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.
Files changed (55) hide show
  1. package/esm/__internal__/character-count/character-count.component.d.ts +2 -2
  2. package/esm/__internal__/character-count/character-count.component.js +16 -7
  3. package/esm/components/date/date.d.ts +0 -1
  4. package/esm/components/decimal/decimal.component.js +1 -0
  5. package/esm/components/grouped-character/grouped-character.component.js +2 -2
  6. package/esm/components/i18n-provider/i18n-provider.component.js +5 -0
  7. package/esm/components/number/number.component.js +2 -2
  8. package/esm/components/select/filterable-select/filterable-select.component.js +11 -1
  9. package/esm/components/select/filterable-select/filterable-select.d.ts +4 -0
  10. package/esm/components/select/multi-select/multi-select.component.js +10 -0
  11. package/esm/components/select/multi-select/multi-select.d.ts +4 -0
  12. package/esm/components/select/select-textbox/select-textbox.component.js +11 -2
  13. package/esm/components/select/select-textbox/select-textbox.d.ts +4 -0
  14. package/esm/components/select/simple-select/simple-select.component.js +10 -0
  15. package/esm/components/select/simple-select/simple-select.d.ts +4 -0
  16. package/esm/components/textarea/textarea.component.d.ts +3 -3
  17. package/esm/components/textarea/textarea.component.js +17 -10
  18. package/esm/components/textbox/textbox.component.d.ts +3 -3
  19. package/esm/components/textbox/textbox.component.js +18 -9
  20. package/esm/components/textbox/textbox.style.d.ts +3 -2
  21. package/esm/components/textbox/textbox.style.js +10 -2
  22. package/esm/hooks/__internal__/useCharacterCount/useCharacterCount.d.ts +6 -1
  23. package/esm/hooks/__internal__/useCharacterCount/useCharacterCount.js +9 -8
  24. package/esm/locales/en-gb.js +5 -0
  25. package/esm/locales/locale.d.ts +5 -0
  26. package/esm/locales/pl-pl.d.ts +2 -0
  27. package/esm/locales/pl-pl.js +17 -0
  28. package/lib/__internal__/character-count/character-count.component.d.ts +2 -2
  29. package/lib/__internal__/character-count/character-count.component.js +17 -7
  30. package/lib/components/date/date.d.ts +0 -1
  31. package/lib/components/decimal/decimal.component.js +1 -0
  32. package/lib/components/grouped-character/grouped-character.component.js +2 -2
  33. package/lib/components/i18n-provider/i18n-provider.component.js +5 -0
  34. package/lib/components/number/number.component.js +2 -2
  35. package/lib/components/select/filterable-select/filterable-select.component.js +11 -1
  36. package/lib/components/select/filterable-select/filterable-select.d.ts +4 -0
  37. package/lib/components/select/multi-select/multi-select.component.js +10 -0
  38. package/lib/components/select/multi-select/multi-select.d.ts +4 -0
  39. package/lib/components/select/select-textbox/select-textbox.component.js +11 -2
  40. package/lib/components/select/select-textbox/select-textbox.d.ts +4 -0
  41. package/lib/components/select/simple-select/simple-select.component.js +10 -0
  42. package/lib/components/select/simple-select/simple-select.d.ts +4 -0
  43. package/lib/components/textarea/textarea.component.d.ts +3 -3
  44. package/lib/components/textarea/textarea.component.js +15 -7
  45. package/lib/components/textbox/textbox.component.d.ts +3 -3
  46. package/lib/components/textbox/textbox.component.js +17 -7
  47. package/lib/components/textbox/textbox.style.d.ts +3 -2
  48. package/lib/components/textbox/textbox.style.js +11 -2
  49. package/lib/hooks/__internal__/useCharacterCount/useCharacterCount.d.ts +6 -1
  50. package/lib/hooks/__internal__/useCharacterCount/useCharacterCount.js +9 -7
  51. package/lib/locales/en-gb.js +5 -0
  52. package/lib/locales/locale.d.ts +5 -0
  53. package/lib/locales/pl-pl.d.ts +2 -0
  54. package/lib/locales/pl-pl.js +19 -1
  55. package/package.json +1 -1
@@ -12,10 +12,18 @@ const ErrorBorder = styled.span`
12
12
  top: 0px;
13
13
  `}
14
14
  `;
15
- const StyledHintText = styled.p`
15
+ const StyledInputHint = styled.p`
16
+ display: block;
17
+ flex: 1;
18
+ margin-top: -3px;
19
+ margin-bottom: 8px;
20
+ color: var(--colorsUtilityYin055);
21
+ white-space: pre-wrap;
22
+ `;
23
+ const StyledHintText = styled.div`
16
24
  margin-top: 0px;
17
25
  margin-bottom: 8px;
18
26
  color: var(--colorsUtilityYin055);
19
27
  font-size: 14px;
20
28
  `;
21
- export { StyledHintText, ErrorBorder };
29
+ export { StyledHintText, ErrorBorder, StyledInputHint };
@@ -1,3 +1,8 @@
1
1
  /// <reference types="react" />
2
- declare const useCharacterCount: (value?: string, characterLimit?: number | undefined, warnOverLimit?: boolean, enforceCharacterLimit?: boolean) => [number | undefined, JSX.Element | null];
2
+ declare const useCharacterCount: (value?: string, characterLimit?: number | undefined, enforceCharacterLimit?: boolean) => [
3
+ number | undefined,
4
+ JSX.Element | null,
5
+ string | undefined,
6
+ string | null
7
+ ];
3
8
  export default useCharacterCount;
@@ -1,12 +1,13 @@
1
- import React, { useMemo } from "react";
1
+ import React, { useMemo, useRef } from "react";
2
2
  import CharacterCount from "../../../__internal__/character-count";
3
3
  import useLocale from "../useLocale";
4
+ import guid from "../../../__internal__/utils/helpers/guid";
4
5
 
5
- const getFormatNumber = (value, locale) => new Intl.NumberFormat(locale).format(value);
6
-
7
- const useCharacterCount = (value = "", characterLimit, warnOverLimit = false, enforceCharacterLimit = true) => {
6
+ const useCharacterCount = (value = "", characterLimit, enforceCharacterLimit = true) => {
8
7
  const isCharacterLimitValid = typeof characterLimit === "number" && !Number.isNaN(characterLimit);
9
8
  const l = useLocale();
9
+ const hintString = l.characterCount.hintString();
10
+ const hintId = useRef(guid());
10
11
  const isOverLimit = useMemo(() => {
11
12
  if (value && isCharacterLimitValid) {
12
13
  return value.length > characterLimit;
@@ -15,11 +16,11 @@ const useCharacterCount = (value = "", characterLimit, warnOverLimit = false, en
15
16
  return false;
16
17
  }, [value, characterLimit, isCharacterLimitValid]);
17
18
  return [enforceCharacterLimit && isCharacterLimitValid ? characterLimit : undefined, isCharacterLimitValid ? /*#__PURE__*/React.createElement(CharacterCount, {
18
- isOverLimit: isOverLimit && warnOverLimit,
19
- value: getFormatNumber(value.length, l.locale()),
20
- limit: getFormatNumber(characterLimit, l.locale()),
19
+ isOverLimit: isOverLimit,
20
+ value: value.length,
21
+ limit: characterLimit,
21
22
  "data-element": "character-limit"
22
- }) : null];
23
+ }) : null, hintId.current, isCharacterLimitValid ? hintString : null];
23
24
  };
24
25
 
25
26
  export default useCharacterCount;
@@ -18,6 +18,11 @@ const enGB = {
18
18
  no: () => "No",
19
19
  yes: () => "Yes"
20
20
  },
21
+ characterCount: {
22
+ hintString: () => "Input contains a character counter",
23
+ tooManyCharacters: (count, formattedCount) => count === 1 ? `You have ${formattedCount} character too many` : `You have ${formattedCount} characters too many`,
24
+ charactersLeft: (count, formattedCount) => count === 1 ? `You have ${formattedCount} character remaining` : `You have ${formattedCount} characters remaining`
25
+ },
21
26
  date: {
22
27
  dateFnsLocale: () => enGBDateLocale
23
28
  },
@@ -11,6 +11,11 @@ interface Locale {
11
11
  batchSelection: {
12
12
  selected: (count: number | string) => string;
13
13
  };
14
+ characterCount: {
15
+ hintString: () => string;
16
+ tooManyCharacters: (count: number, formattedCount: string) => string;
17
+ charactersLeft: (count: number, formattedCount: string) => string;
18
+ };
14
19
  confirm: {
15
20
  no: () => string;
16
21
  yes: () => string;
@@ -1,3 +1,5 @@
1
1
  import Locale from "./locale";
2
+ export declare const PolishPlural: (singularNominativ: string, pluralNominativ: string, pluralGenitive: string, value: number) => string;
2
3
  declare const plPL: Locale;
4
+ export { PolishPlural as PolishPlurals };
3
5
  export default plPL;
@@ -2,6 +2,17 @@ import { pl as plDateLocale } from "./date-fns-locales";
2
2
 
3
3
  const isSingular = count => (typeof count === "string" ? parseInt(count) : count) === 1;
4
4
 
5
+ export const PolishPlural = (singularNominativ, pluralNominativ, pluralGenitive, value) => {
6
+ if (value === 1) {
7
+ return singularNominativ;
8
+ }
9
+
10
+ if (value % 10 >= 2 && value % 10 <= 4 && (value % 100 < 10 || value % 100 >= 20)) {
11
+ return pluralNominativ;
12
+ }
13
+
14
+ return pluralGenitive;
15
+ };
5
16
  const plPL = {
6
17
  locale: () => "pl-PL",
7
18
  actions: {
@@ -18,6 +29,11 @@ const plPL = {
18
29
  no: () => "Nie",
19
30
  yes: () => "Tak"
20
31
  },
32
+ characterCount: {
33
+ hintString: () => "Pole zawiera licznik znaków",
34
+ tooManyCharacters: (count, formattedCount) => `Masz o ${formattedCount} ${PolishPlural("znak", "znaki", "znaków", count)} za dużo`,
35
+ charactersLeft: (count, formattedCount) => `Masz ${formattedCount} ${PolishPlural("pozostały", "pozostałe", "pozostałych", count)} ${PolishPlural("znak", "znaki", "znaków", count)}`
36
+ },
21
37
  date: {
22
38
  dateFnsLocale: () => plDateLocale
23
39
  },
@@ -135,4 +151,5 @@ const plPL = {
135
151
  }
136
152
  }
137
153
  };
154
+ export { PolishPlural as PolishPlurals };
138
155
  export default plPL;
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  interface CharacterCountProps {
3
- value: string;
4
- limit: string;
3
+ value: number;
4
+ limit: number;
5
5
  isOverLimit: boolean;
6
6
  "data-element"?: string;
7
7
  }
@@ -11,6 +11,8 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
11
11
 
12
12
  var _characterCount = _interopRequireDefault(require("./character-count.style"));
13
13
 
14
+ var _useLocale = _interopRequireDefault(require("../../hooks/__internal__/useLocale"));
15
+
14
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
17
 
16
18
  const CharacterCount = ({
@@ -18,17 +20,25 @@ const CharacterCount = ({
18
20
  limit,
19
21
  isOverLimit,
20
22
  "data-element": dataElement
21
- }) => /*#__PURE__*/_react.default.createElement(_characterCount.default, {
22
- "aria-live": "polite",
23
- isOverLimit: isOverLimit,
24
- "data-element": dataElement
25
- }, `${value}/${limit}`);
23
+ }) => {
24
+ const limitMinusValue = +limit - +value;
25
+ const valueMinusLimit = +value - +limit;
26
+ const l = (0, _useLocale.default)();
27
+
28
+ const getFormatNumber = (rawValue, locale) => new Intl.NumberFormat(locale).format(rawValue);
29
+
30
+ return /*#__PURE__*/_react.default.createElement(_characterCount.default, {
31
+ "aria-live": "polite",
32
+ isOverLimit: isOverLimit,
33
+ "data-element": dataElement
34
+ }, !isOverLimit ? l.characterCount.charactersLeft(limitMinusValue, getFormatNumber(limitMinusValue, l.locale())) : l.characterCount.tooManyCharacters(valueMinusLimit, getFormatNumber(valueMinusLimit, l.locale())));
35
+ };
26
36
 
27
37
  CharacterCount.propTypes = {
28
38
  "data-element": _propTypes.default.string,
29
39
  "isOverLimit": _propTypes.default.bool.isRequired,
30
- "limit": _propTypes.default.string.isRequired,
31
- "value": _propTypes.default.string.isRequired
40
+ "limit": _propTypes.default.number.isRequired,
41
+ "value": _propTypes.default.number.isRequired
32
42
  };
33
43
  var _default = CharacterCount;
34
44
  exports.default = _default;
@@ -27,7 +27,6 @@ export interface DateInputProps
27
27
  | "iconOnMouseDown"
28
28
  | "enforceCharacterLimit"
29
29
  | "characterLimit"
30
- | "warnOverLimit"
31
30
  | "iconTabIndex"
32
31
  > {
33
32
  /** Boolean to allow the input to have an empty value */
@@ -341,6 +341,7 @@ Decimal.propTypes = {
341
341
  "id": _propTypes.default.string,
342
342
  "info": _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.bool]),
343
343
  "inlist": _propTypes.default.any,
344
+ "inputHint": _propTypes.default.string,
344
345
  "inputIcon": _propTypes.default.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"]),
345
346
  "inputMode": _propTypes.default.oneOf(["decimal", "email", "none", "numeric", "search", "tel", "text", "url"]),
346
347
  "inputRef": _propTypes.default.func,
@@ -211,7 +211,7 @@ GroupedCharacter.propTypes = {
211
211
  "autoFocus": _propTypes.default.bool,
212
212
  "autoSave": _propTypes.default.string,
213
213
  "capture": _propTypes.default.oneOfType([_propTypes.default.oneOf(["environment", "user"]), _propTypes.default.bool]),
214
- "characterLimit": _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
214
+ "characterLimit": _propTypes.default.number,
215
215
  "checked": _propTypes.default.bool,
216
216
  "children": _propTypes.default.node,
217
217
  "className": _propTypes.default.string,
@@ -256,6 +256,7 @@ GroupedCharacter.propTypes = {
256
256
  "id": _propTypes.default.string,
257
257
  "info": _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.bool]),
258
258
  "inlist": _propTypes.default.any,
259
+ "inputHint": _propTypes.default.string,
259
260
  "inputIcon": _propTypes.default.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"]),
260
261
  "inputMode": _propTypes.default.oneOf(["decimal", "email", "none", "numeric", "search", "tel", "text", "url"]),
261
262
  "inputRef": _propTypes.default.func,
@@ -680,7 +681,6 @@ GroupedCharacter.propTypes = {
680
681
  "value": _propTypes.default.string,
681
682
  "vocab": _propTypes.default.string,
682
683
  "warning": _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.bool]),
683
- "warnOverLimit": _propTypes.default.bool,
684
684
  "width": _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string])
685
685
  };
686
686
  GroupedCharacter.displayName = "GroupedCharacter";
@@ -38,6 +38,11 @@ I18nProvider.propTypes = {
38
38
  "batchSelection": _propTypes.default.shape({
39
39
  "selected": _propTypes.default.func.isRequired
40
40
  }),
41
+ "characterCount": _propTypes.default.shape({
42
+ "charactersLeft": _propTypes.default.func.isRequired,
43
+ "hintString": _propTypes.default.func.isRequired,
44
+ "tooManyCharacters": _propTypes.default.func.isRequired
45
+ }),
41
46
  "confirm": _propTypes.default.shape({
42
47
  "no": _propTypes.default.func.isRequired,
43
48
  "yes": _propTypes.default.func.isRequired
@@ -135,7 +135,7 @@ Number.propTypes = {
135
135
  "autoFocus": _propTypes.default.bool,
136
136
  "autoSave": _propTypes.default.string,
137
137
  "capture": _propTypes.default.oneOfType([_propTypes.default.oneOf(["environment", "user"]), _propTypes.default.bool]),
138
- "characterLimit": _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
138
+ "characterLimit": _propTypes.default.number,
139
139
  "checked": _propTypes.default.bool,
140
140
  "children": _propTypes.default.node,
141
141
  "className": _propTypes.default.string,
@@ -179,6 +179,7 @@ Number.propTypes = {
179
179
  "id": _propTypes.default.string,
180
180
  "info": _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.bool]),
181
181
  "inlist": _propTypes.default.any,
182
+ "inputHint": _propTypes.default.string,
182
183
  "inputIcon": _propTypes.default.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"]),
183
184
  "inputMode": _propTypes.default.oneOf(["decimal", "email", "none", "numeric", "search", "tel", "text", "url"]),
184
185
  "inputRef": _propTypes.default.func,
@@ -602,7 +603,6 @@ Number.propTypes = {
602
603
  "value": _propTypes.default.string,
603
604
  "vocab": _propTypes.default.string,
604
605
  "warning": _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.bool]),
605
- "warnOverLimit": _propTypes.default.bool,
606
606
  "width": _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string])
607
607
  };
608
608
  Number.displayName = "Number";
@@ -47,6 +47,8 @@ let deprecateInputRefWarnTriggered = false;
47
47
  const FilterableSelectList = (0, _withFilter.default)(_selectList.default);
48
48
 
49
49
  const FilterableSelect = /*#__PURE__*/_react.default.forwardRef(({
50
+ "aria-label": ariaLabel,
51
+ "aria-labelledby": ariaLabelledby,
50
52
  value,
51
53
  defaultValue,
52
54
  id,
@@ -489,7 +491,9 @@ const FilterableSelect = /*#__PURE__*/_react.default.forwardRef(({
489
491
  ref: containerRef
490
492
  }, /*#__PURE__*/_react.default.createElement(_selectTextbox.default, _extends({
491
493
  activeDescendantId: activeDescendantId,
492
- labelId: labelId,
494
+ ariaLabel: ariaLabel,
495
+ ariaLabelledby: ariaLabelledby,
496
+ labelId: label ? labelId : undefined,
493
497
  "aria-controls": selectListId.current,
494
498
  isOpen: isOpen,
495
499
  hasTextCursor: true,
@@ -499,6 +503,12 @@ const FilterableSelect = /*#__PURE__*/_react.default.forwardRef(({
499
503
 
500
504
  FilterableSelect.propTypes = { ..._selectTextbox.formInputPropTypes,
501
505
 
506
+ /** Prop to specify the aria-label attribute of the component input */
507
+ "aria-label": _propTypes.default.string,
508
+
509
+ /** Prop to specify the aria-labeledby property of the component input */
510
+ "aria-labelledby": _propTypes.default.string,
511
+
502
512
  /** Identifier used for testing purposes, applied to the root element of the component. */
503
513
  "data-component": _propTypes.default.string,
504
514
 
@@ -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. */
@@ -51,6 +51,8 @@ let deprecateInputRefWarnTriggered = false;
51
51
  const FilterableSelectList = (0, _withFilter.default)(_selectList.default);
52
52
 
53
53
  const MultiSelect = /*#__PURE__*/_react.default.forwardRef(({
54
+ "aria-label": ariaLabel,
55
+ "aria-labelledby": ariaLabelledby,
54
56
  value,
55
57
  defaultValue,
56
58
  id,
@@ -512,6 +514,8 @@ const MultiSelect = /*#__PURE__*/_react.default.forwardRef(({
512
514
  accessibilityLabelId: accessibilityLabelId.current,
513
515
  activeDescendantId: activeDescendantId,
514
516
  "aria-controls": selectListId.current,
517
+ ariaLabel: ariaLabel,
518
+ ariaLabelledby: ariaLabelledby,
515
519
  hasTextCursor: true,
516
520
  isOpen: isOpen,
517
521
  labelId: labelId,
@@ -521,6 +525,12 @@ const MultiSelect = /*#__PURE__*/_react.default.forwardRef(({
521
525
 
522
526
  MultiSelect.propTypes = { ..._selectTextbox.formInputPropTypes,
523
527
 
528
+ /** Prop to specify the aria-label attribute of the component input */
529
+ "aria-label": _propTypes.default.string,
530
+
531
+ /** Prop to specify the aria-labeledby property of the component input */
532
+ "aria-labelledby": _propTypes.default.string,
533
+
524
534
  /** Identifier used for testing purposes, applied to the root element of the component. */
525
535
  "data-component": _propTypes.default.string,
526
536
 
@@ -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. */
@@ -45,6 +45,8 @@ const floatingMiddleware = [(0, _dom.offset)(({
45
45
  })];
46
46
 
47
47
  const SelectTextbox = /*#__PURE__*/_react.default.forwardRef(({
48
+ ariaLabel,
49
+ ariaLabelledBy,
48
50
  accessibilityLabelId,
49
51
  labelId,
50
52
  "aria-controls": ariaControls,
@@ -127,10 +129,10 @@ const SelectTextbox = /*#__PURE__*/_react.default.forwardRef(({
127
129
  function getInputAriaAttributes() {
128
130
  const joinIds = (...ids) => ids.filter(item => item !== undefined).join(" ");
129
131
 
130
- const ariaLabelledby = hasTextCursor ? joinIds(labelId, accessibilityLabelId) : joinIds(labelId, textId.current);
132
+ const combinedAriaLabelledBy = hasTextCursor ? joinIds(ariaLabelledBy || labelId, accessibilityLabelId || textId.current) : joinIds(ariaLabelledBy || labelId, textId.current);
131
133
  return {
132
134
  "aria-expanded": readOnly ? undefined : isOpen,
133
- "aria-labelledby": ariaLabelledby || undefined,
135
+ "aria-labelledby": ariaLabel && !ariaLabelledBy ? undefined : combinedAriaLabelledBy,
134
136
  "aria-activedescendant": activeDescendantId,
135
137
  "aria-controls": ariaControls,
136
138
  "aria-autocomplete": hasTextCursor ? "both" : undefined,
@@ -162,6 +164,7 @@ const SelectTextbox = /*#__PURE__*/_react.default.forwardRef(({
162
164
  }
163
165
 
164
166
  return /*#__PURE__*/_react.default.createElement(_textbox.default, _extends({
167
+ "aria-label": ariaLabel,
165
168
  "data-element": "select-input",
166
169
  inputIcon: "dropdown",
167
170
  autoComplete: "off",
@@ -184,6 +187,12 @@ const formInputPropTypes = {
184
187
  */
185
188
  accessibilityLabelId: _propTypes.default.string,
186
189
 
190
+ /** Prop to specify the aria-label attribute of the component input */
191
+ ariaLabel: _propTypes.default.string,
192
+
193
+ /** Prop to specify the aria-labeledby property of the component input */
194
+ ariaLabelledBy: _propTypes.default.string,
195
+
187
196
  /** Id attribute of the input element */
188
197
  id: _propTypes.default.string,
189
198
 
@@ -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 */
@@ -46,6 +46,8 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
46
46
  let deprecateInputRefWarnTriggered = false;
47
47
 
48
48
  const SimpleSelect = /*#__PURE__*/_react.default.forwardRef(({
49
+ "aria-label": ariaLabel,
50
+ "aria-labelledby": ariaLabelledby,
49
51
  value,
50
52
  defaultValue,
51
53
  id,
@@ -409,8 +411,10 @@ const SimpleSelect = /*#__PURE__*/_react.default.forwardRef(({
409
411
  }, marginProps), /*#__PURE__*/_react.default.createElement("div", {
410
412
  ref: containerRef
411
413
  }, /*#__PURE__*/_react.default.createElement(_selectTextbox.default, _extends({
414
+ ariaLabel: ariaLabel,
412
415
  "aria-controls": selectListId.current,
413
416
  activeDescendantId: activeDescendantId,
417
+ ariaLabelledby: ariaLabelledby,
414
418
  isOpen: isOpen,
415
419
  textboxRef: textboxRef
416
420
  }, getTextboxProps()))), selectList);
@@ -421,6 +425,12 @@ SimpleSelect.propTypes = {
421
425
  ..._propTypes2.default.space,
422
426
  ..._selectTextbox.formInputPropTypes,
423
427
 
428
+ /** Prop to specify the aria-label attribute of the component input */
429
+ "aria-label": _propTypes.default.string,
430
+
431
+ /** Prop to specify the aria-labeledby property of the component input */
432
+ "aria-labelledby": _propTypes.default.string,
433
+
424
434
  /** Identifier used for testing purposes, applied to the root element of the component. */
425
435
  "data-component": _propTypes.default.string,
426
436
 
@@ -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?: string | number;
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 */
@@ -54,13 +54,13 @@ let deprecateInputRefWarnTriggered = false;
54
54
  const Textarea = /*#__PURE__*/_react.default.forwardRef(({
55
55
  "aria-labelledby": ariaLabelledBy,
56
56
  autoFocus,
57
+ inputHint,
57
58
  fieldHelp,
58
59
  label,
59
60
  size,
60
61
  children,
61
62
  characterLimit,
62
63
  enforceCharacterLimit = true,
63
- warnOverLimit = false,
64
64
  onChange,
65
65
  disabled = false,
66
66
  labelInline,
@@ -147,8 +147,7 @@ const Textarea = /*#__PURE__*/_react.default.forwardRef(({
147
147
  label,
148
148
  fieldHelp
149
149
  });
150
- const [maxLength, characterCount] = (0, _useCharacterCount.default)(value, // TODO: Can be removed after the characterLimit type is changed to number
151
- typeof characterLimit === "string" ? parseInt(characterLimit, 10) : characterLimit, warnOverLimit, enforceCharacterLimit);
150
+ const [maxLength, characterCount, characterCountHintId, characterCountHint] = (0, _useCharacterCount.default)(value, characterLimit, enforceCharacterLimit);
152
151
  (0, _react.useEffect)(() => {
153
152
  if (rows) {
154
153
  var _internalRef$current;
@@ -176,6 +175,12 @@ const Textarea = /*#__PURE__*/_react.default.forwardRef(({
176
175
  };
177
176
  }, [expandable]);
178
177
  const hasIconInside = !!(inputIcon || validationIconId && !validationOnLabel);
178
+ const hintId = (0, _react.useRef)((0, _guid.default)());
179
+ const characterCountHintIdValue = characterCount ? characterCountHintId : undefined;
180
+ const inputHintIdValue = inputHint ? hintId.current : undefined;
181
+ const hintIdValue = characterLimit ? characterCountHintIdValue : inputHintIdValue;
182
+ const ariaDescribedByValues = [validationRedesignOptIn ? undefined : ariaDescribedBy, hintIdValue];
183
+ const ariaDescribedByValue = ariaDescribedByValues.filter(Boolean).join(" ");
179
184
 
180
185
  const input = /*#__PURE__*/_react.default.createElement(_input.InputPresentation, {
181
186
  size: size,
@@ -189,7 +194,7 @@ const Textarea = /*#__PURE__*/_react.default.forwardRef(({
189
194
  }, /*#__PURE__*/_react.default.createElement(_input2.default, _extends({
190
195
  "aria-invalid": !!error,
191
196
  "aria-labelledby": ariaLabelledBy,
192
- "aria-describedby": validationRedesignOptIn ? undefined : ariaDescribedBy,
197
+ "aria-describedby": ariaDescribedByValue,
193
198
  autoFocus: autoFocus,
194
199
  name: name,
195
200
  value: value,
@@ -245,7 +250,10 @@ const Textarea = /*#__PURE__*/_react.default.forwardRef(({
245
250
  useValidationIcon: computeLabelPropValues(validationOnLabel),
246
251
  adaptiveLabelBreakpoint: adaptiveLabelBreakpoint,
247
252
  validationRedesignOptIn: validationRedesignOptIn
248
- }, validationRedesignOptIn && labelHelp && /*#__PURE__*/_react.default.createElement(_textbox.StyledHintText, null, labelHelp), validationRedesignOptIn ? /*#__PURE__*/_react.default.createElement(_box.default, {
253
+ }, characterLimit || inputHint ? /*#__PURE__*/_react.default.createElement(_textbox.StyledInputHint, {
254
+ id: hintIdValue,
255
+ "data-element": "input-hint"
256
+ }, characterCountHint || inputHint) : null, validationRedesignOptIn && labelHelp && /*#__PURE__*/_react.default.createElement(_textbox.StyledHintText, null, labelHelp), validationRedesignOptIn ? /*#__PURE__*/_react.default.createElement(_box.default, {
249
257
  position: "relative"
250
258
  }, /*#__PURE__*/_react.default.createElement(_validationMessage.default, {
251
259
  error: error,
@@ -318,7 +326,7 @@ Textarea.propTypes = {
318
326
  "autoFocus": _propTypes.default.bool,
319
327
  "autoSave": _propTypes.default.string,
320
328
  "capture": _propTypes.default.oneOfType([_propTypes.default.oneOf(["environment", "user"]), _propTypes.default.bool]),
321
- "characterLimit": _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
329
+ "characterLimit": _propTypes.default.number,
322
330
  "checked": _propTypes.default.bool,
323
331
  "children": _propTypes.default.node,
324
332
  "className": _propTypes.default.string,
@@ -359,6 +367,7 @@ Textarea.propTypes = {
359
367
  "id": _propTypes.default.string,
360
368
  "info": _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.bool]),
361
369
  "inlist": _propTypes.default.any,
370
+ "inputHint": _propTypes.default.string,
362
371
  "inputIcon": _propTypes.default.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"]),
363
372
  "inputMode": _propTypes.default.oneOf(["decimal", "email", "none", "numeric", "search", "tel", "text", "url"]),
364
373
  "inputRef": _propTypes.default.func,
@@ -779,7 +788,6 @@ Textarea.propTypes = {
779
788
  "value": _propTypes.default.string,
780
789
  "vocab": _propTypes.default.string,
781
790
  "warning": _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.bool]),
782
- "warnOverLimit": _propTypes.default.bool,
783
791
  "width": _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string])
784
792
  };
785
793
  Textarea.displayName = "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?: string | number;
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;