@getcortexlabs/mavis-web 0.1.0-alpha.1 → 0.1.0-alpha.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.
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { mavis } from '@getcortexlabs/mavis-core';
2
- import { createThemeContext, themeKey } from '@getcortexlabs/mavis-core/vue';
1
+ import { createThemeContext, themeKey, } from '@getcortexlabs/mavis-core/vue';
2
+ import { systemAppearance } from './appearance.js';
3
3
  import { MScreen } from './components/MScreen.js';
4
4
  import { MBox, MRow, MColumn } from './components/layout.js';
5
5
  import { MCard } from './components/MCard.js';
@@ -7,14 +7,18 @@ import { MText } from './components/MText.js';
7
7
  import { MButton } from './components/MButton.js';
8
8
  import { MSlider } from './components/MSlider.js';
9
9
  import { MInput } from './components/MInput.js';
10
+ import { MIcon } from './components/MIcon.js';
10
11
  import { MReveal } from './components/MReveal.js';
11
- export { MScreen, MBox, MRow, MColumn, MCard, MText, MButton, MSlider, MInput, MReveal };
12
+ export { MScreen, MBox, MRow, MColumn, MCard, MText, MButton, MSlider, MInput, MIcon, MReveal };
12
13
  export { useMavisTheme } from '@getcortexlabs/mavis-core/vue';
13
14
  export * from '@getcortexlabs/mavis-core';
15
+ /** Create one plugin per application; `system` appearance follows `prefers-color-scheme`. */
14
16
  export function createMavis(options = {}) {
15
17
  return {
16
18
  install(app) {
17
- app.provide(themeKey, createThemeContext(options.theme ?? mavis));
19
+ const context = createThemeContext({ ...options, source: systemAppearance() });
20
+ app.provide(themeKey, context);
21
+ app.onUnmount(() => context.dispose());
18
22
  for (const [name, component] of Object.entries({
19
23
  MScreen,
20
24
  MBox,
@@ -25,6 +29,7 @@ export function createMavis(options = {}) {
25
29
  MButton,
26
30
  MSlider,
27
31
  MInput,
32
+ MIcon,
28
33
  MReveal,
29
34
  })) {
30
35
  app.component(name, component);
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","source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QAAQ,EAAE,OAAO,CAAC,CAAA;YAC9B,GAAG,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAA;YACtC,KAAK,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC;gBAC7C,OAAO;gBACP,IAAI;gBACJ,IAAI;gBACJ,OAAO;gBACP,KAAK;gBACL,KAAK;gBACL,OAAO;gBACP,OAAO;gBACP,MAAM;gBACN,KAAK;gBACL,OAAO;aACR,CAAC,EAAE,CAAC;gBACH,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,CAAA;YAChC,CAAC;QACH,CAAC;KACF,CAAA;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getcortexlabs/mavis-web",
3
- "version": "0.1.0-alpha.1",
3
+ "version": "0.1.0-alpha.2",
4
4
  "description": "Mavis components for Vue Web.",
5
5
  "type": "module",
6
6
  "sideEffects": [
@@ -26,7 +26,7 @@
26
26
  "build": "tsc -p tsconfig.build.json"
27
27
  },
28
28
  "dependencies": {
29
- "@getcortexlabs/mavis-core": "0.1.0-alpha.1"
29
+ "@getcortexlabs/mavis-core": "0.1.0-alpha.2"
30
30
  },
31
31
  "peerDependencies": {
32
32
  "vue": "^3.5.42"
@@ -0,0 +1,23 @@
1
+ import type { AppearanceSource } from '@getcortexlabs/mavis-core/vue'
2
+
3
+ function query() {
4
+ if (typeof window === 'undefined' || typeof window.matchMedia !== 'function') return undefined
5
+ return window.matchMedia('(prefers-color-scheme: dark)')
6
+ }
7
+
8
+ /** `prefers-color-scheme`, read only when called so server builds never touch `window`. */
9
+ export function systemAppearance(): AppearanceSource {
10
+ return {
11
+ current() {
12
+ const media = query()
13
+ return media ? (media.matches ? 'dark' : 'light') : undefined
14
+ },
15
+ observe(listener) {
16
+ const media = query()
17
+ if (!media) return () => {}
18
+ const handler = (event: MediaQueryListEvent) => listener(event.matches ? 'dark' : 'light')
19
+ media.addEventListener('change', handler)
20
+ return () => media.removeEventListener('change', handler)
21
+ },
22
+ }
23
+ }
@@ -7,7 +7,13 @@ import {
7
7
  useDefaultShrink,
8
8
  viewAttrs,
9
9
  } from '@getcortexlabs/mavis-core/vue'
10
- import { nonNegative } from '@getcortexlabs/mavis-core'
10
+ import {
11
+ nonNegative,
12
+ iconGlyph,
13
+ iconFontFamily,
14
+ iconSizes,
15
+ checkIconOnly,
16
+ } from '@getcortexlabs/mavis-core'
11
17
  import { webAttrs } from '../style.js'
12
18
 
13
19
  export const MButton = defineComponent({
@@ -25,6 +31,32 @@ export const MButton = defineComponent({
25
31
  const text = props.loading
26
32
  ? props.loadingText
27
33
  : (props.text ?? textContent(slots.default?.()))
34
+ const hasIcon = Boolean(props.icon || props.trailingIcon)
35
+ checkIconOnly(text, hasIcon, props.accessibilityLabel)
36
+ const iconSize = iconSizes[props.size]
37
+ const paddingX = hasIcon && !text ? Math.round((size.height - iconSize) / 2) : size.padding
38
+ const span = (name: typeof props.icon) =>
39
+ name
40
+ ? h(
41
+ 'span',
42
+ {
43
+ class: 'm-icon',
44
+ 'aria-hidden': 'true',
45
+ style: {
46
+ fontFamily: iconFontFamily,
47
+ fontSize: `${iconSize}px`,
48
+ width: `${iconSize}px`,
49
+ height: `${iconSize}px`,
50
+ lineHeight: 1,
51
+ display: 'inline-flex',
52
+ alignItems: 'center',
53
+ justifyContent: 'center',
54
+ flexShrink: 0,
55
+ },
56
+ },
57
+ iconGlyph(name),
58
+ )
59
+ : null
28
60
  return h(
29
61
  'button',
30
62
  mergeProps(
@@ -32,8 +64,12 @@ export const MButton = defineComponent({
32
64
  class: 'm-button',
33
65
  style: {
34
66
  boxSizing: 'border-box',
67
+ display: 'inline-flex',
68
+ alignItems: 'center',
69
+ justifyContent: 'center',
70
+ gap: hasIcon ? '8px' : undefined,
35
71
  minHeight: `${size.height}px`,
36
- padding: `12px ${size.padding}px`,
72
+ padding: `12px ${paddingX}px`,
37
73
  fontSize: `${size.fontSize}px`,
38
74
  fontWeight: 600,
39
75
  fontFamily: 'inherit',
@@ -66,7 +102,9 @@ export const MButton = defineComponent({
66
102
  },
67
103
  },
68
104
  ),
69
- text,
105
+ hasIcon
106
+ ? [span(props.icon), text ? h('span', {}, text) : null, span(props.trailingIcon)]
107
+ : text,
70
108
  )
71
109
  }
72
110
  },
@@ -0,0 +1,39 @@
1
+ import { defineComponent, h, mergeProps } from 'vue'
2
+ import { iconProps, useMavisTheme } from '@getcortexlabs/mavis-core/vue'
3
+ import { iconFontFamily, iconGlyph, resolveIconSize } from '@getcortexlabs/mavis-core'
4
+ import { webAttrs } from '../style.js'
5
+
6
+ export const MIcon = defineComponent({
7
+ name: 'MIcon',
8
+ inheritAttrs: false,
9
+ props: iconProps,
10
+ setup(props, { attrs }) {
11
+ const { theme } = useMavisTheme()
12
+ return () => {
13
+ const size = `${resolveIconSize(props.size)}px`
14
+ return h(
15
+ 'span',
16
+ mergeProps(
17
+ {
18
+ class: 'm-icon',
19
+ style: {
20
+ fontFamily: iconFontFamily,
21
+ fontSize: size,
22
+ width: size,
23
+ height: size,
24
+ lineHeight: 1,
25
+ color: theme.value.colors[props.tone],
26
+ display: 'inline-flex',
27
+ alignItems: 'center',
28
+ justifyContent: 'center',
29
+ flexShrink: 0,
30
+ },
31
+ },
32
+ webAttrs({ ...attrs, id: props.id }),
33
+ props.label ? { role: 'img', 'aria-label': props.label } : { 'aria-hidden': 'true' },
34
+ ),
35
+ iconGlyph(props.name),
36
+ )
37
+ }
38
+ },
39
+ })
@@ -19,9 +19,11 @@ import {
19
19
  nonNegative,
20
20
  resolveDimension,
21
21
  validateInput,
22
+ iconSizes,
22
23
  type InputHandle,
23
24
  } from '@getcortexlabs/mavis-core'
24
25
  import { length, webAttrs } from '../style.js'
26
+ import { MIcon } from './MIcon.js'
25
27
 
26
28
  export const MInput = defineComponent({
27
29
  name: 'MInput',
@@ -98,6 +100,22 @@ export const MInput = defineComponent({
98
100
  const message = props.error || props.helperText
99
101
  const text = props.type === 'text' || props.type === 'search'
100
102
  const border = props.error ? colors.danger : focused.value ? colors.primary : colors.border
103
+ const inset = 16 + iconSizes.md + 10
104
+ const icon = (name: typeof props.icon, trailing: boolean) =>
105
+ name
106
+ ? h(MIcon, {
107
+ name,
108
+ size: 'md',
109
+ tone: props.error ? 'danger' : 'muted',
110
+ style: {
111
+ position: 'absolute',
112
+ [trailing ? 'right' : 'left']: '16px',
113
+ top: props.multiline ? '16px' : '50%',
114
+ transform: props.multiline ? undefined : 'translateY(-50%)',
115
+ pointerEvents: 'none',
116
+ },
117
+ })
118
+ : null
101
119
  return h(
102
120
  'div',
103
121
  mergeProps(
@@ -131,70 +149,76 @@ export const MInput = defineComponent({
131
149
  },
132
150
  props.label,
133
151
  ),
134
- h(props.multiline ? 'textarea' : 'input', {
135
- ref: editor,
136
- id,
137
- class: 'm-input-editor',
138
- type: props.multiline ? undefined : props.type,
139
- rows: props.multiline ? props.rows : undefined,
140
- value: props.modelValue,
141
- placeholder: props.placeholder,
142
- disabled: props.disabled,
143
- readonly: props.readonly,
144
- maxlength: props.maxLength,
145
- autocapitalize: props.autocapitalize ?? (text ? 'sentences' : 'none'),
146
- autocorrect: (props.autocorrect ?? text) ? 'on' : 'off',
147
- spellcheck: props.autocorrect ?? text,
148
- enterkeyhint: props.multiline ? 'enter' : props.returnKey,
149
- 'aria-invalid': props.error ? 'true' : undefined,
150
- 'aria-describedby': message ? `${id}-message` : undefined,
151
- style: {
152
- boxSizing: 'border-box',
153
- width: '100%',
154
- minWidth: 0,
155
- minHeight: `${props.multiline ? props.rows * typography.body.fontSize * 1.5 + 30 : control.md.height}px`,
156
- margin: 0,
157
- padding: '14px 16px',
158
- border: `1px solid ${border}`,
159
- borderRadius: `${radius.md}px`,
160
- outline: 'none',
161
- boxShadow: focused.value ? `0 0 0 2px ${border}` : 'none',
162
- fontFamily: 'inherit',
163
- fontSize: `${typography.body.fontSize}px`,
164
- lineHeight: '1.5',
165
- backgroundColor: props.readonly ? colors.elevated : colors.surface,
166
- color: colors.text,
167
- caretColor: colors.primary,
168
- resize: 'none',
169
- overflow: props.multiline ? 'hidden' : undefined,
170
- },
171
- onInput: (event: Event) => {
172
- if (props.disabled || props.readonly) return
173
- const value = (event.target as HTMLInputElement).value
174
- if (value !== props.modelValue) emit('update:modelValue', value)
175
- resize()
176
- },
177
- onFocus: () => {
178
- focused.value = true
179
- emit('focus')
180
- },
181
- onBlur: () => {
182
- focused.value = false
183
- emit('blur')
184
- },
185
- onKeydown: (event: KeyboardEvent) => {
186
- if (
187
- event.key !== 'Enter' ||
188
- event.isComposing ||
189
- event.keyCode === 229 ||
190
- props.multiline
191
- )
192
- return
193
- event.preventDefault()
194
- if (!props.disabled && !props.readonly)
195
- emit('submit', (event.target as HTMLInputElement).value)
196
- },
197
- }),
152
+ h('div', { class: 'm-input-field', style: { position: 'relative', display: 'flex' } }, [
153
+ h(props.multiline ? 'textarea' : 'input', {
154
+ ref: editor,
155
+ id,
156
+ class: 'm-input-editor',
157
+ type: props.multiline ? undefined : props.type,
158
+ rows: props.multiline ? props.rows : undefined,
159
+ value: props.modelValue,
160
+ placeholder: props.placeholder,
161
+ disabled: props.disabled,
162
+ readonly: props.readonly,
163
+ maxlength: props.maxLength,
164
+ autocapitalize: props.autocapitalize ?? (text ? 'sentences' : 'none'),
165
+ autocorrect: (props.autocorrect ?? text) ? 'on' : 'off',
166
+ spellcheck: props.autocorrect ?? text,
167
+ enterkeyhint: props.multiline ? 'enter' : props.returnKey,
168
+ 'aria-invalid': props.error ? 'true' : undefined,
169
+ 'aria-describedby': message ? `${id}-message` : undefined,
170
+ style: {
171
+ boxSizing: 'border-box',
172
+ width: '100%',
173
+ minWidth: 0,
174
+ minHeight: `${props.multiline ? props.rows * typography.body.fontSize * 1.5 + 30 : control.md.height}px`,
175
+ margin: 0,
176
+ padding: '14px 16px',
177
+ paddingLeft: props.icon ? `${inset}px` : undefined,
178
+ paddingRight: props.trailingIcon ? `${inset}px` : undefined,
179
+ border: `1px solid ${border}`,
180
+ borderRadius: `${radius.md}px`,
181
+ outline: 'none',
182
+ boxShadow: focused.value ? `0 0 0 2px ${border}` : 'none',
183
+ fontFamily: 'inherit',
184
+ fontSize: `${typography.body.fontSize}px`,
185
+ lineHeight: '1.5',
186
+ backgroundColor: props.readonly ? colors.elevated : colors.surface,
187
+ color: colors.text,
188
+ caretColor: colors.primary,
189
+ resize: 'none',
190
+ overflow: props.multiline ? 'hidden' : undefined,
191
+ },
192
+ onInput: (event: Event) => {
193
+ if (props.disabled || props.readonly) return
194
+ const value = (event.target as HTMLInputElement).value
195
+ if (value !== props.modelValue) emit('update:modelValue', value)
196
+ resize()
197
+ },
198
+ onFocus: () => {
199
+ focused.value = true
200
+ emit('focus')
201
+ },
202
+ onBlur: () => {
203
+ focused.value = false
204
+ emit('blur')
205
+ },
206
+ onKeydown: (event: KeyboardEvent) => {
207
+ if (
208
+ event.key !== 'Enter' ||
209
+ event.isComposing ||
210
+ event.keyCode === 229 ||
211
+ props.multiline
212
+ )
213
+ return
214
+ event.preventDefault()
215
+ if (!props.disabled && !props.readonly)
216
+ emit('submit', (event.target as HTMLInputElement).value)
217
+ },
218
+ }),
219
+ icon(props.icon, false),
220
+ icon(props.trailingIcon, true),
221
+ ]),
198
222
  message
199
223
  ? h(
200
224
  'p',
@@ -0,0 +1,45 @@
1
+ Lucide icon font 1.65.0
2
+
3
+ ISC License
4
+
5
+ Copyright (c) 2026 Lucide Icons and Contributors
6
+
7
+ Permission to use, copy, modify, and/or distribute this software for any
8
+ purpose with or without fee is hereby granted, provided that the above
9
+ copyright notice and this permission notice appear in all copies.
10
+
11
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18
+
19
+ ---
20
+
21
+ The following Lucide icons are derived from the Feather project:
22
+
23
+ airplay, alert-circle, alert-octagon, alert-triangle, aperture, arrow-down-circle, arrow-down-left, arrow-down-right, arrow-down, arrow-left-circle, arrow-left, arrow-right-circle, arrow-right, arrow-up-circle, arrow-up-left, arrow-up-right, arrow-up, at-sign, calendar, cast, check, chevron-down, chevron-left, chevron-right, chevron-up, chevrons-down, chevrons-left, chevrons-right, chevrons-up, circle, clipboard, clock, code, columns, command, compass, corner-down-left, corner-down-right, corner-left-down, corner-left-up, corner-right-down, corner-right-up, corner-up-left, corner-up-right, crosshair, database, divide-circle, divide-square, dollar-sign, download, external-link, feather, frown, hash, headphones, help-circle, info, italic, key, layout, life-buoy, link-2, link, loader, lock, log-in, log-out, maximize, meh, minimize, minimize-2, minus-circle, minus-square, minus, monitor, moon, more-horizontal, more-vertical, move, music, navigation-2, navigation, octagon, pause-circle, percent, plus-circle, plus-square, plus, power, radio, rss, search, server, share, shopping-bag, sidebar, smartphone, smile, square, table-2, tablet, target, terminal, trash-2, trash, triangle, tv, type, upload, x-circle, x-octagon, x-square, x, zoom-in, zoom-out
24
+
25
+ The MIT License (MIT) (for the icons listed above)
26
+
27
+ Copyright (c) 2013-present Cole Bemis
28
+
29
+ Permission is hereby granted, free of charge, to any person obtaining a copy
30
+ of this software and associated documentation files (the "Software"), to deal
31
+ in the Software without restriction, including without limitation the rights
32
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
33
+ copies of the Software, and to permit persons to whom the Software is
34
+ furnished to do so, subject to the following conditions:
35
+
36
+ The above copyright notice and this permission notice shall be included in all
37
+ copies or substantial portions of the Software.
38
+
39
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
40
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
41
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
42
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
43
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
44
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
45
+ SOFTWARE.
Binary file
package/src/index.ts CHANGED
@@ -1,6 +1,10 @@
1
1
  import type { App } from 'vue'
2
- import { mavis, type MavisTheme } from '@getcortexlabs/mavis-core'
3
- import { createThemeContext, themeKey } from '@getcortexlabs/mavis-core/vue'
2
+ import {
3
+ createThemeContext,
4
+ themeKey,
5
+ type ThemeContextOptions,
6
+ } from '@getcortexlabs/mavis-core/vue'
7
+ import { systemAppearance } from './appearance.js'
4
8
  import { MScreen } from './components/MScreen.js'
5
9
  import { MBox, MRow, MColumn } from './components/layout.js'
6
10
  import { MCard } from './components/MCard.js'
@@ -8,18 +12,29 @@ import { MText } from './components/MText.js'
8
12
  import { MButton } from './components/MButton.js'
9
13
  import { MSlider } from './components/MSlider.js'
10
14
  import { MInput } from './components/MInput.js'
15
+ import { MIcon } from './components/MIcon.js'
11
16
  import { MReveal } from './components/MReveal.js'
12
17
 
13
- export { MScreen, MBox, MRow, MColumn, MCard, MText, MButton, MSlider, MInput, MReveal }
18
+ export { MScreen, MBox, MRow, MColumn, MCard, MText, MButton, MSlider, MInput, MIcon, MReveal }
14
19
  export { useMavisTheme } from '@getcortexlabs/mavis-core/vue'
15
- export type { MavisThemeContext } from '@getcortexlabs/mavis-core/vue'
20
+ export type {
21
+ MavisThemeContext,
22
+ Appearance,
23
+ AppearanceMode,
24
+ AppearanceSource,
25
+ } from '@getcortexlabs/mavis-core/vue'
16
26
  export type { Align, Justify } from './components/layout.js'
17
27
  export * from '@getcortexlabs/mavis-core'
18
28
 
19
- export function createMavis(options: { theme?: MavisTheme } = {}) {
29
+ export type MavisOptions = Omit<ThemeContextOptions, 'source'>
30
+
31
+ /** Create one plugin per application; `system` appearance follows `prefers-color-scheme`. */
32
+ export function createMavis(options: MavisOptions = {}) {
20
33
  return {
21
34
  install(app: App) {
22
- app.provide(themeKey, createThemeContext(options.theme ?? mavis))
35
+ const context = createThemeContext({ ...options, source: systemAppearance() })
36
+ app.provide(themeKey, context)
37
+ app.onUnmount(() => context.dispose())
23
38
  for (const [name, component] of Object.entries({
24
39
  MScreen,
25
40
  MBox,
@@ -30,6 +45,7 @@ export function createMavis(options: { theme?: MavisTheme } = {}) {
30
45
  MButton,
31
46
  MSlider,
32
47
  MInput,
48
+ MIcon,
33
49
  MReveal,
34
50
  })) {
35
51
  app.component(name, component)
package/src/style.css CHANGED
@@ -1,3 +1,11 @@
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
+ }
8
+
1
9
  .m-screen {
2
10
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
3
11
  -webkit-font-smoothing: antialiased;
@@ -137,3 +145,12 @@
137
145
  -webkit-text-fill-color: currentColor;
138
146
  opacity: 1;
139
147
  }
148
+
149
+ .m-icon {
150
+ font-style: normal;
151
+ font-weight: normal;
152
+ font-variant: normal;
153
+ text-transform: none;
154
+ user-select: none;
155
+ -webkit-font-smoothing: antialiased;
156
+ }