@jsswift/ui 1.0.49 → 1.0.51

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsswift/ui",
3
- "version": "1.0.49",
3
+ "version": "1.0.51",
4
4
  "description": "JSswift UI layer built on top of @jsswift/core",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -38,6 +38,6 @@
38
38
  "src"
39
39
  ],
40
40
  "peerDependencies": {
41
- "@jsswift/core": "^1.0.49"
41
+ "@jsswift/core": "^1.0.51"
42
42
  }
43
43
  }
@@ -1092,6 +1092,7 @@
1092
1092
  // props: { model: rod OR [get,set] signal OR plain, placeholder, type }
1093
1093
 
1094
1094
 
1095
+ let uiFieldMessageId = 0;
1095
1096
  UI.FormField = (props = {}) => {
1096
1097
 
1097
1098
  applyCommonProps(props);
@@ -1224,6 +1225,14 @@
1224
1225
  return true;
1225
1226
  };
1226
1227
  let messageEl = null;
1228
+ const messageId = `jsswift-field-message-${++uiFieldMessageId}`;
1229
+ const syncDescription = () => {
1230
+ if (!controlEl?.setAttribute) return;
1231
+ const ids = [uiUnwrap(props.ariaDescribedBy), messageEl?.id].filter(Boolean).join(" ").trim();
1232
+ if (ids) controlEl.setAttribute("aria-describedby", [...new Set(ids.split(/\s+/))].join(" "));
1233
+ else controlEl.removeAttribute("aria-describedby");
1234
+ };
1235
+ wrap._syncDescription = syncDescription;
1227
1236
  const renderMessage = () => {
1228
1237
  const statusOrder = [
1229
1238
  { key: "error", value: resolveValue(props.error), slot: "errorMessage", className: "cms-error" },
@@ -1251,7 +1260,7 @@
1251
1260
  ? renderSlotToArray(slots, active.slot, ctx, active.value)
1252
1261
  : [];
1253
1262
  const nextEl = nodes.length
1254
- ? _.div({ class: active?.className }, ...nodes)
1263
+ ? _.div({ id: messageId, class: active?.className }, ...nodes)
1255
1264
  : null;
1256
1265
 
1257
1266
  const stateKeys = ["error", "warning", "success", "note"];
@@ -1264,6 +1273,7 @@
1264
1273
  wrap.appendChild(nextEl);
1265
1274
  }
1266
1275
  messageEl = nextEl;
1276
+ syncDescription();
1267
1277
  };
1268
1278
 
1269
1279
  // state updater
@@ -1416,7 +1426,7 @@
1416
1426
  const label = uiUnwrap(props.ariaLabel) ?? (typeof props.label === "string" ? props.label : null);
1417
1427
  set("aria-label", label);
1418
1428
  set("aria-labelledby", uiUnwrap(props.ariaLabelledBy));
1419
- set("aria-describedby", uiUnwrap(props.ariaDescribedBy));
1429
+ field._syncDescription?.();
1420
1430
  const invalid = props.ariaInvalid == null ? !!uiUnwrap(props.error) : !!uiUnwrap(props.ariaInvalid);
1421
1431
  control.setAttribute("aria-invalid", String(invalid));
1422
1432
  const required = !!uiUnwrap(props.required);