auto-webmcp 0.3.3 → 0.3.4

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.
@@ -1127,7 +1127,7 @@ function fillFormFields(form, params) {
1127
1127
  setReactValue(input, String(value ?? ""));
1128
1128
  snapshot[key] = input.value;
1129
1129
  } else if (input instanceof HTMLSelectElement) {
1130
- fillSelectElement(input, value);
1130
+ fillSelectElement(input, value, form, key);
1131
1131
  snapshot[key] = input.multiple ? Array.from(input.options).filter((o) => o.selected).map((o) => o.value) : input.value;
1132
1132
  }
1133
1133
  continue;
@@ -1150,7 +1150,7 @@ function fillFormFields(form, params) {
1150
1150
  setReactValue(effectiveEl, String(value ?? ""));
1151
1151
  snapshot[key] = effectiveEl.value;
1152
1152
  } else if (effectiveEl instanceof HTMLSelectElement) {
1153
- fillSelectElement(effectiveEl, value);
1153
+ fillSelectElement(effectiveEl, value, form, key);
1154
1154
  snapshot[key] = effectiveEl.multiple ? Array.from(effectiveEl.options).filter((o) => o.selected).map((o) => o.value) : effectiveEl.value;
1155
1155
  } else {
1156
1156
  fillAriaField(effectiveEl, value);
@@ -1159,6 +1159,7 @@ function fillFormFields(form, params) {
1159
1159
  }
1160
1160
  }
1161
1161
  lastFilledSnapshot.set(form, snapshot);
1162
+ window["__lastFillWarnings"] = pendingFillWarnings.get(form) ?? [];
1162
1163
  }
1163
1164
  function fillInput(input, form, key, value) {
1164
1165
  const type = input.type.toLowerCase();
@@ -1225,7 +1226,7 @@ function fillInput(input, form, key, value) {
1225
1226
  }
1226
1227
  setReactValue(input, String(value ?? ""));
1227
1228
  }
1228
- function fillSelectElement(select, value) {
1229
+ function fillSelectElement(select, value, form, key) {
1229
1230
  if (select.multiple) {
1230
1231
  const vals = Array.isArray(value) ? value.map(String) : [String(value ?? "")];
1231
1232
  for (const opt of Array.from(select.options)) {
@@ -1234,7 +1235,24 @@ function fillSelectElement(select, value) {
1234
1235
  select.dispatchEvent(new Event("change", { bubbles: true }));
1235
1236
  return;
1236
1237
  }
1237
- select.value = String(value ?? "");
1238
+ const strVal = String(value ?? "");
1239
+ select.value = strVal;
1240
+ if (select.value !== strVal) {
1241
+ const lower = strVal.toLowerCase();
1242
+ const byLabel = Array.from(select.options).find(
1243
+ (o) => o.text.trim().toLowerCase() === lower || o.label.trim().toLowerCase() === lower
1244
+ );
1245
+ if (byLabel) {
1246
+ select.value = byLabel.value;
1247
+ } else if (form && key) {
1248
+ pendingFillWarnings.get(form)?.push({
1249
+ field: key,
1250
+ type: "not_filled",
1251
+ message: `"${key}" value "${strVal}" did not match any option in the select`,
1252
+ original: strVal
1253
+ });
1254
+ }
1255
+ }
1238
1256
  select.dispatchEvent(new Event("change", { bubbles: true }));
1239
1257
  }
1240
1258
  function fillAriaField(el, value) {