@getcortexlabs/mavis-web 0.1.0-alpha.8 → 0.1.0-alpha.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -2
- package/dist/components/DateCalendar.d.ts +1 -1
- package/dist/components/LoadingDecoration.d.ts +2 -2
- package/dist/components/MAccordion.d.ts +1 -1
- package/dist/components/MAlert.d.ts +2 -2
- package/dist/components/MAvatar.d.ts +1 -1
- package/dist/components/MBadge.d.ts +1 -1
- package/dist/components/MButton.d.ts +5 -5
- package/dist/components/MButton.d.ts.map +1 -1
- package/dist/components/MButton.js +14 -8
- package/dist/components/MButton.js.map +1 -1
- package/dist/components/MCard.d.ts +3 -3
- package/dist/components/MCard.d.ts.map +1 -1
- package/dist/components/MCard.js +3 -2
- package/dist/components/MCard.js.map +1 -1
- package/dist/components/MCheckbox.d.ts +1 -1
- package/dist/components/MChip.d.ts +2 -2
- package/dist/components/MCombobox.d.ts +1 -1
- package/dist/components/MDatePicker.d.ts +56 -8
- package/dist/components/MDatePicker.d.ts.map +1 -1
- package/dist/components/MDatePicker.js +2 -10
- package/dist/components/MDatePicker.js.map +1 -1
- package/dist/components/MEmptyState.d.ts +2 -2
- package/dist/components/MGrid.d.ts +163 -0
- package/dist/components/MGrid.d.ts.map +1 -0
- package/dist/components/MGrid.js +32 -0
- package/dist/components/MGrid.js.map +1 -0
- package/dist/components/MIcon.d.ts +1 -1
- package/dist/components/MIcon.d.ts.map +1 -1
- package/dist/components/MIcon.js +7 -4
- package/dist/components/MIcon.js.map +1 -1
- package/dist/components/MImage.d.ts +48 -3
- package/dist/components/MImage.d.ts.map +1 -1
- package/dist/components/MImage.js +23 -8
- package/dist/components/MImage.js.map +1 -1
- package/dist/components/MInput.d.ts +7 -7
- package/dist/components/MInput.d.ts.map +1 -1
- package/dist/components/MInput.js +7 -0
- package/dist/components/MInput.js.map +1 -1
- package/dist/components/MLink.d.ts +1 -1
- package/dist/components/MLink.d.ts.map +1 -1
- package/dist/components/MLink.js +5 -33
- package/dist/components/MLink.js.map +1 -1
- package/dist/components/MListItem.d.ts +1 -1
- package/dist/components/MProgress.d.ts +2 -2
- package/dist/components/MRadioGroup.d.ts +1 -1
- package/dist/components/MReveal.d.ts +3 -3
- package/dist/components/MSegmentedControl.d.ts +1 -1
- package/dist/components/MSelect.d.ts +1 -1
- package/dist/components/MSheet.d.ts +10 -1
- package/dist/components/MSheet.d.ts.map +1 -1
- package/dist/components/MSheet.js +45 -14
- package/dist/components/MSheet.js.map +1 -1
- package/dist/components/MSkeleton.d.ts +1 -1
- package/dist/components/MStack.d.ts +3 -3
- package/dist/components/MStack.d.ts.map +1 -1
- package/dist/components/MStack.js +3 -13
- package/dist/components/MStack.js.map +1 -1
- package/dist/components/MSwitch.d.ts +1 -1
- package/dist/components/MTabs.d.ts +1 -1
- package/dist/components/MText.d.ts +2 -2
- package/dist/components/configurator.d.ts +3 -3
- package/dist/components/layout.d.ts +12 -12
- package/dist/content-width.d.ts +4 -0
- package/dist/content-width.d.ts.map +1 -0
- package/dist/content-width.js +62 -0
- package/dist/content-width.js.map +1 -0
- package/dist/date-format.d.ts +6 -0
- package/dist/date-format.d.ts.map +1 -0
- package/dist/date-format.js +23 -0
- package/dist/date-format.js.map +1 -0
- package/dist/icons.d.ts +14 -0
- package/dist/icons.d.ts.map +1 -0
- package/dist/icons.js +23 -0
- package/dist/icons.js.map +1 -0
- package/dist/image-effects.d.ts.map +1 -1
- package/dist/image-effects.js +2 -0
- package/dist/image-effects.js.map +1 -1
- package/dist/index.d.ts +11 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -10
- package/dist/index.js.map +1 -1
- package/dist/services.d.ts +16 -0
- package/dist/services.d.ts.map +1 -0
- package/dist/services.js +18 -0
- package/dist/services.js.map +1 -0
- package/package.json +21 -3
- package/src/base.css +992 -0
- package/src/components/MButton.ts +28 -25
- package/src/components/MCard.ts +3 -1
- package/src/components/MDatePicker.ts +1 -9
- package/src/components/MGrid.ts +45 -0
- package/src/components/MIcon.ts +7 -8
- package/src/components/MImage.ts +26 -11
- package/src/components/MInput.ts +9 -3
- package/src/components/MLink.ts +10 -32
- package/src/components/MSheet.ts +47 -14
- package/src/components/MStack.ts +3 -20
- package/src/content-width.ts +70 -0
- package/src/date-format.ts +36 -0
- package/src/icons.css +7 -0
- package/src/icons.ts +28 -0
- package/src/image-effects.ts +2 -0
- package/src/index.ts +63 -63
- package/src/services.ts +33 -0
- package/src/style.css +2 -1000
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import {
|
|
2
|
+
civilDate,
|
|
3
|
+
dateTimeMilliseconds,
|
|
4
|
+
resolveDateTimeOptions,
|
|
5
|
+
type DateTimeValue,
|
|
6
|
+
type DateTimeFormatOptions,
|
|
7
|
+
} from '@getcortexlabs/mavis-core'
|
|
8
|
+
export type { DateTimeValue, DateTimeFormatOptions, DateTimeStyle } from '@getcortexlabs/mavis-core'
|
|
9
|
+
|
|
10
|
+
export function formatDateTime(value: DateTimeValue, options: DateTimeFormatOptions): string {
|
|
11
|
+
const { locale, ...format } = resolveDateTimeOptions(options)
|
|
12
|
+
return new Intl.DateTimeFormat(locale, { ...format, calendar: 'gregory' }).format(
|
|
13
|
+
dateTimeMilliseconds(value),
|
|
14
|
+
)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** Explicit conversion from an instant to a Gregorian calendar day in a named zone. */
|
|
18
|
+
export function dateTimeToCivilDate(
|
|
19
|
+
value: DateTimeValue,
|
|
20
|
+
options: Pick<DateTimeFormatOptions, 'timeZone'>,
|
|
21
|
+
) {
|
|
22
|
+
const { timeZone } = resolveDateTimeOptions(options)
|
|
23
|
+
const parts = new Intl.DateTimeFormat('en-US', {
|
|
24
|
+
timeZone,
|
|
25
|
+
calendar: 'gregory',
|
|
26
|
+
numberingSystem: 'latn',
|
|
27
|
+
year: 'numeric',
|
|
28
|
+
month: '2-digit',
|
|
29
|
+
day: '2-digit',
|
|
30
|
+
era: 'short',
|
|
31
|
+
}).formatToParts(dateTimeMilliseconds(value))
|
|
32
|
+
const part = (type: Intl.DateTimeFormatPartTypes) =>
|
|
33
|
+
parts.find((part) => part.type === type)?.value
|
|
34
|
+
if (part('era') !== 'AD') throw new RangeError('Civil dates support years 0001–9999.')
|
|
35
|
+
return civilDate(`${part('year')!.padStart(4, '0')}-${part('month')}-${part('day')}`)
|
|
36
|
+
}
|
package/src/icons.css
ADDED
package/src/icons.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { h, inject, type Component, type InjectionKey, type VNode } from 'vue'
|
|
2
|
+
import { iconFontFamily, iconGlyph, type IconName } from '@getcortexlabs/mavis-core'
|
|
3
|
+
|
|
4
|
+
export interface MavisIconOptions {
|
|
5
|
+
/** Import only the SVG components the application uses. Missing entries use iconFallback. */
|
|
6
|
+
icons?: Partial<Record<IconName, Component>>
|
|
7
|
+
iconFallback?: 'font' | 'none'
|
|
8
|
+
}
|
|
9
|
+
export const iconOptionsKey: InjectionKey<MavisIconOptions> = Symbol('mavis.icons')
|
|
10
|
+
|
|
11
|
+
/** One app-scoped resolver shared by standalone icons and control adornments. */
|
|
12
|
+
export function useIconContent() {
|
|
13
|
+
const options = inject(iconOptionsKey, undefined)
|
|
14
|
+
return (name: IconName, size: number): { content: string | VNode; fontFamily?: string } => {
|
|
15
|
+
const component = options?.icons?.[name]
|
|
16
|
+
if (component)
|
|
17
|
+
return {
|
|
18
|
+
content: h(component, {
|
|
19
|
+
width: size,
|
|
20
|
+
height: size,
|
|
21
|
+
'aria-hidden': 'true',
|
|
22
|
+
focusable: 'false',
|
|
23
|
+
}),
|
|
24
|
+
}
|
|
25
|
+
if (options?.iconFallback === 'none') return { content: '' }
|
|
26
|
+
return { content: iconGlyph(name), fontFamily: iconFontFamily }
|
|
27
|
+
}
|
|
28
|
+
}
|
package/src/image-effects.ts
CHANGED
|
@@ -33,6 +33,8 @@ export async function webImageEffect(
|
|
|
33
33
|
const image = loadedMotionImage(target),
|
|
34
34
|
presentation = images.get(image)!
|
|
35
35
|
const { to, ...rest } = options
|
|
36
|
+
if (to !== undefined && image.srcset?.trim())
|
|
37
|
+
throw new TypeError('Dissolve source replacement requires an image without srcset.')
|
|
36
38
|
const preparation = {}
|
|
37
39
|
preparations.set(image, preparation)
|
|
38
40
|
let destination: HTMLImageElement | undefined
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { MNumberInput, MMultiSelect } from './components/configurator.js'
|
|
2
2
|
import { MImage } from './components/MImage.js'
|
|
3
3
|
import { MStack } from './components/MStack.js'
|
|
4
|
+
import { MGrid } from './components/MGrid.js'
|
|
4
5
|
export { themeVariables, useMavisTokens } from './tokens.js'
|
|
5
6
|
import { MLink } from './components/MLink.js'
|
|
6
7
|
import { MDatePicker, MDateRangePicker } from './components/MDatePicker.js'
|
|
@@ -9,16 +10,11 @@ import { MFilePicker } from './components/MFilePicker.js'
|
|
|
9
10
|
import { MFormGroup, MFormErrors, MSteps, MPagination } from './components/workflows.js'
|
|
10
11
|
import { MChip } from './components/MChip.js'
|
|
11
12
|
import { MEmptyState } from './components/MEmptyState.js'
|
|
12
|
-
import type { App } from 'vue'
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
installAppToast,
|
|
18
|
-
themeKey,
|
|
19
|
-
type ThemeContextOptions,
|
|
20
|
-
} from '@getcortexlabs/mavis-core/vue'
|
|
21
|
-
import { systemAppearance } from './appearance.js'
|
|
13
|
+
import type { App, Component } from 'vue'
|
|
14
|
+
import { createMavisServices, type MavisServiceOptions } from './services.js'
|
|
15
|
+
export { createMavisServices } from './services.js'
|
|
16
|
+
export type { MavisServiceOptions, MavisIconOptions } from './services.js'
|
|
17
|
+
import { MThemeProvider, MSpan } from '@getcortexlabs/mavis-core/vue'
|
|
22
18
|
import { MScreen } from './components/MScreen.js'
|
|
23
19
|
import { MBox, MRow, MColumn } from './components/layout.js'
|
|
24
20
|
import { MCard } from './components/MCard.js'
|
|
@@ -54,6 +50,7 @@ export {
|
|
|
54
50
|
MRow,
|
|
55
51
|
MColumn,
|
|
56
52
|
MStack,
|
|
53
|
+
MGrid,
|
|
57
54
|
MLink,
|
|
58
55
|
MCard,
|
|
59
56
|
MText,
|
|
@@ -99,6 +96,7 @@ export {
|
|
|
99
96
|
useFormController,
|
|
100
97
|
useFormField,
|
|
101
98
|
useFileSelection,
|
|
99
|
+
useMavisNavigation,
|
|
102
100
|
} from '@getcortexlabs/mavis-core/vue'
|
|
103
101
|
export type {
|
|
104
102
|
MavisThemeContext,
|
|
@@ -109,64 +107,65 @@ export type {
|
|
|
109
107
|
export type { Align, Justify } from './components/layout.js'
|
|
110
108
|
export * from '@getcortexlabs/mavis-core'
|
|
111
109
|
|
|
112
|
-
export type MavisOptions =
|
|
110
|
+
export type MavisOptions = MavisServiceOptions & { components?: false | Record<string, Component> }
|
|
113
111
|
|
|
114
112
|
/** Create one plugin per application; `system` appearance follows `prefers-color-scheme`. */
|
|
115
113
|
export function createMavis(options: MavisOptions = {}) {
|
|
116
114
|
return {
|
|
117
115
|
install(app: App) {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
116
|
+
const { components, ...services } = options
|
|
117
|
+
createMavisServices(services).install(app)
|
|
118
|
+
if (components === false) return
|
|
119
|
+
for (const [name, component] of Object.entries(
|
|
120
|
+
components ?? {
|
|
121
|
+
MThemeProvider,
|
|
122
|
+
MSpan,
|
|
123
|
+
MScreen,
|
|
124
|
+
MBox,
|
|
125
|
+
MRow,
|
|
126
|
+
MColumn,
|
|
127
|
+
MStack,
|
|
128
|
+
MGrid,
|
|
129
|
+
MLink,
|
|
130
|
+
MCard,
|
|
131
|
+
MText,
|
|
132
|
+
MButton,
|
|
133
|
+
MSlider,
|
|
134
|
+
MSwitch,
|
|
135
|
+
MCheckbox,
|
|
136
|
+
MRadioGroup,
|
|
137
|
+
MSelect,
|
|
138
|
+
MToast,
|
|
139
|
+
MDialog,
|
|
140
|
+
MTabs,
|
|
141
|
+
MSkeleton,
|
|
142
|
+
MChip,
|
|
143
|
+
MEmptyState,
|
|
144
|
+
MProgress,
|
|
145
|
+
MAccordion,
|
|
146
|
+
MSegmentedControl,
|
|
147
|
+
MAlert,
|
|
148
|
+
MListItem,
|
|
149
|
+
MSeparator,
|
|
150
|
+
MAvatar,
|
|
151
|
+
MBadge,
|
|
152
|
+
MInput,
|
|
153
|
+
MIcon,
|
|
154
|
+
MReveal,
|
|
155
|
+
MSheet,
|
|
156
|
+
MDatePicker,
|
|
157
|
+
MDateRangePicker,
|
|
158
|
+
MNumberInput,
|
|
159
|
+
MMultiSelect,
|
|
160
|
+
MImage,
|
|
161
|
+
MCombobox,
|
|
162
|
+
MFilePicker,
|
|
163
|
+
MFormGroup,
|
|
164
|
+
MFormErrors,
|
|
165
|
+
MSteps,
|
|
166
|
+
MPagination,
|
|
167
|
+
},
|
|
168
|
+
)) {
|
|
170
169
|
app.component(name, component)
|
|
171
170
|
}
|
|
172
171
|
},
|
|
@@ -174,3 +173,4 @@ export function createMavis(options: MavisOptions = {}) {
|
|
|
174
173
|
}
|
|
175
174
|
|
|
176
175
|
export * from './files.js'
|
|
176
|
+
export { formatDateTime, dateTimeToCivilDate } from './date-format.js'
|
package/src/services.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { iconOptionsKey, type MavisIconOptions } from './icons.js'
|
|
2
|
+
export type { MavisIconOptions } from './icons.js'
|
|
3
|
+
import type { App } from 'vue'
|
|
4
|
+
import type { MavisNavigation } from '@getcortexlabs/mavis-core'
|
|
5
|
+
import {
|
|
6
|
+
createThemeContext,
|
|
7
|
+
installAppToast,
|
|
8
|
+
themeKey,
|
|
9
|
+
navigationKey,
|
|
10
|
+
type ThemeContextOptions,
|
|
11
|
+
} from '@getcortexlabs/mavis-core/vue'
|
|
12
|
+
import { systemAppearance } from './appearance.js'
|
|
13
|
+
|
|
14
|
+
export type MavisServiceOptions = Omit<ThemeContextOptions, 'source'> &
|
|
15
|
+
MavisIconOptions & {
|
|
16
|
+
toast?: { closeLabel?: string }
|
|
17
|
+
navigation?: MavisNavigation
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Application-owned services without global component registration. */
|
|
21
|
+
export function createMavisServices(options: MavisServiceOptions = {}) {
|
|
22
|
+
return {
|
|
23
|
+
install(app: App) {
|
|
24
|
+
installAppToast(app, options.toast)
|
|
25
|
+
const { toast: _toast, icons, iconFallback, navigation, ...theme } = options
|
|
26
|
+
const context = createThemeContext({ ...theme, source: systemAppearance() })
|
|
27
|
+
app.provide(themeKey, context)
|
|
28
|
+
app.provide(iconOptionsKey, { icons, iconFallback })
|
|
29
|
+
app.provide(navigationKey, navigation)
|
|
30
|
+
app.onUnmount(() => context.dispose())
|
|
31
|
+
},
|
|
32
|
+
}
|
|
33
|
+
}
|