@ai-matrx/design-system 0.18.1 → 0.18.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.
@@ -749,7 +749,12 @@ async function buildArtifact(draft, format, label) {
749
749
  const extension = format === "plain" ? "txt" : format === "compact-json" ? "json" : format;
750
750
  return serialize(draft, format, { spreadsheetSafe: format === "csv" || format === "tsv", filename: `${filenameFor(label)}.${extension}` });
751
751
  }
752
- function ContentTransferMenu({ source, surface, label, projection, sections, preferences, table, formatSources, variants = EMPTY_VARIANTS, actions = [], capabilities: local, disabled, enabled = true, className, stopPropagation = true, hide = [], controllerRef }) {
752
+ function ContentTransferMenu(props) {
753
+ const inherited = React7.useContext(CapabilityContext);
754
+ const identityKey = props.capabilities?.identityKey ?? inherited.identityKey;
755
+ return /* @__PURE__ */ jsx10(ContentTransferMenuSession, { ...props }, identityKey ?? "anonymous");
756
+ }
757
+ function ContentTransferMenuSession({ source, surface, label, projection, sections, preferences, table, formatSources, variants = EMPTY_VARIANTS, actions = [], capabilities: local, disabled, enabled = true, className, stopPropagation = true, hide = [], controllerRef }) {
753
758
  const triggerRef = React7.useRef(null);
754
759
  const inherited = React7.useContext(CapabilityContext);
755
760
  const nearestSurface = React7.useContext(SurfaceContext);
@@ -1042,6 +1047,9 @@ function PreparationWorkspace({ restoreFocus, open, state, scopes, onClose, onCh
1042
1047
  const [instruction, setInstruction] = React7.useState("");
1043
1048
  const [busy, setBusy] = React7.useState(null);
1044
1049
  const [aiFailed, setAiFailed] = React7.useState(false);
1050
+ React7.useEffect(() => {
1051
+ setAiFailed(false);
1052
+ }, [state.snapshot.id, state.draft.revision]);
1045
1053
  const activeAi = React7.useRef(null);
1046
1054
  const activeCapture = React7.useRef(null);
1047
1055
  React7.useEffect(() => {
@@ -1352,7 +1360,7 @@ function PreparationWorkspace({ restoreFocus, open, state, scopes, onClose, onCh
1352
1360
  activeCapture.current = null;
1353
1361
  setBusy(null);
1354
1362
  }, children: "Stop loading rows" }) : null,
1355
- ai && aiSession.current?.recover && busy !== "ai" ? /* @__PURE__ */ jsx10(Button, { type: "button", variant: "outline", onClick: () => void runAi(true), children: aiFailed ? "Retry or rejoin AI run" : "Rejoin AI run" }) : null,
1363
+ ai && aiFailed && aiSession.current?.recover && busy !== "ai" ? /* @__PURE__ */ jsx10(Button, { type: "button", variant: "outline", onClick: () => void runAi(true), children: aiFailed ? "Retry or rejoin AI run" : "Rejoin AI run" }) : null,
1356
1364
  ai ? /* @__PURE__ */ jsx10("p", { className: "matrx-alchemy-meta", children: "AI creates a preview. It never copies automatically. Closing detaches this view without cancelling server work." }) : null,
1357
1365
  state.error ? /* @__PURE__ */ jsx10("p", { role: "alert", className: "matrx-alchemy-error", children: state.error }) : null
1358
1366
  ] }) : null
@@ -1479,7 +1487,17 @@ var sourceFor = (id, label, build) => ({
1479
1487
  }
1480
1488
  });
1481
1489
  function MatrxCopyMenu(props) {
1482
- return /* @__PURE__ */ jsx11(MatrxCopyMenuSession, { ...props }, props.sourceId ?? props.label);
1490
+ const inherited = useContentTransferCapabilities();
1491
+ return /* @__PURE__ */ jsx11(
1492
+ MatrxCopyMenuSession,
1493
+ {
1494
+ ...props
1495
+ },
1496
+ JSON.stringify([
1497
+ inherited.identityKey ?? null,
1498
+ props.sourceId ?? props.label
1499
+ ])
1500
+ );
1483
1501
  }
1484
1502
  function MatrxCopyMenuSession(props) {
1485
1503
  const instance = React8.useId();
@@ -1507,7 +1525,7 @@ function MatrxCopyMenuSession(props) {
1507
1525
  })) : void 0;
1508
1526
  const agent = aiVisible && props.agent !== void 0 ? make("agent", () => asPayload(resolve(props.agent))) : void 0;
1509
1527
  const structuredAgent = aiVisible && props.agent !== void 0 ? make("structured-agent", () => structuredPayload(resolve(props.agent))) : void 0;
1510
- const table = exportVisible && props.export?.sheetRows ? make("rows", () => {
1528
+ const table = (exportVisible || props.primarySource === "table") && props.export?.sheetRows ? make("rows", () => {
1511
1529
  const value = normalizeTransferJson(props.export.sheetRows());
1512
1530
  if (!Array.isArray(value) || value.some(
1513
1531
  (row) => row === null || typeof row !== "object" || Array.isArray(row)
@@ -1654,7 +1672,7 @@ function MatrxCopyMenuSession(props) {
1654
1672
  return props.sendToSheet(draft.payload.rows, props.label);
1655
1673
  }
1656
1674
  });
1657
- const source = json ?? table ?? structuredAgent ?? human ?? builderVariants[0]?.source;
1675
+ const source = (props.primarySource === "table" ? table : void 0) ?? json ?? table ?? structuredAgent ?? human ?? builderVariants[0]?.source;
1658
1676
  if (!source && !actions.length) return null;
1659
1677
  const target = source ?? make("actions", () => ({ kind: "text", text: props.label }));
1660
1678
  return /* @__PURE__ */ jsxs7(Fragment2, { children: [
@@ -1674,7 +1692,7 @@ function MatrxCopyMenuSession(props) {
1674
1692
  formatSources: {
1675
1693
  ...human ? { plain: human, markdown: humanMarkdown, html: humanMarkdown } : {},
1676
1694
  ...json ? { json, "compact-json": json } : {},
1677
- ...table ? { csv: table, tsv: table } : {}
1695
+ ...table && exportVisible ? { csv: table, tsv: table } : {}
1678
1696
  },
1679
1697
  ...props.disabled !== void 0 ? { disabled: props.disabled } : {},
1680
1698
  className: cn(
@@ -1947,8 +1965,9 @@ function SourceConfiguration({
1947
1965
  import { jsx as jsx12 } from "react/jsx-runtime";
1948
1966
  function CopyButtons(props) {
1949
1967
  const { CopyControls } = useMatrxDataTableHost();
1950
- if (CopyControls) return /* @__PURE__ */ jsx12(CopyControls, { ...props });
1951
- return /* @__PURE__ */ jsx12(MatrxCopyMenu, { ...props });
1968
+ const copyProps = props.export?.sheetRows ? { ...props, primarySource: "table" } : props;
1969
+ if (CopyControls) return /* @__PURE__ */ jsx12(CopyControls, { ...copyProps });
1970
+ return /* @__PURE__ */ jsx12(MatrxCopyMenu, { ...copyProps });
1952
1971
  }
1953
1972
 
1954
1973
  // src/data-table/MatrxUuidCell.tsx