@gramlot/gramlot 0.3.20 → 0.3.26

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 (172) hide show
  1. package/dist/components/chat/__init__.py +13 -0
  2. package/dist/components/chat/assets/collection.js +9 -0
  3. package/dist/components/chat/assets/index.js +3 -0
  4. package/dist/components/chat/commands.json +7 -0
  5. package/dist/components/chat/grammar.json +48 -0
  6. package/dist/components/editors/__init__.py +2 -2
  7. package/dist/components/editors/assets/collection.js +26 -120912
  8. package/dist/components/editors/assets/index.js +2 -1
  9. package/dist/components/editors/assets/modules/chunk-74O4WKIV.js +1 -0
  10. package/dist/components/editors/assets/modules/chunk-AU4HFPIY.js +1 -0
  11. package/dist/components/editors/assets/modules/chunk-YSGSC7KM.js +1 -0
  12. package/dist/components/editors/assets/modules/code-mirror-engine-RWQTR5G5.js +92 -0
  13. package/dist/components/editors/assets/modules/jodit-engine-MTSA4GZ3.js +1853 -0
  14. package/dist/components/editors/assets/modules/markdown-document-VFC23FAY.js +1 -0
  15. package/dist/components/editors/assets/modules/prose-mirror-engine-GMZPJPNN.js +24 -0
  16. package/dist/components/grid/__init__.py +14 -0
  17. package/dist/components/grid/assets/collection.js +262 -0
  18. package/dist/components/grid/assets/index.js +3 -0
  19. package/dist/components/grid/commands.json +7 -0
  20. package/dist/components/grid/grammar.json +770 -0
  21. package/dist/components/grouplets/__init__.py +13 -0
  22. package/dist/components/grouplets/assets/collection.js +185 -0
  23. package/dist/components/grouplets/assets/index.js +3 -0
  24. package/dist/components/grouplets/assets/modules/chunk-BLMUM44K.js +1 -0
  25. package/dist/components/grouplets/assets/modules/markdown-document-YWNZTOKK.js +1 -0
  26. package/dist/components/grouplets/commands.json +7 -0
  27. package/dist/components/grouplets/grammar.json +355 -0
  28. package/dist/components/inputs/__init__.py +1 -1
  29. package/dist/components/inputs/assets/collection.js +65 -24511
  30. package/dist/components/inputs/assets/index.js +2 -1
  31. package/dist/components/inputs/grammar.json +278 -6
  32. package/dist/components/layout/__init__.py +1 -1
  33. package/dist/components/layout/assets/collection.js +68 -26732
  34. package/dist/components/layout/assets/index.js +2 -1
  35. package/dist/components/layout/grammar.json +39 -0
  36. package/dist/components/selection_trial/__init__.py +13 -0
  37. package/dist/components/selection_trial/assets/collection.js +4 -0
  38. package/dist/components/selection_trial/assets/index.js +3 -0
  39. package/dist/components/selection_trial/commands.json +7 -0
  40. package/dist/components/selection_trial/grammar.json +587 -0
  41. package/dist/components/tree/__init__.py +1 -1
  42. package/dist/components/tree/assets/collection.js +27 -24612
  43. package/dist/components/tree/assets/index.js +2 -1
  44. package/dist/components/tree/grammar.json +341 -1
  45. package/dist/components/typst/__init__.py +2 -2
  46. package/dist/components/typst/assets/collection.js +12 -4
  47. package/dist/components/typst/assets/index.js +2 -1
  48. package/dist/components/typst/assets/modules/chunk-BLMUM44K.js +1 -0
  49. package/dist/components/typst/assets/modules/typst-client-JHC6UVYG.js +4 -0
  50. package/dist/components/uploads/__init__.py +13 -0
  51. package/dist/components/uploads/assets/collection.js +67 -0
  52. package/dist/components/uploads/assets/index.js +3 -0
  53. package/dist/components/uploads/commands.json +7 -0
  54. package/dist/components/uploads/grammar.json +789 -0
  55. package/dist/gramlot-markdown.js +16 -0
  56. package/dist/gramlot.js +6861 -1395
  57. package/dist/gramlot.min.js +1595 -46
  58. package/dist/runtime-notices.json +28 -0
  59. package/package.json +10 -3
  60. package/src/binding/grid-struct.js +63 -0
  61. package/src/binding/installation.js +5 -2
  62. package/src/binding/providers.js +4 -1
  63. package/src/binding/remote-resolver.js +1 -8
  64. package/src/binding/runtime.js +90 -6
  65. package/src/binding/validation-context.js +40 -0
  66. package/src/browser-camera-provider.d.ts +8 -0
  67. package/src/browser-camera-provider.js +104 -0
  68. package/src/builder/gramlot-builder.d.ts +5 -0
  69. package/src/builder/gramlot-builder.js +16 -0
  70. package/src/builder/source.js +34 -0
  71. package/src/chat.d.ts +12 -0
  72. package/src/chat.js +198 -0
  73. package/src/collection-artifact.js +1 -1
  74. package/src/components/attachment-manager.js +160 -0
  75. package/src/components/bases.js +19 -6
  76. package/src/components/border-container.js +86 -8
  77. package/src/components/buttons.js +11 -1
  78. package/src/components/chat.js +28 -0
  79. package/src/components/choice-editor.js +106 -38
  80. package/src/components/database-choices.js +133 -9
  81. package/src/components/editing-status-styles.js +26 -0
  82. package/src/components/editing-status.js +115 -0
  83. package/src/components/field-state.js +42 -54
  84. package/src/components/grid-cell-editor.js +181 -0
  85. package/src/components/grid-grammar.json +258 -0
  86. package/src/components/grid-header-interaction.js +196 -0
  87. package/src/components/grid-row-interaction.js +184 -0
  88. package/src/components/grid-row-layout.js +96 -0
  89. package/src/components/grid-rows.js +28 -0
  90. package/src/components/grid-search-box.js +142 -0
  91. package/src/components/grid-search-styles.js +42 -0
  92. package/src/components/grid-search.js +37 -0
  93. package/src/components/grid-structure.js +85 -0
  94. package/src/components/grid-styles.js +201 -0
  95. package/src/components/grid.js +666 -0
  96. package/src/components/grouplet-card.js +445 -0
  97. package/src/components/grouplets.js +17 -0
  98. package/src/components/html-preview.js +17 -4
  99. package/src/components/image-crop-dialog.js +272 -0
  100. package/src/components/image-crop.js +79 -0
  101. package/src/components/image-uploader.js +252 -0
  102. package/src/components/inputs.js +2 -1
  103. package/src/components/jodit-engine.js +1 -1
  104. package/src/components/markdown-document.js +2 -2
  105. package/src/components/menus.js +1 -0
  106. package/src/components/registry.js +4 -3
  107. package/src/components/screen-capture.js +43 -0
  108. package/src/components/selected-container.js +6 -2
  109. package/src/components/tray-pane.js +32 -4
  110. package/src/components/tree.js +416 -17
  111. package/src/components/typed-editor.js +23 -11
  112. package/src/components/upload-engine.js +156 -0
  113. package/src/components/uploader.js +208 -0
  114. package/src/components/uploads.js +7 -0
  115. package/src/editing-session.d.ts +25 -0
  116. package/src/editing-session.js +396 -0
  117. package/src/experiments/selection-transfer.js +78 -0
  118. package/src/experiments/selection-trial.js +64 -0
  119. package/src/experiments/window-selection.js +124 -0
  120. package/src/format.js +22 -7
  121. package/src/gramlot.d.ts +2 -0
  122. package/src/gramlot.js +2 -1
  123. package/src/handlers/device-handler.d.ts +2 -1
  124. package/src/handlers/rpc-handler.d.ts +3 -3
  125. package/src/index-page-styles.js +2 -1
  126. package/src/index.d.ts +16 -1
  127. package/src/index.js +16 -1
  128. package/src/inout.d.ts +2 -0
  129. package/src/inout.js +6 -0
  130. package/src/markdown-loader.d.ts +1 -0
  131. package/src/markdown-loader.js +4 -0
  132. package/src/markdown.d.ts +1 -0
  133. package/src/markdown.js +2 -0
  134. package/src/media-frame.js +9 -0
  135. package/src/renderer/attributes.js +7 -1
  136. package/src/renderer/gramlot-renderer.d.ts +2 -0
  137. package/src/renderer/gramlot-renderer.js +39 -3
  138. package/src/server/assets.d.ts +1 -1
  139. package/src/server/assets.js +1 -1
  140. package/src/server/gramlot-server.d.ts +10 -1
  141. package/src/server/gramlot-server.js +96 -8
  142. package/src/server/index.d.ts +2 -0
  143. package/src/server/index.js +2 -0
  144. package/src/server/page-base.js +17 -4
  145. package/src/server/page.d.ts +13 -1
  146. package/src/server/page.js +6 -0
  147. package/src/server/source-import.d.ts +2 -0
  148. package/src/server/source-import.js +31 -0
  149. package/src/server/upload.d.ts +20 -0
  150. package/src/server/upload.js +142 -0
  151. package/src/server/visual-editor.d.ts +11 -0
  152. package/src/server/visual-editor.js +149 -0
  153. package/src/source-picker.d.ts +9 -0
  154. package/src/source-picker.js +57 -0
  155. package/src/stores/bag-collection-store.js +51 -0
  156. package/src/stores/bag-collection-view.js +127 -0
  157. package/src/stores/collection-filter.js +77 -0
  158. package/src/tree-store.d.ts +24 -0
  159. package/src/tree-store.js +193 -0
  160. package/src/validation-run.js +50 -0
  161. package/src/view/button.js +8 -5
  162. package/src/view/controls.js +31 -32
  163. package/src/view/grouplet-card.js +54 -0
  164. package/src/view/html.js +29 -4
  165. package/src/view/labelbox.js +7 -3
  166. package/src/visual-editor-icons.js +10 -0
  167. package/src/visual-editor.d.ts +56 -0
  168. package/src/visual-editor.js +844 -0
  169. package/themes/gramlot-base/theme.css +127 -0
  170. package/themes/gramlot-compact/theme.css +8 -0
  171. package/themes/joanna/theme.css +8 -0
  172. package/themes/mimi/theme.css +8 -0
@@ -0,0 +1,666 @@
1
+ import {Bag} from '@gramlot/gramlot';
2
+ import {SVG_NS} from '../renderer/attributes.js';
3
+ import {defineComponent, ComponentCollection} from './registry.js';
4
+ import {Container} from './container.js';
5
+ import {parseSort} from '../stores/bag-collection-view.js';
6
+ import inputs from './inputs.js';
7
+ import {GridCellEditor} from './grid-cell-editor.js';
8
+ import {GridRows} from './grid-rows.js';
9
+ import {GridStructure} from './grid-structure.js';
10
+ import {GridHeaderInteraction} from './grid-header-interaction.js';
11
+ import {GridRowLayout} from './grid-row-layout.js';
12
+ import {GridRowInteraction} from './grid-row-interaction.js';
13
+ import {gridStyles} from './grid-styles.js';
14
+ import {gridSearch} from './grid-search.js';
15
+ import {SearchBox} from './grid-search-box.js';
16
+ import structureGrammar from './grid-grammar.json' with {type: 'json'};
17
+
18
+ /** First grid: explicit Bag row representation and a separately observable Data struct. */
19
+ export const Grid = defineComponent({
20
+ name: 'grid', tag: 'gramlot-grid', base: Container, bagStore: true, bagStruct: true, sourceContext: true, subTags: 'struct,div',
21
+ parameters: {windowInfo: {dtype:'X', nullable:true, default:null, binding:'read'},
22
+ loading: {dtype:'B', default:false, binding:'read'},
23
+ viewport: {dtype:'X', nullable:true, default:null, binding:'write'},
24
+ sortRequest: {dtype:'T', default:'', binding:'write'},
25
+ storepath: {dtype: 'T'}, structpath: {dtype: 'T'}, rowMode: {dtype: 'T'},
26
+ rowHeaders: {dtype:'B', default:false, binding:'read'},
27
+ rowResize: {dtype:'B', default:false, binding:'read'},
28
+ selfDragRows: {dtype:'B', default:false, binding:'read'},
29
+ sortedBy: {dtype:'T', default:'', binding:'read'},
30
+ filter: {annotation:{kind:'type',module:'builtins',name:'dict'}, nullable:true, default:null, binding:'read'}},
31
+ implementation: Base => class extends Base {
32
+ #store;
33
+ #cellEditor;
34
+ #editCell = event => {
35
+ if (event.type === 'keydown' && !['Enter','F2'].includes(event.key)) return;
36
+ const cell = event.target.closest('td[data-field]');
37
+ if (!cell || !this.#structure) return;
38
+ const row = [...this.#rows].find(([, tr]) => tr === cell.parentElement)?.[0];
39
+ const column = this.#structure.columns.find(column => column.field === cell.dataset.field);
40
+ if (row && column.edit) {
41
+ event.preventDefault();
42
+ try { this.#cellEditor.open(row, column, cell); }
43
+ catch (error) { this.#context.reportError(error,'Grid editor'); }
44
+ }
45
+ };
46
+ #windowRevision;
47
+ #windowRequest;
48
+ #context;
49
+ #structure;
50
+ #structBag;
51
+ #structureDirty = true;
52
+ #signature;
53
+ #rows = new Map();
54
+ #head;
55
+ #body;
56
+ #headerTable;
57
+ #bodyTable;
58
+ #headerViewport;
59
+ #bodyViewport;
60
+ #loadingStatus;
61
+ #resizeObserver;
62
+ #layoutFrame = null;
63
+ #headerRows = 1;
64
+ #rowHeaders = false;
65
+ #interaction;
66
+ #rowInteraction;
67
+ #rowLayout;
68
+ #collectionView;
69
+ #requestedSort;
70
+ #requestedFilter;
71
+ #unsubscribeStore;
72
+ #refreshTimer = null;
73
+ #pendingFull = false;
74
+ #pendingRows = new Set();
75
+ #visibleNodes = [];
76
+ #windowStart = -1;
77
+ #windowEnd = -1;
78
+ #topSpace;
79
+ #bottomSpace;
80
+ #geometryKey;
81
+ #endPinned = false;
82
+ #adjustedScroll = null;
83
+ #viewportKey = event => {
84
+ if (event.target !== this.#bodyViewport || !['Home', 'End'].includes(event.key) || !this.#structure) return;
85
+ event.preventDefault();
86
+ this.#endPinned = event.key === 'End';
87
+ this.#scrollTo(this.#endPinned ? Math.max(0, this.#rowLayout.totalHeight - this.#bodyViewport.clientHeight) : 0);
88
+ this.#scheduleLayout();
89
+ };
90
+ #syncScroll = () => {
91
+ const viewport = this.#bodyViewport;
92
+ if (viewport.scrollTop !== this.#adjustedScroll) {
93
+ this.#endPinned = viewport.scrollTop > 0 && viewport.scrollHeight - viewport.clientHeight - viewport.scrollTop <= 1;
94
+ }
95
+ this.#adjustedScroll = null;
96
+ this.#headerViewport.scrollLeft = this.#bodyViewport.scrollLeft;
97
+ this.#scheduleLayout();
98
+ };
99
+ constructor() {
100
+ super();
101
+ const doc = this.ownerDocument;
102
+ const style = doc.createElement('style');
103
+ style.textContent = gridStyles;
104
+ // Two layout tables expose one logical read-only table, with explicit row groups.
105
+ // The header is outside the only user-scrollable viewport.
106
+ this.control.setAttribute('role', 'table');
107
+ this.control.setAttribute('aria-label', 'Grid');
108
+ this.control.setAttribute('part', 'table');
109
+ const headerFrame = doc.createElement('div');
110
+ headerFrame.className = 'header-frame'; headerFrame.setAttribute('part', 'header');
111
+ this.#headerViewport = doc.createElement('div');
112
+ this.#headerViewport.className = 'header-viewport';
113
+ this.#headerViewport.setAttribute('part', 'header-viewport');
114
+ this.#bodyViewport = doc.createElement('div');
115
+ this.#bodyViewport.className = 'body-viewport';
116
+ this.#bodyViewport.setAttribute('part', 'body-viewport');
117
+ this.#bodyViewport.tabIndex = 0;
118
+ this.#bodyViewport.setAttribute('role', 'rowgroup');
119
+ this.#headerTable = doc.createElement('table');
120
+ this.#bodyTable = doc.createElement('table');
121
+ for (const table of [this.#headerTable, this.#bodyTable]) table.setAttribute('role', 'presentation');
122
+ this.#head = doc.createElement('thead'); this.#head.setAttribute('role', 'rowgroup');
123
+ this.#body = doc.createElement('tbody'); this.#body.setAttribute('role', 'presentation');
124
+ this.#headerTable.append(this.#head); this.#bodyTable.append(this.#body);
125
+ this.#headerViewport.append(this.#headerTable); headerFrame.append(this.#headerViewport);
126
+ this.#topSpace = doc.createElement('div');
127
+ this.#bottomSpace = doc.createElement('div');
128
+ for (const space of [this.#topSpace, this.#bottomSpace]) {
129
+ space.className = 'row-space'; space.setAttribute('aria-hidden', 'true');
130
+ }
131
+ this.#bodyViewport.append(this.#topSpace, this.#bodyTable, this.#bottomSpace);
132
+ const bodyFrame = doc.createElement('div'); bodyFrame.className = 'body-frame';
133
+ this.#loadingStatus = doc.createElement('div');
134
+ this.#loadingStatus.className = 'loading-status';
135
+ this.#loadingStatus.setAttribute('role', 'status');
136
+ this.#loadingStatus.setAttribute('aria-label', 'Loading…');
137
+ this.#loadingStatus.hidden = true;
138
+ const spinner = doc.createElementNS(SVG_NS, 'svg');
139
+ spinner.setAttribute('viewBox', '0 0 24 24'); spinner.setAttribute('aria-hidden', 'true');
140
+ const track = doc.createElementNS(SVG_NS, 'circle');
141
+ track.setAttribute('cx', '12'); track.setAttribute('cy', '12'); track.setAttribute('r', '9');
142
+ track.setAttribute('opacity', '.2');
143
+ const arc = doc.createElementNS(SVG_NS, 'path');
144
+ arc.setAttribute('d', 'M12 3a9 9 0 0 1 9 9');
145
+ spinner.append(track, arc); this.#loadingStatus.append(spinner);
146
+ bodyFrame.append(this.#bodyViewport, this.#loadingStatus);
147
+ this.control.replaceChildren(headerFrame, bodyFrame); this.shadowRoot.append(style);
148
+ this.#interaction = new GridHeaderInteraction(this.#head, this.control, () => this.#structure, (field, multiple) => this.#sort(field, multiple),
149
+ () => this.#rowLayout, () => this.#scheduleLayout());
150
+ this.#rowInteraction = new GridRowInteraction(this.#body, this.control, () => this.#rowLayout, row => {
151
+ for (const [node, element] of this.#rows) if (element === row) return node;
152
+ return null;
153
+ }, () => this.#collectionView, () => this.parameters.selfDragRows, () => this.#scheduleLayout());
154
+ this.#resizeObserver = new doc.defaultView.ResizeObserver(() => this.#scheduleLayout());
155
+ }
156
+ connectedCallback() {
157
+ this.#body.addEventListener('dblclick', this.#editCell);
158
+ this.#body.addEventListener('keydown', this.#editCell);
159
+ this.#cellEditor?.connect();
160
+ this.#observeStore();
161
+ if (this.#collectionView) this.#invalidate({full:true, rows:[]});
162
+ this.#interaction.connect();
163
+ this.#rowInteraction.connect();
164
+ this.#bodyViewport.addEventListener('scroll', this.#syncScroll, {passive: true});
165
+ this.#bodyViewport.addEventListener('keydown', this.#viewportKey);
166
+ this.#resizeObserver.observe(this.#bodyViewport);
167
+ this.#resizeObserver.observe(this.#bodyTable);
168
+ this.#scheduleLayout();
169
+ }
170
+ disconnectedCallback() {
171
+ this.#body.removeEventListener('dblclick', this.#editCell);
172
+ this.#body.removeEventListener('keydown', this.#editCell);
173
+ this.#cellEditor?.disconnect();
174
+ this.#cancelRefresh();
175
+ this.#collectionView?.disconnect();
176
+ this.#unsubscribeStore?.(); this.#unsubscribeStore = null;
177
+ this.#interaction.disconnect();
178
+ this.#rowInteraction.disconnect();
179
+ this.#bodyViewport.removeEventListener('scroll', this.#syncScroll);
180
+ this.#bodyViewport.removeEventListener('keydown', this.#viewportKey);
181
+ this.#resizeObserver.disconnect();
182
+ if (this.#layoutFrame !== null) this.ownerDocument.defaultView.cancelAnimationFrame(this.#layoutFrame);
183
+ this.#layoutFrame = null;
184
+ }
185
+ #scheduleLayout() {
186
+ if (!this.isConnected || this.#layoutFrame !== null) return;
187
+ this.#layoutFrame = this.ownerDocument.defaultView.requestAnimationFrame(() => {
188
+ this.#layoutFrame = null;
189
+ const gutter = this.#bodyViewport.offsetWidth - this.#bodyViewport.clientWidth;
190
+ const width = `${gutter}px`;
191
+ if (this.control.style.getPropertyValue('--grid-scrollbar-width') !== width) {
192
+ this.control.style.setProperty('--grid-scrollbar-width', width);
193
+ }
194
+ this.#sizeRowHeader();
195
+ for (const header of this.#head.querySelectorAll('th[scope=col]')) {
196
+ header.querySelector('.column-resize').setAttribute('aria-valuenow', String(Math.round(header.getBoundingClientRect().width)));
197
+ }
198
+ for (const row of this.#rows.values()) {
199
+ const handle = row.querySelector('.row-height-handle');
200
+ if (handle) handle.setAttribute('aria-valuenow', String(Math.round(row.getBoundingClientRect().height)));
201
+ }
202
+ this.#headerViewport.scrollLeft = this.#bodyViewport.scrollLeft;
203
+ if (!this.#structure) return;
204
+ try { this.#layoutWindow(); this.#cellEditor.position(); }
205
+ catch (error) { this.#context.reportError(error, 'Grid viewport'); }
206
+ });
207
+ }
208
+ #sizeRowHeader() {
209
+ if (!this.#rowHeaders) return;
210
+ const probe = this.#head.querySelector('.row-number-measure');
211
+ probe.textContent = String(Math.max(1, this.#rowLayout.count));
212
+ const minimum = Math.ceil(probe.getBoundingClientRect().width);
213
+ this.control.style.setProperty('--grid-row-header-min-width', `${minimum}px`);
214
+ if (this.#rowLayout.headerWidth === null) this.control.style.removeProperty('--grid-row-header-width');
215
+ else this.control.style.setProperty('--grid-row-header-width', `${this.#rowLayout.headerWidth}px`);
216
+ const handle = this.#head.querySelector('.row-heading .column-resize');
217
+ handle.setAttribute('aria-valuemin', String(Math.max(40, minimum)));
218
+ }
219
+ #layoutWindow() {
220
+ const viewport = this.#bodyViewport;
221
+ const anchor = this.#rowLayout.indexAt(viewport.scrollTop);
222
+ const within = viewport.scrollTop - this.#rowLayout.offset(anchor);
223
+ let changed = false;
224
+ const first = this.#rows.values().next().value;
225
+ if (first) {
226
+ const style = this.ownerDocument.defaultView.getComputedStyle(first.querySelector('td'));
227
+ const key = JSON.stringify([this.#bodyTable.getBoundingClientRect().width,
228
+ style.font, style.lineHeight, style.padding, style.getPropertyValue('--gramlot-grid-row-height')]);
229
+ if (key !== this.#geometryKey) {
230
+ this.#rowLayout.resetMeasurements(); this.#geometryKey = key; changed = true;
231
+ }
232
+ }
233
+ for (const [node, row] of this.#rows) {
234
+ changed = this.#rowLayout.measure(node, row.getBoundingClientRect().height) || changed;
235
+ }
236
+ if (changed && this.#visibleNodes.length) {
237
+ // Keep the same visible row while estimated heights become exact.
238
+ const top = this.#rowLayout.offset(anchor) + within;
239
+ this.#setSpaces();
240
+ this.#scrollTo(this.#endPinned ? Math.max(0, this.#rowLayout.totalHeight - viewport.clientHeight) : top);
241
+ }
242
+ if (!this.#rowInteraction.resizing) this.#renderWindow();
243
+ }
244
+ #setSpaces() {
245
+ const start = Math.max(0, this.#windowStart), end = Math.max(start, this.#windowEnd);
246
+ this.#topSpace.style.height = `${this.#rowLayout.offset(start)}px`;
247
+ this.#bottomSpace.style.height = `${Math.max(0, this.#rowLayout.totalHeight - this.#rowLayout.offset(end))}px`;
248
+ }
249
+ #scrollTo(top) {
250
+ if (this.#bodyViewport.scrollTop === top) return;
251
+ this.#bodyViewport.scrollTop = top;
252
+ // A layout correction emits a scroll event too. Do not mistake it
253
+ // for a user leaving the bottom while new rows are being measured.
254
+ this.#adjustedScroll = this.#bodyViewport.scrollTop;
255
+ }
256
+ #renderWindow(force = false) {
257
+ const viewport = this.#bodyViewport;
258
+ const maximum = Math.max(0, this.#rowLayout.totalHeight - viewport.clientHeight);
259
+ const top = this.#endPinned ? maximum : Math.min(viewport.scrollTop, maximum);
260
+ let {start, end} = this.#rowLayout.window(top, viewport.clientHeight);
261
+ const info = this.#windowInfo();
262
+ if (info) {
263
+ const loadedEnd = info.start + this.#visibleNodes.length;
264
+ if (start < info.start || end > loadedEnd) {
265
+ const count = Math.max(200, end - start);
266
+ const requestedStart = Math.max(0, Math.min(Math.max(0, info.total - count), start));
267
+ const key = JSON.stringify([info.revision, requestedStart, count]);
268
+ if (key !== this.#windowRequest) {
269
+ this.#windowRequest = key;
270
+ this.#context.writeParameter('viewport', {start:requestedStart, count});
271
+ }
272
+ } else this.#windowRequest = null;
273
+ start = Math.max(start, info.start);
274
+ end = Math.max(start, Math.min(end, loadedEnd));
275
+ }
276
+ if (!info) this.#windowRequest = null;
277
+ const loading = this.parameters.loading || this.#windowRequest !== null;
278
+ this.#loadingStatus.hidden = !loading;
279
+ if (loading) this.control.setAttribute('aria-busy', 'true');
280
+ else this.control.removeAttribute('aria-busy');
281
+ if (force || start !== this.#windowStart || end !== this.#windowEnd) {
282
+ const rows = new GridRows(this.#collectionView, this.#context.format)
283
+ .read(this.#structure.columns, this.#visibleNodes.slice(start-(info?.start ?? 0), end-(info?.start ?? 0)));
284
+ this.#renderRows(rows, this.#structure.columns, start);
285
+ this.#windowStart = start; this.#windowEnd = end;
286
+ this.#scheduleLayout();
287
+ }
288
+ this.#setSpaces();
289
+ this.#scrollTo(top);
290
+ }
291
+ #windowInfo() {
292
+ const value = this.parameters.windowInfo;
293
+ if (value === null) return null;
294
+ if (!(value instanceof Bag)) throw new TypeError('Grid windowInfo requires a Bag');
295
+ return Object.fromEntries(['start', 'total', 'revision', 'sortedBy'].map(key => [key, value.getItem(key)]));
296
+ }
297
+ #nextEditor(row,field,step) {
298
+ const rows = this.#collectionView.getRows(), columns = this.#structure.columns.filter(column => column.edit);
299
+ const index = rows.indexOf(row) * columns.length + columns.findIndex(column => column.field === field) + (typeof step === 'object' ? step.row * columns.length : step);
300
+ if (index < 0 || index >= rows.length * columns.length) return;
301
+ this.#openEditorAt(Math.floor(index / columns.length),columns[index % columns.length]);
302
+ }
303
+ #openEditorAt(rowIndex,column) {
304
+ const next = this.#collectionView.getRows()[rowIndex];
305
+ this.#endPinned = false;
306
+ const top = this.#rowLayout.offset(rowIndex), bottom = this.#rowLayout.offset(rowIndex + 1);
307
+ if (top < this.#bodyViewport.scrollTop) this.#scrollTo(top);
308
+ else if (bottom > this.#bodyViewport.scrollTop + this.#bodyViewport.clientHeight) this.#scrollTo(Math.max(0,bottom-this.#bodyViewport.clientHeight));
309
+ this.#renderWindow(true);
310
+ const cell = this.#rows.get(next).querySelector(`td[data-field="${column.field}"]`);
311
+ const rect = cell.getBoundingClientRect(), viewport = this.#bodyViewport.getBoundingClientRect();
312
+ if (rect.left < viewport.left) this.#bodyViewport.scrollLeft += rect.left-viewport.left;
313
+ else if (rect.right > viewport.right) this.#bodyViewport.scrollLeft += Math.min(rect.left-viewport.left,rect.right-viewport.right);
314
+ this.#headerViewport.scrollLeft = this.#bodyViewport.scrollLeft;
315
+ this.#cellEditor.open(next,column,cell);
316
+ }
317
+ #focusField(path) {
318
+ const prefix = this.#context.sourceNode.absDatapath(this.parameters.storepath) + '.';
319
+ if (!path.startsWith(prefix)) return false;
320
+ const relative = path.slice(prefix.length), separator = this.parameters.rowMode === 'attributes' ? '?' : '.';
321
+ const split = relative.indexOf(separator);
322
+ if (split < 0) return false;
323
+ const row = this.#store.getNode(relative.slice(0,split));
324
+ const column = this.#structure.columns.find(column => column.field === relative.slice(split+1) && column.edit);
325
+ const index = this.#collectionView.getRows().indexOf(row);
326
+ if (!column || index < 0) return false;
327
+ this.#openEditorAt(index,column);
328
+ return true;
329
+ }
330
+ setSourceContext(context) {
331
+ this.#context = context;
332
+ this.#cellEditor = new GridCellEditor(this, context, (row, field) => this.#rows.get(row)?.querySelector(`td[data-field="${field}"]`), () => ({bag:this.#store, mode:this.parameters.rowMode, window:this.parameters.windowInfo}), () => this.#rows, (row,field,step) => this.#nextEditor(row,field,step), path => this.#focusField(path));
333
+ const node = context.sourceNode;
334
+ if (!Object.hasOwn(node, 'gridRowLayout')) {
335
+ Object.defineProperty(node, 'gridRowLayout', {value:new GridRowLayout(), configurable:true});
336
+ }
337
+ this.#rowLayout = node.gridRowLayout;
338
+ }
339
+ setStoreBag(bag) {
340
+ if (!(bag instanceof Bag)) throw new TypeError('grid storepath must resolve to a Bag');
341
+ if (bag !== this.#store) this.#cellEditor?.replaceData();
342
+ this.#store = bag;
343
+ this.#rowLayout.bindStore(bag);
344
+ }
345
+ setStructBag(bag) { this.#structBag = bag; this.#structureDirty = true; }
346
+ projectAttributes(attrs, adapt) {
347
+ const rest = super.projectAttributes(attrs, adapt);
348
+ const store = this.#context.collectionView(this.#store, this.parameters.rowMode);
349
+ if (this.#collectionView !== store) {
350
+ this.#cancelRefresh();
351
+ this.#unsubscribeStore?.(); this.#unsubscribeStore = null;
352
+ this.#collectionView = store;
353
+ this.#observeStore();
354
+ }
355
+ if (!this.#windowInfo() && this.#requestedSort !== this.parameters.sortedBy) {
356
+ this.#collectionView.sort(this.parameters.sortedBy);
357
+ this.#requestedSort = this.parameters.sortedBy;
358
+ }
359
+ const filter = this.parameters.filter;
360
+ const signature = JSON.stringify(filter);
361
+ if (!this.#windowInfo() && this.#requestedFilter !== signature) {
362
+ this.#collectionView.applyFilter(filter === null ? null : {locale:this.#context.locale,timeZone:this.#context.timeZone,...filter});
363
+ this.#requestedFilter = signature;
364
+ }
365
+ this.#invalidate({full:true, rows:[]});
366
+ return rest;
367
+ }
368
+ #observeStore() {
369
+ if (this.isConnected && this.#collectionView && !this.#unsubscribeStore) {
370
+ this.#collectionView.connect();
371
+ this.#unsubscribeStore = this.#collectionView.subscribe(change => this.#invalidate(change));
372
+ }
373
+ }
374
+ #cancelRefresh() {
375
+ if (this.#refreshTimer !== null) this.ownerDocument.defaultView.clearTimeout(this.#refreshTimer);
376
+ this.#refreshTimer = null;
377
+ this.#pendingFull = false;
378
+ this.#pendingRows.clear();
379
+ }
380
+ #invalidate({full, rows}) {
381
+ this.#pendingFull ||= full;
382
+ if (this.#pendingFull) this.#pendingRows.clear();
383
+ else for (const node of rows) this.#pendingRows.add(node);
384
+ if (!this.isConnected || this.#refreshTimer !== null) return;
385
+ this.#refreshTimer = this.ownerDocument.defaultView.setTimeout(() => {
386
+ const full = this.#pendingFull, nodes = [...this.#pendingRows];
387
+ this.#refreshTimer = null;
388
+ this.#pendingFull = false;
389
+ this.#pendingRows.clear();
390
+ try {
391
+ if (full) this.#project();
392
+ else this.#projectRows(nodes);
393
+ } catch (error) {
394
+ // Keep the last valid DOM. A later change retries a complete pull;
395
+ // there is no automatic retry loop and no exception in Data delivery.
396
+ this.#pendingFull = true;
397
+ this.#context.reportError(error, 'Grid refresh');
398
+ }
399
+ }, 0);
400
+ }
401
+ #projectRows(nodes) {
402
+ for (const node of nodes) this.#rowLayout.forget(node);
403
+ const rows = new GridRows(this.#collectionView, this.#context.format).read(this.#structure.columns, nodes.filter(node => this.#rows.has(node)));
404
+ this.#rowInteraction.cancel();
405
+ for (const {node, cells} of rows) this.#renderCells(this.#rows.get(node), cells);
406
+ this.#scheduleLayout();
407
+ }
408
+ #project() {
409
+ const model = this.#structureDirty ? new GridStructure(this.#structBag) : this.#structure;
410
+ this.#cellEditor.configure(model.columns);
411
+ const nodes = this.#collectionView.getRows();
412
+ this.#rowInteraction.cancel(); this.#rowInteraction.cancelDrag();
413
+ this.#rowLayout.retain(this.#store.getNodes());
414
+ if (this.#structureDirty) this.#rowLayout.resetMeasurements();
415
+ const info = this.#windowInfo();
416
+ this.#rowLayout.setWindow(info);
417
+ this.#rowLayout.setRows(nodes);
418
+ this.#visibleNodes = nodes;
419
+ if (info && this.#windowRevision !== info.revision) {
420
+ this.#endPinned = false;
421
+ this.#scrollTo(0);
422
+ this.#windowRequest = null;
423
+ }
424
+ this.#windowRevision = info?.revision;
425
+ this.#structure = model;
426
+ this.#structureDirty = false;
427
+ gridSearch(this.#context.sourceNode).update(this.#collectionView, model.columns);
428
+ const rowHeaders = this.parameters.rowHeaders || this.parameters.rowResize;
429
+ const signature = JSON.stringify([model.groups, rowHeaders]);
430
+ this.#rowHeaders = rowHeaders;
431
+ if (signature !== this.#signature) {
432
+ this.#renderHeader(model);
433
+ this.#signature = signature;
434
+ }
435
+ this.#renderSort();
436
+ this.#renderWindow(true);
437
+ this.control.setAttribute('aria-colcount', String(model.columns.length + Number(this.#rowHeaders)));
438
+ this.control.setAttribute('aria-rowcount', String(this.#headerRows + Math.max(this.#rowLayout.count, 1)));
439
+ this.#scheduleLayout();
440
+ }
441
+ #sort(field, multiple) {
442
+ try {
443
+ const criteria = this.#windowInfo() ? parseSort(this.#windowInfo().sortedBy) : this.#collectionView.criteria;
444
+ const current = criteria.find(item => item.field === field);
445
+ const direction = current?.direction === 'a' ? 'd' : 'a';
446
+ const next = multiple ? criteria.filter(item => item.field !== field) : [];
447
+ if (multiple && current) next.splice(criteria.indexOf(current), 0, {field, direction});
448
+ else next.push({field, direction});
449
+ const sortedBy = next.map(item => `${item.field}:${item.direction}`).join(',');
450
+ if (this.#windowInfo()) this.#context.writeParameter('sortRequest', sortedBy);
451
+ else this.#collectionView.sort(sortedBy);
452
+ } catch (error) { this.#context.reportError(error, 'Grid sort'); }
453
+ }
454
+ #renderSort() {
455
+ const criteria = this.#windowInfo() ? parseSort(this.#windowInfo().sortedBy) : this.#collectionView.criteria;
456
+ this.#sizeRowHeader();
457
+ for (const header of this.#head.querySelectorAll('th[scope=col]')) {
458
+ const index = criteria.findIndex(item => item.field === header.dataset.field);
459
+ header.removeAttribute('aria-sort');
460
+ if (index < 0) {
461
+ delete header.dataset.sortDirection; delete header.dataset.sortPriority;
462
+ header.removeAttribute('aria-label');
463
+ } else {
464
+ const direction = criteria[index].direction === 'a' ? 'ascending' : 'descending';
465
+ header.dataset.sortDirection = direction; header.dataset.sortPriority = String(index + 1);
466
+ if (index === 0) header.setAttribute('aria-sort', direction);
467
+ header.setAttribute('aria-label', `${header.textContent}, sort ${index + 1}, ${direction}`);
468
+ }
469
+ }
470
+ }
471
+ #renderHeader(model) {
472
+ this.#interaction.cancel();
473
+ const focused = this.shadowRoot.activeElement;
474
+ const focusedField = focused?.closest('th[data-field]')?.dataset.field;
475
+ const resizeFocused = focused?.classList.contains('column-resize');
476
+ const doc = this.ownerDocument, grouped = model.groups.some(group => group.name !== null);
477
+ this.#headerRows = grouped ? 2 : 1;
478
+ const top = doc.createElement('tr'), bottom = doc.createElement('tr');
479
+ for (const [index, row] of [top, bottom].entries()) {
480
+ row.setAttribute('role', 'row'); row.setAttribute('aria-rowindex', String(index + 1));
481
+ }
482
+ const header = (text, span, rowSpan, scope, index, align = 'start') => {
483
+ const cell = doc.createElement('th'); cell.textContent = text;
484
+ cell.colSpan = span; cell.rowSpan = rowSpan; cell.scope = scope;
485
+ cell.setAttribute('role', 'columnheader'); cell.setAttribute('part', scope === 'colgroup' ? 'group-header' : 'column-header');
486
+ cell.setAttribute('aria-colindex', String(index + 1 + Number(this.#rowHeaders)));
487
+ cell.setAttribute('aria-colspan', String(span)); cell.setAttribute('aria-rowspan', String(rowSpan));
488
+ cell.style.textAlign = align;
489
+ if (scope === 'col') {
490
+ const caption = doc.createElement('span');
491
+ caption.className = 'column-caption'; caption.textContent = text; cell.replaceChildren(caption);
492
+ const column = model.columns[index];
493
+ cell.dataset.field = column.field;
494
+ cell.draggable = true; cell.tabIndex = 0;
495
+ cell.title = 'Click: ascending / descending · Shift-click: add or reverse this column without changing the others · Numbers show sort priority · Drag to reorder';
496
+ const indicator = doc.createElementNS(SVG_NS, 'svg');
497
+ indicator.classList.add('sort-indicator'); indicator.setAttribute('viewBox', '0 0 16 16');
498
+ indicator.setAttribute('aria-hidden', 'true');
499
+ const arrow = doc.createElementNS(SVG_NS, 'path');
500
+ arrow.setAttribute('d', 'M4 10L8 6L12 10'); indicator.append(arrow); cell.append(indicator);
501
+ const handle = doc.createElement('span');
502
+ handle.className = 'column-resize'; handle.tabIndex = 0;
503
+ handle.setAttribute('role', 'separator');
504
+ handle.setAttribute('aria-orientation', 'vertical');
505
+ handle.setAttribute('aria-valuemin', '40');
506
+ handle.setAttribute('aria-label', `Resize ${column.name}`);
507
+ handle.title = 'Drag to resize · Arrow keys adjust width';
508
+ cell.append(handle);
509
+ }
510
+ return cell;
511
+ };
512
+ if (this.#rowHeaders) {
513
+ const corner = doc.createElement('th');
514
+ corner.textContent = '#'; corner.scope = 'col'; corner.className = 'row-heading';
515
+ corner.rowSpan = this.#headerRows;
516
+ corner.setAttribute('role', 'columnheader');
517
+ corner.setAttribute('aria-colindex', '1');
518
+ corner.setAttribute('aria-rowspan', String(this.#headerRows));
519
+ corner.setAttribute('part', 'row-header');
520
+ const probe = doc.createElement('span');
521
+ probe.className = 'row-number-measure'; probe.setAttribute('aria-hidden', 'true');
522
+ const handle = doc.createElement('span');
523
+ handle.className = 'column-resize'; handle.tabIndex = 0;
524
+ handle.setAttribute('role', 'separator'); handle.setAttribute('aria-orientation', 'vertical');
525
+ handle.setAttribute('aria-label', 'Resize row numbers');
526
+ handle.title = 'Drag to resize · Arrow keys adjust width';
527
+ corner.append(probe, handle); top.append(corner);
528
+ }
529
+ let index = 0;
530
+ for (const group of model.groups) {
531
+ if (grouped && group.name !== null) {
532
+ const band = header(group.name, group.columns.length, 1, 'colgroup', index, 'center');
533
+ band.style.background = group.background ?? '';
534
+ band.style.color = group.color ?? '';
535
+ top.append(band);
536
+ for (const col of group.columns) bottom.append(header(col.name, 1, 1, 'col', index++, col.align));
537
+ } else for (const col of group.columns) {
538
+ if (grouped) {
539
+ const spacer = doc.createElement('td');
540
+ spacer.className = 'group-spacer'; spacer.setAttribute('aria-hidden', 'true');
541
+ top.append(spacer);
542
+ }
543
+ (grouped ? bottom : top).append(header(col.name, 1, 1, 'col', index++, col.align));
544
+ }
545
+ }
546
+ this.#head.replaceChildren(top, ...(grouped ? [bottom] : []));
547
+ if (focusedField) this.#head.querySelector(`th[data-field="${focusedField}"]${resizeFocused ? ' .column-resize' : ''}`)?.focus({preventScroll:true});
548
+ const widths = model.columns.map(column => column.width ?? 'var(--gramlot-grid-column-width, 10rem)');
549
+ if (this.#rowHeaders) widths.unshift('max(var(--grid-row-header-min-width, 0px), var(--grid-row-header-width, var(--gramlot-grid-row-header-width, 44px)))');
550
+ this.control.style.setProperty('--grid-columns-width', `calc(${widths.join(' + ')})`);
551
+ // Identical colgroups and table constraints keep one CSS sizing policy for both areas.
552
+ for (const table of [this.#headerTable, this.#bodyTable]) {
553
+ for (const group of table.querySelectorAll(':scope > colgroup')) group.remove();
554
+ table.prepend(...model.groups.map(group => {
555
+ const element = doc.createElement('colgroup');
556
+ for (const column of group.columns) {
557
+ const col = doc.createElement('col');
558
+ col.style.width = column.width ?? 'var(--gramlot-grid-column-width, 10rem)';
559
+ element.append(col);
560
+ }
561
+ return element;
562
+ }));
563
+ if (this.#rowHeaders) {
564
+ const group = doc.createElement('colgroup'), col = doc.createElement('col');
565
+ col.style.width = 'max(var(--grid-row-header-min-width, 0px), var(--grid-row-header-width, var(--gramlot-grid-row-header-width, 44px)))';
566
+ group.append(col); table.prepend(group);
567
+ }
568
+ }
569
+ }
570
+ #renderRows(rows, columns, start) {
571
+ this.#rowInteraction.cancel();
572
+
573
+ const keep = new Set(); let previous = null;
574
+ this.#body.querySelector('.empty')?.parentElement.remove();
575
+ for (const {node, cells} of rows) {
576
+ let tr = this.#rows.get(node);
577
+ if (!tr) {
578
+ tr = this.ownerDocument.createElement('tr'); tr.setAttribute('part', 'row');
579
+ tr.setAttribute('role', 'row');
580
+ tr.dataset.row = node.label;
581
+ this.#rows.set(node, tr);
582
+ }
583
+ tr.classList.toggle('alternate', (start + keep.size) % 2 === 1);
584
+ tr.draggable = this.parameters.selfDragRows;
585
+ let heading = tr.querySelector('th[scope=row]');
586
+ if (this.#rowHeaders) {
587
+ if (!heading) {
588
+ heading = this.ownerDocument.createElement('th');
589
+ heading.scope = 'row'; heading.className = 'row-heading';
590
+ heading.setAttribute('role', 'rowheader'); heading.setAttribute('part', 'row-header');
591
+ heading.setAttribute('aria-colindex', '1');
592
+ const caption = this.ownerDocument.createElement('span');
593
+ caption.className = 'row-number'; heading.append(caption); tr.prepend(heading);
594
+ }
595
+ heading.querySelector('.row-number').textContent = String(start + keep.size + 1);
596
+ let handle = heading.querySelector('.row-height-handle');
597
+ if (this.parameters.rowResize) {
598
+ if (!handle) {
599
+ handle = this.ownerDocument.createElement('span');
600
+ handle.className = 'row-height-handle'; handle.tabIndex = 0;
601
+ handle.setAttribute('role', 'separator');
602
+ handle.setAttribute('aria-orientation', 'horizontal');
603
+ handle.title = 'Drag to resize row · Double-click or Home resets · Arrow keys adjust height';
604
+ heading.append(handle);
605
+ }
606
+ handle.setAttribute('aria-label', `Resize row ${start + keep.size + 1}`);
607
+ } else handle?.remove();
608
+ } else heading?.remove();
609
+ const offset = Number(this.#rowHeaders);
610
+ const existing = new Map([...tr.querySelectorAll('td[data-field]')].map(td => [td.dataset.field, td]));
611
+ for (const [index, column] of columns.entries()) {
612
+ let td = existing.get(column.field);
613
+ if (!td) {
614
+ td = this.ownerDocument.createElement('td'); td.setAttribute('part', 'cell');
615
+ td.dataset.field = column.field; td.setAttribute('role', 'cell');
616
+ }
617
+ if (column.edit) td.tabIndex = 0; else td.removeAttribute('tabindex');
618
+ td.style.textAlign = column.align;
619
+ td.style.whiteSpace = column.white_space ?? '';
620
+ td.style.overflowWrap = column.white_space === 'pre-wrap' || column.white_space === 'normal' ? 'anywhere' : '';
621
+ td.setAttribute('aria-colindex', String(index + 1 + offset));
622
+ td.classList.toggle('numeric', ['L', 'R', 'N'].includes(column.dtype));
623
+ if (tr.cells[index + offset] !== td) tr.insertBefore(td, tr.cells[index + offset] ?? null);
624
+ existing.delete(column.field);
625
+ }
626
+ for (const td of existing.values()) td.remove();
627
+ tr.setAttribute('aria-rowindex', String(this.#headerRows + start + keep.size + 1));
628
+ this.#renderCells(tr, cells);
629
+ this.#cellEditor.decorate(tr, node);
630
+ const next = previous ? previous.nextSibling : this.#body.firstChild;
631
+ if (next !== tr) this.#body.insertBefore(tr, next);
632
+ this.#rowInteraction.project(tr, node);
633
+ previous = tr; keep.add(node);
634
+ }
635
+ for (const [node, tr] of this.#rows) if (!keep.has(node)) { tr.remove(); this.#rows.delete(node); }
636
+ if (!rows.length && this.#rowLayout.count === 0 && !this.parameters.loading) {
637
+ const tr = this.ownerDocument.createElement('tr'), td = this.ownerDocument.createElement('td');
638
+ tr.setAttribute('role', 'row'); tr.setAttribute('aria-rowindex', String(this.#headerRows + 1));
639
+ td.setAttribute('role', 'cell'); td.setAttribute('aria-colspan', String(columns.length + Number(this.#rowHeaders)));
640
+ td.className = 'empty'; td.colSpan = columns.length + Number(this.#rowHeaders); td.textContent = 'No rows'; tr.append(td); this.#body.append(tr);
641
+ }
642
+ }
643
+ #renderCells(row, cells) {
644
+ const offset = Number(this.#rowHeaders);
645
+ cells.forEach((text, index) => {
646
+ if (row.cells[index + offset].textContent !== text) row.cells[index + offset].textContent = text;
647
+ });
648
+ }
649
+ }
650
+ });
651
+
652
+ class GridCollection extends ComponentCollection {
653
+ toDocument() {
654
+ const document = super.toDocument();
655
+ const parameters = document.elements.grid.attributes.parameters;
656
+ for (const name of ['storepath', 'rowMode']) {
657
+ const parameter = parameters.find(item => item.name === name);
658
+ parameter.has_default = false; delete parameter.default;
659
+ if (name === 'rowMode') parameter.annotation = {kind: 'annotated', base: {kind: 'dtype', dtype: 'T'},
660
+ metadata: [{kind: 'regex', pattern: '^(values|attributes)$', flags: 0}]};
661
+ }
662
+ Object.assign(document.elements, structuredClone(structureGrammar.elements));
663
+ return document;
664
+ }
665
+ }
666
+ export default new GridCollection({name: 'grid', components: [Grid, SearchBox], dependencies:[inputs]});