-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
219 changed files
with
13,794 additions
and
785 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
packages/taro-platform-harmony-hybrid/src/components/components-library-react/.babelrc.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"presets": [ | ||
[ | ||
"taro", | ||
{ | ||
"absoluteRuntime": false, | ||
"framework": "react", | ||
"hot": false, | ||
"modules": false, | ||
"ts": true | ||
} | ||
] | ||
] | ||
} |
2 changes: 2 additions & 0 deletions
2
packages/taro-platform-harmony-hybrid/src/components/components-library-react/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Stencil autogenerated | ||
src/components.ts |
38 changes: 38 additions & 0 deletions
38
packages/taro-platform-harmony-hybrid/src/components/components-library-react/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"name": "@tarojs/harmony-components-library-react", | ||
"version": "3.6.23", | ||
"description": "Taro 组件库 React 版本库", | ||
"private": true, | ||
"main": "index.js", | ||
"scripts": { | ||
"build:ci": "run-s clean prod", | ||
"clean": "rimraf ../harmony-components/lib/react", | ||
"dev": "pnpm run prod -w", | ||
"preprod": "node ./scripts/fix.js", | ||
"prod": "rollup -c" | ||
}, | ||
"keywords": [], | ||
"author": "ZakaryCode", | ||
"license": "MIT", | ||
"dependencies": { | ||
"@tarojs/harmony-components": "workspace:*", | ||
"react-dom": "^18.2.0", | ||
"tslib": "^2.6.2" | ||
}, | ||
"devDependencies": { | ||
"@babel/cli": "^7.14.5", | ||
"@babel/core": "^7.14.5", | ||
"@rollup/plugin-commonjs": "^20.0.0", | ||
"@rollup/plugin-node-resolve": "^8.0.0", | ||
"@types/node": "^14.14.31", | ||
"babel-preset-taro": "workspace:*", | ||
"postcss": "^8.4.18", | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0", | ||
"rollup": "^2.79.0", | ||
"rollup-plugin-node-externals": "^5.0.0", | ||
"rollup-plugin-postcss": "^4.0.2", | ||
"rollup-plugin-ts": "^3.0.2", | ||
"typescript": "^4.7.4" | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
...ges/taro-platform-harmony-hybrid/src/components/components-library-react/rollup.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import commonjs from '@rollup/plugin-commonjs' | ||
import resolve from '@rollup/plugin-node-resolve' | ||
import externals from 'rollup-plugin-node-externals' | ||
import postcss from 'rollup-plugin-postcss' | ||
import ts from 'rollup-plugin-ts' | ||
|
||
const config = { | ||
input: ['src/index.ts', 'src/component-lib/index.ts'], | ||
output: { | ||
dir: '../harmony-components/lib/react', | ||
exports: 'named', | ||
preserveModules: true, | ||
preserveModulesRoot: 'src', | ||
sourcemap: true | ||
}, | ||
treeshake: false, | ||
plugins: [ | ||
externals({ | ||
deps: true, | ||
devDeps: false, | ||
include: ['react', 'react-dom'] | ||
}), | ||
resolve({ | ||
preferBuiltins: false, | ||
mainFields: ['main:h5', 'browser', 'module', 'jsnext:main', 'main'] | ||
}), | ||
ts({ | ||
sourceMap: true, | ||
}), | ||
commonjs({ | ||
transformMixedEsModules: true, | ||
dynamicRequireTargets: ['./src/**/*.js'] | ||
}), | ||
postcss({ | ||
inject: { insertAt: 'top' }, | ||
minimize: true, | ||
}), | ||
] | ||
} | ||
|
||
export default config |
39 changes: 39 additions & 0 deletions
39
packages/taro-platform-harmony-hybrid/src/components/components-library-react/scripts/fix.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
const fs = require('@tarojs/helper').fs | ||
const path = require('path') | ||
|
||
const componentsPath = path.resolve(__dirname, '..', 'src/components.ts') | ||
// const avoidErrorType = ['Input', 'ScrollView'] | ||
|
||
if (fs.existsSync(componentsPath)) { | ||
const codeBuffer = fs.readFileSync(componentsPath) | ||
let code = codeBuffer.toString().replace(/import\stype\s\{\s([^}]*)\s\}\sfrom\s'@tarojs\/harmony-components[^']*';/ig, `import type { $1 } from '@tarojs/harmony-components/dist/types/components';`) | ||
code = code.replace(/const\sTaro([A-Za-z]+)\s=/g, 'const $1 =').replace(/const\s([A-Za-z]+)Core\s=/g, 'const $1 =') | ||
|
||
// NOTE: HTMLStencilElement 与 HTMLTaroInputCoreElement 在 force 参数上冲突 | ||
// const avoidType = avoidErrorType.join('|') | ||
// code = code.replace( | ||
// new RegExp(`createReactComponent<JSX.Taro(${avoidType})Core, HTMLTaro(${avoidType})CoreElement>`, 'ig'), | ||
// 'createReactComponent<JSX.Taro$1Core, any>' | ||
// ) | ||
|
||
if (code.includes('defineCustomElement as define')) { | ||
code = code.replace(/import\s\{\sdefineCustomElement\sas\sdefine([A-Za-z]+)\s.*/g, '// @ts-ignore\nimport { defineCustomElement$1 as define$1 } from \'@tarojs/harmony-components/dist/components\';') | ||
} | ||
|
||
/** | ||
* 当前不支持配置通用的 manipulatePropsFunction 方法,因此需要手动添加 | ||
* https://github.com/ionic-team/stencil-ds-output-targets/issues/243 | ||
*/ | ||
if (!code.includes('./helper')) { | ||
code = code.replace('/* auto-generated react proxies */', `/* auto-generated react proxies */\nimport { manipulatePropsFunction } from './helper'`) | ||
code = code.replace(/\(([^,)]+)[^;]*,\s([^,]+)\);/ig, '($1, undefined, manipulatePropsFunction, $2);') | ||
} | ||
|
||
if (!code.includes('Fragment')) { | ||
const comps = ['Block'] | ||
code = code.replace('/* auto-generated react proxies */', `/* auto-generated react proxies */\nimport { Fragment } from 'react'`) | ||
code = code.replace(new RegExp(`export const (${comps.join('|')}) = \\/\\*\\@__PURE__\\*\\/createReactComponent.*`, 'ig'), 'export const $1 = Fragment;') | ||
} | ||
|
||
fs.writeFileSync(componentsPath, code) | ||
} |
75 changes: 75 additions & 0 deletions
75
...latform-harmony-hybrid/src/components/components-library-react/src/component-lib/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import { Fragment } from 'react' | ||
|
||
import reactifyWc from './reactify-wc' | ||
|
||
// 视图容器 | ||
export const CoverImage = /* @__PURE__ */ reactifyWc('taro-cover-image-core') | ||
export const CoverView = /* @__PURE__ */ reactifyWc('taro-cover-view-core') | ||
export const MatchMedia = /* @__PURE__ */ reactifyWc('taro-match-media-core') | ||
export const MovableArea = /* @__PURE__ */ reactifyWc('taro-movable-area-core') | ||
export const MovableView = /* @__PURE__ */ reactifyWc('taro-movable-view-core') | ||
export const PageContainer = /* @__PURE__ */ reactifyWc('taro-page-container-core') | ||
export const RootPortal = /* @__PURE__ */ reactifyWc('taro-root-portal-core') | ||
export const ScrollView = /* @__PURE__ */ reactifyWc('taro-scroll-view-core') | ||
export const ShareElement = /* @__PURE__ */ reactifyWc('taro-share-element-core') | ||
export const Swiper = /* @__PURE__ */ reactifyWc('taro-swiper-core') | ||
export const SwiperItem = /* @__PURE__ */ reactifyWc('taro-swiper-item-core') | ||
export const View = /* @__PURE__ */ reactifyWc('taro-view-core') | ||
|
||
// 基础内容 | ||
export const Icon = /* @__PURE__ */ reactifyWc('taro-icon-core') | ||
export const Progress = /* @__PURE__ */ reactifyWc('taro-progress-core') | ||
export const RichText = /* @__PURE__ */ reactifyWc('taro-rich-text-core') | ||
export const Text = /* @__PURE__ */ reactifyWc('taro-text-core') | ||
|
||
// 表单组件 | ||
export const Button = /* @__PURE__ */ reactifyWc('taro-button-core') | ||
export const Checkbox = /* @__PURE__ */ reactifyWc('taro-checkbox-core') | ||
export const CheckboxGroup = /* @__PURE__ */ reactifyWc('taro-checkbox-group-core') | ||
export const Editor = /* @__PURE__ */ reactifyWc('taro-editor-core') | ||
export const Form = /* @__PURE__ */ reactifyWc('taro-form-core') | ||
export { default as Input } from './input' | ||
export const KeyboardAccessory = /* @__PURE__ */ reactifyWc('taro-keyboard-accessory-core') | ||
export const Label = /* @__PURE__ */ reactifyWc('taro-label-core') | ||
export const Picker = /* @__PURE__ */ reactifyWc('taro-picker-core') | ||
export const PickerView = /* @__PURE__ */ reactifyWc('taro-picker-view-core') | ||
export const PickerViewColumn = /* @__PURE__ */ reactifyWc('taro-picker-view-column-core') | ||
export const Radio = /* @__PURE__ */ reactifyWc('taro-radio-core') | ||
export const RadioGroup = /* @__PURE__ */ reactifyWc('taro-radio-group-core') | ||
export const Slider = /* @__PURE__ */ reactifyWc('taro-slider-core') | ||
export const Switch = /* @__PURE__ */ reactifyWc('taro-switch-core') | ||
export const Textarea = /* @__PURE__ */ reactifyWc('taro-textarea-core') | ||
|
||
// 导航 | ||
export const FunctionalPageNavigator = /* @__PURE__ */ reactifyWc('taro-functional-page-navigator-core') | ||
export const Navigator = /* @__PURE__ */ reactifyWc('taro-navigator-core') | ||
export const NavigationBar = /* @__PURE__ */ reactifyWc('taro-navigation-bar-core') | ||
|
||
// 媒体组件 | ||
export const Audio = /* @__PURE__ */ reactifyWc('taro-audio-core') | ||
export const Camera = /* @__PURE__ */ reactifyWc('taro-camera-core') | ||
export const Image = /* @__PURE__ */ reactifyWc('taro-image-core') | ||
export const LivePlayer = /* @__PURE__ */ reactifyWc('taro-live-player-core') | ||
export const LivePusher = /* @__PURE__ */ reactifyWc('taro-live-pusher-core') | ||
export const Video = /* @__PURE__ */ reactifyWc('taro-video-core') | ||
export const VoipRoom = /* @__PURE__ */ reactifyWc('taro-voip-room-core') | ||
|
||
// 地图 | ||
export const Map = /* @__PURE__ */ reactifyWc('taro-map-core') | ||
|
||
// 画布 | ||
export const Canvas = /* @__PURE__ */ reactifyWc('taro-canvas-core') | ||
|
||
// 开放能力 | ||
export const Ad = /* @__PURE__ */ reactifyWc('taro-ad-core') | ||
export const AdCustom = /* @__PURE__ */ reactifyWc('taro-ad-custom-core') | ||
export const OfficialAccount = /* @__PURE__ */ reactifyWc('taro-official-account-core') | ||
export const OpenData = /* @__PURE__ */ reactifyWc('taro-open-data-core') | ||
export const WebView = /* @__PURE__ */ reactifyWc('taro-web-view-core') | ||
|
||
// 页面属性配置节点 | ||
export const PageMeta = /* @__PURE__ */ reactifyWc('taro-page-meta-core') | ||
|
||
// 其他 | ||
export const Block = Fragment | ||
export const CustomWrapper = /* @__PURE__ */ reactifyWc('taro-custom-wrapper-core') |
21 changes: 21 additions & 0 deletions
21
...latform-harmony-hybrid/src/components/components-library-react/src/component-lib/input.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import React from 'react' | ||
|
||
import reactifyWc from './reactify-wc' | ||
|
||
const Input = reactifyWc('taro-input-core') | ||
|
||
const h = React.createElement | ||
|
||
// eslint-disable-next-line react/display-name | ||
export default React.forwardRef((props, ref) => { | ||
const args: Record<string, unknown> = { ...props } | ||
|
||
if (args.hasOwnProperty('focus')) { | ||
args.autoFocus = Boolean(args.focus) | ||
delete args.focus | ||
} | ||
|
||
return ( | ||
h(Input, { ...args, ref }) | ||
) | ||
}) |
Oops, something went wrong.