@getcortexlabs/mavis-core 0.1.0-rc.11.1 → 0.1.0-rc.12.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 +2 -2
- package/dist/advanced-collections.d.ts +74 -0
- package/dist/advanced-collections.d.ts.map +1 -0
- package/dist/advanced-collections.js +129 -0
- package/dist/advanced-collections.js.map +1 -0
- package/dist/capabilities.d.ts +7 -7
- package/dist/capabilities.d.ts.map +1 -1
- package/dist/capabilities.js +29 -4
- package/dist/capabilities.js.map +1 -1
- package/dist/creative-controls.d.ts +47 -0
- package/dist/creative-controls.d.ts.map +1 -0
- package/dist/creative-controls.js +112 -0
- package/dist/creative-controls.js.map +1 -0
- package/dist/dashboard.d.ts +72 -0
- package/dist/dashboard.d.ts.map +1 -0
- package/dist/dashboard.js +115 -0
- package/dist/dashboard.js.map +1 -0
- package/dist/image-crop.d.ts +49 -0
- package/dist/image-crop.d.ts.map +1 -0
- package/dist/image-crop.js +71 -0
- package/dist/image-crop.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/scheduler.d.ts +45 -0
- package/dist/scheduler.d.ts.map +1 -0
- package/dist/scheduler.js +142 -0
- package/dist/scheduler.js.map +1 -0
- package/dist/screen-components.d.ts +45 -0
- package/dist/screen-components.d.ts.map +1 -0
- package/dist/screen-components.js +23 -0
- package/dist/screen-components.js.map +1 -0
- package/dist/vue/advanced-collections.d.ts +486 -0
- package/dist/vue/advanced-collections.d.ts.map +1 -0
- package/dist/vue/advanced-collections.js +476 -0
- package/dist/vue/advanced-collections.js.map +1 -0
- package/dist/vue/advanced-props.d.ts +398 -0
- package/dist/vue/advanced-props.d.ts.map +1 -0
- package/dist/vue/advanced-props.js +128 -0
- package/dist/vue/advanced-props.js.map +1 -0
- package/dist/vue/animated-text.d.ts +101 -0
- package/dist/vue/animated-text.d.ts.map +1 -0
- package/dist/vue/animated-text.js +56 -0
- package/dist/vue/animated-text.js.map +1 -0
- package/dist/vue/chart.d.ts +1 -1
- package/dist/vue/command-palette.d.ts +3 -3
- package/dist/vue/component-props.d.ts +1045 -0
- package/dist/vue/component-props.d.ts.map +1 -1
- package/dist/vue/component-props.js +29 -0
- package/dist/vue/component-props.js.map +1 -1
- package/dist/vue/composer.d.ts +159 -0
- package/dist/vue/composer.d.ts.map +1 -0
- package/dist/vue/composer.js +142 -0
- package/dist/vue/composer.js.map +1 -0
- package/dist/vue/configurator.d.ts +5 -5
- package/dist/vue/creative-controls.d.ts +328 -0
- package/dist/vue/creative-controls.d.ts.map +1 -0
- package/dist/vue/creative-controls.js +396 -0
- package/dist/vue/creative-controls.js.map +1 -0
- package/dist/vue/creative-props.d.ts +260 -0
- package/dist/vue/creative-props.d.ts.map +1 -0
- package/dist/vue/creative-props.js +92 -0
- package/dist/vue/creative-props.js.map +1 -0
- package/dist/vue/dashboard-charts.d.ts +240 -0
- package/dist/vue/dashboard-charts.d.ts.map +1 -0
- package/dist/vue/dashboard-charts.js +263 -0
- package/dist/vue/dashboard-charts.js.map +1 -0
- package/dist/vue/dashboard-effects.d.ts +211 -0
- package/dist/vue/dashboard-effects.d.ts.map +1 -0
- package/dist/vue/dashboard-effects.js +235 -0
- package/dist/vue/dashboard-effects.js.map +1 -0
- package/dist/vue/dashboard-props.d.ts +244 -0
- package/dist/vue/dashboard-props.d.ts.map +1 -0
- package/dist/vue/dashboard-props.js +94 -0
- package/dist/vue/dashboard-props.js.map +1 -0
- package/dist/vue/date-picker.d.ts +8 -8
- package/dist/vue/discovery-controls.d.ts +2 -2
- package/dist/vue/global-components.d.ts +152 -0
- package/dist/vue/global-components.d.ts.map +1 -1
- package/dist/vue/image-cropper.d.ts +187 -0
- package/dist/vue/image-cropper.d.ts.map +1 -0
- package/dist/vue/image-cropper.js +310 -0
- package/dist/vue/image-cropper.js.map +1 -0
- package/dist/vue/index.d.ts +20 -0
- package/dist/vue/index.d.ts.map +1 -1
- package/dist/vue/index.js +20 -0
- package/dist/vue/index.js.map +1 -1
- package/dist/vue/kanban.d.ts +150 -0
- package/dist/vue/kanban.d.ts.map +1 -0
- package/dist/vue/kanban.js +267 -0
- package/dist/vue/kanban.js.map +1 -0
- package/dist/vue/marquee.d.ts +96 -0
- package/dist/vue/marquee.d.ts.map +1 -0
- package/dist/vue/marquee.js +186 -0
- package/dist/vue/marquee.js.map +1 -0
- package/dist/vue/menu.d.ts +2 -2
- package/dist/vue/navigation-controls.d.ts +1 -1
- package/dist/vue/pin-cell.d.ts +14 -0
- package/dist/vue/pin-cell.d.ts.map +1 -0
- package/dist/vue/pin-cell.js +19 -0
- package/dist/vue/pin-cell.js.map +1 -0
- package/dist/vue/pin-input.d.ts +14 -0
- package/dist/vue/pin-input.d.ts.map +1 -0
- package/dist/vue/pin-input.js +23 -0
- package/dist/vue/pin-input.js.map +1 -0
- package/dist/vue/scheduler.d.ts +229 -0
- package/dist/vue/scheduler.d.ts.map +1 -0
- package/dist/vue/scheduler.js +363 -0
- package/dist/vue/scheduler.js.map +1 -0
- package/dist/vue/screen-component-props.d.ts +236 -0
- package/dist/vue/screen-component-props.d.ts.map +1 -0
- package/dist/vue/screen-component-props.js +90 -0
- package/dist/vue/screen-component-props.js.map +1 -0
- package/dist/vue/scroll-frame.d.ts +223 -0
- package/dist/vue/scroll-frame.d.ts.map +1 -0
- package/dist/vue/scroll-frame.js +346 -0
- package/dist/vue/scroll-frame.js.map +1 -0
- package/dist/vue/speed-dial.d.ts +73 -0
- package/dist/vue/speed-dial.d.ts.map +1 -0
- package/dist/vue/speed-dial.js +78 -0
- package/dist/vue/speed-dial.js.map +1 -0
- package/dist/vue/swipe-actions.d.ts +1 -1
- package/dist/vue/swipe-deck.d.ts +120 -0
- package/dist/vue/swipe-deck.d.ts.map +1 -0
- package/dist/vue/swipe-deck.js +229 -0
- package/dist/vue/swipe-deck.js.map +1 -0
- package/dist/vue/time-picker.d.ts +6 -6
- package/dist/vue/tour.d.ts +120 -0
- package/dist/vue/tour.d.ts.map +1 -0
- package/dist/vue/tour.js +165 -0
- package/dist/vue/tour.js.map +1 -0
- package/dist/vue/tree-view.d.ts +1 -1
- package/dist/vue/wayfinding-controls.d.ts +2 -2
- package/dist/vue/workflows.d.ts +3 -3
- package/package.json +1 -1
- package/src/advanced-collections.ts +199 -0
- package/src/capabilities.ts +30 -4
- package/src/creative-controls.ts +169 -0
- package/src/dashboard.ts +164 -0
- package/src/image-crop.ts +125 -0
- package/src/index.ts +11 -0
- package/src/scheduler.ts +194 -0
- package/src/screen-components.ts +59 -0
- package/src/vue/advanced-collections.ts +679 -0
- package/src/vue/advanced-props.ts +144 -0
- package/src/vue/animated-text.ts +72 -0
- package/src/vue/component-props.ts +61 -0
- package/src/vue/composer.ts +192 -0
- package/src/vue/creative-controls.ts +524 -0
- package/src/vue/creative-props.ts +94 -0
- package/src/vue/dashboard-charts.ts +346 -0
- package/src/vue/dashboard-effects.ts +304 -0
- package/src/vue/dashboard-props.ts +95 -0
- package/src/vue/global-components.ts +162 -0
- package/src/vue/image-cropper.ts +413 -0
- package/src/vue/index.ts +28 -0
- package/src/vue/kanban.ts +360 -0
- package/src/vue/marquee.ts +248 -0
- package/src/vue/pin-cell.ts +26 -0
- package/src/vue/pin-input.ts +31 -0
- package/src/vue/scheduler.ts +505 -0
- package/src/vue/screen-component-props.ts +92 -0
- package/src/vue/scroll-frame.ts +429 -0
- package/src/vue/speed-dial.ts +108 -0
- package/src/vue/swipe-deck.ts +277 -0
- package/src/vue/tour.ts +239 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { computed, ref, watch } from '@vue/runtime-core'
|
|
2
|
+
import { normalizePin, pinLength } from '../screen-components.js'
|
|
3
|
+
import { useComponentContent } from './component-motion.js'
|
|
4
|
+
|
|
5
|
+
export function usePinInput(
|
|
6
|
+
props: {
|
|
7
|
+
modelValue: string
|
|
8
|
+
length: number
|
|
9
|
+
disabled: boolean
|
|
10
|
+
readonly: boolean
|
|
11
|
+
error?: string
|
|
12
|
+
},
|
|
13
|
+
emit: (event: 'update:modelValue' | 'complete' | 'focus' | 'blur', value?: string) => void,
|
|
14
|
+
) {
|
|
15
|
+
const focused = ref(false),
|
|
16
|
+
position = ref(0)
|
|
17
|
+
const value = computed(() => normalizePin(props.modelValue, props.length))
|
|
18
|
+
const feedback = useComponentContent(() => props.error, false)
|
|
19
|
+
const change = (raw: string) => {
|
|
20
|
+
if (props.disabled || props.readonly) return value.value
|
|
21
|
+
const next = normalizePin(raw, props.length)
|
|
22
|
+
if (next !== value.value) {
|
|
23
|
+
emit('update:modelValue', next)
|
|
24
|
+
if (next.length === props.length) emit('complete', next)
|
|
25
|
+
}
|
|
26
|
+
position.value = Math.min(next.length, props.length - 1)
|
|
27
|
+
return next
|
|
28
|
+
}
|
|
29
|
+
watch(() => props.length, pinLength, { immediate: true })
|
|
30
|
+
return { value, feedback, focused, position, change }
|
|
31
|
+
}
|
|
@@ -0,0 +1,505 @@
|
|
|
1
|
+
import {
|
|
2
|
+
computed,
|
|
3
|
+
defineComponent,
|
|
4
|
+
h,
|
|
5
|
+
mergeProps,
|
|
6
|
+
nextTick,
|
|
7
|
+
ref,
|
|
8
|
+
useId,
|
|
9
|
+
watch,
|
|
10
|
+
} from '@vue/runtime-core'
|
|
11
|
+
import { addCivilDays } from '../date.js'
|
|
12
|
+
import {
|
|
13
|
+
schedulerOffset,
|
|
14
|
+
schedulerLayout,
|
|
15
|
+
schedulerInstant,
|
|
16
|
+
schedulerCivilFromUTC,
|
|
17
|
+
changeSchedulerEvent,
|
|
18
|
+
type SchedulerClock,
|
|
19
|
+
type SchedulerChange,
|
|
20
|
+
type SchedulerEvent,
|
|
21
|
+
} from '../scheduler.js'
|
|
22
|
+
import { schedulerProps, type AdvancedGesture } from './advanced-props.js'
|
|
23
|
+
import { useComponentLayout } from './component-motion.js'
|
|
24
|
+
import { useMavisTheme } from './theme.js'
|
|
25
|
+
import type { AdvancedUI, AdvancedFocus } from './advanced-collections.js'
|
|
26
|
+
const time = (minutes: number) =>
|
|
27
|
+
`${String(Math.floor(minutes / 60)).padStart(2, '0')}:${String(minutes % 60).padStart(2, '0')}`
|
|
28
|
+
export function createScheduler(ui: AdvancedUI, platform: 'web' | 'native', clock: SchedulerClock) {
|
|
29
|
+
return defineComponent({
|
|
30
|
+
name: 'MScheduler',
|
|
31
|
+
inheritAttrs: false,
|
|
32
|
+
props: schedulerProps,
|
|
33
|
+
emits: {
|
|
34
|
+
'update:modelValue': (_v: SchedulerEvent[]) => true,
|
|
35
|
+
'update:date': (_v: string) => true,
|
|
36
|
+
change: (_v: SchedulerChange) => true,
|
|
37
|
+
error: (_v: string) => true,
|
|
38
|
+
select: (_id: string) => true,
|
|
39
|
+
},
|
|
40
|
+
setup(props, { attrs, emit }) {
|
|
41
|
+
const { theme } = useMavisTheme(),
|
|
42
|
+
uid = useId(),
|
|
43
|
+
host = ref<AdvancedFocus>(),
|
|
44
|
+
selected = ref<string | null>(null),
|
|
45
|
+
draft = ref<SchedulerChange>(),
|
|
46
|
+
failure = ref(''),
|
|
47
|
+
dragging = ref(false)
|
|
48
|
+
let original: SchedulerEvent | undefined,
|
|
49
|
+
kind: 'move' | 'resize' = 'move'
|
|
50
|
+
const shown = computed(() =>
|
|
51
|
+
draft.value ? changeSchedulerEvent(props.modelValue, draft.value) : props.modelValue,
|
|
52
|
+
)
|
|
53
|
+
const layout = computed(() =>
|
|
54
|
+
schedulerLayout(
|
|
55
|
+
shown.value,
|
|
56
|
+
props.date,
|
|
57
|
+
props.days,
|
|
58
|
+
props.timeZone,
|
|
59
|
+
clock,
|
|
60
|
+
props.startHour,
|
|
61
|
+
props.endHour,
|
|
62
|
+
),
|
|
63
|
+
)
|
|
64
|
+
const region = useComponentLayout(
|
|
65
|
+
() => [shown.value, props.date, props.days, props.hourHeight],
|
|
66
|
+
false,
|
|
67
|
+
() => props.animated && !dragging.value,
|
|
68
|
+
)
|
|
69
|
+
const describe = (event: SchedulerEvent) =>
|
|
70
|
+
`${event.title} · ${clock.parts(event.start, props.timeZone).date} ${time(clock.parts(event.start, props.timeZone).minute)}–${time(clock.parts(event.end, props.timeZone).minute)} · ${props.timeZone} ${schedulerOffset(event.start, props.timeZone, clock)} → ${schedulerOffset(event.end, props.timeZone, clock)}`
|
|
71
|
+
function cancel() {
|
|
72
|
+
draft.value = undefined
|
|
73
|
+
original = undefined
|
|
74
|
+
dragging.value = false
|
|
75
|
+
}
|
|
76
|
+
watch(
|
|
77
|
+
() => [
|
|
78
|
+
props.modelValue,
|
|
79
|
+
props.date,
|
|
80
|
+
props.days,
|
|
81
|
+
props.timeZone,
|
|
82
|
+
props.disabled,
|
|
83
|
+
props.startHour,
|
|
84
|
+
props.endHour,
|
|
85
|
+
props.slotMinutes,
|
|
86
|
+
props.hourHeight,
|
|
87
|
+
props.dayWidth,
|
|
88
|
+
],
|
|
89
|
+
cancel,
|
|
90
|
+
{ deep: true, flush: 'sync' },
|
|
91
|
+
)
|
|
92
|
+
function propose(
|
|
93
|
+
event: SchedulerEvent,
|
|
94
|
+
minutes: number,
|
|
95
|
+
days: number,
|
|
96
|
+
operation: 'move' | 'resize',
|
|
97
|
+
): SchedulerChange {
|
|
98
|
+
const target = operation === 'move' ? event.start : event.end,
|
|
99
|
+
civil = clock.parts(target, props.timeZone)
|
|
100
|
+
const nominal =
|
|
101
|
+
new Date(`${civil.date}T00:00:00.000Z`).getTime() +
|
|
102
|
+
(civil.minute + minutes) * 60000 +
|
|
103
|
+
days * 86400000
|
|
104
|
+
const next = schedulerCivilFromUTC(nominal)
|
|
105
|
+
const instant =
|
|
106
|
+
schedulerInstant(next, props.timeZone, clock, props.disambiguation) +
|
|
107
|
+
(target - Math.floor(target / 60000) * 60000)
|
|
108
|
+
const result = {
|
|
109
|
+
id: event.id,
|
|
110
|
+
start: operation === 'move' ? instant : event.start,
|
|
111
|
+
end: operation === 'move' ? instant + event.end - event.start : instant,
|
|
112
|
+
kind: operation,
|
|
113
|
+
}
|
|
114
|
+
changeSchedulerEvent(props.modelValue, result)
|
|
115
|
+
return result
|
|
116
|
+
}
|
|
117
|
+
function commit(change: SchedulerChange) {
|
|
118
|
+
if (props.disabled || props.modelValue.find((event) => event.id === change.id)?.disabled)
|
|
119
|
+
return
|
|
120
|
+
emit('update:modelValue', changeSchedulerEvent(props.modelValue, change))
|
|
121
|
+
emit('change', change)
|
|
122
|
+
}
|
|
123
|
+
function change(
|
|
124
|
+
event: SchedulerEvent,
|
|
125
|
+
minutes: number,
|
|
126
|
+
days: number,
|
|
127
|
+
operation: 'move' | 'resize',
|
|
128
|
+
) {
|
|
129
|
+
if (props.disabled || event.disabled) return
|
|
130
|
+
failure.value = ''
|
|
131
|
+
try {
|
|
132
|
+
commit(propose(event, minutes, days, operation))
|
|
133
|
+
} catch (e) {
|
|
134
|
+
failure.value = e instanceof Error ? e.message : String(e)
|
|
135
|
+
emit('error', failure.value)
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
function gesture(
|
|
139
|
+
event: SchedulerEvent,
|
|
140
|
+
operation: 'move' | 'resize',
|
|
141
|
+
input: AdvancedGesture,
|
|
142
|
+
) {
|
|
143
|
+
if (props.disabled || event.disabled) return
|
|
144
|
+
if (input.phase === 'start') {
|
|
145
|
+
original = { ...event }
|
|
146
|
+
kind = operation
|
|
147
|
+
dragging.value = true
|
|
148
|
+
failure.value = ''
|
|
149
|
+
}
|
|
150
|
+
if (input.phase === 'move' && original) {
|
|
151
|
+
const minutes =
|
|
152
|
+
Math.round(((input.y / props.hourHeight) * 60) / props.slotMinutes) *
|
|
153
|
+
props.slotMinutes,
|
|
154
|
+
days = kind === 'move' ? Math.round(input.x / props.dayWidth) : 0
|
|
155
|
+
try {
|
|
156
|
+
const proposal = propose(original, minutes, days, kind),
|
|
157
|
+
start = clock.parts(proposal.start, props.timeZone),
|
|
158
|
+
end = clock.parts(proposal.end, props.timeZone)
|
|
159
|
+
if (
|
|
160
|
+
start.date < props.date ||
|
|
161
|
+
start.date > addCivilDays(props.date, props.days - 1) ||
|
|
162
|
+
start.minute < props.startHour * 60 ||
|
|
163
|
+
end.date !== start.date ||
|
|
164
|
+
end.minute > props.endHour * 60 ||
|
|
165
|
+
end.minute <= start.minute
|
|
166
|
+
) {
|
|
167
|
+
draft.value = undefined
|
|
168
|
+
return
|
|
169
|
+
}
|
|
170
|
+
draft.value = proposal
|
|
171
|
+
} catch (e) {
|
|
172
|
+
draft.value = undefined
|
|
173
|
+
failure.value = e instanceof Error ? e.message : String(e)
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
if (input.phase === 'end') {
|
|
177
|
+
const pending = draft.value
|
|
178
|
+
cancel()
|
|
179
|
+
if (pending) commit(pending)
|
|
180
|
+
else if (failure.value) emit('error', failure.value)
|
|
181
|
+
}
|
|
182
|
+
if (input.phase === 'cancel') cancel()
|
|
183
|
+
}
|
|
184
|
+
function focus(event: SchedulerEvent) {
|
|
185
|
+
selected.value = event.id
|
|
186
|
+
emit('select', event.id)
|
|
187
|
+
void nextTick(() => host.value?.focus(`${uid}-earlier`))
|
|
188
|
+
}
|
|
189
|
+
return () => {
|
|
190
|
+
if (
|
|
191
|
+
!Number.isFinite(props.hourHeight) ||
|
|
192
|
+
props.hourHeight < 48 ||
|
|
193
|
+
props.hourHeight > 180 ||
|
|
194
|
+
!Number.isFinite(props.dayWidth) ||
|
|
195
|
+
props.dayWidth < 140 ||
|
|
196
|
+
props.dayWidth > 500 ||
|
|
197
|
+
!Number.isInteger(props.slotMinutes) ||
|
|
198
|
+
props.slotMinutes < 5 ||
|
|
199
|
+
props.slotMinutes > 60 ||
|
|
200
|
+
60 % props.slotMinutes !== 0
|
|
201
|
+
)
|
|
202
|
+
throw new RangeError(
|
|
203
|
+
'Scheduler needs hourHeight 48–180, dayWidth 140–500 and a 5–60 minute divisor of an hour.',
|
|
204
|
+
)
|
|
205
|
+
const grid = layout.value,
|
|
206
|
+
gridHeight = (props.endHour - props.startHour) * props.hourHeight + 44,
|
|
207
|
+
totalWidth = 64 + props.days * props.dayWidth,
|
|
208
|
+
event = props.modelValue.find((item) => item.id === selected.value)
|
|
209
|
+
return h(
|
|
210
|
+
ui.Host,
|
|
211
|
+
mergeProps(attrs, {
|
|
212
|
+
id: props.id,
|
|
213
|
+
label: props.label,
|
|
214
|
+
ref: host,
|
|
215
|
+
...(platform === 'web' ? { class: 'm-scheduler' } : {}),
|
|
216
|
+
}),
|
|
217
|
+
() =>
|
|
218
|
+
h(ui.Column, { gap: 'md', motionRegion: region }, () => [
|
|
219
|
+
h(ui.Text, { text: props.label, variant: 'heading' }),
|
|
220
|
+
h(ui.Text, {
|
|
221
|
+
text: `${props.date} · ${props.timeZone}`,
|
|
222
|
+
tone: 'muted',
|
|
223
|
+
variant: 'caption',
|
|
224
|
+
}),
|
|
225
|
+
h(ui.Row, { gap: 'sm' }, () => [
|
|
226
|
+
h(ui.Button, {
|
|
227
|
+
text: props.previousLabel,
|
|
228
|
+
variant: 'secondary',
|
|
229
|
+
disabled: props.disabled,
|
|
230
|
+
onClick: () => {
|
|
231
|
+
if (!props.disabled) emit('update:date', addCivilDays(props.date, -props.days))
|
|
232
|
+
},
|
|
233
|
+
}),
|
|
234
|
+
h(ui.Button, {
|
|
235
|
+
text: props.nextLabel,
|
|
236
|
+
variant: 'secondary',
|
|
237
|
+
disabled: props.disabled,
|
|
238
|
+
onClick: () => {
|
|
239
|
+
if (!props.disabled) emit('update:date', addCivilDays(props.date, props.days))
|
|
240
|
+
},
|
|
241
|
+
}),
|
|
242
|
+
]),
|
|
243
|
+
h(ui.Scroll, {}, () =>
|
|
244
|
+
h(ui.Canvas, { height: gridHeight, width: totalWidth }, () => [
|
|
245
|
+
...Array.from({ length: props.endHour - props.startHour }, (_, i) =>
|
|
246
|
+
h(
|
|
247
|
+
ui.Cell,
|
|
248
|
+
{
|
|
249
|
+
key: `hour-${i}`,
|
|
250
|
+
x: 0,
|
|
251
|
+
y: 44 + i * props.hourHeight,
|
|
252
|
+
width: totalWidth,
|
|
253
|
+
height: props.hourHeight,
|
|
254
|
+
},
|
|
255
|
+
() =>
|
|
256
|
+
h(
|
|
257
|
+
ui.Box,
|
|
258
|
+
{
|
|
259
|
+
height: '100%',
|
|
260
|
+
borderColor: theme.value.colors.border,
|
|
261
|
+
borderWidth: 0.5,
|
|
262
|
+
...(platform === 'web'
|
|
263
|
+
? {
|
|
264
|
+
style: {
|
|
265
|
+
borderTop: `1px solid ${theme.value.colors.border}`,
|
|
266
|
+
boxSizing: 'border-box',
|
|
267
|
+
},
|
|
268
|
+
}
|
|
269
|
+
: {}),
|
|
270
|
+
accessibilityHidden: true,
|
|
271
|
+
},
|
|
272
|
+
() =>
|
|
273
|
+
h(ui.Text, {
|
|
274
|
+
text: time((props.startHour + i) * 60),
|
|
275
|
+
variant: 'caption',
|
|
276
|
+
tone: 'muted',
|
|
277
|
+
width: 60,
|
|
278
|
+
}),
|
|
279
|
+
),
|
|
280
|
+
),
|
|
281
|
+
),
|
|
282
|
+
...grid.flatMap((column, day) => [
|
|
283
|
+
h(
|
|
284
|
+
ui.Cell,
|
|
285
|
+
{
|
|
286
|
+
key: `day-${column.date}`,
|
|
287
|
+
x: 64 + day * props.dayWidth,
|
|
288
|
+
y: 0,
|
|
289
|
+
width: props.dayWidth,
|
|
290
|
+
height: 40,
|
|
291
|
+
},
|
|
292
|
+
() =>
|
|
293
|
+
h(ui.Text, {
|
|
294
|
+
text: column.date,
|
|
295
|
+
variant: 'body',
|
|
296
|
+
weight: '600',
|
|
297
|
+
align: 'center',
|
|
298
|
+
}),
|
|
299
|
+
),
|
|
300
|
+
...column.segments.map((segment) => {
|
|
301
|
+
const item = segment.event,
|
|
302
|
+
editable = !props.disabled && !item.disabled,
|
|
303
|
+
full =
|
|
304
|
+
segment.startsHere &&
|
|
305
|
+
segment.endsHere &&
|
|
306
|
+
((segment.bottom - segment.top) / 60) * props.hourHeight >= 100
|
|
307
|
+
return h(
|
|
308
|
+
ui.Cell,
|
|
309
|
+
{
|
|
310
|
+
key: `event-${column.date}-${item.id}`,
|
|
311
|
+
x:
|
|
312
|
+
64 +
|
|
313
|
+
day * props.dayWidth +
|
|
314
|
+
(segment.lane * props.dayWidth) / segment.lanes +
|
|
315
|
+
3,
|
|
316
|
+
y: 44 + ((segment.top - props.startHour * 60) / 60) * props.hourHeight,
|
|
317
|
+
width: props.dayWidth / segment.lanes - 6,
|
|
318
|
+
height: Math.max(
|
|
319
|
+
28,
|
|
320
|
+
((segment.bottom - segment.top) / 60) * props.hourHeight - 3,
|
|
321
|
+
),
|
|
322
|
+
},
|
|
323
|
+
() =>
|
|
324
|
+
h(
|
|
325
|
+
ui.Box,
|
|
326
|
+
{
|
|
327
|
+
height: '100%',
|
|
328
|
+
backgroundColor: theme.value.colors.surface,
|
|
329
|
+
radius: 'sm',
|
|
330
|
+
borderWidth: 1,
|
|
331
|
+
borderColor: item.color ?? theme.value.colors.primary,
|
|
332
|
+
clipToBounds: true,
|
|
333
|
+
...(platform === 'web'
|
|
334
|
+
? {
|
|
335
|
+
style: {
|
|
336
|
+
overflow: 'hidden',
|
|
337
|
+
border: `1px solid ${item.color ?? theme.value.colors.primary}`,
|
|
338
|
+
borderLeftWidth: '3px',
|
|
339
|
+
boxSizing: 'border-box',
|
|
340
|
+
},
|
|
341
|
+
}
|
|
342
|
+
: {}),
|
|
343
|
+
},
|
|
344
|
+
() =>
|
|
345
|
+
h(ui.Column, { gap: 'none' }, () => [
|
|
346
|
+
full
|
|
347
|
+
? h(
|
|
348
|
+
ui.Gesture,
|
|
349
|
+
{
|
|
350
|
+
label: `${props.moveLabel}: ${item.title}`,
|
|
351
|
+
disabled: !editable,
|
|
352
|
+
onGesture: (input: AdvancedGesture) =>
|
|
353
|
+
gesture(item, 'move', input),
|
|
354
|
+
onStep: (v: { x: number; y: number }) =>
|
|
355
|
+
change(item, v.y * props.slotMinutes, v.x, 'move'),
|
|
356
|
+
},
|
|
357
|
+
() =>
|
|
358
|
+
h(ui.Text, {
|
|
359
|
+
text: '⠿',
|
|
360
|
+
variant: 'caption',
|
|
361
|
+
align: 'center',
|
|
362
|
+
accessibilityHidden: true,
|
|
363
|
+
}),
|
|
364
|
+
)
|
|
365
|
+
: null,
|
|
366
|
+
h(ui.Button, {
|
|
367
|
+
text: item.title,
|
|
368
|
+
height: full
|
|
369
|
+
? undefined
|
|
370
|
+
: Math.max(
|
|
371
|
+
4,
|
|
372
|
+
((segment.bottom - segment.top) / 60) * props.hourHeight -
|
|
373
|
+
3,
|
|
374
|
+
),
|
|
375
|
+
...(platform === 'web'
|
|
376
|
+
? {
|
|
377
|
+
style: {
|
|
378
|
+
padding: '0 4px',
|
|
379
|
+
minHeight: 0,
|
|
380
|
+
fontSize: '12px',
|
|
381
|
+
overflow: 'hidden',
|
|
382
|
+
},
|
|
383
|
+
}
|
|
384
|
+
: {}),
|
|
385
|
+
accessibilityLabel: describe(item),
|
|
386
|
+
size: 'sm',
|
|
387
|
+
variant: selected.value === item.id ? 'secondary' : 'ghost',
|
|
388
|
+
disabled: props.disabled || item.disabled,
|
|
389
|
+
onClick: () => focus(item),
|
|
390
|
+
}),
|
|
391
|
+
full
|
|
392
|
+
? h(
|
|
393
|
+
ui.Gesture,
|
|
394
|
+
{
|
|
395
|
+
label: `${props.resizeLabel}: ${item.title}`,
|
|
396
|
+
disabled: !editable,
|
|
397
|
+
onGesture: (input: AdvancedGesture) =>
|
|
398
|
+
gesture(item, 'resize', input),
|
|
399
|
+
onStep: (v: { x: number; y: number }) =>
|
|
400
|
+
change(
|
|
401
|
+
item,
|
|
402
|
+
(v.y || v.x) * props.slotMinutes,
|
|
403
|
+
0,
|
|
404
|
+
'resize',
|
|
405
|
+
),
|
|
406
|
+
},
|
|
407
|
+
() =>
|
|
408
|
+
h(ui.Text, {
|
|
409
|
+
text: '━',
|
|
410
|
+
variant: 'caption',
|
|
411
|
+
align: 'center',
|
|
412
|
+
accessibilityHidden: true,
|
|
413
|
+
}),
|
|
414
|
+
)
|
|
415
|
+
: null,
|
|
416
|
+
]),
|
|
417
|
+
),
|
|
418
|
+
)
|
|
419
|
+
}),
|
|
420
|
+
]),
|
|
421
|
+
]),
|
|
422
|
+
),
|
|
423
|
+
!grid.some((column) => column.segments.length)
|
|
424
|
+
? h(ui.Text, { text: props.emptyLabel, tone: 'muted' })
|
|
425
|
+
: null,
|
|
426
|
+
failure.value
|
|
427
|
+
? h(ui.Text, {
|
|
428
|
+
text: failure.value,
|
|
429
|
+
...(platform === 'web' ? { role: 'alert' } : {}),
|
|
430
|
+
})
|
|
431
|
+
: null,
|
|
432
|
+
h(ui.Column, { gap: 'xs' }, () =>
|
|
433
|
+
props.modelValue.map((item) =>
|
|
434
|
+
h(ui.Button, {
|
|
435
|
+
key: item.id,
|
|
436
|
+
text: describe(item),
|
|
437
|
+
variant: selected.value === item.id ? 'secondary' : 'ghost',
|
|
438
|
+
disabled: props.disabled || item.disabled,
|
|
439
|
+
onClick: () => focus(item),
|
|
440
|
+
}),
|
|
441
|
+
),
|
|
442
|
+
),
|
|
443
|
+
event
|
|
444
|
+
? h(ui.Card, { padding: 'md' }, () =>
|
|
445
|
+
h(ui.Column, { gap: 'sm' }, () => [
|
|
446
|
+
h(ui.Text, { text: describe(event), variant: 'body', weight: '600' }),
|
|
447
|
+
h(
|
|
448
|
+
ui.Stack,
|
|
449
|
+
{
|
|
450
|
+
direction: 'column',
|
|
451
|
+
responsive: { at: 600, direction: 'row' },
|
|
452
|
+
gap: 'xs',
|
|
453
|
+
},
|
|
454
|
+
() => [
|
|
455
|
+
h(ui.Button, {
|
|
456
|
+
id: `${uid}-earlier`,
|
|
457
|
+
text: props.earlierLabel,
|
|
458
|
+
variant: 'secondary',
|
|
459
|
+
disabled: props.disabled || event.disabled,
|
|
460
|
+
onClick: () => change(event, -props.slotMinutes, 0, 'move'),
|
|
461
|
+
}),
|
|
462
|
+
h(ui.Button, {
|
|
463
|
+
text: props.laterLabel,
|
|
464
|
+
variant: 'secondary',
|
|
465
|
+
disabled: props.disabled || event.disabled,
|
|
466
|
+
onClick: () => change(event, props.slotMinutes, 0, 'move'),
|
|
467
|
+
}),
|
|
468
|
+
h(ui.Button, {
|
|
469
|
+
text: props.previousDayLabel,
|
|
470
|
+
variant: 'ghost',
|
|
471
|
+
disabled: props.disabled || event.disabled,
|
|
472
|
+
onClick: () => change(event, 0, -1, 'move'),
|
|
473
|
+
}),
|
|
474
|
+
h(ui.Button, {
|
|
475
|
+
text: props.nextDayLabel,
|
|
476
|
+
variant: 'ghost',
|
|
477
|
+
disabled: props.disabled || event.disabled,
|
|
478
|
+
onClick: () => change(event, 0, 1, 'move'),
|
|
479
|
+
}),
|
|
480
|
+
h(ui.Button, {
|
|
481
|
+
text: props.shorterLabel,
|
|
482
|
+
variant: 'ghost',
|
|
483
|
+
disabled:
|
|
484
|
+
props.disabled ||
|
|
485
|
+
event.disabled ||
|
|
486
|
+
event.end - event.start <= props.slotMinutes * 60000,
|
|
487
|
+
onClick: () => change(event, -props.slotMinutes, 0, 'resize'),
|
|
488
|
+
}),
|
|
489
|
+
h(ui.Button, {
|
|
490
|
+
text: props.longerLabel,
|
|
491
|
+
variant: 'ghost',
|
|
492
|
+
disabled: props.disabled || event.disabled,
|
|
493
|
+
onClick: () => change(event, props.slotMinutes, 0, 'resize'),
|
|
494
|
+
}),
|
|
495
|
+
],
|
|
496
|
+
),
|
|
497
|
+
]),
|
|
498
|
+
)
|
|
499
|
+
: null,
|
|
500
|
+
]),
|
|
501
|
+
)
|
|
502
|
+
}
|
|
503
|
+
},
|
|
504
|
+
})
|
|
505
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import type { PropType } from '@vue/runtime-core'
|
|
2
|
+
import type { ComposerAttachment, RefreshAction, SpeedDialAction } from '../screen-components.js'
|
|
3
|
+
import { textProps, inputProps, buttonProps } from './props.js'
|
|
4
|
+
|
|
5
|
+
const label = { type: String, required: true as const }
|
|
6
|
+
export const animatedTextProps = {
|
|
7
|
+
id: String,
|
|
8
|
+
text: label,
|
|
9
|
+
variant: { ...textProps.variant, default: 'title' },
|
|
10
|
+
tone: textProps.tone,
|
|
11
|
+
by: { type: String as PropType<'word' | 'letter'>, default: 'word' },
|
|
12
|
+
duration: { type: Number, default: 650 },
|
|
13
|
+
stagger: { type: Number, default: 35 },
|
|
14
|
+
distance: { type: Number, default: 16 },
|
|
15
|
+
animated: { type: Boolean, default: true },
|
|
16
|
+
appear: { type: Boolean, default: true },
|
|
17
|
+
replayKey: { type: [String, Number], default: 0 },
|
|
18
|
+
}
|
|
19
|
+
export const composerProps = {
|
|
20
|
+
id: String,
|
|
21
|
+
label,
|
|
22
|
+
modelValue: { type: String, default: '' },
|
|
23
|
+
placeholder: String,
|
|
24
|
+
disabled: Boolean,
|
|
25
|
+
readonly: Boolean,
|
|
26
|
+
loading: Boolean,
|
|
27
|
+
maxLength: inputProps.maxLength,
|
|
28
|
+
rows: { type: Number, default: 2 },
|
|
29
|
+
error: String,
|
|
30
|
+
attachments: { type: Array as PropType<readonly ComposerAttachment[]>, default: () => [] },
|
|
31
|
+
attachable: { type: Boolean, default: true },
|
|
32
|
+
attachLabel: { type: String, default: 'Add attachment' },
|
|
33
|
+
removeLabel: { type: String, default: 'Remove attachment' },
|
|
34
|
+
sendLabel: { type: String, default: 'Send message' },
|
|
35
|
+
sendingLabel: { type: String, default: 'Sending' },
|
|
36
|
+
/** Use only for an overlay composer; ordinary flowing content follows its screen. */
|
|
37
|
+
followKeyboard: Boolean,
|
|
38
|
+
keyboardOffset: { type: Number, default: 0 },
|
|
39
|
+
/** Ctrl/Cmd+Enter only. Plain Enter always retains multiline editing. */
|
|
40
|
+
shortcut: { type: Boolean, default: true },
|
|
41
|
+
}
|
|
42
|
+
export const pinInputProps = {
|
|
43
|
+
id: String,
|
|
44
|
+
label,
|
|
45
|
+
modelValue: { type: String, default: '' },
|
|
46
|
+
length: { type: Number, default: 6 },
|
|
47
|
+
disabled: Boolean,
|
|
48
|
+
readonly: Boolean,
|
|
49
|
+
required: Boolean,
|
|
50
|
+
name: String,
|
|
51
|
+
form: String,
|
|
52
|
+
error: String,
|
|
53
|
+
helperText: String,
|
|
54
|
+
}
|
|
55
|
+
export const speedDialProps = {
|
|
56
|
+
id: String,
|
|
57
|
+
label,
|
|
58
|
+
open: Boolean,
|
|
59
|
+
disabled: Boolean,
|
|
60
|
+
actions: { type: Array as PropType<readonly SpeedDialAction[]>, required: true as const },
|
|
61
|
+
icon: { ...buttonProps.icon, default: 'plus' },
|
|
62
|
+
closeLabel: { type: String, default: 'Close actions' },
|
|
63
|
+
direction: { type: String as PropType<'up' | 'down'>, default: 'up' },
|
|
64
|
+
}
|
|
65
|
+
export const refreshControlProps = {
|
|
66
|
+
id: String,
|
|
67
|
+
label,
|
|
68
|
+
refresh: { type: Function as PropType<RefreshAction>, required: true as const },
|
|
69
|
+
height: { type: Number, default: 480 },
|
|
70
|
+
disabled: Boolean,
|
|
71
|
+
threshold: { type: Number, default: 80 },
|
|
72
|
+
refreshLabel: { type: String, default: 'Refresh' },
|
|
73
|
+
refreshingLabel: { type: String, default: 'Refreshing' },
|
|
74
|
+
successLabel: { type: String, default: 'Up to date' },
|
|
75
|
+
errorLabel: { type: String, default: 'Could not refresh' },
|
|
76
|
+
retryLabel: { type: String, default: 'Try again' },
|
|
77
|
+
cancelLabel: { type: String, default: 'Cancel refresh' },
|
|
78
|
+
}
|
|
79
|
+
export const collapsibleHeaderProps = {
|
|
80
|
+
id: String,
|
|
81
|
+
title: label,
|
|
82
|
+
subtitle: String,
|
|
83
|
+
image: String,
|
|
84
|
+
height: { type: Number, default: 540 },
|
|
85
|
+
expandedHeight: { type: Number, default: 240 },
|
|
86
|
+
collapsedHeight: { type: Number, default: 64 },
|
|
87
|
+
sectionHeight: { type: Number, default: 0 },
|
|
88
|
+
parallax: { type: Number, default: 0.35 },
|
|
89
|
+
backLabel: { type: String, default: 'Go back' },
|
|
90
|
+
back: Boolean,
|
|
91
|
+
topLabel: { type: String, default: 'Back to top' },
|
|
92
|
+
}
|