initial commit

This commit is contained in:
jackycheng
2024-11-05 18:43:21 +08:00
commit 86fab50b14
16 changed files with 236 additions and 0 deletions

2
README.md Normal file
View File

@@ -0,0 +1,2 @@
# {{ ComponentName }}

38
package.json Normal file
View File

@@ -0,0 +1,38 @@
{
"name": "{{ ComponentName }}",
"version": "0.0.1",
"private": true,
"dependencies": {
"react": "^18",
"react-dom": "^18",
"{{ UIPackageName }}": "{{ UIVersion }}"
},
"devDependencies": {
"@types/node": "^16",
"@types/react": "^18",
"@types/react-dom": "^18",
"react-scripts": "5.0.1",
"typescript": "^4.9.5"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build"
},
"eslintConfig": {
"extends": [
"react-app"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}

BIN
public/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

43
public/index.html Normal file
View File

@@ -0,0 +1,43 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>

BIN
public/logo192.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

BIN
public/logo512.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

25
public/manifest.json Normal file
View File

@@ -0,0 +1,25 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "logo192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}

3
public/robots.txt Normal file
View File

@@ -0,0 +1,3 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:

3
src/App.css Normal file
View File

@@ -0,0 +1,3 @@
.App {
padding: 16px;
}

27
src/App.tsx Normal file
View File

@@ -0,0 +1,27 @@
import React from 'react';
import Component, { renderFieldProps } from './lib';
import './App.css';
import { ConfigProvider, Form } from '{{ UIPackageName }}';
const valueType = Component.displayName.charAt(0).toLowerCase() + Component.displayName.slice(1)
const App: React.FC = () => {
return (
<div className="App">
<ConfigProvider
valueTypeMap={{
[valueType]: renderFieldProps,
}}
>
<Form initialValues={{ test_valuetype: 'aaa', test_comp: 'bbb' }}>
<Form.Item label="ValueType" name="test_valuetype" valueType={valueType} />
<Form.Item label="Children" name="test_comp">
<Component />
</Form.Item>
</Form>
</ConfigProvider>
</div>
);
}
export default App;

13
src/index.css Normal file
View File

@@ -0,0 +1,13 @@
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
monospace;
}

13
src/index.tsx Normal file
View File

@@ -0,0 +1,13 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
import App from './App';
import './index.css';
const root = ReactDOM.createRoot(
document.getElementById('root') as HTMLElement
);
root.render(
<React.StrictMode>
<App />
</React.StrictMode>
);

0
src/lib/index.css Normal file
View File

42
src/lib/index.tsx Normal file
View File

@@ -0,0 +1,42 @@
import React, { useImperativeHandle } from 'react';
import { RenderFieldPropsType } from '{{ UIPackageName }}';
import './index.css';
/**
* props定义
*/
type {{ ComponentName }}Props = {
defaultValue?: {{ ValueType }};
value?: {{ ValueType }};
onChange?: (value?: {{ ValueType }}) => void;
};
/**
* ref对象定义
*/
type {{ ComponentName }}Ref = {
};
/**
* 组件定义
*/
const {{ ComponentName }} = React.forwardRef<{{ ComponentName }}Ref, {{ ComponentName }}Props>((props, ref) => {
const { value, defaultValue } = props;
useImperativeHandle(ref, () => {
return {
/* 请填写ref方法 */
};
});
return <>{JSON.stringify(value || defaultValue || '')}</>;
});
{{ ComponentName }}.displayName = '{{ ComponentName }}';
export const renderFieldProps: RenderFieldPropsType = {
render: (value) => <>{JSON.stringify(value || '')}</>,
renderFormItem: (_, props) => <{{ ComponentName }} {...props.fieldProps} />,
};
export default {{ ComponentName }};

1
src/react-app-env.d.ts vendored Normal file
View File

@@ -0,0 +1 @@
/// <reference types="react-scripts" />

26
tsconfig.json Normal file
View File

@@ -0,0 +1,26 @@
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx"
},
"include": [
"src"
]
}