react-magma-dom 3.2.0-next.4 → 3.2.0-next.6
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/components/CharacterCounter/CharacterCounter.d.ts +4 -0
- package/dist/components/CharacterCounter/CharacterCounter.stories.d.ts +2 -2
- package/dist/components/Input/InputMessage.d.ts +1 -0
- package/dist/esm/index.js +38 -9
- package/dist/esm/index.js.map +1 -1
- package/dist/properties.json +93 -76
- package/dist/react-magma-dom.cjs.development.js +38 -9
- package/dist/react-magma-dom.cjs.development.js.map +1 -1
- package/dist/react-magma-dom.cjs.production.min.js +1 -1
- package/dist/react-magma-dom.cjs.production.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -6,6 +6,7 @@ export declare const Default: import("@storybook/csf").AnnotatedStoryFn<import("
|
|
|
6
6
|
export declare const WithChildren: {
|
|
7
7
|
(args: any): JSX.Element;
|
|
8
8
|
args: {
|
|
9
|
+
id?: string;
|
|
9
10
|
inputLength?: number;
|
|
10
11
|
isInverse?: boolean;
|
|
11
12
|
maxLength?: number;
|
|
@@ -21,7 +22,6 @@ export declare const WithChildren: {
|
|
|
21
22
|
dir?: string;
|
|
22
23
|
draggable?: boolean | "true" | "false";
|
|
23
24
|
hidden?: boolean;
|
|
24
|
-
id?: string;
|
|
25
25
|
lang?: string;
|
|
26
26
|
placeholder?: string;
|
|
27
27
|
slot?: string;
|
|
@@ -272,6 +272,7 @@ export declare const WithChildren: {
|
|
|
272
272
|
export declare const TextArea: {
|
|
273
273
|
(args: any): JSX.Element;
|
|
274
274
|
args: {
|
|
275
|
+
id?: string;
|
|
275
276
|
inputLength?: number;
|
|
276
277
|
isInverse?: boolean;
|
|
277
278
|
maxLength?: number;
|
|
@@ -287,7 +288,6 @@ export declare const TextArea: {
|
|
|
287
288
|
dir?: string;
|
|
288
289
|
draggable?: boolean | "true" | "false";
|
|
289
290
|
hidden?: boolean;
|
|
290
|
-
id?: string;
|
|
291
291
|
lang?: string;
|
|
292
292
|
placeholder?: string;
|
|
293
293
|
slot?: string;
|
package/dist/esm/index.js
CHANGED
|
@@ -4990,7 +4990,7 @@ var InputBase = /*#__PURE__*/forwardRef(function (props, forwardedRef) {
|
|
|
4990
4990
|
}, children));
|
|
4991
4991
|
});
|
|
4992
4992
|
|
|
4993
|
-
var _excluded$j = ["children", "id", "isInverse", "hasError"];
|
|
4993
|
+
var _excluded$j = ["children", "id", "isInverse", "hasError", "maxLength"];
|
|
4994
4994
|
|
|
4995
4995
|
var _templateObject$f, _templateObject2$6;
|
|
4996
4996
|
|
|
@@ -5027,10 +5027,20 @@ var InputMessage = function InputMessage(_ref) {
|
|
|
5027
5027
|
id = _ref.id,
|
|
5028
5028
|
isInverse = _ref.isInverse,
|
|
5029
5029
|
hasError = _ref.hasError,
|
|
5030
|
+
maxLength = _ref.maxLength,
|
|
5030
5031
|
other = _objectWithoutPropertiesLoose(_ref, _excluded$j);
|
|
5031
5032
|
|
|
5032
|
-
var theme = useContext(ThemeContext);
|
|
5033
|
-
|
|
5033
|
+
var theme = useContext(ThemeContext); //Conditional wrapper based on maxLength, allows Character Counter to render without the Announce component for accessibility purposes.
|
|
5034
|
+
|
|
5035
|
+
function AnnounceWrapper(props) {
|
|
5036
|
+
if (maxLength) {
|
|
5037
|
+
return props.children;
|
|
5038
|
+
}
|
|
5039
|
+
|
|
5040
|
+
return createElement(Announce, null, props.children);
|
|
5041
|
+
}
|
|
5042
|
+
|
|
5043
|
+
return createElement(AnnounceWrapper, null, createElement(Message, Object.assign({}, other, {
|
|
5034
5044
|
"data-testid": "inputMessage",
|
|
5035
5045
|
id: id,
|
|
5036
5046
|
isInverse: isInverse,
|
|
@@ -10045,7 +10055,7 @@ var CalendarMonth = function CalendarMonth(props) {
|
|
|
10045
10055
|
})))));
|
|
10046
10056
|
};
|
|
10047
10057
|
|
|
10048
|
-
var _excluded$I = ["children", "inputLength", "maxLength", "testId", "isInverse"];
|
|
10058
|
+
var _excluded$I = ["children", "id", "inputLength", "maxLength", "testId", "isInverse"];
|
|
10049
10059
|
|
|
10050
10060
|
var _templateObject$A;
|
|
10051
10061
|
|
|
@@ -10059,14 +10069,30 @@ function buildFontWeight(props) {
|
|
|
10059
10069
|
|
|
10060
10070
|
var StyledInputMessage = /*#__PURE__*/_styled(InputMessage)(_templateObject$A || (_templateObject$A = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-weight: ", ";\n"])), buildFontWeight);
|
|
10061
10071
|
var CharacterCounter = /*#__PURE__*/forwardRef(function (props) {
|
|
10062
|
-
var
|
|
10072
|
+
var id = props.id,
|
|
10073
|
+
inputLength = props.inputLength,
|
|
10063
10074
|
maxLength = props.maxLength,
|
|
10064
10075
|
testId = props.testId,
|
|
10065
10076
|
isInverse = props.isInverse,
|
|
10066
10077
|
rest = _objectWithoutPropertiesLoose(props, _excluded$I);
|
|
10067
10078
|
|
|
10068
10079
|
var i18n = useContext(I18nContext);
|
|
10069
|
-
var isOverMaxLength = inputLength > maxLength; //
|
|
10080
|
+
var isOverMaxLength = inputLength > maxLength; // Gets percentage value of total characters within Input to let aria-live have dynamic states.
|
|
10081
|
+
|
|
10082
|
+
var getPercentage = inputLength / maxLength * 100; // Returns aria-live states based on percentage of characters within Input.
|
|
10083
|
+
|
|
10084
|
+
function getAriaLiveState() {
|
|
10085
|
+
if (getPercentage >= 80) {
|
|
10086
|
+
if (getPercentage > 100) {
|
|
10087
|
+
return 'assertive';
|
|
10088
|
+
}
|
|
10089
|
+
|
|
10090
|
+
return 'polite';
|
|
10091
|
+
}
|
|
10092
|
+
|
|
10093
|
+
return 'off';
|
|
10094
|
+
} // As the user types, this calculates the remaining characters set by maxLength which counts down to zero then counts up if over the limit.
|
|
10095
|
+
|
|
10070
10096
|
|
|
10071
10097
|
var characterLimit = maxLength > inputLength ? maxLength - inputLength : inputLength - maxLength;
|
|
10072
10098
|
/*
|
|
@@ -10107,8 +10133,10 @@ var CharacterCounter = /*#__PURE__*/forwardRef(function (props) {
|
|
|
10107
10133
|
}
|
|
10108
10134
|
|
|
10109
10135
|
return createElement("div", Object.assign({
|
|
10110
|
-
"data-testid": testId
|
|
10136
|
+
"data-testid": testId,
|
|
10137
|
+
id: id
|
|
10111
10138
|
}, rest), createElement(StyledInputMessage, {
|
|
10139
|
+
"aria-live": getAriaLiveState(),
|
|
10112
10140
|
hasError: isOverMaxLength,
|
|
10113
10141
|
isInverse: isInverse,
|
|
10114
10142
|
inputLength: inputLength,
|
|
@@ -10144,7 +10172,7 @@ var FormFieldContainer = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
10144
10172
|
|
|
10145
10173
|
var theme = useContext(ThemeContext);
|
|
10146
10174
|
var isInverse = useIsInverse(isInverseProp);
|
|
10147
|
-
var descriptionId = errorMessage || helperMessage ? fieldId + "__desc" : null;
|
|
10175
|
+
var descriptionId = errorMessage || helperMessage || maxLength ? fieldId + "__desc" : null;
|
|
10148
10176
|
return createElement(InverseContext.Provider, {
|
|
10149
10177
|
value: {
|
|
10150
10178
|
isInverse: isInverse
|
|
@@ -10162,6 +10190,7 @@ var FormFieldContainer = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
10162
10190
|
size: inputSize,
|
|
10163
10191
|
style: labelStyle
|
|
10164
10192
|
}, isLabelVisuallyHidden ? createElement(VisuallyHidden, null, labelText) : labelText), children, typeof maxLength === 'number' && createElement(CharacterCounter, {
|
|
10193
|
+
id: descriptionId,
|
|
10165
10194
|
inputLength: inputLength,
|
|
10166
10195
|
isInverse: isInverse,
|
|
10167
10196
|
maxLength: maxLength,
|
|
@@ -10193,7 +10222,7 @@ var Input = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
10193
10222
|
other = _objectWithoutPropertiesLoose(props, _excluded$K);
|
|
10194
10223
|
|
|
10195
10224
|
var id = useGenerateId(defaultId);
|
|
10196
|
-
var descriptionId = errorMessage || helperMessage ? id + "__desc" : null;
|
|
10225
|
+
var descriptionId = errorMessage || helperMessage || maxLength ? id + "__desc" : null;
|
|
10197
10226
|
var isInverse = useIsInverse(props.isInverse);
|
|
10198
10227
|
|
|
10199
10228
|
var _useState = useState(0),
|