@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.
@@ -2423,7 +2423,12 @@ async function buildArtifact(draft, format, label) {
2423
2423
  const extension = format === "plain" ? "txt" : format === "compact-json" ? "json" : format;
2424
2424
  return serialize(draft, format, { spreadsheetSafe: format === "csv" || format === "tsv", filename: `${filenameFor(label)}.${extension}` });
2425
2425
  }
2426
- function ContentTransferMenu({ source, surface, label, projection, sections, preferences, table, formatSources, variants = EMPTY_VARIANTS, actions = [], capabilities: local, disabled, enabled = true, className, stopPropagation = true, hide = [], controllerRef }) {
2426
+ function ContentTransferMenu(props) {
2427
+ const inherited = React12.useContext(CapabilityContext);
2428
+ const identityKey = props.capabilities?.identityKey ?? inherited.identityKey;
2429
+ return /* @__PURE__ */ jsx19(ContentTransferMenuSession, { ...props }, identityKey ?? "anonymous");
2430
+ }
2431
+ function ContentTransferMenuSession({ source, surface, label, projection, sections, preferences, table, formatSources, variants = EMPTY_VARIANTS, actions = [], capabilities: local, disabled, enabled = true, className, stopPropagation = true, hide = [], controllerRef }) {
2427
2432
  const triggerRef = React12.useRef(null);
2428
2433
  const inherited = React12.useContext(CapabilityContext);
2429
2434
  const nearestSurface = React12.useContext(SurfaceContext);
@@ -2716,6 +2721,9 @@ function PreparationWorkspace({ restoreFocus, open, state, scopes, onClose, onCh
2716
2721
  const [instruction, setInstruction] = React12.useState("");
2717
2722
  const [busy, setBusy] = React12.useState(null);
2718
2723
  const [aiFailed, setAiFailed] = React12.useState(false);
2724
+ React12.useEffect(() => {
2725
+ setAiFailed(false);
2726
+ }, [state.snapshot.id, state.draft.revision]);
2719
2727
  const activeAi = React12.useRef(null);
2720
2728
  const activeCapture = React12.useRef(null);
2721
2729
  React12.useEffect(() => {
@@ -3026,7 +3034,7 @@ function PreparationWorkspace({ restoreFocus, open, state, scopes, onClose, onCh
3026
3034
  activeCapture.current = null;
3027
3035
  setBusy(null);
3028
3036
  }, children: "Stop loading rows" }) : null,
3029
- ai && aiSession.current?.recover && busy !== "ai" ? /* @__PURE__ */ jsx19(Button, { type: "button", variant: "outline", onClick: () => void runAi(true), children: aiFailed ? "Retry or rejoin AI run" : "Rejoin AI run" }) : null,
3037
+ ai && aiFailed && aiSession.current?.recover && busy !== "ai" ? /* @__PURE__ */ jsx19(Button, { type: "button", variant: "outline", onClick: () => void runAi(true), children: aiFailed ? "Retry or rejoin AI run" : "Rejoin AI run" }) : null,
3030
3038
  ai ? /* @__PURE__ */ jsx19("p", { className: "matrx-alchemy-meta", children: "AI creates a preview. It never copies automatically. Closing detaches this view without cancelling server work." }) : null,
3031
3039
  state.error ? /* @__PURE__ */ jsx19("p", { role: "alert", className: "matrx-alchemy-error", children: state.error }) : null
3032
3040
  ] }) : null
@@ -3153,7 +3161,17 @@ var sourceFor = (id, label, build) => ({
3153
3161
  }
3154
3162
  });
3155
3163
  function MatrxCopyMenu(props) {
3156
- return /* @__PURE__ */ jsx20(MatrxCopyMenuSession, { ...props }, props.sourceId ?? props.label);
3164
+ const inherited = useContentTransferCapabilities();
3165
+ return /* @__PURE__ */ jsx20(
3166
+ MatrxCopyMenuSession,
3167
+ {
3168
+ ...props
3169
+ },
3170
+ JSON.stringify([
3171
+ inherited.identityKey ?? null,
3172
+ props.sourceId ?? props.label
3173
+ ])
3174
+ );
3157
3175
  }
3158
3176
  function MatrxCopyMenuSession(props) {
3159
3177
  const instance = React13.useId();
@@ -3181,7 +3199,7 @@ function MatrxCopyMenuSession(props) {
3181
3199
  })) : void 0;
3182
3200
  const agent = aiVisible && props.agent !== void 0 ? make("agent", () => asPayload(resolve(props.agent))) : void 0;
3183
3201
  const structuredAgent = aiVisible && props.agent !== void 0 ? make("structured-agent", () => structuredPayload(resolve(props.agent))) : void 0;
3184
- const table = exportVisible && props.export?.sheetRows ? make("rows", () => {
3202
+ const table = (exportVisible || props.primarySource === "table") && props.export?.sheetRows ? make("rows", () => {
3185
3203
  const value = normalizeTransferJson(props.export.sheetRows());
3186
3204
  if (!Array.isArray(value) || value.some(
3187
3205
  (row) => row === null || typeof row !== "object" || Array.isArray(row)
@@ -3328,7 +3346,7 @@ function MatrxCopyMenuSession(props) {
3328
3346
  return props.sendToSheet(draft.payload.rows, props.label);
3329
3347
  }
3330
3348
  });
3331
- const source = json ?? table ?? structuredAgent ?? human ?? builderVariants[0]?.source;
3349
+ const source = (props.primarySource === "table" ? table : void 0) ?? json ?? table ?? structuredAgent ?? human ?? builderVariants[0]?.source;
3332
3350
  if (!source && !actions.length) return null;
3333
3351
  const target = source ?? make("actions", () => ({ kind: "text", text: props.label }));
3334
3352
  return /* @__PURE__ */ jsxs14(Fragment3, { children: [
@@ -3348,7 +3366,7 @@ function MatrxCopyMenuSession(props) {
3348
3366
  formatSources: {
3349
3367
  ...human ? { plain: human, markdown: humanMarkdown, html: humanMarkdown } : {},
3350
3368
  ...json ? { json, "compact-json": json } : {},
3351
- ...table ? { csv: table, tsv: table } : {}
3369
+ ...table && exportVisible ? { csv: table, tsv: table } : {}
3352
3370
  },
3353
3371
  ...props.disabled !== void 0 ? { disabled: props.disabled } : {},
3354
3372
  className: cn(
@@ -3648,8 +3666,9 @@ ${JSON.stringify(value.data, null, 2)}
3648
3666
  import { jsx as jsx21 } from "react/jsx-runtime";
3649
3667
  function CopyButtons(props) {
3650
3668
  const { CopyControls } = useMatrxDataTableHost();
3651
- if (CopyControls) return /* @__PURE__ */ jsx21(CopyControls, { ...props });
3652
- return /* @__PURE__ */ jsx21(MatrxCopyMenu, { ...props });
3669
+ const copyProps = props.export?.sheetRows ? { ...props, primarySource: "table" } : props;
3670
+ if (CopyControls) return /* @__PURE__ */ jsx21(CopyControls, { ...copyProps });
3671
+ return /* @__PURE__ */ jsx21(MatrxCopyMenu, { ...copyProps });
3653
3672
  }
3654
3673
  function jsonExportItem(build, label) {
3655
3674
  return { id: "json", label, build: () => ({ content: JSON.stringify(build(), null, 2), extension: "json", mime: "application/json" }) };