@getcortexlabs/mavis-core 0.1.0-rc.13 → 0.1.0-rc.15
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 +2 -2
- package/dist/capabilities.d.ts +2317 -21
- package/dist/capabilities.d.ts.map +1 -1
- package/dist/capabilities.js +234 -9
- package/dist/capabilities.js.map +1 -1
- package/dist/collections.d.ts +2 -0
- package/dist/collections.d.ts.map +1 -1
- package/dist/collections.js +9 -0
- package/dist/collections.js.map +1 -1
- package/dist/contracts.d.ts +6 -6
- package/dist/date.d.ts.map +1 -1
- package/dist/date.js +1 -1
- package/dist/date.js.map +1 -1
- package/dist/experimental-regions.d.ts +17 -2
- package/dist/experimental-regions.d.ts.map +1 -1
- package/dist/experimental-regions.js +40 -7
- package/dist/experimental-regions.js.map +1 -1
- package/dist/experimental.d.ts +25 -4
- package/dist/experimental.d.ts.map +1 -1
- package/dist/experimental.js +75 -7
- package/dist/experimental.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/macos-capabilities.generated.d.ts +1738 -0
- package/dist/macos-capabilities.generated.d.ts.map +1 -0
- package/dist/macos-capabilities.generated.js +4191 -0
- package/dist/macos-capabilities.generated.js.map +1 -0
- package/dist/motion.d.ts +1 -1
- package/dist/section-scroll.d.ts +2 -0
- package/dist/section-scroll.d.ts.map +1 -1
- package/dist/section-scroll.js +2 -0
- package/dist/section-scroll.js.map +1 -1
- package/dist/vue/advanced-collections.d.ts +16 -16
- package/dist/vue/advanced-collections.d.ts.map +1 -1
- package/dist/vue/advanced-collections.js +24 -3
- package/dist/vue/advanced-collections.js.map +1 -1
- package/dist/vue/animated-text.d.ts +4 -4
- package/dist/vue/chart.d.ts +5 -5
- package/dist/vue/chart.d.ts.map +1 -1
- package/dist/vue/chart.js +28 -7
- package/dist/vue/chart.js.map +1 -1
- package/dist/vue/combobox.d.ts.map +1 -1
- package/dist/vue/combobox.js +13 -11
- package/dist/vue/combobox.js.map +1 -1
- package/dist/vue/command-palette.d.ts +5 -5
- package/dist/vue/component-props.d.ts +27 -23
- package/dist/vue/component-props.d.ts.map +1 -1
- package/dist/vue/composer.d.ts +10 -10
- package/dist/vue/configurator.d.ts +15 -15
- package/dist/vue/creative-controls.d.ts +10 -10
- package/dist/vue/dashboard-charts.d.ts +6 -6
- package/dist/vue/dashboard-effects.d.ts +6 -6
- package/dist/vue/date-picker.d.ts +48 -48
- package/dist/vue/discovery-controls.d.ts +7 -7
- package/dist/vue/image-cropper.d.ts +8 -8
- package/dist/vue/image-cropper.d.ts.map +1 -1
- package/dist/vue/kanban.d.ts +25 -7
- package/dist/vue/kanban.d.ts.map +1 -1
- package/dist/vue/kanban.js +73 -44
- package/dist/vue/kanban.js.map +1 -1
- package/dist/vue/list-motion.d.ts.map +1 -1
- package/dist/vue/list-motion.js +24 -7
- package/dist/vue/list-motion.js.map +1 -1
- package/dist/vue/marquee.d.ts +4 -4
- package/dist/vue/menu.d.ts +4 -4
- package/dist/vue/navigation-props.d.ts +5 -0
- package/dist/vue/navigation-props.d.ts.map +1 -1
- package/dist/vue/navigation-props.js +2 -0
- package/dist/vue/navigation-props.js.map +1 -1
- package/dist/vue/number-flow.d.ts +3 -3
- package/dist/vue/platform.d.ts +7 -1
- package/dist/vue/platform.d.ts.map +1 -1
- package/dist/vue/platform.js +5 -4
- package/dist/vue/platform.js.map +1 -1
- package/dist/vue/props.d.ts +46 -46
- package/dist/vue/reveal-state.d.ts +1 -1
- package/dist/vue/scheduler.d.ts +10 -10
- package/dist/vue/scroll-frame.d.ts +7 -6
- package/dist/vue/scroll-frame.d.ts.map +1 -1
- package/dist/vue/scroll-frame.js +55 -39
- package/dist/vue/scroll-frame.js.map +1 -1
- package/dist/vue/speed-dial.d.ts +3 -3
- package/dist/vue/swipe-actions.d.ts +3 -3
- package/dist/vue/swipe-deck.d.ts +3 -3
- package/dist/vue/theme-provider.d.ts +1 -1
- package/dist/vue/time-picker.d.ts +20 -20
- package/dist/vue/tour.d.ts +3 -3
- package/dist/vue/tree-view.d.ts +3 -3
- package/dist/vue/wayfinding-controls.d.ts +1 -1
- package/dist/vue/workflows.d.ts +5 -5
- package/package.json +1 -1
- package/src/capabilities.ts +241 -10
- package/src/collections.ts +22 -0
- package/src/date.ts +2 -1
- package/src/experimental-regions.ts +57 -9
- package/src/experimental.ts +117 -12
- package/src/index.ts +6 -1
- package/src/macos-capabilities.generated.ts +4190 -0
- package/src/section-scroll.ts +4 -0
- package/src/vue/advanced-collections.ts +29 -7
- package/src/vue/chart.ts +34 -9
- package/src/vue/combobox.ts +15 -14
- package/src/vue/kanban.ts +99 -59
- package/src/vue/list-motion.ts +23 -7
- package/src/vue/navigation-props.ts +2 -0
- package/src/vue/platform.ts +13 -5
- package/src/vue/scroll-frame.ts +70 -49
package/src/section-scroll.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export type ScrollEdge = 'start' | 'center' | 'end'
|
|
2
2
|
export interface SectionScrollOptions {
|
|
3
|
+
/** Auto selects Jolt's supported backend; scheduler forces its JavaScript fallback. */
|
|
4
|
+
execution?: 'auto' | 'scheduler'
|
|
3
5
|
/** [section edge, viewport edge]. Default: ['start', 'end']. */
|
|
4
6
|
start?: readonly [ScrollEdge, ScrollEdge]
|
|
5
7
|
/** [section edge, viewport edge]. Default: ['end', 'start']. */
|
|
@@ -7,6 +9,8 @@ export interface SectionScrollOptions {
|
|
|
7
9
|
}
|
|
8
10
|
const edge = { start: 0, center: 0.5, end: 1 } as const
|
|
9
11
|
export function validateSectionScroll(options: SectionScrollOptions) {
|
|
12
|
+
if (options.execution !== undefined && !['auto', 'scheduler'].includes(options.execution))
|
|
13
|
+
throw new TypeError('Scroll execution must be auto or scheduler.')
|
|
10
14
|
for (const value of [options.start, options.end])
|
|
11
15
|
if (
|
|
12
16
|
value !== undefined &&
|
|
@@ -110,6 +110,33 @@ export function createAdvancedPaint(ui: AdvancedUI) {
|
|
|
110
110
|
})
|
|
111
111
|
}
|
|
112
112
|
export function createTreeSelect(ui: AdvancedUI, platform: 'web' | 'native') {
|
|
113
|
+
const Row = defineComponent({
|
|
114
|
+
name: 'MTreeSelectRow',
|
|
115
|
+
props: { animated: Boolean },
|
|
116
|
+
setup(props, { slots }) {
|
|
117
|
+
const { theme } = useMavisTheme()
|
|
118
|
+
const surface = markRaw(createMotionSurface())
|
|
119
|
+
onScopeDispose(
|
|
120
|
+
surface.use((owner) => {
|
|
121
|
+
// Moving existing options across newly inserted ones lets a different control
|
|
122
|
+
// intercept a click mid-expansion. Fade new rows in their final layout boxes.
|
|
123
|
+
const entry = props.animated
|
|
124
|
+
? owner.animate({ opacity: [0, 1] }, componentMotion(theme.value, 'overlay'))
|
|
125
|
+
: undefined
|
|
126
|
+
return watch(
|
|
127
|
+
() => props.animated,
|
|
128
|
+
(animated) => {
|
|
129
|
+
if (!animated) {
|
|
130
|
+
entry?.stop()
|
|
131
|
+
owner.set({ opacity: 1 })
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
)
|
|
135
|
+
}),
|
|
136
|
+
)
|
|
137
|
+
return () => h(ui.Row, { gap: 'xs', align: 'center', motionSurface: surface }, slots)
|
|
138
|
+
},
|
|
139
|
+
})
|
|
113
140
|
return defineComponent({
|
|
114
141
|
name: 'MTreeSelect',
|
|
115
142
|
inheritAttrs: false,
|
|
@@ -123,11 +150,6 @@ export function createTreeSelect(ui: AdvancedUI, platform: 'web' | 'native') {
|
|
|
123
150
|
query = ref(''),
|
|
124
151
|
rows = computed(() => treeSelectRows(props.nodes)),
|
|
125
152
|
visible = computed(() => visibleTreeSelection(rows.value, props.expanded, query.value))
|
|
126
|
-
const region = useComponentLayout(
|
|
127
|
-
() => [props.expanded, query.value, props.modelValue],
|
|
128
|
-
true,
|
|
129
|
-
() => props.animated,
|
|
130
|
-
)
|
|
131
153
|
const mutable = (id: string) =>
|
|
132
154
|
rows.value.some((r) => r.node.id === id && !r.disabled && r.node.selectable !== false)
|
|
133
155
|
function choose(id: string) {
|
|
@@ -170,7 +192,7 @@ export function createTreeSelect(ui: AdvancedUI, platform: 'web' | 'native') {
|
|
|
170
192
|
width: 360,
|
|
171
193
|
},
|
|
172
194
|
() =>
|
|
173
|
-
h(ui.Column, { gap: 'sm'
|
|
195
|
+
h(ui.Column, { gap: 'sm' }, () => [
|
|
174
196
|
h(ui.Input, {
|
|
175
197
|
label: props.searchLabel,
|
|
176
198
|
modelValue: query.value,
|
|
@@ -178,7 +200,7 @@ export function createTreeSelect(ui: AdvancedUI, platform: 'web' | 'native') {
|
|
|
178
200
|
disabled: props.disabled,
|
|
179
201
|
}),
|
|
180
202
|
...visible.value.map((row) =>
|
|
181
|
-
h(
|
|
203
|
+
h(Row, { key: row.node.id, animated: props.animated }, () => [
|
|
182
204
|
row.depth
|
|
183
205
|
? h(ui.Box, { width: row.depth * 16, accessibilityHidden: true })
|
|
184
206
|
: null,
|
package/src/vue/chart.ts
CHANGED
|
@@ -70,14 +70,37 @@ export function createChart(
|
|
|
70
70
|
(series) => !props.hiddenSeries.includes(series.key),
|
|
71
71
|
),
|
|
72
72
|
}))
|
|
73
|
-
const
|
|
74
|
-
if (!
|
|
75
|
-
const category = props.categories.findIndex(
|
|
76
|
-
|
|
77
|
-
)
|
|
78
|
-
const series = visible.value.findIndex((item) => item.key === props.modelValue!.series)
|
|
73
|
+
const locate = (value: ChartSelection | null) => {
|
|
74
|
+
if (!value) return null
|
|
75
|
+
const category = props.categories.findIndex((item) => item.key === value.category)
|
|
76
|
+
const series = visible.value.findIndex((item) => item.key === value.series)
|
|
79
77
|
return category < 0 || series < 0 ? null : { category, series }
|
|
80
|
-
}
|
|
78
|
+
}
|
|
79
|
+
const selected = computed(() => locate(props.modelValue))
|
|
80
|
+
// Pointer exploration is presentation only. Selectors and emitted values remain
|
|
81
|
+
// controlled by the application until it accepts an explicit selection.
|
|
82
|
+
const hovered = ref<ChartSelection | null>(null)
|
|
83
|
+
const presented = computed(() => locate(hovered.value) ?? selected.value)
|
|
84
|
+
function preview(hit: { category: number; series: number } | null) {
|
|
85
|
+
const point =
|
|
86
|
+
hit && !props.disabled && geometry.value.series[hit.series]?.points[hit.category]
|
|
87
|
+
const next =
|
|
88
|
+
point && hit
|
|
89
|
+
? {
|
|
90
|
+
category: props.categories[hit.category]!.key,
|
|
91
|
+
series: visible.value[hit.series]!.key,
|
|
92
|
+
}
|
|
93
|
+
: null
|
|
94
|
+
if (next?.category !== hovered.value?.category || next?.series !== hovered.value?.series)
|
|
95
|
+
hovered.value = next
|
|
96
|
+
}
|
|
97
|
+
watch(
|
|
98
|
+
[geometry, () => props.type, () => props.disabled, () => props.modelValue],
|
|
99
|
+
() => {
|
|
100
|
+
hovered.value = null
|
|
101
|
+
},
|
|
102
|
+
{ flush: 'sync' },
|
|
103
|
+
)
|
|
81
104
|
const format = (value: number | null | undefined) =>
|
|
82
105
|
value == null ? props.missingLabel : (props.formatValue?.(value) ?? String(value))
|
|
83
106
|
const colors = computed(() => {
|
|
@@ -96,7 +119,7 @@ export function createChart(
|
|
|
96
119
|
)
|
|
97
120
|
})
|
|
98
121
|
const summary = computed(() => {
|
|
99
|
-
const point =
|
|
122
|
+
const point = presented.value
|
|
100
123
|
if (!point) return props.description ?? props.label
|
|
101
124
|
const series = visible.value[point.series]!
|
|
102
125
|
return `${props.categories[point.category]!.label} · ${series.label}: ${format(series.values[point.category])}`
|
|
@@ -203,11 +226,13 @@ export function createChart(
|
|
|
203
226
|
() =>
|
|
204
227
|
hasData
|
|
205
228
|
? h(ui.Plot, {
|
|
229
|
+
id: props.id ? `${props.id}-plot` : undefined,
|
|
206
230
|
geometry: geometry.value,
|
|
207
231
|
colors: colors.value,
|
|
208
232
|
type: props.type,
|
|
209
233
|
height: props.height,
|
|
210
|
-
selected:
|
|
234
|
+
selected: presented.value,
|
|
235
|
+
...(web ? { onPreview: preview } : {}),
|
|
211
236
|
disabled: props.disabled,
|
|
212
237
|
onSelect: choose,
|
|
213
238
|
})
|
package/src/vue/combobox.ts
CHANGED
|
@@ -127,21 +127,20 @@ export function useCombobox(props: Props, emit: Emit) {
|
|
|
127
127
|
{ immediate: true, deep: true },
|
|
128
128
|
)
|
|
129
129
|
watch(
|
|
130
|
-
() =>
|
|
131
|
-
|
|
130
|
+
() =>
|
|
131
|
+
[props.query, props.search, props.debounce, props.minQueryLength, props.maxResults] as const,
|
|
132
|
+
(current, previous) => {
|
|
133
|
+
// A parent render can update the controlled query and an inline search
|
|
134
|
+
// callback together. Reconfigure first, then start exactly one request.
|
|
135
|
+
if (current.slice(1).some((value, index) => value !== previous[index + 1])) {
|
|
136
|
+
search.dispose()
|
|
137
|
+
search = makeSearch()
|
|
138
|
+
state.value = search.state
|
|
139
|
+
}
|
|
132
140
|
if (open.value && !composing.value) search.request(props.query)
|
|
133
141
|
else search.cancel()
|
|
134
142
|
},
|
|
135
|
-
{ flush: '
|
|
136
|
-
)
|
|
137
|
-
watch(
|
|
138
|
-
() => [props.search, props.debounce, props.minQueryLength, props.maxResults],
|
|
139
|
-
() => {
|
|
140
|
-
search.dispose()
|
|
141
|
-
search = makeSearch()
|
|
142
|
-
state.value = search.state
|
|
143
|
-
if (open.value && !composing.value) search.request(props.query)
|
|
144
|
-
},
|
|
143
|
+
{ flush: 'post' },
|
|
145
144
|
)
|
|
146
145
|
watch(
|
|
147
146
|
() => props.disabled || !activity.value,
|
|
@@ -177,9 +176,11 @@ export function useCombobox(props: Props, emit: Emit) {
|
|
|
177
176
|
search.cancel()
|
|
178
177
|
active.value = undefined
|
|
179
178
|
open.value = true
|
|
179
|
+
const previousQuery = props.query
|
|
180
180
|
emit('update:query', query)
|
|
181
|
-
if (props.query === query && !composing.value) search.request(query)
|
|
182
|
-
//
|
|
181
|
+
if (previousQuery === query && props.query === query && !composing.value) search.request(query)
|
|
182
|
+
// The watcher owns changed queries after the parent accepts them. An
|
|
183
|
+
// unchanged query (for example compositionend) needs no parent update.
|
|
183
184
|
}
|
|
184
185
|
function choose(option: ChoiceOption) {
|
|
185
186
|
const current = state.value.options.find((item) => item.value === option.value)
|
package/src/vue/kanban.ts
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
watch,
|
|
10
10
|
type Component,
|
|
11
11
|
type InjectionKey,
|
|
12
|
+
type Ref,
|
|
12
13
|
} from '@vue/runtime-core'
|
|
13
14
|
import {
|
|
14
15
|
moveKanban,
|
|
@@ -18,7 +19,6 @@ import {
|
|
|
18
19
|
type KanbanMove,
|
|
19
20
|
} from '../dashboard.js'
|
|
20
21
|
import { kanbanProps } from './dashboard-props.js'
|
|
21
|
-
import { useComponentLayout } from './component-motion.js'
|
|
22
22
|
import { useMavisTheme } from './theme.js'
|
|
23
23
|
import type { DashboardUI } from './dashboard-charts.js'
|
|
24
24
|
|
|
@@ -26,17 +26,35 @@ export interface KanbanDrop {
|
|
|
26
26
|
column: string
|
|
27
27
|
before: string | null
|
|
28
28
|
}
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
/** Extra room below a column that still drops into it, in CSS pixels or DIPs. */
|
|
30
|
+
export const kanbanDropAllowance = 60
|
|
31
|
+
export interface KanbanTarget<T = unknown> {
|
|
32
|
+
id: string
|
|
33
|
+
target: T
|
|
34
|
+
padding: { bottom: number }
|
|
35
|
+
accept: () => boolean
|
|
36
|
+
}
|
|
37
|
+
export interface KanbanRegistry<T = unknown> {
|
|
38
|
+
zones: Map<string, T>
|
|
31
39
|
cards: Map<string, () => DashboardRect | undefined>
|
|
32
40
|
focus: Map<string, () => void>
|
|
41
|
+
/** Changes when a column mounts, unmounts or swaps its element or view. */
|
|
42
|
+
revision: Ref<number>
|
|
43
|
+
/** Mounted columns as drop targets for the card, in column order. */
|
|
44
|
+
targets(id: string): KanbanTarget<T>[]
|
|
33
45
|
begin(id: string, cancel: () => void): boolean
|
|
34
|
-
|
|
35
|
-
|
|
46
|
+
/** The dragged card's bounds and the target under it, in the targets' coordinates. */
|
|
47
|
+
move(target: string | undefined, bounds: DashboardRect): void
|
|
48
|
+
leave(): void
|
|
49
|
+
drop(): void
|
|
50
|
+
finish(id: string): void
|
|
36
51
|
keyboard(id: string, direction: 'up' | 'down' | 'left' | 'right'): void
|
|
37
52
|
}
|
|
38
53
|
export const kanbanRegistryKey: InjectionKey<KanbanRegistry> = Symbol('Mavis Kanban registry')
|
|
39
|
-
export const kanbanZoneProps = {
|
|
54
|
+
export const kanbanZoneProps = {
|
|
55
|
+
column: { type: String, required: true as const },
|
|
56
|
+
raised: Boolean,
|
|
57
|
+
}
|
|
40
58
|
export const kanbanDragProps = {
|
|
41
59
|
cardId: { type: String, required: true as const },
|
|
42
60
|
label: String,
|
|
@@ -69,15 +87,29 @@ export function createKanban(
|
|
|
69
87
|
.includes(props.query.trim().toLowerCase()),
|
|
70
88
|
),
|
|
71
89
|
)
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
90
|
+
const revision = ref(0)
|
|
91
|
+
let session:
|
|
92
|
+
| {
|
|
93
|
+
id: string
|
|
94
|
+
cancel: () => void
|
|
95
|
+
cards: { id: string; column: string; rect: DashboardRect }[]
|
|
96
|
+
drop: KanbanDrop | null
|
|
97
|
+
}
|
|
98
|
+
| undefined
|
|
99
|
+
function place(target: string | undefined, bounds: DashboardRect) {
|
|
100
|
+
const column = target === undefined ? undefined : props.columns[Number(target.slice(1))]?.id
|
|
101
|
+
if (!session || column === undefined) return null
|
|
102
|
+
const id = session.id,
|
|
103
|
+
y = bounds.y + bounds.height / 2
|
|
104
|
+
const before =
|
|
105
|
+
session.cards
|
|
106
|
+
.filter((c) => c.column === column && c.id !== id)
|
|
107
|
+
.sort((a, b) => a.rect.y - b.rect.y)
|
|
108
|
+
.find((c) => y < c.rect.y + c.rect.height / 2)?.id ?? null
|
|
109
|
+
return moveKanban(props.columns, props.modelValue, id, column, before)
|
|
110
|
+
? { column, before }
|
|
111
|
+
: null
|
|
112
|
+
}
|
|
81
113
|
function commit(id: string, drop: KanbanDrop) {
|
|
82
114
|
if (props.disabled) return
|
|
83
115
|
const result = moveKanban(props.columns, props.modelValue, id, drop.column, drop.before)
|
|
@@ -112,7 +144,22 @@ export function createKanban(
|
|
|
112
144
|
zones: new Map(),
|
|
113
145
|
cards: new Map(),
|
|
114
146
|
focus: new Map(),
|
|
147
|
+
revision,
|
|
115
148
|
keyboard,
|
|
149
|
+
targets: (id) =>
|
|
150
|
+
props.columns.flatMap((column, index) => {
|
|
151
|
+
const target = registry.zones.get(column.id)
|
|
152
|
+
return target === undefined
|
|
153
|
+
? []
|
|
154
|
+
: [
|
|
155
|
+
{
|
|
156
|
+
id: `c${index}`,
|
|
157
|
+
target,
|
|
158
|
+
padding: { bottom: kanbanDropAllowance },
|
|
159
|
+
accept: () => session?.id === id && session.drop?.column === column.id,
|
|
160
|
+
},
|
|
161
|
+
]
|
|
162
|
+
}),
|
|
116
163
|
begin(id, cancel) {
|
|
117
164
|
if (
|
|
118
165
|
props.disabled ||
|
|
@@ -120,58 +167,44 @@ export function createKanban(
|
|
|
120
167
|
props.modelValue.find((c) => c.id === id)?.disabled
|
|
121
168
|
)
|
|
122
169
|
return false
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
})
|
|
170
|
+
session?.cancel()
|
|
171
|
+
session = {
|
|
172
|
+
id,
|
|
173
|
+
cancel,
|
|
174
|
+
drop: null,
|
|
175
|
+
cards: visible.value.flatMap((card) => {
|
|
176
|
+
const rect = registry.cards.get(card.id)?.()
|
|
177
|
+
return rect ? [{ id: card.id, column: card.column, rect }] : []
|
|
178
|
+
}),
|
|
179
|
+
}
|
|
134
180
|
active.value = id
|
|
135
181
|
destination.value = null
|
|
136
|
-
cancelDrag = cancel
|
|
137
182
|
return true
|
|
138
183
|
},
|
|
139
|
-
move(
|
|
140
|
-
if (!
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
const zone = zones.find(
|
|
144
|
-
({ rect: r }) =>
|
|
145
|
-
cx >= r.x && cx <= r.x + r.width && cy >= r.y && cy <= r.y + r.height + 60,
|
|
146
|
-
)
|
|
147
|
-
const before = zone
|
|
148
|
-
? (cards
|
|
149
|
-
.filter((c) => c.column === zone.id && c.id !== active.value)
|
|
150
|
-
.sort((a, b) => a.rect.y - b.rect.y)
|
|
151
|
-
.find((c) => cy < c.rect.y + c.rect.height / 2)?.id ?? null)
|
|
152
|
-
: null
|
|
153
|
-
const next = zone ? { column: zone.id, before } : null
|
|
154
|
-
if (
|
|
155
|
-
next &&
|
|
156
|
-
!moveKanban(props.columns, props.modelValue, active.value, next.column, next.before)
|
|
157
|
-
) {
|
|
158
|
-
destination.value = null
|
|
159
|
-
return
|
|
160
|
-
}
|
|
184
|
+
move(target, bounds) {
|
|
185
|
+
if (!session) return
|
|
186
|
+
const next = place(target, bounds)
|
|
187
|
+
session.drop = next
|
|
161
188
|
if (
|
|
162
189
|
destination.value?.column !== next?.column ||
|
|
163
190
|
destination.value?.before !== next?.before
|
|
164
191
|
)
|
|
165
192
|
destination.value = next
|
|
166
193
|
},
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
194
|
+
leave() {
|
|
195
|
+
destination.value = null
|
|
196
|
+
},
|
|
197
|
+
drop() {
|
|
198
|
+
const current = session
|
|
199
|
+
if (!current) return
|
|
200
|
+
registry.finish(current.id)
|
|
201
|
+
if (current.drop) commit(current.id, current.drop)
|
|
202
|
+
},
|
|
203
|
+
finish(id) {
|
|
204
|
+
if (session?.id !== id) return
|
|
205
|
+
session = undefined
|
|
170
206
|
active.value = null
|
|
171
207
|
destination.value = null
|
|
172
|
-
origin = undefined
|
|
173
|
-
cancelDrag = () => {}
|
|
174
|
-
if (accept && id && drop) commit(id, drop)
|
|
175
208
|
},
|
|
176
209
|
}
|
|
177
210
|
provide(kanbanRegistryKey, registry)
|
|
@@ -179,8 +212,9 @@ export function createKanban(
|
|
|
179
212
|
() => [props.modelValue, props.columns, props.query, props.disabled, props.draggable],
|
|
180
213
|
() => {
|
|
181
214
|
menuOpen.value = null
|
|
182
|
-
|
|
183
|
-
|
|
215
|
+
const current = session
|
|
216
|
+
current?.cancel()
|
|
217
|
+
if (current) registry.finish(current.id)
|
|
184
218
|
},
|
|
185
219
|
{ deep: true, flush: 'sync' },
|
|
186
220
|
)
|
|
@@ -193,7 +227,9 @@ export function createKanban(
|
|
|
193
227
|
height: 40,
|
|
194
228
|
radius: 'md',
|
|
195
229
|
backgroundColor: theme.value.colors.primary,
|
|
196
|
-
...(platform === 'web'
|
|
230
|
+
...(platform === 'web'
|
|
231
|
+
? { style: { opacity: 0.2 }, 'data-kanban-gap': '' }
|
|
232
|
+
: { opacity: 0.2 }),
|
|
197
233
|
accessibilityHidden: true,
|
|
198
234
|
})
|
|
199
235
|
: null
|
|
@@ -202,7 +238,6 @@ export function createKanban(
|
|
|
202
238
|
mergeProps(attrs, {
|
|
203
239
|
id: props.id,
|
|
204
240
|
gap: 'md',
|
|
205
|
-
motionRegion: region,
|
|
206
241
|
...(platform === 'web'
|
|
207
242
|
? { class: 'm-kanban', role: 'region', 'aria-label': props.label }
|
|
208
243
|
: { accessibilityLabel: props.label }),
|
|
@@ -227,6 +262,11 @@ export function createKanban(
|
|
|
227
262
|
{
|
|
228
263
|
key: column.id,
|
|
229
264
|
column: column.id,
|
|
265
|
+
raised:
|
|
266
|
+
active.value !== null &&
|
|
267
|
+
props.modelValue.some(
|
|
268
|
+
(c) => c.id === active.value && c.column === column.id,
|
|
269
|
+
),
|
|
230
270
|
...(platform === 'web'
|
|
231
271
|
? { style: { flex: '1 1 0', minWidth: 0 } }
|
|
232
272
|
: { flexGrow: 1 }),
|
package/src/vue/list-motion.ts
CHANGED
|
@@ -4,28 +4,44 @@ import {
|
|
|
4
4
|
type MotionLayoutOptions,
|
|
5
5
|
type MotionPlayback,
|
|
6
6
|
} from '../experimental.js'
|
|
7
|
+
import { validateMotionLayoutChange, validateMotionLayoutOptions } from '../experimental-regions.js'
|
|
7
8
|
|
|
8
9
|
/** Shared Vue data changes; the host measures keyed direct children and Jolt owns playback. */
|
|
9
10
|
export function useMavisListMotion(options: MotionLayoutOptions = {}) {
|
|
11
|
+
validateMotionLayoutOptions(options)
|
|
10
12
|
const region = markRaw(createMotionRegion())
|
|
11
|
-
|
|
13
|
+
const pending = new Set<MotionPlayback>()
|
|
12
14
|
let disposed = false
|
|
13
15
|
onScopeDispose(() => {
|
|
14
16
|
disposed = true
|
|
15
|
-
|
|
17
|
+
for (const playback of pending) playback.stop()
|
|
18
|
+
pending.clear()
|
|
16
19
|
})
|
|
17
20
|
return {
|
|
18
21
|
region,
|
|
19
22
|
update(change: () => void): MotionPlayback {
|
|
20
23
|
if (disposed) throw new Error('This list motion scope is disposed.')
|
|
21
|
-
|
|
22
|
-
|
|
24
|
+
validateMotionLayoutChange(change)
|
|
25
|
+
validateMotionLayoutOptions(options)
|
|
23
26
|
if (!region.available) {
|
|
24
|
-
change()
|
|
27
|
+
const result = change() as unknown
|
|
28
|
+
if (result && typeof (result as PromiseLike<unknown>).then === 'function') {
|
|
29
|
+
void Promise.resolve(result).catch(() => {})
|
|
30
|
+
throw new TypeError('Layout motion needs a synchronous change callback.')
|
|
31
|
+
}
|
|
25
32
|
return { finished: Promise.resolve(false), stop() {} }
|
|
26
33
|
}
|
|
27
|
-
|
|
28
|
-
|
|
34
|
+
// Jolt captures the current visual pose before retiring earlier layout operations.
|
|
35
|
+
// Do not stop the previous handle before this call; retain it only for scope teardown.
|
|
36
|
+
const playback = region.animateLayout(change, options)
|
|
37
|
+
if (disposed) {
|
|
38
|
+
playback.stop()
|
|
39
|
+
return playback
|
|
40
|
+
}
|
|
41
|
+
pending.add(playback)
|
|
42
|
+
const forget = () => pending.delete(playback)
|
|
43
|
+
void playback.finished.then(forget, forget)
|
|
44
|
+
return playback
|
|
29
45
|
},
|
|
30
46
|
}
|
|
31
47
|
}
|
|
@@ -83,5 +83,7 @@ export const virtualListProps = {
|
|
|
83
83
|
height: { type: Number, required: true as const },
|
|
84
84
|
overscan: { type: Number, default: 3 },
|
|
85
85
|
initialIndex: { type: Number, default: 0 },
|
|
86
|
+
/** Animate keyed data changes; scrolling and recycled rows never play entry motion. */
|
|
87
|
+
animated: { type: Boolean, default: true },
|
|
86
88
|
emptyLabel: { type: String, default: 'No items' },
|
|
87
89
|
}
|
package/src/vue/platform.ts
CHANGED
|
@@ -6,14 +6,20 @@ import {
|
|
|
6
6
|
type SlotsType,
|
|
7
7
|
} from '@vue/runtime-core'
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
/**
|
|
10
|
+
* `macos` is the SwiftUI app generated from shared screens. No Vue renderer runs there, so the
|
|
11
|
+
* Web and NativeScript renderers never report it: the Mac generator answers for it instead.
|
|
12
|
+
*/
|
|
13
|
+
export type MavisPlatform = 'web' | 'ios' | 'android' | 'macos'
|
|
10
14
|
export type MavisPlatformTarget = MavisPlatform | 'native'
|
|
11
15
|
export type MavisPlatformContext = Readonly<{
|
|
12
16
|
platform: MavisPlatform
|
|
13
17
|
isWeb: boolean
|
|
18
|
+
/** The NativeScript renderer: iOS and Android. */
|
|
14
19
|
isNative: boolean
|
|
15
20
|
isIOS: boolean
|
|
16
21
|
isAndroid: boolean
|
|
22
|
+
isMacOS: boolean
|
|
17
23
|
}>
|
|
18
24
|
|
|
19
25
|
/** @internal Supplied by the renderer, including services-only installation. */
|
|
@@ -21,13 +27,15 @@ export const platformKey: InjectionKey<MavisPlatformContext> = Symbol('mavis-pla
|
|
|
21
27
|
|
|
22
28
|
/** @internal No browser globals, viewport detection or mutable process-wide state. */
|
|
23
29
|
export function createPlatformContext(platform: MavisPlatform): MavisPlatformContext {
|
|
24
|
-
if (!['web', 'ios', 'android'].includes(platform))
|
|
30
|
+
if (!['web', 'ios', 'android', 'macos'].includes(platform))
|
|
31
|
+
throw new RangeError('Unknown Mavis platform.')
|
|
25
32
|
return Object.freeze({
|
|
26
33
|
platform,
|
|
27
34
|
isWeb: platform === 'web',
|
|
28
|
-
isNative: platform
|
|
35
|
+
isNative: platform === 'ios' || platform === 'android',
|
|
29
36
|
isIOS: platform === 'ios',
|
|
30
37
|
isAndroid: platform === 'android',
|
|
38
|
+
isMacOS: platform === 'macos',
|
|
31
39
|
})
|
|
32
40
|
}
|
|
33
41
|
|
|
@@ -59,10 +67,10 @@ export const MPlatform = defineComponent({
|
|
|
59
67
|
const targets = Array.isArray(props.only) ? props.only : [props.only]
|
|
60
68
|
if (
|
|
61
69
|
!targets.length ||
|
|
62
|
-
targets.some((target) => !['web', 'native', 'ios', 'android'].includes(target))
|
|
70
|
+
targets.some((target) => !['web', 'native', 'ios', 'android', 'macos'].includes(target))
|
|
63
71
|
)
|
|
64
72
|
throw new RangeError(
|
|
65
|
-
'MPlatform.only requires web, native, ios, android, or a non-empty array of these targets.',
|
|
73
|
+
'MPlatform.only requires web, native, ios, android, macos, or a non-empty array of these targets.',
|
|
66
74
|
)
|
|
67
75
|
const matches = targets.some(
|
|
68
76
|
(target) => target === platform.platform || (target === 'native' && platform.isNative),
|