@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 +13 -3
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +13 -3
- package/dist/index.esm.js.map +1 -1
- package/dist/src/components/Field/Field.stories.d.ts +2 -0
- package/package.json +1 -1
- package/src/components/Field/Field.stories.tsx +42 -1
- package/src/components/Field/Field.tsx +14 -2
- package/src/components/TextInput/TextInput.tsx +1 -0
package/dist/index.esm.js
CHANGED
|
@@ -9876,6 +9876,7 @@ var TextInput = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
|
9876
9876
|
disabled: disabled,
|
|
9877
9877
|
placeholder: placeholder,
|
|
9878
9878
|
"aria-label": label || placeholder,
|
|
9879
|
+
"aria-invalid": error ? true : undefined,
|
|
9879
9880
|
ref: ref,
|
|
9880
9881
|
onChange: function onChange(event) {
|
|
9881
9882
|
_onChange === null || _onChange === void 0 || _onChange(event.target.value);
|
|
@@ -11159,11 +11160,16 @@ var Field = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
|
11159
11160
|
label = _ref.label,
|
|
11160
11161
|
placeholder = _ref.placeholder,
|
|
11161
11162
|
rest = _objectWithoutProperties(_ref, _excluded$h);
|
|
11163
|
+
var id = useId();
|
|
11164
|
+
var errorId = "".concat(id, "-error");
|
|
11162
11165
|
var fieldContextValue = useMemo(function () {
|
|
11163
11166
|
return {
|
|
11164
11167
|
displaysError: Boolean(error)
|
|
11165
11168
|
};
|
|
11166
11169
|
}, [error]);
|
|
11170
|
+
|
|
11171
|
+
// Combine any existing aria-describedby with our error ID
|
|
11172
|
+
var ariaDescribedBy = [rest['aria-describedby'], error ? errorId : null].filter(Boolean).join(' ') || undefined;
|
|
11167
11173
|
return /*#__PURE__*/React__default.createElement(FormControlContext.Provider, {
|
|
11168
11174
|
value: fieldContextValue
|
|
11169
11175
|
}, /*#__PURE__*/React__default.createElement("label", {
|
|
@@ -11177,18 +11183,22 @@ var Field = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
|
11177
11183
|
error: error,
|
|
11178
11184
|
placeholder: placeholder,
|
|
11179
11185
|
label: label,
|
|
11180
|
-
shiftIconLeftwards: error && children.type === Select
|
|
11186
|
+
shiftIconLeftwards: error && children.type === Select,
|
|
11187
|
+
'aria-describedby': ariaDescribedBy
|
|
11181
11188
|
}, rest), children.props)), error && /*#__PURE__*/React__default.createElement("span", {
|
|
11182
11189
|
className: "Field__icon"
|
|
11183
11190
|
}, /*#__PURE__*/React__default.createElement(Warning16, null))) : /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(TextInput, _extends$1({
|
|
11184
11191
|
ref: ref,
|
|
11185
11192
|
placeholder: placeholder,
|
|
11186
11193
|
label: label,
|
|
11187
|
-
error: error
|
|
11194
|
+
error: error,
|
|
11195
|
+
"aria-describedby": ariaDescribedBy
|
|
11188
11196
|
}, rest)), error && /*#__PURE__*/React__default.createElement("span", {
|
|
11189
11197
|
className: "Field__icon"
|
|
11190
11198
|
}, /*#__PURE__*/React__default.createElement(Warning16, null)))), error && /*#__PURE__*/React__default.createElement("span", {
|
|
11191
|
-
|
|
11199
|
+
id: errorId,
|
|
11200
|
+
className: "Field__error",
|
|
11201
|
+
role: "alert"
|
|
11192
11202
|
}, error)));
|
|
11193
11203
|
});
|
|
11194
11204
|
Field.displayName = 'Field';
|