@carto/ps-react-ui 4.3.10 → 4.4.0-chat-ui.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/dist/chat.js +798 -0
  2. package/dist/chat.js.map +1 -0
  3. package/dist/components.js +260 -240
  4. package/dist/components.js.map +1 -1
  5. package/dist/types/chat/bubbles/chat-error-message.d.ts +2 -0
  6. package/dist/types/chat/bubbles/chat-suggestion-button.d.ts +2 -0
  7. package/dist/types/chat/bubbles/chat-user-message.d.ts +2 -0
  8. package/dist/types/chat/bubbles/index.d.ts +4 -0
  9. package/dist/types/chat/const.d.ts +3 -0
  10. package/dist/types/chat/containers/chat-content.d.ts +2 -0
  11. package/dist/types/chat/containers/chat-footer.d.ts +2 -0
  12. package/dist/types/chat/containers/chat-header.d.ts +2 -0
  13. package/dist/types/chat/containers/chat-starter.d.ts +2 -0
  14. package/dist/types/chat/containers/index.d.ts +4 -0
  15. package/dist/types/chat/containers/styles.d.ts +101 -0
  16. package/dist/types/chat/feedback/chat-loader.d.ts +2 -0
  17. package/dist/types/chat/feedback/chat-rating-action.d.ts +2 -0
  18. package/dist/types/chat/feedback/chat-thinking.d.ts +2 -0
  19. package/dist/types/chat/feedback/chat-tools.d.ts +2 -0
  20. package/dist/types/chat/feedback/index.d.ts +5 -0
  21. package/dist/types/chat/feedback/styles.d.ts +65 -0
  22. package/dist/types/chat/index.d.ts +16 -0
  23. package/dist/types/chat/types.d.ts +99 -0
  24. package/dist/types/components/copy-button/copy-button.d.ts +2 -0
  25. package/dist/types/components/copy-button/types.d.ts +6 -0
  26. package/dist/types/components/index.d.ts +2 -0
  27. package/dist/widgets/actions.js +22 -21
  28. package/dist/widgets/actions.js.map +1 -1
  29. package/dist/widgets/bar.js +7 -6
  30. package/dist/widgets/bar.js.map +1 -1
  31. package/dist/widgets/category.js +9 -8
  32. package/dist/widgets/category.js.map +1 -1
  33. package/dist/widgets/formula.js +11 -10
  34. package/dist/widgets/formula.js.map +1 -1
  35. package/dist/widgets/histogram.js +7 -6
  36. package/dist/widgets/histogram.js.map +1 -1
  37. package/dist/widgets/markdown.js +9 -8
  38. package/dist/widgets/markdown.js.map +1 -1
  39. package/dist/widgets/pie.js +7 -6
  40. package/dist/widgets/pie.js.map +1 -1
  41. package/dist/widgets/scatterplot.js +7 -6
  42. package/dist/widgets/scatterplot.js.map +1 -1
  43. package/dist/widgets/spread.js +57 -56
  44. package/dist/widgets/spread.js.map +1 -1
  45. package/dist/widgets/table.js +67 -66
  46. package/dist/widgets/table.js.map +1 -1
  47. package/dist/widgets/timeseries.js +23 -22
  48. package/dist/widgets/timeseries.js.map +1 -1
  49. package/dist/widgets/wrapper.js +21 -20
  50. package/dist/widgets/wrapper.js.map +1 -1
  51. package/package.json +7 -3
  52. package/src/chat/bubbles/chat-agent-message.test.tsx +30 -0
  53. package/src/chat/bubbles/chat-agent-message.tsx +11 -0
  54. package/src/chat/bubbles/chat-error-message.test.tsx +40 -0
  55. package/src/chat/bubbles/chat-error-message.tsx +47 -0
  56. package/src/chat/bubbles/chat-suggestion-button.test.tsx +24 -0
  57. package/src/chat/bubbles/chat-suggestion-button.tsx +27 -0
  58. package/src/chat/bubbles/chat-user-message.test.tsx +27 -0
  59. package/src/chat/bubbles/chat-user-message.tsx +27 -0
  60. package/src/chat/bubbles/index.ts +4 -0
  61. package/src/chat/bubbles/styles.ts +106 -0
  62. package/src/chat/const.ts +3 -0
  63. package/src/chat/containers/chat-content.test.tsx +15 -0
  64. package/src/chat/containers/chat-content.tsx +32 -0
  65. package/src/chat/containers/chat-footer.test.tsx +34 -0
  66. package/src/chat/containers/chat-footer.tsx +78 -0
  67. package/src/chat/containers/chat-header.test.tsx +28 -0
  68. package/src/chat/containers/chat-header.tsx +29 -0
  69. package/src/chat/containers/chat-starter.test.tsx +32 -0
  70. package/src/chat/containers/chat-starter.tsx +75 -0
  71. package/src/chat/containers/index.ts +4 -0
  72. package/src/chat/containers/styles.ts +107 -0
  73. package/src/chat/feedback/chat-actions-container.test.tsx +64 -0
  74. package/src/chat/feedback/chat-actions-container.tsx +7 -0
  75. package/src/chat/feedback/chat-loader.test.tsx +10 -0
  76. package/src/chat/feedback/chat-loader.tsx +31 -0
  77. package/src/chat/feedback/chat-rating-action.tsx +43 -0
  78. package/src/chat/feedback/chat-thinking.test.tsx +15 -0
  79. package/src/chat/feedback/chat-thinking.tsx +23 -0
  80. package/src/chat/feedback/chat-tools.test.tsx +23 -0
  81. package/src/chat/feedback/chat-tools.tsx +54 -0
  82. package/src/chat/feedback/index.ts +5 -0
  83. package/src/chat/feedback/styles.ts +80 -0
  84. package/src/chat/index.ts +45 -0
  85. package/src/chat/types.ts +124 -0
  86. package/src/components/copy-button/copy-button.test.tsx +41 -0
  87. package/src/components/copy-button/copy-button.tsx +31 -0
  88. package/src/components/copy-button/types.ts +10 -0
  89. package/src/components/index.ts +3 -0
@@ -0,0 +1,4 @@
1
+ export { ChatContent } from './chat-content';
2
+ export { ChatHeader } from './chat-header';
3
+ export { ChatFooter } from './chat-footer';
4
+ export { ChatStarter } from './chat-starter';
@@ -0,0 +1,101 @@
1
+ import { Theme } from '@mui/material';
2
+ export declare const styles: {
3
+ header: {
4
+ display: "flex";
5
+ alignItems: "center";
6
+ justifyContent: "space-between";
7
+ padding: ({ spacing }: Theme) => string;
8
+ };
9
+ headerTitle: {
10
+ flexGrow: number;
11
+ px: ({ spacing }: Theme) => string;
12
+ };
13
+ headerActions: {
14
+ display: "flex";
15
+ alignItems: "center";
16
+ marginLeft: ({ spacing }: Theme) => string;
17
+ gap: ({ spacing }: Theme) => string;
18
+ };
19
+ footerWrapper: {
20
+ padding: ({ spacing }: Theme) => string;
21
+ position: "relative";
22
+ };
23
+ footerCorner: {
24
+ position: "absolute";
25
+ bottom: string;
26
+ right: string;
27
+ margin: string;
28
+ };
29
+ footer: {
30
+ maxWidth: number;
31
+ margin: string;
32
+ };
33
+ footerCaption: {
34
+ textAlign: "center";
35
+ };
36
+ content: {
37
+ overflowY: "auto";
38
+ flex: number;
39
+ position: "relative";
40
+ mx: string;
41
+ maxWidth: number;
42
+ width: string;
43
+ maxHeight: string;
44
+ pt: number;
45
+ pb: number;
46
+ px: number;
47
+ display: "flex";
48
+ flexDirection: "column";
49
+ '--chat-border-color': ({ palette }: Theme) => string;
50
+ borderTop: string;
51
+ borderBottom: string;
52
+ '@supports (animation-timeline: scroll())': {
53
+ animation: `${{
54
+ name: string;
55
+ styles: string;
56
+ anim: 1;
57
+ toString: () => string;
58
+ } & string} linear both`;
59
+ animationTimeline: "scroll(self)";
60
+ };
61
+ };
62
+ jumpToLatestWrapper: {
63
+ position: "sticky";
64
+ bottom: ({ spacing }: Theme) => string;
65
+ height: number;
66
+ display: "flex";
67
+ justifyContent: "center";
68
+ zIndex: number;
69
+ };
70
+ jumpToLatest: {
71
+ opacity: number;
72
+ pointerEvents: "none";
73
+ '@supports (animation-timeline: scroll())': {
74
+ animation: `${{
75
+ name: string;
76
+ styles: string;
77
+ anim: 1;
78
+ toString: () => string;
79
+ } & string} linear both`;
80
+ animationTimeline: "scroll(nearest)";
81
+ };
82
+ };
83
+ starter: {
84
+ display: "flex";
85
+ flexDirection: "column";
86
+ alignItems: "center";
87
+ justifyContent: "center";
88
+ padding: ({ spacing }: Theme) => string;
89
+ textAlign: "center";
90
+ maxWidth: number;
91
+ margin: string;
92
+ };
93
+ starterItems: {
94
+ display: "grid";
95
+ width: string;
96
+ marginTop: ({ spacing }: Theme) => string;
97
+ };
98
+ starterItemsTwoCol: {
99
+ gridTemplateColumns: string;
100
+ };
101
+ };
@@ -0,0 +1,2 @@
1
+ import { ChatLoaderProps } from '../types';
2
+ export declare function ChatLoader({ size, labels, sx }: ChatLoaderProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,2 @@
1
+ import { ChatRatingActionProps } from '../types';
2
+ export declare function ChatRatingAction({ rating, onRatingChange, labels, }: ChatRatingActionProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,2 @@
1
+ import { ChatThinkingProps } from '../types';
2
+ export declare function ChatThinking({ children, duration, sx, }: ChatThinkingProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,2 @@
1
+ import { ChatToolsProps } from '../types';
2
+ export declare function ChatTools({ tools, labels, sx }: ChatToolsProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,5 @@
1
+ export { ChatThinking } from './chat-thinking';
2
+ export { ChatLoader } from './chat-loader';
3
+ export { ChatActionsContainer } from './chat-actions-container';
4
+ export { ChatRatingAction } from './chat-rating-action';
5
+ export { ChatTools } from './chat-tools';
@@ -0,0 +1,65 @@
1
+ import { Theme } from '@mui/material';
2
+ export declare const styles: {
3
+ thinking: {
4
+ display: "flex";
5
+ alignItems: "center";
6
+ minHeight: ({ spacing }: Theme) => string;
7
+ background: ({ palette }: Theme) => string;
8
+ backgroundSize: string;
9
+ backgroundClip: "text";
10
+ WebkitBackgroundClip: "text";
11
+ WebkitTextFillColor: "transparent";
12
+ animation: `${{
13
+ name: string;
14
+ styles: string;
15
+ anim: 1;
16
+ toString: () => string;
17
+ } & string} 2s ease-in-out infinite`;
18
+ animationDuration: "2s";
19
+ };
20
+ loader: {
21
+ display: "flex";
22
+ alignItems: "center";
23
+ justifyContent: "center";
24
+ position: "relative";
25
+ p: number;
26
+ };
27
+ loaderOuterCircle: {
28
+ position: "absolute";
29
+ inset: number;
30
+ margin: string;
31
+ borderRadius: string;
32
+ backgroundColor: ({ palette }: Theme) => string;
33
+ animation: `${{
34
+ name: string;
35
+ styles: string;
36
+ anim: 1;
37
+ toString: () => string;
38
+ } & string} 1s ease-in-out infinite`;
39
+ };
40
+ loaderInnerCircle: {
41
+ position: "absolute";
42
+ inset: number;
43
+ margin: string;
44
+ borderRadius: string;
45
+ backgroundColor: ({ palette }: Theme) => string;
46
+ animation: `${{
47
+ name: string;
48
+ styles: string;
49
+ anim: 1;
50
+ toString: () => string;
51
+ } & string} 1s ease-in-out infinite`;
52
+ };
53
+ tools: {
54
+ width: string;
55
+ };
56
+ toolHeader: {
57
+ display: "flex";
58
+ alignItems: "center";
59
+ gap: ({ spacing }: Theme) => string;
60
+ };
61
+ toolStatusIcon: {
62
+ display: "flex";
63
+ alignItems: "center";
64
+ };
65
+ };
@@ -0,0 +1,16 @@
1
+ export type { ChatSxProps, ChatErrorAction, ChatUserMessageProps, ChatAgentMessageProps, ChatErrorMessageProps, ChatSuggestionButtonProps, ChatThinkingProps, ChatLoaderProps, ChatContentProps, ChatHeaderProps, ChatFooterProps, ChatStarterItem, ChatStarterProps, ChatActionsContainerProps, ChatRatingActionProps, ChatToolItem, ChatToolsProps, } from './types';
2
+ export { CHAT_MAX_WIDTH, CHAT_SCROLL_DELAY, CHAT_DIVIDER_DELAY } from './const';
3
+ export { ChatUserMessage } from './bubbles/chat-user-message';
4
+ export { ChatAgentMessage } from './bubbles/chat-agent-message';
5
+ export { ChatErrorMessage } from './bubbles/chat-error-message';
6
+ export { ChatSuggestionButton } from './bubbles/chat-suggestion-button';
7
+ export { ChatMessageOverflow } from './bubbles/styles';
8
+ export { ChatThinking } from './feedback/chat-thinking';
9
+ export { ChatLoader } from './feedback/chat-loader';
10
+ export { ChatContent } from './containers/chat-content';
11
+ export { ChatHeader } from './containers/chat-header';
12
+ export { ChatFooter } from './containers/chat-footer';
13
+ export { ChatStarter } from './containers/chat-starter';
14
+ export { ChatActionsContainer } from './feedback/chat-actions-container';
15
+ export { ChatRatingAction } from './feedback/chat-rating-action';
16
+ export { ChatTools } from './feedback/chat-tools';
@@ -0,0 +1,99 @@
1
+ import { ReactNode } from 'react';
2
+ import { ButtonBaseProps, SxProps, Theme } from '@mui/material';
3
+ export interface ChatSxProps {
4
+ sx?: SxProps<Theme>;
5
+ }
6
+ export interface ChatErrorAction {
7
+ label: string;
8
+ onClick: () => void;
9
+ }
10
+ export interface ChatUserMessageProps extends ChatSxProps {
11
+ children: ReactNode;
12
+ /** enabled to render text with a lighter color for indicating things like an error sending the message */
13
+ muted?: boolean;
14
+ /** content to render on top of the message for user attachments */
15
+ topContext?: ReactNode;
16
+ }
17
+ export interface ChatAgentMessageProps extends ChatSxProps {
18
+ children: ReactNode;
19
+ }
20
+ export interface ChatErrorMessageProps extends ChatSxProps {
21
+ errors: string[];
22
+ icon?: ReactNode;
23
+ actions?: ChatErrorAction[];
24
+ }
25
+ export interface ChatSuggestionButtonProps extends ChatSxProps, Omit<ButtonBaseProps, 'children'> {
26
+ label: ReactNode;
27
+ color?: string;
28
+ }
29
+ export interface ChatThinkingProps extends ChatSxProps {
30
+ duration?: number;
31
+ children?: ReactNode;
32
+ }
33
+ export interface ChatLoaderProps extends ChatSxProps {
34
+ size?: number;
35
+ labels?: {
36
+ loading?: string;
37
+ };
38
+ }
39
+ export interface ChatContentProps extends ChatSxProps {
40
+ children: ReactNode;
41
+ labels?: {
42
+ jumpToLatest?: string;
43
+ };
44
+ }
45
+ export interface ChatHeaderProps extends ChatSxProps {
46
+ leftSlot?: ReactNode;
47
+ title: ReactNode;
48
+ rightSlot?: ReactNode;
49
+ onClose?: () => void;
50
+ }
51
+ export interface ChatFooterProps extends ChatSxProps {
52
+ value: string;
53
+ onChange: (value: string) => void;
54
+ onSend: () => void;
55
+ onStop?: () => void;
56
+ isGenerating?: boolean;
57
+ disabled?: boolean;
58
+ placeholder?: string;
59
+ labels?: {
60
+ send?: string;
61
+ stop?: string;
62
+ };
63
+ caption?: ReactNode;
64
+ }
65
+ export interface ChatStarterItem {
66
+ label: string;
67
+ color?: string;
68
+ }
69
+ export interface ChatStarterProps extends ChatSxProps {
70
+ icon?: ReactNode;
71
+ title?: ReactNode;
72
+ description?: ReactNode;
73
+ items: string[] | ChatStarterItem[];
74
+ size?: 'small' | 'medium';
75
+ onSelect?: (prompt: string) => void;
76
+ }
77
+ export interface ChatActionsContainerProps extends ChatSxProps {
78
+ children: ReactNode;
79
+ }
80
+ export interface ChatRatingActionProps {
81
+ onRatingChange?: (rating: 'up' | 'down' | null) => void;
82
+ rating?: 'up' | 'down' | null;
83
+ labels?: {
84
+ thumbUp?: string;
85
+ thumbDown?: string;
86
+ };
87
+ }
88
+ export interface ChatToolItem {
89
+ id: string;
90
+ name: string;
91
+ status: 'loading' | 'thinking' | 'complete' | 'error';
92
+ content?: ReactNode;
93
+ }
94
+ export interface ChatToolsProps extends ChatSxProps {
95
+ tools: ChatToolItem[];
96
+ labels?: {
97
+ title?: string;
98
+ };
99
+ }
@@ -0,0 +1,2 @@
1
+ import { CopyButtonProps } from './types';
2
+ export declare function CopyButton({ copyText, onSuccess, onError, 'aria-label': ariaLabel, ...props }: CopyButtonProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,6 @@
1
+ import { IconButtonProps } from '@mui/material/IconButton';
2
+ export interface CopyButtonProps extends Omit<IconButtonProps, 'onError' | 'onClick'> {
3
+ copyText: string;
4
+ onSuccess?: () => void;
5
+ onError?: (err: Error) => void;
6
+ }
@@ -18,3 +18,5 @@ export { BasemapsUI } from './basemaps/basemaps';
18
18
  export type { BasemapsUIProps } from './basemaps/types';
19
19
  export { Tooltip, setTooltipEnterDelay } from './tooltip/tooltip';
20
20
  export { SmartTooltip } from './smart-tooltip/smart-tooltip';
21
+ export type { CopyButtonProps } from './copy-button/types';
22
+ export { CopyButton } from './copy-button/copy-button';
@@ -6,10 +6,11 @@ import { FullscreenOutlined as Ne, Close as je, FileDownloadOutlined as Ue, Perc
6
6
  import { useShallow as te } from "zustand/shallow";
7
7
  import { useState as he, useRef as de, useEffect as K } from "react";
8
8
  import "react-markdown";
9
- import { a as Rn, d as Bn } from "../exports-Cr43OCul.js";
9
+ import { a as Bn, d as Mn } from "../exports-Cr43OCul.js";
10
10
  import "../lasso-tool-BYbxrJ-7.js";
11
11
  import "../cjs-D4KH3azB.js";
12
12
  import { T as ie } from "../tooltip-BDnrRKrp.js";
13
+ import "@carto/ps-utils";
13
14
  import { b as Xe, a as et, D as tt } from "../utils-idmvq0Oa.js";
14
15
  import { useSensors as nt, useSensor as Ie, PointerSensor as ot, KeyboardSensor as lt, DndContext as st, closestCenter as rt } from "@dnd-kit/core";
15
16
  import { useSortable as it, sortableKeyboardCoordinates as ct, arrayMove as at, SortableContext as dt, verticalListSortingStrategy as ut } from "@dnd-kit/sortable";
@@ -31,7 +32,7 @@ const Ce = {
31
32
  }) => n(1)
32
33
  }
33
34
  }, mt = {};
34
- function En(n) {
35
+ function Ln(n) {
35
36
  const e = q(47), {
36
37
  id: t,
37
38
  labels: a,
@@ -110,7 +111,7 @@ function gt(n) {
110
111
  return n.setWidget;
111
112
  }
112
113
  const pt = {};
113
- function Ln(n) {
114
+ function xn(n) {
114
115
  const e = q(33), {
115
116
  id: t,
116
117
  items: a,
@@ -215,7 +216,7 @@ function bt(n, e) {
215
216
  }));
216
217
  }
217
218
  const pe = "relative-data";
218
- function xn(n) {
219
+ function $n(n) {
219
220
  const e = q(32), {
220
221
  id: t,
221
222
  order: a,
@@ -305,7 +306,7 @@ const ye = {
305
306
  }
306
307
  }
307
308
  }, ee = "zoom-toggle";
308
- function $n(n) {
309
+ function On(n) {
309
310
  const e = q(50), {
310
311
  id: t,
311
312
  defaultZoom: a,
@@ -433,7 +434,7 @@ const wt = () => {
433
434
  let e;
434
435
  return n[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (e = /* @__PURE__ */ g("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ g("path", { d: "M4 20V8H8V20H4ZM9 20V13H13V20H9ZM16 20V4H20V20H16Z", fill: "currentColor" }) }), n[0] = e) : e = n[0], e;
435
436
  }, me = "stack-toggle";
436
- function On(n) {
437
+ function wn(n) {
437
438
  const e = q(47), {
438
439
  id: t,
439
440
  defaultIsStacked: a,
@@ -550,7 +551,7 @@ function Bt(n) {
550
551
  return n.setWidget;
551
552
  }
552
553
  const ae = "lock-selection";
553
- function wn(n) {
554
+ function Dn(n) {
554
555
  const e = q(36), {
555
556
  id: t,
556
557
  selectedItems: a,
@@ -628,7 +629,7 @@ function Nt(n, e) {
628
629
  }));
629
630
  }
630
631
  const ge = "searcher", jt = 300;
631
- function Dn(n) {
632
+ function Wn(n) {
632
633
  const e = q(44), {
633
634
  id: t,
634
635
  filterFn: a,
@@ -724,7 +725,7 @@ const Jt = (n, e) => {
724
725
  const t = e.toLowerCase();
725
726
  return Promise.resolve(n.map((a) => a.filter((p) => Object.values(p).some((c) => typeof c == "string" && c.toLowerCase().includes(t)))));
726
727
  };
727
- function Wn(n) {
728
+ function zn(n) {
728
729
  const e = q(23), {
729
730
  id: t,
730
731
  defaultEnabled: a,
@@ -809,7 +810,7 @@ function nn(n) {
809
810
  return `2px solid ${n.palette.primary.main}`;
810
811
  }
811
812
  const ke = "change-column";
812
- function zn(n) {
813
+ function Pn(n) {
813
814
  const e = q(50), {
814
815
  id: t,
815
816
  labels: a,
@@ -936,21 +937,21 @@ function an(n) {
936
937
  }
937
938
  export {
938
939
  ke as CHANGE_COLUMN_TOOL_ID,
939
- zn as ChangeColumn,
940
- Ln as Download,
941
- En as FullScreen,
940
+ Pn as ChangeColumn,
941
+ xn as Download,
942
+ Ln as FullScreen,
942
943
  ae as LOCK_SELECTION_TOOL_ID,
943
- wn as LockSelection,
944
+ Dn as LockSelection,
944
945
  pe as RELATIVE_DATA_TOOL_ID,
945
- xn as RelativeData,
946
+ $n as RelativeData,
946
947
  ge as SEARCHER_TOOL_ID,
947
948
  me as STACK_TOGGLE_TOOL_ID,
948
- Dn as Searcher,
949
- Wn as SearcherToggle,
950
- On as StackToggle,
949
+ Wn as Searcher,
950
+ zn as SearcherToggle,
951
+ wn as StackToggle,
951
952
  ee as ZOOM_TOGGLE_TOOL_ID,
952
- $n as ZoomToggle,
953
- Rn as downloadToCSV,
954
- Bn as downloadToPNG
953
+ On as ZoomToggle,
954
+ Bn as downloadToCSV,
955
+ Mn as downloadToPNG
955
956
  };
956
957
  //# sourceMappingURL=actions.js.map