@gramlot/gramlot 0.3.27 → 0.3.31
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 +2 -2
- package/dist/components/grid/assets/collection.js +71 -34
- package/dist/components/grid/assets/files/0a1df3a083d0c010560aa342e87959c8c1070e6fd54545741f083f22d0c8b551-fflate.txt +21 -0
- package/dist/components/grid/assets/files/8cf9b31947daf7adb4a7a00a037459e58241af050cd0a603bfcf1756e533f75e-write-excel-file.txt +21 -0
- package/dist/components/grid/assets/index.js +1 -1
- package/dist/components/grid/assets/modules/browser-LVJHKBBV.js +19 -0
- package/dist/components/grid/assets/modules/chunk-RMRBEYTI.js +1 -0
- package/dist/components/grid/commands.json +42 -1
- package/dist/components/grid/grammar.json +650 -10
- 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 +944 -193
- package/dist/gramlot.min.js +85 -53
- package/dist/standard-collections.js +2 -0
- package/package.json +13 -4
- package/src/binding/grid-struct.js +5 -2
- package/src/binding/runtime.js +12 -1
- package/src/bootstrap.js +1 -1
- package/src/builder/gramlot-builder.d.ts +15 -2
- package/src/builder/gramlot-builder.js +116 -8
- package/src/builder/source.js +42 -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-footer.js +120 -0
- package/src/components/grid-formulas.js +403 -0
- package/src/components/grid-grammar.json +131 -2
- 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-selection.js +118 -0
- package/src/components/grid-structure.js +36 -5
- package/src/components/grid-styles.js +37 -1
- package/src/components/grid-tools.js +229 -0
- package/src/components/grid.js +223 -15
- 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/fflate.txt +21 -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/licenses/write-excel-file.txt +21 -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/editing-session.d.ts +2 -0
- package/src/editing-session.js +35 -3
- 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-store.js +14 -5
- package/src/stores/bag-collection-view.js +80 -18
- 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,8 +6,13 @@ 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';
|
|
12
|
+
import {GridFormulas} from './grid-formulas.js';
|
|
13
|
+
import {GridFooter} from './grid-footer.js';
|
|
14
|
+
import {GridTools, registerGridCommands} from './grid-tools.js';
|
|
15
|
+
import {GridSelection, SELECTION_MODES} from './grid-selection.js';
|
|
10
16
|
import {GridHeaderInteraction} from './grid-header-interaction.js';
|
|
11
17
|
import {GridRowLayout} from './grid-row-layout.js';
|
|
12
18
|
import {GridRowInteraction} from './grid-row-interaction.js';
|
|
@@ -18,19 +24,63 @@ import structureGrammar from './grid-grammar.json' with {type: 'json'};
|
|
|
18
24
|
/** First grid: explicit Bag row representation and a separately observable Data struct. */
|
|
19
25
|
export const Grid = defineComponent({
|
|
20
26
|
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'},
|
|
27
|
+
parameters: {columnFilters: {dtype:'B', default:false, binding:'read'}, setFilter: {dtype:'T', default:'', binding:'read'}, windowInfo: {dtype:'X', nullable:true, default:null, binding:'read'},
|
|
22
28
|
loading: {dtype:'B', default:false, binding:'read'},
|
|
23
29
|
viewport: {dtype:'X', nullable:true, default:null, binding:'write'},
|
|
24
30
|
sortRequest: {dtype:'T', default:'', binding:'write'},
|
|
25
31
|
storepath: {dtype: 'T'}, structpath: {dtype: 'T'}, rowMode: {dtype: 'T'},
|
|
26
32
|
rowHeaders: {dtype:'B', default:false, binding:'read'},
|
|
33
|
+
footer: {dtype:['B','T'], default:false, binding:'read'},
|
|
34
|
+
selectionMode: {dtype:'T', default:'multi', binding:'read'},
|
|
35
|
+
selectedId: {dtype:'T', nullable:true, default:null, binding:'write'},
|
|
36
|
+
selectedIndex: {dtype:'L', nullable:true, default:null, binding:'write'},
|
|
37
|
+
selectedLabel: {dtype:'T', nullable:true, default:null, binding:'write'},
|
|
38
|
+
selectedPkeys: {dtype:'X', nullable:true, default:null, binding:'write'},
|
|
39
|
+
selectedRowidx: {dtype:'T', nullable:true, default:null, binding:'write'},
|
|
40
|
+
selectedNodes: {dtype:'X', nullable:true, default:null, binding:'write'},
|
|
41
|
+
selectedRowData: {dtype:'X', nullable:true, default:null, binding:'write'},
|
|
27
42
|
rowResize: {dtype:'B', default:false, binding:'read'},
|
|
28
43
|
selfDragRows: {dtype:'B', default:false, binding:'read'},
|
|
29
44
|
sortedBy: {dtype:'T', default:'', binding:'read'},
|
|
30
45
|
filter: {annotation:{kind:'type',module:'builtins',name:'dict'}, nullable:true, default:null, binding:'read'}},
|
|
31
46
|
implementation: Base => class extends Base {
|
|
32
47
|
#store;
|
|
48
|
+
#checkSets;
|
|
49
|
+
#columnFilters;
|
|
33
50
|
#cellEditor;
|
|
51
|
+
#formulas;
|
|
52
|
+
#footer;
|
|
53
|
+
#tools;
|
|
54
|
+
#derivedSession = null;
|
|
55
|
+
#releaseDerived = null;
|
|
56
|
+
#selection;
|
|
57
|
+
/** Click selects (single); Ctrl/Cmd+click toggles and Shift+click extends (multi). Double-click still edits. */
|
|
58
|
+
#selectRow = event => {
|
|
59
|
+
const tr = event.target.closest('tr[data-row]');
|
|
60
|
+
const node = tr && [...this.#rows].find(([, row]) => row === tr)?.[0];
|
|
61
|
+
if (!node || this.#selection.mode === 'none') return;
|
|
62
|
+
try {
|
|
63
|
+
this.#selection.select(node, {toggle:event.ctrlKey || event.metaKey, range:event.shiftKey});
|
|
64
|
+
this.#renderSelection();
|
|
65
|
+
} catch (error) { this.#context.reportError(error, 'Grid selection'); }
|
|
66
|
+
};
|
|
67
|
+
/** Without an open editor: Up/Down move the current row, Shift extends (multi), Ctrl/Cmd+A selects all visible rows. */
|
|
68
|
+
#selectionKey = event => {
|
|
69
|
+
if (this.#selection.mode === 'none' || event.altKey) return;
|
|
70
|
+
const all = (event.ctrlKey || event.metaKey) && event.key.toLowerCase() === 'a';
|
|
71
|
+
const step = {ArrowUp:-1, ArrowDown:1}[event.key];
|
|
72
|
+
if (!all && (step === undefined || event.ctrlKey || event.metaKey)) return;
|
|
73
|
+
event.preventDefault();
|
|
74
|
+
try {
|
|
75
|
+
if (all) this.#selection.selectAll();
|
|
76
|
+
else {
|
|
77
|
+
const field = event.target.closest?.('td[data-field]')?.dataset.field;
|
|
78
|
+
const node = this.#selection.move(step, event.shiftKey);
|
|
79
|
+
if (node) this.#revealRow(node, field);
|
|
80
|
+
}
|
|
81
|
+
this.#renderSelection();
|
|
82
|
+
} catch (error) { this.#context.reportError(error, 'Grid selection'); }
|
|
83
|
+
};
|
|
34
84
|
#editCell = event => {
|
|
35
85
|
if (event.type === 'keydown' && !['Enter','F2'].includes(event.key)) return;
|
|
36
86
|
const cell = event.target.closest('td[data-field]');
|
|
@@ -94,6 +144,7 @@ export const Grid = defineComponent({
|
|
|
94
144
|
}
|
|
95
145
|
this.#adjustedScroll = null;
|
|
96
146
|
this.#headerViewport.scrollLeft = this.#bodyViewport.scrollLeft;
|
|
147
|
+
if (this.#footer) this.#footer.viewport.scrollLeft = this.#bodyViewport.scrollLeft;
|
|
97
148
|
this.#scheduleLayout();
|
|
98
149
|
};
|
|
99
150
|
constructor() {
|
|
@@ -145,6 +196,7 @@ export const Grid = defineComponent({
|
|
|
145
196
|
spinner.append(track, arc); this.#loadingStatus.append(spinner);
|
|
146
197
|
bodyFrame.append(this.#bodyViewport, this.#loadingStatus);
|
|
147
198
|
this.control.replaceChildren(headerFrame, bodyFrame); this.shadowRoot.append(style);
|
|
199
|
+
this.#columnFilters = new GridColumnFilters(this, this.#head);
|
|
148
200
|
this.#interaction = new GridHeaderInteraction(this.#head, this.control, () => this.#structure, (field, multiple) => this.#sort(field, multiple),
|
|
149
201
|
() => this.#rowLayout, () => this.#scheduleLayout());
|
|
150
202
|
this.#rowInteraction = new GridRowInteraction(this.#body, this.control, () => this.#rowLayout, row => {
|
|
@@ -156,7 +208,12 @@ export const Grid = defineComponent({
|
|
|
156
208
|
connectedCallback() {
|
|
157
209
|
this.#body.addEventListener('dblclick', this.#editCell);
|
|
158
210
|
this.#body.addEventListener('keydown', this.#editCell);
|
|
211
|
+
this.#body.addEventListener('click', this.#selectRow);
|
|
212
|
+
this.#bodyViewport.addEventListener('keydown', this.#selectionKey);
|
|
159
213
|
this.#cellEditor?.connect();
|
|
214
|
+
this.#checkSets?.connect();
|
|
215
|
+
this.#tools?.connect();
|
|
216
|
+
this.#columnFilters.connect();
|
|
160
217
|
this.#observeStore();
|
|
161
218
|
if (this.#collectionView) this.#invalidate({full:true, rows:[]});
|
|
162
219
|
this.#interaction.connect();
|
|
@@ -170,8 +227,16 @@ export const Grid = defineComponent({
|
|
|
170
227
|
disconnectedCallback() {
|
|
171
228
|
this.#body.removeEventListener('dblclick', this.#editCell);
|
|
172
229
|
this.#body.removeEventListener('keydown', this.#editCell);
|
|
230
|
+
this.#body.removeEventListener('click', this.#selectRow);
|
|
231
|
+
this.#bodyViewport.removeEventListener('keydown', this.#selectionKey);
|
|
173
232
|
this.#cellEditor?.disconnect();
|
|
233
|
+
this.#checkSets?.disconnect();
|
|
234
|
+
this.#tools.disconnect();
|
|
235
|
+
this.#releaseDerived?.(); this.#releaseDerived = null; this.#derivedSession = null;
|
|
236
|
+
this.#columnFilters.disconnect();
|
|
237
|
+
this.#formulas.disconnect();
|
|
174
238
|
this.#cancelRefresh();
|
|
239
|
+
gridSearch(this.#context.sourceNode).detach(this.#collectionView);
|
|
175
240
|
this.#collectionView?.disconnect();
|
|
176
241
|
this.#unsubscribeStore?.(); this.#unsubscribeStore = null;
|
|
177
242
|
this.#interaction.disconnect();
|
|
@@ -200,6 +265,7 @@ export const Grid = defineComponent({
|
|
|
200
265
|
if (handle) handle.setAttribute('aria-valuenow', String(Math.round(row.getBoundingClientRect().height)));
|
|
201
266
|
}
|
|
202
267
|
this.#headerViewport.scrollLeft = this.#bodyViewport.scrollLeft;
|
|
268
|
+
this.#footer.viewport.scrollLeft = this.#bodyViewport.scrollLeft;
|
|
203
269
|
if (!this.#structure) return;
|
|
204
270
|
try { this.#layoutWindow(); this.#cellEditor.position(); }
|
|
205
271
|
catch (error) { this.#context.reportError(error, 'Grid viewport'); }
|
|
@@ -279,7 +345,7 @@ export const Grid = defineComponent({
|
|
|
279
345
|
if (loading) this.control.setAttribute('aria-busy', 'true');
|
|
280
346
|
else this.control.removeAttribute('aria-busy');
|
|
281
347
|
if (force || start !== this.#windowStart || end !== this.#windowEnd) {
|
|
282
|
-
const rows = new GridRows(this.#
|
|
348
|
+
const rows = new GridRows(this.#formulas, this.#context.format)
|
|
283
349
|
.read(this.#structure.columns, this.#visibleNodes.slice(start-(info?.start ?? 0), end-(info?.start ?? 0)));
|
|
284
350
|
this.#renderRows(rows, this.#structure.columns, start);
|
|
285
351
|
this.#windowStart = start; this.#windowEnd = end;
|
|
@@ -332,8 +398,28 @@ export const Grid = defineComponent({
|
|
|
332
398
|
this.#openEditorAt(index,column);
|
|
333
399
|
return true;
|
|
334
400
|
}
|
|
401
|
+
/** The last error of each formula field, by field name. */
|
|
402
|
+
get formulaErrors() { return this.#formulas.errors; }
|
|
403
|
+
/** The last error of each totalized column, by field name. */
|
|
404
|
+
get totalErrors() { return this.#footer.errors; }
|
|
335
405
|
setSourceContext(context) {
|
|
336
406
|
this.#context = context;
|
|
407
|
+
this.#formulas = new GridFormulas(context.sourceNode);
|
|
408
|
+
this.#footer = new GridFooter(context.sourceNode, context.format, this.#bodyViewport.parentElement);
|
|
409
|
+
this.#selection = new GridSelection(context, {view:() => this.#collectionView, store:() => this.#collectionStore(),
|
|
410
|
+
mode:() => this.#selectionMode(), rowData:node => this.#rowData(node)});
|
|
411
|
+
this.#tools = new GridTools(context, {columns:() => this.#structure.columns, rows:() => this.#collectionView.getRows(),
|
|
412
|
+
selected:() => this.#selection.nodes, selectionMode:() => this.#selectionMode(),
|
|
413
|
+
reader:() => this.#formulas, store:() => ({bag:this.#store, mode:this.parameters.rowMode}),
|
|
414
|
+
parameters:() => this.parameters, document:this.ownerDocument});
|
|
415
|
+
if (this.isConnected) this.#tools.connect();
|
|
416
|
+
this.#columnFilters.setSourceContext(context);
|
|
417
|
+
this.#checkSets = new GridCheckSets(context.sourceNode, this.#body,
|
|
418
|
+
() => this.#structure?.columns ?? [],
|
|
419
|
+
element => [...this.#rows].find(([,tr]) => tr === element)?.[0],
|
|
420
|
+
(node,field) => this.#collectionView.value(node,field),
|
|
421
|
+
() => this.parameters.setFilter, () => this.#collectionView);
|
|
422
|
+
if (this.isConnected) this.#checkSets.connect();
|
|
337
423
|
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
424
|
const node = context.sourceNode;
|
|
339
425
|
if (!Object.hasOwn(node, 'gridRowLayout')) {
|
|
@@ -350,6 +436,8 @@ export const Grid = defineComponent({
|
|
|
350
436
|
setStructBag(bag) { this.#structBag = bag; this.#structureDirty = true; }
|
|
351
437
|
projectAttributes(attrs, adapt) {
|
|
352
438
|
const rest = super.projectAttributes(attrs, adapt);
|
|
439
|
+
if (this.#windowInfo() && (this.parameters.columnFilters || this.#collectionView?.filterContributions.some(([name]) => name.startsWith('column:')))) throw new TypeError('grid columnFilters requires a complete resident store');
|
|
440
|
+
if (this.#windowInfo() && this.parameters.setFilter !== '') throw new TypeError('grid setFilter requires a complete resident store');
|
|
353
441
|
const store = this.#context.collectionView(this.#store, this.parameters.rowMode);
|
|
354
442
|
if (this.#collectionView !== store) {
|
|
355
443
|
this.#cancelRefresh();
|
|
@@ -364,7 +452,7 @@ export const Grid = defineComponent({
|
|
|
364
452
|
const filter = this.parameters.filter;
|
|
365
453
|
const signature = JSON.stringify(filter);
|
|
366
454
|
if (!this.#windowInfo() && this.#requestedFilter !== signature) {
|
|
367
|
-
this.#collectionView.applyFilter(filter === null ? null : {locale:this.#context.locale,timeZone:this.#context.timeZone,...filter});
|
|
455
|
+
this.#collectionView.applyFilter(filter === null ? null : {locale:this.#context.locale,timeZone:this.#context.timeZone,...filter}, 'base');
|
|
368
456
|
this.#requestedFilter = signature;
|
|
369
457
|
}
|
|
370
458
|
this.#invalidate({full:true, rows:[]});
|
|
@@ -394,7 +482,8 @@ export const Grid = defineComponent({
|
|
|
394
482
|
this.#pendingRows.clear();
|
|
395
483
|
try {
|
|
396
484
|
if (full) this.#project();
|
|
397
|
-
|
|
485
|
+
// View values (#, += and their dependents) of other rows can change too.
|
|
486
|
+
else this.#projectRows(this.#formulas.viewFields.size ? [...this.#rows.keys()] : nodes);
|
|
398
487
|
} catch (error) {
|
|
399
488
|
// Keep the last valid DOM. A later change retries a complete pull;
|
|
400
489
|
// there is no automatic retry loop and no exception in Data delivery.
|
|
@@ -405,14 +494,23 @@ export const Grid = defineComponent({
|
|
|
405
494
|
}
|
|
406
495
|
#projectRows(nodes) {
|
|
407
496
|
for (const node of nodes) this.#rowLayout.forget(node);
|
|
408
|
-
|
|
497
|
+
this.#footer.update(this.#formulas, this.#collectionStore().getRows());
|
|
498
|
+
const rows = new GridRows(this.#formulas, this.#context.format).read(this.#structure.columns, nodes.filter(node => this.#rows.has(node)));
|
|
409
499
|
this.#rowInteraction.cancel();
|
|
410
|
-
for (const {node, cells} of rows) this.#renderCells(this.#rows.get(node), cells);
|
|
500
|
+
for (const {node, cells} of rows) this.#renderCells(this.#rows.get(node), cells, node);
|
|
411
501
|
this.#scheduleLayout();
|
|
412
502
|
}
|
|
413
503
|
#project() {
|
|
414
504
|
const model = this.#structureDirty ? new GridStructure(this.#structBag) : this.#structure;
|
|
505
|
+
const store = this.#collectionStore();
|
|
506
|
+
this.#formulas.configure(model, this.#collectionView, store);
|
|
507
|
+
this.#requireStoredCriteria();
|
|
508
|
+
this.#tools.requireEditableTools(model.columns);
|
|
509
|
+
this.#selection.prune();
|
|
510
|
+
const structureChanged = this.#structureDirty;
|
|
415
511
|
this.#cellEditor.configure(model.columns);
|
|
512
|
+
this.#structure = model;
|
|
513
|
+
this.#checkSets.configure();
|
|
416
514
|
const nodes = this.#collectionView.getRows();
|
|
417
515
|
this.#rowInteraction.cancel(); this.#rowInteraction.cancelDrag();
|
|
418
516
|
this.#rowLayout.retain(this.#store.getNodes());
|
|
@@ -427,24 +525,102 @@ export const Grid = defineComponent({
|
|
|
427
525
|
this.#windowRequest = null;
|
|
428
526
|
}
|
|
429
527
|
this.#windowRevision = info?.revision;
|
|
430
|
-
this.#structure = model;
|
|
431
528
|
this.#structureDirty = false;
|
|
432
|
-
|
|
529
|
+
// View values (#, += and their dependents) derive from the order: they are not searchable.
|
|
530
|
+
gridSearch(this.#context.sourceNode).update(this.#collectionView,
|
|
531
|
+
model.columns.filter(column => !column.check && !this.#formulas.viewFields.has(column.field)));
|
|
433
532
|
const rowHeaders = this.parameters.rowHeaders || this.parameters.rowResize;
|
|
434
|
-
const signature = JSON.stringify([model.groups, rowHeaders]);
|
|
533
|
+
const signature = JSON.stringify([model.groups, rowHeaders, this.parameters.columnFilters, this.parameters.footer]);
|
|
435
534
|
this.#rowHeaders = rowHeaders;
|
|
436
535
|
if (signature !== this.#signature) {
|
|
536
|
+
this.#footer.configure(this.parameters.footer, model.columns, rowHeaders);
|
|
437
537
|
this.#renderHeader(model);
|
|
438
538
|
this.#signature = signature;
|
|
439
539
|
}
|
|
540
|
+
this.#footer.update(this.#formulas, store.getRows());
|
|
541
|
+
this.#declareDerived(structureChanged);
|
|
542
|
+
this.#columnFilters.update(this.#collectionView, model.columns, this.parameters.columnFilters, this.#context.format);
|
|
440
543
|
this.#renderSort();
|
|
441
544
|
this.#renderWindow(true);
|
|
545
|
+
this.#renderSelection();
|
|
442
546
|
this.control.setAttribute('aria-colcount', String(model.columns.length + Number(this.#rowHeaders)));
|
|
443
547
|
this.control.setAttribute('aria-rowcount', String(this.#headerRows + Math.max(this.#rowLayout.count, 1)));
|
|
444
548
|
this.#scheduleLayout();
|
|
445
549
|
}
|
|
550
|
+
/** Formula results, published totals and the published selection are derived values of the editing session, never changes. */
|
|
551
|
+
#declareDerived(structureChanged) {
|
|
552
|
+
const session = this.#context.sourceNode.formState;
|
|
553
|
+
if (session === this.#derivedSession) {
|
|
554
|
+
if (structureChanged) session?.updateChanges();
|
|
555
|
+
return;
|
|
556
|
+
}
|
|
557
|
+
this.#releaseDerived?.();
|
|
558
|
+
this.#derivedSession = session;
|
|
559
|
+
this.#releaseDerived = session === null ? null : session.registerDerived(path => this.#derivedPath(path));
|
|
560
|
+
}
|
|
561
|
+
#derivedPath(path) {
|
|
562
|
+
const base = this.#derivedSession.path;
|
|
563
|
+
const relative = absolute => absolute === base ? '' : absolute.startsWith(base + '.') ? absolute.slice(base.length + 1) : null;
|
|
564
|
+
if (this.#footer.totalPaths().some(total => relative(total) === path)) return true;
|
|
565
|
+
// A published selection Bag (selectedNodes, selectedRowData) is derived with its content.
|
|
566
|
+
if (this.#selection.paths().some(selection => {
|
|
567
|
+
const own = relative(selection);
|
|
568
|
+
return own !== null && (path === own || path.startsWith(own + '.') || path.startsWith(own + '?'));
|
|
569
|
+
})) return true;
|
|
570
|
+
const store = relative(this.#context.sourceNode.absDatapath(this.parameters.storepath));
|
|
571
|
+
if (store === null || store !== '' && !path.startsWith(store + '.')) return false;
|
|
572
|
+
const row = store === '' ? path : path.slice(store.length + 1);
|
|
573
|
+
const field = (this.parameters.rowMode === 'attributes' ? /^[^.?]+\?([^.?]+)$/ : /^[^.?]+\.([^.?]+)$/).exec(row)?.[1];
|
|
574
|
+
return field !== undefined && this.#formulas.dataFields.has(field);
|
|
575
|
+
}
|
|
576
|
+
#selectionMode() {
|
|
577
|
+
const mode = this.parameters.selectionMode;
|
|
578
|
+
if (!SELECTION_MODES.includes(mode)) throw new TypeError('grid selectionMode requires none, single or multi');
|
|
579
|
+
return mode;
|
|
580
|
+
}
|
|
581
|
+
/** The plain field values of a row, as published by selectedNodes and selectedRowData. */
|
|
582
|
+
#rowData(node) {
|
|
583
|
+
if (this.parameters.rowMode === 'attributes') return {...node.getAttr()};
|
|
584
|
+
return Object.fromEntries(node.staticValue.getNodes().filter(cell => !(cell.staticValue instanceof Bag)).map(cell => [cell.label, cell.staticValue]));
|
|
585
|
+
}
|
|
586
|
+
#renderSelection() {
|
|
587
|
+
const mode = this.#selectionMode();
|
|
588
|
+
if (mode === 'multi') this.control.setAttribute('aria-multiselectable', 'true');
|
|
589
|
+
else this.control.removeAttribute('aria-multiselectable');
|
|
590
|
+
for (const [node, tr] of this.#rows) {
|
|
591
|
+
const selected = this.#selection.isSelected(node);
|
|
592
|
+
if (mode === 'none') tr.removeAttribute('aria-selected');
|
|
593
|
+
else tr.setAttribute('aria-selected', String(selected));
|
|
594
|
+
tr.setAttribute('part', selected ? 'row selected-row' : 'row');
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
/** Scroll the view row `node` into the viewport; focus the cell of `field` when given. */
|
|
598
|
+
#revealRow(node, field) {
|
|
599
|
+
const index = this.#collectionView.getRows().indexOf(node);
|
|
600
|
+
this.#endPinned = false;
|
|
601
|
+
const top = this.#rowLayout.offset(index), bottom = this.#rowLayout.offset(index + 1);
|
|
602
|
+
if (top < this.#bodyViewport.scrollTop) this.#scrollTo(top);
|
|
603
|
+
else if (bottom > this.#bodyViewport.scrollTop + this.#bodyViewport.clientHeight) this.#scrollTo(Math.max(0, bottom - this.#bodyViewport.clientHeight));
|
|
604
|
+
this.#renderWindow(true);
|
|
605
|
+
if (field) this.#rows.get(node)?.querySelector(`td[data-field="${field}"]`)?.focus({preventScroll:true});
|
|
606
|
+
}
|
|
607
|
+
/** The shared resident store under this grid's view. */
|
|
608
|
+
#collectionStore() {
|
|
609
|
+
return this.#context.sourceNode.rootBuilder.binding.collectionStore(this.#store, this.parameters.rowMode);
|
|
610
|
+
}
|
|
611
|
+
/** Sort, column filter and search criteria apply to stored fields: a view value derives from the order. */
|
|
612
|
+
#requireStoredCriteria() {
|
|
613
|
+
const view = this.#collectionView, fields = this.#formulas.viewFields;
|
|
614
|
+
const used = [...view.criteria.map(({field}) => ['sort by', field]),
|
|
615
|
+
...view.filterContributions.flatMap(([name, {definition}]) => name.startsWith('column:') ? [['filter', name.slice('column:'.length)]]
|
|
616
|
+
: name === 'sets' ? [] : definition.columns.map(field => ['search', field]))];
|
|
617
|
+
const [kind, field] = used.find(([, field]) => fields.has(field)) ?? [];
|
|
618
|
+
if (field !== undefined) throw new TypeError(`grid cannot ${kind} the view value '${field}'`);
|
|
619
|
+
}
|
|
446
620
|
#sort(field, multiple) {
|
|
621
|
+
if (this.#structure.columns.find(column => column.field === field)?.check) return;
|
|
447
622
|
try {
|
|
623
|
+
if (this.#formulas.viewFields.has(field)) throw new TypeError(`grid cannot sort by the view value '${field}'`);
|
|
448
624
|
const criteria = this.#windowInfo() ? parseSort(this.#windowInfo().sortedBy) : this.#collectionView.criteria;
|
|
449
625
|
const current = criteria.find(item => item.field === field);
|
|
450
626
|
const direction = current?.direction === 'a' ? 'd' : 'a';
|
|
@@ -497,12 +673,14 @@ export const Grid = defineComponent({
|
|
|
497
673
|
const column = model.columns[index];
|
|
498
674
|
cell.dataset.field = column.field;
|
|
499
675
|
cell.draggable = true; cell.tabIndex = 0;
|
|
500
|
-
cell.
|
|
676
|
+
cell.setAttribute('aria-label', column.title ?? column.name);
|
|
677
|
+
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
678
|
const indicator = doc.createElementNS(SVG_NS, 'svg');
|
|
502
679
|
indicator.classList.add('sort-indicator'); indicator.setAttribute('viewBox', '0 0 16 16');
|
|
503
680
|
indicator.setAttribute('aria-hidden', 'true');
|
|
504
681
|
const arrow = doc.createElementNS(SVG_NS, 'path');
|
|
505
682
|
arrow.setAttribute('d', 'M4 10L8 6L12 10'); indicator.append(arrow); cell.append(indicator);
|
|
683
|
+
if (this.parameters.columnFilters && !column.check && !this.#formulas.viewFields.has(column.field)) cell.append(this.#columnFilters.button(column));
|
|
506
684
|
const handle = doc.createElement('span');
|
|
507
685
|
handle.className = 'column-resize'; handle.tabIndex = 0;
|
|
508
686
|
handle.setAttribute('role', 'separator');
|
|
@@ -554,7 +732,8 @@ export const Grid = defineComponent({
|
|
|
554
732
|
if (this.#rowHeaders) widths.unshift('max(var(--grid-row-header-min-width, 0px), var(--grid-row-header-width, var(--gramlot-grid-row-header-width, 44px)))');
|
|
555
733
|
this.control.style.setProperty('--grid-columns-width', `calc(${widths.join(' + ')})`);
|
|
556
734
|
// Identical colgroups and table constraints keep one CSS sizing policy for both areas.
|
|
557
|
-
|
|
735
|
+
const footer = this.parameters.footer === false ? [] : [this.#footer.table];
|
|
736
|
+
for (const table of [this.#headerTable, this.#bodyTable, ...footer]) {
|
|
558
737
|
for (const group of table.querySelectorAll(':scope > colgroup')) group.remove();
|
|
559
738
|
table.prepend(...model.groups.map(group => {
|
|
560
739
|
const element = doc.createElement('colgroup');
|
|
@@ -586,6 +765,11 @@ export const Grid = defineComponent({
|
|
|
586
765
|
this.#rows.set(node, tr);
|
|
587
766
|
}
|
|
588
767
|
tr.classList.toggle('alternate', (start + keep.size) % 2 === 1);
|
|
768
|
+
tr.setAttribute('part', this.#selection.isSelected(node) ? 'row selected-row' : 'row');
|
|
769
|
+
if (this.#selection.mode === 'none') tr.removeAttribute('aria-selected');
|
|
770
|
+
else tr.setAttribute('aria-selected', String(this.#selection.isSelected(node)));
|
|
771
|
+
// Under a filter the numbering covers the visible rows only.
|
|
772
|
+
const partial = this.#collectionView.isFiltered();
|
|
589
773
|
tr.draggable = this.parameters.selfDragRows;
|
|
590
774
|
let heading = tr.querySelector('th[scope=row]');
|
|
591
775
|
if (this.#rowHeaders) {
|
|
@@ -598,6 +782,7 @@ export const Grid = defineComponent({
|
|
|
598
782
|
caption.className = 'row-number'; heading.append(caption); tr.prepend(heading);
|
|
599
783
|
}
|
|
600
784
|
heading.querySelector('.row-number').textContent = String(start + keep.size + 1);
|
|
785
|
+
heading.classList.toggle('filtered-numbering', partial);
|
|
601
786
|
let handle = heading.querySelector('.row-height-handle');
|
|
602
787
|
if (this.parameters.rowResize) {
|
|
603
788
|
if (!handle) {
|
|
@@ -623,6 +808,7 @@ export const Grid = defineComponent({
|
|
|
623
808
|
td.append(content);
|
|
624
809
|
}
|
|
625
810
|
if (column.edit) td.tabIndex = 0; else td.removeAttribute('tabindex');
|
|
811
|
+
td.classList.toggle('filtered-numbering', partial && this.#formulas.viewFields.has(column.field));
|
|
626
812
|
const content = td.firstElementChild;
|
|
627
813
|
const capped = column.max_height != null;
|
|
628
814
|
if (capped) td.style.setProperty('--grid-cell-max-height',column.max_height);
|
|
@@ -639,7 +825,7 @@ export const Grid = defineComponent({
|
|
|
639
825
|
}
|
|
640
826
|
for (const td of existing.values()) td.remove();
|
|
641
827
|
tr.setAttribute('aria-rowindex', String(this.#headerRows + start + keep.size + 1));
|
|
642
|
-
this.#renderCells(tr, cells);
|
|
828
|
+
this.#renderCells(tr, cells, node);
|
|
643
829
|
this.#cellEditor.decorate(tr, node);
|
|
644
830
|
const next = previous ? previous.nextSibling : this.#body.firstChild;
|
|
645
831
|
if (next !== tr) this.#body.insertBefore(tr, next);
|
|
@@ -654,11 +840,29 @@ export const Grid = defineComponent({
|
|
|
654
840
|
td.className = 'empty'; td.colSpan = columns.length + Number(this.#rowHeaders); td.textContent = 'No rows'; tr.append(td); this.#body.append(tr);
|
|
655
841
|
}
|
|
656
842
|
}
|
|
657
|
-
#renderCells(row, cells) {
|
|
843
|
+
#renderCells(row, cells, node) {
|
|
658
844
|
const offset = Number(this.#rowHeaders);
|
|
659
845
|
cells.forEach((text, index) => {
|
|
660
846
|
const content = row.cells[index + offset].firstElementChild;
|
|
661
|
-
|
|
847
|
+
const column = this.#structure.columns[index];
|
|
848
|
+
content.parentElement.classList.toggle('check-cell', Boolean(column.check));
|
|
849
|
+
if (column.check) {
|
|
850
|
+
this.#checkSets.project(content,node,column);
|
|
851
|
+
return;
|
|
852
|
+
}
|
|
853
|
+
const color = column.edit?.tag === 'colorpicker';
|
|
854
|
+
if (color) {
|
|
855
|
+
let swatch = content.querySelector('.cell-color-swatch');
|
|
856
|
+
if (!swatch) {
|
|
857
|
+
swatch = this.ownerDocument.createElement('span');
|
|
858
|
+
swatch.className = 'cell-color-swatch'; swatch.setAttribute('role','img');
|
|
859
|
+
content.replaceChildren(swatch);
|
|
860
|
+
}
|
|
861
|
+
swatch.hidden = text === '';
|
|
862
|
+
swatch.style.backgroundColor = text;
|
|
863
|
+
swatch.title = text;
|
|
864
|
+
swatch.setAttribute('aria-label',text);
|
|
865
|
+
} else if (content.firstElementChild || content.textContent !== text) content.textContent = text;
|
|
662
866
|
});
|
|
663
867
|
}
|
|
664
868
|
}
|
|
@@ -675,7 +879,11 @@ class GridCollection extends ComponentCollection {
|
|
|
675
879
|
metadata: [{kind: 'regex', pattern: '^(values|attributes)$', flags: 0}]};
|
|
676
880
|
}
|
|
677
881
|
Object.assign(document.elements, structuredClone(structureGrammar.elements));
|
|
882
|
+
// selected_<field> is a declared parameter family: composites route it to the grid (frameGrid).
|
|
883
|
+
document.elements.grid._meta.parameterPattern = '^selected_[A-Za-z_][A-Za-z0-9_]*$';
|
|
678
884
|
return document;
|
|
679
885
|
}
|
|
680
886
|
}
|
|
681
|
-
export default new GridCollection({name: 'grid', components: [Grid, SearchBox], dependencies:[inputs]
|
|
887
|
+
export default new GridCollection({name: 'grid', components: [Grid, SearchBox], dependencies:[inputs], registerCommands:registerGridCommands,
|
|
888
|
+
// The lazily loaded Excel writer and its compression library ship their licenses with the collection.
|
|
889
|
+
assets:{writeExcelFileLicense:new URL('./licenses/write-excel-file.txt', import.meta.url), fflateLicense:new URL('./licenses/fflate.txt', import.meta.url)}});
|
|
@@ -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) 2026 Arjun Barrett
|
|
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 all
|
|
13
|
+
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 THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -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.
|