@agentiffai/design 0.1.11 → 0.1.12

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.
@@ -1,9 +1,9 @@
1
1
  import { useButton } from '@react-aria/button';
2
- import { memo, useState, useRef, useEffect } from 'react';
2
+ import { memo, useState, useRef, useEffect, useCallback } from 'react';
3
3
  import styled4, { css, keyframes, createGlobalStyle } from 'styled-components';
4
4
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
5
- import { useTextField } from '@react-aria/textfield';
6
5
  import { CopilotSidebar, useChatContext } from '@copilotkit/react-ui';
6
+ import { useTextField } from '@react-aria/textfield';
7
7
 
8
8
  // src/components/copilotkit/Button/Button.tsx
9
9
 
@@ -127,6 +127,8 @@ var tokens = {
127
127
  lg: "0.75rem",
128
128
  // 12px
129
129
  xl: "1rem",
130
+ // 16px
131
+ "2xl": "1.5rem",
130
132
  // 24px
131
133
  full: "9999px"
132
134
  // Fully rounded
@@ -627,7 +629,16 @@ var ActionExecutionAdapter = ({ message, inProgress }) => {
627
629
  return null;
628
630
  }
629
631
  const toolName = message.name;
630
- const toolArgs = message.arguments || {};
632
+ let toolArgs = {};
633
+ if (typeof message.arguments === "string") {
634
+ try {
635
+ toolArgs = JSON.parse(message.arguments);
636
+ } catch {
637
+ toolArgs = {};
638
+ }
639
+ } else if (message.arguments && typeof message.arguments === "object") {
640
+ toolArgs = message.arguments;
641
+ }
631
642
  const state = inProgress ? "thinking" : "responding";
632
643
  const statusMessage = getToolMessage(toolName, toolArgs);
633
644
  return /* @__PURE__ */ jsxs(Container, { "data-testid": "action-execution-message", children: [
@@ -815,6 +826,9 @@ var Container3 = styled4.div`
815
826
  white-space: pre-wrap;
816
827
  word-break: break-word;
817
828
  line-height: ${tokens.typography.lineHeight.normal};
829
+ /* Performance optimizations for streaming text */
830
+ text-rendering: optimizeSpeed;
831
+ contain: content;
818
832
  `;
819
833
  var Cursor = styled4.span`
820
834
  display: inline-block;
@@ -874,20 +888,9 @@ var MessageContainer = styled4.div`
874
888
  align-items: flex-start;
875
889
  padding: ${tokens.spacing.sm} 0;
876
890
  max-width: 100%;
877
-
878
- /* Fade in and slide up animation */
879
- animation: fadeInSlideUp ${tokens.animation.duration.medium} ease-out;
880
-
881
- @keyframes fadeInSlideUp {
882
- from {
883
- opacity: 0;
884
- transform: translateY(${tokens.spacing.sm});
885
- }
886
- to {
887
- opacity: 1;
888
- transform: translateY(0);
889
- }
890
- }
891
+ /* GPU acceleration hint for smooth rendering during streaming */
892
+ will-change: contents;
893
+ contain: content;
891
894
  `;
892
895
  var AvatarContainer = styled4.div`
893
896
  flex-shrink: 0;
@@ -922,9 +925,8 @@ var ContentContainer = styled4.div`
922
925
  min-width: 0;
923
926
  `;
924
927
  var MessageContent = styled4.div`
925
- background-color: ${tokens.colors.surface.glass};
926
- backdrop-filter: blur(10px);
927
- -webkit-backdrop-filter: blur(10px);
928
+ /* Use solid color instead of backdrop-filter for performance during streaming */
929
+ background-color: ${tokens.colors.surface.elevated};
928
930
  padding: ${tokens.spacing.sm} ${tokens.spacing.md};
929
931
  border-radius: ${tokens.borderRadius.lg};
930
932
  border-top-left-radius: ${tokens.borderRadius.sm};
@@ -934,24 +936,25 @@ var MessageContent = styled4.div`
934
936
  font-family: ${tokens.typography.fontFamily.primary};
935
937
  word-wrap: break-word;
936
938
  white-space: pre-wrap;
939
+ /* Optimize text rendering */
940
+ text-rendering: optimizeSpeed;
937
941
  `;
938
942
  var LoadingDots3 = styled4.div`
939
943
  display: flex;
940
944
  gap: ${tokens.spacing.xs};
941
945
  padding: ${tokens.spacing.sm} ${tokens.spacing.md};
942
- background-color: ${tokens.colors.surface.glass};
943
- backdrop-filter: blur(10px);
944
- -webkit-backdrop-filter: blur(10px);
946
+ /* Use solid color instead of backdrop-filter for performance */
947
+ background-color: ${tokens.colors.surface.elevated};
945
948
  border-radius: ${tokens.borderRadius.lg};
946
949
  border-top-left-radius: ${tokens.borderRadius.sm};
947
950
  width: fit-content;
948
951
  `;
949
- var bounce = keyframes`
950
- 0%, 60%, 100% {
951
- transform: translateY(0);
952
+ var pulse2 = keyframes`
953
+ 0%, 100% {
954
+ opacity: 0.4;
952
955
  }
953
- 30% {
954
- transform: translateY(-${tokens.spacing.sm});
956
+ 50% {
957
+ opacity: 1;
955
958
  }
956
959
  `;
957
960
  var LoadingDot = styled4.div`
@@ -959,7 +962,8 @@ var LoadingDot = styled4.div`
959
962
  height: ${tokens.spacing.sm};
960
963
  border-radius: ${tokens.borderRadius.full};
961
964
  background-color: ${tokens.colors.text.tertiary};
962
- animation: ${bounce} 1.4s ease-in-out infinite;
965
+ /* Use simple opacity animation instead of transform bounce */
966
+ animation: ${pulse2} 1.4s ease-in-out infinite;
963
967
  animation-delay: ${(props) => props.delay}s;
964
968
  `;
965
969
  var FileAttachmentContainer = styled4.div`
@@ -1267,7 +1271,7 @@ var SuggestionButton = styled4.button`
1267
1271
  font-weight: ${tokens.typography.fontWeight.regular};
1268
1272
  text-align: center;
1269
1273
  border: 1px solid ${tokens.colors.border.default};
1270
- border-radius: 20px;
1274
+ border-radius: ${tokens.borderRadius.full};
1271
1275
  cursor: pointer;
1272
1276
  transition: all ${tokens.transitions.fast};
1273
1277
  white-space: nowrap;
@@ -1301,9 +1305,9 @@ var SuggestionButton = styled4.button`
1301
1305
  `;
1302
1306
  var InputWrapper = styled4.div`
1303
1307
  display: flex;
1304
- align-items: center;
1305
- gap: 10px;
1306
- padding: 10px 14px;
1308
+ align-items: flex-end; /* Align button to bottom when textarea expands */
1309
+ gap: ${tokens.spacing.sm};
1310
+ padding: ${tokens.spacing.sm} ${tokens.spacing.md};
1307
1311
  background-color: rgba(25, 25, 25, 0.4);
1308
1312
  border: 1px solid ${tokens.colors.border.subtle};
1309
1313
  border-radius: ${tokens.borderRadius.lg};
@@ -1317,7 +1321,7 @@ var InputWrapper = styled4.div`
1317
1321
  background-color: rgba(50, 50, 52, 0.6);
1318
1322
  }
1319
1323
  `;
1320
- var InputField = styled4.input`
1324
+ var InputField = styled4.textarea`
1321
1325
  flex: 1;
1322
1326
  border: none;
1323
1327
  outline: none;
@@ -1325,6 +1329,13 @@ var InputField = styled4.input`
1325
1329
  font-size: ${tokens.typography.fontSize.sm};
1326
1330
  color: ${tokens.colors.text.secondary};
1327
1331
  background: transparent;
1332
+ resize: none; /* Disable manual resize, we auto-resize */
1333
+ min-height: 24px; /* Single line height */
1334
+ max-height: 150px; /* Max ~6 lines before scrolling */
1335
+ overflow-y: auto;
1336
+ line-height: 1.5;
1337
+ padding: 0;
1338
+ margin: 0;
1328
1339
 
1329
1340
  &::placeholder {
1330
1341
  color: ${tokens.colors.text.tertiary};
@@ -1380,31 +1391,29 @@ var ChatInput = ({
1380
1391
  isReadOnly = false,
1381
1392
  autoFocus = false,
1382
1393
  className,
1383
- "aria-label": ariaLabel = "Chat message input",
1384
- ...ariaProps
1394
+ "aria-label": ariaLabel = "Chat message input"
1395
+ // Note: Additional AriaTextFieldProps are accepted but not spread to textarea
1396
+ // since useTextField is not compatible with textarea elements
1385
1397
  }) => {
1386
1398
  const [internalValue, setInternalValue] = useState(value);
1387
1399
  const inputRef = useRef(null);
1388
1400
  const currentValue = value !== void 0 ? value : internalValue;
1389
1401
  const setValue = onChange || setInternalValue;
1390
- const { inputProps } = useTextField(
1391
- {
1392
- ...ariaProps,
1393
- "aria-label": ariaLabel,
1394
- value: currentValue,
1395
- onChange: (newValue) => {
1396
- setValue(newValue);
1397
- },
1398
- isDisabled,
1399
- isReadOnly
1400
- },
1401
- inputRef
1402
- );
1402
+ const autoResize = useCallback(() => {
1403
+ const textarea = inputRef.current;
1404
+ if (textarea) {
1405
+ textarea.style.height = "auto";
1406
+ textarea.style.height = `${textarea.scrollHeight}px`;
1407
+ }
1408
+ }, []);
1409
+ useEffect(() => {
1410
+ autoResize();
1411
+ }, [currentValue, autoResize]);
1403
1412
  const handleDirectChange = (e) => {
1404
1413
  setValue(e.target.value);
1405
1414
  };
1406
1415
  const handleKeyDown = (e) => {
1407
- if (e.key === "Enter") {
1416
+ if (e.key === "Enter" && !e.shiftKey) {
1408
1417
  e.preventDefault();
1409
1418
  handleSubmit();
1410
1419
  }
@@ -1413,6 +1422,9 @@ var ChatInput = ({
1413
1422
  if (currentValue.trim() && onSubmit && !isDisabled && !isReadOnly) {
1414
1423
  onSubmit(currentValue.trim());
1415
1424
  setValue("");
1425
+ if (inputRef.current) {
1426
+ inputRef.current.style.height = "auto";
1427
+ }
1416
1428
  inputRef.current?.focus();
1417
1429
  }
1418
1430
  };
@@ -1436,16 +1448,16 @@ var ChatInput = ({
1436
1448
  /* @__PURE__ */ jsx(
1437
1449
  InputField,
1438
1450
  {
1439
- ...inputProps,
1440
1451
  ref: inputRef,
1441
- type: "text",
1452
+ "aria-label": ariaLabel,
1442
1453
  placeholder,
1443
1454
  onKeyDown: handleKeyDown,
1444
1455
  onChange: handleDirectChange,
1445
1456
  autoFocus,
1446
1457
  disabled: isDisabled,
1447
1458
  readOnly: isReadOnly,
1448
- value: currentValue
1459
+ value: currentValue,
1460
+ rows: 1
1449
1461
  }
1450
1462
  ),
1451
1463
  /* @__PURE__ */ jsx(
@@ -1593,7 +1605,7 @@ var StyledUserMessage = styled4.button`
1593
1605
  && {
1594
1606
  background: ${tokens.colors.message.user} !important;
1595
1607
  color: ${tokens.colors.text.primary} !important;
1596
- border-radius: ${tokens.borderRadius.full} !important; /* Pill shape - fully rounded ends */
1608
+ border-radius: ${tokens.borderRadius["2xl"]} !important; /* Rounded corners that work for multi-line */
1597
1609
  }
1598
1610
 
1599
1611
  /* Subtle shadow and glow effect */
@@ -1711,20 +1723,8 @@ var UserMessageWrapper = styled4.div`
1711
1723
  justify-content: flex-end;
1712
1724
  width: 100%;
1713
1725
  padding: ${tokens.spacing.sm} 0;
1714
-
1715
- /* Fade in and slide up animation */
1716
- animation: fadeInSlideUp ${tokens.animation.duration.medium} ease-out;
1717
-
1718
- @keyframes fadeInSlideUp {
1719
- from {
1720
- opacity: 0;
1721
- transform: translateY(${tokens.spacing.sm});
1722
- }
1723
- to {
1724
- opacity: 1;
1725
- transform: translateY(0);
1726
- }
1727
- }
1726
+ /* Performance optimization - isolate layout/paint */
1727
+ contain: content;
1728
1728
  `;
1729
1729
  var UserMessageAdapterBase = ({
1730
1730
  message,
@@ -1738,7 +1738,7 @@ var UserMessageAdapterBase = ({
1738
1738
  };
1739
1739
  var UserMessageAdapter = memo(UserMessageAdapterBase);
1740
1740
  UserMessageAdapter.displayName = "UserMessageAdapter";
1741
- var pulse2 = keyframes`
1741
+ var pulse3 = keyframes`
1742
1742
  0%, 100% {
1743
1743
  opacity: 1;
1744
1744
  transform: scale(1);
@@ -1822,7 +1822,7 @@ var StatusDot = styled4.div`
1822
1822
  return tokens.colors.connection.reconnecting;
1823
1823
  }
1824
1824
  }};
1825
- animation: ${(props) => props.status === "streaming" ? pulse2 : "none"} 2s ease-in-out infinite;
1825
+ animation: ${(props) => props.status === "streaming" ? pulse3 : "none"} 2s ease-in-out infinite;
1826
1826
  flex-shrink: 0;
1827
1827
  `;
1828
1828
  var Label = styled4.span`
@@ -2338,8 +2338,8 @@ var StyledChatButton = styled4.button`
2338
2338
  height: 36px;
2339
2339
  border-radius: 18px;
2340
2340
  border: none;
2341
- background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
2342
- box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
2341
+ background: linear-gradient(135deg, ${tokens.colors.primary} 0%, ${tokens.colors.accent} 100%);
2342
+ box-shadow: 0 4px 12px rgba(44, 176, 171, 0.4);
2343
2343
  display: flex;
2344
2344
  align-items: center;
2345
2345
  justify-content: center;
@@ -2349,7 +2349,7 @@ var StyledChatButton = styled4.button`
2349
2349
 
2350
2350
  &:hover {
2351
2351
  transform: scale(1.05);
2352
- box-shadow: 0 6px 16px rgba(102, 126, 234, 0.5);
2352
+ box-shadow: 0 6px 16px rgba(44, 176, 171, 0.5);
2353
2353
  }
2354
2354
 
2355
2355
  &:active {
@@ -2589,20 +2589,10 @@ var GlobalSidebarStyles2 = createGlobalStyle`
2589
2589
  background-color: transparent !important;
2590
2590
  }
2591
2591
 
2592
- /* Fade-in animation for new messages */
2593
- @keyframes messagesFadeIn {
2594
- from {
2595
- opacity: 0;
2596
- transform: translateY(${tokens.spacing.sm});
2597
- }
2598
- to {
2599
- opacity: 1;
2600
- transform: translateY(0);
2601
- }
2602
- }
2603
-
2592
+ /* Performance optimization for messages - no animations to reduce jitter during streaming */
2604
2593
  .copilotKitMessage {
2605
- animation: messagesFadeIn 0.3s ease-out;
2594
+ /* contain: content isolates layout/paint to this element */
2595
+ contain: content;
2606
2596
  }
2607
2597
 
2608
2598
  /* Override CopilotKit suggestions to be single-row with horizontal scroll */