@copilotkit/react-core 1.89.0 → 1.90.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.
@@ -1,5 +1,5 @@
1
1
  import { C as createGenerativeUI, D as DefaultGenerativeUIChatCard, E as useGenerativeUIAccessibility, O as GenerativeUIChatSurfaceProps, S as GenerativeUIStateOf, T as GenerativeUIAriaAttributes, _ as GenerativeUIFunctionArgs, b as GenerativeUIFunctionName, c as useGenerativeUIRuntime, d as GenerativeUI, f as GenerativeUIComponentDefinition, g as GenerativeUIEventDefinition, m as GenerativeUIComponentProps, n as GenerativeUIErrorBoundaryConfig, o as GenerativeUITheme, p as GenerativeUIComponentName, r as GenerativeUIMarkdownConfig, s as GenerativeUIToolConfig, t as GenerativeUIConfig, u as CreateGenerativeUIConfig, v as GenerativeUIFunctionDefinition, w as GenerativeUIAccessibility, x as GenerativeUISlotKind, y as GenerativeUIFunctionInput } from "../runtime-context-Da7T5vy4.cjs";
2
- import { a as childList, i as child, n as useGenerativeUIState, t as useGenerativeUIFunction } from "../hooks-CEFWIeKR.cjs";
2
+ import { a as childList, i as child, n as useGenerativeUIState, t as useGenerativeUIFunction } from "../hooks-DMSkcNOl.cjs";
3
3
  import * as react_jsx_runtime0 from "react/jsx-runtime";
4
4
  import { ComponentProps, ReactNode } from "react";
5
5
  import { Streamdown } from "streamdown";
@@ -1,5 +1,5 @@
1
1
  import { C as createGenerativeUI, D as DefaultGenerativeUIChatCard, E as useGenerativeUIAccessibility, O as GenerativeUIChatSurfaceProps, S as GenerativeUIStateOf, T as GenerativeUIAriaAttributes, _ as GenerativeUIFunctionArgs, b as GenerativeUIFunctionName, c as useGenerativeUIRuntime, d as GenerativeUI, f as GenerativeUIComponentDefinition, g as GenerativeUIEventDefinition, m as GenerativeUIComponentProps, n as GenerativeUIErrorBoundaryConfig, o as GenerativeUITheme, p as GenerativeUIComponentName, r as GenerativeUIMarkdownConfig, s as GenerativeUIToolConfig, t as GenerativeUIConfig, u as CreateGenerativeUIConfig, v as GenerativeUIFunctionDefinition, w as GenerativeUIAccessibility, x as GenerativeUISlotKind, y as GenerativeUIFunctionInput } from "../runtime-context-B4fKyzo6.mjs";
2
- import { a as childList, i as child, n as useGenerativeUIState, t as useGenerativeUIFunction } from "../hooks-DFgYRjj3.mjs";
2
+ import { a as childList, i as child, n as useGenerativeUIState, t as useGenerativeUIFunction } from "../hooks-EwGvqYsW.mjs";
3
3
  import { ComponentProps, ReactNode } from "react";
4
4
  import * as react_jsx_runtime0 from "react/jsx-runtime";
5
5
  import { Streamdown } from "streamdown";
@@ -2464,6 +2464,25 @@ const VISUALLY_HIDDEN = {
2464
2464
  border: 0
2465
2465
  };
2466
2466
  /** Legend labels use the text color, not the series color. */
2467
+ /**
2468
+ * A category label on the side axis of a horizontal bar chart: one line,
2469
+ * shortened to fit the axis, with the full text as a tooltip. Wrapped labels
2470
+ * there run into the labels of the neighbouring bars.
2471
+ */
2472
+ function CategoryTick(props) {
2473
+ const text = String(props.payload?.value ?? "");
2474
+ const fits = Math.max(4, Math.floor((props.width - 8) / 6.6));
2475
+ const shown = text.length > fits ? `${text.slice(0, fits - 1).trimEnd()}…` : text;
2476
+ return /* @__PURE__ */ jsxs("text", {
2477
+ x: props.x,
2478
+ y: props.y,
2479
+ dy: "0.35em",
2480
+ textAnchor: "end",
2481
+ fontSize: 12,
2482
+ fill: props.fill,
2483
+ children: [/* @__PURE__ */ jsx("title", { children: text }), shown]
2484
+ });
2485
+ }
2467
2486
  function legendFormatter(value) {
2468
2487
  return /* @__PURE__ */ jsx("span", {
2469
2488
  style: {
@@ -2573,9 +2592,11 @@ function createRechartsChart(R) {
2573
2592
  fontSize: 12,
2574
2593
  fill: textColor("secondary")
2575
2594
  };
2595
+ const isHorizontal = props.layout === "horizontal";
2576
2596
  const valueLabel = props.showValueLabels ? {
2577
- position: "top",
2597
+ position: isHorizontal ? "right" : "top",
2578
2598
  fontSize: 11,
2599
+ fill: textColor("secondary"),
2579
2600
  formatter: format
2580
2601
  } : void 0;
2581
2602
  const tooltip = showTooltip ? /* @__PURE__ */ jsx(R.Tooltip, {
@@ -2614,10 +2635,11 @@ function createRechartsChart(R) {
2614
2635
  }
2615
2636
  const CartesianChart = cartesianChartOf(R, chartType);
2616
2637
  const stackId = props.stacked ? "stack" : void 0;
2617
- const isHorizontal = props.layout === "horizontal";
2618
2638
  const xKey = props.xKey;
2619
2639
  const isNumericScatter = chartType === "scatter" && xKey !== void 0 && data.length > 0 && data.every((row) => typeof row[xKey] === "number" && Number.isFinite(row[xKey]));
2620
2640
  const domain = [props.yAxis?.min ?? "auto", props.yAxis?.max ?? "auto"];
2641
+ const longestCategory = Math.max(0, ...data.map((row) => props.xKey ? String(row[props.xKey] ?? "").length : 0));
2642
+ const categoryWidth = props.yAxis?.width ?? Math.min(168, Math.max(64, Math.ceil(longestCategory * 6.6) + 12));
2621
2643
  const valueAxisLabel = props.yAxis?.label ? {
2622
2644
  value: props.yAxis.label,
2623
2645
  position: isHorizontal ? "insideBottom" : "insideLeft",
@@ -2695,7 +2717,7 @@ function createRechartsChart(R) {
2695
2717
  layout: isHorizontal ? "vertical" : "horizontal",
2696
2718
  margin: {
2697
2719
  top: 8,
2698
- right: 8,
2720
+ right: isHorizontal && props.showValueLabels ? 48 : 8,
2699
2721
  bottom: 0,
2700
2722
  left: 0
2701
2723
  },
@@ -2713,14 +2735,19 @@ function createRechartsChart(R) {
2713
2735
  tickLine: false,
2714
2736
  axisLine: { stroke: borderColor("default") },
2715
2737
  tickFormatter: format,
2716
- label: valueAxisLabel
2738
+ label: valueAxisLabel,
2739
+ height: valueAxisLabel ? 48 : void 0
2717
2740
  }), /* @__PURE__ */ jsx(R.YAxis, {
2718
2741
  type: isNumericScatter ? "number" : "category",
2719
2742
  dataKey: props.xKey,
2720
- tick: axisTick,
2743
+ interval: 0,
2744
+ tick: /* @__PURE__ */ jsx(CategoryTick, {
2745
+ width: categoryWidth,
2746
+ fill: axisTick.fill
2747
+ }),
2721
2748
  tickLine: false,
2722
2749
  axisLine: false,
2723
- width: props.yAxis?.width ?? 96
2750
+ width: categoryWidth
2724
2751
  })] }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(R.XAxis, {
2725
2752
  type: isNumericScatter ? "number" : "category",
2726
2753
  dataKey: props.xKey,
@@ -3232,7 +3259,32 @@ function Table(props) {
3232
3259
  maxHeight: props.stickyHeader ? 480 : void 0,
3233
3260
  overflowY: props.stickyHeader ? "auto" : void 0
3234
3261
  };
3235
- if (props.children !== void 0 && rows.length === 0 && columns.length === 0) return /* @__PURE__ */ jsx("div", {
3262
+ const isChildrenMode = props.children !== void 0 && rows.length === 0;
3263
+ const rowLengths = rows.map((row) => row.length);
3264
+ const columnCount = Math.max(columns.length, ...rowLengths, 1);
3265
+ const stickyStyle = props.stickyHeader ? {
3266
+ position: "sticky",
3267
+ top: 0,
3268
+ background: backgroundColor("surface")
3269
+ } : {};
3270
+ const header = columns.length > 0 ? /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsx("tr", { children: columns.map((column, index) => {
3271
+ const cell = cellAttributes({
3272
+ isHeader: true,
3273
+ hasDivider: true,
3274
+ align: column.align,
3275
+ width: column.width
3276
+ });
3277
+ return /* @__PURE__ */ jsxs("th", {
3278
+ scope: "col",
3279
+ ...cell,
3280
+ style: {
3281
+ ...cell.style,
3282
+ ...stickyStyle
3283
+ },
3284
+ children: [column.label, column.componentId ? components.get(column.componentId) : null]
3285
+ }, `${column.label ?? column.componentId}-${index}`);
3286
+ }) }) }) : null;
3287
+ if (isChildrenMode) return /* @__PURE__ */ jsx("div", {
3236
3288
  className: "a2ui-std-table-wrap",
3237
3289
  "data-a2ui-std": "",
3238
3290
  style: wrapperStyle,
@@ -3245,17 +3297,14 @@ function Table(props) {
3245
3297
  children: /* @__PURE__ */ jsxs("table", {
3246
3298
  className: "a2ui-std-table",
3247
3299
  style: tableStyle,
3248
- children: [/* @__PURE__ */ jsx(Caption$1, { text: props.caption }), props.children]
3300
+ children: [
3301
+ /* @__PURE__ */ jsx(Caption$1, { text: props.caption }),
3302
+ header,
3303
+ props.children
3304
+ ]
3249
3305
  })
3250
3306
  })
3251
3307
  });
3252
- const rowLengths = rows.map((row) => row.length);
3253
- const columnCount = Math.max(columns.length, ...rowLengths, 1);
3254
- const stickyStyle = props.stickyHeader ? {
3255
- position: "sticky",
3256
- top: 0,
3257
- background: backgroundColor("surface")
3258
- } : {};
3259
3308
  return /* @__PURE__ */ jsx("div", {
3260
3309
  className: "a2ui-std-table-wrap",
3261
3310
  "data-a2ui-std": "",
@@ -3265,23 +3314,7 @@ function Table(props) {
3265
3314
  style: tableStyle,
3266
3315
  children: [
3267
3316
  /* @__PURE__ */ jsx(Caption$1, { text: props.caption }),
3268
- columns.length > 0 ? /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsx("tr", { children: columns.map((column, index) => {
3269
- const cell = cellAttributes({
3270
- isHeader: true,
3271
- hasDivider: true,
3272
- align: column.align,
3273
- width: column.width
3274
- });
3275
- return /* @__PURE__ */ jsxs("th", {
3276
- scope: "col",
3277
- ...cell,
3278
- style: {
3279
- ...cell.style,
3280
- ...stickyStyle
3281
- },
3282
- children: [column.label, column.componentId ? components.get(column.componentId) : null]
3283
- }, `${column.label ?? column.componentId}-${index}`);
3284
- }) }) }) : null,
3317
+ header,
3285
3318
  /* @__PURE__ */ jsx("tbody", { children: rows.length === 0 ? /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx("td", {
3286
3319
  colSpan: columnCount,
3287
3320
  className: "a2ui-std-cell",
@@ -4959,7 +4992,7 @@ function Select(props) {
4959
4992
  ...controlStyle(props, "xl"),
4960
4993
  ...SELECT_STYLE,
4961
4994
  width: props.block === false ? void 0 : "100%",
4962
- paddingLeft: props.icon ? `${PAD_X[props.size ?? "xl"] + 24}px` : void 0
4995
+ ...props.icon ? { paddingLeft: `${PAD_X[props.size ?? "xl"] + 24}px` } : {}
4963
4996
  },
4964
4997
  ...controlAria(aria),
4965
4998
  children: [hasEmptyOption ? /* @__PURE__ */ jsx("option", {