@tarojs/components 3.6.2-canary.0 → 3.6.2-canary.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/taro-input-core.cjs.entry.js +1 -1
- package/dist/cjs/taro-picker-core_2.cjs.entry.js +1 -1
- package/dist/cjs/taro-swiper-core_2.cjs.entry.js +28 -18
- package/dist/cjs/taro-textarea-core.cjs.entry.js +2 -2
- package/dist/collection/components/input/input.js +1 -1
- package/dist/collection/components/picker/picker.js +1 -1
- package/dist/collection/components/swiper/swiper-item.js +16 -9
- package/dist/collection/components/swiper/swiper.js +12 -9
- package/dist/collection/components/textarea/textarea.js +7 -3
- package/dist/components/taro-input-core.js +1 -1
- package/dist/components/taro-picker-core.js +1 -1
- package/dist/components/taro-swiper-core.js +12 -9
- package/dist/components/taro-swiper-item-core.js +16 -9
- package/dist/components/taro-textarea-core.js +2 -2
- package/dist/esm/taro-input-core.entry.js +1 -1
- package/dist/esm/taro-picker-core_2.entry.js +1 -1
- package/dist/esm/taro-swiper-core_2.entry.js +28 -18
- package/dist/esm/taro-textarea-core.entry.js +2 -2
- package/dist/esm-es5/taro-input-core.entry.js +1 -1
- package/dist/esm-es5/taro-picker-core_2.entry.js +1 -1
- package/dist/esm-es5/taro-swiper-core_2.entry.js +1 -1
- package/dist/esm-es5/taro-textarea-core.entry.js +1 -1
- package/dist/taro-components/{p-4d390d17.entry.js → p-0b8b3af5.entry.js} +1 -1
- package/dist/taro-components/p-1c446c65.system.js +1 -1
- package/dist/taro-components/p-1eac7c75.system.entry.js +1 -0
- package/dist/taro-components/{p-3e23fa46.system.entry.js → p-39685396.system.entry.js} +1 -1
- package/dist/taro-components/{p-e53feb03.system.entry.js → p-58f9a827.system.entry.js} +1 -1
- package/dist/taro-components/{p-ab84c88e.entry.js → p-7704e165.entry.js} +1 -1
- package/dist/taro-components/{p-10046f1a.system.entry.js → p-a5afdc47.system.entry.js} +1 -1
- package/dist/taro-components/p-affb28de.entry.js +1 -0
- package/dist/taro-components/{p-7db63e92.entry.js → p-c30d1b2d.entry.js} +1 -1
- package/dist/taro-components/taro-components.esm.js +1 -1
- package/dist/types/components/textarea/textarea.d.ts +1 -1
- package/lib/react/components.js +81 -160
- package/lib/react/components.js.map +1 -1
- package/lib/vue2/components.d.ts +361 -589
- package/lib/vue2/components.js +249 -328
- package/lib/vue2/components.js.map +1 -1
- package/lib/vue3/components.js +81 -160
- package/lib/vue3/components.js.map +1 -1
- package/package.json +5 -5
- package/types/Ad.d.ts +2 -31
- package/types/AdCustom.d.ts +0 -4
- package/types/AnimationVideo.d.ts +0 -9
- package/types/AnimationView.d.ts +0 -6
- package/types/ArCamera.d.ts +0 -7
- package/types/Audio.d.ts +0 -18
- package/types/AwemeData.d.ts +0 -6
- package/types/Button.d.ts +3 -106
- package/types/Camera.d.ts +0 -28
- package/types/Canvas.d.ts +2 -17
- package/types/ChannelLive.d.ts +0 -2
- package/types/ChannelVideo.d.ts +0 -6
- package/types/Checkbox.d.ts +1 -8
- package/types/CheckboxGroup.d.ts +0 -2
- package/types/CommentDetail.d.ts +4 -10
- package/types/CommentList.d.ts +4 -20
- package/types/ContactButton.d.ts +0 -7
- package/types/CoverImage.d.ts +0 -11
- package/types/CoverView.d.ts +0 -26
- package/types/Editor.d.ts +0 -10
- package/types/FollowSwan.d.ts +0 -3
- package/types/Form.d.ts +1 -9
- package/types/FunctionalPageNavigator.d.ts +0 -11
- package/types/GridView.d.ts +5 -10
- package/types/Icon.d.ts +0 -14
- package/types/Image.d.ts +0 -31
- package/types/InlinePaymentPanel.d.ts +0 -9
- package/types/Input.d.ts +0 -62
- package/types/Label.d.ts +3 -2
- package/types/Lifestyle.d.ts +0 -3
- package/types/Like.d.ts +0 -17
- package/types/LivePlayer.d.ts +1 -58
- package/types/LivePusher.d.ts +0 -77
- package/types/Login.d.ts +0 -5
- package/types/Lottie.d.ts +0 -16
- package/types/Map.d.ts +19 -136
- package/types/MatchMedia.d.ts +0 -7
- package/types/MovableArea.d.ts +0 -1
- package/types/MovableView.d.ts +0 -35
- package/types/NavigationBar.d.ts +0 -6
- package/types/Navigator.d.ts +0 -27
- package/types/OfficialAccount.d.ts +0 -12
- package/types/OpenData.d.ts +0 -20
- package/types/PageContainer.d.ts +0 -21
- package/types/PageMeta.d.ts +0 -16
- package/types/Picker.d.ts +17 -45
- package/types/PickerView.d.ts +1 -12
- package/types/Progress.d.ts +0 -13
- package/types/Radio.d.ts +1 -8
- package/types/RadioGroup.d.ts +0 -2
- package/types/RichText.d.ts +1 -22
- package/types/RootPortal.d.ts +1 -2
- package/types/RtcRoom.d.ts +0 -16
- package/types/RtcRoomItem.d.ts +0 -3
- package/types/ScrollView.d.ts +2 -57
- package/types/ShareElement.d.ts +2 -7
- package/types/Slider.d.ts +0 -19
- package/types/Swiper.d.ts +0 -44
- package/types/SwiperItem.d.ts +0 -2
- package/types/Switch.d.ts +2 -11
- package/types/TabItem.d.ts +0 -4
- package/types/Tabs.d.ts +0 -8
- package/types/Text.d.ts +0 -7
- package/types/Textarea.d.ts +0 -36
- package/types/Video.d.ts +1 -112
- package/types/View.d.ts +0 -25
- package/types/VoipRoom.d.ts +0 -6
- package/types/WebView.d.ts +0 -6
- package/dist/taro-components/p-0aaf66d2.entry.js +0 -1
- package/dist/taro-components/p-da1f3d54.system.entry.js +0 -1
|
@@ -370,7 +370,7 @@ const Picker = class {
|
|
|
370
370
|
componentDidLoad() {
|
|
371
371
|
Object.defineProperty(this.el, 'value', {
|
|
372
372
|
get: () => this.pickerValue,
|
|
373
|
-
set:
|
|
373
|
+
set: value => this.value !== value && (this.value = value),
|
|
374
374
|
configurable: true
|
|
375
375
|
});
|
|
376
376
|
if (this.overlay) {
|
|
@@ -9884,9 +9884,18 @@ const Swiper = class {
|
|
|
9884
9884
|
}
|
|
9885
9885
|
};
|
|
9886
9886
|
this.handleSwiperLoop = index$2.debounce(() => {
|
|
9887
|
-
|
|
9888
|
-
|
|
9889
|
-
|
|
9887
|
+
var _a;
|
|
9888
|
+
if (!this.swiper || !this.circular)
|
|
9889
|
+
return;
|
|
9890
|
+
const swiper = this.swiper; // Note: loop 相关的方法 swiper 未声明
|
|
9891
|
+
const duplicates = ((_a = this.swiperWrapper) === null || _a === void 0 ? void 0 : _a.querySelectorAll('.swiper-slide-duplicate')) || [];
|
|
9892
|
+
if (duplicates.length < 2) {
|
|
9893
|
+
// Note: 循环模式下,但是前后垫片未注入
|
|
9894
|
+
swiper.loopDestroy();
|
|
9895
|
+
swiper.loopCreate();
|
|
9896
|
+
}
|
|
9897
|
+
else {
|
|
9898
|
+
swiper.loopFix();
|
|
9890
9899
|
}
|
|
9891
9900
|
}, 50);
|
|
9892
9901
|
this.handleSwiperSize = index$2.debounce(() => {
|
|
@@ -10049,12 +10058,6 @@ const Swiper = class {
|
|
|
10049
10058
|
},
|
|
10050
10059
|
// slideChange 事件在 swiper.slideTo 改写 current 时不触发,因此用 slideChangeTransitionStart 事件代替
|
|
10051
10060
|
slideChangeTransitionStart(_swiper) {
|
|
10052
|
-
if (that.circular) {
|
|
10053
|
-
if (_swiper.isBeginning || _swiper.isEnd) {
|
|
10054
|
-
// _swiper.slideToLoop(this.realIndex, 0, false) // 更新下标
|
|
10055
|
-
return;
|
|
10056
|
-
}
|
|
10057
|
-
}
|
|
10058
10061
|
that.onChange.emit({
|
|
10059
10062
|
current: this.realIndex,
|
|
10060
10063
|
source: ''
|
|
@@ -10136,18 +10139,25 @@ Swiper.style = indexCss;
|
|
|
10136
10139
|
function isEqualTag(a, b) {
|
|
10137
10140
|
return typeof a.tagName === 'undefined' ? a.nodeType === b.nodeType : a.tagName === b.tagName;
|
|
10138
10141
|
}
|
|
10139
|
-
function parseChildNodes(items, targets) {
|
|
10142
|
+
function parseChildNodes(items, targets, needClean = false) {
|
|
10140
10143
|
const list = Array.from(targets.values());
|
|
10141
|
-
for (let i = 0, j = 0; i < list.length; i
|
|
10144
|
+
for (let i = 0, j = 0; i < list.length; i++) {
|
|
10142
10145
|
const target = list[i];
|
|
10146
|
+
if (!target)
|
|
10147
|
+
return;
|
|
10143
10148
|
let item = items.item(j);
|
|
10144
|
-
while (item
|
|
10145
|
-
item
|
|
10146
|
-
|
|
10147
|
-
|
|
10148
|
-
|
|
10149
|
-
|
|
10150
|
-
|
|
10149
|
+
while (item) {
|
|
10150
|
+
if (!isEqualTag(item, target) || needClean) {
|
|
10151
|
+
item.remove();
|
|
10152
|
+
j++;
|
|
10153
|
+
item = items.item(j);
|
|
10154
|
+
continue;
|
|
10155
|
+
}
|
|
10156
|
+
if (target.childNodes.length > 0) {
|
|
10157
|
+
const cleanAll = ['taro-image-core'].includes(target.tagName.toLocaleLowerCase());
|
|
10158
|
+
parseChildNodes(item.childNodes, target.childNodes, cleanAll);
|
|
10159
|
+
}
|
|
10160
|
+
break;
|
|
10151
10161
|
}
|
|
10152
10162
|
while (i === list.length - 1 && j < items.length) {
|
|
10153
10163
|
j++;
|
|
@@ -114,13 +114,13 @@ const Textarea = class {
|
|
|
114
114
|
(_a = this.textareaRef) === null || _a === void 0 ? void 0 : _a.focus();
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
|
-
focus() {
|
|
117
|
+
async focus() {
|
|
118
118
|
this.textareaRef.focus();
|
|
119
119
|
}
|
|
120
120
|
componentDidLoad() {
|
|
121
121
|
Object.defineProperty(this.el, 'value', {
|
|
122
122
|
get: () => this.textareaRef.value,
|
|
123
|
-
set: value => (this.value = value),
|
|
123
|
+
set: value => this.value !== value && (this.value = value),
|
|
124
124
|
configurable: true
|
|
125
125
|
});
|
|
126
126
|
}
|
|
@@ -214,7 +214,7 @@ export class Picker {
|
|
|
214
214
|
componentDidLoad() {
|
|
215
215
|
Object.defineProperty(this.el, 'value', {
|
|
216
216
|
get: () => this.pickerValue,
|
|
217
|
-
set:
|
|
217
|
+
set: value => this.value !== value && (this.value = value),
|
|
218
218
|
configurable: true
|
|
219
219
|
});
|
|
220
220
|
if (this.overlay) {
|
|
@@ -2,18 +2,25 @@ import { Host, h } from '@stencil/core';
|
|
|
2
2
|
function isEqualTag(a, b) {
|
|
3
3
|
return typeof a.tagName === 'undefined' ? a.nodeType === b.nodeType : a.tagName === b.tagName;
|
|
4
4
|
}
|
|
5
|
-
function parseChildNodes(items, targets) {
|
|
5
|
+
function parseChildNodes(items, targets, needClean = false) {
|
|
6
6
|
const list = Array.from(targets.values());
|
|
7
|
-
for (let i = 0, j = 0; i < list.length; i
|
|
7
|
+
for (let i = 0, j = 0; i < list.length; i++) {
|
|
8
8
|
const target = list[i];
|
|
9
|
+
if (!target)
|
|
10
|
+
return;
|
|
9
11
|
let item = items.item(j);
|
|
10
|
-
while (item
|
|
11
|
-
item
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
while (item) {
|
|
13
|
+
if (!isEqualTag(item, target) || needClean) {
|
|
14
|
+
item.remove();
|
|
15
|
+
j++;
|
|
16
|
+
item = items.item(j);
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
if (target.childNodes.length > 0) {
|
|
20
|
+
const cleanAll = ['taro-image-core'].includes(target.tagName.toLocaleLowerCase());
|
|
21
|
+
parseChildNodes(item.childNodes, target.childNodes, cleanAll);
|
|
22
|
+
}
|
|
23
|
+
break;
|
|
17
24
|
}
|
|
18
25
|
while (i === list.length - 1 && j < items.length) {
|
|
19
26
|
j++;
|
|
@@ -26,9 +26,18 @@ export class Swiper {
|
|
|
26
26
|
}
|
|
27
27
|
};
|
|
28
28
|
this.handleSwiperLoop = debounce(() => {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
var _a;
|
|
30
|
+
if (!this.swiper || !this.circular)
|
|
31
|
+
return;
|
|
32
|
+
const swiper = this.swiper; // Note: loop 相关的方法 swiper 未声明
|
|
33
|
+
const duplicates = ((_a = this.swiperWrapper) === null || _a === void 0 ? void 0 : _a.querySelectorAll('.swiper-slide-duplicate')) || [];
|
|
34
|
+
if (duplicates.length < 2) {
|
|
35
|
+
// Note: 循环模式下,但是前后垫片未注入
|
|
36
|
+
swiper.loopDestroy();
|
|
37
|
+
swiper.loopCreate();
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
swiper.loopFix();
|
|
32
41
|
}
|
|
33
42
|
}, 50);
|
|
34
43
|
this.handleSwiperSize = debounce(() => {
|
|
@@ -191,12 +200,6 @@ export class Swiper {
|
|
|
191
200
|
},
|
|
192
201
|
// slideChange 事件在 swiper.slideTo 改写 current 时不触发,因此用 slideChangeTransitionStart 事件代替
|
|
193
202
|
slideChangeTransitionStart(_swiper) {
|
|
194
|
-
if (that.circular) {
|
|
195
|
-
if (_swiper.isBeginning || _swiper.isEnd) {
|
|
196
|
-
// _swiper.slideToLoop(this.realIndex, 0, false) // 更新下标
|
|
197
|
-
return;
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
203
|
that.onChange.emit({
|
|
201
204
|
current: this.realIndex,
|
|
202
205
|
source: ''
|
|
@@ -101,13 +101,13 @@ export class Textarea {
|
|
|
101
101
|
(_a = this.textareaRef) === null || _a === void 0 ? void 0 : _a.focus();
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
|
-
focus() {
|
|
104
|
+
async focus() {
|
|
105
105
|
this.textareaRef.focus();
|
|
106
106
|
}
|
|
107
107
|
componentDidLoad() {
|
|
108
108
|
Object.defineProperty(this.el, 'value', {
|
|
109
109
|
get: () => this.textareaRef.value,
|
|
110
|
-
set: value => (this.value = value),
|
|
110
|
+
set: value => this.value !== value && (this.value = value),
|
|
111
111
|
configurable: true
|
|
112
112
|
});
|
|
113
113
|
}
|
|
@@ -368,7 +368,11 @@ export class Textarea {
|
|
|
368
368
|
"complexType": {
|
|
369
369
|
"signature": "() => Promise<void>",
|
|
370
370
|
"parameters": [],
|
|
371
|
-
"references": {
|
|
371
|
+
"references": {
|
|
372
|
+
"Promise": {
|
|
373
|
+
"location": "global"
|
|
374
|
+
}
|
|
375
|
+
},
|
|
372
376
|
"return": "Promise<void>"
|
|
373
377
|
},
|
|
374
378
|
"docs": {
|
|
@@ -181,7 +181,7 @@ const Input = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
181
181
|
}
|
|
182
182
|
Object.defineProperty(this.el, 'value', {
|
|
183
183
|
get: () => this.inputRef.value,
|
|
184
|
-
set: value => (this.value = value),
|
|
184
|
+
set: value => this.value !== value && (this.value = value),
|
|
185
185
|
configurable: true
|
|
186
186
|
});
|
|
187
187
|
}
|
|
@@ -364,7 +364,7 @@ const Picker = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
364
364
|
componentDidLoad() {
|
|
365
365
|
Object.defineProperty(this.el, 'value', {
|
|
366
366
|
get: () => this.pickerValue,
|
|
367
|
-
set:
|
|
367
|
+
set: value => this.value !== value && (this.value = value),
|
|
368
368
|
configurable: true
|
|
369
369
|
});
|
|
370
370
|
if (this.overlay) {
|
|
@@ -9881,9 +9881,18 @@ const Swiper = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement$1 {
|
|
|
9881
9881
|
}
|
|
9882
9882
|
};
|
|
9883
9883
|
this.handleSwiperLoop = debounce(() => {
|
|
9884
|
-
|
|
9885
|
-
|
|
9886
|
-
|
|
9884
|
+
var _a;
|
|
9885
|
+
if (!this.swiper || !this.circular)
|
|
9886
|
+
return;
|
|
9887
|
+
const swiper = this.swiper; // Note: loop 相关的方法 swiper 未声明
|
|
9888
|
+
const duplicates = ((_a = this.swiperWrapper) === null || _a === void 0 ? void 0 : _a.querySelectorAll('.swiper-slide-duplicate')) || [];
|
|
9889
|
+
if (duplicates.length < 2) {
|
|
9890
|
+
// Note: 循环模式下,但是前后垫片未注入
|
|
9891
|
+
swiper.loopDestroy();
|
|
9892
|
+
swiper.loopCreate();
|
|
9893
|
+
}
|
|
9894
|
+
else {
|
|
9895
|
+
swiper.loopFix();
|
|
9887
9896
|
}
|
|
9888
9897
|
}, 50);
|
|
9889
9898
|
this.handleSwiperSize = debounce(() => {
|
|
@@ -10046,12 +10055,6 @@ const Swiper = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement$1 {
|
|
|
10046
10055
|
},
|
|
10047
10056
|
// slideChange 事件在 swiper.slideTo 改写 current 时不触发,因此用 slideChangeTransitionStart 事件代替
|
|
10048
10057
|
slideChangeTransitionStart(_swiper) {
|
|
10049
|
-
if (that.circular) {
|
|
10050
|
-
if (_swiper.isBeginning || _swiper.isEnd) {
|
|
10051
|
-
// _swiper.slideToLoop(this.realIndex, 0, false) // 更新下标
|
|
10052
|
-
return;
|
|
10053
|
-
}
|
|
10054
|
-
}
|
|
10055
10058
|
that.onChange.emit({
|
|
10056
10059
|
current: this.realIndex,
|
|
10057
10060
|
source: ''
|
|
@@ -3,18 +3,25 @@ import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal
|
|
|
3
3
|
function isEqualTag(a, b) {
|
|
4
4
|
return typeof a.tagName === 'undefined' ? a.nodeType === b.nodeType : a.tagName === b.tagName;
|
|
5
5
|
}
|
|
6
|
-
function parseChildNodes(items, targets) {
|
|
6
|
+
function parseChildNodes(items, targets, needClean = false) {
|
|
7
7
|
const list = Array.from(targets.values());
|
|
8
|
-
for (let i = 0, j = 0; i < list.length; i
|
|
8
|
+
for (let i = 0, j = 0; i < list.length; i++) {
|
|
9
9
|
const target = list[i];
|
|
10
|
+
if (!target)
|
|
11
|
+
return;
|
|
10
12
|
let item = items.item(j);
|
|
11
|
-
while (item
|
|
12
|
-
item
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
while (item) {
|
|
14
|
+
if (!isEqualTag(item, target) || needClean) {
|
|
15
|
+
item.remove();
|
|
16
|
+
j++;
|
|
17
|
+
item = items.item(j);
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
if (target.childNodes.length > 0) {
|
|
21
|
+
const cleanAll = ['taro-image-core'].includes(target.tagName.toLocaleLowerCase());
|
|
22
|
+
parseChildNodes(item.childNodes, target.childNodes, cleanAll);
|
|
23
|
+
}
|
|
24
|
+
break;
|
|
18
25
|
}
|
|
19
26
|
while (i === list.length - 1 && j < items.length) {
|
|
20
27
|
j++;
|
|
@@ -111,13 +111,13 @@ const Textarea = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
111
111
|
(_a = this.textareaRef) === null || _a === void 0 ? void 0 : _a.focus();
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
|
-
focus() {
|
|
114
|
+
async focus() {
|
|
115
115
|
this.textareaRef.focus();
|
|
116
116
|
}
|
|
117
117
|
componentDidLoad() {
|
|
118
118
|
Object.defineProperty(this.el, 'value', {
|
|
119
119
|
get: () => this.textareaRef.value,
|
|
120
|
-
set: value => (this.value = value),
|
|
120
|
+
set: value => this.value !== value && (this.value = value),
|
|
121
121
|
configurable: true
|
|
122
122
|
});
|
|
123
123
|
}
|
|
@@ -366,7 +366,7 @@ const Picker = class {
|
|
|
366
366
|
componentDidLoad() {
|
|
367
367
|
Object.defineProperty(this.el, 'value', {
|
|
368
368
|
get: () => this.pickerValue,
|
|
369
|
-
set:
|
|
369
|
+
set: value => this.value !== value && (this.value = value),
|
|
370
370
|
configurable: true
|
|
371
371
|
});
|
|
372
372
|
if (this.overlay) {
|
|
@@ -9880,9 +9880,18 @@ const Swiper = class {
|
|
|
9880
9880
|
}
|
|
9881
9881
|
};
|
|
9882
9882
|
this.handleSwiperLoop = debounce(() => {
|
|
9883
|
-
|
|
9884
|
-
|
|
9885
|
-
|
|
9883
|
+
var _a;
|
|
9884
|
+
if (!this.swiper || !this.circular)
|
|
9885
|
+
return;
|
|
9886
|
+
const swiper = this.swiper; // Note: loop 相关的方法 swiper 未声明
|
|
9887
|
+
const duplicates = ((_a = this.swiperWrapper) === null || _a === void 0 ? void 0 : _a.querySelectorAll('.swiper-slide-duplicate')) || [];
|
|
9888
|
+
if (duplicates.length < 2) {
|
|
9889
|
+
// Note: 循环模式下,但是前后垫片未注入
|
|
9890
|
+
swiper.loopDestroy();
|
|
9891
|
+
swiper.loopCreate();
|
|
9892
|
+
}
|
|
9893
|
+
else {
|
|
9894
|
+
swiper.loopFix();
|
|
9886
9895
|
}
|
|
9887
9896
|
}, 50);
|
|
9888
9897
|
this.handleSwiperSize = debounce(() => {
|
|
@@ -10045,12 +10054,6 @@ const Swiper = class {
|
|
|
10045
10054
|
},
|
|
10046
10055
|
// slideChange 事件在 swiper.slideTo 改写 current 时不触发,因此用 slideChangeTransitionStart 事件代替
|
|
10047
10056
|
slideChangeTransitionStart(_swiper) {
|
|
10048
|
-
if (that.circular) {
|
|
10049
|
-
if (_swiper.isBeginning || _swiper.isEnd) {
|
|
10050
|
-
// _swiper.slideToLoop(this.realIndex, 0, false) // 更新下标
|
|
10051
|
-
return;
|
|
10052
|
-
}
|
|
10053
|
-
}
|
|
10054
10057
|
that.onChange.emit({
|
|
10055
10058
|
current: this.realIndex,
|
|
10056
10059
|
source: ''
|
|
@@ -10132,18 +10135,25 @@ Swiper.style = indexCss;
|
|
|
10132
10135
|
function isEqualTag(a, b) {
|
|
10133
10136
|
return typeof a.tagName === 'undefined' ? a.nodeType === b.nodeType : a.tagName === b.tagName;
|
|
10134
10137
|
}
|
|
10135
|
-
function parseChildNodes(items, targets) {
|
|
10138
|
+
function parseChildNodes(items, targets, needClean = false) {
|
|
10136
10139
|
const list = Array.from(targets.values());
|
|
10137
|
-
for (let i = 0, j = 0; i < list.length; i
|
|
10140
|
+
for (let i = 0, j = 0; i < list.length; i++) {
|
|
10138
10141
|
const target = list[i];
|
|
10142
|
+
if (!target)
|
|
10143
|
+
return;
|
|
10139
10144
|
let item = items.item(j);
|
|
10140
|
-
while (item
|
|
10141
|
-
item
|
|
10142
|
-
|
|
10143
|
-
|
|
10144
|
-
|
|
10145
|
-
|
|
10146
|
-
|
|
10145
|
+
while (item) {
|
|
10146
|
+
if (!isEqualTag(item, target) || needClean) {
|
|
10147
|
+
item.remove();
|
|
10148
|
+
j++;
|
|
10149
|
+
item = items.item(j);
|
|
10150
|
+
continue;
|
|
10151
|
+
}
|
|
10152
|
+
if (target.childNodes.length > 0) {
|
|
10153
|
+
const cleanAll = ['taro-image-core'].includes(target.tagName.toLocaleLowerCase());
|
|
10154
|
+
parseChildNodes(item.childNodes, target.childNodes, cleanAll);
|
|
10155
|
+
}
|
|
10156
|
+
break;
|
|
10147
10157
|
}
|
|
10148
10158
|
while (i === list.length - 1 && j < items.length) {
|
|
10149
10159
|
j++;
|
|
@@ -110,13 +110,13 @@ const Textarea = class {
|
|
|
110
110
|
(_a = this.textareaRef) === null || _a === void 0 ? void 0 : _a.focus();
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
|
-
focus() {
|
|
113
|
+
async focus() {
|
|
114
114
|
this.textareaRef.focus();
|
|
115
115
|
}
|
|
116
116
|
componentDidLoad() {
|
|
117
117
|
Object.defineProperty(this.el, 'value', {
|
|
118
118
|
get: () => this.textareaRef.value,
|
|
119
|
-
set: value => (this.value = value),
|
|
119
|
+
set: value => this.value !== value && (this.value = value),
|
|
120
120
|
configurable: true
|
|
121
121
|
});
|
|
122
122
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var __awaiter=this&&this.__awaiter||function(e,t,n,i){function o(e){return e instanceof n?e:new n((function(t){t(e)}))}return new(n||(n=Promise))((function(n,a){function r(e){try{s(i.next(e))}catch(e){a(e)}}function u(e){try{s(i["throw"](e))}catch(e){a(e)}}function s(e){e.done?n(e.value):o(e.value).then(r,u)}s((i=i.apply(e,t||[])).next())}))};var __generator=this&&this.__generator||function(e,t){var n={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},i,o,a,r;return r={next:u(0),throw:u(1),return:u(2)},typeof Symbol==="function"&&(r[Symbol.iterator]=function(){return this}),r;function u(e){return function(t){return s([e,t])}}function s(u){if(i)throw new TypeError("Generator is already executing.");while(r&&(r=0,u[0]&&(n=0)),n)try{if(i=1,o&&(a=u[0]&2?o["return"]:u[0]?o["throw"]||((a=o["return"])&&a.call(o),0):o.next)&&!(a=a.call(o,u[1])).done)return a;if(o=0,a)u=[u[0]&2,a.value];switch(u[0]){case 0:case 1:a=u;break;case 4:n.label++;return{value:u[1],done:false};case 5:n.label++;o=u[1];u=[0];continue;case 7:u=n.ops.pop();n.trys.pop();continue;default:if(!(a=n.trys,a=a.length>0&&a[a.length-1])&&(u[0]===6||u[0]===2)){n=0;continue}if(u[0]===3&&(!a||u[1]>a[0]&&u[1]<a[3])){n.label=u[1];break}if(u[0]===6&&n.label<a[1]){n.label=a[1];a=u;break}if(a&&n.label<a[2]){n.label=a[2];n.ops.push(u);break}if(a[2])n.ops.pop();n.trys.pop();continue}u=t.call(e,n)}catch(e){u=[6,e];o=0}finally{i=a=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:true}}};import{r as registerInstance,c as createEvent,h,g as getElement}from"./index-c948674f.js";var indexCss="taro-input-core{display:block}input{display:block;overflow:hidden;height:1.4rem;text-overflow:clip;text-align:inherit;white-space:nowrap}";function getTrueType(e,t,n){if(t==="search")e="search";if(n)e="password";if(typeof e==="undefined"){return"text"}if(!e){throw new Error("unexpected type")}if(e==="digit")e="number";return e}function fixControlledValue(e){return e!==null&&e!==void 0?e:""}var Input=function(){function e(e){var t=this;registerInstance(this,e);this.onInput=createEvent(this,"input",7);this.onPaste=createEvent(this,"paste",7);this.onFocus=createEvent(this,"focus",7);this.onBlur=createEvent(this,"blur",7);this.onConfirm=createEvent(this,"confirm",7);this.onChange=createEvent(this,"change",7);this.onKeyDown=createEvent(this,"keydown",7);this.isOnComposition=false;this.isOnPaste=false;this.onInputExcuted=false;this.handleInput=function(e){e.stopPropagation();var n=t,i=n.type,o=n.maxlength,a=n.confirmType,r=n.password;if(!t.isOnComposition&&!t.onInputExcuted){var u=e.target.value;var s=getTrueType(i,a,r);t.onInputExcuted=true;if(s==="number"&&u&&o>-1&&o<=u.length){u=u.substring(0,o);e.target.value=u}t.value=u;t.onInput.emit({value:u,cursor:u.length});t.onInputExcuted=false}};this.handlePaste=function(e){e.stopPropagation();t.isOnPaste=true;t.onPaste.emit({value:e.target.value})};this.handleFocus=function(e){e.stopPropagation();t.onInputExcuted=false;t.onFocus.emit({value:e.target.value})};this.handleBlur=function(e){e.stopPropagation();t.onBlur.emit({value:e.target.value})};this.handleChange=function(e){e.stopPropagation();t.onChange.emit({value:e.target.value});if(t.isOnPaste){t.isOnPaste=false;t.value=e.target.value;t.onInput.emit({value:e.target.value,cursor:e.target.value.length})}};this.handleKeyDown=function(e){e.stopPropagation();var n=e.target.value;var i=e.keyCode||e.code;t.onInputExcuted=false;t.onKeyDown.emit({value:n,cursor:n.length,keyCode:i});i===13&&t.onConfirm.emit({value:n})};this.handleComposition=function(e){e.stopPropagation();if(!(e.target instanceof HTMLInputElement))return;if(e.type==="compositionend"){t.isOnComposition=false;t.value=e.target.value;t.onInput.emit({value:e.target.value,cursor:e.target.value.length})}else{t.isOnComposition=true}};this.handleBeforeinput=function(e){if(!e.data)return;var n=e.data&&/[0-9]/.test(e.data);if(t.type==="number"&&!n){e.preventDefault()}if(t.type==="digit"&&!n){if(e.data!=="."||e.data==="."&&e.target.value.indexOf(".")>-1){e.preventDefault()}}};this.value=undefined;this.type=undefined;this.password=false;this.placeholder=undefined;this.disabled=false;this.maxlength=140;this.autoFocus=false;this.confirmType="done";this.name=undefined;this.nativeProps={}}e.prototype.focus=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){this.inputRef.focus();return[2]}))}))};e.prototype.watchAutoFocus=function(e,t){var n;if(!t&&e){(n=this.inputRef)===null||n===void 0?void 0:n.focus()}};e.prototype.watchValue=function(e){var t=fixControlledValue(e);if(this.inputRef.value!==t){this.inputRef.value=t}};e.prototype.componentDidLoad=function(){var e=this;var t,n,i,o,a;if(this.type==="file"){this.fileListener=function(){e.onInput.emit()};(t=this.inputRef)===null||t===void 0?void 0:t.addEventListener("change",this.fileListener)}else{(n=this.inputRef)===null||n===void 0?void 0:n.addEventListener("compositionstart",this.handleComposition);(i=this.inputRef)===null||i===void 0?void 0:i.addEventListener("compositionend",this.handleComposition);(o=this.inputRef)===null||o===void 0?void 0:o.addEventListener("beforeinput",this.handleBeforeinput);(a=this.inputRef)===null||a===void 0?void 0:a.addEventListener("textInput",this.handleBeforeinput)}Object.defineProperty(this.el,"value",{get:function(){return e.inputRef.value},set:function(t){return e.value=t},configurable:true})};e.prototype.disconnectedCallback=function(){var e,t,n,i,o;if(this.type==="file"){(e=this.inputRef)===null||e===void 0?void 0:e.removeEventListener("change",this.fileListener)}else{(t=this.inputRef)===null||t===void 0?void 0:t.removeEventListener("compositionstart",this.handleComposition);(n=this.inputRef)===null||n===void 0?void 0:n.removeEventListener("compositionend",this.handleComposition);(i=this.inputRef)===null||i===void 0?void 0:i.removeEventListener("beforeinput",this.handleBeforeinput);(o=this.inputRef)===null||o===void 0?void 0:o.removeEventListener("textInput",this.handleBeforeinput)}};e.prototype.render=function(){var e=this;var t=this,n=t.value,i=t.type,o=t.password,a=t.placeholder,r=t.autoFocus,u=t.disabled,s=t.maxlength,l=t.confirmType,p=t.name,f=t.nativeProps;return h("input",Object.assign({ref:function(t){e.inputRef=t;if(r&&t)t.focus()},class:"weui-input",type:getTrueType(i,l,o),placeholder:a,autoFocus:r,disabled:u,maxlength:s,name:p,onInput:this.handleInput,onFocus:this.handleFocus,onBlur:this.handleBlur,onChange:this.handleChange,onKeyDown:this.handleKeyDown,onPaste:this.handlePaste,onCompositionStart:this.handleComposition,onCompositionEnd:this.handleComposition},f,{value:fixControlledValue(n)}))};Object.defineProperty(e.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});Object.defineProperty(e,"watchers",{get:function(){return{autoFocus:["watchAutoFocus"],value:["watchValue"]}},enumerable:false,configurable:true});return e}();Input.style=indexCss;export{Input as taro_input_core};
|
|
1
|
+
var __awaiter=this&&this.__awaiter||function(e,t,n,i){function o(e){return e instanceof n?e:new n((function(t){t(e)}))}return new(n||(n=Promise))((function(n,a){function r(e){try{s(i.next(e))}catch(e){a(e)}}function u(e){try{s(i["throw"](e))}catch(e){a(e)}}function s(e){e.done?n(e.value):o(e.value).then(r,u)}s((i=i.apply(e,t||[])).next())}))};var __generator=this&&this.__generator||function(e,t){var n={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},i,o,a,r;return r={next:u(0),throw:u(1),return:u(2)},typeof Symbol==="function"&&(r[Symbol.iterator]=function(){return this}),r;function u(e){return function(t){return s([e,t])}}function s(u){if(i)throw new TypeError("Generator is already executing.");while(r&&(r=0,u[0]&&(n=0)),n)try{if(i=1,o&&(a=u[0]&2?o["return"]:u[0]?o["throw"]||((a=o["return"])&&a.call(o),0):o.next)&&!(a=a.call(o,u[1])).done)return a;if(o=0,a)u=[u[0]&2,a.value];switch(u[0]){case 0:case 1:a=u;break;case 4:n.label++;return{value:u[1],done:false};case 5:n.label++;o=u[1];u=[0];continue;case 7:u=n.ops.pop();n.trys.pop();continue;default:if(!(a=n.trys,a=a.length>0&&a[a.length-1])&&(u[0]===6||u[0]===2)){n=0;continue}if(u[0]===3&&(!a||u[1]>a[0]&&u[1]<a[3])){n.label=u[1];break}if(u[0]===6&&n.label<a[1]){n.label=a[1];a=u;break}if(a&&n.label<a[2]){n.label=a[2];n.ops.push(u);break}if(a[2])n.ops.pop();n.trys.pop();continue}u=t.call(e,n)}catch(e){u=[6,e];o=0}finally{i=a=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:true}}};import{r as registerInstance,c as createEvent,h,g as getElement}from"./index-c948674f.js";var indexCss="taro-input-core{display:block}input{display:block;overflow:hidden;height:1.4rem;text-overflow:clip;text-align:inherit;white-space:nowrap}";function getTrueType(e,t,n){if(t==="search")e="search";if(n)e="password";if(typeof e==="undefined"){return"text"}if(!e){throw new Error("unexpected type")}if(e==="digit")e="number";return e}function fixControlledValue(e){return e!==null&&e!==void 0?e:""}var Input=function(){function e(e){var t=this;registerInstance(this,e);this.onInput=createEvent(this,"input",7);this.onPaste=createEvent(this,"paste",7);this.onFocus=createEvent(this,"focus",7);this.onBlur=createEvent(this,"blur",7);this.onConfirm=createEvent(this,"confirm",7);this.onChange=createEvent(this,"change",7);this.onKeyDown=createEvent(this,"keydown",7);this.isOnComposition=false;this.isOnPaste=false;this.onInputExcuted=false;this.handleInput=function(e){e.stopPropagation();var n=t,i=n.type,o=n.maxlength,a=n.confirmType,r=n.password;if(!t.isOnComposition&&!t.onInputExcuted){var u=e.target.value;var s=getTrueType(i,a,r);t.onInputExcuted=true;if(s==="number"&&u&&o>-1&&o<=u.length){u=u.substring(0,o);e.target.value=u}t.value=u;t.onInput.emit({value:u,cursor:u.length});t.onInputExcuted=false}};this.handlePaste=function(e){e.stopPropagation();t.isOnPaste=true;t.onPaste.emit({value:e.target.value})};this.handleFocus=function(e){e.stopPropagation();t.onInputExcuted=false;t.onFocus.emit({value:e.target.value})};this.handleBlur=function(e){e.stopPropagation();t.onBlur.emit({value:e.target.value})};this.handleChange=function(e){e.stopPropagation();t.onChange.emit({value:e.target.value});if(t.isOnPaste){t.isOnPaste=false;t.value=e.target.value;t.onInput.emit({value:e.target.value,cursor:e.target.value.length})}};this.handleKeyDown=function(e){e.stopPropagation();var n=e.target.value;var i=e.keyCode||e.code;t.onInputExcuted=false;t.onKeyDown.emit({value:n,cursor:n.length,keyCode:i});i===13&&t.onConfirm.emit({value:n})};this.handleComposition=function(e){e.stopPropagation();if(!(e.target instanceof HTMLInputElement))return;if(e.type==="compositionend"){t.isOnComposition=false;t.value=e.target.value;t.onInput.emit({value:e.target.value,cursor:e.target.value.length})}else{t.isOnComposition=true}};this.handleBeforeinput=function(e){if(!e.data)return;var n=e.data&&/[0-9]/.test(e.data);if(t.type==="number"&&!n){e.preventDefault()}if(t.type==="digit"&&!n){if(e.data!=="."||e.data==="."&&e.target.value.indexOf(".")>-1){e.preventDefault()}}};this.value=undefined;this.type=undefined;this.password=false;this.placeholder=undefined;this.disabled=false;this.maxlength=140;this.autoFocus=false;this.confirmType="done";this.name=undefined;this.nativeProps={}}e.prototype.focus=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){this.inputRef.focus();return[2]}))}))};e.prototype.watchAutoFocus=function(e,t){var n;if(!t&&e){(n=this.inputRef)===null||n===void 0?void 0:n.focus()}};e.prototype.watchValue=function(e){var t=fixControlledValue(e);if(this.inputRef.value!==t){this.inputRef.value=t}};e.prototype.componentDidLoad=function(){var e=this;var t,n,i,o,a;if(this.type==="file"){this.fileListener=function(){e.onInput.emit()};(t=this.inputRef)===null||t===void 0?void 0:t.addEventListener("change",this.fileListener)}else{(n=this.inputRef)===null||n===void 0?void 0:n.addEventListener("compositionstart",this.handleComposition);(i=this.inputRef)===null||i===void 0?void 0:i.addEventListener("compositionend",this.handleComposition);(o=this.inputRef)===null||o===void 0?void 0:o.addEventListener("beforeinput",this.handleBeforeinput);(a=this.inputRef)===null||a===void 0?void 0:a.addEventListener("textInput",this.handleBeforeinput)}Object.defineProperty(this.el,"value",{get:function(){return e.inputRef.value},set:function(t){return e.value!==t&&(e.value=t)},configurable:true})};e.prototype.disconnectedCallback=function(){var e,t,n,i,o;if(this.type==="file"){(e=this.inputRef)===null||e===void 0?void 0:e.removeEventListener("change",this.fileListener)}else{(t=this.inputRef)===null||t===void 0?void 0:t.removeEventListener("compositionstart",this.handleComposition);(n=this.inputRef)===null||n===void 0?void 0:n.removeEventListener("compositionend",this.handleComposition);(i=this.inputRef)===null||i===void 0?void 0:i.removeEventListener("beforeinput",this.handleBeforeinput);(o=this.inputRef)===null||o===void 0?void 0:o.removeEventListener("textInput",this.handleBeforeinput)}};e.prototype.render=function(){var e=this;var t=this,n=t.value,i=t.type,o=t.password,a=t.placeholder,r=t.autoFocus,u=t.disabled,s=t.maxlength,l=t.confirmType,p=t.name,f=t.nativeProps;return h("input",Object.assign({ref:function(t){e.inputRef=t;if(r&&t)t.focus()},class:"weui-input",type:getTrueType(i,l,o),placeholder:a,autoFocus:r,disabled:u,maxlength:s,name:p,onInput:this.handleInput,onFocus:this.handleFocus,onBlur:this.handleBlur,onChange:this.handleChange,onKeyDown:this.handleKeyDown,onPaste:this.handlePaste,onCompositionStart:this.handleComposition,onCompositionEnd:this.handleComposition},f,{value:fixControlledValue(n)}))};Object.defineProperty(e.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});Object.defineProperty(e,"watchers",{get:function(){return{autoFocus:["watchAutoFocus"],value:["watchValue"]}},enumerable:false,configurable:true});return e}();Input.style=indexCss;export{Input as taro_input_core};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var __awaiter=this&&this.__awaiter||function(e,t,i,n){function r(e){return e instanceof i?e:new i((function(t){t(e)}))}return new(i||(i=Promise))((function(i,a){function o(e){try{s(n.next(e))}catch(e){a(e)}}function u(e){try{s(n["throw"](e))}catch(e){a(e)}}function s(e){e.done?i(e.value):r(e.value).then(o,u)}s((n=n.apply(e,t||[])).next())}))};var __generator=this&&this.__generator||function(e,t){var i={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},n,r,a,o;return o={next:u(0),throw:u(1),return:u(2)},typeof Symbol==="function"&&(o[Symbol.iterator]=function(){return this}),o;function u(e){return function(t){return s([e,t])}}function s(u){if(n)throw new TypeError("Generator is already executing.");while(o&&(o=0,u[0]&&(i=0)),i)try{if(n=1,r&&(a=u[0]&2?r["return"]:u[0]?r["throw"]||((a=r["return"])&&a.call(r),0):r.next)&&!(a=a.call(r,u[1])).done)return a;if(r=0,a)u=[u[0]&2,a.value];switch(u[0]){case 0:case 1:a=u;break;case 4:i.label++;return{value:u[1],done:false};case 5:i.label++;r=u[1];u=[0];continue;case 7:u=i.ops.pop();i.trys.pop();continue;default:if(!(a=i.trys,a=a.length>0&&a[a.length-1])&&(u[0]===6||u[0]===2)){i=0;continue}if(u[0]===3&&(!a||u[1]>a[0]&&u[1]<a[3])){i.label=u[1];break}if(u[0]===6&&i.label<a[1]){i.label=a[1];a=u;break}if(a&&i.label<a[2]){i.label=a[2];i.ops.push(u);break}if(a[2])i.ops.pop();i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e];r=0}finally{n=a=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:true}}};var __spreadArray=this&&this.__spreadArray||function(e,t,i){if(i||arguments.length===2)for(var n=0,r=t.length,a;n<r;n++){if(a||!(n in t)){if(!a)a=Array.prototype.slice.call(t,0,n);a[n]=t[n]}}return e.concat(a||Array.prototype.slice.call(t))};import{r as registerInstance,c as createEvent,h,H as Host,g as getElement}from"./index-c948674f.js";import{c as classnames}from"./index-1d8e8acd.js";function getTimeRange(e,t){var i=[];for(var n=e;n<=t;n++){i.push("".concat(n<10?"0":"").concat(n))}return i}var hoursRange=__spreadArray(__spreadArray(["20","21","22","23"],getTimeRange(0,23),true),["00","01","02","03"],false);var minutesRange=__spreadArray(__spreadArray(["56","57","58","59"],getTimeRange(0,59),true),["00","01","02","03"],false);function verifyValue(e,t){if(!isNaN(+e)&&e>=0&&e<t.length)return true;return false}function verifyTime(e){if(!/^\d{1,2}:\d{1,2}$/.test(e))return false;var t=e.split(":").map((function(e){return+e}));if(t[0]<0||t[0]>23)return false;if(t[1]<0||t[1]>59)return false;return true}function compareTime(e,t){var i=e.split(":").map((function(e){return+e}));var n=t.split(":").map((function(e){return+e}));if(i[0]<n[0])return true;if(i[0]===n[0]&&i[1]<=n[1])return true;return false}function verifyDate(e){if(!e)return false;var t=new Date(e.replace(/-/g,"/"));return isNaN(t.getMonth())?false:t}function getMaxDay(e,t){if(t===4||t===6||t===9||t===11)return 30;if(t===2){if(e%4===0&&e%100!==0||e%400===0)return 29;else return 28}return 31}function formatValue(e){var t;if(Array.isArray(e)){t=e.map((function(e){return String(e)}))}else{t=e}return t}function getDateRange(e,t){var i=[];for(var n=e;n<=t;n++){i.push(n)}return i}function getYearRange(e,t){return getDateRange(e,t)}function getMonthRange(e,t,i){var n=1;var r=12;if(e.getFullYear()===i){n=e.getMonth()+1}if(t.getFullYear()===i){r=t.getMonth()+1}return getDateRange(n,r)}function getDayRange(e,t,i,n){var r=1;var a=getMaxDay(i,n);if(e.getFullYear()===i&&e.getMonth()+1===n){r=e.getDate()}if(t.getFullYear()===i&&t.getMonth()+1===n){a=t.getDate()}return getDateRange(r,a)}var TOP=102;var LINE_HEIGHT=34;var MASK_HEIGHT=LINE_HEIGHT*7;var indexCss=".weui-picker,.weui-picker__hd{font-size:12px}";var Picker=function(){function e(e){var t=this;registerInstance(this,e);this.onChange=createEvent(this,"change",7);this.onColumnChange=createEvent(this,"columnchange",7);this.onCancel=createEvent(this,"cancel",7);this.index=[];this.showPicker=function(){if(t.disabled)return;t.height=t.getHeightByIndex();t.hidden=false};this.getHeightByIndex=function(){var e=t.index.map((function(e){var i=0;if(t.mode==="time"){i=LINE_HEIGHT*4}return TOP-LINE_HEIGHT*e-i}));return e};this.hidePicker=function(){t.fadeOut=true;setTimeout((function(){t.hidden=true;t.fadeOut=false}),350)};this.handleChange=function(){t.hidePicker();t.index=t.height.map((function(e){return(TOP-e)/LINE_HEIGHT}));var e=t.index.length&&t.mode!=="selector"?t.index:t.index[0];if(t.mode==="time"){var i=[hoursRange.slice(),minutesRange.slice()];var n=t.index.map((function(e,t){return i[t][e]}));t.index=n.map((function(e){return parseInt(e)}));e=n.join(":")}if(t.mode==="date"){var r=t.pickerDate,a=r._start,o=r._end,u=r._updateValue;var s=u[0];var h=u[1];var l=getYearRange(a.getFullYear(),o.getFullYear());var c=getMonthRange(a,o,s);var d=getDayRange(a,o,s,h);var f=l[t.index[0]];var g=c[t.index[1]];var p=d[t.index[2]];if(t.fields==="year"){e=[f]}else if(t.fields==="month"){e=[f,g]}else{e=[f,g,p]}e=e.map((function(e){return e<10?"0".concat(e):e})).join("-")}t.pickerValue=e;t.onChange.emit({value:e})};this.handleCancel=function(){t.hidePicker();t.onCancel.emit()};this.updateHeight=function(e,i,n){if(n===void 0){n=false}var r=__spreadArray([],t.height,true);r[i]=e;t.height=r;if(n){var a=t,o=a.start,u=a.end;if(!verifyTime(o))o="00:00";if(!verifyTime(u))u="23:59";if(!compareTime(o,u))return;var s=[hoursRange.slice(),minutesRange.slice()];var h=t.height.map((function(e){return(TOP-e)/LINE_HEIGHT}));var l=h.map((function(e,t){return s[t][e]})).join(":");if(!compareTime(o,l)){var c=o.split(":").map((function(e){return TOP-LINE_HEIGHT*(+e+4)}));requestAnimationFrame((function(){return t.height=c}))}else if(!compareTime(l,u)){var d=u.split(":").map((function(e){return TOP-LINE_HEIGHT*(+e+4)}));requestAnimationFrame((function(){return t.height=d}))}}};this.handleColumnChange=function(e,i){t.onColumnChange.emit({column:Number(i),value:(TOP-e)/LINE_HEIGHT})};this.updateDay=function(e,i){var n=t.pickerDate,r=n._start,a=n._end,o=n._updateValue;o[i]=e;var u=o[0];var s=o[1];var h=o[2];if(i===0){var l=getMonthRange(r,a,u);var c=l[l.length-1];var d=l[0];if(s>c)o[1]=c;if(s<d)o[1]=d;var f=l.indexOf(o[1]);var g=TOP-LINE_HEIGHT*f;t.updateDay(o[1],1);t.updateHeight(g,"1")}else if(i===1){var p=getDayRange(r,a,u,s);var c=p[p.length-1];var d=p[0];if(h>c)o[2]=c;if(h<d)o[2]=d;var f=p.indexOf(o[2]);var g=TOP-LINE_HEIGHT*f;t.updateDay(o[2],2);t.updateHeight(g,"2")}};this.getSelector=function(){return h("taro-picker-group",{range:t.range,rangeKey:t.rangeKey,height:t.height[0],updateHeight:t.updateHeight,columnId:"0"})};this.getMultiSelector=function(){return t.range.map((function(e,i){return h("taro-picker-group",{range:e,rangeKey:t.rangeKey,height:t.height[i],updateHeight:t.updateHeight,onColumnChange:t.handleColumnChange,columnId:String(i)})}))};this.getTimeSelector=function(){var e=hoursRange.slice();var i=minutesRange.slice();return[h("taro-picker-group",{mode:"time",range:e,height:t.height[0],updateHeight:t.updateHeight,columnId:"0"}),h("taro-picker-group",{mode:"time",range:i,height:t.height[1],updateHeight:t.updateHeight,columnId:"1"})]};this.getDateSelector=function(){var e=t,i=e.fields,n=e.height;var r=t.pickerDate,a=r._start,o=r._end,u=r._updateValue;var s=u[0];var l=u[1];var c=getYearRange(a.getFullYear(),o.getFullYear()).map((function(e){return"".concat(e,"年")}));var d=getMonthRange(a,o,s).map((function(e){return"".concat(e<10?"0".concat(e):e,"月")}));var f=getDayRange(a,o,s,l).map((function(e){return"".concat(e<10?"0".concat(e):e,"日")}));var g=[h("taro-picker-group",{mode:"date",range:c,height:n[0],updateDay:t.updateDay,updateHeight:t.updateHeight,columnId:"0"})];if(i==="month"||i==="day"){g.push(h("taro-picker-group",{mode:"date",range:d,height:n[1],updateDay:t.updateDay,updateHeight:t.updateHeight,columnId:"1"}))}if(i==="day"){g.push(h("taro-picker-group",{mode:"date",range:f,height:n[2],updateDay:t.updateDay,updateHeight:t.updateHeight,columnId:"2"}))}return g};this.mode="selector";this.disabled=false;this.range=[];this.rangeKey=undefined;this.value=undefined;this.start="";this.end="";this.fields="day";this.name="";this.pickerValue=[];this.height=[];this.hidden=true;this.fadeOut=false;this.isWillLoadCalled=false}e.prototype.componentWillLoad=function(){this.isWillLoadCalled=true;this.handleProps()};e.prototype.componentDidLoad=function(){var e=this;Object.defineProperty(this.el,"value",{get:function(){return e.pickerValue},set:function(t){return e.value=t},configurable:true});if(this.overlay){document.body.appendChild(this.overlay)}};e.prototype.disconnectedCallback=function(){var e;if(this.overlay){(e=this.overlay.parentNode)===null||e===void 0?void 0:e.removeChild(this.overlay)}};e.prototype.onPropsChange=function(){if(!this.isWillLoadCalled)return;this.handleProps()};e.prototype.handleProps=function(){var e=this;var t=this,i=t.mode,n=t.start,r=t.end;if(i==="selector"){var a=this.value;this.index=[verifyValue(a,this.range)?Math.floor(a):0]}else if(i==="multiSelector"){var o=this.value;this.index=[];this.range.forEach((function(t,i){var n=o===null||o===void 0?void 0:o[i];var r=verifyValue(n,t)?Math.floor(n):0;e.index.push(r)}))}else if(i==="time"){var a=this.value;if(!verifyTime(a)){console.warn("time picker value illegal");a="0:0"}var u=a.split(":").map((function(e){return+e}));this.index=u}else if(i==="date"){var a=this.value;var s=verifyDate(a)||new Date((new Date).setHours(0,0,0,0));var h=verifyDate(n)||new Date("1970/01/01");var l=verifyDate(r)||new Date("2999/01/01");if(s>=h&&s<=l){var c=s.getFullYear();var d=s.getMonth()+1;var f=s.getDate();var g=getYearRange(h.getFullYear(),l.getFullYear());var p=getMonthRange(h,l,c);var v=getDayRange(h,l,c,d);this.index=[g.indexOf(c),p.indexOf(d),v.indexOf(f)];if(!this.pickerDate||this.pickerDate._value.getTime()!==s.getTime()||this.pickerDate._start.getTime()!==h.getTime()||this.pickerDate._end.getTime()!==l.getTime()){this.pickerDate={_value:s,_start:h,_end:l,_updateValue:[c,d,f]}}}else{throw new Error("Date Interval Error")}}this.height=this.getHeightByIndex();this.pickerValue=this.value;if(i==="date"){var m=this.pickerValue;if(this.fields==="month"){this.pickerValue=m.split("-").slice(0,2).join("-")}else if(this.fields==="year"){this.pickerValue=m.split("-")[0]}}};e.prototype.render=function(){var e=this;var t=this,i=t.name,n=t.mode,r=t.fadeOut,a=t.hidden;var o;switch(n){case"multiSelector":o=this.getMultiSelector();break;case"time":o=this.getTimeSelector();break;case"date":o=this.getDateSelector();break;default:o=this.getSelector()}var u=classnames("weui-mask","weui-animate-fade-in",{"weui-animate-fade-out":r});var s=classnames("weui-picker","weui-animate-slide-up",{"weui-animate-slide-down":r});var l=a?{display:"none"}:{};return h(Host,null,h("div",{onClick:this.showPicker},h("slot",null),h("input",{type:"hidden",name:i,value:formatValue(this.pickerValue)})),h("div",{class:"weui-picker__overlay",style:l,ref:function(t){e.overlay=t}},h("div",{class:u,onClick:this.handleCancel}),h("div",{class:s},h("div",{class:"weui-picker__hd"},h("div",{class:"weui-picker__action",onClick:this.handleCancel},"取消"),h("div",{class:"weui-picker__action",onClick:this.handleChange},"确定")),h("div",{class:"weui-picker__bd"},o),h("input",{type:"hidden",name:i,value:formatValue(this.pickerValue)}))))};Object.defineProperty(e.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});Object.defineProperty(e,"watchers",{get:function(){return{mode:["onPropsChange"],value:["onPropsChange"],range:["onPropsChange"],start:["onPropsChange"],end:["onPropsChange"]}},enumerable:false,configurable:true});return e}();Picker.style=indexCss;var TaroPickerGroup=function(){function e(e){registerInstance(this,e);this.mode=undefined;this.range=[];this.rangeKey=undefined;this.height=undefined;this.columnId=undefined;this.updateHeight=undefined;this.onColumnChange=undefined;this.updateDay=undefined;this.startY=undefined;this.preY=undefined;this.hadMove=undefined;this.touchEnd=undefined;this.isMove=undefined}e.prototype.getPosition=function(){var e=this.touchEnd?.3:0;var t="translate3d(0, ".concat(this.height,"px, 0)");var i="transform ".concat(e,"s");return{transform:t,"-webkit-transform":t,transition:i,"-webkit-transition":i}};e.prototype.formulaUnlimitedScroll=function(e,t,i){var n=this;var r=this,a=r.height,o=r.updateHeight,u=r.columnId;var s=i==="up"?1:-1;this.touchEnd=false;o(-e*s*LINE_HEIGHT+a,u);requestAnimationFrame((function(){n.touchEnd=true;var i=Math.round(t/-LINE_HEIGHT)+e*s;var r=TOP-LINE_HEIGHT*i;o(r,u,true)}))};e.prototype.handleMoveStart=function(e){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){this.startY=e;this.preY=e;this.hadMove=false;return[2]}))}))};e.prototype.handleMoving=function(e){return __awaiter(this,void 0,void 0,(function(){var t,i,n;return __generator(this,(function(r){t=e;i=t-this.preY;this.preY=t;this.touchEnd=false;if(Math.abs(t-this.startY)>10)this.hadMove=true;n=this.height+i;if(this.mode==="time"){if(this.columnId==="0"){if(n>TOP-LINE_HEIGHT*3){n=TOP-LINE_HEIGHT*27+i}if(n<TOP-LINE_HEIGHT*28){n=TOP-LINE_HEIGHT*4+i}}else if(this.columnId==="1"){if(n>TOP-LINE_HEIGHT*3){n=TOP-LINE_HEIGHT*63+i}if(n<TOP-LINE_HEIGHT*64){n=TOP-LINE_HEIGHT*4+i}}}this.updateHeight(n,this.columnId);return[2]}))}))};e.prototype.handleMoveEnd=function(e){return __awaiter(this,void 0,void 0,(function(){var t,i,n,r,a,o,u,s,h,l,c,d,f,g,p;return __generator(this,(function(v){t=this,i=t.mode,n=t.range,r=t.height,a=t.updateHeight,o=t.onColumnChange,u=t.columnId;s=0;h=-LINE_HEIGHT*(n.length-1);l=e;this.touchEnd=true;if(!this.hadMove){d=window.innerHeight;f=d-MASK_HEIGHT/2;c=r-TOP-(l-f);if(i==="time"){if(u==="0"){if(c>-LINE_HEIGHT*2.5){return[2,this.formulaUnlimitedScroll(24,c,"up")]}if(c<-LINE_HEIGHT*28.5){return[2,this.formulaUnlimitedScroll(24,c,"down")]}}else if(u==="1"){if(c>-LINE_HEIGHT*2.5){return[2,this.formulaUnlimitedScroll(60,c,"up")]}if(c<-LINE_HEIGHT*64.5){return[2,this.formulaUnlimitedScroll(60,c,"down")]}}}}else{c=r-TOP}if(c>s)c=0;if(c<h)c=h;g=Math.round(c/-LINE_HEIGHT);p=TOP-LINE_HEIGHT*g;if(this.mode==="date"){if(this.columnId==="0"){this.updateDay(+this.range[g].replace(/[^0-9]/gi,""),0)}if(this.columnId==="1"){this.updateDay(+this.range[g].replace(/[^0-9]/gi,""),1)}if(this.columnId==="2"){this.updateDay(+this.range[g].replace(/[^0-9]/gi,""),2)}}a(p,u,i==="time");o&&o(p,u);return[2]}))}))};e.prototype.onMouseDown=function(e){this.isMove=true;this.handleMoveStart(e.clientY)};e.prototype.onMouseMove=function(e){e.preventDefault();if(!this.isMove)return;this.handleMoving(e.clientY)};e.prototype.onMouseMoveEnd=function(e){if(!this.isMove)return;this.isMove=false;this.handleMoveEnd(e.clientY)};e.prototype.onTouchStart=function(e){this.handleMoveStart(e.changedTouches[0].clientY)};e.prototype.onTouchMove=function(e){e.preventDefault();this.handleMoving(e.changedTouches[0].clientY)};e.prototype.onTouchEnd=function(e){this.handleMoveEnd(e.changedTouches[0].clientY)};e.prototype.render=function(){var e=this,t=e.range,i=e.rangeKey;var n=t.map((function(e){var t=i?e[i]:e;return h("div",{class:"weui-picker__item"},t)}));return h(Host,{class:"weui-picker__group"},h("div",{class:"weui-picker__mask"}),h("div",{class:"weui-picker__indicator"}),h("div",{class:"weui-picker__content",style:this.getPosition()},n))};return e}();export{Picker as taro_picker_core,TaroPickerGroup as taro_picker_group};
|
|
1
|
+
var __awaiter=this&&this.__awaiter||function(e,t,i,n){function r(e){return e instanceof i?e:new i((function(t){t(e)}))}return new(i||(i=Promise))((function(i,a){function o(e){try{s(n.next(e))}catch(e){a(e)}}function u(e){try{s(n["throw"](e))}catch(e){a(e)}}function s(e){e.done?i(e.value):r(e.value).then(o,u)}s((n=n.apply(e,t||[])).next())}))};var __generator=this&&this.__generator||function(e,t){var i={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},n,r,a,o;return o={next:u(0),throw:u(1),return:u(2)},typeof Symbol==="function"&&(o[Symbol.iterator]=function(){return this}),o;function u(e){return function(t){return s([e,t])}}function s(u){if(n)throw new TypeError("Generator is already executing.");while(o&&(o=0,u[0]&&(i=0)),i)try{if(n=1,r&&(a=u[0]&2?r["return"]:u[0]?r["throw"]||((a=r["return"])&&a.call(r),0):r.next)&&!(a=a.call(r,u[1])).done)return a;if(r=0,a)u=[u[0]&2,a.value];switch(u[0]){case 0:case 1:a=u;break;case 4:i.label++;return{value:u[1],done:false};case 5:i.label++;r=u[1];u=[0];continue;case 7:u=i.ops.pop();i.trys.pop();continue;default:if(!(a=i.trys,a=a.length>0&&a[a.length-1])&&(u[0]===6||u[0]===2)){i=0;continue}if(u[0]===3&&(!a||u[1]>a[0]&&u[1]<a[3])){i.label=u[1];break}if(u[0]===6&&i.label<a[1]){i.label=a[1];a=u;break}if(a&&i.label<a[2]){i.label=a[2];i.ops.push(u);break}if(a[2])i.ops.pop();i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e];r=0}finally{n=a=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:true}}};var __spreadArray=this&&this.__spreadArray||function(e,t,i){if(i||arguments.length===2)for(var n=0,r=t.length,a;n<r;n++){if(a||!(n in t)){if(!a)a=Array.prototype.slice.call(t,0,n);a[n]=t[n]}}return e.concat(a||Array.prototype.slice.call(t))};import{r as registerInstance,c as createEvent,h,H as Host,g as getElement}from"./index-c948674f.js";import{c as classnames}from"./index-1d8e8acd.js";function getTimeRange(e,t){var i=[];for(var n=e;n<=t;n++){i.push("".concat(n<10?"0":"").concat(n))}return i}var hoursRange=__spreadArray(__spreadArray(["20","21","22","23"],getTimeRange(0,23),true),["00","01","02","03"],false);var minutesRange=__spreadArray(__spreadArray(["56","57","58","59"],getTimeRange(0,59),true),["00","01","02","03"],false);function verifyValue(e,t){if(!isNaN(+e)&&e>=0&&e<t.length)return true;return false}function verifyTime(e){if(!/^\d{1,2}:\d{1,2}$/.test(e))return false;var t=e.split(":").map((function(e){return+e}));if(t[0]<0||t[0]>23)return false;if(t[1]<0||t[1]>59)return false;return true}function compareTime(e,t){var i=e.split(":").map((function(e){return+e}));var n=t.split(":").map((function(e){return+e}));if(i[0]<n[0])return true;if(i[0]===n[0]&&i[1]<=n[1])return true;return false}function verifyDate(e){if(!e)return false;var t=new Date(e.replace(/-/g,"/"));return isNaN(t.getMonth())?false:t}function getMaxDay(e,t){if(t===4||t===6||t===9||t===11)return 30;if(t===2){if(e%4===0&&e%100!==0||e%400===0)return 29;else return 28}return 31}function formatValue(e){var t;if(Array.isArray(e)){t=e.map((function(e){return String(e)}))}else{t=e}return t}function getDateRange(e,t){var i=[];for(var n=e;n<=t;n++){i.push(n)}return i}function getYearRange(e,t){return getDateRange(e,t)}function getMonthRange(e,t,i){var n=1;var r=12;if(e.getFullYear()===i){n=e.getMonth()+1}if(t.getFullYear()===i){r=t.getMonth()+1}return getDateRange(n,r)}function getDayRange(e,t,i,n){var r=1;var a=getMaxDay(i,n);if(e.getFullYear()===i&&e.getMonth()+1===n){r=e.getDate()}if(t.getFullYear()===i&&t.getMonth()+1===n){a=t.getDate()}return getDateRange(r,a)}var TOP=102;var LINE_HEIGHT=34;var MASK_HEIGHT=LINE_HEIGHT*7;var indexCss=".weui-picker,.weui-picker__hd{font-size:12px}";var Picker=function(){function e(e){var t=this;registerInstance(this,e);this.onChange=createEvent(this,"change",7);this.onColumnChange=createEvent(this,"columnchange",7);this.onCancel=createEvent(this,"cancel",7);this.index=[];this.showPicker=function(){if(t.disabled)return;t.height=t.getHeightByIndex();t.hidden=false};this.getHeightByIndex=function(){var e=t.index.map((function(e){var i=0;if(t.mode==="time"){i=LINE_HEIGHT*4}return TOP-LINE_HEIGHT*e-i}));return e};this.hidePicker=function(){t.fadeOut=true;setTimeout((function(){t.hidden=true;t.fadeOut=false}),350)};this.handleChange=function(){t.hidePicker();t.index=t.height.map((function(e){return(TOP-e)/LINE_HEIGHT}));var e=t.index.length&&t.mode!=="selector"?t.index:t.index[0];if(t.mode==="time"){var i=[hoursRange.slice(),minutesRange.slice()];var n=t.index.map((function(e,t){return i[t][e]}));t.index=n.map((function(e){return parseInt(e)}));e=n.join(":")}if(t.mode==="date"){var r=t.pickerDate,a=r._start,o=r._end,u=r._updateValue;var s=u[0];var h=u[1];var l=getYearRange(a.getFullYear(),o.getFullYear());var c=getMonthRange(a,o,s);var d=getDayRange(a,o,s,h);var f=l[t.index[0]];var g=c[t.index[1]];var p=d[t.index[2]];if(t.fields==="year"){e=[f]}else if(t.fields==="month"){e=[f,g]}else{e=[f,g,p]}e=e.map((function(e){return e<10?"0".concat(e):e})).join("-")}t.pickerValue=e;t.onChange.emit({value:e})};this.handleCancel=function(){t.hidePicker();t.onCancel.emit()};this.updateHeight=function(e,i,n){if(n===void 0){n=false}var r=__spreadArray([],t.height,true);r[i]=e;t.height=r;if(n){var a=t,o=a.start,u=a.end;if(!verifyTime(o))o="00:00";if(!verifyTime(u))u="23:59";if(!compareTime(o,u))return;var s=[hoursRange.slice(),minutesRange.slice()];var h=t.height.map((function(e){return(TOP-e)/LINE_HEIGHT}));var l=h.map((function(e,t){return s[t][e]})).join(":");if(!compareTime(o,l)){var c=o.split(":").map((function(e){return TOP-LINE_HEIGHT*(+e+4)}));requestAnimationFrame((function(){return t.height=c}))}else if(!compareTime(l,u)){var d=u.split(":").map((function(e){return TOP-LINE_HEIGHT*(+e+4)}));requestAnimationFrame((function(){return t.height=d}))}}};this.handleColumnChange=function(e,i){t.onColumnChange.emit({column:Number(i),value:(TOP-e)/LINE_HEIGHT})};this.updateDay=function(e,i){var n=t.pickerDate,r=n._start,a=n._end,o=n._updateValue;o[i]=e;var u=o[0];var s=o[1];var h=o[2];if(i===0){var l=getMonthRange(r,a,u);var c=l[l.length-1];var d=l[0];if(s>c)o[1]=c;if(s<d)o[1]=d;var f=l.indexOf(o[1]);var g=TOP-LINE_HEIGHT*f;t.updateDay(o[1],1);t.updateHeight(g,"1")}else if(i===1){var p=getDayRange(r,a,u,s);var c=p[p.length-1];var d=p[0];if(h>c)o[2]=c;if(h<d)o[2]=d;var f=p.indexOf(o[2]);var g=TOP-LINE_HEIGHT*f;t.updateDay(o[2],2);t.updateHeight(g,"2")}};this.getSelector=function(){return h("taro-picker-group",{range:t.range,rangeKey:t.rangeKey,height:t.height[0],updateHeight:t.updateHeight,columnId:"0"})};this.getMultiSelector=function(){return t.range.map((function(e,i){return h("taro-picker-group",{range:e,rangeKey:t.rangeKey,height:t.height[i],updateHeight:t.updateHeight,onColumnChange:t.handleColumnChange,columnId:String(i)})}))};this.getTimeSelector=function(){var e=hoursRange.slice();var i=minutesRange.slice();return[h("taro-picker-group",{mode:"time",range:e,height:t.height[0],updateHeight:t.updateHeight,columnId:"0"}),h("taro-picker-group",{mode:"time",range:i,height:t.height[1],updateHeight:t.updateHeight,columnId:"1"})]};this.getDateSelector=function(){var e=t,i=e.fields,n=e.height;var r=t.pickerDate,a=r._start,o=r._end,u=r._updateValue;var s=u[0];var l=u[1];var c=getYearRange(a.getFullYear(),o.getFullYear()).map((function(e){return"".concat(e,"年")}));var d=getMonthRange(a,o,s).map((function(e){return"".concat(e<10?"0".concat(e):e,"月")}));var f=getDayRange(a,o,s,l).map((function(e){return"".concat(e<10?"0".concat(e):e,"日")}));var g=[h("taro-picker-group",{mode:"date",range:c,height:n[0],updateDay:t.updateDay,updateHeight:t.updateHeight,columnId:"0"})];if(i==="month"||i==="day"){g.push(h("taro-picker-group",{mode:"date",range:d,height:n[1],updateDay:t.updateDay,updateHeight:t.updateHeight,columnId:"1"}))}if(i==="day"){g.push(h("taro-picker-group",{mode:"date",range:f,height:n[2],updateDay:t.updateDay,updateHeight:t.updateHeight,columnId:"2"}))}return g};this.mode="selector";this.disabled=false;this.range=[];this.rangeKey=undefined;this.value=undefined;this.start="";this.end="";this.fields="day";this.name="";this.pickerValue=[];this.height=[];this.hidden=true;this.fadeOut=false;this.isWillLoadCalled=false}e.prototype.componentWillLoad=function(){this.isWillLoadCalled=true;this.handleProps()};e.prototype.componentDidLoad=function(){var e=this;Object.defineProperty(this.el,"value",{get:function(){return e.pickerValue},set:function(t){return e.value!==t&&(e.value=t)},configurable:true});if(this.overlay){document.body.appendChild(this.overlay)}};e.prototype.disconnectedCallback=function(){var e;if(this.overlay){(e=this.overlay.parentNode)===null||e===void 0?void 0:e.removeChild(this.overlay)}};e.prototype.onPropsChange=function(){if(!this.isWillLoadCalled)return;this.handleProps()};e.prototype.handleProps=function(){var e=this;var t=this,i=t.mode,n=t.start,r=t.end;if(i==="selector"){var a=this.value;this.index=[verifyValue(a,this.range)?Math.floor(a):0]}else if(i==="multiSelector"){var o=this.value;this.index=[];this.range.forEach((function(t,i){var n=o===null||o===void 0?void 0:o[i];var r=verifyValue(n,t)?Math.floor(n):0;e.index.push(r)}))}else if(i==="time"){var a=this.value;if(!verifyTime(a)){console.warn("time picker value illegal");a="0:0"}var u=a.split(":").map((function(e){return+e}));this.index=u}else if(i==="date"){var a=this.value;var s=verifyDate(a)||new Date((new Date).setHours(0,0,0,0));var h=verifyDate(n)||new Date("1970/01/01");var l=verifyDate(r)||new Date("2999/01/01");if(s>=h&&s<=l){var c=s.getFullYear();var d=s.getMonth()+1;var f=s.getDate();var g=getYearRange(h.getFullYear(),l.getFullYear());var p=getMonthRange(h,l,c);var v=getDayRange(h,l,c,d);this.index=[g.indexOf(c),p.indexOf(d),v.indexOf(f)];if(!this.pickerDate||this.pickerDate._value.getTime()!==s.getTime()||this.pickerDate._start.getTime()!==h.getTime()||this.pickerDate._end.getTime()!==l.getTime()){this.pickerDate={_value:s,_start:h,_end:l,_updateValue:[c,d,f]}}}else{throw new Error("Date Interval Error")}}this.height=this.getHeightByIndex();this.pickerValue=this.value;if(i==="date"){var m=this.pickerValue;if(this.fields==="month"){this.pickerValue=m.split("-").slice(0,2).join("-")}else if(this.fields==="year"){this.pickerValue=m.split("-")[0]}}};e.prototype.render=function(){var e=this;var t=this,i=t.name,n=t.mode,r=t.fadeOut,a=t.hidden;var o;switch(n){case"multiSelector":o=this.getMultiSelector();break;case"time":o=this.getTimeSelector();break;case"date":o=this.getDateSelector();break;default:o=this.getSelector()}var u=classnames("weui-mask","weui-animate-fade-in",{"weui-animate-fade-out":r});var s=classnames("weui-picker","weui-animate-slide-up",{"weui-animate-slide-down":r});var l=a?{display:"none"}:{};return h(Host,null,h("div",{onClick:this.showPicker},h("slot",null),h("input",{type:"hidden",name:i,value:formatValue(this.pickerValue)})),h("div",{class:"weui-picker__overlay",style:l,ref:function(t){e.overlay=t}},h("div",{class:u,onClick:this.handleCancel}),h("div",{class:s},h("div",{class:"weui-picker__hd"},h("div",{class:"weui-picker__action",onClick:this.handleCancel},"取消"),h("div",{class:"weui-picker__action",onClick:this.handleChange},"确定")),h("div",{class:"weui-picker__bd"},o),h("input",{type:"hidden",name:i,value:formatValue(this.pickerValue)}))))};Object.defineProperty(e.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});Object.defineProperty(e,"watchers",{get:function(){return{mode:["onPropsChange"],value:["onPropsChange"],range:["onPropsChange"],start:["onPropsChange"],end:["onPropsChange"]}},enumerable:false,configurable:true});return e}();Picker.style=indexCss;var TaroPickerGroup=function(){function e(e){registerInstance(this,e);this.mode=undefined;this.range=[];this.rangeKey=undefined;this.height=undefined;this.columnId=undefined;this.updateHeight=undefined;this.onColumnChange=undefined;this.updateDay=undefined;this.startY=undefined;this.preY=undefined;this.hadMove=undefined;this.touchEnd=undefined;this.isMove=undefined}e.prototype.getPosition=function(){var e=this.touchEnd?.3:0;var t="translate3d(0, ".concat(this.height,"px, 0)");var i="transform ".concat(e,"s");return{transform:t,"-webkit-transform":t,transition:i,"-webkit-transition":i}};e.prototype.formulaUnlimitedScroll=function(e,t,i){var n=this;var r=this,a=r.height,o=r.updateHeight,u=r.columnId;var s=i==="up"?1:-1;this.touchEnd=false;o(-e*s*LINE_HEIGHT+a,u);requestAnimationFrame((function(){n.touchEnd=true;var i=Math.round(t/-LINE_HEIGHT)+e*s;var r=TOP-LINE_HEIGHT*i;o(r,u,true)}))};e.prototype.handleMoveStart=function(e){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){this.startY=e;this.preY=e;this.hadMove=false;return[2]}))}))};e.prototype.handleMoving=function(e){return __awaiter(this,void 0,void 0,(function(){var t,i,n;return __generator(this,(function(r){t=e;i=t-this.preY;this.preY=t;this.touchEnd=false;if(Math.abs(t-this.startY)>10)this.hadMove=true;n=this.height+i;if(this.mode==="time"){if(this.columnId==="0"){if(n>TOP-LINE_HEIGHT*3){n=TOP-LINE_HEIGHT*27+i}if(n<TOP-LINE_HEIGHT*28){n=TOP-LINE_HEIGHT*4+i}}else if(this.columnId==="1"){if(n>TOP-LINE_HEIGHT*3){n=TOP-LINE_HEIGHT*63+i}if(n<TOP-LINE_HEIGHT*64){n=TOP-LINE_HEIGHT*4+i}}}this.updateHeight(n,this.columnId);return[2]}))}))};e.prototype.handleMoveEnd=function(e){return __awaiter(this,void 0,void 0,(function(){var t,i,n,r,a,o,u,s,h,l,c,d,f,g,p;return __generator(this,(function(v){t=this,i=t.mode,n=t.range,r=t.height,a=t.updateHeight,o=t.onColumnChange,u=t.columnId;s=0;h=-LINE_HEIGHT*(n.length-1);l=e;this.touchEnd=true;if(!this.hadMove){d=window.innerHeight;f=d-MASK_HEIGHT/2;c=r-TOP-(l-f);if(i==="time"){if(u==="0"){if(c>-LINE_HEIGHT*2.5){return[2,this.formulaUnlimitedScroll(24,c,"up")]}if(c<-LINE_HEIGHT*28.5){return[2,this.formulaUnlimitedScroll(24,c,"down")]}}else if(u==="1"){if(c>-LINE_HEIGHT*2.5){return[2,this.formulaUnlimitedScroll(60,c,"up")]}if(c<-LINE_HEIGHT*64.5){return[2,this.formulaUnlimitedScroll(60,c,"down")]}}}}else{c=r-TOP}if(c>s)c=0;if(c<h)c=h;g=Math.round(c/-LINE_HEIGHT);p=TOP-LINE_HEIGHT*g;if(this.mode==="date"){if(this.columnId==="0"){this.updateDay(+this.range[g].replace(/[^0-9]/gi,""),0)}if(this.columnId==="1"){this.updateDay(+this.range[g].replace(/[^0-9]/gi,""),1)}if(this.columnId==="2"){this.updateDay(+this.range[g].replace(/[^0-9]/gi,""),2)}}a(p,u,i==="time");o&&o(p,u);return[2]}))}))};e.prototype.onMouseDown=function(e){this.isMove=true;this.handleMoveStart(e.clientY)};e.prototype.onMouseMove=function(e){e.preventDefault();if(!this.isMove)return;this.handleMoving(e.clientY)};e.prototype.onMouseMoveEnd=function(e){if(!this.isMove)return;this.isMove=false;this.handleMoveEnd(e.clientY)};e.prototype.onTouchStart=function(e){this.handleMoveStart(e.changedTouches[0].clientY)};e.prototype.onTouchMove=function(e){e.preventDefault();this.handleMoving(e.changedTouches[0].clientY)};e.prototype.onTouchEnd=function(e){this.handleMoveEnd(e.changedTouches[0].clientY)};e.prototype.render=function(){var e=this,t=e.range,i=e.rangeKey;var n=t.map((function(e){var t=i?e[i]:e;return h("div",{class:"weui-picker__item"},t)}));return h(Host,{class:"weui-picker__group"},h("div",{class:"weui-picker__mask"}),h("div",{class:"weui-picker__indicator"}),h("div",{class:"weui-picker__content",style:this.getPosition()},n))};return e}();export{Picker as taro_picker_core,TaroPickerGroup as taro_picker_group};
|