@getcortexlabs/mavis-core 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.
Files changed (100) hide show
  1. package/dist/capabilities.d.ts +7 -7
  2. package/dist/capabilities.d.ts.map +1 -1
  3. package/dist/capabilities.js +16 -4
  4. package/dist/capabilities.js.map +1 -1
  5. package/dist/chart.d.ts +40 -0
  6. package/dist/chart.d.ts.map +1 -0
  7. package/dist/chart.js +73 -0
  8. package/dist/chart.js.map +1 -0
  9. package/dist/discovery.d.ts +49 -0
  10. package/dist/discovery.d.ts.map +1 -0
  11. package/dist/discovery.js +80 -0
  12. package/dist/discovery.js.map +1 -0
  13. package/dist/index.d.ts +3 -0
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +3 -0
  16. package/dist/index.js.map +1 -1
  17. package/dist/vue/carousel.d.ts +11 -0
  18. package/dist/vue/carousel.d.ts.map +1 -0
  19. package/dist/vue/carousel.js +115 -0
  20. package/dist/vue/carousel.js.map +1 -0
  21. package/dist/vue/chart.d.ts +194 -0
  22. package/dist/vue/chart.d.ts.map +1 -0
  23. package/dist/vue/chart.js +246 -0
  24. package/dist/vue/chart.js.map +1 -0
  25. package/dist/vue/command-palette.d.ts +129 -0
  26. package/dist/vue/command-palette.d.ts.map +1 -0
  27. package/dist/vue/command-palette.js +187 -0
  28. package/dist/vue/command-palette.js.map +1 -0
  29. package/dist/vue/component-props.d.ts +475 -18
  30. package/dist/vue/component-props.d.ts.map +1 -1
  31. package/dist/vue/component-props.js +14 -0
  32. package/dist/vue/component-props.js.map +1 -1
  33. package/dist/vue/configurator.d.ts +2 -2
  34. package/dist/vue/data-table.d.ts +17 -0
  35. package/dist/vue/data-table.d.ts.map +1 -0
  36. package/dist/vue/data-table.js +133 -0
  37. package/dist/vue/data-table.js.map +1 -0
  38. package/dist/vue/date-picker.d.ts +8 -8
  39. package/dist/vue/date-props.d.ts +6 -0
  40. package/dist/vue/date-props.d.ts.map +1 -1
  41. package/dist/vue/date-props.js +3 -0
  42. package/dist/vue/date-props.js.map +1 -1
  43. package/dist/vue/discovery-components.d.ts +50 -0
  44. package/dist/vue/discovery-components.d.ts.map +1 -0
  45. package/dist/vue/discovery-components.js +2 -0
  46. package/dist/vue/discovery-components.js.map +1 -0
  47. package/dist/vue/discovery-controls.d.ts +197 -0
  48. package/dist/vue/discovery-controls.d.ts.map +1 -0
  49. package/dist/vue/discovery-controls.js +166 -0
  50. package/dist/vue/discovery-controls.js.map +1 -0
  51. package/dist/vue/discovery-props.d.ts +249 -0
  52. package/dist/vue/discovery-props.d.ts.map +1 -0
  53. package/dist/vue/discovery-props.js +87 -0
  54. package/dist/vue/discovery-props.js.map +1 -0
  55. package/dist/vue/global-components.d.ts +61 -0
  56. package/dist/vue/global-components.d.ts.map +1 -1
  57. package/dist/vue/index.d.ts +10 -0
  58. package/dist/vue/index.d.ts.map +1 -1
  59. package/dist/vue/index.js +9 -0
  60. package/dist/vue/index.js.map +1 -1
  61. package/dist/vue/menu.d.ts +1 -1
  62. package/dist/vue/props.d.ts +36 -36
  63. package/dist/vue/time-picker.d.ts +2 -2
  64. package/dist/vue/tree-view.d.ts +111 -0
  65. package/dist/vue/tree-view.d.ts.map +1 -0
  66. package/dist/vue/tree-view.js +180 -0
  67. package/dist/vue/tree-view.js.map +1 -0
  68. package/dist/vue/wayfinding-controls.d.ts +198 -0
  69. package/dist/vue/wayfinding-controls.d.ts.map +1 -0
  70. package/dist/vue/wayfinding-controls.js +310 -0
  71. package/dist/vue/wayfinding-controls.js.map +1 -0
  72. package/dist/vue/wayfinding-props.d.ts +221 -0
  73. package/dist/vue/wayfinding-props.d.ts.map +1 -0
  74. package/dist/vue/wayfinding-props.js +86 -0
  75. package/dist/vue/wayfinding-props.js.map +1 -0
  76. package/dist/vue/workflows.d.ts +2 -2
  77. package/dist/wayfinding.d.ts +50 -0
  78. package/dist/wayfinding.d.ts.map +1 -0
  79. package/dist/wayfinding.js +54 -0
  80. package/dist/wayfinding.js.map +1 -0
  81. package/package.json +1 -1
  82. package/src/capabilities.ts +16 -4
  83. package/src/chart.ts +112 -0
  84. package/src/discovery.ts +139 -0
  85. package/src/index.ts +5 -0
  86. package/src/vue/carousel.ts +173 -0
  87. package/src/vue/chart.ts +338 -0
  88. package/src/vue/command-palette.ts +232 -0
  89. package/src/vue/component-props.ts +28 -0
  90. package/src/vue/data-table.ts +190 -0
  91. package/src/vue/date-props.ts +3 -0
  92. package/src/vue/discovery-components.ts +60 -0
  93. package/src/vue/discovery-controls.ts +218 -0
  94. package/src/vue/discovery-props.ts +92 -0
  95. package/src/vue/global-components.ts +66 -0
  96. package/src/vue/index.ts +13 -0
  97. package/src/vue/tree-view.ts +220 -0
  98. package/src/vue/wayfinding-controls.ts +412 -0
  99. package/src/vue/wayfinding-props.ts +97 -0
  100. package/src/wayfinding.ts +85 -0
@@ -0,0 +1,190 @@
1
+ import type { DataTableComponent } from './discovery-components.js'
2
+ import {
3
+ computed,
4
+ defineComponent,
5
+ h,
6
+ mergeProps,
7
+ type Component,
8
+ type VNodeChild,
9
+ } from '@vue/runtime-core'
10
+ import { choiceKey, type ChoiceValue } from '../choice.js'
11
+ import {
12
+ collectionKeys,
13
+ nextDataSort,
14
+ selectPage,
15
+ validateColumns,
16
+ type DataColumn,
17
+ type DataSort,
18
+ } from '../discovery.js'
19
+ import { dataTableProps } from './discovery-props.js'
20
+ import { useMavisTheme } from './theme.js'
21
+
22
+ export function createDataTable(
23
+ ui: {
24
+ Column: Component
25
+ Row: Component
26
+ Text: Component
27
+ Button: Component
28
+ Checkbox: Component
29
+ Progress: Component
30
+ table: (
31
+ columns: readonly DataColumn[],
32
+ header: VNodeChild[],
33
+ rows: { key: string; cells: VNodeChild[]; selected: boolean }[],
34
+ label: string,
35
+ busy: boolean,
36
+ ) => VNodeChild
37
+ },
38
+ platform: 'web' | 'native',
39
+ ) {
40
+ return defineComponent({
41
+ name: 'MDataTable',
42
+ inheritAttrs: false,
43
+ props: dataTableProps,
44
+ emits: {
45
+ 'update:sort': (_sort: DataSort | null) => true,
46
+ 'update:selected': (_selected: ChoiceValue[]) => true,
47
+ },
48
+ setup(props, { attrs, slots, emit }) {
49
+ const { theme } = useMavisTheme()
50
+ const keys = computed(() => collectionKeys(props.items, props.itemKey))
51
+ const selectable = computed(() =>
52
+ keys.value.filter((_, index) => !props.rowDisabled?.(props.items[index]!)),
53
+ )
54
+ const selectedIds = computed(() => new Set(props.selected.map(choiceKey)))
55
+ function select(page: readonly ChoiceValue[], checked: boolean) {
56
+ if (!props.disabled && !props.loading)
57
+ emit('update:selected', selectPage(props.selected, page, checked))
58
+ }
59
+ return () => {
60
+ validateColumns(props.columns)
61
+ if (
62
+ props.sort &&
63
+ !props.columns.some((column) => column.key === props.sort!.key && column.sortable)
64
+ )
65
+ throw new RangeError('Sort must identify a sortable column.')
66
+ const count = selectable.value.filter((key) => selectedIds.value.has(choiceKey(key))).length
67
+ const headers = props.columns.map((column) =>
68
+ column.sortable
69
+ ? h(ui.Button, {
70
+ text: column.label,
71
+ variant: 'ghost',
72
+ disabled: props.disabled || props.loading,
73
+ icon:
74
+ props.sort?.key !== column.key
75
+ ? 'arrow-up-down'
76
+ : props.sort.direction === 'ascending'
77
+ ? 'arrow-up'
78
+ : 'arrow-down',
79
+ accessibilityLabel: `${column.label}${platform === 'native' && props.sort?.key === column.key ? `, ${props.sort.direction}` : ''}`,
80
+ onClick: () => {
81
+ if (!props.disabled && !props.loading)
82
+ emit('update:sort', nextDataSort(props.sort, column.key))
83
+ },
84
+ })
85
+ : h(ui.Text, { text: column.label, weight: '600', variant: 'caption' }),
86
+ )
87
+ const columns = props.columns.map((column) => ({
88
+ ...column,
89
+ sort: props.sort?.key === column.key ? props.sort.direction : undefined,
90
+ }))
91
+ if (props.selectable) {
92
+ let selectionKey = '__mavis_selection'
93
+ while (columns.some((column) => column.key === selectionKey))
94
+ selectionKey = '_' + selectionKey
95
+ columns.unshift({
96
+ key: selectionKey,
97
+ // The checkbox carries the accessible label; this column has no visible caption.
98
+ label: '',
99
+ width: 64,
100
+ sort: undefined,
101
+ })
102
+ headers.unshift(
103
+ h(ui.Checkbox, {
104
+ label: props.selectAllLabel,
105
+ modelValue: count > 0 && count === selectable.value.length,
106
+ indeterminate: count > 0 && count < selectable.value.length,
107
+ disabled: props.disabled || props.loading || !selectable.value.length,
108
+ 'onUpdate:modelValue': (value: boolean) => select(selectable.value, value),
109
+ ...(platform === 'web' ? { class: 'm-data-table-selection' } : {}),
110
+ }),
111
+ )
112
+ }
113
+ const rows = props.items.map((item, index) => {
114
+ const key = keys.value[index]!
115
+ const cells = props.columns.map((column) => {
116
+ const raw = column.value ? column.value(item) : item[column.key]
117
+ const value =
118
+ raw == null || typeof raw === 'string' || typeof raw === 'number' ? raw : String(raw)
119
+ const slot = { item, itemKey: key, column, value, index }
120
+ return (
121
+ slots[`cell:${column.key}`]?.(slot) ??
122
+ slots.cell?.(slot) ??
123
+ h(ui.Text, {
124
+ text: String(value ?? '—'),
125
+ align: column.align === 'end' ? 'right' : 'left',
126
+ })
127
+ )
128
+ })
129
+ if (props.selectable)
130
+ cells.unshift(
131
+ h(ui.Checkbox, {
132
+ label: `${props.selectLabel} ${props.rowLabel?.(item) ?? String(key)}`,
133
+ modelValue: selectedIds.value.has(choiceKey(key)),
134
+ disabled: props.disabled || props.loading || props.rowDisabled?.(item),
135
+ 'onUpdate:modelValue': (value: boolean) => {
136
+ if (!props.rowDisabled?.(item)) select([key], value)
137
+ },
138
+ ...(platform === 'web' ? { class: 'm-data-table-selection' } : {}),
139
+ }),
140
+ )
141
+ return { key: choiceKey(key), cells, selected: selectedIds.value.has(choiceKey(key)) }
142
+ })
143
+ return h(
144
+ ui.Column,
145
+ mergeProps(
146
+ { id: props.id, gap: 'md' },
147
+ attrs,
148
+ platform === 'web'
149
+ ? {
150
+ class: 'm-data-table',
151
+ style: {
152
+ '--m-color-border': theme.value.colors.border,
153
+ '--m-color-primarySoft': theme.value.colors.primarySoft,
154
+ },
155
+ }
156
+ : {},
157
+ ),
158
+ () => [
159
+ h(ui.Row, { justify: 'between', gap: 'md', wrap: true }, () => [
160
+ h(ui.Text, { as: 'h2', variant: 'heading', text: props.label }),
161
+ slots.actions?.(),
162
+ ]),
163
+ h(
164
+ ui.Column,
165
+ { radius: 'lg', backgroundColor: theme.value.colors.surface, gap: 'none' },
166
+ () => [
167
+ props.loading
168
+ ? h(ui.Progress, { indeterminate: true, label: props.loadingLabel, size: 'sm' })
169
+ : null,
170
+ ui.table(columns, headers, rows, props.label, props.loading),
171
+ !rows.length
172
+ ? (slots.empty?.() ??
173
+ h(ui.Text, {
174
+ text: props.loading ? props.loadingLabel : props.emptyLabel,
175
+ tone: 'muted',
176
+ style: { padding: 24 },
177
+ ...(platform === 'web'
178
+ ? { role: 'status' }
179
+ : { accessibilityLiveRegion: 'polite' }),
180
+ }))
181
+ : null,
182
+ ],
183
+ ),
184
+ slots.footer?.(),
185
+ ],
186
+ )
187
+ }
188
+ },
189
+ }) as unknown as DataTableComponent
190
+ }
@@ -74,6 +74,9 @@ export type DateRangePickerProps = ExtractPublicPropTypes<typeof dateRangePicker
74
74
 
75
75
  /** @internal Shared themed calendar presentation contract. */
76
76
  export const dateCalendarProps = {
77
+ autofocus: { type: Boolean, default: true },
78
+ disabled: Boolean,
79
+ readonly: Boolean,
77
80
  ...dateOptions,
78
81
  activeDate: { type: String as PropType<CivilDate>, required: true as const },
79
82
  selected: { type: String as PropType<CivilDate | null>, default: null },
@@ -0,0 +1,60 @@
1
+ import type { PublicProps, VNode, VNodeChild } from '@vue/runtime-core'
2
+ import type { ComponentProps } from './component-props.js'
3
+ import type { ChoiceValue } from '../choice.js'
4
+ import type { VirtualItemSlot } from '../collections.js'
5
+ import type { DataColumn, DataCellSlot, DataSort } from '../discovery.js'
6
+
7
+ type Key<T> = Extract<keyof T, string> | ((item: T) => ChoiceValue)
8
+ interface Context<P, S> {
9
+ props: P
10
+ attrs: Record<string, unknown>
11
+ emit: (event: string, ...args: unknown[]) => void
12
+ slots: S
13
+ }
14
+ type CarouselProps<T> = PublicProps &
15
+ Omit<ComponentProps['MCarousel'], 'items' | 'itemKey'> & {
16
+ items: readonly T[]
17
+ itemKey?: Key<T>
18
+ 'onUpdate:modelValue'?: (key: ChoiceValue) => void
19
+ }
20
+ type CarouselContext<T> = Context<
21
+ CarouselProps<T>,
22
+ { default?: (scope: VirtualItemSlot<T>) => VNodeChild; empty?: () => VNodeChild }
23
+ >
24
+ export interface CarouselComponent {
25
+ <T>(
26
+ props: NonNullable<Awaited<typeof setup>>['props'],
27
+ context?: Pick<NonNullable<Awaited<typeof setup>>, 'attrs' | 'emit' | 'slots'>,
28
+ exposed?: undefined,
29
+ setup?: Promise<CarouselContext<T>>,
30
+ ): VNode & { __ctx?: NonNullable<Awaited<typeof setup>> }
31
+ }
32
+ type TableProps<T> = PublicProps &
33
+ Omit<
34
+ ComponentProps['MDataTable'],
35
+ 'items' | 'itemKey' | 'columns' | 'rowLabel' | 'rowDisabled'
36
+ > & {
37
+ items: readonly T[]
38
+ itemKey?: Key<T>
39
+ columns: readonly DataColumn<T>[]
40
+ rowLabel?: (item: T) => string
41
+ rowDisabled?: (item: T) => boolean
42
+ 'onUpdate:sort'?: (sort: DataSort | null) => void
43
+ 'onUpdate:selected'?: (keys: ChoiceValue[]) => void
44
+ }
45
+ type TableSlots<T> = {
46
+ cell?: (scope: DataCellSlot<T>) => VNodeChild
47
+ actions?: () => VNodeChild
48
+ footer?: () => VNodeChild
49
+ empty?: () => VNodeChild
50
+ } & {
51
+ [name: `cell:${string}`]: ((scope: DataCellSlot<T>) => VNodeChild) | undefined
52
+ }
53
+ export interface DataTableComponent {
54
+ <T>(
55
+ props: NonNullable<Awaited<typeof setup>>['props'],
56
+ context?: Pick<NonNullable<Awaited<typeof setup>>, 'attrs' | 'emit' | 'slots'>,
57
+ exposed?: undefined,
58
+ setup?: Promise<Context<TableProps<T>, TableSlots<T>>>,
59
+ ): VNode & { __ctx?: NonNullable<Awaited<typeof setup>> }
60
+ }
@@ -0,0 +1,218 @@
1
+ import {
2
+ computed,
3
+ defineComponent,
4
+ h,
5
+ mergeProps,
6
+ ref,
7
+ watch,
8
+ type Component,
9
+ } from '@vue/runtime-core'
10
+ import { calendarProps, ratingProps } from './discovery-props.js'
11
+ import { ratingValue } from '../discovery.js'
12
+ import {
13
+ civilDate,
14
+ dateAvailability,
15
+ validateDateConstraints,
16
+ validateDateRangeDraft,
17
+ type CivilDate,
18
+ type DateRange,
19
+ } from '../date.js'
20
+ import { useMavisTheme } from './theme.js'
21
+
22
+ interface Primitives {
23
+ Column: Component
24
+ Row: Component
25
+ Text: Component
26
+ Button: Component
27
+ Icon: Component
28
+ Slider: Component
29
+ Calendar: Component
30
+ }
31
+ function initialCalendarDate(
32
+ value: CivilDate | null,
33
+ props: { min?: CivilDate; max?: CivilDate; initialMonth: string },
34
+ ) {
35
+ let date = value ?? props.min ?? civilDate(`${props.initialMonth}-01`)
36
+ if (props.min && date < props.min) date = props.min
37
+ if (props.max && date > props.max) date = props.max
38
+ return date
39
+ }
40
+ export function createDiscoveryControls(ui: Primitives, platform: 'web' | 'native') {
41
+ const MCalendar = defineComponent({
42
+ name: 'MCalendar',
43
+ inheritAttrs: false,
44
+ props: calendarProps,
45
+ emits: {
46
+ 'update:modelValue': (_value: CivilDate | DateRange | null) => true,
47
+ invalid: () => true,
48
+ },
49
+ setup(props, { attrs, emit, slots }) {
50
+ const { theme } = useMavisTheme()
51
+ const selected = computed(() =>
52
+ typeof props.modelValue === 'string' ? civilDate(props.modelValue) : null,
53
+ )
54
+ const range = computed(() =>
55
+ typeof props.modelValue === 'object' && props.modelValue !== null
56
+ ? props.modelValue
57
+ : { start: null, end: null },
58
+ )
59
+ const active = ref<CivilDate>(initialCalendarDate(selected.value ?? range.value.start, props))
60
+ const invalid = ref(false)
61
+ watch(
62
+ () => [props.modelValue, props.initialMonth],
63
+ () => {
64
+ active.value = initialCalendarDate(
65
+ selected.value ?? range.value.end ?? range.value.start,
66
+ props,
67
+ )
68
+ invalid.value = false
69
+ },
70
+ )
71
+ function select(date: CivilDate) {
72
+ if (props.disabled || props.readonly || dateAvailability(date, props)) return
73
+ invalid.value = false
74
+ if (props.mode === 'single') emit('update:modelValue', date)
75
+ else if (!range.value.start || range.value.end)
76
+ emit('update:modelValue', { start: date, end: null })
77
+ else {
78
+ const next =
79
+ date < range.value.start
80
+ ? { start: date, end: range.value.start }
81
+ : { start: range.value.start, end: date }
82
+ if (!validateDateRangeDraft({ start: next.start, end: next.end }, props).valid) {
83
+ invalid.value = true
84
+ emit('invalid')
85
+ } else emit('update:modelValue', next)
86
+ }
87
+ }
88
+ return () => {
89
+ validateDateConstraints(props)
90
+ if (
91
+ props.mode === 'single' &&
92
+ props.modelValue !== null &&
93
+ typeof props.modelValue !== 'string'
94
+ )
95
+ throw new TypeError('Single calendars require a civil date.')
96
+ if (props.mode === 'range' && typeof props.modelValue === 'string')
97
+ throw new TypeError('Range calendars require start and end.')
98
+ for (const date of [range.value.start, range.value.end]) if (date !== null) civilDate(date)
99
+ return h(
100
+ ui.Column,
101
+ mergeProps(
102
+ {
103
+ id: props.id,
104
+ gap: 'md',
105
+ padding: 'sm',
106
+ radius: 'lg',
107
+ backgroundColor: theme.value.colors.surface,
108
+ },
109
+ attrs,
110
+ platform === 'web'
111
+ ? { role: 'group', 'aria-label': props.label, class: 'm-calendar' }
112
+ : {},
113
+ ),
114
+ () => [
115
+ h(ui.Text, { as: 'h2', variant: 'heading', text: props.label }),
116
+ h(ui.Calendar, {
117
+ ...props,
118
+ autofocus: false,
119
+ activeDate: active.value,
120
+ selected: selected.value,
121
+ rangeStart: range.value.start,
122
+ rangeEnd: range.value.end,
123
+ 'onUpdate:activeDate': (date: CivilDate) => {
124
+ active.value = date
125
+ },
126
+ onSelect: select,
127
+ }),
128
+ invalid.value
129
+ ? h(ui.Text, {
130
+ text: props.invalidRangeLabel,
131
+ tone: 'danger',
132
+ ...(platform === 'web'
133
+ ? { role: 'alert' }
134
+ : { accessibilityLiveRegion: 'assertive' }),
135
+ })
136
+ : null,
137
+ slots.footer?.(),
138
+ ],
139
+ )
140
+ }
141
+ },
142
+ })
143
+ const MRating = defineComponent({
144
+ name: 'MRating',
145
+ inheritAttrs: false,
146
+ props: ratingProps,
147
+ emits: { 'update:modelValue': (_value: number) => true },
148
+ setup(props, { attrs, emit }) {
149
+ const value = computed(() => ratingValue(props.modelValue, props.max, props.step))
150
+ const label = (next: number) =>
151
+ props.formatValue?.(next, props.max) ?? `${next} / ${props.max}`
152
+ function choose(next: number) {
153
+ if (!props.readonly && !props.disabled && next !== value.value)
154
+ emit('update:modelValue', ratingValue(next, props.max, props.step))
155
+ }
156
+ return () =>
157
+ h(
158
+ ui.Column,
159
+ mergeProps(
160
+ { id: props.id, gap: 'sm' },
161
+ attrs,
162
+ platform === 'web'
163
+ ? { class: 'm-rating', role: 'group', 'aria-label': props.label }
164
+ : {},
165
+ ),
166
+ () => [
167
+ h(ui.Row, { justify: 'between', gap: 'sm', wrap: true }, () => [
168
+ h(ui.Text, { text: props.label, weight: '600' }),
169
+ h(ui.Text, { text: label(value.value), tone: 'muted', variant: 'caption' }),
170
+ ]),
171
+ h(ui.Row, { gap: 'xs', wrap: true }, () =>
172
+ Array.from({ length: props.max }, (_, index) => {
173
+ const filled = value.value >= index + 1
174
+ const half = value.value > index && !filled
175
+ const icon = half ? 'star-half' : 'star'
176
+ return props.readonly
177
+ ? h(ui.Icon, {
178
+ key: index,
179
+ name: icon,
180
+ size: 28,
181
+ tone: filled || half ? 'primary' : 'muted',
182
+ accessibilityHidden: true,
183
+ })
184
+ : h(ui.Button, {
185
+ key: index,
186
+ icon,
187
+ variant: filled || half ? 'primary' : 'secondary',
188
+ disabled: props.disabled,
189
+ accessibilityLabel: `${props.label}: ${label(index + 1)}`,
190
+ onClick: () => choose(index + 1),
191
+ })
192
+ }),
193
+ ),
194
+ !props.readonly && props.step === 0.5
195
+ ? h(ui.Slider, {
196
+ modelValue: value.value,
197
+ min: 0,
198
+ max: props.max,
199
+ step: props.step,
200
+ label: props.label,
201
+ disabled: props.disabled,
202
+ 'onUpdate:modelValue': choose,
203
+ })
204
+ : null,
205
+ props.clearable && !props.readonly
206
+ ? h(ui.Button, {
207
+ text: props.clearLabel,
208
+ variant: 'ghost',
209
+ disabled: props.disabled || value.value === 0,
210
+ onClick: () => choose(0),
211
+ })
212
+ : null,
213
+ ],
214
+ )
215
+ },
216
+ })
217
+ return { MCalendar, MRating }
218
+ }
@@ -0,0 +1,92 @@
1
+ import type { PropType } from '@vue/runtime-core'
2
+ import type { ChoiceValue } from '../choice.js'
3
+ import type { VirtualItemKey } from '../collections.js'
4
+ import type { CivilDate, DateRange } from '../date.js'
5
+ import type { DataColumn, DataSort, RangeValue, TreeNode } from '../discovery.js'
6
+ import { datePickerProps } from './date-props.js'
7
+ import { sliderProps } from './props.js'
8
+
9
+ const label = { type: String, required: true as const }
10
+ const keys = { type: Array as PropType<readonly ChoiceValue[]>, default: () => [] }
11
+ export const rangeSliderProps = {
12
+ ...sliderProps,
13
+ modelValue: { type: Array as unknown as PropType<RangeValue>, default: () => [0, 100] as const },
14
+ lowerLabel: { type: String, default: 'Minimum' },
15
+ upperLabel: { type: String, default: 'Maximum' },
16
+ formatValue: Function as PropType<(value: number) => string>,
17
+ readonly: Boolean,
18
+ }
19
+ export const ratingProps = {
20
+ label,
21
+ id: String,
22
+ modelValue: { type: Number, default: 0 },
23
+ max: { type: Number, default: 5 },
24
+ step: { type: Number as PropType<1 | 0.5>, default: 1 },
25
+ disabled: Boolean,
26
+ readonly: Boolean,
27
+ clearable: { type: Boolean, default: true },
28
+ clearLabel: { type: String, default: 'Clear rating' },
29
+ formatValue: Function as PropType<(value: number, max: number) => string>,
30
+ }
31
+ export const calendarProps = {
32
+ id: String,
33
+ label,
34
+ mode: { type: String as PropType<'single' | 'range'>, default: 'single' },
35
+ modelValue: { type: [String, Object] as PropType<CivilDate | DateRange | null>, default: null },
36
+ min: datePickerProps.min,
37
+ max: datePickerProps.max,
38
+ unavailableDates: datePickerProps.unavailableDates,
39
+ locale: datePickerProps.locale,
40
+ firstDayOfWeek: datePickerProps.firstDayOfWeek,
41
+ initialMonth: datePickerProps.initialMonth,
42
+ disabled: Boolean,
43
+ readonly: Boolean,
44
+ invalidRangeLabel: { type: String, default: 'This range includes an unavailable date.' },
45
+ }
46
+ export const dataTableProps = {
47
+ id: String,
48
+ label,
49
+ items: { type: Array as PropType<readonly Record<string, unknown>[]>, required: true as const },
50
+ itemKey: {
51
+ type: [String, Function] as PropType<VirtualItemKey<Record<string, unknown>>>,
52
+ default: 'id',
53
+ },
54
+ columns: { type: Array as PropType<readonly DataColumn[]>, required: true as const },
55
+ sort: { type: Object as PropType<DataSort | null>, default: null },
56
+ selected: keys,
57
+ selectable: Boolean,
58
+ disabled: Boolean,
59
+ loading: Boolean,
60
+ rowDisabled: Function as PropType<(item: Record<string, unknown>) => boolean>,
61
+ rowLabel: Function as PropType<(item: Record<string, unknown>) => string>,
62
+ selectLabel: { type: String, default: 'Select' },
63
+ selectAllLabel: { type: String, default: 'Select this page' },
64
+ emptyLabel: { type: String, default: 'No results' },
65
+ loadingLabel: { type: String, default: 'Loading results' },
66
+ }
67
+ export const treeViewProps = {
68
+ id: String,
69
+ label,
70
+ nodes: { type: Array as PropType<readonly TreeNode[]>, required: true as const },
71
+ modelValue: { type: [String, Number] as PropType<ChoiceValue | null>, default: null },
72
+ expanded: keys,
73
+ loadingKeys: keys,
74
+ disabled: Boolean,
75
+ emptyLabel: { type: String, default: 'No items' },
76
+ loadingLabel: { type: String, default: 'Loading' },
77
+ expandedLabel: { type: String, default: 'Expanded' },
78
+ collapsedLabel: { type: String, default: 'Collapsed' },
79
+ }
80
+ export const carouselProps = {
81
+ id: String,
82
+ label,
83
+ items: { type: Array as PropType<readonly unknown[]>, required: true as const },
84
+ itemKey: { type: [String, Function] as PropType<VirtualItemKey>, default: 'id' },
85
+ modelValue: { type: [String, Number] as PropType<ChoiceValue | null>, default: null },
86
+ disabled: Boolean,
87
+ loop: Boolean,
88
+ previousLabel: { type: String, default: 'Previous slide' },
89
+ nextLabel: { type: String, default: 'Next slide' },
90
+ slideLabel: { type: String, default: 'Slide' },
91
+ emptyLabel: { type: String, default: 'No slides' },
92
+ }
@@ -29,6 +29,47 @@ type SheetEvents = {
29
29
  /** Template props come from the same declarations used by both renderers. */
30
30
  declare module '@vue/runtime-core' {
31
31
  export interface GlobalComponents {
32
+ MCommandPalette: DefineComponent<
33
+ ComponentProps['MCommandPalette'] & {
34
+ 'onUpdate:open'?: (open: boolean) => void
35
+ 'onUpdate:query'?: (query: string) => void
36
+ onSelect?: (key: ChoiceValue, item: import('../wayfinding.js').CommandItem) => void
37
+ }
38
+ >
39
+ MNavigationRail: DefineComponent<
40
+ ComponentProps['MNavigationRail'] & {
41
+ 'onUpdate:collapsed'?: (collapsed: boolean) => void
42
+ onError?: (error: unknown) => void
43
+ }
44
+ > & {
45
+ new (): {
46
+ $slots: {
47
+ header?: (scope: { collapsed: boolean }) => unknown
48
+ footer?: (scope: { collapsed: boolean }) => unknown
49
+ }
50
+ }
51
+ }
52
+ MBreadcrumb: DefineComponent<
53
+ ComponentProps['MBreadcrumb'] & { onError?: (error: unknown) => void }
54
+ >
55
+ MTooltip: DefineComponent<ComponentProps['MTooltip']>
56
+ MTimeline: DefineComponent<ComponentProps['MTimeline']> & {
57
+ new (): {
58
+ $slots: {
59
+ default?: (scope: {
60
+ item: import('../wayfinding.js').TimelineItem
61
+ index: number
62
+ }) => unknown
63
+ }
64
+ }
65
+ }
66
+ MChart: DefineComponent<
67
+ ComponentProps['MChart'] & {
68
+ 'onUpdate:modelValue'?: (value: import('../chart.js').ChartSelection | null) => void
69
+ 'onUpdate:hiddenSeries'?: (keys: ChoiceValue[]) => void
70
+ }
71
+ >
72
+
32
73
  MPopover: DefineComponent<
33
74
  ComponentProps['MPopover'] & {
34
75
  'onUpdate:open'?: (open: boolean) => void
@@ -120,6 +161,31 @@ declare module '@vue/runtime-core' {
120
161
  MPagination: DefineComponent<
121
162
  ComponentProps['MPagination'] & { 'onUpdate:modelValue'?: (value: number) => void }
122
163
  >
164
+ MDataTable: import('./discovery-components.js').DataTableComponent
165
+ MCarousel: import('./discovery-components.js').CarouselComponent
166
+ MRangeSlider: DefineComponent<
167
+ ComponentProps['MRangeSlider'] & {
168
+ 'onUpdate:modelValue'?: (value: import('../discovery.js').RangeValue) => void
169
+ }
170
+ >
171
+ MCalendar: DefineComponent<
172
+ ComponentProps['MCalendar'] & {
173
+ 'onUpdate:modelValue'?: (
174
+ value: import('../date.js').CivilDate | import('../date.js').DateRange | null,
175
+ ) => void
176
+ onInvalid?: () => void
177
+ }
178
+ > & { new (): { $slots: { footer?: () => unknown } } }
179
+ MRating: DefineComponent<
180
+ ComponentProps['MRating'] & { 'onUpdate:modelValue'?: (value: number) => void }
181
+ >
182
+ MTreeView: DefineComponent<
183
+ ComponentProps['MTreeView'] & {
184
+ 'onUpdate:modelValue'?: (key: ChoiceValue) => void
185
+ 'onUpdate:expanded'?: (keys: ChoiceValue[]) => void
186
+ onLoad?: (node: import('../discovery.js').TreeNode) => void
187
+ }
188
+ >
123
189
  MScreen: DefineComponent<ComponentProps['MScreen']>
124
190
  MRow: DefineComponent<ComponentProps['MRow']>
125
191
  MColumn: DefineComponent<ComponentProps['MColumn']>
package/src/vue/index.ts CHANGED
@@ -102,3 +102,16 @@ export * from './menu.js'
102
102
  export * from './time-picker.js'
103
103
 
104
104
  export type { VirtualListComponent } from './virtual-list.js'
105
+
106
+ export * from './discovery-props.js'
107
+ export * from './discovery-controls.js'
108
+ export * from './carousel.js'
109
+ export * from './tree-view.js'
110
+ export * from './data-table.js'
111
+
112
+ export type { CarouselComponent, DataTableComponent } from './discovery-components.js'
113
+
114
+ export * from './wayfinding-props.js'
115
+ export * from './wayfinding-controls.js'
116
+ export * from './command-palette.js'
117
+ export * from './chart.js'