@teambit/code 0.0.567 → 0.0.571

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,17 @@
1
+ import { Section } from '@teambit/component';
2
+ import React from 'react';
3
+ import { MenuWidgetIcon } from '@teambit/ui-foundation.ui.menu-widget-icon';
4
+ import type { CodeUI } from './code.ui.runtime';
5
+
6
+ export class CodeSection implements Section {
7
+ constructor(private codeUI: CodeUI) {}
8
+ route = {
9
+ path: '~code/:file*',
10
+ children: this.codeUI.getCodePage(),
11
+ };
12
+ navigationLink = {
13
+ href: '~code',
14
+ children: <MenuWidgetIcon icon="Code" tooltipContent="Code" />,
15
+ };
16
+ order = 30;
17
+ }
@@ -0,0 +1,53 @@
1
+ import { ComponentAspect, ComponentUI } from '@teambit/component';
2
+ import { UIRuntime } from '@teambit/ui';
3
+ import React from 'react';
4
+ import { SlotRegistry, Slot } from '@teambit/harmony';
5
+ import type { FileIconMatch } from '@teambit/code.ui.utils.get-file-icon';
6
+ import { staticStorageUrl } from '@teambit/base-ui.constants.storage';
7
+ import { CodePage } from '@teambit/code.ui.code-tab-page';
8
+ import { CodeAspect } from './code.aspect';
9
+ import { CodeSection } from './code.section';
10
+
11
+ const isTsx = /\.tsx$/;
12
+
13
+ export type FileIconSlot = SlotRegistry<FileIconMatch[]>;
14
+
15
+ /**
16
+ * Component code tab aspect. Presents the code tab page and allows to control the code tab and register specific icons for each file type.
17
+ * @example CodeUI.registerEnvFileIcon([(fileName) => (/your-regexp/.test(fileName) ? 'your.icon.url' : undefined)])
18
+ */
19
+ export class CodeUI {
20
+ constructor(
21
+ /**
22
+ * register an icon for a specific file type. pass icon and a match method/regexp
23
+ */
24
+ private fileIconSlot?: FileIconSlot
25
+ ) {}
26
+ getCodePage = () => {
27
+ return <CodePage fileIconSlot={this.fileIconSlot} />;
28
+ };
29
+ registerEnvFileIcon(icons: FileIconMatch[]) {
30
+ this.fileIconSlot?.register(icons);
31
+ return this;
32
+ }
33
+ static dependencies = [ComponentAspect];
34
+
35
+ static runtime = UIRuntime;
36
+
37
+ static slots = [Slot.withType<string>()];
38
+
39
+ static async provider([component]: [ComponentUI], config, [fileIconSlot]: [FileIconSlot]) {
40
+ const ui = new CodeUI(fileIconSlot);
41
+ const section = new CodeSection(ui);
42
+
43
+ // overrides the default tsx react icon with the typescript icon
44
+ ui.registerEnvFileIcon([
45
+ (fileName) => (isTsx.test(fileName) ? `${staticStorageUrl}/file-icons/file_type_typescript.svg` : undefined),
46
+ ]);
47
+ component.registerRoute(section.route);
48
+ component.registerWidget(section.navigationLink, section.order);
49
+ return ui;
50
+ }
51
+ }
52
+
53
+ CodeAspect.addRuntime(CodeUI);
package/package.json CHANGED
@@ -1,23 +1,23 @@
1
1
  {
2
2
  "name": "@teambit/code",
3
- "version": "0.0.567",
3
+ "version": "0.0.571",
4
4
  "homepage": "https://bit.dev/teambit/component/code",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.component",
8
8
  "name": "code",
9
- "version": "0.0.567"
9
+ "version": "0.0.571"
10
10
  },
11
11
  "dependencies": {
12
12
  "@teambit/harmony": "0.2.11",
13
13
  "@babel/runtime": "7.12.18",
14
14
  "core-js": "^3.0.0",
15
15
  "@teambit/base-ui.constants.storage": "1.0.0",
16
- "@teambit/component": "0.0.567",
17
- "@teambit/ui-foundation.ui.menu-widget-icon": "0.0.472",
18
- "@teambit/code.ui.code-tab-page": "0.0.483",
19
- "@teambit/code.ui.utils.get-file-icon": "0.0.470",
20
- "@teambit/ui": "0.0.567"
16
+ "@teambit/component": "0.0.571",
17
+ "@teambit/ui-foundation.ui.menu-widget-icon": "0.0.474",
18
+ "@teambit/code.ui.code-tab-page": "0.0.485",
19
+ "@teambit/code.ui.utils.get-file-icon": "0.0.472",
20
+ "@teambit/ui": "0.0.571"
21
21
  },
22
22
  "devDependencies": {
23
23
  "@types/react": "^17.0.8",
@@ -28,7 +28,7 @@
28
28
  "@types/node": "12.20.4"
29
29
  },
30
30
  "peerDependencies": {
31
- "@teambit/legacy": "1.0.179",
31
+ "@teambit/legacy": "1.0.181",
32
32
  "react-dom": "^16.8.0 || ^17.0.0",
33
33
  "react": "^16.8.0 || ^17.0.0"
34
34
  },
@@ -56,27 +56,12 @@
56
56
  "react": "-"
57
57
  },
58
58
  "peerDependencies": {
59
- "@teambit/legacy": "1.0.179",
59
+ "@teambit/legacy": "1.0.181",
60
60
  "react-dom": "^16.8.0 || ^17.0.0",
61
61
  "react": "^16.8.0 || ^17.0.0"
62
62
  }
63
63
  }
64
64
  },
65
- "files": [
66
- "dist",
67
- "!dist/tsconfig.tsbuildinfo",
68
- "**/*.md",
69
- "**/*.mdx",
70
- "**/*.js",
71
- "**/*.json",
72
- "**/*.sass",
73
- "**/*.scss",
74
- "**/*.less",
75
- "**/*.css",
76
- "**/*.css",
77
- "**/*.jpeg",
78
- "**/*.gif"
79
- ],
80
65
  "private": false,
81
66
  "engines": {
82
67
  "node": ">=12.22.0"
@@ -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
+ }