@octane-xplat/ui 0.2.1 → 0.4.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 +52 -19
- package/dist/native/ui10.js +25 -45
- package/dist/native/ui11.js +52 -57
- package/dist/native/ui12.js +47 -16
- package/dist/native/ui13.js +24 -18
- package/dist/native/ui14.js +117 -12
- package/dist/native/ui15.js +78 -17
- package/dist/native/ui16.js +88 -115
- package/dist/native/ui17.js +29 -19
- package/dist/native/ui18.js +34 -12
- package/dist/native/ui19.js +244 -8
- package/dist/native/ui2.js +10 -48
- package/dist/native/ui20.js +28 -0
- package/dist/native/ui21.js +383 -0
- package/dist/native/ui22.js +36 -0
- package/dist/native/ui23.js +55 -0
- package/dist/native/ui24.js +83 -0
- package/dist/native/ui25.js +141 -0
- package/dist/native/ui26.js +12 -0
- package/dist/native/ui27.js +61 -0
- package/dist/native/ui28.js +40 -0
- package/dist/native/ui29.js +108 -0
- package/dist/native/ui3.js +17 -20
- package/dist/native/ui30.js +18 -0
- package/dist/native/ui31.js +58 -0
- package/dist/native/ui32.js +58 -0
- package/dist/native/ui33.js +38 -0
- package/dist/native/ui34.js +53 -0
- package/dist/native/ui35.js +105 -0
- package/dist/native/ui36.js +10 -0
- package/dist/native/ui37.js +44 -0
- package/dist/native/ui38.js +197 -0
- package/dist/native/ui39.js +105 -0
- package/dist/native/ui4.js +23 -48
- package/dist/native/ui40.js +58 -0
- package/dist/native/ui41.js +19 -0
- package/dist/native/ui42.js +8 -0
- package/dist/native/ui43.js +38 -0
- package/dist/native/ui44.js +267 -0
- package/dist/native/ui45.js +28 -0
- package/dist/native/ui46.js +35 -0
- package/dist/native/ui47.js +41 -0
- package/dist/native/ui48.js +72 -0
- package/dist/native/ui49.js +66 -0
- package/dist/native/ui5.js +37 -34
- package/dist/native/ui50.js +27 -0
- package/dist/native/ui51.js +13 -0
- package/dist/native/ui52.js +92 -0
- package/dist/native/ui53.js +34 -0
- package/dist/native/ui54.js +17 -0
- package/dist/native/ui55.js +156 -0
- package/dist/native/ui56.js +33 -0
- package/dist/native/ui57.js +14 -0
- package/dist/native/ui58.js +22 -0
- package/dist/native/ui59.js +8 -0
- package/dist/native/ui6.js +79 -20
- package/dist/native/ui60.js +108 -0
- package/dist/native/ui61.js +76 -0
- package/dist/native/ui7.js +44 -65
- package/dist/native/ui8.js +25 -17
- package/dist/native/ui9.js +24 -12
- package/dist/web/octane-client-build.json +1 -1
- package/dist/web/ui.js +51 -19
- package/dist/web/ui10.js +33 -30
- package/dist/web/ui11.js +40 -55
- package/dist/web/ui12.js +36 -15
- package/dist/web/ui13.js +212 -20
- package/dist/web/ui14.js +84 -14
- package/dist/web/ui15.js +425 -46
- package/dist/web/ui16.js +12 -93
- package/dist/web/ui17.js +246 -28
- package/dist/web/ui18.js +238 -15
- package/dist/web/ui19.js +36 -8
- package/dist/web/ui2.js +15 -103
- package/dist/web/ui20.js +85 -0
- package/dist/web/ui21.js +111 -0
- package/dist/web/ui22.js +108 -0
- package/dist/web/ui23.js +96 -0
- package/dist/web/ui24.js +32 -0
- package/dist/web/ui25.js +108 -0
- package/dist/web/ui26.js +45 -0
- package/dist/web/ui27.js +16 -0
- package/dist/web/ui28.js +11 -0
- package/dist/web/ui29.js +58 -0
- package/dist/web/ui3.js +30 -27
- package/dist/web/ui30.js +34 -0
- package/dist/web/ui31.js +123 -0
- package/dist/web/ui32.js +44 -0
- package/dist/web/ui33.js +159 -0
- package/dist/web/ui34.js +70 -0
- package/dist/web/ui35.js +57 -0
- package/dist/web/ui36.js +22 -0
- package/dist/web/ui37.js +7 -0
- package/dist/web/ui38.js +38 -0
- package/dist/web/ui39.js +154 -0
- package/dist/web/ui4.js +46 -24
- package/dist/web/ui40.js +43 -0
- package/dist/web/ui41.js +42 -0
- package/dist/web/ui42.js +76 -0
- package/dist/web/ui43.js +42 -0
- package/dist/web/ui44.js +62 -0
- package/dist/web/ui45.js +9 -0
- package/dist/web/ui46.js +45 -0
- package/dist/web/ui47.js +13 -0
- package/dist/web/ui48.js +63 -0
- package/dist/web/ui49.js +47 -0
- package/dist/web/ui5.js +158 -52
- package/dist/web/ui50.js +17 -0
- package/dist/web/ui51.js +149 -0
- package/dist/web/ui52.js +42 -0
- package/dist/web/ui53.js +17 -0
- package/dist/web/ui54.js +9 -0
- package/dist/web/ui55.js +22 -0
- package/dist/web/ui56.js +8 -0
- package/dist/web/ui57.js +44 -0
- package/dist/web/ui58.js +46 -0
- package/dist/web/ui6.js +85 -22
- package/dist/web/ui7.js +46 -41
- package/dist/web/ui8.js +28 -11
- package/dist/web/ui9.js +32 -13
- package/package.json +18 -6
- package/src/theme/tokens.css +444 -47
- package/types/index.d.ts +180 -29
- package/types/props.d.ts +553 -8
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { cx } from "./ui2.js";
|
|
2
|
+
import { applyThemeClasses, useThemeScheme } from "./ui31.js";
|
|
3
|
+
import { rootLayoutFor } from "./ui34.js";
|
|
4
|
+
import { applyNativeProps } from "./ui36.js";
|
|
5
|
+
import { positionPopover } from "./ui37.js";
|
|
6
|
+
import { createNativeScriptRoot, defineUniversalComponent, hookSlots, universalPlan, universalValue, useEffect, useRef, useState, withSlot } from "@nativescript-community/octane";
|
|
7
|
+
import { GridLayout } from "@nativescript/core";
|
|
8
|
+
//#region src/Popover.native.tsrx
|
|
9
|
+
var _hs$ = /* @__PURE__ */ hookSlots(8);
|
|
10
|
+
var _h$0 = /* @__PURE__ */ Symbol(_hs$);
|
|
11
|
+
var _h$1 = /* @__PURE__ */ Symbol(_hs$ + 1);
|
|
12
|
+
var _h$2 = /* @__PURE__ */ Symbol(_hs$ + 2);
|
|
13
|
+
var _h$3 = /* @__PURE__ */ Symbol(_hs$ + 3);
|
|
14
|
+
var _h$4 = /* @__PURE__ */ Symbol(_hs$ + 4);
|
|
15
|
+
var _h$5 = /* @__PURE__ */ Symbol(_hs$ + 5);
|
|
16
|
+
var _h$6 = /* @__PURE__ */ Symbol(_hs$ + 6);
|
|
17
|
+
var _h$7 = /* @__PURE__ */ Symbol(_hs$ + 7);
|
|
18
|
+
var __octaneUniversalPlan0 = universalPlan("nativescript", {
|
|
19
|
+
"kind": "host",
|
|
20
|
+
"type": "gridlayout",
|
|
21
|
+
"props": {
|
|
22
|
+
"width": "100%",
|
|
23
|
+
"height": "100%",
|
|
24
|
+
"className": "vx-popover-backdrop"
|
|
25
|
+
},
|
|
26
|
+
"bindings": [["backgroundColor", 0], ["onTap", 1]]
|
|
27
|
+
});
|
|
28
|
+
var __octaneUniversalPlan1 = universalPlan("nativescript", {
|
|
29
|
+
"kind": "host",
|
|
30
|
+
"type": "absolutelayout",
|
|
31
|
+
"props": {
|
|
32
|
+
"width": "100%",
|
|
33
|
+
"height": "100%"
|
|
34
|
+
},
|
|
35
|
+
"bindings": [["className", 0]],
|
|
36
|
+
"children": [{
|
|
37
|
+
"kind": "slot",
|
|
38
|
+
"slot": 1
|
|
39
|
+
}, {
|
|
40
|
+
"kind": "host",
|
|
41
|
+
"type": "gridlayout",
|
|
42
|
+
"bindings": [
|
|
43
|
+
["ref", 2],
|
|
44
|
+
["left", 3],
|
|
45
|
+
["top", 4],
|
|
46
|
+
["opacity", 5],
|
|
47
|
+
["className", 6],
|
|
48
|
+
["style", 7],
|
|
49
|
+
["onLoaded", 8],
|
|
50
|
+
["onLayoutChanged", 9]
|
|
51
|
+
],
|
|
52
|
+
"children": [{
|
|
53
|
+
"kind": "slot",
|
|
54
|
+
"slot": 10
|
|
55
|
+
}]
|
|
56
|
+
}]
|
|
57
|
+
});
|
|
58
|
+
var __octaneUniversalPlan2 = universalPlan("nativescript", {
|
|
59
|
+
"kind": "range",
|
|
60
|
+
"children": []
|
|
61
|
+
});
|
|
62
|
+
var PopoverLayer = defineUniversalComponent("nativescript", function PopoverLayer(props) {
|
|
63
|
+
const panelRef = useRef(null, _h$0);
|
|
64
|
+
const [position, setPosition] = useState(null, _h$1);
|
|
65
|
+
const [settled, setSettled] = useState(false, _h$2);
|
|
66
|
+
const update = () => {
|
|
67
|
+
const anchor = props.anchorView;
|
|
68
|
+
const coordinateRoot = anchor?.page?.content;
|
|
69
|
+
if (!anchor?.getLocationRelativeTo || !coordinateRoot?.getActualSize) return;
|
|
70
|
+
const point = anchor.getLocationRelativeTo(coordinateRoot);
|
|
71
|
+
const anchorSize = anchor.getActualSize();
|
|
72
|
+
const panelSize = panelRef.current?.getActualSize?.();
|
|
73
|
+
if (!point || !anchorSize) return;
|
|
74
|
+
const next = positionPopover({
|
|
75
|
+
left: point.x,
|
|
76
|
+
top: point.y,
|
|
77
|
+
width: anchorSize.width,
|
|
78
|
+
height: anchorSize.height
|
|
79
|
+
}, {
|
|
80
|
+
width: panelSize?.width ?? 0,
|
|
81
|
+
height: panelSize?.height ?? 0
|
|
82
|
+
}, {
|
|
83
|
+
left: 0,
|
|
84
|
+
top: 0,
|
|
85
|
+
width: coordinateRoot.getActualSize().width,
|
|
86
|
+
height: coordinateRoot.getActualSize().height
|
|
87
|
+
}, props.placement ?? "bottom");
|
|
88
|
+
setPosition((current) => current?.left === next.left && current?.top === next.top && current?.placement === next.placement ? current : next);
|
|
89
|
+
if (panelSize?.width > 0 && panelSize?.height > 0) setSettled(true);
|
|
90
|
+
};
|
|
91
|
+
useEffect(() => {
|
|
92
|
+
const anchor = props.anchorView;
|
|
93
|
+
if (!props.open || !anchor) return;
|
|
94
|
+
const listeners = [];
|
|
95
|
+
let view = anchor;
|
|
96
|
+
while (view) {
|
|
97
|
+
for (const event of ["layoutChanged", "scroll"]) {
|
|
98
|
+
const handler = () => update();
|
|
99
|
+
view.on?.(event, handler);
|
|
100
|
+
listeners.push({
|
|
101
|
+
view,
|
|
102
|
+
event,
|
|
103
|
+
handler
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
view = view.parent;
|
|
107
|
+
}
|
|
108
|
+
update();
|
|
109
|
+
return () => {
|
|
110
|
+
for (const listener of listeners) listener.view.off?.(listener.event, listener.handler);
|
|
111
|
+
};
|
|
112
|
+
}, [
|
|
113
|
+
props.open,
|
|
114
|
+
props.anchorView,
|
|
115
|
+
props.placement,
|
|
116
|
+
props.children,
|
|
117
|
+
props.style
|
|
118
|
+
], _h$3);
|
|
119
|
+
useEffect(() => {
|
|
120
|
+
applyNativeProps(panelRef.current, props);
|
|
121
|
+
}, [
|
|
122
|
+
props.ios,
|
|
123
|
+
props.android,
|
|
124
|
+
settled
|
|
125
|
+
], _h$4);
|
|
126
|
+
const dismiss = () => props.onDismiss?.();
|
|
127
|
+
return universalValue(__octaneUniversalPlan1, [
|
|
128
|
+
cx("vx-popover-layer", withSlot(_h$5, useThemeScheme) === "dark" && "ns-dark"),
|
|
129
|
+
(props.dismissOnOutsideTap ?? true) && universalValue(__octaneUniversalPlan0, ["transparent", dismiss]),
|
|
130
|
+
panelRef,
|
|
131
|
+
position?.left ?? 0,
|
|
132
|
+
position?.top ?? 0,
|
|
133
|
+
settled ? 1 : 0,
|
|
134
|
+
cx("vx-popover", props.className),
|
|
135
|
+
props.style,
|
|
136
|
+
update,
|
|
137
|
+
update,
|
|
138
|
+
props.children
|
|
139
|
+
]);
|
|
140
|
+
}, { "module": "@nativescript-community/octane" });
|
|
141
|
+
var Popover = defineUniversalComponent("nativescript", function Popover(props) {
|
|
142
|
+
const shown = useRef(null, _h$6);
|
|
143
|
+
useEffect(() => {
|
|
144
|
+
const cur = shown.current;
|
|
145
|
+
if (!props.open) {
|
|
146
|
+
if (!cur) return;
|
|
147
|
+
shown.current = null;
|
|
148
|
+
cur.unbindTheme?.();
|
|
149
|
+
const owner = cur.host.parent;
|
|
150
|
+
if (owner?.hasChild?.(cur.host)) owner.close(cur.host).then(() => cur.root.unmount?.(), (error) => {
|
|
151
|
+
console.error("[Popover] close failed", error);
|
|
152
|
+
cur.root.unmount?.();
|
|
153
|
+
});
|
|
154
|
+
else cur.root.unmount?.();
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
const anchor = props.anchor?.current;
|
|
158
|
+
const rl = rootLayoutFor(anchor);
|
|
159
|
+
if (!anchor || !rl) return;
|
|
160
|
+
if (cur) {
|
|
161
|
+
cur.root.render(PopoverLayer, {
|
|
162
|
+
...props,
|
|
163
|
+
anchorView: anchor
|
|
164
|
+
});
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
const host = new GridLayout();
|
|
168
|
+
const unbindTheme = applyThemeClasses(host, cx("vx-popover-host", props.className));
|
|
169
|
+
host.horizontalAlignment = "stretch";
|
|
170
|
+
host.verticalAlignment = "stretch";
|
|
171
|
+
const root = createNativeScriptRoot(host);
|
|
172
|
+
shown.current = {
|
|
173
|
+
host,
|
|
174
|
+
root,
|
|
175
|
+
unbindTheme
|
|
176
|
+
};
|
|
177
|
+
root.render(PopoverLayer, {
|
|
178
|
+
...props,
|
|
179
|
+
anchorView: anchor
|
|
180
|
+
});
|
|
181
|
+
rl.open(host).catch((error) => {
|
|
182
|
+
if (shown.current?.host === host) shown.current = null;
|
|
183
|
+
console.error("[Popover] open failed", error);
|
|
184
|
+
root.unmount?.();
|
|
185
|
+
});
|
|
186
|
+
}, [
|
|
187
|
+
props.open,
|
|
188
|
+
props.children,
|
|
189
|
+
props.placement,
|
|
190
|
+
props.className,
|
|
191
|
+
props.style,
|
|
192
|
+
props.dismissOnOutsideTap
|
|
193
|
+
], _h$7);
|
|
194
|
+
return universalValue(__octaneUniversalPlan2, []);
|
|
195
|
+
}, { "module": "@nativescript-community/octane" });
|
|
196
|
+
//#endregion
|
|
197
|
+
export { Popover };
|
|
@@ -0,0 +1,105 @@
|
|
|
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
|
|
6
|
+
var __octaneUniversalPlan0 = universalPlan("nativescript", {
|
|
7
|
+
"kind": "host",
|
|
8
|
+
"type": "label",
|
|
9
|
+
"props": { "className": "vx-toast" },
|
|
10
|
+
"children": [{
|
|
11
|
+
"kind": "slot",
|
|
12
|
+
"slot": 0
|
|
13
|
+
}]
|
|
14
|
+
});
|
|
15
|
+
var __octaneUniversalPlan1 = universalPlan("nativescript", {
|
|
16
|
+
"kind": "host",
|
|
17
|
+
"type": "gridlayout",
|
|
18
|
+
"props": { "className": "vx-toast" },
|
|
19
|
+
"children": [{
|
|
20
|
+
"kind": "slot",
|
|
21
|
+
"slot": 0
|
|
22
|
+
}]
|
|
23
|
+
});
|
|
24
|
+
var __octaneUniversalPlan2 = universalPlan("nativescript", {
|
|
25
|
+
"kind": "slot",
|
|
26
|
+
"slot": 0
|
|
27
|
+
});
|
|
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
|
+
})]);
|
|
37
|
+
}, { "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
|
+
//#endregion
|
|
105
|
+
export { showToast };
|
package/dist/native/ui4.js
CHANGED
|
@@ -1,49 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"slot": 0
|
|
24
|
-
});
|
|
25
|
-
var InText = createContext(false);
|
|
26
|
-
var TextScope = defineUniversalComponent("nativescript", function TextScope(props) {
|
|
27
|
-
return InText({
|
|
28
|
-
value: true,
|
|
29
|
-
children: props.children
|
|
30
|
-
});
|
|
31
|
-
}, { "module": "@nativescript-community/octane" });
|
|
32
|
-
var Text = defineUniversalComponent("nativescript", function Text(props) {
|
|
33
|
-
const inText = useContext(InText);
|
|
34
|
-
return universalValue(__octaneUniversalPlan2, [universalIf(inText, () => {
|
|
35
|
-
return universalValue(__octaneUniversalPlan0, [
|
|
36
|
-
props.className,
|
|
37
|
-
props.style,
|
|
38
|
-
props.children
|
|
39
|
-
]);
|
|
40
|
-
}, () => {
|
|
41
|
-
return universalValue(__octaneUniversalPlan1, [
|
|
42
|
-
props.className,
|
|
43
|
-
props.style,
|
|
44
|
-
universalComponent("nativescript", TextScope, universalProps([], props.children))
|
|
45
|
-
]);
|
|
46
|
-
})]);
|
|
47
|
-
}, { "module": "@nativescript-community/octane" });
|
|
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";
|
|
22
|
+
}
|
|
48
23
|
//#endregion
|
|
49
|
-
export {
|
|
24
|
+
export { glassClassOf, glassConfigOf };
|
|
@@ -0,0 +1,58 @@
|
|
|
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);
|
|
49
|
+
}
|
|
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;
|
|
56
|
+
}
|
|
57
|
+
//#endregion
|
|
58
|
+
export { useAnimation };
|
|
@@ -0,0 +1,19 @@
|
|
|
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];
|
|
11
|
+
}
|
|
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);
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { styled };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Application } from "@nativescript/core";
|
|
2
|
+
//#region src/windows.native.ts
|
|
3
|
+
/** Open another NativeScript window and pass app-owned data to its resolver. */
|
|
4
|
+
function openWindow(options = {}) {
|
|
5
|
+
Application.openWindow(options);
|
|
6
|
+
}
|
|
7
|
+
//#endregion
|
|
8
|
+
export { openWindow };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { cx } from "./ui2.js";
|
|
2
|
+
import { applyEscapeProps } from "./ui3.js";
|
|
3
|
+
import { registerRootLayout, unregisterRootLayout } from "./ui34.js";
|
|
4
|
+
import { defineUniversalComponent, universalPlan, universalValue } from "@nativescript-community/octane";
|
|
5
|
+
//#region src/Screen.native.tsrx
|
|
6
|
+
var __octaneUniversalPlan0 = universalPlan("nativescript", {
|
|
7
|
+
"kind": "host",
|
|
8
|
+
"type": "rootlayout",
|
|
9
|
+
"bindings": [
|
|
10
|
+
["id", 0],
|
|
11
|
+
["ref", 1],
|
|
12
|
+
["onLoaded", 2],
|
|
13
|
+
["onUnloaded", 3]
|
|
14
|
+
],
|
|
15
|
+
"children": [{
|
|
16
|
+
"kind": "host",
|
|
17
|
+
"type": "flexboxlayout",
|
|
18
|
+
"props": { "flexDirection": "column" },
|
|
19
|
+
"bindings": [["className", 4], ["style", 5]],
|
|
20
|
+
"children": [{
|
|
21
|
+
"kind": "slot",
|
|
22
|
+
"slot": 6
|
|
23
|
+
}]
|
|
24
|
+
}]
|
|
25
|
+
});
|
|
26
|
+
var Screen = defineUniversalComponent("nativescript", function Screen(props) {
|
|
27
|
+
return universalValue(__octaneUniversalPlan0, [
|
|
28
|
+
props.id,
|
|
29
|
+
(v) => applyEscapeProps(v, props),
|
|
30
|
+
(e) => registerRootLayout(e.object),
|
|
31
|
+
(e) => unregisterRootLayout(e.object),
|
|
32
|
+
cx(props.className),
|
|
33
|
+
props.style,
|
|
34
|
+
props.children
|
|
35
|
+
]);
|
|
36
|
+
}, { "module": "@nativescript-community/octane" });
|
|
37
|
+
//#endregion
|
|
38
|
+
export { Screen };
|