@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/dist/min-ui.js +3 -3
- package/dist/ui.js +12 -2
- package/dist/ui.min.js +3 -3
- package/package.json +2 -2
- package/src/10-primitives-layout.js +12 -2
package/dist/ui.js
CHANGED
|
@@ -2228,6 +2228,7 @@ const unitCover = (v, name = 'size') => {
|
|
|
2228
2228
|
// props: { model: rod OR [get,set] signal OR plain, placeholder, type }
|
|
2229
2229
|
|
|
2230
2230
|
|
|
2231
|
+
let uiFieldMessageId = 0;
|
|
2231
2232
|
UI.FormField = (props = {}) => {
|
|
2232
2233
|
|
|
2233
2234
|
applyCommonProps(props);
|
|
@@ -2360,6 +2361,14 @@ const unitCover = (v, name = 'size') => {
|
|
|
2360
2361
|
return true;
|
|
2361
2362
|
};
|
|
2362
2363
|
let messageEl = null;
|
|
2364
|
+
const messageId = `jsswift-field-message-${++uiFieldMessageId}`;
|
|
2365
|
+
const syncDescription = () => {
|
|
2366
|
+
if (!controlEl?.setAttribute) return;
|
|
2367
|
+
const ids = [uiUnwrap(props.ariaDescribedBy), messageEl?.id].filter(Boolean).join(" ").trim();
|
|
2368
|
+
if (ids) controlEl.setAttribute("aria-describedby", [...new Set(ids.split(/\s+/))].join(" "));
|
|
2369
|
+
else controlEl.removeAttribute("aria-describedby");
|
|
2370
|
+
};
|
|
2371
|
+
wrap._syncDescription = syncDescription;
|
|
2363
2372
|
const renderMessage = () => {
|
|
2364
2373
|
const statusOrder = [
|
|
2365
2374
|
{ key: "error", value: resolveValue(props.error), slot: "errorMessage", className: "cms-error" },
|
|
@@ -2387,7 +2396,7 @@ const unitCover = (v, name = 'size') => {
|
|
|
2387
2396
|
? renderSlotToArray(slots, active.slot, ctx, active.value)
|
|
2388
2397
|
: [];
|
|
2389
2398
|
const nextEl = nodes.length
|
|
2390
|
-
? _.div({ class: active?.className }, ...nodes)
|
|
2399
|
+
? _.div({ id: messageId, class: active?.className }, ...nodes)
|
|
2391
2400
|
: null;
|
|
2392
2401
|
|
|
2393
2402
|
const stateKeys = ["error", "warning", "success", "note"];
|
|
@@ -2400,6 +2409,7 @@ const unitCover = (v, name = 'size') => {
|
|
|
2400
2409
|
wrap.appendChild(nextEl);
|
|
2401
2410
|
}
|
|
2402
2411
|
messageEl = nextEl;
|
|
2412
|
+
syncDescription();
|
|
2403
2413
|
};
|
|
2404
2414
|
|
|
2405
2415
|
// state updater
|
|
@@ -2552,7 +2562,7 @@ const unitCover = (v, name = 'size') => {
|
|
|
2552
2562
|
const label = uiUnwrap(props.ariaLabel) ?? (typeof props.label === "string" ? props.label : null);
|
|
2553
2563
|
set("aria-label", label);
|
|
2554
2564
|
set("aria-labelledby", uiUnwrap(props.ariaLabelledBy));
|
|
2555
|
-
|
|
2565
|
+
field._syncDescription?.();
|
|
2556
2566
|
const invalid = props.ariaInvalid == null ? !!uiUnwrap(props.error) : !!uiUnwrap(props.ariaInvalid);
|
|
2557
2567
|
control.setAttribute("aria-invalid", String(invalid));
|
|
2558
2568
|
const required = !!uiUnwrap(props.required);
|