@optionfactory/ful 0.47.0 → 0.48.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/dist/ful.iife.js +53 -40
- package/dist/ful.iife.js.map +1 -1
- package/dist/ful.iife.min.js +1 -1
- package/dist/ful.iife.min.js.map +1 -1
- package/dist/ful.min.mjs +1 -1
- package/dist/ful.min.mjs.map +1 -1
- package/dist/ful.mjs +51 -40
- package/dist/ful.mjs.map +1 -1
- package/package.json +1 -1
package/dist/ful.iife.js
CHANGED
|
@@ -668,6 +668,38 @@ var ful = (function (exports) {
|
|
|
668
668
|
}
|
|
669
669
|
}
|
|
670
670
|
|
|
671
|
+
class TemplateRegistry {
|
|
672
|
+
#idToFragment = {};
|
|
673
|
+
#idToTemplate = {};
|
|
674
|
+
#ec;
|
|
675
|
+
put(k, fragment) {
|
|
676
|
+
if (this.#ec) {
|
|
677
|
+
this.#idToTemplate[k] = ftl.Template.fromFragment(fragment, ec);
|
|
678
|
+
return;
|
|
679
|
+
}
|
|
680
|
+
this.#idToFragment[k] = fragment;
|
|
681
|
+
}
|
|
682
|
+
get(k) {
|
|
683
|
+
if (!this.#ec) {
|
|
684
|
+
throw new Error("evaluationContext is not configured");
|
|
685
|
+
}
|
|
686
|
+
const tpl = this.#idToTemplate[k];
|
|
687
|
+
if (!tpl) {
|
|
688
|
+
throw new Error(`missing template: '${k}'`);
|
|
689
|
+
}
|
|
690
|
+
return tpl;
|
|
691
|
+
}
|
|
692
|
+
configure(ec) {
|
|
693
|
+
this.#ec = ec;
|
|
694
|
+
for (const [k, fragment] of Object.entries(this.#idToFragment)) {
|
|
695
|
+
delete this.#idToFragment[k];
|
|
696
|
+
this.#idToTemplate[k] = ftl.Template.fromFragment(fragment, ec);
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
const templates = new TemplateRegistry();
|
|
702
|
+
|
|
671
703
|
class UpgradeQueue {
|
|
672
704
|
#q = [];
|
|
673
705
|
constructor() {
|
|
@@ -921,11 +953,7 @@ var ful = (function (exports) {
|
|
|
921
953
|
}
|
|
922
954
|
}
|
|
923
955
|
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
});
|
|
927
|
-
|
|
928
|
-
const template$1 = globalThis.ful_input_template || ftl.Template.fromHtml(`
|
|
956
|
+
templates.put('ful-input', Fragments.fromHtml(`
|
|
929
957
|
<label data-tpl-for="id" class="form-label">{{{{ slotted.default }}}}</label>
|
|
930
958
|
<div class="input-group">
|
|
931
959
|
<span data-tpl-if="slotted.ibefore" class="input-group-text">{{{{ slotted.ibefore }}}}</span>
|
|
@@ -935,11 +963,10 @@ var ful = (function (exports) {
|
|
|
935
963
|
<span data-tpl-if="slotted.iafter" class="input-group-text">{{{{ slotted.iafter }}}}</span>
|
|
936
964
|
</div>
|
|
937
965
|
<ful-field-error data-tpl-if="name" data-tpl-field="name"></ful-field-error>
|
|
938
|
-
|
|
966
|
+
`));
|
|
939
967
|
|
|
940
|
-
const renderInput = (el) => {
|
|
941
|
-
const slotted = Slots.from(el);
|
|
942
968
|
|
|
969
|
+
const makeInputFragment = (el, slotted) => {
|
|
943
970
|
const input = el.input = slotted.input = slotted.input || (() => {
|
|
944
971
|
const el = document.createElement("input");
|
|
945
972
|
el.classList.add("form-control");
|
|
@@ -953,18 +980,14 @@ var ful = (function (exports) {
|
|
|
953
980
|
Attributes.defaultValue(slotted.input, "type", "text");
|
|
954
981
|
Attributes.defaultValue(slotted.input, "placeholder", " ");
|
|
955
982
|
const name = el.getAttribute('name');
|
|
956
|
-
|
|
983
|
+
return templates.get('ful-input').render(el, { id, name, slotted });
|
|
957
984
|
};
|
|
958
985
|
|
|
959
|
-
class StatelessInput extends ParsedElement() {
|
|
960
|
-
render() {
|
|
961
|
-
renderInput(this);
|
|
962
|
-
}
|
|
963
|
-
}
|
|
964
|
-
|
|
965
986
|
class Input extends ParsedElement([], ['value']) {
|
|
966
987
|
render() {
|
|
967
|
-
|
|
988
|
+
const slotted = Slots.from(el);
|
|
989
|
+
const fragment = makeInputFragment(this, slotted);
|
|
990
|
+
this.replaceChildren(fragment);
|
|
968
991
|
}
|
|
969
992
|
get value() {
|
|
970
993
|
return this.input.value;
|
|
@@ -978,11 +1001,8 @@ var ful = (function (exports) {
|
|
|
978
1001
|
* <script src="tom-select.complete.js"></script>
|
|
979
1002
|
* <link href="tom-select.bootstrap5.css" rel="stylesheet" />
|
|
980
1003
|
*/
|
|
981
|
-
const ful_select_ec = globalThis.ec || ftl.EvaluationContext.configure({
|
|
982
|
-
|
|
983
|
-
});
|
|
984
1004
|
|
|
985
|
-
|
|
1005
|
+
templates.put('ful-select', Fragments.fromHtml(`
|
|
986
1006
|
<label data-tpl-for="tsId" class="form-label">{{{{ slotted.default }}}}</label>
|
|
987
1007
|
{{{{ input }}}}
|
|
988
1008
|
<div class="input-group">
|
|
@@ -993,7 +1013,7 @@ var ful = (function (exports) {
|
|
|
993
1013
|
<span data-tpl-if="slotted.iafter" class="input-group-text">{{{{ slotted.iafter }}}}</span>
|
|
994
1014
|
</div>
|
|
995
1015
|
<ful-field-error data-tpl-if="name" data-tpl-field="name"></ful-field-error>
|
|
996
|
-
|
|
1016
|
+
`));
|
|
997
1017
|
|
|
998
1018
|
|
|
999
1019
|
class Select extends ParsedElement([], ["value"]) {
|
|
@@ -1059,7 +1079,7 @@ var ful = (function (exports) {
|
|
|
1059
1079
|
} : {}, tsDefaultConfig, this.tsConfig));
|
|
1060
1080
|
//we remove the input to move it
|
|
1061
1081
|
input.remove();
|
|
1062
|
-
|
|
1082
|
+
templates.get('ful-select').renderTo(this, { id, tsId, name, input, slotted });
|
|
1063
1083
|
}
|
|
1064
1084
|
set value(v) {
|
|
1065
1085
|
(async () => {
|
|
@@ -1075,11 +1095,7 @@ var ful = (function (exports) {
|
|
|
1075
1095
|
}
|
|
1076
1096
|
}
|
|
1077
1097
|
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
});
|
|
1081
|
-
|
|
1082
|
-
const ful_radiougroup_template_ = globalThis.ful_radiogroup_template || ftl.Template.fromHtml(`
|
|
1098
|
+
templates.put('ful-radio-group', Fragments.fromHtml(`
|
|
1083
1099
|
<fieldset>
|
|
1084
1100
|
<legend class="form-label">
|
|
1085
1101
|
{{{{ slotted.default }}}}
|
|
@@ -1098,7 +1114,7 @@ var ful = (function (exports) {
|
|
|
1098
1114
|
{{{{ slotted.footer }}}}
|
|
1099
1115
|
</footer>
|
|
1100
1116
|
</fieldset>
|
|
1101
|
-
|
|
1117
|
+
`));
|
|
1102
1118
|
|
|
1103
1119
|
|
|
1104
1120
|
class RadioGroup extends ParsedElement(['disabled'], ['value']) {
|
|
@@ -1118,8 +1134,7 @@ var ful = (function (exports) {
|
|
|
1118
1134
|
return [input, label];
|
|
1119
1135
|
});
|
|
1120
1136
|
radioEls.forEach(el => el.remove());
|
|
1121
|
-
|
|
1122
|
-
ful_radiougroup_template_.renderTo(this, {
|
|
1137
|
+
templates.get('ful-radio-group').renderTo(this, {
|
|
1123
1138
|
name: name,
|
|
1124
1139
|
slotted: slotted,
|
|
1125
1140
|
inputsAndLabels: inputsAndLabels
|
|
@@ -1134,22 +1149,17 @@ var ful = (function (exports) {
|
|
|
1134
1149
|
}
|
|
1135
1150
|
}
|
|
1136
1151
|
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
});
|
|
1140
|
-
|
|
1141
|
-
const template = globalThis.ful_spinner_template || ftl.Template.fromHtml(`
|
|
1152
|
+
templates.put('ful-spinner', Fragments.fromHtml(`
|
|
1142
1153
|
<div class="ful-spinner-wrapper">
|
|
1143
1154
|
<div class="ful-spinner-text">{{{{ slotted.default }}}}</div>
|
|
1144
1155
|
<div class="ful-spinner-icon"></div>
|
|
1145
1156
|
</div>
|
|
1146
|
-
|
|
1147
|
-
|
|
1157
|
+
`));
|
|
1148
1158
|
|
|
1149
1159
|
class Spinner extends ParsedElement() {
|
|
1150
1160
|
render() {
|
|
1151
1161
|
const slotted = Slots.from(this);
|
|
1152
|
-
|
|
1162
|
+
templates.get('ful-spinner').renderTo(this, { slotted });
|
|
1153
1163
|
}
|
|
1154
1164
|
}
|
|
1155
1165
|
|
|
@@ -1226,7 +1236,8 @@ var ful = (function (exports) {
|
|
|
1226
1236
|
}
|
|
1227
1237
|
|
|
1228
1238
|
class CustomElements {
|
|
1229
|
-
static configure() {
|
|
1239
|
+
static configure(ec) {
|
|
1240
|
+
templates.configure(ec);
|
|
1230
1241
|
customElements.define('ful-spinner', Spinner);
|
|
1231
1242
|
customElements.define('ful-input', Input);
|
|
1232
1243
|
customElements.define('ful-radio-group', RadioGroup);
|
|
@@ -1255,14 +1266,16 @@ var ful = (function (exports) {
|
|
|
1255
1266
|
exports.SessionStorage = SessionStorage;
|
|
1256
1267
|
exports.Slots = Slots;
|
|
1257
1268
|
exports.Spinner = Spinner;
|
|
1258
|
-
exports.StatelessInput = StatelessInput;
|
|
1259
1269
|
exports.SyncEvent = SyncEvent;
|
|
1270
|
+
exports.TemplateRegistry = TemplateRegistry;
|
|
1260
1271
|
exports.VersionedStorage = VersionedStorage;
|
|
1261
1272
|
exports.Wizard = Wizard;
|
|
1262
1273
|
exports.jsonPatch = jsonPatch;
|
|
1263
1274
|
exports.jsonPost = jsonPost;
|
|
1264
1275
|
exports.jsonPut = jsonPut;
|
|
1265
1276
|
exports.jsonRequest = jsonRequest;
|
|
1277
|
+
exports.makeInputFragment = makeInputFragment;
|
|
1278
|
+
exports.templates = templates;
|
|
1266
1279
|
exports.timing = timing;
|
|
1267
1280
|
|
|
1268
1281
|
Object.defineProperty(exports, '__esModule', { value: true });
|