oneslash-design-system 2.16.0 → 2.17.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 (151) hide show
  1. package/README.md +1 -1
  2. package/dist/DESIGN.md +26 -3
  3. package/dist/cases/accept-invite/signed-in.jsx +1 -1
  4. package/dist/cases/accept-invite/signed-out.jsx +1 -1
  5. package/dist/cases/accept-invite.md +2 -2
  6. package/dist/cases/agent-options/cards.d.ts +1 -0
  7. package/dist/cases/agent-options/cards.jsx +91 -0
  8. package/dist/cases/agent-options.md +168 -0
  9. package/dist/cases/agent-pending-reply/steps.d.ts +1 -0
  10. package/dist/cases/agent-pending-reply/steps.jsx +149 -0
  11. package/dist/cases/agent-pending-reply/streaming.d.ts +1 -0
  12. package/dist/cases/agent-pending-reply/streaming.jsx +146 -0
  13. package/dist/cases/agent-pending-reply.md +432 -0
  14. package/dist/cases/agent-plan-proposal/changes.d.ts +1 -0
  15. package/dist/cases/agent-plan-proposal/changes.jsx +224 -0
  16. package/dist/cases/agent-plan-proposal/steps.d.ts +1 -0
  17. package/dist/cases/agent-plan-proposal/steps.jsx +211 -0
  18. package/dist/cases/agent-plan-proposal.md +656 -0
  19. package/dist/cases/agent-question/choices.d.ts +1 -0
  20. package/dist/cases/agent-question/choices.jsx +132 -0
  21. package/dist/cases/agent-question/free-text.d.ts +1 -0
  22. package/dist/cases/agent-question/free-text.jsx +81 -0
  23. package/dist/cases/agent-question.md +338 -0
  24. package/dist/cases/agent-shows-sources.md +2 -2
  25. package/dist/cases/artifact-card/card.d.ts +1 -0
  26. package/dist/cases/artifact-card/card.jsx +45 -0
  27. package/dist/cases/artifact-card.md +103 -0
  28. package/dist/cases/composer-limit/notice-with-action.d.ts +1 -0
  29. package/dist/cases/composer-limit/notice-with-action.jsx +87 -0
  30. package/dist/cases/composer-limit/notice.d.ts +1 -0
  31. package/dist/cases/composer-limit/notice.jsx +84 -0
  32. package/dist/cases/composer-limit.md +286 -0
  33. package/dist/cases/conversation-starters/chips.d.ts +1 -0
  34. package/dist/cases/conversation-starters/chips.jsx +69 -0
  35. package/dist/cases/conversation-starters/none.d.ts +1 -0
  36. package/dist/cases/conversation-starters/none.jsx +45 -0
  37. package/dist/cases/conversation-starters.md +208 -0
  38. package/dist/cases/mention-list/in-composer.d.ts +1 -0
  39. package/dist/cases/mention-list/in-composer.jsx +169 -0
  40. package/dist/cases/mention-list.md +252 -0
  41. package/dist/cases/message-actions/hover-toolbar.d.ts +1 -0
  42. package/dist/cases/message-actions/hover-toolbar.jsx +229 -0
  43. package/dist/cases/message-actions/menu.d.ts +1 -0
  44. package/dist/cases/message-actions/menu.jsx +258 -0
  45. package/dist/cases/message-actions.md +651 -0
  46. package/dist/cases/message-attachments/in-composer.d.ts +1 -0
  47. package/dist/cases/message-attachments/in-composer.jsx +134 -0
  48. package/dist/cases/message-attachments/in-message.d.ts +1 -0
  49. package/dist/cases/message-attachments/in-message.jsx +46 -0
  50. package/dist/cases/message-attachments.md +310 -0
  51. package/dist/cases/message-composer/plain.d.ts +1 -0
  52. package/dist/cases/message-composer/plain.jsx +57 -0
  53. package/dist/cases/message-composer/with-tools.d.ts +1 -0
  54. package/dist/cases/message-composer/with-tools.jsx +182 -0
  55. package/dist/cases/message-composer.md +356 -0
  56. package/dist/cases/message-edit/in-place.d.ts +1 -0
  57. package/dist/cases/message-edit/in-place.jsx +99 -0
  58. package/dist/cases/message-edit.md +179 -0
  59. package/dist/cases/message-reactions/chips.d.ts +1 -0
  60. package/dist/cases/message-reactions/chips.jsx +118 -0
  61. package/dist/cases/message-reactions/quick-pick.d.ts +1 -0
  62. package/dist/cases/message-reactions/quick-pick.jsx +155 -0
  63. package/dist/cases/message-reactions.md +371 -0
  64. package/dist/cases/message-row/grouped.d.ts +1 -0
  65. package/dist/cases/message-row/grouped.jsx +56 -0
  66. package/dist/cases/message-row/person-and-agent.d.ts +1 -0
  67. package/dist/cases/message-row/person-and-agent.jsx +41 -0
  68. package/dist/cases/message-row.md +189 -0
  69. package/dist/cases/reply-feedback/thumbs.d.ts +1 -0
  70. package/dist/cases/reply-feedback/thumbs.jsx +191 -0
  71. package/dist/cases/reply-feedback/with-reason.d.ts +1 -0
  72. package/dist/cases/reply-feedback/with-reason.jsx +221 -0
  73. package/dist/cases/reply-feedback.md +552 -0
  74. package/dist/cases/reply-sources/cards.d.ts +1 -0
  75. package/dist/cases/reply-sources/cards.jsx +83 -0
  76. package/dist/cases/reply-sources/tag-only.d.ts +1 -0
  77. package/dist/cases/reply-sources/tag-only.jsx +45 -0
  78. package/dist/cases/reply-sources.md +247 -0
  79. package/dist/cases/slash-command-list/in-composer.d.ts +1 -0
  80. package/dist/cases/slash-command-list/in-composer.jsx +162 -0
  81. package/dist/cases/slash-command-list.md +247 -0
  82. package/dist/cases/success-feedback.md +1 -1
  83. package/dist/cases/typing-and-status/line.d.ts +1 -0
  84. package/dist/cases/typing-and-status/line.jsx +50 -0
  85. package/dist/cases/typing-and-status.md +96 -0
  86. package/dist/cases.json +1276 -14
  87. package/dist/components/button.d.ts +3 -2
  88. package/dist/components/button.jsx +9 -7
  89. package/dist/components/composer.d.ts +74 -0
  90. package/dist/components/composer.jsx +122 -0
  91. package/dist/components/fileChip.d.ts +33 -0
  92. package/dist/components/fileChip.jsx +61 -0
  93. package/dist/components/iconButton.d.ts +3 -3
  94. package/dist/components/iconButton.jsx +9 -7
  95. package/dist/components/layout.d.ts +7 -1
  96. package/dist/components/layout.jsx +5 -2
  97. package/dist/components/menu.d.ts +21 -0
  98. package/dist/components/menu.jsx +27 -3
  99. package/dist/components/menuItem.d.ts +9 -1
  100. package/dist/components/menuItem.jsx +5 -4
  101. package/dist/components/message.d.ts +28 -0
  102. package/dist/components/message.jsx +25 -0
  103. package/dist/components/paragraph.d.ts +3 -1
  104. package/dist/components/paragraph.jsx +2 -2
  105. package/dist/components/popover.d.ts +7 -1
  106. package/dist/components/popover.jsx +35 -9
  107. package/dist/components/radioGroup.d.ts +8 -1
  108. package/dist/components/radioGroup.jsx +19 -8
  109. package/dist/components/sourceCard.d.ts +23 -0
  110. package/dist/components/sourceCard.jsx +56 -0
  111. package/dist/components/stepList.d.ts +17 -0
  112. package/dist/components/stepList.jsx +79 -0
  113. package/dist/components/tag.d.ts +9 -1
  114. package/dist/components/tag.jsx +6 -4
  115. package/dist/components/textarea.jsx +3 -18
  116. package/dist/components/userImage.d.ts +9 -1
  117. package/dist/components/userImage.jsx +10 -3
  118. package/dist/internal/autoGrow.d.ts +11 -0
  119. package/dist/internal/autoGrow.js +28 -0
  120. package/dist/internal/composer.d.ts +16 -0
  121. package/dist/internal/composer.js +18 -0
  122. package/dist/internal/menu.d.ts +6 -0
  123. package/dist/internal/menu.js +31 -0
  124. package/dist/native-mapping.json +32 -1
  125. package/dist/stories/Button.stories.d.ts +1 -0
  126. package/dist/stories/Button.stories.jsx +17 -1
  127. package/dist/stories/Cases.generated.stories.d.ts +30 -0
  128. package/dist/stories/Cases.generated.stories.jsx +60 -0
  129. package/dist/stories/Composer.stories.d.ts +23 -0
  130. package/dist/stories/Composer.stories.jsx +121 -0
  131. package/dist/stories/FileChip.stories.d.ts +7 -0
  132. package/dist/stories/FileChip.stories.jsx +35 -0
  133. package/dist/stories/IconButton.stories.d.ts +1 -0
  134. package/dist/stories/IconButton.stories.jsx +18 -1
  135. package/dist/stories/Menu.stories.d.ts +4 -0
  136. package/dist/stories/Menu.stories.jsx +46 -1
  137. package/dist/stories/MenuItem.stories.d.ts +1 -0
  138. package/dist/stories/MenuItem.stories.jsx +8 -0
  139. package/dist/stories/Message.stories.d.ts +10 -0
  140. package/dist/stories/Message.stories.jsx +77 -0
  141. package/dist/stories/PageComponents.stories.d.ts +1 -0
  142. package/dist/stories/PageComponents.stories.jsx +21 -0
  143. package/dist/stories/RadioGroup.stories.d.ts +2 -0
  144. package/dist/stories/RadioGroup.stories.jsx +40 -1
  145. package/dist/stories/SourceCard.stories.d.ts +8 -0
  146. package/dist/stories/SourceCard.stories.jsx +33 -0
  147. package/dist/stories/StepList.stories.d.ts +8 -0
  148. package/dist/stories/StepList.stories.jsx +35 -0
  149. package/dist/stories/UserImage.stories.d.ts +2 -0
  150. package/dist/stories/UserImage.stories.jsx +19 -0
  151. package/package.json +4 -3
@@ -8,6 +8,8 @@ interface ParagraphProps {
8
8
  /** Set in the mono face, for labels, numbers and dates. */
9
9
  mono?: boolean;
10
10
  className?: string;
11
+ /** On the `<p>`, so a field can point at this line with `aria-describedby` */
12
+ id?: string;
11
13
  }
12
- export default function Paragraph({ children, tone, size, measure, mono, className, }: ParagraphProps): React.JSX.Element;
14
+ export default function Paragraph({ children, tone, size, measure, mono, className, id, }: ParagraphProps): React.JSX.Element;
13
15
  export {};
@@ -9,8 +9,8 @@ var measures = {
9
9
  none: '',
10
10
  };
11
11
  export default function Paragraph(_a) {
12
- 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;
13
- return (<p className={"".concat(sizes[size], " ").concat(tones[tone], " ").concat(measures[measure], " ").concat(mono ? 'font-mono' : '', " ").concat(className)}>
12
+ 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;
13
+ return (<p id={id} className={"".concat(sizes[size], " ").concat(tones[tone], " ").concat(measures[measure], " ").concat(mono ? 'font-mono' : '', " ").concat(className)}>
14
14
  {children}
15
15
  </p>);
16
16
  }
@@ -5,6 +5,12 @@ interface PopoverProps {
5
5
  open: boolean;
6
6
  onClose: () => void;
7
7
  children: React.ReactNode;
8
+ /**
9
+ * When the Popover closes (Escape, a click outside, or `open` going false), focus goes back to
10
+ * `anchorEl` if it was inside the Popover or nowhere (on the body). Tab or Shift+Tab pressed inside the
11
+ * Popover also closes it (`onClose`) and focuses `anchorEl`. Pass the focusable trigger as `anchorEl`.
12
+ */
13
+ returnFocus?: boolean;
8
14
  }
9
- export default function Popover({ id, anchorEl, open, onClose, children, }: PopoverProps): React.ReactPortal | null;
15
+ export default function Popover({ id, anchorEl, open, onClose, children, returnFocus, }: PopoverProps): React.ReactPortal | null;
10
16
  export {};
@@ -1,22 +1,22 @@
1
1
  'use client';
2
- import React, { useState, useEffect, isValidElement } from 'react';
2
+ import React, { useState, useEffect, useRef, isValidElement } from 'react';
3
3
  import { createPortal } from 'react-dom';
4
4
  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
8
  export default function Popover(_a) {
9
- var id = _a.id, anchorEl = _a.anchorEl, open = _a.open, onClose = _a.onClose, children = _a.children;
10
- var _b = useState(null), popoverElement = _b[0], setPopoverElement = _b[1];
11
- var _c = useState(false), hasMounted = _c[0], setHasMounted = _c[1];
12
- var _d = useOverlayTransition(open), mounted = _d.mounted, visible = _d.visible;
9
+ 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;
10
+ var _c = useState(null), popoverElement = _c[0], setPopoverElement = _c[1];
11
+ var _d = useState(false), hasMounted = _d[0], setHasMounted = _d[1];
12
+ var _e = useOverlayTransition(open), mounted = _e.mounted, visible = _e.visible;
13
13
  // Initialize Popper.js
14
- var _e = usePopper(anchorEl, popoverElement, {
14
+ var _f = usePopper(anchorEl, popoverElement, {
15
15
  placement: 'bottom-start', // Default placement, can be customized
16
16
  modifiers: [
17
17
  { name: 'offset', options: { offset: [0, 4] } }, // Same 4px gap as the Select menu and Tooltip
18
18
  ],
19
- }), styles = _e.styles, attributes = _e.attributes;
19
+ }), styles = _f.styles, attributes = _f.attributes;
20
20
  // Close on outside clicks and Escape. Clicks on the anchor are left to the
21
21
  // anchor's own toggle, otherwise the popover would close and reopen.
22
22
  useEffect(function () {
@@ -27,8 +27,19 @@ export default function Popover(_a) {
27
27
  }
28
28
  };
29
29
  var handleKeyDown = function (event) {
30
- if (event.key === 'Escape')
30
+ if (event.key === 'Escape') {
31
+ // Close only the Popover: keep this Escape from reaching a Modal's window listener
32
+ event.stopPropagation();
31
33
  onClose();
34
+ }
35
+ else if (event.key === 'Tab' && returnFocus && anchorEl && (popoverElement === null || popoverElement === void 0 ? void 0 : popoverElement.contains(event.target))) {
36
+ // Tab or Shift+Tab leaves the Popover: close it and give focus back to the anchor, before a Modal's
37
+ // Tab trap or the browser moves it somewhere else (the Popover is portaled to the end of the body)
38
+ event.preventDefault();
39
+ event.stopPropagation();
40
+ anchorEl.focus();
41
+ onClose();
42
+ }
32
43
  };
33
44
  if (open) {
34
45
  document.addEventListener('mousedown', handleClickOutside);
@@ -38,7 +49,22 @@ export default function Popover(_a) {
38
49
  document.removeEventListener('mousedown', handleClickOutside);
39
50
  document.removeEventListener('keydown', handleKeyDown);
40
51
  };
41
- }, [open, anchorEl, popoverElement, onClose]);
52
+ }, [open, anchorEl, popoverElement, onClose, returnFocus]);
53
+ // On close, wait one task so a click outside has moved focus first: a click on something
54
+ // focusable keeps it there; a click on nothing leaves it on the body, and then the anchor takes it.
55
+ var wasOpen = useRef(open);
56
+ useEffect(function () {
57
+ var closed = wasOpen.current && !open;
58
+ wasOpen.current = open;
59
+ if (!closed || !returnFocus || !anchorEl)
60
+ return;
61
+ var timer = setTimeout(function () {
62
+ var active = document.activeElement;
63
+ if (!active || active === document.body || (popoverElement === null || popoverElement === void 0 ? void 0 : popoverElement.contains(active)))
64
+ anchorEl.focus();
65
+ }, 0);
66
+ return function () { return clearTimeout(timer); };
67
+ }, [open]); // eslint-disable-line react-hooks/exhaustive-deps
42
68
  // Ensure popover is only rendered after the component mounts
43
69
  useEffect(function () {
44
70
  setHasMounted(true);
@@ -3,6 +3,9 @@ interface RadioOption {
3
3
  label: string;
4
4
  secondLabel?: string;
5
5
  value: string;
6
+ /** In the `card` variant, a small info tag beside the label, e.g. "Recommended" */
7
+ badge?: string;
8
+ disabled?: boolean;
6
9
  }
7
10
  interface RadioGroupProps {
8
11
  options: RadioOption[];
@@ -10,6 +13,10 @@ interface RadioGroupProps {
10
13
  onChange: (value: string) => void;
11
14
  direction?: 'horizontal' | 'vertical';
12
15
  'aria-label'?: string;
16
+ /** `card` draws each option as a bordered card that is the radio's label, with the selected one in the accent border */
17
+ variant?: 'default' | 'card';
18
+ /** Disables every option */
19
+ disabled?: boolean;
13
20
  }
14
- export default function RadioGroup({ options, selectedValue, onChange, direction, 'aria-label': ariaLabel, }: RadioGroupProps): React.JSX.Element;
21
+ export default function RadioGroup({ options, selectedValue, onChange, direction, 'aria-label': ariaLabel, variant, disabled, }: RadioGroupProps): React.JSX.Element;
15
22
  export {};
@@ -1,17 +1,22 @@
1
1
  'use client';
2
2
  import React, { useId } from 'react';
3
3
  import { popTransition, stateTransition } from './sharedStyles';
4
+ import Tag from './tag';
4
5
  export default function RadioGroup(_a) {
5
- var options = _a.options, selectedValue = _a.selectedValue, onChange = _a.onChange, _b = _a.direction, direction = _b === void 0 ? 'vertical' : _b, ariaLabel = _a["aria-label"];
6
+ var options = _a.options, selectedValue = _a.selectedValue, onChange = _a.onChange, _b = _a.direction, direction = _b === void 0 ? 'vertical' : _b, ariaLabel = _a["aria-label"], _c = _a.variant, variant = _c === void 0 ? 'default' : _c, _d = _a.disabled, disabled = _d === void 0 ? false : _d;
6
7
  // One shared name gives native arrow-key movement between the options
7
8
  var groupName = useId();
8
9
  return (<div role="radiogroup" aria-label={ariaLabel} className={"flex ".concat(direction === 'horizontal' ? 'gap-4' : 'flex-col gap-2')}>
9
10
  {options.map(function (option) {
10
11
  var isSelected = selectedValue === option.value;
11
- return (<label key={option.value} className="group relative flex items-start cursor-pointer">
12
- <input type="radio" name={groupName} value={option.value} checked={isSelected} onChange={function () { return onChange(option.value); }} className="peer sr-only"/>
12
+ var isDisabled = disabled || !!option.disabled;
13
+ var isCard = variant === 'card';
14
+ return (<label key={option.value} className={"group relative flex items-start ".concat(isCard ? "gap-2 rounded-control border-2 p-3 ".concat(isSelected ? 'border-accent-main' : 'border-fg-disabled', " ") : '').concat(isDisabled ? 'cursor-not-allowed opacity-50' : 'cursor-pointer')}>
15
+ <input type="radio" name={groupName} value={option.value} checked={isSelected} disabled={isDisabled || undefined} onChange={function () { return onChange(option.value); }} className="peer sr-only"/>
16
+ {/* Keyboard focus rings the card just outside its border, so a selected card keeps its accent border */}
17
+ {isCard && (<span aria-hidden="true" className="pointer-events-none absolute inset-0 rounded-control peer-focus-visible:outline peer-focus-visible:outline-2 peer-focus-visible:outline-offset-2 peer-focus-visible:outline-fg-primary"/>)}
13
18
  {/* Hover halo and hit area, same as Checkbox */}
14
- <span className={"relative flex flex-shrink-0 items-center justify-center w-6 h-6 rounded-full ".concat(stateTransition, "\n group-hover:bg-action-selected\n peer-focus-visible:outline peer-focus-visible:outline-2 peer-focus-visible:outline-offset-0 peer-focus-visible:outline-fg-primary")}>
19
+ <span className={"relative flex flex-shrink-0 items-center justify-center w-6 h-6 rounded-full ".concat(stateTransition, "\n ").concat(isDisabled ? '' : 'group-hover:bg-action-selected', "\n peer-focus-visible:outline peer-focus-visible:outline-2 peer-focus-visible:outline-offset-0 peer-focus-visible:outline-fg-primary")}>
15
20
  {/* outer circle */}
16
21
  <span className={"relative flex justify-center items-center w-4 h-4 rounded-full border-2 ".concat(stateTransition, "\n ").concat(isSelected
17
22
  ? 'border-fg-primary'
@@ -20,10 +25,16 @@ export default function RadioGroup(_a) {
20
25
  <span className={"absolute w-2 h-2 rounded-full bg-fg-primary ".concat(popTransition, " ").concat(isSelected ? 'scale-100' : 'scale-0')}/>
21
26
  </span>
22
27
  </span>
23
- <span className="flex flex-col ml-2">
24
- <span className="text-body1 text-fg-primary">{option.label}</span>
25
- {option.secondLabel && (<span className="text-body2 opacity-70 text-fg-primary">{option.secondLabel}</span>)}
26
- </span>
28
+ {isCard ? (<span className="flex flex-col flex-1">
29
+ <span className="flex flex-wrap items-center gap-2">
30
+ <span className="text-body1 font-medium text-fg-primary">{option.label}</span>
31
+ {option.badge && <Tag variant="contained" size="small" color="info" label={option.badge}/>}
32
+ </span>
33
+ {option.secondLabel && (<span className="text-body2 opacity-70 text-fg-primary">{option.secondLabel}</span>)}
34
+ </span>) : (<span className="flex flex-col ml-2">
35
+ <span className="text-body1 text-fg-primary">{option.label}</span>
36
+ {option.secondLabel && (<span className="text-body2 opacity-70 text-fg-primary">{option.secondLabel}</span>)}
37
+ </span>)}
27
38
  </label>);
28
39
  })}
29
40
  </div>);
@@ -0,0 +1,23 @@
1
+ import React from 'react';
2
+ import { type IconSource } from './iconSlot';
3
+ interface SourceCardProps {
4
+ /** Shown at the left in secondary color. A Lucide icon name, an icon component or an element. */
5
+ icon?: IconSource;
6
+ /** One line; a longer title is cut with an ellipsis */
7
+ title: string;
8
+ /** One line of secondary text under the title: where the source lives, or its date */
9
+ meta?: string;
10
+ /** Makes the card a link. A path goes through `next/link`; an `http(s)://` URL is a plain `<a>`. */
11
+ href?: string;
12
+ /** Makes the card a button. Ignored when `href` is set: the link wins and `onClick` does not run. */
13
+ onClick?: () => void;
14
+ /** 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
+ action?: string;
16
+ /** With `href`: open in a new tab. Another site (`http(s)://`) always opens in a new tab. */
17
+ openInNewTab?: boolean;
18
+ /** Overrides the accessible name of a link or button card: by default the title, the meta and the action, joined with commas */
19
+ 'aria-label'?: string;
20
+ }
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
+ declare const SourceCard: React.ForwardRefExoticComponent<SourceCardProps & React.RefAttributes<HTMLButtonElement | HTMLAnchorElement>>;
23
+ export default SourceCard;
@@ -0,0 +1,56 @@
1
+ 'use client';
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ import React, { forwardRef } from 'react';
14
+ import NextLink from 'next/link';
15
+ import IconSlot from './iconSlot';
16
+ import { focusRing, stateTransition } from './sharedStyles';
17
+ // The card for one thing an agent read or made. With `href` or `onClick` it is a link or a
18
+ // button with a hover look and a focus ring; with neither it is plain static text: no role,
19
+ // no hover, no pointer. It fills the width of its parent, so a Grid cell gives it its size.
20
+ // Like Link, it only sets new-tab attributes and shows no extra icon.
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
+ 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"];
24
+ var interactive = href !== undefined || onClick !== undefined;
25
+ var showAction = interactive && !!action;
26
+ // A link or button is named in one string, so the parts are read with a pause between them
27
+ var name = ariaLabel !== null && ariaLabel !== void 0 ? ariaLabel : [title, meta, showAction && action].filter(Boolean).join(', ');
28
+ var classes = "flex w-full min-w-0 items-center gap-medium rounded-container border border-fg-disabled p-3 text-left".concat(interactive ? " cursor-pointer hover:bg-background-accent200 ".concat(stateTransition, " ").concat(focusRing) : '');
29
+ var content = (<>
30
+ {icon && (<span aria-hidden="true" className="flex shrink-0">
31
+ <IconSlot icon={icon} className="size-5 text-fg-secondary"/>
32
+ </span>)}
33
+ <span className="flex min-w-0 flex-1 flex-col">
34
+ {/* Block-level lines, so a static card's title and meta are read as two words, not run together */}
35
+ <span className="truncate text-body1 text-fg-primary">{title}</span>
36
+ {meta && <span className="truncate text-caption text-fg-secondary">{meta}</span>}
37
+ </span>
38
+ {showAction && <span className="shrink-0 text-body2 text-info-text">{action}</span>}
39
+ </>);
40
+ if (href !== undefined) {
41
+ var isExternal = href.startsWith('http://') || href.startsWith('https://');
42
+ var newTab = openInNewTab || isExternal;
43
+ var props = __assign({ className: classes, 'aria-label': name }, (newTab && { target: '_blank', rel: 'noopener noreferrer' }));
44
+ if (newTab) {
45
+ return <a href={href} {...props} ref={ref}>{content}</a>;
46
+ }
47
+ return <NextLink href={href} {...props} ref={ref}>{content}</NextLink>;
48
+ }
49
+ if (onClick) {
50
+ return (<button ref={ref} type="button" className={classes} onClick={onClick} aria-label={name}>
51
+ {content}
52
+ </button>);
53
+ }
54
+ return <div className={classes}>{content}</div>;
55
+ });
56
+ export default SourceCard;
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ export type StepListStatus = 'waiting' | 'running' | 'done' | 'failed' | 'cancelled';
3
+ export interface StepListStep {
4
+ label: string;
5
+ /** Default `waiting` */
6
+ status?: StepListStatus;
7
+ /** One line of secondary text under the label */
8
+ detail?: string;
9
+ }
10
+ interface StepListProps {
11
+ steps: StepListStep[];
12
+ /** Numbers every step in a column before the status mark, for a plan whose order matters */
13
+ numbered?: boolean;
14
+ 'aria-label'?: string;
15
+ }
16
+ export default function StepList({ steps, numbered, 'aria-label': ariaLabel }: StepListProps): React.JSX.Element | null;
17
+ export {};
@@ -0,0 +1,79 @@
1
+ import React from 'react';
2
+ import { Check, Circle, Minus, X } from 'lucide-react';
3
+ import { LoadingSmall } from './loadingScreen';
4
+ var words = {
5
+ waiting: 'Waiting',
6
+ running: 'Running',
7
+ done: 'Done',
8
+ failed: 'Failed',
9
+ cancelled: 'Cancelled',
10
+ };
11
+ // Mark colors; a running mark takes its color from the text, so it shows in dark too.
12
+ var markColors = {
13
+ waiting: 'text-fg-secondary',
14
+ running: 'text-fg-primary',
15
+ done: 'text-success-text',
16
+ failed: 'text-error-text',
17
+ cancelled: 'text-fg-secondary',
18
+ };
19
+ var labelColors = {
20
+ waiting: 'text-fg-secondary',
21
+ running: 'text-fg-primary',
22
+ done: 'text-fg-primary',
23
+ failed: 'text-fg-primary',
24
+ cancelled: 'text-fg-secondary',
25
+ };
26
+ // Steps with a status each: an agent's progress, a plan, an import. An ordered list.
27
+ // A screen reader hears the status, then the label ("Done: Read file"); with `numbered` it hears
28
+ // the position too ("Step 2, Running: Read file"). Each status has its own shape and word, so
29
+ // color is never the only cue. The mark box is as tall as the first text line (24px), so a
30
+ // wrapped label keeps the mark at its first line. There is no line between steps in this version.
31
+ // `numbered` draws a number column before the mark; the drawn number is hidden from assistive tech
32
+ // and the hidden text carries the position, so it is not read twice. A waiting numbered step shows
33
+ // its number and no circle, and its label is primary text: a plan waiting for approval is not disabled.
34
+ // It is read as "Step 1: Read file", with no status word, since it draws none: an approved plan is not read as waiting.
35
+ // There is no live region: a caller that updates the list while an agent works wraps it in
36
+ // `role="status"` or `aria-live="polite"` itself.
37
+ export default function StepList(_a) {
38
+ var steps = _a.steps, _b = _a.numbered, numbered = _b === void 0 ? false : _b, ariaLabel = _a["aria-label"];
39
+ if (steps.length === 0)
40
+ return null;
41
+ var mark = function (status) {
42
+ switch (status) {
43
+ case 'running':
44
+ // The spinner's own "Loading" status is hidden: the row says "Running".
45
+ return <div aria-hidden="true"><LoadingSmall size="tiny"/></div>;
46
+ case 'done':
47
+ return <Check className="size-4" strokeWidth={2} aria-hidden/>;
48
+ case 'failed':
49
+ return <X className="size-4" strokeWidth={2} aria-hidden/>;
50
+ case 'cancelled':
51
+ return <Minus className="size-4" strokeWidth={2} aria-hidden/>;
52
+ default:
53
+ return <Circle className="size-4" strokeWidth={2} aria-hidden/>;
54
+ }
55
+ };
56
+ return (<ol role="list" aria-label={ariaLabel} className="flex flex-col gap-medium">
57
+ {steps.map(function (step, i) {
58
+ var _a;
59
+ var status = (_a = step.status) !== null && _a !== void 0 ? _a : 'waiting';
60
+ var label = labelColors[status === 'waiting' && numbered ? 'running' : status];
61
+ var spoken = numbered
62
+ ? status === 'waiting' ? "Step ".concat(i + 1, ": ") : "Step ".concat(i + 1, ", ").concat(words[status], ": ")
63
+ : "".concat(words[status], ": ");
64
+ return (<li key={i} aria-current={status === 'running' ? 'step' : undefined} className="flex items-start gap-medium">
65
+ {numbered && (<span aria-hidden="true" className="flex h-6 w-6 flex-shrink-0 items-center justify-center text-body2 text-fg-secondary">{i + 1}</span>)}
66
+ {(!numbered || status !== 'waiting') && (<span aria-hidden="true" className={"flex flex-shrink-0 items-center justify-center w-6 h-6 ".concat(markColors[status])}>
67
+ {mark(status)}
68
+ </span>)}
69
+ <span className="flex flex-col flex-1 min-w-0">
70
+ <span className={"break-words text-body1 ".concat(label)}>
71
+ <span className="sr-only">{spoken}</span>
72
+ {step.label}
73
+ </span>
74
+ {step.detail && <span className="break-words text-body2 text-fg-secondary">{step.detail}</span>}
75
+ </span>
76
+ </li>);
77
+ })}
78
+ </ol>);
79
+ }
@@ -15,6 +15,14 @@ interface TagProps {
15
15
  onClick?: React.MouseEventHandler<HTMLDivElement>;
16
16
  /** Only applies to a clickable tag: dims it, drops it from the tab order and ignores clicks */
17
17
  disabled?: boolean;
18
+ /** The tag's name, when the label alone does not say it (a reaction: 'Thumbs up, 3 reactions'). On the button when clickable; a static tag with a name gets `role="img"`. */
19
+ 'aria-label'?: string;
20
+ /**
21
+ * A clickable tag is a toggle by default and reports `aria-pressed`: right for a filter or a reaction.
22
+ * `false` makes it a plain button with no `aria-pressed`, for an action such as a conversation starter.
23
+ * `state="selected"` still gives the selected look then, but it is only a look. No effect without `onClick`.
24
+ */
25
+ toggle?: boolean;
18
26
  }
19
- export default function Tag({ variant, size, state, color, label, secondLabel, iconName, icon, onClick, disabled, }: TagProps): JSX.Element;
27
+ export default function Tag({ variant, size, state, color, label, secondLabel, iconName, icon, onClick, disabled, 'aria-label': ariaLabel, toggle, }: TagProps): React.JSX.Element;
20
28
  export {};
@@ -48,7 +48,7 @@ var colorConfig = {
48
48
  },
49
49
  };
50
50
  export default function Tag(_a) {
51
- var variant = _a.variant, size = _a.size, _b = _a.state, state = _b === void 0 ? 'enabled' : _b, color = _a.color, label = _a.label, secondLabel = _a.secondLabel, iconName = _a.iconName, icon = _a.icon, onClick = _a.onClick, _c = _a.disabled, disabled = _c === void 0 ? false : _c;
51
+ var variant = _a.variant, size = _a.size, _b = _a.state, state = _b === void 0 ? 'enabled' : _b, color = _a.color, label = _a.label, secondLabel = _a.secondLabel, iconName = _a.iconName, icon = _a.icon, onClick = _a.onClick, _c = _a.disabled, disabled = _c === void 0 ? false : _c, ariaLabel = _a["aria-label"], _d = _a.toggle, toggle = _d === void 0 ? true : _d;
52
52
  // Size and padding
53
53
  var sizeClasses = {
54
54
  medium: 'text-body2 px-2 py-1',
@@ -121,12 +121,12 @@ export default function Tag(_a) {
121
121
  var cursorClass = isDisabled ? 'cursor-not-allowed opacity-50' : onClick && !isSelected ? 'cursor-pointer' : '';
122
122
  // inline-flex so a tag wraps its content instead of stretching to its container
123
123
  var baseClasses = "inline-flex items-center gap-1 rounded-full whitespace-nowrap ".concat(stateTransition);
124
- // A clickable tag is a keyboard-reachable toggle button
124
+ // A clickable tag is a keyboard-reachable button, a toggle unless `toggle` is false
125
125
  var interactiveProps = onClick
126
126
  ? {
127
127
  role: 'button',
128
128
  tabIndex: isDisabled ? -1 : 0,
129
- 'aria-pressed': isSelected,
129
+ 'aria-pressed': toggle ? isSelected : undefined,
130
130
  'aria-disabled': isDisabled || undefined,
131
131
  onClick: isDisabled ? undefined : onClick,
132
132
  onKeyDown: function (e) {
@@ -137,7 +137,9 @@ export default function Tag(_a) {
137
137
  },
138
138
  }
139
139
  : {};
140
- return (<div className={"".concat(baseClasses, " ").concat(sizeClasses, " ").concat(bgClasses, " ").concat(fontClasses, " ").concat(borderClasses, " ").concat(hoverClasses, " ").concat(cursorClass, " ").concat(onClick ? focusRing : '', " ").concat(onClick && !isDisabled ? pressFeedbackAny : '')} {...interactiveProps}>
140
+ return (<div className={"".concat(baseClasses, " ").concat(sizeClasses, " ").concat(bgClasses, " ").concat(fontClasses, " ").concat(borderClasses, " ").concat(hoverClasses, " ").concat(cursorClass, " ").concat(onClick ? focusRing : '', " ").concat(onClick && !isDisabled ? pressFeedbackAny : '')} aria-label={ariaLabel}
141
+ // A name on a plain div is not valid; a static tag with a name is an image of its label
142
+ role={!onClick && ariaLabel ? 'img' : undefined} {...interactiveProps}>
141
143
  {variant === 'dot' && (<span className={"w-3 h-3 rounded-full flex-shrink-0 ".concat(dotColor)}/>)}
142
144
  {variant !== 'dot' && <IconSlot icon={icon !== null && icon !== void 0 ? icon : iconName} className={"".concat(size === 'tiny' ? 'w-3 h-3' : 'w-4 h-4', " flex-shrink-0")}/>}
143
145
  <div className="flex flex-col text-center">
@@ -1,6 +1,7 @@
1
1
  'use client';
2
2
  import React, { useCallback, useEffect, useRef } from 'react';
3
3
  import { stateTransition } from './sharedStyles';
4
+ import { fitToContent } from '../internal/autoGrow';
4
5
  export default function Textarea(_a) {
5
6
  var id = _a.id, label = _a.label, value = _a.value, onChange = _a.onChange, onBlur = _a.onBlur, onFocus = _a.onFocus, onKeyDown = _a.onKeyDown, onCompositionStart = _a.onCompositionStart, onCompositionEnd = _a.onCompositionEnd, onSubmit = _a.onSubmit, _b = _a.autoFocus, autoFocus = _b === void 0 ? false : _b, _c = _a.maxRows, maxRows = _c === void 0 ? 6 : _c, _d = _a.disabled, disabled = _d === void 0 ? false : _d, _e = _a.error, error = _e === void 0 ? false : _e, _f = _a.errorText, errorText = _f === void 0 ? 'This field is required' : _f, _g = _a.size, size = _g === void 0 ? 'medium' : _g, placeholder = _a.placeholder, name = _a.name, _h = _a.autoComplete, autoComplete = _h === void 0 ? 'off' : _h, tabIndex = _a.tabIndex, maxLength = _a.maxLength, spellCheck = _a.spellCheck;
6
7
  var textareaRef = useRef(null);
@@ -14,24 +15,8 @@ export default function Textarea(_a) {
14
15
  onKeyDown(e);
15
16
  };
16
17
  var adjustHeight = useCallback(function () {
17
- var textarea = textareaRef.current;
18
- if (!textarea)
19
- return;
20
- textarea.style.height = 'auto'; // Reset height to calculate scrollHeight
21
- var style = getComputedStyle(textarea);
22
- var lineHeight = parseFloat(style.lineHeight);
23
- // style.height is border-box, scrollHeight includes padding but not border
24
- var paddingY = parseFloat(style.paddingTop) + parseFloat(style.paddingBottom);
25
- var borderY = parseFloat(style.borderTopWidth) + parseFloat(style.borderBottomWidth);
26
- var maxContentHeight = lineHeight * maxRows + paddingY;
27
- var scrollHeight = textarea.scrollHeight;
28
- // Fit the content, capped at maxRows, but at least 1 line
29
- var contentHeight = Math.max(Math.min(scrollHeight, maxContentHeight), lineHeight + paddingY);
30
- textarea.style.height = "".concat(contentHeight + borderY, "px");
31
- // Enable vertical scroll if content exceeds maxRows (hide scrollbar)
32
- textarea.style.overflowY = scrollHeight > maxContentHeight ? 'scroll' : 'hidden';
33
- textarea.style.scrollbarWidth = 'none'; // Firefox
34
- textarea.style.msOverflowStyle = 'none'; // IE/Edge
18
+ if (textareaRef.current)
19
+ fitToContent(textareaRef.current, maxRows);
35
20
  }, [maxRows]);
36
21
  // Also re-measure when the value changes from outside (e.g. cleared after submit)
37
22
  useEffect(function () {
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import { type IconSource } from './iconSlot';
2
3
  interface UserImageProps {
3
4
  userHandle: string;
4
5
  userImgUrl?: string;
@@ -7,6 +8,13 @@ interface UserImageProps {
7
8
  size?: number;
8
9
  /** Passed to the `<img>`, e.g. `no-referrer` for hosts that refuse requests carrying a referrer */
9
10
  referrerPolicy?: React.HTMLAttributeReferrerPolicy;
11
+ /** Shows this icon on the panel background in place of a picture or an initial: an agent's avatar. `userHandle` stays its accessible name. A Lucide name, an icon component or an element. */
12
+ icon?: IconSource;
13
+ /**
14
+ * Hides the avatar from assistive tech (`aria-hidden`, no name, an empty `alt` on a picture), for an
15
+ * avatar that sits beside the same name in text, so the name is not read twice. All three forms.
16
+ */
17
+ decorative?: boolean;
10
18
  }
11
- export default function UserImage({ userHandle, userImgUrl, grayscale, size, referrerPolicy, }: UserImageProps): React.JSX.Element;
19
+ export default function UserImage({ userHandle, userImgUrl, grayscale, size, referrerPolicy, icon, decorative, }: UserImageProps): React.JSX.Element;
12
20
  export {};
@@ -11,6 +11,7 @@ var __assign = (this && this.__assign) || function () {
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
13
  import React from 'react';
14
+ import IconSlot from './iconSlot';
14
15
  function getColorSeed(userHandle) {
15
16
  var words = userHandle.trim().split(/\s+/);
16
17
  var letters = words.map(function (word) { return word.charAt(0).toLowerCase(); });
@@ -33,7 +34,13 @@ function getHash(str) {
33
34
  return hash;
34
35
  }
35
36
  export default function UserImage(_a) {
36
- var userHandle = _a.userHandle, userImgUrl = _a.userImgUrl, _b = _a.grayscale, grayscale = _b === void 0 ? false : _b, size = _a.size, referrerPolicy = _a.referrerPolicy;
37
+ var userHandle = _a.userHandle, userImgUrl = _a.userImgUrl, _b = _a.grayscale, grayscale = _b === void 0 ? false : _b, size = _a.size, referrerPolicy = _a.referrerPolicy, icon = _a.icon, _c = _a.decorative, decorative = _c === void 0 ? false : _c;
38
+ if (icon) {
39
+ var diameter = size !== null && size !== void 0 ? size : 24;
40
+ return (<div role={decorative ? undefined : 'img'} aria-label={decorative ? undefined : userHandle} aria-hidden={decorative || undefined} style={size !== undefined ? { width: size, height: size } : undefined} className="flex items-center justify-center flex-shrink-0 w-6 h-6 rounded-full overflow-hidden bg-secondary-main text-secondary-contrast">
41
+ <IconSlot icon={icon} size={Math.round(diameter / 2)}/>
42
+ </div>);
43
+ }
37
44
  var displayInitial = userHandle.charAt(0).toUpperCase() || 'A';
38
45
  var seed = getColorSeed(userHandle);
39
46
  var hue = Math.abs(getHash(seed)) % 360;
@@ -47,8 +54,8 @@ export default function UserImage(_a) {
47
54
  return (
48
55
  // Per-user hue computed in JS, not a theme token, so the dark: variant stays here (one of the two documented
49
56
  // `dark:` exemptions, see the overlay rings in Menu/Popover/Modal). The dark: variant follows whatever dark variant the app's preset/@theme defines (class-only or OS-aware).
50
- <div style={__assign({ '--light-bg': lightBg, '--dark-bg': darkBg }, (size !== undefined && { width: size, height: size, fontSize: (size * 2) / 3 }))} className="flex items-center justify-center w-6 h-6 rounded-full overflow-hidden bg-[var(--light-bg)] dark:bg-[var(--dark-bg)] text-fg-primary">
51
- {userImgUrl ? (<img src={userImgUrl} alt={userHandle} referrerPolicy={referrerPolicy} className="w-full h-full object-cover rounded-full"/>) : (<span className={"".concat(size === undefined ? 'text-body1' : 'leading-none', " text-fg-primary")}>
57
+ <div aria-hidden={decorative || undefined} style={__assign({ '--light-bg': lightBg, '--dark-bg': darkBg }, (size !== undefined && { width: size, height: size, fontSize: (size * 2) / 3 }))} className="flex items-center justify-center w-6 h-6 rounded-full overflow-hidden bg-[var(--light-bg)] dark:bg-[var(--dark-bg)] text-fg-primary">
58
+ {userImgUrl ? (<img src={userImgUrl} alt={decorative ? '' : userHandle} referrerPolicy={referrerPolicy} className="w-full h-full object-cover rounded-full"/>) : (<span className={"".concat(size === undefined ? 'text-body1' : 'leading-none', " text-fg-primary")}>
52
59
  {displayInitial}
53
60
  </span>)}
54
61
  </div>);
@@ -0,0 +1,11 @@
1
+ export declare function fitHeight({ scrollHeight, lineHeight, paddingY, borderY, maxRows, }: {
2
+ scrollHeight: number;
3
+ lineHeight: number;
4
+ paddingY: number;
5
+ borderY: number;
6
+ maxRows: number;
7
+ }): {
8
+ height: number;
9
+ scroll: boolean;
10
+ };
11
+ export declare function fitToContent(textarea: HTMLTextAreaElement, maxRows: number): void;
@@ -0,0 +1,28 @@
1
+ // The auto-grow Textarea and Composer share: the text area fits its content, at least one line
2
+ // and at most maxRows, and scrolls past that. Kept out of the public API.
3
+ // The height to set (border-box) and whether the content needs to scroll
4
+ export function fitHeight(_a) {
5
+ var scrollHeight = _a.scrollHeight, lineHeight = _a.lineHeight, paddingY = _a.paddingY, borderY = _a.borderY, maxRows = _a.maxRows;
6
+ var maxContentHeight = lineHeight * maxRows + paddingY;
7
+ // Fit the content, capped at maxRows, but at least 1 line
8
+ var contentHeight = Math.max(Math.min(scrollHeight, maxContentHeight), lineHeight + paddingY);
9
+ return { height: contentHeight + borderY, scroll: scrollHeight > maxContentHeight };
10
+ }
11
+ // Measures the text area and sets its height. Call it from an effect or an event, never at module scope.
12
+ export function fitToContent(textarea, maxRows) {
13
+ textarea.style.height = 'auto'; // Reset height to calculate scrollHeight
14
+ var style = getComputedStyle(textarea);
15
+ // style.height is border-box, scrollHeight includes padding but not border
16
+ var _a = fitHeight({
17
+ scrollHeight: textarea.scrollHeight,
18
+ lineHeight: parseFloat(style.lineHeight),
19
+ paddingY: parseFloat(style.paddingTop) + parseFloat(style.paddingBottom),
20
+ borderY: parseFloat(style.borderTopWidth) + parseFloat(style.borderBottomWidth),
21
+ maxRows: maxRows,
22
+ }), height = _a.height, scroll = _a.scroll;
23
+ textarea.style.height = "".concat(height, "px");
24
+ // Enable vertical scroll if content exceeds maxRows (hide scrollbar)
25
+ textarea.style.overflowY = scroll ? 'scroll' : 'hidden';
26
+ textarea.style.scrollbarWidth = 'none'; // Firefox
27
+ textarea.style.msOverflowStyle = 'none'; // IE/Edge
28
+ }
@@ -0,0 +1,16 @@
1
+ export declare function isComposing({ composing, nativeIsComposing, keyCode }: {
2
+ composing: boolean;
3
+ nativeIsComposing: boolean;
4
+ keyCode: number;
5
+ }): boolean;
6
+ export declare function shouldSubmit({ key, shiftKey, metaKey, ctrlKey, isComposing, canSubmit, disabled, sending, submitOnEnter, }: {
7
+ key: string;
8
+ shiftKey: boolean;
9
+ metaKey: boolean;
10
+ ctrlKey: boolean;
11
+ isComposing: boolean;
12
+ canSubmit: boolean;
13
+ disabled: boolean;
14
+ sending: boolean;
15
+ submitOnEnter: boolean;
16
+ }): boolean;
@@ -0,0 +1,18 @@
1
+ // Composer's pure helpers, kept out of the public API (index.ts and the package exports do not reach internal/)
2
+ // Whether an input method (Korean, Japanese, Chinese) is composing text, so Enter confirms the
3
+ // text and must not send. Any one sign is enough: the composition events, the event's own flag,
4
+ // and keyCode 229, which Safari gives the Enter that ends a composition after compositionend
5
+ // has fired and while isComposing is already false.
6
+ export function isComposing(_a) {
7
+ var composing = _a.composing, nativeIsComposing = _a.nativeIsComposing, keyCode = _a.keyCode;
8
+ return composing || nativeIsComposing || keyCode === 229;
9
+ }
10
+ // Whether this key press sends the message. Cmd+Enter and Ctrl+Enter always do; plain Enter does
11
+ // when `submitOnEnter` is on and Shift is not held. Never while an input method is composing, when
12
+ // there is nothing to send (`canSubmit` false), or while the Composer is disabled or sending.
13
+ export function shouldSubmit(_a) {
14
+ var key = _a.key, shiftKey = _a.shiftKey, metaKey = _a.metaKey, ctrlKey = _a.ctrlKey, isComposing = _a.isComposing, canSubmit = _a.canSubmit, disabled = _a.disabled, sending = _a.sending, submitOnEnter = _a.submitOnEnter;
15
+ if (key !== 'Enter' || isComposing || !canSubmit || disabled || sending)
16
+ return false;
17
+ return metaKey || ctrlKey || (submitOnEnter && !shiftKey);
18
+ }
@@ -0,0 +1,6 @@
1
+ export declare function nextIndex({ key, current, count, labels }: {
2
+ key: string;
3
+ current: number;
4
+ count: number;
5
+ labels: string[];
6
+ }): number;