@tarojs/components 3.6.0-canary.5 → 3.6.0-canary.7

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 (74) hide show
  1. package/dist/react/component-lib/input.js +1 -1
  2. package/dist/react/component-lib/reactify-wc.js +10 -10
  3. package/dist/react/helper.js +1 -1
  4. package/dist/react/react-component-lib/createComponent.js +9 -9
  5. package/dist/react/react-component-lib/createOverlayComponent.js +10 -10
  6. package/dist/react/react-component-lib/utils/attachProps.js +1 -1
  7. package/dist/react/react-component-lib/utils/index.js +1 -1
  8. package/dist/vue2/component-lib/createComponent.js +1 -1
  9. package/dist/vue2/component-lib/createFormsComponent.js +2 -2
  10. package/dist/vue2/component-lib/index.js +1 -1
  11. package/dist/vue2/component-lib/mixins/listeners.js +1 -1
  12. package/dist/vue2/component-lib/mixins/refs.js +1 -1
  13. package/dist/vue2/component-lib/picker.js +1 -1
  14. package/dist/vue2/component-lib/scroll-view.js +1 -1
  15. package/dist/vue2/components.js +1 -1
  16. package/dist/vue2/index.js +2 -2
  17. package/dist/vue2/vue-component-lib/utils.js +2 -2
  18. package/dist/vue3/component-lib/createComponent.js +1 -1
  19. package/dist/vue3/component-lib/createFormsComponent.js +3 -3
  20. package/dist/vue3/index.js +1 -1
  21. package/dist/vue3/vue-component-lib/utils.js +3 -3
  22. package/package.json +5 -4
  23. package/types/Ad.d.ts +1 -1
  24. package/types/Audio.d.ts +1 -1
  25. package/types/Button.d.ts +1 -1
  26. package/types/Camera.d.ts +1 -1
  27. package/types/Canvas.d.ts +1 -1
  28. package/types/Checkbox.d.ts +1 -1
  29. package/types/CheckboxGroup.d.ts +1 -1
  30. package/types/CoverImage.d.ts +1 -1
  31. package/types/CoverView.d.ts +102 -4
  32. package/types/CustomWrapper.d.ts +1 -1
  33. package/types/Form.d.ts +1 -1
  34. package/types/Icon.d.ts +1 -1
  35. package/types/Image.d.ts +1 -1
  36. package/types/Input.d.ts +71 -8
  37. package/types/LivePlayer.d.ts +1 -1
  38. package/types/LivePusher.d.ts +1 -1
  39. package/types/Map.d.ts +1 -1
  40. package/types/MatchMedia.d.ts +1 -1
  41. package/types/MovableArea.d.ts +2 -2
  42. package/types/MovableView.d.ts +17 -17
  43. package/types/Navigator.d.ts +1 -1
  44. package/types/OpenData.d.ts +1 -1
  45. package/types/PageContainer.d.ts +28 -18
  46. package/types/PageMeta.d.ts +1 -1
  47. package/types/Picker.d.ts +1 -1
  48. package/types/PickerView.d.ts +1 -1
  49. package/types/Progress.d.ts +1 -1
  50. package/types/Radio.d.ts +1 -1
  51. package/types/RadioGroup.d.ts +1 -1
  52. package/types/RootPortal.d.ts +11 -2
  53. package/types/ScrollView.d.ts +1 -1
  54. package/types/ShareElement.d.ts +20 -10
  55. package/types/Slider.d.ts +1 -1
  56. package/types/Swiper.d.ts +1 -1
  57. package/types/SwiperItem.d.ts +3 -2
  58. package/types/Switch.d.ts +1 -1
  59. package/types/Text.d.ts +1 -1
  60. package/types/Textarea.d.ts +7 -1
  61. package/types/Video.d.ts +7 -1
  62. package/types/View.d.ts +1 -1
  63. package/types/WebView.d.ts +1 -1
  64. package/types/index.vue3.d.ts +2 -1
  65. package/virtual-list/index.d.ts +3 -120
  66. package/virtual-list/index.js +3 -7
  67. package/virtual-list/domHelpers.js +0 -40
  68. package/virtual-list/memoize.js +0 -38
  69. package/virtual-list/react/FixedSizeList.js +0 -193
  70. package/virtual-list/react/createListComponent.js +0 -654
  71. package/virtual-list/react/index.d.ts +0 -123
  72. package/virtual-list/react/index.js +0 -67
  73. package/virtual-list/timer.js +0 -24
  74. package/virtual-list/vue/index.js +0 -589
package/types/Text.d.ts CHANGED
@@ -45,7 +45,7 @@ declare namespace TextProps {
45
45
 
46
46
  /** 文本
47
47
  * @classification base
48
- * @supported weapp, swan, alipay, tt, h5, rn
48
+ * @supported weapp, alipay, swan, tt, qq, jd, h5, rn
49
49
  * @example_react
50
50
  * ```tsx
51
51
  * export default class PageView extends Component {
@@ -136,6 +136,12 @@ interface TextareaProps extends StandardProps, FormItemProps {
136
136
  */
137
137
  controlled?: string
138
138
 
139
+ /** 使用原生键盘
140
+ * @default false
141
+ * @supported alipay
142
+ */
143
+ enableNative?: boolean
144
+
139
145
  /** 无障碍访问,(属性)元素的额外描述
140
146
  * @supported qq
141
147
  */
@@ -218,7 +224,7 @@ declare namespace TextareaProps {
218
224
 
219
225
  /** 多行输入框。该组件是原生组件,使用时请注意相关限制
220
226
  * @classification forms
221
- * @supported weapp, h5, rn
227
+ * @supported weapp, alipay, swan, tt, qq, h5, rn
222
228
  * @example_react
223
229
  * ```tsx
224
230
  * export default class PageView extends Component {
package/types/Video.d.ts CHANGED
@@ -282,6 +282,12 @@ interface VideoProps extends StandardProps {
282
282
  */
283
283
  mobilenetHintType?: string
284
284
 
285
+ /** 使用原生
286
+ * @default true
287
+ * @supported alipay
288
+ */
289
+ enableNative?: boolean
290
+
285
291
  /** 浮窗设置。暂时不支持全局浮窗。
286
292
  * 可选值:
287
293
  *
@@ -637,7 +643,7 @@ declare namespace VideoProps {
637
643
 
638
644
  /** 视频。相关api:Taro.createVideoContext
639
645
  * @classification media
640
- * @supported weapp, swan, alipay, tt, h5, rn
646
+ * @supported weapp, alipay, swan, tt, qq, jd, h5, rn
641
647
  * @example_react
642
648
  * ```tsx
643
649
  * export default class PageView extends Component {
package/types/View.d.ts CHANGED
@@ -142,7 +142,7 @@ interface ViewProps extends StandardProps {
142
142
 
143
143
  /** 视图容器
144
144
  * @classification viewContainer
145
- * @supported weapp, swan, alipay, tt, h5, rn
145
+ * @supported weapp, alipay, swan, tt, qq, jd, h5, rn
146
146
  * @example_react
147
147
  * ```tsx
148
148
  * export default class PageView extends Component {
@@ -49,7 +49,7 @@ declare namespace WebViewProps {
49
49
 
50
50
  /** web-view 组件是一个可以用来承载网页的容器,会自动铺满整个小程序页面。个人类型与海外类型的小程序暂不支持使用。
51
51
  * @classification open
52
- * @supported weapp, h5, rn, tt
52
+ * @supported weapp, alipay, swan, tt, qq, jd, h5, rn
53
53
  * @example_react
54
54
  * ```tsx
55
55
  * class App extends Component {
@@ -282,7 +282,8 @@ declare global {
282
282
 
283
283
  'custom-wrapper': ElementAttrs<TransformReact2VueType<CustomWrapperProps>>
284
284
  'taro-custom-wrapper-core': ElementAttrs<TransformReact2VueType<CustomWrapperProps>>
285
- 'slot': ElementAttrs<TransformReact2VueType<SlotProps>>
285
+ /** 为了不与vue3模板默认的slot冲突,增加 Record<string, any> */
286
+ 'slot': ElementAttrs<TransformReact2VueType<SlotProps>> & Record<string, any>
286
287
  'taro-slot-core': ElementAttrs<TransformReact2VueType<SlotProps>>
287
288
  }
288
289
  }
@@ -1,121 +1,4 @@
1
- import { Component, ComponentType, CSSProperties, ReactNode } from 'react'
2
- import { StandardProps, BaseEventOrigFunction } from '../types/common'
3
- import { ScrollViewProps } from '../types/ScrollView'
1
+ import VirtualList from '@tarojs/components-advanced/dist/components/virtual-list/index'
4
2
 
5
- interface VirtualListProps extends StandardProps {
6
- /** 列表的高度。 */
7
- height: string | number
8
- /** 列表的宽度。 */
9
- width: string | number
10
- /** 列表的长度 */
11
- itemCount: number
12
- /** 渲染数据 */
13
- itemData: any[]
14
- /** 列表单项的大小,垂直滚动时为高度,水平滚动时为宽度。 */
15
- itemSize: number
16
- /** 解开高度列表单项大小限制,默认值使用: itemSize (请注意,初始高度与实际高度差异过大会导致隐患)。 */
17
- unlimitedSize?: boolean
18
- /** 布局方式,默认采用 "absolute" */
19
- position?: 'absolute' | 'relative'
20
- /** 初始滚动偏移值,水平滚动影响 scrollLeft,垂直滚动影响 scrollTop。 */
21
- initialScrollOffset?: number
22
- /** 列表内部容器组件类型,默认值为 View。 */
23
- innerElementType?: ComponentType
24
- /** 底部区域 */
25
- renderBottom?: ReactNode
26
- /** 滚动方向。vertical 为垂直滚动,horizontal 为平行滚动。默认为 vertical。 */
27
- layout?: 'vertical' | 'horizontal'
28
- /** 列表滚动时调用函数 */
29
- onScroll?: (event: VirtualListEvent<VirtualListProps.onScrollDetail>) => void
30
- /** 调用平台原生的滚动监听函数。 */
31
- onScrollNative?: BaseEventOrigFunction<ScrollViewProps.onScrollDetail>
32
- /** 在可视区域之外渲染的列表单项数量,值设置得越高,快速滚动时出现白屏的概率就越小,相应地,每次滚动的性能会变得越差。 */
33
- overscanCount?: number
34
- /** 是否注入 isScrolling 属性到 children 组件。这个参数一般用于实现滚动骨架屏(或其它 placeholder) 时比较有用。 */
35
- useIsScrolling?: boolean
36
- children?: ComponentType<{
37
- /** 组件 ID */
38
- id: string
39
- /** 单项的样式,样式必须传入组件的 style 中 */
40
- style?: CSSProperties
41
- /** 组件渲染的数据 */
42
- data: any
43
- /** 组件渲染数据的索引 */
44
- index: number
45
- /** 组件是否正在滚动,当 useIsScrolling 值为 true 时返回布尔值,否则返回 undefined */
46
- isScrolling?: boolean
47
- }>
48
- }
49
-
50
- declare namespace VirtualListProps {
51
- // eslint-disable-next-line @typescript-eslint/class-name-casing
52
- interface onScrollDetail {
53
- clientWidth: number
54
- clientHeight: number
55
- }
56
- }
57
-
58
- interface VirtualListEvent<T> {
59
- /** 滚动方向,可能值为 forward 往前, backward 往后。 */
60
- scrollDirection: 'forward' | 'backward'
61
- /** 滚动距离 */
62
- scrollOffset: number
63
- /** 当滚动是由 scrollTo() 或 scrollToItem() 调用时返回 true,否则返回 false */
64
- scrollUpdateWasRequested: boolean
65
- /** 当前只有 React 支持 */
66
- detail?: {
67
- scrollLeft: number
68
- scrollTop: number
69
- scrollHeight: number
70
- scrollWidth: number
71
- clientWidth: number
72
- clientHeight: number
73
- }
74
- }
75
-
76
- /**
77
- * @classification viewContainer
78
- * @supported weapp, swan, alipay, tt, qq, jd, h5
79
- * @example
80
- * ```tsx
81
- * import VirtualList from `@tarojs/components/virtual-list`
82
- *
83
- * function buildData (offset = 0) {
84
- * return Array(100).fill(0).map((_, i) => i + offset);
85
- * }
86
- *
87
- * const Row = React.memo(({ id, index, style, data }) => {
88
- * return (
89
- * <View id={id} className={index % 2 ? 'ListItemOdd' : 'ListItemEven'} style={style}>
90
- * Row {index}
91
- * </View>
92
- * );
93
- * })
94
- *
95
- * export default class Index extends Component {
96
- * state = {
97
- * data: buildData(0),
98
- * }
99
- *
100
- * render() {
101
- * const { data } = this.state
102
- * const dataLen = data.length
103
- * return (
104
- * <VirtualList
105
- * height={500} // 列表的高度
106
- * width='100%' // 列表的宽度
107
- * itemData={data} // 渲染列表的数据
108
- * itemCount={dataLen} // 渲染列表的长度
109
- * itemSize={100} // 列表单项的高度
110
- * >
111
- * {Row} // 列表单项组件,这里只能传入一个组件
112
- * </VirtualList>
113
- * );
114
- * }
115
- * }
116
- * ```
117
- * @see https://taro-docs.jd.com/taro/docs/virtual-list/
118
- */
119
- declare class VirtualList extends Component<VirtualListProps> {}
120
-
121
- export = VirtualList
3
+ export * from '@tarojs/components-advanced/dist/components/virtual-list/index'
4
+ export default VirtualList
@@ -1,7 +1,3 @@
1
- if (process.env.FRAMEWORK === 'vue') {
2
- module.exports = require('./vue').default
3
- module.exports.default = module.exports
4
- } else {
5
- module.exports = require('./react').default
6
- module.exports.default = module.exports
7
- }
1
+ module.exports = require('@tarojs/components-advanced/dist/components/virtual-list/index.js').default
2
+
3
+ module.exports.default = module.exports
@@ -1,40 +0,0 @@
1
- let cachedRTLResult = null // TRICKY According to the spec, scrollLeft should be negative for RTL aligned elements.
2
- // Chrome does not seem to adhere; its scrollLeft values are positive (measured relative to the left).
3
- // Safari's elastic bounce makes detecting this even more complicated wrt potential false positives.
4
- // The safest way to check this is to intentionally set a negative offset,
5
- // and then verify that the subsequent "scroll" event matches the negative offset.
6
- // If it does not match, then we can assume a non-standard RTL scroll implementation.
7
-
8
- export function getRTLOffsetType (recalculate = false) {
9
- if (cachedRTLResult === null || recalculate) {
10
- const outerDiv = document.createElement('div')
11
- const outerStyle = outerDiv.style
12
- outerStyle.width = '50px'
13
- outerStyle.height = '50px'
14
- outerStyle.overflow = 'scroll'
15
- outerStyle.direction = 'rtl'
16
- const innerDiv = document.createElement('div')
17
- const innerStyle = innerDiv.style
18
- innerStyle.width = '100px'
19
- innerStyle.height = '100px'
20
- outerDiv.appendChild(innerDiv)
21
- document.body.appendChild(outerDiv)
22
-
23
- if (outerDiv.scrollLeft > 0) {
24
- cachedRTLResult = 'positive-descending'
25
- } else {
26
- outerDiv.scrollLeft = 1
27
-
28
- if (outerDiv.scrollLeft === 0) {
29
- cachedRTLResult = 'negative'
30
- } else {
31
- cachedRTLResult = 'positive-ascending'
32
- }
33
- }
34
-
35
- document.body.removeChild(outerDiv)
36
- return cachedRTLResult
37
- }
38
-
39
- return cachedRTLResult
40
- }
@@ -1,38 +0,0 @@
1
- // https://github.com/alexreardon/memoize-one#readme
2
-
3
- function areInputsEqual (newInputs, lastInputs) {
4
- if (newInputs.length !== lastInputs.length) {
5
- return false
6
- }
7
- for (let i = 0; i < newInputs.length; i++) {
8
- if (newInputs[i] !== lastInputs[i]) {
9
- return false
10
- }
11
- }
12
- return true
13
- }
14
-
15
- export function memoizeOne (resultFn, isEqual) {
16
- // eslint-disable-next-line no-void
17
- if (isEqual === void 0) { isEqual = areInputsEqual }
18
- let lastThis
19
- let lastArgs = []
20
- let lastResult
21
- let calledOnce = false
22
- function memoized () {
23
- const newArgs = []
24
- for (let _i = 0; _i < arguments.length; _i++) {
25
- newArgs[_i] = arguments[_i]
26
- }
27
- if (calledOnce && lastThis === this && isEqual(newArgs, lastArgs)) {
28
- return lastResult
29
- }
30
- lastResult = resultFn.apply(this, newArgs)
31
- calledOnce = true
32
- // eslint-disable-next-line @typescript-eslint/no-this-alias
33
- lastThis = this
34
- lastArgs = newArgs
35
- return lastResult
36
- }
37
- return memoized
38
- }
@@ -1,193 +0,0 @@
1
- import createListComponent, { isHorizontalFunc } from './createListComponent'
2
-
3
- let devWarningsDirection = null
4
- let devWarningsTagName = null
5
-
6
- if (process.env.NODE_ENV !== 'production') {
7
- if (typeof window !== 'undefined' && typeof window.WeakSet !== 'undefined') {
8
- devWarningsDirection =
9
- /* #__PURE__ */
10
- new WeakSet()
11
- devWarningsTagName =
12
- /* #__PURE__ */
13
- new WeakSet()
14
- }
15
- }
16
-
17
- const validateSharedProps = ({
18
- children,
19
- direction,
20
- height,
21
- layout,
22
- itemTagName,
23
- innerTagName,
24
- outerTagName,
25
- width
26
- }, {
27
- instance
28
- }) => {
29
- if (process.env.NODE_ENV !== 'production') {
30
- if (innerTagName != null || outerTagName != null || itemTagName != null) {
31
- if (devWarningsTagName && !devWarningsTagName.has(instance)) {
32
- devWarningsTagName.add(instance)
33
- console.warn('The itemTagName、innerTagName and outerTagName props have been deprecated. ' + 'Please use the itemElementType、innerElementType and outerElementType props instead.')
34
- }
35
- } // TODO Deprecate direction "horizontal"
36
-
37
- const isHorizontal = direction === 'horizontal' || layout === 'horizontal'
38
-
39
- switch (direction) {
40
- case 'horizontal':
41
- case 'vertical':
42
- if (devWarningsDirection && !devWarningsDirection.has(instance)) {
43
- devWarningsDirection.add(instance)
44
- console.warn('The direction prop should be either "ltr" (default) or "rtl". ' + 'Please use the layout prop to specify "vertical" (default) or "horizontal" orientation.')
45
- }
46
-
47
- break
48
-
49
- case 'ltr':
50
- case 'rtl':
51
- // Valid values
52
- break
53
-
54
- default:
55
- throw Error('An invalid "direction" prop has been specified. ' + 'Value should be either "ltr" or "rtl". ' + `"${direction}" was specified.`)
56
- }
57
-
58
- switch (layout) {
59
- case 'horizontal':
60
- case 'vertical':
61
- // Valid values
62
- break
63
-
64
- default:
65
- throw Error('An invalid "layout" prop has been specified. ' + 'Value should be either "horizontal" or "vertical". ' + `"${layout}" was specified.`)
66
- }
67
-
68
- if (children == null) {
69
- throw Error('An invalid "children" prop has been specified. ' + 'Value should be a React component. ' + `"${children === null ? 'null' : typeof children}" was specified.`)
70
- }
71
-
72
- if (isHorizontal && typeof width !== 'number') {
73
- throw Error('An invalid "width" prop has been specified. ' + 'Horizontal lists must specify a number for width. ' + `"${width === null ? 'null' : typeof width}" was specified.`)
74
- } else if (!isHorizontal && typeof height !== 'number') {
75
- throw Error('An invalid "height" prop has been specified. ' + 'Vertical lists must specify a number for height. ' + `"${height === null ? 'null' : typeof height}" was specified.`)
76
- }
77
- }
78
- }
79
-
80
- const FixedSizeList =
81
- /* #__PURE__ */
82
- createListComponent({
83
- getItemOffset (props, index, ref) {
84
- if (!props.unlimitedSize) {
85
- return index * props.itemSize
86
- }
87
- return ref._getCountSize(props, index)
88
- },
89
- getItemSize (props, index, ref) {
90
- if (!props.unlimitedSize) {
91
- return props.itemSize
92
- }
93
-
94
- return ref._getSizeUpload(index, isHorizontalFunc(props))
95
- },
96
- getEstimatedTotalSize (props, ref) {
97
- return ref._getCountSize(props, props.itemCount)
98
- },
99
- getOffsetForIndexAndAlignment: (props, id, index, align, scrollOffset, ref) => {
100
- const { height, width } = props
101
- const { sizeList } = ref.state
102
- // TODO Deprecate direction "horizontal"
103
- const size = isHorizontalFunc(props) ? width : height
104
- const itemSize = ref._getSize(sizeList[index])
105
- const lastItemOffset = Math.max(0, ref._getCountSize(props, props.itemCount) - size)
106
- const maxOffset = Math.min(lastItemOffset, ref._getCountSize(props, index))
107
- const minOffset = Math.max(0, ref._getCountSize(props, index) - size + itemSize)
108
-
109
- if (align === 'smart') {
110
- if (scrollOffset >= minOffset - size && scrollOffset <= maxOffset + size) {
111
- align = 'auto'
112
- } else {
113
- align = 'center'
114
- }
115
- }
116
-
117
- switch (align) {
118
- case 'start':
119
- return maxOffset
120
-
121
- case 'end':
122
- return minOffset
123
-
124
- case 'center':
125
- {
126
- // "Centered" offset is usually the average of the min and max.
127
- // But near the edges of the list, this doesn't hold true.
128
- const middleOffset = Math.round(minOffset + (maxOffset - minOffset) / 2)
129
-
130
- if (middleOffset < Math.ceil(size / 2)) {
131
- return 0 // near the beginning
132
- } else if (middleOffset > lastItemOffset + Math.floor(size / 2)) {
133
- return lastItemOffset // near the end
134
- } else {
135
- return middleOffset
136
- }
137
- }
138
-
139
- case 'auto':
140
- default:
141
- if (scrollOffset >= minOffset && scrollOffset <= maxOffset) {
142
- return scrollOffset
143
- } else if (scrollOffset < minOffset) {
144
- return minOffset
145
- } else {
146
- return maxOffset
147
- }
148
- }
149
- },
150
- getStartIndexForOffset (props, scrollOffset, ref) {
151
- return Math.max(0, ref._getSizeCount(props, scrollOffset) - 1)
152
- },
153
- getStopIndexForStartIndex (props, scrollOffset, startIndex, ref) {
154
- const {
155
- height,
156
- itemCount,
157
- itemSize,
158
- width
159
- } = props
160
- const size = isHorizontalFunc(props) ? width : height
161
- const offset = ref._getCountSize(props, startIndex)
162
- if (!props.unlimitedSize) {
163
- // TODO Deprecate direction "horizontal"
164
- const numVisibleItems = Math.ceil((size + scrollOffset - offset) / itemSize)
165
- /** -1 is because stop index is inclusive */
166
- return Math.max(startIndex, Math.min(itemCount - 1, startIndex + numVisibleItems - 1))
167
- }
168
- return Math.max(startIndex, Math.min(itemCount - 1, ref._getSizeCount(props, size + scrollOffset)))
169
- },
170
-
171
- initInstanceProps () { // Noop
172
- },
173
-
174
- shouldResetStyleCacheOnItemSizeChange: true,
175
- validateProps: (nextProps, prevState) => {
176
- const { itemCount, itemSize } = nextProps
177
- const { sizeList } = prevState
178
- if (itemCount > sizeList.length) {
179
- const arr = new Array(itemCount - sizeList.length).fill(-1)
180
- sizeList.push(...arr)
181
- } else if (itemCount < sizeList.length) {
182
- sizeList.length = itemCount
183
- }
184
- if (process.env.NODE_ENV !== 'production') {
185
- if (typeof itemSize !== 'number') {
186
- throw Error('An invalid "itemSize" prop has been specified. ' + 'Value should be a number. ' + `"${itemSize === null ? 'null' : typeof itemSize}" was specified.`)
187
- }
188
- }
189
- validateSharedProps(nextProps, prevState)
190
- }
191
- })
192
-
193
- export default FixedSizeList