@gramlot/gramlot 0.3.27 → 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.
- package/assets/icons/chart.svg +1 -0
- package/dist/components/audio/__init__.py +13 -0
- package/dist/components/audio/assets/collection.js +3 -0
- package/dist/components/audio/assets/index.js +3 -0
- package/dist/components/audio/commands.json +7 -0
- package/dist/components/audio/grammar.json +335 -0
- package/dist/components/charts/__init__.py +13 -0
- package/dist/components/charts/assets/collection.js +47 -0
- package/dist/components/charts/assets/files/55ea01207028f76d844678511f29fc800f8a1e67a8a0fe80470128677847ad32-echarts-gl.txt +29 -0
- package/dist/components/charts/assets/files/63727832aaf62004a2b249c933e327f3c90caf49e41a72f4bf436edf632cbda8-vega.txt +27 -0
- package/dist/components/charts/assets/files/8c45d9eaf50c2f72dd9c7ab9ef440788ba58a3538484b5c51c1f17d5128752e7-plotly.txt +21 -0
- package/dist/components/charts/assets/files/8f989229699b4fe2f1a0432d0e9edc338a8a911e250e2d1b01ecd770a5f5b1bd-uplot.txt +21 -0
- package/dist/components/charts/assets/files/c8fa058cba98f7f288b5d8fa4116f441d6dacb25b96da859e518c973fff41d0c-claygl.txt +23 -0
- package/dist/components/charts/assets/index.js +3 -0
- package/dist/components/charts/assets/modules/chunk-2CCTLZE7.js +76 -0
- package/dist/components/charts/assets/modules/chunk-RMRBEYTI.js +1 -0
- package/dist/components/charts/assets/modules/echarts-gl-CXVTZA6G.js +4409 -0
- package/dist/components/charts/assets/modules/plotly.min-4LB7HE7P.js +3596 -0
- package/dist/components/charts/assets/modules/uPlot.esm-5JJNHHRF.js +3 -0
- package/dist/components/charts/assets/modules/uPlot.min-N3E3FA74.js +1 -0
- package/dist/components/charts/assets/modules/vega.module-2QCOVQ3A.js +13 -0
- package/dist/components/charts/commands.json +7 -0
- package/dist/components/charts/grammar.json +1113 -0
- package/dist/components/chat/__init__.py +1 -1
- package/dist/components/chat/assets/collection.js +3 -3
- package/dist/components/chat/assets/index.js +1 -1
- package/dist/components/drawing/__init__.py +15 -0
- package/dist/components/drawing/assets/collection.js +28 -0
- package/dist/components/drawing/assets/index.js +3 -0
- package/dist/components/drawing/commands.json +7 -0
- package/dist/components/drawing/grammar.json +110 -0
- package/dist/components/editors/__init__.py +2 -2
- package/dist/components/editors/assets/collection.js +18 -18
- package/dist/components/editors/assets/index.js +1 -1
- package/dist/components/editors/assets/modules/{prose-mirror-engine-GMZPJPNN.js → prose-mirror-engine-DQEAEIMV.js} +2 -2
- package/dist/components/editors/grammar.json +150 -0
- package/dist/components/grid/__init__.py +1 -1
- package/dist/components/grid/assets/collection.js +51 -30
- package/dist/components/grid/assets/index.js +1 -1
- package/dist/components/grid/grammar.json +258 -0
- package/dist/components/grouplets/__init__.py +1 -1
- package/dist/components/grouplets/assets/collection.js +3 -3
- package/dist/components/grouplets/assets/index.js +1 -1
- package/dist/components/inputs/__init__.py +3 -2
- package/dist/components/inputs/assets/collection.js +38 -23
- package/dist/components/inputs/assets/index.js +1 -1
- package/dist/components/inputs/grammar.json +1533 -321
- package/dist/components/layout/__init__.py +1 -1
- package/dist/components/layout/assets/collection.js +27 -23
- package/dist/components/layout/assets/index.js +1 -1
- package/dist/components/layout/grammar.json +85 -0
- package/dist/components/selection_trial/__init__.py +1 -1
- package/dist/components/selection_trial/assets/collection.js +3 -3
- 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 +11 -11
- package/dist/components/tree/assets/index.js +1 -1
- package/dist/components/tree/grammar.json +126 -0
- package/dist/components/typst/__init__.py +1 -1
- package/dist/components/typst/assets/collection.js +2 -2
- package/dist/components/typst/assets/index.js +1 -1
- package/dist/components/uploads/__init__.py +1 -1
- package/dist/components/uploads/assets/collection.js +8 -8
- package/dist/components/uploads/assets/index.js +1 -1
- package/dist/components/vizabi/__init__.py +13 -0
- package/dist/components/vizabi/assets/collection.js +22 -0
- package/dist/components/vizabi/assets/index.js +3 -0
- package/dist/components/vizabi/commands.json +7 -0
- package/dist/components/vizabi/grammar.json +128 -0
- package/dist/gramlot.js +572 -176
- package/dist/gramlot.min.js +85 -53
- package/dist/standard-collections.js +2 -0
- package/package.json +12 -4
- package/src/binding/grid-struct.js +2 -2
- package/src/binding/runtime.js +10 -0
- package/src/bootstrap.js +1 -1
- package/src/builder/gramlot-builder.d.ts +15 -2
- package/src/builder/gramlot-builder.js +22 -3
- package/src/builder/source.js +24 -1
- package/src/components/audio-analysis-session.js +65 -0
- package/src/components/audio.js +44 -0
- package/src/components/bases.js +6 -4
- package/src/components/border-container.js +6 -3
- package/src/components/buttons.js +47 -3
- package/src/components/chart-bar3d-options.js +30 -0
- package/src/components/chart-controls.js +83 -0
- package/src/components/chart-data-view.js +52 -0
- package/src/components/chart-data.js +42 -0
- package/src/components/chart-domains.js +46 -0
- package/src/components/chart-engines/echarts-options.js +50 -0
- package/src/components/chart-engines/echarts.js +82 -0
- package/src/components/chart-engines/index.js +22 -0
- package/src/components/chart-engines/plotly-map.js +34 -0
- package/src/components/chart-engines/plotly-spatial.js +35 -0
- package/src/components/chart-engines/plotly.js +138 -0
- package/src/components/chart-engines/uplot.js +57 -0
- package/src/components/chart-engines/vega.js +101 -0
- package/src/components/chart-fields.js +110 -0
- package/src/components/chart-geographic-options.js +47 -0
- package/src/components/chart-geojson.js +60 -0
- package/src/components/chart-geometry.js +11 -0
- package/src/components/chart-map-anchors.js +24 -0
- package/src/components/chart-map-bar3d-options.js +41 -0
- package/src/components/chart-map-data.js +25 -0
- package/src/components/chart-map-labels.js +8 -0
- package/src/components/chart-map-options.js +20 -0
- package/src/components/chart-pane.js +91 -0
- package/src/components/chart-renderer.js +58 -0
- package/src/components/chart-sample-view.js +32 -0
- package/src/components/chart-spatial-options.js +40 -0
- package/src/components/chart-time.js +84 -0
- package/src/components/chart-timeline.js +70 -0
- package/src/components/chart-types/area.js +2 -0
- package/src/components/chart-types/bar.js +2 -0
- package/src/components/chart-types/bar3D.js +2 -0
- package/src/components/chart-types/donut.js +2 -0
- package/src/components/chart-types/horizontalBar.js +2 -0
- package/src/components/chart-types/index.js +26 -0
- package/src/components/chart-types/line.js +2 -0
- package/src/components/chart-types/line3D.js +2 -0
- package/src/components/chart-types/lines3D.js +2 -0
- package/src/components/chart-types/map.js +2 -0
- package/src/components/chart-types/map3D.js +2 -0
- package/src/components/chart-types/mapBar3D.js +2 -0
- package/src/components/chart-types/pie.js +2 -0
- package/src/components/chart-types/polygons3D.js +2 -0
- package/src/components/chart-types/scatter.js +2 -0
- package/src/components/chart-types/scatter3D.js +2 -0
- package/src/components/chart-types/stackedArea.js +2 -0
- package/src/components/chart-types/stackedBar.js +2 -0
- package/src/components/chart-types/surface.js +2 -0
- package/src/components/charts.js +152 -0
- package/src/components/check-box-text-editor.js +88 -0
- package/src/components/check-box-text.js +193 -0
- package/src/components/check-box-tree.js +62 -0
- package/src/components/choice-editor.js +7 -5
- package/src/components/choice-field-styles.js +14 -0
- package/src/components/choices.js +5 -0
- package/src/components/drawing.js +199 -0
- package/src/components/grid-check-sets.js +98 -0
- package/src/components/grid-column-filters.js +198 -0
- package/src/components/grid-grammar.json +44 -0
- package/src/components/grid-header-interaction.js +3 -1
- package/src/components/grid-rows.js +2 -2
- package/src/components/grid-search-box.js +38 -22
- package/src/components/grid-search-styles.js +13 -14
- package/src/components/grid-search.js +8 -1
- package/src/components/grid-structure.js +10 -2
- package/src/components/grid-styles.js +23 -0
- package/src/components/grid.js +52 -10
- package/src/components/image-uploader.js +2 -2
- package/src/components/inputs.js +19 -10
- package/src/components/labelbox.js +5 -1
- package/src/components/licenses/claygl.txt +23 -0
- package/src/components/licenses/echarts-gl.txt +29 -0
- package/src/components/licenses/plotly.txt +21 -0
- package/src/components/licenses/uplot.txt +21 -0
- package/src/components/licenses/vega.txt +27 -0
- package/src/components/menus.js +19 -11
- package/src/components/toolbar-overflow.js +12 -8
- package/src/components/tree.js +30 -8
- package/src/components/typed-editor.js +14 -3
- package/src/components/vizabi-session.js +66 -0
- package/src/components/vizabi.js +66 -0
- package/src/components/window-surface.js +20 -9
- package/src/components/windows.js +1 -1
- package/src/gramlot.d.ts +1 -0
- package/src/gramlot.js +2 -0
- package/src/handlers/device-handler.js +32 -32
- package/src/handlers/source-handler.d.ts +2 -2
- package/src/ide-documents.js +19 -3
- package/src/ide-runtime.d.ts +1 -0
- package/src/ide-runtime.js +45 -31
- package/src/index.d.ts +1 -0
- package/src/renderer/drag-drop.js +1 -0
- package/src/renderer/gramlot-renderer.d.ts +2 -0
- package/src/renderer/gramlot-renderer.js +5 -4
- package/src/server/assets.d.ts +3 -0
- package/src/server/assets.js +9 -0
- package/src/server/gramlot-server.d.ts +1 -1
- package/src/server/gramlot-server.js +2 -1
- package/src/server/index.d.ts +1 -1
- package/src/server/index.js +1 -1
- package/src/server/visual-editor.js +17 -17
- package/src/stores/bag-collection-view.js +79 -17
- package/src/stores/collection-filter.js +2 -1
- package/src/stores/column-filter.js +49 -0
- package/src/stores/id-set.js +10 -0
- package/src/view/controls.js +8 -0
- package/src/view/html.js +10 -1
- package/src/view/label-menu.js +61 -0
- package/src/view/labelbox.js +15 -2
- package/themes/gramlot-base/theme.css +6 -0
- package/tools/gramlot-tools-inspector.js +169 -505
package/src/components/grid.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {GridColumnFilters} from './grid-column-filters.js';
|
|
1
2
|
import {Bag} from '@gramlot/gramlot';
|
|
2
3
|
import {SVG_NS} from '../renderer/attributes.js';
|
|
3
4
|
import {defineComponent, ComponentCollection} from './registry.js';
|
|
@@ -5,6 +6,7 @@ import {Container} from './container.js';
|
|
|
5
6
|
import {parseSort} from '../stores/bag-collection-view.js';
|
|
6
7
|
import inputs from './inputs.js';
|
|
7
8
|
import {GridCellEditor} from './grid-cell-editor.js';
|
|
9
|
+
import {GridCheckSets} from './grid-check-sets.js';
|
|
8
10
|
import {GridRows} from './grid-rows.js';
|
|
9
11
|
import {GridStructure} from './grid-structure.js';
|
|
10
12
|
import {GridHeaderInteraction} from './grid-header-interaction.js';
|
|
@@ -18,7 +20,7 @@ import structureGrammar from './grid-grammar.json' with {type: 'json'};
|
|
|
18
20
|
/** First grid: explicit Bag row representation and a separately observable Data struct. */
|
|
19
21
|
export const Grid = defineComponent({
|
|
20
22
|
name: 'grid', tag: 'gramlot-grid', base: Container, bagStore: true, bagStruct: true, sourceContext: true, subTags: 'struct,div',
|
|
21
|
-
parameters: {windowInfo: {dtype:'X', nullable:true, default:null, binding:'read'},
|
|
23
|
+
parameters: {columnFilters: {dtype:'B', default:false, binding:'read'}, setFilter: {dtype:'T', default:'', binding:'read'}, windowInfo: {dtype:'X', nullable:true, default:null, binding:'read'},
|
|
22
24
|
loading: {dtype:'B', default:false, binding:'read'},
|
|
23
25
|
viewport: {dtype:'X', nullable:true, default:null, binding:'write'},
|
|
24
26
|
sortRequest: {dtype:'T', default:'', binding:'write'},
|
|
@@ -30,6 +32,8 @@ export const Grid = defineComponent({
|
|
|
30
32
|
filter: {annotation:{kind:'type',module:'builtins',name:'dict'}, nullable:true, default:null, binding:'read'}},
|
|
31
33
|
implementation: Base => class extends Base {
|
|
32
34
|
#store;
|
|
35
|
+
#checkSets;
|
|
36
|
+
#columnFilters;
|
|
33
37
|
#cellEditor;
|
|
34
38
|
#editCell = event => {
|
|
35
39
|
if (event.type === 'keydown' && !['Enter','F2'].includes(event.key)) return;
|
|
@@ -145,6 +149,7 @@ export const Grid = defineComponent({
|
|
|
145
149
|
spinner.append(track, arc); this.#loadingStatus.append(spinner);
|
|
146
150
|
bodyFrame.append(this.#bodyViewport, this.#loadingStatus);
|
|
147
151
|
this.control.replaceChildren(headerFrame, bodyFrame); this.shadowRoot.append(style);
|
|
152
|
+
this.#columnFilters = new GridColumnFilters(this, this.#head);
|
|
148
153
|
this.#interaction = new GridHeaderInteraction(this.#head, this.control, () => this.#structure, (field, multiple) => this.#sort(field, multiple),
|
|
149
154
|
() => this.#rowLayout, () => this.#scheduleLayout());
|
|
150
155
|
this.#rowInteraction = new GridRowInteraction(this.#body, this.control, () => this.#rowLayout, row => {
|
|
@@ -157,6 +162,8 @@ export const Grid = defineComponent({
|
|
|
157
162
|
this.#body.addEventListener('dblclick', this.#editCell);
|
|
158
163
|
this.#body.addEventListener('keydown', this.#editCell);
|
|
159
164
|
this.#cellEditor?.connect();
|
|
165
|
+
this.#checkSets?.connect();
|
|
166
|
+
this.#columnFilters.connect();
|
|
160
167
|
this.#observeStore();
|
|
161
168
|
if (this.#collectionView) this.#invalidate({full:true, rows:[]});
|
|
162
169
|
this.#interaction.connect();
|
|
@@ -171,7 +178,10 @@ export const Grid = defineComponent({
|
|
|
171
178
|
this.#body.removeEventListener('dblclick', this.#editCell);
|
|
172
179
|
this.#body.removeEventListener('keydown', this.#editCell);
|
|
173
180
|
this.#cellEditor?.disconnect();
|
|
181
|
+
this.#checkSets?.disconnect();
|
|
182
|
+
this.#columnFilters.disconnect();
|
|
174
183
|
this.#cancelRefresh();
|
|
184
|
+
gridSearch(this.#context.sourceNode).detach(this.#collectionView);
|
|
175
185
|
this.#collectionView?.disconnect();
|
|
176
186
|
this.#unsubscribeStore?.(); this.#unsubscribeStore = null;
|
|
177
187
|
this.#interaction.disconnect();
|
|
@@ -334,6 +344,13 @@ export const Grid = defineComponent({
|
|
|
334
344
|
}
|
|
335
345
|
setSourceContext(context) {
|
|
336
346
|
this.#context = context;
|
|
347
|
+
this.#columnFilters.setSourceContext(context);
|
|
348
|
+
this.#checkSets = new GridCheckSets(context.sourceNode, this.#body,
|
|
349
|
+
() => this.#structure?.columns ?? [],
|
|
350
|
+
element => [...this.#rows].find(([,tr]) => tr === element)?.[0],
|
|
351
|
+
(node,field) => this.#collectionView.value(node,field),
|
|
352
|
+
() => this.parameters.setFilter, () => this.#collectionView);
|
|
353
|
+
if (this.isConnected) this.#checkSets.connect();
|
|
337
354
|
this.#cellEditor = new GridCellEditor(this, context, (row, field) => this.#rows.get(row)?.querySelector(`td[data-field="${field}"]`), () => ({bag:this.#store, mode:this.parameters.rowMode, window:this.parameters.windowInfo}), () => this.#rows, (row,field,step) => this.#nextEditor(row,field,step), path => this.#focusField(path));
|
|
338
355
|
const node = context.sourceNode;
|
|
339
356
|
if (!Object.hasOwn(node, 'gridRowLayout')) {
|
|
@@ -350,6 +367,8 @@ export const Grid = defineComponent({
|
|
|
350
367
|
setStructBag(bag) { this.#structBag = bag; this.#structureDirty = true; }
|
|
351
368
|
projectAttributes(attrs, adapt) {
|
|
352
369
|
const rest = super.projectAttributes(attrs, adapt);
|
|
370
|
+
if (this.#windowInfo() && (this.parameters.columnFilters || this.#collectionView?.filterContributions.some(([name]) => name.startsWith('column:')))) throw new TypeError('grid columnFilters requires a complete resident store');
|
|
371
|
+
if (this.#windowInfo() && this.parameters.setFilter !== '') throw new TypeError('grid setFilter requires a complete resident store');
|
|
353
372
|
const store = this.#context.collectionView(this.#store, this.parameters.rowMode);
|
|
354
373
|
if (this.#collectionView !== store) {
|
|
355
374
|
this.#cancelRefresh();
|
|
@@ -364,7 +383,7 @@ export const Grid = defineComponent({
|
|
|
364
383
|
const filter = this.parameters.filter;
|
|
365
384
|
const signature = JSON.stringify(filter);
|
|
366
385
|
if (!this.#windowInfo() && this.#requestedFilter !== signature) {
|
|
367
|
-
this.#collectionView.applyFilter(filter === null ? null : {locale:this.#context.locale,timeZone:this.#context.timeZone,...filter});
|
|
386
|
+
this.#collectionView.applyFilter(filter === null ? null : {locale:this.#context.locale,timeZone:this.#context.timeZone,...filter}, 'base');
|
|
368
387
|
this.#requestedFilter = signature;
|
|
369
388
|
}
|
|
370
389
|
this.#invalidate({full:true, rows:[]});
|
|
@@ -407,12 +426,14 @@ export const Grid = defineComponent({
|
|
|
407
426
|
for (const node of nodes) this.#rowLayout.forget(node);
|
|
408
427
|
const rows = new GridRows(this.#collectionView, this.#context.format).read(this.#structure.columns, nodes.filter(node => this.#rows.has(node)));
|
|
409
428
|
this.#rowInteraction.cancel();
|
|
410
|
-
for (const {node, cells} of rows) this.#renderCells(this.#rows.get(node), cells);
|
|
429
|
+
for (const {node, cells} of rows) this.#renderCells(this.#rows.get(node), cells, node);
|
|
411
430
|
this.#scheduleLayout();
|
|
412
431
|
}
|
|
413
432
|
#project() {
|
|
414
433
|
const model = this.#structureDirty ? new GridStructure(this.#structBag) : this.#structure;
|
|
415
434
|
this.#cellEditor.configure(model.columns);
|
|
435
|
+
this.#structure = model;
|
|
436
|
+
this.#checkSets.configure();
|
|
416
437
|
const nodes = this.#collectionView.getRows();
|
|
417
438
|
this.#rowInteraction.cancel(); this.#rowInteraction.cancelDrag();
|
|
418
439
|
this.#rowLayout.retain(this.#store.getNodes());
|
|
@@ -427,16 +448,16 @@ export const Grid = defineComponent({
|
|
|
427
448
|
this.#windowRequest = null;
|
|
428
449
|
}
|
|
429
450
|
this.#windowRevision = info?.revision;
|
|
430
|
-
this.#structure = model;
|
|
431
451
|
this.#structureDirty = false;
|
|
432
|
-
gridSearch(this.#context.sourceNode).update(this.#collectionView, model.columns);
|
|
452
|
+
gridSearch(this.#context.sourceNode).update(this.#collectionView, model.columns.filter(column => !column.check));
|
|
433
453
|
const rowHeaders = this.parameters.rowHeaders || this.parameters.rowResize;
|
|
434
|
-
const signature = JSON.stringify([model.groups, rowHeaders]);
|
|
454
|
+
const signature = JSON.stringify([model.groups, rowHeaders, this.parameters.columnFilters]);
|
|
435
455
|
this.#rowHeaders = rowHeaders;
|
|
436
456
|
if (signature !== this.#signature) {
|
|
437
457
|
this.#renderHeader(model);
|
|
438
458
|
this.#signature = signature;
|
|
439
459
|
}
|
|
460
|
+
this.#columnFilters.update(this.#collectionView, model.columns, this.parameters.columnFilters, this.#context.format);
|
|
440
461
|
this.#renderSort();
|
|
441
462
|
this.#renderWindow(true);
|
|
442
463
|
this.control.setAttribute('aria-colcount', String(model.columns.length + Number(this.#rowHeaders)));
|
|
@@ -444,6 +465,7 @@ export const Grid = defineComponent({
|
|
|
444
465
|
this.#scheduleLayout();
|
|
445
466
|
}
|
|
446
467
|
#sort(field, multiple) {
|
|
468
|
+
if (this.#structure.columns.find(column => column.field === field)?.check) return;
|
|
447
469
|
try {
|
|
448
470
|
const criteria = this.#windowInfo() ? parseSort(this.#windowInfo().sortedBy) : this.#collectionView.criteria;
|
|
449
471
|
const current = criteria.find(item => item.field === field);
|
|
@@ -497,12 +519,14 @@ export const Grid = defineComponent({
|
|
|
497
519
|
const column = model.columns[index];
|
|
498
520
|
cell.dataset.field = column.field;
|
|
499
521
|
cell.draggable = true; cell.tabIndex = 0;
|
|
500
|
-
cell.
|
|
522
|
+
cell.setAttribute('aria-label', column.title ?? column.name);
|
|
523
|
+
cell.title = column.check ? (column.title ?? column.name) + ' · Drag to reorder' : 'Click: ascending / descending · Shift-click: add or reverse this column without changing the others · Numbers show sort priority · Drag to reorder';
|
|
501
524
|
const indicator = doc.createElementNS(SVG_NS, 'svg');
|
|
502
525
|
indicator.classList.add('sort-indicator'); indicator.setAttribute('viewBox', '0 0 16 16');
|
|
503
526
|
indicator.setAttribute('aria-hidden', 'true');
|
|
504
527
|
const arrow = doc.createElementNS(SVG_NS, 'path');
|
|
505
528
|
arrow.setAttribute('d', 'M4 10L8 6L12 10'); indicator.append(arrow); cell.append(indicator);
|
|
529
|
+
if (this.parameters.columnFilters && !column.check) cell.append(this.#columnFilters.button(column));
|
|
506
530
|
const handle = doc.createElement('span');
|
|
507
531
|
handle.className = 'column-resize'; handle.tabIndex = 0;
|
|
508
532
|
handle.setAttribute('role', 'separator');
|
|
@@ -639,7 +663,7 @@ export const Grid = defineComponent({
|
|
|
639
663
|
}
|
|
640
664
|
for (const td of existing.values()) td.remove();
|
|
641
665
|
tr.setAttribute('aria-rowindex', String(this.#headerRows + start + keep.size + 1));
|
|
642
|
-
this.#renderCells(tr, cells);
|
|
666
|
+
this.#renderCells(tr, cells, node);
|
|
643
667
|
this.#cellEditor.decorate(tr, node);
|
|
644
668
|
const next = previous ? previous.nextSibling : this.#body.firstChild;
|
|
645
669
|
if (next !== tr) this.#body.insertBefore(tr, next);
|
|
@@ -654,11 +678,29 @@ export const Grid = defineComponent({
|
|
|
654
678
|
td.className = 'empty'; td.colSpan = columns.length + Number(this.#rowHeaders); td.textContent = 'No rows'; tr.append(td); this.#body.append(tr);
|
|
655
679
|
}
|
|
656
680
|
}
|
|
657
|
-
#renderCells(row, cells) {
|
|
681
|
+
#renderCells(row, cells, node) {
|
|
658
682
|
const offset = Number(this.#rowHeaders);
|
|
659
683
|
cells.forEach((text, index) => {
|
|
660
684
|
const content = row.cells[index + offset].firstElementChild;
|
|
661
|
-
|
|
685
|
+
const column = this.#structure.columns[index];
|
|
686
|
+
content.parentElement.classList.toggle('check-cell', Boolean(column.check));
|
|
687
|
+
if (column.check) {
|
|
688
|
+
this.#checkSets.project(content,node,column);
|
|
689
|
+
return;
|
|
690
|
+
}
|
|
691
|
+
const color = column.edit?.tag === 'colorpicker';
|
|
692
|
+
if (color) {
|
|
693
|
+
let swatch = content.querySelector('.cell-color-swatch');
|
|
694
|
+
if (!swatch) {
|
|
695
|
+
swatch = this.ownerDocument.createElement('span');
|
|
696
|
+
swatch.className = 'cell-color-swatch'; swatch.setAttribute('role','img');
|
|
697
|
+
content.replaceChildren(swatch);
|
|
698
|
+
}
|
|
699
|
+
swatch.hidden = text === '';
|
|
700
|
+
swatch.style.backgroundColor = text;
|
|
701
|
+
swatch.title = text;
|
|
702
|
+
swatch.setAttribute('aria-label',text);
|
|
703
|
+
} else if (content.firstElementChild || content.textContent !== text) content.textContent = text;
|
|
662
704
|
});
|
|
663
705
|
}
|
|
664
706
|
}
|
|
@@ -101,7 +101,7 @@ export const ImageUploader = defineComponent({
|
|
|
101
101
|
#syncCamera(event = null) {
|
|
102
102
|
const {gramlot} = this.#context.upload();
|
|
103
103
|
const available = Boolean(gramlot.dvc.provider && gramlot.dvc.provider.capabilities.includes('camera'));
|
|
104
|
-
const camera = gramlot.data.getNode('
|
|
104
|
+
const camera = gramlot.data.getNode('_gramlot.device.camera');
|
|
105
105
|
const status = camera?.attr.status;
|
|
106
106
|
if (available !== this.#cameraAvailable || status !== this.#cameraStatus) {
|
|
107
107
|
this.#cameraAvailable = available; this.#cameraStatus = status; this.#render();
|
|
@@ -116,7 +116,7 @@ export const ImageUploader = defineComponent({
|
|
|
116
116
|
#capture() {
|
|
117
117
|
if (!this.#cameraAvailable || this.#cameraStatus === 'pending' || this.parameters.disabled || this.#pending || this.#cameraToken !== null || this.#screenRequest) return;
|
|
118
118
|
this.#cameraToken = ++this.#generation; this.#cameraPending = false;
|
|
119
|
-
try { this.#context.sourceNode.FIRE('
|
|
119
|
+
try { this.#context.sourceNode.FIRE('_gramlot.device.camera?capture'); }
|
|
120
120
|
catch (error) { this.#cameraToken = null; this.message.textContent = `Camera failed: ${error.message}`; this.#render(); }
|
|
121
121
|
}
|
|
122
122
|
#captureScreen() {
|
package/src/components/inputs.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import tree from './tree.js';
|
|
2
|
+
import {checkBoxChoices} from './check-box-text.js';
|
|
1
3
|
import {EditingStatus} from './editing-status.js';
|
|
2
4
|
import {defineComponent, defineCollection} from './registry.js';
|
|
3
5
|
import {NativeControl, ChoiceGroup} from './bases.js';
|
|
@@ -175,6 +177,7 @@ export const DateTextBox = defineComponent({
|
|
|
175
177
|
name: 'dateTextBox', tag: 'gramlot-date-text-box', base: TypedEditor, mixins: [Labelbox, FieldState],
|
|
176
178
|
parameters: {value: {dtype: 'D', nullable: true, binding: 'twoWay'},
|
|
177
179
|
workdate: {dtype: 'T', nullable: true, binding: 'read'},
|
|
180
|
+
period_to: {dtype: 'T', nullable: true},
|
|
178
181
|
calendar: {dtype: 'B', default: true, binding: 'read'}}, implementation: dateEditor
|
|
179
182
|
});
|
|
180
183
|
export const DateCalendar = defineComponent({
|
|
@@ -213,17 +216,23 @@ export const DbComboBox = defineComponent({
|
|
|
213
216
|
}
|
|
214
217
|
});
|
|
215
218
|
export const CheckBoxText = defineComponent({
|
|
216
|
-
name: 'checkBoxText', tag: 'gramlot-check-box-text', base: ChoiceGroup, mixins: [Labelbox, FieldState],
|
|
219
|
+
name: 'checkBoxText', tag: 'gramlot-check-box-text', sourceContext:true, base: ChoiceGroup, mixins: [Labelbox, FieldState],
|
|
217
220
|
parameters: {
|
|
218
221
|
value: {dtype: 'T', nullable: true, binding: 'twoWay'},
|
|
219
|
-
values: {dtype: 'T', binding: 'read'},
|
|
220
|
-
cols: {dtype: 'L', default: 1, binding: 'read'}
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
}
|
|
227
|
-
|
|
222
|
+
values: {dtype: ['T','X'], default: '', binding: 'read'},
|
|
223
|
+
cols: {dtype: 'L', default: 1, binding: 'read'},
|
|
224
|
+
popup: {dtype: 'B', default: false, binding: 'read'},
|
|
225
|
+
hierarchical: {dtype: 'B', default: false, binding: 'read'},
|
|
226
|
+
checkChildren: {dtype: 'B', default: true, binding: 'read'},
|
|
227
|
+
identifier: {dtype: 'T', binding: 'read'},
|
|
228
|
+
labelAttribute: {dtype: 'T', binding: 'read'},
|
|
229
|
+
dbtable: {dtype: 'T', binding: 'read'},
|
|
230
|
+
method: {dtype: 'T', binding: 'read'},
|
|
231
|
+
caption_field: {dtype: 'T', binding: 'read'},
|
|
232
|
+
order_by: {dtype: 'T', binding: 'read'},
|
|
233
|
+
condition: {dtype: 'T', binding: 'read'}
|
|
234
|
+
}, implementation: checkBoxChoices
|
|
235
|
+
});
|
|
236
|
+
export default defineCollection({name: 'inputs', dependencies:[tree], components: [EditingStatus, Textbox, Checkbox, RadioButtonText,
|
|
228
237
|
TextBoxArea, Passwordbox, RadioButton, Colorpicker, HorizontalSlider, VerticalSlider,
|
|
229
238
|
NumberTextBox, DateTextBox, TimeTextBox, FilteringSelect, CallbackSelect, ComboBox, DbSelect, DbComboBox, CheckBoxText, DateCalendar]});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {parseChoices, choiceCaption} from './choices.js';
|
|
1
2
|
import {labelboxPositions} from '../view/labelbox.js';
|
|
2
3
|
|
|
3
4
|
/** Connect a component's shadow control to the renderer-owned Labelbox. */
|
|
@@ -16,7 +17,8 @@ export function Labelbox(Base) {
|
|
|
16
17
|
const rest = super.projectAttributes(attrs, adapt);
|
|
17
18
|
// ID references cannot cross a shadow boundary. Name the actual
|
|
18
19
|
// control in its own tree; the outer label names the presentation.
|
|
19
|
-
const
|
|
20
|
+
const {lbl, lbl_value, lbl_values} = this.parameters;
|
|
21
|
+
const label = lbl_values == null ? lbl ?? '' : choiceCaption(parseChoices(lbl_values), lbl_value, lbl);
|
|
20
22
|
if (label) this.control.setAttribute('aria-label', label);
|
|
21
23
|
else this.control.removeAttribute('aria-label');
|
|
22
24
|
return rest;
|
|
@@ -26,5 +28,7 @@ export function Labelbox(Base) {
|
|
|
26
28
|
Labelbox.labelbox = true;
|
|
27
29
|
Labelbox.parameters = {
|
|
28
30
|
lbl:{dtype:'T',qualification:'intl_str',nullable:true,binding:'read'},
|
|
31
|
+
lbl_value:{dtype:'T',nullable:true,binding:'twoWay'},
|
|
32
|
+
lbl_values:{dtype:'T',nullable:true,binding:'read'},
|
|
29
33
|
lbl_position:{dtype:'T',default:'TL',binding:'read',enum:labelboxPositions}
|
|
30
34
|
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
Copyright (c) 2014, Yi Shen
|
|
2
|
+
All rights reserved.
|
|
3
|
+
|
|
4
|
+
Redistribution and use in source and binary forms, with or without
|
|
5
|
+
modification, are permitted provided that the following conditions are met:
|
|
6
|
+
|
|
7
|
+
* Redistributions of source code must retain the above copyright notice, this
|
|
8
|
+
list of conditions and the following disclaimer.
|
|
9
|
+
|
|
10
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
|
11
|
+
this list of conditions and the following disclaimer in the documentation
|
|
12
|
+
and/or other materials provided with the distribution.
|
|
13
|
+
|
|
14
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
15
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
16
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
17
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
18
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
19
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
20
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
21
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
22
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
23
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017, Baidu Inc.
|
|
4
|
+
All rights reserved.
|
|
5
|
+
|
|
6
|
+
Redistribution and use in source and binary forms, with or without
|
|
7
|
+
modification, are permitted provided that the following conditions are met:
|
|
8
|
+
|
|
9
|
+
* Redistributions of source code must retain the above copyright notice, this
|
|
10
|
+
list of conditions and the following disclaimer.
|
|
11
|
+
|
|
12
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
|
13
|
+
this list of conditions and the following disclaimer in the documentation
|
|
14
|
+
and/or other materials provided with the distribution.
|
|
15
|
+
|
|
16
|
+
* Neither the name of the copyright holder nor the names of its
|
|
17
|
+
contributors may be used to endorse or promote products derived from
|
|
18
|
+
this software without specific prior written permission.
|
|
19
|
+
|
|
20
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
21
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
22
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
23
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
24
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
25
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
26
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
27
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
28
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
29
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2016-2024 Plotly Technologies Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Leon Sorokin
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
Copyright (c) 2015-2023, University of Washington Interactive Data Lab
|
|
2
|
+
All rights reserved.
|
|
3
|
+
|
|
4
|
+
Redistribution and use in source and binary forms, with or without
|
|
5
|
+
modification, are permitted provided that the following conditions are met:
|
|
6
|
+
|
|
7
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
8
|
+
list of conditions and the following disclaimer.
|
|
9
|
+
|
|
10
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
11
|
+
this list of conditions and the following disclaimer in the documentation
|
|
12
|
+
and/or other materials provided with the distribution.
|
|
13
|
+
|
|
14
|
+
3. Neither the name of the copyright holder nor the names of its contributors
|
|
15
|
+
may be used to endorse or promote products derived from this software
|
|
16
|
+
without specific prior written permission.
|
|
17
|
+
|
|
18
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
19
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
20
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
21
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
|
22
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
23
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
24
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
25
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
26
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
27
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/src/components/menus.js
CHANGED
|
@@ -13,9 +13,9 @@ export function MenuContainer(HTMLElement) {
|
|
|
13
13
|
const doc = this.ownerDocument, shadow = this.attachShadow({mode: 'open'});
|
|
14
14
|
const style = doc.createElement('style');
|
|
15
15
|
style.textContent = `:host{box-sizing:border-box;color:var(--gramlot-ink,CanvasText)}
|
|
16
|
-
:host([role=menu]){position:fixed;inset:auto;margin:0;padding:
|
|
16
|
+
:host([role=menu]){position:fixed;inset:auto;margin:0;padding:3px;min-width:0;width:max-content;font:inherit;
|
|
17
17
|
max-width:min(28rem,var(--gramlot-popup-available-width));max-height:var(--gramlot-popup-available-height);overflow:auto;
|
|
18
|
-
background:var(--gramlot-field-background,Canvas);border:1px solid var(--gramlot-border-control,#888);border-radius:var(--gramlot-radius-
|
|
18
|
+
background:var(--gramlot-field-background,Canvas);border:1px solid var(--gramlot-border-control,#888);border-radius:var(--gramlot-radius-sm,5px);box-shadow:0 4px 14px #0003}
|
|
19
19
|
:host([role=toolbar][aria-orientation=vertical]){flex-direction:column;align-items:stretch}
|
|
20
20
|
:host([role=toolbar]){display:flex;gap:var(--gramlot-toolbar-gap,4px);align-items:center}
|
|
21
21
|
:host([role=menu]) ::slotted([role=separator]){margin:5px 7px 5px 2.5rem;border-top:1px solid var(--gramlot-border-control,#888)}
|
|
@@ -39,7 +39,8 @@ export function MenuContainer(HTMLElement) {
|
|
|
39
39
|
get items() { return [...this.querySelectorAll('gramlot-menu-line')].filter(item => item.menuOwner===this && !item.parameters.group); }
|
|
40
40
|
get overflow() { return this.#overflow; }
|
|
41
41
|
isOverflowed(item) { return this.#overflow.contains(item); }
|
|
42
|
-
get
|
|
42
|
+
get visibleItems() { return this.items.filter(item => labelboxPresentation(item).slot!=='suppressed' && !item.hidden && !item.closest('[hidden]') && item.getAttribute('role') !== 'separator'); }
|
|
43
|
+
get usableItems() { return this.visibleItems.filter(item => !item.disabled); }
|
|
43
44
|
get parentMenu() { return this.parentElement?.closest('gramlot-menu') ?? null; }
|
|
44
45
|
connectedCallback() {
|
|
45
46
|
this.#observer = new this.ownerDocument.defaultView.MutationObserver(() => {this.refreshItems();this.#overflow.schedule();});
|
|
@@ -114,6 +115,12 @@ export function MenuContainer(HTMLElement) {
|
|
|
114
115
|
for(const group of this.querySelectorAll('gramlot-menu-line'))if(group.menuOwner===this && group.parameters.group)group.refreshAvailability();
|
|
115
116
|
for(const item of this.items)item.refreshAvailability();
|
|
116
117
|
const usable = this.usableItems;
|
|
118
|
+
// Reserve only the adornments used by this menu; keep captions aligned.
|
|
119
|
+
for (const [part, present, width] of [
|
|
120
|
+
['check', this.visibleItems.some(item => item.parameters.checked != null), '1.4em'],
|
|
121
|
+
['icon', this.visibleItems.some(item => item.entryIcon || item.entryIconSrc), '1.5em'],
|
|
122
|
+
['arrow', this.visibleItems.some(item => item.submenu), '.9em'],
|
|
123
|
+
]) this.style.setProperty(`--gramlot-menu-${part}-track`, present ? width : '0px');
|
|
117
124
|
if (this.#active && !usable.includes(this.#active)) {
|
|
118
125
|
const index = this.#previous.indexOf(this.#active);
|
|
119
126
|
const next = this.#previous.slice(index+1).find(item => usable.includes(item))
|
|
@@ -208,10 +215,10 @@ export function menuLine(Base) {
|
|
|
208
215
|
const style=doc.createElement('style');
|
|
209
216
|
style.textContent=`:host{color:var(--gramlot-ink,CanvasText)} .control-box{color:inherit;height:100%} :host button{color:inherit}
|
|
210
217
|
.menu-check:empty,.menu-arrow:empty{display:none}
|
|
211
|
-
button.menu-row{display:grid;grid-template-columns:
|
|
212
|
-
align-items:center;width:100%;min-height:max(
|
|
218
|
+
button.menu-row{display:grid;grid-template-columns:var(--gramlot-menu-check-track,0px) var(--gramlot-menu-icon-track,0px) minmax(0,1fr) var(--gramlot-menu-arrow-track,0px);column-gap:0;
|
|
219
|
+
align-items:center;width:100%;min-height:max(24px,var(--gramlot-touch-target,0px));padding:2px 7px;
|
|
213
220
|
line-height:1.3;text-align:left;border:0;border-radius:var(--gramlot-radius-sm,5px);background:transparent;cursor:default}
|
|
214
|
-
.menu-row .menu-check,.menu-row .icon,.menu-row .menu-arrow{display:flex;align-items:center;justify-content:
|
|
221
|
+
.menu-row .menu-check,.menu-row .icon,.menu-row .menu-arrow{display:flex;align-items:center;justify-content:start;min-width:0}
|
|
215
222
|
.menu-row .menu-check{grid-column:1}.menu-row .icon{grid-column:2}
|
|
216
223
|
.menu-row .menu-caption{grid-column:3;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
217
224
|
.menu-row .menu-arrow{grid-column:4;font-size:1.2em;line-height:1}
|
|
@@ -223,6 +230,7 @@ export function menuLine(Base) {
|
|
|
223
230
|
background:transparent;cursor:pointer;line-height:1.2;white-space:nowrap}
|
|
224
231
|
:host button.toolbar-button .icon{display:inline-flex;align-items:center;justify-content:center;
|
|
225
232
|
width:var(--gramlot-toolbar-icon-size);height:var(--gramlot-toolbar-icon-size);font-size:var(--gramlot-toolbar-icon-size);line-height:1}
|
|
233
|
+
#control.toolbar-button.icon-only{--gramlot-button-icon-size:var(--gramlot-toolbar-icon-size)}
|
|
226
234
|
:host button.toolbar-button .icon:empty{display:none}
|
|
227
235
|
:host button.toolbar-button:hover:not(:disabled){background:color-mix(in srgb,currentColor 10%,transparent)}
|
|
228
236
|
:host button.toolbar-button:focus-visible{outline:2px solid var(--gramlot-focus-ring,Highlight);outline-offset:-2px}
|
|
@@ -232,7 +240,7 @@ export function menuLine(Base) {
|
|
|
232
240
|
:host button.toolbar-below .menu-caption{font-size:11px;line-height:1.2}
|
|
233
241
|
:host button.toolbar-tooltip .menu-caption{display:none}
|
|
234
242
|
:host button.toolbar-button .menu-check{display:none}
|
|
235
|
-
:host button.toolbar-tooltip .menu-arrow{position:
|
|
243
|
+
:host button.toolbar-tooltip .menu-arrow{position:static;flex:0 0 8px;margin-inline-start:2px;font-size:12px;line-height:1}
|
|
236
244
|
:host button.toolbar-below .menu-arrow{position:absolute;inset:4px 3px auto auto;font-size:12px}`;
|
|
237
245
|
style.textContent+=`
|
|
238
246
|
:host([role=group]){display:block;min-width:0}
|
|
@@ -263,7 +271,7 @@ export function menuLine(Base) {
|
|
|
263
271
|
this.addEventListener('pointerleave',()=>clearTimeout(this.#hover));
|
|
264
272
|
}
|
|
265
273
|
get menuOwner() { return this.parentElement?.closest('gramlot-menu') ?? null; }
|
|
266
|
-
get submenu() { return [...this.children].map(labelboxContent).find(child=>child
|
|
274
|
+
get submenu() { return [...this.children].map(labelboxContent).find(child=>child?.localName==='gramlot-menu') ?? null; }
|
|
267
275
|
get entryCaption() { return this.parameters.caption ?? this.#registry?.label ?? ''; }
|
|
268
276
|
get entryIcon() { return this.parameters.icon || this.parameters.iconSrc ? this.parameters.icon : this.#registry?.icon; }
|
|
269
277
|
get entryIconSrc() { return this.parameters.icon || this.parameters.iconSrc ? this.parameters.iconSrc : this.#registry?.iconSrc; }
|
|
@@ -275,9 +283,8 @@ export function menuLine(Base) {
|
|
|
275
283
|
const rest=super.projectAttributes(attrs,adapt);
|
|
276
284
|
this.#accessibleLabel=attrs['aria-label'];
|
|
277
285
|
if(this.parameters.iconSize!=null&&(!Number.isFinite(this.parameters.iconSize)||this.parameters.iconSize<=0))throw new TypeError('menuline iconSize must be positive');
|
|
278
|
-
if(!Number.isFinite(this.parameters.priority))throw new TypeError('menuline priority must be finite');
|
|
279
286
|
this.#authoredDisabled=Boolean(this.parameters.disabled);
|
|
280
|
-
this.#render(); this.menuOwner?.overflow.schedule(); return rest;
|
|
287
|
+
this.#render(); this.menuOwner?.refreshItems(); this.menuOwner?.overflow.schedule(); return rest;
|
|
281
288
|
}
|
|
282
289
|
#render() {
|
|
283
290
|
const separator=[...this.childNodes].filter(node=>node.nodeType===3)
|
|
@@ -318,12 +325,13 @@ export function menuLine(Base) {
|
|
|
318
325
|
else this.control.style.removeProperty('--gramlot-toolbar-icon-size');
|
|
319
326
|
this.toggleAttribute('data-menu-group-rows',Boolean(popup || owner?.parameters.orientation==='vertical'));
|
|
320
327
|
this.control.classList.toggle('menu-row', popup);
|
|
321
|
-
this.#arrow.textContent = this.submenu ? (popup || owner?.parameters.orientation==='vertical' ? '›' : '▾') : '';
|
|
328
|
+
this.#arrow.textContent = this.submenu ? (toolbar && labelPosition==='tooltip' ? '⌄' : popup || owner?.parameters.orientation==='vertical' ? '›' : '▾') : '';
|
|
322
329
|
const disabled=this.#authoredDisabled || this.getAttribute('role')==='separator'
|
|
323
330
|
|| Boolean(this.parameters.command && !this.#registry)
|
|
324
331
|
|| ['loading','error'].includes(owner?.status)
|
|
325
332
|
|| Boolean(this.closest('gramlot-drop-down-button')?.parameters.disabled);
|
|
326
333
|
if(this.control.disabled!==disabled)this.control.disabled=disabled;
|
|
334
|
+
this.refreshIconOnly();
|
|
327
335
|
}
|
|
328
336
|
get disabled() {
|
|
329
337
|
for(let p=this.parentElement;p && p!==this.menuOwner;p=p.parentElement)if(p.localName==='gramlot-menu-line' && p.parameters.disabled)return true;
|
|
@@ -43,6 +43,7 @@ export class ToolbarOverflow {
|
|
|
43
43
|
:host([role=toolbar]) .toolbar-viewport{display:flex;align-items:center;gap:var(--gramlot-toolbar-gap,4px);flex:1 1 0%;min-width:0;min-height:0;overflow-x:auto;overflow-y:hidden}
|
|
44
44
|
:host([role=toolbar][aria-orientation=vertical]) .toolbar-viewport{flex-direction:column;align-items:stretch;overflow-x:hidden;overflow-y:auto;width:100%}
|
|
45
45
|
:host([role=toolbar]) ::slotted(*){flex-shrink:0}
|
|
46
|
+
:host([role=toolbar]) .toolbar-viewport[data-measuring]{flex:none;width:max-content;height:max-content;overflow:visible}
|
|
46
47
|
.toolbar-more{flex:0 0 auto;width:max(var(--gramlot-field-height,32px),var(--gramlot-touch-target,0px));height:max(var(--gramlot-field-height,32px),var(--gramlot-touch-target,0px));padding:0;border:0;border-radius:4px;background:transparent;color:inherit;font:inherit;display:grid;place-items:center}
|
|
47
48
|
.toolbar-more svg{display:block;width:18px;height:18px;pointer-events:none}
|
|
48
49
|
.toolbar-more:hover,.toolbar-more:focus-visible{background:var(--gramlot-selected,Highlight)}
|
|
@@ -109,12 +110,16 @@ export class ToolbarOverflow {
|
|
|
109
110
|
this.#overflow.clear();
|
|
110
111
|
menu.refreshItems();
|
|
111
112
|
for(const item of menu.items)item.refreshAvailability();
|
|
113
|
+
// Auto margins distribute spare space; they are not intrinsic content.
|
|
114
|
+
// Measure synchronously without flex allocation, then restore before paint.
|
|
115
|
+
this.#viewport.setAttribute('data-measuring','');
|
|
112
116
|
const gap=parseFloat(win.getComputedStyle(this.#viewport).gap)||0;
|
|
113
117
|
const lengths=new Map(units.map(unit=>{
|
|
114
118
|
const css=win.getComputedStyle(unit);
|
|
115
119
|
const length=labelboxContent(unit).localName==='gramlot-spacer'?(labelboxContent(unit).parameters.size??0):unit.getBoundingClientRect()[axis];
|
|
116
120
|
return [unit,length+(parseFloat(css[vertical?'marginTop':'marginLeft'])||0)+(parseFloat(css[vertical?'marginBottom':'marginRight'])||0)];
|
|
117
121
|
}));
|
|
122
|
+
this.#viewport.removeAttribute('data-measuring');
|
|
118
123
|
const separator=unit=>labelboxContent(unit).getAttribute('role')==='separator';
|
|
119
124
|
const tidy=list=>list.filter((unit,index)=>!separator(unit) ||
|
|
120
125
|
list.slice(0,index).some(item=>labelboxContent(item).localName!=='gramlot-spacer'&&!separator(item)) &&
|
|
@@ -123,16 +128,15 @@ export class ToolbarOverflow {
|
|
|
123
128
|
const required=remaining=>remaining.reduce((sum,unit)=>sum+lengths.get(unit),0)+Math.max(0,remaining.length-1)*gap;
|
|
124
129
|
let remaining=tidy(units);
|
|
125
130
|
if(required(remaining)>available){
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
this.#overflow.add(unit);remaining=tidy(remaining.filter(item=>item!==unit));
|
|
131
|
+
let cut=units.length;
|
|
132
|
+
while(cut>0 && required(remaining)>available-32) {
|
|
133
|
+
cut--;
|
|
134
|
+
remaining=tidy(units.slice(0,cut));
|
|
131
135
|
}
|
|
136
|
+
const suffix=tidy(units.slice(cut).filter(unit=>labelboxContent(unit).localName!=='gramlot-spacer'));
|
|
137
|
+
for(const unit of suffix)this.#overflow.add(unit);
|
|
132
138
|
}
|
|
133
|
-
const
|
|
134
|
-
for(const unit of overflowRows)this.#overflow.add(unit);
|
|
135
|
-
for(const unit of units)if(separator(unit)&&!remaining.includes(unit)&&!this.#overflow.has(unit))unit.slot='suppressed';
|
|
139
|
+
for(const unit of units)if(!remaining.includes(unit)&&!this.#overflow.has(unit))unit.slot='suppressed';
|
|
136
140
|
for(const unit of this.#overflow){unit.slot='overflow';unit.setAttribute('data-menu-overflow','');}
|
|
137
141
|
this.#button.hidden=this.#overflow.size===0;
|
|
138
142
|
for(const item of menu.items)item.refreshAvailability();
|