@octane-xplat/nativescript-mason-core 0.0.1 → 1.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/LICENSE +201 -0
- package/README.md +113 -2
- package/artifact-inventory.json +746 -0
- package/box-shadow.d.ts +10 -0
- package/box-shadow.js +48 -0
- package/common.d.ts +482 -0
- package/common.js +2645 -0
- package/css-colors.d.ts +17 -0
- package/css-colors.js +54 -0
- package/css-filter.d.ts +17 -0
- package/css-filter.js +140 -0
- package/css-keyframes.d.ts +41 -0
- package/css-keyframes.js +437 -0
- package/css-math.d.ts +34 -0
- package/css-math.js +300 -0
- package/css-shorthands.d.ts +65 -0
- package/css-shorthands.js +673 -0
- package/css-transform.d.ts +6 -0
- package/css-transform.js +100 -0
- package/diagnostics.d.ts +51 -0
- package/diagnostics.js +52 -0
- package/display-density.d.ts +9 -0
- package/display-density.js +20 -0
- package/fonts.d.ts +20 -0
- package/fonts.js +88 -0
- package/foreign-layout.d.ts +6 -0
- package/foreign-layout.js +149 -0
- package/gradient-stops.d.ts +25 -0
- package/gradient-stops.js +112 -0
- package/index.android.d.ts +9 -0
- package/index.android.js +8 -0
- package/index.d.ts +10 -0
- package/index.ios.d.ts +9 -0
- package/index.ios.js +8 -0
- package/ios-host-README.md +124 -0
- package/layout-types.d.ts +192 -0
- package/mask.d.ts +54 -0
- package/mask.js +26 -0
- package/native-types-README.md +51 -0
- package/package.json +44 -6
- package/panel-helpers.d.ts +3 -0
- package/panel-helpers.js +8 -0
- package/platforms/android/MasonCore.aar +0 -0
- package/platforms/android/include.gradle +6 -0
- package/platforms/android/manifest.json +73 -0
- package/platforms/ios/FontManager.LICENSE +201 -0
- package/platforms/ios/MasonCore.xcframework/Info.plist +43 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64/MasonCore.framework/Headers/Mason.h +25 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64/MasonCore.framework/Headers/MasonCore-Swift.h +1739 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64/MasonCore.framework/Headers/mason_native.h +601 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64/MasonCore.framework/Info.plist +0 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64/MasonCore.framework/MasonCore +0 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64/MasonCore.framework/Modules/MasonCore.swiftmodule/Project/arm64-apple-ios.swiftsourceinfo +0 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64/MasonCore.framework/Modules/MasonCore.swiftmodule/arm64-apple-ios.abi.json +100095 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64/MasonCore.framework/Modules/MasonCore.swiftmodule/arm64-apple-ios.private.swiftinterface +3174 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64/MasonCore.framework/Modules/MasonCore.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64/MasonCore.framework/Modules/MasonCore.swiftmodule/arm64-apple-ios.swiftinterface +3174 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64/MasonCore.framework/Modules/module.modulemap +9 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64/MasonCore.framework/SDWebImage_SDWebImage.bundle/Info.plist +0 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64/MasonCore.framework/SDWebImage_SDWebImage.bundle/PrivacyInfo.xcprivacy +23 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64-simulator/MasonCore.framework/Headers/Mason.h +25 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64-simulator/MasonCore.framework/Headers/MasonCore-Swift.h +1739 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64-simulator/MasonCore.framework/Headers/mason_native.h +601 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64-simulator/MasonCore.framework/Info.plist +0 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64-simulator/MasonCore.framework/MasonCore +0 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64-simulator/MasonCore.framework/Modules/MasonCore.swiftmodule/Project/arm64-apple-ios-simulator.swiftsourceinfo +0 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64-simulator/MasonCore.framework/Modules/MasonCore.swiftmodule/arm64-apple-ios-simulator.abi.json +100095 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64-simulator/MasonCore.framework/Modules/MasonCore.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +3174 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64-simulator/MasonCore.framework/Modules/MasonCore.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64-simulator/MasonCore.framework/Modules/MasonCore.swiftmodule/arm64-apple-ios-simulator.swiftinterface +3174 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64-simulator/MasonCore.framework/Modules/module.modulemap +9 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64-simulator/MasonCore.framework/SDWebImage_SDWebImage.bundle/Info.plist +0 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64-simulator/MasonCore.framework/SDWebImage_SDWebImage.bundle/PrivacyInfo.xcprivacy +23 -0
- package/platforms/ios/Package.resolved +24 -0
- package/platforms/ios/SDWebImage.LICENSE +20 -0
- package/platforms/ios/build.xcconfig +4 -0
- package/platforms/ios/device-manifest.json +213 -0
- package/platforms/ios/include/FontManager/NSCFontDescriptors.h +36 -0
- package/platforms/ios/include/FontManager/NSCFontFace.h +98 -0
- package/platforms/ios/include/FontManager/NSCFontFaceSet.h +73 -0
- package/platforms/ios/include/FontManager/NSCFontManagerUmbrella.h +7 -0
- package/platforms/ios/include/FontManager/NSCFontParser.h +22 -0
- package/platforms/ios/include/FontManager/NSCFontRegex.h +4 -0
- package/platforms/ios/include/FontManager/NSCFontResolver.h +43 -0
- package/platforms/ios/include/FontManager/NSCFontStyle.h +27 -0
- package/platforms/ios/include/FontManager/NSCFontTypes.h +41 -0
- package/platforms/ios/include/SDWebImage/NSButton+WebCache.h +340 -0
- package/platforms/ios/include/SDWebImage/NSData+ImageContentType.h +63 -0
- package/platforms/ios/include/SDWebImage/NSImage+Compatibility.h +67 -0
- package/platforms/ios/include/SDWebImage/SDAnimatedImage.h +136 -0
- package/platforms/ios/include/SDWebImage/SDAnimatedImagePlayer.h +113 -0
- package/platforms/ios/include/SDWebImage/SDAnimatedImageRep.h +33 -0
- package/platforms/ios/include/SDWebImage/SDAnimatedImageView+WebCache.h +168 -0
- package/platforms/ios/include/SDWebImage/SDAnimatedImageView.h +125 -0
- package/platforms/ios/include/SDWebImage/SDCallbackQueue.h +59 -0
- package/platforms/ios/include/SDWebImage/SDDiskCache.h +146 -0
- package/platforms/ios/include/SDWebImage/SDGraphicsImageRenderer.h +84 -0
- package/platforms/ios/include/SDWebImage/SDImageAPNGCoder.h +19 -0
- package/platforms/ios/include/SDWebImage/SDImageAWebPCoder.h +23 -0
- package/platforms/ios/include/SDWebImage/SDImageCache.h +482 -0
- package/platforms/ios/include/SDWebImage/SDImageCacheConfig.h +153 -0
- package/platforms/ios/include/SDWebImage/SDImageCacheDefine.h +179 -0
- package/platforms/ios/include/SDWebImage/SDImageCachesManager.h +81 -0
- package/platforms/ios/include/SDWebImage/SDImageCoder.h +347 -0
- package/platforms/ios/include/SDWebImage/SDImageCoderHelper.h +251 -0
- package/platforms/ios/include/SDWebImage/SDImageCodersManager.h +58 -0
- package/platforms/ios/include/SDWebImage/SDImageFrame.h +44 -0
- package/platforms/ios/include/SDWebImage/SDImageGIFCoder.h +22 -0
- package/platforms/ios/include/SDWebImage/SDImageGraphics.h +28 -0
- package/platforms/ios/include/SDWebImage/SDImageHEICCoder.h +25 -0
- package/platforms/ios/include/SDWebImage/SDImageIOAnimatedCoder.h +65 -0
- package/platforms/ios/include/SDWebImage/SDImageIOCoder.h +30 -0
- package/platforms/ios/include/SDWebImage/SDImageLoader.h +146 -0
- package/platforms/ios/include/SDWebImage/SDImageLoadersManager.h +40 -0
- package/platforms/ios/include/SDWebImage/SDImageTransformer.h +283 -0
- package/platforms/ios/include/SDWebImage/SDMemoryCache.h +78 -0
- package/platforms/ios/include/SDWebImage/SDWebImage.h +91 -0
- package/platforms/ios/include/SDWebImage/SDWebImageCacheKeyFilter.h +35 -0
- package/platforms/ios/include/SDWebImage/SDWebImageCacheSerializer.h +39 -0
- package/platforms/ios/include/SDWebImage/SDWebImageCompat.h +102 -0
- package/platforms/ios/include/SDWebImage/SDWebImageDefine.h +420 -0
- package/platforms/ios/include/SDWebImage/SDWebImageDownloader.h +320 -0
- package/platforms/ios/include/SDWebImage/SDWebImageDownloaderConfig.h +113 -0
- package/platforms/ios/include/SDWebImage/SDWebImageDownloaderDecryptor.h +52 -0
- package/platforms/ios/include/SDWebImage/SDWebImageDownloaderOperation.h +191 -0
- package/platforms/ios/include/SDWebImage/SDWebImageDownloaderRequestModifier.h +72 -0
- package/platforms/ios/include/SDWebImage/SDWebImageDownloaderResponseModifier.h +72 -0
- package/platforms/ios/include/SDWebImage/SDWebImageError.h +33 -0
- package/platforms/ios/include/SDWebImage/SDWebImageIndicator.h +119 -0
- package/platforms/ios/include/SDWebImage/SDWebImageManager.h +290 -0
- package/platforms/ios/include/SDWebImage/SDWebImageOperation.h +27 -0
- package/platforms/ios/include/SDWebImage/SDWebImageOptionsProcessor.h +78 -0
- package/platforms/ios/include/SDWebImage/SDWebImagePrefetcher.h +168 -0
- package/platforms/ios/include/SDWebImage/SDWebImageTransition.h +131 -0
- package/platforms/ios/include/SDWebImage/UIButton+WebCache.h +402 -0
- package/platforms/ios/include/SDWebImage/UIImage+ExtendedCacheData.h +24 -0
- package/platforms/ios/include/SDWebImage/UIImage+ForceDecode.h +52 -0
- package/platforms/ios/include/SDWebImage/UIImage+GIF.h +26 -0
- package/platforms/ios/include/SDWebImage/UIImage+MemoryCacheCost.h +27 -0
- package/platforms/ios/include/SDWebImage/UIImage+Metadata.h +104 -0
- package/platforms/ios/include/SDWebImage/UIImage+MultiFormat.h +81 -0
- package/platforms/ios/include/SDWebImage/UIImage+Transform.h +164 -0
- package/platforms/ios/include/SDWebImage/UIImageView+HighlightedWebCache.h +142 -0
- package/platforms/ios/include/SDWebImage/UIImageView+WebCache.h +209 -0
- package/platforms/ios/include/SDWebImage/UIView+WebCache.h +131 -0
- package/platforms/ios/include/SDWebImage/UIView+WebCacheOperation.h +52 -0
- package/platforms/ios/include/SDWebImage/UIView+WebCacheState.h +63 -0
- package/platforms/ios/include/module.modulemap +2 -0
- package/platforms/ios/manifest.json +132 -0
- package/platforms/ios/simulator-manifest.json +213 -0
- package/plugin-README.md +197 -0
- package/properties.d.ts +154 -0
- package/properties.js +2454 -0
- package/pseudo.d.ts +9 -0
- package/pseudo.js +57 -0
- package/scroll/index.android.d.ts +15 -0
- package/scroll/index.android.js +72 -0
- package/scroll/index.d.ts +5 -0
- package/scroll/index.ios.d.ts +18 -0
- package/scroll/index.ios.js +106 -0
- package/style.d.ts +768 -0
- package/style.js +7151 -0
- package/symbols.d.ts +25 -0
- package/symbols.js +41 -0
- package/tree/index.android.d.ts +11 -0
- package/tree/index.android.js +42 -0
- package/tree/index.d.ts +15 -0
- package/tree/index.ios.d.ts +26 -0
- package/tree/index.ios.js +53 -0
- package/typings/android-declarations.d.ts +4 -0
- package/typings/android.d.ts +9730 -0
- package/typings/manifest.json +45 -0
- package/typings/native.d.ts +5 -0
- package/typings/objc!FontManager.d.ts +389 -0
- package/typings/objc!MasonCore.d.ts +2472 -0
- package/typings/objc!SDWebImage.d.ts +3378 -0
- package/units.d.ts +29 -0
- package/units.js +44 -0
- package/utils/index.android.d.ts +211 -0
- package/utils/index.android.js +595 -0
- package/utils/index.ios.d.ts +222 -0
- package/utils/index.ios.js +790 -0
- package/view/index.android.d.ts +13 -0
- package/view/index.android.js +74 -0
- package/view/index.d.ts +2 -0
- package/view/index.ios.d.ts +24 -0
- package/view/index.ios.js +157 -0
package/common.js
ADDED
|
@@ -0,0 +1,2645 @@
|
|
|
1
|
+
var _a, _b, _c, _d;
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
3
|
+
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
4
|
+
import { CustomLayoutView, Utils, View as NSView, getViewById, widthProperty, heightProperty, marginLeftProperty, marginRightProperty, marginTopProperty, marginBottomProperty, minWidthProperty, minHeightProperty, fontSizeProperty, fontWeightProperty, fontStyleProperty, colorProperty, Color, lineHeightProperty, letterSpacingProperty, textAlignmentProperty, textDecorationProperty, borderLeftWidthProperty, borderTopWidthProperty, borderRightWidthProperty, borderBottomWidthProperty, backgroundColorProperty, paddingLeftProperty, paddingRightProperty, paddingTopProperty, paddingBottomProperty, zIndexProperty, directionProperty, PseudoClassHandler, } from '@nativescript/core';
|
|
5
|
+
import { alignItemsProperty, alignSelfProperty, flexDirectionProperty, flexGrowProperty, flexShrinkProperty, flexWrapProperty, justifyContentProperty } from '@nativescript/core/ui/layouts/flexbox-layout';
|
|
6
|
+
// The per-corner radius and per-side colour longhands core's `border-radius`
|
|
7
|
+
// / `border-color` shorthands expand into. They live in the styling module
|
|
8
|
+
// rather than core's root export, unlike the border *width* longhands above.
|
|
9
|
+
import { backgroundInternalProperty, borderTopLeftRadiusProperty, borderTopRightRadiusProperty, borderBottomRightRadiusProperty, borderBottomLeftRadiusProperty, borderTopColorProperty, borderRightColorProperty, borderBottomColorProperty, borderLeftColorProperty } from '@nativescript/core/ui/styling/style-properties';
|
|
10
|
+
import { _forceStyleUpdate } from './utils';
|
|
11
|
+
import { borderRadiusCorners, composeBorderRadius, isCssLength, parseCornerRadius, toCamelCase } from './css-shorthands';
|
|
12
|
+
import { originXProperty, originYProperty } from '@nativescript/core/ui/core/view';
|
|
13
|
+
import { animateTransforms } from './css-keyframes';
|
|
14
|
+
import { adoptForeignLayout, invalidateOnLayoutRequest, releaseForeignLayout } from './foreign-layout';
|
|
15
|
+
import { Style, nodeHelper, cssLengthToDip, resolveCssMathIn } from './style';
|
|
16
|
+
import { encodeBoxShadows, parseBoxShadows } from './box-shadow';
|
|
17
|
+
import { parseCssTransform } from './css-transform';
|
|
18
|
+
import { alignContentProperty, aspectRatioProperty, backgroundProperty, borderRadiusProperty, bottomProperty, boxSizingProperty, clearProperty, columnGapProperty, cornerShapeProperty, displayProperty, filterProperty, flexBasisProperty, floatProperty, gridAreaProperty, gridAutoColumnsProperty, gridAutoFlowProperty, gridAutoRowsProperty, gridColumnEndProperty, gridColumnProperty, gridColumnStartProperty, gridRowEndProperty, gridRowProperty, gridRowStartProperty, gridTemplateAreasProperty, gridTemplateColumnsProperty, gridTemplateRowsProperty, justifyItemsProperty, justifySelfProperty, leftProperty, marginProperty, maxHeightProperty, maxWidthProperty, overflowXProperty, overflowYProperty, paddingProperty, positionProperty, rightProperty, rowGapProperty, scrollBarWidthProperty, textOverFlowProperty, textWrapProperty, topProperty, verticalAlignProperty, boxShadowProperty, transformProperty, borderColorProperty, borderTopStyleProperty, borderRightStyleProperty, borderBottomStyleProperty, borderLeftStyleProperty, backgroundImageProperty, listStyleTypeProperty, listStylePositionProperty, installMasonSizeUnits, masonRawDeclaration, } from './properties';
|
|
19
|
+
import { masonLayout } from './display-density';
|
|
20
|
+
import { isMasonView_, isTextChild_, isText_, isPlaceholder_, native_, pseudoStyles_, borderRadiusCorners_, borderSideColors_, eventType_, touchAction_ } from './symbols';
|
|
21
|
+
import { Tree } from './tree';
|
|
22
|
+
import { masonEngine } from './panel-helpers';
|
|
23
|
+
import { compile } from './pseudo';
|
|
24
|
+
function getViewStyle(view) {
|
|
25
|
+
const ret = (__ANDROID__ ? view.get() : view.deref());
|
|
26
|
+
return ret._styleHelper;
|
|
27
|
+
}
|
|
28
|
+
function getWeakRefValue(value) {
|
|
29
|
+
if (!value)
|
|
30
|
+
return null;
|
|
31
|
+
const maybeWeakRef = value;
|
|
32
|
+
if (typeof maybeWeakRef.get === 'function')
|
|
33
|
+
return maybeWeakRef.get();
|
|
34
|
+
if (typeof maybeWeakRef.deref === 'function')
|
|
35
|
+
return maybeWeakRef.deref();
|
|
36
|
+
return value;
|
|
37
|
+
}
|
|
38
|
+
function nativeOwnerFor(nativeView) {
|
|
39
|
+
return getWeakRefValue(nativeView?.__masonOwner);
|
|
40
|
+
}
|
|
41
|
+
function nativeViewFor(owner) {
|
|
42
|
+
return owner?.nativeViewProtected ?? owner?.[native_];
|
|
43
|
+
}
|
|
44
|
+
function masonNativeEventName(eventName) {
|
|
45
|
+
switch (eventName) {
|
|
46
|
+
case 'tap':
|
|
47
|
+
case 'click':
|
|
48
|
+
return 'click';
|
|
49
|
+
case 'beforeinput':
|
|
50
|
+
case 'input':
|
|
51
|
+
case 'change':
|
|
52
|
+
case 'cancel':
|
|
53
|
+
case 'compositionstart':
|
|
54
|
+
case 'compositionupdate':
|
|
55
|
+
case 'compositionend':
|
|
56
|
+
case 'focus':
|
|
57
|
+
case 'blur':
|
|
58
|
+
case 'keydown':
|
|
59
|
+
case 'scroll':
|
|
60
|
+
case 'scrollend':
|
|
61
|
+
return eventName;
|
|
62
|
+
default:
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
const SCROLL_POSITIONS = { start: 0, center: 1, end: 2, nearest: 3 };
|
|
67
|
+
// Scroll offsets and sizes are read from the native view on demand, in CSS pixels.
|
|
68
|
+
function nativeScrollOffset(view, vertical) {
|
|
69
|
+
const native = view[native_];
|
|
70
|
+
if (!native)
|
|
71
|
+
return 0;
|
|
72
|
+
if (__ANDROID__) {
|
|
73
|
+
const scroll = org.nativescript.mason.masonkit.WebScroll;
|
|
74
|
+
return masonLayout.toDeviceIndependentPixels(vertical ? scroll.scrollTop(native) : scroll.scrollLeft(native));
|
|
75
|
+
}
|
|
76
|
+
if (__APPLE__) {
|
|
77
|
+
return (vertical ? native.mason_scrollTop : native.mason_scrollLeft) ?? 0;
|
|
78
|
+
}
|
|
79
|
+
if (false) {
|
|
80
|
+
return (vertical ? masonEngine().ScrollTop(native) : masonEngine().ScrollLeft(native)) ?? 0;
|
|
81
|
+
}
|
|
82
|
+
return 0;
|
|
83
|
+
}
|
|
84
|
+
function nativeScrollMetric(view, metric) {
|
|
85
|
+
const native = view[native_];
|
|
86
|
+
if (!native)
|
|
87
|
+
return 0;
|
|
88
|
+
let value = 0;
|
|
89
|
+
if (__ANDROID__) {
|
|
90
|
+
value = masonLayout.toDeviceIndependentPixels(org.nativescript.mason.masonkit.WebScroll[metric](native));
|
|
91
|
+
}
|
|
92
|
+
else if (__APPLE__) {
|
|
93
|
+
value = native[`mason_${metric}`];
|
|
94
|
+
}
|
|
95
|
+
else if (false) {
|
|
96
|
+
value = masonEngine()[metric.charAt(0).toUpperCase() + metric.slice(1)](native);
|
|
97
|
+
}
|
|
98
|
+
// Whole pixels, as on the web.
|
|
99
|
+
return Math.round(value || 0);
|
|
100
|
+
}
|
|
101
|
+
/** NaN keeps an axis. Before the native view exists, the request is kept for `initNativeView`. */
|
|
102
|
+
function nativeScrollTo(view, left, top, smooth) {
|
|
103
|
+
const native = view[native_];
|
|
104
|
+
if (!native) {
|
|
105
|
+
const pending = (view._masonPendingScroll ?? (view._masonPendingScroll = { left: NaN, top: NaN, smooth }));
|
|
106
|
+
if (!isNaN(left))
|
|
107
|
+
pending.left = left;
|
|
108
|
+
if (!isNaN(top))
|
|
109
|
+
pending.top = top;
|
|
110
|
+
pending.smooth = smooth;
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
if (__ANDROID__) {
|
|
114
|
+
org.nativescript.mason.masonkit.WebScroll.scrollTo(native, isNaN(left) ? NaN : masonLayout.toDevicePixels(left), isNaN(top) ? NaN : masonLayout.toDevicePixels(top), smooth);
|
|
115
|
+
}
|
|
116
|
+
else if (__APPLE__) {
|
|
117
|
+
native.mason_scrollTo(left, top, smooth);
|
|
118
|
+
}
|
|
119
|
+
else if (false) {
|
|
120
|
+
masonEngine().ScrollTo(native, left, top, smooth);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
/** Non-finite scroll coordinates become 0, as on the web. */
|
|
124
|
+
function scrollCoordinate(value) {
|
|
125
|
+
const n = Number(value);
|
|
126
|
+
return Number.isFinite(n) ? n : 0;
|
|
127
|
+
}
|
|
128
|
+
function findOwnerForNativeView(owner, nativeView) {
|
|
129
|
+
if (!owner || !nativeView)
|
|
130
|
+
return null;
|
|
131
|
+
const ownNativeView = nativeViewFor(owner);
|
|
132
|
+
if (ownNativeView === nativeView || owner?.[native_] === nativeView)
|
|
133
|
+
return owner;
|
|
134
|
+
const children = owner._children ?? owner._viewChildren;
|
|
135
|
+
if (!children)
|
|
136
|
+
return null;
|
|
137
|
+
for (const child of children) {
|
|
138
|
+
const match = findOwnerForNativeView(child, nativeView);
|
|
139
|
+
if (match)
|
|
140
|
+
return match;
|
|
141
|
+
}
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
function masonLength(value) {
|
|
145
|
+
return isCssLength(value) ? value.css : value;
|
|
146
|
+
}
|
|
147
|
+
/** A core `Length` (number of dip, or `{ value, unit }`) as a CSS string. */
|
|
148
|
+
function lengthToCssString(value) {
|
|
149
|
+
if (value == null) {
|
|
150
|
+
return '0';
|
|
151
|
+
}
|
|
152
|
+
if (typeof value === 'string') {
|
|
153
|
+
return value;
|
|
154
|
+
}
|
|
155
|
+
if (typeof value === 'number') {
|
|
156
|
+
return `${value}px`;
|
|
157
|
+
}
|
|
158
|
+
const unit = value.unit;
|
|
159
|
+
const amount = value.value ?? 0;
|
|
160
|
+
return unit === '%' ? `${amount * 100}%` : `${amount}px`;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* A core colour value as a CSS string. Duck-typed rather than
|
|
164
|
+
* `instanceof Color` on purpose: a `Color` can arrive from a different
|
|
165
|
+
* `@nativescript/core` copy, where `instanceof` fails.
|
|
166
|
+
*/
|
|
167
|
+
function colorToCssString(value) {
|
|
168
|
+
if (value == null) {
|
|
169
|
+
return 'transparent';
|
|
170
|
+
}
|
|
171
|
+
if (typeof value === 'string') {
|
|
172
|
+
return value;
|
|
173
|
+
}
|
|
174
|
+
const hex = value.hex;
|
|
175
|
+
if (typeof hex === 'string') {
|
|
176
|
+
return hex;
|
|
177
|
+
}
|
|
178
|
+
return String(value);
|
|
179
|
+
}
|
|
180
|
+
function backgroundImageToCssString(value) {
|
|
181
|
+
const gradient = value;
|
|
182
|
+
if (value && typeof value === 'object' && typeof gradient.angle === 'number' && Array.isArray(gradient.colorStops)) {
|
|
183
|
+
const stops = gradient.colorStops.map((stop) => (stop.offset ? `${colorToCssString(stop.color)} ${stop.offset.value * 100}%` : colorToCssString(stop.color)));
|
|
184
|
+
return `linear-gradient(${gradient.angle}rad, ${stops.join(', ')})`;
|
|
185
|
+
}
|
|
186
|
+
return value == null ? 'none' : String(value);
|
|
187
|
+
}
|
|
188
|
+
// Windows raises no pressed state natively, so :active follows the pointer, as core's Button does.
|
|
189
|
+
const WINDOWS_ACTIVE_STATES = ['active', 'highlighted'];
|
|
190
|
+
function onWindowsActiveTouch(args) {
|
|
191
|
+
if (args.action === 'down') {
|
|
192
|
+
for (const state of WINDOWS_ACTIVE_STATES)
|
|
193
|
+
args.object._addVisualState(state);
|
|
194
|
+
}
|
|
195
|
+
else if (args.action === 'up' || args.action === 'cancel') {
|
|
196
|
+
clearWindowsActive(args.object);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
// Core's touch gesture reports no cancel, and a release outside the view isn't delivered to it.
|
|
200
|
+
function onWindowsActiveLeave(args) {
|
|
201
|
+
clearWindowsActive(args.object);
|
|
202
|
+
}
|
|
203
|
+
function clearWindowsActive(view) {
|
|
204
|
+
for (const state of WINDOWS_ACTIVE_STATES)
|
|
205
|
+
view._removeVisualState(state);
|
|
206
|
+
}
|
|
207
|
+
function onWindowsHoverEnter(args) {
|
|
208
|
+
args.object._addVisualState('hover');
|
|
209
|
+
}
|
|
210
|
+
function onWindowsHoverLeave(args) {
|
|
211
|
+
args.object._removeVisualState('hover');
|
|
212
|
+
}
|
|
213
|
+
function onWindowsFocus() {
|
|
214
|
+
this._addVisualState('focus');
|
|
215
|
+
}
|
|
216
|
+
function onWindowsBlur() {
|
|
217
|
+
this._removeVisualState('focus');
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* iOS: sets the frame of a Mason root, a Mason view whose parent is a core view. Core leaves
|
|
221
|
+
* the safe area to each view (`View._modifyNativeViewFrame`), so the root honours
|
|
222
|
+
* `iosOverflowSafeArea` the same way: when the frame grows past the safe area it lays out
|
|
223
|
+
* again at the new size. Like core views, it raises `layoutChanged` when the frame changes.
|
|
224
|
+
*/
|
|
225
|
+
/** Reports the device px size `mason_measure` returns, packed as width * 2^24 + height. */
|
|
226
|
+
export function setMeasuredFromNative(view, packed) {
|
|
227
|
+
const width = Math.floor(packed / 16777216);
|
|
228
|
+
view.setMeasuredDimension(width, packed - width * 16777216);
|
|
229
|
+
}
|
|
230
|
+
export function setRootNativeViewFrame(view, nativeView, frame) {
|
|
231
|
+
// Place the view before adjusting, as core does: the safe-area math reads its
|
|
232
|
+
// position on screen, and a stale one applied the insets twice.
|
|
233
|
+
nativeView.frame = frame;
|
|
234
|
+
const adjusted = view.applySafeAreaInsets(frame) ?? frame;
|
|
235
|
+
if (!CGRectEqualToRect(adjusted, frame)) {
|
|
236
|
+
nativeView.frame = adjusted;
|
|
237
|
+
}
|
|
238
|
+
// A host can place a root beyond its measured safe-area size even when no
|
|
239
|
+
// inset adjustment was needed. Recompute at the final frame in either case.
|
|
240
|
+
const width = masonLayout.toDevicePixels(adjusted.size.width);
|
|
241
|
+
const height = masonLayout.toDevicePixels(adjusted.size.height);
|
|
242
|
+
const layout = view.ios.node.computedLayout;
|
|
243
|
+
if (Math.round(layout.width) !== Math.round(width) || Math.round(layout.height) !== Math.round(height)) {
|
|
244
|
+
view.ios.mason_computeWithSize(width, height);
|
|
245
|
+
view.ios.mason_markRootComputeAppliedWithSize(width, height);
|
|
246
|
+
}
|
|
247
|
+
const previous = view._masonRootFrame;
|
|
248
|
+
if (!previous || !CGRectEqualToRect(previous, adjusted)) {
|
|
249
|
+
view._masonRootFrame = adjusted;
|
|
250
|
+
view._raiseLayoutChangedEvent();
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
const TEARDOWN_SLICE_MS = 8;
|
|
254
|
+
// Reading the clock costs more than a teardown on some devices.
|
|
255
|
+
const TEARDOWNS_PER_CLOCK_READ = 16;
|
|
256
|
+
// Mason roots whose requestLayout already climbed to the page in this turn.
|
|
257
|
+
let climbedRoots = null;
|
|
258
|
+
function markClimbed(root) {
|
|
259
|
+
if (!climbedRoots) {
|
|
260
|
+
climbedRoots = new Set();
|
|
261
|
+
queueMicrotask(() => (climbedRoots = null));
|
|
262
|
+
}
|
|
263
|
+
climbedRoots.add(root);
|
|
264
|
+
}
|
|
265
|
+
// A layout in between clears core's flag, so the next request climbs again.
|
|
266
|
+
function climbedThisTurn(root) {
|
|
267
|
+
return !!climbedRoots?.has(root) && !!root.isLayoutRequested;
|
|
268
|
+
}
|
|
269
|
+
export class ViewBase extends CustomLayoutView {
|
|
270
|
+
_masonCheckChild(child) {
|
|
271
|
+
if (!(child instanceof NSView))
|
|
272
|
+
throw new TypeError('Mason core children must be NativeScript views.');
|
|
273
|
+
if (child.parent)
|
|
274
|
+
throw new Error('Remove the child from its parent before inserting it.');
|
|
275
|
+
for (let ancestor = this; ancestor; ancestor = ancestor.parent) {
|
|
276
|
+
if (ancestor === child)
|
|
277
|
+
throw new Error('A Mason core container cannot contain itself or an ancestor.');
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
addChild(child) {
|
|
281
|
+
this.insertChild(child, this._children.length);
|
|
282
|
+
}
|
|
283
|
+
insertBefore(child, reference) {
|
|
284
|
+
const index = reference == null ? this._children.length : this._children.indexOf(reference);
|
|
285
|
+
if (index < 0)
|
|
286
|
+
throw new Error('The reference view is not a child of this container.');
|
|
287
|
+
this.insertChild(child, index);
|
|
288
|
+
}
|
|
289
|
+
insertChild(child, atIndex) {
|
|
290
|
+
this._masonCheckChild(child);
|
|
291
|
+
if (!Number.isInteger(atIndex) || atIndex < 0 || atIndex > this._children.length) {
|
|
292
|
+
throw new RangeError('The child index is outside the container.');
|
|
293
|
+
}
|
|
294
|
+
this._masonSettleNativeAdds();
|
|
295
|
+
this._invalidateAttachCursor();
|
|
296
|
+
this._children.splice(atIndex, 0, child);
|
|
297
|
+
try {
|
|
298
|
+
this._addView(child, atIndex);
|
|
299
|
+
}
|
|
300
|
+
catch (error) {
|
|
301
|
+
this._children.splice(atIndex, 1);
|
|
302
|
+
throw error;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
replaceChild(child, atIndex) {
|
|
306
|
+
const previous = this._children[atIndex];
|
|
307
|
+
if (!Number.isInteger(atIndex) || !previous)
|
|
308
|
+
throw new RangeError('The child index is outside the container.');
|
|
309
|
+
if (child === previous)
|
|
310
|
+
return;
|
|
311
|
+
this._masonCheckChild(child);
|
|
312
|
+
this.removeChild(previous);
|
|
313
|
+
this.insertChild(child, atIndex);
|
|
314
|
+
}
|
|
315
|
+
removeChild(child) {
|
|
316
|
+
const index = this._children.indexOf(child);
|
|
317
|
+
if (index < 0)
|
|
318
|
+
return;
|
|
319
|
+
this._masonSettleNativeAdds();
|
|
320
|
+
this._invalidateAttachCursor();
|
|
321
|
+
this._children.splice(index, 1);
|
|
322
|
+
this._removeView(child);
|
|
323
|
+
}
|
|
324
|
+
removeChildren() {
|
|
325
|
+
this._masonSettleNativeAdds();
|
|
326
|
+
this._invalidateAttachCursor();
|
|
327
|
+
while (this._children.length)
|
|
328
|
+
this._removeView(this._children.pop());
|
|
329
|
+
this.requestLayout();
|
|
330
|
+
}
|
|
331
|
+
_nativeIndexFor(atIndex) {
|
|
332
|
+
let count = 0;
|
|
333
|
+
for (let index = 0; index < Math.min(atIndex, this._children.length); index++) {
|
|
334
|
+
if (this._children[index]._isMasonChild)
|
|
335
|
+
count++;
|
|
336
|
+
}
|
|
337
|
+
return count;
|
|
338
|
+
}
|
|
339
|
+
_tearDownUI(force) {
|
|
340
|
+
if ((__ANDROID__ || __APPLE__ || false) && !force && !this.reusable && this._context && this.nativeViewProtected) {
|
|
341
|
+
// A keyed move tears down and re-adds within one patch. Detach only this
|
|
342
|
+
// element and defer the recursive teardown; _setupUI cancels it on re-attach.
|
|
343
|
+
if (this.parent) {
|
|
344
|
+
this.parent._removeViewFromNativeVisualTree(this);
|
|
345
|
+
}
|
|
346
|
+
this._masonPendingTeardown = true;
|
|
347
|
+
ViewBase._pendingTeardowns.push(this);
|
|
348
|
+
if (!ViewBase._teardownScheduled) {
|
|
349
|
+
ViewBase._teardownScheduled = true;
|
|
350
|
+
setTimeout(() => ViewBase._drainTeardowns(), 0);
|
|
351
|
+
}
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
super._tearDownUI(force);
|
|
355
|
+
}
|
|
356
|
+
_setupUI(context, atIndex, parentIsLoaded) {
|
|
357
|
+
if ((__ANDROID__ || __APPLE__ || false) && this._masonPendingTeardown) {
|
|
358
|
+
this._masonPendingTeardown = false;
|
|
359
|
+
if (this._context === context) {
|
|
360
|
+
// core 9.1 renamed mIsRootView to the private _isRootView
|
|
361
|
+
const isRootView = this._isRootView ?? this.mIsRootView;
|
|
362
|
+
if (!isRootView && this.parent && !this._isAddedToNativeVisualTree) {
|
|
363
|
+
const nativeIndex = this.parent._childIndexToNativeChildIndex(atIndex ?? -1);
|
|
364
|
+
this._isAddedToNativeVisualTree = this.parent._addViewToNativeVisualTree(this, nativeIndex);
|
|
365
|
+
}
|
|
366
|
+
return;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
super._setupUI(context, atIndex, parentIsLoaded);
|
|
370
|
+
}
|
|
371
|
+
// Core's CustomLayoutView finds the child with a WinRT call per sibling. Mason's containers remove
|
|
372
|
+
// their children natively themselves, so only core's bookkeeping is kept.
|
|
373
|
+
_removeViewFromNativeVisualTree(child) {
|
|
374
|
+
releaseForeignLayout(child);
|
|
375
|
+
if (false) {
|
|
376
|
+
child._isAddedToNativeVisualTree = false;
|
|
377
|
+
return;
|
|
378
|
+
}
|
|
379
|
+
super._removeViewFromNativeVisualTree(child);
|
|
380
|
+
}
|
|
381
|
+
/** Mirror a plain child's CSS layout into its Mason leaf; containers call this after the native insert. */
|
|
382
|
+
_masonAdoptForeign(child) {
|
|
383
|
+
adoptForeignLayout(child);
|
|
384
|
+
}
|
|
385
|
+
_masonFinishTeardown() {
|
|
386
|
+
if (!this._masonPendingTeardown) {
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
389
|
+
this._masonPendingTeardown = false;
|
|
390
|
+
super._tearDownUI(true);
|
|
391
|
+
}
|
|
392
|
+
static _drainTeardowns() {
|
|
393
|
+
ViewBase._teardownScheduled = false;
|
|
394
|
+
const deadline = Date.now() + TEARDOWN_SLICE_MS;
|
|
395
|
+
let done = 0;
|
|
396
|
+
while (ViewBase._pendingTeardowns.length > 0) {
|
|
397
|
+
const view = ViewBase._pendingTeardowns.shift();
|
|
398
|
+
view._masonFinishTeardown();
|
|
399
|
+
if (++done % TEARDOWNS_PER_CLOCK_READ === 0 && Date.now() >= deadline) {
|
|
400
|
+
break;
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
if (ViewBase._pendingTeardowns.length > 0) {
|
|
404
|
+
ViewBase._teardownScheduled = true;
|
|
405
|
+
setTimeout(() => ViewBase._drainTeardowns(), 0);
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* Enable or disable CSS Preflight (web-normalised / Tailwind-like) defaults
|
|
410
|
+
* for the entire Mason tree.
|
|
411
|
+
*
|
|
412
|
+
* When `true` every element starts from a clean, browser-normalised slate:
|
|
413
|
+
* - `box-sizing: border-box`
|
|
414
|
+
* - `margin: 0`, `padding: 0`, `border-width: 0`
|
|
415
|
+
* - `background: transparent`
|
|
416
|
+
* - `list-style: none` on `<ul>` / `<ol>`
|
|
417
|
+
* - `display: block` on `<img>` (replaced elements)
|
|
418
|
+
*
|
|
419
|
+
* This is a **tree-global** flag; it should ideally be set **before** views are
|
|
420
|
+
* created so that all new nodes inherit the preflight baseline. Changing it
|
|
421
|
+
* after views have been created re-seeds the arena defaults but does not
|
|
422
|
+
* retroactively restyle individually modified nodes.
|
|
423
|
+
*
|
|
424
|
+
* @example
|
|
425
|
+
* ```ts
|
|
426
|
+
* import { ViewBase } from '@octane-xplat/nativescript-masonkit';
|
|
427
|
+
* ViewBase.preflight = true; // enable at app startup
|
|
428
|
+
* ```
|
|
429
|
+
*/
|
|
430
|
+
static get preflight() {
|
|
431
|
+
return Tree.instance.preflight;
|
|
432
|
+
}
|
|
433
|
+
static set preflight(value) {
|
|
434
|
+
Tree.instance.preflight = value;
|
|
435
|
+
}
|
|
436
|
+
constructor() {
|
|
437
|
+
super();
|
|
438
|
+
this._children = [];
|
|
439
|
+
this[_a] = false;
|
|
440
|
+
this._masonPendingTeardown = false;
|
|
441
|
+
this[_b] = false;
|
|
442
|
+
this[_c] = false;
|
|
443
|
+
this[_d] = {};
|
|
444
|
+
this._pendingEventsRegistration = [];
|
|
445
|
+
/**
|
|
446
|
+
* iOS: the views in this subtree a root's layout pass must visit (non-Mason children, which core
|
|
447
|
+
* lays out, and Mason views listening to layoutChanged). The pass skips subtrees where it's 0.
|
|
448
|
+
*/
|
|
449
|
+
this._masonLayoutWork = 0;
|
|
450
|
+
this._windowsActiveId = 0;
|
|
451
|
+
this._masonClimbTurn = null;
|
|
452
|
+
// `width`/`height` are core CssAnimationProperties whose stylesheet accessor
|
|
453
|
+
// is non-configurable, so units Mason understands but core does not (`vh`,
|
|
454
|
+
// `rem`, `pt`, …) have to be resolved on this view's own Style object.
|
|
455
|
+
installMasonSizeUnits(this.style);
|
|
456
|
+
if (__ANDROID__) {
|
|
457
|
+
this._isPaddingRelative = false;
|
|
458
|
+
}
|
|
459
|
+
// Core's ContainerView defaults this to true: the view extends under the
|
|
460
|
+
// status bar and home indicator, and core layouts pad their children by
|
|
461
|
+
// the insets. Mason lays children out from its own style, so a root kept
|
|
462
|
+
// that default drew its content under the bars. As on the web, content
|
|
463
|
+
// stays in the safe area; set it to true for a full-bleed root (like
|
|
464
|
+
// `viewport-fit=cover`) and pad it yourself.
|
|
465
|
+
this.iosOverflowSafeArea = false;
|
|
466
|
+
}
|
|
467
|
+
_rememberNativeOwner(nativeView = nativeViewFor(this)) {
|
|
468
|
+
if (!nativeView)
|
|
469
|
+
return;
|
|
470
|
+
try {
|
|
471
|
+
nativeView.__masonOwner = new WeakRef(this);
|
|
472
|
+
}
|
|
473
|
+
catch (_) {
|
|
474
|
+
// Some host objects do not accept expandos; fallback tree matching still works.
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
/**
|
|
478
|
+
* Returns the top-most Mason/NativeScript element at a point in this view's
|
|
479
|
+
* visible local coordinate space, similar to the browser's elementFromPoint().
|
|
480
|
+
* `x` and `y` are CSS pixels (dips) on every platform, the unit touch events report.
|
|
481
|
+
*/
|
|
482
|
+
elementFromPoint(x, y) {
|
|
483
|
+
const nativeView = nativeViewFor(this) ?? this._view;
|
|
484
|
+
if (!nativeView)
|
|
485
|
+
return null;
|
|
486
|
+
this._rememberNativeOwner(nativeView);
|
|
487
|
+
let nativeHit = null;
|
|
488
|
+
if (__ANDROID__ && typeof nativeView.elementFromPoint === 'function') {
|
|
489
|
+
// Android views hit-test in device pixels.
|
|
490
|
+
nativeHit = nativeView.elementFromPoint(masonLayout.toDevicePixels(x), masonLayout.toDevicePixels(y));
|
|
491
|
+
}
|
|
492
|
+
else if (__APPLE__) {
|
|
493
|
+
const hitTest = nativeView.mason_elementFromPointY ?? nativeView.mason_elementFromPoint ?? nativeView.elementFromPoint;
|
|
494
|
+
if (typeof hitTest === 'function') {
|
|
495
|
+
nativeHit = hitTest.call(nativeView, x, y);
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
else if (false && typeof masonEngine().ElementFromPoint === 'function') {
|
|
499
|
+
nativeHit = masonEngine().ElementFromPoint(nativeView, x, y);
|
|
500
|
+
}
|
|
501
|
+
if (!nativeHit)
|
|
502
|
+
return null;
|
|
503
|
+
const known = nativeOwnerFor(nativeHit);
|
|
504
|
+
if (known)
|
|
505
|
+
return known;
|
|
506
|
+
// Owners are remembered on first hit rather than for every view at init.
|
|
507
|
+
const found = findOwnerForNativeView(this, nativeHit);
|
|
508
|
+
found?._rememberNativeOwner?.(nativeHit);
|
|
509
|
+
return found;
|
|
510
|
+
}
|
|
511
|
+
// Scrolling. Size reads run a pending layout first; "scroll"/"scrollend" are only raised for
|
|
512
|
+
// an element with a listener.
|
|
513
|
+
/** Vertical scroll offset; setting it scrolls, clamped to the scroll range. */
|
|
514
|
+
get scrollTop() {
|
|
515
|
+
return nativeScrollOffset(this, true);
|
|
516
|
+
}
|
|
517
|
+
set scrollTop(value) {
|
|
518
|
+
nativeScrollTo(this, NaN, scrollCoordinate(value), false);
|
|
519
|
+
}
|
|
520
|
+
/** Horizontal scroll offset; setting it scrolls, clamped to the scroll range. */
|
|
521
|
+
get scrollLeft() {
|
|
522
|
+
return nativeScrollOffset(this, false);
|
|
523
|
+
}
|
|
524
|
+
set scrollLeft(value) {
|
|
525
|
+
nativeScrollTo(this, scrollCoordinate(value), NaN, false);
|
|
526
|
+
}
|
|
527
|
+
/** Content width, at least `clientWidth`. */
|
|
528
|
+
get scrollWidth() {
|
|
529
|
+
return nativeScrollMetric(this, 'scrollWidth');
|
|
530
|
+
}
|
|
531
|
+
/** Content height, at least `clientHeight`. */
|
|
532
|
+
get scrollHeight() {
|
|
533
|
+
return nativeScrollMetric(this, 'scrollHeight');
|
|
534
|
+
}
|
|
535
|
+
/** Padding box width. */
|
|
536
|
+
get clientWidth() {
|
|
537
|
+
return nativeScrollMetric(this, 'clientWidth');
|
|
538
|
+
}
|
|
539
|
+
/** Padding box height. */
|
|
540
|
+
get clientHeight() {
|
|
541
|
+
return nativeScrollMetric(this, 'clientHeight');
|
|
542
|
+
}
|
|
543
|
+
scrollTo(xOrOptions, y) {
|
|
544
|
+
if (xOrOptions !== null && typeof xOrOptions === 'object') {
|
|
545
|
+
const { left, top, behavior } = xOrOptions;
|
|
546
|
+
nativeScrollTo(this, left === undefined ? NaN : scrollCoordinate(left), top === undefined ? NaN : scrollCoordinate(top), behavior === 'smooth');
|
|
547
|
+
}
|
|
548
|
+
else {
|
|
549
|
+
nativeScrollTo(this, scrollCoordinate(xOrOptions), scrollCoordinate(y), false);
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
scroll(xOrOptions, y) {
|
|
553
|
+
this.scrollTo(xOrOptions, y);
|
|
554
|
+
}
|
|
555
|
+
scrollBy(xOrOptions, y) {
|
|
556
|
+
let dx;
|
|
557
|
+
let dy;
|
|
558
|
+
let smooth = false;
|
|
559
|
+
if (xOrOptions !== null && typeof xOrOptions === 'object') {
|
|
560
|
+
dx = scrollCoordinate(xOrOptions.left);
|
|
561
|
+
dy = scrollCoordinate(xOrOptions.top);
|
|
562
|
+
smooth = xOrOptions.behavior === 'smooth';
|
|
563
|
+
}
|
|
564
|
+
else {
|
|
565
|
+
dx = scrollCoordinate(xOrOptions);
|
|
566
|
+
dy = scrollCoordinate(y);
|
|
567
|
+
}
|
|
568
|
+
// Relative to a request still waiting for the native view, if any.
|
|
569
|
+
const pending = this._masonPendingScroll;
|
|
570
|
+
const left = !dx ? NaN : (pending && !isNaN(pending.left) ? pending.left : this.scrollLeft) + dx;
|
|
571
|
+
const top = !dy ? NaN : (pending && !isNaN(pending.top) ? pending.top : this.scrollTop) + dy;
|
|
572
|
+
nativeScrollTo(this, left, top, smooth);
|
|
573
|
+
}
|
|
574
|
+
/** Scrolls the scroll containers above this element so it's visible. */
|
|
575
|
+
scrollIntoView(arg) {
|
|
576
|
+
const native = this[native_];
|
|
577
|
+
if (!native)
|
|
578
|
+
return;
|
|
579
|
+
const options = arg !== null && typeof arg === 'object' ? arg : { block: arg === false ? 'end' : 'start' };
|
|
580
|
+
const block = SCROLL_POSITIONS[options.block ?? 'start'] ?? 0;
|
|
581
|
+
const inline = SCROLL_POSITIONS[options.inline ?? 'nearest'] ?? 3;
|
|
582
|
+
const smooth = options.behavior === 'smooth';
|
|
583
|
+
if (__ANDROID__) {
|
|
584
|
+
org.nativescript.mason.masonkit.WebScroll.scrollIntoView(native, block, inline, smooth);
|
|
585
|
+
}
|
|
586
|
+
else if (__APPLE__) {
|
|
587
|
+
native.mason_scrollIntoView(block, inline, smooth);
|
|
588
|
+
}
|
|
589
|
+
else if (false) {
|
|
590
|
+
masonEngine().ScrollIntoView(native, block, inline, smooth);
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
_registerNativeEvent(arg, callback, thisArg) {
|
|
594
|
+
if (!this[native_]) {
|
|
595
|
+
this._pendingEventsRegistration.push({ arg, callback, thisArg });
|
|
596
|
+
return;
|
|
597
|
+
}
|
|
598
|
+
//@ts-ignore
|
|
599
|
+
if (this._view) {
|
|
600
|
+
if (__ANDROID__) {
|
|
601
|
+
const ref = new WeakRef(this);
|
|
602
|
+
const cb = new kotlin.jvm.functions.Function1({
|
|
603
|
+
invoke(event) {
|
|
604
|
+
const owner = ref.get();
|
|
605
|
+
if (owner) {
|
|
606
|
+
const ret = wrapNativeEvent(arg);
|
|
607
|
+
ret[native_] = event;
|
|
608
|
+
ret._target = owner;
|
|
609
|
+
callback.call(thisArg || owner, ret);
|
|
610
|
+
}
|
|
611
|
+
},
|
|
612
|
+
});
|
|
613
|
+
//@ts-ignore
|
|
614
|
+
const id = this._view.addEventListener(arg, cb);
|
|
615
|
+
callback['mason:event:id'] = id;
|
|
616
|
+
}
|
|
617
|
+
if (__APPLE__) {
|
|
618
|
+
//@ts-ignore
|
|
619
|
+
const id = this._view.mason_addEventListener(arg, (event) => {
|
|
620
|
+
const ret = wrapNativeEvent(arg);
|
|
621
|
+
ret[native_] = event;
|
|
622
|
+
ret._target = this;
|
|
623
|
+
callback.call(thisArg || this, ret);
|
|
624
|
+
});
|
|
625
|
+
callback['mason:event:id'] = id;
|
|
626
|
+
}
|
|
627
|
+
if (false) {
|
|
628
|
+
if (typeof masonEngine().AddEventListener === 'function') {
|
|
629
|
+
const ref = new WeakRef(this);
|
|
630
|
+
const listener = globalThis.NSWinRT.asDelegate('NativeScript.Mason.EventListener', (event) => {
|
|
631
|
+
const owner = ref.deref();
|
|
632
|
+
if (!owner)
|
|
633
|
+
return;
|
|
634
|
+
const ret = wrapNativeEvent(arg);
|
|
635
|
+
ret[native_] = event;
|
|
636
|
+
ret._target = owner;
|
|
637
|
+
callback.call(thisArg || owner, ret);
|
|
638
|
+
});
|
|
639
|
+
callback['mason:event:id'] = masonEngine().AddEventListener(this._view, arg, listener);
|
|
640
|
+
callback['mason:event:listener'] = listener;
|
|
641
|
+
}
|
|
642
|
+
else if (arg === 'click' || arg === 'tap') {
|
|
643
|
+
try {
|
|
644
|
+
const NSWinRT_ = globalThis.NSWinRT;
|
|
645
|
+
const MUX = globalThis.Microsoft;
|
|
646
|
+
const owner = this;
|
|
647
|
+
const view = this._view;
|
|
648
|
+
const delegate = NSWinRT_.asDelegate('Microsoft.UI.Xaml.Input.TappedEventHandler', (_sender, _e) => {
|
|
649
|
+
const ret = {};
|
|
650
|
+
ret[native_] = _e;
|
|
651
|
+
ret._target = owner;
|
|
652
|
+
callback.call(thisArg || owner, ret);
|
|
653
|
+
});
|
|
654
|
+
if (view.Background == null && MUX?.UI?.Xaml?.Media?.SolidColorBrush) {
|
|
655
|
+
view.Background = new MUX.UI.Xaml.Media.SolidColorBrush(MUX.UI.Colors.Transparent);
|
|
656
|
+
}
|
|
657
|
+
const tappedEvent = MUX?.UI?.Xaml?.UIElement?.TappedEvent ?? view.TappedEvent;
|
|
658
|
+
let attached = false;
|
|
659
|
+
if (tappedEvent && typeof view.AddHandler === 'function') {
|
|
660
|
+
try {
|
|
661
|
+
view.AddHandler(tappedEvent, delegate, true);
|
|
662
|
+
callback['mason:event:tapped'] = tappedEvent;
|
|
663
|
+
attached = true;
|
|
664
|
+
}
|
|
665
|
+
catch (_e) { }
|
|
666
|
+
}
|
|
667
|
+
if (!attached) {
|
|
668
|
+
view.Tapped = delegate;
|
|
669
|
+
}
|
|
670
|
+
callback['mason:event:id'] = delegate;
|
|
671
|
+
}
|
|
672
|
+
catch (_) { }
|
|
673
|
+
}
|
|
674
|
+
else if (typeof this._view.AddEventListener === 'function') {
|
|
675
|
+
const ref = new WeakRef(this);
|
|
676
|
+
const listener = globalThis.NSWinRT.asDelegate('NativeScript.Mason.EventListener', (event) => {
|
|
677
|
+
const owner = ref.deref();
|
|
678
|
+
if (!owner)
|
|
679
|
+
return;
|
|
680
|
+
const ret = wrapNativeEvent(arg);
|
|
681
|
+
ret[native_] = event;
|
|
682
|
+
ret._target = owner;
|
|
683
|
+
callback.call(thisArg || owner, ret);
|
|
684
|
+
});
|
|
685
|
+
callback['mason:event:id'] = this._view.AddEventListener(arg, listener);
|
|
686
|
+
// Held so the delegate isn't collected.
|
|
687
|
+
callback['mason:event:listener'] = listener;
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
_unregisterNativeEvent(arg, callback, thisArg) {
|
|
693
|
+
const id = callback['mason:event:id'];
|
|
694
|
+
if (!this[native_]) {
|
|
695
|
+
this._pendingEventsRegistration = this._pendingEventsRegistration.filter((registration) => {
|
|
696
|
+
return !(registration.arg === arg && registration.callback === callback && registration.thisArg === thisArg);
|
|
697
|
+
});
|
|
698
|
+
return;
|
|
699
|
+
}
|
|
700
|
+
//@ts-ignore
|
|
701
|
+
if (this._view) {
|
|
702
|
+
if (__ANDROID__) {
|
|
703
|
+
if (id) {
|
|
704
|
+
//@ts-ignore
|
|
705
|
+
const removed = this._view.removeEventListener(arg, id);
|
|
706
|
+
callback['mason:event:id'] = undefined;
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
if (__APPLE__) {
|
|
710
|
+
if (id) {
|
|
711
|
+
//@ts-ignore
|
|
712
|
+
const removed = this._view.mason_removeEventListenerId(arg, id);
|
|
713
|
+
callback['mason:event:id'] = undefined;
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
if (false) {
|
|
717
|
+
if (id && callback['mason:event:listener'] && !callback['mason:event:tapped']) {
|
|
718
|
+
masonEngine().RemoveEventListener(this._view, arg, id);
|
|
719
|
+
callback['mason:event:id'] = undefined;
|
|
720
|
+
callback['mason:event:listener'] = undefined;
|
|
721
|
+
}
|
|
722
|
+
else if (id && (arg === 'click' || arg === 'tap')) {
|
|
723
|
+
try {
|
|
724
|
+
const view = this._view;
|
|
725
|
+
const tappedEvent = callback['mason:event:tapped'];
|
|
726
|
+
if (tappedEvent && typeof view.RemoveHandler === 'function') {
|
|
727
|
+
view.RemoveHandler(tappedEvent, id);
|
|
728
|
+
}
|
|
729
|
+
else if (view) {
|
|
730
|
+
view.Tapped = null;
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
catch (_) { }
|
|
734
|
+
callback['mason:event:id'] = undefined;
|
|
735
|
+
callback['mason:event:tapped'] = undefined;
|
|
736
|
+
}
|
|
737
|
+
else if (id && typeof this._view.RemoveEventListener === 'function') {
|
|
738
|
+
this._view.RemoveEventListener(arg, id);
|
|
739
|
+
callback['mason:event:id'] = undefined;
|
|
740
|
+
callback['mason:event:listener'] = undefined;
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
/** Hands `touch-action` to the native node, where the scroll views read it. */
|
|
746
|
+
_applyTouchAction() {
|
|
747
|
+
const flags = this[touchAction_];
|
|
748
|
+
const native = this[native_];
|
|
749
|
+
if (flags === undefined || !native)
|
|
750
|
+
return;
|
|
751
|
+
const node = native.node ?? (__IOS__ ? this.ios?.node : undefined);
|
|
752
|
+
if (node)
|
|
753
|
+
node.touchAction = flags;
|
|
754
|
+
}
|
|
755
|
+
initNativeView() {
|
|
756
|
+
super.initNativeView();
|
|
757
|
+
this._applyTouchAction();
|
|
758
|
+
const scroll = this._masonPendingScroll;
|
|
759
|
+
if (scroll) {
|
|
760
|
+
this._masonPendingScroll = undefined;
|
|
761
|
+
nativeScrollTo(this, scroll.left, scroll.top, scroll.smooth);
|
|
762
|
+
}
|
|
763
|
+
if (this._pendingEventsRegistration.length > 0) {
|
|
764
|
+
const pending = this._pendingEventsRegistration.splice(0);
|
|
765
|
+
for (const registration of pending) {
|
|
766
|
+
this._registerNativeEvent(registration.arg, registration.callback, registration.thisArg);
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
_setNativeViewFrame(nativeView, frame) {
|
|
771
|
+
// nativeView.frame = frame;
|
|
772
|
+
}
|
|
773
|
+
_masonAddLayoutWork(delta) {
|
|
774
|
+
// Up to the root: a non-Mason parent is laid out by core and its Mason roots keep their own count.
|
|
775
|
+
let view = this;
|
|
776
|
+
while (view?.[isMasonView_]) {
|
|
777
|
+
view._masonLayoutWork += delta;
|
|
778
|
+
view = view.parent;
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
_masonListensToLayout() {
|
|
782
|
+
return this.hasListeners(NSView.layoutChangedEvent);
|
|
783
|
+
}
|
|
784
|
+
_addViewCore(view, atIndex) {
|
|
785
|
+
// Before setup: listeners the child gains while loading add themselves through `parent`.
|
|
786
|
+
if (__APPLE__) {
|
|
787
|
+
const work = view?.[isMasonView_] ? view._masonLayoutWork : 1;
|
|
788
|
+
if (work)
|
|
789
|
+
this._masonAddLayoutWork(work);
|
|
790
|
+
}
|
|
791
|
+
// @ts-ignore
|
|
792
|
+
super._addViewCore(view, atIndex);
|
|
793
|
+
}
|
|
794
|
+
_removeViewCore(view) {
|
|
795
|
+
// @ts-ignore
|
|
796
|
+
super._removeViewCore(view);
|
|
797
|
+
// After teardown: listeners removed while unloading already subtracted themselves.
|
|
798
|
+
if (__APPLE__) {
|
|
799
|
+
const work = view?.[isMasonView_] ? view._masonLayoutWork : 1;
|
|
800
|
+
if (work)
|
|
801
|
+
this._masonAddLayoutWork(-work);
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
addEventListener(arg, callback, thisArg) {
|
|
805
|
+
const listened = __APPLE__ && this._masonListensToLayout();
|
|
806
|
+
this._addEventListener(arg, callback, thisArg);
|
|
807
|
+
if (__APPLE__ && !listened && this._masonListensToLayout())
|
|
808
|
+
this._masonAddLayoutWork(1);
|
|
809
|
+
}
|
|
810
|
+
removeEventListener(arg, callback, thisArg) {
|
|
811
|
+
const listened = __APPLE__ && this._masonListensToLayout();
|
|
812
|
+
this._removeEventListener(arg, callback, thisArg);
|
|
813
|
+
if (__APPLE__ && listened && !this._masonListensToLayout())
|
|
814
|
+
this._masonAddLayoutWork(-1);
|
|
815
|
+
}
|
|
816
|
+
_addEventListener(arg, callback, thisArg) {
|
|
817
|
+
if (typeof thisArg === 'boolean') {
|
|
818
|
+
thisArg = {
|
|
819
|
+
capture: thisArg,
|
|
820
|
+
};
|
|
821
|
+
}
|
|
822
|
+
if (typeof arg !== 'string') {
|
|
823
|
+
super.addEventListener(arg, callback, thisArg);
|
|
824
|
+
return;
|
|
825
|
+
}
|
|
826
|
+
const nativeEventName = masonNativeEventName(arg);
|
|
827
|
+
if (nativeEventName) {
|
|
828
|
+
super.addEventListener(nativeEventName, callback, thisArg);
|
|
829
|
+
this._registerNativeEvent(nativeEventName, callback, thisArg);
|
|
830
|
+
return;
|
|
831
|
+
}
|
|
832
|
+
super.addEventListener(arg, callback, thisArg);
|
|
833
|
+
}
|
|
834
|
+
_removeEventListener(arg, callback, thisArg) {
|
|
835
|
+
if (typeof thisArg === 'boolean') {
|
|
836
|
+
thisArg = {
|
|
837
|
+
capture: thisArg,
|
|
838
|
+
};
|
|
839
|
+
}
|
|
840
|
+
if (typeof arg === 'string') {
|
|
841
|
+
const nativeEventName = masonNativeEventName(arg);
|
|
842
|
+
if (nativeEventName) {
|
|
843
|
+
super.removeEventListener(nativeEventName, callback, thisArg);
|
|
844
|
+
this._unregisterNativeEvent(nativeEventName, callback, thisArg);
|
|
845
|
+
return;
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
super.removeEventListener(arg, callback, thisArg);
|
|
849
|
+
}
|
|
850
|
+
_applyPseudoClassStyles(pseudoClass, view, styles) {
|
|
851
|
+
if (pseudoClass && styles && pseudoClass in styles) {
|
|
852
|
+
const current = styles[pseudoClass];
|
|
853
|
+
//@ts-ignore
|
|
854
|
+
const existing = this[pseudoStyles_]?.[pseudoClass];
|
|
855
|
+
const style = existing ?? Style.fromPseudo(pseudoClass, this, view);
|
|
856
|
+
if (style) {
|
|
857
|
+
for (const prop in current) {
|
|
858
|
+
// ruleset props are kebab-case; Style only has camelCase accessors.
|
|
859
|
+
style[toCamelCase(prop)] = current[prop];
|
|
860
|
+
}
|
|
861
|
+
this[pseudoStyles_][pseudoClass] = style;
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
_hoverHandler(subscribe) {
|
|
866
|
+
const styles = compile(this);
|
|
867
|
+
//@ts-ignore
|
|
868
|
+
this._applyPseudoClassStyles('hover', this._view, styles);
|
|
869
|
+
if (false) {
|
|
870
|
+
if (subscribe) {
|
|
871
|
+
this.on('mouseEnter', onWindowsHoverEnter);
|
|
872
|
+
this.on('mouseLeave', onWindowsHoverLeave);
|
|
873
|
+
}
|
|
874
|
+
else {
|
|
875
|
+
this.off('mouseEnter', onWindowsHoverEnter);
|
|
876
|
+
this.off('mouseLeave', onWindowsHoverLeave);
|
|
877
|
+
this._removeVisualState('hover');
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
_handler(subscribe) {
|
|
882
|
+
const styles = compile(this);
|
|
883
|
+
//@ts-ignore
|
|
884
|
+
this._applyPseudoClassStyles('active', this._view, styles);
|
|
885
|
+
if (false) {
|
|
886
|
+
if (subscribe) {
|
|
887
|
+
this.on('touch', onWindowsActiveTouch);
|
|
888
|
+
this.on('mouseLeave', onWindowsActiveLeave);
|
|
889
|
+
}
|
|
890
|
+
else {
|
|
891
|
+
this.off('touch', onWindowsActiveTouch);
|
|
892
|
+
this.off('mouseLeave', onWindowsActiveLeave);
|
|
893
|
+
clearWindowsActive(this);
|
|
894
|
+
}
|
|
895
|
+
this._windowsListenActive(subscribe);
|
|
896
|
+
// A button dims while held only when it has no :active style of its own.
|
|
897
|
+
// @ts-ignore
|
|
898
|
+
const view = this._view;
|
|
899
|
+
if (view?.IsButton)
|
|
900
|
+
view.DimsWhenPressed = !subscribe;
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
// Inline elements a Text draws get no pointer events of their own; the Text reports their presses.
|
|
904
|
+
_windowsListenActive(on) {
|
|
905
|
+
const view = this._view;
|
|
906
|
+
if (!view || typeof masonEngine().AddEventListener !== 'function')
|
|
907
|
+
return;
|
|
908
|
+
if (on && !this._windowsActiveId) {
|
|
909
|
+
const ref = new WeakRef(this);
|
|
910
|
+
this._windowsActiveListener = globalThis.NSWinRT.asDelegate('NativeScript.Mason.EventListener', (event) => {
|
|
911
|
+
const owner = ref.deref();
|
|
912
|
+
if (!owner)
|
|
913
|
+
return;
|
|
914
|
+
if (event.Data === '1') {
|
|
915
|
+
for (const state of WINDOWS_ACTIVE_STATES)
|
|
916
|
+
owner._addVisualState(state);
|
|
917
|
+
}
|
|
918
|
+
else {
|
|
919
|
+
clearWindowsActive(owner);
|
|
920
|
+
}
|
|
921
|
+
});
|
|
922
|
+
this._windowsActiveId = masonEngine().AddEventListener(view, 'mason:active', this._windowsActiveListener);
|
|
923
|
+
}
|
|
924
|
+
else if (!on && this._windowsActiveId) {
|
|
925
|
+
masonEngine().RemoveEventListener(view, 'mason:active', this._windowsActiveId);
|
|
926
|
+
this._windowsActiveId = 0;
|
|
927
|
+
this._windowsActiveListener = undefined;
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
_disableHandler(subscribe) {
|
|
931
|
+
const styles = compile(this);
|
|
932
|
+
//@ts-ignore
|
|
933
|
+
this._applyPseudoClassStyles('disabled', this._view, styles);
|
|
934
|
+
}
|
|
935
|
+
_focusHandler(subscribe) {
|
|
936
|
+
const styles = compile(this);
|
|
937
|
+
//@ts-ignore
|
|
938
|
+
this._applyPseudoClassStyles('focus', this._view, styles);
|
|
939
|
+
if (false) {
|
|
940
|
+
if (subscribe) {
|
|
941
|
+
this.on('focus', onWindowsFocus, this);
|
|
942
|
+
this.on('blur', onWindowsBlur, this);
|
|
943
|
+
}
|
|
944
|
+
else {
|
|
945
|
+
this.off('focus', onWindowsFocus, this);
|
|
946
|
+
this.off('blur', onWindowsBlur, this);
|
|
947
|
+
this._removeVisualState('focus');
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
_blurHandler(subscribe) {
|
|
952
|
+
const styles = compile(this);
|
|
953
|
+
//@ts-ignore
|
|
954
|
+
this._applyPseudoClassStyles('blur', this._view, styles);
|
|
955
|
+
}
|
|
956
|
+
forceStyleUpdate() {
|
|
957
|
+
_forceStyleUpdate(this);
|
|
958
|
+
}
|
|
959
|
+
get _viewChildren() {
|
|
960
|
+
return this._children.filter((child) => {
|
|
961
|
+
return !child[isPlaceholder_] && child instanceof NSView;
|
|
962
|
+
});
|
|
963
|
+
}
|
|
964
|
+
eachLayoutChild(callback) {
|
|
965
|
+
let lastChild = null;
|
|
966
|
+
this.eachChildView((cv) => {
|
|
967
|
+
cv._eachLayoutView((lv) => {
|
|
968
|
+
if (lastChild && !lastChild.isCollapsed) {
|
|
969
|
+
callback(lastChild, false);
|
|
970
|
+
}
|
|
971
|
+
lastChild = lv;
|
|
972
|
+
});
|
|
973
|
+
return true;
|
|
974
|
+
});
|
|
975
|
+
if (lastChild && !lastChild.isCollapsed) {
|
|
976
|
+
callback(lastChild, true);
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
eachChild(callback) {
|
|
980
|
+
this._eachViewChild(callback);
|
|
981
|
+
}
|
|
982
|
+
// Live and allocation-free, like core's LayoutBase.eachChildView (walks run per view).
|
|
983
|
+
_eachViewChild(callback) {
|
|
984
|
+
const children = this._children;
|
|
985
|
+
for (let i = 0, length = children.length; i < length; i++) {
|
|
986
|
+
const child = children[i];
|
|
987
|
+
if (child && !child[isPlaceholder_] && child instanceof NSView) {
|
|
988
|
+
callback(child);
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
// Core's iOS requestLayout climbs to the Page and re-measures the whole tree in JS.
|
|
993
|
+
// A Mason root's native compute already places every Mason descendant, so it skips
|
|
994
|
+
// them and only runs core's layout for non-Mason views inside its subtree.
|
|
995
|
+
/** True for a Mason view whose frame the Mason tree sets natively (iOS). */
|
|
996
|
+
get _masonPlacedNatively() {
|
|
997
|
+
return __APPLE__ && !!this[isMasonView_] && !!this.parent?.[isMasonView_];
|
|
998
|
+
}
|
|
999
|
+
/** Size a non-Mason child with core's measure: its native view rarely implements sizeThatFits. */
|
|
1000
|
+
_masonMeasureForeign(child) {
|
|
1001
|
+
if (!__APPLE__ || child[isMasonView_] || !child.nativeViewProtected)
|
|
1002
|
+
return;
|
|
1003
|
+
// Text views (MasonText) have no `mason` of their own; their node does.
|
|
1004
|
+
const native = this.nativeViewProtected;
|
|
1005
|
+
const mason = native?.mason ?? native?.node?.mason;
|
|
1006
|
+
if (typeof mason?.setMeasureForViewBlock !== 'function')
|
|
1007
|
+
return;
|
|
1008
|
+
invalidateOnLayoutRequest(child, mason);
|
|
1009
|
+
const parentRef = new WeakRef(this);
|
|
1010
|
+
const childRef = new WeakRef(child);
|
|
1011
|
+
const spec = (known, available) => {
|
|
1012
|
+
if (!isNaN(known))
|
|
1013
|
+
return Utils.layout.makeMeasureSpec(known, Utils.layout.EXACTLY);
|
|
1014
|
+
if (available > 0)
|
|
1015
|
+
return Utils.layout.makeMeasureSpec(available, Utils.layout.AT_MOST);
|
|
1016
|
+
return Utils.layout.makeMeasureSpec(0, Utils.layout.UNSPECIFIED);
|
|
1017
|
+
};
|
|
1018
|
+
mason.setMeasureForViewBlock(child.nativeViewProtected, (knownW, knownH, availW, availH) => {
|
|
1019
|
+
const parent = parentRef.deref();
|
|
1020
|
+
const view = childRef.deref();
|
|
1021
|
+
if (!parent || !view)
|
|
1022
|
+
return CGSizeMake(0, 0);
|
|
1023
|
+
NSView.measureChild(parent, view, spec(knownW, availW), spec(knownH, availH));
|
|
1024
|
+
return CGSizeMake(view.getMeasuredWidth(), view.getMeasuredHeight());
|
|
1025
|
+
});
|
|
1026
|
+
}
|
|
1027
|
+
/**
|
|
1028
|
+
* Sets a non-Mason child's percentage width/height (`null` clears it), resolved against the
|
|
1029
|
+
* containing block. Windows core calls this for every percentage; on Android and iOS a view calls
|
|
1030
|
+
* it when its native sizing can't express one. `false` when core should handle it.
|
|
1031
|
+
*/
|
|
1032
|
+
_setChildPercentSize(child, horizontal, fraction) {
|
|
1033
|
+
const nativeChild = child?.nativeViewProtected;
|
|
1034
|
+
if (!nativeChild || child[isMasonView_])
|
|
1035
|
+
return false;
|
|
1036
|
+
const value = fraction ?? NaN;
|
|
1037
|
+
if (false) {
|
|
1038
|
+
if (horizontal)
|
|
1039
|
+
masonEngine().SetPercentWidth(nativeChild, value);
|
|
1040
|
+
else
|
|
1041
|
+
masonEngine().SetPercentHeight(nativeChild, value);
|
|
1042
|
+
}
|
|
1043
|
+
else if (__ANDROID__) {
|
|
1044
|
+
const mason = org.nativescript.mason.masonkit.Mason.getShared();
|
|
1045
|
+
if (horizontal)
|
|
1046
|
+
mason.setPercentWidth(nativeChild, value);
|
|
1047
|
+
else
|
|
1048
|
+
mason.setPercentHeight(nativeChild, value);
|
|
1049
|
+
}
|
|
1050
|
+
else if (__APPLE__) {
|
|
1051
|
+
if (horizontal)
|
|
1052
|
+
NSCMason.shared.setPercentWidth(nativeChild, value);
|
|
1053
|
+
else
|
|
1054
|
+
NSCMason.shared.setPercentHeight(nativeChild, value);
|
|
1055
|
+
}
|
|
1056
|
+
else {
|
|
1057
|
+
return false;
|
|
1058
|
+
}
|
|
1059
|
+
return true;
|
|
1060
|
+
}
|
|
1061
|
+
/**
|
|
1062
|
+
* A native removal relays out natively but runs no core layout pass, so `layoutChanged`
|
|
1063
|
+
* and non-Mason descendants miss it. Ask for one; a subtree being torn down is unloaded.
|
|
1064
|
+
*/
|
|
1065
|
+
_masonRequestLayoutAfterRemoval() {
|
|
1066
|
+
if (__APPLE__ && this.isLoaded)
|
|
1067
|
+
this.requestLayout();
|
|
1068
|
+
}
|
|
1069
|
+
/** Lay out the non-Mason views in this root's subtree from the frames Mason set. */
|
|
1070
|
+
_masonLayoutForeignDescendants() {
|
|
1071
|
+
if (!__APPLE__)
|
|
1072
|
+
return;
|
|
1073
|
+
const visit = (view) => {
|
|
1074
|
+
view.eachChildView((child) => {
|
|
1075
|
+
if (child[isMasonView_]) {
|
|
1076
|
+
if (!(child._masonLayoutWork > 0))
|
|
1077
|
+
return true;
|
|
1078
|
+
// Keep `layoutChanged` working for the few views that listen to it.
|
|
1079
|
+
if (child.hasListeners?.(NSView.layoutChangedEvent)) {
|
|
1080
|
+
const b = child._getCurrentLayoutBounds();
|
|
1081
|
+
if (child._setCurrentLayoutBounds(b.left, b.top, b.right, b.bottom).boundsChanged) {
|
|
1082
|
+
child._raiseLayoutChangedEvent();
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
visit(child);
|
|
1086
|
+
}
|
|
1087
|
+
else if (child.nativeViewProtected) {
|
|
1088
|
+
const b = child._getCurrentLayoutBounds();
|
|
1089
|
+
const w = Utils.layout.makeMeasureSpec(b.right - b.left, Utils.layout.EXACTLY);
|
|
1090
|
+
const h = Utils.layout.makeMeasureSpec(b.bottom - b.top, Utils.layout.EXACTLY);
|
|
1091
|
+
NSView.measureChild(view, child, w, h);
|
|
1092
|
+
child.layout(b.left, b.top, b.right, b.bottom);
|
|
1093
|
+
}
|
|
1094
|
+
return true;
|
|
1095
|
+
});
|
|
1096
|
+
};
|
|
1097
|
+
visit(this);
|
|
1098
|
+
}
|
|
1099
|
+
requestLayout() {
|
|
1100
|
+
// A natively placed view only needs its Mason root re-measured: skip the
|
|
1101
|
+
// per-ancestor hops (each a JS call plus a native setNeedsLayout).
|
|
1102
|
+
if (this._masonPlacedNatively) {
|
|
1103
|
+
// CSS asks once per layout property; reuse this turn's root while it is still flagged.
|
|
1104
|
+
if (climbedRoots && this._masonClimbTurn === climbedRoots && climbedThisTurn(this._masonClimbRoot))
|
|
1105
|
+
return;
|
|
1106
|
+
let root = this.parent;
|
|
1107
|
+
while (root?.parent?.[isMasonView_])
|
|
1108
|
+
root = root.parent;
|
|
1109
|
+
if (root && !climbedThisTurn(root))
|
|
1110
|
+
root.requestLayout();
|
|
1111
|
+
this._masonClimbRoot = root;
|
|
1112
|
+
this._masonClimbTurn = climbedRoots;
|
|
1113
|
+
return;
|
|
1114
|
+
}
|
|
1115
|
+
// Core climbs on every call, once per changed property; once per turn is enough.
|
|
1116
|
+
if (__APPLE__ && climbedThisTurn(this))
|
|
1117
|
+
return;
|
|
1118
|
+
super.requestLayout();
|
|
1119
|
+
if (__APPLE__)
|
|
1120
|
+
markClimbed(this);
|
|
1121
|
+
}
|
|
1122
|
+
_parentChanged(oldParent) {
|
|
1123
|
+
climbedRoots?.delete(this);
|
|
1124
|
+
this._masonClimbTurn = null;
|
|
1125
|
+
super._parentChanged(oldParent);
|
|
1126
|
+
}
|
|
1127
|
+
getMeasuredWidth() {
|
|
1128
|
+
if (this._masonPlacedNatively && this.nativeViewProtected) {
|
|
1129
|
+
return Math.round(masonLayout.toDevicePixels(this.nativeViewProtected.frame.size.width));
|
|
1130
|
+
}
|
|
1131
|
+
return super.getMeasuredWidth();
|
|
1132
|
+
}
|
|
1133
|
+
getMeasuredHeight() {
|
|
1134
|
+
if (this._masonPlacedNatively && this.nativeViewProtected) {
|
|
1135
|
+
return Math.round(masonLayout.toDevicePixels(this.nativeViewProtected.frame.size.height));
|
|
1136
|
+
}
|
|
1137
|
+
return super.getMeasuredHeight();
|
|
1138
|
+
}
|
|
1139
|
+
eachChildView(callback) {
|
|
1140
|
+
this._eachViewChild(callback);
|
|
1141
|
+
}
|
|
1142
|
+
_addChildFromBuilder(name, value) {
|
|
1143
|
+
this.addChild(value);
|
|
1144
|
+
}
|
|
1145
|
+
getChildrenCount() {
|
|
1146
|
+
let count = 0;
|
|
1147
|
+
this._eachViewChild(() => count++);
|
|
1148
|
+
return count;
|
|
1149
|
+
}
|
|
1150
|
+
get _childrenCount() {
|
|
1151
|
+
return this.getChildrenCount();
|
|
1152
|
+
}
|
|
1153
|
+
getChildAt(index) {
|
|
1154
|
+
let found;
|
|
1155
|
+
let i = 0;
|
|
1156
|
+
this._eachViewChild((child) => {
|
|
1157
|
+
if (i++ === index)
|
|
1158
|
+
found = child;
|
|
1159
|
+
});
|
|
1160
|
+
return found;
|
|
1161
|
+
}
|
|
1162
|
+
getChildIndex(child) {
|
|
1163
|
+
let index = -1;
|
|
1164
|
+
let i = 0;
|
|
1165
|
+
this._eachViewChild((c) => {
|
|
1166
|
+
if (c === child && index === -1)
|
|
1167
|
+
index = i;
|
|
1168
|
+
i++;
|
|
1169
|
+
});
|
|
1170
|
+
return index;
|
|
1171
|
+
}
|
|
1172
|
+
getChildById(id) {
|
|
1173
|
+
return getViewById(this, id);
|
|
1174
|
+
}
|
|
1175
|
+
_nativeAttachIndex(child, atIndex) {
|
|
1176
|
+
const cur = this._attachCursor;
|
|
1177
|
+
let jsIndex;
|
|
1178
|
+
let nativeIndex;
|
|
1179
|
+
if (atIndex <= -1 && cur && this._children[cur.jsIndex] === cur.child && this._children[cur.jsIndex + 1] === child) {
|
|
1180
|
+
jsIndex = cur.jsIndex + 1;
|
|
1181
|
+
nativeIndex = cur.nativeIndex + 1;
|
|
1182
|
+
}
|
|
1183
|
+
else {
|
|
1184
|
+
jsIndex = atIndex <= -1 ? this._children.indexOf(child) : atIndex;
|
|
1185
|
+
nativeIndex = jsIndex <= -1 ? jsIndex : this._nativeIndexFor(jsIndex);
|
|
1186
|
+
}
|
|
1187
|
+
this._attachCursor = jsIndex >= 0 && nativeIndex >= 0 ? { child, jsIndex, nativeIndex } : undefined;
|
|
1188
|
+
return { jsIndex, nativeIndex };
|
|
1189
|
+
}
|
|
1190
|
+
_invalidateAttachCursor() {
|
|
1191
|
+
this._attachCursor = undefined;
|
|
1192
|
+
}
|
|
1193
|
+
/** Runs an iOS View's queued inserts before a native child edit. */
|
|
1194
|
+
_masonSettleNativeAdds() {
|
|
1195
|
+
if (this._masonPendingAdds)
|
|
1196
|
+
this._masonFlushNativeAdds();
|
|
1197
|
+
}
|
|
1198
|
+
_childIndexToNativeChildIndex(index) {
|
|
1199
|
+
if (false && typeof index === 'number' && index >= 0) {
|
|
1200
|
+
return this._nativeIndexFor(index);
|
|
1201
|
+
}
|
|
1202
|
+
return super._childIndexToNativeChildIndex(index);
|
|
1203
|
+
}
|
|
1204
|
+
[(_a = isMasonView_, _b = isTextChild_, _c = isText_, _d = pseudoStyles_, zIndexProperty.setNative)](value) {
|
|
1205
|
+
// @ts-ignore
|
|
1206
|
+
const style = this._styleHelper;
|
|
1207
|
+
if (style) {
|
|
1208
|
+
// @ts-ignore
|
|
1209
|
+
style.zIndex = value;
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1212
|
+
[directionProperty.setNative](value) {
|
|
1213
|
+
// @ts-ignore
|
|
1214
|
+
super[directionProperty.setNative]?.(value);
|
|
1215
|
+
const style = this._styleHelper;
|
|
1216
|
+
if (style)
|
|
1217
|
+
style.direction = value === 'rtl' || value === 'ltr' ? value : 'inherit';
|
|
1218
|
+
}
|
|
1219
|
+
set verticalAlign(value) {
|
|
1220
|
+
this.style.verticalAlign = value;
|
|
1221
|
+
}
|
|
1222
|
+
get verticalAlign() {
|
|
1223
|
+
return this.style.verticalAlign;
|
|
1224
|
+
}
|
|
1225
|
+
[verticalAlignProperty.setNative](value) {
|
|
1226
|
+
// @ts-ignore
|
|
1227
|
+
const style = this._styleHelper;
|
|
1228
|
+
if (style) {
|
|
1229
|
+
// @ts-ignore
|
|
1230
|
+
style.verticalAlign = value;
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
|
+
// @ts-ignore
|
|
1234
|
+
set flex(value) {
|
|
1235
|
+
this.style.flex = value;
|
|
1236
|
+
}
|
|
1237
|
+
get flex() {
|
|
1238
|
+
return this.style.flex;
|
|
1239
|
+
}
|
|
1240
|
+
set textWrap(value) {
|
|
1241
|
+
this.style.textWrap = value;
|
|
1242
|
+
}
|
|
1243
|
+
get textWrap() {
|
|
1244
|
+
return this.style.textWrap;
|
|
1245
|
+
}
|
|
1246
|
+
[textWrapProperty.setNative](value) {
|
|
1247
|
+
// @ts-ignore
|
|
1248
|
+
const style = this._styleHelper;
|
|
1249
|
+
if (style) {
|
|
1250
|
+
// @ts-ignore
|
|
1251
|
+
style.textWrap = value;
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1254
|
+
set aspectRatio(value) {
|
|
1255
|
+
this.style.aspectRatio = value;
|
|
1256
|
+
}
|
|
1257
|
+
get aspectRatio() {
|
|
1258
|
+
return this.style.aspectRatio;
|
|
1259
|
+
}
|
|
1260
|
+
[aspectRatioProperty.setNative](value) {
|
|
1261
|
+
// @ts-ignore
|
|
1262
|
+
const style = this._styleHelper;
|
|
1263
|
+
if (style) {
|
|
1264
|
+
// @ts-ignore
|
|
1265
|
+
style.aspectRatio = value;
|
|
1266
|
+
}
|
|
1267
|
+
}
|
|
1268
|
+
get filter() {
|
|
1269
|
+
return this.style.filter;
|
|
1270
|
+
}
|
|
1271
|
+
set filter(value) {
|
|
1272
|
+
this.style.filter = value;
|
|
1273
|
+
}
|
|
1274
|
+
[filterProperty.setNative](value) {
|
|
1275
|
+
// @ts-ignore
|
|
1276
|
+
const style = this._styleHelper;
|
|
1277
|
+
if (style) {
|
|
1278
|
+
// @ts-ignore
|
|
1279
|
+
style.filter = value;
|
|
1280
|
+
}
|
|
1281
|
+
}
|
|
1282
|
+
// @ts-ignore
|
|
1283
|
+
set borderRadius(value) {
|
|
1284
|
+
this.style.borderRadius = value;
|
|
1285
|
+
}
|
|
1286
|
+
get borderRadius() {
|
|
1287
|
+
return this.style.borderRadius;
|
|
1288
|
+
}
|
|
1289
|
+
[borderRadiusProperty.setNative](value) {
|
|
1290
|
+
// @ts-ignore
|
|
1291
|
+
const style = this._styleHelper;
|
|
1292
|
+
if (style) {
|
|
1293
|
+
// @ts-ignore
|
|
1294
|
+
style.borderRadius = value;
|
|
1295
|
+
this[borderRadiusCorners_] = undefined;
|
|
1296
|
+
}
|
|
1297
|
+
}
|
|
1298
|
+
[borderRadiusProperty.getDefault]() {
|
|
1299
|
+
// @ts-ignore
|
|
1300
|
+
return this._styleHelper?.borderRadius;
|
|
1301
|
+
}
|
|
1302
|
+
// `border-radius` / `border-color` arriving as core's longhands.
|
|
1303
|
+
_nativeBorderRadiusCorners() {
|
|
1304
|
+
// @ts-ignore
|
|
1305
|
+
const style = this._styleHelper;
|
|
1306
|
+
if ((__ANDROID__ || __APPLE__) && style && !style.hasBorderRadius()) {
|
|
1307
|
+
return borderRadiusCorners('0');
|
|
1308
|
+
}
|
|
1309
|
+
const native = String(style?.borderRadius ?? '').trim();
|
|
1310
|
+
try {
|
|
1311
|
+
return borderRadiusCorners(native || '0');
|
|
1312
|
+
}
|
|
1313
|
+
catch {
|
|
1314
|
+
return borderRadiusCorners('0');
|
|
1315
|
+
}
|
|
1316
|
+
}
|
|
1317
|
+
_borderRadiusCorner(corner, value) {
|
|
1318
|
+
// @ts-ignore
|
|
1319
|
+
const style = this._styleHelper;
|
|
1320
|
+
if (!style) {
|
|
1321
|
+
return;
|
|
1322
|
+
}
|
|
1323
|
+
if ((__ANDROID__ || __APPLE__) && !isCssLength(value) && style._writeCornerLength(corner, value)) {
|
|
1324
|
+
this[borderRadiusCorners_] = undefined;
|
|
1325
|
+
return;
|
|
1326
|
+
}
|
|
1327
|
+
let corners = this[borderRadiusCorners_];
|
|
1328
|
+
if (!corners) {
|
|
1329
|
+
corners = this[borderRadiusCorners_] = this._nativeBorderRadiusCorners();
|
|
1330
|
+
}
|
|
1331
|
+
// Resolve math functions first: the corner parser can't read them.
|
|
1332
|
+
const text = lengthToCssString(masonLength(value));
|
|
1333
|
+
const css = resolveCssMathIn(text, style.emBasisFor(text));
|
|
1334
|
+
const radius = (corners[corner] = /\s/.test(css) ? parseCornerRadius(css) : [css, css]);
|
|
1335
|
+
const shorthand = composeBorderRadius(corners);
|
|
1336
|
+
if ((__ANDROID__ || __APPLE__) && style._writeCornerRadius(corner, radius, shorthand)) {
|
|
1337
|
+
return;
|
|
1338
|
+
}
|
|
1339
|
+
// @ts-ignore
|
|
1340
|
+
style.borderRadius = shorthand;
|
|
1341
|
+
}
|
|
1342
|
+
_nativeCornerRadius(corner) {
|
|
1343
|
+
// @ts-ignore
|
|
1344
|
+
const style = this._styleHelper;
|
|
1345
|
+
if ((__ANDROID__ || __APPLE__) && style && style._cornerRadiusIsZero(corner)) {
|
|
1346
|
+
return '0';
|
|
1347
|
+
}
|
|
1348
|
+
const [h, v] = this._nativeBorderRadiusCorners()[corner];
|
|
1349
|
+
return h === v ? h : `${h} ${v}`;
|
|
1350
|
+
}
|
|
1351
|
+
[borderTopLeftRadiusProperty.getDefault]() {
|
|
1352
|
+
return this._nativeCornerRadius(0);
|
|
1353
|
+
}
|
|
1354
|
+
[borderTopRightRadiusProperty.getDefault]() {
|
|
1355
|
+
return this._nativeCornerRadius(1);
|
|
1356
|
+
}
|
|
1357
|
+
[borderBottomRightRadiusProperty.getDefault]() {
|
|
1358
|
+
return this._nativeCornerRadius(2);
|
|
1359
|
+
}
|
|
1360
|
+
[borderBottomLeftRadiusProperty.getDefault]() {
|
|
1361
|
+
return this._nativeCornerRadius(3);
|
|
1362
|
+
}
|
|
1363
|
+
[borderTopLeftRadiusProperty.setNative](value) {
|
|
1364
|
+
this._borderRadiusCorner(0, value);
|
|
1365
|
+
}
|
|
1366
|
+
[borderTopRightRadiusProperty.setNative](value) {
|
|
1367
|
+
this._borderRadiusCorner(1, value);
|
|
1368
|
+
}
|
|
1369
|
+
[borderBottomRightRadiusProperty.setNative](value) {
|
|
1370
|
+
this._borderRadiusCorner(2, value);
|
|
1371
|
+
}
|
|
1372
|
+
[borderBottomLeftRadiusProperty.setNative](value) {
|
|
1373
|
+
this._borderRadiusCorner(3, value);
|
|
1374
|
+
}
|
|
1375
|
+
_borderSideColor(side, value) {
|
|
1376
|
+
if (__ANDROID__ || __APPLE__) {
|
|
1377
|
+
const s = this._styleHelper;
|
|
1378
|
+
if (s) {
|
|
1379
|
+
s.setBorderSideColor(side === 't' ? 'top' : side === 'r' ? 'right' : side === 'b' ? 'bottom' : 'left', value);
|
|
1380
|
+
return;
|
|
1381
|
+
}
|
|
1382
|
+
}
|
|
1383
|
+
let sides = this[borderSideColors_];
|
|
1384
|
+
if (!sides) {
|
|
1385
|
+
sides = this[borderSideColors_] = { t: 'transparent', r: 'transparent', b: 'transparent', l: 'transparent' };
|
|
1386
|
+
}
|
|
1387
|
+
sides[side] = colorToCssString(value);
|
|
1388
|
+
const shorthand = `${sides.t} ${sides.r} ${sides.b} ${sides.l}`;
|
|
1389
|
+
if (__ANDROID__) {
|
|
1390
|
+
// @ts-ignore
|
|
1391
|
+
nodeHelper().setBorderColor(this.nativeView, shorthand);
|
|
1392
|
+
}
|
|
1393
|
+
else if (__APPLE__) {
|
|
1394
|
+
// @ts-ignore
|
|
1395
|
+
this.nativeView?.style?.setBorderColor(shorthand);
|
|
1396
|
+
}
|
|
1397
|
+
else if (false) {
|
|
1398
|
+
// @ts-ignore
|
|
1399
|
+
this._styleHelper?.setBorderColor(shorthand);
|
|
1400
|
+
}
|
|
1401
|
+
}
|
|
1402
|
+
[borderTopColorProperty.setNative](value) {
|
|
1403
|
+
this._borderSideColor('t', value);
|
|
1404
|
+
}
|
|
1405
|
+
[borderRightColorProperty.setNative](value) {
|
|
1406
|
+
this._borderSideColor('r', value);
|
|
1407
|
+
}
|
|
1408
|
+
[borderBottomColorProperty.setNative](value) {
|
|
1409
|
+
this._borderSideColor('b', value);
|
|
1410
|
+
}
|
|
1411
|
+
[borderLeftColorProperty.setNative](value) {
|
|
1412
|
+
this._borderSideColor('l', value);
|
|
1413
|
+
}
|
|
1414
|
+
set border(value) {
|
|
1415
|
+
this.style.border = value;
|
|
1416
|
+
}
|
|
1417
|
+
get border() {
|
|
1418
|
+
return this.style.border;
|
|
1419
|
+
}
|
|
1420
|
+
// @ts-ignore
|
|
1421
|
+
set background(value) {
|
|
1422
|
+
this.style.background = value;
|
|
1423
|
+
}
|
|
1424
|
+
get background() {
|
|
1425
|
+
return this.style.background;
|
|
1426
|
+
}
|
|
1427
|
+
[backgroundProperty.setNative](value) {
|
|
1428
|
+
// @ts-ignore
|
|
1429
|
+
const style = this._styleHelper;
|
|
1430
|
+
if (style) {
|
|
1431
|
+
// @ts-ignore
|
|
1432
|
+
style.background = value;
|
|
1433
|
+
}
|
|
1434
|
+
}
|
|
1435
|
+
[backgroundColorProperty.setNative](value) {
|
|
1436
|
+
// @ts-ignore
|
|
1437
|
+
const style = this._styleHelper;
|
|
1438
|
+
if (style) {
|
|
1439
|
+
// Pass the raw value straight through — the style setter's normalizeColorValue handles
|
|
1440
|
+
// number / string / Color / {argb} via duck-typing, which is robust even when a `Color`
|
|
1441
|
+
// instance comes from a different @nativescript/core copy (cross-copy `instanceof` fails).
|
|
1442
|
+
// @ts-ignore
|
|
1443
|
+
style.backgroundColor = value;
|
|
1444
|
+
return;
|
|
1445
|
+
// eslint-disable-next-line no-unreachable
|
|
1446
|
+
switch (typeof value) {
|
|
1447
|
+
case 'number':
|
|
1448
|
+
// @ts-ignore
|
|
1449
|
+
style.backgroundColor = value;
|
|
1450
|
+
return;
|
|
1451
|
+
case 'object':
|
|
1452
|
+
if (value instanceof Color) {
|
|
1453
|
+
// @ts-ignore
|
|
1454
|
+
style.backgroundColor = value.argb;
|
|
1455
|
+
return;
|
|
1456
|
+
}
|
|
1457
|
+
break;
|
|
1458
|
+
case 'string':
|
|
1459
|
+
try {
|
|
1460
|
+
const color = new Color(value);
|
|
1461
|
+
// @ts-ignore
|
|
1462
|
+
style.backgroundColor = color.argb;
|
|
1463
|
+
}
|
|
1464
|
+
catch (error) { }
|
|
1465
|
+
return;
|
|
1466
|
+
}
|
|
1467
|
+
}
|
|
1468
|
+
}
|
|
1469
|
+
[borderLeftWidthProperty.setNative](value) {
|
|
1470
|
+
// @ts-ignore
|
|
1471
|
+
const style = this._styleHelper;
|
|
1472
|
+
if (style) {
|
|
1473
|
+
// @ts-ignore
|
|
1474
|
+
style.borderLeftWidth = masonLength(value);
|
|
1475
|
+
}
|
|
1476
|
+
}
|
|
1477
|
+
[borderTopWidthProperty.setNative](value) {
|
|
1478
|
+
// @ts-ignore
|
|
1479
|
+
const style = this._styleHelper;
|
|
1480
|
+
if (style) {
|
|
1481
|
+
// @ts-ignore
|
|
1482
|
+
style.borderTopWidth = masonLength(value);
|
|
1483
|
+
}
|
|
1484
|
+
}
|
|
1485
|
+
[borderRightWidthProperty.setNative](value) {
|
|
1486
|
+
// @ts-ignore
|
|
1487
|
+
const style = this._styleHelper;
|
|
1488
|
+
if (style) {
|
|
1489
|
+
// @ts-ignore
|
|
1490
|
+
style.borderRightWidth = masonLength(value);
|
|
1491
|
+
}
|
|
1492
|
+
}
|
|
1493
|
+
[borderBottomWidthProperty.setNative](value) {
|
|
1494
|
+
// @ts-ignore
|
|
1495
|
+
const style = this._styleHelper;
|
|
1496
|
+
if (style) {
|
|
1497
|
+
// @ts-ignore
|
|
1498
|
+
style.borderBottomWidth = masonLength(value);
|
|
1499
|
+
}
|
|
1500
|
+
}
|
|
1501
|
+
[lineHeightProperty.setNative](value) {
|
|
1502
|
+
// @ts-ignore
|
|
1503
|
+
const style = this._styleHelper;
|
|
1504
|
+
// @ts-ignore
|
|
1505
|
+
if (style)
|
|
1506
|
+
style.lineHeight = masonRawDeclaration(this.style, 'lineHeight', value);
|
|
1507
|
+
}
|
|
1508
|
+
[letterSpacingProperty.setNative](value) {
|
|
1509
|
+
// @ts-ignore
|
|
1510
|
+
const style = this._styleHelper;
|
|
1511
|
+
// @ts-ignore
|
|
1512
|
+
if (style)
|
|
1513
|
+
style.letterSpacing = masonRawDeclaration(this.style, 'letterSpacing', value);
|
|
1514
|
+
}
|
|
1515
|
+
[textAlignmentProperty.setNative](value) {
|
|
1516
|
+
// @ts-ignore
|
|
1517
|
+
const style = this._styleHelper;
|
|
1518
|
+
// @ts-ignore
|
|
1519
|
+
if (style)
|
|
1520
|
+
style.textAlignment = value;
|
|
1521
|
+
}
|
|
1522
|
+
[textDecorationProperty.setNative](value) {
|
|
1523
|
+
// @ts-ignore
|
|
1524
|
+
const style = this._styleHelper;
|
|
1525
|
+
if (style) {
|
|
1526
|
+
style.textDecoration = String(value);
|
|
1527
|
+
// The shorthand resets every longhand natively, but core tracks each as its own
|
|
1528
|
+
// property and won't reapply one it already holds. Put the explicit ones back.
|
|
1529
|
+
const cssStyle = this.style;
|
|
1530
|
+
for (const name of ['textDecorationLine', 'textDecorationStyle', 'textDecorationColor', 'textDecorationThickness']) {
|
|
1531
|
+
const longhand = cssStyle[name];
|
|
1532
|
+
if (longhand !== undefined && longhand !== null && longhand !== '') {
|
|
1533
|
+
style[name] = longhand;
|
|
1534
|
+
}
|
|
1535
|
+
}
|
|
1536
|
+
}
|
|
1537
|
+
}
|
|
1538
|
+
// @ts-ignore
|
|
1539
|
+
[borderColorProperty.setNative](value) {
|
|
1540
|
+
if (__ANDROID__) {
|
|
1541
|
+
const s = this._styleHelper;
|
|
1542
|
+
if (s)
|
|
1543
|
+
s.setBorderColor(String(value));
|
|
1544
|
+
// @ts-ignore
|
|
1545
|
+
else
|
|
1546
|
+
nodeHelper().setBorderColor(this.nativeView, String(value));
|
|
1547
|
+
}
|
|
1548
|
+
else if (__APPLE__) {
|
|
1549
|
+
const s = this._styleHelper;
|
|
1550
|
+
if (s)
|
|
1551
|
+
s.setBorderColor(String(value));
|
|
1552
|
+
// @ts-ignore
|
|
1553
|
+
else
|
|
1554
|
+
this.nativeView.style.setBorderColor(String(value));
|
|
1555
|
+
}
|
|
1556
|
+
else if (false) {
|
|
1557
|
+
// @ts-ignore
|
|
1558
|
+
const style = this._styleHelper;
|
|
1559
|
+
// @ts-ignore
|
|
1560
|
+
if (style)
|
|
1561
|
+
style.setBorderColor(String(value));
|
|
1562
|
+
}
|
|
1563
|
+
}
|
|
1564
|
+
// `border-style`, `border` and `border-<side>` are shorthands over these.
|
|
1565
|
+
[borderTopStyleProperty.setNative](value) {
|
|
1566
|
+
// @ts-ignore
|
|
1567
|
+
const style = this._styleHelper;
|
|
1568
|
+
if (style)
|
|
1569
|
+
style.borderTopStyle = String(value ?? 'none');
|
|
1570
|
+
}
|
|
1571
|
+
[borderRightStyleProperty.setNative](value) {
|
|
1572
|
+
// @ts-ignore
|
|
1573
|
+
const style = this._styleHelper;
|
|
1574
|
+
if (style)
|
|
1575
|
+
style.borderRightStyle = String(value ?? 'none');
|
|
1576
|
+
}
|
|
1577
|
+
[borderBottomStyleProperty.setNative](value) {
|
|
1578
|
+
// @ts-ignore
|
|
1579
|
+
const style = this._styleHelper;
|
|
1580
|
+
if (style)
|
|
1581
|
+
style.borderBottomStyle = String(value ?? 'none');
|
|
1582
|
+
}
|
|
1583
|
+
[borderLeftStyleProperty.setNative](value) {
|
|
1584
|
+
// @ts-ignore
|
|
1585
|
+
const style = this._styleHelper;
|
|
1586
|
+
if (style)
|
|
1587
|
+
style.borderLeftStyle = String(value ?? 'none');
|
|
1588
|
+
}
|
|
1589
|
+
// @ts-ignore
|
|
1590
|
+
[backgroundImageProperty.setNative](value) {
|
|
1591
|
+
// @ts-ignore
|
|
1592
|
+
const style = this._styleHelper;
|
|
1593
|
+
if (style) {
|
|
1594
|
+
// @ts-ignore
|
|
1595
|
+
style.backgroundImage = backgroundImageToCssString(value);
|
|
1596
|
+
}
|
|
1597
|
+
}
|
|
1598
|
+
// @ts-ignore
|
|
1599
|
+
[listStyleTypeProperty.setNative](value) {
|
|
1600
|
+
if (__ANDROID__) {
|
|
1601
|
+
// @ts-ignore
|
|
1602
|
+
nodeHelper().setListStyleType(this.nativeView, String(value));
|
|
1603
|
+
}
|
|
1604
|
+
else if (__APPLE__) {
|
|
1605
|
+
// @ts-ignore
|
|
1606
|
+
this.nativeView.style.applyListStyleType(String(value));
|
|
1607
|
+
}
|
|
1608
|
+
else if (false) {
|
|
1609
|
+
const style = this._styleHelper;
|
|
1610
|
+
const type = String(value).trim().toLowerCase();
|
|
1611
|
+
if (style && (type === 'none' || type === 'disc' || type === 'circle' || type === 'square' || type === 'decimal'))
|
|
1612
|
+
style.listStyleType = type;
|
|
1613
|
+
}
|
|
1614
|
+
}
|
|
1615
|
+
// @ts-ignore
|
|
1616
|
+
[listStylePositionProperty.setNative](value) {
|
|
1617
|
+
if (__ANDROID__) {
|
|
1618
|
+
// @ts-ignore
|
|
1619
|
+
nodeHelper().setListStylePosition(this.nativeView, String(value));
|
|
1620
|
+
}
|
|
1621
|
+
else if (__APPLE__) {
|
|
1622
|
+
// @ts-ignore
|
|
1623
|
+
this.nativeView.style.applyListStylePosition(String(value));
|
|
1624
|
+
}
|
|
1625
|
+
else if (false) {
|
|
1626
|
+
const style = this._styleHelper;
|
|
1627
|
+
const position = String(value).trim().toLowerCase();
|
|
1628
|
+
if (style && (position === 'inside' || position === 'outside'))
|
|
1629
|
+
style.listStylePosition = position;
|
|
1630
|
+
}
|
|
1631
|
+
}
|
|
1632
|
+
get boxSizing() {
|
|
1633
|
+
return this.style.boxSizing;
|
|
1634
|
+
}
|
|
1635
|
+
set boxSizing(value) {
|
|
1636
|
+
this.style.boxSizing = value;
|
|
1637
|
+
}
|
|
1638
|
+
[boxSizingProperty.setNative](value) {
|
|
1639
|
+
// @ts-ignore
|
|
1640
|
+
const style = this._styleHelper;
|
|
1641
|
+
if (style) {
|
|
1642
|
+
// @ts-ignore
|
|
1643
|
+
style.boxSizing = value;
|
|
1644
|
+
}
|
|
1645
|
+
}
|
|
1646
|
+
get display() {
|
|
1647
|
+
return this.style.display;
|
|
1648
|
+
}
|
|
1649
|
+
set display(value) {
|
|
1650
|
+
this.style.display = value;
|
|
1651
|
+
}
|
|
1652
|
+
[displayProperty.setNative](value) {
|
|
1653
|
+
// @ts-ignore
|
|
1654
|
+
const style = this._styleHelper;
|
|
1655
|
+
if (style) {
|
|
1656
|
+
// @ts-ignore
|
|
1657
|
+
style.display = value;
|
|
1658
|
+
}
|
|
1659
|
+
}
|
|
1660
|
+
get overflow() {
|
|
1661
|
+
return this.style.overflow;
|
|
1662
|
+
}
|
|
1663
|
+
set overflow(value) {
|
|
1664
|
+
this.style.overflow = value;
|
|
1665
|
+
}
|
|
1666
|
+
get overflowX() {
|
|
1667
|
+
return this.style.overflowX;
|
|
1668
|
+
}
|
|
1669
|
+
set overflowX(value) {
|
|
1670
|
+
this.style.overflowX = value;
|
|
1671
|
+
}
|
|
1672
|
+
[overflowXProperty.setNative](value) {
|
|
1673
|
+
// @ts-ignore
|
|
1674
|
+
const style = this._styleHelper;
|
|
1675
|
+
if (style) {
|
|
1676
|
+
// @ts-ignore
|
|
1677
|
+
style.overflowX = value;
|
|
1678
|
+
}
|
|
1679
|
+
}
|
|
1680
|
+
get overflowY() {
|
|
1681
|
+
return this.style.overflowY;
|
|
1682
|
+
}
|
|
1683
|
+
set overflowY(value) {
|
|
1684
|
+
this.style.overflowY = value;
|
|
1685
|
+
}
|
|
1686
|
+
[overflowYProperty.setNative](value) {
|
|
1687
|
+
// @ts-ignore
|
|
1688
|
+
const style = this._styleHelper;
|
|
1689
|
+
if (style) {
|
|
1690
|
+
// @ts-ignore
|
|
1691
|
+
style.overflowY = value;
|
|
1692
|
+
}
|
|
1693
|
+
}
|
|
1694
|
+
get scrollBarWidth() {
|
|
1695
|
+
return this.style.scrollBarWidth;
|
|
1696
|
+
}
|
|
1697
|
+
set scrollBarWidth(value) {
|
|
1698
|
+
this.style.scrollBarWidth = value;
|
|
1699
|
+
}
|
|
1700
|
+
[scrollBarWidthProperty.setNative](value) {
|
|
1701
|
+
// @ts-ignore
|
|
1702
|
+
const style = this._styleHelper;
|
|
1703
|
+
if (style) {
|
|
1704
|
+
// @ts-ignore
|
|
1705
|
+
style.scrollBarWidth = value;
|
|
1706
|
+
}
|
|
1707
|
+
}
|
|
1708
|
+
get position() {
|
|
1709
|
+
return this.style.position;
|
|
1710
|
+
}
|
|
1711
|
+
set position(value) {
|
|
1712
|
+
this.style.position = value;
|
|
1713
|
+
}
|
|
1714
|
+
[positionProperty.setNative](value) {
|
|
1715
|
+
// @ts-ignore
|
|
1716
|
+
const style = this._styleHelper;
|
|
1717
|
+
if (style) {
|
|
1718
|
+
// @ts-ignore
|
|
1719
|
+
style.position = value;
|
|
1720
|
+
}
|
|
1721
|
+
}
|
|
1722
|
+
// Font props only land in the style buffer, which the TextBlock-backed text doesn't read, so they
|
|
1723
|
+
// must be forwarded to the native Text control to take visual effect. No-op off a Text container.
|
|
1724
|
+
_applyTextRunProp(method, arg) {
|
|
1725
|
+
if (!false)
|
|
1726
|
+
return;
|
|
1727
|
+
try {
|
|
1728
|
+
const view = this._view;
|
|
1729
|
+
if (view && typeof view[method] === 'function')
|
|
1730
|
+
view[method](arg);
|
|
1731
|
+
}
|
|
1732
|
+
catch (_) { }
|
|
1733
|
+
}
|
|
1734
|
+
[colorProperty.setNative](value) {
|
|
1735
|
+
// @ts-ignore
|
|
1736
|
+
const style = this._styleHelper;
|
|
1737
|
+
if (style) {
|
|
1738
|
+
// Duck-typed via normalizeColorValue (robust to cross-core Color instances).
|
|
1739
|
+
// @ts-ignore
|
|
1740
|
+
style.color = value;
|
|
1741
|
+
if (false) {
|
|
1742
|
+
// Push the resolved color to the Text container's TextBlock (the default for all runs).
|
|
1743
|
+
// Imperative — not during layout.
|
|
1744
|
+
try {
|
|
1745
|
+
const argb = style.color >>> 0 || 0;
|
|
1746
|
+
const view = this._view;
|
|
1747
|
+
if (view && argb && typeof view.SetColor === 'function')
|
|
1748
|
+
view.SetColor(argb);
|
|
1749
|
+
}
|
|
1750
|
+
catch (_) { }
|
|
1751
|
+
}
|
|
1752
|
+
}
|
|
1753
|
+
}
|
|
1754
|
+
[flexWrapProperty.setNative](value) {
|
|
1755
|
+
// @ts-ignore
|
|
1756
|
+
const style = this._styleHelper;
|
|
1757
|
+
if (style) {
|
|
1758
|
+
style.flexWrap = value;
|
|
1759
|
+
}
|
|
1760
|
+
}
|
|
1761
|
+
[flexDirectionProperty.setNative](value) {
|
|
1762
|
+
// @ts-ignore
|
|
1763
|
+
const style = this._styleHelper;
|
|
1764
|
+
if (style) {
|
|
1765
|
+
style.flexDirection = value;
|
|
1766
|
+
}
|
|
1767
|
+
}
|
|
1768
|
+
[flexGrowProperty.setNative](value) {
|
|
1769
|
+
// @ts-ignore
|
|
1770
|
+
const style = this._styleHelper;
|
|
1771
|
+
if (style) {
|
|
1772
|
+
style.flexGrow = value;
|
|
1773
|
+
}
|
|
1774
|
+
}
|
|
1775
|
+
[flexShrinkProperty.setNative](value) {
|
|
1776
|
+
// @ts-ignore
|
|
1777
|
+
const style = this._styleHelper;
|
|
1778
|
+
if (style) {
|
|
1779
|
+
style.flexShrink = value;
|
|
1780
|
+
}
|
|
1781
|
+
}
|
|
1782
|
+
[flexBasisProperty.setNative](value) {
|
|
1783
|
+
// @ts-ignore
|
|
1784
|
+
const style = this._styleHelper;
|
|
1785
|
+
if (style) {
|
|
1786
|
+
style.flexBasis = value;
|
|
1787
|
+
}
|
|
1788
|
+
}
|
|
1789
|
+
[alignItemsProperty.setNative](value) {
|
|
1790
|
+
// @ts-ignore
|
|
1791
|
+
const style = this._styleHelper;
|
|
1792
|
+
if (style) {
|
|
1793
|
+
style.alignItems = value;
|
|
1794
|
+
}
|
|
1795
|
+
}
|
|
1796
|
+
[alignSelfProperty.setNative](value) {
|
|
1797
|
+
// @ts-ignore
|
|
1798
|
+
const style = this._styleHelper;
|
|
1799
|
+
if (style) {
|
|
1800
|
+
style.alignSelf = value;
|
|
1801
|
+
}
|
|
1802
|
+
}
|
|
1803
|
+
get alignContent() {
|
|
1804
|
+
return this.style.alignContent;
|
|
1805
|
+
}
|
|
1806
|
+
set alignContent(value) {
|
|
1807
|
+
this.style.alignContent = value;
|
|
1808
|
+
}
|
|
1809
|
+
[alignContentProperty.setNative](value) {
|
|
1810
|
+
// @ts-ignore
|
|
1811
|
+
const style = this._styleHelper;
|
|
1812
|
+
if (style) {
|
|
1813
|
+
style.alignContent = value;
|
|
1814
|
+
}
|
|
1815
|
+
}
|
|
1816
|
+
get justifyItems() {
|
|
1817
|
+
return this.style.justifyItems;
|
|
1818
|
+
}
|
|
1819
|
+
set justifyItems(value) {
|
|
1820
|
+
this.style.justifyItems = value;
|
|
1821
|
+
}
|
|
1822
|
+
[justifyItemsProperty.setNative](value) {
|
|
1823
|
+
// @ts-ignore
|
|
1824
|
+
const style = this._styleHelper;
|
|
1825
|
+
if (style) {
|
|
1826
|
+
style.justifyItems = value;
|
|
1827
|
+
}
|
|
1828
|
+
}
|
|
1829
|
+
get justifySelf() {
|
|
1830
|
+
return this.style.justifySelf;
|
|
1831
|
+
}
|
|
1832
|
+
set justifySelf(value) {
|
|
1833
|
+
this.style.justifySelf = value;
|
|
1834
|
+
}
|
|
1835
|
+
[justifySelfProperty.setNative](value) {
|
|
1836
|
+
// @ts-ignore
|
|
1837
|
+
const style = this._styleHelper;
|
|
1838
|
+
if (style) {
|
|
1839
|
+
style.justifySelf = value;
|
|
1840
|
+
}
|
|
1841
|
+
}
|
|
1842
|
+
[justifyContentProperty.setNative](value) {
|
|
1843
|
+
// @ts-ignore
|
|
1844
|
+
const style = this._styleHelper;
|
|
1845
|
+
if (style) {
|
|
1846
|
+
style.justifyContent = value;
|
|
1847
|
+
}
|
|
1848
|
+
}
|
|
1849
|
+
[leftProperty.setNative](value) {
|
|
1850
|
+
// @ts-ignore
|
|
1851
|
+
const style = this._styleHelper;
|
|
1852
|
+
if (style) {
|
|
1853
|
+
style.left = value;
|
|
1854
|
+
}
|
|
1855
|
+
}
|
|
1856
|
+
get right() {
|
|
1857
|
+
return this.style.right;
|
|
1858
|
+
}
|
|
1859
|
+
set right(value) {
|
|
1860
|
+
this.style.right = value;
|
|
1861
|
+
}
|
|
1862
|
+
[rightProperty.setNative](value) {
|
|
1863
|
+
// @ts-ignore
|
|
1864
|
+
const style = this._styleHelper;
|
|
1865
|
+
if (style) {
|
|
1866
|
+
style.right = value;
|
|
1867
|
+
}
|
|
1868
|
+
}
|
|
1869
|
+
get bottom() {
|
|
1870
|
+
return this.style.bottom;
|
|
1871
|
+
}
|
|
1872
|
+
set bottom(value) {
|
|
1873
|
+
this.style.bottom = value;
|
|
1874
|
+
}
|
|
1875
|
+
[bottomProperty.setNative](value) {
|
|
1876
|
+
// @ts-ignore
|
|
1877
|
+
const style = this._styleHelper;
|
|
1878
|
+
if (style) {
|
|
1879
|
+
style.bottom = value;
|
|
1880
|
+
}
|
|
1881
|
+
}
|
|
1882
|
+
[topProperty.setNative](value) {
|
|
1883
|
+
// @ts-ignore
|
|
1884
|
+
const style = this._styleHelper;
|
|
1885
|
+
if (style) {
|
|
1886
|
+
style.top = value;
|
|
1887
|
+
}
|
|
1888
|
+
}
|
|
1889
|
+
[minWidthProperty.setNative](value) {
|
|
1890
|
+
// @ts-ignore
|
|
1891
|
+
const style = this._styleHelper;
|
|
1892
|
+
if (style) {
|
|
1893
|
+
style.minWidth = value;
|
|
1894
|
+
}
|
|
1895
|
+
}
|
|
1896
|
+
[minHeightProperty.setNative](value) {
|
|
1897
|
+
// @ts-ignore
|
|
1898
|
+
const style = this._styleHelper;
|
|
1899
|
+
if (style) {
|
|
1900
|
+
style.minHeight = value;
|
|
1901
|
+
}
|
|
1902
|
+
}
|
|
1903
|
+
[heightProperty.setNative](value) {
|
|
1904
|
+
// @ts-ignore
|
|
1905
|
+
const style = this._styleHelper;
|
|
1906
|
+
if (style) {
|
|
1907
|
+
style.height = value;
|
|
1908
|
+
}
|
|
1909
|
+
}
|
|
1910
|
+
[widthProperty.setNative](value) {
|
|
1911
|
+
// @ts-ignore
|
|
1912
|
+
const style = this._styleHelper;
|
|
1913
|
+
if (style) {
|
|
1914
|
+
style.width = value;
|
|
1915
|
+
}
|
|
1916
|
+
}
|
|
1917
|
+
// @ts-ignore core declares maxWidth as a field on View
|
|
1918
|
+
set maxWidth(value) {
|
|
1919
|
+
this.style.maxWidth = value;
|
|
1920
|
+
}
|
|
1921
|
+
// @ts-ignore
|
|
1922
|
+
get maxWidth() {
|
|
1923
|
+
return this.style.maxWidth;
|
|
1924
|
+
}
|
|
1925
|
+
// @ts-ignore core declares maxHeight as a field on View
|
|
1926
|
+
set maxHeight(value) {
|
|
1927
|
+
this.style.maxHeight = value;
|
|
1928
|
+
}
|
|
1929
|
+
// @ts-ignore
|
|
1930
|
+
get maxHeight() {
|
|
1931
|
+
return this.style.maxHeight;
|
|
1932
|
+
}
|
|
1933
|
+
[maxWidthProperty.setNative](value) {
|
|
1934
|
+
// @ts-ignore
|
|
1935
|
+
const style = this._styleHelper;
|
|
1936
|
+
if (style) {
|
|
1937
|
+
style.maxWidth = value;
|
|
1938
|
+
}
|
|
1939
|
+
}
|
|
1940
|
+
[maxHeightProperty.setNative](value) {
|
|
1941
|
+
// @ts-ignore
|
|
1942
|
+
const style = this._styleHelper;
|
|
1943
|
+
if (style) {
|
|
1944
|
+
style.maxHeight = value;
|
|
1945
|
+
}
|
|
1946
|
+
}
|
|
1947
|
+
_redrawNativeBackground(value) { }
|
|
1948
|
+
[backgroundInternalProperty.getDefault]() {
|
|
1949
|
+
if (__ANDROID__ || __APPLE__)
|
|
1950
|
+
return null;
|
|
1951
|
+
// @ts-ignore
|
|
1952
|
+
return super[backgroundInternalProperty.getDefault]?.();
|
|
1953
|
+
}
|
|
1954
|
+
[marginProperty.setNative](value) {
|
|
1955
|
+
// @ts-ignore
|
|
1956
|
+
const style = this._styleHelper;
|
|
1957
|
+
if (style) {
|
|
1958
|
+
style.marginCss = value;
|
|
1959
|
+
}
|
|
1960
|
+
}
|
|
1961
|
+
[marginLeftProperty.setNative](value) {
|
|
1962
|
+
// @ts-ignore
|
|
1963
|
+
const style = this._styleHelper;
|
|
1964
|
+
if (style) {
|
|
1965
|
+
style.marginLeft = masonLength(value);
|
|
1966
|
+
}
|
|
1967
|
+
}
|
|
1968
|
+
[marginRightProperty.setNative](value) {
|
|
1969
|
+
// @ts-ignore
|
|
1970
|
+
const style = this._styleHelper;
|
|
1971
|
+
if (style) {
|
|
1972
|
+
style.marginRight = masonLength(value);
|
|
1973
|
+
}
|
|
1974
|
+
}
|
|
1975
|
+
[marginBottomProperty.setNative](value) {
|
|
1976
|
+
// @ts-ignore
|
|
1977
|
+
const style = this._styleHelper;
|
|
1978
|
+
if (style) {
|
|
1979
|
+
style.marginBottom = masonLength(value);
|
|
1980
|
+
}
|
|
1981
|
+
}
|
|
1982
|
+
[marginTopProperty.setNative](value) {
|
|
1983
|
+
// @ts-ignore
|
|
1984
|
+
const style = this._styleHelper;
|
|
1985
|
+
if (style) {
|
|
1986
|
+
style.marginTop = masonLength(value);
|
|
1987
|
+
}
|
|
1988
|
+
}
|
|
1989
|
+
get padding() {
|
|
1990
|
+
return this.style.padding;
|
|
1991
|
+
}
|
|
1992
|
+
set padding(value) {
|
|
1993
|
+
this.style.padding = value;
|
|
1994
|
+
}
|
|
1995
|
+
[paddingProperty.setNative](value) {
|
|
1996
|
+
// @ts-ignore
|
|
1997
|
+
const style = this._styleHelper;
|
|
1998
|
+
if (style) {
|
|
1999
|
+
// @ts-ignore
|
|
2000
|
+
style.paddingCss = value;
|
|
2001
|
+
}
|
|
2002
|
+
}
|
|
2003
|
+
[paddingLeftProperty.setNative](value) {
|
|
2004
|
+
// @ts-ignore
|
|
2005
|
+
const style = this._styleHelper;
|
|
2006
|
+
if (style) {
|
|
2007
|
+
style.paddingLeft = masonLength(value);
|
|
2008
|
+
}
|
|
2009
|
+
}
|
|
2010
|
+
[paddingRightProperty.setNative](value) {
|
|
2011
|
+
// @ts-ignore
|
|
2012
|
+
const style = this._styleHelper;
|
|
2013
|
+
if (style) {
|
|
2014
|
+
style.paddingRight = masonLength(value);
|
|
2015
|
+
}
|
|
2016
|
+
}
|
|
2017
|
+
[paddingTopProperty.setNative](value) {
|
|
2018
|
+
// @ts-ignore
|
|
2019
|
+
const style = this._styleHelper;
|
|
2020
|
+
if (style) {
|
|
2021
|
+
style.paddingTop = masonLength(value);
|
|
2022
|
+
}
|
|
2023
|
+
}
|
|
2024
|
+
[paddingBottomProperty.setNative](value) {
|
|
2025
|
+
// @ts-ignore
|
|
2026
|
+
const style = this._styleHelper;
|
|
2027
|
+
if (style) {
|
|
2028
|
+
style.paddingBottom = masonLength(value);
|
|
2029
|
+
}
|
|
2030
|
+
}
|
|
2031
|
+
set gap(value) {
|
|
2032
|
+
this.style.gap = value;
|
|
2033
|
+
}
|
|
2034
|
+
get gap() {
|
|
2035
|
+
return this.style.gap;
|
|
2036
|
+
}
|
|
2037
|
+
set gridGap(value) {
|
|
2038
|
+
this.style.gridGap = value;
|
|
2039
|
+
}
|
|
2040
|
+
get gridGap() {
|
|
2041
|
+
return this.style.gridGap;
|
|
2042
|
+
}
|
|
2043
|
+
set rowGap(value) {
|
|
2044
|
+
this.style.rowGap = value;
|
|
2045
|
+
}
|
|
2046
|
+
get rowGap() {
|
|
2047
|
+
return this.style.rowGap;
|
|
2048
|
+
}
|
|
2049
|
+
[rowGapProperty.setNative](value) {
|
|
2050
|
+
// @ts-ignore
|
|
2051
|
+
const style = this._styleHelper;
|
|
2052
|
+
if (style) {
|
|
2053
|
+
// @ts-ignore
|
|
2054
|
+
style.rowGap = value;
|
|
2055
|
+
}
|
|
2056
|
+
}
|
|
2057
|
+
set columnGap(value) {
|
|
2058
|
+
this.style.columnGap = value;
|
|
2059
|
+
}
|
|
2060
|
+
get columnGap() {
|
|
2061
|
+
return this.style.columnGap;
|
|
2062
|
+
}
|
|
2063
|
+
[columnGapProperty.setNative](value) {
|
|
2064
|
+
// @ts-ignore
|
|
2065
|
+
const style = this._styleHelper;
|
|
2066
|
+
if (style) {
|
|
2067
|
+
// @ts-ignore
|
|
2068
|
+
style.columnGap = value;
|
|
2069
|
+
}
|
|
2070
|
+
}
|
|
2071
|
+
set gridColumnStart(value) {
|
|
2072
|
+
this.style.gridColumnStart = value;
|
|
2073
|
+
}
|
|
2074
|
+
get gridColumnStart() {
|
|
2075
|
+
return this.style.gridColumnStart;
|
|
2076
|
+
}
|
|
2077
|
+
[gridColumnStartProperty.setNative](value) {
|
|
2078
|
+
// @ts-ignore
|
|
2079
|
+
const style = this._styleHelper;
|
|
2080
|
+
if (style) {
|
|
2081
|
+
// @ts-ignore
|
|
2082
|
+
style.gridColumnStart = value;
|
|
2083
|
+
}
|
|
2084
|
+
}
|
|
2085
|
+
set gridColumnEnd(value) {
|
|
2086
|
+
this.style.gridColumnEnd = value;
|
|
2087
|
+
}
|
|
2088
|
+
get gridColumnEnd() {
|
|
2089
|
+
return this.style.gridColumnEnd;
|
|
2090
|
+
}
|
|
2091
|
+
[gridColumnEndProperty.setNative](value) {
|
|
2092
|
+
// @ts-ignore
|
|
2093
|
+
const style = this._styleHelper;
|
|
2094
|
+
if (style) {
|
|
2095
|
+
// @ts-ignore
|
|
2096
|
+
style.gridColumnEnd = value;
|
|
2097
|
+
}
|
|
2098
|
+
}
|
|
2099
|
+
get gridColumn() {
|
|
2100
|
+
return this.style.gridColumn;
|
|
2101
|
+
}
|
|
2102
|
+
set gridColumn(value) {
|
|
2103
|
+
this.style.gridColumn = value;
|
|
2104
|
+
}
|
|
2105
|
+
[gridColumnProperty.setNative](value) {
|
|
2106
|
+
// @ts-ignore
|
|
2107
|
+
const style = this._styleHelper;
|
|
2108
|
+
if (style) {
|
|
2109
|
+
// @ts-ignore
|
|
2110
|
+
style.gridColumn = value;
|
|
2111
|
+
}
|
|
2112
|
+
}
|
|
2113
|
+
set gridRowStart(value) {
|
|
2114
|
+
this.style.gridRowStart = value;
|
|
2115
|
+
}
|
|
2116
|
+
get gridRowStart() {
|
|
2117
|
+
return this.style.gridRowStart;
|
|
2118
|
+
}
|
|
2119
|
+
[gridRowStartProperty.setNative](value) {
|
|
2120
|
+
// @ts-ignore
|
|
2121
|
+
const style = this._styleHelper;
|
|
2122
|
+
if (style) {
|
|
2123
|
+
// @ts-ignore
|
|
2124
|
+
style.gridRowStart = value;
|
|
2125
|
+
}
|
|
2126
|
+
}
|
|
2127
|
+
set gridRowEnd(value) {
|
|
2128
|
+
this.style.gridRowEnd = value;
|
|
2129
|
+
}
|
|
2130
|
+
get gridRowEnd() {
|
|
2131
|
+
return this.style.gridRowEnd;
|
|
2132
|
+
}
|
|
2133
|
+
[gridRowEndProperty.setNative](value) {
|
|
2134
|
+
// @ts-ignore
|
|
2135
|
+
const style = this._styleHelper;
|
|
2136
|
+
if (style) {
|
|
2137
|
+
// @ts-ignore
|
|
2138
|
+
style.gridRowEnd = value;
|
|
2139
|
+
}
|
|
2140
|
+
}
|
|
2141
|
+
get gridRow() {
|
|
2142
|
+
return this.style.gridRow;
|
|
2143
|
+
}
|
|
2144
|
+
set gridRow(value) {
|
|
2145
|
+
this.style.gridRow = value;
|
|
2146
|
+
}
|
|
2147
|
+
[gridRowProperty.setNative](value) {
|
|
2148
|
+
// @ts-ignore
|
|
2149
|
+
const style = this._styleHelper;
|
|
2150
|
+
if (style) {
|
|
2151
|
+
// @ts-ignore
|
|
2152
|
+
style.gridRow = value;
|
|
2153
|
+
}
|
|
2154
|
+
}
|
|
2155
|
+
set gridTemplateRows(value) {
|
|
2156
|
+
this.style.gridTemplateRows = value;
|
|
2157
|
+
}
|
|
2158
|
+
get gridTemplateRows() {
|
|
2159
|
+
return this.style.gridTemplateRows;
|
|
2160
|
+
}
|
|
2161
|
+
[gridTemplateRowsProperty.setNative](value) {
|
|
2162
|
+
// @ts-ignore
|
|
2163
|
+
const style = this._styleHelper;
|
|
2164
|
+
if (style) {
|
|
2165
|
+
// @ts-ignore
|
|
2166
|
+
style.gridTemplateRows = value;
|
|
2167
|
+
}
|
|
2168
|
+
}
|
|
2169
|
+
set gridTemplateColumns(value) {
|
|
2170
|
+
this.style.gridTemplateColumns = value;
|
|
2171
|
+
}
|
|
2172
|
+
get gridTemplateColumns() {
|
|
2173
|
+
return this.style.gridTemplateColumns;
|
|
2174
|
+
}
|
|
2175
|
+
[gridTemplateColumnsProperty.setNative](value) {
|
|
2176
|
+
// @ts-ignore
|
|
2177
|
+
const style = this._styleHelper;
|
|
2178
|
+
if (style) {
|
|
2179
|
+
// @ts-ignore
|
|
2180
|
+
style.gridTemplateColumns = value;
|
|
2181
|
+
}
|
|
2182
|
+
}
|
|
2183
|
+
set gridAutoColumns(value) {
|
|
2184
|
+
this.style.gridAutoColumns = value;
|
|
2185
|
+
}
|
|
2186
|
+
get gridAutoColumns() {
|
|
2187
|
+
return this.style.gridAutoColumns;
|
|
2188
|
+
}
|
|
2189
|
+
[gridAutoColumnsProperty.setNative](value) {
|
|
2190
|
+
// @ts-ignore
|
|
2191
|
+
const style = this._styleHelper;
|
|
2192
|
+
if (style) {
|
|
2193
|
+
// @ts-ignore
|
|
2194
|
+
style.gridAutoColumns = value;
|
|
2195
|
+
}
|
|
2196
|
+
}
|
|
2197
|
+
set gridAutoRows(value) {
|
|
2198
|
+
this.style.gridAutoRows = value;
|
|
2199
|
+
}
|
|
2200
|
+
get gridAutoRows() {
|
|
2201
|
+
return this.style.gridAutoRows;
|
|
2202
|
+
}
|
|
2203
|
+
[gridAutoRowsProperty.setNative](value) {
|
|
2204
|
+
// @ts-ignore
|
|
2205
|
+
const style = this._styleHelper;
|
|
2206
|
+
if (style) {
|
|
2207
|
+
// @ts-ignore
|
|
2208
|
+
style.gridAutoRows = value;
|
|
2209
|
+
}
|
|
2210
|
+
}
|
|
2211
|
+
set gridAutoFlow(value) {
|
|
2212
|
+
this.style.gridAutoFlow = value;
|
|
2213
|
+
}
|
|
2214
|
+
get gridAutoFlow() {
|
|
2215
|
+
return this.style.gridAutoFlow;
|
|
2216
|
+
}
|
|
2217
|
+
[gridAutoFlowProperty.setNative](value) {
|
|
2218
|
+
// @ts-ignore
|
|
2219
|
+
const style = this._styleHelper;
|
|
2220
|
+
if (style) {
|
|
2221
|
+
// @ts-ignore
|
|
2222
|
+
style.gridAutoFlow = value;
|
|
2223
|
+
}
|
|
2224
|
+
}
|
|
2225
|
+
set gridArea(value) {
|
|
2226
|
+
this.style.gridArea = value;
|
|
2227
|
+
}
|
|
2228
|
+
get gridArea() {
|
|
2229
|
+
return this.style.gridArea;
|
|
2230
|
+
}
|
|
2231
|
+
[gridAreaProperty.setNative](value) {
|
|
2232
|
+
// @ts-ignore
|
|
2233
|
+
const style = this._styleHelper;
|
|
2234
|
+
if (style) {
|
|
2235
|
+
// @ts-ignore
|
|
2236
|
+
style.gridArea = value;
|
|
2237
|
+
}
|
|
2238
|
+
}
|
|
2239
|
+
set gridTemplateAreas(value) {
|
|
2240
|
+
this.style.gridTemplateAreas = value;
|
|
2241
|
+
}
|
|
2242
|
+
get gridTemplateAreas() {
|
|
2243
|
+
return this.style.gridTemplateAreas;
|
|
2244
|
+
}
|
|
2245
|
+
[gridTemplateAreasProperty.setNative](value) {
|
|
2246
|
+
// @ts-ignore
|
|
2247
|
+
const style = this._styleHelper;
|
|
2248
|
+
if (style) {
|
|
2249
|
+
// @ts-ignore
|
|
2250
|
+
style.gridTemplateAreas = value;
|
|
2251
|
+
}
|
|
2252
|
+
}
|
|
2253
|
+
[fontSizeProperty.setNative](value) {
|
|
2254
|
+
// @ts-ignore
|
|
2255
|
+
if (this._styleHelper) {
|
|
2256
|
+
//@ts-ignore
|
|
2257
|
+
this._styleHelper.fontSize = value;
|
|
2258
|
+
}
|
|
2259
|
+
}
|
|
2260
|
+
[fontWeightProperty.setNative](value) {
|
|
2261
|
+
// @ts-ignore
|
|
2262
|
+
if (this._styleHelper) {
|
|
2263
|
+
//@ts-ignore
|
|
2264
|
+
this._styleHelper.fontWeight = value;
|
|
2265
|
+
}
|
|
2266
|
+
}
|
|
2267
|
+
[fontStyleProperty.setNative](value) {
|
|
2268
|
+
// @ts-ignore
|
|
2269
|
+
if (this._styleHelper) {
|
|
2270
|
+
//@ts-ignore
|
|
2271
|
+
this._styleHelper.fontStyle = value;
|
|
2272
|
+
}
|
|
2273
|
+
}
|
|
2274
|
+
set flexFlowProperty(value) {
|
|
2275
|
+
this.style.flexFlow = value;
|
|
2276
|
+
}
|
|
2277
|
+
get flexFlowProperty() {
|
|
2278
|
+
return this.style.flexFlow;
|
|
2279
|
+
}
|
|
2280
|
+
set inset(value) {
|
|
2281
|
+
// @ts-ignore
|
|
2282
|
+
const style = this._styleHelper;
|
|
2283
|
+
if (style) {
|
|
2284
|
+
style.insetCss = value;
|
|
2285
|
+
}
|
|
2286
|
+
}
|
|
2287
|
+
get inset() {
|
|
2288
|
+
return this.style.inset;
|
|
2289
|
+
}
|
|
2290
|
+
set textOverFlow(value) {
|
|
2291
|
+
this.style.textOverflow = value;
|
|
2292
|
+
}
|
|
2293
|
+
get textOverFlow() {
|
|
2294
|
+
return this.style.textOverflow;
|
|
2295
|
+
}
|
|
2296
|
+
[textOverFlowProperty.setNative](value) {
|
|
2297
|
+
// @ts-ignore
|
|
2298
|
+
const style = this._styleHelper;
|
|
2299
|
+
if (style) {
|
|
2300
|
+
style.textOverflow = value;
|
|
2301
|
+
}
|
|
2302
|
+
}
|
|
2303
|
+
[clearProperty.setNative](value) {
|
|
2304
|
+
// @ts-ignore
|
|
2305
|
+
const style = this._styleHelper;
|
|
2306
|
+
if (style) {
|
|
2307
|
+
// @ts-ignore
|
|
2308
|
+
style.clear = value;
|
|
2309
|
+
}
|
|
2310
|
+
}
|
|
2311
|
+
[floatProperty.setNative](value) {
|
|
2312
|
+
// @ts-ignore
|
|
2313
|
+
const style = this._styleHelper;
|
|
2314
|
+
if (style) {
|
|
2315
|
+
// @ts-ignore
|
|
2316
|
+
style.float = value;
|
|
2317
|
+
}
|
|
2318
|
+
}
|
|
2319
|
+
[cornerShapeProperty.setNative](value) {
|
|
2320
|
+
// @ts-ignore
|
|
2321
|
+
const style = this._styleHelper;
|
|
2322
|
+
if (style) {
|
|
2323
|
+
style.cornerShape = value;
|
|
2324
|
+
}
|
|
2325
|
+
}
|
|
2326
|
+
[boxShadowProperty.setNative](value) {
|
|
2327
|
+
// @ts-ignore
|
|
2328
|
+
const style = this._styleHelper;
|
|
2329
|
+
if (style) {
|
|
2330
|
+
// @ts-ignore
|
|
2331
|
+
style.boxShadow = value;
|
|
2332
|
+
if (false) {
|
|
2333
|
+
const nv = this.nativeViewProtected ?? this._view;
|
|
2334
|
+
try {
|
|
2335
|
+
const shadows = parseBoxShadows(typeof value === 'string' ? value : '', (token) => cssLengthToDip(token, style.emBasisFor(token)));
|
|
2336
|
+
const current = style.color >>> 0 || 0xff000000;
|
|
2337
|
+
const spec = encodeBoxShadows(shadows, (color) => {
|
|
2338
|
+
if (!color || color.toLowerCase() === 'currentcolor')
|
|
2339
|
+
return current;
|
|
2340
|
+
try {
|
|
2341
|
+
return new Color(color).argb >>> 0;
|
|
2342
|
+
}
|
|
2343
|
+
catch (_) {
|
|
2344
|
+
return current;
|
|
2345
|
+
}
|
|
2346
|
+
});
|
|
2347
|
+
NativeScript.Mason.Css.SetBoxShadow(nv, spec);
|
|
2348
|
+
}
|
|
2349
|
+
catch (_) { }
|
|
2350
|
+
}
|
|
2351
|
+
}
|
|
2352
|
+
}
|
|
2353
|
+
// Core's scale/rotate/translate on Windows. Core's own TransformGroup never renders on a Mason
|
|
2354
|
+
// element, so View.rotate etc. did nothing; they're set natively as one matrix instead. CSS
|
|
2355
|
+
// keyframes and animate() play them per frame (css-keyframes.ts).
|
|
2356
|
+
updateNativeTransform() {
|
|
2357
|
+
if (!false) {
|
|
2358
|
+
// @ts-ignore
|
|
2359
|
+
return super.updateNativeTransform?.();
|
|
2360
|
+
}
|
|
2361
|
+
const native = this.nativeViewProtected;
|
|
2362
|
+
if (!native)
|
|
2363
|
+
return;
|
|
2364
|
+
const self = this;
|
|
2365
|
+
const origin = this._windowsTransformOrigin(native);
|
|
2366
|
+
NativeScript.Mason.Css.SetTransforms(native, typeof self.scaleX === 'number' ? self.scaleX : 1, typeof self.scaleY === 'number' ? self.scaleY : 1, self.rotate || 0, self.translateX || 0, self.translateY || 0, origin.x, origin.y);
|
|
2367
|
+
}
|
|
2368
|
+
// CSS transform-origin when set, else core's originX/originY. RenderTransformOrigin is shared
|
|
2369
|
+
// by every part of the element's transform.
|
|
2370
|
+
_windowsTransformOrigin(native) {
|
|
2371
|
+
const self = this;
|
|
2372
|
+
// @ts-ignore
|
|
2373
|
+
const css = this._styleHelper?.transformOriginFraction?.(native?.ActualWidth ?? 0, native?.ActualHeight ?? 0);
|
|
2374
|
+
return css ?? { x: self.originX ?? 0.5, y: self.originY ?? 0.5 };
|
|
2375
|
+
}
|
|
2376
|
+
_applyWindowsTransform(value = this._windowsTransformValue) {
|
|
2377
|
+
// @ts-ignore
|
|
2378
|
+
const style = this._styleHelper;
|
|
2379
|
+
const nv = this.nativeViewProtected ?? this._view;
|
|
2380
|
+
this._windowsTransformValue = value;
|
|
2381
|
+
if (!style || !nv)
|
|
2382
|
+
return;
|
|
2383
|
+
try {
|
|
2384
|
+
const size = { width: nv.ActualWidth ?? 0, height: nv.ActualHeight ?? 0 };
|
|
2385
|
+
const m = parseCssTransform(typeof value === 'string' ? value : '', (token) => cssLengthToDip(token, style.emBasisFor(token)), size);
|
|
2386
|
+
const origin = this._windowsTransformOrigin(nv);
|
|
2387
|
+
if (!m)
|
|
2388
|
+
NativeScript.Mason.Css.ClearTransform(nv);
|
|
2389
|
+
else
|
|
2390
|
+
NativeScript.Mason.Css.ApplyTransform(nv, m[0], m[1], m[2], m[3], m[4], m[5]);
|
|
2391
|
+
NativeScript.Mason.Css.SetTransformOrigin(nv, origin.x, origin.y);
|
|
2392
|
+
}
|
|
2393
|
+
catch (_) { }
|
|
2394
|
+
}
|
|
2395
|
+
animate(options) {
|
|
2396
|
+
if (!false || !options || !('rotate' in options || 'scale' in options || 'translate' in options)) {
|
|
2397
|
+
return super.animate(options);
|
|
2398
|
+
}
|
|
2399
|
+
// Core's storyboards would animate a transform that doesn't show on a Mason view.
|
|
2400
|
+
const { rotate, scale, translate, ...rest } = options;
|
|
2401
|
+
const core = ['opacity', 'backgroundColor', 'width', 'height'].some((key) => key in rest) ? super.animate(rest) : null;
|
|
2402
|
+
const transforms = animateTransforms(this, options);
|
|
2403
|
+
const promise = Promise.all([core, transforms.done]).then(() => undefined);
|
|
2404
|
+
promise.cancel = () => {
|
|
2405
|
+
transforms.cancel();
|
|
2406
|
+
core?.cancel?.();
|
|
2407
|
+
};
|
|
2408
|
+
return promise;
|
|
2409
|
+
}
|
|
2410
|
+
[originXProperty.setNative](value) {
|
|
2411
|
+
if (!false) {
|
|
2412
|
+
// @ts-ignore
|
|
2413
|
+
return super[originXProperty.setNative]?.(value);
|
|
2414
|
+
}
|
|
2415
|
+
this.updateNativeTransform();
|
|
2416
|
+
}
|
|
2417
|
+
[originYProperty.setNative](value) {
|
|
2418
|
+
if (!false) {
|
|
2419
|
+
// @ts-ignore
|
|
2420
|
+
return super[originYProperty.setNative]?.(value);
|
|
2421
|
+
}
|
|
2422
|
+
this.updateNativeTransform();
|
|
2423
|
+
}
|
|
2424
|
+
[transformProperty.setNative](value) {
|
|
2425
|
+
// @ts-ignore
|
|
2426
|
+
const style = this._styleHelper;
|
|
2427
|
+
if (style) {
|
|
2428
|
+
// @ts-ignore
|
|
2429
|
+
style.transform = value;
|
|
2430
|
+
// Windows: transform isn't read from the buffer; it becomes the panel's RenderTransform.
|
|
2431
|
+
if (false)
|
|
2432
|
+
this._applyWindowsTransform(value);
|
|
2433
|
+
}
|
|
2434
|
+
}
|
|
2435
|
+
}
|
|
2436
|
+
ViewBase._pendingTeardowns = [];
|
|
2437
|
+
ViewBase._teardownScheduled = false;
|
|
2438
|
+
__decorate([
|
|
2439
|
+
PseudoClassHandler('hover'),
|
|
2440
|
+
__metadata("design:type", Function),
|
|
2441
|
+
__metadata("design:paramtypes", [Boolean]),
|
|
2442
|
+
__metadata("design:returntype", void 0)
|
|
2443
|
+
], ViewBase.prototype, "_hoverHandler", null);
|
|
2444
|
+
__decorate([
|
|
2445
|
+
PseudoClassHandler('highlighted', 'pressed', 'active'),
|
|
2446
|
+
__metadata("design:type", Function),
|
|
2447
|
+
__metadata("design:paramtypes", [Boolean]),
|
|
2448
|
+
__metadata("design:returntype", void 0)
|
|
2449
|
+
], ViewBase.prototype, "_handler", null);
|
|
2450
|
+
__decorate([
|
|
2451
|
+
PseudoClassHandler('disabled'),
|
|
2452
|
+
__metadata("design:type", Function),
|
|
2453
|
+
__metadata("design:paramtypes", [Boolean]),
|
|
2454
|
+
__metadata("design:returntype", void 0)
|
|
2455
|
+
], ViewBase.prototype, "_disableHandler", null);
|
|
2456
|
+
__decorate([
|
|
2457
|
+
PseudoClassHandler('focus'),
|
|
2458
|
+
__metadata("design:type", Function),
|
|
2459
|
+
__metadata("design:paramtypes", [Boolean]),
|
|
2460
|
+
__metadata("design:returntype", void 0)
|
|
2461
|
+
], ViewBase.prototype, "_focusHandler", null);
|
|
2462
|
+
__decorate([
|
|
2463
|
+
PseudoClassHandler('blur'),
|
|
2464
|
+
__metadata("design:type", Function),
|
|
2465
|
+
__metadata("design:paramtypes", [Boolean]),
|
|
2466
|
+
__metadata("design:returntype", void 0)
|
|
2467
|
+
], ViewBase.prototype, "_blurHandler", null);
|
|
2468
|
+
export class Event {
|
|
2469
|
+
get bubbles() {
|
|
2470
|
+
if (__ANDROID__) {
|
|
2471
|
+
return this[native_]?.getBubbles();
|
|
2472
|
+
}
|
|
2473
|
+
if (__APPLE__) {
|
|
2474
|
+
return this[native_]?.bubbles;
|
|
2475
|
+
}
|
|
2476
|
+
if (false) {
|
|
2477
|
+
return this[native_]?.Bubbles ?? false;
|
|
2478
|
+
}
|
|
2479
|
+
return false;
|
|
2480
|
+
}
|
|
2481
|
+
get cancelable() {
|
|
2482
|
+
if (__ANDROID__) {
|
|
2483
|
+
return this[native_]?.getCancelable();
|
|
2484
|
+
}
|
|
2485
|
+
if (__APPLE__) {
|
|
2486
|
+
return this[native_]?.cancelable;
|
|
2487
|
+
}
|
|
2488
|
+
if (false) {
|
|
2489
|
+
return this[native_]?.Cancelable ?? false;
|
|
2490
|
+
}
|
|
2491
|
+
return false;
|
|
2492
|
+
}
|
|
2493
|
+
get isComposing() {
|
|
2494
|
+
if (__ANDROID__) {
|
|
2495
|
+
return this[native_]?.getIsComposing();
|
|
2496
|
+
}
|
|
2497
|
+
if (__APPLE__) {
|
|
2498
|
+
return this[native_]?.isComposing;
|
|
2499
|
+
}
|
|
2500
|
+
if (false) {
|
|
2501
|
+
return this[native_]?.IsComposing ?? false;
|
|
2502
|
+
}
|
|
2503
|
+
return false;
|
|
2504
|
+
}
|
|
2505
|
+
get timeStamp() {
|
|
2506
|
+
if (__ANDROID__) {
|
|
2507
|
+
return this[native_]?.getTimeStamp();
|
|
2508
|
+
}
|
|
2509
|
+
if (__APPLE__) {
|
|
2510
|
+
return this[native_]?.timeStamp;
|
|
2511
|
+
}
|
|
2512
|
+
if (false) {
|
|
2513
|
+
return this[native_]?.TimeStamp ?? 0;
|
|
2514
|
+
}
|
|
2515
|
+
return 0;
|
|
2516
|
+
}
|
|
2517
|
+
get defaultPrevented() {
|
|
2518
|
+
if (__ANDROID__) {
|
|
2519
|
+
return this[native_]?.getDefaultPrevented();
|
|
2520
|
+
}
|
|
2521
|
+
if (__APPLE__) {
|
|
2522
|
+
return this[native_]?.defaultPrevented;
|
|
2523
|
+
}
|
|
2524
|
+
if (false) {
|
|
2525
|
+
return this[native_]?.DefaultPrevented ?? false;
|
|
2526
|
+
}
|
|
2527
|
+
return false;
|
|
2528
|
+
}
|
|
2529
|
+
get propagationStopped() {
|
|
2530
|
+
if (__ANDROID__) {
|
|
2531
|
+
return this[native_]?.getPropagationStopped();
|
|
2532
|
+
}
|
|
2533
|
+
if (__APPLE__) {
|
|
2534
|
+
return this[native_]?.propagationStopped;
|
|
2535
|
+
}
|
|
2536
|
+
if (false) {
|
|
2537
|
+
return this[native_]?.PropagationStopped ?? false;
|
|
2538
|
+
}
|
|
2539
|
+
return false;
|
|
2540
|
+
}
|
|
2541
|
+
get immediatePropagationStopped() {
|
|
2542
|
+
if (__ANDROID__) {
|
|
2543
|
+
return this[native_]?.getImmediatePropagationStopped();
|
|
2544
|
+
}
|
|
2545
|
+
if (__APPLE__) {
|
|
2546
|
+
return this[native_]?.immediatePropagationStopped;
|
|
2547
|
+
}
|
|
2548
|
+
if (false) {
|
|
2549
|
+
return this[native_]?.ImmediatePropagationStopped ?? false;
|
|
2550
|
+
}
|
|
2551
|
+
return false;
|
|
2552
|
+
}
|
|
2553
|
+
get currentTarget() {
|
|
2554
|
+
// DOM semantics: the element the listener is attached to, not the raw
|
|
2555
|
+
// native view. `_target` is set to that same owner at every dispatch
|
|
2556
|
+
// site (_registerNativeEvent), so reuse it here.
|
|
2557
|
+
return this['_target'];
|
|
2558
|
+
}
|
|
2559
|
+
stopImmediatePropagation() {
|
|
2560
|
+
if (__ANDROID__) {
|
|
2561
|
+
return this[native_]?.stopImmediatePropagation();
|
|
2562
|
+
}
|
|
2563
|
+
if (__APPLE__) {
|
|
2564
|
+
return this[native_]?.stopImmediatePropagation();
|
|
2565
|
+
}
|
|
2566
|
+
if (false) {
|
|
2567
|
+
return this[native_]?.StopImmediatePropagation();
|
|
2568
|
+
}
|
|
2569
|
+
}
|
|
2570
|
+
stopPropagation() {
|
|
2571
|
+
if (__ANDROID__) {
|
|
2572
|
+
return this[native_]?.stopPropagation();
|
|
2573
|
+
}
|
|
2574
|
+
if (__APPLE__) {
|
|
2575
|
+
return this[native_]?.stopPropagation();
|
|
2576
|
+
}
|
|
2577
|
+
if (false) {
|
|
2578
|
+
return this[native_]?.StopPropagation();
|
|
2579
|
+
}
|
|
2580
|
+
}
|
|
2581
|
+
preventDefault() {
|
|
2582
|
+
if (__ANDROID__) {
|
|
2583
|
+
return this[native_]?.preventDefault();
|
|
2584
|
+
}
|
|
2585
|
+
if (__APPLE__) {
|
|
2586
|
+
return this[native_]?.preventDefault();
|
|
2587
|
+
}
|
|
2588
|
+
if (false) {
|
|
2589
|
+
return this[native_]?.PreventDefault();
|
|
2590
|
+
}
|
|
2591
|
+
}
|
|
2592
|
+
// Writable on purpose, unlike the DOM's read-only `Event.type`. Aliases
|
|
2593
|
+
// (e.g. 'tap') are folded onto the native name ('click') before the event
|
|
2594
|
+
// reaches JS; a host framework's DOM shim relabels it back to the name the
|
|
2595
|
+
// listener was registered under and re-dispatches, which needs a working
|
|
2596
|
+
// setter or the relabel is silently dropped and the listener never fires.
|
|
2597
|
+
get type() {
|
|
2598
|
+
const override = this[eventType_];
|
|
2599
|
+
if (override !== undefined) {
|
|
2600
|
+
return override;
|
|
2601
|
+
}
|
|
2602
|
+
if (__ANDROID__) {
|
|
2603
|
+
return this[native_]?.getType();
|
|
2604
|
+
}
|
|
2605
|
+
if (false) {
|
|
2606
|
+
return this[native_]?.Type;
|
|
2607
|
+
}
|
|
2608
|
+
return this[native_]?.type;
|
|
2609
|
+
}
|
|
2610
|
+
set type(value) {
|
|
2611
|
+
this[eventType_] = value;
|
|
2612
|
+
}
|
|
2613
|
+
// DOM MouseEvent.button: 0 = primary button. Mason's touch-originated
|
|
2614
|
+
// click has no native concept of mouse buttons, but callers checking
|
|
2615
|
+
// `e.button === 0` (e.g. a router's <Link> onClick guard) expect this.
|
|
2616
|
+
get button() {
|
|
2617
|
+
return 0;
|
|
2618
|
+
}
|
|
2619
|
+
set button(_) { }
|
|
2620
|
+
get target() {
|
|
2621
|
+
// The element the event started at, which differs from currentTarget once it bubbles.
|
|
2622
|
+
const nativeEvent = this[native_];
|
|
2623
|
+
const nativeTarget = __ANDROID__ ? nativeEvent?.getTarget?.() : __APPLE__ ? nativeEvent?.target : false ? nativeEvent?.Target : null;
|
|
2624
|
+
const current = this['_target'];
|
|
2625
|
+
if (nativeTarget && nativeTarget !== nativeViewFor(current)) {
|
|
2626
|
+
const found = nativeOwnerFor(nativeTarget) ?? findOwnerForNativeView(current, nativeTarget);
|
|
2627
|
+
if (found)
|
|
2628
|
+
return found;
|
|
2629
|
+
}
|
|
2630
|
+
return current;
|
|
2631
|
+
}
|
|
2632
|
+
set target(_) { }
|
|
2633
|
+
get object() {
|
|
2634
|
+
return this['_target'];
|
|
2635
|
+
}
|
|
2636
|
+
get eventName() {
|
|
2637
|
+
return this.type;
|
|
2638
|
+
}
|
|
2639
|
+
set currentTarget(_) { }
|
|
2640
|
+
set bubbles(_) { }
|
|
2641
|
+
set cancelable(_) { }
|
|
2642
|
+
set timeStamp(_) { }
|
|
2643
|
+
set defaultPrevented(_) { }
|
|
2644
|
+
}
|
|
2645
|
+
function wrapNativeEvent(_type) { return new Event(); }
|