@ai-matrx/design-system 0.21.1 → 0.21.3

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.
Files changed (61) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/content-transfer.cjs +20 -6
  3. package/dist/content-transfer.cjs.map +1 -1
  4. package/dist/content-transfer.d.cts +38 -4
  5. package/dist/content-transfer.d.ts +38 -4
  6. package/dist/content-transfer.js +20 -6
  7. package/dist/content-transfer.js.map +1 -1
  8. package/dist/data-table/copy-helpers.d.cts +4 -3
  9. package/dist/data-table/copy-helpers.d.ts +4 -3
  10. package/dist/data-table/copy-types.cjs.map +1 -1
  11. package/dist/data-table/copy-types.d.cts +7 -2
  12. package/dist/data-table/copy-types.d.ts +7 -2
  13. package/dist/data-table/data-row-inspector.cjs +23 -6
  14. package/dist/data-table/data-row-inspector.cjs.map +1 -1
  15. package/dist/data-table/data-row-inspector.js +23 -6
  16. package/dist/data-table/data-row-inspector.js.map +1 -1
  17. package/dist/data-table/data-row-window.cjs +23 -6
  18. package/dist/data-table/data-row-window.cjs.map +1 -1
  19. package/dist/data-table/data-row-window.js +23 -6
  20. package/dist/data-table/data-row-window.js.map +1 -1
  21. package/dist/data-table/filter-engine.d.cts +4 -3
  22. package/dist/data-table/filter-engine.d.ts +4 -3
  23. package/dist/data-table/host.cjs +12 -1
  24. package/dist/data-table/host.cjs.map +1 -1
  25. package/dist/data-table/host.d.cts +16 -3
  26. package/dist/data-table/host.d.ts +16 -3
  27. package/dist/data-table/host.js +12 -1
  28. package/dist/data-table/host.js.map +1 -1
  29. package/dist/data-table/index.cjs +992 -843
  30. package/dist/data-table/index.cjs.map +1 -1
  31. package/dist/data-table/index.d.cts +15 -6
  32. package/dist/data-table/index.d.ts +15 -6
  33. package/dist/data-table/index.js +949 -800
  34. package/dist/data-table/index.js.map +1 -1
  35. package/dist/data-table/infer-filter.d.cts +4 -3
  36. package/dist/data-table/infer-filter.d.ts +4 -3
  37. package/dist/data-table/layered-filters.d.cts +4 -3
  38. package/dist/data-table/layered-filters.d.ts +4 -3
  39. package/dist/data-table/pagination.cjs +3 -0
  40. package/dist/data-table/pagination.cjs.map +1 -1
  41. package/dist/data-table/pagination.js +3 -0
  42. package/dist/data-table/pagination.js.map +1 -1
  43. package/dist/data-table/query-control.d.cts +4 -3
  44. package/dist/data-table/query-control.d.ts +4 -3
  45. package/dist/data-table/types.cjs.map +1 -1
  46. package/dist/data-table/types.d.cts +3 -2
  47. package/dist/data-table/types.d.ts +3 -2
  48. package/dist/data-table/url-state.d.cts +4 -3
  49. package/dist/data-table/url-state.d.ts +4 -3
  50. package/dist/data-table/uuid-cell.cjs +3 -0
  51. package/dist/data-table/uuid-cell.cjs.map +1 -1
  52. package/dist/data-table/uuid-cell.js +3 -0
  53. package/dist/data-table/uuid-cell.js.map +1 -1
  54. package/dist/data-table/xlsx.d.cts +4 -3
  55. package/dist/data-table/xlsx.d.ts +4 -3
  56. package/dist/styles.css +9 -0
  57. package/dist/{types-B99KFITZ.d.cts → types-BarjBFyG.d.cts} +9 -1
  58. package/dist/{types-CryQuMmz.d.ts → types-JFlsIv-0.d.ts} +9 -1
  59. package/package.json +1 -1
  60. package/dist/extensions-DCHtNwG3.d.cts +0 -32
  61. package/dist/extensions-DCHtNwG3.d.ts +0 -32
@@ -1,8 +1,9 @@
1
1
  import { AgentPayloadInput } from './copy-types.cjs';
2
- import { f as MatrxDataTableCopyConfig, M as MatrxColumnDef } from '../types-B99KFITZ.cjs';
3
- import '../extensions-DCHtNwG3.cjs';
4
- import '@ai-matrx/kit/content-transfer';
2
+ import { f as MatrxDataTableCopyConfig, M as MatrxColumnDef } from '../types-BarjBFyG.cjs';
3
+ import '../content-transfer.cjs';
5
4
  import 'react';
5
+ import '@ai-matrx/kit/content-transfer';
6
+ import '../content-transfer/icon.cjs';
6
7
 
7
8
  /**
8
9
  * Typed, declared-column capture for MatrxDataTable's built-in Alchemy source.
@@ -1,8 +1,9 @@
1
1
  import { AgentPayloadInput } from './copy-types.js';
2
- import { f as MatrxDataTableCopyConfig, M as MatrxColumnDef } from '../types-CryQuMmz.js';
3
- import '../extensions-DCHtNwG3.js';
4
- import '@ai-matrx/kit/content-transfer';
2
+ import { f as MatrxDataTableCopyConfig, M as MatrxColumnDef } from '../types-JFlsIv-0.js';
3
+ import '../content-transfer.js';
5
4
  import 'react';
5
+ import '@ai-matrx/kit/content-transfer';
6
+ import '../content-transfer/icon.js';
6
7
 
7
8
  /**
8
9
  * Typed, declared-column capture for MatrxDataTable's built-in Alchemy source.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/data-table/copy-types.ts"],"sourcesContent":["import type { ContentTransferReference } from \"../content-transfer/extensions\";\nimport type { ComponentType, ReactNode } from \"react\";\n\nexport type CopyResolvable<T> = T | (() => T);\nexport type CopyScalar = string | number | boolean | null | undefined;\nexport interface AgentPayloadInput { kind: string; location: string; description: string; data: unknown; summary?: string; context?: Record<string, CopyScalar>; attributes?: Record<string, CopyScalar>; }\nexport type AiIcon = ComponentType<{ className?: string }>;\nexport interface AiVariant { id: string; label: string; hint?: string; icon?: AiIcon; section?: \"copy\" | \"ai\"; ariaLabel?: string; successMessage?: string; build?: () => AgentPayloadInput | string | Promise<AgentPayloadInput | string>; onSelect?: () => void; modal?: (props: { open: boolean; onOpenChange: (open: boolean) => void }) => ReactNode; }\nexport type AiCustomOption =\n | { kind: \"toggle\"; key: string; label: string; hint?: string; default: boolean }\n | { kind: \"preset\"; key: string; label: string; options: { label: string; value: number }[]; default: number }\n | { kind: \"slider\"; key: string; label: string; hint?: string; stops: number[]; default: number; formatValue: (value: number) => string }\n | { kind: \"number\"; key: string; label: string; hint?: string; min?: number; step?: number; presets?: { label: string; value: number }[]; default: number };\nexport type AiOptionValues = Record<string, boolean | number>;\nexport interface AiCustomSource { label?: string; hint?: string; options: AiCustomOption[]; build: (options: AiOptionValues) => { text: string; meta?: Record<string, string | number | boolean | undefined> }; wrap: (text: string, options: AiOptionValues, meta?: Record<string, string | number | boolean | undefined>) => AgentPayloadInput; dialogTitle?: string; dialogDescription?: string; }\nexport interface ExportItem { id: string; label: string; build?: () => { content: BlobPart; extension: string; mime: string; filename?: string }; onSelect?: () => void | Promise<void>; }\nexport interface CopyExportConfig { items: ExportItem[]; sheetRows?: () => Array<Record<string, unknown>>; sheetColumns?: () => Array<{ id: string; label: string }>; }\n/** Exact portable table-copy API. Host adapters import this, never recreate it. */\nexport interface CopyControlProps {\n references?: readonly ContentTransferReference[];\n triggerVariant?: \"transparent\" | \"glass\" | \"outline\";\n /** Changes reset the preparation session when a mounted control changes record. */\n sourceId?: string;\n /** Canonical table controls opt into row preparation when sheet rows exist. */\n primarySource?: \"table\";\n human?: CopyResolvable<string>;\n agent?: CopyResolvable<AgentPayloadInput | string>;\n json?: CopyResolvable<unknown>;\n label: string;\n size?: \"xs\" | \"icon\" | \"sm\" | \"toolbar\";\n /** Accepted for direct compatibility; package chrome has no application groomer engine. */\n appearance?: \"segmented\" | \"bare\";\n disabled?: boolean;\n stopPropagation?: boolean;\n className?: string;\n /** Legacy source compatibility; controls are already grouped by default. */\n grouped?: boolean;\n aiVariants?: AiVariant[];\n agentVariant?: { id?: string; label?: string; hint?: string; position?: \"first\" | \"last\" };\n aiCustom?: AiCustomSource;\n export?: CopyExportConfig;\n hide?: Array<\"copy\" | \"ai\" | \"export\">;\n}\nexport interface CopySubsetColumn<T> { id: string; header: string; accessorKey?: keyof T & string; accessorFn?: (row: T) => unknown; hidden?: boolean; }\nexport interface CopySubsetSource<T> { label: string; location: string; kind: string; rows: T[]; columns: CopySubsetColumn<T>[]; getRowId: (row: T) => string; serializer?: (rows: T[]) => AgentPayloadInput; }\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
1
+ {"version":3,"sources":["../../src/data-table/copy-types.ts"],"sourcesContent":["import type { ContentTransferReference } from \"../content-transfer/extensions\";\nimport type { ContentTransferController } from \"../content-transfer\";\nimport type { ComponentType, ReactNode, Ref } from \"react\";\n\nexport type CopyResolvable<T> = T | (() => T);\nexport type CopyScalar = string | number | boolean | null | undefined;\nexport interface AgentPayloadInput { kind: string; location: string; description: string; data: unknown; summary?: string; context?: Record<string, CopyScalar>; attributes?: Record<string, CopyScalar>; }\nexport type AiIcon = ComponentType<{ className?: string }>;\nexport interface AiVariant { id: string; label: string; hint?: string; icon?: AiIcon; section?: \"copy\" | \"ai\"; ariaLabel?: string; successMessage?: string; build?: () => AgentPayloadInput | string | Promise<AgentPayloadInput | string>; onSelect?: () => void; modal?: (props: { open: boolean; onOpenChange: (open: boolean) => void }) => ReactNode; }\nexport type AiCustomOption =\n | { kind: \"toggle\"; key: string; label: string; hint?: string; default: boolean }\n | { kind: \"preset\"; key: string; label: string; options: { label: string; value: number }[]; default: number }\n | { kind: \"slider\"; key: string; label: string; hint?: string; stops: number[]; default: number; formatValue: (value: number) => string }\n | { kind: \"number\"; key: string; label: string; hint?: string; min?: number; step?: number; presets?: { label: string; value: number }[]; default: number };\nexport type AiOptionValues = Record<string, boolean | number>;\nexport interface AiCustomSource { label?: string; hint?: string; options: AiCustomOption[]; build: (options: AiOptionValues) => { text: string; meta?: Record<string, string | number | boolean | undefined> }; wrap: (text: string, options: AiOptionValues, meta?: Record<string, string | number | boolean | undefined>) => AgentPayloadInput; dialogTitle?: string; dialogDescription?: string; }\nexport interface ExportItem { id: string; label: string; build?: () => { content: BlobPart; extension: string; mime: string; filename?: string }; onSelect?: () => void | Promise<void>; }\nexport interface CopyExportConfig { items: ExportItem[]; sheetRows?: () => Array<Record<string, unknown>>; sheetColumns?: () => Array<{ id: string; label: string }>; }\n/** Exact portable table-copy API. Host adapters import this, never recreate it. */\nexport interface CopyControlProps {\n references?: readonly ContentTransferReference[];\n triggerVariant?: \"transparent\" | \"glass\" | \"outline\";\n /** Changes reset the preparation session when a mounted control changes record. */\n sourceId?: string;\n /** Canonical table controls opt into row preparation when sheet rows exist. */\n primarySource?: \"table\";\n human?: CopyResolvable<string>;\n agent?: CopyResolvable<AgentPayloadInput | string>;\n json?: CopyResolvable<unknown>;\n label: string;\n size?: \"xs\" | \"icon\" | \"sm\" | \"toolbar\";\n /** Accepted for direct compatibility; package chrome has no application groomer engine. */\n appearance?: \"segmented\" | \"bare\";\n disabled?: boolean;\n stopPropagation?: boolean;\n className?: string;\n /** Legacy source compatibility; controls are already grouped by default. */\n grouped?: boolean;\n aiVariants?: AiVariant[];\n agentVariant?: { id?: string; label?: string; hint?: string; position?: \"first\" | \"last\" };\n aiCustom?: AiCustomSource;\n export?: CopyExportConfig;\n hide?: Array<\"copy\" | \"ai\" | \"export\">;\n /** Programmatic host port for an existing menu; never uses a DOM click. */\n controllerRef?: Ref<ContentTransferController>;\n /** The host supplies the visible command. */\n triggerHidden?: boolean;\n}\nexport interface CopySubsetColumn<T> { id: string; header: string; accessorKey?: keyof T & string; accessorFn?: (row: T) => unknown; hidden?: boolean; }\nexport interface CopySubsetSource<T> { label: string; location: string; kind: string; rows: T[]; columns: CopySubsetColumn<T>[]; getRowId: (row: T) => string; serializer?: (rows: T[]) => AgentPayloadInput; }\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -1,6 +1,7 @@
1
- import { C as ContentTransferReference } from '../extensions-DCHtNwG3.cjs';
2
- import { ComponentType, ReactNode } from 'react';
1
+ import { ContentTransferReference, ContentTransferController } from '../content-transfer.cjs';
2
+ import { ComponentType, ReactNode, Ref } from 'react';
3
3
  import '@ai-matrx/kit/content-transfer';
4
+ import '../content-transfer/icon.cjs';
4
5
 
5
6
  type CopyResolvable<T> = T | (() => T);
6
7
  type CopyScalar = string | number | boolean | null | undefined;
@@ -129,6 +130,10 @@ interface CopyControlProps {
129
130
  aiCustom?: AiCustomSource;
130
131
  export?: CopyExportConfig;
131
132
  hide?: Array<"copy" | "ai" | "export">;
133
+ /** Programmatic host port for an existing menu; never uses a DOM click. */
134
+ controllerRef?: Ref<ContentTransferController>;
135
+ /** The host supplies the visible command. */
136
+ triggerHidden?: boolean;
132
137
  }
133
138
  interface CopySubsetColumn<T> {
134
139
  id: string;
@@ -1,6 +1,7 @@
1
- import { C as ContentTransferReference } from '../extensions-DCHtNwG3.js';
2
- import { ComponentType, ReactNode } from 'react';
1
+ import { ContentTransferReference, ContentTransferController } from '../content-transfer.js';
2
+ import { ComponentType, ReactNode, Ref } from 'react';
3
3
  import '@ai-matrx/kit/content-transfer';
4
+ import '../content-transfer/icon.js';
4
5
 
5
6
  type CopyResolvable<T> = T | (() => T);
6
7
  type CopyScalar = string | number | boolean | null | undefined;
@@ -129,6 +130,10 @@ interface CopyControlProps {
129
130
  aiCustom?: AiCustomSource;
130
131
  export?: CopyExportConfig;
131
132
  hide?: Array<"copy" | "ai" | "export">;
133
+ /** Programmatic host port for an existing menu; never uses a DOM click. */
134
+ controllerRef?: Ref<ContentTransferController>;
135
+ /** The host supplies the visible command. */
136
+ triggerHidden?: boolean;
132
137
  }
133
138
  interface CopySubsetColumn<T> {
134
139
  id: string;
@@ -1353,8 +1353,9 @@ function ContentTransferMenu(props) {
1353
1353
  const identityKey = props.capabilities?.identityKey ?? inherited.identityKey;
1354
1354
  return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ContentTransferMenuSession, { ...props }, identityKey ?? "anonymous");
1355
1355
  }
1356
- function ContentTransferMenuSession({ references = [], referenceActions = [], source, surface, label, projection, sections, preferences, table, formatSources, sourceFormats = true, variants = EMPTY_VARIANTS, actions = [], capabilities: local, disabled, enabled = true, className, stopPropagation = true, hide = [], controllerRef, icon = "portal", triggerVariant = "transparent", triggerSize = "default" }) {
1356
+ function ContentTransferMenuSession({ references = [], referenceActions = [], source, surface, label, projection, sections, preferences, table, formatSources, sourceFormats = true, variants = EMPTY_VARIANTS, actions = [], capabilities: local, disabled, enabled = true, className, stopPropagation = true, hide = [], controllerRef, icon = "portal", triggerVariant = "transparent", triggerSize = "default", triggerHidden = false }) {
1357
1357
  const triggerRef = React9.useRef(null);
1358
+ const restoreFocusRef = React9.useRef(null);
1358
1359
  const inherited = React9.useContext(CapabilityContext);
1359
1360
  const nearestSurface = React9.useContext(SurfaceContext);
1360
1361
  const fence = useFence();
@@ -1604,13 +1605,21 @@ function ContentTransferMenuSession({ references = [], referenceActions = [], so
1604
1605
  );
1605
1606
  React9.useImperativeHandle(controllerRef, () => ({
1606
1607
  focusTrigger: () => triggerRef.current?.focus(),
1608
+ preparePrimary: async (options) => {
1609
+ if (!enabled) throw new Error("Alchemy is not enabled for this record.");
1610
+ if (disabled) throw new Error("Alchemy is disabled for this record.");
1611
+ if (hide.includes("prepare")) throw new Error("Alchemy preparation is unavailable for this record.");
1612
+ if (!primary) throw new Error("Alchemy has no source to prepare.");
1613
+ restoreFocusRef.current = options?.restoreFocus ?? null;
1614
+ await openWorkspace(primaryWorkspaceKey, { source: primary, label: sourceLabel });
1615
+ },
1607
1616
  prepare: async (requestedSource, options) => {
1608
1617
  const requestedLabel = options?.label ?? ("label" in requestedSource ? requestedSource.label : "content");
1609
1618
  const requestedKey = `controller:${options?.id ?? "source"}:${materialIdentity(requestedSource)}`;
1610
1619
  externalWorkspaceKeys.current.add(requestedKey);
1611
1620
  await openWorkspace(requestedKey, { source: requestedSource, label: requestedLabel });
1612
1621
  }
1613
- }), [openWorkspace]);
1622
+ }), [disabled, enabled, hide, openWorkspace, primary, primaryWorkspaceKey, sourceLabel]);
1614
1623
  const runAction = React9.useCallback(async (action) => {
1615
1624
  const { controller, id } = fence.begin();
1616
1625
  try {
@@ -1693,7 +1702,7 @@ function ContentTransferMenuSession({ references = [], referenceActions = [], so
1693
1702
  ] }, id);
1694
1703
  };
1695
1704
  return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("span", { className: cn("matrx-alchemy", className), onClick: stopPropagation ? (event) => event.stopPropagation() : void 0, children: [
1696
- /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(Popover, { open: paletteOpen, onOpenChange: (open) => {
1705
+ !triggerHidden ? /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(Popover, { open: paletteOpen, onOpenChange: (open) => {
1697
1706
  setPaletteOpen(open);
1698
1707
  if (open) {
1699
1708
  setMode("copy");
@@ -1802,13 +1811,13 @@ function ContentTransferMenuSession({ references = [], referenceActions = [], so
1802
1811
  ] }, group) : null;
1803
1812
  })
1804
1813
  ] })
1805
- ] }),
1814
+ ] }) : null,
1806
1815
  notice && triggerRef.current ? (0, import_react_dom.createPortal)(/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "matrx-alchemy-feedback", children: [
1807
1816
  /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { role: "status", children: notice }),
1808
1817
  /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ReceiptLink, { target: receiptTarget }),
1809
1818
  /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("button", { type: "button", "aria-label": "Dismiss Alchemy feedback", onClick: () => setNotice(null), children: "\xD7" })
1810
1819
  ] }), triggerRef.current.ownerDocument.body) : null,
1811
- Object.values(workspaces).map((saved) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(PreparationWorkspace, { restoreFocus: () => triggerRef.current?.focus(), open: workspaceOpen && workspaceKey === saved.key, state: saved, scopes, scopeLabels: table?.scopeLabels, onClose: () => setWorkspaceOpen(false), onChange: (next) => setWorkspaces((current) => ({ ...current, [saved.key]: next })), transport, adapters, actions: preparedActions, captureScope: workspaceCaptures.current.get(saved.key) ?? capturePrimary, ...ai ? { ai } : {}, onOutcome: report }, saved.key)),
1820
+ Object.values(workspaces).map((saved) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(PreparationWorkspace, { restoreFocus: () => restoreFocusRef.current?.() ?? triggerRef.current?.focus(), open: workspaceOpen && workspaceKey === saved.key, state: saved, scopes, scopeLabels: table?.scopeLabels, onClose: () => setWorkspaceOpen(false), onChange: (next) => setWorkspaces((current) => ({ ...current, [saved.key]: next })), transport, adapters, actions: preparedActions, captureScope: workspaceCaptures.current.get(saved.key) ?? capturePrimary, ...ai ? { ai } : {}, onOutcome: report }, saved.key)),
1812
1821
  emailReview
1813
1822
  ] });
1814
1823
  }
@@ -2615,7 +2624,12 @@ function MatrxCopyMenuSession(props) {
2615
2624
  ...props.referenceActions ? { referenceActions: props.referenceActions } : {},
2616
2625
  ...props.icon !== void 0 ? { icon: props.icon } : {},
2617
2626
  ...props.triggerVariant !== void 0 ? { triggerVariant: props.triggerVariant } : {},
2618
- controllerRef: controller,
2627
+ controllerRef: (value) => {
2628
+ controller.current = value;
2629
+ if (typeof props.controllerRef === "function") props.controllerRef(value);
2630
+ else if (props.controllerRef) props.controllerRef.current = value;
2631
+ },
2632
+ ...props.triggerHidden ? { triggerHidden: true } : {},
2619
2633
  label: props.label,
2620
2634
  variants,
2621
2635
  actions,
@@ -2913,6 +2927,9 @@ var HostContext = hostRegistry[HOST_SLOT] ??= (0, import_react2.createContext)({
2913
2927
  function useMatrxDataTableHost() {
2914
2928
  return (0, import_react2.useContext)(HostContext);
2915
2929
  }
2930
+ var ROW_ALCHEMY_SLOT = /* @__PURE__ */ Symbol.for("ai-matrx.design-system.table-row-alchemy-context");
2931
+ var rowAlchemyRegistry = globalThis;
2932
+ var RowAlchemyContext = rowAlchemyRegistry[ROW_ALCHEMY_SLOT] ??= (0, import_react2.createContext)(null);
2916
2933
 
2917
2934
  // src/data-table/copy.tsx
2918
2935
  var import_jsx_runtime13 = require("react/jsx-runtime");