@octane-xplat/ui 0.3.0 → 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 -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 +118 -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 +78 -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/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 -24
- package/dist/native/ui4.js +22 -20
- package/dist/native/ui40.js +57 -13
- package/dist/native/ui41.js +15 -100
- package/dist/native/ui42.js +6 -146
- package/dist/native/ui43.js +37 -21
- package/dist/native/ui44.js +265 -6
- 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 -77
- 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 +52 -9
- package/dist/native/ui60.js +108 -0
- package/dist/native/ui61.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 +51 -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 +201 -97
- 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 +54 -51
- package/dist/web/ui35.js +55 -7
- package/dist/web/ui36.js +18 -41
- package/dist/web/ui37.js +6 -46
- package/dist/web/ui38.js +37 -16
- package/dist/web/ui39.js +135 -81
- package/dist/web/ui4.js +46 -152
- package/dist/web/ui40.js +39 -37
- package/dist/web/ui41.js +41 -16
- package/dist/web/ui42.js +74 -7
- package/dist/web/ui43.js +40 -20
- package/dist/web/ui44.js +60 -6
- 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 +131 -27
- 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 +81 -45
- package/dist/web/ui7.js +43 -21
- package/dist/web/ui8.js +27 -21
- package/dist/web/ui9.js +29 -18
- package/package.json +13 -4
- package/src/theme/tokens.css +369 -138
- package/types/index.d.ts +102 -58
- package/types/props.d.ts +233 -13
package/dist/native/ui28.js
CHANGED
|
@@ -1,146 +1,40 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
});
|
|
13
|
-
var __octaneUniversalPlan1 = universalPlan("nativescript", {
|
|
14
|
-
"kind": "host",
|
|
15
|
-
"type": "tabview",
|
|
16
|
-
"bindings": [
|
|
17
|
-
["id", 0],
|
|
18
|
-
["className", 1],
|
|
19
|
-
["style", 2],
|
|
20
|
-
["items", 3],
|
|
21
|
-
["selectedIndex", 4],
|
|
22
|
-
["onSelectedIndexChanged", 5],
|
|
23
|
-
["onLoaded", 6]
|
|
24
|
-
]
|
|
25
|
-
});
|
|
26
|
-
var __octaneUniversalPlan2 = universalPlan("nativescript", {
|
|
27
|
-
"kind": "slot",
|
|
28
|
-
"slot": 0
|
|
29
|
-
});
|
|
30
|
-
var TabPane = defineUniversalComponent("nativescript", function TabPane(props) {
|
|
31
|
-
return universalValue(__octaneUniversalPlan0, [props.render()]);
|
|
32
|
-
}, { "module": "@nativescript-community/octane" });
|
|
33
|
-
var paneRoots = /* @__PURE__ */ new WeakMap();
|
|
34
|
-
var tabsByView = /* @__PURE__ */ new WeakMap();
|
|
35
|
-
var itemsCache = /* @__PURE__ */ new WeakMap();
|
|
36
|
-
function itemsFor(tabs) {
|
|
37
|
-
let items = itemsCache.get(tabs);
|
|
38
|
-
if (items !== void 0) return items;
|
|
39
|
-
items = tabs.map((t) => {
|
|
40
|
-
const item = new TabViewItem();
|
|
41
|
-
item.title = t.title;
|
|
42
|
-
if (t.stack) {
|
|
43
|
-
const frame = new Frame();
|
|
44
|
-
frame.once("loaded", () => {
|
|
45
|
-
frame.navigate({ create: () => {
|
|
46
|
-
const page = new Page();
|
|
47
|
-
page.actionBarHidden = true;
|
|
48
|
-
const pane = new GridLayout();
|
|
49
|
-
page.content = pane;
|
|
50
|
-
createNativeScriptRoot(pane).render(TabPane, { render: t.render });
|
|
51
|
-
return page;
|
|
52
|
-
} });
|
|
53
|
-
});
|
|
54
|
-
registerStack(t.stack, frame);
|
|
55
|
-
item.view = frame;
|
|
56
|
-
return item;
|
|
57
|
-
}
|
|
58
|
-
const cv = new GridLayout();
|
|
59
|
-
tabsByView.set(cv, t.render);
|
|
60
|
-
item.view = cv;
|
|
61
|
-
return item;
|
|
62
|
-
});
|
|
63
|
-
itemsCache.set(tabs, items);
|
|
64
|
-
return items;
|
|
1
|
+
import { registerElement } from "@nativescript-community/octane";
|
|
2
|
+
import { SVGView } from "@nativescript-community/ui-svg";
|
|
3
|
+
//#region src/svg.native.ts
|
|
4
|
+
registerElement("svgview", SVGView);
|
|
5
|
+
var SVG_DATA_URI = /^data:image\/svg\+xml[;,]/i;
|
|
6
|
+
var SVG_PATH = /\.svg([?#].*)?$/i;
|
|
7
|
+
var EMPTY_SVG = "<svg xmlns=\"http://www.w3.org/2000/svg\"/>";
|
|
8
|
+
/** True when an `src` carries SVG: inline markup, an svg data URI, or an
|
|
9
|
+
* .svg path/URL. Anything else stays on the raster <image> path. */
|
|
10
|
+
function isSvgSrc(src) {
|
|
11
|
+
return src.trimStart().startsWith("<svg") || SVG_DATA_URI.test(src) || SVG_PATH.test(src);
|
|
65
12
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
13
|
+
/** Normalize an svg-shaped src into SVGView's grammar: file/resource paths and
|
|
14
|
+
* markup pass through, data URIs decode to markup, remote URLs fetch to
|
|
15
|
+
* markup (SVGView has no fetch of its own — it awaits promise srcs). */
|
|
16
|
+
function svgSource(src) {
|
|
17
|
+
if (SVG_DATA_URI.test(src)) {
|
|
18
|
+
const comma = src.indexOf(",");
|
|
19
|
+
const body = src.slice(comma + 1);
|
|
20
|
+
if (src.slice(0, comma).endsWith(";base64")) {
|
|
21
|
+
const atob = globalThis.atob;
|
|
22
|
+
if (!atob) return EMPTY_SVG;
|
|
23
|
+
return atob(body);
|
|
24
|
+
}
|
|
25
|
+
return decodeURIComponent(body);
|
|
76
26
|
}
|
|
77
|
-
|
|
27
|
+
if (/^https?:\/\//.test(src)) return fetch(src).then((r) => r.ok ? r.text() : EMPTY_SVG).catch(() => EMPTY_SVG);
|
|
28
|
+
return src;
|
|
29
|
+
}
|
|
30
|
+
/** IconGlyph → a full `<svg>` string for SVGView. `svg` path data gets a
|
|
31
|
+
* `<path>` with the requested fill; `markup` wraps inside a viewBox shell
|
|
32
|
+
* with `color`/`fill` set on the root so `currentColor` and default-fill
|
|
33
|
+
* children pick up the tint. */
|
|
34
|
+
function glyphSvgMarkup(glyph, color) {
|
|
35
|
+
const viewBox = glyph.viewBox ?? "0 0 24 24";
|
|
36
|
+
if (glyph.markup) return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="${viewBox}"${color ? ` color="${color}" fill="${color}"` : ""}>${glyph.markup}</svg>`;
|
|
37
|
+
if (glyph.svg) return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="${viewBox}"><path d="${glyph.svg}" fill="${color ?? "currentColor"}"/></svg>`;
|
|
78
38
|
}
|
|
79
|
-
var TabsInner = defineUniversalComponent("nativescript", function TabsInner(props) {
|
|
80
|
-
return universalValue(__octaneUniversalPlan1, [
|
|
81
|
-
props.id,
|
|
82
|
-
cx(props.className),
|
|
83
|
-
props.style,
|
|
84
|
-
itemsFor(props.tabs),
|
|
85
|
-
props.selectedIndex,
|
|
86
|
-
(e) => props.onSelectedIndexChanged?.(e.value),
|
|
87
|
-
mountPanes
|
|
88
|
-
]);
|
|
89
|
-
}, { "module": "@nativescript-community/octane" });
|
|
90
|
-
var MemoTabs = memo(TabsInner, (a, b) => a.tabs === b.tabs && a.selectedIndex === b.selectedIndex);
|
|
91
|
-
var Tabs = defineUniversalComponent("nativescript", markWarm(function Tabs(props) {
|
|
92
|
-
useBatch([], () => {
|
|
93
|
-
warmChild(MemoTabs, {
|
|
94
|
-
id: props.id,
|
|
95
|
-
className: props.className,
|
|
96
|
-
style: props.style,
|
|
97
|
-
tabs: props.tabs,
|
|
98
|
-
selectedIndex: props.selectedIndex,
|
|
99
|
-
onSelectedIndexChanged: props.onSelectedIndexChanged
|
|
100
|
-
});
|
|
101
|
-
});
|
|
102
|
-
return universalValue(__octaneUniversalPlan2, [universalComponent("nativescript", MemoTabs, universalProps([
|
|
103
|
-
[
|
|
104
|
-
"set",
|
|
105
|
-
"id",
|
|
106
|
-
props.id
|
|
107
|
-
],
|
|
108
|
-
[
|
|
109
|
-
"set",
|
|
110
|
-
"className",
|
|
111
|
-
props.className
|
|
112
|
-
],
|
|
113
|
-
[
|
|
114
|
-
"set",
|
|
115
|
-
"style",
|
|
116
|
-
props.style
|
|
117
|
-
],
|
|
118
|
-
[
|
|
119
|
-
"set",
|
|
120
|
-
"tabs",
|
|
121
|
-
props.tabs
|
|
122
|
-
],
|
|
123
|
-
[
|
|
124
|
-
"set",
|
|
125
|
-
"selectedIndex",
|
|
126
|
-
props.selectedIndex
|
|
127
|
-
],
|
|
128
|
-
[
|
|
129
|
-
"set",
|
|
130
|
-
"onSelectedIndexChanged",
|
|
131
|
-
props.onSelectedIndexChanged
|
|
132
|
-
]
|
|
133
|
-
]))]);
|
|
134
|
-
}, (__wp) => {
|
|
135
|
-
const props = __wp;
|
|
136
|
-
warmChild(MemoTabs, {
|
|
137
|
-
id: props.id,
|
|
138
|
-
className: props.className,
|
|
139
|
-
style: props.style,
|
|
140
|
-
tabs: props.tabs,
|
|
141
|
-
selectedIndex: props.selectedIndex,
|
|
142
|
-
onSelectedIndexChanged: props.onSelectedIndexChanged
|
|
143
|
-
});
|
|
144
|
-
}), { "module": "@nativescript-community/octane" });
|
|
145
39
|
//#endregion
|
|
146
|
-
export {
|
|
40
|
+
export { glyphSvgMarkup, isSvgSrc, svgSource };
|
package/dist/native/ui29.js
CHANGED
|
@@ -1,28 +1,108 @@
|
|
|
1
1
|
import { cx } from "./ui2.js";
|
|
2
2
|
import { applyEscapeProps } from "./ui3.js";
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import { layoutChildProps } from "./ui5.js";
|
|
4
|
+
import { isSvgSrc, svgSource } from "./ui28.js";
|
|
5
|
+
import { defineUniversalComponent, hookSlots, universalIf, universalPlan, universalProps, universalValue, useMemo } from "@nativescript-community/octane";
|
|
6
|
+
import { ImageSource } from "@nativescript/core";
|
|
7
|
+
//#region src/Image.native.tsrx
|
|
8
|
+
var _hs$ = /* @__PURE__ */ hookSlots(2);
|
|
9
|
+
var _h$0 = /* @__PURE__ */ Symbol(_hs$);
|
|
10
|
+
var _h$1 = /* @__PURE__ */ Symbol(_hs$ + 1);
|
|
5
11
|
var __octaneUniversalPlan0 = universalPlan("nativescript", {
|
|
6
12
|
"kind": "host",
|
|
7
|
-
"type": "
|
|
8
|
-
"
|
|
9
|
-
["ref", 0],
|
|
10
|
-
["id", 1],
|
|
11
|
-
["className", 2],
|
|
12
|
-
["style", 3],
|
|
13
|
-
["checked", 4],
|
|
14
|
-
["onCheckedChange", 5]
|
|
15
|
-
]
|
|
13
|
+
"type": "svgview",
|
|
14
|
+
"propsSlot": 0
|
|
16
15
|
});
|
|
17
|
-
var
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
16
|
+
var __octaneUniversalPlan1 = universalPlan("nativescript", {
|
|
17
|
+
"kind": "host",
|
|
18
|
+
"type": "image",
|
|
19
|
+
"propsSlot": 0
|
|
20
|
+
});
|
|
21
|
+
var __octaneUniversalPlan2 = universalPlan("nativescript", {
|
|
22
|
+
"kind": "slot",
|
|
23
|
+
"slot": 0
|
|
24
|
+
});
|
|
25
|
+
var Image = defineUniversalComponent("nativescript", function Image(props) {
|
|
26
|
+
const svg = useMemo(() => isSvgSrc(props.src) ? svgSource(props.src) : null, [props.src], _h$0);
|
|
27
|
+
const source = useMemo(() => {
|
|
28
|
+
const comma = props.src.indexOf(",");
|
|
29
|
+
if (props.src.startsWith("data:") && comma > 0 && props.src.slice(0, comma).endsWith(";base64")) return ImageSource.fromBase64Sync(props.src.slice(comma + 1));
|
|
30
|
+
return props.src;
|
|
31
|
+
}, [props.src], _h$1);
|
|
32
|
+
return universalValue(__octaneUniversalPlan2, [universalIf(svg != null, () => {
|
|
33
|
+
return universalValue(__octaneUniversalPlan0, [universalProps([
|
|
34
|
+
[
|
|
35
|
+
"set",
|
|
36
|
+
"ref",
|
|
37
|
+
(v) => applyEscapeProps(v, props)
|
|
38
|
+
],
|
|
39
|
+
[
|
|
40
|
+
"set",
|
|
41
|
+
"id",
|
|
42
|
+
props.id
|
|
43
|
+
],
|
|
44
|
+
["spread", layoutChildProps(props)],
|
|
45
|
+
[
|
|
46
|
+
"set",
|
|
47
|
+
"className",
|
|
48
|
+
cx(props.className)
|
|
49
|
+
],
|
|
50
|
+
[
|
|
51
|
+
"set",
|
|
52
|
+
"style",
|
|
53
|
+
props.style
|
|
54
|
+
],
|
|
55
|
+
[
|
|
56
|
+
"set",
|
|
57
|
+
"src",
|
|
58
|
+
svg
|
|
59
|
+
],
|
|
60
|
+
[
|
|
61
|
+
"set",
|
|
62
|
+
"stretch",
|
|
63
|
+
"aspectFit"
|
|
64
|
+
],
|
|
65
|
+
[
|
|
66
|
+
"set",
|
|
67
|
+
"accessibilityLabel",
|
|
68
|
+
props.alt
|
|
69
|
+
]
|
|
70
|
+
])]);
|
|
71
|
+
}, () => {
|
|
72
|
+
return universalValue(__octaneUniversalPlan1, [universalProps([
|
|
73
|
+
[
|
|
74
|
+
"set",
|
|
75
|
+
"ref",
|
|
76
|
+
(v) => applyEscapeProps(v, props)
|
|
77
|
+
],
|
|
78
|
+
[
|
|
79
|
+
"set",
|
|
80
|
+
"id",
|
|
81
|
+
props.id
|
|
82
|
+
],
|
|
83
|
+
["spread", layoutChildProps(props)],
|
|
84
|
+
[
|
|
85
|
+
"set",
|
|
86
|
+
"className",
|
|
87
|
+
cx(props.className)
|
|
88
|
+
],
|
|
89
|
+
[
|
|
90
|
+
"set",
|
|
91
|
+
"style",
|
|
92
|
+
props.style
|
|
93
|
+
],
|
|
94
|
+
[
|
|
95
|
+
"set",
|
|
96
|
+
"src",
|
|
97
|
+
source
|
|
98
|
+
],
|
|
99
|
+
[
|
|
100
|
+
"set",
|
|
101
|
+
"accessibilityLabel",
|
|
102
|
+
props.alt
|
|
103
|
+
]
|
|
104
|
+
])]);
|
|
105
|
+
})]);
|
|
26
106
|
}, { "module": "@nativescript-community/octane" });
|
|
27
107
|
//#endregion
|
|
28
|
-
export {
|
|
108
|
+
export { Image };
|
package/dist/native/ui30.js
CHANGED
|
@@ -1,35 +1,18 @@
|
|
|
1
|
-
import { hookSlots, useEffect, useState } from "@nativescript-community/octane";
|
|
2
1
|
import { Application } from "@nativescript/core";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
function measure() {
|
|
8
|
-
const insets = (Application.ios?.rootController?.view)?.safeAreaInsets;
|
|
9
|
-
if (insets) return {
|
|
10
|
-
top: insets.top,
|
|
11
|
-
right: insets.right,
|
|
12
|
-
bottom: insets.bottom,
|
|
13
|
-
left: insets.left
|
|
14
|
-
};
|
|
15
|
-
return {
|
|
16
|
-
top: 0,
|
|
17
|
-
right: 0,
|
|
18
|
-
bottom: 0,
|
|
19
|
-
left: 0
|
|
20
|
-
};
|
|
2
|
+
import { hookSlots, useSyncExternalStore } from "octane";
|
|
3
|
+
//#region src/theme/colorScheme.native.ts
|
|
4
|
+
function getColorScheme() {
|
|
5
|
+
return Application.primaryWindow?.systemAppearance?.() ?? Application.systemAppearance?.() ?? "light";
|
|
21
6
|
}
|
|
22
|
-
function
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
Application.on(Application.orientationChangedEvent, update);
|
|
27
|
-
update();
|
|
28
|
-
return () => {
|
|
29
|
-
Application.off(Application.orientationChangedEvent, update);
|
|
30
|
-
};
|
|
31
|
-
}, [], _h$1);
|
|
32
|
-
return insets;
|
|
7
|
+
function subscribeSystemScheme(cb) {
|
|
8
|
+
const h = () => cb();
|
|
9
|
+
Application.on("systemAppearanceChanged", h);
|
|
10
|
+
return () => Application.off("systemAppearanceChanged", h);
|
|
33
11
|
}
|
|
12
|
+
/** Reactive system appearance — 'light' | 'dark', re-renders on OS change. */
|
|
13
|
+
function useColorScheme() {
|
|
14
|
+
return useSyncExternalStore(subscribeSystemScheme, getColorScheme, _h$0);
|
|
15
|
+
}
|
|
16
|
+
var _h$0 = /* @__PURE__ */ Symbol(/* @__PURE__ */ hookSlots(1));
|
|
34
17
|
//#endregion
|
|
35
|
-
export {
|
|
18
|
+
export { getColorScheme, subscribeSystemScheme, useColorScheme };
|
package/dist/native/ui31.js
CHANGED
|
@@ -1,39 +1,58 @@
|
|
|
1
1
|
import { cx } from "./ui2.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import { getColorScheme, subscribeSystemScheme } from "./ui30.js";
|
|
3
|
+
import { hookSlots, useSyncExternalStore } from "octane";
|
|
4
|
+
//#region src/theme/theme-scheme.ts
|
|
5
|
+
var preference = "system";
|
|
6
|
+
var listeners = /* @__PURE__ */ new Set();
|
|
7
|
+
var emit = () => listeners.forEach((l) => l());
|
|
8
|
+
/** App-level theme override. 'system' clears the override and follows the OS. */
|
|
9
|
+
function setThemePreference(p) {
|
|
10
|
+
if (p !== preference) {
|
|
11
|
+
preference = p;
|
|
12
|
+
emit();
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function getThemePreference() {
|
|
16
|
+
return preference;
|
|
17
|
+
}
|
|
18
|
+
/** The effective scheme: explicit override if set, else system appearance. */
|
|
19
|
+
function getThemeScheme() {
|
|
20
|
+
return preference === "system" ? getColorScheme() : preference;
|
|
21
|
+
}
|
|
22
|
+
function subscribe(cb) {
|
|
23
|
+
listeners.add(cb);
|
|
24
|
+
const offSystem = subscribeSystemScheme(cb);
|
|
25
|
+
return () => {
|
|
26
|
+
listeners.delete(cb);
|
|
27
|
+
offSystem();
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/** Reactive effective scheme — re-renders on override or OS change. */
|
|
31
|
+
function useThemeScheme() {
|
|
32
|
+
return useSyncExternalStore(subscribe, getThemeScheme, _h$0);
|
|
33
|
+
}
|
|
34
|
+
/** Class string to stamp on independently-mounted roots (portal hosts,
|
|
35
|
+
* overlay/sheet/modal/toast containers): 'ns-dark dark' when effective
|
|
36
|
+
* dark, '' otherwise. Both names because tokens.css publishes both
|
|
37
|
+
* selectors and hosts may render either vocabulary. */
|
|
38
|
+
function themeSchemeClasses() {
|
|
39
|
+
return getThemeScheme() === "dark" ? "ns-dark dark" : "";
|
|
40
|
+
}
|
|
41
|
+
/** Subscribe imperative hosts to effective-scheme changes; returns an
|
|
42
|
+
* unsubscribe. Use for hosts that live outside any render cycle. */
|
|
43
|
+
function onThemeSchemeChange(cb) {
|
|
44
|
+
return subscribe(cb);
|
|
45
|
+
}
|
|
46
|
+
/** Stamp `base + themeSchemeClasses()` onto an imperative host (NS view or
|
|
47
|
+
* DOM element) and keep it live — returns an unsubscribe to call when the
|
|
48
|
+
* host closes. Works on both leaves since both honor `.className`. */
|
|
49
|
+
function applyThemeClasses(view, base) {
|
|
50
|
+
const apply = () => {
|
|
51
|
+
view.className = cx(base, themeSchemeClasses());
|
|
52
|
+
};
|
|
53
|
+
apply();
|
|
54
|
+
return onThemeSchemeChange(apply);
|
|
55
|
+
}
|
|
6
56
|
var _h$0 = /* @__PURE__ */ Symbol(/* @__PURE__ */ hookSlots(1));
|
|
7
|
-
var __octaneUniversalPlan0 = universalPlan("nativescript", {
|
|
8
|
-
"kind": "host",
|
|
9
|
-
"type": "flexboxlayout",
|
|
10
|
-
"bindings": [
|
|
11
|
-
["ref", 0],
|
|
12
|
-
["className", 1],
|
|
13
|
-
["style", 2]
|
|
14
|
-
],
|
|
15
|
-
"children": [{
|
|
16
|
-
"kind": "slot",
|
|
17
|
-
"slot": 3
|
|
18
|
-
}]
|
|
19
|
-
});
|
|
20
|
-
var SafeArea = defineUniversalComponent("nativescript", function SafeArea(props) {
|
|
21
|
-
const insets = withSlot(_h$0, useSafeAreaInsets);
|
|
22
|
-
const platformProps = Application.ios != null ? props.ios : props.android;
|
|
23
|
-
return universalValue(__octaneUniversalPlan0, [
|
|
24
|
-
(host) => {
|
|
25
|
-
if (host && platformProps) Object.assign(host, platformProps);
|
|
26
|
-
},
|
|
27
|
-
cx("vx-safe-area", props.className),
|
|
28
|
-
{
|
|
29
|
-
...props.style,
|
|
30
|
-
paddingTop: insets.top,
|
|
31
|
-
paddingRight: insets.right,
|
|
32
|
-
paddingBottom: insets.bottom,
|
|
33
|
-
paddingLeft: insets.left
|
|
34
|
-
},
|
|
35
|
-
props.children
|
|
36
|
-
]);
|
|
37
|
-
}, { "module": "@nativescript-community/octane" });
|
|
38
57
|
//#endregion
|
|
39
|
-
export {
|
|
58
|
+
export { applyThemeClasses, getThemePreference, getThemeScheme, onThemeSchemeChange, setThemePreference, themeSchemeClasses, useThemeScheme };
|
package/dist/native/ui32.js
CHANGED
|
@@ -1,70 +1,58 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { defineUniversalComponent, hookSlots, universalPlan, universalValue, useEffect,
|
|
3
|
-
import {
|
|
4
|
-
//#region src/
|
|
5
|
-
var _hs$ = /* @__PURE__ */ hookSlots(
|
|
1
|
+
import { applyThemeClasses } from "./ui31.js";
|
|
2
|
+
import { createNativeScriptRoot, defineUniversalComponent, hookSlots, universalPlan, universalValue, useEffect, useRef } from "@nativescript-community/octane";
|
|
3
|
+
import { Frame, GridLayout } from "@nativescript/core";
|
|
4
|
+
//#region src/Modal.native.tsrx
|
|
5
|
+
var _hs$ = /* @__PURE__ */ hookSlots(2);
|
|
6
6
|
var _h$0 = /* @__PURE__ */ Symbol(_hs$);
|
|
7
7
|
var _h$1 = /* @__PURE__ */ Symbol(_hs$ + 1);
|
|
8
|
-
var _h$2 = /* @__PURE__ */ Symbol(_hs$ + 2);
|
|
9
|
-
var _h$3 = /* @__PURE__ */ Symbol(_hs$ + 3);
|
|
10
|
-
var _h$4 = /* @__PURE__ */ Symbol(_hs$ + 4);
|
|
11
8
|
var __octaneUniversalPlan0 = universalPlan("nativescript", {
|
|
12
|
-
"kind": "
|
|
13
|
-
"type": "scrollview",
|
|
14
|
-
"bindings": [
|
|
15
|
-
["className", 0],
|
|
16
|
-
["style", 1],
|
|
17
|
-
["ref", 2]
|
|
18
|
-
],
|
|
9
|
+
"kind": "range",
|
|
19
10
|
"children": [{
|
|
20
|
-
"kind": "
|
|
21
|
-
"
|
|
22
|
-
"props": { "flexDirection": "column" },
|
|
23
|
-
"bindings": [["style", 3]],
|
|
24
|
-
"children": [{
|
|
25
|
-
"kind": "slot",
|
|
26
|
-
"slot": 4
|
|
27
|
-
}]
|
|
11
|
+
"kind": "slot",
|
|
12
|
+
"slot": 0
|
|
28
13
|
}]
|
|
29
14
|
});
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
});
|
|
40
|
-
return () => center.removeObserver(token);
|
|
41
|
-
}, [], _h$1);
|
|
42
|
-
return inset;
|
|
43
|
-
}
|
|
44
|
-
function useAndroidResize() {
|
|
15
|
+
var __octaneUniversalPlan1 = universalPlan("nativescript", {
|
|
16
|
+
"kind": "range",
|
|
17
|
+
"children": []
|
|
18
|
+
});
|
|
19
|
+
var Panel = defineUniversalComponent("nativescript", function Panel(props) {
|
|
20
|
+
return universalValue(__octaneUniversalPlan0, [props.children]);
|
|
21
|
+
}, { "module": "@nativescript-community/octane" });
|
|
22
|
+
var Modal = defineUniversalComponent("nativescript", function Modal(props) {
|
|
23
|
+
const shown = useRef(null, _h$0);
|
|
45
24
|
useEffect(() => {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
25
|
+
if (props.open && !shown.current) {
|
|
26
|
+
const presenter = Frame.topmost()?.currentPage ?? Frame.topmost();
|
|
27
|
+
if (!presenter) return;
|
|
28
|
+
const host = new GridLayout();
|
|
29
|
+
const unbindTheme = applyThemeClasses(host, "vx-modal-host");
|
|
30
|
+
const root = createNativeScriptRoot(host);
|
|
31
|
+
shown.current = {
|
|
32
|
+
host,
|
|
33
|
+
root,
|
|
34
|
+
unbindTheme
|
|
35
|
+
};
|
|
36
|
+
if (props.component) root.render(props.component, props.params ?? {});
|
|
37
|
+
else root.render(Panel, { children: props.children });
|
|
38
|
+
const fullscreen = props.presentation ? props.presentation === "fullscreen" : props.fullscreen ?? true;
|
|
39
|
+
presenter.showModal(host, {
|
|
40
|
+
context: {},
|
|
41
|
+
closeCallback: (result) => {
|
|
42
|
+
shown.current?.unbindTheme?.();
|
|
43
|
+
shown.current = null;
|
|
44
|
+
props.onClose?.(result);
|
|
45
|
+
},
|
|
46
|
+
fullscreen,
|
|
47
|
+
animated: true
|
|
48
|
+
});
|
|
49
|
+
} else if (!props.open && shown.current) {
|
|
50
|
+
const { host } = shown.current;
|
|
51
|
+
shown.current = null;
|
|
52
|
+
host.closeModal();
|
|
53
|
+
}
|
|
54
|
+
}, [props.open], _h$1);
|
|
55
|
+
return universalValue(__octaneUniversalPlan1, []);
|
|
68
56
|
}, { "module": "@nativescript-community/octane" });
|
|
69
57
|
//#endregion
|
|
70
|
-
export {
|
|
58
|
+
export { Modal };
|
package/dist/native/ui33.js
CHANGED
|
@@ -1,30 +1,38 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
//#region src/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
import { applyThemeClasses } from "./ui31.js";
|
|
2
|
+
import { createNativeScriptRoot } from "@nativescript-community/octane";
|
|
3
|
+
import { Frame, GridLayout } from "@nativescript/core";
|
|
4
|
+
//#region src/modal-service.native.ts
|
|
5
|
+
/** Open a component in its own NativeScript modal root and resolve on close. */
|
|
6
|
+
var openModal = (Component, params, options = {}) => new Promise((resolve, reject) => {
|
|
7
|
+
const presenter = Frame.topmost()?.currentPage ?? Frame.topmost();
|
|
8
|
+
if (!presenter) {
|
|
9
|
+
reject(/* @__PURE__ */ new Error("Cannot open modal before a NativeScript page is active"));
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
const host = new GridLayout();
|
|
13
|
+
const unbindTheme = applyThemeClasses(host, "vx-modal-host");
|
|
14
|
+
const root = createNativeScriptRoot(host);
|
|
15
|
+
let finished = false;
|
|
16
|
+
const finish = (result) => {
|
|
17
|
+
if (finished) return;
|
|
18
|
+
finished = true;
|
|
19
|
+
unbindTheme();
|
|
20
|
+
root.unmount?.();
|
|
21
|
+
host.removeChildren?.();
|
|
22
|
+
resolve(result);
|
|
23
|
+
};
|
|
24
|
+
const close = (result) => host.closeModal(result);
|
|
25
|
+
root.render(Component, {
|
|
26
|
+
params,
|
|
27
|
+
close
|
|
28
|
+
});
|
|
29
|
+
const fullscreen = options.presentation ? options.presentation === "fullscreen" : options.fullscreen ?? true;
|
|
30
|
+
presenter.showModal(host, {
|
|
31
|
+
context: {},
|
|
32
|
+
closeCallback: finish,
|
|
33
|
+
fullscreen,
|
|
34
|
+
animated: options.animated ?? true
|
|
35
|
+
});
|
|
17
36
|
});
|
|
18
|
-
var Drawer = defineUniversalComponent("nativescript", function Drawer(props) {
|
|
19
|
-
const platformProps = Application.ios != null ? props.ios : props.android;
|
|
20
|
-
return universalValue(__octaneUniversalPlan0, [
|
|
21
|
-
(host) => {
|
|
22
|
-
if (host && platformProps) Object.assign(host, platformProps);
|
|
23
|
-
},
|
|
24
|
-
cx("vx-drawer", props.className),
|
|
25
|
-
props.style,
|
|
26
|
-
props.main
|
|
27
|
-
]);
|
|
28
|
-
}, { "module": "@nativescript-community/octane" });
|
|
29
37
|
//#endregion
|
|
30
|
-
export {
|
|
38
|
+
export { openModal };
|