@getcortexlabs/mavis-core 0.1.0-rc.15 → 0.1.0-rc.16
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/avatar.d.ts +5 -0
- package/dist/avatar.d.ts.map +1 -1
- package/dist/capabilities.d.ts +17 -1827
- package/dist/capabilities.d.ts.map +1 -1
- package/dist/capabilities.js +9 -90
- package/dist/capabilities.js.map +1 -1
- package/dist/contracts.d.ts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/vue/advanced-collections.d.ts +16 -16
- package/dist/vue/animated-text.d.ts +4 -4
- package/dist/vue/chart.d.ts +5 -5
- package/dist/vue/command-palette.d.ts +4 -4
- package/dist/vue/component-props.d.ts +90 -20
- package/dist/vue/component-props.d.ts.map +1 -1
- package/dist/vue/component-props.js +4 -0
- package/dist/vue/component-props.js.map +1 -1
- package/dist/vue/composer.d.ts +11 -9
- package/dist/vue/composer.d.ts.map +1 -1
- package/dist/vue/composer.js +12 -16
- package/dist/vue/composer.js.map +1 -1
- package/dist/vue/configurator.d.ts +16 -16
- package/dist/vue/creative-controls.d.ts +11 -11
- package/dist/vue/dashboard-charts.d.ts +6 -6
- package/dist/vue/dashboard-effects.d.ts +7 -7
- package/dist/vue/date-picker.d.ts +52 -52
- package/dist/vue/discovery-controls.d.ts +8 -8
- package/dist/vue/editor-controls.d.ts +223 -0
- package/dist/vue/editor-controls.d.ts.map +1 -0
- package/dist/vue/editor-controls.js +323 -0
- package/dist/vue/editor-controls.js.map +1 -0
- package/dist/vue/global-components.d.ts +22 -1
- package/dist/vue/global-components.d.ts.map +1 -1
- package/dist/vue/image-cropper.d.ts +8 -8
- package/dist/vue/image-cropper.d.ts.map +1 -1
- package/dist/vue/index.d.ts +3 -2
- package/dist/vue/index.d.ts.map +1 -1
- package/dist/vue/index.js +1 -0
- package/dist/vue/index.js.map +1 -1
- package/dist/vue/kanban.d.ts +2 -2
- package/dist/vue/marquee.d.ts +4 -4
- package/dist/vue/menu.d.ts +4 -4
- package/dist/vue/number-flow.d.ts +3 -3
- package/dist/vue/platform.d.ts +1 -2
- package/dist/vue/platform.d.ts.map +1 -1
- package/dist/vue/platform.js.map +1 -1
- package/dist/vue/props.d.ts +40 -40
- package/dist/vue/reveal-state.d.ts +1 -1
- package/dist/vue/scheduler.d.ts +10 -10
- package/dist/vue/screen-component-props.d.ts +10 -0
- package/dist/vue/screen-component-props.d.ts.map +1 -1
- package/dist/vue/screen-component-props.js +6 -0
- package/dist/vue/screen-component-props.js.map +1 -1
- package/dist/vue/scroll-frame.d.ts +28 -6
- package/dist/vue/scroll-frame.d.ts.map +1 -1
- package/dist/vue/scroll-frame.js +51 -4
- package/dist/vue/scroll-frame.js.map +1 -1
- package/dist/vue/speed-dial.d.ts +3 -3
- package/dist/vue/swipe-actions.d.ts +3 -3
- package/dist/vue/swipe-deck.d.ts +3 -3
- package/dist/vue/theme-provider.d.ts +17 -2
- package/dist/vue/theme-provider.d.ts.map +1 -1
- package/dist/vue/theme-provider.js +7 -1
- package/dist/vue/theme-provider.js.map +1 -1
- package/dist/vue/theme.d.ts +7 -0
- package/dist/vue/theme.d.ts.map +1 -1
- package/dist/vue/theme.js +23 -19
- package/dist/vue/theme.js.map +1 -1
- package/dist/vue/time-picker.d.ts +20 -20
- package/dist/vue/tour.d.ts +3 -3
- package/dist/vue/tree-view.d.ts +3 -3
- package/dist/vue/wayfinding-controls.d.ts +1 -1
- package/dist/vue/workflows.d.ts +3 -3
- package/package.json +1 -1
- package/src/avatar.ts +6 -0
- package/src/capabilities.ts +9 -90
- package/src/index.ts +2 -7
- package/src/vue/component-props.ts +4 -0
- package/src/vue/composer.ts +22 -16
- package/src/vue/editor-controls.ts +370 -0
- package/src/vue/global-components.ts +21 -1
- package/src/vue/index.ts +3 -1
- package/src/vue/platform.ts +1 -2
- package/src/vue/screen-component-props.ts +6 -0
- package/src/vue/scroll-frame.ts +70 -5
- package/src/vue/theme-provider.ts +14 -1
- package/src/vue/theme.ts +31 -18
- package/dist/macos-capabilities.generated.d.ts +0 -1738
- package/dist/macos-capabilities.generated.d.ts.map +0 -1
- package/dist/macos-capabilities.generated.js +0 -4191
- package/dist/macos-capabilities.generated.js.map +0 -1
- package/src/macos-capabilities.generated.ts +0 -4190
package/src/capabilities.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { macosCapabilities } from './macos-capabilities.generated.js'
|
|
2
1
|
import { componentContracts } from './contracts.js'
|
|
3
|
-
export { macosCapabilities } from './macos-capabilities.generated.js'
|
|
4
2
|
|
|
5
3
|
/** Source capabilities, not a promise that every feature is in the last npm release. */
|
|
6
4
|
export const componentNames = [
|
|
@@ -25,6 +23,9 @@ export const componentNames = [
|
|
|
25
23
|
'MMarquee',
|
|
26
24
|
'MCollapsibleHeader',
|
|
27
25
|
'MRefreshControl',
|
|
26
|
+
'MTagInput',
|
|
27
|
+
'MAvatarGroup',
|
|
28
|
+
'MSearchBar',
|
|
28
29
|
'MComposer',
|
|
29
30
|
'MSpeedDial',
|
|
30
31
|
'MPinInput',
|
|
@@ -145,7 +146,7 @@ const nativeFoundation = {
|
|
|
145
146
|
streaming: 'unsupported',
|
|
146
147
|
rsc: 'unsupported',
|
|
147
148
|
},
|
|
148
|
-
motion: { engine: 'jolt', minimum: '0.1.0-rc.
|
|
149
|
+
motion: { engine: 'jolt', minimum: '0.1.0-rc.18', start: 'native-loaded' },
|
|
149
150
|
lifecycle: { unload: 'release-native-resources', reload: 'reattach', dispose: 'final' },
|
|
150
151
|
compatibility: {
|
|
151
152
|
node: '22.23.3',
|
|
@@ -153,7 +154,7 @@ const nativeFoundation = {
|
|
|
153
154
|
nativeCore: '9.1.4',
|
|
154
155
|
ios: '9.1.0',
|
|
155
156
|
android: '9.1.1',
|
|
156
|
-
jolt: '0.1.0-rc.
|
|
157
|
+
jolt: '0.1.0-rc.18',
|
|
157
158
|
peerOverrides: 'examples/native-adapters/package.json',
|
|
158
159
|
upstreamIssue: 'https://github.com/rafaelaugustos/jolt/issues/517',
|
|
159
160
|
},
|
|
@@ -168,69 +169,11 @@ const nativeFoundation = {
|
|
|
168
169
|
export const targetCapabilities = {
|
|
169
170
|
version: 1,
|
|
170
171
|
source: 'repository',
|
|
171
|
-
publishedBaseline: '0.1.0-rc.
|
|
172
|
+
publishedBaseline: '0.1.0-rc.16',
|
|
172
173
|
developmentMotion: {
|
|
173
174
|
availability: 'published',
|
|
174
175
|
joltCommit: null,
|
|
175
|
-
publishedJoltRelease: '0.1.0-rc.
|
|
176
|
-
macos: {
|
|
177
|
-
availability: 'published',
|
|
178
|
-
joltSwiftRelease: '0.1.0-rc.16',
|
|
179
|
-
reveal: 'experimental',
|
|
180
|
-
textEffects: { status: 'experimental', minimumOS: 15, macOS14: 'static' },
|
|
181
|
-
numberFlow: { status: 'experimental', minimumOS: 15, macOS14: 'static' },
|
|
182
|
-
confetti: 'experimental',
|
|
183
|
-
marquee: 'experimental',
|
|
184
|
-
surface: {
|
|
185
|
-
status: 'partial',
|
|
186
|
-
targets: ['MBox', 'MIcon', 'MImage:loaded-artwork'],
|
|
187
|
-
methods: ['available', 'onAvailable', 'use', 'set', 'animate', 'refresh'],
|
|
188
|
-
playback: ['finished', 'stop', 'pause', 'resume', 'paused', 'duration', 'progress:read'],
|
|
189
|
-
channels: [
|
|
190
|
-
'x',
|
|
191
|
-
'y',
|
|
192
|
-
'scale',
|
|
193
|
-
'scaleX',
|
|
194
|
-
'scaleY',
|
|
195
|
-
'rotate',
|
|
196
|
-
'rotateX',
|
|
197
|
-
'rotateY',
|
|
198
|
-
'opacity',
|
|
199
|
-
],
|
|
200
|
-
timing: ['spring', 'tween'],
|
|
201
|
-
interruptedSpringVelocity: {
|
|
202
|
-
status: 'not-inherited',
|
|
203
|
-
upstreamIssue: 'https://github.com/rafaelaugustos/jolt/issues/505',
|
|
204
|
-
},
|
|
205
|
-
maximumFrames: 2,
|
|
206
|
-
cleanupCallbacks: 'definite-cleanup-or-void',
|
|
207
|
-
whenMotionAvailable: ['surfaces', 'regions'],
|
|
208
|
-
trackingIssue: 354,
|
|
209
|
-
},
|
|
210
|
-
region: {
|
|
211
|
-
status: 'partial',
|
|
212
|
-
targets: ['MBox'],
|
|
213
|
-
methods: ['available', 'onAvailable', 'timeline', 'sequence'],
|
|
214
|
-
steps: 'surface-tuples',
|
|
215
|
-
positions: ['next', 'previous-start', 'absolute-forward', 'relative-forward'],
|
|
216
|
-
callbackSteps: 'unsupported',
|
|
217
|
-
durationRead: 'unsupported',
|
|
218
|
-
trackingIssue: 354,
|
|
219
|
-
},
|
|
220
|
-
shapes: {
|
|
221
|
-
status: 'unsupported',
|
|
222
|
-
upstreamIssue: 'https://github.com/rafaelaugustos/jolt/issues/504',
|
|
223
|
-
trackingIssue: 354,
|
|
224
|
-
},
|
|
225
|
-
particles: {
|
|
226
|
-
status: 'partial',
|
|
227
|
-
finite: true,
|
|
228
|
-
continuous: 'unsupported',
|
|
229
|
-
maximumDurationIncludingLifetime: 60000,
|
|
230
|
-
upstreamIssue: 'https://github.com/rafaelaugustos/jolt/issues/503',
|
|
231
|
-
trackingIssue: 354,
|
|
232
|
-
},
|
|
233
|
-
},
|
|
176
|
+
publishedJoltRelease: '0.1.0-rc.18',
|
|
234
177
|
features: {
|
|
235
178
|
gradient: ['web', 'ios', 'android'],
|
|
236
179
|
loadingEffects: ['web', 'ios'],
|
|
@@ -256,7 +199,7 @@ export const targetCapabilities = {
|
|
|
256
199
|
streaming: 'unverified',
|
|
257
200
|
rsc: 'unsupported',
|
|
258
201
|
},
|
|
259
|
-
motion: { engine: 'jolt', minimum: '0.1.0-rc.
|
|
202
|
+
motion: { engine: 'jolt', minimum: '0.1.0-rc.18', start: 'client-mount' },
|
|
260
203
|
ssr: {
|
|
261
204
|
availability: '0.1.0-alpha.5',
|
|
262
205
|
host: 'nuxt',
|
|
@@ -299,31 +242,7 @@ export const targetCapabilities = {
|
|
|
299
242
|
streaming: 'unsupported',
|
|
300
243
|
rsc: 'unsupported',
|
|
301
244
|
},
|
|
302
|
-
motion: { engine: 'jolt', minimum: '0.1.0-rc.
|
|
303
|
-
},
|
|
304
|
-
{
|
|
305
|
-
id: 'macos-swiftui',
|
|
306
|
-
framework: 'shared',
|
|
307
|
-
authoring: macosCapabilities.authoring,
|
|
308
|
-
renderer: 'swiftui',
|
|
309
|
-
status: 'experimental',
|
|
310
|
-
source: macosCapabilities.source,
|
|
311
|
-
minimumOS: macosCapabilities.minimumOS,
|
|
312
|
-
validation: macosCapabilities.validation,
|
|
313
|
-
ci: 'paused',
|
|
314
|
-
components: Object.keys(macosCapabilities.components),
|
|
315
|
-
componentCapabilities: macosCapabilities.components,
|
|
316
|
-
limitations: macosCapabilities.sharedLimits,
|
|
317
|
-
rendering: {
|
|
318
|
-
client: 'experimental',
|
|
319
|
-
serverImport: 'unsupported',
|
|
320
|
-
serverHTML: 'unsupported',
|
|
321
|
-
hydration: 'unsupported',
|
|
322
|
-
ssg: 'unsupported',
|
|
323
|
-
streaming: 'unsupported',
|
|
324
|
-
rsc: 'unsupported',
|
|
325
|
-
},
|
|
326
|
-
motion: { engine: 'jolt-swiftui', minimum: '0.1.0-rc.16', start: 'native-view' },
|
|
245
|
+
motion: { engine: 'jolt', minimum: '0.1.0-rc.18', start: 'native-loaded' },
|
|
327
246
|
},
|
|
328
247
|
...(
|
|
329
248
|
[
|
package/src/index.ts
CHANGED
|
@@ -23,7 +23,7 @@ export type {
|
|
|
23
23
|
} from './theme/types.js'
|
|
24
24
|
export { listItemLabel } from './list-item.js'
|
|
25
25
|
export { avatarSizes, avatarInitials } from './avatar.js'
|
|
26
|
-
export type { AvatarSize } from './avatar.js'
|
|
26
|
+
export type { AvatarSize, AvatarMember } from './avatar.js'
|
|
27
27
|
export { badgeColors } from './badge.js'
|
|
28
28
|
export type { BadgeTone } from './badge.js'
|
|
29
29
|
export { sliderScale } from './slider.js'
|
|
@@ -78,12 +78,7 @@ export type {
|
|
|
78
78
|
ButtonEvents,
|
|
79
79
|
TextInputHandle,
|
|
80
80
|
} from './contracts.js'
|
|
81
|
-
export {
|
|
82
|
-
targetCapabilities,
|
|
83
|
-
componentNames,
|
|
84
|
-
themeContract,
|
|
85
|
-
macosCapabilities,
|
|
86
|
-
} from './capabilities.js'
|
|
81
|
+
export { targetCapabilities, componentNames, themeContract } from './capabilities.js'
|
|
87
82
|
export type { ComponentName, CapabilityStatus } from './capabilities.js'
|
|
88
83
|
|
|
89
84
|
export * from './date.js'
|
|
@@ -64,6 +64,7 @@ import {
|
|
|
64
64
|
virtualListProps,
|
|
65
65
|
} from './navigation-props.js'
|
|
66
66
|
import { numberInputProps, multiSelectProps, imageProps } from './configurator-props.js'
|
|
67
|
+
import { avatarGroupProps, tagInputProps, searchBarProps } from './editor-controls.js'
|
|
67
68
|
import type { ExtractPublicPropTypes } from '@vue/runtime-core'
|
|
68
69
|
import type { SheetName } from '../sheet.js'
|
|
69
70
|
import { componentProps as foundationProps } from './props.js'
|
|
@@ -98,6 +99,9 @@ export const componentProps = {
|
|
|
98
99
|
|
|
99
100
|
MCollapsibleHeader: collapsibleHeaderProps,
|
|
100
101
|
MRefreshControl: refreshControlProps,
|
|
102
|
+
MAvatarGroup: avatarGroupProps,
|
|
103
|
+
MSearchBar: searchBarProps,
|
|
104
|
+
MTagInput: tagInputProps,
|
|
101
105
|
MComposer: composerProps,
|
|
102
106
|
MSpeedDial: speedDialProps,
|
|
103
107
|
MPinInput: pinInputProps,
|
package/src/vue/composer.ts
CHANGED
|
@@ -2,6 +2,8 @@ import {
|
|
|
2
2
|
computed,
|
|
3
3
|
defineComponent,
|
|
4
4
|
h,
|
|
5
|
+
inject,
|
|
6
|
+
type InjectionKey,
|
|
5
7
|
markRaw,
|
|
6
8
|
mergeProps,
|
|
7
9
|
onScopeDispose,
|
|
@@ -9,11 +11,16 @@ import {
|
|
|
9
11
|
watch,
|
|
10
12
|
type Component,
|
|
11
13
|
} from '@vue/runtime-core'
|
|
12
|
-
import { createMotionSurface
|
|
14
|
+
import { createMotionSurface } from '../experimental.js'
|
|
13
15
|
import type { ComposerMessage } from '../screen-components.js'
|
|
14
16
|
import { composerProps } from './screen-component-props.js'
|
|
15
17
|
import { useComponentLayout } from './component-motion.js'
|
|
16
18
|
|
|
19
|
+
import { useCachedActivity } from './cached-activity.js'
|
|
20
|
+
|
|
21
|
+
/** Whether the enclosing layout already fits the software keyboard. */
|
|
22
|
+
export const keyboardViewportOwner: InjectionKey<() => boolean> = Symbol('mavis-keyboard-viewport')
|
|
23
|
+
|
|
17
24
|
export function createComposer(
|
|
18
25
|
ui: {
|
|
19
26
|
Box: Component
|
|
@@ -47,23 +54,22 @@ export function createComposer(
|
|
|
47
54
|
const canSend = computed(
|
|
48
55
|
() => !blocked.value && Boolean(props.modelValue.trim() || props.attachments.length),
|
|
49
56
|
)
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
follow?.dispose()
|
|
53
|
-
follow = undefined
|
|
54
|
-
if (props.followKeyboard && surface.available)
|
|
55
|
-
follow = surface.followKeyboard({ offset: props.keyboardOffset })
|
|
56
|
-
}
|
|
57
|
+
const active = useCachedActivity()
|
|
58
|
+
const viewportOwned = inject(keyboardViewportOwner, () => false)
|
|
57
59
|
onScopeDispose(
|
|
58
|
-
surface.use(() =>
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
60
|
+
surface.use(() =>
|
|
61
|
+
watch(
|
|
62
|
+
() => [props.followKeyboard, props.keyboardOffset, viewportOwned(), active.value],
|
|
63
|
+
(_, __, cleanup) => {
|
|
64
|
+
if (props.followKeyboard && active.value && !viewportOwned()) {
|
|
65
|
+
const follow = surface.followKeyboard({ offset: props.keyboardOffset })
|
|
66
|
+
cleanup(() => follow.dispose())
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
{ immediate: true, flush: 'post' },
|
|
70
|
+
),
|
|
71
|
+
),
|
|
65
72
|
)
|
|
66
|
-
watch(() => [props.followKeyboard, props.keyboardOffset], followKeyboard, { flush: 'post' })
|
|
67
73
|
const submit = () => {
|
|
68
74
|
if (canSend.value)
|
|
69
75
|
emit('submit', {
|
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
import { defineComponent, h, nextTick, ref, type Component, type PropType } from '@vue/runtime-core'
|
|
2
|
+
import type { InputHandle } from '../input.js'
|
|
3
|
+
import { avatarSizes, type AvatarMember } from '../avatar.js'
|
|
4
|
+
import { avatarProps } from './props.js'
|
|
5
|
+
import { useMavisTheme } from './theme.js'
|
|
6
|
+
|
|
7
|
+
const editorProps = {
|
|
8
|
+
id: String,
|
|
9
|
+
label: { type: String, required: true as const },
|
|
10
|
+
placeholder: String,
|
|
11
|
+
disabled: Boolean,
|
|
12
|
+
}
|
|
13
|
+
export const searchBarProps = {
|
|
14
|
+
...editorProps,
|
|
15
|
+
modelValue: { type: String, default: '' },
|
|
16
|
+
clearLabel: { type: String, default: 'Clear search' },
|
|
17
|
+
cancelLabel: { type: String, default: 'Cancel' },
|
|
18
|
+
showCancel: Boolean,
|
|
19
|
+
}
|
|
20
|
+
export const tagInputProps = {
|
|
21
|
+
...editorProps,
|
|
22
|
+
modelValue: { type: Array as PropType<readonly string[]>, default: () => [] },
|
|
23
|
+
addLabel: { type: String, default: 'Add tag' },
|
|
24
|
+
removeLabel: { type: String, default: 'Remove' },
|
|
25
|
+
maxTags: Number,
|
|
26
|
+
}
|
|
27
|
+
export const avatarGroupProps = {
|
|
28
|
+
id: String,
|
|
29
|
+
members: { type: Array as PropType<readonly AvatarMember[]>, required: true as const },
|
|
30
|
+
maxVisible: { type: Number, default: 4 },
|
|
31
|
+
size: avatarProps.size,
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function createEditorControls(
|
|
35
|
+
ui: {
|
|
36
|
+
Row: Component
|
|
37
|
+
Column: Component
|
|
38
|
+
Input: Component
|
|
39
|
+
Chip: Component
|
|
40
|
+
Button: Component
|
|
41
|
+
Avatar: Component
|
|
42
|
+
},
|
|
43
|
+
platform: 'web' | 'native',
|
|
44
|
+
) {
|
|
45
|
+
const web = platform === 'web'
|
|
46
|
+
const MSearchBar = defineComponent({
|
|
47
|
+
name: 'MSearchBar',
|
|
48
|
+
props: searchBarProps,
|
|
49
|
+
emits: {
|
|
50
|
+
'update:modelValue': (_v: string) => true,
|
|
51
|
+
submit: (_v: string) => true,
|
|
52
|
+
clear: () => true,
|
|
53
|
+
cancel: () => true,
|
|
54
|
+
},
|
|
55
|
+
setup(props, { emit, expose }) {
|
|
56
|
+
const editor = ref<InputHandle>()
|
|
57
|
+
const focus = () => editor.value?.focus()
|
|
58
|
+
const blur = () => editor.value?.blur()
|
|
59
|
+
expose({ focus, blur })
|
|
60
|
+
return () =>
|
|
61
|
+
h(
|
|
62
|
+
ui.Row,
|
|
63
|
+
{ gap: 'sm', align: 'center' },
|
|
64
|
+
{
|
|
65
|
+
default: () => [
|
|
66
|
+
h(ui.Input, {
|
|
67
|
+
ref: editor,
|
|
68
|
+
id: props.id,
|
|
69
|
+
label: props.label,
|
|
70
|
+
placeholder: props.placeholder,
|
|
71
|
+
width: 0,
|
|
72
|
+
grow: 1,
|
|
73
|
+
modelValue: props.modelValue,
|
|
74
|
+
disabled: props.disabled,
|
|
75
|
+
icon: 'search',
|
|
76
|
+
inputmode: 'search',
|
|
77
|
+
returnKey: 'search',
|
|
78
|
+
trailingAction: props.modelValue
|
|
79
|
+
? { icon: 'x', label: props.clearLabel }
|
|
80
|
+
: undefined,
|
|
81
|
+
'onUpdate:modelValue': (value: string) => {
|
|
82
|
+
if (!props.disabled) emit('update:modelValue', value)
|
|
83
|
+
},
|
|
84
|
+
onSubmit: (value: string) => {
|
|
85
|
+
if (!props.disabled) emit('submit', value)
|
|
86
|
+
},
|
|
87
|
+
onAction: () => {
|
|
88
|
+
if (props.disabled || !props.modelValue) return
|
|
89
|
+
emit('update:modelValue', '')
|
|
90
|
+
emit('clear')
|
|
91
|
+
void nextTick(focus)
|
|
92
|
+
},
|
|
93
|
+
}),
|
|
94
|
+
props.showCancel
|
|
95
|
+
? h(ui.Button, {
|
|
96
|
+
text: props.cancelLabel,
|
|
97
|
+
variant: 'ghost',
|
|
98
|
+
disabled: props.disabled,
|
|
99
|
+
onClick: () => {
|
|
100
|
+
if (!props.disabled) {
|
|
101
|
+
blur()
|
|
102
|
+
emit('cancel')
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
})
|
|
106
|
+
: null,
|
|
107
|
+
],
|
|
108
|
+
},
|
|
109
|
+
)
|
|
110
|
+
},
|
|
111
|
+
})
|
|
112
|
+
const MTagInput = defineComponent({
|
|
113
|
+
name: 'MTagInput',
|
|
114
|
+
props: tagInputProps,
|
|
115
|
+
emits: { 'update:modelValue': (_v: string[]) => true },
|
|
116
|
+
setup(props, { emit, expose }) {
|
|
117
|
+
const draft = ref('')
|
|
118
|
+
const editor = ref<InputHandle>()
|
|
119
|
+
let composing = false
|
|
120
|
+
let editVersion = 0
|
|
121
|
+
const focus = () => editor.value?.focus()
|
|
122
|
+
expose({ focus, blur: () => editor.value?.blur() })
|
|
123
|
+
function add(value: string, finish: boolean, fromEditor = false) {
|
|
124
|
+
if (props.disabled) return
|
|
125
|
+
const parts = value.split(/[,\r\n]+/)
|
|
126
|
+
const tail = finish ? '' : (parts.pop() ?? '')
|
|
127
|
+
const result = [...props.modelValue]
|
|
128
|
+
const seen = new Set(result.map((tag) => tag.trim().toLowerCase()))
|
|
129
|
+
const remaining: string[] = []
|
|
130
|
+
for (const part of parts) {
|
|
131
|
+
const tag = part.trim()
|
|
132
|
+
const key = tag.toLowerCase()
|
|
133
|
+
if (!tag || seen.has(key)) continue
|
|
134
|
+
seen.add(key)
|
|
135
|
+
if (result.length < (props.maxTags ?? Infinity)) result.push(tag)
|
|
136
|
+
else remaining.push(tag)
|
|
137
|
+
}
|
|
138
|
+
const nextDraft = [...remaining, tail].filter(Boolean).join(', ')
|
|
139
|
+
const version = ++editVersion
|
|
140
|
+
// A native paste can add whole tags to an already-empty editor. Give the
|
|
141
|
+
// controlled field the input echo before clearing it, even if the final draft is unchanged.
|
|
142
|
+
if (fromEditor && nextDraft !== value) {
|
|
143
|
+
draft.value = value
|
|
144
|
+
void nextTick(() => {
|
|
145
|
+
if (version === editVersion) draft.value = nextDraft
|
|
146
|
+
})
|
|
147
|
+
} else draft.value = nextDraft
|
|
148
|
+
if (result.length !== props.modelValue.length) emit('update:modelValue', result)
|
|
149
|
+
}
|
|
150
|
+
function remove(index: number) {
|
|
151
|
+
if (!props.disabled && index >= 0)
|
|
152
|
+
emit(
|
|
153
|
+
'update:modelValue',
|
|
154
|
+
props.modelValue.filter((_, i) => i !== index),
|
|
155
|
+
)
|
|
156
|
+
}
|
|
157
|
+
return () => {
|
|
158
|
+
if (props.maxTags !== undefined && (!Number.isInteger(props.maxTags) || props.maxTags < 0))
|
|
159
|
+
throw new RangeError('maxTags must be a nonnegative integer.')
|
|
160
|
+
const webEvents = web
|
|
161
|
+
? {
|
|
162
|
+
onCompositionstart: () => {
|
|
163
|
+
composing = true
|
|
164
|
+
},
|
|
165
|
+
onCompositionend: (e: CompositionEvent) => {
|
|
166
|
+
composing = false
|
|
167
|
+
add((e.target as HTMLInputElement).value, false)
|
|
168
|
+
},
|
|
169
|
+
onKeydown: (e: KeyboardEvent) => {
|
|
170
|
+
if (
|
|
171
|
+
e.key === 'Backspace' &&
|
|
172
|
+
!e.repeat &&
|
|
173
|
+
!composing &&
|
|
174
|
+
!e.isComposing &&
|
|
175
|
+
!draft.value &&
|
|
176
|
+
(e.target as HTMLElement).tagName === 'INPUT' &&
|
|
177
|
+
props.modelValue.length &&
|
|
178
|
+
!props.disabled
|
|
179
|
+
) {
|
|
180
|
+
e.preventDefault()
|
|
181
|
+
remove(props.modelValue.length - 1)
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
onPaste: (e: ClipboardEvent) => {
|
|
185
|
+
const field = e.target as HTMLInputElement
|
|
186
|
+
const text = e.clipboardData?.getData('text/plain')
|
|
187
|
+
if (
|
|
188
|
+
field.tagName !== 'INPUT' ||
|
|
189
|
+
!text ||
|
|
190
|
+
!/[,\r\n]/.test(text) ||
|
|
191
|
+
props.disabled ||
|
|
192
|
+
composing
|
|
193
|
+
)
|
|
194
|
+
return
|
|
195
|
+
e.preventDefault()
|
|
196
|
+
add(
|
|
197
|
+
field.value.slice(0, field.selectionStart ?? 0) +
|
|
198
|
+
text +
|
|
199
|
+
field.value.slice(field.selectionEnd ?? field.value.length),
|
|
200
|
+
true,
|
|
201
|
+
)
|
|
202
|
+
},
|
|
203
|
+
}
|
|
204
|
+
: {}
|
|
205
|
+
return h(
|
|
206
|
+
ui.Column,
|
|
207
|
+
{ gap: 'sm', ...webEvents },
|
|
208
|
+
{
|
|
209
|
+
default: () => [
|
|
210
|
+
h(ui.Input, {
|
|
211
|
+
ref: editor,
|
|
212
|
+
id: props.id,
|
|
213
|
+
label: props.label,
|
|
214
|
+
placeholder: props.placeholder,
|
|
215
|
+
modelValue: draft.value,
|
|
216
|
+
disabled: props.disabled,
|
|
217
|
+
returnKey: 'done',
|
|
218
|
+
trailingAction: draft.value.trim()
|
|
219
|
+
? { icon: 'plus', label: props.addLabel }
|
|
220
|
+
: undefined,
|
|
221
|
+
'onUpdate:modelValue': (text: string) => {
|
|
222
|
+
if (composing) {
|
|
223
|
+
editVersion++
|
|
224
|
+
draft.value = text
|
|
225
|
+
} else
|
|
226
|
+
add(
|
|
227
|
+
text,
|
|
228
|
+
!web && /[,\r\n]/.test(text) && text.length > draft.value.length + 1,
|
|
229
|
+
true,
|
|
230
|
+
)
|
|
231
|
+
},
|
|
232
|
+
onSubmit: (text: string) => add(text, true),
|
|
233
|
+
onAction: () => {
|
|
234
|
+
add(draft.value, true)
|
|
235
|
+
void nextTick(focus)
|
|
236
|
+
},
|
|
237
|
+
}),
|
|
238
|
+
props.modelValue.length
|
|
239
|
+
? h(
|
|
240
|
+
ui.Row,
|
|
241
|
+
{ wrap: true, gap: 'xs' },
|
|
242
|
+
{
|
|
243
|
+
default: () =>
|
|
244
|
+
props.modelValue.map((tag, i) =>
|
|
245
|
+
h(ui.Chip, {
|
|
246
|
+
key: tag,
|
|
247
|
+
label: tag,
|
|
248
|
+
removable: true,
|
|
249
|
+
removeLabel: props.removeLabel + ' ' + tag,
|
|
250
|
+
disabled: props.disabled,
|
|
251
|
+
onRemove: () => remove(i),
|
|
252
|
+
}),
|
|
253
|
+
),
|
|
254
|
+
},
|
|
255
|
+
)
|
|
256
|
+
: null,
|
|
257
|
+
],
|
|
258
|
+
},
|
|
259
|
+
)
|
|
260
|
+
}
|
|
261
|
+
},
|
|
262
|
+
})
|
|
263
|
+
const MAvatarGroup = defineComponent({
|
|
264
|
+
name: 'MAvatarGroup',
|
|
265
|
+
props: avatarGroupProps,
|
|
266
|
+
setup(props) {
|
|
267
|
+
const { theme } = useMavisTheme()
|
|
268
|
+
return () => {
|
|
269
|
+
if (!Number.isInteger(props.maxVisible) || props.maxVisible < 1)
|
|
270
|
+
throw new RangeError('maxVisible must be a positive integer.')
|
|
271
|
+
const seen = new Set<string>()
|
|
272
|
+
for (const person of props.members) {
|
|
273
|
+
if (!person.id || seen.has(person.id))
|
|
274
|
+
throw new TypeError('Avatar members require unique ids.')
|
|
275
|
+
seen.add(person.id)
|
|
276
|
+
}
|
|
277
|
+
const visible = props.members.slice(0, props.maxVisible)
|
|
278
|
+
const extra = props.members.length - visible.length
|
|
279
|
+
const size = avatarSizes[props.size]
|
|
280
|
+
const stride = Math.ceil(size * 0.82)
|
|
281
|
+
const count = visible.length + Number(extra > 0)
|
|
282
|
+
const width = count ? size + (count - 1) * stride : 0
|
|
283
|
+
const colors = theme.value.colors
|
|
284
|
+
const cell = (index: number) =>
|
|
285
|
+
web
|
|
286
|
+
? {
|
|
287
|
+
position: 'absolute',
|
|
288
|
+
left: index * stride + 'px',
|
|
289
|
+
top: 0,
|
|
290
|
+
width: size + 'px',
|
|
291
|
+
height: size + 'px',
|
|
292
|
+
borderRadius: '50%',
|
|
293
|
+
boxShadow: '0 0 0 2px ' + colors.surface,
|
|
294
|
+
}
|
|
295
|
+
: {
|
|
296
|
+
width: size,
|
|
297
|
+
height: size,
|
|
298
|
+
borderRadius: size / 2,
|
|
299
|
+
borderWidth: 2,
|
|
300
|
+
borderColor: colors.surface,
|
|
301
|
+
backgroundColor: colors.surface,
|
|
302
|
+
clipToBounds: true,
|
|
303
|
+
}
|
|
304
|
+
const cells = visible.map((person, i) =>
|
|
305
|
+
h(
|
|
306
|
+
web ? 'span' : 'GridLayout',
|
|
307
|
+
{
|
|
308
|
+
key: 'member:' + person.id,
|
|
309
|
+
...(!web ? { left: i * stride, top: 0 } : {}),
|
|
310
|
+
style: cell(i),
|
|
311
|
+
},
|
|
312
|
+
[h(ui.Avatar, { name: person.name, src: person.src, size: props.size })],
|
|
313
|
+
),
|
|
314
|
+
)
|
|
315
|
+
if (extra)
|
|
316
|
+
cells.push(
|
|
317
|
+
h(
|
|
318
|
+
web ? 'span' : 'Label',
|
|
319
|
+
{
|
|
320
|
+
key: 'overflow',
|
|
321
|
+
...(web
|
|
322
|
+
? {}
|
|
323
|
+
: {
|
|
324
|
+
left: visible.length * stride,
|
|
325
|
+
top: 0,
|
|
326
|
+
text: '+' + extra,
|
|
327
|
+
textAlignment: 'center',
|
|
328
|
+
verticalTextAlignment: 'middle',
|
|
329
|
+
}),
|
|
330
|
+
style: {
|
|
331
|
+
...cell(visible.length),
|
|
332
|
+
...(web
|
|
333
|
+
? {
|
|
334
|
+
display: 'grid',
|
|
335
|
+
placeItems: 'center',
|
|
336
|
+
fontSize: Math.round(size * 0.32) + 'px',
|
|
337
|
+
}
|
|
338
|
+
: { fontSize: Math.round(size * 0.32) }),
|
|
339
|
+
fontWeight: '600',
|
|
340
|
+
color: colors.onPrimary,
|
|
341
|
+
backgroundColor: colors.primary,
|
|
342
|
+
},
|
|
343
|
+
},
|
|
344
|
+
web ? '+' + extra : undefined,
|
|
345
|
+
),
|
|
346
|
+
)
|
|
347
|
+
return h(
|
|
348
|
+
web ? 'span' : 'AbsoluteLayout',
|
|
349
|
+
{
|
|
350
|
+
id: props.id,
|
|
351
|
+
...(web
|
|
352
|
+
? {
|
|
353
|
+
class: 'm-avatar-group',
|
|
354
|
+
style: {
|
|
355
|
+
position: 'relative',
|
|
356
|
+
display: 'inline-block',
|
|
357
|
+
width: width + 'px',
|
|
358
|
+
height: size + 'px',
|
|
359
|
+
alignSelf: 'flex-start',
|
|
360
|
+
},
|
|
361
|
+
}
|
|
362
|
+
: { width, height: size, horizontalAlignment: 'left' }),
|
|
363
|
+
},
|
|
364
|
+
cells,
|
|
365
|
+
)
|
|
366
|
+
}
|
|
367
|
+
},
|
|
368
|
+
})
|
|
369
|
+
return { MTagInput, MSearchBar, MAvatarGroup }
|
|
370
|
+
}
|
|
@@ -20,6 +20,9 @@ type InputEvents = {
|
|
|
20
20
|
|
|
21
21
|
/** Additional input attributes supplied by a renderer, without DOM dependencies in core. */
|
|
22
22
|
export interface InputPlatformAttributes {}
|
|
23
|
+
|
|
24
|
+
/** Action attributes supplied by the card renderer. */
|
|
25
|
+
export interface CardPlatformAttributes {}
|
|
23
26
|
type SheetEvents = {
|
|
24
27
|
'onUpdate:open'?: (value: boolean) => void
|
|
25
28
|
onClose?: (reason: SheetCloseReason) => void
|
|
@@ -147,6 +150,19 @@ declare module '@vue/runtime-core' {
|
|
|
147
150
|
onClose?: (reason: string) => void
|
|
148
151
|
}
|
|
149
152
|
>
|
|
153
|
+
MAvatarGroup: DefineComponent<ComponentProps['MAvatarGroup']>
|
|
154
|
+
MSearchBar: DefineComponent<
|
|
155
|
+
ComponentProps['MSearchBar'] &
|
|
156
|
+
Pick<InputEvents, 'onUpdate:modelValue' | 'onSubmit'> & {
|
|
157
|
+
onClear?: () => void
|
|
158
|
+
onCancel?: () => void
|
|
159
|
+
},
|
|
160
|
+
InputHandle
|
|
161
|
+
>
|
|
162
|
+
MTagInput: DefineComponent<
|
|
163
|
+
ComponentProps['MTagInput'] & { 'onUpdate:modelValue'?: (tags: string[]) => void },
|
|
164
|
+
InputHandle
|
|
165
|
+
>
|
|
150
166
|
MComposer: DefineComponent<
|
|
151
167
|
ComponentProps['MComposer'] &
|
|
152
168
|
Omit<InputEvents, 'onSubmit'> & {
|
|
@@ -163,7 +179,9 @@ declare module '@vue/runtime-core' {
|
|
|
163
179
|
> & {
|
|
164
180
|
new (): {
|
|
165
181
|
scrollToTop(animated?: boolean): void
|
|
182
|
+
preserveAnchor(change: () => void | Promise<void>): Promise<void>
|
|
166
183
|
$slots: {
|
|
184
|
+
item?: (scope: { itemKey: string; index: number }) => unknown
|
|
167
185
|
default?: () => unknown
|
|
168
186
|
artwork?: () => unknown
|
|
169
187
|
leading?: () => unknown
|
|
@@ -181,7 +199,9 @@ declare module '@vue/runtime-core' {
|
|
|
181
199
|
new (): {
|
|
182
200
|
refresh(): Promise<boolean>
|
|
183
201
|
cancel(): void
|
|
202
|
+
preserveAnchor(change: () => void | Promise<void>): Promise<void>
|
|
184
203
|
$slots: {
|
|
204
|
+
item?: (scope: { itemKey: string; index: number }) => unknown
|
|
185
205
|
default?: (scope: {
|
|
186
206
|
state: import('../screen-components.js').RefreshState
|
|
187
207
|
refresh(): Promise<boolean>
|
|
@@ -380,7 +400,7 @@ declare module '@vue/runtime-core' {
|
|
|
380
400
|
ComponentProps['MLink'] & Action & { onError?: (error: unknown) => void }
|
|
381
401
|
>
|
|
382
402
|
MBox: DefineComponent<ComponentProps['MBox']>
|
|
383
|
-
MCard: DefineComponent<ComponentProps['MCard'] & Action>
|
|
403
|
+
MCard: DefineComponent<ComponentProps['MCard'] & Action & CardPlatformAttributes>
|
|
384
404
|
MText: DefineComponent<ComponentProps['MText']>
|
|
385
405
|
MButton: DefineComponent<ComponentProps['MButton'] & Action> & {
|
|
386
406
|
new (): {
|