@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.
Files changed (106) hide show
  1. package/README.md +4 -2
  2. package/dist/components/DateCalendar.d.ts +1 -1
  3. package/dist/components/LoadingDecoration.d.ts +2 -2
  4. package/dist/components/MAccordion.d.ts +1 -1
  5. package/dist/components/MAlert.d.ts +2 -2
  6. package/dist/components/MAvatar.d.ts +1 -1
  7. package/dist/components/MBadge.d.ts +1 -1
  8. package/dist/components/MButton.d.ts +5 -5
  9. package/dist/components/MButton.d.ts.map +1 -1
  10. package/dist/components/MButton.js +14 -8
  11. package/dist/components/MButton.js.map +1 -1
  12. package/dist/components/MCard.d.ts +3 -3
  13. package/dist/components/MCard.d.ts.map +1 -1
  14. package/dist/components/MCard.js +3 -2
  15. package/dist/components/MCard.js.map +1 -1
  16. package/dist/components/MCheckbox.d.ts +1 -1
  17. package/dist/components/MChip.d.ts +2 -2
  18. package/dist/components/MCombobox.d.ts +1 -1
  19. package/dist/components/MDatePicker.d.ts +56 -8
  20. package/dist/components/MDatePicker.d.ts.map +1 -1
  21. package/dist/components/MDatePicker.js +2 -10
  22. package/dist/components/MDatePicker.js.map +1 -1
  23. package/dist/components/MEmptyState.d.ts +2 -2
  24. package/dist/components/MGrid.d.ts +163 -0
  25. package/dist/components/MGrid.d.ts.map +1 -0
  26. package/dist/components/MGrid.js +32 -0
  27. package/dist/components/MGrid.js.map +1 -0
  28. package/dist/components/MIcon.d.ts +1 -1
  29. package/dist/components/MIcon.d.ts.map +1 -1
  30. package/dist/components/MIcon.js +7 -4
  31. package/dist/components/MIcon.js.map +1 -1
  32. package/dist/components/MImage.d.ts +48 -3
  33. package/dist/components/MImage.d.ts.map +1 -1
  34. package/dist/components/MImage.js +23 -8
  35. package/dist/components/MImage.js.map +1 -1
  36. package/dist/components/MInput.d.ts +7 -7
  37. package/dist/components/MInput.d.ts.map +1 -1
  38. package/dist/components/MInput.js +7 -0
  39. package/dist/components/MInput.js.map +1 -1
  40. package/dist/components/MLink.d.ts +1 -1
  41. package/dist/components/MLink.d.ts.map +1 -1
  42. package/dist/components/MLink.js +5 -33
  43. package/dist/components/MLink.js.map +1 -1
  44. package/dist/components/MListItem.d.ts +1 -1
  45. package/dist/components/MProgress.d.ts +2 -2
  46. package/dist/components/MRadioGroup.d.ts +1 -1
  47. package/dist/components/MReveal.d.ts +3 -3
  48. package/dist/components/MSegmentedControl.d.ts +1 -1
  49. package/dist/components/MSelect.d.ts +1 -1
  50. package/dist/components/MSheet.d.ts +10 -1
  51. package/dist/components/MSheet.d.ts.map +1 -1
  52. package/dist/components/MSheet.js +45 -14
  53. package/dist/components/MSheet.js.map +1 -1
  54. package/dist/components/MSkeleton.d.ts +1 -1
  55. package/dist/components/MStack.d.ts +3 -3
  56. package/dist/components/MStack.d.ts.map +1 -1
  57. package/dist/components/MStack.js +3 -13
  58. package/dist/components/MStack.js.map +1 -1
  59. package/dist/components/MSwitch.d.ts +1 -1
  60. package/dist/components/MTabs.d.ts +1 -1
  61. package/dist/components/MText.d.ts +2 -2
  62. package/dist/components/configurator.d.ts +3 -3
  63. package/dist/components/layout.d.ts +12 -12
  64. package/dist/content-width.d.ts +4 -0
  65. package/dist/content-width.d.ts.map +1 -0
  66. package/dist/content-width.js +62 -0
  67. package/dist/content-width.js.map +1 -0
  68. package/dist/date-format.d.ts +6 -0
  69. package/dist/date-format.d.ts.map +1 -0
  70. package/dist/date-format.js +23 -0
  71. package/dist/date-format.js.map +1 -0
  72. package/dist/icons.d.ts +14 -0
  73. package/dist/icons.d.ts.map +1 -0
  74. package/dist/icons.js +23 -0
  75. package/dist/icons.js.map +1 -0
  76. package/dist/image-effects.d.ts.map +1 -1
  77. package/dist/image-effects.js +2 -0
  78. package/dist/image-effects.js.map +1 -1
  79. package/dist/index.d.ts +11 -8
  80. package/dist/index.d.ts.map +1 -1
  81. package/dist/index.js +13 -10
  82. package/dist/index.js.map +1 -1
  83. package/dist/services.d.ts +16 -0
  84. package/dist/services.d.ts.map +1 -0
  85. package/dist/services.js +18 -0
  86. package/dist/services.js.map +1 -0
  87. package/package.json +21 -3
  88. package/src/base.css +992 -0
  89. package/src/components/MButton.ts +28 -25
  90. package/src/components/MCard.ts +3 -1
  91. package/src/components/MDatePicker.ts +1 -9
  92. package/src/components/MGrid.ts +45 -0
  93. package/src/components/MIcon.ts +7 -8
  94. package/src/components/MImage.ts +26 -11
  95. package/src/components/MInput.ts +9 -3
  96. package/src/components/MLink.ts +10 -32
  97. package/src/components/MSheet.ts +47 -14
  98. package/src/components/MStack.ts +3 -20
  99. package/src/content-width.ts +70 -0
  100. package/src/date-format.ts +36 -0
  101. package/src/icons.css +7 -0
  102. package/src/icons.ts +28 -0
  103. package/src/image-effects.ts +2 -0
  104. package/src/index.ts +63 -63
  105. package/src/services.ts +33 -0
  106. 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
@@ -0,0 +1,7 @@
1
+ @font-face {
2
+ font-family: 'lucide';
3
+ src: url('./fonts/lucide.woff2') format('woff2');
4
+ font-weight: normal;
5
+ font-style: normal;
6
+ font-display: block;
7
+ }
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
+ }
@@ -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
- MThemeProvider,
15
- MSpan,
16
- createThemeContext,
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 = Omit<ThemeContextOptions, 'source'> & { toast?: { closeLabel?: string } }
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
- installAppToast(app, options.toast)
119
- const { toast: _toast, ...theme } = options
120
- const context = createThemeContext({ ...theme, source: systemAppearance() })
121
- app.provide(themeKey, context)
122
- app.onUnmount(() => context.dispose())
123
- for (const [name, component] of Object.entries({
124
- MThemeProvider,
125
- MSpan,
126
- MScreen,
127
- MBox,
128
- MRow,
129
- MColumn,
130
- MStack,
131
- MLink,
132
- MCard,
133
- MText,
134
- MButton,
135
- MSlider,
136
- MSwitch,
137
- MCheckbox,
138
- MRadioGroup,
139
- MSelect,
140
- MToast,
141
- MDialog,
142
- MTabs,
143
- MSkeleton,
144
- MChip,
145
- MEmptyState,
146
- MProgress,
147
- MAccordion,
148
- MSegmentedControl,
149
- MAlert,
150
- MListItem,
151
- MSeparator,
152
- MAvatar,
153
- MBadge,
154
- MInput,
155
- MIcon,
156
- MReveal,
157
- MSheet,
158
- MDatePicker,
159
- MDateRangePicker,
160
- MNumberInput,
161
- MMultiSelect,
162
- MImage,
163
- MCombobox,
164
- MFilePicker,
165
- MFormGroup,
166
- MFormErrors,
167
- MSteps,
168
- MPagination,
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'
@@ -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
+ }