@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.iife.js CHANGED
@@ -812,11 +812,11 @@ var ful = (function (exports) {
812
812
  const upgradeQueue = new UpgradeQueue();
813
813
 
814
814
  const ParsedElement = (conf) => {
815
- const {flags, attrs, template, slots} = conf || {};
815
+ const {states, attributes, template, slots} = conf || {};
816
816
 
817
- const observed_flags = flags || [];
818
- const observed_others = attrs || [];
819
- const observed = [].concat(observed_flags).concat(observed_others);
817
+ const observed_states = states || [];
818
+ const observed_attributes = attributes || [];
819
+ const observed = [].concat(observed_states).concat(observed_attributes);
820
820
 
821
821
  const templateId = elements.defineTemplate(template);
822
822
 
@@ -870,12 +870,12 @@ var ful = (function (exports) {
870
870
  }
871
871
  this.#parsed = true;
872
872
  await this.render(elements.template(templateId), slots ? LightSlots.from(this) : undefined);
873
- for (const flag of observed_flags) {
873
+ for (const flag of observed_states) {
874
874
  if (this.hasAttribute(flag)) {
875
875
  this[flag] = true;
876
876
  }
877
877
  }
878
- for (const other of observed_others) {
878
+ for (const other of observed_attributes) {
879
879
  if (this.hasAttribute(other)) {
880
880
  this[other] = this.getAttribute(other);
881
881
  }
@@ -884,18 +884,17 @@ var ful = (function (exports) {
884
884
  }
885
885
  };
886
886
 
887
- for (const flag of observed_flags) {
888
- const state = `--${flag};`;
889
- Object.defineProperty(k.prototype, flag, {
887
+ for (const state of observed_states) {
888
+ Object.defineProperty(k.prototype, state, {
890
889
  enumerable: true,
891
890
  configurable: true,
892
891
  get() {
893
- return this.internals.states.has(state);
892
+ return this.internals.states.has(`--${state}`);
894
893
  },
895
894
  set(value) {
896
895
  const v = Attributes.asBoolean(value);
897
896
  const et = this.initialized ? 'changed' : 'init';
898
- const event = new SyncEvent(`${flag}:${et}`, {
897
+ const event = new SyncEvent(`${state}:${et}`, {
899
898
  detail: {
900
899
  target: this,
901
900
  value: v
@@ -906,12 +905,8 @@ var ful = (function (exports) {
906
905
  if (!success) {
907
906
  return;
908
907
  }
909
- if (v) {
910
- //see https://developer.mozilla.org/en-US/docs/Web/API/CustomStateSet#using_double_dash_prefixed_idents
911
- this.internals.states.add(state);
912
- return;
913
- }
914
- this.internals.states.delete(state);
908
+ //see https://developer.mozilla.org/en-US/docs/Web/API/CustomStateSet#using_double_dash_prefixed_idents
909
+ this.internals.states[v ? 'add' : 'delete'](`--${state}`);
915
910
  })();
916
911
  }
917
912
  });
@@ -1069,6 +1064,18 @@ var ful = (function (exports) {
1069
1064
  }
1070
1065
  }
1071
1066
 
1067
+ const INPUT_TEMPLATE = `
1068
+ <label data-tpl-for="id" class="form-label">{{{{ slots.default }}}}</label>
1069
+ <div class="input-group">
1070
+ <span data-tpl-if="slots.ibefore" class="input-group-text">{{{{ slots.ibefore }}}}</span>
1071
+ <div data-tpl-if="slots.before" data-tpl-remove="tag">{{{{ slots.before }}}}</div>
1072
+ {{{{ slots.input }}}}
1073
+ <div data-tpl-if="slots.after" data-tpl-remove="tag">{{{{ slots.after }}}}</div>
1074
+ <span data-tpl-if="slots.iafter" class="input-group-text">{{{{ slots.iafter }}}}</span>
1075
+ </div>
1076
+ <ful-field-error data-tpl-if="name" data-tpl-field="name"></ful-field-error>
1077
+ `;
1078
+
1072
1079
  const makeInputFragment = (el, template, slots) => {
1073
1080
  const input = el.input = slots.input = slots.input || (() => {
1074
1081
  const el = document.createElement("input");
@@ -1087,20 +1094,10 @@ var ful = (function (exports) {
1087
1094
  };
1088
1095
 
1089
1096
  class Input extends ParsedElement({
1090
- flags: [],
1091
- attrs: ['value'],
1097
+ states: [],
1098
+ attributes: ['value'],
1092
1099
  slots: true,
1093
- template: `
1094
- <label data-tpl-for="id" class="form-label">{{{{ slots.default }}}}</label>
1095
- <div class="input-group">
1096
- <span data-tpl-if="slots.ibefore" class="input-group-text">{{{{ slots.ibefore }}}}</span>
1097
- <div data-tpl-if="slots.before" data-tpl-remove="tag">{{{{ slots.before }}}}</div>
1098
- {{{{ slots.input }}}}
1099
- <div data-tpl-if="slots.after" data-tpl-remove="tag">{{{{ slots.after }}}}</div>
1100
- <span data-tpl-if="slots.iafter" class="input-group-text">{{{{ slots.iafter }}}}</span>
1101
- </div>
1102
- <ful-field-error data-tpl-if="name" data-tpl-field="name"></ful-field-error>
1103
- `
1100
+ template: INPUT_TEMPLATE
1104
1101
  }){
1105
1102
  render(template, slots) {
1106
1103
  const fragment = makeInputFragment(this, template, slots);
@@ -1120,8 +1117,8 @@ var ful = (function (exports) {
1120
1117
  */
1121
1118
 
1122
1119
  class Select extends ParsedElement({
1123
- flags: [],
1124
- attrs: ["value"],
1120
+ states: [],
1121
+ attributes: ["value"],
1125
1122
  slots: true,
1126
1123
  template: `
1127
1124
  <label data-tpl-for="tsId" class="form-label">{{{{ slots.default }}}}</label>
@@ -1221,8 +1218,8 @@ var ful = (function (exports) {
1221
1218
  }
1222
1219
 
1223
1220
  class RadioGroup extends ParsedElement({
1224
- flags: ['disabled'],
1225
- attrs: ['value'],
1221
+ states: ['disabled'],
1222
+ attributes: ['value'],
1226
1223
  slots: true,
1227
1224
  template: `
1228
1225
  <fieldset>
@@ -1368,6 +1365,7 @@ var ful = (function (exports) {
1368
1365
  exports.Fragments = Fragments;
1369
1366
  exports.Hex = Hex;
1370
1367
  exports.HttpClient = HttpClient;
1368
+ exports.INPUT_TEMPLATE = INPUT_TEMPLATE;
1371
1369
  exports.Input = Input;
1372
1370
  exports.LightSlots = LightSlots;
1373
1371
  exports.LocalStorage = LocalStorage;