@getcortexlabs/mavis-core 0.1.0-rc.12 → 0.1.0-rc.12.2

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 (82) hide show
  1. package/README.md +2 -2
  2. package/dist/advanced-collections.d.ts +74 -0
  3. package/dist/advanced-collections.d.ts.map +1 -0
  4. package/dist/advanced-collections.js +129 -0
  5. package/dist/advanced-collections.js.map +1 -0
  6. package/dist/capabilities.d.ts +7 -7
  7. package/dist/capabilities.d.ts.map +1 -1
  8. package/dist/capabilities.js +10 -4
  9. package/dist/capabilities.js.map +1 -1
  10. package/dist/image-crop.d.ts +49 -0
  11. package/dist/image-crop.d.ts.map +1 -0
  12. package/dist/image-crop.js +71 -0
  13. package/dist/image-crop.js.map +1 -0
  14. package/dist/index.d.ts +3 -0
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +3 -0
  17. package/dist/index.js.map +1 -1
  18. package/dist/scheduler.d.ts +45 -0
  19. package/dist/scheduler.d.ts.map +1 -0
  20. package/dist/scheduler.js +142 -0
  21. package/dist/scheduler.js.map +1 -0
  22. package/dist/vue/advanced-collections.d.ts +486 -0
  23. package/dist/vue/advanced-collections.d.ts.map +1 -0
  24. package/dist/vue/advanced-collections.js +476 -0
  25. package/dist/vue/advanced-collections.js.map +1 -0
  26. package/dist/vue/advanced-props.d.ts +398 -0
  27. package/dist/vue/advanced-props.d.ts.map +1 -0
  28. package/dist/vue/advanced-props.js +128 -0
  29. package/dist/vue/advanced-props.js.map +1 -0
  30. package/dist/vue/animated-text.d.ts +1 -1
  31. package/dist/vue/chart.d.ts +1 -1
  32. package/dist/vue/command-palette.d.ts +3 -3
  33. package/dist/vue/component-props.d.ts +359 -3
  34. package/dist/vue/component-props.d.ts.map +1 -1
  35. package/dist/vue/component-props.js +7 -0
  36. package/dist/vue/component-props.js.map +1 -1
  37. package/dist/vue/composer.d.ts +1 -1
  38. package/dist/vue/configurator.d.ts +4 -4
  39. package/dist/vue/creative-controls.d.ts +1 -1
  40. package/dist/vue/dashboard-charts.d.ts +1 -1
  41. package/dist/vue/dashboard-effects.d.ts +2 -2
  42. package/dist/vue/date-picker.d.ts +8 -8
  43. package/dist/vue/discovery-controls.d.ts +1 -1
  44. package/dist/vue/global-components.d.ts +46 -0
  45. package/dist/vue/global-components.d.ts.map +1 -1
  46. package/dist/vue/image-cropper.d.ts +187 -0
  47. package/dist/vue/image-cropper.d.ts.map +1 -0
  48. package/dist/vue/image-cropper.js +310 -0
  49. package/dist/vue/image-cropper.js.map +1 -0
  50. package/dist/vue/index.d.ts +4 -0
  51. package/dist/vue/index.d.ts.map +1 -1
  52. package/dist/vue/index.js +4 -0
  53. package/dist/vue/index.js.map +1 -1
  54. package/dist/vue/kanban.d.ts +2 -2
  55. package/dist/vue/menu.d.ts +2 -2
  56. package/dist/vue/navigation-controls.d.ts +1 -1
  57. package/dist/vue/props.d.ts +6 -6
  58. package/dist/vue/scheduler.d.ts +229 -0
  59. package/dist/vue/scheduler.d.ts.map +1 -0
  60. package/dist/vue/scheduler.js +363 -0
  61. package/dist/vue/scheduler.js.map +1 -0
  62. package/dist/vue/scroll-frame.d.ts +1 -1
  63. package/dist/vue/speed-dial.d.ts +2 -2
  64. package/dist/vue/swipe-actions.d.ts +1 -1
  65. package/dist/vue/swipe-deck.d.ts +1 -1
  66. package/dist/vue/time-picker.d.ts +4 -4
  67. package/dist/vue/tour.d.ts +1 -1
  68. package/dist/vue/wayfinding-controls.d.ts +2 -2
  69. package/dist/vue/workflows.d.ts +3 -3
  70. package/package.json +1 -1
  71. package/src/advanced-collections.ts +199 -0
  72. package/src/capabilities.ts +10 -4
  73. package/src/image-crop.ts +125 -0
  74. package/src/index.ts +6 -0
  75. package/src/scheduler.ts +194 -0
  76. package/src/vue/advanced-collections.ts +679 -0
  77. package/src/vue/advanced-props.ts +144 -0
  78. package/src/vue/component-props.ts +14 -0
  79. package/src/vue/global-components.ts +46 -0
  80. package/src/vue/image-cropper.ts +413 -0
  81. package/src/vue/index.ts +8 -0
  82. package/src/vue/scheduler.ts +505 -0
@@ -0,0 +1,144 @@
1
+ import type { PropType } from '@vue/runtime-core'
2
+ import type {
3
+ TreeSelectNode,
4
+ MasonryItem,
5
+ HeatmapValue,
6
+ MavisNotification,
7
+ } from '../advanced-collections.js'
8
+ import type { ImageCrop, CropExportOptions } from '../image-crop.js'
9
+ import type { CivilDate } from '../date.js'
10
+ import type { SchedulerEvent, SchedulerDisambiguation } from '../scheduler.js'
11
+ import { spacingProp } from './props.js'
12
+ const label = { type: String, required: true as const },
13
+ animated = { type: Boolean, default: true }
14
+ export const treeSelectProps = {
15
+ id: String,
16
+ label,
17
+ nodes: { type: Array as PropType<readonly TreeSelectNode[]>, required: true as const },
18
+ modelValue: { type: Array as PropType<readonly string[]>, default: () => [] },
19
+ expanded: { type: Array as PropType<readonly string[]>, default: () => [] },
20
+ multiple: Boolean,
21
+ disabled: Boolean,
22
+ animated,
23
+ placeholder: { type: String, default: 'Choose items' },
24
+ searchLabel: { type: String, default: 'Search' },
25
+ clearLabel: { type: String, default: 'Clear selection' },
26
+ emptyLabel: { type: String, default: 'No matches' },
27
+ expandLabel: { type: String, default: 'Expand' },
28
+ collapseLabel: { type: String, default: 'Collapse' },
29
+ }
30
+ export const masonryProps = {
31
+ id: String,
32
+ label,
33
+ items: { type: Array as PropType<readonly MasonryItem[]>, required: true as const },
34
+ minColumnWidth: { type: Number, default: 220 },
35
+ columns: { type: Number, default: 4 },
36
+ gap: { ...spacingProp, default: 'md' },
37
+ animated,
38
+ emptyLabel: { type: String, default: 'No items' },
39
+ }
40
+ export const heatmapProps = {
41
+ id: String,
42
+ label,
43
+ start: { type: String as PropType<CivilDate>, required: true as const },
44
+ end: { type: String as PropType<CivilDate>, required: true as const },
45
+ values: { type: Array as PropType<readonly HeatmapValue[]>, required: true as const },
46
+ modelValue: { type: String as PropType<CivilDate | null>, default: null },
47
+ colors: {
48
+ type: Array as PropType<readonly string[]>,
49
+ default: () => ['#E6E4EB', '#C6ABCD', '#9B6AA9', '#704080', '#4C245C'],
50
+ },
51
+ cellSize: { type: Number, default: 40 },
52
+ weekStartsOn: { type: Number as PropType<0 | 1>, default: 1 },
53
+ animated,
54
+ disabled: Boolean,
55
+ missingLabel: { type: String, default: 'No data' },
56
+ dataLabel: { type: String, default: 'View data' },
57
+ lessLabel: { type: String, default: 'Less' },
58
+ moreLabel: { type: String, default: 'More' },
59
+ formatValue: Function as PropType<(value: number) => string>,
60
+ }
61
+ export const notificationCenterProps = {
62
+ id: String,
63
+ label,
64
+ modelValue: { type: Array as PropType<readonly MavisNotification[]>, required: true as const },
65
+ disabled: Boolean,
66
+ animated,
67
+ filter: { type: String as PropType<'all' | 'unread'>, default: 'all' },
68
+ allLabel: { type: String, default: 'All' },
69
+ unreadLabel: { type: String, default: 'Unread' },
70
+ readLabel: { type: String, default: 'Mark as read' },
71
+ unreadActionLabel: { type: String, default: 'Mark as unread' },
72
+ readAllLabel: { type: String, default: 'Mark all as read' },
73
+ dismissLabel: { type: String, default: 'Dismiss' },
74
+ emptyLabel: { type: String, default: 'You are all caught up' },
75
+ ungroupedLabel: { type: String, default: 'Notifications' },
76
+ }
77
+ export const imageCropperProps = {
78
+ id: String,
79
+ label,
80
+ src: { type: String, required: true as const },
81
+ modelValue: { type: Object as PropType<ImageCrop | null>, default: null },
82
+ aspectRatio: { type: Number, default: 1 },
83
+ animated,
84
+ disabled: Boolean,
85
+ output: {
86
+ type: Object as PropType<CropExportOptions>,
87
+ default: () => ({ mimeType: 'image/png', quality: 0.92 }),
88
+ },
89
+ zoomLabel: { type: String, default: 'Zoom' },
90
+ rotateLabel: { type: String, default: 'Rotate clockwise' },
91
+ resetLabel: { type: String, default: 'Reset' },
92
+ exportLabel: { type: String, default: 'Export image' },
93
+ loadingLabel: { type: String, default: 'Loading image' },
94
+ moveLabel: { type: String, default: 'Move image' },
95
+ leftLabel: { type: String, default: 'Move left' },
96
+ rightLabel: { type: String, default: 'Move right' },
97
+ upLabel: { type: String, default: 'Move up' },
98
+ downLabel: { type: String, default: 'Move down' },
99
+ }
100
+ export const schedulerProps = {
101
+ id: String,
102
+ label,
103
+ modelValue: { type: Array as PropType<readonly SchedulerEvent[]>, required: true as const },
104
+ date: { type: String as PropType<CivilDate>, required: true as const },
105
+ timeZone: { type: String, required: true as const },
106
+ days: { type: Number as PropType<1 | 7>, default: 7 },
107
+ startHour: { type: Number, default: 8 },
108
+ endHour: { type: Number, default: 19 },
109
+ slotMinutes: { type: Number, default: 15 },
110
+ hourHeight: { type: Number, default: 80 },
111
+ dayWidth: { type: Number, default: 180 },
112
+ animated,
113
+ disabled: Boolean,
114
+ disambiguation: { type: String as PropType<SchedulerDisambiguation>, default: 'reject' },
115
+ previousLabel: { type: String, default: 'Previous' },
116
+ nextLabel: { type: String, default: 'Next' },
117
+ moveLabel: { type: String, default: 'Move event' },
118
+ resizeLabel: { type: String, default: 'Resize event' },
119
+ earlierLabel: { type: String, default: 'Earlier' },
120
+ laterLabel: { type: String, default: 'Later' },
121
+ previousDayLabel: { type: String, default: 'Previous day' },
122
+ nextDayLabel: { type: String, default: 'Next day' },
123
+ shorterLabel: { type: String, default: 'Shorter' },
124
+ longerLabel: { type: String, default: 'Longer' },
125
+ emptyLabel: { type: String, default: 'No events' },
126
+ }
127
+ export const advancedCellProps = {
128
+ x: { type: Number, default: 0 },
129
+ y: { type: Number, default: 0 },
130
+ width: { type: Number, required: true as const },
131
+ height: Number,
132
+ measure: Boolean,
133
+ }
134
+ export const advancedCanvasProps = {
135
+ height: { type: Number, required: true as const },
136
+ width: Number,
137
+ }
138
+ export const advancedGestureProps = { label, disabled: Boolean }
139
+ export interface AdvancedGesture {
140
+ phase: 'start' | 'move' | 'end' | 'cancel'
141
+ x: number
142
+ y: number
143
+ scale: number
144
+ }
@@ -1,3 +1,11 @@
1
+ import {
2
+ treeSelectProps,
3
+ masonryProps,
4
+ heatmapProps,
5
+ imageCropperProps,
6
+ schedulerProps,
7
+ notificationCenterProps,
8
+ } from './advanced-props.js'
1
9
  import {
2
10
  kanbanProps,
3
11
  donutChartProps,
@@ -67,6 +75,12 @@ import { formGroupProps, formErrorsProps, stepsProps, paginationProps } from './
67
75
  /** Complete registry, kept separate from the primitives used to compose controls. */
68
76
  export const componentProps = {
69
77
  ...foundationProps,
78
+ MTreeSelect: treeSelectProps,
79
+ MMasonry: masonryProps,
80
+ MHeatmap: heatmapProps,
81
+ MImageCropper: imageCropperProps,
82
+ MScheduler: schedulerProps,
83
+ MNotificationCenter: notificationCenterProps,
70
84
  MKanban: kanbanProps,
71
85
  MDonutChart: donutChartProps,
72
86
  MSparkline: sparklineProps,
@@ -29,6 +29,52 @@ 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
+ MTreeSelect: DefineComponent<
33
+ ComponentProps['MTreeSelect'] & {
34
+ 'onUpdate:modelValue'?: (value: string[]) => void
35
+ 'onUpdate:expanded'?: (value: string[]) => void
36
+ }
37
+ >
38
+ MMasonry: DefineComponent<ComponentProps['MMasonry']> & {
39
+ new (): {
40
+ $slots: {
41
+ item?: (props: {
42
+ item: import('../advanced-collections.js').MasonryItem
43
+ index: number
44
+ width: number
45
+ }) => unknown
46
+ }
47
+ }
48
+ }
49
+ MHeatmap: DefineComponent<
50
+ ComponentProps['MHeatmap'] & { 'onUpdate:modelValue'?: (date: CivilDate) => void }
51
+ >
52
+ MNotificationCenter: DefineComponent<
53
+ ComponentProps['MNotificationCenter'] & {
54
+ 'onUpdate:modelValue'?: (
55
+ items: import('../advanced-collections.js').MavisNotification[],
56
+ ) => void
57
+ 'onUpdate:filter'?: (filter: 'all' | 'unread') => void
58
+ onAction?: (id: string) => void
59
+ }
60
+ >
61
+ MImageCropper: DefineComponent<
62
+ ComponentProps['MImageCropper'] & {
63
+ 'onUpdate:modelValue'?: (crop: import('../image-crop.js').ImageCrop) => void
64
+ onExport?: (image: import('../image-crop.js').CropExport) => void
65
+ onError?: (failure: { stage: 'load' | 'export'; message: string }) => void
66
+ onLoad?: (size: { width: number; height: number }) => void
67
+ }
68
+ > & { new (): { export(): Promise<import('../image-crop.js').CropExport | undefined> } }
69
+ MScheduler: DefineComponent<
70
+ ComponentProps['MScheduler'] & {
71
+ 'onUpdate:modelValue'?: (events: import('../scheduler.js').SchedulerEvent[]) => void
72
+ 'onUpdate:date'?: (date: string) => void
73
+ onChange?: (change: import('../scheduler.js').SchedulerChange) => void
74
+ onSelect?: (id: string) => void
75
+ onError?: (message: string) => void
76
+ }
77
+ >
32
78
  MKanban: DefineComponent<
33
79
  ComponentProps['MKanban'] & {
34
80
  'onUpdate:modelValue'?: (cards: import('../dashboard.js').KanbanCard[]) => void
@@ -0,0 +1,413 @@
1
+ import {
2
+ computed,
3
+ defineComponent,
4
+ h,
5
+ markRaw,
6
+ mergeProps,
7
+ onMounted,
8
+ onActivated,
9
+ onDeactivated,
10
+ onScopeDispose,
11
+ ref,
12
+ shallowRef,
13
+ watch,
14
+ type Component,
15
+ } from '@vue/runtime-core'
16
+ import { createMotionSurface } from '../experimental.js'
17
+ import { componentMotion } from '../motion.js'
18
+ import {
19
+ fitImageCrop,
20
+ validateImageCrop,
21
+ moveImageCrop,
22
+ zoomImageCrop,
23
+ cropPresentation,
24
+ type ImageCrop,
25
+ type CropSource,
26
+ type CropExport,
27
+ type CropRotation,
28
+ } from '../image-crop.js'
29
+ import { imageCropperProps, type AdvancedGesture } from './advanced-props.js'
30
+ import type { AdvancedUI } from './advanced-collections.js'
31
+ import { useMavisTheme } from './theme.js'
32
+ export function createImageCropper(
33
+ ui: AdvancedUI & { CropPreview: Component },
34
+ platform: 'web' | 'native',
35
+ load: (src: string) => Promise<CropSource>,
36
+ ) {
37
+ return defineComponent({
38
+ name: 'MImageCropper',
39
+ inheritAttrs: false,
40
+ props: imageCropperProps,
41
+ emits: {
42
+ 'update:modelValue': (_v: ImageCrop) => true,
43
+ export: (_v: CropExport) => true,
44
+ load: (_v: { width: number; height: number }) => true,
45
+ error: (_v: { stage: 'load' | 'export'; message: string }) => true,
46
+ },
47
+ setup(props, { attrs, emit, expose }) {
48
+ const source = shallowRef<CropSource>(),
49
+ width = ref(320),
50
+ error = ref(''),
51
+ loading = ref(false),
52
+ exporting = ref(false),
53
+ draft = ref<ImageCrop>(),
54
+ surface = markRaw(createMotionSurface()),
55
+ { theme } = useMavisTheme()
56
+ let active = false,
57
+ epoch = 0,
58
+ gestureBase: ImageCrop | undefined,
59
+ gestureWidth = 0
60
+ const effective = computed(() => {
61
+ if (!source.value) return undefined
62
+ const value =
63
+ draft.value ?? props.modelValue ?? fitImageCrop(source.value, props.aspectRatio)
64
+ return validateImageCrop(source.value, value, props.aspectRatio)
65
+ })
66
+ const zoom = computed(() =>
67
+ source.value && effective.value
68
+ ? fitImageCrop(source.value, props.aspectRatio, effective.value.rotation).width /
69
+ effective.value.width
70
+ : 1,
71
+ )
72
+ function fail(stage: 'load' | 'export', failure: unknown) {
73
+ error.value = failure instanceof Error ? failure.message : String(failure)
74
+ emit('error', { stage, message: error.value })
75
+ }
76
+ function discard() {
77
+ epoch++
78
+ source.value?.dispose()
79
+ source.value = undefined
80
+ draft.value = undefined
81
+ gestureBase = undefined
82
+ loading.value = false
83
+ exporting.value = false
84
+ }
85
+ async function fetchSource() {
86
+ discard()
87
+ if (!active || !props.src) return
88
+ const request = epoch
89
+ loading.value = true
90
+ error.value = ''
91
+ try {
92
+ const result = await load(props.src)
93
+ if (!active || request !== epoch) {
94
+ result.dispose()
95
+ return
96
+ }
97
+ if (result.width * result.height > 40000000) {
98
+ result.dispose()
99
+ throw new RangeError('ImageCropper supports decoded images up to 40 megapixels.')
100
+ }
101
+ try {
102
+ validateImageCrop(
103
+ result,
104
+ props.modelValue ?? fitImageCrop(result, props.aspectRatio),
105
+ props.aspectRatio,
106
+ )
107
+ } catch (error) {
108
+ result.dispose()
109
+ throw error
110
+ }
111
+ source.value = markRaw(result)
112
+ emit('load', { width: result.width, height: result.height })
113
+ } catch (e) {
114
+ if (request === epoch) fail('load', e)
115
+ } finally {
116
+ if (request === epoch) loading.value = false
117
+ }
118
+ }
119
+ onMounted(() => {
120
+ active = true
121
+ void fetchSource()
122
+ })
123
+ onActivated(() => {
124
+ if (!active) {
125
+ active = true
126
+ void fetchSource()
127
+ }
128
+ })
129
+ onDeactivated(() => {
130
+ active = false
131
+ discard()
132
+ })
133
+ onScopeDispose(() => {
134
+ active = false
135
+ discard()
136
+ })
137
+ watch(
138
+ () => props.src,
139
+ () => {
140
+ if (active) void fetchSource()
141
+ },
142
+ )
143
+ watch(
144
+ () => [props.disabled, props.modelValue, props.aspectRatio],
145
+ () => {
146
+ draft.value = undefined
147
+ gestureBase = undefined
148
+ },
149
+ { flush: 'sync', deep: true },
150
+ )
151
+ onScopeDispose(
152
+ surface.use((owner) => {
153
+ let initialized = false
154
+ return watch(
155
+ () => [effective.value, width.value, props.animated, draft.value],
156
+ () => {
157
+ const crop = effective.value,
158
+ image = source.value
159
+ if (!crop || !image) return
160
+ const presentation = cropPresentation(image, crop, width.value),
161
+ values = { x: presentation.x, y: presentation.y, rotate: presentation.rotation }
162
+ if (initialized && props.animated && !draft.value)
163
+ owner.animate(values, componentMotion(theme.value, 'selection'))
164
+ else owner.set(values)
165
+ initialized = true
166
+ },
167
+ { immediate: true, flush: 'post' },
168
+ )
169
+ }),
170
+ )
171
+ function choose(value: ImageCrop) {
172
+ if (!props.disabled && source.value) {
173
+ validateImageCrop(source.value, value, props.aspectRatio)
174
+ emit('update:modelValue', value)
175
+ }
176
+ }
177
+ function gesture(event: AdvancedGesture) {
178
+ const image = source.value,
179
+ crop = effective.value
180
+ if (!image || !crop || props.disabled) return
181
+ if (event.phase === 'start') {
182
+ gestureBase = { ...crop }
183
+ gestureWidth = width.value
184
+ }
185
+ if (event.phase === 'move' && gestureBase) {
186
+ const base = gestureBase
187
+ const z = zoomImageCrop(
188
+ image,
189
+ base,
190
+ Math.min(
191
+ 8,
192
+ Math.max(
193
+ 1,
194
+ (fitImageCrop(image, props.aspectRatio, base.rotation).width / base.width) *
195
+ event.scale,
196
+ ),
197
+ ),
198
+ )
199
+ draft.value = moveImageCrop(
200
+ image,
201
+ z,
202
+ (-event.x * base.width) / gestureWidth,
203
+ (-event.y * base.width) / gestureWidth,
204
+ )
205
+ }
206
+ if (event.phase === 'end') {
207
+ const value = draft.value
208
+ gestureBase = undefined
209
+ draft.value = undefined
210
+ if (value) choose(value)
211
+ }
212
+ if (event.phase === 'cancel') {
213
+ gestureBase = undefined
214
+ draft.value = undefined
215
+ }
216
+ }
217
+ function pan(x: number, y: number) {
218
+ if (source.value && effective.value)
219
+ choose(
220
+ moveImageCrop(
221
+ source.value,
222
+ effective.value,
223
+ (x * effective.value.width) / 20,
224
+ (y * effective.value.height) / 20,
225
+ ),
226
+ )
227
+ }
228
+ async function exportImage() {
229
+ if (props.disabled || exporting.value || !source.value || !effective.value) return
230
+ const request = epoch,
231
+ image = source.value,
232
+ crop = { ...effective.value }
233
+ exporting.value = true
234
+ error.value = ''
235
+ try {
236
+ const result = await image.export(crop, props.output)
237
+ if (!active || request !== epoch || props.disabled) {
238
+ await result.dispose()
239
+ return
240
+ }
241
+ emit('export', result)
242
+ return result
243
+ } catch (e) {
244
+ if (request === epoch) fail('export', e)
245
+ } finally {
246
+ if (request === epoch) exporting.value = false
247
+ }
248
+ }
249
+ expose({ export: exportImage })
250
+ return () =>
251
+ h(
252
+ ui.Host,
253
+ mergeProps(attrs, {
254
+ id: props.id,
255
+ label: props.label,
256
+ ...(platform === 'web' ? { class: 'm-image-cropper' } : {}),
257
+ }),
258
+ () =>
259
+ h(ui.Column, { gap: 'md' }, () => [
260
+ h(ui.Text, { text: props.label, variant: 'heading' }),
261
+ h(
262
+ ui.Measure,
263
+ {
264
+ onWidth: (v: number) => {
265
+ if (v > 0 && Math.abs(width.value - v) > 0.5) {
266
+ gestureBase = undefined
267
+ draft.value = undefined
268
+ width.value = v
269
+ }
270
+ },
271
+ },
272
+ () =>
273
+ h(
274
+ ui.Gesture,
275
+ {
276
+ label: props.moveLabel,
277
+ disabled: props.disabled || !source.value,
278
+ onGesture: gesture,
279
+ onStep: (v: { x: number; y: number }) => pan(-v.x, -v.y),
280
+ },
281
+ () =>
282
+ h(
283
+ ui.Box,
284
+ {
285
+ backgroundColor: '#20232A',
286
+ radius: 'lg',
287
+ clipToBounds: true,
288
+ height: width.value / props.aspectRatio,
289
+ width: '100%',
290
+ ...(platform === 'web'
291
+ ? { style: { overflow: 'hidden', position: 'relative' } }
292
+ : {}),
293
+ },
294
+ () => {
295
+ const crop = effective.value,
296
+ image = source.value
297
+ if (!crop || !image)
298
+ return [
299
+ h(ui.Text, {
300
+ text: loading.value
301
+ ? props.loadingLabel
302
+ : error.value || props.loadingLabel,
303
+ tone: 'muted',
304
+ }),
305
+ ]
306
+ const presentation = cropPresentation(image, crop, width.value)
307
+ return [
308
+ h(ui.CropPreview, {
309
+ source: image,
310
+ width: presentation.width,
311
+ height: presentation.height,
312
+ motionSurface: surface,
313
+ }),
314
+ h(ui.Box, {
315
+ width: '100%',
316
+ height: '100%',
317
+ borderWidth: 1,
318
+ borderColor: '#FFFFFF',
319
+ accessibilityHidden: true,
320
+ isUserInteractionEnabled: false,
321
+ ...(platform === 'web'
322
+ ? {
323
+ style: {
324
+ position: 'absolute',
325
+ inset: 0,
326
+ pointerEvents: 'none',
327
+ border: '1px solid #FFFFFF',
328
+ boxSizing: 'border-box',
329
+ backgroundImage:
330
+ 'linear-gradient(90deg, transparent 33%, #ffffff50 33%, #ffffff50 33.4%, transparent 33.4%, transparent 66%, #ffffff50 66%, #ffffff50 66.4%, transparent 66.4%)',
331
+ },
332
+ }
333
+ : {}),
334
+ }),
335
+ ]
336
+ },
337
+ ),
338
+ ),
339
+ ),
340
+ error.value
341
+ ? h(ui.Text, {
342
+ text: error.value,
343
+ ...(platform === 'web' ? { role: 'alert' } : {}),
344
+ })
345
+ : null,
346
+ h(ui.Slider, {
347
+ label: props.zoomLabel,
348
+ min: 1,
349
+ max: 8,
350
+ step: 0.1,
351
+ modelValue: zoom.value,
352
+ disabled: props.disabled || !source.value,
353
+ 'onUpdate:modelValue': (v: number) => {
354
+ if (source.value && effective.value)
355
+ choose(zoomImageCrop(source.value, effective.value, v))
356
+ },
357
+ }),
358
+ h(ui.Row, { gap: 'xs', wrap: true }, () =>
359
+ [
360
+ [props.leftLabel, -1, 0],
361
+ [props.rightLabel, 1, 0],
362
+ [props.upLabel, 0, -1],
363
+ [props.downLabel, 0, 1],
364
+ ].map(([label, x, y]) =>
365
+ h(ui.Button, {
366
+ text: label,
367
+ variant: 'ghost',
368
+ size: 'sm',
369
+ disabled: props.disabled || !source.value,
370
+ onClick: () => pan(x as number, y as number),
371
+ }),
372
+ ),
373
+ ),
374
+ h(
375
+ ui.Stack,
376
+ { direction: 'column', responsive: { at: 520, direction: 'row' }, gap: 'sm' },
377
+ () => [
378
+ h(ui.Button, {
379
+ text: props.rotateLabel,
380
+ variant: 'secondary',
381
+ disabled: props.disabled || !source.value,
382
+ onClick: () => {
383
+ if (source.value && effective.value)
384
+ choose(
385
+ fitImageCrop(
386
+ source.value,
387
+ props.aspectRatio,
388
+ ((effective.value.rotation + 90) % 360) as CropRotation,
389
+ ),
390
+ )
391
+ },
392
+ }),
393
+ h(ui.Button, {
394
+ text: props.resetLabel,
395
+ variant: 'ghost',
396
+ disabled: props.disabled || !source.value,
397
+ onClick: () => {
398
+ if (source.value) choose(fitImageCrop(source.value, props.aspectRatio))
399
+ },
400
+ }),
401
+ h(ui.Button, {
402
+ text: props.exportLabel,
403
+ loading: exporting.value,
404
+ disabled: props.disabled || !source.value || exporting.value,
405
+ onClick: () => void exportImage(),
406
+ }),
407
+ ],
408
+ ),
409
+ ]),
410
+ )
411
+ },
412
+ })
413
+ }
package/src/vue/index.ts CHANGED
@@ -150,3 +150,11 @@ export * from './dashboard-props.js'
150
150
  export * from './dashboard-charts.js'
151
151
  export * from './dashboard-effects.js'
152
152
  export * from './kanban.js'
153
+
154
+ export * from './advanced-props.js'
155
+
156
+ export * from './advanced-collections.js'
157
+
158
+ export * from './image-cropper.js'
159
+
160
+ export * from './scheduler.js'