@teambit/react 1.0.40 → 1.0.42
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.
- package/artifacts/env-template/public/{29.945e5ad7423216520f6d.js → 29.ddc7bc194190fac98e8b.js} +20 -20
- package/artifacts/env-template/public/{238.64be32cc6d4bc396b35e.js → 293.4bce474b96c9eb955917.js} +4 -4
- package/artifacts/env-template/public/assets-manifest.json +14 -14
- package/artifacts/env-template/public/{compositions.7e9f498935fc23eb4e05.js → compositions.3c3b3230660e1a556e41.js} +1 -1
- package/artifacts/env-template/public/compositions.html +1 -1
- package/artifacts/env-template/public/{overview.43e37513c5428b001f91.js → overview.e6a80013a110693d6dac.js} +1 -1
- package/artifacts/env-template/public/overview.html +1 -1
- package/artifacts/env-template/public/{peers.f47f3d9546b9102bd8fd.js → peers.8430739d7755eb333339.js} +1 -1
- package/artifacts/env-template/public/{preview-root.983463c786334e1fbaf1.js → preview-root.3b62d04b3a7f234bd8ca.js} +1 -1
- package/artifacts/env-template/public/static/css/{29.a9958296.css → 29.1c2448c7.css} +1 -1
- package/dist/apps/web/ssr/ssr-express.js +2 -2
- package/dist/apps/web/ssr/ssr-express.js.map +1 -1
- package/dist/apps/web/webpack/webpack.app.ssr.config.js +2 -4
- package/dist/apps/web/webpack/webpack.app.ssr.config.js.map +1 -1
- package/dist/{preview-1698930721010.js → preview-1699364645970.js} +2 -2
- package/dist/react.aspect.js +2 -4
- package/dist/react.aspect.js.map +1 -1
- package/dist/react.env.js +2 -3
- package/dist/react.env.js.map +1 -1
- package/dist/react.main.runtime.d.ts +5 -2
- package/dist/react.main.runtime.js +18 -3
- package/dist/react.main.runtime.js.map +1 -1
- package/dist/react.preview.runtime.js +3 -4
- package/dist/react.preview.runtime.js.map +1 -1
- package/dist/react.templates.d.ts +2 -1
- package/dist/react.templates.js +21 -36
- package/dist/react.templates.js.map +1 -1
- package/dist/react.ui.runtime.js +1 -2
- package/dist/react.ui.runtime.js.map +1 -1
- package/dist/webpack/postcss.config.js +1 -2
- package/dist/webpack/postcss.config.js.map +1 -1
- package/dist/webpack/webpack.config.base.js +2 -2
- package/dist/webpack/webpack.config.base.js.map +1 -1
- package/package.json +44 -42
- package/dist/templates/react-app/files/app-plugin.d.ts +0 -2
- package/dist/templates/react-app/files/app-plugin.js +0 -17
- package/dist/templates/react-app/files/app-plugin.js.map +0 -1
- package/dist/templates/react-app/files/app-root.d.ts +0 -2
- package/dist/templates/react-app/files/app-root.js +0 -24
- package/dist/templates/react-app/files/app-root.js.map +0 -1
- package/dist/templates/react-app/files/app.d.ts +0 -2
- package/dist/templates/react-app/files/app.js +0 -34
- package/dist/templates/react-app/files/app.js.map +0 -1
- package/dist/templates/react-app/files/compositions.d.ts +0 -2
- package/dist/templates/react-app/files/compositions.js +0 -24
- package/dist/templates/react-app/files/compositions.js.map +0 -1
- package/dist/templates/react-app/files/doc.d.ts +0 -2
- package/dist/templates/react-app/files/doc.js +0 -33
- package/dist/templates/react-app/files/doc.js.map +0 -1
- package/dist/templates/react-app/files/index.d.ts +0 -2
- package/dist/templates/react-app/files/index.js +0 -13
- package/dist/templates/react-app/files/index.js.map +0 -1
- package/dist/templates/react-app/index.d.ts +0 -2
- package/dist/templates/react-app/index.js +0 -84
- package/dist/templates/react-app/index.js.map +0 -1
- package/dist/templates/react-component/files/component.d.ts +0 -5
- package/dist/templates/react-component/files/component.js +0 -35
- package/dist/templates/react-component/files/component.js.map +0 -1
- package/dist/templates/react-component/files/composition.d.ts +0 -5
- package/dist/templates/react-component/files/composition.js +0 -27
- package/dist/templates/react-component/files/composition.js.map +0 -1
- package/dist/templates/react-component/files/docs.d.ts +0 -5
- package/dist/templates/react-component/files/docs.js +0 -37
- package/dist/templates/react-component/files/docs.js.map +0 -1
- package/dist/templates/react-component/files/index-file.d.ts +0 -5
- package/dist/templates/react-component/files/index-file.js +0 -21
- package/dist/templates/react-component/files/index-file.js.map +0 -1
- package/dist/templates/react-component/files/test.d.ts +0 -5
- package/dist/templates/react-component/files/test.js +0 -28
- package/dist/templates/react-component/files/test.js.map +0 -1
- package/dist/templates/react-component/index.d.ts +0 -3
- package/dist/templates/react-component/index.js +0 -68
- package/dist/templates/react-component/index.js.map +0 -1
- package/dist/templates/react-component-js/files/component.d.ts +0 -5
- package/dist/templates/react-component-js/files/component.js +0 -28
- package/dist/templates/react-component-js/files/component.js.map +0 -1
- package/dist/templates/react-component-js/files/composition.d.ts +0 -5
- package/dist/templates/react-component-js/files/composition.js +0 -25
- package/dist/templates/react-component-js/files/composition.js.map +0 -1
- package/dist/templates/react-component-js/files/docs.d.ts +0 -5
- package/dist/templates/react-component-js/files/docs.js +0 -41
- package/dist/templates/react-component-js/files/docs.js.map +0 -1
- package/dist/templates/react-component-js/files/test.d.ts +0 -5
- package/dist/templates/react-component-js/files/test.js +0 -30
- package/dist/templates/react-component-js/files/test.js.map +0 -1
- package/dist/templates/react-component-js/index.d.ts +0 -3
- package/dist/templates/react-component-js/index.js +0 -70
- package/dist/templates/react-component-js/index.js.map +0 -1
- package/dist/templates/react-context/files/composition.d.ts +0 -5
- package/dist/templates/react-context/files/composition.js +0 -36
- package/dist/templates/react-context/files/composition.js.map +0 -1
- package/dist/templates/react-context/files/context-provider.d.ts +0 -5
- package/dist/templates/react-context/files/context-provider.js +0 -37
- package/dist/templates/react-context/files/context-provider.js.map +0 -1
- package/dist/templates/react-context/files/context.d.ts +0 -5
- package/dist/templates/react-context/files/context.js +0 -31
- package/dist/templates/react-context/files/context.js.map +0 -1
- package/dist/templates/react-context/files/docs.d.ts +0 -5
- package/dist/templates/react-context/files/docs.js +0 -60
- package/dist/templates/react-context/files/docs.js.map +0 -1
- package/dist/templates/react-context/files/index-file.d.ts +0 -5
- package/dist/templates/react-context/files/index-file.js +0 -23
- package/dist/templates/react-context/files/index-file.js.map +0 -1
- package/dist/templates/react-context/files/test.d.ts +0 -5
- package/dist/templates/react-context/files/test.js +0 -26
- package/dist/templates/react-context/files/test.js.map +0 -1
- package/dist/templates/react-context/index.d.ts +0 -2
- package/dist/templates/react-context/index.js +0 -65
- package/dist/templates/react-context/index.js.map +0 -1
- package/dist/templates/react-env/files/aspect.d.ts +0 -2
- package/dist/templates/react-env/files/aspect.js +0 -19
- package/dist/templates/react-env/files/aspect.js.map +0 -1
- package/dist/templates/react-env/files/doc.d.ts +0 -2
- package/dist/templates/react-env/files/doc.js +0 -186
- package/dist/templates/react-env/files/doc.js.map +0 -1
- package/dist/templates/react-env/files/index.d.ts +0 -2
- package/dist/templates/react-env/files/index.js +0 -19
- package/dist/templates/react-env/files/index.js.map +0 -1
- package/dist/templates/react-env/files/jest.config.d.ts +0 -1
- package/dist/templates/react-env/files/jest.config.js +0 -29
- package/dist/templates/react-env/files/jest.config.js.map +0 -1
- package/dist/templates/react-env/files/main.runtime.d.ts +0 -2
- package/dist/templates/react-env/files/main.runtime.js +0 -103
- package/dist/templates/react-env/files/main.runtime.js.map +0 -1
- package/dist/templates/react-env/files/preview.runtime.d.ts +0 -2
- package/dist/templates/react-env/files/preview.runtime.js +0 -37
- package/dist/templates/react-env/files/preview.runtime.js.map +0 -1
- package/dist/templates/react-env/files/typescript/styles.d.ts +0 -1
- package/dist/templates/react-env/files/typescript/styles.js +0 -15
- package/dist/templates/react-env/files/typescript/styles.js.map +0 -1
- package/dist/templates/react-env/files/typescript/ts-transformer.d.ts +0 -1
- package/dist/templates/react-env/files/typescript/ts-transformer.js +0 -58
- package/dist/templates/react-env/files/typescript/ts-transformer.js.map +0 -1
- package/dist/templates/react-env/files/typescript/typescript.config.d.ts +0 -1
- package/dist/templates/react-env/files/typescript/typescript.config.js +0 -29
- package/dist/templates/react-env/files/typescript/typescript.config.js.map +0 -1
- package/dist/templates/react-env/files/webpack.config.d.ts +0 -1
- package/dist/templates/react-env/files/webpack.config.js +0 -56
- package/dist/templates/react-env/files/webpack.config.js.map +0 -1
- package/dist/templates/react-env/index.d.ts +0 -2
- package/dist/templates/react-env/index.js +0 -124
- package/dist/templates/react-env/index.js.map +0 -1
- package/dist/templates/react-hook/files/component.d.ts +0 -5
- package/dist/templates/react-hook/files/component.js +0 -26
- package/dist/templates/react-hook/files/component.js.map +0 -1
- package/dist/templates/react-hook/files/composition.d.ts +0 -5
- package/dist/templates/react-hook/files/composition.js +0 -32
- package/dist/templates/react-hook/files/composition.js.map +0 -1
- package/dist/templates/react-hook/files/docs.d.ts +0 -5
- package/dist/templates/react-hook/files/docs.js +0 -42
- package/dist/templates/react-hook/files/docs.js.map +0 -1
- package/dist/templates/react-hook/files/index-file.d.ts +0 -5
- package/dist/templates/react-hook/files/index-file.js +0 -20
- package/dist/templates/react-hook/files/index-file.js.map +0 -1
- package/dist/templates/react-hook/files/index-file.spec.d.ts +0 -1
- package/dist/templates/react-hook/files/index-file.spec.js +0 -36
- package/dist/templates/react-hook/files/index-file.spec.js.map +0 -1
- package/dist/templates/react-hook/files/test.d.ts +0 -5
- package/dist/templates/react-hook/files/test.js +0 -29
- package/dist/templates/react-hook/files/test.js.map +0 -1
- package/dist/templates/react-hook/index.d.ts +0 -2
- package/dist/templates/react-hook/index.js +0 -58
- package/dist/templates/react-hook/index.js.map +0 -1
- package/templates/react-app/files/app-plugin.ts +0 -9
- package/templates/react-app/files/app-root.ts +0 -16
- package/templates/react-app/files/app.ts +0 -26
- package/templates/react-app/files/compositions.ts +0 -16
- package/templates/react-app/files/doc.ts +0 -23
- package/templates/react-app/files/index.ts +0 -5
- package/templates/react-app/index.ts +0 -48
- package/templates/react-component/files/component.ts +0 -25
- package/templates/react-component/files/composition.ts +0 -18
- package/templates/react-component/files/docs.ts +0 -28
- package/templates/react-component/files/index-file.ts +0 -12
- package/templates/react-component/files/test.ts +0 -19
- package/templates/react-component/index.ts +0 -27
- package/templates/react-component-js/files/component.ts +0 -18
- package/templates/react-component-js/files/composition.ts +0 -16
- package/templates/react-component-js/files/docs.ts +0 -32
- package/templates/react-component-js/files/test.ts +0 -21
- package/templates/react-component-js/index.ts +0 -32
- package/templates/react-context/files/composition.ts +0 -27
- package/templates/react-context/files/context-provider.ts +0 -27
- package/templates/react-context/files/context.ts +0 -21
- package/templates/react-context/files/docs.ts +0 -51
- package/templates/react-context/files/index-file.ts +0 -14
- package/templates/react-context/files/test.ts +0 -18
- package/templates/react-context/index.ts +0 -29
- package/templates/react-env/files/aspect.ts +0 -10
- package/templates/react-env/files/doc.ts +0 -177
- package/templates/react-env/files/index.ts +0 -10
- package/templates/react-env/files/jest.config.ts +0 -21
- package/templates/react-env/files/main.runtime.ts +0 -94
- package/templates/react-env/files/preview.runtime.ts +0 -27
- package/templates/react-env/files/typescript/styles.ts +0 -7
- package/templates/react-env/files/typescript/ts-transformer.ts +0 -50
- package/templates/react-env/files/typescript/typescript.config.ts +0 -21
- package/templates/react-env/files/webpack.config.ts +0 -48
- package/templates/react-env/index.ts +0 -68
- package/templates/react-hook/files/component.ts +0 -16
- package/templates/react-hook/files/composition.ts +0 -23
- package/templates/react-hook/files/docs.ts +0 -33
- package/templates/react-hook/files/index-file.spec.ts +0 -24
- package/templates/react-hook/files/index-file.ts +0 -11
- package/templates/react-hook/files/test.ts +0 -20
- package/templates/react-hook/index.ts +0 -21
- /package/{compositions-1698930721010.js → compositions-1699364645970.js} +0 -0
- /package/{overview-1698930721010.js → overview-1699364645970.js} +0 -0
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { ComponentContext } from '@teambit/generator';
|
|
2
|
-
|
|
3
|
-
export const compositionFile = (context: ComponentContext) => {
|
|
4
|
-
const { name, namePascalCase: Name } = context;
|
|
5
|
-
|
|
6
|
-
return {
|
|
7
|
-
relativePath: `${name}.composition.tsx`,
|
|
8
|
-
content: `import React from 'react';
|
|
9
|
-
import { ${Name} } from './${name}';
|
|
10
|
-
|
|
11
|
-
export const Basic${Name} = () => {
|
|
12
|
-
return (
|
|
13
|
-
<${Name}>hello world!</${Name}>
|
|
14
|
-
);
|
|
15
|
-
}
|
|
16
|
-
`,
|
|
17
|
-
};
|
|
18
|
-
};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { ComponentContext } from '@teambit/generator';
|
|
2
|
-
|
|
3
|
-
export const docsFile = (context: ComponentContext) => {
|
|
4
|
-
const { name, namePascalCase: Name } = context;
|
|
5
|
-
|
|
6
|
-
return {
|
|
7
|
-
relativePath: `${name}.docs.mdx`,
|
|
8
|
-
content: `---
|
|
9
|
-
description: A ${Name} component.
|
|
10
|
-
---
|
|
11
|
-
|
|
12
|
-
import { ${Name} } from './${name}';
|
|
13
|
-
|
|
14
|
-
A component that does something special and renders text in a div.
|
|
15
|
-
|
|
16
|
-
### Component usage
|
|
17
|
-
\`\`\`js
|
|
18
|
-
<${Name}>Hello world!</${Name}>
|
|
19
|
-
\`\`\`
|
|
20
|
-
|
|
21
|
-
### Render hello world!
|
|
22
|
-
|
|
23
|
-
\`\`\`js live
|
|
24
|
-
<${Name}>Hello world!</${Name}>
|
|
25
|
-
\`\`\`
|
|
26
|
-
`,
|
|
27
|
-
};
|
|
28
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { ComponentContext } from '@teambit/generator';
|
|
2
|
-
|
|
3
|
-
export const indexFile = (context: ComponentContext) => {
|
|
4
|
-
const { name, namePascalCase: Name } = context;
|
|
5
|
-
|
|
6
|
-
return {
|
|
7
|
-
relativePath: 'index.ts',
|
|
8
|
-
content: `export { ${Name} } from './${name}';
|
|
9
|
-
export type { ${Name}Props } from './${name}';
|
|
10
|
-
`,
|
|
11
|
-
};
|
|
12
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { ComponentContext } from '@teambit/generator';
|
|
2
|
-
|
|
3
|
-
export const testFile = (context: ComponentContext) => {
|
|
4
|
-
const { name, namePascalCase: Name } = context;
|
|
5
|
-
|
|
6
|
-
return {
|
|
7
|
-
relativePath: `${name}.spec.tsx`,
|
|
8
|
-
content: `import React from 'react';
|
|
9
|
-
import { render } from '@testing-library/react';
|
|
10
|
-
import { Basic${Name} } from './${name}.composition';
|
|
11
|
-
|
|
12
|
-
it('should render with the correct text', () => {
|
|
13
|
-
const { getByText } = render(<Basic${Name} />);
|
|
14
|
-
const rendered = getByText('hello world!');
|
|
15
|
-
expect(rendered).toBeTruthy();
|
|
16
|
-
});
|
|
17
|
-
`,
|
|
18
|
-
};
|
|
19
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { ComponentTemplate, ComponentContext } from '@teambit/generator';
|
|
2
|
-
import { componentFile } from './files/component';
|
|
3
|
-
import { compositionFile } from './files/composition';
|
|
4
|
-
import { docsFile } from './files/docs';
|
|
5
|
-
import { testFile } from './files/test';
|
|
6
|
-
import { indexFile } from './files/index-file';
|
|
7
|
-
|
|
8
|
-
export const reactComponent: ComponentTemplate = {
|
|
9
|
-
name: 'react',
|
|
10
|
-
description: 'a basic react component',
|
|
11
|
-
hidden: true,
|
|
12
|
-
generateFiles: (context: ComponentContext) => {
|
|
13
|
-
return [indexFile(context), componentFile(context), compositionFile(context), docsFile(context), testFile(context)];
|
|
14
|
-
},
|
|
15
|
-
config: {
|
|
16
|
-
'teambit.react/react': {},
|
|
17
|
-
'teambit.envs/envs': {
|
|
18
|
-
env: 'teambit.react/react',
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export const deprecatedReactComponent: ComponentTemplate = {
|
|
24
|
-
...reactComponent,
|
|
25
|
-
name: 'react-component',
|
|
26
|
-
hidden: true,
|
|
27
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { ComponentContext } from '@teambit/generator';
|
|
2
|
-
|
|
3
|
-
export const componentFile = (context: ComponentContext) => {
|
|
4
|
-
const { name, namePascalCase: Name } = context;
|
|
5
|
-
return {
|
|
6
|
-
relativePath: `${name}.jsx`,
|
|
7
|
-
content: `import React from 'react';
|
|
8
|
-
|
|
9
|
-
export function ${Name}({ text }) {
|
|
10
|
-
return (
|
|
11
|
-
<div>
|
|
12
|
-
{text}
|
|
13
|
-
</div>
|
|
14
|
-
);
|
|
15
|
-
}
|
|
16
|
-
`,
|
|
17
|
-
};
|
|
18
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { ComponentContext } from '@teambit/generator';
|
|
2
|
-
|
|
3
|
-
export const compositionFile = (context: ComponentContext) => {
|
|
4
|
-
const { name, namePascalCase: Name } = context;
|
|
5
|
-
|
|
6
|
-
return {
|
|
7
|
-
relativePath: `${name}.composition.jsx`,
|
|
8
|
-
content: `import React from 'react';
|
|
9
|
-
import { ${Name} } from './${name}';
|
|
10
|
-
|
|
11
|
-
export const Basic${Name} = () => (
|
|
12
|
-
<${Name} text="hello from ${Name}" />
|
|
13
|
-
);
|
|
14
|
-
`,
|
|
15
|
-
};
|
|
16
|
-
};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { ComponentContext } from '@teambit/generator';
|
|
2
|
-
|
|
3
|
-
export const docsFile = (context: ComponentContext) => {
|
|
4
|
-
const { name, namePascalCase: Name } = context;
|
|
5
|
-
|
|
6
|
-
return {
|
|
7
|
-
relativePath: `${name}.docs.mdx`,
|
|
8
|
-
content: `---
|
|
9
|
-
description: 'A ${Name} component.'
|
|
10
|
-
labels: ['label1', 'label2', 'label3']
|
|
11
|
-
---
|
|
12
|
-
|
|
13
|
-
import { ${Name} } from './${name}';
|
|
14
|
-
|
|
15
|
-
## React Component for rendering text
|
|
16
|
-
|
|
17
|
-
A basic div that renders some text
|
|
18
|
-
|
|
19
|
-
### Component usage
|
|
20
|
-
\`\`\`js
|
|
21
|
-
<${Name} text="hello from ${Name}" />
|
|
22
|
-
\`\`\`
|
|
23
|
-
|
|
24
|
-
### Using props to customize the text
|
|
25
|
-
|
|
26
|
-
Modify the text to see it change live:
|
|
27
|
-
\`\`\`js live
|
|
28
|
-
<${Name} text="hello from ${Name}" />
|
|
29
|
-
\`\`\`
|
|
30
|
-
`,
|
|
31
|
-
};
|
|
32
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { ComponentContext } from '@teambit/generator';
|
|
2
|
-
|
|
3
|
-
export const testFile = (context: ComponentContext) => {
|
|
4
|
-
const { name, namePascalCase: Name } = context;
|
|
5
|
-
|
|
6
|
-
return {
|
|
7
|
-
relativePath: `${name}.spec.jsx`,
|
|
8
|
-
content: `import React from 'react';
|
|
9
|
-
import { render } from '@testing-library/react';
|
|
10
|
-
import { Basic${Name} } from './${name}.composition';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
it('should render with the correct text', () => {
|
|
14
|
-
const { getByText } = render(<Basic${Name} />);
|
|
15
|
-
const rendered = getByText('hello from ${Name}');
|
|
16
|
-
expect(rendered).toBeTruthy();
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
`,
|
|
20
|
-
};
|
|
21
|
-
};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { ComponentTemplate, ComponentContext } from '@teambit/generator';
|
|
2
|
-
import { componentFile } from './files/component';
|
|
3
|
-
import { compositionFile } from './files/composition';
|
|
4
|
-
import { docsFile } from './files/docs';
|
|
5
|
-
import { testFile } from './files/test';
|
|
6
|
-
|
|
7
|
-
export const reactComponentJS: ComponentTemplate = {
|
|
8
|
-
name: 'react-js',
|
|
9
|
-
description: 'a basic react component in js',
|
|
10
|
-
hidden: true,
|
|
11
|
-
generateFiles: (context: ComponentContext) => {
|
|
12
|
-
const { name, namePascalCase: Name } = context;
|
|
13
|
-
const indexFile = {
|
|
14
|
-
relativePath: 'index.js',
|
|
15
|
-
content: `export { ${Name} } from './${name}';
|
|
16
|
-
`,
|
|
17
|
-
};
|
|
18
|
-
return [indexFile, componentFile(context), compositionFile(context), docsFile(context), testFile(context)];
|
|
19
|
-
},
|
|
20
|
-
config: {
|
|
21
|
-
'teambit.react/react': {},
|
|
22
|
-
'teambit.envs/envs': {
|
|
23
|
-
env: 'teambit.react/react',
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export const deprecatedReactComponentJS: ComponentTemplate = {
|
|
29
|
-
...reactComponentJS,
|
|
30
|
-
name: 'react-component-js',
|
|
31
|
-
hidden: true,
|
|
32
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { ComponentContext } from '@teambit/generator';
|
|
2
|
-
|
|
3
|
-
export const compositionFile = (context: ComponentContext) => {
|
|
4
|
-
const { name, namePascalCase: Name } = context;
|
|
5
|
-
|
|
6
|
-
return {
|
|
7
|
-
relativePath: `${name}-context.composition.tsx`,
|
|
8
|
-
content: `import React, { useContext } from 'react';
|
|
9
|
-
import { ${Name}Provider } from './${name}-context-provider';
|
|
10
|
-
import { ${Name}Context } from './${name}-context';
|
|
11
|
-
|
|
12
|
-
export function MockComponent() {
|
|
13
|
-
const theme = useContext(${Name}Context);
|
|
14
|
-
|
|
15
|
-
return <div style={{ color: theme.color }}>this should be {theme.color}</div>;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export const BasicThemeUsage = () => {
|
|
19
|
-
return (
|
|
20
|
-
<${Name}Provider color="blue">
|
|
21
|
-
<MockComponent />
|
|
22
|
-
</${Name}Provider>
|
|
23
|
-
);
|
|
24
|
-
};
|
|
25
|
-
`,
|
|
26
|
-
};
|
|
27
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { ComponentContext } from '@teambit/generator';
|
|
2
|
-
|
|
3
|
-
export const contextProviderFile = (context: ComponentContext) => {
|
|
4
|
-
const { name, namePascalCase: Name } = context;
|
|
5
|
-
return {
|
|
6
|
-
relativePath: `${name}-context-provider.tsx`,
|
|
7
|
-
content: `import React, { ReactNode } from 'react';
|
|
8
|
-
import { ${Name}Context } from './${name}-context';
|
|
9
|
-
|
|
10
|
-
export type ${Name}ProviderProps = {
|
|
11
|
-
/**
|
|
12
|
-
* primary color of theme.
|
|
13
|
-
*/
|
|
14
|
-
color?: string,
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* children to be rendered within this theme.
|
|
18
|
-
*/
|
|
19
|
-
children: ReactNode
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export function ${Name}Provider({ color, children }: ${Name}ProviderProps) {
|
|
23
|
-
return <${Name}Context.Provider value={{ color }}>{children}</${Name}Context.Provider>
|
|
24
|
-
}
|
|
25
|
-
`,
|
|
26
|
-
};
|
|
27
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { ComponentContext } from '@teambit/generator';
|
|
2
|
-
|
|
3
|
-
export const contextFile = (context: ComponentContext) => {
|
|
4
|
-
const { name, namePascalCase: Name } = context;
|
|
5
|
-
return {
|
|
6
|
-
relativePath: `${name}-context.tsx`,
|
|
7
|
-
content: `import { createContext } from 'react';
|
|
8
|
-
|
|
9
|
-
export type ${Name}ContextType = {
|
|
10
|
-
/**
|
|
11
|
-
* primary color of theme.
|
|
12
|
-
*/
|
|
13
|
-
color?: string;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export const ${Name}Context = createContext<${Name}ContextType>({
|
|
17
|
-
color: 'aqua'
|
|
18
|
-
});
|
|
19
|
-
`,
|
|
20
|
-
};
|
|
21
|
-
};
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { ComponentContext } from '@teambit/generator';
|
|
2
|
-
|
|
3
|
-
export const docsFile = (context: ComponentContext) => {
|
|
4
|
-
const { name, namePascalCase: Name } = context;
|
|
5
|
-
|
|
6
|
-
return {
|
|
7
|
-
relativePath: `${name}-context.docs.mdx`,
|
|
8
|
-
content: `---
|
|
9
|
-
description: ${Name} context.
|
|
10
|
-
labels: ['context']
|
|
11
|
-
---
|
|
12
|
-
|
|
13
|
-
import { ${Name}Context } from './${name}-context';
|
|
14
|
-
import { ${Name}Provider } from './${name}-context-provider';
|
|
15
|
-
import { MockComponent } from './${name}-context.composition';
|
|
16
|
-
|
|
17
|
-
## React Theme Context
|
|
18
|
-
|
|
19
|
-
This is a simple [React Context](https://reactjs.org/docs/context.html) shared as a Bit component.
|
|
20
|
-
Use this component to apply a theme as a context to set on it's children.
|
|
21
|
-
|
|
22
|
-
### Component usage
|
|
23
|
-
|
|
24
|
-
\`\`\`tsx
|
|
25
|
-
() => {
|
|
26
|
-
import React, { useContext } from 'react';
|
|
27
|
-
import { ThemeProvider } from './theme-context-provider';
|
|
28
|
-
import { ThemeContext } from './theme-context';
|
|
29
|
-
|
|
30
|
-
<${Name}Provider color="blue">
|
|
31
|
-
// My lovely children now get a theme!
|
|
32
|
-
<MockComponent />
|
|
33
|
-
</${Name}Provider>;
|
|
34
|
-
\`\`\`
|
|
35
|
-
|
|
36
|
-
### Using props to customize the theme
|
|
37
|
-
|
|
38
|
-
Change the color to see the text change:
|
|
39
|
-
|
|
40
|
-
\`\`\`tsx live
|
|
41
|
-
() => {
|
|
42
|
-
return (
|
|
43
|
-
<${Name}Provider color="red">
|
|
44
|
-
<MockComponent />
|
|
45
|
-
</${Name}Provider>
|
|
46
|
-
);
|
|
47
|
-
};
|
|
48
|
-
\`\`\`
|
|
49
|
-
`,
|
|
50
|
-
};
|
|
51
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { ComponentContext } from '@teambit/generator';
|
|
2
|
-
|
|
3
|
-
export const indexFile = (context: ComponentContext) => {
|
|
4
|
-
const { name, namePascalCase: Name } = context;
|
|
5
|
-
|
|
6
|
-
return {
|
|
7
|
-
relativePath: 'index.ts',
|
|
8
|
-
content: `export { ${Name}Context } from './${name}-context';
|
|
9
|
-
export type { ${Name}ContextType } from './${name}-context';
|
|
10
|
-
export { ${Name}Provider } from './${name}-context-provider';
|
|
11
|
-
export type { ${Name}ProviderProps } from './${name}-context-provider';
|
|
12
|
-
`,
|
|
13
|
-
};
|
|
14
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { ComponentContext } from '@teambit/generator';
|
|
2
|
-
|
|
3
|
-
export const testFile = (context: ComponentContext) => {
|
|
4
|
-
const { name } = context;
|
|
5
|
-
|
|
6
|
-
return {
|
|
7
|
-
relativePath: `${name}-context.spec.tsx`,
|
|
8
|
-
content: `import { BasicThemeUsage } from './${name}-context.composition';
|
|
9
|
-
import { render } from '@testing-library/react';
|
|
10
|
-
|
|
11
|
-
it('should render the button in the color blue', () => {
|
|
12
|
-
const { getByText } = render(<BasicThemeUsage />);
|
|
13
|
-
const rendered = getByText('this should be blue');
|
|
14
|
-
expect(rendered).toBeTruthy();
|
|
15
|
-
});
|
|
16
|
-
`,
|
|
17
|
-
};
|
|
18
|
-
};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { ComponentTemplate, ComponentContext } from '@teambit/generator';
|
|
2
|
-
import { contextFile } from './files/context';
|
|
3
|
-
import { contextProviderFile } from './files/context-provider';
|
|
4
|
-
import { compositionFile } from './files/composition';
|
|
5
|
-
import { docsFile } from './files/docs';
|
|
6
|
-
import { testFile } from './files/test';
|
|
7
|
-
import { indexFile } from './files/index-file';
|
|
8
|
-
|
|
9
|
-
export const reactContext: ComponentTemplate = {
|
|
10
|
-
name: 'react-context',
|
|
11
|
-
description: 'a react context component',
|
|
12
|
-
hidden: true,
|
|
13
|
-
generateFiles: (context: ComponentContext) => {
|
|
14
|
-
return [
|
|
15
|
-
indexFile(context),
|
|
16
|
-
contextFile(context),
|
|
17
|
-
contextProviderFile(context),
|
|
18
|
-
compositionFile(context),
|
|
19
|
-
docsFile(context),
|
|
20
|
-
testFile(context),
|
|
21
|
-
];
|
|
22
|
-
},
|
|
23
|
-
config: {
|
|
24
|
-
'teambit.react/react': {},
|
|
25
|
-
'teambit.envs/envs': {
|
|
26
|
-
env: 'teambit.react/react',
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { ComponentContext } from '@teambit/generator';
|
|
2
|
-
|
|
3
|
-
export function aspectFile({ namePascalCase: Name, componentId }: ComponentContext) {
|
|
4
|
-
return `import { Aspect } from '@teambit/harmony';
|
|
5
|
-
|
|
6
|
-
export const ${Name}Aspect = Aspect.create({
|
|
7
|
-
id: '${componentId}',
|
|
8
|
-
});
|
|
9
|
-
`;
|
|
10
|
-
}
|
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
import { ComponentContext } from '@teambit/generator';
|
|
2
|
-
|
|
3
|
-
export function docFile({ name, componentId }: ComponentContext) {
|
|
4
|
-
return `---
|
|
5
|
-
description: 'A standard React component development environment'
|
|
6
|
-
labels: ['react', 'typescript', 'env', 'extension']
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
## Overview
|
|
10
|
-
|
|
11
|
-
A customized version which extends the default React component development environment created by teambit.
|
|
12
|
-
|
|
13
|
-
This environment can be applied to all your components or a set of components via the command \`bit env set <pattern or component_id> ${componentId}\`, or under the variants of your \`workspace.json\` file.
|
|
14
|
-
That means they will use your custom environment instead of the default environment. Environment components are just like any other Bit components in that they can be
|
|
15
|
-
exported and then shared and used in various projects which makes it easier to create standards when working with many teams.
|
|
16
|
-
|
|
17
|
-
### Usage instructions
|
|
18
|
-
|
|
19
|
-
#### Recommended usage:
|
|
20
|
-
|
|
21
|
-
Run the command \`bit env set <"pattern" or component_id> ${componentId}\` where the pattern is a glob pattern to select multiple components. This will put the env
|
|
22
|
-
config in your component's entry in the \`.bitmap\` file.
|
|
23
|
-
|
|
24
|
-
:::Note - this will override any variants policy that tries to set an env for this component in the workspace.jsonc
|
|
25
|
-
:::
|
|
26
|
-
|
|
27
|
-
#### Alternative Usage
|
|
28
|
-
Under the **variant** section of your \`workspace.json\` file choose which components you want to have the custom environment set. You can find the id of the extension in the \`${name}.aspect.ts\` file.
|
|
29
|
-
|
|
30
|
-
\`\`\`json
|
|
31
|
-
{
|
|
32
|
-
"teambit.workspace/variants": {
|
|
33
|
-
"{ui/**}, {pages/**}": {
|
|
34
|
-
"${componentId}": {}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
\`\`\`
|
|
39
|
-
|
|
40
|
-
This usage may be deprecated in future in favour of the recommended usage above
|
|
41
|
-
## Runtime Configurations
|
|
42
|
-
|
|
43
|
-
Extend the \`main.runtime\` file when you want to add custom configurations at runtime.
|
|
44
|
-
|
|
45
|
-
### Compilation
|
|
46
|
-
|
|
47
|
-
By default, Component compilation is done with the TypeScript compiler. Target format is \`ES2015\` which
|
|
48
|
-
supports execution from both NodeJS and browser runtimes for server-side rendering. You can modify the \`tsconfig.json\` file to add your own compiler options which will then be merged with the default configs set by teambit.
|
|
49
|
-
|
|
50
|
-
Example:
|
|
51
|
-
|
|
52
|
-
\`\`\`json
|
|
53
|
-
{
|
|
54
|
-
"compilerOptions": {
|
|
55
|
-
"target": "es2017",
|
|
56
|
-
"module": "es2015",
|
|
57
|
-
"moduleResolution": "node",
|
|
58
|
-
"lib": ["es2017", "dom"],
|
|
59
|
-
"experimentalDecorators": true,
|
|
60
|
-
"esModuleInterop": true,
|
|
61
|
-
"outDir": "dist",
|
|
62
|
-
"sourceMap": true,
|
|
63
|
-
"emitDecoratorMetadata": true,
|
|
64
|
-
"allowJs": true,
|
|
65
|
-
"baseUrl": ".",
|
|
66
|
-
"jsx": "react"
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
\`\`\`
|
|
70
|
-
|
|
71
|
-
### Testing
|
|
72
|
-
|
|
73
|
-
Component testing is done through [Jest](https://jestjs.io/) with the default \`teambit.react/react\` environment. You can modify the \`jestconfig.js\` file to add your own configurations which will then be merged with the default configs set by teambit.
|
|
74
|
-
|
|
75
|
-
Example:
|
|
76
|
-
|
|
77
|
-
To Override the Jest config to ignore transpiling from specific folders add this to the \`jestconfig.js\` file:
|
|
78
|
-
|
|
79
|
-
\`\`\`js
|
|
80
|
-
const reactJestConfig = require('@teambit/react/jest/jest.config');
|
|
81
|
-
module.exports = {
|
|
82
|
-
...reactJestConfig,
|
|
83
|
-
transformIgnorePatterns: ['/node_modules/(?!(prop-types|@teambit))']
|
|
84
|
-
};
|
|
85
|
-
\`\`\`
|
|
86
|
-
|
|
87
|
-
### Webpack
|
|
88
|
-
|
|
89
|
-
Bit uses webpack 5 to bundle components. You can modify the \`webpack.config.js\` file to add your own configurations which will then be merged with the default configs set by teambit.
|
|
90
|
-
|
|
91
|
-
Example:
|
|
92
|
-
|
|
93
|
-
\`\`\`ts
|
|
94
|
-
module.exports = {
|
|
95
|
-
module: {
|
|
96
|
-
// add your custom rules here
|
|
97
|
-
rules: []
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
\`\`\`
|
|
101
|
-
|
|
102
|
-
### ESLint
|
|
103
|
-
|
|
104
|
-
Bit uses ESLint to lint your components. You can add your own rules in the \`${name}.main.runtime\` file.
|
|
105
|
-
|
|
106
|
-
Example:
|
|
107
|
-
|
|
108
|
-
\`\`\`ts
|
|
109
|
-
react.useEslint({
|
|
110
|
-
transformers: [
|
|
111
|
-
(config) => {
|
|
112
|
-
config.setRule('no-console', ['error']);
|
|
113
|
-
// add more rules here
|
|
114
|
-
return config;
|
|
115
|
-
}
|
|
116
|
-
]
|
|
117
|
-
}),
|
|
118
|
-
\`\`\`
|
|
119
|
-
|
|
120
|
-
To use ESLint:
|
|
121
|
-
|
|
122
|
-
\`\`\`bash
|
|
123
|
-
bit lint
|
|
124
|
-
bit lint --fix
|
|
125
|
-
\`\`\`
|
|
126
|
-
|
|
127
|
-
### Formatting
|
|
128
|
-
|
|
129
|
-
Bit uses Prettier to format your components. You can add your own rules in the \`${name}.main.runtime\` file.
|
|
130
|
-
|
|
131
|
-
Example:
|
|
132
|
-
|
|
133
|
-
\`\`\`ts
|
|
134
|
-
react.usePrettier({
|
|
135
|
-
transformers: [
|
|
136
|
-
(config) => {
|
|
137
|
-
config.setKey('tabWidth', 2);
|
|
138
|
-
// add more rules here
|
|
139
|
-
return config;
|
|
140
|
-
}
|
|
141
|
-
]
|
|
142
|
-
}),
|
|
143
|
-
\`\`\`
|
|
144
|
-
|
|
145
|
-
To use Prettier:
|
|
146
|
-
|
|
147
|
-
\`\`\`bash
|
|
148
|
-
bit format --check
|
|
149
|
-
bit format
|
|
150
|
-
\`\`\`
|
|
151
|
-
|
|
152
|
-
### Dependencies
|
|
153
|
-
|
|
154
|
-
Override the default dependencies in the \`${name}.main.runtime\` file to include react types of a different version for example.
|
|
155
|
-
|
|
156
|
-
\`\`\`ts
|
|
157
|
-
react.overrideDependencies({
|
|
158
|
-
devDependencies: {
|
|
159
|
-
'@types/react': '17.0.3'
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
\`\`\`
|
|
163
|
-
|
|
164
|
-
## Preview Configurations
|
|
165
|
-
|
|
166
|
-
Extend the \`${name}.preview.runtime\` file when you want to add your own customizations only for previewing in the Bit UI.
|
|
167
|
-
|
|
168
|
-
### Adding a Theme
|
|
169
|
-
|
|
170
|
-
A custom theme has been added to the env which wraps all the composition files with the required theme so they can be developed with the correct themeing rather than the browsers default. This is added only in the preview runtime and not in the main runtime meaning it is only applied to compositions and not when consuming components. Adding a theme when consuming should be done at App level as you component may be consumed in various apps and have different themes applied depending on where it is consumed.
|
|
171
|
-
|
|
172
|
-
Example:
|
|
173
|
-
|
|
174
|
-
\`\`\`ts
|
|
175
|
-
react.registerProvider([ThemeCompositions]);
|
|
176
|
-
`;
|
|
177
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { ComponentContext } from '@teambit/generator';
|
|
2
|
-
|
|
3
|
-
export function indexFile({ namePascalCase: Name, name }: ComponentContext) {
|
|
4
|
-
return `import { ${Name}Aspect } from './${name}.aspect';
|
|
5
|
-
|
|
6
|
-
export type { ${Name}Main } from './${name}.main.runtime';
|
|
7
|
-
export default ${Name}Aspect;
|
|
8
|
-
export { ${Name}Aspect };
|
|
9
|
-
`;
|
|
10
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export function jestConfigFile() {
|
|
2
|
-
return `
|
|
3
|
-
// Override the Jest config to ignore transpiling from specific folders
|
|
4
|
-
// See the base Jest config: https://bit.cloud/teambit/react/react/~code/jest/jest.config.js
|
|
5
|
-
|
|
6
|
-
// const reactJestConfig = require('@teambit/react/jest/jest.config');
|
|
7
|
-
// uncomment the line below and install the package if you want to use this function
|
|
8
|
-
// const {
|
|
9
|
-
// generateNodeModulesPattern,
|
|
10
|
-
// } = require('@teambit/dependencies.modules.packages-excluder');
|
|
11
|
-
// const packagesToExclude = ['@my-org', 'my-package-name'];
|
|
12
|
-
|
|
13
|
-
// module.exports = {
|
|
14
|
-
// ...reactJestConfig,
|
|
15
|
-
// transformIgnorePatterns: [
|
|
16
|
-
// '^.+\\.module\\.(css|sass|scss)$',
|
|
17
|
-
// generateNodeModulesPattern({ packages: packagesToExclude }),
|
|
18
|
-
// ],
|
|
19
|
-
// };
|
|
20
|
-
`;
|
|
21
|
-
}
|