@copilotkit/web-components 1.62.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 (49) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +90 -0
  3. package/dist/index.cjs +12 -0
  4. package/dist/index.d.cts +7 -0
  5. package/dist/index.d.mts +7 -0
  6. package/dist/index.mjs +7 -0
  7. package/dist/index.umd.js +2548 -0
  8. package/dist/index.umd.js.map +1 -0
  9. package/dist/threads-drawer/copilotkit-threads-drawer.cjs +677 -0
  10. package/dist/threads-drawer/copilotkit-threads-drawer.cjs.map +1 -0
  11. package/dist/threads-drawer/copilotkit-threads-drawer.d.cts +182 -0
  12. package/dist/threads-drawer/copilotkit-threads-drawer.d.cts.map +1 -0
  13. package/dist/threads-drawer/copilotkit-threads-drawer.d.mts +182 -0
  14. package/dist/threads-drawer/copilotkit-threads-drawer.d.mts.map +1 -0
  15. package/dist/threads-drawer/copilotkit-threads-drawer.mjs +676 -0
  16. package/dist/threads-drawer/copilotkit-threads-drawer.mjs.map +1 -0
  17. package/dist/threads-drawer/define.cjs +15 -0
  18. package/dist/threads-drawer/define.cjs.map +1 -0
  19. package/dist/threads-drawer/define.d.cts +17 -0
  20. package/dist/threads-drawer/define.d.cts.map +1 -0
  21. package/dist/threads-drawer/define.d.mts +17 -0
  22. package/dist/threads-drawer/define.d.mts.map +1 -0
  23. package/dist/threads-drawer/define.mjs +15 -0
  24. package/dist/threads-drawer/define.mjs.map +1 -0
  25. package/dist/threads-drawer/generated-tokens.cjs +33 -0
  26. package/dist/threads-drawer/generated-tokens.cjs.map +1 -0
  27. package/dist/threads-drawer/generated-tokens.d.cts +32 -0
  28. package/dist/threads-drawer/generated-tokens.d.cts.map +1 -0
  29. package/dist/threads-drawer/generated-tokens.d.mts +32 -0
  30. package/dist/threads-drawer/generated-tokens.d.mts.map +1 -0
  31. package/dist/threads-drawer/generated-tokens.mjs +32 -0
  32. package/dist/threads-drawer/generated-tokens.mjs.map +1 -0
  33. package/dist/threads-drawer/index.cjs +11 -0
  34. package/dist/threads-drawer/index.d.cts +6 -0
  35. package/dist/threads-drawer/index.d.mts +6 -0
  36. package/dist/threads-drawer/index.mjs +6 -0
  37. package/dist/threads-drawer/styles.cjs +499 -0
  38. package/dist/threads-drawer/styles.cjs.map +1 -0
  39. package/dist/threads-drawer/styles.d.cts +24 -0
  40. package/dist/threads-drawer/styles.d.cts.map +1 -0
  41. package/dist/threads-drawer/styles.d.mts +24 -0
  42. package/dist/threads-drawer/styles.d.mts.map +1 -0
  43. package/dist/threads-drawer/styles.mjs +499 -0
  44. package/dist/threads-drawer/styles.mjs.map +1 -0
  45. package/dist/threads-drawer/types.d.cts +97 -0
  46. package/dist/threads-drawer/types.d.cts.map +1 -0
  47. package/dist/threads-drawer/types.d.mts +97 -0
  48. package/dist/threads-drawer/types.d.mts.map +1 -0
  49. package/package.json +85 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) Atai Barkai
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,90 @@
1
+ # @copilotkit/web-components
2
+
3
+ Framework-agnostic, shadow-DOM [Lit](https://lit.dev) custom elements for CopilotKit.
4
+
5
+ This package currently ships **`<copilotkit-threads-drawer>`** — a public, self-contained,
6
+ controlled threads drawer. It is a pure **VIEW**: domain data flows in as
7
+ properties and user intent flows out as DOM `CustomEvent`s. It imports no React,
8
+ Angular, or `@copilotkit/core` code and renders correctly in any host page,
9
+ surviving hostile host CSS (`all: unset`, Tailwind preflight `!important`).
10
+
11
+ ## Install
12
+
13
+ ```bash
14
+ npm install @copilotkit/web-components lit
15
+ ```
16
+
17
+ `lit` is a peer/runtime dependency so the host dedupes a single Lit runtime.
18
+
19
+ ## Usage
20
+
21
+ ```ts
22
+ import { defineCopilotKitThreadsDrawer } from "@copilotkit/web-components/threads-drawer";
23
+
24
+ defineCopilotKitThreadsDrawer(); // registers <copilotkit-threads-drawer> (idempotent)
25
+ ```
26
+
27
+ ```html
28
+ <copilotkit-threads-drawer active-thread-id="t-123"></copilotkit-threads-drawer>
29
+ <script>
30
+ const drawer = document.querySelector("copilotkit-threads-drawer");
31
+ drawer.threads = [
32
+ {
33
+ id: "t-123",
34
+ name: "My thread",
35
+ archived: false,
36
+ createdAt: "...",
37
+ updatedAt: "...",
38
+ },
39
+ ];
40
+ drawer.addEventListener("thread-selected", (e) => open(e.detail.threadId));
41
+ drawer.addEventListener("new-thread", () => createThread());
42
+ </script>
43
+ ```
44
+
45
+ ### Inbound properties (DOMAIN state — owned by the consumer)
46
+
47
+ | property | type | notes |
48
+ | ---------------- | ---------------- | ----------------------------------------------- |
49
+ | `threads` | `DrawerThread[]` | the element re-orders + filters authoritatively |
50
+ | `loading` | `boolean` | initial-fetch loading |
51
+ | `error` | `string \| null` | initial-fetch error → actionable Retry |
52
+ | `activeThreadId` | `string \| null` | drives selection highlight |
53
+ | `licensed` | `boolean` | `false` → upsell replaces the list |
54
+ | `fetchingMore` | `boolean` | in-flight pagination |
55
+ | `fetchMoreError` | `string \| null` | inline "couldn't load more — retry" |
56
+ | `open` | `boolean` | externally controllable (mobile coordination) |
57
+ | `collapsed` | `boolean` | desktop collapse-to-rail |
58
+
59
+ ### Outbound events (INTENT — bubbling + composed `CustomEvent`s)
60
+
61
+ `thread-selected`, `archive`, `unarchive`, `delete` (after in-element confirm),
62
+ `new-thread`, `filter-change`, `open-change`, `retry` (`{ scope }`), `upsell`.
63
+
64
+ The element owns VIEW state: open/collapsed, the Active/All filter, the
65
+ confirm-delete dialog, and per-row entry/reveal animations.
66
+
67
+ ## Theming (hybrid)
68
+
69
+ - **CSS variables** pierce the shadow boundary — set `--cpk-drawer-*`
70
+ (`-bg`, `-fg`, `-surface`, `-accent`, `-primary`, `-danger`, `-border`,
71
+ `-ring`, `-radius`, `-width`, `-rail-width`, `-font-family`, …) from the host.
72
+ - **`::part()`** hooks on structural nodes (`root`, `header`, `list`, `row`,
73
+ `row-name`, `confirm-dialog`, `backdrop`, …).
74
+ - **Named slots**: `header`, `footer`, `empty`, `upsell`, `memories`, plus a
75
+ **per-row slot** `row:{id}` that projects wrapper-provided row content while
76
+ the element keeps the selection/archived/animation chrome around it.
77
+
78
+ The built-in default skin's token values are **derived at build time** from
79
+ react-core's canonical theme (`packages/react-core/src/v2/styles/globals.css`)
80
+ by `scripts/generate-tokens.ts`, which writes the checked-in
81
+ `src/threads-drawer/generated-tokens.ts`. Run `pnpm run gen:tokens` to regenerate;
82
+ `generated-tokens.test.ts` fails if the checked-in values drift from react-core.
83
+
84
+ ## Mobile + a11y
85
+
86
+ At/below `768px` the drawer is an off-canvas modal overlay with backdrop,
87
+ `Escape` close, scroll-lock, and a focus trap (mobile only) that operates over
88
+ the composed/flattened tree so slotted rows are included. On desktop it is an
89
+ in-flow region with collapse-to-rail — **not** a modal (no focus trap, no
90
+ scroll-lock).
package/dist/index.cjs ADDED
@@ -0,0 +1,12 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_generated_tokens = require('./threads-drawer/generated-tokens.cjs');
3
+ const require_styles = require('./threads-drawer/styles.cjs');
4
+ const require_copilotkit_threads_drawer = require('./threads-drawer/copilotkit-threads-drawer.cjs');
5
+ const require_define = require('./threads-drawer/define.cjs');
6
+ require('./threads-drawer/index.cjs');
7
+
8
+ exports.COPILOTKIT_THREADS_DRAWER_TAG = require_copilotkit_threads_drawer.COPILOTKIT_THREADS_DRAWER_TAG;
9
+ exports.CopilotKitThreadsDrawer = require_copilotkit_threads_drawer.CopilotKitThreadsDrawer;
10
+ exports.GENERATED_DRAWER_TOKEN_DEFAULTS = require_generated_tokens.GENERATED_DRAWER_TOKEN_DEFAULTS;
11
+ exports.defineCopilotKitThreadsDrawer = require_define.defineCopilotKitThreadsDrawer;
12
+ exports.drawerStyles = require_styles.drawerStyles;
@@ -0,0 +1,7 @@
1
+ import { ArchiveDetail, CopilotKitThreadsDrawerEventMap, DeleteDetail, DrawerFilter, DrawerThread, FilterChangeDetail, LicensedDetail, LoadMoreDetail, NewThreadDetail, OpenChangeDetail, RetryDetail, ThreadSelectedDetail, UnarchiveDetail } from "./threads-drawer/types.cjs";
2
+ import { COPILOTKIT_THREADS_DRAWER_TAG, CopilotKitThreadsDrawer } from "./threads-drawer/copilotkit-threads-drawer.cjs";
3
+ import { defineCopilotKitThreadsDrawer } from "./threads-drawer/define.cjs";
4
+ import { drawerStyles } from "./threads-drawer/styles.cjs";
5
+ import { GENERATED_DRAWER_TOKEN_DEFAULTS, GeneratedDrawerTokenKey } from "./threads-drawer/generated-tokens.cjs";
6
+ import "./threads-drawer/index.cjs";
7
+ export { ArchiveDetail, COPILOTKIT_THREADS_DRAWER_TAG, CopilotKitThreadsDrawer, CopilotKitThreadsDrawerEventMap, DeleteDetail, DrawerFilter, DrawerThread, FilterChangeDetail, GENERATED_DRAWER_TOKEN_DEFAULTS, GeneratedDrawerTokenKey, LicensedDetail, LoadMoreDetail, NewThreadDetail, OpenChangeDetail, RetryDetail, ThreadSelectedDetail, UnarchiveDetail, defineCopilotKitThreadsDrawer, drawerStyles };
@@ -0,0 +1,7 @@
1
+ import { ArchiveDetail, CopilotKitThreadsDrawerEventMap, DeleteDetail, DrawerFilter, DrawerThread, FilterChangeDetail, LicensedDetail, LoadMoreDetail, NewThreadDetail, OpenChangeDetail, RetryDetail, ThreadSelectedDetail, UnarchiveDetail } from "./threads-drawer/types.mjs";
2
+ import { COPILOTKIT_THREADS_DRAWER_TAG, CopilotKitThreadsDrawer } from "./threads-drawer/copilotkit-threads-drawer.mjs";
3
+ import { defineCopilotKitThreadsDrawer } from "./threads-drawer/define.mjs";
4
+ import { drawerStyles } from "./threads-drawer/styles.mjs";
5
+ import { GENERATED_DRAWER_TOKEN_DEFAULTS, GeneratedDrawerTokenKey } from "./threads-drawer/generated-tokens.mjs";
6
+ import "./threads-drawer/index.mjs";
7
+ export { ArchiveDetail, COPILOTKIT_THREADS_DRAWER_TAG, CopilotKitThreadsDrawer, CopilotKitThreadsDrawerEventMap, DeleteDetail, DrawerFilter, DrawerThread, FilterChangeDetail, GENERATED_DRAWER_TOKEN_DEFAULTS, GeneratedDrawerTokenKey, LicensedDetail, LoadMoreDetail, NewThreadDetail, OpenChangeDetail, RetryDetail, ThreadSelectedDetail, UnarchiveDetail, defineCopilotKitThreadsDrawer, drawerStyles };
package/dist/index.mjs ADDED
@@ -0,0 +1,7 @@
1
+ import { GENERATED_DRAWER_TOKEN_DEFAULTS } from "./threads-drawer/generated-tokens.mjs";
2
+ import { drawerStyles } from "./threads-drawer/styles.mjs";
3
+ import { COPILOTKIT_THREADS_DRAWER_TAG, CopilotKitThreadsDrawer } from "./threads-drawer/copilotkit-threads-drawer.mjs";
4
+ import { defineCopilotKitThreadsDrawer } from "./threads-drawer/define.mjs";
5
+ import "./threads-drawer/index.mjs";
6
+
7
+ export { COPILOTKIT_THREADS_DRAWER_TAG, CopilotKitThreadsDrawer, GENERATED_DRAWER_TOKEN_DEFAULTS, defineCopilotKitThreadsDrawer, drawerStyles };