@arbidocs/blocks 0.4.96 → 0.4.97

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 (73) hide show
  1. package/dist/agents/index.cjs +280 -280
  2. package/dist/agents/index.js +4 -4
  3. package/dist/{chunk-3WW32OUU.cjs → chunk-3US5OIDQ.cjs} +3 -3
  4. package/dist/{chunk-3WW32OUU.cjs.map → chunk-3US5OIDQ.cjs.map} +1 -1
  5. package/dist/{chunk-SJVUKXS6.js → chunk-5NQIBJPP.js} +5 -5
  6. package/dist/{chunk-SJVUKXS6.js.map → chunk-5NQIBJPP.js.map} +1 -1
  7. package/dist/chunk-D54JXTPG.cjs +164 -0
  8. package/dist/chunk-D54JXTPG.cjs.map +1 -0
  9. package/dist/{chunk-MROSCSPW.cjs → chunk-DDYXFALG.cjs} +43 -43
  10. package/dist/{chunk-MROSCSPW.cjs.map → chunk-DDYXFALG.cjs.map} +1 -1
  11. package/dist/{chunk-CK6TU76J.cjs → chunk-EHB7J6SR.cjs} +5 -5
  12. package/dist/{chunk-CK6TU76J.cjs.map → chunk-EHB7J6SR.cjs.map} +1 -1
  13. package/dist/{chunk-SC33PQTQ.cjs → chunk-GVOTXXZG.cjs} +5 -5
  14. package/dist/{chunk-SC33PQTQ.cjs.map → chunk-GVOTXXZG.cjs.map} +1 -1
  15. package/dist/{chunk-7RI3G5BO.cjs → chunk-HGJGALLN.cjs} +296 -53
  16. package/dist/chunk-HGJGALLN.cjs.map +1 -0
  17. package/dist/{chunk-PSN4VWI7.cjs → chunk-LENXDIMY.cjs} +5 -5
  18. package/dist/{chunk-PSN4VWI7.cjs.map → chunk-LENXDIMY.cjs.map} +1 -1
  19. package/dist/{chunk-SF4BDUZS.js → chunk-PGDL26TQ.js} +3 -3
  20. package/dist/{chunk-SF4BDUZS.js.map → chunk-PGDL26TQ.js.map} +1 -1
  21. package/dist/{chunk-K27SDLLN.js → chunk-QIEEFBZ5.js} +299 -56
  22. package/dist/chunk-QIEEFBZ5.js.map +1 -0
  23. package/dist/{chunk-Y52CEKVD.js → chunk-RSUOOMPT.js} +3 -3
  24. package/dist/{chunk-Y52CEKVD.js.map → chunk-RSUOOMPT.js.map} +1 -1
  25. package/dist/{chunk-H4SVY5FH.js → chunk-YH6SSJDW.js} +3 -3
  26. package/dist/{chunk-H4SVY5FH.js.map → chunk-YH6SSJDW.js.map} +1 -1
  27. package/dist/{chunk-JID3CZSY.js → chunk-Z3G65XHZ.js} +3 -3
  28. package/dist/{chunk-JID3CZSY.js.map → chunk-Z3G65XHZ.js.map} +1 -1
  29. package/dist/chunk-ZCOVDK2E.js +153 -0
  30. package/dist/chunk-ZCOVDK2E.js.map +1 -0
  31. package/dist/components/DetailPanel.d.ts +106 -0
  32. package/dist/connect/docx.cjs +6 -6
  33. package/dist/connect/docx.js +4 -4
  34. package/dist/connect/index.cjs +25 -25
  35. package/dist/connect/index.js +5 -5
  36. package/dist/databases/DatabaseRowDetail.d.ts +32 -0
  37. package/dist/databases/DatabaseTable.d.ts +3 -1
  38. package/dist/databases/DatabaseToolbar.d.ts +9 -1
  39. package/dist/databases/PickCellEditor.d.ts +8 -1
  40. package/dist/databases/SelectCellEditor.d.ts +6 -1
  41. package/dist/databases/column-types.d.ts +5 -0
  42. package/dist/databases/databaseColumns.d.ts +7 -0
  43. package/dist/databases/index.cjs +381 -11
  44. package/dist/databases/index.cjs.map +1 -1
  45. package/dist/databases/index.d.ts +7 -5
  46. package/dist/databases/index.js +379 -14
  47. package/dist/databases/index.js.map +1 -1
  48. package/dist/databases/linkCells.d.ts +4 -2
  49. package/dist/docx/RibbonMenu.d.ts +15 -0
  50. package/dist/docx/StyleGallery.d.ts +9 -0
  51. package/dist/docx/WordReferences.d.ts +21 -0
  52. package/dist/docx/index.cjs +24 -24
  53. package/dist/docx/index.js +3 -3
  54. package/dist/docx/wordStyles.d.ts +21 -0
  55. package/dist/files/index.cjs +308 -0
  56. package/dist/files/index.cjs.map +1 -1
  57. package/dist/files/index.js +298 -2
  58. package/dist/files/index.js.map +1 -1
  59. package/dist/files/views/gridViews.d.ts +80 -0
  60. package/dist/files/views/index.d.ts +2 -0
  61. package/dist/files/views/useGridViews.d.ts +38 -0
  62. package/dist/index.cjs +428 -428
  63. package/dist/index.cjs.map +1 -1
  64. package/dist/index.d.ts +1 -0
  65. package/dist/index.js +87 -126
  66. package/dist/index.js.map +1 -1
  67. package/dist/tags/TagDetail.d.ts +1 -0
  68. package/dist/workflow-canvas/index.cjs +47 -47
  69. package/dist/workflow-canvas/index.js +4 -4
  70. package/package.json +4 -4
  71. package/src/docx/styles.css +91 -0
  72. package/dist/chunk-7RI3G5BO.cjs.map +0 -1
  73. package/dist/chunk-K27SDLLN.js.map +0 -1
@@ -34,15 +34,17 @@ export declare function PersonCell({ value, titles }: {
34
34
  value: unknown;
35
35
  titles?: Record<string, string>;
36
36
  }): import("react").JSX.Element | null;
37
- export declare function LinkChipsCell({ value, titles, kind, onOpenDocument, }: {
37
+ export declare function LinkChipsCell({ value, titles, kind, onOpenDocument, wrap, }: {
38
38
  value: unknown;
39
39
  titles?: Record<string, string>;
40
40
  kind: 'document' | 'relation';
41
41
  onOpenDocument?: (id: string) => void;
42
+ wrap?: boolean;
42
43
  }): import("react").JSX.Element | null;
43
44
  /** A lookup's values: related rows and documents as chips, anything else as quiet tags. */
44
- export declare function LookupCell({ value, titles, locale, }: {
45
+ export declare function LookupCell({ value, titles, locale, wrap, }: {
45
46
  value: unknown;
46
47
  titles?: Record<string, string>;
47
48
  locale?: string;
49
+ wrap?: boolean;
48
50
  }): import("react").JSX.Element | null;
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ /**
3
+ * A ribbon button that opens a panel under the ribbon (Font, More formatting, the style gallery).
4
+ * Pressing the trigger never takes the caret out of the document; the panel closes on Escape or a
5
+ * press outside it. `children` may be a function that receives `close`, for panels that close
6
+ * themselves once the user has picked something.
7
+ */
8
+ export declare function RibbonMenu({ label, icon, children, className, testId, }: {
9
+ label: string;
10
+ /** Trigger content: an icon, or a short text label with a `className` that widens it. */
11
+ icon: React.ReactNode;
12
+ children: React.ReactNode | ((close: () => void) => React.ReactNode);
13
+ className?: string;
14
+ testId?: string;
15
+ }): React.JSX.Element;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Word's Styles group for the native editor's Home tab: a box showing the current paragraph's
3
+ * style that opens a gallery of the document's own paragraph styles (from its `styles.xml`, so a
4
+ * firm template's styles appear beside the built-ins), each drawn in its own face, with Normal,
5
+ * Title and Headings 1-3 as quick picks. Applying a style writes `w:pStyle`.
6
+ */
7
+ import React from 'react';
8
+ /** The Home tab's style box: the current paragraph style, opening the gallery. */
9
+ export declare function StyleGallery(): React.JSX.Element;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Footnotes and endnotes for the native editor's References tab, and Word's keyboard shortcuts
3
+ * for notes and paragraph styles.
4
+ *
5
+ * The engine owns notes end to end: Insert footnote writes a `w:footnoteReference` at the caret
6
+ * and its note in `footnotes.xml` (creating the part on a document that has none), moves the caret
7
+ * into the note so the user types it straight away, numbers notes in document order, and lays
8
+ * them out at the foot of the page, where an existing note is edited in place. What it leaves out
9
+ * is Word's note paragraph style, so a new note is given the document's "footnote text" (or
10
+ * "endnote text") style when it defines one.
11
+ */
12
+ import React, { type RefObject } from 'react';
13
+ /** References tab: Insert footnote, Insert endnote. */
14
+ export declare function NoteButtons(): React.JSX.Element;
15
+ /**
16
+ * Binds Word's note and style shortcuts to key presses inside `scope` (the editor's page area),
17
+ * ahead of the editor's own handling. Renders nothing; mount it inside `DocxEditor.Root`.
18
+ */
19
+ export declare function WordShortcuts({ scope }: {
20
+ scope: RefObject<HTMLElement | null>;
21
+ }): null;
@@ -1,8 +1,8 @@
1
1
  "use client";
2
2
  'use strict';
3
3
 
4
- var chunkSC33PQTQ_cjs = require('../chunk-SC33PQTQ.cjs');
5
- var chunk7RI3G5BO_cjs = require('../chunk-7RI3G5BO.cjs');
4
+ var chunkGVOTXXZG_cjs = require('../chunk-GVOTXXZG.cjs');
5
+ var chunkHGJGALLN_cjs = require('../chunk-HGJGALLN.cjs');
6
6
  require('../chunk-AOFATOT3.cjs');
7
7
  require('../chunk-RC25WMVB.cjs');
8
8
  require('../chunk-7UTB4PHM.cjs');
@@ -60,7 +60,7 @@ function NativeDocxComparison({
60
60
  if (!documentId)
61
61
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "native-docx-error", role: "status", children: "Comparing Word documents\u2026" });
62
62
  return /* @__PURE__ */ jsxRuntime.jsx(
63
- chunk7RI3G5BO_cjs.NativeDocxEditor,
63
+ chunkHGJGALLN_cjs.NativeDocxEditor,
64
64
  {
65
65
  adapter,
66
66
  documentId,
@@ -72,87 +72,87 @@ function NativeDocxComparison({
72
72
 
73
73
  Object.defineProperty(exports, "StreamedWordArtifact", {
74
74
  enumerable: true,
75
- get: function () { return chunkSC33PQTQ_cjs.StreamedWordArtifact; }
75
+ get: function () { return chunkGVOTXXZG_cjs.StreamedWordArtifact; }
76
76
  });
77
77
  Object.defineProperty(exports, "DEFAULT_DEFINED_TERMS_LABELS", {
78
78
  enumerable: true,
79
- get: function () { return chunk7RI3G5BO_cjs.DEFAULT_DEFINED_TERMS_LABELS; }
79
+ get: function () { return chunkHGJGALLN_cjs.DEFAULT_DEFINED_TERMS_LABELS; }
80
80
  });
81
81
  Object.defineProperty(exports, "DEFINED_TERM_TRIGGER", {
82
82
  enumerable: true,
83
- get: function () { return chunk7RI3G5BO_cjs.DEFINED_TERM_TRIGGER; }
83
+ get: function () { return chunkHGJGALLN_cjs.DEFINED_TERM_TRIGGER; }
84
84
  });
85
85
  Object.defineProperty(exports, "DefinedTermsProvider", {
86
86
  enumerable: true,
87
- get: function () { return chunk7RI3G5BO_cjs.DefinedTermsProvider; }
87
+ get: function () { return chunkHGJGALLN_cjs.DefinedTermsProvider; }
88
88
  });
89
89
  Object.defineProperty(exports, "DocxCommentActivity", {
90
90
  enumerable: true,
91
- get: function () { return chunk7RI3G5BO_cjs.DocxCommentActivity; }
91
+ get: function () { return chunkHGJGALLN_cjs.DocxCommentActivity; }
92
92
  });
93
93
  Object.defineProperty(exports, "DocxEditorReview", {
94
94
  enumerable: true,
95
- get: function () { return chunk7RI3G5BO_cjs.DocxEditorReview; }
95
+ get: function () { return chunkHGJGALLN_cjs.DocxEditorReview; }
96
96
  });
97
97
  Object.defineProperty(exports, "DocxMentions", {
98
98
  enumerable: true,
99
- get: function () { return chunk7RI3G5BO_cjs.DocxMentions; }
99
+ get: function () { return chunkHGJGALLN_cjs.DocxMentions; }
100
100
  });
101
101
  Object.defineProperty(exports, "DocxParticipants", {
102
102
  enumerable: true,
103
- get: function () { return chunk7RI3G5BO_cjs.DocxParticipants; }
103
+ get: function () { return chunkHGJGALLN_cjs.DocxParticipants; }
104
104
  });
105
105
  Object.defineProperty(exports, "DocxRibbon", {
106
106
  enumerable: true,
107
- get: function () { return chunk7RI3G5BO_cjs.DocxRibbon; }
107
+ get: function () { return chunkHGJGALLN_cjs.DocxRibbon; }
108
108
  });
109
109
  Object.defineProperty(exports, "NativeDocxEditor", {
110
110
  enumerable: true,
111
- get: function () { return chunk7RI3G5BO_cjs.NativeDocxEditor; }
111
+ get: function () { return chunkHGJGALLN_cjs.NativeDocxEditor; }
112
112
  });
113
113
  Object.defineProperty(exports, "editorPort", {
114
114
  enumerable: true,
115
- get: function () { return chunk7RI3G5BO_cjs.editorPort; }
115
+ get: function () { return chunkHGJGALLN_cjs.editorPort; }
116
116
  });
117
117
  Object.defineProperty(exports, "findDefinitionsSection", {
118
118
  enumerable: true,
119
- get: function () { return chunk7RI3G5BO_cjs.findDefinitionsSection; }
119
+ get: function () { return chunkHGJGALLN_cjs.findDefinitionsSection; }
120
120
  });
121
121
  Object.defineProperty(exports, "insertDefinedTerm", {
122
122
  enumerable: true,
123
- get: function () { return chunk7RI3G5BO_cjs.insertDefinedTerm; }
123
+ get: function () { return chunkHGJGALLN_cjs.insertDefinedTerm; }
124
124
  });
125
125
  Object.defineProperty(exports, "loadDocxFonts", {
126
126
  enumerable: true,
127
- get: function () { return chunk7RI3G5BO_cjs.loadDocxFonts; }
127
+ get: function () { return chunkHGJGALLN_cjs.loadDocxFonts; }
128
128
  });
129
129
  Object.defineProperty(exports, "normalizeDocxExport", {
130
130
  enumerable: true,
131
- get: function () { return chunk7RI3G5BO_cjs.normalizeDocxExport; }
131
+ get: function () { return chunkHGJGALLN_cjs.normalizeDocxExport; }
132
132
  });
133
133
  Object.defineProperty(exports, "reviewModule", {
134
134
  enumerable: true,
135
- get: function () { return chunk7RI3G5BO_cjs.reviewModule; }
135
+ get: function () { return chunkHGJGALLN_cjs.reviewModule; }
136
136
  });
137
137
  Object.defineProperty(exports, "updateDefinitions", {
138
138
  enumerable: true,
139
- get: function () { return chunk7RI3G5BO_cjs.updateDefinitions; }
139
+ get: function () { return chunkHGJGALLN_cjs.updateDefinitions; }
140
140
  });
141
141
  Object.defineProperty(exports, "useDefinedTerms", {
142
142
  enumerable: true,
143
- get: function () { return chunk7RI3G5BO_cjs.useDefinedTerms; }
143
+ get: function () { return chunkHGJGALLN_cjs.useDefinedTerms; }
144
144
  });
145
145
  Object.defineProperty(exports, "useReview", {
146
146
  enumerable: true,
147
- get: function () { return chunk7RI3G5BO_cjs.useReview; }
147
+ get: function () { return chunkHGJGALLN_cjs.useReview; }
148
148
  });
149
149
  Object.defineProperty(exports, "useReviewItem", {
150
150
  enumerable: true,
151
- get: function () { return chunk7RI3G5BO_cjs.useReviewItem; }
151
+ get: function () { return chunkHGJGALLN_cjs.useReviewItem; }
152
152
  });
153
153
  Object.defineProperty(exports, "withDirectEditing", {
154
154
  enumerable: true,
155
- get: function () { return chunk7RI3G5BO_cjs.withDirectEditing; }
155
+ get: function () { return chunkHGJGALLN_cjs.withDirectEditing; }
156
156
  });
157
157
  Object.defineProperty(exports, "DocxEditor", {
158
158
  enumerable: true,
@@ -1,7 +1,7 @@
1
1
  "use client";
2
- export { StreamedWordArtifact } from '../chunk-Y52CEKVD.js';
3
- import { NativeDocxEditor } from '../chunk-K27SDLLN.js';
4
- export { DEFAULT_DEFINED_TERMS_LABELS, DEFINED_TERM_TRIGGER, DefinedTermsProvider, DocxCommentActivity, DocxEditorReview, DocxMentions, DocxParticipants, DocxRibbon, NativeDocxEditor, editorPort, findDefinitionsSection, insertDefinedTerm, loadDocxFonts, normalizeDocxExport, reviewModule, updateDefinitions, useDefinedTerms, useReview, useReviewItem, withDirectEditing } from '../chunk-K27SDLLN.js';
2
+ export { StreamedWordArtifact } from '../chunk-RSUOOMPT.js';
3
+ import { NativeDocxEditor } from '../chunk-QIEEFBZ5.js';
4
+ export { DEFAULT_DEFINED_TERMS_LABELS, DEFINED_TERM_TRIGGER, DefinedTermsProvider, DocxCommentActivity, DocxEditorReview, DocxMentions, DocxParticipants, DocxRibbon, NativeDocxEditor, editorPort, findDefinitionsSection, insertDefinedTerm, loadDocxFonts, normalizeDocxExport, reviewModule, updateDefinitions, useDefinedTerms, useReview, useReviewItem, withDirectEditing } from '../chunk-QIEEFBZ5.js';
5
5
  import '../chunk-D3QPYKZG.js';
6
6
  import '../chunk-AF6RDAJF.js';
7
7
  import '../chunk-AA3PT6KR.js';
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Word's paragraph-style vocabulary for the native editor's chrome: finding a built-in style in
3
+ * the document's own list, showing its name the way Word does, and Word's keyboard shortcuts for
4
+ * styles and notes.
5
+ */
6
+ import type { ParagraphStyleOption } from '@docx-editor.dev/react';
7
+ /** Word's quick picks, by the built-in style names `styles.xml` gives them. */
8
+ export declare const QUICK_STYLES: readonly ["Normal", "Title", "heading 1", "heading 2", "heading 3"];
9
+ /**
10
+ * The style `name` names, matched the way Word matches built-in names (case-insensitively), with
11
+ * the conventional id (`Heading1` for "heading 1") as a fallback for documents that name their
12
+ * styles differently but keep Word's ids.
13
+ */
14
+ export declare function findStyle(options: readonly ParagraphStyleOption[], name: string): ParagraphStyleOption | undefined;
15
+ /** A style's name as Word shows it: built-in names are stored lower-case ("heading 1"). */
16
+ export declare function styleLabel(name: string): string;
17
+ /**
18
+ * Word's shortcut for a keydown, or null. Ctrl+Alt (Cmd+Option on a Mac) with F, D or 1-3, and
19
+ * Ctrl+Shift+N; read from `code` so a keyboard layout cannot move them.
20
+ */
21
+ export declare function wordShortcut(event: Pick<KeyboardEvent, 'ctrlKey' | 'metaKey' | 'altKey' | 'shiftKey' | 'code'>): 'footnote' | 'endnote' | 'heading 1' | 'heading 2' | 'heading 3' | 'Normal' | null;
@@ -6152,6 +6152,302 @@ function TagFormFooter({
6152
6152
  )
6153
6153
  ] });
6154
6154
  }
6155
+
6156
+ // src/files/views/gridViews.ts
6157
+ var SELECTION_COL_ID = "ag-Grid-SelectionColumn";
6158
+ var live = (api) => Boolean(api && !api.isDestroyed());
6159
+ function visibleColumns(api, ignored, fallback) {
6160
+ if (!live(api)) return fallback;
6161
+ const state = api.getColumnState();
6162
+ if (!state) return fallback;
6163
+ return state.filter((c) => !c.hide && !ignored.has(c.colId)).map((c) => c.colId);
6164
+ }
6165
+ function columnsMatch(api, current, viewColumns) {
6166
+ const gridIds = live(api) ? new Set(api.getColumns()?.map((c) => c.getColId()) ?? []) : null;
6167
+ const effective = gridIds ? viewColumns.filter((c) => gridIds.has(c)) : viewColumns;
6168
+ return current.length === effective.length && current.every((c, i) => c === effective[i]);
6169
+ }
6170
+ function widthsMatch(api, widths) {
6171
+ if (!widths || !live(api)) return true;
6172
+ const byId = new Map(api.getColumnState().map((c) => [c.colId, c.width]));
6173
+ return Object.entries(widths).every(([colId, w]) => {
6174
+ const cur = byId.get(colId);
6175
+ return cur != null && Math.round(cur) === Math.round(w);
6176
+ });
6177
+ }
6178
+ function pinnedLeftColumns(api) {
6179
+ if (!live(api)) return /* @__PURE__ */ new Set();
6180
+ return new Set(
6181
+ api.getColumnState().filter((c) => c.pinned === "left").map((c) => c.colId)
6182
+ );
6183
+ }
6184
+ function captureColumnWidths(api, ignored) {
6185
+ const widths = {};
6186
+ if (!live(api)) return widths;
6187
+ for (const col of api.getColumnState()) {
6188
+ if (ignored.has(col.colId) || col.hide) continue;
6189
+ if (col.flex != null) continue;
6190
+ if (typeof col.width === "number") widths[col.colId] = col.width;
6191
+ }
6192
+ return widths;
6193
+ }
6194
+ function columnItems(api, visible, canonical, ignored) {
6195
+ if (!live(api)) return [];
6196
+ const state = api.getColumnState();
6197
+ if (!state) return [];
6198
+ const shown = new Set(visible);
6199
+ const all = /* @__PURE__ */ new Map();
6200
+ for (const col of state) {
6201
+ if (ignored.has(col.colId)) continue;
6202
+ const def = api.getColumnDef(col.colId);
6203
+ all.set(col.colId, {
6204
+ colId: col.colId,
6205
+ label: def?.headerName || col.colId,
6206
+ hidden: !shown.has(col.colId)
6207
+ });
6208
+ }
6209
+ const result = [];
6210
+ const seen = /* @__PURE__ */ new Set();
6211
+ for (const colId of canonical) {
6212
+ const col = all.get(colId);
6213
+ if (col) {
6214
+ result.push(col);
6215
+ seen.add(colId);
6216
+ }
6217
+ }
6218
+ for (const [colId, col] of all) if (!seen.has(colId)) result.push(col);
6219
+ return result;
6220
+ }
6221
+ function toggleColumn(current, colId, canonical) {
6222
+ if (current.includes(colId)) {
6223
+ return current.length <= 1 ? current : current.filter((c) => c !== colId);
6224
+ }
6225
+ const index = canonical.indexOf(colId);
6226
+ const next = [...current];
6227
+ let insertAt = next.length;
6228
+ for (let i = index - 1; i >= 0; i--) {
6229
+ const at = next.indexOf(canonical[i]);
6230
+ if (at !== -1) {
6231
+ insertAt = at + 1;
6232
+ break;
6233
+ }
6234
+ }
6235
+ next.splice(insertAt, 0, colId);
6236
+ return next;
6237
+ }
6238
+ function applyColumnLayout(api, columns) {
6239
+ if (api.isDestroyed()) return;
6240
+ const state = api.getColumnState();
6241
+ const selection = state.find((c) => c.colId === SELECTION_COL_ID);
6242
+ const byId = new Map(state.map((c) => [c.colId, c]));
6243
+ const wanted = new Set(columns);
6244
+ api.applyColumnState({
6245
+ state: [
6246
+ { colId: SELECTION_COL_ID, hide: false, width: selection?.width || 48 },
6247
+ ...columns.map((colId) => {
6248
+ const existing = byId.get(colId);
6249
+ if (existing) return { ...existing, hide: false };
6250
+ const def = api.getColumnDef(colId);
6251
+ return { colId, hide: false, width: def?.width || def?.minWidth || 200 };
6252
+ }),
6253
+ ...state.filter((c) => c.colId !== SELECTION_COL_ID && !wanted.has(c.colId)).map((c) => ({ ...c, hide: true }))
6254
+ ],
6255
+ defaultState: { hide: void 0 },
6256
+ applyOrder: true
6257
+ });
6258
+ api.setColumnsVisible(
6259
+ columns.filter((id) => !id.startsWith("ag-Grid-")),
6260
+ true
6261
+ );
6262
+ api.setColumnsVisible(
6263
+ state.filter((c) => !c.colId.startsWith("ag-Grid-") && !wanted.has(c.colId)).map((c) => c.colId),
6264
+ false
6265
+ );
6266
+ }
6267
+ function applyViewColumns(api, view, applyColumns = (c, a) => applyColumnLayout(a, c)) {
6268
+ applyColumns(view.columns, api);
6269
+ if (view.column_widths && !api.isDestroyed()) {
6270
+ api.applyColumnState({
6271
+ state: Object.entries(view.column_widths).map(([colId, width]) => ({ colId, width })),
6272
+ applyOrder: false
6273
+ });
6274
+ }
6275
+ if (view.pinned_left && !api.isDestroyed()) {
6276
+ const pinned = new Set(view.pinned_left);
6277
+ api.applyColumnState({
6278
+ state: api.getColumnState().map((c) => ({
6279
+ colId: c.colId,
6280
+ pinned: pinned.has(c.colId) ? "left" : null
6281
+ })),
6282
+ applyOrder: false
6283
+ });
6284
+ }
6285
+ }
6286
+ function upsertView(views, view) {
6287
+ return [...views.filter((v) => v.name !== view.name), view];
6288
+ }
6289
+ function useGridViews({
6290
+ getGridApi,
6291
+ defaultColumns,
6292
+ builtins,
6293
+ savedViews,
6294
+ stateVersion,
6295
+ ignoredColumns,
6296
+ currentRowHeight,
6297
+ currentTileSize,
6298
+ defaultTileSize,
6299
+ onApplyColumns,
6300
+ onLoadView,
6301
+ onSaveView,
6302
+ onDeleteView,
6303
+ isSaving
6304
+ }) {
6305
+ const [open, setOpen] = react.useState(false);
6306
+ const [saveName, setSaveName] = react.useState("");
6307
+ const ignoredKey = (ignoredColumns ?? []).join("\0");
6308
+ const ignored = react.useMemo(
6309
+ () => /* @__PURE__ */ new Set([SELECTION_COL_ID, ...ignoredKey ? ignoredKey.split("\0") : []]),
6310
+ [ignoredKey]
6311
+ );
6312
+ const current = react.useMemo(
6313
+ () => visibleColumns(getGridApi(), ignored, defaultColumns),
6314
+ // stateVersion: the grid's column state lives outside React.
6315
+ // eslint-disable-next-line react-hooks/exhaustive-deps
6316
+ [getGridApi, defaultColumns, ignored, stateVersion]
6317
+ );
6318
+ const viewMatches = react.useCallback(
6319
+ (view) => {
6320
+ const api = getGridApi();
6321
+ return columnsMatch(api, current, view.columns) && widthsMatch(api, view.column_widths) && (view.row_height == null || currentRowHeight == null || view.row_height === currentRowHeight) && (view.tile_size == null || currentTileSize == null || view.tile_size === currentTileSize);
6322
+ },
6323
+ [getGridApi, current, currentRowHeight, currentTileSize]
6324
+ );
6325
+ const currentView = react.useMemo(() => {
6326
+ const api = getGridApi();
6327
+ const pinned = pinnedLeftColumns(api);
6328
+ const pinsMatch = (pinnedLeft = []) => pinnedLeft.length > 0 ? pinnedLeft.every((id) => pinned.has(id)) : !pinned.has(SELECTION_COL_ID);
6329
+ if (currentTileSize == null || defaultTileSize == null || currentTileSize === defaultTileSize) {
6330
+ for (const b of builtins) {
6331
+ if ((b.rowHeight == null || currentRowHeight == null || currentRowHeight === b.rowHeight) && pinsMatch(b.pinnedLeft) && columnsMatch(api, current, b.columns))
6332
+ return b.key;
6333
+ }
6334
+ }
6335
+ for (const view of savedViews) if (viewMatches(view)) return view.name;
6336
+ return "unsaved";
6337
+ }, [
6338
+ getGridApi,
6339
+ builtins,
6340
+ current,
6341
+ savedViews,
6342
+ viewMatches,
6343
+ currentRowHeight,
6344
+ currentTileSize,
6345
+ defaultTileSize
6346
+ ]);
6347
+ const loadView = react.useCallback(
6348
+ (key) => {
6349
+ const api = getGridApi();
6350
+ if (!api) return;
6351
+ const builtin = builtins.find((b) => b.key === key);
6352
+ if (builtin) {
6353
+ onLoadView(
6354
+ {
6355
+ name: builtin.key,
6356
+ columns: builtin.columns,
6357
+ row_height: builtin.rowHeight,
6358
+ tile_size: defaultTileSize,
6359
+ pinned_left: builtin.pinnedLeft ?? []
6360
+ },
6361
+ api
6362
+ );
6363
+ setOpen(false);
6364
+ return;
6365
+ }
6366
+ const view = savedViews.find((v) => v.name === key);
6367
+ if (view) {
6368
+ onLoadView(view, api);
6369
+ setOpen(false);
6370
+ }
6371
+ },
6372
+ [getGridApi, builtins, savedViews, onLoadView, defaultTileSize]
6373
+ );
6374
+ const save = react.useCallback(async () => {
6375
+ const name = saveName.trim();
6376
+ if (!name) return;
6377
+ const api = getGridApi();
6378
+ const view = {
6379
+ name,
6380
+ columns: current,
6381
+ column_widths: captureColumnWidths(api, ignored),
6382
+ ...currentTileSize != null ? { tile_size: currentTileSize } : {},
6383
+ ...currentRowHeight != null ? { row_height: currentRowHeight } : {}
6384
+ };
6385
+ try {
6386
+ await onSaveView(view);
6387
+ } catch {
6388
+ return;
6389
+ }
6390
+ setSaveName("");
6391
+ setOpen(false);
6392
+ if (api && !api.isDestroyed()) onLoadView(view, api);
6393
+ }, [
6394
+ saveName,
6395
+ getGridApi,
6396
+ current,
6397
+ ignored,
6398
+ currentTileSize,
6399
+ currentRowHeight,
6400
+ onSaveView,
6401
+ onLoadView
6402
+ ]);
6403
+ const remove = react.useCallback(
6404
+ async (name) => {
6405
+ const deleted = await onDeleteView(name);
6406
+ if (deleted === false) return;
6407
+ if (currentView === name && builtins[0]) loadView(builtins[0].key);
6408
+ },
6409
+ [onDeleteView, currentView, builtins, loadView]
6410
+ );
6411
+ const columns = react.useMemo(
6412
+ () => columnItems(getGridApi(), current, defaultColumns, ignored),
6413
+ [getGridApi, current, defaultColumns, ignored]
6414
+ );
6415
+ const toggle = react.useCallback(
6416
+ (colId) => {
6417
+ const api = getGridApi();
6418
+ if (!api || api.isDestroyed()) return;
6419
+ const next = toggleColumn(
6420
+ current,
6421
+ colId,
6422
+ columns.map((c) => c.colId)
6423
+ );
6424
+ if (next !== current) onApplyColumns(next, api);
6425
+ },
6426
+ [getGridApi, current, columns, onApplyColumns]
6427
+ );
6428
+ const builtinItems = react.useMemo(
6429
+ () => builtins.map(({ key, label, icon, testId }) => ({ key, label, icon, testId })),
6430
+ [builtins]
6431
+ );
6432
+ return {
6433
+ open,
6434
+ onOpenChange: (next) => {
6435
+ setOpen(next);
6436
+ if (!next) setSaveName("");
6437
+ },
6438
+ currentView,
6439
+ builtins: builtinItems,
6440
+ savedViewNames: savedViews.map((v) => v.name),
6441
+ columns,
6442
+ saveName,
6443
+ onSaveNameChange: setSaveName,
6444
+ onSave: () => void save(),
6445
+ isSaving,
6446
+ onSelectView: loadView,
6447
+ onDeleteView: (name) => void remove(name),
6448
+ onToggleColumn: toggle
6449
+ };
6450
+ }
6155
6451
  var DEFAULT_AI_REVIEW_DIALOG_LABELS = {
6156
6452
  title: "AI annotation",
6157
6453
  fieldLabel: "Field",
@@ -6907,6 +7203,7 @@ exports.PassageStepper = PassageStepper;
6907
7203
  exports.PdfPageNav = PdfPageNav;
6908
7204
  exports.RejectedFilesList = RejectedFilesList;
6909
7205
  exports.RelatedDocsCell = RelatedDocsCell;
7206
+ exports.SELECTION_COL_ID = SELECTION_COL_ID;
6910
7207
  exports.SelectedFilesList = SelectedFilesList;
6911
7208
  exports.StatusPill = StatusPill;
6912
7209
  exports.TagColumnHeader = TagColumnHeader;
@@ -6956,12 +7253,23 @@ exports.ViewerPreviewUnavailable = ViewerPreviewUnavailable;
6956
7253
  exports.ViewerTabBar = ViewerTabBar;
6957
7254
  exports.ViewerTitle = ViewerTitle;
6958
7255
  exports.ViewerZoomControl = ViewerZoomControl;
7256
+ exports.applyColumnLayout = applyColumnLayout;
7257
+ exports.applyViewColumns = applyViewColumns;
7258
+ exports.captureColumnWidths = captureColumnWidths;
7259
+ exports.columnItems = columnItems;
7260
+ exports.columnsMatch = columnsMatch;
6959
7261
  exports.documentGridLayoutProps = documentGridLayoutProps;
6960
7262
  exports.fieldsApplyBarCopy = fieldsApplyBarCopy;
6961
7263
  exports.fieldsEmptyText = fieldsEmptyText;
6962
7264
  exports.filterFieldsByName = filterFieldsByName;
6963
7265
  exports.labelChipClampHeight = labelChipClampHeight;
7266
+ exports.pinnedLeftColumns = pinnedLeftColumns;
6964
7267
  exports.resolveDocumentGridLayout = resolveDocumentGridLayout;
6965
7268
  exports.sortFields = sortFields;
7269
+ exports.toggleColumn = toggleColumn;
7270
+ exports.upsertView = upsertView;
7271
+ exports.useGridViews = useGridViews;
7272
+ exports.visibleColumns = visibleColumns;
7273
+ exports.widthsMatch = widthsMatch;
6966
7274
  //# sourceMappingURL=index.cjs.map
6967
7275
  //# sourceMappingURL=index.cjs.map