@getcortexlabs/mavis 0.1.0-rc.11.1 → 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 +5 -5
- package/dist/vue/components/MChip.d.ts +1 -1
- package/dist/vue/components/MCombobox.d.ts +1 -1
- package/dist/vue/components/MDialog.d.ts +2 -2
- package/dist/vue/components/MFilePicker.d.ts +3 -3
- package/dist/vue/components/MListItem.d.ts +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.map +1 -1
- package/dist/vue/components/MPopover.js +23 -11
- package/dist/vue/components/MPopover.js.map +1 -1
- package/dist/vue/components/MStack.d.ts +6 -6
- package/dist/vue/components/MTimePicker.d.ts +4 -4
- package/dist/vue/components/configurator.d.ts +1 -1
- 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 +2 -2
- 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/index.d.ts +4 -1
- package/dist/vue/index.d.ts.map +1 -1
- package/dist/vue/index.js +23 -1
- package/dist/vue/index.js.map +1 -1
- package/package.json +3 -3
- package/src/vue/components/MPinInput.ts +145 -0
- package/src/vue/components/MPopover.ts +20 -11
- package/src/vue/components/creative.ts +246 -0
- package/src/vue/components/dashboard.ts +249 -0
- package/src/vue/components/screen-components.ts +61 -0
- package/src/vue/index.ts +64 -0
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defineComponent,
|
|
3
|
+
h,
|
|
4
|
+
inject,
|
|
5
|
+
markRaw,
|
|
6
|
+
mergeProps,
|
|
7
|
+
onBeforeUnmount,
|
|
8
|
+
onDeactivated,
|
|
9
|
+
onScopeDispose,
|
|
10
|
+
watch,
|
|
11
|
+
} from 'nativescript-vue'
|
|
12
|
+
import {
|
|
13
|
+
Application,
|
|
14
|
+
type View,
|
|
15
|
+
type EventData,
|
|
16
|
+
type PanGestureEventData,
|
|
17
|
+
} from '@nativescript/core'
|
|
18
|
+
import { notifyAccessibilityLayout } from '../../native/accessibility-layout'
|
|
19
|
+
import { reducedMotion, onReducedMotion } from '@rafaelaugusto/jolt'
|
|
20
|
+
import {
|
|
21
|
+
createDashboardShape,
|
|
22
|
+
createDonutChart,
|
|
23
|
+
createSparkline,
|
|
24
|
+
createDashboardEffects,
|
|
25
|
+
createKanban,
|
|
26
|
+
dashboardEnvironmentProps,
|
|
27
|
+
dashboardPlotProps,
|
|
28
|
+
kanbanRegistryKey,
|
|
29
|
+
kanbanZoneProps,
|
|
30
|
+
kanbanDragProps,
|
|
31
|
+
} from '@getcortexlabs/mavis-core/vue'
|
|
32
|
+
import { createMotionSurface } from '@getcortexlabs/mavis-core/experimental'
|
|
33
|
+
import { MBox, MColumn, MRow } from './layout.js'
|
|
34
|
+
import { MStack } from './MStack.js'
|
|
35
|
+
import { MText } from './MText.js'
|
|
36
|
+
import { MButton } from './MButton.js'
|
|
37
|
+
import { MNumberFlow } from './interactive.js'
|
|
38
|
+
import { MMenu } from './navigation.js'
|
|
39
|
+
|
|
40
|
+
const Fallback = defineComponent({
|
|
41
|
+
setup: () => () => h('GridLayout', { accessible: false, isUserInteractionEnabled: false }),
|
|
42
|
+
})
|
|
43
|
+
const Environment = defineComponent({
|
|
44
|
+
inheritAttrs: false,
|
|
45
|
+
props: dashboardEnvironmentProps,
|
|
46
|
+
emits: ['environment'],
|
|
47
|
+
setup(_props, { attrs, slots, emit }) {
|
|
48
|
+
let attached = false,
|
|
49
|
+
suspended = false,
|
|
50
|
+
release = () => {}
|
|
51
|
+
const update = () =>
|
|
52
|
+
emit('environment', { reduced: reducedMotion(), paused: !attached || suspended })
|
|
53
|
+
const suspend = () => {
|
|
54
|
+
suspended = true
|
|
55
|
+
update()
|
|
56
|
+
},
|
|
57
|
+
resume = () => {
|
|
58
|
+
suspended = false
|
|
59
|
+
update()
|
|
60
|
+
}
|
|
61
|
+
function detach() {
|
|
62
|
+
attached = false
|
|
63
|
+
release()
|
|
64
|
+
release = () => {}
|
|
65
|
+
Application.off(Application.suspendEvent, suspend)
|
|
66
|
+
Application.off(Application.resumeEvent, resume)
|
|
67
|
+
update()
|
|
68
|
+
}
|
|
69
|
+
function attach() {
|
|
70
|
+
if (attached) return
|
|
71
|
+
attached = true
|
|
72
|
+
release = onReducedMotion(update)
|
|
73
|
+
Application.on(Application.suspendEvent, suspend)
|
|
74
|
+
Application.on(Application.resumeEvent, resume)
|
|
75
|
+
update()
|
|
76
|
+
}
|
|
77
|
+
onBeforeUnmount(detach)
|
|
78
|
+
onDeactivated(detach)
|
|
79
|
+
return () =>
|
|
80
|
+
h(
|
|
81
|
+
'GridLayout',
|
|
82
|
+
mergeProps(attrs, { width: '100%', onLoaded: attach, onUnloaded: detach }),
|
|
83
|
+
slots.default?.(),
|
|
84
|
+
)
|
|
85
|
+
},
|
|
86
|
+
})
|
|
87
|
+
function rect(view?: View) {
|
|
88
|
+
if (!view?.isLoaded) return
|
|
89
|
+
const p = view.getLocationOnScreen(),
|
|
90
|
+
size = view.getActualSize()
|
|
91
|
+
return p ? { ...p, ...size } : undefined
|
|
92
|
+
}
|
|
93
|
+
const Zone = defineComponent({
|
|
94
|
+
inheritAttrs: false,
|
|
95
|
+
props: kanbanZoneProps,
|
|
96
|
+
setup(props, { attrs, slots }) {
|
|
97
|
+
const registry = inject(kanbanRegistryKey)!
|
|
98
|
+
let view: View | undefined
|
|
99
|
+
onBeforeUnmount(() => registry.zones.delete(props.column))
|
|
100
|
+
return () =>
|
|
101
|
+
h(
|
|
102
|
+
'GridLayout',
|
|
103
|
+
mergeProps(attrs, {
|
|
104
|
+
onLoaded: (e: EventData) => {
|
|
105
|
+
view = e.object as View
|
|
106
|
+
registry.zones.set(props.column, () => rect(view))
|
|
107
|
+
},
|
|
108
|
+
onUnloaded: () => {
|
|
109
|
+
view = undefined
|
|
110
|
+
registry.zones.delete(props.column)
|
|
111
|
+
},
|
|
112
|
+
}),
|
|
113
|
+
slots.default?.(),
|
|
114
|
+
)
|
|
115
|
+
},
|
|
116
|
+
})
|
|
117
|
+
const Drag = defineComponent({
|
|
118
|
+
inheritAttrs: false,
|
|
119
|
+
props: kanbanDragProps,
|
|
120
|
+
setup(props, { attrs, slots }) {
|
|
121
|
+
const registry = inject(kanbanRegistryKey)!,
|
|
122
|
+
surface = markRaw(createMotionSurface())
|
|
123
|
+
let view: View | undefined,
|
|
124
|
+
anchor: ReturnType<typeof rect>,
|
|
125
|
+
dragging = false
|
|
126
|
+
function end(commit = false) {
|
|
127
|
+
const was = dragging
|
|
128
|
+
dragging = false
|
|
129
|
+
if (surface.available) {
|
|
130
|
+
if (props.animated && !commit)
|
|
131
|
+
surface.animate({ x: 0, y: 0, scale: 1 }, { type: 'spring', duration: 280, bounce: 0.12 })
|
|
132
|
+
else surface.set({ x: 0, y: 0, scale: 1 })
|
|
133
|
+
}
|
|
134
|
+
if (view) view.style.zIndex = 0
|
|
135
|
+
if (was) registry.finish(commit)
|
|
136
|
+
}
|
|
137
|
+
const cancel = () => end(false)
|
|
138
|
+
onBeforeUnmount(() => {
|
|
139
|
+
cancel()
|
|
140
|
+
registry.cards.delete(props.cardId)
|
|
141
|
+
registry.focus.delete(props.cardId)
|
|
142
|
+
})
|
|
143
|
+
onDeactivated(cancel)
|
|
144
|
+
onScopeDispose(surface.use(() => cancel))
|
|
145
|
+
watch(
|
|
146
|
+
() => props.disabled,
|
|
147
|
+
(value) => {
|
|
148
|
+
if (value) cancel()
|
|
149
|
+
},
|
|
150
|
+
)
|
|
151
|
+
return () =>
|
|
152
|
+
h(
|
|
153
|
+
'GridLayout',
|
|
154
|
+
mergeProps(attrs, {
|
|
155
|
+
onLoaded: (e: EventData) => {
|
|
156
|
+
view = e.object as View
|
|
157
|
+
registry.cards.set(props.cardId, () => rect(view))
|
|
158
|
+
registry.focus.set(props.cardId, () => {
|
|
159
|
+
if (view) notifyAccessibilityLayout(view)
|
|
160
|
+
})
|
|
161
|
+
},
|
|
162
|
+
onUnloaded: () => {
|
|
163
|
+
cancel()
|
|
164
|
+
view = undefined
|
|
165
|
+
registry.cards.delete(props.cardId)
|
|
166
|
+
registry.focus.delete(props.cardId)
|
|
167
|
+
},
|
|
168
|
+
}),
|
|
169
|
+
[
|
|
170
|
+
h(MBox, { motionSurface: surface }, () =>
|
|
171
|
+
h(MColumn, { gap: 'xs' }, () => [
|
|
172
|
+
h(
|
|
173
|
+
MBox,
|
|
174
|
+
{
|
|
175
|
+
height: 36,
|
|
176
|
+
accessibilityHidden: true,
|
|
177
|
+
accessibilityLabel: props.label,
|
|
178
|
+
opacity: props.disabled ? 0.4 : 0.65,
|
|
179
|
+
onPan: (e: PanGestureEventData) => {
|
|
180
|
+
if (props.disabled) return
|
|
181
|
+
if (e.state === 1) {
|
|
182
|
+
anchor = rect(view)
|
|
183
|
+
dragging = registry.begin(props.cardId, cancel)
|
|
184
|
+
if (dragging && view) view.style.zIndex = 20
|
|
185
|
+
}
|
|
186
|
+
if (e.state === 2 && dragging && surface.available) {
|
|
187
|
+
const current = rect(view)
|
|
188
|
+
surface.set({
|
|
189
|
+
x: e.deltaX + (anchor && current ? anchor.x - current.x : 0),
|
|
190
|
+
y: e.deltaY + (anchor && current ? anchor.y - current.y : 0),
|
|
191
|
+
scale: 1.02,
|
|
192
|
+
})
|
|
193
|
+
registry.move(e.deltaX, e.deltaY)
|
|
194
|
+
}
|
|
195
|
+
if (e.state === 3) end(true)
|
|
196
|
+
if (e.state === 4) cancel()
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
() => h(MText, { text: '⠿', textAlignment: 'center' }),
|
|
200
|
+
),
|
|
201
|
+
...(slots.default?.() ?? []),
|
|
202
|
+
]),
|
|
203
|
+
),
|
|
204
|
+
],
|
|
205
|
+
)
|
|
206
|
+
},
|
|
207
|
+
})
|
|
208
|
+
const Plot = defineComponent({
|
|
209
|
+
inheritAttrs: false,
|
|
210
|
+
props: dashboardPlotProps,
|
|
211
|
+
emits: ['width'],
|
|
212
|
+
setup(props, { attrs, slots, emit }) {
|
|
213
|
+
const measure = (event: EventData) =>
|
|
214
|
+
emit('width', (event.object as View).getActualSize().width)
|
|
215
|
+
return () =>
|
|
216
|
+
h(
|
|
217
|
+
'GridLayout',
|
|
218
|
+
mergeProps(attrs, {
|
|
219
|
+
height: props.height,
|
|
220
|
+
width: '100%',
|
|
221
|
+
clipToBounds: true,
|
|
222
|
+
accessible: false,
|
|
223
|
+
isUserInteractionEnabled: false,
|
|
224
|
+
onLoaded: measure,
|
|
225
|
+
onLayoutChanged: measure,
|
|
226
|
+
}),
|
|
227
|
+
slots.default?.(),
|
|
228
|
+
)
|
|
229
|
+
},
|
|
230
|
+
})
|
|
231
|
+
const ui = {
|
|
232
|
+
Box: MBox,
|
|
233
|
+
Column: MColumn,
|
|
234
|
+
Row: MRow,
|
|
235
|
+
Stack: MStack,
|
|
236
|
+
Text: MText,
|
|
237
|
+
Button: MButton,
|
|
238
|
+
NumberFlow: MNumberFlow,
|
|
239
|
+
Shape: createDashboardShape(MBox, Fallback, 'native'),
|
|
240
|
+
Environment,
|
|
241
|
+
Plot,
|
|
242
|
+
}
|
|
243
|
+
export const MDonutChart = createDonutChart(ui, 'native')
|
|
244
|
+
export const MSparkline = createSparkline(ui, 'native')
|
|
245
|
+
export const { MGradientBackground, MParticleField, MConfetti } = createDashboardEffects(
|
|
246
|
+
ui,
|
|
247
|
+
'native',
|
|
248
|
+
)
|
|
249
|
+
export const MKanban = createKanban({ ...ui, Zone, Drag, Menu: MMenu }, 'native')
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { defineComponent, h, mergeProps, registerElement } from 'nativescript-vue'
|
|
2
|
+
import { ScrollHeaderSurface } from '@rafaelaugusto/jolt'
|
|
3
|
+
import {
|
|
4
|
+
createAnimatedText,
|
|
5
|
+
createComposer,
|
|
6
|
+
createSpeedDial,
|
|
7
|
+
createScrollComponents,
|
|
8
|
+
scrollFrameHostProps,
|
|
9
|
+
} from '@getcortexlabs/mavis-core/vue'
|
|
10
|
+
import { useMotionRegion } from '../use-motion-region.js'
|
|
11
|
+
import { useScrollMotion } from '../use-scroll-motion.js'
|
|
12
|
+
import { MBox, MColumn, MRow } from './layout.js'
|
|
13
|
+
import { MCard } from './MCard.js'
|
|
14
|
+
import { MText } from './MText.js'
|
|
15
|
+
import { MInput } from './MInput.js'
|
|
16
|
+
import { MImage } from './MImage.js'
|
|
17
|
+
import { MButton } from './MButton.js'
|
|
18
|
+
import { MChip } from './MChip.js'
|
|
19
|
+
import { MPopover } from './MPopover.js'
|
|
20
|
+
|
|
21
|
+
registerElement('MavisRefreshFrame', () => ScrollHeaderSurface, { viewFlags: 4 })
|
|
22
|
+
const Frame = defineComponent({
|
|
23
|
+
name: 'MScrollFrameHost',
|
|
24
|
+
inheritAttrs: false,
|
|
25
|
+
props: scrollFrameHostProps,
|
|
26
|
+
setup(props, { attrs, slots }) {
|
|
27
|
+
const motion = useMotionRegion(() => props.region)
|
|
28
|
+
const scroll = useScrollMotion(() => props.source)
|
|
29
|
+
return () =>
|
|
30
|
+
h(
|
|
31
|
+
'MavisRefreshFrame',
|
|
32
|
+
mergeProps(attrs, motion, { height: props.height, clipToBounds: true }),
|
|
33
|
+
[
|
|
34
|
+
h(
|
|
35
|
+
'ScrollView',
|
|
36
|
+
{ ...scroll, accessibilityLabel: props.label, iosOverflowSafeArea: false },
|
|
37
|
+
[h('StackLayout', { paddingTop: 0 }, slots.default?.())],
|
|
38
|
+
),
|
|
39
|
+
slots.overlay?.(),
|
|
40
|
+
],
|
|
41
|
+
)
|
|
42
|
+
},
|
|
43
|
+
})
|
|
44
|
+
const ui = {
|
|
45
|
+
Box: MBox,
|
|
46
|
+
Card: MCard,
|
|
47
|
+
Column: MColumn,
|
|
48
|
+
Row: MRow,
|
|
49
|
+
Text: MText,
|
|
50
|
+
Input: MInput,
|
|
51
|
+
Button: MButton,
|
|
52
|
+
Chip: MChip,
|
|
53
|
+
Image: MImage,
|
|
54
|
+
Popover: MPopover,
|
|
55
|
+
Frame,
|
|
56
|
+
}
|
|
57
|
+
export const MAnimatedText = createAnimatedText(MText)
|
|
58
|
+
export const MComposer = createComposer(ui, 'native')
|
|
59
|
+
export const MSpeedDial = createSpeedDial(ui)
|
|
60
|
+
export const { MCollapsibleHeader, MRefreshControl } = createScrollComponents(ui, 'native')
|
|
61
|
+
export { MPinInput } from './MPinInput.js'
|
package/src/vue/index.ts
CHANGED
|
@@ -1,3 +1,28 @@
|
|
|
1
|
+
import {
|
|
2
|
+
MKanban,
|
|
3
|
+
MDonutChart,
|
|
4
|
+
MSparkline,
|
|
5
|
+
MGradientBackground,
|
|
6
|
+
MParticleField,
|
|
7
|
+
MConfetti,
|
|
8
|
+
} from './components/dashboard.js'
|
|
9
|
+
import {
|
|
10
|
+
MColorPicker,
|
|
11
|
+
MSwipeDeck,
|
|
12
|
+
MGauge,
|
|
13
|
+
MTour,
|
|
14
|
+
MTourTarget,
|
|
15
|
+
MTransferList,
|
|
16
|
+
MMarquee,
|
|
17
|
+
} from './components/creative.js'
|
|
18
|
+
import {
|
|
19
|
+
MCollapsibleHeader,
|
|
20
|
+
MRefreshControl,
|
|
21
|
+
MComposer,
|
|
22
|
+
MSpeedDial,
|
|
23
|
+
MPinInput,
|
|
24
|
+
MAnimatedText,
|
|
25
|
+
} from './components/screen-components.js'
|
|
1
26
|
import {
|
|
2
27
|
MImageViewer,
|
|
3
28
|
MNumberFlow,
|
|
@@ -65,6 +90,25 @@ import { MSheet } from './components/MSheet.js'
|
|
|
65
90
|
import type { ClaimSystemBack, SystemBackClaimant } from './system-back.js'
|
|
66
91
|
|
|
67
92
|
export {
|
|
93
|
+
MKanban,
|
|
94
|
+
MDonutChart,
|
|
95
|
+
MSparkline,
|
|
96
|
+
MGradientBackground,
|
|
97
|
+
MParticleField,
|
|
98
|
+
MConfetti,
|
|
99
|
+
MColorPicker,
|
|
100
|
+
MSwipeDeck,
|
|
101
|
+
MGauge,
|
|
102
|
+
MTour,
|
|
103
|
+
MTourTarget,
|
|
104
|
+
MTransferList,
|
|
105
|
+
MMarquee,
|
|
106
|
+
MCollapsibleHeader,
|
|
107
|
+
MRefreshControl,
|
|
108
|
+
MComposer,
|
|
109
|
+
MSpeedDial,
|
|
110
|
+
MPinInput,
|
|
111
|
+
MAnimatedText,
|
|
68
112
|
MImageViewer,
|
|
69
113
|
MNumberFlow,
|
|
70
114
|
MSortableList,
|
|
@@ -172,6 +216,26 @@ export function createMavis(options: MavisOptions = {}) {
|
|
|
172
216
|
if (components === false) return
|
|
173
217
|
for (const [name, component] of Object.entries(
|
|
174
218
|
components ?? {
|
|
219
|
+
MKanban,
|
|
220
|
+
MDonutChart,
|
|
221
|
+
MSparkline,
|
|
222
|
+
MGradientBackground,
|
|
223
|
+
MParticleField,
|
|
224
|
+
MConfetti,
|
|
225
|
+
MColorPicker,
|
|
226
|
+
MSwipeDeck,
|
|
227
|
+
MGauge,
|
|
228
|
+
MTour,
|
|
229
|
+
MTourTarget,
|
|
230
|
+
MTransferList,
|
|
231
|
+
MMarquee,
|
|
232
|
+
MCollapsibleHeader,
|
|
233
|
+
MRefreshControl,
|
|
234
|
+
MComposer,
|
|
235
|
+
MSpeedDial,
|
|
236
|
+
MPinInput,
|
|
237
|
+
MAnimatedText,
|
|
238
|
+
|
|
175
239
|
MImageViewer,
|
|
176
240
|
MNumberFlow,
|
|
177
241
|
MSortableList,
|