@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,10 +1,11 @@
|
|
|
1
1
|
import { createTaroEvent, eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME } from '@tarojs/runtime'
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import { FlexManager } from './utils/
|
|
5
|
-
import { shouldBindEvent,
|
|
3
|
+
import commonStyleModify, { rowModify, columnModify } from './style'
|
|
4
|
+
import { FlexManager } from './utils/flexManager'
|
|
5
|
+
import { shouldBindEvent, getNodeThresholds } from './utils/helper'
|
|
6
6
|
|
|
7
|
-
import type {
|
|
7
|
+
import type { TaroAny, TaroEvent, TaroCheckboxElement, TaroCheckboxGroupElement } from '@tarojs/runtime'
|
|
8
|
+
import { isUndefined } from '@tarojs/shared'
|
|
8
9
|
|
|
9
10
|
interface CheckboxOptions {
|
|
10
11
|
name?: string
|
|
@@ -12,82 +13,20 @@ interface CheckboxOptions {
|
|
|
12
13
|
}
|
|
13
14
|
interface CheckboxAttrs {
|
|
14
15
|
selectedColor?: ResourceColor
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
@Extend(Checkbox)
|
|
18
|
-
function checkboxStyle (style: TaroStyleType) {
|
|
19
|
-
.id(style.id)
|
|
20
|
-
.key(style.id)
|
|
21
|
-
.flexGrow(style.flexGrow)
|
|
22
|
-
.flexShrink(style.flexShrink)
|
|
23
|
-
.flexBasis(style.flexBasis)
|
|
24
|
-
.alignSelf(style.alignSelf)
|
|
25
|
-
.padding({
|
|
26
|
-
top: style.paddingTop,
|
|
27
|
-
right: style.paddingRight,
|
|
28
|
-
bottom: style.paddingBottom,
|
|
29
|
-
left: style.paddingLeft
|
|
30
|
-
})
|
|
31
|
-
.margin({
|
|
32
|
-
top: style.marginTop,
|
|
33
|
-
right: style.marginRight,
|
|
34
|
-
bottom: style.marginBottom,
|
|
35
|
-
left: style.marginLeft
|
|
36
|
-
})
|
|
37
|
-
.width(style.width)
|
|
38
|
-
.height(style.height)
|
|
39
|
-
.constraintSize({
|
|
40
|
-
minWidth: style.minWidth,
|
|
41
|
-
maxWidth: style.maxWidth,
|
|
42
|
-
minHeight: style.minHeight,
|
|
43
|
-
maxHeight: style.maxHeight
|
|
44
|
-
})
|
|
45
|
-
.backgroundColor(style.backgroundColor)
|
|
46
|
-
.backgroundImage(style.backgroundImage?.src, style.backgroundRepeat)
|
|
47
|
-
.backgroundImageSize(style.backgroundSize)
|
|
48
|
-
.backgroundImagePosition(style.backgroundPosition)
|
|
49
|
-
.borderStyle({
|
|
50
|
-
top: style.borderTopStyle,
|
|
51
|
-
right: style.borderRightStyle,
|
|
52
|
-
bottom: style.borderBottomStyle,
|
|
53
|
-
left: style.borderLeftStyle
|
|
54
|
-
})
|
|
55
|
-
.borderWidth({
|
|
56
|
-
top: style.borderTopWidth,
|
|
57
|
-
right: style.borderRightWidth,
|
|
58
|
-
bottom: style.borderBottomWidth,
|
|
59
|
-
left: style.borderLeftWidth
|
|
60
|
-
})
|
|
61
|
-
.borderColor({
|
|
62
|
-
top: style.borderTopColor,
|
|
63
|
-
right: style.borderRightColor,
|
|
64
|
-
bottom: style.borderBottomColor,
|
|
65
|
-
left: style.borderLeftColor
|
|
66
|
-
})
|
|
67
|
-
.borderRadius({
|
|
68
|
-
topLeft: style.borderTopLeftRadius,
|
|
69
|
-
topRight: style.borderTopRightRadius,
|
|
70
|
-
bottomLeft: style.borderBottomLeftRadius,
|
|
71
|
-
bottomRight: style.borderBottomRightRadius
|
|
72
|
-
})
|
|
73
|
-
.zIndex(style.zIndex)
|
|
74
|
-
.opacity(style.opacity)
|
|
75
|
-
.linearGradient(style.linearGradient)
|
|
76
|
-
.clip(style.overflow)
|
|
77
|
-
.rotate({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y, angle: 0 })
|
|
78
|
-
.scale({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y })
|
|
79
|
-
.transform(style.transform)
|
|
16
|
+
disabled?: boolean
|
|
80
17
|
}
|
|
81
18
|
|
|
82
19
|
@Extend(Checkbox)
|
|
83
20
|
function checkboxAttr(attr: CheckboxAttrs) {
|
|
84
21
|
.selectedColor(attr.selectedColor)
|
|
22
|
+
.enabled(!attr.disabled)
|
|
85
23
|
}
|
|
86
24
|
|
|
87
25
|
function getAttributes (node: TaroCheckboxElement): CheckboxAttrs {
|
|
88
26
|
const _attrs = node._attrs
|
|
89
27
|
const checkboxAttrs: CheckboxAttrs = {}
|
|
90
28
|
checkboxAttrs.selectedColor = _attrs.color || '#1aad19'
|
|
29
|
+
checkboxAttrs.disabled = !!_attrs.disabled
|
|
91
30
|
return checkboxAttrs
|
|
92
31
|
}
|
|
93
32
|
|
|
@@ -97,198 +36,74 @@ function getOptions (node: TaroCheckboxElement): CheckboxOptions {
|
|
|
97
36
|
}
|
|
98
37
|
}
|
|
99
38
|
|
|
39
|
+
|
|
100
40
|
@Component
|
|
101
41
|
export struct TaroCheckbox {
|
|
102
|
-
|
|
42
|
+
@Builder customBuilder() {}
|
|
43
|
+
@BuilderParam createLazyChildren: (node: TaroCheckboxElement, layer?: number) => void = this.customBuilder
|
|
44
|
+
@ObjectLink node: TaroCheckboxElement
|
|
45
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
103
46
|
|
|
104
47
|
aboutToAppear () {
|
|
105
48
|
if (this.node && !this.node._isInit) {
|
|
106
49
|
this.node._isInit = true
|
|
50
|
+
this.node._instance = this
|
|
107
51
|
this.node._reset = this.node.checked || false
|
|
108
52
|
}
|
|
109
53
|
}
|
|
110
54
|
|
|
111
55
|
build () {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
.
|
|
121
|
-
if (this.node) {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
eventHandler(event, 'change', this.node)
|
|
130
|
-
}
|
|
56
|
+
Stack() {
|
|
57
|
+
Row() {
|
|
58
|
+
Checkbox(getOptions(this.node))
|
|
59
|
+
.attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
60
|
+
.checkboxAttr(getAttributes(this.node))
|
|
61
|
+
.opacity(!!this.node._attrs.disabled ? 0.4 : 1)
|
|
62
|
+
.select(this.node.checked)
|
|
63
|
+
.onChange((value: boolean) => {
|
|
64
|
+
if (this.node) {
|
|
65
|
+
if (!!this.node?._attrs.disabled) {
|
|
66
|
+
this.node.updateComponent()
|
|
67
|
+
} else {
|
|
68
|
+
this.node.updateCheckedValue(value)
|
|
69
|
+
|
|
70
|
+
if (value) {
|
|
71
|
+
const event: TaroEvent = createTaroEvent('change', { detail: { value: this.node?._attrs.value } }, this.node)
|
|
72
|
+
eventHandler(event, 'change', this.node)
|
|
131
73
|
}
|
|
132
74
|
}
|
|
133
|
-
})
|
|
134
|
-
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
135
|
-
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
136
|
-
if (this.node) {
|
|
137
|
-
this.node._nodeInfo.areaInfo = res[1]
|
|
138
|
-
}
|
|
139
|
-
}))
|
|
140
|
-
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
141
|
-
Text(this.node.textContent)
|
|
142
|
-
.textAlign(TextAlign.Center)
|
|
143
|
-
.opacity(!!this.node._attrs.disabled ? 0.4 : 1)
|
|
144
|
-
}
|
|
145
|
-
.onClick(() => {
|
|
146
|
-
if (this.node) {
|
|
147
|
-
if (!this.node?._attrs.disabled) {
|
|
148
|
-
this.node.checked = !this.node.checked
|
|
149
75
|
}
|
|
150
|
-
}
|
|
151
|
-
|
|
76
|
+
})
|
|
77
|
+
.onClick(shouldBindEvent((e: ClickEvent) => { eventHandler(e, 'click', this.node) }, this.node, ['click']))
|
|
78
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
79
|
+
if (this.node) {
|
|
80
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
81
|
+
}
|
|
82
|
+
}))
|
|
83
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
84
|
+
Text(this.node.textContent)
|
|
85
|
+
.textAlign(TextAlign.Center)
|
|
86
|
+
.opacity(!!this.node._attrs.disabled ? 0.4 : 1)
|
|
152
87
|
}
|
|
88
|
+
.onClick(() => {
|
|
89
|
+
if (this.node) {
|
|
90
|
+
if (!this.node?._attrs.disabled) {
|
|
91
|
+
this.node.checked = !this.node.checked
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
})
|
|
153
95
|
}
|
|
154
96
|
}
|
|
155
97
|
}
|
|
156
98
|
|
|
157
|
-
@Extend(Column)
|
|
158
|
-
function checkboxGroupColumnAttrs (style: TaroStyleType) {
|
|
159
|
-
.id(style.id)
|
|
160
|
-
.key(style.id)
|
|
161
|
-
.flexGrow(style.flexGrow)
|
|
162
|
-
.flexShrink(style.flexShrink)
|
|
163
|
-
.flexBasis(style.flexBasis)
|
|
164
|
-
.alignSelf(style.alignSelf)
|
|
165
|
-
.padding({
|
|
166
|
-
top: style.paddingTop,
|
|
167
|
-
right: style.paddingRight,
|
|
168
|
-
bottom: style.paddingBottom,
|
|
169
|
-
left: style.paddingLeft
|
|
170
|
-
})
|
|
171
|
-
.margin({
|
|
172
|
-
top: style.marginTop,
|
|
173
|
-
right: style.marginRight,
|
|
174
|
-
bottom: style.marginBottom,
|
|
175
|
-
left: style.marginLeft
|
|
176
|
-
})
|
|
177
|
-
.width(style.width)
|
|
178
|
-
.height(style.height)
|
|
179
|
-
.constraintSize({
|
|
180
|
-
minWidth: style.minWidth,
|
|
181
|
-
maxWidth: style.maxWidth,
|
|
182
|
-
minHeight: style.minHeight,
|
|
183
|
-
maxHeight: style.maxHeight
|
|
184
|
-
})
|
|
185
|
-
.backgroundColor(style.backgroundColor)
|
|
186
|
-
.backgroundImage(style.backgroundImage?.src, style.backgroundRepeat)
|
|
187
|
-
.backgroundImageSize(style.backgroundSize)
|
|
188
|
-
.backgroundImagePosition(style.backgroundPosition)
|
|
189
|
-
.borderStyle({
|
|
190
|
-
top: style.borderTopStyle,
|
|
191
|
-
right: style.borderRightStyle,
|
|
192
|
-
bottom: style.borderBottomStyle,
|
|
193
|
-
left: style.borderLeftStyle
|
|
194
|
-
})
|
|
195
|
-
.borderWidth({
|
|
196
|
-
top: style.borderTopWidth,
|
|
197
|
-
right: style.borderRightWidth,
|
|
198
|
-
bottom: style.borderBottomWidth,
|
|
199
|
-
left: style.borderLeftWidth
|
|
200
|
-
})
|
|
201
|
-
.borderColor({
|
|
202
|
-
top: style.borderTopColor,
|
|
203
|
-
right: style.borderRightColor,
|
|
204
|
-
bottom: style.borderBottomColor,
|
|
205
|
-
left: style.borderLeftColor
|
|
206
|
-
})
|
|
207
|
-
.borderRadius({
|
|
208
|
-
topLeft: style.borderTopLeftRadius,
|
|
209
|
-
topRight: style.borderTopRightRadius,
|
|
210
|
-
bottomLeft: style.borderBottomLeftRadius,
|
|
211
|
-
bottomRight: style.borderBottomRightRadius
|
|
212
|
-
})
|
|
213
|
-
.zIndex(style.zIndex)
|
|
214
|
-
.opacity(style.opacity)
|
|
215
|
-
.linearGradient(style.linearGradient)
|
|
216
|
-
.clip(style.overflow)
|
|
217
|
-
.rotate({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y, angle: 0 })
|
|
218
|
-
.scale({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y })
|
|
219
|
-
.transform(style.transform)
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
@Extend(Row)
|
|
223
|
-
function checkboxGroupRowAttrs (style: TaroStyleType) {
|
|
224
|
-
.id(style.id)
|
|
225
|
-
.key(style.id)
|
|
226
|
-
.flexGrow(style.flexGrow)
|
|
227
|
-
.flexShrink(style.flexShrink)
|
|
228
|
-
.flexBasis(style.flexBasis)
|
|
229
|
-
.alignSelf(style.alignSelf)
|
|
230
|
-
.padding({
|
|
231
|
-
top: style.paddingTop,
|
|
232
|
-
right: style.paddingRight,
|
|
233
|
-
bottom: style.paddingBottom,
|
|
234
|
-
left: style.paddingLeft
|
|
235
|
-
})
|
|
236
|
-
.margin({
|
|
237
|
-
top: style.marginTop,
|
|
238
|
-
right: style.marginRight,
|
|
239
|
-
bottom: style.marginBottom,
|
|
240
|
-
left: style.marginLeft
|
|
241
|
-
})
|
|
242
|
-
.width(style.width)
|
|
243
|
-
.height(style.height)
|
|
244
|
-
.constraintSize({
|
|
245
|
-
minWidth: style.minWidth,
|
|
246
|
-
maxWidth: style.maxWidth,
|
|
247
|
-
minHeight: style.minHeight,
|
|
248
|
-
maxHeight: style.maxHeight
|
|
249
|
-
})
|
|
250
|
-
.backgroundColor(style.backgroundColor)
|
|
251
|
-
.backgroundImage(style.backgroundImage?.src, style.backgroundRepeat)
|
|
252
|
-
.backgroundImageSize(style.backgroundSize)
|
|
253
|
-
.backgroundImagePosition(style.backgroundPosition)
|
|
254
|
-
.borderStyle({
|
|
255
|
-
top: style.borderTopStyle,
|
|
256
|
-
right: style.borderRightStyle,
|
|
257
|
-
bottom: style.borderBottomStyle,
|
|
258
|
-
left: style.borderLeftStyle
|
|
259
|
-
})
|
|
260
|
-
.borderWidth({
|
|
261
|
-
top: style.borderTopWidth,
|
|
262
|
-
right: style.borderRightWidth,
|
|
263
|
-
bottom: style.borderBottomWidth,
|
|
264
|
-
left: style.borderLeftWidth
|
|
265
|
-
})
|
|
266
|
-
.borderColor({
|
|
267
|
-
top: style.borderTopColor,
|
|
268
|
-
right: style.borderRightColor,
|
|
269
|
-
bottom: style.borderBottomColor,
|
|
270
|
-
left: style.borderLeftColor
|
|
271
|
-
})
|
|
272
|
-
.borderRadius({
|
|
273
|
-
topLeft: style.borderTopLeftRadius,
|
|
274
|
-
topRight: style.borderTopRightRadius,
|
|
275
|
-
bottomLeft: style.borderBottomLeftRadius,
|
|
276
|
-
bottomRight: style.borderBottomRightRadius
|
|
277
|
-
})
|
|
278
|
-
.zIndex(style.zIndex)
|
|
279
|
-
.opacity(style.opacity)
|
|
280
|
-
.linearGradient(style.linearGradient)
|
|
281
|
-
.clip(style.overflow)
|
|
282
|
-
.rotate({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y, angle: 0 })
|
|
283
|
-
.scale({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y })
|
|
284
|
-
.transform(style.transform)
|
|
285
|
-
}
|
|
286
|
-
|
|
287
99
|
interface ChangeEventDetail { value: string[] }
|
|
288
100
|
|
|
289
101
|
@Component
|
|
290
102
|
export struct TaroCheckboxGroup {
|
|
291
|
-
|
|
103
|
+
@Builder customBuilder() {}
|
|
104
|
+
@BuilderParam createLazyChildren: (node: TaroCheckboxGroupElement, layer?: number) => void = this.customBuilder
|
|
105
|
+
@ObjectLink node: TaroCheckboxGroupElement
|
|
106
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
292
107
|
|
|
293
108
|
@Styles visibleChangeEvent () {
|
|
294
109
|
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
@@ -296,6 +111,7 @@ export struct TaroCheckboxGroup {
|
|
|
296
111
|
|
|
297
112
|
aboutToAppear () {
|
|
298
113
|
if (this.node) {
|
|
114
|
+
this.node._instance = this
|
|
299
115
|
// 阻止事件冒泡传递上去
|
|
300
116
|
this.node.addEventListener('change', (e: TaroEvent<ChangeEventDetail>) => {
|
|
301
117
|
e.stopPropagation()
|
|
@@ -305,7 +121,7 @@ export struct TaroCheckboxGroup {
|
|
|
305
121
|
}
|
|
306
122
|
|
|
307
123
|
@Styles defaultEvent () {
|
|
308
|
-
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
124
|
+
.onClick(shouldBindEvent((e: ClickEvent) => { eventHandler(e, 'click', this.node) }, this.node, ['click']))
|
|
309
125
|
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
310
126
|
if (this.node) {
|
|
311
127
|
this.node._nodeInfo.areaInfo = res[1]
|
|
@@ -314,26 +130,27 @@ export struct TaroCheckboxGroup {
|
|
|
314
130
|
}
|
|
315
131
|
|
|
316
132
|
build() {
|
|
317
|
-
if (this.node) {
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
.
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
.
|
|
334
|
-
.alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)
|
|
335
|
-
.justifyContent(FlexManager.flexOptions(this.node).justifyContent)
|
|
133
|
+
if (FlexManager.useFlexLayout(this.node)) {
|
|
134
|
+
Flex(FlexManager.flexOptions(this.node)) {
|
|
135
|
+
this.createLazyChildren(this.node, 0)
|
|
136
|
+
}
|
|
137
|
+
.attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
138
|
+
.defaultEvent()
|
|
139
|
+
.visibleChangeEvent()
|
|
140
|
+
} else if (FlexManager.isFlexNode(this.node) && FlexManager.direction(this.node) !== FlexDirection.Column) {
|
|
141
|
+
Row() {
|
|
142
|
+
this.createLazyChildren(this.node, 0)
|
|
143
|
+
}
|
|
144
|
+
.attributeModifier(rowModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
145
|
+
.defaultEvent()
|
|
146
|
+
.visibleChangeEvent()
|
|
147
|
+
} else {
|
|
148
|
+
Column() {
|
|
149
|
+
this.createLazyChildren(this.node, 0)
|
|
336
150
|
}
|
|
151
|
+
.attributeModifier(columnModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
152
|
+
.defaultEvent()
|
|
153
|
+
.visibleChangeEvent()
|
|
337
154
|
}
|
|
338
155
|
}
|
|
339
156
|
}
|
|
@@ -1,169 +1,62 @@
|
|
|
1
1
|
import { AREA_CHANGE_EVENT_NAME, eventHandler, getComponentEventCallback, VISIBLE_CHANGE_EVENT_NAME } from '@tarojs/runtime'
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import commonStyleModify, { rowModify, columnModify } from './style'
|
|
4
|
+
|
|
4
5
|
import { TOUCH_EVENT_MAP } from './utils/constant/event'
|
|
5
|
-
import { FlexManager } from './utils/
|
|
6
|
-
import {
|
|
6
|
+
import { FlexManager } from './utils/flexManager'
|
|
7
|
+
import { shouldBindEvent, getNodeThresholds } from './utils/helper'
|
|
7
8
|
|
|
8
|
-
import type { TaroAny, TaroFormElement
|
|
9
|
+
import type { TaroAny, TaroFormElement } from '@tarojs/runtime'
|
|
10
|
+
import { isUndefined } from '@tarojs/shared'
|
|
9
11
|
|
|
10
|
-
@
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
.flexShrink(style.flexShrink)
|
|
16
|
-
.flexBasis(style.flexBasis)
|
|
17
|
-
.alignSelf(style.alignSelf)
|
|
18
|
-
.padding({
|
|
19
|
-
top: style.paddingTop,
|
|
20
|
-
right: style.paddingRight,
|
|
21
|
-
bottom: style.paddingBottom,
|
|
22
|
-
left: style.paddingLeft
|
|
23
|
-
})
|
|
24
|
-
.margin({
|
|
25
|
-
top: style.marginTop,
|
|
26
|
-
right: style.marginRight,
|
|
27
|
-
bottom: style.marginBottom,
|
|
28
|
-
left: style.marginLeft
|
|
29
|
-
})
|
|
30
|
-
.width(style.width)
|
|
31
|
-
.height(style.height)
|
|
32
|
-
.constraintSize({
|
|
33
|
-
minWidth: style.minWidth,
|
|
34
|
-
maxWidth: style.maxWidth,
|
|
35
|
-
minHeight: style.minHeight,
|
|
36
|
-
maxHeight: style.maxHeight
|
|
37
|
-
})
|
|
38
|
-
.backgroundColor(style.backgroundColor)
|
|
39
|
-
.backgroundImage(style.backgroundImage?.src, style.backgroundRepeat)
|
|
40
|
-
.backgroundImageSize(style.backgroundSize)
|
|
41
|
-
.backgroundImagePosition(style.backgroundPosition)
|
|
42
|
-
.borderStyle({
|
|
43
|
-
top: style.borderTopStyle,
|
|
44
|
-
right: style.borderRightStyle,
|
|
45
|
-
bottom: style.borderBottomStyle,
|
|
46
|
-
left: style.borderLeftStyle
|
|
47
|
-
})
|
|
48
|
-
.borderWidth({
|
|
49
|
-
top: style.borderTopWidth,
|
|
50
|
-
right: style.borderRightWidth,
|
|
51
|
-
bottom: style.borderBottomWidth,
|
|
52
|
-
left: style.borderLeftWidth
|
|
53
|
-
})
|
|
54
|
-
.borderColor({
|
|
55
|
-
top: style.borderTopColor,
|
|
56
|
-
right: style.borderRightColor,
|
|
57
|
-
bottom: style.borderBottomColor,
|
|
58
|
-
left: style.borderLeftColor
|
|
59
|
-
})
|
|
60
|
-
.borderRadius({
|
|
61
|
-
topLeft: style.borderTopLeftRadius,
|
|
62
|
-
topRight: style.borderTopRightRadius,
|
|
63
|
-
bottomLeft: style.borderBottomLeftRadius,
|
|
64
|
-
bottomRight: style.borderBottomRightRadius
|
|
65
|
-
})
|
|
66
|
-
.zIndex(style.zIndex)
|
|
67
|
-
.opacity(style.opacity)
|
|
68
|
-
.linearGradient(style.linearGradient)
|
|
69
|
-
.clip(style.overflow)
|
|
70
|
-
.rotate({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y, angle: 0 })
|
|
71
|
-
.scale({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y })
|
|
72
|
-
.transform(style.transform)
|
|
73
|
-
}
|
|
12
|
+
@Component
|
|
13
|
+
export default struct TaroForm {
|
|
14
|
+
@Builder customBuilder() {}
|
|
15
|
+
@BuilderParam createLazyChildren: (node: TaroFormElement, layer?: number) => void = this.customBuilder
|
|
16
|
+
@ObjectLink node: TaroFormElement
|
|
74
17
|
|
|
75
|
-
@
|
|
76
|
-
function columnAttrs (style: TaroStyleType) {
|
|
77
|
-
.id(style.id)
|
|
78
|
-
.key(style.id)
|
|
79
|
-
.flexGrow(style.flexGrow)
|
|
80
|
-
.flexShrink(style.flexShrink)
|
|
81
|
-
.flexBasis(style.flexBasis)
|
|
82
|
-
.alignSelf(style.alignSelf)
|
|
83
|
-
.padding({
|
|
84
|
-
top: style.paddingTop,
|
|
85
|
-
right: style.paddingRight,
|
|
86
|
-
bottom: style.paddingBottom,
|
|
87
|
-
left: style.paddingLeft
|
|
88
|
-
})
|
|
89
|
-
.margin({
|
|
90
|
-
top: style.marginTop,
|
|
91
|
-
right: style.marginRight,
|
|
92
|
-
bottom: style.marginBottom,
|
|
93
|
-
left: style.marginLeft
|
|
94
|
-
})
|
|
95
|
-
.width(style.width)
|
|
96
|
-
.height(style.height)
|
|
97
|
-
.constraintSize({
|
|
98
|
-
minWidth: style.minWidth,
|
|
99
|
-
maxWidth: style.maxWidth,
|
|
100
|
-
minHeight: style.minHeight,
|
|
101
|
-
maxHeight: style.maxHeight
|
|
102
|
-
})
|
|
103
|
-
.backgroundColor(style.backgroundColor)
|
|
104
|
-
.backgroundImage(style.backgroundImage?.src, style.backgroundRepeat)
|
|
105
|
-
.backgroundImageSize(style.backgroundSize)
|
|
106
|
-
.backgroundImagePosition(style.backgroundPosition)
|
|
107
|
-
.borderStyle({
|
|
108
|
-
top: style.borderTopStyle,
|
|
109
|
-
right: style.borderRightStyle,
|
|
110
|
-
bottom: style.borderBottomStyle,
|
|
111
|
-
left: style.borderLeftStyle
|
|
112
|
-
})
|
|
113
|
-
.borderWidth({
|
|
114
|
-
top: style.borderTopWidth,
|
|
115
|
-
right: style.borderRightWidth,
|
|
116
|
-
bottom: style.borderBottomWidth,
|
|
117
|
-
left: style.borderLeftWidth
|
|
118
|
-
})
|
|
119
|
-
.borderColor({
|
|
120
|
-
top: style.borderTopColor,
|
|
121
|
-
right: style.borderRightColor,
|
|
122
|
-
bottom: style.borderBottomColor,
|
|
123
|
-
left: style.borderLeftColor
|
|
124
|
-
})
|
|
125
|
-
.borderRadius({
|
|
126
|
-
topLeft: style.borderTopLeftRadius,
|
|
127
|
-
topRight: style.borderTopRightRadius,
|
|
128
|
-
bottomLeft: style.borderBottomLeftRadius,
|
|
129
|
-
bottomRight: style.borderBottomRightRadius
|
|
130
|
-
})
|
|
131
|
-
.zIndex(style.zIndex)
|
|
132
|
-
.opacity(style.opacity)
|
|
133
|
-
.linearGradient(style.linearGradient)
|
|
134
|
-
.clip(style.overflow)
|
|
135
|
-
.rotate({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y, angle: 0 })
|
|
136
|
-
.scale({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y })
|
|
137
|
-
.transform(style.transform)
|
|
138
|
-
}
|
|
18
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
139
19
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
Row() {
|
|
144
|
-
createLazyChildren(node)
|
|
20
|
+
aboutToAppear(): void {
|
|
21
|
+
if (this.node) {
|
|
22
|
+
this.node._instance = this
|
|
145
23
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
.
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
build() {
|
|
27
|
+
if (FlexManager.useFlexLayout(this.node)) {
|
|
28
|
+
Flex(FlexManager.flexOptions(this.node)) {
|
|
29
|
+
this.createLazyChildren(this.node, 0)
|
|
30
|
+
}
|
|
31
|
+
.attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
32
|
+
.onClick(shouldBindEvent((e: ClickEvent) => { eventHandler(e, 'click', this.node) }, this.node, ['click']))
|
|
33
|
+
.onTouch(shouldBindEvent((e: TouchEvent) => { eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node) }, this.node, TOUCH_EVENT_MAP.values()))
|
|
34
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
35
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
36
|
+
}))
|
|
37
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
38
|
+
} else if (FlexManager.isFlexNode(this.node) && FlexManager.direction(this.node) !== FlexDirection.Column) {
|
|
39
|
+
Row() {
|
|
40
|
+
this.createLazyChildren(this.node, 0)
|
|
41
|
+
}
|
|
42
|
+
.attributeModifier(rowModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
43
|
+
.onClick(shouldBindEvent((e: ClickEvent) => { eventHandler(e, 'click', this.node) }, this.node, ['click']))
|
|
44
|
+
.onTouch(shouldBindEvent((e: TouchEvent) => { eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node) }, this.node, TOUCH_EVENT_MAP.values()))
|
|
45
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
46
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
47
|
+
}))
|
|
48
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
49
|
+
} else {
|
|
50
|
+
Column() {
|
|
51
|
+
this.createLazyChildren(this.node, 0)
|
|
52
|
+
}
|
|
53
|
+
.attributeModifier(columnModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
54
|
+
.onClick(shouldBindEvent((e: ClickEvent) => { eventHandler(e, 'click', this.node) }, this.node, ['click']))
|
|
55
|
+
.onTouch(shouldBindEvent((e: TouchEvent) => { eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node) }, this.node, TOUCH_EVENT_MAP.values()))
|
|
56
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
57
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
58
|
+
}))
|
|
59
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
158
60
|
}
|
|
159
|
-
.columnAttrs(getNormalAttributes(node))
|
|
160
|
-
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', node), node, ['click']))
|
|
161
|
-
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), node), node, TOUCH_EVENT_MAP.values()))
|
|
162
|
-
.onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
163
|
-
node._nodeInfo.areaInfo = res[1]
|
|
164
|
-
}))
|
|
165
|
-
.onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
|
|
166
|
-
.alignItems(FlexManager.flexOptions(node).alignItems as HorizontalAlign)
|
|
167
|
-
.justifyContent(FlexManager.flexOptions(node).justifyContent)
|
|
168
61
|
}
|
|
169
62
|
}
|