@getcortexlabs/mavis-web 0.1.0-alpha.10 → 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 +4 -4
- 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/DateCalendar.d.ts +16 -1
- package/dist/components/DateCalendar.d.ts.map +1 -1
- package/dist/components/DateCalendar.js +17 -8
- package/dist/components/DateCalendar.js.map +1 -1
- package/dist/components/MAccordion.d.ts +1 -1
- package/dist/components/MChip.d.ts +1 -1
- package/dist/components/MCombobox.d.ts +3 -3
- package/dist/components/MDatePicker.d.ts +16 -16
- package/dist/components/MDialog.d.ts +3 -3
- package/dist/components/MEmptyState.d.ts +1 -1
- package/dist/components/MFilePicker.d.ts +2 -2
- package/dist/components/MImage.d.ts +1 -1
- package/dist/components/MInput.d.ts +1 -1
- package/dist/components/MListItem.d.ts +1 -1
- 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 +8 -8
- package/dist/components/MSelect.d.ts +2 -2
- package/dist/components/MSheet.d.ts +4 -4
- package/dist/components/MStack.d.ts +8 -8
- package/dist/components/MText.d.ts +1 -1
- package/dist/components/MTimePicker.d.ts +4 -4
- 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/configurator.d.ts +2 -2
- 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 +24 -24
- package/dist/components/navigation.d.ts +1 -1
- 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 +2 -2
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/base.css +117 -0
- package/src/components/ChartPlot.ts +139 -0
- package/src/components/DateCalendar.ts +20 -8
- package/src/components/MRangeSlider.ts +115 -0
- package/src/components/MTooltip.ts +293 -0
- package/src/components/discovery.ts +163 -0
- package/src/components/wayfinding.ts +68 -0
- package/src/index.ts +34 -0
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defineComponent,
|
|
3
|
+
h,
|
|
4
|
+
markRaw,
|
|
5
|
+
mergeProps,
|
|
6
|
+
nextTick,
|
|
7
|
+
onActivated,
|
|
8
|
+
onBeforeUnmount,
|
|
9
|
+
onDeactivated,
|
|
10
|
+
onMounted,
|
|
11
|
+
onScopeDispose,
|
|
12
|
+
ref,
|
|
13
|
+
shallowRef,
|
|
14
|
+
Teleport,
|
|
15
|
+
useId,
|
|
16
|
+
watch,
|
|
17
|
+
} from 'vue'
|
|
18
|
+
import { placePopover } from '@getcortexlabs/mavis-core'
|
|
19
|
+
import { createMotionSurface } from '@getcortexlabs/mavis-core/experimental'
|
|
20
|
+
import { tooltipProps, useMavisTheme } from '@getcortexlabs/mavis-core/vue'
|
|
21
|
+
import { MButton } from './MButton.js'
|
|
22
|
+
import { MBox } from './layout.js'
|
|
23
|
+
|
|
24
|
+
/** Non-interactive help. Focus remains on the trigger; touch users can toggle it. */
|
|
25
|
+
export const MTooltip = defineComponent({
|
|
26
|
+
name: 'MTooltip',
|
|
27
|
+
inheritAttrs: false,
|
|
28
|
+
props: tooltipProps,
|
|
29
|
+
setup(props, { attrs }) {
|
|
30
|
+
const { theme } = useMavisTheme()
|
|
31
|
+
const id = `m-tooltip-${useId()}`
|
|
32
|
+
const trigger = ref<{ $el?: HTMLElement }>()
|
|
33
|
+
const panel = ref<HTMLElement>()
|
|
34
|
+
const host = shallowRef<HTMLElement>()
|
|
35
|
+
const open = ref(false),
|
|
36
|
+
ready = ref(false)
|
|
37
|
+
const position = ref({ x: 0, y: 0 })
|
|
38
|
+
let hovered = false,
|
|
39
|
+
focused = false,
|
|
40
|
+
pinned = false,
|
|
41
|
+
suppressed = false
|
|
42
|
+
let timer: ReturnType<typeof setTimeout> | undefined
|
|
43
|
+
let observer: ResizeObserver | undefined
|
|
44
|
+
let frame = 0,
|
|
45
|
+
revision = 0
|
|
46
|
+
let active = false
|
|
47
|
+
const motion = markRaw(createMotionSurface())
|
|
48
|
+
onScopeDispose(
|
|
49
|
+
motion.use(() => {
|
|
50
|
+
if (open.value)
|
|
51
|
+
motion.animate(
|
|
52
|
+
{ opacity: [0, 1], y: [3, 0] },
|
|
53
|
+
{ duration: theme.value.motion.enterDuration },
|
|
54
|
+
)
|
|
55
|
+
}),
|
|
56
|
+
)
|
|
57
|
+
function clearTimer() {
|
|
58
|
+
if (timer) clearTimeout(timer)
|
|
59
|
+
timer = undefined
|
|
60
|
+
}
|
|
61
|
+
function close() {
|
|
62
|
+
clearTimer()
|
|
63
|
+
open.value = false
|
|
64
|
+
pinned = false
|
|
65
|
+
}
|
|
66
|
+
function place() {
|
|
67
|
+
frame = 0
|
|
68
|
+
const anchor = trigger.value?.$el,
|
|
69
|
+
popup = panel.value
|
|
70
|
+
if (!active || !open.value || !anchor || !popup) return
|
|
71
|
+
const rect = anchor.getBoundingClientRect()
|
|
72
|
+
if (!anchor.isConnected || !rect.width || !rect.height) {
|
|
73
|
+
close()
|
|
74
|
+
return
|
|
75
|
+
}
|
|
76
|
+
const viewport = window.visualViewport
|
|
77
|
+
position.value = placePopover(
|
|
78
|
+
rect,
|
|
79
|
+
popup.getBoundingClientRect(),
|
|
80
|
+
{
|
|
81
|
+
x: viewport?.offsetLeft ?? 0,
|
|
82
|
+
y: viewport?.offsetTop ?? 0,
|
|
83
|
+
width: viewport?.width ?? window.innerWidth,
|
|
84
|
+
height: viewport?.height ?? window.innerHeight,
|
|
85
|
+
},
|
|
86
|
+
props.placement,
|
|
87
|
+
getComputedStyle(anchor).direction === 'rtl',
|
|
88
|
+
)
|
|
89
|
+
ready.value = true
|
|
90
|
+
}
|
|
91
|
+
const schedule = () => {
|
|
92
|
+
if (open.value && !frame) frame = requestAnimationFrame(place)
|
|
93
|
+
}
|
|
94
|
+
const escape = (event: KeyboardEvent) => {
|
|
95
|
+
if (open.value && event.key === 'Escape') {
|
|
96
|
+
event.preventDefault()
|
|
97
|
+
event.stopPropagation()
|
|
98
|
+
suppressed = true
|
|
99
|
+
close()
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
const outside = (event: PointerEvent) => {
|
|
103
|
+
if (
|
|
104
|
+
!trigger.value?.$el?.contains(event.target as Node) &&
|
|
105
|
+
!panel.value?.contains(event.target as Node)
|
|
106
|
+
)
|
|
107
|
+
close()
|
|
108
|
+
}
|
|
109
|
+
function detach() {
|
|
110
|
+
revision++
|
|
111
|
+
observer?.disconnect()
|
|
112
|
+
observer = undefined
|
|
113
|
+
if (typeof window === 'undefined') return
|
|
114
|
+
if (frame) cancelAnimationFrame(frame)
|
|
115
|
+
frame = 0
|
|
116
|
+
window.removeEventListener('resize', schedule)
|
|
117
|
+
document.removeEventListener('scroll', schedule, true)
|
|
118
|
+
document.removeEventListener('keydown', escape, true)
|
|
119
|
+
document.removeEventListener('pointerdown', outside, true)
|
|
120
|
+
window.visualViewport?.removeEventListener('resize', schedule)
|
|
121
|
+
window.visualViewport?.removeEventListener('scroll', schedule)
|
|
122
|
+
}
|
|
123
|
+
async function present() {
|
|
124
|
+
detach()
|
|
125
|
+
ready.value = false
|
|
126
|
+
if (!active || !open.value || props.disabled) return
|
|
127
|
+
const token = revision
|
|
128
|
+
host.value = trigger.value?.$el?.closest('dialog') ?? document.body
|
|
129
|
+
await nextTick()
|
|
130
|
+
if (token !== revision || !active || !open.value) return
|
|
131
|
+
place()
|
|
132
|
+
observer = new ResizeObserver(schedule)
|
|
133
|
+
if (panel.value) observer.observe(panel.value)
|
|
134
|
+
if (trigger.value?.$el) observer.observe(trigger.value.$el)
|
|
135
|
+
window.addEventListener('resize', schedule)
|
|
136
|
+
document.addEventListener('scroll', schedule, true)
|
|
137
|
+
document.addEventListener('keydown', escape, true)
|
|
138
|
+
document.addEventListener('pointerdown', outside, true)
|
|
139
|
+
window.visualViewport?.addEventListener('resize', schedule)
|
|
140
|
+
window.visualViewport?.addEventListener('scroll', schedule)
|
|
141
|
+
if (motion.available)
|
|
142
|
+
motion.animate(
|
|
143
|
+
{ opacity: [0, 1], y: [3, 0] },
|
|
144
|
+
{ duration: theme.value.motion.enterDuration },
|
|
145
|
+
)
|
|
146
|
+
}
|
|
147
|
+
function show(delay = 0) {
|
|
148
|
+
clearTimer()
|
|
149
|
+
if (props.disabled || suppressed || !active) return
|
|
150
|
+
if (delay)
|
|
151
|
+
timer = setTimeout(() => {
|
|
152
|
+
open.value = true
|
|
153
|
+
}, delay)
|
|
154
|
+
else open.value = true
|
|
155
|
+
}
|
|
156
|
+
function leave() {
|
|
157
|
+
clearTimer()
|
|
158
|
+
if (!hovered && !focused && !pinned) timer = setTimeout(close, 120)
|
|
159
|
+
}
|
|
160
|
+
watch(open, (value) => {
|
|
161
|
+
if (value) void present()
|
|
162
|
+
else detach()
|
|
163
|
+
})
|
|
164
|
+
watch(
|
|
165
|
+
() => props.disabled,
|
|
166
|
+
(value) => {
|
|
167
|
+
if (value) close()
|
|
168
|
+
},
|
|
169
|
+
)
|
|
170
|
+
watch(() => props.placement, schedule)
|
|
171
|
+
onMounted(() => {
|
|
172
|
+
active = true
|
|
173
|
+
host.value = trigger.value?.$el?.closest('dialog') ?? document.body
|
|
174
|
+
})
|
|
175
|
+
onActivated(() => {
|
|
176
|
+
active = true
|
|
177
|
+
})
|
|
178
|
+
onDeactivated(() => {
|
|
179
|
+
active = false
|
|
180
|
+
close()
|
|
181
|
+
detach()
|
|
182
|
+
hovered = focused = pinned = false
|
|
183
|
+
})
|
|
184
|
+
onBeforeUnmount(() => {
|
|
185
|
+
active = false
|
|
186
|
+
clearTimer()
|
|
187
|
+
detach()
|
|
188
|
+
})
|
|
189
|
+
return () => {
|
|
190
|
+
if (!props.text.trim() || !props.triggerLabel.trim())
|
|
191
|
+
throw new TypeError('Tooltip requires text and a trigger label.')
|
|
192
|
+
if (!Number.isFinite(props.delay) || props.delay < 0)
|
|
193
|
+
throw new RangeError('Tooltip delay must be nonnegative and finite.')
|
|
194
|
+
const tooltipId = props.id ?? id
|
|
195
|
+
const content = h(
|
|
196
|
+
'span',
|
|
197
|
+
{
|
|
198
|
+
ref: panel,
|
|
199
|
+
id: tooltipId,
|
|
200
|
+
role: 'tooltip',
|
|
201
|
+
hidden: !open.value,
|
|
202
|
+
class: 'm-tooltip-content',
|
|
203
|
+
style: {
|
|
204
|
+
position: 'fixed',
|
|
205
|
+
zIndex: 1100,
|
|
206
|
+
left: `${position.value.x}px`,
|
|
207
|
+
top: `${position.value.y}px`,
|
|
208
|
+
width: 'max-content',
|
|
209
|
+
maxWidth: 'min(300px, calc(100vw - 16px))',
|
|
210
|
+
visibility: open.value && ready.value ? 'visible' : 'hidden',
|
|
211
|
+
},
|
|
212
|
+
onPointerenter: () => {
|
|
213
|
+
hovered = true
|
|
214
|
+
clearTimer()
|
|
215
|
+
},
|
|
216
|
+
onPointerleave: () => {
|
|
217
|
+
hovered = false
|
|
218
|
+
leave()
|
|
219
|
+
},
|
|
220
|
+
},
|
|
221
|
+
[
|
|
222
|
+
h(
|
|
223
|
+
MBox,
|
|
224
|
+
{
|
|
225
|
+
motionSurface: motion,
|
|
226
|
+
padding: 'sm',
|
|
227
|
+
radius: 'md',
|
|
228
|
+
backgroundColor: theme.value.colors.text,
|
|
229
|
+
style: {
|
|
230
|
+
color: theme.value.colors.background,
|
|
231
|
+
fontSize: '13px',
|
|
232
|
+
lineHeight: 1.5,
|
|
233
|
+
boxShadow: '0 6px 20px #0002',
|
|
234
|
+
overflowWrap: 'anywhere',
|
|
235
|
+
},
|
|
236
|
+
},
|
|
237
|
+
() => props.text,
|
|
238
|
+
),
|
|
239
|
+
],
|
|
240
|
+
)
|
|
241
|
+
return h(
|
|
242
|
+
'span',
|
|
243
|
+
mergeProps(attrs, {
|
|
244
|
+
class: 'm-tooltip',
|
|
245
|
+
style: { display: 'inline-flex', alignSelf: 'flex-start' },
|
|
246
|
+
}),
|
|
247
|
+
[
|
|
248
|
+
h(MButton, {
|
|
249
|
+
ref: trigger,
|
|
250
|
+
icon: props.icon,
|
|
251
|
+
accessibilityLabel: props.triggerLabel,
|
|
252
|
+
variant: props.variant,
|
|
253
|
+
disabled: props.disabled,
|
|
254
|
+
'aria-describedby': tooltipId,
|
|
255
|
+
onPointerenter: (event: PointerEvent) => {
|
|
256
|
+
if (event.pointerType === 'touch') return
|
|
257
|
+
hovered = true
|
|
258
|
+
suppressed = false
|
|
259
|
+
show(props.delay)
|
|
260
|
+
},
|
|
261
|
+
onPointerleave: () => {
|
|
262
|
+
hovered = false
|
|
263
|
+
if (!focused) suppressed = false
|
|
264
|
+
leave()
|
|
265
|
+
},
|
|
266
|
+
onFocus: () => {
|
|
267
|
+
focused = true
|
|
268
|
+
suppressed = false
|
|
269
|
+
show()
|
|
270
|
+
},
|
|
271
|
+
onBlur: () => {
|
|
272
|
+
focused = false
|
|
273
|
+
pinned = false
|
|
274
|
+
leave()
|
|
275
|
+
},
|
|
276
|
+
onClick: () => {
|
|
277
|
+
if (props.disabled) return
|
|
278
|
+
if (pinned) {
|
|
279
|
+
suppressed = true
|
|
280
|
+
close()
|
|
281
|
+
} else {
|
|
282
|
+
pinned = true
|
|
283
|
+
suppressed = false
|
|
284
|
+
show()
|
|
285
|
+
}
|
|
286
|
+
},
|
|
287
|
+
}),
|
|
288
|
+
host.value ? h(Teleport, { to: host.value }, content) : content,
|
|
289
|
+
],
|
|
290
|
+
)
|
|
291
|
+
}
|
|
292
|
+
},
|
|
293
|
+
})
|
|
@@ -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
|
+
)
|
|
@@ -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
|
+
)
|
package/src/index.ts
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
import {
|
|
2
|
+
MCommandPalette,
|
|
3
|
+
MNavigationRail,
|
|
4
|
+
MBreadcrumb,
|
|
5
|
+
MTimeline,
|
|
6
|
+
MChart,
|
|
7
|
+
} from './components/wayfinding.js'
|
|
8
|
+
import { MTooltip } from './components/MTooltip.js'
|
|
9
|
+
import { MDataTable, MCarousel, MCalendar, MRating, MTreeView } from './components/discovery.js'
|
|
10
|
+
import { MRangeSlider } from './components/MRangeSlider.js'
|
|
1
11
|
import { MPopover } from './components/MPopover.js'
|
|
2
12
|
import { MMenu, MAppBar, MTabBar } from './components/navigation.js'
|
|
3
13
|
import { MTimePicker } from './components/MTimePicker.js'
|
|
@@ -100,6 +110,18 @@ export {
|
|
|
100
110
|
MTabBar,
|
|
101
111
|
MTimePicker,
|
|
102
112
|
MVirtualList,
|
|
113
|
+
MDataTable,
|
|
114
|
+
MCarousel,
|
|
115
|
+
MRangeSlider,
|
|
116
|
+
MCalendar,
|
|
117
|
+
MRating,
|
|
118
|
+
MTreeView,
|
|
119
|
+
MCommandPalette,
|
|
120
|
+
MNavigationRail,
|
|
121
|
+
MBreadcrumb,
|
|
122
|
+
MTooltip,
|
|
123
|
+
MTimeline,
|
|
124
|
+
MChart,
|
|
103
125
|
}
|
|
104
126
|
export {
|
|
105
127
|
useMavisTheme,
|
|
@@ -187,6 +209,18 @@ export function createMavis(options: MavisOptions = {}) {
|
|
|
187
209
|
MTabBar,
|
|
188
210
|
MTimePicker,
|
|
189
211
|
MVirtualList,
|
|
212
|
+
MDataTable,
|
|
213
|
+
MCarousel,
|
|
214
|
+
MRangeSlider,
|
|
215
|
+
MCalendar,
|
|
216
|
+
MRating,
|
|
217
|
+
MTreeView,
|
|
218
|
+
MCommandPalette,
|
|
219
|
+
MNavigationRail,
|
|
220
|
+
MBreadcrumb,
|
|
221
|
+
MTooltip,
|
|
222
|
+
MTimeline,
|
|
223
|
+
MChart,
|
|
190
224
|
},
|
|
191
225
|
)) {
|
|
192
226
|
app.component(name, component)
|