@optionfactory/ful 0.46.0 → 0.47.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 +108 -103
- 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 +109 -102
- package/dist/ful.mjs.map +1 -1
- package/package.json +1 -1
package/dist/ful.mjs
CHANGED
|
@@ -683,83 +683,85 @@ class UpgradeQueue {
|
|
|
683
683
|
|
|
684
684
|
const upgradeQueue = new UpgradeQueue();
|
|
685
685
|
|
|
686
|
-
|
|
687
|
-
#parsed;
|
|
688
|
-
connectedCallback() {
|
|
689
|
-
if (this.#parsed) {
|
|
690
|
-
return;
|
|
691
|
-
}
|
|
692
|
-
if (this.ownerDocument.readyState === 'complete' || Nodes.isParsed(this)) {
|
|
693
|
-
upgradeQueue.enqueue(this);
|
|
694
|
-
return;
|
|
695
|
-
}
|
|
696
|
-
this.ownerDocument.addEventListener('DOMContentLoaded', () => {
|
|
697
|
-
observer.disconnect();
|
|
698
|
-
upgradeQueue.enqueue(this);
|
|
699
|
-
});
|
|
700
|
-
const observer = new MutationObserver(() => {
|
|
701
|
-
if (!Nodes.isParsed(this)) {
|
|
702
|
-
return;
|
|
703
|
-
}
|
|
704
|
-
observer.disconnect();
|
|
705
|
-
upgradeQueue.enqueue(this);
|
|
706
|
-
});
|
|
707
|
-
observer.observe(this.parentNode, { childList: true, subtree: true });
|
|
708
|
-
}
|
|
709
|
-
attributeChangedCallback(name, oldValue, newValue) {
|
|
710
|
-
if (!this.#parsed || oldValue === newValue) {
|
|
711
|
-
return;
|
|
712
|
-
}
|
|
713
|
-
this[name] = newValue;
|
|
714
|
-
}
|
|
715
|
-
upgrade() {
|
|
716
|
-
if (this.#parsed) {
|
|
717
|
-
return;
|
|
718
|
-
}
|
|
719
|
-
this.#parsed = true;
|
|
720
|
-
return this.ready();
|
|
721
|
-
}
|
|
722
|
-
}
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
const Templated = (SuperClass, template) => {
|
|
726
|
-
return class extends SuperClass {
|
|
727
|
-
async ready() {
|
|
728
|
-
const slotted = Slots.from(this);
|
|
729
|
-
const fragment = await Promise.resolve(this.render(slotted, template));
|
|
730
|
-
this.replaceChildren(fragment);
|
|
731
|
-
}
|
|
732
|
-
};
|
|
733
|
-
};
|
|
686
|
+
const ParsedElement = (flags, others) => {
|
|
734
687
|
|
|
735
|
-
const
|
|
688
|
+
const observed_flags = flags || [];
|
|
689
|
+
const observed_others = others || [];
|
|
690
|
+
const observed = [].concat(observed_flags).concat(observed_others);
|
|
736
691
|
|
|
737
|
-
const
|
|
738
|
-
|
|
739
|
-
const k = class extends SuperClass {
|
|
692
|
+
const k = class extends HTMLElement {
|
|
740
693
|
static get observedAttributes() {
|
|
741
|
-
return
|
|
694
|
+
return observed;
|
|
742
695
|
}
|
|
696
|
+
#parsed;
|
|
697
|
+
#internals;
|
|
743
698
|
constructor(...args) {
|
|
744
699
|
super(...args);
|
|
745
|
-
this
|
|
700
|
+
this.#internals = this.attachInternals();
|
|
701
|
+
}
|
|
702
|
+
get internals() {
|
|
703
|
+
return this.#internals;
|
|
704
|
+
}
|
|
705
|
+
connectedCallback() {
|
|
706
|
+
if (this.#parsed) {
|
|
707
|
+
return;
|
|
708
|
+
}
|
|
709
|
+
if (this.ownerDocument.readyState === 'complete' || Nodes.isParsed(this)) {
|
|
710
|
+
upgradeQueue.enqueue(this);
|
|
711
|
+
return;
|
|
712
|
+
}
|
|
713
|
+
this.ownerDocument.addEventListener('DOMContentLoaded', () => {
|
|
714
|
+
observer.disconnect();
|
|
715
|
+
upgradeQueue.enqueue(this);
|
|
716
|
+
});
|
|
717
|
+
const observer = new MutationObserver(() => {
|
|
718
|
+
if (!Nodes.isParsed(this)) {
|
|
719
|
+
return;
|
|
720
|
+
}
|
|
721
|
+
observer.disconnect();
|
|
722
|
+
upgradeQueue.enqueue(this);
|
|
723
|
+
});
|
|
724
|
+
observer.observe(this.parentNode, { childList: true, subtree: true });
|
|
725
|
+
}
|
|
726
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
727
|
+
if (!this.#parsed || oldValue === newValue) {
|
|
728
|
+
return;
|
|
729
|
+
}
|
|
730
|
+
this[name] = newValue;
|
|
746
731
|
}
|
|
732
|
+
async upgrade() {
|
|
733
|
+
if (this.#parsed) {
|
|
734
|
+
return;
|
|
735
|
+
}
|
|
736
|
+
this.#parsed = true;
|
|
737
|
+
await this.render();
|
|
738
|
+
for (const flag of observed_flags) {
|
|
739
|
+
if(this.hasAttribute(flag)){
|
|
740
|
+
this[flag] = true;
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
for (const other of observed_others) {
|
|
744
|
+
if(this.hasAttribute(other)){
|
|
745
|
+
this[other] = this.getAttribute(other);
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
}
|
|
747
749
|
};
|
|
748
750
|
|
|
749
|
-
for (const flag of
|
|
751
|
+
for (const flag of observed_flags) {
|
|
750
752
|
Object.defineProperty(k.prototype, flag, {
|
|
751
753
|
enumerable: true,
|
|
752
754
|
configurable: true,
|
|
753
755
|
get() {
|
|
754
|
-
return this.
|
|
756
|
+
return this.internals.states.has(`--${flag}`);
|
|
755
757
|
},
|
|
756
758
|
set(value) {
|
|
757
759
|
//see https://developer.mozilla.org/en-US/docs/Web/API/CustomStateSet#using_double_dash_prefixed_idents
|
|
758
760
|
if (Attributes.asBoolean(value)) {
|
|
759
|
-
this.
|
|
761
|
+
this.internals.states.add(`--${flag}`);
|
|
760
762
|
return;
|
|
761
763
|
}
|
|
762
|
-
this.
|
|
764
|
+
this.internals.states.delete(`--${flag}`);
|
|
763
765
|
}
|
|
764
766
|
});
|
|
765
767
|
}
|
|
@@ -836,12 +838,12 @@ function mutate(el, raw) {
|
|
|
836
838
|
el.value = raw;
|
|
837
839
|
}
|
|
838
840
|
|
|
839
|
-
class Form extends
|
|
841
|
+
class Form extends ParsedElement() {
|
|
840
842
|
static IGNORED_CHILDREN_SELECTOR = '.d-none, [hidden]';
|
|
841
843
|
static SCROLL_OFFSET = 50;
|
|
842
|
-
render(
|
|
844
|
+
render() {
|
|
843
845
|
const form = document.createElement('form');
|
|
844
|
-
form.
|
|
846
|
+
form.replaceChildren(...this.childNodes);
|
|
845
847
|
form.addEventListener('submit', async (e) => {
|
|
846
848
|
e.preventDefault();
|
|
847
849
|
this.spinner(true);
|
|
@@ -859,7 +861,7 @@ class Form extends Templated(ParsedElement) {
|
|
|
859
861
|
this.spinner(false);
|
|
860
862
|
}
|
|
861
863
|
});
|
|
862
|
-
|
|
864
|
+
this.replaceChildren(form);
|
|
863
865
|
}
|
|
864
866
|
spinner(spin) {
|
|
865
867
|
this.querySelectorAll('ful-spinner').forEach(el => el.hidden = !spin);
|
|
@@ -920,7 +922,7 @@ const ful_input_ec = globalThis.ec || ftl.EvaluationContext.configure({
|
|
|
920
922
|
|
|
921
923
|
});
|
|
922
924
|
|
|
923
|
-
const
|
|
925
|
+
const template$1 = globalThis.ful_input_template || ftl.Template.fromHtml(`
|
|
924
926
|
<label data-tpl-for="id" class="form-label">{{{{ slotted.default }}}}</label>
|
|
925
927
|
<div class="input-group">
|
|
926
928
|
<span data-tpl-if="slotted.ibefore" class="input-group-text">{{{{ slotted.ibefore }}}}</span>
|
|
@@ -932,31 +934,34 @@ const ful_input_template_ = globalThis.ful_input_template || ftl.Template.fromHt
|
|
|
932
934
|
<ful-field-error data-tpl-if="name" data-tpl-field="name"></ful-field-error>
|
|
933
935
|
`, ful_input_ec);
|
|
934
936
|
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
937
|
+
const renderInput = (el) => {
|
|
938
|
+
const slotted = Slots.from(el);
|
|
939
|
+
|
|
940
|
+
const input = el.input = slotted.input = slotted.input || (() => {
|
|
941
|
+
const el = document.createElement("input");
|
|
942
|
+
el.classList.add("form-control");
|
|
943
|
+
return el;
|
|
944
|
+
})();
|
|
945
|
+
input.setAttribute('ful-validation-target', '');
|
|
946
|
+
|
|
947
|
+
const id = input.getAttribute('id') || el.getAttribute('input-id') || Attributes.uid('ful-input');
|
|
948
|
+
Attributes.forward('input-', el, slotted.input);
|
|
949
|
+
Attributes.defaultValue(slotted.input, "id", id);
|
|
950
|
+
Attributes.defaultValue(slotted.input, "type", "text");
|
|
951
|
+
Attributes.defaultValue(slotted.input, "placeholder", " ");
|
|
952
|
+
const name = el.getAttribute('name');
|
|
953
|
+
template$1.renderTo(el, { id, name, slotted });
|
|
954
|
+
};
|
|
943
955
|
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
Attributes.defaultValue(slotted.input, "type", "text");
|
|
948
|
-
Attributes.defaultValue(slotted.input, "placeholder", " ");
|
|
949
|
-
const name = this.getAttribute('name');
|
|
950
|
-
return template.render({ id, name, slotted });
|
|
956
|
+
class StatelessInput extends ParsedElement() {
|
|
957
|
+
render() {
|
|
958
|
+
renderInput(this);
|
|
951
959
|
}
|
|
952
|
-
|
|
953
960
|
}
|
|
954
961
|
|
|
955
|
-
class Input extends
|
|
956
|
-
render(
|
|
957
|
-
|
|
958
|
-
this.input.value = this.getAttribute('value');
|
|
959
|
-
return fragment;
|
|
962
|
+
class Input extends ParsedElement([], ['value']) {
|
|
963
|
+
render() {
|
|
964
|
+
renderInput(this);
|
|
960
965
|
}
|
|
961
966
|
get value() {
|
|
962
967
|
return this.input.value;
|
|
@@ -988,12 +993,14 @@ const ful_select_template_ = globalThis.ful_select_template || ftl.Template.from
|
|
|
988
993
|
`, ful_select_ec);
|
|
989
994
|
|
|
990
995
|
|
|
991
|
-
class Select extends
|
|
996
|
+
class Select extends ParsedElement([], ["value"]) {
|
|
992
997
|
constructor(tsConfig) {
|
|
993
998
|
super();
|
|
994
999
|
this.tsConfig = tsConfig;
|
|
995
1000
|
}
|
|
996
|
-
render(
|
|
1001
|
+
render() {
|
|
1002
|
+
const slotted = Slots.from(this);
|
|
1003
|
+
|
|
997
1004
|
const type = this.getAttribute("type") || 'local';
|
|
998
1005
|
const remote = type != 'local';
|
|
999
1006
|
const loadOnce = this.getAttribute('load') != 'always';
|
|
@@ -1021,7 +1028,6 @@ class Select extends Stateful(Templated(ParsedElement, ful_select_template_), []
|
|
|
1021
1028
|
}
|
|
1022
1029
|
};
|
|
1023
1030
|
|
|
1024
|
-
|
|
1025
1031
|
this._remote = remote;
|
|
1026
1032
|
// we need to await this load in setValue when remote is configured and the option
|
|
1027
1033
|
// is not loaded yet.
|
|
@@ -1036,7 +1042,7 @@ class Select extends Stateful(Templated(ParsedElement, ful_select_template_), []
|
|
|
1036
1042
|
const type = query && query.hasOwnProperty('byId') ? 'id' : 'query';
|
|
1037
1043
|
const qvalue = type === 'id' ? query.byId : query;
|
|
1038
1044
|
const data = await (this.loader ? this.loader(qvalue, type) : []);
|
|
1039
|
-
if(type !== 'id'){
|
|
1045
|
+
if (type !== 'id') {
|
|
1040
1046
|
this.loaded = true;
|
|
1041
1047
|
}
|
|
1042
1048
|
callback(data);
|
|
@@ -1050,12 +1056,12 @@ class Select extends Stateful(Templated(ParsedElement, ful_select_template_), []
|
|
|
1050
1056
|
} : {}, tsDefaultConfig, this.tsConfig));
|
|
1051
1057
|
//we remove the input to move it
|
|
1052
1058
|
input.remove();
|
|
1053
|
-
|
|
1059
|
+
ful_select_template_.renderTo(this, { id, tsId, name, input, slotted });
|
|
1054
1060
|
}
|
|
1055
1061
|
set value(v) {
|
|
1056
1062
|
(async () => {
|
|
1057
|
-
if(this._remote){
|
|
1058
|
-
await this._unwrappedRemoteLoad({byId: v}, this.ts.loadCallback.bind(this.ts));
|
|
1063
|
+
if (this._remote) {
|
|
1064
|
+
await this._unwrappedRemoteLoad({ byId: v }, this.ts.loadCallback.bind(this.ts));
|
|
1059
1065
|
}
|
|
1060
1066
|
this.ts.setValue(v);
|
|
1061
1067
|
})();
|
|
@@ -1092,8 +1098,9 @@ const ful_radiougroup_template_ = globalThis.ful_radiogroup_template || ftl.Temp
|
|
|
1092
1098
|
`, ful_radiogroup_ec);
|
|
1093
1099
|
|
|
1094
1100
|
|
|
1095
|
-
class RadioGroup extends
|
|
1096
|
-
render(
|
|
1101
|
+
class RadioGroup extends ParsedElement(['disabled'], ['value']) {
|
|
1102
|
+
render() {
|
|
1103
|
+
const slotted = Slots.from(this);
|
|
1097
1104
|
const name = this.getAttribute('name') || Attributes.uid('ful-radiogroup');
|
|
1098
1105
|
const radioEls = Array.from(slotted.default.querySelectorAll('ful-radio'));
|
|
1099
1106
|
const inputsAndLabels = radioEls.map(el => {
|
|
@@ -1108,19 +1115,18 @@ class RadioGroup extends Stateful(Templated(ParsedElement, ful_radiougroup_templ
|
|
|
1108
1115
|
return [input, label];
|
|
1109
1116
|
});
|
|
1110
1117
|
radioEls.forEach(el => el.remove());
|
|
1111
|
-
|
|
1112
|
-
|
|
1118
|
+
|
|
1119
|
+
ful_radiougroup_template_.renderTo(this, {
|
|
1113
1120
|
name: name,
|
|
1114
1121
|
slotted: slotted,
|
|
1115
1122
|
inputsAndLabels: inputsAndLabels
|
|
1116
1123
|
});
|
|
1117
|
-
return fragment;
|
|
1118
1124
|
}
|
|
1119
1125
|
get value() {
|
|
1120
1126
|
const checked = this.querySelector('input[type=radio]:checked');
|
|
1121
1127
|
return checked ? checked.value : null;
|
|
1122
1128
|
}
|
|
1123
|
-
set value(value){
|
|
1129
|
+
set value(value) {
|
|
1124
1130
|
this.querySelector(`input[type=radio][value=${CSS.escape(value)}]`).checked = true;
|
|
1125
1131
|
}
|
|
1126
1132
|
}
|
|
@@ -1129,7 +1135,7 @@ const ful_spinner_ec = globalThis.ec || ftl.EvaluationContext.configure({
|
|
|
1129
1135
|
|
|
1130
1136
|
});
|
|
1131
1137
|
|
|
1132
|
-
const
|
|
1138
|
+
const template = globalThis.ful_spinner_template || ftl.Template.fromHtml(`
|
|
1133
1139
|
<div class="ful-spinner-wrapper">
|
|
1134
1140
|
<div class="ful-spinner-text">{{{{ slotted.default }}}}</div>
|
|
1135
1141
|
<div class="ful-spinner-icon"></div>
|
|
@@ -1137,9 +1143,10 @@ const ful_spinner_template_ = globalThis.ful_spinner_template || ftl.Template.fr
|
|
|
1137
1143
|
`, ful_spinner_ec);
|
|
1138
1144
|
|
|
1139
1145
|
|
|
1140
|
-
class Spinner extends
|
|
1141
|
-
render(
|
|
1142
|
-
|
|
1146
|
+
class Spinner extends ParsedElement() {
|
|
1147
|
+
render() {
|
|
1148
|
+
const slotted = Slots.from(this);
|
|
1149
|
+
template.renderTo(this, { slotted });
|
|
1143
1150
|
}
|
|
1144
1151
|
}
|
|
1145
1152
|
|
|
@@ -1225,5 +1232,5 @@ class CustomElements {
|
|
|
1225
1232
|
}
|
|
1226
1233
|
}
|
|
1227
1234
|
|
|
1228
|
-
export { Attributes, AuthorizationCodeFlow, AuthorizationCodeFlowInterceptor, AuthorizationCodeFlowSession, Base64, CustomElements, Failure, Form, Fragments, Hex, HttpClient, Input, LocalStorage, Nodes, ParsedElement, RadioGroup, Select, SessionStorage, Slots, Spinner,
|
|
1235
|
+
export { Attributes, AuthorizationCodeFlow, AuthorizationCodeFlowInterceptor, AuthorizationCodeFlowSession, Base64, CustomElements, Failure, Form, Fragments, Hex, HttpClient, Input, LocalStorage, Nodes, ParsedElement, RadioGroup, Select, SessionStorage, Slots, Spinner, StatelessInput, SyncEvent, VersionedStorage, Wizard, jsonPatch, jsonPost, jsonPut, jsonRequest, timing };
|
|
1229
1236
|
//# sourceMappingURL=ful.mjs.map
|