@gram-ai/elements 1.20.2 → 1.21.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.
Files changed (74) hide show
  1. package/bin/cli.js +14 -12
  2. package/dist/components/Chat/stories/ConnectionConfiguration.stories.d.ts +2 -2
  3. package/dist/components/Chat/stories/ToolApproval.stories.d.ts +2 -0
  4. package/dist/components/ui/dialog.d.ts +1 -1
  5. package/dist/components/ui/tooltip.d.ts +3 -1
  6. package/dist/constants/tailwind.d.ts +1 -0
  7. package/dist/contexts/portal-container-context.d.ts +2 -0
  8. package/dist/contexts/portal-container.d.ts +7 -0
  9. package/dist/elements.cjs +1 -160
  10. package/dist/elements.cjs.map +1 -1
  11. package/dist/elements.css +1 -1
  12. package/dist/elements.js +11 -47215
  13. package/dist/elements.js.map +1 -1
  14. package/dist/hooks/usePortalContainer.d.ts +8 -0
  15. package/dist/hooks/useSession.d.ts +1 -2
  16. package/dist/index-BVvrv2G3.cjs +169 -0
  17. package/dist/index-BVvrv2G3.cjs.map +1 -0
  18. package/dist/index-OU3wjArm.js +54670 -0
  19. package/dist/index-OU3wjArm.js.map +1 -0
  20. package/dist/index.d.ts +3 -1
  21. package/dist/lib/auth.d.ts +2 -2
  22. package/dist/lib/errorTracking.config.d.ts +16 -0
  23. package/dist/lib/errorTracking.d.ts +24 -0
  24. package/dist/lib/tools.d.ts +3 -2
  25. package/dist/profiler-DPH9zydw.cjs +2 -0
  26. package/dist/profiler-DPH9zydw.cjs.map +1 -0
  27. package/dist/profiler-D_HNXmyv.js +278 -0
  28. package/dist/profiler-D_HNXmyv.js.map +1 -0
  29. package/dist/startRecording-B97e4Mlu.cjs +3 -0
  30. package/dist/startRecording-B97e4Mlu.cjs.map +1 -0
  31. package/dist/startRecording-DOMzQAAr.js +1212 -0
  32. package/dist/startRecording-DOMzQAAr.js.map +1 -0
  33. package/dist/types/index.d.ts +45 -15
  34. package/package.json +16 -2
  35. package/src/components/Chat/index.tsx +31 -3
  36. package/src/components/Chat/stories/Composer.stories.tsx +0 -7
  37. package/src/components/Chat/stories/ConnectionConfiguration.stories.tsx +7 -14
  38. package/src/components/Chat/stories/CustomComponents.stories.tsx +0 -7
  39. package/src/components/Chat/stories/Density.stories.tsx +0 -7
  40. package/src/components/Chat/stories/ErrorBoundary.stories.tsx +4 -23
  41. package/src/components/Chat/stories/FrontendTools.stories.tsx +0 -7
  42. package/src/components/Chat/stories/Model.stories.tsx +0 -7
  43. package/src/components/Chat/stories/Plugins.stories.tsx +0 -7
  44. package/src/components/Chat/stories/Radius.stories.tsx +0 -7
  45. package/src/components/Chat/stories/ToolApproval.stories.tsx +51 -7
  46. package/src/components/Chat/stories/Tools.stories.tsx +0 -7
  47. package/src/components/Chat/stories/Variants.stories.tsx +5 -2
  48. package/src/components/Chat/stories/Welcome.stories.tsx +0 -8
  49. package/src/components/assistant-ui/assistant-sidecar.tsx +1 -4
  50. package/src/components/assistant-ui/attachment.tsx +1 -4
  51. package/src/components/assistant-ui/error-boundary.tsx +6 -0
  52. package/src/components/assistant-ui/thread-list.tsx +3 -1
  53. package/src/components/assistant-ui/thread.tsx +10 -12
  54. package/src/components/ui/dialog.tsx +10 -1
  55. package/src/components/ui/popover.tsx +10 -12
  56. package/src/components/ui/tooltip.tsx +7 -2
  57. package/src/constants/tailwind.ts +2 -0
  58. package/src/contexts/ElementsProvider.tsx +13 -1
  59. package/src/contexts/portal-container-context.ts +4 -0
  60. package/src/contexts/portal-container.tsx +20 -0
  61. package/src/global.css +129 -16
  62. package/src/hooks/useAuth.ts +6 -16
  63. package/src/hooks/usePortalContainer.ts +16 -0
  64. package/src/hooks/useSession.ts +1 -3
  65. package/src/index.ts +5 -0
  66. package/src/lib/api.test.ts +5 -5
  67. package/src/lib/auth.ts +4 -4
  68. package/src/lib/errorTracking.config.ts +16 -0
  69. package/src/lib/errorTracking.ts +104 -0
  70. package/src/lib/tools.ts +37 -8
  71. package/src/types/index.ts +48 -16
  72. package/src/vite-env.d.ts +3 -0
  73. package/dist/components/Chat/stories/ColorScheme.stories.d.ts +0 -8
  74. package/src/components/Chat/stories/ColorScheme.stories.tsx +0 -52
package/bin/cli.js CHANGED
@@ -1,8 +1,9 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  import { execSync } from 'node:child_process'
4
- import { existsSync } from 'node:fs'
5
- import { resolve } from 'node:path'
4
+ import { existsSync, readFileSync } from 'node:fs'
5
+ import { resolve, dirname } from 'node:path'
6
+ import { fileURLToPath } from 'node:url'
6
7
 
7
8
  // Colors
8
9
  const c = {
@@ -20,15 +21,14 @@ const c = {
20
21
  white: '\x1b[37m',
21
22
  }
22
23
 
23
- const PEER_DEPS = [
24
- 'react',
25
- 'react-dom',
26
- 'motion',
27
- 'remark-gfm',
28
- 'zustand',
29
- 'vega',
30
- 'shiki',
31
- ]
24
+ // Read peer dependencies from package.json (excluding @types/* packages)
25
+ const __dirname = dirname(fileURLToPath(import.meta.url))
26
+ const packageJson = JSON.parse(
27
+ readFileSync(resolve(__dirname, '../package.json'), 'utf-8')
28
+ )
29
+ const PEER_DEPS = Object.keys(packageJson.peerDependencies || {}).filter(
30
+ (dep) => !dep.startsWith('@types/')
31
+ )
32
32
 
33
33
  const PACKAGE_NAME = '@gram-ai/elements'
34
34
 
@@ -110,7 +110,9 @@ ${c.dim}Package manager:${c.reset} ${c.cyan}${pm}${c.reset}
110
110
  `)
111
111
 
112
112
  // Install everything in one command
113
- console.log(`${c.yellow}○${c.reset} Installing ${c.cyan}@gram-ai/elements${c.reset} and peer dependencies...`)
113
+ console.log(
114
+ `${c.yellow}○${c.reset} Installing ${c.cyan}@gram-ai/elements${c.reset} and peer dependencies...`
115
+ )
114
116
  const allPackages = [...PEER_DEPS, PACKAGE_NAME]
115
117
  const cmd = getInstallCommand(pm, allPackages)
116
118
  if (!run(cmd)) {
@@ -1,10 +1,10 @@
1
- import { Chat } from '..';
2
1
  import { Meta, StoryFn } from '@storybook/react-vite';
2
+ import { Chat } from '..';
3
3
  declare const meta: Meta<typeof Chat>;
4
4
  export default meta;
5
5
  type Story = StoryFn<typeof Chat>;
6
6
  export declare const SystemPrompt: Story;
7
7
  export declare const WithImplicitSessionAuth: Story;
8
8
  export declare const WithExplicitSessionAuth: Story;
9
- export declare const WithExplicitAPIKeyAuth: Story;
9
+ export declare const WithStaticSessionAuth: Story;
10
10
  export declare const LanguageModel: Story;
@@ -4,5 +4,7 @@ declare const meta: Meta<typeof Chat>;
4
4
  export default meta;
5
5
  type Story = StoryFn<typeof Chat>;
6
6
  export declare const SingleTool: Story;
7
+ export declare const SingleToolWithFunction: Story;
7
8
  export declare const MultipleGroupedTools: Story;
8
9
  export declare const FrontendTool: Story;
10
+ export declare const FrontendToolWithFunction: Story;
@@ -2,7 +2,7 @@ import * as React from 'react';
2
2
  import * as DialogPrimitive from '@radix-ui/react-dialog';
3
3
  declare function Dialog({ ...props }: React.ComponentProps<typeof DialogPrimitive.Root>): import("react/jsx-runtime").JSX.Element;
4
4
  declare function DialogTrigger({ ...props }: React.ComponentProps<typeof DialogPrimitive.Trigger>): import("react/jsx-runtime").JSX.Element;
5
- declare function DialogPortal({ ...props }: React.ComponentProps<typeof DialogPrimitive.Portal>): import("react/jsx-runtime").JSX.Element;
5
+ declare function DialogPortal({ container, ...props }: React.ComponentProps<typeof DialogPrimitive.Portal>): import("react/jsx-runtime").JSX.Element;
6
6
  declare function DialogClose({ ...props }: React.ComponentProps<typeof DialogPrimitive.Close>): import("react/jsx-runtime").JSX.Element;
7
7
  declare function DialogOverlay({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Overlay>): import("react/jsx-runtime").JSX.Element;
8
8
  declare function DialogContent({ className, children, showCloseButton, ...props }: React.ComponentProps<typeof DialogPrimitive.Content> & {
@@ -3,5 +3,7 @@ import * as TooltipPrimitive from '@radix-ui/react-tooltip';
3
3
  declare function TooltipProvider({ delayDuration, ...props }: React.ComponentProps<typeof TooltipPrimitive.Provider>): import("react/jsx-runtime").JSX.Element;
4
4
  declare function Tooltip({ ...props }: React.ComponentProps<typeof TooltipPrimitive.Root>): import("react/jsx-runtime").JSX.Element;
5
5
  declare function TooltipTrigger({ ...props }: React.ComponentProps<typeof TooltipPrimitive.Trigger>): import("react/jsx-runtime").JSX.Element;
6
- declare function TooltipContent({ className, sideOffset, children, ...props }: React.ComponentProps<typeof TooltipPrimitive.Content>): import("react/jsx-runtime").JSX.Element;
6
+ declare function TooltipContent({ className, sideOffset, children, container, ...props }: React.ComponentProps<typeof TooltipPrimitive.Content> & {
7
+ container?: HTMLElement | null;
8
+ }): import("react/jsx-runtime").JSX.Element;
7
9
  export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider };
@@ -0,0 +1 @@
1
+ export declare const ROOT_SELECTOR = "gram-elements";
@@ -0,0 +1,2 @@
1
+ import { RefObject } from 'react';
2
+ export declare const PortalContainerContext: import('react').Context<RefObject<HTMLElement | null> | null>;
@@ -0,0 +1,7 @@
1
+ import { RefObject } from 'react';
2
+ import { PortalContainerContext } from './portal-container-context';
3
+ export { PortalContainerContext };
4
+ export declare function PortalContainerProvider({ containerRef, children, }: {
5
+ containerRef: RefObject<HTMLElement | null>;
6
+ children: React.ReactNode;
7
+ }): import("react/jsx-runtime").JSX.Element;