@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.
@@ -756,7 +756,12 @@ async function buildArtifact(draft, format, label) {
756
756
  const extension = format === "plain" ? "txt" : format === "compact-json" ? "json" : format;
757
757
  return (0, import_content_transfer.serialize)(draft, format, { spreadsheetSafe: format === "csv" || format === "tsv", filename: `${filenameFor(label)}.${extension}` });
758
758
  }
759
- function ContentTransferMenu({ source, surface, label, projection, sections, preferences, table, formatSources, variants = EMPTY_VARIANTS, actions = [], capabilities: local, disabled, enabled = true, className, stopPropagation = true, hide = [], controllerRef }) {
759
+ function ContentTransferMenu(props) {
760
+ const inherited = React7.useContext(CapabilityContext);
761
+ const identityKey = props.capabilities?.identityKey ?? inherited.identityKey;
762
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ContentTransferMenuSession, { ...props }, identityKey ?? "anonymous");
763
+ }
764
+ function ContentTransferMenuSession({ source, surface, label, projection, sections, preferences, table, formatSources, variants = EMPTY_VARIANTS, actions = [], capabilities: local, disabled, enabled = true, className, stopPropagation = true, hide = [], controllerRef }) {
760
765
  const triggerRef = React7.useRef(null);
761
766
  const inherited = React7.useContext(CapabilityContext);
762
767
  const nearestSurface = React7.useContext(SurfaceContext);
@@ -1049,6 +1054,9 @@ function PreparationWorkspace({ restoreFocus, open, state, scopes, onClose, onCh
1049
1054
  const [instruction, setInstruction] = React7.useState("");
1050
1055
  const [busy, setBusy] = React7.useState(null);
1051
1056
  const [aiFailed, setAiFailed] = React7.useState(false);
1057
+ React7.useEffect(() => {
1058
+ setAiFailed(false);
1059
+ }, [state.snapshot.id, state.draft.revision]);
1052
1060
  const activeAi = React7.useRef(null);
1053
1061
  const activeCapture = React7.useRef(null);
1054
1062
  React7.useEffect(() => {
@@ -1359,7 +1367,7 @@ function PreparationWorkspace({ restoreFocus, open, state, scopes, onClose, onCh
1359
1367
  activeCapture.current = null;
1360
1368
  setBusy(null);
1361
1369
  }, children: "Stop loading rows" }) : null,
1362
- ai && aiSession.current?.recover && busy !== "ai" ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Button, { type: "button", variant: "outline", onClick: () => void runAi(true), children: aiFailed ? "Retry or rejoin AI run" : "Rejoin AI run" }) : null,
1370
+ ai && aiFailed && aiSession.current?.recover && busy !== "ai" ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Button, { type: "button", variant: "outline", onClick: () => void runAi(true), children: aiFailed ? "Retry or rejoin AI run" : "Rejoin AI run" }) : null,
1363
1371
  ai ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "matrx-alchemy-meta", children: "AI creates a preview. It never copies automatically. Closing detaches this view without cancelling server work." }) : null,
1364
1372
  state.error ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { role: "alert", className: "matrx-alchemy-error", children: state.error }) : null
1365
1373
  ] }) : null
@@ -1486,7 +1494,17 @@ var sourceFor = (id, label, build) => ({
1486
1494
  }
1487
1495
  });
1488
1496
  function MatrxCopyMenu(props) {
1489
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(MatrxCopyMenuSession, { ...props }, props.sourceId ?? props.label);
1497
+ const inherited = useContentTransferCapabilities();
1498
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1499
+ MatrxCopyMenuSession,
1500
+ {
1501
+ ...props
1502
+ },
1503
+ JSON.stringify([
1504
+ inherited.identityKey ?? null,
1505
+ props.sourceId ?? props.label
1506
+ ])
1507
+ );
1490
1508
  }
1491
1509
  function MatrxCopyMenuSession(props) {
1492
1510
  const instance = React8.useId();
@@ -1514,7 +1532,7 @@ function MatrxCopyMenuSession(props) {
1514
1532
  })) : void 0;
1515
1533
  const agent = aiVisible && props.agent !== void 0 ? make("agent", () => asPayload(resolve(props.agent))) : void 0;
1516
1534
  const structuredAgent = aiVisible && props.agent !== void 0 ? make("structured-agent", () => structuredPayload(resolve(props.agent))) : void 0;
1517
- const table = exportVisible && props.export?.sheetRows ? make("rows", () => {
1535
+ const table = (exportVisible || props.primarySource === "table") && props.export?.sheetRows ? make("rows", () => {
1518
1536
  const value = (0, import_content_transfer2.normalizeTransferJson)(props.export.sheetRows());
1519
1537
  if (!Array.isArray(value) || value.some(
1520
1538
  (row) => row === null || typeof row !== "object" || Array.isArray(row)
@@ -1661,7 +1679,7 @@ function MatrxCopyMenuSession(props) {
1661
1679
  return props.sendToSheet(draft.payload.rows, props.label);
1662
1680
  }
1663
1681
  });
1664
- const source = json ?? table ?? structuredAgent ?? human ?? builderVariants[0]?.source;
1682
+ const source = (props.primarySource === "table" ? table : void 0) ?? json ?? table ?? structuredAgent ?? human ?? builderVariants[0]?.source;
1665
1683
  if (!source && !actions.length) return null;
1666
1684
  const target = source ?? make("actions", () => ({ kind: "text", text: props.label }));
1667
1685
  return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
@@ -1681,7 +1699,7 @@ function MatrxCopyMenuSession(props) {
1681
1699
  formatSources: {
1682
1700
  ...human ? { plain: human, markdown: humanMarkdown, html: humanMarkdown } : {},
1683
1701
  ...json ? { json, "compact-json": json } : {},
1684
- ...table ? { csv: table, tsv: table } : {}
1702
+ ...table && exportVisible ? { csv: table, tsv: table } : {}
1685
1703
  },
1686
1704
  ...props.disabled !== void 0 ? { disabled: props.disabled } : {},
1687
1705
  className: cn(
@@ -1954,8 +1972,9 @@ function SourceConfiguration({
1954
1972
  var import_jsx_runtime12 = require("react/jsx-runtime");
1955
1973
  function CopyButtons(props) {
1956
1974
  const { CopyControls } = useMatrxDataTableHost();
1957
- if (CopyControls) return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(CopyControls, { ...props });
1958
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(MatrxCopyMenu, { ...props });
1975
+ const copyProps = props.export?.sheetRows ? { ...props, primarySource: "table" } : props;
1976
+ if (CopyControls) return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(CopyControls, { ...copyProps });
1977
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(MatrxCopyMenu, { ...copyProps });
1959
1978
  }
1960
1979
 
1961
1980
  // src/data-table/MatrxUuidCell.tsx