@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.
@@ -103,6 +103,8 @@ interface MatrxCopyMenuProps {
103
103
  label: string;
104
104
  /** Stable record identity when this mounted control can switch between records. */
105
105
  sourceId?: string;
106
+ /** Prepare the tabular view while keeping raw JSON and human copy formats. */
107
+ primarySource?: "table";
106
108
  human?: Resolvable<string>;
107
109
  json?: Resolvable<unknown>;
108
110
  agent?: Resolvable<AgentPayloadInput | string>;
@@ -141,6 +143,8 @@ declare function groomerPresetVariants(getConfig: () => AlchemyGroomerConfig): A
141
143
 
142
144
  declare function AlchemyGlyph(props: React.SVGAttributes<SVGSVGElement>): React.JSX.Element;
143
145
  type ContentTransferCapabilities = TransferCapabilities & {
146
+ /** Opaque host session boundary. It is used only to reset local menu state. */
147
+ identityKey?: string;
144
148
  transport?: Transport;
145
149
  actions?: PageAction[];
146
150
  preferences?: TransferPreferenceOverrides;
@@ -203,6 +207,6 @@ interface ContentTransferController {
203
207
  label?: string;
204
208
  }): Promise<void>;
205
209
  }
206
- declare function ContentTransferMenu({ source, surface, label, projection, sections, preferences, table, formatSources, variants, actions, capabilities: local, disabled, enabled, className, stopPropagation, hide, controllerRef }: ContentTransferMenuProps): React.JSX.Element | null;
210
+ declare function ContentTransferMenu(props: ContentTransferMenuProps): React.JSX.Element;
207
211
 
208
212
  export { type AlchemyCopyVariant, type AlchemyCustomSource, type AlchemyDetail, type AlchemyExportItem, AlchemyGlyph, type AlchemyGroomerConfig, type AlchemyGroomerPreset, type AlchemyGroomerSection, type AlchemyOptionValues, type AlchemySourceOption, type ContentTransferCapabilities, ContentTransferCapabilitiesProvider, type ContentTransferController, ContentTransferMenu, type ContentTransferMenuProps, ContentTransferSurfaceProvider, GROOMER_LEVELS, MatrxCopyMenu, type MatrxCopyMenuProps, type SerializableFormat, type TransferMenuPresentation, type TransferMenuVariant, applyGroomerPreset, buildGroomerPresetPayload, defaultGroomerSelections, groomerPresetVariants, useContentTransferCapabilities, useContentTransferSurface };
@@ -103,6 +103,8 @@ interface MatrxCopyMenuProps {
103
103
  label: string;
104
104
  /** Stable record identity when this mounted control can switch between records. */
105
105
  sourceId?: string;
106
+ /** Prepare the tabular view while keeping raw JSON and human copy formats. */
107
+ primarySource?: "table";
106
108
  human?: Resolvable<string>;
107
109
  json?: Resolvable<unknown>;
108
110
  agent?: Resolvable<AgentPayloadInput | string>;
@@ -141,6 +143,8 @@ declare function groomerPresetVariants(getConfig: () => AlchemyGroomerConfig): A
141
143
 
142
144
  declare function AlchemyGlyph(props: React.SVGAttributes<SVGSVGElement>): React.JSX.Element;
143
145
  type ContentTransferCapabilities = TransferCapabilities & {
146
+ /** Opaque host session boundary. It is used only to reset local menu state. */
147
+ identityKey?: string;
144
148
  transport?: Transport;
145
149
  actions?: PageAction[];
146
150
  preferences?: TransferPreferenceOverrides;
@@ -203,6 +207,6 @@ interface ContentTransferController {
203
207
  label?: string;
204
208
  }): Promise<void>;
205
209
  }
206
- declare function ContentTransferMenu({ source, surface, label, projection, sections, preferences, table, formatSources, variants, actions, capabilities: local, disabled, enabled, className, stopPropagation, hide, controllerRef }: ContentTransferMenuProps): React.JSX.Element | null;
210
+ declare function ContentTransferMenu(props: ContentTransferMenuProps): React.JSX.Element;
207
211
 
208
212
  export { type AlchemyCopyVariant, type AlchemyCustomSource, type AlchemyDetail, type AlchemyExportItem, AlchemyGlyph, type AlchemyGroomerConfig, type AlchemyGroomerPreset, type AlchemyGroomerSection, type AlchemyOptionValues, type AlchemySourceOption, type ContentTransferCapabilities, ContentTransferCapabilitiesProvider, type ContentTransferController, ContentTransferMenu, type ContentTransferMenuProps, ContentTransferSurfaceProvider, GROOMER_LEVELS, MatrxCopyMenu, type MatrxCopyMenuProps, type SerializableFormat, type TransferMenuPresentation, type TransferMenuVariant, applyGroomerPreset, buildGroomerPresetPayload, defaultGroomerSelections, groomerPresetVariants, useContentTransferCapabilities, useContentTransferSurface };
@@ -641,7 +641,17 @@ var sourceFor = (id, label, build) => ({
641
641
  }
642
642
  });
643
643
  function MatrxCopyMenu(props) {
644
- return /* @__PURE__ */ jsx7(MatrxCopyMenuSession, { ...props }, props.sourceId ?? props.label);
644
+ const inherited = useContentTransferCapabilities();
645
+ return /* @__PURE__ */ jsx7(
646
+ MatrxCopyMenuSession,
647
+ {
648
+ ...props
649
+ },
650
+ JSON.stringify([
651
+ inherited.identityKey ?? null,
652
+ props.sourceId ?? props.label
653
+ ])
654
+ );
645
655
  }
646
656
  function MatrxCopyMenuSession(props) {
647
657
  const instance = React7.useId();
@@ -669,7 +679,7 @@ function MatrxCopyMenuSession(props) {
669
679
  })) : void 0;
670
680
  const agent = aiVisible && props.agent !== void 0 ? make("agent", () => asPayload(resolve(props.agent))) : void 0;
671
681
  const structuredAgent = aiVisible && props.agent !== void 0 ? make("structured-agent", () => structuredPayload(resolve(props.agent))) : void 0;
672
- const table = exportVisible && props.export?.sheetRows ? make("rows", () => {
682
+ const table = (exportVisible || props.primarySource === "table") && props.export?.sheetRows ? make("rows", () => {
673
683
  const value = normalizeTransferJson(props.export.sheetRows());
674
684
  if (!Array.isArray(value) || value.some(
675
685
  (row) => row === null || typeof row !== "object" || Array.isArray(row)
@@ -816,7 +826,7 @@ function MatrxCopyMenuSession(props) {
816
826
  return props.sendToSheet(draft.payload.rows, props.label);
817
827
  }
818
828
  });
819
- const source = json ?? table ?? structuredAgent ?? human ?? builderVariants[0]?.source;
829
+ const source = (props.primarySource === "table" ? table : void 0) ?? json ?? table ?? structuredAgent ?? human ?? builderVariants[0]?.source;
820
830
  if (!source && !actions.length) return null;
821
831
  const target = source ?? make("actions", () => ({ kind: "text", text: props.label }));
822
832
  return /* @__PURE__ */ jsxs4(Fragment, { children: [
@@ -836,7 +846,7 @@ function MatrxCopyMenuSession(props) {
836
846
  formatSources: {
837
847
  ...human ? { plain: human, markdown: humanMarkdown, html: humanMarkdown } : {},
838
848
  ...json ? { json, "compact-json": json } : {},
839
- ...table ? { csv: table, tsv: table } : {}
849
+ ...table && exportVisible ? { csv: table, tsv: table } : {}
840
850
  },
841
851
  ...props.disabled !== void 0 ? { disabled: props.disabled } : {},
842
852
  className: cn(
@@ -1269,7 +1279,12 @@ async function buildArtifact(draft, format, label) {
1269
1279
  const extension = format === "plain" ? "txt" : format === "compact-json" ? "json" : format;
1270
1280
  return serialize(draft, format, { spreadsheetSafe: format === "csv" || format === "tsv", filename: `${filenameFor(label)}.${extension}` });
1271
1281
  }
1272
- function ContentTransferMenu({ source, surface, label, projection, sections, preferences, table, formatSources, variants = EMPTY_VARIANTS, actions = [], capabilities: local, disabled, enabled = true, className, stopPropagation = true, hide = [], controllerRef }) {
1282
+ function ContentTransferMenu(props) {
1283
+ const inherited = React8.useContext(CapabilityContext);
1284
+ const identityKey = props.capabilities?.identityKey ?? inherited.identityKey;
1285
+ return /* @__PURE__ */ jsx8(ContentTransferMenuSession, { ...props }, identityKey ?? "anonymous");
1286
+ }
1287
+ function ContentTransferMenuSession({ source, surface, label, projection, sections, preferences, table, formatSources, variants = EMPTY_VARIANTS, actions = [], capabilities: local, disabled, enabled = true, className, stopPropagation = true, hide = [], controllerRef }) {
1273
1288
  const triggerRef = React8.useRef(null);
1274
1289
  const inherited = React8.useContext(CapabilityContext);
1275
1290
  const nearestSurface = React8.useContext(SurfaceContext);
@@ -1562,6 +1577,9 @@ function PreparationWorkspace({ restoreFocus, open, state, scopes, onClose, onCh
1562
1577
  const [instruction, setInstruction] = React8.useState("");
1563
1578
  const [busy, setBusy] = React8.useState(null);
1564
1579
  const [aiFailed, setAiFailed] = React8.useState(false);
1580
+ React8.useEffect(() => {
1581
+ setAiFailed(false);
1582
+ }, [state.snapshot.id, state.draft.revision]);
1565
1583
  const activeAi = React8.useRef(null);
1566
1584
  const activeCapture = React8.useRef(null);
1567
1585
  React8.useEffect(() => {
@@ -1872,7 +1890,7 @@ function PreparationWorkspace({ restoreFocus, open, state, scopes, onClose, onCh
1872
1890
  activeCapture.current = null;
1873
1891
  setBusy(null);
1874
1892
  }, children: "Stop loading rows" }) : null,
1875
- ai && aiSession.current?.recover && busy !== "ai" ? /* @__PURE__ */ jsx8(Button, { type: "button", variant: "outline", onClick: () => void runAi(true), children: aiFailed ? "Retry or rejoin AI run" : "Rejoin AI run" }) : null,
1893
+ ai && aiFailed && aiSession.current?.recover && busy !== "ai" ? /* @__PURE__ */ jsx8(Button, { type: "button", variant: "outline", onClick: () => void runAi(true), children: aiFailed ? "Retry or rejoin AI run" : "Rejoin AI run" }) : null,
1876
1894
  ai ? /* @__PURE__ */ jsx8("p", { className: "matrx-alchemy-meta", children: "AI creates a preview. It never copies automatically. Closing detaches this view without cancelling server work." }) : null,
1877
1895
  state.error ? /* @__PURE__ */ jsx8("p", { role: "alert", className: "matrx-alchemy-error", children: state.error }) : null
1878
1896
  ] }) : null