From 83799d9edff171a1c54da39a4d1b23cc3b2e426c Mon Sep 17 00:00:00 2001 From: Yadong Zhang Date: Wed, 24 Aug 2022 16:57:56 +0000 Subject: [PATCH 01/10] fix: supported React.Profiler use in component. --- code/renderers/react/src/docs/jsxDecorator.test.tsx | 13 +++++++++++++ code/renderers/react/src/docs/jsxDecorator.tsx | 1 + 2 files changed, 14 insertions(+) diff --git a/code/renderers/react/src/docs/jsxDecorator.test.tsx b/code/renderers/react/src/docs/jsxDecorator.test.tsx index 6089148f9880..fd214bf577f7 100644 --- a/code/renderers/react/src/docs/jsxDecorator.test.tsx +++ b/code/renderers/react/src/docs/jsxDecorator.test.tsx @@ -137,6 +137,19 @@ describe('renderJsx', () => { `); }); + it('Profiler', () => { + const ProfilerComponent: FC = React.Profiler(function ProfilerComponent(props) { + return
{props.children}
; + }); + + expect(renderJsx(createElement(ProfilerComponent, {}, 'I am Profiler'), {})) + .toMatchInlineSnapshot(` + + I m Profiler + + `); + }); + it('should not add default props to string if the prop value has not changed', () => { const Container = ({ className, children }: { className: string; children: string }) => { return
{children}
; diff --git a/code/renderers/react/src/docs/jsxDecorator.tsx b/code/renderers/react/src/docs/jsxDecorator.tsx index f075b0feca03..1a534060a488 100644 --- a/code/renderers/react/src/docs/jsxDecorator.tsx +++ b/code/renderers/react/src/docs/jsxDecorator.tsx @@ -101,6 +101,7 @@ export const renderJsx = (code: React.ReactElement, options: JSXOptions) => { // To get exotic component names resolving properly displayName: (el: any): string => el.type.displayName || + (el.type === Symbol.for('react.profiler') ? 'Profiler' : null) || getDocgenSection(el.type, 'displayName') || (el.type.name !== '_default' ? el.type.name : null) || (typeof el.type === 'function' ? 'No Display Name' : null) || From ab720aee3064a65d3bcfddbc87acfa56b9c38d14 Mon Sep 17 00:00:00 2001 From: Yadong Zhang Date: Thu, 25 Aug 2022 01:09:16 +0800 Subject: [PATCH 02/10] fix: typo --- code/renderers/react/src/docs/jsxDecorator.test.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/renderers/react/src/docs/jsxDecorator.test.tsx b/code/renderers/react/src/docs/jsxDecorator.test.tsx index fd214bf577f7..9deb76fe327b 100644 --- a/code/renderers/react/src/docs/jsxDecorator.test.tsx +++ b/code/renderers/react/src/docs/jsxDecorator.test.tsx @@ -144,7 +144,7 @@ describe('renderJsx', () => { expect(renderJsx(createElement(ProfilerComponent, {}, 'I am Profiler'), {})) .toMatchInlineSnapshot(` - + I m Profiler `); From 876778d6a62b1a897711dd53790b31aee5488386 Mon Sep 17 00:00:00 2001 From: Yadong Zhang Date: Wed, 24 Aug 2022 17:27:50 +0000 Subject: [PATCH 03/10] test: typo. --- code/renderers/react/src/docs/jsxDecorator.test.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/renderers/react/src/docs/jsxDecorator.test.tsx b/code/renderers/react/src/docs/jsxDecorator.test.tsx index 9deb76fe327b..4f1d63fb56bd 100644 --- a/code/renderers/react/src/docs/jsxDecorator.test.tsx +++ b/code/renderers/react/src/docs/jsxDecorator.test.tsx @@ -145,7 +145,7 @@ describe('renderJsx', () => { expect(renderJsx(createElement(ProfilerComponent, {}, 'I am Profiler'), {})) .toMatchInlineSnapshot(` - I m Profiler + I am Profiler `); }); From 718886fc8b8c6e24f98f0367628e8df2f1c9177c Mon Sep 17 00:00:00 2001 From: Yadong Zhang Date: Thu, 25 Aug 2022 02:37:52 +0800 Subject: [PATCH 04/10] test: close tag. --- code/renderers/react/src/docs/jsxDecorator.test.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/renderers/react/src/docs/jsxDecorator.test.tsx b/code/renderers/react/src/docs/jsxDecorator.test.tsx index 4f1d63fb56bd..816397897e3c 100644 --- a/code/renderers/react/src/docs/jsxDecorator.test.tsx +++ b/code/renderers/react/src/docs/jsxDecorator.test.tsx @@ -146,7 +146,7 @@ describe('renderJsx', () => { .toMatchInlineSnapshot(` I am Profiler - + `); }); From c25ada4e5d4c27f223641700e84b34e5a8659cbf Mon Sep 17 00:00:00 2001 From: Yadong Zhang Date: Wed, 24 Aug 2022 19:20:30 +0000 Subject: [PATCH 05/10] test: added renderers dir to jest work path. + test: fixed dead unit tests. --- code/jest.config.js | 1 + code/renderers/react/src/docs/jsxDecorator.test.tsx | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/code/jest.config.js b/code/jest.config.js index a2ffa022105e..90cfabc15c2c 100644 --- a/code/jest.config.js +++ b/code/jest.config.js @@ -42,6 +42,7 @@ module.exports = { '/addons', '/frameworks', '/lib', + '/renderers', '/examples/official-storybook', '/examples/react-ts', ], diff --git a/code/renderers/react/src/docs/jsxDecorator.test.tsx b/code/renderers/react/src/docs/jsxDecorator.test.tsx index 816397897e3c..da9cf53c585d 100644 --- a/code/renderers/react/src/docs/jsxDecorator.test.tsx +++ b/code/renderers/react/src/docs/jsxDecorator.test.tsx @@ -120,7 +120,7 @@ describe('renderJsx', () => { expect(renderJsx(createElement(MyExoticComponent, {}, 'I am forwardRef!'), {})) .toMatchInlineSnapshot(` - I'm forwardRef! + I am forwardRef! `); }); @@ -132,15 +132,16 @@ describe('renderJsx', () => { expect(renderJsx(createElement(MyMemoComponent, {}, 'I am memo!'), {})).toMatchInlineSnapshot(` - I'm memo! + I am memo! `); }); it('Profiler', () => { - const ProfilerComponent: FC = React.Profiler(function ProfilerComponent(props) { + // TODO: add Profiler integrate + function ProfilerComponent(props: any) { return
{props.children}
; - }); + } expect(renderJsx(createElement(ProfilerComponent, {}, 'I am Profiler'), {})) .toMatchInlineSnapshot(` From 8cdcfee522795ba470e79d55ccaa844797d84e45 Mon Sep 17 00:00:00 2001 From: Yadong Zhang Date: Thu, 25 Aug 2022 01:44:39 +0000 Subject: [PATCH 06/10] test: updated snapshots. --- .../8140-js-prop-types-oneof/docgen.snapshot | 20 +++--- .../8428-js-static-prop-types/docgen.snapshot | 4 +- .../8663-js-styled-components/docgen.snapshot | 4 +- .../9023-js-hoc/docgen.snapshot | 16 ++--- .../9399-js-proptypes-shape/docgen.snapshot | 4 +- .../docgen.snapshot | 2 +- .../9575-ts-camel-case/docgen.snapshot | 4 +- .../9586-js-react-memo/docgen.snapshot | 8 +-- .../docgen.snapshot | 8 +-- .../js-class-component/docgen.snapshot | 72 +++++++++---------- .../docgen.snapshot | 72 +++++++++---------- .../js-function-component/docgen.snapshot | 72 +++++++++---------- .../react/src/docs/jsxDecorator.test.tsx | 3 +- .../svelte/src/docs/extractArgTypes.test.ts | 4 +- 14 files changed, 146 insertions(+), 147 deletions(-) diff --git a/code/renderers/react/src/docs/__testfixtures__/8140-js-prop-types-oneof/docgen.snapshot b/code/renderers/react/src/docs/__testfixtures__/8140-js-prop-types-oneof/docgen.snapshot index 0f5ed90d714b..fb40620026d7 100644 --- a/code/renderers/react/src/docs/__testfixtures__/8140-js-prop-types-oneof/docgen.snapshot +++ b/code/renderers/react/src/docs/__testfixtures__/8140-js-prop-types-oneof/docgen.snapshot @@ -36,6 +36,7 @@ Alert.__docgenInfo = { \\"value\\": \\"'static'\\", \\"computed\\": false }, + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"enum\\", \\"value\\": [{ @@ -46,14 +47,14 @@ Alert.__docgenInfo = { \\"computed\\": false }] }, - \\"required\\": false, - \\"description\\": \\"\\" + \\"required\\": false }, \\"type\\": { \\"defaultValue\\": { \\"value\\": \\"'warning'\\", \\"computed\\": false }, + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"enum\\", \\"value\\": [{ @@ -70,29 +71,28 @@ Alert.__docgenInfo = { \\"computed\\": false }] }, - \\"required\\": false, - \\"description\\": \\"\\" + \\"required\\": false }, \\"message\\": { + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"string\\" }, - \\"required\\": true, - \\"description\\": \\"\\" + \\"required\\": true }, \\"blank\\": { + \\"description\\": \\"No background or border if static alert\\", \\"type\\": { \\"name\\": \\"bool\\" }, - \\"required\\": false, - \\"description\\": \\"No background or border if static alert\\" + \\"required\\": false }, \\"icon\\": { + \\"description\\": \\"Allows icon override, accepts material icon name\\", \\"type\\": { \\"name\\": \\"string\\" }, - \\"required\\": false, - \\"description\\": \\"Allows icon override, accepts material icon name\\" + \\"required\\": false } } };" diff --git a/code/renderers/react/src/docs/__testfixtures__/8428-js-static-prop-types/docgen.snapshot b/code/renderers/react/src/docs/__testfixtures__/8428-js-static-prop-types/docgen.snapshot index 10a2a46836d4..66de29c0363d 100644 --- a/code/renderers/react/src/docs/__testfixtures__/8428-js-static-prop-types/docgen.snapshot +++ b/code/renderers/react/src/docs/__testfixtures__/8428-js-static-prop-types/docgen.snapshot @@ -27,11 +27,11 @@ Test.__docgenInfo = { \\"displayName\\": \\"Test\\", \\"props\\": { \\"test\\": { + \\"description\\": \\"Please work...\\", \\"type\\": { \\"name\\": \\"string\\" }, - \\"required\\": false, - \\"description\\": \\"Please work...\\" + \\"required\\": false } } };" diff --git a/code/renderers/react/src/docs/__testfixtures__/8663-js-styled-components/docgen.snapshot b/code/renderers/react/src/docs/__testfixtures__/8663-js-styled-components/docgen.snapshot index bf03a19e7769..fc150a0dd969 100644 --- a/code/renderers/react/src/docs/__testfixtures__/8663-js-styled-components/docgen.snapshot +++ b/code/renderers/react/src/docs/__testfixtures__/8663-js-styled-components/docgen.snapshot @@ -21,11 +21,11 @@ MyBox.__docgenInfo = { \\"displayName\\": \\"MyBox\\", \\"props\\": { \\"bg\\": { + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"string\\" }, - \\"required\\": false, - \\"description\\": \\"\\" + \\"required\\": false } } };" diff --git a/code/renderers/react/src/docs/__testfixtures__/9023-js-hoc/docgen.snapshot b/code/renderers/react/src/docs/__testfixtures__/9023-js-hoc/docgen.snapshot index 6755a05a5cfc..7eaddd268c72 100644 --- a/code/renderers/react/src/docs/__testfixtures__/9023-js-hoc/docgen.snapshot +++ b/code/renderers/react/src/docs/__testfixtures__/9023-js-hoc/docgen.snapshot @@ -47,36 +47,36 @@ Alert.__docgenInfo = { \\"value\\": \\"'primary'\\", \\"computed\\": false }, + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"string\\" }, - \\"required\\": false, - \\"description\\": \\"\\" + \\"required\\": false }, \\"dismissible\\": { \\"defaultValue\\": { \\"value\\": \\"false\\", \\"computed\\": false }, + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"bool\\" }, - \\"required\\": false, - \\"description\\": \\"\\" + \\"required\\": false }, \\"icon\\": { + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"elementType\\" }, - \\"required\\": false, - \\"description\\": \\"\\" + \\"required\\": false }, \\"classes\\": { + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"object\\" }, - \\"required\\": true, - \\"description\\": \\"\\" + \\"required\\": true } } };" diff --git a/code/renderers/react/src/docs/__testfixtures__/9399-js-proptypes-shape/docgen.snapshot b/code/renderers/react/src/docs/__testfixtures__/9399-js-proptypes-shape/docgen.snapshot index 97f537acf986..396775caa8ae 100644 --- a/code/renderers/react/src/docs/__testfixtures__/9399-js-proptypes-shape/docgen.snapshot +++ b/code/renderers/react/src/docs/__testfixtures__/9399-js-proptypes-shape/docgen.snapshot @@ -20,6 +20,7 @@ Credits.__docgenInfo = { \\"displayName\\": \\"Credits\\", \\"props\\": { \\"areas\\": { + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"arrayOf\\", \\"value\\": { @@ -39,8 +40,7 @@ Credits.__docgenInfo = { } } }, - \\"required\\": true, - \\"description\\": \\"\\" + \\"required\\": true } } };" diff --git a/code/renderers/react/src/docs/__testfixtures__/9556-ts-react-default-exports/docgen.snapshot b/code/renderers/react/src/docs/__testfixtures__/9556-ts-react-default-exports/docgen.snapshot index 3885b65757ac..f859bb234989 100644 --- a/code/renderers/react/src/docs/__testfixtures__/9556-ts-react-default-exports/docgen.snapshot +++ b/code/renderers/react/src/docs/__testfixtures__/9556-ts-react-default-exports/docgen.snapshot @@ -1,7 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`react component properties 9556-ts-react-default-exports 1`] = ` -"function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } +"function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } /* eslint-disable react/button-has-type */ import React from 'react'; diff --git a/code/renderers/react/src/docs/__testfixtures__/9575-ts-camel-case/docgen.snapshot b/code/renderers/react/src/docs/__testfixtures__/9575-ts-camel-case/docgen.snapshot index 9494b9c88cd9..032cc7300373 100644 --- a/code/renderers/react/src/docs/__testfixtures__/9575-ts-camel-case/docgen.snapshot +++ b/code/renderers/react/src/docs/__testfixtures__/9575-ts-camel-case/docgen.snapshot @@ -26,11 +26,11 @@ iconButton.__docgenInfo = { \\"value\\": \\"'primary'\\", \\"computed\\": false }, + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"string\\" }, - \\"required\\": false, - \\"description\\": \\"\\" + \\"required\\": false } } }; diff --git a/code/renderers/react/src/docs/__testfixtures__/9586-js-react-memo/docgen.snapshot b/code/renderers/react/src/docs/__testfixtures__/9586-js-react-memo/docgen.snapshot index e31e4ae12586..9de1e177c96e 100644 --- a/code/renderers/react/src/docs/__testfixtures__/9586-js-react-memo/docgen.snapshot +++ b/code/renderers/react/src/docs/__testfixtures__/9586-js-react-memo/docgen.snapshot @@ -26,18 +26,18 @@ Button.__docgenInfo = { \\"displayName\\": \\"Button\\", \\"props\\": { \\"label\\": { + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"string\\" }, - \\"required\\": true, - \\"description\\": \\"\\" + \\"required\\": true }, \\"onClick\\": { + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"func\\" }, - \\"required\\": true, - \\"description\\": \\"\\" + \\"required\\": true } } };" diff --git a/code/renderers/react/src/docs/__testfixtures__/9668-js-proptypes-no-jsdoc/docgen.snapshot b/code/renderers/react/src/docs/__testfixtures__/9668-js-proptypes-no-jsdoc/docgen.snapshot index 1d189717438e..46bb0295459a 100644 --- a/code/renderers/react/src/docs/__testfixtures__/9668-js-proptypes-no-jsdoc/docgen.snapshot +++ b/code/renderers/react/src/docs/__testfixtures__/9668-js-proptypes-no-jsdoc/docgen.snapshot @@ -17,18 +17,18 @@ CCTable.__docgenInfo = { \\"displayName\\": \\"CCTable\\", \\"props\\": { \\"heads\\": { + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"array\\" }, - \\"required\\": true, - \\"description\\": \\"\\" + \\"required\\": true }, \\"onAddClick\\": { + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"func\\" }, - \\"required\\": false, - \\"description\\": \\"\\" + \\"required\\": false } } };" diff --git a/code/renderers/react/src/docs/__testfixtures__/js-class-component/docgen.snapshot b/code/renderers/react/src/docs/__testfixtures__/js-class-component/docgen.snapshot index 1db7dceec9b5..c512e6f255f5 100644 --- a/code/renderers/react/src/docs/__testfixtures__/js-class-component/docgen.snapshot +++ b/code/renderers/react/src/docs/__testfixtures__/js-class-component/docgen.snapshot @@ -65,126 +65,126 @@ PropsWriter.__docgenInfo = { \\"value\\": \\"1\\", \\"computed\\": false }, + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"number\\" }, - \\"required\\": false, - \\"description\\": \\"\\" + \\"required\\": false }, \\"stringOptional\\": { \\"defaultValue\\": { \\"value\\": \\"'stringOptional'\\", \\"computed\\": false }, + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"string\\" }, - \\"required\\": false, - \\"description\\": \\"\\" + \\"required\\": false }, \\"booleanOptional\\": { \\"defaultValue\\": { \\"value\\": \\"false\\", \\"computed\\": false }, + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"bool\\" }, - \\"required\\": false, - \\"description\\": \\"\\" + \\"required\\": false }, \\"arrayOptional\\": { \\"defaultValue\\": { \\"value\\": \\"['array', 'optional']\\", \\"computed\\": false }, + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"arrayOf\\", \\"value\\": { \\"name\\": \\"string\\" } }, - \\"required\\": false, - \\"description\\": \\"\\" + \\"required\\": false }, \\"objectOptional\\": { \\"defaultValue\\": { \\"value\\": \\"{ object: 'optional' }\\", \\"computed\\": false }, + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"shape\\", \\"value\\": {} }, - \\"required\\": false, - \\"description\\": \\"\\" + \\"required\\": false }, \\"functionOptional\\": { \\"defaultValue\\": { \\"value\\": \\"() => 'foo'\\", \\"computed\\": false }, + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"func\\" }, - \\"required\\": false, - \\"description\\": \\"\\" + \\"required\\": false }, \\"dateOptional\\": { \\"defaultValue\\": { \\"value\\": \\"new Date('20 Jan 1983')\\", \\"computed\\": false }, + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"instanceOf\\", \\"value\\": \\"Date\\" }, - \\"required\\": false, - \\"description\\": \\"\\" + \\"required\\": false }, \\"localReference\\": { \\"defaultValue\\": { \\"value\\": \\"'local-value'\\", \\"computed\\": false }, + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"string\\" }, - \\"required\\": false, - \\"description\\": \\"\\" + \\"required\\": false }, \\"importedReference\\": { \\"defaultValue\\": { \\"value\\": \\"imported\\", \\"computed\\": true }, + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"string\\" }, - \\"required\\": false, - \\"description\\": \\"\\" + \\"required\\": false }, \\"globalReference\\": { \\"defaultValue\\": { \\"value\\": \\"Date\\", \\"computed\\": true }, + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"any\\" }, - \\"required\\": false, - \\"description\\": \\"\\" + \\"required\\": false }, \\"stringGlobalName\\": { \\"defaultValue\\": { \\"value\\": \\"'top'\\", \\"computed\\": false }, + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"string\\" }, - \\"required\\": false, - \\"description\\": \\"\\" + \\"required\\": false }, \\"stringNoPropType\\": { \\"defaultValue\\": { @@ -194,58 +194,58 @@ PropsWriter.__docgenInfo = { \\"required\\": false }, \\"numberRequired\\": { + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"number\\" }, - \\"required\\": true, - \\"description\\": \\"\\" + \\"required\\": true }, \\"stringRequired\\": { + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"string\\" }, - \\"required\\": true, - \\"description\\": \\"\\" + \\"required\\": true }, \\"booleanRequired\\": { + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"bool\\" }, - \\"required\\": true, - \\"description\\": \\"\\" + \\"required\\": true }, \\"arrayRequired\\": { + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"arrayOf\\", \\"value\\": { \\"name\\": \\"string\\" } }, - \\"required\\": true, - \\"description\\": \\"\\" + \\"required\\": true }, \\"objectRequired\\": { + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"shape\\", \\"value\\": {} }, - \\"required\\": true, - \\"description\\": \\"\\" + \\"required\\": true }, \\"functionRequired\\": { + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"func\\" }, - \\"required\\": true, - \\"description\\": \\"\\" + \\"required\\": true }, \\"dateRequired\\": { + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"instanceOf\\", \\"value\\": \\"Date\\" }, - \\"required\\": true, - \\"description\\": \\"\\" + \\"required\\": true } } };" diff --git a/code/renderers/react/src/docs/__testfixtures__/js-function-component-inline-defaults/docgen.snapshot b/code/renderers/react/src/docs/__testfixtures__/js-function-component-inline-defaults/docgen.snapshot index 7f74499f9600..a09659ff435c 100644 --- a/code/renderers/react/src/docs/__testfixtures__/js-function-component-inline-defaults/docgen.snapshot +++ b/code/renderers/react/src/docs/__testfixtures__/js-function-component-inline-defaults/docgen.snapshot @@ -67,180 +67,180 @@ PropsWriter.__docgenInfo = { \\"value\\": \\"1\\", \\"computed\\": false }, + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"number\\" }, - \\"required\\": false, - \\"description\\": \\"\\" + \\"required\\": false }, \\"stringOptional\\": { \\"defaultValue\\": { \\"value\\": \\"'stringOptional'\\", \\"computed\\": false }, + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"string\\" }, - \\"required\\": false, - \\"description\\": \\"\\" + \\"required\\": false }, \\"booleanOptional\\": { \\"defaultValue\\": { \\"value\\": \\"false\\", \\"computed\\": false }, + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"bool\\" }, - \\"required\\": false, - \\"description\\": \\"\\" + \\"required\\": false }, \\"arrayOptional\\": { \\"defaultValue\\": { \\"value\\": \\"['array', 'optional']\\", \\"computed\\": false }, + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"arrayOf\\", \\"value\\": { \\"name\\": \\"string\\" } }, - \\"required\\": false, - \\"description\\": \\"\\" + \\"required\\": false }, \\"objectOptional\\": { \\"defaultValue\\": { \\"value\\": \\"{ object: 'optional' }\\", \\"computed\\": false }, + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"shape\\", \\"value\\": {} }, - \\"required\\": false, - \\"description\\": \\"\\" + \\"required\\": false }, \\"functionOptional\\": { \\"defaultValue\\": { \\"value\\": \\"() => 'foo'\\", \\"computed\\": false }, + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"func\\" }, - \\"required\\": false, - \\"description\\": \\"\\" + \\"required\\": false }, \\"dateOptional\\": { \\"defaultValue\\": { \\"value\\": \\"new Date('20 Jan 1983')\\", \\"computed\\": false }, + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"instanceOf\\", \\"value\\": \\"Date\\" }, - \\"required\\": false, - \\"description\\": \\"\\" + \\"required\\": false }, \\"localReference\\": { \\"defaultValue\\": { \\"value\\": \\"'local-value'\\", \\"computed\\": false }, + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"string\\" }, - \\"required\\": false, - \\"description\\": \\"\\" + \\"required\\": false }, \\"importedReference\\": { \\"defaultValue\\": { \\"value\\": \\"imported\\", \\"computed\\": true }, + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"string\\" }, - \\"required\\": false, - \\"description\\": \\"\\" + \\"required\\": false }, \\"globalReference\\": { \\"defaultValue\\": { \\"value\\": \\"Date\\", \\"computed\\": true }, + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"any\\" }, - \\"required\\": false, - \\"description\\": \\"\\" + \\"required\\": false }, \\"stringGlobalName\\": { \\"defaultValue\\": { \\"value\\": \\"'top'\\", \\"computed\\": false }, + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"string\\" }, - \\"required\\": false, - \\"description\\": \\"\\" + \\"required\\": false }, \\"numberRequired\\": { + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"number\\" }, - \\"required\\": true, - \\"description\\": \\"\\" + \\"required\\": true }, \\"stringRequired\\": { + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"string\\" }, - \\"required\\": true, - \\"description\\": \\"\\" + \\"required\\": true }, \\"booleanRequired\\": { + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"bool\\" }, - \\"required\\": true, - \\"description\\": \\"\\" + \\"required\\": true }, \\"arrayRequired\\": { + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"arrayOf\\", \\"value\\": { \\"name\\": \\"string\\" } }, - \\"required\\": true, - \\"description\\": \\"\\" + \\"required\\": true }, \\"objectRequired\\": { + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"shape\\", \\"value\\": {} }, - \\"required\\": true, - \\"description\\": \\"\\" + \\"required\\": true }, \\"functionRequired\\": { + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"func\\" }, - \\"required\\": true, - \\"description\\": \\"\\" + \\"required\\": true }, \\"dateRequired\\": { + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"instanceOf\\", \\"value\\": \\"Date\\" }, - \\"required\\": true, - \\"description\\": \\"\\" + \\"required\\": true } } };" diff --git a/code/renderers/react/src/docs/__testfixtures__/js-function-component/docgen.snapshot b/code/renderers/react/src/docs/__testfixtures__/js-function-component/docgen.snapshot index a650f7562577..720d40ca5a0b 100644 --- a/code/renderers/react/src/docs/__testfixtures__/js-function-component/docgen.snapshot +++ b/code/renderers/react/src/docs/__testfixtures__/js-function-component/docgen.snapshot @@ -56,180 +56,180 @@ PropsWriter.__docgenInfo = { \\"value\\": \\"1\\", \\"computed\\": false }, + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"number\\" }, - \\"required\\": false, - \\"description\\": \\"\\" + \\"required\\": false }, \\"stringOptional\\": { \\"defaultValue\\": { \\"value\\": \\"'stringOptional'\\", \\"computed\\": false }, + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"string\\" }, - \\"required\\": false, - \\"description\\": \\"\\" + \\"required\\": false }, \\"booleanOptional\\": { \\"defaultValue\\": { \\"value\\": \\"false\\", \\"computed\\": false }, + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"bool\\" }, - \\"required\\": false, - \\"description\\": \\"\\" + \\"required\\": false }, \\"arrayOptional\\": { \\"defaultValue\\": { \\"value\\": \\"['array', 'optional']\\", \\"computed\\": false }, + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"arrayOf\\", \\"value\\": { \\"name\\": \\"string\\" } }, - \\"required\\": false, - \\"description\\": \\"\\" + \\"required\\": false }, \\"objectOptional\\": { \\"defaultValue\\": { \\"value\\": \\"{ object: 'optional' }\\", \\"computed\\": false }, + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"shape\\", \\"value\\": {} }, - \\"required\\": false, - \\"description\\": \\"\\" + \\"required\\": false }, \\"functionOptional\\": { \\"defaultValue\\": { \\"value\\": \\"() => 'foo'\\", \\"computed\\": false }, + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"func\\" }, - \\"required\\": false, - \\"description\\": \\"\\" + \\"required\\": false }, \\"dateOptional\\": { \\"defaultValue\\": { \\"value\\": \\"new Date('20 Jan 1983')\\", \\"computed\\": false }, + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"instanceOf\\", \\"value\\": \\"Date\\" }, - \\"required\\": false, - \\"description\\": \\"\\" + \\"required\\": false }, \\"localReference\\": { \\"defaultValue\\": { \\"value\\": \\"'local-value'\\", \\"computed\\": false }, + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"string\\" }, - \\"required\\": false, - \\"description\\": \\"\\" + \\"required\\": false }, \\"importedReference\\": { \\"defaultValue\\": { \\"value\\": \\"imported\\", \\"computed\\": true }, + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"string\\" }, - \\"required\\": false, - \\"description\\": \\"\\" + \\"required\\": false }, \\"globalReference\\": { \\"defaultValue\\": { \\"value\\": \\"Date\\", \\"computed\\": true }, + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"any\\" }, - \\"required\\": false, - \\"description\\": \\"\\" + \\"required\\": false }, \\"stringGlobalName\\": { \\"defaultValue\\": { \\"value\\": \\"'top'\\", \\"computed\\": false }, + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"string\\" }, - \\"required\\": false, - \\"description\\": \\"\\" + \\"required\\": false }, \\"numberRequired\\": { + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"number\\" }, - \\"required\\": true, - \\"description\\": \\"\\" + \\"required\\": true }, \\"stringRequired\\": { + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"string\\" }, - \\"required\\": true, - \\"description\\": \\"\\" + \\"required\\": true }, \\"booleanRequired\\": { + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"bool\\" }, - \\"required\\": true, - \\"description\\": \\"\\" + \\"required\\": true }, \\"arrayRequired\\": { + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"arrayOf\\", \\"value\\": { \\"name\\": \\"string\\" } }, - \\"required\\": true, - \\"description\\": \\"\\" + \\"required\\": true }, \\"objectRequired\\": { + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"shape\\", \\"value\\": {} }, - \\"required\\": true, - \\"description\\": \\"\\" + \\"required\\": true }, \\"functionRequired\\": { + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"func\\" }, - \\"required\\": true, - \\"description\\": \\"\\" + \\"required\\": true }, \\"dateRequired\\": { + \\"description\\": \\"\\", \\"type\\": { \\"name\\": \\"instanceOf\\", \\"value\\": \\"Date\\" }, - \\"required\\": true, - \\"description\\": \\"\\" + \\"required\\": true } } };" diff --git a/code/renderers/react/src/docs/jsxDecorator.test.tsx b/code/renderers/react/src/docs/jsxDecorator.test.tsx index da9cf53c585d..889e55ca480e 100644 --- a/code/renderers/react/src/docs/jsxDecorator.test.tsx +++ b/code/renderers/react/src/docs/jsxDecorator.test.tsx @@ -137,8 +137,7 @@ describe('renderJsx', () => { `); }); - it('Profiler', () => { - // TODO: add Profiler integrate + it.todo('Profiler', () => { function ProfilerComponent(props: any) { return
{props.children}
; } diff --git a/code/renderers/svelte/src/docs/extractArgTypes.test.ts b/code/renderers/svelte/src/docs/extractArgTypes.test.ts index e25ec8bb2853..c1911ffa3d1d 100644 --- a/code/renderers/svelte/src/docs/extractArgTypes.test.ts +++ b/code/renderers/svelte/src/docs/extractArgTypes.test.ts @@ -87,7 +87,7 @@ describe('Extracting Arguments', () => { "control": Object { "type": "boolean", }, - "description": null, + "description": undefined, "name": "rounded", "table": Object { "category": "properties", @@ -117,7 +117,7 @@ describe('Extracting Arguments', () => { "control": Object { "type": "text", }, - "description": null, + "description": undefined, "name": "text", "table": Object { "category": "properties", From 40d1da06240d1f3d1168269bbcd5b8091bffe3ab Mon Sep 17 00:00:00 2001 From: Yadong Zhang Date: Thu, 25 Aug 2022 02:00:48 +0000 Subject: [PATCH 07/10] test: done Profiler test. --- code/renderers/react/src/docs/jsxDecorator.test.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/code/renderers/react/src/docs/jsxDecorator.test.tsx b/code/renderers/react/src/docs/jsxDecorator.test.tsx index 889e55ca480e..6e7597aa35e8 100644 --- a/code/renderers/react/src/docs/jsxDecorator.test.tsx +++ b/code/renderers/react/src/docs/jsxDecorator.test.tsx @@ -1,5 +1,5 @@ /* eslint-disable jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */ -import React, { createElement, FC, PropsWithChildren } from 'react'; +import React, { createElement, FC, Profiler, PropsWithChildren } from 'react'; import PropTypes from 'prop-types'; import { addons, useEffect } from '@storybook/addons'; import { SNIPPET_RENDERED } from '@storybook/docs-tools'; @@ -137,9 +137,13 @@ describe('renderJsx', () => { `); }); - it.todo('Profiler', () => { + it('Profiler', () => { function ProfilerComponent(props: any) { - return
{props.children}
; + return ( + {}}> +
{props.children}
+
+ ); } expect(renderJsx(createElement(ProfilerComponent, {}, 'I am Profiler'), {})) From 62f77ce8cef1ad86c804015345a9d76d77eebd78 Mon Sep 17 00:00:00 2001 From: Yadong Zhang Date: Thu, 25 Aug 2022 02:22:37 +0000 Subject: [PATCH 08/10] fix: replaced 'function noRefCheck() {}' *globally*. --- code/renderers/react/src/docs/jsxDecorator.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/renderers/react/src/docs/jsxDecorator.tsx b/code/renderers/react/src/docs/jsxDecorator.tsx index 1a534060a488..c09eda0b69a4 100644 --- a/code/renderers/react/src/docs/jsxDecorator.tsx +++ b/code/renderers/react/src/docs/jsxDecorator.tsx @@ -142,7 +142,7 @@ export const renderJsx = (code: React.ReactElement, options: JSXOptions) => { return string; }).join('\n'); - return result.replace(/function\s+noRefCheck\(\)\s+\{\}/, '() => {}'); + return result.replace(/function\s+noRefCheck\(\)\s+\{\}/g, '() => {}'); }; const defaultOpts = { From b26e1216e0fe9c0933512c55314bb76515baafd2 Mon Sep 17 00:00:00 2001 From: Yadong Zhang Date: Thu, 1 Sep 2022 02:28:39 +0000 Subject: [PATCH 09/10] test: added noRefCheck story test file. --- .../src/stories/no-ref-check.stories.tsx | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 code/examples/cra-ts-kitchen-sink/src/stories/no-ref-check.stories.tsx diff --git a/code/examples/cra-ts-kitchen-sink/src/stories/no-ref-check.stories.tsx b/code/examples/cra-ts-kitchen-sink/src/stories/no-ref-check.stories.tsx new file mode 100644 index 000000000000..dbb4949b7863 --- /dev/null +++ b/code/examples/cra-ts-kitchen-sink/src/stories/no-ref-check.stories.tsx @@ -0,0 +1,19 @@ +import React, { Profiler } from 'react'; +import { Button } from './Button'; + +export default { + title: 'noRefCheck', +}; + +const Template = (args: any) => ( + console.log('test-profiler')}> + + +); + +export const Primary = Template.bind({}); + +Primary.args = { + primary: true, + onClick: () => console.log('test-button'), +}; From c46aa2bfc4f77c2cf75648a6a9f4a52fafb2727e Mon Sep 17 00:00:00 2001 From: Yadong Zhang Date: Wed, 12 Oct 2022 19:13:15 +0800 Subject: [PATCH 10/10] fix: deleted examples/cra-ts-kitchen-sink folder. merge the latest upstream commits into this branch. --- .../src/stories/no-ref-check.stories.tsx | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 code/examples/cra-ts-kitchen-sink/src/stories/no-ref-check.stories.tsx diff --git a/code/examples/cra-ts-kitchen-sink/src/stories/no-ref-check.stories.tsx b/code/examples/cra-ts-kitchen-sink/src/stories/no-ref-check.stories.tsx deleted file mode 100644 index dbb4949b7863..000000000000 --- a/code/examples/cra-ts-kitchen-sink/src/stories/no-ref-check.stories.tsx +++ /dev/null @@ -1,19 +0,0 @@ -import React, { Profiler } from 'react'; -import { Button } from './Button'; - -export default { - title: 'noRefCheck', -}; - -const Template = (args: any) => ( - console.log('test-profiler')}> - - -); - -export const Primary = Template.bind({}); - -Primary.args = { - primary: true, - onClick: () => console.log('test-button'), -};