@gramlot/gramlot 0.3.41 → 0.5.0
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/align-center.svg +4 -0
- package/assets/icons/align-justify.svg +4 -0
- package/assets/icons/align-left.svg +4 -0
- package/assets/icons/align-right.svg +4 -0
- package/assets/icons/applications.svg +4 -0
- package/assets/icons/archive.svg +4 -0
- package/assets/icons/attachment.svg +4 -0
- package/assets/icons/bold.svg +4 -0
- package/assets/icons/book.svg +4 -0
- package/assets/icons/bookmark.svg +4 -0
- package/assets/icons/calendar.svg +4 -0
- package/assets/icons/cancel.svg +4 -0
- package/assets/icons/chart.svg +4 -1
- package/assets/icons/chat.svg +4 -0
- package/assets/icons/clock.svg +4 -0
- package/assets/icons/code.svg +4 -0
- package/assets/icons/collapse.svg +4 -0
- package/assets/icons/columns.svg +4 -0
- package/assets/icons/confirm.svg +4 -0
- package/assets/icons/copy.svg +4 -0
- package/assets/icons/cut.svg +4 -0
- package/assets/icons/database.svg +4 -0
- package/assets/icons/delete.svg +4 -0
- package/assets/icons/detach.svg +4 -0
- package/assets/icons/document.svg +4 -0
- package/assets/icons/download.svg +4 -0
- package/assets/icons/duplicate.svg +4 -0
- package/assets/icons/edit.svg +4 -0
- package/assets/icons/eraser.svg +4 -0
- package/assets/icons/expand.svg +4 -0
- package/assets/icons/export.svg +4 -0
- package/assets/icons/eye.svg +4 -0
- package/assets/icons/filter.svg +4 -0
- package/assets/icons/first.svg +4 -0
- package/assets/icons/folder.svg +4 -0
- package/assets/icons/group.svg +4 -0
- package/assets/icons/help.svg +4 -0
- package/assets/icons/home.svg +4 -0
- package/assets/icons/horizontal-rule.svg +4 -0
- package/assets/icons/image.svg +4 -0
- package/assets/icons/import.svg +4 -0
- package/assets/icons/indent.svg +4 -0
- package/assets/icons/info.svg +4 -0
- package/assets/icons/inspector.svg +4 -0
- package/assets/icons/italic.svg +4 -0
- package/assets/icons/last.svg +4 -0
- package/assets/icons/layers.svg +4 -0
- package/assets/icons/link.svg +4 -0
- package/assets/icons/list-bulleted.svg +4 -0
- package/assets/icons/list-numbered.svg +4 -0
- package/assets/icons/list.svg +4 -0
- package/assets/icons/lock.svg +4 -0
- package/assets/icons/logout.svg +4 -0
- package/assets/icons/navigation.svg +4 -0
- package/assets/icons/new.svg +4 -0
- package/assets/icons/next.svg +4 -0
- package/assets/icons/open.svg +4 -0
- package/assets/icons/outdent.svg +4 -0
- package/assets/icons/palette.svg +4 -0
- package/assets/icons/panel-bottom.svg +4 -0
- package/assets/icons/panel-left.svg +4 -0
- package/assets/icons/panel-right.svg +4 -0
- package/assets/icons/panel-top.svg +4 -0
- package/assets/icons/paragraph.svg +4 -0
- package/assets/icons/paste.svg +4 -0
- package/assets/icons/pause.svg +4 -0
- package/assets/icons/pin.svg +4 -0
- package/assets/icons/play.svg +4 -0
- package/assets/icons/previous.svg +4 -0
- package/assets/icons/print.svg +4 -0
- package/assets/icons/redo.svg +4 -0
- package/assets/icons/refresh.svg +4 -0
- package/assets/icons/save.svg +4 -0
- package/assets/icons/search.svg +4 -0
- package/assets/icons/select-all.svg +4 -0
- package/assets/icons/send.svg +4 -0
- package/assets/icons/settings.svg +4 -0
- package/assets/icons/sort-ascending.svg +4 -0
- package/assets/icons/sort-descending.svg +4 -0
- package/assets/icons/stop.svg +4 -0
- package/assets/icons/strikethrough.svg +4 -0
- package/assets/icons/table.svg +4 -0
- package/assets/icons/tree.svg +4 -0
- package/assets/icons/underline.svg +4 -0
- package/assets/icons/undo.svg +4 -0
- package/assets/icons/unlock.svg +4 -0
- package/assets/icons/upload.svg +4 -0
- package/assets/icons/user.svg +4 -0
- package/assets/icons/warning.svg +4 -0
- package/assets/icons/zoom-in.svg +4 -0
- package/assets/icons/zoom-out.svg +4 -0
- package/dist/components/charts/__init__.py +1 -1
- package/dist/components/charts/assets/index.js +1 -1
- package/dist/components/charts/assets/libraries/vega.js +11 -11
- package/dist/components/charts/grammar.json +2032 -72
- package/dist/components/editors/__init__.py +1 -1
- package/dist/components/editors/assets/collection.js +1 -1
- package/dist/components/editors/assets/index.js +1 -1
- package/dist/components/editors/assets/libraries/codemirror.js +30 -31
- package/dist/components/editors/assets/libraries/jodit.js +453 -447
- package/dist/components/editors/commands.json +113 -1
- package/dist/components/editors/grammar.json +12 -5
- package/dist/components/grid/__init__.py +1 -1
- package/dist/components/grid/assets/index.js +1 -1
- package/dist/components/grid/commands.json +4 -6
- package/dist/components/grid/grammar.json +112 -0
- package/dist/components/inputs/__init__.py +1 -1
- package/dist/components/inputs/assets/index.js +1 -1
- package/dist/components/inputs/grammar.json +5165 -359
- package/dist/components/layout/__init__.py +1 -1
- package/dist/components/layout/assets/collection.js +1 -0
- package/dist/components/layout/assets/index.js +1 -1
- package/dist/components/layout/grammar.json +433 -4
- package/dist/components/tree/__init__.py +1 -1
- package/dist/components/tree/assets/index.js +1 -1
- package/dist/components/tree/grammar.json +51 -0
- package/dist/components/typst/__init__.py +1 -1
- package/dist/components/typst/assets/collection.js +6 -6
- package/dist/components/typst/assets/index.js +1 -1
- package/dist/components/uploads/__init__.py +1 -1
- package/dist/components/uploads/assets/index.js +1 -1
- package/dist/components/uploads/grammar.json +66 -0
- package/dist/declared-collections.js +1 -1
- package/dist/gramlot.js +5486 -2029
- package/dist/gramlot.min.js +361 -138
- package/dist/libraries.json +6 -4
- package/dist/standard-collections.js +1 -1
- package/dist/standard-grammar.js +1 -1
- package/package.json +6 -2
- package/src/binding/ask-dialog.js +17 -3
- package/src/binding/providers.js +3 -2
- package/src/binding/remote.js +41 -6
- package/src/binding/runtime.js +30 -3
- package/src/builder/gramlot-builder.d.ts +3 -1
- package/src/builder/gramlot-builder.js +77 -26
- package/src/builder/source.js +78 -15
- package/src/builder/xml-recipe.js +144 -0
- package/src/chat-file-types.js +13 -0
- package/src/chat.d.ts +1 -0
- package/src/chat.js +35 -25
- package/src/commands.d.ts +1 -1
- package/src/commands.js +1 -1
- package/src/components/border-container.js +64 -6
- package/src/components/buttons.js +26 -31
- package/src/components/chart-bar3d-options.js +0 -1
- package/src/components/chart-boxplot-options.js +1 -1
- package/src/components/chart-candlestick-options.js +1 -1
- package/src/components/chart-engines/echarts-options.js +6 -5
- package/src/components/chart-engines/echarts.js +27 -10
- package/src/components/chart-engines/plotly-map.js +1 -1
- package/src/components/chart-engines/plotly.js +21 -14
- package/src/components/chart-engines/uplot.js +17 -11
- package/src/components/chart-engines/vega.js +17 -11
- package/src/components/chart-funnel-options.js +1 -1
- package/src/components/chart-geographic-options.js +2 -2
- package/src/components/chart-heatmap-options.js +1 -1
- package/src/components/chart-map-bar3d-options.js +2 -2
- package/src/components/chart-map-options.js +2 -2
- package/src/components/chart-pane.js +5 -5
- package/src/components/chart-parallel-options.js +1 -1
- package/src/components/chart-radar-options.js +1 -1
- package/src/components/chart-renderer.js +6 -1
- package/src/components/chart-sankey-options.js +1 -1
- package/src/components/chart-spatial-options.js +6 -2
- package/src/components/chart-sunburst-options.js +13 -1
- package/src/components/chart-theme.js +14 -0
- package/src/components/chart-treemap-options.js +1 -1
- package/src/components/chart-type-data.js +24 -4
- package/src/components/charts.js +7 -6
- package/src/components/check-box-text-editor.js +1 -0
- package/src/components/check-box-text.js +2 -0
- package/src/components/check-box-tree.js +1 -1
- package/src/components/choice-editor.js +5 -4
- package/src/components/choice-field-styles.js +9 -1
- package/src/components/code-mirror-engine.js +19 -5
- package/src/components/code-mirror-gramlot.js +85 -0
- package/src/components/code-mirror.js +3 -2
- package/src/components/drawing.js +43 -14
- package/src/components/editor-commands.js +69 -0
- package/src/components/editor-options.js +1 -1
- package/src/components/editors.js +5 -3
- package/src/components/form-tray-pane.js +18 -0
- package/src/components/graphical-ranges.js +190 -0
- package/src/components/grid-check-sets.js +39 -3
- package/src/components/grid-footer.js +6 -1
- package/src/components/grid-header-interaction.js +3 -3
- package/src/components/grid-styles.js +30 -5
- package/src/components/grid-tools.js +15 -7
- package/src/components/grid.js +109 -15
- package/src/components/html-editor-commands.js +61 -0
- package/src/components/html-editor.js +18 -3
- package/src/components/inputs.js +94 -23
- package/src/components/jodit-engine.js +110 -7
- package/src/components/layout.js +3 -2
- package/src/components/menus.js +89 -26
- package/src/components/numeric-range.js +39 -0
- package/src/components/selected-container.js +123 -64
- package/src/components/tab-bar.js +389 -0
- package/src/components/toolbar-icon-style.js +22 -0
- package/src/components/toolbar-overflow.js +74 -12
- package/src/components/tray-base.js +528 -0
- package/src/components/tray-pane.js +41 -518
- package/src/components/tree.js +56 -4
- package/src/components/typed-editor.js +5 -2
- package/src/components/typst-preview.js +3 -3
- package/src/components/upload-blocks.js +88 -0
- package/src/components/upload-engine.js +21 -31
- package/src/components/uploader.js +168 -47
- package/src/editing-session.js +2 -1
- package/src/gramlot.js +6 -3
- package/src/handlers/dom-handler.d.ts +2 -0
- package/src/handlers/dom-handler.js +9 -0
- package/src/handlers/rpc-handler.d.ts +1 -1
- package/src/handlers/rpc-handler.js +2 -0
- package/src/handlers/source-handler.d.ts +5 -3
- package/src/handlers/source-handler.js +31 -13
- package/src/icons.js +84 -0
- package/src/ide-runtime.js +3 -1
- package/src/index-page-runtime.js +20 -5
- package/src/index-page-styles.js +1 -1
- package/src/index-theme.js +210 -3
- package/src/index.d.ts +7 -2
- package/src/index.js +7 -2
- package/src/libraries.js +4 -4
- package/src/object-extract.d.ts +7 -0
- package/src/object-extract.js +31 -0
- package/src/renderer/attributes.js +1 -1
- package/src/renderer/gramlot-renderer.d.ts +2 -2
- package/src/renderer/gramlot-renderer.js +4 -1
- package/src/server/chat-attachments.js +139 -0
- package/src/server/chat.d.ts +33 -0
- package/src/server/chat.js +168 -0
- package/src/server/database-selectors.d.ts +6 -0
- package/src/server/database-selectors.js +13 -0
- package/src/server/gramlot-file-server.js +6 -1
- package/src/server/gramlot-server.d.ts +19 -3
- package/src/server/gramlot-server.js +149 -19
- package/src/server/index-page.d.ts +10 -0
- package/src/server/index-page.js +92 -8
- package/src/server/index.d.ts +1 -1
- package/src/server/index.js +1 -1
- package/src/server/page-base.js +4 -0
- package/src/server/page-store.d.ts +21 -0
- package/src/server/page-store.js +219 -0
- package/src/server/page.d.ts +6 -1
- package/src/server/page.js +5 -1
- package/src/server/store-recipe.js +102 -0
- package/src/server/toolbar-icon-name.d.ts +93 -0
- package/src/server/upload.d.ts +2 -0
- package/src/server/upload.js +36 -18
- package/src/server/visual-editor.js +4 -2
- package/src/tree-store.d.ts +5 -1
- package/src/tree-store.js +11 -2
- package/src/view/choice-focus.js +17 -0
- package/src/view/html.js +21 -1
- package/src/view/labelbox.js +6 -1
- package/src/view/menu.js +9 -3
- package/src/visual-editor.d.ts +1 -0
- package/src/visual-editor.js +10 -5
- package/themes/gramlot-base/theme.css +60 -28
- package/themes/gramlot-compact/theme.css +2 -0
- package/themes/gramlot-index/icons/align-center.svg +4 -0
- package/themes/gramlot-index/icons/align-justify.svg +4 -0
- package/themes/gramlot-index/icons/align-left.svg +4 -0
- package/themes/gramlot-index/icons/align-right.svg +4 -0
- package/themes/gramlot-index/icons/applications.svg +4 -0
- package/themes/gramlot-index/icons/archive.svg +4 -0
- package/themes/gramlot-index/icons/attachment.svg +4 -0
- package/themes/gramlot-index/icons/bold.svg +4 -0
- package/themes/gramlot-index/icons/book.svg +4 -0
- package/themes/gramlot-index/icons/bookmark.svg +4 -0
- package/themes/gramlot-index/icons/calendar.svg +4 -0
- package/themes/gramlot-index/icons/cancel.svg +4 -0
- package/themes/gramlot-index/icons/chart.svg +4 -0
- package/themes/gramlot-index/icons/chat.svg +4 -0
- package/themes/gramlot-index/icons/clock.svg +4 -0
- package/themes/gramlot-index/icons/code.svg +4 -0
- package/themes/gramlot-index/icons/collapse.svg +4 -0
- package/themes/gramlot-index/icons/columns.svg +4 -0
- package/themes/gramlot-index/icons/confirm.svg +4 -0
- package/themes/gramlot-index/icons/copy.svg +4 -0
- package/themes/gramlot-index/icons/cut.svg +4 -0
- package/themes/gramlot-index/icons/database.svg +4 -0
- package/themes/gramlot-index/icons/delete.svg +4 -0
- package/themes/gramlot-index/icons/detach.svg +4 -0
- package/themes/gramlot-index/icons/document.svg +4 -0
- package/themes/gramlot-index/icons/download.svg +4 -0
- package/themes/gramlot-index/icons/duplicate.svg +4 -0
- package/themes/gramlot-index/icons/edit.svg +4 -0
- package/themes/gramlot-index/icons/eraser.svg +4 -0
- package/themes/gramlot-index/icons/expand.svg +4 -0
- package/themes/gramlot-index/icons/export.svg +4 -0
- package/themes/gramlot-index/icons/eye.svg +4 -0
- package/themes/gramlot-index/icons/filter.svg +4 -0
- package/themes/gramlot-index/icons/first.svg +4 -0
- package/themes/gramlot-index/icons/folder.svg +4 -0
- package/themes/gramlot-index/icons/group.svg +4 -0
- package/themes/gramlot-index/icons/help.svg +4 -0
- package/themes/gramlot-index/icons/home.svg +4 -0
- package/themes/gramlot-index/icons/horizontal-rule.svg +4 -0
- package/themes/gramlot-index/icons/image.svg +4 -0
- package/themes/gramlot-index/icons/import.svg +4 -0
- package/themes/gramlot-index/icons/indent.svg +4 -0
- package/themes/gramlot-index/icons/info.svg +4 -0
- package/themes/gramlot-index/icons/inspector.svg +4 -0
- package/themes/gramlot-index/icons/italic.svg +4 -0
- package/themes/gramlot-index/icons/last.svg +4 -0
- package/themes/gramlot-index/icons/layers.svg +4 -0
- package/themes/gramlot-index/icons/link.svg +4 -0
- package/themes/gramlot-index/icons/list-bulleted.svg +4 -0
- package/themes/gramlot-index/icons/list-numbered.svg +4 -0
- package/themes/gramlot-index/icons/list.svg +4 -0
- package/themes/gramlot-index/icons/lock.svg +4 -0
- package/themes/gramlot-index/icons/logout.svg +4 -0
- package/themes/gramlot-index/icons/navigation.svg +4 -0
- package/themes/gramlot-index/icons/new.svg +4 -0
- package/themes/gramlot-index/icons/next.svg +4 -0
- package/themes/gramlot-index/icons/open.svg +4 -0
- package/themes/gramlot-index/icons/outdent.svg +4 -0
- package/themes/gramlot-index/icons/palette.svg +4 -0
- package/themes/gramlot-index/icons/panel-bottom.svg +4 -0
- package/themes/gramlot-index/icons/panel-left.svg +4 -0
- package/themes/gramlot-index/icons/panel-right.svg +4 -0
- package/themes/gramlot-index/icons/panel-top.svg +4 -0
- package/themes/gramlot-index/icons/paragraph.svg +4 -0
- package/themes/gramlot-index/icons/paste.svg +4 -0
- package/themes/gramlot-index/icons/pause.svg +4 -0
- package/themes/gramlot-index/icons/pin.svg +4 -0
- package/themes/gramlot-index/icons/play.svg +4 -0
- package/themes/gramlot-index/icons/previous.svg +4 -0
- package/themes/gramlot-index/icons/print.svg +4 -0
- package/themes/gramlot-index/icons/redo.svg +4 -0
- package/themes/gramlot-index/icons/refresh.svg +4 -0
- package/themes/gramlot-index/icons/save.svg +4 -0
- package/themes/gramlot-index/icons/search.svg +4 -0
- package/themes/gramlot-index/icons/select-all.svg +4 -0
- package/themes/gramlot-index/icons/send.svg +4 -0
- package/themes/gramlot-index/icons/settings.svg +4 -0
- package/themes/gramlot-index/icons/sort-ascending.svg +4 -0
- package/themes/gramlot-index/icons/sort-descending.svg +4 -0
- package/themes/gramlot-index/icons/stop.svg +4 -0
- package/themes/gramlot-index/icons/strikethrough.svg +4 -0
- package/themes/gramlot-index/icons/table.svg +4 -0
- package/themes/gramlot-index/icons/tree.svg +4 -0
- package/themes/gramlot-index/icons/underline.svg +4 -0
- package/themes/gramlot-index/icons/undo.svg +4 -0
- package/themes/gramlot-index/icons/unlock.svg +4 -0
- package/themes/gramlot-index/icons/upload.svg +4 -0
- package/themes/gramlot-index/icons/user.svg +4 -0
- package/themes/gramlot-index/icons/warning.svg +4 -0
- package/themes/gramlot-index/icons/zoom-in.svg +4 -0
- package/themes/gramlot-index/icons/zoom-out.svg +4 -0
- package/themes/gramlot-index/icons.json +93 -0
- package/themes/gramlot-index/theme.css +24 -0
- package/themes/joanna/theme.css +2 -0
- package/themes/mela/theme.css +2 -0
- package/themes/mimi/theme.css +2 -0
- package/tools/gramlot-tools-inspector.js +11 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gramlot/gramlot",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Declarative HTML/SVG interfaces with live data binding, authored in JavaScript or Python.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -24,8 +24,10 @@
|
|
|
24
24
|
"@codemirror/lang-json": "^6.0.2",
|
|
25
25
|
"@codemirror/lang-markdown": "^6.5.2",
|
|
26
26
|
"@codemirror/lang-python": "^6.2.1",
|
|
27
|
+
"@codemirror/lang-rust": "^6.0.2",
|
|
27
28
|
"@codemirror/lang-sql": "^6.10.0",
|
|
28
29
|
"@codemirror/lang-xml": "^6.1.0",
|
|
30
|
+
"@codemirror/lang-yaml": "^6.1.3",
|
|
29
31
|
"@codemirror/language": "^6.13.1",
|
|
30
32
|
"@codemirror/lint": "^6.9.8",
|
|
31
33
|
"@codemirror/search": "^6.7.2",
|
|
@@ -34,7 +36,7 @@
|
|
|
34
36
|
"@genrojs/bag": ">=0.12.0",
|
|
35
37
|
"@genrojs/builders": ">=0.7.0",
|
|
36
38
|
"@genrojs/toolbox": ">=0.19.0",
|
|
37
|
-
"@genrojs/tytx": ">=0.16.
|
|
39
|
+
"@genrojs/tytx": ">=0.16.4",
|
|
38
40
|
"@lezer/highlight": "^1.2.5",
|
|
39
41
|
"@myriaddreamin/typst-ts-renderer": "0.7.0",
|
|
40
42
|
"@myriaddreamin/typst-ts-web-compiler": "0.7.0",
|
|
@@ -60,6 +62,7 @@
|
|
|
60
62
|
"write-excel-file": "4.1.1"
|
|
61
63
|
},
|
|
62
64
|
"devDependencies": {
|
|
65
|
+
"@gramlot/builder": "file:../tools/gramlot-builder",
|
|
63
66
|
"c8": "10.1.3",
|
|
64
67
|
"esbuild": "0.28.2",
|
|
65
68
|
"jsdom": "27.0.1",
|
|
@@ -72,6 +75,7 @@
|
|
|
72
75
|
"./build-plugins": "./src/build-plugins.js",
|
|
73
76
|
"./markdown": "./src/markdown.js",
|
|
74
77
|
"./page": "./src/server/page.js",
|
|
78
|
+
"./db": "./src/server/database-selectors.js",
|
|
75
79
|
"./gramlot-server": "./src/server/gramlot-server.js",
|
|
76
80
|
"./themes/*": "./themes/*",
|
|
77
81
|
"./assets/branding/*": "./assets/branding/*",
|
|
@@ -37,7 +37,7 @@ export class AskDialog {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
/** Show the dialog of `specification`; resolves with the values of its fields, or null when cancelled. */
|
|
40
|
-
show(binding, specification, parameters, title = 'Parameters') {
|
|
40
|
+
show(binding, specification, parameters, title = 'Parameters', {interpolate = false} = {}) {
|
|
41
41
|
const spec = typeof specification === 'string' ? {msg: specification, title} : specification;
|
|
42
42
|
if (!spec || typeof spec !== 'object' || Array.isArray(spec)) throw new TypeError('ask requires text or a parameter description');
|
|
43
43
|
for (const key of Object.keys(spec)) {
|
|
@@ -86,8 +86,22 @@ export class AskDialog {
|
|
|
86
86
|
connect_oncancel: `${group}.cancel`, connect_onclose: `${group}.cancel`,
|
|
87
87
|
class: 'gramlot-ask', 'aria-labelledby': `${id}_title`,
|
|
88
88
|
style: 'border:1px solid #aab4c2;border-radius:8px;padding:16px;max-width:32rem;width:calc(100% - 48px);font:inherit;'});
|
|
89
|
-
|
|
90
|
-
|
|
89
|
+
const dialogText = (key, text) => {
|
|
90
|
+
if (!interpolate || typeof text !== 'string' || /^[=^]/.test(text)) return text;
|
|
91
|
+
let substituted = false;
|
|
92
|
+
const formatted = text.replace(/\{([A-Za-z_]\w*)\}/g, (token, name) => {
|
|
93
|
+
if (!Object.hasOwn(parameters, name)) return token;
|
|
94
|
+
substituted = true;
|
|
95
|
+
return String(parameters[name] ?? '');
|
|
96
|
+
});
|
|
97
|
+
if (!substituted) return text;
|
|
98
|
+
// Bind the result as Data so argument values are always displayed as text.
|
|
99
|
+
const path = `.ask-text.${key}`;
|
|
100
|
+
app.data.setItem(id + path, formatted);
|
|
101
|
+
return '^' + path;
|
|
102
|
+
};
|
|
103
|
+
dialog.h2(dialogText('title', spec.title ?? title), {id: `${id}_title`, style: 'font-size:1.1em;margin:0 0 12px;'});
|
|
104
|
+
if (spec.msg) dialog.p(dialogText('msg', spec.msg));
|
|
91
105
|
const form = dialog.form({request: id, connect_onsubmit: `${group}.confirm`});
|
|
92
106
|
for (const field of fields) {
|
|
93
107
|
form.dataSetter({destination_path: `.${field.name}`,
|
package/src/binding/providers.js
CHANGED
|
@@ -157,7 +157,7 @@ export class Provider {
|
|
|
157
157
|
|
|
158
158
|
/**
|
|
159
159
|
* The one pipeline of every trigger, `{kind: 'data'|'init'|'built'|'start'|'timing', change}` or
|
|
160
|
-
* `{kind: 'click', event, counter}
|
|
160
|
+
* `{kind: 'click', event, counter}`, or `{kind: 'fireNode', change: null, runKwargs}` (`Source node.fireNode`, merged over the arguments):
|
|
161
161
|
* arguments, `_if`, body, and for a formula the write of the result at `result_path`. `_if` and
|
|
162
162
|
* `_else` are inline (Q11.1): a false `_if` stops, or `_else` replaces the body (D5); an empty `_if`
|
|
163
163
|
* is absent and an empty `_else` or body is none, as legacy. A body is
|
|
@@ -175,6 +175,7 @@ export class Provider {
|
|
|
175
175
|
const rpc = this.kind === 'rpc';
|
|
176
176
|
const remote = this.kind === 'remote';
|
|
177
177
|
const kwargs = this.readArguments(trigger);
|
|
178
|
+
if (trigger.runKwargs) Object.assign(kwargs, trigger.runKwargs);
|
|
178
179
|
if (trigger.askResult) {
|
|
179
180
|
Object.assign(kwargs, trigger.askResult);
|
|
180
181
|
kwargs._askResult = trigger.askResult;
|
|
@@ -182,7 +183,7 @@ export class Provider {
|
|
|
182
183
|
const ask = node.getAttr('_ask');
|
|
183
184
|
const askDialog = this.binding.runtime.askDialog;
|
|
184
185
|
if (ask && !trigger.askDone && askDialog.required(this.binding, ask, kwargs, '_ask')) {
|
|
185
|
-
return askDialog.show(this.binding, ask, kwargs, node.getAttr('_ask_title') ?? 'Warning').then(result => {
|
|
186
|
+
return askDialog.show(this.binding, ask, kwargs, node.getAttr('_ask_title') ?? 'Warning', {interpolate: true}).then(result => {
|
|
186
187
|
if (this.binding.closed) return;
|
|
187
188
|
if (result === null) {
|
|
188
189
|
const cancel = node.getAttr('_ask_onCancel');
|
package/src/binding/remote.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {invokeHook} from './hooks.js';
|
|
2
2
|
import {toTytx} from '@genrojs/tytx';
|
|
3
3
|
import {TriggerTimers} from './providers.js';
|
|
4
|
+
import {objectExtract} from '../object-extract.js';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* The `remote` attribute of a Source node (GC-095 §105): the content of the element is the fragment of a
|
|
@@ -12,9 +13,12 @@ import {TriggerTimers} from './providers.js';
|
|
|
12
13
|
* The control attributes: `_cachedRemote` (no call when name and parameters equal those of the request in
|
|
13
14
|
* flight, or of the fragment mounted last when none is in flight), `_if` (inline, false → no call, and `_else`
|
|
14
15
|
* runs when present; a readiness condition that never cancels a request), `_onCalling` (inline, before the
|
|
15
|
-
* call; `false` makes no call), `_onRemote` (inline, after the fragment is mounted), `
|
|
16
|
+
* call; `false` makes no call), `_onRemote` (inline, after the fragment is mounted), `_waitingMessage` (a layer
|
|
17
|
+
* with a message over the element while the request runs), `_delay` (ms of debounce
|
|
16
18
|
* of a Data change), `_timing` (seconds between two calls) and `_userChanges` (only the changes of level
|
|
17
|
-
* `node` call). The inline code has the parameters as locals and `this` = the node.
|
|
19
|
+
* `node` call). The inline code has the parameters as locals and `this` = the node. The parameter
|
|
20
|
+
* `sendInheritedAttributes` sends `node.getInheritedAttributes()` as `_inheritedAttributes`: the server
|
|
21
|
+
* builds the fragment on a root that carries them.
|
|
18
22
|
*/
|
|
19
23
|
export class RemoteBinding {
|
|
20
24
|
#binding;
|
|
@@ -74,9 +78,10 @@ export class RemoteBinding {
|
|
|
74
78
|
const node = this.node;
|
|
75
79
|
const [, attrs] = node.rootBuilder.runtimeValues(node);
|
|
76
80
|
const name = attrs.remote;
|
|
77
|
-
const params = {};
|
|
78
|
-
|
|
79
|
-
|
|
81
|
+
const params = objectExtract(attrs, 'remote_*', {pop: false});
|
|
82
|
+
// As legacy: the server builds the fragment on a root that carries the inherited attributes.
|
|
83
|
+
if (objectExtract(params, 'sendInheritedAttributes').sendInheritedAttributes) {
|
|
84
|
+
params._inheritedAttributes = node.getInheritedAttributes();
|
|
80
85
|
}
|
|
81
86
|
const condition = node.getAttr('_if');
|
|
82
87
|
if (condition && !this.#inline('_if', condition, `return (${condition})`, params)) {
|
|
@@ -90,7 +95,9 @@ export class RemoteBinding {
|
|
|
90
95
|
if (attrs._cachedRemote && this.#cached(name, text)) return;
|
|
91
96
|
const onCalling = node.getAttr('_onCalling');
|
|
92
97
|
if (!node.requests.calling(onCalling ? () => this.#inline('_onCalling', onCalling, onCalling, params) : null)) return;
|
|
93
|
-
|
|
98
|
+
const hide = this.#showWaiting(attrs._waitingMessage);
|
|
99
|
+
try { mounted = await this.binding.runtime.gramlot.src.remoteSource(node, name, params); }
|
|
100
|
+
finally { hide(); }
|
|
94
101
|
} catch (error) {
|
|
95
102
|
throw new Error(`${node.nodeTag} '${node.label}': remote '${name}' failed: ${error.message}`, {cause: error});
|
|
96
103
|
}
|
|
@@ -114,6 +121,34 @@ export class RemoteBinding {
|
|
|
114
121
|
return name === this.#lastName && text === this.#lastParams;
|
|
115
122
|
}
|
|
116
123
|
|
|
124
|
+
/**
|
|
125
|
+
* `_waitingMessage`, as legacy (`gnrdomsource.js:1820`): while the request runs, a layer with the message
|
|
126
|
+
* (`'Loading content'` for `true`) covers the element of the node, which is marked `aria-busy`. A static
|
|
127
|
+
* element is positioned for the time of the layer. Returns the function that removes the layer.
|
|
128
|
+
*/
|
|
129
|
+
#showWaiting(message) {
|
|
130
|
+
// An element is missing only before the node's first build, when no request starts.
|
|
131
|
+
const element = message ? this.binding.runtime.gramlot.dom.getDomNode(this.node) : null;
|
|
132
|
+
if (!element) return () => {};
|
|
133
|
+
const document = element.ownerDocument;
|
|
134
|
+
const layer = document.createElement('div');
|
|
135
|
+
layer.className = 'gramlot-waiting-layer';
|
|
136
|
+
layer.setAttribute('role', 'status');
|
|
137
|
+
const text = document.createElement('div');
|
|
138
|
+
text.className = 'gramlot-waiting-message';
|
|
139
|
+
text.textContent = message === true ? 'Loading content' : String(message);
|
|
140
|
+
layer.append(text);
|
|
141
|
+
const positioned = document.defaultView.getComputedStyle(element).position === 'static';
|
|
142
|
+
if (positioned) element.classList.add('gramlot-waiting-host');
|
|
143
|
+
element.setAttribute('aria-busy', 'true');
|
|
144
|
+
element.append(layer);
|
|
145
|
+
return () => {
|
|
146
|
+
layer.remove();
|
|
147
|
+
element.removeAttribute('aria-busy');
|
|
148
|
+
if (positioned) element.classList.remove('gramlot-waiting-host');
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
|
|
117
152
|
/** The current value of a control attribute: a pointer is read from Data. */
|
|
118
153
|
#control(name) {
|
|
119
154
|
const [, attrs] = this.node.rootBuilder.runtimeValues(this.node);
|
package/src/binding/runtime.js
CHANGED
|
@@ -69,6 +69,7 @@ export class BindingRuntime {
|
|
|
69
69
|
#dataRootTrees = new Set();
|
|
70
70
|
// One collection store per absolute Data path and rowMode, never per Bag identity.
|
|
71
71
|
#collectionStores = new Map();
|
|
72
|
+
#pendingFires = new Map();
|
|
72
73
|
|
|
73
74
|
constructor(gramlot, {subscriptions}) {
|
|
74
75
|
this.#gramlot = gramlot;
|
|
@@ -231,6 +232,28 @@ export class BindingRuntime {
|
|
|
231
232
|
}
|
|
232
233
|
}
|
|
233
234
|
|
|
235
|
+
/**
|
|
236
|
+
* The fire scheduled by `FIRE_AFTER` for the absolute Data `path`, one per path in the page (legacy
|
|
237
|
+
* `pendingCallAfter`, `genro.js:1216`): a new call cancels the pending one. `binding`, when given,
|
|
238
|
+
* owns the timer, so the close of its node cancels it. Returns the cancellation of this call.
|
|
239
|
+
*/
|
|
240
|
+
fireAfter(path, delay, binding, run) {
|
|
241
|
+
this.#pendingFires.get(path)?.();
|
|
242
|
+
let release = null;
|
|
243
|
+
const cancel = () => {
|
|
244
|
+
clearTimeout(timer);
|
|
245
|
+
release?.();
|
|
246
|
+
if (this.#pendingFires.get(path) === cancel) this.#pendingFires.delete(path);
|
|
247
|
+
};
|
|
248
|
+
const timer = setTimeout(() => {
|
|
249
|
+
cancel();
|
|
250
|
+
run();
|
|
251
|
+
}, delay);
|
|
252
|
+
release = binding?.track(cancel) ?? null;
|
|
253
|
+
this.#pendingFires.set(path, cancel);
|
|
254
|
+
return cancel;
|
|
255
|
+
}
|
|
256
|
+
|
|
234
257
|
/** The open NodeBinding of `node`, or null. */
|
|
235
258
|
bindingFor(node) {
|
|
236
259
|
return this.#bindings.get(node) ?? null;
|
|
@@ -405,6 +428,7 @@ export class BindingRuntime {
|
|
|
405
428
|
this.root.unsubscribe(this.#subscription, {any: true});
|
|
406
429
|
this.nodeIds.clear();
|
|
407
430
|
this.#dependents.clear();
|
|
431
|
+
for (const cancel of [...this.#pendingFires.values()]) cancel();
|
|
408
432
|
this.#collectionStores.clear();
|
|
409
433
|
const errors = [];
|
|
410
434
|
for (const [node, binding] of [...this.#bindings.entries()].reverse()) {
|
|
@@ -763,7 +787,7 @@ export class NodeBinding {
|
|
|
763
787
|
|
|
764
788
|
/**
|
|
765
789
|
* Send `request`, the request of this node in flight (NodeRequests), through `gramlot.rpc.call` as
|
|
766
|
-
* `contentType`;
|
|
790
|
+
* `contentType`; returns the envelope for Source and the value for Data. The close of the node aborts it until the answer arrives, also
|
|
767
791
|
* when the answer arrived and was not yet received here: the call then rejects with the abort reason.
|
|
768
792
|
* Used by `dataRpc`, `dataRemote` and `remoteSource`.
|
|
769
793
|
*/
|
|
@@ -771,8 +795,11 @@ export class NodeBinding {
|
|
|
771
795
|
const {controller} = request;
|
|
772
796
|
const release = this.track(() => controller.abort());
|
|
773
797
|
try {
|
|
774
|
-
const
|
|
775
|
-
|
|
798
|
+
const rpc = this.runtime.gramlot.rpc;
|
|
799
|
+
const options = {signal: controller.signal};
|
|
800
|
+
const value = contentType === 'source'
|
|
801
|
+
? await rpc.callEnvelope(contentType, request.method, request.params, options)
|
|
802
|
+
: await rpc.call(contentType, request.method, request.params, options);
|
|
776
803
|
if (controller.signal.aborted) throw controller.signal.reason;
|
|
777
804
|
return value;
|
|
778
805
|
} finally {
|
|
@@ -24,9 +24,11 @@ export class GramlotBuilder extends HtmlBuilder {
|
|
|
24
24
|
/** The dialect name, `'gramlot'`. */
|
|
25
25
|
static _name: string;
|
|
26
26
|
static containers: string[];
|
|
27
|
+
codeMirrorWithOptions(parent: SourceBag | SourceBagNode, options: Parameters<typeof import('../components/editor-options.js').codeMirrorWithOptions>[1]): void;
|
|
28
|
+
VisualEditor(parent: SourceBag | SourceBagNode, options: ConstructorParameters<typeof import('../server/visual-editor.js').VisualEditor>[1]): void;
|
|
27
29
|
/** Build an ordinary framePane containing center.grid; requires layout and grid. */
|
|
28
30
|
frameGrid(parent: SourceBag | SourceBagNode, options: SourceAttributes & {
|
|
29
|
-
storepath: string; rowMode: 'values' | 'attributes'; structpath?: string; searchOn?: boolean | string; searchHelp?: boolean; chart?: boolean | string;
|
|
31
|
+
storepath: string; rowMode: 'values' | 'attributes'; structpath?: string; searchOn?: boolean | string; searchHelp?: boolean; addrow?: boolean; addrow_label?: string; delrow?: boolean | 'row'; delrow_label?: string; chart?: boolean | string;
|
|
30
32
|
}): SourceBagNode;
|
|
31
33
|
/** Tag prefixes of the parent dialects, from the names of the classes above `GramlotBuilder`. */
|
|
32
34
|
static get dialectPrefixes(): string[];
|
|
@@ -4,8 +4,12 @@
|
|
|
4
4
|
*
|
|
5
5
|
* @module
|
|
6
6
|
*/
|
|
7
|
+
import {codeMirrorWithOptions} from '../components/editor-options.js';
|
|
8
|
+
import {htmlEditorToolbar} from '../components/html-editor-commands.js';
|
|
9
|
+
import {VisualEditor} from '../server/visual-editor.js';
|
|
7
10
|
import buttons from '../components/buttons.js';
|
|
8
11
|
import {ComponentCollection} from '../components/registry.js';
|
|
12
|
+
import {objectExtract} from '../object-extract.js';
|
|
9
13
|
import {Bag} from '@genrojs/bag';
|
|
10
14
|
import {HtmlBuilder, META_ATTRS, SourceBagNode, sourceTarget} from '@genrojs/builders';
|
|
11
15
|
import {toTytx} from '@genrojs/tytx';
|
|
@@ -43,6 +47,8 @@ const EXPORT_FORMATS = {csv:'CSV', json:'JSON', tytx:'TYTX', xml:'XML', xlsx:'Ex
|
|
|
43
47
|
// frameGrid composes these grid attributes itself; its own parameters reach the grid too.
|
|
44
48
|
const FRAME_GRID_COMPOSED = new Set(['node_label', 'frameTarget', 'nodeId']);
|
|
45
49
|
const FRAME_GRID_PARAMETERS = new Set(['storepath', 'rowMode', 'structpath']);
|
|
50
|
+
// An editor frame composes these canvas attributes itself.
|
|
51
|
+
const EDITOR_FRAME_COMPOSED = new Set(['node_label', 'frameTarget']);
|
|
46
52
|
|
|
47
53
|
/**
|
|
48
54
|
* An element whose `_meta.keywordPattern` is set accepts, besides its declared attributes, only the
|
|
@@ -102,24 +108,52 @@ function excludedAttribute(attrs) {
|
|
|
102
108
|
/** Gramlot vocabulary and inert authoring on the shared builder grammar. */
|
|
103
109
|
export class GramlotBuilder extends HtmlBuilder {
|
|
104
110
|
static _name = 'gramlot';
|
|
105
|
-
static containers = ['frameGrid'];
|
|
111
|
+
static containers = ['frameGrid', 'codeMirrorWithOptions', 'VisualEditor', 'htmlEditor'];
|
|
106
112
|
static _sourceClass = GramlotBuilderBag;
|
|
107
113
|
// Composed on the inherited HtmlBuilder grammar; its data-elements replace Builder's.
|
|
108
114
|
static { this.defineGrammar(BINDING); }
|
|
109
115
|
static { this.defineGrammar(WEBCOMPONENT); }
|
|
110
116
|
static { this.defineGrammar(buttons.toDocument()); }
|
|
111
117
|
|
|
118
|
+
codeMirrorWithOptions(parent, options) {
|
|
119
|
+
codeMirrorWithOptions(parent, options);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
VisualEditor(parent, options) {
|
|
123
|
+
return new VisualEditor(parent, options);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/** A framePane with the htmlEditorCanvas in its center and, unless `toolbar` is false, the htmlEditor toolbar in top.bar. */
|
|
127
|
+
htmlEditor(parent, {toolbar = true, ...attrs} = {}) {
|
|
128
|
+
if (typeof toolbar !== 'boolean') throw new TypeError('htmlEditor toolbar requires a boolean');
|
|
129
|
+
return this.editorFrame(parent, 'htmlEditor', 'htmlEditorCanvas', toolbar ? htmlEditorToolbar : null, attrs);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Compose an editor frame: a framePane, the canvas as frame target in its center (node `canvas`) and
|
|
134
|
+
* the standard toolbar in top.bar. Canvas parameters go to the canvas; `canvas_`/`frame_` force any attribute.
|
|
135
|
+
*/
|
|
136
|
+
editorFrame(parent, owner, canvasTag, toolbar, attrs) {
|
|
137
|
+
for (const tag of ['framePane', canvasTag]) {
|
|
138
|
+
if (!this.schemaTag(tag)) throw new TypeError(`${owner} requires the ${tag} collection`);
|
|
139
|
+
}
|
|
140
|
+
const [frameAttrs, routed] = this.frameRoute(attrs, {owner, tag:canvasTag, prefix:'canvas_', composed:EDITOR_FRAME_COMPOSED});
|
|
141
|
+
const canvasAttrs = {...routed, node_label:'canvas', frameTarget:true, height:'100%', box_height:'100%'};
|
|
142
|
+
this.validateNodeValues(canvasTag, null, canvasAttrs);
|
|
143
|
+
const frame = parent.framePane({height:'400px', ...frameAttrs});
|
|
144
|
+
frame.center[canvasTag](canvasAttrs);
|
|
145
|
+
if (toolbar) toolbar(frame.top.menu({presentation:'bar', node_label:'bar', aria_label:'Editor toolbar', labelPosition:'tooltip'}));
|
|
146
|
+
return frame;
|
|
147
|
+
}
|
|
148
|
+
|
|
112
149
|
/** Compose real Source nodes; frame/grid/menu retain their existing runtime owners. */
|
|
113
150
|
frameGrid(parent, {storepath, rowMode, structpath, searchOn = false, searchHelp = false, chart = false,
|
|
114
|
-
export: exportRows = false, printRows = false, advancedTools = false, addrow = false, addrow_defaults = null,
|
|
115
|
-
duprow = false, delrow = false, gridsemaphore = false, ...attrs} = {}) {
|
|
151
|
+
export: exportRows = false, printRows = false, advancedTools = false, addrow = false, addrow_defaults = null, addrow_label = null,
|
|
152
|
+
duprow = false, delrow = false, delrow_label = null, gridsemaphore = false, ...attrs} = {}) {
|
|
116
153
|
for (const tag of ['framePane', 'grid']) {
|
|
117
154
|
if (!this.schemaTag(tag)) throw new TypeError(`frameGrid requires the ${tag} collection`);
|
|
118
155
|
}
|
|
119
|
-
const chartOptions =
|
|
120
|
-
for (const key of Object.keys(attrs)) if (key.startsWith('chart_')) {
|
|
121
|
-
chartOptions[key.slice(6)] = attrs[key]; delete attrs[key];
|
|
122
|
-
}
|
|
156
|
+
const chartOptions = objectExtract(attrs, 'chart_*');
|
|
123
157
|
const [frameAttrs, routed] = this.frameGridRoute(attrs);
|
|
124
158
|
const twice = Object.keys(routed).find(name => ['storepath', 'rowMode'].includes(name) || name === 'structpath' && structpath != null);
|
|
125
159
|
if (twice !== undefined) throw new TypeError(`frameGrid: '${twice}' is given twice`);
|
|
@@ -130,9 +164,10 @@ export class GramlotBuilder extends HtmlBuilder {
|
|
|
130
164
|
if (typeof chart === 'string') chartOptions.chartType = chart;
|
|
131
165
|
} else if (Object.keys(chartOptions).length) throw new TypeError('chart_* options require chart');
|
|
132
166
|
const exportFormats = frameGridExportFormats(exportRows);
|
|
133
|
-
for (const [name, value] of Object.entries({printRows, advancedTools, addrow, duprow,
|
|
167
|
+
for (const [name, value] of Object.entries({printRows, advancedTools, addrow, duprow, gridsemaphore})) {
|
|
134
168
|
if (typeof value !== 'boolean') throw new TypeError(`frameGrid ${name} requires a boolean`);
|
|
135
169
|
}
|
|
170
|
+
if (typeof delrow !== 'boolean' && delrow !== 'row') throw new TypeError('frameGrid delrow requires a boolean or row');
|
|
136
171
|
if (addrow_defaults !== null && (!addrow || typeof addrow_defaults !== 'object' || Array.isArray(addrow_defaults))) {
|
|
137
172
|
throw new TypeError('addrow_defaults requires addrow and a mapping');
|
|
138
173
|
}
|
|
@@ -145,6 +180,10 @@ export class GramlotBuilder extends HtmlBuilder {
|
|
|
145
180
|
node_label: 'grid', frameTarget: true, height: '100%', width: '100%',
|
|
146
181
|
// Legacy frameGrid default: the current row identity at .selectedId of the frame's own datapath.
|
|
147
182
|
...(frameAttrs.datapath ? {selectedId: '^.selectedId'} : {}), ...routed};
|
|
183
|
+
if (delrow === 'row') {
|
|
184
|
+
gridAttrs.delrow = delrow;
|
|
185
|
+
if (delrow_label !== null) gridAttrs.delrow_label = delrow_label;
|
|
186
|
+
}
|
|
148
187
|
if (chart !== false) gridAttrs.nodeId = randomId();
|
|
149
188
|
this.validateNodeValues('grid', null, gridAttrs);
|
|
150
189
|
if (searchOn !== false) this.validateNodeValues('searchBox', null, {searchOn, searchHelp});
|
|
@@ -152,24 +191,26 @@ export class GramlotBuilder extends HtmlBuilder {
|
|
|
152
191
|
frame.center.grid(gridAttrs);
|
|
153
192
|
const bar = frame.top.menu({presentation:'bar', node_label:'bar', aria_label:'Grid toolbar', class:'gramlot-grid-toolbar'});
|
|
154
193
|
if (searchOn !== false) bar.menuline({group:true, node_label:'search', class:'gramlot-grid-search'}).searchBox({searchOn, searchHelp});
|
|
155
|
-
if (addrow) bar.menuline({command:'grid:addrow', node_label:'addrow',
|
|
194
|
+
if (addrow) bar.menuline({command:'grid:addrow', node_label:'addrow', class:'button--standard',
|
|
195
|
+
...(addrow_label === null ? {} : {caption:addrow_label}), ...(addrow_defaults === null ? {} : {parameters:{defaults:addrow_defaults}})});
|
|
156
196
|
if (duprow) bar.menuline({command:'grid:duprow', node_label:'duprow'});
|
|
157
|
-
if (delrow) bar.menuline({command:'grid:delrow', node_label:'delrow'
|
|
197
|
+
if (delrow === true) bar.menuline({command:'grid:delrow', node_label:'delrow', disabled:true, class:'button--standard',
|
|
198
|
+
...(delrow_label === null ? {} : {caption:delrow_label})});
|
|
158
199
|
const exportMenu = parent => {
|
|
159
|
-
const menu = parent.menuline({caption:'Export', icon:'
|
|
200
|
+
const menu = parent.menuline({caption:'Export', icon:'download', labelPosition:'tooltip', node_label:'export'}).menu();
|
|
160
201
|
for (const name of exportFormats) menu.menuline({command:'grid:export', caption:EXPORT_FORMATS[name], parameters:{format:name}, node_label:name});
|
|
161
202
|
};
|
|
162
203
|
if (exportFormats.length) exportMenu(bar);
|
|
163
204
|
if (printRows) bar.menuline({command:'grid:printRows', node_label:'printRows'});
|
|
164
205
|
if (advancedTools) {
|
|
165
|
-
const tools = bar.menuline({caption:'Advanced tools', icon:'
|
|
206
|
+
const tools = bar.menuline({caption:'Advanced tools', icon:'list', labelPosition:'tooltip', node_label:'advancedTools'}).menu();
|
|
166
207
|
tools.menuline({command:'grid:lineNumbers', node_label:'lineNumbers'});
|
|
167
208
|
if (exportFormats.length) exportMenu(tools);
|
|
168
209
|
if (printRows) tools.menuline({command:'grid:printRows', node_label:'printRows'});
|
|
169
210
|
}
|
|
170
211
|
if (gridsemaphore) bar.menuline({group:true, node_label:'semaphore'}).editingStatus();
|
|
171
212
|
if (chart !== false) {
|
|
172
|
-
bar.menuline({caption:'Chart', icon:'
|
|
213
|
+
bar.menuline({caption:'Chart', icon:'chart', labelPosition:'tooltip', node_label:'chart', action:"this.SET('._chart.open',true)"});
|
|
173
214
|
const window = frame.center.floatingPane({title:'Chart', open:'^._chart.open', width:'820px', height:'560px',
|
|
174
215
|
movable:true, resizable:true, maximizable:true, node_label:'chartWindow'});
|
|
175
216
|
window.frame.center.chartPane({storepath,rowMode,gridId:gridAttrs.nodeId,configpath:'._chart',
|
|
@@ -180,25 +221,35 @@ export class GramlotBuilder extends HtmlBuilder {
|
|
|
180
221
|
|
|
181
222
|
/** Split frameGrid keywords: unprefixed grid parameters go to the grid, `grid_`/`frame_` force any attribute. */
|
|
182
223
|
frameGridRoute(attrs) {
|
|
183
|
-
|
|
224
|
+
return this.frameRoute(attrs, {owner:'frameGrid', tag:'grid', prefix:'grid_', composed:FRAME_GRID_COMPOSED, parameters:FRAME_GRID_PARAMETERS});
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Split the keywords of a frame composite between the frame and its central `tag`. Unprefixed parameters
|
|
229
|
+
* of `tag` go to it; `prefix` and `frame_` force any attribute. `composed` names are set by the composite;
|
|
230
|
+
* `parameters` are its own keywords.
|
|
231
|
+
*/
|
|
232
|
+
frameRoute(attrs, {owner, tag, prefix, composed, parameters = new Set()}) {
|
|
233
|
+
const declared = name => new Set(this.schema[name].attributes.parameters.filter(parameter => !parameter.kind.startsWith('var_')).map(parameter => parameter.name));
|
|
184
234
|
const source = new Set([...FRAMEWORK_ATTRIBUTES, ...META_ATTRS]);
|
|
185
|
-
const
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
235
|
+
const childNames = declared(tag), frameNames = declared('framePane');
|
|
236
|
+
// A declared parameter family (grid selected_<field>); most elements declare none.
|
|
237
|
+
const family = this.schema[tag]._meta.parameterPattern, pattern = family ? new RegExp(family) : null;
|
|
238
|
+
// A name the frame also accepts stays on the frame unless forced with the prefix.
|
|
239
|
+
const routed = name => (childNames.has(name) || Boolean(pattern?.test(name))) && !frameNames.has(name) && !source.has(name)
|
|
240
|
+
&& !composed.has(name) && !parameters.has(name);
|
|
241
|
+
const frame = {}, child = {};
|
|
191
242
|
for (const [key, value] of Object.entries(attrs)) {
|
|
192
243
|
let name, target;
|
|
193
|
-
if (key.startsWith(
|
|
194
|
-
name = key.slice(
|
|
195
|
-
if (
|
|
244
|
+
if (key.startsWith(prefix)) {
|
|
245
|
+
name = key.slice(prefix.length); target = child;
|
|
246
|
+
if (composed.has(name)) throw new TypeError(`${owner}: '${key}' is composed by ${owner}`);
|
|
196
247
|
} else if (key.startsWith('frame_')) { name = key.slice('frame_'.length); target = frame; }
|
|
197
|
-
else { name = key; target = routed(key) ?
|
|
198
|
-
if (Object.hasOwn(target, name)) throw new TypeError(
|
|
248
|
+
else { name = key; target = routed(key) ? child : frame; }
|
|
249
|
+
if (Object.hasOwn(target, name)) throw new TypeError(`${owner}: '${name}' is given twice`);
|
|
199
250
|
target[name] = value;
|
|
200
251
|
}
|
|
201
|
-
return [frame,
|
|
252
|
+
return [frame, child];
|
|
202
253
|
}
|
|
203
254
|
|
|
204
255
|
/** Tag prefixes of the parent dialects, from the `_name` of the classes above GramlotBuilder. */
|
package/src/builder/source.js
CHANGED
|
@@ -14,7 +14,8 @@ const CODE_ATTRIBUTES = {
|
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
// The control attributes of `remote`, written on the node as they are; every other parameter becomes `remote_<k>`.
|
|
17
|
-
const REMOTE_CONTROLS = ['_cachedRemote', '_if', '_else', '_onRemote', '_onCalling', '
|
|
17
|
+
const REMOTE_CONTROLS = ['_cachedRemote', '_if', '_else', '_onRemote', '_onCalling', '_waitingMessage', '_delay', '_timing',
|
|
18
|
+
'_userChanges'];
|
|
18
19
|
// The inline code attributes of any node whose `remote` is a string.
|
|
19
20
|
const REMOTE_CODE_ATTRIBUTES = ['_if', '_else', '_onRemote', '_onCalling'];
|
|
20
21
|
|
|
@@ -204,6 +205,15 @@ export function stringHash(text) {
|
|
|
204
205
|
return Math.abs(hash);
|
|
205
206
|
}
|
|
206
207
|
|
|
208
|
+
// Resolver captions are data even when their text starts with a pointer symbol.
|
|
209
|
+
export const resolverMenuLines = new WeakSet();
|
|
210
|
+
|
|
211
|
+
function literalMenuField(node, name, value) {
|
|
212
|
+
if (node.nodeTag !== 'menuline') return false;
|
|
213
|
+
if (name === 'caption') return resolverMenuLines.has(node) || typeof value !== 'string' || !value.startsWith('^');
|
|
214
|
+
return ['tooltip','command'].includes(name);
|
|
215
|
+
}
|
|
216
|
+
|
|
207
217
|
/** The nearest node of `bag` whose `childname` is `name`: direct children first, then unnamed children's descendants. */
|
|
208
218
|
function namedChild(bag, name) {
|
|
209
219
|
const nodes = bag.getNodes();
|
|
@@ -288,7 +298,7 @@ export class GramlotBuilderBagNode extends SourceBagNode {
|
|
|
288
298
|
frameRegion(region) {
|
|
289
299
|
if (this.nodeTag !== 'framePane') throw new TypeError('Region accessors require framePane');
|
|
290
300
|
const existing = this.value instanceof SourceBag
|
|
291
|
-
? this.value.getNodes().find(child => child.getAttr('region') === region) : null;
|
|
301
|
+
? this.value.getNodes().find(child => child.nodeTag === 'contentPane' && child.getAttr('region') === region) : null;
|
|
292
302
|
if (existing) return this.builder.wrapSource(existing);
|
|
293
303
|
const attrs = {region, node_label: region};
|
|
294
304
|
if (region !== 'center') Object.assign(attrs, {display: 'flex', flex_direction: ['top', 'bottom'].includes(region) ? 'column' : 'row'});
|
|
@@ -300,6 +310,7 @@ export class GramlotBuilderBagNode extends SourceBagNode {
|
|
|
300
310
|
// The texts of the inline code received with the Source, by the name InlineCompiler uses; null before activation.
|
|
301
311
|
#activatedCode = null;
|
|
302
312
|
#requests = null;
|
|
313
|
+
#watches = new Map();
|
|
303
314
|
|
|
304
315
|
/** The requests of this node (NodeRequests): the request in flight and the waiting call of remote, dataRpc and dataRemote. */
|
|
305
316
|
get requests() {
|
|
@@ -372,7 +383,8 @@ export class GramlotBuilderBagNode extends SourceBagNode {
|
|
|
372
383
|
/**
|
|
373
384
|
* Declare the content of this element as the fragment `name` of a `@source` method: writes
|
|
374
385
|
* `remote = name` and one `remote_<k> = v` per entry of `params` on this node; the control attributes
|
|
375
|
-
* `_cachedRemote`, `_if`, `_else`, `_onRemote`, `_onCalling`, `_delay`, `_timing` and
|
|
386
|
+
* `_cachedRemote`, `_if`, `_else`, `_onRemote`, `_onCalling`, `_waitingMessage`, `_delay`, `_timing` and
|
|
387
|
+
* `_userChanges` are
|
|
376
388
|
* written as they are. Returns this node. `name` is a method name, matched by the name syntax of the
|
|
377
389
|
* page builder (`nameSyntax` of `rootBuilder`), or a `^`/`=` pointer to it; any other name, or another
|
|
378
390
|
* `_` parameter, is a TypeError.
|
|
@@ -405,7 +417,7 @@ export class GramlotBuilderBagNode extends SourceBagNode {
|
|
|
405
417
|
pointers() {
|
|
406
418
|
const datapath = this.getAttr('datapath');
|
|
407
419
|
const dependencies = pointerTransform(datapath) ? pointerDependencies(this, datapath) : new Set();
|
|
408
|
-
const result = super.pointers().filter(([name, pointer]) => !(this
|
|
420
|
+
const result = super.pointers().filter(([name, pointer]) => !literalMenuField(this, name, pointer) && !dependencies.has(name) && !this.#isPathAttribute(name, pointer))
|
|
409
421
|
.map(([name, pointer]) => [name, pointerTransform(pointer)?.pointer ?? pointer]);
|
|
410
422
|
for (const name of dependencies) {
|
|
411
423
|
const value = this.getAttr(name);
|
|
@@ -422,7 +434,7 @@ export class GramlotBuilderBagNode extends SourceBagNode {
|
|
|
422
434
|
runtimeToEvaluate() {
|
|
423
435
|
const items = super.runtimeToEvaluate();
|
|
424
436
|
for (const [name, value] of items) {
|
|
425
|
-
if (this
|
|
437
|
+
if (literalMenuField(this, name, value)) {
|
|
426
438
|
items.set(name, new BagCbResolver(() => value));
|
|
427
439
|
continue;
|
|
428
440
|
}
|
|
@@ -516,21 +528,72 @@ export class GramlotBuilderBagNode extends SourceBagNode {
|
|
|
516
528
|
/**
|
|
517
529
|
* FIRE after `delay` ms. A null path (Q7) is an error at the call, not inside the timer. The timer
|
|
518
530
|
* is tracked on the node's NodeBinding when the node has one, so the close of the node cancels it;
|
|
519
|
-
* the returned function cancels it as well.
|
|
531
|
+
* the returned function cancels it as well. As legacy `fireAfter` (`genro.js:1216`), a call
|
|
532
|
+
* cancels the fire still pending for the same absolute path, whichever node scheduled it: the
|
|
533
|
+
* registry is the page's BindingRuntime. A node without a page runtime has no registry.
|
|
520
534
|
*/
|
|
521
535
|
FIRE_AFTER(path, value = true, delay = 10) {
|
|
522
536
|
this.#requireWritablePath(path);
|
|
523
|
-
const
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
537
|
+
const runtime = this.rootBuilder?.binding ?? null;
|
|
538
|
+
const binding = runtime?.bindingFor(this) ?? null;
|
|
539
|
+
if (runtime) return runtime.fireAfter(this.absDatapath(path), delay, binding, () => this.FIRE(path, value));
|
|
540
|
+
const timer = setTimeout(() => this.FIRE(path, value), delay);
|
|
541
|
+
return () => clearTimeout(timer);
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
/**
|
|
545
|
+
* Legacy `watch` (`gnrdomsource.js:1937`): poll `conditionCb` every `delay` ms (default 200). When it is
|
|
546
|
+
* already true, `action` runs at once; otherwise the first poll that finds it true stops the watch, then
|
|
547
|
+
* runs `action`. A second `watch` with the same `watchId` replaces the first. `action` may be null: a
|
|
548
|
+
* `conditionCb` that works and returns false then runs until `unwatch`. The watches of a node stop when
|
|
549
|
+
* the node closes (the timer is tracked on its NodeBinding, as `FIRE_AFTER`).
|
|
550
|
+
*/
|
|
551
|
+
watch(watchId, conditionCb, action = null, delay = 200) {
|
|
552
|
+
delay = delay || 200;
|
|
553
|
+
this.unwatch(watchId);
|
|
554
|
+
if (conditionCb()) {
|
|
555
|
+
action?.();
|
|
556
|
+
return;
|
|
557
|
+
}
|
|
558
|
+
const binding = this.#openBinding();
|
|
559
|
+
const timer = setInterval(() => {
|
|
560
|
+
if (!conditionCb()) return;
|
|
561
|
+
this.unwatch(watchId);
|
|
562
|
+
action?.();
|
|
528
563
|
}, delay);
|
|
529
|
-
release = binding?.track(() =>
|
|
530
|
-
|
|
531
|
-
|
|
564
|
+
const release = binding?.track(() => clearInterval(timer)) ?? null;
|
|
565
|
+
this.#watches.set(watchId, () => {
|
|
566
|
+
clearInterval(timer);
|
|
532
567
|
release?.();
|
|
533
|
-
};
|
|
568
|
+
});
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
/** Legacy `unwatch` (`gnrdomsource.js:1930`): stop the watch `watchId` of this node; an unknown id does nothing. */
|
|
572
|
+
unwatch(watchId) {
|
|
573
|
+
const stop = this.#watches.get(watchId);
|
|
574
|
+
if (!stop) return;
|
|
575
|
+
this.#watches.delete(watchId);
|
|
576
|
+
stop();
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
/**
|
|
580
|
+
* Legacy `fireNode` (`gnrdomsource.js:179`): run now the provider of this node (`dataFormula`,
|
|
581
|
+
* `dataController`, `dataRpc`, `dataRemote`) with `runKwargs` merged over its arguments, trigger kind
|
|
582
|
+
* `fireNode`. Returns what `invoke` returns (the promise of a `dataRpc`). A node without a provider is
|
|
583
|
+
* an error; a node without an open NodeBinding runs nothing, as a closed provider.
|
|
584
|
+
*/
|
|
585
|
+
fireNode(runKwargs = {}) {
|
|
586
|
+
const binding = this.#openBinding();
|
|
587
|
+
if (binding === null) return undefined;
|
|
588
|
+
const [provider] = binding.providers;
|
|
589
|
+
if (!provider) throw new Error(`fireNode: '${this.label}' has no provider`);
|
|
590
|
+
return provider.invoke({kind: 'fireNode', change: null, runKwargs});
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
/** The open NodeBinding of this node; null for a node outside a Source or without one. */
|
|
594
|
+
#openBinding() {
|
|
595
|
+
if (this.parentBag === null) return null;
|
|
596
|
+
return this.rootBuilder?.binding?.bindingFor(this) ?? null;
|
|
534
597
|
}
|
|
535
598
|
|
|
536
599
|
/**
|