@getcortexlabs/mavis 0.1.0-rc.13 → 0.1.0-rc.14
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/native/flex-layout.ios.d.ts.map +1 -1
- package/dist/native/flex-layout.ios.js +4 -0
- package/dist/native/flex-layout.ios.js.map +1 -1
- package/dist/native/motion-region.d.ts.map +1 -1
- package/dist/native/motion-region.js +1 -0
- 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 +20 -3
- package/dist/native/motion-surface.js.map +1 -1
- package/dist/native/scroll-motion.d.ts +1 -1
- package/dist/native/scroll-motion.d.ts.map +1 -1
- package/dist/native/scroll-motion.js +55 -16
- package/dist/native/scroll-motion.js.map +1 -1
- package/dist/native/section-scroll.d.ts +1 -1
- package/dist/native/section-scroll.d.ts.map +1 -1
- package/dist/native/section-scroll.js +19 -6
- package/dist/native/section-scroll.js.map +1 -1
- package/dist/vue/card-input.d.ts +4 -0
- package/dist/vue/card-input.d.ts.map +1 -0
- package/dist/vue/card-input.js +37 -0
- package/dist/vue/card-input.js.map +1 -0
- package/dist/vue/components/ChoiceControl.d.ts +1 -1
- package/dist/vue/components/DateCalendar.d.ts +1 -1
- package/dist/vue/components/MButton.d.ts +6 -6
- package/dist/vue/components/MCard.d.ts.map +1 -1
- package/dist/vue/components/MCard.js +3 -2
- package/dist/vue/components/MCard.js.map +1 -1
- package/dist/vue/components/MChip.d.ts +1 -1
- package/dist/vue/components/MDatePicker.d.ts +96 -96
- package/dist/vue/components/MDatePicker.d.ts.map +1 -1
- package/dist/vue/components/MEmptyState.d.ts +1 -1
- package/dist/vue/components/MInput.d.ts +4 -4
- package/dist/vue/components/MPopover.d.ts +1 -1
- package/dist/vue/components/MProgress.d.ts +1 -1
- package/dist/vue/components/MRangeSlider.d.ts +2 -2
- package/dist/vue/components/MResizablePanels.d.ts +1 -1
- package/dist/vue/components/MReveal.d.ts +8 -8
- package/dist/vue/components/MSheet.d.ts +4 -4
- package/dist/vue/components/MSlider.d.ts +1 -1
- package/dist/vue/components/MStack.d.ts +8 -8
- 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 +1 -1
- package/dist/vue/components/MVirtualList.d.ts.map +1 -1
- package/dist/vue/components/MVirtualList.js +88 -67
- package/dist/vue/components/MVirtualList.js.map +1 -1
- package/dist/vue/components/advanced.d.ts +34 -34
- package/dist/vue/components/configurator.d.ts +33 -33
- package/dist/vue/components/creative.d.ts +20 -20
- package/dist/vue/components/dashboard.d.ts +12 -12
- package/dist/vue/components/dashboard.d.ts.map +1 -1
- package/dist/vue/components/dashboard.js +167 -66
- package/dist/vue/components/dashboard.js.map +1 -1
- package/dist/vue/components/discovery.d.ts +10 -10
- package/dist/vue/components/interactive.d.ts +6 -6
- package/dist/vue/components/layout.d.ts +16 -16
- package/dist/vue/components/navigation.d.ts +4 -4
- package/dist/vue/components/screen-components.d.ts +23 -23
- package/dist/vue/components/wayfinding.d.ts +11 -11
- package/dist/vue/components/workflows.d.ts +5 -5
- package/dist/vue/use-motion-surface.d.ts.map +1 -1
- package/dist/vue/use-motion-surface.js +0 -6
- package/dist/vue/use-motion-surface.js.map +1 -1
- package/package.json +3 -3
- package/src/native/flex-layout.ios.ts +4 -0
- package/src/native/motion-region.ts +1 -0
- package/src/native/motion-surface.ts +22 -3
- package/src/native/scroll-motion.ts +60 -19
- package/src/native/section-scroll.ts +16 -6
- package/src/vue/card-input.ts +44 -0
- package/src/vue/components/MCard.ts +4 -3
- package/src/vue/components/MVirtualList.ts +104 -78
- package/src/vue/components/dashboard.ts +173 -68
- package/src/vue/use-motion-surface.ts +0 -4
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
inject,
|
|
5
5
|
markRaw,
|
|
6
6
|
mergeProps,
|
|
7
|
+
nextTick,
|
|
7
8
|
onBeforeUnmount,
|
|
8
9
|
onDeactivated,
|
|
9
10
|
onScopeDispose,
|
|
@@ -11,12 +12,14 @@ import {
|
|
|
11
12
|
} from 'nativescript-vue'
|
|
12
13
|
import {
|
|
13
14
|
Application,
|
|
15
|
+
isAndroid,
|
|
14
16
|
type View,
|
|
15
17
|
type EventData,
|
|
16
|
-
type
|
|
18
|
+
type LayoutBase,
|
|
19
|
+
type TouchGestureEventData,
|
|
17
20
|
} from '@nativescript/core'
|
|
18
21
|
import { notifyAccessibilityLayout } from '../../native/accessibility-layout'
|
|
19
|
-
import { reducedMotion, onReducedMotion } from '@rafaelaugusto/jolt'
|
|
22
|
+
import { dropZones, reducedMotion, onReducedMotion, type DropZones } from '@rafaelaugusto/jolt'
|
|
20
23
|
import {
|
|
21
24
|
createDashboardShape,
|
|
22
25
|
createDonutChart,
|
|
@@ -28,6 +31,7 @@ import {
|
|
|
28
31
|
kanbanRegistryKey,
|
|
29
32
|
kanbanZoneProps,
|
|
30
33
|
kanbanDragProps,
|
|
34
|
+
type KanbanRegistry,
|
|
31
35
|
} from '@getcortexlabs/mavis-core/vue'
|
|
32
36
|
import { createMotionSurface } from '@getcortexlabs/mavis-core/experimental'
|
|
33
37
|
import { MBox, MColumn, MRow } from './layout.js'
|
|
@@ -86,29 +90,49 @@ const Environment = defineComponent({
|
|
|
86
90
|
})
|
|
87
91
|
function rect(view?: View) {
|
|
88
92
|
if (!view?.isLoaded) return
|
|
89
|
-
const p = view.
|
|
93
|
+
const p = view.getLocationInWindow(),
|
|
90
94
|
size = view.getActualSize()
|
|
91
95
|
return p ? { ...p, ...size } : undefined
|
|
92
96
|
}
|
|
97
|
+
// A dragged card leaves its column: nothing between the card and the board may clip it.
|
|
98
|
+
// On Android a clipped source counts as hidden and Jolt cancels the drag.
|
|
99
|
+
function unclip(source: View, columns: readonly View[]) {
|
|
100
|
+
const show = (view: View) => {
|
|
101
|
+
if (isAndroid) {
|
|
102
|
+
const group = view.android as { setClipChildren?(clip: boolean): void } & {
|
|
103
|
+
setClipToPadding?(clip: boolean): void
|
|
104
|
+
}
|
|
105
|
+
group?.setClipChildren?.(false)
|
|
106
|
+
group?.setClipToPadding?.(false)
|
|
107
|
+
} else (view as LayoutBase).clipToBounds = false
|
|
108
|
+
}
|
|
109
|
+
for (let view = source.parent as View | undefined; view; view = view.parent as View | undefined) {
|
|
110
|
+
show(view)
|
|
111
|
+
if (columns.includes(view)) {
|
|
112
|
+
if (view.parent) show(view.parent as View)
|
|
113
|
+
break
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
93
117
|
const Zone = defineComponent({
|
|
94
118
|
inheritAttrs: false,
|
|
95
119
|
props: kanbanZoneProps,
|
|
96
120
|
setup(props, { attrs, slots }) {
|
|
97
|
-
const registry = inject(kanbanRegistryKey)!
|
|
98
|
-
|
|
99
|
-
|
|
121
|
+
const registry = inject(kanbanRegistryKey)! as KanbanRegistry<View>
|
|
122
|
+
const leave = () => {
|
|
123
|
+
if (registry.zones.delete(props.column)) registry.revision.value++
|
|
124
|
+
}
|
|
125
|
+
onBeforeUnmount(leave)
|
|
100
126
|
return () =>
|
|
101
127
|
h(
|
|
102
128
|
'GridLayout',
|
|
103
129
|
mergeProps(attrs, {
|
|
130
|
+
zIndex: props.raised ? 20 : 0,
|
|
104
131
|
onLoaded: (e: EventData) => {
|
|
105
|
-
|
|
106
|
-
registry.
|
|
107
|
-
},
|
|
108
|
-
onUnloaded: () => {
|
|
109
|
-
view = undefined
|
|
110
|
-
registry.zones.delete(props.column)
|
|
132
|
+
registry.zones.set(props.column, e.object as View)
|
|
133
|
+
registry.revision.value++
|
|
111
134
|
},
|
|
135
|
+
onUnloaded: leave,
|
|
112
136
|
}),
|
|
113
137
|
slots.default?.(),
|
|
114
138
|
)
|
|
@@ -118,39 +142,118 @@ const Drag = defineComponent({
|
|
|
118
142
|
inheritAttrs: false,
|
|
119
143
|
props: kanbanDragProps,
|
|
120
144
|
setup(props, { attrs, slots }) {
|
|
121
|
-
const registry = inject(kanbanRegistryKey)
|
|
145
|
+
const registry = inject(kanbanRegistryKey)! as KanbanRegistry<View>,
|
|
122
146
|
surface = markRaw(createMotionSurface())
|
|
123
147
|
let view: View | undefined,
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
148
|
+
source: View | undefined,
|
|
149
|
+
grip: View | undefined,
|
|
150
|
+
zones: DropZones | undefined,
|
|
151
|
+
live = false,
|
|
152
|
+
queued = false,
|
|
153
|
+
disposed = false
|
|
154
|
+
function settle() {
|
|
155
|
+
live = false
|
|
156
|
+
Application.off(Application.suspendEvent, cancel)
|
|
134
157
|
if (view) view.style.zIndex = 0
|
|
135
|
-
if (was) registry.finish(commit)
|
|
136
158
|
}
|
|
137
|
-
|
|
138
|
-
|
|
159
|
+
// Jolt can end a drag on its own (a cancelled touch, a source that went out of sight) and
|
|
160
|
+
// leaves the card where it was; once the touch is over the board brings it back.
|
|
161
|
+
const touched = (e: TouchGestureEventData) => {
|
|
162
|
+
if (e.action !== 'up' && e.action !== 'cancel') return
|
|
163
|
+
setTimeout(() => {
|
|
164
|
+
if (live && !zones?.dragging) cancel()
|
|
165
|
+
})
|
|
166
|
+
}
|
|
167
|
+
function rest(animated: boolean) {
|
|
168
|
+
if (!surface.available) return
|
|
169
|
+
if (animated && props.animated)
|
|
170
|
+
surface.animate({ x: 0, y: 0, scale: 1 }, { type: 'spring', duration: 280, bounce: 0.12 })
|
|
171
|
+
else surface.set({ x: 0, y: 0, scale: 1 })
|
|
172
|
+
}
|
|
173
|
+
function cancel() {
|
|
174
|
+
const was = live
|
|
175
|
+
settle()
|
|
176
|
+
zones?.cancel()
|
|
177
|
+
if (!was) return
|
|
178
|
+
rest(true)
|
|
179
|
+
registry.finish(props.cardId)
|
|
180
|
+
}
|
|
181
|
+
function release() {
|
|
182
|
+
zones?.dispose()
|
|
183
|
+
zones = undefined
|
|
184
|
+
}
|
|
185
|
+
function attach() {
|
|
186
|
+
if (live) return
|
|
187
|
+
release()
|
|
188
|
+
if (props.disabled || !source?.isLoaded || !grip?.isLoaded) return
|
|
189
|
+
const targets = registry.targets(props.cardId).filter(({ target }) => target.isLoaded)
|
|
190
|
+
if (!targets.length) return
|
|
191
|
+
unclip(
|
|
192
|
+
source,
|
|
193
|
+
targets.map(({ target }) => target),
|
|
194
|
+
)
|
|
195
|
+
zones = dropZones(source, {
|
|
196
|
+
targets,
|
|
197
|
+
drag: { handle: grip, snap: [0] },
|
|
198
|
+
onMove({ id, bounds }) {
|
|
199
|
+
if (!live) {
|
|
200
|
+
if (!registry.begin(props.cardId, cancel)) {
|
|
201
|
+
zones?.cancel()
|
|
202
|
+
return
|
|
203
|
+
}
|
|
204
|
+
live = true
|
|
205
|
+
Application.on(Application.suspendEvent, cancel)
|
|
206
|
+
if (view) view.style.zIndex = 20
|
|
207
|
+
if (surface.available) surface.set({ scale: 1.02 })
|
|
208
|
+
}
|
|
209
|
+
registry.move(id, bounds)
|
|
210
|
+
},
|
|
211
|
+
onLeave: () => registry.leave(),
|
|
212
|
+
onDrop() {
|
|
213
|
+
settle()
|
|
214
|
+
rest(false)
|
|
215
|
+
registry.drop()
|
|
216
|
+
},
|
|
217
|
+
onReject() {
|
|
218
|
+
settle()
|
|
219
|
+
registry.finish(props.cardId)
|
|
220
|
+
if (!surface.available) return
|
|
221
|
+
if (props.animated)
|
|
222
|
+
surface.animate({ scale: 1 }, { type: 'spring', duration: 280, bounce: 0.12 })
|
|
223
|
+
else
|
|
224
|
+
void Promise.resolve().then(() => {
|
|
225
|
+
zones?.cancel()
|
|
226
|
+
rest(false)
|
|
227
|
+
})
|
|
228
|
+
},
|
|
229
|
+
})
|
|
230
|
+
}
|
|
231
|
+
// Views load parent first, so the columns and the card's own views arrive over one tick.
|
|
232
|
+
function schedule() {
|
|
233
|
+
if (queued || disposed) return
|
|
234
|
+
queued = true
|
|
235
|
+
void nextTick(() => {
|
|
236
|
+
queued = false
|
|
237
|
+
if (!disposed) attach()
|
|
238
|
+
})
|
|
239
|
+
}
|
|
240
|
+
function unload() {
|
|
139
241
|
cancel()
|
|
242
|
+
release()
|
|
243
|
+
}
|
|
244
|
+
onBeforeUnmount(() => {
|
|
245
|
+
disposed = true
|
|
246
|
+
unload()
|
|
140
247
|
registry.cards.delete(props.cardId)
|
|
141
248
|
registry.focus.delete(props.cardId)
|
|
142
249
|
})
|
|
143
250
|
onDeactivated(cancel)
|
|
144
251
|
onScopeDispose(surface.use(() => cancel))
|
|
145
|
-
watch(
|
|
146
|
-
|
|
147
|
-
(value) => {
|
|
148
|
-
if (value) cancel()
|
|
149
|
-
},
|
|
150
|
-
)
|
|
252
|
+
watch(() => [registry.revision.value, props.disabled], schedule)
|
|
253
|
+
// A plain GridLayout would take the column's whole height on iOS; a box keeps the card's own.
|
|
151
254
|
return () =>
|
|
152
255
|
h(
|
|
153
|
-
|
|
256
|
+
MBox,
|
|
154
257
|
mergeProps(attrs, {
|
|
155
258
|
onLoaded: (e: EventData) => {
|
|
156
259
|
view = e.object as View
|
|
@@ -160,48 +263,50 @@ const Drag = defineComponent({
|
|
|
160
263
|
})
|
|
161
264
|
},
|
|
162
265
|
onUnloaded: () => {
|
|
163
|
-
|
|
266
|
+
unload()
|
|
164
267
|
view = undefined
|
|
165
268
|
registry.cards.delete(props.cardId)
|
|
166
269
|
registry.focus.delete(props.cardId)
|
|
167
270
|
},
|
|
168
271
|
}),
|
|
169
|
-
|
|
170
|
-
h(
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
272
|
+
() =>
|
|
273
|
+
h(
|
|
274
|
+
MBox,
|
|
275
|
+
{
|
|
276
|
+
motionSurface: surface,
|
|
277
|
+
onLoaded: (e: EventData) => {
|
|
278
|
+
source = e.object as View
|
|
279
|
+
schedule()
|
|
280
|
+
},
|
|
281
|
+
onUnloaded: () => {
|
|
282
|
+
unload()
|
|
283
|
+
source = undefined
|
|
284
|
+
},
|
|
285
|
+
},
|
|
286
|
+
() =>
|
|
287
|
+
h(MColumn, { gap: 'xs' }, () => [
|
|
288
|
+
h(
|
|
289
|
+
MBox,
|
|
290
|
+
{
|
|
291
|
+
height: 36,
|
|
292
|
+
accessibilityHidden: true,
|
|
293
|
+
accessibilityLabel: props.label,
|
|
294
|
+
opacity: props.disabled ? 0.4 : 0.65,
|
|
295
|
+
onTouch: touched,
|
|
296
|
+
onLoaded: (e: EventData) => {
|
|
297
|
+
grip = e.object as View
|
|
298
|
+
schedule()
|
|
299
|
+
},
|
|
300
|
+
onUnloaded: () => {
|
|
301
|
+
unload()
|
|
302
|
+
grip = undefined
|
|
303
|
+
},
|
|
197
304
|
},
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
]),
|
|
305
|
+
() => h(MText, { text: '⠿', textAlignment: 'center' }),
|
|
306
|
+
),
|
|
307
|
+
...(slots.default?.() ?? []),
|
|
308
|
+
]),
|
|
203
309
|
),
|
|
204
|
-
],
|
|
205
310
|
)
|
|
206
311
|
},
|
|
207
312
|
})
|
|
@@ -89,10 +89,6 @@ export function useMotionSurface(
|
|
|
89
89
|
},
|
|
90
90
|
set: (values) => {
|
|
91
91
|
continuous?.interrupt(Object.keys(values))
|
|
92
|
-
// Jolt on Android leaves the path's translationY on the view when a path still in
|
|
93
|
-
// flight is replaced by a zero-duration set (rafaelaugustos/jolt#479).
|
|
94
|
-
if (isAndroid && ('x' in values || 'y' in values || 'rotate' in values))
|
|
95
|
-
for (const [handle, frames] of active) if (frames.path) handle.stop()
|
|
96
92
|
const handle = animate(target, values, { duration: 0 })
|
|
97
93
|
takeShadow(target, values)
|
|
98
94
|
return handle
|