@copilotkit/react-core 2.0.0-rc.7 → 2.0.0-rc.9
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/dist/{MarkdownRendererContext-B4Us6mwL.d.cts → MarkdownRendererContext-CS35epe1.d.mts} +17 -33
- package/dist/MarkdownRendererContext-CS35epe1.d.mts.map +1 -0
- package/dist/{MarkdownRendererContext-CRKFzsEB.d.mts → MarkdownRendererContext-CfTh92vk.d.cts} +17 -33
- package/dist/MarkdownRendererContext-CfTh92vk.d.cts.map +1 -0
- package/dist/{MarkdownSurfaces-S4wfUl3J.cjs → MarkdownSurfaces-Ije2ZQh0.cjs} +111 -89
- package/dist/MarkdownSurfaces-Ije2ZQh0.cjs.map +1 -0
- package/dist/{MarkdownSurfaces-Bd--93O1.mjs → MarkdownSurfaces-iFKorV2w.mjs} +95 -80
- package/dist/MarkdownSurfaces-iFKorV2w.mjs.map +1 -0
- package/dist/context.cjs +20 -17
- package/dist/context.cjs.map +1 -1
- package/dist/context.d.cts +38 -98
- package/dist/context.d.cts.map +1 -1
- package/dist/context.d.mts +38 -98
- package/dist/context.d.mts.map +1 -1
- package/dist/context.mjs +20 -17
- package/dist/context.mjs.map +1 -1
- package/dist/generative-ui.cjs +541 -520
- package/dist/generative-ui.cjs.map +1 -1
- package/dist/generative-ui.d.cts +2137 -4178
- package/dist/generative-ui.d.cts.map +1 -1
- package/dist/generative-ui.d.mts +2137 -4178
- package/dist/generative-ui.d.mts.map +1 -1
- package/dist/generative-ui.mjs +37 -17
- package/dist/generative-ui.mjs.map +1 -1
- package/dist/headless.cjs +50 -76
- package/dist/headless.cjs.map +1 -1
- package/dist/headless.d.cts +78 -253
- package/dist/headless.d.cts.map +1 -1
- package/dist/headless.d.mts +56 -202
- package/dist/headless.d.mts.map +1 -1
- package/dist/headless.mjs +43 -74
- package/dist/headless.mjs.map +1 -1
- package/dist/index.cjs +765 -1292
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +176 -518
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +175 -517
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +469 -1251
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +867 -1375
- package/dist/index.umd.js.map +1 -1
- package/package.json +15 -16
- package/dist/MarkdownRendererContext-B4Us6mwL.d.cts.map +0 -1
- package/dist/MarkdownRendererContext-CRKFzsEB.d.mts.map +0 -1
- package/dist/MarkdownSurfaces-Bd--93O1.mjs.map +0 -1
- package/dist/MarkdownSurfaces-S4wfUl3J.cjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generative-ui.d.mts","names":[],"sources":["../src/generative-ui/refs.ts","../src/generative-ui/catalog-export.ts","../src/generative-ui/GenerativeUISurface.tsx","../src/generative-ui/markdown/MarkdownSurfaces.tsx","../src/generative-ui/hooks.ts","../src/generative-ui/standard/index.ts"],"mappings":";;;;;;;;;;;;;iBAgCgB,KAAA,CAAM,WAAA,YAAoB,CAAA,CAAA,
|
|
1
|
+
{"version":3,"file":"generative-ui.d.mts","names":[],"sources":["../src/generative-ui/refs.ts","../src/generative-ui/catalog-export.ts","../src/generative-ui/GenerativeUISurface.tsx","../src/generative-ui/markdown/MarkdownSurfaces.tsx","../src/generative-ui/hooks.ts","../src/generative-ui/standard/index.ts"],"mappings":";;;;;;;;;;;;;iBAgCgB,KAAA,CAAM,WAAA,YAAoB,CAAA,CAAA,OAAA,CAAA,CAAA,CAAA,SAAA,EAAA,CAAA,CAAA,YAAA,sCAAA,KAAA,CAAA,YAAA,mBAAA,KAAA,CAAA,qBAAA,SAAA,QAAA,CAAA,SAAA,IAAA,KAAA,CAAA,WAAA;;;AAA1C;;;;iBAcgB,SAAA,CAAU,WAAA,YAAoB,CAAA,CAAA,OAAA,CAAA,CAAA,CAAA,QAAA,WAAA,CAAA,CAAA,QAAA,CAAA,CAAA,CAAA,SAAA,GAAA,CAAA,CAAA,SAAA;;;8GAA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AAoB,EAAA,WAAA,CACtC,EAAA,EAAI,EAAA,EAAI,GAAA,EAAK,GAAA,EAAK,KAAA,EAAO,UAAA,CAAW,EAAA,EAAI,GAAA;;;;;;;;;;;AJN1C;;;;;;;;;;;;iBIgEgB,uBAAA,YACH,YAAA,oBACE,wBAAA,CAAyB,EAAA,EAAA,CAEtC,EAAA,EAAI,EAAA,EACJ,IAAA,EAAM,IAAA,EACN,OAAA,GAAU,IAAA,EAAM,wBAAA,CAAyB,EAAA,EAAI,IAAA;;;;;;;;;;;;AJpF/C;;;;;;;;;;;;;;;cKuCa,UAAA;;;;;;cAGX,CAAA,CAAA,SAAA"}
|
package/dist/generative-ui.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { A as GenerativeUIError, F as toJsonSchema, P as createGenerativeUI, _ as GenerativeUINodeContext, b as useRequiredGenerativeUIRuntime, c as SurfaceView, d as namedRole, f as useGenerativeUIAccessibility, g as useManagerVersion, h as useGenerativeUIState, j as isRecord, l as DARK_THEME_CSS, m as useGenerativeUIFunction, n as ProviderMarkdown, p as wrapperAria, r as DefaultGenerativeUIChatCard, t as MarkdownSurfaces, u as controlAria, y as useGenerativeUIRuntime } from "./MarkdownSurfaces-
|
|
3
|
+
import { A as GenerativeUIError, F as toJsonSchema, K as IconSvg, P as createGenerativeUI, _ as GenerativeUINodeContext, b as useRequiredGenerativeUIRuntime, c as SurfaceView, d as namedRole, f as useGenerativeUIAccessibility, g as useManagerVersion, h as useGenerativeUIState, j as isRecord, l as DARK_THEME_CSS, m as useGenerativeUIFunction, n as ProviderMarkdown, p as wrapperAria, r as DefaultGenerativeUIChatCard, t as MarkdownSurfaces, u as controlAria, y as useGenerativeUIRuntime } from "./MarkdownSurfaces-iFKorV2w.mjs";
|
|
4
4
|
import React, { Suspense, createContext, isValidElement, memo, useCallback, useContext, useEffect, useId, useInsertionEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
5
5
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
import { A2UI_CHILD_LIST_MARK, A2UI_CHILD_LIST_REF, A2UI_COMPONENT_ID_MARK, A2UI_COMPONENT_ID_REF, GENERATIVE_UI_FUNCTIONS, GENERATIVE_UI_MAX_TARGET_COMPONENTS, childRefKind, functionCallers } from "@copilotkit/shared";
|
|
7
|
-
import
|
|
7
|
+
import * as z from "zod";
|
|
8
8
|
import { createPortal } from "react-dom";
|
|
9
9
|
|
|
10
10
|
//#region src/generative-ui/refs.ts
|
|
@@ -2290,10 +2290,14 @@ const ICON_STROKE = {
|
|
|
2290
2290
|
function kebabToPascal(name) {
|
|
2291
2291
|
return name.split(/[-_\s]+/).filter(Boolean).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("");
|
|
2292
2292
|
}
|
|
2293
|
+
/** "ArrowRight" gives "arrow-right", as Lucide names its icon classes. */
|
|
2294
|
+
function pascalToKebab(name) {
|
|
2295
|
+
return name.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
2296
|
+
}
|
|
2293
2297
|
let lucidePromise = null;
|
|
2294
2298
|
let lucideIcons = null;
|
|
2295
2299
|
function loadLucideIcons() {
|
|
2296
|
-
lucidePromise ??= import("lucide
|
|
2300
|
+
lucidePromise ??= import("lucide").then((module) => {
|
|
2297
2301
|
const icons = module.icons;
|
|
2298
2302
|
lucideIcons = icons;
|
|
2299
2303
|
return icons;
|
|
@@ -2301,9 +2305,9 @@ function loadLucideIcons() {
|
|
|
2301
2305
|
return lucidePromise;
|
|
2302
2306
|
}
|
|
2303
2307
|
/**
|
|
2304
|
-
*
|
|
2305
|
-
*
|
|
2306
|
-
*
|
|
2308
|
+
* Lucide has about 1,500 icons. A static import of its `icons` map puts all
|
|
2309
|
+
* of them in every bundle and makes module load slow. So the map loads once,
|
|
2310
|
+
* on first use, and the icons show when it is there.
|
|
2307
2311
|
*/
|
|
2308
2312
|
function useLucideIcons() {
|
|
2309
2313
|
const [icons, setIcons] = useState(lucideIcons);
|
|
@@ -2319,6 +2323,20 @@ function useLucideIcons() {
|
|
|
2319
2323
|
}, []);
|
|
2320
2324
|
return icons;
|
|
2321
2325
|
}
|
|
2326
|
+
/** The icon for a kebab-case or PascalCase name, or `null` when there is none. */
|
|
2327
|
+
function findLucideIcon(icons, name) {
|
|
2328
|
+
const pascalName = kebabToPascal(name);
|
|
2329
|
+
const key = pascalName in icons ? pascalName : name in icons ? name : null;
|
|
2330
|
+
if (key === null) return null;
|
|
2331
|
+
const nodes = icons[key].map(([tag, attributes]) => ({
|
|
2332
|
+
tag,
|
|
2333
|
+
attributes
|
|
2334
|
+
}));
|
|
2335
|
+
return {
|
|
2336
|
+
lucideName: pascalToKebab(key),
|
|
2337
|
+
nodes
|
|
2338
|
+
};
|
|
2339
|
+
}
|
|
2322
2340
|
/**
|
|
2323
2341
|
* A lucide icon by kebab-case (or PascalCase) name. An unknown name renders
|
|
2324
2342
|
* nothing. Without a `label`, the icon is hidden from screen readers.
|
|
@@ -2331,18 +2349,20 @@ function useLucideIcons() {
|
|
|
2331
2349
|
function LucideIcon({ name, label, description, size = "md", color, weight, inline, style }) {
|
|
2332
2350
|
const icons = useLucideIcons();
|
|
2333
2351
|
if (!name || !icons) return null;
|
|
2334
|
-
const
|
|
2335
|
-
if (!
|
|
2352
|
+
const icon = findLucideIcon(icons, name);
|
|
2353
|
+
if (!icon) return null;
|
|
2336
2354
|
const pixels = typeof size === "number" ? size : inline ? "1em" : ICON_PX$1[size];
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2355
|
+
const a11y = label === void 0 ? { "aria-hidden": true } : {
|
|
2356
|
+
role: "img",
|
|
2357
|
+
"aria-label": label,
|
|
2358
|
+
"aria-description": description
|
|
2359
|
+
};
|
|
2360
|
+
return /* @__PURE__ */ jsx(IconSvg, {
|
|
2361
|
+
lucideName: icon.lucideName,
|
|
2362
|
+
nodes: icon.nodes,
|
|
2363
|
+
...a11y,
|
|
2343
2364
|
focusable: "false",
|
|
2344
|
-
|
|
2345
|
-
height: pixels,
|
|
2365
|
+
size: pixels,
|
|
2346
2366
|
color: textColor(color) ?? "currentColor",
|
|
2347
2367
|
strokeWidth: weight ? ICON_STROKE[weight] : void 0,
|
|
2348
2368
|
style: {
|
|
@@ -5648,7 +5668,7 @@ const validationResult = z.object({
|
|
|
5648
5668
|
message: z.string().optional(),
|
|
5649
5669
|
code: z.string().optional(),
|
|
5650
5670
|
severity: severity.optional()
|
|
5651
|
-
}).
|
|
5671
|
+
}).loose();
|
|
5652
5672
|
const checksProp = z.array(z.object({
|
|
5653
5673
|
condition: z.union([z.boolean(), validationResult]).optional().describe("A validator call, for example {\"@call\":\"required\",\"args\":{\"value\":{\"@path\":\"/x\"}}}, or a boolean binding"),
|
|
5654
5674
|
message: z.string().optional().describe("Shown when the check fails, instead of the default message")
|