@getcortexlabs/mavis-core 0.1.0-alpha.9 → 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 +48 -4
- package/dist/capabilities.js.map +1 -1
- package/dist/chart.d.ts +43 -0
- package/dist/chart.d.ts.map +1 -0
- package/dist/chart.js +105 -0
- package/dist/chart.js.map +1 -0
- package/dist/collections.d.ts +46 -0
- package/dist/collections.d.ts.map +1 -0
- package/dist/collections.js +48 -0
- package/dist/collections.js.map +1 -0
- package/dist/contracts.d.ts +20 -0
- package/dist/contracts.d.ts.map +1 -1
- package/dist/contracts.js +2 -0
- package/dist/contracts.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/discovery.d.ts +49 -0
- package/dist/discovery.d.ts.map +1 -0
- package/dist/discovery.js +80 -0
- package/dist/discovery.js.map +1 -0
- package/dist/experimental-regions.d.ts +10 -0
- package/dist/experimental-regions.d.ts.map +1 -1
- package/dist/experimental-regions.js +23 -0
- package/dist/experimental-regions.js.map +1 -1
- package/dist/experimental.d.ts +5 -0
- package/dist/experimental.d.ts.map +1 -1
- package/dist/experimental.js +29 -0
- package/dist/experimental.js.map +1 -1
- package/dist/index.d.ts +15 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -1
- package/dist/index.js.map +1 -1
- package/dist/interactive.d.ts +36 -0
- package/dist/interactive.d.ts.map +1 -0
- package/dist/interactive.js +61 -0
- package/dist/interactive.js.map +1 -0
- package/dist/link.d.ts +2 -0
- package/dist/link.d.ts.map +1 -1
- package/dist/link.js.map +1 -1
- package/dist/motion.d.ts +8 -0
- package/dist/motion.d.ts.map +1 -1
- package/dist/motion.js +11 -0
- package/dist/motion.js.map +1 -1
- package/dist/navigation-transition.d.ts +10 -0
- package/dist/navigation-transition.d.ts.map +1 -0
- package/dist/navigation-transition.js +10 -0
- package/dist/navigation-transition.js.map +1 -0
- package/dist/number-flow-format.d.ts +16 -0
- package/dist/number-flow-format.d.ts.map +1 -0
- package/dist/number-flow-format.js +49 -0
- package/dist/number-flow-format.js.map +1 -0
- package/dist/popover.d.ts +17 -0
- package/dist/popover.d.ts.map +1 -0
- package/dist/popover.js +19 -0
- package/dist/popover.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/section-scroll.d.ts +14 -0
- package/dist/section-scroll.d.ts.map +1 -0
- package/dist/section-scroll.js +28 -0
- package/dist/section-scroll.js.map +1 -0
- package/dist/time.d.ts +34 -0
- package/dist/time.d.ts.map +1 -0
- package/dist/time.js +78 -0
- package/dist/time.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/carousel.d.ts +13 -0
- package/dist/vue/carousel.d.ts.map +1 -0
- package/dist/vue/carousel.js +136 -0
- package/dist/vue/carousel.js.map +1 -0
- package/dist/vue/chart.d.ts +194 -0
- package/dist/vue/chart.d.ts.map +1 -0
- package/dist/vue/chart.js +245 -0
- package/dist/vue/chart.js.map +1 -0
- package/dist/vue/command-palette.d.ts +129 -0
- package/dist/vue/command-palette.d.ts.map +1 -0
- package/dist/vue/command-palette.js +190 -0
- package/dist/vue/command-palette.js.map +1 -0
- package/dist/vue/component-motion.d.ts +17 -0
- package/dist/vue/component-motion.d.ts.map +1 -0
- package/dist/vue/component-motion.js +83 -0
- package/dist/vue/component-motion.js.map +1 -0
- package/dist/vue/component-props.d.ts +1708 -21
- package/dist/vue/component-props.d.ts.map +1 -1
- package/dist/vue/component-props.js +50 -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 +2 -2
- package/dist/vue/configurator.d.ts.map +1 -1
- package/dist/vue/configurator.js +3 -1
- package/dist/vue/configurator.js.map +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/data-table.d.ts +17 -0
- package/dist/vue/data-table.d.ts.map +1 -0
- package/dist/vue/data-table.js +133 -0
- package/dist/vue/data-table.js.map +1 -0
- package/dist/vue/date-calendar.d.ts +2 -0
- package/dist/vue/date-calendar.d.ts.map +1 -1
- package/dist/vue/date-calendar.js +20 -1
- package/dist/vue/date-calendar.js.map +1 -1
- package/dist/vue/date-picker.d.ts +8 -8
- package/dist/vue/date-props.d.ts +6 -0
- package/dist/vue/date-props.d.ts.map +1 -1
- package/dist/vue/date-props.js +3 -0
- package/dist/vue/date-props.js.map +1 -1
- package/dist/vue/discovery-components.d.ts +50 -0
- package/dist/vue/discovery-components.d.ts.map +1 -0
- package/dist/vue/discovery-components.js +2 -0
- package/dist/vue/discovery-components.js.map +1 -0
- package/dist/vue/discovery-controls.d.ts +197 -0
- package/dist/vue/discovery-controls.d.ts.map +1 -0
- package/dist/vue/discovery-controls.js +185 -0
- package/dist/vue/discovery-controls.js.map +1 -0
- package/dist/vue/discovery-props.d.ts +249 -0
- package/dist/vue/discovery-props.d.ts.map +1 -0
- package/dist/vue/discovery-props.js +87 -0
- package/dist/vue/discovery-props.js.map +1 -0
- package/dist/vue/global-components.d.ts +237 -0
- package/dist/vue/global-components.d.ts.map +1 -1
- package/dist/vue/index.d.ts +41 -0
- package/dist/vue/index.d.ts.map +1 -1
- package/dist/vue/index.js +37 -0
- package/dist/vue/index.js.map +1 -1
- package/dist/vue/interactive-components.d.ts +31 -0
- package/dist/vue/interactive-components.d.ts.map +1 -0
- package/dist/vue/interactive-components.js +2 -0
- package/dist/vue/interactive-components.js.map +1 -0
- package/dist/vue/interactive-props.d.ts +254 -0
- package/dist/vue/interactive-props.d.ts.map +1 -0
- package/dist/vue/interactive-props.js +85 -0
- package/dist/vue/interactive-props.js.map +1 -0
- 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/list-motion.d.ts +7 -0
- package/dist/vue/list-motion.d.ts.map +1 -0
- package/dist/vue/list-motion.js +28 -0
- package/dist/vue/list-motion.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 +122 -0
- package/dist/vue/menu.d.ts.map +1 -0
- package/dist/vue/menu.js +79 -0
- package/dist/vue/menu.js.map +1 -0
- package/dist/vue/navigation-controls.d.ts +125 -0
- package/dist/vue/navigation-controls.d.ts.map +1 -0
- package/dist/vue/navigation-controls.js +130 -0
- package/dist/vue/navigation-controls.js.map +1 -0
- package/dist/vue/navigation-props.d.ts +283 -0
- package/dist/vue/navigation-props.d.ts.map +1 -0
- package/dist/vue/navigation-props.js +82 -0
- package/dist/vue/navigation-props.js.map +1 -0
- package/dist/vue/number-flow.d.ts +75 -0
- package/dist/vue/number-flow.d.ts.map +1 -0
- package/dist/vue/number-flow.js +57 -0
- package/dist/vue/number-flow.js.map +1 -0
- package/dist/vue/partition.d.ts +15 -0
- package/dist/vue/partition.d.ts.map +1 -0
- package/dist/vue/partition.js +42 -0
- package/dist/vue/partition.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/platform.d.ts +37 -0
- package/dist/vue/platform.d.ts.map +1 -0
- package/dist/vue/platform.js +46 -0
- package/dist/vue/platform.js.map +1 -0
- package/dist/vue/props.d.ts +82 -42
- package/dist/vue/props.d.ts.map +1 -1
- package/dist/vue/props.js +3 -1
- package/dist/vue/props.js.map +1 -1
- 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/sortable-list.d.ts +24 -0
- package/dist/vue/sortable-list.d.ts.map +1 -0
- package/dist/vue/sortable-list.js +251 -0
- package/dist/vue/sortable-list.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 +96 -0
- package/dist/vue/swipe-actions.d.ts.map +1 -0
- package/dist/vue/swipe-actions.js +174 -0
- package/dist/vue/swipe-actions.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 +488 -0
- package/dist/vue/time-picker.d.ts.map +1 -0
- package/dist/vue/time-picker.js +190 -0
- package/dist/vue/time-picker.js.map +1 -0
- 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 +111 -0
- package/dist/vue/tree-view.d.ts.map +1 -0
- package/dist/vue/tree-view.js +204 -0
- package/dist/vue/tree-view.js.map +1 -0
- package/dist/vue/virtual-list.d.ts +26 -0
- package/dist/vue/virtual-list.d.ts.map +1 -0
- package/dist/vue/virtual-list.js +2 -0
- package/dist/vue/virtual-list.js.map +1 -0
- package/dist/vue/wayfinding-controls.d.ts +199 -0
- package/dist/vue/wayfinding-controls.d.ts.map +1 -0
- package/dist/vue/wayfinding-controls.js +330 -0
- package/dist/vue/wayfinding-controls.js.map +1 -0
- package/dist/vue/wayfinding-props.d.ts +221 -0
- package/dist/vue/wayfinding-props.d.ts.map +1 -0
- package/dist/vue/wayfinding-props.js +86 -0
- package/dist/vue/wayfinding-props.js.map +1 -0
- package/dist/vue/workflows.d.ts +2 -2
- package/dist/vue/workflows.d.ts.map +1 -1
- package/dist/vue/workflows.js +17 -4
- package/dist/vue/workflows.js.map +1 -1
- package/dist/wayfinding.d.ts +50 -0
- package/dist/wayfinding.d.ts.map +1 -0
- package/dist/wayfinding.js +54 -0
- package/dist/wayfinding.js.map +1 -0
- package/package.json +2 -2
- package/src/capabilities.ts +50 -4
- package/src/chart.ts +151 -0
- package/src/collections.ts +87 -0
- package/src/contracts.ts +2 -0
- package/src/creative-controls.ts +169 -0
- package/src/dashboard.ts +164 -0
- package/src/discovery.ts +139 -0
- package/src/experimental-regions.ts +29 -0
- package/src/experimental.ts +40 -0
- package/src/index.ts +23 -1
- package/src/interactive.ts +91 -0
- package/src/link.ts +2 -0
- package/src/motion.ts +14 -0
- package/src/navigation-transition.ts +14 -0
- package/src/number-flow-format.ts +68 -0
- package/src/popover.ts +38 -0
- package/src/screen-components.ts +59 -0
- package/src/section-scroll.ts +46 -0
- package/src/time.ts +83 -0
- package/src/vue/animated-text.ts +72 -0
- package/src/vue/carousel.ts +198 -0
- package/src/vue/chart.ts +337 -0
- package/src/vue/command-palette.ts +235 -0
- package/src/vue/component-motion.ts +109 -0
- package/src/vue/component-props.ts +104 -0
- package/src/vue/composer.ts +192 -0
- package/src/vue/configurator.ts +3 -1
- 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/data-table.ts +190 -0
- package/src/vue/date-calendar.ts +30 -1
- package/src/vue/date-props.ts +3 -0
- package/src/vue/discovery-components.ts +60 -0
- package/src/vue/discovery-controls.ts +241 -0
- package/src/vue/discovery-props.ts +92 -0
- package/src/vue/global-components.ts +237 -0
- package/src/vue/index.ts +64 -0
- package/src/vue/interactive-components.ts +29 -0
- package/src/vue/interactive-props.ts +90 -0
- package/src/vue/kanban.ts +360 -0
- package/src/vue/list-motion.ts +31 -0
- package/src/vue/marquee.ts +248 -0
- package/src/vue/menu.ts +100 -0
- package/src/vue/navigation-controls.ts +159 -0
- package/src/vue/navigation-props.ts +87 -0
- package/src/vue/number-flow.ts +83 -0
- package/src/vue/partition.ts +49 -0
- package/src/vue/pin-cell.ts +26 -0
- package/src/vue/pin-input.ts +31 -0
- package/src/vue/platform.ts +73 -0
- package/src/vue/props.ts +3 -1
- package/src/vue/screen-component-props.ts +92 -0
- package/src/vue/scroll-frame.ts +429 -0
- package/src/vue/sortable-list.ts +308 -0
- package/src/vue/speed-dial.ts +108 -0
- package/src/vue/swipe-actions.ts +226 -0
- package/src/vue/swipe-deck.ts +277 -0
- package/src/vue/time-picker.ts +227 -0
- package/src/vue/tour.ts +239 -0
- package/src/vue/tree-view.ts +259 -0
- package/src/vue/virtual-list.ts +28 -0
- package/src/vue/wayfinding-controls.ts +430 -0
- package/src/vue/wayfinding-props.ts +97 -0
- package/src/vue/workflows.ts +17 -4
- package/src/wayfinding.ts +85 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import type { PropType } from '@vue/runtime-core'
|
|
2
|
+
import type { ComposerAttachment, RefreshAction, SpeedDialAction } from '../screen-components.js'
|
|
3
|
+
import { textProps, inputProps, buttonProps } from './props.js'
|
|
4
|
+
|
|
5
|
+
const label = { type: String, required: true as const }
|
|
6
|
+
export const animatedTextProps = {
|
|
7
|
+
id: String,
|
|
8
|
+
text: label,
|
|
9
|
+
variant: { ...textProps.variant, default: 'title' },
|
|
10
|
+
tone: textProps.tone,
|
|
11
|
+
by: { type: String as PropType<'word' | 'letter'>, default: 'word' },
|
|
12
|
+
duration: { type: Number, default: 650 },
|
|
13
|
+
stagger: { type: Number, default: 35 },
|
|
14
|
+
distance: { type: Number, default: 16 },
|
|
15
|
+
animated: { type: Boolean, default: true },
|
|
16
|
+
appear: { type: Boolean, default: true },
|
|
17
|
+
replayKey: { type: [String, Number], default: 0 },
|
|
18
|
+
}
|
|
19
|
+
export const composerProps = {
|
|
20
|
+
id: String,
|
|
21
|
+
label,
|
|
22
|
+
modelValue: { type: String, default: '' },
|
|
23
|
+
placeholder: String,
|
|
24
|
+
disabled: Boolean,
|
|
25
|
+
readonly: Boolean,
|
|
26
|
+
loading: Boolean,
|
|
27
|
+
maxLength: inputProps.maxLength,
|
|
28
|
+
rows: { type: Number, default: 2 },
|
|
29
|
+
error: String,
|
|
30
|
+
attachments: { type: Array as PropType<readonly ComposerAttachment[]>, default: () => [] },
|
|
31
|
+
attachable: { type: Boolean, default: true },
|
|
32
|
+
attachLabel: { type: String, default: 'Add attachment' },
|
|
33
|
+
removeLabel: { type: String, default: 'Remove attachment' },
|
|
34
|
+
sendLabel: { type: String, default: 'Send message' },
|
|
35
|
+
sendingLabel: { type: String, default: 'Sending' },
|
|
36
|
+
/** Use only for an overlay composer; ordinary flowing content follows its screen. */
|
|
37
|
+
followKeyboard: Boolean,
|
|
38
|
+
keyboardOffset: { type: Number, default: 0 },
|
|
39
|
+
/** Ctrl/Cmd+Enter only. Plain Enter always retains multiline editing. */
|
|
40
|
+
shortcut: { type: Boolean, default: true },
|
|
41
|
+
}
|
|
42
|
+
export const pinInputProps = {
|
|
43
|
+
id: String,
|
|
44
|
+
label,
|
|
45
|
+
modelValue: { type: String, default: '' },
|
|
46
|
+
length: { type: Number, default: 6 },
|
|
47
|
+
disabled: Boolean,
|
|
48
|
+
readonly: Boolean,
|
|
49
|
+
required: Boolean,
|
|
50
|
+
name: String,
|
|
51
|
+
form: String,
|
|
52
|
+
error: String,
|
|
53
|
+
helperText: String,
|
|
54
|
+
}
|
|
55
|
+
export const speedDialProps = {
|
|
56
|
+
id: String,
|
|
57
|
+
label,
|
|
58
|
+
open: Boolean,
|
|
59
|
+
disabled: Boolean,
|
|
60
|
+
actions: { type: Array as PropType<readonly SpeedDialAction[]>, required: true as const },
|
|
61
|
+
icon: { ...buttonProps.icon, default: 'plus' },
|
|
62
|
+
closeLabel: { type: String, default: 'Close actions' },
|
|
63
|
+
direction: { type: String as PropType<'up' | 'down'>, default: 'up' },
|
|
64
|
+
}
|
|
65
|
+
export const refreshControlProps = {
|
|
66
|
+
id: String,
|
|
67
|
+
label,
|
|
68
|
+
refresh: { type: Function as PropType<RefreshAction>, required: true as const },
|
|
69
|
+
height: { type: Number, default: 480 },
|
|
70
|
+
disabled: Boolean,
|
|
71
|
+
threshold: { type: Number, default: 80 },
|
|
72
|
+
refreshLabel: { type: String, default: 'Refresh' },
|
|
73
|
+
refreshingLabel: { type: String, default: 'Refreshing' },
|
|
74
|
+
successLabel: { type: String, default: 'Up to date' },
|
|
75
|
+
errorLabel: { type: String, default: 'Could not refresh' },
|
|
76
|
+
retryLabel: { type: String, default: 'Try again' },
|
|
77
|
+
cancelLabel: { type: String, default: 'Cancel refresh' },
|
|
78
|
+
}
|
|
79
|
+
export const collapsibleHeaderProps = {
|
|
80
|
+
id: String,
|
|
81
|
+
title: label,
|
|
82
|
+
subtitle: String,
|
|
83
|
+
image: String,
|
|
84
|
+
height: { type: Number, default: 540 },
|
|
85
|
+
expandedHeight: { type: Number, default: 240 },
|
|
86
|
+
collapsedHeight: { type: Number, default: 64 },
|
|
87
|
+
sectionHeight: { type: Number, default: 0 },
|
|
88
|
+
parallax: { type: Number, default: 0.35 },
|
|
89
|
+
backLabel: { type: String, default: 'Go back' },
|
|
90
|
+
back: Boolean,
|
|
91
|
+
topLabel: { type: String, default: 'Back to top' },
|
|
92
|
+
}
|
|
@@ -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
|
+
}
|