@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.
Files changed (125) hide show
  1. package/README.md +2 -2
  2. package/dist/capabilities.d.ts +7 -7
  3. package/dist/capabilities.d.ts.map +1 -1
  4. package/dist/capabilities.js +23 -4
  5. package/dist/capabilities.js.map +1 -1
  6. package/dist/creative-controls.d.ts +47 -0
  7. package/dist/creative-controls.d.ts.map +1 -0
  8. package/dist/creative-controls.js +112 -0
  9. package/dist/creative-controls.js.map +1 -0
  10. package/dist/dashboard.d.ts +72 -0
  11. package/dist/dashboard.d.ts.map +1 -0
  12. package/dist/dashboard.js +115 -0
  13. package/dist/dashboard.js.map +1 -0
  14. package/dist/index.d.ts +3 -0
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +3 -0
  17. package/dist/index.js.map +1 -1
  18. package/dist/screen-components.d.ts +45 -0
  19. package/dist/screen-components.d.ts.map +1 -0
  20. package/dist/screen-components.js +23 -0
  21. package/dist/screen-components.js.map +1 -0
  22. package/dist/vue/animated-text.d.ts +101 -0
  23. package/dist/vue/animated-text.d.ts.map +1 -0
  24. package/dist/vue/animated-text.js +56 -0
  25. package/dist/vue/animated-text.js.map +1 -0
  26. package/dist/vue/component-props.d.ts +692 -3
  27. package/dist/vue/component-props.d.ts.map +1 -1
  28. package/dist/vue/component-props.js +22 -0
  29. package/dist/vue/component-props.js.map +1 -1
  30. package/dist/vue/composer.d.ts +159 -0
  31. package/dist/vue/composer.d.ts.map +1 -0
  32. package/dist/vue/composer.js +142 -0
  33. package/dist/vue/composer.js.map +1 -0
  34. package/dist/vue/configurator.d.ts +1 -1
  35. package/dist/vue/creative-controls.d.ts +328 -0
  36. package/dist/vue/creative-controls.d.ts.map +1 -0
  37. package/dist/vue/creative-controls.js +396 -0
  38. package/dist/vue/creative-controls.js.map +1 -0
  39. package/dist/vue/creative-props.d.ts +260 -0
  40. package/dist/vue/creative-props.d.ts.map +1 -0
  41. package/dist/vue/creative-props.js +92 -0
  42. package/dist/vue/creative-props.js.map +1 -0
  43. package/dist/vue/dashboard-charts.d.ts +240 -0
  44. package/dist/vue/dashboard-charts.d.ts.map +1 -0
  45. package/dist/vue/dashboard-charts.js +263 -0
  46. package/dist/vue/dashboard-charts.js.map +1 -0
  47. package/dist/vue/dashboard-effects.d.ts +211 -0
  48. package/dist/vue/dashboard-effects.d.ts.map +1 -0
  49. package/dist/vue/dashboard-effects.js +235 -0
  50. package/dist/vue/dashboard-effects.js.map +1 -0
  51. package/dist/vue/dashboard-props.d.ts +244 -0
  52. package/dist/vue/dashboard-props.d.ts.map +1 -0
  53. package/dist/vue/dashboard-props.js +94 -0
  54. package/dist/vue/dashboard-props.js.map +1 -0
  55. package/dist/vue/discovery-controls.d.ts +1 -1
  56. package/dist/vue/global-components.d.ts +106 -0
  57. package/dist/vue/global-components.d.ts.map +1 -1
  58. package/dist/vue/index.d.ts +16 -0
  59. package/dist/vue/index.d.ts.map +1 -1
  60. package/dist/vue/index.js +16 -0
  61. package/dist/vue/index.js.map +1 -1
  62. package/dist/vue/kanban.d.ts +150 -0
  63. package/dist/vue/kanban.d.ts.map +1 -0
  64. package/dist/vue/kanban.js +267 -0
  65. package/dist/vue/kanban.js.map +1 -0
  66. package/dist/vue/marquee.d.ts +96 -0
  67. package/dist/vue/marquee.d.ts.map +1 -0
  68. package/dist/vue/marquee.js +186 -0
  69. package/dist/vue/marquee.js.map +1 -0
  70. package/dist/vue/pin-cell.d.ts +14 -0
  71. package/dist/vue/pin-cell.d.ts.map +1 -0
  72. package/dist/vue/pin-cell.js +19 -0
  73. package/dist/vue/pin-cell.js.map +1 -0
  74. package/dist/vue/pin-input.d.ts +14 -0
  75. package/dist/vue/pin-input.d.ts.map +1 -0
  76. package/dist/vue/pin-input.js +23 -0
  77. package/dist/vue/pin-input.js.map +1 -0
  78. package/dist/vue/props.d.ts +6 -6
  79. package/dist/vue/screen-component-props.d.ts +236 -0
  80. package/dist/vue/screen-component-props.d.ts.map +1 -0
  81. package/dist/vue/screen-component-props.js +90 -0
  82. package/dist/vue/screen-component-props.js.map +1 -0
  83. package/dist/vue/scroll-frame.d.ts +223 -0
  84. package/dist/vue/scroll-frame.d.ts.map +1 -0
  85. package/dist/vue/scroll-frame.js +346 -0
  86. package/dist/vue/scroll-frame.js.map +1 -0
  87. package/dist/vue/speed-dial.d.ts +73 -0
  88. package/dist/vue/speed-dial.d.ts.map +1 -0
  89. package/dist/vue/speed-dial.js +78 -0
  90. package/dist/vue/speed-dial.js.map +1 -0
  91. package/dist/vue/swipe-deck.d.ts +120 -0
  92. package/dist/vue/swipe-deck.d.ts.map +1 -0
  93. package/dist/vue/swipe-deck.js +229 -0
  94. package/dist/vue/swipe-deck.js.map +1 -0
  95. package/dist/vue/time-picker.d.ts +2 -2
  96. package/dist/vue/tour.d.ts +120 -0
  97. package/dist/vue/tour.d.ts.map +1 -0
  98. package/dist/vue/tour.js +165 -0
  99. package/dist/vue/tour.js.map +1 -0
  100. package/dist/vue/tree-view.d.ts +1 -1
  101. package/package.json +1 -1
  102. package/src/capabilities.ts +24 -4
  103. package/src/creative-controls.ts +169 -0
  104. package/src/dashboard.ts +164 -0
  105. package/src/index.ts +5 -0
  106. package/src/screen-components.ts +59 -0
  107. package/src/vue/animated-text.ts +72 -0
  108. package/src/vue/component-props.ts +47 -0
  109. package/src/vue/composer.ts +192 -0
  110. package/src/vue/creative-controls.ts +524 -0
  111. package/src/vue/creative-props.ts +94 -0
  112. package/src/vue/dashboard-charts.ts +346 -0
  113. package/src/vue/dashboard-effects.ts +304 -0
  114. package/src/vue/dashboard-props.ts +95 -0
  115. package/src/vue/global-components.ts +116 -0
  116. package/src/vue/index.ts +20 -0
  117. package/src/vue/kanban.ts +360 -0
  118. package/src/vue/marquee.ts +248 -0
  119. package/src/vue/pin-cell.ts +26 -0
  120. package/src/vue/pin-input.ts +31 -0
  121. package/src/vue/screen-component-props.ts +92 -0
  122. package/src/vue/scroll-frame.ts +429 -0
  123. package/src/vue/speed-dial.ts +108 -0
  124. package/src/vue/swipe-deck.ts +277 -0
  125. package/src/vue/tour.ts +239 -0
@@ -0,0 +1,248 @@
1
+ import {
2
+ computed,
3
+ defineComponent,
4
+ h,
5
+ markRaw,
6
+ mergeProps,
7
+ onScopeDispose,
8
+ ref,
9
+ watch,
10
+ type Component,
11
+ } from '@vue/runtime-core'
12
+ import { createMotionSurface, type MotionControlledPlayback } from '../experimental.js'
13
+ import { validateCards } from '../creative-controls.js'
14
+ import { marqueeProps } from './creative-props.js'
15
+ import type { CreativeUI } from './creative-controls.js'
16
+
17
+ export const marqueeHostProps = { moving: Boolean }
18
+ export function createMarquee(
19
+ ui: CreativeUI & { MarqueeHost: Component },
20
+ platform: 'web' | 'native',
21
+ ) {
22
+ return defineComponent({
23
+ name: 'MMarquee',
24
+ inheritAttrs: false,
25
+ props: marqueeProps,
26
+ emits: { 'update:paused': (_paused: boolean) => true },
27
+ setup(props, { attrs, emit }) {
28
+ const surface = markRaw(createMotionSurface())
29
+ const environment = ref({ reduced: true, paused: true, width: 0 })
30
+ const requested = ref(props.autoplay),
31
+ failed = ref(false),
32
+ available = ref(false)
33
+ const distance = computed(() => props.items.length * (props.itemWidth + props.gap))
34
+ const moving = computed(
35
+ () =>
36
+ requested.value && !environment.value.reduced && !failed.value && props.items.length > 0,
37
+ )
38
+ const running = computed(() => moving.value && !props.paused && !environment.value.paused)
39
+ let playback: MotionControlledPlayback | undefined,
40
+ generation = 0
41
+ function stop() {
42
+ generation++
43
+ playback?.stop()
44
+ playback = undefined
45
+ }
46
+ function cycle(progress = 0) {
47
+ if (!available.value || !moving.value) return
48
+ const token = generation,
49
+ start = Date.now()
50
+ const [from, to] = props.direction === 'left' ? [0, -distance.value] : [-distance.value, 0]
51
+ playback = surface.animate(
52
+ { x: [from, to] },
53
+ { type: 'tween', duration: (distance.value / props.speed) * 1000, ease: 'linear' },
54
+ )
55
+ if (progress > 0) playback.progress = progress
56
+ if (!running.value) playback.pause()
57
+ else if (playback.paused) playback.resume()
58
+ void playback.finished.then((completed) => {
59
+ if (token !== generation || !completed) return
60
+ // A disabled backend can finish immediately. Do not spin a microtask loop.
61
+ if (Date.now() - start < 16) {
62
+ failed.value = true
63
+ return
64
+ }
65
+ cycle()
66
+ })
67
+ }
68
+ function rebuild() {
69
+ // Cloning or wrapping items changes the transform origin. Refresh Jolt's
70
+ // geometry after Vue patches, before stopping or starting its playback.
71
+ if (available.value) surface.refresh()
72
+ const progress = playback?.progress ?? 0
73
+ stop()
74
+ if (moving.value) cycle(progress)
75
+ else if (surface.available) surface.set({ x: 0 })
76
+ }
77
+ onScopeDispose(
78
+ surface.use(() => {
79
+ surface.set({ x: 0 })
80
+ available.value = true
81
+ rebuild()
82
+ return () => {
83
+ available.value = false
84
+ stop()
85
+ }
86
+ }),
87
+ )
88
+ watch(
89
+ () => props.autoplay,
90
+ (value) => {
91
+ requested.value = value
92
+ },
93
+ )
94
+ watch(
95
+ () => [distance.value, props.speed, props.direction, moving.value, environment.value.width],
96
+ rebuild,
97
+ {
98
+ flush: 'post',
99
+ },
100
+ )
101
+ watch(running, (run) => {
102
+ if (!available.value || !playback) return
103
+ if (run) playback.resume()
104
+ else playback.pause()
105
+ })
106
+ onScopeDispose(stop)
107
+ return () => {
108
+ validateCards(props.items.map((item) => ({ id: item.id, title: item.label })))
109
+ if (
110
+ !Number.isFinite(props.speed) ||
111
+ props.speed <= 0 ||
112
+ props.speed > 500 ||
113
+ !Number.isFinite(props.itemWidth) ||
114
+ props.itemWidth < 80 ||
115
+ !Number.isFinite(props.gap) ||
116
+ props.gap < 0
117
+ )
118
+ throw new RangeError(
119
+ 'Marquee requires speed in (0, 500], itemWidth >= 80 and a nonnegative gap.',
120
+ )
121
+ const copies = moving.value
122
+ ? Math.max(2, Math.ceil(environment.value.width / Math.max(1, distance.value)) + 1)
123
+ : 1
124
+ return h(
125
+ ui.Column,
126
+ mergeProps(attrs, {
127
+ id: props.id,
128
+ gap: 'sm',
129
+ ...(platform === 'web'
130
+ ? { class: 'm-marquee', role: 'region', 'aria-label': props.label }
131
+ : { accessibilityLabel: props.label }),
132
+ }),
133
+ {
134
+ default: () => [
135
+ h(
136
+ ui.Row,
137
+ { gap: 'sm', justify: 'between', wrap: true },
138
+ {
139
+ default: () => [
140
+ h(ui.Text, { text: props.label, variant: 'heading' }),
141
+ h(ui.Button, {
142
+ text: requested.value && !props.paused ? props.pauseLabel : props.playLabel,
143
+ variant: 'ghost',
144
+ size: 'sm',
145
+ disabled: environment.value.reduced || !props.items.length,
146
+ onClick: () => {
147
+ const next = !requested.value || props.paused
148
+ requested.value = next
149
+ failed.value = false
150
+ emit('update:paused', !next)
151
+ },
152
+ }),
153
+ ],
154
+ },
155
+ ),
156
+ h(
157
+ ui.MarqueeHost,
158
+ {
159
+ moving: moving.value,
160
+ onEnvironment: (value: typeof environment.value) => {
161
+ environment.value = value
162
+ },
163
+ },
164
+ {
165
+ default: () =>
166
+ h(
167
+ ui.Box,
168
+ {
169
+ id: props.id ? `${props.id}-track` : undefined,
170
+ motionSurface: surface,
171
+ ...(platform === 'web'
172
+ ? {
173
+ style: {
174
+ width: moving.value ? `${distance.value * copies}px` : '100%',
175
+ },
176
+ }
177
+ : {
178
+ width: moving.value ? distance.value * copies : '100%',
179
+ horizontalAlignment: 'left',
180
+ }),
181
+ },
182
+ {
183
+ default: () =>
184
+ h(
185
+ ui.Row,
186
+ {
187
+ gap: props.gap,
188
+ wrap: !moving.value,
189
+ ...(platform === 'web' ? { role: 'list' } : {}),
190
+ },
191
+ {
192
+ default: () =>
193
+ Array.from({ length: copies }, (_, copy) =>
194
+ props.items.map((item) =>
195
+ h(
196
+ ui.Card,
197
+ {
198
+ key: `${copy}:${typeof item.id}:${item.id}`,
199
+ width: props.itemWidth,
200
+ padding: 'md',
201
+ accessibilityHidden: copy > 0,
202
+ ...(platform === 'web'
203
+ ? {
204
+ role: 'listitem',
205
+ inert: copy > 0 || undefined,
206
+ style: { flexShrink: 0 },
207
+ }
208
+ : {}),
209
+ },
210
+ {
211
+ default: () =>
212
+ h(
213
+ ui.Column,
214
+ { gap: 'sm' },
215
+ {
216
+ default: () => [
217
+ item.image
218
+ ? h(ui.Image, {
219
+ src: item.image,
220
+ alt: '',
221
+ height: 64,
222
+ fit: 'contain',
223
+ })
224
+ : null,
225
+ h(ui.Text, {
226
+ text: item.label,
227
+ variant: 'heading',
228
+ }),
229
+ ],
230
+ },
231
+ ),
232
+ },
233
+ ),
234
+ ),
235
+ ),
236
+ },
237
+ ),
238
+ },
239
+ ),
240
+ },
241
+ ),
242
+ ],
243
+ },
244
+ )
245
+ }
246
+ },
247
+ })
248
+ }
@@ -0,0 +1,26 @@
1
+ import { defineComponent, h, mergeProps, type Component } from '@vue/runtime-core'
2
+ import { useComponentState } from './component-motion.js'
3
+
4
+ /** Decorative cells animate independently; the real editor never moves. */
5
+ export function createPinCell(Text: Component) {
6
+ return defineComponent({
7
+ name: 'MPinCell',
8
+ inheritAttrs: false,
9
+ props: { active: Boolean, digit: String },
10
+ setup(props, { attrs }) {
11
+ const surface = useComponentState(
12
+ () => ({ scale: props.active ? 1.04 : 1, opacity: props.digit ? 1 : 0.8 }),
13
+ 'feedback',
14
+ )
15
+ return () =>
16
+ h(
17
+ Text,
18
+ mergeProps(attrs, {
19
+ motionSurface: surface,
20
+ text: props.digit ?? '',
21
+ accessibilityHidden: true,
22
+ }),
23
+ )
24
+ },
25
+ })
26
+ }
@@ -0,0 +1,31 @@
1
+ import { computed, ref, watch } from '@vue/runtime-core'
2
+ import { normalizePin, pinLength } from '../screen-components.js'
3
+ import { useComponentContent } from './component-motion.js'
4
+
5
+ export function usePinInput(
6
+ props: {
7
+ modelValue: string
8
+ length: number
9
+ disabled: boolean
10
+ readonly: boolean
11
+ error?: string
12
+ },
13
+ emit: (event: 'update:modelValue' | 'complete' | 'focus' | 'blur', value?: string) => void,
14
+ ) {
15
+ const focused = ref(false),
16
+ position = ref(0)
17
+ const value = computed(() => normalizePin(props.modelValue, props.length))
18
+ const feedback = useComponentContent(() => props.error, false)
19
+ const change = (raw: string) => {
20
+ if (props.disabled || props.readonly) return value.value
21
+ const next = normalizePin(raw, props.length)
22
+ if (next !== value.value) {
23
+ emit('update:modelValue', next)
24
+ if (next.length === props.length) emit('complete', next)
25
+ }
26
+ position.value = Math.min(next.length, props.length - 1)
27
+ return next
28
+ }
29
+ watch(() => props.length, pinLength, { immediate: true })
30
+ return { value, feedback, focused, position, change }
31
+ }
@@ -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
+ }