@tarojs/components 3.6.5 → 3.7.0-alpha.1

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.
Files changed (29) hide show
  1. package/dist/cjs/taro-swiper-core_2.cjs.entry.js +14 -3
  2. package/dist/cjs/taro-textarea-core.cjs.entry.js +14 -1
  3. package/dist/collection/components/swiper/swiper.js +14 -3
  4. package/dist/collection/components/textarea/textarea.js +42 -1
  5. package/dist/components/taro-swiper-core.js +14 -3
  6. package/dist/components/taro-textarea-core.js +14 -1
  7. package/dist/esm/taro-swiper-core_2.entry.js +14 -3
  8. package/dist/esm/taro-textarea-core.entry.js +14 -1
  9. package/dist/esm-es5/taro-swiper-core_2.entry.js +1 -1
  10. package/dist/esm-es5/taro-textarea-core.entry.js +1 -1
  11. package/dist/taro-components/{p-ba7cb688.entry.js → p-1e43a2d5.entry.js} +1 -1
  12. package/dist/taro-components/p-2c89af5b.system.entry.js +1 -0
  13. package/dist/taro-components/{p-f7baa03f.system.entry.js → p-5905e3ef.system.entry.js} +1 -1
  14. package/dist/taro-components/p-d9e2e3aa.entry.js +1 -0
  15. package/dist/taro-components/p-ed331c06.system.js +1 -1
  16. package/dist/taro-components/taro-components.esm.js +1 -1
  17. package/dist/types/components/textarea/textarea.d.ts +3 -0
  18. package/dist/types/components.d.ts +2 -0
  19. package/lib/vue2/components.js +1 -1
  20. package/lib/vue2/components.js.map +1 -1
  21. package/lib/vue3/components.js +3 -1
  22. package/lib/vue3/components.js.map +1 -1
  23. package/package.json +4 -4
  24. package/types/Input.d.ts +0 -1
  25. package/types/Map.d.ts +1 -0
  26. package/types/Picker.d.ts +4 -4
  27. package/types/Textarea.d.ts +1 -1
  28. package/dist/taro-components/p-cfb01848.system.entry.js +0 -1
  29. package/dist/taro-components/p-d8831b3c.entry.js +0 -1
@@ -10047,7 +10047,7 @@ const Swiper = class {
10047
10047
  direction: vertical ? 'vertical' : 'horizontal',
10048
10048
  loop: circular,
10049
10049
  slidesPerView: displayMultipleItems,
10050
- initialSlide: current,
10050
+ initialSlide: circular ? current + 1 : current,
10051
10051
  speed: duration,
10052
10052
  observer: true,
10053
10053
  observeParents: true,
@@ -10056,8 +10056,19 @@ const Swiper = class {
10056
10056
  slideTo() {
10057
10057
  that.current = this.realIndex;
10058
10058
  },
10059
- // slideChange 事件在 swiper.slideTo 改写 current 时不触发,因此用 slideChangeTransitionStart 事件代替
10060
- slideChangeTransitionStart(_swiper) {
10059
+ // Note: slideChange 事件在 swiper.slideTo 改写 current 时不触发,因此用 slideChangeTransitionEnd 事件代替
10060
+ slideChangeTransitionEnd() {
10061
+ /** Note: 此处不能使用 slideChangeTransitionStart 事件
10062
+ * - 因为在它触发时 swiper 各个参数并未准备好,将会导致错误的事件抛出;
10063
+ * - 同时抛出 change 事件会导致 current 监听被打乱 swiper 的生命周期;
10064
+ * - 模式与 slideTo 结合时,会导致动画会被中断、slider 展示不完整或衔接模式错误等问题。
10065
+ */
10066
+ if (circular) {
10067
+ if (this.isBeginning || this.isEnd) {
10068
+ this.slideToLoop(this.realIndex, 0); // 更新下标
10069
+ return;
10070
+ }
10071
+ }
10061
10072
  that.onChange.emit({
10062
10073
  current: this.realIndex,
10063
10074
  source: ''
@@ -15,8 +15,10 @@ const Textarea = class {
15
15
  this.onInput = index.createEvent(this, "input", 7);
16
16
  this.onFocus = index.createEvent(this, "focus", 7);
17
17
  this.onBlur = index.createEvent(this, "blur", 7);
18
+ this.onConfirm = index.createEvent(this, "confirm", 7);
18
19
  this.onChange = index.createEvent(this, "change", 7);
19
20
  this.onLineChange = index.createEvent(this, "linechange", 7);
21
+ this.onKeyDown = index.createEvent(this, "keydown", 7);
20
22
  this.handleInput = (e) => {
21
23
  e.stopPropagation();
22
24
  this.handleLineChange();
@@ -54,6 +56,17 @@ const Textarea = class {
54
56
  });
55
57
  }
56
58
  };
59
+ this.handleKeyDown = (e) => {
60
+ e.stopPropagation();
61
+ const { value } = e.target;
62
+ const keyCode = e.keyCode || e.code;
63
+ this.onKeyDown.emit({
64
+ value,
65
+ cursor: value.length,
66
+ keyCode
67
+ });
68
+ keyCode === 13 && this.onConfirm.emit({ value });
69
+ };
57
70
  this.calculateContentHeight = (ta, scanAmount) => {
58
71
  let origHeight = ta.style.height, height = ta.offsetHeight, scrollHeight = ta.scrollHeight, overflow = ta.style.overflow, originMinHeight = ta.style.minHeight || null;
59
72
  /// only bother if the ta is bigger than content
@@ -136,7 +149,7 @@ const Textarea = class {
136
149
  if (autoFocus && input)
137
150
  input.focus();
138
151
  }
139
- }, class: `taro-textarea ${autoHeight ? 'auto-height' : ''}`, value: fixControlledValue(value), placeholder: placeholder, name: name, disabled: disabled, maxlength: maxlength, autofocus: autoFocus, onInput: handleInput, onFocus: handleFocus, onBlur: handleBlur, onChange: handleChange }, nativeProps, otherProps)));
152
+ }, class: `taro-textarea ${autoHeight ? 'auto-height' : ''}`, value: fixControlledValue(value), placeholder: placeholder, name: name, disabled: disabled, maxlength: maxlength, autofocus: autoFocus, onInput: handleInput, onFocus: handleFocus, onBlur: handleBlur, onChange: handleChange, onKeyDown: this.handleKeyDown }, nativeProps, otherProps)));
140
153
  }
141
154
  get el() { return index.getElement(this); }
142
155
  static get watchers() { return {
@@ -189,7 +189,7 @@ export class Swiper {
189
189
  direction: vertical ? 'vertical' : 'horizontal',
190
190
  loop: circular,
191
191
  slidesPerView: displayMultipleItems,
192
- initialSlide: current,
192
+ initialSlide: circular ? current + 1 : current,
193
193
  speed: duration,
194
194
  observer: true,
195
195
  observeParents: true,
@@ -198,8 +198,19 @@ export class Swiper {
198
198
  slideTo() {
199
199
  that.current = this.realIndex;
200
200
  },
201
- // slideChange 事件在 swiper.slideTo 改写 current 时不触发,因此用 slideChangeTransitionStart 事件代替
202
- slideChangeTransitionStart(_swiper) {
201
+ // Note: slideChange 事件在 swiper.slideTo 改写 current 时不触发,因此用 slideChangeTransitionEnd 事件代替
202
+ slideChangeTransitionEnd() {
203
+ /** Note: 此处不能使用 slideChangeTransitionStart 事件
204
+ * - 因为在它触发时 swiper 各个参数并未准备好,将会导致错误的事件抛出;
205
+ * - 同时抛出 change 事件会导致 current 监听被打乱 swiper 的生命周期;
206
+ * - 模式与 slideTo 结合时,会导致动画会被中断、slider 展示不完整或衔接模式错误等问题。
207
+ */
208
+ if (circular) {
209
+ if (this.isBeginning || this.isEnd) {
210
+ this.slideToLoop(this.realIndex, 0); // 更新下标
211
+ return;
212
+ }
213
+ }
203
214
  that.onChange.emit({
204
215
  current: this.realIndex,
205
216
  source: ''
@@ -41,6 +41,17 @@ export class Textarea {
41
41
  });
42
42
  }
43
43
  };
44
+ this.handleKeyDown = (e) => {
45
+ e.stopPropagation();
46
+ const { value } = e.target;
47
+ const keyCode = e.keyCode || e.code;
48
+ this.onKeyDown.emit({
49
+ value,
50
+ cursor: value.length,
51
+ keyCode
52
+ });
53
+ keyCode === 13 && this.onConfirm.emit({ value });
54
+ };
44
55
  this.calculateContentHeight = (ta, scanAmount) => {
45
56
  let origHeight = ta.style.height, height = ta.offsetHeight, scrollHeight = ta.scrollHeight, overflow = ta.style.overflow, originMinHeight = ta.style.minHeight || null;
46
57
  /// only bother if the ta is bigger than content
@@ -123,7 +134,7 @@ export class Textarea {
123
134
  if (autoFocus && input)
124
135
  input.focus();
125
136
  }
126
- }, class: `taro-textarea ${autoHeight ? 'auto-height' : ''}`, value: fixControlledValue(value), placeholder: placeholder, name: name, disabled: disabled, maxlength: maxlength, autofocus: autoFocus, onInput: handleInput, onFocus: handleFocus, onBlur: handleBlur, onChange: handleChange }, nativeProps, otherProps)));
137
+ }, class: `taro-textarea ${autoHeight ? 'auto-height' : ''}`, value: fixControlledValue(value), placeholder: placeholder, name: name, disabled: disabled, maxlength: maxlength, autofocus: autoFocus, onInput: handleInput, onFocus: handleFocus, onBlur: handleBlur, onChange: handleChange, onKeyDown: this.handleKeyDown }, nativeProps, otherProps)));
127
138
  }
128
139
  static get is() { return "taro-textarea-core"; }
129
140
  static get originalStyleUrls() {
@@ -330,6 +341,21 @@ export class Textarea {
330
341
  "resolved": "any",
331
342
  "references": {}
332
343
  }
344
+ }, {
345
+ "method": "onConfirm",
346
+ "name": "confirm",
347
+ "bubbles": true,
348
+ "cancelable": true,
349
+ "composed": true,
350
+ "docs": {
351
+ "tags": [],
352
+ "text": ""
353
+ },
354
+ "complexType": {
355
+ "original": "any",
356
+ "resolved": "any",
357
+ "references": {}
358
+ }
333
359
  }, {
334
360
  "method": "onChange",
335
361
  "name": "change",
@@ -360,6 +386,21 @@ export class Textarea {
360
386
  "resolved": "any",
361
387
  "references": {}
362
388
  }
389
+ }, {
390
+ "method": "onKeyDown",
391
+ "name": "keydown",
392
+ "bubbles": true,
393
+ "cancelable": true,
394
+ "composed": true,
395
+ "docs": {
396
+ "tags": [],
397
+ "text": ""
398
+ },
399
+ "complexType": {
400
+ "original": "any",
401
+ "resolved": "any",
402
+ "references": {}
403
+ }
363
404
  }];
364
405
  }
365
406
  static get methods() {
@@ -10044,7 +10044,7 @@ const Swiper = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement$1 {
10044
10044
  direction: vertical ? 'vertical' : 'horizontal',
10045
10045
  loop: circular,
10046
10046
  slidesPerView: displayMultipleItems,
10047
- initialSlide: current,
10047
+ initialSlide: circular ? current + 1 : current,
10048
10048
  speed: duration,
10049
10049
  observer: true,
10050
10050
  observeParents: true,
@@ -10053,8 +10053,19 @@ const Swiper = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement$1 {
10053
10053
  slideTo() {
10054
10054
  that.current = this.realIndex;
10055
10055
  },
10056
- // slideChange 事件在 swiper.slideTo 改写 current 时不触发,因此用 slideChangeTransitionStart 事件代替
10057
- slideChangeTransitionStart(_swiper) {
10056
+ // Note: slideChange 事件在 swiper.slideTo 改写 current 时不触发,因此用 slideChangeTransitionEnd 事件代替
10057
+ slideChangeTransitionEnd() {
10058
+ /** Note: 此处不能使用 slideChangeTransitionStart 事件
10059
+ * - 因为在它触发时 swiper 各个参数并未准备好,将会导致错误的事件抛出;
10060
+ * - 同时抛出 change 事件会导致 current 监听被打乱 swiper 的生命周期;
10061
+ * - 模式与 slideTo 结合时,会导致动画会被中断、slider 展示不完整或衔接模式错误等问题。
10062
+ */
10063
+ if (circular) {
10064
+ if (this.isBeginning || this.isEnd) {
10065
+ this.slideToLoop(this.realIndex, 0); // 更新下标
10066
+ return;
10067
+ }
10068
+ }
10058
10069
  that.onChange.emit({
10059
10070
  current: this.realIndex,
10060
10071
  source: ''
@@ -12,8 +12,10 @@ const Textarea = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
12
12
  this.onInput = createEvent(this, "input", 7);
13
13
  this.onFocus = createEvent(this, "focus", 7);
14
14
  this.onBlur = createEvent(this, "blur", 7);
15
+ this.onConfirm = createEvent(this, "confirm", 7);
15
16
  this.onChange = createEvent(this, "change", 7);
16
17
  this.onLineChange = createEvent(this, "linechange", 7);
18
+ this.onKeyDown = createEvent(this, "keydown", 7);
17
19
  this.handleInput = (e) => {
18
20
  e.stopPropagation();
19
21
  this.handleLineChange();
@@ -51,6 +53,17 @@ const Textarea = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
51
53
  });
52
54
  }
53
55
  };
56
+ this.handleKeyDown = (e) => {
57
+ e.stopPropagation();
58
+ const { value } = e.target;
59
+ const keyCode = e.keyCode || e.code;
60
+ this.onKeyDown.emit({
61
+ value,
62
+ cursor: value.length,
63
+ keyCode
64
+ });
65
+ keyCode === 13 && this.onConfirm.emit({ value });
66
+ };
54
67
  this.calculateContentHeight = (ta, scanAmount) => {
55
68
  let origHeight = ta.style.height, height = ta.offsetHeight, scrollHeight = ta.scrollHeight, overflow = ta.style.overflow, originMinHeight = ta.style.minHeight || null;
56
69
  /// only bother if the ta is bigger than content
@@ -133,7 +146,7 @@ const Textarea = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
133
146
  if (autoFocus && input)
134
147
  input.focus();
135
148
  }
136
- }, class: `taro-textarea ${autoHeight ? 'auto-height' : ''}`, value: fixControlledValue(value), placeholder: placeholder, name: name, disabled: disabled, maxlength: maxlength, autofocus: autoFocus, onInput: handleInput, onFocus: handleFocus, onBlur: handleBlur, onChange: handleChange }, nativeProps, otherProps)));
149
+ }, class: `taro-textarea ${autoHeight ? 'auto-height' : ''}`, value: fixControlledValue(value), placeholder: placeholder, name: name, disabled: disabled, maxlength: maxlength, autofocus: autoFocus, onInput: handleInput, onFocus: handleFocus, onBlur: handleBlur, onChange: handleChange, onKeyDown: this.handleKeyDown }, nativeProps, otherProps)));
137
150
  }
138
151
  get el() { return this; }
139
152
  static get watchers() { return {
@@ -10043,7 +10043,7 @@ const Swiper = class {
10043
10043
  direction: vertical ? 'vertical' : 'horizontal',
10044
10044
  loop: circular,
10045
10045
  slidesPerView: displayMultipleItems,
10046
- initialSlide: current,
10046
+ initialSlide: circular ? current + 1 : current,
10047
10047
  speed: duration,
10048
10048
  observer: true,
10049
10049
  observeParents: true,
@@ -10052,8 +10052,19 @@ const Swiper = class {
10052
10052
  slideTo() {
10053
10053
  that.current = this.realIndex;
10054
10054
  },
10055
- // slideChange 事件在 swiper.slideTo 改写 current 时不触发,因此用 slideChangeTransitionStart 事件代替
10056
- slideChangeTransitionStart(_swiper) {
10055
+ // Note: slideChange 事件在 swiper.slideTo 改写 current 时不触发,因此用 slideChangeTransitionEnd 事件代替
10056
+ slideChangeTransitionEnd() {
10057
+ /** Note: 此处不能使用 slideChangeTransitionStart 事件
10058
+ * - 因为在它触发时 swiper 各个参数并未准备好,将会导致错误的事件抛出;
10059
+ * - 同时抛出 change 事件会导致 current 监听被打乱 swiper 的生命周期;
10060
+ * - 模式与 slideTo 结合时,会导致动画会被中断、slider 展示不完整或衔接模式错误等问题。
10061
+ */
10062
+ if (circular) {
10063
+ if (this.isBeginning || this.isEnd) {
10064
+ this.slideToLoop(this.realIndex, 0); // 更新下标
10065
+ return;
10066
+ }
10067
+ }
10057
10068
  that.onChange.emit({
10058
10069
  current: this.realIndex,
10059
10070
  source: ''
@@ -11,8 +11,10 @@ const Textarea = class {
11
11
  this.onInput = createEvent(this, "input", 7);
12
12
  this.onFocus = createEvent(this, "focus", 7);
13
13
  this.onBlur = createEvent(this, "blur", 7);
14
+ this.onConfirm = createEvent(this, "confirm", 7);
14
15
  this.onChange = createEvent(this, "change", 7);
15
16
  this.onLineChange = createEvent(this, "linechange", 7);
17
+ this.onKeyDown = createEvent(this, "keydown", 7);
16
18
  this.handleInput = (e) => {
17
19
  e.stopPropagation();
18
20
  this.handleLineChange();
@@ -50,6 +52,17 @@ const Textarea = class {
50
52
  });
51
53
  }
52
54
  };
55
+ this.handleKeyDown = (e) => {
56
+ e.stopPropagation();
57
+ const { value } = e.target;
58
+ const keyCode = e.keyCode || e.code;
59
+ this.onKeyDown.emit({
60
+ value,
61
+ cursor: value.length,
62
+ keyCode
63
+ });
64
+ keyCode === 13 && this.onConfirm.emit({ value });
65
+ };
53
66
  this.calculateContentHeight = (ta, scanAmount) => {
54
67
  let origHeight = ta.style.height, height = ta.offsetHeight, scrollHeight = ta.scrollHeight, overflow = ta.style.overflow, originMinHeight = ta.style.minHeight || null;
55
68
  /// only bother if the ta is bigger than content
@@ -132,7 +145,7 @@ const Textarea = class {
132
145
  if (autoFocus && input)
133
146
  input.focus();
134
147
  }
135
- }, class: `taro-textarea ${autoHeight ? 'auto-height' : ''}`, value: fixControlledValue(value), placeholder: placeholder, name: name, disabled: disabled, maxlength: maxlength, autofocus: autoFocus, onInput: handleInput, onFocus: handleFocus, onBlur: handleBlur, onChange: handleChange }, nativeProps, otherProps)));
148
+ }, class: `taro-textarea ${autoHeight ? 'auto-height' : ''}`, value: fixControlledValue(value), placeholder: placeholder, name: name, disabled: disabled, maxlength: maxlength, autofocus: autoFocus, onInput: handleInput, onFocus: handleFocus, onBlur: handleBlur, onChange: handleChange, onKeyDown: this.handleKeyDown }, nativeProps, otherProps)));
136
149
  }
137
150
  get el() { return getElement(this); }
138
151
  static get watchers() { return {