@tarojs/components 3.6.0-canary.6 → 3.6.0-canary.8

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 (69) hide show
  1. package/dist/react/component-lib/index.js +20 -10
  2. package/dist/react/component-lib/input.js +3 -4
  3. package/dist/react/component-lib/reactify-wc.js +9 -46
  4. package/dist/react/components.js +0 -2
  5. package/dist/react/react-component-lib/createComponent.js +10 -30
  6. package/dist/react/react-component-lib/createOverlayComponent.js +8 -37
  7. package/dist/react/react-component-lib/utils/attachProps.js +9 -18
  8. package/dist/react/react-component-lib/utils/index.js +6 -9
  9. package/dist/vue2/component-lib/components.js +22 -11
  10. package/dist/vue2/component-lib/createFormsComponent.js +0 -5
  11. package/dist/vue2/component-lib/index.js +6 -8
  12. package/dist/vue2/component-lib/mixins/refs.js +0 -5
  13. package/dist/vue2/components.js +0 -3
  14. package/dist/vue2/index.js +3 -7
  15. package/dist/vue2/vue-component-lib/utils.js +0 -1
  16. package/dist/vue3/component-lib/createComponent.js +1 -1
  17. package/dist/vue3/component-lib/createFormsComponent.js +3 -8
  18. package/dist/vue3/component-lib/forwardRef.js +0 -2
  19. package/dist/vue3/component-lib/icon.js +2 -2
  20. package/dist/vue3/component-lib/image.js +2 -2
  21. package/dist/vue3/component-lib/index.js +22 -11
  22. package/dist/vue3/component-lib/scroll-view.js +2 -2
  23. package/dist/vue3/component-lib/text.js +2 -2
  24. package/dist/vue3/components.js +0 -2
  25. package/dist/vue3/index.js +2 -4
  26. package/dist/vue3/vue-component-lib/utils.js +7 -29
  27. package/package.json +4 -3
  28. package/types/Button.d.ts +1 -1
  29. package/types/Camera.d.ts +1 -1
  30. package/types/Checkbox.d.ts +1 -1
  31. package/types/CheckboxGroup.d.ts +1 -1
  32. package/types/CoverImage.d.ts +1 -1
  33. package/types/CustomWrapper.d.ts +1 -0
  34. package/types/Form.d.ts +1 -1
  35. package/types/Icon.d.ts +1 -1
  36. package/types/Image.d.ts +1 -1
  37. package/types/Input.d.ts +15 -1
  38. package/types/Label.d.ts +1 -1
  39. package/types/NativeSlot.d.ts +1 -0
  40. package/types/NavigationBar.d.ts +2 -1
  41. package/types/Navigator.d.ts +1 -1
  42. package/types/Picker.d.ts +1 -1
  43. package/types/PickerView.d.ts +1 -1
  44. package/types/PickerViewColumn.d.ts +1 -1
  45. package/types/Progress.d.ts +1 -1
  46. package/types/Radio.d.ts +1 -1
  47. package/types/RadioGroup.d.ts +1 -1
  48. package/types/RichText.d.ts +1 -1
  49. package/types/ScrollView.d.ts +1 -1
  50. package/types/ShareElement.d.ts +3 -3
  51. package/types/Slider.d.ts +1 -1
  52. package/types/Slot.d.ts +2 -1
  53. package/types/Swiper.d.ts +1 -1
  54. package/types/SwiperItem.d.ts +1 -1
  55. package/types/Switch.d.ts +1 -1
  56. package/types/Textarea.d.ts +1 -1
  57. package/types/Video.d.ts +1 -1
  58. package/types/View.d.ts +1 -1
  59. package/types/WebView.d.ts +1 -1
  60. package/virtual-list/index.d.ts +3 -120
  61. package/virtual-list/index.js +3 -7
  62. package/virtual-list/domHelpers.js +0 -40
  63. package/virtual-list/memoize.js +0 -38
  64. package/virtual-list/react/FixedSizeList.js +0 -193
  65. package/virtual-list/react/createListComponent.js +0 -654
  66. package/virtual-list/react/index.d.ts +0 -123
  67. package/virtual-list/react/index.js +0 -67
  68. package/virtual-list/timer.js +0 -24
  69. package/virtual-list/vue/index.js +0 -589
@@ -1,123 +0,0 @@
1
- import { Component, ComponentType, CSSProperties, ReactNode } from 'react'
2
- import { StandardProps, BaseEventOrigFunction } from '../../types/common'
3
- import { ScrollViewProps } from '../../types/ScrollView'
4
-
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
- renderTop?: ReactNode
26
- /** 底部区域 */
27
- renderBottom?: ReactNode
28
- /** 滚动方向。vertical 为垂直滚动,horizontal 为平行滚动。默认为 vertical。 */
29
- layout?: 'vertical' | 'horizontal'
30
- /** 列表滚动时调用函数 */
31
- onScroll?: (event: VirtualListEvent<VirtualListProps.onScrollDetail>) => void
32
- /** 调用平台原生的滚动监听函数。 */
33
- onScrollNative?: BaseEventOrigFunction<ScrollViewProps.onScrollDetail>
34
- /** 在可视区域之外渲染的列表单项数量,值设置得越高,快速滚动时出现白屏的概率就越小,相应地,每次滚动的性能会变得越差。 */
35
- overscanCount?: number
36
- /** 是否注入 isScrolling 属性到 children 组件。这个参数一般用于实现滚动骨架屏(或其它 placeholder) 时比较有用。 */
37
- useIsScrolling?: boolean
38
- children?: ComponentType<{
39
- /** 组件 ID */
40
- id: string
41
- /** 单项的样式,样式必须传入组件的 style 中 */
42
- style?: CSSProperties
43
- /** 组件渲染的数据 */
44
- data: any
45
- /** 组件渲染数据的索引 */
46
- index: number
47
- /** 组件是否正在滚动,当 useIsScrolling 值为 true 时返回布尔值,否则返回 undefined */
48
- isScrolling?: boolean
49
- }>
50
- }
51
-
52
- declare namespace VirtualListProps {
53
- // eslint-disable-next-line @typescript-eslint/class-name-casing
54
- interface onScrollDetail {
55
- clientWidth: number
56
- clientHeight: number
57
- }
58
- }
59
-
60
- interface VirtualListEvent<T> {
61
- /** 滚动方向,可能值为 forward 往前, backward 往后。 */
62
- scrollDirection: 'forward' | 'backward'
63
- /** 滚动距离 */
64
- scrollOffset: number
65
- /** 当滚动是由 scrollTo() 或 scrollToItem() 调用时返回 true,否则返回 false */
66
- scrollUpdateWasRequested: boolean
67
- /** 当前只有 React 支持 */
68
- detail?: {
69
- scrollLeft: number
70
- scrollTop: number
71
- scrollHeight: number
72
- scrollWidth: number
73
- clientWidth: number
74
- clientHeight: number
75
- }
76
- }
77
-
78
- /**
79
- * @classification viewContainer
80
- * @supported weapp, swan, alipay, tt, qq, jd, h5
81
- * @example
82
- * ```tsx
83
- * import VirtualList from `@tarojs/components/virtual-list`
84
- *
85
- * function buildData (offset = 0) {
86
- * return Array(100).fill(0).map((_, i) => i + offset);
87
- * }
88
- *
89
- * const Row = React.memo(({ id, index, style, data }) => {
90
- * return (
91
- * <View id={id} className={index % 2 ? 'ListItemOdd' : 'ListItemEven'} style={style}>
92
- * Row {index}
93
- * </View>
94
- * );
95
- * })
96
- *
97
- * export default class Index extends Component {
98
- * state = {
99
- * data: buildData(0),
100
- * }
101
- *
102
- * render() {
103
- * const { data } = this.state
104
- * const dataLen = data.length
105
- * return (
106
- * <VirtualList
107
- * height={500} // 列表的高度
108
- * width='100%' // 列表的宽度
109
- * itemData={data} // 渲染列表的数据
110
- * itemCount={dataLen} // 渲染列表的长度
111
- * itemSize={100} // 列表单项的高度
112
- * >
113
- * {Row} // 列表单项组件,这里只能传入一个组件
114
- * </VirtualList>
115
- * );
116
- * }
117
- * }
118
- * ```
119
- * @see https://taro-docs.jd.com/taro/docs/virtual-list/
120
- */
121
- declare class VirtualList extends Component<VirtualListProps> {}
122
-
123
- export = VirtualList
@@ -1,67 +0,0 @@
1
- import { ScrollView, View } from '@tarojs/components'
2
- import React from 'react'
3
-
4
- import FixedSizeList from './FixedSizeList'
5
-
6
- function convertPxToInt (style) {
7
- if (typeof style === 'string') {
8
- const str = style.toLowerCase()
9
- if (/px$/.test(str)) {
10
- return Number(str.replace(/px$/, ''))
11
- }
12
- }
13
- return style
14
- }
15
-
16
- const OuterScrollView = React.forwardRef(
17
- (props, ref) => {
18
- const { style, onScroll, onScrollNative, layout, ...rest } = props
19
- const handleScroll = event => {
20
- onScroll({
21
- ...event,
22
- currentTarget: {
23
- ...event.detail,
24
- clientWidth: convertPxToInt(style.width),
25
- clientHeight: convertPxToInt(style.height)
26
- }
27
- })
28
-
29
- if (typeof onScrollNative === 'function') {
30
- onScrollNative(event)
31
- }
32
- }
33
-
34
- return React.createElement(ScrollView, {
35
- ref,
36
- style,
37
- scrollY: layout === 'vertical',
38
- scrollX: layout === 'horizontal',
39
- onScroll: handleScroll,
40
- ...rest
41
- })
42
- }
43
- )
44
-
45
- const VirtualList = React.forwardRef((props, ref) => {
46
- const {
47
- direction = 'ltr',
48
- innerElementType = View,
49
- itemElementType = View,
50
- initialScrollOffset = 0,
51
- overscanCount = 1,
52
- ...rest
53
- } = props
54
-
55
- return React.createElement(FixedSizeList, {
56
- ref,
57
- ...rest,
58
- itemElementType,
59
- innerElementType,
60
- outerElementType: OuterScrollView,
61
- direction,
62
- initialScrollOffset,
63
- overscanCount
64
- })
65
- })
66
-
67
- export default VirtualList
@@ -1,24 +0,0 @@
1
- import { cancelAnimationFrame, now, requestAnimationFrame } from '@tarojs/runtime'
2
-
3
- export function cancelTimeout (timeoutID) {
4
- cancelAnimationFrame(timeoutID.id)
5
- }
6
-
7
- export function requestTimeout (callback, delay) {
8
- const start = now()
9
-
10
- const timeoutID = {
11
- id: requestAnimationFrame(tick)
12
- }
13
-
14
- function tick () {
15
- if (now() - start >= delay) {
16
- // eslint-disable-next-line no-useless-call
17
- callback.call(null)
18
- } else {
19
- timeoutID.id = requestAnimationFrame(tick)
20
- }
21
- }
22
-
23
- return timeoutID
24
- }