@gramlot/gramlot 0.3.26 → 0.3.30

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 (213) hide show
  1. package/assets/icons/chart.svg +1 -0
  2. package/dist/components/audio/__init__.py +13 -0
  3. package/dist/components/audio/assets/collection.js +3 -0
  4. package/dist/components/audio/assets/index.js +3 -0
  5. package/dist/components/audio/commands.json +7 -0
  6. package/dist/components/audio/grammar.json +335 -0
  7. package/dist/components/charts/__init__.py +13 -0
  8. package/dist/components/charts/assets/collection.js +47 -0
  9. package/dist/components/charts/assets/files/55ea01207028f76d844678511f29fc800f8a1e67a8a0fe80470128677847ad32-echarts-gl.txt +29 -0
  10. package/dist/components/charts/assets/files/63727832aaf62004a2b249c933e327f3c90caf49e41a72f4bf436edf632cbda8-vega.txt +27 -0
  11. package/dist/components/charts/assets/files/8c45d9eaf50c2f72dd9c7ab9ef440788ba58a3538484b5c51c1f17d5128752e7-plotly.txt +21 -0
  12. package/dist/components/charts/assets/files/8f989229699b4fe2f1a0432d0e9edc338a8a911e250e2d1b01ecd770a5f5b1bd-uplot.txt +21 -0
  13. package/dist/components/charts/assets/files/c8fa058cba98f7f288b5d8fa4116f441d6dacb25b96da859e518c973fff41d0c-claygl.txt +23 -0
  14. package/dist/components/charts/assets/index.js +3 -0
  15. package/dist/components/charts/assets/modules/chunk-2CCTLZE7.js +76 -0
  16. package/dist/components/charts/assets/modules/chunk-RMRBEYTI.js +1 -0
  17. package/dist/components/charts/assets/modules/echarts-gl-CXVTZA6G.js +4409 -0
  18. package/dist/components/charts/assets/modules/plotly.min-4LB7HE7P.js +3596 -0
  19. package/dist/components/charts/assets/modules/uPlot.esm-5JJNHHRF.js +3 -0
  20. package/dist/components/charts/assets/modules/uPlot.min-N3E3FA74.js +1 -0
  21. package/dist/components/charts/assets/modules/vega.module-2QCOVQ3A.js +13 -0
  22. package/dist/components/charts/commands.json +7 -0
  23. package/dist/components/charts/grammar.json +1113 -0
  24. package/dist/components/chat/__init__.py +1 -1
  25. package/dist/components/chat/assets/collection.js +3 -3
  26. package/dist/components/chat/assets/index.js +1 -1
  27. package/dist/components/drawing/__init__.py +15 -0
  28. package/dist/components/drawing/assets/collection.js +28 -0
  29. package/dist/components/drawing/assets/index.js +3 -0
  30. package/dist/components/drawing/commands.json +7 -0
  31. package/dist/components/drawing/grammar.json +110 -0
  32. package/dist/components/editors/__init__.py +2 -2
  33. package/dist/components/editors/assets/collection.js +18 -18
  34. package/dist/components/editors/assets/index.js +1 -1
  35. package/dist/components/editors/assets/modules/{prose-mirror-engine-GMZPJPNN.js → prose-mirror-engine-DQEAEIMV.js} +2 -2
  36. package/dist/components/editors/grammar.json +150 -0
  37. package/dist/components/grid/__init__.py +1 -1
  38. package/dist/components/grid/assets/collection.js +63 -33
  39. package/dist/components/grid/assets/index.js +1 -1
  40. package/dist/components/grid/grammar.json +279 -0
  41. package/dist/components/grouplets/__init__.py +1 -1
  42. package/dist/components/grouplets/assets/collection.js +3 -3
  43. package/dist/components/grouplets/assets/index.js +1 -1
  44. package/dist/components/inputs/__init__.py +3 -2
  45. package/dist/components/inputs/assets/collection.js +38 -23
  46. package/dist/components/inputs/assets/index.js +1 -1
  47. package/dist/components/inputs/grammar.json +1533 -321
  48. package/dist/components/layout/__init__.py +1 -1
  49. package/dist/components/layout/assets/collection.js +27 -23
  50. package/dist/components/layout/assets/index.js +1 -1
  51. package/dist/components/layout/grammar.json +85 -0
  52. package/dist/components/selection_trial/__init__.py +1 -1
  53. package/dist/components/selection_trial/assets/collection.js +3 -3
  54. package/dist/components/selection_trial/assets/index.js +1 -1
  55. package/dist/components/tree/__init__.py +1 -1
  56. package/dist/components/tree/assets/collection.js +12 -12
  57. package/dist/components/tree/assets/index.js +1 -1
  58. package/dist/components/tree/grammar.json +126 -0
  59. package/dist/components/typst/__init__.py +1 -1
  60. package/dist/components/typst/assets/collection.js +3 -3
  61. package/dist/components/typst/assets/index.js +1 -1
  62. package/dist/components/uploads/__init__.py +1 -1
  63. package/dist/components/uploads/assets/collection.js +9 -9
  64. package/dist/components/uploads/assets/index.js +1 -1
  65. package/dist/components/vizabi/__init__.py +13 -0
  66. package/dist/components/vizabi/assets/collection.js +22 -0
  67. package/dist/components/vizabi/assets/index.js +3 -0
  68. package/dist/components/vizabi/commands.json +7 -0
  69. package/dist/components/vizabi/grammar.json +128 -0
  70. package/dist/gramlot.js +1190 -256
  71. package/dist/gramlot.min.js +85 -52
  72. package/dist/standard-collections.js +2 -0
  73. package/package.json +12 -4
  74. package/src/binding/grid-struct.js +2 -2
  75. package/src/binding/runtime.js +10 -0
  76. package/src/binding/validation-context.js +2 -1
  77. package/src/bootstrap.js +1 -1
  78. package/src/builder/gramlot-builder.d.ts +15 -2
  79. package/src/builder/gramlot-builder.js +22 -3
  80. package/src/builder/source.js +24 -1
  81. package/src/components/audio-analysis-session.js +65 -0
  82. package/src/components/audio.js +44 -0
  83. package/src/components/bases.js +11 -7
  84. package/src/components/border-container.js +6 -3
  85. package/src/components/buttons.js +47 -3
  86. package/src/components/chart-bar3d-options.js +30 -0
  87. package/src/components/chart-controls.js +83 -0
  88. package/src/components/chart-data-view.js +52 -0
  89. package/src/components/chart-data.js +42 -0
  90. package/src/components/chart-domains.js +46 -0
  91. package/src/components/chart-engines/echarts-options.js +50 -0
  92. package/src/components/chart-engines/echarts.js +82 -0
  93. package/src/components/chart-engines/index.js +22 -0
  94. package/src/components/chart-engines/plotly-map.js +34 -0
  95. package/src/components/chart-engines/plotly-spatial.js +35 -0
  96. package/src/components/chart-engines/plotly.js +138 -0
  97. package/src/components/chart-engines/uplot.js +57 -0
  98. package/src/components/chart-engines/vega.js +101 -0
  99. package/src/components/chart-fields.js +110 -0
  100. package/src/components/chart-geographic-options.js +47 -0
  101. package/src/components/chart-geojson.js +60 -0
  102. package/src/components/chart-geometry.js +11 -0
  103. package/src/components/chart-map-anchors.js +24 -0
  104. package/src/components/chart-map-bar3d-options.js +41 -0
  105. package/src/components/chart-map-data.js +25 -0
  106. package/src/components/chart-map-labels.js +8 -0
  107. package/src/components/chart-map-options.js +20 -0
  108. package/src/components/chart-pane.js +91 -0
  109. package/src/components/chart-renderer.js +58 -0
  110. package/src/components/chart-sample-view.js +32 -0
  111. package/src/components/chart-spatial-options.js +40 -0
  112. package/src/components/chart-time.js +84 -0
  113. package/src/components/chart-timeline.js +70 -0
  114. package/src/components/chart-types/area.js +2 -0
  115. package/src/components/chart-types/bar.js +2 -0
  116. package/src/components/chart-types/bar3D.js +2 -0
  117. package/src/components/chart-types/donut.js +2 -0
  118. package/src/components/chart-types/horizontalBar.js +2 -0
  119. package/src/components/chart-types/index.js +26 -0
  120. package/src/components/chart-types/line.js +2 -0
  121. package/src/components/chart-types/line3D.js +2 -0
  122. package/src/components/chart-types/lines3D.js +2 -0
  123. package/src/components/chart-types/map.js +2 -0
  124. package/src/components/chart-types/map3D.js +2 -0
  125. package/src/components/chart-types/mapBar3D.js +2 -0
  126. package/src/components/chart-types/pie.js +2 -0
  127. package/src/components/chart-types/polygons3D.js +2 -0
  128. package/src/components/chart-types/scatter.js +2 -0
  129. package/src/components/chart-types/scatter3D.js +2 -0
  130. package/src/components/chart-types/stackedArea.js +2 -0
  131. package/src/components/chart-types/stackedBar.js +2 -0
  132. package/src/components/chart-types/surface.js +2 -0
  133. package/src/components/charts.js +152 -0
  134. package/src/components/check-box-text-editor.js +88 -0
  135. package/src/components/check-box-text.js +193 -0
  136. package/src/components/check-box-tree.js +62 -0
  137. package/src/components/choice-editor.js +35 -18
  138. package/src/components/choice-field-styles.js +14 -0
  139. package/src/components/choices.js +5 -0
  140. package/src/components/database-choices.js +9 -6
  141. package/src/components/drawing.js +199 -0
  142. package/src/components/field-state.js +8 -1
  143. package/src/components/grid-cell-editor.js +83 -19
  144. package/src/components/grid-check-sets.js +98 -0
  145. package/src/components/grid-column-filters.js +198 -0
  146. package/src/components/grid-grammar.json +65 -0
  147. package/src/components/grid-header-interaction.js +3 -1
  148. package/src/components/grid-rows.js +2 -2
  149. package/src/components/grid-search-box.js +38 -22
  150. package/src/components/grid-search-styles.js +13 -14
  151. package/src/components/grid-search.js +8 -1
  152. package/src/components/grid-structure.js +13 -2
  153. package/src/components/grid-styles.js +34 -2
  154. package/src/components/grid.js +67 -10
  155. package/src/components/image-uploader.js +2 -2
  156. package/src/components/inputs.js +21 -12
  157. package/src/components/labelbox.js +5 -1
  158. package/src/components/licenses/claygl.txt +23 -0
  159. package/src/components/licenses/echarts-gl.txt +29 -0
  160. package/src/components/licenses/plotly.txt +21 -0
  161. package/src/components/licenses/uplot.txt +21 -0
  162. package/src/components/licenses/vega.txt +27 -0
  163. package/src/components/menus.js +19 -11
  164. package/src/components/parameters.js +6 -2
  165. package/src/components/toolbar-overflow.js +12 -8
  166. package/src/components/tree.js +31 -8
  167. package/src/components/typed-editor.js +18 -7
  168. package/src/components/validation.js +1 -1
  169. package/src/components/vizabi-session.js +66 -0
  170. package/src/components/vizabi.js +66 -0
  171. package/src/components/window-surface.js +20 -9
  172. package/src/components/windows.js +1 -1
  173. package/src/editing-session.d.ts +1 -0
  174. package/src/editing-session.js +113 -15
  175. package/src/editor-values.js +57 -0
  176. package/src/gramlot.d.ts +2 -0
  177. package/src/gramlot.js +9 -4
  178. package/src/handlers/device-handler.js +32 -32
  179. package/src/handlers/source-handler.d.ts +2 -2
  180. package/src/ide-documents.js +19 -3
  181. package/src/ide-runtime.d.ts +1 -0
  182. package/src/ide-runtime.js +45 -31
  183. package/src/index.d.ts +2 -1
  184. package/src/renderer/drag-drop.js +1 -0
  185. package/src/renderer/gramlot-renderer.d.ts +3 -0
  186. package/src/renderer/gramlot-renderer.js +16 -4
  187. package/src/server/assets.d.ts +3 -0
  188. package/src/server/assets.js +9 -0
  189. package/src/server/gramlot-server.d.ts +1 -1
  190. package/src/server/gramlot-server.js +2 -1
  191. package/src/server/index.d.ts +1 -1
  192. package/src/server/index.js +1 -1
  193. package/src/server/source-import.d.ts +1 -1
  194. package/src/server/source-import.js +5 -1
  195. package/src/server/visual-editor.d.ts +1 -1
  196. package/src/server/visual-editor.js +44 -34
  197. package/src/source-picker.d.ts +1 -1
  198. package/src/source-picker.js +1 -2
  199. package/src/stores/bag-collection-view.js +79 -17
  200. package/src/stores/collection-filter.js +2 -1
  201. package/src/stores/column-filter.js +49 -0
  202. package/src/stores/id-set.js +10 -0
  203. package/src/view/controls.js +8 -0
  204. package/src/view/html.js +10 -1
  205. package/src/view/label-menu.js +61 -0
  206. package/src/view/labelbox.js +15 -2
  207. package/src/visual-editor-canvas.js +29 -0
  208. package/src/visual-editor-catalogue.js +34 -0
  209. package/src/visual-editor.d.ts +5 -0
  210. package/src/visual-editor.js +244 -26
  211. package/themes/gramlot-base/theme.css +84 -36
  212. package/tools/gramlot-tools-inspector.js +170 -506
  213. package/tools/inspector-agent.js +1 -1
@@ -0,0 +1,199 @@
1
+ import {Bag, sourceTarget} from '@gramlot/gramlot';
2
+ import inputs from './inputs.js';
3
+ import layout from './layout.js';
4
+ import {defineCollection, defineComponent} from './registry.js';
5
+ import {Container} from './container.js';
6
+ import {randomId} from '../random-id.js';
7
+
8
+ import {SVG_NS} from '../renderer/attributes.js';
9
+
10
+ /** An editable image annotation layer whose durable state is a Data Bag. */
11
+ export const DrawingPane = defineComponent({
12
+ name:'drawingPane', tag:'gramlot-drawing-pane', base:Container, sourceContext:true, subTags:'*',
13
+ parameters:{image:{dtype:'T',nullable:true,default:null,binding:'read'},
14
+ annotations:{dtype:'X',binding:'read'}},
15
+ implementation:Base => class extends Base {
16
+ #svg; #image; #editor; #editing; #state; #statePath; #stateSubscription = `drawing-state-${randomId()}`; #syncing = false; #built = false; #lastColor; #lastSize; #bag; #subscription = `drawing-${randomId()}`;
17
+ #tool='select'; #selected=null; #gesture=null; #dimensions=[1000,1000]; #url=null; #events;
18
+ constructor() {
19
+ super();
20
+ const d=this.ownerDocument;
21
+ const style=d.createElement('style');
22
+ style.textContent=`:host{display:block;height:100%;min-height:0}.control-box{height:100%;display:flex;flex-direction:row;min-height:0;position:relative}
23
+ slot{display:contents} ::slotted(gramlot-menu){flex:0 0 56px;box-sizing:border-box;padding:6px;background:var(--gramlot-surface,Canvas);border-right:1px solid var(--gramlot-border-control,#a8b2bf);overflow:hidden}
24
+ .canvas{display:block;flex:1;width:0;height:100%;min-width:0;min-height:0;background:var(--gramlot-surface-subtle,#eee);touch-action:none;user-select:none}
25
+ .text-editor{position:absolute;z-index:2;min-width:120px;padding:2px 4px;border:1px solid #3977bc;border-radius:3px;background:white;color:#222;box-shadow:0 2px 8px #0003}
26
+ .text-editor[hidden]{display:none}.shape{cursor:pointer}.selected{stroke:#1683ff}.selected [data-text-hit]{stroke:#3977bc;stroke-width:1;stroke-dasharray:4 3}`;
27
+ this.shadowRoot.append(style);this.control.replaceChildren();
28
+ this.#editor=d.createElement('input');this.#editor.type='text';this.#editor.className='text-editor';this.#editor.hidden=true;this.#editor.setAttribute('aria-label','Annotation text');
29
+ this.#svg=d.createElementNS(SVG_NS,'svg');this.#svg.setAttribute('role','img');this.#svg.setAttribute('aria-label','Annotated image');
30
+ this.#svg.setAttribute('class','canvas');
31
+ this.#svg.setAttribute('viewBox','0 0 1000 1000');this.#svg.setAttribute('preserveAspectRatio','xMidYMid meet');
32
+ this.controlBox.append(d.createElement('slot'),this.#svg,this.#editor);
33
+ this.#image=d.createElement('img');
34
+ }
35
+ setSourceContext(context) { this.context=context; }
36
+ projectAttributes(attrs,adapt) {
37
+ const rest=super.projectAttributes(attrs,adapt);
38
+ if(this.isConnected)this.#connect();
39
+ return rest;
40
+ }
41
+ connectedCallback() {
42
+ this.#events=new this.ownerDocument.defaultView.AbortController();const options={signal:this.#events.signal};
43
+ this.#makeToolbar();
44
+ if(!this.isConnected)return;
45
+ this.#state.subscribe(this.#stateSubscription,{any:()=>this.#stateChanged()});
46
+ this.#svg.addEventListener('pointerdown',e=>this.#down(e),options);
47
+ this.#svg.addEventListener('pointermove',e=>this.#move(e),options);
48
+ this.#svg.addEventListener('pointerup',e=>this.#up(e),options);
49
+ this.#svg.addEventListener('pointercancel',()=>{this.#gesture=null;this.#render();},options);
50
+ this.#svg.addEventListener('dblclick',e=>{const id=e.target.closest('[data-id]')?.dataset.id;if(id&&this.#bag.getItem(id)?.getItem('type')==='text'){this.#gesture=null;this.#editText(id);e.preventDefault();}},options);
51
+ this.#editor.addEventListener('keydown',e=>{if(e.key==='Enter'){e.preventDefault();this.#finishText(true);}else if(e.key==='Escape'){e.preventDefault();this.#finishText(false);}},options);
52
+ this.#editor.addEventListener('blur',()=>this.#finishText(true),options);
53
+ this.#connect();
54
+ }
55
+ disconnectedCallback() {this.#finishText(false);this.#events?.abort();this.#events=null;this.#state?.unsubscribe(this.#stateSubscription,{any:true});this.#bag?.unsubscribe(this.#subscription,{any:true});this.#bag=null;this.#image.onload=null;this.#image.onerror=null;this.#url=null;this.#gesture=null;}
56
+ #connect() {
57
+ const bag=this.parameters.annotations;
58
+ if(!(bag instanceof Bag))throw new TypeError('drawingPane annotations requires a Data Bag');
59
+ if(bag!==this.#bag){this.#bag?.unsubscribe(this.#subscription,{any:true});this.#bag=bag;bag.subscribe(this.#subscription,{any:()=>this.#render()});this.#selected=null;}
60
+ const url=this.parameters.image;
61
+ if(url!==this.#url){
62
+ this.#url=url;this.#gesture=null;
63
+ if(!url){this.#dimensions=[1000,1000];this.#render();}
64
+ else {
65
+ this.#dimensions=null;this.#render();
66
+ this.#image.onload=()=>{if(this.#url!==url)return;this.#dimensions=[this.#image.naturalWidth,this.#image.naturalHeight];this.#render();};
67
+ this.#image.onerror=()=>{if(this.#url===url){this.#dimensions=null;this.context.reportError(new Error('Cannot load image'),'Drawing image');this.#render();}};
68
+ this.#image.src=url;
69
+ }
70
+ }
71
+ this.#render();
72
+ }
73
+ #makeToolbar(){
74
+ if(this.#built)return;
75
+ const node=this.context.sourceNode,builder=node.rootBuilder;
76
+ const existing=node.value?.getNode('bar');
77
+ if(existing){this.#state=node.drawingState;this.#statePath=node.drawingStatePath;existing.drawingController=this;this.#built=true;this.#tool=this.#state.getItem('tool');this.#lastColor=this.#state.getItem('color');this.#lastSize=this.#state.getItem('size');return;}
78
+ this.#statePath=`_gramlot.drawing.${randomId()}`;
79
+ this.#state=new Bag({tool:'select',color:'#dd2222',size:3});
80
+ node.setRelativeData(this.#statePath,this.#state);
81
+ Object.defineProperty(node,'drawingState',{value:this.#state,configurable:true});
82
+ Object.defineProperty(node,'drawingStatePath',{value:this.#statePath,configurable:true});
83
+ this.#lastColor=this.#state.getItem('color');this.#lastSize=this.#state.getItem('size');
84
+ const fragment=new builder.source.constructor(null,builder),root=builder.wrapSource(fragment);
85
+ const bar=root.menu({node_label:'bar',presentation:'bar',orientation:'vertical',labelPosition:'tooltip',iconSize:20,aria_label:'Image annotations'});
86
+ Object.defineProperty(sourceTarget(bar),'drawingController',{value:this,configurable:true,writable:true});
87
+ const paths={select:'M5 3l13 11-6 .5-3 5z',freehand:'M4 20l3.5-.7L19 7.8 16.2 5 4.7 16.5z M14.7 6.5l2.8 2.8',arrow:'M4 19L19 4 M12 4h7v7',circle:'M20 12a8 8 0 1 1-16 0 8 8 0 0 1 16 0z',text:'M4 5h16 M12 5v14 M8 19h8',delete:'M4 7h16 M9 7V4h6v3 M7 7l1 13h8l1-13 M10 10v7 M14 10v7'};
88
+ const icon=key=>'data:image/svg+xml,'+encodeURIComponent(`<svg xmlns="${SVG_NS}" viewBox="0 0 24 24" fill="none" stroke="#7e93ad" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="${paths[key]}"/></svg>`);
89
+ for(const [tool,label] of [['select','Select'],['freehand','Draw'],['arrow','Arrow'],['circle','Circle'],['text','Text']]){
90
+ bar.menuline({caption:label,tooltip:label,iconSrc:icon(tool),checked:`^${this.#statePath}.tool:={} === '${tool}'`,action:`this.parentBag.parentNode.drawingController.setTool('${tool}')`});
91
+ }
92
+ bar.contentPane({height:'1px',margin:'6px 4px',background:'var(--gramlot-border-control,#a8b2bf)'});
93
+ const circleIcon=color=>'data:image/svg+xml,'+encodeURIComponent(`<svg xmlns="${SVG_NS}" viewBox="0 0 24 24"><circle cx="12" cy="12" r="8" fill="${color}" stroke="#8793a3" stroke-width="1.5"/></svg>`);
94
+ const colorMenu=bar.menuline({caption:'Color',tooltip:'Color',iconSrc:`^${this.#statePath}.color:='data:image/svg+xml,' + encodeURIComponent('<svg xmlns="${SVG_NS}" viewBox="0 0 24 24"><circle cx="12" cy="12" r="8" fill="' + {} + '" stroke="#8793a3" stroke-width="1.5"/></svg>')`}).menu({aria_label:'Annotation colors'});
95
+ for(const [color,label] of [['#dd2222','Red'],['#e6a700','Yellow'],['#16834a','Green'],['#1677d2','Blue'],['#ffffff','White'],['#202733','Black']]){
96
+ colorMenu.menuline({caption:label,iconSrc:circleIcon(color),checked:`^${this.#statePath}.color:={} === '${color}'`,
97
+ action:`this.SET('${this.#statePath}.color', '${color}');`});
98
+ }
99
+ colorMenu.contentPane({padding:'8px'}).colorpicker({value:`^${this.#statePath}.color`,lbl:'Custom color',aria_label:'Color',width:'140px'});
100
+ const strokeIcon=size=>'data:image/svg+xml,'+encodeURIComponent(`<svg xmlns="${SVG_NS}" viewBox="0 0 24 24"><path d="M4 12h16" stroke="#7e93ad" stroke-width="${size}" stroke-linecap="round"/></svg>`);
101
+ const sizeMenu=bar.menuline({caption:'Pen size',tooltip:'Pen size',iconSrc:`^${this.#statePath}.size:='data:image/svg+xml,' + encodeURIComponent('<svg xmlns="${SVG_NS}" viewBox="0 0 24 24"><path d="M4 12h16" stroke="#7e93ad" stroke-width="' + Math.min({}, 12) + '" stroke-linecap="round"/></svg>')`}).menu({aria_label:'Pen size'});
102
+ for(const size of [1,3,5,7,12,20])sizeMenu.menuline({caption:`${size} px`,iconSrc:strokeIcon(Math.min(size,12)),checked:`^${this.#statePath}.size:={} === ${size}`,action:`this.SET('${this.#statePath}.size', ${size});`});
103
+ sizeMenu.contentPane({padding:'8px'}).numberTextBox({value:`^${this.#statePath}.size`,lbl:'Custom size',aria_label:'Pen size',dtype:'L',min:1,max:20,width:'140px'});
104
+ bar.contentPane({flex:'1',min_height:'12px'});
105
+ bar.menuline({caption:'Delete',tooltip:'Delete',iconSrc:icon('delete'),action:'this.parentBag.parentNode.drawingController.deleteSelection()'});
106
+ const app=builder.binding.gramlot,source=app.src.prepareSource(fragment);
107
+ app.src.renderer.validateCandidate(source);this.#built=true;node.setValue(source);
108
+ }
109
+ setTool(tool){this.#finishText(true);this.#gesture=null;this.#state.setItem('tool',tool);}
110
+ deleteSelection(){if(this.#selected){this.#bag.popNode(this.#selected);this.#selected=null;this.#render();}}
111
+ #stateChanged(){
112
+ const tool=this.#state.getItem('tool');this.#tool=tool;
113
+ const color=this.#state.getItem('color'),size=this.#state.getItem('size');
114
+ const changed=color!==this.#lastColor||size!==this.#lastSize;this.#lastColor=color;this.#lastSize=size;
115
+ if(changed&&!this.#syncing)this.#styleSelection();
116
+ this.#render();
117
+ }
118
+ #point(event){
119
+ const matrix=this.#svg.getScreenCTM();if(!matrix)return null;
120
+ const p=this.#svg.createSVGPoint();p.x=event.clientX;p.y=event.clientY;const q=p.matrixTransform(matrix.inverse());
121
+ return {x:Math.max(0,Math.min(this.#dimensions[0],q.x)),y:Math.max(0,Math.min(this.#dimensions[1],q.y))};
122
+ }
123
+ #down(event){
124
+ if(event.button!==0||!this.#dimensions)return;const point=this.#point(event);if(!point)return;
125
+ const id=event.target.closest('[data-id]')?.getAttribute('data-id');
126
+ if(this.#tool==='select'){
127
+ this.#selected=id||null;
128
+ if(id){const value=this.#bag.getItem(id);if(!(value instanceof Bag))throw new TypeError('Annotation must be a Bag');const row=this.#read(value);this.#syncing=true;try{this.#state.setItem('color',row.color);this.#state.setItem('size',row.width);}finally{this.#syncing=false;}this.#gesture={id,start:point,original:row};}
129
+ }else if(this.#tool==='text'){
130
+ const value=id?this.#bag.getItem(id):null;
131
+ this.#editText(value instanceof Bag&&value.getItem('type')==='text'?id:null,point);
132
+ }else {this.#selected=null;this.#gesture={start:point,current:point,points:[point]};}
133
+ if(this.#gesture)this.#svg.setPointerCapture(event.pointerId);this.#render();event.preventDefault();
134
+ }
135
+ #move(event){if(!this.#gesture||!this.#dimensions)return;const point=this.#point(event);if(!point)return;this.#gesture.current=point;if(this.#tool==='freehand')this.#gesture.points.push(point);this.#render();}
136
+ #up(event){
137
+ if(!this.#gesture)return;this.#move(event);const gesture=this.#gesture;this.#gesture=null;
138
+ if(gesture.id){const delta={x:gesture.current.x-gesture.start.x,y:gesture.current.y-gesture.start.y};const row=this.#translate(gesture.original,delta);this.#bag.setItem(gesture.id,new Bag(row));}
139
+ else {const {start,current,points}=gesture;let row;
140
+ if(this.#tool==='arrow')row={type:'arrow',x:start.x,y:start.y,x2:current.x,y2:current.y};
141
+ else if(this.#tool==='circle')row={type:'circle',x:start.x,y:start.y,radius:Math.hypot(current.x-start.x,current.y-start.y)};
142
+ else if(this.#tool==='freehand')row={type:'freehand',points};
143
+ if(row)this.#insert({...row,color:this.#state.getItem('color'),width:this.#penSize()});
144
+ }
145
+ if(this.#svg.hasPointerCapture(event.pointerId))this.#svg.releasePointerCapture(event.pointerId);this.#render();
146
+ }
147
+ #insert(row){const id=`item_${randomId()}`;this.#bag.setItem(id,new Bag(row));this.#selected=id;}
148
+ #penSize(){const value=this.#state.getItem('size');return Number.isFinite(value)?Math.max(1,Math.min(20,value)):3;}
149
+ #styleSelection(){if(!this.#selected)return;const value=this.#bag.getItem(this.#selected);if(!(value instanceof Bag))return;const row=this.#read(value);row.color=this.#state.getItem('color');row.width=this.#penSize();this.#bag.setItem(this.#selected,new Bag(row));}
150
+ #editText(id,point){
151
+ this.#finishText(true);const row=id?this.#read(this.#bag.getItem(id)):{type:'text',...point,text:'',color:this.#state.getItem('color'),width:this.#penSize()};
152
+ this.#selected=id;this.#editing={id,row};this.#editor.value=row.text;this.#editor.hidden=false;
153
+ const svgPoint=this.#svg.createSVGPoint();svgPoint.x=row.x;svgPoint.y=row.y;const matrix=this.#svg.getScreenCTM();if(!matrix){this.#finishText(false);return;}
154
+ const position=svgPoint.matrixTransform(matrix),box=this.controlBox.getBoundingClientRect();
155
+ const fontSize=Math.max(14,Math.max(14,12+row.width*2)*matrix.a);
156
+ this.#editor.style.left=`${position.x-box.left}px`;this.#editor.style.top=`${position.y-box.top-fontSize}px`;
157
+ this.#editor.style.fontSize=`${fontSize}px`;this.#editor.focus();this.#editor.select();
158
+ }
159
+ #finishText(commit){
160
+ if(!this.#editing)return;const {id,row}=this.#editing;this.#editing=null;const text=this.#editor.value.trim();this.#editor.hidden=true;
161
+ if(commit&&text){row.text=text;if(id)this.#bag.setItem(id,new Bag(row));else this.#insert(row);}
162
+ if(commit)this.#state.setItem('tool','select');
163
+ this.#render();
164
+ }
165
+ #read(row){
166
+ const result=Object.fromEntries(row.getNodes().map(node=>[node.label,node.getValue()]));
167
+ if(result.type==='freehand')result.points=result.points.getNodes().map(node=>({x:node.getValue().getItem('x'),y:node.getValue().getItem('y')}));
168
+ return result;
169
+ }
170
+ #translate(row,delta){const result={...row};if(row.type==='freehand')result.points=row.points.map(p=>({x:p.x+delta.x,y:p.y+delta.y}));else {result.x+=delta.x;result.y+=delta.y;if(row.type==='arrow'){result.x2+=delta.x;result.y2+=delta.y;}}return result;}
171
+ #element(tag,attrs){const el=this.ownerDocument.createElementNS(SVG_NS,tag);for(const [k,v] of Object.entries(attrs))el.setAttribute(k,String(v));return el;}
172
+ #shape(row,id){
173
+ const g=this.#element('g',{'data-id':id,class:`shape${id===this.#selected?' selected':''}`,fill:'none',stroke:row.color,'stroke-width':row.width,'stroke-linecap':'round','stroke-linejoin':'round'});
174
+ if(row.type==='circle')g.append(this.#element('circle',{cx:row.x,cy:row.y,r:row.radius}));
175
+ if(row.type==='arrow'){
176
+ g.append(this.#element('line',{x1:row.x,y1:row.y,x2:row.x2,y2:row.y2}));
177
+ const angle=Math.atan2(row.y2-row.y,row.x2-row.x),size=Math.max(12,row.width*5);
178
+ const x1=row.x2-size*Math.cos(angle-0.45),y1=row.y2-size*Math.sin(angle-0.45),x2=row.x2-size*Math.cos(angle+0.45),y2=row.y2-size*Math.sin(angle+0.45);
179
+ g.append(this.#element('polyline',{points:`${x1},${y1} ${row.x2},${row.y2} ${x2},${y2}`}));
180
+ }
181
+ if(row.type==='freehand')g.append(this.#element('polyline',{points:row.points.map(p=>`${p.x},${p.y}`).join(' ')}));
182
+ if(row.type==='text'){const hit=this.#element('rect',{'data-text-hit':'',fill:'transparent',stroke:'none','pointer-events':'all'});const t=this.#element('text',{x:row.x,y:row.y,fill:row.color,stroke:'none','font-size':Math.max(14,12+row.width*2)});t.textContent=row.text;g.append(hit,t);}
183
+ return g;
184
+ }
185
+ #render(){
186
+ if(!this.#svg||!this.#bag)return;this.#svg.replaceChildren();if(!this.#dimensions)return;
187
+ const [width,height]=this.#dimensions;this.#svg.setAttribute('viewBox',`0 0 ${width} ${height}`);
188
+ if(this.#url)this.#svg.append(this.#element('image',{href:this.#url,x:0,y:0,width,height,'pointer-events':'none'}));
189
+ for(const node of this.#bag.getNodes()){
190
+ const value=node.getValue();if(!(value instanceof Bag))throw new TypeError('Annotation must be a Bag');let row=this.#read(value);
191
+ if(this.#gesture?.id===node.label&&this.#gesture.current)row=this.#translate(this.#gesture.original,{x:this.#gesture.current.x-this.#gesture.start.x,y:this.#gesture.current.y-this.#gesture.start.y});
192
+ const shape=this.#shape(row,node.label);this.#svg.append(shape);
193
+ if(row.type==='text'){const bounds=shape.querySelector('text').getBBox(),hit=shape.querySelector('[data-text-hit]');for(const name of ['x','y','width','height'])hit.setAttribute(name,bounds[name]);}
194
+ }
195
+ const g=this.#gesture;if(g&&!g.id&&g.current){let row;if(this.#tool==='arrow')row={type:'arrow',x:g.start.x,y:g.start.y,x2:g.current.x,y2:g.current.y};if(this.#tool==='circle')row={type:'circle',x:g.start.x,y:g.start.y,radius:Math.hypot(g.current.x-g.start.x,g.current.y-g.start.y)};if(this.#tool==='freehand')row={type:'freehand',points:g.points};if(row)this.#svg.append(this.#shape({...row,color:this.#state.getItem('color'),width:this.#penSize()},''));}
196
+ }
197
+ }
198
+ });
199
+ export default defineCollection({name:'drawing',dependencies:[inputs,layout],components:[DrawingPane]});
@@ -1,6 +1,7 @@
1
1
  import {validateInput, validationParameters} from './validation.js';
2
2
  import {ValidationRun} from '../validation-run.js';
3
3
  import {positionPopup} from './popup.js';
4
+ import {parameterValues} from './parameters.js';
4
5
 
5
6
  const MESSAGE_DURATION = 1800;
6
7
  const MESSAGE_FADE_DURATION = 200;
@@ -9,7 +10,13 @@ const MESSAGE_FADE_DURATION = 200;
9
10
  export function FieldState(Base) {
10
11
  return class extends Base {
11
12
  get supportsFormValidation() { return true; }
12
- get validationExecutor() { return validateInput; }
13
+ static validationParameters(attrs) {
14
+ const parameters = {...parameterValues(this.gramlotComponent,attrs),...attrs};
15
+ if (this.constrained && parameters.validate_select == null) parameters.validate_select = true;
16
+ return parameters;
17
+ }
18
+ static get validationExecutor() { return validateInput; }
19
+ get validationExecutor() { return this.constructor.validationExecutor; }
13
20
  connectedCallback() { super.connectedCallback(); if (this.pageContext?.form) this.pageContext.formValidate(); }
14
21
  #rejected = false;
15
22
  #projected;
@@ -1,4 +1,4 @@
1
- import {sourceTarget} from '@gramlot/gramlot';
1
+ import {sourceTarget, toTytx} from '@gramlot/gramlot';
2
2
 
3
3
  /** Grid navigation and temporary Source controls; all editing registers belong to the shared session. */
4
4
  export class GridCellEditor {
@@ -12,6 +12,8 @@ export class GridCellEditor {
12
12
  this.focusField = focusField;
13
13
  this.retained = new Map();
14
14
  this.declarations = new Map();
15
+ this.checking = new Set();
16
+ this.columns = [];
15
17
  this.layer = grid.ownerDocument.createElement('div');
16
18
  this.layer.className = 'cell-editor'; this.layer.hidden = true;
17
19
  const slot = grid.ownerDocument.createElement('slot'); slot.name = 'cell-editor'; this.layer.append(slot);
@@ -77,44 +79,100 @@ export class GridCellEditor {
77
79
  return this.context.sourceNode.absDatapath(this.context.sourceNode.getAttr('storepath')) + '.' + row.label + (mode === 'attributes' ? '?' : '.') + field;
78
80
  }
79
81
  configure(columns) {
80
- if (!columns.some(column => column.edit)) return;
81
- if (this.store().window !== null) throw new Error('Editing requires a fully resident Bag; remote windows are read-only.');
82
- const owner = this.context.sourceNode;
83
- this.session = owner.editCollection(owner.absDatapath(owner.getAttr('storepath')));
82
+ const editable = columns.filter(column => column.edit);
83
+ if (editable.length) {
84
+ if (this.store().window !== null) throw new Error('Editing requires a fully resident Bag; remote windows are read-only.');
85
+ const owner = this.context.sourceNode;
86
+ this.session = owner.editCollection(owner.absDatapath(owner.getAttr('storepath')));
87
+ }
88
+ const signature = toTytx(editable.map(({field,dtype,edit}) => ({field,dtype,edit})));
89
+ if (signature === this.validationSignature) return;
90
+ this.validationSignature = signature;
91
+ this.columns = editable;
92
+ for (const [path,declaration] of this.declarations) {
93
+ const column = editable.find(column => column.field === declaration.field);
94
+ if (!column) {
95
+ if (this.active?.path === path) this.close();
96
+ this.releaseField(path);
97
+ } else {
98
+ const {tag,options} = this.definition(column);
99
+ if (tag !== declaration.tag) {
100
+ if (this.active?.path === path) this.close();
101
+ this.releaseField(path);
102
+ } else {
103
+ declaration.source.setAttr({...Object.fromEntries(Object.keys(declaration.options).map(key => [key,null])),...options});
104
+ declaration.options = options;
105
+ }
106
+ }
107
+ }
108
+ if (!editable.length) {
109
+ this.releaseValidation?.(); this.releaseValidation = null;
110
+ return;
111
+ }
84
112
  if (!this.releaseStatus) this.releaseStatus = this.session.subscribe(() => this.refresh());
85
113
  if (!this.releaseNavigator) this.releaseNavigator = this.session.registerNavigator(this.focusField);
114
+ if (!this.releaseValidation) this.releaseValidation = this.session.registerValidationSource(() => this.validationFields());
115
+ else this.session.invalidateValidation();
116
+ }
117
+ definition(column) {
118
+ const options = column.edit === true ? {} : {...column.edit};
119
+ const tag = options.tag ?? ({L:'numberTextBox',R:'numberTextBox',N:'numberTextBox',D:'dateTextBox',H:'timeTextBox',B:'checkBox'}[column.dtype] ?? 'textbox');
120
+ if (column.dtype === 'DHZ' && !options.tag) throw new Error('A datetime column requires an explicitly declared supported editor.');
121
+ delete options.tag;
122
+ return {tag,options:{...options,dtype:column.dtype ?? 'T'}};
123
+ }
124
+ *validationFields() {
125
+ const owner = this.context.sourceNode;
126
+ this.session.trackValidationDependency(owner.absDatapath(owner.getAttr('structpath')));
127
+ const bag = this.store().bag;
128
+ for (const row of bag.getNodes()) for (const column of this.columns) {
129
+ if (row.parentBag !== bag) continue;
130
+ const path = this.path(row,column.field);
131
+ this.checking.add(path);
132
+ try {
133
+ const declaration = this.declare(row,column,false);
134
+ yield {node:declaration.source,release:() => {
135
+ this.checking.delete(path);
136
+ if (path !== this.active?.path) this.releaseCleanField(path);
137
+ }};
138
+ } catch (error) { this.checking.delete(path); this.releaseCleanField(path); throw error; }
139
+ }
86
140
  }
87
141
  open(row, column, cell) {
88
142
  if (this.store().window !== null) throw new Error('Editing requires a fully resident Bag; remote windows are read-only.');
89
143
  if (this.active?.row === row && this.active.column.field === column.field) { this.active.element.control.focus(); return; }
90
144
  this.close();
145
+ const path = this.path(row,column.field), declaration = this.declare(row,column,true);
146
+ const element = this.grid.ownerDocument.getElementById(declaration.id);
147
+ this.active = {row,column,path,...declaration,element};
148
+ this.layer.hidden = false;
149
+ this.position(cell);
150
+ element.control.focus();
151
+ }
152
+ declare(row,column,mount) {
91
153
  const owner = this.context.sourceNode, path = this.path(row,column.field);
92
154
  if (!this.retained.has(path)) { this.session.retainField(path); this.retained.set(path,row); }
93
155
  let declaration = this.declarations.get(path);
94
156
  if (!declaration) {
95
- const options = column.edit === true ? {} : {...column.edit};
96
- const tag = options.tag ?? ({L:'numberTextBox', R:'numberTextBox', N:'numberTextBox', D:'dateTextBox', H:'timeTextBox', B:'checkBox'}[column.dtype] ?? 'textbox');
97
- delete options.tag;
98
- if (column.dtype === 'DHZ' && !column.edit.tag) throw new Error('A datetime column requires an explicitly declared supported editor.');
157
+ const {tag,options} = this.definition(column);
99
158
  if (!owner.rootBuilder.schemaTag(tag)) throw new Error(`Grid editor requires the ${tag} input collection.`);
100
159
  const builder = owner.rootBuilder, id = `grid-cell-${crypto.randomUUID()}`;
101
160
  const container = builder.wrapSource(owner).div({node_label:id, slot:'cell-editor'});
161
+ // Unmount the branch before declaring a control: no editor element is constructed.
162
+ if (!mount) builder.binding.renderer.unmountView(sourceTarget(container));
102
163
  try {
103
- const control = container[tag]({...options, value:'^'+path, dtype:column.dtype ?? 'T', id, width:'100%', margin:'0'});
104
- declaration = {container:sourceTarget(container),source:sourceTarget(control),id};
105
- if (!this.grid.ownerDocument.getElementById(id).supportsFormValidation) throw new TypeError('Grid editors require a Gramlot input with shared form validation.');
164
+ const control = container[tag]({...options, value:'^'+path, id, width:'100%', margin:'0'});
165
+ declaration = {container:sourceTarget(container),source:sourceTarget(control),id,tag,options,field:column.field};
166
+ const component = this.grid.ownerDocument.defaultView.customElements.get(declaration.source._getMeta('render_tag'));
167
+ this.session.registerField(declaration.source,component,mount);
106
168
  this.declarations.set(path,declaration);
107
169
  } catch (error) {
108
170
  const node = sourceTarget(container); node.parentBag.popNode(node.label);
109
171
  this.releaseCleanField(path);
110
172
  throw error;
111
173
  }
112
- } else owner.rootBuilder.binding.renderer.mountView(declaration.container);
113
- const element = this.grid.ownerDocument.getElementById(declaration.id);
114
- this.active = {row,column,path,...declaration,element};
115
- this.layer.hidden = false;
116
- this.position(cell);
117
- element.control.focus();
174
+ } else if (mount) owner.rootBuilder.binding.renderer.mountView(declaration.container);
175
+ return declaration;
118
176
  }
119
177
  close() {
120
178
  const active = this.active;
@@ -125,6 +183,7 @@ export class GridCellEditor {
125
183
  }
126
184
  }
127
185
  releaseCleanField(path) {
186
+ if (this.checking.has(path)) return;
128
187
  const state = this.session.fieldStatus(path);
129
188
  if (state.error === null && state.pending === null && state.draft === null && this.retained.has(path)) {
130
189
  this.releaseField(path);
@@ -142,12 +201,16 @@ export class GridCellEditor {
142
201
  if (!cell) { this.close(); return; }
143
202
  const rect = cell.getBoundingClientRect(), host = this.grid.control.getBoundingClientRect();
144
203
  const viewport = this.grid.shadowRoot.querySelector('.body-viewport').getBoundingClientRect();
145
- if (viewport.height && (rect.top < viewport.top || rect.bottom > viewport.bottom || rect.right <= viewport.left || rect.left >= viewport.right)) { this.close(); return; }
146
204
  Object.assign(this.layer.style,{
147
205
  left:`${rect.left-host.left-this.grid.control.clientLeft}px`,
148
206
  top:`${rect.top-host.top-this.grid.control.clientTop}px`,width:`${rect.width}px`
149
207
  });
150
208
  this.layer.style.setProperty('--grid-editor-height',`${rect.height}px`);
209
+ const maxHeight = cell.style.getPropertyValue('--grid-cell-max-height');
210
+ if (maxHeight) this.layer.style.setProperty('--grid-cell-max-height',maxHeight);
211
+ else this.layer.style.removeProperty('--grid-cell-max-height');
212
+ const editor = this.layer.getBoundingClientRect();
213
+ if (viewport.height && (editor.top < viewport.top || editor.bottom > viewport.bottom || editor.right <= viewport.left || editor.left >= viewport.right)) this.close();
151
214
  }
152
215
  decorate(tr, row) {
153
216
  if (!this.session) return;
@@ -176,6 +239,7 @@ export class GridCellEditor {
176
239
  }
177
240
  }
178
241
  dispose() {
242
+ this.releaseValidation?.(); this.releaseValidation = null;
179
243
  this.disconnect(); this.replaceData(); this.releaseStatus?.(); this.layer.remove();
180
244
  }
181
245
  }
@@ -0,0 +1,98 @@
1
+ import {containsId, requireId, requireIdSet} from '../stores/id-set.js';
2
+
3
+ function singleId(id) {
4
+ if (typeof id === 'number' && Number.isFinite(id)) return id;
5
+ return requireId(id);
6
+ }
7
+
8
+ /** External membership columns. Data IDs and membership strings are authoritative; DOM checks are projections. */
9
+ export class GridCheckSets {
10
+ #registrations = [];
11
+ #connected = false;
12
+ constructor(source, body, columns, rowFor, read, selection, view) {
13
+ this.source = source; this.body = body; this.columns = columns;
14
+ this.rowFor = rowFor; this.read = read; this.selection = selection; this.view = view;
15
+ }
16
+ path(column) { return this.source.absDatapath(column.checked.slice(1)); }
17
+ value(column) {
18
+ const value = this.source.getRelativeData(column.checked.slice(1));
19
+ if (column.check === 'single') return value == null || value === '' ? value : singleId(value);
20
+ return requireIdSet(value);
21
+ }
22
+ id(row, column) {
23
+ const id = this.read(row,column.checkedField);
24
+ if (column.check === 'single') return singleId(id);
25
+ return requireId(id);
26
+ }
27
+ contains(column, value, id) { return column.check === 'single' ? value === id : containsId(value,id); }
28
+ filter() {
29
+ const selected = this.selection();
30
+ const sets = selected === '' ? null : selected.split(',').map(field => {
31
+ const column = this.columns().find(column => column.field === field && column.check === 'multiple');
32
+ if (!column) throw new TypeError(`Unknown external check column: ${field}`);
33
+ return {field:column.checkedField,value:this.value(column)};
34
+ });
35
+ this.view().applySetFilter(sets);
36
+ }
37
+ project(content, row, column) {
38
+ const id = this.id(row,column), value = this.value(column);
39
+ let input = content.querySelector('input.grid-set-check');
40
+ if (!input) {
41
+ input = content.ownerDocument.createElement('input');
42
+ input.className = 'grid-set-check'; content.replaceChildren(input);
43
+ }
44
+ input.type = column.check === 'single' ? 'radio' : 'checkbox';
45
+ if (column.check === 'single') input.name = column.field;
46
+ else input.removeAttribute('name');
47
+ input.setAttribute('aria-label', `${column.title ?? column.name}: ${id}`);
48
+ input.checked = this.contains(column,value,id);
49
+ }
50
+ refresh = () => {
51
+ this.filter();
52
+ for (const input of this.body.querySelectorAll('input.grid-set-check')) {
53
+ const cell = input.closest('td[data-field]');
54
+ const column = this.columns().find(c => c.field === cell.dataset.field);
55
+ const row = this.rowFor(cell.parentElement);
56
+ if (column?.check && row) this.project(input.parentElement,row,column);
57
+ }
58
+ };
59
+ change = event => {
60
+ const input = event.target;
61
+ if (!input.matches('input.grid-set-check')) return;
62
+ const cell = input.closest('td[data-field]');
63
+ const column = this.columns().find(c => c.field === cell.dataset.field);
64
+ const row = this.rowFor(cell.parentElement);
65
+ const id = this.id(row,column), value = this.value(column);
66
+ const present = this.contains(column,value,id);
67
+ if (input.checked === present) return;
68
+ if (column.check === 'single') {
69
+ if (input.checked) this.source.setRelativeData(column.checked.slice(1),id);
70
+ else this.project(input.parentElement,row,column);
71
+ return;
72
+ }
73
+ const next = input.checked ? (value ? value + ',' + id : id)
74
+ : (',' + value + ',').replace(',' + id + ',', ',').slice(1,-1);
75
+ this.source.setRelativeData(column.checked.slice(1),next);
76
+ };
77
+ configure() {
78
+ for (const registration of this.#registrations) registration.close();
79
+ this.#registrations = [];
80
+ if (!this.#connected) return;
81
+ this.filter();
82
+ for (const column of this.columns().filter(column => column.check)) {
83
+ this.#registrations.push(this.source.rootBuilder.binding.router.register({
84
+ path:this.path(column), recipient:{receive:this.refresh}
85
+ }));
86
+ }
87
+ }
88
+ connect() {
89
+ if (this.#connected) return;
90
+ this.#connected = true;
91
+ this.body.addEventListener('change',this.change);
92
+ }
93
+ disconnect() {
94
+ this.body.removeEventListener('change',this.change);
95
+ this.#connected = false;
96
+ this.configure();
97
+ }
98
+ }