@pega/cosmos-react-core 8.20.0 → 8.21.1

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 (70) hide show
  1. package/lib/components/CompositeInput/CompositeInput.d.ts.map +1 -1
  2. package/lib/components/CompositeInput/CompositeInput.js +6 -6
  3. package/lib/components/CompositeInput/CompositeInput.js.map +1 -1
  4. package/lib/components/CompositeInput/CompositeInput.styles.d.ts +1 -0
  5. package/lib/components/CompositeInput/CompositeInput.styles.d.ts.map +1 -1
  6. package/lib/components/CompositeInput/CompositeInput.styles.js +30 -1
  7. package/lib/components/CompositeInput/CompositeInput.styles.js.map +1 -1
  8. package/lib/components/DateTime/Input/DateInput.d.ts.map +1 -1
  9. package/lib/components/DateTime/Input/DateInput.js +1 -1
  10. package/lib/components/DateTime/Input/DateInput.js.map +1 -1
  11. package/lib/components/DateTime/Input/DateRangeInput.d.ts.map +1 -1
  12. package/lib/components/DateTime/Input/DateRangeInput.js +1 -1
  13. package/lib/components/DateTime/Input/DateRangeInput.js.map +1 -1
  14. package/lib/components/DateTime/Input/DateTimeInput.d.ts.map +1 -1
  15. package/lib/components/DateTime/Input/DateTimeInput.js +1 -1
  16. package/lib/components/DateTime/Input/DateTimeInput.js.map +1 -1
  17. package/lib/components/DateTime/Input/Duration/DurationInput.d.ts.map +1 -1
  18. package/lib/components/DateTime/Input/Duration/DurationInput.js +1 -1
  19. package/lib/components/DateTime/Input/Duration/DurationInput.js.map +1 -1
  20. package/lib/components/DateTime/Input/MonthInput.d.ts.map +1 -1
  21. package/lib/components/DateTime/Input/MonthInput.js +1 -1
  22. package/lib/components/DateTime/Input/MonthInput.js.map +1 -1
  23. package/lib/components/DateTime/Input/QuarterInput.d.ts.map +1 -1
  24. package/lib/components/DateTime/Input/QuarterInput.js +1 -1
  25. package/lib/components/DateTime/Input/QuarterInput.js.map +1 -1
  26. package/lib/components/DateTime/Input/TimeInput.d.ts.map +1 -1
  27. package/lib/components/DateTime/Input/TimeInput.js +1 -1
  28. package/lib/components/DateTime/Input/TimeInput.js.map +1 -1
  29. package/lib/components/DateTime/Input/TimeRangeInput.d.ts.map +1 -1
  30. package/lib/components/DateTime/Input/TimeRangeInput.js +1 -1
  31. package/lib/components/DateTime/Input/TimeRangeInput.js.map +1 -1
  32. package/lib/components/DateTime/Input/WeekInput.d.ts.map +1 -1
  33. package/lib/components/DateTime/Input/WeekInput.js +1 -1
  34. package/lib/components/DateTime/Input/WeekInput.js.map +1 -1
  35. package/lib/components/File/FileInput.d.ts.map +1 -1
  36. package/lib/components/File/FileInput.js +10 -19
  37. package/lib/components/File/FileInput.js.map +1 -1
  38. package/lib/components/File/FileInput.styles.d.ts +3 -1
  39. package/lib/components/File/FileInput.styles.d.ts.map +1 -1
  40. package/lib/components/File/FileInput.styles.js +16 -18
  41. package/lib/components/File/FileInput.styles.js.map +1 -1
  42. package/lib/components/FormField/FormField.d.ts +1 -1
  43. package/lib/components/FormField/FormField.d.ts.map +1 -1
  44. package/lib/components/FormField/FormField.js +34 -32
  45. package/lib/components/FormField/FormField.js.map +1 -1
  46. package/lib/components/Number/NumberRangeInput.d.ts.map +1 -1
  47. package/lib/components/Number/NumberRangeInput.js +1 -1
  48. package/lib/components/Number/NumberRangeInput.js.map +1 -1
  49. package/lib/components/Phone/PhoneInput.d.ts.map +1 -1
  50. package/lib/components/Phone/PhoneInput.js +1 -1
  51. package/lib/components/Phone/PhoneInput.js.map +1 -1
  52. package/lib/components/RadioCheckGroup/RadioCheckGroup.d.ts.map +1 -1
  53. package/lib/components/RadioCheckGroup/RadioCheckGroup.js +1 -1
  54. package/lib/components/RadioCheckGroup/RadioCheckGroup.js.map +1 -1
  55. package/lib/components/SearchInput/SearchInput.d.ts.map +1 -1
  56. package/lib/components/SearchInput/SearchInput.js +3 -2
  57. package/lib/components/SearchInput/SearchInput.js.map +1 -1
  58. package/lib/components/TextArea/TextArea.d.ts +3 -1
  59. package/lib/components/TextArea/TextArea.d.ts.map +1 -1
  60. package/lib/components/TextArea/TextArea.js +30 -15
  61. package/lib/components/TextArea/TextArea.js.map +1 -1
  62. package/lib/hooks/useI18n.d.ts +2 -0
  63. package/lib/hooks/useI18n.d.ts.map +1 -1
  64. package/lib/i18n/default.d.ts +2 -0
  65. package/lib/i18n/default.d.ts.map +1 -1
  66. package/lib/i18n/default.js +3 -0
  67. package/lib/i18n/default.js.map +1 -1
  68. package/lib/i18n/i18n.d.ts +2 -0
  69. package/lib/i18n/i18n.d.ts.map +1 -1
  70. package/package.json +1 -1
@@ -1,9 +1,9 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { forwardRef, useCallback, useState, useEffect, useMemo, useRef } from 'react';
2
+ import { forwardRef, useCallback, useState, useEffect, useRef } from 'react';
3
3
  import FormField from '../FormField';
4
4
  import { StyledFormControl } from '../FormControl';
5
5
  import { hasProp, withTestIds } from '../../utils';
6
- import { useConsolidatedRef, useElement, useI18n, useTestIds, useUID } from '../../hooks';
6
+ import { useConsolidatedRef, useElement, useI18n, useLiveLog, useTestIds, useUID } from '../../hooks';
7
7
  import Text from '../Text';
8
8
  import VisuallyHiddenText from '../VisuallyHiddenText';
9
9
  import StyledTextArea from './TextArea.styles';
@@ -14,9 +14,12 @@ const TextArea = forwardRef(function TextArea(props, ref) {
14
14
  const t = useI18n();
15
15
  const testIds = useTestIds(testId, getTextAreaTestIds);
16
16
  const [charCount, setCharCount] = useState(value?.length ?? defaultValue?.length ?? 0);
17
+ const [focused, setFocused] = useState(false);
17
18
  const [textAreaEl, setTextAreaEl] = useElement();
18
19
  const textAreaRef = useConsolidatedRef(ref, setTextAreaEl);
19
20
  const prevHeightRef = useRef(0);
21
+ const focusTimeoutRef = useRef(NaN);
22
+ const { announceAssertive } = useLiveLog();
20
23
  const controlProp = {};
21
24
  // Conditionally render component as controlled/uncontrolled
22
25
  if (hasProp(props, 'value')) {
@@ -26,21 +29,15 @@ const TextArea = forwardRef(function TextArea(props, ref) {
26
29
  controlProp.defaultValue = defaultValue ?? '';
27
30
  }
28
31
  const onChange = useCallback((e) => {
32
+ // Announce every change event when the limit is reached or exceeded.
33
+ if (maxLength !== undefined && e.target.value.length >= maxLength) {
34
+ announceAssertive({ message: t('text_area_character_limit'), type: 'warning' });
35
+ }
29
36
  if (!hardStop || maxLength === undefined || e.target.value.length <= maxLength) {
30
37
  onChangeProp?.(e);
31
38
  setCharCount(e.target.value.length);
32
39
  }
33
- }, [onChangeProp, hardStop, maxLength]);
34
- const ariaDescribedBy = useMemo(() => {
35
- const idString = [];
36
- if (info) {
37
- idString.push(`${id}-info`);
38
- }
39
- if (displayCharCount && typeof maxLength === 'number') {
40
- idString.push(`${id}-charCount`);
41
- }
42
- return idString.length ? idString.join(' ') : undefined;
43
- }, [info, id, displayCharCount, maxLength]);
40
+ }, [onChangeProp, hardStop, maxLength, announceAssertive, t]);
44
41
  const recalculateHeight = useCallback(() => {
45
42
  if (!textAreaRef.current)
46
43
  return;
@@ -78,8 +75,26 @@ const TextArea = forwardRef(function TextArea(props, ref) {
78
75
  observer.observe(textAreaEl);
79
76
  return () => observer.disconnect();
80
77
  }, [autoResize, recalculateHeight, textAreaEl]);
81
- const TextAreaControl = (_jsx(StyledFormControl, { "data-testid": testIds.control, ref: textAreaRef, id: id, "aria-describedby": ariaDescribedBy, required: required, disabled: disabled, status: status, readOnly: readOnly, autoResize: autoResize, resizable: autoResize ? false : resizable, maxLength: hardStop ? maxLength : undefined, hasSuggestion: status === 'pending' && !!onResolveSuggestion, ...controlProp, ...restProps, onChange: onChange, as: StyledTextArea }));
82
- return label || displayCharCount ? (_jsx(FormField, { testId: testIds, additionalInfo: additionalInfo, label: label, labelHidden: labelHidden, id: id, readOnly: readOnly, info: info, status: status, charLimitDisplay: displayCharCount && typeof maxLength === 'number' ? (_jsxs(Text, { id: `${id}-charCount`, readOnly: readOnly, variant: 'secondary', "aria-live": maxLength >= 0 && maxLength - charCount <= 20 ? 'polite' : 'off', children: [maxLength >= 0 ? t('x_of_y', [charCount || '0', maxLength]) : charCount, ' ', _jsx(VisuallyHiddenText, { children: t('characters_typed') })] })) : undefined, required: required, disabled: disabled, onResolveSuggestion: onResolveSuggestion, children: TextAreaControl })) : (TextAreaControl);
78
+ useEffect(() => () => {
79
+ clearTimeout(focusTimeoutRef.current);
80
+ }, []);
81
+ const TextAreaControl = (_jsx(StyledFormControl, { "data-testid": testIds.control, ref: textAreaRef, id: id, "aria-describedby":
82
+ // Remove when focused to prevent each change in character count from being announced.
83
+ !focused && displayCharCount && typeof maxLength === 'number'
84
+ ? `${id}-charCount`
85
+ : undefined, required: required, disabled: disabled, status: status, readOnly: readOnly, autoResize: autoResize, resizable: autoResize ? false : resizable, maxLength: hardStop ? maxLength : undefined, hasSuggestion: status === 'pending' && !!onResolveSuggestion, ...controlProp, ...restProps, onChange: onChange, onFocus: (e) => {
86
+ // Need to delay so screen readers will include the character count in announcement on initial focus.
87
+ // Shorter delays did not seem to work.
88
+ focusTimeoutRef.current = window.setTimeout(() => {
89
+ setFocused(true);
90
+ }, 250);
91
+ restProps.onFocus?.(e);
92
+ }, onBlur: (e) => {
93
+ clearTimeout(focusTimeoutRef.current);
94
+ setFocused(false);
95
+ restProps.onBlur?.(e);
96
+ }, as: StyledTextArea }));
97
+ return label || displayCharCount ? (_jsx(FormField, { testId: testIds, additionalInfo: additionalInfo, label: label, labelHidden: labelHidden, id: id, readOnly: readOnly, info: info, status: status, charLimitDisplay: displayCharCount && typeof maxLength === 'number' ? (_jsxs(Text, { id: `${id}-charCount`, readOnly: readOnly, variant: 'secondary', children: [maxLength >= 0 ? t('x_of_y', [charCount || '0', maxLength]) : charCount, ' ', _jsx(VisuallyHiddenText, { children: t('characters_typed') })] })) : undefined, required: required, disabled: disabled, onResolveSuggestion: onResolveSuggestion, children: TextAreaControl })) : (TextAreaControl);
83
98
  });
84
99
  export default withTestIds(TextArea, getTextAreaTestIds);
85
100
  //# sourceMappingURL=TextArea.js.map
@@ -1 +1 @@
1
- {"version":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,QAAQ,EAAE,QAAQ,EAClB,EAAE,EAAE,cAAc,GAClB,CACH,CAAC;IAEF,OAAO,KAAK,IAAI,gBAAgB,CAAC,CAAC,CAAC,CACjC,KAAC,SAAS,IACR,MAAM,EAAE,OAAO,EACf,cAAc,EAAE,cAAc,EAC9B,KAAK,EAAE,KAAK,EACZ,WAAW,EAAE,WAAW,EACxB,EAAE,EAAE,EAAE,EACN,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,MAAM,EACd,gBAAgB,EACd,gBAAgB,IAAI,OAAO,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,CAClD,MAAC,IAAI,IACH,EAAE,EAAE,GAAG,EAAE,YAAY,EACrB,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAC,WAAW,eACR,SAAS,IAAI,CAAC,IAAI,SAAS,GAAG,SAAS,IAAI,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,aAE1E,SAAS,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,SAAS,IAAI,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,GAAG,EAC7E,KAAC,kBAAkB,cAAE,CAAC,CAAC,kBAAkB,CAAC,GAAsB,IAC3D,CACR,CAAC,CAAC,CAAC,SAAS,EAEf,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,mBAAmB,EAAE,mBAAmB,YAEvC,eAAe,GACN,CACb,CAAC,CAAC,CAAC,CACF,eAAe,CAChB,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,WAAW,CAAC,QAAQ,EAAE,kBAAkB,CAAC,CAAC","sourcesContent":["import { forwardRef, useCallback, useState, useEffect, useMemo, useRef } from 'react';\nimport type { FC, Ref, PropsWithoutRef, ChangeEvent, ChangeEventHandler } from 'react';\n\nimport type { BaseProps, ForwardProps, NoChildrenProp, TestIdProp } from '../../types';\nimport FormField from '../FormField';\nimport { StyledFormControl } from '../FormControl';\nimport type { FormControlProps } from '../FormControl';\nimport { hasProp, withTestIds } from '../../utils';\nimport { useConsolidatedRef, useElement, useI18n, useTestIds, useUID } from '../../hooks';\nimport Text from '../Text';\nimport VisuallyHiddenText from '../VisuallyHiddenText';\n\nimport StyledTextArea from './TextArea.styles';\nimport { getTextAreaTestIds } from './TextArea.test-ids';\n\nexport interface TextAreaProps extends FormControlProps, BaseProps, NoChildrenProp, TestIdProp {\n /** Minimum length of characters that can be input. */\n minLength?: number;\n /** Maximum length of characters that can be input. */\n maxLength?: number;\n /**\n * Allows the user to resize the Text Area. This prop is ignored if autoResize is true.\n * @default false\n */\n resizable?: boolean;\n /**\n * Enables the Text Area to resize itself automatically.\n * @default true\n */\n autoResize?: boolean;\n /**\n * Display a live character count in relation to the maxLength.\n * @default false\n */\n displayCharCount?: boolean;\n /**\n * Allow or disallow a value beyond the maxLength.\n * @default true\n */\n hardStop?: boolean;\n onChange?: ChangeEventHandler<HTMLTextAreaElement>;\n}\n\nconst TextArea: FC<TextAreaProps & ForwardProps> = forwardRef(function TextArea(\n props: PropsWithoutRef<TextAreaProps>,\n ref: Ref<HTMLTextAreaElement>\n) {\n const uid = useUID();\n const {\n testId,\n additionalInfo,\n id = uid,\n value,\n defaultValue,\n required = false,\n disabled = false,\n readOnly = false,\n label,\n labelHidden,\n info,\n status,\n resizable = false,\n autoResize = true,\n maxLength,\n displayCharCount = false,\n hardStop = true,\n onChange: onChangeProp,\n onResolveSuggestion,\n ...restProps\n } = props;\n const t = useI18n();\n\n const testIds = useTestIds(testId, getTextAreaTestIds);\n const [charCount, setCharCount] = useState(value?.length ?? defaultValue?.length ?? 0);\n const [textAreaEl, setTextAreaEl] = useElement<HTMLTextAreaElement>();\n const textAreaRef = useConsolidatedRef(ref, setTextAreaEl);\n const prevHeightRef = useRef(0);\n\n const controlProp: {\n value?: string;\n defaultValue?: string;\n } = {};\n\n // Conditionally render component as controlled/uncontrolled\n if (hasProp(props, 'value')) {\n controlProp.value = value ?? '';\n } else if (hasProp(props, 'defaultValue')) {\n controlProp.defaultValue = defaultValue ?? '';\n }\n\n const onChange = useCallback(\n (e: ChangeEvent<HTMLTextAreaElement>) => {\n if (!hardStop || maxLength === undefined || e.target.value.length <= maxLength) {\n onChangeProp?.(e);\n setCharCount(e.target.value.length);\n }\n },\n [onChangeProp, hardStop, maxLength]\n );\n\n const ariaDescribedBy = useMemo(() => {\n const idString = [];\n\n if (info) {\n idString.push(`${id}-info`);\n }\n if (displayCharCount && typeof maxLength === 'number') {\n idString.push(`${id}-charCount`);\n }\n\n return idString.length ? idString.join(' ') : undefined;\n }, [info, id, displayCharCount, maxLength]);\n\n const recalculateHeight = useCallback(() => {\n if (!textAreaRef.current) return;\n\n textAreaRef.current.style.setProperty('--textarea-height', 'auto');\n\n // Remove scrollbar width to avoid interference with calculation.\n textAreaRef.current.style.setProperty('scrollbar-width', 'none');\n\n const scrollHeight = textAreaRef.current.scrollHeight;\n const borderWidth = textAreaRef.current.offsetHeight - textAreaRef.current.clientHeight;\n // Set height to auto then scrollHeight + borderWidth to resize TextArea to content\n textAreaRef.current.style.setProperty('--textarea-height', `${scrollHeight + borderWidth}px`);\n\n textAreaRef.current.style.removeProperty('scrollbar-width');\n }, []);\n\n useEffect(() => {\n if (!textAreaRef.current) return;\n\n if (autoResize) {\n recalculateHeight();\n } else {\n textAreaRef.current.style.removeProperty('--textarea-height');\n }\n }, [value, autoResize, recalculateHeight]);\n\n // Recalculate height when the element becomes visible after being displayed none.\n useEffect(() => {\n if (!textAreaEl || !autoResize) return;\n\n prevHeightRef.current = textAreaEl.offsetHeight;\n\n const observer = new ResizeObserver(entries => {\n const currentHeight = entries[0].contentRect.height;\n if (prevHeightRef.current === 0 && currentHeight > 0) {\n recalculateHeight();\n }\n prevHeightRef.current = currentHeight;\n });\n\n observer.observe(textAreaEl);\n return () => observer.disconnect();\n }, [autoResize, recalculateHeight, textAreaEl]);\n\n const TextAreaControl = (\n <StyledFormControl\n data-testid={testIds.control}\n ref={textAreaRef}\n id={id}\n aria-describedby={ariaDescribedBy}\n required={required}\n disabled={disabled}\n status={status}\n readOnly={readOnly}\n autoResize={autoResize}\n resizable={autoResize ? false : resizable}\n maxLength={hardStop ? maxLength : undefined}\n hasSuggestion={status === 'pending' && !!onResolveSuggestion}\n {...controlProp}\n {...restProps}\n onChange={onChange}\n as={StyledTextArea}\n />\n );\n\n return label || displayCharCount ? (\n <FormField\n testId={testIds}\n additionalInfo={additionalInfo}\n label={label}\n labelHidden={labelHidden}\n id={id}\n readOnly={readOnly}\n info={info}\n status={status}\n charLimitDisplay={\n displayCharCount && typeof maxLength === 'number' ? (\n <Text\n id={`${id}-charCount`}\n readOnly={readOnly}\n variant='secondary'\n aria-live={maxLength >= 0 && maxLength - charCount <= 20 ? 'polite' : 'off'}\n >\n {maxLength >= 0 ? t('x_of_y', [charCount || '0', maxLength]) : charCount}{' '}\n <VisuallyHiddenText>{t('characters_typed')}</VisuallyHiddenText>\n </Text>\n ) : undefined\n }\n required={required}\n disabled={disabled}\n onResolveSuggestion={onResolveSuggestion}\n >\n {TextAreaControl}\n </FormField>\n ) : (\n TextAreaControl\n );\n});\n\nexport default withTestIds(TextArea, getTextAreaTestIds);\n"]}
1
+ {"version":3,"file":"TextArea.js","sourceRoot":"","sources":["../../../src/components/TextArea/TextArea.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAY7E,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EACL,kBAAkB,EAClB,UAAU,EACV,OAAO,EACP,UAAU,EACV,UAAU,EACV,MAAM,EACP,MAAM,aAAa,CA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useEffect, useRef } from 'react';\nimport type {\n FC,\n Ref,\n PropsWithoutRef,\n ChangeEvent,\n ChangeEventHandler,\n FocusEvent,\n FocusEventHandler\n} from 'react';\n\nimport type { BaseProps, ForwardProps, NoChildrenProp, TestIdProp } from '../../types';\nimport FormField from '../FormField';\nimport { StyledFormControl } from '../FormControl';\nimport type { FormControlProps } from '../FormControl';\nimport { hasProp, withTestIds } from '../../utils';\nimport {\n useConsolidatedRef,\n useElement,\n useI18n,\n useLiveLog,\n useTestIds,\n useUID\n} from '../../hooks';\nimport Text from '../Text';\nimport VisuallyHiddenText from '../VisuallyHiddenText';\n\nimport StyledTextArea from './TextArea.styles';\nimport { getTextAreaTestIds } from './TextArea.test-ids';\n\nexport interface TextAreaProps extends FormControlProps, BaseProps, NoChildrenProp, TestIdProp {\n /** Minimum length of characters that can be input. */\n minLength?: number;\n /** Maximum length of characters that can be input. */\n maxLength?: number;\n /**\n * Allows the user to resize the Text Area. This prop is ignored if autoResize is true.\n * @default false\n */\n resizable?: boolean;\n /**\n * Enables the Text Area to resize itself automatically.\n * @default true\n */\n autoResize?: boolean;\n /**\n * Display a live character count in relation to the maxLength.\n * @default false\n */\n displayCharCount?: boolean;\n /**\n * Allow or disallow a value beyond the maxLength.\n * @default true\n */\n hardStop?: boolean;\n\n onChange?: ChangeEventHandler<HTMLTextAreaElement>;\n onFocus?: FocusEventHandler<HTMLTextAreaElement>;\n onBlur?: FocusEventHandler<HTMLTextAreaElement>;\n}\n\nconst TextArea: FC<TextAreaProps & ForwardProps> = forwardRef(function TextArea(\n props: PropsWithoutRef<TextAreaProps>,\n ref: Ref<HTMLTextAreaElement>\n) {\n const uid = useUID();\n const {\n testId,\n additionalInfo,\n id = uid,\n value,\n defaultValue,\n required = false,\n disabled = false,\n readOnly = false,\n label,\n labelHidden,\n info,\n status,\n resizable = false,\n autoResize = true,\n maxLength,\n displayCharCount = false,\n hardStop = true,\n onChange: onChangeProp,\n onResolveSuggestion,\n ...restProps\n } = props;\n const t = useI18n();\n\n const testIds = useTestIds(testId, getTextAreaTestIds);\n const [charCount, setCharCount] = useState(value?.length ?? defaultValue?.length ?? 0);\n const [focused, setFocused] = useState(false);\n const [textAreaEl, setTextAreaEl] = useElement<HTMLTextAreaElement>();\n const textAreaRef = useConsolidatedRef(ref, setTextAreaEl);\n const prevHeightRef = useRef(0);\n const focusTimeoutRef = useRef(NaN);\n const { announceAssertive } = useLiveLog();\n\n const controlProp: {\n value?: string;\n defaultValue?: string;\n } = {};\n\n // Conditionally render component as controlled/uncontrolled\n if (hasProp(props, 'value')) {\n controlProp.value = value ?? '';\n } else if (hasProp(props, 'defaultValue')) {\n controlProp.defaultValue = defaultValue ?? '';\n }\n\n const onChange = useCallback(\n (e: ChangeEvent<HTMLTextAreaElement>) => {\n // Announce every change event when the limit is reached or exceeded.\n if (maxLength !== undefined && e.target.value.length >= maxLength) {\n announceAssertive({ message: t('text_area_character_limit'), type: 'warning' });\n }\n\n if (!hardStop || maxLength === undefined || e.target.value.length <= maxLength) {\n onChangeProp?.(e);\n setCharCount(e.target.value.length);\n }\n },\n [onChangeProp, hardStop, maxLength, announceAssertive, t]\n );\n\n const recalculateHeight = useCallback(() => {\n if (!textAreaRef.current) return;\n\n textAreaRef.current.style.setProperty('--textarea-height', 'auto');\n\n // Remove scrollbar width to avoid interference with calculation.\n textAreaRef.current.style.setProperty('scrollbar-width', 'none');\n\n const scrollHeight = textAreaRef.current.scrollHeight;\n const borderWidth = textAreaRef.current.offsetHeight - textAreaRef.current.clientHeight;\n // Set height to auto then scrollHeight + borderWidth to resize TextArea to content\n textAreaRef.current.style.setProperty('--textarea-height', `${scrollHeight + borderWidth}px`);\n\n textAreaRef.current.style.removeProperty('scrollbar-width');\n }, []);\n\n useEffect(() => {\n if (!textAreaRef.current) return;\n\n if (autoResize) {\n recalculateHeight();\n } else {\n textAreaRef.current.style.removeProperty('--textarea-height');\n }\n }, [value, autoResize, recalculateHeight]);\n\n // Recalculate height when the element becomes visible after being displayed none.\n useEffect(() => {\n if (!textAreaEl || !autoResize) return;\n\n prevHeightRef.current = textAreaEl.offsetHeight;\n\n const observer = new ResizeObserver(entries => {\n const currentHeight = entries[0].contentRect.height;\n if (prevHeightRef.current === 0 && currentHeight > 0) {\n recalculateHeight();\n }\n prevHeightRef.current = currentHeight;\n });\n\n observer.observe(textAreaEl);\n return () => observer.disconnect();\n }, [autoResize, recalculateHeight, textAreaEl]);\n\n useEffect(\n () => () => {\n clearTimeout(focusTimeoutRef.current);\n },\n []\n );\n\n const TextAreaControl = (\n <StyledFormControl\n data-testid={testIds.control}\n ref={textAreaRef}\n id={id}\n aria-describedby={\n // Remove when focused to prevent each change in character count from being announced.\n !focused && displayCharCount && typeof maxLength === 'number'\n ? `${id}-charCount`\n : undefined\n }\n required={required}\n disabled={disabled}\n status={status}\n readOnly={readOnly}\n autoResize={autoResize}\n resizable={autoResize ? false : resizable}\n maxLength={hardStop ? maxLength : undefined}\n hasSuggestion={status === 'pending' && !!onResolveSuggestion}\n {...controlProp}\n {...restProps}\n onChange={onChange}\n onFocus={(e: FocusEvent<HTMLTextAreaElement>) => {\n // Need to delay so screen readers will include the character count in announcement on initial focus.\n // Shorter delays did not seem to work.\n focusTimeoutRef.current = window.setTimeout(() => {\n setFocused(true);\n }, 250);\n\n restProps.onFocus?.(e);\n }}\n onBlur={(e: FocusEvent<HTMLTextAreaElement>) => {\n clearTimeout(focusTimeoutRef.current);\n setFocused(false);\n restProps.onBlur?.(e);\n }}\n as={StyledTextArea}\n />\n );\n\n return label || displayCharCount ? (\n <FormField\n testId={testIds}\n additionalInfo={additionalInfo}\n label={label}\n labelHidden={labelHidden}\n id={id}\n readOnly={readOnly}\n info={info}\n status={status}\n charLimitDisplay={\n displayCharCount && typeof maxLength === 'number' ? (\n <Text id={`${id}-charCount`} readOnly={readOnly} variant='secondary'>\n {maxLength >= 0 ? t('x_of_y', [charCount || '0', maxLength]) : charCount}{' '}\n <VisuallyHiddenText>{t('characters_typed')}</VisuallyHiddenText>\n </Text>\n ) : undefined\n }\n required={required}\n disabled={disabled}\n onResolveSuggestion={onResolveSuggestion}\n >\n {TextAreaControl}\n </FormField>\n ) : (\n TextAreaControl\n );\n});\n\nexport default withTestIds(TextArea, getTextAreaTestIds);\n"]}
@@ -255,6 +255,7 @@ declare const useI18n: () => import("../i18n/translate").TranslationFunction<Rea
255
255
  x_of_y: string;
256
256
  n_more: string;
257
257
  keypress_instruction: string;
258
+ text_area_character_limit: string;
258
259
  preview_link_instruction: string;
259
260
  polite_announcements: string;
260
261
  assertive_announcements: string;
@@ -342,6 +343,7 @@ declare const useI18n: () => import("../i18n/translate").TranslationFunction<Rea
342
343
  many: string;
343
344
  other: string;
344
345
  };
346
+ no_file_chosen: string;
345
347
  attach_files: string;
346
348
  attach_review: string;
347
349
  files_uploaded: {
@@ -1 +1 @@
1
- {"version":3,"file":"useI18n.d.ts","sourceRoot":"","sources":["../../src/hooks/useI18n.ts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,QAAA,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAGZ,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -251,6 +251,7 @@ declare const _default: {
251
251
  x_of_y: string;
252
252
  n_more: string;
253
253
  keypress_instruction: string;
254
+ text_area_character_limit: string;
254
255
  preview_link_instruction: string;
255
256
  polite_announcements: string;
256
257
  assertive_announcements: string;
@@ -338,6 +339,7 @@ declare const _default: {
338
339
  many: string;
339
340
  other: string;
340
341
  };
342
+ no_file_chosen: string;
341
343
  attach_files: string;
342
344
  attach_review: string;
343
345
  files_uploaded: {
@@ -1 +1 @@
1
- {"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../../src/i18n/default.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;AAxtD3C,wBAovDE"}
@@ -268,6 +268,8 @@ export default {
268
268
  // -----------------------------------------------------------------------------
269
269
  // {pkg}:{ComponentDir} entries
270
270
  // -----------------------------------------------------------------------------
271
+ /* core:TextArea */
272
+ text_area_character_limit: 'Maximum character limit reached.',
271
273
  /* core:Link */
272
274
  preview_link_instruction: 'Press {0} and p to open this link in a preview.',
273
275
  /* core:LiveLog */
@@ -371,6 +373,7 @@ export default {
371
373
  many: '{0} items',
372
374
  other: '{0} items'
373
375
  },
376
+ no_file_chosen: 'No file chosen',
374
377
  attach_files: 'Attach files',
375
378
  attach_review: 'Attach or review',
376
379
  files_uploaded: {