@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
|
@@ -124,14 +124,14 @@ export declare const MRow: import("nativescript-vue").DefineComponent<import("na
|
|
|
124
124
|
default: undefined;
|
|
125
125
|
};
|
|
126
126
|
}>> & Readonly<{}>, {
|
|
127
|
+
justify: import("@getcortexlabs/mavis-core/vue").Justify;
|
|
127
128
|
wrap: boolean;
|
|
129
|
+
padding: import("@getcortexlabs/mavis-core").Spacing;
|
|
128
130
|
accessibilityHidden: boolean;
|
|
129
131
|
accessibilityLabel: string;
|
|
130
132
|
width: import("@getcortexlabs/mavis-core").Dimension;
|
|
131
133
|
height: import("@getcortexlabs/mavis-core").Dimension;
|
|
132
134
|
id: string;
|
|
133
|
-
justify: import("@getcortexlabs/mavis-core/vue").Justify;
|
|
134
|
-
padding: import("@getcortexlabs/mavis-core").Spacing;
|
|
135
135
|
paddingX: import("@getcortexlabs/mavis-core").Spacing;
|
|
136
136
|
paddingY: import("@getcortexlabs/mavis-core").Spacing;
|
|
137
137
|
radius: number | import("@getcortexlabs/mavis-core").Radius;
|
|
@@ -265,14 +265,14 @@ export declare const MColumn: import("nativescript-vue").DefineComponent<import(
|
|
|
265
265
|
default: undefined;
|
|
266
266
|
};
|
|
267
267
|
}>> & Readonly<{}>, {
|
|
268
|
+
justify: import("@getcortexlabs/mavis-core/vue").Justify;
|
|
268
269
|
wrap: boolean;
|
|
270
|
+
padding: import("@getcortexlabs/mavis-core").Spacing;
|
|
269
271
|
accessibilityHidden: boolean;
|
|
270
272
|
accessibilityLabel: string;
|
|
271
273
|
width: import("@getcortexlabs/mavis-core").Dimension;
|
|
272
274
|
height: import("@getcortexlabs/mavis-core").Dimension;
|
|
273
275
|
id: string;
|
|
274
|
-
justify: import("@getcortexlabs/mavis-core/vue").Justify;
|
|
275
|
-
padding: import("@getcortexlabs/mavis-core").Spacing;
|
|
276
276
|
paddingX: import("@getcortexlabs/mavis-core").Spacing;
|
|
277
277
|
paddingY: import("@getcortexlabs/mavis-core").Spacing;
|
|
278
278
|
radius: number | import("@getcortexlabs/mavis-core").Radius;
|
|
@@ -377,12 +377,12 @@ export declare const MBox: import("nativescript-vue").DefineComponent<import("na
|
|
|
377
377
|
default: undefined;
|
|
378
378
|
};
|
|
379
379
|
}>> & Readonly<{}>, {
|
|
380
|
+
padding: import("@getcortexlabs/mavis-core").Spacing;
|
|
380
381
|
accessibilityHidden: boolean;
|
|
381
382
|
accessibilityLabel: string;
|
|
382
383
|
width: import("@getcortexlabs/mavis-core").Dimension;
|
|
383
384
|
height: import("@getcortexlabs/mavis-core").Dimension;
|
|
384
385
|
id: string;
|
|
385
|
-
padding: import("@getcortexlabs/mavis-core").Spacing;
|
|
386
386
|
paddingX: import("@getcortexlabs/mavis-core").Spacing;
|
|
387
387
|
paddingY: import("@getcortexlabs/mavis-core").Spacing;
|
|
388
388
|
radius: number | import("@getcortexlabs/mavis-core").Radius;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../../src/vue/components/layout.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../../src/vue/components/layout.ts"],"names":[],"mappings":"AAcA,YAAY,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAA;AAuDnE,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yFAA8B,CAAA;AAC/C,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yFAAoC,CAAA;AAExD,+DAA+D;AAC/D,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yFAef,CAAA"}
|
|
@@ -2,12 +2,14 @@ import { rowProps, columnProps, useMavisTheme, layoutDirection, useDefaultShrink
|
|
|
2
2
|
import { defineComponent, h, mergeProps, provide, registerElement } from 'nativescript-vue';
|
|
3
3
|
import { resolveSpace } from '@getcortexlabs/mavis-core';
|
|
4
4
|
import { boxProps, boxStyle } from '../props.js';
|
|
5
|
-
import { MavisFlexLayout } from '../../native/flex-layout
|
|
5
|
+
import { MavisFlexLayout } from '../../native/flex-layout';
|
|
6
|
+
import { MavisBox } from '../../native/box';
|
|
6
7
|
import { useNativeViewAttrs } from '../accessibility.js';
|
|
7
8
|
registerElement('MavisFlexLayout', () => MavisFlexLayout, {
|
|
8
9
|
// NSVViewFlags.LAYOUT_VIEW is a const enum with no runtime export.
|
|
9
10
|
viewFlags: 4,
|
|
10
11
|
});
|
|
12
|
+
registerElement('MavisBox', () => MavisBox, { viewFlags: 4 });
|
|
11
13
|
const alignment = {
|
|
12
14
|
start: 'flex-start',
|
|
13
15
|
center: 'center',
|
|
@@ -55,7 +57,7 @@ export const MBox = defineComponent({
|
|
|
55
57
|
const { theme } = useMavisTheme();
|
|
56
58
|
const nativeAttrs = useNativeViewAttrs(props);
|
|
57
59
|
const shrink = useDefaultShrink();
|
|
58
|
-
return () => h('
|
|
60
|
+
return () => h('MavisBox', mergeProps({ style: boxStyle(theme.value, props, shrink) }, nativeAttrs(), attrs), slots.default?.());
|
|
59
61
|
},
|
|
60
62
|
});
|
|
61
63
|
//# sourceMappingURL=layout.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layout.js","sourceRoot":"","sources":["../../../src/vue/components/layout.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,WAAW,EACX,aAAa,EACb,eAAe,EACf,gBAAgB,GACjB,MAAM,+BAA+B,CAAA;AACtC,OAAO,EAAE,eAAe,EAAE,CAAC,EAAE,UAAU,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAC3F,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AACxD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"layout.js","sourceRoot":"","sources":["../../../src/vue/components/layout.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,WAAW,EACX,aAAa,EACb,eAAe,EACf,gBAAgB,GACjB,MAAM,+BAA+B,CAAA;AACtC,OAAO,EAAE,eAAe,EAAE,CAAC,EAAE,UAAU,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAC3F,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AACxD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAIxD,eAAe,CAAC,iBAAiB,EAAE,GAAG,EAAE,CAAC,eAAe,EAAE;IACxD,mEAAmE;IACnE,SAAS,EAAE,CAAC;CACb,CAAC,CAAA;AACF,eAAe,CAAC,UAAU,EAAE,GAAG,EAAE,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC,CAAA;AAE7D,MAAM,SAAS,GAAG;IAChB,KAAK,EAAE,YAAY;IACnB,MAAM,EAAE,QAAQ;IAChB,GAAG,EAAE,UAAU;IACf,OAAO,EAAE,SAAS;CACV,CAAA;AACV,MAAM,YAAY,GAAG;IACnB,KAAK,EAAE,YAAY;IACnB,MAAM,EAAE,QAAQ;IAChB,GAAG,EAAE,UAAU;IACf,OAAO,EAAE,eAAe;IACxB,MAAM,EAAE,cAAc;CACd,CAAA;AAEV,SAAS,YAAY,CAAC,IAAY,EAAE,SAA2B;IAC7D,OAAO,eAAe,CAAC;QACrB,IAAI;QACJ,YAAY,EAAE,KAAK;QACnB,KAAK,EAAE,SAAS,KAAK,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,WAAW;QACnD,KAAK,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE;YAC3B,MAAM,EAAE,KAAK,EAAE,GAAG,aAAa,EAAE,CAAA;YACjC,MAAM,WAAW,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAA;YAC7C,MAAM,MAAM,GAAG,gBAAgB,EAAE,CAAA;YACjC,OAAO,CAAC,eAAe,EAAE,SAAS,CAAC,CAAA;YACnC,OAAO,GAAG,EAAE,CACV,CAAC,CACC,iBAAiB,EACjB,UAAU,CACR;gBACE,KAAK,EAAE;oBACL,GAAG,QAAQ,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC;oBACvC,aAAa,EAAE,SAAS;oBACxB,UAAU,EAAE,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC;oBAClC,cAAc,EAAE,YAAY,CAAC,KAAK,CAAC,OAAO,CAAC;oBAC3C,QAAQ,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ;oBACxC,GAAG,EAAE,YAAY,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,IAAI,MAAM,CAAC;iBACpD;aACF,EACD,WAAW,EAAE,EACb,KAAK,CACN,EACD,KAAK,CAAC,OAAO,EAAE,EAAE,CAClB,CAAA;QACL,CAAC;KACF,CAAC,CAAA;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,IAAI,GAAG,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;AAC/C,MAAM,CAAC,MAAM,OAAO,GAAG,YAAY,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAA;AAExD,+DAA+D;AAC/D,MAAM,CAAC,MAAM,IAAI,GAAG,eAAe,CAAC;IAClC,IAAI,EAAE,MAAM;IACZ,YAAY,EAAE,KAAK;IACnB,KAAK,EAAE,QAAQ;IACf,KAAK,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE;QAC3B,MAAM,EAAE,KAAK,EAAE,GAAG,aAAa,EAAE,CAAA;QACjC,MAAM,WAAW,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAA;QAC7C,MAAM,MAAM,GAAG,gBAAgB,EAAE,CAAA;QACjC,OAAO,GAAG,EAAE,CACV,CAAC,CACC,UAAU,EACV,UAAU,CAAC,EAAE,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,EAAE,EAAE,WAAW,EAAE,EAAE,KAAK,CAAC,EACjF,KAAK,CAAC,OAAO,EAAE,EAAE,CAClB,CAAA;IACL,CAAC;CACF,CAAC,CAAA"}
|
package/dist/vue/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { App } from 'nativescript-vue';
|
|
2
|
-
import type
|
|
2
|
+
import { type ThemeContextOptions } from '@getcortexlabs/mavis-core/vue';
|
|
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,16 +7,16 @@ 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
|
-
export type { MavisThemeContext } from '@getcortexlabs/mavis-core/vue';
|
|
14
|
+
export type { MavisThemeContext, Appearance, AppearanceMode, AppearanceSource, } from '@getcortexlabs/mavis-core/vue';
|
|
14
15
|
export type { Align, Justify } from './components/layout.js';
|
|
15
16
|
export type {} from '@getcortexlabs/mavis-core/vue';
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}): {
|
|
17
|
+
export type MavisOptions = Omit<ThemeContextOptions, 'source'>;
|
|
18
|
+
/** Create one plugin per application; `system` appearance follows the device. Vue also resolves MButton as <m-button>. */
|
|
19
|
+
export declare function createMavis(options?: MavisOptions): {
|
|
20
20
|
install(app: App): void;
|
|
21
21
|
};
|
|
22
22
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/vue/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vue/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vue/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAGL,KAAK,mBAAmB,EACzB,MAAM,+BAA+B,CAAA;AAEtC,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA;AACjD,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AAC5D,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAA;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAA;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAA;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA;AAEjD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,CAAA;AAC/F,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAA;AAC7D,YAAY,EACV,iBAAiB,EACjB,UAAU,EACV,cAAc,EACd,gBAAgB,GACjB,MAAM,+BAA+B,CAAA;AACtC,YAAY,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AAC5D,YAAY,EAAE,MAAM,+BAA+B,CAAA;AAEnD,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,mBAAmB,EAAE,QAAQ,CAAC,CAAA;AAE9D,0HAA0H;AAC1H,wBAAgB,WAAW,CAAC,OAAO,GAAE,YAAiB;iBAErC,GAAG;EAqBnB"}
|
package/dist/vue/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { createThemeContext, themeKey, } from '@getcortexlabs/mavis-core/vue';
|
|
2
|
+
import { systemAppearance } from '../native/appearance';
|
|
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,17 @@ 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
|
-
/** Create one plugin per application. Vue also resolves MButton as <m-button>. */
|
|
14
|
+
/** Create one plugin per application; `system` appearance follows the device. Vue also resolves MButton as <m-button>. */
|
|
14
15
|
export function createMavis(options = {}) {
|
|
15
16
|
return {
|
|
16
17
|
install(app) {
|
|
17
|
-
|
|
18
|
+
const context = createThemeContext({ ...options, source: systemAppearance() });
|
|
19
|
+
app.provide(themeKey, context);
|
|
20
|
+
app.onUnmount(() => context.dispose());
|
|
18
21
|
for (const [name, component] of Object.entries({
|
|
19
22
|
MScreen,
|
|
20
23
|
MBox,
|
|
@@ -25,6 +28,7 @@ export function createMavis(options = {}) {
|
|
|
25
28
|
MButton,
|
|
26
29
|
MSlider,
|
|
27
30
|
MInput,
|
|
31
|
+
MIcon,
|
|
28
32
|
MReveal,
|
|
29
33
|
})) {
|
|
30
34
|
app.component(name, component);
|
package/dist/vue/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/vue/index.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/vue/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,kBAAkB,EAClB,QAAQ,GAET,MAAM,+BAA+B,CAAA;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA;AACjD,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AAC5D,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAA;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAA;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAA;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA;AAEjD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,CAAA;AAC/F,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAA;AAY7D,0HAA0H;AAC1H,MAAM,UAAU,WAAW,CAAC,UAAwB,EAAE;IACpD,OAAO;QACL,OAAO,CAAC,GAAQ;YACd,MAAM,OAAO,GAAG,kBAAkB,CAAC,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,EAAE,CAAC,CAAA;YAC9E,GAAG,CAAC,OAAO,CAAC,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/fonts/LICENSE
ADDED
|
@@ -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.
|
package/fonts/lucide.ttf
ADDED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getcortexlabs/mavis",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.2",
|
|
4
4
|
"description": "Mavis UI foundations for NativeScript, with a Vue integration.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
},
|
|
17
17
|
"files": [
|
|
18
18
|
"dist",
|
|
19
|
+
"fonts",
|
|
19
20
|
"platforms/android/include.gradle",
|
|
20
21
|
"platforms/android/java",
|
|
21
22
|
"src",
|
|
@@ -36,7 +37,7 @@
|
|
|
36
37
|
}
|
|
37
38
|
},
|
|
38
39
|
"dependencies": {
|
|
39
|
-
"@getcortexlabs/mavis-core": "0.1.0-alpha.
|
|
40
|
+
"@getcortexlabs/mavis-core": "0.1.0-alpha.2"
|
|
40
41
|
},
|
|
41
42
|
"nativescript": {
|
|
42
43
|
"platforms": {
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
package com.mavis.ui;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
import android.view.ViewGroup;
|
|
5
|
+
import org.nativescript.widgets.CommonLayoutParams;
|
|
6
|
+
import org.nativescript.widgets.GridLayout;
|
|
7
|
+
|
|
8
|
+
/** An auto-height Box takes its content height when the parent only limits the available space. */
|
|
9
|
+
public class Box extends GridLayout {
|
|
10
|
+
public Box(Context context) {
|
|
11
|
+
super(context);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
@Override
|
|
15
|
+
protected void onMeasure(int widthSpec, int heightSpec) {
|
|
16
|
+
if (MeasureSpec.getMode(heightSpec) == MeasureSpec.AT_MOST && isAutoHeight()) {
|
|
17
|
+
heightSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
|
|
18
|
+
}
|
|
19
|
+
super.onMeasure(widthSpec, heightSpec);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
private boolean isAutoHeight() {
|
|
23
|
+
ViewGroup.LayoutParams params = getLayoutParams();
|
|
24
|
+
if (params instanceof CommonLayoutParams) {
|
|
25
|
+
CommonLayoutParams common = (CommonLayoutParams) params;
|
|
26
|
+
return common.height < 0 && common.heightPercent <= 0;
|
|
27
|
+
}
|
|
28
|
+
return params == null || params.height < 0;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -56,5 +56,26 @@ public class FlexLayout extends FlexboxLayout {
|
|
|
56
56
|
params.flexShrink = shrinks[i];
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
+
if (!horizontal && getFlexWrap() == FLEX_WRAP_NOWRAP && getRowGap() > 0) {
|
|
60
|
+
keepRowGaps(heightSpec);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Core adds row gaps to a column's main size but not to its gap total, so its growth and shrink
|
|
65
|
+
// passes report the column shorter by every gap. Measure the single line again with the gaps.
|
|
66
|
+
private void keepRowGaps(int heightSpec) {
|
|
67
|
+
int content = getPaddingTop() + getPaddingBottom();
|
|
68
|
+
int visible = 0;
|
|
69
|
+
for (int i = 0, count = getChildCount(); i < count; i++) {
|
|
70
|
+
View child = getChildAt(i);
|
|
71
|
+
if (child.getVisibility() == View.GONE) continue;
|
|
72
|
+
LayoutParams params = (LayoutParams) child.getLayoutParams();
|
|
73
|
+
content += child.getMeasuredHeight() + params.topMargin + params.bottomMargin;
|
|
74
|
+
visible++;
|
|
75
|
+
}
|
|
76
|
+
content += getRowGap() * Math.max(0, visible - 1);
|
|
77
|
+
content = Math.max(content, getSuggestedMinimumHeight());
|
|
78
|
+
int state = getMeasuredHeightAndState() & View.MEASURED_STATE_MASK;
|
|
79
|
+
setMeasuredDimension(getMeasuredWidthAndState(), resolveSizeAndState(content, heightSpec, state));
|
|
59
80
|
}
|
|
60
81
|
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { Application, Utils } from '@nativescript/core'
|
|
2
|
+
import type { Appearance, AppearanceSource } from '@getcortexlabs/mavis-core/vue'
|
|
3
|
+
|
|
4
|
+
interface Configuration {
|
|
5
|
+
uiMode: number
|
|
6
|
+
}
|
|
7
|
+
interface Context {
|
|
8
|
+
getResources(): { getConfiguration(): Configuration }
|
|
9
|
+
registerComponentCallbacks(callbacks: object): void
|
|
10
|
+
unregisterComponentCallbacks(callbacks: object): void
|
|
11
|
+
}
|
|
12
|
+
declare const android: {
|
|
13
|
+
content: {
|
|
14
|
+
ComponentCallbacks2: new (implementation: {
|
|
15
|
+
onConfigurationChanged(configuration: Configuration): void
|
|
16
|
+
onLowMemory(): void
|
|
17
|
+
onTrimMemory(level: number): void
|
|
18
|
+
}) => object
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// android.content.res.Configuration.UI_MODE_NIGHT_MASK and UI_MODE_NIGHT_YES.
|
|
23
|
+
const NIGHT_MASK = 0x30
|
|
24
|
+
const NIGHT_YES = 0x20
|
|
25
|
+
|
|
26
|
+
function context(): Context | undefined {
|
|
27
|
+
try {
|
|
28
|
+
return Utils.android.getApplicationContext() as Context
|
|
29
|
+
} catch {
|
|
30
|
+
// The application context does not exist before launch.
|
|
31
|
+
return undefined
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const appearanceOf = (configuration: Configuration): Appearance =>
|
|
36
|
+
(configuration.uiMode & NIGHT_MASK) === NIGHT_YES ? 'dark' : 'light'
|
|
37
|
+
|
|
38
|
+
/** Reads `uiMode` from the application configuration directly; Core's window cache can lag on older devices. */
|
|
39
|
+
export function systemAppearance(): AppearanceSource {
|
|
40
|
+
return {
|
|
41
|
+
current() {
|
|
42
|
+
const app = context()
|
|
43
|
+
return app ? appearanceOf(app.getResources().getConfiguration()) : undefined
|
|
44
|
+
},
|
|
45
|
+
observe(listener) {
|
|
46
|
+
let registered: { app: Context; callbacks: object } | undefined
|
|
47
|
+
const register = () => {
|
|
48
|
+
const app = context()
|
|
49
|
+
if (!app || registered) return
|
|
50
|
+
const callbacks = new android.content.ComponentCallbacks2({
|
|
51
|
+
onConfigurationChanged: (configuration) => listener(appearanceOf(configuration)),
|
|
52
|
+
onLowMemory() {},
|
|
53
|
+
onTrimMemory() {},
|
|
54
|
+
})
|
|
55
|
+
app.registerComponentCallbacks(callbacks)
|
|
56
|
+
registered = { app, callbacks }
|
|
57
|
+
listener(appearanceOf(app.getResources().getConfiguration()))
|
|
58
|
+
}
|
|
59
|
+
// An Android 8 phone skipped one of four configuration deliveries; resuming re-reads it.
|
|
60
|
+
const resumed = () => {
|
|
61
|
+
const app = context()
|
|
62
|
+
if (app) listener(appearanceOf(app.getResources().getConfiguration()))
|
|
63
|
+
}
|
|
64
|
+
register()
|
|
65
|
+
Application.on(Application.launchEvent, register)
|
|
66
|
+
Application.on(Application.resumeEvent, resumed)
|
|
67
|
+
return () => {
|
|
68
|
+
Application.off(Application.launchEvent, register)
|
|
69
|
+
Application.off(Application.resumeEvent, resumed)
|
|
70
|
+
registered?.app.unregisterComponentCallbacks(registered.callbacks)
|
|
71
|
+
registered = undefined
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Application } from '@nativescript/core'
|
|
2
|
+
import type { Appearance, AppearanceSource } from '@getcortexlabs/mavis-core/vue'
|
|
3
|
+
|
|
4
|
+
function read(): Appearance | undefined {
|
|
5
|
+
try {
|
|
6
|
+
return (
|
|
7
|
+
Application.primaryWindow?.systemAppearance() ?? Application.systemAppearance() ?? undefined
|
|
8
|
+
)
|
|
9
|
+
} catch {
|
|
10
|
+
// Android has no application context before launch; the launch event resolves it below.
|
|
11
|
+
return undefined
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** Core reports the primary window's appearance and raises `systemAppearanceChanged` on changes. */
|
|
16
|
+
export function systemAppearance(): AppearanceSource {
|
|
17
|
+
return {
|
|
18
|
+
current: read,
|
|
19
|
+
observe(listener) {
|
|
20
|
+
const changed = (args: { newValue: Appearance }) => listener(args.newValue)
|
|
21
|
+
const launched = () => {
|
|
22
|
+
const value = read()
|
|
23
|
+
if (value) listener(value)
|
|
24
|
+
}
|
|
25
|
+
Application.on(Application.systemAppearanceChangedEvent, changed)
|
|
26
|
+
Application.on(Application.launchEvent, launched)
|
|
27
|
+
return () => {
|
|
28
|
+
Application.off(Application.systemAppearanceChangedEvent, changed)
|
|
29
|
+
Application.off(Application.launchEvent, launched)
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { GridLayout } from '@nativescript/core'
|
|
2
|
+
|
|
3
|
+
declare const com: {
|
|
4
|
+
mavis: { ui: { Box: new (context: unknown) => object } }
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export class MavisBox extends GridLayout {
|
|
8
|
+
createNativeView() {
|
|
9
|
+
return new com.mavis.ui.Box(this._context)
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { GridLayout, Utils } from '@nativescript/core'
|
|
2
|
+
|
|
3
|
+
const { layout } = Utils
|
|
4
|
+
|
|
5
|
+
/** An auto-height Box takes its content height when the parent only limits the available space. */
|
|
6
|
+
export class MavisBox extends GridLayout {
|
|
7
|
+
onMeasure(widthSpec: number, heightSpec: number) {
|
|
8
|
+
const relaxed =
|
|
9
|
+
this.effectiveHeight < 0 && layout.getMeasureSpecMode(heightSpec) === layout.AT_MOST
|
|
10
|
+
? layout.makeMeasureSpec(0, layout.UNSPECIFIED)
|
|
11
|
+
: heightSpec
|
|
12
|
+
super.onMeasure(widthSpec, relaxed)
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Button, type FormattedString } from '@nativescript/core'
|
|
2
|
+
import { formattedTextProperty } from '@nativescript/core/ui/text-base'
|
|
3
|
+
import {
|
|
4
|
+
accessibilityLabelProperty,
|
|
5
|
+
accessibilityValueProperty,
|
|
6
|
+
} from '@nativescript/core/accessibility/accessibility-properties'
|
|
7
|
+
|
|
8
|
+
type Setter = (this: Button, value: unknown) => void
|
|
9
|
+
const base = Button.prototype as unknown as Record<symbol, Setter>
|
|
10
|
+
const setLabel = base[accessibilityLabelProperty.setNative]!
|
|
11
|
+
const setValue = base[accessibilityValueProperty.setNative]!
|
|
12
|
+
const setFormatted = base[formattedTextProperty.setNative]!
|
|
13
|
+
|
|
14
|
+
/** Core copies formatted text into `text`, so its description would repeat the label after icon glyphs. */
|
|
15
|
+
export class MavisButton extends Button {
|
|
16
|
+
[accessibilityLabelProperty.setNative](value: string) {
|
|
17
|
+
setLabel.call(this, value)
|
|
18
|
+
this.describe()
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
[accessibilityValueProperty.setNative](value: string) {
|
|
22
|
+
setValue.call(this, value)
|
|
23
|
+
this.describe()
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
[formattedTextProperty.setNative](value: FormattedString) {
|
|
27
|
+
setFormatted.call(this, value)
|
|
28
|
+
this.describe()
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
private describe() {
|
|
32
|
+
if (!this.formattedText) return
|
|
33
|
+
const description = [this.accessibilityLabel, this.accessibilityValue]
|
|
34
|
+
.filter(Boolean)
|
|
35
|
+
.join('. ')
|
|
36
|
+
this.nativeViewProtected?.setContentDescription(description)
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { FlexboxLayout, View } from '@nativescript/core'
|
|
2
|
+
import { flexShrinkProperty } from '@nativescript/core/ui/layouts/flexbox-layout'
|
|
3
|
+
|
|
4
|
+
const source = flexShrinkProperty.sourceKey
|
|
5
|
+
|
|
6
|
+
/** Children without their own shrink keep their natural height in a column, like Mavis children. */
|
|
7
|
+
export function applyColumnShrink(layout: FlexboxLayout, child: View) {
|
|
8
|
+
if (!layout.flexDirection.startsWith('column')) return
|
|
9
|
+
// Core records the value source even when a local value equals the default, unlike isSet.
|
|
10
|
+
const declared = (child.style as unknown as Record<symbol, number | undefined>)[source]
|
|
11
|
+
if (!declared) child.style.flexShrink = 0
|
|
12
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { FlexboxLayout } from '@nativescript/core'
|
|
1
|
+
import { FlexboxLayout, type View } from '@nativescript/core'
|
|
2
|
+
import { applyColumnShrink } from './flex-children'
|
|
2
3
|
|
|
3
4
|
declare const com: {
|
|
4
5
|
mavis: { ui: { FlexLayout: new (context: unknown) => object } }
|
|
@@ -8,4 +9,14 @@ export class MavisFlexLayout extends FlexboxLayout {
|
|
|
8
9
|
createNativeView() {
|
|
9
10
|
return new com.mavis.ui.FlexLayout(this._context)
|
|
10
11
|
}
|
|
12
|
+
|
|
13
|
+
_registerLayoutChild(child: View) {
|
|
14
|
+
super._registerLayoutChild(child)
|
|
15
|
+
applyColumnShrink(this, child)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
onLoaded() {
|
|
19
|
+
super.onLoaded()
|
|
20
|
+
this.eachLayoutChild((child) => applyColumnShrink(this, child))
|
|
21
|
+
}
|
|
11
22
|
}
|
|
@@ -1,18 +1,36 @@
|
|
|
1
1
|
import { FlexboxLayout, Utils, type View } from '@nativescript/core'
|
|
2
|
+
import { applyColumnShrink } from './flex-children'
|
|
2
3
|
|
|
3
4
|
// Core 9.1.3 computes row heights before growing children. This adapter runs after width
|
|
4
5
|
// allocation and before cross-axis alignment; no global prototype or consumer styles change.
|
|
5
6
|
interface FlexMeasurement {
|
|
6
7
|
_determineMainSize(direction: string, widthSpec: number, heightSpec: number): void
|
|
7
|
-
_flexLines: {
|
|
8
|
+
_flexLines: {
|
|
9
|
+
_itemCount: number
|
|
10
|
+
_crossSize: number
|
|
11
|
+
_mainSize: number
|
|
12
|
+
_gapLengthInMainSize: number
|
|
13
|
+
}[]
|
|
8
14
|
_getReorderedChildAt(index: number): View
|
|
15
|
+
effectiveRowGap: number
|
|
9
16
|
}
|
|
10
17
|
|
|
11
18
|
const { layout } = Utils
|
|
12
19
|
const base = FlexboxLayout.prototype as unknown as FlexMeasurement
|
|
13
20
|
|
|
14
21
|
export class MavisFlexLayout extends FlexboxLayout {
|
|
22
|
+
_registerLayoutChild(child: View) {
|
|
23
|
+
super._registerLayoutChild(child)
|
|
24
|
+
applyColumnShrink(this, child)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
onLoaded() {
|
|
28
|
+
super.onLoaded()
|
|
29
|
+
this.eachLayoutChild((child) => applyColumnShrink(this, child))
|
|
30
|
+
}
|
|
31
|
+
|
|
15
32
|
_determineMainSize(direction: string, widthSpec: number, heightSpec: number) {
|
|
33
|
+
if (direction === 'column' || direction === 'column-reverse') this.keepRowGaps()
|
|
16
34
|
if (direction === 'column' && this.alignItems === 'stretch' && this.flexWrap === 'nowrap') {
|
|
17
35
|
const measurement = this as unknown as FlexMeasurement
|
|
18
36
|
const width =
|
|
@@ -56,6 +74,22 @@ export class MavisFlexLayout extends FlexboxLayout {
|
|
|
56
74
|
}
|
|
57
75
|
}
|
|
58
76
|
|
|
77
|
+
// Core 9.1.3 adds row gaps to a column's main size but not to its gap total, so the growth and
|
|
78
|
+
// shrink passes measured the column shorter by every gap and squeezed shrinking children.
|
|
79
|
+
private keepRowGaps() {
|
|
80
|
+
const measurement = this as unknown as FlexMeasurement
|
|
81
|
+
if (!(measurement.effectiveRowGap > 0)) return
|
|
82
|
+
let index = 0
|
|
83
|
+
for (const line of measurement._flexLines) {
|
|
84
|
+
let visible = 0
|
|
85
|
+
for (let i = 0; i < line._itemCount; i++, index++) {
|
|
86
|
+
const child = measurement._getReorderedChildAt(index)
|
|
87
|
+
if (child && !child.isCollapsed) visible++
|
|
88
|
+
}
|
|
89
|
+
line._gapLengthInMainSize = measurement.effectiveRowGap * Math.max(0, visible - 1)
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
59
93
|
private measureAtWidth(child: View, width: number, heightSpec: number) {
|
|
60
94
|
const available = Math.max(
|
|
61
95
|
0,
|