@octane-xplat/ui 0.3.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.
- package/README.md +46 -0
- package/dist/native/octane-client-build.json +1 -1
- package/dist/native/ui.js +55 -40
- package/dist/native/ui10.js +20 -11
- package/dist/native/ui11.js +42 -109
- package/dist/native/ui12.js +17 -84
- package/dist/native/ui13.js +11 -41
- package/dist/native/ui14.js +133 -76
- package/dist/native/ui15.js +43 -92
- package/dist/native/ui16.js +106 -45
- package/dist/native/ui17.js +29 -42
- package/dist/native/ui18.js +34 -53
- package/dist/native/ui19.js +246 -32
- package/dist/native/ui20.js +27 -16
- package/dist/native/ui21.js +376 -86
- package/dist/native/ui22.js +26 -114
- package/dist/native/ui23.js +49 -97
- package/dist/native/ui24.js +79 -53
- package/dist/native/ui25.js +138 -16
- package/dist/native/ui26.js +8 -23
- package/dist/native/ui27.js +60 -34
- package/dist/native/ui28.js +36 -142
- package/dist/native/ui29.js +101 -21
- package/dist/native/ui3.js +22 -1
- package/dist/native/ui30.js +14 -31
- package/dist/native/ui31.js +55 -36
- package/dist/native/ui32.js +49 -61
- package/dist/native/ui33.js +36 -28
- package/dist/native/ui34.js +51 -8
- package/dist/native/ui35.js +98 -20
- package/dist/native/ui36.js +9 -33
- package/dist/native/ui37.js +42 -15
- package/dist/native/ui38.js +186 -57
- package/dist/native/ui39.js +96 -26
- package/dist/native/ui4.js +22 -20
- package/dist/native/ui40.js +179 -8
- package/dist/native/ui41.js +52 -98
- package/dist/native/ui42.js +14 -145
- package/dist/native/ui43.js +16 -19
- package/dist/native/ui44.js +6 -6
- package/dist/native/ui45.js +38 -0
- package/dist/native/ui46.js +267 -0
- package/dist/native/ui47.js +28 -0
- package/dist/native/ui48.js +35 -0
- package/dist/native/ui49.js +41 -0
- package/dist/native/ui5.js +37 -77
- package/dist/native/ui50.js +72 -0
- package/dist/native/ui51.js +66 -0
- package/dist/native/ui52.js +64 -0
- package/dist/native/ui53.js +27 -0
- package/dist/native/ui54.js +13 -0
- package/dist/native/ui55.js +92 -0
- package/dist/native/ui56.js +34 -0
- package/dist/native/ui57.js +19 -0
- package/dist/native/ui58.js +156 -0
- package/dist/native/ui59.js +33 -0
- package/dist/native/ui6.js +94 -9
- package/dist/native/ui60.js +14 -0
- package/dist/native/ui61.js +22 -0
- package/dist/native/ui62.js +8 -0
- package/dist/native/ui63.js +108 -0
- package/dist/native/ui64.js +76 -0
- package/dist/native/ui7.js +42 -26
- package/dist/native/ui8.js +22 -12
- package/dist/native/ui9.js +18 -9
- package/dist/web/octane-client-build.json +1 -1
- package/dist/web/ui.js +53 -40
- package/dist/web/ui10.js +33 -186
- package/dist/web/ui11.js +28 -409
- package/dist/web/ui12.js +21 -68
- package/dist/web/ui13.js +265 -96
- package/dist/web/ui14.js +85 -95
- package/dist/web/ui15.js +368 -25
- package/dist/web/ui16.js +13 -101
- package/dist/web/ui17.js +246 -42
- package/dist/web/ui18.js +237 -28
- package/dist/web/ui19.js +36 -10
- package/dist/web/ui20.js +73 -102
- package/dist/web/ui21.js +102 -73
- package/dist/web/ui22.js +95 -55
- package/dist/web/ui23.js +94 -55
- package/dist/web/ui24.js +31 -15
- package/dist/web/ui25.js +105 -19
- package/dist/web/ui26.js +29 -23
- package/dist/web/ui27.js +12 -123
- package/dist/web/ui28.js +9 -110
- package/dist/web/ui29.js +52 -102
- package/dist/web/ui3.js +29 -18
- package/dist/web/ui30.js +32 -41
- package/dist/web/ui31.js +120 -39
- package/dist/web/ui32.js +41 -74
- package/dist/web/ui33.js +148 -32
- package/dist/web/ui34.js +145 -62
- package/dist/web/ui35.js +140 -7
- package/dist/web/ui36.js +86 -41
- package/dist/web/ui37.js +19 -44
- package/dist/web/ui38.js +5 -15
- package/dist/web/ui39.js +24 -86
- package/dist/web/ui4.js +46 -152
- package/dist/web/ui40.js +150 -37
- package/dist/web/ui41.js +36 -10
- package/dist/web/ui42.js +40 -7
- package/dist/web/ui43.js +73 -19
- package/dist/web/ui44.js +40 -6
- package/dist/web/ui45.js +62 -0
- package/dist/web/ui46.js +50 -0
- package/dist/web/ui47.js +9 -0
- package/dist/web/ui48.js +45 -0
- package/dist/web/ui49.js +13 -0
- package/dist/web/ui5.js +131 -27
- package/dist/web/ui50.js +63 -0
- package/dist/web/ui51.js +47 -0
- package/dist/web/ui52.js +19 -0
- package/dist/web/ui53.js +273 -0
- package/dist/web/ui54.js +42 -0
- package/dist/web/ui55.js +17 -0
- package/dist/web/ui56.js +9 -0
- package/dist/web/ui57.js +22 -0
- package/dist/web/ui58.js +8 -0
- package/dist/web/ui59.js +44 -0
- package/dist/web/ui6.js +81 -45
- package/dist/web/ui60.js +46 -0
- package/dist/web/ui7.js +43 -21
- package/dist/web/ui8.js +27 -21
- package/dist/web/ui9.js +29 -18
- package/package.json +17 -4
- package/src/theme/tokens.css +597 -141
- package/types/index.d.ts +112 -58
- package/types/props.d.ts +291 -16
package/dist/native/ui39.js
CHANGED
|
@@ -1,33 +1,103 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
//#region src/
|
|
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": "
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
["style", 2],
|
|
13
|
-
["accessibilityRole", 3],
|
|
14
|
-
["ref", 4]
|
|
15
|
-
],
|
|
10
|
+
"kind": "slot",
|
|
11
|
+
"slot": 0
|
|
12
|
+
});
|
|
13
|
+
var __octaneUniversalPlan1 = universalPlan("nativescript", {
|
|
14
|
+
"kind": "range",
|
|
16
15
|
"children": [{
|
|
17
16
|
"kind": "slot",
|
|
18
|
-
"slot":
|
|
17
|
+
"slot": 0
|
|
18
|
+
}, {
|
|
19
|
+
"kind": "slot",
|
|
20
|
+
"slot": 1
|
|
19
21
|
}]
|
|
20
22
|
});
|
|
21
|
-
var
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
23
|
+
var __octaneUniversalPlan2 = universalPlan("nativescript", {
|
|
24
|
+
"kind": "slot",
|
|
25
|
+
"slot": 0
|
|
26
|
+
});
|
|
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
|
+
})))]);
|
|
31
101
|
}, { "module": "@nativescript-community/octane" });
|
|
32
102
|
//#endregion
|
|
33
|
-
export {
|
|
103
|
+
export { Hoverable };
|
package/dist/native/ui4.js
CHANGED
|
@@ -1,22 +1,24 @@
|
|
|
1
|
-
//#region src/
|
|
2
|
-
/**
|
|
3
|
-
*
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
//#region src/glass.ts
|
|
2
|
+
/** Normalize the `glass` surface prop into the config object handed to
|
|
3
|
+
* `iosGlassEffect` on native. Always returns an object — the upstream
|
|
4
|
+
* string shorthand silently drops `interactive` on the layout's update
|
|
5
|
+
* path, and an empty config defaults the variant to 'regular' here rather
|
|
6
|
+
* than upstream's own fallback. `false`/'none'/'identity' → no glass. */
|
|
7
|
+
function glassConfigOf(glass) {
|
|
8
|
+
if (!glass || glass === "none" || glass === "identity") return;
|
|
9
|
+
const c = typeof glass === "string" ? { variant: glass } : glass === true ? {} : glass;
|
|
10
|
+
if (c.variant === "none" || c.variant === "identity") return;
|
|
11
|
+
return {
|
|
12
|
+
variant: "regular",
|
|
13
|
+
...c
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
/** `vx-glass` classes shared by web (real styling) and native (hook for
|
|
17
|
+
* app-supplied fallback CSS on non-glass OSes). */
|
|
18
|
+
function glassClassOf(glass) {
|
|
19
|
+
const c = glassConfigOf(glass);
|
|
20
|
+
if (!c) return;
|
|
21
|
+
return c.variant === "clear" ? "vx-glass vx-glass--clear" : "vx-glass";
|
|
20
22
|
}
|
|
21
23
|
//#endregion
|
|
22
|
-
export {
|
|
24
|
+
export { glassClassOf, glassConfigOf };
|
package/dist/native/ui40.js
CHANGED
|
@@ -1,14 +1,185 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
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
|
|
4
7
|
var __octaneUniversalPlan0 = universalPlan("nativescript", {
|
|
5
8
|
"kind": "host",
|
|
6
9
|
"type": "label",
|
|
7
|
-
"
|
|
8
|
-
|
|
10
|
+
"children": [{
|
|
11
|
+
"kind": "slot",
|
|
12
|
+
"slot": 0
|
|
13
|
+
}]
|
|
9
14
|
});
|
|
10
|
-
var
|
|
11
|
-
|
|
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
|
+
})]);
|
|
12
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();
|
|
117
|
+
};
|
|
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
|
|
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
|
+
});
|
|
176
|
+
}
|
|
177
|
+
function showToast(content, options = {}) {
|
|
178
|
+
queue.push({
|
|
179
|
+
content,
|
|
180
|
+
options
|
|
181
|
+
});
|
|
182
|
+
showNext();
|
|
183
|
+
}
|
|
13
184
|
//#endregion
|
|
14
|
-
export {
|
|
185
|
+
export { showToast };
|
package/dist/native/ui41.js
CHANGED
|
@@ -1,104 +1,58 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
for (const key of Object.keys(files).sort()) {
|
|
22
|
-
let rel = key.replace(/^\.?\//, "");
|
|
23
|
-
if (rel.startsWith(prefix)) rel = rel.slice(prefix.length);
|
|
24
|
-
rel = rel.replace(EXT, "");
|
|
25
|
-
const parts = rel.split("/");
|
|
26
|
-
let base = parts[parts.length - 1];
|
|
27
|
-
const sm = SUFFIX.exec(base);
|
|
28
|
-
const suffix = sm?.[1];
|
|
29
|
-
if (sm) base = base.slice(0, base.length - sm[0].length);
|
|
30
|
-
if (suffix && !prefer.includes(suffix)) continue;
|
|
31
|
-
const rank = suffix ? prefer.indexOf(suffix) : prefer.length;
|
|
32
|
-
if (base === "_layout") {
|
|
33
|
-
const d = parts.slice(0, -1).join("/");
|
|
34
|
-
const prev = layoutRank.get(d);
|
|
35
|
-
if (prev !== void 0 && prev <= rank) continue;
|
|
36
|
-
const component = pick(files[key], key);
|
|
37
|
-
if (component) {
|
|
38
|
-
layouts[d] = component;
|
|
39
|
-
layoutRank.set(d, rank);
|
|
40
|
-
}
|
|
41
|
-
continue;
|
|
42
|
-
}
|
|
43
|
-
const segs = parts.slice(0, -1).concat(base);
|
|
44
|
-
if (segs[segs.length - 1] === "index") segs.pop();
|
|
45
|
-
const segments = segs.map((s) => {
|
|
46
|
-
const p = PARAM.exec(s);
|
|
47
|
-
return p ? ":" + p[1] : s;
|
|
48
|
-
});
|
|
49
|
-
const name = segments.join("/") || "index";
|
|
50
|
-
const meta = {
|
|
51
|
-
name,
|
|
52
|
-
segments,
|
|
53
|
-
params: segments.filter((s) => s.startsWith(":")).map((s) => s.slice(1)),
|
|
54
|
-
file: key
|
|
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);
|
|
55
21
|
};
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
if (prev.rank === rank && !warned.has(name)) {
|
|
59
|
-
warned.add(name);
|
|
60
|
-
console.warn(`[octane-xplat] route '${name}' is defined by both ${prev.meta.file} and ${key} — keeping ${prev.meta.file}`);
|
|
61
|
-
}
|
|
62
|
-
continue;
|
|
63
|
-
}
|
|
64
|
-
const component = pick(files[key], key);
|
|
65
|
-
if (component) seen.set(name, {
|
|
66
|
-
rank,
|
|
67
|
-
meta,
|
|
68
|
-
component
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
const screens = {};
|
|
72
|
-
const routes = [];
|
|
73
|
-
for (const { meta, component } of seen.values()) {
|
|
74
|
-
screens[meta.name] = component;
|
|
75
|
-
routes.push(meta);
|
|
76
|
-
}
|
|
77
|
-
routes.sort((a, b) => b.segments.reduce((n, s) => n + (s.startsWith(":") ? 1 : 2), 0) - a.segments.reduce((n, s) => n + (s.startsWith(":") ? 1 : 2), 0) || a.name.localeCompare(b.name));
|
|
22
|
+
raf = requestAnimationFrame(tick);
|
|
23
|
+
};
|
|
78
24
|
return {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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
|
+
}
|
|
82
50
|
};
|
|
83
51
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
const meta = routes.find((m) => m.name === r.name);
|
|
89
|
-
let segs;
|
|
90
|
-
let rest = r.params;
|
|
91
|
-
if (meta) {
|
|
92
|
-
segs = meta.segments.map((s) => {
|
|
93
|
-
if (!s.startsWith(":")) return s;
|
|
94
|
-
const v = r.params[s.slice(1)];
|
|
95
|
-
if (v === void 0) console.warn(`[octane-xplat] route '${r.name}' pushed without path param ${s}`);
|
|
96
|
-
return encodeURIComponent(String(v ?? ""));
|
|
97
|
-
});
|
|
98
|
-
rest = Object.fromEntries(Object.entries(r.params).filter(([k]) => !meta.params.includes(k)));
|
|
99
|
-
} else segs = [r.name];
|
|
100
|
-
const q = Object.entries(rest).map(([k, v]) => encodeURIComponent(k) + "=" + encodeURIComponent(String(v))).join("&");
|
|
101
|
-
return (((r.stack === "root" ? "" : "/" + r.stack) + "/" + segs.join("/")).replace(/\/+$/, "") || "/") + (q ? "?" + q : "");
|
|
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;
|
|
102
56
|
}
|
|
103
57
|
//#endregion
|
|
104
|
-
export {
|
|
58
|
+
export { useAnimation };
|