From 3da2c556f6f197a918f207b5bf975af0b8b5aeeb Mon Sep 17 00:00:00 2001 From: zhangpaopao Date: Tue, 7 Feb 2023 15:35:21 +0800 Subject: [PATCH 1/5] feat(datetimepicker): support aria --- src/picker/picker.wxml | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/picker/picker.wxml b/src/picker/picker.wxml index d29d02304..542899c5a 100644 --- a/src/picker/picker.wxml +++ b/src/picker/picker.wxml @@ -3,13 +3,23 @@ - {{cancelBtn}} + {{cancelBtn}} + {{title}} - {{confirmBtn}} + {{confirmBtn}} + From e5206c0c435099f4f57fa3e3316bc2b151f0d1f1 Mon Sep 17 00:00:00 2001 From: zhangpaopao Date: Tue, 7 Feb 2023 16:39:45 +0800 Subject: [PATCH 2/5] feat(datetimepicker): update snap --- .../__test__/__snapshots__/index.test.js.snap | 10 ++++++++-- src/picker/__test__/__snapshots__/index.test.js.snap | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/date-time-picker/__test__/__snapshots__/index.test.js.snap b/src/date-time-picker/__test__/__snapshots__/index.test.js.snap index d037302af..03199de82 100644 --- a/src/date-time-picker/__test__/__snapshots__/index.test.js.snap +++ b/src/date-time-picker/__test__/__snapshots__/index.test.js.snap @@ -36,10 +36,13 @@ exports[`date-time-picker :base 1`] = ` class="t-picker__toolbar" > - 取消 + + 取消 + - 确定 + + 确定 + - 取消 + + 取消 + - 确认 + + 确认 + Date: Tue, 14 Feb 2023 14:21:45 +0800 Subject: [PATCH 3/5] feat(picker): support aria --- src/picker-item/picker-item.less | 32 ++++++++++++++++++++++++++++++++ src/picker-item/picker-item.ts | 26 ++++++++++++++++++++++---- src/picker-item/picker-item.wxml | 27 +++++++++++++++++++++++++++ 3 files changed, 81 insertions(+), 4 deletions(-) diff --git a/src/picker-item/picker-item.less b/src/picker-item/picker-item.less index 5ba7b3d87..4487a70e6 100644 --- a/src/picker-item/picker-item.less +++ b/src/picker-item/picker-item.less @@ -18,10 +18,42 @@ overflow: hidden; flex: 1; z-index: 1; + position: relative; } &__wrapper { padding: 144rpx 0; + position: absolute; + z-index: 1; + width: 100%; + left: 0; + } + + &__accessible { + position: relative; + // top: calc(@picker-item-height * -1); + top: 0; + width: 100%; + height: 100%; + // pointer-events: none; + opacity: 0; + display: flex; + flex-direction: column; + z-index: 1; + padding-bottom: 1px; + + &--current { + width: 100%; + height: 100%; + flex: 1; + text-overflow: ellipsis; + } + &--button { + width: 100%; + height: 100%; + flex: 2; + text-overflow: ellipsis; + } } &__item { diff --git a/src/picker-item/picker-item.ts b/src/picker-item/picker-item.ts index 2406857b5..71cad2f9f 100644 --- a/src/picker-item/picker-item.ts +++ b/src/picker-item/picker-item.ts @@ -63,15 +63,23 @@ export default class PickerItem extends SuperComponent { }); }, - onTouchEnd() { + onTouchEnd(_, nowIndex) { const { offset } = this.data; const { options } = this.properties; - if (offset === this.StartOffset) { + let index = nowIndex; + if (index !== undefined && (index < 0 || index > options.length - 1)) { return; } - // 调整偏移量 - const index = range(Math.round(-offset / this.itemHeight), 0, this.getCount() - 1); + + if (index === undefined) { + if (offset === this.StartOffset) { + return; + } + // 调整偏移量 + index = range(Math.round(-offset / this.itemHeight), 0, this.getCount() - 1); + } + this.setData({ curIndex: index, offset: -index * this.itemHeight, @@ -92,6 +100,16 @@ export default class PickerItem extends SuperComponent { }); }, + onClickPrev() { + const { curIndex } = this.data; + this.onTouchEnd(null, curIndex - 1); + }, + + onClickNext() { + const { curIndex } = this.data; + this.onTouchEnd(null, curIndex + 1); + }, + // 刷新选中状态 update() { const { options, value } = this.data; diff --git a/src/picker-item/picker-item.wxml b/src/picker-item/picker-item.wxml index 805e6e9f6..c7a08a8c1 100644 --- a/src/picker-item/picker-item.wxml +++ b/src/picker-item/picker-item.wxml @@ -10,6 +10,7 @@ > + + + + - + + + - + + + - + + From c1db7dc2dfc2b2e8438916aaf1622bfbc6716954 Mon Sep 17 00:00:00 2001 From: zhangpaopao Date: Tue, 14 Feb 2023 17:08:12 +0800 Subject: [PATCH 4/5] chore(picker): update snap --- .../__test__/__snapshots__/index.test.js.snap | 68 +++++++++++++++++++ .../__test__/__snapshots__/index.test.js.snap | 68 +++++++++++++++++++ 2 files changed, 136 insertions(+) diff --git a/src/date-time-picker/__test__/__snapshots__/index.test.js.snap b/src/date-time-picker/__test__/__snapshots__/index.test.js.snap index 03199de82..511bf6f69 100644 --- a/src/date-time-picker/__test__/__snapshots__/index.test.js.snap +++ b/src/date-time-picker/__test__/__snapshots__/index.test.js.snap @@ -75,6 +75,7 @@ exports[`date-time-picker :base 1`] = ` bind:touchstart="onTouchStart" > @@ -325,6 +326,39 @@ exports[`date-time-picker :base 1`] = ` 2030年 + + + + + + - + + + + + - + + + + + - + @@ -342,6 +376,7 @@ exports[`date-time-picker :base 1`] = ` bind:touchstart="onTouchStart" > @@ -440,6 +475,39 @@ exports[`date-time-picker :base 1`] = ` 12月 + + + + + + - + + + + + - + + + + + - + diff --git a/src/picker/__test__/__snapshots__/index.test.js.snap b/src/picker/__test__/__snapshots__/index.test.js.snap index 20974fb9e..ecca49825 100644 --- a/src/picker/__test__/__snapshots__/index.test.js.snap +++ b/src/picker/__test__/__snapshots__/index.test.js.snap @@ -70,6 +70,7 @@ exports[`picker :base 1`] = ` bind:touchstart="onTouchStart" > @@ -96,6 +97,39 @@ exports[`picker :base 1`] = ` 2019年 + + + + + + - + + + + + - + + + + + - + @@ -110,6 +144,7 @@ exports[`picker :base 1`] = ` bind:touchstart="onTouchStart" > @@ -144,6 +179,39 @@ exports[`picker :base 1`] = ` 冬 + + + + + + - + + + + + - + + + + + - + From 9790cfc4c165217e25ed64b89e55d545ad3fc0d9 Mon Sep 17 00:00:00 2001 From: zhangpaopao Date: Fri, 24 Mar 2023 17:23:28 +0800 Subject: [PATCH 5/5] chore(datetimepicker): update snap --- .../index.test.js.snap | 2 +- .../index.test.js.snap | 80 +++++++++++++++++-- .../index.test.js.snap | 78 +++++++++++++++++- .../__virtualHostSnapshot__/demo.test.js.snap | 4 +- 4 files changed, 154 insertions(+), 10 deletions(-) diff --git a/src/calendar/__test__/__virtualHostSnapshot__/index.test.js.snap b/src/calendar/__test__/__virtualHostSnapshot__/index.test.js.snap index f643b662c..5e9f6aaf6 100644 --- a/src/calendar/__test__/__virtualHostSnapshot__/index.test.js.snap +++ b/src/calendar/__test__/__virtualHostSnapshot__/index.test.js.snap @@ -748,7 +748,7 @@ exports[`calendar :base 1`] = ` bind:getuserinfo="getuserinfo" bind:launchapp="launchapp" bind:opensetting="opensetting" - catch:tap="" + catch:tap="handleTap" > - 取消 + + 取消 + - 确定 + + 确定 + @@ -300,6 +307,39 @@ exports[`date-time-picker :base 1`] = ` 2030年 + + + + + + - + + + + + - + + + + + - + @@ -312,6 +352,7 @@ exports[`date-time-picker :base 1`] = ` bind:touchstart="onTouchStart" > @@ -413,9 +454,38 @@ exports[`date-time-picker :base 1`] = ` + class="t-picker-item__accessible" + > + + + - + + + + + - + + + + + - + + + - 取消 + + 取消 + - 确认 + + 确认 + @@ -75,6 +82,39 @@ exports[`picker :base 1`] = ` 2019年 + + + + + + - + + + + + - + + + + + - + @@ -87,6 +127,7 @@ exports[`picker :base 1`] = ` bind:touchstart="onTouchStart" > @@ -121,6 +162,39 @@ exports[`picker :base 1`] = ` 冬 + + + + + + - + + + + + - + + + + + - + diff --git a/src/switch/__test__/__virtualHostSnapshot__/demo.test.js.snap b/src/switch/__test__/__virtualHostSnapshot__/demo.test.js.snap index c0d1f83ce..fc066d891 100644 --- a/src/switch/__test__/__virtualHostSnapshot__/demo.test.js.snap +++ b/src/switch/__test__/__virtualHostSnapshot__/demo.test.js.snap @@ -40,8 +40,8 @@ exports[`Switch Switch label demo works fine 1`] = `