@getcortexlabs/mavis-core 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 +2 -2
- package/dist/capabilities.d.ts +7 -7
- package/dist/capabilities.d.ts.map +1 -1
- package/dist/capabilities.js +23 -4
- package/dist/capabilities.js.map +1 -1
- package/dist/creative-controls.d.ts +47 -0
- package/dist/creative-controls.d.ts.map +1 -0
- package/dist/creative-controls.js +112 -0
- package/dist/creative-controls.js.map +1 -0
- package/dist/dashboard.d.ts +72 -0
- package/dist/dashboard.d.ts.map +1 -0
- package/dist/dashboard.js +115 -0
- package/dist/dashboard.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/screen-components.d.ts +45 -0
- package/dist/screen-components.d.ts.map +1 -0
- package/dist/screen-components.js +23 -0
- package/dist/screen-components.js.map +1 -0
- package/dist/vue/animated-text.d.ts +101 -0
- package/dist/vue/animated-text.d.ts.map +1 -0
- package/dist/vue/animated-text.js +56 -0
- package/dist/vue/animated-text.js.map +1 -0
- package/dist/vue/component-props.d.ts +692 -3
- package/dist/vue/component-props.d.ts.map +1 -1
- package/dist/vue/component-props.js +22 -0
- package/dist/vue/component-props.js.map +1 -1
- package/dist/vue/composer.d.ts +159 -0
- package/dist/vue/composer.d.ts.map +1 -0
- package/dist/vue/composer.js +142 -0
- package/dist/vue/composer.js.map +1 -0
- package/dist/vue/configurator.d.ts +1 -1
- package/dist/vue/creative-controls.d.ts +328 -0
- package/dist/vue/creative-controls.d.ts.map +1 -0
- package/dist/vue/creative-controls.js +396 -0
- package/dist/vue/creative-controls.js.map +1 -0
- package/dist/vue/creative-props.d.ts +260 -0
- package/dist/vue/creative-props.d.ts.map +1 -0
- package/dist/vue/creative-props.js +92 -0
- package/dist/vue/creative-props.js.map +1 -0
- package/dist/vue/dashboard-charts.d.ts +240 -0
- package/dist/vue/dashboard-charts.d.ts.map +1 -0
- package/dist/vue/dashboard-charts.js +263 -0
- package/dist/vue/dashboard-charts.js.map +1 -0
- package/dist/vue/dashboard-effects.d.ts +211 -0
- package/dist/vue/dashboard-effects.d.ts.map +1 -0
- package/dist/vue/dashboard-effects.js +235 -0
- package/dist/vue/dashboard-effects.js.map +1 -0
- package/dist/vue/dashboard-props.d.ts +244 -0
- package/dist/vue/dashboard-props.d.ts.map +1 -0
- package/dist/vue/dashboard-props.js +94 -0
- package/dist/vue/dashboard-props.js.map +1 -0
- package/dist/vue/discovery-controls.d.ts +1 -1
- package/dist/vue/global-components.d.ts +106 -0
- package/dist/vue/global-components.d.ts.map +1 -1
- package/dist/vue/index.d.ts +16 -0
- package/dist/vue/index.d.ts.map +1 -1
- package/dist/vue/index.js +16 -0
- package/dist/vue/index.js.map +1 -1
- package/dist/vue/kanban.d.ts +150 -0
- package/dist/vue/kanban.d.ts.map +1 -0
- package/dist/vue/kanban.js +267 -0
- package/dist/vue/kanban.js.map +1 -0
- package/dist/vue/marquee.d.ts +96 -0
- package/dist/vue/marquee.d.ts.map +1 -0
- package/dist/vue/marquee.js +186 -0
- package/dist/vue/marquee.js.map +1 -0
- package/dist/vue/pin-cell.d.ts +14 -0
- package/dist/vue/pin-cell.d.ts.map +1 -0
- package/dist/vue/pin-cell.js +19 -0
- package/dist/vue/pin-cell.js.map +1 -0
- package/dist/vue/pin-input.d.ts +14 -0
- package/dist/vue/pin-input.d.ts.map +1 -0
- package/dist/vue/pin-input.js +23 -0
- package/dist/vue/pin-input.js.map +1 -0
- package/dist/vue/props.d.ts +6 -6
- package/dist/vue/screen-component-props.d.ts +236 -0
- package/dist/vue/screen-component-props.d.ts.map +1 -0
- package/dist/vue/screen-component-props.js +90 -0
- package/dist/vue/screen-component-props.js.map +1 -0
- package/dist/vue/scroll-frame.d.ts +223 -0
- package/dist/vue/scroll-frame.d.ts.map +1 -0
- package/dist/vue/scroll-frame.js +346 -0
- package/dist/vue/scroll-frame.js.map +1 -0
- package/dist/vue/speed-dial.d.ts +73 -0
- package/dist/vue/speed-dial.d.ts.map +1 -0
- package/dist/vue/speed-dial.js +78 -0
- package/dist/vue/speed-dial.js.map +1 -0
- package/dist/vue/swipe-deck.d.ts +120 -0
- package/dist/vue/swipe-deck.d.ts.map +1 -0
- package/dist/vue/swipe-deck.js +229 -0
- package/dist/vue/swipe-deck.js.map +1 -0
- package/dist/vue/time-picker.d.ts +2 -2
- package/dist/vue/tour.d.ts +120 -0
- package/dist/vue/tour.d.ts.map +1 -0
- package/dist/vue/tour.js +165 -0
- package/dist/vue/tour.js.map +1 -0
- package/dist/vue/tree-view.d.ts +1 -1
- package/package.json +1 -1
- package/src/capabilities.ts +24 -4
- package/src/creative-controls.ts +169 -0
- package/src/dashboard.ts +164 -0
- package/src/index.ts +5 -0
- package/src/screen-components.ts +59 -0
- package/src/vue/animated-text.ts +72 -0
- package/src/vue/component-props.ts +47 -0
- package/src/vue/composer.ts +192 -0
- package/src/vue/creative-controls.ts +524 -0
- package/src/vue/creative-props.ts +94 -0
- package/src/vue/dashboard-charts.ts +346 -0
- package/src/vue/dashboard-effects.ts +304 -0
- package/src/vue/dashboard-props.ts +95 -0
- package/src/vue/global-components.ts +116 -0
- package/src/vue/index.ts +20 -0
- package/src/vue/kanban.ts +360 -0
- package/src/vue/marquee.ts +248 -0
- package/src/vue/pin-cell.ts +26 -0
- package/src/vue/pin-input.ts +31 -0
- package/src/vue/screen-component-props.ts +92 -0
- package/src/vue/scroll-frame.ts +429 -0
- package/src/vue/speed-dial.ts +108 -0
- package/src/vue/swipe-deck.ts +277 -0
- package/src/vue/tour.ts +239 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type { PropType } from '@vue/runtime-core'
|
|
2
|
+
import type { KanbanCard, KanbanColumn, DonutSegment, SparklinePoint } from '../dashboard.js'
|
|
3
|
+
const label = { type: String, required: true as const }
|
|
4
|
+
const animated = { type: Boolean, default: true }
|
|
5
|
+
const colors = {
|
|
6
|
+
type: Array as PropType<readonly string[]>,
|
|
7
|
+
default: () => ['#9C5270', '#51847B', '#D5AD6C'],
|
|
8
|
+
}
|
|
9
|
+
export const kanbanProps = {
|
|
10
|
+
id: String,
|
|
11
|
+
label,
|
|
12
|
+
columns: { type: Array as PropType<readonly KanbanColumn[]>, required: true as const },
|
|
13
|
+
modelValue: { type: Array as PropType<readonly KanbanCard[]>, required: true as const },
|
|
14
|
+
query: { type: String, default: '' },
|
|
15
|
+
disabled: Boolean,
|
|
16
|
+
animated,
|
|
17
|
+
draggable: { type: Boolean, default: true },
|
|
18
|
+
moveLabel: { type: String, default: 'Move card' },
|
|
19
|
+
upLabel: { type: String, default: 'Move up' },
|
|
20
|
+
downLabel: { type: String, default: 'Move down' },
|
|
21
|
+
emptyLabel: { type: String, default: 'No cards' },
|
|
22
|
+
fullLabel: { type: String, default: 'Column full' },
|
|
23
|
+
}
|
|
24
|
+
export const donutChartProps = {
|
|
25
|
+
id: String,
|
|
26
|
+
label,
|
|
27
|
+
segments: { type: Array as PropType<readonly DonutSegment[]>, required: true as const },
|
|
28
|
+
modelValue: { type: String as PropType<string | null>, default: null },
|
|
29
|
+
size: { type: Number, default: 220 },
|
|
30
|
+
strokeWidth: { type: Number, default: 12 },
|
|
31
|
+
animated,
|
|
32
|
+
animateNumber: Boolean,
|
|
33
|
+
disabled: Boolean,
|
|
34
|
+
totalLabel: { type: String, default: 'Total' },
|
|
35
|
+
emptyLabel: { type: String, default: 'No data' },
|
|
36
|
+
formatValue: Function as PropType<(value: number) => string>,
|
|
37
|
+
}
|
|
38
|
+
export const sparklineProps = {
|
|
39
|
+
id: String,
|
|
40
|
+
label,
|
|
41
|
+
points: { type: Array as PropType<readonly SparklinePoint[]>, required: true as const },
|
|
42
|
+
domain: Array as unknown as PropType<readonly [number, number]>,
|
|
43
|
+
height: { type: Number, default: 64 },
|
|
44
|
+
color: String,
|
|
45
|
+
animated,
|
|
46
|
+
showData: Boolean,
|
|
47
|
+
dataLabel: { type: String, default: 'View data' },
|
|
48
|
+
emptyLabel: { type: String, default: 'No data' },
|
|
49
|
+
formatValue: Function as PropType<(value: number) => string>,
|
|
50
|
+
}
|
|
51
|
+
const background = {
|
|
52
|
+
id: String,
|
|
53
|
+
colors,
|
|
54
|
+
height: { type: Number, default: 280 },
|
|
55
|
+
radius: { type: String as PropType<'none' | 'sm' | 'md' | 'lg' | 'full'>, default: 'lg' },
|
|
56
|
+
}
|
|
57
|
+
export const gradientBackgroundProps = {
|
|
58
|
+
...background,
|
|
59
|
+
angle: { type: Number, default: 130 },
|
|
60
|
+
animated,
|
|
61
|
+
active: Boolean,
|
|
62
|
+
duration: { type: Number, default: 12000 },
|
|
63
|
+
}
|
|
64
|
+
export const particleFieldProps = {
|
|
65
|
+
...background,
|
|
66
|
+
active: Boolean,
|
|
67
|
+
density: { type: Number, default: 12 },
|
|
68
|
+
speed: { type: Number, default: 28 },
|
|
69
|
+
lifetime: { type: Number, default: 3000 },
|
|
70
|
+
duration: Number,
|
|
71
|
+
size: { type: Number, default: 3 },
|
|
72
|
+
shape: { type: String as PropType<'circle' | 'rectangle' | 'ring'>, default: 'circle' },
|
|
73
|
+
backgroundColor: { type: String, default: '#202A32' },
|
|
74
|
+
}
|
|
75
|
+
export const confettiProps = {
|
|
76
|
+
id: String,
|
|
77
|
+
colors,
|
|
78
|
+
trigger: { type: [String, Number], default: 0 },
|
|
79
|
+
count: { type: Number, default: 70 },
|
|
80
|
+
disabled: Boolean,
|
|
81
|
+
}
|
|
82
|
+
export const dashboardEnvironmentProps = { interactive: Boolean }
|
|
83
|
+
export const dashboardPlotProps = { height: { type: Number, required: true as const } }
|
|
84
|
+
export const dashboardShapeProps = {
|
|
85
|
+
d: { type: String, required: true as const },
|
|
86
|
+
viewBox: {
|
|
87
|
+
type: Array as unknown as PropType<readonly [number, number, number, number]>,
|
|
88
|
+
required: true as const,
|
|
89
|
+
},
|
|
90
|
+
color: { type: String, required: true as const },
|
|
91
|
+
strokeWidth: { type: Number, default: 2 },
|
|
92
|
+
start: { type: Number, default: 0 },
|
|
93
|
+
end: { type: Number, default: 1 },
|
|
94
|
+
animated,
|
|
95
|
+
}
|
|
@@ -29,6 +29,122 @@ type SheetEvents = {
|
|
|
29
29
|
/** Template props come from the same declarations used by both renderers. */
|
|
30
30
|
declare module '@vue/runtime-core' {
|
|
31
31
|
export interface GlobalComponents {
|
|
32
|
+
MKanban: DefineComponent<
|
|
33
|
+
ComponentProps['MKanban'] & {
|
|
34
|
+
'onUpdate:modelValue'?: (cards: import('../dashboard.js').KanbanCard[]) => void
|
|
35
|
+
onMove?: (move: import('../dashboard.js').KanbanMove) => void
|
|
36
|
+
}
|
|
37
|
+
> & {
|
|
38
|
+
new (): {
|
|
39
|
+
$slots: {
|
|
40
|
+
card?: (props: {
|
|
41
|
+
card: import('../dashboard.js').KanbanCard
|
|
42
|
+
column: import('../dashboard.js').KanbanColumn
|
|
43
|
+
}) => unknown
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
MDonutChart: DefineComponent<
|
|
48
|
+
ComponentProps['MDonutChart'] & { 'onUpdate:modelValue'?: (value: string | null) => void }
|
|
49
|
+
>
|
|
50
|
+
MSparkline: DefineComponent<ComponentProps['MSparkline']>
|
|
51
|
+
MGradientBackground: DefineComponent<ComponentProps['MGradientBackground']>
|
|
52
|
+
MParticleField: DefineComponent<ComponentProps['MParticleField']>
|
|
53
|
+
MConfetti: DefineComponent<
|
|
54
|
+
ComponentProps['MConfetti'] & {
|
|
55
|
+
onBurst?: () => void
|
|
56
|
+
onSkipped?: (reason: 'disabled' | 'reduced-motion' | 'unavailable') => void
|
|
57
|
+
}
|
|
58
|
+
> & { new (): { burst(): void; stop(): void } }
|
|
59
|
+
|
|
60
|
+
MColorPicker: DefineComponent<
|
|
61
|
+
ComponentProps['MColorPicker'] & { 'onUpdate:modelValue'?: (value: string) => void }
|
|
62
|
+
>
|
|
63
|
+
MGauge: DefineComponent<ComponentProps['MGauge']>
|
|
64
|
+
MSwipeDeck: DefineComponent<
|
|
65
|
+
ComponentProps['MSwipeDeck'] & {
|
|
66
|
+
'onUpdate:modelValue'?: (value: ChoiceValue | null) => void
|
|
67
|
+
onDecide?: (event: {
|
|
68
|
+
item: import('../creative-controls.js').SwipeCard
|
|
69
|
+
decision: import('../creative-controls.js').SwipeDecision
|
|
70
|
+
}) => void
|
|
71
|
+
onUndo?: () => void
|
|
72
|
+
}
|
|
73
|
+
>
|
|
74
|
+
MTour: DefineComponent<
|
|
75
|
+
ComponentProps['MTour'] & {
|
|
76
|
+
'onUpdate:modelValue'?: (value: string | null) => void
|
|
77
|
+
onMissing?: (id: string) => void
|
|
78
|
+
onFinish?: (reason: string) => void
|
|
79
|
+
}
|
|
80
|
+
>
|
|
81
|
+
MTourTarget: DefineComponent<ComponentProps['MTourTarget']>
|
|
82
|
+
MTransferList: DefineComponent<
|
|
83
|
+
ComponentProps['MTransferList'] & { 'onUpdate:modelValue'?: (values: ChoiceValue[]) => void }
|
|
84
|
+
>
|
|
85
|
+
MMarquee: DefineComponent<
|
|
86
|
+
ComponentProps['MMarquee'] & { 'onUpdate:paused'?: (paused: boolean) => void }
|
|
87
|
+
>
|
|
88
|
+
|
|
89
|
+
MAnimatedText: DefineComponent<ComponentProps['MAnimatedText']> & { new (): { replay(): void } }
|
|
90
|
+
MPinInput: DefineComponent<
|
|
91
|
+
ComponentProps['MPinInput'] & InputEvents & { onComplete?: (value: string) => void },
|
|
92
|
+
InputHandle
|
|
93
|
+
>
|
|
94
|
+
MSpeedDial: DefineComponent<
|
|
95
|
+
ComponentProps['MSpeedDial'] & {
|
|
96
|
+
'onUpdate:open'?: (open: boolean) => void
|
|
97
|
+
onSelect?: (
|
|
98
|
+
value: ChoiceValue,
|
|
99
|
+
action: import('../screen-components.js').SpeedDialAction,
|
|
100
|
+
) => void
|
|
101
|
+
onClose?: (reason: string) => void
|
|
102
|
+
}
|
|
103
|
+
>
|
|
104
|
+
MComposer: DefineComponent<
|
|
105
|
+
ComponentProps['MComposer'] &
|
|
106
|
+
Omit<InputEvents, 'onSubmit'> & {
|
|
107
|
+
onSubmit?: (message: import('../screen-components.js').ComposerMessage) => void
|
|
108
|
+
onAttach?: () => void
|
|
109
|
+
'onUpdate:attachments'?: (
|
|
110
|
+
items: import('../screen-components.js').ComposerAttachment[],
|
|
111
|
+
) => void
|
|
112
|
+
},
|
|
113
|
+
InputHandle
|
|
114
|
+
> & { new (): { $slots: { default?: () => unknown } } }
|
|
115
|
+
MCollapsibleHeader: DefineComponent<
|
|
116
|
+
ComponentProps['MCollapsibleHeader'] & { onBack?: () => void }
|
|
117
|
+
> & {
|
|
118
|
+
new (): {
|
|
119
|
+
scrollToTop(animated?: boolean): void
|
|
120
|
+
$slots: {
|
|
121
|
+
default?: () => unknown
|
|
122
|
+
artwork?: () => unknown
|
|
123
|
+
leading?: () => unknown
|
|
124
|
+
actions?: () => unknown
|
|
125
|
+
section?: () => unknown
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
MRefreshControl: DefineComponent<
|
|
130
|
+
ComponentProps['MRefreshControl'] & {
|
|
131
|
+
onStateChange?: (state: import('../screen-components.js').RefreshState) => void
|
|
132
|
+
onError?: (error: unknown) => void
|
|
133
|
+
}
|
|
134
|
+
> & {
|
|
135
|
+
new (): {
|
|
136
|
+
refresh(): Promise<boolean>
|
|
137
|
+
cancel(): void
|
|
138
|
+
$slots: {
|
|
139
|
+
default?: (scope: {
|
|
140
|
+
state: import('../screen-components.js').RefreshState
|
|
141
|
+
refresh(): Promise<boolean>
|
|
142
|
+
cancel(): void
|
|
143
|
+
}) => unknown
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
32
148
|
MSortableList: import('./interactive-components.js').SortableListComponent
|
|
33
149
|
MNumberFlow: DefineComponent<ComponentProps['MNumberFlow']>
|
|
34
150
|
MSwipeActions: DefineComponent<
|
package/src/vue/index.ts
CHANGED
|
@@ -130,3 +130,23 @@ export * from './swipe-actions.js'
|
|
|
130
130
|
export * from './partition.js'
|
|
131
131
|
|
|
132
132
|
export type { SortableListComponent } from './interactive-components.js'
|
|
133
|
+
|
|
134
|
+
export * from './screen-component-props.js'
|
|
135
|
+
export * from './scroll-frame.js'
|
|
136
|
+
export * from './animated-text.js'
|
|
137
|
+
export * from './composer.js'
|
|
138
|
+
export * from './speed-dial.js'
|
|
139
|
+
export * from './pin-input.js'
|
|
140
|
+
|
|
141
|
+
export * from './pin-cell.js'
|
|
142
|
+
|
|
143
|
+
export * from './creative-props.js'
|
|
144
|
+
export * from './creative-controls.js'
|
|
145
|
+
export * from './swipe-deck.js'
|
|
146
|
+
export * from './tour.js'
|
|
147
|
+
export * from './marquee.js'
|
|
148
|
+
|
|
149
|
+
export * from './dashboard-props.js'
|
|
150
|
+
export * from './dashboard-charts.js'
|
|
151
|
+
export * from './dashboard-effects.js'
|
|
152
|
+
export * from './kanban.js'
|
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
import {
|
|
2
|
+
computed,
|
|
3
|
+
defineComponent,
|
|
4
|
+
h,
|
|
5
|
+
mergeProps,
|
|
6
|
+
nextTick,
|
|
7
|
+
provide,
|
|
8
|
+
ref,
|
|
9
|
+
watch,
|
|
10
|
+
type Component,
|
|
11
|
+
type InjectionKey,
|
|
12
|
+
} from '@vue/runtime-core'
|
|
13
|
+
import {
|
|
14
|
+
moveKanban,
|
|
15
|
+
validateKanban,
|
|
16
|
+
type DashboardRect,
|
|
17
|
+
type KanbanCard,
|
|
18
|
+
type KanbanMove,
|
|
19
|
+
} from '../dashboard.js'
|
|
20
|
+
import { kanbanProps } from './dashboard-props.js'
|
|
21
|
+
import { useComponentLayout } from './component-motion.js'
|
|
22
|
+
import { useMavisTheme } from './theme.js'
|
|
23
|
+
import type { DashboardUI } from './dashboard-charts.js'
|
|
24
|
+
|
|
25
|
+
export interface KanbanDrop {
|
|
26
|
+
column: string
|
|
27
|
+
before: string | null
|
|
28
|
+
}
|
|
29
|
+
export interface KanbanRegistry {
|
|
30
|
+
zones: Map<string, () => DashboardRect | undefined>
|
|
31
|
+
cards: Map<string, () => DashboardRect | undefined>
|
|
32
|
+
focus: Map<string, () => void>
|
|
33
|
+
begin(id: string, cancel: () => void): boolean
|
|
34
|
+
move(x: number, y: number): void
|
|
35
|
+
finish(commit: boolean): void
|
|
36
|
+
keyboard(id: string, direction: 'up' | 'down' | 'left' | 'right'): void
|
|
37
|
+
}
|
|
38
|
+
export const kanbanRegistryKey: InjectionKey<KanbanRegistry> = Symbol('Mavis Kanban registry')
|
|
39
|
+
export const kanbanZoneProps = { column: { type: String, required: true as const } }
|
|
40
|
+
export const kanbanDragProps = {
|
|
41
|
+
cardId: { type: String, required: true as const },
|
|
42
|
+
label: String,
|
|
43
|
+
disabled: Boolean,
|
|
44
|
+
animated: Boolean,
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function createKanban(
|
|
48
|
+
ui: DashboardUI & { Zone: Component; Drag: Component; Menu: Component },
|
|
49
|
+
platform: 'web' | 'native',
|
|
50
|
+
) {
|
|
51
|
+
return defineComponent({
|
|
52
|
+
name: 'MKanban',
|
|
53
|
+
inheritAttrs: false,
|
|
54
|
+
props: kanbanProps,
|
|
55
|
+
emits: {
|
|
56
|
+
'update:modelValue': (_cards: KanbanCard[]) => true,
|
|
57
|
+
move: (_move: KanbanMove) => true,
|
|
58
|
+
},
|
|
59
|
+
setup(props, { attrs, slots, emit }) {
|
|
60
|
+
const menuOpen = ref<string | null>(null)
|
|
61
|
+
const { theme } = useMavisTheme(),
|
|
62
|
+
announcement = ref(''),
|
|
63
|
+
active = ref<string | null>(null),
|
|
64
|
+
destination = ref<KanbanDrop | null>(null)
|
|
65
|
+
const visible = computed(() =>
|
|
66
|
+
props.modelValue.filter((c) =>
|
|
67
|
+
`${c.title} ${c.description ?? ''}`
|
|
68
|
+
.toLowerCase()
|
|
69
|
+
.includes(props.query.trim().toLowerCase()),
|
|
70
|
+
),
|
|
71
|
+
)
|
|
72
|
+
const region = useComponentLayout(
|
|
73
|
+
() => [props.modelValue, props.query, destination.value],
|
|
74
|
+
true,
|
|
75
|
+
() => props.animated,
|
|
76
|
+
)
|
|
77
|
+
let origin: DashboardRect | undefined,
|
|
78
|
+
cancelDrag = () => {}
|
|
79
|
+
let zones: { id: string; rect: DashboardRect }[] = [],
|
|
80
|
+
cards: { id: string; column: string; rect: DashboardRect }[] = []
|
|
81
|
+
function commit(id: string, drop: KanbanDrop) {
|
|
82
|
+
if (props.disabled) return
|
|
83
|
+
const result = moveKanban(props.columns, props.modelValue, id, drop.column, drop.before)
|
|
84
|
+
if (!result) return
|
|
85
|
+
emit('update:modelValue', result.cards)
|
|
86
|
+
emit('move', result.move)
|
|
87
|
+
void nextTick(() => {
|
|
88
|
+
const card = props.modelValue.find((c) => c.id === id),
|
|
89
|
+
column = props.columns.find((c) => c.id === card?.column)
|
|
90
|
+
if (card && column) announcement.value = `${card.title} · ${column.title}`
|
|
91
|
+
registry.focus.get(id)?.()
|
|
92
|
+
})
|
|
93
|
+
}
|
|
94
|
+
function keyboard(id: string, direction: 'up' | 'down' | 'left' | 'right') {
|
|
95
|
+
const card = props.modelValue.find((c) => c.id === id)
|
|
96
|
+
if (!card || props.disabled) return
|
|
97
|
+
const list = visible.value.filter((c) => c.column === card.column),
|
|
98
|
+
index = list.findIndex((c) => c.id === id)
|
|
99
|
+
if (direction === 'up' && index > 0)
|
|
100
|
+
commit(id, { column: card.column, before: list[index - 1]!.id })
|
|
101
|
+
if (direction === 'down' && index < list.length - 1)
|
|
102
|
+
commit(id, { column: card.column, before: list[index + 2]?.id ?? null })
|
|
103
|
+
if (direction === 'left' || direction === 'right') {
|
|
104
|
+
const column =
|
|
105
|
+
props.columns[
|
|
106
|
+
props.columns.findIndex((c) => c.id === card.column) + (direction === 'left' ? -1 : 1)
|
|
107
|
+
]
|
|
108
|
+
if (column) commit(id, { column: column.id, before: null })
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
const registry: KanbanRegistry = {
|
|
112
|
+
zones: new Map(),
|
|
113
|
+
cards: new Map(),
|
|
114
|
+
focus: new Map(),
|
|
115
|
+
keyboard,
|
|
116
|
+
begin(id, cancel) {
|
|
117
|
+
if (
|
|
118
|
+
props.disabled ||
|
|
119
|
+
!props.draggable ||
|
|
120
|
+
props.modelValue.find((c) => c.id === id)?.disabled
|
|
121
|
+
)
|
|
122
|
+
return false
|
|
123
|
+
cancelDrag()
|
|
124
|
+
origin = registry.cards.get(id)?.()
|
|
125
|
+
if (!origin) return false
|
|
126
|
+
zones = [...registry.zones].flatMap(([id, measure]) => {
|
|
127
|
+
const rect = measure()
|
|
128
|
+
return rect ? [{ id, rect }] : []
|
|
129
|
+
})
|
|
130
|
+
cards = visible.value.flatMap((card) => {
|
|
131
|
+
const rect = registry.cards.get(card.id)?.()
|
|
132
|
+
return rect ? [{ id: card.id, column: card.column, rect }] : []
|
|
133
|
+
})
|
|
134
|
+
active.value = id
|
|
135
|
+
destination.value = null
|
|
136
|
+
cancelDrag = cancel
|
|
137
|
+
return true
|
|
138
|
+
},
|
|
139
|
+
move(x, y) {
|
|
140
|
+
if (!origin || !active.value) return
|
|
141
|
+
const cx = origin.x + origin.width / 2 + x,
|
|
142
|
+
cy = origin.y + origin.height / 2 + y
|
|
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
|
+
}
|
|
161
|
+
if (
|
|
162
|
+
destination.value?.column !== next?.column ||
|
|
163
|
+
destination.value?.before !== next?.before
|
|
164
|
+
)
|
|
165
|
+
destination.value = next
|
|
166
|
+
},
|
|
167
|
+
finish(accept) {
|
|
168
|
+
const id = active.value,
|
|
169
|
+
drop = destination.value
|
|
170
|
+
active.value = null
|
|
171
|
+
destination.value = null
|
|
172
|
+
origin = undefined
|
|
173
|
+
cancelDrag = () => {}
|
|
174
|
+
if (accept && id && drop) commit(id, drop)
|
|
175
|
+
},
|
|
176
|
+
}
|
|
177
|
+
provide(kanbanRegistryKey, registry)
|
|
178
|
+
watch(
|
|
179
|
+
() => [props.modelValue, props.columns, props.query, props.disabled, props.draggable],
|
|
180
|
+
() => {
|
|
181
|
+
menuOpen.value = null
|
|
182
|
+
cancelDrag()
|
|
183
|
+
registry.finish(false)
|
|
184
|
+
},
|
|
185
|
+
{ deep: true, flush: 'sync' },
|
|
186
|
+
)
|
|
187
|
+
return () => {
|
|
188
|
+
validateKanban(props.columns, props.modelValue)
|
|
189
|
+
const gap = (column: string, before: string | null) =>
|
|
190
|
+
destination.value?.column === column && destination.value.before === before
|
|
191
|
+
? h(ui.Box, {
|
|
192
|
+
key: `drop:${before}`,
|
|
193
|
+
height: 40,
|
|
194
|
+
radius: 'md',
|
|
195
|
+
backgroundColor: theme.value.colors.primary,
|
|
196
|
+
...(platform === 'web' ? { style: { opacity: 0.2 } } : { opacity: 0.2 }),
|
|
197
|
+
accessibilityHidden: true,
|
|
198
|
+
})
|
|
199
|
+
: null
|
|
200
|
+
return h(
|
|
201
|
+
ui.Column,
|
|
202
|
+
mergeProps(attrs, {
|
|
203
|
+
id: props.id,
|
|
204
|
+
gap: 'md',
|
|
205
|
+
motionRegion: region,
|
|
206
|
+
...(platform === 'web'
|
|
207
|
+
? { class: 'm-kanban', role: 'region', 'aria-label': props.label }
|
|
208
|
+
: { accessibilityLabel: props.label }),
|
|
209
|
+
}),
|
|
210
|
+
() => [
|
|
211
|
+
h(ui.Text, { text: props.label, variant: 'heading' }),
|
|
212
|
+
h(
|
|
213
|
+
ui.Stack,
|
|
214
|
+
{
|
|
215
|
+
direction: 'column',
|
|
216
|
+
gap: 'md',
|
|
217
|
+
align: 'stretch',
|
|
218
|
+
responsive: { at: 760, direction: 'row' },
|
|
219
|
+
},
|
|
220
|
+
() =>
|
|
221
|
+
props.columns.map((column) => {
|
|
222
|
+
const list = visible.value.filter((c) => c.column === column.id),
|
|
223
|
+
all = props.modelValue.filter((c) => c.column === column.id),
|
|
224
|
+
full = column.limit !== undefined && all.length >= column.limit
|
|
225
|
+
return h(
|
|
226
|
+
ui.Zone,
|
|
227
|
+
{
|
|
228
|
+
key: column.id,
|
|
229
|
+
column: column.id,
|
|
230
|
+
...(platform === 'web'
|
|
231
|
+
? { style: { flex: '1 1 0', minWidth: 0 } }
|
|
232
|
+
: { flexGrow: 1 }),
|
|
233
|
+
},
|
|
234
|
+
() =>
|
|
235
|
+
h(
|
|
236
|
+
ui.Column,
|
|
237
|
+
{
|
|
238
|
+
gap: 'sm',
|
|
239
|
+
padding: 'sm',
|
|
240
|
+
radius: 'lg',
|
|
241
|
+
backgroundColor: theme.value.colors.elevated,
|
|
242
|
+
minHeight: 180,
|
|
243
|
+
},
|
|
244
|
+
() => [
|
|
245
|
+
h(ui.Text, {
|
|
246
|
+
text: `${column.title} · ${all.length}${column.limit ? ` / ${column.limit}` : ''}`,
|
|
247
|
+
variant: 'heading',
|
|
248
|
+
}),
|
|
249
|
+
full
|
|
250
|
+
? h(ui.Text, {
|
|
251
|
+
text: props.fullLabel,
|
|
252
|
+
variant: 'caption',
|
|
253
|
+
tone: 'muted',
|
|
254
|
+
})
|
|
255
|
+
: null,
|
|
256
|
+
...list.flatMap((card, index) => [
|
|
257
|
+
gap(column.id, card.id),
|
|
258
|
+
h(
|
|
259
|
+
ui.Drag,
|
|
260
|
+
{
|
|
261
|
+
key: card.id,
|
|
262
|
+
cardId: card.id,
|
|
263
|
+
label: `${props.moveLabel}: ${card.title}`,
|
|
264
|
+
disabled: props.disabled || card.disabled || !props.draggable,
|
|
265
|
+
animated: props.animated,
|
|
266
|
+
},
|
|
267
|
+
() =>
|
|
268
|
+
h(
|
|
269
|
+
ui.Column,
|
|
270
|
+
{
|
|
271
|
+
gap: 'sm',
|
|
272
|
+
padding: 'md',
|
|
273
|
+
radius: 'md',
|
|
274
|
+
backgroundColor: theme.value.colors.surface,
|
|
275
|
+
},
|
|
276
|
+
() => [
|
|
277
|
+
...(slots.card?.({ card, column }) ?? [
|
|
278
|
+
h(ui.Text, { text: card.title, variant: 'heading' }),
|
|
279
|
+
card.description
|
|
280
|
+
? h(ui.Text, {
|
|
281
|
+
text: card.description,
|
|
282
|
+
tone: 'muted',
|
|
283
|
+
variant: 'caption',
|
|
284
|
+
})
|
|
285
|
+
: null,
|
|
286
|
+
]),
|
|
287
|
+
h(ui.Row, { gap: 'xs', wrap: true }, () => [
|
|
288
|
+
h(ui.Menu, {
|
|
289
|
+
label: `${props.moveLabel}: ${card.title}`,
|
|
290
|
+
open: menuOpen.value === card.id,
|
|
291
|
+
'onUpdate:open': (open: boolean) => {
|
|
292
|
+
menuOpen.value = open ? card.id : null
|
|
293
|
+
},
|
|
294
|
+
triggerLabel: props.moveLabel,
|
|
295
|
+
disabled: props.disabled || card.disabled,
|
|
296
|
+
items: props.columns
|
|
297
|
+
.filter((c) => c.id !== card.column)
|
|
298
|
+
.map((c) => ({
|
|
299
|
+
value: c.id,
|
|
300
|
+
label: c.title,
|
|
301
|
+
disabled:
|
|
302
|
+
props.disabled ||
|
|
303
|
+
card.disabled ||
|
|
304
|
+
(c.limit !== undefined &&
|
|
305
|
+
props.modelValue.filter((v) => v.column === c.id)
|
|
306
|
+
.length >= c.limit),
|
|
307
|
+
})),
|
|
308
|
+
onSelect: (to: string) =>
|
|
309
|
+
commit(card.id, { column: to, before: null }),
|
|
310
|
+
}),
|
|
311
|
+
h(ui.Button, {
|
|
312
|
+
icon: 'chevron-up',
|
|
313
|
+
variant: 'ghost',
|
|
314
|
+
size: 'sm',
|
|
315
|
+
accessibilityLabel: `${props.upLabel}: ${card.title}`,
|
|
316
|
+
disabled: props.disabled || card.disabled || index === 0,
|
|
317
|
+
onClick: () => keyboard(card.id, 'up'),
|
|
318
|
+
}),
|
|
319
|
+
h(ui.Button, {
|
|
320
|
+
icon: 'chevron-down',
|
|
321
|
+
variant: 'ghost',
|
|
322
|
+
size: 'sm',
|
|
323
|
+
accessibilityLabel: `${props.downLabel}: ${card.title}`,
|
|
324
|
+
disabled:
|
|
325
|
+
props.disabled ||
|
|
326
|
+
card.disabled ||
|
|
327
|
+
index === list.length - 1,
|
|
328
|
+
onClick: () => keyboard(card.id, 'down'),
|
|
329
|
+
}),
|
|
330
|
+
]),
|
|
331
|
+
],
|
|
332
|
+
),
|
|
333
|
+
),
|
|
334
|
+
]),
|
|
335
|
+
gap(column.id, null),
|
|
336
|
+
!list.length
|
|
337
|
+
? h(ui.Text, {
|
|
338
|
+
text: props.emptyLabel,
|
|
339
|
+
tone: 'muted',
|
|
340
|
+
variant: 'caption',
|
|
341
|
+
})
|
|
342
|
+
: null,
|
|
343
|
+
],
|
|
344
|
+
),
|
|
345
|
+
)
|
|
346
|
+
}),
|
|
347
|
+
),
|
|
348
|
+
h(ui.Text, {
|
|
349
|
+
text: announcement.value,
|
|
350
|
+
variant: 'caption',
|
|
351
|
+
...(platform === 'web'
|
|
352
|
+
? { class: 'm-sr-only', role: 'status', 'aria-live': 'polite' }
|
|
353
|
+
: { accessibilityLiveRegion: 'polite' }),
|
|
354
|
+
}),
|
|
355
|
+
],
|
|
356
|
+
)
|
|
357
|
+
}
|
|
358
|
+
},
|
|
359
|
+
})
|
|
360
|
+
}
|