@tarojs/plugin-platform-harmony-ets 4.0.0-canary.8 → 4.0.0
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/apis/base/system.ts +73 -20
- package/dist/apis/canvas/index.ts +10 -1
- package/dist/apis/device/clipboard.ts +23 -8
- package/dist/apis/framework/index.ts +1 -5
- package/dist/apis/index.ts +27 -17
- package/dist/apis/media/image/index.ts +169 -17
- package/dist/apis/network/request.ts +5 -5
- package/dist/apis/route/index.ts +15 -0
- package/dist/apis/storage/index.ts +146 -78
- package/dist/apis/ui/animation/animation.ts +71 -29
- package/dist/apis/ui/background.ts +2 -1
- package/dist/apis/ui/interaction/index.ts +58 -59
- package/dist/apis/ui/navigation-bar/index.ts +1 -1
- package/dist/apis/ui/pull-down-refresh.ts +9 -3
- package/dist/apis/ui/scroll/index.ts +5 -5
- package/dist/apis/ui/tab-bar.ts +3 -3
- package/dist/apis/utils/index.ts +21 -2
- package/dist/apis/utils/permissions.ts +6 -0
- package/dist/apis/wxml/IntersectionObserver.ts +18 -10
- package/dist/apis/wxml/index.ts +2 -0
- package/dist/apis/wxml/selectorQuery.ts +26 -13
- package/dist/components-harmony-ets/button.ets +63 -77
- package/dist/components-harmony-ets/canvas.ets +51 -0
- package/dist/components-harmony-ets/checkbox.ets +75 -258
- package/dist/components-harmony-ets/form.ets +51 -158
- package/dist/components-harmony-ets/icon.ets +33 -83
- package/dist/components-harmony-ets/image.ets +35 -79
- package/dist/components-harmony-ets/index.ets +92 -0
- package/dist/components-harmony-ets/innerHtml.ets +11 -6
- package/dist/components-harmony-ets/input.ets +64 -101
- package/dist/components-harmony-ets/label.ets +72 -174
- package/dist/components-harmony-ets/listView.ets +31 -0
- package/dist/components-harmony-ets/movableArea.ets +126 -0
- package/dist/components-harmony-ets/movableView.ets +93 -0
- package/dist/components-harmony-ets/navigationBar.ets +65 -0
- package/dist/components-harmony-ets/pageMeta.ets +94 -0
- package/dist/components-harmony-ets/picker.ets +46 -163
- package/dist/components-harmony-ets/progress.ets +52 -0
- package/dist/components-harmony-ets/pseudo.ets +80 -0
- package/dist/components-harmony-ets/radio.ets +80 -264
- package/dist/components-harmony-ets/richText.ets +20 -102
- package/dist/components-harmony-ets/scrollList.ets +108 -0
- package/dist/components-harmony-ets/scrollView.ets +71 -160
- package/dist/components-harmony-ets/slider.ets +22 -82
- package/dist/components-harmony-ets/stickySection.ets +42 -0
- package/dist/components-harmony-ets/style.ets +410 -0
- package/dist/components-harmony-ets/swiper.ets +64 -87
- package/dist/components-harmony-ets/switch.ets +39 -99
- package/dist/components-harmony-ets/{index.ts → tag.ts} +6 -0
- package/dist/components-harmony-ets/text.ets +111 -113
- package/dist/components-harmony-ets/textArea.ets +51 -95
- package/dist/components-harmony-ets/utils/AttributeManager.ets +2 -2
- package/dist/components-harmony-ets/utils/DynamicCenter.ts +2 -2
- package/dist/components-harmony-ets/utils/flexManager.ets +50 -19
- package/dist/components-harmony-ets/utils/helper.ets +20 -8
- package/dist/components-harmony-ets/utils/htmlParser/HarmonyHTMLParser.ts +1 -2
- package/dist/components-harmony-ets/utils/htmlParser/index.ts +1 -1
- package/dist/components-harmony-ets/utils/index.ts +54 -50
- package/dist/components-harmony-ets/utils/styles.ets +172 -92
- package/dist/components-harmony-ets/video.ets +37 -88
- package/dist/components-harmony-ets/view.ets +63 -159
- package/dist/components-harmony-ets/webView.ets +41 -98
- package/dist/index.d.ts +152 -0
- package/dist/index.js +187 -56
- package/dist/index.js.map +1 -1
- package/dist/runtime-ets/bom/document.ts +6 -4
- package/dist/runtime-ets/bom/getComputedStyle.ts +2 -2
- package/dist/runtime-ets/bom/window.ts +9 -2
- package/dist/runtime-ets/current.ts +5 -1
- package/dist/runtime-ets/dom/bind.ts +28 -12
- package/dist/runtime-ets/dom/class-list.ts +2 -2
- package/dist/runtime-ets/dom/cssNesting.ts +419 -0
- package/dist/runtime-ets/dom/cssStyleDeclaration.ts +28 -42
- package/dist/runtime-ets/dom/document.ts +22 -8
- package/dist/runtime-ets/dom/element/canvas.ts +136 -0
- package/dist/runtime-ets/dom/element/element.ts +376 -57
- package/dist/runtime-ets/dom/element/form.ts +31 -26
- package/dist/runtime-ets/dom/element/index.ts +30 -2
- package/dist/runtime-ets/dom/element/movableArea.ts +11 -0
- package/dist/runtime-ets/dom/element/movableView.ts +248 -0
- package/dist/runtime-ets/dom/element/normal.ts +35 -8
- package/dist/runtime-ets/dom/element/progress.ts +11 -0
- package/dist/runtime-ets/dom/element/scrollView.ts +1 -0
- package/dist/runtime-ets/dom/element/text.ts +1 -8
- package/dist/runtime-ets/dom/element/video.ts +5 -4
- package/dist/runtime-ets/dom/element/webView.ts +12 -5
- package/dist/runtime-ets/dom/event.ts +3 -5
- package/dist/runtime-ets/dom/eventTarget.ts +2 -3
- package/dist/runtime-ets/dom/node.ts +65 -32
- package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +418 -237
- package/dist/runtime-ets/dom/stylesheet/index.ts +29 -311
- package/dist/runtime-ets/dom/stylesheet/type.ts +53 -11
- package/dist/runtime-ets/dom/stylesheet/util.ts +33 -27
- package/dist/runtime-ets/index.ts +2 -2
- package/dist/runtime-ets/interface/event.ts +1 -1
- package/dist/runtime-ets/utils/index.ts +74 -13
- package/dist/runtime-ets/utils/info.ts +2 -2
- package/dist/runtime-framework/react/app.ts +25 -30
- package/dist/runtime-framework/react/hooks.ts +3 -4
- package/dist/runtime-framework/react/index.ts +0 -2
- package/dist/runtime-framework/react/native-page.ts +219 -82
- package/dist/runtime-framework/react/page.ts +6 -10
- package/dist/runtime-framework/react/utils/index.ts +3 -3
- package/dist/runtime-framework/solid/app.ts +30 -46
- package/dist/runtime-framework/solid/connect.ts +21 -3
- package/dist/runtime-framework/solid/hooks.ts +17 -12
- package/dist/runtime-framework/solid/index.ts +6 -2
- package/dist/runtime-framework/solid/page.ts +85 -31
- package/dist/runtime-framework/solid/reconciler/props.ts +70 -25
- package/dist/runtime-framework/solid/reconciler/render.ts +16 -6
- package/dist/runtime-framework/solid/reconciler/use.ts +0 -1
- package/dist/runtime-framework/solid/utils/index.ts +3 -5
- package/dist/runtime-utils.d.ts +827 -0
- package/dist/runtime-utils.js +618 -245
- package/dist/runtime-utils.js.map +1 -1
- package/dist/runtime.d.ts +1 -0
- package/dist/runtime.js +618 -245
- package/dist/runtime.js.map +1 -1
- package/index.js +3 -1
- package/package.json +14 -15
- package/static/media/cancel.svg +1 -1
- package/static/media/circle.svg +1 -1
- package/static/media/clear.svg +1 -1
- package/static/media/download.svg +1 -1
- package/static/media/info.svg +1 -1
- package/static/media/info_circle.svg +1 -1
- package/static/media/search.svg +1 -1
- package/static/media/success.svg +1 -1
- package/static/media/success_no_circle.svg +1 -1
- package/static/media/warn.svg +1 -1
- package/types/harmony.d.ts +5 -0
- package/types/index.d.ts +4 -0
- package/types/runtime.d.ts +3 -1
- package/dist/runtime-ets/utils/bind.ts +0 -24
- /package/dist/runtime-framework/solid/{contant.ts → constant.ts} +0 -0
|
@@ -1,86 +1,24 @@
|
|
|
1
1
|
import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, createTaroEvent } from '@tarojs/runtime'
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import commonStyleModify, { rowModify, columnModify } from './style'
|
|
4
4
|
import { TOUCH_EVENT_MAP } from './utils/constant/event'
|
|
5
|
-
import { FlexManager } from './utils/
|
|
6
|
-
import { shouldBindEvent,
|
|
5
|
+
import { FlexManager } from './utils/flexManager'
|
|
6
|
+
import { shouldBindEvent, getNodeThresholds } from './utils/helper'
|
|
7
7
|
|
|
8
|
-
import { TaroEvent, TaroAny,
|
|
8
|
+
import { TaroEvent, TaroAny, HarmonyType, TaroRadioGroupElement, TaroRadioElement } from '@tarojs/runtime'
|
|
9
|
+
import { isUndefined } from '@tarojs/shared'
|
|
9
10
|
|
|
10
11
|
interface RadioAttrs {
|
|
11
12
|
radioStyle?: HarmonyType.RadioStyle
|
|
12
13
|
themeStyles?: boolean
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
@Extend(Radio)
|
|
16
|
-
function style (style: TaroStyleType) {
|
|
17
|
-
.id(style.id)
|
|
18
|
-
.key(style.id)
|
|
19
|
-
.flexGrow(style.flexGrow)
|
|
20
|
-
.flexShrink(style.flexShrink)
|
|
21
|
-
.flexBasis(style.flexBasis)
|
|
22
|
-
.alignSelf(style.alignSelf)
|
|
23
|
-
.padding({
|
|
24
|
-
top: style.paddingTop,
|
|
25
|
-
right: style.paddingRight,
|
|
26
|
-
bottom: style.paddingBottom,
|
|
27
|
-
left: style.paddingLeft
|
|
28
|
-
})
|
|
29
|
-
.margin({
|
|
30
|
-
top: style.marginTop,
|
|
31
|
-
right: style.marginRight,
|
|
32
|
-
bottom: style.marginBottom,
|
|
33
|
-
left: style.marginLeft
|
|
34
|
-
})
|
|
35
|
-
.width(style.width)
|
|
36
|
-
.height(style.height)
|
|
37
|
-
.constraintSize({
|
|
38
|
-
minWidth: style.minWidth,
|
|
39
|
-
maxWidth: style.maxWidth,
|
|
40
|
-
minHeight: style.minHeight,
|
|
41
|
-
maxHeight: style.maxHeight
|
|
42
|
-
})
|
|
43
|
-
.backgroundColor(style.backgroundColor)
|
|
44
|
-
.backgroundImage(style.backgroundImage?.src, style.backgroundRepeat)
|
|
45
|
-
.backgroundImageSize(style.backgroundSize)
|
|
46
|
-
.backgroundImagePosition(style.backgroundPosition)
|
|
47
|
-
.borderStyle({
|
|
48
|
-
top: style.borderTopStyle,
|
|
49
|
-
right: style.borderRightStyle,
|
|
50
|
-
bottom: style.borderBottomStyle,
|
|
51
|
-
left: style.borderLeftStyle
|
|
52
|
-
})
|
|
53
|
-
.borderWidth({
|
|
54
|
-
top: style.borderTopWidth,
|
|
55
|
-
right: style.borderRightWidth,
|
|
56
|
-
bottom: style.borderBottomWidth,
|
|
57
|
-
left: style.borderLeftWidth
|
|
58
|
-
})
|
|
59
|
-
.borderColor({
|
|
60
|
-
top: style.borderTopColor,
|
|
61
|
-
right: style.borderRightColor,
|
|
62
|
-
bottom: style.borderBottomColor,
|
|
63
|
-
left: style.borderLeftColor
|
|
64
|
-
})
|
|
65
|
-
.borderRadius({
|
|
66
|
-
topLeft: style.borderTopLeftRadius,
|
|
67
|
-
topRight: style.borderTopRightRadius,
|
|
68
|
-
bottomLeft: style.borderBottomLeftRadius,
|
|
69
|
-
bottomRight: style.borderBottomRightRadius
|
|
70
|
-
})
|
|
71
|
-
.zIndex(style.zIndex)
|
|
72
|
-
.opacity(style.opacity)
|
|
73
|
-
.linearGradient(style.linearGradient)
|
|
74
|
-
.clip(style.overflow)
|
|
75
|
-
.rotate({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y, angle: 0 })
|
|
76
|
-
.scale({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y })
|
|
77
|
-
.transform(style.transform)
|
|
14
|
+
disabled?: boolean
|
|
78
15
|
}
|
|
79
16
|
|
|
80
17
|
@Extend(Radio)
|
|
81
18
|
function radioAttr (attr: RadioAttrs) {
|
|
82
19
|
.radioStyle(attr.radioStyle)
|
|
83
|
-
.themeStyles(attr.themeStyles)
|
|
20
|
+
.themeStyles(attr.themeStyles || false)
|
|
21
|
+
.enabled(!attr.disabled)
|
|
84
22
|
}
|
|
85
23
|
|
|
86
24
|
function getAttributes (node: TaroRadioElement): RadioAttrs {
|
|
@@ -89,6 +27,7 @@ function getAttributes (node: TaroRadioElement): RadioAttrs {
|
|
|
89
27
|
checkedBackgroundColor: node._attrs.color || '#1aad19'
|
|
90
28
|
}
|
|
91
29
|
radioAttrs.themeStyles = !!node._attrs.disabled
|
|
30
|
+
radioAttrs.disabled = !!node._attrs.disabled
|
|
92
31
|
return radioAttrs
|
|
93
32
|
}
|
|
94
33
|
|
|
@@ -99,197 +38,72 @@ function themeStyles(isDisabled: boolean) {
|
|
|
99
38
|
|
|
100
39
|
@Component
|
|
101
40
|
export struct TaroRadio {
|
|
102
|
-
|
|
103
|
-
|
|
41
|
+
@Builder customBuilder() {}
|
|
42
|
+
@BuilderParam createLazyChildren: (node: TaroRadioElement, layer?: number) => void = this.customBuilder
|
|
43
|
+
@ObjectLink node: TaroRadioElement
|
|
44
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
45
|
+
|
|
104
46
|
aboutToAppear () {
|
|
105
47
|
if (this.node && !this.node._isInit) {
|
|
106
48
|
this.node._isInit = true
|
|
49
|
+
this.node._instance = this
|
|
107
50
|
this.node._reset = this.node.checked || false
|
|
108
51
|
}
|
|
109
52
|
}
|
|
110
53
|
|
|
111
54
|
build () {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
.
|
|
123
|
-
if (this.node) {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
eventHandler(event, 'change', this.node)
|
|
132
|
-
}
|
|
55
|
+
Stack() {
|
|
56
|
+
Row() {
|
|
57
|
+
Radio({
|
|
58
|
+
group: this.node.group || this.node.parentNode?._nid.toString() || '',
|
|
59
|
+
value: this.node.value || '',
|
|
60
|
+
})
|
|
61
|
+
.checked(this.node.checked)
|
|
62
|
+
.attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
63
|
+
.radioAttr(getAttributes(this.node))
|
|
64
|
+
.onChange((value: boolean) => {
|
|
65
|
+
if (this.node) {
|
|
66
|
+
if (!!this.node?._attrs.disabled) {
|
|
67
|
+
this.node.updateComponent()
|
|
68
|
+
} else {
|
|
69
|
+
this.node.updateCheckedValue(value)
|
|
70
|
+
|
|
71
|
+
if (value) {
|
|
72
|
+
const event: TaroEvent = createTaroEvent('change', { detail: { value: this.node?._attrs.value } }, this.node)
|
|
73
|
+
eventHandler(event, 'change', this.node)
|
|
133
74
|
}
|
|
134
75
|
}
|
|
135
|
-
})
|
|
136
|
-
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
137
|
-
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
138
|
-
if (this.node) {
|
|
139
|
-
this.node._nodeInfo.areaInfo = res[1]
|
|
140
|
-
}
|
|
141
|
-
}))
|
|
142
|
-
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
143
|
-
Text(this.node.textContent)
|
|
144
|
-
.textAlign(TextAlign.Center)
|
|
145
|
-
.opacity(!!this.node?._attrs.disabled ? 0.4 : 1)
|
|
146
|
-
}
|
|
147
|
-
.onClick(() => {
|
|
148
|
-
if (this.node) {
|
|
149
|
-
if (!this.node._checked && !this.node?._attrs.disabled) {
|
|
150
|
-
this.node.checked = !this.node.checked
|
|
151
76
|
}
|
|
152
|
-
}
|
|
153
|
-
|
|
77
|
+
})
|
|
78
|
+
.onClick(shouldBindEvent((e: ClickEvent) => { eventHandler(e, 'click', this.node) }, this.node, ['click']))
|
|
79
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
80
|
+
if (this.node) {
|
|
81
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
82
|
+
}
|
|
83
|
+
}))
|
|
84
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
85
|
+
Text(this.node.textContent)
|
|
86
|
+
.textAlign(TextAlign.Center)
|
|
87
|
+
.opacity(!!this.node?._attrs.disabled ? 0.4 : 1)
|
|
154
88
|
}
|
|
89
|
+
.onClick(() => {
|
|
90
|
+
if (this.node) {
|
|
91
|
+
if (!this.node._checked && !this.node?._attrs.disabled) {
|
|
92
|
+
this.node.checked = !this.node.checked
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
})
|
|
155
96
|
}
|
|
156
97
|
}
|
|
157
98
|
}
|
|
158
99
|
|
|
159
|
-
@Extend(Column)
|
|
160
|
-
function radioGroupColumnAttrs (style: TaroStyleType) {
|
|
161
|
-
.id(style.id)
|
|
162
|
-
.key(style.id)
|
|
163
|
-
.flexGrow(style.flexGrow)
|
|
164
|
-
.flexShrink(style.flexShrink)
|
|
165
|
-
.flexBasis(style.flexBasis)
|
|
166
|
-
.alignSelf(style.alignSelf)
|
|
167
|
-
.padding({
|
|
168
|
-
top: style.paddingTop,
|
|
169
|
-
right: style.paddingRight,
|
|
170
|
-
bottom: style.paddingBottom,
|
|
171
|
-
left: style.paddingLeft
|
|
172
|
-
})
|
|
173
|
-
.margin({
|
|
174
|
-
top: style.marginTop,
|
|
175
|
-
right: style.marginRight,
|
|
176
|
-
bottom: style.marginBottom,
|
|
177
|
-
left: style.marginLeft
|
|
178
|
-
})
|
|
179
|
-
.width(style.width)
|
|
180
|
-
.height(style.height)
|
|
181
|
-
.constraintSize({
|
|
182
|
-
minWidth: style.minWidth,
|
|
183
|
-
maxWidth: style.maxWidth,
|
|
184
|
-
minHeight: style.minHeight,
|
|
185
|
-
maxHeight: style.maxHeight
|
|
186
|
-
})
|
|
187
|
-
.backgroundColor(style.backgroundColor)
|
|
188
|
-
.backgroundImage(style.backgroundImage?.src, style.backgroundRepeat)
|
|
189
|
-
.backgroundImageSize(style.backgroundSize)
|
|
190
|
-
.backgroundImagePosition(style.backgroundPosition)
|
|
191
|
-
.borderStyle({
|
|
192
|
-
top: style.borderTopStyle,
|
|
193
|
-
right: style.borderRightStyle,
|
|
194
|
-
bottom: style.borderBottomStyle,
|
|
195
|
-
left: style.borderLeftStyle
|
|
196
|
-
})
|
|
197
|
-
.borderWidth({
|
|
198
|
-
top: style.borderTopWidth,
|
|
199
|
-
right: style.borderRightWidth,
|
|
200
|
-
bottom: style.borderBottomWidth,
|
|
201
|
-
left: style.borderLeftWidth
|
|
202
|
-
})
|
|
203
|
-
.borderColor({
|
|
204
|
-
top: style.borderTopColor,
|
|
205
|
-
right: style.borderRightColor,
|
|
206
|
-
bottom: style.borderBottomColor,
|
|
207
|
-
left: style.borderLeftColor
|
|
208
|
-
})
|
|
209
|
-
.borderRadius({
|
|
210
|
-
topLeft: style.borderTopLeftRadius,
|
|
211
|
-
topRight: style.borderTopRightRadius,
|
|
212
|
-
bottomLeft: style.borderBottomLeftRadius,
|
|
213
|
-
bottomRight: style.borderBottomRightRadius
|
|
214
|
-
})
|
|
215
|
-
.zIndex(style.zIndex)
|
|
216
|
-
.opacity(style.opacity)
|
|
217
|
-
.linearGradient(style.linearGradient)
|
|
218
|
-
.clip(style.overflow)
|
|
219
|
-
.rotate({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y, angle: 0 })
|
|
220
|
-
.scale({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y })
|
|
221
|
-
.transform(style.transform)
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
@Extend(Row)
|
|
225
|
-
function radioGroupRowAttrs (style: TaroStyleType) {
|
|
226
|
-
.id(style.id)
|
|
227
|
-
.key(style.id)
|
|
228
|
-
.flexGrow(style.flexGrow)
|
|
229
|
-
.flexShrink(style.flexShrink)
|
|
230
|
-
.flexBasis(style.flexBasis)
|
|
231
|
-
.alignSelf(style.alignSelf)
|
|
232
|
-
.padding({
|
|
233
|
-
top: style.paddingTop,
|
|
234
|
-
right: style.paddingRight,
|
|
235
|
-
bottom: style.paddingBottom,
|
|
236
|
-
left: style.paddingLeft
|
|
237
|
-
})
|
|
238
|
-
.margin({
|
|
239
|
-
top: style.marginTop,
|
|
240
|
-
right: style.marginRight,
|
|
241
|
-
bottom: style.marginBottom,
|
|
242
|
-
left: style.marginLeft
|
|
243
|
-
})
|
|
244
|
-
.width(style.width)
|
|
245
|
-
.height(style.height)
|
|
246
|
-
.constraintSize({
|
|
247
|
-
minWidth: style.minWidth,
|
|
248
|
-
maxWidth: style.maxWidth,
|
|
249
|
-
minHeight: style.minHeight,
|
|
250
|
-
maxHeight: style.maxHeight
|
|
251
|
-
})
|
|
252
|
-
.backgroundColor(style.backgroundColor)
|
|
253
|
-
.backgroundImage(style.backgroundImage?.src, style.backgroundRepeat)
|
|
254
|
-
.backgroundImageSize(style.backgroundSize)
|
|
255
|
-
.backgroundImagePosition(style.backgroundPosition)
|
|
256
|
-
.borderStyle({
|
|
257
|
-
top: style.borderTopStyle,
|
|
258
|
-
right: style.borderRightStyle,
|
|
259
|
-
bottom: style.borderBottomStyle,
|
|
260
|
-
left: style.borderLeftStyle
|
|
261
|
-
})
|
|
262
|
-
.borderWidth({
|
|
263
|
-
top: style.borderTopWidth,
|
|
264
|
-
right: style.borderRightWidth,
|
|
265
|
-
bottom: style.borderBottomWidth,
|
|
266
|
-
left: style.borderLeftWidth
|
|
267
|
-
})
|
|
268
|
-
.borderColor({
|
|
269
|
-
top: style.borderTopColor,
|
|
270
|
-
right: style.borderRightColor,
|
|
271
|
-
bottom: style.borderBottomColor,
|
|
272
|
-
left: style.borderLeftColor
|
|
273
|
-
})
|
|
274
|
-
.borderRadius({
|
|
275
|
-
topLeft: style.borderTopLeftRadius,
|
|
276
|
-
topRight: style.borderTopRightRadius,
|
|
277
|
-
bottomLeft: style.borderBottomLeftRadius,
|
|
278
|
-
bottomRight: style.borderBottomRightRadius
|
|
279
|
-
})
|
|
280
|
-
.zIndex(style.zIndex)
|
|
281
|
-
.opacity(style.opacity)
|
|
282
|
-
.linearGradient(style.linearGradient)
|
|
283
|
-
.clip(style.overflow)
|
|
284
|
-
.rotate({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y, angle: 0 })
|
|
285
|
-
.scale({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y })
|
|
286
|
-
.transform(style.transform)
|
|
287
|
-
}
|
|
288
|
-
|
|
289
100
|
|
|
290
101
|
@Component
|
|
291
102
|
export struct TaroRadioGroup {
|
|
292
|
-
|
|
103
|
+
@Builder customBuilder() {}
|
|
104
|
+
@BuilderParam createLazyChildren: (node: TaroRadioGroupElement, layer?: number) => void = this.customBuilder
|
|
105
|
+
@ObjectLink node: TaroRadioGroupElement
|
|
106
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
293
107
|
|
|
294
108
|
@Styles visibleChangeEvent () {
|
|
295
109
|
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
@@ -297,9 +111,10 @@ export struct TaroRadioGroup {
|
|
|
297
111
|
|
|
298
112
|
aboutToAppear () {
|
|
299
113
|
if (this.node) {
|
|
114
|
+
this.node._instance = this
|
|
300
115
|
const childList = this.node.getElementsByTagName<TaroRadioElement>('RADIO')
|
|
301
116
|
childList.forEach(element => {
|
|
302
|
-
element.group = this.node?._attrs.name || this.node?._nid
|
|
117
|
+
element.group = this.node?._attrs.name || this.node?._nid.toString()
|
|
303
118
|
})
|
|
304
119
|
// 阻止事件冒泡传递上去
|
|
305
120
|
this.node.addEventListener('change', (e: TaroEvent) => e.stopPropagation())
|
|
@@ -307,8 +122,8 @@ export struct TaroRadioGroup {
|
|
|
307
122
|
}
|
|
308
123
|
|
|
309
124
|
@Styles defaultEvent () {
|
|
310
|
-
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
311
|
-
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
|
|
125
|
+
.onClick(shouldBindEvent((e: ClickEvent) => { eventHandler(e, 'click', this.node) }, this.node, ['click']))
|
|
126
|
+
.onTouch(shouldBindEvent((e: TouchEvent) => { eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node) }, this.node, TOUCH_EVENT_MAP.values()))
|
|
312
127
|
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
313
128
|
if (this.node) {
|
|
314
129
|
this.node._nodeInfo.areaInfo = res[1]
|
|
@@ -317,26 +132,27 @@ export struct TaroRadioGroup {
|
|
|
317
132
|
}
|
|
318
133
|
|
|
319
134
|
build() {
|
|
320
|
-
if (this.node) {
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
.
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
.
|
|
337
|
-
.alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)
|
|
338
|
-
.justifyContent(FlexManager.flexOptions(this.node).justifyContent)
|
|
135
|
+
if (FlexManager.useFlexLayout(this.node)) {
|
|
136
|
+
Flex(FlexManager.flexOptions(this.node)) {
|
|
137
|
+
this.createLazyChildren(this.node, 0)
|
|
138
|
+
}
|
|
139
|
+
.attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
140
|
+
.defaultEvent()
|
|
141
|
+
.visibleChangeEvent()
|
|
142
|
+
} else if (FlexManager.isFlexNode(this.node) && FlexManager.direction(this.node) !== FlexDirection.Column) {
|
|
143
|
+
Row() {
|
|
144
|
+
this.createLazyChildren(this.node, 0)
|
|
145
|
+
}
|
|
146
|
+
.attributeModifier(rowModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
147
|
+
.defaultEvent()
|
|
148
|
+
.visibleChangeEvent()
|
|
149
|
+
} else {
|
|
150
|
+
Column() {
|
|
151
|
+
this.createLazyChildren(this.node, 0)
|
|
339
152
|
}
|
|
153
|
+
.attributeModifier(columnModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
154
|
+
.defaultEvent()
|
|
155
|
+
.visibleChangeEvent()
|
|
340
156
|
}
|
|
341
157
|
}
|
|
342
158
|
}
|
|
@@ -1,107 +1,25 @@
|
|
|
1
1
|
import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME } from '@tarojs/runtime'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import type { TaroAny,
|
|
8
|
-
|
|
9
|
-
@
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
.margin({
|
|
24
|
-
top: style.marginTop,
|
|
25
|
-
right: style.marginRight,
|
|
26
|
-
bottom: style.marginBottom,
|
|
27
|
-
left: style.marginLeft
|
|
28
|
-
})
|
|
29
|
-
.width(style.width)
|
|
30
|
-
.height(style.height)
|
|
31
|
-
.constraintSize({
|
|
32
|
-
minWidth: style.minWidth,
|
|
33
|
-
maxWidth: style.maxWidth,
|
|
34
|
-
minHeight: style.minHeight,
|
|
35
|
-
maxHeight: style.maxHeight
|
|
36
|
-
})
|
|
37
|
-
.backgroundColor(style.backgroundColor)
|
|
38
|
-
.backgroundImage(style.backgroundImage?.src, style.backgroundRepeat)
|
|
39
|
-
.backgroundImageSize(style.backgroundSize)
|
|
40
|
-
.backgroundImagePosition(style.backgroundPosition)
|
|
41
|
-
.borderStyle({
|
|
42
|
-
top: style.borderTopStyle,
|
|
43
|
-
right: style.borderRightStyle,
|
|
44
|
-
bottom: style.borderBottomStyle,
|
|
45
|
-
left: style.borderLeftStyle
|
|
46
|
-
})
|
|
47
|
-
.borderWidth({
|
|
48
|
-
top: style.borderTopWidth,
|
|
49
|
-
right: style.borderRightWidth,
|
|
50
|
-
bottom: style.borderBottomWidth,
|
|
51
|
-
left: style.borderLeftWidth
|
|
52
|
-
})
|
|
53
|
-
.borderColor({
|
|
54
|
-
top: style.borderTopColor,
|
|
55
|
-
right: style.borderRightColor,
|
|
56
|
-
bottom: style.borderBottomColor,
|
|
57
|
-
left: style.borderLeftColor
|
|
58
|
-
})
|
|
59
|
-
.borderRadius({
|
|
60
|
-
topLeft: style.borderTopLeftRadius,
|
|
61
|
-
topRight: style.borderTopRightRadius,
|
|
62
|
-
bottomLeft: style.borderBottomLeftRadius,
|
|
63
|
-
bottomRight: style.borderBottomRightRadius
|
|
64
|
-
})
|
|
65
|
-
.zIndex(style.zIndex)
|
|
66
|
-
.opacity(style.opacity)
|
|
67
|
-
.linearGradient(style.linearGradient)
|
|
68
|
-
.clip(style.overflow)
|
|
69
|
-
.rotate({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y, angle: 0 })
|
|
70
|
-
.scale({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y })
|
|
71
|
-
.transform(style.transform)
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
function generateText (node: TaroRichTextElement): string {
|
|
76
|
-
return parseHtmlNode(node._attrs.nodes || '')
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
@Builder
|
|
80
|
-
export default function TaroRichText (node: TaroRichTextElement) {
|
|
81
|
-
RichText(generateText(node))
|
|
82
|
-
.attrs(getNormalAttributes(node))
|
|
83
|
-
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', node), node, ['click']))
|
|
84
|
-
.onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
85
|
-
node._nodeInfo.areaInfo = res[1]
|
|
86
|
-
}))
|
|
87
|
-
.onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// 将nodeTree转换成harmony需要的string结构
|
|
91
|
-
function nodeToHtml(node: RichTextProps.Text | RichTextProps.HTMLElement): string {
|
|
92
|
-
if (node.type === 'text') {
|
|
93
|
-
return node.text;
|
|
94
|
-
}
|
|
95
|
-
if (node.attrs) {
|
|
96
|
-
const attributes = Object.entries(node.attrs)
|
|
97
|
-
.map((item: [string, string]) => `${item[0]}="${item[1]}"`)
|
|
98
|
-
.join(' ');
|
|
99
|
-
const childrenHtml: string = typeof node.children === 'string' ? node.children : (node.children || []).map((child: RichTextProps.Text | RichTextProps.HTMLElement) => nodeToHtml(child)).join('');
|
|
100
|
-
return `<${node.name}${attributes ? ' ' + attributes : ''}>${childrenHtml}</${node.name}>`;
|
|
3
|
+
import commonStyleModify from './style'
|
|
4
|
+
import { generateText } from './utils'
|
|
5
|
+
import { getNodeThresholds, shouldBindEvent } from './utils/helper'
|
|
6
|
+
|
|
7
|
+
import type { TaroAny, TaroRichTextElement } from '@tarojs/runtime'
|
|
8
|
+
|
|
9
|
+
@Component
|
|
10
|
+
export default struct TaroRichText {
|
|
11
|
+
@Builder customBuilder() {}
|
|
12
|
+
@BuilderParam createLazyChildren: (node: TaroRichTextElement, layer?: number) => void = this.customBuilder
|
|
13
|
+
@ObjectLink node: TaroRichTextElement
|
|
14
|
+
|
|
15
|
+
build () {
|
|
16
|
+
RichText(generateText(this.node))
|
|
17
|
+
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
18
|
+
.onClick(shouldBindEvent((e: ClickEvent) => { eventHandler(e, 'click', this.node) }, this.node, ['click']))
|
|
19
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
20
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
21
|
+
}))
|
|
22
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
101
23
|
}
|
|
102
|
-
return ''
|
|
103
24
|
}
|
|
104
25
|
|
|
105
|
-
function parseHtmlNode (nodes: Array<RichTextProps.Text | RichTextProps.HTMLElement> | string) {
|
|
106
|
-
return typeof nodes === 'string' ? nodes: `<div>${nodes.map(node => nodeToHtml(node)).join('')}</div>`
|
|
107
|
-
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, createTaroEvent } from '@tarojs/runtime'
|
|
2
|
+
|
|
3
|
+
import commonStyleModify from './style'
|
|
4
|
+
import { TOUCH_EVENT_MAP } from './utils/constant/event'
|
|
5
|
+
import { getNodeThresholds, shouldBindEvent } from './utils/helper'
|
|
6
|
+
|
|
7
|
+
import type { TaroScrollViewElement, TaroAny, TaroEvent } from '@tarojs/runtime'
|
|
8
|
+
|
|
9
|
+
interface ScrollViewAttrs {
|
|
10
|
+
scrollBar: BarState
|
|
11
|
+
}
|
|
12
|
+
interface ScrollViewCurrentOffset {
|
|
13
|
+
xOffset: number
|
|
14
|
+
yOffset: number
|
|
15
|
+
}
|
|
16
|
+
interface ScrollViewEvent {
|
|
17
|
+
deltaX: number
|
|
18
|
+
deltaY: number
|
|
19
|
+
scrollLeft: number
|
|
20
|
+
scrollTop: number
|
|
21
|
+
scrollWidth: number
|
|
22
|
+
scrollHeight: number
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function getAttributes (node: TaroScrollViewElement): ScrollViewAttrs {
|
|
26
|
+
const _attrs = node._attrs
|
|
27
|
+
const scrollAttrs: ScrollViewAttrs = {
|
|
28
|
+
scrollBar: typeof _attrs.showScrollbar === 'boolean'
|
|
29
|
+
? _attrs.showScrollbar ? BarState.On : BarState.Off
|
|
30
|
+
: BarState.Auto
|
|
31
|
+
}
|
|
32
|
+
return scrollAttrs
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function handleScrollEvent (node: TaroScrollViewElement, eventName = 'scroll', scrollOffset?: number) {
|
|
36
|
+
if (!node || !node.scroller) return
|
|
37
|
+
|
|
38
|
+
const currentOffset = node.scroller.currentOffset() as ScrollViewCurrentOffset
|
|
39
|
+
|
|
40
|
+
if (!currentOffset) return
|
|
41
|
+
|
|
42
|
+
const currentXOffset = currentOffset?.xOffset || 0
|
|
43
|
+
const currentYOffset = currentOffset?.yOffset || 0
|
|
44
|
+
const value: ScrollViewEvent = {
|
|
45
|
+
deltaX: vp2px(node._attrs.scrollX ? scrollOffset : 0),
|
|
46
|
+
deltaY: vp2px(node._attrs.scrollX ? 0 : scrollOffset),
|
|
47
|
+
scrollLeft: vp2px(currentXOffset),
|
|
48
|
+
scrollTop: vp2px(currentYOffset),
|
|
49
|
+
scrollWidth: vp2px(Number(node._nodeInfo?._scroll?.width)),
|
|
50
|
+
scrollHeight: vp2px(Number(node._nodeInfo?._scroll?.height)),
|
|
51
|
+
}
|
|
52
|
+
const event: TaroEvent = createTaroEvent(eventName, { detail: value }, node)
|
|
53
|
+
|
|
54
|
+
eventHandler(event, eventName, node)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@Component
|
|
58
|
+
export default struct TaroScrollList {
|
|
59
|
+
@Builder customBuilder() {}
|
|
60
|
+
@BuilderParam createLazyChildren: (node: TaroScrollViewElement, layer?: number) => void = this.customBuilder
|
|
61
|
+
@ObjectLink node: TaroScrollViewElement
|
|
62
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
63
|
+
|
|
64
|
+
aboutToAppear(): void {
|
|
65
|
+
if (this.node) {
|
|
66
|
+
this.node._instance = this
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
handleScroll = (scrollOffset: number) => {
|
|
71
|
+
handleScrollEvent(this.node, 'scroll', scrollOffset)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
build() {
|
|
75
|
+
List({
|
|
76
|
+
scroller: this.node.scroller
|
|
77
|
+
}) {
|
|
78
|
+
this.createLazyChildren(this.node, 0)
|
|
79
|
+
}
|
|
80
|
+
.attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
81
|
+
.sticky(StickyStyle.Header)
|
|
82
|
+
.listDirection(this.node.getAttribute('scrollX') ? Axis.Horizontal: Axis.Vertical)
|
|
83
|
+
.align(Alignment.TopStart)
|
|
84
|
+
.clip(true)
|
|
85
|
+
.scrollBar(getAttributes(this.node).scrollBar)
|
|
86
|
+
.onScrollIndex((first: number, last: number) => {
|
|
87
|
+
const scrollindexfns = (this.node?.__listeners?.['scrollindex'] || []) as Function[]
|
|
88
|
+
scrollindexfns.forEach(fn => {
|
|
89
|
+
fn({
|
|
90
|
+
first,
|
|
91
|
+
last
|
|
92
|
+
})
|
|
93
|
+
})
|
|
94
|
+
})
|
|
95
|
+
.onClick(shouldBindEvent((e: ClickEvent) => { eventHandler(e, 'click', this.node) }, this.node, ['click']))
|
|
96
|
+
.onTouch(shouldBindEvent((e: TouchEvent) => { eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node) }, this.node, TOUCH_EVENT_MAP.values()))
|
|
97
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
98
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
99
|
+
}))
|
|
100
|
+
.onDidScroll(shouldBindEvent((scrollOffset: number) => { handleScrollEvent(this.node, 'scroll', scrollOffset) }, this.node, ['scroll']))
|
|
101
|
+
.onScrollStart(shouldBindEvent(() => { handleScrollEvent(this.node, 'scrollstart') }, this.node, ['scrollstart']))
|
|
102
|
+
.onScrollStop(shouldBindEvent(() => { handleScrollEvent(this.node, 'scrollend') }, this.node, ['scrollend']))
|
|
103
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
104
|
+
.onReachEnd(shouldBindEvent(() => { handleScrollEvent(this.node, 'scrolltolower') }, this.node, ['scrolltolower']))
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
|