oneslash-design-system 2.25.0 → 2.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/dist/cases/message-attachments.md +3 -0
  2. package/dist/cases/on-this-page.md +2 -0
  3. package/dist/cases/side-pane.md +1 -0
  4. package/dist/cases.json +6 -0
  5. package/dist/components/accordion.d.ts +6 -0
  6. package/dist/components/accordion.jsx +11 -4
  7. package/dist/components/alert.d.ts +3 -1
  8. package/dist/components/alert.jsx +5 -5
  9. package/dist/components/appShell.jsx +5 -2
  10. package/dist/components/avatarStack.d.ts +3 -1
  11. package/dist/components/avatarStack.jsx +2 -2
  12. package/dist/components/codeBlock.d.ts +7 -2
  13. package/dist/components/codeBlock.jsx +5 -3
  14. package/dist/components/composer.d.ts +29 -0
  15. package/dist/components/composer.jsx +19 -5
  16. package/dist/components/dropZone.jsx +5 -64
  17. package/dist/components/fileChip.d.ts +9 -1
  18. package/dist/components/fileChip.jsx +16 -3
  19. package/dist/components/heading.d.ts +2 -2
  20. package/dist/components/heading.jsx +1 -0
  21. package/dist/components/image.d.ts +3 -1
  22. package/dist/components/image.jsx +3 -2
  23. package/dist/components/list.d.ts +15 -1
  24. package/dist/components/list.jsx +8 -3
  25. package/dist/components/menuItem.d.ts +22 -4
  26. package/dist/components/menuItem.jsx +16 -8
  27. package/dist/components/onThisPage.d.ts +14 -3
  28. package/dist/components/onThisPage.jsx +72 -8
  29. package/dist/components/paragraph.d.ts +10 -3
  30. package/dist/components/paragraph.jsx +7 -5
  31. package/dist/components/popover.d.ts +32 -2
  32. package/dist/components/popover.jsx +56 -12
  33. package/dist/components/sidePane.d.ts +20 -0
  34. package/dist/components/sidePane.jsx +4 -4
  35. package/dist/components/sourceCard.d.ts +6 -0
  36. package/dist/components/sourceCard.jsx +2 -2
  37. package/dist/components/textField.d.ts +6 -2
  38. package/dist/components/textField.jsx +9 -3
  39. package/dist/components/titleBar.d.ts +9 -2
  40. package/dist/components/titleBar.jsx +11 -7
  41. package/dist/internal/dropZone.d.ts +23 -0
  42. package/dist/internal/dropZone.js +71 -1
  43. package/dist/stories/Accordion.stories.d.ts +1 -0
  44. package/dist/stories/Accordion.stories.jsx +18 -1
  45. package/dist/stories/Alert.stories.d.ts +1 -0
  46. package/dist/stories/Alert.stories.jsx +14 -0
  47. package/dist/stories/AppShell.stories.d.ts +1 -0
  48. package/dist/stories/AppShell.stories.jsx +17 -0
  49. package/dist/stories/AvatarStack.stories.d.ts +1 -0
  50. package/dist/stories/AvatarStack.stories.jsx +4 -0
  51. package/dist/stories/CodeBlock.stories.d.ts +1 -0
  52. package/dist/stories/CodeBlock.stories.jsx +11 -0
  53. package/dist/stories/Composer.stories.d.ts +4 -0
  54. package/dist/stories/Composer.stories.jsx +41 -0
  55. package/dist/stories/FileChip.stories.d.ts +2 -0
  56. package/dist/stories/FileChip.stories.jsx +27 -0
  57. package/dist/stories/Heading.stories.d.ts +1 -0
  58. package/dist/stories/Heading.stories.jsx +4 -0
  59. package/dist/stories/Image.stories.d.ts +1 -0
  60. package/dist/stories/Image.stories.jsx +4 -0
  61. package/dist/stories/List.stories.d.ts +2 -0
  62. package/dist/stories/List.stories.jsx +6 -0
  63. package/dist/stories/MenuItem.stories.d.ts +4 -0
  64. package/dist/stories/MenuItem.stories.jsx +63 -0
  65. package/dist/stories/OnThisPage.stories.d.ts +1 -0
  66. package/dist/stories/OnThisPage.stories.jsx +11 -0
  67. package/dist/stories/Paragraph.stories.d.ts +7 -0
  68. package/dist/stories/Paragraph.stories.jsx +30 -0
  69. package/dist/stories/Popover.stories.d.ts +4 -0
  70. package/dist/stories/Popover.stories.jsx +123 -0
  71. package/dist/stories/SidePane.stories.d.ts +2 -0
  72. package/dist/stories/SidePane.stories.jsx +34 -1
  73. package/dist/stories/SourceCard.stories.d.ts +1 -0
  74. package/dist/stories/SourceCard.stories.jsx +17 -1
  75. package/dist/stories/TextField.stories.d.ts +1 -0
  76. package/dist/stories/TextField.stories.jsx +19 -0
  77. package/dist/stories/TitleBar.stories.d.ts +1 -0
  78. package/dist/stories/TitleBar.stories.jsx +13 -0
  79. package/package.json +1 -1
@@ -1,7 +1,11 @@
1
1
  'use client';
2
2
  import React from 'react';
3
3
  import { stateTransition } from './sharedStyles';
4
- export default function TextField(_a) {
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. The heading takes tabIndex -1 so a page or a pane can
5
- // move focus to it (a pane does on open) without adding it to the tab order.
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
- return (<div className={"flex min-w-0 items-center gap-2".concat(back || below ? ' flex-wrap md:flex-nowrap' : '')}>
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 {};
@@ -1,4 +1,6 @@
1
- // Checks a set of files against what a DropZone accepts. Pure, so it can be tested without a browser.
1
+ // Checks a set of files against what a DropZone accepts (pure, so it can be tested without a browser), and
2
+ // the drag state DropZone and Composer share.
3
+ import { useEffect, useRef, useState } from 'react';
2
4
  function matchesType(file, pattern) {
3
5
  var p = pattern.trim().toLowerCase();
4
6
  if (!p)
@@ -40,3 +42,71 @@ export function checkFiles(files, _a) {
40
42
  });
41
43
  return { accepted: accepted, rejected: rejected };
42
44
  }
45
+ 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'); };
46
+ /**
47
+ * The handlers for a box that takes dropped files, and whether a file drag is over it. Only a drag whose types
48
+ * include 'Files' is handled, so a text drag stays native. The state clears on drag leave, on drop and when the
49
+ * drag is cancelled.
50
+ */
51
+ export function useFileDrag(_a) {
52
+ var off = _a.off, ignore = _a.ignore, onFiles = _a.onFiles;
53
+ // Entering a child fires dragenter before the parent's dragleave, so count them to keep the state steady
54
+ var depth = useRef(0);
55
+ var _b = useState(false), dragging = _b[0], setDragging = _b[1];
56
+ var stop = function () {
57
+ depth.current = 0;
58
+ setDragging(false);
59
+ };
60
+ // A drag cancelled with Escape, or dropped somewhere else, may not reach the box: clear on the page's events
61
+ useEffect(function () {
62
+ if (!dragging)
63
+ return;
64
+ var onKey = function (e) {
65
+ if (e.key === 'Escape')
66
+ stop();
67
+ };
68
+ window.addEventListener('drop', stop);
69
+ window.addEventListener('dragend', stop);
70
+ window.addEventListener('keydown', onKey);
71
+ return function () {
72
+ window.removeEventListener('drop', stop);
73
+ window.removeEventListener('dragend', stop);
74
+ window.removeEventListener('keydown', onKey);
75
+ };
76
+ }, [dragging]);
77
+ useEffect(function () {
78
+ if (off || ignore)
79
+ stop();
80
+ }, [off, ignore]);
81
+ var onDragEnter = function (e) {
82
+ if (off || !hasFiles(e))
83
+ return;
84
+ e.preventDefault();
85
+ if (ignore)
86
+ return;
87
+ depth.current += 1;
88
+ setDragging(true);
89
+ };
90
+ var onDragOver = function (e) {
91
+ if (off || !hasFiles(e))
92
+ return;
93
+ e.preventDefault();
94
+ };
95
+ var onDragLeave = function (e) {
96
+ if (off || !hasFiles(e))
97
+ return;
98
+ depth.current = Math.max(0, depth.current - 1);
99
+ if (depth.current === 0)
100
+ setDragging(false);
101
+ };
102
+ var onDrop = function (e) {
103
+ if (off || !hasFiles(e))
104
+ return;
105
+ e.preventDefault();
106
+ stop();
107
+ if (ignore)
108
+ return;
109
+ onFiles(Array.from(e.dataTransfer.files));
110
+ };
111
+ return { dragging: dragging, dropProps: { onDragEnter: onDragEnter, onDragOver: onDragOver, onDragLeave: onDragLeave, onDrop: onDrop } };
112
+ }
@@ -9,3 +9,4 @@ export declare const Single: Story;
9
9
  export declare const DeepLink: Story;
10
10
  export declare const DeepLinkJumped: Story;
11
11
  export declare const DeepLinkScrolledOn: Story;
12
+ export declare const SecondTitle: Story;
@@ -1,4 +1,4 @@
1
- import React, { useLayoutEffect } from "react";
1
+ import React, { useLayoutEffect, useState } from "react";
2
2
  import Accordion from "../components/accordion";
3
3
  import SiteHeader from "../components/siteHeader";
4
4
  import Paragraph from "../components/paragraph";
@@ -91,3 +91,20 @@ export var DeepLinkScrolledOn = {
91
91
  decorators: [],
92
92
  render: function () { return <Page jump scrolledOn/>; },
93
93
  };
94
+ var reviews = [
95
+ { id: "security", title: "Security", preview: "The new route checks the session but not the workspace, so any signed-in person can read it.", text: "Check that the person belongs to the workspace before you return the file." },
96
+ { id: "design", title: "Design", preview: "The empty state has no action. Add a Button that starts the first export.", text: "Add a Button that starts the first export." },
97
+ ];
98
+ // A closed item shows one line of its panel; an open item leaves secondTitle off
99
+ function PreviewBox() {
100
+ var _a = useState(["security"]), open = _a[0], setOpen = _a[1];
101
+ return (<Accordion id="accordion-second-title" open={open} onOpenChange={setOpen} items={reviews.map(function (review) { return ({
102
+ id: review.id,
103
+ title: review.title,
104
+ secondTitle: open.includes(review.id) ? undefined : review.preview,
105
+ content: <Paragraph>{review.text}</Paragraph>,
106
+ }); })}/>);
107
+ }
108
+ export var SecondTitle = {
109
+ render: function () { return <PreviewBox />; },
110
+ };
@@ -14,3 +14,4 @@ export declare const InlineWarning: Story;
14
14
  export declare const InlineError: Story;
15
15
  export declare const InlineInfo: Story;
16
16
  export declare const InlineAllTypes: Story;
17
+ export declare const CloseLabel: Story;
@@ -15,6 +15,7 @@ var meta = {
15
15
  },
16
16
  message: { control: "text" },
17
17
  showCloseButton: { control: "boolean" },
18
+ closeLabel: { control: "text" },
18
19
  },
19
20
  };
20
21
  export default meta;
@@ -135,3 +136,16 @@ export var InlineAllTypes = {
135
136
  <Alert type="default" message="Default alert message" variant="inline" showCloseButton/>
136
137
  </div>); },
137
138
  };
139
+ // The close button says what it turns off, not "Dismiss"
140
+ export var CloseLabel = {
141
+ render: function (args) { return <InlineAlertWrapper {...args}/>; },
142
+ args: {
143
+ type: "info",
144
+ message: "Plan mode",
145
+ secondMessage: "The next request needs a plan first",
146
+ variant: "inline",
147
+ showCloseButton: true,
148
+ closeLabel: "Turn off plan mode",
149
+ autoDismiss: false,
150
+ },
151
+ };
@@ -13,3 +13,4 @@ export declare const Default: Story;
13
13
  export declare const WithPane: Story;
14
14
  export declare const Phone: Story;
15
15
  export declare const Probe: Story;
16
+ export declare const DisabledChoice: Story;
@@ -135,3 +135,20 @@ export var Probe = {
135
135
  tags: ["!dev", "!autodocs", "test-only"],
136
136
  render: function () { return <ShellBox resizable/>; },
137
137
  };
138
+ // For tests/interactions.spec.ts only: a disabled item leaves the phone menu open; the item under it closes it
139
+ function DisabledChoiceBox() {
140
+ var _a = useState(false), navOpen = _a[0], setNavOpen = _a[1];
141
+ return (<Bleed>
142
+ <AppShell title="Inbox" navOpen={navOpen} onNavOpenChange={setNavOpen} sidebar={<Navigation aria-label="Main">
143
+ <MenuItem size="small" iconName="Loader" label="Creating…" disabled/>
144
+ <MenuItem size="small" iconName="Globe" label="Website" href="#website" disabled/>
145
+ <MenuItem size="small" iconName="Inbox" label="Inbox" onClick={function () { }}/>
146
+ </Navigation>}>
147
+ <TitleBar title="Inbox"/>
148
+ </AppShell>
149
+ </Bleed>);
150
+ }
151
+ export var DisabledChoice = {
152
+ tags: ["!dev", "!autodocs", "test-only"],
153
+ render: function () { return <DisabledChoiceBox />; },
154
+ };
@@ -5,3 +5,4 @@ export default meta;
5
5
  type Story = StoryObj<typeof AvatarStack>;
6
6
  export declare const Sizes: Story;
7
7
  export declare const WithPopover: Story;
8
+ export declare const Grayscale: Story;
@@ -44,3 +44,7 @@ function PopoverBox() {
44
44
  export var WithPopover = {
45
45
  render: function () { return <PopoverBox />; },
46
46
  };
47
+ // `grayscale` greys the letter circles
48
+ export var Grayscale = {
49
+ args: { people: everyone.slice(0, 6), grayscale: true },
50
+ };
@@ -5,6 +5,7 @@ export default meta;
5
5
  type Story = StoryObj<typeof CodeBlock>;
6
6
  export declare const Short: Story;
7
7
  export declare const LongLine: Story;
8
+ export declare const MaxRows: Story;
8
9
  interface ProbeArgs {
9
10
  clipboard: "refuse" | "missing" | "accept";
10
11
  wrap?: boolean;
@@ -7,6 +7,7 @@ var meta = {
7
7
  label: { control: "text" },
8
8
  language: { control: "text" },
9
9
  wrap: { control: "boolean" },
10
+ maxRows: { control: "number" },
10
11
  copyLabel: { control: "text" },
11
12
  copiedLabel: { control: "text" },
12
13
  },
@@ -27,6 +28,16 @@ export var LongLine = {
27
28
  tags: ["phone"],
28
29
  args: { id: "codeblock-long-line", label: "Install command", language: "bash", code: longLine },
29
30
  };
31
+ // Five lines tall; the rest scrolls inside the block, and Copy takes all of it
32
+ export var MaxRows = {
33
+ args: {
34
+ id: "codeblock-max-rows",
35
+ label: "Tool result",
36
+ wrap: true,
37
+ maxRows: 5,
38
+ code: Array.from({ length: 12 }, function (_, i) { return "Row ".concat(i + 1, ": read file ").concat(i + 1, " of 12"); }).join("\n"),
39
+ },
40
+ };
30
41
  // For tests/interactions.spec.ts: a 300-character line, and a stubbed navigator.clipboard that refuses, is missing or accepts.
31
42
  // `writes` counts what reached the clipboard.
32
43
  function ProbeBox(_a) {
@@ -10,6 +10,10 @@ export declare const WithAttachments: Story;
10
10
  export declare const Stop: Story;
11
11
  export declare const Disabled: Story;
12
12
  export declare const WithActions: Story;
13
+ export declare const DropAndPaste: Story;
14
+ export declare const DropProbe: StoryObj<{
15
+ disabled: boolean;
16
+ }>;
13
17
  interface ProbeArgs {
14
18
  submitOnEnter: boolean;
15
19
  canSubmit?: boolean;
@@ -22,6 +22,7 @@ import React, { useRef, useState } from "react";
22
22
  import Composer from "../components/composer";
23
23
  import IconButton from "../components/iconButton";
24
24
  import Tag from "../components/tag";
25
+ import FileChip from "../components/fileChip";
25
26
  import Alert from "../components/alert";
26
27
  import Button from "../components/button";
27
28
  import Paragraph from "../components/paragraph";
@@ -70,6 +71,46 @@ export var WithActions = {
70
71
  <Button size="small" type="primary" state="enabled" label="Save"/>
71
72
  </Cluster>}/>); },
72
73
  };
74
+ // Dropped and pasted files wait in `above`. The attach button stays, for people who do not drag.
75
+ // A live line says what was added: the Composer announces nothing.
76
+ function DropBox(_a) {
77
+ var _b = _a.disabled, disabled = _b === void 0 ? false : _b;
78
+ var _c = useState([]), files = _c[0], setFiles = _c[1];
79
+ var _d = useState(0), drops = _d[0], setDrops = _d[1];
80
+ var _e = useState(""), said = _e[0], setSaid = _e[1];
81
+ var add = function (added) {
82
+ setFiles(function (list) { return __spreadArray(__spreadArray([], list, true), added.map(function (f) { return f.name; }), true); });
83
+ setSaid(added.length === 1 ? "".concat(added[0].name, " added") : "".concat(added.length, " files added"));
84
+ };
85
+ return (<>
86
+ <Box disabled={disabled} tools={tools} spellCheck lang="en" onDropFiles={function (added) {
87
+ setDrops(function (n) { return n + 1; });
88
+ add(added);
89
+ }} onPaste={function (e) {
90
+ var pasted = Array.from(e.clipboardData.files);
91
+ if (pasted.length === 0)
92
+ return; // Text pastes as usual
93
+ e.preventDefault();
94
+ add(pasted);
95
+ }} above={files.length > 0 ? (<Cluster gap="small">
96
+ {files.map(function (name, i) { return (<FileChip key={"".concat(name, "-").concat(i)} name={name} onRemove={function () { return setFiles(function (list) { return list.filter(function (_, n) { return n !== i; }); }); }}/>); })}
97
+ </Cluster>) : undefined}/>
98
+ <Paragraph size="caption" tone="secondary">
99
+ <span role="status">{said}</span>
100
+ </Paragraph>
101
+ <output data-testid="drops" hidden>
102
+ {drops}
103
+ </output>
104
+ </>);
105
+ }
106
+ // Drag a file from the desktop onto the box: its border turns dashed. Dropped and pasted files are added.
107
+ export var DropAndPaste = { render: function () { return <DropBox />; } };
108
+ export var DropProbe = {
109
+ // For tests/interactions.spec.ts only: hidden from the sidebar and the docs, and skipped by the visual gate
110
+ tags: ["!dev", "!autodocs", "test-only"],
111
+ args: { disabled: false },
112
+ render: function (args) { return <DropBox disabled={args.disabled}/>; },
113
+ };
73
114
  // For tests/interactions.spec.ts: counts submits and stops on screen. Its args are set from the URL.
74
115
  function ProbeBox(_a) {
75
116
  var submitOnEnter = _a.submitOnEnter, canSubmit = _a.canSubmit, disabled = _a.disabled, sending = _a.sending, stop = _a.stop, withActions = _a.withActions, takeEnter = _a.takeEnter, withAbove = _a.withAbove;
@@ -4,4 +4,6 @@ declare const meta: Meta<typeof FileChip>;
4
4
  export default meta;
5
5
  type Story = StoryObj<typeof FileChip>;
6
6
  export declare const States: Story;
7
+ export declare const Thumbnails: Story;
7
8
  export declare const RemoveProbe: Story;
9
+ export declare const ThumbnailProbe: Story;
@@ -21,6 +21,16 @@ export var States = {
21
21
  <FileChip name="a-very-long-file-name-that-would-stretch-the-row-if-it-were-not-cut-at-the-end-of-the-line.pdf" kind="PDF" meta="9 MB" onRemove={function () { }}/>
22
22
  </Stack>); },
23
23
  };
24
+ var picture = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 160 120'%3E%3Crect width='160' height='120' fill='%23dfe9f2'/%3E%3Ccircle cx='120' cy='32' r='14' fill='%23f2c46d'/%3E%3Cpath d='M0 90 50 60l40 22 30-18 40 24v32H0z' fill='%232f6b4f'/%3E%3C/svg%3E";
25
+ // A thumbnail takes the place of `kind`. Uploading and failed keep their marks; a picture that does not load shows `kind`.
26
+ export var Thumbnails = {
27
+ render: function () { return (<Stack gap="medium" align="start">
28
+ <FileChip name="hills.png" kind="PNG" thumbnail={picture} meta="2.1 MB" onRemove={function () { }}/>
29
+ <FileChip name="uploading.png" kind="PNG" thumbnail={picture} meta="Uploading" state="uploading" onRemove={function () { }}/>
30
+ <FileChip name="too-large.png" kind="PNG" thumbnail={picture} meta="Upload failed" state="failed" onRemove={function () { }}/>
31
+ <FileChip name="broken.png" kind="PNG" thumbnail="data:image/png;base64,bm90IGFuIGltYWdl" meta="4 KB" onRemove={function () { }}/>
32
+ </Stack>); },
33
+ };
24
34
  // For tests/interactions.spec.ts: the remove button calls onRemove, which drops the chip here
25
35
  function RemoveProbeBox() {
26
36
  var _a = useState(["plan.pdf", "notes.txt"]), names = _a[0], setNames = _a[1];
@@ -33,3 +43,20 @@ export var RemoveProbe = {
33
43
  tags: ["!dev", "!autodocs", "test-only"],
34
44
  render: function () { return <RemoveProbeBox />; },
35
45
  };
46
+ // For tests/interactions.spec.ts only: the buttons change one chip's thumbnail URL
47
+ function ThumbnailProbeBox() {
48
+ var _a = useState("data:image/png;base64,bm90IGFuIGltYWdl"), url = _a[0], setUrl = _a[1];
49
+ return (<>
50
+ <FileChip name="hills.png" kind="PNG" thumbnail={url}/>
51
+ <button type="button" onClick={function () { return setUrl(picture); }}>
52
+ Good URL
53
+ </button>
54
+ <button type="button" onClick={function () { return setUrl("data:image/png;base64,bm90IGFuIGltYWdl"); }}>
55
+ Broken URL
56
+ </button>
57
+ </>);
58
+ }
59
+ export var ThumbnailProbe = {
60
+ tags: ["!dev", "!autodocs", "test-only"],
61
+ render: function () { return <ThumbnailProbeBox />; },
62
+ };
@@ -5,3 +5,4 @@ export default meta;
5
5
  type Story = StoryObj<typeof Heading>;
6
6
  export declare const Level1: Story;
7
7
  export declare const RefProbe: Story;
8
+ export declare const Subtitle2: Story;
@@ -25,3 +25,7 @@ export var RefProbe = {
25
25
  tags: ["!dev", "!autodocs", "test-only"],
26
26
  render: function () { return <RefProbeView />; },
27
27
  };
28
+ // `size="subtitle2"` is the smallest heading. The element still follows `level`.
29
+ export var Subtitle2 = {
30
+ args: { level: 4, size: "subtitle2", children: "Notification rules" },
31
+ };
@@ -5,3 +5,4 @@ export default meta;
5
5
  type Story = StoryObj<typeof Image>;
6
6
  export declare const Default: Story;
7
7
  export declare const Decoration: Story;
8
+ export declare const ClassName: Story;
@@ -16,3 +16,7 @@ export var Default = {
16
16
  export var Decoration = {
17
17
  args: { src: src, alt: "", width: 160, height: 90, fit: "cover" },
18
18
  };
19
+ // `className` adds spacing and corners to the <img> itself, so it needs no wrapper
20
+ export var ClassName = {
21
+ args: { src: src, alt: "A grey rectangle with round corners", width: 320, height: 180, className: "my-2 block max-w-full rounded-control" },
22
+ };
@@ -7,3 +7,5 @@ export declare const None: Story;
7
7
  export declare const Dot: Story;
8
8
  export declare const Number: Story;
9
9
  export declare const SecondaryDot: Story;
10
+ export declare const NumberStart: Story;
11
+ export declare const ItemProps: Story;
@@ -25,3 +25,9 @@ export var None = { args: { marker: "none" } };
25
25
  export var Dot = { args: { marker: "dot" } };
26
26
  export var Number = { args: { marker: "number" } };
27
27
  export var SecondaryDot = { args: { marker: "dot", tone: "secondary" } };
28
+ // `start` keeps the numbers of a list that was split in two
29
+ export var NumberStart = { args: { marker: "number", start: 4 } };
30
+ // `itemProps` gives an item an id, so an in-page link can point at it, or classes
31
+ export var ItemProps = {
32
+ args: { marker: "number", itemProps: [{ id: "note-1" }, undefined, { className: "list-none" }] },
33
+ };
@@ -14,3 +14,7 @@ export declare const WithRightAction: Story;
14
14
  export declare const WithCustomIcon: Story;
15
15
  export declare const Danger: Story;
16
16
  export declare const SelectedWithTags: Story;
17
+ export declare const Levels: Story;
18
+ export declare const Disabled: Story;
19
+ export declare const ClickProbe: Story;
20
+ export declare const NavigableDisabledProbe: Story;
@@ -1,5 +1,17 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
1
12
  import React from "react";
2
13
  import MenuItem from "../components/menuItem";
14
+ import Menu from "../components/menu";
3
15
  import IconButton from "../components/iconButton";
4
16
  var meta = {
5
17
  title: "Components/MenuItem",
@@ -104,3 +116,54 @@ export var SelectedWithTags = {
104
116
  <MenuItem label="Offline" iconName="Users" tag={{ label: "Away", variant: "dot", color: "warning" }}/>
105
117
  </div>); },
106
118
  };
119
+ // level 2 is a place inside a place; level 3 is a place inside a level 2 place. Nothing goes deeper.
120
+ export var Levels = {
121
+ render: function () { return (<div style={{ width: 280 }} className="flex flex-col gap-1">
122
+ <MenuItem size="small" iconName="Building2" label="Acme" role="button" aria-expanded iconRight="ChevronDown"/>
123
+ <MenuItem size="small" iconName="Folder" label="Website" level={2}/>
124
+ <MenuItem size="small" iconName="File" label="Launch checklist" level={3}/>
125
+ <MenuItem size="small" iconName="File" label="Pricing page" level={3} href="/pricing" isSelected aria-current="page"/>
126
+ </div>); },
127
+ };
128
+ // A disabled row is dimmed and cannot be chosen. A selected one keeps its fill. With href there is no link.
129
+ export var Disabled = {
130
+ render: function () { return (<div style={{ width: 280 }} className="flex flex-col gap-1">
131
+ <MenuItem size="small" iconName="Plus" label="Creating…" role="button" disabled/>
132
+ <MenuItem size="small" iconName="Inbox" label="Inbox" isSelected disabled tag={{ label: "3", variant: "textOnly" }}/>
133
+ <MenuItem size="small" iconName="Globe" label="Website" href="/website" disabled/>
134
+ <MenuItem size="small" iconName="Trash2" label="Delete" color="danger" disabled/>
135
+ <MenuItem size="small" iconName="Copy" label="Duplicate"/>
136
+ </div>); },
137
+ };
138
+ // For tests/interactions.spec.ts: counts how often each row's onClick runs. The link goes to a hash,
139
+ // and 'Stay here' cancels its navigation.
140
+ function ClickProbeRows() {
141
+ var _a = React.useState({ link: 0, stay: 0, row: 0, off: 0 }), counts = _a[0], setCounts = _a[1];
142
+ var count = function (key) { return setCounts(function (c) {
143
+ var _a;
144
+ return (__assign(__assign({}, c), (_a = {}, _a[key] = c[key] + 1, _a)));
145
+ }); };
146
+ return (<div style={{ width: 280 }} className="flex flex-col gap-1">
147
+ <MenuItem size="small" label="Profile" href="#profile" onClick={function () { return count("link"); }}/>
148
+ <MenuItem size="small" label="Stay here" href="#stay" onClick={function (e) {
149
+ e.preventDefault();
150
+ count("stay");
151
+ }}/>
152
+ <MenuItem size="small" label="Rename" onClick={function () { return count("row"); }}/>
153
+ <MenuItem size="small" label="Creating" href="#creating" disabled onClick={function () { return count("off"); }}/>
154
+ <output>{"link ".concat(counts.link, ", stay ").concat(counts.stay, ", row ").concat(counts.row, ", disabled ").concat(counts.off)}</output>
155
+ </div>);
156
+ }
157
+ export var ClickProbe = {
158
+ tags: ["!dev", "!autodocs", "test-only"],
159
+ render: function () { return <ClickProbeRows />; },
160
+ };
161
+ // For tests/interactions.spec.ts only: a navigable Menu's keys skip a disabled row
162
+ export var NavigableDisabledProbe = {
163
+ tags: ["!dev", "!autodocs", "test-only"],
164
+ render: function () { return (<Menu navigable aria-label="Row actions" width="240px">
165
+ <MenuItem size="small" label="Open" role="menuitem"/>
166
+ <MenuItem size="small" label="Rename" role="menuitem" disabled/>
167
+ <MenuItem size="small" label="Delete" role="menuitem"/>
168
+ </Menu>); },
169
+ };
@@ -8,3 +8,4 @@ export declare const Probe: Story;
8
8
  export declare const HeaderProbe: Story;
9
9
  export declare const HashProbe: Story;
10
10
  export declare const HashScrolledProbe: Story;
11
+ export declare const KeepProbe: Story;
@@ -103,3 +103,14 @@ export var HashScrolledProbe = {
103
103
  <JumpToHash scrolledOn/>
104
104
  </Bleed>); },
105
105
  };
106
+ // For tests/interactions.spec.ts only: Probe with the address replaced and the heading kept in view. Scroll anchoring
107
+ // is off, as in a browser without it, so only OnThisPage can hold the heading when something loads above it
108
+ export var KeepProbe = {
109
+ tags: ["!dev", "!autodocs", "test-only"],
110
+ render: function () { return (<Bleed>
111
+ <style>{"html, body { overflow-anchor: none; }"}</style>
112
+ <PageShell id="main" aside={<OnThisPage items={items} history="replace" keepInView/>}>
113
+ <Sections />
114
+ </PageShell>
115
+ </Bleed>); },
116
+ };
@@ -0,0 +1,7 @@
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
+ import Paragraph from "../components/paragraph";
3
+ declare const meta: Meta<typeof Paragraph>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof Paragraph>;
6
+ export declare const InheritTone: Story;
7
+ export declare const Status: Story;