@moda/om 21.7.1 → 21.7.2

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.cjs.js CHANGED
@@ -9896,6 +9896,7 @@ var TextInput = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
9896
9896
  disabled: disabled,
9897
9897
  placeholder: placeholder,
9898
9898
  "aria-label": label || placeholder,
9899
+ "aria-invalid": error ? true : undefined,
9899
9900
  ref: ref,
9900
9901
  onChange: function onChange(event) {
9901
9902
  _onChange === null || _onChange === void 0 || _onChange(event.target.value);
@@ -11179,11 +11180,16 @@ var Field = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
11179
11180
  label = _ref.label,
11180
11181
  placeholder = _ref.placeholder,
11181
11182
  rest = _objectWithoutProperties(_ref, _excluded$h);
11183
+ var id = React.useId();
11184
+ var errorId = "".concat(id, "-error");
11182
11185
  var fieldContextValue = React.useMemo(function () {
11183
11186
  return {
11184
11187
  displaysError: Boolean(error)
11185
11188
  };
11186
11189
  }, [error]);
11190
+
11191
+ // Combine any existing aria-describedby with our error ID
11192
+ var ariaDescribedBy = [rest['aria-describedby'], error ? errorId : null].filter(Boolean).join(' ') || undefined;
11187
11193
  return /*#__PURE__*/React.createElement(FormControlContext.Provider, {
11188
11194
  value: fieldContextValue
11189
11195
  }, /*#__PURE__*/React.createElement("label", {
@@ -11197,18 +11203,22 @@ var Field = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
11197
11203
  error: error,
11198
11204
  placeholder: placeholder,
11199
11205
  label: label,
11200
- shiftIconLeftwards: error && children.type === Select
11206
+ shiftIconLeftwards: error && children.type === Select,
11207
+ 'aria-describedby': ariaDescribedBy
11201
11208
  }, rest), children.props)), error && /*#__PURE__*/React.createElement("span", {
11202
11209
  className: "Field__icon"
11203
11210
  }, /*#__PURE__*/React.createElement(Warning16, null))) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(TextInput, _extends$1({
11204
11211
  ref: ref,
11205
11212
  placeholder: placeholder,
11206
11213
  label: label,
11207
- error: error
11214
+ error: error,
11215
+ "aria-describedby": ariaDescribedBy
11208
11216
  }, rest)), error && /*#__PURE__*/React.createElement("span", {
11209
11217
  className: "Field__icon"
11210
11218
  }, /*#__PURE__*/React.createElement(Warning16, null)))), error && /*#__PURE__*/React.createElement("span", {
11211
- className: "Field__error"
11219
+ id: errorId,
11220
+ className: "Field__error",
11221
+ role: "alert"
11212
11222
  }, error)));
11213
11223
  });
11214
11224
  Field.displayName = 'Field';