@getcortexlabs/mavis-core 0.1.0-rc.11.1 → 0.1.0-rc.12.1
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/advanced-collections.d.ts +74 -0
- package/dist/advanced-collections.d.ts.map +1 -0
- package/dist/advanced-collections.js +129 -0
- package/dist/advanced-collections.js.map +1 -0
- package/dist/capabilities.d.ts +7 -7
- package/dist/capabilities.d.ts.map +1 -1
- package/dist/capabilities.js +29 -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/image-crop.d.ts +49 -0
- package/dist/image-crop.d.ts.map +1 -0
- package/dist/image-crop.js +71 -0
- package/dist/image-crop.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/scheduler.d.ts +45 -0
- package/dist/scheduler.d.ts.map +1 -0
- package/dist/scheduler.js +142 -0
- package/dist/scheduler.js.map +1 -0
- 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/advanced-collections.d.ts +486 -0
- package/dist/vue/advanced-collections.d.ts.map +1 -0
- package/dist/vue/advanced-collections.js +476 -0
- package/dist/vue/advanced-collections.js.map +1 -0
- package/dist/vue/advanced-props.d.ts +398 -0
- package/dist/vue/advanced-props.d.ts.map +1 -0
- package/dist/vue/advanced-props.js +128 -0
- package/dist/vue/advanced-props.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/chart.d.ts +1 -1
- package/dist/vue/command-palette.d.ts +3 -3
- package/dist/vue/component-props.d.ts +1045 -0
- package/dist/vue/component-props.d.ts.map +1 -1
- package/dist/vue/component-props.js +29 -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 +5 -5
- 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/date-picker.d.ts +8 -8
- package/dist/vue/discovery-controls.d.ts +2 -2
- package/dist/vue/global-components.d.ts +152 -0
- package/dist/vue/global-components.d.ts.map +1 -1
- package/dist/vue/image-cropper.d.ts +187 -0
- package/dist/vue/image-cropper.d.ts.map +1 -0
- package/dist/vue/image-cropper.js +310 -0
- package/dist/vue/image-cropper.js.map +1 -0
- package/dist/vue/index.d.ts +20 -0
- package/dist/vue/index.d.ts.map +1 -1
- package/dist/vue/index.js +20 -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/menu.d.ts +2 -2
- package/dist/vue/navigation-controls.d.ts +1 -1
- 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/scheduler.d.ts +229 -0
- package/dist/vue/scheduler.d.ts.map +1 -0
- package/dist/vue/scheduler.js +363 -0
- package/dist/vue/scheduler.js.map +1 -0
- 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-actions.d.ts +1 -1
- 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 +6 -6
- 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/dist/vue/wayfinding-controls.d.ts +2 -2
- package/dist/vue/workflows.d.ts +3 -3
- package/package.json +1 -1
- package/src/advanced-collections.ts +199 -0
- package/src/capabilities.ts +30 -4
- package/src/creative-controls.ts +169 -0
- package/src/dashboard.ts +164 -0
- package/src/image-crop.ts +125 -0
- package/src/index.ts +11 -0
- package/src/scheduler.ts +194 -0
- package/src/screen-components.ts +59 -0
- package/src/vue/advanced-collections.ts +679 -0
- package/src/vue/advanced-props.ts +144 -0
- package/src/vue/animated-text.ts +72 -0
- package/src/vue/component-props.ts +61 -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 +162 -0
- package/src/vue/image-cropper.ts +413 -0
- package/src/vue/index.ts +28 -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/scheduler.ts +505 -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,429 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defineComponent,
|
|
3
|
+
h,
|
|
4
|
+
markRaw,
|
|
5
|
+
mergeProps,
|
|
6
|
+
nextTick,
|
|
7
|
+
onScopeDispose,
|
|
8
|
+
ref,
|
|
9
|
+
watch,
|
|
10
|
+
type Component,
|
|
11
|
+
type PropType,
|
|
12
|
+
} from '@vue/runtime-core'
|
|
13
|
+
import {
|
|
14
|
+
createMotionRegion,
|
|
15
|
+
createMotionScrollSource,
|
|
16
|
+
createMotionSurface,
|
|
17
|
+
whenMotionAvailable,
|
|
18
|
+
type MotionHeader,
|
|
19
|
+
type MotionRefreshContext,
|
|
20
|
+
} from '../experimental.js'
|
|
21
|
+
import { collapsibleHeaderProps, refreshControlProps } from './screen-component-props.js'
|
|
22
|
+
import type { RefreshState } from '../screen-components.js'
|
|
23
|
+
import { useMavisTheme } from './theme.js'
|
|
24
|
+
import { useCachedActivity } from './cached-activity.js'
|
|
25
|
+
|
|
26
|
+
export const scrollFrameHostProps = {
|
|
27
|
+
source: {
|
|
28
|
+
type: Object as PropType<ReturnType<typeof createMotionScrollSource>>,
|
|
29
|
+
required: true as const,
|
|
30
|
+
},
|
|
31
|
+
region: {
|
|
32
|
+
type: Object as PropType<ReturnType<typeof createMotionRegion>>,
|
|
33
|
+
required: true as const,
|
|
34
|
+
},
|
|
35
|
+
height: { type: Number, required: true as const },
|
|
36
|
+
label: { type: String, required: true as const },
|
|
37
|
+
}
|
|
38
|
+
type UI = {
|
|
39
|
+
Frame: Component
|
|
40
|
+
Box: Component
|
|
41
|
+
Row: Component
|
|
42
|
+
Column: Component
|
|
43
|
+
Text: Component
|
|
44
|
+
Image: Component
|
|
45
|
+
Button: Component
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function createScrollComponents(ui: UI, platform: 'web' | 'native') {
|
|
49
|
+
const ScrollFrame = defineComponent({
|
|
50
|
+
name: 'MScrollFrame',
|
|
51
|
+
inheritAttrs: false,
|
|
52
|
+
props: {
|
|
53
|
+
...collapsibleHeaderProps,
|
|
54
|
+
...refreshControlProps,
|
|
55
|
+
title: String,
|
|
56
|
+
label: String,
|
|
57
|
+
refresh: refreshControlProps.refresh.type,
|
|
58
|
+
refreshMode: Boolean,
|
|
59
|
+
},
|
|
60
|
+
emits: {
|
|
61
|
+
back: () => true,
|
|
62
|
+
stateChange: (_state: RefreshState) => true,
|
|
63
|
+
error: (_error: unknown) => true,
|
|
64
|
+
},
|
|
65
|
+
setup(props, { slots, attrs, emit, expose }) {
|
|
66
|
+
const { theme } = useMavisTheme()
|
|
67
|
+
const active = useCachedActivity()
|
|
68
|
+
const region = markRaw(createMotionRegion()),
|
|
69
|
+
source = markRaw(createMotionScrollSource())
|
|
70
|
+
const make = () => markRaw(createMotionSurface())
|
|
71
|
+
const header = make(),
|
|
72
|
+
artwork = make(),
|
|
73
|
+
title = make(),
|
|
74
|
+
toolbar = make(),
|
|
75
|
+
toolbarTitle = make(),
|
|
76
|
+
section = make()
|
|
77
|
+
const state = ref<RefreshState>('idle'),
|
|
78
|
+
ready = ref(false)
|
|
79
|
+
let control: MotionHeader | undefined,
|
|
80
|
+
request: AbortController | undefined,
|
|
81
|
+
revision = 0
|
|
82
|
+
const setState = (value: RefreshState) => {
|
|
83
|
+
if (state.value !== value) {
|
|
84
|
+
state.value = value
|
|
85
|
+
emit('stateChange', value)
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
const cancel = () => {
|
|
89
|
+
revision++
|
|
90
|
+
request?.abort()
|
|
91
|
+
request = undefined
|
|
92
|
+
control?.cancelRefresh()
|
|
93
|
+
if (state.value === 'refreshing') setState('idle')
|
|
94
|
+
}
|
|
95
|
+
const refresh = async (context: MotionRefreshContext) => {
|
|
96
|
+
if (!props.refresh || props.disabled || !active.value) return
|
|
97
|
+
const current = ++revision,
|
|
98
|
+
abort = new AbortController()
|
|
99
|
+
request?.abort()
|
|
100
|
+
request = abort
|
|
101
|
+
setState('refreshing')
|
|
102
|
+
try {
|
|
103
|
+
await props.refresh({
|
|
104
|
+
signal: abort.signal,
|
|
105
|
+
get cancelled() {
|
|
106
|
+
return abort.signal.aborted || context.cancelled || current !== revision
|
|
107
|
+
},
|
|
108
|
+
commit: async (change) => {
|
|
109
|
+
if (abort.signal.aborted || current !== revision) return false
|
|
110
|
+
return context.commit(async () => {
|
|
111
|
+
if (!abort.signal.aborted && current === revision) {
|
|
112
|
+
await change()
|
|
113
|
+
await nextTick()
|
|
114
|
+
}
|
|
115
|
+
})
|
|
116
|
+
},
|
|
117
|
+
})
|
|
118
|
+
if (current === revision && !context.cancelled && !abort.signal.aborted)
|
|
119
|
+
setState('success')
|
|
120
|
+
} catch (error) {
|
|
121
|
+
if (current === revision && !context.cancelled && !abort.signal.aborted) {
|
|
122
|
+
setState('error')
|
|
123
|
+
emit('error', error)
|
|
124
|
+
throw error
|
|
125
|
+
}
|
|
126
|
+
} finally {
|
|
127
|
+
if (request === abort) request = undefined
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
const expanded = () => (props.refreshMode ? 104 : props.expandedHeight)
|
|
131
|
+
const minimum = () => (props.refreshMode ? 56 : props.collapsedHeight)
|
|
132
|
+
let release: (() => void) | undefined
|
|
133
|
+
function bind() {
|
|
134
|
+
release?.()
|
|
135
|
+
release = undefined
|
|
136
|
+
if (!active.value) return
|
|
137
|
+
release = whenMotionAvailable(
|
|
138
|
+
[region, source, header, artwork, title, toolbar, toolbarTitle, section],
|
|
139
|
+
() => {
|
|
140
|
+
const owned = region.scrollHeader(source, {
|
|
141
|
+
header,
|
|
142
|
+
artwork,
|
|
143
|
+
title,
|
|
144
|
+
toolbar,
|
|
145
|
+
toolbarTitle,
|
|
146
|
+
section,
|
|
147
|
+
expanded: expanded(),
|
|
148
|
+
minimum: minimum(),
|
|
149
|
+
parallax: props.refreshMode ? 0 : (expanded() - minimum()) * props.parallax,
|
|
150
|
+
items: () => [],
|
|
151
|
+
onRefresh: props.refresh ? refresh : undefined,
|
|
152
|
+
onRefreshError: () => {},
|
|
153
|
+
refreshThreshold: props.threshold,
|
|
154
|
+
})
|
|
155
|
+
control = owned
|
|
156
|
+
ready.value = true
|
|
157
|
+
if (props.disabled) owned.pause()
|
|
158
|
+
return () => {
|
|
159
|
+
cancel()
|
|
160
|
+
owned.dispose()
|
|
161
|
+
if (control === owned) control = undefined
|
|
162
|
+
ready.value = false
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
)
|
|
166
|
+
}
|
|
167
|
+
watch(
|
|
168
|
+
() => [
|
|
169
|
+
active.value,
|
|
170
|
+
props.expandedHeight,
|
|
171
|
+
props.collapsedHeight,
|
|
172
|
+
props.sectionHeight,
|
|
173
|
+
props.height,
|
|
174
|
+
props.parallax,
|
|
175
|
+
props.refresh,
|
|
176
|
+
props.threshold,
|
|
177
|
+
],
|
|
178
|
+
bind,
|
|
179
|
+
{ immediate: true, flush: 'post' },
|
|
180
|
+
)
|
|
181
|
+
watch(
|
|
182
|
+
() => props.disabled,
|
|
183
|
+
(disabled) => {
|
|
184
|
+
if (disabled) {
|
|
185
|
+
cancel()
|
|
186
|
+
control?.pause()
|
|
187
|
+
} else control?.play()
|
|
188
|
+
},
|
|
189
|
+
)
|
|
190
|
+
onScopeDispose(() => {
|
|
191
|
+
release?.()
|
|
192
|
+
cancel()
|
|
193
|
+
})
|
|
194
|
+
expose({
|
|
195
|
+
refresh: () => control?.refresh() ?? Promise.resolve(false),
|
|
196
|
+
cancel,
|
|
197
|
+
scrollToTop: (animated = true) => control?.scrollToTop(animated),
|
|
198
|
+
})
|
|
199
|
+
return () => {
|
|
200
|
+
if (
|
|
201
|
+
!Number.isFinite(props.height) ||
|
|
202
|
+
props.height <= 0 ||
|
|
203
|
+
!(expanded() > minimum() && minimum() > 0) ||
|
|
204
|
+
!Number.isFinite(expanded()) ||
|
|
205
|
+
!Number.isFinite(minimum()) ||
|
|
206
|
+
props.sectionHeight < 0 ||
|
|
207
|
+
!Number.isFinite(props.sectionHeight) ||
|
|
208
|
+
props.parallax < 0 ||
|
|
209
|
+
props.parallax > 1
|
|
210
|
+
)
|
|
211
|
+
throw new RangeError(
|
|
212
|
+
'Scroll components require finite height, expandedHeight > collapsedHeight > 0, nonnegative sectionHeight and parallax between 0 and 1.',
|
|
213
|
+
)
|
|
214
|
+
const label = props.title ?? props.label ?? ''
|
|
215
|
+
const overlay =
|
|
216
|
+
platform === 'web'
|
|
217
|
+
? { position: 'absolute', top: 0, left: 0, right: 0, pointerEvents: 'none' }
|
|
218
|
+
: { verticalAlignment: 'top' }
|
|
219
|
+
const pointer = platform === 'web' ? { pointerEvents: 'auto' } : {}
|
|
220
|
+
const status =
|
|
221
|
+
state.value === 'refreshing'
|
|
222
|
+
? props.refreshingLabel
|
|
223
|
+
: state.value === 'error'
|
|
224
|
+
? props.errorLabel
|
|
225
|
+
: state.value === 'success'
|
|
226
|
+
? props.successLabel
|
|
227
|
+
: props.refreshLabel
|
|
228
|
+
const refreshButton = () =>
|
|
229
|
+
props.refresh
|
|
230
|
+
? h(ui.Button, {
|
|
231
|
+
text:
|
|
232
|
+
state.value === 'refreshing'
|
|
233
|
+
? props.cancelLabel
|
|
234
|
+
: state.value === 'error'
|
|
235
|
+
? props.retryLabel
|
|
236
|
+
: props.refreshLabel,
|
|
237
|
+
icon: state.value === 'refreshing' ? 'x' : 'refresh-cw',
|
|
238
|
+
variant: 'ghost',
|
|
239
|
+
size: 'sm',
|
|
240
|
+
disabled: props.disabled || !ready.value,
|
|
241
|
+
style: pointer,
|
|
242
|
+
onClick: () => (state.value === 'refreshing' ? cancel() : control?.refresh()),
|
|
243
|
+
})
|
|
244
|
+
: null
|
|
245
|
+
return h(
|
|
246
|
+
ui.Frame,
|
|
247
|
+
mergeProps(attrs, { id: props.id, region, source, height: props.height, label }),
|
|
248
|
+
{
|
|
249
|
+
default: () => [
|
|
250
|
+
!ready.value
|
|
251
|
+
? h(ui.Box, {
|
|
252
|
+
height: expanded() + (props.refreshMode ? 36 : props.sectionHeight),
|
|
253
|
+
accessibilityHidden: true,
|
|
254
|
+
})
|
|
255
|
+
: null,
|
|
256
|
+
slots.default?.({ state: state.value, refresh: () => control?.refresh(), cancel }),
|
|
257
|
+
],
|
|
258
|
+
overlay: () => [
|
|
259
|
+
h(
|
|
260
|
+
ui.Box,
|
|
261
|
+
{ motionSurface: header, height: expanded(), style: overlay },
|
|
262
|
+
{
|
|
263
|
+
default: () => [
|
|
264
|
+
h(
|
|
265
|
+
ui.Box,
|
|
266
|
+
{
|
|
267
|
+
motionSurface: artwork,
|
|
268
|
+
height: expanded(),
|
|
269
|
+
backgroundColor: theme.value.colors.surface,
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
default: () =>
|
|
273
|
+
props.image
|
|
274
|
+
? h(ui.Image, {
|
|
275
|
+
src: props.image,
|
|
276
|
+
alt: '',
|
|
277
|
+
decorative: true,
|
|
278
|
+
height: expanded(),
|
|
279
|
+
fit: 'cover',
|
|
280
|
+
})
|
|
281
|
+
: slots.artwork?.(),
|
|
282
|
+
},
|
|
283
|
+
),
|
|
284
|
+
h(
|
|
285
|
+
ui.Column,
|
|
286
|
+
{
|
|
287
|
+
padding: 'lg',
|
|
288
|
+
justify: 'end',
|
|
289
|
+
gap: 'xs',
|
|
290
|
+
...(props.image ? { backgroundColor: '#00000080' } : {}),
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
default: () => [
|
|
294
|
+
h(ui.Text, {
|
|
295
|
+
motionSurface: title,
|
|
296
|
+
text: label,
|
|
297
|
+
variant: props.refreshMode ? 'heading' : 'title',
|
|
298
|
+
...(props.image ? { style: { color: '#ffffff' } } : {}),
|
|
299
|
+
}),
|
|
300
|
+
props.subtitle
|
|
301
|
+
? h(ui.Text, {
|
|
302
|
+
text: props.subtitle,
|
|
303
|
+
tone: props.image ? undefined : 'muted',
|
|
304
|
+
...(props.image ? { style: { color: '#ffffff' } } : {}),
|
|
305
|
+
})
|
|
306
|
+
: null,
|
|
307
|
+
],
|
|
308
|
+
},
|
|
309
|
+
),
|
|
310
|
+
],
|
|
311
|
+
},
|
|
312
|
+
),
|
|
313
|
+
h(
|
|
314
|
+
ui.Box,
|
|
315
|
+
{
|
|
316
|
+
motionSurface: toolbar,
|
|
317
|
+
height: minimum(),
|
|
318
|
+
backgroundColor: theme.value.colors.surface,
|
|
319
|
+
style: overlay,
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
default: () =>
|
|
323
|
+
h(
|
|
324
|
+
ui.Row,
|
|
325
|
+
{ align: 'center', justify: 'between', gap: 'sm', paddingX: 'sm' },
|
|
326
|
+
{
|
|
327
|
+
default: () => [
|
|
328
|
+
props.back
|
|
329
|
+
? h(ui.Button, {
|
|
330
|
+
icon: 'arrow-left',
|
|
331
|
+
accessibilityLabel: props.backLabel,
|
|
332
|
+
variant: 'ghost',
|
|
333
|
+
size: 'sm',
|
|
334
|
+
style: pointer,
|
|
335
|
+
onClick: () => emit('back'),
|
|
336
|
+
})
|
|
337
|
+
: slots.leading?.(),
|
|
338
|
+
h(ui.Text, {
|
|
339
|
+
motionSurface: toolbarTitle,
|
|
340
|
+
text: label,
|
|
341
|
+
variant: 'heading',
|
|
342
|
+
shrink: 1,
|
|
343
|
+
}),
|
|
344
|
+
props.refresh
|
|
345
|
+
? refreshButton()
|
|
346
|
+
: h(ui.Button, {
|
|
347
|
+
icon: 'arrow-up',
|
|
348
|
+
accessibilityLabel: props.topLabel,
|
|
349
|
+
variant: 'ghost',
|
|
350
|
+
size: 'sm',
|
|
351
|
+
style: pointer,
|
|
352
|
+
onClick: () => control?.scrollToTop(),
|
|
353
|
+
}),
|
|
354
|
+
slots.actions?.(),
|
|
355
|
+
],
|
|
356
|
+
},
|
|
357
|
+
),
|
|
358
|
+
},
|
|
359
|
+
),
|
|
360
|
+
h(
|
|
361
|
+
ui.Box,
|
|
362
|
+
{
|
|
363
|
+
motionSurface: section,
|
|
364
|
+
height: props.refreshMode ? 36 : props.sectionHeight,
|
|
365
|
+
backgroundColor: theme.value.colors.surface,
|
|
366
|
+
style: overlay,
|
|
367
|
+
},
|
|
368
|
+
{
|
|
369
|
+
default: () =>
|
|
370
|
+
props.refreshMode
|
|
371
|
+
? h(ui.Text, {
|
|
372
|
+
text: status,
|
|
373
|
+
variant: 'caption',
|
|
374
|
+
tone: state.value === 'error' ? 'danger' : 'muted',
|
|
375
|
+
...(platform === 'web'
|
|
376
|
+
? {
|
|
377
|
+
role: 'status',
|
|
378
|
+
'aria-live': 'polite',
|
|
379
|
+
style: { padding: '6px 16px' },
|
|
380
|
+
}
|
|
381
|
+
: { accessibilityLiveRegion: 'polite', padding: 6 }),
|
|
382
|
+
})
|
|
383
|
+
: slots.section?.(),
|
|
384
|
+
},
|
|
385
|
+
),
|
|
386
|
+
],
|
|
387
|
+
},
|
|
388
|
+
)
|
|
389
|
+
}
|
|
390
|
+
},
|
|
391
|
+
})
|
|
392
|
+
const MCollapsibleHeader = defineComponent({
|
|
393
|
+
name: 'MCollapsibleHeader',
|
|
394
|
+
inheritAttrs: false,
|
|
395
|
+
props: collapsibleHeaderProps,
|
|
396
|
+
emits: ['back'],
|
|
397
|
+
setup(props, { attrs, slots, emit, expose }) {
|
|
398
|
+
const inner = ref<{ scrollToTop(animated?: boolean): void }>()
|
|
399
|
+
expose({ scrollToTop: (animated = true) => inner.value?.scrollToTop(animated) })
|
|
400
|
+
return () =>
|
|
401
|
+
h(ScrollFrame, mergeProps(attrs, props, { ref: inner, onBack: () => emit('back') }), slots)
|
|
402
|
+
},
|
|
403
|
+
})
|
|
404
|
+
const MRefreshControl = defineComponent({
|
|
405
|
+
name: 'MRefreshControl',
|
|
406
|
+
inheritAttrs: false,
|
|
407
|
+
props: refreshControlProps,
|
|
408
|
+
emits: ['stateChange', 'error'],
|
|
409
|
+
setup(props, { attrs, slots, emit, expose }) {
|
|
410
|
+
const inner = ref<{ refresh(): Promise<boolean>; cancel(): void }>()
|
|
411
|
+
expose({
|
|
412
|
+
refresh: () => inner.value?.refresh() ?? Promise.resolve(false),
|
|
413
|
+
cancel: () => inner.value?.cancel(),
|
|
414
|
+
})
|
|
415
|
+
return () =>
|
|
416
|
+
h(
|
|
417
|
+
ScrollFrame,
|
|
418
|
+
mergeProps(attrs, props, {
|
|
419
|
+
ref: inner,
|
|
420
|
+
refreshMode: true,
|
|
421
|
+
onStateChange: (s: RefreshState) => emit('stateChange', s),
|
|
422
|
+
onError: (e: unknown) => emit('error', e),
|
|
423
|
+
}),
|
|
424
|
+
slots,
|
|
425
|
+
)
|
|
426
|
+
},
|
|
427
|
+
})
|
|
428
|
+
return { MCollapsibleHeader, MRefreshControl }
|
|
429
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defineComponent,
|
|
3
|
+
h,
|
|
4
|
+
markRaw,
|
|
5
|
+
mergeProps,
|
|
6
|
+
onScopeDispose,
|
|
7
|
+
type Component,
|
|
8
|
+
} from '@vue/runtime-core'
|
|
9
|
+
import { createMotionSurface } from '../experimental.js'
|
|
10
|
+
import { uniqueActions, type SpeedDialAction } from '../screen-components.js'
|
|
11
|
+
import { speedDialProps } from './screen-component-props.js'
|
|
12
|
+
import type { ChoiceValue } from '../choice.js'
|
|
13
|
+
import { useMavisTheme } from './theme.js'
|
|
14
|
+
import { componentMotion } from '../motion.js'
|
|
15
|
+
|
|
16
|
+
export function createSpeedDial(ui: { Popover: Component; Column: Component; Button: Component }) {
|
|
17
|
+
const Action = defineComponent({
|
|
18
|
+
props: { index: { type: Number, required: true }, direction: String },
|
|
19
|
+
setup(props, { slots }) {
|
|
20
|
+
const { theme } = useMavisTheme()
|
|
21
|
+
const surface = markRaw(createMotionSurface())
|
|
22
|
+
onScopeDispose(
|
|
23
|
+
surface.use((owner) => {
|
|
24
|
+
owner.animate(
|
|
25
|
+
{ opacity: [0, 1], y: [props.direction === 'up' ? 12 : -12, 0], scale: [0.94, 1] },
|
|
26
|
+
{ ...componentMotion(theme.value, 'overlay'), delay: props.index * 35 },
|
|
27
|
+
)
|
|
28
|
+
}),
|
|
29
|
+
)
|
|
30
|
+
return () => h(ui.Column, { motionSurface: surface }, slots)
|
|
31
|
+
},
|
|
32
|
+
})
|
|
33
|
+
return defineComponent({
|
|
34
|
+
name: 'MSpeedDial',
|
|
35
|
+
inheritAttrs: false,
|
|
36
|
+
props: speedDialProps,
|
|
37
|
+
emits: {
|
|
38
|
+
'update:open': (_v: boolean) => true,
|
|
39
|
+
select: (_v: ChoiceValue, _a: SpeedDialAction) => true,
|
|
40
|
+
close: (_reason: string) => true,
|
|
41
|
+
},
|
|
42
|
+
setup(props, { attrs, emit }) {
|
|
43
|
+
return () =>
|
|
44
|
+
h(
|
|
45
|
+
ui.Popover,
|
|
46
|
+
mergeProps(attrs, {
|
|
47
|
+
id: props.id,
|
|
48
|
+
label: props.label,
|
|
49
|
+
triggerLabel: props.label,
|
|
50
|
+
icon: props.open ? 'x' : props.icon,
|
|
51
|
+
variant: 'primary',
|
|
52
|
+
open: props.open,
|
|
53
|
+
disabled: props.disabled,
|
|
54
|
+
placement: props.direction === 'up' ? 'top-end' : 'bottom-end',
|
|
55
|
+
width: 260,
|
|
56
|
+
padding: 'sm',
|
|
57
|
+
'onUpdate:open': (v: boolean) => emit('update:open', v),
|
|
58
|
+
onClose: (reason: string) => emit('close', reason),
|
|
59
|
+
}),
|
|
60
|
+
{
|
|
61
|
+
default: () =>
|
|
62
|
+
h(
|
|
63
|
+
ui.Column,
|
|
64
|
+
{ gap: 'xs' },
|
|
65
|
+
{
|
|
66
|
+
default: () => [
|
|
67
|
+
...uniqueActions(props.actions).map((action, index) =>
|
|
68
|
+
h(
|
|
69
|
+
Action,
|
|
70
|
+
{
|
|
71
|
+
key: `${typeof action.value}:${action.value}`,
|
|
72
|
+
index,
|
|
73
|
+
direction: props.direction,
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
default: () =>
|
|
77
|
+
h(ui.Button, {
|
|
78
|
+
text: action.label,
|
|
79
|
+
icon: action.icon,
|
|
80
|
+
variant: 'ghost',
|
|
81
|
+
disabled: props.disabled || action.disabled,
|
|
82
|
+
onClick: () => {
|
|
83
|
+
if (!props.disabled && !action.disabled) {
|
|
84
|
+
emit('select', action.value, action)
|
|
85
|
+
emit('update:open', false)
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
}),
|
|
89
|
+
},
|
|
90
|
+
),
|
|
91
|
+
),
|
|
92
|
+
h(ui.Button, {
|
|
93
|
+
text: props.closeLabel,
|
|
94
|
+
variant: 'ghost',
|
|
95
|
+
size: 'sm',
|
|
96
|
+
onClick: () => {
|
|
97
|
+
emit('update:open', false)
|
|
98
|
+
emit('close', 'action')
|
|
99
|
+
},
|
|
100
|
+
}),
|
|
101
|
+
],
|
|
102
|
+
},
|
|
103
|
+
),
|
|
104
|
+
},
|
|
105
|
+
)
|
|
106
|
+
},
|
|
107
|
+
})
|
|
108
|
+
}
|