@getcortexlabs/mavis 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/README.md +4 -4
- package/dist/native/appearance.android.d.ts +4 -0
- package/dist/native/appearance.android.d.ts.map +1 -0
- package/dist/native/appearance.android.js +55 -0
- package/dist/native/appearance.android.js.map +1 -0
- package/dist/native/appearance.d.ts +4 -0
- package/dist/native/appearance.d.ts.map +1 -0
- package/dist/native/appearance.js +31 -0
- package/dist/native/appearance.js.map +1 -0
- package/dist/native/box.android.d.ts +5 -0
- package/dist/native/box.android.d.ts.map +1 -0
- package/dist/native/box.android.js +7 -0
- package/dist/native/box.android.js.map +1 -0
- package/dist/native/box.d.ts +2 -0
- package/dist/native/box.d.ts.map +1 -0
- package/dist/native/box.ios.d.ts +6 -0
- package/dist/native/box.ios.d.ts.map +1 -0
- package/dist/native/box.ios.js +12 -0
- package/dist/native/box.ios.js.map +1 -0
- package/dist/native/box.js +3 -0
- package/dist/native/box.js.map +1 -0
- package/dist/native/button.android.d.ts +11 -0
- package/dist/native/button.android.d.ts.map +1 -0
- package/dist/native/button.android.js +31 -0
- package/dist/native/button.android.js.map +1 -0
- package/dist/native/flex-children.d.ts +4 -0
- package/dist/native/flex-children.d.ts.map +1 -0
- package/dist/native/flex-children.js +12 -0
- package/dist/native/flex-children.js.map +1 -0
- package/dist/native/flex-layout.android.d.ts +3 -1
- package/dist/native/flex-layout.android.d.ts.map +1 -1
- package/dist/native/flex-layout.android.js +9 -0
- package/dist/native/flex-layout.android.js.map +1 -1
- package/dist/native/flex-layout.ios.d.ts +4 -1
- package/dist/native/flex-layout.ios.d.ts.map +1 -1
- package/dist/native/flex-layout.ios.js +28 -0
- package/dist/native/flex-layout.ios.js.map +1 -1
- package/dist/vue/components/MButton.d.ts +26 -8
- package/dist/vue/components/MButton.d.ts.map +1 -1
- package/dist/vue/components/MButton.js +25 -6
- package/dist/vue/components/MButton.js.map +1 -1
- package/dist/vue/components/MCard.d.ts +1 -1
- package/dist/vue/components/MIcon.d.ts +55 -0
- package/dist/vue/components/MIcon.d.ts.map +1 -0
- package/dist/vue/components/MIcon.js +34 -0
- package/dist/vue/components/MIcon.js.map +1 -0
- package/dist/vue/components/MInput.d.ts +31 -13
- package/dist/vue/components/MInput.d.ts.map +1 -1
- package/dist/vue/components/MInput.js +26 -5
- package/dist/vue/components/MInput.js.map +1 -1
- package/dist/vue/components/MReveal.d.ts +2 -2
- package/dist/vue/components/MReveal.js +1 -1
- package/dist/vue/components/MReveal.js.map +1 -1
- package/dist/vue/components/MScreen.d.ts +1 -1
- package/dist/vue/components/MScreen.js +1 -1
- package/dist/vue/components/MScreen.js.map +1 -1
- package/dist/vue/components/MSlider.js +1 -1
- package/dist/vue/components/MSlider.js.map +1 -1
- package/dist/vue/components/MText.d.ts +2 -2
- package/dist/vue/components/MText.js +1 -1
- package/dist/vue/components/MText.js.map +1 -1
- package/dist/vue/components/layout.d.ts +5 -5
- package/dist/vue/components/layout.d.ts.map +1 -1
- package/dist/vue/components/layout.js +4 -2
- package/dist/vue/components/layout.js.map +1 -1
- package/dist/vue/index.d.ts +7 -7
- package/dist/vue/index.d.ts.map +1 -1
- package/dist/vue/index.js +9 -5
- package/dist/vue/index.js.map +1 -1
- package/fonts/LICENSE +45 -0
- package/fonts/lucide.ttf +0 -0
- package/package.json +3 -2
- package/platforms/android/java/com/mavis/ui/Box.java +30 -0
- package/platforms/android/java/com/mavis/ui/FlexLayout.java +21 -0
- package/src/native/appearance.android.ts +75 -0
- package/src/native/appearance.ts +33 -0
- package/src/native/box.android.ts +11 -0
- package/src/native/box.ios.ts +14 -0
- package/src/native/box.ts +2 -0
- package/src/native/button.android.ts +38 -0
- package/src/native/flex-children.ts +12 -0
- package/src/native/flex-layout.android.ts +12 -1
- package/src/native/flex-layout.ios.ts +35 -1
- package/src/vue/components/MButton.ts +32 -5
- package/src/vue/components/MIcon.ts +41 -0
- package/src/vue/components/MInput.ts +27 -4
- package/src/vue/components/MReveal.ts +1 -1
- package/src/vue/components/MScreen.ts +1 -1
- package/src/vue/components/MSlider.ts +1 -1
- package/src/vue/components/MText.ts +1 -1
- package/src/vue/components/layout.ts +4 -2
- package/src/vue/index.ts +22 -8
|
@@ -6,10 +6,16 @@ import {
|
|
|
6
6
|
textContent,
|
|
7
7
|
useDefaultShrink,
|
|
8
8
|
} from '@getcortexlabs/mavis-core/vue'
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
nonNegative,
|
|
11
|
+
iconGlyph,
|
|
12
|
+
iconFontFamily,
|
|
13
|
+
iconSizes,
|
|
14
|
+
checkIconOnly,
|
|
15
|
+
} from '@getcortexlabs/mavis-core'
|
|
10
16
|
import { isAndroid } from '@nativescript/core'
|
|
11
17
|
import { usePressFeedback } from '../use-press.js'
|
|
12
|
-
import { MavisButton } from '../../native/button
|
|
18
|
+
import { MavisButton } from '../../native/button'
|
|
13
19
|
import { useNativeViewAttrs } from '../accessibility.js'
|
|
14
20
|
|
|
15
21
|
registerElement('MavisButton', () => MavisButton)
|
|
@@ -32,19 +38,30 @@ export const MButton = defineComponent({
|
|
|
32
38
|
const text = props.loading
|
|
33
39
|
? props.loadingText
|
|
34
40
|
: (props.text ?? textContent(slots.default?.()))
|
|
41
|
+
const hasIcon = Boolean(props.icon || props.trailingIcon)
|
|
42
|
+
checkIconOnly(text, hasIcon, props.accessibilityLabel)
|
|
43
|
+
const iconSize = iconSizes[props.size]
|
|
44
|
+
const minHeight = Math.max(size.height, isAndroid ? 48 : 44)
|
|
45
|
+
const paddingX = hasIcon && !text ? Math.round((minHeight - iconSize) / 2) : size.padding
|
|
46
|
+
const span = (name: typeof props.icon) =>
|
|
47
|
+
name
|
|
48
|
+
? h('Span', { text: iconGlyph(name), fontFamily: iconFontFamily, fontSize: iconSize })
|
|
49
|
+
: null
|
|
35
50
|
return h(
|
|
36
51
|
'MavisButton',
|
|
37
52
|
mergeProps(
|
|
38
53
|
{
|
|
39
54
|
// Android builds the accessible description from the current text.
|
|
40
55
|
// Apply it before updating the label/value during the same render.
|
|
56
|
+
// Core ignores text while spans render, so the plain text keeps the description short.
|
|
41
57
|
text,
|
|
58
|
+
...(hasIcon ? {} : { formattedText: null }),
|
|
42
59
|
textWrap: true,
|
|
43
60
|
iosAccessibilityAdjustsFontSize: true,
|
|
44
61
|
style: {
|
|
45
|
-
minHeight
|
|
46
|
-
paddingLeft:
|
|
47
|
-
paddingRight:
|
|
62
|
+
minHeight,
|
|
63
|
+
paddingLeft: paddingX,
|
|
64
|
+
paddingRight: paddingX,
|
|
48
65
|
paddingTop: 12,
|
|
49
66
|
paddingBottom: 12,
|
|
50
67
|
fontSize: size.fontSize,
|
|
@@ -83,6 +100,16 @@ export const MButton = defineComponent({
|
|
|
83
100
|
},
|
|
84
101
|
},
|
|
85
102
|
),
|
|
103
|
+
hasIcon
|
|
104
|
+
? [
|
|
105
|
+
h('FormattedString', {}, [
|
|
106
|
+
span(props.icon),
|
|
107
|
+
text ? h('Span', { text: props.icon ? ` ${text}` : text }) : null,
|
|
108
|
+
props.trailingIcon && text ? h('Span', { text: ' ' }) : null,
|
|
109
|
+
span(props.trailingIcon),
|
|
110
|
+
]),
|
|
111
|
+
]
|
|
112
|
+
: undefined,
|
|
86
113
|
)
|
|
87
114
|
}
|
|
88
115
|
},
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { defineComponent, h, mergeProps, registerElement } from 'nativescript-vue'
|
|
2
|
+
import { iconProps, useMavisTheme } from '@getcortexlabs/mavis-core/vue'
|
|
3
|
+
import { iconFontFamily, iconGlyph, resolveIconSize } from '@getcortexlabs/mavis-core'
|
|
4
|
+
import { MavisLabel } from '../../native/label'
|
|
5
|
+
|
|
6
|
+
registerElement('MavisIcon', () => MavisLabel)
|
|
7
|
+
|
|
8
|
+
export const MIcon = defineComponent({
|
|
9
|
+
name: 'MIcon',
|
|
10
|
+
inheritAttrs: false,
|
|
11
|
+
props: iconProps,
|
|
12
|
+
setup(props, { attrs }) {
|
|
13
|
+
const { theme } = useMavisTheme()
|
|
14
|
+
return () => {
|
|
15
|
+
const size = resolveIconSize(props.size)
|
|
16
|
+
return h(
|
|
17
|
+
'MavisIcon',
|
|
18
|
+
mergeProps(
|
|
19
|
+
{
|
|
20
|
+
id: props.id,
|
|
21
|
+
text: iconGlyph(props.name),
|
|
22
|
+
textWrap: false,
|
|
23
|
+
accessible: Boolean(props.label),
|
|
24
|
+
accessibilityHidden: !props.label,
|
|
25
|
+
accessibilityRole: 'image',
|
|
26
|
+
accessibilityLabel: props.label,
|
|
27
|
+
style: {
|
|
28
|
+
fontFamily: iconFontFamily,
|
|
29
|
+
fontSize: size,
|
|
30
|
+
color: theme.value.colors[props.tone],
|
|
31
|
+
textAlignment: 'center',
|
|
32
|
+
verticalAlignment: 'middle',
|
|
33
|
+
flexShrink: 0,
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
attrs,
|
|
37
|
+
),
|
|
38
|
+
)
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
})
|
|
@@ -19,12 +19,14 @@ import {
|
|
|
19
19
|
validateInput,
|
|
20
20
|
nonNegative,
|
|
21
21
|
resolveDimension,
|
|
22
|
+
iconSizes,
|
|
22
23
|
type InputHandle,
|
|
23
24
|
} from '@getcortexlabs/mavis-core'
|
|
24
25
|
import type { EventData, PropertyChangeData, TextField, TextView } from '@nativescript/core'
|
|
25
|
-
import { MavisTextField } from '../../native/text-field
|
|
26
|
-
import { MavisTextView } from '../../native/text-view
|
|
26
|
+
import { MavisTextField } from '../../native/text-field'
|
|
27
|
+
import { MavisTextView } from '../../native/text-view'
|
|
27
28
|
import { MText } from './MText.js'
|
|
29
|
+
import { MIcon } from './MIcon.js'
|
|
28
30
|
import { useNativeViewAttrs } from '../accessibility.js'
|
|
29
31
|
|
|
30
32
|
registerElement('MavisTextField', () => MavisTextField)
|
|
@@ -67,6 +69,25 @@ export const MInput = defineComponent({
|
|
|
67
69
|
const text = props.type === 'text' || props.type === 'search'
|
|
68
70
|
const capitalize = props.autocapitalize ?? (text ? 'sentences' : 'none')
|
|
69
71
|
const border = props.error ? colors.danger : focused.value ? colors.primary : colors.border
|
|
72
|
+
const inset = 16 + iconSizes.md + 10
|
|
73
|
+
// Icons sit over the editor box and let touches through to it.
|
|
74
|
+
const icon = (name: typeof props.icon, trailing: boolean) =>
|
|
75
|
+
name
|
|
76
|
+
? h(MIcon, {
|
|
77
|
+
name,
|
|
78
|
+
size: 'md',
|
|
79
|
+
tone: props.error ? 'danger' : 'muted',
|
|
80
|
+
row: 1,
|
|
81
|
+
isUserInteractionEnabled: false,
|
|
82
|
+
style: {
|
|
83
|
+
horizontalAlignment: trailing ? 'right' : 'left',
|
|
84
|
+
verticalAlignment: props.multiline ? 'top' : 'middle',
|
|
85
|
+
marginLeft: trailing ? 0 : 16,
|
|
86
|
+
marginRight: trailing ? 16 : 0,
|
|
87
|
+
marginTop: space.sm + (props.multiline ? 14 : 0),
|
|
88
|
+
},
|
|
89
|
+
})
|
|
90
|
+
: null
|
|
70
91
|
return h(
|
|
71
92
|
'GridLayout',
|
|
72
93
|
mergeProps(
|
|
@@ -124,8 +145,8 @@ export const MInput = defineComponent({
|
|
|
124
145
|
minWidth: 0,
|
|
125
146
|
minHeight: props.multiline ? props.rows * 24 + 30 : control.md.height,
|
|
126
147
|
padding: 14,
|
|
127
|
-
paddingLeft: 16,
|
|
128
|
-
paddingRight: 16,
|
|
148
|
+
paddingLeft: props.icon ? inset : 16,
|
|
149
|
+
paddingRight: props.trailingIcon ? inset : 16,
|
|
129
150
|
margin: 0,
|
|
130
151
|
marginTop: space.sm,
|
|
131
152
|
fontSize: typography.body.fontSize,
|
|
@@ -159,6 +180,8 @@ export const MInput = defineComponent({
|
|
|
159
180
|
emit('submit', field.text ?? '')
|
|
160
181
|
},
|
|
161
182
|
}),
|
|
183
|
+
icon(props.icon, false),
|
|
184
|
+
icon(props.trailingIcon, true),
|
|
162
185
|
message
|
|
163
186
|
? h(MText, {
|
|
164
187
|
row: 2,
|
|
@@ -4,7 +4,7 @@ import { revealProps } from '@getcortexlabs/mavis-core/vue'
|
|
|
4
4
|
import { MColumn } from './layout.js'
|
|
5
5
|
import { isAndroid, type View } from '@nativescript/core'
|
|
6
6
|
import { focusedView } from '../accessibility.js'
|
|
7
|
-
import { notifyAccessibilityLayout } from '../../native/accessibility-layout
|
|
7
|
+
import { notifyAccessibilityLayout } from '../../native/accessibility-layout'
|
|
8
8
|
|
|
9
9
|
export const MReveal = defineComponent({
|
|
10
10
|
name: 'MReveal',
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineComponent, h, mergeProps, provide, registerElement } from 'nativescript-vue'
|
|
2
2
|
import { screenProps, useMavisTheme, layoutDirection } from '@getcortexlabs/mavis-core/vue'
|
|
3
3
|
import { MColumn } from './layout.js'
|
|
4
|
-
import { MavisScreenScroll } from '../../native/screen-scroll
|
|
4
|
+
import { MavisScreenScroll } from '../../native/screen-scroll'
|
|
5
5
|
import { useNativeViewAttrs } from '../accessibility.js'
|
|
6
6
|
|
|
7
7
|
registerElement('MavisScreenScroll', () => MavisScreenScroll, {
|
|
@@ -2,7 +2,7 @@ import { defineComponent, h, mergeProps, registerElement } from 'nativescript-vu
|
|
|
2
2
|
import { sliderProps, useMavisTheme, sliderEmits } from '@getcortexlabs/mavis-core/vue'
|
|
3
3
|
import { sliderScale } from '@getcortexlabs/mavis-core'
|
|
4
4
|
import { isAndroid, type PropertyChangeData } from '@nativescript/core'
|
|
5
|
-
import { MavisSlider } from '../../native/slider
|
|
5
|
+
import { MavisSlider } from '../../native/slider'
|
|
6
6
|
import { useNativeViewAttrs } from '../accessibility.js'
|
|
7
7
|
|
|
8
8
|
registerElement('MavisSlider', () => MavisSlider)
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
useDefaultShrink,
|
|
7
7
|
} from '@getcortexlabs/mavis-core/vue'
|
|
8
8
|
import { nonNegative } from '@getcortexlabs/mavis-core'
|
|
9
|
-
import { MavisLabel } from '../../native/label
|
|
9
|
+
import { MavisLabel } from '../../native/label'
|
|
10
10
|
import { useNativeViewAttrs } from '../accessibility.js'
|
|
11
11
|
|
|
12
12
|
registerElement('MavisLabel', () => MavisLabel)
|
|
@@ -8,7 +8,8 @@ import {
|
|
|
8
8
|
import { defineComponent, h, mergeProps, provide, registerElement } from 'nativescript-vue'
|
|
9
9
|
import { resolveSpace } from '@getcortexlabs/mavis-core'
|
|
10
10
|
import { boxProps, boxStyle } from '../props.js'
|
|
11
|
-
import { MavisFlexLayout } from '../../native/flex-layout
|
|
11
|
+
import { MavisFlexLayout } from '../../native/flex-layout'
|
|
12
|
+
import { MavisBox } from '../../native/box'
|
|
12
13
|
import { useNativeViewAttrs } from '../accessibility.js'
|
|
13
14
|
|
|
14
15
|
export type { Align, Justify } from '@getcortexlabs/mavis-core/vue'
|
|
@@ -17,6 +18,7 @@ registerElement('MavisFlexLayout', () => MavisFlexLayout, {
|
|
|
17
18
|
// NSVViewFlags.LAYOUT_VIEW is a const enum with no runtime export.
|
|
18
19
|
viewFlags: 4,
|
|
19
20
|
})
|
|
21
|
+
registerElement('MavisBox', () => MavisBox, { viewFlags: 4 })
|
|
20
22
|
|
|
21
23
|
const alignment = {
|
|
22
24
|
start: 'flex-start',
|
|
@@ -79,7 +81,7 @@ export const MBox = defineComponent({
|
|
|
79
81
|
const shrink = useDefaultShrink()
|
|
80
82
|
return () =>
|
|
81
83
|
h(
|
|
82
|
-
'
|
|
84
|
+
'MavisBox',
|
|
83
85
|
mergeProps({ style: boxStyle(theme.value, props, shrink) }, nativeAttrs(), attrs),
|
|
84
86
|
slots.default?.(),
|
|
85
87
|
)
|
package/src/vue/index.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import type { App } from 'nativescript-vue'
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import {
|
|
3
|
+
createThemeContext,
|
|
4
|
+
themeKey,
|
|
5
|
+
type ThemeContextOptions,
|
|
6
|
+
} from '@getcortexlabs/mavis-core/vue'
|
|
7
|
+
import { systemAppearance } from '../native/appearance'
|
|
5
8
|
import { MScreen } from './components/MScreen.js'
|
|
6
9
|
import { MBox, MRow, MColumn } from './components/layout.js'
|
|
7
10
|
import { MCard } from './components/MCard.js'
|
|
@@ -9,19 +12,29 @@ import { MText } from './components/MText.js'
|
|
|
9
12
|
import { MButton } from './components/MButton.js'
|
|
10
13
|
import { MSlider } from './components/MSlider.js'
|
|
11
14
|
import { MInput } from './components/MInput.js'
|
|
15
|
+
import { MIcon } from './components/MIcon.js'
|
|
12
16
|
import { MReveal } from './components/MReveal.js'
|
|
13
17
|
|
|
14
|
-
export { MScreen, MBox, MRow, MColumn, MCard, MText, MButton, MSlider, MInput, MReveal }
|
|
18
|
+
export { MScreen, MBox, MRow, MColumn, MCard, MText, MButton, MSlider, MInput, MIcon, MReveal }
|
|
15
19
|
export { useMavisTheme } from '@getcortexlabs/mavis-core/vue'
|
|
16
|
-
export type {
|
|
20
|
+
export type {
|
|
21
|
+
MavisThemeContext,
|
|
22
|
+
Appearance,
|
|
23
|
+
AppearanceMode,
|
|
24
|
+
AppearanceSource,
|
|
25
|
+
} from '@getcortexlabs/mavis-core/vue'
|
|
17
26
|
export type { Align, Justify } from './components/layout.js'
|
|
18
27
|
export type {} from '@getcortexlabs/mavis-core/vue'
|
|
19
28
|
|
|
20
|
-
|
|
21
|
-
|
|
29
|
+
export type MavisOptions = Omit<ThemeContextOptions, 'source'>
|
|
30
|
+
|
|
31
|
+
/** Create one plugin per application; `system` appearance follows the device. Vue also resolves MButton as <m-button>. */
|
|
32
|
+
export function createMavis(options: MavisOptions = {}) {
|
|
22
33
|
return {
|
|
23
34
|
install(app: App) {
|
|
24
|
-
|
|
35
|
+
const context = createThemeContext({ ...options, source: systemAppearance() })
|
|
36
|
+
app.provide(themeKey, context)
|
|
37
|
+
app.onUnmount(() => context.dispose())
|
|
25
38
|
for (const [name, component] of Object.entries({
|
|
26
39
|
MScreen,
|
|
27
40
|
MBox,
|
|
@@ -32,6 +45,7 @@ export function createMavis(options: { theme?: MavisTheme } = {}) {
|
|
|
32
45
|
MButton,
|
|
33
46
|
MSlider,
|
|
34
47
|
MInput,
|
|
48
|
+
MIcon,
|
|
35
49
|
MReveal,
|
|
36
50
|
})) {
|
|
37
51
|
app.component(name, component)
|