carbon-react 116.2.2 → 117.1.0
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/esm/__internal__/character-count/character-count.component.d.ts +2 -2
- package/esm/__internal__/character-count/character-count.component.js +16 -7
- package/esm/components/date/date.d.ts +0 -1
- package/esm/components/decimal/decimal.component.js +1 -0
- package/esm/components/grouped-character/grouped-character.component.js +2 -2
- package/esm/components/i18n-provider/i18n-provider.component.js +5 -0
- package/esm/components/number/number.component.js +2 -2
- package/esm/components/select/filterable-select/filterable-select.component.js +11 -1
- package/esm/components/select/filterable-select/filterable-select.d.ts +4 -0
- package/esm/components/select/multi-select/multi-select.component.js +10 -0
- package/esm/components/select/multi-select/multi-select.d.ts +4 -0
- package/esm/components/select/select-textbox/select-textbox.component.js +11 -2
- package/esm/components/select/select-textbox/select-textbox.d.ts +4 -0
- package/esm/components/select/simple-select/simple-select.component.js +10 -0
- package/esm/components/select/simple-select/simple-select.d.ts +4 -0
- package/esm/components/textarea/textarea.component.d.ts +3 -3
- package/esm/components/textarea/textarea.component.js +17 -10
- package/esm/components/textbox/textbox.component.d.ts +3 -3
- package/esm/components/textbox/textbox.component.js +18 -9
- package/esm/components/textbox/textbox.style.d.ts +3 -2
- package/esm/components/textbox/textbox.style.js +10 -2
- package/esm/hooks/__internal__/useCharacterCount/useCharacterCount.d.ts +6 -1
- package/esm/hooks/__internal__/useCharacterCount/useCharacterCount.js +9 -8
- package/esm/locales/en-gb.js +5 -0
- package/esm/locales/locale.d.ts +5 -0
- package/esm/locales/pl-pl.d.ts +2 -0
- package/esm/locales/pl-pl.js +17 -0
- package/lib/__internal__/character-count/character-count.component.d.ts +2 -2
- package/lib/__internal__/character-count/character-count.component.js +17 -7
- package/lib/components/date/date.d.ts +0 -1
- package/lib/components/decimal/decimal.component.js +1 -0
- package/lib/components/grouped-character/grouped-character.component.js +2 -2
- package/lib/components/i18n-provider/i18n-provider.component.js +5 -0
- package/lib/components/number/number.component.js +2 -2
- package/lib/components/select/filterable-select/filterable-select.component.js +11 -1
- package/lib/components/select/filterable-select/filterable-select.d.ts +4 -0
- package/lib/components/select/multi-select/multi-select.component.js +10 -0
- package/lib/components/select/multi-select/multi-select.d.ts +4 -0
- package/lib/components/select/select-textbox/select-textbox.component.js +11 -2
- package/lib/components/select/select-textbox/select-textbox.d.ts +4 -0
- package/lib/components/select/simple-select/simple-select.component.js +10 -0
- package/lib/components/select/simple-select/simple-select.d.ts +4 -0
- package/lib/components/textarea/textarea.component.d.ts +3 -3
- package/lib/components/textarea/textarea.component.js +15 -7
- package/lib/components/textbox/textbox.component.d.ts +3 -3
- package/lib/components/textbox/textbox.component.js +17 -7
- package/lib/components/textbox/textbox.style.d.ts +3 -2
- package/lib/components/textbox/textbox.style.js +11 -2
- package/lib/hooks/__internal__/useCharacterCount/useCharacterCount.d.ts +6 -1
- package/lib/hooks/__internal__/useCharacterCount/useCharacterCount.js +9 -7
- package/lib/locales/en-gb.js +5 -0
- package/lib/locales/locale.d.ts +5 -0
- package/lib/locales/pl-pl.d.ts +2 -0
- package/lib/locales/pl-pl.js +19 -1
- package/package.json +1 -1
|
@@ -1,22 +1,31 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import PropTypes from "prop-types";
|
|
3
3
|
import StyledCharacterCount from "./character-count.style";
|
|
4
|
+
import useLocale from "../../hooks/__internal__/useLocale";
|
|
4
5
|
|
|
5
6
|
const CharacterCount = ({
|
|
6
7
|
value,
|
|
7
8
|
limit,
|
|
8
9
|
isOverLimit,
|
|
9
10
|
"data-element": dataElement
|
|
10
|
-
}) =>
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
}) => {
|
|
12
|
+
const limitMinusValue = +limit - +value;
|
|
13
|
+
const valueMinusLimit = +value - +limit;
|
|
14
|
+
const l = useLocale();
|
|
15
|
+
|
|
16
|
+
const getFormatNumber = (rawValue, locale) => new Intl.NumberFormat(locale).format(rawValue);
|
|
17
|
+
|
|
18
|
+
return /*#__PURE__*/React.createElement(StyledCharacterCount, {
|
|
19
|
+
"aria-live": "polite",
|
|
20
|
+
isOverLimit: isOverLimit,
|
|
21
|
+
"data-element": dataElement
|
|
22
|
+
}, !isOverLimit ? l.characterCount.charactersLeft(limitMinusValue, getFormatNumber(limitMinusValue, l.locale())) : l.characterCount.tooManyCharacters(valueMinusLimit, getFormatNumber(valueMinusLimit, l.locale())));
|
|
23
|
+
};
|
|
15
24
|
|
|
16
25
|
CharacterCount.propTypes = {
|
|
17
26
|
"data-element": PropTypes.string,
|
|
18
27
|
"isOverLimit": PropTypes.bool.isRequired,
|
|
19
|
-
"limit": PropTypes.
|
|
20
|
-
"value": PropTypes.
|
|
28
|
+
"limit": PropTypes.number.isRequired,
|
|
29
|
+
"value": PropTypes.number.isRequired
|
|
21
30
|
};
|
|
22
31
|
export default CharacterCount;
|
|
@@ -317,6 +317,7 @@ Decimal.propTypes = {
|
|
|
317
317
|
"id": PropTypes.string,
|
|
318
318
|
"info": PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
|
|
319
319
|
"inlist": PropTypes.any,
|
|
320
|
+
"inputHint": PropTypes.string,
|
|
320
321
|
"inputIcon": PropTypes.oneOf(["add", "admin", "alert_on", "alert", "analysis", "arrow_bottom_right_circle", "arrow_down", "arrow_left_boxed", "arrow_left_right_small", "arrow_left_small", "arrow_left", "arrow_right_small", "arrow_right", "arrow_top_left_circle", "arrow_up", "arrow", "arrows_left_right", "attach", "bank_with_card", "bank", "basket_with_squares", "basket", "bed", "bin", "block_arrow_right", "blocked_square", "blocked", "bold", "box_arrow_left", "boxed_shapes", "bulk_destroy", "bullet_list_dotted", "bullet_list_numbers", "bullet_list", "business", "calendar_today", "calendar", "call", "camera", "car_lock", "car_money", "car_repair", "card_view", "caret_down", "caret_large_down", "caret_large_left", "caret_large_right", "caret_large_up", "caret_left", "caret_right", "caret_up", "cart", "cash", "chart_bar", "chart_line", "chart_pie", "chat_notes", "chat", "chevron_down_thick", "chevron_down", "chevron_left_thick", "chevron_left", "chevron_right_thick", "chevron_right", "chevron_up_thick", "chevron_up", "circle_with_dots", "circles_connection", "clock", "close", "coins", "collaborate", "computer_clock", "connect", "construction", "contacts", "copy", "create", "credit_card_slash", "credit_card", "cross_circle", "cross", "csv", "dashboard", "delete", "delivery", "disconnect", "disputed", "document_right_align", "document_tick", "document_vertical_lines", "download", "draft", "drag_vertical", "drag", "drill", "dropdown", "duplicate", "edit", "edited", "ellipsis_horizontal", "ellipsis_vertical", "email_switch", "email", "entry", "envelope_dollar", "envelope_euro", "error_square", "error", "euro", "expand", "factory", "favourite_lined", "favourite", "fax", "feedback", "file_excel", "file_generic", "file_image", "file_pdf", "file_word", "files_leaning", "filter_new", "filter", "fit_height", "fit_width", "flag", "folder", "form_refresh", "gift", "go", "graduation_hat", "graph", "grid", "hand_cash_coins", "hand_cash_note", "help", "hide", "home", "image", "in_progress", "in_transit", "individual", "info", "italic", "key", "laptop", "ledger_arrow_left", "ledger_arrow_right", "ledger", "lightbulb_off", "lightbulb_on", "link", "list_view", "location", "locked", "logout", "lookup", "marker", "message", "minus_large", "minus", "mobile", "money_bag", "none", "old_warning", "palm_tree", "pause_circle", "pause", "pdf", "people_switch", "people", "percentage_boxed", "person_info", "person_tick", "person", "petrol_pump", "phone", "piggy_bank", "plane", "play_circle", "play", "plus_large", "plus", "pound", "print", "progress", "progressed", "question_hollow", "question_mark", "question", "refresh_clock", "refresh", "remove", "sage_coin", "save", "scan", "search", "services", "settings_old", "settings", "share", "shop", "sort_down", "sort_up", "spanner", "split_container", "split", "square_dot", "squares_nine", "stacked_boxes", "stacked_squares", "submitted", "sync", "tag", "talk", "theatre_masks", "three_boxes", "tick_circle", "tick_thick", "tick", "true_tick", "u_turn_left", "u_turn_right", "undo", "unlocked", "upload", "uploaded", "video", "view", "warning"]),
|
|
321
322
|
"inputMode": PropTypes.oneOf(["decimal", "email", "none", "numeric", "search", "tel", "text", "url"]),
|
|
322
323
|
"inputRef": PropTypes.func,
|
|
@@ -190,7 +190,7 @@ GroupedCharacter.propTypes = {
|
|
|
190
190
|
"autoFocus": PropTypes.bool,
|
|
191
191
|
"autoSave": PropTypes.string,
|
|
192
192
|
"capture": PropTypes.oneOfType([PropTypes.oneOf(["environment", "user"]), PropTypes.bool]),
|
|
193
|
-
"characterLimit": PropTypes.
|
|
193
|
+
"characterLimit": PropTypes.number,
|
|
194
194
|
"checked": PropTypes.bool,
|
|
195
195
|
"children": PropTypes.node,
|
|
196
196
|
"className": PropTypes.string,
|
|
@@ -235,6 +235,7 @@ GroupedCharacter.propTypes = {
|
|
|
235
235
|
"id": PropTypes.string,
|
|
236
236
|
"info": PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
|
|
237
237
|
"inlist": PropTypes.any,
|
|
238
|
+
"inputHint": PropTypes.string,
|
|
238
239
|
"inputIcon": PropTypes.oneOf(["add", "admin", "alert_on", "alert", "analysis", "arrow_bottom_right_circle", "arrow_down", "arrow_left_boxed", "arrow_left_right_small", "arrow_left_small", "arrow_left", "arrow_right_small", "arrow_right", "arrow_top_left_circle", "arrow_up", "arrow", "arrows_left_right", "attach", "bank_with_card", "bank", "basket_with_squares", "basket", "bed", "bin", "block_arrow_right", "blocked_square", "blocked", "bold", "box_arrow_left", "boxed_shapes", "bulk_destroy", "bullet_list_dotted", "bullet_list_numbers", "bullet_list", "business", "calendar_today", "calendar", "call", "camera", "car_lock", "car_money", "car_repair", "card_view", "caret_down", "caret_large_down", "caret_large_left", "caret_large_right", "caret_large_up", "caret_left", "caret_right", "caret_up", "cart", "cash", "chart_bar", "chart_line", "chart_pie", "chat_notes", "chat", "chevron_down_thick", "chevron_down", "chevron_left_thick", "chevron_left", "chevron_right_thick", "chevron_right", "chevron_up_thick", "chevron_up", "circle_with_dots", "circles_connection", "clock", "close", "coins", "collaborate", "computer_clock", "connect", "construction", "contacts", "copy", "create", "credit_card_slash", "credit_card", "cross_circle", "cross", "csv", "dashboard", "delete", "delivery", "disconnect", "disputed", "document_right_align", "document_tick", "document_vertical_lines", "download", "draft", "drag_vertical", "drag", "drill", "dropdown", "duplicate", "edit", "edited", "ellipsis_horizontal", "ellipsis_vertical", "email_switch", "email", "entry", "envelope_dollar", "envelope_euro", "error_square", "error", "euro", "expand", "factory", "favourite_lined", "favourite", "fax", "feedback", "file_excel", "file_generic", "file_image", "file_pdf", "file_word", "files_leaning", "filter_new", "filter", "fit_height", "fit_width", "flag", "folder", "form_refresh", "gift", "go", "graduation_hat", "graph", "grid", "hand_cash_coins", "hand_cash_note", "help", "hide", "home", "image", "in_progress", "in_transit", "individual", "info", "italic", "key", "laptop", "ledger_arrow_left", "ledger_arrow_right", "ledger", "lightbulb_off", "lightbulb_on", "link", "list_view", "location", "locked", "logout", "lookup", "marker", "message", "minus_large", "minus", "mobile", "money_bag", "none", "old_warning", "palm_tree", "pause_circle", "pause", "pdf", "people_switch", "people", "percentage_boxed", "person_info", "person_tick", "person", "petrol_pump", "phone", "piggy_bank", "plane", "play_circle", "play", "plus_large", "plus", "pound", "print", "progress", "progressed", "question_hollow", "question_mark", "question", "refresh_clock", "refresh", "remove", "sage_coin", "save", "scan", "search", "services", "settings_old", "settings", "share", "shop", "sort_down", "sort_up", "spanner", "split_container", "split", "square_dot", "squares_nine", "stacked_boxes", "stacked_squares", "submitted", "sync", "tag", "talk", "theatre_masks", "three_boxes", "tick_circle", "tick_thick", "tick", "true_tick", "u_turn_left", "u_turn_right", "undo", "unlocked", "upload", "uploaded", "video", "view", "warning"]),
|
|
239
240
|
"inputMode": PropTypes.oneOf(["decimal", "email", "none", "numeric", "search", "tel", "text", "url"]),
|
|
240
241
|
"inputRef": PropTypes.func,
|
|
@@ -659,7 +660,6 @@ GroupedCharacter.propTypes = {
|
|
|
659
660
|
"value": PropTypes.string,
|
|
660
661
|
"vocab": PropTypes.string,
|
|
661
662
|
"warning": PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
|
|
662
|
-
"warnOverLimit": PropTypes.bool,
|
|
663
663
|
"width": PropTypes.oneOfType([PropTypes.number, PropTypes.string])
|
|
664
664
|
};
|
|
665
665
|
export { GroupedCharacter };
|
|
@@ -24,6 +24,11 @@ I18nProvider.propTypes = {
|
|
|
24
24
|
"batchSelection": PropTypes.shape({
|
|
25
25
|
"selected": PropTypes.func.isRequired
|
|
26
26
|
}),
|
|
27
|
+
"characterCount": PropTypes.shape({
|
|
28
|
+
"charactersLeft": PropTypes.func.isRequired,
|
|
29
|
+
"hintString": PropTypes.func.isRequired,
|
|
30
|
+
"tooManyCharacters": PropTypes.func.isRequired
|
|
31
|
+
}),
|
|
27
32
|
"confirm": PropTypes.shape({
|
|
28
33
|
"no": PropTypes.func.isRequired,
|
|
29
34
|
"yes": PropTypes.func.isRequired
|
|
@@ -115,7 +115,7 @@ Number.propTypes = {
|
|
|
115
115
|
"autoFocus": PropTypes.bool,
|
|
116
116
|
"autoSave": PropTypes.string,
|
|
117
117
|
"capture": PropTypes.oneOfType([PropTypes.oneOf(["environment", "user"]), PropTypes.bool]),
|
|
118
|
-
"characterLimit": PropTypes.
|
|
118
|
+
"characterLimit": PropTypes.number,
|
|
119
119
|
"checked": PropTypes.bool,
|
|
120
120
|
"children": PropTypes.node,
|
|
121
121
|
"className": PropTypes.string,
|
|
@@ -159,6 +159,7 @@ Number.propTypes = {
|
|
|
159
159
|
"id": PropTypes.string,
|
|
160
160
|
"info": PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
|
|
161
161
|
"inlist": PropTypes.any,
|
|
162
|
+
"inputHint": PropTypes.string,
|
|
162
163
|
"inputIcon": PropTypes.oneOf(["add", "admin", "alert_on", "alert", "analysis", "arrow_bottom_right_circle", "arrow_down", "arrow_left_boxed", "arrow_left_right_small", "arrow_left_small", "arrow_left", "arrow_right_small", "arrow_right", "arrow_top_left_circle", "arrow_up", "arrow", "arrows_left_right", "attach", "bank_with_card", "bank", "basket_with_squares", "basket", "bed", "bin", "block_arrow_right", "blocked_square", "blocked", "bold", "box_arrow_left", "boxed_shapes", "bulk_destroy", "bullet_list_dotted", "bullet_list_numbers", "bullet_list", "business", "calendar_today", "calendar", "call", "camera", "car_lock", "car_money", "car_repair", "card_view", "caret_down", "caret_large_down", "caret_large_left", "caret_large_right", "caret_large_up", "caret_left", "caret_right", "caret_up", "cart", "cash", "chart_bar", "chart_line", "chart_pie", "chat_notes", "chat", "chevron_down_thick", "chevron_down", "chevron_left_thick", "chevron_left", "chevron_right_thick", "chevron_right", "chevron_up_thick", "chevron_up", "circle_with_dots", "circles_connection", "clock", "close", "coins", "collaborate", "computer_clock", "connect", "construction", "contacts", "copy", "create", "credit_card_slash", "credit_card", "cross_circle", "cross", "csv", "dashboard", "delete", "delivery", "disconnect", "disputed", "document_right_align", "document_tick", "document_vertical_lines", "download", "draft", "drag_vertical", "drag", "drill", "dropdown", "duplicate", "edit", "edited", "ellipsis_horizontal", "ellipsis_vertical", "email_switch", "email", "entry", "envelope_dollar", "envelope_euro", "error_square", "error", "euro", "expand", "factory", "favourite_lined", "favourite", "fax", "feedback", "file_excel", "file_generic", "file_image", "file_pdf", "file_word", "files_leaning", "filter_new", "filter", "fit_height", "fit_width", "flag", "folder", "form_refresh", "gift", "go", "graduation_hat", "graph", "grid", "hand_cash_coins", "hand_cash_note", "help", "hide", "home", "image", "in_progress", "in_transit", "individual", "info", "italic", "key", "laptop", "ledger_arrow_left", "ledger_arrow_right", "ledger", "lightbulb_off", "lightbulb_on", "link", "list_view", "location", "locked", "logout", "lookup", "marker", "message", "minus_large", "minus", "mobile", "money_bag", "none", "old_warning", "palm_tree", "pause_circle", "pause", "pdf", "people_switch", "people", "percentage_boxed", "person_info", "person_tick", "person", "petrol_pump", "phone", "piggy_bank", "plane", "play_circle", "play", "plus_large", "plus", "pound", "print", "progress", "progressed", "question_hollow", "question_mark", "question", "refresh_clock", "refresh", "remove", "sage_coin", "save", "scan", "search", "services", "settings_old", "settings", "share", "shop", "sort_down", "sort_up", "spanner", "split_container", "split", "square_dot", "squares_nine", "stacked_boxes", "stacked_squares", "submitted", "sync", "tag", "talk", "theatre_masks", "three_boxes", "tick_circle", "tick_thick", "tick", "true_tick", "u_turn_left", "u_turn_right", "undo", "unlocked", "upload", "uploaded", "video", "view", "warning"]),
|
|
163
164
|
"inputMode": PropTypes.oneOf(["decimal", "email", "none", "numeric", "search", "tel", "text", "url"]),
|
|
164
165
|
"inputRef": PropTypes.func,
|
|
@@ -582,7 +583,6 @@ Number.propTypes = {
|
|
|
582
583
|
"value": PropTypes.string,
|
|
583
584
|
"vocab": PropTypes.string,
|
|
584
585
|
"warning": PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
|
|
585
|
-
"warnOverLimit": PropTypes.bool,
|
|
586
586
|
"width": PropTypes.oneOfType([PropTypes.number, PropTypes.string])
|
|
587
587
|
};
|
|
588
588
|
export { Number };
|
|
@@ -18,6 +18,8 @@ import useInputAccessibility from "../../../hooks/__internal__/useInputAccessibi
|
|
|
18
18
|
let deprecateInputRefWarnTriggered = false;
|
|
19
19
|
const FilterableSelectList = withFilter(SelectList);
|
|
20
20
|
const FilterableSelect = /*#__PURE__*/React.forwardRef(({
|
|
21
|
+
"aria-label": ariaLabel,
|
|
22
|
+
"aria-labelledby": ariaLabelledby,
|
|
21
23
|
value,
|
|
22
24
|
defaultValue,
|
|
23
25
|
id,
|
|
@@ -458,7 +460,9 @@ const FilterableSelect = /*#__PURE__*/React.forwardRef(({
|
|
|
458
460
|
ref: containerRef
|
|
459
461
|
}, /*#__PURE__*/React.createElement(SelectTextbox, _extends({
|
|
460
462
|
activeDescendantId: activeDescendantId,
|
|
461
|
-
|
|
463
|
+
ariaLabel: ariaLabel,
|
|
464
|
+
ariaLabelledby: ariaLabelledby,
|
|
465
|
+
labelId: label ? labelId : undefined,
|
|
462
466
|
"aria-controls": selectListId.current,
|
|
463
467
|
isOpen: isOpen,
|
|
464
468
|
hasTextCursor: true,
|
|
@@ -467,6 +471,12 @@ const FilterableSelect = /*#__PURE__*/React.forwardRef(({
|
|
|
467
471
|
});
|
|
468
472
|
FilterableSelect.propTypes = { ...formInputPropTypes,
|
|
469
473
|
|
|
474
|
+
/** Prop to specify the aria-label attribute of the component input */
|
|
475
|
+
"aria-label": PropTypes.string,
|
|
476
|
+
|
|
477
|
+
/** Prop to specify the aria-labeledby property of the component input */
|
|
478
|
+
"aria-labelledby": PropTypes.string,
|
|
479
|
+
|
|
470
480
|
/** Identifier used for testing purposes, applied to the root element of the component. */
|
|
471
481
|
"data-component": PropTypes.string,
|
|
472
482
|
|
|
@@ -5,6 +5,10 @@ import { FormInputPropTypes } from "../select-textbox/select-textbox";
|
|
|
5
5
|
|
|
6
6
|
export interface FilterableSelectProps
|
|
7
7
|
extends Omit<FormInputPropTypes, "defaultValue" | "value"> {
|
|
8
|
+
/** Prop to specify the aria-label attribute of the component input */
|
|
9
|
+
"aria-label"?: string;
|
|
10
|
+
/** Prop to specify the aria-labeledby property of the component input */
|
|
11
|
+
"aria-labelledby"?: string;
|
|
8
12
|
/** Identifier used for testing purposes, applied to the root element of the component. */
|
|
9
13
|
"data-component"?: string;
|
|
10
14
|
/** Identifier used for testing purposes, applied to the root element of the component. */
|
|
@@ -20,6 +20,8 @@ import useInputAccessibility from "../../../hooks/__internal__/useInputAccessibi
|
|
|
20
20
|
let deprecateInputRefWarnTriggered = false;
|
|
21
21
|
const FilterableSelectList = withFilter(SelectList);
|
|
22
22
|
const MultiSelect = /*#__PURE__*/React.forwardRef(({
|
|
23
|
+
"aria-label": ariaLabel,
|
|
24
|
+
"aria-labelledby": ariaLabelledby,
|
|
23
25
|
value,
|
|
24
26
|
defaultValue,
|
|
25
27
|
id,
|
|
@@ -478,6 +480,8 @@ const MultiSelect = /*#__PURE__*/React.forwardRef(({
|
|
|
478
480
|
accessibilityLabelId: accessibilityLabelId.current,
|
|
479
481
|
activeDescendantId: activeDescendantId,
|
|
480
482
|
"aria-controls": selectListId.current,
|
|
483
|
+
ariaLabel: ariaLabel,
|
|
484
|
+
ariaLabelledby: ariaLabelledby,
|
|
481
485
|
hasTextCursor: true,
|
|
482
486
|
isOpen: isOpen,
|
|
483
487
|
labelId: labelId,
|
|
@@ -486,6 +490,12 @@ const MultiSelect = /*#__PURE__*/React.forwardRef(({
|
|
|
486
490
|
});
|
|
487
491
|
MultiSelect.propTypes = { ...formInputPropTypes,
|
|
488
492
|
|
|
493
|
+
/** Prop to specify the aria-label attribute of the component input */
|
|
494
|
+
"aria-label": PropTypes.string,
|
|
495
|
+
|
|
496
|
+
/** Prop to specify the aria-labeledby property of the component input */
|
|
497
|
+
"aria-labelledby": PropTypes.string,
|
|
498
|
+
|
|
489
499
|
/** Identifier used for testing purposes, applied to the root element of the component. */
|
|
490
500
|
"data-component": PropTypes.string,
|
|
491
501
|
|
|
@@ -4,6 +4,10 @@ import { FormInputPropTypes } from "../select-textbox/select-textbox";
|
|
|
4
4
|
|
|
5
5
|
export interface MultiSelectProps
|
|
6
6
|
extends Omit<FormInputPropTypes, "defaultValue" | "value"> {
|
|
7
|
+
/** Prop to specify the aria-label attribute of the component input */
|
|
8
|
+
"aria-label"?: string;
|
|
9
|
+
/** Prop to specify the aria-labeledby property of the component input */
|
|
10
|
+
"aria-labelledby"?: string;
|
|
7
11
|
/** Identifier used for testing purposes, applied to the root element of the component. */
|
|
8
12
|
"data-component"?: string;
|
|
9
13
|
/** Identifier used for testing purposes, applied to the root element of the component. */
|
|
@@ -23,6 +23,8 @@ const floatingMiddleware = [offset(({
|
|
|
23
23
|
|
|
24
24
|
})];
|
|
25
25
|
const SelectTextbox = /*#__PURE__*/React.forwardRef(({
|
|
26
|
+
ariaLabel,
|
|
27
|
+
ariaLabelledBy,
|
|
26
28
|
accessibilityLabelId,
|
|
27
29
|
labelId,
|
|
28
30
|
"aria-controls": ariaControls,
|
|
@@ -105,10 +107,10 @@ const SelectTextbox = /*#__PURE__*/React.forwardRef(({
|
|
|
105
107
|
function getInputAriaAttributes() {
|
|
106
108
|
const joinIds = (...ids) => ids.filter(item => item !== undefined).join(" ");
|
|
107
109
|
|
|
108
|
-
const
|
|
110
|
+
const combinedAriaLabelledBy = hasTextCursor ? joinIds(ariaLabelledBy || labelId, accessibilityLabelId || textId.current) : joinIds(ariaLabelledBy || labelId, textId.current);
|
|
109
111
|
return {
|
|
110
112
|
"aria-expanded": readOnly ? undefined : isOpen,
|
|
111
|
-
"aria-labelledby":
|
|
113
|
+
"aria-labelledby": ariaLabel && !ariaLabelledBy ? undefined : combinedAriaLabelledBy,
|
|
112
114
|
"aria-activedescendant": activeDescendantId,
|
|
113
115
|
"aria-controls": ariaControls,
|
|
114
116
|
"aria-autocomplete": hasTextCursor ? "both" : undefined,
|
|
@@ -140,6 +142,7 @@ const SelectTextbox = /*#__PURE__*/React.forwardRef(({
|
|
|
140
142
|
}
|
|
141
143
|
|
|
142
144
|
return /*#__PURE__*/React.createElement(Textbox, _extends({
|
|
145
|
+
"aria-label": ariaLabel,
|
|
143
146
|
"data-element": "select-input",
|
|
144
147
|
inputIcon: "dropdown",
|
|
145
148
|
autoComplete: "off",
|
|
@@ -161,6 +164,12 @@ const formInputPropTypes = {
|
|
|
161
164
|
*/
|
|
162
165
|
accessibilityLabelId: PropTypes.string,
|
|
163
166
|
|
|
167
|
+
/** Prop to specify the aria-label attribute of the component input */
|
|
168
|
+
ariaLabel: PropTypes.string,
|
|
169
|
+
|
|
170
|
+
/** Prop to specify the aria-labeledby property of the component input */
|
|
171
|
+
ariaLabelledBy: PropTypes.string,
|
|
172
|
+
|
|
164
173
|
/** Id attribute of the input element */
|
|
165
174
|
id: PropTypes.string,
|
|
166
175
|
|
|
@@ -8,6 +8,10 @@ export interface FormInputPropTypes
|
|
|
8
8
|
Omit<CommonTextboxProps, "onClick"> {
|
|
9
9
|
/** Breakpoint for adaptive label (inline labels change to top aligned). Enables the adaptive behaviour when set */
|
|
10
10
|
adaptiveLabelBreakpoint?: number;
|
|
11
|
+
/** Prop to specify the aria-label attribute of the component input */
|
|
12
|
+
ariaLabel?: string;
|
|
13
|
+
/** Prop to specify the aria-labeledby property of the component input */
|
|
14
|
+
ariaLabelledBy?: string;
|
|
11
15
|
/** If true the Component will be focused when rendered */
|
|
12
16
|
autoFocus?: boolean;
|
|
13
17
|
/** If true, the component will be disabled */
|
|
@@ -17,6 +17,8 @@ import useFormSpacing from "../../../hooks/__internal__/useFormSpacing";
|
|
|
17
17
|
import useInputAccessibility from "../../../hooks/__internal__/useInputAccessibility/useInputAccessibility";
|
|
18
18
|
let deprecateInputRefWarnTriggered = false;
|
|
19
19
|
const SimpleSelect = /*#__PURE__*/React.forwardRef(({
|
|
20
|
+
"aria-label": ariaLabel,
|
|
21
|
+
"aria-labelledby": ariaLabelledby,
|
|
20
22
|
value,
|
|
21
23
|
defaultValue,
|
|
22
24
|
id,
|
|
@@ -378,8 +380,10 @@ const SimpleSelect = /*#__PURE__*/React.forwardRef(({
|
|
|
378
380
|
}, marginProps), /*#__PURE__*/React.createElement("div", {
|
|
379
381
|
ref: containerRef
|
|
380
382
|
}, /*#__PURE__*/React.createElement(SelectTextbox, _extends({
|
|
383
|
+
ariaLabel: ariaLabel,
|
|
381
384
|
"aria-controls": selectListId.current,
|
|
382
385
|
activeDescendantId: activeDescendantId,
|
|
386
|
+
ariaLabelledby: ariaLabelledby,
|
|
383
387
|
isOpen: isOpen,
|
|
384
388
|
textboxRef: textboxRef
|
|
385
389
|
}, getTextboxProps()))), selectList);
|
|
@@ -389,6 +393,12 @@ SimpleSelect.propTypes = {
|
|
|
389
393
|
...propTypes.space,
|
|
390
394
|
...formInputPropTypes,
|
|
391
395
|
|
|
396
|
+
/** Prop to specify the aria-label attribute of the component input */
|
|
397
|
+
"aria-label": PropTypes.string,
|
|
398
|
+
|
|
399
|
+
/** Prop to specify the aria-labeledby property of the component input */
|
|
400
|
+
"aria-labelledby": PropTypes.string,
|
|
401
|
+
|
|
392
402
|
/** Identifier used for testing purposes, applied to the root element of the component. */
|
|
393
403
|
"data-component": PropTypes.string,
|
|
394
404
|
|
|
@@ -4,6 +4,10 @@ import { FormInputPropTypes } from "../select-textbox/select-textbox";
|
|
|
4
4
|
|
|
5
5
|
export interface SimpleSelectProps
|
|
6
6
|
extends Omit<FormInputPropTypes, "defaultValue" | "value"> {
|
|
7
|
+
/** Prop to specify the aria-label attribute of the component input */
|
|
8
|
+
"aria-label"?: string;
|
|
9
|
+
/** Prop to specify the aria-labeledby property of the component input */
|
|
10
|
+
"aria-labelledby"?: string;
|
|
7
11
|
/** Identifier used for testing purposes, applied to the root element of the component. */
|
|
8
12
|
"data-component"?: string;
|
|
9
13
|
/** Identifier used for testing purposes, applied to the root element of the component. */
|
|
@@ -19,7 +19,7 @@ export interface TextareaProps extends ValidationProps, MarginProps, Omit<Common
|
|
|
19
19
|
/** Automatically focus the input on component mount */
|
|
20
20
|
autoFocus?: boolean;
|
|
21
21
|
/** Character limit of the textarea */
|
|
22
|
-
characterLimit?:
|
|
22
|
+
characterLimit?: number;
|
|
23
23
|
/** Type of the icon that will be rendered next to the input */
|
|
24
24
|
children?: React.ReactNode;
|
|
25
25
|
/** The visible width of the text control, in average character widths */
|
|
@@ -34,6 +34,8 @@ export interface TextareaProps extends ValidationProps, MarginProps, Omit<Common
|
|
|
34
34
|
error?: boolean | string;
|
|
35
35
|
/** Allows the Textareas Height to change based on user input */
|
|
36
36
|
expandable?: boolean;
|
|
37
|
+
/** A hint string rendered before the input but after the label. Intended to describe the purpose or content of the input. */
|
|
38
|
+
inputHint?: string;
|
|
37
39
|
/** Help content to be displayed under an input */
|
|
38
40
|
fieldHelp?: React.ReactNode;
|
|
39
41
|
/** Aria label for rendered help component */
|
|
@@ -89,8 +91,6 @@ export interface TextareaProps extends ValidationProps, MarginProps, Omit<Common
|
|
|
89
91
|
validationOnLabel?: boolean;
|
|
90
92
|
/** The value of the Textbox */
|
|
91
93
|
value?: string;
|
|
92
|
-
/** Whether to display the character count message in red */
|
|
93
|
-
warnOverLimit?: boolean;
|
|
94
94
|
/** Indicate that warning has occurred
|
|
95
95
|
Pass string to display icon, tooltip and orange border
|
|
96
96
|
Pass true boolean to only display orange border */
|
|
@@ -13,23 +13,22 @@ import StyledTextarea, { MIN_HEIGHT } from "./textarea.style";
|
|
|
13
13
|
import { TooltipProvider } from "../../__internal__/tooltip-provider";
|
|
14
14
|
import useInputAccessibility from "../../hooks/__internal__/useInputAccessibility";
|
|
15
15
|
import { NewValidationContext } from "../carbon-provider/carbon-provider.component";
|
|
16
|
-
import { ErrorBorder, StyledHintText } from "../textbox/textbox.style";
|
|
16
|
+
import { ErrorBorder, StyledHintText, StyledInputHint } from "../textbox/textbox.style";
|
|
17
17
|
import ValidationMessage from "../../__internal__/validation-message";
|
|
18
18
|
import Box from "../box";
|
|
19
19
|
import Logger from "../../__internal__/utils/logger";
|
|
20
|
-
import useFormSpacing from "../../hooks/__internal__/useFormSpacing";
|
|
21
|
-
|
|
20
|
+
import useFormSpacing from "../../hooks/__internal__/useFormSpacing";
|
|
22
21
|
let deprecateInputRefWarnTriggered = false;
|
|
23
22
|
const Textarea = /*#__PURE__*/React.forwardRef(({
|
|
24
23
|
"aria-labelledby": ariaLabelledBy,
|
|
25
24
|
autoFocus,
|
|
25
|
+
inputHint,
|
|
26
26
|
fieldHelp,
|
|
27
27
|
label,
|
|
28
28
|
size,
|
|
29
29
|
children,
|
|
30
30
|
characterLimit,
|
|
31
31
|
enforceCharacterLimit = true,
|
|
32
|
-
warnOverLimit = false,
|
|
33
32
|
onChange,
|
|
34
33
|
disabled = false,
|
|
35
34
|
labelInline,
|
|
@@ -115,8 +114,7 @@ const Textarea = /*#__PURE__*/React.forwardRef(({
|
|
|
115
114
|
label,
|
|
116
115
|
fieldHelp
|
|
117
116
|
});
|
|
118
|
-
const [maxLength, characterCount] = useCharacterCount(value,
|
|
119
|
-
typeof characterLimit === "string" ? parseInt(characterLimit, 10) : characterLimit, warnOverLimit, enforceCharacterLimit);
|
|
117
|
+
const [maxLength, characterCount, characterCountHintId, characterCountHint] = useCharacterCount(value, characterLimit, enforceCharacterLimit);
|
|
120
118
|
useEffect(() => {
|
|
121
119
|
if (rows) {
|
|
122
120
|
var _internalRef$current;
|
|
@@ -144,6 +142,12 @@ const Textarea = /*#__PURE__*/React.forwardRef(({
|
|
|
144
142
|
};
|
|
145
143
|
}, [expandable]);
|
|
146
144
|
const hasIconInside = !!(inputIcon || validationIconId && !validationOnLabel);
|
|
145
|
+
const hintId = useRef(guid());
|
|
146
|
+
const characterCountHintIdValue = characterCount ? characterCountHintId : undefined;
|
|
147
|
+
const inputHintIdValue = inputHint ? hintId.current : undefined;
|
|
148
|
+
const hintIdValue = characterLimit ? characterCountHintIdValue : inputHintIdValue;
|
|
149
|
+
const ariaDescribedByValues = [validationRedesignOptIn ? undefined : ariaDescribedBy, hintIdValue];
|
|
150
|
+
const ariaDescribedByValue = ariaDescribedByValues.filter(Boolean).join(" ");
|
|
147
151
|
const input = /*#__PURE__*/React.createElement(InputPresentation, {
|
|
148
152
|
size: size,
|
|
149
153
|
disabled: disabled,
|
|
@@ -156,7 +160,7 @@ const Textarea = /*#__PURE__*/React.forwardRef(({
|
|
|
156
160
|
}, /*#__PURE__*/React.createElement(Input, _extends({
|
|
157
161
|
"aria-invalid": !!error,
|
|
158
162
|
"aria-labelledby": ariaLabelledBy,
|
|
159
|
-
"aria-describedby":
|
|
163
|
+
"aria-describedby": ariaDescribedByValue,
|
|
160
164
|
autoFocus: autoFocus,
|
|
161
165
|
name: name,
|
|
162
166
|
value: value,
|
|
@@ -211,7 +215,10 @@ const Textarea = /*#__PURE__*/React.forwardRef(({
|
|
|
211
215
|
useValidationIcon: computeLabelPropValues(validationOnLabel),
|
|
212
216
|
adaptiveLabelBreakpoint: adaptiveLabelBreakpoint,
|
|
213
217
|
validationRedesignOptIn: validationRedesignOptIn
|
|
214
|
-
},
|
|
218
|
+
}, characterLimit || inputHint ? /*#__PURE__*/React.createElement(StyledInputHint, {
|
|
219
|
+
id: hintIdValue,
|
|
220
|
+
"data-element": "input-hint"
|
|
221
|
+
}, characterCountHint || inputHint) : null, validationRedesignOptIn && labelHelp && /*#__PURE__*/React.createElement(StyledHintText, null, labelHelp), validationRedesignOptIn ? /*#__PURE__*/React.createElement(Box, {
|
|
215
222
|
position: "relative"
|
|
216
223
|
}, /*#__PURE__*/React.createElement(ValidationMessage, {
|
|
217
224
|
error: error,
|
|
@@ -282,7 +289,7 @@ Textarea.propTypes = {
|
|
|
282
289
|
"autoFocus": PropTypes.bool,
|
|
283
290
|
"autoSave": PropTypes.string,
|
|
284
291
|
"capture": PropTypes.oneOfType([PropTypes.oneOf(["environment", "user"]), PropTypes.bool]),
|
|
285
|
-
"characterLimit": PropTypes.
|
|
292
|
+
"characterLimit": PropTypes.number,
|
|
286
293
|
"checked": PropTypes.bool,
|
|
287
294
|
"children": PropTypes.node,
|
|
288
295
|
"className": PropTypes.string,
|
|
@@ -323,6 +330,7 @@ Textarea.propTypes = {
|
|
|
323
330
|
"id": PropTypes.string,
|
|
324
331
|
"info": PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
|
|
325
332
|
"inlist": PropTypes.any,
|
|
333
|
+
"inputHint": PropTypes.string,
|
|
326
334
|
"inputIcon": PropTypes.oneOf(["add", "admin", "alert_on", "alert", "analysis", "arrow_bottom_right_circle", "arrow_down", "arrow_left_boxed", "arrow_left_right_small", "arrow_left_small", "arrow_left", "arrow_right_small", "arrow_right", "arrow_top_left_circle", "arrow_up", "arrow", "arrows_left_right", "attach", "bank_with_card", "bank", "basket_with_squares", "basket", "bed", "bin", "block_arrow_right", "blocked_square", "blocked", "bold", "box_arrow_left", "boxed_shapes", "bulk_destroy", "bullet_list_dotted", "bullet_list_numbers", "bullet_list", "business", "calendar_today", "calendar", "call", "camera", "car_lock", "car_money", "car_repair", "card_view", "caret_down", "caret_large_down", "caret_large_left", "caret_large_right", "caret_large_up", "caret_left", "caret_right", "caret_up", "cart", "cash", "chart_bar", "chart_line", "chart_pie", "chat_notes", "chat", "chevron_down_thick", "chevron_down", "chevron_left_thick", "chevron_left", "chevron_right_thick", "chevron_right", "chevron_up_thick", "chevron_up", "circle_with_dots", "circles_connection", "clock", "close", "coins", "collaborate", "computer_clock", "connect", "construction", "contacts", "copy", "create", "credit_card_slash", "credit_card", "cross_circle", "cross", "csv", "dashboard", "delete", "delivery", "disconnect", "disputed", "document_right_align", "document_tick", "document_vertical_lines", "download", "draft", "drag_vertical", "drag", "drill", "dropdown", "duplicate", "edit", "edited", "ellipsis_horizontal", "ellipsis_vertical", "email_switch", "email", "entry", "envelope_dollar", "envelope_euro", "error_square", "error", "euro", "expand", "factory", "favourite_lined", "favourite", "fax", "feedback", "file_excel", "file_generic", "file_image", "file_pdf", "file_word", "files_leaning", "filter_new", "filter", "fit_height", "fit_width", "flag", "folder", "form_refresh", "gift", "go", "graduation_hat", "graph", "grid", "hand_cash_coins", "hand_cash_note", "help", "hide", "home", "image", "in_progress", "in_transit", "individual", "info", "italic", "key", "laptop", "ledger_arrow_left", "ledger_arrow_right", "ledger", "lightbulb_off", "lightbulb_on", "link", "list_view", "location", "locked", "logout", "lookup", "marker", "message", "minus_large", "minus", "mobile", "money_bag", "none", "old_warning", "palm_tree", "pause_circle", "pause", "pdf", "people_switch", "people", "percentage_boxed", "person_info", "person_tick", "person", "petrol_pump", "phone", "piggy_bank", "plane", "play_circle", "play", "plus_large", "plus", "pound", "print", "progress", "progressed", "question_hollow", "question_mark", "question", "refresh_clock", "refresh", "remove", "sage_coin", "save", "scan", "search", "services", "settings_old", "settings", "share", "shop", "sort_down", "sort_up", "spanner", "split_container", "split", "square_dot", "squares_nine", "stacked_boxes", "stacked_squares", "submitted", "sync", "tag", "talk", "theatre_masks", "three_boxes", "tick_circle", "tick_thick", "tick", "true_tick", "u_turn_left", "u_turn_right", "undo", "unlocked", "upload", "uploaded", "video", "view", "warning"]),
|
|
327
335
|
"inputMode": PropTypes.oneOf(["decimal", "email", "none", "numeric", "search", "tel", "text", "url"]),
|
|
328
336
|
"inputRef": PropTypes.func,
|
|
@@ -743,7 +751,6 @@ Textarea.propTypes = {
|
|
|
743
751
|
"value": PropTypes.string,
|
|
744
752
|
"vocab": PropTypes.string,
|
|
745
753
|
"warning": PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
|
|
746
|
-
"warnOverLimit": PropTypes.bool,
|
|
747
754
|
"width": PropTypes.oneOfType([PropTypes.number, PropTypes.string])
|
|
748
755
|
};
|
|
749
756
|
export { Textarea };
|
|
@@ -16,6 +16,8 @@ export interface CommonTextboxProps extends ValidationProps, MarginProps, Omit<C
|
|
|
16
16
|
adaptiveLabelBreakpoint?: number;
|
|
17
17
|
/** Integer to determine a timeout for the deferred callback */
|
|
18
18
|
deferTimeout?: number;
|
|
19
|
+
/** A hint string rendered before the input but after the label. Intended to describe the purpose or content of the input. */
|
|
20
|
+
inputHint?: string;
|
|
19
21
|
/** Help content to be displayed under an input */
|
|
20
22
|
fieldHelp?: React.ReactNode;
|
|
21
23
|
/**
|
|
@@ -91,11 +93,9 @@ export interface TextboxProps extends CommonTextboxProps {
|
|
|
91
93
|
/** Container for DatePicker or SelectList components */
|
|
92
94
|
positionedChildren?: React.ReactNode;
|
|
93
95
|
/** Character limit of the textarea */
|
|
94
|
-
characterLimit?:
|
|
96
|
+
characterLimit?: number;
|
|
95
97
|
/** Stop the user typing over the characterLimit */
|
|
96
98
|
enforceCharacterLimit?: boolean;
|
|
97
|
-
/** Whether to display the character count message in red */
|
|
98
|
-
warnOverLimit?: boolean;
|
|
99
99
|
}
|
|
100
100
|
export declare const Textbox: React.ForwardRefExoticComponent<TextboxProps & React.RefAttributes<HTMLInputElement>>;
|
|
101
101
|
export default Textbox;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
2
|
|
|
3
|
-
import React, { useContext } from "react";
|
|
3
|
+
import React, { useContext, useRef } from "react";
|
|
4
4
|
import PropTypes from "prop-types";
|
|
5
5
|
import { filterStyledSystemMarginProps } from "../../style/utils";
|
|
6
6
|
import { Input, InputPresentation } from "../../__internal__/input";
|
|
@@ -12,12 +12,13 @@ import StyledPrefix from "./__internal__/prefix.style";
|
|
|
12
12
|
import { TooltipProvider } from "../../__internal__/tooltip-provider";
|
|
13
13
|
import useCharacterCount from "../../hooks/__internal__/useCharacterCount";
|
|
14
14
|
import useInputAccessibility from "../../hooks/__internal__/useInputAccessibility/useInputAccessibility";
|
|
15
|
-
import { ErrorBorder, StyledHintText } from "./textbox.style";
|
|
15
|
+
import { ErrorBorder, StyledInputHint, StyledHintText } from "./textbox.style";
|
|
16
16
|
import ValidationMessage from "../../__internal__/validation-message";
|
|
17
17
|
import { NewValidationContext } from "../carbon-provider/carbon-provider.component";
|
|
18
18
|
import NumeralDateContext from "../numeral-date/numeral-date-context";
|
|
19
19
|
import Box from "../box";
|
|
20
20
|
import Logger from "../../__internal__/utils/logger";
|
|
21
|
+
import guid from "../../__internal__/utils/helpers/guid";
|
|
21
22
|
let deprecateInputRefWarnTriggered = false;
|
|
22
23
|
const Textbox = /*#__PURE__*/React.forwardRef(({
|
|
23
24
|
"aria-labelledby": ariaLabelledBy,
|
|
@@ -34,6 +35,7 @@ const Textbox = /*#__PURE__*/React.forwardRef(({
|
|
|
34
35
|
labelSpacing,
|
|
35
36
|
id,
|
|
36
37
|
formattedValue,
|
|
38
|
+
inputHint,
|
|
37
39
|
fieldHelp,
|
|
38
40
|
error,
|
|
39
41
|
warning,
|
|
@@ -70,13 +72,11 @@ const Textbox = /*#__PURE__*/React.forwardRef(({
|
|
|
70
72
|
"data-role": dataRole,
|
|
71
73
|
enforceCharacterLimit = true,
|
|
72
74
|
characterLimit,
|
|
73
|
-
warnOverLimit = false,
|
|
74
75
|
helpAriaLabel,
|
|
75
76
|
...props
|
|
76
77
|
}, ref) => {
|
|
77
78
|
const characterCountValue = typeof value === "string" ? value : "";
|
|
78
|
-
const [maxLength, characterCount] = useCharacterCount(characterCountValue,
|
|
79
|
-
typeof characterLimit === "string" ? parseInt(characterLimit, 10) : characterLimit, warnOverLimit, enforceCharacterLimit);
|
|
79
|
+
const [maxLength, characterCount, characterCountHintId, characterCountHint] = useCharacterCount(characterCountValue, characterLimit, enforceCharacterLimit);
|
|
80
80
|
const {
|
|
81
81
|
validationRedesignOptIn
|
|
82
82
|
} = useContext(NewValidationContext);
|
|
@@ -106,6 +106,12 @@ const Textbox = /*#__PURE__*/React.forwardRef(({
|
|
|
106
106
|
label,
|
|
107
107
|
fieldHelp
|
|
108
108
|
});
|
|
109
|
+
const hintId = useRef(guid());
|
|
110
|
+
const characterCountHintIdValue = characterCount ? characterCountHintId : undefined;
|
|
111
|
+
const inputHintIdValue = inputHint ? hintId.current : undefined;
|
|
112
|
+
const hintIdValue = characterLimit ? characterCountHintIdValue : inputHintIdValue;
|
|
113
|
+
const ariaDescribedByValues = [validationRedesignOptIn ? undefined : ariaDescribedBy, hintIdValue];
|
|
114
|
+
const ariaDescribedByValue = ariaDescribedByValues.filter(Boolean).join(" ");
|
|
109
115
|
const hasIconInside = !!(inputIcon || validationIconId && !validationOnLabel);
|
|
110
116
|
const input = /*#__PURE__*/React.createElement(InputPresentation, {
|
|
111
117
|
align: align,
|
|
@@ -128,7 +134,7 @@ const Textbox = /*#__PURE__*/React.forwardRef(({
|
|
|
128
134
|
align: align,
|
|
129
135
|
"aria-invalid": !!error,
|
|
130
136
|
"aria-labelledby": ariaLabelledBy,
|
|
131
|
-
"aria-describedby":
|
|
137
|
+
"aria-describedby": ariaDescribedByValue,
|
|
132
138
|
autoFocus: autoFocus,
|
|
133
139
|
deferTimeout: deferTimeout,
|
|
134
140
|
disabled: disabled,
|
|
@@ -189,7 +195,10 @@ const Textbox = /*#__PURE__*/React.forwardRef(({
|
|
|
189
195
|
"data-element": dataElement,
|
|
190
196
|
validationIconId: validationRedesignOptIn ? undefined : validationIconId,
|
|
191
197
|
validationRedesignOptIn: validationRedesignOptIn
|
|
192
|
-
}, filterStyledSystemMarginProps(props)),
|
|
198
|
+
}, filterStyledSystemMarginProps(props)), characterLimit || inputHint ? /*#__PURE__*/React.createElement(StyledInputHint, {
|
|
199
|
+
id: hintIdValue,
|
|
200
|
+
"data-element": "input-hint"
|
|
201
|
+
}, characterCountHint || inputHint) : null, validationRedesignOptIn && labelHelp && /*#__PURE__*/React.createElement(StyledHintText, null, labelHelp), validationRedesignOptIn ? /*#__PURE__*/React.createElement(Box, {
|
|
193
202
|
position: "relative"
|
|
194
203
|
}, /*#__PURE__*/React.createElement(ValidationMessage, {
|
|
195
204
|
error: error,
|
|
@@ -260,7 +269,7 @@ Textbox.propTypes = {
|
|
|
260
269
|
"autoFocus": PropTypes.bool,
|
|
261
270
|
"autoSave": PropTypes.string,
|
|
262
271
|
"capture": PropTypes.oneOfType([PropTypes.oneOf(["environment", "user"]), PropTypes.bool]),
|
|
263
|
-
"characterLimit": PropTypes.
|
|
272
|
+
"characterLimit": PropTypes.number,
|
|
264
273
|
"checked": PropTypes.bool,
|
|
265
274
|
"children": PropTypes.node,
|
|
266
275
|
"className": PropTypes.string,
|
|
@@ -304,6 +313,7 @@ Textbox.propTypes = {
|
|
|
304
313
|
"id": PropTypes.string,
|
|
305
314
|
"info": PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
|
|
306
315
|
"inlist": PropTypes.any,
|
|
316
|
+
"inputHint": PropTypes.string,
|
|
307
317
|
"inputIcon": PropTypes.oneOf(["add", "admin", "alert_on", "alert", "analysis", "arrow_bottom_right_circle", "arrow_down", "arrow_left_boxed", "arrow_left_right_small", "arrow_left_small", "arrow_left", "arrow_right_small", "arrow_right", "arrow_top_left_circle", "arrow_up", "arrow", "arrows_left_right", "attach", "bank_with_card", "bank", "basket_with_squares", "basket", "bed", "bin", "block_arrow_right", "blocked_square", "blocked", "bold", "box_arrow_left", "boxed_shapes", "bulk_destroy", "bullet_list_dotted", "bullet_list_numbers", "bullet_list", "business", "calendar_today", "calendar", "call", "camera", "car_lock", "car_money", "car_repair", "card_view", "caret_down", "caret_large_down", "caret_large_left", "caret_large_right", "caret_large_up", "caret_left", "caret_right", "caret_up", "cart", "cash", "chart_bar", "chart_line", "chart_pie", "chat_notes", "chat", "chevron_down_thick", "chevron_down", "chevron_left_thick", "chevron_left", "chevron_right_thick", "chevron_right", "chevron_up_thick", "chevron_up", "circle_with_dots", "circles_connection", "clock", "close", "coins", "collaborate", "computer_clock", "connect", "construction", "contacts", "copy", "create", "credit_card_slash", "credit_card", "cross_circle", "cross", "csv", "dashboard", "delete", "delivery", "disconnect", "disputed", "document_right_align", "document_tick", "document_vertical_lines", "download", "draft", "drag_vertical", "drag", "drill", "dropdown", "duplicate", "edit", "edited", "ellipsis_horizontal", "ellipsis_vertical", "email_switch", "email", "entry", "envelope_dollar", "envelope_euro", "error_square", "error", "euro", "expand", "factory", "favourite_lined", "favourite", "fax", "feedback", "file_excel", "file_generic", "file_image", "file_pdf", "file_word", "files_leaning", "filter_new", "filter", "fit_height", "fit_width", "flag", "folder", "form_refresh", "gift", "go", "graduation_hat", "graph", "grid", "hand_cash_coins", "hand_cash_note", "help", "hide", "home", "image", "in_progress", "in_transit", "individual", "info", "italic", "key", "laptop", "ledger_arrow_left", "ledger_arrow_right", "ledger", "lightbulb_off", "lightbulb_on", "link", "list_view", "location", "locked", "logout", "lookup", "marker", "message", "minus_large", "minus", "mobile", "money_bag", "none", "old_warning", "palm_tree", "pause_circle", "pause", "pdf", "people_switch", "people", "percentage_boxed", "person_info", "person_tick", "person", "petrol_pump", "phone", "piggy_bank", "plane", "play_circle", "play", "plus_large", "plus", "pound", "print", "progress", "progressed", "question_hollow", "question_mark", "question", "refresh_clock", "refresh", "remove", "sage_coin", "save", "scan", "search", "services", "settings_old", "settings", "share", "shop", "sort_down", "sort_up", "spanner", "split_container", "split", "square_dot", "squares_nine", "stacked_boxes", "stacked_squares", "submitted", "sync", "tag", "talk", "theatre_masks", "three_boxes", "tick_circle", "tick_thick", "tick", "true_tick", "u_turn_left", "u_turn_right", "undo", "unlocked", "upload", "uploaded", "video", "view", "warning"]),
|
|
308
318
|
"inputMode": PropTypes.oneOf(["decimal", "email", "none", "numeric", "search", "tel", "text", "url"]),
|
|
309
319
|
"inputRef": PropTypes.func,
|
|
@@ -727,7 +737,6 @@ Textbox.propTypes = {
|
|
|
727
737
|
"value": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string), PropTypes.number, PropTypes.string]),
|
|
728
738
|
"vocab": PropTypes.string,
|
|
729
739
|
"warning": PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
|
|
730
|
-
"warnOverLimit": PropTypes.bool,
|
|
731
740
|
"width": PropTypes.oneOfType([PropTypes.number, PropTypes.string])
|
|
732
741
|
};
|
|
733
742
|
export { Textbox };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
declare const ErrorBorder: import("styled-components").StyledComponent<"span", any, {
|
|
2
2
|
warning: boolean;
|
|
3
3
|
}, never>;
|
|
4
|
-
declare const
|
|
5
|
-
|
|
4
|
+
declare const StyledInputHint: import("styled-components").StyledComponent<"p", any, {}, never>;
|
|
5
|
+
declare const StyledHintText: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
6
|
+
export { StyledHintText, ErrorBorder, StyledInputHint };
|