Skip to content
This repository has been archived by the owner on Dec 6, 2021. It is now read-only.

Commit

Permalink
Merge pull request #89 from b2nil/dev
Browse files Browse the repository at this point in the history
for release of alpha 19
  • Loading branch information
b2nil authored Mar 20, 2021
2 parents 80a1739 + 0bc85a9 commit 8552cc9
Show file tree
Hide file tree
Showing 50 changed files with 1,960 additions and 1,870 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ tests/components
tests/utils
tests/composables
tests/index.ts*
.yarnrc.yml
.npmrc

2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
- 在本地添加一个 remote 分支: `git remote add upstream https://github.com/b2nil/taro-ui-vue3.git`
- 同步 upstream 分支的代码:`git fetch upstream`
- 进行需要的更改
- PR 提交值本项目的 dev 分支
- PR 提交至本项目的 dev 分支

2 changes: 1 addition & 1 deletion build/esbuild.build.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const path = require('path')
const toastPlugin = {
name: 'toast',
setup(build) {
build.onLoad({ filter: /toast\\index.ts$/ }, async (args) => {
build.onLoad({ filter: /toast.index\.ts$/ }, async (args) => {
const text = await fs.promises.readFile(args.path, "utf8")
const contents = text.replace("img.json", "img.js")
return {
Expand Down
12 changes: 7 additions & 5 deletions config/h5-building-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ import Image from './components/image'
import Icon from './components/icon'
import ScrollView from './components/scroll-view'
const componentMap = {}
function genSimpleComponents(components) {
const componentMap = {}
components.map(component => {
if (typeof component === 'string') {
componentMap[component] = createComponent(component)
Expand All @@ -23,9 +24,10 @@ function genSimpleComponents(components) {
componentMap[name] = createComponent(name, classNames)
}
})
return componentMap
}
genSimpleComponents(simpleComponents)
const componentMap = genSimpleComponents(simpleComponents)
// simple components
export const View = componentMap['taro-view']
Expand Down Expand Up @@ -74,9 +76,9 @@ export const Slider = createFormsComponent('taro-slider', 'change', 'value', ['w
export function initVue3Components(app) {
app.config.isCustomElement = tag => /^taro-/.test(tag) || tag === 'root' || tag === 'block'
simpleComponents.map(component => {
app.component(component, componentMap[component])
})
for (const [name, component] of Object.entries(componentMap)) {
app.component(name, component)
}
app.component('taro-input', Input)
app.component('taro-textarea', Textarea)
Expand Down
41 changes: 20 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@
"build:qq": "taro build --type qq",
"build:jd": "taro build --type jd",
"build:quickapp": "taro build --type quickapp",
"dev:weapp": "taro build --type weapp --watch",
"dev:swan": "npm run build:swan -- --watch",
"dev:alipay": "npm run build:alipay -- --watch",
"dev:tt": "npm run build:tt -- --watch",
"dev:h5": "npm run build:h5 -- --watch",
"dev:rn": "npm run build:rn -- --watch",
"dev:qq": "npm run build:qq -- --watch",
"dev:jd": "npm run build:jd -- --watch",
"dev:quickapp": "npm run build:quickapp -- --watch",
"dev:weapp": "yarn dev && taro build --type weapp --watch",
"dev:swan": "yarn dev && taro build --type swan --watch",
"dev:alipay": "yarn dev && taro build --type alipay --watch",
"dev:tt": "yarn dev && taro build --type tt --watch",
"dev:h5": "yarn dev && node ./config/h5-building-script.js && taro build --type h5 --watch",
"dev:rn": "yarn dev && taro build --type rn --watch",
"dev:qq": "yarn dev && taro build --type qq --watch",
"dev:jd": "yarn dev && taro build --type jd --watch",
"dev:quickapp": "yarn dev && taro build --type quickapp --watch",
"clean": "rimraf .temp dist lib coverage"
},
"browserslist": [
Expand All @@ -80,32 +80,32 @@
"lodash-es": "^4.17.15"
},
"peerDependencies": {
"@tarojs/components": "^3.0.15",
"@tarojs/taro": "^3.0.15",
"vue": "^3.0.0"
"@tarojs/components": "^3.1.4",
"@tarojs/taro": "^3.1.4",
"vue": "^3.0.6"
},
"devDependencies": {
"@babel/core": "^7.8.0",
"@babel/runtime": "^7.7.7",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^9.0.0",
"@tarojs/components": "^3.0.15",
"@tarojs/mini-runner": "^3.0.15",
"@tarojs/runtime": "^3.0.15",
"@tarojs/taro": "^3.0.15",
"@tarojs/webpack-runner": "^3.0.15",
"@tarojs/components": "^3.1.4",
"@tarojs/mini-runner": "^3.1.4",
"@tarojs/runtime": "^3.1.4",
"@tarojs/taro": "^3.1.4",
"@tarojs/webpack-runner": "^3.1.4",
"@types/jest": "^26.0.17",
"@types/lodash-es": "^4.17.3",
"@types/webpack-env": "^1.13.6",
"@typescript-eslint/eslint-plugin": "^2.x",
"@typescript-eslint/parser": "^2.x",
"@vue/babel-plugin-jsx": "^1.0.0-rc.4",
"@vue/compiler-sfc": "^3.0.0",
"@vue/compiler-sfc": "^3.0.6",
"@vue/test-utils": "2.0.0-rc.0",
"babel-preset-taro": "^3.0.5",
"cross-env": "^7.0.2",
"csstype": "^2.6.11",
"esbuild": "^0.8.42",
"esbuild": "^0.9.0",
"eslint": "^6.8.0",
"eslint-config-taro": "^3.0.5",
"eslint-plugin-vue": "^7.0.0-alpha.6",
Expand All @@ -115,7 +115,6 @@
"rimraf": "^3.0.2",
"rollup": "^2.29.0",
"rollup-plugin-copy": "^3.3.0",
"rollup-plugin-esbuild": "^2.6.1",
"rollup-plugin-sass": "^1.2.2",
"rollup-plugin-typescript2": "^0.27.2",
"shelljs": "^0.8.4",
Expand All @@ -124,7 +123,7 @@
"ts-jest": "^26.4.4",
"ts-loader": "^8.0.2",
"typescript": "^3.7.0",
"vue": "^3.0.0",
"vue": "^3.0.6",
"vue-jest": "^5.0.0-alpha.7",
"vue-loader": "^16.1.0",
"webpack-bundle-analyzer": "^4.2.0"
Expand Down
2 changes: 1 addition & 1 deletion src/components/action-sheet/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const AtActionSheet = defineComponent({
return () => (
h(View, mergeProps(attrs, {
class: rootClasses.value,
onTouchMove: handleTouchMove
onTouchmove: handleTouchMove
}), {
default: () => [
h(View, {
Expand Down
23 changes: 15 additions & 8 deletions src/components/button/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,13 @@ const AtButton = defineComponent({
}

function handleGetUserInfo(event) {
warn(
"2021 年 4 月 13 日后发布的新版本小程序,",
"开发者调用 `wx.getUserInfo` 或 `<button open-type=\"getUserInfo\"/>` 将不再弹出弹窗,",
"直接返回匿名的用户个人信息。",
"详情见:https://developers.weixin.qq.com/community/develop/doc/000cacfa20ce88df04cb468bc52801?idescene=6&page=10,",
"请使用 `getUserProfile` 进行适配。"
)
props.onGetUserInfo?.(event)
}

Expand Down Expand Up @@ -168,10 +175,10 @@ const AtButton = defineComponent({
interface miniAppEventHandleProps {
onError?: typeof props.onError
onContact?: typeof props.onContact
onOpenSetting?: typeof props.onOpenSetting
onGetPhoneNumber?: typeof props.onGetPhoneNumber
onGetUserInfo?: typeof props.onGetUserInfo
onGetAuthorize?: typeof props.onGetAuthorize
onOpensetting?: typeof props.onOpenSetting
onGetphonenumber?: typeof props.onGetPhoneNumber
onGetuserinfo?: typeof props.onGetUserInfo
onGetauthorize?: typeof props.onGetAuthorize
onLaunchapp?: typeof props.onLaunchapp
}

Expand All @@ -185,16 +192,16 @@ const AtButton = defineComponent({
wxButtonProps.onContact = handleContact
break
case 'openSetting':
wxButtonProps.onOpenSetting = handleOpenSetting
wxButtonProps.onOpensetting = handleOpenSetting
break
case 'getPhoneNumber':
wxButtonProps.onGetPhoneNumber = handleGetPhoneNumber
wxButtonProps.onGetphonenumber = handleGetPhoneNumber
break
case 'getUserInfo':
wxButtonProps.onGetUserInfo = handleGetUserInfo
wxButtonProps.onGetuserinfo = handleGetUserInfo
break
case 'getAuthorize':
wxButtonProps.onGetAuthorize = handleGetAuthorize
wxButtonProps.onGetauthorize = handleGetAuthorize
break
case 'launchApp':
wxButtonProps.onLaunchapp = handleLaunchapp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ exports[`AtCalendar should render default calendar -- h5 1`] = `
<view class="container-text">27</view>
</view>
<view class="flex__item-extra extra">
<!---->
<view class="extra-marks"><text class="mark">2020-11-27</text></view>
</view>
</view>
<view class="flex__item flex__item--now">
Expand Down Expand Up @@ -323,7 +323,7 @@ exports[`AtCalendar should render default calendar -- h5 1`] = `
<view class="container-text">1</view>
</view>
<view class="flex__item-extra extra">
<!---->
<view class="extra-marks"><text class="mark">2020-12-01</text></view>
</view>
</view>
<view class="flex__item flex__item--next flex__item--blur">
Expand Down Expand Up @@ -383,7 +383,7 @@ exports[`AtCalendar should render default calendar -- h5 1`] = `
<view class="container-text">1</view>
</view>
<view class="flex__item-extra extra">
<!---->
<view class="extra-marks"><text class="mark">2020-12-01</text></view>
</view>
</view>
<view class="flex__item flex__item--now">
Expand Down Expand Up @@ -610,7 +610,7 @@ exports[`AtCalendar should render default calendar -- h5 1`] = `
<!---->
</view>
</view>
<view class="flex__item flex__item--now flex__item--today">
<view class="flex__item flex__item--now">
<view class="flex__item-container">
<view class="container-text">30</view>
</view>
Expand Down
21 changes: 14 additions & 7 deletions src/components/calendar/__tests__/calendar.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@ import { mountFactory } from '@/tests/helper'
import AtCalendar from '../index'
import Taro from '@tarojs/taro'

const today = new Date()
const dString = today.toISOString().substring(0, 7)

describe('AtCalendar', () => {
it('should render default calendar -- h5', () => {
const wrapper = mountFactory(AtCalendar, undefined, { currentDate: '2020-12-27' })
const wrapper = mountFactory(AtCalendar, undefined, {
currentDate: '2020-12-27',
marks: [{ value: "2020-11-27" }, { value: "2020-12-01" }]
})
expect(wrapper.html()).toMatchSnapshot()
expect(wrapper.find('.main > .main__body > .body__slider--pre').exists()).toBeTruthy()
expect(wrapper.find('.main > .main__body > .body__slider--now').exists()).toBeTruthy()
Expand Down Expand Up @@ -81,12 +87,13 @@ describe('AtCalendar', () => {
})

it('should render marks', async () => {
const wrapper = mountFactory(AtCalendar)
expect(wrapper.findAll('.mark').length).toBe(0)

await wrapper.setProps({ marks: [{ value: '2020-12-27' }, { value: '2020-12-28' }] })
today.setDate(today.getDate() - 28)
const prevM = new Date(today).toISOString().substring(0, 10)
const wrapper = mountFactory(AtCalendar, undefined, { marks: [{ value: prevM }] })
expect(wrapper.findAll('.mark').length).toBe(1)
await wrapper.setProps({ marks: [{ value: `${dString}-21` }, { value: prevM }, { value: `${dString}-23` }] })
wrapper.vm.$nextTick()
expect(wrapper.findAll('.mark').length).toBe(2)
expect(wrapper.findAll('.mark').length).toBe(3)
})

it('should render minDate and maxDate', () => {
Expand Down Expand Up @@ -124,7 +131,7 @@ describe('AtCalendar', () => {

it('should render valid dates', () => {
const wrapper = mountFactory(AtCalendar, undefined, {
validDates: [{ value: '2020-12-27' }, { value: '2020-12-28' }]
validDates: [{ value: `${dString}-21` }, { value: `${dString}-25` }]
})

expect(
Expand Down
16 changes: 8 additions & 8 deletions src/components/calendar/body/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,9 @@ const AtCalendarBody = defineComponent({
if (isWeb.value) {
return h(View, {
class: rootClass.value,
onTouchEnd: handleTouchEnd,
onTouchMove: handleTouchMove,
onTouchStart: handleTouchStart
onTouchend: handleTouchEnd,
onTouchmove: handleTouchMove,
onTouchstart: handleTouchStart
}, {
default: () => [
h(AtCalendarDayList),
Expand Down Expand Up @@ -355,8 +355,8 @@ const AtCalendarBody = defineComponent({

// 支付宝 Swiper 组件无 onAnimationFinish 属性,应改为 onAnimationEnd
const animationEndOrFinish = isAlipay.value
? { onAnimationEnd: handleAnimateFinish }
: { onAnimationFinish: handleAnimateFinish }
? { onAnimationend: handleAnimateFinish }
: { onAnimationfinish: handleAnimateFinish }

return h(View, {
class: rootClass.value
Expand All @@ -370,9 +370,9 @@ const AtCalendarBody = defineComponent({
skipHiddenItemLayout: true,
current: currentSwiperIndex.value,
onChange: handleChange,
onTouchMove: handleSwipeTouchMove,
onTouchEnd: handleSwipeTouchEnd,
onTouchStart: handleSwipeTouchStart
onTouchmove: handleSwipeTouchMove,
onTouchend: handleSwipeTouchEnd,
onTouchstart: handleSwipeTouchStart
}), {
default: () => state.listGroup.map((item, key) => (
h(SwiperItem, {
Expand Down
6 changes: 6 additions & 0 deletions src/components/calendar/common/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ function getFullItem(
selectedDate: Calendar.SelectedDate,
isShowStatus?: boolean
) {
if (options.marks.find(x => x.value === item.value)) {
(item.marks as Array<Calendar.Mark>) = [{
value: item.value as string
}]
}

if (!isShowStatus) return item

const bindedPlugins = plugins.map(fn =>
Expand Down
4 changes: 2 additions & 2 deletions src/components/calendar/ui/date-list/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const AtCalendarList = defineComponent({
key: `list-item-${item.value}-${index}`,
class: flexItemClass.value(item),
onTap: handleClick.bind(this, item),
onLongPress: handleLongClick.bind(this, item)
onLongpress: handleLongClick.bind(this, item)
}, {
default: () => [
h(View, {
Expand All @@ -89,7 +89,7 @@ const AtCalendarList = defineComponent({
h(Text, {
key: key,
class: 'mark'
}, { default: () => String(mark) })
}, { default: () => mark.value })
))
})
)
Expand Down
6 changes: 3 additions & 3 deletions src/components/float-layout/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const AtFloatLayout = defineComponent({
return () => (
h(View, mergeProps(attrs, {
class: rootClass.value,
onTouchMove: handleTouchMove
onTouchmove: handleTouchMove
}), {
default: () => [
// overlay
Expand Down Expand Up @@ -113,8 +113,8 @@ const AtFloatLayout = defineComponent({
lowerThreshold: props.lowerThreshold,
scrollWithAnimation: props.scrollWithAnimation,
onScroll: props.onScroll,
onScrollToLower: props.onScrollToLower,
onScrollToUpper: props.onScrollToUpper,
onScrolltolower: props.onScrollToLower,
onScrolltoupper: props.onScrollToUpper,
}, { default: () => slots.default && slots.default() })
]
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

exports[`AtInput should render all nodes and match snapshot 1`] = `
<view
class="at-input at-input--without-border"
class="at-input"
>
<view
class="at-input__container at-input--error"
Expand Down
Loading

0 comments on commit 8552cc9

Please sign in to comment.