@teambit/mdx 0.0.546 → 0.0.550

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.
@@ -0,0 +1,8 @@
1
+ const presets = [require.resolve('@babel/preset-env'), require.resolve('@babel/preset-react')];
2
+ const plugins = [require.resolve('@babel/plugin-proposal-class-properties')];
3
+
4
+ export const babelConfig = {
5
+ presets,
6
+ plugins,
7
+ sourceMaps: true,
8
+ };
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+
3
+ export const Logo = () => (
4
+ <div style={{ height: '100%', display: 'flex', justifyContent: 'center' }}>
5
+ <img style={{ width: 70 }} src="https://static.bit.dev/brands/logo-mdx.svg" />
6
+ </div>
7
+ );
@@ -0,0 +1,42 @@
1
+ import React from 'react';
2
+ import { CompositionsAspect, CompositionsUI } from '@teambit/compositions';
3
+ import { UIRuntime } from '@teambit/ui';
4
+ import { TesterAspect, TesterUI } from '@teambit/tester';
5
+ import { EmptyBox } from '@teambit/design.ui.empty-box';
6
+ import { MDXAspect } from './mdx.aspect';
7
+
8
+ export class MDXEnvUI {
9
+ static runtime = UIRuntime;
10
+ static slots = [];
11
+ static dependencies = [CompositionsAspect, TesterAspect];
12
+
13
+ static async provider([compositionsUI, testerUi]: [CompositionsUI, TesterUI]) {
14
+ const mdxEnvUI = new MDXEnvUI();
15
+
16
+ testerUi.registerEmptyState(() => {
17
+ return (
18
+ <EmptyBox
19
+ title="This component doesn’t have any tests."
20
+ linkText="Learn how to add tests to your MDX components"
21
+ link="https://harmony-docs.bit.dev/testing/overview/"
22
+ />
23
+ );
24
+ });
25
+
26
+ compositionsUI.registerEmptyState(() => {
27
+ return (
28
+ <EmptyBox
29
+ title="This component doesn’t have any compositions."
30
+ linkText="Learn how to add compositions to your MDX components"
31
+ link="https://harmony-docs.bit.dev/compositions/overview/"
32
+ />
33
+ );
34
+ });
35
+
36
+ return mdxEnvUI;
37
+ }
38
+ }
39
+
40
+ MDXAspect.addRuntime(MDXEnvUI);
41
+
42
+ export default MDXEnvUI;
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/mdx",
3
- "version": "0.0.546",
3
+ "version": "0.0.550",
4
4
  "homepage": "https://bit.dev/teambit/mdx/mdx",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.mdx",
8
8
  "name": "mdx",
9
- "version": "0.0.546"
9
+ "version": "0.0.550"
10
10
  },
11
11
  "dependencies": {
12
12
  "@teambit/harmony": "0.2.11",
@@ -15,24 +15,24 @@
15
15
  "minimatch": "3.0.4",
16
16
  "@babel/runtime": "7.12.18",
17
17
  "core-js": "^3.0.0",
18
- "@teambit/builder": "0.0.566",
19
- "@teambit/compilation.modules.babel-compiler": "0.0.108",
20
- "@teambit/compiler": "0.0.566",
21
- "@teambit/mdx.modules.mdx-compiler": "0.0.470",
22
- "@teambit/dependency-resolver": "0.0.566",
23
- "@teambit/docs": "0.0.566",
24
- "@teambit/babel": "0.0.566",
25
- "@teambit/cli": "0.0.393",
26
- "@teambit/envs": "0.0.566",
27
- "@teambit/generator": "0.0.566",
28
- "@teambit/multi-compiler": "0.0.566",
29
- "@teambit/react": "0.0.566",
30
- "@teambit/typescript.modules.ts-config-mutator": "0.0.50",
31
- "@teambit/typescript": "0.0.566",
32
- "@teambit/compositions": "0.0.566",
18
+ "@teambit/builder": "0.0.570",
19
+ "@teambit/compilation.modules.babel-compiler": "0.0.110",
20
+ "@teambit/compiler": "0.0.570",
21
+ "@teambit/mdx.modules.mdx-compiler": "0.0.472",
22
+ "@teambit/dependency-resolver": "0.0.570",
23
+ "@teambit/docs": "0.0.570",
24
+ "@teambit/babel": "0.0.570",
25
+ "@teambit/cli": "0.0.395",
26
+ "@teambit/envs": "0.0.570",
27
+ "@teambit/generator": "0.0.570",
28
+ "@teambit/multi-compiler": "0.0.570",
29
+ "@teambit/react": "0.0.570",
30
+ "@teambit/typescript.modules.ts-config-mutator": "0.0.52",
31
+ "@teambit/typescript": "0.0.570",
32
+ "@teambit/compositions": "0.0.570",
33
33
  "@teambit/design.ui.empty-box": "0.0.352",
34
- "@teambit/tester": "0.0.566",
35
- "@teambit/ui": "0.0.566"
34
+ "@teambit/tester": "0.0.570",
35
+ "@teambit/ui": "0.0.570"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@types/fs-extra": "9.0.7",
@@ -43,10 +43,10 @@
43
43
  "@types/jest": "^26.0.0",
44
44
  "@types/react-dom": "^17.0.5",
45
45
  "@types/node": "12.20.4",
46
- "@teambit/mdx.aspect-docs.mdx": "0.0.112"
46
+ "@teambit/mdx.aspect-docs.mdx": "0.0.116"
47
47
  },
48
48
  "peerDependencies": {
49
- "@teambit/legacy": "1.0.179",
49
+ "@teambit/legacy": "1.0.181",
50
50
  "react-dom": "^16.8.0 || ^17.0.0",
51
51
  "react": "^16.8.0 || ^17.0.0"
52
52
  },
@@ -74,27 +74,12 @@
74
74
  "react": "-"
75
75
  },
76
76
  "peerDependencies": {
77
- "@teambit/legacy": "1.0.179",
77
+ "@teambit/legacy": "1.0.181",
78
78
  "react-dom": "^16.8.0 || ^17.0.0",
79
79
  "react": "^16.8.0 || ^17.0.0"
80
80
  }
81
81
  }
82
82
  },
83
- "files": [
84
- "dist",
85
- "!dist/tsconfig.tsbuildinfo",
86
- "**/*.md",
87
- "**/*.mdx",
88
- "**/*.js",
89
- "**/*.json",
90
- "**/*.sass",
91
- "**/*.scss",
92
- "**/*.less",
93
- "**/*.css",
94
- "**/*.css",
95
- "**/*.jpeg",
96
- "**/*.gif"
97
- ],
98
83
  "private": false,
99
84
  "engines": {
100
85
  "node": ">=12.22.0"
@@ -0,0 +1,18 @@
1
+ import { ComponentContext } from '@teambit/generator';
2
+
3
+ export const componentFile = (context: ComponentContext) => {
4
+ const { name, namePascalCase: Name } = context;
5
+ return {
6
+ relativePath: `${name}.mdx`,
7
+ content: `# Title - ${Name}
8
+
9
+ This is markdown.
10
+
11
+ <p>This is HTML</p>
12
+
13
+ # Import a React Component or use HTML
14
+
15
+ <button>Button 👋 </button>
16
+ `,
17
+ };
18
+ };
@@ -0,0 +1,16 @@
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 './index';
10
+
11
+ export const Basic${Name} = () => (
12
+ <${Name} />
13
+ );
14
+ `,
15
+ };
16
+ };
@@ -0,0 +1,35 @@
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: 'An MDX component.'
10
+ labels: ['content', 'mdx']
11
+ ---
12
+
13
+ import { ${Name} } from './index';
14
+
15
+ ### Component usage
16
+ \`\`\`js
17
+ <${Name} />
18
+ \`\`\`
19
+
20
+ ### Render with theme and MDX providers
21
+
22
+ \`\`\`js
23
+ import { ThemeCompositions } from '@teambit/documenter.theme.theme-compositions'
24
+ import { MDXLayout } from '@teambit/ui.mdx-layout'
25
+ import { ${Name} } from './index'
26
+
27
+ <ThemeCompositions>
28
+ <MDXLayout>
29
+ <${Name} />
30
+ </MDXLayout>
31
+ </ThemeCompositions>
32
+ \`\`\`
33
+ `,
34
+ };
35
+ };
@@ -0,0 +1,19 @@
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('${Name}');
15
+ expect(rendered).toBeTruthy();
16
+ });
17
+ `,
18
+ };
19
+ };
@@ -0,0 +1,39 @@
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
+ // TODO @ranm8 Tests won't work in MDX until we add a Jest Transformer for the MDX env.
6
+ // import { testFile } from './files/test';
7
+
8
+ export const MDXComponent: ComponentTemplate = {
9
+ name: 'mdx',
10
+ description: 'MDX-file compiled by Bit to a reuseable component',
11
+
12
+ generateFiles: (context: ComponentContext) => {
13
+ const { name, namePascalCase: Name } = context;
14
+ const indexFile = {
15
+ relativePath: 'index.ts',
16
+ content: `export { default as ${Name}, default } from './${name}.mdx';
17
+ `,
18
+ };
19
+
20
+ return [indexFile, componentFile(context), compositionFile(context), docsFile(context)];
21
+ },
22
+ };
23
+
24
+ export const deprecatedMDXComponent: ComponentTemplate = {
25
+ name: 'mdx-component',
26
+ description: 'MDX-file compiled by Bit to a reuseable component',
27
+ hidden: true,
28
+
29
+ generateFiles: (context: ComponentContext) => {
30
+ const { name, namePascalCase: Name } = context;
31
+ const indexFile = {
32
+ relativePath: 'index.ts',
33
+ content: `export { default as ${Name} } from './${name}.mdx';
34
+ `,
35
+ };
36
+
37
+ return [indexFile, componentFile(context), compositionFile(context), docsFile(context)];
38
+ },
39
+ };
@@ -0,0 +1,29 @@
1
+ declare module '*.png' {
2
+ const value: any;
3
+ export = value;
4
+ }
5
+ declare module '*.svg' {
6
+ import type { FunctionComponent, SVGProps } from 'react';
7
+
8
+ export const ReactComponent: FunctionComponent<SVGProps<SVGSVGElement> & { title?: string }>;
9
+ const src: string;
10
+ export default src;
11
+ }
12
+
13
+ // @TODO Gilad
14
+ declare module '*.jpg' {
15
+ const value: any;
16
+ export = value;
17
+ }
18
+ declare module '*.jpeg' {
19
+ const value: any;
20
+ export = value;
21
+ }
22
+ declare module '*.gif' {
23
+ const value: any;
24
+ export = value;
25
+ }
26
+ declare module '*.bmp' {
27
+ const value: any;
28
+ export = value;
29
+ }
@@ -0,0 +1,42 @@
1
+ declare module '*.module.css' {
2
+ const classes: { readonly [key: string]: string };
3
+ export default classes;
4
+ }
5
+ declare module '*.module.scss' {
6
+ const classes: { readonly [key: string]: string };
7
+ export default classes;
8
+ }
9
+ declare module '*.module.sass' {
10
+ const classes: { readonly [key: string]: string };
11
+ export default classes;
12
+ }
13
+
14
+ declare module '*.module.less' {
15
+ const classes: { readonly [key: string]: string };
16
+ export default classes;
17
+ }
18
+
19
+ declare module '*.less' {
20
+ const classes: { readonly [key: string]: string };
21
+ export default classes;
22
+ }
23
+
24
+ declare module '*.css' {
25
+ const classes: { readonly [key: string]: string };
26
+ export default classes;
27
+ }
28
+
29
+ declare module '*.sass' {
30
+ const classes: { readonly [key: string]: string };
31
+ export default classes;
32
+ }
33
+
34
+ declare module '*.scss' {
35
+ const classes: { readonly [key: string]: string };
36
+ export default classes;
37
+ }
38
+
39
+ declare module '*.mdx' {
40
+ const component: any;
41
+ export default component;
42
+ }