@octane-xplat/ui 0.4.0 → 0.5.0

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 (67) hide show
  1. package/dist/native/octane-client-build.json +1 -1
  2. package/dist/native/ui.js +26 -23
  3. package/dist/native/ui14.js +16 -1
  4. package/dist/native/ui16.js +2 -2
  5. package/dist/native/ui24.js +2 -1
  6. package/dist/native/ui3.js +22 -1
  7. package/dist/native/ui39.js +89 -91
  8. package/dist/native/ui40.js +180 -53
  9. package/dist/native/ui41.js +55 -16
  10. package/dist/native/ui42.js +15 -6
  11. package/dist/native/ui43.js +18 -37
  12. package/dist/native/ui44.js +6 -265
  13. package/dist/native/ui45.js +24 -14
  14. package/dist/native/ui46.js +261 -29
  15. package/dist/native/ui47.js +17 -30
  16. package/dist/native/ui48.js +28 -65
  17. package/dist/native/ui49.js +21 -46
  18. package/dist/native/ui50.js +58 -13
  19. package/dist/native/ui51.js +65 -12
  20. package/dist/native/ui52.js +58 -86
  21. package/dist/native/ui53.js +8 -15
  22. package/dist/native/ui54.js +11 -15
  23. package/dist/native/ui55.js +82 -146
  24. package/dist/native/ui56.js +18 -17
  25. package/dist/native/ui57.js +18 -13
  26. package/dist/native/ui58.js +155 -21
  27. package/dist/native/ui59.js +32 -7
  28. package/dist/native/ui6.js +54 -12
  29. package/dist/native/ui60.js +8 -102
  30. package/dist/native/ui61.js +20 -74
  31. package/dist/native/ui62.js +8 -0
  32. package/dist/native/ui63.js +108 -0
  33. package/dist/native/ui64.js +76 -0
  34. package/dist/web/octane-client-build.json +1 -1
  35. package/dist/web/ui.js +26 -24
  36. package/dist/web/ui13.js +106 -41
  37. package/dist/web/ui34.js +147 -67
  38. package/dist/web/ui35.js +136 -51
  39. package/dist/web/ui36.js +86 -18
  40. package/dist/web/ui37.js +20 -5
  41. package/dist/web/ui38.js +6 -37
  42. package/dist/web/ui39.js +26 -142
  43. package/dist/web/ui40.js +143 -32
  44. package/dist/web/ui41.js +42 -41
  45. package/dist/web/ui42.js +40 -74
  46. package/dist/web/ui43.js +47 -13
  47. package/dist/web/ui44.js +13 -33
  48. package/dist/web/ui45.js +60 -7
  49. package/dist/web/ui46.js +47 -42
  50. package/dist/web/ui47.js +7 -11
  51. package/dist/web/ui48.js +30 -48
  52. package/dist/web/ui49.js +12 -46
  53. package/dist/web/ui50.js +62 -16
  54. package/dist/web/ui51.js +33 -135
  55. package/dist/web/ui52.js +18 -41
  56. package/dist/web/ui53.js +266 -10
  57. package/dist/web/ui54.js +41 -8
  58. package/dist/web/ui55.js +16 -21
  59. package/dist/web/ui56.js +7 -6
  60. package/dist/web/ui57.js +20 -42
  61. package/dist/web/ui58.js +6 -44
  62. package/dist/web/ui59.js +44 -0
  63. package/dist/web/ui60.js +46 -0
  64. package/package.json +5 -1
  65. package/src/theme/tokens.css +255 -30
  66. package/types/index.d.ts +10 -0
  67. package/types/props.d.ts +59 -4
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 1,
3
- "buildId": "945217e4-b47f-4701-903e-c65b8de4bec5",
3
+ "buildId": "d5edf471-fc0d-486d-9d3d-c0ab3ededea6",
4
4
  "mode": "production",
5
5
  "capabilities": {
6
6
  "independentHydration": false
package/dist/native/ui.js CHANGED
@@ -27,26 +27,29 @@ import { openModal } from "./ui33.js";
27
27
  import { findInRootLayouts, rootLayoutFor, topRootLayout } from "./ui34.js";
28
28
  import { Overlay } from "./ui35.js";
29
29
  import { Popover } from "./ui38.js";
30
- import { showToast } from "./ui39.js";
31
- import { useAnimation } from "./ui40.js";
32
- import { styled } from "./ui41.js";
33
- import { openWindow } from "./ui42.js";
34
- import { Screen } from "./ui43.js";
35
- import { Tabs } from "./ui44.js";
36
- import { Switch } from "./ui45.js";
37
- import { useSafeAreaInsets } from "./ui46.js";
38
- import { SafeArea } from "./ui47.js";
39
- import { KeyboardAvoiding } from "./ui48.js";
40
- import { Drawer } from "./ui49.js";
41
- import { ActivityIndicator } from "./ui50.js";
42
- import { Meter } from "./ui52.js";
43
- import { Slider } from "./ui53.js";
44
- import { registerIcon, registerIcons } from "./ui54.js";
45
- import { Icon } from "./ui55.js";
46
- import { Heading } from "./ui56.js";
47
- import { PlatformBadge } from "./ui57.js";
48
- import { createStore } from "./ui58.js";
49
- import { useStore } from "./ui59.js";
50
- import { Sheet } from "./ui60.js";
51
- import { closeSheet, openSheet, sheetHost } from "./ui61.js";
52
- export { Absolute, ActivityIndicator, View as Column, Drawer, Grid, Heading, Icon, Image, KeyboardAvoiding, Link, LiquidGlass, LiquidGlassContainer, List, Meter, Modal, NavLink, Overlay, PlatformBadge, Popover, Pressable, RichText, RichTextSpan, Row, SafeArea, Screen, ScrollBox, ScrollView, Sheet, Slider, Spacer, Stack, Switch, Tabs, Text, TextArea, TextInput, View, applyThemeClasses, canGoBack, closeSheet, createStore, currentModalRoute, currentRoute, deriveRouteManifest, findInRootLayouts, getColorScheme, getStack, getThemePreference, getThemeScheme, hrefFor, layoutsForRoute, onThemeSchemeChange, openModal, openSheet, openWindow, popRoute, pushDeepLink, pushRoute, redirect, registerIcon, registerIcons, registerRoutes, registerScreens, registerStack, rootLayoutFor, routeFor, routeStacks, screenFor, setThemePreference, sheetHost, showToast, stackEntries, styled, themeSchemeClasses, topRootLayout, useAnimation, useCanGoBack, useColorScheme, useModalRoute, useRoute, useSafeAreaInsets, useStore, useThemeScheme };
30
+ import { Hoverable } from "./ui39.js";
31
+ import { showToast } from "./ui40.js";
32
+ import { useAnimation } from "./ui41.js";
33
+ import "./ui42.js";
34
+ import { styled } from "./ui43.js";
35
+ import { openWindow } from "./ui44.js";
36
+ import { Screen } from "./ui45.js";
37
+ import { Tabs } from "./ui46.js";
38
+ import { Switch } from "./ui47.js";
39
+ import { useSafeAreaInsets } from "./ui48.js";
40
+ import { SafeArea } from "./ui49.js";
41
+ import { KeyboardAvoiding } from "./ui50.js";
42
+ import { Drawer } from "./ui51.js";
43
+ import { useMeasure } from "./ui52.js";
44
+ import { ActivityIndicator } from "./ui53.js";
45
+ import { Meter } from "./ui55.js";
46
+ import { Slider } from "./ui56.js";
47
+ import { registerIcon, registerIcons } from "./ui57.js";
48
+ import { Icon } from "./ui58.js";
49
+ import { Heading } from "./ui59.js";
50
+ import { PlatformBadge } from "./ui60.js";
51
+ import { createStore } from "./ui61.js";
52
+ import { useStore } from "./ui62.js";
53
+ import { Sheet } from "./ui63.js";
54
+ import { closeSheet, openSheet, sheetHost } from "./ui64.js";
55
+ export { Absolute, ActivityIndicator, View as Column, Drawer, Grid, Heading, Hoverable, Icon, Image, KeyboardAvoiding, Link, LiquidGlass, LiquidGlassContainer, List, Meter, Modal, NavLink, Overlay, PlatformBadge, Popover, Pressable, RichText, RichTextSpan, Row, SafeArea, Screen, ScrollBox, ScrollView, Sheet, Slider, Spacer, Stack, Switch, Tabs, Text, TextArea, TextInput, View, applyThemeClasses, canGoBack, closeSheet, createStore, currentModalRoute, currentRoute, deriveRouteManifest, findInRootLayouts, getColorScheme, getStack, getThemePreference, getThemeScheme, hrefFor, layoutsForRoute, onThemeSchemeChange, openModal, openSheet, openWindow, popRoute, pushDeepLink, pushRoute, redirect, registerIcon, registerIcons, registerRoutes, registerScreens, registerStack, rootLayoutFor, routeFor, routeStacks, screenFor, setThemePreference, sheetHost, showToast, stackEntries, styled, themeSchemeClasses, topRootLayout, useAnimation, useCanGoBack, useColorScheme, useMeasure, useModalRoute, useRoute, useSafeAreaInsets, useStore, useThemeScheme };
@@ -1,5 +1,5 @@
1
1
  import { cx } from "./ui2.js";
2
- import { applyEscapeProps, nativeAccessibilityState } from "./ui3.js";
2
+ import { applyEscapeProps, nativeAccessibilityRole, nativeAccessibilityState } from "./ui3.js";
3
3
  import { layoutChildProps } from "./ui5.js";
4
4
  import { createContext, defineUniversalComponent, universalComponent, universalIf, universalPlan, universalProps, universalValue, useContext } from "@nativescript-community/octane";
5
5
  //#region src/Text.native.tsrx
@@ -98,6 +98,21 @@ var Text = defineUniversalComponent("nativescript", function Text(props) {
98
98
  "textOverflow",
99
99
  props.ellipsize ? "ellipsis" : void 0
100
100
  ],
101
+ [
102
+ "set",
103
+ "accessible",
104
+ props.accessible
105
+ ],
106
+ [
107
+ "set",
108
+ "accessibilityLabel",
109
+ props.accessibilityLabel
110
+ ],
111
+ [
112
+ "set",
113
+ "accessibilityRole",
114
+ nativeAccessibilityRole(props.accessibilityRole)
115
+ ],
101
116
  [
102
117
  "set",
103
118
  "accessibilityHint",
@@ -1,5 +1,5 @@
1
1
  import { cx } from "./ui2.js";
2
- import { applyEscapeProps, nativeAccessibilityState } from "./ui3.js";
2
+ import { applyEscapeProps, nativeAccessibilityRole, nativeAccessibilityState } from "./ui3.js";
3
3
  import { glassClassOf, glassConfigOf } from "./ui4.js";
4
4
  import { layoutChildProps } from "./ui5.js";
5
5
  import { defineUniversalComponent, universalPlan, universalProps, universalValue } from "@nativescript-community/octane";
@@ -60,7 +60,7 @@ var Pressable = defineUniversalComponent("nativescript", function Pressable(prop
60
60
  [
61
61
  "set",
62
62
  "accessibilityRole",
63
- props.accessibilityRole
63
+ nativeAccessibilityRole(props.accessibilityRole)
64
64
  ],
65
65
  [
66
66
  "set",
@@ -28,6 +28,7 @@ var __octaneUniversalPlan0 = universalPlan("nativescript", {
28
28
  });
29
29
  var TextArea = defineUniversalComponent("nativescript", function TextArea(props) {
30
30
  const el = useRef(null, _h$0);
31
+ const submitOnReturn = props.returnKeyType === "done" || props.returnKeyType === "send";
31
32
  const lineDip = (v) => {
32
33
  const ios = v?.ios?.font?.lineHeight;
33
34
  if (ios > 0) return ios;
@@ -74,7 +75,7 @@ var TextArea = defineUniversalComponent("nativescript", function TextArea(props)
74
75
  props.editable ?? true,
75
76
  (e) => fit(e.object),
76
77
  (e) => props.onChange?.(e.value),
77
- props.onSubmit,
78
+ submitOnReturn ? props.onSubmit : void 0,
78
79
  props.onFocus,
79
80
  props.onBlur
80
81
  ]);
@@ -6,6 +6,27 @@ function applyEscapeProps(view, props) {
6
6
  const bag = isIOS ? props.ios : isAndroid ? props.android : void 0;
7
7
  if (bag) Object.assign(view, bag);
8
8
  }
9
+ var NATIVE_ACCESSIBILITY_ROLES = {
10
+ button: "button",
11
+ link: "link",
12
+ search: "search",
13
+ image: "image",
14
+ heading: "header",
15
+ adjustable: "adjustable",
16
+ summary: "summary",
17
+ text: "text",
18
+ none: "none",
19
+ progressbar: "progressBar",
20
+ checkbox: "checkbox",
21
+ switch: "switch",
22
+ radio: "radioButton",
23
+ spinbutton: "spinButton",
24
+ tab: "button"
25
+ };
26
+ /** Translate the shared/ARIA spelling to NativeScript's narrower role enum. */
27
+ function nativeAccessibilityRole(role) {
28
+ return role ? NATIVE_ACCESSIBILITY_ROLES[role] : void 0;
29
+ }
9
30
  /** NativeScript's AccessibilityState is a single enum value, unlike the
10
31
  * web's independent ARIA booleans. Priority follows the strongest state. */
11
32
  function nativeAccessibilityState(state) {
@@ -15,4 +36,4 @@ function nativeAccessibilityState(state) {
15
36
  if (state?.checked === false) return "unchecked";
16
37
  }
17
38
  //#endregion
18
- export { applyEscapeProps, nativeAccessibilityState };
39
+ export { applyEscapeProps, nativeAccessibilityRole, nativeAccessibilityState };
@@ -1,105 +1,103 @@
1
- import { applyThemeClasses } from "./ui31.js";
2
- import { topRootLayout } from "./ui34.js";
3
- import { createNativeScriptRoot, defineUniversalComponent, universalComponent, universalIf, universalPlan, universalProps, universalValue } from "@nativescript-community/octane";
4
- import { GridLayout, isAndroid, isIOS } from "@nativescript/core";
5
- //#region src/toast.native.tsrx
1
+ import { View } from "./ui6.js";
2
+ import { Pressable } from "./ui16.js";
3
+ import { Popover } from "./ui38.js";
4
+ import { defineUniversalComponent, hookSlots, universalChildren, universalComponent, universalPlan, universalProps, universalValue, useRef, useState } from "@nativescript-community/octane";
5
+ //#region src/Hoverable.native.tsrx
6
+ var _hs$ = /* @__PURE__ */ hookSlots(2);
7
+ var _h$0 = /* @__PURE__ */ Symbol(_hs$);
8
+ var _h$1 = /* @__PURE__ */ Symbol(_hs$ + 1);
6
9
  var __octaneUniversalPlan0 = universalPlan("nativescript", {
7
- "kind": "host",
8
- "type": "label",
9
- "props": { "className": "vx-toast" },
10
- "children": [{
11
- "kind": "slot",
12
- "slot": 0
13
- }]
10
+ "kind": "slot",
11
+ "slot": 0
14
12
  });
15
13
  var __octaneUniversalPlan1 = universalPlan("nativescript", {
16
- "kind": "host",
17
- "type": "gridlayout",
18
- "props": { "className": "vx-toast" },
14
+ "kind": "range",
19
15
  "children": [{
20
16
  "kind": "slot",
21
17
  "slot": 0
18
+ }, {
19
+ "kind": "slot",
20
+ "slot": 1
22
21
  }]
23
22
  });
24
23
  var __octaneUniversalPlan2 = universalPlan("nativescript", {
25
24
  "kind": "slot",
26
25
  "slot": 0
27
26
  });
28
- var queue = [];
29
- var active = null;
30
- var ToastBody = defineUniversalComponent("nativescript", function ToastBody(props) {
31
- return universalValue(__octaneUniversalPlan2, [universalIf(typeof props.content === "string", () => {
32
- return universalValue(__octaneUniversalPlan0, [props.content]);
33
- }, () => {
34
- const Component = props.content;
35
- return universalValue(__octaneUniversalPlan1, [universalComponent("nativescript", Component, universalProps([]))]);
36
- })]);
27
+ var Hoverable = defineUniversalComponent("nativescript", function Hoverable(props) {
28
+ const [open, setOpen] = useState(false, _h$0);
29
+ const anchor = useRef(null, _h$1);
30
+ return universalValue(__octaneUniversalPlan2, [universalComponent("nativescript", View, universalProps([
31
+ [
32
+ "set",
33
+ "className",
34
+ props.className
35
+ ],
36
+ [
37
+ "set",
38
+ "style",
39
+ props.style
40
+ ],
41
+ [
42
+ "set",
43
+ "bind",
44
+ (view) => {
45
+ anchor.current = view;
46
+ }
47
+ ],
48
+ [
49
+ "set",
50
+ "ios",
51
+ props.ios
52
+ ],
53
+ [
54
+ "set",
55
+ "android",
56
+ props.android
57
+ ]
58
+ ], universalChildren("nativescript", () => {
59
+ return universalValue(__octaneUniversalPlan1, [universalComponent("nativescript", Pressable, universalProps([[
60
+ "set",
61
+ "onLongPress",
62
+ () => setOpen(true)
63
+ ]], props.children)), universalComponent("nativescript", Popover, universalProps([
64
+ [
65
+ "set",
66
+ "open",
67
+ open
68
+ ],
69
+ [
70
+ "set",
71
+ "anchor",
72
+ anchor
73
+ ],
74
+ [
75
+ "set",
76
+ "placement",
77
+ props.placement ?? "bottom"
78
+ ],
79
+ [
80
+ "set",
81
+ "dismissOnOutsideTap",
82
+ true
83
+ ],
84
+ [
85
+ "set",
86
+ "onDismiss",
87
+ () => setOpen(false)
88
+ ]
89
+ ], universalChildren("nativescript", () => {
90
+ return universalValue(__octaneUniversalPlan0, [universalComponent("nativescript", View, universalProps([[
91
+ "set",
92
+ "className",
93
+ props.cardClassName
94
+ ], [
95
+ "set",
96
+ "style",
97
+ props.cardStyle
98
+ ]], props.card))]);
99
+ })))]);
100
+ })))]);
37
101
  }, { "module": "@nativescript-community/octane" });
38
- function finishToast(entry) {
39
- if (active !== entry) return;
40
- if (entry.timer !== null) clearTimeout(entry.timer);
41
- entry.timer = null;
42
- const rootLayout = topRootLayout();
43
- const finish = () => {
44
- entry.unbindTheme?.();
45
- entry.root.unmount?.();
46
- if (active === entry) active = null;
47
- showNext();
48
- };
49
- if (rootLayout && rootLayout?.hasChild?.(entry.host)) rootLayout.close(entry.host).then(finish, (error) => {
50
- console.error("[Toast] close failed", error);
51
- finish();
52
- });
53
- else finish();
54
- }
55
- function showNext() {
56
- if (active || queue.length === 0) return;
57
- const entry = queue.shift();
58
- const rootLayout = topRootLayout();
59
- if (!rootLayout) {
60
- console.warn("[Toast] RootLayout is not mounted; toast was skipped");
61
- return;
62
- }
63
- const host = new GridLayout();
64
- const unbindTheme = applyThemeClasses(host, "vx-toast-host");
65
- host.horizontalAlignment = "stretch";
66
- host.verticalAlignment = entry.options.position === "top" ? "top" : "bottom";
67
- host.marginTop = entry.options.position === "top" ? 24 : 0;
68
- host.marginBottom = entry.options.position === "top" ? 0 : 24;
69
- Object.assign(host, isIOS ? entry.options.ios : isAndroid ? entry.options.android : void 0);
70
- const root = createNativeScriptRoot(host);
71
- const current = {
72
- ...entry,
73
- host,
74
- root,
75
- timer: null,
76
- unbindTheme
77
- };
78
- active = current;
79
- root.render(ToastBody, { content: entry.content });
80
- const open = () => {
81
- rootLayout.open(host).then(() => {
82
- if (active === current) current.timer = setTimeout(() => finishToast(current), Math.max(0, entry.options.duration ?? 3e3));
83
- }, (error) => {
84
- console.error("[Toast] open failed", error);
85
- root.unmount?.();
86
- if (active === current) active = null;
87
- showNext();
88
- });
89
- };
90
- if (rootLayout.hasChild?.(host)) rootLayout.close(host).then(open, (error) => {
91
- console.error("[Toast] stale host close failed", error);
92
- if (active === current) active = null;
93
- showNext();
94
- });
95
- else open();
96
- }
97
- function showToast(content, options = {}) {
98
- queue.push({
99
- content,
100
- options
101
- });
102
- showNext();
103
- }
104
102
  //#endregion
105
- export { showToast };
103
+ export { Hoverable };
@@ -1,58 +1,185 @@
1
- import { hookSlots, useRef } from "@nativescript-community/octane";
2
- import { cancelAnimationFrame, requestAnimationFrame } from "@nativescript/core/animation-frame";
3
- //#region src/anim.native.tsrx
4
- var _h$0 = /* @__PURE__ */ Symbol(/* @__PURE__ */ hookSlots(1));
5
- function createAnimated(initial, prop) {
6
- let view = null;
7
- let current = initial;
8
- let raf = 0;
9
- const apply = (v) => {
10
- current = v;
11
- if (view) view[prop] = v;
12
- };
13
- const run = (step) => {
14
- cancelAnimationFrame(raf);
15
- const start = Date.now();
16
- const tick = () => {
17
- const v = step(Date.now() - start);
18
- if (v === null) return;
19
- apply(v);
20
- raf = requestAnimationFrame(tick);
21
- };
22
- raf = requestAnimationFrame(tick);
1
+ import { applyThemeClasses } from "./ui31.js";
2
+ import { topRootLayout } from "./ui34.js";
3
+ import { Popover } from "./ui38.js";
4
+ import { createNativeScriptRoot, defineUniversalComponent, universalChildren, universalComponent, universalIf, universalPlan, universalProps, universalValue } from "@nativescript-community/octane";
5
+ import { GridLayout, isAndroid, isIOS } from "@nativescript/core";
6
+ //#region src/toast-anchor.native.tsrx
7
+ var __octaneUniversalPlan0 = universalPlan("nativescript", {
8
+ "kind": "host",
9
+ "type": "label",
10
+ "children": [{
11
+ "kind": "slot",
12
+ "slot": 0
13
+ }]
14
+ });
15
+ var __octaneUniversalPlan1 = universalPlan("nativescript", {
16
+ "kind": "slot",
17
+ "slot": 0
18
+ });
19
+ var __octaneUniversalPlan2 = universalPlan("nativescript", {
20
+ "kind": "host",
21
+ "type": "gridlayout",
22
+ "props": { "className": "vx-toast" },
23
+ "children": [{
24
+ "kind": "slot",
25
+ "slot": 0
26
+ }]
27
+ });
28
+ var __octaneUniversalPlan3 = universalPlan("nativescript", {
29
+ "kind": "slot",
30
+ "slot": 0
31
+ });
32
+ var __octaneUniversalPlan4 = universalPlan("nativescript", {
33
+ "kind": "host",
34
+ "type": "label",
35
+ "props": { "className": "vx-toast" },
36
+ "children": [{
37
+ "kind": "slot",
38
+ "slot": 0
39
+ }]
40
+ });
41
+ var __octaneUniversalPlan5 = universalPlan("nativescript", {
42
+ "kind": "host",
43
+ "type": "gridlayout",
44
+ "props": { "className": "vx-toast" },
45
+ "children": [{
46
+ "kind": "slot",
47
+ "slot": 0
48
+ }]
49
+ });
50
+ var __octaneUniversalPlan6 = universalPlan("nativescript", {
51
+ "kind": "slot",
52
+ "slot": 0
53
+ });
54
+ var __octaneUniversalPlan7 = universalPlan("nativescript", {
55
+ "kind": "slot",
56
+ "slot": 0
57
+ });
58
+ var queue = [];
59
+ var active = null;
60
+ function placementFor(position = "bottom") {
61
+ return position.startsWith("top") ? "top" : "bottom";
62
+ }
63
+ function horizontalFor(position = "bottom") {
64
+ if (position.endsWith("-start")) return "left";
65
+ if (position.endsWith("-end")) return "right";
66
+ return "center";
67
+ }
68
+ var ToastBody = defineUniversalComponent("nativescript", function ToastBody(props) {
69
+ return universalValue(__octaneUniversalPlan7, [universalIf(props.options.anchor, () => {
70
+ return universalValue(__octaneUniversalPlan3, [universalComponent("nativescript", Popover, universalProps([
71
+ [
72
+ "set",
73
+ "open",
74
+ props.open
75
+ ],
76
+ [
77
+ "set",
78
+ "anchor",
79
+ props.options.anchor
80
+ ],
81
+ [
82
+ "set",
83
+ "placement",
84
+ props.options.placement ?? placementFor(props.options.position)
85
+ ],
86
+ [
87
+ "set",
88
+ "dismissOnOutsideTap",
89
+ false
90
+ ]
91
+ ], universalChildren("nativescript", () => {
92
+ return universalValue(__octaneUniversalPlan2, [universalIf(typeof props.content === "string", () => {
93
+ return universalValue(__octaneUniversalPlan0, [props.content]);
94
+ }, () => {
95
+ const Component = props.content;
96
+ return universalValue(__octaneUniversalPlan1, [universalComponent("nativescript", Component, universalProps([]))]);
97
+ })]);
98
+ })))]);
99
+ }, () => {
100
+ return universalValue(__octaneUniversalPlan6, [universalIf(typeof props.content === "string", () => {
101
+ return universalValue(__octaneUniversalPlan4, [props.content]);
102
+ }, () => {
103
+ const Component = props.content;
104
+ return universalValue(__octaneUniversalPlan5, [universalComponent("nativescript", Component, universalProps([]))]);
105
+ })]);
106
+ })]);
107
+ }, { "module": "@nativescript-community/octane" });
108
+ function finishToast(entry) {
109
+ if (active !== entry) return;
110
+ if (entry.timer !== null) clearTimeout(entry.timer);
111
+ entry.timer = null;
112
+ const cleanup = () => {
113
+ entry.unbindTheme?.();
114
+ entry.root.unmount?.();
115
+ if (active === entry) active = null;
116
+ showNext();
23
117
  };
24
- return {
25
- get value() {
26
- return current;
27
- },
28
- bind(v) {
29
- view = v;
30
- if (view) view[prop] = current;
31
- },
32
- to(target, opts) {
33
- const dur = opts?.duration ?? 300;
34
- const from = current;
35
- run((t) => t >= dur ? (apply(target), null) : from + (target - from) * (t / dur));
36
- },
37
- spring(target, opts) {
38
- const damping = opts?.damping ?? 14, stiffness = opts?.stiffness ?? 120;
39
- let v = 0, x = current;
40
- run(() => {
41
- const dt = 1 / 60;
42
- v += (-stiffness * (x - target) - damping * v) * dt;
43
- x += v * dt;
44
- return Math.abs(v) < .5 && Math.abs(x - target) < .5 ? (apply(target), null) : x;
45
- });
46
- },
47
- stop() {
48
- cancelAnimationFrame(raf);
49
- }
118
+ if (entry.options.anchor) {
119
+ entry.root.render(ToastBody, {
120
+ ...entry,
121
+ open: false
122
+ });
123
+ setTimeout(cleanup, 0);
124
+ return;
125
+ }
126
+ const rootLayout = topRootLayout();
127
+ if (rootLayout && rootLayout.hasChild?.(entry.host)) rootLayout.close(entry.host).then(cleanup, (error) => {
128
+ console.error("[Toast] close failed", error);
129
+ cleanup();
130
+ });
131
+ else cleanup();
132
+ }
133
+ function showNext() {
134
+ if (active || queue.length === 0) return;
135
+ const entry = queue.shift();
136
+ const anchored = Boolean(entry.options.anchor);
137
+ const rootLayout = topRootLayout();
138
+ if (!anchored && !rootLayout) {
139
+ console.warn("[Toast] RootLayout is not mounted; toast was skipped");
140
+ showNext();
141
+ return;
142
+ }
143
+ const host = new GridLayout();
144
+ const position = entry.options.position ?? "bottom";
145
+ const unbindTheme = applyThemeClasses(host, "vx-toast-host");
146
+ const root = createNativeScriptRoot(host);
147
+ const current = {
148
+ ...entry,
149
+ host,
150
+ root,
151
+ timer: null,
152
+ unbindTheme
50
153
  };
154
+ active = current;
155
+ root.render(ToastBody, {
156
+ ...entry,
157
+ open: true
158
+ });
159
+ if (anchored) {
160
+ current.timer = setTimeout(() => finishToast(current), Math.max(0, entry.options.duration ?? 3e3));
161
+ return;
162
+ }
163
+ host.horizontalAlignment = horizontalFor(position);
164
+ host.verticalAlignment = placementFor(position) === "top" ? "top" : "bottom";
165
+ host.marginTop = placementFor(position) === "top" ? 24 : 0;
166
+ host.marginBottom = placementFor(position) === "top" ? 0 : 24;
167
+ Object.assign(host, isIOS ? entry.options.ios : isAndroid ? entry.options.android : void 0);
168
+ rootLayout.open(host).then(() => {
169
+ if (active === current) current.timer = setTimeout(() => finishToast(current), Math.max(0, entry.options.duration ?? 3e3));
170
+ }, (error) => {
171
+ console.error("[Toast] open failed", error);
172
+ root.unmount?.();
173
+ if (active === current) active = null;
174
+ showNext();
175
+ });
51
176
  }
52
- function useAnimation(initial = 0, prop = "translateX") {
53
- const c = useRef(null, _h$0);
54
- if (!c.current) c.current = createAnimated(initial, prop);
55
- return c.current;
177
+ function showToast(content, options = {}) {
178
+ queue.push({
179
+ content,
180
+ options
181
+ });
182
+ showNext();
56
183
  }
57
184
  //#endregion
58
- export { useAnimation };
185
+ export { showToast };
@@ -1,19 +1,58 @@
1
- import "@nativescript-community/octane";
2
- import { defineUniversalComponent as defineUniversalComponent$1, universalComponent as universalComponent$1 } from "octane/universal/native";
3
- //#region src/styled.native.tsrx
4
- function styled(Base, def) {
5
- function Styled(props) {
6
- const cls = [def.base];
7
- const rest = { ...props };
8
- for (const k of Object.keys(def.variants ?? {})) {
9
- if (props[k]) cls.push(def.variants[k]);
10
- delete rest[k];
1
+ import { hookSlots, useRef } from "@nativescript-community/octane";
2
+ import { cancelAnimationFrame, requestAnimationFrame } from "@nativescript/core/animation-frame";
3
+ //#region src/anim.native.tsrx
4
+ var _h$0 = /* @__PURE__ */ Symbol(/* @__PURE__ */ hookSlots(1));
5
+ function createAnimated(initial, prop) {
6
+ let view = null;
7
+ let current = initial;
8
+ let raf = 0;
9
+ const apply = (v) => {
10
+ current = v;
11
+ if (view) view[prop] = v;
12
+ };
13
+ const run = (step) => {
14
+ cancelAnimationFrame(raf);
15
+ const start = Date.now();
16
+ const tick = () => {
17
+ const v = step(Date.now() - start);
18
+ if (v === null) return;
19
+ apply(v);
20
+ raf = requestAnimationFrame(tick);
21
+ };
22
+ raf = requestAnimationFrame(tick);
23
+ };
24
+ return {
25
+ get value() {
26
+ return current;
27
+ },
28
+ bind(v) {
29
+ view = v;
30
+ if (view) view[prop] = current;
31
+ },
32
+ to(target, opts) {
33
+ const dur = opts?.duration ?? 300;
34
+ const from = current;
35
+ run((t) => t >= dur ? (apply(target), null) : from + (target - from) * (t / dur));
36
+ },
37
+ spring(target, opts) {
38
+ const damping = opts?.damping ?? 14, stiffness = opts?.stiffness ?? 120;
39
+ let v = 0, x = current;
40
+ run(() => {
41
+ const dt = 1 / 60;
42
+ v += (-stiffness * (x - target) - damping * v) * dt;
43
+ x += v * dt;
44
+ return Math.abs(v) < .5 && Math.abs(x - target) < .5 ? (apply(target), null) : x;
45
+ });
46
+ },
47
+ stop() {
48
+ cancelAnimationFrame(raf);
11
49
  }
12
- if (props.className) cls.push(props.className);
13
- rest.className = cls;
14
- return universalComponent$1("nativescript", Base, rest);
15
- }
16
- return defineUniversalComponent$1("nativescript", Styled);
50
+ };
51
+ }
52
+ function useAnimation(initial = 0, prop = "translateX") {
53
+ const c = useRef(null, _h$0);
54
+ if (!c.current) c.current = createAnimated(initial, prop);
55
+ return c.current;
17
56
  }
18
57
  //#endregion
19
- export { styled };
58
+ export { useAnimation };