@getcortexlabs/mavis 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 +8 -6
- package/dist/date-format.d.ts +3 -0
- package/dist/date-format.d.ts.map +1 -0
- package/dist/date-format.js +2 -0
- package/dist/date-format.js.map +1 -0
- package/dist/native/date-format.android.d.ts +5 -0
- package/dist/native/date-format.android.d.ts.map +1 -0
- package/dist/native/date-format.android.js +39 -0
- package/dist/native/date-format.android.js.map +1 -0
- package/dist/native/date-format.d.ts +6 -0
- package/dist/native/date-format.d.ts.map +1 -0
- package/dist/native/date-format.ios.d.ts +5 -0
- package/dist/native/date-format.ios.d.ts.map +1 -0
- package/dist/native/date-format.ios.js +29 -0
- package/dist/native/date-format.ios.js.map +1 -0
- package/dist/native/date-format.js +8 -0
- package/dist/native/date-format.js.map +1 -0
- package/dist/native/motion-region.d.ts +1 -0
- package/dist/native/motion-region.d.ts.map +1 -1
- package/dist/native/motion-region.js +8 -1
- package/dist/native/motion-region.js.map +1 -1
- package/dist/native/motion-surface.d.ts +1 -1
- package/dist/native/motion-surface.d.ts.map +1 -1
- package/dist/native/motion-surface.js +17 -1
- package/dist/native/motion-surface.js.map +1 -1
- package/dist/native/number-flow-format.android.d.ts +3 -0
- package/dist/native/number-flow-format.android.d.ts.map +1 -0
- package/dist/native/number-flow-format.android.js +27 -0
- package/dist/native/number-flow-format.android.js.map +1 -0
- package/dist/native/number-flow-format.d.ts +4 -0
- package/dist/native/number-flow-format.d.ts.map +1 -0
- package/dist/native/number-flow-format.ios.d.ts +3 -0
- package/dist/native/number-flow-format.ios.d.ts.map +1 -0
- package/dist/native/number-flow-format.ios.js +24 -0
- package/dist/native/number-flow-format.ios.js.map +1 -0
- package/dist/native/number-flow-format.js +5 -0
- package/dist/native/number-flow-format.js.map +1 -0
- package/dist/native/section-scroll.d.ts +9 -0
- package/dist/native/section-scroll.d.ts.map +1 -0
- package/dist/native/section-scroll.js +69 -0
- package/dist/native/section-scroll.js.map +1 -0
- package/dist/native/segmented.d.ts.map +1 -1
- package/dist/native/segmented.js +4 -3
- package/dist/native/segmented.js.map +1 -1
- package/dist/vue/animated-number.d.ts +6 -0
- package/dist/vue/animated-number.d.ts.map +1 -0
- package/dist/vue/animated-number.js +52 -0
- package/dist/vue/animated-number.js.map +1 -0
- package/dist/vue/component-width.d.ts +7 -0
- package/dist/vue/component-width.d.ts.map +1 -0
- package/dist/vue/component-width.js +29 -0
- package/dist/vue/component-width.js.map +1 -0
- package/dist/vue/components/ChartPlot.d.ts +66 -0
- package/dist/vue/components/ChartPlot.d.ts.map +1 -0
- package/dist/vue/components/ChartPlot.js +236 -0
- package/dist/vue/components/ChartPlot.js.map +1 -0
- package/dist/vue/components/ChoiceControl.d.ts +3 -0
- package/dist/vue/components/ChoiceControl.d.ts.map +1 -1
- package/dist/vue/components/ChoiceControl.js +29 -22
- package/dist/vue/components/ChoiceControl.js.map +1 -1
- package/dist/vue/components/DateCalendar.d.ts +17 -2
- package/dist/vue/components/DateCalendar.d.ts.map +1 -1
- package/dist/vue/components/DateCalendar.js +45 -10
- package/dist/vue/components/DateCalendar.js.map +1 -1
- package/dist/vue/components/LoadingDecoration.d.ts +1 -1
- package/dist/vue/components/MAccordion.d.ts +1 -1
- package/dist/vue/components/MAlert.d.ts +3 -3
- package/dist/vue/components/MAlert.d.ts.map +1 -1
- package/dist/vue/components/MAlert.js +3 -0
- package/dist/vue/components/MAlert.js.map +1 -1
- package/dist/vue/components/MAvatar.d.ts +1 -1
- package/dist/vue/components/MAvatar.d.ts.map +1 -1
- package/dist/vue/components/MAvatar.js +5 -1
- package/dist/vue/components/MAvatar.js.map +1 -1
- package/dist/vue/components/MBadge.d.ts +1 -1
- package/dist/vue/components/MBadge.d.ts.map +1 -1
- package/dist/vue/components/MBadge.js +3 -1
- package/dist/vue/components/MBadge.js.map +1 -1
- package/dist/vue/components/MButton.d.ts +6 -6
- package/dist/vue/components/MButton.d.ts.map +1 -1
- package/dist/vue/components/MButton.js +4 -3
- package/dist/vue/components/MButton.js.map +1 -1
- package/dist/vue/components/MCard.d.ts +3 -3
- package/dist/vue/components/MCard.d.ts.map +1 -1
- package/dist/vue/components/MCard.js +4 -3
- package/dist/vue/components/MCard.js.map +1 -1
- package/dist/vue/components/MChip.d.ts +2 -2
- package/dist/vue/components/MCombobox.d.ts +3 -3
- package/dist/vue/components/MCombobox.d.ts.map +1 -1
- package/dist/vue/components/MCombobox.js +3 -1
- package/dist/vue/components/MCombobox.js.map +1 -1
- package/dist/vue/components/MDatePicker.d.ts +72 -24
- package/dist/vue/components/MDatePicker.d.ts.map +1 -1
- package/dist/vue/components/MDatePicker.js +4 -14
- package/dist/vue/components/MDatePicker.js.map +1 -1
- package/dist/vue/components/MDialog.d.ts +3 -3
- package/dist/vue/components/MEmptyState.d.ts +2 -2
- package/dist/vue/components/MEmptyState.d.ts.map +1 -1
- package/dist/vue/components/MEmptyState.js +3 -0
- package/dist/vue/components/MEmptyState.js.map +1 -1
- package/dist/vue/components/MFilePicker.d.ts +4 -4
- package/dist/vue/components/MFilePicker.d.ts.map +1 -1
- package/dist/vue/components/MFilePicker.js +3 -0
- package/dist/vue/components/MFilePicker.js.map +1 -1
- package/dist/vue/components/MGrid.d.ts +176 -0
- package/dist/vue/components/MGrid.d.ts.map +1 -0
- package/dist/vue/components/MGrid.js +56 -0
- package/dist/vue/components/MGrid.js.map +1 -0
- package/dist/vue/components/MIcon.d.ts +3 -3
- package/dist/vue/components/MImage.d.ts +47 -2
- package/dist/vue/components/MImage.d.ts.map +1 -1
- package/dist/vue/components/MImage.js +8 -1
- package/dist/vue/components/MImage.js.map +1 -1
- package/dist/vue/components/MImageCompare.d.ts +92 -0
- package/dist/vue/components/MImageCompare.d.ts.map +1 -0
- package/dist/vue/components/MImageCompare.js +138 -0
- package/dist/vue/components/MImageCompare.js.map +1 -0
- package/dist/vue/components/MImageViewer.d.ts +121 -0
- package/dist/vue/components/MImageViewer.d.ts.map +1 -0
- package/dist/vue/components/MImageViewer.js +444 -0
- package/dist/vue/components/MImageViewer.js.map +1 -0
- package/dist/vue/components/MInput.d.ts +6 -6
- package/dist/vue/components/MInput.d.ts.map +1 -1
- package/dist/vue/components/MInput.js +18 -0
- package/dist/vue/components/MInput.js.map +1 -1
- package/dist/vue/components/MLink.d.ts.map +1 -1
- package/dist/vue/components/MLink.js +6 -11
- package/dist/vue/components/MLink.js.map +1 -1
- package/dist/vue/components/MListItem.d.ts +1 -1
- package/dist/vue/components/MPopover.d.ts +106 -0
- package/dist/vue/components/MPopover.d.ts.map +1 -0
- package/dist/vue/components/MPopover.js +247 -0
- package/dist/vue/components/MPopover.js.map +1 -0
- package/dist/vue/components/MProgress.d.ts +3 -3
- package/dist/vue/components/MProgress.d.ts.map +1 -1
- package/dist/vue/components/MProgress.js +5 -2
- package/dist/vue/components/MProgress.js.map +1 -1
- package/dist/vue/components/MRangeSlider.d.ts +105 -0
- package/dist/vue/components/MRangeSlider.d.ts.map +1 -0
- package/dist/vue/components/MRangeSlider.js +134 -0
- package/dist/vue/components/MRangeSlider.js.map +1 -0
- package/dist/vue/components/MResizablePanels.d.ts +137 -0
- package/dist/vue/components/MResizablePanels.d.ts.map +1 -0
- package/dist/vue/components/MResizablePanels.js +148 -0
- package/dist/vue/components/MResizablePanels.js.map +1 -0
- package/dist/vue/components/MReveal.d.ts +11 -11
- package/dist/vue/components/MSelect.d.ts +1 -1
- package/dist/vue/components/MSheet.d.ts +14 -5
- package/dist/vue/components/MSheet.d.ts.map +1 -1
- package/dist/vue/components/MStack.d.ts +22 -11
- package/dist/vue/components/MStack.d.ts.map +1 -1
- package/dist/vue/components/MStack.js +6 -1
- package/dist/vue/components/MStack.js.map +1 -1
- package/dist/vue/components/MTabs.d.ts.map +1 -1
- package/dist/vue/components/MTabs.js +6 -5
- package/dist/vue/components/MTabs.js.map +1 -1
- package/dist/vue/components/MText.d.ts +4 -4
- package/dist/vue/components/MTimePicker.d.ts +655 -0
- package/dist/vue/components/MTimePicker.d.ts.map +1 -0
- package/dist/vue/components/MTimePicker.js +50 -0
- package/dist/vue/components/MTimePicker.js.map +1 -0
- package/dist/vue/components/MTooltip.d.ts +65 -0
- package/dist/vue/components/MTooltip.d.ts.map +1 -0
- package/dist/vue/components/MTooltip.js +35 -0
- package/dist/vue/components/MTooltip.js.map +1 -0
- package/dist/vue/components/MVirtualList.d.ts +3 -0
- package/dist/vue/components/MVirtualList.d.ts.map +1 -0
- package/dist/vue/components/MVirtualList.js +106 -0
- package/dist/vue/components/MVirtualList.js.map +1 -0
- package/dist/vue/components/MotionRows.d.ts +15 -0
- package/dist/vue/components/MotionRows.d.ts.map +1 -0
- package/dist/vue/components/MotionRows.js +12 -0
- package/dist/vue/components/MotionRows.js.map +1 -0
- package/dist/vue/components/configurator.d.ts +5 -5
- package/dist/vue/components/discovery.d.ts +282 -0
- package/dist/vue/components/discovery.d.ts.map +1 -0
- package/dist/vue/components/discovery.js +65 -0
- package/dist/vue/components/discovery.js.map +1 -0
- package/dist/vue/components/interactive.d.ts +164 -0
- package/dist/vue/components/interactive.d.ts.map +1 -0
- package/dist/vue/components/interactive.js +33 -0
- package/dist/vue/components/interactive.js.map +1 -0
- package/dist/vue/components/layout.d.ts +47 -25
- package/dist/vue/components/layout.d.ts.map +1 -1
- package/dist/vue/components/layout.js +2 -1
- package/dist/vue/components/layout.js.map +1 -1
- package/dist/vue/components/navigation.d.ts +225 -0
- package/dist/vue/components/navigation.d.ts.map +1 -0
- package/dist/vue/components/navigation.js +16 -0
- package/dist/vue/components/navigation.js.map +1 -0
- package/dist/vue/components/wayfinding.d.ts +441 -0
- package/dist/vue/components/wayfinding.d.ts.map +1 -0
- package/dist/vue/components/wayfinding.js +39 -0
- package/dist/vue/components/wayfinding.js.map +1 -0
- package/dist/vue/components/workflows.d.ts +2 -2
- package/dist/vue/index.d.ts +22 -12
- package/dist/vue/index.d.ts.map +1 -1
- package/dist/vue/index.js +47 -12
- package/dist/vue/index.js.map +1 -1
- package/dist/vue/router-navigation.d.ts +25 -0
- package/dist/vue/router-navigation.d.ts.map +1 -0
- package/dist/vue/router-navigation.js +15 -0
- package/dist/vue/router-navigation.js.map +1 -0
- package/dist/vue/services.d.ts +16 -0
- package/dist/vue/services.d.ts.map +1 -0
- package/dist/vue/services.js +23 -0
- package/dist/vue/services.js.map +1 -0
- package/package.json +16 -5
- package/src/date-format.ts +2 -0
- package/src/native/date-format.android.ts +72 -0
- package/src/native/date-format.ios.ts +54 -0
- package/src/native/date-format.ts +17 -0
- package/src/native/motion-region.ts +14 -1
- package/src/native/motion-surface.ts +24 -1
- package/src/native/number-flow-format.android.ts +61 -0
- package/src/native/number-flow-format.ios.ts +40 -0
- package/src/native/number-flow-format.ts +9 -0
- package/src/native/section-scroll.ts +81 -0
- package/src/native/segmented.ts +4 -3
- package/src/vue/animated-number.ts +57 -0
- package/src/vue/component-width.ts +34 -0
- package/src/vue/components/ChartPlot.ts +267 -0
- package/src/vue/components/ChoiceControl.ts +32 -25
- package/src/vue/components/DateCalendar.ts +50 -9
- package/src/vue/components/MAlert.ts +3 -0
- package/src/vue/components/MAvatar.ts +5 -1
- package/src/vue/components/MBadge.ts +3 -1
- package/src/vue/components/MButton.ts +4 -2
- package/src/vue/components/MCard.ts +4 -2
- package/src/vue/components/MCombobox.ts +6 -1
- package/src/vue/components/MDatePicker.ts +3 -11
- package/src/vue/components/MEmptyState.ts +3 -0
- package/src/vue/components/MFilePicker.ts +3 -0
- package/src/vue/components/MGrid.ts +100 -0
- package/src/vue/components/MImage.ts +10 -1
- package/src/vue/components/MImageCompare.ts +162 -0
- package/src/vue/components/MImageViewer.ts +489 -0
- package/src/vue/components/MInput.ts +17 -3
- package/src/vue/components/MLink.ts +12 -9
- package/src/vue/components/MPopover.ts +305 -0
- package/src/vue/components/MProgress.ts +8 -2
- package/src/vue/components/MRangeSlider.ts +157 -0
- package/src/vue/components/MResizablePanels.ts +180 -0
- package/src/vue/components/MStack.ts +6 -0
- package/src/vue/components/MTabs.ts +10 -4
- package/src/vue/components/MTimePicker.ts +57 -0
- package/src/vue/components/MTooltip.ts +39 -0
- package/src/vue/components/MVirtualList.ts +140 -0
- package/src/vue/components/MotionRows.ts +17 -0
- package/src/vue/components/discovery.ts +91 -0
- package/src/vue/components/interactive.ts +43 -0
- package/src/vue/components/layout.ts +2 -0
- package/src/vue/components/navigation.ts +19 -0
- package/src/vue/components/wayfinding.ts +48 -0
- package/src/vue/index.ts +142 -69
- package/src/vue/router-navigation.ts +39 -0
- package/src/vue/services.ts +39 -0
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
import { animate } from '@rafaelaugusto/jolt'
|
|
2
|
+
import {
|
|
3
|
+
computed,
|
|
4
|
+
defineComponent,
|
|
5
|
+
getCurrentInstance,
|
|
6
|
+
h,
|
|
7
|
+
inject,
|
|
8
|
+
nextTick,
|
|
9
|
+
onBeforeUnmount,
|
|
10
|
+
provide,
|
|
11
|
+
ref,
|
|
12
|
+
shallowRef,
|
|
13
|
+
watch,
|
|
14
|
+
type PropType,
|
|
15
|
+
type VNodeChild,
|
|
16
|
+
} from 'nativescript-vue'
|
|
17
|
+
import { isAndroid, type EventData, type View } from '@nativescript/core'
|
|
18
|
+
import {
|
|
19
|
+
placePopover,
|
|
20
|
+
resolveSpace,
|
|
21
|
+
componentMotion,
|
|
22
|
+
type PopoverCloseReason,
|
|
23
|
+
} from '@getcortexlabs/mavis-core'
|
|
24
|
+
import { popoverProps, useCachedActivity, useMavisTheme } from '@getcortexlabs/mavis-core/vue'
|
|
25
|
+
import { useLayerHost } from '../layers.js'
|
|
26
|
+
import { systemBackKey } from '../system-back.js'
|
|
27
|
+
import { contentInsets, safeAreaOf, setModal, watchBack } from '../../native/sheet'
|
|
28
|
+
import { notifyAccessibilityLayout } from '../../native/accessibility-layout'
|
|
29
|
+
import { MButton } from './MButton.js'
|
|
30
|
+
import { MColumn } from './layout.js'
|
|
31
|
+
|
|
32
|
+
export const MPopover = defineComponent({
|
|
33
|
+
name: 'MPopover',
|
|
34
|
+
inheritAttrs: false,
|
|
35
|
+
props: popoverProps,
|
|
36
|
+
emits: {
|
|
37
|
+
'update:open': (_open: boolean) => true,
|
|
38
|
+
close: (_reason: PopoverCloseReason) => true,
|
|
39
|
+
opened: () => true,
|
|
40
|
+
},
|
|
41
|
+
setup(props, { attrs, slots, emit }) {
|
|
42
|
+
const host = useLayerHost('MPopover')
|
|
43
|
+
const { theme } = useMavisTheme()
|
|
44
|
+
const active = useCachedActivity()
|
|
45
|
+
const requested = computed(() => props.open && !props.disabled && active.value)
|
|
46
|
+
const presented = ref(requested.value)
|
|
47
|
+
let presentation: View | undefined
|
|
48
|
+
let playback: ReturnType<typeof animate> | undefined
|
|
49
|
+
let revision = 0
|
|
50
|
+
watch(requested, (open) => {
|
|
51
|
+
const token = ++revision
|
|
52
|
+
if (presentation) {
|
|
53
|
+
presentation.accessibilityHidden = !open
|
|
54
|
+
setModal(presentation, open)
|
|
55
|
+
}
|
|
56
|
+
if (open) {
|
|
57
|
+
presented.value = true
|
|
58
|
+
if (presentation)
|
|
59
|
+
playback = animate(
|
|
60
|
+
presentation,
|
|
61
|
+
{ opacity: 1, y: 0 },
|
|
62
|
+
componentMotion(theme.value, 'overlay'),
|
|
63
|
+
)
|
|
64
|
+
} else if (presentation?.isLoaded && active.value) {
|
|
65
|
+
playback = animate(
|
|
66
|
+
presentation,
|
|
67
|
+
{ opacity: 0, y: 3 },
|
|
68
|
+
{ duration: theme.value.motion.exitDuration },
|
|
69
|
+
)
|
|
70
|
+
void playback.finished.then(() => {
|
|
71
|
+
if (token === revision) presented.value = false
|
|
72
|
+
})
|
|
73
|
+
} else presented.value = false
|
|
74
|
+
})
|
|
75
|
+
const anchor = shallowRef<{ nativeView: View }>()
|
|
76
|
+
const trigger = shallowRef<{ $el?: { nativeView?: View } }>()
|
|
77
|
+
const provides =
|
|
78
|
+
(getCurrentInstance() as { provides?: Record<PropertyKey, unknown> } | null)?.provides ?? {}
|
|
79
|
+
const claimBack = inject(systemBackKey, undefined)
|
|
80
|
+
let releaseBack = () => {}
|
|
81
|
+
let releaseClaim = () => {}
|
|
82
|
+
const scrollParents: View[] = []
|
|
83
|
+
function close(reason: PopoverCloseReason) {
|
|
84
|
+
if (!props.open) return
|
|
85
|
+
emit('update:open', false)
|
|
86
|
+
emit('close', reason)
|
|
87
|
+
}
|
|
88
|
+
const scrolled = () => close('program')
|
|
89
|
+
function cleanup() {
|
|
90
|
+
releaseBack()
|
|
91
|
+
releaseClaim()
|
|
92
|
+
releaseBack = releaseClaim = () => {}
|
|
93
|
+
scrollParents.splice(0).forEach((view) => view.off('scroll', scrolled))
|
|
94
|
+
}
|
|
95
|
+
watch(
|
|
96
|
+
requested,
|
|
97
|
+
(value) => {
|
|
98
|
+
cleanup()
|
|
99
|
+
if (!value) {
|
|
100
|
+
void nextTick(() => {
|
|
101
|
+
if (active.value && !props.open) trigger.value?.$el?.nativeView?.focus()
|
|
102
|
+
})
|
|
103
|
+
return
|
|
104
|
+
}
|
|
105
|
+
const back = () => close('back')
|
|
106
|
+
releaseBack = watchBack((event) => {
|
|
107
|
+
event.cancel = true
|
|
108
|
+
back()
|
|
109
|
+
})
|
|
110
|
+
releaseClaim = claimBack?.({ owns: () => requested.value, back }) ?? (() => {})
|
|
111
|
+
for (
|
|
112
|
+
let parent = anchor.value?.nativeView.parent as View | undefined;
|
|
113
|
+
parent;
|
|
114
|
+
parent = parent.parent as View | undefined
|
|
115
|
+
) {
|
|
116
|
+
parent.on('scroll', scrolled)
|
|
117
|
+
scrollParents.push(parent)
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
{ immediate: true },
|
|
121
|
+
)
|
|
122
|
+
watch(
|
|
123
|
+
() => active.value && !props.disabled,
|
|
124
|
+
(value) => {
|
|
125
|
+
if (!value && props.open) close('program')
|
|
126
|
+
},
|
|
127
|
+
)
|
|
128
|
+
const Layer = defineComponent({
|
|
129
|
+
name: 'MPopoverLayer',
|
|
130
|
+
props: { content: { type: Function as PropType<() => VNodeChild>, required: true } },
|
|
131
|
+
setup(layer) {
|
|
132
|
+
const seen = new Set<PropertyKey>()
|
|
133
|
+
for (
|
|
134
|
+
let source: object | null = provides;
|
|
135
|
+
source && source !== Object.prototype;
|
|
136
|
+
source = Object.getPrototypeOf(source)
|
|
137
|
+
) {
|
|
138
|
+
for (const key of Reflect.ownKeys(source)) {
|
|
139
|
+
if (seen.has(key)) continue
|
|
140
|
+
seen.add(key)
|
|
141
|
+
provide(key as string | symbol, (source as Record<PropertyKey, unknown>)[key])
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
const root = shallowRef<View>()
|
|
145
|
+
const panel = shallowRef<View>()
|
|
146
|
+
const position = ref({ x: 8, y: 8, width: props.width, height: 400 })
|
|
147
|
+
function place() {
|
|
148
|
+
const container = root.value
|
|
149
|
+
const target = anchor.value?.nativeView
|
|
150
|
+
const surface = panel.value
|
|
151
|
+
if (!container?.isLoaded || !target?.isLoaded || !surface) return
|
|
152
|
+
const location = target.getLocationRelativeTo(container)
|
|
153
|
+
if (!location) {
|
|
154
|
+
close('program')
|
|
155
|
+
return
|
|
156
|
+
}
|
|
157
|
+
const size = container.getActualSize()
|
|
158
|
+
if (!size.width || !size.height) return
|
|
159
|
+
const inset = contentInsets(container)
|
|
160
|
+
const safe = safeAreaOf(container)
|
|
161
|
+
const viewport = {
|
|
162
|
+
x: inset.left,
|
|
163
|
+
y: safe.top,
|
|
164
|
+
width: size.width - inset.left - inset.right,
|
|
165
|
+
height: size.height - safe.top - safe.bottom,
|
|
166
|
+
}
|
|
167
|
+
const width = Math.max(1, Math.min(props.width, viewport.width - 16))
|
|
168
|
+
const height = Math.max(1, viewport.height - 16)
|
|
169
|
+
const measured = surface.getActualSize()
|
|
170
|
+
const rtl = isAndroid
|
|
171
|
+
? target.android?.getLayoutDirection?.() === 1
|
|
172
|
+
: target.ios?.effectiveUserInterfaceLayoutDirection === 1
|
|
173
|
+
const next = {
|
|
174
|
+
...placePopover(
|
|
175
|
+
{ ...location, ...target.getActualSize() },
|
|
176
|
+
{ width, height: Math.min(measured.height, height) },
|
|
177
|
+
viewport,
|
|
178
|
+
props.placement,
|
|
179
|
+
rtl,
|
|
180
|
+
),
|
|
181
|
+
width,
|
|
182
|
+
height,
|
|
183
|
+
}
|
|
184
|
+
if (JSON.stringify(next) !== JSON.stringify(position.value)) position.value = next
|
|
185
|
+
}
|
|
186
|
+
watch(
|
|
187
|
+
() => [props.width, props.placement],
|
|
188
|
+
() => void nextTick(place),
|
|
189
|
+
)
|
|
190
|
+
return () =>
|
|
191
|
+
h(
|
|
192
|
+
'GridLayout',
|
|
193
|
+
{
|
|
194
|
+
onLoaded: (event: EventData) => {
|
|
195
|
+
root.value = event.object as View
|
|
196
|
+
place()
|
|
197
|
+
},
|
|
198
|
+
onLayoutChanged: place,
|
|
199
|
+
},
|
|
200
|
+
[
|
|
201
|
+
h('MavisBox', {
|
|
202
|
+
backgroundColor: 'transparent',
|
|
203
|
+
accessible: false,
|
|
204
|
+
onTap: () => close('outside'),
|
|
205
|
+
}),
|
|
206
|
+
h('AbsoluteLayout', { isPassThroughParentEnabled: true }, [
|
|
207
|
+
h(
|
|
208
|
+
'ScrollView',
|
|
209
|
+
{
|
|
210
|
+
left: position.value.x,
|
|
211
|
+
top: position.value.y,
|
|
212
|
+
width: position.value.width,
|
|
213
|
+
maxHeight: position.value.height,
|
|
214
|
+
id: props.id,
|
|
215
|
+
isUserInteractionEnabled: requested.value,
|
|
216
|
+
accessibilityHidden: !requested.value,
|
|
217
|
+
accessibilityLabel: props.label,
|
|
218
|
+
backgroundColor: theme.value.colors.surface,
|
|
219
|
+
borderColor: theme.value.colors.border,
|
|
220
|
+
borderWidth: 1,
|
|
221
|
+
borderRadius: theme.value.radius.md,
|
|
222
|
+
onLoaded: (event: EventData) => {
|
|
223
|
+
const view = event.object as View
|
|
224
|
+
panel.value = view
|
|
225
|
+
presentation = view
|
|
226
|
+
if (!requested.value) {
|
|
227
|
+
presented.value = false
|
|
228
|
+
return
|
|
229
|
+
}
|
|
230
|
+
playback = animate(
|
|
231
|
+
view,
|
|
232
|
+
{ opacity: [0, 1], y: [6, 0] },
|
|
233
|
+
componentMotion(theme.value, 'overlay'),
|
|
234
|
+
)
|
|
235
|
+
setModal(view, true)
|
|
236
|
+
void nextTick(() => {
|
|
237
|
+
if (!view.isLoaded || !requested.value) return
|
|
238
|
+
place()
|
|
239
|
+
if (isAndroid) view.android?.performAccessibilityAction(64, null)
|
|
240
|
+
else notifyAccessibilityLayout(view)
|
|
241
|
+
emit('opened')
|
|
242
|
+
})
|
|
243
|
+
},
|
|
244
|
+
onLayoutChanged: place,
|
|
245
|
+
onUnloaded: () => {
|
|
246
|
+
if (panel.value) setModal(panel.value, false)
|
|
247
|
+
playback?.stop()
|
|
248
|
+
presentation = undefined
|
|
249
|
+
panel.value = undefined
|
|
250
|
+
},
|
|
251
|
+
},
|
|
252
|
+
[
|
|
253
|
+
h(
|
|
254
|
+
MColumn,
|
|
255
|
+
{ padding: resolveSpace(theme.value, props.padding), gap: 'sm' },
|
|
256
|
+
() => layer.content(),
|
|
257
|
+
),
|
|
258
|
+
],
|
|
259
|
+
),
|
|
260
|
+
]),
|
|
261
|
+
],
|
|
262
|
+
)
|
|
263
|
+
},
|
|
264
|
+
})
|
|
265
|
+
const remove = host.add({
|
|
266
|
+
component: Layer,
|
|
267
|
+
props: { content: () => slots.default?.({ close: () => close('program') }) },
|
|
268
|
+
presented,
|
|
269
|
+
})
|
|
270
|
+
onBeforeUnmount(() => {
|
|
271
|
+
revision++
|
|
272
|
+
playback?.stop()
|
|
273
|
+
cleanup()
|
|
274
|
+
remove()
|
|
275
|
+
})
|
|
276
|
+
return () => {
|
|
277
|
+
if (!props.label.trim() || !props.triggerLabel.trim())
|
|
278
|
+
throw new TypeError('Popovers require panel and trigger labels.')
|
|
279
|
+
if (!Number.isFinite(props.width) || props.width <= 0)
|
|
280
|
+
throw new RangeError('Popover width must be positive and finite.')
|
|
281
|
+
return h(
|
|
282
|
+
'GridLayout',
|
|
283
|
+
{
|
|
284
|
+
rows: 'auto',
|
|
285
|
+
columns: 'auto',
|
|
286
|
+
...attrs,
|
|
287
|
+
ref: anchor,
|
|
288
|
+
horizontalAlignment: 'left',
|
|
289
|
+
verticalAlignment: 'top',
|
|
290
|
+
},
|
|
291
|
+
[
|
|
292
|
+
h(MButton, {
|
|
293
|
+
ref: trigger,
|
|
294
|
+
text: props.triggerLabel,
|
|
295
|
+
icon: props.icon,
|
|
296
|
+
variant: props.variant,
|
|
297
|
+
disabled: props.disabled,
|
|
298
|
+
accessibilityState: props.open ? 'expanded' : '',
|
|
299
|
+
onClick: () => (props.open ? close('trigger') : emit('update:open', true)),
|
|
300
|
+
}),
|
|
301
|
+
],
|
|
302
|
+
)
|
|
303
|
+
}
|
|
304
|
+
},
|
|
305
|
+
})
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineComponent, h, mergeProps, onBeforeUnmount, watch } from 'nativescript-vue'
|
|
2
2
|
import type { EventData, View } from '@nativescript/core'
|
|
3
|
-
import { progressProps, useMavisTheme } from '@getcortexlabs/mavis-core/vue'
|
|
3
|
+
import { progressProps, useMavisTheme, useComponentState } from '@getcortexlabs/mavis-core/vue'
|
|
4
4
|
import {
|
|
5
5
|
progressSizes,
|
|
6
6
|
progressMotion,
|
|
@@ -17,6 +17,10 @@ export const MProgress = defineComponent({
|
|
|
17
17
|
props: progressProps,
|
|
18
18
|
setup(props, { attrs }) {
|
|
19
19
|
const { theme } = useMavisTheme()
|
|
20
|
+
const fillState = useComponentState(
|
|
21
|
+
() => ({ scaleX: Math.max(0.0001, progressState(props.value, props.max).ratio) }),
|
|
22
|
+
'data',
|
|
23
|
+
)
|
|
20
24
|
const nativeAttrs = useNativeViewAttrs(props)
|
|
21
25
|
let track: View | undefined
|
|
22
26
|
let fill: View | undefined
|
|
@@ -70,7 +74,9 @@ export const MProgress = defineComponent({
|
|
|
70
74
|
{
|
|
71
75
|
default: () =>
|
|
72
76
|
h(MBox, {
|
|
73
|
-
width:
|
|
77
|
+
width: props.indeterminate ? `${fraction * 100}%` : '100%',
|
|
78
|
+
originX: 0,
|
|
79
|
+
motionSurface: props.indeterminate ? undefined : fillState,
|
|
74
80
|
height: progressSizes[props.size],
|
|
75
81
|
radius: 'full',
|
|
76
82
|
horizontalAlignment: 'left',
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { computed, defineComponent, h, markRaw, mergeProps, ref, watch } from 'nativescript-vue'
|
|
2
|
+
import type { EventData, PanGestureEventData, View } from '@nativescript/core'
|
|
3
|
+
import { moveRange, rangeValue, type RangeValue } from '@getcortexlabs/mavis-core'
|
|
4
|
+
import { createMotionSurface } from '@getcortexlabs/mavis-core/experimental'
|
|
5
|
+
import { rangeSliderProps, useMavisTheme, useComponentState } from '@getcortexlabs/mavis-core/vue'
|
|
6
|
+
import { MColumn, MRow, MBox } from './layout.js'
|
|
7
|
+
import { MText } from './MText.js'
|
|
8
|
+
import { MNumberInput } from './configurator.js'
|
|
9
|
+
|
|
10
|
+
/** Large touch handles plus labelled native editors for precise and assistive input. */
|
|
11
|
+
export const MRangeSlider = defineComponent({
|
|
12
|
+
name: 'MRangeSlider',
|
|
13
|
+
inheritAttrs: false,
|
|
14
|
+
props: rangeSliderProps,
|
|
15
|
+
emits: { 'update:modelValue': (_value: RangeValue) => true },
|
|
16
|
+
setup(props, { attrs, emit }) {
|
|
17
|
+
const { theme } = useMavisTheme()
|
|
18
|
+
const width = ref(0)
|
|
19
|
+
const surfaces = [markRaw(createMotionSurface()), markRaw(createMotionSurface())]
|
|
20
|
+
const pair = computed(() => rangeValue(props.modelValue, props.min, props.max, props.step))
|
|
21
|
+
const active = ref<number | null>(null)
|
|
22
|
+
const halos = [0, 1].map((index) =>
|
|
23
|
+
useComponentState(
|
|
24
|
+
() => ({
|
|
25
|
+
opacity: active.value === index ? 0.18 : 0,
|
|
26
|
+
scale: active.value === index ? 1 : 0.65,
|
|
27
|
+
}),
|
|
28
|
+
'feedback',
|
|
29
|
+
),
|
|
30
|
+
)
|
|
31
|
+
watch(
|
|
32
|
+
() => props.disabled || props.readonly,
|
|
33
|
+
(blocked) => {
|
|
34
|
+
if (blocked) {
|
|
35
|
+
active.value = null
|
|
36
|
+
for (const surface of surfaces) if (surface.available) surface.set({ scale: 1 })
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
)
|
|
40
|
+
const origins = [0, 0]
|
|
41
|
+
const format = (value: number) => props.formatValue?.(value) ?? String(value)
|
|
42
|
+
function update(thumb: 0 | 1, value: number | null) {
|
|
43
|
+
if (value === null || props.disabled || props.readonly) return
|
|
44
|
+
const next = moveRange(pair.value, thumb, value, props.min, props.max, props.step)
|
|
45
|
+
if (next[thumb] !== pair.value[thumb]) emit('update:modelValue', next)
|
|
46
|
+
}
|
|
47
|
+
return () => {
|
|
48
|
+
const travel = Math.max(0, width.value - 48)
|
|
49
|
+
const position = (value: number) => ((value - props.min) / (props.max - props.min)) * travel
|
|
50
|
+
return h(MColumn, mergeProps({ id: props.id, gap: 'sm' }, attrs), () => [
|
|
51
|
+
h(MRow, { justify: 'between', gap: 'md', wrap: true }, () => [
|
|
52
|
+
h(MText, { text: props.label, weight: '600' }),
|
|
53
|
+
h(MText, { text: `${format(pair.value[0])} – ${format(pair.value[1])}`, tone: 'muted' }),
|
|
54
|
+
]),
|
|
55
|
+
h(
|
|
56
|
+
'AbsoluteLayout',
|
|
57
|
+
{
|
|
58
|
+
height: 56,
|
|
59
|
+
onLayoutChanged: (event: EventData) => {
|
|
60
|
+
width.value = (event.object as View).getActualSize().width
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
[
|
|
64
|
+
h('StackLayout', {
|
|
65
|
+
left: 24,
|
|
66
|
+
top: 25,
|
|
67
|
+
width: travel,
|
|
68
|
+
height: 6,
|
|
69
|
+
borderRadius: 3,
|
|
70
|
+
backgroundColor: theme.value.colors.border,
|
|
71
|
+
accessibilityHidden: true,
|
|
72
|
+
}),
|
|
73
|
+
h('StackLayout', {
|
|
74
|
+
left: 24 + position(pair.value[0]),
|
|
75
|
+
top: 25,
|
|
76
|
+
width: position(pair.value[1]) - position(pair.value[0]),
|
|
77
|
+
height: 6,
|
|
78
|
+
borderRadius: 3,
|
|
79
|
+
backgroundColor: theme.value.colors.primary,
|
|
80
|
+
accessibilityHidden: true,
|
|
81
|
+
}),
|
|
82
|
+
...([0, 1] as const).map((thumb) =>
|
|
83
|
+
h(
|
|
84
|
+
MBox,
|
|
85
|
+
{
|
|
86
|
+
key: thumb,
|
|
87
|
+
left: position(pair.value[thumb]),
|
|
88
|
+
top: 4,
|
|
89
|
+
width: 48,
|
|
90
|
+
height: 48,
|
|
91
|
+
accessibilityHidden: true,
|
|
92
|
+
onPan: (event: PanGestureEventData) => {
|
|
93
|
+
if (props.disabled || props.readonly || !travel) return
|
|
94
|
+
const motion = surfaces[thumb]!
|
|
95
|
+
if (event.state === 1) {
|
|
96
|
+
active.value = thumb
|
|
97
|
+
origins[thumb] = pair.value[thumb]
|
|
98
|
+
if (motion.available) motion.animate({ scale: 1.15 }, { duration: 120 })
|
|
99
|
+
}
|
|
100
|
+
if (event.state === 2)
|
|
101
|
+
update(
|
|
102
|
+
thumb,
|
|
103
|
+
origins[thumb]! + (event.deltaX / travel) * (props.max - props.min),
|
|
104
|
+
)
|
|
105
|
+
if (event.state === 3 || event.state === 4) {
|
|
106
|
+
active.value = null
|
|
107
|
+
if (motion.available)
|
|
108
|
+
motion.animate(
|
|
109
|
+
{ scale: 1 },
|
|
110
|
+
{ type: 'spring', duration: 180, bounce: 0.15 },
|
|
111
|
+
)
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
() => [
|
|
116
|
+
h(MBox, {
|
|
117
|
+
motionSurface: halos[thumb],
|
|
118
|
+
width: 42,
|
|
119
|
+
height: 42,
|
|
120
|
+
radius: 'full',
|
|
121
|
+
backgroundColor: theme.value.colors.primary,
|
|
122
|
+
horizontalAlignment: 'center',
|
|
123
|
+
verticalAlignment: 'middle',
|
|
124
|
+
accessibilityHidden: true,
|
|
125
|
+
}),
|
|
126
|
+
h(MBox, {
|
|
127
|
+
motionSurface: surfaces[thumb],
|
|
128
|
+
width: 26,
|
|
129
|
+
height: 26,
|
|
130
|
+
radius: 'full',
|
|
131
|
+
backgroundColor: theme.value.colors.primary,
|
|
132
|
+
horizontalAlignment: 'center',
|
|
133
|
+
verticalAlignment: 'middle',
|
|
134
|
+
}),
|
|
135
|
+
],
|
|
136
|
+
),
|
|
137
|
+
),
|
|
138
|
+
],
|
|
139
|
+
),
|
|
140
|
+
h(MColumn, { gap: 'md' }, () =>
|
|
141
|
+
([0, 1] as const).map((thumb) =>
|
|
142
|
+
h(MNumberInput, {
|
|
143
|
+
label: thumb === 0 ? props.lowerLabel : props.upperLabel,
|
|
144
|
+
modelValue: pair.value[thumb],
|
|
145
|
+
min: thumb === 0 ? props.min : pair.value[0],
|
|
146
|
+
max: thumb === 0 ? pair.value[1] : props.max,
|
|
147
|
+
step: props.step,
|
|
148
|
+
disabled: props.disabled,
|
|
149
|
+
readonly: props.readonly,
|
|
150
|
+
'onUpdate:modelValue': (value: number | null) => update(thumb, value),
|
|
151
|
+
}),
|
|
152
|
+
),
|
|
153
|
+
),
|
|
154
|
+
])
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
})
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { computed, defineComponent, h, mergeProps, ref, watch } from 'nativescript-vue'
|
|
2
|
+
import type { EventData, PanGestureEventData, View } from '@nativescript/core'
|
|
3
|
+
import { panelValue, positiveSize } from '@getcortexlabs/mavis-core'
|
|
4
|
+
import { resizablePanelsProps, usePartition, useMavisTheme } from '@getcortexlabs/mavis-core/vue'
|
|
5
|
+
import { useAnimatedNumber } from '../animated-number.js'
|
|
6
|
+
import { MColumn, MRow, MBox } from './layout.js'
|
|
7
|
+
import { MSlider } from './MSlider.js'
|
|
8
|
+
import { MButton } from './MButton.js'
|
|
9
|
+
|
|
10
|
+
export const MResizablePanels = defineComponent({
|
|
11
|
+
name: 'MResizablePanels',
|
|
12
|
+
inheritAttrs: false,
|
|
13
|
+
props: resizablePanelsProps,
|
|
14
|
+
emits: { 'update:modelValue': (_value: number) => true, resize: (_value: number) => true },
|
|
15
|
+
setup(props, { attrs, slots, emit }) {
|
|
16
|
+
const { theme } = useMavisTheme()
|
|
17
|
+
const size = ref({ width: 0, height: 0 })
|
|
18
|
+
const value = computed(() =>
|
|
19
|
+
panelValue(props.modelValue, props.min, props.max, props.collapsible),
|
|
20
|
+
)
|
|
21
|
+
let remembered = Math.max(props.min, 40),
|
|
22
|
+
origin = 0
|
|
23
|
+
const state = usePartition(
|
|
24
|
+
() => value.value,
|
|
25
|
+
() => ({
|
|
26
|
+
min: props.collapsible ? 0 : props.min,
|
|
27
|
+
max: props.max,
|
|
28
|
+
step: props.step,
|
|
29
|
+
disabled: props.disabled,
|
|
30
|
+
}),
|
|
31
|
+
(next) =>
|
|
32
|
+
emit('update:modelValue', next === 0 && props.collapsible ? 0 : Math.max(props.min, next)),
|
|
33
|
+
)
|
|
34
|
+
const motion = useAnimatedNumber(
|
|
35
|
+
() => value.value,
|
|
36
|
+
() => state.dragging.value,
|
|
37
|
+
)
|
|
38
|
+
const vertical = () => props.orientation === 'vertical'
|
|
39
|
+
function finish() {
|
|
40
|
+
state.end()
|
|
41
|
+
const closest = props.snap
|
|
42
|
+
.filter((p) => Number.isFinite(p) && p >= props.min && p <= props.max)
|
|
43
|
+
.sort((a, b) => Math.abs(a - value.value) - Math.abs(b - value.value))[0]
|
|
44
|
+
if (closest !== undefined && Math.abs(closest - value.value) <= 3)
|
|
45
|
+
emit('update:modelValue', closest)
|
|
46
|
+
emit(
|
|
47
|
+
'resize',
|
|
48
|
+
closest !== undefined && Math.abs(closest - value.value) <= 3 ? closest : value.value,
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
|
+
function toggle() {
|
|
52
|
+
if (props.disabled || !props.collapsible) return
|
|
53
|
+
if (value.value) {
|
|
54
|
+
remembered = value.value
|
|
55
|
+
emit('update:modelValue', 0)
|
|
56
|
+
} else emit('update:modelValue', Math.max(props.min, Math.min(props.max, remembered)))
|
|
57
|
+
}
|
|
58
|
+
watch(
|
|
59
|
+
() => [props.orientation, props.direction],
|
|
60
|
+
() => state.cancel(),
|
|
61
|
+
)
|
|
62
|
+
return () => {
|
|
63
|
+
const ratio = Math.max(0, Math.min(100, motion.shown.value)),
|
|
64
|
+
flipped = !vertical() && props.direction === 'rtl'
|
|
65
|
+
const first = flipped ? 100 - ratio : ratio,
|
|
66
|
+
last = flipped ? ratio : 100 - ratio
|
|
67
|
+
const tracks = `${first}*,44,${last}*`
|
|
68
|
+
return h(MColumn, mergeProps(attrs, { gap: 'sm' }), () => [
|
|
69
|
+
h(
|
|
70
|
+
'GridLayout',
|
|
71
|
+
{
|
|
72
|
+
onLoaded: motion.onLoaded,
|
|
73
|
+
onUnloaded: motion.onUnloaded,
|
|
74
|
+
height: positiveSize(props.height, 'height'),
|
|
75
|
+
columns: vertical() ? '*' : tracks,
|
|
76
|
+
rows: vertical() ? tracks : '*',
|
|
77
|
+
clipToBounds: true,
|
|
78
|
+
borderRadius: 16,
|
|
79
|
+
borderWidth: 1,
|
|
80
|
+
borderColor: theme.value.colors.border,
|
|
81
|
+
onLayoutChanged: (event: EventData) => {
|
|
82
|
+
const next = (event.object as View).getActualSize()
|
|
83
|
+
if (next.width !== size.value.width || next.height !== size.value.height) {
|
|
84
|
+
state.cancel()
|
|
85
|
+
size.value = next
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
[
|
|
90
|
+
h(
|
|
91
|
+
'ScrollView',
|
|
92
|
+
{
|
|
93
|
+
row: vertical() ? 0 : 0,
|
|
94
|
+
col: flipped ? 2 : 0,
|
|
95
|
+
visibility: value.value === 0 ? 'hidden' : 'visible',
|
|
96
|
+
accessibilityLabel: props.primaryLabel,
|
|
97
|
+
},
|
|
98
|
+
[h(MColumn, {}, () => slots.primary?.())],
|
|
99
|
+
),
|
|
100
|
+
h(
|
|
101
|
+
MBox,
|
|
102
|
+
{
|
|
103
|
+
row: vertical() ? 1 : 0,
|
|
104
|
+
col: vertical() ? 0 : 1,
|
|
105
|
+
backgroundColor: theme.value.colors.elevated,
|
|
106
|
+
accessibilityHidden: true,
|
|
107
|
+
onPan: (event: PanGestureEventData) => {
|
|
108
|
+
const travel = (vertical() ? size.value.height : size.value.width) - 44
|
|
109
|
+
if (props.disabled || travel <= 0) return
|
|
110
|
+
if (event.state === 1) {
|
|
111
|
+
if (state.begin()) origin = value.value
|
|
112
|
+
}
|
|
113
|
+
if (event.state === 2 && state.dragging.value)
|
|
114
|
+
state.update(
|
|
115
|
+
origin +
|
|
116
|
+
((vertical() ? event.deltaY : event.deltaX * (flipped ? -1 : 1)) / travel) *
|
|
117
|
+
100,
|
|
118
|
+
)
|
|
119
|
+
if (event.state === 3 && state.dragging.value) finish()
|
|
120
|
+
if (event.state === 4) state.cancel()
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
() =>
|
|
124
|
+
h(MBox, {
|
|
125
|
+
width: vertical() ? 28 : 4,
|
|
126
|
+
height: vertical() ? 4 : 28,
|
|
127
|
+
radius: 'full',
|
|
128
|
+
backgroundColor: theme.value.colors.muted,
|
|
129
|
+
horizontalAlignment: 'center',
|
|
130
|
+
verticalAlignment: 'middle',
|
|
131
|
+
}),
|
|
132
|
+
),
|
|
133
|
+
h(
|
|
134
|
+
'ScrollView',
|
|
135
|
+
{
|
|
136
|
+
row: vertical() ? 2 : 0,
|
|
137
|
+
col: vertical() ? 0 : flipped ? 0 : 2,
|
|
138
|
+
accessibilityLabel: props.secondaryLabel,
|
|
139
|
+
},
|
|
140
|
+
[h(MColumn, {}, () => slots.secondary?.())],
|
|
141
|
+
),
|
|
142
|
+
],
|
|
143
|
+
),
|
|
144
|
+
h(MSlider, {
|
|
145
|
+
label: props.label,
|
|
146
|
+
modelValue: value.value,
|
|
147
|
+
min: props.collapsible ? 0 : props.min,
|
|
148
|
+
max: props.max,
|
|
149
|
+
step: props.step,
|
|
150
|
+
disabled: props.disabled,
|
|
151
|
+
'onUpdate:modelValue': state.update,
|
|
152
|
+
}),
|
|
153
|
+
h(MRow, { gap: 'sm' }, () => [
|
|
154
|
+
h(MButton, {
|
|
155
|
+
text: '−',
|
|
156
|
+
variant: 'ghost',
|
|
157
|
+
accessibilityLabel: `${props.primaryLabel}: −${props.step}%`,
|
|
158
|
+
disabled: props.disabled || value.value <= props.min,
|
|
159
|
+
onClick: () => state.update(value.value - props.step),
|
|
160
|
+
}),
|
|
161
|
+
h(MButton, {
|
|
162
|
+
text: '+',
|
|
163
|
+
variant: 'ghost',
|
|
164
|
+
accessibilityLabel: `${props.primaryLabel}: +${props.step}%`,
|
|
165
|
+
disabled: props.disabled || value.value >= props.max,
|
|
166
|
+
onClick: () => state.update(value.value + props.step),
|
|
167
|
+
}),
|
|
168
|
+
props.collapsible
|
|
169
|
+
? h(MButton, {
|
|
170
|
+
text: value.value ? props.collapseLabel : props.expandLabel,
|
|
171
|
+
variant: 'ghost',
|
|
172
|
+
disabled: props.disabled,
|
|
173
|
+
onClick: toggle,
|
|
174
|
+
})
|
|
175
|
+
: null,
|
|
176
|
+
]),
|
|
177
|
+
])
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
})
|