@getcortexlabs/mavis-core 0.1.0-rc.14 → 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 +454 -1777
- package/dist/capabilities.d.ts.map +1 -1
- package/dist/capabilities.js +143 -82
- package/dist/capabilities.js.map +1 -1
- package/dist/contracts.d.ts +4 -4
- package/dist/experimental-regions.d.ts +5 -2
- package/dist/experimental-regions.d.ts.map +1 -1
- package/dist/experimental-regions.js +3 -0
- package/dist/experimental-regions.js.map +1 -1
- 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 +92 -22
- 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 +44 -44
- 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 +29 -6
- package/dist/vue/scroll-frame.d.ts.map +1 -1
- package/dist/vue/scroll-frame.js +106 -43
- 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 +148 -82
- package/src/experimental-regions.ts +10 -2
- 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 +140 -54
- 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/scroll-frame.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
computed,
|
|
2
3
|
defineComponent,
|
|
3
4
|
h,
|
|
4
5
|
markRaw,
|
|
@@ -38,6 +39,7 @@ export const scrollFrameHostProps = {
|
|
|
38
39
|
type UI = {
|
|
39
40
|
Frame: Component
|
|
40
41
|
Box: Component
|
|
42
|
+
Clip?: Component
|
|
41
43
|
Row: Component
|
|
42
44
|
Column: Component
|
|
43
45
|
Text: Component
|
|
@@ -68,6 +70,22 @@ export function createScrollComponents(ui: UI, platform: 'web' | 'native') {
|
|
|
68
70
|
const region = markRaw(createMotionRegion()),
|
|
69
71
|
source = markRaw(createMotionScrollSource())
|
|
70
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
|
+
})
|
|
71
89
|
const header = make(),
|
|
72
90
|
artwork = make(),
|
|
73
91
|
title = make(),
|
|
@@ -147,7 +165,7 @@ export function createScrollComponents(ui: UI, platform: 'web' | 'native') {
|
|
|
147
165
|
expanded: expanded(),
|
|
148
166
|
minimum: minimum(),
|
|
149
167
|
parallax: props.refreshMode ? 0 : (expanded() - minimum()) * props.parallax,
|
|
150
|
-
items: () =>
|
|
168
|
+
items: () => rows.value.filter((row) => row.target.available),
|
|
151
169
|
onRefresh: props.refresh ? refresh : undefined,
|
|
152
170
|
onRefreshError: () => {},
|
|
153
171
|
refreshThreshold: props.threshold,
|
|
@@ -174,10 +192,31 @@ export function createScrollComponents(ui: UI, platform: 'web' | 'native') {
|
|
|
174
192
|
props.parallax,
|
|
175
193
|
props.refresh,
|
|
176
194
|
props.threshold,
|
|
195
|
+
props.sourceKey,
|
|
177
196
|
],
|
|
178
197
|
bind,
|
|
179
198
|
{ immediate: true, flush: 'post' },
|
|
180
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
|
+
}
|
|
181
220
|
watch(
|
|
182
221
|
() => props.disabled,
|
|
183
222
|
(disabled) => {
|
|
@@ -192,6 +231,7 @@ export function createScrollComponents(ui: UI, platform: 'web' | 'native') {
|
|
|
192
231
|
cancel()
|
|
193
232
|
})
|
|
194
233
|
expose({
|
|
234
|
+
preserveAnchor,
|
|
195
235
|
refresh: () => control?.refresh() ?? Promise.resolve(false),
|
|
196
236
|
cancel,
|
|
197
237
|
scrollToTop: (animated = true) => control?.scrollToTop(animated),
|
|
@@ -244,7 +284,13 @@ export function createScrollComponents(ui: UI, platform: 'web' | 'native') {
|
|
|
244
284
|
: null
|
|
245
285
|
return h(
|
|
246
286
|
ui.Frame,
|
|
247
|
-
mergeProps(attrs, {
|
|
287
|
+
mergeProps(attrs, {
|
|
288
|
+
id: props.id,
|
|
289
|
+
region,
|
|
290
|
+
source,
|
|
291
|
+
height: props.height,
|
|
292
|
+
label,
|
|
293
|
+
}),
|
|
248
294
|
{
|
|
249
295
|
default: () => [
|
|
250
296
|
!ready.value
|
|
@@ -254,60 +300,87 @@ export function createScrollComponents(ui: UI, platform: 'web' | 'native') {
|
|
|
254
300
|
})
|
|
255
301
|
: null,
|
|
256
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
|
+
),
|
|
257
310
|
],
|
|
258
311
|
overlay: () => [
|
|
259
312
|
h(
|
|
260
313
|
ui.Box,
|
|
261
|
-
{ motionSurface: header, height: expanded(), style: overlay },
|
|
262
314
|
{
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
315
|
+
motionSurface: header,
|
|
316
|
+
height: expanded(),
|
|
317
|
+
style: platform === 'web' ? { ...overlay, overflow: 'hidden' } : overlay,
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
default: () => {
|
|
321
|
+
const layers = [
|
|
322
|
+
h(
|
|
323
|
+
ui.Box,
|
|
324
|
+
{
|
|
325
|
+
motionSurface: artwork,
|
|
326
|
+
height: expanded(),
|
|
327
|
+
backgroundColor: theme.value.colors.surface,
|
|
328
|
+
},
|
|
329
|
+
{
|
|
330
|
+
default: () =>
|
|
331
|
+
props.image
|
|
332
|
+
? h(ui.Image, {
|
|
333
|
+
src: props.image,
|
|
334
|
+
alt: '',
|
|
335
|
+
decorative: true,
|
|
336
|
+
height: expanded(),
|
|
337
|
+
fit: 'cover',
|
|
338
|
+
})
|
|
339
|
+
: slots.artwork?.(),
|
|
340
|
+
},
|
|
341
|
+
),
|
|
342
|
+
h(
|
|
343
|
+
ui.Column,
|
|
344
|
+
{
|
|
345
|
+
padding: 'lg',
|
|
346
|
+
justify: 'end',
|
|
347
|
+
gap: 'xs',
|
|
348
|
+
// Artwork has a transform and therefore its own stacking context.
|
|
349
|
+
// Keep the whole text group above it, including the static subtitle.
|
|
350
|
+
...(platform === 'web'
|
|
351
|
+
? { style: { position: 'relative', zIndex: 1 } }
|
|
352
|
+
: {}),
|
|
353
|
+
...(props.image ? { backgroundColor: '#00000080' } : {}),
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
default: () => [
|
|
357
|
+
h(ui.Text, {
|
|
358
|
+
motionSurface: title,
|
|
359
|
+
text: label,
|
|
360
|
+
variant: props.refreshMode ? 'heading' : 'title',
|
|
361
|
+
...(props.image ? { style: { color: '#ffffff' } } : {}),
|
|
362
|
+
}),
|
|
363
|
+
props.subtitle
|
|
364
|
+
? h(ui.Text, {
|
|
365
|
+
text: props.subtitle,
|
|
366
|
+
tone: props.image ? undefined : 'muted',
|
|
367
|
+
...(props.image ? { style: { color: '#ffffff' } } : {}),
|
|
368
|
+
})
|
|
369
|
+
: null,
|
|
370
|
+
],
|
|
371
|
+
},
|
|
372
|
+
),
|
|
373
|
+
]
|
|
374
|
+
// Jolt owns the moving header and clears its iOS clipping. Keep
|
|
375
|
+
// the component's artwork bounds on a separate retained layer.
|
|
376
|
+
return platform === 'native'
|
|
377
|
+
? h(
|
|
378
|
+
ui.Clip ?? ui.Box,
|
|
379
|
+
{ height: expanded(), clipToBounds: true },
|
|
380
|
+
{ default: () => layers },
|
|
381
|
+
)
|
|
382
|
+
: layers
|
|
383
|
+
},
|
|
311
384
|
},
|
|
312
385
|
),
|
|
313
386
|
h(
|
|
@@ -395,8 +468,15 @@ export function createScrollComponents(ui: UI, platform: 'web' | 'native') {
|
|
|
395
468
|
props: collapsibleHeaderProps,
|
|
396
469
|
emits: ['back'],
|
|
397
470
|
setup(props, { attrs, slots, emit, expose }) {
|
|
398
|
-
const inner = ref<{
|
|
399
|
-
|
|
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
|
+
})
|
|
400
480
|
return () =>
|
|
401
481
|
h(ScrollFrame, mergeProps(attrs, props, { ref: inner, onBack: () => emit('back') }), slots)
|
|
402
482
|
},
|
|
@@ -407,8 +487,14 @@ export function createScrollComponents(ui: UI, platform: 'web' | 'native') {
|
|
|
407
487
|
props: refreshControlProps,
|
|
408
488
|
emits: ['stateChange', 'error'],
|
|
409
489
|
setup(props, { attrs, slots, emit, expose }) {
|
|
410
|
-
const inner = ref<{
|
|
490
|
+
const inner = ref<{
|
|
491
|
+
refresh(): Promise<boolean>
|
|
492
|
+
cancel(): void
|
|
493
|
+
preserveAnchor(change: () => void | Promise<void>): Promise<void>
|
|
494
|
+
}>()
|
|
411
495
|
expose({
|
|
496
|
+
preserveAnchor: (change: () => void | Promise<void>) =>
|
|
497
|
+
inner.value ? inner.value.preserveAnchor(change) : Promise.resolve().then(change),
|
|
412
498
|
refresh: () => inner.value?.refresh() ?? Promise.resolve(false),
|
|
413
499
|
cancel: () => inner.value?.cancel(),
|
|
414
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?.()
|