@getcortexlabs/mavis 0.1.0-alpha.3 → 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.map +1 -1
- package/dist/native/box.ios.js +16 -1
- package/dist/native/box.ios.js.map +1 -1
- package/dist/native/button.ios.d.ts +9 -1
- package/dist/native/button.ios.d.ts.map +1 -1
- package/dist/native/button.ios.js +17 -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 +5 -0
- package/dist/native/flex-layout.ios.d.ts.map +1 -1
- package/dist/native/flex-layout.ios.js +63 -2
- 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.ios.d.ts.map +1 -1
- package/dist/native/keyboard-dismiss.ios.js +3 -0
- package/dist/native/keyboard-dismiss.ios.js.map +1 -1
- 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 +10 -1
- package/dist/native/label.ios.d.ts.map +1 -1
- package/dist/native/label.ios.js +25 -1
- package/dist/native/label.ios.js.map +1 -1
- 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/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 +5 -1
- package/dist/native/sheet.android.d.ts.map +1 -1
- package/dist/native/sheet.android.js +2 -2
- package/dist/native/sheet.android.js.map +1 -1
- package/dist/native/sheet.d.ts +5 -1
- package/dist/native/sheet.d.ts.map +1 -1
- package/dist/native/sheet.ios.d.ts +5 -1
- package/dist/native/sheet.ios.d.ts.map +1 -1
- package/dist/native/sheet.ios.js +12 -3
- package/dist/native/sheet.ios.js.map +1 -1
- package/dist/native/sheet.js +2 -2
- package/dist/native/sheet.js.map +1 -1
- 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 +25 -7
- 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 +63 -8
- 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 +2 -2
- 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 +9 -0
- package/dist/vue/components/MScreen.d.ts.map +1 -1
- package/dist/vue/components/MScreen.js +19 -4
- 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 +10 -4
- package/dist/vue/components/MSheet.d.ts.map +1 -1
- package/dist/vue/components/MSheet.js +66 -34
- package/dist/vue/components/MSheet.js.map +1 -1
- 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 +17 -8
- 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/components/layout.d.ts +6 -6
- package/dist/vue/index.d.ts +24 -3
- package/dist/vue/index.d.ts.map +1 -1
- package/dist/vue/index.js +43 -4
- package/dist/vue/index.js.map +1 -1
- package/dist/vue/layers.d.ts +2 -0
- package/dist/vue/layers.d.ts.map +1 -1
- package/dist/vue/layers.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/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 +3 -1
- package/platforms/android/java/com/mavis/ui/ContentWidth.java +77 -0
- package/platforms/android/java/com/mavis/ui/FlexLayout.java +5 -1
- 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 +21 -1
- package/src/native/button.ios.ts +40 -2
- 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 +74 -2
- package/src/native/input-action.ts +15 -0
- package/src/native/keyboard-dismiss.ios.ts +2 -0
- package/src/native/label.android.ts +27 -0
- package/src/native/label.ios.ts +40 -1
- 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/scroll-motion.ts +101 -0
- package/src/native/segmented.ts +95 -0
- package/src/native/sheet.android.ts +2 -2
- package/src/native/sheet.ios.ts +12 -3
- package/src/native/sheet.ts +2 -2
- 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 +21 -6
- 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 +83 -43
- 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 +65 -2
- package/src/vue/layers.ts +2 -0
- package/src/vue/reveal-motion.ts +61 -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,6 +15,22 @@ 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'
|
|
@@ -18,6 +39,8 @@ import { MSheet } from './components/MSheet.js'
|
|
|
18
39
|
import { systemBackKey, type ClaimSystemBack, type SystemBackClaimant } from './system-back.js'
|
|
19
40
|
|
|
20
41
|
export {
|
|
42
|
+
MThemeProvider,
|
|
43
|
+
MSpan,
|
|
21
44
|
MScreen,
|
|
22
45
|
MBox,
|
|
23
46
|
MRow,
|
|
@@ -26,12 +49,30 @@ export {
|
|
|
26
49
|
MText,
|
|
27
50
|
MButton,
|
|
28
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,
|
|
29
70
|
MInput,
|
|
30
71
|
MIcon,
|
|
31
72
|
MReveal,
|
|
32
73
|
MSheet,
|
|
33
74
|
}
|
|
34
|
-
export { useMavisTheme } from '@getcortexlabs/mavis-core/vue'
|
|
75
|
+
export { useMavisTheme, useToast } from '@getcortexlabs/mavis-core/vue'
|
|
35
76
|
export type {
|
|
36
77
|
MavisThemeContext,
|
|
37
78
|
Appearance,
|
|
@@ -44,6 +85,7 @@ export type {} from '@getcortexlabs/mavis-core/vue'
|
|
|
44
85
|
export type { SystemBackClaimant, ClaimSystemBack }
|
|
45
86
|
|
|
46
87
|
export type MavisOptions = Omit<ThemeContextOptions, 'source'> & {
|
|
88
|
+
toast?: { closeLabel?: string }
|
|
47
89
|
/** Lets a router hand the Android back press to an open sheet first, e.g. vue-router-ns `claimSystemBack`. */
|
|
48
90
|
claimSystemBack?: ClaimSystemBack
|
|
49
91
|
}
|
|
@@ -52,12 +94,15 @@ export type MavisOptions = Omit<ThemeContextOptions, 'source'> & {
|
|
|
52
94
|
export function createMavis(options: MavisOptions = {}) {
|
|
53
95
|
return {
|
|
54
96
|
install(app: App) {
|
|
55
|
-
|
|
97
|
+
installAppToast(app, options.toast)
|
|
98
|
+
const { claimSystemBack, toast: _toast, ...theme } = options
|
|
56
99
|
const context = createThemeContext({ ...theme, source: systemAppearance() })
|
|
57
100
|
app.provide(themeKey, context)
|
|
58
101
|
app.provide(systemBackKey, claimSystemBack)
|
|
59
102
|
app.onUnmount(() => context.dispose())
|
|
60
103
|
for (const [name, component] of Object.entries({
|
|
104
|
+
MThemeProvider,
|
|
105
|
+
MSpan,
|
|
61
106
|
MScreen,
|
|
62
107
|
MBox,
|
|
63
108
|
MRow,
|
|
@@ -66,6 +111,24 @@ export function createMavis(options: MavisOptions = {}) {
|
|
|
66
111
|
MText,
|
|
67
112
|
MButton,
|
|
68
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,
|
|
69
132
|
MInput,
|
|
70
133
|
MIcon,
|
|
71
134
|
MReveal,
|
package/src/vue/layers.ts
CHANGED
|
@@ -12,6 +12,8 @@ export interface Layer {
|
|
|
12
12
|
props: Record<string, unknown>
|
|
13
13
|
/** True while the layer covers the screen content. */
|
|
14
14
|
presented: Ref<boolean>
|
|
15
|
+
/** Non-modal notices leave the screen content reachable. */
|
|
16
|
+
modal?: boolean
|
|
15
17
|
}
|
|
16
18
|
export interface LayerEntry extends Layer {
|
|
17
19
|
key: number
|
|
@@ -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,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
|
+
}
|
package/src/vue/use-press.ts
CHANGED
|
@@ -3,27 +3,35 @@ import { onBeforeUnmount, watch, type Ref } from 'nativescript-vue'
|
|
|
3
3
|
import type { MavisTheme } from '@getcortexlabs/mavis-core'
|
|
4
4
|
import { attachPressFeedback } from '../native/press.js'
|
|
5
5
|
|
|
6
|
-
export function usePressFeedback(
|
|
6
|
+
export function usePressFeedback(
|
|
7
|
+
enabled: () => boolean,
|
|
8
|
+
theme: Readonly<Ref<MavisTheme>>,
|
|
9
|
+
keyboard?: Readonly<Ref<boolean>>,
|
|
10
|
+
) {
|
|
7
11
|
let view: View | undefined
|
|
8
|
-
let remove:
|
|
12
|
+
let remove: ReturnType<typeof attachPressFeedback> | undefined
|
|
9
13
|
|
|
10
14
|
const release = () => {
|
|
11
15
|
remove?.()
|
|
12
16
|
remove = undefined
|
|
13
17
|
}
|
|
14
18
|
const refresh = () => {
|
|
15
|
-
|
|
16
|
-
|
|
19
|
+
if (view && enabled()) {
|
|
20
|
+
if (remove) remove.update(theme.value.motion.pressScale)
|
|
21
|
+
else remove = attachPressFeedback(view, theme.value.motion.pressScale)
|
|
22
|
+
} else release()
|
|
17
23
|
}
|
|
18
24
|
const unloaded = () => {
|
|
19
25
|
release()
|
|
20
26
|
view = undefined
|
|
21
27
|
}
|
|
22
28
|
watch([enabled, () => theme.value.motion.pressScale], refresh, { flush: 'post' })
|
|
29
|
+
if (keyboard) watch(keyboard, (pressed) => remove?.press(pressed), { flush: 'sync' })
|
|
23
30
|
onBeforeUnmount(unloaded)
|
|
24
31
|
|
|
25
32
|
return {
|
|
26
33
|
onLoaded(event: EventData) {
|
|
34
|
+
release()
|
|
27
35
|
view = event.object as View
|
|
28
36
|
refresh()
|
|
29
37
|
},
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { EventData, ScrollView } from '@nativescript/core'
|
|
2
|
+
import { onBeforeUnmount, watch } from 'nativescript-vue'
|
|
3
|
+
import type { MotionScrollSource } from '@getcortexlabs/mavis-core/experimental'
|
|
4
|
+
import { attachNativeScrollSource } from '../native/scroll-motion.js'
|
|
5
|
+
|
|
6
|
+
export function useScrollMotion(source: () => MotionScrollSource | undefined) {
|
|
7
|
+
let view: ScrollView | undefined
|
|
8
|
+
let release: (() => void) | undefined
|
|
9
|
+
const clear = () => {
|
|
10
|
+
release?.()
|
|
11
|
+
release = undefined
|
|
12
|
+
}
|
|
13
|
+
const attach = () => {
|
|
14
|
+
clear()
|
|
15
|
+
const reference = source()
|
|
16
|
+
if (reference && view) release = attachNativeScrollSource(reference, view)
|
|
17
|
+
}
|
|
18
|
+
const unload = () => {
|
|
19
|
+
clear()
|
|
20
|
+
view = undefined
|
|
21
|
+
}
|
|
22
|
+
watch(source, attach, { flush: 'post' })
|
|
23
|
+
onBeforeUnmount(unload)
|
|
24
|
+
return {
|
|
25
|
+
onLoaded(event: EventData) {
|
|
26
|
+
view = event.object as ScrollView
|
|
27
|
+
attach()
|
|
28
|
+
},
|
|
29
|
+
onUnloaded: unload,
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { TextField, TextView } from '@nativescript/core';
|
|
2
|
-
export declare function updateInputDescription(view: TextField | TextView): void;
|
|
3
|
-
export declare function writeInputText(view: TextField | TextView, write: () => void): void;
|
|
4
|
-
//# sourceMappingURL=input-description.android.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"input-description.android.d.ts","sourceRoot":"","sources":["../../src/native/input-description.android.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAE7D,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,SAAS,GAAG,QAAQ,QAMhE;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,SAAS,GAAG,QAAQ,EAAE,KAAK,EAAE,MAAM,IAAI,QAU3E"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export function updateInputDescription(view) {
|
|
2
|
-
// Core appends `text` to explicit labels, including secure text. EditText
|
|
3
|
-
// already exposes its current value (or password masking) to the platform.
|
|
4
|
-
view.android?.setContentDescription([view.accessibilityLabel, view.accessibilityHint].filter(Boolean).join('. ') || null);
|
|
5
|
-
}
|
|
6
|
-
export function writeInputText(view, write) {
|
|
7
|
-
const filters = view.android.getFilters();
|
|
8
|
-
// InputFilters also affect setText(). An external model must remain intact;
|
|
9
|
-
// restore the user's editing limit immediately after the programmatic write.
|
|
10
|
-
view.android.setFilters([]);
|
|
11
|
-
try {
|
|
12
|
-
write();
|
|
13
|
-
}
|
|
14
|
-
finally {
|
|
15
|
-
view.android.setFilters(filters);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
//# sourceMappingURL=input-description.android.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"input-description.android.js","sourceRoot":"","sources":["../../src/native/input-description.android.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,sBAAsB,CAAC,IAA0B;IAC/D,0EAA0E;IAC1E,2EAA2E;IAC3E,IAAI,CAAC,OAAO,EAAE,qBAAqB,CACjC,CAAC,IAAI,CAAC,kBAAkB,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CACrF,CAAA;AACH,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,IAA0B,EAAE,KAAiB;IAC1E,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAA;IACzC,4EAA4E;IAC5E,6EAA6E;IAC7E,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC,CAAA;IAC3B,IAAI,CAAC;QACH,KAAK,EAAE,CAAA;IACT,CAAC;YAAS,CAAC;QACT,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,CAAA;IAClC,CAAC;AACH,CAAC"}
|
package/dist/theme/resolve.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../src/theme/resolve.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAErD,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM,CAMtE"}
|
package/dist/theme/resolve.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export function resolveSpace(theme, value) {
|
|
2
|
-
const resolved = typeof value === 'number' ? value : theme.space[value];
|
|
3
|
-
if (!Number.isFinite(resolved) || resolved < 0) {
|
|
4
|
-
throw new RangeError(`Unknown or invalid spacing: ${String(value)}`);
|
|
5
|
-
}
|
|
6
|
-
return resolved;
|
|
7
|
-
}
|
|
8
|
-
//# sourceMappingURL=resolve.js.map
|