oneslash-design-system 2.25.0 → 2.27.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/dist/cases/message-attachments.md +3 -0
- package/dist/cases/on-this-page.md +2 -0
- package/dist/cases/side-pane.md +1 -0
- package/dist/cases.json +6 -0
- package/dist/components/accordion.d.ts +6 -0
- package/dist/components/accordion.jsx +11 -4
- package/dist/components/alert.d.ts +3 -1
- package/dist/components/alert.jsx +5 -5
- package/dist/components/appShell.jsx +5 -2
- package/dist/components/avatarStack.d.ts +3 -1
- package/dist/components/avatarStack.jsx +2 -2
- package/dist/components/codeBlock.d.ts +7 -2
- package/dist/components/codeBlock.jsx +5 -3
- package/dist/components/composer.d.ts +29 -0
- package/dist/components/composer.jsx +19 -5
- package/dist/components/dropZone.jsx +5 -64
- package/dist/components/fileChip.d.ts +9 -1
- package/dist/components/fileChip.jsx +16 -3
- package/dist/components/heading.d.ts +2 -2
- package/dist/components/heading.jsx +1 -0
- package/dist/components/image.d.ts +3 -1
- package/dist/components/image.jsx +3 -2
- package/dist/components/list.d.ts +15 -1
- package/dist/components/list.jsx +8 -3
- package/dist/components/menuItem.d.ts +22 -4
- package/dist/components/menuItem.jsx +16 -8
- package/dist/components/onThisPage.d.ts +14 -3
- package/dist/components/onThisPage.jsx +72 -8
- package/dist/components/paragraph.d.ts +10 -3
- package/dist/components/paragraph.jsx +7 -5
- package/dist/components/popover.d.ts +32 -2
- package/dist/components/popover.jsx +56 -12
- package/dist/components/sidePane.d.ts +20 -0
- package/dist/components/sidePane.jsx +4 -4
- package/dist/components/sourceCard.d.ts +6 -0
- package/dist/components/sourceCard.jsx +2 -2
- package/dist/components/textField.d.ts +6 -2
- package/dist/components/textField.jsx +9 -3
- package/dist/components/titleBar.d.ts +9 -2
- package/dist/components/titleBar.jsx +11 -7
- package/dist/internal/dropZone.d.ts +23 -0
- package/dist/internal/dropZone.js +71 -1
- package/dist/stories/Accordion.stories.d.ts +1 -0
- package/dist/stories/Accordion.stories.jsx +18 -1
- package/dist/stories/Alert.stories.d.ts +1 -0
- package/dist/stories/Alert.stories.jsx +14 -0
- package/dist/stories/AppShell.stories.d.ts +1 -0
- package/dist/stories/AppShell.stories.jsx +17 -0
- package/dist/stories/AvatarStack.stories.d.ts +1 -0
- package/dist/stories/AvatarStack.stories.jsx +4 -0
- package/dist/stories/CodeBlock.stories.d.ts +1 -0
- package/dist/stories/CodeBlock.stories.jsx +11 -0
- package/dist/stories/Composer.stories.d.ts +4 -0
- package/dist/stories/Composer.stories.jsx +41 -0
- package/dist/stories/FileChip.stories.d.ts +2 -0
- package/dist/stories/FileChip.stories.jsx +27 -0
- package/dist/stories/Heading.stories.d.ts +1 -0
- package/dist/stories/Heading.stories.jsx +4 -0
- package/dist/stories/Image.stories.d.ts +1 -0
- package/dist/stories/Image.stories.jsx +4 -0
- package/dist/stories/List.stories.d.ts +2 -0
- package/dist/stories/List.stories.jsx +6 -0
- package/dist/stories/MenuItem.stories.d.ts +4 -0
- package/dist/stories/MenuItem.stories.jsx +63 -0
- package/dist/stories/OnThisPage.stories.d.ts +1 -0
- package/dist/stories/OnThisPage.stories.jsx +11 -0
- package/dist/stories/Paragraph.stories.d.ts +7 -0
- package/dist/stories/Paragraph.stories.jsx +30 -0
- package/dist/stories/Popover.stories.d.ts +4 -0
- package/dist/stories/Popover.stories.jsx +123 -0
- package/dist/stories/SidePane.stories.d.ts +2 -0
- package/dist/stories/SidePane.stories.jsx +34 -1
- package/dist/stories/SourceCard.stories.d.ts +1 -0
- package/dist/stories/SourceCard.stories.jsx +17 -1
- package/dist/stories/TextField.stories.d.ts +1 -0
- package/dist/stories/TextField.stories.jsx +19 -0
- package/dist/stories/TitleBar.stories.d.ts +1 -0
- package/dist/stories/TitleBar.stories.jsx +13 -0
- package/package.json +1 -1
package/dist/components/list.jsx
CHANGED
|
@@ -7,10 +7,15 @@ var markers = { dot: 'list-disc pl-xlarge', number: 'list-decimal pl-xlarge' };
|
|
|
7
7
|
// A list, one line of text per item, a little apart. `marker` puts a dot or a
|
|
8
8
|
// number before each item; numbers use an <ol>.
|
|
9
9
|
export default function List(_a) {
|
|
10
|
-
var items = _a.items, _b = _a.size, size = _b === void 0 ? 'body2' : _b, _c = _a.tone, tone = _c === void 0 ? 'primary' : _c, _d = _a.marker, marker = _d === void 0 ? 'none' : _d, _e = _a.className, className = _e === void 0 ? '' : _e;
|
|
10
|
+
var items = _a.items, _b = _a.size, size = _b === void 0 ? 'body2' : _b, _c = _a.tone, tone = _c === void 0 ? 'primary' : _c, _d = _a.marker, marker = _d === void 0 ? 'none' : _d, _e = _a.className, className = _e === void 0 ? '' : _e, start = _a.start, itemProps = _a.itemProps;
|
|
11
11
|
var Tag = marker === 'number' ? 'ol' : 'ul';
|
|
12
12
|
var markerClass = marker === 'none' ? '' : "".concat(markers[marker], " ");
|
|
13
|
-
return (<Tag className={"flex flex-col gap-medium ".concat(markerClass).concat(sizes[size], " ").concat(tones[tone], " ").concat(className)}>
|
|
14
|
-
{items.map(function (item, i) {
|
|
13
|
+
return (<Tag {...(marker === 'number' ? { start: start } : undefined)} className={"flex flex-col gap-medium ".concat(markerClass).concat(sizes[size], " ").concat(tones[tone], " ").concat(className)}>
|
|
14
|
+
{items.map(function (item, i) {
|
|
15
|
+
var _a, _b;
|
|
16
|
+
return (<li key={i} id={(_a = itemProps === null || itemProps === void 0 ? void 0 : itemProps[i]) === null || _a === void 0 ? void 0 : _a.id} className={(_b = itemProps === null || itemProps === void 0 ? void 0 : itemProps[i]) === null || _b === void 0 ? void 0 : _b.className}>
|
|
17
|
+
{item}
|
|
18
|
+
</li>);
|
|
19
|
+
})}
|
|
15
20
|
</Tag>);
|
|
16
21
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
interface MenuItemProps {
|
|
3
|
-
/** Renders the row as a link. The link has no `role`, so a navigable Menu's arrow keys skip it: use `onClick` items there. */
|
|
3
|
+
/** Renders the row as a link. The link has no `role`, so a navigable Menu's arrow keys skip it: use `onClick` items there. Ignored while `disabled`. */
|
|
4
4
|
href?: string;
|
|
5
5
|
iconName?: string;
|
|
6
6
|
icon?: React.ReactNode;
|
|
@@ -9,6 +9,11 @@ interface MenuItemProps {
|
|
|
9
9
|
label: string;
|
|
10
10
|
secondLabel?: string;
|
|
11
11
|
isSelected?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Runs once when the row is chosen, by a click, Enter or Space. With `href` it goes on the `<a>`, so Enter on
|
|
14
|
+
* the focused link runs it too (Space does not press a link), `event.currentTarget` is the `<a>`, and
|
|
15
|
+
* `event.preventDefault()` stops the navigation. A press in `rightAction` does not run it. Not called while `disabled`.
|
|
16
|
+
*/
|
|
12
17
|
onClick?: any;
|
|
13
18
|
className?: string;
|
|
14
19
|
size?: 'tiny' | 'small' | 'medium';
|
|
@@ -40,8 +45,21 @@ interface MenuItemProps {
|
|
|
40
45
|
'aria-label'?: string;
|
|
41
46
|
/** For a row that shows or hides others (a group of places): whether they are shown. Use with `role="button"`. On a link it goes on the `<a>`. */
|
|
42
47
|
'aria-expanded'?: boolean;
|
|
43
|
-
/**
|
|
44
|
-
|
|
48
|
+
/**
|
|
49
|
+
* `2` indents the row one step, for a place inside another place. `3` indents it two steps, only for a place
|
|
50
|
+
* inside a level 2 place. Nothing goes deeper. Default 1. The indent is visual only and a screen reader does
|
|
51
|
+
* not hear it, so the names or the order must still make sense without it.
|
|
52
|
+
*/
|
|
53
|
+
level?: 1 | 2 | 3;
|
|
54
|
+
/**
|
|
55
|
+
* The row cannot be chosen now. Default false. It is dimmed, has `aria-disabled="true"` and tabIndex -1 (in
|
|
56
|
+
* place of any `tabIndex`), so Tab and a navigable Menu's arrow keys skip it. `onClick` is not called, by a
|
|
57
|
+
* click, Enter or Space. `href` is ignored: there is no link, and `role` and the `aria-*` props go on the row.
|
|
58
|
+
* A selected row keeps its fill. `AppShell`'s phone menu stays open on a press. Disable `rightAction` yourself.
|
|
59
|
+
* A person cannot reach the row with Tab to learn why: when they need to know, keep it pressable and say why
|
|
60
|
+
* on press, or show the reason in text they can see.
|
|
61
|
+
*/
|
|
62
|
+
disabled?: boolean;
|
|
45
63
|
}
|
|
46
|
-
export default function MenuItem({ href, iconName, icon, userHandle, userImgUrl, label, secondLabel, isSelected, onClick, className, size, tag, iconRight, rightAction, role, id, isActive, 'aria-selected': ariaSelected, tabIndex, color, 'aria-current': ariaCurrent, 'aria-label': ariaLabel, 'aria-expanded': ariaExpanded, level, }: MenuItemProps): React.JSX.Element;
|
|
64
|
+
export default function MenuItem({ href, iconName, icon, userHandle, userImgUrl, label, secondLabel, isSelected, onClick, className, size, tag, iconRight, rightAction, role, id, isActive, 'aria-selected': ariaSelected, tabIndex, color, 'aria-current': ariaCurrent, 'aria-label': ariaLabel, 'aria-expanded': ariaExpanded, level, disabled, }: MenuItemProps): React.JSX.Element;
|
|
47
65
|
export {};
|
|
@@ -7,7 +7,7 @@ import Tag from './tag';
|
|
|
7
7
|
import { focusRing, pressFeedbackAny, stateTransition } from './sharedStyles';
|
|
8
8
|
export default function MenuItem(_a) {
|
|
9
9
|
var _b;
|
|
10
|
-
var href = _a.href, iconName = _a.iconName, icon = _a.icon, userHandle = _a.userHandle, userImgUrl = _a.userImgUrl, label = _a.label, secondLabel = _a.secondLabel, isSelected = _a.isSelected, onClick = _a.onClick, _c = _a.className, className = _c === void 0 ? '' : _c, _d = _a.size, size = _d === void 0 ? 'medium' : _d, tag = _a.tag, iconRight = _a.iconRight, rightAction = _a.rightAction, _e = _a.role, role = _e === void 0 ? 'menuitem' : _e, id = _a.id, _f = _a.isActive, isActive = _f === void 0 ? false : _f, ariaSelected = _a["aria-selected"], tabIndex = _a.tabIndex, _g = _a.color, color = _g === void 0 ? 'default' : _g, ariaCurrent = _a["aria-current"], ariaLabel = _a["aria-label"], ariaExpanded = _a["aria-expanded"], _h = _a.level, level = _h === void 0 ? 1 : _h;
|
|
10
|
+
var href = _a.href, iconName = _a.iconName, icon = _a.icon, userHandle = _a.userHandle, userImgUrl = _a.userImgUrl, label = _a.label, secondLabel = _a.secondLabel, isSelected = _a.isSelected, onClick = _a.onClick, _c = _a.className, className = _c === void 0 ? '' : _c, _d = _a.size, size = _d === void 0 ? 'medium' : _d, tag = _a.tag, iconRight = _a.iconRight, rightAction = _a.rightAction, _e = _a.role, role = _e === void 0 ? 'menuitem' : _e, id = _a.id, _f = _a.isActive, isActive = _f === void 0 ? false : _f, ariaSelected = _a["aria-selected"], tabIndex = _a.tabIndex, _g = _a.color, color = _g === void 0 ? 'default' : _g, ariaCurrent = _a["aria-current"], ariaLabel = _a["aria-label"], ariaExpanded = _a["aria-expanded"], _h = _a.level, level = _h === void 0 ? 1 : _h, _j = _a.disabled, disabled = _j === void 0 ? false : _j;
|
|
11
11
|
// Size-based icon and text classes
|
|
12
12
|
var iconSize = { tiny: 'w-4 h-4', small: 'w-5 h-5', medium: 'w-6 h-6' }[size];
|
|
13
13
|
var labelClass = { tiny: 'text-caption', small: 'text-body2', medium: 'text-body1' }[size];
|
|
@@ -16,14 +16,20 @@ export default function MenuItem(_a) {
|
|
|
16
16
|
var tagSize = { tiny: 'tiny', small: 'tiny', medium: 'small' }[size];
|
|
17
17
|
var paddingClass = size === 'tiny' ? 'p-1' : 'p-2';
|
|
18
18
|
var danger = color === 'danger' && !isSelected;
|
|
19
|
-
|
|
19
|
+
// A disabled row is never a link, so everything a plain row carries stays on it
|
|
20
|
+
var link = disabled ? undefined : href;
|
|
21
|
+
var content = (<div id={id} role={link ? undefined : role}
|
|
20
22
|
// A link wrapper is already focusable; otherwise the row itself takes focus
|
|
21
|
-
tabIndex={
|
|
23
|
+
tabIndex={disabled ? -1 : link ? undefined : tabIndex !== null && tabIndex !== void 0 ? tabIndex : 0} aria-disabled={disabled || undefined} aria-selected={role === 'option' ? ariaSelected !== null && ariaSelected !== void 0 ? ariaSelected : !!isSelected : undefined} aria-checked={!link && role === 'menuitemradio' ? !!isSelected : undefined} aria-current={link ? undefined : ariaCurrent} aria-label={link ? undefined : ariaLabel} aria-expanded={link ? undefined : ariaExpanded} className={"\n flex items-center ".concat(paddingClass, " rounded-control ").concat(disabled ? 'cursor-not-allowed opacity-50' : 'cursor-pointer', " justify-between text-left ").concat(stateTransition, " ").concat(disabled ? '' : pressFeedbackAny, " ").concat(focusRing, "\n ").concat(isSelected
|
|
22
24
|
? 'bg-primary-dark text-primary-contrast'
|
|
23
|
-
: "hover:bg-background-accent200 ".concat(isActive ? 'bg-background-accent200' : ''), "\n ").concat(className, "\n ")} style={{ width: '100%' }}
|
|
24
|
-
|
|
25
|
+
: disabled ? '' : "hover:bg-background-accent200 ".concat(isActive ? 'bg-background-accent200' : ''), "\n ").concat(className, "\n ")} style={{ width: '100%' }}
|
|
26
|
+
// A link row's onClick is on the <a>: a click on the row bubbles to it, and Enter on the link reaches it
|
|
27
|
+
onClick={disabled || link ? undefined : onClick} onKeyDown={function (e) {
|
|
28
|
+
if (!link && e.target === e.currentTarget && (e.key === 'Enter' || e.key === ' ')) {
|
|
25
29
|
e.preventDefault();
|
|
26
|
-
|
|
30
|
+
// No click from a disabled row, so nothing around it takes the key as a choice
|
|
31
|
+
if (!disabled)
|
|
32
|
+
e.currentTarget.click();
|
|
27
33
|
}
|
|
28
34
|
}}>
|
|
29
35
|
{/* Left group: icon/userImg + label with 8px gap */}
|
|
@@ -50,6 +56,8 @@ export default function MenuItem(_a) {
|
|
|
50
56
|
</div>)}
|
|
51
57
|
</div>
|
|
52
58
|
</div>);
|
|
53
|
-
var row =
|
|
54
|
-
|
|
59
|
+
var row = link ? <NextLink href={link} onClick={onClick} aria-label={ariaLabel} aria-current={ariaCurrent} aria-expanded={ariaExpanded} tabIndex={tabIndex} className={"block rounded-control ".concat(focusRing)}>{content}</NextLink> : content;
|
|
60
|
+
if (level === 1)
|
|
61
|
+
return row;
|
|
62
|
+
return <div className={level === 3 ? 'pl-12' : 'pl-6'}>{row}</div>;
|
|
55
63
|
}
|
|
@@ -16,14 +16,25 @@ interface OnThisPageProps {
|
|
|
16
16
|
/**
|
|
17
17
|
* How far below the top of the scroll area a heading counts as reached, in px. Default 40, plus the height of a
|
|
18
18
|
* `SiteHeader` above the page (`--os-header-offset`) when the window scrolls. A click scrolls the heading to just
|
|
19
|
-
* under that header.
|
|
19
|
+
* under that header, or to its `scroll-margin-top` when that is more.
|
|
20
20
|
*/
|
|
21
21
|
offset?: number;
|
|
22
|
+
/**
|
|
23
|
+
* What a click does to the browser history. 'push', the default, adds an entry for the `#hash`, so Back returns
|
|
24
|
+
* to where the reader was. 'replace' changes the address only, for a page that Back should leave.
|
|
25
|
+
*/
|
|
26
|
+
history?: 'push' | 'replace';
|
|
27
|
+
/**
|
|
28
|
+
* After a click, keep the heading in place while the page changes height, as images above it load. It lets go
|
|
29
|
+
* after 3 seconds, or when the reader scrolls, presses a key or presses the pointer.
|
|
30
|
+
*/
|
|
31
|
+
keepInView?: boolean;
|
|
22
32
|
}
|
|
23
33
|
/**
|
|
24
34
|
* Links to a long page's headings, with the one the reader is at marked. The current heading is the last one
|
|
25
35
|
* above `offset`; the last item at the end of the scroll; the one in the `#hash` on load. A click keeps its item
|
|
26
|
-
* current until the scroll ends. Reduced motion jumps instead of scrolling.
|
|
36
|
+
* current until the scroll ends. Reduced motion jumps instead of scrolling. `history="replace"` leaves no entry
|
|
37
|
+
* for Back, and `keepInView` holds the heading while the page above it loads.
|
|
27
38
|
*/
|
|
28
|
-
export default function OnThisPage({ items, 'aria-label': ariaLabel, root, offset }: OnThisPageProps): React.JSX.Element | null;
|
|
39
|
+
export default function OnThisPage({ items, 'aria-label': ariaLabel, root, offset, history: historyMode, keepInView, }: OnThisPageProps): React.JSX.Element | null;
|
|
29
40
|
export { OnThisPage };
|
|
@@ -5,24 +5,35 @@ import { focusRing } from './sharedStyles';
|
|
|
5
5
|
import { hashId, isAtBottom, pickCurrent } from '../internal/scrollSpy';
|
|
6
6
|
// A click or a #hash pins its item as current while the page scrolls there, so the items in between don't flash past
|
|
7
7
|
var PIN_LIMIT = 1000;
|
|
8
|
+
// With keepInView, how long after a click the heading is held in place
|
|
9
|
+
var KEEP_LIMIT = 3000;
|
|
8
10
|
var headerOffset = function () { return parseFloat(getComputedStyle(document.documentElement).getPropertyValue('--os-header-offset')) || 0; };
|
|
11
|
+
// Where a jump puts a heading, from the top of the scroll area: under the header (`gap`), or lower when the
|
|
12
|
+
// heading's own scroll-margin-top asks for it, as a #hash link would
|
|
13
|
+
var landing = function (heading, gap) {
|
|
14
|
+
return Math.max(gap, parseFloat(getComputedStyle(heading).scrollMarginTop) || 0);
|
|
15
|
+
};
|
|
9
16
|
var INPUT_EVENTS = ['wheel', 'touchstart', 'keydown', 'pointerdown'];
|
|
10
17
|
/**
|
|
11
18
|
* Links to a long page's headings, with the one the reader is at marked. The current heading is the last one
|
|
12
19
|
* above `offset`; the last item at the end of the scroll; the one in the `#hash` on load. A click keeps its item
|
|
13
|
-
* current until the scroll ends. Reduced motion jumps instead of scrolling.
|
|
20
|
+
* current until the scroll ends. Reduced motion jumps instead of scrolling. `history="replace"` leaves no entry
|
|
21
|
+
* for Back, and `keepInView` holds the heading while the page above it loads.
|
|
14
22
|
*/
|
|
15
23
|
export default function OnThisPage(_a) {
|
|
16
24
|
var _b, _c;
|
|
17
|
-
var items = _a.items, _d = _a["aria-label"], ariaLabel = _d === void 0 ? 'On this page' : _d, root = _a.root, offset = _a.offset;
|
|
25
|
+
var items = _a.items, _d = _a["aria-label"], ariaLabel = _d === void 0 ? 'On this page' : _d, root = _a.root, offset = _a.offset, _e = _a.history, historyMode = _e === void 0 ? 'push' : _e, _f = _a.keepInView, keepInView = _f === void 0 ? false : _f;
|
|
18
26
|
var ids = items.map(function (item) { return item.id; });
|
|
19
27
|
var key = ids.join('\n');
|
|
20
|
-
var
|
|
21
|
-
var
|
|
28
|
+
var _g = useState((_c = (_b = items[0]) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : null), current = _g[0], setCurrent = _g[1];
|
|
29
|
+
var _h = useSlidingIndicator("".concat(key, "|").concat(current)), containerRef = _h.containerRef, indicator = _h.indicator;
|
|
22
30
|
var pin = useRef(null);
|
|
23
31
|
var pinTimer = useRef(undefined);
|
|
24
32
|
// The effect below puts its recompute here, for the click handler
|
|
25
33
|
var refresh = useRef(function () { });
|
|
34
|
+
// Ends the hold a click with keepInView started
|
|
35
|
+
var letGo = useRef(function () { });
|
|
36
|
+
useEffect(function () { return function () { return letGo.current(); }; }, []);
|
|
26
37
|
var setPin = function (id, until) {
|
|
27
38
|
clearTimeout(pinTimer.current);
|
|
28
39
|
pin.current = { id: id, until: until };
|
|
@@ -46,9 +57,14 @@ export default function OnThisPage(_a) {
|
|
|
46
57
|
if (pin.current)
|
|
47
58
|
return;
|
|
48
59
|
var base = rootEl ? rootEl.getBoundingClientRect().top : 0;
|
|
60
|
+
var gap = rootEl ? 0 : headerOffset();
|
|
49
61
|
var tops = ids.map(function (id) {
|
|
50
62
|
var el = document.getElementById(id);
|
|
51
|
-
|
|
63
|
+
if (!el)
|
|
64
|
+
return null;
|
|
65
|
+
// By default a heading with a deeper scroll margin counts as reached that much lower, so it is current
|
|
66
|
+
// where a jump leaves it. A caller's `offset` is taken as it is.
|
|
67
|
+
return el.getBoundingClientRect().top - base - (offset === undefined ? landing(el, gap) - gap : 0);
|
|
52
68
|
});
|
|
53
69
|
var metrics = rootEl
|
|
54
70
|
? { scrollTop: rootEl.scrollTop, clientHeight: rootEl.clientHeight, scrollHeight: rootEl.scrollHeight }
|
|
@@ -57,7 +73,7 @@ export default function OnThisPage(_a) {
|
|
|
57
73
|
clientHeight: window.innerHeight,
|
|
58
74
|
scrollHeight: document.documentElement.scrollHeight,
|
|
59
75
|
};
|
|
60
|
-
var i = pickCurrent(tops, offset !== null && offset !== void 0 ? offset : 40 +
|
|
76
|
+
var i = pickCurrent(tops, offset !== null && offset !== void 0 ? offset : 40 + gap, isAtBottom(metrics));
|
|
61
77
|
if (i >= 0)
|
|
62
78
|
setCurrent(ids[i]);
|
|
63
79
|
};
|
|
@@ -103,6 +119,47 @@ export default function OnThisPage(_a) {
|
|
|
103
119
|
INPUT_EVENTS.forEach(function (type) { return target.removeEventListener(type, onInput); });
|
|
104
120
|
};
|
|
105
121
|
}, [key, root, offset]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
122
|
+
// Scrolls to the heading again each time the page changes height. Until the click's own scroll ends it keeps
|
|
123
|
+
// that scroll's behavior, so the glide carries on to where the heading is now; after that it jumps.
|
|
124
|
+
var keep = function (id, heading, rootEl, behavior) {
|
|
125
|
+
if (typeof ResizeObserver === 'undefined')
|
|
126
|
+
return;
|
|
127
|
+
var target = rootEl !== null && rootEl !== void 0 ? rootEl : window;
|
|
128
|
+
var arrived = false;
|
|
129
|
+
var onScrollEnd = function () {
|
|
130
|
+
arrived = true;
|
|
131
|
+
};
|
|
132
|
+
var arrival = setTimeout(onScrollEnd, PIN_LIMIT);
|
|
133
|
+
var align = function () {
|
|
134
|
+
if (!heading.isConnected)
|
|
135
|
+
return stop();
|
|
136
|
+
var base = rootEl ? rootEl.getBoundingClientRect().top : 0;
|
|
137
|
+
var delta = heading.getBoundingClientRect().top - base - landing(heading, rootEl ? 0 : headerOffset());
|
|
138
|
+
var top = rootEl ? rootEl.scrollTop : window.scrollY;
|
|
139
|
+
var room = rootEl
|
|
140
|
+
? rootEl.scrollHeight - rootEl.clientHeight - top
|
|
141
|
+
: document.documentElement.scrollHeight - window.innerHeight - top;
|
|
142
|
+
if (Math.abs(delta > 0 ? Math.min(delta, room) : Math.max(delta, -top)) < 1)
|
|
143
|
+
return;
|
|
144
|
+
setPin(id, 'scrollend');
|
|
145
|
+
(rootEl !== null && rootEl !== void 0 ? rootEl : window).scrollBy({ top: delta, behavior: arrived ? 'instant' : behavior });
|
|
146
|
+
};
|
|
147
|
+
var observer = new ResizeObserver(align);
|
|
148
|
+
// A scrolling element keeps its own size as its content grows, so its children are watched
|
|
149
|
+
(rootEl ? Array.from(rootEl.children) : [document.body]).forEach(function (el) { return observer.observe(el); });
|
|
150
|
+
var limit = setTimeout(function () { return stop(); }, KEEP_LIMIT);
|
|
151
|
+
var onInput = function () { return stop(); };
|
|
152
|
+
function stop() {
|
|
153
|
+
clearTimeout(arrival);
|
|
154
|
+
clearTimeout(limit);
|
|
155
|
+
observer.disconnect();
|
|
156
|
+
target.removeEventListener('scrollend', onScrollEnd);
|
|
157
|
+
INPUT_EVENTS.forEach(function (type) { return window.removeEventListener(type, onInput); });
|
|
158
|
+
}
|
|
159
|
+
target.addEventListener('scrollend', onScrollEnd);
|
|
160
|
+
INPUT_EVENTS.forEach(function (type) { return window.addEventListener(type, onInput, { passive: true }); });
|
|
161
|
+
letGo.current = stop;
|
|
162
|
+
};
|
|
106
163
|
var onLinkClick = function (e, id) {
|
|
107
164
|
if (e.defaultPrevented || e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey)
|
|
108
165
|
return;
|
|
@@ -115,8 +172,15 @@ export default function OnThisPage(_a) {
|
|
|
115
172
|
// The heading ends just under a header above the page; 'instant' ignores a page's own `scroll-behavior: smooth`
|
|
116
173
|
var behavior = reduced ? 'instant' : 'smooth';
|
|
117
174
|
var gap = rootEl ? 0 : headerOffset();
|
|
118
|
-
var delta = heading.getBoundingClientRect().top - (rootEl ? rootEl.getBoundingClientRect().top : 0) - gap;
|
|
119
|
-
|
|
175
|
+
var delta = heading.getBoundingClientRect().top - (rootEl ? rootEl.getBoundingClientRect().top : 0) - landing(heading, gap);
|
|
176
|
+
var address = "#".concat(encodeURIComponent(id));
|
|
177
|
+
if (historyMode === 'replace')
|
|
178
|
+
window.history.replaceState(window.history.state, '', address);
|
|
179
|
+
else
|
|
180
|
+
window.history.pushState(window.history.state, '', address);
|
|
181
|
+
letGo.current();
|
|
182
|
+
if (keepInView)
|
|
183
|
+
keep(id, heading, rootEl, behavior);
|
|
120
184
|
var top = rootEl ? rootEl.scrollTop : window.scrollY;
|
|
121
185
|
var room = rootEl
|
|
122
186
|
? rootEl.scrollHeight - rootEl.clientHeight - top
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
interface ParagraphProps {
|
|
3
3
|
children: React.ReactNode;
|
|
4
|
-
|
|
4
|
+
/** The text color. Default 'primary'. 'inherit' sets no color class, so the parent's color applies, as inside a quote. The parent's color must then be readable on its background. */
|
|
5
|
+
tone?: 'primary' | 'secondary' | 'inherit';
|
|
5
6
|
size?: 'body1' | 'body2' | 'caption';
|
|
6
7
|
/** How wide a line may run, so a paragraph stays readable. `none` leaves it to the parent. */
|
|
7
8
|
measure?: 'narrow' | 'lede' | 'body' | 'wide' | 'none';
|
|
@@ -10,6 +11,12 @@ interface ParagraphProps {
|
|
|
10
11
|
className?: string;
|
|
11
12
|
/** On the `<p>`, so a field can point at this line with `aria-describedby` */
|
|
12
13
|
id?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Makes the line a polite live region, for progress text that changes. Default none. A screen reader announces a
|
|
16
|
+
* live region most reliably when it is on the page before its text changes, so draw the line first and then
|
|
17
|
+
* change its text.
|
|
18
|
+
*/
|
|
19
|
+
role?: 'status';
|
|
13
20
|
}
|
|
14
|
-
|
|
15
|
-
export
|
|
21
|
+
declare const Paragraph: React.ForwardRefExoticComponent<ParagraphProps & React.RefAttributes<HTMLParagraphElement>>;
|
|
22
|
+
export default Paragraph;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
var tones = { primary: 'text-fg-primary', secondary: 'text-fg-secondary' };
|
|
2
|
+
var tones = { primary: 'text-fg-primary', secondary: 'text-fg-secondary', inherit: '' };
|
|
3
3
|
var sizes = { body1: 'text-body1', body2: 'text-body2', caption: 'text-caption' };
|
|
4
4
|
var measures = {
|
|
5
5
|
narrow: 'max-w-measure-narrow',
|
|
@@ -8,9 +8,11 @@ var measures = {
|
|
|
8
8
|
wide: 'max-w-measure-wide',
|
|
9
9
|
none: '',
|
|
10
10
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
// The ref lands on the <p>, so a screen can scroll to the line.
|
|
12
|
+
var Paragraph = React.forwardRef(function Paragraph(_a, ref) {
|
|
13
|
+
var children = _a.children, _b = _a.tone, tone = _b === void 0 ? 'primary' : _b, _c = _a.size, size = _c === void 0 ? 'body1' : _c, _d = _a.measure, measure = _d === void 0 ? 'body' : _d, _e = _a.mono, mono = _e === void 0 ? false : _e, _f = _a.className, className = _f === void 0 ? '' : _f, id = _a.id, role = _a.role;
|
|
14
|
+
return (<p ref={ref} id={id} role={role} className={"".concat(sizes[size], " ").concat(tones[tone], " ").concat(measures[measure], " ").concat(mono ? 'font-mono' : '', " ").concat(className)}>
|
|
14
15
|
{children}
|
|
15
16
|
</p>);
|
|
16
|
-
}
|
|
17
|
+
});
|
|
18
|
+
export default Paragraph;
|
|
@@ -1,7 +1,25 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* An anchor that is not an element, such as a text selection's saved Range:
|
|
4
|
+
* `{ getBoundingClientRect: () => range.getBoundingClientRect(), contextElement: body }`.
|
|
5
|
+
*/
|
|
6
|
+
export interface VirtualAnchor {
|
|
7
|
+
/** The box the Popover sits against, in viewport coordinates */
|
|
8
|
+
getBoundingClientRect(): DOMRect;
|
|
9
|
+
/** The element the box is in. The Popover follows its scroll containers, and uses it to tell whether it sits in the top Modal or Drawer. */
|
|
10
|
+
contextElement: Element;
|
|
11
|
+
}
|
|
2
12
|
interface PopoverProps {
|
|
3
13
|
id?: string;
|
|
4
|
-
|
|
14
|
+
/**
|
|
15
|
+
* What the Popover sits against, below its start edge: an element, or a `VirtualAnchor`. Default none, and
|
|
16
|
+
* then the Popover does not show. Keep a `VirtualAnchor` the same object between renders (state or a memo),
|
|
17
|
+
* or the Popover is positioned again on every render without end. With a `VirtualAnchor` there is no
|
|
18
|
+
* trigger: every press outside the Popover closes it, and `returnFocus` and `tabWithin` do nothing.
|
|
19
|
+
* The Popover takes no focus when it opens, so a text selection stays. Pressing a control in it moves
|
|
20
|
+
* focus unless that control calls `preventDefault` on `mousedown`. It still needs a name.
|
|
21
|
+
*/
|
|
22
|
+
anchorEl?: HTMLElement | VirtualAnchor | null;
|
|
5
23
|
open: boolean;
|
|
6
24
|
onClose: () => void;
|
|
7
25
|
children: React.ReactNode;
|
|
@@ -11,10 +29,22 @@ interface PopoverProps {
|
|
|
11
29
|
* Popover also closes it (`onClose`) and focuses `anchorEl`. Pass the focusable trigger as `anchorEl`.
|
|
12
30
|
*/
|
|
13
31
|
returnFocus?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Used only with `returnFocus`, for a Popover that holds a form of several controls. Default false.
|
|
34
|
+
* Tab and Shift+Tab move between the controls inside; only Tab from the last one or Shift+Tab from the
|
|
35
|
+
* first closes the Popover (`onClose`) and focuses `anchorEl`, as does either key from an element that is
|
|
36
|
+
* not one of those controls. The controls are the visible, enabled ones in the tab order, in DOM order
|
|
37
|
+
* (a positive `tabIndex` does not move one). Radios with the same name in the same form are one stop:
|
|
38
|
+
* the checked one, or with none checked the first (the last for Shift+Tab). A `summary`, editable text
|
|
39
|
+
* and an `iframe` are stops too. Tab pressed inside an `iframe` is left to the browser.
|
|
40
|
+
* A key that a child has already handled (`preventDefault`) is left alone. The dialog's role and name,
|
|
41
|
+
* Escape and a click outside do not change.
|
|
42
|
+
*/
|
|
43
|
+
tabWithin?: boolean;
|
|
14
44
|
/** The dialog's name. Give one unless the content is a `navigable` (or `role`d) `Menu` with its own `aria-label`: that Menu names itself, and the Popover around it stays unnamed so it is not heard twice. */
|
|
15
45
|
'aria-label'?: string;
|
|
16
46
|
/** The id of the element that names the dialog, as an alternative to `aria-label`. */
|
|
17
47
|
'aria-labelledby'?: string;
|
|
18
48
|
}
|
|
19
|
-
export default function Popover({ id, anchorEl, open, onClose, children, returnFocus, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledby, }: PopoverProps): React.ReactPortal | null;
|
|
49
|
+
export default function Popover({ id, anchorEl, open, onClose, children, returnFocus, tabWithin, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledby, }: PopoverProps): React.ReactPortal | null;
|
|
20
50
|
export {};
|
|
@@ -5,38 +5,82 @@ import { usePopper } from 'react-popper';
|
|
|
5
5
|
import { overlayHidden, overlayTransition, overlayVisible } from './sharedStyles';
|
|
6
6
|
import { useOverlayTransition } from './useOverlayTransition';
|
|
7
7
|
import Menu from './menu';
|
|
8
|
-
import { isInTopOverlay } from '../internal/overlayStack';
|
|
8
|
+
import { PICKABLE, isInTopOverlay } from '../internal/overlayStack';
|
|
9
|
+
// PICKABLE plus the other things a browser stops on with Tab
|
|
10
|
+
var TAB_STOPS = "".concat(PICKABLE, ", details > summary:first-of-type, [contenteditable]:not([contenteditable=\"false\"]), iframe");
|
|
11
|
+
var isRadio = function (el) { return el instanceof HTMLInputElement && el.type === 'radio'; };
|
|
12
|
+
// Radios with the same name in the same form are one Tab stop
|
|
13
|
+
var sameGroup = function (a, b) { return isRadio(a) && isRadio(b) && a.name !== '' && a.name === b.name && a.form === b.form; };
|
|
14
|
+
// The `tabWithin` control after `from` (before it with `back`), or undefined when Tab should leave
|
|
15
|
+
function tabNeighbor(panel, from, back) {
|
|
16
|
+
var usable = Array.from(panel.querySelectorAll(TAB_STOPS)).filter(function (el) {
|
|
17
|
+
var _a, _b;
|
|
18
|
+
// Chrome reports tabIndex -1 for editable text that has no tabindex attribute, though Tab stops on it
|
|
19
|
+
return (el.tabIndex >= 0 || (el.isContentEditable && !((_a = el.parentElement) === null || _a === void 0 ? void 0 : _a.isContentEditable) && !el.hasAttribute('tabindex'))) &&
|
|
20
|
+
!el.matches(':disabled') &&
|
|
21
|
+
!el.closest('[inert]') &&
|
|
22
|
+
// False under `content-visibility: hidden`, which keeps client rects
|
|
23
|
+
((_b = el.checkVisibility) === null || _b === void 0 ? void 0 : _b.call(el)) !== false &&
|
|
24
|
+
// A closed details keeps client rects for its content in Chrome
|
|
25
|
+
!el.closest('details:not([open]) > :not(summary:first-of-type)') &&
|
|
26
|
+
el.getClientRects().length > 0 &&
|
|
27
|
+
getComputedStyle(el).visibility !== 'hidden';
|
|
28
|
+
});
|
|
29
|
+
// A group's stop is its checked radio; with none checked, the first, or the last going back
|
|
30
|
+
var stops = usable.filter(function (el) {
|
|
31
|
+
var _a;
|
|
32
|
+
if (!isRadio(el))
|
|
33
|
+
return true;
|
|
34
|
+
var group = usable.filter(function (other) { return other === el || sameGroup(other, el); });
|
|
35
|
+
return el === ((_a = group.find(function (other) { return other.checked; })) !== null && _a !== void 0 ? _a : group[back ? group.length - 1 : 0]);
|
|
36
|
+
});
|
|
37
|
+
var index = stops.findIndex(function (el) { return el === from || sameGroup(el, from); });
|
|
38
|
+
return index < 0 ? undefined : stops[index + (back ? -1 : 1)];
|
|
39
|
+
}
|
|
9
40
|
export default function Popover(_a) {
|
|
10
|
-
var id = _a.id, anchorEl = _a.anchorEl, open = _a.open, onClose = _a.onClose, children = _a.children, _b = _a.returnFocus, returnFocus = _b === void 0 ? false : _b, ariaLabel = _a["aria-label"], ariaLabelledby = _a["aria-labelledby"];
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var
|
|
41
|
+
var id = _a.id, anchorEl = _a.anchorEl, open = _a.open, onClose = _a.onClose, children = _a.children, _b = _a.returnFocus, returnFocus = _b === void 0 ? false : _b, _c = _a.tabWithin, tabWithin = _c === void 0 ? false : _c, ariaLabel = _a["aria-label"], ariaLabelledby = _a["aria-labelledby"];
|
|
42
|
+
var _d = useState(null), popoverElement = _d[0], setPopoverElement = _d[1];
|
|
43
|
+
var _e = useState(false), hasMounted = _e[0], setHasMounted = _e[1];
|
|
44
|
+
var _f = useOverlayTransition(open), mounted = _f.mounted, visible = _f.visible;
|
|
14
45
|
// Initialize Popper.js
|
|
15
|
-
var
|
|
46
|
+
var _g = usePopper(anchorEl, popoverElement, {
|
|
16
47
|
placement: 'bottom-start', // Default placement, can be customized
|
|
17
48
|
modifiers: [
|
|
18
49
|
{ name: 'offset', options: { offset: [0, 4] } }, // Same 4px gap as the Select menu and Tooltip
|
|
19
50
|
],
|
|
20
|
-
}), styles =
|
|
51
|
+
}), styles = _g.styles, attributes = _g.attributes;
|
|
21
52
|
// Close on outside clicks and Escape. Clicks on the anchor are left to the
|
|
22
53
|
// anchor's own toggle, otherwise the popover would close and reopen.
|
|
23
54
|
useEffect(function () {
|
|
24
55
|
var handleClickOutside = function (event) {
|
|
25
56
|
var target = event.target;
|
|
26
|
-
if (popoverElement && !popoverElement.contains(target) && anchorEl && !anchorEl.contains(target)) {
|
|
57
|
+
if (popoverElement && !popoverElement.contains(target) && anchorEl && !(anchorEl instanceof Element && anchorEl.contains(target))) {
|
|
27
58
|
onClose();
|
|
28
59
|
}
|
|
29
60
|
};
|
|
30
61
|
var handleKeyDown = function (event) {
|
|
31
62
|
if (event.key === 'Escape') {
|
|
32
63
|
// Under a Modal or Drawer opened after it, the Escape belongs to that overlay
|
|
33
|
-
|
|
64
|
+
// A virtual anchor is in no panel itself, so its contextElement answers for it
|
|
65
|
+
if (!isInTopOverlay(anchorEl && !(anchorEl instanceof Element) ? anchorEl.contextElement : anchorEl))
|
|
34
66
|
return;
|
|
35
67
|
// Close only the Popover: keep this Escape from reaching a Modal's window listener
|
|
36
68
|
event.stopPropagation();
|
|
37
69
|
onClose();
|
|
38
70
|
}
|
|
39
|
-
else if (event.key === 'Tab' && returnFocus && anchorEl && (popoverElement === null || popoverElement === void 0 ? void 0 : popoverElement.contains(event.target))) {
|
|
71
|
+
else if (event.key === 'Tab' && returnFocus && anchorEl instanceof Element && (popoverElement === null || popoverElement === void 0 ? void 0 : popoverElement.contains(event.target))) {
|
|
72
|
+
if (tabWithin) {
|
|
73
|
+
if (event.defaultPrevented)
|
|
74
|
+
return;
|
|
75
|
+
var next = tabNeighbor(popoverElement, event.target, event.shiftKey);
|
|
76
|
+
if (next) {
|
|
77
|
+
// Moved here, and stopped, so a Modal's Tab trap cannot take focus from the portaled Popover
|
|
78
|
+
event.preventDefault();
|
|
79
|
+
event.stopPropagation();
|
|
80
|
+
next.focus();
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
40
84
|
// Tab or Shift+Tab leaves the Popover: close it and give focus back to the anchor, before a Modal's
|
|
41
85
|
// Tab trap or the browser moves it somewhere else (the Popover is portaled to the end of the body)
|
|
42
86
|
event.preventDefault();
|
|
@@ -53,7 +97,7 @@ export default function Popover(_a) {
|
|
|
53
97
|
document.removeEventListener('mousedown', handleClickOutside);
|
|
54
98
|
document.removeEventListener('keydown', handleKeyDown);
|
|
55
99
|
};
|
|
56
|
-
}, [open, anchorEl, popoverElement, onClose, returnFocus]);
|
|
100
|
+
}, [open, anchorEl, popoverElement, onClose, returnFocus, tabWithin]);
|
|
57
101
|
// On close, wait one task so a click outside has moved focus first: a click on something
|
|
58
102
|
// focusable keeps it there; a click on nothing leaves it on the body, and then the anchor takes it.
|
|
59
103
|
// A caller may clear `anchorEl` in the same render that closes it, so the last one set is kept.
|
|
@@ -65,7 +109,7 @@ export default function Popover(_a) {
|
|
|
65
109
|
var closed = wasOpen.current && !open;
|
|
66
110
|
wasOpen.current = open;
|
|
67
111
|
var target = lastAnchor.current;
|
|
68
|
-
if (!closed || !returnFocus || !target)
|
|
112
|
+
if (!closed || !returnFocus || !(target instanceof Element))
|
|
69
113
|
return;
|
|
70
114
|
var timer = setTimeout(function () {
|
|
71
115
|
var active = document.activeElement;
|
|
@@ -17,6 +17,26 @@ interface SidePaneProps {
|
|
|
17
17
|
maxWidth?: number;
|
|
18
18
|
/** The Close button's name. Default 'Close <title>'. */
|
|
19
19
|
closeLabel?: string;
|
|
20
|
+
/**
|
|
21
|
+
* A Button before the title that goes one step up inside the pane, such as 'Back to Plan'. It is TitleBar's
|
|
22
|
+
* `back`: below md it takes its own line. It is not a phone close button, since Close is always there.
|
|
23
|
+
* Default none. The pane is still named by its title, and focus on open still goes to the title.
|
|
24
|
+
* Pressing it usually removes it, so call `focus()` on the pane's ref after the step changes.
|
|
25
|
+
*/
|
|
26
|
+
back?: React.ReactNode;
|
|
27
|
+
/**
|
|
28
|
+
* One line under the title: a status Tag, an AvatarStack, short facts. It is TitleBar's `meta`: it wraps
|
|
29
|
+
* and is not part of the heading, so the pane is still named by the title alone. Default none.
|
|
30
|
+
* Pass it, or leave it out, for as long as the title is on screen: adding or removing it while the pane
|
|
31
|
+
* is open replaces the heading, and focus on the title is lost.
|
|
32
|
+
*/
|
|
33
|
+
meta?: React.ReactNode;
|
|
34
|
+
/**
|
|
35
|
+
* The body's inner space. 'none' removes it, for content that draws its own edges, such as code or a
|
|
36
|
+
* full-width list. The body still scrolls, and the title bar does not change. Default 'default'.
|
|
37
|
+
* It changes no roles or names. With 'none', give focusable rows room for their focus ring.
|
|
38
|
+
*/
|
|
39
|
+
padding?: 'default' | 'none';
|
|
20
40
|
}
|
|
21
41
|
/** What a ref on SidePane gets: `focus()` moves focus to the pane's title, to bring an open pane forward */
|
|
22
42
|
export interface SidePaneHandle {
|
|
@@ -15,7 +15,7 @@ var DEFAULT_WIDTH = 384;
|
|
|
15
15
|
* Escape anywhere inside the pane closes it, including an Escape that hides a tooltip or clears a field.
|
|
16
16
|
*/
|
|
17
17
|
var SidePane = forwardRef(function SidePane(_a, ref) {
|
|
18
|
-
var title = _a.title, onClose = _a.onClose, children = _a.children, actions = _a.actions, width = _a.width, onWidthChange = _a.onWidthChange, _b = _a.minWidth, minWidth = _b === void 0 ? 320 : _b, maxWidth = _a.maxWidth, closeLabel = _a.closeLabel;
|
|
18
|
+
var title = _a.title, onClose = _a.onClose, children = _a.children, actions = _a.actions, width = _a.width, onWidthChange = _a.onWidthChange, _b = _a.minWidth, minWidth = _b === void 0 ? 320 : _b, maxWidth = _a.maxWidth, closeLabel = _a.closeLabel, back = _a.back, meta = _a.meta, _c = _a.padding, padding = _c === void 0 ? 'default' : _c;
|
|
19
19
|
var asideRef = useRef(null);
|
|
20
20
|
var titleId = useId();
|
|
21
21
|
var onCloseRef = useRef(onClose);
|
|
@@ -64,7 +64,7 @@ var SidePane = forwardRef(function SidePane(_a, ref) {
|
|
|
64
64
|
var resizable = !!onWidthChange;
|
|
65
65
|
var sized = resizable || width !== undefined;
|
|
66
66
|
// The default maximum needs the window, so it is known only after mount (the server uses the width)
|
|
67
|
-
var
|
|
67
|
+
var _d = useState(null), windowWidth = _d[0], setWindowWidth = _d[1];
|
|
68
68
|
useEffect(function () {
|
|
69
69
|
if (!sized || maxWidth !== undefined)
|
|
70
70
|
return;
|
|
@@ -114,12 +114,12 @@ var SidePane = forwardRef(function SidePane(_a, ref) {
|
|
|
114
114
|
<div className="mx-auto h-full w-0.5 group-hover:bg-fg-secondary group-active:bg-fg-primary"/>
|
|
115
115
|
</div>)}
|
|
116
116
|
<div className="shrink-0 border-b border-misc-divider py-2 pl-4 pr-2">
|
|
117
|
-
<TitleBar title={title} level={2} id={titleId} actions={<>
|
|
117
|
+
<TitleBar title={title} level={2} id={titleId} back={back} meta={meta} actions={<>
|
|
118
118
|
{actions}
|
|
119
119
|
<IconButton color="iconOnly" state="enabled" size="medium" icon={X} ariaLabel={closeLabel !== null && closeLabel !== void 0 ? closeLabel : "Close ".concat(title)} onClick={onClose}/>
|
|
120
120
|
</>}/>
|
|
121
121
|
</div>
|
|
122
|
-
<div className="min-h-0 flex-1 overflow-y-auto px-4 py-4 text-body1 text-fg-primary" style={{ scrollbarWidth: 'thin' }}>
|
|
122
|
+
<div className={"min-h-0 flex-1 overflow-y-auto".concat(padding === 'none' ? '' : ' px-4 py-4', " text-body1 text-fg-primary")} style={{ scrollbarWidth: 'thin' }}>
|
|
123
123
|
{children}
|
|
124
124
|
</div>
|
|
125
125
|
</aside>);
|
|
@@ -11,6 +11,12 @@ interface SourceCardProps {
|
|
|
11
11
|
href?: string;
|
|
12
12
|
/** Makes the card a button. Ignored when `href` is set: the link wins and `onClick` does not run. */
|
|
13
13
|
onClick?: () => void;
|
|
14
|
+
/**
|
|
15
|
+
* With `href`: hears the link's click, also from Enter and from a click with a modifier key. The link still opens
|
|
16
|
+
* unless this calls `event.preventDefault()`. A middle click does not call it. Ignored without `href`.
|
|
17
|
+
* Default none. It changes no role or name.
|
|
18
|
+
*/
|
|
19
|
+
onLinkClick?: (event: React.MouseEvent<HTMLAnchorElement>) => void;
|
|
14
20
|
/** A short text at the right end ('Open'), in the info text color. Shown only on a link or button card, and part of its accessible name. */
|
|
15
21
|
action?: string;
|
|
16
22
|
/** With `href`: open in a new tab. Another site (`http(s)://`) always opens in a new tab. */
|
|
@@ -20,7 +20,7 @@ import { focusRing, stateTransition } from './sharedStyles';
|
|
|
20
20
|
// Like Link, it only sets new-tab attributes and shows no extra icon.
|
|
21
21
|
/** The ref reaches the link or the button, so a page can move focus back to the card that opened something. A static card has no ref target. */
|
|
22
22
|
var SourceCard = forwardRef(function SourceCard(_a, ref) {
|
|
23
|
-
var icon = _a.icon, title = _a.title, meta = _a.meta, href = _a.href, onClick = _a.onClick, action = _a.action, _b = _a.openInNewTab, openInNewTab = _b === void 0 ? false : _b, ariaLabel = _a["aria-label"];
|
|
23
|
+
var icon = _a.icon, title = _a.title, meta = _a.meta, href = _a.href, onClick = _a.onClick, onLinkClick = _a.onLinkClick, action = _a.action, _b = _a.openInNewTab, openInNewTab = _b === void 0 ? false : _b, ariaLabel = _a["aria-label"];
|
|
24
24
|
var interactive = href !== undefined || onClick !== undefined;
|
|
25
25
|
var showAction = interactive && !!action;
|
|
26
26
|
// A link or button is named in one string, so the parts are read with a pause between them
|
|
@@ -40,7 +40,7 @@ var SourceCard = forwardRef(function SourceCard(_a, ref) {
|
|
|
40
40
|
if (href !== undefined) {
|
|
41
41
|
var isExternal = href.startsWith('http://') || href.startsWith('https://');
|
|
42
42
|
var newTab = openInNewTab || isExternal;
|
|
43
|
-
var props = __assign({ className: classes, 'aria-label': name }, (newTab && { target: '_blank', rel: 'noopener noreferrer' }));
|
|
43
|
+
var props = __assign({ className: classes, 'aria-label': name, onClick: onLinkClick }, (newTab && { target: '_blank', rel: 'noopener noreferrer' }));
|
|
44
44
|
if (newTab) {
|
|
45
45
|
return <a href={href} {...props} ref={ref}>{content}</a>;
|
|
46
46
|
}
|
|
@@ -44,5 +44,9 @@ interface TextFieldProps extends Pick<React.AriaAttributes, 'aria-label' | 'aria
|
|
|
44
44
|
*/
|
|
45
45
|
role?: React.AriaRole;
|
|
46
46
|
}
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
/**
|
|
48
|
+
* A ref lands on the `<input>`, or on the `<textarea>` when `multiline`, so a screen can move focus to the field,
|
|
49
|
+
* for example after a button clears it. Focus moved this way is announced with the field's own name and description.
|
|
50
|
+
*/
|
|
51
|
+
declare const TextField: React.ForwardRefExoticComponent<TextFieldProps & React.RefAttributes<HTMLInputElement | HTMLTextAreaElement>>;
|
|
52
|
+
export default TextField;
|