@getcortexlabs/mavis 0.1.0-rc.14 → 0.1.0-rc.16
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/components/bindings.d.ts +14 -0
- package/dist/components/bindings.d.ts.map +1 -0
- package/dist/components/bindings.js +21 -0
- package/dist/components/bindings.js.map +1 -0
- package/dist/components/contracts.d.ts +28 -0
- package/dist/components/contracts.d.ts.map +1 -0
- package/dist/components/contracts.js +27 -0
- package/dist/components/contracts.js.map +1 -0
- package/dist/components/controller.d.ts +56 -0
- package/dist/components/controller.d.ts.map +1 -0
- package/dist/components/controller.js +508 -0
- package/dist/components/controller.js.map +1 -0
- package/dist/components/index.d.ts +53 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +95 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/style.d.ts +52 -0
- package/dist/components/style.d.ts.map +1 -0
- package/dist/components/style.js +68 -0
- package/dist/components/style.js.map +1 -0
- package/dist/components/theme.d.ts +12 -0
- package/dist/components/theme.d.ts.map +1 -0
- package/dist/components/theme.js +29 -0
- package/dist/components/theme.js.map +1 -0
- package/dist/native/box.ios.d.ts +1 -0
- package/dist/native/box.ios.d.ts.map +1 -1
- package/dist/native/box.ios.js +21 -1
- package/dist/native/box.ios.js.map +1 -1
- package/dist/native/collection-motion.d.ts.map +1 -1
- package/dist/native/collection-motion.js +7 -4
- package/dist/native/collection-motion.js.map +1 -1
- package/dist/native/motion-binding.d.ts +11 -0
- package/dist/native/motion-binding.d.ts.map +1 -0
- package/dist/native/motion-binding.js +132 -0
- package/dist/native/motion-binding.js.map +1 -0
- package/dist/native/motion-surface.d.ts +1 -1
- package/dist/native/motion-surface.d.ts.map +1 -1
- package/dist/native/motion-surface.js +20 -5
- package/dist/native/motion-surface.js.map +1 -1
- package/dist/native/navigation.d.ts +4 -0
- package/dist/native/navigation.d.ts.map +1 -0
- package/dist/native/navigation.js +16 -0
- package/dist/native/navigation.js.map +1 -0
- package/dist/native/pointer-availability.d.ts +7 -0
- package/dist/native/pointer-availability.d.ts.map +1 -0
- package/dist/native/pointer-availability.js +43 -0
- package/dist/native/pointer-availability.js.map +1 -0
- package/dist/native/scroll-motion.d.ts +1 -1
- package/dist/native/section-scroll.d.ts +1 -1
- package/dist/native/sheet.android.d.ts +2 -0
- package/dist/native/sheet.android.d.ts.map +1 -1
- package/dist/native/sheet.android.js +18 -0
- package/dist/native/sheet.android.js.map +1 -1
- package/dist/native/sheet.d.ts +1 -0
- package/dist/native/sheet.d.ts.map +1 -1
- package/dist/native/sheet.ios.d.ts +1 -0
- package/dist/native/sheet.ios.d.ts.map +1 -1
- package/dist/native/sheet.ios.js +1 -0
- package/dist/native/sheet.ios.js.map +1 -1
- package/dist/native/sheet.js +1 -0
- package/dist/native/sheet.js.map +1 -1
- package/dist/native/visual-effects.d.ts.map +1 -1
- package/dist/native/visual-effects.js +7 -1
- package/dist/native/visual-effects.js.map +1 -1
- package/dist/vue/components/ChoiceControl.d.ts +3 -3
- package/dist/vue/components/DateCalendar.d.ts +1 -1
- package/dist/vue/components/LoadingDecoration.d.ts +5 -5
- package/dist/vue/components/MAccordion.d.ts +3 -3
- package/dist/vue/components/MAlert.d.ts +4 -4
- package/dist/vue/components/MAvatar.d.ts +4 -4
- package/dist/vue/components/MBadge.d.ts +3 -3
- package/dist/vue/components/MButton.d.ts +20 -20
- package/dist/vue/components/MCard.d.ts +11 -11
- package/dist/vue/components/MCheckbox.d.ts +3 -3
- package/dist/vue/components/MChip.d.ts +4 -4
- package/dist/vue/components/MCombobox.d.ts +5 -5
- package/dist/vue/components/MDatePicker.d.ts +104 -104
- package/dist/vue/components/MDatePicker.d.ts.map +1 -1
- package/dist/vue/components/MDialog.d.ts +3 -3
- package/dist/vue/components/MEmptyState.d.ts +3 -3
- package/dist/vue/components/MFilePicker.d.ts +1 -1
- package/dist/vue/components/MGrid.d.ts +7 -7
- package/dist/vue/components/MGrid.d.ts.map +1 -1
- package/dist/vue/components/MGrid.js +5 -1
- package/dist/vue/components/MGrid.js.map +1 -1
- package/dist/vue/components/MIcon.d.ts +2 -2
- package/dist/vue/components/MImage.d.ts +7 -7
- package/dist/vue/components/MImageCompare.d.ts +1 -1
- package/dist/vue/components/MImageViewer.d.ts.map +1 -1
- package/dist/vue/components/MImageViewer.js +11 -2
- package/dist/vue/components/MImageViewer.js.map +1 -1
- package/dist/vue/components/MInput.d.ts +20 -20
- package/dist/vue/components/MLink.d.ts +5 -5
- package/dist/vue/components/MListItem.d.ts +5 -5
- package/dist/vue/components/MPinInput.d.ts +1 -1
- package/dist/vue/components/MPopover.d.ts +3 -3
- package/dist/vue/components/MProgress.d.ts +5 -5
- package/dist/vue/components/MRadioGroup.d.ts +3 -3
- package/dist/vue/components/MRangeSlider.d.ts +3 -3
- package/dist/vue/components/MResizablePanels.d.ts +3 -3
- package/dist/vue/components/MReveal.d.ts +17 -17
- package/dist/vue/components/MScreen.d.ts +3 -3
- package/dist/vue/components/MScreen.d.ts.map +1 -1
- package/dist/vue/components/MScreen.js +11 -1
- package/dist/vue/components/MScreen.js.map +1 -1
- package/dist/vue/components/MSegmentedControl.d.ts +3 -3
- package/dist/vue/components/MSelect.d.ts +4 -4
- package/dist/vue/components/MSheet.d.ts +7 -7
- package/dist/vue/components/MSheet.d.ts.map +1 -1
- package/dist/vue/components/MSheet.js +66 -10
- package/dist/vue/components/MSheet.js.map +1 -1
- package/dist/vue/components/MSkeleton.d.ts +3 -3
- package/dist/vue/components/MSlider.d.ts +2 -2
- package/dist/vue/components/MStack.d.ts +19 -19
- package/dist/vue/components/MStack.d.ts.map +1 -1
- package/dist/vue/components/MStack.js +12 -2
- package/dist/vue/components/MStack.js.map +1 -1
- package/dist/vue/components/MSwitch.d.ts +3 -3
- package/dist/vue/components/MTabs.d.ts +3 -3
- package/dist/vue/components/MText.d.ts +8 -8
- package/dist/vue/components/MText.d.ts.map +1 -1
- package/dist/vue/components/MText.js +4 -1
- package/dist/vue/components/MText.js.map +1 -1
- package/dist/vue/components/MTimePicker.d.ts +40 -40
- package/dist/vue/components/MTimePicker.d.ts.map +1 -1
- package/dist/vue/components/MTooltip.d.ts +2 -2
- package/dist/vue/components/advanced.d.ts +34 -34
- package/dist/vue/components/configurator.d.ts +36 -36
- package/dist/vue/components/creative.d.ts +21 -21
- package/dist/vue/components/dashboard.d.ts +13 -13
- package/dist/vue/components/dashboard.d.ts.map +1 -1
- package/dist/vue/components/dashboard.js +21 -6
- package/dist/vue/components/dashboard.js.map +1 -1
- package/dist/vue/components/discovery.d.ts +11 -11
- package/dist/vue/components/interactive.d.ts +6 -6
- package/dist/vue/components/layout.d.ts +45 -45
- package/dist/vue/components/layout.d.ts.map +1 -1
- package/dist/vue/components/layout.js +8 -2
- package/dist/vue/components/layout.js.map +1 -1
- package/dist/vue/components/navigation.d.ts +4 -4
- package/dist/vue/components/screen-components.d.ts +192 -21
- package/dist/vue/components/screen-components.d.ts.map +1 -1
- package/dist/vue/components/screen-components.js +18 -1
- package/dist/vue/components/screen-components.js.map +1 -1
- package/dist/vue/components/wayfinding.d.ts +10 -10
- package/dist/vue/components/workflows.d.ts +3 -3
- package/dist/vue/index.d.ts +3 -3
- package/dist/vue/index.d.ts.map +1 -1
- package/dist/vue/index.js +5 -2
- package/dist/vue/index.js.map +1 -1
- package/dist/vue/layout-context.d.ts +4 -0
- package/dist/vue/layout-context.d.ts.map +1 -0
- package/dist/vue/layout-context.js +3 -0
- package/dist/vue/layout-context.js.map +1 -0
- package/dist/vue/navigation.d.ts +1 -3
- package/dist/vue/navigation.d.ts.map +1 -1
- package/dist/vue/navigation.js +1 -15
- package/dist/vue/navigation.js.map +1 -1
- package/dist/vue/screen-overlay.d.ts +9 -0
- package/dist/vue/screen-overlay.d.ts.map +1 -0
- package/dist/vue/screen-overlay.js +17 -0
- package/dist/vue/screen-overlay.js.map +1 -0
- package/dist/vue/use-motion-surface.d.ts +2 -3
- package/dist/vue/use-motion-surface.d.ts.map +1 -1
- package/dist/vue/use-motion-surface.js +9 -128
- package/dist/vue/use-motion-surface.js.map +1 -1
- package/package.json +8 -4
- package/platforms/android/java/com/mavis/ui/Box.java +31 -0
- package/src/components/bindings.ts +32 -0
- package/src/components/contracts.ts +60 -0
- package/src/components/controller.ts +542 -0
- package/src/components/index.ts +136 -0
- package/src/components/style.ts +84 -0
- package/src/components/theme.ts +25 -0
- package/src/native/box.ios.ts +31 -1
- package/src/native/collection-motion.ts +6 -4
- package/src/native/motion-binding.ts +143 -0
- package/src/native/motion-surface.ts +19 -5
- package/src/native/navigation.ts +15 -0
- package/src/native/pointer-availability.ts +44 -0
- package/src/native/sheet.android.ts +19 -0
- package/src/native/sheet.ios.ts +2 -0
- package/src/native/sheet.ts +2 -0
- package/src/native/visual-effects.ts +6 -2
- package/src/vue/components/MGrid.ts +10 -1
- package/src/vue/components/MImageViewer.ts +10 -2
- package/src/vue/components/MScreen.ts +12 -1
- package/src/vue/components/MSheet.ts +89 -19
- package/src/vue/components/MStack.ts +17 -2
- package/src/vue/components/MText.ts +4 -1
- package/src/vue/components/dashboard.ts +23 -5
- package/src/vue/components/layout.ts +8 -0
- package/src/vue/components/screen-components.ts +20 -0
- package/src/vue/index.ts +10 -0
- package/src/vue/layout-context.ts +4 -0
- package/src/vue/navigation.ts +1 -15
- package/src/vue/screen-overlay.ts +20 -0
- package/src/vue/use-motion-surface.ts +10 -133
|
@@ -1,5 +1,10 @@
|
|
|
1
|
+
import { onKeyboard } from '@rafaelaugusto/jolt'
|
|
1
2
|
import { computed } from 'nativescript-vue'
|
|
2
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
keyboardViewportOwner,
|
|
5
|
+
useButtonAction,
|
|
6
|
+
useCachedActivity,
|
|
7
|
+
} from '@getcortexlabs/mavis-core/vue'
|
|
3
8
|
import {
|
|
4
9
|
defineComponent,
|
|
5
10
|
getCurrentInstance,
|
|
@@ -25,14 +30,20 @@ import {
|
|
|
25
30
|
type MavisThemeContext,
|
|
26
31
|
} from '@getcortexlabs/mavis-core/vue'
|
|
27
32
|
import { checkSheetName, type SheetName, type SheetCloseReason } from '@getcortexlabs/mavis-core'
|
|
28
|
-
import { isAndroid, type EventData, type ScrollView, type View } from '@nativescript/core'
|
|
33
|
+
import { isAndroid, Utils, type EventData, type ScrollView, type View } from '@nativescript/core'
|
|
29
34
|
import { MRow, MColumn, MBox } from './layout.js'
|
|
30
35
|
import { MText } from './MText.js'
|
|
31
36
|
import { MButton } from './MButton.js'
|
|
32
37
|
import { useLayerHost } from '../layers.js'
|
|
33
38
|
import { nativeViewOf } from '../native-view.js'
|
|
34
39
|
import { systemBackKey } from '../system-back.js'
|
|
35
|
-
import {
|
|
40
|
+
import {
|
|
41
|
+
watchBack,
|
|
42
|
+
setModal,
|
|
43
|
+
safeAreaOf,
|
|
44
|
+
contentInsets,
|
|
45
|
+
revealSheetFocus,
|
|
46
|
+
} from '../../native/sheet'
|
|
36
47
|
import { notifyAccessibilityLayout } from '../../native/accessibility-layout'
|
|
37
48
|
|
|
38
49
|
registerElement('MavisSheetPanel', () => GestureSurface, { viewFlags: 4 })
|
|
@@ -84,6 +95,7 @@ const SheetLayer = defineComponent({
|
|
|
84
95
|
useButtonAction()
|
|
85
96
|
const bridge = props.bridge
|
|
86
97
|
bridgeProvides(bridge.provides)
|
|
98
|
+
provide(keyboardViewportOwner, () => true)
|
|
87
99
|
const { theme } = bridge.context
|
|
88
100
|
const claimSystemBack = inject(systemBackKey, undefined)
|
|
89
101
|
const panel = shallowRef<Element<GestureSurface>>()
|
|
@@ -92,16 +104,31 @@ const SheetLayer = defineComponent({
|
|
|
92
104
|
const backdrop = shallowRef<Element>()
|
|
93
105
|
// The surface covers the window edges; content clears the home indicator and landscape notch.
|
|
94
106
|
const insets = ref({ left: 0, right: 0, bottom: 0 })
|
|
107
|
+
const compactEditor = ref(false)
|
|
95
108
|
let title: View | undefined
|
|
96
109
|
let sheet: BottomSheet | undefined
|
|
97
110
|
let pending: SheetCloseReason | undefined
|
|
98
111
|
let requested = false
|
|
99
112
|
let releaseBack = () => {}
|
|
100
113
|
let releaseClaim = () => {}
|
|
114
|
+
let releaseKeyboard = () => {}
|
|
115
|
+
let keyboardHeight = 0
|
|
116
|
+
let keyboardDuration = 0
|
|
117
|
+
let revealTimer: ReturnType<typeof setTimeout> | undefined
|
|
101
118
|
|
|
102
119
|
function updateInsets() {
|
|
103
120
|
const host = nativeViewOf(panel.value)?.parent as View | undefined
|
|
104
121
|
if (!host) return
|
|
122
|
+
if (isAndroid && host.android) {
|
|
123
|
+
const windowHeight = Utils.layout.toDeviceIndependentPixels(
|
|
124
|
+
host.android.getRootView().getHeight(),
|
|
125
|
+
)
|
|
126
|
+
const available = windowHeight - keyboardHeight - (host.getLocationInWindow()?.y ?? 0)
|
|
127
|
+
// In a short IME viewport the fixed handle, heading and padding can
|
|
128
|
+
// consume the entire scroll region. Let the heading scroll with the form.
|
|
129
|
+
const compact = keyboardHeight > 0 && available < 160
|
|
130
|
+
compactEditor.value = compact
|
|
131
|
+
}
|
|
105
132
|
const next = contentInsets(host)
|
|
106
133
|
const current = insets.value
|
|
107
134
|
if (
|
|
@@ -112,7 +139,23 @@ const SheetLayer = defineComponent({
|
|
|
112
139
|
insets.value = next
|
|
113
140
|
}
|
|
114
141
|
|
|
142
|
+
function revealCompactEditor() {
|
|
143
|
+
const viewport = nativeViewOf(scroll.value)
|
|
144
|
+
if (compactEditor.value && viewport) revealSheetFocus(viewport)
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function queueFocusReveal() {
|
|
148
|
+
clearTimeout(revealTimer)
|
|
149
|
+
// Jolt and Android finish their automatic scroll during the IME transition.
|
|
150
|
+
if (compactEditor.value) revealTimer = setTimeout(revealCompactEditor, keyboardDuration)
|
|
151
|
+
}
|
|
152
|
+
|
|
115
153
|
function dispose() {
|
|
154
|
+
clearTimeout(revealTimer)
|
|
155
|
+
releaseKeyboard()
|
|
156
|
+
releaseKeyboard = () => {}
|
|
157
|
+
keyboardHeight = 0
|
|
158
|
+
compactEditor.value = false
|
|
116
159
|
releaseBack()
|
|
117
160
|
releaseClaim()
|
|
118
161
|
releaseBack = releaseClaim = () => {}
|
|
@@ -172,6 +215,14 @@ const SheetLayer = defineComponent({
|
|
|
172
215
|
},
|
|
173
216
|
onDismiss: () => bridge.settled(),
|
|
174
217
|
})
|
|
218
|
+
if (isAndroid) {
|
|
219
|
+
releaseKeyboard = onKeyboard((keyboard) => {
|
|
220
|
+
keyboardHeight = keyboard.height
|
|
221
|
+
if (keyboard.duration > 0) keyboardDuration = keyboard.duration
|
|
222
|
+
updateInsets()
|
|
223
|
+
queueFocusReveal()
|
|
224
|
+
})
|
|
225
|
+
}
|
|
175
226
|
sheet.open()
|
|
176
227
|
}
|
|
177
228
|
|
|
@@ -208,11 +259,21 @@ const SheetLayer = defineComponent({
|
|
|
208
259
|
const { colors, radius } = theme.value
|
|
209
260
|
const name = checkSheetName(state.title, state.accessibilityLabel)
|
|
210
261
|
const heading = state.title?.trim()
|
|
211
|
-
const header =
|
|
262
|
+
const header = (inScroll = false) =>
|
|
212
263
|
heading || state.dismissible
|
|
213
264
|
? h(
|
|
214
265
|
MRow,
|
|
215
|
-
{
|
|
266
|
+
{
|
|
267
|
+
row: 1,
|
|
268
|
+
visibility: inScroll === compactEditor.value ? 'visible' : 'collapse',
|
|
269
|
+
// Android clears editor focus if its ScrollView reaches zero height
|
|
270
|
+
// during IME layout, before Vue can move the heading into the scroller.
|
|
271
|
+
maxHeight: isAndroid && !inScroll ? '50%' : undefined,
|
|
272
|
+
paddingX: 'lg',
|
|
273
|
+
paddingY: 'sm',
|
|
274
|
+
gap: 'sm',
|
|
275
|
+
justify: 'between',
|
|
276
|
+
},
|
|
216
277
|
{
|
|
217
278
|
default: () => [
|
|
218
279
|
heading
|
|
@@ -222,7 +283,7 @@ const SheetLayer = defineComponent({
|
|
|
222
283
|
grow: 1,
|
|
223
284
|
text: heading,
|
|
224
285
|
onLoaded: (event: EventData) => {
|
|
225
|
-
title = event.object as View
|
|
286
|
+
if (!inScroll) title = event.object as View
|
|
226
287
|
},
|
|
227
288
|
})
|
|
228
289
|
: h(MBox, { grow: 1 }),
|
|
@@ -268,24 +329,33 @@ const SheetLayer = defineComponent({
|
|
|
268
329
|
},
|
|
269
330
|
[
|
|
270
331
|
h('GridLayout', { rows: 'auto,auto,*' }, [
|
|
271
|
-
h(
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
332
|
+
h(
|
|
333
|
+
'GridLayout',
|
|
334
|
+
{
|
|
335
|
+
ref: handle,
|
|
336
|
+
accessibilityLabel: name,
|
|
337
|
+
row: 0,
|
|
338
|
+
height: compactEditor.value ? 0 : 24,
|
|
339
|
+
},
|
|
340
|
+
[
|
|
341
|
+
h('MavisBox', {
|
|
342
|
+
width: 36,
|
|
343
|
+
height: 5,
|
|
344
|
+
borderRadius: 3,
|
|
345
|
+
backgroundColor: colors.border,
|
|
346
|
+
horizontalAlignment: 'center',
|
|
347
|
+
verticalAlignment: 'middle',
|
|
348
|
+
}),
|
|
349
|
+
],
|
|
350
|
+
),
|
|
351
|
+
header(),
|
|
282
352
|
// Reserve the handle/header before measuring the viewport. A flex child's
|
|
283
353
|
// initial measurement can otherwise retain the full panel height on Android.
|
|
284
|
-
h('ScrollView', { ref: scroll, row: 2 }, [
|
|
354
|
+
h('ScrollView', { ref: scroll, row: 2, onLayoutChanged: queueFocusReveal }, [
|
|
285
355
|
h(
|
|
286
356
|
MColumn,
|
|
287
357
|
{ padding: state.padding, gap: state.gap, align: state.align },
|
|
288
|
-
{ default: () => bridge.content() },
|
|
358
|
+
{ default: () => [bridge.content(), isAndroid ? header(true) : null] },
|
|
289
359
|
),
|
|
290
360
|
]),
|
|
291
361
|
]),
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
import { boxStyle } from '../props.js'
|
|
13
13
|
import { useNativeViewAttrs } from '../accessibility.js'
|
|
14
14
|
import './layout.js'
|
|
15
|
+
import { useOverlayLayout } from '../screen-overlay.js'
|
|
15
16
|
|
|
16
17
|
const align = {
|
|
17
18
|
start: 'flex-start',
|
|
@@ -32,6 +33,7 @@ export const MStack = defineComponent({
|
|
|
32
33
|
inheritAttrs: false,
|
|
33
34
|
props: stackProps,
|
|
34
35
|
setup(props, { attrs, slots }) {
|
|
36
|
+
const overlay = useOverlayLayout()
|
|
35
37
|
const { theme } = useMavisTheme()
|
|
36
38
|
const nativeAttrs = useNativeViewAttrs(props)
|
|
37
39
|
const shrink = useLayoutShrink()
|
|
@@ -55,25 +57,38 @@ export const MStack = defineComponent({
|
|
|
55
57
|
provide(layoutDirection, direction)
|
|
56
58
|
const measure = (event: EventData) => {
|
|
57
59
|
const view = event.object as View
|
|
58
|
-
const size = view.getActualSize()
|
|
60
|
+
const size = view.getActualSize()?.width ?? 0
|
|
59
61
|
// The inner layout occupies the outer Box's content area, after padding.
|
|
60
62
|
if (size > 0 && size !== width.value) width.value = size
|
|
61
63
|
}
|
|
62
64
|
return () =>
|
|
63
65
|
h(
|
|
64
66
|
'MavisBox',
|
|
65
|
-
mergeProps(
|
|
67
|
+
mergeProps(
|
|
68
|
+
overlay(attrs),
|
|
69
|
+
{ style: boxStyle(theme.value, props, shrink.value) },
|
|
70
|
+
nativeAttrs(),
|
|
71
|
+
attrs,
|
|
72
|
+
),
|
|
66
73
|
[
|
|
67
74
|
h(
|
|
68
75
|
'MavisFlexLayout',
|
|
69
76
|
{
|
|
77
|
+
...overlay({}),
|
|
70
78
|
...motion,
|
|
79
|
+
onLoaded: (event: EventData) => {
|
|
80
|
+
motion.onLoaded(event)
|
|
81
|
+
measure(event)
|
|
82
|
+
},
|
|
71
83
|
onLayoutChanged: measure,
|
|
72
84
|
onUnloaded: () => {
|
|
73
85
|
motion.onUnloaded()
|
|
74
86
|
width.value = undefined
|
|
75
87
|
},
|
|
76
88
|
style: {
|
|
89
|
+
// Flex growth/shrink needs an exact content width on native;
|
|
90
|
+
// a GridLayout's loose offer otherwise retains oversized columns.
|
|
91
|
+
width: '100%',
|
|
77
92
|
flexDirection: direction.value,
|
|
78
93
|
alignItems: align[layout.value.align ?? props.align],
|
|
79
94
|
justifyContent: justify[layout.value.justify ?? props.justify],
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent, h, mergeProps, registerElement } from 'nativescript-vue'
|
|
1
|
+
import { defineComponent, h, inject, mergeProps, registerElement } from 'nativescript-vue'
|
|
2
2
|
import {
|
|
3
3
|
textProps,
|
|
4
4
|
useMavisTheme,
|
|
@@ -10,6 +10,7 @@ import { isAndroid } from '@nativescript/core'
|
|
|
10
10
|
import { MavisLabel } from '../../native/label'
|
|
11
11
|
import { useNativeViewAttrs } from '../accessibility.js'
|
|
12
12
|
import { useMotionSurface } from '../use-motion-surface.js'
|
|
13
|
+
import { boxLayer } from '../layout-context.js'
|
|
13
14
|
|
|
14
15
|
registerElement('MavisLabel', () => MavisLabel)
|
|
15
16
|
|
|
@@ -18,6 +19,7 @@ export const MText = defineComponent({
|
|
|
18
19
|
inheritAttrs: false,
|
|
19
20
|
props: textProps,
|
|
20
21
|
setup(props, { attrs, slots }) {
|
|
22
|
+
const layered = inject(boxLayer, false)
|
|
21
23
|
const { theme } = useMavisTheme()
|
|
22
24
|
const nativeAttrs = useNativeViewAttrs(props)
|
|
23
25
|
const shrink = useLayoutShrink()
|
|
@@ -44,6 +46,7 @@ export const MText = defineComponent({
|
|
|
44
46
|
accessible: true,
|
|
45
47
|
accessibilityRole: /^h[1-6]$/.test(props.as) ? 'header' : 'text',
|
|
46
48
|
style: {
|
|
49
|
+
...(layered ? { verticalAlignment: 'top' } : {}),
|
|
47
50
|
...type,
|
|
48
51
|
fontFamily: fontFamily(type.fontFamily, isAndroid ? 'android' : 'ios'),
|
|
49
52
|
fontWeight: props.weight ? validateWeight(props.weight) : type.fontWeight,
|
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
kanbanRegistryKey,
|
|
32
32
|
kanbanZoneProps,
|
|
33
33
|
kanbanDragProps,
|
|
34
|
+
useLayoutShrink,
|
|
34
35
|
type KanbanRegistry,
|
|
35
36
|
} from '@getcortexlabs/mavis-core/vue'
|
|
36
37
|
import { createMotionSurface } from '@getcortexlabs/mavis-core/experimental'
|
|
@@ -118,6 +119,7 @@ const Zone = defineComponent({
|
|
|
118
119
|
inheritAttrs: false,
|
|
119
120
|
props: kanbanZoneProps,
|
|
120
121
|
setup(props, { attrs, slots }) {
|
|
122
|
+
const shrink = useLayoutShrink()
|
|
121
123
|
const registry = inject(kanbanRegistryKey)! as KanbanRegistry<View>
|
|
122
124
|
const leave = () => {
|
|
123
125
|
if (registry.zones.delete(props.column)) registry.revision.value++
|
|
@@ -127,7 +129,10 @@ const Zone = defineComponent({
|
|
|
127
129
|
h(
|
|
128
130
|
'GridLayout',
|
|
129
131
|
mergeProps(attrs, {
|
|
130
|
-
|
|
132
|
+
// Match the Web's equal zero-basis columns only in the horizontal stack.
|
|
133
|
+
width: shrink.value ? 0 : 'auto',
|
|
134
|
+
flexShrink: shrink.value,
|
|
135
|
+
style: { zIndex: props.raised ? 20 : 0 },
|
|
131
136
|
onLoaded: (e: EventData) => {
|
|
132
137
|
registry.zones.set(props.column, e.object as View)
|
|
133
138
|
registry.revision.value++
|
|
@@ -171,11 +176,17 @@ const Drag = defineComponent({
|
|
|
171
176
|
else surface.set({ x: 0, y: 0, scale: 1 })
|
|
172
177
|
}
|
|
173
178
|
function cancel() {
|
|
179
|
+
end(true)
|
|
180
|
+
}
|
|
181
|
+
function cancelImmediately() {
|
|
182
|
+
end(false)
|
|
183
|
+
}
|
|
184
|
+
function end(animated: boolean) {
|
|
174
185
|
const was = live
|
|
175
186
|
settle()
|
|
176
187
|
zones?.cancel()
|
|
177
188
|
if (!was) return
|
|
178
|
-
rest(
|
|
189
|
+
rest(animated)
|
|
179
190
|
registry.finish(props.cardId)
|
|
180
191
|
}
|
|
181
192
|
function release() {
|
|
@@ -238,7 +249,7 @@ const Drag = defineComponent({
|
|
|
238
249
|
})
|
|
239
250
|
}
|
|
240
251
|
function unload() {
|
|
241
|
-
|
|
252
|
+
cancelImmediately()
|
|
242
253
|
release()
|
|
243
254
|
}
|
|
244
255
|
onBeforeUnmount(() => {
|
|
@@ -247,8 +258,15 @@ const Drag = defineComponent({
|
|
|
247
258
|
registry.cards.delete(props.cardId)
|
|
248
259
|
registry.focus.delete(props.cardId)
|
|
249
260
|
})
|
|
250
|
-
onDeactivated(
|
|
251
|
-
onScopeDispose(
|
|
261
|
+
onDeactivated(cancelImmediately)
|
|
262
|
+
onScopeDispose(
|
|
263
|
+
surface.use(() => {
|
|
264
|
+
// A retained native view can reconnect after its return animation was
|
|
265
|
+
// stopped by unload. Start each presentation at the controlled position.
|
|
266
|
+
rest(false)
|
|
267
|
+
return cancelImmediately
|
|
268
|
+
}),
|
|
269
|
+
)
|
|
252
270
|
watch(() => [registry.revision.value, props.disabled], schedule)
|
|
253
271
|
// A plain GridLayout would take the column's whole height on iOS; a box keeps the card's own.
|
|
254
272
|
return () =>
|
|
@@ -16,6 +16,8 @@ import { useNativeViewAttrs } from '../accessibility.js'
|
|
|
16
16
|
import { useMotionRegion } from '../use-motion-region.js'
|
|
17
17
|
import { useMotionSurface } from '../use-motion-surface.js'
|
|
18
18
|
import { perspectiveKey } from '../perspective.js'
|
|
19
|
+
import { useOverlayLayout } from '../screen-overlay.js'
|
|
20
|
+
import { boxLayer } from '../layout-context.js'
|
|
19
21
|
|
|
20
22
|
export type { Align, Justify } from '@getcortexlabs/mavis-core/vue'
|
|
21
23
|
|
|
@@ -45,6 +47,8 @@ function createLayout(name: string, direction: 'row' | 'column') {
|
|
|
45
47
|
inheritAttrs: false,
|
|
46
48
|
props: direction === 'row' ? rowProps : columnProps,
|
|
47
49
|
setup(props, { attrs, slots }) {
|
|
50
|
+
const overlay = useOverlayLayout()
|
|
51
|
+
provide(boxLayer, false)
|
|
48
52
|
const region = useMotionRegion(() => props.motionRegion)
|
|
49
53
|
const { theme } = useMavisTheme()
|
|
50
54
|
const nativeAttrs = useNativeViewAttrs(props)
|
|
@@ -54,6 +58,7 @@ function createLayout(name: string, direction: 'row' | 'column') {
|
|
|
54
58
|
h(
|
|
55
59
|
'MavisFlexLayout',
|
|
56
60
|
mergeProps(
|
|
61
|
+
overlay(attrs),
|
|
57
62
|
{
|
|
58
63
|
style: {
|
|
59
64
|
...boxStyle(theme.value, props, shrink.value),
|
|
@@ -83,6 +88,8 @@ export const MBox = defineComponent({
|
|
|
83
88
|
inheritAttrs: false,
|
|
84
89
|
props: motionBoxProps,
|
|
85
90
|
setup(props, { attrs, slots }) {
|
|
91
|
+
const overlay = useOverlayLayout()
|
|
92
|
+
provide(boxLayer, true)
|
|
86
93
|
const region = useMotionRegion(() => props.motionRegion)
|
|
87
94
|
const surface = useMotionSurface(() => props.motionSurface)
|
|
88
95
|
provide(perspectiveKey, () => resolvePerspective(props.perspective))
|
|
@@ -93,6 +100,7 @@ export const MBox = defineComponent({
|
|
|
93
100
|
h(
|
|
94
101
|
'MavisBox',
|
|
95
102
|
mergeProps(
|
|
103
|
+
overlay(attrs),
|
|
96
104
|
{ style: boxStyle(theme.value, props, shrink.value) },
|
|
97
105
|
nativeAttrs(),
|
|
98
106
|
attrs,
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { defineComponent, h, mergeProps, registerElement } from 'nativescript-vue'
|
|
2
|
+
import { isIOS, type EventData, type View } from '@nativescript/core'
|
|
2
3
|
import { ScrollHeaderSurface } from '@rafaelaugusto/jolt'
|
|
3
4
|
import {
|
|
4
5
|
createAnimatedText,
|
|
5
6
|
createComposer,
|
|
7
|
+
createEditorControls,
|
|
6
8
|
createSpeedDial,
|
|
7
9
|
createScrollComponents,
|
|
8
10
|
scrollFrameHostProps,
|
|
@@ -14,11 +16,24 @@ import { MCard } from './MCard.js'
|
|
|
14
16
|
import { MText } from './MText.js'
|
|
15
17
|
import { MInput } from './MInput.js'
|
|
16
18
|
import { MImage } from './MImage.js'
|
|
19
|
+
import { MAvatar } from './MAvatar.js'
|
|
17
20
|
import { MButton } from './MButton.js'
|
|
18
21
|
import { MChip } from './MChip.js'
|
|
19
22
|
import { MPopover } from './MPopover.js'
|
|
20
23
|
|
|
21
24
|
registerElement('MavisRefreshFrame', () => ScrollHeaderSurface, { viewFlags: 4 })
|
|
25
|
+
const Clip = defineComponent({
|
|
26
|
+
name: 'MScrollHeaderClip',
|
|
27
|
+
inheritAttrs: false,
|
|
28
|
+
setup(_, { attrs, slots }) {
|
|
29
|
+
const loaded = ({ object }: EventData) => {
|
|
30
|
+
// Core defaults clipToBounds to true, so assigning true can skip its native
|
|
31
|
+
// setter. Enforce it once the UIView exists, independently of Jolt's header.
|
|
32
|
+
if (isIOS) (object as View).nativeViewProtected.clipsToBounds = true
|
|
33
|
+
}
|
|
34
|
+
return () => h(MBox, mergeProps(attrs, { clipToBounds: true, onLoaded: loaded }), slots)
|
|
35
|
+
},
|
|
36
|
+
})
|
|
22
37
|
const Frame = defineComponent({
|
|
23
38
|
name: 'MScrollFrameHost',
|
|
24
39
|
inheritAttrs: false,
|
|
@@ -43,6 +58,7 @@ const Frame = defineComponent({
|
|
|
43
58
|
})
|
|
44
59
|
const ui = {
|
|
45
60
|
Box: MBox,
|
|
61
|
+
Clip,
|
|
46
62
|
Card: MCard,
|
|
47
63
|
Column: MColumn,
|
|
48
64
|
Row: MRow,
|
|
@@ -55,6 +71,10 @@ const ui = {
|
|
|
55
71
|
Frame,
|
|
56
72
|
}
|
|
57
73
|
export const MAnimatedText = createAnimatedText(MText)
|
|
74
|
+
export const { MTagInput, MAvatarGroup, MSearchBar } = createEditorControls(
|
|
75
|
+
{ ...ui, Avatar: MAvatar },
|
|
76
|
+
'native',
|
|
77
|
+
)
|
|
58
78
|
export const MComposer = createComposer(ui, 'native')
|
|
59
79
|
export const MSpeedDial = createSpeedDial(ui)
|
|
60
80
|
export const { MCollapsibleHeader, MRefreshControl } = createScrollComponents(ui, 'native')
|
package/src/vue/index.ts
CHANGED
|
@@ -26,6 +26,9 @@ import {
|
|
|
26
26
|
import {
|
|
27
27
|
MCollapsibleHeader,
|
|
28
28
|
MRefreshControl,
|
|
29
|
+
MTagInput,
|
|
30
|
+
MAvatarGroup,
|
|
31
|
+
MSearchBar,
|
|
29
32
|
MComposer,
|
|
30
33
|
MSpeedDial,
|
|
31
34
|
MPinInput,
|
|
@@ -119,6 +122,9 @@ export {
|
|
|
119
122
|
MMarquee,
|
|
120
123
|
MCollapsibleHeader,
|
|
121
124
|
MRefreshControl,
|
|
125
|
+
MTagInput,
|
|
126
|
+
MAvatarGroup,
|
|
127
|
+
MSearchBar,
|
|
122
128
|
MComposer,
|
|
123
129
|
MSpeedDial,
|
|
124
130
|
MPinInput,
|
|
@@ -207,6 +213,7 @@ export {
|
|
|
207
213
|
} from '@getcortexlabs/mavis-core/vue'
|
|
208
214
|
export type {
|
|
209
215
|
MavisThemeContext,
|
|
216
|
+
ThemePair,
|
|
210
217
|
MavisPlatform,
|
|
211
218
|
MavisPlatformTarget,
|
|
212
219
|
MavisPlatformContext,
|
|
@@ -251,6 +258,9 @@ export function createMavis(options: MavisOptions = {}) {
|
|
|
251
258
|
MMarquee,
|
|
252
259
|
MCollapsibleHeader,
|
|
253
260
|
MRefreshControl,
|
|
261
|
+
MTagInput,
|
|
262
|
+
MAvatarGroup,
|
|
263
|
+
MSearchBar,
|
|
254
264
|
MComposer,
|
|
255
265
|
MSpeedDial,
|
|
256
266
|
MPinInput,
|
package/src/vue/navigation.ts
CHANGED
|
@@ -1,15 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { linkDestination, type NavigationOptions } from '@getcortexlabs/mavis-core'
|
|
3
|
-
|
|
4
|
-
export function nativeDestination(options: NavigationOptions) {
|
|
5
|
-
const href = linkDestination(options.href!)
|
|
6
|
-
if (!options.navigate && !/^[a-z][a-z\d+.-]*:/i.test(href))
|
|
7
|
-
throw new TypeError('Native navigation needs a navigate handler for in-app destinations.')
|
|
8
|
-
return href
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export async function navigateNative(options: NavigationOptions) {
|
|
12
|
-
const href = nativeDestination(options)
|
|
13
|
-
if (options.navigate) await options.navigate(href)
|
|
14
|
-
else if (!(await Utils.openUrl(href))) throw new Error(`The system could not open ${href}.`)
|
|
15
|
-
}
|
|
1
|
+
export { nativeDestination, navigateNative } from '../native/navigation.js'
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { inject, type InjectionKey } from 'nativescript-vue'
|
|
2
|
+
|
|
3
|
+
/** Only the screen's decorative slot inherits this; modal and toast hosts do not. */
|
|
4
|
+
export const screenOverlay: InjectionKey<boolean> = Symbol('mavis.screenOverlay')
|
|
5
|
+
|
|
6
|
+
export function useOverlayLayout() {
|
|
7
|
+
const overlay = inject(screenOverlay, false)
|
|
8
|
+
return (attrs: Record<string, unknown>) => {
|
|
9
|
+
if (!overlay) return {}
|
|
10
|
+
const style = attrs.style as { pointerEvents?: string } | undefined
|
|
11
|
+
// Explicit native gestures and the Web's pointer opt-in keep interactive
|
|
12
|
+
// layers usable. Plain nested layouts let their empty area pass through.
|
|
13
|
+
const interactive =
|
|
14
|
+
style?.pointerEvents === 'auto' ||
|
|
15
|
+
['onTap', 'onTouch', 'onPan', 'onLongPress', 'onDoubleTap', 'onSwipe'].some(
|
|
16
|
+
(name) => attrs[name],
|
|
17
|
+
)
|
|
18
|
+
return { isPassThroughParentEnabled: !interactive }
|
|
19
|
+
}
|
|
20
|
+
}
|