rift-ds 1.37.0 → 1.38.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/behaviors/whenProgramLinked.d.ts +26 -0
- package/behaviors/whenProgramLinked.js +22 -0
- package/bin/templates/blocks/components/blocks/AppShell.module.css +6 -1
- package/bin/templates/blocks/components/blocks/AppShell.tsx +1 -0
- package/bin/templates/blocks/components/blocks/DocsShell.tsx +3 -3
- package/components/AppLayout/AppLayout.d.ts +9 -4
- package/components/AppLayout/AppLayout.js +1 -1
- package/components/AppSidebar/AppSidebar.css +197 -11
- package/components/AppSidebar/AppSidebar.d.ts +54 -11
- package/components/AppSidebar/AppSidebar.js +122 -42
- package/components/BottomNav/BottomNav.d.ts +2 -1
- package/components/DrillMenu/DrillMenu.css +302 -0
- package/components/DrillMenu/DrillMenu.d.ts +124 -0
- package/components/DrillMenu/DrillMenu.js +176 -0
- package/components/DrillMenu/path.d.ts +22 -0
- package/components/DrillMenu/path.js +27 -0
- package/components/IconButton/IconButton.css +35 -0
- package/components/IconButton/IconButton.d.ts +8 -0
- package/components/IconButton/IconButton.js +2 -0
- package/components/NavList/NavList.d.ts +30 -111
- package/components/NavList/NavList.js +4 -228
- package/components/ShaderField/useShaderField.js +63 -27
- package/components/ShaderScene/ShaderScene.js +135 -95
- package/components/ShaderScene/renderer.d.ts +15 -3
- package/components/ShaderScene/renderer.js +45 -14
- package/components/{NavList/NavList.css → SideNav/SideNav.css} +95 -85
- package/components/SideNav/SideNav.d.ts +118 -0
- package/components/SideNav/SideNav.js +233 -0
- package/components/SidebarPanel/SidebarPanel.d.ts +21 -54
- package/components/SidebarPanel/SidebarPanel.js +4 -168
- package/components/SiteHeader/SiteHeader.css +66 -30
- package/components/SiteHeader/SiteHeader.d.ts +45 -7
- package/components/SiteHeader/SiteHeader.js +51 -21
- package/components/SiteLayout/SiteLayout.css +7 -7
- package/components/SiteLayout/SiteLayout.d.ts +1 -1
- package/components/{SidebarPanel/SidebarPanel.css → SubNavPanel/SubNavPanel.css} +78 -38
- package/components/SubNavPanel/SubNavPanel.d.ts +63 -0
- package/components/SubNavPanel/SubNavPanel.js +182 -0
- package/components/ThreadPanel/ThreadPanel.css +1 -1
- package/components/registry.d.ts +2 -2
- package/components/registry.json +34 -26
- package/components/registry.json.d.ts +34 -26
- package/components/registry.json.js +1 -1
- package/index.d.ts +3 -1
- package/index.js +8 -2
- package/package.json +1 -1
- package/components/Nav/Nav.css +0 -57
- package/components/Nav/Nav.d.ts +0 -32
- package/components/Nav/Nav.js +0 -23
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { LinkComponent } from '../../behaviors/LinkProvider';
|
|
3
|
+
export interface DrillMenuItem {
|
|
4
|
+
/** Row text. */
|
|
5
|
+
label: string;
|
|
6
|
+
/**
|
|
7
|
+
* Where the row links. On a row with `items` it is the level's landing
|
|
8
|
+
* page instead: the level opens with an overview row linking to it.
|
|
9
|
+
*/
|
|
10
|
+
href?: string;
|
|
11
|
+
/** Stable identity, used in `path`. Defaults to `href`, then `label`. */
|
|
12
|
+
id?: string;
|
|
13
|
+
/** A second line under the label, in the secondary text style. */
|
|
14
|
+
description?: string;
|
|
15
|
+
/** Icon before the label: a Material Symbol name (string) or a custom element, such as a swatch or a brand mark. */
|
|
16
|
+
icon?: string | React.ReactNode;
|
|
17
|
+
/** A pill after the label: a count (a number, or digits with an optional `+`) on the count badge pair, a word such as "New" as a quiet pill. */
|
|
18
|
+
badge?: string | number;
|
|
19
|
+
/** The setting's current value at the row's trailing end, such as "Dark", on a row that drills into a list of choices. */
|
|
20
|
+
value?: string;
|
|
21
|
+
/** The heading of the level this row opens, and the name the back rows below it give that level. Defaults to `label`, for a row whose label is a value (a chosen account) rather than the level's name. */
|
|
22
|
+
title?: string;
|
|
23
|
+
/** Rows on the level this row opens. A row with items drills in instead of navigating. */
|
|
24
|
+
items?: DrillMenuEntry[];
|
|
25
|
+
/**
|
|
26
|
+
* Marks the row as the page being viewed, regardless of the exact match
|
|
27
|
+
* against `currentHref`, for a section that stays current on its child
|
|
28
|
+
* routes.
|
|
29
|
+
*/
|
|
30
|
+
current?: boolean;
|
|
31
|
+
/** On an `onClick` row in a list of choices, whether it is the chosen one: true carries the chosen mark, and either value sets `aria-pressed`. */
|
|
32
|
+
selected?: boolean;
|
|
33
|
+
/** The link leaves the site: it opens in a new tab and carries an outward arrow. */
|
|
34
|
+
external?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Makes the row an action rather than a link, such as a pick or a copy.
|
|
37
|
+
* The menu stays on its level; a choice list's rows set `selected` too.
|
|
38
|
+
*/
|
|
39
|
+
onClick?: (event: React.MouseEvent<HTMLButtonElement>) => void;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* A group of rows under an optional heading: one level's resources or
|
|
43
|
+
* settings, say, set apart from the rows above it.
|
|
44
|
+
*/
|
|
45
|
+
export interface DrillMenuSection {
|
|
46
|
+
/** Marks the entry as a section rather than a row. */
|
|
47
|
+
type: 'section';
|
|
48
|
+
/** The heading over the rows. Leave it out for a group set apart by space alone. */
|
|
49
|
+
label?: string;
|
|
50
|
+
/** The section's rows. */
|
|
51
|
+
items: DrillMenuItem[];
|
|
52
|
+
/**
|
|
53
|
+
* `prominent` draws the rows in the heading-3 style on a taller row, for
|
|
54
|
+
* a menu that wants its top level louder. The site header's and the app
|
|
55
|
+
* sidebar's drawers keep the default rows.
|
|
56
|
+
* @default 'default'
|
|
57
|
+
*/
|
|
58
|
+
variant?: 'default' | 'prominent';
|
|
59
|
+
/** Stable identity for the React key. Defaults to the label. */
|
|
60
|
+
id?: string;
|
|
61
|
+
}
|
|
62
|
+
/** An entry on a level: a row, or a section of rows. */
|
|
63
|
+
export type DrillMenuEntry = DrillMenuItem | DrillMenuSection;
|
|
64
|
+
/** Props owned by DrillMenu itself — everything else falls through to the `<nav>`. */
|
|
65
|
+
type DrillMenuOwnProps = {
|
|
66
|
+
/** The first level's rows and sections. A row with `items` drills into the next level. */
|
|
67
|
+
items: DrillMenuEntry[];
|
|
68
|
+
/** href of the current page: the exactly matching row gets `aria-current="page"` and the current treatment, and every row on the way to it the current treatment. */
|
|
69
|
+
currentHref?: string;
|
|
70
|
+
/** The ids of the rows drilled into, first level first: `[]` is the first level. Pair with `onPathChange`. */
|
|
71
|
+
path?: string[];
|
|
72
|
+
/**
|
|
73
|
+
* The path the menu opens on, when it owns its state. Left out, it opens
|
|
74
|
+
* on the deepest level that holds the current page (`currentHref`, or a
|
|
75
|
+
* row marked `current`), so a reader deep in a section reopens the menu
|
|
76
|
+
* where they are; `[]` opens on the first level always.
|
|
77
|
+
*/
|
|
78
|
+
defaultPath?: string[];
|
|
79
|
+
/** Fires with the new path whenever a row drills in or the back row steps out, in both controlled and uncontrolled modes. */
|
|
80
|
+
onPathChange?: (path: string[]) => void;
|
|
81
|
+
/** Fires when a link row is followed, alongside native navigation, such as to close the drawer the menu sits in. */
|
|
82
|
+
onNavigate?: (item: DrillMenuItem, event: React.MouseEvent<HTMLElement>) => void;
|
|
83
|
+
/** Content above the first level's rows, such as a search field. */
|
|
84
|
+
header?: React.ReactNode;
|
|
85
|
+
/** The back row's text on the second level, naming the first. */
|
|
86
|
+
rootLabel?: string;
|
|
87
|
+
/** The back row's accessible name, given the title of the level it returns to. Defaults to "Back to <title>". */
|
|
88
|
+
backLabel?: (title: string) => string;
|
|
89
|
+
/** The overview row's text on a level whose row has an `href`, given that row's label. Defaults to "<label> overview". */
|
|
90
|
+
overviewLabel?: (label: string) => string;
|
|
91
|
+
/** The accessible name of the `<nav>` landmark. */
|
|
92
|
+
navLabel?: string;
|
|
93
|
+
/**
|
|
94
|
+
* The component its links render with, such as Next.js's `Link`, so they
|
|
95
|
+
* navigate through the app's router. Wins over a LinkProvider's; a plain
|
|
96
|
+
* `<a>` when neither is set.
|
|
97
|
+
*/
|
|
98
|
+
linkComponent?: LinkComponent;
|
|
99
|
+
/** Additional CSS classes. */
|
|
100
|
+
className?: string;
|
|
101
|
+
};
|
|
102
|
+
export interface DrillMenuProps extends DrillMenuOwnProps, Omit<React.ComponentPropsWithRef<'nav'>, keyof DrillMenuOwnProps> {
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* A drill-in menu for a phone: each level fills the space it is given, a
|
|
106
|
+
* row with children opens the next level in its place, and a back row
|
|
107
|
+
* names the level it returns to. Rows are a touch target tall, with an
|
|
108
|
+
* optional icon, a second line, a current value and a trailing chevron,
|
|
109
|
+
* external arrow or chosen mark, every label on one start line. The level
|
|
110
|
+
* changes with a short slide along the reading direction; focus moves to
|
|
111
|
+
* the new level's title, and back to the row it came from on the way out.
|
|
112
|
+
* The path is uncontrolled by default (`defaultPath`) or controlled with
|
|
113
|
+
* `path` and `onPathChange`.
|
|
114
|
+
*/
|
|
115
|
+
export declare function DrillMenu({ items, currentHref, path: pathProp, defaultPath, onPathChange, onNavigate, header, rootLabel, backLabel, overviewLabel, navLabel, linkComponent, className, ref, ...rest }: DrillMenuProps): React.JSX.Element;
|
|
116
|
+
/**
|
|
117
|
+
* Where a DrillMenu will open, given its items and the current page: the
|
|
118
|
+
* ids of the rows down to the deepest level that holds it. A host that
|
|
119
|
+
* shows something only on the first level (as SiteHeader's drawer does its
|
|
120
|
+
* footer) reads it to know where the menu opens. It is part of DrillMenu's
|
|
121
|
+
* published API, so the Fast Refresh rule that wants a component module to
|
|
122
|
+
* export only components does not apply to it, as MaskedInput's helpers.
|
|
123
|
+
*/
|
|
124
|
+
export { drillMenuPathTo } from './path';
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { useState, useRef, useLayoutEffect, useEffect } from "react";
|
|
4
|
+
import { useLinkComponent } from "../../behaviors/LinkProvider.js";
|
|
5
|
+
import { mirrorClass } from "../../behaviors/direction.js";
|
|
6
|
+
import { ChosenMark } from "../Dropdown/Dropdown.js";
|
|
7
|
+
import "../../behaviors/direction.css";
|
|
8
|
+
import { drillMenuPathTo, rowsOf, idOf, isSection, holdsCurrent } from "./path.js";
|
|
9
|
+
import "./DrillMenu.css";
|
|
10
|
+
import "../../fonts/material-symbols.css";
|
|
11
|
+
const isCount = (badge) => typeof badge === "number" || /^\d+\+?$/.test(badge);
|
|
12
|
+
function DrillMenu({
|
|
13
|
+
items,
|
|
14
|
+
currentHref,
|
|
15
|
+
path: pathProp,
|
|
16
|
+
defaultPath,
|
|
17
|
+
onPathChange,
|
|
18
|
+
onNavigate,
|
|
19
|
+
header,
|
|
20
|
+
rootLabel = "Menu",
|
|
21
|
+
backLabel = (title) => `Back to ${title}`,
|
|
22
|
+
overviewLabel = (label) => `${label} overview`,
|
|
23
|
+
navLabel = "Menu",
|
|
24
|
+
linkComponent,
|
|
25
|
+
className = "",
|
|
26
|
+
ref,
|
|
27
|
+
...rest
|
|
28
|
+
}) {
|
|
29
|
+
const Link = useLinkComponent(linkComponent);
|
|
30
|
+
const [ownPath, setOwnPath] = useState(() => defaultPath ?? drillMenuPathTo(items, currentHref));
|
|
31
|
+
const path = pathProp ?? ownPath;
|
|
32
|
+
const [direction, setDirection] = useState(null);
|
|
33
|
+
const titleRef = useRef(null);
|
|
34
|
+
const levelRef = useRef(null);
|
|
35
|
+
const returnTo = useRef(null);
|
|
36
|
+
const trail = [];
|
|
37
|
+
let entries = items;
|
|
38
|
+
for (const id of path) {
|
|
39
|
+
const next = rowsOf(entries).find((row) => idOf(row) === id && row.items);
|
|
40
|
+
if (!next) break;
|
|
41
|
+
trail.push(next);
|
|
42
|
+
entries = next.items;
|
|
43
|
+
}
|
|
44
|
+
const level = trail[trail.length - 1];
|
|
45
|
+
const parent = trail[trail.length - 2];
|
|
46
|
+
const setPath = (next) => {
|
|
47
|
+
if (pathProp === void 0) setOwnPath(next);
|
|
48
|
+
onPathChange?.(next);
|
|
49
|
+
};
|
|
50
|
+
const settle = (from) => {
|
|
51
|
+
const nav = from.closest(".ds-drill-menu");
|
|
52
|
+
if (!nav) return;
|
|
53
|
+
nav.setAttribute("data-settling", "");
|
|
54
|
+
const done = () => {
|
|
55
|
+
nav.removeAttribute("data-settling");
|
|
56
|
+
nav.removeEventListener("pointermove", done);
|
|
57
|
+
};
|
|
58
|
+
nav.addEventListener("pointermove", done);
|
|
59
|
+
};
|
|
60
|
+
const drillIn = (item) => {
|
|
61
|
+
setDirection("in");
|
|
62
|
+
returnTo.current = null;
|
|
63
|
+
setPath([...trail.map(idOf), idOf(item)]);
|
|
64
|
+
};
|
|
65
|
+
const stepOut = () => {
|
|
66
|
+
setDirection("out");
|
|
67
|
+
returnTo.current = level ? idOf(level) : null;
|
|
68
|
+
setPath(trail.slice(0, -1).map(idOf));
|
|
69
|
+
};
|
|
70
|
+
useLayoutEffect(() => {
|
|
71
|
+
if (direction === null) return;
|
|
72
|
+
const back = returnTo.current;
|
|
73
|
+
const row = back ? levelRef.current?.querySelector(`[data-drill-menu-id="${CSS.escape(back)}"]`) : null;
|
|
74
|
+
(row ?? titleRef.current ?? levelRef.current?.querySelector("a, button"))?.focus();
|
|
75
|
+
}, [trail.length]);
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
if (direction === null) return;
|
|
78
|
+
for (let node = levelRef.current?.parentElement; node; node = node.parentElement) {
|
|
79
|
+
const { overflowY } = getComputedStyle(node);
|
|
80
|
+
if ((overflowY === "auto" || overflowY === "scroll") && node.scrollHeight > node.clientHeight) {
|
|
81
|
+
node.scrollTo({ top: 0 });
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}, [trail.length]);
|
|
86
|
+
const renderRow = (item, variant = "default") => {
|
|
87
|
+
const id = idOf(item);
|
|
88
|
+
const drills = Boolean(item.items);
|
|
89
|
+
const isCurrent = holdsCurrent(item, currentHref);
|
|
90
|
+
const exact = !drills && (item.current || currentHref != null && item.href === currentHref);
|
|
91
|
+
const classes = [
|
|
92
|
+
"ds-drill-menu__row",
|
|
93
|
+
variant === "prominent" && "ds-drill-menu__row--prominent",
|
|
94
|
+
isCurrent && "ds-drill-menu__row--current"
|
|
95
|
+
].filter(Boolean).join(" ");
|
|
96
|
+
const trailing = drills ? /* @__PURE__ */ jsx("span", { className: "ds-drill-menu__chevron material-symbols-rounded ds-mirror-rtl", "aria-hidden": "true", children: "chevron_right" }) : item.selected ? /* @__PURE__ */ jsx(ChosenMark, { className: "ds-drill-menu__chosen" }) : item.external ? /* @__PURE__ */ jsx("span", { className: "ds-drill-menu__external material-symbols-rounded", "aria-hidden": "true", children: "arrow_outward" }) : null;
|
|
97
|
+
const body = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
98
|
+
item.icon != null && /* @__PURE__ */ jsx("span", { className: "ds-drill-menu__icon", "aria-hidden": "true", children: typeof item.icon === "string" ? /* @__PURE__ */ jsx("span", { className: `material-symbols-rounded ${mirrorClass(item.icon)}`, children: item.icon }) : item.icon }),
|
|
99
|
+
/* @__PURE__ */ jsxs("span", { className: "ds-drill-menu__text", children: [
|
|
100
|
+
/* @__PURE__ */ jsx("span", { className: "ds-drill-menu__label", children: item.label }),
|
|
101
|
+
item.description && /* @__PURE__ */ jsx("span", { className: "ds-drill-menu__description", children: item.description })
|
|
102
|
+
] }),
|
|
103
|
+
item.badge !== void 0 && /* @__PURE__ */ jsx("span", { className: `ds-drill-menu__badge${isCount(item.badge) ? " ds-drill-menu__badge--count" : ""}`, children: item.badge }),
|
|
104
|
+
item.value && /* @__PURE__ */ jsx("span", { className: "ds-drill-menu__value", children: item.value }),
|
|
105
|
+
trailing && /* @__PURE__ */ jsx("span", { className: "ds-drill-menu__trail", children: trailing })
|
|
106
|
+
] });
|
|
107
|
+
if (drills || item.onClick || !item.href) {
|
|
108
|
+
return /* @__PURE__ */ jsx("li", { className: "ds-drill-menu__item", children: /* @__PURE__ */ jsx(
|
|
109
|
+
"button",
|
|
110
|
+
{
|
|
111
|
+
type: "button",
|
|
112
|
+
className: classes,
|
|
113
|
+
"data-drill-menu-id": id,
|
|
114
|
+
"aria-pressed": item.selected !== void 0 && !drills ? item.selected : void 0,
|
|
115
|
+
onClick: (event) => {
|
|
116
|
+
if (drills) {
|
|
117
|
+
settle(event.currentTarget);
|
|
118
|
+
drillIn(item);
|
|
119
|
+
} else item.onClick?.(event);
|
|
120
|
+
},
|
|
121
|
+
children: body
|
|
122
|
+
}
|
|
123
|
+
) }, id);
|
|
124
|
+
}
|
|
125
|
+
return /* @__PURE__ */ jsx("li", { className: "ds-drill-menu__item", children: /* @__PURE__ */ jsx(
|
|
126
|
+
Link,
|
|
127
|
+
{
|
|
128
|
+
href: item.href,
|
|
129
|
+
className: classes,
|
|
130
|
+
"data-drill-menu-id": id,
|
|
131
|
+
"aria-current": exact ? "page" : void 0,
|
|
132
|
+
...item.external ? { target: "_blank", rel: "noopener noreferrer" } : {},
|
|
133
|
+
onClick: (event) => onNavigate?.(item, event),
|
|
134
|
+
children: body
|
|
135
|
+
}
|
|
136
|
+
) }, id);
|
|
137
|
+
};
|
|
138
|
+
const groups = [];
|
|
139
|
+
entries.forEach((entry, index) => {
|
|
140
|
+
if (isSection(entry)) groups.push({ key: entry.id ?? entry.label ?? `section-${index}`, section: entry, rows: entry.items });
|
|
141
|
+
else {
|
|
142
|
+
const last = groups[groups.length - 1];
|
|
143
|
+
if (last && !last.section) last.rows.push(entry);
|
|
144
|
+
else groups.push({ key: `rows-${index}`, rows: [entry] });
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
return /* @__PURE__ */ jsx("nav", { ...rest, ref, "aria-label": navLabel, className: ["ds-drill-menu", className].filter(Boolean).join(" "), children: /* @__PURE__ */ jsxs(
|
|
148
|
+
"div",
|
|
149
|
+
{
|
|
150
|
+
ref: levelRef,
|
|
151
|
+
className: ["ds-drill-menu__level", direction && `ds-drill-menu__level--${direction}`].filter(Boolean).join(" "),
|
|
152
|
+
children: [
|
|
153
|
+
level ? /* @__PURE__ */ jsxs("div", { className: "ds-drill-menu__head", children: [
|
|
154
|
+
/* @__PURE__ */ jsxs("button", { type: "button", className: "ds-drill-menu__back", "aria-label": backLabel(parent ? parent.title ?? parent.label : rootLabel), onClick: (event) => {
|
|
155
|
+
settle(event.currentTarget);
|
|
156
|
+
stepOut();
|
|
157
|
+
}, children: [
|
|
158
|
+
/* @__PURE__ */ jsx("span", { className: "ds-drill-menu__back-chevron material-symbols-rounded ds-mirror-rtl", "aria-hidden": "true", children: "chevron_left" }),
|
|
159
|
+
/* @__PURE__ */ jsx("span", { children: parent ? parent.title ?? parent.label : rootLabel })
|
|
160
|
+
] }),
|
|
161
|
+
/* @__PURE__ */ jsx("h2", { ref: titleRef, tabIndex: -1, className: "ds-drill-menu__title", children: level.title ?? level.label })
|
|
162
|
+
] }) : header && /* @__PURE__ */ jsx("div", { className: "ds-drill-menu__header", children: header }),
|
|
163
|
+
level?.href && /* @__PURE__ */ jsx("ul", { className: "ds-drill-menu__list", children: renderRow({ label: overviewLabel(level.label), href: level.href, icon: level.icon, id: `${idOf(level)}#overview` }) }),
|
|
164
|
+
groups.map(({ key, section, rows }) => /* @__PURE__ */ jsxs("section", { className: "ds-drill-menu__section", children: [
|
|
165
|
+
section?.label && /* @__PURE__ */ jsx("h3", { className: "ds-drill-menu__section-label", children: section.label }),
|
|
166
|
+
/* @__PURE__ */ jsx("ul", { className: "ds-drill-menu__list", children: rows.map((item) => renderRow(item, section?.variant)) })
|
|
167
|
+
] }, key))
|
|
168
|
+
]
|
|
169
|
+
},
|
|
170
|
+
trail.map(idOf).join("/") || "root"
|
|
171
|
+
) });
|
|
172
|
+
}
|
|
173
|
+
export {
|
|
174
|
+
DrillMenu,
|
|
175
|
+
drillMenuPathTo
|
|
176
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { DrillMenuEntry, DrillMenuItem, DrillMenuSection } from './DrillMenu';
|
|
2
|
+
/**
|
|
3
|
+
* The walks DrillMenu takes over its tree, apart from the component so a
|
|
4
|
+
* host can read the same answers: which row is which, which rows hold the
|
|
5
|
+
* current page, and where the menu opens. `drillMenuPathTo` is published
|
|
6
|
+
* from the DrillMenu module; the rest stay internal.
|
|
7
|
+
*/
|
|
8
|
+
export declare const isSection: (entry: DrillMenuEntry) => entry is DrillMenuSection;
|
|
9
|
+
/** A row's id in a path: its `id`, else its `href`, else its label. */
|
|
10
|
+
export declare const idOf: (item: DrillMenuItem) => string;
|
|
11
|
+
/** The rows a level lists, sections opened up. */
|
|
12
|
+
export declare const rowsOf: (entries: DrillMenuEntry[]) => DrillMenuItem[];
|
|
13
|
+
/** Whether a row is the current page, or holds it somewhere below. */
|
|
14
|
+
export declare function holdsCurrent(item: DrillMenuItem, currentHref?: string): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* The path to the deepest level that holds the current page: each row on
|
|
17
|
+
* the way drills in and holds it (it is `current`, its `href` is
|
|
18
|
+
* `currentHref`, or a row below it is). DrillMenu opens there when it is
|
|
19
|
+
* given no `defaultPath`; a host that shows something only on the first
|
|
20
|
+
* level reads the same path to know where the menu will open.
|
|
21
|
+
*/
|
|
22
|
+
export declare function drillMenuPathTo(items: DrillMenuEntry[], currentHref?: string): string[];
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const isSection = (entry) => entry.type === "section";
|
|
2
|
+
const idOf = (item) => item.id ?? item.href ?? item.label;
|
|
3
|
+
const rowsOf = (entries) => entries.flatMap((entry) => isSection(entry) ? entry.items : [entry]);
|
|
4
|
+
function holdsCurrent(item, currentHref) {
|
|
5
|
+
if (item.current) return true;
|
|
6
|
+
if (currentHref && item.href === currentHref) return true;
|
|
7
|
+
return (item.items ?? []).some(
|
|
8
|
+
(entry) => isSection(entry) ? entry.items.some((child) => holdsCurrent(child, currentHref)) : holdsCurrent(entry, currentHref)
|
|
9
|
+
);
|
|
10
|
+
}
|
|
11
|
+
function drillMenuPathTo(items, currentHref) {
|
|
12
|
+
const path = [];
|
|
13
|
+
let entries = items;
|
|
14
|
+
for (; ; ) {
|
|
15
|
+
const next = rowsOf(entries).find((row) => row.items?.length && holdsCurrent(row, currentHref));
|
|
16
|
+
if (!next) return path;
|
|
17
|
+
path.push(idOf(next));
|
|
18
|
+
entries = next.items;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export {
|
|
22
|
+
drillMenuPathTo,
|
|
23
|
+
holdsCurrent,
|
|
24
|
+
idOf,
|
|
25
|
+
isSection,
|
|
26
|
+
rowsOf
|
|
27
|
+
};
|
|
@@ -442,4 +442,39 @@
|
|
|
442
442
|
padding: 0;
|
|
443
443
|
}
|
|
444
444
|
|
|
445
|
+
/* ============================================
|
|
446
|
+
GLASS
|
|
447
|
+
Button's glass, on the icon-only form: the button frosts what is behind
|
|
448
|
+
it, with the floating surfaces' blur. An outlined or ghost cell takes
|
|
449
|
+
the glass fill at rest; a filled cell keeps its colour and lets a little
|
|
450
|
+
of the ground through it. These rest rules carry two classes, so every
|
|
451
|
+
pointer hover and press rule above (three) still fills the button
|
|
452
|
+
solid, and the documentation-only state classes are left out through
|
|
453
|
+
:where(), which adds no weight.
|
|
454
|
+
============================================ */
|
|
455
|
+
|
|
456
|
+
.ds-icon-button--glass {
|
|
457
|
+
-webkit-backdrop-filter: blur(24px);
|
|
458
|
+
backdrop-filter: blur(24px);
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
.ds-icon-button--glass.ds-icon-button--secondary:where(:not(.ds-icon-button--hover, .ds-icon-button--active)),
|
|
462
|
+
.ds-icon-button--glass.ds-icon-button--secondary-neutral:where(:not(.ds-icon-button--hover, .ds-icon-button--active)),
|
|
463
|
+
.ds-icon-button--glass.ds-icon-button--tertiary:where(:not(.ds-icon-button--hover, .ds-icon-button--active)),
|
|
464
|
+
.ds-icon-button--glass.ds-icon-button--destructive:where(:not(.ds-icon-button--hover, .ds-icon-button--active)) {
|
|
465
|
+
background-color: var(--color-bg-glass);
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
.ds-icon-button--glass.ds-icon-button--primary:where(:not(.ds-icon-button--hover, .ds-icon-button--active)) {
|
|
469
|
+
background-color: color-mix(in srgb, var(--color-action-primary-bg) 72%, transparent);
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
.ds-icon-button--glass.ds-icon-button--neutral:where(:not(.ds-icon-button--hover, .ds-icon-button--active)) {
|
|
473
|
+
background-color: color-mix(in srgb, var(--color-action-neutral-bg) 72%, transparent);
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
.ds-icon-button--glass.ds-icon-button--primary-destructive:where(:not(.ds-icon-button--hover, .ds-icon-button--active)) {
|
|
477
|
+
background-color: color-mix(in srgb, var(--color-action-destructive-bg) 72%, transparent);
|
|
478
|
+
}
|
|
479
|
+
|
|
445
480
|
} /* @layer rift.components */
|
|
@@ -45,6 +45,14 @@ type IconButtonOwnProps = {
|
|
|
45
45
|
* the disabled state) and sets `aria-busy` on the rendered element.
|
|
46
46
|
*/
|
|
47
47
|
loading?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Frosts the button for a busy ground (a shader, a photo, a map), as
|
|
50
|
+
* Button's `glass` does: the page behind it is blurred, an outlined or
|
|
51
|
+
* ghost button takes the glass fill at rest and a filled one lets a
|
|
52
|
+
* little of the ground through its colour. Hover and press are the
|
|
53
|
+
* variant's own. Works on every `variant` and `tone`.
|
|
54
|
+
*/
|
|
55
|
+
glass?: boolean;
|
|
48
56
|
/**
|
|
49
57
|
* The button's name: what a screen reader announces and, by default, what
|
|
50
58
|
* the tooltip shows. Required, because the button has no visible text.
|
|
@@ -27,6 +27,7 @@ const IconButton = React.forwardRef(
|
|
|
27
27
|
state,
|
|
28
28
|
size = "default",
|
|
29
29
|
loading,
|
|
30
|
+
glass,
|
|
30
31
|
label,
|
|
31
32
|
tooltip,
|
|
32
33
|
tooltipPosition = "top",
|
|
@@ -54,6 +55,7 @@ const IconButton = React.forwardRef(
|
|
|
54
55
|
`${baseClass}--${resolvedState}`,
|
|
55
56
|
`${baseClass}--${size}`,
|
|
56
57
|
isLoading && `${baseClass}--loading`,
|
|
58
|
+
glass && `${baseClass}--glass`,
|
|
57
59
|
badge !== void 0 && `${baseClass}--badged`,
|
|
58
60
|
className
|
|
59
61
|
].filter(Boolean).join(" ");
|
|
@@ -1,117 +1,36 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
export interface NavListItem {
|
|
4
|
-
/** Row text. */
|
|
5
|
-
label: string;
|
|
6
|
-
/** Link destination — every row is a real link. */
|
|
7
|
-
href: string;
|
|
8
|
-
/** Stable identity for expansion state and aria wiring. Defaults to `href`. */
|
|
9
|
-
id?: string;
|
|
10
|
-
/** Child rows, indented one level. Nesting is supported three levels deep. */
|
|
11
|
-
items?: NavListItem[];
|
|
12
|
-
/**
|
|
13
|
-
* When false, an item with children renders no toggle and its children stay
|
|
14
|
-
* visible — a permanent group rather than a collapsible section.
|
|
15
|
-
* @default true
|
|
16
|
-
*/
|
|
17
|
-
collapsible?: boolean;
|
|
18
|
-
/**
|
|
19
|
-
* Forces the current-page treatment on this row regardless of the exact
|
|
20
|
-
* match against `currentHref` — for prefix-matched sections that should
|
|
21
|
-
* stay current on their child routes.
|
|
22
|
-
*/
|
|
23
|
-
current?: boolean;
|
|
24
|
-
/** A short tag after the label, such as "New" or "Beta", drawn as a neutral Badge. */
|
|
25
|
-
badge?: string;
|
|
26
|
-
/** Icon before the label — Material Symbol name (string) or custom element (ReactNode) */
|
|
27
|
-
icon?: string | React.ReactNode;
|
|
28
|
-
}
|
|
2
|
+
import { SideNavEntry, SideNavItem, SideNavProps, SideNavSection } from '../SideNav/SideNav';
|
|
29
3
|
/**
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
4
|
+
* Props of the deprecated NavList: SideNav's.
|
|
5
|
+
*
|
|
6
|
+
* @deprecated Use `SideNavProps`.
|
|
7
|
+
*/
|
|
8
|
+
export type NavListProps = SideNavProps;
|
|
9
|
+
/**
|
|
10
|
+
* A link row of the deprecated NavList: SideNav's.
|
|
11
|
+
*
|
|
12
|
+
* @deprecated Use `SideNavItem`.
|
|
13
|
+
*/
|
|
14
|
+
export type NavListItem = SideNavItem;
|
|
15
|
+
/**
|
|
16
|
+
* A titled group of the deprecated NavList: SideNav's.
|
|
17
|
+
*
|
|
18
|
+
* @deprecated Use `SideNavSection`.
|
|
19
|
+
*/
|
|
20
|
+
export type NavListSection = SideNavSection;
|
|
21
|
+
/**
|
|
22
|
+
* An entry of the deprecated NavList: SideNav's.
|
|
23
|
+
*
|
|
24
|
+
* @deprecated Use `SideNavEntry`.
|
|
33
25
|
*/
|
|
34
|
-
export
|
|
35
|
-
/** Marks the entry as a section rather than a row. */
|
|
36
|
-
type: 'section';
|
|
37
|
-
/** The section's heading. */
|
|
38
|
-
label: string;
|
|
39
|
-
/** The section's rows. */
|
|
40
|
-
items: NavListItem[];
|
|
41
|
-
/**
|
|
42
|
-
* Stable identity for its expansion state. Defaults to the label. In
|
|
43
|
-
* `expandedIds`, `defaultExpandedIds` and `onExpandedChange` a section
|
|
44
|
-
* appears as `section:<id>`, so its id never collides with a row's.
|
|
45
|
-
*/
|
|
46
|
-
id?: string;
|
|
47
|
-
/**
|
|
48
|
-
* Let the reader fold the section under its heading. Unlike a row with
|
|
49
|
-
* `items`, which folds unless told not to, a section is a plain label
|
|
50
|
-
* unless told to fold.
|
|
51
|
-
* @default false
|
|
52
|
-
*/
|
|
53
|
-
collapsible?: boolean;
|
|
54
|
-
}
|
|
55
|
-
/** A top-level entry: a row, or a section of rows. */
|
|
56
|
-
export type NavListEntry = NavListItem | NavListSection;
|
|
57
|
-
/** Props owned by NavList itself — everything else falls through to the list element. */
|
|
58
|
-
type NavListOwnProps = {
|
|
59
|
-
/** Navigation tree to render: rows, and at the top level, sections of rows. */
|
|
60
|
-
items: NavListEntry[];
|
|
61
|
-
/**
|
|
62
|
-
* Row density. `default` is the drawer's 40px top row; `compact` sets
|
|
63
|
-
* every row on the 32px compact control height, for a long sidebar of
|
|
64
|
-
* pages (a documentation site's hundred entries).
|
|
65
|
-
*/
|
|
66
|
-
size?: 'default' | 'compact';
|
|
67
|
-
/**
|
|
68
|
-
* Make the list its own scroll area: it fills the height its parent
|
|
69
|
-
* gives it, scrolls inside without carrying the page along at its ends,
|
|
70
|
-
* and brings the current row into view when it first renders. Put it in
|
|
71
|
-
* a column with a fixed or sticky height.
|
|
72
|
-
*/
|
|
73
|
-
scrollable?: boolean;
|
|
74
|
-
/** href of the current page — the exactly matching row gets `aria-current="page"` and the active treatment. */
|
|
75
|
-
currentHref?: string;
|
|
76
|
-
/** Controlled list of expanded item ids. */
|
|
77
|
-
expandedIds?: string[];
|
|
78
|
-
/**
|
|
79
|
-
* Initially expanded item ids (uncontrolled). The branch and the
|
|
80
|
-
* collapsible section that hold the current page start open as well, so a
|
|
81
|
-
* reader landing deep in a long tree sees where they are.
|
|
82
|
-
*/
|
|
83
|
-
defaultExpandedIds?: string[];
|
|
84
|
-
/** Fires with the full new list of expanded ids whenever a toggle is pressed, in both controlled and uncontrolled modes. */
|
|
85
|
-
onExpandedChange?: (expandedIds: string[]) => void;
|
|
86
|
-
/** Allow several branches expanded at once. Default false: expanding one collapses its siblings, never the section or the rows it sits in. */
|
|
87
|
-
multiple?: boolean;
|
|
88
|
-
/** Fires when any link is clicked, alongside native navigation — e.g. to close the drawer that contains the list. */
|
|
89
|
-
onNavigate?: (item: NavListItem, event: React.MouseEvent<HTMLElement>) => void;
|
|
90
|
-
/** Accessible name of a collapsed row's or section's toggle, given its label. Defaults to "Expand <label>". */
|
|
91
|
-
expandLabel?: (label: string) => string;
|
|
92
|
-
/** Accessible name of an expanded row's or section's toggle, given its label. Defaults to "Collapse <label>". */
|
|
93
|
-
collapseLabel?: (label: string) => string;
|
|
94
|
-
/**
|
|
95
|
-
* The component its links render with, such as Next.js's `Link`, so they
|
|
96
|
-
* navigate through the app's router; passed on to each row's Button. Wins over a
|
|
97
|
-
* LinkProvider's; a plain `<a>` when neither is set.
|
|
98
|
-
*/
|
|
99
|
-
linkComponent?: LinkComponent;
|
|
100
|
-
/** Additional CSS classes */
|
|
101
|
-
className?: string;
|
|
102
|
-
};
|
|
103
|
-
export interface NavListProps extends NavListOwnProps, Omit<React.ComponentPropsWithoutRef<'ul'>, keyof NavListOwnProps> {
|
|
104
|
-
}
|
|
26
|
+
export type NavListEntry = SideNavEntry;
|
|
105
27
|
/**
|
|
106
|
-
*
|
|
28
|
+
* SideNav under its old name. It renders the same list and adds the old
|
|
29
|
+
* `ds-nav-list` base class beside the new one, so a rule written against
|
|
30
|
+
* the base still matches. The old modifier and element classes are gone: a
|
|
31
|
+
* rule written against one moves to its `ds-side-nav` twin.
|
|
107
32
|
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
* An item with children gets a separate chevron toggle — tapping the label
|
|
111
|
-
* navigates, tapping the chevron expands — and collapsed sublists are `inert`,
|
|
112
|
-
* so they leave the tab order and the accessibility tree. Expansion is
|
|
113
|
-
* uncontrolled by default (`defaultExpandedIds`) or controlled via
|
|
114
|
-
* `expandedIds` + `onExpandedChange`.
|
|
33
|
+
* @deprecated Use `SideNav`. The list was renamed for what it is: a site's
|
|
34
|
+
* side navigation.
|
|
115
35
|
*/
|
|
116
|
-
export declare const NavList: React.ForwardRefExoticComponent<
|
|
117
|
-
export {};
|
|
36
|
+
export declare const NavList: React.ForwardRefExoticComponent<SideNavProps & React.RefAttributes<HTMLUListElement>>;
|