@getcortexlabs/mavis-core 0.1.0-rc.15 → 0.1.0-rc.16
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/avatar.d.ts +5 -0
- package/dist/avatar.d.ts.map +1 -1
- package/dist/capabilities.d.ts +17 -1827
- package/dist/capabilities.d.ts.map +1 -1
- package/dist/capabilities.js +9 -90
- package/dist/capabilities.js.map +1 -1
- package/dist/contracts.d.ts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/vue/advanced-collections.d.ts +16 -16
- package/dist/vue/animated-text.d.ts +4 -4
- package/dist/vue/chart.d.ts +5 -5
- package/dist/vue/command-palette.d.ts +4 -4
- package/dist/vue/component-props.d.ts +90 -20
- package/dist/vue/component-props.d.ts.map +1 -1
- package/dist/vue/component-props.js +4 -0
- package/dist/vue/component-props.js.map +1 -1
- package/dist/vue/composer.d.ts +11 -9
- package/dist/vue/composer.d.ts.map +1 -1
- package/dist/vue/composer.js +12 -16
- package/dist/vue/composer.js.map +1 -1
- package/dist/vue/configurator.d.ts +16 -16
- package/dist/vue/creative-controls.d.ts +11 -11
- package/dist/vue/dashboard-charts.d.ts +6 -6
- package/dist/vue/dashboard-effects.d.ts +7 -7
- package/dist/vue/date-picker.d.ts +52 -52
- package/dist/vue/discovery-controls.d.ts +8 -8
- package/dist/vue/editor-controls.d.ts +223 -0
- package/dist/vue/editor-controls.d.ts.map +1 -0
- package/dist/vue/editor-controls.js +323 -0
- package/dist/vue/editor-controls.js.map +1 -0
- package/dist/vue/global-components.d.ts +22 -1
- package/dist/vue/global-components.d.ts.map +1 -1
- package/dist/vue/image-cropper.d.ts +8 -8
- package/dist/vue/image-cropper.d.ts.map +1 -1
- package/dist/vue/index.d.ts +3 -2
- package/dist/vue/index.d.ts.map +1 -1
- package/dist/vue/index.js +1 -0
- package/dist/vue/index.js.map +1 -1
- package/dist/vue/kanban.d.ts +2 -2
- package/dist/vue/marquee.d.ts +4 -4
- package/dist/vue/menu.d.ts +4 -4
- package/dist/vue/number-flow.d.ts +3 -3
- package/dist/vue/platform.d.ts +1 -2
- package/dist/vue/platform.d.ts.map +1 -1
- package/dist/vue/platform.js.map +1 -1
- package/dist/vue/props.d.ts +40 -40
- package/dist/vue/reveal-state.d.ts +1 -1
- package/dist/vue/scheduler.d.ts +10 -10
- package/dist/vue/screen-component-props.d.ts +10 -0
- package/dist/vue/screen-component-props.d.ts.map +1 -1
- package/dist/vue/screen-component-props.js +6 -0
- package/dist/vue/screen-component-props.js.map +1 -1
- package/dist/vue/scroll-frame.d.ts +28 -6
- package/dist/vue/scroll-frame.d.ts.map +1 -1
- package/dist/vue/scroll-frame.js +51 -4
- package/dist/vue/scroll-frame.js.map +1 -1
- package/dist/vue/speed-dial.d.ts +3 -3
- package/dist/vue/swipe-actions.d.ts +3 -3
- package/dist/vue/swipe-deck.d.ts +3 -3
- package/dist/vue/theme-provider.d.ts +17 -2
- package/dist/vue/theme-provider.d.ts.map +1 -1
- package/dist/vue/theme-provider.js +7 -1
- package/dist/vue/theme-provider.js.map +1 -1
- package/dist/vue/theme.d.ts +7 -0
- package/dist/vue/theme.d.ts.map +1 -1
- package/dist/vue/theme.js +23 -19
- package/dist/vue/theme.js.map +1 -1
- package/dist/vue/time-picker.d.ts +20 -20
- package/dist/vue/tour.d.ts +3 -3
- package/dist/vue/tree-view.d.ts +3 -3
- package/dist/vue/wayfinding-controls.d.ts +1 -1
- package/dist/vue/workflows.d.ts +3 -3
- package/package.json +1 -1
- package/src/avatar.ts +6 -0
- package/src/capabilities.ts +9 -90
- package/src/index.ts +2 -7
- package/src/vue/component-props.ts +4 -0
- package/src/vue/composer.ts +22 -16
- package/src/vue/editor-controls.ts +370 -0
- package/src/vue/global-components.ts +21 -1
- package/src/vue/index.ts +3 -1
- package/src/vue/platform.ts +1 -2
- package/src/vue/screen-component-props.ts +6 -0
- package/src/vue/scroll-frame.ts +70 -5
- package/src/vue/theme-provider.ts +14 -1
- package/src/vue/theme.ts +31 -18
- package/dist/macos-capabilities.generated.d.ts +0 -1738
- package/dist/macos-capabilities.generated.d.ts.map +0 -1
- package/dist/macos-capabilities.generated.js +0 -4191
- package/dist/macos-capabilities.generated.js.map +0 -1
- package/src/macos-capabilities.generated.ts +0 -4190
package/src/vue/index.ts
CHANGED
|
@@ -21,11 +21,12 @@ export type {
|
|
|
21
21
|
AppearanceMode,
|
|
22
22
|
AppearanceSource,
|
|
23
23
|
ThemeContextOptions,
|
|
24
|
+
ThemePair,
|
|
24
25
|
} from './theme.js'
|
|
25
26
|
export { layoutDirection, useDefaultShrink, useLayoutShrink } from './layout-context.js'
|
|
26
27
|
export { textContent } from './text-content.js'
|
|
27
28
|
export type {} from './global-components.js'
|
|
28
|
-
export type { InputPlatformAttributes } from './global-components.js'
|
|
29
|
+
export type { CardPlatformAttributes, InputPlatformAttributes } from './global-components.js'
|
|
29
30
|
export {
|
|
30
31
|
boxProps,
|
|
31
32
|
motionBoxProps,
|
|
@@ -135,6 +136,7 @@ export * from './screen-component-props.js'
|
|
|
135
136
|
export * from './scroll-frame.js'
|
|
136
137
|
export * from './animated-text.js'
|
|
137
138
|
export * from './composer.js'
|
|
139
|
+
export * from './editor-controls.js'
|
|
138
140
|
export * from './speed-dial.js'
|
|
139
141
|
export * from './pin-input.js'
|
|
140
142
|
|
package/src/vue/platform.ts
CHANGED
|
@@ -7,8 +7,7 @@ import {
|
|
|
7
7
|
} from '@vue/runtime-core'
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
11
|
-
* Web and NativeScript renderers never report it: the Mac generator answers for it instead.
|
|
10
|
+
* The web and mobile renderers supply their own platform explicitly.
|
|
12
11
|
*/
|
|
13
12
|
export type MavisPlatform = 'web' | 'ios' | 'android' | 'macos'
|
|
14
13
|
export type MavisPlatformTarget = MavisPlatform | 'native'
|
|
@@ -62,7 +62,12 @@ export const speedDialProps = {
|
|
|
62
62
|
closeLabel: { type: String, default: 'Close actions' },
|
|
63
63
|
direction: { type: String as PropType<'up' | 'down'>, default: 'up' },
|
|
64
64
|
}
|
|
65
|
+
const scrollRows = {
|
|
66
|
+
itemKeys: { type: Array as PropType<readonly string[]>, default: () => [] },
|
|
67
|
+
sourceKey: [String, Number],
|
|
68
|
+
}
|
|
65
69
|
export const refreshControlProps = {
|
|
70
|
+
...scrollRows,
|
|
66
71
|
id: String,
|
|
67
72
|
label,
|
|
68
73
|
refresh: { type: Function as PropType<RefreshAction>, required: true as const },
|
|
@@ -77,6 +82,7 @@ export const refreshControlProps = {
|
|
|
77
82
|
cancelLabel: { type: String, default: 'Cancel refresh' },
|
|
78
83
|
}
|
|
79
84
|
export const collapsibleHeaderProps = {
|
|
85
|
+
...scrollRows,
|
|
80
86
|
id: String,
|
|
81
87
|
title: label,
|
|
82
88
|
subtitle: String,
|
package/src/vue/scroll-frame.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
computed,
|
|
2
3
|
defineComponent,
|
|
3
4
|
h,
|
|
4
5
|
markRaw,
|
|
@@ -69,6 +70,22 @@ export function createScrollComponents(ui: UI, platform: 'web' | 'native') {
|
|
|
69
70
|
const region = markRaw(createMotionRegion()),
|
|
70
71
|
source = markRaw(createMotionScrollSource())
|
|
71
72
|
const make = () => markRaw(createMotionSurface())
|
|
73
|
+
const targets = new Map<string, ReturnType<typeof make>>()
|
|
74
|
+
const rows = computed(() => {
|
|
75
|
+
const keys = new Set(props.itemKeys)
|
|
76
|
+
if (
|
|
77
|
+
keys.size !== props.itemKeys.length ||
|
|
78
|
+
keys.size > 1000 ||
|
|
79
|
+
props.itemKeys.some((key) => typeof key !== 'string' || !key)
|
|
80
|
+
)
|
|
81
|
+
throw new TypeError('Scroll rows require up to 1000 unique nonempty string keys.')
|
|
82
|
+
for (const key of targets.keys()) if (!keys.has(key)) targets.delete(key)
|
|
83
|
+
return props.itemKeys.map((key) => {
|
|
84
|
+
const target = targets.get(key) ?? make()
|
|
85
|
+
targets.set(key, target)
|
|
86
|
+
return { key, target }
|
|
87
|
+
})
|
|
88
|
+
})
|
|
72
89
|
const header = make(),
|
|
73
90
|
artwork = make(),
|
|
74
91
|
title = make(),
|
|
@@ -148,7 +165,7 @@ export function createScrollComponents(ui: UI, platform: 'web' | 'native') {
|
|
|
148
165
|
expanded: expanded(),
|
|
149
166
|
minimum: minimum(),
|
|
150
167
|
parallax: props.refreshMode ? 0 : (expanded() - minimum()) * props.parallax,
|
|
151
|
-
items: () =>
|
|
168
|
+
items: () => rows.value.filter((row) => row.target.available),
|
|
152
169
|
onRefresh: props.refresh ? refresh : undefined,
|
|
153
170
|
onRefreshError: () => {},
|
|
154
171
|
refreshThreshold: props.threshold,
|
|
@@ -175,10 +192,31 @@ export function createScrollComponents(ui: UI, platform: 'web' | 'native') {
|
|
|
175
192
|
props.parallax,
|
|
176
193
|
props.refresh,
|
|
177
194
|
props.threshold,
|
|
195
|
+
props.sourceKey,
|
|
178
196
|
],
|
|
179
197
|
bind,
|
|
180
198
|
{ immediate: true, flush: 'post' },
|
|
181
199
|
)
|
|
200
|
+
watch(
|
|
201
|
+
() => props.sourceKey,
|
|
202
|
+
() => {
|
|
203
|
+
// End the previous feed's anchor transaction while its native views
|
|
204
|
+
// are still attached. The post-render watcher binds the next feed.
|
|
205
|
+
control?.scrollToTop(false)
|
|
206
|
+
release?.()
|
|
207
|
+
release = undefined
|
|
208
|
+
setState('idle')
|
|
209
|
+
},
|
|
210
|
+
{ flush: 'sync' },
|
|
211
|
+
)
|
|
212
|
+
const preserveAnchor = async (change: () => void | Promise<void>) => {
|
|
213
|
+
const update = async () => {
|
|
214
|
+
await change()
|
|
215
|
+
await nextTick()
|
|
216
|
+
}
|
|
217
|
+
if (control?.ready && rows.value.length) await control.preserveAnchor(update)
|
|
218
|
+
else await update()
|
|
219
|
+
}
|
|
182
220
|
watch(
|
|
183
221
|
() => props.disabled,
|
|
184
222
|
(disabled) => {
|
|
@@ -193,6 +231,7 @@ export function createScrollComponents(ui: UI, platform: 'web' | 'native') {
|
|
|
193
231
|
cancel()
|
|
194
232
|
})
|
|
195
233
|
expose({
|
|
234
|
+
preserveAnchor,
|
|
196
235
|
refresh: () => control?.refresh() ?? Promise.resolve(false),
|
|
197
236
|
cancel,
|
|
198
237
|
scrollToTop: (animated = true) => control?.scrollToTop(animated),
|
|
@@ -245,7 +284,13 @@ export function createScrollComponents(ui: UI, platform: 'web' | 'native') {
|
|
|
245
284
|
: null
|
|
246
285
|
return h(
|
|
247
286
|
ui.Frame,
|
|
248
|
-
mergeProps(attrs, {
|
|
287
|
+
mergeProps(attrs, {
|
|
288
|
+
id: props.id,
|
|
289
|
+
region,
|
|
290
|
+
source,
|
|
291
|
+
height: props.height,
|
|
292
|
+
label,
|
|
293
|
+
}),
|
|
249
294
|
{
|
|
250
295
|
default: () => [
|
|
251
296
|
!ready.value
|
|
@@ -255,6 +300,13 @@ export function createScrollComponents(ui: UI, platform: 'web' | 'native') {
|
|
|
255
300
|
})
|
|
256
301
|
: null,
|
|
257
302
|
slots.default?.({ state: state.value, refresh: () => control?.refresh(), cancel }),
|
|
303
|
+
...rows.value.map(({ key, target }, index) =>
|
|
304
|
+
h(
|
|
305
|
+
ui.Box,
|
|
306
|
+
{ key, motionSurface: target },
|
|
307
|
+
{ default: () => slots.item?.({ itemKey: key, index }) },
|
|
308
|
+
),
|
|
309
|
+
),
|
|
258
310
|
],
|
|
259
311
|
overlay: () => [
|
|
260
312
|
h(
|
|
@@ -416,8 +468,15 @@ export function createScrollComponents(ui: UI, platform: 'web' | 'native') {
|
|
|
416
468
|
props: collapsibleHeaderProps,
|
|
417
469
|
emits: ['back'],
|
|
418
470
|
setup(props, { attrs, slots, emit, expose }) {
|
|
419
|
-
const inner = ref<{
|
|
420
|
-
|
|
471
|
+
const inner = ref<{
|
|
472
|
+
scrollToTop(animated?: boolean): void
|
|
473
|
+
preserveAnchor(change: () => void | Promise<void>): Promise<void>
|
|
474
|
+
}>()
|
|
475
|
+
expose({
|
|
476
|
+
preserveAnchor: (change: () => void | Promise<void>) =>
|
|
477
|
+
inner.value ? inner.value.preserveAnchor(change) : Promise.resolve().then(change),
|
|
478
|
+
scrollToTop: (animated = true) => inner.value?.scrollToTop(animated),
|
|
479
|
+
})
|
|
421
480
|
return () =>
|
|
422
481
|
h(ScrollFrame, mergeProps(attrs, props, { ref: inner, onBack: () => emit('back') }), slots)
|
|
423
482
|
},
|
|
@@ -428,8 +487,14 @@ export function createScrollComponents(ui: UI, platform: 'web' | 'native') {
|
|
|
428
487
|
props: refreshControlProps,
|
|
429
488
|
emits: ['stateChange', 'error'],
|
|
430
489
|
setup(props, { attrs, slots, emit, expose }) {
|
|
431
|
-
const inner = ref<{
|
|
490
|
+
const inner = ref<{
|
|
491
|
+
refresh(): Promise<boolean>
|
|
492
|
+
cancel(): void
|
|
493
|
+
preserveAnchor(change: () => void | Promise<void>): Promise<void>
|
|
494
|
+
}>()
|
|
432
495
|
expose({
|
|
496
|
+
preserveAnchor: (change: () => void | Promise<void>) =>
|
|
497
|
+
inner.value ? inner.value.preserveAnchor(change) : Promise.resolve().then(change),
|
|
433
498
|
refresh: () => inner.value?.refresh() ?? Promise.resolve(false),
|
|
434
499
|
cancel: () => inner.value?.cancel(),
|
|
435
500
|
})
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
import { computed, defineComponent, provide, type PropType } from '@vue/runtime-core'
|
|
2
2
|
import type { MavisTheme } from '../theme/types.js'
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
checkedThemePair,
|
|
5
|
+
type ThemePair,
|
|
6
|
+
themeKey,
|
|
7
|
+
useMavisTheme,
|
|
8
|
+
type AppearanceMode,
|
|
9
|
+
type MavisThemeContext,
|
|
10
|
+
} from './theme.js'
|
|
4
11
|
|
|
5
12
|
export const themeProviderProps = {
|
|
6
13
|
theme: { type: Object as PropType<MavisTheme>, default: undefined },
|
|
14
|
+
themePair: { type: Object as PropType<ThemePair>, default: undefined },
|
|
7
15
|
darkTheme: { type: Object as PropType<MavisTheme>, default: undefined },
|
|
8
16
|
appearance: { type: String as PropType<AppearanceMode>, default: undefined },
|
|
9
17
|
}
|
|
@@ -14,6 +22,7 @@ export const MThemeProvider = defineComponent({
|
|
|
14
22
|
inheritAttrs: false,
|
|
15
23
|
props: themeProviderProps,
|
|
16
24
|
emits: {
|
|
25
|
+
'update:themePair': (_pair: ThemePair) => true,
|
|
17
26
|
'update:theme': (_theme: MavisTheme) => true,
|
|
18
27
|
'update:appearance': (_appearance: AppearanceMode) => true,
|
|
19
28
|
},
|
|
@@ -24,6 +33,7 @@ export const MThemeProvider = defineComponent({
|
|
|
24
33
|
throw new RangeError('darkTheme must have dark appearance')
|
|
25
34
|
return {
|
|
26
35
|
...parent.themes.value,
|
|
36
|
+
...(props.themePair && checkedThemePair(props.themePair)),
|
|
27
37
|
...(props.theme ? { [props.theme.appearance]: props.theme } : {}),
|
|
28
38
|
...(props.darkTheme ? { dark: props.darkTheme } : {}),
|
|
29
39
|
}
|
|
@@ -52,6 +62,9 @@ export const MThemeProvider = defineComponent({
|
|
|
52
62
|
themes,
|
|
53
63
|
appearance,
|
|
54
64
|
systemAppearance: parent.systemAppearance,
|
|
65
|
+
setThemePair(pair) {
|
|
66
|
+
emit('update:themePair', checkedThemePair(pair))
|
|
67
|
+
},
|
|
55
68
|
setTheme(next) {
|
|
56
69
|
emit('update:theme', next)
|
|
57
70
|
emit('update:appearance', next.appearance)
|
package/src/vue/theme.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { inject, readonly, shallowRef, type InjectionKey } from '@vue/runtime-core'
|
|
1
|
+
import { computed, inject, readonly, shallowRef, type InjectionKey } from '@vue/runtime-core'
|
|
2
2
|
import { mavis } from '../theme/themes.js'
|
|
3
3
|
import type { MavisTheme } from '../theme/types.js'
|
|
4
4
|
|
|
@@ -18,6 +18,19 @@ export interface ThemeContextOptions {
|
|
|
18
18
|
source?: AppearanceSource
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
export interface ThemePair {
|
|
22
|
+
light: MavisTheme
|
|
23
|
+
dark: MavisTheme
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function checkedThemePair({ light, dark }: ThemePair): ThemePair {
|
|
27
|
+
if (light?.appearance !== 'light' || dark?.appearance !== 'dark')
|
|
28
|
+
throw new RangeError(
|
|
29
|
+
'A theme pair requires a light theme under light and a dark theme under dark.',
|
|
30
|
+
)
|
|
31
|
+
return { light, dark }
|
|
32
|
+
}
|
|
33
|
+
|
|
21
34
|
const modes: readonly AppearanceMode[] = ['system', 'light', 'dark']
|
|
22
35
|
|
|
23
36
|
function checkMode(mode: AppearanceMode) {
|
|
@@ -28,29 +41,25 @@ function checkMode(mode: AppearanceMode) {
|
|
|
28
41
|
export function createThemeContext(options: MavisTheme | ThemeContextOptions = {}) {
|
|
29
42
|
const config: ThemeContextOptions = 'colors' in options ? { theme: options } : options
|
|
30
43
|
const initial = config.theme ?? mavis
|
|
31
|
-
const
|
|
32
|
-
[initial.appearance]: initial,
|
|
33
|
-
})
|
|
44
|
+
const variants: Partial<ThemePair> = { [initial.appearance]: initial }
|
|
34
45
|
if (config.darkTheme) {
|
|
35
46
|
if (config.darkTheme.appearance !== 'dark')
|
|
36
47
|
throw new RangeError('darkTheme must have dark appearance')
|
|
37
|
-
|
|
48
|
+
variants.dark = config.darkTheme
|
|
38
49
|
}
|
|
39
|
-
const
|
|
40
|
-
const
|
|
50
|
+
const selection = shallowRef({ variants, mode: checkMode(config.appearance ?? 'system') })
|
|
51
|
+
const themes = computed(() => selection.value.variants)
|
|
52
|
+
const appearance = computed(() => selection.value.mode)
|
|
41
53
|
const systemAppearance = shallowRef(config.source?.current())
|
|
42
|
-
const
|
|
54
|
+
const theme = computed(() => {
|
|
43
55
|
const wanted =
|
|
44
56
|
appearance.value === 'system'
|
|
45
57
|
? (systemAppearance.value ?? initial.appearance)
|
|
46
58
|
: appearance.value
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
resolve()
|
|
59
|
+
return themes.value[wanted] ?? themes.value[wanted === 'dark' ? 'light' : 'dark'] ?? initial
|
|
60
|
+
})
|
|
51
61
|
const stop = config.source?.observe((next) => {
|
|
52
62
|
systemAppearance.value = next
|
|
53
|
-
if (appearance.value === 'system') resolve()
|
|
54
63
|
})
|
|
55
64
|
return {
|
|
56
65
|
theme: readonly(theme),
|
|
@@ -59,14 +68,18 @@ export function createThemeContext(options: MavisTheme | ThemeContextOptions = {
|
|
|
59
68
|
/** The selection: `system` follows the device; `light` and `dark` are explicit overrides. */
|
|
60
69
|
appearance: readonly(appearance),
|
|
61
70
|
setAppearance(mode: AppearanceMode) {
|
|
62
|
-
|
|
63
|
-
resolve()
|
|
71
|
+
selection.value = { ...selection.value, mode: checkMode(mode) }
|
|
64
72
|
},
|
|
65
73
|
/** Registers the theme for its own appearance and pins that appearance. */
|
|
66
74
|
setTheme(next: MavisTheme) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
75
|
+
selection.value = {
|
|
76
|
+
variants: { ...themes.value, [next.appearance]: next },
|
|
77
|
+
mode: next.appearance,
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
/** Replaces both palettes in one reactive write, preserving the appearance selection. */
|
|
81
|
+
setThemePair(pair: ThemePair) {
|
|
82
|
+
selection.value = { variants: checkedThemePair(pair), mode: appearance.value }
|
|
70
83
|
},
|
|
71
84
|
dispose() {
|
|
72
85
|
stop?.()
|