@getcortexlabs/mavis-web 0.1.0-alpha.1 → 0.1.0-alpha.10
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 +8 -4
- package/dist/appearance.d.ts +4 -0
- package/dist/appearance.d.ts.map +1 -0
- package/dist/appearance.js +23 -0
- package/dist/appearance.js.map +1 -0
- package/dist/collection-motion.d.ts +4 -0
- package/dist/collection-motion.d.ts.map +1 -0
- package/dist/collection-motion.js +97 -0
- package/dist/collection-motion.js.map +1 -0
- package/dist/components/ChoicePaint.d.ts +17 -0
- package/dist/components/ChoicePaint.d.ts.map +1 -0
- package/dist/components/ChoicePaint.js +81 -0
- package/dist/components/ChoicePaint.js.map +1 -0
- package/dist/components/DateCalendar.d.ts +95 -0
- package/dist/components/DateCalendar.d.ts.map +1 -0
- package/dist/components/DateCalendar.js +157 -0
- package/dist/components/DateCalendar.js.map +1 -0
- package/dist/components/LoadingDecoration.d.ts +116 -0
- package/dist/components/LoadingDecoration.d.ts.map +1 -0
- package/dist/components/LoadingDecoration.js +35 -0
- package/dist/components/LoadingDecoration.js.map +1 -0
- package/dist/components/MAccordion.d.ts +119 -0
- package/dist/components/MAccordion.d.ts.map +1 -0
- package/dist/components/MAccordion.js +180 -0
- package/dist/components/MAccordion.js.map +1 -0
- package/dist/components/MAlert.d.ts +109 -0
- package/dist/components/MAlert.d.ts.map +1 -0
- package/dist/components/MAlert.js +88 -0
- package/dist/components/MAlert.js.map +1 -0
- package/dist/components/MAvatar.d.ts +80 -0
- package/dist/components/MAvatar.d.ts.map +1 -0
- package/dist/components/MAvatar.js +88 -0
- package/dist/components/MAvatar.js.map +1 -0
- package/dist/components/MBadge.d.ts +70 -0
- package/dist/components/MBadge.d.ts.map +1 -0
- package/dist/components/MBadge.js +35 -0
- package/dist/components/MBadge.js.map +1 -0
- package/dist/components/MButton.d.ts +215 -35
- package/dist/components/MButton.d.ts.map +1 -1
- package/dist/components/MButton.js +104 -19
- package/dist/components/MButton.js.map +1 -1
- package/dist/components/MCard.d.ts +118 -25
- package/dist/components/MCard.d.ts.map +1 -1
- package/dist/components/MCard.js +69 -33
- package/dist/components/MCard.js.map +1 -1
- package/dist/components/MCheckbox.d.ts +103 -0
- package/dist/components/MCheckbox.d.ts.map +1 -0
- package/dist/components/MCheckbox.js +132 -0
- package/dist/components/MCheckbox.js.map +1 -0
- package/dist/components/MChip.d.ts +117 -0
- package/dist/components/MChip.d.ts.map +1 -0
- package/dist/components/MChip.js +103 -0
- package/dist/components/MChip.js.map +1 -0
- package/dist/components/MCombobox.d.ts +282 -0
- package/dist/components/MCombobox.d.ts.map +1 -0
- package/dist/components/MCombobox.js +450 -0
- package/dist/components/MCombobox.js.map +1 -0
- package/dist/components/MDatePicker.d.ts +1350 -0
- package/dist/components/MDatePicker.d.ts.map +1 -0
- package/dist/components/MDatePicker.js +23 -0
- package/dist/components/MDatePicker.js.map +1 -0
- package/dist/components/MDialog.d.ts +99 -0
- package/dist/components/MDialog.d.ts.map +1 -0
- package/dist/components/MDialog.js +279 -0
- package/dist/components/MDialog.js.map +1 -0
- package/dist/components/MEmptyState.d.ts +117 -0
- package/dist/components/MEmptyState.d.ts.map +1 -0
- package/dist/components/MEmptyState.js +79 -0
- package/dist/components/MEmptyState.js.map +1 -0
- package/dist/components/MFilePicker.d.ts +112 -0
- package/dist/components/MFilePicker.d.ts.map +1 -0
- package/dist/components/MFilePicker.js +193 -0
- package/dist/components/MFilePicker.js.map +1 -0
- package/dist/components/MGrid.d.ts +163 -0
- package/dist/components/MGrid.d.ts.map +1 -0
- package/dist/components/MGrid.js +32 -0
- package/dist/components/MGrid.js.map +1 -0
- package/dist/components/MIcon.d.ts +75 -0
- package/dist/components/MIcon.d.ts.map +1 -0
- package/dist/components/MIcon.js +38 -0
- package/dist/components/MIcon.js.map +1 -0
- package/dist/components/MImage.d.ts +248 -0
- package/dist/components/MImage.d.ts.map +1 -0
- package/dist/components/MImage.js +163 -0
- package/dist/components/MImage.js.map +1 -0
- package/dist/components/MInput.d.ts +201 -53
- package/dist/components/MInput.d.ts.map +1 -1
- package/dist/components/MInput.js +192 -71
- package/dist/components/MInput.js.map +1 -1
- package/dist/components/MLink.d.ts +120 -0
- package/dist/components/MLink.d.ts.map +1 -0
- package/dist/components/MLink.js +47 -0
- package/dist/components/MLink.js.map +1 -0
- package/dist/components/MListItem.d.ts +106 -0
- package/dist/components/MListItem.d.ts.map +1 -0
- package/dist/components/MListItem.js +53 -0
- package/dist/components/MListItem.js.map +1 -0
- package/dist/components/MPopover.d.ts +105 -0
- package/dist/components/MPopover.d.ts.map +1 -0
- package/dist/components/MPopover.js +238 -0
- package/dist/components/MPopover.js.map +1 -0
- package/dist/components/MProgress.d.ts +122 -0
- package/dist/components/MProgress.d.ts.map +1 -0
- package/dist/components/MProgress.js +69 -0
- package/dist/components/MProgress.js.map +1 -0
- package/dist/components/MRadioGroup.d.ts +104 -0
- package/dist/components/MRadioGroup.d.ts.map +1 -0
- package/dist/components/MRadioGroup.js +191 -0
- package/dist/components/MRadioGroup.js.map +1 -0
- package/dist/components/MReveal.d.ts +76 -40
- package/dist/components/MReveal.d.ts.map +1 -1
- package/dist/components/MReveal.js +43 -29
- package/dist/components/MReveal.js.map +1 -1
- package/dist/components/MScreen.d.ts +40 -7
- package/dist/components/MScreen.d.ts.map +1 -1
- package/dist/components/MScreen.js +59 -17
- package/dist/components/MScreen.js.map +1 -1
- package/dist/components/MSegmentedControl.d.ts +95 -0
- package/dist/components/MSegmentedControl.d.ts.map +1 -0
- package/dist/components/MSegmentedControl.js +128 -0
- package/dist/components/MSegmentedControl.js.map +1 -0
- package/dist/components/MSelect.d.ts +140 -0
- package/dist/components/MSelect.d.ts.map +1 -0
- package/dist/components/MSelect.js +314 -0
- package/dist/components/MSelect.js.map +1 -0
- package/dist/components/MSeparator.d.ts +56 -0
- package/dist/components/MSeparator.d.ts.map +1 -0
- package/dist/components/MSeparator.js +36 -0
- package/dist/components/MSeparator.js.map +1 -0
- package/dist/components/MSheet.d.ts +117 -0
- package/dist/components/MSheet.d.ts.map +1 -0
- package/dist/components/MSheet.js +303 -0
- package/dist/components/MSheet.js.map +1 -0
- package/dist/components/MSkeleton.d.ts +89 -0
- package/dist/components/MSkeleton.d.ts.map +1 -0
- package/dist/components/MSkeleton.js +49 -0
- package/dist/components/MSkeleton.js.map +1 -0
- package/dist/components/MSlider.d.ts +9 -5
- package/dist/components/MSlider.d.ts.map +1 -1
- package/dist/components/MSlider.js +14 -2
- package/dist/components/MSlider.js.map +1 -1
- package/dist/components/MStack.d.ts +198 -0
- package/dist/components/MStack.d.ts.map +1 -0
- package/dist/components/MStack.js +52 -0
- package/dist/components/MStack.js.map +1 -0
- package/dist/components/MSwitch.d.ts +89 -0
- package/dist/components/MSwitch.d.ts.map +1 -0
- package/dist/components/MSwitch.js +94 -0
- package/dist/components/MSwitch.js.map +1 -0
- package/dist/components/MTabs.d.ts +101 -0
- package/dist/components/MTabs.d.ts.map +1 -0
- package/dist/components/MTabs.js +228 -0
- package/dist/components/MTabs.js.map +1 -0
- package/dist/components/MText.d.ts +62 -26
- package/dist/components/MText.d.ts.map +1 -1
- package/dist/components/MText.js +37 -13
- package/dist/components/MText.js.map +1 -1
- 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 +24 -0
- package/dist/components/MToast.d.ts.map +1 -0
- package/dist/components/MToast.js +196 -0
- package/dist/components/MToast.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 +109 -0
- package/dist/components/MVirtualList.js.map +1 -0
- package/dist/components/configurator.d.ts +541 -0
- package/dist/components/configurator.d.ts.map +1 -0
- package/dist/components/configurator.js +20 -0
- package/dist/components/configurator.js.map +1 -0
- package/dist/components/layout.d.ts +425 -95
- package/dist/components/layout.d.ts.map +1 -1
- package/dist/components/layout.js +18 -13
- 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/workflows.d.ts +251 -0
- package/dist/components/workflows.d.ts.map +1 -0
- package/dist/components/workflows.js +23 -0
- package/dist/components/workflows.js.map +1 -0
- package/dist/connected-motion.d.ts +6 -0
- package/dist/connected-motion.d.ts.map +1 -0
- package/dist/connected-motion.js +18 -0
- package/dist/connected-motion.js.map +1 -0
- 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/experimental.d.ts +11 -0
- package/dist/experimental.d.ts.map +1 -0
- package/dist/experimental.js +31 -0
- package/dist/experimental.js.map +1 -0
- package/dist/files.d.ts +6 -0
- package/dist/files.d.ts.map +1 -0
- package/dist/files.js +82 -0
- package/dist/files.js.map +1 -0
- package/dist/hydration.d.ts +3 -0
- package/dist/hydration.d.ts.map +1 -0
- package/dist/hydration.js +20 -0
- package/dist/hydration.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 +11 -0
- package/dist/image-effects.d.ts.map +1 -0
- package/dist/image-effects.js +67 -0
- package/dist/image-effects.js.map +1 -0
- package/dist/index.d.ts +51 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +92 -6
- package/dist/index.js.map +1 -1
- package/dist/input-attrs.d.ts +15 -0
- package/dist/input-attrs.d.ts.map +1 -0
- package/dist/input-attrs.js +18 -0
- package/dist/input-attrs.js.map +1 -0
- package/dist/motion-context.d.ts +13 -0
- package/dist/motion-context.d.ts.map +1 -0
- package/dist/motion-context.js +33 -0
- package/dist/motion-context.js.map +1 -0
- package/dist/motion-region.d.ts +16 -0
- package/dist/motion-region.d.ts.map +1 -0
- package/dist/motion-region.js +174 -0
- package/dist/motion-region.js.map +1 -0
- package/dist/motion-surface.d.ts +16 -0
- package/dist/motion-surface.d.ts.map +1 -0
- package/dist/motion-surface.js +244 -0
- package/dist/motion-surface.js.map +1 -0
- package/dist/motion.d.ts +20 -0
- package/dist/motion.d.ts.map +1 -0
- package/dist/motion.js +244 -0
- package/dist/motion.js.map +1 -0
- package/dist/navigation.d.ts +12 -0
- package/dist/navigation.d.ts.map +1 -0
- package/dist/navigation.js +38 -0
- package/dist/navigation.js.map +1 -0
- 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/platform-motion.d.ts +4 -0
- package/dist/platform-motion.d.ts.map +1 -0
- package/dist/platform-motion.js +23 -0
- package/dist/platform-motion.js.map +1 -0
- package/dist/reveal-motion.d.ts +5 -0
- package/dist/reveal-motion.d.ts.map +1 -0
- package/dist/reveal-motion.js +53 -0
- package/dist/reveal-motion.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 +8 -0
- package/dist/screen-viewport.js.map +1 -1
- package/dist/scroll-motion.d.ts +5 -0
- package/dist/scroll-motion.d.ts.map +1 -0
- package/dist/scroll-motion.js +84 -0
- package/dist/scroll-motion.js.map +1 -0
- 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/dist/sheet-motion.d.ts +12 -0
- package/dist/sheet-motion.d.ts.map +1 -0
- package/dist/sheet-motion.js +83 -0
- package/dist/sheet-motion.js.map +1 -0
- package/dist/style.d.ts.map +1 -1
- package/dist/style.js +24 -9
- package/dist/style.js.map +1 -1
- package/dist/surface-effects.d.ts +4 -0
- package/dist/surface-effects.d.ts.map +1 -0
- package/dist/surface-effects.js +28 -0
- package/dist/surface-effects.js.map +1 -0
- package/dist/tokens.d.ts +7 -0
- package/dist/tokens.d.ts.map +1 -0
- package/dist/tokens.js +29 -0
- package/dist/tokens.js.map +1 -0
- package/dist/use-motion-surface.d.ts +8 -0
- package/dist/use-motion-surface.d.ts.map +1 -0
- package/dist/use-motion-surface.js +33 -0
- package/dist/use-motion-surface.js.map +1 -0
- package/dist/visual-effects.d.ts +4 -0
- package/dist/visual-effects.d.ts.map +1 -0
- package/dist/visual-effects.js +120 -0
- package/dist/visual-effects.js.map +1 -0
- package/package.json +27 -4
- package/src/appearance.ts +23 -0
- package/src/base.css +998 -0
- package/src/collection-motion.ts +107 -0
- package/src/components/ChoicePaint.ts +96 -0
- package/src/components/DateCalendar.ts +213 -0
- package/src/components/LoadingDecoration.ts +39 -0
- package/src/components/MAccordion.ts +231 -0
- package/src/components/MAlert.ts +109 -0
- package/src/components/MAvatar.ts +97 -0
- package/src/components/MBadge.ts +40 -0
- package/src/components/MButton.ts +138 -20
- package/src/components/MCard.ts +96 -30
- package/src/components/MCheckbox.ts +160 -0
- package/src/components/MChip.ts +109 -0
- package/src/components/MCombobox.ts +520 -0
- package/src/components/MDatePicker.ts +23 -0
- package/src/components/MDialog.ts +319 -0
- package/src/components/MEmptyState.ts +96 -0
- package/src/components/MFilePicker.ts +233 -0
- package/src/components/MGrid.ts +45 -0
- package/src/components/MIcon.ts +47 -0
- package/src/components/MImage.ts +183 -0
- package/src/components/MInput.ts +216 -71
- package/src/components/MLink.ts +63 -0
- package/src/components/MListItem.ts +66 -0
- package/src/components/MPopover.ts +280 -0
- package/src/components/MProgress.ts +82 -0
- package/src/components/MRadioGroup.ts +216 -0
- package/src/components/MReveal.ts +62 -32
- package/src/components/MScreen.ts +57 -3
- package/src/components/MSegmentedControl.ts +151 -0
- package/src/components/MSelect.ts +367 -0
- package/src/components/MSeparator.ts +40 -0
- package/src/components/MSheet.ts +361 -0
- package/src/components/MSkeleton.ts +61 -0
- package/src/components/MSlider.ts +25 -2
- package/src/components/MStack.ts +73 -0
- package/src/components/MSwitch.ts +119 -0
- package/src/components/MTabs.ts +275 -0
- package/src/components/MText.ts +46 -14
- package/src/components/MTimePicker.ts +124 -0
- package/src/components/MToast.ts +241 -0
- package/src/components/MVirtualList.ts +146 -0
- package/src/components/configurator.ts +24 -0
- package/src/components/layout.ts +20 -12
- package/src/components/navigation.ts +44 -0
- package/src/components/workflows.ts +27 -0
- package/src/connected-motion.ts +23 -0
- package/src/content-width.ts +70 -0
- package/src/date-format.ts +36 -0
- package/src/experimental.ts +37 -0
- package/src/files.ts +77 -0
- package/src/fonts/LICENSE +45 -0
- package/src/fonts/lucide.woff2 +0 -0
- package/src/hydration.ts +21 -0
- package/src/icons.css +7 -0
- package/src/icons.ts +28 -0
- package/src/image-effects.ts +80 -0
- package/src/index.ts +183 -20
- package/src/input-attrs.ts +41 -0
- package/src/motion-context.ts +35 -0
- package/src/motion-region.ts +209 -0
- package/src/motion-surface.ts +274 -0
- package/src/motion.ts +281 -0
- package/src/navigation.ts +44 -0
- package/src/nuxt-navigation.ts +29 -0
- package/src/platform-motion.ts +36 -0
- package/src/reveal-motion.ts +59 -0
- package/src/router-navigation.ts +249 -0
- package/src/screen-viewport.ts +6 -0
- package/src/scroll-motion.ts +88 -0
- package/src/section-scroll.ts +101 -0
- package/src/services.ts +39 -0
- package/src/sheet-motion.ts +80 -0
- package/src/style.css +2 -139
- package/src/style.ts +20 -9
- package/src/surface-effects.ts +33 -0
- package/src/tokens.ts +29 -0
- package/src/use-motion-surface.ts +43 -0
- package/src/visual-effects.ts +139 -0
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { getCurrentScope, onScopeDispose } from 'vue'
|
|
2
|
+
import type { WebMotionScope, WebMotionResource } from '@rafaelaugusto/jolt/web'
|
|
3
|
+
import { regionState, type MotionRegion } from '@getcortexlabs/mavis-core/experimental'
|
|
4
|
+
import { webRegion } from './motion-region.js'
|
|
5
|
+
|
|
6
|
+
/** Call from an explicit application action; a request does not prove physical vibration. */
|
|
7
|
+
export function requestMavisWebHaptic(
|
|
8
|
+
region: MotionRegion,
|
|
9
|
+
style: import('@rafaelaugusto/jolt/web').HapticStyle,
|
|
10
|
+
): import('@rafaelaugusto/jolt/web').WebHapticResult {
|
|
11
|
+
return webRegion(regionState(region).adapter).runtime.haptic(style)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Web-only composition for application HTML/SVG inside a declared MBox region.
|
|
16
|
+
* Borrows the very same Jolt context as the region's component press surfaces.
|
|
17
|
+
* Setup is absent during SSR and recreated with its region and document lifecycle.
|
|
18
|
+
*/
|
|
19
|
+
export function useMavisWebMotion(
|
|
20
|
+
region: MotionRegion,
|
|
21
|
+
setup: (scope: WebMotionScope, element: HTMLElement) => void | WebMotionResource,
|
|
22
|
+
): () => void {
|
|
23
|
+
if (!getCurrentScope()) throw new Error('useMavisWebMotion requires a Vue setup scope.')
|
|
24
|
+
const stop = region.onAvailable(() => {
|
|
25
|
+
const { runtime, target } = webRegion(regionState(region).adapter)
|
|
26
|
+
const owner = runtime.scope()
|
|
27
|
+
try {
|
|
28
|
+
owner.use((scope) => setup(scope, target))
|
|
29
|
+
} catch (error) {
|
|
30
|
+
owner.dispose()
|
|
31
|
+
throw error
|
|
32
|
+
}
|
|
33
|
+
return () => owner.dispose()
|
|
34
|
+
})
|
|
35
|
+
onScopeDispose(stop)
|
|
36
|
+
return stop
|
|
37
|
+
}
|
package/src/files.ts
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { FileHandle, FilePickerAdapter, SelectedFile } from '@getcortexlabs/mavis-core'
|
|
2
|
+
|
|
3
|
+
const handles = new WeakMap<FileHandle, File>()
|
|
4
|
+
|
|
5
|
+
/** The host may read/send the File while the selection owns its resource. */
|
|
6
|
+
export function getWebFile(handle: FileHandle): File {
|
|
7
|
+
const file = handles.get(handle)
|
|
8
|
+
if (!file) throw new Error('This Web file handle is unavailable or has been released')
|
|
9
|
+
return file
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function resource(file: File): SelectedFile {
|
|
13
|
+
const handle = Object.freeze({}) as FileHandle
|
|
14
|
+
handles.set(handle, file)
|
|
15
|
+
let source: string | undefined
|
|
16
|
+
let released = false
|
|
17
|
+
return {
|
|
18
|
+
name: file.name,
|
|
19
|
+
size: file.size,
|
|
20
|
+
type: file.type || undefined,
|
|
21
|
+
handle,
|
|
22
|
+
async preview() {
|
|
23
|
+
if (released || !file.type.startsWith('image/')) return
|
|
24
|
+
source ??= URL.createObjectURL(file)
|
|
25
|
+
return source
|
|
26
|
+
},
|
|
27
|
+
release() {
|
|
28
|
+
if (released) return
|
|
29
|
+
released = true
|
|
30
|
+
if (source) URL.revokeObjectURL(source)
|
|
31
|
+
handles.delete(handle)
|
|
32
|
+
},
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Creating the adapter is SSR-safe. The input exists only during user-triggered selection. */
|
|
37
|
+
export function createWebFilePicker(): FilePickerAdapter {
|
|
38
|
+
return {
|
|
39
|
+
pick(request, cancellation) {
|
|
40
|
+
if (typeof document === 'undefined')
|
|
41
|
+
return Promise.reject(new Error('File selection requires a mounted browser'))
|
|
42
|
+
if (cancellation.cancelled) return Promise.resolve(null)
|
|
43
|
+
return new Promise((resolve, reject) => {
|
|
44
|
+
const input = document.createElement('input')
|
|
45
|
+
input.type = 'file'
|
|
46
|
+
input.multiple = request.multiple
|
|
47
|
+
input.accept = request.accept.join(',')
|
|
48
|
+
input.tabIndex = -1
|
|
49
|
+
input.setAttribute('aria-hidden', 'true')
|
|
50
|
+
input.style.display = 'none'
|
|
51
|
+
let done = false
|
|
52
|
+
let unsubscribe = () => {}
|
|
53
|
+
const finish = (files: readonly SelectedFile[] | null, error?: unknown) => {
|
|
54
|
+
if (done) return
|
|
55
|
+
done = true
|
|
56
|
+
unsubscribe()
|
|
57
|
+
input.removeEventListener('change', change)
|
|
58
|
+
input.removeEventListener('cancel', cancel)
|
|
59
|
+
input.remove()
|
|
60
|
+
if (error) reject(error)
|
|
61
|
+
else resolve(files)
|
|
62
|
+
}
|
|
63
|
+
const change = () => finish(Array.from(input.files ?? []).map(resource))
|
|
64
|
+
const cancel = () => finish(null)
|
|
65
|
+
input.addEventListener('change', change)
|
|
66
|
+
input.addEventListener('cancel', cancel)
|
|
67
|
+
document.body.append(input)
|
|
68
|
+
unsubscribe = cancellation.onCancel(cancel)
|
|
69
|
+
try {
|
|
70
|
+
input.click()
|
|
71
|
+
} catch (error) {
|
|
72
|
+
finish(null, error)
|
|
73
|
+
}
|
|
74
|
+
})
|
|
75
|
+
},
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
Lucide icon font 1.65.0
|
|
2
|
+
|
|
3
|
+
ISC License
|
|
4
|
+
|
|
5
|
+
Copyright (c) 2026 Lucide Icons and Contributors
|
|
6
|
+
|
|
7
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
8
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
9
|
+
copyright notice and this permission notice appear in all copies.
|
|
10
|
+
|
|
11
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
12
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
13
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
14
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
15
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
16
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
17
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
The following Lucide icons are derived from the Feather project:
|
|
22
|
+
|
|
23
|
+
airplay, alert-circle, alert-octagon, alert-triangle, aperture, arrow-down-circle, arrow-down-left, arrow-down-right, arrow-down, arrow-left-circle, arrow-left, arrow-right-circle, arrow-right, arrow-up-circle, arrow-up-left, arrow-up-right, arrow-up, at-sign, calendar, cast, check, chevron-down, chevron-left, chevron-right, chevron-up, chevrons-down, chevrons-left, chevrons-right, chevrons-up, circle, clipboard, clock, code, columns, command, compass, corner-down-left, corner-down-right, corner-left-down, corner-left-up, corner-right-down, corner-right-up, corner-up-left, corner-up-right, crosshair, database, divide-circle, divide-square, dollar-sign, download, external-link, feather, frown, hash, headphones, help-circle, info, italic, key, layout, life-buoy, link-2, link, loader, lock, log-in, log-out, maximize, meh, minimize, minimize-2, minus-circle, minus-square, minus, monitor, moon, more-horizontal, more-vertical, move, music, navigation-2, navigation, octagon, pause-circle, percent, plus-circle, plus-square, plus, power, radio, rss, search, server, share, shopping-bag, sidebar, smartphone, smile, square, table-2, tablet, target, terminal, trash-2, trash, triangle, tv, type, upload, x-circle, x-octagon, x-square, x, zoom-in, zoom-out
|
|
24
|
+
|
|
25
|
+
The MIT License (MIT) (for the icons listed above)
|
|
26
|
+
|
|
27
|
+
Copyright (c) 2013-present Cole Bemis
|
|
28
|
+
|
|
29
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
30
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
31
|
+
in the Software without restriction, including without limitation the rights
|
|
32
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
33
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
34
|
+
furnished to do so, subject to the following conditions:
|
|
35
|
+
|
|
36
|
+
The above copyright notice and this permission notice shall be included in all
|
|
37
|
+
copies or substantial portions of the Software.
|
|
38
|
+
|
|
39
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
40
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
41
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
42
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
43
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
44
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
45
|
+
SOFTWARE.
|
|
Binary file
|
package/src/hydration.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { getCurrentInstance, onBeforeMount, onMounted, shallowRef } from 'vue'
|
|
2
|
+
|
|
3
|
+
/** Read only this component's existing server root, before Vue patches editor values. */
|
|
4
|
+
export function useHydrationEdit<T>(
|
|
5
|
+
read: (root: Element) => T | undefined,
|
|
6
|
+
adopt: (value: T) => void,
|
|
7
|
+
) {
|
|
8
|
+
const instance = getCurrentInstance()!
|
|
9
|
+
let edit: T | undefined
|
|
10
|
+
const mounted = shallowRef(false)
|
|
11
|
+
onBeforeMount(() => {
|
|
12
|
+
const root = instance.vnode.el
|
|
13
|
+
if (root?.nodeType === 1) edit = read(root as Element)
|
|
14
|
+
})
|
|
15
|
+
onMounted(() => {
|
|
16
|
+
if (edit !== undefined) adopt(edit)
|
|
17
|
+
// A rerender also restores controlled values when the parent rejects the edit.
|
|
18
|
+
mounted.value = true
|
|
19
|
+
})
|
|
20
|
+
return () => (mounted.value ? undefined : edit)
|
|
21
|
+
}
|
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
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
MotionImageEffectName,
|
|
3
|
+
MotionImageEffectOptions,
|
|
4
|
+
MotionPlayback,
|
|
5
|
+
} from '@getcortexlabs/mavis-core/experimental'
|
|
6
|
+
import type { WebRuntime, WebMotionScope } from '@rafaelaugusto/jolt/web'
|
|
7
|
+
|
|
8
|
+
type Presentation = {
|
|
9
|
+
current(): boolean
|
|
10
|
+
commit(src: string): Promise<boolean>
|
|
11
|
+
}
|
|
12
|
+
const images = new WeakMap<HTMLImageElement, Presentation>()
|
|
13
|
+
const preparations = new WeakMap<HTMLImageElement, object>()
|
|
14
|
+
export function registerMotionImage(target: HTMLImageElement, presentation: Presentation) {
|
|
15
|
+
images.set(target, presentation)
|
|
16
|
+
return () => {
|
|
17
|
+
if (images.get(target) === presentation) images.delete(target)
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export function loadedMotionImage(target: HTMLElement): HTMLImageElement {
|
|
21
|
+
const image = target as HTMLImageElement
|
|
22
|
+
if (!images.has(image) || !image.complete || !image.naturalWidth)
|
|
23
|
+
throw new TypeError('Use the ready motionSurface of MImage for pixel effects.')
|
|
24
|
+
return image
|
|
25
|
+
}
|
|
26
|
+
export async function webImageEffect(
|
|
27
|
+
owner: WebRuntime | WebMotionScope,
|
|
28
|
+
target: HTMLElement,
|
|
29
|
+
name: MotionImageEffectName,
|
|
30
|
+
options: MotionImageEffectOptions = {},
|
|
31
|
+
live: () => boolean = () => true,
|
|
32
|
+
) {
|
|
33
|
+
const image = loadedMotionImage(target),
|
|
34
|
+
presentation = images.get(image)!
|
|
35
|
+
const { to, ...rest } = options
|
|
36
|
+
if (to !== undefined && image.srcset?.trim())
|
|
37
|
+
throw new TypeError('Dissolve source replacement requires an image without srcset.')
|
|
38
|
+
const preparation = {}
|
|
39
|
+
preparations.set(image, preparation)
|
|
40
|
+
let destination: HTMLImageElement | undefined
|
|
41
|
+
if (to !== undefined) {
|
|
42
|
+
if (name !== 'dissolve' || !to.trim())
|
|
43
|
+
throw new TypeError('Only dissolve accepts a nonempty destination source.')
|
|
44
|
+
destination = new image.ownerDocument.defaultView!.Image()
|
|
45
|
+
destination.crossOrigin = image.crossOrigin ?? 'anonymous'
|
|
46
|
+
destination.src = to
|
|
47
|
+
await destination.decode()
|
|
48
|
+
}
|
|
49
|
+
if (
|
|
50
|
+
!live() ||
|
|
51
|
+
preparations.get(image) !== preparation ||
|
|
52
|
+
!presentation.current() ||
|
|
53
|
+
images.get(image) !== presentation ||
|
|
54
|
+
!image.isConnected
|
|
55
|
+
)
|
|
56
|
+
throw new Error('Image presentation changed while preparing the effect.')
|
|
57
|
+
const previous = image.src
|
|
58
|
+
const raw = owner.imageEffect(image, name, {
|
|
59
|
+
...rest,
|
|
60
|
+
...(destination ? { to: destination } : {}),
|
|
61
|
+
})
|
|
62
|
+
const finished = raw.finished.then(async (success) => {
|
|
63
|
+
if (!success || !to || raw.progress !== 1) return success
|
|
64
|
+
if (!presentation.current() || images.get(image) !== presentation) return false
|
|
65
|
+
if (!live()) {
|
|
66
|
+
if (image.src === destination?.src) image.src = previous
|
|
67
|
+
return false
|
|
68
|
+
}
|
|
69
|
+
return presentation.commit(to)
|
|
70
|
+
})
|
|
71
|
+
return new Proxy(raw as MotionPlayback, {
|
|
72
|
+
get(target, key) {
|
|
73
|
+
if (key === 'then') return undefined
|
|
74
|
+
if (key === 'finished') return finished
|
|
75
|
+
const value = Reflect.get(target, key, target)
|
|
76
|
+
return typeof value === 'function' ? value.bind(target) : value
|
|
77
|
+
},
|
|
78
|
+
set: (target, key, value) => Reflect.set(target, key, value, target),
|
|
79
|
+
})
|
|
80
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,39 +1,202 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { MPopover } from './components/MPopover.js'
|
|
2
|
+
import { MMenu, MAppBar, MTabBar } from './components/navigation.js'
|
|
3
|
+
import { MTimePicker } from './components/MTimePicker.js'
|
|
4
|
+
import { MVirtualList } from './components/MVirtualList.js'
|
|
5
|
+
import { MNumberInput, MMultiSelect } from './components/configurator.js'
|
|
6
|
+
import { MImage } from './components/MImage.js'
|
|
7
|
+
import { MStack } from './components/MStack.js'
|
|
8
|
+
import { MGrid } from './components/MGrid.js'
|
|
9
|
+
export { themeVariables, useMavisTokens } from './tokens.js'
|
|
10
|
+
import { MLink } from './components/MLink.js'
|
|
11
|
+
import { MDatePicker, MDateRangePicker } from './components/MDatePicker.js'
|
|
12
|
+
import { MCombobox } from './components/MCombobox.js'
|
|
13
|
+
import { MFilePicker } from './components/MFilePicker.js'
|
|
14
|
+
import { MFormGroup, MFormErrors, MSteps, MPagination } from './components/workflows.js'
|
|
15
|
+
import { MChip } from './components/MChip.js'
|
|
16
|
+
import { MEmptyState } from './components/MEmptyState.js'
|
|
17
|
+
import type { App, Component } from 'vue'
|
|
18
|
+
import { createMavisServices, type MavisServiceOptions } from './services.js'
|
|
19
|
+
export { createMavisServices } from './services.js'
|
|
20
|
+
export type { MavisServiceOptions, MavisIconOptions } from './services.js'
|
|
21
|
+
import { MThemeProvider, MSpan, MPlatform } from '@getcortexlabs/mavis-core/vue'
|
|
4
22
|
import { MScreen } from './components/MScreen.js'
|
|
5
23
|
import { MBox, MRow, MColumn } from './components/layout.js'
|
|
6
24
|
import { MCard } from './components/MCard.js'
|
|
7
25
|
import { MText } from './components/MText.js'
|
|
8
26
|
import { MButton } from './components/MButton.js'
|
|
27
|
+
import { MToast } from './components/MToast.js'
|
|
28
|
+
import { MDialog } from './components/MDialog.js'
|
|
29
|
+
import { MListItem } from './components/MListItem.js'
|
|
30
|
+
import { MSeparator } from './components/MSeparator.js'
|
|
31
|
+
import { MAvatar } from './components/MAvatar.js'
|
|
32
|
+
import { MBadge } from './components/MBadge.js'
|
|
33
|
+
import { MSkeleton } from './components/MSkeleton.js'
|
|
34
|
+
import { MProgress } from './components/MProgress.js'
|
|
35
|
+
import { MAccordion } from './components/MAccordion.js'
|
|
36
|
+
import { MSegmentedControl } from './components/MSegmentedControl.js'
|
|
37
|
+
import { MAlert } from './components/MAlert.js'
|
|
38
|
+
import { MTabs } from './components/MTabs.js'
|
|
39
|
+
import { MSelect } from './components/MSelect.js'
|
|
40
|
+
import { MRadioGroup } from './components/MRadioGroup.js'
|
|
41
|
+
import { MCheckbox } from './components/MCheckbox.js'
|
|
42
|
+
import { MSwitch } from './components/MSwitch.js'
|
|
9
43
|
import { MSlider } from './components/MSlider.js'
|
|
10
44
|
import { MInput } from './components/MInput.js'
|
|
45
|
+
import { MIcon } from './components/MIcon.js'
|
|
11
46
|
import { MReveal } from './components/MReveal.js'
|
|
47
|
+
import { MSheet } from './components/MSheet.js'
|
|
12
48
|
|
|
13
|
-
export {
|
|
14
|
-
|
|
15
|
-
|
|
49
|
+
export {
|
|
50
|
+
MThemeProvider,
|
|
51
|
+
MPlatform,
|
|
52
|
+
MSpan,
|
|
53
|
+
MScreen,
|
|
54
|
+
MBox,
|
|
55
|
+
MRow,
|
|
56
|
+
MColumn,
|
|
57
|
+
MStack,
|
|
58
|
+
MGrid,
|
|
59
|
+
MLink,
|
|
60
|
+
MCard,
|
|
61
|
+
MText,
|
|
62
|
+
MButton,
|
|
63
|
+
MSlider,
|
|
64
|
+
MSwitch,
|
|
65
|
+
MCheckbox,
|
|
66
|
+
MRadioGroup,
|
|
67
|
+
MSelect,
|
|
68
|
+
MToast,
|
|
69
|
+
MDialog,
|
|
70
|
+
MTabs,
|
|
71
|
+
MSkeleton,
|
|
72
|
+
MChip,
|
|
73
|
+
MEmptyState,
|
|
74
|
+
MProgress,
|
|
75
|
+
MAccordion,
|
|
76
|
+
MSegmentedControl,
|
|
77
|
+
MAlert,
|
|
78
|
+
MListItem,
|
|
79
|
+
MSeparator,
|
|
80
|
+
MAvatar,
|
|
81
|
+
MBadge,
|
|
82
|
+
MInput,
|
|
83
|
+
MIcon,
|
|
84
|
+
MReveal,
|
|
85
|
+
MSheet,
|
|
86
|
+
MDatePicker,
|
|
87
|
+
MDateRangePicker,
|
|
88
|
+
MNumberInput,
|
|
89
|
+
MMultiSelect,
|
|
90
|
+
MImage,
|
|
91
|
+
MCombobox,
|
|
92
|
+
MFilePicker,
|
|
93
|
+
MFormGroup,
|
|
94
|
+
MFormErrors,
|
|
95
|
+
MSteps,
|
|
96
|
+
MPagination,
|
|
97
|
+
MPopover,
|
|
98
|
+
MMenu,
|
|
99
|
+
MAppBar,
|
|
100
|
+
MTabBar,
|
|
101
|
+
MTimePicker,
|
|
102
|
+
MVirtualList,
|
|
103
|
+
}
|
|
104
|
+
export {
|
|
105
|
+
useMavisTheme,
|
|
106
|
+
useMavisPlatform,
|
|
107
|
+
useMavisListMotion,
|
|
108
|
+
useToast,
|
|
109
|
+
useFormController,
|
|
110
|
+
useFormField,
|
|
111
|
+
useFileSelection,
|
|
112
|
+
useMavisNavigation,
|
|
113
|
+
} from '@getcortexlabs/mavis-core/vue'
|
|
114
|
+
export type {
|
|
115
|
+
MavisThemeContext,
|
|
116
|
+
MavisPlatform,
|
|
117
|
+
MavisPlatformTarget,
|
|
118
|
+
MavisPlatformContext,
|
|
119
|
+
Appearance,
|
|
120
|
+
AppearanceMode,
|
|
121
|
+
AppearanceSource,
|
|
122
|
+
} from '@getcortexlabs/mavis-core/vue'
|
|
16
123
|
export type { Align, Justify } from './components/layout.js'
|
|
17
124
|
export * from '@getcortexlabs/mavis-core'
|
|
18
125
|
|
|
19
|
-
export
|
|
126
|
+
export type MavisOptions = MavisServiceOptions & { components?: false | Record<string, Component> }
|
|
127
|
+
|
|
128
|
+
/** Create one plugin per application; `system` appearance follows `prefers-color-scheme`. */
|
|
129
|
+
export function createMavis(options: MavisOptions = {}) {
|
|
20
130
|
return {
|
|
21
131
|
install(app: App) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
132
|
+
const { components, ...services } = options
|
|
133
|
+
createMavisServices(services).install(app)
|
|
134
|
+
if (components === false) return
|
|
135
|
+
for (const [name, component] of Object.entries(
|
|
136
|
+
components ?? {
|
|
137
|
+
MThemeProvider,
|
|
138
|
+
MPlatform,
|
|
139
|
+
MSpan,
|
|
140
|
+
MScreen,
|
|
141
|
+
MBox,
|
|
142
|
+
MRow,
|
|
143
|
+
MColumn,
|
|
144
|
+
MStack,
|
|
145
|
+
MGrid,
|
|
146
|
+
MLink,
|
|
147
|
+
MCard,
|
|
148
|
+
MText,
|
|
149
|
+
MButton,
|
|
150
|
+
MSlider,
|
|
151
|
+
MSwitch,
|
|
152
|
+
MCheckbox,
|
|
153
|
+
MRadioGroup,
|
|
154
|
+
MSelect,
|
|
155
|
+
MToast,
|
|
156
|
+
MDialog,
|
|
157
|
+
MTabs,
|
|
158
|
+
MSkeleton,
|
|
159
|
+
MChip,
|
|
160
|
+
MEmptyState,
|
|
161
|
+
MProgress,
|
|
162
|
+
MAccordion,
|
|
163
|
+
MSegmentedControl,
|
|
164
|
+
MAlert,
|
|
165
|
+
MListItem,
|
|
166
|
+
MSeparator,
|
|
167
|
+
MAvatar,
|
|
168
|
+
MBadge,
|
|
169
|
+
MInput,
|
|
170
|
+
MIcon,
|
|
171
|
+
MReveal,
|
|
172
|
+
MSheet,
|
|
173
|
+
MDatePicker,
|
|
174
|
+
MDateRangePicker,
|
|
175
|
+
MNumberInput,
|
|
176
|
+
MMultiSelect,
|
|
177
|
+
MImage,
|
|
178
|
+
MCombobox,
|
|
179
|
+
MFilePicker,
|
|
180
|
+
MFormGroup,
|
|
181
|
+
MFormErrors,
|
|
182
|
+
MSteps,
|
|
183
|
+
MPagination,
|
|
184
|
+
MPopover,
|
|
185
|
+
MMenu,
|
|
186
|
+
MAppBar,
|
|
187
|
+
MTabBar,
|
|
188
|
+
MTimePicker,
|
|
189
|
+
MVirtualList,
|
|
190
|
+
},
|
|
191
|
+
)) {
|
|
35
192
|
app.component(name, component)
|
|
36
193
|
}
|
|
37
194
|
},
|
|
38
195
|
}
|
|
39
196
|
}
|
|
197
|
+
|
|
198
|
+
export * from './files.js'
|
|
199
|
+
export { formatDateTime, dateTimeToCivilDate } from './date-format.js'
|
|
200
|
+
|
|
201
|
+
export { createMavisNavigation } from './router-navigation.js'
|
|
202
|
+
export { createNuxtMavisNavigation } from './nuxt-navigation.js'
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { AriaAttributes, HTMLAttributes } from 'vue'
|
|
2
|
+
|
|
3
|
+
type EditorEvents = Pick<
|
|
4
|
+
HTMLAttributes,
|
|
5
|
+
| 'onBeforeinput'
|
|
6
|
+
| 'onInput'
|
|
7
|
+
| 'onChange'
|
|
8
|
+
| 'onInvalid'
|
|
9
|
+
| 'onKeydown'
|
|
10
|
+
| 'onKeyup'
|
|
11
|
+
| 'onKeypress'
|
|
12
|
+
| 'onCompositionstart'
|
|
13
|
+
| 'onCompositionupdate'
|
|
14
|
+
| 'onCompositionend'
|
|
15
|
+
>
|
|
16
|
+
|
|
17
|
+
export interface InputEditorAttributes extends AriaAttributes, EditorEvents {}
|
|
18
|
+
|
|
19
|
+
declare module '@getcortexlabs/mavis-core/vue' {
|
|
20
|
+
interface InputPlatformAttributes extends InputEditorAttributes {}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Editing events belong to the editor; layout and other attributes stay on its wrapper. */
|
|
24
|
+
const editorEvent =
|
|
25
|
+
/^on(?:Beforeinput|Input|Change|Invalid|Keydown|Keyup|Keypress|Compositionstart|Compositionupdate|Compositionend)(?:Once|Capture|Passive)*$/
|
|
26
|
+
|
|
27
|
+
export function inputAttrs(attrs: Record<string, unknown>) {
|
|
28
|
+
const editor: Record<string, unknown> = {}
|
|
29
|
+
const wrapper: Record<string, unknown> = {}
|
|
30
|
+
for (const [name, value] of Object.entries(attrs)) {
|
|
31
|
+
const target = name.startsWith('aria-') || editorEvent.test(name) ? editor : wrapper
|
|
32
|
+
target[name] = value
|
|
33
|
+
}
|
|
34
|
+
return { editor, wrapper }
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function describedBy(value: unknown, message: string | undefined) {
|
|
38
|
+
const ids = typeof value === 'string' ? value.trim().split(/\s+/).filter(Boolean) : []
|
|
39
|
+
if (message) ids.push(message)
|
|
40
|
+
return [...new Set(ids)].join(' ') || undefined
|
|
41
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { inject, type InjectionKey } from 'vue'
|
|
2
|
+
import { createWebRuntime, type WebRuntime } from '@rafaelaugusto/jolt/web'
|
|
3
|
+
|
|
4
|
+
export interface WebMotionContext {
|
|
5
|
+
acquire(document: Document): { runtime: WebRuntime; release(): void }
|
|
6
|
+
}
|
|
7
|
+
export const motionContextKey: InjectionKey<WebMotionContext> = Symbol('mavis-motion-context')
|
|
8
|
+
|
|
9
|
+
/** A context belongs to a declared region, never to a process or an SSR request singleton. */
|
|
10
|
+
export function createMotionContext(): WebMotionContext {
|
|
11
|
+
let current: { document: Document; runtime: WebRuntime; users: number } | undefined
|
|
12
|
+
return {
|
|
13
|
+
acquire(document) {
|
|
14
|
+
if (current && current.document !== document)
|
|
15
|
+
throw new Error('A motion region cannot span documents.')
|
|
16
|
+
const context = (current ??= { document, runtime: createWebRuntime(document), users: 0 })
|
|
17
|
+
context.users++
|
|
18
|
+
let released = false
|
|
19
|
+
return {
|
|
20
|
+
runtime: context.runtime,
|
|
21
|
+
release() {
|
|
22
|
+
if (released) return
|
|
23
|
+
released = true
|
|
24
|
+
if (--context.users === 0) {
|
|
25
|
+
if (current === context) current = undefined
|
|
26
|
+
context.runtime.dispose()
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export function useMotionContext() {
|
|
34
|
+
return inject(motionContextKey, undefined) ?? createMotionContext()
|
|
35
|
+
}
|