@major-tech/ui 1.0.1 → 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
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
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
|
+
|
|
3
9
|
## 1.0.1
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -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,CAAC,EAAE,SAAS,CAAC;IACnB,yFAAyF;IACzF,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,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,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,CAAC;QAClC,OAAO,CACL,4BACY,SAAS,eACR,IAAI,EACf,SAAS,EAAE,EAAE;YACX,wGAAwG;YACxG,4GAA4G;YAC5G,sEAAsE,EACtE,SAAS,IAAI,MAAM,EACnB,MAAM,IAAI,YAAY,EACtB,SAAS,CACV,KACG,KAAK,aAET,eAAK,SAAS,EAAE,E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Q,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"]}
|
|
@@ -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
|
|