@getcortexlabs/mavis 0.1.0-alpha.10 → 0.1.0-alpha.11
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 +5 -5
- package/dist/vue/components/ChartPlot.d.ts +65 -0
- package/dist/vue/components/ChartPlot.d.ts.map +1 -0
- package/dist/vue/components/ChartPlot.js +100 -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 +9 -7
- package/dist/vue/components/DateCalendar.js.map +1 -1
- package/dist/vue/components/MAccordion.d.ts +1 -1
- package/dist/vue/components/MCombobox.d.ts +2 -2
- package/dist/vue/components/MDatePicker.d.ts +16 -16
- package/dist/vue/components/MDialog.d.ts +2 -2
- package/dist/vue/components/MFilePicker.d.ts +3 -3
- package/dist/vue/components/MImage.d.ts +1 -1
- package/dist/vue/components/MListItem.d.ts +1 -1
- package/dist/vue/components/MProgress.d.ts +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 +107 -0
- package/dist/vue/components/MRangeSlider.js.map +1 -0
- package/dist/vue/components/MReveal.d.ts +8 -8
- package/dist/vue/components/MSelect.d.ts +1 -1
- package/dist/vue/components/MSheet.d.ts +5 -5
- package/dist/vue/components/MStack.d.ts +8 -8
- package/dist/vue/components/MTimePicker.d.ts +4 -4
- 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/configurator.d.ts +2 -2
- 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 +67 -0
- package/dist/vue/components/discovery.js.map +1 -0
- package/dist/vue/components/layout.d.ts +16 -16
- package/dist/vue/components/navigation.d.ts +1 -1
- 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 +37 -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 +5 -1
- package/dist/vue/index.d.ts.map +1 -1
- package/dist/vue/index.js +17 -1
- package/dist/vue/index.js.map +1 -1
- package/package.json +3 -3
- package/src/vue/components/ChartPlot.ts +114 -0
- package/src/vue/components/ChoiceControl.ts +32 -25
- package/src/vue/components/DateCalendar.ts +11 -7
- package/src/vue/components/MRangeSlider.ts +125 -0
- package/src/vue/components/MTooltip.ts +39 -0
- package/src/vue/components/discovery.ts +92 -0
- package/src/vue/components/wayfinding.ts +46 -0
- package/src/vue/index.ts +34 -0
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { defineComponent, h, ref } from 'nativescript-vue'
|
|
2
|
+
import type { EventData, TapGestureEventData, View } from '@nativescript/core'
|
|
3
|
+
import { chartPlotProps, useMavisTheme } from '@getcortexlabs/mavis-core/vue'
|
|
4
|
+
import { chartHitTest, type ChartPoint } from '@getcortexlabs/mavis-core'
|
|
5
|
+
|
|
6
|
+
/** Bounded native geometry, without a WebView or a second animation scheduler. */
|
|
7
|
+
export const ChartPlot = defineComponent({
|
|
8
|
+
name: 'MChartPlot',
|
|
9
|
+
props: chartPlotProps,
|
|
10
|
+
emits: { select: (_category: number, _series: number) => true },
|
|
11
|
+
setup(props, { emit }) {
|
|
12
|
+
const { theme } = useMavisTheme()
|
|
13
|
+
const width = ref(0)
|
|
14
|
+
return () => {
|
|
15
|
+
const height = props.height
|
|
16
|
+
const x = (point: ChartPoint) => point.x * width.value
|
|
17
|
+
const y = (point: ChartPoint) => 8 + point.y * (height - 16)
|
|
18
|
+
const zero = 8 + props.geometry.zero * (height - 16)
|
|
19
|
+
const count = props.geometry.series[0]?.points.length ?? 0
|
|
20
|
+
const groupWidth = (width.value / Math.max(1, count)) * 0.7
|
|
21
|
+
const barWidth = groupWidth / Math.max(1, props.geometry.series.length)
|
|
22
|
+
const shape = (key: string, values: Record<string, unknown>) =>
|
|
23
|
+
h('ContentView', {
|
|
24
|
+
key,
|
|
25
|
+
accessibilityHidden: true,
|
|
26
|
+
isUserInteractionEnabled: false,
|
|
27
|
+
...values,
|
|
28
|
+
})
|
|
29
|
+
return h(
|
|
30
|
+
'AbsoluteLayout',
|
|
31
|
+
{
|
|
32
|
+
class: 'm-chart-plot',
|
|
33
|
+
height,
|
|
34
|
+
accessibilityHidden: true,
|
|
35
|
+
onLayoutChanged: (event: EventData) => {
|
|
36
|
+
const size = (event.object as View).getActualSize()
|
|
37
|
+
if (width.value !== size.width) width.value = size.width
|
|
38
|
+
},
|
|
39
|
+
onTap: (event: TapGestureEventData) => {
|
|
40
|
+
if (props.disabled || !width.value || !count) return
|
|
41
|
+
const hit = chartHitTest(
|
|
42
|
+
props.geometry,
|
|
43
|
+
props.type,
|
|
44
|
+
event.getX() / width.value,
|
|
45
|
+
(event.getY() - 8) / (height - 16),
|
|
46
|
+
)
|
|
47
|
+
if (hit) emit('select', hit.category, hit.series)
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
width.value <= 0
|
|
51
|
+
? []
|
|
52
|
+
: [
|
|
53
|
+
...props.geometry.ticks.map((_, i) =>
|
|
54
|
+
shape(`grid:${i}`, {
|
|
55
|
+
left: 0,
|
|
56
|
+
top: 8 + ((height - 16) * i) / 4,
|
|
57
|
+
width: width.value,
|
|
58
|
+
height: 1,
|
|
59
|
+
backgroundColor: theme.value.colors.border,
|
|
60
|
+
}),
|
|
61
|
+
),
|
|
62
|
+
...props.geometry.series.flatMap((series, seriesIndex) =>
|
|
63
|
+
series.points.flatMap((point, index) => {
|
|
64
|
+
if (!point) return []
|
|
65
|
+
const color = props.colors[seriesIndex]
|
|
66
|
+
const selected =
|
|
67
|
+
props.selected?.category === index && props.selected.series === seriesIndex
|
|
68
|
+
const previous = series.points[index - 1]
|
|
69
|
+
const line =
|
|
70
|
+
props.type === 'line' && previous
|
|
71
|
+
? (() => {
|
|
72
|
+
const dx = x(point) - x(previous),
|
|
73
|
+
dy = y(point) - y(previous)
|
|
74
|
+
const length = Math.hypot(dx, dy)
|
|
75
|
+
return shape(`line:${seriesIndex}:${index}`, {
|
|
76
|
+
left: (x(point) + x(previous)) / 2 - length / 2,
|
|
77
|
+
top: (y(point) + y(previous)) / 2 - 1.25,
|
|
78
|
+
width: length,
|
|
79
|
+
height: 2.5,
|
|
80
|
+
rotate: (Math.atan2(dy, dx) * 180) / Math.PI,
|
|
81
|
+
backgroundColor: color,
|
|
82
|
+
borderRadius: 1.25,
|
|
83
|
+
})
|
|
84
|
+
})()
|
|
85
|
+
: null
|
|
86
|
+
const radius = selected ? 5 : 3
|
|
87
|
+
return [
|
|
88
|
+
line,
|
|
89
|
+
props.type === 'bar'
|
|
90
|
+
? shape(`bar:${seriesIndex}:${index}`, {
|
|
91
|
+
left: x(point) - groupWidth / 2 + seriesIndex * barWidth,
|
|
92
|
+
top: Math.min(y(point), zero),
|
|
93
|
+
width: Math.max(1, barWidth * 0.82),
|
|
94
|
+
height: Math.max(1, Math.abs(zero - y(point))),
|
|
95
|
+
borderRadius: 3,
|
|
96
|
+
backgroundColor: color,
|
|
97
|
+
opacity: props.selected && !selected ? 0.45 : 1,
|
|
98
|
+
})
|
|
99
|
+
: shape(`point:${seriesIndex}:${index}`, {
|
|
100
|
+
left: x(point) - radius,
|
|
101
|
+
top: y(point) - radius,
|
|
102
|
+
width: radius * 2,
|
|
103
|
+
height: radius * 2,
|
|
104
|
+
borderRadius: radius,
|
|
105
|
+
backgroundColor: color,
|
|
106
|
+
}),
|
|
107
|
+
]
|
|
108
|
+
}),
|
|
109
|
+
),
|
|
110
|
+
],
|
|
111
|
+
)
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
})
|
|
@@ -23,7 +23,12 @@ registerElement('MavisRadioButton', () => MavisButton)
|
|
|
23
23
|
export const ChoiceControl = defineComponent({
|
|
24
24
|
name: 'ChoiceControl',
|
|
25
25
|
inheritAttrs: false,
|
|
26
|
-
props: {
|
|
26
|
+
props: {
|
|
27
|
+
...checkboxProps,
|
|
28
|
+
radio: Boolean,
|
|
29
|
+
labelHidden: Boolean,
|
|
30
|
+
pressFeedback: { type: Boolean, default: true },
|
|
31
|
+
},
|
|
27
32
|
emits: ['activate'],
|
|
28
33
|
setup(props, { attrs, emit }) {
|
|
29
34
|
const { theme } = useMavisTheme()
|
|
@@ -220,33 +225,35 @@ export const ChoiceControl = defineComponent({
|
|
|
220
225
|
: null,
|
|
221
226
|
},
|
|
222
227
|
),
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
},
|
|
230
|
-
{
|
|
231
|
-
default: () => [
|
|
232
|
-
h(MText, {
|
|
233
|
-
text: props.label,
|
|
234
|
-
accessibilityHidden: true,
|
|
228
|
+
props.labelHidden
|
|
229
|
+
? null
|
|
230
|
+
: h(
|
|
231
|
+
MColumn,
|
|
232
|
+
{
|
|
233
|
+
gap: 'xs',
|
|
235
234
|
isUserInteractionEnabled: false,
|
|
236
|
-
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
tone: 'muted',
|
|
235
|
+
accessibilityHidden: true,
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
default: () => [
|
|
239
|
+
h(MText, {
|
|
240
|
+
text: props.label,
|
|
243
241
|
accessibilityHidden: true,
|
|
244
242
|
isUserInteractionEnabled: false,
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
243
|
+
style: { fontWeight: '600' },
|
|
244
|
+
}),
|
|
245
|
+
props.helperText
|
|
246
|
+
? h(MText, {
|
|
247
|
+
text: props.helperText,
|
|
248
|
+
variant: 'caption',
|
|
249
|
+
tone: 'muted',
|
|
250
|
+
accessibilityHidden: true,
|
|
251
|
+
isUserInteractionEnabled: false,
|
|
252
|
+
})
|
|
253
|
+
: null,
|
|
254
|
+
],
|
|
255
|
+
},
|
|
256
|
+
),
|
|
250
257
|
],
|
|
251
258
|
},
|
|
252
259
|
),
|
|
@@ -34,7 +34,7 @@ export const DateCalendar = defineComponent({
|
|
|
34
34
|
icon: 'chevron-left',
|
|
35
35
|
variant: 'ghost',
|
|
36
36
|
accessibilityLabel: calendar.words.value.previous,
|
|
37
|
-
disabled: !calendar.canPage(-1),
|
|
37
|
+
disabled: props.disabled || !calendar.canPage(-1),
|
|
38
38
|
onClick: () => calendar.page(-1),
|
|
39
39
|
}),
|
|
40
40
|
h(MText, {
|
|
@@ -47,7 +47,7 @@ export const DateCalendar = defineComponent({
|
|
|
47
47
|
icon: 'chevron-right',
|
|
48
48
|
variant: 'ghost',
|
|
49
49
|
accessibilityLabel: calendar.words.value.next,
|
|
50
|
-
disabled: !calendar.canPage(1),
|
|
50
|
+
disabled: props.disabled || !calendar.canPage(1),
|
|
51
51
|
onClick: () => calendar.page(1),
|
|
52
52
|
}),
|
|
53
53
|
],
|
|
@@ -73,12 +73,15 @@ export const DateCalendar = defineComponent({
|
|
|
73
73
|
variant: 'caption',
|
|
74
74
|
tone: 'muted',
|
|
75
75
|
accessibilityLabel: calendar.words.value.weekdays[weekday],
|
|
76
|
-
style: { minWidth:
|
|
76
|
+
style: { minWidth: 44, textAlignment: 'center', padding: 8 },
|
|
77
77
|
}),
|
|
78
78
|
),
|
|
79
79
|
...calendar.cells.value.map((date, index) => {
|
|
80
80
|
if (!date) return null
|
|
81
|
-
const selected =
|
|
81
|
+
const selected =
|
|
82
|
+
date === props.selected ||
|
|
83
|
+
date === props.rangeStart ||
|
|
84
|
+
date === props.rangeEnd
|
|
82
85
|
return h(MButton, {
|
|
83
86
|
key: date,
|
|
84
87
|
row: Math.floor(index / 7) + 1,
|
|
@@ -87,9 +90,9 @@ export const DateCalendar = defineComponent({
|
|
|
87
90
|
variant: 'ghost',
|
|
88
91
|
accessibilityLabel: calendarDayLabel(date, props.locale),
|
|
89
92
|
accessibilityValue: selected ? calendar.words.value.selected : '',
|
|
90
|
-
disabled: !calendar.available(date),
|
|
93
|
+
disabled: props.disabled || props.readonly || !calendar.available(date),
|
|
91
94
|
style: {
|
|
92
|
-
minWidth:
|
|
95
|
+
minWidth: 44,
|
|
93
96
|
minHeight: 48,
|
|
94
97
|
margin: 1,
|
|
95
98
|
paddingLeft: 6,
|
|
@@ -102,7 +105,8 @@ export const DateCalendar = defineComponent({
|
|
|
102
105
|
color: colors.text,
|
|
103
106
|
},
|
|
104
107
|
onClick: () => {
|
|
105
|
-
if (calendar.available(date))
|
|
108
|
+
if (!props.disabled && !props.readonly && calendar.available(date))
|
|
109
|
+
emit('select', date)
|
|
106
110
|
},
|
|
107
111
|
})
|
|
108
112
|
}),
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { computed, defineComponent, h, markRaw, mergeProps, ref } from 'nativescript-vue'
|
|
2
|
+
import type { EventData, PanGestureEventData, View } from '@nativescript/core'
|
|
3
|
+
import { moveRange, rangeValue, type RangeValue } from '@getcortexlabs/mavis-core'
|
|
4
|
+
import { createMotionSurface } from '@getcortexlabs/mavis-core/experimental'
|
|
5
|
+
import { rangeSliderProps, useMavisTheme } from '@getcortexlabs/mavis-core/vue'
|
|
6
|
+
import { MColumn, MRow, MBox } from './layout.js'
|
|
7
|
+
import { MText } from './MText.js'
|
|
8
|
+
import { MNumberInput } from './configurator.js'
|
|
9
|
+
|
|
10
|
+
/** Large touch handles plus labelled native editors for precise and assistive input. */
|
|
11
|
+
export const MRangeSlider = defineComponent({
|
|
12
|
+
name: 'MRangeSlider',
|
|
13
|
+
inheritAttrs: false,
|
|
14
|
+
props: rangeSliderProps,
|
|
15
|
+
emits: { 'update:modelValue': (_value: RangeValue) => true },
|
|
16
|
+
setup(props, { attrs, emit }) {
|
|
17
|
+
const { theme } = useMavisTheme()
|
|
18
|
+
const width = ref(0)
|
|
19
|
+
const surfaces = [markRaw(createMotionSurface()), markRaw(createMotionSurface())]
|
|
20
|
+
const pair = computed(() => rangeValue(props.modelValue, props.min, props.max, props.step))
|
|
21
|
+
const origins = [0, 0]
|
|
22
|
+
const format = (value: number) => props.formatValue?.(value) ?? String(value)
|
|
23
|
+
function update(thumb: 0 | 1, value: number | null) {
|
|
24
|
+
if (value === null || props.disabled || props.readonly) return
|
|
25
|
+
const next = moveRange(pair.value, thumb, value, props.min, props.max, props.step)
|
|
26
|
+
if (next[thumb] !== pair.value[thumb]) emit('update:modelValue', next)
|
|
27
|
+
}
|
|
28
|
+
return () => {
|
|
29
|
+
const travel = Math.max(0, width.value - 48)
|
|
30
|
+
const position = (value: number) => ((value - props.min) / (props.max - props.min)) * travel
|
|
31
|
+
return h(MColumn, mergeProps({ id: props.id, gap: 'sm' }, attrs), () => [
|
|
32
|
+
h(MRow, { justify: 'between', gap: 'md', wrap: true }, () => [
|
|
33
|
+
h(MText, { text: props.label, weight: '600' }),
|
|
34
|
+
h(MText, { text: `${format(pair.value[0])} – ${format(pair.value[1])}`, tone: 'muted' }),
|
|
35
|
+
]),
|
|
36
|
+
h(
|
|
37
|
+
'AbsoluteLayout',
|
|
38
|
+
{
|
|
39
|
+
height: 56,
|
|
40
|
+
onLayoutChanged: (event: EventData) => {
|
|
41
|
+
width.value = (event.object as View).getActualSize().width
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
[
|
|
45
|
+
h('StackLayout', {
|
|
46
|
+
left: 24,
|
|
47
|
+
top: 25,
|
|
48
|
+
width: travel,
|
|
49
|
+
height: 6,
|
|
50
|
+
borderRadius: 3,
|
|
51
|
+
backgroundColor: theme.value.colors.border,
|
|
52
|
+
accessibilityHidden: true,
|
|
53
|
+
}),
|
|
54
|
+
h('StackLayout', {
|
|
55
|
+
left: 24 + position(pair.value[0]),
|
|
56
|
+
top: 25,
|
|
57
|
+
width: position(pair.value[1]) - position(pair.value[0]),
|
|
58
|
+
height: 6,
|
|
59
|
+
borderRadius: 3,
|
|
60
|
+
backgroundColor: theme.value.colors.primary,
|
|
61
|
+
accessibilityHidden: true,
|
|
62
|
+
}),
|
|
63
|
+
...([0, 1] as const).map((thumb) =>
|
|
64
|
+
h(
|
|
65
|
+
MBox,
|
|
66
|
+
{
|
|
67
|
+
key: thumb,
|
|
68
|
+
left: position(pair.value[thumb]),
|
|
69
|
+
top: 4,
|
|
70
|
+
width: 48,
|
|
71
|
+
height: 48,
|
|
72
|
+
accessibilityHidden: true,
|
|
73
|
+
onPan: (event: PanGestureEventData) => {
|
|
74
|
+
if (props.disabled || props.readonly || !travel) return
|
|
75
|
+
const motion = surfaces[thumb]!
|
|
76
|
+
if (event.state === 1) {
|
|
77
|
+
origins[thumb] = pair.value[thumb]
|
|
78
|
+
if (motion.available) motion.animate({ scale: 1.15 }, { duration: 120 })
|
|
79
|
+
}
|
|
80
|
+
if (event.state === 2)
|
|
81
|
+
update(
|
|
82
|
+
thumb,
|
|
83
|
+
origins[thumb]! + (event.deltaX / travel) * (props.max - props.min),
|
|
84
|
+
)
|
|
85
|
+
if (event.state === 3 || event.state === 4) {
|
|
86
|
+
if (motion.available)
|
|
87
|
+
motion.animate(
|
|
88
|
+
{ scale: 1 },
|
|
89
|
+
{ type: 'spring', duration: 180, bounce: 0.15 },
|
|
90
|
+
)
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
() =>
|
|
95
|
+
h(MBox, {
|
|
96
|
+
motionSurface: surfaces[thumb],
|
|
97
|
+
width: 26,
|
|
98
|
+
height: 26,
|
|
99
|
+
radius: 'full',
|
|
100
|
+
backgroundColor: theme.value.colors.primary,
|
|
101
|
+
horizontalAlignment: 'center',
|
|
102
|
+
verticalAlignment: 'middle',
|
|
103
|
+
}),
|
|
104
|
+
),
|
|
105
|
+
),
|
|
106
|
+
],
|
|
107
|
+
),
|
|
108
|
+
h(MColumn, { gap: 'md' }, () =>
|
|
109
|
+
([0, 1] as const).map((thumb) =>
|
|
110
|
+
h(MNumberInput, {
|
|
111
|
+
label: thumb === 0 ? props.lowerLabel : props.upperLabel,
|
|
112
|
+
modelValue: pair.value[thumb],
|
|
113
|
+
min: thumb === 0 ? props.min : pair.value[0],
|
|
114
|
+
max: thumb === 0 ? pair.value[1] : props.max,
|
|
115
|
+
step: props.step,
|
|
116
|
+
disabled: props.disabled,
|
|
117
|
+
readonly: props.readonly,
|
|
118
|
+
'onUpdate:modelValue': (value: number | null) => update(thumb, value),
|
|
119
|
+
}),
|
|
120
|
+
),
|
|
121
|
+
),
|
|
122
|
+
])
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
})
|
|
@@ -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,92 @@
|
|
|
1
|
+
import { h, type Component } from 'nativescript-vue'
|
|
2
|
+
import type { SwipeGestureEventData } from '@nativescript/core'
|
|
3
|
+
import {
|
|
4
|
+
createDiscoveryControls,
|
|
5
|
+
createCarousel,
|
|
6
|
+
createTreeView,
|
|
7
|
+
createDataTable,
|
|
8
|
+
} from '@getcortexlabs/mavis-core/vue'
|
|
9
|
+
import { MRow, MColumn, MBox } from './layout.js'
|
|
10
|
+
import { MText } from './MText.js'
|
|
11
|
+
import { MButton } from './MButton.js'
|
|
12
|
+
import { MIcon } from './MIcon.js'
|
|
13
|
+
import { MSlider } from './MSlider.js'
|
|
14
|
+
import { MCheckbox } from './MCheckbox.js'
|
|
15
|
+
import { MProgress } from './MProgress.js'
|
|
16
|
+
import { MReveal } from './MReveal.js'
|
|
17
|
+
import { DateCalendar } from './DateCalendar.js'
|
|
18
|
+
const ui = {
|
|
19
|
+
Row: MRow,
|
|
20
|
+
Column: MColumn,
|
|
21
|
+
Box: MBox,
|
|
22
|
+
Text: MText,
|
|
23
|
+
Button: MButton,
|
|
24
|
+
Icon: MIcon,
|
|
25
|
+
Slider: MSlider,
|
|
26
|
+
Checkbox: MCheckbox,
|
|
27
|
+
Progress: MProgress,
|
|
28
|
+
Reveal: MReveal,
|
|
29
|
+
Calendar: DateCalendar,
|
|
30
|
+
}
|
|
31
|
+
export const { MCalendar, MRating } = createDiscoveryControls(ui, 'native')
|
|
32
|
+
export const MTreeView = createTreeView(ui, 'native')
|
|
33
|
+
export const MCarousel = createCarousel(
|
|
34
|
+
{
|
|
35
|
+
...ui,
|
|
36
|
+
gestures: (move) => ({
|
|
37
|
+
onSwipe: (event: SwipeGestureEventData) => {
|
|
38
|
+
if (event.direction === 2) move(1)
|
|
39
|
+
else if (event.direction === 1) move(-1)
|
|
40
|
+
},
|
|
41
|
+
}),
|
|
42
|
+
},
|
|
43
|
+
'native',
|
|
44
|
+
)
|
|
45
|
+
export const MDataTable = createDataTable(
|
|
46
|
+
{
|
|
47
|
+
...ui,
|
|
48
|
+
Checkbox: (props: Record<string, unknown>) =>
|
|
49
|
+
h(MCheckbox as Component, { ...props, labelHidden: true }),
|
|
50
|
+
table: (columns, header, rows, label) =>
|
|
51
|
+
h('ScrollView', { orientation: 'horizontal', accessibilityLabel: label }, [
|
|
52
|
+
h('StackLayout', { verticalAlignment: 'top', horizontalAlignment: 'left' }, [
|
|
53
|
+
h(
|
|
54
|
+
'GridLayout',
|
|
55
|
+
{
|
|
56
|
+
columns: columns.map((column) => column.width ?? 160).join(','),
|
|
57
|
+
rows: 'auto',
|
|
58
|
+
padding: 8,
|
|
59
|
+
},
|
|
60
|
+
header.map((content, index) =>
|
|
61
|
+
h('StackLayout', { col: index, padding: 8, verticalAlignment: 'middle' }, [content]),
|
|
62
|
+
),
|
|
63
|
+
),
|
|
64
|
+
...rows.map((row) =>
|
|
65
|
+
h(
|
|
66
|
+
'GridLayout',
|
|
67
|
+
{
|
|
68
|
+
key: row.key,
|
|
69
|
+
columns: columns.map((column) => column.width ?? 160).join(','),
|
|
70
|
+
rows: 'auto',
|
|
71
|
+
padding: 8,
|
|
72
|
+
},
|
|
73
|
+
row.cells.map((content, index) =>
|
|
74
|
+
h('StackLayout', { col: index, padding: 8, verticalAlignment: 'middle' }, [
|
|
75
|
+
columns[index]!.label
|
|
76
|
+
? h(MText, {
|
|
77
|
+
text: columns[index]!.label,
|
|
78
|
+
variant: 'caption',
|
|
79
|
+
tone: 'muted',
|
|
80
|
+
align: columns[index]!.align === 'end' ? 'right' : 'left',
|
|
81
|
+
})
|
|
82
|
+
: null,
|
|
83
|
+
content,
|
|
84
|
+
]),
|
|
85
|
+
),
|
|
86
|
+
),
|
|
87
|
+
),
|
|
88
|
+
]),
|
|
89
|
+
]),
|
|
90
|
+
},
|
|
91
|
+
'native',
|
|
92
|
+
)
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createChart,
|
|
3
|
+
createCommandPalette,
|
|
4
|
+
createWayfindingControls,
|
|
5
|
+
} from '@getcortexlabs/mavis-core/vue'
|
|
6
|
+
import type { View } from '@nativescript/core'
|
|
7
|
+
import { MRow, MColumn, MBox } from './layout.js'
|
|
8
|
+
import { MText } from './MText.js'
|
|
9
|
+
import { MButton } from './MButton.js'
|
|
10
|
+
import { MLink } from './MLink.js'
|
|
11
|
+
import { MIcon } from './MIcon.js'
|
|
12
|
+
import { MBadge } from './MBadge.js'
|
|
13
|
+
import { MSeparator } from './MSeparator.js'
|
|
14
|
+
import { MSheet } from './MSheet.js'
|
|
15
|
+
import { MInput } from './MInput.js'
|
|
16
|
+
import { MSelect } from './MSelect.js'
|
|
17
|
+
import { MReveal } from './MReveal.js'
|
|
18
|
+
import { ChartPlot } from './ChartPlot.js'
|
|
19
|
+
const ui = {
|
|
20
|
+
focus: (component: unknown) =>
|
|
21
|
+
(component as { $el?: { nativeView?: View } } | undefined)?.$el?.nativeView?.focus(),
|
|
22
|
+
Row: MRow,
|
|
23
|
+
Column: MColumn,
|
|
24
|
+
Box: MBox,
|
|
25
|
+
Text: MText,
|
|
26
|
+
Button: MButton,
|
|
27
|
+
Link: MLink,
|
|
28
|
+
Icon: MIcon,
|
|
29
|
+
Badge: MBadge,
|
|
30
|
+
Separator: MSeparator,
|
|
31
|
+
Sheet: MSheet,
|
|
32
|
+
Input: MInput,
|
|
33
|
+
Select: MSelect,
|
|
34
|
+
Reveal: MReveal,
|
|
35
|
+
Plot: ChartPlot,
|
|
36
|
+
}
|
|
37
|
+
export const { MNavigationRail, MBreadcrumb, MTimeline } = createWayfindingControls(ui, 'native')
|
|
38
|
+
export const MChart = createChart(ui, 'native')
|
|
39
|
+
export const MCommandPalette = createCommandPalette(
|
|
40
|
+
{
|
|
41
|
+
...ui,
|
|
42
|
+
focus: (component) =>
|
|
43
|
+
(component as { $el?: { nativeView?: View } } | undefined)?.$el?.nativeView?.focus(),
|
|
44
|
+
},
|
|
45
|
+
'native',
|
|
46
|
+
)
|
package/src/vue/index.ts
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
import {
|
|
2
|
+
MCommandPalette,
|
|
3
|
+
MNavigationRail,
|
|
4
|
+
MBreadcrumb,
|
|
5
|
+
MTimeline,
|
|
6
|
+
MChart,
|
|
7
|
+
} from './components/wayfinding.js'
|
|
8
|
+
import { MTooltip } from './components/MTooltip.js'
|
|
9
|
+
import { MDataTable, MCarousel, MCalendar, MRating, MTreeView } from './components/discovery.js'
|
|
10
|
+
import { MRangeSlider } from './components/MRangeSlider.js'
|
|
1
11
|
import { MPopover } from './components/MPopover.js'
|
|
2
12
|
import { MMenu, MAppBar, MTabBar } from './components/navigation.js'
|
|
3
13
|
import { MTimePicker } from './components/MTimePicker.js'
|
|
@@ -100,6 +110,18 @@ export {
|
|
|
100
110
|
MTabBar,
|
|
101
111
|
MTimePicker,
|
|
102
112
|
MVirtualList,
|
|
113
|
+
MDataTable,
|
|
114
|
+
MCarousel,
|
|
115
|
+
MRangeSlider,
|
|
116
|
+
MCalendar,
|
|
117
|
+
MRating,
|
|
118
|
+
MTreeView,
|
|
119
|
+
MCommandPalette,
|
|
120
|
+
MNavigationRail,
|
|
121
|
+
MBreadcrumb,
|
|
122
|
+
MTooltip,
|
|
123
|
+
MTimeline,
|
|
124
|
+
MChart,
|
|
103
125
|
}
|
|
104
126
|
export {
|
|
105
127
|
useMavisTheme,
|
|
@@ -189,6 +211,18 @@ export function createMavis(options: MavisOptions = {}) {
|
|
|
189
211
|
MTabBar,
|
|
190
212
|
MTimePicker,
|
|
191
213
|
MVirtualList,
|
|
214
|
+
MDataTable,
|
|
215
|
+
MCarousel,
|
|
216
|
+
MRangeSlider,
|
|
217
|
+
MCalendar,
|
|
218
|
+
MRating,
|
|
219
|
+
MTreeView,
|
|
220
|
+
MCommandPalette,
|
|
221
|
+
MNavigationRail,
|
|
222
|
+
MBreadcrumb,
|
|
223
|
+
MTooltip,
|
|
224
|
+
MTimeline,
|
|
225
|
+
MChart,
|
|
192
226
|
},
|
|
193
227
|
)) {
|
|
194
228
|
app.component(name, component)
|