@codecademy/gamut 67.5.2-alpha.e6a0d9.0 → 67.5.2

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.
@@ -4,6 +4,9 @@
4
4
  * Useful for converting JSX to plain text for accessibility purposes
5
5
  * like screenreader announcements or aria-labels.
6
6
  *
7
+ * Also handles components that use a `text` prop instead of children
8
+ * (e.g. the Markdown component).
9
+ *
7
10
  * @param children - React children to extract text from
8
11
  * @returns Plain text string with all text content joined by spaces
9
12
  *
@@ -13,6 +16,7 @@
13
16
  * <div>Hello <strong>world</strong>!</div>
14
17
  * );
15
18
  * // Returns: "Hello world !"
19
+ *
16
20
  * ```
17
21
  */
18
22
  export declare const extractTextContent: (children: React.ReactNode) => string;
@@ -6,6 +6,9 @@ import { Children, isValidElement } from 'react';
6
6
  * Useful for converting JSX to plain text for accessibility purposes
7
7
  * like screenreader announcements or aria-labels.
8
8
  *
9
+ * Also handles components that use a `text` prop instead of children
10
+ * (e.g. the Markdown component).
11
+ *
9
12
  * @param children - React children to extract text from
10
13
  * @returns Plain text string with all text content joined by spaces
11
14
  *
@@ -15,6 +18,7 @@ import { Children, isValidElement } from 'react';
15
18
  * <div>Hello <strong>world</strong>!</div>
16
19
  * );
17
20
  * // Returns: "Hello world !"
21
+ *
18
22
  * ```
19
23
  */
20
24
  export const extractTextContent = children => {
@@ -29,7 +33,8 @@ export const extractTextContent = children => {
29
33
  return '';
30
34
  }
31
35
  if (/*#__PURE__*/isValidElement(child)) {
32
- return extractTextContent(child.props.children);
36
+ const textContent = child.props.children ?? child.props.text ?? '';
37
+ return extractTextContent(textContent);
33
38
  }
34
39
  return '';
35
40
  }).filter(Boolean).join(' ');
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@codecademy/gamut",
3
3
  "description": "Styleguide & Component library for Codecademy",
4
- "version": "67.5.2-alpha.e6a0d9.0",
4
+ "version": "67.5.2",
5
5
  "author": "Codecademy Engineering <dev@codecademy.com>",
6
6
  "dependencies": {
7
7
  "@codecademy/gamut-icons": "9.52.1",
@@ -56,5 +56,5 @@
56
56
  "dist/**/[A-Z]**/[A-Z]*.js",
57
57
  "dist/**/[A-Z]**/index.js"
58
58
  ],
59
- "gitHead": "023fb3b817ae3e05445a3988bba918e8ece5eb80"
59
+ "gitHead": "8faef7dca5e247446a00816f6da4771befdf43c3"
60
60
  }