@getcortexlabs/mavis 0.1.0-rc.13 → 0.1.0-rc.15

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 (190) hide show
  1. package/README.md +7 -5
  2. package/dist/components/bindings.d.ts +14 -0
  3. package/dist/components/bindings.d.ts.map +1 -0
  4. package/dist/components/bindings.js +21 -0
  5. package/dist/components/bindings.js.map +1 -0
  6. package/dist/components/contracts.d.ts +28 -0
  7. package/dist/components/contracts.d.ts.map +1 -0
  8. package/dist/components/contracts.js +27 -0
  9. package/dist/components/contracts.js.map +1 -0
  10. package/dist/components/controller.d.ts +56 -0
  11. package/dist/components/controller.d.ts.map +1 -0
  12. package/dist/components/controller.js +508 -0
  13. package/dist/components/controller.js.map +1 -0
  14. package/dist/components/index.d.ts +53 -0
  15. package/dist/components/index.d.ts.map +1 -0
  16. package/dist/components/index.js +95 -0
  17. package/dist/components/index.js.map +1 -0
  18. package/dist/components/style.d.ts +52 -0
  19. package/dist/components/style.d.ts.map +1 -0
  20. package/dist/components/style.js +68 -0
  21. package/dist/components/style.js.map +1 -0
  22. package/dist/components/theme.d.ts +12 -0
  23. package/dist/components/theme.d.ts.map +1 -0
  24. package/dist/components/theme.js +29 -0
  25. package/dist/components/theme.js.map +1 -0
  26. package/dist/native/box.ios.d.ts +1 -0
  27. package/dist/native/box.ios.d.ts.map +1 -1
  28. package/dist/native/box.ios.js +21 -1
  29. package/dist/native/box.ios.js.map +1 -1
  30. package/dist/native/flex-layout.ios.d.ts.map +1 -1
  31. package/dist/native/flex-layout.ios.js +4 -0
  32. package/dist/native/flex-layout.ios.js.map +1 -1
  33. package/dist/native/motion-binding.d.ts +11 -0
  34. package/dist/native/motion-binding.d.ts.map +1 -0
  35. package/dist/native/motion-binding.js +132 -0
  36. package/dist/native/motion-binding.js.map +1 -0
  37. package/dist/native/motion-region.d.ts.map +1 -1
  38. package/dist/native/motion-region.js +1 -0
  39. package/dist/native/motion-region.js.map +1 -1
  40. package/dist/native/motion-surface.d.ts +1 -1
  41. package/dist/native/motion-surface.d.ts.map +1 -1
  42. package/dist/native/motion-surface.js +40 -8
  43. package/dist/native/motion-surface.js.map +1 -1
  44. package/dist/native/navigation.d.ts +4 -0
  45. package/dist/native/navigation.d.ts.map +1 -0
  46. package/dist/native/navigation.js +16 -0
  47. package/dist/native/navigation.js.map +1 -0
  48. package/dist/native/pointer-availability.d.ts +7 -0
  49. package/dist/native/pointer-availability.d.ts.map +1 -0
  50. package/dist/native/pointer-availability.js +43 -0
  51. package/dist/native/pointer-availability.js.map +1 -0
  52. package/dist/native/scroll-motion.d.ts +1 -1
  53. package/dist/native/scroll-motion.d.ts.map +1 -1
  54. package/dist/native/scroll-motion.js +55 -16
  55. package/dist/native/scroll-motion.js.map +1 -1
  56. package/dist/native/section-scroll.d.ts +1 -1
  57. package/dist/native/section-scroll.d.ts.map +1 -1
  58. package/dist/native/section-scroll.js +19 -6
  59. package/dist/native/section-scroll.js.map +1 -1
  60. package/dist/vue/card-input.d.ts +4 -0
  61. package/dist/vue/card-input.d.ts.map +1 -0
  62. package/dist/vue/card-input.js +37 -0
  63. package/dist/vue/card-input.js.map +1 -0
  64. package/dist/vue/components/ChoiceControl.d.ts +3 -3
  65. package/dist/vue/components/LoadingDecoration.d.ts +5 -5
  66. package/dist/vue/components/MAccordion.d.ts +3 -3
  67. package/dist/vue/components/MAlert.d.ts +4 -4
  68. package/dist/vue/components/MAvatar.d.ts +4 -4
  69. package/dist/vue/components/MBadge.d.ts +3 -3
  70. package/dist/vue/components/MButton.d.ts +20 -20
  71. package/dist/vue/components/MCard.d.ts +11 -11
  72. package/dist/vue/components/MCard.d.ts.map +1 -1
  73. package/dist/vue/components/MCard.js +3 -2
  74. package/dist/vue/components/MCard.js.map +1 -1
  75. package/dist/vue/components/MCheckbox.d.ts +3 -3
  76. package/dist/vue/components/MChip.d.ts +4 -4
  77. package/dist/vue/components/MCombobox.d.ts +5 -5
  78. package/dist/vue/components/MDatePicker.d.ts +96 -96
  79. package/dist/vue/components/MDatePicker.d.ts.map +1 -1
  80. package/dist/vue/components/MDialog.d.ts +3 -3
  81. package/dist/vue/components/MEmptyState.d.ts +3 -3
  82. package/dist/vue/components/MGrid.d.ts +7 -7
  83. package/dist/vue/components/MGrid.d.ts.map +1 -1
  84. package/dist/vue/components/MGrid.js +5 -1
  85. package/dist/vue/components/MGrid.js.map +1 -1
  86. package/dist/vue/components/MIcon.d.ts +2 -2
  87. package/dist/vue/components/MImage.d.ts +7 -7
  88. package/dist/vue/components/MImageCompare.d.ts +1 -1
  89. package/dist/vue/components/MInput.d.ts +22 -22
  90. package/dist/vue/components/MLink.d.ts +5 -5
  91. package/dist/vue/components/MListItem.d.ts +5 -5
  92. package/dist/vue/components/MPinInput.d.ts +1 -1
  93. package/dist/vue/components/MPopover.d.ts +3 -3
  94. package/dist/vue/components/MProgress.d.ts +5 -5
  95. package/dist/vue/components/MRadioGroup.d.ts +3 -3
  96. package/dist/vue/components/MRangeSlider.d.ts +1 -1
  97. package/dist/vue/components/MResizablePanels.d.ts +3 -3
  98. package/dist/vue/components/MReveal.d.ts +17 -17
  99. package/dist/vue/components/MScreen.d.ts +3 -3
  100. package/dist/vue/components/MScreen.d.ts.map +1 -1
  101. package/dist/vue/components/MScreen.js +11 -1
  102. package/dist/vue/components/MScreen.js.map +1 -1
  103. package/dist/vue/components/MSegmentedControl.d.ts +3 -3
  104. package/dist/vue/components/MSelect.d.ts +4 -4
  105. package/dist/vue/components/MSheet.d.ts +7 -7
  106. package/dist/vue/components/MSkeleton.d.ts +3 -3
  107. package/dist/vue/components/MSlider.d.ts +1 -1
  108. package/dist/vue/components/MStack.d.ts +19 -19
  109. package/dist/vue/components/MStack.d.ts.map +1 -1
  110. package/dist/vue/components/MStack.js +12 -2
  111. package/dist/vue/components/MStack.js.map +1 -1
  112. package/dist/vue/components/MSwitch.d.ts +3 -3
  113. package/dist/vue/components/MTabs.d.ts +3 -3
  114. package/dist/vue/components/MText.d.ts +8 -8
  115. package/dist/vue/components/MText.d.ts.map +1 -1
  116. package/dist/vue/components/MText.js +4 -1
  117. package/dist/vue/components/MText.js.map +1 -1
  118. package/dist/vue/components/MTimePicker.d.ts +40 -40
  119. package/dist/vue/components/MTimePicker.d.ts.map +1 -1
  120. package/dist/vue/components/MTooltip.d.ts +2 -2
  121. package/dist/vue/components/MVirtualList.d.ts.map +1 -1
  122. package/dist/vue/components/MVirtualList.js +88 -67
  123. package/dist/vue/components/MVirtualList.js.map +1 -1
  124. package/dist/vue/components/advanced.d.ts +34 -34
  125. package/dist/vue/components/configurator.d.ts +33 -33
  126. package/dist/vue/components/creative.d.ts +20 -20
  127. package/dist/vue/components/dashboard.d.ts +12 -12
  128. package/dist/vue/components/dashboard.d.ts.map +1 -1
  129. package/dist/vue/components/dashboard.js +185 -69
  130. package/dist/vue/components/dashboard.js.map +1 -1
  131. package/dist/vue/components/discovery.d.ts +10 -10
  132. package/dist/vue/components/interactive.d.ts +6 -6
  133. package/dist/vue/components/layout.d.ts +45 -45
  134. package/dist/vue/components/layout.d.ts.map +1 -1
  135. package/dist/vue/components/layout.js +8 -2
  136. package/dist/vue/components/layout.js.map +1 -1
  137. package/dist/vue/components/navigation.d.ts +4 -4
  138. package/dist/vue/components/screen-components.d.ts +23 -23
  139. package/dist/vue/components/screen-components.d.ts.map +1 -1
  140. package/dist/vue/components/screen-components.js +15 -0
  141. package/dist/vue/components/screen-components.js.map +1 -1
  142. package/dist/vue/components/wayfinding.d.ts +11 -11
  143. package/dist/vue/components/workflows.d.ts +5 -5
  144. package/dist/vue/layout-context.d.ts +4 -0
  145. package/dist/vue/layout-context.d.ts.map +1 -0
  146. package/dist/vue/layout-context.js +3 -0
  147. package/dist/vue/layout-context.js.map +1 -0
  148. package/dist/vue/navigation.d.ts +1 -3
  149. package/dist/vue/navigation.d.ts.map +1 -1
  150. package/dist/vue/navigation.js +1 -15
  151. package/dist/vue/navigation.js.map +1 -1
  152. package/dist/vue/screen-overlay.d.ts +9 -0
  153. package/dist/vue/screen-overlay.d.ts.map +1 -0
  154. package/dist/vue/screen-overlay.js +17 -0
  155. package/dist/vue/screen-overlay.js.map +1 -0
  156. package/dist/vue/use-motion-surface.d.ts +2 -3
  157. package/dist/vue/use-motion-surface.d.ts.map +1 -1
  158. package/dist/vue/use-motion-surface.js +9 -134
  159. package/dist/vue/use-motion-surface.js.map +1 -1
  160. package/package.json +8 -4
  161. package/platforms/android/java/com/mavis/ui/Box.java +31 -0
  162. package/src/components/bindings.ts +32 -0
  163. package/src/components/contracts.ts +60 -0
  164. package/src/components/controller.ts +542 -0
  165. package/src/components/index.ts +136 -0
  166. package/src/components/style.ts +84 -0
  167. package/src/components/theme.ts +25 -0
  168. package/src/native/box.ios.ts +31 -1
  169. package/src/native/flex-layout.ios.ts +4 -0
  170. package/src/native/motion-binding.ts +143 -0
  171. package/src/native/motion-region.ts +1 -0
  172. package/src/native/motion-surface.ts +41 -8
  173. package/src/native/navigation.ts +15 -0
  174. package/src/native/pointer-availability.ts +44 -0
  175. package/src/native/scroll-motion.ts +60 -19
  176. package/src/native/section-scroll.ts +16 -6
  177. package/src/vue/card-input.ts +44 -0
  178. package/src/vue/components/MCard.ts +4 -3
  179. package/src/vue/components/MGrid.ts +10 -1
  180. package/src/vue/components/MScreen.ts +12 -1
  181. package/src/vue/components/MStack.ts +17 -2
  182. package/src/vue/components/MText.ts +4 -1
  183. package/src/vue/components/MVirtualList.ts +104 -78
  184. package/src/vue/components/dashboard.ts +192 -69
  185. package/src/vue/components/layout.ts +8 -0
  186. package/src/vue/components/screen-components.ts +14 -0
  187. package/src/vue/layout-context.ts +4 -0
  188. package/src/vue/navigation.ts +1 -15
  189. package/src/vue/screen-overlay.ts +20 -0
  190. package/src/vue/use-motion-surface.ts +10 -137
@@ -75,8 +75,8 @@ export declare const MNavigationRail: import("nativescript-vue").DefineComponent
75
75
  modelValue: import("@getcortexlabs/mavis-core").ChoiceValue | null;
76
76
  expandLabel: string;
77
77
  collapseLabel: string;
78
- collapsible: boolean;
79
78
  collapsed: boolean;
79
+ collapsible: boolean;
80
80
  currentLabel: string;
81
81
  }, {}, {}, {}, string, import("nativescript-vue").ComponentProvideOptions, true, {}, any>, MBreadcrumb: import("nativescript-vue").DefineComponent<import("nativescript-vue").ExtractPropTypes<{
82
82
  id: StringConstructor;
@@ -321,15 +321,15 @@ export declare const MChart: import("nativescript-vue").DefineComponent<import("
321
321
  disabled: boolean;
322
322
  modelValue: import("@getcortexlabs/mavis-core").ChartSelection | null;
323
323
  height: number;
324
- clearLabel: string;
325
324
  emptyLabel: string;
326
- missingLabel: string;
325
+ categoryLabel: string;
326
+ clearLabel: string;
327
327
  hiddenSeries: readonly import("@getcortexlabs/mavis-core").ChoiceValue[];
328
- showData: boolean;
329
- showDataLabel: string;
330
328
  hideDataLabel: string;
331
- categoryLabel: string;
329
+ missingLabel: string;
332
330
  seriesLabel: string;
331
+ showData: boolean;
332
+ showDataLabel: string;
333
333
  }, {}, {}, {}, string, import("nativescript-vue").ComponentProvideOptions, true, {}, any>;
334
334
  export declare const MCommandPalette: import("nativescript-vue").DefineComponent<import("nativescript-vue").ExtractPropTypes<{
335
335
  id: StringConstructor;
@@ -427,15 +427,15 @@ export declare const MCommandPalette: import("nativescript-vue").DefineComponent
427
427
  "onUpdate:open"?: ((_value: boolean) => any) | undefined;
428
428
  }>, {
429
429
  disabled: boolean;
430
+ closeLabel: string;
430
431
  loading: boolean;
431
- query: string;
432
+ shortcut: boolean;
433
+ emptyLabel: string;
432
434
  placeholder: string;
435
+ query: string;
433
436
  loadingLabel: string;
434
- searchLabel: string;
435
- emptyLabel: string;
436
437
  open: boolean;
437
- closeLabel: string;
438
- shortcut: boolean;
439
438
  returnFocus: import("@getcortexlabs/mavis-core").SheetReturnFocus;
439
+ searchLabel: string;
440
440
  }, {}, {}, {}, string, import("nativescript-vue").ComponentProvideOptions, true, {}, any>;
441
441
  //# sourceMappingURL=wayfinding.d.ts.map
@@ -120,8 +120,8 @@ export declare const MFormGroup: import("nativescript-vue").DefineComponent<impo
120
120
  "onUpdate:modelValue"?: ((_value: import("@getcortexlabs/mavis-core").ChoiceValue) => any) | undefined;
121
121
  }>, {
122
122
  disabled: boolean;
123
- loading: boolean;
124
123
  modelValue: import("@getcortexlabs/mavis-core").ChoiceValue | null;
124
+ loading: boolean;
125
125
  errorLabel: string;
126
126
  currentLabel: string;
127
127
  completeLabel: string;
@@ -236,16 +236,16 @@ export declare const MFormGroup: import("nativescript-vue").DefineComponent<impo
236
236
  }>, {
237
237
  label: string;
238
238
  disabled: boolean;
239
- loading: boolean;
240
239
  modelValue: number;
240
+ loading: boolean;
241
241
  emptyLabel: string;
242
- previousLabel: string;
243
242
  nextLabel: string;
243
+ previousLabel: string;
244
244
  currentLabel: string;
245
+ invalidPageLabel: string;
246
+ pageLabel: string;
245
247
  pageSize: number;
246
248
  siblingCount: number;
247
- pageLabel: string;
248
249
  statusText: string;
249
- invalidPageLabel: string;
250
250
  }, {}, {}, {}, string, import("nativescript-vue").ComponentProvideOptions, true, {}, any>;
251
251
  //# sourceMappingURL=workflows.d.ts.map
@@ -0,0 +1,4 @@
1
+ import type { InjectionKey } from 'nativescript-vue';
2
+ /** Text directly in a layered box starts at its top, like text in a CSS grid cell. */
3
+ export declare const boxLayer: InjectionKey<boolean>;
4
+ //# sourceMappingURL=layout-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout-context.d.ts","sourceRoot":"","sources":["../../src/vue/layout-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAEpD,sFAAsF;AACtF,eAAO,MAAM,QAAQ,EAAE,YAAY,CAAC,OAAO,CAA4B,CAAA"}
@@ -0,0 +1,3 @@
1
+ /** Text directly in a layered box starts at its top, like text in a CSS grid cell. */
2
+ export const boxLayer = Symbol('mavis.boxLayer');
3
+ //# sourceMappingURL=layout-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout-context.js","sourceRoot":"","sources":["../../src/vue/layout-context.ts"],"names":[],"mappings":"AAEA,sFAAsF;AACtF,MAAM,CAAC,MAAM,QAAQ,GAA0B,MAAM,CAAC,gBAAgB,CAAC,CAAA"}
@@ -1,4 +1,2 @@
1
- import { type NavigationOptions } from '@getcortexlabs/mavis-core';
2
- export declare function nativeDestination(options: NavigationOptions): string;
3
- export declare function navigateNative(options: NavigationOptions): Promise<void>;
1
+ export { nativeDestination, navigateNative } from '../native/navigation.js';
4
2
  //# sourceMappingURL=navigation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"navigation.d.ts","sourceRoot":"","sources":["../../src/vue/navigation.ts"],"names":[],"mappings":"AACA,OAAO,EAAmB,KAAK,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAEnF,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,iBAAiB,UAK3D;AAED,wBAAsB,cAAc,CAAC,OAAO,EAAE,iBAAiB,iBAI9D"}
1
+ {"version":3,"file":"navigation.d.ts","sourceRoot":"","sources":["../../src/vue/navigation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA"}
@@ -1,16 +1,2 @@
1
- import { Utils } from '@nativescript/core';
2
- import { linkDestination } from '@getcortexlabs/mavis-core';
3
- export function nativeDestination(options) {
4
- const href = linkDestination(options.href);
5
- if (!options.navigate && !/^[a-z][a-z\d+.-]*:/i.test(href))
6
- throw new TypeError('Native navigation needs a navigate handler for in-app destinations.');
7
- return href;
8
- }
9
- export async function navigateNative(options) {
10
- const href = nativeDestination(options);
11
- if (options.navigate)
12
- await options.navigate(href);
13
- else if (!(await Utils.openUrl(href)))
14
- throw new Error(`The system could not open ${href}.`);
15
- }
1
+ export { nativeDestination, navigateNative } from '../native/navigation.js';
16
2
  //# sourceMappingURL=navigation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"navigation.js","sourceRoot":"","sources":["../../src/vue/navigation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAC1C,OAAO,EAAE,eAAe,EAA0B,MAAM,2BAA2B,CAAA;AAEnF,MAAM,UAAU,iBAAiB,CAAC,OAA0B;IAC1D,MAAM,IAAI,GAAG,eAAe,CAAC,OAAO,CAAC,IAAK,CAAC,CAAA;IAC3C,IAAI,CAAC,OAAO,CAAC,QAAQ,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC;QACxD,MAAM,IAAI,SAAS,CAAC,qEAAqE,CAAC,CAAA;IAC5F,OAAO,IAAI,CAAA;AACb,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,OAA0B;IAC7D,MAAM,IAAI,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAA;IACvC,IAAI,OAAO,CAAC,QAAQ;QAAE,MAAM,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;SAC7C,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,6BAA6B,IAAI,GAAG,CAAC,CAAA;AAC9F,CAAC"}
1
+ {"version":3,"file":"navigation.js","sourceRoot":"","sources":["../../src/vue/navigation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA"}
@@ -0,0 +1,9 @@
1
+ import { type InjectionKey } from 'nativescript-vue';
2
+ /** Only the screen's decorative slot inherits this; modal and toast hosts do not. */
3
+ export declare const screenOverlay: InjectionKey<boolean>;
4
+ export declare function useOverlayLayout(): (attrs: Record<string, unknown>) => {
5
+ isPassThroughParentEnabled?: undefined;
6
+ } | {
7
+ isPassThroughParentEnabled: boolean;
8
+ };
9
+ //# sourceMappingURL=screen-overlay.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"screen-overlay.d.ts","sourceRoot":"","sources":["../../src/vue/screen-overlay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAE5D,qFAAqF;AACrF,eAAO,MAAM,aAAa,EAAE,YAAY,CAAC,OAAO,CAAiC,CAAA;AAEjF,wBAAgB,gBAAgB,KAEtB,OAAO,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;;EAYvC"}
@@ -0,0 +1,17 @@
1
+ import { inject } from 'nativescript-vue';
2
+ /** Only the screen's decorative slot inherits this; modal and toast hosts do not. */
3
+ export const screenOverlay = Symbol('mavis.screenOverlay');
4
+ export function useOverlayLayout() {
5
+ const overlay = inject(screenOverlay, false);
6
+ return (attrs) => {
7
+ if (!overlay)
8
+ return {};
9
+ const style = attrs.style;
10
+ // Explicit native gestures and the Web's pointer opt-in keep interactive
11
+ // layers usable. Plain nested layouts let their empty area pass through.
12
+ const interactive = style?.pointerEvents === 'auto' ||
13
+ ['onTap', 'onTouch', 'onPan', 'onLongPress', 'onDoubleTap', 'onSwipe'].some((name) => attrs[name]);
14
+ return { isPassThroughParentEnabled: !interactive };
15
+ };
16
+ }
17
+ //# sourceMappingURL=screen-overlay.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"screen-overlay.js","sourceRoot":"","sources":["../../src/vue/screen-overlay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAqB,MAAM,kBAAkB,CAAA;AAE5D,qFAAqF;AACrF,MAAM,CAAC,MAAM,aAAa,GAA0B,MAAM,CAAC,qBAAqB,CAAC,CAAA;AAEjF,MAAM,UAAU,gBAAgB;IAC9B,MAAM,OAAO,GAAG,MAAM,CAAC,aAAa,EAAE,KAAK,CAAC,CAAA;IAC5C,OAAO,CAAC,KAA8B,EAAE,EAAE;QACxC,IAAI,CAAC,OAAO;YAAE,OAAO,EAAE,CAAA;QACvB,MAAM,KAAK,GAAG,KAAK,CAAC,KAA+C,CAAA;QACnE,yEAAyE;QACzE,yEAAyE;QACzE,MAAM,WAAW,GACf,KAAK,EAAE,aAAa,KAAK,MAAM;YAC/B,CAAC,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,SAAS,CAAC,CAAC,IAAI,CACzE,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CACtB,CAAA;QACH,OAAO,EAAE,0BAA0B,EAAE,CAAC,WAAW,EAAE,CAAA;IACrD,CAAC,CAAA;AACH,CAAC"}
@@ -1,8 +1,7 @@
1
- import { type EventData } from '@nativescript/core';
2
- import { type MotionSurface } from '@getcortexlabs/mavis-core/experimental';
1
+ import type { MotionSurface } from '@getcortexlabs/mavis-core/experimental';
3
2
  export declare function useMotionSurface(surface: () => MotionSurface | undefined, enabled?: () => boolean, plainText?: () => boolean, afterLayout?: boolean): {
4
3
  allowsActivation: () => boolean;
5
- onLoaded(event: EventData): void;
4
+ onLoaded: (event: import("@nativescript/core").EventData) => void;
6
5
  onUnloaded: () => void;
7
6
  };
8
7
  //# sourceMappingURL=use-motion-surface.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-motion-surface.d.ts","sourceRoot":"","sources":["../../src/vue/use-motion-surface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,SAAS,EAAa,MAAM,oBAAoB,CAAA;AAGhF,OAAO,EAKL,KAAK,aAAa,EACnB,MAAM,wCAAwC,CAAA;AAM/C,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,aAAa,GAAG,SAAS,EACxC,OAAO,GAAE,MAAM,OAAoB,EACnC,SAAS,GAAE,MAAM,OAAqB,EACtC,WAAW,UAAQ;;oBA4HD,SAAS;;EAM5B"}
1
+ {"version":3,"file":"use-motion-surface.d.ts","sourceRoot":"","sources":["../../src/vue/use-motion-surface.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAA;AAI3E,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,aAAa,GAAG,SAAS,EACxC,OAAO,GAAE,MAAM,OAAoB,EACnC,SAAS,GAAE,MAAM,OAAqB,EACtC,WAAW,UAAQ;;;;EAapB"}
@@ -1,143 +1,18 @@
1
- import { Utils, isAndroid } from '@nativescript/core';
2
1
  import { inject, onBeforeUnmount, watch } from 'nativescript-vue';
3
- import { animate, set, onReducedMotion } from '@rafaelaugusto/jolt';
4
- import { bindMotionSurface, motionChannels, motionKeyframes, } from '@getcortexlabs/mavis-core/experimental';
5
- import { nativeContinuousSurface } from '../native/motion-surface.js';
6
- import { nativeMotionOwner } from '../native/motion-owner.js';
2
+ import { createNativeMotionSurface } from '../native/motion-binding.js';
7
3
  import { perspectiveKey } from './perspective.js';
8
- import { takeShadow } from '../native/moved-shadow.js';
9
4
  export function useMotionSurface(surface, enabled = () => true, plainText = () => false, afterLayout = false) {
10
- let view;
11
- let unbind;
12
- let offPreference;
13
- let continuous;
14
- const active = new Map();
15
- let layoutView;
16
- let layoutQueued = false;
17
5
  const perspective = inject(perspectiveKey, undefined);
18
- let flat;
19
- const project = () => {
20
- const depth = perspective?.();
21
- if (flat && (depth === undefined || flat.view !== view)) {
22
- flat.view.perspective = flat.perspective;
23
- flat = undefined;
24
- }
25
- if (!view || depth === undefined || !unbind)
26
- return;
27
- flat ??= { view, perspective: view.perspective };
28
- // Core multiplies by the density for Android's camera distance, whose unit is not the
29
- // CSS distance. This is the factor that draws the same projection as iOS and the Web.
30
- view.perspective = isAndroid ? depth * Utils.layout.getDisplayDensity() * Math.sqrt(5) : depth;
31
- };
32
- const clearLayout = () => {
33
- layoutView?.off('layoutChanged', laidOut);
34
- layoutView = undefined;
35
- };
36
- const release = () => {
37
- unbind?.();
38
- unbind = undefined;
39
- continuous = undefined;
40
- offPreference?.();
41
- offPreference = undefined;
42
- for (const handle of active.keys())
43
- handle.stop();
44
- active.clear();
45
- project();
46
- };
47
- const bind = () => {
48
- release();
49
- const target = view;
50
- const reference = surface();
51
- if (!target || !reference)
52
- return;
53
- if (afterLayout &&
54
- (!target.isLayoutValid ||
55
- target.getActualSize().width <= 0 ||
56
- target.getActualSize().height <= 0)) {
57
- if (layoutView !== target) {
58
- clearLayout();
59
- layoutView = target;
60
- target.on('layoutChanged', laidOut);
61
- }
62
- return;
63
- }
64
- clearLayout();
65
- continuous = nativeContinuousSurface(target, enabled, plainText);
66
- unbind = bindMotionSurface(reference, nativeMotionOwner({
67
- ...continuous.adapter,
68
- animate(values, options) {
69
- continuous?.interrupt(motionChannels(values));
70
- const handle = animate(target, motionKeyframes(values), options);
71
- takeShadow(target, values);
72
- active.set(handle, values);
73
- void handle.finished.then(() => active.delete(handle));
74
- return handle;
75
- },
76
- set: (values) => {
77
- continuous?.interrupt(Object.keys(values));
78
- // Jolt on Android leaves the path's translationY on the view when a path still in
79
- // flight is replaced by a zero-duration set (rafaelaugustos/jolt#479).
80
- if (isAndroid && ('x' in values || 'y' in values || 'rotate' in values))
81
- for (const [handle, frames] of active)
82
- if (frames.path)
83
- handle.stop();
84
- const handle = animate(target, values, { duration: 0 });
85
- takeShadow(target, values);
86
- return handle;
87
- },
88
- }, target));
89
- project();
90
- offPreference = onReducedMotion((reduced) => {
91
- if (!reduced)
92
- return;
93
- // Set only spatial channels: opacity and shadow paint can keep their timelines.
94
- const values = {};
95
- for (const frames of active.values()) {
96
- if (frames.path)
97
- Object.assign(values, {
98
- x: frames.path.end.x,
99
- y: frames.path.end.y,
100
- ...(frames.orient ? { rotate: frames.path.end.rotate } : {}),
101
- });
102
- for (const [property, value] of Object.entries(frames)) {
103
- if (property === 'opacity' || property.startsWith('shadow'))
104
- continue;
105
- const final = Array.isArray(value) ? value.at(-1) : value;
106
- if (typeof final === 'number')
107
- values[property] = final;
108
- }
109
- }
110
- if (Object.keys(values).length)
111
- set(target, values);
112
- });
113
- };
114
- const laidOut = () => {
115
- if (layoutQueued)
116
- return;
117
- layoutQueued = true;
118
- void Promise.resolve().then(() => {
119
- layoutQueued = false;
120
- if (view)
121
- bind();
122
- });
123
- };
124
- const unloaded = () => {
125
- clearLayout();
126
- release();
127
- view = undefined;
128
- };
129
- watch(surface, bind, { flush: 'post' });
6
+ const binding = createNativeMotionSurface(surface, enabled, plainText, afterLayout, perspective);
7
+ watch(surface, binding.refresh, { flush: 'post' });
130
8
  if (perspective)
131
- watch(perspective, project, { flush: 'post' });
132
- watch(enabled, () => continuous?.refresh(), { flush: 'sync' });
133
- onBeforeUnmount(unloaded);
9
+ watch(perspective, binding.refreshPerspective, { flush: 'post' });
10
+ watch(enabled, binding.refreshEnabled, { flush: 'sync' });
11
+ onBeforeUnmount(binding.onUnloaded);
134
12
  return {
135
- allowsActivation: () => continuous?.allowsActivation() ?? true,
136
- onLoaded(event) {
137
- view = event.object;
138
- bind();
139
- },
140
- onUnloaded: unloaded,
13
+ allowsActivation: binding.allowsActivation,
14
+ onLoaded: binding.onLoaded,
15
+ onUnloaded: binding.onUnloaded,
141
16
  };
142
17
  }
143
18
  //# sourceMappingURL=use-motion-surface.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-motion-surface.js","sourceRoot":"","sources":["../../src/vue/use-motion-surface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAA6B,MAAM,oBAAoB,CAAA;AAChF,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AACjE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACnE,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,eAAe,GAGhB,MAAM,wCAAwC,CAAA;AAC/C,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAA;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AAEtD,MAAM,UAAU,gBAAgB,CAC9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W,EAAE,WAAW,CAAC,CAAA;IAChG,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAA;IAClD,IAAI,WAAW;QAAE,KAAK,CAAC,WAAW,EAAE,OAAO,CAAC,kBAAkB,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAA;IAClF,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,cAAc,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAA;IACzD,eAAe,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;IACnC,OAAO;QACL,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;QAC1C,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,UAAU,EAAE,OAAO,CAAC,UAAU;KAC/B,CAAA;AACH,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@getcortexlabs/mavis",
3
- "version": "0.1.0-rc.13",
4
- "description": "Mavis UI foundations for NativeScript, with a Vue integration.",
3
+ "version": "0.1.0-rc.15",
4
+ "description": "Mavis UI foundations and direct NativeScript framework integrations.",
5
5
  "type": "module",
6
6
  "sideEffects": [
7
7
  "./dist/vue/components/layout.js",
@@ -27,6 +27,10 @@
27
27
  "./date-format": {
28
28
  "types": "./dist/date-format.d.ts",
29
29
  "default": "./dist/date-format.js"
30
+ },
31
+ "./native": {
32
+ "types": "./dist/components/index.d.ts",
33
+ "default": "./dist/components/index.js"
30
34
  }
31
35
  },
32
36
  "files": [
@@ -43,7 +47,7 @@
43
47
  },
44
48
  "peerDependencies": {
45
49
  "@nativescript/core": "^9.1.3",
46
- "@rafaelaugusto/jolt": "^0.1.0-rc.13",
50
+ "@rafaelaugusto/jolt": "^0.1.0-rc.17",
47
51
  "nativescript-vue": "^3.1.3"
48
52
  },
49
53
  "peerDependenciesMeta": {
@@ -52,7 +56,7 @@
52
56
  }
53
57
  },
54
58
  "dependencies": {
55
- "@getcortexlabs/mavis-core": "0.1.0-rc.13"
59
+ "@getcortexlabs/mavis-core": "0.1.0-rc.15"
56
60
  },
57
61
  "nativescript": {
58
62
  "platforms": {
@@ -1,6 +1,8 @@
1
1
  package com.mavis.ui;
2
2
 
3
3
  import android.content.Context;
4
+ import android.view.Gravity;
5
+ import android.view.View;
4
6
  import android.view.ViewGroup;
5
7
  import org.nativescript.widgets.CommonLayoutParams;
6
8
  import org.nativescript.widgets.GridLayout;
@@ -13,6 +15,35 @@ public class Box extends GridLayout implements MeasureMemo.Owner {
13
15
  super(context);
14
16
  }
15
17
 
18
+ @Override
19
+ protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
20
+ // Core interprets FILL plus a declared size as CENTER. Keep grid's own
21
+ // inset/margin handling, but anchor fixed layers like the Web's one cell.
22
+ int[] gravity = new int[getChildCount()];
23
+ for (int i = 0; i < getChildCount(); i++) {
24
+ View child = getChildAt(i);
25
+ CommonLayoutParams params = (CommonLayoutParams) child.getLayoutParams();
26
+ gravity[i] = params.gravity;
27
+ int value = params.gravity == -1 ? Gravity.FILL : params.gravity;
28
+ if ((params.width >= 0 || params.widthPercent > 0)
29
+ && (value & Gravity.HORIZONTAL_GRAVITY_MASK) == Gravity.FILL_HORIZONTAL) {
30
+ value = (value & ~Gravity.HORIZONTAL_GRAVITY_MASK) | Gravity.LEFT;
31
+ }
32
+ if ((params.height >= 0 || params.heightPercent > 0)
33
+ && (value & Gravity.VERTICAL_GRAVITY_MASK) == Gravity.FILL_VERTICAL) {
34
+ value = (value & ~Gravity.VERTICAL_GRAVITY_MASK) | Gravity.TOP;
35
+ }
36
+ params.gravity = value;
37
+ }
38
+ try {
39
+ super.onLayout(changed, left, top, right, bottom);
40
+ } finally {
41
+ for (int i = 0; i < gravity.length; i++) {
42
+ ((CommonLayoutParams) getChildAt(i).getLayoutParams()).gravity = gravity[i];
43
+ }
44
+ }
45
+ }
46
+
16
47
  @Override
17
48
  public int memoWidthSpec() {
18
49
  return memo.receivedWidthSpec();
@@ -0,0 +1,32 @@
1
+ import type { NativeComponentEvents } from './contracts.js'
2
+
3
+ /** Framework-specific event syntax maps to these semantic callbacks. */
4
+ export interface ComponentCallbacks {
5
+ onClick?(): void
6
+ onError?(error: unknown): void
7
+ onValueChange?(value: string): void
8
+ onSubmit?(value: string): void
9
+ onFocus?(): void
10
+ onBlur?(): void
11
+ onAction?(): void
12
+ }
13
+ export function componentEvents(props: ComponentCallbacks): NativeComponentEvents {
14
+ return {
15
+ activate: props.onClick,
16
+ error: props.onError,
17
+ valueChange: props.onValueChange,
18
+ submit: props.onSubmit,
19
+ focus: props.onFocus,
20
+ blur: props.onBlur,
21
+ action: props.onAction,
22
+ }
23
+ }
24
+
25
+ export function plainComponentText(value: unknown): string {
26
+ if (value === null || value === undefined || typeof value === 'boolean') return ''
27
+ if (typeof value === 'string' || typeof value === 'number') return String(value)
28
+ if (Array.isArray(value)) return value.map(plainComponentText).join('')
29
+ throw new TypeError(
30
+ 'This foundation text slot accepts text. Use the text prop for computed content.',
31
+ )
32
+ }
@@ -0,0 +1,60 @@
1
+ import { componentContracts, type ContractProps } from '@getcortexlabs/mavis-core'
2
+ import type { MavisThemeScope } from './theme.js'
3
+
4
+ export type NativeComponentName = keyof typeof componentContracts
5
+ export type NativeComponentProps<N extends NativeComponentName> = ContractProps<
6
+ (typeof componentContracts)[N]['props']
7
+ >
8
+ export type MBoxProps = NativeComponentProps<'MBox'>
9
+ export type MRowProps = NativeComponentProps<'MRow'>
10
+ export type MColumnProps = NativeComponentProps<'MColumn'>
11
+ export type MTextProps = NativeComponentProps<'MText'>
12
+ export type MButtonProps = NativeComponentProps<'MButton'>
13
+ export type MInputProps = NativeComponentProps<'MInput'>
14
+
15
+ export interface NativeComponentEvents {
16
+ activate?(): void
17
+ error?(error: unknown): void
18
+ valueChange?(value: string): void
19
+ submit?(value: string): void
20
+ focus?(): void
21
+ blur?(): void
22
+ action?(): void
23
+ }
24
+
25
+ export interface NativeComponentOptions {
26
+ theme?: MavisThemeScope
27
+ events?: NativeComponentEvents
28
+ }
29
+
30
+ export function componentDefaults<N extends NativeComponentName>(name: N) {
31
+ return Object.fromEntries(
32
+ Object.entries(componentContracts[name].props).map(([key, definition]) => [
33
+ key,
34
+ 'default' in definition ? definition.default : undefined,
35
+ ]),
36
+ )
37
+ }
38
+
39
+ export function normalizeComponentProps<N extends NativeComponentName>(
40
+ name: N,
41
+ props: NativeComponentProps<N>,
42
+ ) {
43
+ const result = componentDefaults(name)
44
+ for (const [key, definition] of Object.entries(componentContracts[name].props)) {
45
+ const value = (props as Record<string, unknown>)[key]
46
+ if (value !== undefined) result[key] = value
47
+ if (result[key] === undefined) {
48
+ if ('required' in definition && definition.required)
49
+ throw new TypeError(`${name}.${key} is required`)
50
+ continue
51
+ }
52
+ const kinds: readonly string[] =
53
+ typeof definition.kind === 'string' ? [definition.kind] : definition.kind
54
+ if (!kinds.includes(typeof result[key]))
55
+ throw new TypeError(`${name}.${key} must be ${kinds.join(' or ')}`)
56
+ if ('values' in definition && !(definition.values as readonly unknown[]).includes(result[key]))
57
+ throw new RangeError(`Invalid ${name}.${key}: ${String(result[key])}`)
58
+ }
59
+ return result as Required<NativeComponentProps<N>>
60
+ }