@getcortexlabs/mavis 0.1.0-alpha.9 → 0.1.0-rc.12
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 +6 -6
- package/dist/native/motion-region.d.ts +1 -0
- package/dist/native/motion-region.d.ts.map +1 -1
- package/dist/native/motion-region.js +8 -1
- package/dist/native/motion-region.js.map +1 -1
- 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 +17 -1
- package/dist/native/motion-surface.js.map +1 -1
- package/dist/native/number-flow-format.android.d.ts +3 -0
- package/dist/native/number-flow-format.android.d.ts.map +1 -0
- package/dist/native/number-flow-format.android.js +27 -0
- package/dist/native/number-flow-format.android.js.map +1 -0
- package/dist/native/number-flow-format.d.ts +4 -0
- package/dist/native/number-flow-format.d.ts.map +1 -0
- package/dist/native/number-flow-format.ios.d.ts +3 -0
- package/dist/native/number-flow-format.ios.d.ts.map +1 -0
- package/dist/native/number-flow-format.ios.js +24 -0
- package/dist/native/number-flow-format.ios.js.map +1 -0
- package/dist/native/number-flow-format.js +5 -0
- package/dist/native/number-flow-format.js.map +1 -0
- package/dist/native/section-scroll.d.ts +9 -0
- package/dist/native/section-scroll.d.ts.map +1 -0
- package/dist/native/section-scroll.js +69 -0
- package/dist/native/section-scroll.js.map +1 -0
- package/dist/native/segmented.d.ts.map +1 -1
- package/dist/native/segmented.js +4 -3
- package/dist/native/segmented.js.map +1 -1
- package/dist/vue/animated-number.d.ts +6 -0
- package/dist/vue/animated-number.d.ts.map +1 -0
- package/dist/vue/animated-number.js +52 -0
- package/dist/vue/animated-number.js.map +1 -0
- package/dist/vue/component-width.d.ts +7 -0
- package/dist/vue/component-width.d.ts.map +1 -0
- package/dist/vue/component-width.js +29 -0
- package/dist/vue/component-width.js.map +1 -0
- package/dist/vue/components/ChartPlot.d.ts +66 -0
- package/dist/vue/components/ChartPlot.d.ts.map +1 -0
- package/dist/vue/components/ChartPlot.js +236 -0
- package/dist/vue/components/ChartPlot.js.map +1 -0
- package/dist/vue/components/ChoiceControl.d.ts +3 -0
- package/dist/vue/components/ChoiceControl.d.ts.map +1 -1
- package/dist/vue/components/ChoiceControl.js +29 -22
- package/dist/vue/components/ChoiceControl.js.map +1 -1
- package/dist/vue/components/DateCalendar.d.ts +16 -1
- package/dist/vue/components/DateCalendar.d.ts.map +1 -1
- package/dist/vue/components/DateCalendar.js +45 -10
- package/dist/vue/components/DateCalendar.js.map +1 -1
- package/dist/vue/components/LoadingDecoration.d.ts +1 -1
- package/dist/vue/components/MAccordion.d.ts +1 -1
- package/dist/vue/components/MAlert.d.ts +3 -3
- package/dist/vue/components/MAlert.d.ts.map +1 -1
- package/dist/vue/components/MAlert.js +3 -0
- package/dist/vue/components/MAlert.js.map +1 -1
- package/dist/vue/components/MAvatar.d.ts +1 -1
- package/dist/vue/components/MAvatar.d.ts.map +1 -1
- package/dist/vue/components/MAvatar.js +5 -1
- package/dist/vue/components/MAvatar.js.map +1 -1
- package/dist/vue/components/MBadge.d.ts +1 -1
- package/dist/vue/components/MBadge.d.ts.map +1 -1
- package/dist/vue/components/MBadge.js +3 -1
- package/dist/vue/components/MBadge.js.map +1 -1
- package/dist/vue/components/MButton.d.ts +6 -6
- package/dist/vue/components/MCard.d.ts +3 -3
- package/dist/vue/components/MChip.d.ts +3 -3
- package/dist/vue/components/MCombobox.d.ts +4 -4
- package/dist/vue/components/MCombobox.d.ts.map +1 -1
- package/dist/vue/components/MCombobox.js +3 -1
- package/dist/vue/components/MCombobox.js.map +1 -1
- package/dist/vue/components/MDatePicker.d.ts +16 -16
- package/dist/vue/components/MDialog.d.ts +1 -1
- package/dist/vue/components/MEmptyState.d.ts +2 -2
- package/dist/vue/components/MEmptyState.d.ts.map +1 -1
- package/dist/vue/components/MEmptyState.js +3 -0
- package/dist/vue/components/MEmptyState.js.map +1 -1
- package/dist/vue/components/MFilePicker.d.ts +3 -3
- package/dist/vue/components/MFilePicker.d.ts.map +1 -1
- package/dist/vue/components/MFilePicker.js +3 -0
- package/dist/vue/components/MFilePicker.js.map +1 -1
- package/dist/vue/components/MGrid.d.ts +13 -2
- 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 +3 -3
- package/dist/vue/components/MImage.d.ts +2 -2
- package/dist/vue/components/MImage.d.ts.map +1 -1
- package/dist/vue/components/MImage.js +8 -1
- package/dist/vue/components/MImage.js.map +1 -1
- package/dist/vue/components/MImageCompare.d.ts +92 -0
- package/dist/vue/components/MImageCompare.d.ts.map +1 -0
- package/dist/vue/components/MImageCompare.js +138 -0
- package/dist/vue/components/MImageCompare.js.map +1 -0
- package/dist/vue/components/MImageViewer.d.ts +121 -0
- package/dist/vue/components/MImageViewer.d.ts.map +1 -0
- package/dist/vue/components/MImageViewer.js +444 -0
- package/dist/vue/components/MImageViewer.js.map +1 -0
- package/dist/vue/components/MInput.d.ts +4 -4
- package/dist/vue/components/MInput.d.ts.map +1 -1
- package/dist/vue/components/MInput.js +3 -0
- package/dist/vue/components/MInput.js.map +1 -1
- package/dist/vue/components/MPinInput.d.ts +57 -0
- package/dist/vue/components/MPinInput.d.ts.map +1 -0
- package/dist/vue/components/MPinInput.js +128 -0
- package/dist/vue/components/MPinInput.js.map +1 -0
- package/dist/vue/components/MPopover.d.ts +106 -0
- package/dist/vue/components/MPopover.d.ts.map +1 -0
- package/dist/vue/components/MPopover.js +259 -0
- package/dist/vue/components/MPopover.js.map +1 -0
- package/dist/vue/components/MProgress.d.ts +3 -3
- package/dist/vue/components/MProgress.d.ts.map +1 -1
- package/dist/vue/components/MProgress.js +5 -2
- package/dist/vue/components/MProgress.js.map +1 -1
- package/dist/vue/components/MRangeSlider.d.ts +105 -0
- package/dist/vue/components/MRangeSlider.d.ts.map +1 -0
- package/dist/vue/components/MRangeSlider.js +134 -0
- package/dist/vue/components/MRangeSlider.js.map +1 -0
- package/dist/vue/components/MResizablePanels.d.ts +137 -0
- package/dist/vue/components/MResizablePanels.d.ts.map +1 -0
- package/dist/vue/components/MResizablePanels.js +148 -0
- package/dist/vue/components/MResizablePanels.js.map +1 -0
- package/dist/vue/components/MReveal.d.ts +11 -11
- package/dist/vue/components/MSelect.d.ts +1 -1
- package/dist/vue/components/MSheet.d.ts +6 -6
- package/dist/vue/components/MStack.d.ts +28 -17
- package/dist/vue/components/MStack.d.ts.map +1 -1
- package/dist/vue/components/MStack.js +6 -1
- package/dist/vue/components/MStack.js.map +1 -1
- package/dist/vue/components/MTabs.d.ts.map +1 -1
- package/dist/vue/components/MTabs.js +6 -5
- package/dist/vue/components/MTabs.js.map +1 -1
- package/dist/vue/components/MText.d.ts +4 -4
- package/dist/vue/components/MTimePicker.d.ts +655 -0
- package/dist/vue/components/MTimePicker.d.ts.map +1 -0
- package/dist/vue/components/MTimePicker.js +50 -0
- package/dist/vue/components/MTimePicker.js.map +1 -0
- package/dist/vue/components/MTooltip.d.ts +65 -0
- package/dist/vue/components/MTooltip.d.ts.map +1 -0
- package/dist/vue/components/MTooltip.js +35 -0
- package/dist/vue/components/MTooltip.js.map +1 -0
- package/dist/vue/components/MVirtualList.d.ts +3 -0
- package/dist/vue/components/MVirtualList.d.ts.map +1 -0
- package/dist/vue/components/MVirtualList.js +106 -0
- package/dist/vue/components/MVirtualList.js.map +1 -0
- package/dist/vue/components/MotionRows.d.ts +15 -0
- package/dist/vue/components/MotionRows.d.ts.map +1 -0
- package/dist/vue/components/MotionRows.js +12 -0
- package/dist/vue/components/MotionRows.js.map +1 -0
- package/dist/vue/components/configurator.d.ts +2 -2
- package/dist/vue/components/creative.d.ts +614 -0
- package/dist/vue/components/creative.d.ts.map +1 -0
- package/dist/vue/components/creative.js +185 -0
- package/dist/vue/components/creative.js.map +1 -0
- package/dist/vue/components/dashboard.d.ts +474 -0
- package/dist/vue/components/dashboard.d.ts.map +1 -0
- package/dist/vue/components/dashboard.js +193 -0
- package/dist/vue/components/dashboard.js.map +1 -0
- package/dist/vue/components/discovery.d.ts +282 -0
- package/dist/vue/components/discovery.d.ts.map +1 -0
- package/dist/vue/components/discovery.js +65 -0
- package/dist/vue/components/discovery.js.map +1 -0
- package/dist/vue/components/interactive.d.ts +164 -0
- package/dist/vue/components/interactive.d.ts.map +1 -0
- package/dist/vue/components/interactive.js +33 -0
- package/dist/vue/components/interactive.js.map +1 -0
- package/dist/vue/components/layout.d.ts +47 -25
- package/dist/vue/components/layout.d.ts.map +1 -1
- package/dist/vue/components/layout.js +2 -1
- package/dist/vue/components/layout.js.map +1 -1
- package/dist/vue/components/navigation.d.ts +225 -0
- package/dist/vue/components/navigation.d.ts.map +1 -0
- package/dist/vue/components/navigation.js +16 -0
- package/dist/vue/components/navigation.js.map +1 -0
- package/dist/vue/components/screen-components.d.ts +502 -0
- package/dist/vue/components/screen-components.d.ts.map +1 -0
- package/dist/vue/components/screen-components.js +46 -0
- package/dist/vue/components/screen-components.js.map +1 -0
- package/dist/vue/components/wayfinding.d.ts +441 -0
- package/dist/vue/components/wayfinding.d.ts.map +1 -0
- package/dist/vue/components/wayfinding.js +39 -0
- package/dist/vue/components/wayfinding.js.map +1 -0
- package/dist/vue/components/workflows.d.ts +2 -2
- package/dist/vue/index.d.ts +17 -4
- package/dist/vue/index.d.ts.map +1 -1
- package/dist/vue/index.js +60 -3
- package/dist/vue/index.js.map +1 -1
- package/dist/vue/router-navigation.d.ts +25 -0
- package/dist/vue/router-navigation.d.ts.map +1 -0
- package/dist/vue/router-navigation.js +15 -0
- package/dist/vue/router-navigation.js.map +1 -0
- package/dist/vue/services.d.ts.map +1 -1
- package/dist/vue/services.js +7 -2
- package/dist/vue/services.js.map +1 -1
- package/package.json +4 -4
- package/src/native/motion-region.ts +14 -1
- package/src/native/motion-surface.ts +24 -1
- package/src/native/number-flow-format.android.ts +61 -0
- package/src/native/number-flow-format.ios.ts +40 -0
- package/src/native/number-flow-format.ts +9 -0
- package/src/native/section-scroll.ts +81 -0
- package/src/native/segmented.ts +4 -3
- package/src/vue/animated-number.ts +57 -0
- package/src/vue/component-width.ts +34 -0
- package/src/vue/components/ChartPlot.ts +267 -0
- package/src/vue/components/ChoiceControl.ts +32 -25
- package/src/vue/components/DateCalendar.ts +50 -9
- package/src/vue/components/MAlert.ts +3 -0
- package/src/vue/components/MAvatar.ts +5 -1
- package/src/vue/components/MBadge.ts +3 -1
- package/src/vue/components/MCombobox.ts +6 -1
- package/src/vue/components/MEmptyState.ts +3 -0
- package/src/vue/components/MFilePicker.ts +3 -0
- package/src/vue/components/MGrid.ts +14 -0
- package/src/vue/components/MImage.ts +10 -1
- package/src/vue/components/MImageCompare.ts +162 -0
- package/src/vue/components/MImageViewer.ts +489 -0
- package/src/vue/components/MInput.ts +3 -0
- package/src/vue/components/MPinInput.ts +145 -0
- package/src/vue/components/MPopover.ts +314 -0
- package/src/vue/components/MProgress.ts +8 -2
- package/src/vue/components/MRangeSlider.ts +157 -0
- package/src/vue/components/MResizablePanels.ts +180 -0
- package/src/vue/components/MStack.ts +6 -0
- package/src/vue/components/MTabs.ts +10 -4
- package/src/vue/components/MTimePicker.ts +57 -0
- package/src/vue/components/MTooltip.ts +39 -0
- package/src/vue/components/MVirtualList.ts +140 -0
- package/src/vue/components/MotionRows.ts +17 -0
- package/src/vue/components/creative.ts +246 -0
- package/src/vue/components/dashboard.ts +249 -0
- package/src/vue/components/discovery.ts +91 -0
- package/src/vue/components/interactive.ts +43 -0
- package/src/vue/components/layout.ts +2 -0
- package/src/vue/components/navigation.ts +19 -0
- package/src/vue/components/screen-components.ts +61 -0
- package/src/vue/components/wayfinding.ts +48 -0
- package/src/vue/index.ts +144 -1
- package/src/vue/router-navigation.ts +39 -0
- package/src/vue/services.ts +8 -1
- package/dist/date-format.android.d.ts +0 -5
- package/dist/date-format.android.d.ts.map +0 -1
- package/dist/date-format.android.js +0 -39
- package/dist/date-format.android.js.map +0 -1
- package/dist/date-format.ios.d.ts +0 -5
- package/dist/date-format.ios.d.ts.map +0 -1
- package/dist/date-format.ios.js +0 -29
- package/dist/date-format.ios.js.map +0 -1
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { computed, defineComponent, h, mergeProps, ref, watch } from 'nativescript-vue'
|
|
2
|
+
import type { EventData, PanGestureEventData, View } from '@nativescript/core'
|
|
3
|
+
import { panelValue, positiveSize } from '@getcortexlabs/mavis-core'
|
|
4
|
+
import { resizablePanelsProps, usePartition, useMavisTheme } from '@getcortexlabs/mavis-core/vue'
|
|
5
|
+
import { useAnimatedNumber } from '../animated-number.js'
|
|
6
|
+
import { MColumn, MRow, MBox } from './layout.js'
|
|
7
|
+
import { MSlider } from './MSlider.js'
|
|
8
|
+
import { MButton } from './MButton.js'
|
|
9
|
+
|
|
10
|
+
export const MResizablePanels = defineComponent({
|
|
11
|
+
name: 'MResizablePanels',
|
|
12
|
+
inheritAttrs: false,
|
|
13
|
+
props: resizablePanelsProps,
|
|
14
|
+
emits: { 'update:modelValue': (_value: number) => true, resize: (_value: number) => true },
|
|
15
|
+
setup(props, { attrs, slots, emit }) {
|
|
16
|
+
const { theme } = useMavisTheme()
|
|
17
|
+
const size = ref({ width: 0, height: 0 })
|
|
18
|
+
const value = computed(() =>
|
|
19
|
+
panelValue(props.modelValue, props.min, props.max, props.collapsible),
|
|
20
|
+
)
|
|
21
|
+
let remembered = Math.max(props.min, 40),
|
|
22
|
+
origin = 0
|
|
23
|
+
const state = usePartition(
|
|
24
|
+
() => value.value,
|
|
25
|
+
() => ({
|
|
26
|
+
min: props.collapsible ? 0 : props.min,
|
|
27
|
+
max: props.max,
|
|
28
|
+
step: props.step,
|
|
29
|
+
disabled: props.disabled,
|
|
30
|
+
}),
|
|
31
|
+
(next) =>
|
|
32
|
+
emit('update:modelValue', next === 0 && props.collapsible ? 0 : Math.max(props.min, next)),
|
|
33
|
+
)
|
|
34
|
+
const motion = useAnimatedNumber(
|
|
35
|
+
() => value.value,
|
|
36
|
+
() => state.dragging.value,
|
|
37
|
+
)
|
|
38
|
+
const vertical = () => props.orientation === 'vertical'
|
|
39
|
+
function finish() {
|
|
40
|
+
state.end()
|
|
41
|
+
const closest = props.snap
|
|
42
|
+
.filter((p) => Number.isFinite(p) && p >= props.min && p <= props.max)
|
|
43
|
+
.sort((a, b) => Math.abs(a - value.value) - Math.abs(b - value.value))[0]
|
|
44
|
+
if (closest !== undefined && Math.abs(closest - value.value) <= 3)
|
|
45
|
+
emit('update:modelValue', closest)
|
|
46
|
+
emit(
|
|
47
|
+
'resize',
|
|
48
|
+
closest !== undefined && Math.abs(closest - value.value) <= 3 ? closest : value.value,
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
|
+
function toggle() {
|
|
52
|
+
if (props.disabled || !props.collapsible) return
|
|
53
|
+
if (value.value) {
|
|
54
|
+
remembered = value.value
|
|
55
|
+
emit('update:modelValue', 0)
|
|
56
|
+
} else emit('update:modelValue', Math.max(props.min, Math.min(props.max, remembered)))
|
|
57
|
+
}
|
|
58
|
+
watch(
|
|
59
|
+
() => [props.orientation, props.direction],
|
|
60
|
+
() => state.cancel(),
|
|
61
|
+
)
|
|
62
|
+
return () => {
|
|
63
|
+
const ratio = Math.max(0, Math.min(100, motion.shown.value)),
|
|
64
|
+
flipped = !vertical() && props.direction === 'rtl'
|
|
65
|
+
const first = flipped ? 100 - ratio : ratio,
|
|
66
|
+
last = flipped ? ratio : 100 - ratio
|
|
67
|
+
const tracks = `${first}*,44,${last}*`
|
|
68
|
+
return h(MColumn, mergeProps(attrs, { gap: 'sm' }), () => [
|
|
69
|
+
h(
|
|
70
|
+
'GridLayout',
|
|
71
|
+
{
|
|
72
|
+
onLoaded: motion.onLoaded,
|
|
73
|
+
onUnloaded: motion.onUnloaded,
|
|
74
|
+
height: positiveSize(props.height, 'height'),
|
|
75
|
+
columns: vertical() ? '*' : tracks,
|
|
76
|
+
rows: vertical() ? tracks : '*',
|
|
77
|
+
clipToBounds: true,
|
|
78
|
+
borderRadius: 16,
|
|
79
|
+
borderWidth: 1,
|
|
80
|
+
borderColor: theme.value.colors.border,
|
|
81
|
+
onLayoutChanged: (event: EventData) => {
|
|
82
|
+
const next = (event.object as View).getActualSize()
|
|
83
|
+
if (next.width !== size.value.width || next.height !== size.value.height) {
|
|
84
|
+
state.cancel()
|
|
85
|
+
size.value = next
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
[
|
|
90
|
+
h(
|
|
91
|
+
'ScrollView',
|
|
92
|
+
{
|
|
93
|
+
row: vertical() ? 0 : 0,
|
|
94
|
+
col: flipped ? 2 : 0,
|
|
95
|
+
visibility: value.value === 0 ? 'hidden' : 'visible',
|
|
96
|
+
accessibilityLabel: props.primaryLabel,
|
|
97
|
+
},
|
|
98
|
+
[h(MColumn, {}, () => slots.primary?.())],
|
|
99
|
+
),
|
|
100
|
+
h(
|
|
101
|
+
MBox,
|
|
102
|
+
{
|
|
103
|
+
row: vertical() ? 1 : 0,
|
|
104
|
+
col: vertical() ? 0 : 1,
|
|
105
|
+
backgroundColor: theme.value.colors.elevated,
|
|
106
|
+
accessibilityHidden: true,
|
|
107
|
+
onPan: (event: PanGestureEventData) => {
|
|
108
|
+
const travel = (vertical() ? size.value.height : size.value.width) - 44
|
|
109
|
+
if (props.disabled || travel <= 0) return
|
|
110
|
+
if (event.state === 1) {
|
|
111
|
+
if (state.begin()) origin = value.value
|
|
112
|
+
}
|
|
113
|
+
if (event.state === 2 && state.dragging.value)
|
|
114
|
+
state.update(
|
|
115
|
+
origin +
|
|
116
|
+
((vertical() ? event.deltaY : event.deltaX * (flipped ? -1 : 1)) / travel) *
|
|
117
|
+
100,
|
|
118
|
+
)
|
|
119
|
+
if (event.state === 3 && state.dragging.value) finish()
|
|
120
|
+
if (event.state === 4) state.cancel()
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
() =>
|
|
124
|
+
h(MBox, {
|
|
125
|
+
width: vertical() ? 28 : 4,
|
|
126
|
+
height: vertical() ? 4 : 28,
|
|
127
|
+
radius: 'full',
|
|
128
|
+
backgroundColor: theme.value.colors.muted,
|
|
129
|
+
horizontalAlignment: 'center',
|
|
130
|
+
verticalAlignment: 'middle',
|
|
131
|
+
}),
|
|
132
|
+
),
|
|
133
|
+
h(
|
|
134
|
+
'ScrollView',
|
|
135
|
+
{
|
|
136
|
+
row: vertical() ? 2 : 0,
|
|
137
|
+
col: vertical() ? 0 : flipped ? 0 : 2,
|
|
138
|
+
accessibilityLabel: props.secondaryLabel,
|
|
139
|
+
},
|
|
140
|
+
[h(MColumn, {}, () => slots.secondary?.())],
|
|
141
|
+
),
|
|
142
|
+
],
|
|
143
|
+
),
|
|
144
|
+
h(MSlider, {
|
|
145
|
+
label: props.label,
|
|
146
|
+
modelValue: value.value,
|
|
147
|
+
min: props.collapsible ? 0 : props.min,
|
|
148
|
+
max: props.max,
|
|
149
|
+
step: props.step,
|
|
150
|
+
disabled: props.disabled,
|
|
151
|
+
'onUpdate:modelValue': state.update,
|
|
152
|
+
}),
|
|
153
|
+
h(MRow, { gap: 'sm' }, () => [
|
|
154
|
+
h(MButton, {
|
|
155
|
+
text: '−',
|
|
156
|
+
variant: 'ghost',
|
|
157
|
+
accessibilityLabel: `${props.primaryLabel}: −${props.step}%`,
|
|
158
|
+
disabled: props.disabled || value.value <= props.min,
|
|
159
|
+
onClick: () => state.update(value.value - props.step),
|
|
160
|
+
}),
|
|
161
|
+
h(MButton, {
|
|
162
|
+
text: '+',
|
|
163
|
+
variant: 'ghost',
|
|
164
|
+
accessibilityLabel: `${props.primaryLabel}: +${props.step}%`,
|
|
165
|
+
disabled: props.disabled || value.value >= props.max,
|
|
166
|
+
onClick: () => state.update(value.value + props.step),
|
|
167
|
+
}),
|
|
168
|
+
props.collapsible
|
|
169
|
+
? h(MButton, {
|
|
170
|
+
text: value.value ? props.collapseLabel : props.expandLabel,
|
|
171
|
+
variant: 'ghost',
|
|
172
|
+
disabled: props.disabled,
|
|
173
|
+
onClick: toggle,
|
|
174
|
+
})
|
|
175
|
+
: null,
|
|
176
|
+
]),
|
|
177
|
+
])
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
})
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useMotionRegion } from '../use-motion-region.js'
|
|
1
2
|
import { computed, defineComponent, h, mergeProps, provide, shallowRef } from 'nativescript-vue'
|
|
2
3
|
import type { EventData, View } from '@nativescript/core'
|
|
3
4
|
import { resolveSpace, stackLayout } from '@getcortexlabs/mavis-core'
|
|
@@ -6,6 +7,7 @@ import {
|
|
|
6
7
|
layoutDirection,
|
|
7
8
|
useLayoutShrink,
|
|
8
9
|
useMavisTheme,
|
|
10
|
+
useComponentLayout,
|
|
9
11
|
} from '@getcortexlabs/mavis-core/vue'
|
|
10
12
|
import { boxStyle } from '../props.js'
|
|
11
13
|
import { useNativeViewAttrs } from '../accessibility.js'
|
|
@@ -47,6 +49,8 @@ export const MStack = defineComponent({
|
|
|
47
49
|
width.value,
|
|
48
50
|
),
|
|
49
51
|
)
|
|
52
|
+
const automatic = useComponentLayout(() => JSON.stringify(layout.value), false)
|
|
53
|
+
const motion = useMotionRegion(() => props.motionRegion ?? automatic)
|
|
50
54
|
const direction = computed(() => layout.value.direction ?? props.direction)
|
|
51
55
|
provide(layoutDirection, direction)
|
|
52
56
|
const measure = (event: EventData) => {
|
|
@@ -63,8 +67,10 @@ export const MStack = defineComponent({
|
|
|
63
67
|
h(
|
|
64
68
|
'MavisFlexLayout',
|
|
65
69
|
{
|
|
70
|
+
...motion,
|
|
66
71
|
onLayoutChanged: measure,
|
|
67
72
|
onUnloaded: () => {
|
|
73
|
+
motion.onUnloaded()
|
|
68
74
|
width.value = undefined
|
|
69
75
|
},
|
|
70
76
|
style: {
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
import type { EventData, ScrollView, View } from '@nativescript/core'
|
|
14
14
|
import { animate, onReducedMotion, set } from '@rafaelaugusto/jolt'
|
|
15
15
|
import {
|
|
16
|
+
componentMotion,
|
|
16
17
|
canChoose,
|
|
17
18
|
choiceKey,
|
|
18
19
|
tabFocusTarget,
|
|
@@ -85,11 +86,16 @@ export const MTabs = defineComponent({
|
|
|
85
86
|
if (changed) {
|
|
86
87
|
motion?.stop()
|
|
87
88
|
motion = undefined
|
|
88
|
-
indicator.width =
|
|
89
|
+
indicator.width = 100
|
|
90
|
+
indicator.originX = 0
|
|
89
91
|
indicator.opacity = 1
|
|
90
92
|
if (previous && animateNext)
|
|
91
|
-
motion = animate(
|
|
92
|
-
|
|
93
|
+
motion = animate(
|
|
94
|
+
indicator,
|
|
95
|
+
{ x: point.x, scaleX: width / 100 },
|
|
96
|
+
componentMotion(theme.value, 'selection'),
|
|
97
|
+
)
|
|
98
|
+
else set(indicator, { x: point.x, scaleX: width / 100 })
|
|
93
99
|
}
|
|
94
100
|
previous = { key, x: point.x, width }
|
|
95
101
|
animateNext = false
|
|
@@ -163,7 +169,7 @@ export const MTabs = defineComponent({
|
|
|
163
169
|
if (value && indicator && previous) {
|
|
164
170
|
motion?.stop()
|
|
165
171
|
motion = undefined
|
|
166
|
-
set(indicator, { x: previous.x })
|
|
172
|
+
set(indicator, { x: previous.x, scaleX: previous.width / 100 })
|
|
167
173
|
}
|
|
168
174
|
})
|
|
169
175
|
schedule()
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { defineComponent, h } from 'nativescript-vue'
|
|
2
|
+
import { Utils, isAndroid, type EventData, type TimePicker } from '@nativescript/core'
|
|
3
|
+
import { createTimePicker, timePickerProps } from '@getcortexlabs/mavis-core/vue'
|
|
4
|
+
import { localTime, timeMinutes, timeOptions } from '@getcortexlabs/mavis-core'
|
|
5
|
+
import { MInput } from './MInput.js'
|
|
6
|
+
import { MColumn, MRow } from './layout.js'
|
|
7
|
+
import { MButton } from './MButton.js'
|
|
8
|
+
import { MText } from './MText.js'
|
|
9
|
+
import { MSheet } from './MSheet.js'
|
|
10
|
+
|
|
11
|
+
declare const NSLocale: { alloc(): { initWithLocaleIdentifier(locale: string): unknown } }
|
|
12
|
+
declare const java: { lang: { Boolean: { valueOf(value: boolean): unknown } } }
|
|
13
|
+
|
|
14
|
+
const TimeWheel = defineComponent({
|
|
15
|
+
props: timePickerProps,
|
|
16
|
+
emits: ['update:modelValue'],
|
|
17
|
+
setup(props, { emit }) {
|
|
18
|
+
return () => {
|
|
19
|
+
const minutes = timeMinutes(props.modelValue ?? '00:00')
|
|
20
|
+
const { cycle, step } = timeOptions(props)
|
|
21
|
+
return h('TimePicker', {
|
|
22
|
+
// A Date is only the native widget transport. The public model remains HH:mm.
|
|
23
|
+
key: `${props.locale}:${cycle}:${step}`,
|
|
24
|
+
time: new Date(2000, 0, 1, Math.floor(minutes / 60), minutes % 60),
|
|
25
|
+
minuteInterval: step,
|
|
26
|
+
iosPreferredDatePickerStyle: 1,
|
|
27
|
+
accessibilityLabel: props.label,
|
|
28
|
+
onLoaded: (event: EventData) => {
|
|
29
|
+
const picker = event.object as TimePicker
|
|
30
|
+
if (isAndroid) picker.android.setIs24HourView(java.lang.Boolean.valueOf(cycle === 'h23'))
|
|
31
|
+
else
|
|
32
|
+
picker.ios.locale = NSLocale.alloc().initWithLocaleIdentifier(
|
|
33
|
+
`${props.locale.replace('-', '_')}@hours=${cycle}`,
|
|
34
|
+
)
|
|
35
|
+
},
|
|
36
|
+
onTimeChange: (event: EventData) => {
|
|
37
|
+
const picker = event.object as TimePicker
|
|
38
|
+
if (picker.isLoaded)
|
|
39
|
+
emit('update:modelValue', localTime(picker.hour * 60 + picker.minute))
|
|
40
|
+
},
|
|
41
|
+
})
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
})
|
|
45
|
+
export const MTimePicker = createTimePicker(
|
|
46
|
+
{
|
|
47
|
+
Input: MInput,
|
|
48
|
+
Column: MColumn,
|
|
49
|
+
Row: MRow,
|
|
50
|
+
Button: MButton,
|
|
51
|
+
Text: MText,
|
|
52
|
+
Sheet: MSheet,
|
|
53
|
+
Picker: TimeWheel,
|
|
54
|
+
beforeOpen: () => Utils.dismissKeyboard(),
|
|
55
|
+
},
|
|
56
|
+
'native',
|
|
57
|
+
)
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { defineComponent, h, ref } from 'nativescript-vue'
|
|
2
|
+
import { tooltipProps } from '@getcortexlabs/mavis-core/vue'
|
|
3
|
+
import { MPopover } from './MPopover.js'
|
|
4
|
+
import { MText } from './MText.js'
|
|
5
|
+
|
|
6
|
+
/** Native help uses an explicit touch/assistive trigger; it never depends on hover or long press. */
|
|
7
|
+
export const MTooltip = defineComponent({
|
|
8
|
+
name: 'MTooltip',
|
|
9
|
+
inheritAttrs: false,
|
|
10
|
+
props: tooltipProps,
|
|
11
|
+
setup(props, { attrs }) {
|
|
12
|
+
const open = ref(false)
|
|
13
|
+
return () => {
|
|
14
|
+
if (!props.text.trim() || !props.triggerLabel.trim())
|
|
15
|
+
throw new TypeError('Tooltip requires text and a trigger label.')
|
|
16
|
+
if (!Number.isFinite(props.delay) || props.delay < 0)
|
|
17
|
+
throw new RangeError('Tooltip delay must be nonnegative and finite.')
|
|
18
|
+
return h(
|
|
19
|
+
MPopover,
|
|
20
|
+
{
|
|
21
|
+
...attrs,
|
|
22
|
+
id: props.id,
|
|
23
|
+
open: open.value,
|
|
24
|
+
label: props.triggerLabel,
|
|
25
|
+
triggerLabel: props.triggerLabel,
|
|
26
|
+
icon: props.icon,
|
|
27
|
+
variant: props.variant,
|
|
28
|
+
disabled: props.disabled,
|
|
29
|
+
placement: props.placement,
|
|
30
|
+
width: 280,
|
|
31
|
+
'onUpdate:open': (value: boolean) => {
|
|
32
|
+
open.value = value
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
() => h(MText, { text: props.text }),
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
})
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { useComponentContent } from '@getcortexlabs/mavis-core/vue'
|
|
2
|
+
import { useMotionSurface } from '../use-motion-surface.js'
|
|
3
|
+
import type { VirtualListComponent } from '@getcortexlabs/mavis-core/vue'
|
|
4
|
+
import {
|
|
5
|
+
computed,
|
|
6
|
+
defineComponent,
|
|
7
|
+
h,
|
|
8
|
+
ListView,
|
|
9
|
+
mergeProps,
|
|
10
|
+
nextTick,
|
|
11
|
+
shallowRef,
|
|
12
|
+
ref,
|
|
13
|
+
watch,
|
|
14
|
+
} from 'nativescript-vue'
|
|
15
|
+
import { isAndroid, type EventData, type ListView as NativeList } from '@nativescript/core'
|
|
16
|
+
import { virtualListProps } from '@getcortexlabs/mavis-core/vue'
|
|
17
|
+
import {
|
|
18
|
+
choiceKey,
|
|
19
|
+
virtualKeys,
|
|
20
|
+
virtualWindow,
|
|
21
|
+
type VirtualItemSlot,
|
|
22
|
+
type VirtualListHandle,
|
|
23
|
+
} from '@getcortexlabs/mavis-core'
|
|
24
|
+
import { MText } from './MText.js'
|
|
25
|
+
|
|
26
|
+
// A recycled cell never inherits the previous item's presentation. Only a data
|
|
27
|
+
// revision on an already loaded logical item plays; ordinary scrolling stays still.
|
|
28
|
+
const RealizedContent = defineComponent({
|
|
29
|
+
props: { revision: Number, height: Number },
|
|
30
|
+
setup(props, { slots }) {
|
|
31
|
+
const feedback = useComponentContent(() => props.revision, false)
|
|
32
|
+
const motion = useMotionSurface(() => feedback)
|
|
33
|
+
return () => h('GridLayout', { ...motion, height: props.height }, slots.default?.())
|
|
34
|
+
},
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
const VirtualList = defineComponent({
|
|
38
|
+
name: 'MVirtualList',
|
|
39
|
+
inheritAttrs: false,
|
|
40
|
+
props: virtualListProps,
|
|
41
|
+
setup(props, { attrs, slots, expose }) {
|
|
42
|
+
const keys = computed(() => virtualKeys(props.items, props.itemKey))
|
|
43
|
+
const list = shallowRef<NativeList>()
|
|
44
|
+
const revision = ref(0)
|
|
45
|
+
let requested = props.initialIndex
|
|
46
|
+
function scrollToIndex(index: number) {
|
|
47
|
+
if (!Number.isInteger(index) || index < 0 || index >= props.items.length)
|
|
48
|
+
throw new RangeError('List index is out of range.')
|
|
49
|
+
requested = index
|
|
50
|
+
list.value?.scrollToIndex(index)
|
|
51
|
+
}
|
|
52
|
+
expose({ scrollToIndex } satisfies VirtualListHandle)
|
|
53
|
+
watch(
|
|
54
|
+
keys,
|
|
55
|
+
(next, previous) => {
|
|
56
|
+
revision.value++
|
|
57
|
+
const view = list.value
|
|
58
|
+
const first = view
|
|
59
|
+
? isAndroid
|
|
60
|
+
? view.android?.getFirstVisiblePosition()
|
|
61
|
+
: view.ios?.indexPathsForVisibleRows?.firstObject?.row
|
|
62
|
+
: requested
|
|
63
|
+
const key = previous[Math.max(0, first ?? requested)]
|
|
64
|
+
const index = key === undefined ? -1 : next.indexOf(key)
|
|
65
|
+
requested = Math.max(0, Math.min(index < 0 ? requested : index, next.length - 1))
|
|
66
|
+
void nextTick(() => {
|
|
67
|
+
if (next.length && view?.isLoaded) view.scrollToIndex(requested)
|
|
68
|
+
})
|
|
69
|
+
},
|
|
70
|
+
{ flush: 'pre' },
|
|
71
|
+
)
|
|
72
|
+
return () => {
|
|
73
|
+
virtualWindow(props.items.length, props.rowHeight, props.height, 0, props.overscan)
|
|
74
|
+
void keys.value
|
|
75
|
+
if (!props.label.trim()) throw new TypeError('Virtual lists require a label.')
|
|
76
|
+
if (!Number.isInteger(props.initialIndex) || props.initialIndex < 0)
|
|
77
|
+
throw new RangeError('initialIndex must be a nonnegative integer.')
|
|
78
|
+
if (!props.items.length)
|
|
79
|
+
return h(
|
|
80
|
+
'GridLayout',
|
|
81
|
+
mergeProps(attrs, {
|
|
82
|
+
id: props.id,
|
|
83
|
+
height: props.height,
|
|
84
|
+
accessibilityLabel: props.label,
|
|
85
|
+
}),
|
|
86
|
+
slots.empty?.() ?? [h(MText, { text: props.emptyLabel, tone: 'muted' })],
|
|
87
|
+
)
|
|
88
|
+
const content = h(
|
|
89
|
+
ListView,
|
|
90
|
+
mergeProps(attrs, {
|
|
91
|
+
id: props.id,
|
|
92
|
+
items: props.items,
|
|
93
|
+
rowHeight: props.rowHeight,
|
|
94
|
+
height: props.height,
|
|
95
|
+
separatorColor: 'transparent',
|
|
96
|
+
accessibilityLabel: props.label,
|
|
97
|
+
onLoaded: (event: EventData) => {
|
|
98
|
+
list.value = event.object as NativeList
|
|
99
|
+
// Core iOS coerces a pre-mount rowHeight to auto. Reapply it once the
|
|
100
|
+
// UITableView exists so its delegate and scroll geometry use fixed rows.
|
|
101
|
+
if (!isAndroid) {
|
|
102
|
+
list.value.rowHeight = 'auto'
|
|
103
|
+
list.value.rowHeight = props.rowHeight
|
|
104
|
+
}
|
|
105
|
+
void nextTick(() => {
|
|
106
|
+
if (list.value?.isLoaded)
|
|
107
|
+
list.value.scrollToIndex(Math.min(requested, props.items.length - 1))
|
|
108
|
+
})
|
|
109
|
+
},
|
|
110
|
+
onUnloaded: () => {
|
|
111
|
+
list.value = undefined
|
|
112
|
+
},
|
|
113
|
+
}),
|
|
114
|
+
{
|
|
115
|
+
default: ({ item, index }: VirtualItemSlot) =>
|
|
116
|
+
h('GridLayout', { height: props.rowHeight }, [
|
|
117
|
+
// NativeScript owns cell reuse. A keyed child remounts local state when its logical item changes.
|
|
118
|
+
h(
|
|
119
|
+
RealizedContent,
|
|
120
|
+
{
|
|
121
|
+
key: choiceKey(keys.value[index]!),
|
|
122
|
+
height: props.rowHeight,
|
|
123
|
+
revision: revision.value,
|
|
124
|
+
},
|
|
125
|
+
() => slots.default?.({ item, index, itemKey: keys.value[index]! }),
|
|
126
|
+
),
|
|
127
|
+
]),
|
|
128
|
+
},
|
|
129
|
+
)
|
|
130
|
+
// A flex parent's intrinsic/exact passes alternate width measure modes.
|
|
131
|
+
// Core iOS reloads UITableView when that spec changes, losing its scroll
|
|
132
|
+
// offset during cell reuse. The bounded grid gives the list one exact width.
|
|
133
|
+
return isAndroid
|
|
134
|
+
? content
|
|
135
|
+
: h('GridLayout', { rows: '*', columns: '*', height: props.height }, [content])
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
})
|
|
139
|
+
|
|
140
|
+
export const MVirtualList = VirtualList as unknown as VirtualListComponent
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { defineComponent, h, type PropType, type VNode } from 'nativescript-vue'
|
|
2
|
+
import { useComponentLayout } from '@getcortexlabs/mavis-core/vue'
|
|
3
|
+
import { useMotionRegion } from '../use-motion-region.js'
|
|
4
|
+
|
|
5
|
+
export const MotionRows = defineComponent({
|
|
6
|
+
props: { nodes: { type: Array as PropType<VNode[]>, required: true } },
|
|
7
|
+
setup(props) {
|
|
8
|
+
const region = useComponentLayout(() => props.nodes.map((node) => node.key))
|
|
9
|
+
const hooks = useMotionRegion(() => region)
|
|
10
|
+
return () =>
|
|
11
|
+
h(
|
|
12
|
+
'StackLayout',
|
|
13
|
+
{ ...hooks, verticalAlignment: 'top', horizontalAlignment: 'left' },
|
|
14
|
+
props.nodes,
|
|
15
|
+
)
|
|
16
|
+
},
|
|
17
|
+
})
|