Skip to content

Commit 0b38d74

Browse files
committed
refactor: use index.tsx for native, index.web.tsx for web entry
1 parent d45279d commit 0b38d74

File tree

9 files changed

+28
-18
lines changed

9 files changed

+28
-18
lines changed

apps/example-web/src/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ function App() {
55
return (
66
<div className="container">
77
<div>Text input</div>
8-
<EnrichedTextInput />
8+
<EnrichedTextInput defaultValue="Type something" />
99
</div>
1010
);
1111
}

apps/example-web/tsconfig.app.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"types": ["vite/client"],
66
"baseUrl": ".",
77
"paths": {
8-
"react-native-enriched": ["../../src/index.tsx"]
8+
"react-native-enriched": ["../../src/index.web"]
99
}
1010
},
1111
"include": ["src"]

apps/example-web/vite.config.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ export default defineConfig({
77
plugins: [react()],
88
resolve: {
99
alias: {
10-
'react-native-enriched': path.resolve(__dirname, '../../src/index.tsx'),
10+
'react-native-enriched': path.resolve(
11+
__dirname,
12+
'../../src/index.web.tsx'
13+
),
1114
},
1215
},
1316
});

package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22
"name": "react-native-enriched",
33
"version": "0.5.2",
44
"description": "Rich Text Editor component for React Native",
5-
"source": "./src/index.native.tsx",
5+
"source": "./src/index.tsx",
66
"main": "./lib/module/index.js",
77
"types": "./lib/typescript/src/index.d.ts",
88
"exports": {
99
".": {
1010
"types": "./lib/typescript/src/index.d.ts",
11+
"source": "./src/index.tsx",
12+
"react-native": "./lib/module/index.js",
1113
"default": "./lib/module/index.js"
1214
},
1315
"./package.json": "./package.json"
@@ -27,7 +29,9 @@
2729
"!android/gradlew.bat",
2830
"!android/local.properties",
2931
"!src/web",
30-
"!src/index.tsx",
32+
"!src/index.web.tsx",
33+
"!lib/module/web",
34+
"!lib/typescript/src/web",
3135
"!**/__tests__",
3236
"!**/__fixtures__",
3337
"!**/__mocks__",

src/index.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
export { EnrichedTextInput } from './web/EnrichedTextInput';
2-
export type { EnrichedTextInputWebProps as EnrichedTextInputProps } from './web/EnrichedTextInput';
1+
export { EnrichedTextInput } from './native/EnrichedTextInput';
2+
export type {
3+
FocusEvent,
4+
BlurEvent,
5+
EnrichedTextInputInstance,
6+
EnrichedTextInputProps,
7+
} from './componentTypes';
38
export type {
49
OnChangeTextEvent,
510
OnChangeHtmlEvent,
Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
1-
export { EnrichedTextInput } from './native/EnrichedTextInput';
2-
export type {
3-
FocusEvent,
4-
BlurEvent,
5-
EnrichedTextInputInstance,
6-
EnrichedTextInputProps,
7-
} from './componentTypes';
1+
export { EnrichedTextInput } from './web/EnrichedTextInput';
2+
export type { EnrichedTextInputWebProps as EnrichedTextInputProps } from './web/EnrichedTextInput';
83
export type {
94
OnChangeTextEvent,
105
OnChangeHtmlEvent,

src/web/EnrichedTextInput.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ export interface EnrichedTextInputWebProps {
4242
const noop = () => {};
4343
const noopPromise = () => Promise.resolve('');
4444

45-
export const EnrichedTextInput = ({ ref }: EnrichedTextInputWebProps) => {
45+
export const EnrichedTextInput = ({
46+
ref,
47+
defaultValue,
48+
}: EnrichedTextInputWebProps) => {
4649
useImperativeHandle(ref, () => ({
4750
focus: noop,
4851
blur: noop,
@@ -72,5 +75,5 @@ export const EnrichedTextInput = ({ ref }: EnrichedTextInputWebProps) => {
7275
setMention: noop,
7376
}));
7477

75-
return <div data-testid="enriched-text-input-web" />;
78+
return <textarea defaultValue={defaultValue} />;
7679
};

tsconfig.build.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"extends": "./tsconfig",
3-
"exclude": ["apps", "lib", "cpp/build", "src/web"]
3+
"exclude": ["apps", "lib", "cpp/build", "src/web", "src/index.web.tsx"]
44
}

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"compilerOptions": {
44
"rootDir": ".",
55
"paths": {
6-
"react-native-enriched": ["./src/index.native"]
6+
"react-native-enriched": ["./src/index"]
77
}
88
}
99
}

0 commit comments

Comments
 (0)