@major-tech/ui 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/components/editor-tabs.d.ts.map +1 -1
- package/dist/components/editor-tabs.js +3 -1
- package/dist/components/editor-tabs.js.map +1 -1
- package/dist/components/message.d.ts.map +1 -1
- package/dist/components/message.js +6 -3
- package/dist/components/message.js.map +1 -1
- package/dist/docs/components/editor-tabs.md +1 -0
- package/dist/docs/components/message.md +3 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @major-tech/ui
|
|
2
2
|
|
|
3
|
+
## 1.0.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Message: a bubble is at most 80% of the conversation's width (85% for Major's reply), no longer 302px, so on a wide page the two sides overlap instead of splitting it in half. The width sits on the root, so `className` overrides it.
|
|
8
|
+
|
|
9
|
+
## 1.0.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- EditorTabs: a focused tab's ring is drawn inside it, so the scrolling strip no longer cuts it off.
|
|
14
|
+
|
|
3
15
|
## 1.0.0
|
|
4
16
|
|
|
5
17
|
### Major Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editor-tabs.d.ts","sourceRoot":"","sources":["../../src/components/editor-tabs.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAmD,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAiBxF,mGAAmG;AACnG,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,4EAA4E;IAC5E,KAAK,EAAE,SAAS,CAAC;IACjB,oCAAoC;IACpC,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,2DAA2D;IAC3D,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,yFAAyF;IACzF,UAA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E,SAAS,CAAC;IACjB,oCAAoC;IACpC,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,2DAA2D;IAC3D,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,yFAAyF;IACzF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,0DAA0D;IAC1D,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,6FAA6F;IAC7F,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,SAAS,EAAE,CAAC;IAClB,iCAAiC;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,8EAA8E;IAC9E,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,6GAA6G;IAC7G,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC;;;OAGG;IACH,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IACvC,qHAAqH;IACrH,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,uGAAuG;IACvG,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,oFAAoF;IACpF,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,6GAA6G;IAC7G,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAoCD;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,EACzB,IAAI,EACJ,KAAK,EACL,YAAY,EACZ,aAAa,EACb,OAAO,EACP,SAAS,EACT,QAAQ,EACR,kBAA0B,EAC1B,YAAY,EAAE,SAAS,EACvB,QAAQ,EACR,SAAS,GACV,EAAE,eAAe,sCA0PjB"}
|
|
@@ -150,7 +150,9 @@ export function EditorTabs({ tabs, value, defaultValue, onValueChange, onClose,
|
|
|
150
150
|
// The list is the scroll container, so Motion measures the tabs with its scroll offset.
|
|
151
151
|
layoutScroll: true }), className: "relative min-w-0 gap-space-4 overflow-x-auto overscroll-x-contain rounded-none bg-transparent p-0 [scrollbar-width:none]", style: stripFadeStyle, children: _jsx(AnimatePresence, { initial: false, children: tabs.map((tab) => (_jsxs(Reorder.Item, { as: "span", value: tab.value, drag: isReorderable ? "x" : false, layout: "position", initial: { opacity: 0, scale: 0.85 }, animate: { opacity: 1, scale: 1 }, exit: { opacity: 0, scale: 0.85 }, transition: TAB_TRANSITION, "data-tab-value": tab.value,
|
|
152
152
|
// Positioned, so the dragged tab's raised z-index puts it over its neighbours.
|
|
153
|
-
className: "relative inline-flex shrink-0", children: [_jsxs(TabsTrigger, { value: tab.value, "aria-keyshortcuts": isReorderable ? "Alt+Shift+ArrowLeft Alt+Shift+ArrowRight" : undefined, onKeyDown: (event) => handleTabKeyDown(event, tab.value), className: cn("rounded-md border border-transparent px-space-10 text-ui-sm font-normal [&_svg]:size-3.5",
|
|
153
|
+
className: "relative inline-flex shrink-0", children: [_jsxs(TabsTrigger, { value: tab.value, "aria-keyshortcuts": isReorderable ? "Alt+Shift+ArrowLeft Alt+Shift+ArrowRight" : undefined, onKeyDown: (event) => handleTabKeyDown(event, tab.value), className: cn("rounded-md border border-transparent px-space-10 text-ui-sm font-normal [&_svg]:size-3.5",
|
|
154
|
+
// The list scrolls, so it cuts off anything drawn outside a tab: the focus ring goes inside.
|
|
155
|
+
"focus-visible:ring-inset", "data-active:border-panel-edge data-active:shadow-none", "aria-selected:border-panel-edge aria-selected:shadow-none", isReorderable && "cursor-grab active:cursor-grabbing", tab.closable && "pr-8.5"), children: [tab.icon, _jsx("span", { className: cn("max-w-45 truncate", tab.preview && "italic"), children: tab.label }), tab.unsaved && (_jsx("span", { role: "img", "aria-label": "Unsaved changes", className: "size-1.5 shrink-0 rounded-full bg-warn" }))] }), tab.closable && (
|
|
154
156
|
// A sibling of the tab, not inside it: its own focus stop with its own name.
|
|
155
157
|
_jsx("button", { type: "button", "aria-label": getCloseLabel(tab), onClick: () => onClose?.(tab.value), className: "absolute top-1/2 right-2.5 grid size-4.5 -translate-y-1/2 cursor-pointer place-items-center rounded-sm text-faint outline-none hover:bg-hover hover:text-ink focus-visible:ring-2 focus-visible:ring-faint", children: _jsx(X, { className: "size-3" }) }))] }, tab.value))) }) }), scroll.isOverflowing && (_jsxs(motion.div, { initial: { opacity: 0 }, animate: { opacity: 1 }, className: "flex shrink-0 items-center gap-space-2", children: [_jsx(Button, { variant: BUTTON_VARIANTS.GHOST, size: BUTTON_SIZES.ICON_SM, "aria-label": "Scroll tabs left", disabled: !scroll.canScrollBack, className: "disabled:opacity-40", onClick: () => scrollByStep(-1), children: _jsx(ChevronLeft, {}) }), _jsx(Button, { variant: BUTTON_VARIANTS.GHOST, size: BUTTON_SIZES.ICON_SM, "aria-label": "Scroll tabs right", disabled: !scroll.canScrollForward, className: "disabled:opacity-40", onClick: () => scrollByStep(1), children: _jsx(ChevronRight, {}) })] })), hasTrailing && (_jsx("div", { ref: trailingRef, className: "flex shrink-0 items-center", children: trailing }))] }) })), children] }));
|
|
156
158
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editor-tabs.js","sourceRoot":"","sources":["../../src/components/editor-tabs.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAsC,MAAM,OAAO,CAAC;AACxF,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChG,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAClC,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AACnG,OAAO,EAAE,YAAY,EAAE,eAAe,EA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C,YAAY,CAAC,CAAC,CAAC,YAE9B,KAAC,YAAY,KAAG,GACT,IACE,CACd,EACA,WAAW,IAAI,CACd,cAAK,GAAG,EAAE,WAAW,EAAE,SAAS,EAAC,4BAA4B,YAC1D,QAAQ,GACL,CACP,IACG,GACO,CAChB,EACA,QAAQ,IACJ,CACR,CAAC;AACJ,CAAC","sourcesContent":["\"use client\";\n\nimport { useEffect, useRef, useState, type KeyboardEvent, type ReactNode } from \"react\";\nimport { ChevronLeft, ChevronRight, X } from \"lucide-react\";\nimport { AnimatePresence, MotionConfig, Reorder, motion, useReducedMotion } from \"motion/react\";\nimport { cn } from \"../lib/cn.ts\";\nimport { NO_SCROLL_FADE_EDGES, SCROLL_FADE_PX, buildScrollFadeStyle } from \"../lib/scroll-fade.ts\";\nimport { BUTTON_SIZES, BUTTON_VARIANTS, Button } from \"./button.tsx\";\nimport { Tabs, TabsList, TabsTrigger } from \"./tabs.tsx\";\n\n/** How much of the strip's visible width one press of an arrow scrolls. */\nconst SCROLL_STEP_RATIO = 0.6;\n/** Sub-pixel slack, so fractional widths don't read as overflow when the tabs fit. */\nconst OVERFLOW_EPSILON_PX = 1;\n/** A tab opening, closing, or making room for the one being dragged. */\nconst TAB_TRANSITION = { duration: 0.15, ease: \"easeOut\" } as const;\n/** With Alt and Shift held, the arrow keys move the focused tab one place. */\nconst MOVE_STEPS: Record<string, number> = { ArrowLeft: -1, ArrowRight: 1 };\n\n/** One tab of the strip: the agent (or skill) itself, an app opened from it, or a chat session. */\nexport interface EditorTab {\n value: string;\n /** Its name, truncated at 180px: text, or a node that looks the name up. */\n label: ReactNode;\n /** A 14px icon before the label. */\n icon?: ReactNode;\n /** Apps close with a ×; the agent's own tab never does. */\n closable?: boolean;\n /** The ×'s name. Defaults to “Close {label}” for a text label, “Close tab” otherwise. */\n closeLabel?: string;\n /** Shows the `warn` dot: this tab has unsaved changes. */\n unsaved?: boolean;\n /** A tab only looked into, not started yet (a session not running): its label in italics. */\n preview?: boolean;\n}\n\nexport interface EditorTabsProps {\n tabs: EditorTab[];\n /** The open tab (controlled). */\n value?: string;\n /** The tab open on first render (uncontrolled). Defaults to the first tab. */\n defaultValue?: string;\n onValueChange?: (value: string) => void;\n /** Called with the value of the tab whose × was pressed. Pick the next tab and drop this one from `tabs`. */\n onClose?: (value: string) => void;\n /**\n * Called with every tab's value in the new order while a tab is dragged, or moved with Alt+Shift+← / →. Put\n * `tabs` in that order. Without it the tabs stay where they are.\n */\n onReorder?: (values: string[]) => void;\n /** After the tabs and their arrows: the control that opens a new one (New chat). It keeps the strip with one tab. */\n trailing?: ReactNode;\n /** Keeps the strip while only one tab is open, where that tab says something (the chat's New chat). */\n isSingleTabVisible?: boolean;\n /** The tab list's name, where the page has more than one strip: “Chat sessions”. */\n \"aria-label\"?: string;\n /** The tabs' panels, as `TabsContent` from `@major-tech/ui/tabs`. They stay visible when the strip hides. */\n children?: ReactNode;\n className?: string;\n}\n\ninterface StripScroll {\n isOverflowing: boolean;\n canScrollBack: boolean;\n canScrollForward: boolean;\n}\n\nconst NO_OVERFLOW: StripScroll = { isOverflowing: false, canScrollBack: false, canScrollForward: false };\n\n/** Whether the tabs overflow the strip, and which way the list can scroll. `reservedPx`: the trailing control's room. */\nfunction measureStripScroll(strip: HTMLElement, list: HTMLElement, reservedPx: number): StripScroll {\n return {\n // Against the whole strip, not the list: the arrows narrow the list, and that would keep them showing.\n isOverflowing: list.scrollWidth > strip.clientWidth - reservedPx + OVERFLOW_EPSILON_PX,\n canScrollBack: list.scrollLeft > OVERFLOW_EPSILON_PX,\n canScrollForward: list.scrollLeft + list.clientWidth < list.scrollWidth - OVERFLOW_EPSILON_PX,\n };\n}\n\nfunction isSameScroll(a: StripScroll, b: StripScroll) {\n return (\n a.isOverflowing === b.isOverflowing &&\n a.canScrollBack === b.canScrollBack &&\n a.canScrollForward === b.canScrollForward\n );\n}\n\nfunction getCloseLabel(tab: EditorTab) {\n return tab.closeLabel ?? (typeof tab.label === \"string\" ? `Close ${tab.label}` : \"Close tab\");\n}\n\nfunction findTabItem(list: HTMLElement | null, value: string | undefined) {\n return value === undefined ? null : (list?.querySelector<HTMLElement>(`[data-tab-value=\"${CSS.escape(value)}\"]`) ?? null);\n}\n\n/**\n * The tab strip above the editor, built on Tabs: the agent (or skill) tab plus any apps opened from it, or a chat's\n * sessions. Hidden while only one tab is open, unless it has a `trailing` control or `isSingleTabVisible`. The selected tab is `surface` with a `panel-edge` border, the others `muted`;\n * labels truncate at 180px. With `onReorder` the tabs drag into a new order. When they don't fit, the strip scrolls,\n * fades out on the side with more, and arrows appear at its end; the open tab is always scrolled into view.\n */\nexport function EditorTabs({\n tabs,\n value,\n defaultValue,\n onValueChange,\n onClose,\n onReorder,\n trailing,\n isSingleTabVisible = false,\n \"aria-label\": ariaLabel,\n children,\n className,\n}: EditorTabsProps) {\n const stripRef = useRef<HTMLDivElement>(null);\n const listRef = useRef<HTMLDivElement>(null);\n const trailingRef = useRef<HTMLDivElement>(null);\n // The tab just moved with the keyboard: moving its node in the DOM drops its focus, so it gets it back.\n const movedTabRef = useRef<string | null>(null);\n const [uncontrolledValue, setUncontrolledValue] = useState(defaultValue ?? tabs[0]?.value);\n const [scroll, setScroll] = useState(NO_OVERFLOW);\n const isReducedMotion = useReducedMotion();\n const scrollBehavior = isReducedMotion ? \"auto\" : \"smooth\";\n\n const hasTrailing = Boolean(trailing);\n const isStripVisible = tabs.length > 1 || (tabs.length > 0 && (hasTrailing || isSingleTabVisible));\n const isReorderable = onReorder !== undefined;\n const values = tabs.map((tab) => tab.value);\n const openValue = value ?? uncontrolledValue;\n\n const measureScroll = () => {\n const strip = stripRef.current;\n const list = listRef.current;\n const trailingElement = trailingRef.current;\n const reservedPx =\n trailingElement && strip\n ? trailingElement.offsetWidth + (Number.parseFloat(getComputedStyle(strip).columnGap) || 0)\n : 0;\n const next = strip && list ? measureStripScroll(strip, list, reservedPx) : NO_OVERFLOW;\n\n setScroll((current) => (isSameScroll(current, next) ? current : next));\n };\n\n // Resizing the strip and scrolling the list change which arrows show; the strip mounts and unmounts with its\n // second tab.\n useEffect(() => {\n const strip = stripRef.current;\n const list = listRef.current;\n\n if (!strip || !list) {\n return;\n }\n\n const observer = new ResizeObserver(measureScroll);\n\n observer.observe(strip);\n observer.observe(list);\n list.addEventListener(\"scroll\", measureScroll, { passive: true });\n\n return () => {\n observer.disconnect();\n list.removeEventListener(\"scroll\", measureScroll);\n };\n // measureScroll reads only refs and the state setter, so the first one stays right.\n }, [isStripVisible]);\n\n // Tabs opening, closing or renamed change what there is to scroll without resizing anything.\n useEffect(measureScroll);\n\n // Bring the open tab into view, clear of the edge fade: one opened past the edge, or one clicked while half hidden\n // or faded. At either end of the list the browser stops the scroll short, where there is no fade. Only the strip\n // scrolls, never the page around it.\n useEffect(() => {\n const list = listRef.current;\n const item = findTabItem(list, openValue);\n\n if (!list || !item) {\n return;\n }\n\n const start = item.offsetLeft;\n const end = start + item.offsetWidth;\n\n if (start < list.scrollLeft + SCROLL_FADE_PX) {\n list.scrollTo({ left: start - SCROLL_FADE_PX, behavior: scrollBehavior });\n } else if (end > list.scrollLeft + list.clientWidth - SCROLL_FADE_PX) {\n list.scrollTo({ left: end - list.clientWidth + SCROLL_FADE_PX, behavior: scrollBehavior });\n }\n }, [openValue, tabs.length, scrollBehavior]);\n\n useEffect(() => {\n const moved = movedTabRef.current;\n\n movedTabRef.current = null;\n\n if (moved && document.activeElement === document.body) {\n findTabItem(listRef.current, moved)?.querySelector<HTMLElement>('[role=\"tab\"]')?.focus();\n }\n });\n\n if (!isStripVisible && !children) {\n return null;\n }\n\n const handleValueChange = (next: string) => {\n setUncontrolledValue(next);\n onValueChange?.(next);\n };\n\n const handleTabKeyDown = (event: KeyboardEvent<HTMLElement>, tabValue: string) => {\n const step = MOVE_STEPS[event.key];\n\n if (!onReorder || !step || !event.altKey || !event.shiftKey || event.ctrlKey || event.metaKey) {\n return;\n }\n\n // Keep the tablist from also moving focus to the neighbour.\n event.preventDefault();\n event.stopPropagation();\n\n const from = values.indexOf(tabValue);\n const to = from + step;\n\n if (to < 0 || to >= values.length) {\n return;\n }\n\n const next = values.filter((current) => current !== tabValue);\n\n next.splice(to, 0, tabValue);\n movedTabRef.current = tabValue;\n onReorder(next);\n };\n\n const stripFadeStyle = buildScrollFadeStyle({\n ...NO_SCROLL_FADE_EDGES,\n left: scroll.canScrollBack,\n right: scroll.canScrollForward,\n });\n\n const scrollByStep = (direction: -1 | 1) => {\n const list = listRef.current;\n\n list?.scrollBy({ left: direction * list.clientWidth * SCROLL_STEP_RATIO, behavior: scrollBehavior });\n };\n\n return (\n <Tabs\n data-slot=\"editor-tabs\"\n value={value}\n defaultValue={defaultValue ?? tabs[0]?.value}\n onValueChange={handleValueChange}\n className={className}\n >\n {isStripVisible && (\n <MotionConfig reducedMotion=\"user\">\n <div ref={stripRef} className=\"flex min-w-0 items-center gap-space-4\">\n <TabsList\n ref={listRef}\n aria-label={ariaLabel}\n render={\n <Reorder.Group\n as=\"div\"\n axis=\"x\"\n values={values}\n onReorder={(next: string[]) => onReorder?.(next)}\n // The list is the scroll container, so Motion measures the tabs with its scroll offset.\n layoutScroll\n />\n }\n className=\"relative min-w-0 gap-space-4 overflow-x-auto overscroll-x-contain rounded-none bg-transparent p-0 [scrollbar-width:none]\"\n style={stripFadeStyle}\n >\n <AnimatePresence initial={false}>\n {tabs.map((tab) => (\n <Reorder.Item\n key={tab.value}\n as=\"span\"\n value={tab.value}\n drag={isReorderable ? \"x\" : false}\n layout=\"position\"\n initial={{ opacity: 0, scale: 0.85 }}\n animate={{ opacity: 1, scale: 1 }}\n exit={{ opacity: 0, scale: 0.85 }}\n transition={TAB_TRANSITION}\n data-tab-value={tab.value}\n // Positioned, so the dragged tab's raised z-index puts it over its neighbours.\n className=\"relative inline-flex shrink-0\"\n >\n <TabsTrigger\n value={tab.value}\n aria-keyshortcuts={isReorderable ? \"Alt+Shift+ArrowLeft Alt+Shift+ArrowRight\" : undefined}\n onKeyDown={(event) => handleTabKeyDown(event, tab.value)}\n className={cn(\n \"rounded-md border border-transparent px-space-10 text-ui-sm font-normal [&_svg]:size-3.5\",\n \"data-active:border-panel-edge data-active:shadow-none\",\n \"aria-selected:border-panel-edge aria-selected:shadow-none\",\n isReorderable && \"cursor-grab active:cursor-grabbing\",\n tab.closable && \"pr-8.5\"\n )}\n >\n {tab.icon}\n <span className={cn(\"max-w-45 truncate\", tab.preview && \"italic\")}>{tab.label}</span>\n {tab.unsaved && (\n <span role=\"img\" aria-label=\"Unsaved changes\" className=\"size-1.5 shrink-0 rounded-full bg-warn\" />\n )}\n </TabsTrigger>\n {tab.closable && (\n // A sibling of the tab, not inside it: its own focus stop with its own name.\n <button\n type=\"button\"\n aria-label={getCloseLabel(tab)}\n onClick={() => onClose?.(tab.value)}\n className=\"absolute top-1/2 right-2.5 grid size-4.5 -translate-y-1/2 cursor-pointer place-items-center rounded-sm text-faint outline-none hover:bg-hover hover:text-ink focus-visible:ring-2 focus-visible:ring-faint\"\n >\n <X className=\"size-3\" />\n </button>\n )}\n </Reorder.Item>\n ))}\n </AnimatePresence>\n </TabsList>\n {scroll.isOverflowing && (\n <motion.div\n initial={{ opacity: 0 }}\n animate={{ opacity: 1 }}\n className=\"flex shrink-0 items-center gap-space-2\"\n >\n <Button\n variant={BUTTON_VARIANTS.GHOST}\n size={BUTTON_SIZES.ICON_SM}\n aria-label=\"Scroll tabs left\"\n disabled={!scroll.canScrollBack}\n className=\"disabled:opacity-40\"\n onClick={() => scrollByStep(-1)}\n >\n <ChevronLeft />\n </Button>\n <Button\n variant={BUTTON_VARIANTS.GHOST}\n size={BUTTON_SIZES.ICON_SM}\n aria-label=\"Scroll tabs right\"\n disabled={!scroll.canScrollForward}\n className=\"disabled:opacity-40\"\n onClick={() => scrollByStep(1)}\n >\n <ChevronRight />\n </Button>\n </motion.div>\n )}\n {hasTrailing && (\n <div ref={trailingRef} className=\"flex shrink-0 items-center\">\n {trailing}\n </div>\n )}\n </div>\n </MotionConfig>\n )}\n {children}\n </Tabs>\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AE,EACvB,OAAO,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,EACvB,SAAS,EAAC,wCAAwC,aAElD,KAAC,MAAM,IACL,OAAO,EAAE,eAAe,CAAC,KAAK,EAC9B,IAAI,EAAE,YAAY,CAAC,OAAO,gBACf,kBAAkB,EAC7B,QAAQ,EAAE,CAAC,MAAM,CAAC,aAAa,EAC/B,SAAS,EAAC,qBAAqB,EAC/B,OAAO,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,YAE/B,KAAC,WAAW,KAAG,GACR,EACT,KAAC,MAAM,IACL,OAAO,EAAE,eAAe,CAAC,KAAK,EAC9B,IAAI,EAAE,YAAY,CAAC,OAAO,gBACf,mBAAmB,EAC9B,QAAQ,EAAE,CAAC,MAAM,CAAC,gBAAgB,EAClC,SAAS,EAAC,qBAAqB,EAC/B,OAAO,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC,YAE9B,KAAC,YAAY,KAAG,GACT,IACE,CACd,EACA,WAAW,IAAI,CACd,cAAK,GAAG,EAAE,WAAW,EAAE,SAAS,EAAC,4BAA4B,YAC1D,QAAQ,GACL,CACP,IACG,GACO,CAChB,EACA,QAAQ,IACJ,CACR,CAAC;AACJ,CAAC","sourcesContent":["\"use client\";\n\nimport { useEffect, useRef, useState, type KeyboardEvent, type ReactNode } from \"react\";\nimport { ChevronLeft, ChevronRight, X } from \"lucide-react\";\nimport { AnimatePresence, MotionConfig, Reorder, motion, useReducedMotion } from \"motion/react\";\nimport { cn } from \"../lib/cn.ts\";\nimport { NO_SCROLL_FADE_EDGES, SCROLL_FADE_PX, buildScrollFadeStyle } from \"../lib/scroll-fade.ts\";\nimport { BUTTON_SIZES, BUTTON_VARIANTS, Button } from \"./button.tsx\";\nimport { Tabs, TabsList, TabsTrigger } from \"./tabs.tsx\";\n\n/** How much of the strip's visible width one press of an arrow scrolls. */\nconst SCROLL_STEP_RATIO = 0.6;\n/** Sub-pixel slack, so fractional widths don't read as overflow when the tabs fit. */\nconst OVERFLOW_EPSILON_PX = 1;\n/** A tab opening, closing, or making room for the one being dragged. */\nconst TAB_TRANSITION = { duration: 0.15, ease: \"easeOut\" } as const;\n/** With Alt and Shift held, the arrow keys move the focused tab one place. */\nconst MOVE_STEPS: Record<string, number> = { ArrowLeft: -1, ArrowRight: 1 };\n\n/** One tab of the strip: the agent (or skill) itself, an app opened from it, or a chat session. */\nexport interface EditorTab {\n value: string;\n /** Its name, truncated at 180px: text, or a node that looks the name up. */\n label: ReactNode;\n /** A 14px icon before the label. */\n icon?: ReactNode;\n /** Apps close with a ×; the agent's own tab never does. */\n closable?: boolean;\n /** The ×'s name. Defaults to “Close {label}” for a text label, “Close tab” otherwise. */\n closeLabel?: string;\n /** Shows the `warn` dot: this tab has unsaved changes. */\n unsaved?: boolean;\n /** A tab only looked into, not started yet (a session not running): its label in italics. */\n preview?: boolean;\n}\n\nexport interface EditorTabsProps {\n tabs: EditorTab[];\n /** The open tab (controlled). */\n value?: string;\n /** The tab open on first render (uncontrolled). Defaults to the first tab. */\n defaultValue?: string;\n onValueChange?: (value: string) => void;\n /** Called with the value of the tab whose × was pressed. Pick the next tab and drop this one from `tabs`. */\n onClose?: (value: string) => void;\n /**\n * Called with every tab's value in the new order while a tab is dragged, or moved with Alt+Shift+← / →. Put\n * `tabs` in that order. Without it the tabs stay where they are.\n */\n onReorder?: (values: string[]) => void;\n /** After the tabs and their arrows: the control that opens a new one (New chat). It keeps the strip with one tab. */\n trailing?: ReactNode;\n /** Keeps the strip while only one tab is open, where that tab says something (the chat's New chat). */\n isSingleTabVisible?: boolean;\n /** The tab list's name, where the page has more than one strip: “Chat sessions”. */\n \"aria-label\"?: string;\n /** The tabs' panels, as `TabsContent` from `@major-tech/ui/tabs`. They stay visible when the strip hides. */\n children?: ReactNode;\n className?: string;\n}\n\ninterface StripScroll {\n isOverflowing: boolean;\n canScrollBack: boolean;\n canScrollForward: boolean;\n}\n\nconst NO_OVERFLOW: StripScroll = { isOverflowing: false, canScrollBack: false, canScrollForward: false };\n\n/** Whether the tabs overflow the strip, and which way the list can scroll. `reservedPx`: the trailing control's room. */\nfunction measureStripScroll(strip: HTMLElement, list: HTMLElement, reservedPx: number): StripScroll {\n return {\n // Against the whole strip, not the list: the arrows narrow the list, and that would keep them showing.\n isOverflowing: list.scrollWidth > strip.clientWidth - reservedPx + OVERFLOW_EPSILON_PX,\n canScrollBack: list.scrollLeft > OVERFLOW_EPSILON_PX,\n canScrollForward: list.scrollLeft + list.clientWidth < list.scrollWidth - OVERFLOW_EPSILON_PX,\n };\n}\n\nfunction isSameScroll(a: StripScroll, b: StripScroll) {\n return (\n a.isOverflowing === b.isOverflowing &&\n a.canScrollBack === b.canScrollBack &&\n a.canScrollForward === b.canScrollForward\n );\n}\n\nfunction getCloseLabel(tab: EditorTab) {\n return tab.closeLabel ?? (typeof tab.label === \"string\" ? `Close ${tab.label}` : \"Close tab\");\n}\n\nfunction findTabItem(list: HTMLElement | null, value: string | undefined) {\n return value === undefined ? null : (list?.querySelector<HTMLElement>(`[data-tab-value=\"${CSS.escape(value)}\"]`) ?? null);\n}\n\n/**\n * The tab strip above the editor, built on Tabs: the agent (or skill) tab plus any apps opened from it, or a chat's\n * sessions. Hidden while only one tab is open, unless it has a `trailing` control or `isSingleTabVisible`. The selected tab is `surface` with a `panel-edge` border, the others `muted`;\n * labels truncate at 180px. With `onReorder` the tabs drag into a new order. When they don't fit, the strip scrolls,\n * fades out on the side with more, and arrows appear at its end; the open tab is always scrolled into view.\n */\nexport function EditorTabs({\n tabs,\n value,\n defaultValue,\n onValueChange,\n onClose,\n onReorder,\n trailing,\n isSingleTabVisible = false,\n \"aria-label\": ariaLabel,\n children,\n className,\n}: EditorTabsProps) {\n const stripRef = useRef<HTMLDivElement>(null);\n const listRef = useRef<HTMLDivElement>(null);\n const trailingRef = useRef<HTMLDivElement>(null);\n // The tab just moved with the keyboard: moving its node in the DOM drops its focus, so it gets it back.\n const movedTabRef = useRef<string | null>(null);\n const [uncontrolledValue, setUncontrolledValue] = useState(defaultValue ?? tabs[0]?.value);\n const [scroll, setScroll] = useState(NO_OVERFLOW);\n const isReducedMotion = useReducedMotion();\n const scrollBehavior = isReducedMotion ? \"auto\" : \"smooth\";\n\n const hasTrailing = Boolean(trailing);\n const isStripVisible = tabs.length > 1 || (tabs.length > 0 && (hasTrailing || isSingleTabVisible));\n const isReorderable = onReorder !== undefined;\n const values = tabs.map((tab) => tab.value);\n const openValue = value ?? uncontrolledValue;\n\n const measureScroll = () => {\n const strip = stripRef.current;\n const list = listRef.current;\n const trailingElement = trailingRef.current;\n const reservedPx =\n trailingElement && strip\n ? trailingElement.offsetWidth + (Number.parseFloat(getComputedStyle(strip).columnGap) || 0)\n : 0;\n const next = strip && list ? measureStripScroll(strip, list, reservedPx) : NO_OVERFLOW;\n\n setScroll((current) => (isSameScroll(current, next) ? current : next));\n };\n\n // Resizing the strip and scrolling the list change which arrows show; the strip mounts and unmounts with its\n // second tab.\n useEffect(() => {\n const strip = stripRef.current;\n const list = listRef.current;\n\n if (!strip || !list) {\n return;\n }\n\n const observer = new ResizeObserver(measureScroll);\n\n observer.observe(strip);\n observer.observe(list);\n list.addEventListener(\"scroll\", measureScroll, { passive: true });\n\n return () => {\n observer.disconnect();\n list.removeEventListener(\"scroll\", measureScroll);\n };\n // measureScroll reads only refs and the state setter, so the first one stays right.\n }, [isStripVisible]);\n\n // Tabs opening, closing or renamed change what there is to scroll without resizing anything.\n useEffect(measureScroll);\n\n // Bring the open tab into view, clear of the edge fade: one opened past the edge, or one clicked while half hidden\n // or faded. At either end of the list the browser stops the scroll short, where there is no fade. Only the strip\n // scrolls, never the page around it.\n useEffect(() => {\n const list = listRef.current;\n const item = findTabItem(list, openValue);\n\n if (!list || !item) {\n return;\n }\n\n const start = item.offsetLeft;\n const end = start + item.offsetWidth;\n\n if (start < list.scrollLeft + SCROLL_FADE_PX) {\n list.scrollTo({ left: start - SCROLL_FADE_PX, behavior: scrollBehavior });\n } else if (end > list.scrollLeft + list.clientWidth - SCROLL_FADE_PX) {\n list.scrollTo({ left: end - list.clientWidth + SCROLL_FADE_PX, behavior: scrollBehavior });\n }\n }, [openValue, tabs.length, scrollBehavior]);\n\n useEffect(() => {\n const moved = movedTabRef.current;\n\n movedTabRef.current = null;\n\n if (moved && document.activeElement === document.body) {\n findTabItem(listRef.current, moved)?.querySelector<HTMLElement>('[role=\"tab\"]')?.focus();\n }\n });\n\n if (!isStripVisible && !children) {\n return null;\n }\n\n const handleValueChange = (next: string) => {\n setUncontrolledValue(next);\n onValueChange?.(next);\n };\n\n const handleTabKeyDown = (event: KeyboardEvent<HTMLElement>, tabValue: string) => {\n const step = MOVE_STEPS[event.key];\n\n if (!onReorder || !step || !event.altKey || !event.shiftKey || event.ctrlKey || event.metaKey) {\n return;\n }\n\n // Keep the tablist from also moving focus to the neighbour.\n event.preventDefault();\n event.stopPropagation();\n\n const from = values.indexOf(tabValue);\n const to = from + step;\n\n if (to < 0 || to >= values.length) {\n return;\n }\n\n const next = values.filter((current) => current !== tabValue);\n\n next.splice(to, 0, tabValue);\n movedTabRef.current = tabValue;\n onReorder(next);\n };\n\n const stripFadeStyle = buildScrollFadeStyle({\n ...NO_SCROLL_FADE_EDGES,\n left: scroll.canScrollBack,\n right: scroll.canScrollForward,\n });\n\n const scrollByStep = (direction: -1 | 1) => {\n const list = listRef.current;\n\n list?.scrollBy({ left: direction * list.clientWidth * SCROLL_STEP_RATIO, behavior: scrollBehavior });\n };\n\n return (\n <Tabs\n data-slot=\"editor-tabs\"\n value={value}\n defaultValue={defaultValue ?? tabs[0]?.value}\n onValueChange={handleValueChange}\n className={className}\n >\n {isStripVisible && (\n <MotionConfig reducedMotion=\"user\">\n <div ref={stripRef} className=\"flex min-w-0 items-center gap-space-4\">\n <TabsList\n ref={listRef}\n aria-label={ariaLabel}\n render={\n <Reorder.Group\n as=\"div\"\n axis=\"x\"\n values={values}\n onReorder={(next: string[]) => onReorder?.(next)}\n // The list is the scroll container, so Motion measures the tabs with its scroll offset.\n layoutScroll\n />\n }\n className=\"relative min-w-0 gap-space-4 overflow-x-auto overscroll-x-contain rounded-none bg-transparent p-0 [scrollbar-width:none]\"\n style={stripFadeStyle}\n >\n <AnimatePresence initial={false}>\n {tabs.map((tab) => (\n <Reorder.Item\n key={tab.value}\n as=\"span\"\n value={tab.value}\n drag={isReorderable ? \"x\" : false}\n layout=\"position\"\n initial={{ opacity: 0, scale: 0.85 }}\n animate={{ opacity: 1, scale: 1 }}\n exit={{ opacity: 0, scale: 0.85 }}\n transition={TAB_TRANSITION}\n data-tab-value={tab.value}\n // Positioned, so the dragged tab's raised z-index puts it over its neighbours.\n className=\"relative inline-flex shrink-0\"\n >\n <TabsTrigger\n value={tab.value}\n aria-keyshortcuts={isReorderable ? \"Alt+Shift+ArrowLeft Alt+Shift+ArrowRight\" : undefined}\n onKeyDown={(event) => handleTabKeyDown(event, tab.value)}\n className={cn(\n \"rounded-md border border-transparent px-space-10 text-ui-sm font-normal [&_svg]:size-3.5\",\n // The list scrolls, so it cuts off anything drawn outside a tab: the focus ring goes inside.\n \"focus-visible:ring-inset\",\n \"data-active:border-panel-edge data-active:shadow-none\",\n \"aria-selected:border-panel-edge aria-selected:shadow-none\",\n isReorderable && \"cursor-grab active:cursor-grabbing\",\n tab.closable && \"pr-8.5\"\n )}\n >\n {tab.icon}\n <span className={cn(\"max-w-45 truncate\", tab.preview && \"italic\")}>{tab.label}</span>\n {tab.unsaved && (\n <span role=\"img\" aria-label=\"Unsaved changes\" className=\"size-1.5 shrink-0 rounded-full bg-warn\" />\n )}\n </TabsTrigger>\n {tab.closable && (\n // A sibling of the tab, not inside it: its own focus stop with its own name.\n <button\n type=\"button\"\n aria-label={getCloseLabel(tab)}\n onClick={() => onClose?.(tab.value)}\n className=\"absolute top-1/2 right-2.5 grid size-4.5 -translate-y-1/2 cursor-pointer place-items-center rounded-sm text-faint outline-none hover:bg-hover hover:text-ink focus-visible:ring-2 focus-visible:ring-faint\"\n >\n <X className=\"size-3\" />\n </button>\n )}\n </Reorder.Item>\n ))}\n </AnimatePresence>\n </TabsList>\n {scroll.isOverflowing && (\n <motion.div\n initial={{ opacity: 0 }}\n animate={{ opacity: 1 }}\n className=\"flex shrink-0 items-center gap-space-2\"\n >\n <Button\n variant={BUTTON_VARIANTS.GHOST}\n size={BUTTON_SIZES.ICON_SM}\n aria-label=\"Scroll tabs left\"\n disabled={!scroll.canScrollBack}\n className=\"disabled:opacity-40\"\n onClick={() => scrollByStep(-1)}\n >\n <ChevronLeft />\n </Button>\n <Button\n variant={BUTTON_VARIANTS.GHOST}\n size={BUTTON_SIZES.ICON_SM}\n aria-label=\"Scroll tabs right\"\n disabled={!scroll.canScrollForward}\n className=\"disabled:opacity-40\"\n onClick={() => scrollByStep(1)}\n >\n <ChevronRight />\n </Button>\n </motion.div>\n )}\n {hasTrailing && (\n <div ref={trailingRef} className=\"flex shrink-0 items-center\">\n {trailing}\n </div>\n )}\n </div>\n </MotionConfig>\n )}\n {children}\n </Tabs>\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../src/components/message.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvD,eAAO,MAAM,eAAe;IAC1B,8DAA8D;;IAE9D,sEAAsE;;CAE9D,CAAC;AAEX,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,OAAO,eAAe,CAAC,CAAC;AAEnF,MAAM,WAAW,YAAa,SAAQ,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IACxE,6FAA6F;IAC7F,IAAI,EAAE,aAAa,CAAC;IACpB,+EAA+E;IAC/E,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,gDAAgD;IAChD,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,4EAA4E;IAC5E,MAAM,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,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,qFAAqF;IACrF,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,sGAAsG;IACtG,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,mHAAmH;IACnH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,uFAAuF;IACvF,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,yFAAyF;IACzF,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,uEAAuE;IACvE,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;CACvB;AAQD;;;GAGG;AACH,wBAAgB,OAAO,CAAC,EACtB,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,MAAM,EACN,OAAO,EACP,SAAS,EACT,IAAI,EACJ,MAAc,EACd,MAAc,EACd,MAAM,EACN,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,YAAY,+BAiFd"}
|
|
@@ -8,17 +8,20 @@ export const MESSAGE_AUTHORS = {
|
|
|
8
8
|
AGENT: "agent",
|
|
9
9
|
};
|
|
10
10
|
const QUEUED_ACTION_CLASSES = "cursor-pointer rounded-xs italic underline outline-none hover:text-ink focus-visible:ring-2 focus-visible:ring-faint";
|
|
11
|
-
const BUBBLE_CLASSES = "relative
|
|
11
|
+
const BUBBLE_CLASSES = "relative rounded-lg px-space-10 py-1.75 text-body leading-5 break-words whitespace-pre-wrap text-ink";
|
|
12
12
|
/**
|
|
13
13
|
* One turn in the chat panel. Stack turns with a 12px gap (`flex flex-col gap-space-12`), and keep 32px between the
|
|
14
14
|
* last message and the Composer.
|
|
15
15
|
*/
|
|
16
16
|
export function Message({ from, time, trace, avatar, actions, reactions, meta, bubble = false, queued = false, onEdit, onCancel, className, children, ...props }) {
|
|
17
17
|
if (from === MESSAGE_AUTHORS.USER) {
|
|
18
|
-
return (_jsxs("div", { "data-slot": "message", "data-from": from, className: cn(
|
|
18
|
+
return (_jsxs("div", { "data-slot": "message", "data-from": from, className: cn(
|
|
19
|
+
// A share of the conversation's width, not a fixed one: the two sides overlap, as in any messenger, and
|
|
20
|
+
// never split a wide page into halves. As wide as the bubble and pushed right, in a flex column or a block.
|
|
21
|
+
"ml-auto flex w-fit max-w-4/5 flex-col items-end gap-space-4 self-end", reactions && "pt-4", queued && "opacity-60", className), ...props, children: [_jsxs("div", { className: cn(BUBBLE_CLASSES, "border border-line bg-bubble"), children: [reactions && (_jsx("div", { "data-slot": "message-reactions", className: "absolute -top-3.5 -left-3.5 flex items-center gap-0.5 rounded-full border border-line bg-surface px-space-8 text-editor-body leading-7 shadow-card", children: reactions })), children] }), (meta || time || queued) && (_jsxs("div", { className: "flex items-center gap-space-8 px-space-4 text-small text-faint", children: [meta, queued && (_jsxs("span", { "data-slot": "message-queued", className: "flex items-center gap-1.5 text-muted", children: [_jsx("span", { className: "italic", children: "Queued" }), onEdit && (_jsx("button", { type: "button", onClick: onEdit, className: QUEUED_ACTION_CLASSES, children: "Edit" })), onCancel && (_jsx("button", { type: "button", onClick: onCancel, className: QUEUED_ACTION_CLASSES, children: "Cancel" }))] })), time && _jsx("span", { children: time })] }))] }));
|
|
19
22
|
}
|
|
20
23
|
if (bubble) {
|
|
21
|
-
return (_jsxs("div", { "data-slot": "message", "data-from": from, className: cn("flex flex-col items-start gap-space-4 self-start", className), ...props, children: [_jsx("div", { className: cn(BUBBLE_CLASSES, "bg-secondary"), children: children }), time && _jsx("span", { className: "px-space-4 text-small text-faint", children: time })] }));
|
|
24
|
+
return (_jsxs("div", { "data-slot": "message", "data-from": from, className: cn("flex w-fit max-w-17/20 flex-col items-start gap-space-4 self-start", className), ...props, children: [_jsx("div", { className: cn(BUBBLE_CLASSES, "bg-secondary"), children: children }), time && _jsx("span", { className: "px-space-4 text-small text-faint", children: time })] }));
|
|
22
25
|
}
|
|
23
26
|
return (_jsxs("div", { "data-slot": "message", "data-from": from, className: cn("flex gap-2.5 self-stretch", className), ...props, children: [avatar && _jsx("div", { className: "shrink-0 pt-0.5", children: avatar }), _jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-space-6", children: [trace, _jsx("div", { className: "flex flex-col gap-space-6 text-body text-ink-2 [&_p]:m-0", children: children }), (actions || time) && (_jsxs("div", { className: "-ml-1 flex items-center gap-0.5 text-small text-faint", children: [actions, time && _jsx("span", { className: "ml-1", children: time })] }))] })] }));
|
|
24
27
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message.js","sourceRoot":"","sources":["../../src/components/message.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAGb,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAElC,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,8DAA8D;IAC9D,IAAI,EAAE,MAAM;IACZ,sEAAsE;IACtE,KAAK,EAAE,OAAO;CACN,CAAC;AA6BX,MAAM,qBAAqB,GACzB,sHAAsH,CAAC;AAEzH,MAAM,cAAc,GAClB,
|
|
1
|
+
{"version":3,"file":"message.js","sourceRoot":"","sources":["../../src/components/message.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAGb,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAElC,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,8DAA8D;IAC9D,IAAI,EAAE,MAAM;IACZ,sEAAsE;IACtE,KAAK,EAAE,OAAO;CACN,CAAC;AA6BX,MAAM,qBAAqB,GACzB,sHAAsH,CAAC;AAEzH,MAAM,cAAc,GAClB,sGAAsG,CAAC;AAEzG;;;GAGG;AACH,MAAM,UAAU,OAAO,CAAC,EACtB,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,MAAM,EACN,OAAO,EACP,SAAS,EACT,IAAI,EACJ,MAAM,GAAG,KAAK,EACd,MAAM,GAAG,KAAK,EACd,MAAM,EACN,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,GAAG,KAAK,EACK;IACb,IAAI,IAAI,KAAK,eAAe,CAAC,IAAI,EAAE,CAA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S,EAAE,EAAE,CAAC,2BAA2B,EAAE,SAAS,CAAC,KAAM,KAAK,aACvG,MAAM,IAAI,cAAK,SAAS,EAAC,iBAAiB,YAAE,MAAM,GAAO,EAC1D,eAAK,SAAS,EAAC,0CAA0C,aACtD,KAAK,EACN,cAAK,SAAS,EAAC,0DAA0D,YAAE,QAAQ,GAAO,EACzF,CAAC,OAAO,IAAI,IAAI,CAAC,IAAI,CACpB,eAAK,SAAS,EAAC,uDAAuD,aACnE,OAAO,EACP,IAAI,IAAI,eAAM,SAAS,EAAC,MAAM,YAAE,IAAI,GAAQ,IACzC,CACP,IACG,IACF,CACP,CAAC;AACJ,CAAC","sourcesContent":["\"use client\";\n\nimport type { ComponentProps, ReactNode } from \"react\";\nimport { cn } from \"../lib/cn.ts\";\n\nexport const MESSAGE_AUTHORS = {\n /** The person: a right-aligned bubble with the time below. */\n USER: \"user\",\n /** Major: plain text in `ink-2`, no bubble, preceded by its Trace. */\n AGENT: \"agent\",\n} as const;\n\nexport type MessageAuthor = (typeof MESSAGE_AUTHORS)[keyof typeof MESSAGE_AUTHORS];\n\nexport interface MessageProps extends Omit<ComponentProps<\"div\">, \"title\"> {\n /** Who wrote it. The person gets a right-aligned bubble; the agent replies in plain text. */\n from: MessageAuthor;\n /** Time under the person's bubble, or after the agent's actions (\"9:45am\"). */\n time?: ReactNode;\n /** The agent's Trace, shown above its reply. */\n trace?: ReactNode;\n /** Optional avatar before the agent's reply (most chats don't show one). */\n avatar?: ReactNode;\n /** Actions under the reply (Copy, Try again): ghost `icon-sm` Buttons with a Tooltip. */\n actions?: ReactNode;\n /** On the person's bubble's corner, like a tapback: the emoji Major reacted with. */\n reactions?: ReactNode;\n /** Before the time under the person's bubble: where it was sent from (a 12px Slack or Teams mark). */\n meta?: ReactNode;\n /** The agent's reply in a bubble, like a text message: a reply delivered in a conversation (Pepper over Slack). */\n bubble?: boolean;\n /** The person's message waits until Major finishes: dimmed, with “Queued” under it. */\n queued?: boolean;\n /** With `queued`: Edit under the bubble, which puts the message back in the Composer. */\n onEdit?: () => void;\n /** With `queued`: Cancel under the bubble, which drops the message. */\n onCancel?: () => void;\n}\n\nconst QUEUED_ACTION_CLASSES =\n \"cursor-pointer rounded-xs italic underline outline-none hover:text-ink focus-visible:ring-2 focus-visible:ring-faint\";\n\nconst BUBBLE_CLASSES =\n \"relative rounded-lg px-space-10 py-1.75 text-body leading-5 break-words whitespace-pre-wrap text-ink\";\n\n/**\n * One turn in the chat panel. Stack turns with a 12px gap (`flex flex-col gap-space-12`), and keep 32px between the\n * last message and the Composer.\n */\nexport function Message({\n from,\n time,\n trace,\n avatar,\n actions,\n reactions,\n meta,\n bubble = false,\n queued = false,\n onEdit,\n onCancel,\n className,\n children,\n ...props\n}: MessageProps) {\n if (from === MESSAGE_AUTHORS.USER) {\n return (\n <div\n data-slot=\"message\"\n data-from={from}\n className={cn(\n // A share of the conversation's width, not a fixed one: the two sides overlap, as in any messenger, and\n // never split a wide page into halves. As wide as the bubble and pushed right, in a flex column or a block.\n \"ml-auto flex w-fit max-w-4/5 flex-col items-end gap-space-4 self-end\",\n reactions && \"pt-4\",\n queued && \"opacity-60\",\n className,\n )}\n {...props}\n >\n <div className={cn(BUBBLE_CLASSES, \"border border-line bg-bubble\")}>\n {reactions && (\n <div\n data-slot=\"message-reactions\"\n className=\"absolute -top-3.5 -left-3.5 flex items-center gap-0.5 rounded-full border border-line bg-surface px-space-8 text-editor-body leading-7 shadow-card\"\n >\n {reactions}\n </div>\n )}\n {children}\n </div>\n {(meta || time || queued) && (\n <div className=\"flex items-center gap-space-8 px-space-4 text-small text-faint\">\n {meta}\n {queued && (\n <span data-slot=\"message-queued\" className=\"flex items-center gap-1.5 text-muted\">\n <span className=\"italic\">Queued</span>\n {onEdit && (\n <button type=\"button\" onClick={onEdit} className={QUEUED_ACTION_CLASSES}>\n Edit\n </button>\n )}\n {onCancel && (\n <button type=\"button\" onClick={onCancel} className={QUEUED_ACTION_CLASSES}>\n Cancel\n </button>\n )}\n </span>\n )}\n {time && <span>{time}</span>}\n </div>\n )}\n </div>\n );\n }\n\n if (bubble) {\n return (\n <div\n data-slot=\"message\"\n data-from={from}\n className={cn(\"flex w-fit max-w-17/20 flex-col items-start gap-space-4 self-start\", className)}\n {...props}\n >\n <div className={cn(BUBBLE_CLASSES, \"bg-secondary\")}>{children}</div>\n {time && <span className=\"px-space-4 text-small text-faint\">{time}</span>}\n </div>\n );\n }\n\n return (\n <div data-slot=\"message\" data-from={from} className={cn(\"flex gap-2.5 self-stretch\", className)} {...props}>\n {avatar && <div className=\"shrink-0 pt-0.5\">{avatar}</div>}\n <div className=\"flex min-w-0 flex-1 flex-col gap-space-6\">\n {trace}\n <div className=\"flex flex-col gap-space-6 text-body text-ink-2 [&_p]:m-0\">{children}</div>\n {(actions || time) && (\n <div className=\"-ml-1 flex items-center gap-0.5 text-small text-faint\">\n {actions}\n {time && <span className=\"ml-1\">{time}</span>}\n </div>\n )}\n </div>\n </div>\n );\n}\n"]}
|
|
@@ -280,4 +280,5 @@ import { EditorTabs } from "@major-tech/ui/editor-tabs";
|
|
|
280
280
|
- The unsaved dot is announced as “Unsaved changes”.
|
|
281
281
|
- With `onReorder`, Alt+Shift+← / → moves the focused tab and keeps focus on it; each tab names the keys in `aria-keyshortcuts`.
|
|
282
282
|
- The arrows are named “Scroll tabs left” and “Scroll tabs right”. Keyboard focus scrolls the strip by itself.
|
|
283
|
+
- The focus ring is drawn inside the tab: the strip scrolls, and it would cut off a ring outside.
|
|
283
284
|
- Tabs opening, closing and making room animate only without `prefers-reduced-motion`.
|
|
@@ -86,7 +86,7 @@ export default function ChatConversation() {
|
|
|
86
86
|
}
|
|
87
87
|
```
|
|
88
88
|
|
|
89
|
-
- **The person**: a bubble fill with a line border, rounded-lg, 14/20, at most
|
|
89
|
+
- **The person**: a bubble fill with a line border, rounded-lg, 14/20, at most 80% of the conversation's width; the time below in faint 12px.
|
|
90
90
|
- **The agent**: ink-2 body text (14/21), no bubble, left-aligned, its Trace above.
|
|
91
91
|
- 12px between messages; 32px between the last message and the Composer.
|
|
92
92
|
|
|
@@ -121,7 +121,7 @@ export default function MessageConversationOverSlack() {
|
|
|
121
121
|
|
|
122
122
|
- **reactions**: the emoji Major reacted with, on the person's bubble's corner like a tapback.
|
|
123
123
|
- **meta**: before the time under the bubble, where it was sent from: a 12px Slack or Teams mark.
|
|
124
|
-
- **bubble**: Major's delivered reply in a bubble too, on the left in `secondary`, as the other app shows it.
|
|
124
|
+
- **bubble**: Major's delivered reply in a bubble too, on the left in `secondary`, as the other app shows it, at most 85% wide. The two sides overlap rather than split a wide conversation in half.
|
|
125
125
|
|
|
126
126
|
### Replies with cards and actions
|
|
127
127
|
|
|
@@ -326,6 +326,7 @@ Also accepts `<div>` attributes, and a ref to the root element.
|
|
|
326
326
|
| `queued` | `boolean` | `false` | The person's message waits until Major finishes: dimmed, “Queued” under it. |
|
|
327
327
|
| `onEdit` | `() => void` | — | With `queued`: Edit, which puts the message back in the Composer. |
|
|
328
328
|
| `onCancel` | `() => void` | — | With `queued`: Cancel, which drops the message. |
|
|
329
|
+
| `className` | `string` | — | On the root, which holds a bubble's width: `max-w-full` or any `max-w-*` replaces its 80% (85% for Major's). |
|
|
329
330
|
|
|
330
331
|
`*` marks a required prop.
|
|
331
332
|
|