@optionfactory/ful 0.50.0 → 0.52.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.mjs CHANGED
@@ -809,11 +809,11 @@ class UpgradeQueue {
809
809
  const upgradeQueue = new UpgradeQueue();
810
810
 
811
811
  const ParsedElement = (conf) => {
812
- const {flags, attrs, template, slots} = conf || {};
812
+ const {states, attributes, template, slots} = conf || {};
813
813
 
814
- const observed_flags = flags || [];
815
- const observed_others = attrs || [];
816
- const observed = [].concat(observed_flags).concat(observed_others);
814
+ const observed_states = states || [];
815
+ const observed_attributes = attributes || [];
816
+ const observed = [].concat(observed_states).concat(observed_attributes);
817
817
 
818
818
  const templateId = elements.defineTemplate(template);
819
819
 
@@ -867,12 +867,12 @@ const ParsedElement = (conf) => {
867
867
  }
868
868
  this.#parsed = true;
869
869
  await this.render(elements.template(templateId), slots ? LightSlots.from(this) : undefined);
870
- for (const flag of observed_flags) {
870
+ for (const flag of observed_states) {
871
871
  if (this.hasAttribute(flag)) {
872
872
  this[flag] = true;
873
873
  }
874
874
  }
875
- for (const other of observed_others) {
875
+ for (const other of observed_attributes) {
876
876
  if (this.hasAttribute(other)) {
877
877
  this[other] = this.getAttribute(other);
878
878
  }
@@ -881,18 +881,17 @@ const ParsedElement = (conf) => {
881
881
  }
882
882
  };
883
883
 
884
- for (const flag of observed_flags) {
885
- const state = `--${flag};`;
886
- Object.defineProperty(k.prototype, flag, {
884
+ for (const state of observed_states) {
885
+ Object.defineProperty(k.prototype, state, {
887
886
  enumerable: true,
888
887
  configurable: true,
889
888
  get() {
890
- return this.internals.states.has(state);
889
+ return this.internals.states.has(`--${state}`);
891
890
  },
892
891
  set(value) {
893
892
  const v = Attributes.asBoolean(value);
894
893
  const et = this.initialized ? 'changed' : 'init';
895
- const event = new SyncEvent(`${flag}:${et}`, {
894
+ const event = new SyncEvent(`${state}:${et}`, {
896
895
  detail: {
897
896
  target: this,
898
897
  value: v
@@ -903,12 +902,8 @@ const ParsedElement = (conf) => {
903
902
  if (!success) {
904
903
  return;
905
904
  }
906
- if (v) {
907
- //see https://developer.mozilla.org/en-US/docs/Web/API/CustomStateSet#using_double_dash_prefixed_idents
908
- this.internals.states.add(state);
909
- return;
910
- }
911
- this.internals.states.delete(state);
905
+ //see https://developer.mozilla.org/en-US/docs/Web/API/CustomStateSet#using_double_dash_prefixed_idents
906
+ this.internals.states[v ? 'add' : 'delete'](`--${state}`);
912
907
  })();
913
908
  }
914
909
  });
@@ -1066,6 +1061,18 @@ class Form extends ParsedElement() {
1066
1061
  }
1067
1062
  }
1068
1063
 
1064
+ const INPUT_TEMPLATE = `
1065
+ <label data-tpl-for="id" class="form-label">{{{{ slots.default }}}}</label>
1066
+ <div class="input-group">
1067
+ <span data-tpl-if="slots.ibefore" class="input-group-text">{{{{ slots.ibefore }}}}</span>
1068
+ <div data-tpl-if="slots.before" data-tpl-remove="tag">{{{{ slots.before }}}}</div>
1069
+ {{{{ slots.input }}}}
1070
+ <div data-tpl-if="slots.after" data-tpl-remove="tag">{{{{ slots.after }}}}</div>
1071
+ <span data-tpl-if="slots.iafter" class="input-group-text">{{{{ slots.iafter }}}}</span>
1072
+ </div>
1073
+ <ful-field-error data-tpl-if="name" data-tpl-field="name"></ful-field-error>
1074
+ `;
1075
+
1069
1076
  const makeInputFragment = (el, template, slots) => {
1070
1077
  const input = el.input = slots.input = slots.input || (() => {
1071
1078
  const el = document.createElement("input");
@@ -1084,20 +1091,10 @@ const makeInputFragment = (el, template, slots) => {
1084
1091
  };
1085
1092
 
1086
1093
  class Input extends ParsedElement({
1087
- flags: [],
1088
- attrs: ['value'],
1094
+ states: [],
1095
+ attributes: ['value'],
1089
1096
  slots: true,
1090
- template: `
1091
- <label data-tpl-for="id" class="form-label">{{{{ slots.default }}}}</label>
1092
- <div class="input-group">
1093
- <span data-tpl-if="slots.ibefore" class="input-group-text">{{{{ slots.ibefore }}}}</span>
1094
- <div data-tpl-if="slots.before" data-tpl-remove="tag">{{{{ slots.before }}}}</div>
1095
- {{{{ slots.input }}}}
1096
- <div data-tpl-if="slots.after" data-tpl-remove="tag">{{{{ slots.after }}}}</div>
1097
- <span data-tpl-if="slots.iafter" class="input-group-text">{{{{ slots.iafter }}}}</span>
1098
- </div>
1099
- <ful-field-error data-tpl-if="name" data-tpl-field="name"></ful-field-error>
1100
- `
1097
+ template: INPUT_TEMPLATE
1101
1098
  }){
1102
1099
  render(template, slots) {
1103
1100
  const fragment = makeInputFragment(this, template, slots);
@@ -1117,8 +1114,8 @@ class Input extends ParsedElement({
1117
1114
  */
1118
1115
 
1119
1116
  class Select extends ParsedElement({
1120
- flags: [],
1121
- attrs: ["value"],
1117
+ states: [],
1118
+ attributes: ["value"],
1122
1119
  slots: true,
1123
1120
  template: `
1124
1121
  <label data-tpl-for="tsId" class="form-label">{{{{ slots.default }}}}</label>
@@ -1218,8 +1215,8 @@ class Select extends ParsedElement({
1218
1215
  }
1219
1216
 
1220
1217
  class RadioGroup extends ParsedElement({
1221
- flags: ['disabled'],
1222
- attrs: ['value'],
1218
+ states: ['disabled'],
1219
+ attributes: ['value'],
1223
1220
  slots: true,
1224
1221
  template: `
1225
1222
  <fieldset>
@@ -1354,5 +1351,5 @@ class Wizard extends HTMLElement {
1354
1351
  }
1355
1352
  }
1356
1353
 
1357
- export { Attributes, AuthorizationCodeFlow, AuthorizationCodeFlowInterceptor, AuthorizationCodeFlowSession, Base64, ElementsRegistry, Failure, Form, Fragments, Hex, HttpClient, Input, LightSlots, LocalStorage, Nodes, ParsedElement, RadioGroup, Select, SessionStorage, Spinner, SyncEvent, TemplatesRegistry, VersionedStorage, Wizard, elements, jsonPatch, jsonPost, jsonPut, jsonRequest, makeInputFragment, timing };
1354
+ export { Attributes, AuthorizationCodeFlow, AuthorizationCodeFlowInterceptor, AuthorizationCodeFlowSession, Base64, ElementsRegistry, Failure, Form, Fragments, Hex, HttpClient, INPUT_TEMPLATE, Input, LightSlots, LocalStorage, Nodes, ParsedElement, RadioGroup, Select, SessionStorage, Spinner, SyncEvent, TemplatesRegistry, VersionedStorage, Wizard, elements, jsonPatch, jsonPost, jsonPut, jsonRequest, makeInputFragment, timing };
1358
1355
  //# sourceMappingURL=ful.mjs.map