@optionfactory/ful 0.58.0 → 0.60.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
@@ -1073,7 +1073,7 @@ class Form extends ParsedElement() {
1073
1073
  if (!this.hasAttribute('scroll-on-error')) {
1074
1074
  return;
1075
1075
  }
1076
- const ys = Array.from(this.querySelectorAll('ful-field-error'))
1076
+ const ys = Array.from(this.querySelectorAll('[ful-validated-field]:has(.is-invalid) ful-field-error'))
1077
1077
  .map(el => el.parentElement ? el.parentElement : el)
1078
1078
  .map(el => el.getBoundingClientRect().y + window.scrollY);
1079
1079
  const miny = Math.min(...ys);
@@ -1084,15 +1084,17 @@ class Form extends ParsedElement() {
1084
1084
  }
1085
1085
 
1086
1086
  const INPUT_TEMPLATE = `
1087
- <label data-tpl-for="id" class="form-label">{{{{ slots.default }}}}</label>
1088
- <div class="input-group">
1089
- <span data-tpl-if="slots.ibefore" class="input-group-text">{{{{ slots.ibefore }}}}</span>
1090
- <div data-tpl-if="slots.before" data-tpl-remove="tag">{{{{ slots.before }}}}</div>
1091
- {{{{ slots.input }}}}
1092
- <div data-tpl-if="slots.after" data-tpl-remove="tag">{{{{ slots.after }}}}</div>
1093
- <span data-tpl-if="slots.iafter" class="input-group-text">{{{{ slots.iafter }}}}</span>
1087
+ <div ful-validated-field>
1088
+ <label data-tpl-for="id" class="form-label">{{{{ slots.default }}}}</label>
1089
+ <div class="input-group">
1090
+ <span data-tpl-if="slots.ibefore" class="input-group-text">{{{{ slots.ibefore }}}}</span>
1091
+ <div data-tpl-if="slots.before" data-tpl-remove="tag">{{{{ slots.before }}}}</div>
1092
+ {{{{ slots.input }}}}
1093
+ <div data-tpl-if="slots.after" data-tpl-remove="tag">{{{{ slots.after }}}}</div>
1094
+ <span data-tpl-if="slots.iafter" class="input-group-text">{{{{ slots.iafter }}}}</span>
1095
+ </div>
1096
+ <ful-field-error data-tpl-if="name" data-tpl-field="name"></ful-field-error>
1094
1097
  </div>
1095
- <ful-field-error data-tpl-if="name" data-tpl-field="name"></ful-field-error>
1096
1098
  `;
1097
1099
 
1098
1100
  const makeInputFragment = (el, template, slots) => {
@@ -1125,6 +1127,17 @@ class Input extends ParsedElement({
1125
1127
  return this.input.value;
1126
1128
  }
1127
1129
  set value(value) {
1130
+ const success = this.dispatchEvent(new CustomEvent("change", {
1131
+ bubbles: true,
1132
+ cancelable: true,
1133
+ detail: {
1134
+ target: this,
1135
+ value: value
1136
+ }
1137
+ }));
1138
+ if(!success){
1139
+ return;
1140
+ }
1128
1141
  this.input.value = value;
1129
1142
  }
1130
1143
  }
@@ -1138,16 +1151,18 @@ class Select extends ParsedElement({
1138
1151
  observed: ["value"],
1139
1152
  slots: true,
1140
1153
  template: `
1141
- <label data-tpl-for="tsId" class="form-label">{{{{ slots.default }}}}</label>
1142
- {{{{ input }}}}
1143
- <div class="input-group">
1144
- <span data-tpl-if="slots.ibefore" class="input-group-text">{{{{ slots.ibefore }}}}</span>
1145
- <div data-tpl-if="slots.before" data-tpl-remove="tag">{{{{ slots.before }}}}</div>
1146
- {{{{ slots.input }}}}
1147
- <div data-tpl-if="slots.after" data-tpl-remove="tag">{{{{ slots.after }}}}</div>
1148
- <span data-tpl-if="slots.iafter" class="input-group-text">{{{{ slots.iafter }}}}</span>
1154
+ <div ful-validated-field>
1155
+ <label data-tpl-for="tsId" class="form-label">{{{{ slots.default }}}}</label>
1156
+ {{{{ input }}}}
1157
+ <div class="input-group">
1158
+ <span data-tpl-if="slots.ibefore" class="input-group-text">{{{{ slots.ibefore }}}}</span>
1159
+ <div data-tpl-if="slots.before" data-tpl-remove="tag">{{{{ slots.before }}}}</div>
1160
+ {{{{ slots.input }}}}
1161
+ <div data-tpl-if="slots.after" data-tpl-remove="tag">{{{{ slots.after }}}}</div>
1162
+ <span data-tpl-if="slots.iafter" class="input-group-text">{{{{ slots.iafter }}}}</span>
1163
+ </div>
1164
+ <ful-field-error data-tpl-if="name" data-tpl-field="name"></ful-field-error>
1149
1165
  </div>
1150
- <ful-field-error data-tpl-if="name" data-tpl-field="name"></ful-field-error>
1151
1166
  `
1152
1167
  }) {
1153
1168
  constructor(tsConfig) {
@@ -1220,12 +1235,23 @@ class Select extends ParsedElement({
1220
1235
  this.value = this.getAttribute("value");
1221
1236
  }
1222
1237
  }
1223
- set value(v) {
1238
+ set value(value) {
1239
+ const success = this.dispatchEvent(new CustomEvent("change", {
1240
+ bubbles: true,
1241
+ cancelable: true,
1242
+ detail: {
1243
+ target: this,
1244
+ value: value
1245
+ }
1246
+ }));
1247
+ if(!success){
1248
+ return;
1249
+ }
1224
1250
  (async () => {
1225
1251
  if (this._remote) {
1226
- await this._unwrappedRemoteLoad({ byId: v }, this.ts.loadCallback.bind(this.ts));
1252
+ await this._unwrappedRemoteLoad({ byId: value }, this.ts.loadCallback.bind(this.ts));
1227
1253
  }
1228
- this.ts.setValue(v);
1254
+ this.ts.setValue(value);
1229
1255
  })();
1230
1256
  }
1231
1257
  get value() {
@@ -1238,7 +1264,7 @@ class RadioGroup extends ParsedElement({
1238
1264
  observed: ['value', 'disabled:bool'],
1239
1265
  slots: true,
1240
1266
  template: `
1241
- <fieldset>
1267
+ <fieldset ful-validated-field>
1242
1268
  <legend class="form-label">
1243
1269
  {{{{ slots.default }}}}
1244
1270
  </legend>
@@ -1282,6 +1308,17 @@ class RadioGroup extends ParsedElement({
1282
1308
  return checked ? checked.value : null;
1283
1309
  }
1284
1310
  set value(value) {
1311
+ const success = this.dispatchEvent(new CustomEvent("change", {
1312
+ bubbles: true,
1313
+ cancelable: true,
1314
+ detail: {
1315
+ target: this,
1316
+ value: value
1317
+ }
1318
+ }));
1319
+ if(!success){
1320
+ return;
1321
+ }
1285
1322
  this.querySelector(`input[type=radio][value=${CSS.escape(value)}]`).checked = true;
1286
1323
  }
1287
1324
  }