@gramlot/gramlot 0.3.3 → 0.3.4
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 +9 -6
- package/dist/gramlot.min.js +13 -13
- package/package.json +1 -1
- package/src/components/border-container.js +13 -4
- package/src/view/html.js +12 -7
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@ const borderRegions = new WeakMap();
|
|
|
8
8
|
const horizontal = side => side === 'top' || side === 'bottom';
|
|
9
9
|
|
|
10
10
|
/** Resolved Source attributes, not DOM scraping, supply the parent's region contract. */
|
|
11
|
-
function projectBorderChild(element, attrs, {adapt, invoke, publish, publishParent}) {
|
|
11
|
+
function projectBorderChild(element, attrs, {adapt, invoke, publish, publishParent, writeParameter}) {
|
|
12
12
|
const rest = {...attrs}, splitter = {}, drawer = {};
|
|
13
13
|
for (const [name, value] of Object.entries(rest)) {
|
|
14
14
|
for (const [prefix, group] of [['splitter_', splitter], ['drawer_', drawer]]) {
|
|
@@ -24,7 +24,14 @@ function projectBorderChild(element, attrs, {adapt, invoke, publish, publishPare
|
|
|
24
24
|
if (![undefined, null, false, true, 'close'].includes(rest.drawer)) throw new TypeError('drawer must be true, false or close');
|
|
25
25
|
const probe = element.ownerDocument.createElement('div');
|
|
26
26
|
probe.style.cssText = rest.style ?? '';
|
|
27
|
-
const
|
|
27
|
+
const dimension = horizontal(region) ? 'height' : 'width';
|
|
28
|
+
const numeric = typeof rest[dimension] === 'number';
|
|
29
|
+
if (numeric) {
|
|
30
|
+
if (!Number.isFinite(rest[dimension]) || rest[dimension] < 0) throw new TypeError('Border numeric dimensions must be finite nonnegative pixels');
|
|
31
|
+
probe.style[dimension] = `${rest[dimension]}px`;
|
|
32
|
+
}
|
|
33
|
+
const size = probe.style[dimension];
|
|
34
|
+
delete rest.width; delete rest.height;
|
|
28
35
|
// The region owns its authored size; its child fills the allotted viewport.
|
|
29
36
|
probe.style.width = '100%'; probe.style.height = '100%';
|
|
30
37
|
rest.style = probe.style.cssText;
|
|
@@ -38,7 +45,8 @@ function projectBorderChild(element, attrs, {adapt, invoke, publish, publishPare
|
|
|
38
45
|
if (drawerAttrs.style != null) drawerAttrs.style = drawerProbe.style.cssText;
|
|
39
46
|
borderRegions.set(element, {region, size, min, max, splitter: rest.splitter === true,
|
|
40
47
|
drawer: rest.drawer, hidden: rest.hidden === true,
|
|
41
|
-
splitterAttrs: adapt(splitter), drawerAttrs, label, icon, minimize,
|
|
48
|
+
splitterAttrs: adapt(splitter), drawerAttrs, label, icon, minimize,
|
|
49
|
+
writeParameter: size => { if (numeric) writeParameter(dimension, size); }, notifications: {
|
|
42
50
|
closableChange: payload => publish('closable_change', payload),
|
|
43
51
|
splitterResize: payload => publishParent('splitter_resize', payload),
|
|
44
52
|
},
|
|
@@ -71,7 +79,7 @@ export const ContentPane = defineComponent({
|
|
|
71
79
|
|
|
72
80
|
export const BorderContainer = defineComponent({
|
|
73
81
|
name: 'borderContainer', tag: 'gramlot-border-container', base: Container, subTags: '*',
|
|
74
|
-
childParameters: {region: {required: true, enum: REGIONS, unique: true}, drawer_onclick: {inline: ['evt', 'show']}},
|
|
82
|
+
childParameters: {region: {required: true, enum: REGIONS, unique: true}, width: {}, height: {}, drawer_onclick: {inline: ['evt', 'show']}},
|
|
75
83
|
parameters: {
|
|
76
84
|
design: {dtype: 'T', default: 'headline', binding: 'read', enum: ['headline', 'sidebar']},
|
|
77
85
|
persist: {dtype: 'B', default: false, binding: 'read'},
|
|
@@ -326,6 +334,7 @@ export const BorderContainer = defineComponent({
|
|
|
326
334
|
const available = Math.max(0, (horizontal(side) ? box.height : box.width) - this.#extent(opposite));
|
|
327
335
|
const size = Math.max(Math.min(c.min, available), Math.min(desired, c.max, available));
|
|
328
336
|
state.size = `${size}px`; this.#render(side);
|
|
337
|
+
c.writeParameter(size);
|
|
329
338
|
}
|
|
330
339
|
#keyResize(side, evt) {
|
|
331
340
|
const state = this.#regions.get(side);
|
package/src/view/html.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {SourceBag, META_ATTRS, resolveRenderTag, sourceAttributeItems, SvgBuilder} from '@genrojs/builders';
|
|
1
|
+
import {SourceBag, META_ATTRS, resolveRenderTag, sourceAttributeItems, SvgBuilder, pointerTransform} from '@genrojs/builders';
|
|
2
2
|
import {ControlAdapter} from './controls.js';
|
|
3
3
|
import {SVG_NS, XHTML_NS} from '../renderer/attributes.js';
|
|
4
4
|
import {requireNoScriptAttributes, requireStyleClassAttributes} from '../renderer/attributes.js';
|
|
@@ -94,12 +94,7 @@ export class HtmlElement {
|
|
|
94
94
|
if (meta.gramlot_component?.sourceContext) {
|
|
95
95
|
element.setSourceContext({
|
|
96
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
|
-
},
|
|
97
|
+
writeParameter: (name, value) => this.writeParameter(node, name, value),
|
|
103
98
|
});
|
|
104
99
|
}
|
|
105
100
|
const text = document.createTextNode(this.text(node));
|
|
@@ -115,6 +110,15 @@ export class HtmlElement {
|
|
|
115
110
|
&& record.element.namespaceURI === namespace;
|
|
116
111
|
}
|
|
117
112
|
|
|
113
|
+
/** Write a component interaction through a plain reactive Source pointer. */
|
|
114
|
+
writeParameter(node, name, value) {
|
|
115
|
+
const pointer = node.getAttr(name);
|
|
116
|
+
if (node.pointerType(pointer) === '^' && !pointerTransform(pointer)
|
|
117
|
+
&& !Object.is(node.getRelativeData(pointer.slice(1)), value)) {
|
|
118
|
+
node.setRelativeData(pointer.slice(1), value);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
118
122
|
compose(record, text, children) {
|
|
119
123
|
record.text.data = text ?? '';
|
|
120
124
|
for (const child of children) record.element.append(child);
|
|
@@ -144,6 +148,7 @@ export class HtmlElement {
|
|
|
144
148
|
invoke: (name, code, keywords) => this.invokeScript(node, name, code, keywords),
|
|
145
149
|
publish: (topic, payload) => node.publish(topic, payload),
|
|
146
150
|
publishParent: (topic, payload) => parent.publish(topic, payload),
|
|
151
|
+
writeParameter: (name, value) => this.writeParameter(node, name, value),
|
|
147
152
|
remove: () => node.parentBag.popNode(node.label),
|
|
148
153
|
});
|
|
149
154
|
}
|