@optionfactory/ful 6.0.1 → 6.0.3
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 +12 -5
- 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 +13 -6
- package/dist/ful.mjs.map +1 -1
- package/package.json +1 -1
package/dist/ful.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ParsedElement, Attributes, registry, Fragments, Nodes, Rendering } from '@optionfactory/ftl';
|
|
2
2
|
|
|
3
3
|
class Base64 {
|
|
4
4
|
static encode(arrayBuffer, dialect) {
|
|
@@ -1213,12 +1213,14 @@ class Bindings {
|
|
|
1213
1213
|
/**
|
|
1214
1214
|
*
|
|
1215
1215
|
* @param {HTMLFormElement} form
|
|
1216
|
+
* @param {HTMLElement} [submitter]
|
|
1216
1217
|
* @returns
|
|
1217
1218
|
*/
|
|
1218
|
-
static extractFrom(form){
|
|
1219
|
+
static extractFrom(form, submitter){
|
|
1219
1220
|
let result = {};
|
|
1220
1221
|
for(const el of form.elements){
|
|
1221
|
-
|
|
1222
|
+
// we are assuming submitters are disabled during submit.
|
|
1223
|
+
if(!el.hasAttribute("name") || (el.matches(":disabled") && el !== submitter)){
|
|
1222
1224
|
continue;
|
|
1223
1225
|
}
|
|
1224
1226
|
result = Bindings.providePath(result, /** @type {string} */(el.getAttribute('name')), Bindings.extract(el));
|
|
@@ -1354,7 +1356,7 @@ class Form extends ParsedElement {
|
|
|
1354
1356
|
form.addEventListener('submit', async (e) => {
|
|
1355
1357
|
e.preventDefault();
|
|
1356
1358
|
e.stopPropagation();
|
|
1357
|
-
await this.submit();
|
|
1359
|
+
await this.submit(e.submitter);
|
|
1358
1360
|
});
|
|
1359
1361
|
if (this.hasAttribute("clear-invalid-on-change")) {
|
|
1360
1362
|
this.addEventListener('change', (/** @type any */evt) => {
|
|
@@ -1363,11 +1365,16 @@ class Form extends ParsedElement {
|
|
|
1363
1365
|
}
|
|
1364
1366
|
this.replaceChildren(form);
|
|
1365
1367
|
}
|
|
1366
|
-
|
|
1368
|
+
/**
|
|
1369
|
+
*
|
|
1370
|
+
* @param {HTMLElement} [submitter]
|
|
1371
|
+
* @returns
|
|
1372
|
+
*/
|
|
1373
|
+
async submit(submitter) {
|
|
1367
1374
|
this.spinner(true);
|
|
1368
1375
|
try {
|
|
1369
1376
|
const loader = registry.component(this.getAttribute("loader") ?? 'loaders:form').create(this);
|
|
1370
|
-
const values = this.
|
|
1377
|
+
const values = Bindings.extractFrom(this.form, submitter);
|
|
1371
1378
|
let request = await loader.prepare(values, this);
|
|
1372
1379
|
try {
|
|
1373
1380
|
const se = new CustomEvent('submit', { bubbles: true, cancelable: true, detail: { values, request } });
|