@tarojs/plugin-platform-harmony-ets 4.0.0-alpha.0 → 4.0.0-alpha.2
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/device/memory.ts +10 -3
- package/dist/apis/index.ts +2 -0
- package/dist/apis/media/video/VideoContext.ts +56 -7
- package/dist/apis/media/video/index.ts +3 -2
- package/dist/apis/network/request.ts +5 -5
- package/dist/apis/route/index.ts +15 -0
- package/dist/apis/wxml/index.ts +2 -0
- package/dist/components-harmony-ets/button.ets +26 -40
- package/dist/components-harmony-ets/checkbox.ets +70 -99
- package/dist/components-harmony-ets/form.ets +29 -42
- package/dist/components-harmony-ets/icon.ets +6 -34
- package/dist/components-harmony-ets/image.ets +2 -32
- package/dist/components-harmony-ets/innerHtml.ets +2 -2
- package/dist/components-harmony-ets/input.ets +7 -27
- package/dist/components-harmony-ets/label.ets +40 -47
- package/dist/components-harmony-ets/picker.ets +66 -73
- package/dist/components-harmony-ets/radio.ets +72 -101
- package/dist/components-harmony-ets/richText.ets +4 -36
- package/dist/components-harmony-ets/scrollView.ets +34 -74
- package/dist/components-harmony-ets/slider.ets +9 -34
- package/dist/components-harmony-ets/style.ets +154 -0
- package/dist/components-harmony-ets/swiper.ets +4 -34
- package/dist/components-harmony-ets/switch.ets +43 -56
- package/dist/components-harmony-ets/text.ets +7 -34
- package/dist/components-harmony-ets/textArea.ets +8 -28
- package/dist/components-harmony-ets/utils/DynamicCenter.ts +2 -11
- package/dist/components-harmony-ets/utils/flexManager.ets +45 -7
- package/dist/components-harmony-ets/utils/helper.ets +2 -2
- package/dist/components-harmony-ets/utils/styles.ets +58 -20
- package/dist/components-harmony-ets/video.ets +4 -34
- package/dist/components-harmony-ets/view.ets +25 -67
- package/dist/components-harmony-ets/webView.ets +50 -0
- package/dist/index.js +103 -5
- package/dist/index.js.map +1 -1
- package/dist/runtime-ets/bom/window.ts +2 -2
- package/dist/runtime-ets/dom/cssStyleDeclaration.ts +30 -6
- package/dist/runtime-ets/dom/document.ts +21 -4
- package/dist/runtime-ets/dom/element/element.ts +1 -0
- package/dist/runtime-ets/dom/element/form.ts +11 -2
- package/dist/runtime-ets/dom/element/index.ts +4 -1
- package/dist/runtime-ets/dom/element/normal.ts +1 -0
- package/dist/runtime-ets/dom/element/webView.ts +61 -0
- package/dist/runtime-ets/dom/node.ts +29 -16
- package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +624 -0
- package/dist/runtime-ets/dom/stylesheet/index.ts +216 -354
- package/dist/runtime-ets/dom/stylesheet/type.ts +46 -11
- package/dist/runtime-ets/dom/stylesheet/util.ts +58 -6
- package/dist/runtime-ets/index.ts +1 -2
- package/dist/runtime-ets/interface/event.ts +2 -1
- package/dist/runtime-ets/utils/index.ts +6 -1
- package/dist/runtime-ets/utils/info.ts +3 -1
- package/dist/runtime-framework/react/app.ts +12 -22
- package/dist/runtime-framework/react/hooks.ts +3 -3
- package/dist/runtime-framework/react/index.ts +1 -0
- package/dist/runtime-framework/react/native-page.ts +344 -0
- package/dist/runtime-framework/react/page.ts +2 -2
- package/dist/runtime-framework/solid/hooks.ts +3 -3
- package/dist/runtime-utils.js +76 -20
- package/dist/runtime-utils.js.map +1 -1
- package/dist/runtime.js +76 -20
- package/dist/runtime.js.map +1 -1
- package/package.json +12 -11
- package/static/media/cancel.svg +1 -0
- package/static/media/circle.svg +1 -0
- package/static/media/clear.svg +1 -0
- package/static/media/download.svg +1 -0
- package/static/media/info.svg +1 -0
- package/static/media/info_circle.svg +1 -0
- package/static/media/search.svg +1 -0
- package/static/media/success.svg +1 -0
- package/static/media/success_no_circle.svg +1 -0
- package/static/media/taro_arrow_left.svg +1 -0
- package/static/media/taro_home.svg +1 -0
- package/static/media/waiting.svg +1 -0
- package/static/media/warn.svg +1 -0
- package/types/runtime.d.ts +2 -0
- package/dist/runtime-ets/utils/bind.ts +0 -24
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import htmlParser from './utils/htmlParser'
|
|
2
|
-
import {
|
|
2
|
+
import { createChildItem } from './render'
|
|
3
3
|
|
|
4
4
|
import type { TaroElement } from '@tarojs/runtime'
|
|
5
5
|
|
|
6
6
|
@Builder
|
|
7
7
|
export default function TaroInnerHtml (node: TaroElement) {
|
|
8
8
|
if (node.innerHTML) {
|
|
9
|
-
|
|
9
|
+
createChildItem(htmlParser(node.innerHTML))
|
|
10
10
|
}
|
|
11
11
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, createTaroEvent } from '@tarojs/runtime'
|
|
2
2
|
|
|
3
|
+
import commonStyleModify from './style'
|
|
3
4
|
import { getNormalAttributes, parseStyles, shouldBindEvent, getNodeThresholds } from './utils/helper'
|
|
4
5
|
import { INPUT_TYPE_MAP, INPUT_CONFIRM_MAP } from './utils/constant/style'
|
|
5
6
|
|
|
@@ -11,33 +12,6 @@ interface InputAttrs {
|
|
|
11
12
|
|
|
12
13
|
@Extend(TextInput)
|
|
13
14
|
function styles (style: TaroStyleType) {
|
|
14
|
-
.id(style.id)
|
|
15
|
-
.key(style.id)
|
|
16
|
-
.padding(style.padding)
|
|
17
|
-
.margin(style.margin)
|
|
18
|
-
.width(style.width)
|
|
19
|
-
.height(style.height)
|
|
20
|
-
.constraintSize(style.constraintSize)
|
|
21
|
-
.flexGrow(style.flexGrow)
|
|
22
|
-
.flexShrink(style.flexShrink)
|
|
23
|
-
.flexBasis(style.flexBasis)
|
|
24
|
-
.alignSelf(style.alignSelf)
|
|
25
|
-
.backgroundColor(style.backgroundColor)
|
|
26
|
-
.backgroundImage(style.backgroundImage, style.backgroundRepeat)
|
|
27
|
-
.backgroundImageSize(style.backgroundImageSize)
|
|
28
|
-
.backgroundImagePosition(style.backgroundImagePosition)
|
|
29
|
-
.rotate(style.rotate)
|
|
30
|
-
.scale(style.scale)
|
|
31
|
-
.translate(style.translate)
|
|
32
|
-
.transform(style.transform)
|
|
33
|
-
.borderStyle(style.borderStyle)
|
|
34
|
-
.borderWidth(style.borderWidth)
|
|
35
|
-
.borderColor(style.borderColor)
|
|
36
|
-
.borderRadius(style.borderRadius)
|
|
37
|
-
.linearGradient(style.linearGradient)
|
|
38
|
-
.zIndex(style.zIndex)
|
|
39
|
-
.opacity(style.opacity)
|
|
40
|
-
.clip(style.clip)
|
|
41
15
|
.fontColor(style.color)
|
|
42
16
|
.fontSize(style.fontSize)
|
|
43
17
|
.fontWeight(style.fontWeight)
|
|
@@ -80,6 +54,11 @@ export default struct TaroInput {
|
|
|
80
54
|
if (this.node) {
|
|
81
55
|
this.value = this.node.value
|
|
82
56
|
this.node._instance = this
|
|
57
|
+
|
|
58
|
+
if (!this.node._isInit) {
|
|
59
|
+
this.node._isInit = true
|
|
60
|
+
this.node._reset = this.node.value || ''
|
|
61
|
+
}
|
|
83
62
|
}
|
|
84
63
|
}
|
|
85
64
|
|
|
@@ -91,6 +70,7 @@ export default struct TaroInput {
|
|
|
91
70
|
.maxLength(Number(this.node._attrs?.maxlength) || null)
|
|
92
71
|
.placeholderColor(getPlaceholderColor(this.node))
|
|
93
72
|
.enterKeyType(INPUT_CONFIRM_MAP.get(this.node._attrs?.confirmType) || EnterKeyType.Done)
|
|
73
|
+
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
94
74
|
.styles(getNormalAttributes(this.node))
|
|
95
75
|
.attrs(getAttributes(this.node))
|
|
96
76
|
.onChange((value: string) => {
|
|
@@ -1,42 +1,12 @@
|
|
|
1
1
|
import { Current, eventHandler, getComponentEventCallback, VISIBLE_CHANGE_EVENT_NAME, getPageScrollerOrNode, AREA_CHANGE_EVENT_NAME } from '@tarojs/runtime'
|
|
2
2
|
|
|
3
|
+
import commonStyleModify from './style'
|
|
3
4
|
import { createLazyChildren } from './render'
|
|
4
5
|
import { TOUCH_EVENT_MAP } from './utils/constant/event'
|
|
5
6
|
import { FlexManager } from './utils/FlexManager'
|
|
6
7
|
import { getNormalAttributes, shouldBindEvent, getNodeThresholds } from './utils/helper'
|
|
7
8
|
|
|
8
|
-
import type {
|
|
9
|
-
|
|
10
|
-
@Extend(Flex)
|
|
11
|
-
function attrs (style: TaroStyleType) {
|
|
12
|
-
.id(style.id)
|
|
13
|
-
.key(style.id)
|
|
14
|
-
.padding(style.padding)
|
|
15
|
-
.margin(style.margin)
|
|
16
|
-
.width(style.width)
|
|
17
|
-
.height(style.height)
|
|
18
|
-
.constraintSize(style.constraintSize)
|
|
19
|
-
.flexGrow(style.flexGrow)
|
|
20
|
-
.flexShrink(style.flexShrink)
|
|
21
|
-
.flexBasis(style.flexBasis)
|
|
22
|
-
.alignSelf(style.alignSelf)
|
|
23
|
-
.backgroundColor(style.backgroundColor)
|
|
24
|
-
.backgroundImage(style.backgroundImage, style.backgroundRepeat)
|
|
25
|
-
.backgroundImageSize(style.backgroundImageSize)
|
|
26
|
-
.backgroundImagePosition(style.backgroundImagePosition)
|
|
27
|
-
.rotate(style.rotate)
|
|
28
|
-
.scale(style.scale)
|
|
29
|
-
.translate(style.translate)
|
|
30
|
-
.transform(style.transform)
|
|
31
|
-
.borderStyle(style.borderStyle)
|
|
32
|
-
.borderWidth(style.borderWidth)
|
|
33
|
-
.borderColor(style.borderColor)
|
|
34
|
-
.borderRadius(style.borderRadius)
|
|
35
|
-
.linearGradient(style.linearGradient)
|
|
36
|
-
.zIndex(style.zIndex)
|
|
37
|
-
.opacity(style.opacity)
|
|
38
|
-
.clip(style.clip)
|
|
39
|
-
}
|
|
9
|
+
import type { TaroLabelElement, TaroElement, TaroAny, TaroRadioElement, TaroCheckboxElement } from '@tarojs/runtime'
|
|
40
10
|
|
|
41
11
|
function handleTargetChange (id: string) {
|
|
42
12
|
const taro: TaroAny = Current.taro
|
|
@@ -66,20 +36,43 @@ function handleTargetChange (id: string) {
|
|
|
66
36
|
|
|
67
37
|
@Builder
|
|
68
38
|
export default function TaroLabel (node: TaroLabelElement) {
|
|
69
|
-
|
|
70
|
-
|
|
39
|
+
if (FlexManager.isFlexNode(node) && FlexManager.flexOptions(node).direction !== FlexDirection.Column) {
|
|
40
|
+
Row() {
|
|
41
|
+
createLazyChildren(node)
|
|
42
|
+
}
|
|
43
|
+
.attributeModifier(commonStyleModify.setNode(node))
|
|
44
|
+
.onClick((e: ClickEvent) => {
|
|
45
|
+
const firstChild: TaroElement | null = node.childNodes[0] as TaroElement | null
|
|
46
|
+
const id: string = node._attrs.for || firstChild?._attrs.id || firstChild?._nid || ''
|
|
47
|
+
|
|
48
|
+
handleTargetChange(id)
|
|
49
|
+
eventHandler(e, 'click', node)
|
|
50
|
+
})
|
|
51
|
+
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), node), node, TOUCH_EVENT_MAP.values()))
|
|
52
|
+
.onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
53
|
+
node._nodeInfo.areaInfo = res[1]
|
|
54
|
+
}))
|
|
55
|
+
.onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
|
|
56
|
+
.alignItems(FlexManager.flexOptions(node).alignItems as VerticalAlign)
|
|
57
|
+
.justifyContent(FlexManager.flexOptions(node).justifyContent)
|
|
58
|
+
} else {
|
|
59
|
+
Column() {
|
|
60
|
+
createLazyChildren(node)
|
|
61
|
+
}
|
|
62
|
+
.attributeModifier(commonStyleModify.setNode(node))
|
|
63
|
+
.onClick((e: ClickEvent) => {
|
|
64
|
+
const firstChild: TaroElement | null = node.childNodes[0] as TaroElement | null
|
|
65
|
+
const id: string = node._attrs.for || firstChild?._attrs.id || firstChild?._nid || ''
|
|
66
|
+
|
|
67
|
+
handleTargetChange(id)
|
|
68
|
+
eventHandler(e, 'click', node)
|
|
69
|
+
})
|
|
70
|
+
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), node), node, TOUCH_EVENT_MAP.values()))
|
|
71
|
+
.onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
72
|
+
node._nodeInfo.areaInfo = res[1]
|
|
73
|
+
}))
|
|
74
|
+
.onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
|
|
75
|
+
.alignItems(FlexManager.flexOptions(node).alignItems as HorizontalAlign)
|
|
76
|
+
.justifyContent(FlexManager.flexOptions(node).justifyContent)
|
|
71
77
|
}
|
|
72
|
-
.attrs(getNormalAttributes(node))
|
|
73
|
-
.onClick((e: ClickEvent) => {
|
|
74
|
-
const firstChild: TaroElement | null = node.childNodes[0] as TaroElement | null
|
|
75
|
-
const id: string = node._attrs.for || firstChild?._attrs.id || firstChild?._nid || ''
|
|
76
|
-
|
|
77
|
-
handleTargetChange(id)
|
|
78
|
-
eventHandler(e, 'click', node)
|
|
79
|
-
})
|
|
80
|
-
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), node), node, TOUCH_EVENT_MAP.values()))
|
|
81
|
-
.onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
82
|
-
node._nodeInfo.areaInfo = res[1]
|
|
83
|
-
}))
|
|
84
|
-
.onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
|
|
85
78
|
}
|
|
@@ -1,76 +1,15 @@
|
|
|
1
1
|
import { AREA_CHANGE_EVENT_NAME, eventHandler, getComponentEventCallback, VISIBLE_CHANGE_EVENT_NAME, TaroPickerElement, createTaroEvent } from '@tarojs/runtime'
|
|
2
2
|
import { createLazyChildren } from './render'
|
|
3
|
+
import commonStyleModify from './style'
|
|
3
4
|
import { getSingleSelector, getMultiSelector } from './utils'
|
|
4
5
|
import { TOUCH_EVENT_MAP } from './utils/constant/event'
|
|
5
6
|
import { FlexManager } from './utils/FlexManager'
|
|
6
7
|
import { getNormalAttributes, shouldBindEvent, getNodeThresholds } from './utils/helper'
|
|
7
8
|
|
|
8
|
-
import type { TaroAny,
|
|
9
|
+
import type { TaroAny, TaroEvent } from '@tarojs/runtime'
|
|
9
10
|
|
|
10
11
|
import { PickerDateProps, PickerMultiSelectorProps, PickerSelectorProps, PickerTimeProps } from './types'
|
|
11
12
|
|
|
12
|
-
@Extend(TextPicker)
|
|
13
|
-
function textPickerAttrs (style: TaroStyleType) {
|
|
14
|
-
.id(style.id)
|
|
15
|
-
.key(style.id)
|
|
16
|
-
.padding(style.padding)
|
|
17
|
-
.margin(style.margin)
|
|
18
|
-
.width(style.width || '100%')
|
|
19
|
-
.height(style.height)
|
|
20
|
-
.constraintSize(style.constraintSize)
|
|
21
|
-
.flexGrow(style.flexGrow)
|
|
22
|
-
.flexShrink(style.flexShrink)
|
|
23
|
-
.flexBasis(style.flexBasis)
|
|
24
|
-
.alignSelf(style.alignSelf)
|
|
25
|
-
.backgroundColor(style.backgroundColor || '#fff')
|
|
26
|
-
.backgroundImage(style.backgroundImage, style.backgroundRepeat)
|
|
27
|
-
.backgroundImageSize(style.backgroundImageSize)
|
|
28
|
-
.backgroundImagePosition(style.backgroundImagePosition)
|
|
29
|
-
.rotate(style.rotate)
|
|
30
|
-
.scale(style.scale)
|
|
31
|
-
.translate(style.translate)
|
|
32
|
-
.transform(style.transform)
|
|
33
|
-
.borderStyle(style.borderStyle)
|
|
34
|
-
.borderWidth(style.borderWidth)
|
|
35
|
-
.borderColor(style.borderColor)
|
|
36
|
-
.borderRadius(style.borderRadius)
|
|
37
|
-
.linearGradient(style.linearGradient)
|
|
38
|
-
.zIndex(style.zIndex)
|
|
39
|
-
.opacity(style.opacity)
|
|
40
|
-
.clip(style.clip)
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
@Extend(DatePicker)
|
|
44
|
-
function datePickerAttrs (style: TaroStyleType) {
|
|
45
|
-
.id(style.id)
|
|
46
|
-
.key(style.id)
|
|
47
|
-
.padding(style.padding)
|
|
48
|
-
.margin(style.margin)
|
|
49
|
-
.width(style.width || '100%')
|
|
50
|
-
.height(style.height)
|
|
51
|
-
.constraintSize(style.constraintSize)
|
|
52
|
-
.flexGrow(style.flexGrow)
|
|
53
|
-
.flexShrink(style.flexShrink)
|
|
54
|
-
.flexBasis(style.flexBasis)
|
|
55
|
-
.alignSelf(style.alignSelf)
|
|
56
|
-
.backgroundColor(style.backgroundColor || '#fff')
|
|
57
|
-
.backgroundImage(style.backgroundImage, style.backgroundRepeat)
|
|
58
|
-
.backgroundImageSize(style.backgroundImageSize)
|
|
59
|
-
.backgroundImagePosition(style.backgroundImagePosition)
|
|
60
|
-
.rotate(style.rotate)
|
|
61
|
-
.scale(style.scale)
|
|
62
|
-
.translate(style.translate)
|
|
63
|
-
.transform(style.transform)
|
|
64
|
-
.borderStyle(style.borderStyle)
|
|
65
|
-
.borderWidth(style.borderWidth)
|
|
66
|
-
.borderColor(style.borderColor)
|
|
67
|
-
.borderRadius(style.borderRadius)
|
|
68
|
-
.linearGradient(style.linearGradient)
|
|
69
|
-
.zIndex(style.zIndex)
|
|
70
|
-
.opacity(style.opacity)
|
|
71
|
-
.clip(style.clip)
|
|
72
|
-
}
|
|
73
|
-
|
|
74
13
|
interface TimeRange {
|
|
75
14
|
startHH: number
|
|
76
15
|
startMM: number
|
|
@@ -129,7 +68,7 @@ export struct PickerView {
|
|
|
129
68
|
const left = generateNumberArray(timeRange.startHH, timeRange.endHH)
|
|
130
69
|
const right = generateNumberArray(timeRange.startMM, timeRange.endMM)
|
|
131
70
|
const range = [left, right]
|
|
132
|
-
const _selected = _attrs.value
|
|
71
|
+
const _selected = _attrs.value?.split(':') as string[]
|
|
133
72
|
return {
|
|
134
73
|
range: range,
|
|
135
74
|
selected: [left.findIndex(i => parseInt(_selected[0]) === Number(i)), right.findIndex(i => parseInt(_selected[1]) === Number(i))],
|
|
@@ -191,7 +130,7 @@ export struct PickerView {
|
|
|
191
130
|
this.controller?.close()
|
|
192
131
|
})
|
|
193
132
|
Text(this.getText()[0]).fontSize(15).padding({top: 20, bottom: 40}).fontColor('#1aad19').onClick(() => {
|
|
194
|
-
this.emitEvent('change', { value: this.node?.value})
|
|
133
|
+
this.emitEvent('change', { value: this.node?.value })
|
|
195
134
|
this.controller?.close()
|
|
196
135
|
})
|
|
197
136
|
}
|
|
@@ -207,7 +146,9 @@ export struct PickerView {
|
|
|
207
146
|
color: '#000'
|
|
208
147
|
})
|
|
209
148
|
.canLoop(false)
|
|
210
|
-
.
|
|
149
|
+
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
150
|
+
.width(getNormalAttributes(this.node).width || '100%')
|
|
151
|
+
.backgroundColor(getNormalAttributes(this.node).backgroundColor || '#fff')
|
|
211
152
|
.onChange((_, index) => {
|
|
212
153
|
this.node?.updateFormWidgetValue(index)
|
|
213
154
|
})
|
|
@@ -217,7 +158,9 @@ export struct PickerView {
|
|
|
217
158
|
color: '#000'
|
|
218
159
|
})
|
|
219
160
|
.canLoop(false)
|
|
220
|
-
.
|
|
161
|
+
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
162
|
+
.width(getNormalAttributes(this.node).width || '100%')
|
|
163
|
+
.backgroundColor(getNormalAttributes(this.node).backgroundColor || '#fff')
|
|
221
164
|
.onChange((_, index) => {
|
|
222
165
|
if (index instanceof Array) {
|
|
223
166
|
this.node?.updateFormWidgetValue(index)
|
|
@@ -244,7 +187,9 @@ export struct PickerView {
|
|
|
244
187
|
.selectedTextStyle({
|
|
245
188
|
color: '#000'
|
|
246
189
|
})
|
|
247
|
-
.
|
|
190
|
+
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
191
|
+
.width(getNormalAttributes(this.node).width || '100%')
|
|
192
|
+
.backgroundColor(getNormalAttributes(this.node).backgroundColor || '#fff')
|
|
248
193
|
.onDateChange(value => {
|
|
249
194
|
const data = value.toLocaleDateString().split('/')
|
|
250
195
|
const day = data[1]
|
|
@@ -258,7 +203,9 @@ export struct PickerView {
|
|
|
258
203
|
color: '#000'
|
|
259
204
|
})
|
|
260
205
|
.canLoop(false)
|
|
261
|
-
.
|
|
206
|
+
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
207
|
+
.width(getNormalAttributes(this.node).width || '100%')
|
|
208
|
+
.backgroundColor(getNormalAttributes(this.node).backgroundColor || '#fff')
|
|
262
209
|
.onChange((value) => {
|
|
263
210
|
this.node?.updateFormWidgetValue(`${('00'+value[0]).slice(-2)}:${('00'+value[1]).slice(-2)}`)
|
|
264
211
|
})
|
|
@@ -278,6 +225,40 @@ export default struct TaroPicker {
|
|
|
278
225
|
|
|
279
226
|
aboutToAppear () {
|
|
280
227
|
this.node?.addEventListener('click', this.handleClick)
|
|
228
|
+
|
|
229
|
+
if (this.node && !this.node._isInit) {
|
|
230
|
+
let defaultResetValue: TaroAny = ''
|
|
231
|
+
switch (this.node._attrs.mode) {
|
|
232
|
+
case 'selector':
|
|
233
|
+
defaultResetValue = 0
|
|
234
|
+
break
|
|
235
|
+
case 'multiSelector':
|
|
236
|
+
defaultResetValue = this.node._attrs.range.map((_: TaroAny) => 0)
|
|
237
|
+
break
|
|
238
|
+
case 'time': {
|
|
239
|
+
const hour = new Date().getHours()
|
|
240
|
+
const minute = new Date().getMinutes()
|
|
241
|
+
|
|
242
|
+
defaultResetValue = `${('00'+hour).slice(-2)}:${('00'+minute).slice(-2)}`
|
|
243
|
+
break
|
|
244
|
+
}
|
|
245
|
+
case 'date': {
|
|
246
|
+
const data = new Date().toLocaleDateString().split('/')
|
|
247
|
+
const day = data[1]
|
|
248
|
+
const month = data[0]
|
|
249
|
+
const year = data[2]
|
|
250
|
+
|
|
251
|
+
defaultResetValue = `${year}-${month}-${day}`
|
|
252
|
+
break
|
|
253
|
+
}
|
|
254
|
+
default:
|
|
255
|
+
defaultResetValue = ''
|
|
256
|
+
break
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
this.node._isInit = true
|
|
260
|
+
this.node._reset = this.node.value || defaultResetValue
|
|
261
|
+
}
|
|
281
262
|
}
|
|
282
263
|
|
|
283
264
|
dialogController: CustomDialogController | null = null
|
|
@@ -325,11 +306,23 @@ export default struct TaroPicker {
|
|
|
325
306
|
|
|
326
307
|
build() {
|
|
327
308
|
if (this.node) {
|
|
328
|
-
|
|
329
|
-
|
|
309
|
+
if (FlexManager.isFlexNode(this.node) && FlexManager.flexOptions(this.node).direction !== FlexDirection.Column) {
|
|
310
|
+
Row() {
|
|
311
|
+
createLazyChildren(this.node)
|
|
312
|
+
}
|
|
313
|
+
.defaultEvent()
|
|
314
|
+
.visibleChangeEvent()
|
|
315
|
+
.alignItems(FlexManager.flexOptions(this.node).alignItems as VerticalAlign)
|
|
316
|
+
.justifyContent(FlexManager.flexOptions(this.node).justifyContent)
|
|
317
|
+
} else {
|
|
318
|
+
Column() {
|
|
319
|
+
createLazyChildren(this.node)
|
|
320
|
+
}
|
|
321
|
+
.defaultEvent()
|
|
322
|
+
.visibleChangeEvent()
|
|
323
|
+
.alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)
|
|
324
|
+
.justifyContent(FlexManager.flexOptions(this.node).justifyContent)
|
|
330
325
|
}
|
|
331
|
-
.defaultEvent()
|
|
332
|
-
.visibleChangeEvent()
|
|
333
326
|
}
|
|
334
327
|
}
|
|
335
328
|
}
|
|
@@ -1,48 +1,18 @@
|
|
|
1
1
|
import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, createTaroEvent } from '@tarojs/runtime'
|
|
2
2
|
|
|
3
|
+
import commonStyleModify from './style'
|
|
3
4
|
import { createLazyChildren } from './render'
|
|
4
5
|
import { TOUCH_EVENT_MAP } from './utils/constant/event'
|
|
5
6
|
import { FlexManager } from './utils/FlexManager'
|
|
6
|
-
import { shouldBindEvent,
|
|
7
|
+
import { shouldBindEvent, getNodeThresholds } from './utils/helper'
|
|
7
8
|
|
|
8
|
-
import
|
|
9
|
+
import { TaroEvent, TaroAny, HarmonyType, TaroRadioGroupElement, TaroRadioElement } from '@tarojs/runtime'
|
|
9
10
|
|
|
10
11
|
interface RadioAttrs {
|
|
11
12
|
radioStyle?: HarmonyType.RadioStyle
|
|
12
13
|
themeStyles?: boolean
|
|
13
14
|
}
|
|
14
15
|
|
|
15
|
-
@Extend(Radio)
|
|
16
|
-
function style (style: TaroStyleType) {
|
|
17
|
-
.id(style.id)
|
|
18
|
-
.key(style.id)
|
|
19
|
-
.padding(style.padding)
|
|
20
|
-
.margin(style.margin)
|
|
21
|
-
.width(style.width)
|
|
22
|
-
.height(style.height)
|
|
23
|
-
.constraintSize(style.constraintSize)
|
|
24
|
-
.flexGrow(style.flexGrow)
|
|
25
|
-
.flexShrink(style.flexShrink)
|
|
26
|
-
.flexBasis(style.flexBasis)
|
|
27
|
-
.alignSelf(style.alignSelf)
|
|
28
|
-
.backgroundColor(style.backgroundColor)
|
|
29
|
-
.backgroundImage(style.backgroundImage, style.backgroundRepeat)
|
|
30
|
-
.backgroundImageSize(style.backgroundImageSize)
|
|
31
|
-
.backgroundImagePosition(style.backgroundImagePosition)
|
|
32
|
-
.rotate(style.rotate)
|
|
33
|
-
.scale(style.scale)
|
|
34
|
-
.translate(style.translate)
|
|
35
|
-
.transform(style.transform)
|
|
36
|
-
.borderStyle(style.borderStyle)
|
|
37
|
-
.borderWidth(style.borderWidth)
|
|
38
|
-
.borderColor(style.borderColor)
|
|
39
|
-
.borderRadius(style.borderRadius)
|
|
40
|
-
.linearGradient(style.linearGradient)
|
|
41
|
-
.zIndex(style.zIndex)
|
|
42
|
-
.opacity(style.opacity)
|
|
43
|
-
.clip(style.clip)
|
|
44
|
-
}
|
|
45
|
-
|
|
46
16
|
@Extend(Radio)
|
|
47
17
|
function radioAttr (attr: RadioAttrs) {
|
|
48
18
|
.radioStyle(attr.radioStyle)
|
|
@@ -63,77 +33,65 @@ function themeStyles(isDisabled: boolean) {
|
|
|
63
33
|
.opacity(isDisabled ? 0.4 : 1)
|
|
64
34
|
}
|
|
65
35
|
|
|
66
|
-
@
|
|
67
|
-
export
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
.radioAttr(getAttributes(node))
|
|
77
|
-
.onChange((value: boolean) => {
|
|
78
|
-
if (!!node?._attrs.disabled) {
|
|
79
|
-
node.updateComponent()
|
|
80
|
-
} else {
|
|
81
|
-
node.updateCheckedValue(value)
|
|
36
|
+
@Component
|
|
37
|
+
export struct TaroRadio {
|
|
38
|
+
node: TaroRadioElement | null = null
|
|
39
|
+
|
|
40
|
+
aboutToAppear () {
|
|
41
|
+
if (this.node && !this.node._isInit) {
|
|
42
|
+
this.node._isInit = true
|
|
43
|
+
this.node._reset = this.node.checked || false
|
|
44
|
+
}
|
|
45
|
+
}
|
|
82
46
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
47
|
+
build () {
|
|
48
|
+
if (this.node) {
|
|
49
|
+
Stack() {
|
|
50
|
+
Row() {
|
|
51
|
+
Radio({
|
|
52
|
+
group: this.node.group || this.node.parentNode?._nid || '',
|
|
53
|
+
value: this.node.value || '',
|
|
54
|
+
})
|
|
55
|
+
.checked(this.node.checked)
|
|
56
|
+
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
57
|
+
.radioAttr(getAttributes(this.node))
|
|
58
|
+
.onChange((value: boolean) => {
|
|
59
|
+
if (this.node) {
|
|
60
|
+
if (!!this.node?._attrs.disabled) {
|
|
61
|
+
this.node.updateComponent()
|
|
62
|
+
} else {
|
|
63
|
+
this.node.updateCheckedValue(value)
|
|
64
|
+
|
|
65
|
+
if (value) {
|
|
66
|
+
const event: TaroEvent = createTaroEvent('change', { detail: { value: this.node?._attrs.value } }, this.node)
|
|
67
|
+
eventHandler(event, 'change', this.node)
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
})
|
|
72
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
73
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
74
|
+
if (this.node) {
|
|
75
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
76
|
+
}
|
|
77
|
+
}))
|
|
78
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
79
|
+
Text(this.node.textContent)
|
|
80
|
+
.textAlign(TextAlign.Center)
|
|
81
|
+
.opacity(!!this.node?._attrs.disabled ? 0.4 : 1)
|
|
82
|
+
}
|
|
83
|
+
.onClick(() => {
|
|
84
|
+
if (this.node) {
|
|
85
|
+
if (!this.node._checked && !this.node?._attrs.disabled) {
|
|
86
|
+
this.node.checked = !this.node.checked
|
|
86
87
|
}
|
|
87
88
|
}
|
|
88
89
|
})
|
|
89
|
-
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', node), node, ['click']))
|
|
90
|
-
.onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
91
|
-
node._nodeInfo.areaInfo = res[1]
|
|
92
|
-
}))
|
|
93
|
-
.onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
|
|
94
|
-
Text(node.textContent)
|
|
95
|
-
.textAlign(TextAlign.Center)
|
|
96
|
-
.opacity(!!node?._attrs.disabled ? 0.4 : 1)
|
|
97
|
-
}
|
|
98
|
-
.onClick(() => {
|
|
99
|
-
if (!node._checked && !node?._attrs.disabled) {
|
|
100
|
-
node.checked = !node.checked
|
|
101
90
|
}
|
|
102
|
-
}
|
|
91
|
+
}
|
|
103
92
|
}
|
|
104
93
|
}
|
|
105
94
|
|
|
106
|
-
@Extend(Flex)
|
|
107
|
-
function radioGroupAttrs (style: TaroStyleType) {
|
|
108
|
-
.id(style.id)
|
|
109
|
-
.key(style.id)
|
|
110
|
-
.padding(style.padding)
|
|
111
|
-
.margin(style.margin)
|
|
112
|
-
.width(style.width)
|
|
113
|
-
.height(style.height)
|
|
114
|
-
.constraintSize(style.constraintSize)
|
|
115
|
-
.flexGrow(style.flexGrow)
|
|
116
|
-
.flexShrink(style.flexShrink)
|
|
117
|
-
.flexBasis(style.flexBasis)
|
|
118
|
-
.alignSelf(style.alignSelf)
|
|
119
|
-
.backgroundColor(style.backgroundColor)
|
|
120
|
-
.backgroundImage(style.backgroundImage, style.backgroundRepeat)
|
|
121
|
-
.backgroundImageSize(style.backgroundImageSize)
|
|
122
|
-
.backgroundImagePosition(style.backgroundImagePosition)
|
|
123
|
-
.rotate(style.rotate)
|
|
124
|
-
.scale(style.scale)
|
|
125
|
-
.translate(style.translate)
|
|
126
|
-
.transform(style.transform)
|
|
127
|
-
.borderStyle(style.borderStyle)
|
|
128
|
-
.borderWidth(style.borderWidth)
|
|
129
|
-
.borderColor(style.borderColor)
|
|
130
|
-
.borderRadius(style.borderRadius)
|
|
131
|
-
.linearGradient(style.linearGradient)
|
|
132
|
-
.zIndex(style.zIndex)
|
|
133
|
-
.opacity(style.opacity)
|
|
134
|
-
.clip(style.clip)
|
|
135
|
-
}
|
|
136
|
-
|
|
137
95
|
|
|
138
96
|
@Component
|
|
139
97
|
export struct TaroRadioGroup {
|
|
@@ -166,12 +124,25 @@ export struct TaroRadioGroup {
|
|
|
166
124
|
|
|
167
125
|
build() {
|
|
168
126
|
if (this.node) {
|
|
169
|
-
|
|
170
|
-
|
|
127
|
+
if (FlexManager.isFlexNode(this.node) && FlexManager.flexOptions(this.node).direction !== FlexDirection.Column) {
|
|
128
|
+
Row() {
|
|
129
|
+
createLazyChildren(this.node)
|
|
130
|
+
}
|
|
131
|
+
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
132
|
+
.defaultEvent()
|
|
133
|
+
.visibleChangeEvent()
|
|
134
|
+
.alignItems(FlexManager.flexOptions(this.node).alignItems as VerticalAlign)
|
|
135
|
+
.justifyContent(FlexManager.flexOptions(this.node).justifyContent)
|
|
136
|
+
} else {
|
|
137
|
+
Column() {
|
|
138
|
+
createLazyChildren(this.node)
|
|
139
|
+
}
|
|
140
|
+
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
141
|
+
.defaultEvent()
|
|
142
|
+
.visibleChangeEvent()
|
|
143
|
+
.alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)
|
|
144
|
+
.justifyContent(FlexManager.flexOptions(this.node).justifyContent)
|
|
171
145
|
}
|
|
172
|
-
.radioGroupAttrs(getNormalAttributes(this.node))
|
|
173
|
-
.defaultEvent()
|
|
174
|
-
.visibleChangeEvent()
|
|
175
146
|
}
|
|
176
147
|
}
|
|
177
148
|
}
|
|
@@ -1,42 +1,10 @@
|
|
|
1
1
|
import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME } from '@tarojs/runtime'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
import { getNodeThresholds,
|
|
3
|
+
import commonStyleModify from './style'
|
|
4
|
+
import { getNodeThresholds, shouldBindEvent } from './utils/helper'
|
|
5
5
|
|
|
6
6
|
import type { RichTextProps } from '@tarojs/components/types/RichText'
|
|
7
|
-
import type { TaroAny,
|
|
8
|
-
|
|
9
|
-
@Extend(RichText)
|
|
10
|
-
function attrs (style: TaroStyleType) {
|
|
11
|
-
.id(style.id)
|
|
12
|
-
.key(style.id)
|
|
13
|
-
.padding(style.padding)
|
|
14
|
-
.margin(style.margin)
|
|
15
|
-
.width(style.width)
|
|
16
|
-
.height(style.height)
|
|
17
|
-
.constraintSize(style.constraintSize)
|
|
18
|
-
.flexGrow(style.flexGrow)
|
|
19
|
-
.flexShrink(style.flexShrink)
|
|
20
|
-
.flexBasis(style.flexBasis)
|
|
21
|
-
.alignSelf(style.alignSelf)
|
|
22
|
-
.backgroundColor(style.backgroundColor)
|
|
23
|
-
.backgroundImage(style.backgroundImage, style.backgroundRepeat)
|
|
24
|
-
.backgroundImageSize(style.backgroundImageSize)
|
|
25
|
-
.backgroundImagePosition(style.backgroundImagePosition)
|
|
26
|
-
.rotate(style.rotate)
|
|
27
|
-
.scale(style.scale)
|
|
28
|
-
.translate(style.translate)
|
|
29
|
-
.transform(style.transform)
|
|
30
|
-
.borderStyle(style.borderStyle)
|
|
31
|
-
.borderWidth(style.borderWidth)
|
|
32
|
-
.borderColor(style.borderColor)
|
|
33
|
-
.borderRadius(style.borderRadius)
|
|
34
|
-
// .linearGradient(style.linearGradient)
|
|
35
|
-
.zIndex(style.zIndex)
|
|
36
|
-
.opacity(style.opacity)
|
|
37
|
-
.clip(style.clip)
|
|
38
|
-
}
|
|
39
|
-
|
|
7
|
+
import type { TaroAny, TaroRichTextElement } from '@tarojs/runtime'
|
|
40
8
|
|
|
41
9
|
function generateText (node: TaroRichTextElement): string {
|
|
42
10
|
return parseHtmlNode(node._attrs.nodes || '')
|
|
@@ -45,7 +13,7 @@ function generateText (node: TaroRichTextElement): string {
|
|
|
45
13
|
@Builder
|
|
46
14
|
export default function TaroRichText (node: TaroRichTextElement) {
|
|
47
15
|
RichText(generateText(node))
|
|
48
|
-
.
|
|
16
|
+
.attributeModifier(commonStyleModify.setNode(node))
|
|
49
17
|
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', node), node, ['click']))
|
|
50
18
|
.onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
51
19
|
node._nodeInfo.areaInfo = res[1]
|