@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,88 +1,26 @@
|
|
|
1
1
|
import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, createTaroEvent } from '@tarojs/runtime'
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import commonStyleModify from './style'
|
|
4
|
+
import { getNodeThresholds, shouldBindEvent } from './utils/helper'
|
|
4
5
|
|
|
5
|
-
import type { TaroAny,
|
|
6
|
+
import type { TaroAny, TaroSwitchElement, TaroEvent } from '@tarojs/runtime'
|
|
6
7
|
|
|
7
8
|
interface SwitchAttrs {
|
|
8
9
|
selectedColor?: ResourceColor
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
@Extend(Toggle)
|
|
12
|
-
function styles (style: TaroStyleType) {
|
|
13
|
-
.id(style.id)
|
|
14
|
-
.key(style.id)
|
|
15
|
-
.flexGrow(style.flexGrow)
|
|
16
|
-
.flexShrink(style.flexShrink)
|
|
17
|
-
.flexBasis(style.flexBasis)
|
|
18
|
-
.alignSelf(style.alignSelf)
|
|
19
|
-
.padding({
|
|
20
|
-
top: style.paddingTop,
|
|
21
|
-
right: style.paddingRight,
|
|
22
|
-
bottom: style.paddingBottom,
|
|
23
|
-
left: style.paddingLeft
|
|
24
|
-
})
|
|
25
|
-
.margin({
|
|
26
|
-
top: style.marginTop,
|
|
27
|
-
right: style.marginRight,
|
|
28
|
-
bottom: style.marginBottom,
|
|
29
|
-
left: style.marginLeft
|
|
30
|
-
})
|
|
31
|
-
.width(style.width)
|
|
32
|
-
.height(style.height)
|
|
33
|
-
.constraintSize({
|
|
34
|
-
minWidth: style.minWidth,
|
|
35
|
-
maxWidth: style.maxWidth,
|
|
36
|
-
minHeight: style.minHeight,
|
|
37
|
-
maxHeight: style.maxHeight
|
|
38
|
-
})
|
|
39
|
-
.backgroundColor(style.backgroundColor)
|
|
40
|
-
.backgroundImage(style.backgroundImage?.src, style.backgroundRepeat)
|
|
41
|
-
.backgroundImageSize(style.backgroundSize)
|
|
42
|
-
.backgroundImagePosition(style.backgroundPosition)
|
|
43
|
-
.borderStyle({
|
|
44
|
-
top: style.borderTopStyle,
|
|
45
|
-
right: style.borderRightStyle,
|
|
46
|
-
bottom: style.borderBottomStyle,
|
|
47
|
-
left: style.borderLeftStyle
|
|
48
|
-
})
|
|
49
|
-
.borderWidth({
|
|
50
|
-
top: style.borderTopWidth,
|
|
51
|
-
right: style.borderRightWidth,
|
|
52
|
-
bottom: style.borderBottomWidth,
|
|
53
|
-
left: style.borderLeftWidth
|
|
54
|
-
})
|
|
55
|
-
.borderColor({
|
|
56
|
-
top: style.borderTopColor,
|
|
57
|
-
right: style.borderRightColor,
|
|
58
|
-
bottom: style.borderBottomColor,
|
|
59
|
-
left: style.borderLeftColor
|
|
60
|
-
})
|
|
61
|
-
.borderRadius({
|
|
62
|
-
topLeft: style.borderTopLeftRadius,
|
|
63
|
-
topRight: style.borderTopRightRadius,
|
|
64
|
-
bottomLeft: style.borderBottomLeftRadius,
|
|
65
|
-
bottomRight: style.borderBottomRightRadius
|
|
66
|
-
})
|
|
67
|
-
.zIndex(style.zIndex)
|
|
68
|
-
.opacity(style.opacity)
|
|
69
|
-
.linearGradient(style.linearGradient)
|
|
70
|
-
.clip(style.overflow)
|
|
71
|
-
.rotate({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y, angle: 0 })
|
|
72
|
-
.scale({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y })
|
|
73
|
-
.transform(style.transform)
|
|
10
|
+
disabled?: boolean
|
|
74
11
|
}
|
|
75
12
|
|
|
76
13
|
@Extend(Toggle)
|
|
77
14
|
function attrs(attr: SwitchAttrs) {
|
|
78
15
|
.selectedColor(attr.selectedColor)
|
|
16
|
+
.enabled(!attr.disabled)
|
|
79
17
|
}
|
|
80
18
|
|
|
81
19
|
function getAttributes (node: TaroSwitchElement): SwitchAttrs {
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
return
|
|
20
|
+
const attr: SwitchAttrs = {}
|
|
21
|
+
attr.selectedColor = node._attrs.color || '#04BE02'
|
|
22
|
+
attr.disabled = !!node._attrs.disabled
|
|
23
|
+
return attr
|
|
86
24
|
}
|
|
87
25
|
|
|
88
26
|
@Extend(Toggle)
|
|
@@ -92,43 +30,45 @@ function themeStyles(isDisabled: boolean) {
|
|
|
92
30
|
|
|
93
31
|
@Component
|
|
94
32
|
export default struct TaroSwitch {
|
|
95
|
-
|
|
33
|
+
@Builder customBuilder() {}
|
|
34
|
+
@BuilderParam createLazyChildren: (node: TaroSwitchElement, layer?: number) => void = this.customBuilder
|
|
35
|
+
@ObjectLink node: TaroSwitchElement
|
|
36
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
96
37
|
|
|
97
38
|
aboutToAppear () {
|
|
98
39
|
if (this.node && !this.node._isInit) {
|
|
99
40
|
this.node._isInit = true
|
|
41
|
+
this.node._instance = this
|
|
100
42
|
this.node._reset = this.node.checked || false
|
|
101
43
|
}
|
|
102
44
|
}
|
|
103
45
|
|
|
104
46
|
build () {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
.
|
|
114
|
-
if (this.node) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
this.node.updateComponent()
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
})
|
|
125
|
-
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
126
|
-
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
127
|
-
if (this.node) {
|
|
128
|
-
this.node._nodeInfo.areaInfo = res[1]
|
|
47
|
+
Toggle({
|
|
48
|
+
type: this.node._attrs.type !== 'checkbox' ? ToggleType.Switch : ToggleType.Checkbox,
|
|
49
|
+
isOn: this.node.checked,
|
|
50
|
+
})
|
|
51
|
+
.attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
52
|
+
.attrs(getAttributes(this.node))
|
|
53
|
+
.themeStyles(!!this.node._attrs.disabled)
|
|
54
|
+
.onChange((isOn: boolean) => {
|
|
55
|
+
if (this.node) {
|
|
56
|
+
if (!this.node?._attrs.disabled) {
|
|
57
|
+
const event: TaroEvent = createTaroEvent('change', { detail: { value: isOn } }, this.node)
|
|
58
|
+
|
|
59
|
+
this.node.updateCheckedValue(isOn)
|
|
60
|
+
eventHandler(event, 'change', this.node)
|
|
61
|
+
} else {
|
|
62
|
+
this.node.updateComponent()
|
|
129
63
|
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
|
|
64
|
+
}
|
|
65
|
+
})
|
|
66
|
+
.onClick(shouldBindEvent((e: ClickEvent) => { eventHandler(e, 'click', this.node) }, this.node, ['click']))
|
|
67
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
68
|
+
if (this.node) {
|
|
69
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
70
|
+
}
|
|
71
|
+
}))
|
|
72
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
133
73
|
}
|
|
134
74
|
}
|
|
@@ -35,6 +35,8 @@ export const TaroAdTagName = 'ad'
|
|
|
35
35
|
export const TaroWebViewTagName = 'web-view'
|
|
36
36
|
export const TaroBlockTagName = 'block'
|
|
37
37
|
export const TaroMapTagName = 'map'
|
|
38
|
+
export const TaroPageMetaTagName = 'page-meta'
|
|
39
|
+
export const TaroNavigationBarTagName = 'navigation-bar'
|
|
38
40
|
export const TaroSlotTagName = 'slot'
|
|
39
41
|
export const TaroNativeSlotTagName = 'native-slot'
|
|
40
42
|
export const TaroCustomWrapperTagName = 'custom-wrapper'
|
|
@@ -47,3 +49,7 @@ export const TaroListTagName = 'list'
|
|
|
47
49
|
export const TaroListItemTagName = 'list-item'
|
|
48
50
|
export const TaroOpenDataTagName = 'open-data'
|
|
49
51
|
export const TaroIgnoreTagName = 'ignore'
|
|
52
|
+
|
|
53
|
+
export const TaroStickySectionTagName = 'sticky-section'
|
|
54
|
+
export const TaroStickyHeaderTagName = 'sticky-header'
|
|
55
|
+
export const TaroListViewTagName = 'list-view'
|
|
@@ -1,130 +1,128 @@
|
|
|
1
|
+
import { isString } from '@tarojs/shared'
|
|
1
2
|
import { eventHandler, convertNumber2VP, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, NodeType } from '@tarojs/runtime'
|
|
2
3
|
|
|
4
|
+
import commonStyleModify, { textModify, setNormalTextAttributeIntoInstance } from './style'
|
|
3
5
|
import { getButtonColor } from './button'
|
|
6
|
+
import { getImageMode } from './image'
|
|
4
7
|
import { BUTTON_THEME_COLOR } from './utils/constant/style'
|
|
5
|
-
import { getNodeThresholds,
|
|
8
|
+
import { getNodeThresholds, getStyleAttr, shouldBindEvent, getNormalAttributes } from './utils/helper'
|
|
6
9
|
|
|
7
|
-
import type { TaroButtonElement, TaroElement, TaroTextElement, TaroAny,
|
|
10
|
+
import type { TaroButtonElement, TaroElement, TaroTextElement, TaroAny, HarmonyStyle } from '@tarojs/runtime'
|
|
8
11
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
.id(style.id)
|
|
12
|
-
.key(style.id)
|
|
13
|
-
.flexGrow(style.flexGrow)
|
|
14
|
-
.flexShrink(style.flexShrink)
|
|
15
|
-
.flexBasis(style.flexBasis)
|
|
16
|
-
.alignSelf(style.alignSelf)
|
|
17
|
-
.padding({
|
|
18
|
-
top: style.paddingTop,
|
|
19
|
-
right: style.paddingRight,
|
|
20
|
-
bottom: style.paddingBottom,
|
|
21
|
-
left: style.paddingLeft
|
|
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
|
-
}
|
|
12
|
+
function getButtonFontSize (node: TaroButtonElement): string | number {
|
|
13
|
+
const isMini = node._attrs.size === 'mini'
|
|
73
14
|
|
|
74
|
-
|
|
75
|
-
function textNormalFontStyle (style: TaroStyleType) {
|
|
76
|
-
.id(style.id)
|
|
77
|
-
.key(style.id)
|
|
78
|
-
.opacity(style.opacity)
|
|
79
|
-
.fontColor(style.color)
|
|
80
|
-
.fontSize(style.fontSize)
|
|
81
|
-
.fontWeight(style.fontWeight)
|
|
82
|
-
.fontStyle(style.fontStyle)
|
|
83
|
-
.fontFamily(style.fontFamily)
|
|
84
|
-
.lineHeight(style.lineHeight)
|
|
85
|
-
.decoration({
|
|
86
|
-
type: style.textDecoration,
|
|
87
|
-
color: style.color
|
|
88
|
-
})
|
|
15
|
+
return isMini ? convertNumber2VP(26) : convertNumber2VP(36)
|
|
89
16
|
}
|
|
90
17
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
18
|
+
function getTextInViewWidth (node: TaroElement | null): TaroAny {
|
|
19
|
+
if (node) {
|
|
20
|
+
const hmStyle = node.hmStyle || {}
|
|
21
|
+
const isFlexView = hmStyle.display === 'flex'
|
|
22
|
+
const width: TaroAny = getStyleAttr(node, 'width')
|
|
23
|
+
const isPercentWidth = isString(width) && width.includes('%')
|
|
24
|
+
|
|
25
|
+
return isFlexView || isPercentWidth ? null : getStyleAttr(node, 'width')
|
|
26
|
+
}
|
|
97
27
|
}
|
|
98
28
|
|
|
99
|
-
function getButtonFontSize (node: TaroButtonElement) {
|
|
100
|
-
const isMini = node._attrs.size === 'mini'
|
|
101
29
|
|
|
102
|
-
|
|
103
|
-
|
|
30
|
+
@Component
|
|
31
|
+
export default struct TaroText {
|
|
32
|
+
@Builder customBuilder() {}
|
|
33
|
+
@BuilderParam createLazyChildren: (node: TaroTextElement, layer?: number) => void = this.customBuilder
|
|
34
|
+
@ObjectLink node: TaroTextElement
|
|
35
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
36
|
+
|
|
37
|
+
aboutToAppear(): void {
|
|
38
|
+
if (this.node) {
|
|
39
|
+
this.node._instance = this
|
|
40
|
+
}
|
|
41
|
+
}
|
|
104
42
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
43
|
+
build () {
|
|
44
|
+
if (this.node.nodeType === NodeType.TEXT_NODE) {
|
|
45
|
+
if (this.node.parentNode) {
|
|
46
|
+
if ((this.node.parentNode as TaroElement).tagName === 'BUTTON') {
|
|
47
|
+
Text(this.node.textContent)
|
|
48
|
+
.attributeModifier(textModify.setNode(this.node?.parentElement as TaroElement, {
|
|
49
|
+
fontSize: getButtonFontSize(this.node.parentNode as TaroButtonElement),
|
|
50
|
+
color: getButtonColor(this.node.parentNode as TaroButtonElement, BUTTON_THEME_COLOR.get((this.node.parentNode as TaroButtonElement)._attrs.type || '').text)
|
|
51
|
+
}))
|
|
52
|
+
} else {
|
|
53
|
+
Text(this.node.textContent)
|
|
54
|
+
.attributeModifier(textModify.setNode(this.node?.parentElement as TaroElement))
|
|
55
|
+
.width(getTextInViewWidth(this.node.parentElement))
|
|
56
|
+
}
|
|
57
|
+
}
|
|
114
58
|
} else {
|
|
115
|
-
Text(node.textContent)
|
|
116
|
-
|
|
117
|
-
.
|
|
59
|
+
Text(this.node.textContent) {
|
|
60
|
+
// text 下还有标签
|
|
61
|
+
if (this.node.childNodes.length > 1 || ((this.node.childNodes[0] && this.node.childNodes[0] as TaroElement)?.nodeType === NodeType.ELEMENT_NODE)) {
|
|
62
|
+
ForEach(this.node.childNodes, (item: TaroElement) => {
|
|
63
|
+
if (item.tagName === 'IMAGE') {
|
|
64
|
+
ImageSpan(item.getAttribute('src'))
|
|
65
|
+
.attributeModifier(commonStyleModify.setNode(item))
|
|
66
|
+
.objectFit(getImageMode(item.getAttribute('mode')))
|
|
67
|
+
.verticalAlign(getImageSpanAlignment(this.node?.hmStyle?.verticalAlign))
|
|
68
|
+
.onClick(shouldBindEvent((e: ClickEvent) => { eventHandler(e, 'click', item) }, item, ['click']))
|
|
69
|
+
} else if (item.nodeType === NodeType.TEXT_NODE) {
|
|
70
|
+
Span(item.textContent)
|
|
71
|
+
} else if (item.tagName === 'TEXT') {
|
|
72
|
+
Span(item.textContent)
|
|
73
|
+
.attributeModifier(spanModify.setNode(item))
|
|
74
|
+
.letterSpacing(item._st.hmStyle.letterSpacing)
|
|
75
|
+
.textBackgroundStyle({
|
|
76
|
+
color: item._st.hmStyle.backgroundColor,
|
|
77
|
+
radius: {
|
|
78
|
+
topLeft: item._st.hmStyle.borderTopLeftRadius,
|
|
79
|
+
topRight: item._st.hmStyle.borderTopRightRadius,
|
|
80
|
+
bottomLeft: item._st.hmStyle.borderBottomLeftRadius,
|
|
81
|
+
bottomRight: item._st.hmStyle.borderBottomRightRadius,
|
|
82
|
+
}
|
|
83
|
+
})
|
|
84
|
+
.onClick(shouldBindEvent((e: ClickEvent) => { eventHandler(e, 'click', item) }, item, ['click']))
|
|
85
|
+
}
|
|
86
|
+
}, (item: TaroElement) => `${item._nid}${this.node._updateTrigger}`)
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
.onClick(shouldBindEvent((e: ClickEvent) => { eventHandler(e, 'click', this.node) }, this.node, ['click']))
|
|
90
|
+
.attributeModifier(textModify.setNode(this.node).withNormalStyle().setAnimationStyle(this.overwriteStyle))
|
|
91
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
92
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
93
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
94
|
+
}))
|
|
118
95
|
}
|
|
119
|
-
} else {
|
|
120
|
-
Text(node.textContent)
|
|
121
|
-
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', node), node, ['click']))
|
|
122
|
-
.textNormalStyle(getNormalAttributes(node))
|
|
123
|
-
.textNormalFontStyle(getNormalAttributes(node))
|
|
124
|
-
.textSpecialFontStyle(getFontAttributes(node))
|
|
125
|
-
.onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
|
|
126
|
-
.onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
127
|
-
node._nodeInfo.areaInfo = res[1]
|
|
128
|
-
}))
|
|
129
96
|
}
|
|
130
97
|
}
|
|
98
|
+
|
|
99
|
+
function getImageSpanAlignment (align: TaroAny): TaroAny {
|
|
100
|
+
if (align === Alignment.Top) {
|
|
101
|
+
return ImageSpanAlignment.TOP
|
|
102
|
+
} else if (align === Alignment.Bottom) {
|
|
103
|
+
return ImageSpanAlignment.BOTTOM
|
|
104
|
+
} else if (align === Alignment.Center) {
|
|
105
|
+
return ImageSpanAlignment.CENTER
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
class SpanStyleModify implements AttributeModifier<SpanAttribute> {
|
|
110
|
+
node: TaroTextElement | null = null
|
|
111
|
+
style: HarmonyStyle | null = null
|
|
112
|
+
overwriteStyle: Record<string, TaroAny> = {}
|
|
113
|
+
withNormal = false
|
|
114
|
+
|
|
115
|
+
setNode (node: TaroTextElement) {
|
|
116
|
+
this.node = node
|
|
117
|
+
this.style = getNormalAttributes(this.node)
|
|
118
|
+
return this
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
applyNormalAttribute(instance: SpanAttribute): void {
|
|
122
|
+
if (this.node && this.style) {
|
|
123
|
+
setNormalTextAttributeIntoInstance(instance, this.style, this.node)
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const spanModify = new SpanStyleModify()
|
|
@@ -1,72 +1,17 @@
|
|
|
1
1
|
import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, createTaroEvent } from '@tarojs/runtime'
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import commonStyleModify from './style'
|
|
4
|
+
import { getNodeThresholds, getFontAttributes, shouldBindEvent, parseStyles } from './utils/helper'
|
|
4
5
|
|
|
5
6
|
import type { TaroAny, TaroStyleType, TaroTextStyleType, TaroTextAreaElement, TaroEvent } from '@tarojs/runtime'
|
|
6
7
|
|
|
8
|
+
interface TextareaAttrs extends TaroTextStyleType {
|
|
9
|
+
autoFocus?: boolean
|
|
10
|
+
disabled?: boolean
|
|
11
|
+
}
|
|
12
|
+
|
|
7
13
|
@Extend(TextArea)
|
|
8
14
|
function textStyle (style: TaroStyleType) {
|
|
9
|
-
.id(style.id)
|
|
10
|
-
.key(style.id)
|
|
11
|
-
.flexGrow(style.flexGrow)
|
|
12
|
-
.flexShrink(style.flexShrink)
|
|
13
|
-
.flexBasis(style.flexBasis)
|
|
14
|
-
.alignSelf(style.alignSelf)
|
|
15
|
-
.padding({
|
|
16
|
-
top: style.paddingTop,
|
|
17
|
-
right: style.paddingRight,
|
|
18
|
-
bottom: style.paddingBottom,
|
|
19
|
-
left: style.paddingLeft
|
|
20
|
-
})
|
|
21
|
-
.margin({
|
|
22
|
-
top: style.marginTop,
|
|
23
|
-
right: style.marginRight,
|
|
24
|
-
bottom: style.marginBottom,
|
|
25
|
-
left: style.marginLeft
|
|
26
|
-
})
|
|
27
|
-
.width(style.width)
|
|
28
|
-
.height(style.height)
|
|
29
|
-
.constraintSize({
|
|
30
|
-
minWidth: style.minWidth,
|
|
31
|
-
maxWidth: style.maxWidth,
|
|
32
|
-
minHeight: style.minHeight,
|
|
33
|
-
maxHeight: style.maxHeight
|
|
34
|
-
})
|
|
35
|
-
.backgroundColor(style.backgroundColor)
|
|
36
|
-
.backgroundImage(style.backgroundImage?.src, style.backgroundRepeat)
|
|
37
|
-
.backgroundImageSize(style.backgroundSize)
|
|
38
|
-
.backgroundImagePosition(style.backgroundPosition)
|
|
39
|
-
.borderStyle({
|
|
40
|
-
top: style.borderTopStyle,
|
|
41
|
-
right: style.borderRightStyle,
|
|
42
|
-
bottom: style.borderBottomStyle,
|
|
43
|
-
left: style.borderLeftStyle
|
|
44
|
-
})
|
|
45
|
-
.borderWidth({
|
|
46
|
-
top: style.borderTopWidth,
|
|
47
|
-
right: style.borderRightWidth,
|
|
48
|
-
bottom: style.borderBottomWidth,
|
|
49
|
-
left: style.borderLeftWidth
|
|
50
|
-
})
|
|
51
|
-
.borderColor({
|
|
52
|
-
top: style.borderTopColor,
|
|
53
|
-
right: style.borderRightColor,
|
|
54
|
-
bottom: style.borderBottomColor,
|
|
55
|
-
left: style.borderLeftColor
|
|
56
|
-
})
|
|
57
|
-
.borderRadius({
|
|
58
|
-
topLeft: style.borderTopLeftRadius,
|
|
59
|
-
topRight: style.borderTopRightRadius,
|
|
60
|
-
bottomLeft: style.borderBottomLeftRadius,
|
|
61
|
-
bottomRight: style.borderBottomRightRadius
|
|
62
|
-
})
|
|
63
|
-
.zIndex(style.zIndex)
|
|
64
|
-
.opacity(style.opacity)
|
|
65
|
-
.linearGradient(style.linearGradient)
|
|
66
|
-
.clip(style.overflow)
|
|
67
|
-
.rotate({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y, angle: 0 })
|
|
68
|
-
.scale({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y })
|
|
69
|
-
.transform(style.transform)
|
|
70
15
|
.fontColor(style.color)
|
|
71
16
|
.fontSize(style.fontSize)
|
|
72
17
|
.fontWeight(style.fontWeight)
|
|
@@ -75,9 +20,18 @@ function textStyle (style: TaroStyleType) {
|
|
|
75
20
|
}
|
|
76
21
|
|
|
77
22
|
@Extend(TextArea)
|
|
78
|
-
function textAttr(attr:
|
|
23
|
+
function textAttr(attr: TextareaAttrs) {
|
|
79
24
|
.textAlign(attr.textAlign)
|
|
80
25
|
.maxLines(attr.WebkitLineClamp)
|
|
26
|
+
.defaultFocus(attr.autoFocus)
|
|
27
|
+
.enabled(!attr.disabled)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function getAttributes(node: TaroTextAreaElement): TextareaAttrs {
|
|
31
|
+
const attrs: TaroAny = getFontAttributes(node)
|
|
32
|
+
attrs.autoFocus = node._attrs.autoFocus || node._attrs.focus || false
|
|
33
|
+
attrs.disabled = node._attrs.disabled || false
|
|
34
|
+
return attrs
|
|
81
35
|
}
|
|
82
36
|
|
|
83
37
|
function getPlaceholderColor (node: TaroTextAreaElement): string {
|
|
@@ -90,7 +44,10 @@ function getPlaceholderColor (node: TaroTextAreaElement): string {
|
|
|
90
44
|
export default struct TaroTextArea {
|
|
91
45
|
@State value: string = ''
|
|
92
46
|
|
|
93
|
-
|
|
47
|
+
@Builder customBuilder() {}
|
|
48
|
+
@BuilderParam createLazyChildren: (node: TaroTextAreaElement, layer?: number) => void = this.customBuilder
|
|
49
|
+
@ObjectLink node: TaroTextAreaElement
|
|
50
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
94
51
|
|
|
95
52
|
aboutToAppear () {
|
|
96
53
|
if (this.node) {
|
|
@@ -105,36 +62,35 @@ export default struct TaroTextArea {
|
|
|
105
62
|
}
|
|
106
63
|
|
|
107
64
|
build () {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}
|
|
65
|
+
TextArea({ text: this.value, placeholder: this.node._attrs?.placeholder || '', controller: this.node.controller })
|
|
66
|
+
.key(this.node._nid.toString())
|
|
67
|
+
.maxLength(Number(this.node._attrs?.maxlength) || null)
|
|
68
|
+
.placeholderColor(getPlaceholderColor(this.node))
|
|
69
|
+
.attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
70
|
+
.textStyle(this.node?.hmStyle)
|
|
71
|
+
.textAttr(getAttributes(this.node))
|
|
72
|
+
.onChange((value: string) => {
|
|
73
|
+
const event: TaroEvent = createTaroEvent('input', { detail: { value } }, this.node)
|
|
74
|
+
|
|
75
|
+
this.value = value
|
|
76
|
+
this.node?.updateFormWidgetValue(value)
|
|
77
|
+
eventHandler(event, 'input', this.node)
|
|
78
|
+
})
|
|
79
|
+
.onClick(shouldBindEvent((e: ClickEvent) => { eventHandler(e, 'click', this.node) }, this.node, ['click']))
|
|
80
|
+
.onBlur(() => {
|
|
81
|
+
const event: TaroEvent = createTaroEvent('blur', { detail: { value: this.value } }, this.node)
|
|
82
|
+
eventHandler(event, 'blur', this.node)
|
|
83
|
+
})
|
|
84
|
+
.onFocus(() => {
|
|
85
|
+
const event: TaroEvent = createTaroEvent('focus', { detail: { value: this.value, height: this.node?._height } }, this.node)
|
|
86
|
+
|
|
87
|
+
eventHandler(event, 'focus', this.node)
|
|
88
|
+
})
|
|
89
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
90
|
+
if (this.node) {
|
|
91
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
92
|
+
}
|
|
93
|
+
}))
|
|
94
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
139
95
|
}
|
|
140
96
|
}
|
|
@@ -60,7 +60,7 @@ class AttributeManager {
|
|
|
60
60
|
const dataValue: string = AttributeManager.getNodeStyle(style, 'animation')
|
|
61
61
|
|
|
62
62
|
if (dataValue) {
|
|
63
|
-
let values: string[] = dataValue.trim().split(new RegExp("/\s+/"))
|
|
63
|
+
let values: string[] = dataValue.toString().trim().split(new RegExp("/\s+/"))
|
|
64
64
|
switch (values.length) {
|
|
65
65
|
case 4:
|
|
66
66
|
res = { duration: values[0], curve: values[1], delay: values[2] }
|
|
@@ -140,7 +140,7 @@ class AttributeManager {
|
|
|
140
140
|
}
|
|
141
141
|
let resultTransform: matrix4.Matrix4Transit
|
|
142
142
|
|
|
143
|
-
const matches = transform.match(new RegExp("/(\w+)\(([^)]+)\)/g")) || [];
|
|
143
|
+
const matches: string[] = transform.match(new RegExp("/(\w+)\(([^)]+)\)/g")) || [];
|
|
144
144
|
|
|
145
145
|
// 处理matrix
|
|
146
146
|
|
|
@@ -11,7 +11,7 @@ export class DynamicCenter {
|
|
|
11
11
|
if (!node._isCompileMode || !node._instance) return
|
|
12
12
|
|
|
13
13
|
if (node._attrs?._dynamicID) {
|
|
14
|
-
node._instance[node._attrs._dynamicID] =
|
|
14
|
+
node._instance[node._attrs._dynamicID] = new TaroElement('Ignore')
|
|
15
15
|
}
|
|
16
16
|
node._instance = null
|
|
17
17
|
}
|
|
@@ -36,4 +36,4 @@ export class DynamicCenter {
|
|
|
36
36
|
this.bindComponentToNodeWithDFS(node.childNodes[i] as TaroElement, component)
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
}
|
|
39
|
+
}
|