@octane-xplat/ui 0.2.0 → 0.3.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 (94) hide show
  1. package/dist/native/octane-client-build.json +1 -1
  2. package/dist/native/ui.js +40 -19
  3. package/dist/native/ui10.js +19 -48
  4. package/dist/native/ui11.js +118 -56
  5. package/dist/native/ui12.js +114 -16
  6. package/dist/native/ui13.js +54 -18
  7. package/dist/native/ui14.js +76 -13
  8. package/dist/native/ui15.js +128 -18
  9. package/dist/native/ui16.js +48 -136
  10. package/dist/native/ui17.js +42 -19
  11. package/dist/native/ui18.js +50 -9
  12. package/dist/native/ui19.js +34 -12
  13. package/dist/native/ui2.js +10 -48
  14. package/dist/native/ui20.js +17 -0
  15. package/dist/native/ui21.js +93 -0
  16. package/dist/native/ui22.js +124 -0
  17. package/dist/native/ui23.js +103 -0
  18. package/dist/native/ui24.js +58 -0
  19. package/dist/native/ui25.js +19 -0
  20. package/dist/native/ui26.js +27 -0
  21. package/dist/native/ui27.js +35 -0
  22. package/dist/native/ui28.js +146 -0
  23. package/dist/native/ui29.js +28 -0
  24. package/dist/native/ui3.js +17 -20
  25. package/dist/native/ui30.js +35 -0
  26. package/dist/native/ui31.js +39 -0
  27. package/dist/native/ui32.js +70 -0
  28. package/dist/native/ui33.js +30 -0
  29. package/dist/native/ui34.js +10 -0
  30. package/dist/native/ui35.js +27 -0
  31. package/dist/native/ui36.js +34 -0
  32. package/dist/native/ui37.js +17 -0
  33. package/dist/native/ui38.js +68 -0
  34. package/dist/native/ui39.js +33 -0
  35. package/dist/native/ui4.js +21 -48
  36. package/dist/native/ui40.js +14 -0
  37. package/dist/native/ui41.js +104 -0
  38. package/dist/native/ui42.js +148 -0
  39. package/dist/native/ui43.js +22 -0
  40. package/dist/native/ui44.js +8 -0
  41. package/dist/native/ui5.js +70 -27
  42. package/dist/native/ui6.js +36 -20
  43. package/dist/native/ui7.js +24 -61
  44. package/dist/native/ui8.js +16 -18
  45. package/dist/native/ui9.js +16 -13
  46. package/dist/web/octane-client-build.json +1 -1
  47. package/dist/web/ui.js +40 -19
  48. package/dist/web/ui10.js +187 -31
  49. package/dist/web/ui11.js +419 -53
  50. package/dist/web/ui12.js +83 -15
  51. package/dist/web/ui13.js +107 -19
  52. package/dist/web/ui14.js +98 -18
  53. package/dist/web/ui15.js +83 -47
  54. package/dist/web/ui16.js +100 -93
  55. package/dist/web/ui17.js +36 -22
  56. package/dist/web/ui18.js +29 -15
  57. package/dist/web/ui19.js +9 -7
  58. package/dist/web/ui2.js +15 -103
  59. package/dist/web/ui20.js +114 -0
  60. package/dist/web/ui21.js +82 -0
  61. package/dist/web/ui22.js +68 -0
  62. package/dist/web/ui23.js +57 -0
  63. package/dist/web/ui24.js +16 -0
  64. package/dist/web/ui25.js +22 -0
  65. package/dist/web/ui26.js +39 -0
  66. package/dist/web/ui27.js +127 -0
  67. package/dist/web/ui28.js +112 -0
  68. package/dist/web/ui29.js +108 -0
  69. package/dist/web/ui3.js +19 -27
  70. package/dist/web/ui30.js +43 -0
  71. package/dist/web/ui31.js +42 -0
  72. package/dist/web/ui32.js +77 -0
  73. package/dist/web/ui33.js +43 -0
  74. package/dist/web/ui34.js +67 -0
  75. package/dist/web/ui35.js +9 -0
  76. package/dist/web/ui36.js +45 -0
  77. package/dist/web/ui37.js +47 -0
  78. package/dist/web/ui38.js +17 -0
  79. package/dist/web/ui39.js +100 -0
  80. package/dist/web/ui4.js +145 -17
  81. package/dist/web/ui40.js +41 -0
  82. package/dist/web/ui41.js +17 -0
  83. package/dist/web/ui42.js +9 -0
  84. package/dist/web/ui43.js +22 -0
  85. package/dist/web/ui44.js +8 -0
  86. package/dist/web/ui5.js +54 -52
  87. package/dist/web/ui6.js +43 -16
  88. package/dist/web/ui7.js +29 -36
  89. package/dist/web/ui8.js +29 -18
  90. package/dist/web/ui9.js +24 -16
  91. package/package.json +14 -3
  92. package/src/theme/tokens.css +166 -0
  93. package/types/index.d.ts +108 -1
  94. package/types/props.d.ts +333 -8
@@ -0,0 +1,93 @@
1
+ import { cx } from "./ui2.js";
2
+ import { getColorScheme } from "./ui20.js";
3
+ import { createNativeScriptRoot, defineUniversalComponent, hookSlots, universalPlan, universalValue, useEffect, useRef } from "@nativescript-community/octane";
4
+ import { GridLayout, getRootLayout, isAndroid, isIOS } from "@nativescript/core";
5
+ //#region src/Overlay.native.tsrx
6
+ var _hs$ = /* @__PURE__ */ hookSlots(3);
7
+ var _h$0 = /* @__PURE__ */ Symbol(_hs$);
8
+ var _h$1 = /* @__PURE__ */ Symbol(_hs$ + 1);
9
+ var _h$2 = /* @__PURE__ */ Symbol(_hs$ + 2);
10
+ var __octaneUniversalPlan0 = universalPlan("nativescript", {
11
+ "kind": "range",
12
+ "children": [{
13
+ "kind": "slot",
14
+ "slot": 0
15
+ }]
16
+ });
17
+ var __octaneUniversalPlan1 = universalPlan("nativescript", {
18
+ "kind": "range",
19
+ "children": []
20
+ });
21
+ var OverlayBody = defineUniversalComponent("nativescript", function OverlayBody(props) {
22
+ return universalValue(__octaneUniversalPlan0, [props.children]);
23
+ }, { "module": "@nativescript-community/octane" });
24
+ var Overlay = defineUniversalComponent("nativescript", function Overlay(props) {
25
+ const shown = useRef(null, _h$0);
26
+ const dismiss = useRef(props.onDismiss, _h$1);
27
+ dismiss.current = props.onDismiss;
28
+ useEffect(() => {
29
+ const current = shown.current;
30
+ if (!props.open) {
31
+ if (!current) return;
32
+ current.dismissOnClose = false;
33
+ shown.current = null;
34
+ const rootLayout = getRootLayout();
35
+ if (rootLayout?.hasChild?.(current.host)) rootLayout.close(current.host).then(() => current.root.unmount?.(), (error) => {
36
+ console.error("[Overlay] close failed", error);
37
+ current.root.unmount?.();
38
+ });
39
+ else current.root.unmount?.();
40
+ return;
41
+ }
42
+ if (current) {
43
+ current.root.render(OverlayBody, { children: props.children });
44
+ current.host.className = cx("vx-overlay-host", getColorScheme() === "dark" && "ns-dark", props.className);
45
+ if (props.style) Object.assign(current.host.style, props.style);
46
+ Object.assign(current.host, isIOS ? props.ios : isAndroid ? props.android : void 0);
47
+ return;
48
+ }
49
+ const rootLayout = getRootLayout();
50
+ if (!rootLayout) return;
51
+ const host = new GridLayout();
52
+ host.className = cx("vx-overlay-host", getColorScheme() === "dark" && "ns-dark", props.className);
53
+ host.horizontalAlignment = "stretch";
54
+ host.verticalAlignment = "stretch";
55
+ if (props.style) Object.assign(host.style, props.style);
56
+ Object.assign(host, isIOS ? props.ios : isAndroid ? props.android : void 0);
57
+ const root = createNativeScriptRoot(host);
58
+ const opened = {
59
+ host,
60
+ root,
61
+ dismissOnClose: true
62
+ };
63
+ shown.current = opened;
64
+ root.render(OverlayBody, { children: props.children });
65
+ host.on("closed", () => {
66
+ if (shown.current === opened) shown.current = null;
67
+ root.unmount?.();
68
+ if (opened.dismissOnClose) dismiss.current?.();
69
+ });
70
+ const open = () => rootLayout.open(host, props.shadeCover ? { shadeCover: {
71
+ opacity: .45,
72
+ color: "#000000",
73
+ tapToClose: true
74
+ } } : {}).catch((error) => {
75
+ if (shown.current === opened) shown.current = null;
76
+ console.error("[Overlay] open failed", error);
77
+ root.unmount?.();
78
+ });
79
+ if (rootLayout.hasChild?.(host)) rootLayout.close(host).then(open, (error) => console.error("[Overlay] stale host close failed", error));
80
+ else open();
81
+ }, [
82
+ props.open,
83
+ props.children,
84
+ props.shadeCover,
85
+ props.className,
86
+ props.style,
87
+ props.ios,
88
+ props.android
89
+ ], _h$2);
90
+ return universalValue(__octaneUniversalPlan1, []);
91
+ }, { "module": "@nativescript-community/octane" });
92
+ //#endregion
93
+ export { Overlay };
@@ -0,0 +1,124 @@
1
+ import { cx } from "./ui2.js";
2
+ import { getColorScheme } from "./ui20.js";
3
+ import { createNativeScriptRoot, defineUniversalComponent, hookSlots, universalPlan, universalValue, useEffect, useRef } from "@nativescript-community/octane";
4
+ import { GridLayout, getRootLayout, isAndroid, isIOS } from "@nativescript/core";
5
+ //#region src/Popover.native.tsrx
6
+ var _hs$ = /* @__PURE__ */ hookSlots(2);
7
+ var _h$0 = /* @__PURE__ */ Symbol(_hs$);
8
+ var _h$1 = /* @__PURE__ */ Symbol(_hs$ + 1);
9
+ var __octaneUniversalPlan0 = universalPlan("nativescript", {
10
+ "kind": "host",
11
+ "type": "absolutelayout",
12
+ "children": [{
13
+ "kind": "host",
14
+ "type": "gridlayout",
15
+ "bindings": [
16
+ ["left", 0],
17
+ ["top", 1],
18
+ ["className", 2],
19
+ ["style", 3]
20
+ ],
21
+ "children": [{
22
+ "kind": "slot",
23
+ "slot": 4
24
+ }]
25
+ }]
26
+ });
27
+ var __octaneUniversalPlan1 = universalPlan("nativescript", {
28
+ "kind": "range",
29
+ "children": []
30
+ });
31
+ var PopoverBody = defineUniversalComponent("nativescript", function PopoverBody(props) {
32
+ return universalValue(__octaneUniversalPlan0, [
33
+ props.left,
34
+ props.top,
35
+ cx("vx-popover", props.className),
36
+ props.style,
37
+ props.children
38
+ ]);
39
+ }, { "module": "@nativescript-community/octane" });
40
+ var Popover = defineUniversalComponent("nativescript", function Popover(props) {
41
+ const shown = useRef(null, _h$0);
42
+ const anchorRef = props.anchor?.current ?? props.anchor;
43
+ useEffect(() => {
44
+ const current = shown.current;
45
+ if (!props.open) {
46
+ if (!current) return;
47
+ shown.current = null;
48
+ const rootLayout = getRootLayout();
49
+ if (rootLayout?.hasChild?.(current.host)) rootLayout.close(current.host).then(() => current.root.unmount?.(), (error) => {
50
+ console.error("[Popover] close failed", error);
51
+ current.root.unmount?.();
52
+ });
53
+ else current.root.unmount?.();
54
+ return;
55
+ }
56
+ const rootLayout = getRootLayout();
57
+ if (!rootLayout || !anchorRef?.getLocationRelativeTo || !anchorRef?.getActualSize) return;
58
+ const anchorPoint = anchorRef.getLocationRelativeTo(rootLayout);
59
+ const size = anchorRef.getActualSize();
60
+ const gap = 8;
61
+ let left = anchorPoint.x;
62
+ let top = anchorPoint.y + size.height + gap;
63
+ if (props.placement === "top") top = anchorPoint.y - 56;
64
+ if (props.placement === "left") {
65
+ left = anchorPoint.x - 168;
66
+ top = anchorPoint.y;
67
+ }
68
+ if (props.placement === "right") {
69
+ left = anchorPoint.x + size.width + gap;
70
+ top = anchorPoint.y;
71
+ }
72
+ if (current) {
73
+ current.left = left;
74
+ current.top = top;
75
+ current.root.render(PopoverBody, {
76
+ children: props.children,
77
+ left,
78
+ top,
79
+ className: props.className,
80
+ style: props.style
81
+ });
82
+ return;
83
+ }
84
+ const host = new GridLayout();
85
+ host.className = cx("vx-popover-host", getColorScheme() === "dark" && "ns-dark");
86
+ host.horizontalAlignment = "stretch";
87
+ host.verticalAlignment = "stretch";
88
+ Object.assign(host, isIOS ? props.ios : isAndroid ? props.android : void 0);
89
+ const root = createNativeScriptRoot(host);
90
+ const opened = {
91
+ host,
92
+ root,
93
+ left,
94
+ top
95
+ };
96
+ shown.current = opened;
97
+ root.render(PopoverBody, {
98
+ children: props.children,
99
+ left,
100
+ top,
101
+ className: props.className,
102
+ style: props.style
103
+ });
104
+ const open = () => rootLayout.open(host).catch((error) => {
105
+ if (shown.current === opened) shown.current = null;
106
+ console.error("[Popover] open failed", error);
107
+ root.unmount?.();
108
+ });
109
+ if (rootLayout.hasChild?.(host)) rootLayout.close(host).then(open, (error) => console.error("[Popover] stale host close failed", error));
110
+ else open();
111
+ }, [
112
+ props.open,
113
+ props.anchor,
114
+ props.placement,
115
+ props.children,
116
+ props.className,
117
+ props.style,
118
+ props.ios,
119
+ props.android
120
+ ], _h$1);
121
+ return universalValue(__octaneUniversalPlan1, []);
122
+ }, { "module": "@nativescript-community/octane" });
123
+ //#endregion
124
+ export { Popover };
@@ -0,0 +1,103 @@
1
+ import { cx } from "./ui2.js";
2
+ import { getColorScheme } from "./ui20.js";
3
+ import { createNativeScriptRoot, defineUniversalComponent, universalComponent, universalIf, universalPlan, universalProps, universalValue } from "@nativescript-community/octane";
4
+ import { GridLayout, getRootLayout, 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 = getRootLayout();
43
+ const finish = () => {
44
+ entry.root.unmount?.();
45
+ if (active === entry) active = null;
46
+ showNext();
47
+ };
48
+ if (rootLayout?.hasChild?.(entry.host)) rootLayout.close(entry.host).then(finish, (error) => {
49
+ console.error("[Toast] close failed", error);
50
+ finish();
51
+ });
52
+ else finish();
53
+ }
54
+ function showNext() {
55
+ if (active || queue.length === 0) return;
56
+ const entry = queue.shift();
57
+ const rootLayout = getRootLayout();
58
+ if (!rootLayout) {
59
+ console.warn("[Toast] RootLayout is not mounted; toast was skipped");
60
+ return;
61
+ }
62
+ const host = new GridLayout();
63
+ host.className = cx("vx-toast-host", getColorScheme() === "dark" && "ns-dark");
64
+ host.horizontalAlignment = "stretch";
65
+ host.verticalAlignment = entry.options.position === "top" ? "top" : "bottom";
66
+ host.marginTop = entry.options.position === "top" ? 24 : 0;
67
+ host.marginBottom = entry.options.position === "top" ? 0 : 24;
68
+ Object.assign(host, isIOS ? entry.options.ios : isAndroid ? entry.options.android : void 0);
69
+ const root = createNativeScriptRoot(host);
70
+ const current = {
71
+ ...entry,
72
+ host,
73
+ root,
74
+ timer: null
75
+ };
76
+ active = current;
77
+ root.render(ToastBody, { content: entry.content });
78
+ const open = () => {
79
+ rootLayout.open(host).then(() => {
80
+ if (active === current) current.timer = setTimeout(() => finishToast(current), Math.max(0, entry.options.duration ?? 3e3));
81
+ }, (error) => {
82
+ console.error("[Toast] open failed", error);
83
+ root.unmount?.();
84
+ if (active === current) active = null;
85
+ showNext();
86
+ });
87
+ };
88
+ if (rootLayout.hasChild?.(host)) rootLayout.close(host).then(open, (error) => {
89
+ console.error("[Toast] stale host close failed", error);
90
+ if (active === current) active = null;
91
+ showNext();
92
+ });
93
+ else open();
94
+ }
95
+ function showToast(content, options = {}) {
96
+ queue.push({
97
+ content,
98
+ options
99
+ });
100
+ showNext();
101
+ }
102
+ //#endregion
103
+ export { showToast };
@@ -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,27 @@
1
+ import { cx } from "./ui2.js";
2
+ import { applyEscapeProps } from "./ui3.js";
3
+ import { defineUniversalComponent, universalPlan, universalValue } from "@nativescript-community/octane";
4
+ //#region src/Screen.native.tsrx
5
+ var __octaneUniversalPlan0 = universalPlan("nativescript", {
6
+ "kind": "host",
7
+ "type": "rootlayout",
8
+ "bindings": [
9
+ ["ref", 0],
10
+ ["className", 1],
11
+ ["style", 2]
12
+ ],
13
+ "children": [{
14
+ "kind": "slot",
15
+ "slot": 3
16
+ }]
17
+ });
18
+ var Screen = defineUniversalComponent("nativescript", function Screen(props) {
19
+ return universalValue(__octaneUniversalPlan0, [
20
+ (v) => applyEscapeProps(v, props),
21
+ cx(props.className),
22
+ props.style,
23
+ props.children
24
+ ]);
25
+ }, { "module": "@nativescript-community/octane" });
26
+ //#endregion
27
+ export { Screen };
@@ -0,0 +1,35 @@
1
+ import { Application, Frame } from "@nativescript/core";
2
+ //#region src/stacks.native.ts
3
+ /** Named parallel stacks. A shell (Tabs with `stack` on a spec, the app
4
+ * entry's root frame) registers its Frame here; `pushRoute` resolves the
5
+ * target by name. Native-only concept — on web, parallel stacks map to
6
+ * nested routes (one linear URL stack). 'root' needs no registration:
7
+ * unregistered, it resolves to the app's root view when that's a
8
+ * Frame — the standard `Application.run({ create: () => frame })` boot
9
+ * shape. An explicit registerStack('root', frame) overrides it. */
10
+ var stacks = /* @__PURE__ */ new Map();
11
+ var regListeners = /* @__PURE__ */ new Set();
12
+ function registerStack(name, frame) {
13
+ stacks.set(name, frame);
14
+ regListeners.forEach((l) => l(name, frame));
15
+ }
16
+ function getStack(name) {
17
+ const registered = stacks.get(name);
18
+ if (registered) return registered;
19
+ if (name === "root") {
20
+ const rv = Application.getRootView?.();
21
+ if (rv instanceof Frame) return rv;
22
+ }
23
+ }
24
+ /** All registered stacks in registration order — for hardware-back
25
+ * resolution (pop whichever stack is visibly on top). */
26
+ function stackEntries() {
27
+ return stacks.entries();
28
+ }
29
+ /** Internal: route.native attaches frame listeners as stacks appear —
30
+ * named frames can register after a useRoute subscription ran. */
31
+ function onStackRegistered(cb) {
32
+ regListeners.add(cb);
33
+ }
34
+ //#endregion
35
+ export { getStack, onStackRegistered, registerStack, stackEntries };
@@ -0,0 +1,146 @@
1
+ import { cx } from "./ui2.js";
2
+ import { registerStack } from "./ui27.js";
3
+ import { createNativeScriptRoot, defineUniversalComponent, markWarm, memo, universalComponent, universalPlan, universalProps, universalValue, useBatch, warmChild } from "@nativescript-community/octane";
4
+ import { Frame, GridLayout, Page, TabViewItem } from "@nativescript/core";
5
+ //#region src/Tabs.native.tsrx
6
+ var __octaneUniversalPlan0 = universalPlan("nativescript", {
7
+ "kind": "range",
8
+ "children": [{
9
+ "kind": "slot",
10
+ "slot": 0
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;
65
+ }
66
+ function mountPanes(e) {
67
+ const tv = e.object;
68
+ for (const item of tv.items) {
69
+ const cv = item.view;
70
+ if (!(cv instanceof GridLayout) || paneRoots.has(cv)) continue;
71
+ const render = tabsByView.get(cv);
72
+ if (!render) continue;
73
+ const root = createNativeScriptRoot(cv);
74
+ paneRoots.set(cv, root);
75
+ root.render(TabPane, { render });
76
+ }
77
+ console.log("[probe] tabs mounted panes=" + tv.items.length);
78
+ }
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
+ //#endregion
146
+ export { Tabs };
@@ -0,0 +1,28 @@
1
+ import { cx } from "./ui2.js";
2
+ import { applyEscapeProps } from "./ui3.js";
3
+ import { defineUniversalComponent, universalPlan, universalValue } from "@nativescript-community/octane";
4
+ //#region src/Switch.native.tsrx
5
+ var __octaneUniversalPlan0 = universalPlan("nativescript", {
6
+ "kind": "host",
7
+ "type": "switch",
8
+ "bindings": [
9
+ ["ref", 0],
10
+ ["id", 1],
11
+ ["className", 2],
12
+ ["style", 3],
13
+ ["checked", 4],
14
+ ["onCheckedChange", 5]
15
+ ]
16
+ });
17
+ var Switch = defineUniversalComponent("nativescript", function Switch(props) {
18
+ return universalValue(__octaneUniversalPlan0, [
19
+ (v) => applyEscapeProps(v, props),
20
+ props.id,
21
+ cx(props.className),
22
+ props.style,
23
+ props.checked,
24
+ (e) => props.onCheckedChange?.(e.value)
25
+ ]);
26
+ }, { "module": "@nativescript-community/octane" });
27
+ //#endregion
28
+ export { Switch };
@@ -1,21 +1,18 @@
1
- import { defineUniversalComponent, universalPlan, universalValue } from "@nativescript-community/octane";
2
- //#region src/Row.native.tsrx
3
- var __octaneUniversalPlan0 = universalPlan("nativescript", {
4
- "kind": "host",
5
- "type": "flexboxlayout",
6
- "props": { "flexDirection": "row" },
7
- "bindings": [["className", 0], ["style", 1]],
8
- "children": [{
9
- "kind": "slot",
10
- "slot": 2
11
- }]
12
- });
13
- var Row = defineUniversalComponent("nativescript", function Row(props) {
14
- return universalValue(__octaneUniversalPlan0, [
15
- props.className,
16
- props.style,
17
- props.children
18
- ]);
19
- }, { "module": "@nativescript-community/octane" });
1
+ import { isAndroid, isIOS } from "@nativescript/core";
2
+ //#region src/escape-props.native.ts
3
+ /** Apply only the active device's escape bag after the primitive's own props. */
4
+ function applyEscapeProps(view, props) {
5
+ if (!view) return;
6
+ const bag = isIOS ? props.ios : isAndroid ? props.android : void 0;
7
+ if (bag) Object.assign(view, bag);
8
+ }
9
+ /** NativeScript's AccessibilityState is a single enum value, unlike the
10
+ * web's independent ARIA booleans. Priority follows the strongest state. */
11
+ function nativeAccessibilityState(state) {
12
+ if (state?.disabled) return "disabled";
13
+ if (state?.selected) return "selected";
14
+ if (state?.checked === true) return "checked";
15
+ if (state?.checked === false) return "unchecked";
16
+ }
20
17
  //#endregion
21
- export { Row };
18
+ export { applyEscapeProps, nativeAccessibilityState };