@ai-gui/plugin-form 0.4.0 → 0.4.2
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/index.cjs +8 -5
- package/dist/index.js +8 -5
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -329,7 +329,8 @@ function mountForm(host, definition, runtime) {
|
|
|
329
329
|
actionError.hidden = true;
|
|
330
330
|
formElement.appendChild(actionError);
|
|
331
331
|
const submit = document.createElement("button");
|
|
332
|
-
submit.type = "
|
|
332
|
+
submit.type = "button";
|
|
333
|
+
submit.setAttribute("data-aigui-form-submit", "");
|
|
333
334
|
submit.textContent = definition.submitLabel ?? "Submit";
|
|
334
335
|
formElement.appendChild(submit);
|
|
335
336
|
const onInput = (event) => {
|
|
@@ -338,8 +339,7 @@ function mountForm(host, definition, runtime) {
|
|
|
338
339
|
clearFieldError(control.name, controls, errorElements);
|
|
339
340
|
actionError.hidden = true;
|
|
340
341
|
};
|
|
341
|
-
const onSubmit = (
|
|
342
|
-
event.preventDefault();
|
|
342
|
+
const onSubmit = () => {
|
|
343
343
|
if (pending || disposed) return;
|
|
344
344
|
const validation = validateFormValues(definition, readControls(definition, controls));
|
|
345
345
|
renderErrors(validation.errors, controls, errorElements);
|
|
@@ -372,16 +372,19 @@ function mountForm(host, definition, runtime) {
|
|
|
372
372
|
settle();
|
|
373
373
|
});
|
|
374
374
|
};
|
|
375
|
+
const preventImplicitSubmit = (event) => event.preventDefault();
|
|
375
376
|
formElement.addEventListener("input", onInput);
|
|
376
377
|
formElement.addEventListener("change", onInput);
|
|
377
|
-
formElement.addEventListener("submit",
|
|
378
|
+
formElement.addEventListener("submit", preventImplicitSubmit);
|
|
379
|
+
submit.addEventListener("click", onSubmit);
|
|
378
380
|
host.replaceChildren(formElement);
|
|
379
381
|
return () => {
|
|
380
382
|
disposed = true;
|
|
381
383
|
controller.abort();
|
|
382
384
|
formElement.removeEventListener("input", onInput);
|
|
383
385
|
formElement.removeEventListener("change", onInput);
|
|
384
|
-
formElement.removeEventListener("submit",
|
|
386
|
+
formElement.removeEventListener("submit", preventImplicitSubmit);
|
|
387
|
+
submit.removeEventListener("click", onSubmit);
|
|
385
388
|
};
|
|
386
389
|
}
|
|
387
390
|
function createField(formId, field) {
|
package/dist/index.js
CHANGED
|
@@ -305,7 +305,8 @@ function mountForm(host, definition, runtime) {
|
|
|
305
305
|
actionError.hidden = true;
|
|
306
306
|
formElement.appendChild(actionError);
|
|
307
307
|
const submit = document.createElement("button");
|
|
308
|
-
submit.type = "
|
|
308
|
+
submit.type = "button";
|
|
309
|
+
submit.setAttribute("data-aigui-form-submit", "");
|
|
309
310
|
submit.textContent = definition.submitLabel ?? "Submit";
|
|
310
311
|
formElement.appendChild(submit);
|
|
311
312
|
const onInput = (event) => {
|
|
@@ -314,8 +315,7 @@ function mountForm(host, definition, runtime) {
|
|
|
314
315
|
clearFieldError(control.name, controls, errorElements);
|
|
315
316
|
actionError.hidden = true;
|
|
316
317
|
};
|
|
317
|
-
const onSubmit = (
|
|
318
|
-
event.preventDefault();
|
|
318
|
+
const onSubmit = () => {
|
|
319
319
|
if (pending || disposed) return;
|
|
320
320
|
const validation = validateFormValues(definition, readControls(definition, controls));
|
|
321
321
|
renderErrors(validation.errors, controls, errorElements);
|
|
@@ -348,16 +348,19 @@ function mountForm(host, definition, runtime) {
|
|
|
348
348
|
settle();
|
|
349
349
|
});
|
|
350
350
|
};
|
|
351
|
+
const preventImplicitSubmit = (event) => event.preventDefault();
|
|
351
352
|
formElement.addEventListener("input", onInput);
|
|
352
353
|
formElement.addEventListener("change", onInput);
|
|
353
|
-
formElement.addEventListener("submit",
|
|
354
|
+
formElement.addEventListener("submit", preventImplicitSubmit);
|
|
355
|
+
submit.addEventListener("click", onSubmit);
|
|
354
356
|
host.replaceChildren(formElement);
|
|
355
357
|
return () => {
|
|
356
358
|
disposed = true;
|
|
357
359
|
controller.abort();
|
|
358
360
|
formElement.removeEventListener("input", onInput);
|
|
359
361
|
formElement.removeEventListener("change", onInput);
|
|
360
|
-
formElement.removeEventListener("submit",
|
|
362
|
+
formElement.removeEventListener("submit", preventImplicitSubmit);
|
|
363
|
+
submit.removeEventListener("click", onSubmit);
|
|
361
364
|
};
|
|
362
365
|
}
|
|
363
366
|
function createField(formId, field) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-gui/plugin-form",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"description": "Safe interactive form blocks for AIGUI, backed by the core ActionRuntime.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"llm",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"access": "public"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@ai-gui/core": "0.4.
|
|
52
|
+
"@ai-gui/core": "0.4.2"
|
|
53
53
|
},
|
|
54
54
|
"scripts": {
|
|
55
55
|
"build": "tsdown",
|