From 2c6904cb5287ad848732694bbc4ba470aeefc4e1 Mon Sep 17 00:00:00 2001 From: zoney Date: Wed, 10 Mar 2021 11:13:43 +0800 Subject: [PATCH 01/23] =?UTF-8?q?enhance(image-picker):=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E4=B8=8A=E4=BC=A0=E7=8A=B6=E6=80=81=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E4=BB=A5=E5=8F=8Ademo=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/image-picker/index.ts | 61 ++++++++++++++++++++------ src/pages/form/image-picker/index.ts | 36 ++++++++++++++- src/style/components/image-picker.scss | 56 ++++++++++++++++++++++- types/image-picker.d.ts | 15 +++++++ 4 files changed, 152 insertions(+), 16 deletions(-) diff --git a/src/components/image-picker/index.ts b/src/components/image-picker/index.ts index ce13579c..3e3b4fe4 100644 --- a/src/components/image-picker/index.ts +++ b/src/components/image-picker/index.ts @@ -5,6 +5,7 @@ import { uuid } from '../../utils/common' import { Image, View } from '@tarojs/components' import { AtImagePickerProps, File } from 'types/image-picker' +import AtLoading from '../loading/index' interface MatrixFile extends Partial { type: 'blank' | 'btn' @@ -146,6 +147,32 @@ const AtImagePicker = defineComponent({ props.onChange(newFiles, 'remove', idx) } + function renderUploadStatus(item: MatrixFile) { + return h(View, { + class: `at-image-picker__upload-status`, + }, { + default: () => { + const r = [ + item.status === 'uploading' + ? h(AtLoading, { + color: '#fff' + }) + : h(View, { + class: 'at-image-picker__upload-status--failed' + }) + ] + if (item.message) { + r.push( + h(View, { + class: 'at-image-picker__status-message' + }, { default: () => item.message }) + ) + } + return r + } + }) + } + return () => ( h(View, mergeProps(attrs, { class: 'at-image-picker' @@ -168,19 +195,27 @@ const AtImagePicker = defineComponent({ h(View, { class: 'at-image-picker__item' }, { - default: () => [ - h(View, { - class: 'at-image-picker__remove-btn', - onTap: handleRemoveImg.bind(this, i * props.length! + j) - }), - - h(Image, { - class: 'at-image-picker__preview-img', - mode: props.mode, - src: item.url, - onTap: handleImageClick.bind(this, i * props.length! + j) - }) - ] + default: () => { + const r = [ + h(View, { + class: 'at-image-picker__remove-btn', + onTap: handleRemoveImg.bind(this, i * props.length! + j) + }), + + h(Image, { + class: 'at-image-picker__preview-img', + mode: props.mode, + src: item.url, + onTap: handleImageClick.bind(this, i * props.length! + j) + }), + ] + if (item.status && item.status !== 'done') { + r.push( + renderUploadStatus(item) + ) + } + return r + } }) ) : item.type === 'btn' && ( // add bar diff --git a/src/pages/form/image-picker/index.ts b/src/pages/form/image-picker/index.ts index 584ddcac..0abfd557 100644 --- a/src/pages/form/image-picker/index.ts +++ b/src/pages/form/image-picker/index.ts @@ -6,11 +6,13 @@ import './index.scss' type DogaImage = { url: string + status?: 'uploading' | 'failed' | 'done' + message?: string } const dogaImages: DogaImage[] = [ { - url: 'https://storage.360buyimg.com/mtd/home/111543234387022.jpg' + url: 'https://storage.360buyimg.com/mtd/home/111543234387022.jpg', }, { url: 'https://storage.360buyimg.com/mtd/home/221543234387016.jpg' @@ -37,7 +39,21 @@ export default defineComponent({ url: 'https://storage.360buyimg.com/mtd/home/36549825_887087111478302_5745542532574478336_n1543234831971.jpg' } - ]) + ]), + files5: [ + { + url: + 'https://storage.360buyimg.com/mtd/home/111543234387022.jpg', + status: 'uploading', + message: '上传中' + }, + { + url: + 'https://storage.360buyimg.com/mtd/home/221543234387016.jpg', + status: 'failed', + message: '上传失败' + } + ] }) function onChange(stateName: string, files: DogaImage[]): void { @@ -125,6 +141,22 @@ export default defineComponent({ }), ] }), + + /* 上传状态*/ + h(Panel, { title: '上传状态', noPadding: true }, { + default: () => [ + h(ExampleItem, null, { + default: () => [ + h(AtImagePicker, { + mode: 'aspectFit', + multiple: true, + files: state.files5, + onChange: onChange.bind(this, 'files5'), + }) + ] + }), + ] + }), ] }) ) diff --git a/src/style/components/image-picker.scss b/src/style/components/image-picker.scss index 1ddeb09e..fd0034dc 100644 --- a/src/style/components/image-picker.scss +++ b/src/style/components/image-picker.scss @@ -116,4 +116,58 @@ width: 100%; height: 100%; } -} + + &__upload-status { + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + font-weight: 300; + color: #fff; + @include overlay; + + + &--failed { + height: $at-loading-size; + width: $at-loading-size; + position: relative; + + &::before, + &::after { + content: ''; + position: absolute; + left: 50%; + top: 50%; + transform: translate(-50%, -50%); + } + + &::before { + width: 100%; + border-top: 1PX solid; + transform: translate(-50%, -50%) rotate(45deg); + } + + &::after { + width: 100%; + height:100%; + border: 1PX solid; + border-radius: 50%; + } + } + + } + + &__status-message { + margin-top: 20px; + } + + @keyframes spin { + 0% { + transform: rotate(0deg); + } + + 100% { + transform: rotate(360deg); + } + } +} \ No newline at end of file diff --git a/types/image-picker.d.ts b/types/image-picker.d.ts index 9d15598c..399e77a1 100644 --- a/types/image-picker.d.ts +++ b/types/image-picker.d.ts @@ -12,6 +12,21 @@ export interface File { url: string file?: FileItem + + /** + * 图片上传的状态 + * - `uploading`: 正在上传 + * - `failed`: 上传失败 + * - `done`: 上传成功 + * @default "done" + * @since v2.0.2 how to get version?? + */ + status?: "uploading" | "failed" | "done" + /** + * 图片上传的状态文案 + * @since v2.0.2 how to get version?? + */ + message?: string } export interface AtImagePickerProps extends AtComponent { From 370b17155271da54e16ea48bb85121470a084684 Mon Sep 17 00:00:00 2001 From: zoney Date: Wed, 10 Mar 2021 11:57:22 +0800 Subject: [PATCH 02/23] remove useless css --- src/style/components/image-picker.scss | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/style/components/image-picker.scss b/src/style/components/image-picker.scss index fd0034dc..12ecf3f1 100644 --- a/src/style/components/image-picker.scss +++ b/src/style/components/image-picker.scss @@ -160,14 +160,4 @@ &__status-message { margin-top: 20px; } - - @keyframes spin { - 0% { - transform: rotate(0deg); - } - - 100% { - transform: rotate(360deg); - } - } } \ No newline at end of file From e8e2a1a6c2a36fadd51e942aab245e53ad69ca6f Mon Sep 17 00:00:00 2001 From: "zoney.zhou" Date: Wed, 10 Mar 2021 16:00:10 +0800 Subject: [PATCH 03/23] Update image-picker.d.ts modify @since version --- types/image-picker.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/image-picker.d.ts b/types/image-picker.d.ts index 399e77a1..533c2755 100644 --- a/types/image-picker.d.ts +++ b/types/image-picker.d.ts @@ -19,12 +19,12 @@ export interface File { * - `failed`: 上传失败 * - `done`: 上传成功 * @default "done" - * @since v2.0.2 how to get version?? + * @since v1.0.0-alpha18 */ status?: "uploading" | "failed" | "done" /** * 图片上传的状态文案 - * @since v2.0.2 how to get version?? + * @since 1.0.0-alpha18 */ message?: string } From aabd96cca845dbc9726e3cf792d1c1b5fb327440 Mon Sep 17 00:00:00 2001 From: zoney Date: Tue, 16 Mar 2021 22:12:22 +0800 Subject: [PATCH 04/23] =?UTF-8?q?feat(image-picker):=E5=A2=9E=E5=8A=A0#86?= =?UTF-8?q?=E5=AF=B9=E5=BA=94=E6=B5=8B=E8=AF=95,files=E6=94=B9=E6=88=90?= =?UTF-8?q?=E5=93=8D=E5=BA=94=E5=BC=8F=EF=BC=8C=E6=9B=B4=E6=96=B0snap?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../__snapshots__/image-picker.spec.ts.snap | 22 +++++ .../__tests__/image-picker.spec.ts | 81 +++++++++++++++++-- 2 files changed, 97 insertions(+), 6 deletions(-) diff --git a/src/components/image-picker/__tests__/__snapshots__/image-picker.spec.ts.snap b/src/components/image-picker/__tests__/__snapshots__/image-picker.spec.ts.snap index e4c7811c..da8c3d03 100644 --- a/src/components/image-picker/__tests__/__snapshots__/image-picker.spec.ts.snap +++ b/src/components/image-picker/__tests__/__snapshots__/image-picker.spec.ts.snap @@ -7,24 +7,46 @@ exports[`AtImagePicker should render all nodes and match snapshot 1`] = ` + + + + + + + + + + + + + + + + + 正在上传自定义消息 + + + + 上传失败自定义消息 + diff --git a/src/components/image-picker/__tests__/image-picker.spec.ts b/src/components/image-picker/__tests__/image-picker.spec.ts index 7a6496f4..e7092059 100644 --- a/src/components/image-picker/__tests__/image-picker.spec.ts +++ b/src/components/image-picker/__tests__/image-picker.spec.ts @@ -1,6 +1,7 @@ import { mountFactory, Slots } from '@/tests/helper' import AtImagePicker from '../index' import Taro from '@tarojs/taro' +import { ref, unref } from 'vue' const factory = ( props: object = {}, @@ -9,28 +10,34 @@ const factory = ( return mountFactory(AtImagePicker, undefined, props, slots) } -const files = [ +const files = ref([ { url: 'https://zos.alipayobjects.com/rmsportal/PZUUCKTRIHWiZSY.jpeg', id: '2121', + status: 'uploading', }, { url: 'https://zos.alipayobjects.com/rmsportal/hqQWgTXdrlmVVYi.jpeg', id: '2122', + status: 'failed', }, { url: 'https://zos.alipayobjects.com/rmsportal/PZUUCKTRIHWiZSY.jpeg', id: '2121', + status: 'uploading', + message: '正在上传自定义消息' }, { url: 'https://zos.alipayobjects.com/rmsportal/PZUUCKTRIHWiZSY.jpeg', id: '2121', + status: 'failed', + message: '上传失败自定义消息' }, { url: 'https://zos.alipayobjects.com/rmsportal/PZUUCKTRIHWiZSY.jpeg', id: '2121', }, -] +]) describe('AtImagePicker', () => { let getEnv @@ -65,21 +72,29 @@ describe('AtImagePicker', () => { it('should render prop files', async () => { const wrapper = factory({ files: files }) const imageEls = wrapper.findAll('.at-image-picker__preview-img') - expect(imageEls.length).toBe(files.length) + const uploadingIconEls = wrapper.findAll('.at-loading') + const failedIconEls = wrapper.findAll('.at-image-picker__upload-status--failed') + const statusMessageEls = wrapper.findAll('.at-image-picker__status-message') + expect(imageEls.length).toBe(unref(files).length) + expect(uploadingIconEls.length).toBe(unref(files).filter(({ status }) => status === 'uploading').length) + expect(failedIconEls.length).toBe(unref(files).filter(({ status }) => status === 'failed').length) + expect(statusMessageEls.length).toBe(unref(files).filter(({ message }) => !!message).length) imageEls.forEach((el, index) => { - expect(el.attributes('src')).toEqual(files[index].url) + expect(el.attributes('src')).toEqual(unref(files)[index].url) + const statusMessageEl = el.find('.at-image-picker__status-message') + statusMessageEl.exists() && expect(statusMessageEl.text()).toBe(unref(files)[index].message) }) }) it('should render prop length', async () => { let length = 5 - let row = Math.ceil((files.length + 1) / length) + let row = Math.ceil((unref(files).length + 1) / length) const wrapper = factory({ files: files, length }) expect(wrapper.findAll('.at-image-picker__flex-item').length).toBe(row * length) expect(wrapper.findAll('.at-image-picker__flex-box').length).toBe(row) length = 0 - row = Math.ceil((files.length + 1) / 1) + row = Math.ceil((unref(files).length + 1) / 1) await wrapper.setProps({ length }) await wrapper.vm.$nextTick() expect(wrapper.findAll('.at-image-picker__flex-item').length).toBe(row * 1) @@ -184,4 +199,58 @@ describe('AtImagePicker Behaviours', () => { expect(onFail).toBeCalled() spy.mockClear() }) + + test('modify files to show uploading status', async () => { + const index = 4 + const status = 'uploading' + const message = '正在上传' + const wrapper = factory({ files: files }) + unref(files)[index].status = status + unref(files)[index].message = message + await wrapper.vm.$nextTick() + const el = wrapper.findAll('.at-image-picker__item')[index] + expect(el.find('.at-loading').exists()).toBeTruthy() + expect(el.find('.at-image-picker__status-message').text()).toBe(message) + }) + + test('modify files to show failed status', async () => { + const index = 4 + const status = 'failed' + const message = '上传失败' + const wrapper = factory({ files: files }) + unref(files)[index].status = status + unref(files)[index].message = message + await wrapper.vm.$nextTick() + const el = wrapper.findAll('.at-image-picker__item')[index] + el.get('.at-image-picker__upload-status--failed') + expect(el.find('.at-image-picker__status-message').text()).toBe(message) + }) + + it.each([ + { + index: 4, + status: 'done', + message: '不会显示的message' + }, + { + index: 4, + status: '', + message: '不会显示的message' + }, + { + index: 4, + message: '不会显示的message' + }, + { + index: 4, + } + ])('modify files to show done status ', async ({ index, status, message }) => { + const wrapper = factory({ files: files }) + unref(files)[index].status = status + unref(files)[index].message = message + await wrapper.vm.$nextTick() + const el = wrapper.findAll('.at-image-picker__item')[index] + expect(() => el.get('.at-image-picker__upload-status')).toThrowError() + }) + }) From a98c119d5e21a8ff6c1988c86bedf121033e9dec Mon Sep 17 00:00:00 2001 From: zoney Date: Mon, 22 Mar 2021 14:50:23 +0800 Subject: [PATCH 05/23] =?UTF-8?q?#86,=E4=B8=8A=E4=BC=A0=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=E8=BD=AC=E6=80=81=E9=A2=9C=E8=89=B2=E6=94=B9=E6=88=90=E7=BA=A2?= =?UTF-8?q?=E8=89=B2=E7=8A=B6=E6=80=81=E9=81=AE=E7=BD=A9=E9=80=8F=E6=98=8E?= =?UTF-8?q?=E5=BA=A6=E6=94=B9=E4=B8=BA0.7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/image-picker/index.ts | 8 +++++--- src/style/components/image-picker.scss | 18 +++++++++++++----- src/style/mixins/libs/overlay.scss | 11 +++++++++-- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/src/components/image-picker/index.ts b/src/components/image-picker/index.ts index 3e3b4fe4..90b80a31 100644 --- a/src/components/image-picker/index.ts +++ b/src/components/image-picker/index.ts @@ -152,19 +152,21 @@ const AtImagePicker = defineComponent({ class: `at-image-picker__upload-status`, }, { default: () => { + const isUploading = item.status === 'uploading' const r = [ - item.status === 'uploading' + isUploading ? h(AtLoading, { color: '#fff' }) : h(View, { - class: 'at-image-picker__upload-status--failed' + class: 'at-image-picker__status-icon at-image-picker__status-icon--failed' }) ] if (item.message) { + const messageBasicClass = 'at-image-picker__status-message' r.push( h(View, { - class: 'at-image-picker__status-message' + class: `${messageBasicClass} ${messageBasicClass}--${isUploading ? 'uploading' : 'failed'}` }, { default: () => item.message }) ) } diff --git a/src/style/components/image-picker.scss b/src/style/components/image-picker.scss index 12ecf3f1..31666ef2 100644 --- a/src/style/components/image-picker.scss +++ b/src/style/components/image-picker.scss @@ -124,13 +124,17 @@ flex-direction: column; font-weight: 300; color: #fff; - @include overlay; + @include overlay-dark; + } + + &__status-icon { + height: $at-loading-size; + width: $at-loading-size; + position: relative; &--failed { - height: $at-loading-size; - width: $at-loading-size; - position: relative; + color: $color-error; &::before, &::after { @@ -149,7 +153,7 @@ &::after { width: 100%; - height:100%; + height: 100%; border: 1PX solid; border-radius: 50%; } @@ -158,6 +162,10 @@ } &__status-message { + &--failed { + color: $color-error; + } + margin-top: 20px; } } \ No newline at end of file diff --git a/src/style/mixins/libs/overlay.scss b/src/style/mixins/libs/overlay.scss index 2cdbbbc9..86202d1a 100644 --- a/src/style/mixins/libs/overlay.scss +++ b/src/style/mixins/libs/overlay.scss @@ -1,11 +1,18 @@ /** * 通用的遮罩 */ -@mixin overlay { +@mixin overlay ($alpha:0.3) { top: 0; left: 0; width: 100%; height: 100%; position: absolute; - background-color: rgba($color: #000, $alpha: 0.3); + background-color: rgba($color: #000, $alpha:$alpha); } + +/** + * 深一点的遮罩 + */ +@mixin overlay-dark { + @include overlay(.7) +} \ No newline at end of file From 7f718e6a1965b8b26ad8953f5ee44da6b12ebbde Mon Sep 17 00:00:00 2001 From: Ken Ho Date: Mon, 22 Mar 2021 17:35:25 +0800 Subject: [PATCH 06/23] demo(image-picker): @image-pick should be @image-click --- src/pages/form/image-picker/index.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/form/image-picker/index.vue b/src/pages/form/image-picker/index.vue index 6944cd75..487fb1f2 100644 --- a/src/pages/form/image-picker/index.vue +++ b/src/pages/form/image-picker/index.vue @@ -22,7 +22,7 @@ :files="files2" @change="onChange('files2', $event)" @fail="onFail" - @image-pick="onImageClick" + @image-click="onImageClick" /> @@ -155,4 +155,4 @@ export default defineComponent({ } } }) - \ No newline at end of file + From e9176f5c3f82e111057a86640bc91a5459c1cf04 Mon Sep 17 00:00:00 2001 From: zoney Date: Fri, 26 Mar 2021 20:05:48 +0800 Subject: [PATCH 07/23] =?UTF-8?q?refactor(image-picker):onChange=E5=A4=9A?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E6=94=B9=E4=B8=BA=E5=AF=B9=E8=B1=A1=E5=8F=82?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/image-picker/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/image-picker/index.ts b/src/components/image-picker/index.ts index 90b80a31..56c9cd4b 100644 --- a/src/components/image-picker/index.ts +++ b/src/components/image-picker/index.ts @@ -128,7 +128,7 @@ const AtImagePicker = defineComponent({ const newFiles = props.files.concat(targetFiles) - props.onChange(newFiles, 'add') + props.onChange({ files: newFiles, operationType: 'add' }) }) .catch(props.onFail) } @@ -144,7 +144,7 @@ const AtImagePicker = defineComponent({ const newFiles = props.files.filter((_, i) => i !== idx) - props.onChange(newFiles, 'remove', idx) + props.onChange({ files: newFiles, operationType: 'remove', index: idx }) } function renderUploadStatus(item: MatrixFile) { From a67191ea8a740e91a0ded38648e22d5be8f8bb03 Mon Sep 17 00:00:00 2001 From: zoney Date: Fri, 26 Mar 2021 20:08:03 +0800 Subject: [PATCH 08/23] =?UTF-8?q?test:(image-picker):=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=90=8C=E6=AD=A5=E6=A0=B7=E5=BC=8F=E7=B1=BB?= =?UTF-8?q?=E5=90=8D=E7=9A=84=E6=9B=B4=E6=94=B9=EF=BC=8C=E5=B9=B6=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E6=B5=8B=E8=AF=95=E5=BF=AB=E7=85=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../__tests__/__snapshots__/image-picker.spec.ts.snap | 8 ++++---- .../image-picker/__tests__/image-picker.spec.ts | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/image-picker/__tests__/__snapshots__/image-picker.spec.ts.snap b/src/components/image-picker/__tests__/__snapshots__/image-picker.spec.ts.snap index da8c3d03..81c33f2d 100644 --- a/src/components/image-picker/__tests__/__snapshots__/image-picker.spec.ts.snap +++ b/src/components/image-picker/__tests__/__snapshots__/image-picker.spec.ts.snap @@ -21,7 +21,7 @@ exports[`AtImagePicker should render all nodes and match snapshot 1`] = ` - + @@ -35,7 +35,7 @@ exports[`AtImagePicker should render all nodes and match snapshot 1`] = ` - 正在上传自定义消息 + 正在上传自定义消息 @@ -44,8 +44,8 @@ exports[`AtImagePicker should render all nodes and match snapshot 1`] = ` - - 上传失败自定义消息 + + 上传失败自定义消息 diff --git a/src/components/image-picker/__tests__/image-picker.spec.ts b/src/components/image-picker/__tests__/image-picker.spec.ts index e7092059..21e8e4fa 100644 --- a/src/components/image-picker/__tests__/image-picker.spec.ts +++ b/src/components/image-picker/__tests__/image-picker.spec.ts @@ -73,7 +73,7 @@ describe('AtImagePicker', () => { const wrapper = factory({ files: files }) const imageEls = wrapper.findAll('.at-image-picker__preview-img') const uploadingIconEls = wrapper.findAll('.at-loading') - const failedIconEls = wrapper.findAll('.at-image-picker__upload-status--failed') + const failedIconEls = wrapper.findAll('.at-image-picker__status-icon--failed') const statusMessageEls = wrapper.findAll('.at-image-picker__status-message') expect(imageEls.length).toBe(unref(files).length) expect(uploadingIconEls.length).toBe(unref(files).filter(({ status }) => status === 'uploading').length) @@ -222,7 +222,7 @@ describe('AtImagePicker Behaviours', () => { unref(files)[index].message = message await wrapper.vm.$nextTick() const el = wrapper.findAll('.at-image-picker__item')[index] - el.get('.at-image-picker__upload-status--failed') + el.get('.at-image-picker__status-icon--failed') expect(el.find('.at-image-picker__status-message').text()).toBe(message) }) From 03b2e881521ade6f7c70359925a3e552e0f193ca Mon Sep 17 00:00:00 2001 From: zoney Date: Fri, 26 Mar 2021 20:12:12 +0800 Subject: [PATCH 09/23] =?UTF-8?q?feat(image-picker):=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E7=8A=B6=E6=80=81demo=E4=B8=AD=EF=BC=8C=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E6=A8=A1=E6=8B=9F=E4=B8=8A=E4=BC=A0=E5=8A=A8=E4=BD=9C=E5=8A=A8?= =?UTF-8?q?=E6=80=81=E6=9B=B4=E6=96=B0=E4=B8=8A=E4=BC=A0=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/form/image-picker/index.vue | 57 +++++++++++++++++++++++++-- types/image-picker.d.ts | 21 +++++++--- 2 files changed, 69 insertions(+), 9 deletions(-) diff --git a/src/pages/form/image-picker/index.vue b/src/pages/form/image-picker/index.vue index 6944cd75..00473792 100644 --- a/src/pages/form/image-picker/index.vue +++ b/src/pages/form/image-picker/index.vue @@ -75,11 +75,12 @@ import { defineComponent, reactive, toRefs } from 'vue' import Taro from '@tarojs/taro' import './index.scss' - +import { uuid } from '../../../utils/common' type DogaImage = { url: string, status?: 'uploading' | 'failed' | 'done' message?: string + [propName:string]:any } const dogaImages: DogaImage[] = [ @@ -128,9 +129,33 @@ export default defineComponent({ } ] }) + + function onChange(stateName: string, { + files, operationType + }: { + files: DogaImage[], + operationType: 'add' | 'remove' + }): void { + const oldLen = state[stateName].length + const currentFiles = state[stateName] - function onChange(stateName: string, files: DogaImage[]): void { - state[stateName] = files + if (operationType === 'add') { + files.slice(oldLen).forEach((file, index) => { + const id = uuid() + currentFiles.push({ ...file, id }) + setStatus(currentFiles[index + oldLen], 'uploading') + uploadMock(file.url) + .then(() => { + const target = currentFiles.find(({ id: _id }) => _id === id) + target && setStatus(target, 'done') + }).catch(() => { + const target = currentFiles.find(({ id: _id }) => _id === id) + target && setStatus(target, 'failed') + }) + }); + } else if (operationType === 'remove') { + state[stateName] = files + } } function onFail(mes: string): void { @@ -147,6 +172,32 @@ export default defineComponent({ }) } + function uploadMock(url){ + return new Promise((resolve,reject)=>{ + setTimeout(() => { + Math.random()>.5?resolve(url):reject('err') + }, 5000); + }) + } + + + function setStatus(item, type){ + switch(type){ + case 'uploading': + item.status='uploading' + item.message='正在上传' + break; + case 'failed': + item.status='failed' + item.message='上传失败' + break; + case 'done': + item.status='done' + break; + } + return item + } + return { ...toRefs(state), onFail, diff --git a/types/image-picker.d.ts b/types/image-picker.d.ts index 533c2755..ca043ec0 100644 --- a/types/image-picker.d.ts +++ b/types/image-picker.d.ts @@ -22,11 +22,16 @@ export interface File { * @since v1.0.0-alpha18 */ status?: "uploading" | "failed" | "done" - /** - * 图片上传的状态文案 - * @since 1.0.0-alpha18 - */ + /** + * 图片上传的状态文案 + * @since 1.0.0-alpha18 + */ message?: string + /** + * 自定义字段 + * @since 1.0.0-alpha18 + */ + [propName: string]: any } export interface AtImagePickerProps extends AtComponent { @@ -78,9 +83,13 @@ export interface AtImagePickerProps extends AtComponent { */ sourceType?: ("album" | "camera" | "user" | "environment")[] /** - * files 值发生变化触发的回调函数, operationType 操作类型有添加,移除,如果是移除操作,则第三个参数代表的是移除图片的索引 + * files 值发生变化触发的回调函数, operationType 操作类型有添加,移除,如果是移除操作,则index代表的是移除图片的索引 */ - onChange: (files: File[], operationType: 'add' | 'remove', index?: number) => void + onChange: (args: { + files: File[], + operationType: 'add' | 'remove', + index?: number + }) => void /** * 点击图片触发的回调 */ From 1897eb71e8607d98956e9a206668afc12afcb741 Mon Sep 17 00:00:00 2001 From: Ken Ho Date: Sat, 27 Mar 2021 09:44:38 +0800 Subject: [PATCH 10/23] style(image-picker): add font-size to status text to avoid disproportionate font size in h5, especially on small devices --- src/style/components/image-picker.scss | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/style/components/image-picker.scss b/src/style/components/image-picker.scss index 31666ef2..f79d850c 100644 --- a/src/style/components/image-picker.scss +++ b/src/style/components/image-picker.scss @@ -167,5 +167,6 @@ } margin-top: 20px; + font-size: $font-size-base; } -} \ No newline at end of file +} From c51b8d182269902a5823cba65343750d0a096632 Mon Sep 17 00:00:00 2001 From: Ken Ho Date: Sat, 27 Mar 2021 09:46:43 +0800 Subject: [PATCH 11/23] chore: shorten upload mock time to 2s --- src/pages/form/image-picker/index.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/form/image-picker/index.vue b/src/pages/form/image-picker/index.vue index 4dae325b..f0e49168 100644 --- a/src/pages/form/image-picker/index.vue +++ b/src/pages/form/image-picker/index.vue @@ -176,7 +176,7 @@ export default defineComponent({ return new Promise((resolve,reject)=>{ setTimeout(() => { Math.random()>.5?resolve(url):reject('err') - }, 5000); + }, 2000); }) } From 385cc1b9b9b63e513cd382b2ac65900c00d553fd Mon Sep 17 00:00:00 2001 From: Ken Ho Date: Sat, 27 Mar 2021 11:52:54 +0800 Subject: [PATCH 12/23] fix(SearchBar): not to clear searchtext by default --- src/components/search-bar/index.ts | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/components/search-bar/index.ts b/src/components/search-bar/index.ts index 595d4eaa..51530248 100644 --- a/src/components/search-bar/index.ts +++ b/src/components/search-bar/index.ts @@ -165,17 +165,6 @@ const AtSearchBar = defineComponent({ function handleActionClick(event: CommonEvent): void { props.onActionClick?.(event) - - // default to clear value after action click - if (attrs['onUpdate:value']) { - inputValue.value = '' - } else { - props.onChange?.('', event) - } - - if (process.env.TARO_ENV === 'h5') { - clearInputNodeValue() - } } return () => ( From 7d008ad266e35a4e4137ed83e679cce783e8c5be Mon Sep 17 00:00:00 2001 From: Ken Ho Date: Sat, 3 Apr 2021 23:10:34 +0800 Subject: [PATCH 13/23] fix(tabs): removerequired for props with default value --- src/components/tabs/index.ts | 6 ++---- src/components/tabs/pane/index.ts | 3 +-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/components/tabs/index.ts b/src/components/tabs/index.ts index c95686fd..8f3621d9 100644 --- a/src/components/tabs/index.ts +++ b/src/components/tabs/index.ts @@ -23,8 +23,7 @@ const AtTabs = defineComponent({ }, current: { type: Number, - default: 0, - required: true + default: 0 }, scroll: { type: Boolean, @@ -45,8 +44,7 @@ const AtTabs = defineComponent({ }, onClick: { type: Function as PropType, - default: () => (index: number, event: CommonEvent) => { }, - required: true + default: () => (index: number, event: CommonEvent) => { } }, }, diff --git a/src/components/tabs/pane/index.ts b/src/components/tabs/pane/index.ts index 3de150c3..7cc22095 100644 --- a/src/components/tabs/pane/index.ts +++ b/src/components/tabs/pane/index.ts @@ -8,8 +8,7 @@ const AtTabsPane = defineComponent({ props: { tabDirection: { type: String as PropType, - default: 'horizontal', - required: true + default: 'horizontal' }, index: { type: Number, From b57c958208946ad5b5b79ecaa8b1359a339a2c46 Mon Sep 17 00:00:00 2001 From: Ken Ho Date: Sat, 3 Apr 2021 23:14:03 +0800 Subject: [PATCH 14/23] fix(segmented-control): remove required for props with default value --- src/components/segmented-control/index.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/components/segmented-control/index.ts b/src/components/segmented-control/index.ts index 9a080c15..b73993ff 100644 --- a/src/components/segmented-control/index.ts +++ b/src/components/segmented-control/index.ts @@ -11,8 +11,7 @@ const AtSegmentedControl = defineComponent({ props: { current: { type: Number, - default: 0, - required: true + default: 0 }, color: { type: String, @@ -40,8 +39,7 @@ const AtSegmentedControl = defineComponent({ }, onClick: { type: Function as PropType, - default: () => (index: number, event: CommonEvent) => { }, - required: true + default: () => (index: number, event: CommonEvent) => { } }, }, From 3a638fff1ccd80760b71d274381d9570daeee2d0 Mon Sep 17 00:00:00 2001 From: Ken Ho Date: Sat, 3 Apr 2021 23:20:16 +0800 Subject: [PATCH 15/23] fix(modal): remove required for props with default value --- src/components/modal/action/index.ts | 2 +- src/components/modal/index.ts | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/components/modal/action/index.ts b/src/components/modal/action/index.ts index 06db521a..8dd5a91a 100644 --- a/src/components/modal/action/index.ts +++ b/src/components/modal/action/index.ts @@ -7,7 +7,7 @@ const AtModalAction = defineComponent({ name: "AtModalAction", props: { - isSimple: { type: Boolean, default: false, required: true } + isSimple: { type: Boolean, default: false } }, setup(props: AtModalActionProps, { attrs, slots }) { diff --git a/src/components/modal/index.ts b/src/components/modal/index.ts index d0b6739c..92d1a4db 100644 --- a/src/components/modal/index.ts +++ b/src/components/modal/index.ts @@ -19,8 +19,7 @@ const AtModal = defineComponent({ title: String as PropType, isOpened: { type: Boolean, - default: false, - required: true + default: false }, content: String as PropType, closeOnClickOverlay: { From 07c9c4f361e1768285ee41e6a2cb2761aff22920 Mon Sep 17 00:00:00 2001 From: Ken Ho Date: Sat, 3 Apr 2021 23:39:20 +0800 Subject: [PATCH 16/23] fix(components): remove required for props with default value --- src/components/calendar/controller/index.ts | 3 +-- src/components/checkbox/index.ts | 3 +-- src/components/countdown/item/index.ts | 3 +-- src/components/drawer/index.ts | 3 +-- src/components/float-layout/index.ts | 3 +-- src/components/image-picker/index.ts | 3 +-- src/components/input-number/index.ts | 3 +-- src/components/input/index.ts | 3 +-- src/components/pagination/index.ts | 2 +- src/components/radio/index.ts | 6 ++---- src/components/search-bar/index.ts | 3 +-- src/components/segmented-control/index.ts | 3 +-- src/components/steps/index.ts | 6 ++---- src/components/swipe-action/options/index.ts | 9 +++------ src/components/tab-bar/index.ts | 8 +++----- src/components/tabs/index.ts | 3 +-- src/components/tabs/pane/index.ts | 6 ++---- src/components/toast/index.ts | 2 +- src/pages/components/demo-page/index.ts | 6 ++---- 19 files changed, 27 insertions(+), 51 deletions(-) diff --git a/src/components/calendar/controller/index.ts b/src/components/calendar/controller/index.ts index 9c6d9336..2736b701 100644 --- a/src/components/calendar/controller/index.ts +++ b/src/components/calendar/controller/index.ts @@ -11,8 +11,7 @@ const AtCalendarController = defineComponent({ props: { generateDate: { type: [String, Number] as PropType, - default: Date.now(), - required: true + default: Date.now() }, minDate: [String, Number, Date] as PropType, maxDate: [String, Number, Date] as PropType, diff --git a/src/components/checkbox/index.ts b/src/components/checkbox/index.ts index 39db6d8e..715637c0 100644 --- a/src/components/checkbox/index.ts +++ b/src/components/checkbox/index.ts @@ -11,8 +11,7 @@ const AtCheckbox = defineComponent({ // 参数 options: { type: Array as PropType['options']>, - default: () => [], - required: true + default: () => [] }, selectedList: { type: Array as PropType['selectedList']>, diff --git a/src/components/countdown/item/index.ts b/src/components/countdown/item/index.ts index 30a32084..893bcff8 100644 --- a/src/components/countdown/item/index.ts +++ b/src/components/countdown/item/index.ts @@ -10,8 +10,7 @@ const AtCountdownItem = defineComponent({ // 参数 num: { type: Number as PropType, - default: 0, - required: true + default: 0 }, separator: { type: String as PropType, diff --git a/src/components/drawer/index.ts b/src/components/drawer/index.ts index deceba16..a967e539 100644 --- a/src/components/drawer/index.ts +++ b/src/components/drawer/index.ts @@ -10,8 +10,7 @@ const AtDrawer = defineComponent({ props: { show: { type: Boolean, - default: false, - required: true + default: false }, mask: { type: Boolean, diff --git a/src/components/float-layout/index.ts b/src/components/float-layout/index.ts index d7134209..756a0cbb 100644 --- a/src/components/float-layout/index.ts +++ b/src/components/float-layout/index.ts @@ -12,8 +12,7 @@ const AtFloatLayout = defineComponent({ // 参数 isOpened: { type: Boolean, - default: false, - required: true + default: false }, title: { type: String as PropType, diff --git a/src/components/image-picker/index.ts b/src/components/image-picker/index.ts index 56c9cd4b..2bd68ea5 100644 --- a/src/components/image-picker/index.ts +++ b/src/components/image-picker/index.ts @@ -78,8 +78,7 @@ const AtImagePicker = defineComponent({ // 事件 onChange: { type: Function as PropType, - default: () => () => { }, - required: true + default: () => () => { } }, onImageClick: Function as PropType, onFail: Function as PropType, diff --git a/src/components/input-number/index.ts b/src/components/input-number/index.ts index 7c09a16a..a7dd0c79 100644 --- a/src/components/input-number/index.ts +++ b/src/components/input-number/index.ts @@ -54,8 +54,7 @@ const AtInputNumber = defineComponent({ }, value: { type: [Number, String] as PropType, - default: 1, - required: true + default: 1 }, style: String as PropType, min: { diff --git a/src/components/input/index.ts b/src/components/input/index.ts index 9a580caa..4472faf1 100644 --- a/src/components/input/index.ts +++ b/src/components/input/index.ts @@ -50,8 +50,7 @@ const AtInput = defineComponent({ props: { name: { type: String as PropType, - default: '', - required: true + default: '' }, title: { type: String as PropType, diff --git a/src/components/pagination/index.ts b/src/components/pagination/index.ts index 95dec1b0..e4671b79 100644 --- a/src/components/pagination/index.ts +++ b/src/components/pagination/index.ts @@ -19,7 +19,7 @@ const AtPagination = defineComponent({ name: "AtPagination", props: { - total: { type: Number, default: 0, required: true }, + total: { type: Number, default: 0 }, current: { type: Number, default: 1 }, pageSize: { type: Number, default: 20 }, icon: { type: Boolean, default: false }, diff --git a/src/components/radio/index.ts b/src/components/radio/index.ts index 56f02ae4..9d9051c5 100644 --- a/src/components/radio/index.ts +++ b/src/components/radio/index.ts @@ -10,13 +10,11 @@ const AtRadio = defineComponent({ props: { value: { type: String as PropType['value']>, - default: '', - required: true + default: '' }, options: { type: Array as PropType['options']>, - default: [], - required: true + default: [] }, onClick: Function as PropType['onClick']> }, diff --git a/src/components/search-bar/index.ts b/src/components/search-bar/index.ts index 51530248..1bf1ae6d 100644 --- a/src/components/search-bar/index.ts +++ b/src/components/search-bar/index.ts @@ -11,8 +11,7 @@ const AtSearchBar = defineComponent({ props: { value: { type: String, - default: '', - required: true + default: '' }, placeholder: { type: String, diff --git a/src/components/segmented-control/index.ts b/src/components/segmented-control/index.ts index b73993ff..c5d7b624 100644 --- a/src/components/segmented-control/index.ts +++ b/src/components/segmented-control/index.ts @@ -34,8 +34,7 @@ const AtSegmentedControl = defineComponent({ }, values: { type: Array as PropType, - default: [], - required: true + default: [] }, onClick: { type: Function as PropType, diff --git a/src/components/steps/index.ts b/src/components/steps/index.ts index 67a7badc..69cd7130 100644 --- a/src/components/steps/index.ts +++ b/src/components/steps/index.ts @@ -9,8 +9,7 @@ const AtSteps = defineComponent({ props: { current: { type: Number, - default: 0, - required: true + default: 0 }, items: { type: Array as PropType, @@ -18,8 +17,7 @@ const AtSteps = defineComponent({ }, onChange: { type: Function as PropType, - default: () => (current: number, event: CommonEvent) => { }, - required: true + default: () => (current: number, event: CommonEvent) => { } }, }, diff --git a/src/components/swipe-action/options/index.ts b/src/components/swipe-action/options/index.ts index 99ead6ab..da115cde 100644 --- a/src/components/swipe-action/options/index.ts +++ b/src/components/swipe-action/options/index.ts @@ -9,18 +9,15 @@ const AtSwipeActionOptions = defineComponent({ props: { componentId: { type: String, - default: '', - required: true + default: '' }, options: { type: Array as PropType, - default: [], - required: true + default: [] }, onQueryedDom: { type: Function as PropType, - default: () => ({ width }: { width: number }) => { }, - required: true + default: () => ({ width }: { width: number }) => { } }, }, diff --git a/src/components/tab-bar/index.ts b/src/components/tab-bar/index.ts index ddbe21ad..42b89f16 100644 --- a/src/components/tab-bar/index.ts +++ b/src/components/tab-bar/index.ts @@ -20,8 +20,7 @@ const AtTabBar = defineComponent({ }, current: { type: Number, - default: 0, - required: true + default: 0 }, iconSize: { type: [Number, String], @@ -51,9 +50,8 @@ const AtTabBar = defineComponent({ }, onClick: { type: Function as PropType, - default: () => (index: number, event: CommonEvent) => { }, - required: true - }, + default: () => (index: number, event: CommonEvent) => { } + } }, setup(props: AtTabBarProps, { attrs }) { diff --git a/src/components/tabs/index.ts b/src/components/tabs/index.ts index 8f3621d9..36210dd4 100644 --- a/src/components/tabs/index.ts +++ b/src/components/tabs/index.ts @@ -39,8 +39,7 @@ const AtTabs = defineComponent({ }, tabList: { type: Array as PropType, - default: [], - required: true + default: [] }, onClick: { type: Function as PropType, diff --git a/src/components/tabs/pane/index.ts b/src/components/tabs/pane/index.ts index 7cc22095..42900069 100644 --- a/src/components/tabs/pane/index.ts +++ b/src/components/tabs/pane/index.ts @@ -12,13 +12,11 @@ const AtTabsPane = defineComponent({ }, index: { type: Number, - default: 0, - required: true + default: 0 }, current: { type: Number, - default: 0, - required: true + default: 0 }, }, diff --git a/src/components/toast/index.ts b/src/components/toast/index.ts index cffc2abc..4ff940ea 100644 --- a/src/components/toast/index.ts +++ b/src/components/toast/index.ts @@ -9,7 +9,7 @@ const AtToast = defineComponent({ name: "AtToast", props: { - isOpened: { type: Boolean, default: false, required: true }, + isOpened: { type: Boolean, default: false }, text: { type: String, default: '' }, icon: { type: String, default: '' }, image: { type: String, default: '' }, diff --git a/src/pages/components/demo-page/index.ts b/src/pages/components/demo-page/index.ts index c4170d67..17ab6907 100644 --- a/src/pages/components/demo-page/index.ts +++ b/src/pages/components/demo-page/index.ts @@ -9,8 +9,7 @@ const Page = defineComponent({ props: { headerTitle: { type: String, - default: '标题', - required: true + default: '标题' } }, @@ -64,8 +63,7 @@ const Panel = defineComponent({ props: { title: { type: String, - default: '', - required: true + default: '' }, noPadding: Boolean }, From 74434b8267420c71285000e0bf067f29a336cf99 Mon Sep 17 00:00:00 2001 From: Ken Ho Date: Tue, 6 Apr 2021 23:05:46 +0800 Subject: [PATCH 17/23] chore: update typescript to version 4 and correct synax errors --- package.json | 15 +- src/components/accordion/index.ts | 2 +- .../action-sheet/body/item/index.ts | 2 +- src/components/action-sheet/footer/index.ts | 2 +- src/components/action-sheet/index.ts | 4 +- src/components/button/index.ts | 18 +- src/components/calendar/body/index.ts | 6 +- src/components/calendar/common/plugins.ts | 20 +- src/components/calendar/controller/index.ts | 6 +- src/components/calendar/index.ts | 12 +- src/components/calendar/ui/date-list/index.ts | 4 +- src/components/card/index.ts | 2 +- src/components/checkbox/index.ts | 2 +- src/components/countdown/index.ts | 2 +- src/components/curtain/index.ts | 2 +- src/components/drawer/index.ts | 4 +- src/components/fab/index.ts | 2 +- src/components/float-layout/index.ts | 8 +- src/components/form/index.ts | 4 +- src/components/grid/index.ts | 2 +- src/components/icon/index.ts | 2 +- src/components/image-picker/index.ts | 6 +- src/components/indexes/index.ts | 4 +- src/components/input-number/index.ts | 6 +- src/components/input/index.ts | 14 +- src/components/list/item/index.ts | 4 +- src/components/load-more/index.ts | 2 +- src/components/modal/index.ts | 6 +- src/components/nav-bar/index.ts | 6 +- src/components/noticebar/index.ts | 4 +- src/components/pagination/index.ts | 2 +- src/components/radio/index.ts | 2 +- src/components/range/index.ts | 4 +- src/components/rate/index.ts | 2 +- src/components/search-bar/index.ts | 12 +- src/components/segmented-control/index.ts | 2 +- src/components/slider/index.ts | 4 +- src/components/steps/index.ts | 2 +- src/components/swipe-action/index.ts | 6 +- src/components/swipe-action/options/index.ts | 2 +- src/components/switch/index.ts | 2 +- src/components/tab-bar/index.ts | 2 +- src/components/tabs/index.ts | 2 +- src/components/tag/index.ts | 2 +- src/components/textarea/index.ts | 10 +- src/components/toast/index.ts | 4 +- src/components/virtual-scroll/index.ts | 4 +- types/calendar.d.ts | 2 +- yarn.lock | 175 ++++++++++-------- 49 files changed, 213 insertions(+), 201 deletions(-) diff --git a/package.json b/package.json index 482154c4..c986f0e1 100644 --- a/package.json +++ b/package.json @@ -82,7 +82,7 @@ "peerDependencies": { "@tarojs/components": "^3.1.4", "@tarojs/taro": "^3.1.4", - "vue": "^3.0.6" + "vue": "^3.0.9" }, "devDependencies": { "@babel/core": "^7.8.0", @@ -100,12 +100,12 @@ "@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.6", + "@vue/compiler-sfc": "^3.0.9", "@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.9.0", + "esbuild": "^0.11.0", "eslint": "^6.8.0", "eslint-config-taro": "^3.0.5", "eslint-plugin-vue": "^7.0.0-alpha.6", @@ -116,16 +116,17 @@ "rollup": "^2.29.0", "rollup-plugin-copy": "^3.3.0", "rollup-plugin-sass": "^1.2.2", - "rollup-plugin-typescript2": "^0.27.2", + "rollup-plugin-typescript2": "0.30.0", "shelljs": "^0.8.4", "stylelint": "^9.3.0", "tiny-glob": "^0.2.8", "ts-jest": "^26.4.4", "ts-loader": "^8.0.2", - "typescript": "^3.7.0", - "vue": "^3.0.6", + "tslib": "^2.1.0", + "typescript": "^4.2.0", + "vue": "^3.0.9", "vue-jest": "^5.0.0-alpha.7", "vue-loader": "^16.1.0", "webpack-bundle-analyzer": "^4.2.0" } -} \ No newline at end of file +} diff --git a/src/components/accordion/index.ts b/src/components/accordion/index.ts index 239a09a8..9ffbbbeb 100644 --- a/src/components/accordion/index.ts +++ b/src/components/accordion/index.ts @@ -29,7 +29,7 @@ const AtAccordion = defineComponent({ type: String, default: '' }, - onClick: Function as PropType + onClick: Function as unknown as PropType }, setup(props: AtAccordionProps, { attrs, slots }) { diff --git a/src/components/action-sheet/body/item/index.ts b/src/components/action-sheet/body/item/index.ts index 8ced067b..30769b29 100644 --- a/src/components/action-sheet/body/item/index.ts +++ b/src/components/action-sheet/body/item/index.ts @@ -7,7 +7,7 @@ const AtActionSheetItem = defineComponent({ name: "AtActionSheetItem", props: { - onClick: Function as PropType<(event?: CommonEvent) => void> + onClick: Function as unknown as PropType<(event?: CommonEvent) => void> }, setup(props: AtActionSheetItemProps, { attrs, slots }) { diff --git a/src/components/action-sheet/footer/index.ts b/src/components/action-sheet/footer/index.ts index 41850ae7..5d4c0302 100644 --- a/src/components/action-sheet/footer/index.ts +++ b/src/components/action-sheet/footer/index.ts @@ -6,7 +6,7 @@ const AtActionSheetFooter = defineComponent({ name: "AtActionSheetFooter", props: { - onClick: Function as PropType + onClick: Function as unknown as PropType }, setup(props: AtActionSheetFooterProps, { attrs, slots }) { diff --git a/src/components/action-sheet/index.ts b/src/components/action-sheet/index.ts index 5c5f0fdb..9f65ab29 100644 --- a/src/components/action-sheet/index.ts +++ b/src/components/action-sheet/index.ts @@ -23,8 +23,8 @@ const AtActionSheet = defineComponent({ type: String, default: '' }, - onClose: Function as PropType<(event?: CommonEvent) => void>, - onCancel: Function as PropType<(event?: CommonEvent) => void> + onClose: Function as unknown as PropType<(event?: CommonEvent) => void>, + onCancel: Function as unknown as PropType<(event?: CommonEvent) => void> }, setup(props: AtActionSheetProps, { attrs, slots }) { diff --git a/src/components/button/index.ts b/src/components/button/index.ts index 1af9156d..afc88982 100644 --- a/src/components/button/index.ts +++ b/src/components/button/index.ts @@ -37,7 +37,7 @@ const AtButton = defineComponent({ full: Boolean, loading: Boolean, disabled: Boolean, - onClick: Function as PropType, + onClick: Function as unknown as PropType, // Taro Button Props formType: { @@ -74,14 +74,14 @@ const AtButton = defineComponent({ scope: String as PropType, // alipay scope // Taro Button Events - onGetUserInfo: Function as PropType, - onGetAuthorize: Function as PropType, // Alipay auth - onContact: Function as PropType, - onGetPhoneNumber: Function as PropType, - onGetRealnameAuthInfo: Function as PropType, - onError: Function as PropType, - onOpenSetting: Function as PropType, - onLaunchapp: Function as PropType, + onGetUserInfo: Function as unknown as PropType, + onGetAuthorize: Function as unknown as PropType, // Alipay auth + onContact: Function as unknown as PropType, + onGetPhoneNumber: Function as unknown as PropType, + onGetRealnameAuthInfo: Function as unknown as PropType, + onError: Function as unknown as PropType, + onOpenSetting: Function as unknown as PropType, + onLaunchapp: Function as unknown as PropType, }, setup(props: AtButtonProps, { attrs, slots }) { diff --git a/src/components/calendar/body/index.ts b/src/components/calendar/body/index.ts index 44e14352..c7dd2bff 100644 --- a/src/components/calendar/body/index.ts +++ b/src/components/calendar/body/index.ts @@ -57,15 +57,15 @@ const AtCalendarBody = defineComponent({ default: () => [] }, onDayClick: { - type: Function as PropType, + type: Function as unknown as PropType, default: () => () => { } }, onLongClick: { - type: Function as PropType, + type: Function as unknown as PropType, default: () => () => { } }, onSwipeMonth: { - type: Function as PropType, + type: Function as unknown as PropType, default: () => () => { } }, }, diff --git a/src/components/calendar/common/plugins.ts b/src/components/calendar/common/plugins.ts index dd8337e8..9a5e93d6 100644 --- a/src/components/calendar/common/plugins.ts +++ b/src/components/calendar/common/plugins.ts @@ -21,14 +21,14 @@ export function handleActive( const dayjsStart = start ? dayjs(start) : dayjsEnd item.isSelected = - _value.isSame(dayjsEnd) || - _value.isSame(dayjsStart) || - (_value.isAfter(dayjsStart) && _value.isBefore(dayjsEnd)) + _value!.isSame(dayjsEnd) || + _value!.isSame(dayjsStart) || + (_value!.isAfter(dayjsStart) && _value!.isBefore(dayjsEnd)) - item.isSelectedHead = _value.isSame(dayjsStart) - item.isSelectedTail = _value.isSame(dayjsEnd) + item.isSelectedHead = _value!.isSame(dayjsStart) + item.isSelectedTail = _value!.isSame(dayjsEnd) - item.isToday = _value.diff(dayjs(Date.now()).startOf('day'), 'day') === 0 + item.isToday = _value!.diff(dayjs(Date.now()).startOf('day'), 'day') === 0 return item } @@ -44,7 +44,7 @@ export function handleMarks( const markList = marks.filter(mark => dayjs(mark.value) .startOf('day') - .isSame(_value) + .isSame(_value!) ) item.marks = markList.slice(0, 1) @@ -96,8 +96,8 @@ export function handleDisabled( const dayjsMaxDate = dayjs(maxDate) item.isDisabled = - !!(minDate && _value.isBefore(dayjsMinDate)) || - !!(maxDate && _value.isAfter(dayjsMaxDate)) + !!(minDate && _value!.isBefore(dayjsMinDate)) || + !!(maxDate && _value!.isAfter(dayjsMaxDate)) return item } @@ -114,7 +114,7 @@ export function handleValid( const isInclude = validDates.some(date => dayjs(date.value) .startOf('day') - .isSame(_value) + .isSame(_value!) ) item.isDisabled = !isInclude diff --git a/src/components/calendar/controller/index.ts b/src/components/calendar/controller/index.ts index 2736b701..1e88932e 100644 --- a/src/components/calendar/controller/index.ts +++ b/src/components/calendar/controller/index.ts @@ -20,9 +20,9 @@ const AtCalendarController = defineComponent({ type: String as PropType, default: 'YYYY年MM月' }, - onPreMonth: Function as PropType, - onNextMonth: Function as PropType, - onSelectDate: Function as PropType + onPreMonth: Function as unknown as PropType, + onNextMonth: Function as unknown as PropType, + onSelectDate: Function as unknown as PropType }, setup(props: AtCalendarControllerProps) { diff --git a/src/components/calendar/index.ts b/src/components/calendar/index.ts index 5b7b7596..3ac0890e 100644 --- a/src/components/calendar/index.ts +++ b/src/components/calendar/index.ts @@ -59,12 +59,12 @@ const AtCalendar = defineComponent({ default: () => [] }, // 事件 - onClickPreMonth: Function as PropType, - onClickNextMonth: Function as PropType, - onDayClick: Function as PropType, - onDayLongClick: Function as PropType, - onMonthChange: Function as PropType, - onSelectDate: Function as PropType + onClickPreMonth: Function as unknown as PropType, + onClickNextMonth: Function as unknown as PropType, + onDayClick: Function as unknown as PropType, + onDayLongClick: Function as unknown as PropType, + onMonthChange: Function as unknown as PropType, + onSelectDate: Function as unknown as PropType }, setup(props: AtCalendarProps, { attrs }) { diff --git a/src/components/calendar/ui/date-list/index.ts b/src/components/calendar/ui/date-list/index.ts index 896a53d3..b789ba21 100644 --- a/src/components/calendar/ui/date-list/index.ts +++ b/src/components/calendar/ui/date-list/index.ts @@ -25,8 +25,8 @@ const AtCalendarList = defineComponent({ type: Array as PropType, default: () => [] as Calendar.List }, - onClick: Function as PropType, - onLongClick: Function as PropType, + onClick: Function as unknown as PropType, + onLongClick: Function as unknown as PropType, }, setup(props: AtCalendarListProps) { diff --git a/src/components/card/index.ts b/src/components/card/index.ts index da1410a0..a347c367 100644 --- a/src/components/card/index.ts +++ b/src/components/card/index.ts @@ -29,7 +29,7 @@ const AtCard = defineComponent({ }, icon: Object as PropType, renderIcon: Object as PropType, - onClick: Function as PropType + onClick: Function as unknown as PropType }, setup(props: AtCardProps, { attrs, slots }) { diff --git a/src/components/checkbox/index.ts b/src/components/checkbox/index.ts index 715637c0..bb110061 100644 --- a/src/components/checkbox/index.ts +++ b/src/components/checkbox/index.ts @@ -18,7 +18,7 @@ const AtCheckbox = defineComponent({ default: () => [] }, // 事件 - onChange: Function as PropType['onChange']> + onChange: Function as unknown as PropType['onChange']> }, setup(props: AtCheckboxProps, { attrs, emit }) { diff --git a/src/components/countdown/index.ts b/src/components/countdown/index.ts index f752e0d0..16dfbf2f 100644 --- a/src/components/countdown/index.ts +++ b/src/components/countdown/index.ts @@ -45,7 +45,7 @@ const AtCountdown = defineComponent({ default: 0, }, // 事件 - onTimeUp: Function as PropType + onTimeUp: Function as unknown as PropType }, onShow() { diff --git a/src/components/curtain/index.ts b/src/components/curtain/index.ts index aec5935d..c4246b6e 100644 --- a/src/components/curtain/index.ts +++ b/src/components/curtain/index.ts @@ -15,7 +15,7 @@ const AtCurtain = defineComponent({ }, // 事件 onClose: { - type: Function as PropType, + type: Function as unknown as PropType, default: () => () => { } } }, diff --git a/src/components/drawer/index.ts b/src/components/drawer/index.ts index a967e539..4c53a27a 100644 --- a/src/components/drawer/index.ts +++ b/src/components/drawer/index.ts @@ -26,11 +26,11 @@ const AtDrawer = defineComponent({ default: () => [], }, onItemClick: { - type: Function as PropType, + type: Function as unknown as PropType, default: () => () => { } }, onClose: { - type: Function as PropType, + type: Function as unknown as PropType, default: () => () => { } } }, diff --git a/src/components/fab/index.ts b/src/components/fab/index.ts index 3bb807b3..7e689d42 100644 --- a/src/components/fab/index.ts +++ b/src/components/fab/index.ts @@ -13,7 +13,7 @@ const AtFab = defineComponent({ validator: (prop: string) => ['normal', 'small'].includes(prop) }, onClick: { - type: Function as PropType, + type: Function as unknown as PropType, default: () => () => { } } }, diff --git a/src/components/float-layout/index.ts b/src/components/float-layout/index.ts index 756a0cbb..c7a2f867 100644 --- a/src/components/float-layout/index.ts +++ b/src/components/float-layout/index.ts @@ -29,10 +29,10 @@ const AtFloatLayout = defineComponent({ lowerThreshold: Number as PropType, scrollWithAnimation: Boolean, // 事件 - onClose: Function as PropType, - onScroll: Function as PropType, - onScrollToUpper: Function as PropType, - onScrollToLower: Function as PropType, + onClose: Function as unknown as PropType, + onScroll: Function as unknown as PropType, + onScrollToUpper: Function as unknown as PropType, + onScrollToLower: Function as unknown as PropType, }, setup(props: AtFloatLayoutProps, { attrs, slots }) { diff --git a/src/components/form/index.ts b/src/components/form/index.ts index 9ae8c27c..6e4144bc 100644 --- a/src/components/form/index.ts +++ b/src/components/form/index.ts @@ -7,8 +7,8 @@ const AtForm = defineComponent({ props: { reportSubmit: Boolean as PropType, - onSubmit: Function as PropType, - onReset: Function as PropType, + onSubmit: Function as unknown as PropType, + onReset: Function as unknown as PropType, }, setup(props: AtFormProps, { attrs, slots }) { diff --git a/src/components/grid/index.ts b/src/components/grid/index.ts index b108c779..84c35e0a 100644 --- a/src/components/grid/index.ts +++ b/src/components/grid/index.ts @@ -27,7 +27,7 @@ const AtGrid = defineComponent({ default: 'square', }, onClick: { - type: Function as PropType, + type: Function as unknown as PropType, default: () => () => { } } }, diff --git a/src/components/icon/index.ts b/src/components/icon/index.ts index 7abd652f..dd07e850 100644 --- a/src/components/icon/index.ts +++ b/src/components/icon/index.ts @@ -24,7 +24,7 @@ const AtIcon = defineComponent({ default: 24 }, onClick: { - type: Function as PropType, + type: Function as unknown as PropType, default: () => () => { } } }, diff --git a/src/components/image-picker/index.ts b/src/components/image-picker/index.ts index 2bd68ea5..e9211f87 100644 --- a/src/components/image-picker/index.ts +++ b/src/components/image-picker/index.ts @@ -77,11 +77,11 @@ const AtImagePicker = defineComponent({ }, // 事件 onChange: { - type: Function as PropType, + type: Function as unknown as PropType, default: () => () => { } }, - onImageClick: Function as PropType, - onFail: Function as PropType, + onImageClick: Function as unknown as PropType, + onFail: Function as unknown as PropType, }, setup(props: AtImagePickerProps, { attrs }) { diff --git a/src/components/indexes/index.ts b/src/components/indexes/index.ts index fce28d4c..a6efc82d 100644 --- a/src/components/indexes/index.ts +++ b/src/components/indexes/index.ts @@ -50,8 +50,8 @@ const AtIndexes = defineComponent({ default: () => [] }, // 事件 - onClick: Function as PropType, - onScrollIntoView: Function as PropType + onClick: Function as unknown as PropType, + onScrollIntoView: Function as unknown as PropType }, setup(props: AtIndexesProps, { attrs, slots }) { diff --git a/src/components/input-number/index.ts b/src/components/input-number/index.ts index a7dd0c79..ec856d9d 100644 --- a/src/components/input-number/index.ts +++ b/src/components/input-number/index.ts @@ -80,9 +80,9 @@ const AtInputNumber = defineComponent({ disabled: Boolean, disabledInput: Boolean, // 事件 - onChange: Function as PropType, - onBlur: Function as PropType, - onErrorInput: Function as PropType + onChange: Function as unknown as PropType, + onBlur: Function as unknown as PropType, + onErrorInput: Function as unknown as PropType }, setup(props: AtInputNumberProps, { attrs, emit }) { diff --git a/src/components/input/index.ts b/src/components/input/index.ts index 4472faf1..ab3835c3 100644 --- a/src/components/input/index.ts +++ b/src/components/input/index.ts @@ -118,13 +118,13 @@ const AtInput = defineComponent({ validator: (val: string) => ["done", "send", "search", "next", "go"].includes(val) }, // events - onChange: Function as PropType, - onBlur: Function as PropType, - onFocus: Function as PropType, - onConfirm: Function as PropType, - onClick: Function as PropType, - onKeyboardHeightChange: Function as PropType, - onErrorClick: Function as PropType + onChange: Function as unknown as PropType, + onBlur: Function as unknown as PropType, + onFocus: Function as unknown as PropType, + onConfirm: Function as unknown as PropType, + onClick: Function as unknown as PropType, + onKeyboardHeightChange: Function as unknown as PropType, + onErrorClick: Function as unknown as PropType }, setup(props: AtInputProps, { attrs, slots, emit }) { diff --git a/src/components/list/item/index.ts b/src/components/list/item/index.ts index 8f3bcbca..23ced552 100644 --- a/src/components/list/item/index.ts +++ b/src/components/list/item/index.ts @@ -27,8 +27,8 @@ const AtListItem = defineComponent({ default: '', validator: (prop: string) => ['up', 'down', 'right', ''].includes(prop) }, - onClick: Function as PropType, - onSwitchChange: Function as PropType + onClick: Function as unknown as PropType, + onSwitchChange: Function as unknown as PropType }, setup(props: AtListItemProps, { attrs }) { diff --git a/src/components/load-more/index.ts b/src/components/load-more/index.ts index ed735e90..82df85d6 100644 --- a/src/components/load-more/index.ts +++ b/src/components/load-more/index.ts @@ -36,7 +36,7 @@ const AtLoadMore = defineComponent({ }, // 事件 onClick: { - type: Function as PropType, + type: Function as unknown as PropType, default: () => () => { } }, }, diff --git a/src/components/modal/index.ts b/src/components/modal/index.ts index 92d1a4db..c1c99de2 100644 --- a/src/components/modal/index.ts +++ b/src/components/modal/index.ts @@ -28,9 +28,9 @@ const AtModal = defineComponent({ }, cancelText: String as PropType, confirmText: String as PropType, - onClose: Function as PropType, - onConfirm: Function as PropType, - onCancel: Function as PropType, + onClose: Function as unknown as PropType, + onConfirm: Function as unknown as PropType, + onCancel: Function as unknown as PropType, }, setup(props: AtModalProps, { attrs, slots }) { diff --git a/src/components/nav-bar/index.ts b/src/components/nav-bar/index.ts index fb92298f..61d57cfd 100644 --- a/src/components/nav-bar/index.ts +++ b/src/components/nav-bar/index.ts @@ -38,9 +38,9 @@ const AtNavBar = defineComponent({ default: '' }, // events - onClickLeftIcon: Function as PropType, - onClickRightFirstIcon: Function as PropType, - onClickRightSecondIcon: Function as PropType + onClickLeftIcon: Function as unknown as PropType, + onClickRightFirstIcon: Function as unknown as PropType, + onClickRightSecondIcon: Function as unknown as PropType }, setup(props: AtNavBarProps, { attrs, slots }) { diff --git a/src/components/noticebar/index.ts b/src/components/noticebar/index.ts index ec1ff53b..5cb61e32 100644 --- a/src/components/noticebar/index.ts +++ b/src/components/noticebar/index.ts @@ -34,8 +34,8 @@ const AtNoticebar = defineComponent({ }, icon: String as PropType, // events - onClose: Function as PropType, - onGotoMore: Function as PropType + onClose: Function as unknown as PropType, + onGotoMore: Function as unknown as PropType }, setup(props: AtNoticeBarProps, { attrs, slots }) { diff --git a/src/components/pagination/index.ts b/src/components/pagination/index.ts index e4671b79..5f7042e0 100644 --- a/src/components/pagination/index.ts +++ b/src/components/pagination/index.ts @@ -23,7 +23,7 @@ const AtPagination = defineComponent({ current: { type: Number, default: 1 }, pageSize: { type: Number, default: 20 }, icon: { type: Boolean, default: false }, - onPageChange: Function as PropType, + onPageChange: Function as unknown as PropType, }, setup(props: AtPaginationProps, { attrs, slots }) { diff --git a/src/components/radio/index.ts b/src/components/radio/index.ts index 9d9051c5..5cacd0fe 100644 --- a/src/components/radio/index.ts +++ b/src/components/radio/index.ts @@ -16,7 +16,7 @@ const AtRadio = defineComponent({ type: Array as PropType['options']>, default: [] }, - onClick: Function as PropType['onClick']> + onClick: Function as unknown as PropType['onClick']> }, setup(props: AtRadioProps, { attrs, emit }) { diff --git a/src/components/range/index.ts b/src/components/range/index.ts index 72c74913..1e3820b5 100644 --- a/src/components/range/index.ts +++ b/src/components/range/index.ts @@ -44,8 +44,8 @@ const AtRange = defineComponent({ type: Boolean, default: false }, - onChange: Function as PropType, - onAfterChange: Function as PropType, + onChange: Function as unknown as PropType, + onAfterChange: Function as unknown as PropType, }, setup(props: AtRangeProps, { attrs }) { diff --git a/src/components/rate/index.ts b/src/components/rate/index.ts index 45600261..8ba14b5c 100644 --- a/src/components/rate/index.ts +++ b/src/components/rate/index.ts @@ -39,7 +39,7 @@ const AtRate = defineComponent({ default: 'star' }, color: String, - onChange: Function as PropType + onChange: Function as unknown as PropType }, setup(props: AtRateProps, { attrs, emit }) { diff --git a/src/components/search-bar/index.ts b/src/components/search-bar/index.ts index 1bf1ae6d..b14c76ec 100644 --- a/src/components/search-bar/index.ts +++ b/src/components/search-bar/index.ts @@ -45,12 +45,12 @@ const AtSearchBar = defineComponent({ type: String as PropType, default: 'text' }, - onChange: Function as PropType, - onFocus: Function as PropType, - onBlur: Function as PropType, - onConfirm: Function as PropType, - onActionClick: Function as PropType, - onClear: Function as PropType, + onChange: Function as unknown as PropType, + onFocus: Function as unknown as PropType, + onBlur: Function as unknown as PropType, + onConfirm: Function as unknown as PropType, + onActionClick: Function as unknown as PropType, + onClear: Function as unknown as PropType, }, setup(props: AtSearchBarProps, { attrs, emit }) { diff --git a/src/components/segmented-control/index.ts b/src/components/segmented-control/index.ts index c5d7b624..0e47099d 100644 --- a/src/components/segmented-control/index.ts +++ b/src/components/segmented-control/index.ts @@ -37,7 +37,7 @@ const AtSegmentedControl = defineComponent({ default: [] }, onClick: { - type: Function as PropType, + type: Function as unknown as PropType, default: () => (index: number, event: CommonEvent) => { } }, }, diff --git a/src/components/slider/index.ts b/src/components/slider/index.ts index 03a8d4a1..2e27ceaf 100644 --- a/src/components/slider/index.ts +++ b/src/components/slider/index.ts @@ -49,11 +49,11 @@ const AtSlider = defineComponent({ default: false }, onChange: { - type: Function as PropType, + type: Function as unknown as PropType, default: () => (value: number) => { } }, onChanging: { - type: Function as PropType, + type: Function as unknown as PropType, default: () => (value: number) => { } }, }, diff --git a/src/components/steps/index.ts b/src/components/steps/index.ts index 69cd7130..478c0a26 100644 --- a/src/components/steps/index.ts +++ b/src/components/steps/index.ts @@ -16,7 +16,7 @@ const AtSteps = defineComponent({ default: [] }, onChange: { - type: Function as PropType, + type: Function as unknown as PropType, default: () => (current: number, event: CommonEvent) => { } }, }, diff --git a/src/components/swipe-action/index.ts b/src/components/swipe-action/index.ts index 9eadda7e..9ffce93b 100644 --- a/src/components/swipe-action/index.ts +++ b/src/components/swipe-action/index.ts @@ -27,9 +27,9 @@ const AtSwipeAction = defineComponent({ type: Array as PropType, default: () => [] }, - onClick: Function as PropType, - onOpened: Function as PropType, - onClosed: Function as PropType, + onClick: Function as unknown as PropType, + onOpened: Function as unknown as PropType, + onClosed: Function as unknown as PropType, }, setup(props: AtSwipeActionProps, { attrs, slots }) { diff --git a/src/components/swipe-action/options/index.ts b/src/components/swipe-action/options/index.ts index da115cde..423407eb 100644 --- a/src/components/swipe-action/options/index.ts +++ b/src/components/swipe-action/options/index.ts @@ -16,7 +16,7 @@ const AtSwipeActionOptions = defineComponent({ default: [] }, onQueryedDom: { - type: Function as PropType, + type: Function as unknown as PropType, default: () => ({ width }: { width: number }) => { } }, }, diff --git a/src/components/switch/index.ts b/src/components/switch/index.ts index 46abe3e0..edf035a8 100644 --- a/src/components/switch/index.ts +++ b/src/components/switch/index.ts @@ -20,7 +20,7 @@ const AtSwitch = defineComponent({ checked: Boolean, disabled: Boolean, border: Boolean, - onChange: Function as PropType, + onChange: Function as unknown as PropType, }, setup(props: AtSwitchProps, { attrs, emit }) { diff --git a/src/components/tab-bar/index.ts b/src/components/tab-bar/index.ts index 42b89f16..9ccbc29d 100644 --- a/src/components/tab-bar/index.ts +++ b/src/components/tab-bar/index.ts @@ -49,7 +49,7 @@ const AtTabBar = defineComponent({ default: [] }, onClick: { - type: Function as PropType, + type: Function as unknown as PropType, default: () => (index: number, event: CommonEvent) => { } } }, diff --git a/src/components/tabs/index.ts b/src/components/tabs/index.ts index 36210dd4..5ac46726 100644 --- a/src/components/tabs/index.ts +++ b/src/components/tabs/index.ts @@ -42,7 +42,7 @@ const AtTabs = defineComponent({ default: [] }, onClick: { - type: Function as PropType, + type: Function as unknown as PropType, default: () => (index: number, event: CommonEvent) => { } }, }, diff --git a/src/components/tag/index.ts b/src/components/tag/index.ts index d0aada27..5ec60bc3 100644 --- a/src/components/tag/index.ts +++ b/src/components/tag/index.ts @@ -42,7 +42,7 @@ const AtTag = defineComponent({ type: Boolean, default: false }, - onClick: Function as PropType, + onClick: Function as unknown as PropType, }, setup(props: AtTagProps, { attrs, slots }) { diff --git a/src/components/textarea/index.ts b/src/components/textarea/index.ts index 0d237542..9b913e4c 100644 --- a/src/components/textarea/index.ts +++ b/src/components/textarea/index.ts @@ -51,11 +51,11 @@ const AtTextarea = defineComponent({ height: { type: [String, Number], default: 100 }, cursorSpacing: { type: Number, default: 100 }, // event handlers - onChange: Function as PropType, - onFocus: Function as PropType, - onBlur: Function as PropType, - onConfirm: Function as PropType, - onLinechange: Function as PropType, + onChange: Function as unknown as PropType, + onFocus: Function as unknown as PropType, + onBlur: Function as unknown as PropType, + onConfirm: Function as unknown as PropType, + onLinechange: Function as unknown as PropType, }, setup(props: AtTextareaProps, { attrs, emit }) { diff --git a/src/components/toast/index.ts b/src/components/toast/index.ts index 4ff940ea..7b58f6c6 100644 --- a/src/components/toast/index.ts +++ b/src/components/toast/index.ts @@ -20,8 +20,8 @@ const AtToast = defineComponent({ }, duration: { type: Number, default: 3000 }, hasMask: Boolean, - onClick: Function as PropType, - onClose: Function as PropType, + onClick: Function as unknown as PropType, + onClose: Function as unknown as PropType, }, setup(props: AtToastProps, { attrs }) { diff --git a/src/components/virtual-scroll/index.ts b/src/components/virtual-scroll/index.ts index 1a0c2389..8b856e81 100644 --- a/src/components/virtual-scroll/index.ts +++ b/src/components/virtual-scroll/index.ts @@ -52,8 +52,8 @@ const AtVirtualScroll = defineComponent({ type: [Number, String] as PropType, default: 50 }, - onReachTop: Function as PropType, - onReachBottom: Function as PropType, + onReachTop: Function as unknown as PropType, + onReachBottom: Function as unknown as PropType, }, setup(props: AtVirtualScrollProps, { slots }) { diff --git a/types/calendar.d.ts b/types/calendar.d.ts index a9d7c45c..63286709 100644 --- a/types/calendar.d.ts +++ b/types/calendar.d.ts @@ -22,7 +22,7 @@ declare namespace Calendar { export interface Item { value: string - _value: dayjs.Dayjs + _value?: dayjs.Dayjs text: number diff --git a/yarn.lock b/yarn.lock index 0d11fe4a..f2247391 100644 --- a/yarn.lock +++ b/yarn.lock @@ -266,6 +266,11 @@ resolved "https://registry.npm.taobao.org/@babel/parser/download/@babel/parser-7.13.10.tgz?cache=0&sync_timestamp=1615243067115&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40babel%2Fparser%2Fdownload%2F%40babel%2Fparser-7.13.10.tgz#8f8f9bf7b3afa3eabd061f7a5bcdf4fec3c48409" integrity sha1-j4+b97Ovo+q9Bh96W830/sPEhAk= +"@babel/parser@^7.13.9": + version "7.13.13" + resolved "https://registry.npm.taobao.org/@babel/parser/download/@babel/parser-7.13.13.tgz#42f03862f4aed50461e543270916b47dd501f0df" + integrity sha1-QvA4YvSu1QRh5UMnCRa0fdUB8N8= + "@babel/plugin-proposal-async-generator-functions@^7.10.4": version "7.13.8" resolved "https://registry.npm.taobao.org/@babel/plugin-proposal-async-generator-functions/download/@babel/plugin-proposal-async-generator-functions-7.13.8.tgz?cache=0&sync_timestamp=1614383147950&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40babel%2Fplugin-proposal-async-generator-functions%2Fdownload%2F%40babel%2Fplugin-proposal-async-generator-functions-7.13.8.tgz#87aacb574b3bc4b5603f6fe41458d72a5a2ec4b1" @@ -1310,6 +1315,14 @@ estree-walker "^1.0.1" picomatch "^2.2.2" +"@rollup/pluginutils@^4.1.0": + version "4.1.0" + resolved "https://registry.npm.taobao.org/@rollup/pluginutils/download/@rollup/pluginutils-4.1.0.tgz?cache=0&sync_timestamp=1603765613301&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40rollup%2Fpluginutils%2Fdownload%2F%40rollup%2Fpluginutils-4.1.0.tgz#0dcc61c780e39257554feb7f77207dceca13c838" + integrity sha1-Dcxhx4DjkldVT+t/dyB9zsoTyDg= + dependencies: + estree-walker "^2.0.1" + picomatch "^2.2.2" + "@sinonjs/commons@^1.7.0": version "1.8.2" resolved "https://registry.npm.taobao.org/@sinonjs/commons/download/@sinonjs/commons-1.8.2.tgz?cache=0&sync_timestamp=1610537579259&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40sinonjs%2Fcommons%2Fdownload%2F%40sinonjs%2Fcommons-1.8.2.tgz#858f5c4b48d80778fde4b9d541f27edc0d56488b" @@ -1983,36 +1996,36 @@ html-tags "^3.1.0" svg-tags "^1.0.0" -"@vue/compiler-core@3.0.7": - version "3.0.7" - resolved "https://registry.npm.taobao.org/@vue/compiler-core/download/@vue/compiler-core-3.0.7.tgz?cache=0&sync_timestamp=1614614485985&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40vue%2Fcompiler-core%2Fdownload%2F%40vue%2Fcompiler-core-3.0.7.tgz#421782a4c67cc3f2b7c30457ef446d74f8524f74" - integrity sha1-QheCpMZ8w/K3wwRX70RtdPhST3Q= +"@vue/compiler-core@3.0.11": + version "3.0.11" + resolved "https://registry.npm.taobao.org/@vue/compiler-core/download/@vue/compiler-core-3.0.11.tgz#5ef579e46d7b336b8735228758d1c2c505aae69a" + integrity sha1-XvV55G17M2uHNSKHWNHCxQWq5po= dependencies: "@babel/parser" "^7.12.0" "@babel/types" "^7.12.0" - "@vue/shared" "3.0.7" + "@vue/shared" "3.0.11" estree-walker "^2.0.1" source-map "^0.6.1" -"@vue/compiler-dom@3.0.7": - version "3.0.7" - resolved "https://registry.npm.taobao.org/@vue/compiler-dom/download/@vue/compiler-dom-3.0.7.tgz?cache=0&sync_timestamp=1614614688376&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40vue%2Fcompiler-dom%2Fdownload%2F%40vue%2Fcompiler-dom-3.0.7.tgz#54d2e12fb9a7aff53abd19dac2c2679533f0c919" - integrity sha1-VNLhL7mnr/U6vRnawsJnlTPwyRk= +"@vue/compiler-dom@3.0.11": + version "3.0.11" + resolved "https://registry.npm.taobao.org/@vue/compiler-dom/download/@vue/compiler-dom-3.0.11.tgz#b15fc1c909371fd671746020ba55b5dab4a730ee" + integrity sha1-sV/ByQk3H9ZxdGAgulW12rSnMO4= dependencies: - "@vue/compiler-core" "3.0.7" - "@vue/shared" "3.0.7" + "@vue/compiler-core" "3.0.11" + "@vue/shared" "3.0.11" -"@vue/compiler-sfc@^3.0.6": - version "3.0.7" - resolved "https://registry.npm.taobao.org/@vue/compiler-sfc/download/@vue/compiler-sfc-3.0.7.tgz?cache=0&sync_timestamp=1614614689770&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40vue%2Fcompiler-sfc%2Fdownload%2F%40vue%2Fcompiler-sfc-3.0.7.tgz#900414750cc726553b870490f48073451fd14f07" - integrity sha1-kAQUdQzHJlU7hwSQ9IBzRR/RTwc= +"@vue/compiler-sfc@^3.0.9": + version "3.0.11" + resolved "https://registry.npm.taobao.org/@vue/compiler-sfc/download/@vue/compiler-sfc-3.0.11.tgz#cd8ca2154b88967b521f5ad3b10f5f8b6b665679" + integrity sha1-zYyiFUuIlntSH1rTsQ9fi2tmVnk= dependencies: - "@babel/parser" "^7.12.0" - "@babel/types" "^7.12.0" - "@vue/compiler-core" "3.0.7" - "@vue/compiler-dom" "3.0.7" - "@vue/compiler-ssr" "3.0.7" - "@vue/shared" "3.0.7" + "@babel/parser" "^7.13.9" + "@babel/types" "^7.13.0" + "@vue/compiler-core" "3.0.11" + "@vue/compiler-dom" "3.0.11" + "@vue/compiler-ssr" "3.0.11" + "@vue/shared" "3.0.11" consolidate "^0.16.0" estree-walker "^2.0.1" hash-sum "^2.0.0" @@ -2024,42 +2037,42 @@ postcss-selector-parser "^6.0.4" source-map "^0.6.1" -"@vue/compiler-ssr@3.0.7": - version "3.0.7" - resolved "https://registry.npm.taobao.org/@vue/compiler-ssr/download/@vue/compiler-ssr-3.0.7.tgz?cache=0&sync_timestamp=1614614487268&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40vue%2Fcompiler-ssr%2Fdownload%2F%40vue%2Fcompiler-ssr-3.0.7.tgz#28b85d497381d75fe44234057b140b0065ca9dbf" - integrity sha1-KLhdSXOB11/kQjQFexQLAGXKnb8= +"@vue/compiler-ssr@3.0.11": + version "3.0.11" + resolved "https://registry.npm.taobao.org/@vue/compiler-ssr/download/@vue/compiler-ssr-3.0.11.tgz#ac5a05fd1257412fa66079c823d8203b6a889a13" + integrity sha1-rFoF/RJXQS+mYHnII9ggO2qImhM= dependencies: - "@vue/compiler-dom" "3.0.7" - "@vue/shared" "3.0.7" + "@vue/compiler-dom" "3.0.11" + "@vue/shared" "3.0.11" -"@vue/reactivity@3.0.7": - version "3.0.7" - resolved "https://registry.npm.taobao.org/@vue/reactivity/download/@vue/reactivity-3.0.7.tgz?cache=0&sync_timestamp=1614614692200&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40vue%2Freactivity%2Fdownload%2F%40vue%2Freactivity-3.0.7.tgz#e6ccc7bef7fc10b0972e4d974bad71679d3b26ad" - integrity sha1-5szHvvf8ELCXLk2XS61xZ507Jq0= +"@vue/reactivity@3.0.11": + version "3.0.11" + resolved "https://registry.npm.taobao.org/@vue/reactivity/download/@vue/reactivity-3.0.11.tgz?cache=0&sync_timestamp=1617321201900&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40vue%2Freactivity%2Fdownload%2F%40vue%2Freactivity-3.0.11.tgz#07b588349fd05626b17f3500cbef7d4bdb4dbd0b" + integrity sha1-B7WINJ/QViaxfzUAy+99S9tNvQs= dependencies: - "@vue/shared" "3.0.7" + "@vue/shared" "3.0.11" -"@vue/runtime-core@3.0.7": - version "3.0.7" - resolved "https://registry.npm.taobao.org/@vue/runtime-core/download/@vue/runtime-core-3.0.7.tgz?cache=0&sync_timestamp=1614614696507&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40vue%2Fruntime-core%2Fdownload%2F%40vue%2Fruntime-core-3.0.7.tgz#d44c0b0a57d7e392912a87362a4430ccf446ecea" - integrity sha1-1EwLClfX45KRKoc2KkQwzPRG7Oo= +"@vue/runtime-core@3.0.11": + version "3.0.11" + resolved "https://registry.npm.taobao.org/@vue/runtime-core/download/@vue/runtime-core-3.0.11.tgz#c52dfc6acf3215493623552c1c2919080c562e44" + integrity sha1-xS38as8yFUk2I1UsHCkZCAxWLkQ= dependencies: - "@vue/reactivity" "3.0.7" - "@vue/shared" "3.0.7" + "@vue/reactivity" "3.0.11" + "@vue/shared" "3.0.11" -"@vue/runtime-dom@3.0.7": - version "3.0.7" - resolved "https://registry.npm.taobao.org/@vue/runtime-dom/download/@vue/runtime-dom-3.0.7.tgz?cache=0&sync_timestamp=1614614488383&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40vue%2Fruntime-dom%2Fdownload%2F%40vue%2Fruntime-dom-3.0.7.tgz#b70668d729020bc4ad608c20367223f259576ba6" - integrity sha1-twZo1ykCC8StYIwgNnIj8llXa6Y= +"@vue/runtime-dom@3.0.11": + version "3.0.11" + resolved "https://registry.npm.taobao.org/@vue/runtime-dom/download/@vue/runtime-dom-3.0.11.tgz?cache=0&sync_timestamp=1617322690018&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40vue%2Fruntime-dom%2Fdownload%2F%40vue%2Fruntime-dom-3.0.11.tgz#7a552df21907942721feb6961c418e222a699337" + integrity sha1-elUt8hkHlCch/raWHEGOIippkzc= dependencies: - "@vue/runtime-core" "3.0.7" - "@vue/shared" "3.0.7" + "@vue/runtime-core" "3.0.11" + "@vue/shared" "3.0.11" csstype "^2.6.8" -"@vue/shared@3.0.7": - version "3.0.7" - resolved "https://registry.npm.taobao.org/@vue/shared/download/@vue/shared-3.0.7.tgz?cache=0&sync_timestamp=1614614487890&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40vue%2Fshared%2Fdownload%2F%40vue%2Fshared-3.0.7.tgz#96d52988efc07444c108c7c6803ba7cc93e40045" - integrity sha1-ltUpiO/AdETBCMfGgDunzJPkAEU= +"@vue/shared@3.0.11": + version "3.0.11" + resolved "https://registry.npm.taobao.org/@vue/shared/download/@vue/shared-3.0.11.tgz?cache=0&sync_timestamp=1617321216740&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40vue%2Fshared%2Fdownload%2F%40vue%2Fshared-3.0.11.tgz#20d22dd0da7d358bb21c17f9bde8628152642c77" + integrity sha1-INIt0Np9NYuyHBf5vehigVJkLHc= "@vue/test-utils@2.0.0-rc.0": version "2.0.0-rc.0" @@ -4589,10 +4602,10 @@ es6-symbol@^3.1.1, es6-symbol@~3.1.3: d "^1.0.1" ext "^1.1.2" -esbuild@^0.9.0: - version "0.9.2" - resolved "https://registry.npm.taobao.org/esbuild/download/esbuild-0.9.2.tgz?cache=0&sync_timestamp=1615581516132&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fesbuild%2Fdownload%2Fesbuild-0.9.2.tgz#7e9fde247c913ed8ee059e2648b0c53f7d00abe5" - integrity sha1-fp/eJHyRPtjuBZ4mSLDFP30Aq+U= +esbuild@^0.11.0: + version "0.11.5" + resolved "https://registry.npm.taobao.org/esbuild/download/esbuild-0.11.5.tgz#25b18a2ff2fb9580683edce26a48f64c08c2f2df" + integrity sha1-JbGKL/L7lYBoPtziakj2TAjC8t8= escalade@^3.1.1: version "3.1.1" @@ -9864,14 +9877,7 @@ resolve@1.15.1: dependencies: path-parse "^1.0.6" -resolve@1.17.0: - version "1.17.0" - resolved "https://registry.npm.taobao.org/resolve/download/resolve-1.17.0.tgz#b25941b54968231cc2d1bb76a79cb7f2c0bf8444" - integrity sha1-sllBtUloIxzC0bt2p5y38sC/hEQ= - dependencies: - path-parse "^1.0.6" - -resolve@^1.1.6, resolve@^1.1.7, resolve@^1.10.0, resolve@^1.11.1, resolve@^1.12.0, resolve@^1.17.0, resolve@^1.18.1, resolve@^1.3.2, resolve@^1.5.0, resolve@^1.8.1: +resolve@1.20.0, resolve@^1.1.6, resolve@^1.1.7, resolve@^1.10.0, resolve@^1.11.1, resolve@^1.12.0, resolve@^1.17.0, resolve@^1.18.1, resolve@^1.3.2, resolve@^1.5.0, resolve@^1.8.1: version "1.20.0" resolved "https://registry.npm.taobao.org/resolve/download/resolve-1.20.0.tgz#629a013fb3f70755d6f0b7935cc1c2c5378b1975" integrity sha1-YpoBP7P3B1XW8LeTXMHCxTeLGXU= @@ -9975,16 +9981,16 @@ rollup-plugin-sass@^1.2.2: rollup-pluginutils ">= 1.3.1" sass "1.7.2" -rollup-plugin-typescript2@^0.27.2: - version "0.27.3" - resolved "https://registry.npm.taobao.org/rollup-plugin-typescript2/download/rollup-plugin-typescript2-0.27.3.tgz#cd9455ac026d325b20c5728d2cc54a08a771b68b" - integrity sha1-zZRVrAJtMlsgxXKNLMVKCKdxtos= +rollup-plugin-typescript2@0.30.0: + version "0.30.0" + resolved "https://registry.npm.taobao.org/rollup-plugin-typescript2/download/rollup-plugin-typescript2-0.30.0.tgz#1cc99ac2309bf4b9d0a3ebdbc2002aecd56083d3" + integrity sha1-HMmawjCb9LnQo+vbwgAq7NVgg9M= dependencies: - "@rollup/pluginutils" "^3.1.0" + "@rollup/pluginutils" "^4.1.0" find-cache-dir "^3.3.1" fs-extra "8.1.0" - resolve "1.17.0" - tslib "2.0.1" + resolve "1.20.0" + tslib "2.1.0" "rollup-pluginutils@>= 1.3.1": version "2.8.2" @@ -11380,16 +11386,21 @@ tsconfig@^7.0.0: strip-bom "^3.0.0" strip-json-comments "^2.0.0" -tslib@2.0.1: - version "2.0.1" - resolved "https://registry.npm.taobao.org/tslib/download/tslib-2.0.1.tgz?cache=0&sync_timestamp=1609887446200&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Ftslib%2Fdownload%2Ftslib-2.0.1.tgz#410eb0d113e5b6356490eec749603725b021b43e" - integrity sha1-QQ6w0RPltjVkkO7HSWA3JbAhtD4= +tslib@2.1.0: + version "2.1.0" + resolved "https://registry.npm.taobao.org/tslib/download/tslib-2.1.0.tgz?cache=0&sync_timestamp=1617647331485&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Ftslib%2Fdownload%2Ftslib-2.1.0.tgz#da60860f1c2ecaa5703ab7d39bc05b6bf988b97a" + integrity sha1-2mCGDxwuyqVwOrfTm8Bba/mIuXo= tslib@^1.10.0, tslib@^1.8.1, tslib@^1.9.0: version "1.14.1" resolved "https://registry.npm.taobao.org/tslib/download/tslib-1.14.1.tgz?cache=0&sync_timestamp=1609887446200&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Ftslib%2Fdownload%2Ftslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00" integrity sha1-zy04vcNKE0vK8QkcQfZhni9nLQA= +tslib@^2.1.0: + version "2.2.0" + resolved "https://registry.npm.taobao.org/tslib/download/tslib-2.2.0.tgz?cache=0&sync_timestamp=1617647331485&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Ftslib%2Fdownload%2Ftslib-2.2.0.tgz#fb2c475977e35e241311ede2693cee1ec6698f5c" + integrity sha1-+yxHWXfjXiQTEe3iaTzuHsZpj1w= + tsutils@^3.17.1: version "3.21.0" resolved "https://registry.npm.taobao.org/tsutils/download/tsutils-3.21.0.tgz?cache=0&sync_timestamp=1615138068192&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Ftsutils%2Fdownload%2Ftsutils-3.21.0.tgz#b48717d394cea6c1e096983eed58e9d61715b623" @@ -11471,10 +11482,10 @@ typedarray@^0.0.6: resolved "https://registry.npm.taobao.org/typedarray/download/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= -typescript@^3.7.0: - version "3.9.9" - resolved "https://registry.npm.taobao.org/typescript/download/typescript-3.9.9.tgz?cache=0&sync_timestamp=1615620825867&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Ftypescript%2Fdownload%2Ftypescript-3.9.9.tgz#e69905c54bc0681d0518bd4d587cc6f2d0b1a674" - integrity sha1-5pkFxUvAaB0FGL1NWHzG8tCxpnQ= +typescript@4.2.3: + version "4.2.3" + resolved "https://registry.npm.taobao.org/typescript/download/typescript-4.2.3.tgz?cache=0&sync_timestamp=1617693588914&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Ftypescript%2Fdownload%2Ftypescript-4.2.3.tgz#39062d8019912d43726298f09493d598048c1ce3" + integrity sha1-OQYtgBmRLUNyYpjwlJPVmASMHOM= uglify-js@3.4.x: version "3.4.10" @@ -11862,14 +11873,14 @@ vue-loader@^16.1.0: hash-sum "^2.0.0" loader-utils "^2.0.0" -vue@^3.0.6: - version "3.0.7" - resolved "https://registry.npm.taobao.org/vue/download/vue-3.0.7.tgz?cache=0&sync_timestamp=1614614622087&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fvue%2Fdownload%2Fvue-3.0.7.tgz#8bcff51f8be570f9e4ce8cc5f52e2ab0fe3c74a1" - integrity sha1-i8/1H4vlcPnkzozF9S4qsP48dKE= +vue@^3.0.9: + version "3.0.11" + resolved "https://registry.npm.taobao.org/vue/download/vue-3.0.11.tgz?cache=0&sync_timestamp=1617321643721&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fvue%2Fdownload%2Fvue-3.0.11.tgz#c82f9594cbf4dcc869241d4c8dd3e08d9a8f4b5f" + integrity sha1-yC+VlMv03MhpJB1MjdPgjZqPS18= dependencies: - "@vue/compiler-dom" "3.0.7" - "@vue/runtime-dom" "3.0.7" - "@vue/shared" "3.0.7" + "@vue/compiler-dom" "3.0.11" + "@vue/runtime-dom" "3.0.11" + "@vue/shared" "3.0.11" w3c-hr-time@^1.0.1, w3c-hr-time@^1.0.2: version "1.0.2" From 0f798b11c78ab36c111e33a14c0f9c7ce76dc838 Mon Sep 17 00:00:00 2001 From: Ken Ho Date: Mon, 12 Apr 2021 17:54:34 +0800 Subject: [PATCH 18/23] chore: update dep versions --- package.json | 22 ++-- yarn.lock | 292 +++++++++++++++++++++++++-------------------------- 2 files changed, 153 insertions(+), 161 deletions(-) diff --git a/package.json b/package.json index c986f0e1..c10e345e 100644 --- a/package.json +++ b/package.json @@ -80,27 +80,27 @@ "lodash-es": "^4.17.15" }, "peerDependencies": { - "@tarojs/components": "^3.1.4", - "@tarojs/taro": "^3.1.4", - "vue": "^3.0.9" + "@tarojs/components": "^3.2.1", + "@tarojs/taro": "^3.2.1", + "vue": "^3.0.10" }, "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.1.4", - "@tarojs/mini-runner": "^3.1.4", - "@tarojs/runtime": "^3.1.4", - "@tarojs/taro": "^3.1.4", - "@tarojs/webpack-runner": "^3.1.4", + "@tarojs/components": "^3.2.1", + "@tarojs/mini-runner": "^3.2.1", + "@tarojs/runtime": "^3.2.1", + "@tarojs/taro": "^3.2.1", + "@tarojs/webpack-runner": "^3.2.1", "@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.9", + "@vue/compiler-sfc": "^3.0.10", "@vue/test-utils": "2.0.0-rc.0", "babel-preset-taro": "^3.0.5", "cross-env": "^7.0.2", @@ -124,9 +124,9 @@ "ts-loader": "^8.0.2", "tslib": "^2.1.0", "typescript": "^4.2.0", - "vue": "^3.0.9", + "vue": "^3.0.10", "vue-jest": "^5.0.0-alpha.7", "vue-loader": "^16.1.0", "webpack-bundle-analyzer": "^4.2.0" } -} +} \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index f2247391..6cb69447 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1349,20 +1349,20 @@ dependencies: "@tarojs/runtime" "3.1.3" -"@tarojs/api@3.1.4": - version "3.1.4" - resolved "https://registry.npm.taobao.org/@tarojs/api/download/@tarojs/api-3.1.4.tgz?cache=0&sync_timestamp=1615810120602&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40tarojs%2Fapi%2Fdownload%2F%40tarojs%2Fapi-3.1.4.tgz#ed8beb8792ac9d8dac5a4c6dae166f3dd74b1910" - integrity sha1-7Yvrh5KsnY2sWkxtrhZvPddLGRA= +"@tarojs/api@3.2.1": + version "3.2.1" + resolved "https://registry.npm.taobao.org/@tarojs/api/download/@tarojs/api-3.2.1.tgz#01d39c1b86ea9e9ee9d7ca2e2041bea9756046e0" + integrity sha1-AdOcG4bqnp7p18ouIEG+qXVgRuA= dependencies: - "@tarojs/runtime" "3.1.4" + "@tarojs/runtime" "3.2.1" -"@tarojs/components@3.1.4", "@tarojs/components@^3.1.4": - version "3.1.4" - resolved "https://registry.npm.taobao.org/@tarojs/components/download/@tarojs/components-3.1.4.tgz?cache=0&sync_timestamp=1616124415764&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40tarojs%2Fcomponents%2Fdownload%2F%40tarojs%2Fcomponents-3.1.4.tgz#e3cb48d777f8a2585918e1789a36a6ffec8b73b0" - integrity sha1-48tI13f4olhZGOF4mjam/+yLc7A= +"@tarojs/components@3.2.1", "@tarojs/components@^3.2.1": + version "3.2.1" + resolved "https://registry.npm.taobao.org/@tarojs/components/download/@tarojs/components-3.2.1.tgz#db70af6752afbc3af6f0359bbe197660327d30bb" + integrity sha1-23CvZ1KvvDr28DWbvhl2YDJ9MLs= dependencies: "@stencil/core" "2.4.0" - "@tarojs/taro" "3.1.4" + "@tarojs/taro" "3.2.1" better-scroll "^1.14.1" classnames "^2.2.5" intersection-observer "^0.7.0" @@ -1371,10 +1371,10 @@ swiper "4.4.2" weui "^1.1.2" -"@tarojs/helper@3.1.4": - version "3.1.4" - resolved "https://registry.npm.taobao.org/@tarojs/helper/download/@tarojs/helper-3.1.4.tgz#ec0b5e58d429c64a40caf0cbd825058e83792f5c" - integrity sha1-7AteWNQpxkpAyvDL2CUFjoN5L1w= +"@tarojs/helper@3.2.1": + version "3.2.1" + resolved "https://registry.npm.taobao.org/@tarojs/helper/download/@tarojs/helper-3.2.1.tgz#6321bfc36eb6ea7ade1fa43745052eff59ea7731" + integrity sha1-YyG/w2626nreH6Q3RQUu/1nqdzE= dependencies: "@babel/core" "7.11.1" "@babel/plugin-proposal-class-properties" "7.10.4" @@ -1385,7 +1385,7 @@ "@babel/preset-typescript" "7.12.17" "@babel/register" "7.9.0" "@babel/runtime" "7.9.2" - "@tarojs/taro" "3.1.4" + "@tarojs/taro" "3.2.1" chalk "3.0.0" chokidar "3.3.1" cross-spawn "7.0.3" @@ -1396,26 +1396,26 @@ resolve "1.15.1" yauzl "2.10.0" -"@tarojs/mini-runner@^3.1.4": - version "3.1.4" - resolved "https://registry.npm.taobao.org/@tarojs/mini-runner/download/@tarojs/mini-runner-3.1.4.tgz#bf916db9fd5e06e4c999ef80c325da85b13ecd63" - integrity sha1-v5Ftuf1eBuTJme+AwyXahbE+zWM= +"@tarojs/mini-runner@^3.2.1": + version "3.2.1" + resolved "https://registry.npm.taobao.org/@tarojs/mini-runner/download/@tarojs/mini-runner-3.2.1.tgz#da10ec6710869d0ef6d8f8860f562abdf688978d" + integrity sha1-2hDsZxCGnQ722PiGD1YqvfaIl40= dependencies: "@babel/core" "7.11.1" "@babel/plugin-proposal-class-properties" "7.10.4" "@babel/preset-env" "7.11.0" - "@tarojs/helper" "3.1.4" - "@tarojs/plugin-platform-alipay" "3.1.4" - "@tarojs/plugin-platform-jd" "3.1.4" - "@tarojs/plugin-platform-qq" "3.1.4" - "@tarojs/plugin-platform-swan" "3.1.4" - "@tarojs/plugin-platform-tt" "3.1.4" - "@tarojs/plugin-platform-weapp" "3.1.4" - "@tarojs/runner-utils" "3.1.4" - "@tarojs/runtime" "3.1.4" - "@tarojs/shared" "3.1.4" - "@tarojs/taro" "3.1.4" - "@tarojs/taro-loader" "3.1.4" + "@tarojs/helper" "3.2.1" + "@tarojs/plugin-platform-alipay" "3.2.1" + "@tarojs/plugin-platform-jd" "3.2.1" + "@tarojs/plugin-platform-qq" "3.2.1" + "@tarojs/plugin-platform-swan" "3.2.1" + "@tarojs/plugin-platform-tt" "3.2.1" + "@tarojs/plugin-platform-weapp" "3.2.1" + "@tarojs/runner-utils" "3.2.1" + "@tarojs/runtime" "3.2.1" + "@tarojs/shared" "3.2.1" + "@tarojs/taro" "3.2.1" + "@tarojs/taro-loader" "3.2.1" babel-loader "8.0.6" babel-types "^6.26.0" copy-webpack-plugin "5.1.2" @@ -1438,7 +1438,7 @@ ora "^3.4.0" postcss-import "12.0.1" postcss-loader "^3.0.0" - postcss-pxtransform "^1.3.2" + postcss-pxtransform "3.2.1" postcss-url "8.0.0" regenerator-runtime "0.11" request "^2.88.0" @@ -1457,57 +1457,57 @@ webpack-format-messages "^2.0.5" yauzl "2.10.0" -"@tarojs/plugin-platform-alipay@3.1.4": - version "3.1.4" - resolved "https://registry.npm.taobao.org/@tarojs/plugin-platform-alipay/download/@tarojs/plugin-platform-alipay-3.1.4.tgz?cache=0&sync_timestamp=1615810126494&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40tarojs%2Fplugin-platform-alipay%2Fdownload%2F%40tarojs%2Fplugin-platform-alipay-3.1.4.tgz#858ec4e0961e9db9637f18830c8f58e16d76cc67" - integrity sha1-hY7E4JYenbljfxiDDI9Y4W12zGc= +"@tarojs/plugin-platform-alipay@3.2.1": + version "3.2.1" + resolved "https://registry.npm.taobao.org/@tarojs/plugin-platform-alipay/download/@tarojs/plugin-platform-alipay-3.2.1.tgz#17672df0a9ac15f861ad2df9e523280c81cb6bff" + integrity sha1-F2ct8KmsFfhhrS355SMoDIHLa/8= dependencies: - "@tarojs/components" "3.1.4" - "@tarojs/service" "3.1.4" - "@tarojs/shared" "3.1.4" + "@tarojs/components" "3.2.1" + "@tarojs/service" "3.2.1" + "@tarojs/shared" "3.2.1" -"@tarojs/plugin-platform-jd@3.1.4": - version "3.1.4" - resolved "https://registry.npm.taobao.org/@tarojs/plugin-platform-jd/download/@tarojs/plugin-platform-jd-3.1.4.tgz?cache=0&sync_timestamp=1615810125966&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40tarojs%2Fplugin-platform-jd%2Fdownload%2F%40tarojs%2Fplugin-platform-jd-3.1.4.tgz#0caeefd1d7758b2beaf4c329488eead65ec71617" - integrity sha1-DK7v0dd1iyvq9MMpSI7q1l7HFhc= +"@tarojs/plugin-platform-jd@3.2.1": + version "3.2.1" + resolved "https://registry.npm.taobao.org/@tarojs/plugin-platform-jd/download/@tarojs/plugin-platform-jd-3.2.1.tgz?cache=0&sync_timestamp=1618199871023&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40tarojs%2Fplugin-platform-jd%2Fdownload%2F%40tarojs%2Fplugin-platform-jd-3.2.1.tgz#c375aace2fadbc9ca77b0b2ec51eb7f99e16c693" + integrity sha1-w3Wqzi+tvJynewsuxR63+Z4WxpM= dependencies: - "@tarojs/service" "3.1.4" - "@tarojs/shared" "3.1.4" + "@tarojs/service" "3.2.1" + "@tarojs/shared" "3.2.1" -"@tarojs/plugin-platform-qq@3.1.4": - version "3.1.4" - resolved "https://registry.npm.taobao.org/@tarojs/plugin-platform-qq/download/@tarojs/plugin-platform-qq-3.1.4.tgz?cache=0&sync_timestamp=1615810121080&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40tarojs%2Fplugin-platform-qq%2Fdownload%2F%40tarojs%2Fplugin-platform-qq-3.1.4.tgz#07789040789903d70e38ff92becac5109cde0636" - integrity sha1-B3iQQHiZA9cOOP+SvsrFEJzeBjY= +"@tarojs/plugin-platform-qq@3.2.1": + version "3.2.1" + resolved "https://registry.npm.taobao.org/@tarojs/plugin-platform-qq/download/@tarojs/plugin-platform-qq-3.2.1.tgz?cache=0&sync_timestamp=1618199871641&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40tarojs%2Fplugin-platform-qq%2Fdownload%2F%40tarojs%2Fplugin-platform-qq-3.2.1.tgz#ed279a7da2ed32016151df1e38180e3f44c86668" + integrity sha1-7SeafaLtMgFhUd8eOBgOP0TIZmg= dependencies: - "@tarojs/plugin-platform-weapp" "3.1.4" - "@tarojs/service" "3.1.4" - "@tarojs/shared" "3.1.4" + "@tarojs/plugin-platform-weapp" "3.2.1" + "@tarojs/service" "3.2.1" + "@tarojs/shared" "3.2.1" -"@tarojs/plugin-platform-swan@3.1.4": - version "3.1.4" - resolved "https://registry.npm.taobao.org/@tarojs/plugin-platform-swan/download/@tarojs/plugin-platform-swan-3.1.4.tgz?cache=0&sync_timestamp=1615810124096&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40tarojs%2Fplugin-platform-swan%2Fdownload%2F%40tarojs%2Fplugin-platform-swan-3.1.4.tgz#f3c38b118c34d67024e5dca9c3c40670d252f56a" - integrity sha1-88OLEYw01nAk5dypw8QGcNJS9Wo= +"@tarojs/plugin-platform-swan@3.2.1": + version "3.2.1" + resolved "https://registry.npm.taobao.org/@tarojs/plugin-platform-swan/download/@tarojs/plugin-platform-swan-3.2.1.tgz#49842bd021dcf22ff900a889c3dc9c7cf240df88" + integrity sha1-SYQr0CHc8i/5AKiJw9ycfPJA34g= dependencies: - "@tarojs/components" "3.1.4" - "@tarojs/service" "3.1.4" - "@tarojs/shared" "3.1.4" + "@tarojs/components" "3.2.1" + "@tarojs/service" "3.2.1" + "@tarojs/shared" "3.2.1" -"@tarojs/plugin-platform-tt@3.1.4": - version "3.1.4" - resolved "https://registry.npm.taobao.org/@tarojs/plugin-platform-tt/download/@tarojs/plugin-platform-tt-3.1.4.tgz?cache=0&sync_timestamp=1615810126240&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40tarojs%2Fplugin-platform-tt%2Fdownload%2F%40tarojs%2Fplugin-platform-tt-3.1.4.tgz#37e6d7cdb26b8d02b6d2864d6078ac958e7ea854" - integrity sha1-N+bXzbJrjQK20oZNYHislY5+qFQ= +"@tarojs/plugin-platform-tt@3.2.1": + version "3.2.1" + resolved "https://registry.npm.taobao.org/@tarojs/plugin-platform-tt/download/@tarojs/plugin-platform-tt-3.2.1.tgz?cache=0&sync_timestamp=1618199871318&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40tarojs%2Fplugin-platform-tt%2Fdownload%2F%40tarojs%2Fplugin-platform-tt-3.2.1.tgz#9fcd39f1a267a76f8be78151406fd202d2b48d32" + integrity sha1-n8058aJnp2+L54FRQG/SAtK0jTI= dependencies: - "@tarojs/service" "3.1.4" - "@tarojs/shared" "3.1.4" + "@tarojs/service" "3.2.1" + "@tarojs/shared" "3.2.1" -"@tarojs/plugin-platform-weapp@3.1.4": - version "3.1.4" - resolved "https://registry.npm.taobao.org/@tarojs/plugin-platform-weapp/download/@tarojs/plugin-platform-weapp-3.1.4.tgz?cache=0&sync_timestamp=1615810119011&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40tarojs%2Fplugin-platform-weapp%2Fdownload%2F%40tarojs%2Fplugin-platform-weapp-3.1.4.tgz#ea0d0cf480882680707a33addfdc7a44f4d2827f" - integrity sha1-6g0M9ICIJoBwejOt39x6RPTSgn8= +"@tarojs/plugin-platform-weapp@3.2.1": + version "3.2.1" + resolved "https://registry.npm.taobao.org/@tarojs/plugin-platform-weapp/download/@tarojs/plugin-platform-weapp-3.2.1.tgz#8135b20990ba2eb396941e7701b4a91a5e469d59" + integrity sha1-gTWyCZC6LrOWlB53AbSpGl5GnVk= dependencies: - "@tarojs/components" "3.1.4" - "@tarojs/service" "3.1.4" - "@tarojs/shared" "3.1.4" + "@tarojs/components" "3.2.1" + "@tarojs/service" "3.2.1" + "@tarojs/shared" "3.2.1" "@tarojs/router@3.1.3": version "3.1.3" @@ -1520,24 +1520,24 @@ universal-router "^8.3.0" url-parse "^1.4.7" -"@tarojs/router@3.1.4": - version "3.1.4" - resolved "https://registry.npm.taobao.org/@tarojs/router/download/@tarojs/router-3.1.4.tgz#c38162740b9baa658ba57851194816f55b07998e" - integrity sha1-w4FidAubqmWLpXhRGUgW9VsHmY4= +"@tarojs/router@3.2.1": + version "3.2.1" + resolved "https://registry.npm.taobao.org/@tarojs/router/download/@tarojs/router-3.2.1.tgz#4ed9ad6b4f7a2cce9960eaba71e527f3f6ba6cbb" + integrity sha1-Ttmta096LM6ZYOq6ceUn8/a6bLs= dependencies: - "@tarojs/runtime" "3.1.4" + "@tarojs/runtime" "3.2.1" history "^4.10.1" query-string "^6.13.8" universal-router "^8.3.0" url-parse "^1.4.7" -"@tarojs/runner-utils@3.1.4": - version "3.1.4" - resolved "https://registry.npm.taobao.org/@tarojs/runner-utils/download/@tarojs/runner-utils-3.1.4.tgz#807cbb8a2eee7a4724c70ecad41eda798affef15" - integrity sha1-gHy7ii7uekckxw7K1B7aeYr/7xU= +"@tarojs/runner-utils@3.2.1": + version "3.2.1" + resolved "https://registry.npm.taobao.org/@tarojs/runner-utils/download/@tarojs/runner-utils-3.2.1.tgz#b8c8af3f6d6c8ed986f53f240906299f3a0d885e" + integrity sha1-uMivP21sjtmG9T8kCQYpnzoNiF4= dependencies: "@babel/core" "7.11.1" - "@tarojs/helper" "3.1.4" + "@tarojs/helper" "3.2.1" chalk "^3.0.0" fs-extra "^8.1.0" lodash "^4.17.15" @@ -1551,23 +1551,23 @@ "@tarojs/shared" "3.1.3" lodash-es "4.17.15" -"@tarojs/runtime@3.1.4", "@tarojs/runtime@^3.1.4": - version "3.1.4" - resolved "https://registry.npm.taobao.org/@tarojs/runtime/download/@tarojs/runtime-3.1.4.tgz?cache=0&sync_timestamp=1615810120141&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40tarojs%2Fruntime%2Fdownload%2F%40tarojs%2Fruntime-3.1.4.tgz#c8b4809bc8c13b58cd238e0d4eca0427f1fab2bb" - integrity sha1-yLSAm8jBO1jNI44NTsoEJ/H6srs= +"@tarojs/runtime@3.2.1", "@tarojs/runtime@^3.2.1": + version "3.2.1" + resolved "https://registry.npm.taobao.org/@tarojs/runtime/download/@tarojs/runtime-3.2.1.tgz#8d9d56f683cfcecfaebc6bb837ff786a19f412a2" + integrity sha1-jZ1W9oPPzs+uvGu4N/94ahn0EqI= dependencies: - "@tarojs/shared" "3.1.4" + "@tarojs/shared" "3.2.1" lodash-es "4.17.15" -"@tarojs/service@3.1.4": - version "3.1.4" - resolved "https://registry.npm.taobao.org/@tarojs/service/download/@tarojs/service-3.1.4.tgz#1d16df6d3809e2d57a910cd5193fd8cf7bdbe4f5" - integrity sha1-HRbfbTgJ4tV6kQzVGT/Yz3vb5PU= +"@tarojs/service@3.2.1": + version "3.2.1" + resolved "https://registry.npm.taobao.org/@tarojs/service/download/@tarojs/service-3.2.1.tgz?cache=0&sync_timestamp=1618199870704&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40tarojs%2Fservice%2Fdownload%2F%40tarojs%2Fservice-3.2.1.tgz#7999ac05e3c8af63e48b03572024ae691b9189fc" + integrity sha1-eZmsBePIr2PkiwNXICSuaRuRifw= dependencies: "@hapi/joi" "17.1.1" - "@tarojs/helper" "3.1.4" - "@tarojs/shared" "3.1.4" - "@tarojs/taro" "3.1.4" + "@tarojs/helper" "3.2.1" + "@tarojs/shared" "3.2.1" + "@tarojs/taro" "3.2.1" fs-extra "8.1.0" lodash "4.17.20" resolve "1.15.1" @@ -1578,10 +1578,10 @@ resolved "https://registry.npm.taobao.org/@tarojs/shared/download/@tarojs/shared-3.1.3.tgz?cache=0&sync_timestamp=1615574321080&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40tarojs%2Fshared%2Fdownload%2F%40tarojs%2Fshared-3.1.3.tgz#348f6e7fbc52f1385907ef92bd811b59ae4177d0" integrity sha1-NI9uf7xS8ThZB++SvYEbWa5Bd9A= -"@tarojs/shared@3.1.4": - version "3.1.4" - resolved "https://registry.npm.taobao.org/@tarojs/shared/download/@tarojs/shared-3.1.4.tgz?cache=0&sync_timestamp=1615810117793&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40tarojs%2Fshared%2Fdownload%2F%40tarojs%2Fshared-3.1.4.tgz#fc1611de7b691ace79ade9a5254310004412ab3b" - integrity sha1-/BYR3ntpGs55remlJUMQAEQSqzs= +"@tarojs/shared@3.2.1": + version "3.2.1" + resolved "https://registry.npm.taobao.org/@tarojs/shared/download/@tarojs/shared-3.2.1.tgz#a97e9579c213ca7b93d189028d880b09c0683514" + integrity sha1-qX6VecITynuT0YkCjYgLCcBoNRQ= "@tarojs/taro-h5@3.1.3": version "3.1.3" @@ -1597,51 +1597,51 @@ raf "^3.4.1" whatwg-fetch "^3.4.0" -"@tarojs/taro-h5@3.1.4": - version "3.1.4" - resolved "https://registry.npm.taobao.org/@tarojs/taro-h5/download/@tarojs/taro-h5-3.1.4.tgz?cache=0&sync_timestamp=1616124377461&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40tarojs%2Ftaro-h5%2Fdownload%2F%40tarojs%2Ftaro-h5-3.1.4.tgz#f3718faad8481d7d3761f9839a21f9f790e81475" - integrity sha1-83GPqthIHX03YfmDmiH595DoFHU= +"@tarojs/taro-h5@3.2.1": + version "3.2.1" + resolved "https://registry.npm.taobao.org/@tarojs/taro-h5/download/@tarojs/taro-h5-3.2.1.tgz#5a0d05caff4e0b80fdab1d6eebe6898d46f92f8f" + integrity sha1-Wg0Fyv9OC4D9qx1u6+aJjUb5L48= dependencies: - "@tarojs/api" "3.1.4" - "@tarojs/router" "3.1.4" - "@tarojs/runtime" "3.1.4" + "@tarojs/api" "3.2.1" + "@tarojs/router" "3.2.1" + "@tarojs/runtime" "3.2.1" base64-js "^1.3.0" jsonp-retry "^1.0.3" mobile-detect "^1.4.2" raf "^3.4.1" whatwg-fetch "^3.4.0" -"@tarojs/taro-loader@3.1.4": - version "3.1.4" - resolved "https://registry.npm.taobao.org/@tarojs/taro-loader/download/@tarojs/taro-loader-3.1.4.tgz?cache=0&sync_timestamp=1615810123190&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40tarojs%2Ftaro-loader%2Fdownload%2F%40tarojs%2Ftaro-loader-3.1.4.tgz#382b978fa8fbc4f355efa5f6ab065a2ec08b35c2" - integrity sha1-OCuXj6j7xPNV76X2qwZaLsCLNcI= +"@tarojs/taro-loader@3.2.1": + version "3.2.1" + resolved "https://registry.npm.taobao.org/@tarojs/taro-loader/download/@tarojs/taro-loader-3.2.1.tgz#e5c0a5b83e2294048740c3ef213ce7d665aebe8c" + integrity sha1-5cCluD4ilASHQMPvITzn1mWuvow= dependencies: - "@tarojs/helper" "3.1.4" + "@tarojs/helper" "3.2.1" acorn "^8.0.4" acorn-walk "^8.0.0" loader-utils "^1.2.3" -"@tarojs/taro@3.1.4", "@tarojs/taro@^3.1.4": - version "3.1.4" - resolved "https://registry.npm.taobao.org/@tarojs/taro/download/@tarojs/taro-3.1.4.tgz#3d96a2c87d2cd778810a57ef2f60022676f0b388" - integrity sha1-PZaiyH0s13iBClfvL2ACJnbws4g= +"@tarojs/taro@3.2.1", "@tarojs/taro@^3.2.1": + version "3.2.1" + resolved "https://registry.npm.taobao.org/@tarojs/taro/download/@tarojs/taro-3.2.1.tgz#73ad8abd48fcef343d911ca7c8fcd229a448c337" + integrity sha1-c62KvUj87zQ9kRynyPzSKaRIwzc= dependencies: - "@tarojs/api" "3.1.4" - "@tarojs/runtime" "3.1.4" - "@tarojs/taro-h5" "3.1.4" + "@tarojs/api" "3.2.1" + "@tarojs/runtime" "3.2.1" + "@tarojs/taro-h5" "3.2.1" -"@tarojs/webpack-runner@^3.1.4": - version "3.1.4" - resolved "https://registry.npm.taobao.org/@tarojs/webpack-runner/download/@tarojs/webpack-runner-3.1.4.tgz?cache=0&sync_timestamp=1616124411846&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40tarojs%2Fwebpack-runner%2Fdownload%2F%40tarojs%2Fwebpack-runner-3.1.4.tgz#38037f25bbabc174bcd3cf413014bdf4b407193d" - integrity sha1-OAN/JburwXS8089BMBS99LQHGT0= +"@tarojs/webpack-runner@^3.2.1": + version "3.2.1" + resolved "https://registry.npm.taobao.org/@tarojs/webpack-runner/download/@tarojs/webpack-runner-3.2.1.tgz#2384dccf071ed291f3ea8224c1dea07f87557fc3" + integrity sha1-I4Tczwce0pHz6oIkwd6gf4dVf8M= dependencies: "@babel/core" "7.11.1" "@pmmmwh/react-refresh-webpack-plugin" "0.4.3" - "@tarojs/helper" "3.1.4" - "@tarojs/runner-utils" "3.1.4" - "@tarojs/runtime" "3.1.4" - "@tarojs/shared" "3.1.4" - "@tarojs/taro-loader" "3.1.4" + "@tarojs/helper" "3.2.1" + "@tarojs/runner-utils" "3.2.1" + "@tarojs/runtime" "3.2.1" + "@tarojs/shared" "3.2.1" + "@tarojs/taro-loader" "3.2.1" autoprefixer "9.7.4" babel-loader "8.0.6" copy-webpack-plugin "5.1.1" @@ -1659,8 +1659,8 @@ open "7.0.2" ora "4.0.3" postcss-loader "3.0.0" - postcss-plugin-constparse "3.1.4" - postcss-pxtransform "3.1.4" + postcss-plugin-constparse "3.2.1" + postcss-pxtransform "3.2.1" react-refresh "0.9.0" resolve "1.15.1" resolve-url-loader "3.1.1" @@ -2015,7 +2015,7 @@ "@vue/compiler-core" "3.0.11" "@vue/shared" "3.0.11" -"@vue/compiler-sfc@^3.0.9": +"@vue/compiler-sfc@^3.0.10": version "3.0.11" resolved "https://registry.npm.taobao.org/@vue/compiler-sfc/download/@vue/compiler-sfc-3.0.11.tgz#cd8ca2154b88967b521f5ad3b10f5f8b6b665679" integrity sha1-zYyiFUuIlntSH1rTsQ9fi2tmVnk= @@ -9011,10 +9011,10 @@ postcss-modules@^4.0.0: postcss-modules-values "^4.0.0" string-hash "^1.1.1" -postcss-plugin-constparse@3.1.4: - version "3.1.4" - resolved "https://registry.npm.taobao.org/postcss-plugin-constparse/download/postcss-plugin-constparse-3.1.4.tgz#cc93ecf1eabb853c08a3969278365741c36ff54e" - integrity sha1-zJPs8eq7hTwIo5aSeDZXQcNv9U4= +postcss-plugin-constparse@3.2.1: + version "3.2.1" + resolved "https://registry.npm.taobao.org/postcss-plugin-constparse/download/postcss-plugin-constparse-3.2.1.tgz#851d52aab2fcfbc9fd8ba5f32474f5146cb35d26" + integrity sha1-hR1SqrL8+8n9i6XzJHT1FGyzXSY= dependencies: postcss "^6.0.22" @@ -9026,18 +9026,10 @@ postcss-pxtorem@^4.0.1: object-assign "^4.1.0" postcss "^5.2.10" -postcss-pxtransform@3.1.4: - version "3.1.4" - resolved "https://registry.npm.taobao.org/postcss-pxtransform/download/postcss-pxtransform-3.1.4.tgz#5a959abcbe3f2b90b8560cbc09fa4216271745b9" - integrity sha1-WpWavL4/K5C4Vgy8CfpCFicXRbk= - dependencies: - postcss "^6.0.16" - postcss-pxtorem "^4.0.1" - -postcss-pxtransform@^1.3.2: - version "1.3.46" - resolved "https://registry.npm.taobao.org/postcss-pxtransform/download/postcss-pxtransform-1.3.46.tgz#3b07699ad29cb4044c8f5e0e067c701d7ebc3ab7" - integrity sha1-OwdpmtKctARMj14OBnxwHX68Orc= +postcss-pxtransform@3.2.1: + version "3.2.1" + resolved "https://registry.npm.taobao.org/postcss-pxtransform/download/postcss-pxtransform-3.2.1.tgz#d97881770c96ebcbc505cf2940529e5559187f1d" + integrity sha1-2XiBdwyW68vFBc8pQFKeVVkYfx0= dependencies: postcss "^6.0.16" postcss-pxtorem "^4.0.1" @@ -11482,10 +11474,10 @@ typedarray@^0.0.6: resolved "https://registry.npm.taobao.org/typedarray/download/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= -typescript@4.2.3: - version "4.2.3" - resolved "https://registry.npm.taobao.org/typescript/download/typescript-4.2.3.tgz?cache=0&sync_timestamp=1617693588914&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Ftypescript%2Fdownload%2Ftypescript-4.2.3.tgz#39062d8019912d43726298f09493d598048c1ce3" - integrity sha1-OQYtgBmRLUNyYpjwlJPVmASMHOM= +typescript@^4.2.0: + version "4.2.4" + resolved "https://registry.npm.taobao.org/typescript/download/typescript-4.2.4.tgz?cache=0&sync_timestamp=1618212066089&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Ftypescript%2Fdownload%2Ftypescript-4.2.4.tgz#8610b59747de028fda898a8aef0e103f156d0961" + integrity sha1-hhC1l0feAo/aiYqK7w4QPxVtCWE= uglify-js@3.4.x: version "3.4.10" @@ -11873,7 +11865,7 @@ vue-loader@^16.1.0: hash-sum "^2.0.0" loader-utils "^2.0.0" -vue@^3.0.9: +vue@^3.0.10: version "3.0.11" resolved "https://registry.npm.taobao.org/vue/download/vue-3.0.11.tgz?cache=0&sync_timestamp=1617321643721&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fvue%2Fdownload%2Fvue-3.0.11.tgz#c82f9594cbf4dcc869241d4c8dd3e08d9a8f4b5f" integrity sha1-yC+VlMv03MhpJB1MjdPgjZqPS18= From fc8ccd8f9867e319e08dee47fdf13cea38e47dda Mon Sep 17 00:00:00 2001 From: Ken Ho Date: Mon, 12 Apr 2021 22:30:44 +0800 Subject: [PATCH 19/23] chore: update esbuild to 0.11.9 --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 6cb69447..9eda8d03 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4603,9 +4603,9 @@ es6-symbol@^3.1.1, es6-symbol@~3.1.3: ext "^1.1.2" esbuild@^0.11.0: - version "0.11.5" - resolved "https://registry.npm.taobao.org/esbuild/download/esbuild-0.11.5.tgz#25b18a2ff2fb9580683edce26a48f64c08c2f2df" - integrity sha1-JbGKL/L7lYBoPtziakj2TAjC8t8= + version "0.11.9" + resolved "https://registry.npm.taobao.org/esbuild/download/esbuild-0.11.9.tgz#408bf4fb5ae9abc2f27d56b62e19aab697687975" + integrity sha1-QIv0+1rpq8LyfVa2LhmqtpdoeXU= escalade@^3.1.1: version "3.1.1" From db9c8ee02da27ad2d949ca622e2b1da413069a4c Mon Sep 17 00:00:00 2001 From: Ken Ho Date: Tue, 13 Apr 2021 18:45:22 +0800 Subject: [PATCH 20/23] refactor(tabs): simplify the use of refs --- src/components/tabs/index.ts | 69 +++++++++++++++++------------------- 1 file changed, 33 insertions(+), 36 deletions(-) diff --git a/src/components/tabs/index.ts b/src/components/tabs/index.ts index 5ac46726..1b54673d 100644 --- a/src/components/tabs/index.ts +++ b/src/components/tabs/index.ts @@ -1,4 +1,16 @@ -import { h, defineComponent, reactive, ref, watch, onMounted, onUnmounted, CSSProperties, computed, mergeProps, PropType } from 'vue' +import { + h, + computed, + defineComponent, + mergeProps, + onMounted, + onUnmounted, + ref, + reactive, + watch, + CSSProperties, + PropType +} from 'vue' import { ScrollView, View, Text } from '@tarojs/components' import { CommonEvent, ITouchEvent } from '@tarojs/components/types/common' import Taro from '@tarojs/taro' @@ -123,7 +135,7 @@ const AtTabs = defineComponent({ } case Taro.ENV_TYPE.WEB: { const index = Math.max(idx - 1, 0) - const prevTabItem = tabHeaderRef.value.childNodes[index] + const prevTabItem = tabHeaderRef.value.$el.children[index] if (prevTabItem) { state._scrollTop = prevTabItem.offsetTop state._scrollLeft = prevTabItem.offsetLeft @@ -186,36 +198,16 @@ const AtTabs = defineComponent({ _isMoving.value = false } - function getTabHeaderRef(): void { - if (ENV === Taro.ENV_TYPE.WEB) { - tabHeaderRef.value = document.getElementById(_tabId.value) - } - } - - watch(() => [ - props.scroll, - props.current - ], ( - [scroll, current]: [boolean, number], - [preScroll, preCurrent]: [boolean, number] + watch(() => props.current, ( + current: number ) => { - if (scroll !== preScroll) { - getTabHeaderRef() - } - if (current !== preCurrent) { - updateState(current) - } + updateState(current) }) onMounted(() => { - getTabHeaderRef() updateState(props.current) }) - onUnmounted(() => { - tabHeaderRef.value = null - }) - return () => { const tabItems = props.tabList.map((item, idx) => ( @@ -243,17 +235,22 @@ const AtTabs = defineComponent({ // scroll view ? props.scroll ? ( // with scroll view - h(ScrollView, { - id: _tabId.value, - class: 'at-tabs__header', - style: heightStyle.value, - scrollX: scrollX.value, - scrollY: scrollY.value, - scrollWithAnimation: true, - scrollLeft: state._scrollLeft, - scrollTop: state._scrollTop, - scrollIntoView: state._scrollIntoView, - }, { default: () => tabItems }) + h(ScrollView, mergeProps( + ENV === Taro.ENV_TYPE.WEB + ? { ref: (el) => { tabHeaderRef.value = el } } + : {}, + { + id: _tabId.value, + + class: 'at-tabs__header', + style: heightStyle.value, + scrollX: scrollX.value, + scrollY: scrollY.value, + scrollWithAnimation: true, + scrollLeft: state._scrollLeft, + scrollTop: state._scrollTop, + scrollIntoView: state._scrollIntoView, + }), { default: () => tabItems }) ) : ( // or without scroll view h(View, { From f19b1e8f754e63fbea97e656947c2e1efa2c44e2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 20 Apr 2021 02:11:13 +0000 Subject: [PATCH 21/23] chore(deps): bump ssri from 6.0.1 to 6.0.2 Bumps [ssri](https://github.com/npm/ssri) from 6.0.1 to 6.0.2. - [Release notes](https://github.com/npm/ssri/releases) - [Changelog](https://github.com/npm/ssri/blob/v6.0.2/CHANGELOG.md) - [Commits](https://github.com/npm/ssri/compare/v6.0.1...v6.0.2) Signed-off-by: dependabot[bot] --- yarn.lock | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/yarn.lock b/yarn.lock index f2247391..8b35b998 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5094,8 +5094,8 @@ fd-slicer@~1.1.0: figgy-pudding@^3.5.1: version "3.5.2" - resolved "https://registry.npm.taobao.org/figgy-pudding/download/figgy-pudding-3.5.2.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Ffiggy-pudding%2Fdownload%2Ffiggy-pudding-3.5.2.tgz#b4eee8148abb01dcf1d1ac34367d59e12fa61d6e" - integrity sha1-tO7oFIq7Adzx0aw0Nn1Z4S+mHW4= + resolved "https://registry.yarnpkg.com/figgy-pudding/-/figgy-pudding-3.5.2.tgz#b4eee8148abb01dcf1d1ac34367d59e12fa61d6e" + integrity sha512-0btnI/H8f2pavGMN8w40mlSKOfTK2SVJmBfBeVIj3kNw0swwgzyRq0d5TJVOwodFmtvpPeWPN/MCcfuWF0Ezbw== figures@^3.0.0: version "3.2.0" @@ -10622,9 +10622,9 @@ ssr-window@^2.0.0: integrity sha1-mMMBrvmVIzF/jWlhjwAQeRCW78Q= ssri@^6.0.1: - version "6.0.1" - resolved "https://registry.npm.taobao.org/ssri/download/ssri-6.0.1.tgz#2a3c41b28dd45b62b63676ecb74001265ae9edd8" - integrity sha1-KjxBso3UW2K2Nnbst0ABJlrp7dg= + version "6.0.2" + resolved "https://registry.yarnpkg.com/ssri/-/ssri-6.0.2.tgz#157939134f20464e7301ddba3e90ffa8f7728ac5" + integrity sha512-cepbSq/neFK7xB6A50KHN0xHDotYzq58wWCa5LeWqnPrHG8GzfEjO/4O8kpmcGW+oaxkvhEJCWgbgNk4/ZV93Q== dependencies: figgy-pudding "^3.5.1" @@ -11482,10 +11482,10 @@ typedarray@^0.0.6: resolved "https://registry.npm.taobao.org/typedarray/download/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= -typescript@4.2.3: - version "4.2.3" - resolved "https://registry.npm.taobao.org/typescript/download/typescript-4.2.3.tgz?cache=0&sync_timestamp=1617693588914&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Ftypescript%2Fdownload%2Ftypescript-4.2.3.tgz#39062d8019912d43726298f09493d598048c1ce3" - integrity sha1-OQYtgBmRLUNyYpjwlJPVmASMHOM= +typescript@^4.2.0: + version "4.2.4" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.2.4.tgz#8610b59747de028fda898a8aef0e103f156d0961" + integrity sha512-V+evlYHZnQkaz8TRBuxTA92yZBPotr5H+WhQ7bD3hZUndx5tGOa1fuCgeSjxAzM1RiN5IzvadIXTVefuuwZCRg== uglify-js@3.4.x: version "3.4.10" From c86ff0cdeac34ee5dbd05db402cf1d9ea9b08eed Mon Sep 17 00:00:00 2001 From: Ken Ho Date: Sun, 25 Apr 2021 18:15:50 +0800 Subject: [PATCH 22/23] test(calendar): fix marks test case --- src/components/calendar/__tests__/calendar.spec.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/calendar/__tests__/calendar.spec.ts b/src/components/calendar/__tests__/calendar.spec.ts index 2d427d50..9aec00b6 100644 --- a/src/components/calendar/__tests__/calendar.spec.ts +++ b/src/components/calendar/__tests__/calendar.spec.ts @@ -90,10 +90,10 @@ describe('AtCalendar', () => { 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) + expect(wrapper.findAll('.flex__item:not(.flex__item--blur) .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(3) + expect(wrapper.findAll('.flex__item:not(.flex__item--blur) .mark').length).toBe(3) }) it('should render minDate and maxDate', () => { From 655f274b4f4f6da8ce582ab66d4d46d878364a94 Mon Sep 17 00:00:00 2001 From: Ken Ho Date: Sun, 25 Apr 2021 18:22:04 +0800 Subject: [PATCH 23/23] test(tabs): update test cases --- .../__tests__/__snapshots__/tabs.spec.ts.snap | 348 +++++------------- src/components/tabs/__tests__/tabs.spec.ts | 339 +++++++++++++++-- src/components/tabs/index.ts | 3 - 3 files changed, 408 insertions(+), 282 deletions(-) diff --git a/src/components/tabs/__tests__/__snapshots__/tabs.spec.ts.snap b/src/components/tabs/__tests__/__snapshots__/tabs.spec.ts.snap index 8355ad5c..ce99ac08 100644 --- a/src/components/tabs/__tests__/__snapshots__/tabs.spec.ts.snap +++ b/src/components/tabs/__tests__/__snapshots__/tabs.spec.ts.snap @@ -16,245 +16,110 @@ exports[`AtTabs should render default AtTabs 1`] = ` class="at-tabs__underline" style="width: 0%;" /> - - + `; -exports[`AtTabs should render prop -- animated 1`] = ` +exports[`AtTabs should render prop -- height 1`] = ` - - - 标签页1 - - - - - - 标签页2 - - - + 标签页1 + - - 标签页3 - - - - - - - - - -`; - -exports[`AtTabs should render prop -- class 1`] = ` - - + + 标签页2 + - - - -`; - -exports[`AtTabs should render prop -- current 1`] = ` - - - - 标签页1 - - - + 标签页3 + - - 标签页2 - - - - - - 标签页3 - - - - - - - - `; -exports[`AtTabs should render prop -- height 1`] = ` - - - - 标签页1 - - - - - - 标签页2 - - - + 标签页1 + - - 标签页3 - - - + class="at-tabs__item-underline" + /> + + 标签页2 + - - - -`; - -exports[`AtTabs should render prop -- style 1`] = ` - - + + 标签页3 + - - - + `; -exports[`AtTabs should render prop -- swipeable 1`] = ` +exports[`AtTabs should render prop -- tabDirection 1`] = ` @@ -310,19 +175,22 @@ exports[`AtTabs should render prop -- swipeable 1`] = ` class="at-tabs__underline" style="width: 300%;" /> - - + `; -exports[`AtTabs should render prop -- tabDirection 1`] = ` +exports[`AtTabs should render prop -- tabDirection 2`] = ` - - + - - + `; exports[`AtTabs should render prop -- tabList 1`] = ` - - - 标签页1 - - - + 标签页1 + + + + - - 标签页2 - - - + 标签页2 + - - 标签页3 - - - + class="at-tabs__item-underline" + /> + + 标签页3 + - - `; diff --git a/src/components/tabs/__tests__/tabs.spec.ts b/src/components/tabs/__tests__/tabs.spec.ts index abdf3efd..d1b19b19 100644 --- a/src/components/tabs/__tests__/tabs.spec.ts +++ b/src/components/tabs/__tests__/tabs.spec.ts @@ -1,71 +1,348 @@ -import { mount } from '@vue/test-utils' +import { mountFactory, Slots } from '@/tests/helper' +import { h } from '@vue/runtime-core' +import { ref } from 'vue' import AtTabs from '../index' -const factory = (values = {}, slots = { default: [] }) => { - return mount(AtTabs as any, { - slots, - props: { ...values }, - }) +const factory = (props = {}, slots?: Slots) => { + return mountFactory(AtTabs, undefined, props, slots) } -const tabList = [{ title: '标签页1' }, { title: '标签页2' }, { title: '标签页3' }] +const tabList = [ + { title: '标签页1' }, + { title: '标签页2' }, + { title: '标签页3' } +] + describe('AtTabs', () => { + + beforeEach(() => { + jest.useFakeTimers() + }) + it('should render default AtTabs', () => { const wrapper = factory() expect(wrapper.element).toMatchSnapshot() }) it('should render prop -- style', () => { - const wrapper = factory({ style: 'color:red;' }) - expect(wrapper.element).toMatchSnapshot() + const wrapper = factory({ style: 'color: red;' }) + expect( + wrapper + .find('.at-tabs') + .attributes('style') + ).toContain('color: red;') }) it('should render prop -- class', () => { const wrapper = factory({ class: 'test' }) - expect(wrapper.element).toMatchSnapshot() + expect( + wrapper + .find('.at-tabs') + .classes() + ).toContain('test') }) it('should render prop -- tabList', () => { const wrapper = factory({ tabList: tabList }) - expect(wrapper.element).toMatchSnapshot() + expect( + wrapper + .findAll('.at-tabs__item') + .length + ).toBe(tabList.length) + + expect( + wrapper + .findAll('.at-tabs__item--active') + .length + ).toBe(1) + + expect( + wrapper + .find('.at-tabs__header') + .element + ).toMatchSnapshot() }) - it('should render prop -- current', () => { - const wrapper = factory({ tabList: tabList, current: 2 }) - expect(wrapper.element).toMatchSnapshot() + it('should render prop -- current', async () => { + const wrapper = factory({ + tabList: tabList + }) + + const activeTab = wrapper.find('.at-tabs__item--active') + const tabs = wrapper.findAll('.at-tabs__item') + expect(tabs[0]).toEqual(activeTab) + + await wrapper.setProps({ current: 2 }) + const activeTab1 = wrapper.find('.at-tabs__item--active') + const tabs1 = wrapper.findAll('.at-tabs__item') + expect(tabs1[2]).toEqual(activeTab1) }) - it('should render prop -- swipeable', () => { - const wrapper = factory({ tabList: tabList, swipeable: true }) - expect(wrapper.element).toMatchSnapshot() + it('should render prop -- scroll', async () => { + const wrapper = factory({ + tabList: tabList + }) + + expect( + wrapper + .find('.at-tabs--scroll') + .exists() + ).toBe(false) + + expect( + wrapper + .find('view.at-tabs__header') + .exists() + ).toBe(true) + + expect( + wrapper + .find('scroll-view.at-tabs__header') + .exists() + ).toBe(false) + + await wrapper.setProps({ scroll: true }) + expect( + wrapper + .find('.at-tabs--scroll') + .exists() + ).toBe(true) + + expect( + wrapper + .find('view.at-tabs__header') + .exists() + ).toBe(false) + + const scrollView = wrapper.find('scroll-view.at-tabs__header') + expect(scrollView.exists()).toBe(true) + expect(scrollView.element).toMatchSnapshot() }) - // it('should render prop -- scroll', () => { - // const wrapper = factory({ tabList: tabList, scroll: true }) - // expect(wrapper.element).toMatchSnapshot() - // }) + it('should render prop -- tabDirection', async () => { + const wrapper = factory({ + tabList: tabList + }) + + expect( + wrapper + .find('.at-tabs--horizontal') + .exists() + ).toBe(true) + expect( + wrapper + .find('.at-tabs--vertical') + .exists() + ).toBe(false) + + expect( + wrapper + .find('.at-tabs__underline') + .attributes('style') + ).toContain(`width: ${tabList.length * 100}%;`) + + expect( + wrapper + .find('.at-tabs__body') + .attributes('style') + ).toContain(`transform: translate3d(-0%, 0px, 0px);`) + + expect(wrapper.element).toMatchSnapshot() + + await wrapper.setProps({ + tabDirection: 'vertical', + scroll: true + }) + + await wrapper.vm.$nextTick() + + expect( + wrapper + .find('.at-tabs--horizontal') + .exists() + ).toBe(false) + expect( + wrapper + .find('.at-tabs--vertical') + .exists() + ).toBe(true) + + expect( + wrapper + .find('.at-tabs__underline') + .attributes('style') + ).toContain(`height: ${tabList.length * 100}%;`) + + expect( + wrapper + .find('.at-tabs__body') + .attributes('style') + ).toContain(`transform: translate3d(0px, -${0 * 100}%, 0px);`) + + expect( + wrapper + .find('.at-tabs__header') + .attributes('scrolly') + ).toBe('true') - it('should render prop -- tabDirection', () => { - const wrapper = factory({ tabList: tabList, tabDirection: 'vertical' }) expect(wrapper.element).toMatchSnapshot() }) it('should render prop -- animated', () => { - const wrapper = factory({ tabList: tabList, animated: false }) - expect(wrapper.element).toMatchSnapshot() + const wrapper = factory({ + tabList: tabList, + animated: false + }) + + expect( + wrapper + .find('.at-tabs__body') + .attributes('style') + ).toContain('transition: unset;') }) it('should render prop -- height', () => { - const wrapper = factory({ tabList: tabList, tabDirection: 'vertical', height: '300px' }) - expect(wrapper.element).toMatchSnapshot() + const wrapper = factory({ + tabList: tabList, + tabDirection: 'vertical', + height: '300px', + // scroll: true, + }) + + expect( + wrapper + .find('.at-tabs__header') + .element + ).toMatchSnapshot() + + expect( + wrapper + .find('.at-tabs') + .attributes('style') + ).toContain('height: 300px;') + + // expect( + // wrapper + // .find('.at-tabs__header') + // .attributes('style') + // ).toContain('height: 300px;') + + expect( + wrapper + .find('.at-tabs__body') + .attributes('style') + ).toContain('height: 300px;') + }) + + it('should render slot content', () => { + const wrapper = factory( + { tabList }, + { default: () => [h('view', { class: "test" }, "slot content")] } + ) + + expect( + wrapper + .find('.at-tabs__body > .test') + .text() + ).toBe('slot content') }) }) describe('AtTabs Behavior', () => { - it('should trigger onClick', () => { + beforeEach(() => { + jest.useFakeTimers() + }) + + it('should trigger onClick', async () => { const onClick = jest.fn() - const wrapper = factory({ onClick: onClick, tabList: tabList }) - wrapper.find('.at-tabs .at-tabs__item').trigger('tap') + const wrapper = factory({ + tabList: tabList, + onClick: onClick + }) + await wrapper.find('.at-tabs__item').trigger('tap') expect(onClick).toBeCalled() }) -}) + + it.skip('should switch between tabs when swipeable is true', async () => { + const current = ref(0) + const handleClick = (index) => { + current.value = index + } + + const wrapper = factory( + { + tabList, + current, + swipeable: true, + onClick: (e) => handleClick(e) + }, + { default: () => [h('view', { class: "test" }, "slot content")] } + ) + + const tabs0 = wrapper.findAll('.at-tabs__item') + expect(tabs0[0].classes()).toContain('at-tabs__item--active') + + await wrapper + .find('.at-tabs__body') + .trigger('touchstart', { + touches: [{ + pageX: 100, + pageY: 0, + }] + }) + + await wrapper + .find('.at-tabs__body') + .trigger('touchmove', { + touches: [{ + pageX: 50, + pageY: 0, + }] + }) + + await wrapper + .find('.at-tabs__body') + .trigger('touchend', { + touches: [{ + pageX: 50, + pageY: 0, + }] + }) + + await wrapper.vm.$nextTick() + const tabs1 = wrapper.findAll('.at-tabs__item') + console.log('tabs1[0].classes(): ', tabs1[0].classes()) + console.log('tabs1[1].classes(): ', tabs1[1].classes()) + expect(tabs1[1].classes()).toContain('at-tabs__item--active') + + await wrapper + .find('.at-tabs__body') + .trigger('touchstart', { + touches: [{ + pageX: 100, + pageY: 0, + }] + }) + + await wrapper + .find('.at-tabs__body') + .trigger('touchmove', { + touches: [{ + pageX: 50, + pageY: 0, + }] + }) + + await wrapper + .find('.at-tabs__body') + .trigger('touchend', { + touches: [{ + pageX: 50, + pageY: 0, + }] + }) + + const tabs2 = wrapper.findAll('.at-tabs__item') + expect(tabs2[2].classes()).toContain('at-tabs__item--active') + }) +}) \ No newline at end of file diff --git a/src/components/tabs/index.ts b/src/components/tabs/index.ts index 1b54673d..ebc75fa5 100644 --- a/src/components/tabs/index.ts +++ b/src/components/tabs/index.ts @@ -4,7 +4,6 @@ import { defineComponent, mergeProps, onMounted, - onUnmounted, ref, reactive, watch, @@ -155,7 +154,6 @@ const AtTabs = defineComponent({ } function handleTouchStart(e: ITouchEvent): void { - if (!props.swipeable || props.tabDirection === 'vertical') return // 获取触摸时的原点 _touchDot.value = e.touches[0].pageX @@ -241,7 +239,6 @@ const AtTabs = defineComponent({ : {}, { id: _tabId.value, - class: 'at-tabs__header', style: heightStyle.value, scrollX: scrollX.value,