@designa8/vibedesign-tinkerly-dryrun-ds-176b 0.0.3 → 0.0.4
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/README.md +1 -1
- package/dist/index.cjs +157 -4
- package/dist/index.js +157 -4
- package/dist/styles.css +6 -3
- package/package.json +1 -1
- package/src/atoms/Icon/icons.data.ts +2 -0
- package/src/organisms/ChatWindow/ChatWindow.tsx +285 -74
- package/src/organisms/ChatWindow/preview.tsx +115 -101
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @designa8/vibedesign-tinkerly-dryrun-ds-176b
|
|
2
2
|
|
|
3
|
-
Complete design system generated by Atoms Design, version **0.0.
|
|
3
|
+
Complete design system generated by Atoms Design, version **0.0.4**.
|
|
4
4
|
Tokens, atoms, molecules, organisms, and templates — import from the package root;
|
|
5
5
|
never hardcode visual values in consumer code.
|
|
6
6
|
|
package/dist/index.cjs
CHANGED
|
@@ -249,7 +249,9 @@ var ICON_REGISTRY = {
|
|
|
249
249
|
"trending-down": { viewBox: "0 0 24 24", nodes: [{ tag: "path", d: "M16 17h6v-6" }, { tag: "path", d: "m22 17-8.5-8.5-5 5L2 7" }] },
|
|
250
250
|
"circle-dashed": { viewBox: "0 0 24 24", nodes: [{ tag: "path", d: "M10.1 2.182a10 10 0 0 1 3.8 0" }, { tag: "path", d: "M13.9 21.818a10 10 0 0 1-3.8 0" }, { tag: "path", d: "M17.609 3.721a10 10 0 0 1 2.69 2.7" }, { tag: "path", d: "M2.182 13.9a10 10 0 0 1 0-3.8" }, { tag: "path", d: "M20.279 17.609a10 10 0 0 1-2.7 2.69" }, { tag: "path", d: "M21.818 10.1a10 10 0 0 1 0 3.8" }, { tag: "path", d: "M3.721 6.391a10 10 0 0 1 2.7-2.69" }, { tag: "path", d: "M6.391 20.279a10 10 0 0 1-2.69-2.7" }] },
|
|
251
251
|
"calendar-days": { viewBox: "0 0 24 24", nodes: [{ tag: "path", d: "M8 2v4" }, { tag: "path", d: "M16 2v4" }, { tag: "rect", width: "18", height: "18", x: "3", y: "4", rx: "2" }, { tag: "path", d: "M3 10h18" }, { tag: "path", d: "M8 14h.01" }, { tag: "path", d: "M12 14h.01" }, { tag: "path", d: "M16 14h.01" }, { tag: "path", d: "M8 18h.01" }, { tag: "path", d: "M12 18h.01" }, { tag: "path", d: "M16 18h.01" }] },
|
|
252
|
-
"milestone": { viewBox: "0 0 24 24", nodes: [{ tag: "path", d: "M12 13v8" }, { tag: "path", d: "M12 3v3" }, { tag: "path", d: "M4 6a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1h13a2 2 0 0 0 1.152-.365l3.424-2.317a1 1 0 0 0 0-1.635l-3.424-2.318A2 2 0 0 0 17 6z" }] }
|
|
252
|
+
"milestone": { viewBox: "0 0 24 24", nodes: [{ tag: "path", d: "M12 13v8" }, { tag: "path", d: "M12 3v3" }, { tag: "path", d: "M4 6a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1h13a2 2 0 0 0 1.152-.365l3.424-2.317a1 1 0 0 0 0-1.635l-3.424-2.318A2 2 0 0 0 17 6z" }] },
|
|
253
|
+
"quote": { viewBox: "0 0 24 24", nodes: [{ tag: "path", d: "M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z" }, { tag: "path", d: "M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z" }] },
|
|
254
|
+
"brain": { viewBox: "0 0 24 24", nodes: [{ tag: "path", d: "M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z" }, { tag: "path", d: "M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z" }, { tag: "path", d: "M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4" }, { tag: "path", d: "M17.599 6.5a3 3 0 0 0 .399-1.375" }, { tag: "path", d: "M6.003 5.125A3 3 0 0 0 6.401 6.5" }, { tag: "path", d: "M3.477 10.896a4 4 0 0 1 .585-.396" }, { tag: "path", d: "M19.938 10.5a4 4 0 0 1 .585.396" }, { tag: "path", d: "M6 18a4 4 0 0 1-1.967-.516" }, { tag: "path", d: "M19.967 17.484A4 4 0 0 1 18 18" }] }
|
|
253
255
|
};
|
|
254
256
|
|
|
255
257
|
// virtual-pkg:src/atoms/Icon/Icon.tsx
|
|
@@ -7623,6 +7625,7 @@ var ASSISTANT_ACTIONS = [
|
|
|
7623
7625
|
{ action: "copy", icon: "copy", label: "Copy message" },
|
|
7624
7626
|
{ action: "more", icon: "ellipsis", label: "More options" }
|
|
7625
7627
|
];
|
|
7628
|
+
var MAX_COMPOSER_ROWS = 6;
|
|
7626
7629
|
var ChatWindow = React49.forwardRef(
|
|
7627
7630
|
({
|
|
7628
7631
|
variant = "channel",
|
|
@@ -7639,11 +7642,20 @@ var ChatWindow = React49.forwardRef(
|
|
|
7639
7642
|
onStartCall,
|
|
7640
7643
|
onOpenChannelMenu,
|
|
7641
7644
|
onMessageAction,
|
|
7645
|
+
suggestions = [],
|
|
7646
|
+
onSuggestion,
|
|
7647
|
+
composerContext,
|
|
7648
|
+
composerPlaceholder = "Ask anything",
|
|
7649
|
+
composerTools = [],
|
|
7650
|
+
composerModes = [],
|
|
7651
|
+
mode,
|
|
7652
|
+
onChange: _ignoredOnChange,
|
|
7642
7653
|
className,
|
|
7643
7654
|
...rest
|
|
7644
7655
|
}, ref) => {
|
|
7645
7656
|
const [draft, setDraft] = React49.useState(defaultDraft);
|
|
7646
7657
|
const [reactions, setReactions] = React49.useState({});
|
|
7658
|
+
const [selectedMode, setSelectedMode] = React49.useState("");
|
|
7647
7659
|
const isAssistant = variant === "assistant";
|
|
7648
7660
|
const heading = (isAssistant ? title ?? channelName : channelName) || channelName;
|
|
7649
7661
|
const threadLabel = "Conversation in " + heading;
|
|
@@ -7667,12 +7679,36 @@ var ChatWindow = React49.forwardRef(
|
|
|
7667
7679
|
[message.id]: !isReacted(message)
|
|
7668
7680
|
}));
|
|
7669
7681
|
};
|
|
7670
|
-
const
|
|
7671
|
-
event.preventDefault();
|
|
7682
|
+
const sendDraft = () => {
|
|
7672
7683
|
if (!hasDraft) return;
|
|
7673
7684
|
onSend?.(draft.trim());
|
|
7674
7685
|
setDraft("");
|
|
7675
7686
|
};
|
|
7687
|
+
const submit = (event) => {
|
|
7688
|
+
event.preventDefault();
|
|
7689
|
+
sendDraft();
|
|
7690
|
+
};
|
|
7691
|
+
const fieldRef = React49.useRef(null);
|
|
7692
|
+
React49.useEffect(() => {
|
|
7693
|
+
const element = fieldRef.current;
|
|
7694
|
+
if (!element || !isAssistant) return;
|
|
7695
|
+
element.style.height = "auto";
|
|
7696
|
+
const lineHeight = Number.parseFloat(window.getComputedStyle(element).lineHeight) || 22;
|
|
7697
|
+
const maxHeight = lineHeight * MAX_COMPOSER_ROWS;
|
|
7698
|
+
element.style.height = Math.min(element.scrollHeight, maxHeight) + "px";
|
|
7699
|
+
element.style.overflowY = element.scrollHeight > maxHeight ? "auto" : "hidden";
|
|
7700
|
+
}, [draft, isAssistant]);
|
|
7701
|
+
const onComposerKeyDown = (event) => {
|
|
7702
|
+
if (event.key === "Enter" && !event.shiftKey) {
|
|
7703
|
+
event.preventDefault();
|
|
7704
|
+
sendDraft();
|
|
7705
|
+
}
|
|
7706
|
+
};
|
|
7707
|
+
const resolvedMode = mode ?? (selectedMode || composerModes[0]?.value || "");
|
|
7708
|
+
const chooseMode = (next) => {
|
|
7709
|
+
if (mode === void 0) setSelectedMode(next);
|
|
7710
|
+
onModeChange?.(next);
|
|
7711
|
+
};
|
|
7676
7712
|
const threadRef = React49.useRef(null);
|
|
7677
7713
|
const [showJump, setShowJump] = React49.useState(false);
|
|
7678
7714
|
const measureJump = React49.useCallback(() => {
|
|
@@ -7917,7 +7953,124 @@ var ChatWindow = React49.forwardRef(
|
|
|
7917
7953
|
}
|
|
7918
7954
|
) }) : null
|
|
7919
7955
|
] }),
|
|
7920
|
-
/* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(
|
|
7956
|
+
isAssistant ? /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("div", { className: "flex shrink-0 flex-col gap-sm px-base pb-base pt-sm", children: [
|
|
7957
|
+
suggestions.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("div", { className: "flex flex-wrap items-center gap-xs", children: suggestions.map((suggestion) => /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
7958
|
+
Button,
|
|
7959
|
+
{
|
|
7960
|
+
variant: "secondary",
|
|
7961
|
+
size: "sm",
|
|
7962
|
+
onClick: () => onSuggestion?.(suggestion),
|
|
7963
|
+
children: suggestion
|
|
7964
|
+
},
|
|
7965
|
+
suggestion
|
|
7966
|
+
)) }) : null,
|
|
7967
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(
|
|
7968
|
+
"form",
|
|
7969
|
+
{
|
|
7970
|
+
onSubmit: submit,
|
|
7971
|
+
className: cn33(
|
|
7972
|
+
"flex w-full flex-col gap-xs rounded-xl border border-hairline bg-surface p-sm shadow-sm",
|
|
7973
|
+
"transition duration-150 ease-out",
|
|
7974
|
+
"hover:border-hairline-strong focus-within:border-focus-blue"
|
|
7975
|
+
),
|
|
7976
|
+
children: [
|
|
7977
|
+
composerContext && (composerContext.backLabel || composerContext.activeLabel) ? /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("div", { className: "flex flex-col items-start gap-xs border-b border-hairline pb-sm", children: [
|
|
7978
|
+
composerContext.backLabel ? /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
7979
|
+
Button,
|
|
7980
|
+
{
|
|
7981
|
+
variant: "ghost",
|
|
7982
|
+
size: "sm",
|
|
7983
|
+
justify: "start",
|
|
7984
|
+
leadingIcon: "arrow-left",
|
|
7985
|
+
onClick: composerContext.onBack,
|
|
7986
|
+
labelClassName: "text-muted",
|
|
7987
|
+
children: composerContext.backLabel
|
|
7988
|
+
}
|
|
7989
|
+
) : null,
|
|
7990
|
+
composerContext.activeLabel ? /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
7991
|
+
Button,
|
|
7992
|
+
{
|
|
7993
|
+
variant: "soft",
|
|
7994
|
+
size: "sm",
|
|
7995
|
+
fullWidth: true,
|
|
7996
|
+
justify: "start",
|
|
7997
|
+
leadingIcon: composerContext.activeIcon,
|
|
7998
|
+
children: composerContext.activeLabel
|
|
7999
|
+
}
|
|
8000
|
+
) : null
|
|
8001
|
+
] }) : null,
|
|
8002
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
8003
|
+
Textarea,
|
|
8004
|
+
{
|
|
8005
|
+
ref: fieldRef,
|
|
8006
|
+
chrome: "none",
|
|
8007
|
+
size: "md",
|
|
8008
|
+
rows: 1,
|
|
8009
|
+
value: draft,
|
|
8010
|
+
onChange: (event) => setDraft(event.target.value),
|
|
8011
|
+
onKeyDown: onComposerKeyDown,
|
|
8012
|
+
placeholder: composerPlaceholder,
|
|
8013
|
+
"aria-label": composerPlaceholder,
|
|
8014
|
+
wrapperClassName: "min-w-0",
|
|
8015
|
+
className: "min-h-0! resize-none px-0! py-0! text-body-md"
|
|
8016
|
+
}
|
|
8017
|
+
),
|
|
8018
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("div", { className: "flex flex-wrap items-center gap-xs", children: [
|
|
8019
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
8020
|
+
IconButton,
|
|
8021
|
+
{
|
|
8022
|
+
icon: "plus",
|
|
8023
|
+
label: "Attach to the message",
|
|
8024
|
+
variant: "outline",
|
|
8025
|
+
size: "sm",
|
|
8026
|
+
shape: "circle"
|
|
8027
|
+
}
|
|
8028
|
+
),
|
|
8029
|
+
composerTools.map((tool) => /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
8030
|
+
Button,
|
|
8031
|
+
{
|
|
8032
|
+
variant: "outline",
|
|
8033
|
+
size: "sm",
|
|
8034
|
+
leadingIcon: tool.icon,
|
|
8035
|
+
children: tool.label
|
|
8036
|
+
},
|
|
8037
|
+
tool.value
|
|
8038
|
+
)),
|
|
8039
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("div", { className: "ml-auto flex items-center gap-xxs", children: [
|
|
8040
|
+
composerModes.map((item) => {
|
|
8041
|
+
const active = item.value === resolvedMode;
|
|
8042
|
+
return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
8043
|
+
Button,
|
|
8044
|
+
{
|
|
8045
|
+
variant: active ? "soft" : "ghost",
|
|
8046
|
+
size: "sm",
|
|
8047
|
+
leadingIcon: item.icon,
|
|
8048
|
+
"aria-pressed": active,
|
|
8049
|
+
onClick: () => chooseMode(item.value),
|
|
8050
|
+
children: item.label
|
|
8051
|
+
},
|
|
8052
|
+
item.value
|
|
8053
|
+
);
|
|
8054
|
+
}),
|
|
8055
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
8056
|
+
IconButton,
|
|
8057
|
+
{
|
|
8058
|
+
icon: "arrow-up",
|
|
8059
|
+
label: "Send message",
|
|
8060
|
+
variant: "primary",
|
|
8061
|
+
size: "sm",
|
|
8062
|
+
shape: "circle",
|
|
8063
|
+
type: "submit",
|
|
8064
|
+
disabled: !hasDraft,
|
|
8065
|
+
className: "ml-xxs"
|
|
8066
|
+
}
|
|
8067
|
+
)
|
|
8068
|
+
] })
|
|
8069
|
+
] })
|
|
8070
|
+
]
|
|
8071
|
+
}
|
|
8072
|
+
)
|
|
8073
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(
|
|
7921
8074
|
"form",
|
|
7922
8075
|
{
|
|
7923
8076
|
onSubmit: submit,
|
package/dist/index.js
CHANGED
|
@@ -124,7 +124,9 @@ var ICON_REGISTRY = {
|
|
|
124
124
|
"trending-down": { viewBox: "0 0 24 24", nodes: [{ tag: "path", d: "M16 17h6v-6" }, { tag: "path", d: "m22 17-8.5-8.5-5 5L2 7" }] },
|
|
125
125
|
"circle-dashed": { viewBox: "0 0 24 24", nodes: [{ tag: "path", d: "M10.1 2.182a10 10 0 0 1 3.8 0" }, { tag: "path", d: "M13.9 21.818a10 10 0 0 1-3.8 0" }, { tag: "path", d: "M17.609 3.721a10 10 0 0 1 2.69 2.7" }, { tag: "path", d: "M2.182 13.9a10 10 0 0 1 0-3.8" }, { tag: "path", d: "M20.279 17.609a10 10 0 0 1-2.7 2.69" }, { tag: "path", d: "M21.818 10.1a10 10 0 0 1 0 3.8" }, { tag: "path", d: "M3.721 6.391a10 10 0 0 1 2.7-2.69" }, { tag: "path", d: "M6.391 20.279a10 10 0 0 1-2.69-2.7" }] },
|
|
126
126
|
"calendar-days": { viewBox: "0 0 24 24", nodes: [{ tag: "path", d: "M8 2v4" }, { tag: "path", d: "M16 2v4" }, { tag: "rect", width: "18", height: "18", x: "3", y: "4", rx: "2" }, { tag: "path", d: "M3 10h18" }, { tag: "path", d: "M8 14h.01" }, { tag: "path", d: "M12 14h.01" }, { tag: "path", d: "M16 14h.01" }, { tag: "path", d: "M8 18h.01" }, { tag: "path", d: "M12 18h.01" }, { tag: "path", d: "M16 18h.01" }] },
|
|
127
|
-
"milestone": { viewBox: "0 0 24 24", nodes: [{ tag: "path", d: "M12 13v8" }, { tag: "path", d: "M12 3v3" }, { tag: "path", d: "M4 6a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1h13a2 2 0 0 0 1.152-.365l3.424-2.317a1 1 0 0 0 0-1.635l-3.424-2.318A2 2 0 0 0 17 6z" }] }
|
|
127
|
+
"milestone": { viewBox: "0 0 24 24", nodes: [{ tag: "path", d: "M12 13v8" }, { tag: "path", d: "M12 3v3" }, { tag: "path", d: "M4 6a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1h13a2 2 0 0 0 1.152-.365l3.424-2.317a1 1 0 0 0 0-1.635l-3.424-2.318A2 2 0 0 0 17 6z" }] },
|
|
128
|
+
"quote": { viewBox: "0 0 24 24", nodes: [{ tag: "path", d: "M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z" }, { tag: "path", d: "M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z" }] },
|
|
129
|
+
"brain": { viewBox: "0 0 24 24", nodes: [{ tag: "path", d: "M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z" }, { tag: "path", d: "M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z" }, { tag: "path", d: "M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4" }, { tag: "path", d: "M17.599 6.5a3 3 0 0 0 .399-1.375" }, { tag: "path", d: "M6.003 5.125A3 3 0 0 0 6.401 6.5" }, { tag: "path", d: "M3.477 10.896a4 4 0 0 1 .585-.396" }, { tag: "path", d: "M19.938 10.5a4 4 0 0 1 .585.396" }, { tag: "path", d: "M6 18a4 4 0 0 1-1.967-.516" }, { tag: "path", d: "M19.967 17.484A4 4 0 0 1 18 18" }] }
|
|
128
130
|
};
|
|
129
131
|
|
|
130
132
|
// virtual-pkg:src/atoms/Icon/Icon.tsx
|
|
@@ -7498,6 +7500,7 @@ var ASSISTANT_ACTIONS = [
|
|
|
7498
7500
|
{ action: "copy", icon: "copy", label: "Copy message" },
|
|
7499
7501
|
{ action: "more", icon: "ellipsis", label: "More options" }
|
|
7500
7502
|
];
|
|
7503
|
+
var MAX_COMPOSER_ROWS = 6;
|
|
7501
7504
|
var ChatWindow = React49.forwardRef(
|
|
7502
7505
|
({
|
|
7503
7506
|
variant = "channel",
|
|
@@ -7514,11 +7517,20 @@ var ChatWindow = React49.forwardRef(
|
|
|
7514
7517
|
onStartCall,
|
|
7515
7518
|
onOpenChannelMenu,
|
|
7516
7519
|
onMessageAction,
|
|
7520
|
+
suggestions = [],
|
|
7521
|
+
onSuggestion,
|
|
7522
|
+
composerContext,
|
|
7523
|
+
composerPlaceholder = "Ask anything",
|
|
7524
|
+
composerTools = [],
|
|
7525
|
+
composerModes = [],
|
|
7526
|
+
mode,
|
|
7527
|
+
onChange: _ignoredOnChange,
|
|
7517
7528
|
className,
|
|
7518
7529
|
...rest
|
|
7519
7530
|
}, ref) => {
|
|
7520
7531
|
const [draft, setDraft] = React49.useState(defaultDraft);
|
|
7521
7532
|
const [reactions, setReactions] = React49.useState({});
|
|
7533
|
+
const [selectedMode, setSelectedMode] = React49.useState("");
|
|
7522
7534
|
const isAssistant = variant === "assistant";
|
|
7523
7535
|
const heading = (isAssistant ? title ?? channelName : channelName) || channelName;
|
|
7524
7536
|
const threadLabel = "Conversation in " + heading;
|
|
@@ -7542,12 +7554,36 @@ var ChatWindow = React49.forwardRef(
|
|
|
7542
7554
|
[message.id]: !isReacted(message)
|
|
7543
7555
|
}));
|
|
7544
7556
|
};
|
|
7545
|
-
const
|
|
7546
|
-
event.preventDefault();
|
|
7557
|
+
const sendDraft = () => {
|
|
7547
7558
|
if (!hasDraft) return;
|
|
7548
7559
|
onSend?.(draft.trim());
|
|
7549
7560
|
setDraft("");
|
|
7550
7561
|
};
|
|
7562
|
+
const submit = (event) => {
|
|
7563
|
+
event.preventDefault();
|
|
7564
|
+
sendDraft();
|
|
7565
|
+
};
|
|
7566
|
+
const fieldRef = React49.useRef(null);
|
|
7567
|
+
React49.useEffect(() => {
|
|
7568
|
+
const element = fieldRef.current;
|
|
7569
|
+
if (!element || !isAssistant) return;
|
|
7570
|
+
element.style.height = "auto";
|
|
7571
|
+
const lineHeight = Number.parseFloat(window.getComputedStyle(element).lineHeight) || 22;
|
|
7572
|
+
const maxHeight = lineHeight * MAX_COMPOSER_ROWS;
|
|
7573
|
+
element.style.height = Math.min(element.scrollHeight, maxHeight) + "px";
|
|
7574
|
+
element.style.overflowY = element.scrollHeight > maxHeight ? "auto" : "hidden";
|
|
7575
|
+
}, [draft, isAssistant]);
|
|
7576
|
+
const onComposerKeyDown = (event) => {
|
|
7577
|
+
if (event.key === "Enter" && !event.shiftKey) {
|
|
7578
|
+
event.preventDefault();
|
|
7579
|
+
sendDraft();
|
|
7580
|
+
}
|
|
7581
|
+
};
|
|
7582
|
+
const resolvedMode = mode ?? (selectedMode || composerModes[0]?.value || "");
|
|
7583
|
+
const chooseMode = (next) => {
|
|
7584
|
+
if (mode === void 0) setSelectedMode(next);
|
|
7585
|
+
onModeChange?.(next);
|
|
7586
|
+
};
|
|
7551
7587
|
const threadRef = React49.useRef(null);
|
|
7552
7588
|
const [showJump, setShowJump] = React49.useState(false);
|
|
7553
7589
|
const measureJump = React49.useCallback(() => {
|
|
@@ -7792,7 +7828,124 @@ var ChatWindow = React49.forwardRef(
|
|
|
7792
7828
|
}
|
|
7793
7829
|
) }) : null
|
|
7794
7830
|
] }),
|
|
7795
|
-
/* @__PURE__ */ jsxs46(
|
|
7831
|
+
isAssistant ? /* @__PURE__ */ jsxs46("div", { className: "flex shrink-0 flex-col gap-sm px-base pb-base pt-sm", children: [
|
|
7832
|
+
suggestions.length > 0 ? /* @__PURE__ */ jsx49("div", { className: "flex flex-wrap items-center gap-xs", children: suggestions.map((suggestion) => /* @__PURE__ */ jsx49(
|
|
7833
|
+
Button,
|
|
7834
|
+
{
|
|
7835
|
+
variant: "secondary",
|
|
7836
|
+
size: "sm",
|
|
7837
|
+
onClick: () => onSuggestion?.(suggestion),
|
|
7838
|
+
children: suggestion
|
|
7839
|
+
},
|
|
7840
|
+
suggestion
|
|
7841
|
+
)) }) : null,
|
|
7842
|
+
/* @__PURE__ */ jsxs46(
|
|
7843
|
+
"form",
|
|
7844
|
+
{
|
|
7845
|
+
onSubmit: submit,
|
|
7846
|
+
className: cn33(
|
|
7847
|
+
"flex w-full flex-col gap-xs rounded-xl border border-hairline bg-surface p-sm shadow-sm",
|
|
7848
|
+
"transition duration-150 ease-out",
|
|
7849
|
+
"hover:border-hairline-strong focus-within:border-focus-blue"
|
|
7850
|
+
),
|
|
7851
|
+
children: [
|
|
7852
|
+
composerContext && (composerContext.backLabel || composerContext.activeLabel) ? /* @__PURE__ */ jsxs46("div", { className: "flex flex-col items-start gap-xs border-b border-hairline pb-sm", children: [
|
|
7853
|
+
composerContext.backLabel ? /* @__PURE__ */ jsx49(
|
|
7854
|
+
Button,
|
|
7855
|
+
{
|
|
7856
|
+
variant: "ghost",
|
|
7857
|
+
size: "sm",
|
|
7858
|
+
justify: "start",
|
|
7859
|
+
leadingIcon: "arrow-left",
|
|
7860
|
+
onClick: composerContext.onBack,
|
|
7861
|
+
labelClassName: "text-muted",
|
|
7862
|
+
children: composerContext.backLabel
|
|
7863
|
+
}
|
|
7864
|
+
) : null,
|
|
7865
|
+
composerContext.activeLabel ? /* @__PURE__ */ jsx49(
|
|
7866
|
+
Button,
|
|
7867
|
+
{
|
|
7868
|
+
variant: "soft",
|
|
7869
|
+
size: "sm",
|
|
7870
|
+
fullWidth: true,
|
|
7871
|
+
justify: "start",
|
|
7872
|
+
leadingIcon: composerContext.activeIcon,
|
|
7873
|
+
children: composerContext.activeLabel
|
|
7874
|
+
}
|
|
7875
|
+
) : null
|
|
7876
|
+
] }) : null,
|
|
7877
|
+
/* @__PURE__ */ jsx49(
|
|
7878
|
+
Textarea,
|
|
7879
|
+
{
|
|
7880
|
+
ref: fieldRef,
|
|
7881
|
+
chrome: "none",
|
|
7882
|
+
size: "md",
|
|
7883
|
+
rows: 1,
|
|
7884
|
+
value: draft,
|
|
7885
|
+
onChange: (event) => setDraft(event.target.value),
|
|
7886
|
+
onKeyDown: onComposerKeyDown,
|
|
7887
|
+
placeholder: composerPlaceholder,
|
|
7888
|
+
"aria-label": composerPlaceholder,
|
|
7889
|
+
wrapperClassName: "min-w-0",
|
|
7890
|
+
className: "min-h-0! resize-none px-0! py-0! text-body-md"
|
|
7891
|
+
}
|
|
7892
|
+
),
|
|
7893
|
+
/* @__PURE__ */ jsxs46("div", { className: "flex flex-wrap items-center gap-xs", children: [
|
|
7894
|
+
/* @__PURE__ */ jsx49(
|
|
7895
|
+
IconButton,
|
|
7896
|
+
{
|
|
7897
|
+
icon: "plus",
|
|
7898
|
+
label: "Attach to the message",
|
|
7899
|
+
variant: "outline",
|
|
7900
|
+
size: "sm",
|
|
7901
|
+
shape: "circle"
|
|
7902
|
+
}
|
|
7903
|
+
),
|
|
7904
|
+
composerTools.map((tool) => /* @__PURE__ */ jsx49(
|
|
7905
|
+
Button,
|
|
7906
|
+
{
|
|
7907
|
+
variant: "outline",
|
|
7908
|
+
size: "sm",
|
|
7909
|
+
leadingIcon: tool.icon,
|
|
7910
|
+
children: tool.label
|
|
7911
|
+
},
|
|
7912
|
+
tool.value
|
|
7913
|
+
)),
|
|
7914
|
+
/* @__PURE__ */ jsxs46("div", { className: "ml-auto flex items-center gap-xxs", children: [
|
|
7915
|
+
composerModes.map((item) => {
|
|
7916
|
+
const active = item.value === resolvedMode;
|
|
7917
|
+
return /* @__PURE__ */ jsx49(
|
|
7918
|
+
Button,
|
|
7919
|
+
{
|
|
7920
|
+
variant: active ? "soft" : "ghost",
|
|
7921
|
+
size: "sm",
|
|
7922
|
+
leadingIcon: item.icon,
|
|
7923
|
+
"aria-pressed": active,
|
|
7924
|
+
onClick: () => chooseMode(item.value),
|
|
7925
|
+
children: item.label
|
|
7926
|
+
},
|
|
7927
|
+
item.value
|
|
7928
|
+
);
|
|
7929
|
+
}),
|
|
7930
|
+
/* @__PURE__ */ jsx49(
|
|
7931
|
+
IconButton,
|
|
7932
|
+
{
|
|
7933
|
+
icon: "arrow-up",
|
|
7934
|
+
label: "Send message",
|
|
7935
|
+
variant: "primary",
|
|
7936
|
+
size: "sm",
|
|
7937
|
+
shape: "circle",
|
|
7938
|
+
type: "submit",
|
|
7939
|
+
disabled: !hasDraft,
|
|
7940
|
+
className: "ml-xxs"
|
|
7941
|
+
}
|
|
7942
|
+
)
|
|
7943
|
+
] })
|
|
7944
|
+
] })
|
|
7945
|
+
]
|
|
7946
|
+
}
|
|
7947
|
+
)
|
|
7948
|
+
] }) : /* @__PURE__ */ jsxs46(
|
|
7796
7949
|
"form",
|
|
7797
7950
|
{
|
|
7798
7951
|
onSubmit: submit,
|
package/dist/styles.css
CHANGED
|
@@ -786,6 +786,9 @@
|
|
|
786
786
|
.min-h-0 {
|
|
787
787
|
min-height: 0;
|
|
788
788
|
}
|
|
789
|
+
.min-h-0\! {
|
|
790
|
+
min-height: 0 !important;
|
|
791
|
+
}
|
|
789
792
|
.min-h-4 {
|
|
790
793
|
min-height: calc(var(--spacing) * 4);
|
|
791
794
|
}
|
|
@@ -1147,6 +1150,9 @@
|
|
|
1147
1150
|
.resize {
|
|
1148
1151
|
resize: both;
|
|
1149
1152
|
}
|
|
1153
|
+
.resize-none {
|
|
1154
|
+
resize: none;
|
|
1155
|
+
}
|
|
1150
1156
|
.snap-x {
|
|
1151
1157
|
scroll-snap-type: x var(--tw-scroll-snap-strictness);
|
|
1152
1158
|
}
|
|
@@ -1156,9 +1162,6 @@
|
|
|
1156
1162
|
.snap-start {
|
|
1157
1163
|
scroll-snap-align: start;
|
|
1158
1164
|
}
|
|
1159
|
-
.list-disc {
|
|
1160
|
-
list-style-type: disc;
|
|
1161
|
-
}
|
|
1162
1165
|
.list-none {
|
|
1163
1166
|
list-style-type: none;
|
|
1164
1167
|
}
|
package/package.json
CHANGED
|
@@ -124,6 +124,8 @@ export const ICON_REGISTRY = {
|
|
|
124
124
|
"circle-dashed": { viewBox: "0 0 24 24", nodes: [{ tag: "path", d: "M10.1 2.182a10 10 0 0 1 3.8 0" }, { tag: "path", d: "M13.9 21.818a10 10 0 0 1-3.8 0" }, { tag: "path", d: "M17.609 3.721a10 10 0 0 1 2.69 2.7" }, { tag: "path", d: "M2.182 13.9a10 10 0 0 1 0-3.8" }, { tag: "path", d: "M20.279 17.609a10 10 0 0 1-2.7 2.69" }, { tag: "path", d: "M21.818 10.1a10 10 0 0 1 0 3.8" }, { tag: "path", d: "M3.721 6.391a10 10 0 0 1 2.7-2.69" }, { tag: "path", d: "M6.391 20.279a10 10 0 0 1-2.69-2.7" }] },
|
|
125
125
|
"calendar-days": { viewBox: "0 0 24 24", nodes: [{ tag: "path", d: "M8 2v4" }, { tag: "path", d: "M16 2v4" }, { tag: "rect", width: "18", height: "18", x: "3", y: "4", rx: "2" }, { tag: "path", d: "M3 10h18" }, { tag: "path", d: "M8 14h.01" }, { tag: "path", d: "M12 14h.01" }, { tag: "path", d: "M16 14h.01" }, { tag: "path", d: "M8 18h.01" }, { tag: "path", d: "M12 18h.01" }, { tag: "path", d: "M16 18h.01" }] },
|
|
126
126
|
"milestone": { viewBox: "0 0 24 24", nodes: [{ tag: "path", d: "M12 13v8" }, { tag: "path", d: "M12 3v3" }, { tag: "path", d: "M4 6a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1h13a2 2 0 0 0 1.152-.365l3.424-2.317a1 1 0 0 0 0-1.635l-3.424-2.318A2 2 0 0 0 17 6z" }] },
|
|
127
|
+
"quote": { viewBox: "0 0 24 24", nodes: [{ tag: "path", d: "M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z" }, { tag: "path", d: "M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z" }] },
|
|
128
|
+
"brain": { viewBox: "0 0 24 24", nodes: [{ tag: "path", d: "M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z" }, { tag: "path", d: "M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z" }, { tag: "path", d: "M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4" }, { tag: "path", d: "M17.599 6.5a3 3 0 0 0 .399-1.375" }, { tag: "path", d: "M6.003 5.125A3 3 0 0 0 6.401 6.5" }, { tag: "path", d: "M3.477 10.896a4 4 0 0 1 .585-.396" }, { tag: "path", d: "M19.938 10.5a4 4 0 0 1 .585.396" }, { tag: "path", d: "M6 18a4 4 0 0 1-1.967-.516" }, { tag: "path", d: "M19.967 17.484A4 4 0 0 1 18 18" }] },
|
|
127
129
|
} satisfies Record<string, IconEntry>;
|
|
128
130
|
|
|
129
131
|
export type IconName = keyof typeof ICON_REGISTRY;
|
|
@@ -9,17 +9,25 @@ import type { IconName } from "../../atoms/Icon";
|
|
|
9
9
|
import { IconButton } from "../../atoms/IconButton";
|
|
10
10
|
import { Input } from "../../atoms/Input";
|
|
11
11
|
import { MenuItem } from "../../molecules/MenuItem";
|
|
12
|
+
import { Textarea } from "../../atoms/Textarea";
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* Which conversation surface this window paints.
|
|
15
16
|
*
|
|
16
17
|
* - `"channel"` (default) — a team channel: hash glyph, call / member / options
|
|
17
|
-
* actions in the header,
|
|
18
|
+
* actions in the header, an avatar + author + time stack per message, and a
|
|
19
|
+
* single-line input with a reveal-on-type action cluster at the bottom.
|
|
18
20
|
* - `"assistant"` — a helper thread inside a product workspace: a title with an
|
|
19
21
|
* optional disclosure chevron and a subtitle line plus ghost header actions,
|
|
20
22
|
* assistant replies as full-width prose with a compact action row, and user
|
|
21
|
-
* turns as a soft tinted bubble aligned right.
|
|
22
|
-
*
|
|
23
|
+
* turns as a soft tinted bubble aligned right. Pinned under the thread sits a
|
|
24
|
+
* composer card: optional suggestion buttons above it, optional context rows
|
|
25
|
+
* (a muted back link plus the active item as a soft row), a borderless
|
|
26
|
+
* multi-line field that grows from one to six rows, and a toolbar with an
|
|
27
|
+
* attach action, optional tool buttons, optional mode toggles and a circular
|
|
28
|
+
* send button that waits for a draft. Enter sends, Shift+Enter adds a line.
|
|
29
|
+
* A floating "scroll to latest" control appears above the composer once the
|
|
30
|
+
* thread is scrolled up.
|
|
23
31
|
*/
|
|
24
32
|
export type ChatWindowVariant = "channel" | "assistant";
|
|
25
33
|
|
|
@@ -62,6 +70,23 @@ export interface ChatWindowTitleMenuItem {
|
|
|
62
70
|
onSelect?: () => void;
|
|
63
71
|
}
|
|
64
72
|
|
|
73
|
+
/** The two optional rows that sit at the top of the assistant composer card. */
|
|
74
|
+
export interface ChatWindowComposerContext {
|
|
75
|
+
/** Small muted back affordance, rendered with a left arrow. */
|
|
76
|
+
backLabel?: string;
|
|
77
|
+
onBack?: () => void;
|
|
78
|
+
/** The item the composer is currently writing into. */
|
|
79
|
+
activeLabel?: string;
|
|
80
|
+
activeIcon?: IconName;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** A tool button or a mode toggle in the composer toolbar. */
|
|
84
|
+
export interface ChatWindowComposerItem {
|
|
85
|
+
value: string;
|
|
86
|
+
label: string;
|
|
87
|
+
icon?: IconName;
|
|
88
|
+
}
|
|
89
|
+
|
|
65
90
|
export interface ChatWindowProps
|
|
66
91
|
extends Omit<React.HTMLAttributes<HTMLDivElement>, "onSubmit" | "children"> {
|
|
67
92
|
/** Conversation surface — see `ChatWindowVariant`. Defaults to `"channel"`. */
|
|
@@ -86,6 +111,23 @@ export interface ChatWindowProps
|
|
|
86
111
|
onOpenChannelMenu?: () => void;
|
|
87
112
|
/** Assistant variant: a message action row was pressed. */
|
|
88
113
|
onMessageAction?: (id: string, action: ChatMessageAction) => void;
|
|
114
|
+
|
|
115
|
+
/** Assistant variant: starter prompts, as secondary buttons above the card. */
|
|
116
|
+
suggestions?: string[];
|
|
117
|
+
/** Assistant variant: a starter prompt was pressed. */
|
|
118
|
+
onSuggestion?: (suggestion: string) => void;
|
|
119
|
+
/** Assistant variant: back link and active item rows at the top of the card. */
|
|
120
|
+
composerContext?: ChatWindowComposerContext;
|
|
121
|
+
/** Assistant variant: the multi-line field's placeholder. */
|
|
122
|
+
composerPlaceholder?: string;
|
|
123
|
+
/** Assistant variant: outline tool buttons next to the attach action. */
|
|
124
|
+
composerTools?: ChatWindowComposerItem[];
|
|
125
|
+
/** Assistant variant: ghost mode toggles on the right of the toolbar. */
|
|
126
|
+
composerModes?: ChatWindowComposerItem[];
|
|
127
|
+
/** Assistant variant: the selected mode (controlled). */
|
|
128
|
+
mode?: string;
|
|
129
|
+
/** Assistant variant: a mode toggle was pressed. */
|
|
130
|
+
onModeChange?: (mode: string) => void;
|
|
89
131
|
}
|
|
90
132
|
|
|
91
133
|
const cn = (...parts: Array<string | false | null | undefined>): string =>
|
|
@@ -104,6 +146,8 @@ const ASSISTANT_ACTIONS: Array<{
|
|
|
104
146
|
{ action: "more", icon: "ellipsis", label: "More options" },
|
|
105
147
|
];
|
|
106
148
|
|
|
149
|
+
const MAX_COMPOSER_ROWS = 6;
|
|
150
|
+
|
|
107
151
|
export const ChatWindow = React.forwardRef<HTMLDivElement, ChatWindowProps>(
|
|
108
152
|
(
|
|
109
153
|
{
|
|
@@ -121,6 +165,14 @@ export const ChatWindow = React.forwardRef<HTMLDivElement, ChatWindowProps>(
|
|
|
121
165
|
onStartCall,
|
|
122
166
|
onOpenChannelMenu,
|
|
123
167
|
onMessageAction,
|
|
168
|
+
suggestions = [],
|
|
169
|
+
onSuggestion,
|
|
170
|
+
composerContext,
|
|
171
|
+
composerPlaceholder = "Ask anything",
|
|
172
|
+
composerTools = [],
|
|
173
|
+
composerModes = [],
|
|
174
|
+
mode,
|
|
175
|
+
onChange: _ignoredOnChange,
|
|
124
176
|
className,
|
|
125
177
|
...rest
|
|
126
178
|
},
|
|
@@ -128,6 +180,7 @@ export const ChatWindow = React.forwardRef<HTMLDivElement, ChatWindowProps>(
|
|
|
128
180
|
) => {
|
|
129
181
|
const [draft, setDraft] = React.useState(defaultDraft);
|
|
130
182
|
const [reactions, setReactions] = React.useState<Record<string, boolean>>({});
|
|
183
|
+
const [selectedMode, setSelectedMode] = React.useState<string>("");
|
|
131
184
|
|
|
132
185
|
const isAssistant = variant === "assistant";
|
|
133
186
|
const heading =
|
|
@@ -158,13 +211,49 @@ export const ChatWindow = React.forwardRef<HTMLDivElement, ChatWindowProps>(
|
|
|
158
211
|
}));
|
|
159
212
|
};
|
|
160
213
|
|
|
161
|
-
const
|
|
162
|
-
event.preventDefault();
|
|
214
|
+
const sendDraft = (): void => {
|
|
163
215
|
if (!hasDraft) return;
|
|
164
216
|
onSend?.(draft.trim());
|
|
165
217
|
setDraft("");
|
|
166
218
|
};
|
|
167
219
|
|
|
220
|
+
const submit = (event: React.FormEvent<HTMLFormElement>): void => {
|
|
221
|
+
event.preventDefault();
|
|
222
|
+
sendDraft();
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
/* ---- assistant composer: auto-growing field --------------------------- */
|
|
226
|
+
|
|
227
|
+
const fieldRef = React.useRef<HTMLTextAreaElement | null>(null);
|
|
228
|
+
|
|
229
|
+
React.useEffect(() => {
|
|
230
|
+
const element = fieldRef.current;
|
|
231
|
+
if (!element || !isAssistant) return;
|
|
232
|
+
element.style.height = "auto";
|
|
233
|
+
const lineHeight =
|
|
234
|
+
Number.parseFloat(window.getComputedStyle(element).lineHeight) || 22;
|
|
235
|
+
const maxHeight = lineHeight * MAX_COMPOSER_ROWS;
|
|
236
|
+
element.style.height = Math.min(element.scrollHeight, maxHeight) + "px";
|
|
237
|
+
element.style.overflowY =
|
|
238
|
+
element.scrollHeight > maxHeight ? "auto" : "hidden";
|
|
239
|
+
}, [draft, isAssistant]);
|
|
240
|
+
|
|
241
|
+
const onComposerKeyDown = (
|
|
242
|
+
event: React.KeyboardEvent<HTMLTextAreaElement>,
|
|
243
|
+
): void => {
|
|
244
|
+
if (event.key === "Enter" && !event.shiftKey) {
|
|
245
|
+
event.preventDefault();
|
|
246
|
+
sendDraft();
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
const resolvedMode = mode ?? (selectedMode || composerModes[0]?.value || "");
|
|
251
|
+
|
|
252
|
+
const chooseMode = (next: string): void => {
|
|
253
|
+
if (mode === undefined) setSelectedMode(next);
|
|
254
|
+
onModeChange?.(next);
|
|
255
|
+
};
|
|
256
|
+
|
|
168
257
|
/* ---- scroll to latest (assistant variant) ---------------------------- */
|
|
169
258
|
|
|
170
259
|
const threadRef = React.useRef<HTMLDivElement | null>(null);
|
|
@@ -484,87 +573,209 @@ export const ChatWindow = React.forwardRef<HTMLDivElement, ChatWindowProps>(
|
|
|
484
573
|
) : null}
|
|
485
574
|
</div>
|
|
486
575
|
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
576
|
+
{isAssistant ? (
|
|
577
|
+
<div className="flex shrink-0 flex-col gap-sm px-base pb-base pt-sm">
|
|
578
|
+
{suggestions.length > 0 ? (
|
|
579
|
+
<div className="flex flex-wrap items-center gap-xs">
|
|
580
|
+
{suggestions.map((suggestion) => (
|
|
581
|
+
<Button
|
|
582
|
+
key={suggestion}
|
|
583
|
+
variant="secondary"
|
|
584
|
+
size="sm"
|
|
585
|
+
onClick={() => onSuggestion?.(suggestion)}
|
|
586
|
+
>
|
|
587
|
+
{suggestion}
|
|
588
|
+
</Button>
|
|
589
|
+
))}
|
|
590
|
+
</div>
|
|
591
|
+
) : null}
|
|
499
592
|
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
593
|
+
<form
|
|
594
|
+
onSubmit={submit}
|
|
595
|
+
className={cn(
|
|
596
|
+
"flex w-full flex-col gap-xs rounded-xl border border-hairline bg-surface p-sm shadow-sm",
|
|
597
|
+
"transition duration-150 ease-out",
|
|
598
|
+
"hover:border-hairline-strong focus-within:border-focus-blue",
|
|
599
|
+
)}
|
|
600
|
+
>
|
|
601
|
+
{composerContext &&
|
|
602
|
+
(composerContext.backLabel || composerContext.activeLabel) ? (
|
|
603
|
+
<div className="flex flex-col items-start gap-xs border-b border-hairline pb-sm">
|
|
604
|
+
{composerContext.backLabel ? (
|
|
605
|
+
<Button
|
|
606
|
+
variant="ghost"
|
|
607
|
+
size="sm"
|
|
608
|
+
justify="start"
|
|
609
|
+
leadingIcon="arrow-left"
|
|
610
|
+
onClick={composerContext.onBack}
|
|
611
|
+
labelClassName="text-muted"
|
|
612
|
+
>
|
|
613
|
+
{composerContext.backLabel}
|
|
614
|
+
</Button>
|
|
615
|
+
) : null}
|
|
616
|
+
|
|
617
|
+
{composerContext.activeLabel ? (
|
|
618
|
+
<Button
|
|
619
|
+
variant="soft"
|
|
620
|
+
size="sm"
|
|
621
|
+
fullWidth
|
|
622
|
+
justify="start"
|
|
623
|
+
leadingIcon={composerContext.activeIcon}
|
|
624
|
+
>
|
|
625
|
+
{composerContext.activeLabel}
|
|
626
|
+
</Button>
|
|
627
|
+
) : null}
|
|
628
|
+
</div>
|
|
629
|
+
) : null}
|
|
630
|
+
|
|
631
|
+
<Textarea
|
|
632
|
+
ref={fieldRef}
|
|
633
|
+
chrome="none"
|
|
634
|
+
size="md"
|
|
635
|
+
rows={1}
|
|
636
|
+
value={draft}
|
|
637
|
+
onChange={(event) => setDraft(event.target.value)}
|
|
638
|
+
onKeyDown={onComposerKeyDown}
|
|
639
|
+
placeholder={composerPlaceholder}
|
|
640
|
+
aria-label={composerPlaceholder}
|
|
641
|
+
wrapperClassName="min-w-0"
|
|
642
|
+
className="min-h-0! resize-none px-0! py-0! text-body-md"
|
|
643
|
+
/>
|
|
644
|
+
|
|
645
|
+
<div className="flex flex-wrap items-center gap-xs">
|
|
646
|
+
<IconButton
|
|
647
|
+
icon="plus"
|
|
648
|
+
label="Attach to the message"
|
|
649
|
+
variant="outline"
|
|
650
|
+
size="sm"
|
|
651
|
+
shape="circle"
|
|
652
|
+
/>
|
|
653
|
+
|
|
654
|
+
{composerTools.map((tool) => (
|
|
655
|
+
<Button
|
|
656
|
+
key={tool.value}
|
|
657
|
+
variant="outline"
|
|
658
|
+
size="sm"
|
|
659
|
+
leadingIcon={tool.icon}
|
|
660
|
+
>
|
|
661
|
+
{tool.label}
|
|
662
|
+
</Button>
|
|
663
|
+
))}
|
|
664
|
+
|
|
665
|
+
<div className="ml-auto flex items-center gap-xxs">
|
|
666
|
+
{composerModes.map((item) => {
|
|
667
|
+
const active = item.value === resolvedMode;
|
|
668
|
+
return (
|
|
669
|
+
<Button
|
|
670
|
+
key={item.value}
|
|
671
|
+
variant={active ? "soft" : "ghost"}
|
|
672
|
+
size="sm"
|
|
673
|
+
leadingIcon={item.icon}
|
|
674
|
+
aria-pressed={active}
|
|
675
|
+
onClick={() => chooseMode(item.value)}
|
|
676
|
+
>
|
|
677
|
+
{item.label}
|
|
678
|
+
</Button>
|
|
679
|
+
);
|
|
680
|
+
})}
|
|
681
|
+
|
|
682
|
+
<IconButton
|
|
683
|
+
icon="arrow-up"
|
|
684
|
+
label="Send message"
|
|
685
|
+
variant="primary"
|
|
686
|
+
size="sm"
|
|
687
|
+
shape="circle"
|
|
688
|
+
type="submit"
|
|
689
|
+
disabled={!hasDraft}
|
|
690
|
+
className="ml-xxs"
|
|
691
|
+
/>
|
|
692
|
+
</div>
|
|
693
|
+
</div>
|
|
694
|
+
</form>
|
|
695
|
+
</div>
|
|
696
|
+
) : (
|
|
697
|
+
<form
|
|
698
|
+
onSubmit={submit}
|
|
699
|
+
className="flex items-center gap-sm px-base pb-base pt-sm"
|
|
507
700
|
>
|
|
508
|
-
<
|
|
509
|
-
|
|
701
|
+
<IconButton
|
|
702
|
+
icon="plus"
|
|
703
|
+
label="Add to the conversation"
|
|
704
|
+
variant="outline"
|
|
510
705
|
size="md"
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
placeholder={placeholder}
|
|
514
|
-
aria-label={placeholder}
|
|
515
|
-
wrapperClassName="min-w-0 flex-1"
|
|
706
|
+
shape="circle"
|
|
707
|
+
type="button"
|
|
516
708
|
/>
|
|
517
709
|
|
|
518
710
|
<div
|
|
519
|
-
className=
|
|
520
|
-
|
|
521
|
-
|
|
711
|
+
className={cn(
|
|
712
|
+
"flex min-w-0 flex-1 items-center gap-xs rounded-md border bg-surface",
|
|
713
|
+
"transition duration-150 ease-out",
|
|
714
|
+
"border-hairline hover:border-hairline-strong",
|
|
715
|
+
"focus-within:border-focus-blue focus-within:ring-2 focus-within:ring-focus-blue/25",
|
|
716
|
+
)}
|
|
522
717
|
>
|
|
718
|
+
<Input
|
|
719
|
+
chrome="none"
|
|
720
|
+
size="md"
|
|
721
|
+
value={draft}
|
|
722
|
+
onChange={(event) => setDraft(event.target.value)}
|
|
723
|
+
placeholder={placeholder}
|
|
724
|
+
aria-label={placeholder}
|
|
725
|
+
wrapperClassName="min-w-0 flex-1"
|
|
726
|
+
/>
|
|
727
|
+
|
|
523
728
|
<div
|
|
524
|
-
className=
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
hasDraft ? "opacity-100" : "opacity-0",
|
|
528
|
-
)}
|
|
729
|
+
className="grid shrink-0 overflow-hidden transition-all duration-200 ease-out"
|
|
730
|
+
style={{ gridTemplateColumns: hasDraft ? "1fr" : "0fr" }}
|
|
731
|
+
aria-hidden={hasDraft ? undefined : true}
|
|
529
732
|
>
|
|
530
|
-
<
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
tabIndex={hasDraft ? 0 : -1}
|
|
537
|
-
/>
|
|
538
|
-
<IconButton
|
|
539
|
-
icon="paperclip"
|
|
540
|
-
label="Attach a file"
|
|
541
|
-
variant="ghost"
|
|
542
|
-
size="sm"
|
|
543
|
-
shape="circle"
|
|
544
|
-
tabIndex={hasDraft ? 0 : -1}
|
|
545
|
-
/>
|
|
546
|
-
<IconButton
|
|
547
|
-
icon="smile"
|
|
548
|
-
label="Add an emoji"
|
|
549
|
-
variant="ghost"
|
|
550
|
-
size="sm"
|
|
551
|
-
shape="circle"
|
|
552
|
-
tabIndex={hasDraft ? 0 : -1}
|
|
553
|
-
/>
|
|
554
|
-
<Button
|
|
555
|
-
type="submit"
|
|
556
|
-
variant="primary"
|
|
557
|
-
size="sm"
|
|
558
|
-
disabled={!hasDraft}
|
|
559
|
-
tabIndex={hasDraft ? 0 : -1}
|
|
560
|
-
className="ml-xxs"
|
|
733
|
+
<div
|
|
734
|
+
className={cn(
|
|
735
|
+
"flex min-w-0 items-center gap-xxs overflow-hidden pr-xs",
|
|
736
|
+
"transition-opacity duration-200 ease-out",
|
|
737
|
+
hasDraft ? "opacity-100" : "opacity-0",
|
|
738
|
+
)}
|
|
561
739
|
>
|
|
562
|
-
|
|
563
|
-
|
|
740
|
+
<IconButton
|
|
741
|
+
icon="at-sign"
|
|
742
|
+
label="Mention a teammate"
|
|
743
|
+
variant="ghost"
|
|
744
|
+
size="sm"
|
|
745
|
+
shape="circle"
|
|
746
|
+
tabIndex={hasDraft ? 0 : -1}
|
|
747
|
+
/>
|
|
748
|
+
<IconButton
|
|
749
|
+
icon="paperclip"
|
|
750
|
+
label="Attach a file"
|
|
751
|
+
variant="ghost"
|
|
752
|
+
size="sm"
|
|
753
|
+
shape="circle"
|
|
754
|
+
tabIndex={hasDraft ? 0 : -1}
|
|
755
|
+
/>
|
|
756
|
+
<IconButton
|
|
757
|
+
icon="smile"
|
|
758
|
+
label="Add an emoji"
|
|
759
|
+
variant="ghost"
|
|
760
|
+
size="sm"
|
|
761
|
+
shape="circle"
|
|
762
|
+
tabIndex={hasDraft ? 0 : -1}
|
|
763
|
+
/>
|
|
764
|
+
<Button
|
|
765
|
+
type="submit"
|
|
766
|
+
variant="primary"
|
|
767
|
+
size="sm"
|
|
768
|
+
disabled={!hasDraft}
|
|
769
|
+
tabIndex={hasDraft ? 0 : -1}
|
|
770
|
+
className="ml-xxs"
|
|
771
|
+
>
|
|
772
|
+
Send
|
|
773
|
+
</Button>
|
|
774
|
+
</div>
|
|
564
775
|
</div>
|
|
565
776
|
</div>
|
|
566
|
-
</
|
|
567
|
-
|
|
777
|
+
</form>
|
|
778
|
+
)}
|
|
568
779
|
|
|
569
780
|
{hasTitleMenu
|
|
570
781
|
? createPortal(
|
|
@@ -1,129 +1,143 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { ChatWindow } from "./ChatWindow";
|
|
3
|
-
import type {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
import type { ChatMessageAction, ChatWindowMessage } from "./ChatWindow";
|
|
4
|
+
|
|
5
|
+
const channelMessages: ChatWindowMessage[] = [
|
|
6
|
+
{
|
|
7
|
+
id: "c1",
|
|
8
|
+
author: "Marta Ibarra",
|
|
9
|
+
time: "9:12",
|
|
10
|
+
text: "Handoff notes are in the shared folder — the motion spec is the last tab.",
|
|
11
|
+
reactionCount: 2,
|
|
12
|
+
reacted: true,
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
id: "c2",
|
|
16
|
+
author: "Devon Park",
|
|
17
|
+
time: "9:18",
|
|
18
|
+
text: "Got them. I'll wire the empty states this afternoon and ping here.",
|
|
19
|
+
reactionCount: 1,
|
|
20
|
+
},
|
|
21
|
+
];
|
|
8
22
|
|
|
9
23
|
const assistantMessages: ChatWindowMessage[] = [
|
|
10
24
|
{
|
|
11
25
|
id: "a1",
|
|
12
26
|
role: "user",
|
|
13
|
-
text: "Summarise
|
|
27
|
+
text: "Summarise what changed in the navigation this sprint.",
|
|
14
28
|
},
|
|
15
29
|
{
|
|
16
30
|
id: "a2",
|
|
17
31
|
role: "assistant",
|
|
18
|
-
|
|
19
|
-
<div className="flex flex-col gap-sm">
|
|
20
|
-
<p>
|
|
21
|
-
Three of the five steps are shipped. The remaining work sits in the
|
|
22
|
-
invite step, which is blocked on the permission review.
|
|
23
|
-
</p>
|
|
24
|
-
<ul className="flex list-disc flex-col gap-xxs pl-lg">
|
|
25
|
-
<li>Account setup — shipped</li>
|
|
26
|
-
<li>Profile details — shipped</li>
|
|
27
|
-
<li>Workspace invite — in review</li>
|
|
28
|
-
<li>Billing — not started</li>
|
|
29
|
-
</ul>
|
|
30
|
-
</div>
|
|
31
|
-
),
|
|
32
|
+
text: "Three changes shipped: the sidebar now folds to an icon rail, the nav rows use the label type role, and the focus ring moved to the parent control so it no longer doubles up.",
|
|
32
33
|
},
|
|
33
34
|
{
|
|
34
35
|
id: "a3",
|
|
35
|
-
role: "user",
|
|
36
|
-
text: "Who owns the invite step?",
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
id: "a4",
|
|
40
36
|
role: "assistant",
|
|
41
|
-
text: "
|
|
37
|
+
text: "Want me to draft the release note for those three items?",
|
|
42
38
|
},
|
|
43
39
|
];
|
|
44
40
|
|
|
45
|
-
const
|
|
46
|
-
{
|
|
47
|
-
|
|
48
|
-
author: "Robin Vale",
|
|
49
|
-
time: "9:42",
|
|
50
|
-
text: "Draft of the kickoff agenda is in the doc — two bullets still need owners.",
|
|
51
|
-
reactionCount: 2,
|
|
52
|
-
reacted: true,
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
id: "c2",
|
|
56
|
-
author: "Sam Ortega",
|
|
57
|
-
time: "9:48",
|
|
58
|
-
text: "I can take the research recap. Adding the timeline slide after lunch.",
|
|
59
|
-
reactionCount: 1,
|
|
60
|
-
},
|
|
41
|
+
const MODES = [
|
|
42
|
+
{ value: "fast", label: "Fast", icon: "zap" as const },
|
|
43
|
+
{ value: "deep", label: "Deep", icon: "brain" as const },
|
|
61
44
|
];
|
|
62
45
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
];
|
|
46
|
+
export default function ChatWindowPreview(): React.ReactElement {
|
|
47
|
+
const [mode, setMode] = React.useState("fast");
|
|
48
|
+
const [log, setLog] = React.useState<string[]>([]);
|
|
49
|
+
const [thread, setThread] =
|
|
50
|
+
React.useState<ChatWindowMessage[]>(assistantMessages);
|
|
51
|
+
|
|
52
|
+
const note = (line: string): void => {
|
|
53
|
+
setLog((previous) => [line, ...previous].slice(0, 3));
|
|
54
|
+
};
|
|
68
55
|
|
|
69
|
-
|
|
70
|
-
|
|
56
|
+
const sendMessage = (text: string): void => {
|
|
57
|
+
setThread((previous) => [
|
|
58
|
+
...previous,
|
|
59
|
+
{ id: "u-" + previous.length, role: "user", text },
|
|
60
|
+
{
|
|
61
|
+
id: "r-" + previous.length,
|
|
62
|
+
role: "assistant",
|
|
63
|
+
text: "Noted. I'll answer that against the current draft of the thread.",
|
|
64
|
+
},
|
|
65
|
+
]);
|
|
66
|
+
note("sent: " + text);
|
|
67
|
+
};
|
|
71
68
|
|
|
72
69
|
return (
|
|
73
|
-
<div className="mx-auto
|
|
74
|
-
<
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
70
|
+
<div className="mx-auto w-full max-w-3xl space-y-lg bg-canvas p-lg">
|
|
71
|
+
<ChatWindow
|
|
72
|
+
variant="assistant"
|
|
73
|
+
title="Workspace helper"
|
|
74
|
+
subtitle="Reads the open project and the current selection"
|
|
75
|
+
headerActions={[
|
|
76
|
+
{ icon: "plus", label: "New thread", onClick: () => note("new thread") },
|
|
77
|
+
{
|
|
78
|
+
icon: "ellipsis",
|
|
79
|
+
label: "Thread options",
|
|
80
|
+
onClick: () => note("thread options"),
|
|
81
|
+
},
|
|
82
|
+
]}
|
|
83
|
+
messages={thread}
|
|
84
|
+
suggestions={[
|
|
85
|
+
"Summarise this sprint",
|
|
86
|
+
"Draft a release note",
|
|
87
|
+
"Find open questions",
|
|
88
|
+
]}
|
|
89
|
+
onSuggestion={(suggestion) => {
|
|
90
|
+
note("suggestion: " + suggestion);
|
|
91
|
+
sendMessage(suggestion);
|
|
92
|
+
}}
|
|
93
|
+
composerContext={{
|
|
94
|
+
backLabel: "All threads",
|
|
95
|
+
onBack: () => note("back to all threads"),
|
|
96
|
+
activeLabel: "Navigation system",
|
|
97
|
+
activeIcon: "layers",
|
|
98
|
+
}}
|
|
99
|
+
composerPlaceholder="Ask about the navigation system"
|
|
100
|
+
composerTools={[
|
|
101
|
+
{ value: "attach", label: "Attach", icon: "paperclip" },
|
|
102
|
+
{ value: "cite", label: "Cite", icon: "quote" },
|
|
103
|
+
]}
|
|
104
|
+
composerModes={MODES}
|
|
105
|
+
mode={mode}
|
|
106
|
+
onModeChange={(next) => {
|
|
107
|
+
setMode(next);
|
|
108
|
+
note("mode: " + next);
|
|
109
|
+
}}
|
|
110
|
+
onSend={sendMessage}
|
|
111
|
+
onMessageAction={(id: string, action: ChatMessageAction) =>
|
|
112
|
+
note(action + " on " + id)
|
|
113
|
+
}
|
|
114
|
+
/>
|
|
115
|
+
|
|
116
|
+
<ChatWindow
|
|
117
|
+
variant="assistant"
|
|
118
|
+
title="Workspace helper"
|
|
119
|
+
subtitle="A fresh thread, no context yet"
|
|
120
|
+
messages={[]}
|
|
121
|
+
suggestions={["What can you help with?"]}
|
|
122
|
+
onSuggestion={sendMessage}
|
|
123
|
+
composerPlaceholder="Ask anything"
|
|
124
|
+
composerModes={MODES}
|
|
125
|
+
onSend={sendMessage}
|
|
126
|
+
/>
|
|
99
127
|
|
|
100
|
-
<
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
channelName="Project Kickoff"
|
|
108
|
-
memberCount={12}
|
|
109
|
-
messages={channelMessages}
|
|
110
|
-
onSend={(text: string) => setLog('Channel draft: "' + text + '"')}
|
|
111
|
-
/>
|
|
112
|
-
</div>
|
|
113
|
-
</section>
|
|
128
|
+
<ChatWindow
|
|
129
|
+
variant="channel"
|
|
130
|
+
channelName="project-kickoff"
|
|
131
|
+
memberCount={8}
|
|
132
|
+
messages={channelMessages}
|
|
133
|
+
onSend={(text) => note("channel sent: " + text)}
|
|
134
|
+
/>
|
|
114
135
|
|
|
115
|
-
<
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
className="h-full"
|
|
121
|
-
title="Workspace helper"
|
|
122
|
-
subtitle="Ask about anything in this workspace"
|
|
123
|
-
headerActions={[{ icon: "sparkles", label: "Start over" }]}
|
|
124
|
-
/>
|
|
125
|
-
</div>
|
|
126
|
-
</section>
|
|
136
|
+
<p className="text-body-sm text-muted">
|
|
137
|
+
{log.length > 0
|
|
138
|
+
? "Latest events: " + log.join(" · ")
|
|
139
|
+
: "Use a suggestion, a mode toggle, or type a message to see the events here."}
|
|
140
|
+
</p>
|
|
127
141
|
</div>
|
|
128
142
|
);
|
|
129
143
|
}
|