@inseefr/lunatic 3.4.18 → 3.4.19

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 (52) hide show
  1. package/components/Input/Input.js +6 -3
  2. package/components/Input/Input.js.map +1 -1
  3. package/components/Input/Input.spec.js +13 -0
  4. package/components/Input/Input.spec.js.map +1 -1
  5. package/components/Textarea/Textarea.js +4 -1
  6. package/components/Textarea/Textarea.js.map +1 -1
  7. package/components/Textarea/Textarea.spec.js +13 -0
  8. package/components/Textarea/Textarea.spec.js.map +1 -1
  9. package/components/shared/CharactersCount/CharactersCount.d.ts +7 -0
  10. package/components/shared/CharactersCount/CharactersCount.js +20 -0
  11. package/components/shared/CharactersCount/CharactersCount.js.map +1 -0
  12. package/components/shared/CharactersCount/CharactersCount.spec.d.ts +1 -0
  13. package/components/shared/CharactersCount/CharactersCount.spec.js +28 -0
  14. package/components/shared/CharactersCount/CharactersCount.spec.js.map +1 -0
  15. package/components/shared/utils/getCharactersCountId.d.ts +4 -0
  16. package/components/shared/utils/getCharactersCountId.js +10 -0
  17. package/components/shared/utils/getCharactersCountId.js.map +1 -0
  18. package/esm/components/Input/Input.js +6 -3
  19. package/esm/components/Input/Input.js.map +1 -1
  20. package/esm/components/Input/Input.spec.js +13 -0
  21. package/esm/components/Input/Input.spec.js.map +1 -1
  22. package/esm/components/Textarea/Textarea.js +4 -1
  23. package/esm/components/Textarea/Textarea.js.map +1 -1
  24. package/esm/components/Textarea/Textarea.spec.js +13 -0
  25. package/esm/components/Textarea/Textarea.spec.js.map +1 -1
  26. package/esm/components/shared/CharactersCount/CharactersCount.d.ts +7 -0
  27. package/esm/components/shared/CharactersCount/CharactersCount.js +15 -0
  28. package/esm/components/shared/CharactersCount/CharactersCount.js.map +1 -0
  29. package/esm/components/shared/CharactersCount/CharactersCount.spec.d.ts +1 -0
  30. package/esm/components/shared/CharactersCount/CharactersCount.spec.js +26 -0
  31. package/esm/components/shared/CharactersCount/CharactersCount.spec.js.map +1 -0
  32. package/esm/components/shared/utils/getCharactersCountId.d.ts +4 -0
  33. package/esm/components/shared/utils/getCharactersCountId.js +7 -0
  34. package/esm/components/shared/utils/getCharactersCountId.js.map +1 -0
  35. package/esm/main.css +10 -0
  36. package/esm/main.css.map +1 -1
  37. package/main.css +10 -0
  38. package/main.css.map +1 -1
  39. package/package.json +23 -1
  40. package/src/components/Input/Input.spec.tsx +19 -0
  41. package/src/components/Input/Input.tsx +26 -18
  42. package/src/components/Input/__snapshots__/Input.spec.tsx.snap +27 -19
  43. package/src/components/RosterForLoop/__snapshots__/RosterForLoop.spec.tsx.snap +42 -20
  44. package/src/components/Textarea/Textarea.spec.tsx +18 -0
  45. package/src/components/Textarea/Textarea.tsx +21 -13
  46. package/src/components/Textarea/__snapshots__/Textarea.spec.tsx.snap +21 -11
  47. package/src/components/shared/CharactersCount/CharactersCount.spec.tsx +31 -0
  48. package/src/components/shared/CharactersCount/CharactersCount.tsx +27 -0
  49. package/src/components/shared/utils/getCharactersCountId.test.ts +14 -0
  50. package/src/components/shared/utils/getCharactersCountId.ts +6 -0
  51. package/src/css/components/Input.scss +10 -0
  52. package/tsconfig.build.tsbuildinfo +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inseefr/lunatic",
3
- "version": "3.4.18",
3
+ "version": "3.4.19",
4
4
  "description": "Library of questionnaire components",
5
5
  "repository": {
6
6
  "type": "git",
@@ -98,6 +98,8 @@
98
98
  "src/components/shared/Button/IconButton.spec.tsx",
99
99
  "src/components/shared/Button/IconButton.tsx",
100
100
  "src/components/shared/Button/__snapshots__/Button.spec.tsx.snap",
101
+ "src/components/shared/CharactersCount/CharactersCount.spec.tsx",
102
+ "src/components/shared/CharactersCount/CharactersCount.tsx",
101
103
  "src/components/shared/Checkbox/CheckboxOption.spec.tsx",
102
104
  "src/components/shared/Checkbox/CheckboxOption.tsx",
103
105
  "src/components/shared/Checkbox/getShortcutKey.ts",
@@ -177,6 +179,8 @@
177
179
  "src/components/shared/Table/Tr.spec.tsx",
178
180
  "src/components/shared/Table/Tr.tsx",
179
181
  "src/components/shared/Table/index.ts",
182
+ "src/components/shared/utils/getCharactersCountId.test.ts",
183
+ "src/components/shared/utils/getCharactersCountId.ts",
180
184
  "src/components/type.ts",
181
185
  "src/css/components/Button.scss",
182
186
  "src/css/components/CheckboxGroup.scss",
@@ -640,6 +644,12 @@
640
644
  "components/shared/Button/IconButton.spec.d.ts",
641
645
  "components/shared/Button/IconButton.spec.js",
642
646
  "components/shared/Button/IconButton.spec.js.map",
647
+ "components/shared/CharactersCount/CharactersCount.d.ts",
648
+ "components/shared/CharactersCount/CharactersCount.js",
649
+ "components/shared/CharactersCount/CharactersCount.js.map",
650
+ "components/shared/CharactersCount/CharactersCount.spec.d.ts",
651
+ "components/shared/CharactersCount/CharactersCount.spec.js",
652
+ "components/shared/CharactersCount/CharactersCount.spec.js.map",
643
653
  "components/shared/Checkbox/CheckboxOption.d.ts",
644
654
  "components/shared/Checkbox/CheckboxOption.js",
645
655
  "components/shared/Checkbox/CheckboxOption.js.map",
@@ -874,6 +884,9 @@
874
884
  "components/shared/Table/index.d.ts",
875
885
  "components/shared/Table/index.js",
876
886
  "components/shared/Table/index.js.map",
887
+ "components/shared/utils/getCharactersCountId.d.ts",
888
+ "components/shared/utils/getCharactersCountId.js",
889
+ "components/shared/utils/getCharactersCountId.js.map",
877
890
  "components/type.d.ts",
878
891
  "components/type.js",
879
892
  "components/type.js.map",
@@ -1048,6 +1061,12 @@
1048
1061
  "esm/components/shared/Button/IconButton.spec.d.ts",
1049
1062
  "esm/components/shared/Button/IconButton.spec.js",
1050
1063
  "esm/components/shared/Button/IconButton.spec.js.map",
1064
+ "esm/components/shared/CharactersCount/CharactersCount.d.ts",
1065
+ "esm/components/shared/CharactersCount/CharactersCount.js",
1066
+ "esm/components/shared/CharactersCount/CharactersCount.js.map",
1067
+ "esm/components/shared/CharactersCount/CharactersCount.spec.d.ts",
1068
+ "esm/components/shared/CharactersCount/CharactersCount.spec.js",
1069
+ "esm/components/shared/CharactersCount/CharactersCount.spec.js.map",
1051
1070
  "esm/components/shared/Checkbox/CheckboxOption.d.ts",
1052
1071
  "esm/components/shared/Checkbox/CheckboxOption.js",
1053
1072
  "esm/components/shared/Checkbox/CheckboxOption.js.map",
@@ -1282,6 +1301,9 @@
1282
1301
  "esm/components/shared/Table/index.d.ts",
1283
1302
  "esm/components/shared/Table/index.js",
1284
1303
  "esm/components/shared/Table/index.js.map",
1304
+ "esm/components/shared/utils/getCharactersCountId.d.ts",
1305
+ "esm/components/shared/utils/getCharactersCountId.js",
1306
+ "esm/components/shared/utils/getCharactersCountId.js.map",
1285
1307
  "esm/components/type.d.ts",
1286
1308
  "esm/components/type.js",
1287
1309
  "esm/components/type.js.map",
@@ -1,6 +1,12 @@
1
1
  import { fireEvent, render, screen } from '@testing-library/react';
2
2
  import { beforeEach, describe, expect, it, vi } from 'vitest';
3
3
  import { Input } from './Input';
4
+ import { CharactersCount } from '../shared/CharactersCount/CharactersCount';
5
+
6
+ vi.mock('../shared/CharactersCount/CharactersCount', () => ({
7
+ CharactersCount: vi.fn(),
8
+ }));
9
+
4
10
  describe('Input', () => {
5
11
  const mockOnChange = vi.fn();
6
12
  const baseProps = {
@@ -34,6 +40,19 @@ describe('Input', () => {
34
40
  expect(input).toBeInTheDocument();
35
41
  });
36
42
 
43
+ it('calls CharactersCount component with correct props', () => {
44
+ const props = { ...baseProps, maxLength: 30 };
45
+ render(<Input {...props} />);
46
+ expect(CharactersCount).toHaveBeenCalledWith(
47
+ {
48
+ id: props.id,
49
+ maxLength: props.maxLength,
50
+ value: props.value,
51
+ },
52
+ {}
53
+ );
54
+ });
55
+
37
56
  it('calls onChange with parsed value', () => {
38
57
  const { container } = render(<Input {...baseProps} errors={undefined} />);
39
58
 
@@ -8,6 +8,8 @@ import {
8
8
  } from '../shared/ComponentErrors/ComponentErrors';
9
9
  import { Declarations } from '../shared/Declarations/Declarations';
10
10
  import type { LunaticError } from '../../use-lunatic/type';
11
+ import { CharactersCount } from '../shared/CharactersCount/CharactersCount';
12
+ import { getCharactersCountId } from '../shared/utils/getCharactersCountId';
11
13
 
12
14
  export function Input({
13
15
  handleChanges,
@@ -47,6 +49,8 @@ export const CustomInput = slottableComponent<CustomProps>('Input', (props) => {
47
49
  declarations,
48
50
  } = props;
49
51
  const labelId = `label-${id}`;
52
+ const charactersCountId = getCharactersCountId(id, maxLength);
53
+
50
54
  return (
51
55
  <div className={classnames('lunatic-input')}>
52
56
  <Label htmlFor={id} id={labelId} description={description}>
@@ -57,24 +61,28 @@ export const CustomInput = slottableComponent<CustomProps>('Input', (props) => {
57
61
  declarations={declarations}
58
62
  id={id}
59
63
  />
60
- <input
61
- id={id}
62
- aria-labelledby={labelId}
63
- autoComplete="off"
64
- type="text"
65
- disabled={disabled}
66
- readOnly={readOnly}
67
- value={(value ?? '').toString()}
68
- title={value ?? ''}
69
- onChange={(e) => onChange(e.target.value)}
70
- aria-required={required}
71
- required={required}
72
- maxLength={maxLength}
73
- aria-invalid={!!errors}
74
- onBlur={(e) => {
75
- e.target.setSelectionRange(0, 0);
76
- }}
77
- />
64
+ <div className="field-with-count">
65
+ <input
66
+ id={id}
67
+ aria-labelledby={labelId}
68
+ aria-describedby={maxLength ? charactersCountId : undefined}
69
+ autoComplete="off"
70
+ type="text"
71
+ disabled={disabled}
72
+ readOnly={readOnly}
73
+ value={(value ?? '').toString()}
74
+ title={value ?? ''}
75
+ onChange={(e) => onChange(e.target.value)}
76
+ aria-required={required}
77
+ required={required}
78
+ maxLength={maxLength}
79
+ aria-invalid={!!errors}
80
+ onBlur={(e) => {
81
+ e.target.setSelectionRange(0, 0);
82
+ }}
83
+ />
84
+ <CharactersCount id={id} maxLength={maxLength} value={value} />
85
+ </div>
78
86
  <ComponentErrors errors={errors} />
79
87
  </div>
80
88
  );
@@ -16,15 +16,19 @@ exports[`Input > renders without crashing 1`] = `
16
16
  description
17
17
  </span>
18
18
  </label>
19
- <input
20
- aria-invalid="false"
21
- aria-labelledby="label-input"
22
- autocomplete="off"
23
- id="input"
24
- title="input"
25
- type="text"
26
- value="input"
27
- />
19
+ <div
20
+ class="field-with-count"
21
+ >
22
+ <input
23
+ aria-invalid="false"
24
+ aria-labelledby="label-input"
25
+ autocomplete="off"
26
+ id="input"
27
+ title="input"
28
+ type="text"
29
+ value="input"
30
+ />
31
+ </div>
28
32
  </div>
29
33
  </div>
30
34
  `;
@@ -34,16 +38,20 @@ exports[`Input > should handle readOnly 1`] = `
34
38
  <div
35
39
  class="lunatic-input"
36
40
  >
37
- <input
38
- aria-invalid="false"
39
- aria-labelledby="label-number"
40
- autocomplete="off"
41
- id="number"
42
- readonly=""
43
- title="toto"
44
- type="text"
45
- value="toto"
46
- />
41
+ <div
42
+ class="field-with-count"
43
+ >
44
+ <input
45
+ aria-invalid="false"
46
+ aria-labelledby="label-number"
47
+ autocomplete="off"
48
+ id="number"
49
+ readonly=""
50
+ title="toto"
51
+ type="text"
52
+ value="toto"
53
+ />
54
+ </div>
47
55
  </div>
48
56
  </div>
49
57
  `;
@@ -31,16 +31,27 @@ exports[`RosterForLoop > renders the right number of columns 1`] = `
31
31
  <div
32
32
  class="lunatic-input"
33
33
  >
34
- <input
35
- aria-invalid="false"
36
- aria-labelledby="label-jrc3ye5q-QOP-lo6tcvvx-0"
37
- autocomplete="off"
38
- id="jrc3ye5q-QOP-lo6tcvvx-0"
39
- maxlength="249"
40
- title="azeaze"
41
- type="text"
42
- value="azeaze"
43
- />
34
+ <div
35
+ class="field-with-count"
36
+ >
37
+ <input
38
+ aria-describedby="characters-count-jrc3ye5q-QOP-lo6tcvvx-0"
39
+ aria-invalid="false"
40
+ aria-labelledby="label-jrc3ye5q-QOP-lo6tcvvx-0"
41
+ autocomplete="off"
42
+ id="jrc3ye5q-QOP-lo6tcvvx-0"
43
+ maxlength="249"
44
+ title="azeaze"
45
+ type="text"
46
+ value="azeaze"
47
+ />
48
+ <span
49
+ class="characters-count"
50
+ id="characters-count-jrc3ye5q-QOP-lo6tcvvx-0"
51
+ >
52
+ 6/249
53
+ </span>
54
+ </div>
44
55
  </div>
45
56
  </div>
46
57
  </div>
@@ -61,16 +72,27 @@ exports[`RosterForLoop > renders the right number of columns 1`] = `
61
72
  <div
62
73
  class="lunatic-input"
63
74
  >
64
- <input
65
- aria-invalid="false"
66
- aria-labelledby="label-jrc3ye5q-QOP-lo6tcvvx-1"
67
- autocomplete="off"
68
- id="jrc3ye5q-QOP-lo6tcvvx-1"
69
- maxlength="249"
70
- title="azeaze"
71
- type="text"
72
- value="azeaze"
73
- />
75
+ <div
76
+ class="field-with-count"
77
+ >
78
+ <input
79
+ aria-describedby="characters-count-jrc3ye5q-QOP-lo6tcvvx-1"
80
+ aria-invalid="false"
81
+ aria-labelledby="label-jrc3ye5q-QOP-lo6tcvvx-1"
82
+ autocomplete="off"
83
+ id="jrc3ye5q-QOP-lo6tcvvx-1"
84
+ maxlength="249"
85
+ title="azeaze"
86
+ type="text"
87
+ value="azeaze"
88
+ />
89
+ <span
90
+ class="characters-count"
91
+ id="characters-count-jrc3ye5q-QOP-lo6tcvvx-1"
92
+ >
93
+ 6/249
94
+ </span>
95
+ </div>
74
96
  </div>
75
97
  </div>
76
98
  </div>
@@ -1,6 +1,11 @@
1
1
  import { render } from '@testing-library/react';
2
2
  import { beforeEach, describe, expect, it, vi } from 'vitest';
3
3
  import { Textarea } from './Textarea';
4
+ import { CharactersCount } from '../shared/CharactersCount/CharactersCount';
5
+
6
+ vi.mock('../shared/CharactersCount/CharactersCount', () => ({
7
+ CharactersCount: vi.fn(),
8
+ }));
4
9
 
5
10
  describe('Textarea', () => {
6
11
  const mockOnChange = vi.fn();
@@ -22,6 +27,19 @@ describe('Textarea', () => {
22
27
  expect(container).toMatchSnapshot();
23
28
  });
24
29
 
30
+ it('calls CharactersCount component with correct props', () => {
31
+ const props = { ...baseProps, maxLength: 30 };
32
+ render(<Textarea {...props} />);
33
+ expect(CharactersCount).toHaveBeenCalledWith(
34
+ {
35
+ id: props.id,
36
+ maxLength: props.maxLength,
37
+ value: props.value,
38
+ },
39
+ {}
40
+ );
41
+ });
42
+
25
43
  it('should handle readOnly', () => {
26
44
  const { container } = render(
27
45
  <Textarea
@@ -7,6 +7,8 @@ import {
7
7
  import { slottableComponent } from '../shared/HOC/slottableComponent';
8
8
  import { Declarations } from '../shared/Declarations/Declarations';
9
9
  import type { LunaticError } from '../../use-lunatic/type';
10
+ import { CharactersCount } from '../shared/CharactersCount/CharactersCount';
11
+ import { getCharactersCountId } from '../shared/utils/getCharactersCountId';
10
12
 
11
13
  export function Textarea({
12
14
  handleChanges,
@@ -51,6 +53,7 @@ export const CustomTextarea = slottableComponent<CustomProps>(
51
53
  placeHolder,
52
54
  } = props;
53
55
  const labelId = `label-${id}`;
56
+ const charactersCountId = getCharactersCountId(id, maxLength);
54
57
 
55
58
  return (
56
59
  <div className="lunatic-textarea">
@@ -62,19 +65,24 @@ export const CustomTextarea = slottableComponent<CustomProps>(
62
65
  declarations={declarations}
63
66
  id={id}
64
67
  />
65
- <textarea
66
- required={required}
67
- disabled={disabled}
68
- id={id}
69
- rows={rows}
70
- maxLength={maxLength}
71
- cols={cols}
72
- onChange={(e) => onChange(e.target.value)}
73
- value={value ?? ''}
74
- placeholder={placeHolder}
75
- readOnly={readOnly}
76
- aria-invalid={!!errors}
77
- />
68
+ <div className="field-with-count">
69
+ <textarea
70
+ required={required}
71
+ disabled={disabled}
72
+ id={id}
73
+ aria-labelledby={labelId}
74
+ aria-describedby={maxLength ? charactersCountId : undefined}
75
+ rows={rows}
76
+ maxLength={maxLength}
77
+ cols={cols}
78
+ onChange={(e) => onChange(e.target.value)}
79
+ value={value ?? ''}
80
+ placeholder={placeHolder}
81
+ readOnly={readOnly}
82
+ aria-invalid={!!errors}
83
+ />
84
+ <CharactersCount id={id} maxLength={maxLength} value={value} />
85
+ </div>
78
86
  <ComponentErrors errors={errors} />
79
87
  </div>
80
88
  );
@@ -5,12 +5,17 @@ exports[`Textarea > renders without crashing 1`] = `
5
5
  <div
6
6
  class="lunatic-textarea"
7
7
  >
8
- <textarea
9
- aria-invalid="false"
10
- id="input"
8
+ <div
9
+ class="field-with-count"
11
10
  >
12
- input
13
- </textarea>
11
+ <textarea
12
+ aria-invalid="false"
13
+ aria-labelledby="label-input"
14
+ id="input"
15
+ >
16
+ input
17
+ </textarea>
18
+ </div>
14
19
  </div>
15
20
  </div>
16
21
  `;
@@ -20,13 +25,18 @@ exports[`Textarea > should handle readOnly 1`] = `
20
25
  <div
21
26
  class="lunatic-textarea"
22
27
  >
23
- <textarea
24
- aria-invalid="false"
25
- id="textarea"
26
- readonly=""
28
+ <div
29
+ class="field-with-count"
27
30
  >
28
- Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
29
- </textarea>
31
+ <textarea
32
+ aria-invalid="false"
33
+ aria-labelledby="label-textarea"
34
+ id="textarea"
35
+ readonly=""
36
+ >
37
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
38
+ </textarea>
39
+ </div>
30
40
  </div>
31
41
  </div>
32
42
  `;
@@ -0,0 +1,31 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { CharactersCount } from './CharactersCount';
3
+ import { render } from '@testing-library/react';
4
+
5
+ describe('CharactersCount', () => {
6
+ const defaultProps = {
7
+ id: 'test-id',
8
+ maxLength: 20,
9
+ value: 'Hello',
10
+ };
11
+
12
+ it('renders correctly characters count if there is a maximum length', () => {
13
+ const { getByText } = render(<CharactersCount {...defaultProps} />);
14
+
15
+ expect(getByText('5/20')).toBeInTheDocument();
16
+ });
17
+
18
+ it('should apply the max-length-reached class when limit is reached', () => {
19
+ const props = { ...defaultProps, maxLength: 5 };
20
+ const { getByText } = render(<CharactersCount {...props} />);
21
+
22
+ expect(getByText('5/5')).toHaveClass('max-length-reached');
23
+ });
24
+
25
+ it('should not render anything when maxLength is not provided', () => {
26
+ const props = { ...defaultProps, maxLength: undefined };
27
+ const { container } = render(<CharactersCount {...props} />);
28
+
29
+ expect(container.firstChild).toBeNull();
30
+ });
31
+ });
@@ -0,0 +1,27 @@
1
+ import classNames from 'classnames';
2
+ import { getCharactersCountId } from '../utils/getCharactersCountId';
3
+
4
+ type Props = {
5
+ id: string;
6
+ maxLength?: number;
7
+ value?: string | null;
8
+ };
9
+
10
+ export function CharactersCount({ id, maxLength, value }: Readonly<Props>) {
11
+ if (!maxLength) return null;
12
+
13
+ const currentLength = value?.length ?? 0;
14
+ const charactersCountId = getCharactersCountId(id, maxLength);
15
+ const hasReachedMaxLength = currentLength === maxLength;
16
+
17
+ return (
18
+ <span
19
+ id={charactersCountId}
20
+ className={classNames('characters-count', {
21
+ 'max-length-reached': hasReachedMaxLength,
22
+ })}
23
+ >
24
+ {`${currentLength}/${maxLength}`}
25
+ </span>
26
+ );
27
+ }
@@ -0,0 +1,14 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { getCharactersCountId } from './getCharactersCountId';
3
+
4
+ describe('getCharacterCountId', () => {
5
+ it('should return the correct ID when maxLength is provided', () => {
6
+ expect(getCharactersCountId('test-id', 100)).toBe(
7
+ 'characters-count-test-id'
8
+ );
9
+ });
10
+
11
+ it('should return undefined when maxLength is not provided', () => {
12
+ expect(getCharactersCountId('test-id')).toBeUndefined();
13
+ });
14
+ });
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Get the correct id for characters count div, used for both input and textarea.
3
+ */
4
+ export function getCharactersCountId(id: string, maxLength?: number) {
5
+ return maxLength ? `characters-count-${id}` : undefined;
6
+ }
@@ -43,3 +43,13 @@
43
43
  }
44
44
  }
45
45
  }
46
+
47
+ .characters-count {
48
+ display: block;
49
+ font-size: 12px;
50
+ padding-top: 0.3rem;
51
+ }
52
+
53
+ .max-length-reached {
54
+ color: red;
55
+ }