@getcortexlabs/mavis 0.1.0-alpha.2 → 0.1.0-alpha.4
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/README.md +7 -5
- package/dist/native/avatar-image.d.ts +4 -0
- package/dist/native/avatar-image.d.ts.map +1 -0
- package/dist/native/avatar-image.js +12 -0
- package/dist/native/avatar-image.js.map +1 -0
- package/dist/native/avatar-label.android.d.ts +9 -0
- package/dist/native/avatar-label.android.d.ts.map +1 -0
- package/dist/native/avatar-label.android.js +9 -0
- package/dist/native/avatar-label.android.js.map +1 -0
- package/dist/native/avatar-label.d.ts +2 -0
- package/dist/native/avatar-label.d.ts.map +1 -0
- package/dist/native/avatar-label.js +2 -0
- package/dist/native/avatar-label.js.map +1 -0
- package/dist/native/box.ios.d.ts +4 -0
- package/dist/native/box.ios.d.ts.map +1 -1
- package/dist/native/box.ios.js +29 -1
- package/dist/native/box.ios.js.map +1 -1
- package/dist/native/button.ios.d.ts +13 -1
- package/dist/native/button.ios.d.ts.map +1 -1
- package/dist/native/button.ios.js +29 -1
- package/dist/native/button.ios.js.map +1 -1
- package/dist/native/checkbox.android.d.ts +7 -0
- package/dist/native/checkbox.android.d.ts.map +1 -0
- package/dist/native/checkbox.android.js +26 -0
- package/dist/native/checkbox.android.js.map +1 -0
- package/dist/native/checkbox.d.ts +7 -0
- package/dist/native/checkbox.d.ts.map +1 -0
- package/dist/native/checkbox.js +7 -0
- package/dist/native/checkbox.js.map +1 -0
- package/dist/native/composed-button.android.d.ts +4 -0
- package/dist/native/composed-button.android.d.ts.map +1 -0
- package/dist/native/composed-button.android.js +53 -0
- package/dist/native/composed-button.android.js.map +1 -0
- package/dist/native/composed-button.d.ts +3 -0
- package/dist/native/composed-button.d.ts.map +1 -0
- package/dist/native/composed-button.js +4 -0
- package/dist/native/composed-button.js.map +1 -0
- package/dist/native/dialog.android.d.ts +12 -0
- package/dist/native/dialog.android.d.ts.map +1 -0
- package/dist/native/dialog.android.js +46 -0
- package/dist/native/dialog.android.js.map +1 -0
- package/dist/native/dialog.d.ts +12 -0
- package/dist/native/dialog.d.ts.map +1 -0
- package/dist/native/dialog.ios.d.ts +12 -0
- package/dist/native/dialog.ios.d.ts.map +1 -0
- package/dist/native/dialog.ios.js +13 -0
- package/dist/native/dialog.ios.js.map +1 -0
- package/dist/native/dialog.js +4 -0
- package/dist/native/dialog.js.map +1 -0
- package/dist/native/dynamic-type.d.ts +15 -0
- package/dist/native/dynamic-type.d.ts.map +1 -0
- package/dist/native/dynamic-type.js +47 -0
- package/dist/native/dynamic-type.js.map +1 -0
- package/dist/native/flex-layout.ios.d.ts +10 -0
- package/dist/native/flex-layout.ios.d.ts.map +1 -1
- package/dist/native/flex-layout.ios.js +85 -0
- package/dist/native/flex-layout.ios.js.map +1 -1
- package/dist/native/input-action.d.ts +5 -0
- package/dist/native/input-action.d.ts.map +1 -0
- package/dist/native/input-action.js +13 -0
- package/dist/native/input-action.js.map +1 -0
- package/dist/native/keyboard-dismiss.android.d.ts +8 -0
- package/dist/native/keyboard-dismiss.android.d.ts.map +1 -0
- package/dist/native/keyboard-dismiss.android.js +9 -0
- package/dist/native/keyboard-dismiss.android.js.map +1 -0
- package/dist/native/keyboard-dismiss.d.ts +10 -0
- package/dist/native/keyboard-dismiss.d.ts.map +1 -0
- package/dist/native/keyboard-dismiss.ios.d.ts +8 -0
- package/dist/native/keyboard-dismiss.ios.d.ts.map +1 -0
- package/dist/native/keyboard-dismiss.ios.js +91 -0
- package/dist/native/keyboard-dismiss.ios.js.map +1 -0
- package/dist/native/keyboard-dismiss.js +6 -0
- package/dist/native/keyboard-dismiss.js.map +1 -0
- package/dist/native/label.android.d.ts +12 -0
- package/dist/native/label.android.d.ts.map +1 -0
- package/dist/native/label.android.js +19 -0
- package/dist/native/label.android.js.map +1 -0
- package/dist/native/label.ios.d.ts +14 -1
- package/dist/native/label.ios.d.ts.map +1 -1
- package/dist/native/label.ios.js +37 -1
- package/dist/native/label.ios.js.map +1 -1
- package/dist/native/measure-memo.d.ts +37 -0
- package/dist/native/measure-memo.d.ts.map +1 -0
- package/dist/native/measure-memo.js +82 -0
- package/dist/native/measure-memo.js.map +1 -0
- package/dist/native/motion-surface.d.ts +9 -0
- package/dist/native/motion-surface.d.ts.map +1 -0
- package/dist/native/motion-surface.js +119 -0
- package/dist/native/motion-surface.js.map +1 -0
- package/dist/native/press.d.ts +5 -2
- package/dist/native/press.d.ts.map +1 -1
- package/dist/native/press.js +52 -8
- package/dist/native/press.js.map +1 -1
- package/dist/native/progress.d.ts +7 -0
- package/dist/native/progress.d.ts.map +1 -0
- package/dist/native/progress.js +77 -0
- package/dist/native/progress.js.map +1 -0
- package/dist/native/screen.android.d.ts +6 -0
- package/dist/native/screen.android.d.ts.map +1 -0
- package/dist/native/screen.android.js +8 -0
- package/dist/native/screen.android.js.map +1 -0
- package/dist/native/screen.d.ts +2 -0
- package/dist/native/screen.d.ts.map +1 -0
- package/dist/native/screen.js +3 -0
- package/dist/native/screen.js.map +1 -0
- package/dist/native/scroll-motion.d.ts +11 -0
- package/dist/native/scroll-motion.d.ts.map +1 -0
- package/dist/native/scroll-motion.js +94 -0
- package/dist/native/scroll-motion.js.map +1 -0
- package/dist/native/segmented.d.ts +14 -0
- package/dist/native/segmented.d.ts.map +1 -0
- package/dist/native/segmented.js +86 -0
- package/dist/native/segmented.js.map +1 -0
- package/dist/native/sheet.android.d.ts +18 -0
- package/dist/native/sheet.android.d.ts.map +1 -0
- package/dist/native/sheet.android.js +16 -0
- package/dist/native/sheet.android.js.map +1 -0
- package/dist/native/sheet.d.ts +21 -0
- package/dist/native/sheet.d.ts.map +1 -0
- package/dist/native/sheet.ios.d.ts +19 -0
- package/dist/native/sheet.ios.d.ts.map +1 -0
- package/dist/native/sheet.ios.js +41 -0
- package/dist/native/sheet.ios.js.map +1 -0
- package/dist/native/sheet.js +17 -0
- package/dist/native/sheet.js.map +1 -0
- package/dist/native/tabs.android.d.ts +3 -0
- package/dist/native/tabs.android.d.ts.map +1 -0
- package/dist/native/tabs.android.js +29 -0
- package/dist/native/tabs.android.js.map +1 -0
- package/dist/native/tabs.d.ts +3 -0
- package/dist/native/tabs.d.ts.map +1 -0
- package/dist/native/tabs.js +4 -0
- package/dist/native/tabs.js.map +1 -0
- package/dist/native/text-field.android.d.ts +1 -0
- package/dist/native/text-field.android.d.ts.map +1 -1
- package/dist/native/text-field.android.js +13 -0
- package/dist/native/text-field.android.js.map +1 -1
- package/dist/native/text-field.ios.d.ts +9 -0
- package/dist/native/text-field.ios.d.ts.map +1 -0
- package/dist/native/text-field.ios.js +52 -0
- package/dist/native/text-field.ios.js.map +1 -0
- package/dist/native/text-view.ios.d.ts +7 -0
- package/dist/native/text-view.ios.d.ts.map +1 -0
- package/dist/native/text-view.ios.js +10 -0
- package/dist/native/text-view.ios.js.map +1 -0
- package/dist/native/toast.android.d.ts +4 -0
- package/dist/native/toast.android.d.ts.map +1 -0
- package/dist/native/toast.android.js +10 -0
- package/dist/native/toast.android.js.map +1 -0
- package/dist/native/toast.d.ts +4 -0
- package/dist/native/toast.d.ts.map +1 -0
- package/dist/native/toast.ios.d.ts +4 -0
- package/dist/native/toast.ios.d.ts.map +1 -0
- package/dist/native/toast.ios.js +8 -0
- package/dist/native/toast.ios.js.map +1 -0
- package/dist/native/toast.js +5 -0
- package/dist/native/toast.js.map +1 -0
- package/dist/vue/components/ChoiceControl.d.ts +101 -0
- package/dist/vue/components/ChoiceControl.d.ts.map +1 -0
- package/dist/vue/components/ChoiceControl.js +196 -0
- package/dist/vue/components/ChoiceControl.js.map +1 -0
- package/dist/vue/components/MAccordion.d.ts +109 -0
- package/dist/vue/components/MAccordion.d.ts.map +1 -0
- package/dist/vue/components/MAccordion.js +83 -0
- package/dist/vue/components/MAccordion.js.map +1 -0
- package/dist/vue/components/MAlert.d.ts +99 -0
- package/dist/vue/components/MAlert.d.ts.map +1 -0
- package/dist/vue/components/MAlert.js +126 -0
- package/dist/vue/components/MAlert.js.map +1 -0
- package/dist/vue/components/MAvatar.d.ts +74 -0
- package/dist/vue/components/MAvatar.d.ts.map +1 -0
- package/dist/vue/components/MAvatar.js +86 -0
- package/dist/vue/components/MAvatar.js.map +1 -0
- package/dist/vue/components/MBadge.d.ts +64 -0
- package/dist/vue/components/MBadge.d.ts.map +1 -0
- package/dist/vue/components/MBadge.js +30 -0
- package/dist/vue/components/MBadge.js.map +1 -0
- package/dist/vue/components/MButton.d.ts +57 -5
- package/dist/vue/components/MButton.d.ts.map +1 -1
- package/dist/vue/components/MButton.js +129 -11
- package/dist/vue/components/MButton.js.map +1 -1
- package/dist/vue/components/MCard.d.ts +23 -5
- package/dist/vue/components/MCard.d.ts.map +1 -1
- package/dist/vue/components/MCard.js +14 -4
- package/dist/vue/components/MCard.js.map +1 -1
- package/dist/vue/components/MCheckbox.d.ts +93 -0
- package/dist/vue/components/MCheckbox.d.ts.map +1 -0
- package/dist/vue/components/MCheckbox.js +26 -0
- package/dist/vue/components/MCheckbox.js.map +1 -0
- package/dist/vue/components/MChip.d.ts +107 -0
- package/dist/vue/components/MChip.d.ts.map +1 -0
- package/dist/vue/components/MChip.js +120 -0
- package/dist/vue/components/MChip.js.map +1 -0
- package/dist/vue/components/MDialog.d.ts +95 -0
- package/dist/vue/components/MDialog.d.ts.map +1 -0
- package/dist/vue/components/MDialog.js +245 -0
- package/dist/vue/components/MDialog.js.map +1 -0
- package/dist/vue/components/MEmptyState.d.ts +107 -0
- package/dist/vue/components/MEmptyState.d.ts.map +1 -0
- package/dist/vue/components/MEmptyState.js +79 -0
- package/dist/vue/components/MEmptyState.js.map +1 -0
- package/dist/vue/components/MInput.d.ts +62 -7
- package/dist/vue/components/MInput.d.ts.map +1 -1
- package/dist/vue/components/MInput.js +88 -14
- package/dist/vue/components/MInput.js.map +1 -1
- package/dist/vue/components/MListItem.d.ts +92 -0
- package/dist/vue/components/MListItem.d.ts.map +1 -0
- package/dist/vue/components/MListItem.js +53 -0
- package/dist/vue/components/MListItem.js.map +1 -0
- package/dist/vue/components/MProgress.d.ts +112 -0
- package/dist/vue/components/MProgress.d.ts.map +1 -0
- package/dist/vue/components/MProgress.js +75 -0
- package/dist/vue/components/MProgress.js.map +1 -0
- package/dist/vue/components/MRadioGroup.d.ts +93 -0
- package/dist/vue/components/MRadioGroup.d.ts.map +1 -0
- package/dist/vue/components/MRadioGroup.js +57 -0
- package/dist/vue/components/MRadioGroup.js.map +1 -0
- package/dist/vue/components/MReveal.d.ts.map +1 -1
- package/dist/vue/components/MReveal.js +5 -7
- package/dist/vue/components/MReveal.js.map +1 -1
- package/dist/vue/components/MScreen.d.ts +18 -0
- package/dist/vue/components/MScreen.d.ts.map +1 -1
- package/dist/vue/components/MScreen.js +68 -5
- package/dist/vue/components/MScreen.js.map +1 -1
- package/dist/vue/components/MSegmentedControl.d.ts +85 -0
- package/dist/vue/components/MSegmentedControl.d.ts.map +1 -0
- package/dist/vue/components/MSegmentedControl.js +172 -0
- package/dist/vue/components/MSegmentedControl.js.map +1 -0
- package/dist/vue/components/MSelect.d.ts +130 -0
- package/dist/vue/components/MSelect.d.ts.map +1 -0
- package/dist/vue/components/MSelect.js +158 -0
- package/dist/vue/components/MSelect.js.map +1 -0
- package/dist/vue/components/MSeparator.d.ts +54 -0
- package/dist/vue/components/MSeparator.d.ts.map +1 -0
- package/dist/vue/components/MSeparator.js +36 -0
- package/dist/vue/components/MSeparator.js.map +1 -0
- package/dist/vue/components/MSheet.d.ts +101 -0
- package/dist/vue/components/MSheet.d.ts.map +1 -0
- package/dist/vue/components/MSheet.js +313 -0
- package/dist/vue/components/MSheet.js.map +1 -0
- package/dist/vue/components/MSkeleton.d.ts +70 -0
- package/dist/vue/components/MSkeleton.d.ts.map +1 -0
- package/dist/vue/components/MSkeleton.js +87 -0
- package/dist/vue/components/MSkeleton.js.map +1 -0
- package/dist/vue/components/MSlider.d.ts +1 -1
- package/dist/vue/components/MSlider.d.ts.map +1 -1
- package/dist/vue/components/MSlider.js +2 -1
- package/dist/vue/components/MSlider.js.map +1 -1
- package/dist/vue/components/MSwitch.d.ts +79 -0
- package/dist/vue/components/MSwitch.d.ts.map +1 -0
- package/dist/vue/components/MSwitch.js +163 -0
- package/dist/vue/components/MSwitch.js.map +1 -0
- package/dist/vue/components/MTabs.d.ts +91 -0
- package/dist/vue/components/MTabs.d.ts.map +1 -0
- package/dist/vue/components/MTabs.js +245 -0
- package/dist/vue/components/MTabs.js.map +1 -0
- package/dist/vue/components/MText.d.ts +16 -7
- package/dist/vue/components/MText.d.ts.map +1 -1
- package/dist/vue/components/MText.js +43 -17
- package/dist/vue/components/MText.js.map +1 -1
- package/dist/vue/components/MToast.d.ts +23 -0
- package/dist/vue/components/MToast.d.ts.map +1 -0
- package/dist/vue/components/MToast.js +242 -0
- package/dist/vue/components/MToast.js.map +1 -0
- package/dist/vue/index.d.ts +31 -4
- package/dist/vue/index.d.ts.map +1 -1
- package/dist/vue/index.js +48 -4
- package/dist/vue/index.js.map +1 -1
- package/dist/vue/layers.d.ts +19 -0
- package/dist/vue/layers.d.ts.map +1 -0
- package/dist/vue/layers.js +26 -0
- package/dist/vue/layers.js.map +1 -0
- package/dist/vue/native-view.d.ts +6 -0
- package/dist/vue/native-view.d.ts.map +1 -0
- package/dist/vue/native-view.js +5 -0
- package/dist/vue/native-view.js.map +1 -0
- package/dist/vue/props.d.ts +12 -11
- package/dist/vue/props.d.ts.map +1 -1
- package/dist/vue/props.js +25 -10
- package/dist/vue/props.js.map +1 -1
- package/dist/vue/reveal-motion.d.ts +13 -0
- package/dist/vue/reveal-motion.d.ts.map +1 -0
- package/dist/vue/reveal-motion.js +55 -0
- package/dist/vue/reveal-motion.js.map +1 -0
- package/dist/vue/system-back.d.ts +11 -0
- package/dist/vue/system-back.d.ts.map +1 -0
- package/dist/vue/system-back.js +2 -0
- package/dist/vue/system-back.js.map +1 -0
- package/dist/vue/use-motion-surface.d.ts +8 -0
- package/dist/vue/use-motion-surface.d.ts.map +1 -0
- package/dist/vue/use-motion-surface.js +75 -0
- package/dist/vue/use-motion-surface.js.map +1 -0
- package/dist/vue/use-press.d.ts +1 -1
- package/dist/vue/use-press.d.ts.map +1 -1
- package/dist/vue/use-press.js +12 -4
- package/dist/vue/use-press.js.map +1 -1
- package/dist/vue/use-scroll-motion.d.ts +7 -0
- package/dist/vue/use-scroll-motion.d.ts.map +1 -0
- package/dist/vue/use-scroll-motion.js +30 -0
- package/dist/vue/use-scroll-motion.js.map +1 -0
- package/package.json +3 -3
- package/platforms/android/java/com/mavis/ui/Box.java +38 -3
- package/platforms/android/java/com/mavis/ui/ContentWidth.java +77 -0
- package/platforms/android/java/com/mavis/ui/FlexLayout.java +80 -4
- package/platforms/android/java/com/mavis/ui/MeasureMemo.java +145 -0
- package/platforms/android/java/com/mavis/ui/Screen.java +108 -0
- package/src/native/avatar-image.ts +9 -0
- package/src/native/avatar-label.android.ts +14 -0
- package/src/native/avatar-label.ts +1 -0
- package/src/native/box.ios.ts +48 -1
- package/src/native/button.ios.ts +53 -1
- package/src/native/checkbox.android.ts +35 -0
- package/src/native/checkbox.ts +9 -0
- package/src/native/composed-button.android.ts +74 -0
- package/src/native/composed-button.ts +9 -0
- package/src/native/dialog.android.ts +56 -0
- package/src/native/dialog.ios.ts +23 -0
- package/src/native/dialog.ts +10 -0
- package/src/native/dynamic-type.ts +71 -0
- package/src/native/flex-layout.ios.ts +113 -0
- package/src/native/input-action.ts +15 -0
- package/src/native/keyboard-dismiss.android.ts +17 -0
- package/src/native/keyboard-dismiss.ios.ts +124 -0
- package/src/native/keyboard-dismiss.ts +14 -0
- package/src/native/label.android.ts +27 -0
- package/src/native/label.ios.ts +54 -1
- package/src/native/measure-memo.ts +116 -0
- package/src/native/motion-surface.ts +137 -0
- package/src/native/press.ts +52 -10
- package/src/native/progress.ts +78 -0
- package/src/native/screen.android.ts +12 -0
- package/src/native/screen.ts +2 -0
- package/src/native/scroll-motion.ts +101 -0
- package/src/native/segmented.ts +95 -0
- package/src/native/sheet.android.ts +24 -0
- package/src/native/sheet.ios.ts +52 -0
- package/src/native/sheet.ts +26 -0
- package/src/native/tabs.android.ts +58 -0
- package/src/native/tabs.ts +8 -0
- package/src/native/text-field.android.ts +19 -0
- package/src/native/text-field.ios.ts +53 -0
- package/src/native/text-view.ios.ts +10 -0
- package/src/native/toast.android.ts +9 -0
- package/src/native/toast.ios.ts +13 -0
- package/src/native/toast.ts +6 -0
- package/src/vue/components/ChoiceControl.ts +238 -0
- package/src/vue/components/MAccordion.ts +123 -0
- package/src/vue/components/MAlert.ts +156 -0
- package/src/vue/components/MAvatar.ts +103 -0
- package/src/vue/components/MBadge.ts +34 -0
- package/src/vue/components/MButton.ts +176 -9
- package/src/vue/components/MCard.ts +23 -3
- package/src/vue/components/MCheckbox.ts +25 -0
- package/src/vue/components/MChip.ts +134 -0
- package/src/vue/components/MDialog.ts +312 -0
- package/src/vue/components/MEmptyState.ts +96 -0
- package/src/vue/components/MInput.ts +96 -12
- package/src/vue/components/MListItem.ts +66 -0
- package/src/vue/components/MProgress.ts +94 -0
- package/src/vue/components/MRadioGroup.ts +64 -0
- package/src/vue/components/MReveal.ts +6 -7
- package/src/vue/components/MScreen.ts +93 -5
- package/src/vue/components/MSegmentedControl.ts +214 -0
- package/src/vue/components/MSelect.ts +185 -0
- package/src/vue/components/MSeparator.ts +40 -0
- package/src/vue/components/MSheet.ts +375 -0
- package/src/vue/components/MSkeleton.ts +100 -0
- package/src/vue/components/MSlider.ts +7 -1
- package/src/vue/components/MSwitch.ts +187 -0
- package/src/vue/components/MTabs.ts +302 -0
- package/src/vue/components/MText.ts +37 -6
- package/src/vue/components/MToast.ts +289 -0
- package/src/vue/index.ts +90 -4
- package/src/vue/layers.ts +48 -0
- package/src/vue/native-view.ts +6 -0
- package/src/vue/props.ts +37 -12
- package/src/vue/reveal-motion.ts +61 -0
- package/src/vue/system-back.ts +12 -0
- package/src/vue/use-motion-surface.ts +77 -0
- package/src/vue/use-press.ts +12 -4
- package/src/vue/use-scroll-motion.ts +31 -0
- package/dist/native/input-description.android.d.ts +0 -4
- package/dist/native/input-description.android.d.ts.map +0 -1
- package/dist/native/input-description.android.js +0 -18
- package/dist/native/input-description.android.js.map +0 -1
- package/dist/theme/resolve.d.ts +0 -3
- package/dist/theme/resolve.d.ts.map +0 -1
- package/dist/theme/resolve.js +0 -8
- package/dist/theme/resolve.js.map +0 -1
- package/dist/theme/themes.d.ts +0 -6
- package/dist/theme/themes.d.ts.map +0 -1
- package/dist/theme/themes.js +0 -83
- package/dist/theme/themes.js.map +0 -1
- package/dist/theme/types.d.ts +0 -50
- package/dist/theme/types.d.ts.map +0 -1
- package/dist/theme/types.js +0 -2
- package/dist/theme/types.js.map +0 -1
- package/dist/vue/global-components.d.ts +0 -21
- package/dist/vue/global-components.d.ts.map +0 -1
- package/dist/vue/global-components.js +0 -2
- package/dist/vue/global-components.js.map +0 -1
- package/dist/vue/layout-context.d.ts +0 -5
- package/dist/vue/layout-context.d.ts.map +0 -1
- package/dist/vue/layout-context.js +0 -7
- package/dist/vue/layout-context.js.map +0 -1
- package/dist/vue/text-content.d.ts +0 -4
- package/dist/vue/text-content.d.ts.map +0 -1
- package/dist/vue/text-content.js +0 -17
- package/dist/vue/text-content.js.map +0 -1
- package/dist/vue/theme.d.ts +0 -177
- package/dist/vue/theme.d.ts.map +0 -1
- package/dist/vue/theme.js +0 -17
- package/dist/vue/theme.js.map +0 -1
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
import { useButtonAction, themeKey, type MavisThemeContext } from '@getcortexlabs/mavis-core/vue'
|
|
2
|
+
import {
|
|
3
|
+
provide,
|
|
4
|
+
defineComponent,
|
|
5
|
+
h,
|
|
6
|
+
onBeforeUnmount,
|
|
7
|
+
onActivated,
|
|
8
|
+
onDeactivated,
|
|
9
|
+
ref,
|
|
10
|
+
watch,
|
|
11
|
+
type PropType,
|
|
12
|
+
} from 'nativescript-vue'
|
|
13
|
+
import { Application, isIOS, Utils, type EventData, type View } from '@nativescript/core'
|
|
14
|
+
import { JoltTransition } from '@rafaelaugusto/jolt/vue'
|
|
15
|
+
import { toastProps, useMavisTheme, useToastHost } from '@getcortexlabs/mavis-core/vue'
|
|
16
|
+
import type { IconName, ToastTone } from '@getcortexlabs/mavis-core'
|
|
17
|
+
import { useLayerHost } from '../layers.js'
|
|
18
|
+
import { announceToast, toastReaderActive } from '../../native/toast'
|
|
19
|
+
import { observeCheckbox } from '../../native/checkbox'
|
|
20
|
+
import { MColumn, MBox } from './layout.js'
|
|
21
|
+
import { MText } from './MText.js'
|
|
22
|
+
import { MIcon } from './MIcon.js'
|
|
23
|
+
import { MButton } from './MButton.js'
|
|
24
|
+
|
|
25
|
+
const icons: Record<ToastTone, IconName> = {
|
|
26
|
+
success: 'circle-check',
|
|
27
|
+
error: 'circle-alert',
|
|
28
|
+
warning: 'triangle-alert',
|
|
29
|
+
info: 'info',
|
|
30
|
+
}
|
|
31
|
+
const tones = { success: 'success', error: 'danger', warning: 'warning', info: 'accent' } as const
|
|
32
|
+
|
|
33
|
+
type Bridge = {
|
|
34
|
+
context: MavisThemeContext
|
|
35
|
+
host: ReturnType<typeof useToastHost>
|
|
36
|
+
theme: ReturnType<typeof useMavisTheme>['theme']
|
|
37
|
+
props: Readonly<{
|
|
38
|
+
controller: import('@getcortexlabs/mavis-core').ToastController
|
|
39
|
+
closeLabel: string
|
|
40
|
+
}>
|
|
41
|
+
}
|
|
42
|
+
const ToastLayer = defineComponent({
|
|
43
|
+
name: 'MToastLayer',
|
|
44
|
+
props: { bridge: { type: Object as PropType<Bridge>, required: true }, covered: Boolean },
|
|
45
|
+
setup(props) {
|
|
46
|
+
provide(themeKey, props.bridge.context)
|
|
47
|
+
const { host, theme } = props.bridge
|
|
48
|
+
const width = ref(320)
|
|
49
|
+
const height = ref(600)
|
|
50
|
+
let enteredId: number | undefined
|
|
51
|
+
let announcedId: number | undefined
|
|
52
|
+
let root: View | undefined
|
|
53
|
+
let parent: View | undefined
|
|
54
|
+
let focus: ReturnType<typeof observeCheckbox> | undefined
|
|
55
|
+
const size = () => {
|
|
56
|
+
const bounds = parent?.getActualSize()
|
|
57
|
+
if (bounds) {
|
|
58
|
+
// The parent includes iOS safe areas even though Core lays this layer inside them.
|
|
59
|
+
const insets = isIOS ? parent?.getSafeAreaInsets() : undefined
|
|
60
|
+
const horizontal = insets
|
|
61
|
+
? Utils.layout.toDeviceIndependentPixels(insets.left + insets.right)
|
|
62
|
+
: 0
|
|
63
|
+
const vertical = insets
|
|
64
|
+
? Utils.layout.toDeviceIndependentPixels(insets.top + insets.bottom)
|
|
65
|
+
: 0
|
|
66
|
+
width.value = Math.max(0, Math.min(440, bounds.width - horizontal - 32))
|
|
67
|
+
height.value = Math.max(48, bounds.height - vertical - 32)
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
let background = false
|
|
71
|
+
const suspend = () => {
|
|
72
|
+
background = true
|
|
73
|
+
host.pause('background', true)
|
|
74
|
+
}
|
|
75
|
+
const resume = () => {
|
|
76
|
+
background = false
|
|
77
|
+
if (root?.isLoaded) host.pause('background', false)
|
|
78
|
+
}
|
|
79
|
+
Application.on(Application.suspendEvent, suspend)
|
|
80
|
+
Application.on(Application.resumeEvent, resume)
|
|
81
|
+
function unload() {
|
|
82
|
+
parent?.off('layoutChanged', size)
|
|
83
|
+
focus?.dispose()
|
|
84
|
+
focus = undefined
|
|
85
|
+
root = parent = undefined
|
|
86
|
+
// NativeScript also unloads the page when the app enters the background.
|
|
87
|
+
if (!background) host.deactivate()
|
|
88
|
+
}
|
|
89
|
+
function announce() {
|
|
90
|
+
const item = host.snapshot.value.message
|
|
91
|
+
if (!root || props.covered || !item || item.id !== enteredId || item.id === announcedId)
|
|
92
|
+
return
|
|
93
|
+
announceToast(root, [item.title, item.message].filter(Boolean).join('. '))
|
|
94
|
+
announcedId = item.id
|
|
95
|
+
}
|
|
96
|
+
watch(
|
|
97
|
+
() => props.covered,
|
|
98
|
+
(covered) => {
|
|
99
|
+
host.pause('modal', covered)
|
|
100
|
+
if (!covered) announce()
|
|
101
|
+
},
|
|
102
|
+
{ immediate: true },
|
|
103
|
+
)
|
|
104
|
+
onBeforeUnmount(() => {
|
|
105
|
+
unload()
|
|
106
|
+
host.deactivate()
|
|
107
|
+
Application.off(Application.suspendEvent, suspend)
|
|
108
|
+
Application.off(Application.resumeEvent, resume)
|
|
109
|
+
})
|
|
110
|
+
return () => {
|
|
111
|
+
const { colors, radius } = theme.value
|
|
112
|
+
const { message, visible } = host.snapshot.value
|
|
113
|
+
const tone = message ? tones[message.tone] : 'accent'
|
|
114
|
+
return h(
|
|
115
|
+
'MavisBox',
|
|
116
|
+
{
|
|
117
|
+
width: width.value,
|
|
118
|
+
margin: 16,
|
|
119
|
+
verticalAlignment: 'top',
|
|
120
|
+
horizontalAlignment: 'center',
|
|
121
|
+
visibility: props.covered || !message ? 'collapse' : 'visible',
|
|
122
|
+
accessibilityHidden: props.covered || !message,
|
|
123
|
+
onLoaded: (event: EventData) => {
|
|
124
|
+
root = event.object as View
|
|
125
|
+
parent = root.parent as View
|
|
126
|
+
size()
|
|
127
|
+
parent?.on('layoutChanged', size)
|
|
128
|
+
host.pause('background', background)
|
|
129
|
+
host.pause('modal', props.covered)
|
|
130
|
+
host.activate()
|
|
131
|
+
},
|
|
132
|
+
onUnloaded: unload,
|
|
133
|
+
},
|
|
134
|
+
[
|
|
135
|
+
h(
|
|
136
|
+
JoltTransition,
|
|
137
|
+
{
|
|
138
|
+
appear: true,
|
|
139
|
+
enter: [{ opacity: [0, 1], y: [-8, 0] }, { duration: 180 }],
|
|
140
|
+
leave: [{ opacity: 0, y: -4 }, { duration: 120 }],
|
|
141
|
+
onBeforeEnter: () => {
|
|
142
|
+
if (message) host.begin(message.id)
|
|
143
|
+
},
|
|
144
|
+
onAfterEnter: () => {
|
|
145
|
+
if (!message) return
|
|
146
|
+
host.pause('reader', toastReaderActive())
|
|
147
|
+
enteredId = message.id
|
|
148
|
+
announce()
|
|
149
|
+
host.entered(message.id)
|
|
150
|
+
},
|
|
151
|
+
onBeforeLeave: (element: { nativeView?: View }) => {
|
|
152
|
+
if (element.nativeView) element.nativeView.accessibilityHidden = true
|
|
153
|
+
},
|
|
154
|
+
onAfterLeave: () => {
|
|
155
|
+
if (message) host.left(message.id)
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
default: () =>
|
|
160
|
+
message && visible
|
|
161
|
+
? h(
|
|
162
|
+
'MavisBox',
|
|
163
|
+
{
|
|
164
|
+
key: message.id,
|
|
165
|
+
columns: '40,*,44',
|
|
166
|
+
padding: 16,
|
|
167
|
+
borderWidth: 1,
|
|
168
|
+
borderColor: colors.border,
|
|
169
|
+
borderRadius: radius.lg,
|
|
170
|
+
backgroundColor: colors.surface,
|
|
171
|
+
style: isIOS ? { boxShadow: '0 6 18 0 rgba(26, 15, 25, 0.12)' } : undefined,
|
|
172
|
+
},
|
|
173
|
+
[
|
|
174
|
+
h(
|
|
175
|
+
MBox,
|
|
176
|
+
{
|
|
177
|
+
col: 0,
|
|
178
|
+
width: 40,
|
|
179
|
+
height: 40,
|
|
180
|
+
radius: 'full',
|
|
181
|
+
backgroundColor: colors.elevated,
|
|
182
|
+
verticalAlignment: 'top',
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
default: () =>
|
|
186
|
+
h(MIcon, {
|
|
187
|
+
name: icons[message.tone],
|
|
188
|
+
tone,
|
|
189
|
+
horizontalAlignment: 'center',
|
|
190
|
+
verticalAlignment: 'middle',
|
|
191
|
+
}),
|
|
192
|
+
},
|
|
193
|
+
),
|
|
194
|
+
h(
|
|
195
|
+
'ScrollView',
|
|
196
|
+
{
|
|
197
|
+
col: 1,
|
|
198
|
+
marginLeft: 12,
|
|
199
|
+
style: { maxHeight: height.value - 34 },
|
|
200
|
+
},
|
|
201
|
+
[
|
|
202
|
+
h(
|
|
203
|
+
MColumn,
|
|
204
|
+
{
|
|
205
|
+
gap: 'xs',
|
|
206
|
+
verticalAlignment: 'top',
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
default: () => [
|
|
210
|
+
message.title
|
|
211
|
+
? h(MText, {
|
|
212
|
+
text: message.title,
|
|
213
|
+
style: { fontWeight: '600' },
|
|
214
|
+
})
|
|
215
|
+
: null,
|
|
216
|
+
h(MText, {
|
|
217
|
+
text: message.message,
|
|
218
|
+
tone: message.title ? 'muted' : 'text',
|
|
219
|
+
}),
|
|
220
|
+
],
|
|
221
|
+
},
|
|
222
|
+
),
|
|
223
|
+
],
|
|
224
|
+
),
|
|
225
|
+
h(MButton, {
|
|
226
|
+
col: 2,
|
|
227
|
+
size: 'sm',
|
|
228
|
+
variant: 'ghost',
|
|
229
|
+
icon: 'x',
|
|
230
|
+
width: 44,
|
|
231
|
+
verticalAlignment: 'top',
|
|
232
|
+
accessibilityLabel: props.bridge.props.closeLabel,
|
|
233
|
+
style: { paddingLeft: 0, paddingRight: 0 },
|
|
234
|
+
onClick: () => props.bridge.props.controller.dismiss(message.id),
|
|
235
|
+
onLoaded: (event: EventData) => {
|
|
236
|
+
focus?.dispose()
|
|
237
|
+
focus = observeCheckbox(event.object as View, (value) =>
|
|
238
|
+
host.pause('focus', value),
|
|
239
|
+
)
|
|
240
|
+
},
|
|
241
|
+
onUnloaded: () => {
|
|
242
|
+
focus?.dispose()
|
|
243
|
+
focus = undefined
|
|
244
|
+
host.pause('focus', false)
|
|
245
|
+
},
|
|
246
|
+
}),
|
|
247
|
+
],
|
|
248
|
+
)
|
|
249
|
+
: null,
|
|
250
|
+
},
|
|
251
|
+
),
|
|
252
|
+
],
|
|
253
|
+
)
|
|
254
|
+
}
|
|
255
|
+
},
|
|
256
|
+
})
|
|
257
|
+
|
|
258
|
+
export const MToast = defineComponent({
|
|
259
|
+
name: 'MToast',
|
|
260
|
+
inheritAttrs: false,
|
|
261
|
+
props: toastProps,
|
|
262
|
+
setup(props) {
|
|
263
|
+
useButtonAction()
|
|
264
|
+
const layers = useLayerHost('MToast')
|
|
265
|
+
const host = useToastHost(() => props.controller)
|
|
266
|
+
const context = useMavisTheme()
|
|
267
|
+
const { theme } = context
|
|
268
|
+
let remove: (() => void) | undefined
|
|
269
|
+
const attach = () => {
|
|
270
|
+
if (!remove)
|
|
271
|
+
remove = layers.add({
|
|
272
|
+
component: ToastLayer,
|
|
273
|
+
props: { bridge: { host, theme, props, context } },
|
|
274
|
+
presented: ref(true),
|
|
275
|
+
modal: false,
|
|
276
|
+
})
|
|
277
|
+
}
|
|
278
|
+
const detach = () => {
|
|
279
|
+
remove?.()
|
|
280
|
+
remove = undefined
|
|
281
|
+
host.deactivate()
|
|
282
|
+
}
|
|
283
|
+
attach()
|
|
284
|
+
onActivated(attach)
|
|
285
|
+
onDeactivated(detach)
|
|
286
|
+
onBeforeUnmount(detach)
|
|
287
|
+
return () => null
|
|
288
|
+
},
|
|
289
|
+
})
|
package/src/vue/index.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
+
import { MChip } from './components/MChip.js'
|
|
2
|
+
import { MEmptyState } from './components/MEmptyState.js'
|
|
1
3
|
import type { App } from 'nativescript-vue'
|
|
2
4
|
import {
|
|
5
|
+
MThemeProvider,
|
|
6
|
+
MSpan,
|
|
3
7
|
createThemeContext,
|
|
8
|
+
installAppToast,
|
|
4
9
|
themeKey,
|
|
5
10
|
type ThemeContextOptions,
|
|
6
11
|
} from '@getcortexlabs/mavis-core/vue'
|
|
@@ -10,13 +15,64 @@ import { MBox, MRow, MColumn } from './components/layout.js'
|
|
|
10
15
|
import { MCard } from './components/MCard.js'
|
|
11
16
|
import { MText } from './components/MText.js'
|
|
12
17
|
import { MButton } from './components/MButton.js'
|
|
18
|
+
import { MToast } from './components/MToast.js'
|
|
19
|
+
import { MDialog } from './components/MDialog.js'
|
|
20
|
+
import { MListItem } from './components/MListItem.js'
|
|
21
|
+
import { MSeparator } from './components/MSeparator.js'
|
|
22
|
+
import { MAvatar } from './components/MAvatar.js'
|
|
23
|
+
import { MBadge } from './components/MBadge.js'
|
|
24
|
+
import { MSkeleton } from './components/MSkeleton.js'
|
|
25
|
+
import { MProgress } from './components/MProgress.js'
|
|
26
|
+
import { MAccordion } from './components/MAccordion.js'
|
|
27
|
+
import { MSegmentedControl } from './components/MSegmentedControl.js'
|
|
28
|
+
import { MAlert } from './components/MAlert.js'
|
|
29
|
+
import { MTabs } from './components/MTabs.js'
|
|
30
|
+
import { MSelect } from './components/MSelect.js'
|
|
31
|
+
import { MRadioGroup } from './components/MRadioGroup.js'
|
|
32
|
+
import { MCheckbox } from './components/MCheckbox.js'
|
|
33
|
+
import { MSwitch } from './components/MSwitch.js'
|
|
13
34
|
import { MSlider } from './components/MSlider.js'
|
|
14
35
|
import { MInput } from './components/MInput.js'
|
|
15
36
|
import { MIcon } from './components/MIcon.js'
|
|
16
37
|
import { MReveal } from './components/MReveal.js'
|
|
38
|
+
import { MSheet } from './components/MSheet.js'
|
|
39
|
+
import { systemBackKey, type ClaimSystemBack, type SystemBackClaimant } from './system-back.js'
|
|
17
40
|
|
|
18
|
-
export {
|
|
19
|
-
|
|
41
|
+
export {
|
|
42
|
+
MThemeProvider,
|
|
43
|
+
MSpan,
|
|
44
|
+
MScreen,
|
|
45
|
+
MBox,
|
|
46
|
+
MRow,
|
|
47
|
+
MColumn,
|
|
48
|
+
MCard,
|
|
49
|
+
MText,
|
|
50
|
+
MButton,
|
|
51
|
+
MSlider,
|
|
52
|
+
MSwitch,
|
|
53
|
+
MCheckbox,
|
|
54
|
+
MRadioGroup,
|
|
55
|
+
MSelect,
|
|
56
|
+
MToast,
|
|
57
|
+
MDialog,
|
|
58
|
+
MTabs,
|
|
59
|
+
MSkeleton,
|
|
60
|
+
MChip,
|
|
61
|
+
MEmptyState,
|
|
62
|
+
MProgress,
|
|
63
|
+
MAccordion,
|
|
64
|
+
MSegmentedControl,
|
|
65
|
+
MAlert,
|
|
66
|
+
MListItem,
|
|
67
|
+
MSeparator,
|
|
68
|
+
MAvatar,
|
|
69
|
+
MBadge,
|
|
70
|
+
MInput,
|
|
71
|
+
MIcon,
|
|
72
|
+
MReveal,
|
|
73
|
+
MSheet,
|
|
74
|
+
}
|
|
75
|
+
export { useMavisTheme, useToast } from '@getcortexlabs/mavis-core/vue'
|
|
20
76
|
export type {
|
|
21
77
|
MavisThemeContext,
|
|
22
78
|
Appearance,
|
|
@@ -26,16 +82,27 @@ export type {
|
|
|
26
82
|
export type { Align, Justify } from './components/layout.js'
|
|
27
83
|
export type {} from '@getcortexlabs/mavis-core/vue'
|
|
28
84
|
|
|
29
|
-
export type
|
|
85
|
+
export type { SystemBackClaimant, ClaimSystemBack }
|
|
86
|
+
|
|
87
|
+
export type MavisOptions = Omit<ThemeContextOptions, 'source'> & {
|
|
88
|
+
toast?: { closeLabel?: string }
|
|
89
|
+
/** Lets a router hand the Android back press to an open sheet first, e.g. vue-router-ns `claimSystemBack`. */
|
|
90
|
+
claimSystemBack?: ClaimSystemBack
|
|
91
|
+
}
|
|
30
92
|
|
|
31
93
|
/** Create one plugin per application; `system` appearance follows the device. Vue also resolves MButton as <m-button>. */
|
|
32
94
|
export function createMavis(options: MavisOptions = {}) {
|
|
33
95
|
return {
|
|
34
96
|
install(app: App) {
|
|
35
|
-
|
|
97
|
+
installAppToast(app, options.toast)
|
|
98
|
+
const { claimSystemBack, toast: _toast, ...theme } = options
|
|
99
|
+
const context = createThemeContext({ ...theme, source: systemAppearance() })
|
|
36
100
|
app.provide(themeKey, context)
|
|
101
|
+
app.provide(systemBackKey, claimSystemBack)
|
|
37
102
|
app.onUnmount(() => context.dispose())
|
|
38
103
|
for (const [name, component] of Object.entries({
|
|
104
|
+
MThemeProvider,
|
|
105
|
+
MSpan,
|
|
39
106
|
MScreen,
|
|
40
107
|
MBox,
|
|
41
108
|
MRow,
|
|
@@ -44,9 +111,28 @@ export function createMavis(options: MavisOptions = {}) {
|
|
|
44
111
|
MText,
|
|
45
112
|
MButton,
|
|
46
113
|
MSlider,
|
|
114
|
+
MSwitch,
|
|
115
|
+
MCheckbox,
|
|
116
|
+
MRadioGroup,
|
|
117
|
+
MSelect,
|
|
118
|
+
MToast,
|
|
119
|
+
MDialog,
|
|
120
|
+
MTabs,
|
|
121
|
+
MSkeleton,
|
|
122
|
+
MChip,
|
|
123
|
+
MEmptyState,
|
|
124
|
+
MProgress,
|
|
125
|
+
MAccordion,
|
|
126
|
+
MSegmentedControl,
|
|
127
|
+
MAlert,
|
|
128
|
+
MListItem,
|
|
129
|
+
MSeparator,
|
|
130
|
+
MAvatar,
|
|
131
|
+
MBadge,
|
|
47
132
|
MInput,
|
|
48
133
|
MIcon,
|
|
49
134
|
MReveal,
|
|
135
|
+
MSheet,
|
|
50
136
|
})) {
|
|
51
137
|
app.component(name, component)
|
|
52
138
|
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import {
|
|
2
|
+
inject,
|
|
3
|
+
provide,
|
|
4
|
+
shallowReactive,
|
|
5
|
+
type Component,
|
|
6
|
+
type InjectionKey,
|
|
7
|
+
type Ref,
|
|
8
|
+
} from 'nativescript-vue'
|
|
9
|
+
|
|
10
|
+
export interface Layer {
|
|
11
|
+
component: Component
|
|
12
|
+
props: Record<string, unknown>
|
|
13
|
+
/** True while the layer covers the screen content. */
|
|
14
|
+
presented: Ref<boolean>
|
|
15
|
+
/** Non-modal notices leave the screen content reachable. */
|
|
16
|
+
modal?: boolean
|
|
17
|
+
}
|
|
18
|
+
export interface LayerEntry extends Layer {
|
|
19
|
+
key: number
|
|
20
|
+
}
|
|
21
|
+
export interface LayerHost {
|
|
22
|
+
add(layer: Layer): () => void
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const layerHost: InjectionKey<LayerHost> = Symbol('mavis.layers')
|
|
26
|
+
|
|
27
|
+
/** A Screen renders registered layers above its content, inside one native cell. */
|
|
28
|
+
export function provideLayerHost(): LayerEntry[] {
|
|
29
|
+
const layers = shallowReactive<LayerEntry[]>([])
|
|
30
|
+
let next = 0
|
|
31
|
+
provide(layerHost, {
|
|
32
|
+
add(layer) {
|
|
33
|
+
const entry = { ...layer, key: next++ }
|
|
34
|
+
layers.push(entry)
|
|
35
|
+
return () => {
|
|
36
|
+
const index = layers.indexOf(entry)
|
|
37
|
+
if (index >= 0) layers.splice(index, 1)
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
})
|
|
41
|
+
return layers
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function useLayerHost(name: string): LayerHost {
|
|
45
|
+
const host = inject(layerHost, undefined)
|
|
46
|
+
if (!host) throw new Error(`${name} needs an MScreen ancestor on NativeScript`)
|
|
47
|
+
return host
|
|
48
|
+
}
|
package/src/vue/props.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { MavisTheme } from '@getcortexlabs/mavis-core'
|
|
1
|
+
import type { Dimension, MavisTheme } from '@getcortexlabs/mavis-core'
|
|
2
2
|
import {
|
|
3
3
|
resolveSpace,
|
|
4
4
|
resolveRadius,
|
|
@@ -8,19 +8,44 @@ import {
|
|
|
8
8
|
import type { BoxProps } from '@getcortexlabs/mavis-core/vue'
|
|
9
9
|
export { boxProps, spacingProp } from '@getcortexlabs/mavis-core/vue'
|
|
10
10
|
|
|
11
|
-
export
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
export interface BoxStyle {
|
|
12
|
+
paddingLeft?: number
|
|
13
|
+
paddingRight?: number
|
|
14
|
+
paddingTop?: number
|
|
15
|
+
paddingBottom?: number
|
|
16
|
+
borderRadius?: number
|
|
17
|
+
flexGrow: number
|
|
18
|
+
flexShrink: number
|
|
19
|
+
minWidth: number
|
|
20
|
+
width?: Dimension
|
|
21
|
+
height?: Dimension
|
|
22
|
+
backgroundColor?: string
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// A prop that was not given leaves its style untouched, so a plain attribute such as
|
|
26
|
+
// `paddingTop` or `borderRadius` on the element survives every render.
|
|
27
|
+
export function boxStyle(theme: MavisTheme, props: BoxProps, defaultShrink = 0): BoxStyle {
|
|
28
|
+
const style: BoxStyle = {
|
|
19
29
|
flexGrow: nonNegative(props.grow, 'grow'),
|
|
20
30
|
flexShrink: nonNegative(props.shrink ?? defaultShrink, 'shrink'),
|
|
21
31
|
minWidth: 0,
|
|
22
|
-
width: resolveDimension(props.width),
|
|
23
|
-
height: resolveDimension(props.height),
|
|
24
|
-
backgroundColor: props.backgroundColor,
|
|
25
32
|
}
|
|
33
|
+
const padding = props.padding === undefined ? undefined : resolveSpace(theme, props.padding)
|
|
34
|
+
const x = props.paddingX === undefined ? padding : resolveSpace(theme, props.paddingX)
|
|
35
|
+
const y = props.paddingY === undefined ? padding : resolveSpace(theme, props.paddingY)
|
|
36
|
+
if (x !== undefined) {
|
|
37
|
+
style.paddingLeft = x
|
|
38
|
+
style.paddingRight = x
|
|
39
|
+
}
|
|
40
|
+
if (y !== undefined) {
|
|
41
|
+
style.paddingTop = y
|
|
42
|
+
style.paddingBottom = y
|
|
43
|
+
}
|
|
44
|
+
if (props.radius !== undefined) style.borderRadius = resolveRadius(theme, props.radius)
|
|
45
|
+
const width = resolveDimension(props.width)
|
|
46
|
+
if (width !== undefined) style.width = width
|
|
47
|
+
const height = resolveDimension(props.height)
|
|
48
|
+
if (height !== undefined) style.height = height
|
|
49
|
+
if (props.backgroundColor !== undefined) style.backgroundColor = props.backgroundColor
|
|
50
|
+
return style
|
|
26
51
|
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { onBeforeUnmount } from 'nativescript-vue'
|
|
2
|
+
import type { View } from '@nativescript/core'
|
|
3
|
+
import { animate, set, onReducedMotion } from '@rafaelaugusto/jolt'
|
|
4
|
+
import { revealMotion } from '@getcortexlabs/mavis-core'
|
|
5
|
+
|
|
6
|
+
type Element = { nativeView: View }
|
|
7
|
+
|
|
8
|
+
/** Each transition owns its completion; an interrupted leave cannot finish a new entry. */
|
|
9
|
+
export function useRevealMotion() {
|
|
10
|
+
const entered = new WeakSet<View>()
|
|
11
|
+
const active = new Map<
|
|
12
|
+
View,
|
|
13
|
+
{ handle: ReturnType<typeof animate>; phase: 'enter' | 'leave'; remove: () => void }
|
|
14
|
+
>()
|
|
15
|
+
const cancel = ({ nativeView: view }: Element) => {
|
|
16
|
+
const operation = active.get(view)
|
|
17
|
+
if (!operation) return
|
|
18
|
+
active.delete(view)
|
|
19
|
+
operation.remove()
|
|
20
|
+
operation.handle.stop()
|
|
21
|
+
}
|
|
22
|
+
const run = (phase: 'enter' | 'leave') => (element: Element, done: () => void) => {
|
|
23
|
+
const view = element.nativeView
|
|
24
|
+
cancel(element)
|
|
25
|
+
if (phase === 'enter' && !entered.has(view)) {
|
|
26
|
+
entered.add(view)
|
|
27
|
+
set(view, { opacity: revealMotion.enter[0].opacity[0], y: revealMotion.enter[0].y[0] })
|
|
28
|
+
}
|
|
29
|
+
const handle = animate(
|
|
30
|
+
view,
|
|
31
|
+
phase === 'enter' ? { opacity: 1, y: 0 } : revealMotion.leave[0],
|
|
32
|
+
revealMotion[phase][1],
|
|
33
|
+
)
|
|
34
|
+
const unloaded = () => cancel(element)
|
|
35
|
+
const operation = { handle, phase, remove: () => view.off('unloaded', unloaded) }
|
|
36
|
+
active.set(view, operation)
|
|
37
|
+
view.on('unloaded', unloaded)
|
|
38
|
+
void handle.finished.then(() => {
|
|
39
|
+
if (active.get(view) !== operation) return
|
|
40
|
+
active.delete(view)
|
|
41
|
+
operation.remove()
|
|
42
|
+
done()
|
|
43
|
+
})
|
|
44
|
+
}
|
|
45
|
+
const offPreference = onReducedMotion((reduced) => {
|
|
46
|
+
if (reduced)
|
|
47
|
+
for (const [view, operation] of active) {
|
|
48
|
+
if (operation.phase === 'enter') set(view, { y: 0 })
|
|
49
|
+
}
|
|
50
|
+
})
|
|
51
|
+
onBeforeUnmount(() => {
|
|
52
|
+
offPreference()
|
|
53
|
+
for (const view of active.keys()) cancel({ nativeView: view })
|
|
54
|
+
})
|
|
55
|
+
return {
|
|
56
|
+
onEnter: run('enter'),
|
|
57
|
+
onLeave: run('leave'),
|
|
58
|
+
onEnterCancelled: cancel,
|
|
59
|
+
onLeaveCancelled: cancel,
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { InjectionKey } from 'nativescript-vue'
|
|
2
|
+
|
|
3
|
+
/** Something other than a page that the Android system back should reach first. */
|
|
4
|
+
export interface SystemBackClaimant {
|
|
5
|
+
/** Whether it wants the next back press or gesture. */
|
|
6
|
+
owns(): boolean
|
|
7
|
+
/** Takes the press. */
|
|
8
|
+
back(): void
|
|
9
|
+
}
|
|
10
|
+
export type ClaimSystemBack = (claimant: SystemBackClaimant) => () => void
|
|
11
|
+
|
|
12
|
+
export const systemBackKey: InjectionKey<ClaimSystemBack | undefined> = Symbol('mavis.systemBack')
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { EventData, View } from '@nativescript/core'
|
|
2
|
+
import { onBeforeUnmount, watch } from 'nativescript-vue'
|
|
3
|
+
import { animate, set, onReducedMotion } from '@rafaelaugusto/jolt'
|
|
4
|
+
import {
|
|
5
|
+
bindMotionSurface,
|
|
6
|
+
type MotionFrames,
|
|
7
|
+
type MotionSurface,
|
|
8
|
+
} from '@getcortexlabs/mavis-core/experimental'
|
|
9
|
+
import { nativeContinuousSurface } from '../native/motion-surface.js'
|
|
10
|
+
|
|
11
|
+
export function useMotionSurface(
|
|
12
|
+
surface: () => MotionSurface | undefined,
|
|
13
|
+
enabled: () => boolean = () => true,
|
|
14
|
+
) {
|
|
15
|
+
let view: View | undefined
|
|
16
|
+
let unbind: (() => void) | undefined
|
|
17
|
+
let offPreference: (() => void) | undefined
|
|
18
|
+
let continuous: ReturnType<typeof nativeContinuousSurface> | undefined
|
|
19
|
+
const active = new Map<ReturnType<typeof animate>, MotionFrames>()
|
|
20
|
+
const release = () => {
|
|
21
|
+
unbind?.()
|
|
22
|
+
unbind = undefined
|
|
23
|
+
continuous = undefined
|
|
24
|
+
offPreference?.()
|
|
25
|
+
offPreference = undefined
|
|
26
|
+
for (const handle of active.keys()) handle.stop()
|
|
27
|
+
active.clear()
|
|
28
|
+
}
|
|
29
|
+
const bind = () => {
|
|
30
|
+
release()
|
|
31
|
+
const target = view
|
|
32
|
+
const reference = surface()
|
|
33
|
+
if (!target || !reference) return
|
|
34
|
+
continuous = nativeContinuousSurface(target, enabled)
|
|
35
|
+
unbind = bindMotionSurface(reference, {
|
|
36
|
+
...continuous.adapter,
|
|
37
|
+
animate(values, options) {
|
|
38
|
+
continuous?.interrupt(Object.keys(values))
|
|
39
|
+
const handle = animate(target, values, options)
|
|
40
|
+
active.set(handle, values)
|
|
41
|
+
void handle.finished.then(() => active.delete(handle))
|
|
42
|
+
return handle
|
|
43
|
+
},
|
|
44
|
+
set: (values) => {
|
|
45
|
+
continuous?.interrupt(Object.keys(values))
|
|
46
|
+
return animate(target, values, { duration: 0 })
|
|
47
|
+
},
|
|
48
|
+
})
|
|
49
|
+
offPreference = onReducedMotion((reduced) => {
|
|
50
|
+
if (!reduced) return
|
|
51
|
+
// Set only spatial channels: opacity can keep its existing timeline.
|
|
52
|
+
const values: Record<string, number> = {}
|
|
53
|
+
for (const frames of active.values())
|
|
54
|
+
for (const [property, value] of Object.entries(frames)) {
|
|
55
|
+
if (property === 'opacity') continue
|
|
56
|
+
const final = Array.isArray(value) ? value.at(-1) : value
|
|
57
|
+
if (typeof final === 'number') values[property] = final
|
|
58
|
+
}
|
|
59
|
+
if (Object.keys(values).length) set(target, values)
|
|
60
|
+
})
|
|
61
|
+
}
|
|
62
|
+
const unloaded = () => {
|
|
63
|
+
release()
|
|
64
|
+
view = undefined
|
|
65
|
+
}
|
|
66
|
+
watch(surface, bind, { flush: 'post' })
|
|
67
|
+
watch(enabled, () => continuous?.refresh(), { flush: 'sync' })
|
|
68
|
+
onBeforeUnmount(unloaded)
|
|
69
|
+
return {
|
|
70
|
+
allowsActivation: () => continuous?.allowsActivation() ?? true,
|
|
71
|
+
onLoaded(event: EventData) {
|
|
72
|
+
view = event.object as View
|
|
73
|
+
bind()
|
|
74
|
+
},
|
|
75
|
+
onUnloaded: unloaded,
|
|
76
|
+
}
|
|
77
|
+
}
|