@gramlot/gramlot 0.2.18 → 0.2.19
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 +74 -4
- package/dist/gramlot.min.js +11 -11
- package/package.json +1 -1
- package/src/binding/installation.js +4 -2
- package/src/builder/binding.json +26 -1
- package/src/builder/gramlot-builder.js +10 -0
- package/src/view/button.js +37 -2
package/dist/gramlot.js
CHANGED
|
@@ -22575,7 +22575,7 @@ var binding_default = {
|
|
|
22575
22575
|
name: "binding",
|
|
22576
22576
|
version: null,
|
|
22577
22577
|
title: "Gramlot binding",
|
|
22578
|
-
description: "Data
|
|
22578
|
+
description: "Gramlot Data declarations and the plain HTML button; loaded after the HTML grammar."
|
|
22579
22579
|
},
|
|
22580
22580
|
abstracts: {},
|
|
22581
22581
|
elements: {
|
|
@@ -22942,6 +22942,31 @@ var binding_default = {
|
|
|
22942
22942
|
_meta: {
|
|
22943
22943
|
data_element: true
|
|
22944
22944
|
}
|
|
22945
|
+
},
|
|
22946
|
+
html_button: {
|
|
22947
|
+
doc: "Plain native HTML button without Gramlot click mechanisms.",
|
|
22948
|
+
sub_tags: "a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",
|
|
22949
|
+
parent_tags: null,
|
|
22950
|
+
inherits_from: null,
|
|
22951
|
+
ns: null,
|
|
22952
|
+
attributes: {
|
|
22953
|
+
parameters: [
|
|
22954
|
+
{
|
|
22955
|
+
name: "kwargs",
|
|
22956
|
+
kind: "var_keyword",
|
|
22957
|
+
role: "attribute",
|
|
22958
|
+
annotation: null,
|
|
22959
|
+
has_default: false
|
|
22960
|
+
}
|
|
22961
|
+
],
|
|
22962
|
+
accepts_var_keyword: true,
|
|
22963
|
+
accepts_var_positional: false
|
|
22964
|
+
},
|
|
22965
|
+
node_label: null,
|
|
22966
|
+
collection_key: null,
|
|
22967
|
+
_meta: {
|
|
22968
|
+
render_tag: "button"
|
|
22969
|
+
}
|
|
22945
22970
|
}
|
|
22946
22971
|
}
|
|
22947
22972
|
};
|
|
@@ -23012,6 +23037,9 @@ var DATA_PATH_ATTRIBUTES = {
|
|
|
23012
23037
|
};
|
|
23013
23038
|
var DATA_INLINE_ATTRIBUTES = { dataFormula: "formula", dataController: "script" };
|
|
23014
23039
|
function dataElementError(tag2, attrs) {
|
|
23040
|
+
if (tag2 === "html_button" && Object.keys(attrs).some((name) => ["action", "ask", "_delay", "fire"].includes(name) || name.startsWith("fire_"))) {
|
|
23041
|
+
return "plain HTML button: use button for action, ask, fire or _delay";
|
|
23042
|
+
}
|
|
23015
23043
|
if (Object.hasOwn(attrs, "ask") && tag2 !== "button") return "'ask' is supported on buttons";
|
|
23016
23044
|
if (Object.hasOwn(attrs, "_ask") && !["dataController", "dataFormula", "dataRpc"].includes(tag2)) return "'_ask' requires a controller, formula or RPC";
|
|
23017
23045
|
if (["dataSetter", "dataRemote"].includes(tag2) && Object.keys(attrs).some((name) => name.startsWith("subscribe_") || name.startsWith("selfsubscribe_"))) {
|
|
@@ -23128,6 +23156,15 @@ var GramlotBuilder = class _GramlotBuilder extends HtmlBuilder {
|
|
|
23128
23156
|
if (error) throw new Error(`${node.nodeTag} '${node.label}': ${error}`);
|
|
23129
23157
|
return super.validateNode(node, options);
|
|
23130
23158
|
}
|
|
23159
|
+
/** Both button declarations occupy the native button slot in HTML content models. */
|
|
23160
|
+
_validateChildren(parentTag, info, tags, includeMinimum) {
|
|
23161
|
+
return super._validateChildren(
|
|
23162
|
+
parentTag,
|
|
23163
|
+
info,
|
|
23164
|
+
tags.map((tag2) => tag2 === "html_button" ? "button" : tag2),
|
|
23165
|
+
includeMinimum
|
|
23166
|
+
);
|
|
23167
|
+
}
|
|
23131
23168
|
/** Custom elements are outside the native HTML child catalogue, as components are. */
|
|
23132
23169
|
_countsForGrammar(info) {
|
|
23133
23170
|
return info !== this.schema.webcomponent && super._countsForGrammar(info);
|
|
@@ -23878,10 +23915,12 @@ var AskDialog = class {
|
|
|
23878
23915
|
var ButtonBinding = class _ButtonBinding {
|
|
23879
23916
|
#binding;
|
|
23880
23917
|
#record;
|
|
23881
|
-
|
|
23918
|
+
#cancelDelay = null;
|
|
23919
|
+
#pendingCount = 0;
|
|
23920
|
+
/** The binding of a Gramlot button; html_button remains native despite its DOM tag. */
|
|
23882
23921
|
static for(binding, record2) {
|
|
23883
23922
|
const element = record2.element;
|
|
23884
|
-
if (element?.namespaceURI !== XHTML_NS || element.localName !== "button") return null;
|
|
23923
|
+
if (binding.node.nodeTag !== "button" || element?.namespaceURI !== XHTML_NS || element.localName !== "button") return null;
|
|
23885
23924
|
return new _ButtonBinding(binding, record2);
|
|
23886
23925
|
}
|
|
23887
23926
|
constructor(binding, record2) {
|
|
@@ -23940,6 +23979,7 @@ var ButtonBinding = class _ButtonBinding {
|
|
|
23940
23979
|
}
|
|
23941
23980
|
detach() {
|
|
23942
23981
|
this.element.removeEventListener("click", this);
|
|
23982
|
+
this.#cancelDelay?.();
|
|
23943
23983
|
}
|
|
23944
23984
|
handleEvent(event) {
|
|
23945
23985
|
this.onClick(event);
|
|
@@ -23956,6 +23996,36 @@ var ButtonBinding = class _ButtonBinding {
|
|
|
23956
23996
|
event.stopPropagation();
|
|
23957
23997
|
if (this.element.disabled) return;
|
|
23958
23998
|
const counter = this.binding.countClick();
|
|
23999
|
+
let owner = this.node;
|
|
24000
|
+
while (owner && owner.getAttr("_delay") == null) owner = owner.parentNode;
|
|
24001
|
+
const delay = owner ? owner.builder.runtimeValues(owner)[1]._delay : 0;
|
|
24002
|
+
if (delay > 0) {
|
|
24003
|
+
const count = this.#pendingCount + 1;
|
|
24004
|
+
this.#cancelDelay?.();
|
|
24005
|
+
this.#pendingCount = count;
|
|
24006
|
+
const timer = setTimeout(() => {
|
|
24007
|
+
release();
|
|
24008
|
+
this.#cancelDelay = null;
|
|
24009
|
+
this.#pendingCount = 0;
|
|
24010
|
+
this.#execute(event, count);
|
|
24011
|
+
}, delay);
|
|
24012
|
+
const release = this.binding.track(() => this.#cancelDelay?.());
|
|
24013
|
+
this.#cancelDelay = () => {
|
|
24014
|
+
clearTimeout(timer);
|
|
24015
|
+
release();
|
|
24016
|
+
this.#cancelDelay = null;
|
|
24017
|
+
this.#pendingCount = 0;
|
|
24018
|
+
};
|
|
24019
|
+
return;
|
|
24020
|
+
}
|
|
24021
|
+
this.#cancelDelay?.();
|
|
24022
|
+
return this.#execute(event, counter);
|
|
24023
|
+
}
|
|
24024
|
+
/** Deliver the last event once; arguments are read when the mechanism executes. */
|
|
24025
|
+
#execute(event, counter) {
|
|
24026
|
+
if (this.binding.closed || this.element.disabled) return;
|
|
24027
|
+
const mechanism = this.mechanism;
|
|
24028
|
+
if (!mechanism) return;
|
|
23959
24029
|
const node = this.node;
|
|
23960
24030
|
const modifiers = eventToString(event);
|
|
23961
24031
|
if (mechanism === "controller") {
|
|
@@ -24467,7 +24537,7 @@ function requireProviderAttributes(node) {
|
|
|
24467
24537
|
}
|
|
24468
24538
|
return;
|
|
24469
24539
|
}
|
|
24470
|
-
const name = PROVIDER_ATTRIBUTES.find(isSet);
|
|
24540
|
+
const name = PROVIDER_ATTRIBUTES.find((name2) => isSet(name2) && !(name2 === "_delay" && !node._getMeta("data_element") && node.nodeTag !== "html_button"));
|
|
24471
24541
|
if (!name) return;
|
|
24472
24542
|
const tags = LIFECYCLE_ATTRIBUTES.includes(name) ? "dataFormula, dataController and dataRpc" : "dataFormula, dataController, dataRpc and dataRemote";
|
|
24473
24543
|
throw new Error(`${node.nodeTag ?? "fragment"} '${node.label}': '${name}' is allowed only on ${tags}`);
|