@nativescript/core 9.1.0-alpha.8 → 9.1.0-dev.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/animation-frame/animation-native.windows.d.ts +1 -0
- package/animation-frame/animation-native.windows.js +4 -0
- package/animation-frame/animation-native.windows.js.map +1 -0
- package/application/application-common.d.ts +2 -1
- package/application/application-common.js +4 -0
- package/application/application-common.js.map +1 -1
- package/application/application.android.d.ts +0 -16
- package/application/application.android.js +1 -6
- package/application/application.android.js.map +1 -1
- package/application/application.d.ts +9 -0
- package/application/application.ios.d.ts +1 -2
- package/application/application.ios.js +3 -50
- package/application/application.ios.js.map +1 -1
- package/application/application.windows.d.ts +27 -0
- package/application/application.windows.js +331 -0
- package/application/application.windows.js.map +1 -0
- package/application/helpers.windows.d.ts +8 -0
- package/application/helpers.windows.js +12 -0
- package/application/helpers.windows.js.map +1 -0
- package/application/index.windows.d.ts +2 -0
- package/application/index.windows.js +3 -0
- package/application/index.windows.js.map +1 -0
- package/application/window-helper.windows.d.ts +29 -0
- package/application/window-helper.windows.js +159 -0
- package/application/window-helper.windows.js.map +1 -0
- package/application-settings/index.windows.d.ts +11 -0
- package/application-settings/index.windows.js +93 -0
- package/application-settings/index.windows.js.map +1 -0
- package/color/index.d.ts +5 -0
- package/color/index.windows.d.ts +8 -0
- package/color/index.windows.js +19 -0
- package/color/index.windows.js.map +1 -0
- package/connectivity/index.windows.d.ts +11 -0
- package/connectivity/index.windows.js +50 -0
- package/connectivity/index.windows.js.map +1 -0
- package/debugger/webinspector-network.windows.d.ts +79 -0
- package/debugger/webinspector-network.windows.js +307 -0
- package/debugger/webinspector-network.windows.js.map +1 -0
- package/file-system/file-system-access.windows.d.ts +76 -0
- package/file-system/file-system-access.windows.js +476 -0
- package/file-system/file-system-access.windows.js.map +1 -0
- package/fps-meter/fps-native.windows.d.ts +8 -0
- package/fps-meter/fps-native.windows.js +40 -0
- package/fps-meter/fps-native.windows.js.map +1 -0
- package/global-types.d.ts +1 -0
- package/globals/index.js +1 -4
- package/globals/index.js.map +1 -1
- package/http/http-request/index.android.js.map +1 -1
- package/http/http-request/index.ios.js.map +1 -1
- package/http/http-request/index.windows.d.ts +2 -0
- package/http/http-request/index.windows.js +41 -0
- package/http/http-request/index.windows.js.map +1 -0
- package/http/http-request-internal/index.android.d.ts +1 -7
- package/http/http-request-internal/index.android.js.map +1 -1
- package/http/http-request-internal/index.ios.d.ts +1 -7
- package/http/http-request-internal/index.ios.js.map +1 -1
- package/http/http-request-internal/index.windows.d.ts +4 -0
- package/http/http-request-internal/index.windows.js +134 -0
- package/http/http-request-internal/index.windows.js.map +1 -0
- package/image-asset/index.windows.d.ts +9 -0
- package/image-asset/index.windows.js +34 -0
- package/image-asset/index.windows.js.map +1 -0
- package/image-source/index.android.d.ts +1 -0
- package/image-source/index.android.js.map +1 -1
- package/image-source/index.d.ts +5 -0
- package/image-source/index.ios.d.ts +1 -0
- package/image-source/index.ios.js.map +1 -1
- package/image-source/index.windows.d.ts +52 -0
- package/image-source/index.windows.js +498 -0
- package/image-source/index.windows.js.map +1 -0
- package/package.json +6 -2
- package/platform/common.d.ts +2 -0
- package/platform/common.js +2 -0
- package/platform/common.js.map +1 -1
- package/platform/device/index.windows.d.ts +18 -0
- package/platform/device/index.windows.js +94 -0
- package/platform/device/index.windows.js.map +1 -0
- package/platform/screen/index.windows.d.ts +13 -0
- package/platform/screen/index.windows.js +25 -0
- package/platform/screen/index.windows.js.map +1 -0
- package/platforms/windows/arm64/NativeScript.Widgets.dll +0 -0
- package/platforms/windows/arm64/NativeScript.Widgets.winmd +0 -0
- package/platforms/windows/x64/NativeScript.Widgets.dll +0 -0
- package/platforms/windows/x64/NativeScript.Widgets.winmd +0 -0
- package/plugin.props +12 -0
- package/plugin.targets +71 -0
- package/references.d.ts +4 -0
- package/text/index.windows.d.ts +9 -0
- package/text/index.windows.js +12 -0
- package/text/index.windows.js.map +1 -0
- package/timer/index.windows.d.ts +4 -0
- package/timer/index.windows.js +14 -0
- package/timer/index.windows.js.map +1 -0
- package/ui/action-bar/index.ios.js +1 -0
- package/ui/action-bar/index.ios.js.map +1 -1
- package/ui/action-bar/index.windows.d.ts +12 -0
- package/ui/action-bar/index.windows.js +36 -0
- package/ui/action-bar/index.windows.js.map +1 -0
- package/ui/activity-indicator/index.windows.d.ts +15 -0
- package/ui/activity-indicator/index.windows.js +65 -0
- package/ui/activity-indicator/index.windows.js.map +1 -0
- package/ui/animation/index.windows.d.ts +19 -0
- package/ui/animation/index.windows.js +603 -0
- package/ui/animation/index.windows.js.map +1 -0
- package/ui/builder/index.d.ts +1 -0
- package/ui/builder/index.js +2 -1
- package/ui/builder/index.js.map +1 -1
- package/ui/button/index.android.d.ts +9 -2
- package/ui/button/index.android.js +24 -7
- package/ui/button/index.android.js.map +1 -1
- package/ui/button/index.ios.d.ts +9 -2
- package/ui/button/index.ios.js +72 -17
- package/ui/button/index.ios.js.map +1 -1
- package/ui/button/index.windows.d.ts +13 -0
- package/ui/button/index.windows.js +73 -0
- package/ui/button/index.windows.js.map +1 -0
- package/ui/core/bindable/index.js +1 -2
- package/ui/core/bindable/index.js.map +1 -1
- package/ui/core/control-state-change/index.windows.d.ts +4 -0
- package/ui/core/control-state-change/index.windows.js +6 -0
- package/ui/core/control-state-change/index.windows.js.map +1 -0
- package/ui/core/view/index.android.d.ts +0 -1
- package/ui/core/view/index.android.js +8 -17
- package/ui/core/view/index.android.js.map +1 -1
- package/ui/core/view/index.ios.d.ts +0 -1
- package/ui/core/view/index.ios.js +4 -17
- package/ui/core/view/index.ios.js.map +1 -1
- package/ui/core/view/index.windows.d.ts +120 -0
- package/ui/core/view/index.windows.js +2178 -0
- package/ui/core/view/index.windows.js.map +1 -0
- package/ui/core/view/view-common.d.ts +2 -0
- package/ui/core/view/view-common.js +6 -1
- package/ui/core/view/view-common.js.map +1 -1
- package/ui/core/view/view-helper/index.d.ts +0 -1
- package/ui/core/view/view-helper/index.ios.d.ts +0 -24
- package/ui/core/view/view-helper/index.ios.js +5 -54
- package/ui/core/view/view-helper/index.ios.js.map +1 -1
- package/ui/core/view/view-helper/index.windows.d.ts +3 -0
- package/ui/core/view/view-helper/index.windows.js +4 -0
- package/ui/core/view/view-helper/index.windows.js.map +1 -0
- package/ui/core/view-base/index.d.ts +10 -24
- package/ui/core/view-base/index.js +32 -50
- package/ui/core/view-base/index.js.map +1 -1
- package/ui/date-picker/index.windows.d.ts +22 -0
- package/ui/date-picker/index.windows.js +97 -0
- package/ui/date-picker/index.windows.js.map +1 -0
- package/ui/dialogs/index.windows.d.ts +17 -0
- package/ui/dialogs/index.windows.js +471 -0
- package/ui/dialogs/index.windows.js.map +1 -0
- package/ui/editable-text-base/index.windows.d.ts +27 -0
- package/ui/editable-text-base/index.windows.js +165 -0
- package/ui/editable-text-base/index.windows.js.map +1 -0
- package/ui/embedding/index.windows.d.ts +1 -0
- package/ui/embedding/index.windows.js +4 -0
- package/ui/embedding/index.windows.js.map +1 -0
- package/ui/frame/fragment.transitions.android.d.ts +13 -13
- package/ui/frame/fragment.transitions.android.js.map +1 -1
- package/ui/frame/frame-common.d.ts +1 -2
- package/ui/frame/frame-common.js +0 -10
- package/ui/frame/frame-common.js.map +1 -1
- package/ui/frame/frame-helper-for-android.d.ts +4 -4
- package/ui/frame/frame-helper-for-android.js +8 -17
- package/ui/frame/frame-helper-for-android.js.map +1 -1
- package/ui/frame/index.android.d.ts +11 -6
- package/ui/frame/index.android.js +59 -18
- package/ui/frame/index.android.js.map +1 -1
- package/ui/frame/index.d.ts +21 -12
- package/ui/frame/index.ios.d.ts +2 -2
- package/ui/frame/index.ios.js.map +1 -1
- package/ui/frame/index.windows.d.ts +52 -0
- package/ui/frame/index.windows.js +778 -0
- package/ui/frame/index.windows.js.map +1 -0
- package/ui/gestures/index.windows.d.ts +35 -0
- package/ui/gestures/index.windows.js +483 -0
- package/ui/gestures/index.windows.js.map +1 -0
- package/ui/html-view/index.windows.d.ts +18 -0
- package/ui/html-view/index.windows.js +191 -0
- package/ui/html-view/index.windows.js.map +1 -0
- package/ui/image/index.windows.d.ts +17 -0
- package/ui/image/index.windows.js +132 -0
- package/ui/image/index.windows.js.map +1 -0
- package/ui/image/symbol-effects.windows.d.ts +5 -0
- package/ui/image/symbol-effects.windows.js +8 -0
- package/ui/image/symbol-effects.windows.js.map +1 -0
- package/ui/image-cache/index.windows.d.ts +11 -0
- package/ui/image-cache/index.windows.js +48 -0
- package/ui/image-cache/index.windows.js.map +1 -0
- package/ui/label/index.ios.d.ts +5 -2
- package/ui/label/index.ios.js +44 -12
- package/ui/label/index.ios.js.map +1 -1
- package/ui/label/index.windows.d.ts +15 -0
- package/ui/label/index.windows.js +66 -0
- package/ui/label/index.windows.js.map +1 -0
- package/ui/layouts/absolute-layout/index.ios.js +1 -5
- package/ui/layouts/absolute-layout/index.ios.js.map +1 -1
- package/ui/layouts/absolute-layout/index.windows.d.ts +8 -0
- package/ui/layouts/absolute-layout/index.windows.js +47 -0
- package/ui/layouts/absolute-layout/index.windows.js.map +1 -0
- package/ui/layouts/dock-layout/index.ios.js +1 -5
- package/ui/layouts/dock-layout/index.ios.js.map +1 -1
- package/ui/layouts/dock-layout/index.windows.d.ts +19 -0
- package/ui/layouts/dock-layout/index.windows.js +202 -0
- package/ui/layouts/dock-layout/index.windows.js.map +1 -0
- package/ui/layouts/flexbox-layout/flexbox-layout-common.d.ts +17 -2
- package/ui/layouts/flexbox-layout/flexbox-layout-common.js +73 -2
- package/ui/layouts/flexbox-layout/flexbox-layout-common.js.map +1 -1
- package/ui/layouts/flexbox-layout/index.ios.js +1 -5
- package/ui/layouts/flexbox-layout/index.ios.js.map +1 -1
- package/ui/layouts/flexbox-layout/index.windows.d.ts +27 -0
- package/ui/layouts/flexbox-layout/index.windows.js +188 -0
- package/ui/layouts/flexbox-layout/index.windows.js.map +1 -0
- package/ui/layouts/grid-layout/index.ios.js +1 -5
- package/ui/layouts/grid-layout/index.ios.js.map +1 -1
- package/ui/layouts/grid-layout/index.windows.d.ts +20 -0
- package/ui/layouts/grid-layout/index.windows.js +130 -0
- package/ui/layouts/grid-layout/index.windows.js.map +1 -0
- package/ui/layouts/layout-base.android.d.ts +10 -3
- package/ui/layouts/layout-base.android.js +24 -7
- package/ui/layouts/layout-base.android.js.map +1 -1
- package/ui/layouts/layout-base.ios.js.map +1 -1
- package/ui/layouts/layout-base.windows.d.ts +4 -0
- package/ui/layouts/layout-base.windows.js +5 -0
- package/ui/layouts/layout-base.windows.js.map +1 -0
- package/ui/layouts/liquid-glass/index.windows.d.ts +4 -0
- package/ui/layouts/liquid-glass/index.windows.js +5 -0
- package/ui/layouts/liquid-glass/index.windows.js.map +1 -0
- package/ui/layouts/liquid-glass-container/index.windows.d.ts +4 -0
- package/ui/layouts/liquid-glass-container/index.windows.js +5 -0
- package/ui/layouts/liquid-glass-container/index.windows.js.map +1 -0
- package/ui/layouts/root-layout/index.windows.d.ts +13 -0
- package/ui/layouts/root-layout/index.windows.js +160 -0
- package/ui/layouts/root-layout/index.windows.js.map +1 -0
- package/ui/layouts/stack-layout/index.ios.js +1 -5
- package/ui/layouts/stack-layout/index.ios.js.map +1 -1
- package/ui/layouts/stack-layout/index.windows.d.ts +13 -0
- package/ui/layouts/stack-layout/index.windows.js +63 -0
- package/ui/layouts/stack-layout/index.windows.js.map +1 -0
- package/ui/layouts/wrap-layout/index.ios.js +1 -5
- package/ui/layouts/wrap-layout/index.ios.js.map +1 -1
- package/ui/layouts/wrap-layout/index.windows.d.ts +20 -0
- package/ui/layouts/wrap-layout/index.windows.js +182 -0
- package/ui/layouts/wrap-layout/index.windows.js.map +1 -0
- package/ui/list-picker/index.windows.d.ts +19 -0
- package/ui/list-picker/index.windows.js +75 -0
- package/ui/list-picker/index.windows.js.map +1 -0
- package/ui/list-view/index.d.ts +1 -13
- package/ui/list-view/index.ios.d.ts +1 -3
- package/ui/list-view/index.ios.js +10 -48
- package/ui/list-view/index.ios.js.map +1 -1
- package/ui/list-view/index.windows.d.ts +60 -0
- package/ui/list-view/index.windows.js +842 -0
- package/ui/list-view/index.windows.js.map +1 -0
- package/ui/list-view/list-view-common.d.ts +0 -14
- package/ui/list-view/list-view-common.js +0 -4
- package/ui/list-view/list-view-common.js.map +1 -1
- package/ui/page/index.d.ts +1 -1
- package/ui/page/index.ios.d.ts +0 -1
- package/ui/page/index.ios.js +1 -15
- package/ui/page/index.ios.js.map +1 -1
- package/ui/page/index.windows.d.ts +12 -0
- package/ui/page/index.windows.js +42 -0
- package/ui/page/index.windows.js.map +1 -0
- package/ui/page/page-common.d.ts +2 -5
- package/ui/page/page-common.js.map +1 -1
- package/ui/progress/index.windows.d.ts +20 -0
- package/ui/progress/index.windows.js +65 -0
- package/ui/progress/index.windows.js.map +1 -0
- package/ui/repeater/index.d.ts +1 -2
- package/ui/repeater/index.js.map +1 -1
- package/ui/scroll-view/index.d.ts +0 -13
- package/ui/scroll-view/index.ios.js +7 -21
- package/ui/scroll-view/index.ios.js.map +1 -1
- package/ui/scroll-view/index.windows.d.ts +29 -0
- package/ui/scroll-view/index.windows.js +192 -0
- package/ui/scroll-view/index.windows.js.map +1 -0
- package/ui/scroll-view/scroll-view-common.d.ts +0 -6
- package/ui/scroll-view/scroll-view-common.js +0 -8
- package/ui/scroll-view/scroll-view-common.js.map +1 -1
- package/ui/search-bar/index.windows.d.ts +19 -0
- package/ui/search-bar/index.windows.js +91 -0
- package/ui/search-bar/index.windows.js.map +1 -0
- package/ui/segmented-bar/index.windows.d.ts +23 -0
- package/ui/segmented-bar/index.windows.js +117 -0
- package/ui/segmented-bar/index.windows.js.map +1 -0
- package/ui/segmented-bar/segmented-bar-common.d.ts +1 -5
- package/ui/segmented-bar/segmented-bar-common.js.map +1 -1
- package/ui/slider/index.windows.d.ts +25 -0
- package/ui/slider/index.windows.js +134 -0
- package/ui/slider/index.windows.js.map +1 -0
- package/ui/split-view/index.windows.d.ts +49 -0
- package/ui/split-view/index.windows.js +549 -0
- package/ui/split-view/index.windows.js.map +1 -0
- package/ui/styling/background.windows.d.ts +2 -0
- package/ui/styling/background.windows.js +2 -0
- package/ui/styling/background.windows.js.map +1 -0
- package/ui/styling/font.d.ts +4 -0
- package/ui/styling/font.windows.d.ts +25 -0
- package/ui/styling/font.windows.js +213 -0
- package/ui/styling/font.windows.js.map +1 -0
- package/ui/styling/style/index.d.ts +0 -1
- package/ui/styling/style/index.js.map +1 -1
- package/ui/styling/style-properties.d.ts +0 -1
- package/ui/styling/style-properties.js +32 -41
- package/ui/styling/style-properties.js.map +1 -1
- package/ui/styling/style-scope.js +9 -1
- package/ui/styling/style-scope.js.map +1 -1
- package/ui/switch/index.windows.d.ts +20 -0
- package/ui/switch/index.windows.js +97 -0
- package/ui/switch/index.windows.js.map +1 -0
- package/ui/tab-view/index.ios.d.ts +1 -10
- package/ui/tab-view/index.ios.js +4 -21
- package/ui/tab-view/index.ios.js.map +1 -1
- package/ui/tab-view/index.windows.d.ts +29 -0
- package/ui/tab-view/index.windows.js +268 -0
- package/ui/tab-view/index.windows.js.map +1 -0
- package/ui/tab-view/tab-view-common.d.ts +1 -5
- package/ui/tab-view/tab-view-common.js.map +1 -1
- package/ui/text-base/index.android.d.ts +9 -2
- package/ui/text-base/index.android.js +24 -7
- package/ui/text-base/index.android.js.map +1 -1
- package/ui/text-base/index.windows.d.ts +47 -0
- package/ui/text-base/index.windows.js +639 -0
- package/ui/text-base/index.windows.js.map +1 -0
- package/ui/text-field/index.ios.d.ts +9 -2
- package/ui/text-field/index.ios.js +23 -2
- package/ui/text-field/index.ios.js.map +1 -1
- package/ui/text-field/index.windows.d.ts +23 -0
- package/ui/text-field/index.windows.js +186 -0
- package/ui/text-field/index.windows.js.map +1 -0
- package/ui/text-view/index.ios.d.ts +9 -2
- package/ui/text-view/index.ios.js +72 -20
- package/ui/text-view/index.ios.js.map +1 -1
- package/ui/text-view/index.windows.d.ts +12 -0
- package/ui/text-view/index.windows.js +47 -0
- package/ui/text-view/index.windows.js.map +1 -0
- package/ui/time-picker/index.windows.d.ts +18 -0
- package/ui/time-picker/index.windows.js +77 -0
- package/ui/time-picker/index.windows.js.map +1 -0
- package/ui/transition/fade-transition.windows.d.ts +3 -0
- package/ui/transition/fade-transition.windows.js +4 -0
- package/ui/transition/fade-transition.windows.js.map +1 -0
- package/ui/transition/index.d.ts +1 -2
- package/ui/transition/index.windows.d.ts +20 -0
- package/ui/transition/index.windows.js +30 -0
- package/ui/transition/index.windows.js.map +1 -0
- package/ui/transition/modal-transition.ios.js +5 -33
- package/ui/transition/modal-transition.ios.js.map +1 -1
- package/ui/transition/modal-transition.windows.d.ts +3 -0
- package/ui/transition/modal-transition.windows.js +4 -0
- package/ui/transition/modal-transition.windows.js.map +1 -0
- package/ui/transition/page-transition.ios.d.ts +0 -5
- package/ui/transition/page-transition.ios.js +33 -296
- package/ui/transition/page-transition.ios.js.map +1 -1
- package/ui/transition/page-transition.windows.d.ts +3 -0
- package/ui/transition/page-transition.windows.js +4 -0
- package/ui/transition/page-transition.windows.js.map +1 -0
- package/ui/transition/shared-transition-helper.android.d.ts +0 -3
- package/ui/transition/shared-transition-helper.android.js +0 -9
- package/ui/transition/shared-transition-helper.android.js.map +1 -1
- package/ui/transition/shared-transition-helper.d.ts +0 -7
- package/ui/transition/shared-transition-helper.ios.d.ts +0 -36
- package/ui/transition/shared-transition-helper.ios.js +89 -765
- package/ui/transition/shared-transition-helper.ios.js.map +1 -1
- package/ui/transition/shared-transition-helper.windows.d.ts +30 -0
- package/ui/transition/shared-transition-helper.windows.js +155 -0
- package/ui/transition/shared-transition-helper.windows.js.map +1 -0
- package/ui/transition/shared-transition.d.ts +0 -66
- package/ui/transition/shared-transition.js +2 -57
- package/ui/transition/shared-transition.js.map +1 -1
- package/ui/transition/slide-transition.windows.d.ts +3 -0
- package/ui/transition/slide-transition.windows.js +4 -0
- package/ui/transition/slide-transition.windows.js.map +1 -0
- package/ui/utils.windows.d.ts +9 -0
- package/ui/utils.windows.js +21 -0
- package/ui/utils.windows.js.map +1 -0
- package/ui/web-view/index.windows.d.ts +23 -0
- package/ui/web-view/index.windows.js +115 -0
- package/ui/web-view/index.windows.js.map +1 -0
- package/utils/constants.windows.d.ts +2 -0
- package/utils/constants.windows.js +5 -0
- package/utils/constants.windows.js.map +1 -0
- package/utils/debug-source.js +3 -0
- package/utils/debug-source.js.map +1 -1
- package/utils/index.windows.d.ts +20 -0
- package/utils/index.windows.js +94 -0
- package/utils/index.windows.js.map +1 -0
- package/utils/layout-helper/index.windows.d.ts +25 -0
- package/utils/layout-helper/index.windows.js +74 -0
- package/utils/layout-helper/index.windows.js.map +1 -0
- package/utils/mainthread-helper.windows.d.ts +3 -0
- package/utils/mainthread-helper.windows.js +18 -0
- package/utils/mainthread-helper.windows.js.map +1 -0
- package/utils/native-helper.android.d.ts +2 -66
- package/utils/native-helper.android.js.map +1 -1
- package/utils/native-helper.ios.d.ts +2 -105
- package/utils/native-helper.ios.js +4 -15
- package/utils/native-helper.ios.js.map +1 -1
- package/utils/native-helper.windows.d.ts +8 -0
- package/utils/native-helper.windows.js +101 -0
- package/utils/native-helper.windows.js.map +1 -0
- package/utils/platform-check.d.ts +1 -1
- package/utils/platform-check.js.map +1 -1
- package/utils/native-helper.types.d.ts +0 -2
|
@@ -0,0 +1,639 @@
|
|
|
1
|
+
export * from './text-base-common';
|
|
2
|
+
import { TextBaseCommon, textProperty, formattedTextProperty, textTransformProperty, textAlignmentProperty, whiteSpaceProperty, resetSymbol, textShadowProperty, letterSpacingProperty, lineHeightProperty, textDecorationProperty } from './text-base-common';
|
|
3
|
+
import { Color } from '../../color';
|
|
4
|
+
import { colorProperty, fontInternalProperty, fontSizeProperty, paddingLeftProperty, paddingTopProperty, paddingRightProperty, paddingBottomProperty, fontWeightProperty, fontStyleProperty } from '../styling/style-properties';
|
|
5
|
+
import { getFontFamilyCached } from '../styling/font.windows';
|
|
6
|
+
import { layout } from '../../utils';
|
|
7
|
+
// WinUI uses DIPs — do not multiply by density. Convert px→dip for 'px' unit values.
|
|
8
|
+
function toDip(value, auto = 0) {
|
|
9
|
+
if (typeof value === 'number')
|
|
10
|
+
return value;
|
|
11
|
+
if (!value || typeof value === 'string')
|
|
12
|
+
return auto;
|
|
13
|
+
const v = value;
|
|
14
|
+
if (v.unit === 'dip')
|
|
15
|
+
return v.value;
|
|
16
|
+
if (v.unit === 'px')
|
|
17
|
+
return v.value / (layout.getDisplayDensity?.() ?? 1);
|
|
18
|
+
return auto;
|
|
19
|
+
}
|
|
20
|
+
function makeThickness(options, def) {
|
|
21
|
+
const { Left, Top, Right, Bottom } = options;
|
|
22
|
+
return Microsoft.UI.Xaml.ThicknessHelper.FromLengths(Left ?? def.Left, Top ?? def.Top, Right ?? def.Right, Bottom ?? def.Bottom);
|
|
23
|
+
}
|
|
24
|
+
// Microsoft.UI.Text.FontWeights resolves in WinUI3; guarded so a future projection gap degrades gracefully.
|
|
25
|
+
function toFontWeight(value) {
|
|
26
|
+
try {
|
|
27
|
+
switch (value) {
|
|
28
|
+
case '700':
|
|
29
|
+
case 'bold':
|
|
30
|
+
return Microsoft.UI.Text.FontWeights.Bold;
|
|
31
|
+
case '400':
|
|
32
|
+
case 'normal':
|
|
33
|
+
return Microsoft.UI.Text.FontWeights.Normal;
|
|
34
|
+
case '100': return Microsoft.UI.Text.FontWeights.Thin;
|
|
35
|
+
case '200': return Microsoft.UI.Text.FontWeights.ExtraLight;
|
|
36
|
+
case '300': return Microsoft.UI.Text.FontWeights.Light;
|
|
37
|
+
case '500': return Microsoft.UI.Text.FontWeights.Medium;
|
|
38
|
+
case '600': return Microsoft.UI.Text.FontWeights.SemiBold;
|
|
39
|
+
case '800': return Microsoft.UI.Text.FontWeights.ExtraBold;
|
|
40
|
+
case '900': return Microsoft.UI.Text.FontWeights.Black;
|
|
41
|
+
default:
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function fromFontWeight(value) {
|
|
50
|
+
switch (value) {
|
|
51
|
+
case Microsoft.UI.Text.FontWeights.Bold:
|
|
52
|
+
return '700';
|
|
53
|
+
case Microsoft.UI.Text.FontWeights.Normal:
|
|
54
|
+
return '400';
|
|
55
|
+
case Microsoft.UI.Text.FontWeights.Thin:
|
|
56
|
+
return '100';
|
|
57
|
+
case Microsoft.UI.Text.FontWeights.ExtraLight:
|
|
58
|
+
return '200';
|
|
59
|
+
case Microsoft.UI.Text.FontWeights.Light:
|
|
60
|
+
return '300';
|
|
61
|
+
case Microsoft.UI.Text.FontWeights.Medium:
|
|
62
|
+
return '500';
|
|
63
|
+
case Microsoft.UI.Text.FontWeights.SemiBold:
|
|
64
|
+
return '600';
|
|
65
|
+
case Microsoft.UI.Text.FontWeights.ExtraBold:
|
|
66
|
+
return '800';
|
|
67
|
+
case Microsoft.UI.Text.FontWeights.Black:
|
|
68
|
+
return '900';
|
|
69
|
+
default:
|
|
70
|
+
return '400';
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
// FontStyle is `Windows.UI.Text.FontStyle` — NOT `Microsoft.UI.Text` (which was NOT migrated from
|
|
74
|
+
// WinUI3; only FontWeights was). `Microsoft.UI.Text.FontStyle` is undefined, so `.Normal` throws.
|
|
75
|
+
// Guard: a throw inside applyAllNativeSetters aborts loading every following sibling, blanking the page.
|
|
76
|
+
function toFontStyle(value) {
|
|
77
|
+
try {
|
|
78
|
+
switch (value) {
|
|
79
|
+
case 'italic':
|
|
80
|
+
return Windows.UI.Text.FontStyle.Italic;
|
|
81
|
+
case 'normal':
|
|
82
|
+
return Windows.UI.Text.FontStyle.Normal;
|
|
83
|
+
case 'oblique':
|
|
84
|
+
return Windows.UI.Text.FontStyle.Oblique;
|
|
85
|
+
default:
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
function fromFontStyle(value) {
|
|
94
|
+
try {
|
|
95
|
+
if (value === Windows.UI.Text.FontStyle.Italic) {
|
|
96
|
+
return 'italic';
|
|
97
|
+
}
|
|
98
|
+
else if (value === Windows.UI.Text.FontStyle.Oblique) {
|
|
99
|
+
return 'oblique';
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
catch {
|
|
103
|
+
}
|
|
104
|
+
return 'normal';
|
|
105
|
+
}
|
|
106
|
+
// TextAlignment enum: Center=0, Left=1, Right=2, Justify=3 (note: NOT Left=0). undefined leaves the default.
|
|
107
|
+
function toTextAlignment(value) {
|
|
108
|
+
switch (value) {
|
|
109
|
+
case 'center': return 0;
|
|
110
|
+
case 'left': return 1;
|
|
111
|
+
case 'right': return 2;
|
|
112
|
+
case 'justify': return 3;
|
|
113
|
+
default: return undefined;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
// Windows.UI.Text.TextDecorations flags: None=0, Underline=1, Strikethrough=2.
|
|
117
|
+
function toTextDecorations(value) {
|
|
118
|
+
const v = value || 'none';
|
|
119
|
+
let flags = 0;
|
|
120
|
+
if (v.includes('underline'))
|
|
121
|
+
flags |= 1;
|
|
122
|
+
if (v.includes('line-through'))
|
|
123
|
+
flags |= 2;
|
|
124
|
+
return flags;
|
|
125
|
+
}
|
|
126
|
+
const HYPERLINK_CLICK_TYPE = 'Windows.Foundation.TypedEventHandler`2<Microsoft.UI.Xaml.Documents.Hyperlink,Microsoft.UI.Xaml.Documents.HyperlinkClickEventArgs>';
|
|
127
|
+
// Build TextBlock.Inlines from a NativeScript FormattedString, applying per-span font/color/
|
|
128
|
+
// decoration. Falls back to plain text for views without an Inlines property (TextBox, Button).
|
|
129
|
+
function _buildFormattedInlines(formattedText, inlines) {
|
|
130
|
+
inlines.Clear();
|
|
131
|
+
const spans = formattedText?.spans;
|
|
132
|
+
if (!spans)
|
|
133
|
+
return;
|
|
134
|
+
// text-transform on the host Label applies to every span's text (matches iOS/Android).
|
|
135
|
+
const textTransform = formattedText?.parent?.textTransform;
|
|
136
|
+
for (let i = 0; i < spans.length; i++) {
|
|
137
|
+
const span = spans.getItem(i);
|
|
138
|
+
const run = new Microsoft.UI.Xaml.Documents.Run();
|
|
139
|
+
const spanText = span.text ?? '';
|
|
140
|
+
run.Text = textTransform && textTransform !== 'none' ? getTransformedText(spanText, textTransform) : spanText;
|
|
141
|
+
if (span.fontFamily) {
|
|
142
|
+
const ff = getFontFamilyCached(span.fontFamily);
|
|
143
|
+
if (ff)
|
|
144
|
+
run.FontFamily = ff;
|
|
145
|
+
}
|
|
146
|
+
if (span.fontSize)
|
|
147
|
+
run.FontSize = span.fontSize;
|
|
148
|
+
if (span.fontStyle) {
|
|
149
|
+
const fs = toFontStyle(span.fontStyle);
|
|
150
|
+
if (fs !== null)
|
|
151
|
+
run.FontStyle = fs;
|
|
152
|
+
}
|
|
153
|
+
if (span.fontWeight) {
|
|
154
|
+
const fw = toFontWeight(span.fontWeight);
|
|
155
|
+
if (fw !== null)
|
|
156
|
+
run.FontWeight = fw;
|
|
157
|
+
}
|
|
158
|
+
if (span.color) {
|
|
159
|
+
try {
|
|
160
|
+
run.Foreground = new Microsoft.UI.Xaml.Media.SolidColorBrush(span.color.windows);
|
|
161
|
+
}
|
|
162
|
+
catch (_e) { }
|
|
163
|
+
}
|
|
164
|
+
// Span-level decoration only — host-level decoration is set on the TextBlock itself and
|
|
165
|
+
// renders block-wide without needing per-run flags.
|
|
166
|
+
const flags = toTextDecorations(span.textDecoration);
|
|
167
|
+
if (flags) {
|
|
168
|
+
run.TextDecorations = flags;
|
|
169
|
+
}
|
|
170
|
+
// Tappable spans → wrap the Run in a Hyperlink (XAML hit-tests it and raises Click).
|
|
171
|
+
// UnderlineStyle=None keeps the span's own styling; the delegate is parked on the span so
|
|
172
|
+
// it isn't GC'd while only the native Click holds it.
|
|
173
|
+
if (span.tappable) {
|
|
174
|
+
try {
|
|
175
|
+
const link = new Microsoft.UI.Xaml.Documents.Hyperlink();
|
|
176
|
+
try {
|
|
177
|
+
link.UnderlineStyle = 0;
|
|
178
|
+
}
|
|
179
|
+
catch (_e) { }
|
|
180
|
+
if (span.color) {
|
|
181
|
+
try {
|
|
182
|
+
link.Foreground = new Microsoft.UI.Xaml.Media.SolidColorBrush(span.color.windows);
|
|
183
|
+
}
|
|
184
|
+
catch (_e) { }
|
|
185
|
+
}
|
|
186
|
+
const del = NSWinRT.asDelegate(HYPERLINK_CLICK_TYPE, () => span._emit('linkTap'));
|
|
187
|
+
span.__winLinkDelegate = del;
|
|
188
|
+
link.Click = del;
|
|
189
|
+
link.Inlines.Append(run);
|
|
190
|
+
inlines.Append(link);
|
|
191
|
+
continue;
|
|
192
|
+
}
|
|
193
|
+
catch (_e) { /* fall back to a plain, non-tappable run */ }
|
|
194
|
+
}
|
|
195
|
+
inlines.Append(run);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
// Module-level foreground brush cache. Avoids creating a new SolidColorBrush COM object for
|
|
199
|
+
// every text view that shares the same color. Foreground brushes are not mutated by animations
|
|
200
|
+
// (NativeScript's color animation calls setNative per frame, re-assigning Foreground rather than
|
|
201
|
+
// targeting the brush's Color property directly), so sharing is safe.
|
|
202
|
+
const _fgBrushCache = new Map(); // argb → SolidColorBrush
|
|
203
|
+
const _FG_BRUSH_MAX = 32;
|
|
204
|
+
export class TextBase extends TextBaseCommon {
|
|
205
|
+
constructor() {
|
|
206
|
+
super(...arguments);
|
|
207
|
+
this._textShadowVisual = null;
|
|
208
|
+
this._wrapTextBlock = null;
|
|
209
|
+
// Active text-shadow for a TextBox (TextField/TextView). The C++ glyph mask is a snapshot, so we
|
|
210
|
+
// remember the value and rebuild it when the text changes. null when no shadow / not a TextBox.
|
|
211
|
+
this._textBoxShadow = null;
|
|
212
|
+
}
|
|
213
|
+
[textProperty.getDefault]() {
|
|
214
|
+
return resetSymbol;
|
|
215
|
+
}
|
|
216
|
+
[textProperty.setNative](value) {
|
|
217
|
+
const reset = value === resetSymbol;
|
|
218
|
+
if (!reset && this.formattedText) {
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
this._setNativeText(reset);
|
|
222
|
+
}
|
|
223
|
+
// Apply (or clear) a CSS text-shadow on a WinUI TextBox via the C++ TextShadowHelper, which draws
|
|
224
|
+
// the glyph alpha mask on a GPU composition surface (no PNG) and attaches a DropShadow.
|
|
225
|
+
_applyTextBoxShadow(nv, value) {
|
|
226
|
+
try {
|
|
227
|
+
if (!value || !value.color) {
|
|
228
|
+
this._textBoxShadow = null;
|
|
229
|
+
NativeScript.Widgets.TextShadowHelper.Clear(nv);
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
this._textBoxShadow = value;
|
|
233
|
+
const argb = (value.color.argb) >>> 0;
|
|
234
|
+
NativeScript.Widgets.TextShadowHelper.Apply(nv, argb, toDip(value.blurRadius ?? 0, 0), toDip(value.offsetX ?? 0, 0), toDip(value.offsetY ?? 0, 0));
|
|
235
|
+
}
|
|
236
|
+
catch (_e) { }
|
|
237
|
+
}
|
|
238
|
+
// @ts-ignore — setNative is a symbol index whose value type is widened across properties.
|
|
239
|
+
[textShadowProperty.setNative](value) {
|
|
240
|
+
// Guarded: a throw here would abort page setup / navigation.
|
|
241
|
+
try {
|
|
242
|
+
const nv = this.nativeTextViewProtected;
|
|
243
|
+
if (!nv) {
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
// Resolve the TextBlock whose text silhouette (GetAlphaMask) the shadow is cast from:
|
|
247
|
+
// • Label IS a TextBlock → use it directly.
|
|
248
|
+
// • Button has plain string Content (no alpha mask) → hoist it into a TextBlock (shared with
|
|
249
|
+
// the decoration / white-space hoist) and shadow that, matching iOS (shadow on all text).
|
|
250
|
+
// • TextField/TextView are a WinUI TextBox: no GetAlphaMask and no Content to hoist, so a
|
|
251
|
+
// composition text-shadow can't be produced there (WinUI capability gap).
|
|
252
|
+
let tv = nv;
|
|
253
|
+
if (typeof nv.GetAlphaMask !== 'function') {
|
|
254
|
+
if (typeof nv.Content !== 'undefined' && typeof nv.TextWrapping === 'undefined') {
|
|
255
|
+
if (!this._wrapTextBlock) {
|
|
256
|
+
const tb = new Microsoft.UI.Xaml.Controls.TextBlock();
|
|
257
|
+
tb.Text = getTransformedText(this.text ?? '', this.textTransform);
|
|
258
|
+
nv.Content = tb;
|
|
259
|
+
this._wrapTextBlock = tb;
|
|
260
|
+
}
|
|
261
|
+
tv = this._wrapTextBlock;
|
|
262
|
+
}
|
|
263
|
+
else {
|
|
264
|
+
// TextField/TextView are a WinUI TextBox (no GetAlphaMask, no hoistable Content). The
|
|
265
|
+
// C++ TextShadowHelper rasterizes the glyphs onto a GPU composition surface and applies
|
|
266
|
+
// the same DropShadow mask — no PNG round-trip, so it's cheap to redraw. Remember the
|
|
267
|
+
// value so the snapshot mask can be rebuilt when the text changes (see _setNativeText).
|
|
268
|
+
this._applyTextBoxShadow(nv, value);
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
const host = Microsoft.UI.Xaml.Hosting.ElementCompositionPreview.GetElementVisual(tv);
|
|
273
|
+
const compositor = host.Compositor;
|
|
274
|
+
if (this._textShadowVisual) {
|
|
275
|
+
Microsoft.UI.Xaml.Hosting.ElementCompositionPreview.SetElementChildVisual(tv, null);
|
|
276
|
+
this._textShadowVisual = null;
|
|
277
|
+
}
|
|
278
|
+
if (!value || !value.color || typeof tv.GetAlphaMask !== 'function') {
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
// GetAlphaMask gives the text's exact silhouette as a CompositionBrush — the correct
|
|
282
|
+
// mask for a text DropShadow (WinUI's canonical text-shadow technique).
|
|
283
|
+
const sprite = compositor.CreateSpriteVisual();
|
|
284
|
+
// Track the host element's size natively. Expression animations on `Size` throw E_INVALIDARG
|
|
285
|
+
// in this V8/UWP composition projection (same gotcha documented in CompositionBorderHandler),
|
|
286
|
+
// which left the sprite at Size 0 → the DropShadow had no area to cast → text-shadow was
|
|
287
|
+
// invisible. RelativeSizeAdjustment(1,1) tracks the parent (the text element) size natively.
|
|
288
|
+
sprite.RelativeSizeAdjustment = new Windows.Foundation.Numerics.Vector2(1, 1);
|
|
289
|
+
const drop = compositor.CreateDropShadow();
|
|
290
|
+
drop.Mask = tv.GetAlphaMask();
|
|
291
|
+
drop.Color = value.color.windows;
|
|
292
|
+
drop.BlurRadius = toDip(value.blurRadius ?? 0, 0);
|
|
293
|
+
drop.Offset = new Windows.Foundation.Numerics.Vector3(toDip(value.offsetX ?? 0, 0), toDip(value.offsetY ?? 0, 0), 0);
|
|
294
|
+
// Sprite has no fill brush, so only the shadow paints (the crisp text still renders
|
|
295
|
+
// from the TextBlock itself).
|
|
296
|
+
sprite.Shadow = drop;
|
|
297
|
+
Microsoft.UI.Xaml.Hosting.ElementCompositionPreview.SetElementChildVisual(tv, sprite);
|
|
298
|
+
this._textShadowVisual = sprite;
|
|
299
|
+
}
|
|
300
|
+
catch (_e) { }
|
|
301
|
+
}
|
|
302
|
+
[colorProperty.getDefault]() {
|
|
303
|
+
const nativeView = this.nativeTextViewProtected;
|
|
304
|
+
return nativeView?.Foreground ?? null;
|
|
305
|
+
}
|
|
306
|
+
[colorProperty.setNative](value) {
|
|
307
|
+
if (!this.formattedText || !(value instanceof Color)) {
|
|
308
|
+
try {
|
|
309
|
+
let brush = null;
|
|
310
|
+
if (value instanceof Color) {
|
|
311
|
+
// Reuse cached brush for the same ARGB — avoids a new SolidColorBrush COM object
|
|
312
|
+
// per text view when multiple views share the same color (e.g. theme text color).
|
|
313
|
+
const argb = value.argb;
|
|
314
|
+
brush = _fgBrushCache.get(argb) ?? null;
|
|
315
|
+
if (!brush) {
|
|
316
|
+
brush = new Microsoft.UI.Xaml.Media.SolidColorBrush(value.windows);
|
|
317
|
+
if (_fgBrushCache.size >= _FG_BRUSH_MAX) {
|
|
318
|
+
_fgBrushCache.delete(_fgBrushCache.keys().next().value);
|
|
319
|
+
}
|
|
320
|
+
_fgBrushCache.set(argb, brush);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
else if (value != null) {
|
|
324
|
+
//@ts-ignore
|
|
325
|
+
if (value instanceof Windows.UI.Color) {
|
|
326
|
+
brush = new Microsoft.UI.Xaml.Media.SolidColorBrush(value);
|
|
327
|
+
}
|
|
328
|
+
else {
|
|
329
|
+
brush = new Microsoft.UI.Xaml.Media.SolidColorBrush(new Color(value).windows);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
if (brush) {
|
|
333
|
+
this.nativeTextViewProtected.Foreground = brush;
|
|
334
|
+
// Override ButtonForeground resource so the XAML template binding picks up
|
|
335
|
+
// our colour even when the Normal-state VSM animation replaces it.
|
|
336
|
+
try {
|
|
337
|
+
this.nativeTextViewProtected.Resources.Insert('ButtonForeground', brush);
|
|
338
|
+
}
|
|
339
|
+
catch (_re) { }
|
|
340
|
+
try {
|
|
341
|
+
this.nativeTextViewProtected.Resources.Insert('ButtonForegroundPointerOver', brush);
|
|
342
|
+
}
|
|
343
|
+
catch (_re) { }
|
|
344
|
+
try {
|
|
345
|
+
this.nativeTextViewProtected.Resources.Insert('ButtonForegroundPressed', brush);
|
|
346
|
+
}
|
|
347
|
+
catch (_re) { }
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
catch (_e) { }
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
[fontSizeProperty.getDefault]() {
|
|
354
|
+
// WinUI3 default FontSize = 14. Hardcoded to avoid a WinRT property read per text view
|
|
355
|
+
// during applyAllNativeSetters — saves 1 WinRT call per Label/Button/TextField created.
|
|
356
|
+
return { nativeSize: 14 };
|
|
357
|
+
}
|
|
358
|
+
[fontSizeProperty.setNative](value) {
|
|
359
|
+
if (!this.formattedText || typeof value !== 'number') {
|
|
360
|
+
const size = typeof value === 'number' ? value : value.nativeSize;
|
|
361
|
+
this.nativeTextViewProtected.FontSize = size;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
[fontStyleProperty.getDefault]() {
|
|
365
|
+
// WinUI3 default FontStyle = Normal for all standard text controls.
|
|
366
|
+
// Hardcoded to avoid a WinRT read per text view.
|
|
367
|
+
return 'normal';
|
|
368
|
+
}
|
|
369
|
+
[fontStyleProperty.setNative](value) {
|
|
370
|
+
if (!this.formattedText) {
|
|
371
|
+
const style = toFontStyle(value);
|
|
372
|
+
if (!style)
|
|
373
|
+
return;
|
|
374
|
+
this.nativeTextViewProtected.FontStyle = style;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
[fontWeightProperty.getDefault]() {
|
|
378
|
+
// WinUI3 default FontWeight = Normal (400) for TextBlock, Button, TextBox, etc.
|
|
379
|
+
// Hardcoded to avoid a WinRT read per text view; saves 1 WinRT call during creation.
|
|
380
|
+
return '400';
|
|
381
|
+
}
|
|
382
|
+
[fontWeightProperty.setNative](value) {
|
|
383
|
+
const weight = toFontWeight(value);
|
|
384
|
+
if (!weight)
|
|
385
|
+
return;
|
|
386
|
+
this.nativeTextViewProtected.FontWeight = weight;
|
|
387
|
+
}
|
|
388
|
+
[fontInternalProperty.setNative](value) {
|
|
389
|
+
const nativeView = this.nativeTextViewProtected;
|
|
390
|
+
if (!nativeView)
|
|
391
|
+
return;
|
|
392
|
+
if (value) {
|
|
393
|
+
value?.applyWindowsFont?.(nativeView);
|
|
394
|
+
if (value?.fontStyle) {
|
|
395
|
+
const style = toFontStyle(value.fontStyle);
|
|
396
|
+
if (style) {
|
|
397
|
+
nativeView.FontStyle = style;
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
if (value?.fontWeight) {
|
|
401
|
+
const weight = toFontWeight(value.fontWeight);
|
|
402
|
+
if (weight) {
|
|
403
|
+
nativeView.FontWeight = weight;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
if (value?.fontSize) {
|
|
407
|
+
nativeView.FontSize = value.fontSize;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
[formattedTextProperty.setNative](value) {
|
|
412
|
+
const nativeView = this.nativeTextViewProtected;
|
|
413
|
+
// Sync the `text` mirror FIRST so the plain-text fallback below (TextBox/PasswordBox have no
|
|
414
|
+
// rich Inlines) reads the current value, not the stale one.
|
|
415
|
+
textProperty.nativeValueChange(this, !value ? '' : value.toString());
|
|
416
|
+
if (value && nativeView) {
|
|
417
|
+
let inlinesHost = nativeView;
|
|
418
|
+
if (typeof nativeView.Inlines === 'undefined' && typeof nativeView.Content !== 'undefined') {
|
|
419
|
+
// Button: no Inlines on the control itself — host the spans in a TextBlock Content.
|
|
420
|
+
if (!this._wrapTextBlock) {
|
|
421
|
+
this._wrapTextBlock = new Microsoft.UI.Xaml.Controls.TextBlock();
|
|
422
|
+
nativeView.Content = this._wrapTextBlock;
|
|
423
|
+
// The Button itself has no TextDecorations — carry the host-level value over
|
|
424
|
+
// to the freshly created TextBlock.
|
|
425
|
+
this._wrapTextBlock.TextDecorations = toTextDecorations(this.style.textDecoration);
|
|
426
|
+
}
|
|
427
|
+
inlinesHost = this._wrapTextBlock;
|
|
428
|
+
}
|
|
429
|
+
if (typeof inlinesHost.Inlines !== 'undefined') {
|
|
430
|
+
_buildFormattedInlines(value, inlinesHost.Inlines);
|
|
431
|
+
}
|
|
432
|
+
else {
|
|
433
|
+
// TextBox/PasswordBox: no rich text support — plain text fallback.
|
|
434
|
+
this._setNativeText();
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
else {
|
|
438
|
+
this._setNativeText();
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
[textTransformProperty.setNative](_value) {
|
|
442
|
+
if (this.formattedText) {
|
|
443
|
+
// Rebuild the spans so the new transform applies to each span's text.
|
|
444
|
+
// @ts-ignore
|
|
445
|
+
this[formattedTextProperty.setNative](this.formattedText);
|
|
446
|
+
return;
|
|
447
|
+
}
|
|
448
|
+
this._setNativeText();
|
|
449
|
+
}
|
|
450
|
+
[paddingTopProperty.getDefault]() {
|
|
451
|
+
return { value: this._defaultPaddingTop, unit: 'px' };
|
|
452
|
+
}
|
|
453
|
+
//@ts-ignore
|
|
454
|
+
[paddingTopProperty.setNative](value) {
|
|
455
|
+
const padding = this.nativeTextViewProtected.Padding;
|
|
456
|
+
if (!padding)
|
|
457
|
+
return;
|
|
458
|
+
this.nativeTextViewProtected.Padding = makeThickness({
|
|
459
|
+
Top: toDip(value) + toDip(this.style.borderTopWidth),
|
|
460
|
+
}, padding);
|
|
461
|
+
}
|
|
462
|
+
[paddingRightProperty.getDefault]() {
|
|
463
|
+
return { value: this._defaultPaddingRight, unit: 'px' };
|
|
464
|
+
}
|
|
465
|
+
//@ts-ignore
|
|
466
|
+
[paddingRightProperty.setNative](value) {
|
|
467
|
+
const padding = this.nativeTextViewProtected.Padding;
|
|
468
|
+
if (!padding)
|
|
469
|
+
return;
|
|
470
|
+
this.nativeTextViewProtected.Padding = makeThickness({
|
|
471
|
+
Right: toDip(value) + toDip(this.style.borderRightWidth),
|
|
472
|
+
}, padding);
|
|
473
|
+
}
|
|
474
|
+
[paddingBottomProperty.getDefault]() {
|
|
475
|
+
return { value: this._defaultPaddingBottom, unit: 'px' };
|
|
476
|
+
}
|
|
477
|
+
//@ts-ignore
|
|
478
|
+
[paddingBottomProperty.setNative](value) {
|
|
479
|
+
const padding = this.nativeTextViewProtected.Padding;
|
|
480
|
+
if (!padding)
|
|
481
|
+
return;
|
|
482
|
+
this.nativeTextViewProtected.Padding = makeThickness({
|
|
483
|
+
Bottom: toDip(value) + toDip(this.style.borderBottomWidth),
|
|
484
|
+
}, padding);
|
|
485
|
+
}
|
|
486
|
+
[paddingLeftProperty.getDefault]() {
|
|
487
|
+
return { value: this._defaultPaddingLeft, unit: 'px' };
|
|
488
|
+
}
|
|
489
|
+
//@ts-ignore
|
|
490
|
+
[paddingLeftProperty.setNative](value) {
|
|
491
|
+
const padding = this.nativeTextViewProtected.Padding;
|
|
492
|
+
if (!padding)
|
|
493
|
+
return;
|
|
494
|
+
this.nativeTextViewProtected.Padding = makeThickness({
|
|
495
|
+
Left: toDip(value) + toDip(this.style.borderLeftWidth),
|
|
496
|
+
}, padding);
|
|
497
|
+
}
|
|
498
|
+
[textAlignmentProperty.setNative](value) {
|
|
499
|
+
const nativeView = this.nativeTextViewProtected;
|
|
500
|
+
if (!nativeView)
|
|
501
|
+
return;
|
|
502
|
+
const ta = toTextAlignment(value);
|
|
503
|
+
if (ta === undefined)
|
|
504
|
+
return;
|
|
505
|
+
// A wrapping Button hoists its text into a TextBlock; the Button itself has no TextAlignment.
|
|
506
|
+
if (this._wrapTextBlock) {
|
|
507
|
+
this._wrapTextBlock.TextAlignment = ta;
|
|
508
|
+
}
|
|
509
|
+
if (typeof nativeView.TextAlignment !== 'undefined') {
|
|
510
|
+
nativeView.TextAlignment = ta;
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
// TextWrapping: NoWrap=1, Wrap=2, WrapWholeWords=3
|
|
514
|
+
[whiteSpaceProperty.setNative](value) {
|
|
515
|
+
const nativeView = this.nativeTextViewProtected;
|
|
516
|
+
if (!nativeView)
|
|
517
|
+
return;
|
|
518
|
+
// Button has no TextWrapping — use a TextBlock as its Content so word-wrap works.
|
|
519
|
+
if (typeof nativeView.TextWrapping === 'undefined' && typeof nativeView.Content !== 'undefined') {
|
|
520
|
+
if (value !== 'nowrap') {
|
|
521
|
+
if (!this._wrapTextBlock) {
|
|
522
|
+
const tb = new Microsoft.UI.Xaml.Controls.TextBlock();
|
|
523
|
+
// Read the text from the model, not nativeView.Content: a Button's Content getter does
|
|
524
|
+
// NOT return a JS string after boxing (it's an IInspectable wrapper), so the old
|
|
525
|
+
// `=== 'string'` check failed and the TextBlock was created empty → blank Button.
|
|
526
|
+
tb.Text = getTransformedText(this.text ?? '', this.textTransform);
|
|
527
|
+
nativeView.Content = tb;
|
|
528
|
+
nativeView.HorizontalContentAlignment = 3; // Stretch
|
|
529
|
+
// Carry the host's text-align onto the new TextBlock (may have been applied earlier).
|
|
530
|
+
const wrapTa = toTextAlignment(this.style.textAlignment);
|
|
531
|
+
if (wrapTa !== undefined)
|
|
532
|
+
tb.TextAlignment = wrapTa;
|
|
533
|
+
this._wrapTextBlock = tb;
|
|
534
|
+
}
|
|
535
|
+
this._wrapTextBlock.TextWrapping = 2; // Wrap
|
|
536
|
+
}
|
|
537
|
+
else {
|
|
538
|
+
if (this._wrapTextBlock) {
|
|
539
|
+
nativeView.Content = this._wrapTextBlock.Text;
|
|
540
|
+
nativeView.HorizontalContentAlignment = 1; // Center (default)
|
|
541
|
+
this._wrapTextBlock = null;
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
return;
|
|
545
|
+
}
|
|
546
|
+
nativeView.TextWrapping = (value === 'nowrap') ? 1 : 3; // NoWrap or WrapWholeWords
|
|
547
|
+
}
|
|
548
|
+
// CharacterSpacing is in 1/1000 em units; NativeScript letterSpacing is in em.
|
|
549
|
+
// @ts-ignore — setNative is a symbol index
|
|
550
|
+
[letterSpacingProperty.setNative](value) {
|
|
551
|
+
const nativeView = this.nativeTextViewProtected;
|
|
552
|
+
if (!nativeView)
|
|
553
|
+
return;
|
|
554
|
+
if (typeof nativeView.CharacterSpacing !== 'undefined') {
|
|
555
|
+
nativeView.CharacterSpacing = Math.round((value || 0) * 1000);
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
// @ts-ignore — setNative is a symbol index
|
|
559
|
+
[lineHeightProperty.setNative](value) {
|
|
560
|
+
const nativeView = this.nativeTextViewProtected;
|
|
561
|
+
if (!nativeView)
|
|
562
|
+
return;
|
|
563
|
+
// TextBlock.LineHeight: 0 = auto (default), positive value = exact line height in DIPs.
|
|
564
|
+
// TextBox/Button have no LineHeight property; the undefined-check makes this a no-op there.
|
|
565
|
+
if (typeof nativeView.LineHeight !== 'undefined') {
|
|
566
|
+
nativeView.LineHeight = value > 0 ? value : 0;
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
// @ts-ignore — setNative is a symbol index
|
|
570
|
+
[textDecorationProperty.setNative](value) {
|
|
571
|
+
const nativeView = this.nativeTextViewProtected;
|
|
572
|
+
if (!nativeView)
|
|
573
|
+
return;
|
|
574
|
+
const flags = toTextDecorations(value);
|
|
575
|
+
// Property existence on COM proxies must be checked via value access, not `in`.
|
|
576
|
+
let host = this._wrapTextBlock ?? nativeView;
|
|
577
|
+
if (host.TextDecorations === undefined && flags && typeof nativeView.Content !== 'undefined') {
|
|
578
|
+
// Button: string Content can't render decorations — hoist it into a TextBlock.
|
|
579
|
+
if (!this._wrapTextBlock) {
|
|
580
|
+
const tb = new Microsoft.UI.Xaml.Controls.TextBlock();
|
|
581
|
+
// Read the text from the model, not nativeView.Content: a Button's Content getter does
|
|
582
|
+
// NOT return a JS string after boxing (it's an IInspectable wrapper), so the old
|
|
583
|
+
// `=== 'string'` check failed and the TextBlock was created empty → blank Button.
|
|
584
|
+
tb.Text = getTransformedText(this.text ?? '', this.textTransform);
|
|
585
|
+
nativeView.Content = tb;
|
|
586
|
+
this._wrapTextBlock = tb;
|
|
587
|
+
}
|
|
588
|
+
host = this._wrapTextBlock;
|
|
589
|
+
}
|
|
590
|
+
if (host.TextDecorations !== undefined) {
|
|
591
|
+
host.TextDecorations = flags;
|
|
592
|
+
}
|
|
593
|
+
// TextBox/PasswordBox have no TextDecorations — no-op there (matches WinUI capability).
|
|
594
|
+
}
|
|
595
|
+
_setNativeText(reset = false) {
|
|
596
|
+
const nativeView = this.nativeTextViewProtected;
|
|
597
|
+
if (!nativeView)
|
|
598
|
+
return;
|
|
599
|
+
const transformed = reset ? '' : getTransformedText(this.text ?? '', this.textTransform);
|
|
600
|
+
// Native Text/Content are HSTRING — a non-string value (e.g. a number bound straight from a
|
|
601
|
+
// ListView item) fails to marshal with 0x80004005. Coerce so any bound value renders as text.
|
|
602
|
+
const text = typeof transformed === 'string' ? transformed : String(transformed ?? '');
|
|
603
|
+
if (typeof nativeView.Text !== 'undefined') {
|
|
604
|
+
nativeView.Text = text;
|
|
605
|
+
// The TextBox shadow mask is a glyph snapshot (no live GetAlphaMask) — rebuild it on text
|
|
606
|
+
// change so the shadow tracks the new text. Only set for a TextBox.
|
|
607
|
+
if (this._textBoxShadow) {
|
|
608
|
+
this._applyTextBoxShadow(nativeView, this._textBoxShadow);
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
else if (typeof nativeView.Password !== 'undefined') {
|
|
612
|
+
// Secure TextField → PasswordBox, which has no Text property; its value is Password.
|
|
613
|
+
nativeView.Password = text;
|
|
614
|
+
}
|
|
615
|
+
else if (this._wrapTextBlock) {
|
|
616
|
+
// Button in wrap mode: update the inner TextBlock, not the Button.Content directly.
|
|
617
|
+
this._wrapTextBlock.Text = text;
|
|
618
|
+
}
|
|
619
|
+
else if (typeof nativeView.Content !== 'undefined') {
|
|
620
|
+
nativeView.Content = text;
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
export function getTransformedText(text, textTransform) {
|
|
625
|
+
if (!text || !textTransform || textTransform === 'none') {
|
|
626
|
+
return text;
|
|
627
|
+
}
|
|
628
|
+
switch (textTransform) {
|
|
629
|
+
case 'uppercase':
|
|
630
|
+
return text.toUpperCase();
|
|
631
|
+
case 'lowercase':
|
|
632
|
+
return text.toLowerCase();
|
|
633
|
+
case 'capitalize':
|
|
634
|
+
return text.replace(/\b\w/g, (c) => c.toUpperCase());
|
|
635
|
+
default:
|
|
636
|
+
return text;
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
//# sourceMappingURL=index.windows.js.map
|