oneslash-design-system 2.26.0 → 2.27.1

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.
Files changed (76) hide show
  1. package/dist/cases/message-attachments.md +3 -0
  2. package/dist/cases/side-pane.md +1 -0
  3. package/dist/cases.json +4 -0
  4. package/dist/components/accordion.d.ts +6 -0
  5. package/dist/components/accordion.jsx +11 -4
  6. package/dist/components/alert.d.ts +3 -1
  7. package/dist/components/alert.jsx +5 -5
  8. package/dist/components/appShell.jsx +5 -2
  9. package/dist/components/avatarStack.d.ts +3 -1
  10. package/dist/components/avatarStack.jsx +2 -2
  11. package/dist/components/codeBlock.d.ts +7 -2
  12. package/dist/components/codeBlock.jsx +5 -3
  13. package/dist/components/composer.d.ts +29 -0
  14. package/dist/components/composer.jsx +19 -5
  15. package/dist/components/dropZone.jsx +5 -64
  16. package/dist/components/fileChip.d.ts +9 -1
  17. package/dist/components/fileChip.jsx +16 -3
  18. package/dist/components/heading.d.ts +2 -2
  19. package/dist/components/heading.jsx +1 -0
  20. package/dist/components/image.d.ts +3 -1
  21. package/dist/components/image.jsx +3 -2
  22. package/dist/components/list.d.ts +15 -1
  23. package/dist/components/list.jsx +8 -3
  24. package/dist/components/menuItem.d.ts +22 -4
  25. package/dist/components/menuItem.jsx +16 -8
  26. package/dist/components/paragraph.d.ts +10 -3
  27. package/dist/components/paragraph.jsx +7 -5
  28. package/dist/components/popover.d.ts +32 -2
  29. package/dist/components/popover.jsx +72 -15
  30. package/dist/components/sharedStyles.d.ts +2 -0
  31. package/dist/components/sharedStyles.jsx +4 -0
  32. package/dist/components/sidePane.d.ts +20 -0
  33. package/dist/components/sidePane.jsx +4 -4
  34. package/dist/components/sourceCard.d.ts +6 -0
  35. package/dist/components/sourceCard.jsx +2 -2
  36. package/dist/components/textField.d.ts +6 -2
  37. package/dist/components/textField.jsx +9 -3
  38. package/dist/components/titleBar.d.ts +9 -2
  39. package/dist/components/titleBar.jsx +11 -7
  40. package/dist/internal/dropZone.d.ts +23 -0
  41. package/dist/internal/dropZone.js +71 -1
  42. package/dist/stories/Accordion.stories.d.ts +1 -0
  43. package/dist/stories/Accordion.stories.jsx +18 -1
  44. package/dist/stories/Alert.stories.d.ts +1 -0
  45. package/dist/stories/Alert.stories.jsx +14 -0
  46. package/dist/stories/AppShell.stories.d.ts +1 -0
  47. package/dist/stories/AppShell.stories.jsx +17 -0
  48. package/dist/stories/AvatarStack.stories.d.ts +1 -0
  49. package/dist/stories/AvatarStack.stories.jsx +4 -0
  50. package/dist/stories/CodeBlock.stories.d.ts +1 -0
  51. package/dist/stories/CodeBlock.stories.jsx +11 -0
  52. package/dist/stories/Composer.stories.d.ts +4 -0
  53. package/dist/stories/Composer.stories.jsx +41 -0
  54. package/dist/stories/FileChip.stories.d.ts +2 -0
  55. package/dist/stories/FileChip.stories.jsx +27 -0
  56. package/dist/stories/Heading.stories.d.ts +1 -0
  57. package/dist/stories/Heading.stories.jsx +4 -0
  58. package/dist/stories/Image.stories.d.ts +1 -0
  59. package/dist/stories/Image.stories.jsx +4 -0
  60. package/dist/stories/List.stories.d.ts +2 -0
  61. package/dist/stories/List.stories.jsx +6 -0
  62. package/dist/stories/MenuItem.stories.d.ts +4 -0
  63. package/dist/stories/MenuItem.stories.jsx +63 -0
  64. package/dist/stories/Paragraph.stories.d.ts +7 -0
  65. package/dist/stories/Paragraph.stories.jsx +30 -0
  66. package/dist/stories/Popover.stories.d.ts +4 -0
  67. package/dist/stories/Popover.stories.jsx +123 -0
  68. package/dist/stories/SidePane.stories.d.ts +2 -0
  69. package/dist/stories/SidePane.stories.jsx +34 -1
  70. package/dist/stories/SourceCard.stories.d.ts +1 -0
  71. package/dist/stories/SourceCard.stories.jsx +17 -1
  72. package/dist/stories/TextField.stories.d.ts +1 -0
  73. package/dist/stories/TextField.stories.jsx +19 -0
  74. package/dist/stories/TitleBar.stories.d.ts +1 -0
  75. package/dist/stories/TitleBar.stories.jsx +13 -0
  76. package/package.json +1 -1
@@ -5,6 +5,8 @@ A person adds files to a message, and people open the files in a message that wa
5
5
  ## Do
6
6
 
7
7
  - Show each waiting file as a `FileChip` in the Composer's `above` slot, with `onRemove`.
8
+ - To take dropped files too, pass `onDropFiles` to the Composer. Check the type and size of each file, and announce what was added or refused.
9
+ - A waiting picture can show a small `thumbnail` on its chip. Make its object URL once, and revoke it when the file is removed or sent.
8
10
  - Show a file that is still uploading with `state="uploading"` and the `meta` 'Uploading'.
9
11
  - Show a file that cannot be sent with `state="failed"` and the reason in `meta`: 'Too large. The limit is 25 MB.'
10
12
  - Pass `onClick` and the `meta` 'Failed. Try again' when the upload can be tried again. A file that is too large can only be removed.
@@ -22,6 +24,7 @@ A person adds files to a message, and people open the files in a message that wa
22
24
 
23
25
  ## Don't
24
26
 
27
+ - Do not make dropping the only way to add a file. Keep the attach button.
25
28
  - Do not show a failed upload only in an Alert away from the file.
26
29
  - Do not use the file name as the `alt` text of an image. Say what it shows.
27
30
  - Do not send a message while one of its files is still uploading.
@@ -11,6 +11,7 @@ A person opens more about the page, such as its members, its history or a docume
11
11
  - Let Close and Escape close the pane. Focus goes back to the opener.
12
12
  - Open a pane only from the person's own action. It takes focus when it mounts.
13
13
  - Make a pane resizable only when it holds a document: pass `width` and `onWidthChange`. The start edge then moves with the pointer and with the arrow keys.
14
+ - Keep the space around a pane's content. Pass `padding="none"` only when the content draws its own edges, such as code or a full-width list.
14
15
  - Use `Drawer side="end"` with a `title` for a short task. On a phone it is a sheet from the bottom.
15
16
  - Give a Drawer `initialFocus="body"` when it holds a control, so focus lands on the control. Keep the Drawer open while its request runs.
16
17
  - Show the result of a task in the page behind the Drawer, such as 'Assigned to Ben Carter.' Show no toast.
package/dist/cases.json CHANGED
@@ -4413,6 +4413,8 @@
4413
4413
  "situation": "A person adds files to a message, and people open the files in a message that was sent.",
4414
4414
  "do": [
4415
4415
  "Show each waiting file as a `FileChip` in the Composer's `above` slot, with `onRemove`.",
4416
+ "To take dropped files too, pass `onDropFiles` to the Composer. Check the type and size of each file, and announce what was added or refused.",
4417
+ "A waiting picture can show a small `thumbnail` on its chip. Make its object URL once, and revoke it when the file is removed or sent.",
4416
4418
  "Show a file that is still uploading with `state=\"uploading\"` and the `meta` 'Uploading'.",
4417
4419
  "Show a file that cannot be sent with `state=\"failed\"` and the reason in `meta`: 'Too large. The limit is 25 MB.'",
4418
4420
  "Pass `onClick` and the `meta` 'Failed. Try again' when the upload can be tried again. A file that is too large can only be removed.",
@@ -4429,6 +4431,7 @@
4429
4431
  "Open an image at full size in a `Lightbox`: render one with the list of images, the `index`, `onIndexChange`, `isOpen` and `onClose`, as the case 'Image viewer' says. Closing it gives focus back to the thumbnail."
4430
4432
  ],
4431
4433
  "dont": [
4434
+ "Do not make dropping the only way to add a file. Keep the attach button.",
4432
4435
  "Do not show a failed upload only in an Alert away from the file.",
4433
4436
  "Do not use the file name as the `alt` text of an image. Say what it shows.",
4434
4437
  "Do not send a message while one of its files is still uploading.",
@@ -6827,6 +6830,7 @@
6827
6830
  "Let Close and Escape close the pane. Focus goes back to the opener.",
6828
6831
  "Open a pane only from the person's own action. It takes focus when it mounts.",
6829
6832
  "Make a pane resizable only when it holds a document: pass `width` and `onWidthChange`. The start edge then moves with the pointer and with the arrow keys.",
6833
+ "Keep the space around a pane's content. Pass `padding=\"none\"` only when the content draws its own edges, such as code or a full-width list.",
6830
6834
  "Use `Drawer side=\"end\"` with a `title` for a short task. On a phone it is a sheet from the bottom.",
6831
6835
  "Give a Drawer `initialFocus=\"body\"` when it holds a control, so focus lands on the control. Keep the Drawer open while its request runs.",
6832
6836
  "Show the result of a task in the page behind the Drawer, such as 'Assigned to Ben Carter.' Show no toast.",
@@ -4,6 +4,12 @@ export interface AccordionItem {
4
4
  id: string;
5
5
  /** The words on the heading's button */
6
6
  title: string;
7
+ /**
8
+ * One line of secondary text under the title, inside the heading's button, such as a preview of the panel. A long
9
+ * line is cut with an ellipsis. The heading, button and region stay named by the title alone; this line is the
10
+ * button's description. Default none. For a preview of a closed item only, control `open` and leave it off open items.
11
+ */
12
+ secondTitle?: string;
7
13
  content: React.ReactNode;
8
14
  }
9
15
  interface AccordionProps {
@@ -84,16 +84,23 @@ export default function Accordion(_a) {
84
84
  var headingId = "".concat(id, "-").concat(item.id);
85
85
  var buttonId = "".concat(headingId, "-button");
86
86
  var panelId = "".concat(headingId, "-panel");
87
+ var secondTitle = item.secondTitle;
88
+ // With a second line, names point at the title's own span: a reference to the button would read both lines
89
+ var titleId = secondTitle ? "".concat(headingId, "-title") : undefined;
90
+ var secondId = secondTitle ? "".concat(headingId, "-second") : undefined;
87
91
  return (<div key={item.id}>
88
- <Heading id={headingId} className="m-0 scroll-mt-[var(--os-header-offset,0px)]">
92
+ <Heading id={headingId} aria-labelledby={titleId} className="m-0 scroll-mt-[var(--os-header-offset,0px)]">
89
93
  <button ref={function (el) {
90
94
  buttons.current[index] = el;
91
- }} id={buttonId} type="button" aria-expanded={isOpen} aria-controls={panelId} onClick={function () { return change(toggleOpen(current, item.id, multiple)); }} onKeyDown={function (e) { return onKeyDown(e, index); }} className={"flex w-full items-center justify-between gap-3 rounded-control py-3 text-left text-subtitle1 text-fg-primary ".concat(focusRing)}>
92
- <span className="min-w-0 break-words">{item.title}</span>
95
+ }} id={buttonId} type="button" aria-expanded={isOpen} aria-controls={panelId} aria-labelledby={titleId} aria-describedby={secondId} onClick={function () { return change(toggleOpen(current, item.id, multiple)); }} onKeyDown={function (e) { return onKeyDown(e, index); }} className={"flex w-full items-center justify-between gap-3 rounded-control py-3 text-left text-subtitle1 text-fg-primary ".concat(focusRing)}>
96
+ {secondTitle ? (<span className="flex min-w-0 flex-col">
97
+ <span id={titleId} className="min-w-0 break-words">{item.title}</span>
98
+ <span id={secondId} className="truncate text-body2 text-fg-secondary">{secondTitle}</span>
99
+ </span>) : (<span className="min-w-0 break-words">{item.title}</span>)}
93
100
  <ChevronDown aria-hidden strokeWidth={2} className={"h-6 w-6 shrink-0 text-fg-secondary transition-transform duration-[var(--os-duration-fast)] ease-out motion-reduce:transition-none ".concat(isOpen ? 'rotate-180' : '')}/>
94
101
  </button>
95
102
  </Heading>
96
- <div id={panelId} hidden={!isOpen} role={regions ? 'region' : undefined} aria-labelledby={regions ? buttonId : undefined} className="pb-4 text-body1 text-fg-secondary">
103
+ <div id={panelId} hidden={!isOpen} role={regions ? 'region' : undefined} aria-labelledby={regions ? titleId !== null && titleId !== void 0 ? titleId : buttonId : undefined} className="pb-4 text-body1 text-fg-secondary">
97
104
  {item.content}
98
105
  </div>
99
106
  </div>);
@@ -8,11 +8,13 @@ interface AlertProps {
8
8
  secondMessage?: string;
9
9
  onClose?: () => void;
10
10
  showCloseButton?: boolean;
11
+ /** The close button's accessible name, for a close that does more than dismiss a message ('Turn off plan mode'). Default 'Dismiss'. No effect without `showCloseButton`. */
12
+ closeLabel?: string;
11
13
  variant?: 'toast' | 'inline';
12
14
  /** Not set: the alert dismisses itself after 5 seconds unless it has a close button. `false` keeps it open; `true` dismisses it even with a close button. */
13
15
  autoDismiss?: boolean;
14
16
  /** Default `true`: the alert is a live region (`role="alert"` for errors, `role="status"` otherwise). `false` drops the role, for an alert whose text is announced elsewhere, as Toaster does. */
15
17
  announce?: boolean;
16
18
  }
17
- export default function Alert({ id, open, type, message, secondMessage, onClose, showCloseButton, variant, autoDismiss, announce, }: AlertProps): React.JSX.Element | null;
19
+ export default function Alert({ id, open, type, message, secondMessage, onClose, showCloseButton, closeLabel, variant, autoDismiss, announce, }: AlertProps): React.JSX.Element | null;
18
20
  export {};
@@ -18,11 +18,11 @@ var motionClasses = {
18
18
  };
19
19
  export default function Alert(_a) {
20
20
  var _b;
21
- var id = _a.id, _c = _a.open, open = _c === void 0 ? true : _c, type = _a.type, message = _a.message, secondMessage = _a.secondMessage, onClose = _a.onClose, _d = _a.showCloseButton, showCloseButton = _d === void 0 ? false : _d, _e = _a.variant, variant = _e === void 0 ? 'toast' : _e, autoDismiss = _a.autoDismiss, _f = _a.announce, announce = _f === void 0 ? true : _f;
22
- var _g = useState(false), isVisible = _g[0], setIsVisible = _g[1];
23
- var _h = useState(false), shouldRender = _h[0], setShouldRender = _h[1];
21
+ var id = _a.id, _c = _a.open, open = _c === void 0 ? true : _c, type = _a.type, message = _a.message, secondMessage = _a.secondMessage, onClose = _a.onClose, _d = _a.showCloseButton, showCloseButton = _d === void 0 ? false : _d, _e = _a.closeLabel, closeLabel = _e === void 0 ? 'Dismiss' : _e, _f = _a.variant, variant = _f === void 0 ? 'toast' : _f, autoDismiss = _a.autoDismiss, _g = _a.announce, announce = _g === void 0 ? true : _g;
22
+ var _h = useState(false), isVisible = _h[0], setIsVisible = _h[1];
23
+ var _j = useState(false), shouldRender = _j[0], setShouldRender = _j[1];
24
24
  // Auto-dismiss pauses while the toast is hovered or focused
25
- var _j = useState(false), isPaused = _j[0], setIsPaused = _j[1];
25
+ var _k = useState(false), isPaused = _k[0], setIsPaused = _k[1];
26
26
  var remainingMs = useRef(AUTO_DISMISS_MS);
27
27
  useEffect(function () {
28
28
  if (open) {
@@ -77,7 +77,7 @@ export default function Alert(_a) {
77
77
  </div>
78
78
  </div>
79
79
  {showCloseButton && (<div className="ml-4">
80
- <IconButton color="iconOnly" state="enabled" size="small" iconName="X" ariaLabel="Dismiss" onClick={handleClose}/>
80
+ <IconButton color="iconOnly" state="enabled" size="small" iconName="X" ariaLabel={closeLabel} onClick={handleClose}/>
81
81
  </div>)}
82
82
  </div>);
83
83
  if (variant === 'inline') {
@@ -61,11 +61,14 @@ export default function AppShell(_a) {
61
61
  (_c = ((_b = (_a = columnRef.current) === null || _a === void 0 ? void 0 : _a.querySelector('[aria-current]')) !== null && _b !== void 0 ? _b : mainRef.current)) === null || _c === void 0 ? void 0 : _c.focus();
62
62
  }, [navOpen]);
63
63
  // A choice in the menu (a link or a menu item in the sidebar itself) closes it. A Button that opens
64
- // its own menu (aria-haspopup) does not, and neither does an item in a Popover, which is not in the panel.
64
+ // its own menu (aria-haspopup) does not, nor does a disabled item (aria-disabled), and neither does
65
+ // an item in a Popover, which is not in the panel.
65
66
  var closeOnChoice = function (e) {
66
67
  var _a, _b;
67
68
  var choice = (_b = (_a = e.target).closest) === null || _b === void 0 ? void 0 : _b.call(_a, 'a[href], [role="menuitem"]');
68
- if (choice && e.currentTarget.contains(choice) && !choice.hasAttribute('aria-haspopup'))
69
+ if (!choice || !e.currentTarget.contains(choice))
70
+ return;
71
+ if (!choice.hasAttribute('aria-haspopup') && choice.getAttribute('aria-disabled') !== 'true')
69
72
  onNavOpenChange(false);
70
73
  };
71
74
  var skipLink = function (target, shown) { return (<a href={"#".concat(target)} className={"sr-only focus:not-sr-only focus:fixed focus:left-2 focus:top-2 focus:z-[var(--os-z-tooltip)] focus:rounded-control focus:bg-background-elevated focus:px-3 focus:py-2 focus:text-body2 focus:text-fg-primary focus:shadow-overlay ".concat(focusRing).concat(shown)}>
@@ -9,6 +9,8 @@ interface AvatarStackProps {
9
9
  max?: number;
10
10
  /** Face diameter in pixels. Default 24. */
11
11
  size?: number;
12
+ /** Draws the letter circles in grey, as `UserImage grayscale` does. A picture keeps its own colors. Default false. It does not change the spoken names. */
13
+ grayscale?: boolean;
12
14
  /** The spoken name of the group. Defaults to the names, e.g. 'Dana Lee, Ben Carter and 4 others'. */
13
15
  'aria-label'?: string;
14
16
  /** Makes the stack one button. The caller anchors a Popover on `event.currentTarget` to list everyone. */
@@ -18,5 +20,5 @@ interface AvatarStackProps {
18
20
  /** With `onClick`: whether what it opens is open now */
19
21
  'aria-expanded'?: boolean;
20
22
  }
21
- export default function AvatarStack({ people, max, size, 'aria-label': ariaLabel, onClick, 'aria-haspopup': ariaHasPopup, 'aria-expanded': ariaExpanded, }: AvatarStackProps): React.JSX.Element | null;
23
+ export default function AvatarStack({ people, max, size, grayscale, 'aria-label': ariaLabel, onClick, 'aria-haspopup': ariaHasPopup, 'aria-expanded': ariaExpanded, }: AvatarStackProps): React.JSX.Element | null;
22
24
  export {};
@@ -6,7 +6,7 @@ import { peopleLabel } from '../internal/people';
6
6
  var ring = 'rounded-full border-2 border-background-default';
7
7
  // Overlapping faces for the people on a thing. Past `max` the last circle counts the rest.
8
8
  export default function AvatarStack(_a) {
9
- var people = _a.people, _b = _a.max, max = _b === void 0 ? 4 : _b, _c = _a.size, size = _c === void 0 ? 24 : _c, ariaLabel = _a["aria-label"], onClick = _a.onClick, ariaHasPopup = _a["aria-haspopup"], ariaExpanded = _a["aria-expanded"];
9
+ var people = _a.people, _b = _a.max, max = _b === void 0 ? 4 : _b, _c = _a.size, size = _c === void 0 ? 24 : _c, _d = _a.grayscale, grayscale = _d === void 0 ? false : _d, ariaLabel = _a["aria-label"], onClick = _a.onClick, ariaHasPopup = _a["aria-haspopup"], ariaExpanded = _a["aria-expanded"];
10
10
  if (people.length === 0)
11
11
  return null;
12
12
  var over = people.length > max;
@@ -15,7 +15,7 @@ export default function AvatarStack(_a) {
15
15
  var overlap = function (i) { return (i > 0 ? ' -ml-2' : ''); };
16
16
  var faces = (<>
17
17
  {shown.map(function (p, i) { return (<span key={i} className={"inline-flex shrink-0 ".concat(ring).concat(overlap(i))}>
18
- <UserImage userHandle={p.name} userImgUrl={p.imageUrl} size={size} decorative/>
18
+ <UserImage userHandle={p.name} userImgUrl={p.imageUrl} size={size} grayscale={grayscale} decorative/>
19
19
  </span>); })}
20
20
  {over && (<span aria-hidden="true" style={{ width: size + 4, height: size + 4 }} className={"inline-flex shrink-0 items-center justify-center bg-background-accent200 text-fg-primary text-caption ".concat(ring).concat(overlap(shown.length))}>
21
21
  +{people.length - shown.length}
@@ -8,6 +8,11 @@ interface CodeBlockProps {
8
8
  language?: string;
9
9
  /** Wrap long lines instead of scrolling them sideways. Default false. */
10
10
  wrap?: boolean;
11
+ /**
12
+ * The most lines the code is tall; the rest scrolls inside the code, in the same named region a keyboard can focus.
13
+ * Copy still copies the whole text. Default none: the code is as tall as its text.
14
+ */
15
+ maxRows?: number;
11
16
  /** The button's words. Defaults to "Copy". */
12
17
  copyLabel?: string;
13
18
  /** The button's words for 2 seconds after the text is on the clipboard. Defaults to "Copied". */
@@ -19,8 +24,8 @@ interface CodeBlockProps {
19
24
  * Code in a figure: a visible label, a Copy button at the end of the label row, and the code on the panel
20
25
  * surface. A long line scrolls inside the code, a named region a keyboard can focus and scroll; the page never
21
26
  * does. "Copied" shows only after the browser accepted the text; otherwise a line says to copy by hand.
22
- * With `wrap` the block is still a Tab stop, so use `wrap` only for short blocks.
27
+ * With `wrap` the block is still a Tab stop, so use `wrap` only for short blocks, or give a long one `maxRows`.
23
28
  * No highlighting and no line numbers. One line to paste is a `CopyField`.
24
29
  */
25
- export default function CodeBlock({ code, label, language, wrap, copyLabel, copiedLabel, id, }: CodeBlockProps): React.JSX.Element;
30
+ export default function CodeBlock({ code, label, language, wrap, maxRows, copyLabel, copiedLabel, id, }: CodeBlockProps): React.JSX.Element;
26
31
  export { CodeBlock };
@@ -43,12 +43,12 @@ import { focusRing } from './sharedStyles';
43
43
  * Code in a figure: a visible label, a Copy button at the end of the label row, and the code on the panel
44
44
  * surface. A long line scrolls inside the code, a named region a keyboard can focus and scroll; the page never
45
45
  * does. "Copied" shows only after the browser accepted the text; otherwise a line says to copy by hand.
46
- * With `wrap` the block is still a Tab stop, so use `wrap` only for short blocks.
46
+ * With `wrap` the block is still a Tab stop, so use `wrap` only for short blocks, or give a long one `maxRows`.
47
47
  * No highlighting and no line numbers. One line to paste is a `CopyField`.
48
48
  */
49
49
  export default function CodeBlock(_a) {
50
50
  var _this = this;
51
- var code = _a.code, label = _a.label, language = _a.language, _b = _a.wrap, wrap = _b === void 0 ? false : _b, _c = _a.copyLabel, copyLabel = _c === void 0 ? 'Copy' : _c, _d = _a.copiedLabel, copiedLabel = _d === void 0 ? 'Copied' : _d, id = _a.id;
51
+ var code = _a.code, label = _a.label, language = _a.language, _b = _a.wrap, wrap = _b === void 0 ? false : _b, maxRows = _a.maxRows, _c = _a.copyLabel, copyLabel = _c === void 0 ? 'Copy' : _c, _d = _a.copiedLabel, copiedLabel = _d === void 0 ? 'Copied' : _d, id = _a.id;
52
52
  var _e = useState(false), copied = _e[0], setCopied = _e[1];
53
53
  var _f = useState(false), blocked = _f[0], setBlocked = _f[1];
54
54
  var timer = useRef(undefined);
@@ -87,7 +87,9 @@ export default function CodeBlock(_a) {
87
87
  <div className="flex-shrink-0">
88
88
  <Button size="small" type="tertiary" state="enabled" label={copied ? copiedLabel : copyLabel} aria-label={"".concat(copied ? copiedLabel : copyLabel, " ").concat(label)} aria-describedby={blocked ? blockedId : undefined} onClickButton={handleCopy}/>
89
89
  </div>
90
- <pre id={"".concat(id, "-code")} tabIndex={0} role="region" aria-label={label} className={"col-span-2 m-0 max-w-full overflow-x-auto rounded-control bg-background-panel p-medium font-mono text-body2 text-fg-primary ".concat(wrap ? 'whitespace-pre-wrap break-words' : '', " ").concat(focusRing)}>
90
+ <pre id={"".concat(id, "-code")} tabIndex={0} role="region" aria-label={label}
91
+ // The height of that many lines plus the p-medium above and below them
92
+ style={maxRows ? { maxHeight: "calc(".concat(maxRows, "lh + 2 * var(--os-spacing-medium))") } : undefined} className={"col-span-2 m-0 max-w-full ".concat(maxRows ? 'overflow-auto' : 'overflow-x-auto', " rounded-control bg-background-panel p-medium font-mono text-body2 text-fg-primary ").concat(wrap ? 'whitespace-pre-wrap break-words' : '', " ").concat(focusRing)}>
91
93
  <code>{code}</code>
92
94
  </pre>
93
95
  {blocked && (<p id={blockedId} role="alert" className="col-span-2 text-error-text text-body2">
@@ -69,6 +69,35 @@ interface ComposerProps extends React.AriaAttributes {
69
69
  * word it completes.
70
70
  */
71
71
  onSelect?: (event: React.SyntheticEvent<HTMLTextAreaElement>) => void;
72
+ /**
73
+ * Default undefined: the box takes no drop. When set, files can be dropped anywhere on the box. Only a drag
74
+ * of files is handled, so dragging text into the field works as before. During such a drag the border is
75
+ * dashed in the primary text color. Every dropped file is passed on: the caller checks type and size and
76
+ * words any errors. While `disabled`, a file drop is taken from the page and ignored, with no highlight.
77
+ * Accessibility: dropping is only an extra way in. Keep an attach control in `tools` for keyboard, touch and
78
+ * screen reader users. The Composer announces nothing: the caller says which files were added or refused.
79
+ */
80
+ onDropFiles?: (files: File[]) => void;
81
+ /**
82
+ * Default undefined. React's `onPaste` on the text area. Call `preventDefault()` to take a paste, for
83
+ * instance to attach pasted files or a long text. The Composer adds no paste handling of its own, so
84
+ * without that call the paste stays native. When you take a paste, say what was added.
85
+ */
86
+ onPaste?: React.ClipboardEventHandler<HTMLTextAreaElement>;
87
+ /** Default undefined, so the browser decides. The text area's `spellcheck`. */
88
+ spellCheck?: boolean;
89
+ /**
90
+ * Default undefined, so the field has the page's language. The text area's `lang`: it tells assistive
91
+ * technology which language the field is in, and the browser may use it to check spelling.
92
+ */
93
+ lang?: string;
94
+ /**
95
+ * Default undefined. On the text area, after the Composer's own composition tracking (an input method,
96
+ * such as Korean, Japanese or Chinese, has started to compose text)
97
+ */
98
+ onCompositionStart?: (event: React.CompositionEvent<HTMLTextAreaElement>) => void;
99
+ /** Default undefined. On the text area, after the Composer's own composition tracking */
100
+ onCompositionEnd?: (event: React.CompositionEvent<HTMLTextAreaElement>) => void;
72
101
  }
73
102
  declare const Composer: React.ForwardRefExoticComponent<ComposerProps & React.RefAttributes<HTMLTextAreaElement>>;
74
103
  export default Composer;
@@ -17,12 +17,13 @@ import { Cluster } from './layout';
17
17
  import { stateTransition } from './sharedStyles';
18
18
  import { fitToContent } from '../internal/autoGrow';
19
19
  import { isComposing, shouldSubmit } from '../internal/composer';
20
+ import { useFileDrag } from '../internal/dropZone';
20
21
  // The outline the text area's focus gives the box: Textarea's focus look, on the border around everything
21
22
  var focusedOutline = 'outline outline-1 outline-offset-2 outline-fg-primary';
22
23
  // The message box: a text area with its tools inside one border. Enter sends, Shift+Enter adds a line,
23
24
  // and Enter that confirms an input method's text (Korean, Japanese, Chinese) does neither.
24
25
  var Composer = forwardRef(function Composer(_a, ref) {
25
- var id = _a.id, value = _a.value, onChange = _a.onChange, onSubmit = _a.onSubmit, placeholder = _a.placeholder, ariaLabel = _a["aria-label"], _b = _a.disabled, disabled = _b === void 0 ? false : _b, _c = _a.maxRows, maxRows = _c === void 0 ? 6 : _c, _d = _a.autoFocus, autoFocus = _d === void 0 ? false : _d, above = _a.above, tools = _a.tools, actions = _a.actions, _e = _a.sendLabel, sendLabel = _e === void 0 ? 'Send' : _e, _f = _a.sending, sending = _f === void 0 ? false : _f, onStop = _a.onStop, _g = _a.stopLabel, stopLabel = _g === void 0 ? 'Stop' : _g, canSubmit = _a.canSubmit, _h = _a.submitOnEnter, submitOnEnter = _h === void 0 ? true : _h, onKeyDown = _a.onKeyDown, onFocus = _a.onFocus, onBlur = _a.onBlur, onSelect = _a.onSelect, textareaProps = __rest(_a, ["id", "value", "onChange", "onSubmit", "placeholder", 'aria-label', "disabled", "maxRows", "autoFocus", "above", "tools", "actions", "sendLabel", "sending", "onStop", "stopLabel", "canSubmit", "submitOnEnter", "onKeyDown", "onFocus", "onBlur", "onSelect"]) // role and aria-*
26
+ var id = _a.id, value = _a.value, onChange = _a.onChange, onSubmit = _a.onSubmit, placeholder = _a.placeholder, ariaLabel = _a["aria-label"], _b = _a.disabled, disabled = _b === void 0 ? false : _b, _c = _a.maxRows, maxRows = _c === void 0 ? 6 : _c, _d = _a.autoFocus, autoFocus = _d === void 0 ? false : _d, above = _a.above, tools = _a.tools, actions = _a.actions, _e = _a.sendLabel, sendLabel = _e === void 0 ? 'Send' : _e, _f = _a.sending, sending = _f === void 0 ? false : _f, onStop = _a.onStop, _g = _a.stopLabel, stopLabel = _g === void 0 ? 'Stop' : _g, canSubmit = _a.canSubmit, _h = _a.submitOnEnter, submitOnEnter = _h === void 0 ? true : _h, onKeyDown = _a.onKeyDown, onFocus = _a.onFocus, onBlur = _a.onBlur, onSelect = _a.onSelect, onDropFiles = _a.onDropFiles, onPaste = _a.onPaste, spellCheck = _a.spellCheck, lang = _a.lang, onCompositionStart = _a.onCompositionStart, onCompositionEnd = _a.onCompositionEnd, textareaProps = __rest(_a, ["id", "value", "onChange", "onSubmit", "placeholder", 'aria-label', "disabled", "maxRows", "autoFocus", "above", "tools", "actions", "sendLabel", "sending", "onStop", "stopLabel", "canSubmit", "submitOnEnter", "onKeyDown", "onFocus", "onBlur", "onSelect", "onDropFiles", "onPaste", "spellCheck", "lang", "onCompositionStart", "onCompositionEnd"]) // role and aria-*
26
27
  ;
27
28
  var textareaRef = useRef(null);
28
29
  useImperativeHandle(ref, function () { return textareaRef.current; }, []);
@@ -38,6 +39,15 @@ var Composer = forwardRef(function Composer(_a, ref) {
38
39
  useEffect(function () {
39
40
  adjustHeight();
40
41
  }, [adjustHeight, value]);
42
+ var _k = useFileDrag({
43
+ off: !onDropFiles,
44
+ ignore: disabled,
45
+ onFiles: function (files) {
46
+ if (files.length > 0)
47
+ onDropFiles === null || onDropFiles === void 0 ? void 0 : onDropFiles(files);
48
+ },
49
+ }), dragging = _k.dragging, dropProps = _k.dropProps;
50
+ var dropping = dragging && !disabled && onDropFiles !== undefined;
41
51
  var hasSomething = canSubmit !== null && canSubmit !== void 0 ? canSubmit : value.trim() !== '';
42
52
  var canSend = hasSomething && !disabled && !sending;
43
53
  var handleKeyDown = function (e) {
@@ -88,9 +98,11 @@ var Composer = forwardRef(function Composer(_a, ref) {
88
98
  e.preventDefault();
89
99
  (_b = textareaRef.current) === null || _b === void 0 ? void 0 : _b.focus();
90
100
  };
101
+ // While files are dragged over the box, DropZone's drag look: a dashed border in the primary text color
102
+ var edgeClasses = dropping ? 'border-dashed border-fg-primary' : 'border-fg-disabled hover:border-fg-secondary';
91
103
  var boxClasses = disabled
92
104
  ? 'bg-transparent border-fg-disabled'
93
- : "bg-background-default border-fg-disabled hover:border-fg-secondary cursor-text".concat(focused ? " ".concat(focusedOutline) : '');
105
+ : "bg-background-default ".concat(edgeClasses, " cursor-text").concat(focused ? " ".concat(focusedOutline) : '');
94
106
  var textClasses = disabled ? 'text-fg-disabled cursor-not-allowed' : 'text-fg-primary';
95
107
  // IconButton names a loading button 'Loading'; aria-labelledby wins over that name
96
108
  var sendLabelId = "".concat(id, "-send-label");
@@ -100,7 +112,7 @@ var Composer = forwardRef(function Composer(_a, ref) {
100
112
  </span>)}
101
113
  <IconButton color="primary" state={canSend || sending ? 'enabled' : 'disabled'} size="small" icon={ArrowUp} ariaLabel={sendLabel} aria-labelledby={sending ? sendLabelId : undefined} loading={sending} onClick={canSend ? handleSend : undefined}/>
102
114
  </>));
103
- return (<div className={"flex flex-col gap-small w-full p-2 border rounded-control ".concat(stateTransition, " ").concat(boxClasses)} onMouseDown={handleMouseDown}>
115
+ return (<div className={"flex flex-col gap-small w-full p-2 border rounded-control ".concat(stateTransition, " ").concat(boxClasses)} onMouseDown={handleMouseDown} {...(onDropFiles && dropProps)}>
104
116
  {above && <div ref={aboveRef}>{above}</div>}
105
117
  <textarea {...textareaProps} ref={textareaRef} id={id} rows={1} className={"block w-full px-1 bg-transparent outline-none resize-none [&::-webkit-scrollbar]:hidden text-body1 leading-[22px] placeholder:text-fg-disabled ".concat(textClasses)} value={value} onChange={function (e) { return onChange(e.target.value); }} onInput={adjustHeight} onKeyDown={handleKeyDown} onFocus={function (e) {
106
118
  setFocused(true);
@@ -108,10 +120,12 @@ var Composer = forwardRef(function Composer(_a, ref) {
108
120
  }} onBlur={function (e) {
109
121
  setFocused(false);
110
122
  onBlur === null || onBlur === void 0 ? void 0 : onBlur(e);
111
- }} onSelect={onSelect} onCompositionStart={function () {
123
+ }} onSelect={onSelect} onPaste={onPaste} spellCheck={spellCheck} lang={lang} onCompositionStart={function (e) {
112
124
  composingRef.current = true;
113
- }} onCompositionEnd={function () {
125
+ onCompositionStart === null || onCompositionStart === void 0 ? void 0 : onCompositionStart(e);
126
+ }} onCompositionEnd={function (e) {
114
127
  composingRef.current = false;
128
+ onCompositionEnd === null || onCompositionEnd === void 0 ? void 0 : onCompositionEnd(e);
115
129
  }} placeholder={placeholder} aria-label={ariaLabel} autoFocus={autoFocus} disabled={disabled} autoComplete="off"/>
116
130
  <Cluster justify={tools ? 'between' : 'end'}>
117
131
  {tools && <Cluster gap="small">{tools}</Cluster>}
@@ -1,9 +1,8 @@
1
1
  'use client';
2
- import React, { useEffect, useRef, useState } from 'react';
2
+ import React, { useRef, useState } from 'react';
3
3
  import { Upload } from 'lucide-react';
4
4
  import Button from './button';
5
- import { checkFiles } from '../internal/dropZone';
6
- var hasFiles = function (e) { var _a, _b; return Array.from((_b = (_a = e.dataTransfer) === null || _a === void 0 ? void 0 : _a.types) !== null && _b !== void 0 ? _b : []).includes('Files'); };
5
+ import { checkFiles, useFileDrag } from '../internal/dropZone';
7
6
  // A place to drop files, and a Button that opens the file chooser for everyone who does not drag (keyboard,
8
7
  // touch, screen reader). The drop checks each file against `accept`, `maxBytes` and the count, then reports
9
8
  // the good ones through `onFiles` and the bad ones, with a reason, through `onReject`. A drag over the page
@@ -11,37 +10,9 @@ var hasFiles = function (e) { var _a, _b; return Array.from((_b = (_a = e.dataTr
11
10
  export default function DropZone(_a) {
12
11
  var id = _a.id, label = _a.label, _b = _a.buttonLabel, buttonLabel = _b === void 0 ? 'Choose File' : _b, hint = _a.hint, accept = _a.accept, maxBytes = _a.maxBytes, _c = _a.multiple, multiple = _c === void 0 ? false : _c, maxFiles = _a.maxFiles, _d = _a.disabled, disabled = _d === void 0 ? false : _d, _e = _a.loading, loading = _e === void 0 ? false : _e, _f = _a.size, size = _f === void 0 ? 'large' : _f, onFiles = _a.onFiles, onReject = _a.onReject, children = _a.children, describedBy = _a["aria-describedby"], invalid = _a["aria-invalid"], status = _a.status;
13
12
  var inputRef = useRef(null);
14
- // Entering a child fires dragenter before the parent's dragleave, so count them to keep the state steady
15
- var depth = useRef(0);
16
- var _g = useState(false), dragging = _g[0], setDragging = _g[1];
17
- var _h = useState(''), said = _h[0], setSaid = _h[1];
13
+ var _g = useState(''), said = _g[0], setSaid = _g[1];
18
14
  var labelId = "".concat(id, "-label");
19
15
  var hintId = "".concat(id, "-hint");
20
- var stop = function () {
21
- depth.current = 0;
22
- setDragging(false);
23
- };
24
- // A drag cancelled with Escape, or dropped somewhere else, may not reach the zone: clear on the page's events
25
- useEffect(function () {
26
- if (!dragging)
27
- return;
28
- var onKey = function (e) {
29
- if (e.key === 'Escape')
30
- stop();
31
- };
32
- window.addEventListener('drop', stop);
33
- window.addEventListener('dragend', stop);
34
- window.addEventListener('keydown', onKey);
35
- return function () {
36
- window.removeEventListener('drop', stop);
37
- window.removeEventListener('dragend', stop);
38
- window.removeEventListener('keydown', onKey);
39
- };
40
- }, [dragging]);
41
- useEffect(function () {
42
- if (disabled || loading)
43
- stop();
44
- }, [disabled, loading]);
45
16
  var handle = function (list) {
46
17
  if (list.length === 0)
47
18
  return;
@@ -57,38 +28,8 @@ export default function DropZone(_a) {
57
28
  if (rejected.length > 0)
58
29
  onReject === null || onReject === void 0 ? void 0 : onReject(rejected);
59
30
  };
60
- var onDragEnter = function (e) {
61
- if (disabled || !hasFiles(e))
62
- return;
63
- e.preventDefault();
64
- if (loading)
65
- return;
66
- depth.current += 1;
67
- setDragging(true);
68
- };
69
- var onDragOver = function (e) {
70
- if (disabled || !hasFiles(e))
71
- return;
72
- e.preventDefault();
73
- };
74
- var onDragLeave = function (e) {
75
- if (disabled || !hasFiles(e))
76
- return;
77
- depth.current = Math.max(0, depth.current - 1);
78
- if (depth.current === 0)
79
- setDragging(false);
80
- };
81
- var onDrop = function (e) {
82
- if (disabled || !hasFiles(e))
83
- return;
84
- // Taken from the page while loading, so the browser does not open the file, then ignored
85
- e.preventDefault();
86
- stop();
87
- if (loading)
88
- return;
89
- handle(Array.from(e.dataTransfer.files));
90
- };
91
- var dropProps = { onDragEnter: onDragEnter, onDragOver: onDragOver, onDragLeave: onDragLeave, onDrop: onDrop };
31
+ // While loading, a drop is taken from the page and ignored
32
+ var _h = useFileDrag({ off: disabled, ignore: loading, onFiles: handle }), dragging = _h.dragging, dropProps = _h.dropProps;
92
33
  var button = (<Button size="small" type="secondary" state={disabled ? 'disabled' : 'enabled'} loading={loading} label={buttonLabel} aria-describedby={[hint ? hintId : '', describedBy !== null && describedBy !== void 0 ? describedBy : ''].filter(Boolean).join(' ') || undefined} onClickButton={function () { var _a; return (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.click(); }}/>);
93
34
  var input = (<input ref={inputRef} id={"".concat(id, "-input")} type="file" className="hidden" tabIndex={-1} aria-hidden="true" accept={accept && accept.length > 0 ? accept.join(',') : undefined} multiple={multiple} disabled={disabled} onChange={function (e) {
94
35
  var _a;
@@ -4,6 +4,14 @@ interface FileChipProps {
4
4
  name: string;
5
5
  /** A short type label such as 'PDF', shown in a small tinted box before the name */
6
6
  kind?: string;
7
+ /**
8
+ * An image URL, default undefined. The picture is drawn small and cropped in a square, in place of `kind`.
9
+ * The uploading and failed marks come first. If the picture does not load, `kind` shows again; a new URL
10
+ * starts over. With an object URL, the caller makes it once, keeps it, and revokes it when done.
11
+ * Accessibility: it is decorative (an empty `alt`), since `name` identifies the file, and the chip's name
12
+ * does not change. It is not a preview: show an image people need to see some other way.
13
+ */
14
+ thumbnail?: string;
7
15
  /**
8
16
  * One line of secondary text: the size, or the status. An uploading or failed chip
9
17
  * does not announce its state in words, so put the words here ('Uploading', 'Upload failed').
@@ -29,5 +37,5 @@ interface FileChipProps {
29
37
  /** With `href`: open in a new tab. Another site (`http(s)://`) always opens in a new tab. */
30
38
  openInNewTab?: boolean;
31
39
  }
32
- export default function FileChip({ name, kind, meta, state, onRemove, removeLabel, href, onClick, openInNewTab, }: FileChipProps): React.JSX.Element;
40
+ export default function FileChip({ name, kind, thumbnail, meta, state, onRemove, removeLabel, href, onClick, openInNewTab, }: FileChipProps): React.JSX.Element;
33
41
  export {};
@@ -10,7 +10,7 @@ var __assign = (this && this.__assign) || function () {
10
10
  };
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
- import React from 'react';
13
+ import React, { useEffect, useRef, useState } from 'react';
14
14
  import NextLink from 'next/link';
15
15
  import { AlertCircle, X } from 'lucide-react';
16
16
  import IconButton from './iconButton';
@@ -20,15 +20,28 @@ import { focusRing, stateTransition } from './sharedStyles';
20
20
  // 28rem wide so a long name does not stretch it. The name part is the link or button; the remove
21
21
  // button is its sibling, never inside it. With no `href` and no `onClick` the name is static text.
22
22
  export default function FileChip(_a) {
23
- var name = _a.name, kind = _a.kind, meta = _a.meta, _b = _a.state, state = _b === void 0 ? 'ready' : _b, onRemove = _a.onRemove, removeLabel = _a.removeLabel, href = _a.href, onClick = _a.onClick, _c = _a.openInNewTab, openInNewTab = _c === void 0 ? false : _c;
23
+ var name = _a.name, kind = _a.kind, thumbnail = _a.thumbnail, meta = _a.meta, _b = _a.state, state = _b === void 0 ? 'ready' : _b, onRemove = _a.onRemove, removeLabel = _a.removeLabel, href = _a.href, onClick = _a.onClick, _c = _a.openInNewTab, openInNewTab = _c === void 0 ? false : _c;
24
24
  var failed = state === 'failed';
25
25
  var interactive = href !== undefined || onClick !== undefined;
26
26
  var nameClasses = "flex min-w-0 flex-1 items-center gap-2 rounded-control text-left".concat(interactive ? " cursor-pointer ".concat(stateTransition, " ").concat(focusRing) : '');
27
+ // The failure belongs to one URL: another URL starts over
28
+ var _d = useState({ url: thumbnail, failed: false }), picture = _d[0], setPicture = _d[1];
29
+ if (picture.url !== thumbnail)
30
+ setPicture({ url: thumbnail, failed: false });
31
+ var showPicture = Boolean(thumbnail) && !(picture.url === thumbnail && picture.failed);
32
+ var pictureRef = useRef(null);
33
+ // A picture that failed before React listened (server-rendered HTML) is complete with no pixels. Loading it
34
+ // again reports the error; a good one with no natural size (an SVG with only a viewBox) just loads again.
35
+ useEffect(function () {
36
+ var img = pictureRef.current;
37
+ if ((img === null || img === void 0 ? void 0 : img.complete) && img.naturalWidth === 0)
38
+ img.src = img.src;
39
+ }, [thumbnail]);
27
40
  var lead = state === 'uploading' ? (
28
41
  // The caller says "Uploading" in `meta`; the spinner's own "Loading" status is hidden.
29
42
  <span aria-hidden="true" className="flex size-6 shrink-0 items-center justify-center text-fg-primary">
30
43
  <LoadingSmall size="tiny"/>
31
- </span>) : failed ? (<AlertCircle role="img" aria-label="Failed" className="size-6 shrink-0 p-1 text-error-text" strokeWidth={2}/>) : kind ? (<span aria-hidden="true" className="flex h-6 shrink-0 items-center rounded-inline bg-background-accent300 px-1.5 text-caption text-fg-primary">
44
+ </span>) : failed ? (<AlertCircle role="img" aria-label="Failed" className="size-6 shrink-0 p-1 text-error-text" strokeWidth={2}/>) : showPicture ? (<img key={thumbnail} ref={pictureRef} src={thumbnail} alt="" className="size-6 shrink-0 rounded-inline object-cover" onError={function () { return setPicture({ url: thumbnail, failed: true }); }}/>) : kind ? (<span aria-hidden="true" className="flex h-6 shrink-0 items-center rounded-inline bg-background-accent300 px-1.5 text-caption text-fg-primary">
32
45
  {kind}
33
46
  </span>) : null;
34
47
  var content = (<>
@@ -3,8 +3,8 @@ interface HeadingProps {
3
3
  children: React.ReactNode;
4
4
  /** The element: h1 to h4. Pick the one that fits the page's outline, not the size. */
5
5
  level?: 1 | 2 | 3 | 4;
6
- /** How large it is set. */
7
- size?: 'h4' | 'h5' | 'h6' | 'subtitle1';
6
+ /** How large it is set. Default 'h6'. `level` still picks the element, so the page's outline does not change with the size. */
7
+ size?: 'h4' | 'h5' | 'h6' | 'subtitle1' | 'subtitle2';
8
8
  /** `danger` gives the heading the error text color, for a danger zone. */
9
9
  color?: 'default' | 'danger';
10
10
  id?: string;
@@ -4,6 +4,7 @@ var sizes = {
4
4
  h5: 'text-h5',
5
5
  h6: 'text-h6',
6
6
  subtitle1: 'text-subtitle1',
7
+ subtitle2: 'text-subtitle2',
7
8
  };
8
9
  // The ref lands on the heading element, so a screen can move focus to a step's heading (with tabIndex -1).
9
10
  var Heading = React.forwardRef(function Heading(_a, ref) {
@@ -9,6 +9,8 @@ interface ImageProps {
9
9
  /** How the image fills its box. Not set, the browser default applies. Inside a `Figure` with `crop`, the figure fills the frame and `fit` has no effect. */
10
10
  fit?: 'cover' | 'contain';
11
11
  loading?: 'lazy' | 'eager';
12
+ /** Classes on the `<img>`, after the `fit` class, for spacing and corners. Default none. It does not change the accessible name, which is always `alt`. */
13
+ className?: string;
12
14
  }
13
- export default function Image({ src, alt, width, height, fit, loading }: ImageProps): React.JSX.Element;
15
+ export default function Image({ src, alt, width, height, fit, loading, className }: ImageProps): React.JSX.Element;
14
16
  export {};
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  var fits = { cover: 'object-cover', contain: 'object-contain' };
3
3
  export default function Image(_a) {
4
- var src = _a.src, alt = _a.alt, width = _a.width, height = _a.height, fit = _a.fit, loading = _a.loading;
5
- return <img src={src} alt={alt} width={width} height={height} loading={loading} className={fit ? fits[fit] : undefined}/>;
4
+ var src = _a.src, alt = _a.alt, width = _a.width, height = _a.height, fit = _a.fit, loading = _a.loading, className = _a.className;
5
+ var classes = [fit && fits[fit], className].filter(Boolean).join(' ') || undefined;
6
+ return <img src={src} alt={alt} width={width} height={height} loading={loading} className={classes}/>;
6
7
  }
@@ -5,6 +5,20 @@ interface ListProps {
5
5
  tone?: 'primary' | 'secondary';
6
6
  marker?: 'none' | 'dot' | 'number';
7
7
  className?: string;
8
+ /**
9
+ * The number the first item shows, with `marker="number"`. Ignored for other markers. Default none, so the list
10
+ * starts at 1. It is the `start` attribute of the `<ol>`, so screen readers read the same numbers.
11
+ */
12
+ start?: number;
13
+ /**
14
+ * An `id` and classes for each `<li>`, matched to `items` by position. Leave a position `undefined` for an item
15
+ * that needs neither. Default none. An `id` makes the item the target of an in-page link, such as a footnote. It
16
+ * adds no role or name.
17
+ */
18
+ itemProps?: ({
19
+ id?: string;
20
+ className?: string;
21
+ } | undefined)[];
8
22
  }
9
- export default function List({ items, size, tone, marker, className }: ListProps): React.JSX.Element;
23
+ export default function List({ items, size, tone, marker, className, start, itemProps }: ListProps): React.JSX.Element;
10
24
  export {};
@@ -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) { return (<li key={i}>{item}</li>); })}
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
  }