Skip to content

Commit

Permalink
Merge branch 'next' into fix/dart-sass
Browse files Browse the repository at this point in the history
# Conflicts:
#	packages/babel-preset-taro/yarn.lock
#	packages/taro-helper/yarn.lock
#	packages/taro-mini-runner/yarn.lock
#	packages/taro-webpack-runner/yarn.lock
  • Loading branch information
Chen-jj committed Apr 25, 2021
2 parents 5560e55 + b83fd4d commit 0e42794
Show file tree
Hide file tree
Showing 42 changed files with 2,781 additions and 2,693 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,16 @@
integrity sha512-np/lG3uARFybkoHokJUmf1QfEvRVCPbmQeUQpKow5cQ3xWrV9i3rUHodKDJPQfTVX61qKi+UdYk8kik84n7XOw==

"@babel/parser@^7.1.0":
version "7.13.13"
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.13.13.tgz#42f03862f4aed50461e543270916b47dd501f0df"
integrity sha512-OhsyMrqygfk5v8HmWwOzlYjJrtLaFhF34MrfG/Z73DgYCI6ojNUTUp2TYbtnjo8PegeJp12eamsNettCQjKjVw==
version "7.13.16"
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.13.16.tgz#0f18179b0448e6939b1f3f5c4c355a3a9bcdfd37"
integrity sha512-6bAg36mCwuqLO0hbR+z7PHuqWiCeP7Dzg73OpQwsAB1Eb8HnGEz5xYBzCfbu+YjoaJsJs+qheDxVAuqbt3ILEw==

"@babel/types@^7.0.0", "@babel/types@^7.3.0":
version "7.13.14"
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.13.14.tgz#c35a4abb15c7cd45a2746d78ab328e362cbace0d"
integrity sha512-A2aa3QTkWoyqsZZFl56MLUsfmh7O0gN41IPvXAE/++8ojpbz12SszD7JEGYVdn4f9Kt4amIei07swF1h4AqmmQ==
version "7.13.17"
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.13.17.tgz#48010a115c9fba7588b4437dd68c9469012b38b4"
integrity sha512-RawydLgxbOPDlTLJNtoIypwdmAy//uQIzlKt2+iBiJaRlVuI6QLUxVAyWGNfOzp8Yu4L4lLIacoCyTNtpb4wiA==
dependencies:
"@babel/helper-validator-identifier" "^7.12.11"
lodash "^4.17.19"
to-fast-properties "^2.0.0"

"@types/babel__core@^7.1.14":
Expand Down Expand Up @@ -59,11 +58,6 @@ camelize@^1.0.0:
resolved "https://registry.yarnpkg.com/camelize/-/camelize-1.0.0.tgz#164a5483e630fa4321e5af07020e531831b2609b"
integrity sha1-FkpUg+Yw+kMh5a8HAg5TGDGyYJs=

lodash@^4.17.19:
version "4.17.21"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==

to-fast-properties@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-2.0.0.tgz#dc5e698cbd079265bc73e0377681a4e4e83f616e"
Expand Down
345 changes: 194 additions & 151 deletions packages/babel-preset-taro/yarn.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/taro-components-rn/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"author": "O2Team",
"license": "MIT",
"dependencies": {
"@ant-design/react-native": "^4.0.5",
"@ant-design/react-native": "4.0.7",
"@react-native-community/picker": "^1.8.1",
"@react-native-community/slider": "4.0.0-rc.1",
"@react-native-community/viewpager": "^4.2.2",
Expand Down
409 changes: 212 additions & 197 deletions packages/taro-components-rn/yarn.lock

Large diffs are not rendered by default.

183 changes: 106 additions & 77 deletions packages/taro-components/h5/react/utils/reactify-wc.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,103 @@ function getClassName (wc, prevProps, props) {
return finalClassNames.join(' ')
}

function updateStyle (dom, key, val) {
if (/^--/.test(key)) {
// css variable
dom.style.setProperty(key, val)
} else {
dom.style[key] = val
}
}

function updateProp (ctx, comp, propKey, prevProps, props) {
const dom = ctx.ref.current
const val = props[propKey]
const prevVal = prevProps ? prevProps[propKey] : undefined

if (propKey === 'children') {
return
}
if (propKey.toLowerCase() === 'classname') {
dom.className = prevProps
? getClassName(dom, prevProps, props)
: val
return
}
if (propKey === 'style') {
if (typeof val === 'string') {
dom.setAttribute(propKey, val)
return
}
if (!val) {
dom.removeAttribute(propKey)
return
}

if (prevProps) {
if (typeof prevVal === 'string') {
dom.style.cssText = ''
} else {
for (const styleKey in prevVal) {
updateStyle(dom, styleKey, '')
}
}
}

for (const styleKey in val) {
updateStyle(dom, styleKey, val[styleKey])
}
return
}
if (comp === SCROLL_VIEW) {
if (propKey === 'scrollTop') {
dom.mpScrollTop = val
return
}
if (propKey === 'scrollLeft') {
dom.mpScrollLeft = val
return
}
if (propKey === 'scrollIntoView') {
dom.mpScrollIntoView = val
return
}
}
if (typeof val === 'function' && propKey.match(/^on[A-Z]/)) {
const event = propKey.substr(2).toLowerCase()
let fn = val

// 解决用户监听 ScrollView 的 onScroll 会监听到原生 onScroll 的问题
if (comp === SCROLL_VIEW && event === 'scroll') {
fn = function (e) {
if (e instanceof CustomEvent) {
val.apply(null, Array.from(arguments))
}
}
}

ctx.eventHandlers.push([event, fn])
return dom.addEventListener(event, fn)
}

if (typeof val === 'string' || typeof val === 'number') {
dom[propKey] = val
return
}
if (typeof val === 'boolean') {
if (val) {
dom[propKey] = true
return dom.setAttribute(
propKey,
val
)
}
dom[propKey] = false
return dom.removeAttribute(propKey)
}
dom[propKey] = val
}

const reactifyWebComponent = WC => {
class Index extends React.Component {
constructor (props) {
Expand All @@ -40,84 +137,16 @@ const reactifyWebComponent = WC => {

update (prevProps) {
this.clearEventHandlers()
Object.entries(this.props).forEach(([prop, val]) => {
if (!this.ref.current) return
if (prop === 'children') {
return
}
if (prop.toLowerCase() === 'classname') {
this.ref.current.className = prevProps
? getClassName(this.ref.current, prevProps, this.props)
: val
return
}
if (prop === 'style') {
if (typeof val === 'string') {
return this.ref.current.setAttribute(prop, val)
} else if (val && typeof val === 'object') {
for (const key in val) {
if (/^--/.test(key)) {
// css variable
this.ref.current.style.setProperty(key, val[key])
} else {
this.ref.current.style[key] = val[key]
}
}
return
}
return
}
if (WC === SCROLL_VIEW) {
if (prop === 'scrollTop') {
this.ref.current.mpScrollTop = val
return
}
if (prop === 'scrollLeft') {
this.ref.current.mpScrollLeft = val
return
}
if (prop === 'scrollIntoView') {
this.ref.current.mpScrollIntoView = val
return
}
}
if (typeof val === 'function' && prop.match(/^on[A-Z]/)) {
const event = prop.substr(2).toLowerCase()
let fn = val

// 解决用户监听 ScrollView 的 onScroll 会监听到原生 onScroll 的问题
if (WC === SCROLL_VIEW && event === 'scroll') {
fn = function (e) {
if (e instanceof CustomEvent) {
val.apply(null, Array.from(arguments))
}
}
}

this.eventHandlers.push([event, fn])
return this.ref.current.addEventListener(event, fn)
}
// if (typeof val === 'function' && prop.match(/^on-[a-z]/)) {
// const event = prop.substr(3)
// this.eventHandlers.push([event, val])
// return this.ref.current.addEventListener(event, val)
// }
if (typeof val === 'string' || typeof val === 'number') {
this.ref.current[prop] = val
return
}
if (typeof val === 'boolean') {
if (val) {
this.ref.current[prop] = true
return this.ref.current.setAttribute(
prop,
val
)
}
this.ref.current[prop] = false
return this.ref.current.removeAttribute(prop)
if (!this.ref.current) return

Object.keys(prevProps || {}).forEach((key) => {
if (key !== 'children' && key !== 'key' && !(key in this.props)) {
updateProp(this, WC, key, prevProps, this.props)
}
this.ref.current[prop] = val
})

Object.keys(this.props).forEach((key) => {
updateProp(this, WC, key, prevProps, this.props)
})
}

Expand Down
11 changes: 11 additions & 0 deletions packages/taro-components/types/CoverView.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@ interface CoverViewProps extends ViewProps {
* @supported weapp
*/
scrollTop?: number

/**
* 适用于地图组件 map 的自定义气泡 customCallout
* @supported weapp
*/
markerId?: string

/**
* @supported weapp
*/
slot?: string
}

/** 覆盖在原生组件之上的文本视图。可覆盖的原生组件包括 map、video、canvas、camera、live-player、live-pusher 只支持嵌套 cover-view、cover-image,可在 cover-view 中使用 button。
Expand Down
Loading

0 comments on commit 0e42794

Please sign in to comment.