@jsswift/ui 1.0.47 → 1.0.49

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.47",
3
+ "version": "1.0.49",
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.47"
41
+ "@jsswift/core": "^1.0.49"
42
42
  }
43
43
  }
@@ -1405,6 +1405,30 @@
1405
1405
  return el;
1406
1406
  };
1407
1407
 
1408
+ // Public field attributes belong to the interactive control, not its wrapper.
1409
+ function uiConfigureFieldControl(field, control, props, native = false) {
1410
+ field.focus = (options) => control.focus(options);
1411
+ const set = (name, value) => {
1412
+ if (value == null || value === false) control.removeAttribute(name);
1413
+ else control.setAttribute(name, String(value));
1414
+ };
1415
+ JSswift.reactive.effect(() => {
1416
+ const label = uiUnwrap(props.ariaLabel) ?? (typeof props.label === "string" ? props.label : null);
1417
+ set("aria-label", label);
1418
+ set("aria-labelledby", uiUnwrap(props.ariaLabelledBy));
1419
+ set("aria-describedby", uiUnwrap(props.ariaDescribedBy));
1420
+ const invalid = props.ariaInvalid == null ? !!uiUnwrap(props.error) : !!uiUnwrap(props.ariaInvalid);
1421
+ control.setAttribute("aria-invalid", String(invalid));
1422
+ const required = !!uiUnwrap(props.required);
1423
+ control.setAttribute("aria-required", String(required));
1424
+ if (native) {
1425
+ control.required = required;
1426
+ for (const name of ["min", "max", "step", "pattern", "minLength", "maxLength"])
1427
+ set(name.toLowerCase(), uiUnwrap(props[name]));
1428
+ }
1429
+ }, "UI.Field:controlAttributes");
1430
+ }
1431
+
1408
1432
  UI.Input = (props = {}) => {
1409
1433
  const slots = props.slots || {};
1410
1434
  const fieldProps = {
@@ -1566,6 +1590,7 @@
1566
1590
 
1567
1591
  // expose reference
1568
1592
  field._input = input;
1593
+ uiConfigureFieldControl(field, input, props, true);
1569
1594
  uiRegisterShortcode(input, props, {
1570
1595
  isEnabled: () => !input.disabled,
1571
1596
  action: () => uiFocusShortcutTarget(input, { selectText: !!props.selectOnShortcode })
@@ -2963,6 +2988,7 @@
2963
2988
  // refresh has-value when value changes
2964
2989
  JSswift.reactive.effect(() => { field._refresh?.(); }, "UI.Select:fieldRefresh");
2965
2990
 
2991
+ uiConfigureFieldControl(field, root, props);
2966
2992
  field._select = root;
2967
2993
  field._dispose = root._dispose;
2968
2994
  JSswift._registerCleanup?.(field, field._dispose);