oneslash-design-system 2.26.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/side-pane.md +1 -0
- package/dist/cases.json +4 -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/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/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
|
@@ -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
|
}
|
|
@@ -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;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { stateTransition } from './sharedStyles';
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* A ref lands on the `<input>`, or on the `<textarea>` when `multiline`, so a screen can move focus to the field,
|
|
6
|
+
* for example after a button clears it. Focus moved this way is announced with the field's own name and description.
|
|
7
|
+
*/
|
|
8
|
+
var TextField = React.forwardRef(function TextField(_a, ref) {
|
|
5
9
|
var id = _a.id, label = _a.label, value = _a.value, _b = _a.type, type = _b === void 0 ? 'text' : _b, onChange = _a.onChange, onBlur = _a.onBlur, onFocus = _a.onFocus, onKeyDown = _a.onKeyDown, onSubmit = _a.onSubmit, _c = _a.autoFocus, autoFocus = _c === void 0 ? false : _c, _d = _a.multiline, multiline = _d === void 0 ? false : _d, _e = _a.maxRows, maxRows = _e === void 0 ? 6 : _e, _f = _a.disabled, disabled = _f === void 0 ? false : _f, _g = _a.readOnly, readOnly = _g === void 0 ? false : _g, _h = _a.error, error = _h === void 0 ? false : _h, _j = _a.errorText, errorText = _j === void 0 ? 'This field is required' : _j, helperText = _a.helperText, _k = _a.required, required = _k === void 0 ? false : _k, _l = _a.size, size = _l === void 0 ? 'medium' : _l, placeholder = _a.placeholder, name = _a.name, _m = _a.autoComplete, autoComplete = _m === void 0 ? 'off' : _m, tabIndex = _a.tabIndex, maxLength = _a.maxLength, minLength = _a.minLength, spellCheck = _a.spellCheck, ariaDescribedBy = _a["aria-describedby"], _o = _a["aria-invalid"], ariaInvalid = _o === void 0 ? false : _o, role = _a.role, ariaLabel = _a["aria-label"], ariaExpanded = _a["aria-expanded"], ariaControls = _a["aria-controls"], ariaActiveDescendant = _a["aria-activedescendant"], ariaAutocomplete = _a["aria-autocomplete"];
|
|
6
10
|
var handleKeyDown = function (e) {
|
|
7
11
|
// Ctrl+Enter or Cmd+Enter to submit
|
|
@@ -70,7 +74,7 @@ export default function TextField(_a) {
|
|
|
70
74
|
{label}{required && <span className="text-error-text ml-0.5">*</span>}
|
|
71
75
|
</label>)}
|
|
72
76
|
<div className="relative">
|
|
73
|
-
{multiline ? (<textarea id={id} rows={maxRows} className={containerClasses} value={value} onChange={onChange} placeholder={placeholder} onFocus={onFocus} onBlur={onBlur} onKeyDown={handleKeyDown} autoFocus={autoFocus} disabled={disabled} readOnly={readOnly} required={required} name={name} autoComplete={autoComplete} tabIndex={tabIndex} maxLength={maxLength} minLength={minLength} spellCheck={spellCheck} {...errorProps}/>) : (<input id={id} type={type} inputMode={getInputMode()} className={containerClasses} value={value} onChange={onChange} placeholder={placeholder} onFocus={onFocus} onBlur={onBlur} onKeyDown={handleKeyDown} autoFocus={autoFocus} disabled={disabled} readOnly={readOnly} required={required} name={name} autoComplete={autoComplete} tabIndex={tabIndex} maxLength={maxLength} minLength={minLength} spellCheck={spellCheck} {...errorProps}/>)}
|
|
77
|
+
{multiline ? (<textarea ref={ref} id={id} rows={maxRows} className={containerClasses} value={value} onChange={onChange} placeholder={placeholder} onFocus={onFocus} onBlur={onBlur} onKeyDown={handleKeyDown} autoFocus={autoFocus} disabled={disabled} readOnly={readOnly} required={required} name={name} autoComplete={autoComplete} tabIndex={tabIndex} maxLength={maxLength} minLength={minLength} spellCheck={spellCheck} {...errorProps}/>) : (<input ref={ref} id={id} type={type} inputMode={getInputMode()} className={containerClasses} value={value} onChange={onChange} placeholder={placeholder} onFocus={onFocus} onBlur={onBlur} onKeyDown={handleKeyDown} autoFocus={autoFocus} disabled={disabled} readOnly={readOnly} required={required} name={name} autoComplete={autoComplete} tabIndex={tabIndex} maxLength={maxLength} minLength={minLength} spellCheck={spellCheck} {...errorProps}/>)}
|
|
74
78
|
</div>
|
|
75
79
|
{error && (<p id={errorId} className="mt-1 text-error-text text-body2">
|
|
76
80
|
{errorText}
|
|
@@ -79,4 +83,6 @@ export default function TextField(_a) {
|
|
|
79
83
|
{helperText}
|
|
80
84
|
</p>)}
|
|
81
85
|
</div>);
|
|
82
|
-
}
|
|
86
|
+
});
|
|
87
|
+
TextField.displayName = 'TextField';
|
|
88
|
+
export default TextField;
|
|
@@ -6,10 +6,17 @@ interface TitleBarProps {
|
|
|
6
6
|
level?: 1 | 2 | 3 | 4;
|
|
7
7
|
/** A Button before the title that goes one step up, e.g. 'Back to Inbox' */
|
|
8
8
|
back?: React.ReactNode;
|
|
9
|
-
/** Buttons at the end of the row. They never shrink; a long title wraps instead. */
|
|
9
|
+
/** Buttons at the end of the row. They never shrink; a long title wraps instead. `actionsWrap` changes this. */
|
|
10
10
|
actions?: React.ReactNode;
|
|
11
11
|
/** Below md the `actions` take their own line under the title, as `back` does above it, for a control too wide to sit beside the title (a range switch). From md up nothing changes. Ignored with `phoneActions`. */
|
|
12
12
|
actionsBelow?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* The actions move to their own line when the column leaves the title less than 15rem. It follows the column's
|
|
15
|
+
* width, not the window's. Default false. There the actions also wrap among themselves, and with `back` a
|
|
16
|
+
* narrow column can give Back a line of its own from md up too. The DOM order, the focus order and the heading
|
|
17
|
+
* stay the same, so a screen reader hears no difference. Ignored with `phoneActions`.
|
|
18
|
+
*/
|
|
19
|
+
actionsWrap?: boolean;
|
|
13
20
|
/** Below md these replace `actions`: the main action and a More menu holding the rest */
|
|
14
21
|
phoneActions?: React.ReactNode;
|
|
15
22
|
/** One line under the title: a status Tag, an AvatarStack, short facts. It wraps at every width and is not part of the heading. */
|
|
@@ -17,5 +24,5 @@ interface TitleBarProps {
|
|
|
17
24
|
/** The heading's id */
|
|
18
25
|
id?: string;
|
|
19
26
|
}
|
|
20
|
-
export default function TitleBar({ title, level, back, actions, actionsBelow, phoneActions, meta, id }: TitleBarProps): React.JSX.Element;
|
|
27
|
+
export default function TitleBar({ title, level, back, actions, actionsBelow, actionsWrap, phoneActions, meta, id }: TitleBarProps): React.JSX.Element;
|
|
21
28
|
export { TitleBar };
|
|
@@ -1,22 +1,26 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import Heading from './heading';
|
|
3
3
|
// One row from md up: back, the title, then the actions. Below md Back takes its own line above the title.
|
|
4
|
-
// A row without Back is one row at every width.
|
|
5
|
-
// move focus to it (a pane does on open) without
|
|
4
|
+
// A row without Back is one row at every width. `actionsBelow` and `actionsWrap` let it take more lines.
|
|
5
|
+
// The heading takes tabIndex -1 so a page or a pane can move focus to it (a pane does on open) without
|
|
6
|
+
// adding it to the tab order.
|
|
6
7
|
export default function TitleBar(_a) {
|
|
7
|
-
var title = _a.title, _b = _a.level, level = _b === void 0 ? 1 : _b, back = _a.back, actions = _a.actions, _c = _a.actionsBelow, actionsBelow = _c === void 0 ? false : _c, phoneActions = _a.phoneActions, meta = _a.meta, id = _a.id;
|
|
8
|
+
var title = _a.title, _b = _a.level, level = _b === void 0 ? 1 : _b, back = _a.back, actions = _a.actions, _c = _a.actionsBelow, actionsBelow = _c === void 0 ? false : _c, _d = _a.actionsWrap, actionsWrap = _d === void 0 ? false : _d, phoneActions = _a.phoneActions, meta = _a.meta, id = _a.id;
|
|
8
9
|
var below = actionsBelow && !phoneActions;
|
|
9
|
-
|
|
10
|
+
var wrap = actionsWrap && !phoneActions;
|
|
11
|
+
// 15rem is the room the title keeps before the actions leave its line
|
|
12
|
+
var titleBasis = wrap ? ' basis-60' : '';
|
|
13
|
+
return (<div className={"flex min-w-0 items-center gap-2".concat(wrap ? ' flex-wrap' : back || below ? ' flex-wrap md:flex-nowrap' : '')}>
|
|
10
14
|
{back && <div className="flex shrink-0 basis-full items-center md:basis-auto">{back}</div>}
|
|
11
|
-
{meta ? (<div className="flex min-w-0 flex-1 flex-col gap-1">
|
|
15
|
+
{meta ? (<div className={"flex min-w-0 flex-1 flex-col gap-1".concat(titleBasis)}>
|
|
12
16
|
<Heading level={level} size="h5" id={id} tabIndex={-1} className="min-w-0 break-words outline-none">
|
|
13
17
|
{title}
|
|
14
18
|
</Heading>
|
|
15
19
|
<div className="flex flex-wrap items-center gap-small text-body2 text-fg-secondary">{meta}</div>
|
|
16
|
-
</div>) : (<Heading level={level} size="h5" id={id} tabIndex={-1} className="min-w-0 flex-1 break-words outline-none">
|
|
20
|
+
</div>) : (<Heading level={level} size="h5" id={id} tabIndex={-1} className={"min-w-0 flex-1 break-words outline-none".concat(titleBasis)}>
|
|
17
21
|
{title}
|
|
18
22
|
</Heading>)}
|
|
19
|
-
{actions && <div className={"".concat(phoneActions ? 'hidden md:flex' : 'flex', " shrink-0 items-center gap-2").concat(below ? ' basis-full md:basis-auto' : '')}>{actions}</div>}
|
|
23
|
+
{actions && <div className={"".concat(phoneActions ? 'hidden md:flex' : 'flex', " ").concat(wrap ? 'max-w-full flex-wrap' : 'shrink-0', " items-center gap-2").concat(below ? ' basis-full md:basis-auto' : '')}>{actions}</div>}
|
|
20
24
|
{phoneActions && <div className="flex shrink-0 items-center gap-2 md:hidden">{phoneActions}</div>}
|
|
21
25
|
</div>);
|
|
22
26
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type DragEvent } from 'react';
|
|
1
2
|
export type FileRejection = {
|
|
2
3
|
name: string;
|
|
3
4
|
reason: 'type' | 'size' | 'count';
|
|
@@ -25,4 +26,26 @@ export declare function checkFiles(files: FileInfo[], { accept, maxBytes, multip
|
|
|
25
26
|
accepted: number[];
|
|
26
27
|
rejected: FileRejection[];
|
|
27
28
|
};
|
|
29
|
+
interface FileDragOptions {
|
|
30
|
+
/** The box takes no part: the page keeps every drag and drop */
|
|
31
|
+
off: boolean;
|
|
32
|
+
/** A file drop is taken from the page, so the browser does not open the file, then ignored, with no highlight */
|
|
33
|
+
ignore: boolean;
|
|
34
|
+
/** Every file of a drop, unchecked. May be empty. */
|
|
35
|
+
onFiles: (files: File[]) => void;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The handlers for a box that takes dropped files, and whether a file drag is over it. Only a drag whose types
|
|
39
|
+
* include 'Files' is handled, so a text drag stays native. The state clears on drag leave, on drop and when the
|
|
40
|
+
* drag is cancelled.
|
|
41
|
+
*/
|
|
42
|
+
export declare function useFileDrag({ off, ignore, onFiles }: FileDragOptions): {
|
|
43
|
+
dragging: boolean;
|
|
44
|
+
dropProps: {
|
|
45
|
+
onDragEnter: (e: DragEvent) => void;
|
|
46
|
+
onDragOver: (e: DragEvent) => void;
|
|
47
|
+
onDragLeave: (e: DragEvent) => void;
|
|
48
|
+
onDrop: (e: DragEvent) => void;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
28
51
|
export {};
|