commit 86fab50b14430e31845d2c83c64c0dd12c51c7ee Author: jackycheng <> Date: Tue Nov 5 18:43:21 2024 +0800 initial commit diff --git a/README.md b/README.md new file mode 100644 index 0000000..c761440 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# {{ ComponentName }} + diff --git a/package.json b/package.json new file mode 100644 index 0000000..eaed22a --- /dev/null +++ b/package.json @@ -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" + ] + } +} diff --git a/public/favicon.ico b/public/favicon.ico new file mode 100644 index 0000000..a11777c Binary files /dev/null and b/public/favicon.ico differ diff --git a/public/index.html b/public/index.html new file mode 100644 index 0000000..aa069f2 --- /dev/null +++ b/public/index.html @@ -0,0 +1,43 @@ + + + + + + + + + + + + + React App + + + +
+ + + diff --git a/public/logo192.png b/public/logo192.png new file mode 100644 index 0000000..fc44b0a Binary files /dev/null and b/public/logo192.png differ diff --git a/public/logo512.png b/public/logo512.png new file mode 100644 index 0000000..a4e47a6 Binary files /dev/null and b/public/logo512.png differ diff --git a/public/manifest.json b/public/manifest.json new file mode 100644 index 0000000..080d6c7 --- /dev/null +++ b/public/manifest.json @@ -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" +} diff --git a/public/robots.txt b/public/robots.txt new file mode 100644 index 0000000..e9e57dc --- /dev/null +++ b/public/robots.txt @@ -0,0 +1,3 @@ +# https://www.robotstxt.org/robotstxt.html +User-agent: * +Disallow: diff --git a/src/App.css b/src/App.css new file mode 100644 index 0000000..391149e --- /dev/null +++ b/src/App.css @@ -0,0 +1,3 @@ +.App { + padding: 16px; +} diff --git a/src/App.tsx b/src/App.tsx new file mode 100644 index 0000000..9956040 --- /dev/null +++ b/src/App.tsx @@ -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 ( +
+ +
+ + + + + +
+
+ ); +} + +export default App; diff --git a/src/index.css b/src/index.css new file mode 100644 index 0000000..ec2585e --- /dev/null +++ b/src/index.css @@ -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; +} diff --git a/src/index.tsx b/src/index.tsx new file mode 100644 index 0000000..7ffc198 --- /dev/null +++ b/src/index.tsx @@ -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( + + + +); diff --git a/src/lib/index.css b/src/lib/index.css new file mode 100644 index 0000000..e69de29 diff --git a/src/lib/index.tsx b/src/lib/index.tsx new file mode 100644 index 0000000..6f92975 --- /dev/null +++ b/src/lib/index.tsx @@ -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 }}; \ No newline at end of file diff --git a/src/react-app-env.d.ts b/src/react-app-env.d.ts new file mode 100644 index 0000000..6431bc5 --- /dev/null +++ b/src/react-app-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..a273b0c --- /dev/null +++ b/tsconfig.json @@ -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" + ] +}