@tarojs/plugin-platform-harmony-ets 3.7.0-alpha.27 → 4.0.0-beta.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/apis.ts +6 -2
- package/dist/apis/base/crypto.ts +4 -0
- package/dist/apis/base/debug.ts +5 -0
- package/dist/apis/base/index.ts +9 -1
- package/dist/apis/base/performance.ts +8 -0
- package/dist/apis/base/system.ts +1 -1
- package/dist/apis/base/update.ts +5 -0
- package/dist/apis/base/weapp/app-event.ts +75 -0
- package/dist/apis/base/weapp/life-cycle.ts +21 -0
- package/dist/apis/canvas/index.ts +18 -0
- package/dist/apis/data-analysis/index.ts +6 -0
- package/dist/apis/device/accelerometer.ts +2 -1
- package/dist/apis/device/accessibility.ts +4 -0
- package/dist/apis/device/battery.ts +2 -2
- package/dist/apis/device/bluetooth-ble.ts +19 -0
- package/dist/apis/device/bluetooth-peripheral.ts +6 -0
- package/dist/apis/device/bluetooth.ts +16 -0
- package/dist/apis/device/calendar.ts +5 -0
- package/dist/apis/device/clipboard.ts +1 -1
- package/dist/apis/device/compass.ts +21 -0
- package/dist/apis/device/contact.ts +5 -0
- package/dist/apis/device/crypto.ts +4 -0
- package/dist/apis/device/gyroscope.ts +7 -0
- package/dist/apis/device/iBeacon.ts +10 -0
- package/dist/apis/device/index.ts +15 -0
- package/dist/apis/device/keyboard.ts +2 -1
- package/dist/apis/device/motion.ts +6 -0
- package/dist/apis/device/network.ts +26 -9
- package/dist/apis/device/nfc.ts +10 -0
- package/dist/apis/device/phone.ts +2 -1
- package/dist/apis/device/scan.ts +4 -0
- package/dist/apis/device/screen.ts +2 -1
- package/dist/apis/device/sms.ts +4 -0
- package/dist/apis/device/vibrate.ts +19 -11
- package/dist/apis/device/wifi.ts +15 -0
- package/dist/apis/ext/index.ts +5 -0
- package/dist/apis/files/index.ts +2 -1
- package/dist/apis/files/manager.ts +2 -1
- package/dist/apis/framework/index.ts +5 -6
- package/dist/apis/location/index.ts +61 -68
- package/dist/apis/media/EditorContext.ts +32 -0
- package/dist/apis/media/audio/index.ts +18 -0
- package/dist/apis/media/background-audio/index.ts +16 -0
- package/dist/apis/media/camera.ts +16 -0
- package/dist/apis/media/common.ts +2 -1
- package/dist/apis/media/{image.ts → image/index.ts} +3 -2
- package/dist/apis/media/index.ts +10 -0
- package/dist/apis/media/live.ts +5 -0
- package/dist/apis/media/map.ts +4 -0
- package/dist/apis/media/media-recorder.ts +4 -0
- package/dist/apis/media/recorder.ts +6 -0
- package/dist/apis/media/video/VideoContext.ts +19 -0
- package/dist/apis/media/{video.ts → video/index.ts} +12 -2
- package/dist/apis/media/video-decoder.ts +4 -0
- package/dist/apis/media/video-processing.ts +4 -0
- package/dist/apis/media/voip.ts +19 -0
- package/dist/apis/network/index.ts +3 -0
- package/dist/apis/network/mdns.ts +13 -0
- package/dist/apis/network/request.ts +2 -1
- package/dist/apis/network/tcp.ts +4 -0
- package/dist/apis/network/udp.ts +4 -0
- package/dist/apis/network/webSocket.ts +2 -6
- package/dist/apis/open-api/account.ts +4 -0
- package/dist/apis/open-api/address.ts +4 -0
- package/dist/apis/open-api/authorize.ts +5 -0
- package/dist/apis/open-api/card.ts +5 -0
- package/dist/apis/open-api/channels-live.ts +11 -0
- package/dist/apis/open-api/customer-service.ts +4 -0
- package/dist/apis/open-api/device-voip.ts +5 -0
- package/dist/apis/open-api/facial.ts +7 -0
- package/dist/apis/open-api/favorites.ts +5 -0
- package/dist/apis/open-api/group.ts +4 -0
- package/dist/apis/open-api/index.ts +20 -6
- package/dist/apis/open-api/invoice.ts +5 -0
- package/dist/apis/open-api/license-plate.ts +4 -0
- package/dist/apis/open-api/login.ts +6 -0
- package/dist/apis/open-api/my-miniprogram.ts +4 -0
- package/dist/apis/open-api/privacy.ts +7 -0
- package/dist/apis/open-api/red-package.ts +4 -0
- package/dist/apis/open-api/settings.ts +5 -0
- package/dist/apis/open-api/soter.ts +6 -0
- package/dist/apis/open-api/subscribe-message.ts +6 -0
- package/dist/apis/open-api/{user-info/index.ts → user-info.ts} +1 -16
- package/dist/apis/open-api/werun.ts +5 -0
- package/dist/apis/payment/index.ts +6 -0
- package/dist/apis/route/index.ts +4 -28
- package/dist/apis/share/index.ts +33 -0
- package/dist/apis/storage/background-fetch.ts +7 -0
- package/dist/apis/storage/cache-manager.ts +4 -0
- package/dist/apis/storage/index.ts +20 -18
- package/dist/apis/ui/{animation.ts → animation/animation.ts} +2 -2
- package/dist/apis/ui/animation/index.ts +7 -0
- package/dist/apis/ui/background.ts +2 -18
- package/dist/apis/ui/custom-component.ts +8 -0
- package/dist/apis/ui/fonts.ts +4 -0
- package/dist/apis/ui/index.ts +8 -10
- package/dist/apis/ui/interaction/index.ts +3 -0
- package/dist/apis/ui/menu.ts +4 -0
- package/dist/apis/ui/navigation-bar/index.ts +60 -21
- package/dist/apis/ui/pull-down-refresh.ts +1 -1
- package/dist/apis/{page → ui/scroll}/index.ts +27 -22
- package/dist/apis/ui/sticky.ts +4 -0
- package/dist/apis/{tabbar/index.ts → ui/tab-bar.ts} +3 -5
- package/dist/apis/ui/window.ts +20 -0
- package/dist/apis/utils/handler.ts +4 -4
- package/dist/apis/worker/index.ts +4 -0
- package/dist/apis/wxml/IntersectionObserver.ts +12 -21
- package/dist/apis/wxml/index.ts +5 -2
- package/dist/apis/wxml/nodesRef.ts +2 -2
- package/dist/apis/wxml/selectorQuery.ts +3 -4
- package/dist/components-harmony-ets/button.ets +90 -64
- package/dist/components-harmony-ets/checkbox.ets +53 -98
- package/dist/components-harmony-ets/form.ets +16 -112
- package/dist/components-harmony-ets/icon.ets +59 -46
- package/dist/components-harmony-ets/image.ets +15 -40
- package/dist/components-harmony-ets/innerHtml.ets +6 -74
- package/dist/components-harmony-ets/input.ets +58 -128
- package/dist/components-harmony-ets/label.ets +43 -69
- package/dist/components-harmony-ets/picker.ets +114 -137
- package/dist/components-harmony-ets/radio.ets +55 -103
- package/dist/components-harmony-ets/richText.ets +17 -41
- package/dist/components-harmony-ets/scrollView.ets +69 -101
- package/dist/components-harmony-ets/slider.ets +35 -58
- package/dist/components-harmony-ets/swiper.ets +24 -135
- package/dist/components-harmony-ets/switch.ets +25 -55
- package/dist/components-harmony-ets/text.ets +42 -46
- package/dist/components-harmony-ets/textArea.ets +39 -107
- package/dist/components-harmony-ets/utils/constant/style.ets +9 -6
- package/dist/components-harmony-ets/utils/flexManager.ets +3 -88
- package/dist/components-harmony-ets/utils/helper.ets +2 -62
- package/dist/components-harmony-ets/utils/index.ts +1 -1
- package/dist/components-harmony-ets/utils/styles.ets +6 -9
- package/dist/components-harmony-ets/video.ets +63 -92
- package/dist/components-harmony-ets/view.ets +65 -40
- package/dist/index.js +33 -4
- package/dist/index.js.map +1 -1
- package/dist/runtime-ets/bom/getComputedStyle.ts +1 -1
- package/dist/runtime-ets/dom/bind.ts +80 -0
- package/dist/runtime-ets/dom/class-list.ts +2 -4
- package/dist/runtime-ets/dom/comment.ts +1 -2
- package/dist/runtime-ets/dom/cssStyleDeclaration.ts +1 -1
- package/dist/runtime-ets/dom/dataSource.ts +64 -0
- package/dist/runtime-ets/dom/document.ts +14 -43
- package/dist/runtime-ets/dom/element/element.ts +162 -0
- package/dist/runtime-ets/dom/element/form.ts +397 -0
- package/dist/runtime-ets/dom/element/index.ts +89 -0
- package/dist/runtime-ets/dom/element/normal.ts +75 -0
- package/dist/runtime-ets/dom/element/scrollView.ts +14 -0
- package/dist/runtime-ets/dom/element/text.ts +17 -0
- package/dist/runtime-ets/dom/element/video.ts +49 -0
- package/dist/runtime-ets/dom/event.ts +24 -1
- package/dist/runtime-ets/dom/eventTarget.ts +2 -1
- package/dist/runtime-ets/dom/node.ts +74 -44
- package/dist/runtime-ets/dom/stylesheet/index.ts +136 -23
- package/dist/runtime-ets/dom/stylesheet/type.ts +4 -3
- package/dist/runtime-ets/dom/stylesheet/util.ts +71 -1
- package/dist/runtime-ets/index.ts +0 -1
- package/dist/runtime-ets/utils/bind.ts +3 -14
- package/dist/runtime-ets/utils/index.ts +12 -7
- package/dist/runtime-ets/utils/info.ts +22 -50
- package/dist/runtime-framework/react/app.ts +3 -6
- package/dist/runtime-framework/react/page.ts +2 -9
- package/dist/runtime-framework/solid/page.ts +0 -6
- package/dist/runtime-utils.js +1150 -339
- package/dist/runtime-utils.js.map +1 -1
- package/dist/runtime.js +1150 -339
- package/dist/runtime.js.map +1 -1
- package/package.json +8 -8
- package/types/runtime.d.ts +4 -0
- package/LICENSE +0 -160
- package/dist/components-harmony-ets/base.ets +0 -63
- package/dist/components-harmony-ets/element.ets +0 -223
- package/dist/components-harmony-ets/utils/constant/icon.ts +0 -19
- package/dist/runtime-ets/dom/element.ts +0 -457
- package/dist/runtime-ets/dom/text.ts +0 -19
- package/types/api.d.ts +0 -4
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
TaroAny } from '@tarojs/runtime'
|
|
1
|
+
import { Current, eventHandler, getComponentEventCallback, VISIBLE_CHANGE_EVENT_NAME, getPageScrollerOrNode, AREA_CHANGE_EVENT_NAME } from '@tarojs/runtime'
|
|
3
2
|
|
|
4
|
-
import {
|
|
5
|
-
import TaroComponentWrapper from './base'
|
|
3
|
+
import { createLazyChildren } from './render'
|
|
6
4
|
import { TOUCH_EVENT_MAP } from './utils/constant/event'
|
|
7
5
|
import { FlexManager } from './utils/FlexManager'
|
|
8
|
-
import { getNormalAttributes, shouldBindEvent, getNodeThresholds
|
|
6
|
+
import { getNormalAttributes, shouldBindEvent, getNodeThresholds } from './utils/helper'
|
|
9
7
|
|
|
10
|
-
import type { TaroLabelElement, TaroElement } from '
|
|
11
|
-
import type { TaroStyleType } from '@tarojs/runtime'
|
|
8
|
+
import type { TaroStyleType, TaroLabelElement, TaroElement, TaroAny, TaroRadioElement, TaroCheckboxElement } from '@tarojs/runtime'
|
|
12
9
|
|
|
13
10
|
@Extend(Flex)
|
|
14
11
|
function attrs (style: TaroStyleType) {
|
|
@@ -26,6 +23,7 @@ function attrs (style: TaroStyleType) {
|
|
|
26
23
|
.backgroundColor(style.backgroundColor)
|
|
27
24
|
.backgroundImage(style.backgroundImage, style.backgroundRepeat)
|
|
28
25
|
.backgroundImageSize(style.backgroundImageSize)
|
|
26
|
+
.backgroundImagePosition(style.backgroundImagePosition)
|
|
29
27
|
.rotate(style.rotate)
|
|
30
28
|
.scale(style.scale)
|
|
31
29
|
.translate(style.translate)
|
|
@@ -40,72 +38,48 @@ function attrs (style: TaroStyleType) {
|
|
|
40
38
|
.clip(style.clip)
|
|
41
39
|
}
|
|
42
40
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
function handleTargetChange (id: string) {
|
|
42
|
+
const taro: TaroAny = Current.taro
|
|
43
|
+
const page: TaroAny = taro.getCurrentInstance().page
|
|
44
|
+
const currentPageNode: TaroElement = getPageScrollerOrNode(page.node, page)
|
|
45
|
+
const node: TaroElement | null = currentPageNode.getElementById(id)
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
@ObjectLink node: TaroLabelElement
|
|
52
|
-
|
|
53
|
-
aboutToAppear () {
|
|
54
|
-
initComponentNodeInfo(this, this.node)
|
|
55
|
-
bindInstanceToNode(this.node, this)
|
|
56
|
-
// 绑定动画
|
|
57
|
-
bindAnimation(this.node)
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
@Styles defaultEvent () {
|
|
61
|
-
.onClick((e: ClickEvent) => {
|
|
62
|
-
const firstChild = this.node.childNodes[0] as TaroElement | null
|
|
63
|
-
const id: string = this.node._attrs.for || firstChild?._attrs.id || firstChild?._nid || ''
|
|
64
|
-
this.handleTargetChange(id)
|
|
65
|
-
eventHandler(e, 'click', this.node)
|
|
66
|
-
})
|
|
67
|
-
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
|
|
68
|
-
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, res => {
|
|
69
|
-
const eventResult: TaroAny = res.eventResult
|
|
70
|
-
this.nodeInfoMap[this.node._nid].areaInfo = eventResult[1]
|
|
71
|
-
}))
|
|
72
|
-
}
|
|
47
|
+
if (!node) return
|
|
73
48
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
break
|
|
90
|
-
case 'CHECKBOX':
|
|
91
|
-
instance.checked = !instance.checked
|
|
92
|
-
break
|
|
93
|
-
default:
|
|
94
|
-
focusControl.requestFocus(id)
|
|
95
|
-
}
|
|
49
|
+
if (['BUTTON', 'CHECKBOX', 'RADIO', 'SWITCH', 'INPUT'].includes(node.tagName)) {
|
|
50
|
+
switch (node.tagName) {
|
|
51
|
+
case 'RADIO':
|
|
52
|
+
const radioNode: TaroRadioElement = node as TaroRadioElement
|
|
53
|
+
if (!radioNode.checked) {
|
|
54
|
+
radioNode.checked = !radioNode.checked
|
|
55
|
+
}
|
|
56
|
+
break
|
|
57
|
+
case 'CHECKBOX':
|
|
58
|
+
const checkBoxNode: TaroCheckboxElement = node as TaroCheckboxElement
|
|
59
|
+
checkBoxNode.checked = !checkBoxNode.checked
|
|
60
|
+
break
|
|
61
|
+
default:
|
|
62
|
+
focusControl.requestFocus(id)
|
|
96
63
|
}
|
|
97
64
|
}
|
|
65
|
+
}
|
|
98
66
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
createNode(item)
|
|
104
|
-
}, (item: TaroElement) => item._nid)
|
|
105
|
-
}
|
|
106
|
-
.attrs(getNormalAttributes(this.node))
|
|
107
|
-
.defaultEvent()
|
|
108
|
-
.visibleChangeEvent()
|
|
109
|
-
}
|
|
67
|
+
@Builder
|
|
68
|
+
export default function TaroLabel (node: TaroLabelElement) {
|
|
69
|
+
Flex(FlexManager.flexOptions(node)) {
|
|
70
|
+
createLazyChildren(node)
|
|
110
71
|
}
|
|
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))
|
|
111
85
|
}
|
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
TaroEvent
|
|
4
|
-
} from '@tarojs/runtime'
|
|
5
|
-
import { createNode } from './render'
|
|
6
|
-
import TaroComponentWrapper from './base'
|
|
1
|
+
import { AREA_CHANGE_EVENT_NAME, eventHandler, getComponentEventCallback, VISIBLE_CHANGE_EVENT_NAME, TaroPickerElement, createTaroEvent } from '@tarojs/runtime'
|
|
2
|
+
import { createLazyChildren } from './render'
|
|
7
3
|
import { getSingleSelector, getMultiSelector } from './utils'
|
|
8
4
|
import { TOUCH_EVENT_MAP } from './utils/constant/event'
|
|
9
5
|
import { FlexManager } from './utils/FlexManager'
|
|
10
|
-
import {
|
|
11
|
-
import { getNormalAttributes, shouldBindEvent, getNodeThresholds, bindAnimation } from './utils/helper'
|
|
6
|
+
import { getNormalAttributes, shouldBindEvent, getNodeThresholds } from './utils/helper'
|
|
12
7
|
|
|
13
|
-
import type {
|
|
14
|
-
import type { TaroStyleType } from '@tarojs/runtime'
|
|
8
|
+
import type { TaroAny, TaroStyleType, TaroEvent } from '@tarojs/runtime'
|
|
15
9
|
|
|
16
10
|
import { PickerDateProps, PickerMultiSelectorProps, PickerSelectorProps, PickerTimeProps } from './types'
|
|
17
11
|
|
|
@@ -31,6 +25,7 @@ function textPickerAttrs (style: TaroStyleType) {
|
|
|
31
25
|
.backgroundColor(style.backgroundColor || '#fff')
|
|
32
26
|
.backgroundImage(style.backgroundImage, style.backgroundRepeat)
|
|
33
27
|
.backgroundImageSize(style.backgroundImageSize)
|
|
28
|
+
.backgroundImagePosition(style.backgroundImagePosition)
|
|
34
29
|
.rotate(style.rotate)
|
|
35
30
|
.scale(style.scale)
|
|
36
31
|
.translate(style.translate)
|
|
@@ -61,6 +56,7 @@ function datePickerAttrs (style: TaroStyleType) {
|
|
|
61
56
|
.backgroundColor(style.backgroundColor || '#fff')
|
|
62
57
|
.backgroundImage(style.backgroundImage, style.backgroundRepeat)
|
|
63
58
|
.backgroundImageSize(style.backgroundImageSize)
|
|
59
|
+
.backgroundImagePosition(style.backgroundImagePosition)
|
|
64
60
|
.rotate(style.rotate)
|
|
65
61
|
.scale(style.scale)
|
|
66
62
|
.translate(style.translate)
|
|
@@ -84,10 +80,7 @@ interface TimeRange {
|
|
|
84
80
|
|
|
85
81
|
@CustomDialog
|
|
86
82
|
export struct PickerView {
|
|
87
|
-
|
|
88
|
-
@ObjectLink node: TaroPickerElement
|
|
89
|
-
|
|
90
|
-
@Link select: string | number
|
|
83
|
+
node: TaroPickerElement | null = null
|
|
91
84
|
|
|
92
85
|
controller?: CustomDialogController
|
|
93
86
|
|
|
@@ -96,7 +89,7 @@ export struct PickerView {
|
|
|
96
89
|
showSelector: number[] = []
|
|
97
90
|
|
|
98
91
|
getDateOptions (): DatePickerOptions {
|
|
99
|
-
const _attrs = this.node
|
|
92
|
+
const _attrs = this.node?._attrs as PickerDateProps
|
|
100
93
|
return {
|
|
101
94
|
start: new Date(_attrs.start || ''),
|
|
102
95
|
end: new Date(_attrs.end || ''),
|
|
@@ -105,9 +98,9 @@ export struct PickerView {
|
|
|
105
98
|
}
|
|
106
99
|
|
|
107
100
|
getTextOptions (): TextPickerOptions {
|
|
108
|
-
let mode: string = this.node
|
|
101
|
+
let mode: string = this.node?._attrs.mode || 'selector'
|
|
109
102
|
if (!mode) {
|
|
110
|
-
const _attrs = this.node
|
|
103
|
+
const _attrs = this.node?._attrs as PickerSelectorProps
|
|
111
104
|
const range = _attrs.range
|
|
112
105
|
if (range && range.length && range[0] instanceof Array) {
|
|
113
106
|
mode = 'multiSelector'
|
|
@@ -116,7 +109,7 @@ export struct PickerView {
|
|
|
116
109
|
}
|
|
117
110
|
switch (mode) {
|
|
118
111
|
case 'time': {
|
|
119
|
-
const _attrs = this.node
|
|
112
|
+
const _attrs = this.node?._attrs as PickerTimeProps
|
|
120
113
|
let timeRange: TimeRange = {
|
|
121
114
|
startHH: 0,
|
|
122
115
|
startMM: 0,
|
|
@@ -143,30 +136,27 @@ export struct PickerView {
|
|
|
143
136
|
}
|
|
144
137
|
}
|
|
145
138
|
case 'multiSelector': {
|
|
146
|
-
const _attrs = this.node
|
|
147
|
-
const value = _attrs.value as number[]
|
|
139
|
+
const _attrs = this.node?._attrs as PickerMultiSelectorProps
|
|
148
140
|
let showRange = _attrs.range as string[][]
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
selects = selects.split(',').map(i => Number(i))
|
|
154
|
-
}
|
|
141
|
+
const selected: number[] = this.node?.value
|
|
142
|
+
this.showSelector = selected
|
|
143
|
+
showRange = getMultiSelector(this, _attrs.range, _attrs.rangeKey, selected)
|
|
144
|
+
|
|
155
145
|
return {
|
|
146
|
+
selected,
|
|
156
147
|
range: showRange,
|
|
157
|
-
selected: selects || value
|
|
158
148
|
}
|
|
159
149
|
}
|
|
160
150
|
default: {
|
|
161
|
-
const _attrs = this.node
|
|
151
|
+
const _attrs = this.node?._attrs as PickerSelectorProps
|
|
162
152
|
const range = _attrs.range
|
|
163
153
|
let showRange = _attrs.range as string[]
|
|
164
154
|
if (_attrs.rangeKey && typeof range[0] === 'object') {
|
|
165
|
-
showRange = getSingleSelector(
|
|
155
|
+
showRange = getSingleSelector(range, _attrs.rangeKey)
|
|
166
156
|
}
|
|
167
157
|
return {
|
|
168
158
|
range: showRange,
|
|
169
|
-
selected:
|
|
159
|
+
selected: this.node?.value
|
|
170
160
|
}
|
|
171
161
|
}
|
|
172
162
|
}
|
|
@@ -179,7 +169,7 @@ export struct PickerView {
|
|
|
179
169
|
}
|
|
180
170
|
|
|
181
171
|
getText = () => {
|
|
182
|
-
if (this.node
|
|
172
|
+
if (this.node?._attrs.mode === 'selector') {
|
|
183
173
|
const _attrs = this.node._attrs as PickerSelectorProps
|
|
184
174
|
return [_attrs.textProps?.okText || '确认', _attrs.textProps?.cancelText || '取消']
|
|
185
175
|
} else {
|
|
@@ -190,83 +180,89 @@ export struct PickerView {
|
|
|
190
180
|
@Builder
|
|
191
181
|
showDialog() {
|
|
192
182
|
Column() {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
this.
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
Text(this.getText()[0]).fontSize(15).padding({top: 20, bottom: 40}).fontColor('#1aad19').onClick(() => {
|
|
203
|
-
this.emitEvent('change', { value: this.select})
|
|
204
|
-
this.controller?.close()
|
|
205
|
-
})
|
|
206
|
-
}
|
|
207
|
-
.width('100%')
|
|
208
|
-
.backgroundColor('#fff')
|
|
209
|
-
.padding({
|
|
210
|
-
left: 20,
|
|
211
|
-
right: 20
|
|
212
|
-
})
|
|
213
|
-
if (this.node._attrs.mode === 'selector') {
|
|
214
|
-
TextPicker(this.getTextOptions())
|
|
215
|
-
.selectedTextStyle({
|
|
216
|
-
color: '#000'
|
|
183
|
+
if (this.node) {
|
|
184
|
+
Flex({
|
|
185
|
+
direction: FlexDirection.Row,
|
|
186
|
+
justifyContent: FlexAlign.SpaceBetween,
|
|
187
|
+
alignItems: ItemAlign.Center
|
|
188
|
+
}) {
|
|
189
|
+
Text(this.getText()[1]).fontSize(15).padding({top: 20, bottom: 40}).fontColor('#888').onClick(() => {
|
|
190
|
+
this.emitEvent('cancel')
|
|
191
|
+
this.controller?.close()
|
|
217
192
|
})
|
|
218
|
-
.
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
this.select = index as number
|
|
193
|
+
Text(this.getText()[0]).fontSize(15).padding({top: 20, bottom: 40}).fontColor('#1aad19').onClick(() => {
|
|
194
|
+
this.emitEvent('change', { value: this.node?.value})
|
|
195
|
+
this.controller?.close()
|
|
222
196
|
})
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
197
|
+
}
|
|
198
|
+
.width('100%')
|
|
199
|
+
.backgroundColor('#fff')
|
|
200
|
+
.padding({
|
|
201
|
+
left: 20,
|
|
202
|
+
right: 20
|
|
203
|
+
})
|
|
204
|
+
if (this.node._attrs.mode === 'selector') {
|
|
205
|
+
TextPicker(this.getTextOptions())
|
|
206
|
+
.selectedTextStyle({
|
|
207
|
+
color: '#000'
|
|
208
|
+
})
|
|
209
|
+
.canLoop(false)
|
|
210
|
+
.textPickerAttrs(getNormalAttributes(this.node))
|
|
211
|
+
.onChange((_, index) => {
|
|
212
|
+
this.node?.updateFormWidgetValue(index)
|
|
213
|
+
})
|
|
214
|
+
} else if (this.node?._attrs.mode === 'multiSelector') {
|
|
215
|
+
TextPicker(this.getTextOptions())
|
|
216
|
+
.selectedTextStyle({
|
|
217
|
+
color: '#000'
|
|
218
|
+
})
|
|
219
|
+
.canLoop(false)
|
|
220
|
+
.textPickerAttrs(getNormalAttributes(this.node))
|
|
221
|
+
.onChange((_, index) => {
|
|
222
|
+
if (index instanceof Array) {
|
|
223
|
+
this.node?.updateFormWidgetValue(index)
|
|
224
|
+
// 计算几列发生了变化
|
|
225
|
+
const originIndexs: number[] = this.multiColumnIndex || this.showSelector
|
|
226
|
+
this.multiColumnIndex = index
|
|
227
|
+
let changeValue: number | undefined
|
|
228
|
+
const changeIndex = index.findIndex((item, i) => {
|
|
229
|
+
const originIndex = originIndexs[i]
|
|
230
|
+
if (originIndex != item) {
|
|
231
|
+
changeValue = item
|
|
232
|
+
return true
|
|
233
|
+
}
|
|
234
|
+
return false
|
|
235
|
+
})
|
|
236
|
+
if (changeIndex < 0) {
|
|
237
|
+
return
|
|
242
238
|
}
|
|
243
|
-
|
|
244
|
-
})
|
|
245
|
-
if (changeIndex < 0) {
|
|
246
|
-
return
|
|
239
|
+
this.emitEvent('columnChange', { column: changeIndex, value: changeValue })
|
|
247
240
|
}
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
241
|
+
})
|
|
242
|
+
} else if (this.node._attrs.mode === 'date') {
|
|
243
|
+
DatePicker(this.getDateOptions())
|
|
244
|
+
.selectedTextStyle({
|
|
245
|
+
color: '#000'
|
|
246
|
+
})
|
|
247
|
+
.datePickerAttrs(getNormalAttributes(this.node))
|
|
248
|
+
.onDateChange(value => {
|
|
249
|
+
const data = value.toLocaleDateString().split('/')
|
|
250
|
+
const day = data[1]
|
|
251
|
+
const month = data[0]
|
|
252
|
+
const year = data[2]
|
|
253
|
+
this.node?.updateFormWidgetValue(`${year}-${month}-${day}`)
|
|
254
|
+
})
|
|
255
|
+
} else if (this.node._attrs.mode === 'time') {
|
|
256
|
+
TextPicker(this.getTextOptions())
|
|
257
|
+
.selectedTextStyle({
|
|
258
|
+
color: '#000'
|
|
259
|
+
})
|
|
260
|
+
.canLoop(false)
|
|
261
|
+
.textPickerAttrs(getNormalAttributes(this.node))
|
|
262
|
+
.onChange((value) => {
|
|
263
|
+
this.node?.updateFormWidgetValue(`${('00'+value[0]).slice(-2)}:${('00'+value[1]).slice(-2)}`)
|
|
264
|
+
})
|
|
265
|
+
}
|
|
270
266
|
}
|
|
271
267
|
}
|
|
272
268
|
}
|
|
@@ -276,41 +272,25 @@ export struct PickerView {
|
|
|
276
272
|
}
|
|
277
273
|
}
|
|
278
274
|
|
|
279
|
-
|
|
280
|
-
|
|
281
275
|
@Component
|
|
282
276
|
export default struct TaroPicker {
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
@State select: string = ''
|
|
286
|
-
|
|
287
|
-
@ObjectLink node: TaroPickerElement
|
|
277
|
+
node: TaroPickerElement | null = null
|
|
288
278
|
|
|
289
279
|
aboutToAppear () {
|
|
290
|
-
|
|
291
|
-
bindInstanceToNode(this.node, this)
|
|
292
|
-
// 绑定动画
|
|
293
|
-
bindAnimation(this.node)
|
|
294
|
-
|
|
295
|
-
this.select = this.node._attrs.value as TaroAny
|
|
296
|
-
|
|
297
|
-
this.node.addEventListener('click', this.handleClick)
|
|
280
|
+
this.node?.addEventListener('click', this.handleClick)
|
|
298
281
|
}
|
|
299
282
|
|
|
300
283
|
dialogController: CustomDialogController | null = null
|
|
301
284
|
|
|
302
285
|
aboutToDisappear() {
|
|
303
286
|
this.dialogController = null // 将dialogController置空
|
|
287
|
+
this.node?.removeEventListener('click', this.handleClick)
|
|
304
288
|
}
|
|
305
289
|
|
|
306
|
-
|
|
307
290
|
handleClick = () => {
|
|
308
|
-
if (!this.dialogController) {
|
|
291
|
+
if (!this.dialogController && this.node) {
|
|
309
292
|
this.dialogController = new CustomDialogController({
|
|
310
|
-
builder: PickerView({
|
|
311
|
-
node: this.node,
|
|
312
|
-
select: this.select
|
|
313
|
-
}),
|
|
293
|
+
builder: PickerView({ node: this.node }),
|
|
314
294
|
customStyle: true,
|
|
315
295
|
cornerRadius: '0vp',
|
|
316
296
|
autoCancel: true,
|
|
@@ -324,7 +304,7 @@ export default struct TaroPicker {
|
|
|
324
304
|
}
|
|
325
305
|
})
|
|
326
306
|
}
|
|
327
|
-
this.dialogController
|
|
307
|
+
this.dialogController?.open()
|
|
328
308
|
}
|
|
329
309
|
|
|
330
310
|
@Styles defaultEvent () {
|
|
@@ -332,9 +312,10 @@ export default struct TaroPicker {
|
|
|
332
312
|
eventHandler(e, 'click', this.node)
|
|
333
313
|
})
|
|
334
314
|
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
|
|
335
|
-
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, res => {
|
|
336
|
-
|
|
337
|
-
|
|
315
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
316
|
+
if (this.node) {
|
|
317
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
318
|
+
}
|
|
338
319
|
}))
|
|
339
320
|
}
|
|
340
321
|
|
|
@@ -343,20 +324,16 @@ export default struct TaroPicker {
|
|
|
343
324
|
}
|
|
344
325
|
|
|
345
326
|
build() {
|
|
346
|
-
|
|
327
|
+
if (this.node) {
|
|
347
328
|
Flex(FlexManager.flexOptions(this.node)) {
|
|
348
|
-
|
|
349
|
-
createNode(item)
|
|
350
|
-
}, (item: TaroElement) => item._nid)
|
|
329
|
+
createLazyChildren(this.node)
|
|
351
330
|
}
|
|
352
|
-
|
|
353
|
-
|
|
331
|
+
.defaultEvent()
|
|
332
|
+
.visibleChangeEvent()
|
|
354
333
|
}
|
|
355
334
|
}
|
|
356
335
|
}
|
|
357
336
|
|
|
358
|
-
|
|
359
|
-
|
|
360
337
|
function generateNumberArray(x: number, y: number) {
|
|
361
338
|
// 创建一个空数组来存储结果
|
|
362
339
|
let result: string[] = []
|