@tarojs/plugin-platform-harmony-ets 3.7.0-alpha.27 → 4.0.0-alpha.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,7 +1,5 @@
|
|
|
1
1
|
/* eslint-disable accessor-pairs */
|
|
2
2
|
// @ts-nocheck
|
|
3
|
-
import matrix4 from '@ohos.matrix4'
|
|
4
|
-
|
|
5
3
|
import { ObjectAssign, TaroAny } from '../../'
|
|
6
4
|
import { FlexManager, getNodeMarginOrPaddingData, getUnit } from './util'
|
|
7
5
|
|
|
@@ -143,6 +141,32 @@ export default class StyleSheet {
|
|
|
143
141
|
this.hmStyle.left = value
|
|
144
142
|
}
|
|
145
143
|
|
|
144
|
+
get flex () {
|
|
145
|
+
return this.hmStyle.flex
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
set flex (value: string | number) {
|
|
149
|
+
let res: [number, number, number | string] = [0, 0, 'auto']
|
|
150
|
+
|
|
151
|
+
if (typeof value === 'number') {
|
|
152
|
+
res = [value, 1, 0]
|
|
153
|
+
} else if (value === 'auto') {
|
|
154
|
+
res = [1, 1, 'auto']
|
|
155
|
+
} else if (value === 'none') {
|
|
156
|
+
res = [0, 0, 'auto']
|
|
157
|
+
} else if (typeof value === 'string') {
|
|
158
|
+
const FlexList = value.replace(new RegExp('/\\s+/g'), ' ').split(' ')
|
|
159
|
+
FlexList.forEach((item, index) => {
|
|
160
|
+
res[index] = index < 2 ? Number(item) : item
|
|
161
|
+
})
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
this.flexGrow = res[0]
|
|
165
|
+
this.flexShrink = res[1]
|
|
166
|
+
this.flexBasis = res[2]
|
|
167
|
+
this.hmStyle.flex = value
|
|
168
|
+
}
|
|
169
|
+
|
|
146
170
|
get flexBasis () {
|
|
147
171
|
return this.hmStyle.flexBasis
|
|
148
172
|
}
|
|
@@ -201,6 +225,12 @@ export default class StyleSheet {
|
|
|
201
225
|
if (typeof value.alignItems !== 'undefined') {
|
|
202
226
|
this.hmStyle.alignItems = value.alignItems
|
|
203
227
|
}
|
|
228
|
+
if (typeof value.wrap !== 'undefined') {
|
|
229
|
+
this.hmStyle.flexWrap = value.wrap
|
|
230
|
+
}
|
|
231
|
+
if (typeof value.alignContent !== 'undefined') {
|
|
232
|
+
this.hmStyle.alignContent = value.alignContent
|
|
233
|
+
}
|
|
204
234
|
}
|
|
205
235
|
|
|
206
236
|
get flexDirection () {
|
|
@@ -211,10 +241,6 @@ export default class StyleSheet {
|
|
|
211
241
|
this.hmStyle.direction = FlexManager.direction(value)
|
|
212
242
|
}
|
|
213
243
|
|
|
214
|
-
set _direction (value: FlexDirection) {
|
|
215
|
-
this.hmStyle.direction = value
|
|
216
|
-
}
|
|
217
|
-
|
|
218
244
|
get justifyContent () {
|
|
219
245
|
return FlexManager.reverseFlexAlign(this.hmStyle.justifyContent)
|
|
220
246
|
}
|
|
@@ -223,10 +249,6 @@ export default class StyleSheet {
|
|
|
223
249
|
this.hmStyle.justifyContent = FlexManager.flexAlign(value)
|
|
224
250
|
}
|
|
225
251
|
|
|
226
|
-
set _justifyContent (value: FlexAlign) {
|
|
227
|
-
this.hmStyle.justifyContent = value
|
|
228
|
-
}
|
|
229
|
-
|
|
230
252
|
get alignItems () {
|
|
231
253
|
return FlexManager.reverseItemAlign(this.hmStyle.alignItems)
|
|
232
254
|
}
|
|
@@ -235,8 +257,20 @@ export default class StyleSheet {
|
|
|
235
257
|
this.hmStyle.alignItems = FlexManager.itemAlign(value)
|
|
236
258
|
}
|
|
237
259
|
|
|
238
|
-
|
|
239
|
-
this.hmStyle.
|
|
260
|
+
get alignContent () {
|
|
261
|
+
return FlexManager.reverseFlexAlign(this.hmStyle.alignContent)
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
set alignContent (value: string) {
|
|
265
|
+
this.hmStyle.alignContent = FlexManager.flexAlign(value)
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
get flexWrap () {
|
|
269
|
+
return FlexManager.reverseFlexWrap(this.hmStyle.wrap)
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
set flexWrap (value: string) {
|
|
273
|
+
this.hmStyle.wrap = FlexManager.flexWrap(value)
|
|
240
274
|
}
|
|
241
275
|
|
|
242
276
|
get width () {
|
|
@@ -318,6 +352,9 @@ export default class StyleSheet {
|
|
|
318
352
|
}
|
|
319
353
|
this.hmStyle.backgroundImageSize = value?.size?.[0]
|
|
320
354
|
this.hmStyle.backgroundColor = this.hmStyle.backgroundImage ? null : value?.color
|
|
355
|
+
|
|
356
|
+
const _backgroundPosition: HarmonyType.Background.backgroundImagePosition = value?.position?.[0]
|
|
357
|
+
this.hmStyle.backgroundImagePosition = _backgroundPosition
|
|
321
358
|
}
|
|
322
359
|
|
|
323
360
|
get backgroundColor () {
|
|
@@ -381,6 +418,62 @@ export default class StyleSheet {
|
|
|
381
418
|
}
|
|
382
419
|
}
|
|
383
420
|
|
|
421
|
+
get backgroundPosition () {
|
|
422
|
+
if (this.hmStyle.backgroundImagePosition) {
|
|
423
|
+
switch (this.hmStyle.backgroundImagePosition) {
|
|
424
|
+
case Alignment.TopStart: return 'left top'; break
|
|
425
|
+
case Alignment.Top: return 'center top'; break
|
|
426
|
+
case Alignment.TopEnd: return 'right top'; break
|
|
427
|
+
case Alignment.Start: return 'left center'; break
|
|
428
|
+
case Alignment.Center: return 'center center'; break
|
|
429
|
+
case Alignment.End: return 'right center'; break
|
|
430
|
+
case Alignment.BottomStart: return 'left bottom'; break
|
|
431
|
+
case Alignment.Bottom: return 'center bottom'; break
|
|
432
|
+
case Alignment.BottomEnd: return 'right bottom'; break
|
|
433
|
+
default: {
|
|
434
|
+
if (this.hmStyle.backgroundImagePosition) {
|
|
435
|
+
return [this.hmStyle.backgroundImagePosition, this.hmStyle.backgroundImagePosition.y].join(' ')
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
set backgroundPosition (value: string) {
|
|
443
|
+
if (typeof value === 'string') {
|
|
444
|
+
const positions = backgroundImagePosition.split(' ')
|
|
445
|
+
const horizontal = positions[0].toLowerCase()
|
|
446
|
+
const vertical = positions[1].toLowerCase() || 'top'
|
|
447
|
+
|
|
448
|
+
if (horizontal === 'left' && vertical === 'top') {
|
|
449
|
+
this.hmStyle.backgroundImagePosition = Alignment.TopStart
|
|
450
|
+
} else if (horizontal === 'center' && vertical === 'top') {
|
|
451
|
+
this.hmStyle.backgroundImagePosition = Alignment.Top
|
|
452
|
+
} else if (horizontal === 'right' && vertical === 'top') {
|
|
453
|
+
this.hmStyle.backgroundImagePosition = Alignment.TopEnd
|
|
454
|
+
} else if (horizontal === 'left' && vertical === 'center') {
|
|
455
|
+
this.hmStyle.backgroundImagePosition = Alignment.Start
|
|
456
|
+
} else if (horizontal === 'center' && vertical === 'center') {
|
|
457
|
+
this.hmStyle.backgroundImagePosition = Alignment.Center
|
|
458
|
+
} else if (horizontal === 'right' && vertical === 'center') {
|
|
459
|
+
this.hmStyle.backgroundImagePosition = Alignment.End
|
|
460
|
+
} else if (horizontal === 'left' && vertical === 'bottom') {
|
|
461
|
+
this.hmStyle.backgroundImagePosition = Alignment.BottomStart
|
|
462
|
+
} else if (horizontal === 'center' && vertical === 'bottom') {
|
|
463
|
+
this.hmStyle.backgroundImagePosition = Alignment.Bottom
|
|
464
|
+
} else if (horizontal === 'right' && vertical === 'bottom') {
|
|
465
|
+
this.hmStyle.backgroundImagePosition = Alignment.BottomEnd
|
|
466
|
+
} else {
|
|
467
|
+
if (/^\d+(\.\d+)?(px|%|vw|vh)$/.test(horizontal)) {
|
|
468
|
+
this.hmStyle.backgroundImagePosition = { x: getUnit(horizontal) }
|
|
469
|
+
if (/^\d+(\.\d+)?(px|%|vw|vh)$/.test(vertical)) {
|
|
470
|
+
this.hmStyle.backgroundImagePosition = { x: getUnit(horizontal), y: getUnit(vertical) }
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
|
|
384
477
|
get border () {
|
|
385
478
|
return [this.borderWidth, this.borderStyle, this.bordercolor].join(' ')
|
|
386
479
|
}
|
|
@@ -453,7 +546,9 @@ export default class StyleSheet {
|
|
|
453
546
|
}
|
|
454
547
|
|
|
455
548
|
set opacity (value: string) {
|
|
456
|
-
|
|
549
|
+
const val = Number(value)
|
|
550
|
+
|
|
551
|
+
this.hmStyle.opacity = Number.isNaN(val) ? 1 : val
|
|
457
552
|
}
|
|
458
553
|
|
|
459
554
|
get overflow () {
|
|
@@ -464,10 +559,6 @@ export default class StyleSheet {
|
|
|
464
559
|
this.hmStyle.clip = value === 'hidden'
|
|
465
560
|
}
|
|
466
561
|
|
|
467
|
-
set _overflow (value: boolean) {
|
|
468
|
-
this.hmStyle.clip = value
|
|
469
|
-
}
|
|
470
|
-
|
|
471
562
|
get focus () {
|
|
472
563
|
return !!this.hmStyle.focus
|
|
473
564
|
}
|
|
@@ -517,6 +608,27 @@ export default class StyleSheet {
|
|
|
517
608
|
this.hmStyle.fontWeight = value
|
|
518
609
|
}
|
|
519
610
|
|
|
611
|
+
get fontStyle () {
|
|
612
|
+
switch (this.hmStyle.fontStyle) {
|
|
613
|
+
case FontStyle.Italic: return 'italic'; break
|
|
614
|
+
case FontStyle.Normal: return 'normal'; break
|
|
615
|
+
default: return ''
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
set fontStyle (value: string) {
|
|
620
|
+
switch (value) {
|
|
621
|
+
case 'italic':
|
|
622
|
+
return FontStyle.Italic
|
|
623
|
+
default:
|
|
624
|
+
return FontStyle.Normal
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
set _fontStyle (value: FontStyle) {
|
|
629
|
+
this.hmStyle.fontStyle = value
|
|
630
|
+
}
|
|
631
|
+
|
|
520
632
|
get fontFamily () {
|
|
521
633
|
return this.hmStyle.fontFamily
|
|
522
634
|
}
|
|
@@ -598,7 +710,7 @@ export default class StyleSheet {
|
|
|
598
710
|
}
|
|
599
711
|
}
|
|
600
712
|
|
|
601
|
-
set
|
|
713
|
+
set _decoration (value: TextDecorationType) {
|
|
602
714
|
this.hmStyle.decoration = value
|
|
603
715
|
}
|
|
604
716
|
|
|
@@ -628,6 +740,12 @@ export default class StyleSheet {
|
|
|
628
740
|
}
|
|
629
741
|
|
|
630
742
|
set _textOverflow (value: TextOverflow) {
|
|
743
|
+
switch (value.overflow) {
|
|
744
|
+
case TextOverflow.Clip:
|
|
745
|
+
case TextOverflow.Ellipsis:
|
|
746
|
+
case TextOverflow.None: this.hmStyle.maxLines = this.hmStyle.maxLines || 1; break
|
|
747
|
+
default: break
|
|
748
|
+
}
|
|
631
749
|
this.hmStyle.textOverflow = value
|
|
632
750
|
}
|
|
633
751
|
|
|
@@ -643,11 +761,6 @@ export default class StyleSheet {
|
|
|
643
761
|
this.hmStyle.maxLines = value
|
|
644
762
|
}
|
|
645
763
|
|
|
646
|
-
// TODO: 未实现转换为w3c
|
|
647
|
-
get linearGradient (): HarmonyType.LinearGradient {
|
|
648
|
-
return this.hmStyle.linearGradient
|
|
649
|
-
}
|
|
650
|
-
|
|
651
764
|
set _linearGradient (value: HarmonyType.LinearGradient[]) {
|
|
652
765
|
this.hmStyle.linearGradient = value?.[0]
|
|
653
766
|
}
|
|
@@ -10,8 +10,8 @@ export interface HarmonyStyle extends TaroStyleType {
|
|
|
10
10
|
export interface TaroStyleType {
|
|
11
11
|
id?: string
|
|
12
12
|
|
|
13
|
-
padding?:
|
|
14
|
-
margin?: Margin
|
|
13
|
+
padding?: Padding
|
|
14
|
+
margin?: Margin
|
|
15
15
|
width?: Length
|
|
16
16
|
height?: Length
|
|
17
17
|
constraintSize?: ConstraintSizeOptions
|
|
@@ -31,7 +31,7 @@ export interface TaroStyleType {
|
|
|
31
31
|
direction?: FlexDirection
|
|
32
32
|
justifyContent?: FlexAlign
|
|
33
33
|
alignItems?: ItemAlign
|
|
34
|
-
|
|
34
|
+
flexWrap?: FlexWrap
|
|
35
35
|
alignContent?: FlexAlign
|
|
36
36
|
|
|
37
37
|
// background
|
|
@@ -39,6 +39,7 @@ export interface TaroStyleType {
|
|
|
39
39
|
backgroundImage?: ResourceStr
|
|
40
40
|
backgroundRepeat?: ImageRepeat
|
|
41
41
|
backgroundImageSize?: SizeOptions | ImageSize
|
|
42
|
+
backgroundImagePosition?: Position | Alignment
|
|
42
43
|
|
|
43
44
|
// transform
|
|
44
45
|
rotate?: HarmonyType.Transform.Rotate
|
|
@@ -22,6 +22,25 @@ export class FlexManager {
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
static reverseFlexAlign (value: FlexAlign): string {
|
|
26
|
+
switch (value) {
|
|
27
|
+
case FlexAlign.Start:
|
|
28
|
+
return 'flex-start'
|
|
29
|
+
case FlexAlign.End:
|
|
30
|
+
return 'flex-end'
|
|
31
|
+
case FlexAlign.Center:
|
|
32
|
+
return 'center'
|
|
33
|
+
case FlexAlign.SpaceBetween:
|
|
34
|
+
return 'space-between'
|
|
35
|
+
case FlexAlign.SpaceAround:
|
|
36
|
+
return 'space-around'
|
|
37
|
+
case FlexAlign.SpaceEvenly:
|
|
38
|
+
return 'space-evenly'
|
|
39
|
+
default:
|
|
40
|
+
return ''
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
25
44
|
static direction (value: string): FlexDirection {
|
|
26
45
|
switch (value) {
|
|
27
46
|
case 'row': return FlexDirection.Row
|
|
@@ -31,6 +50,16 @@ export class FlexManager {
|
|
|
31
50
|
}
|
|
32
51
|
}
|
|
33
52
|
|
|
53
|
+
static reverseDirection (value: FlexDirection): string {
|
|
54
|
+
switch (value) {
|
|
55
|
+
case FlexDirection.Row: return 'row'
|
|
56
|
+
case FlexDirection.RowReverse: return 'row-reverse'
|
|
57
|
+
case FlexDirection.Column: return 'column'
|
|
58
|
+
case FlexDirection.ColumnReverse: return 'column-reverse'
|
|
59
|
+
default: return ''
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
34
63
|
static itemAlign (value: string | number | undefined): ItemAlign {
|
|
35
64
|
switch (value) {
|
|
36
65
|
case 'flex-start':
|
|
@@ -48,6 +77,25 @@ export class FlexManager {
|
|
|
48
77
|
}
|
|
49
78
|
}
|
|
50
79
|
|
|
80
|
+
static reverseItemAlign (value: ItemAlign): string {
|
|
81
|
+
switch (value) {
|
|
82
|
+
case ItemAlign.Start:
|
|
83
|
+
return 'flex-start'
|
|
84
|
+
case ItemAlign.End:
|
|
85
|
+
return 'flex-end'
|
|
86
|
+
case ItemAlign.Center:
|
|
87
|
+
return 'center'
|
|
88
|
+
case ItemAlign.Stretch:
|
|
89
|
+
return 'stretch'
|
|
90
|
+
case ItemAlign.Baseline:
|
|
91
|
+
return 'baseline'
|
|
92
|
+
case ItemAlign.Auto:
|
|
93
|
+
return 'auto'
|
|
94
|
+
default:
|
|
95
|
+
return ''
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
51
99
|
static justifyContent (value: string): FlexAlign {
|
|
52
100
|
return FlexManager.flexAlign(value)
|
|
53
101
|
}
|
|
@@ -61,7 +109,29 @@ export class FlexManager {
|
|
|
61
109
|
}
|
|
62
110
|
|
|
63
111
|
static flexWrap (value: string): FlexWrap {
|
|
64
|
-
|
|
112
|
+
switch (value) {
|
|
113
|
+
case 'nowrap':
|
|
114
|
+
return FlexWrap.NoWrap
|
|
115
|
+
case 'wrap':
|
|
116
|
+
return FlexWrap.Wrap
|
|
117
|
+
case 'wrap-reverse':
|
|
118
|
+
return FlexWrap.WrapReverse
|
|
119
|
+
default:
|
|
120
|
+
return FlexWrap.NoWrap
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
static reverseFlexWrap (value: FlexWrap): string {
|
|
125
|
+
switch (value) {
|
|
126
|
+
case FlexWrap.NoWrap:
|
|
127
|
+
return 'nowrap'
|
|
128
|
+
case FlexWrap.Wrap:
|
|
129
|
+
return 'wrap'
|
|
130
|
+
case FlexWrap.WrapReverse:
|
|
131
|
+
return 'wrap-reverse'
|
|
132
|
+
default:
|
|
133
|
+
return 'nowrap'
|
|
134
|
+
}
|
|
65
135
|
}
|
|
66
136
|
|
|
67
137
|
static alignContent (style: Record<string, string | number> = {}): FlexAlign | undefined {
|
|
@@ -1,25 +1,14 @@
|
|
|
1
1
|
import { bindAttributesCallback } from './info'
|
|
2
2
|
|
|
3
|
-
import type { TaroElement } from '../dom/element'
|
|
3
|
+
import type { TaroElement } from '../dom/element/element'
|
|
4
4
|
|
|
5
5
|
// function convertToCamelCase(str) {
|
|
6
6
|
// return str.replace(/-(.)/g, (_, char) => char.toUpperCase()).replace(/^\w/, firstChar => firstChar.toUpperCase())
|
|
7
7
|
// }
|
|
8
8
|
|
|
9
|
-
export function
|
|
10
|
-
if (!node) return
|
|
11
|
-
|
|
12
|
-
// @ts-ignore
|
|
13
|
-
node._instance = instance
|
|
14
|
-
|
|
15
|
-
// 触发appear,让node监听到TaroNode已经和ete自定义组件绑定上
|
|
16
|
-
// @ts-ignore
|
|
17
|
-
node.resolveAppear?.() // #text node节点没有实现该方法
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export function bindScrollTo (node: TaroElement, instance: any) {
|
|
9
|
+
export function bindScrollTo (node: TaroElement) {
|
|
21
10
|
bindAttributesCallback(node, 'scrollTo', () => {
|
|
22
|
-
|
|
11
|
+
node.scroller.scrollTo({
|
|
23
12
|
xOffset: node._attrs.scrollLeft || 0,
|
|
24
13
|
yOffset: node._attrs.scrollTop || 0,
|
|
25
14
|
})
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
+
import _display from '@ohos.display'
|
|
1
2
|
import { pxTransformHelper } from '@tarojs/taro'
|
|
2
3
|
|
|
3
4
|
import { NodeType } from '../dom/node'
|
|
4
5
|
|
|
5
6
|
import type { CSSProperties } from 'react'
|
|
6
|
-
import type { TaroElement } from '../dom/element'
|
|
7
|
+
import type { TaroElement } from '../dom/element/element'
|
|
7
8
|
import type { TaroNode } from '../dom/node'
|
|
8
9
|
|
|
10
|
+
const display = _display.getDefaultDisplaySync()
|
|
11
|
+
|
|
9
12
|
export function isElement (node: TaroNode): node is TaroElement {
|
|
10
13
|
return node.nodeType === NodeType.ELEMENT_NODE
|
|
11
14
|
}
|
|
@@ -18,7 +21,6 @@ export function isElement (node: TaroNode): node is TaroElement {
|
|
|
18
21
|
export function isParentBinded (node: TaroElement | null, type: string): boolean {
|
|
19
22
|
let res = false
|
|
20
23
|
|
|
21
|
-
// TODO: 当前 node 结构没有 root,因此不作判断,后续可根据情况添加 root 条件
|
|
22
24
|
while (node?.parentElement) {
|
|
23
25
|
if (node.parentElement.__listeners[type]?.length) {
|
|
24
26
|
res = true
|
|
@@ -35,7 +37,10 @@ export function convertNumber2PX (value: number) {
|
|
|
35
37
|
return pxTransformHelper(value, 'vp')
|
|
36
38
|
}
|
|
37
39
|
|
|
38
|
-
export function convertNumber2VP (value: number) {
|
|
40
|
+
export function convertNumber2VP (value: number, unit = 'px') {
|
|
41
|
+
if (unit === 'vw' || unit === 'vh') {
|
|
42
|
+
return (value / 100 * (unit === 'vw' ? display.width: display.height)) + 'px'
|
|
43
|
+
}
|
|
39
44
|
return pxTransformHelper(value, 'vp')
|
|
40
45
|
}
|
|
41
46
|
|
|
@@ -84,10 +89,10 @@ export function bindFn (fn: any, ctx: any, ...args: any) {
|
|
|
84
89
|
|
|
85
90
|
// 使用深度优先遍历寻找节点树中对应的子节点,且只需要找到第一个
|
|
86
91
|
// 通过 selector 判断是 id 还是 selector,从 node 的 id 和 className 属性中寻找
|
|
87
|
-
export function findChildNodeWithDFS<T extends TaroElement> (node: TaroElement, selector: string | ((ele: T) => boolean), selectAll: true):
|
|
88
|
-
export function findChildNodeWithDFS<T extends TaroElement> (node: TaroElement, selector: string | ((ele: T) => boolean), selectAll?: false):
|
|
89
|
-
export function findChildNodeWithDFS<T extends TaroElement> (node: TaroElement, selector: string | ((ele: T) => boolean), selectAll: boolean):
|
|
90
|
-
export function findChildNodeWithDFS<T extends TaroElement> (node: TaroElement, selector: string | ((ele: T) => boolean), selectAll):
|
|
92
|
+
export function findChildNodeWithDFS<T extends TaroElement = TaroElement> (node: TaroElement, selector: string | ((ele: T) => boolean), selectAll: true): T[] | null;
|
|
93
|
+
export function findChildNodeWithDFS<T extends TaroElement = TaroElement> (node: TaroElement, selector: string | ((ele: T) => boolean), selectAll?: false): T | null;
|
|
94
|
+
export function findChildNodeWithDFS<T extends TaroElement = TaroElement> (node: TaroElement, selector: string | ((ele: T) => boolean), selectAll: boolean): T[] | T | null;
|
|
95
|
+
export function findChildNodeWithDFS<T extends TaroElement = TaroElement> (node: TaroElement, selector: string | ((ele: T) => boolean), selectAll): T[] | T | null {
|
|
91
96
|
const queue = [node]
|
|
92
97
|
|
|
93
98
|
const nodeList: TaroElement[] = []
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isFunction } from '@tarojs/shared'
|
|
2
2
|
|
|
3
|
-
import type { TaroElement } from '../dom/element'
|
|
3
|
+
import type { TaroElement } from '../dom/element/element'
|
|
4
4
|
|
|
5
5
|
export const AREA_CHANGE_EVENT_NAME = 'areaChange'
|
|
6
6
|
export const VISIBLE_CHANGE_EVENT_NAME = 'visibleChange'
|
|
@@ -20,34 +20,23 @@ export function createEventTapName (eventName: string) {
|
|
|
20
20
|
export const disconnectEvent = (node: TaroElement, eventName: string) => {
|
|
21
21
|
if (!node) return null
|
|
22
22
|
|
|
23
|
-
const id = node._nid
|
|
24
|
-
const component = node._instance
|
|
25
|
-
|
|
26
23
|
try {
|
|
27
|
-
|
|
24
|
+
node._nodeInfo.eventMap[createEventTapName(eventName)] = false
|
|
28
25
|
} catch (e) {
|
|
29
26
|
console.warn(`disconnectEvent ${eventName} error: `, e)
|
|
30
27
|
}
|
|
31
28
|
}
|
|
32
29
|
|
|
33
|
-
export function getComponentEventCallback (node: TaroElement, eventName: string, callback?: (data:
|
|
34
|
-
if (!node
|
|
35
|
-
|
|
36
|
-
const id = node._nid
|
|
37
|
-
const component = node?._instance
|
|
30
|
+
export function getComponentEventCallback (node: TaroElement, eventName: string, callback?: (data: any) => void) {
|
|
31
|
+
if (!node) return null
|
|
38
32
|
|
|
39
|
-
if (
|
|
33
|
+
if (node._nodeInfo?.eventMap?.[createEventTapName(eventName)]) {
|
|
40
34
|
return (...eventResult: any[]) => {
|
|
41
|
-
if (!
|
|
35
|
+
if (!node._nodeInfo?.eventMap?.[createEventTapName(eventName)]) return
|
|
42
36
|
|
|
43
|
-
|
|
44
|
-
component,
|
|
45
|
-
eventResult
|
|
46
|
-
}
|
|
37
|
+
callback && callback(eventResult)
|
|
47
38
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
node?.[createEventOnName(eventName)]?.(res)
|
|
39
|
+
node?.[createEventOnName(eventName)]?.(eventResult)
|
|
51
40
|
}
|
|
52
41
|
}
|
|
53
42
|
|
|
@@ -56,33 +45,25 @@ export function getComponentEventCallback (node: TaroElement, eventName: string,
|
|
|
56
45
|
|
|
57
46
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
58
47
|
function tapCallbackToNodeAndUpdate (node: TaroElement, eventName: string, callback: Function) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
node._instance.nodeInfoMap[id].eventMap[createEventTapName(eventName)] = true
|
|
62
|
-
node[createEventOnName(eventName)] = ({ eventResult }) => {
|
|
48
|
+
node._nodeInfo.eventMap[createEventTapName(eventName)] = true
|
|
49
|
+
node[createEventOnName(eventName)] = (eventResult) => {
|
|
63
50
|
callback && callback(...eventResult)
|
|
64
51
|
}
|
|
65
52
|
|
|
66
|
-
|
|
67
|
-
if (!node._isDynamicNode && node._isCompileMode) {
|
|
68
|
-
node.updateComponent()
|
|
69
|
-
}
|
|
53
|
+
node.updateComponent()
|
|
70
54
|
}
|
|
71
55
|
|
|
72
56
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
73
57
|
export async function setNodeEventCallbackAndTriggerComponentUpdate (node: TaroElement, eventName: string, callback: Function, isAsync = false) {
|
|
74
|
-
const id = node._nid
|
|
75
|
-
const instance = node._instance
|
|
76
|
-
|
|
77
58
|
if (isAsync) {
|
|
78
59
|
// 阻塞函数执行,等待监听节点绑定上的回调函数
|
|
79
|
-
if (!
|
|
60
|
+
if (!node._nodeInfo.eventMap[createEventTapName(eventName)]) {
|
|
80
61
|
let onEventPromiseResolve
|
|
81
62
|
const eventPromise = new Promise(resolve => {
|
|
82
63
|
onEventPromiseResolve = resolve
|
|
83
64
|
})
|
|
84
65
|
|
|
85
|
-
|
|
66
|
+
node._nodeInfo.promiseMap[eventName] = eventPromise
|
|
86
67
|
tapCallbackToNodeAndUpdate(node, eventName, (...eventResult) => {
|
|
87
68
|
callback && callback(...eventResult)
|
|
88
69
|
|
|
@@ -90,39 +71,30 @@ export async function setNodeEventCallbackAndTriggerComponentUpdate (node: TaroE
|
|
|
90
71
|
})
|
|
91
72
|
}
|
|
92
73
|
|
|
93
|
-
await
|
|
74
|
+
await node._nodeInfo.promiseMap[eventName]
|
|
94
75
|
} else {
|
|
95
76
|
tapCallbackToNodeAndUpdate(node, eventName, callback)
|
|
96
77
|
}
|
|
97
78
|
}
|
|
98
79
|
|
|
99
80
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
100
|
-
export function bindAttributesCallback (node: TaroElement,
|
|
81
|
+
export function bindAttributesCallback (node: TaroElement, _: string, callback: Function) {
|
|
101
82
|
if (!node) return
|
|
102
83
|
|
|
103
|
-
|
|
104
|
-
const component = node._instance
|
|
105
|
-
|
|
106
|
-
component.nodeInfoMap[id].attributeCallback[attributeName] = callback
|
|
84
|
+
node._nodeInfo = callback
|
|
107
85
|
}
|
|
108
86
|
|
|
109
87
|
export function triggerAttributesCallback (node, attributeName) {
|
|
110
88
|
if (!node) return
|
|
111
89
|
|
|
112
|
-
const id = node._nid
|
|
113
90
|
const value = node._attrs[attributeName]
|
|
114
|
-
|
|
115
|
-
return node.awaitAppear.then(() => {
|
|
116
|
-
const component = node._instance
|
|
117
|
-
const cb = component.nodeInfoMap[id].attributeCallback[attributeName]
|
|
91
|
+
const cb = node._nodeInfo.attributeCallback[attributeName]
|
|
118
92
|
|
|
119
|
-
|
|
120
|
-
})
|
|
93
|
+
isFunction(cb) && cb(value)
|
|
121
94
|
}
|
|
122
95
|
|
|
123
|
-
export function initComponentNodeInfo (
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
component.nodeInfoMap[node._nid].attributeCallback = {}
|
|
96
|
+
export function initComponentNodeInfo (node: TaroElement) {
|
|
97
|
+
node._nodeInfo.eventMap = {}
|
|
98
|
+
node._nodeInfo.promiseMap = {}
|
|
99
|
+
node._nodeInfo.attributeCallback = {}
|
|
128
100
|
}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
// eslint-disable-
|
|
2
|
-
import {
|
|
3
|
-
// eslint-disable-next-line import/no-duplicates
|
|
4
|
-
import { eventCenter } from '@tarojs/runtime/dist/runtime.esm'
|
|
1
|
+
import { Current, document } from '@tarojs/runtime' // eslint-disable-line import/no-duplicates
|
|
2
|
+
import { eventCenter } from '@tarojs/runtime/dist/runtime.esm' // eslint-disable-line import/no-duplicates
|
|
5
3
|
|
|
6
4
|
import { setReconciler } from './connect'
|
|
7
5
|
import { injectPageInstance } from './page'
|
|
@@ -69,7 +67,6 @@ export function connectReactPage (
|
|
|
69
67
|
...refs
|
|
70
68
|
}))
|
|
71
69
|
|
|
72
|
-
// TODO root
|
|
73
70
|
return h(
|
|
74
71
|
'view',
|
|
75
72
|
{ id, className: 'taro_page' },
|
|
@@ -212,7 +209,7 @@ export function createReactApp (
|
|
|
212
209
|
|
|
213
210
|
app.onCreate?.()
|
|
214
211
|
}
|
|
215
|
-
|
|
212
|
+
|
|
216
213
|
eventCenter.trigger('__taroRouterLaunch', launchParam)
|
|
217
214
|
})
|
|
218
215
|
},
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
// eslint-disable-
|
|
2
|
-
import {
|
|
3
|
-
// eslint-disable-next-line import/no-duplicates
|
|
4
|
-
import { CONTEXT_ACTIONS, env, eventCenter } from '@tarojs/runtime/dist/runtime.esm'
|
|
1
|
+
import { Current, document, requestAnimationFrame, window } from '@tarojs/runtime' // eslint-disable-line import/no-duplicates
|
|
2
|
+
import { CONTEXT_ACTIONS, env, eventCenter } from '@tarojs/runtime/dist/runtime.esm' // eslint-disable-line import/no-duplicates
|
|
5
3
|
import { hooks, isArray, isFunction, isUndefined } from '@tarojs/shared'
|
|
6
4
|
|
|
7
5
|
import { ON_HIDE, ON_LOAD, ON_READY, ON_SHOW, ON_UNLOAD } from './constant'
|
|
@@ -9,17 +7,14 @@ import { incrementId } from './utils'
|
|
|
9
7
|
|
|
10
8
|
import type { PageConfig } from '@tarojs/taro'
|
|
11
9
|
|
|
12
|
-
// TODO TYPE
|
|
13
10
|
const instances = new Map<string, any>()
|
|
14
11
|
const pageId = incrementId()
|
|
15
12
|
|
|
16
|
-
// TODO TYPE
|
|
17
13
|
export function injectPageInstance (inst: any, id: string) {
|
|
18
14
|
hooks.call('mergePageInstance', instances.get(id), inst)
|
|
19
15
|
instances.set(id, inst)
|
|
20
16
|
}
|
|
21
17
|
|
|
22
|
-
// TODO TYPE
|
|
23
18
|
export function getPageInstance (id: string): any {
|
|
24
19
|
return instances.get(id)
|
|
25
20
|
}
|
|
@@ -98,12 +93,10 @@ export function createPageConfig (component: any, pageName?: string, pageConfig?
|
|
|
98
93
|
SIDE_EFFECT_LIFECYCLES,
|
|
99
94
|
] = hooks.call('getMiniLifecycleImpl')!.page
|
|
100
95
|
|
|
101
|
-
// TODO TYPE
|
|
102
96
|
let pageElement: any = null
|
|
103
97
|
let unmounting = false
|
|
104
98
|
let prepareMountList: (() => void)[] = []
|
|
105
99
|
|
|
106
|
-
// TODO TYPE
|
|
107
100
|
function setCurrentRouter (page) {
|
|
108
101
|
const router = page.route || page.__route__ || page.$taroPath
|
|
109
102
|
|