@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
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/* @ts-self-types="./gramlot-server.d.ts" */
|
|
2
|
+
import {standardCollections} from '../../dist/standard-collections.js';
|
|
2
3
|
/**
|
|
3
4
|
* The neutral server: registers pages and builds their Sources, with no HTTP engine.
|
|
4
5
|
*
|
|
@@ -122,7 +123,7 @@ export class GramlotServer {
|
|
|
122
123
|
Object.assign(this, {runtimeUrl, rpcUrl, closeUrl, rootId, pageTtl, maxPages, cssTheme});
|
|
123
124
|
this.pages = new Map();
|
|
124
125
|
this.uploads = uploadsEnabled ? new UploadRegistry() : null;
|
|
125
|
-
this.collections = [...collections];
|
|
126
|
+
this.collections = this.collectionGraph([...standardCollections, ...collections]);
|
|
126
127
|
this.preparedGrammars = new WeakMap();
|
|
127
128
|
this.environmentPages = new WeakMap();
|
|
128
129
|
}
|
package/src/server/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export type {GramlotServerOptions, OpenedPage, RegisteredPage} from './gramlot-s
|
|
|
11
11
|
export {GramlotBuilder} from '../builder/gramlot-builder.js';
|
|
12
12
|
export {GramlotFileServer} from './gramlot-file-server.js';
|
|
13
13
|
export type {GramlotFileServerOptions} from './gramlot-file-server.js';
|
|
14
|
-
export {gramlotDev, runtimeAsset} from './assets.js';
|
|
14
|
+
export {gramlotDev, runtimeAsset, standardCollectionAssets} from './assets.js';
|
|
15
15
|
export {checkProtocol} from './conformance.js';
|
|
16
16
|
export {InvalidResourceName, parseRequires} from './resources.js';
|
|
17
17
|
export type {Resources} from './resources.js';
|
package/src/server/index.js
CHANGED
|
@@ -11,7 +11,7 @@ export {GramlotServer, EndpointNotFound, InvalidRequest, NotAuthenticated, NotAu
|
|
|
11
11
|
SourceNotFound, ServerCapacity} from './gramlot-server.js';
|
|
12
12
|
export {GramlotBuilder} from '../builder/gramlot-builder.js';
|
|
13
13
|
export {GramlotFileServer} from './gramlot-file-server.js';
|
|
14
|
-
export {gramlotDev, runtimeAsset} from './assets.js';
|
|
14
|
+
export {gramlotDev, runtimeAsset, standardCollectionAssets} from './assets.js';
|
|
15
15
|
export {checkProtocol} from './conformance.js';
|
|
16
16
|
export {InvalidResourceName, parseRequires} from './resources.js';
|
|
17
17
|
export {NAME_SYNTAX, NameSyntax} from '../builder/name-syntax.js';
|
|
@@ -24,30 +24,30 @@ export class VisualEditor {
|
|
|
24
24
|
pane.dataController({func:'initializeEditorAppearance', _onBuilt:true});
|
|
25
25
|
pane.dataController({func:'applyEditorAppearance', profile:'^.appearanceProfile', palette:'^.appearancePalette', mode:'^.appearanceMode'});
|
|
26
26
|
const rail = this.rail = pane.menu({presentation:'bar', orientation:'vertical', aria_label:'Editor panels', class:'visual-editor-rail'});
|
|
27
|
-
this.toolButton(rail.menuline({group:true
|
|
28
|
-
this.toolButton(rail.menuline({group:true
|
|
29
|
-
this.toolButton(rail.menuline({group:true
|
|
30
|
-
this.toolButton(rail.menuline({group:true
|
|
27
|
+
this.toolButton(rail.menuline({group:true}), 'Source / Data', 'toggleNavigation', toolIcons.navigation);
|
|
28
|
+
this.toolButton(rail.menuline({group:true}), 'Catalogue', 'openCatalogue', toolIcons.catalogue);
|
|
29
|
+
this.toolButton(rail.menuline({group:true}), 'Properties', 'openProperties', toolIcons.properties);
|
|
30
|
+
this.toolButton(rail.menuline({group:true}), 'Clipboard', "this.SET('.clipboardVisible', !this.GET('.clipboardVisible'))", toolIcons.paste,
|
|
31
31
|
{dropTarget:true, dropTypes:'app/source', dropTags:`${editorId}Source`, dropEffect:'^.clipboardDropEffect',
|
|
32
32
|
connect_ondragover:'clipboardModifiers', connect_ondrop:'clipboardModifiers', onDrop:'dropClipboard'});
|
|
33
33
|
rail.spacer({flex:1});
|
|
34
|
-
this.toolButton(rail.menuline({group:true
|
|
34
|
+
this.toolButton(rail.menuline({group:true}), 'Appearance', "this.SET('.appearanceOpen', !this.GET('.appearanceOpen'))", toolIcons.appearance);
|
|
35
35
|
const layoutRoot = pane.framePane({node_label:'layout', height:'100%', id:`${editorId}-editor-frame`, class:'visual-editor-layout'});
|
|
36
36
|
layoutRoot.top.setAttr({height:'30px'});
|
|
37
37
|
const toolbar = layoutRoot.top.menu({presentation:'bar', aria_label:'Editor tools', class:'visual-editor-toolbar'});
|
|
38
|
-
toolbar.menuline({group:true
|
|
39
|
-
const files = toolbar.menuline({group:true,
|
|
38
|
+
toolbar.menuline({group:true}).span('Source editor', {class:'visual-editor-brand'});
|
|
39
|
+
const files = toolbar.menuline({group:true, gap:'4px', hidden:!fileCommands});
|
|
40
40
|
for (const [caption,action,icon] of [['New','newPage','new'],['Open','openUpload','open'],['Download','downloadPage','download'],['Copy Source','copySource','copy']])
|
|
41
41
|
this.toolButton(files,caption,action,toolIcons[icon],{id:`${editorId}-${icon}`});
|
|
42
|
-
toolbar.menuline({group:true
|
|
43
|
-
const edit = toolbar.menuline({group:true,
|
|
42
|
+
toolbar.menuline({group:true}).span({class:'visual-toolbar-divider', aria_hidden:'true'});
|
|
43
|
+
const edit = toolbar.menuline({group:true, gap:'2px'});
|
|
44
44
|
this.toolButton(edit,'Cut branch','cutBranch',toolIcons.cut,{title:'Cut branch (F8)'});
|
|
45
45
|
this.toolButton(edit,'Copy branch','copyBranch',toolIcons.copy);
|
|
46
46
|
this.toolButton(edit,'Paste branch','pasteBranch',toolIcons.paste,{title:'Paste branch (F9)'});
|
|
47
47
|
toolbar.spacer({flex:1});
|
|
48
|
-
toolbar.menuline({group:true,
|
|
49
|
-
toolbar.menuline({group:true
|
|
50
|
-
toolbar.menuline({group:true
|
|
48
|
+
toolbar.menuline({group:true, hidden:'^.modified:=!{}'}).span('Unsaved changes', {role:'status', class:'visual-editor-hint'});
|
|
49
|
+
toolbar.menuline({group:true}).span('^.fileStatus', {role:'status', class:'visual-editor-file-status'});
|
|
50
|
+
toolbar.menuline({group:true}).span('^.filename', {class:'visual-editor-filename'});
|
|
51
51
|
const left = layoutRoot.left;
|
|
52
52
|
left.setAttr({width:'min(240px, 34vw)', splitter:true,
|
|
53
53
|
drawer:'^.navigationOpen', default_drawer:true, drawer_label:'Source / Data',
|
|
@@ -96,7 +96,7 @@ export class VisualEditor {
|
|
|
96
96
|
naming.frame.center.p('^.error', {role:'alert', margin:'12px'});
|
|
97
97
|
const namingBar = naming.frame.bottom.menu({presentation:'bar', aria_label:'Clipboard commands', padding:'3px 6px'});
|
|
98
98
|
namingBar.spacer({flex:1});
|
|
99
|
-
const namingButtons = namingBar.menuline({group:true,
|
|
99
|
+
const namingButtons = namingBar.menuline({group:true, gap:'8px'});
|
|
100
100
|
namingButtons.button('Cancel', {action:"this.SET('.clipboardOpen', false)"});
|
|
101
101
|
namingButtons.button('Save branch', {action:'saveClipboard'});
|
|
102
102
|
const dialog = pane.dialog({class:'visual-editor-popup', title:'Required parameters', open:'^.insertionOpen', width:'400px', height:'280px', movable:true, resizable:true});
|
|
@@ -104,7 +104,7 @@ export class VisualEditor {
|
|
|
104
104
|
dialog.frame.center.p('^.error', {role:'alert'});
|
|
105
105
|
const bar = dialog.frame.bottom.menu({presentation:'bar', aria_label:'Insertion commands', padding:'3px 6px', border_top:'1px solid var(--gramlot-border)'});
|
|
106
106
|
bar.spacer({flex:1});
|
|
107
|
-
const buttons = bar.menuline({group:true,
|
|
107
|
+
const buttons = bar.menuline({group:true, gap:'8px'});
|
|
108
108
|
buttons.button('Cancel', {action:"this.SET('.insertionOpen', false)"});
|
|
109
109
|
buttons.button('Insert', {action:'insertWidget'});
|
|
110
110
|
const settings = pane.floatingPane({class:'visual-editor-popup', title:'Appearance', open:'^.appearanceOpen', default_open:false, width:'280px', height:'260px', movable:true, resizable:true});
|
|
@@ -128,7 +128,7 @@ export class VisualEditor {
|
|
|
128
128
|
pane.dataSetter({destination_path:'.codeDocument', value:new Bag({...document, saved:document.content, busy:false, status:''})});
|
|
129
129
|
const anchor = `#${pane.getAttr('visualEditorId')}Editor`;
|
|
130
130
|
const opener = frame === this.frame ? this.toolbar : frame.top.menu({presentation:'bar', aria_label:'Code drawer'});
|
|
131
|
-
opener.menuline({group:true
|
|
131
|
+
opener.menuline({group:true}).button('Code', {action:'openCode', class:'button--quiet'});
|
|
132
132
|
const drawer = frame.right;
|
|
133
133
|
drawer.setAttr({class:'visual-editor-code', datapath:anchor, title:'Page code', detachable:true, width:'60%', minSize:240, splitter:true,
|
|
134
134
|
drawer:'^.codeOpen', default_drawer:'close', drawer_label:'Code', drawer_minimize:false,
|
|
@@ -141,7 +141,7 @@ export class VisualEditor {
|
|
|
141
141
|
code.bottom.div('^.codeDocument.status', {role:'status', font_size:'12px', padding:'4px 10px'});
|
|
142
142
|
const bar = code.bottom.menu({presentation:'bar', aria_label:'Page code commands', padding:'3px 6px'});
|
|
143
143
|
bar.spacer({flex:1});
|
|
144
|
-
const commands = bar.menuline({group:true,
|
|
144
|
+
const commands = bar.menuline({group:true, gap:'6px'});
|
|
145
145
|
commands.button('Close', {action:"this.SET('.codeOpen', 'close')"});
|
|
146
146
|
commands.button('Preview saved', {action:'codePreview', disabled:'^.codeDocument.busy'});
|
|
147
147
|
commands.button('Save', {action:'codeSave', disabled:'^.codeSaveDisabled'});
|
|
@@ -150,7 +150,7 @@ export class VisualEditor {
|
|
|
150
150
|
}
|
|
151
151
|
search(pane, path, label) {
|
|
152
152
|
const bar = pane.menu({presentation:'bar', aria_label:label, class:'visual-search-toolbar'});
|
|
153
|
-
const field = bar.menuline({group:true,
|
|
153
|
+
const field = bar.menuline({group:true, flex:1, min_width:0}).div({class:'visual-search-field'});
|
|
154
154
|
field.span({class:'visual-search-icon', aria_hidden:'true'});
|
|
155
155
|
field.input({type:'search', value:`^.${path}`, default:'', live:true, placeholder:label, aria_label:label});
|
|
156
156
|
field.html_button({type:'button', class:'visual-search-clear', aria_label:`Clear ${label.toLowerCase()}`,
|
|
@@ -14,9 +14,14 @@ export class BagCollectionStore {
|
|
|
14
14
|
this.#listeners.add(listener);
|
|
15
15
|
return () => this.#listeners.delete(listener);
|
|
16
16
|
}
|
|
17
|
-
/**
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Called by the page's single Data subscription. Each view reconciles independently.
|
|
19
|
+
* `row` is the row node the event is inside, null for a change of the row list itself;
|
|
20
|
+
* `field` is the label directly under the row on the event path, null when the event
|
|
21
|
+
* targets the row node or inserts/deletes its direct children.
|
|
22
|
+
*/
|
|
23
|
+
receiveData(event, row = null, field = null) {
|
|
24
|
+
publishCollection(this.#listeners, {full:row === null, rows:row ? [row] : [], event, field});
|
|
20
25
|
}
|
|
21
26
|
getRows() {
|
|
22
27
|
const nodes = this.bag.getNodes();
|
|
@@ -39,10 +44,14 @@ export class BagCollectionStore {
|
|
|
39
44
|
}
|
|
40
45
|
}
|
|
41
46
|
|
|
42
|
-
/**
|
|
47
|
+
/**
|
|
48
|
+
* One invalidation protocol at both collection levels; failures cannot skip siblings.
|
|
49
|
+
* A store notice also carries its Data `event` and changed `field`; a view notice carries null.
|
|
50
|
+
*/
|
|
43
51
|
export function publishCollection(listeners, change) {
|
|
44
52
|
const errors = [];
|
|
45
|
-
const notice = Object.freeze({full:change.full, rows:Object.freeze([...change.rows])
|
|
53
|
+
const notice = Object.freeze({full:change.full, rows:Object.freeze([...change.rows]),
|
|
54
|
+
event:change.event ?? null, field:change.field ?? null});
|
|
46
55
|
for (const listener of [...listeners]) {
|
|
47
56
|
if (!listeners.has(listener)) continue;
|
|
48
57
|
try { listener(notice); } catch (error) { errors.push(error); }
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import {columnValue, columnValueKey, columnSelection, columnDateRange, columnDateMatches} from './column-filter.js';
|
|
1
2
|
import {isDecimal} from '@genrojs/tytx';
|
|
2
3
|
import {compileFilter} from './collection-filter.js';
|
|
4
|
+
import {containsId, requireId, requireIdSet} from './id-set.js';
|
|
3
5
|
import {publishCollection} from './bag-collection-store.js';
|
|
4
6
|
|
|
5
7
|
/** Source-owned view: original BagNodes, independent indices and criteria. */
|
|
@@ -9,15 +11,25 @@ export class BagCollectionView {
|
|
|
9
11
|
#listeners = new Set();
|
|
10
12
|
#indices = new Map();
|
|
11
13
|
#sortedBy = '';
|
|
12
|
-
#
|
|
13
|
-
#predicate = null;
|
|
14
|
+
#filters = new Map();
|
|
14
15
|
#filtered = null;
|
|
15
16
|
constructor(store) { this.bindStore(store); }
|
|
16
17
|
get bag() { return this.#store.bag; }
|
|
17
18
|
get rowMode() { return this.#store.rowMode; }
|
|
18
19
|
get sortedBy() { return this.#sortedBy; }
|
|
19
20
|
get criteria() { return parseSort(this.#sortedBy); }
|
|
20
|
-
get filter() { return this.#
|
|
21
|
+
get filter() { return this.#filters.get('search')?.definition ?? null; }
|
|
22
|
+
get filterSignature() { return JSON.stringify([...this.#filters].map(([name,{definition}]) => [name,definition])); }
|
|
23
|
+
/** Immutable accepted entries cross runtime/collection bundle boundaries. */
|
|
24
|
+
get filterContributions() {
|
|
25
|
+
return Object.freeze([...this.#filters].map(([name, entry]) =>
|
|
26
|
+
Object.freeze([name, Object.freeze({...entry})])));
|
|
27
|
+
}
|
|
28
|
+
/** Copy immutable accepted criteria into another Source-owned view, never rows. */
|
|
29
|
+
copyFiltersFrom(view) {
|
|
30
|
+
if (this.filterSignature === view.filterSignature) return;
|
|
31
|
+
this.#commit(this.#orderedNodes(),this.#sortedBy,new Map(view.filterContributions));
|
|
32
|
+
}
|
|
21
33
|
get filtered() { return this.#filtered === null ? null : [...this.#filtered]; }
|
|
22
34
|
isFiltered() { return this.#filtered !== null; }
|
|
23
35
|
value(node, field) { return this.#store.value(node, field); }
|
|
@@ -49,40 +61,90 @@ export class BagCollectionView {
|
|
|
49
61
|
return this.#store.getRows().toSorted((a,b) => (this.#indices.get(a) ?? Infinity) - (this.#indices.get(b) ?? Infinity));
|
|
50
62
|
}
|
|
51
63
|
synchronize(change = {full:true, rows:[]}) {
|
|
52
|
-
if (!change.full && !this.#sortedBy && !this.#
|
|
53
|
-
publishCollection(this.#listeners,change);
|
|
64
|
+
if (!change.full && !this.#sortedBy && !this.#filters.size) {
|
|
65
|
+
publishCollection(this.#listeners,{full:change.full, rows:change.rows});
|
|
54
66
|
return;
|
|
55
67
|
}
|
|
56
|
-
this.#commit(this.#sorted(this.#orderedNodes(),this.criteria),this.#sortedBy,this.#
|
|
68
|
+
this.#commit(this.#sorted(this.#orderedNodes(),this.criteria),this.#sortedBy,this.#filters,change);
|
|
57
69
|
}
|
|
58
70
|
sort(sortedBy) {
|
|
59
71
|
const nodes = this.#sorted(this.#orderedNodes(),parseSort(sortedBy));
|
|
60
|
-
this.#commit(nodes,sortedBy,this.#
|
|
72
|
+
this.#commit(nodes,sortedBy,this.#filters);
|
|
61
73
|
}
|
|
62
74
|
moveRow(node, target, after = false) {
|
|
63
75
|
if (node === target || node.parentBag !== this.bag || target.parentBag !== this.bag) return;
|
|
64
76
|
const nodes = this.getRows(false);
|
|
65
77
|
nodes.splice(nodes.indexOf(node),1);
|
|
66
78
|
nodes.splice(nodes.indexOf(target)+Number(after),0,node);
|
|
67
|
-
this.#commit(nodes,'',this.#
|
|
79
|
+
this.#commit(nodes,'',this.#filters);
|
|
68
80
|
}
|
|
69
|
-
applyFilter(filter) {
|
|
70
|
-
|
|
71
|
-
// cannot replace it, the predicate or the visible index.
|
|
81
|
+
applyFilter(filter, contribution = 'search') {
|
|
82
|
+
if (!['base','search'].includes(contribution)) throw new TypeError('Unknown collection filter contribution');
|
|
72
83
|
const definition = filter === null ? null : Object.freeze({...filter,columns:Object.freeze([...filter.columns])});
|
|
73
|
-
|
|
74
|
-
|
|
84
|
+
this.#applyContribution(contribution, definition, compileFilter(definition));
|
|
85
|
+
}
|
|
86
|
+
applySetFilter(sets) {
|
|
87
|
+
const definition = sets === null ? null : Object.freeze(sets.map(({field,value}) => {
|
|
88
|
+
if (typeof field !== 'string' || !field) throw new TypeError('Set filter requires an identity field');
|
|
89
|
+
requireIdSet(value);
|
|
90
|
+
return Object.freeze({field,value});
|
|
91
|
+
}));
|
|
92
|
+
const predicate = definition === null ? null : read => definition.every(({field,value}) =>
|
|
93
|
+
containsId(value,requireId(read(field))));
|
|
94
|
+
this.#applyContribution('sets',definition,predicate);
|
|
95
|
+
}
|
|
96
|
+
columnFilter(field) { return this.#filters.get(`column:${field}`)?.definition.values ?? null; }
|
|
97
|
+
columnRange(field) {
|
|
98
|
+
const range = this.#filters.get(`column:${field}`)?.definition.range;
|
|
99
|
+
return range ? {...range,from:range.from && new Date(range.from+'T00:00:00Z'),to:range.to && new Date(range.to+'T00:00:00Z')} : null;
|
|
100
|
+
}
|
|
101
|
+
applyColumnFilter(field, values, range = this.columnRange(field)) {
|
|
102
|
+
range = columnDateRange(range);
|
|
103
|
+
if (typeof field !== 'string' || !field) throw new TypeError('Column filter requires a field');
|
|
104
|
+
const selected = values === null ? null : columnSelection(values);
|
|
105
|
+
const keys = selected?.map(columnValueKey);
|
|
106
|
+
const definition = selected === null && range === null ? null : Object.freeze({field,values:selected,keys:keys && Object.freeze(keys),range});
|
|
107
|
+
const predicate = definition === null ? null : read => columnDateMatches(read(field),range) && (keys === undefined || keys.includes(columnValueKey(read(field))));
|
|
108
|
+
this.#applyContribution(`column:${field}`,definition,predicate);
|
|
109
|
+
}
|
|
110
|
+
columnFacets(field) {
|
|
111
|
+
const facets = new Map();
|
|
112
|
+
const range = this.#filters.get(`column:${field}`)?.definition.range ?? null;
|
|
113
|
+
const selected = this.columnFilter(field);
|
|
114
|
+
const keys = selected?.map(columnValueKey);
|
|
115
|
+
const predicates = [...this.#filters].filter(([name]) => name !== `column:${field}`)
|
|
116
|
+
.map(([,entry]) => entry.predicate).filter(predicate => predicate !== null);
|
|
117
|
+
for (const node of this.#orderedNodes()) {
|
|
118
|
+
const value = columnValue(this.value(node,field)), key = columnValueKey(value);
|
|
119
|
+
if (!facets.has(key)) facets.set(key,{key,value,count:0,selected:columnDateMatches(value,range) && (keys === undefined || keys.includes(key))});
|
|
120
|
+
if (predicates.every(predicate => predicate(field => this.value(node,field)))) facets.get(key).count++;
|
|
121
|
+
}
|
|
122
|
+
// Selections absent from the current Bag remain visible and removable.
|
|
123
|
+
for (const value of selected ?? []) {
|
|
124
|
+
const key = columnValueKey(value);
|
|
125
|
+
if (!facets.has(key)) facets.set(key,{key,value,count:0,selected:true});
|
|
126
|
+
}
|
|
127
|
+
return [...facets.values()].filter(entry => columnDateMatches(entry.value,range));
|
|
128
|
+
}
|
|
129
|
+
#applyContribution(name, definition, predicate) {
|
|
130
|
+
if (JSON.stringify(this.#filters.get(name)?.definition ?? null) === JSON.stringify(definition)) return;
|
|
131
|
+
const filters = new Map(this.#filters);
|
|
132
|
+
if (definition === null) filters.delete(name);
|
|
133
|
+
else filters.set(name,{definition,predicate});
|
|
134
|
+
this.#commit(this.#orderedNodes(),this.#sortedBy,filters);
|
|
75
135
|
}
|
|
76
|
-
#commit(nodes, sortedBy,
|
|
77
|
-
const
|
|
78
|
-
const
|
|
136
|
+
#commit(nodes, sortedBy, filters, change = {full:false, rows:[]}) {
|
|
137
|
+
const predicates = [...filters.values()].map(entry => entry.predicate).filter(predicate => predicate !== null);
|
|
138
|
+
const filtered = predicates.length ? nodes.flatMap((node,index) =>
|
|
139
|
+
predicates.every(predicate => predicate(field => this.value(node,field))) ? [index] : []) : null;
|
|
140
|
+
const full = change.full || sortedBy !== this.#sortedBy || filters !== this.#filters ||
|
|
79
141
|
nodes.length !== this.#indices.size || nodes.some((node,index) => this.#indices.get(node) !== index) ||
|
|
80
142
|
JSON.stringify(filtered) !== JSON.stringify(this.#filtered);
|
|
81
143
|
this.#indices = new Map(nodes.map((node,index) => [node,index]));
|
|
82
|
-
this.#sortedBy = sortedBy; this.#
|
|
144
|
+
this.#sortedBy = sortedBy; this.#filters = filters; this.#filtered = filtered;
|
|
83
145
|
const visible = filtered === null ? null : new Set(filtered);
|
|
84
146
|
const rows = full ? [] : change.rows.filter(node => this.#indices.has(node) && (visible === null || visible.has(this.#indices.get(node))));
|
|
85
|
-
if (full || rows.length) publishCollection(this.#listeners,{full,rows});
|
|
147
|
+
if (full || rows.length || change.rows.length) publishCollection(this.#listeners,{full,rows});
|
|
86
148
|
}
|
|
87
149
|
#sorted(nodes, criteria) {
|
|
88
150
|
if (!criteria.length) return nodes;
|
|
@@ -11,7 +11,8 @@ export function compileFilter(filter) {
|
|
|
11
11
|
!['T', 'L', 'R', 'N', 'D'].includes(dtype)) throw new TypeError('Invalid collection filter');
|
|
12
12
|
if (!value.trim()) return null;
|
|
13
13
|
if (dtype === 'T') {
|
|
14
|
-
const
|
|
14
|
+
const pattern = filter.literal === true ? value.replace(/[.*+?^${}()|[\]\\]/g,'\\$&') : value;
|
|
15
|
+
const expression = new RegExp(pattern, 'i');
|
|
15
16
|
return read => expression.test(columns.map(field => searchText(read(field), locale, filter.timeZone)).join(' '));
|
|
16
17
|
}
|
|
17
18
|
if (columns.length !== 1) throw new TypeError('Typed filters require one column');
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import {isDecimal, toTytx, fromTytx} from '@genrojs/tytx';
|
|
2
|
+
|
|
3
|
+
/** Typed identities: captions never determine membership. Blank values share one bucket. */
|
|
4
|
+
export function columnValue(value) {
|
|
5
|
+
if (value == null || value === '') return null;
|
|
6
|
+
if (typeof value === 'string' || typeof value === 'boolean' ||
|
|
7
|
+
typeof value === 'number' && Number.isFinite(value) ||
|
|
8
|
+
value instanceof Date && Number.isFinite(value.getTime()) ||
|
|
9
|
+
isDecimal(value) && value.isFinite()) return value;
|
|
10
|
+
throw new TypeError('Column filters require loaded scalar values');
|
|
11
|
+
}
|
|
12
|
+
export function columnValueKey(value) { return toTytx(columnValue(value)); }
|
|
13
|
+
export function columnSelection(values) {
|
|
14
|
+
if (!Array.isArray(values)) throw new TypeError('Column selection requires an array or null');
|
|
15
|
+
return Object.freeze([...new Map(values.map(value => {
|
|
16
|
+
const key = columnValueKey(value);
|
|
17
|
+
return [key, fromTytx(key)];
|
|
18
|
+
})).values()]);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Civil bounds; datetime values use the same day convention as their display. */
|
|
22
|
+
export function columnDateRange(range) {
|
|
23
|
+
if (range === null) return null;
|
|
24
|
+
const {from, to, dtype, timeZone} = range;
|
|
25
|
+
if (!['D','DH','DHZ'].includes(dtype)) throw new TypeError('Date range requires a date column');
|
|
26
|
+
for (const value of [from,to]) {
|
|
27
|
+
if (value !== null && (!(value instanceof Date) || !Number.isFinite(value.getTime()) ||
|
|
28
|
+
value.getUTCHours() || value.getUTCMinutes() || value.getUTCSeconds() || value.getUTCMilliseconds())) {
|
|
29
|
+
throw new TypeError('Date bounds require civil dates');
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (from && to && from > to) throw new RangeError('From must not be after To.');
|
|
33
|
+
if (dtype === 'DHZ' && !timeZone) throw new TypeError('DHZ requires a timeZone');
|
|
34
|
+
return from || to ? Object.freeze({from:from?.toISOString().slice(0,10) ?? null,
|
|
35
|
+
to:to?.toISOString().slice(0,10) ?? null,dtype,timeZone}) : null;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function columnDateMatches(value, range) {
|
|
39
|
+
if (!range) return true;
|
|
40
|
+
if (value == null || value === '') return false;
|
|
41
|
+
if (!(value instanceof Date) || !Number.isFinite(value.getTime())) throw new TypeError('Date range requires date values');
|
|
42
|
+
let day;
|
|
43
|
+
if (range.dtype === 'DHZ') {
|
|
44
|
+
const parts = new Intl.DateTimeFormat('en', {timeZone:range.timeZone,year:'numeric',month:'2-digit',day:'2-digit'}).formatToParts(value);
|
|
45
|
+
const part = type => parts.find(item=>item.type===type).value;
|
|
46
|
+
day = `${part('year')}-${part('month')}-${part('day')}`;
|
|
47
|
+
} else day = value.toISOString().slice(0,10);
|
|
48
|
+
return (!range.from || day >= range.from) && (!range.to || day <= range.to);
|
|
49
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Literal membership shared by checkbox projections and collection-view predicates. */
|
|
2
|
+
export function containsId(value, id) { return (',' + value + ',').includes(',' + id + ','); }
|
|
3
|
+
export function requireIdSet(value) {
|
|
4
|
+
if (typeof value !== 'string') throw new TypeError('grid checked must refer to a string (empty string for an empty set)');
|
|
5
|
+
return value;
|
|
6
|
+
}
|
|
7
|
+
export function requireId(id) {
|
|
8
|
+
if (typeof id !== 'string' || !id || id.includes(',')) throw new TypeError('grid checkedField requires nonempty text IDs without commas');
|
|
9
|
+
return id;
|
|
10
|
+
}
|
package/src/view/controls.js
CHANGED
|
@@ -623,6 +623,14 @@ function componentContext(adapter) {
|
|
|
623
623
|
callLogic:(name, keywords) => callLogic(binding.runtime, node, name, keywords),
|
|
624
624
|
format:(value, options) => app.format(value, options),
|
|
625
625
|
...validationContext(binding),
|
|
626
|
+
selectionDisplay:(caption, value) => {
|
|
627
|
+
if (binding.closed) return;
|
|
628
|
+
const pointer = node.getAttr('value');
|
|
629
|
+
if (node.pointerType(pointer) !== '^' || pointer.includes('?') || !Object.is(node.getRelativeData(pointer), value)) return;
|
|
630
|
+
const path = pointer.slice(1) + '?_displayedValue';
|
|
631
|
+
if (node.getRelativeData(path) !== caption) node.setRelativeData(path, caption);
|
|
632
|
+
},
|
|
633
|
+
periodOutput:(path, value) => node.setRelativeData(path, value),
|
|
626
634
|
selectionOutputs:({selectedCaption, selectedRecord, fields}, row) => {
|
|
627
635
|
if (binding.closed) return;
|
|
628
636
|
if (selectedCaption) node.setRelativeData(selectedCaption, row?.caption ?? null);
|
package/src/view/html.js
CHANGED
|
@@ -146,6 +146,10 @@ export class HtmlElement {
|
|
|
146
146
|
this.validateLabelbox(node);
|
|
147
147
|
const controlBox = document.createElement('div'); controlBox.append(element);
|
|
148
148
|
record.labelbox = createLabelbox(document,controlBox);
|
|
149
|
+
record.labelbox.choose = value => {
|
|
150
|
+
if (node.pointerType(node.getAttr('lbl_value'))) this.writeParameter(node, 'lbl_value', value);
|
|
151
|
+
else node.setAttr({lbl_value:value});
|
|
152
|
+
};
|
|
149
153
|
record.presentation = record.labelbox.box;
|
|
150
154
|
record.labelId = `gramlot-label-${randomId()}`;
|
|
151
155
|
record.controlId = `gramlot-control-${randomId()}`;
|
|
@@ -224,7 +228,12 @@ export class HtmlElement {
|
|
|
224
228
|
}
|
|
225
229
|
if (record.labelbox) {
|
|
226
230
|
record.labelbox.box.style.visibility = '';
|
|
227
|
-
|
|
231
|
+
const parameters = this.definition(node).meta.gramlot_component?.parameters ?? {};
|
|
232
|
+
const defaults = Object.fromEntries(Object.entries(parameters)
|
|
233
|
+
.filter(([name, spec]) => name.startsWith('lbl_') && Object.hasOwn(spec, 'default'))
|
|
234
|
+
.map(([name, spec]) => [name, spec.default]));
|
|
235
|
+
if (attrs.lbl_variant === 'card' && attrs.lbl_position == null) delete defaults.lbl_position;
|
|
236
|
+
projectLabelbox(record.labelbox, {...defaults, ...attrs}, adapt);
|
|
228
237
|
}
|
|
229
238
|
if (this.definition(node).meta.gramlot_component) {
|
|
230
239
|
if (this.definition(node).meta.gramlot_component.bagStore) {
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import {parseChoices, choiceCaption} from '../components/choices.js';
|
|
2
|
+
|
|
3
|
+
/** Label presentation over the shared menu. Source/Data own choices and selection. */
|
|
4
|
+
export class LabelMenu {
|
|
5
|
+
constructor(layout, choose) {
|
|
6
|
+
this.layout = layout;
|
|
7
|
+
const doc = layout.box.ownerDocument;
|
|
8
|
+
this.button = doc.createElement('button');
|
|
9
|
+
this.button.type = 'button';
|
|
10
|
+
this.button.className = 'label-menu-trigger';
|
|
11
|
+
this.button.setAttribute('aria-haspopup', 'menu');
|
|
12
|
+
this.button.setAttribute('aria-expanded', 'false');
|
|
13
|
+
this.menu = doc.createElement('gramlot-menu');
|
|
14
|
+
this.menu.projectAttributes({});
|
|
15
|
+
layout.labelBox.append(this.button, this.menu);
|
|
16
|
+
this.button.addEventListener('click', event => {
|
|
17
|
+
event.preventDefault(); event.stopPropagation();
|
|
18
|
+
if (this.menu.opened) this.menu.close();
|
|
19
|
+
else this.menu.open(this.button);
|
|
20
|
+
});
|
|
21
|
+
this.button.addEventListener('keydown', event => {
|
|
22
|
+
if (!['ArrowDown', 'ArrowUp'].includes(event.key)) return;
|
|
23
|
+
event.preventDefault(); event.stopPropagation();
|
|
24
|
+
this.menu.open(this.button, event.key === 'ArrowUp');
|
|
25
|
+
});
|
|
26
|
+
this.choose = choose;
|
|
27
|
+
}
|
|
28
|
+
project({lbl, lbl_value, lbl_values, disabled, readonly}, adapt) {
|
|
29
|
+
const choices = parseChoices(lbl_values);
|
|
30
|
+
if (this.values !== lbl_values) {
|
|
31
|
+
this.menu.close(false);
|
|
32
|
+
for (const item of this.menu.items) item.releaseCommand();
|
|
33
|
+
this.menu.replaceChildren(...choices.map(({id, caption}) => {
|
|
34
|
+
const item = this.menu.ownerDocument.createElement('gramlot-menu-line');
|
|
35
|
+
item.projectAttributes({code:id, caption}, adapt);
|
|
36
|
+
item.activateCommand = event => {
|
|
37
|
+
if (item.prepareCommand(event)) this.choose(id);
|
|
38
|
+
};
|
|
39
|
+
item.control.addEventListener('click', event => item.activateCommand(event));
|
|
40
|
+
return item;
|
|
41
|
+
}));
|
|
42
|
+
this.values = lbl_values;
|
|
43
|
+
}
|
|
44
|
+
const caption = choiceCaption(choices, lbl_value, lbl);
|
|
45
|
+
this.button.textContent = caption;
|
|
46
|
+
this.button.disabled = Boolean(disabled || readonly || !choices.length);
|
|
47
|
+
if (this.button.disabled) this.menu.close(false);
|
|
48
|
+
for (const item of this.menu.items) {
|
|
49
|
+
item.projectAttributes({...item.parameters, checked:item.parameters.code === lbl_value}, adapt);
|
|
50
|
+
}
|
|
51
|
+
this.layout.fieldLabel.textContent = caption;
|
|
52
|
+
this.layout.fieldLabel.hidden = true;
|
|
53
|
+
this.layout.labelBox.hidden = false;
|
|
54
|
+
}
|
|
55
|
+
dispose() {
|
|
56
|
+
this.menu.close(false);
|
|
57
|
+
for (const item of this.menu.items) item.releaseCommand();
|
|
58
|
+
this.menu.remove(); this.button.remove();
|
|
59
|
+
this.layout.fieldLabel.hidden = false;
|
|
60
|
+
}
|
|
61
|
+
}
|
package/src/view/labelbox.js
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
|
+
import {LabelMenu} from './label-menu.js';
|
|
2
|
+
|
|
1
3
|
/** Shared DOM presentation; instance-owned projection cache, no application state. */
|
|
2
4
|
export const labelboxPositions = ['TL', 'TC', 'TR', 'L', 'R', 'BL', 'BC', 'BR'];
|
|
3
|
-
export const labelboxStyle = `.gramlot-labelbox
|
|
5
|
+
export const labelboxStyle = `.gramlot-labelbox>.label-box>.label-menu-trigger{font:inherit;color:inherit;background:transparent;border:0;padding:0;min-width:0;min-height:var(--gramlot-touch-target,0px);height:auto;display:inline-flex;align-items:center;gap:.4em;cursor:pointer;text-align:inherit;line-height:inherit}
|
|
6
|
+
.gramlot-labelbox>.label-box>.label-menu-trigger::after{content:'';width:.35em;height:.35em;border-right:1.5px solid currentColor;border-bottom:1.5px solid currentColor;transform:translateY(-.1em) rotate(45deg);flex:none}
|
|
7
|
+
.gramlot-labelbox>.label-box>.label-menu-trigger:focus-visible{outline:2px solid var(--gramlot-focus-ring,Highlight);outline-offset:3px;border-radius:2px}
|
|
8
|
+
.gramlot-labelbox>.label-box>.label-menu-trigger:disabled{opacity:.5;cursor:default}
|
|
9
|
+
.gramlot-labelbox>.label-box>label[hidden]{display:none}
|
|
10
|
+
.gramlot-labelbox[hidden]{display:none!important}
|
|
4
11
|
.gramlot-labelbox{box-sizing:border-box;min-width:0;min-height:0;--gramlot-label-width:initial;--gramlot-formlet-label-width:initial;display:grid;gap:var(--gramlot-label-gap,.25em);grid-template-areas:'label' 'control';grid-template-columns:minmax(0,1fr);grid-template-rows:max-content minmax(0,1fr)}
|
|
5
12
|
.gramlot-labelbox>.label-box{grid-area:label;color:var(--gramlot-label-color,var(--gramlot-text-secondary,inherit));font-size:var(--gramlot-label-size,1em)} .gramlot-labelbox>.control-box{box-sizing:border-box;grid-area:control;min-width:0;min-height:0;display:grid;grid-template-columns:minmax(0,1fr);grid-template-rows:minmax(0,1fr)}
|
|
6
13
|
.gramlot-labelbox>.control-box>*{max-width:100%;box-sizing:border-box}
|
|
@@ -59,7 +66,7 @@ export function createLabelbox(document, controlBox) {
|
|
|
59
66
|
}
|
|
60
67
|
|
|
61
68
|
export function projectLabelbox(layout, attrs, adapt) {
|
|
62
|
-
const {lbl, lbl_variant, lbl_position = lbl_variant === 'card' ? 'TC' : 'TL', ...rest} = attrs;
|
|
69
|
+
const {lbl, lbl_value, lbl_values, lbl_variant, lbl_position = lbl_variant === 'card' ? 'TC' : 'TL', ...rest} = attrs;
|
|
63
70
|
if (!labelboxPositions.includes(lbl_position)) throw new TypeError(`Invalid lbl_position: ${lbl_position}`);
|
|
64
71
|
const groups = {box:{},label:{},labelBox:{},controlBox:{}};
|
|
65
72
|
const prefixes = [['box_l_','labelBox'],['box_c_','controlBox'],['lbl_','label'],['box_','box']];
|
|
@@ -85,6 +92,12 @@ export function projectLabelbox(layout, attrs, adapt) {
|
|
|
85
92
|
else layout.box.dataset.variant = lbl_variant;
|
|
86
93
|
layout.fieldLabel.textContent = lbl ?? '';
|
|
87
94
|
layout.labelBox.hidden = lbl == null || lbl === '';
|
|
95
|
+
if (lbl_values != null) {
|
|
96
|
+
layout.menu ??= new LabelMenu(layout, value => layout.choose(value));
|
|
97
|
+
layout.menu.project(attrs, adapt);
|
|
98
|
+
} else if (layout.menu) {
|
|
99
|
+
layout.menu.dispose(); layout.menu = null;
|
|
100
|
+
}
|
|
88
101
|
layout.box.dispatchEvent(new layout.box.ownerDocument.defaultView.Event('gramlot-label-layout', {bubbles:true}));
|
|
89
102
|
return rest;
|
|
90
103
|
}
|
|
@@ -36,6 +36,8 @@
|
|
|
36
36
|
--gramlot-error: #b13d48;
|
|
37
37
|
--gramlot-error-background: #fceef0;
|
|
38
38
|
|
|
39
|
+
--gramlot-button-icon-size: 24px;
|
|
40
|
+
--gramlot-button-icon-padding: 5px;
|
|
39
41
|
--gramlot-field-height: 2.75rem;
|
|
40
42
|
--gramlot-field-padding: .55rem .75rem;
|
|
41
43
|
--gramlot-field-font-size: .875rem;
|
|
@@ -472,3 +474,7 @@
|
|
|
472
474
|
.visual-clipboard { padding:3px; gap:2px; border-top:1px solid var(--gramlot-border); }
|
|
473
475
|
.visual-clipboard-title { font-weight:600; }
|
|
474
476
|
.visual-clipboard .visual-editor-hint { font-size:11px; }
|
|
477
|
+
|
|
478
|
+
/* FrameGrid owns its single command/search toolbar. */
|
|
479
|
+
.gramlot-grid-toolbar { padding:2px 6px; min-height:40px; background:var(--gramlot-surface-subtle); }
|
|
480
|
+
.gramlot-grid-toolbar > .gramlot-grid-search { margin-inline-start:auto; }
|