Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dist/SmarkForm.esm.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/SmarkForm.esm.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/SmarkForm.umd.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/SmarkForm.umd.js.map

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions src/types/input.type.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ export class input extends form {
const me = this;
if (me.isSingleton) return; // (Only for real field)
me.targetFieldNode.value = value;
if (me._maskInstance != null) {
me.targetFieldNode.dispatchEvent(new Event("input", {bubbles: true}));
};
};//}}}
async render() {//{{{
const me = this;
Expand Down Expand Up @@ -200,6 +203,11 @@ export class input extends form {
// Keep fallback working when encoding is json and value attribute is not set.
// (and don't expetct <opton> inner text to be JSON)
retv = JSON.stringify(nodeFld.options[nodeFld.selectedIndex].text);
} else if (
me._maskInstance != null
&& me._maskInstance.unmaskedValue !== undefined
) {
retv = me._maskInstance.unmaskedValue;
} else {
retv = nodeFld.value;
};
Expand Down Expand Up @@ -263,4 +271,26 @@ export class input extends form {
return ! value.trim().length;
// Native input's value type is always a string.
};//}}}
mask(callback) {//{{{
const me = this;
// For singletons, delegate to the inner field so _maskInstance lives
// where export() reads it from.
if (me.isSingleton) {
me.children[""].mask(callback);
return me;
};
const fld = me.targetFieldNode;
if (
fld
&& fld.tagName === "INPUT"
) {
const currentType = (fld.getAttribute("type") || "text").toLowerCase();
if (currentType !== "text") {
me._originalType = currentType;
fld.setAttribute("type", "text");
};
};
me._maskInstance = callback(fld) ?? null;
return me;
};//}}}
};
Loading