@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,72 @@
1
+ import {
2
+ defineComponent,
3
+ h,
4
+ markRaw,
5
+ mergeProps,
6
+ onScopeDispose,
7
+ watch,
8
+ type Component,
9
+ } from '@vue/runtime-core'
10
+ import { createMotionSurface, type MotionPlayback } from '../experimental.js'
11
+ import { animatedTextProps } from './screen-component-props.js'
12
+
13
+ export function createAnimatedText(Text: Component) {
14
+ return defineComponent({
15
+ name: 'MAnimatedText',
16
+ inheritAttrs: false,
17
+ props: animatedTextProps,
18
+ setup(props, { attrs, expose }) {
19
+ const surface = markRaw(createMotionSurface())
20
+ let playback: MotionPlayback | undefined
21
+ const validate = () => {
22
+ if (
23
+ !Number.isFinite(props.duration) ||
24
+ props.duration <= 0 ||
25
+ !Number.isFinite(props.stagger) ||
26
+ props.stagger < 0 ||
27
+ !Number.isFinite(props.distance) ||
28
+ !['word', 'letter'].includes(props.by)
29
+ )
30
+ throw new RangeError(
31
+ 'MAnimatedText requires a positive duration, nonnegative stagger and finite distance.',
32
+ )
33
+ }
34
+ function play() {
35
+ validate()
36
+ playback?.stop()
37
+ if (surface.available && props.animated && props.text)
38
+ playback = surface.animateText({
39
+ by: props.by,
40
+ duration: props.duration,
41
+ stagger: props.stagger,
42
+ y: props.distance,
43
+ })
44
+ }
45
+ onScopeDispose(
46
+ surface.use(() => {
47
+ if (props.appear) play()
48
+ return () => {
49
+ playback?.stop()
50
+ playback = undefined
51
+ }
52
+ }),
53
+ )
54
+ watch(() => [props.text, props.replayKey, props.by, props.animated], play, { flush: 'post' })
55
+ onScopeDispose(() => playback?.stop())
56
+ expose({ replay: play })
57
+ return () => {
58
+ validate()
59
+ return h(
60
+ Text,
61
+ mergeProps(attrs, {
62
+ id: props.id,
63
+ text: props.text,
64
+ variant: props.variant,
65
+ tone: props.tone,
66
+ motionSurface: surface,
67
+ }),
68
+ )
69
+ }
70
+ },
71
+ })
72
+ }
@@ -1,3 +1,28 @@
1
+ import {
2
+ kanbanProps,
3
+ donutChartProps,
4
+ sparklineProps,
5
+ gradientBackgroundProps,
6
+ particleFieldProps,
7
+ confettiProps,
8
+ } from './dashboard-props.js'
9
+ import {
10
+ colorPickerProps,
11
+ swipeDeckProps,
12
+ gaugeProps,
13
+ tourProps,
14
+ tourTargetProps,
15
+ transferListProps,
16
+ marqueeProps,
17
+ } from './creative-props.js'
18
+ import {
19
+ collapsibleHeaderProps,
20
+ refreshControlProps,
21
+ composerProps,
22
+ speedDialProps,
23
+ pinInputProps,
24
+ animatedTextProps,
25
+ } from './screen-component-props.js'
1
26
  import {
2
27
  sortableListProps,
3
28
  swipeActionsProps,
@@ -42,6 +67,28 @@ import { formGroupProps, formErrorsProps, stepsProps, paginationProps } from './
42
67
  /** Complete registry, kept separate from the primitives used to compose controls. */
43
68
  export const componentProps = {
44
69
  ...foundationProps,
70
+ MKanban: kanbanProps,
71
+ MDonutChart: donutChartProps,
72
+ MSparkline: sparklineProps,
73
+ MGradientBackground: gradientBackgroundProps,
74
+ MParticleField: particleFieldProps,
75
+ MConfetti: confettiProps,
76
+
77
+ MColorPicker: colorPickerProps,
78
+ MSwipeDeck: swipeDeckProps,
79
+ MGauge: gaugeProps,
80
+ MTour: tourProps,
81
+ MTourTarget: tourTargetProps,
82
+ MTransferList: transferListProps,
83
+ MMarquee: marqueeProps,
84
+
85
+ MCollapsibleHeader: collapsibleHeaderProps,
86
+ MRefreshControl: refreshControlProps,
87
+ MComposer: composerProps,
88
+ MSpeedDial: speedDialProps,
89
+ MPinInput: pinInputProps,
90
+ MAnimatedText: animatedTextProps,
91
+
45
92
  MSortableList: sortableListProps,
46
93
  MSwipeActions: swipeActionsProps,
47
94
  MNumberFlow: numberFlowProps,
@@ -0,0 +1,192 @@
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 MotionBinding } from '../experimental.js'
13
+ import type { ComposerMessage } from '../screen-components.js'
14
+ import { composerProps } from './screen-component-props.js'
15
+ import { useComponentLayout } from './component-motion.js'
16
+
17
+ export function createComposer(
18
+ ui: {
19
+ Box: Component
20
+ Card: Component
21
+ Row: Component
22
+ Column: Component
23
+ Input: Component
24
+ Button: Component
25
+ Chip: Component
26
+ Text: Component
27
+ },
28
+ platform: 'web' | 'native',
29
+ ) {
30
+ return defineComponent({
31
+ name: 'MComposer',
32
+ inheritAttrs: false,
33
+ props: composerProps,
34
+ emits: {
35
+ 'update:modelValue': (_v: string) => true,
36
+ 'update:attachments': (_v: unknown[]) => true,
37
+ submit: (_message: ComposerMessage) => true,
38
+ attach: () => true,
39
+ focus: () => true,
40
+ blur: () => true,
41
+ },
42
+ setup(props, { attrs, emit, expose, slots }) {
43
+ const editor = ref<{ focus(): void; blur(): void }>()
44
+ const surface = markRaw(createMotionSurface())
45
+ const layout = useComponentLayout(() => props.attachments.map((a) => a.id))
46
+ const blocked = computed(() => props.disabled || props.readonly || props.loading)
47
+ const canSend = computed(
48
+ () => !blocked.value && Boolean(props.modelValue.trim() || props.attachments.length),
49
+ )
50
+ let follow: MotionBinding | undefined
51
+ function followKeyboard() {
52
+ follow?.dispose()
53
+ follow = undefined
54
+ if (props.followKeyboard && surface.available)
55
+ follow = surface.followKeyboard({ offset: props.keyboardOffset })
56
+ }
57
+ onScopeDispose(
58
+ surface.use(() => {
59
+ followKeyboard()
60
+ return () => {
61
+ follow?.dispose()
62
+ follow = undefined
63
+ }
64
+ }),
65
+ )
66
+ watch(() => [props.followKeyboard, props.keyboardOffset], followKeyboard, { flush: 'post' })
67
+ const submit = () => {
68
+ if (canSend.value)
69
+ emit('submit', {
70
+ text: props.modelValue,
71
+ attachments: props.attachments.map((a) => ({ ...a })),
72
+ })
73
+ }
74
+ expose({ focus: () => editor.value?.focus(), blur: () => editor.value?.blur() })
75
+ return () => {
76
+ const ids = new Set(props.attachments.map((a) => a.id))
77
+ if (ids.size !== props.attachments.length)
78
+ throw new TypeError('Composer attachments require unique ids.')
79
+ return h(
80
+ ui.Box,
81
+ mergeProps(attrs, {
82
+ motionSurface: surface,
83
+ ...(platform === 'web'
84
+ ? {
85
+ class: 'm-composer',
86
+ role: 'group',
87
+ 'aria-label': props.label,
88
+ onKeydown: (e: KeyboardEvent) => {
89
+ if (
90
+ props.shortcut &&
91
+ e.key === 'Enter' &&
92
+ (e.ctrlKey || e.metaKey) &&
93
+ !e.isComposing &&
94
+ e.keyCode !== 229 &&
95
+ !e.defaultPrevented
96
+ ) {
97
+ e.preventDefault()
98
+ submit()
99
+ }
100
+ },
101
+ }
102
+ : {}),
103
+ }),
104
+ {
105
+ default: () =>
106
+ h(
107
+ ui.Card,
108
+ { padding: 'md', gap: 'sm', motionRegion: layout },
109
+ {
110
+ default: () => [
111
+ h(ui.Input, {
112
+ ref: editor,
113
+ id: props.id,
114
+ label: props.label,
115
+ modelValue: props.modelValue,
116
+ multiline: true,
117
+ rows: props.rows,
118
+ maxLength: props.maxLength,
119
+ placeholder: props.placeholder,
120
+ error: props.error,
121
+ disabled: props.disabled,
122
+ readonly: props.readonly || props.loading,
123
+ 'onUpdate:modelValue': (value: string) => {
124
+ if (!blocked.value) emit('update:modelValue', value)
125
+ },
126
+ onFocus: () => emit('focus'),
127
+ onBlur: () => emit('blur'),
128
+ }),
129
+ props.attachments.length
130
+ ? h(
131
+ ui.Row,
132
+ { gap: 'xs', wrap: true },
133
+ {
134
+ default: () =>
135
+ props.attachments.map((a) =>
136
+ h(ui.Chip, {
137
+ key: a.id,
138
+ label: a.name,
139
+ removable: true,
140
+ removeLabel: `${props.removeLabel}: ${a.name}`,
141
+ disabled: blocked.value,
142
+ onRemove: () => {
143
+ if (!blocked.value)
144
+ emit(
145
+ 'update:attachments',
146
+ props.attachments.filter((item) => item.id !== a.id),
147
+ )
148
+ },
149
+ }),
150
+ ),
151
+ },
152
+ )
153
+ : null,
154
+ slots.default?.(),
155
+ h(
156
+ ui.Row,
157
+ { gap: 'sm', align: 'center', justify: 'between', wrap: true },
158
+ {
159
+ default: () => [
160
+ props.attachable
161
+ ? h(ui.Button, {
162
+ text: props.attachLabel,
163
+ icon: 'paperclip',
164
+ variant: 'ghost',
165
+ size: 'sm',
166
+ disabled: blocked.value,
167
+ onClick: () => {
168
+ if (!blocked.value) emit('attach')
169
+ },
170
+ })
171
+ : null,
172
+ h(ui.Button, {
173
+ text: props.sendLabel,
174
+ icon: 'arrow-up',
175
+ size: 'sm',
176
+ disabled: !canSend.value && !props.loading,
177
+ loading: props.loading,
178
+ loadingText: props.sendingLabel,
179
+ onClick: submit,
180
+ }),
181
+ ],
182
+ },
183
+ ),
184
+ ],
185
+ },
186
+ ),
187
+ },
188
+ )
189
+ }
190
+ },
191
+ })
192
+ }