@getcortexlabs/mavis-web 0.1.0-alpha.1 → 0.1.0-alpha.11
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/ChartPlot.d.ts +65 -0
- package/dist/components/ChartPlot.d.ts.map +1 -0
- package/dist/components/ChartPlot.js +135 -0
- package/dist/components/ChartPlot.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 +110 -0
- package/dist/components/DateCalendar.d.ts.map +1 -0
- package/dist/components/DateCalendar.js +166 -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 +202 -54
- 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/MRangeSlider.d.ts +104 -0
- package/dist/components/MRangeSlider.d.ts.map +1 -0
- package/dist/components/MRangeSlider.js +95 -0
- package/dist/components/MRangeSlider.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/MTooltip.d.ts +65 -0
- package/dist/components/MTooltip.d.ts.map +1 -0
- package/dist/components/MTooltip.js +259 -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 +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/discovery.d.ts +282 -0
- package/dist/components/discovery.d.ts.map +1 -0
- package/dist/components/discovery.js +113 -0
- package/dist/components/discovery.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/wayfinding.d.ts +441 -0
- package/dist/components/wayfinding.d.ts.map +1 -0
- package/dist/components/wayfinding.js +56 -0
- package/dist/components/wayfinding.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 +55 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +108 -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 +1115 -0
- package/src/collection-motion.ts +107 -0
- package/src/components/ChartPlot.ts +139 -0
- package/src/components/ChoicePaint.ts +96 -0
- package/src/components/DateCalendar.ts +225 -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/MRangeSlider.ts +115 -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/MTooltip.ts +293 -0
- package/src/components/MVirtualList.ts +146 -0
- package/src/components/configurator.ts +24 -0
- package/src/components/discovery.ts +163 -0
- package/src/components/layout.ts +20 -12
- package/src/components/navigation.ts +44 -0
- package/src/components/wayfinding.ts +68 -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 +217 -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,163 @@
|
|
|
1
|
+
import { h } from 'vue'
|
|
2
|
+
import {
|
|
3
|
+
createDiscoveryControls,
|
|
4
|
+
createCarousel,
|
|
5
|
+
createTreeView,
|
|
6
|
+
createDataTable,
|
|
7
|
+
} from '@getcortexlabs/mavis-core/vue'
|
|
8
|
+
import type { DataColumn } from '@getcortexlabs/mavis-core'
|
|
9
|
+
import { MRow, MColumn, MBox } from './layout.js'
|
|
10
|
+
import { MText } from './MText.js'
|
|
11
|
+
import { MButton } from './MButton.js'
|
|
12
|
+
import { MIcon } from './MIcon.js'
|
|
13
|
+
import { MSlider } from './MSlider.js'
|
|
14
|
+
import { MCheckbox } from './MCheckbox.js'
|
|
15
|
+
import { MProgress } from './MProgress.js'
|
|
16
|
+
import { MReveal } from './MReveal.js'
|
|
17
|
+
import { DateCalendar } from './DateCalendar.js'
|
|
18
|
+
|
|
19
|
+
const ui = {
|
|
20
|
+
Row: MRow,
|
|
21
|
+
Column: MColumn,
|
|
22
|
+
Box: MBox,
|
|
23
|
+
Text: MText,
|
|
24
|
+
Button: MButton,
|
|
25
|
+
Icon: MIcon,
|
|
26
|
+
Slider: MSlider,
|
|
27
|
+
Checkbox: MCheckbox,
|
|
28
|
+
Progress: MProgress,
|
|
29
|
+
Reveal: MReveal,
|
|
30
|
+
Calendar: DateCalendar,
|
|
31
|
+
}
|
|
32
|
+
export const { MCalendar, MRating } = createDiscoveryControls(ui, 'web')
|
|
33
|
+
export const MTreeView = createTreeView(
|
|
34
|
+
{
|
|
35
|
+
...ui,
|
|
36
|
+
focus: (id) => document.getElementById(id)?.focus(),
|
|
37
|
+
containsFocus: (id) => !!document.getElementById(id)?.contains(document.activeElement),
|
|
38
|
+
},
|
|
39
|
+
'web',
|
|
40
|
+
)
|
|
41
|
+
export const MCarousel = createCarousel(
|
|
42
|
+
{
|
|
43
|
+
...ui,
|
|
44
|
+
gestures: (move) => {
|
|
45
|
+
let start: { x: number; y: number; id: number } | undefined
|
|
46
|
+
return {
|
|
47
|
+
tabindex: 0,
|
|
48
|
+
onKeydown: (event: KeyboardEvent) => {
|
|
49
|
+
if (
|
|
50
|
+
event.target !== event.currentTarget ||
|
|
51
|
+
event.altKey ||
|
|
52
|
+
event.ctrlKey ||
|
|
53
|
+
event.metaKey
|
|
54
|
+
)
|
|
55
|
+
return
|
|
56
|
+
const rtl = getComputedStyle(event.currentTarget as HTMLElement).direction === 'rtl'
|
|
57
|
+
if (event.key === 'ArrowRight' || event.key === 'ArrowLeft') {
|
|
58
|
+
event.preventDefault()
|
|
59
|
+
move((event.key === 'ArrowRight' ? 1 : -1) * (rtl ? -1 : 1))
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
onPointerdown: (event: PointerEvent) => {
|
|
63
|
+
start = undefined
|
|
64
|
+
if (
|
|
65
|
+
!event.isPrimary ||
|
|
66
|
+
event.button !== 0 ||
|
|
67
|
+
(event.target as HTMLElement).closest(
|
|
68
|
+
'button,a,input,textarea,select,[contenteditable]',
|
|
69
|
+
)
|
|
70
|
+
)
|
|
71
|
+
return
|
|
72
|
+
start = { x: event.clientX, y: event.clientY, id: event.pointerId }
|
|
73
|
+
;(event.currentTarget as HTMLElement).setPointerCapture(event.pointerId)
|
|
74
|
+
},
|
|
75
|
+
onPointercancel: () => {
|
|
76
|
+
start = undefined
|
|
77
|
+
},
|
|
78
|
+
onPointerup: (event: PointerEvent) => {
|
|
79
|
+
const point = start
|
|
80
|
+
start = undefined
|
|
81
|
+
if (!point || point.id !== event.pointerId) return
|
|
82
|
+
const dx = event.clientX - point.x,
|
|
83
|
+
dy = event.clientY - point.y
|
|
84
|
+
if (Math.abs(dx) > 40 && Math.abs(dx) > Math.abs(dy) * 1.5) {
|
|
85
|
+
const rtl = getComputedStyle(event.currentTarget as HTMLElement).direction === 'rtl'
|
|
86
|
+
move((dx < 0 ? 1 : -1) * (rtl ? -1 : 1))
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
'web',
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
// Theme access must happen in setup, not in the render callback supplied to the factory.
|
|
96
|
+
export const MDataTable = createDataTable(
|
|
97
|
+
{
|
|
98
|
+
...ui,
|
|
99
|
+
table: (columns, header, rows, label, busy) => {
|
|
100
|
+
const cell = (column: DataColumn) => ({
|
|
101
|
+
padding: '12px 16px',
|
|
102
|
+
minWidth: `${column.width ?? 144}px`,
|
|
103
|
+
width: column.width ? `${column.width}px` : undefined,
|
|
104
|
+
textAlign: column.align === 'end' ? ('end' as const) : ('start' as const),
|
|
105
|
+
verticalAlign: 'middle',
|
|
106
|
+
})
|
|
107
|
+
return h(
|
|
108
|
+
'div',
|
|
109
|
+
{
|
|
110
|
+
class: 'm-data-table-scroll',
|
|
111
|
+
tabindex: 0,
|
|
112
|
+
role: 'region',
|
|
113
|
+
'aria-label': label,
|
|
114
|
+
style: { overflowX: 'auto', borderRadius: 'inherit' },
|
|
115
|
+
},
|
|
116
|
+
[
|
|
117
|
+
h(
|
|
118
|
+
'table',
|
|
119
|
+
{
|
|
120
|
+
'aria-label': label,
|
|
121
|
+
'aria-busy': busy,
|
|
122
|
+
style: { width: '100%', borderCollapse: 'collapse' },
|
|
123
|
+
},
|
|
124
|
+
[
|
|
125
|
+
h('thead', [
|
|
126
|
+
h(
|
|
127
|
+
'tr',
|
|
128
|
+
columns.map((column, index) =>
|
|
129
|
+
h(
|
|
130
|
+
'th',
|
|
131
|
+
{
|
|
132
|
+
key: column.key,
|
|
133
|
+
scope: 'col',
|
|
134
|
+
'aria-sort': (column as DataColumn & { sort?: string }).sort,
|
|
135
|
+
style: cell(column),
|
|
136
|
+
},
|
|
137
|
+
[header[index]],
|
|
138
|
+
),
|
|
139
|
+
),
|
|
140
|
+
),
|
|
141
|
+
]),
|
|
142
|
+
h(
|
|
143
|
+
'tbody',
|
|
144
|
+
rows.map((row) =>
|
|
145
|
+
h(
|
|
146
|
+
'tr',
|
|
147
|
+
{ key: row.key, 'data-selected': row.selected },
|
|
148
|
+
row.cells.map((content, index) =>
|
|
149
|
+
h('td', { key: columns[index]!.key, style: cell(columns[index]!) }, [
|
|
150
|
+
content,
|
|
151
|
+
]),
|
|
152
|
+
),
|
|
153
|
+
),
|
|
154
|
+
),
|
|
155
|
+
),
|
|
156
|
+
],
|
|
157
|
+
),
|
|
158
|
+
],
|
|
159
|
+
)
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
'web',
|
|
163
|
+
)
|
package/src/components/layout.ts
CHANGED
|
@@ -4,12 +4,14 @@ import {
|
|
|
4
4
|
viewAttrs,
|
|
5
5
|
useMavisTheme,
|
|
6
6
|
layoutDirection,
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
useLayoutShrink,
|
|
8
|
+
motionBoxProps,
|
|
9
9
|
} from '@getcortexlabs/mavis-core/vue'
|
|
10
10
|
import { defineComponent, h, mergeProps, provide } from 'vue'
|
|
11
11
|
import { resolveSpace } from '@getcortexlabs/mavis-core'
|
|
12
12
|
import { boxStyle, webAttrs } from '../style.js'
|
|
13
|
+
import { useMotionRegion } from '../motion-region.js'
|
|
14
|
+
import { useMotionSurface } from '../use-motion-surface.js'
|
|
13
15
|
|
|
14
16
|
export type { Align, Justify } from '@getcortexlabs/mavis-core/vue'
|
|
15
17
|
|
|
@@ -27,31 +29,33 @@ const distribution = {
|
|
|
27
29
|
around: 'space-around',
|
|
28
30
|
} as const
|
|
29
31
|
|
|
30
|
-
function createLayout(name: string, direction: 'row' | 'column') {
|
|
32
|
+
export function createLayout(name: string, direction: 'row' | 'column', tag = 'div') {
|
|
31
33
|
return defineComponent({
|
|
32
34
|
name,
|
|
33
35
|
inheritAttrs: false,
|
|
34
36
|
props: direction === 'row' ? rowProps : columnProps,
|
|
35
37
|
setup(props, { attrs, slots }) {
|
|
38
|
+
const region = useMotionRegion(() => props.motionRegion)
|
|
36
39
|
const { theme } = useMavisTheme()
|
|
37
|
-
const shrink =
|
|
40
|
+
const shrink = useLayoutShrink()
|
|
38
41
|
provide(layoutDirection, direction)
|
|
39
42
|
return () =>
|
|
40
43
|
h(
|
|
41
|
-
|
|
44
|
+
tag,
|
|
42
45
|
mergeProps(
|
|
43
46
|
{
|
|
44
47
|
style: {
|
|
45
|
-
...boxStyle(theme.value, props, shrink),
|
|
48
|
+
...boxStyle(theme.value, props, shrink.value),
|
|
46
49
|
display: 'flex',
|
|
47
50
|
flexDirection: direction,
|
|
48
|
-
alignItems: alignment[props.align]
|
|
49
|
-
justifyContent: distribution[props.justify]
|
|
51
|
+
alignItems: `var(--m-layout-align, ${alignment[props.align]})`,
|
|
52
|
+
justifyContent: `var(--m-layout-justify, ${distribution[props.justify]})`,
|
|
50
53
|
flexWrap: props.wrap ? 'wrap' : 'nowrap',
|
|
51
|
-
gap:
|
|
54
|
+
gap: `var(--m-layout-gap, ${resolveSpace(theme.value, props.gap ?? 'none')}px)`,
|
|
52
55
|
},
|
|
53
56
|
},
|
|
54
57
|
webAttrs({ ...attrs, ...viewAttrs(props) }),
|
|
58
|
+
region,
|
|
55
59
|
),
|
|
56
60
|
slots.default?.(),
|
|
57
61
|
)
|
|
@@ -64,19 +68,23 @@ export const MColumn = createLayout('MColumn', 'column')
|
|
|
64
68
|
export const MBox = defineComponent({
|
|
65
69
|
name: 'MBox',
|
|
66
70
|
inheritAttrs: false,
|
|
67
|
-
props:
|
|
71
|
+
props: motionBoxProps,
|
|
68
72
|
setup(props, { attrs, slots }) {
|
|
73
|
+
const region = useMotionRegion(() => props.motionRegion)
|
|
74
|
+
const surface = useMotionSurface(() => props.motionSurface)
|
|
69
75
|
const { theme } = useMavisTheme()
|
|
70
|
-
const shrink =
|
|
76
|
+
const shrink = useLayoutShrink()
|
|
71
77
|
return () =>
|
|
72
78
|
h(
|
|
73
79
|
'div',
|
|
74
80
|
mergeProps(
|
|
75
81
|
{
|
|
76
82
|
class: 'm-box',
|
|
77
|
-
style: { ...boxStyle(theme.value, props, shrink), display: 'grid' },
|
|
83
|
+
style: { ...boxStyle(theme.value, props, shrink.value), display: 'grid' },
|
|
78
84
|
},
|
|
79
85
|
webAttrs({ ...attrs, ...viewAttrs(props) }),
|
|
86
|
+
region,
|
|
87
|
+
surface,
|
|
80
88
|
),
|
|
81
89
|
slots.default?.(),
|
|
82
90
|
)
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { createMenu, createNavigationControls } from '@getcortexlabs/mavis-core/vue'
|
|
2
|
+
import { MPopover } from './MPopover.js'
|
|
3
|
+
import { MRow, MColumn } 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
|
+
{ 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,68 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createChart,
|
|
3
|
+
createCommandPalette,
|
|
4
|
+
createWayfindingControls,
|
|
5
|
+
} from '@getcortexlabs/mavis-core/vue'
|
|
6
|
+
import { MRow, MColumn, MBox } from './layout.js'
|
|
7
|
+
import { MText } from './MText.js'
|
|
8
|
+
import { MButton } from './MButton.js'
|
|
9
|
+
import { MLink } from './MLink.js'
|
|
10
|
+
import { MIcon } from './MIcon.js'
|
|
11
|
+
import { MBadge } from './MBadge.js'
|
|
12
|
+
import { MSeparator } from './MSeparator.js'
|
|
13
|
+
import { MSheet } from './MSheet.js'
|
|
14
|
+
import { MInput } from './MInput.js'
|
|
15
|
+
import { MSelect } from './MSelect.js'
|
|
16
|
+
import { MReveal } from './MReveal.js'
|
|
17
|
+
import { ChartPlot } from './ChartPlot.js'
|
|
18
|
+
const ui = {
|
|
19
|
+
focus: (component: unknown) => (component as { $el?: HTMLElement } | undefined)?.$el?.focus(),
|
|
20
|
+
Row: MRow,
|
|
21
|
+
Column: MColumn,
|
|
22
|
+
Box: MBox,
|
|
23
|
+
Text: MText,
|
|
24
|
+
Button: MButton,
|
|
25
|
+
Link: MLink,
|
|
26
|
+
Icon: MIcon,
|
|
27
|
+
Badge: MBadge,
|
|
28
|
+
Separator: MSeparator,
|
|
29
|
+
Sheet: MSheet,
|
|
30
|
+
Input: MInput,
|
|
31
|
+
Select: MSelect,
|
|
32
|
+
Reveal: MReveal,
|
|
33
|
+
Plot: ChartPlot,
|
|
34
|
+
}
|
|
35
|
+
export const { MNavigationRail, MBreadcrumb, MTimeline } = createWayfindingControls(ui, 'web')
|
|
36
|
+
export const MChart = createChart(ui, 'web')
|
|
37
|
+
export const MCommandPalette = createCommandPalette(
|
|
38
|
+
{
|
|
39
|
+
...ui,
|
|
40
|
+
focus: (component) => (component as { $el?: HTMLElement } | undefined)?.$el?.focus(),
|
|
41
|
+
shortcut: (callback, enabled) => {
|
|
42
|
+
const handler = (event: KeyboardEvent) => {
|
|
43
|
+
if (
|
|
44
|
+
!enabled() ||
|
|
45
|
+
event.defaultPrevented ||
|
|
46
|
+
event.repeat ||
|
|
47
|
+
event.isComposing ||
|
|
48
|
+
event.altKey ||
|
|
49
|
+
!(event.metaKey || event.ctrlKey) ||
|
|
50
|
+
event.key.toLowerCase() !== 'k'
|
|
51
|
+
)
|
|
52
|
+
return
|
|
53
|
+
const target = event.target as HTMLElement | null
|
|
54
|
+
if (
|
|
55
|
+
target?.closest(
|
|
56
|
+
'input,textarea,select,[contenteditable=""],[contenteditable="true"],dialog[open],[role="dialog"]',
|
|
57
|
+
)
|
|
58
|
+
)
|
|
59
|
+
return
|
|
60
|
+
event.preventDefault()
|
|
61
|
+
callback()
|
|
62
|
+
}
|
|
63
|
+
document.addEventListener('keydown', handler)
|
|
64
|
+
return () => document.removeEventListener('keydown', handler)
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
'web',
|
|
68
|
+
)
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { createWorkflows } from '@getcortexlabs/mavis-core/vue'
|
|
2
|
+
import { MColumn, MRow } from './layout.js'
|
|
3
|
+
import { MText } from './MText.js'
|
|
4
|
+
import { MButton } from './MButton.js'
|
|
5
|
+
|
|
6
|
+
/** Restore only a focus lost because pagination removed/disabled its own action. */
|
|
7
|
+
function preserveFocus(root: unknown, currentId: string) {
|
|
8
|
+
const element = (root as { $el?: HTMLElement } | undefined)?.$el
|
|
9
|
+
const previous = element?.ownerDocument.activeElement as HTMLButtonElement | null
|
|
10
|
+
if (!element || !previous || !element.contains(previous)) return () => {}
|
|
11
|
+
return () => {
|
|
12
|
+
const document = element.ownerDocument
|
|
13
|
+
if (
|
|
14
|
+
element.isConnected &&
|
|
15
|
+
(document.activeElement === document.body || document.activeElement === previous) &&
|
|
16
|
+
(!previous.isConnected || previous.disabled)
|
|
17
|
+
) {
|
|
18
|
+
const target = document.getElementById(currentId)
|
|
19
|
+
if (target && element.contains(target)) target.focus({ preventScroll: true })
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const { MFormGroup, MFormErrors, MSteps, MPagination } = createWorkflows(
|
|
25
|
+
{ Column: MColumn, Row: MRow, Text: MText, Button: MButton, preserveFocus },
|
|
26
|
+
'web',
|
|
27
|
+
)
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { onScopeDispose, type Ref } from 'vue'
|
|
2
|
+
import { useWebMotion } from '@rafaelaugusto/jolt/web/vue'
|
|
3
|
+
import type { WebRuntime } from '@rafaelaugusto/jolt/web'
|
|
4
|
+
import type { WebMotionContext } from './motion-context.js'
|
|
5
|
+
|
|
6
|
+
/** Jolt owns deferred insertion and KeepAlive; the presentation borrows its region's runtime. */
|
|
7
|
+
export function useConnectedMotion(
|
|
8
|
+
element: Readonly<Ref<HTMLElement | null | undefined>>,
|
|
9
|
+
context: WebMotionContext,
|
|
10
|
+
setup: (runtime: WebRuntime, target: HTMLElement) => () => void,
|
|
11
|
+
) {
|
|
12
|
+
let lease: ReturnType<WebMotionContext['acquire']> | undefined
|
|
13
|
+
const motion = useWebMotion(element, {
|
|
14
|
+
get runtime() {
|
|
15
|
+
// Evaluated only by Jolt after attachment, never during SSR or pending Suspense.
|
|
16
|
+
if (!lease && element.value) lease = context.acquire(element.value.ownerDocument)
|
|
17
|
+
return lease?.runtime
|
|
18
|
+
},
|
|
19
|
+
})
|
|
20
|
+
motion.use((_, target) => setup(lease!.runtime, target))
|
|
21
|
+
// Registered after Jolt: dispose its scopes before releasing the borrowed runtime.
|
|
22
|
+
onScopeDispose(() => lease?.release())
|
|
23
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -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
|