@getcortexlabs/mavis-web 0.1.0-alpha.8 → 0.1.0-rc.11.1
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 +7 -5
- package/dist/animated-number.d.ts +3 -0
- package/dist/animated-number.d.ts.map +1 -0
- package/dist/animated-number.js +61 -0
- package/dist/animated-number.js.map +1 -0
- package/dist/component-motion.d.ts +18 -0
- package/dist/component-motion.d.ts.map +1 -0
- package/dist/component-motion.js +156 -0
- package/dist/component-motion.js.map +1 -0
- package/dist/component-width.d.ts +6 -0
- package/dist/component-width.d.ts.map +1 -0
- package/dist/component-width.js +30 -0
- package/dist/component-width.js.map +1 -0
- package/dist/components/ChartPlot.d.ts +66 -0
- package/dist/components/ChartPlot.d.ts.map +1 -0
- package/dist/components/ChartPlot.js +254 -0
- package/dist/components/ChartPlot.js.map +1 -0
- package/dist/components/DateCalendar.d.ts +16 -1
- package/dist/components/DateCalendar.d.ts.map +1 -1
- package/dist/components/DateCalendar.js +58 -12
- package/dist/components/DateCalendar.js.map +1 -1
- package/dist/components/LoadingDecoration.d.ts +5 -5
- package/dist/components/MAccordion.d.ts +2 -2
- package/dist/components/MAlert.d.ts +4 -4
- package/dist/components/MAlert.d.ts.map +1 -1
- package/dist/components/MAlert.js +3 -0
- package/dist/components/MAlert.js.map +1 -1
- package/dist/components/MAvatar.d.ts +1 -1
- package/dist/components/MAvatar.d.ts.map +1 -1
- package/dist/components/MAvatar.js +4 -0
- package/dist/components/MAvatar.js.map +1 -1
- package/dist/components/MBadge.d.ts +1 -1
- package/dist/components/MBadge.d.ts.map +1 -1
- package/dist/components/MBadge.js +5 -1
- package/dist/components/MBadge.js.map +1 -1
- package/dist/components/MButton.d.ts +6 -6
- package/dist/components/MButton.d.ts.map +1 -1
- package/dist/components/MButton.js +14 -8
- package/dist/components/MButton.js.map +1 -1
- package/dist/components/MCard.d.ts +8 -8
- package/dist/components/MCard.d.ts.map +1 -1
- package/dist/components/MCard.js +3 -2
- package/dist/components/MCard.js.map +1 -1
- package/dist/components/MCheckbox.d.ts +2 -2
- package/dist/components/MChip.d.ts +3 -3
- package/dist/components/MChip.d.ts.map +1 -1
- package/dist/components/MChip.js +4 -2
- package/dist/components/MChip.js.map +1 -1
- package/dist/components/MCombobox.d.ts +6 -6
- package/dist/components/MCombobox.d.ts.map +1 -1
- package/dist/components/MCombobox.js +121 -92
- package/dist/components/MCombobox.js.map +1 -1
- package/dist/components/MDatePicker.d.ts +72 -24
- package/dist/components/MDatePicker.d.ts.map +1 -1
- package/dist/components/MDatePicker.js +2 -10
- package/dist/components/MDatePicker.js.map +1 -1
- package/dist/components/MDialog.d.ts +4 -4
- package/dist/components/MDialog.d.ts.map +1 -1
- package/dist/components/MDialog.js +9 -4
- package/dist/components/MDialog.js.map +1 -1
- package/dist/components/MEmptyState.d.ts +3 -3
- package/dist/components/MEmptyState.d.ts.map +1 -1
- package/dist/components/MEmptyState.js +3 -0
- package/dist/components/MEmptyState.js.map +1 -1
- package/dist/components/MFilePicker.d.ts +4 -4
- package/dist/components/MFilePicker.d.ts.map +1 -1
- package/dist/components/MFilePicker.js +3 -1
- package/dist/components/MFilePicker.js.map +1 -1
- package/dist/components/MGrid.d.ts +174 -0
- package/dist/components/MGrid.d.ts.map +1 -0
- package/dist/components/MGrid.js +42 -0
- package/dist/components/MGrid.js.map +1 -0
- package/dist/components/MIcon.d.ts +2 -2
- package/dist/components/MIcon.d.ts.map +1 -1
- package/dist/components/MIcon.js +7 -4
- package/dist/components/MIcon.js.map +1 -1
- package/dist/components/MImage.d.ts +50 -5
- package/dist/components/MImage.d.ts.map +1 -1
- package/dist/components/MImage.js +31 -9
- package/dist/components/MImage.js.map +1 -1
- package/dist/components/MImageCompare.d.ts +92 -0
- package/dist/components/MImageCompare.d.ts.map +1 -0
- package/dist/components/MImageCompare.js +177 -0
- package/dist/components/MImageCompare.js.map +1 -0
- package/dist/components/MImageViewer.d.ts +121 -0
- package/dist/components/MImageViewer.d.ts.map +1 -0
- package/dist/components/MImageViewer.js +490 -0
- package/dist/components/MImageViewer.js.map +1 -0
- package/dist/components/MInput.d.ts +11 -11
- package/dist/components/MInput.d.ts.map +1 -1
- package/dist/components/MInput.js +12 -0
- package/dist/components/MInput.js.map +1 -1
- package/dist/components/MLink.d.ts +1 -1
- package/dist/components/MLink.d.ts.map +1 -1
- package/dist/components/MLink.js +5 -33
- package/dist/components/MLink.js.map +1 -1
- package/dist/components/MListItem.d.ts +3 -3
- package/dist/components/MPopover.d.ts +105 -0
- package/dist/components/MPopover.d.ts.map +1 -0
- package/dist/components/MPopover.js +256 -0
- package/dist/components/MPopover.js.map +1 -0
- package/dist/components/MProgress.d.ts +4 -4
- package/dist/components/MProgress.d.ts.map +1 -1
- package/dist/components/MProgress.js +34 -11
- package/dist/components/MProgress.js.map +1 -1
- package/dist/components/MRadioGroup.d.ts +2 -2
- package/dist/components/MRangeSlider.d.ts +104 -0
- package/dist/components/MRangeSlider.d.ts.map +1 -0
- package/dist/components/MRangeSlider.js +125 -0
- package/dist/components/MRangeSlider.js.map +1 -0
- package/dist/components/MResizablePanels.d.ts +137 -0
- package/dist/components/MResizablePanels.d.ts.map +1 -0
- package/dist/components/MResizablePanels.js +174 -0
- package/dist/components/MResizablePanels.js.map +1 -0
- package/dist/components/MReveal.d.ts +14 -14
- package/dist/components/MSegmentedControl.d.ts +2 -2
- package/dist/components/MSegmentedControl.d.ts.map +1 -1
- package/dist/components/MSegmentedControl.js +6 -2
- package/dist/components/MSegmentedControl.js.map +1 -1
- package/dist/components/MSelect.d.ts +4 -4
- package/dist/components/MSeparator.d.ts +1 -1
- package/dist/components/MSheet.d.ts +16 -7
- package/dist/components/MSheet.d.ts.map +1 -1
- package/dist/components/MSheet.js +45 -14
- package/dist/components/MSheet.js.map +1 -1
- package/dist/components/MSkeleton.d.ts +3 -3
- package/dist/components/MStack.d.ts +25 -14
- package/dist/components/MStack.d.ts.map +1 -1
- package/dist/components/MStack.js +8 -14
- package/dist/components/MStack.js.map +1 -1
- package/dist/components/MSwitch.d.ts +2 -2
- package/dist/components/MTabs.d.ts +2 -2
- package/dist/components/MTabs.d.ts.map +1 -1
- package/dist/components/MTabs.js +6 -3
- package/dist/components/MTabs.js.map +1 -1
- package/dist/components/MText.d.ts +5 -5
- package/dist/components/MTimePicker.d.ts +655 -0
- package/dist/components/MTimePicker.d.ts.map +1 -0
- package/dist/components/MTimePicker.js +81 -0
- package/dist/components/MTimePicker.js.map +1 -0
- package/dist/components/MToast.d.ts.map +1 -1
- package/dist/components/MToast.js +5 -1
- package/dist/components/MToast.js.map +1 -1
- package/dist/components/MTooltip.d.ts +65 -0
- package/dist/components/MTooltip.d.ts.map +1 -0
- package/dist/components/MTooltip.js +256 -0
- package/dist/components/MTooltip.js.map +1 -0
- package/dist/components/MVirtualList.d.ts +3 -0
- package/dist/components/MVirtualList.d.ts.map +1 -0
- package/dist/components/MVirtualList.js +118 -0
- package/dist/components/MVirtualList.js.map +1 -0
- package/dist/components/MotionRows.d.ts +26 -0
- package/dist/components/MotionRows.d.ts.map +1 -0
- package/dist/components/MotionRows.js +16 -0
- package/dist/components/MotionRows.js.map +1 -0
- package/dist/components/RangeHalo.d.ts +19 -0
- package/dist/components/RangeHalo.d.ts.map +1 -0
- package/dist/components/RangeHalo.js +29 -0
- package/dist/components/RangeHalo.js.map +1 -0
- package/dist/components/configurator.d.ts +5 -5
- package/dist/components/discovery.d.ts +282 -0
- package/dist/components/discovery.d.ts.map +1 -0
- package/dist/components/discovery.js +104 -0
- package/dist/components/discovery.js.map +1 -0
- package/dist/components/interactive.d.ts +163 -0
- package/dist/components/interactive.d.ts.map +1 -0
- package/dist/components/interactive.js +40 -0
- package/dist/components/interactive.js.map +1 -0
- package/dist/components/layout.d.ts +81 -48
- package/dist/components/layout.d.ts.map +1 -1
- package/dist/components/layout.js +2 -1
- package/dist/components/layout.js.map +1 -1
- package/dist/components/navigation.d.ts +225 -0
- package/dist/components/navigation.d.ts.map +1 -0
- package/dist/components/navigation.js +41 -0
- package/dist/components/navigation.js.map +1 -0
- package/dist/components/wayfinding.d.ts +441 -0
- package/dist/components/wayfinding.d.ts.map +1 -0
- package/dist/components/wayfinding.js +58 -0
- package/dist/components/wayfinding.js.map +1 -0
- package/dist/components/workflows.d.ts +2 -2
- package/dist/content-width.d.ts +4 -0
- package/dist/content-width.d.ts.map +1 -0
- package/dist/content-width.js +62 -0
- package/dist/content-width.js.map +1 -0
- package/dist/date-format.d.ts +6 -0
- package/dist/date-format.d.ts.map +1 -0
- package/dist/date-format.js +23 -0
- package/dist/date-format.js.map +1 -0
- package/dist/icons.d.ts +14 -0
- package/dist/icons.d.ts.map +1 -0
- package/dist/icons.js +23 -0
- package/dist/icons.js.map +1 -0
- package/dist/image-effects.d.ts.map +1 -1
- package/dist/image-effects.js +2 -0
- package/dist/image-effects.js.map +1 -1
- package/dist/index.d.ts +23 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +49 -10
- package/dist/index.js.map +1 -1
- package/dist/motion-region.d.ts.map +1 -1
- package/dist/motion-region.js +4 -2
- package/dist/motion-region.js.map +1 -1
- package/dist/motion-surface.d.ts.map +1 -1
- package/dist/motion-surface.js +2 -0
- package/dist/motion-surface.js.map +1 -1
- package/dist/motion.js +1 -1
- package/dist/motion.js.map +1 -1
- package/dist/nuxt-navigation.d.ts +18 -0
- package/dist/nuxt-navigation.d.ts.map +1 -0
- package/dist/nuxt-navigation.js +23 -0
- package/dist/nuxt-navigation.js.map +1 -0
- package/dist/partition-pointer.d.ts +19 -0
- package/dist/partition-pointer.d.ts.map +1 -0
- package/dist/partition-pointer.js +78 -0
- package/dist/partition-pointer.js.map +1 -0
- package/dist/router-navigation.d.ts +31 -0
- package/dist/router-navigation.d.ts.map +1 -0
- package/dist/router-navigation.js +215 -0
- package/dist/router-navigation.js.map +1 -0
- package/dist/screen-viewport.d.ts.map +1 -1
- package/dist/screen-viewport.js +6 -4
- package/dist/screen-viewport.js.map +1 -1
- package/dist/section-scroll.d.ts +8 -0
- package/dist/section-scroll.d.ts.map +1 -0
- package/dist/section-scroll.js +79 -0
- package/dist/section-scroll.js.map +1 -0
- package/dist/services.d.ts +16 -0
- package/dist/services.d.ts.map +1 -0
- package/dist/services.js +22 -0
- package/dist/services.js.map +1 -0
- package/package.json +23 -5
- package/src/animated-number.ts +59 -0
- package/src/base.css +1101 -0
- package/src/component-motion.ts +176 -0
- package/src/component-width.ts +34 -0
- package/src/components/ChartPlot.ts +277 -0
- package/src/components/DateCalendar.ts +71 -11
- package/src/components/MAlert.ts +3 -0
- package/src/components/MAvatar.ts +4 -0
- package/src/components/MBadge.ts +10 -1
- package/src/components/MButton.ts +28 -25
- package/src/components/MCard.ts +3 -1
- package/src/components/MChip.ts +4 -2
- package/src/components/MCombobox.ts +136 -101
- package/src/components/MDatePicker.ts +1 -9
- package/src/components/MDialog.ts +9 -4
- package/src/components/MEmptyState.ts +3 -0
- package/src/components/MFilePicker.ts +3 -1
- package/src/components/MGrid.ts +69 -0
- package/src/components/MIcon.ts +7 -8
- package/src/components/MImage.ts +36 -12
- package/src/components/MImageCompare.ts +218 -0
- package/src/components/MImageViewer.ts +560 -0
- package/src/components/MInput.ts +14 -3
- package/src/components/MLink.ts +10 -32
- package/src/components/MPopover.ts +300 -0
- package/src/components/MProgress.ts +36 -11
- package/src/components/MRangeSlider.ts +144 -0
- package/src/components/MResizablePanels.ts +208 -0
- package/src/components/MSegmentedControl.ts +6 -2
- package/src/components/MSheet.ts +47 -14
- package/src/components/MStack.ts +8 -20
- package/src/components/MTabs.ts +9 -3
- package/src/components/MTimePicker.ts +124 -0
- package/src/components/MToast.ts +5 -1
- package/src/components/MTooltip.ts +291 -0
- package/src/components/MVirtualList.ts +155 -0
- package/src/components/MotionRows.ts +16 -0
- package/src/components/RangeHalo.ts +34 -0
- package/src/components/discovery.ts +147 -0
- package/src/components/interactive.ts +60 -0
- package/src/components/layout.ts +2 -0
- package/src/components/navigation.ts +44 -0
- package/src/components/wayfinding.ts +70 -0
- package/src/content-width.ts +70 -0
- package/src/date-format.ts +36 -0
- package/src/icons.css +7 -0
- package/src/icons.ts +28 -0
- package/src/image-effects.ts +2 -0
- package/src/index.ts +143 -63
- package/src/motion-region.ts +5 -2
- package/src/motion-surface.ts +10 -0
- package/src/motion.ts +1 -1
- package/src/nuxt-navigation.ts +29 -0
- package/src/partition-pointer.ts +88 -0
- package/src/router-navigation.ts +249 -0
- package/src/screen-viewport.ts +8 -4
- package/src/section-scroll.ts +101 -0
- package/src/services.ts +39 -0
- package/src/style.css +2 -1000
package/src/components/layout.ts
CHANGED
|
@@ -35,6 +35,7 @@ export function createLayout(name: string, direction: 'row' | 'column', tag = 'd
|
|
|
35
35
|
inheritAttrs: false,
|
|
36
36
|
props: direction === 'row' ? rowProps : columnProps,
|
|
37
37
|
setup(props, { attrs, slots }) {
|
|
38
|
+
const region = useMotionRegion(() => props.motionRegion)
|
|
38
39
|
const { theme } = useMavisTheme()
|
|
39
40
|
const shrink = useLayoutShrink()
|
|
40
41
|
provide(layoutDirection, direction)
|
|
@@ -54,6 +55,7 @@ export function createLayout(name: string, direction: 'row' | 'column', tag = 'd
|
|
|
54
55
|
},
|
|
55
56
|
},
|
|
56
57
|
webAttrs({ ...attrs, ...viewAttrs(props) }),
|
|
58
|
+
region,
|
|
57
59
|
),
|
|
58
60
|
slots.default?.(),
|
|
59
61
|
)
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { createMenu, createNavigationControls } from '@getcortexlabs/mavis-core/vue'
|
|
2
|
+
import { MPopover } from './MPopover.js'
|
|
3
|
+
import { MRow, MColumn, MBox } from './layout.js'
|
|
4
|
+
import { MButton } from './MButton.js'
|
|
5
|
+
import { MText } from './MText.js'
|
|
6
|
+
import { MBadge } from './MBadge.js'
|
|
7
|
+
import { MSeparator } from './MSeparator.js'
|
|
8
|
+
|
|
9
|
+
export const { MAppBar, MTabBar } = createNavigationControls(
|
|
10
|
+
{ Box: MBox, Row: MRow, Column: MColumn, Text: MText, Button: MButton, Badge: MBadge },
|
|
11
|
+
'web',
|
|
12
|
+
)
|
|
13
|
+
export const MMenu = createMenu(
|
|
14
|
+
{ Popover: MPopover, Column: MColumn, Text: MText, Button: MButton, Separator: MSeparator },
|
|
15
|
+
(input) => {
|
|
16
|
+
const event = input as KeyboardEvent
|
|
17
|
+
const root = event.currentTarget as HTMLElement
|
|
18
|
+
const items = [...root.querySelectorAll<HTMLElement>('[role="menuitem"]:not(:disabled)')]
|
|
19
|
+
const current = items.indexOf(document.activeElement as HTMLElement)
|
|
20
|
+
let next = current
|
|
21
|
+
if (event.key === 'ArrowDown') next = (current + 1) % items.length
|
|
22
|
+
else if (event.key === 'ArrowUp') next = (current + items.length - 1) % items.length
|
|
23
|
+
else if (event.key === 'Home') next = 0
|
|
24
|
+
else if (event.key === 'End') next = items.length - 1
|
|
25
|
+
else if (
|
|
26
|
+
event.key.length === 1 &&
|
|
27
|
+
!event.ctrlKey &&
|
|
28
|
+
!event.metaKey &&
|
|
29
|
+
!event.altKey &&
|
|
30
|
+
event.key !== ' '
|
|
31
|
+
) {
|
|
32
|
+
const order = [...items.slice(current + 1), ...items.slice(0, current + 1)]
|
|
33
|
+
const match = order.find((item) =>
|
|
34
|
+
(item.getAttribute('aria-label') ?? item.textContent ?? '')
|
|
35
|
+
.trim()
|
|
36
|
+
.toLocaleLowerCase()
|
|
37
|
+
.startsWith(event.key.toLocaleLowerCase()),
|
|
38
|
+
)
|
|
39
|
+
if (match) next = items.indexOf(match)
|
|
40
|
+
} else return
|
|
41
|
+
event.preventDefault()
|
|
42
|
+
items[next]?.focus()
|
|
43
|
+
},
|
|
44
|
+
)
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { useComponentWidth } from '../component-width.js'
|
|
2
|
+
import {
|
|
3
|
+
createChart,
|
|
4
|
+
createCommandPalette,
|
|
5
|
+
createWayfindingControls,
|
|
6
|
+
} from '@getcortexlabs/mavis-core/vue'
|
|
7
|
+
import { MRow, MColumn, MBox } from './layout.js'
|
|
8
|
+
import { MText } from './MText.js'
|
|
9
|
+
import { MButton } from './MButton.js'
|
|
10
|
+
import { MLink } from './MLink.js'
|
|
11
|
+
import { MIcon } from './MIcon.js'
|
|
12
|
+
import { MBadge } from './MBadge.js'
|
|
13
|
+
import { MSeparator } from './MSeparator.js'
|
|
14
|
+
import { MSheet } from './MSheet.js'
|
|
15
|
+
import { MInput } from './MInput.js'
|
|
16
|
+
import { MSelect } from './MSelect.js'
|
|
17
|
+
import { MReveal } from './MReveal.js'
|
|
18
|
+
import { ChartPlot } from './ChartPlot.js'
|
|
19
|
+
const ui = {
|
|
20
|
+
railWidth: useComponentWidth,
|
|
21
|
+
focus: (component: unknown) => (component as { $el?: HTMLElement } | undefined)?.$el?.focus(),
|
|
22
|
+
Row: MRow,
|
|
23
|
+
Column: MColumn,
|
|
24
|
+
Box: MBox,
|
|
25
|
+
Text: MText,
|
|
26
|
+
Button: MButton,
|
|
27
|
+
Link: MLink,
|
|
28
|
+
Icon: MIcon,
|
|
29
|
+
Badge: MBadge,
|
|
30
|
+
Separator: MSeparator,
|
|
31
|
+
Sheet: MSheet,
|
|
32
|
+
Input: MInput,
|
|
33
|
+
Select: MSelect,
|
|
34
|
+
Reveal: MReveal,
|
|
35
|
+
Plot: ChartPlot,
|
|
36
|
+
}
|
|
37
|
+
export const { MNavigationRail, MBreadcrumb, MTimeline } = createWayfindingControls(ui, 'web')
|
|
38
|
+
export const MChart = createChart(ui, 'web')
|
|
39
|
+
export const MCommandPalette = createCommandPalette(
|
|
40
|
+
{
|
|
41
|
+
...ui,
|
|
42
|
+
focus: (component) => (component as { $el?: HTMLElement } | undefined)?.$el?.focus(),
|
|
43
|
+
shortcut: (callback, enabled) => {
|
|
44
|
+
const handler = (event: KeyboardEvent) => {
|
|
45
|
+
if (
|
|
46
|
+
!enabled() ||
|
|
47
|
+
event.defaultPrevented ||
|
|
48
|
+
event.repeat ||
|
|
49
|
+
event.isComposing ||
|
|
50
|
+
event.altKey ||
|
|
51
|
+
!(event.metaKey || event.ctrlKey) ||
|
|
52
|
+
event.key.toLowerCase() !== 'k'
|
|
53
|
+
)
|
|
54
|
+
return
|
|
55
|
+
const target = event.target as HTMLElement | null
|
|
56
|
+
if (
|
|
57
|
+
target?.closest(
|
|
58
|
+
'input,textarea,select,[contenteditable=""],[contenteditable="true"],dialog[open],[role="dialog"]',
|
|
59
|
+
)
|
|
60
|
+
)
|
|
61
|
+
return
|
|
62
|
+
event.preventDefault()
|
|
63
|
+
callback()
|
|
64
|
+
}
|
|
65
|
+
document.addEventListener('keydown', handler)
|
|
66
|
+
return () => document.removeEventListener('keydown', handler)
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
'web',
|
|
70
|
+
)
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import {
|
|
2
|
+
onActivated,
|
|
3
|
+
onBeforeUnmount,
|
|
4
|
+
onDeactivated,
|
|
5
|
+
onMounted,
|
|
6
|
+
shallowRef,
|
|
7
|
+
watch,
|
|
8
|
+
type ShallowRef,
|
|
9
|
+
} from 'vue'
|
|
10
|
+
|
|
11
|
+
/** Width-only observation: layout updates run outside ResizeObserver's delivery loop. */
|
|
12
|
+
export function useContentWidth(
|
|
13
|
+
element: ShallowRef<HTMLElement | undefined>,
|
|
14
|
+
enabled: () => boolean,
|
|
15
|
+
) {
|
|
16
|
+
const width = shallowRef<number>()
|
|
17
|
+
let observer: ResizeObserver | undefined
|
|
18
|
+
let frame: number | undefined
|
|
19
|
+
let measured: number | undefined
|
|
20
|
+
let mounted = false
|
|
21
|
+
function stop() {
|
|
22
|
+
observer?.disconnect()
|
|
23
|
+
observer = undefined
|
|
24
|
+
if (frame !== undefined) cancelAnimationFrame(frame)
|
|
25
|
+
frame = undefined
|
|
26
|
+
measured = undefined
|
|
27
|
+
}
|
|
28
|
+
function start() {
|
|
29
|
+
if (
|
|
30
|
+
!mounted ||
|
|
31
|
+
observer ||
|
|
32
|
+
!enabled() ||
|
|
33
|
+
!element.value ||
|
|
34
|
+
typeof ResizeObserver === 'undefined'
|
|
35
|
+
)
|
|
36
|
+
return
|
|
37
|
+
observer = new ResizeObserver(([entry]) => {
|
|
38
|
+
if (!mounted || !enabled() || !entry || entry.contentRect.width === measured) return
|
|
39
|
+
measured = entry.contentRect.width
|
|
40
|
+
if (frame !== undefined) cancelAnimationFrame(frame)
|
|
41
|
+
frame = requestAnimationFrame(() => {
|
|
42
|
+
frame = undefined
|
|
43
|
+
width.value = measured
|
|
44
|
+
})
|
|
45
|
+
})
|
|
46
|
+
observer.observe(element.value)
|
|
47
|
+
}
|
|
48
|
+
onMounted(() => {
|
|
49
|
+
mounted = true
|
|
50
|
+
start()
|
|
51
|
+
})
|
|
52
|
+
onActivated(() => {
|
|
53
|
+
mounted = true
|
|
54
|
+
start()
|
|
55
|
+
})
|
|
56
|
+
onDeactivated(() => {
|
|
57
|
+
mounted = false
|
|
58
|
+
stop()
|
|
59
|
+
})
|
|
60
|
+
onBeforeUnmount(() => {
|
|
61
|
+
mounted = false
|
|
62
|
+
stop()
|
|
63
|
+
})
|
|
64
|
+
watch(enabled, () => {
|
|
65
|
+
stop()
|
|
66
|
+
if (enabled()) start()
|
|
67
|
+
else width.value = undefined
|
|
68
|
+
})
|
|
69
|
+
return width
|
|
70
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import {
|
|
2
|
+
civilDate,
|
|
3
|
+
dateTimeMilliseconds,
|
|
4
|
+
resolveDateTimeOptions,
|
|
5
|
+
type DateTimeValue,
|
|
6
|
+
type DateTimeFormatOptions,
|
|
7
|
+
} from '@getcortexlabs/mavis-core'
|
|
8
|
+
export type { DateTimeValue, DateTimeFormatOptions, DateTimeStyle } from '@getcortexlabs/mavis-core'
|
|
9
|
+
|
|
10
|
+
export function formatDateTime(value: DateTimeValue, options: DateTimeFormatOptions): string {
|
|
11
|
+
const { locale, ...format } = resolveDateTimeOptions(options)
|
|
12
|
+
return new Intl.DateTimeFormat(locale, { ...format, calendar: 'gregory' }).format(
|
|
13
|
+
dateTimeMilliseconds(value),
|
|
14
|
+
)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** Explicit conversion from an instant to a Gregorian calendar day in a named zone. */
|
|
18
|
+
export function dateTimeToCivilDate(
|
|
19
|
+
value: DateTimeValue,
|
|
20
|
+
options: Pick<DateTimeFormatOptions, 'timeZone'>,
|
|
21
|
+
) {
|
|
22
|
+
const { timeZone } = resolveDateTimeOptions(options)
|
|
23
|
+
const parts = new Intl.DateTimeFormat('en-US', {
|
|
24
|
+
timeZone,
|
|
25
|
+
calendar: 'gregory',
|
|
26
|
+
numberingSystem: 'latn',
|
|
27
|
+
year: 'numeric',
|
|
28
|
+
month: '2-digit',
|
|
29
|
+
day: '2-digit',
|
|
30
|
+
era: 'short',
|
|
31
|
+
}).formatToParts(dateTimeMilliseconds(value))
|
|
32
|
+
const part = (type: Intl.DateTimeFormatPartTypes) =>
|
|
33
|
+
parts.find((part) => part.type === type)?.value
|
|
34
|
+
if (part('era') !== 'AD') throw new RangeError('Civil dates support years 0001–9999.')
|
|
35
|
+
return civilDate(`${part('year')!.padStart(4, '0')}-${part('month')}-${part('day')}`)
|
|
36
|
+
}
|
package/src/icons.css
ADDED
package/src/icons.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { h, inject, type Component, type InjectionKey, type VNode } from 'vue'
|
|
2
|
+
import { iconFontFamily, iconGlyph, type IconName } from '@getcortexlabs/mavis-core'
|
|
3
|
+
|
|
4
|
+
export interface MavisIconOptions {
|
|
5
|
+
/** Import only the SVG components the application uses. Missing entries use iconFallback. */
|
|
6
|
+
icons?: Partial<Record<IconName, Component>>
|
|
7
|
+
iconFallback?: 'font' | 'none'
|
|
8
|
+
}
|
|
9
|
+
export const iconOptionsKey: InjectionKey<MavisIconOptions> = Symbol('mavis.icons')
|
|
10
|
+
|
|
11
|
+
/** One app-scoped resolver shared by standalone icons and control adornments. */
|
|
12
|
+
export function useIconContent() {
|
|
13
|
+
const options = inject(iconOptionsKey, undefined)
|
|
14
|
+
return (name: IconName, size: number): { content: string | VNode; fontFamily?: string } => {
|
|
15
|
+
const component = options?.icons?.[name]
|
|
16
|
+
if (component)
|
|
17
|
+
return {
|
|
18
|
+
content: h(component, {
|
|
19
|
+
width: size,
|
|
20
|
+
height: size,
|
|
21
|
+
'aria-hidden': 'true',
|
|
22
|
+
focusable: 'false',
|
|
23
|
+
}),
|
|
24
|
+
}
|
|
25
|
+
if (options?.iconFallback === 'none') return { content: '' }
|
|
26
|
+
return { content: iconGlyph(name), fontFamily: iconFontFamily }
|
|
27
|
+
}
|
|
28
|
+
}
|
package/src/image-effects.ts
CHANGED
|
@@ -33,6 +33,8 @@ export async function webImageEffect(
|
|
|
33
33
|
const image = loadedMotionImage(target),
|
|
34
34
|
presentation = images.get(image)!
|
|
35
35
|
const { to, ...rest } = options
|
|
36
|
+
if (to !== undefined && image.srcset?.trim())
|
|
37
|
+
throw new TypeError('Dissolve source replacement requires an image without srcset.')
|
|
36
38
|
const preparation = {}
|
|
37
39
|
preparations.set(image, preparation)
|
|
38
40
|
let destination: HTMLImageElement | undefined
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,29 @@
|
|
|
1
|
+
import {
|
|
2
|
+
MImageViewer,
|
|
3
|
+
MNumberFlow,
|
|
4
|
+
MSortableList,
|
|
5
|
+
MSwipeActions,
|
|
6
|
+
MResizablePanels,
|
|
7
|
+
MImageCompare,
|
|
8
|
+
} from './components/interactive.js'
|
|
9
|
+
import {
|
|
10
|
+
MCommandPalette,
|
|
11
|
+
MNavigationRail,
|
|
12
|
+
MBreadcrumb,
|
|
13
|
+
MTimeline,
|
|
14
|
+
MChart,
|
|
15
|
+
} from './components/wayfinding.js'
|
|
16
|
+
import { MTooltip } from './components/MTooltip.js'
|
|
17
|
+
import { MDataTable, MCarousel, MCalendar, MRating, MTreeView } from './components/discovery.js'
|
|
18
|
+
import { MRangeSlider } from './components/MRangeSlider.js'
|
|
19
|
+
import { MPopover } from './components/MPopover.js'
|
|
20
|
+
import { MMenu, MAppBar, MTabBar } from './components/navigation.js'
|
|
21
|
+
import { MTimePicker } from './components/MTimePicker.js'
|
|
22
|
+
import { MVirtualList } from './components/MVirtualList.js'
|
|
1
23
|
import { MNumberInput, MMultiSelect } from './components/configurator.js'
|
|
2
24
|
import { MImage } from './components/MImage.js'
|
|
3
25
|
import { MStack } from './components/MStack.js'
|
|
26
|
+
import { MGrid } from './components/MGrid.js'
|
|
4
27
|
export { themeVariables, useMavisTokens } from './tokens.js'
|
|
5
28
|
import { MLink } from './components/MLink.js'
|
|
6
29
|
import { MDatePicker, MDateRangePicker } from './components/MDatePicker.js'
|
|
@@ -9,16 +32,11 @@ import { MFilePicker } from './components/MFilePicker.js'
|
|
|
9
32
|
import { MFormGroup, MFormErrors, MSteps, MPagination } from './components/workflows.js'
|
|
10
33
|
import { MChip } from './components/MChip.js'
|
|
11
34
|
import { MEmptyState } from './components/MEmptyState.js'
|
|
12
|
-
import type { App } from 'vue'
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
installAppToast,
|
|
18
|
-
themeKey,
|
|
19
|
-
type ThemeContextOptions,
|
|
20
|
-
} from '@getcortexlabs/mavis-core/vue'
|
|
21
|
-
import { systemAppearance } from './appearance.js'
|
|
35
|
+
import type { App, Component } from 'vue'
|
|
36
|
+
import { createMavisServices, type MavisServiceOptions } from './services.js'
|
|
37
|
+
export { createMavisServices } from './services.js'
|
|
38
|
+
export type { MavisServiceOptions, MavisIconOptions } from './services.js'
|
|
39
|
+
import { MThemeProvider, MSpan, MPlatform } from '@getcortexlabs/mavis-core/vue'
|
|
22
40
|
import { MScreen } from './components/MScreen.js'
|
|
23
41
|
import { MBox, MRow, MColumn } from './components/layout.js'
|
|
24
42
|
import { MCard } from './components/MCard.js'
|
|
@@ -47,13 +65,21 @@ import { MReveal } from './components/MReveal.js'
|
|
|
47
65
|
import { MSheet } from './components/MSheet.js'
|
|
48
66
|
|
|
49
67
|
export {
|
|
68
|
+
MImageViewer,
|
|
69
|
+
MNumberFlow,
|
|
70
|
+
MSortableList,
|
|
71
|
+
MSwipeActions,
|
|
72
|
+
MResizablePanels,
|
|
73
|
+
MImageCompare,
|
|
50
74
|
MThemeProvider,
|
|
75
|
+
MPlatform,
|
|
51
76
|
MSpan,
|
|
52
77
|
MScreen,
|
|
53
78
|
MBox,
|
|
54
79
|
MRow,
|
|
55
80
|
MColumn,
|
|
56
81
|
MStack,
|
|
82
|
+
MGrid,
|
|
57
83
|
MLink,
|
|
58
84
|
MCard,
|
|
59
85
|
MText,
|
|
@@ -92,16 +118,40 @@ export {
|
|
|
92
118
|
MFormErrors,
|
|
93
119
|
MSteps,
|
|
94
120
|
MPagination,
|
|
121
|
+
MPopover,
|
|
122
|
+
MMenu,
|
|
123
|
+
MAppBar,
|
|
124
|
+
MTabBar,
|
|
125
|
+
MTimePicker,
|
|
126
|
+
MVirtualList,
|
|
127
|
+
MDataTable,
|
|
128
|
+
MCarousel,
|
|
129
|
+
MRangeSlider,
|
|
130
|
+
MCalendar,
|
|
131
|
+
MRating,
|
|
132
|
+
MTreeView,
|
|
133
|
+
MCommandPalette,
|
|
134
|
+
MNavigationRail,
|
|
135
|
+
MBreadcrumb,
|
|
136
|
+
MTooltip,
|
|
137
|
+
MTimeline,
|
|
138
|
+
MChart,
|
|
95
139
|
}
|
|
96
140
|
export {
|
|
97
141
|
useMavisTheme,
|
|
142
|
+
useMavisPlatform,
|
|
143
|
+
useMavisListMotion,
|
|
98
144
|
useToast,
|
|
99
145
|
useFormController,
|
|
100
146
|
useFormField,
|
|
101
147
|
useFileSelection,
|
|
148
|
+
useMavisNavigation,
|
|
102
149
|
} from '@getcortexlabs/mavis-core/vue'
|
|
103
150
|
export type {
|
|
104
151
|
MavisThemeContext,
|
|
152
|
+
MavisPlatform,
|
|
153
|
+
MavisPlatformTarget,
|
|
154
|
+
MavisPlatformContext,
|
|
105
155
|
Appearance,
|
|
106
156
|
AppearanceMode,
|
|
107
157
|
AppearanceSource,
|
|
@@ -109,64 +159,90 @@ export type {
|
|
|
109
159
|
export type { Align, Justify } from './components/layout.js'
|
|
110
160
|
export * from '@getcortexlabs/mavis-core'
|
|
111
161
|
|
|
112
|
-
export type MavisOptions =
|
|
162
|
+
export type MavisOptions = MavisServiceOptions & { components?: false | Record<string, Component> }
|
|
113
163
|
|
|
114
164
|
/** Create one plugin per application; `system` appearance follows `prefers-color-scheme`. */
|
|
115
165
|
export function createMavis(options: MavisOptions = {}) {
|
|
116
166
|
return {
|
|
117
167
|
install(app: App) {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
168
|
+
const { components, ...services } = options
|
|
169
|
+
createMavisServices(services).install(app)
|
|
170
|
+
if (components === false) return
|
|
171
|
+
for (const [name, component] of Object.entries(
|
|
172
|
+
components ?? {
|
|
173
|
+
MImageViewer,
|
|
174
|
+
MNumberFlow,
|
|
175
|
+
MSortableList,
|
|
176
|
+
MSwipeActions,
|
|
177
|
+
MResizablePanels,
|
|
178
|
+
MImageCompare,
|
|
179
|
+
MThemeProvider,
|
|
180
|
+
MPlatform,
|
|
181
|
+
MSpan,
|
|
182
|
+
MScreen,
|
|
183
|
+
MBox,
|
|
184
|
+
MRow,
|
|
185
|
+
MColumn,
|
|
186
|
+
MStack,
|
|
187
|
+
MGrid,
|
|
188
|
+
MLink,
|
|
189
|
+
MCard,
|
|
190
|
+
MText,
|
|
191
|
+
MButton,
|
|
192
|
+
MSlider,
|
|
193
|
+
MSwitch,
|
|
194
|
+
MCheckbox,
|
|
195
|
+
MRadioGroup,
|
|
196
|
+
MSelect,
|
|
197
|
+
MToast,
|
|
198
|
+
MDialog,
|
|
199
|
+
MTabs,
|
|
200
|
+
MSkeleton,
|
|
201
|
+
MChip,
|
|
202
|
+
MEmptyState,
|
|
203
|
+
MProgress,
|
|
204
|
+
MAccordion,
|
|
205
|
+
MSegmentedControl,
|
|
206
|
+
MAlert,
|
|
207
|
+
MListItem,
|
|
208
|
+
MSeparator,
|
|
209
|
+
MAvatar,
|
|
210
|
+
MBadge,
|
|
211
|
+
MInput,
|
|
212
|
+
MIcon,
|
|
213
|
+
MReveal,
|
|
214
|
+
MSheet,
|
|
215
|
+
MDatePicker,
|
|
216
|
+
MDateRangePicker,
|
|
217
|
+
MNumberInput,
|
|
218
|
+
MMultiSelect,
|
|
219
|
+
MImage,
|
|
220
|
+
MCombobox,
|
|
221
|
+
MFilePicker,
|
|
222
|
+
MFormGroup,
|
|
223
|
+
MFormErrors,
|
|
224
|
+
MSteps,
|
|
225
|
+
MPagination,
|
|
226
|
+
MPopover,
|
|
227
|
+
MMenu,
|
|
228
|
+
MAppBar,
|
|
229
|
+
MTabBar,
|
|
230
|
+
MTimePicker,
|
|
231
|
+
MVirtualList,
|
|
232
|
+
MDataTable,
|
|
233
|
+
MCarousel,
|
|
234
|
+
MRangeSlider,
|
|
235
|
+
MCalendar,
|
|
236
|
+
MRating,
|
|
237
|
+
MTreeView,
|
|
238
|
+
MCommandPalette,
|
|
239
|
+
MNavigationRail,
|
|
240
|
+
MBreadcrumb,
|
|
241
|
+
MTooltip,
|
|
242
|
+
MTimeline,
|
|
243
|
+
MChart,
|
|
244
|
+
},
|
|
245
|
+
)) {
|
|
170
246
|
app.component(name, component)
|
|
171
247
|
}
|
|
172
248
|
},
|
|
@@ -174,3 +250,7 @@ export function createMavis(options: MavisOptions = {}) {
|
|
|
174
250
|
}
|
|
175
251
|
|
|
176
252
|
export * from './files.js'
|
|
253
|
+
export { formatDateTime, dateTimeToCivilDate } from './date-format.js'
|
|
254
|
+
|
|
255
|
+
export { createMavisNavigation } from './router-navigation.js'
|
|
256
|
+
export { createNuxtMavisNavigation } from './nuxt-navigation.js'
|
package/src/motion-region.ts
CHANGED
|
@@ -4,7 +4,8 @@ import {
|
|
|
4
4
|
type MotionRegion,
|
|
5
5
|
type MotionRegionAdapter,
|
|
6
6
|
} from '@getcortexlabs/mavis-core/experimental'
|
|
7
|
-
import { createMotionContext, motionContextKey } from './motion-context.js'
|
|
7
|
+
import { createMotionContext, motionContextKey, useMotionContext } from './motion-context.js'
|
|
8
|
+
import { isComponentMotionRegion } from '@getcortexlabs/mavis-core/vue'
|
|
8
9
|
import { webSurfaceTarget } from './motion-surface.js'
|
|
9
10
|
import { webScrollElement } from './scroll-motion.js'
|
|
10
11
|
import type { WebRuntime } from '@rafaelaugusto/jolt/web'
|
|
@@ -41,6 +42,8 @@ function regionAdapter(runtime: WebRuntime, target: HTMLElement): MotionRegionAd
|
|
|
41
42
|
: ([resolve(step[0]), step[1], step[2]] as const),
|
|
42
43
|
)
|
|
43
44
|
const adapter: MotionRegionAdapter = {
|
|
45
|
+
animateLayout: (change, { transition, ...options }) =>
|
|
46
|
+
runtime.animateLayout(target, change, { ...transition, ...options }),
|
|
44
47
|
...webPlatformMotion(runtime, target, resolve),
|
|
45
48
|
...webCollectionMotion(runtime, target, resolve),
|
|
46
49
|
sequence: (items) =>
|
|
@@ -158,7 +161,7 @@ export function useMotionRegion(reference: () => MotionRegion | undefined) {
|
|
|
158
161
|
})
|
|
159
162
|
return {}
|
|
160
163
|
}
|
|
161
|
-
const context = createMotionContext()
|
|
164
|
+
const context = isComponentMotionRegion(reference()!) ? useMotionContext() : createMotionContext()
|
|
162
165
|
provide(motionContextKey, context)
|
|
163
166
|
const element = shallowRef<HTMLElement>()
|
|
164
167
|
let release: (() => void) | undefined
|
package/src/motion-surface.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { webScrollElement } from './scroll-motion.js'
|
|
2
|
+
import { webSectionScroll } from './section-scroll.js'
|
|
2
3
|
import type {
|
|
3
4
|
WebReadableValue,
|
|
4
5
|
WebRuntime,
|
|
@@ -139,6 +140,15 @@ export function webMotionSurface(
|
|
|
139
140
|
}
|
|
140
141
|
},
|
|
141
142
|
refresh: () => runtime.refresh(target),
|
|
143
|
+
scrollSection: (source, section, frames, options) =>
|
|
144
|
+
webSectionScroll(
|
|
145
|
+
owner,
|
|
146
|
+
webScrollElement(source),
|
|
147
|
+
webRegion(section).target,
|
|
148
|
+
target,
|
|
149
|
+
frames,
|
|
150
|
+
options,
|
|
151
|
+
),
|
|
142
152
|
scrollLinked: (source, frames, options) =>
|
|
143
153
|
owner.scrollLinked(webScrollElement(source), target, frames, options),
|
|
144
154
|
map(source, input, output, options) {
|
package/src/motion.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { webMotionSurface } from './motion-surface.js'
|
|
|
6
6
|
import { useMotionContext } from './motion-context.js'
|
|
7
7
|
import { useConnectedMotion } from './connected-motion.js'
|
|
8
8
|
|
|
9
|
-
// Chip
|
|
9
|
+
// Selectable Chip uses the same input and lifecycle contract.
|
|
10
10
|
export function pressStyle(scale: number) {
|
|
11
11
|
return { '--m-press-scale': scale, '--m-press-duration': '120ms', '--m-press-ease': 'ease-out' }
|
|
12
12
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { createMavisNavigation, type WebNavigationRouter } from './router-navigation.js'
|
|
2
|
+
import type { NavigationTransition } from '@getcortexlabs/mavis-core'
|
|
3
|
+
|
|
4
|
+
export interface NuxtNavigationHost {
|
|
5
|
+
$router: WebNavigationRouter
|
|
6
|
+
hook(name: 'page:finish', callback: () => void): () => void
|
|
7
|
+
}
|
|
8
|
+
/** Subscribe before confirmation so synchronous and async Nuxt pages cannot miss page:finish. */
|
|
9
|
+
export function createNuxtMavisNavigation(
|
|
10
|
+
app: NuxtNavigationHost,
|
|
11
|
+
options: { transition?: NavigationTransition; focus?: () => HTMLElement | null } = {},
|
|
12
|
+
) {
|
|
13
|
+
return createMavisNavigation(app.$router, {
|
|
14
|
+
...options,
|
|
15
|
+
ready(signal, to, from) {
|
|
16
|
+
if (to.matched?.at(-1) === from.matched?.at(-1)) return
|
|
17
|
+
return new Promise<void>((resolve) => {
|
|
18
|
+
const finish = () => {
|
|
19
|
+
stop()
|
|
20
|
+
signal.removeEventListener('abort', finish)
|
|
21
|
+
resolve()
|
|
22
|
+
}
|
|
23
|
+
const stop = app.hook('page:finish', finish)
|
|
24
|
+
signal.addEventListener('abort', finish, { once: true })
|
|
25
|
+
if (signal.aborted) finish()
|
|
26
|
+
})
|
|
27
|
+
},
|
|
28
|
+
})
|
|
29
|
+
}
|