@gramlot/gramlot 0.3.37 → 0.3.39
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.
- package/dist/components/audio/__init__.py +1 -1
- package/dist/components/audio/assets/collection.js +4 -3
- package/dist/components/audio/assets/index.js +1 -1
- package/dist/components/charts/__init__.py +2 -2
- package/dist/components/charts/assets/collection.js +3 -28
- package/dist/components/charts/assets/index.js +1 -1
- package/dist/components/charts/assets/libraries/chunks/chunk-LVZ6SHV2.js +1 -0
- package/dist/components/charts/assets/{modules/echarts.esm.min-VHLRZDVQ.js → libraries/echarts.js} +1 -1
- package/dist/components/charts/assets/{modules/plotly.min-SSDU2DOH.js → libraries/plotly.js} +1 -1
- package/dist/components/charts/assets/{modules/uPlot.esm-Q2UYUQHJ.js → libraries/uplot.js} +1 -1
- package/dist/components/charts/assets/libraries/uplotStyle.js +1 -0
- package/dist/components/charts/assets/{modules/vega.module-Y5CWNSZO.js → libraries/vega.js} +1 -1
- package/dist/components/chat/__init__.py +1 -1
- package/dist/components/chat/assets/collection.js +4 -9
- package/dist/components/chat/assets/index.js +1 -1
- package/dist/components/drawing/__init__.py +1 -1
- package/dist/components/drawing/assets/collection.js +4 -7
- package/dist/components/drawing/assets/index.js +1 -1
- package/dist/components/drawing/grammar.json +75 -0
- package/dist/components/editors/__init__.py +2 -2
- package/dist/components/editors/assets/collection.js +9 -7
- package/dist/components/editors/assets/index.js +1 -1
- package/dist/components/editors/assets/libraries/chunks/chunk-4TTZUUSG.js +1 -0
- package/dist/components/editors/assets/libraries/chunks/chunk-QRHUDCCH.js +1 -0
- package/dist/components/editors/assets/libraries/chunks/chunk-XGS3SDSL.js +1 -0
- package/dist/components/editors/assets/{modules/code-mirror-engine-RWQTR5G5.js → libraries/codemirror.js} +2 -2
- package/dist/components/editors/assets/{modules/jodit-engine-CXRSFV47.js → libraries/jodit.js} +292 -292
- package/dist/components/editors/assets/libraries/markdownIt.js +1 -0
- package/dist/components/editors/assets/{modules/prose-mirror-engine-DQEAEIMV.js → libraries/prosemirror.js} +1 -1
- package/dist/components/editors/assets/{modules/xterm-UBEXZEYY.js → libraries/xterm.js} +1 -1
- package/dist/components/editors/assets/{modules/addon-fit-L6JK4OJX.js → libraries/xtermFit.js} +1 -1
- package/dist/components/editors/assets/{modules/xterm-BF3OSWRI.js → libraries/xtermStyle.js} +1 -1
- package/dist/components/grid/__init__.py +2 -2
- package/dist/components/grid/assets/collection.js +4 -286
- package/dist/components/grid/assets/index.js +1 -1
- package/dist/components/grid/assets/{modules/browser-Y2BRNI3P.js → libraries/writeExcelFile.js} +1 -1
- package/dist/components/grouplets/__init__.py +2 -2
- package/dist/components/grouplets/assets/collection.js +5 -185
- package/dist/components/grouplets/assets/index.js +1 -1
- package/dist/components/grouplets/assets/libraries/markdownIt.js +1 -0
- package/dist/components/inputs/__init__.py +1 -1
- package/dist/components/inputs/assets/collection.js +22 -65
- package/dist/components/inputs/assets/index.js +1 -1
- package/dist/components/layout/__init__.py +1 -1
- package/dist/components/layout/assets/collection.js +14 -218
- package/dist/components/layout/assets/index.js +1 -1
- package/dist/components/layout/grammar.json +146 -1
- package/dist/components/selection_trial/__init__.py +1 -1
- package/dist/components/selection_trial/assets/collection.js +2 -4
- package/dist/components/selection_trial/assets/index.js +1 -1
- package/dist/components/tree/__init__.py +1 -1
- package/dist/components/tree/assets/collection.js +5 -31
- package/dist/components/tree/assets/index.js +1 -1
- package/dist/components/typst/__init__.py +2 -2
- package/dist/components/typst/assets/collection.js +3 -3
- package/dist/components/typst/assets/index.js +1 -1
- package/dist/components/typst/assets/libraries/typst.js +4 -0
- package/dist/components/uploads/__init__.py +1 -1
- package/dist/components/uploads/assets/collection.js +6 -40
- package/dist/components/uploads/assets/index.js +1 -1
- package/dist/components/uploads/grammar.json +15 -0
- package/dist/declared-collections.js +1 -1
- package/dist/gramlot.js +23518 -5533
- package/dist/gramlot.min.js +915 -50
- package/dist/libraries.json +10 -1
- package/dist/standard-collections.js +1 -1
- package/dist/standard-grammar.js +3 -0
- package/package.json +3 -2
- package/src/bootstrap.js +6 -0
- package/src/build-plugins.d.ts +9 -0
- package/src/build-plugins.js +59 -0
- package/src/bundled-collections.js +25 -0
- package/src/components/attachment-manager.js +1 -1
- package/src/components/border-container.js +1 -1
- package/src/components/chart-fields.js +1 -1
- package/src/components/chart-pane.js +2 -1
- package/src/components/chart-renderer.js +1 -1
- package/src/components/chart-type-data.js +1 -1
- package/src/components/charts.js +1 -1
- package/src/components/chat.js +1 -1
- package/src/components/check-box-text.js +1 -1
- package/src/components/check-box-tree.js +1 -1
- package/src/components/choice-editor.js +1 -1
- package/src/components/database-choices.js +1 -1
- package/src/components/drawing.js +10 -4
- package/src/components/editing-status.js +1 -1
- package/src/components/grid-cell-editor.js +3 -1
- package/src/components/grid-column-filters.js +2 -1
- package/src/components/grid-selection.js +1 -1
- package/src/components/grid-structure.js +1 -1
- package/src/components/grid-tools.js +1 -1
- package/src/components/grid.js +1 -1
- package/src/components/grouplet-card.js +2 -1
- package/src/components/html-preview.js +2 -1
- package/src/components/image-crop-dialog.js +44 -4
- package/src/components/image-rectangle-selection.js +128 -0
- package/src/components/image-uploader.js +2 -1
- package/src/components/index.js +1 -0
- package/src/components/jodit-engine.js +1 -1
- package/src/components/markdown-document.js +1 -1
- package/src/components/tray-geometry.js +35 -0
- package/src/components/tray-pane.js +50 -7
- package/src/components/tree.js +2 -1
- package/src/components/upload-engine.js +1 -1
- package/src/components/uploader.js +1 -1
- package/src/components/validation.js +1 -1
- package/src/components/window-surface.js +122 -18
- package/src/components/windows.js +3 -2
- package/src/experiments/selection-transfer.js +2 -1
- package/src/experiments/selection-trial.js +1 -1
- package/src/experiments/window-selection.js +1 -1
- package/src/handlers/source-handler.d.ts +3 -0
- package/src/handlers/source-handler.js +18 -1
- package/src/index.d.ts +5 -0
- package/src/index.js +4 -0
- package/src/libraries.js +4 -1
- package/src/server/gramlot-server.d.ts +4 -0
- package/src/server/gramlot-server.js +16 -1
- package/src/shared-modules.js +28 -1
- package/src/view/html.js +8 -1
- package/dist/components/charts/assets/modules/chunk-USZCUBTC.js +0 -1
- package/dist/components/charts/assets/modules/uPlot.min-XXHNQFXH.js +0 -1
- package/dist/components/editors/assets/modules/chunk-74O4WKIV.js +0 -1
- package/dist/components/editors/assets/modules/chunk-AU4HFPIY.js +0 -1
- package/dist/components/editors/assets/modules/markdown-document-VFC23FAY.js +0 -1
- package/dist/components/grid/assets/modules/chunk-BLMUM44K.js +0 -1
- package/dist/components/grouplets/assets/modules/chunk-BLMUM44K.js +0 -1
- package/dist/components/grouplets/assets/modules/markdown-document-YWNZTOKK.js +0 -1
- package/dist/components/typst/assets/modules/chunk-BLMUM44K.js +0 -1
- package/dist/components/typst/assets/modules/typst-client-JHC6UVYG.js +0 -4
- /package/dist/components/charts/assets/{modules/echarts-gl.min-N6L67H2M.js → libraries/echartsGl.js} +0 -0
- /package/dist/components/editors/assets/{modules/chunk-YSGSC7KM.js → libraries/chunks/chunk-TSYAHRZC.js} +0 -0
|
@@ -11,6 +11,7 @@ export const ImageUploader = defineComponent({
|
|
|
11
11
|
storepath:{dtype:'T'}, contextPath:{dtype:'T',nullable:true,default:null}, operation:{dtype:'T', nullable:true, default:null},
|
|
12
12
|
cropWidth:{dtype:'L', default:256}, cropHeight:{dtype:'L', default:256},
|
|
13
13
|
outputWidth:{dtype:'L', default:512}, outputHeight:{dtype:'L', default:512},
|
|
14
|
+
screenCapture:{dtype:'B', default:true},
|
|
14
15
|
disabled:{dtype:'B', default:false, binding:'read'}, onComplete:{dtype:'T', nullable:true, default:null}},
|
|
15
16
|
implementation: Base => class extends Base {
|
|
16
17
|
#context; #engine; #original; #dialog; #pending; #generation = 0; #projected; #written;
|
|
@@ -155,7 +156,7 @@ export const ImageUploader = defineComponent({
|
|
|
155
156
|
if (value) { this.preview.src = value; this.preview.hidden = false; } else { this.preview.removeAttribute('src'); this.preview.hidden = true; }
|
|
156
157
|
const state = this.#pending && this.#engine.store.getItem(this.#pending.id)?.getItem('status');
|
|
157
158
|
const busy = Boolean(this.#pending || this.#cameraToken !== null || this.#screenRequest);
|
|
158
|
-
this.screenButton.hidden = !this.ownerDocument.defaultView.navigator.mediaDevices?.getDisplayMedia;
|
|
159
|
+
this.screenButton.hidden = this.parameters.screenCapture === false || !this.ownerDocument.defaultView.navigator.mediaDevices?.getDisplayMedia;
|
|
159
160
|
this.screenButton.disabled = Boolean(this.parameters.disabled || busy);
|
|
160
161
|
this.cancelScreenButton.hidden = !this.#screenRequest;
|
|
161
162
|
this.cameraButton.hidden = !this.#cameraAvailable;
|
package/src/components/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** Locally bundled optional Jodit engine, initialized only by htmlEditor. */
|
|
2
2
|
import {Jodit} from 'jodit';
|
|
3
|
-
import
|
|
3
|
+
import createDOMPurify from 'dompurify';
|
|
4
4
|
import 'jodit/esm/plugins/clean-html/clean-html.js';
|
|
5
5
|
import 'jodit/esm/plugins/clipboard/clipboard.js';
|
|
6
6
|
import 'jodit/esm/plugins/paste/paste.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import MarkdownIt from '@gramlot/gramlot/markdown';
|
|
2
|
-
import
|
|
2
|
+
import createDOMPurify from 'dompurify';
|
|
3
3
|
|
|
4
4
|
// Keep the rich-editor codec and ordinary previews in HTML-as-text mode.
|
|
5
5
|
export const markdownRenderer = new MarkdownIt({html:false});
|
|
@@ -85,3 +85,38 @@ export function contactFraction(start,end,obstacles,bounds) {
|
|
|
85
85
|
}
|
|
86
86
|
return search(0,1);
|
|
87
87
|
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Even grid for autoArrange, in item order. With fit, each card fills its cell
|
|
91
|
+
* (keeping aspectRatio when set), then grows to minWidth/minHeight. Without fit,
|
|
92
|
+
* each card keeps its width/height. The column count is the one whose cards fit
|
|
93
|
+
* their cells with the largest total area (fit), or the largest scale margin.
|
|
94
|
+
*/
|
|
95
|
+
export function arrangeGrid({width,height,gap,fit,items}) {
|
|
96
|
+
let best=null;
|
|
97
|
+
for(let columns=1;columns<=items.length;columns++) {
|
|
98
|
+
const rows=Math.ceil(items.length/columns);
|
|
99
|
+
const cellWidth=Math.max(0,(width-gap*(columns+1))/columns),cellHeight=Math.max(0,(height-gap*(rows+1))/rows);
|
|
100
|
+
const sizes=items.map(item=>fit ? fitCell(item,cellWidth,cellHeight) : {width:item.width,height:item.height});
|
|
101
|
+
const margin=Math.min(...sizes.map(size=>Math.min(cellWidth/size.width,cellHeight/size.height)));
|
|
102
|
+
const area=sizes.reduce((sum,size)=>sum+size.width*size.height,0);
|
|
103
|
+
const fits=margin>=1-EPSILON;
|
|
104
|
+
const better=!best || (!fit ? margin>best.margin+EPSILON
|
|
105
|
+
: fits ? !best.fits||area>best.area+EPSILON : !best.fits&&margin>best.margin+EPSILON);
|
|
106
|
+
if(better)best={columns,rows,cellWidth,cellHeight,sizes,margin,area,fits};
|
|
107
|
+
}
|
|
108
|
+
if(!best)return [];
|
|
109
|
+
const {columns,cellWidth,cellHeight,sizes}=best;
|
|
110
|
+
return sizes.map((size,index)=>{
|
|
111
|
+
const row=Math.floor(index/columns),column=index%columns;
|
|
112
|
+
// An incomplete last row is centered horizontally.
|
|
113
|
+
const inRow=Math.min(columns,items.length-row*columns),offset=(columns-inRow)*(cellWidth+gap)/2;
|
|
114
|
+
return {left:offset+gap+column*(cellWidth+gap)+(cellWidth-size.width)/2,
|
|
115
|
+
top:gap+row*(cellHeight+gap)+(cellHeight-size.height)/2,width:size.width,height:size.height};
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
function fitCell({aspectRatio,minWidth,minHeight},cellWidth,cellHeight) {
|
|
119
|
+
if(aspectRatio==null)return {width:Math.max(cellWidth,minWidth),height:Math.max(cellHeight,minHeight)};
|
|
120
|
+
const width=Math.max(Math.min(cellWidth,cellHeight*aspectRatio),minWidth,minHeight*aspectRatio);
|
|
121
|
+
return {width,height:width/aspectRatio};
|
|
122
|
+
}
|
|
@@ -1,27 +1,31 @@
|
|
|
1
1
|
/** Contained Labelbox movement. The store Bag is the sole geometry state. */
|
|
2
|
-
import {Bag} from '@
|
|
2
|
+
import {Bag} from '@genrojs/bag';
|
|
3
3
|
import {defineComponent} from './registry.js';
|
|
4
4
|
import {Container} from './container.js';
|
|
5
5
|
import {SVG_NS} from '../renderer/attributes.js';
|
|
6
|
-
import {corners, overlaps, contactFraction} from './tray-geometry.js';
|
|
6
|
+
import {corners, overlaps, contactFraction, arrangeGrid} from './tray-geometry.js';
|
|
7
7
|
import {createTraySettings} from './tray-settings.js';
|
|
8
8
|
|
|
9
9
|
export const TrayPane = defineComponent({
|
|
10
10
|
name: 'trayPane', tag: 'gramlot-tray-pane', base: Container, subTags: '*', sourceContext: true,
|
|
11
11
|
parameters: {storepath: {dtype: 'T'}, locked: {dtype:'B',default:false,binding:'read'},
|
|
12
12
|
gridStep:{dtype:'L',default:10,binding:'read'},gridVisible:{dtype:'B',default:false,binding:'read'},
|
|
13
|
-
rotationStep:{dtype:'N',default:15,binding:'read'}
|
|
14
|
-
|
|
13
|
+
rotationStep:{dtype:'N',default:15,binding:'read'},
|
|
14
|
+
autoArrange:{dtype:'B',default:false,binding:'twoWay'},autoSize:{dtype:'B',default:false,binding:'read'}},
|
|
15
|
+
childParameters: {closable:{dtype:'B',default:false},minWidth:{dtype:'N',default:100},minHeight:{dtype:'N',default:64},
|
|
16
|
+
aspectRatio:{dtype:'N',nullable:true,default:null}},
|
|
15
17
|
implementation: Base => class TrayPane extends Base {
|
|
16
18
|
// Projection metadata, keyed by the existing renderer presentation.
|
|
17
19
|
static #blocks = new WeakMap();
|
|
18
20
|
static projectChild(box, attrs, {label, remove}) {
|
|
19
21
|
if (!box.labelbox) throw new TypeError('trayPane children require a Labelbox (declare lbl)');
|
|
20
|
-
const {minWidth=100, minHeight=64, closable=false, ...rest} = attrs;
|
|
22
|
+
const {minWidth=100, minHeight=64, closable=false, aspectRatio=null, ...rest} = attrs;
|
|
21
23
|
if(typeof closable!=='boolean')throw new TypeError('closable must be a boolean');
|
|
22
24
|
if (![minWidth,minHeight].every(value=>typeof value==='number'&&Number.isFinite(value)&&value>0))
|
|
23
25
|
throw new TypeError('trayPane minimum dimensions must be positive numbers');
|
|
24
|
-
|
|
26
|
+
if(aspectRatio!==null&&!(typeof aspectRatio==='number'&&Number.isFinite(aspectRatio)&&aspectRatio>0))
|
|
27
|
+
throw new TypeError('trayPane aspectRatio must be a positive number or null');
|
|
28
|
+
TrayPane.#blocks.set(box, {label, minWidth, minHeight, aspectRatio, closable, remove});
|
|
25
29
|
box.setAttribute('data-tray-block','');
|
|
26
30
|
const settings=box.labelbox.traySettings ??= createTraySettings(box);
|
|
27
31
|
for(const [key,{button}] of Object.entries(settings.controls)) {
|
|
@@ -82,6 +86,9 @@ export const TrayPane = defineComponent({
|
|
|
82
86
|
#context;
|
|
83
87
|
// The router registration on the storepath address: the geometry events reach the tray by path.
|
|
84
88
|
#geometry = null;
|
|
89
|
+
#resizeObserver;
|
|
90
|
+
// Inputs of the last automatic arrangement; null requests a new one.
|
|
91
|
+
#arranged=null;
|
|
85
92
|
#settings=new Set();
|
|
86
93
|
#events;
|
|
87
94
|
#scheduled = false;
|
|
@@ -96,7 +103,9 @@ export const TrayPane = defineComponent({
|
|
|
96
103
|
this.shadowRoot.append(style);
|
|
97
104
|
}
|
|
98
105
|
projectAttributes(attrs) {
|
|
106
|
+
const previous=this.parameters;
|
|
99
107
|
const rest=super.projectAttributes(attrs);
|
|
108
|
+
if(this.parameters.autoArrange&&!previous?.autoArrange)this.#arranged=null;
|
|
100
109
|
for(const key of ['gridStep','rotationStep']) {
|
|
101
110
|
const value=this.parameters[key];
|
|
102
111
|
if(typeof value!=='number'||!Number.isFinite(value)||value<0||(key==='gridStep'&&!Number.isInteger(value)))
|
|
@@ -120,6 +129,8 @@ export const TrayPane = defineComponent({
|
|
|
120
129
|
this.#observeGeometry();
|
|
121
130
|
this.#events = new this.ownerDocument.defaultView.AbortController();
|
|
122
131
|
const options = {signal:this.#events.signal};
|
|
132
|
+
this.#resizeObserver=new this.ownerDocument.defaultView.ResizeObserver(()=>this.#schedule());
|
|
133
|
+
this.#resizeObserver.observe(this);
|
|
123
134
|
this.shadowRoot.querySelector('slot').addEventListener('slotchange', () => this.#schedule(), options);
|
|
124
135
|
this.addEventListener('pointerdown', event => this.#start(event), options);
|
|
125
136
|
this.addEventListener('pointermove', event => this.#move(event), options);
|
|
@@ -162,7 +173,7 @@ export const TrayPane = defineComponent({
|
|
|
162
173
|
}
|
|
163
174
|
disconnectedCallback() {
|
|
164
175
|
for(const settings of this.#settings)settings.remove();
|
|
165
|
-
this.#finish(); this.#events.abort();
|
|
176
|
+
this.#finish(); this.#events.abort(); this.#resizeObserver.disconnect();
|
|
166
177
|
this.#geometry?.close(); this.#geometry=null;
|
|
167
178
|
}
|
|
168
179
|
/**
|
|
@@ -174,11 +185,14 @@ export const TrayPane = defineComponent({
|
|
|
174
185
|
const path=this.#context.attrDatapath('storepath');
|
|
175
186
|
if(this.#geometry?.path===path)return;
|
|
176
187
|
if(this.#geometry){this.#finish();this.#geometry.close();}
|
|
188
|
+
this.#arranged=null;
|
|
177
189
|
this.#geometry=this.#context.sourceNode.rootBuilder.binding.router.register({path,subtree:true,
|
|
178
190
|
recipient:{receive:change=>this.#geometryChange(change)}});
|
|
179
191
|
}
|
|
180
192
|
#geometryChange(event) {
|
|
181
193
|
if(this.#writing)return;
|
|
194
|
+
// A new Bag at the storepath address is arranged again.
|
|
195
|
+
if(event.path===this.#geometry.path)this.#arranged=null;
|
|
182
196
|
if(event.node.label!=='selected'||this.#drag?.members||this.#drag?.marquee)this.#finish();
|
|
183
197
|
if(!['layer','rotation','scale'].includes(event.node.label) || !['upd_value','upd_value_attr'].includes(event.evt))return;
|
|
184
198
|
// The row of the event, by address: <storepath>.<row label>.<key>.
|
|
@@ -212,6 +226,7 @@ export const TrayPane = defineComponent({
|
|
|
212
226
|
for(const settings of this.#settings)if(![...this.children].some(box=>box.labelbox.traySettings===settings)) {
|
|
213
227
|
settings.remove();this.#settings.delete(settings);
|
|
214
228
|
}
|
|
229
|
+
if(this.parameters.autoArrange)this.#arrange();
|
|
215
230
|
for (const box of this.children) {
|
|
216
231
|
const block = TrayPane.#blocks.get(box);
|
|
217
232
|
const row = this.#row(block.label);
|
|
@@ -245,6 +260,30 @@ export const TrayPane = defineComponent({
|
|
|
245
260
|
}
|
|
246
261
|
});
|
|
247
262
|
}
|
|
263
|
+
/** Writes an even grid into the rows when its inputs changed since the last arrangement. */
|
|
264
|
+
#arrange() {
|
|
265
|
+
const width=this.clientWidth,height=this.clientHeight,fit=this.parameters.autoSize;
|
|
266
|
+
// A pane without layout (for example in a hidden panel) arranges once it has a size.
|
|
267
|
+
if(width<=0||height<=0)return;
|
|
268
|
+
const boxes=[...this.children],items=boxes.map(box=>{
|
|
269
|
+
const {label,aspectRatio,minWidth,minHeight}=TrayPane.#blocks.get(box);
|
|
270
|
+
if(fit)return {label,aspectRatio,minWidth,minHeight};
|
|
271
|
+
const rectangle=this.#rectangle(box);
|
|
272
|
+
return {label,aspectRatio,minWidth,minHeight,width:rectangle.width,height:rectangle.height};
|
|
273
|
+
});
|
|
274
|
+
const inputs=JSON.stringify([width,height,fit,this.parameters.gridStep,items]);
|
|
275
|
+
if(inputs===this.#arranged)return;
|
|
276
|
+
this.#arranged=inputs;
|
|
277
|
+
const rectangles=arrangeGrid({width,height,gap:this.parameters.gridStep,fit,items});
|
|
278
|
+
boxes.forEach((box,index)=>{
|
|
279
|
+
const rectangle=rectangles[index],row=this.#row(TrayPane.#blocks.get(box).label);
|
|
280
|
+
this.#write(row,fit ? rectangle : {left:rectangle.left,top:rectangle.top});
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
/** A user move or resize keeps the user's arrangement. */
|
|
284
|
+
#manual() {
|
|
285
|
+
if(this.parameters.autoArrange)this.#context.writeParameter('autoArrange',false);
|
|
286
|
+
}
|
|
248
287
|
#row(label) {
|
|
249
288
|
const store = this.#storeBag(), node = store.getNode([label]);
|
|
250
289
|
let row = node?.value;
|
|
@@ -326,6 +365,7 @@ export const TrayPane = defineComponent({
|
|
|
326
365
|
const members=!rotate&&!resize ? [...this.children].filter(child=>child===box||this.#row(TrayPane.#blocks.get(child).label).getItem('selected'))
|
|
327
366
|
.map(child=>({box:child,label:TrayPane.#blocks.get(child).label,...this.#rectangle(child)})) : null;
|
|
328
367
|
this.#drag = {box, label:block.label, members, pendingSelection, extend:event.shiftKey, moved:false, id:event.pointerId, left:row.getItem('left'), top:row.getItem('top'),
|
|
368
|
+
autoArrange:this.parameters.autoArrange,
|
|
329
369
|
resize, rotate, angle:row.getItem('rotation'), ...this.#rectangle(box),
|
|
330
370
|
x:event.clientX-rect.left, y:event.clientY-rect.top};
|
|
331
371
|
if(rotate)this.#drag.pointerAngle=Math.atan2(event.clientY-rect.top-this.clientTop-this.#drag.top-this.#drag.height/2,
|
|
@@ -390,6 +430,7 @@ export const TrayPane = defineComponent({
|
|
|
390
430
|
}
|
|
391
431
|
if(dx===0&&dy===0&&!drag.moved)return;
|
|
392
432
|
drag.moved=true;
|
|
433
|
+
this.#manual();
|
|
393
434
|
const left=this.#snap(Math.round(drag.left+dx),this.parameters.gridStep,event.shiftKey),
|
|
394
435
|
top=this.#snap(Math.round(drag.top+dy),this.parameters.gridStep,event.shiftKey);
|
|
395
436
|
if (left !== drag.left || top !== drag.top) this.#suppressClick = true;
|
|
@@ -437,6 +478,7 @@ export const TrayPane = defineComponent({
|
|
|
437
478
|
}
|
|
438
479
|
else if (drag.box.parentElement === this&&this.#gestureRows([drag.label])) this.#write(this.#row(drag.label),drag.rotate ? {rotation:drag.rotation} : drag.resize
|
|
439
480
|
? {left:drag.left,top:drag.top,width:drag.width,height:drag.height} : {left:drag.left,top:drag.top});
|
|
481
|
+
if(drag.autoArrange&&!this.parameters.autoArrange)this.#context.writeParameter('autoArrange',true);
|
|
440
482
|
this.#suppressClick = false;
|
|
441
483
|
this.#finish();
|
|
442
484
|
}
|
|
@@ -454,6 +496,7 @@ export const TrayPane = defineComponent({
|
|
|
454
496
|
}
|
|
455
497
|
#resize(box,row,width,height,origin=this.#rectangle(box)){
|
|
456
498
|
const block=TrayPane.#blocks.get(box);
|
|
499
|
+
this.#manual();
|
|
457
500
|
width=Math.max(block.minWidth,width);height=Math.max(block.minHeight,height);
|
|
458
501
|
// Keep the transformed upper-left corner anchored during resize.
|
|
459
502
|
const dw=(width-origin.width)/2,dh=(height-origin.height)/2,a=origin.rotation*Math.PI/180;
|
package/src/components/tree.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/** Bag hierarchy, lazy branch expansion, captions and path selection. */
|
|
2
|
-
import {Bag
|
|
2
|
+
import {Bag} from '@genrojs/bag';
|
|
3
|
+
import createDOMPurify from 'dompurify';
|
|
3
4
|
import {defineComponent, defineCollection} from './registry.js';
|
|
4
5
|
import {Container} from './container.js';
|
|
5
6
|
import {SVG_NS} from '../renderer/attributes.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Select or drop files into a shared upload queue. */
|
|
2
|
-
import {Bag} from '@
|
|
2
|
+
import {Bag} from '@genrojs/bag';
|
|
3
3
|
import {defineComponent} from './registry.js';
|
|
4
4
|
import {Container} from './container.js';
|
|
5
5
|
import {UploadEngine, readUploadContext} from './upload-engine.js';
|
|
@@ -2,14 +2,16 @@ import {SVG_NS} from '../renderer/attributes.js';
|
|
|
2
2
|
|
|
3
3
|
// Shared presentation only; Source ownership remains with the caller.
|
|
4
4
|
const surfaces = new WeakMap();
|
|
5
|
+
// Pointer travel in px that turns a press on the move handle of a docked detachable window into a detach.
|
|
6
|
+
const DETACH_DISTANCE = 6;
|
|
5
7
|
export class WindowSurface {
|
|
6
8
|
#context; #observer; #scheduled = false; #live = false;
|
|
7
9
|
#open = false; #collapsed = false; #maximized = false; #pending = null; #generation = 0;
|
|
8
|
-
#geometry = null; #gesture = null; #previousFocus = null;
|
|
9
|
-
#resize = () => { if (this.#open && !this
|
|
10
|
-
constructor(host, root, {modal, validateContent}) {
|
|
10
|
+
#geometry = null; #gesture = null; #previousFocus = null; #written = new Map();
|
|
11
|
+
#resize = () => { if (this.#open && !this.#docked) this.#fit(); };
|
|
12
|
+
constructor(host, root, {modal, validateContent, content = null}) {
|
|
11
13
|
this.host = host; this.root = root; this.modal = modal;
|
|
12
|
-
this.validateContent = validateContent;
|
|
14
|
+
this.validateContent = validateContent; this.content = content;
|
|
13
15
|
const doc = this.ownerDocument;
|
|
14
16
|
const shadow = this.root; shadow.classList.add('window-surface');
|
|
15
17
|
const style = doc.createElement('style');
|
|
@@ -20,7 +22,7 @@ export class WindowSurface {
|
|
|
20
22
|
background:var(--gramlot-surface,Canvas);box-shadow:0 2px 6px #00000014,0 16px 36px #00000029;overflow:hidden;
|
|
21
23
|
max-width:calc(100vw - 16px);max-height:calc(100dvh - 16px)}
|
|
22
24
|
.window-surface dialog[open]{display:flex;flex-direction:column}
|
|
23
|
-
.window-surface dialog[data-docked]{position:relative!important;inset:0!important;width:100%!important;height:100
|
|
25
|
+
.window-surface dialog[data-docked]{position:relative!important;inset:0!important;width:100%!important;height:var(--collapsed-height,100%)!important;
|
|
24
26
|
min-width:0!important;min-height:0!important;max-width:none!important;max-height:none!important;
|
|
25
27
|
border:0;border-radius:0;box-shadow:none;z-index:auto!important}
|
|
26
28
|
.window-surface dialog[data-docked] .titlebar,.window-surface dialog[data-docked] .resize{display:none!important}
|
|
@@ -79,11 +81,38 @@ export class WindowSurface {
|
|
|
79
81
|
handle.addEventListener('lostpointercapture',event=>this.#endGesture(event,false));
|
|
80
82
|
handle.addEventListener('keydown',event=>this.#keyGeometry(event,kind));
|
|
81
83
|
}
|
|
84
|
+
this.titlebar.addEventListener('dblclick',event=>this.#toggleDocked(event));
|
|
85
|
+
// Without the title bar, the top region of the framePane child (content) moves the window.
|
|
86
|
+
if(content) {
|
|
87
|
+
this.host.addEventListener('pointerdown',event=>{
|
|
88
|
+
const handle=this.#frameTopHandle(event);
|
|
89
|
+
if(handle)this.#startGesture(event,'move',handle);
|
|
90
|
+
});
|
|
91
|
+
const frameGesture=()=>this.#gesture&&this.#gesture.handle!==this.titlebar&&this.#gesture.handle!==this.resizeButton;
|
|
92
|
+
this.host.addEventListener('pointermove',event=>{if(frameGesture())this.#moveGesture(event);});
|
|
93
|
+
this.host.addEventListener('pointerup',event=>{if(frameGesture())this.#endGesture(event,true);});
|
|
94
|
+
for(const type of ['pointercancel','lostpointercapture'])this.host.addEventListener(type,event=>{if(frameGesture())this.#endGesture(event,false);});
|
|
95
|
+
this.host.addEventListener('dblclick',event=>{if(this.#frameTopHandle(event))this.#toggleDocked(event);});
|
|
96
|
+
}
|
|
82
97
|
this.#observer=new doc.defaultView.MutationObserver(()=>this.#schedule());
|
|
83
98
|
}
|
|
84
99
|
#button(label,text) { const b=this.ownerDocument.createElement('button');b.type='button';b.textContent=text;b.setAttribute('aria-label',label);b.title=label;return b; }
|
|
85
100
|
get ownerDocument() { return this.host.ownerDocument; }
|
|
86
101
|
get opened() { return this.#open; }
|
|
102
|
+
// Docked presentation applies unless maximized: a maximized docked window fills the viewport as when floating.
|
|
103
|
+
get #docked() { return this.parameters.docked===true&&!this.#maximized; }
|
|
104
|
+
// The window's own title bar is not displayed: docked, or omitted with titlebar=false.
|
|
105
|
+
get #barless() { return this.#docked||this.parameters.titlebar===false; }
|
|
106
|
+
#frameTop() { return this.content?.().querySelector(':scope>[slot="top"]')??null; }
|
|
107
|
+
// The framePane top region moves the window without its own title bar, and while docked (the title bar is hidden).
|
|
108
|
+
#frameTopHandle(event) {
|
|
109
|
+
if(this.parameters.titlebar!==false&&!this.#docked)return null;
|
|
110
|
+
const top=this.#frameTop();if(!top)return null;
|
|
111
|
+
const path=event.composedPath(),index=path.indexOf(top);
|
|
112
|
+
if(index<0)return null;
|
|
113
|
+
const interactive='button,input,select,textarea,a[href],[contenteditable],[role=button],[role=menuitem],[role=menubar],[role=toolbar]';
|
|
114
|
+
return path.slice(0,index+1).some(node=>node.matches?.(interactive))?null:top;
|
|
115
|
+
}
|
|
87
116
|
focus() { this.#raise(); this.closeButton.focus(); }
|
|
88
117
|
setSourceContext(context) { this.#context=context; }
|
|
89
118
|
connect() {
|
|
@@ -104,11 +133,14 @@ export class WindowSurface {
|
|
|
104
133
|
const previous=this.parameters;
|
|
105
134
|
this.parameters=parameters;
|
|
106
135
|
if(previous) {
|
|
107
|
-
|
|
136
|
+
// A geometry value this window wrote itself comes back through Data: it is not a new placement.
|
|
137
|
+
const changed=name=>previous[name]!==this.parameters[name]&&!(this.#written.has(name)&&this.#written.get(name)===this.parameters[name]);
|
|
138
|
+
if(['width','height','left','top','minWidth','minHeight'].some(changed)) {
|
|
108
139
|
this.#cancelGesture();this.#geometry=null;this.#collapsed=false;this.#maximized=false;
|
|
109
140
|
}
|
|
141
|
+
for(const [name,value] of this.#written)if(value!==this.parameters[name])this.#written.delete(name);
|
|
110
142
|
if(previous.open!==this.parameters.open) { this.#generation++;this.#pending=null; }
|
|
111
|
-
if(previous.movable!==this.parameters.movable || previous.resizable!==this.parameters.resizable || previous.docked!==this.parameters.docked)this.#cancelGesture();
|
|
143
|
+
if(previous.movable!==this.parameters.movable || previous.resizable!==this.parameters.resizable || previous.docked!==this.parameters.docked || previous.titlebar!==this.parameters.titlebar)this.#cancelGesture();
|
|
112
144
|
}
|
|
113
145
|
this.#schedule();
|
|
114
146
|
}
|
|
@@ -122,7 +154,9 @@ export class WindowSurface {
|
|
|
122
154
|
this.heading.textContent=p.title;this.shell.setAttribute('aria-label',p.title);
|
|
123
155
|
this.closeButton.hidden=!p.closable;this.closeButton.disabled=Boolean(this.#pending);
|
|
124
156
|
this.collapseButton.hidden=!p.collapsible;this.maximizeButton.hidden=!p.maximizable;
|
|
125
|
-
this.
|
|
157
|
+
this.titlebar.hidden=p.titlebar===false;
|
|
158
|
+
// Before any measurement: an undocked window is measured with its floating size.
|
|
159
|
+
this.shell.toggleAttribute('data-docked',this.#docked);
|
|
126
160
|
if(!p.open) { this.#close(false);return; }
|
|
127
161
|
if(!this.#open) {
|
|
128
162
|
this.#previousFocus=this.#activeElement();
|
|
@@ -131,7 +165,6 @@ export class WindowSurface {
|
|
|
131
165
|
this.#open=true;if(!p.docked){this.#applySize();this.#fit();this.#raise();}
|
|
132
166
|
this.#context.publish('opened',{});
|
|
133
167
|
} else if(!p.docked && !this.#geometry) { this.#applySize();this.#fit(); }
|
|
134
|
-
if(p.docked) { this.body.hidden=false;this.resizeButton.hidden=true;return; }
|
|
135
168
|
this.#setMaximized(p.maximizable&&p.maximized,false);
|
|
136
169
|
this.#setCollapsed(p.collapsible&&p.collapsed,false);
|
|
137
170
|
if(!p.maximizable && p.maximized)this.#context.writeParameter('maximized',false);
|
|
@@ -153,6 +186,7 @@ export class WindowSurface {
|
|
|
153
186
|
}
|
|
154
187
|
}
|
|
155
188
|
#fit() {
|
|
189
|
+
if(this.#docked)return;
|
|
156
190
|
if(this.#maximized){this.#renderGeometry();return;}
|
|
157
191
|
const r=this.shell.getBoundingClientRect(),w=this.ownerDocument.defaultView;
|
|
158
192
|
const width=Math.min(r.width,Math.max(0,w.document.documentElement.clientWidth-16)),height=Math.min(r.height,Math.max(0,w.document.documentElement.clientHeight-16));
|
|
@@ -162,7 +196,7 @@ export class WindowSurface {
|
|
|
162
196
|
}
|
|
163
197
|
#paint(rect) { for(const key of ['left','top','width','height'])this.shell.style[key]=`${rect[key]}px`; }
|
|
164
198
|
#raise() {
|
|
165
|
-
if(this.modal||!this.#open||this
|
|
199
|
+
if(this.modal||!this.#open||this.#docked)return;
|
|
166
200
|
// Reserve the page's low stacking levels for layout chrome (splitters/drawers).
|
|
167
201
|
// Modal dialogs and menu popovers remain above these nonmodal windows in the top layer.
|
|
168
202
|
const base=100;
|
|
@@ -171,11 +205,28 @@ export class WindowSurface {
|
|
|
171
205
|
this.shell.style.zIndex=String(base+peers.length);
|
|
172
206
|
}
|
|
173
207
|
// #geometry always holds the normal expanded rectangle, never viewport size.
|
|
208
|
+
// Collapsed without its own title bar, the window keeps only the framePane top region.
|
|
174
209
|
#renderGeometry() {
|
|
210
|
+
const docked=this.#docked,barless=this.#barless;
|
|
211
|
+
this.shell.toggleAttribute('data-docked',docked);
|
|
212
|
+
this.shell.toggleAttribute('data-maximized',this.#maximized);
|
|
213
|
+
this.body.hidden=this.#collapsed&&!barless;
|
|
214
|
+
const collapsedHeight=barless?(this.#frameTop()?.getBoundingClientRect().height??0):this.titlebar.getBoundingClientRect().height;
|
|
215
|
+
if(docked) {
|
|
216
|
+
if(this.#collapsed)this.shell.style.setProperty('--collapsed-height',`${collapsedHeight}px`);
|
|
217
|
+
else this.shell.style.removeProperty('--collapsed-height');
|
|
218
|
+
this.titlebar.removeAttribute('data-movable');this.titlebar.tabIndex=-1;this.resizeButton.hidden=true;
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
this.shell.style.removeProperty('--collapsed-height');
|
|
222
|
+
if(!this.#maximized&&!this.#geometry) {
|
|
223
|
+
// First floating presentation of a window opened docked.
|
|
224
|
+
this.#applySize();const r=this.shell.getBoundingClientRect();
|
|
225
|
+
this.#geometry={left:r.left,top:r.top,width:r.width,height:r.height};
|
|
226
|
+
}
|
|
175
227
|
const viewport=this.ownerDocument.documentElement;
|
|
176
228
|
const rect=this.#maximized?{left:0,top:0,width:viewport.clientWidth,height:viewport.clientHeight}:{...this.#geometry};
|
|
177
|
-
if(this.#collapsed)rect.height=
|
|
178
|
-
this.shell.toggleAttribute('data-maximized',this.#maximized);
|
|
229
|
+
if(this.#collapsed)rect.height=collapsedHeight+2;
|
|
179
230
|
this.shell.style.minWidth=this.#maximized?'0':this.parameters.minWidth??'min(220px, calc(100vw - 16px))';
|
|
180
231
|
this.shell.style.minHeight=this.#collapsed||this.#maximized?'0':this.parameters.minHeight??'min(140px, calc(100dvh - 16px))';
|
|
181
232
|
this.#paint(rect);
|
|
@@ -186,7 +237,7 @@ export class WindowSurface {
|
|
|
186
237
|
}
|
|
187
238
|
#setMaximized(value,write) {
|
|
188
239
|
if(!this.#open)return;
|
|
189
|
-
if(value!==this.#maximized){this.#cancelGesture();this.#maximized=value;}
|
|
240
|
+
if(value!==this.#maximized){this.#cancelGesture();this.#maximized=value;if(value)this.#raise();}
|
|
190
241
|
this.#renderGeometry();
|
|
191
242
|
if(!value)this.#fit();
|
|
192
243
|
this.maximizeButton.textContent=value?'❐':'□';
|
|
@@ -202,7 +253,6 @@ export class WindowSurface {
|
|
|
202
253
|
if(value && this.body.contains(this.#activeElement()))this.collapseButton.focus();
|
|
203
254
|
this.#collapsed=value;
|
|
204
255
|
}
|
|
205
|
-
this.body.hidden=value;
|
|
206
256
|
this.shell.toggleAttribute('data-collapsed',value);this.collapseButton.textContent=value?'+':'−';
|
|
207
257
|
this.collapseButton.setAttribute('aria-label',value?'Expand window':'Collapse window');
|
|
208
258
|
this.collapseButton.title=value?'Expand window':'Collapse window';
|
|
@@ -238,16 +288,26 @@ export class WindowSurface {
|
|
|
238
288
|
if(write){this.parameters.open=false;this.#context.writeParameter('open',false);}
|
|
239
289
|
this.#context.publish('closed',{});
|
|
240
290
|
}
|
|
241
|
-
#startGesture(event,kind) {
|
|
291
|
+
#startGesture(event,kind,handle=event.currentTarget) {
|
|
292
|
+
if(kind==='move'&&this.#detachable&&this.#docked&&event.button===0&&this.#open) {
|
|
293
|
+
// A docked detachable window: the move becomes a detach once the pointer passes DETACH_DISTANCE.
|
|
294
|
+
event.preventDefault();this.#cancelGesture();
|
|
295
|
+
this.#gesture={kind:'detach',id:event.pointerId,handle,x:event.clientX,y:event.clientY,rect:null};
|
|
296
|
+
handle.setPointerCapture(event.pointerId);return;
|
|
297
|
+
}
|
|
242
298
|
if(event.button!==0||!this.#open||this.parameters.docked||this.#maximized||kind==='move'&&!this.parameters.movable||kind==='resize'&&(!this.parameters.resizable||this.#collapsed))return;
|
|
243
299
|
if(kind==='move'&&event.target.closest('button'))return;
|
|
244
300
|
event.preventDefault();this.#cancelGesture();
|
|
245
301
|
const r=this.shell.getBoundingClientRect();
|
|
246
|
-
this.#gesture={kind,id:event.pointerId,handle
|
|
247
|
-
|
|
302
|
+
this.#gesture={kind,id:event.pointerId,handle,x:event.clientX,y:event.clientY,rect:{left:r.left,top:r.top,width:r.width,height:r.height}};
|
|
303
|
+
handle.setPointerCapture(event.pointerId);if(handle===event.currentTarget)handle.focus();
|
|
248
304
|
}
|
|
249
305
|
#moveGesture(event) {
|
|
250
306
|
const g=this.#gesture;if(!g||g.id!==event.pointerId)return;
|
|
307
|
+
if(g.kind==='detach') {
|
|
308
|
+
if(Math.hypot(event.clientX-g.x,event.clientY-g.y)<DETACH_DISTANCE)return;
|
|
309
|
+
this.#detachUnder(g,event);
|
|
310
|
+
}
|
|
251
311
|
this.#adjust(g.rect,event.clientX-g.x,event.clientY-g.y,g.kind);
|
|
252
312
|
}
|
|
253
313
|
#adjust(start,dx,dy,kind) {
|
|
@@ -267,13 +327,57 @@ export class WindowSurface {
|
|
|
267
327
|
#endGesture(event,commit) {
|
|
268
328
|
const g=this.#gesture;if(!g||g.id!==event.pointerId)return;
|
|
269
329
|
this.#gesture=null;if(g.handle.hasPointerCapture(g.id))g.handle.releasePointerCapture(g.id);
|
|
330
|
+
if(g.kind==='detach')return;
|
|
270
331
|
if(commit)this.#commitGeometry(g.kind);else {this.#paint(g.rect);if(!this.#collapsed)this.#geometry=g.rect;else this.#geometry={...this.#geometry,left:g.rect.left,top:g.rect.top,width:g.rect.width};}
|
|
271
332
|
}
|
|
272
333
|
#cancelGesture() { if(this.#gesture)this.#endGesture({pointerId:this.#gesture.id},false); }
|
|
334
|
+
get #detachable() { return this.parameters.detachable===true; }
|
|
335
|
+
/**
|
|
336
|
+
* Undock under the pointer, keeping the docked size and the grab point inside the window, then go on as a move:
|
|
337
|
+
* the window follows the pointer as a tab pulled out of a browser strip.
|
|
338
|
+
*/
|
|
339
|
+
#detachUnder(g,event) {
|
|
340
|
+
const r=this.#dockedRect();
|
|
341
|
+
const offsetX=Math.min(Math.max(0,g.x-r.left),r.width),offsetY=Math.min(Math.max(0,g.y-r.top),r.height);
|
|
342
|
+
this.#geometry={...r,left:event.clientX-offsetX,top:event.clientY-offsetY};
|
|
343
|
+
this.#writeDocked(false);
|
|
344
|
+
const s=this.shell.getBoundingClientRect();
|
|
345
|
+
Object.assign(g,{kind:'move',x:event.clientX,y:event.clientY,rect:{left:s.left,top:s.top,width:s.width,height:s.height}});
|
|
346
|
+
}
|
|
347
|
+
/** Double click on the move handle of a detachable window: dock a floating window, detach a docked one in place. */
|
|
348
|
+
#toggleDocked(event) {
|
|
349
|
+
if(!this.#detachable||!this.#open||event.target.closest?.('button'))return;
|
|
350
|
+
event.preventDefault();this.#cancelGesture();
|
|
351
|
+
if(this.parameters.docked===true&&!this.#maximized) {
|
|
352
|
+
if(!this.#geometry)this.#geometry=this.#dockedRect();
|
|
353
|
+
this.#writeDocked(false);
|
|
354
|
+
} else {
|
|
355
|
+
if(this.#maximized)this.#setMaximized(false,true);
|
|
356
|
+
this.#writeDocked(true);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
// The rectangle of the docked window as its floating geometry; collapsed, the expanded height is not on screen.
|
|
360
|
+
#dockedRect() {
|
|
361
|
+
const r=this.shell.getBoundingClientRect();
|
|
362
|
+
const height=this.#collapsed?this.#geometry?.height??Math.max(r.width*9/16,140):r.height;
|
|
363
|
+
return {left:r.left,top:r.top,width:r.width,height};
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* The local parameter changes first: the projection of the written value then finds nothing to cancel.
|
|
367
|
+
* Undocking also writes the floating size.
|
|
368
|
+
*/
|
|
369
|
+
#writeDocked(value) {
|
|
370
|
+
this.parameters.docked=value;
|
|
371
|
+
this.#renderGeometry();
|
|
372
|
+
if(!value){this.#fit();this.#raise();}
|
|
373
|
+
this.#context.writeParameter('docked',value);
|
|
374
|
+
if(!value)for(const name of ['width','height'])this.#writeGeometry(name,`${this.#geometry[name]}px`);
|
|
375
|
+
}
|
|
376
|
+
#writeGeometry(name,value) { this.#written.set(name,value);this.#context.writeParameter(name,value); }
|
|
273
377
|
#commitGeometry(kind) {
|
|
274
378
|
const r=this.shell.getBoundingClientRect();
|
|
275
379
|
for(const key of kind==='move'?['left','top']:['width','height']) {
|
|
276
|
-
|
|
380
|
+
this.#writeGeometry(key,`${r[key]}px`);
|
|
277
381
|
}
|
|
278
382
|
}
|
|
279
383
|
#keyGeometry(event,kind) {
|
|
@@ -18,7 +18,8 @@ function WindowShell(HTMLElement) {
|
|
|
18
18
|
if (this.children.length !== 1 || labelboxContent(this.firstElementChild).localName !== 'gramlot-frame-pane') {
|
|
19
19
|
throw new TypeError('A window requires exactly one framePane child');
|
|
20
20
|
}
|
|
21
|
-
}
|
|
21
|
+
},
|
|
22
|
+
content:() => labelboxContent(this.firstElementChild)});
|
|
22
23
|
}
|
|
23
24
|
get shell() { return this.surface.shell; }
|
|
24
25
|
get titlebar() { return this.surface.titlebar; }
|
|
@@ -52,4 +53,4 @@ WindowShell.parameters={
|
|
|
52
53
|
};
|
|
53
54
|
export const Dialog=defineComponent({name:'dialog',tag:'gramlot-dialog',base:WindowShell,sourceContext:true,subTags:'framePane',implementation:Base=>class extends Base{}});
|
|
54
55
|
export const FloatingPane=defineComponent({name:'floatingPane',tag:'gramlot-floating-pane',base:WindowShell,sourceContext:true,subTags:'framePane',
|
|
55
|
-
parameters:{movable:bool(true),resizable:bool(true),collapsible:bool(true),docked:bool(false)},implementation:Base=>class extends Base{}});
|
|
56
|
+
parameters:{movable:bool(true),resizable:bool(true),collapsible:bool(true),docked:bool(false,'twoWay'),titlebar:bool(true),detachable:bool(false)},implementation:Base=>class extends Base{}});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/** Isolated local HTTP experiment; ordinary RpcHandler/HttpTransport stay unchanged. */
|
|
2
|
-
import {
|
|
2
|
+
import {toTytx, fromTytxIter} from '@genrojs/tytx';
|
|
3
|
+
import {Bag} from '@genrojs/bag';
|
|
3
4
|
|
|
4
5
|
export async function* jsonLines(body, metrics, now = () => performance.now()) {
|
|
5
6
|
const reader = body.getReader(), decoder = new TextDecoder('utf-8', {fatal:true});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Source-bound JSONL loader for the local resident-selection examples. */
|
|
2
|
-
import {Bag} from '@
|
|
2
|
+
import {Bag} from '@genrojs/bag';
|
|
3
3
|
import {defineComponent, ComponentCollection} from '../components/registry.js';
|
|
4
4
|
import {Container} from '../components/container.js';
|
|
5
5
|
import {WindowSelection} from './window-selection.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Experimental coordinator for bounded windows delivered by a PageStore. */
|
|
2
|
-
import {Bag} from '@
|
|
2
|
+
import {Bag} from '@genrojs/bag';
|
|
3
3
|
import {defineComponent} from '../components/registry.js';
|
|
4
4
|
import {Container} from '../components/container.js';
|
|
5
5
|
|
|
@@ -33,6 +33,9 @@ export class SourceHandler extends Handler {
|
|
|
33
33
|
*/
|
|
34
34
|
constructor(gramlot: Gramlot, options: {collections: unknown[]; destination: DomElement | null; subscriptions: unknown;
|
|
35
35
|
nameSyntax: NameSyntax});
|
|
36
|
+
/** The builder of a page: the prepared grammar of the standard collections in one step when `collections`
|
|
37
|
+
* start with them in its order, then the other collections one by one (GC-325 §165). */
|
|
38
|
+
static pageBuilder(collections: unknown[], nameSyntax: NameSyntax | undefined): GramlotBuilder;
|
|
36
39
|
/** Start from an embedded typed Source, with the same observed insertion as `main`. */
|
|
37
40
|
startSource(wire: SourceBag | string): Gramlot;
|
|
38
41
|
/** Validate and insert `main` in the Source. */
|
|
@@ -12,6 +12,8 @@ import {GramlotBuilderBag} from '../builder/source.js';
|
|
|
12
12
|
import {GramlotRenderer} from '../renderer/gramlot-renderer.js';
|
|
13
13
|
import {BindingRuntime} from '../binding/runtime.js';
|
|
14
14
|
import {LogicRegistry} from '../binding/logic.js';
|
|
15
|
+
import {bundledCollections} from '../bundled-collections.js';
|
|
16
|
+
import {standardGrammar} from '../../dist/standard-grammar.js';
|
|
15
17
|
|
|
16
18
|
/**
|
|
17
19
|
* The Source and every change of it. The construction order is the one of source plan §4.3: the Data
|
|
@@ -24,13 +26,28 @@ export class SourceHandler extends Handler {
|
|
|
24
26
|
// The BindingRuntime reaches the builder through gramlot.src while it attaches.
|
|
25
27
|
gramlot.src = this;
|
|
26
28
|
this.logicRegistry = new LogicRegistry(gramlot);
|
|
27
|
-
this.builder =
|
|
29
|
+
this.builder = SourceHandler.pageBuilder(collections, nameSyntax);
|
|
28
30
|
this.binding = new BindingRuntime(gramlot, {subscriptions});
|
|
29
31
|
this.builder.binding = this.binding;
|
|
30
32
|
this.binding.attach();
|
|
31
33
|
this.source = this.builder.source;
|
|
32
34
|
this.renderer = new GramlotRenderer(this.builder, this.source, destination, {binding: this.binding});
|
|
33
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* The builder of the page. When the collections start with the standard collections in the order of the
|
|
38
|
+
* prepared grammar (`dist/standard-grammar.js`, written by the build), the builder loads that grammar in one
|
|
39
|
+
* step and composes only the collections after them; otherwise it composes each collection (GC-325 §165).
|
|
40
|
+
*/
|
|
41
|
+
static pageBuilder(collections, nameSyntax) {
|
|
42
|
+
const prepared = standardGrammar?.collections ?? [];
|
|
43
|
+
const bundled = new Map(bundledCollections.map(collection => [collection.name, collection]));
|
|
44
|
+
const standard = prepared.length > 0 && prepared.every((name, index) => collections[index] === bundled.get(name));
|
|
45
|
+
if (!standard) return new GramlotBuilder(null, {collections, nameSyntax});
|
|
46
|
+
const builder = new GramlotBuilder(null, {nameSyntax});
|
|
47
|
+
builder.loadGrammar(standardGrammar.document, {replace: true});
|
|
48
|
+
for (const collection of collections.slice(prepared.length)) builder.loadCollection(collection);
|
|
49
|
+
return builder;
|
|
50
|
+
}
|
|
34
51
|
/** Start from an embedded typed Source using the same observed insertion as main. */
|
|
35
52
|
startSource(wire) {
|
|
36
53
|
if (!['ready', 'failed'].includes(this.gramlot.state)) {
|