@hubspot/ui-extensions-sdk-api-metadata 0.12.1 → 0.12.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.
@@ -5,39 +5,39 @@ describe('convertHtmlToJsx', () => {
5
5
  it('should convert <br> to self-closing tag', () => {
6
6
  const input = '<strong>Hello<br>World</strong>';
7
7
  const output = convertHtmlToJsx(input);
8
- expect(output).toBe('<><strong>Hello<br/>World</strong></>');
8
+ expect(output).toBe('<><strong>Hello<br />World</strong></>');
9
9
  });
10
10
  it('should convert <hr> to self-closing tag', () => {
11
11
  const input = '<div>Section 1<hr>Section 2</div>';
12
12
  const output = convertHtmlToJsx(input);
13
- expect(output).toBe('<><div>Section 1<hr/>Section 2</div></>');
13
+ expect(output).toBe('<><div>Section 1<hr />Section 2</div></>');
14
14
  });
15
15
  it('should convert <img> to self-closing tag', () => {
16
16
  const input = '<img src="test.png">';
17
17
  const output = convertHtmlToJsx(input);
18
- expect(output).toBe('<><img src="test.png"/></>');
18
+ expect(output).toBe('<><img src="test.png" /></>');
19
19
  });
20
20
  it('should convert <input> to self-closing tag', () => {
21
21
  const input = '<input type="text" name="field">';
22
22
  const output = convertHtmlToJsx(input);
23
- expect(output).toBe('<><input type="text" name="field"/></>');
23
+ expect(output).toBe('<><input type="text" name="field" /></>');
24
24
  });
25
25
  it('should handle multiple void elements', () => {
26
26
  const input = '<div><img src="a.png"><br><img src="b.png"></div>';
27
27
  const output = convertHtmlToJsx(input);
28
- expect(output).toBe('<><div><img src="a.png"/><br/><img src="b.png"/></div></>');
28
+ expect(output).toBe('<><div><img src="a.png" /><br /><img src="b.png" /></div></>');
29
29
  });
30
30
  it('should preserve already self-closing tags', () => {
31
31
  const input = '<strong>Hello<br/>World</strong>';
32
32
  const output = convertHtmlToJsx(input);
33
- expect(output).toBe('<><strong>Hello<br/>World</strong></>');
33
+ expect(output).toBe('<><strong>Hello<br />World</strong></>');
34
34
  });
35
35
  });
36
36
  describe('attributes', () => {
37
37
  it('should preserve attributes on void elements', () => {
38
38
  const input = '<img src="test.png" alt="Test Image" width="100">';
39
39
  const output = convertHtmlToJsx(input);
40
- expect(output).toBe('<><img src="test.png" alt="Test Image" width="100"/></>');
40
+ expect(output).toBe('<><img src="test.png" alt="Test Image" width="100" /></>');
41
41
  });
42
42
  it('should preserve attributes on regular elements', () => {
43
43
  const input = '<div class="container" id="main">Content</div>';
@@ -59,7 +59,7 @@ describe('convertHtmlToJsx', () => {
59
59
  it('should handle void elements within nested structures', () => {
60
60
  const input = '<div><p>Line 1<br>Line 2</p><hr><p>Line 3</p></div>';
61
61
  const output = convertHtmlToJsx(input);
62
- expect(output).toBe('<><div><p>Line 1<br/>Line 2</p><hr/><p>Line 3</p></div></>');
62
+ expect(output).toBe('<><div><p>Line 1<br />Line 2</p><hr /><p>Line 3</p></div></>');
63
63
  });
64
64
  });
65
65
  describe('text content', () => {
@@ -100,8 +100,8 @@ describe('convertHtmlToJsx', () => {
100
100
  it('should handle empty elements', () => {
101
101
  const input = '<strong></strong>';
102
102
  const output = convertHtmlToJsx(input);
103
- // Empty elements are converted to self-closing tags in XHTML
104
- expect(output).toBe('<><strong/></>');
103
+ // Empty non-void elements remain as open/close tags (not self-closing)
104
+ expect(output).toBe('<><strong></strong></>');
105
105
  });
106
106
  it('should handle plain text without tags', () => {
107
107
  const input = 'Just plain text';
@@ -1,7 +1,7 @@
1
1
  import { isObjectNode, isTypeReferenceNode, } from '@hubspot/ts-export-types-reader';
2
2
  import { componentPropsReader } from "./__generated__/component-props.js";
3
3
  import { renderPropTypeToJsx, } from "./internal/render-prop-type.js";
4
- import { getDefaultValueFromJsdocTags, getSeeTagsFromJsdocTags, } from "./internal/utils/jsdoc-utils.js";
4
+ import { getDefaultValueFromJsdocTags, getSeeTagsFromJsdocTags, hasDeprecatedJsdocTag, } from "./internal/utils/jsdoc-utils.js";
5
5
  import { renderMarkdownToJsx } from "./internal/utils/markdown-utils.js";
6
6
  import { getComponentTypeSource } from "./internal/get-type-source.js";
7
7
  /**
@@ -73,8 +73,10 @@ export const getComponentPropsDocumentation = (componentName) => {
73
73
  if (!propsObject) {
74
74
  throw new Error(`Props object not found for component "${componentName}" (${exportName} in ${exportPath})`);
75
75
  }
76
- // Sort properties first by required status, then alphabetically by name for consistent output
77
- const props = [...propsObject.properties].sort((a, b) => {
76
+ // Filter out deprecated properties, then sort by required status and alphabetically by name for consistent output
77
+ const props = [...propsObject.properties]
78
+ .filter((prop) => !hasDeprecatedJsdocTag(prop.jsdoc?.tags))
79
+ .sort((a, b) => {
78
80
  const aRequired = a.isOptional !== true;
79
81
  const bRequired = b.isOptional !== true;
80
82
  if (aRequired !== bRequired) {
@@ -27,3 +27,14 @@ export declare const getDefaultValueFromJsdocTags: (tags: JsdocTag[] | undefined
27
27
  * @returns An array of see tag text values, or an empty array if none found
28
28
  */
29
29
  export declare const getSeeTagsFromJsdocTags: (tags: JsdocTag[] | undefined) => string[];
30
+ /**
31
+ * Checks if a property is deprecated based on JSDoc tags.
32
+ *
33
+ * Searches through an array of JSDoc tags to determine if a 'deprecated'
34
+ * tag exists. Properties marked as deprecated should be filtered out from
35
+ * documentation.
36
+ *
37
+ * @param tags - An array of JSDoc tags, or undefined if no tags exist
38
+ * @returns True if a deprecated tag is found, false otherwise
39
+ */
40
+ export declare const hasDeprecatedJsdocTag: (tags: JsdocTag[] | undefined) => boolean;
@@ -50,3 +50,21 @@ export const getSeeTagsFromJsdocTags = (tags) => {
50
50
  .filter((tag) => tag.name === 'see' && tag.text)
51
51
  .map((tag) => tag.text);
52
52
  };
53
+ /**
54
+ * Checks if a property is deprecated based on JSDoc tags.
55
+ *
56
+ * Searches through an array of JSDoc tags to determine if a 'deprecated'
57
+ * tag exists. Properties marked as deprecated should be filtered out from
58
+ * documentation.
59
+ *
60
+ * @param tags - An array of JSDoc tags, or undefined if no tags exist
61
+ * @returns True if a deprecated tag is found, false otherwise
62
+ */
63
+ export const hasDeprecatedJsdocTag = (tags) => {
64
+ // Return false if there are no tags
65
+ if (!tags) {
66
+ return false;
67
+ }
68
+ // Check if any tag is named 'deprecated'
69
+ return tags.some((tag) => tag.name === 'deprecated');
70
+ };
@@ -70,8 +70,18 @@ export const convertHtmlToJsx = (html) => {
70
70
  stripOutermostParagraphNode(dom);
71
71
  // Serialize back to string with XML rules (self-closing tags, etc.)
72
72
  const xhtml = serialize(dom, {
73
- xmlMode: true, // Use XML/XHTML serialization rules
74
- selfClosingTags: true, // Ensure void elements are self-closing
73
+ // xmlMode defaults to true which is more aggressive and unnecessary encoding of element text so we turn it off.
74
+ // We still output XHTML (well-formed XML) by enabling emptyAttrs and selfClosingTags.
75
+ xmlMode: false,
76
+ // Print empty attribute values as attr="" (e.g., <input checked=""/>)
77
+ emptyAttrs: true,
78
+ // Self-close HTML void elements (br, img, etc.) as <br /> for JSX compatibility.
79
+ // Note: Non-void empty elements render as <span></span> (not <span/>), but this is fine for JSX.
80
+ selfClosingTags: true,
81
+ // encodeEntities controls how element text is encoded. We use utf8 to ensure all
82
+ // special characters are encoded in addition to the characters that are already encoded by default (&, <, >)
83
+ // but results in quotes not being encoded for better readability.
84
+ encodeEntities: 'utf8',
75
85
  });
76
86
  return `<>${escapeJsxExpressions(xhtml)}</>`;
77
87
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hubspot/ui-extensions-sdk-api-metadata",
3
- "version": "0.12.1",
3
+ "version": "0.12.2",
4
4
  "description": "UI Extensions SDK API Metadata",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -32,11 +32,12 @@
32
32
  },
33
33
  "devDependencies": {
34
34
  "@hubspot/ts-export-types": "1.1.0",
35
- "@vitest/coverage-v8": "2.1.8",
35
+ "@vitest/coverage-v8": "4.0.18",
36
36
  "typescript": "5.9.3",
37
- "vitest": "2.1.9"
37
+ "vitest": "4.0.18"
38
38
  },
39
39
  "engines": {
40
40
  "node": ">=16"
41
- }
41
+ },
42
+ "gitHead": "b8c8170048a28b28112833cb552be43d4587c2ed"
42
43
  }