@gramlot/gramlot 0.3.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/gramlot.js +158 -70
- package/dist/gramlot.min.js +42 -24
- package/package.json +1 -1
- package/src/builder/source.js +1 -0
- package/src/components/border-container.js +399 -0
- package/src/components/choice-editor.js +3 -1
- package/src/components/container.js +25 -0
- package/src/components/layout.js +6 -23
- package/src/components/popup.js +3 -3
- package/src/components/registry.js +5 -3
- package/src/components/selected-container.js +289 -0
- package/src/index-page-runtime.d.ts +2 -1
- package/src/index-page-runtime.js +94 -50
- package/src/index-page-styles.js +1 -1
- package/src/renderer/attributes.js +4 -1
- package/src/renderer/gramlot-renderer.js +6 -3
- package/src/view/html.js +30 -6
- package/themes/gramlot-base/theme.css +3 -2
- package/themes/joanna/theme.css +9 -0
- package/themes/mimi/theme.css +9 -0
- package/tools/gramlot-tools-inspector.js +549 -35
- package/tools/inspector-agent.js +259 -5
|
@@ -42,7 +42,9 @@ export class GramlotRenderer extends GramlotHtmlRenderer {
|
|
|
42
42
|
this._binding = binding;
|
|
43
43
|
this.source = source;
|
|
44
44
|
this.destination = destination;
|
|
45
|
-
this.html = new HtmlElement({metadataAttributes: ['__ref']
|
|
45
|
+
this.html = new HtmlElement({metadataAttributes: ['__ref'],
|
|
46
|
+
invokeScript: (node, name, code, keywords) => this.inlineCompiler.compile(
|
|
47
|
+
node, name, code, node.parentNode._getMeta('gramlot_component').childParameters[name].inline)(keywords)});
|
|
46
48
|
this.records = new Map();
|
|
47
49
|
this.references = new References(source);
|
|
48
50
|
this.pending = [];
|
|
@@ -533,9 +535,10 @@ export class GramlotRenderer extends GramlotHtmlRenderer {
|
|
|
533
535
|
/** Component parameters use resolved Source values, before HTML-only filtering (e.g. validate_*). */
|
|
534
536
|
componentAttributes(node, attrs) {
|
|
535
537
|
const component = node._getMeta('gramlot_component');
|
|
536
|
-
|
|
538
|
+
const childParameters = node.parentNode?._getMeta('gramlot_component')?.childParameters;
|
|
539
|
+
if (!component && !childParameters) return attrs;
|
|
537
540
|
const resolved = this.#resolvedAttributes.get(node);
|
|
538
|
-
const parameters = Object.fromEntries([...new Set([...Object.keys(component
|
|
541
|
+
const parameters = Object.fromEntries([...new Set([...Object.keys(component?.parameters ?? {}), ...Object.keys(childParameters ?? {}), ...Object.keys(resolved).filter(name => name.startsWith('validate_'))])]
|
|
539
542
|
.filter(name => Object.hasOwn(resolved, name)).map(name => [name, resolved[name]]));
|
|
540
543
|
return {...attrs, ...parameters};
|
|
541
544
|
}
|
package/src/view/html.js
CHANGED
|
@@ -36,7 +36,8 @@ function domPropertyName(name) {
|
|
|
36
36
|
* names and style arrive adapted by the renderers (GramlotHtmlRenderer, GramlotSvgRenderer).
|
|
37
37
|
*/
|
|
38
38
|
export class HtmlElement {
|
|
39
|
-
constructor({metadataAttributes = []} = {}) {
|
|
39
|
+
constructor({metadataAttributes = [], invokeScript = null} = {}) {
|
|
40
|
+
this.invokeScript = invokeScript;
|
|
40
41
|
this.metadataAttributes = new Set([...META_ATTRS, '_text', ...metadataAttributes]);
|
|
41
42
|
}
|
|
42
43
|
|
|
@@ -90,6 +91,17 @@ export class HtmlElement {
|
|
|
90
91
|
return node.getRelativeData('.');
|
|
91
92
|
};
|
|
92
93
|
}
|
|
94
|
+
if (meta.gramlot_component?.sourceContext) {
|
|
95
|
+
element.setSourceContext({
|
|
96
|
+
publish: (topic, payload) => node.publish(topic, payload),
|
|
97
|
+
writeParameter: (name, value) => {
|
|
98
|
+
const pointer = node.getAttr(name);
|
|
99
|
+
if (node.pointerType(pointer) === '^' && !Object.is(node.getRelativeData(pointer.slice(1)), value)) {
|
|
100
|
+
node.setRelativeData(pointer.slice(1), value);
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
}
|
|
93
105
|
const text = document.createTextNode(this.text(node));
|
|
94
106
|
if (namespace !== XHTML_NS || !meta.void) element.append(text);
|
|
95
107
|
const record = {element, text, tag};
|
|
@@ -119,13 +131,25 @@ export class HtmlElement {
|
|
|
119
131
|
const isHtml = element.namespaceURI === XHTML_NS;
|
|
120
132
|
const renderAttributes = this.definition(node).meta.render_attributes ?? {};
|
|
121
133
|
const previous = record.attrs ?? {};
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
134
|
+
const adapt = values => {
|
|
135
|
+
requireNoScriptAttributes(node, values, node.builder.constructor.dialectPrefixes);
|
|
136
|
+
requireStyleClassAttributes(node, values, node.builder.constructor.dialectPrefixes);
|
|
137
|
+
return node.builder.renderer_html.adaptAttrs(values);
|
|
138
|
+
};
|
|
139
|
+
const parent = node.parentNode;
|
|
140
|
+
if (parent?._getMeta('gramlot_component')?.childParameters) {
|
|
141
|
+
const Parent = element.ownerDocument.defaultView.customElements.get(parent._getMeta('render_tag'));
|
|
142
|
+
attrs = Parent.projectChild(element, attrs, {
|
|
143
|
+
adapt,
|
|
144
|
+
invoke: (name, code, keywords) => this.invokeScript(node, name, code, keywords),
|
|
145
|
+
publish: (topic, payload) => node.publish(topic, payload),
|
|
146
|
+
publishParent: (topic, payload) => parent.publish(topic, payload),
|
|
147
|
+
remove: () => node.parentBag.popNode(node.label),
|
|
127
148
|
});
|
|
128
149
|
}
|
|
150
|
+
if (this.definition(node).meta.gramlot_component) {
|
|
151
|
+
attrs = element.projectAttributes(attrs, adapt);
|
|
152
|
+
}
|
|
129
153
|
attrs = Object.fromEntries(sourceAttributeItems({...attrs, ...renderAttributes}));
|
|
130
154
|
const controlled = ControlAdapter.classFor(element, attrs) !== null;
|
|
131
155
|
if (textValue === DEFAULT_TEXT) textValue = this.text(node);
|
|
@@ -271,12 +271,13 @@
|
|
|
271
271
|
|
|
272
272
|
/* Interaction density is independent of the selected color/profile theme. */
|
|
273
273
|
@layer gramlot.touch {
|
|
274
|
-
:root[data-gramlot-touch="
|
|
274
|
+
:root[data-gramlot-touch="off"] {--gramlot-drawer-reveal:0;}
|
|
275
|
+
:root[data-gramlot-touch="on"] {--gramlot-drawer-reveal:1;--gramlot-touch-target:44px; --gramlot-field-height:44px; --gramlot-field-font-size:16px;
|
|
275
276
|
--gramlot-field-padding:8px 10px; --gramlot-field-line-height:1.35;
|
|
276
277
|
--gramlot-label-size:14px; --gramlot-label-gap:6px; --gramlot-space-2:10px;
|
|
277
278
|
--gramlot-calendar-width:322px; --gramlot-choice-toggle-width:44px;}
|
|
278
279
|
@media (pointer: coarse) {
|
|
279
|
-
:root:not([data-gramlot-touch="off"]) {--gramlot-touch-target:44px; --gramlot-field-height:44px; --gramlot-field-font-size:16px;
|
|
280
|
+
:root:not([data-gramlot-touch="off"]) {--gramlot-drawer-reveal:1;--gramlot-touch-target:44px; --gramlot-field-height:44px; --gramlot-field-font-size:16px;
|
|
280
281
|
--gramlot-field-padding:8px 10px; --gramlot-field-line-height:1.35;
|
|
281
282
|
--gramlot-label-size:14px; --gramlot-label-gap:6px; --gramlot-space-2:10px;
|
|
282
283
|
--gramlot-calendar-width:322px; --gramlot-choice-toggle-width:44px;}
|
package/themes/joanna/theme.css
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
/* Gramlot adaptation of legacy joanna; load after Base and Compact. */
|
|
2
2
|
@layer gramlot.tokens {
|
|
3
3
|
:root {
|
|
4
|
+
--gramlot-tab-height: 26px;
|
|
5
|
+
--gramlot-tab-padding: 3px 10px;
|
|
6
|
+
--gramlot-tab-radius: 6px;
|
|
7
|
+
--gramlot-tab-gap: 2px;
|
|
8
|
+
--gramlot-tab-strip-padding: 3px;
|
|
9
|
+
--gramlot-tab-background: var(--gramlot-background);
|
|
10
|
+
--gramlot-tab-selected-background: var(--gramlot-surface);
|
|
11
|
+
--gramlot-tab-selected-color: var(--gramlot-ink);
|
|
12
|
+
--gramlot-tab-border: var(--gramlot-border);
|
|
4
13
|
--gramlot-background: #F2F2F7;
|
|
5
14
|
--gramlot-surface: #FFFFFF;
|
|
6
15
|
--gramlot-surface-subtle: #F2F2F7;
|
package/themes/mimi/theme.css
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
/* Gramlot adaptation of legacy mimi; load after Base and Compact. */
|
|
2
2
|
@layer gramlot.tokens {
|
|
3
3
|
:root {
|
|
4
|
+
--gramlot-tab-height: 24px;
|
|
5
|
+
--gramlot-tab-padding: 3px 10px;
|
|
6
|
+
--gramlot-tab-radius: 3px;
|
|
7
|
+
--gramlot-tab-gap: 2px;
|
|
8
|
+
--gramlot-tab-strip-padding: 3px;
|
|
9
|
+
--gramlot-tab-background: var(--gramlot-background);
|
|
10
|
+
--gramlot-tab-selected-background: var(--gramlot-surface);
|
|
11
|
+
--gramlot-tab-selected-color: var(--gramlot-ink);
|
|
12
|
+
--gramlot-tab-border: var(--gramlot-border);
|
|
4
13
|
--gramlot-background: #EDEEF0;
|
|
5
14
|
--gramlot-surface: #F5F5F6;
|
|
6
15
|
--gramlot-surface-subtle: #E0E1E3;
|