react-f0rm 0.6.0 → 0.6.1

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.umd.js CHANGED
@@ -1517,6 +1517,12 @@
1517
1517
  const id = key.replace(/["'[\],\s]+/g, "-").replace(/^-+|-+$/g, "");
1518
1518
  return id || "field";
1519
1519
  }
1520
+ function ariaProps(error, fieldKey, props) {
1521
+ return {
1522
+ "aria-invalid": error ? true : props["aria-invalid"],
1523
+ "aria-describedby": error ? [props["aria-describedby"], errorIdFromKey(fieldKey)].filter(Boolean).join(" ") : props["aria-describedby"]
1524
+ };
1525
+ }
1520
1526
  function fieldErrorId(name) {
1521
1527
  return errorIdFromKey(create$1(name).key);
1522
1528
  }
@@ -1610,7 +1616,6 @@
1610
1616
  );
1611
1617
  const toValue = eventToValue ?? ((e) => e.target.value);
1612
1618
  const errorId = errorIdFromKey(fieldKey);
1613
- const describedBy = error ? [props["aria-describedby"], errorId].filter(Boolean).join(" ") : props["aria-describedby"];
1614
1619
  return /* @__PURE__ */ React__namespace.createElement(React__namespace.Fragment, null, /* @__PURE__ */ React__namespace.createElement(
1615
1620
  Component,
1616
1621
  {
@@ -1619,8 +1624,7 @@
1619
1624
  onBlur,
1620
1625
  ...asProps,
1621
1626
  ...valueToProps ? valueToProps(value) : { value },
1622
- "aria-invalid": error ? true : props["aria-invalid"],
1623
- "aria-describedby": describedBy,
1627
+ ...ariaProps(error, fieldKey, props),
1624
1628
  disabled: isDisabled,
1625
1629
  onChange: (e) => onChange(toValue(e)),
1626
1630
  ref: mergedRef
@@ -1669,8 +1673,7 @@
1669
1673
  onBlur,
1670
1674
  type: "checkbox",
1671
1675
  checked: !!value,
1672
- "aria-invalid": error ? true : props["aria-invalid"],
1673
- "aria-describedby": error ? [props["aria-describedby"], errorIdFromKey(fieldKey)].filter(Boolean).join(" ") : props["aria-describedby"],
1676
+ ...ariaProps(error, fieldKey, props),
1674
1677
  disabled: isDisabled,
1675
1678
  onChange: (e) => onChange(e.target.checked),
1676
1679
  ref
@@ -1725,8 +1728,7 @@
1725
1728
  onBlur,
1726
1729
  multiple,
1727
1730
  value: toSelectValue(multiple, value),
1728
- "aria-invalid": error ? true : props["aria-invalid"],
1729
- "aria-describedby": error ? [props["aria-describedby"], errorIdFromKey(fieldKey)].filter(Boolean).join(" ") : props["aria-describedby"],
1731
+ ...ariaProps(error, fieldKey, props),
1730
1732
  disabled: isDisabled,
1731
1733
  onChange: (e) => onChange(
1732
1734
  multiple ? Array.from(e.target.selectedOptions, (option) => option.value) : e.target.value