@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
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { cx } from "./ui2.js";
|
|
2
|
+
import { meterRange } from "./ui51.js";
|
|
3
|
+
import { defineUniversalComponent, hookSlots, registerElement, universalPlan, universalValue, useEffect, useRef } from "@nativescript-community/octane";
|
|
4
|
+
import { AccessibilityRole } from "@nativescript/core";
|
|
5
|
+
import { CanvasView, Cap, Paint, Style } from "@nativescript-community/ui-canvas";
|
|
6
|
+
//#region src/Meter.native.tsrx
|
|
7
|
+
var _hs$ = /* @__PURE__ */ hookSlots(2);
|
|
8
|
+
var _h$0 = /* @__PURE__ */ Symbol(_hs$);
|
|
9
|
+
var _h$1 = /* @__PURE__ */ Symbol(_hs$ + 1);
|
|
10
|
+
var __octaneUniversalPlan0 = universalPlan("nativescript", {
|
|
11
|
+
"kind": "host",
|
|
12
|
+
"type": "canvasview",
|
|
13
|
+
"props": { "accessible": true },
|
|
14
|
+
"bindings": [
|
|
15
|
+
["id", 0],
|
|
16
|
+
["ref", 1],
|
|
17
|
+
["className", 2],
|
|
18
|
+
["style", 3],
|
|
19
|
+
["onDraw", 4],
|
|
20
|
+
["accessibilityRole", 5],
|
|
21
|
+
["accessibilityLabel", 6],
|
|
22
|
+
["accessibilityValue", 7]
|
|
23
|
+
],
|
|
24
|
+
"children": [{
|
|
25
|
+
"kind": "host",
|
|
26
|
+
"type": "gridlayout",
|
|
27
|
+
"props": {
|
|
28
|
+
"horizontalAlignment": "center",
|
|
29
|
+
"verticalAlignment": "middle"
|
|
30
|
+
},
|
|
31
|
+
"children": [{
|
|
32
|
+
"kind": "slot",
|
|
33
|
+
"slot": 8
|
|
34
|
+
}]
|
|
35
|
+
}]
|
|
36
|
+
});
|
|
37
|
+
registerElement("canvasview", CanvasView);
|
|
38
|
+
var Meter = defineUniversalComponent("nativescript", function Meter(props) {
|
|
39
|
+
const max = props.max ?? 100;
|
|
40
|
+
const { max: rangeMax, value, ratio } = meterRange(props.value, max);
|
|
41
|
+
const size = props.size ?? 24;
|
|
42
|
+
const strokeWidth = Math.max(0, Math.min(props.strokeWidth ?? 3, size));
|
|
43
|
+
const color = props.color ?? "#3376cc";
|
|
44
|
+
const trackColor = props.trackColor ?? "#e1ecf7";
|
|
45
|
+
const canvasRef = useRef(null, _h$0);
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
canvasRef.current?.invalidate();
|
|
48
|
+
}, [
|
|
49
|
+
value,
|
|
50
|
+
rangeMax,
|
|
51
|
+
strokeWidth,
|
|
52
|
+
color,
|
|
53
|
+
trackColor
|
|
54
|
+
], _h$1);
|
|
55
|
+
const draw = (event) => {
|
|
56
|
+
const canvas = event.canvas;
|
|
57
|
+
const width = canvas.getWidth();
|
|
58
|
+
const height = canvas.getHeight();
|
|
59
|
+
const diameter = Math.max(0, Math.min(width, height) - strokeWidth);
|
|
60
|
+
const left = (width - diameter) / 2;
|
|
61
|
+
const top = (height - diameter) / 2;
|
|
62
|
+
const right = left + diameter;
|
|
63
|
+
const bottom = top + diameter;
|
|
64
|
+
const paint = new Paint();
|
|
65
|
+
paint.style = Style.STROKE;
|
|
66
|
+
paint.strokeCap = Cap.ROUND;
|
|
67
|
+
paint.strokeWidth = strokeWidth;
|
|
68
|
+
paint.setColor(trackColor);
|
|
69
|
+
canvas.drawArc(left, top, right, bottom, -90, 360, false, paint);
|
|
70
|
+
if (ratio > 0) {
|
|
71
|
+
paint.setColor(color);
|
|
72
|
+
canvas.drawArc(left, top, right, bottom, -90, ratio * 360, false, paint);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
return universalValue(__octaneUniversalPlan0, [
|
|
76
|
+
props.id,
|
|
77
|
+
canvasRef,
|
|
78
|
+
cx("vx-meter", props.className),
|
|
79
|
+
{
|
|
80
|
+
width: size,
|
|
81
|
+
height: size,
|
|
82
|
+
...props.style
|
|
83
|
+
},
|
|
84
|
+
draw,
|
|
85
|
+
AccessibilityRole.ProgressBar,
|
|
86
|
+
props.accessibilityLabel,
|
|
87
|
+
`${value} of ${rangeMax}`,
|
|
88
|
+
props.children
|
|
89
|
+
]);
|
|
90
|
+
}, { "module": "@nativescript-community/octane" });
|
|
91
|
+
//#endregion
|
|
92
|
+
export { Meter };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { cx } from "./ui2.js";
|
|
2
|
+
import { applyNativeProps } from "./ui36.js";
|
|
3
|
+
import { defineUniversalComponent, universalPlan, universalValue } from "@nativescript-community/octane";
|
|
4
|
+
//#region src/Slider.native.tsrx
|
|
5
|
+
var __octaneUniversalPlan0 = universalPlan("nativescript", {
|
|
6
|
+
"kind": "host",
|
|
7
|
+
"type": "slider",
|
|
8
|
+
"bindings": [
|
|
9
|
+
["id", 0],
|
|
10
|
+
["className", 1],
|
|
11
|
+
["style", 2],
|
|
12
|
+
["value", 3],
|
|
13
|
+
["minValue", 4],
|
|
14
|
+
["maxValue", 5],
|
|
15
|
+
["isEnabled", 6],
|
|
16
|
+
["onValueChange", 7],
|
|
17
|
+
["ref", 8]
|
|
18
|
+
]
|
|
19
|
+
});
|
|
20
|
+
var Slider = defineUniversalComponent("nativescript", function Slider(props) {
|
|
21
|
+
return universalValue(__octaneUniversalPlan0, [
|
|
22
|
+
props.id,
|
|
23
|
+
cx(props.className),
|
|
24
|
+
props.style,
|
|
25
|
+
props.value,
|
|
26
|
+
props.minValue ?? 0,
|
|
27
|
+
props.maxValue ?? 100,
|
|
28
|
+
props.disabled ? false : true,
|
|
29
|
+
(e) => props.onValueChange?.(e.value),
|
|
30
|
+
(el) => applyNativeProps(el, props)
|
|
31
|
+
]);
|
|
32
|
+
}, { "module": "@nativescript-community/octane" });
|
|
33
|
+
//#endregion
|
|
34
|
+
export { Slider };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region src/icons.ts
|
|
2
|
+
/**
|
|
3
|
+
* App-owned icon registry. `svg` is SVG path `d` data (not a full SVG
|
|
4
|
+
* markup string). Native `font` glyphs render only when the app ships that font.
|
|
5
|
+
*/
|
|
6
|
+
var icons = /* @__PURE__ */ new Map();
|
|
7
|
+
function registerIcon(name, glyph) {
|
|
8
|
+
icons.set(name, glyph);
|
|
9
|
+
}
|
|
10
|
+
function registerIcons(record) {
|
|
11
|
+
for (const [name, glyph] of Object.entries(record)) icons.set(name, glyph);
|
|
12
|
+
}
|
|
13
|
+
function getIcon(name) {
|
|
14
|
+
return icons.get(name);
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
export { getIcon, registerIcon, registerIcons };
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { cx } from "./ui2.js";
|
|
2
|
+
import { glyphSvgMarkup, isSvgSrc, svgSource } from "./ui28.js";
|
|
3
|
+
import { applyNativeProps } from "./ui36.js";
|
|
4
|
+
import { getIcon } from "./ui54.js";
|
|
5
|
+
import { defineUniversalComponent, universalIf, universalPlan, universalValue } from "@nativescript-community/octane";
|
|
6
|
+
//#region src/Icon.native.tsrx
|
|
7
|
+
var __octaneUniversalPlan0 = universalPlan("nativescript", {
|
|
8
|
+
"kind": "host",
|
|
9
|
+
"type": "svgview",
|
|
10
|
+
"props": { "stretch": "aspectFit" },
|
|
11
|
+
"bindings": [
|
|
12
|
+
["id", 0],
|
|
13
|
+
["className", 1],
|
|
14
|
+
["src", 2],
|
|
15
|
+
["style", 3],
|
|
16
|
+
["ref", 4]
|
|
17
|
+
]
|
|
18
|
+
});
|
|
19
|
+
var __octaneUniversalPlan1 = universalPlan("nativescript", {
|
|
20
|
+
"kind": "host",
|
|
21
|
+
"type": "label",
|
|
22
|
+
"bindings": [
|
|
23
|
+
["id", 0],
|
|
24
|
+
["className", 1],
|
|
25
|
+
["text", 2],
|
|
26
|
+
["style", 3],
|
|
27
|
+
["ref", 4]
|
|
28
|
+
]
|
|
29
|
+
});
|
|
30
|
+
var __octaneUniversalPlan2 = universalPlan("nativescript", {
|
|
31
|
+
"kind": "host",
|
|
32
|
+
"type": "svgview",
|
|
33
|
+
"props": { "stretch": "aspectFit" },
|
|
34
|
+
"bindings": [
|
|
35
|
+
["id", 0],
|
|
36
|
+
["className", 1],
|
|
37
|
+
["src", 2],
|
|
38
|
+
["style", 3],
|
|
39
|
+
["ref", 4]
|
|
40
|
+
]
|
|
41
|
+
});
|
|
42
|
+
var __octaneUniversalPlan3 = universalPlan("nativescript", {
|
|
43
|
+
"kind": "host",
|
|
44
|
+
"type": "image",
|
|
45
|
+
"bindings": [
|
|
46
|
+
["id", 0],
|
|
47
|
+
["className", 1],
|
|
48
|
+
["src", 2],
|
|
49
|
+
["style", 3],
|
|
50
|
+
["ref", 4]
|
|
51
|
+
]
|
|
52
|
+
});
|
|
53
|
+
var __octaneUniversalPlan4 = universalPlan("nativescript", {
|
|
54
|
+
"kind": "slot",
|
|
55
|
+
"slot": 0
|
|
56
|
+
});
|
|
57
|
+
var __octaneUniversalPlan5 = universalPlan("nativescript", {
|
|
58
|
+
"kind": "host",
|
|
59
|
+
"type": "label",
|
|
60
|
+
"bindings": [
|
|
61
|
+
["id", 0],
|
|
62
|
+
["className", 1],
|
|
63
|
+
["text", 2],
|
|
64
|
+
["style", 3],
|
|
65
|
+
["ref", 4]
|
|
66
|
+
]
|
|
67
|
+
});
|
|
68
|
+
var __octaneUniversalPlan6 = universalPlan("nativescript", {
|
|
69
|
+
"kind": "slot",
|
|
70
|
+
"slot": 0
|
|
71
|
+
});
|
|
72
|
+
var __octaneUniversalPlan7 = universalPlan("nativescript", {
|
|
73
|
+
"kind": "slot",
|
|
74
|
+
"slot": 0
|
|
75
|
+
});
|
|
76
|
+
var __octaneUniversalPlan8 = universalPlan("nativescript", {
|
|
77
|
+
"kind": "slot",
|
|
78
|
+
"slot": 0
|
|
79
|
+
});
|
|
80
|
+
var __octaneUniversalPlan9 = universalPlan("nativescript", {
|
|
81
|
+
"kind": "slot",
|
|
82
|
+
"slot": 0
|
|
83
|
+
});
|
|
84
|
+
var Icon = defineUniversalComponent("nativescript", function Icon(props) {
|
|
85
|
+
const glyph = getIcon(props.name);
|
|
86
|
+
if (!glyph) return null;
|
|
87
|
+
const size = props.size ?? 24;
|
|
88
|
+
const markup = glyphSvgMarkup(glyph, props.color);
|
|
89
|
+
return universalValue(__octaneUniversalPlan9, [universalIf(markup, () => {
|
|
90
|
+
return universalValue(__octaneUniversalPlan0, [
|
|
91
|
+
props.id,
|
|
92
|
+
cx(props.className),
|
|
93
|
+
markup,
|
|
94
|
+
{
|
|
95
|
+
width: size,
|
|
96
|
+
height: size
|
|
97
|
+
},
|
|
98
|
+
(el) => applyNativeProps(el, props)
|
|
99
|
+
]);
|
|
100
|
+
}, () => {
|
|
101
|
+
return universalValue(__octaneUniversalPlan8, [universalIf(glyph.font, () => {
|
|
102
|
+
return universalValue(__octaneUniversalPlan1, [
|
|
103
|
+
props.id,
|
|
104
|
+
cx(props.className),
|
|
105
|
+
glyph.font.glyph,
|
|
106
|
+
{
|
|
107
|
+
fontFamily: glyph.font.family,
|
|
108
|
+
fontSize: size,
|
|
109
|
+
color: props.color
|
|
110
|
+
},
|
|
111
|
+
(el) => applyNativeProps(el, props)
|
|
112
|
+
]);
|
|
113
|
+
}, () => {
|
|
114
|
+
return universalValue(__octaneUniversalPlan7, [universalIf(glyph.src, () => {
|
|
115
|
+
return universalValue(__octaneUniversalPlan4, [universalIf(isSvgSrc(glyph.src), () => {
|
|
116
|
+
return universalValue(__octaneUniversalPlan2, [
|
|
117
|
+
props.id,
|
|
118
|
+
cx(props.className),
|
|
119
|
+
svgSource(glyph.src),
|
|
120
|
+
{
|
|
121
|
+
width: size,
|
|
122
|
+
height: size
|
|
123
|
+
},
|
|
124
|
+
(el) => applyNativeProps(el, props)
|
|
125
|
+
]);
|
|
126
|
+
}, () => {
|
|
127
|
+
return universalValue(__octaneUniversalPlan3, [
|
|
128
|
+
props.id,
|
|
129
|
+
cx(props.className),
|
|
130
|
+
glyph.src,
|
|
131
|
+
{
|
|
132
|
+
width: size,
|
|
133
|
+
height: size
|
|
134
|
+
},
|
|
135
|
+
(el) => applyNativeProps(el, props)
|
|
136
|
+
]);
|
|
137
|
+
})]);
|
|
138
|
+
}, () => {
|
|
139
|
+
return universalValue(__octaneUniversalPlan6, [universalIf(glyph.text, () => {
|
|
140
|
+
return universalValue(__octaneUniversalPlan5, [
|
|
141
|
+
props.id,
|
|
142
|
+
cx(props.className),
|
|
143
|
+
glyph.text,
|
|
144
|
+
{
|
|
145
|
+
fontSize: size,
|
|
146
|
+
color: props.color
|
|
147
|
+
},
|
|
148
|
+
(el) => applyNativeProps(el, props)
|
|
149
|
+
]);
|
|
150
|
+
})]);
|
|
151
|
+
})]);
|
|
152
|
+
})]);
|
|
153
|
+
})]);
|
|
154
|
+
}, { "module": "@nativescript-community/octane" });
|
|
155
|
+
//#endregion
|
|
156
|
+
export { Icon };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { cx } from "./ui2.js";
|
|
2
|
+
import { applyNativeProps } from "./ui36.js";
|
|
3
|
+
import { defineUniversalComponent, universalPlan, universalValue } from "@nativescript-community/octane";
|
|
4
|
+
import { AccessibilityRole } from "@nativescript/core";
|
|
5
|
+
//#region src/Heading.native.tsrx
|
|
6
|
+
var __octaneUniversalPlan0 = universalPlan("nativescript", {
|
|
7
|
+
"kind": "host",
|
|
8
|
+
"type": "label",
|
|
9
|
+
"bindings": [
|
|
10
|
+
["id", 0],
|
|
11
|
+
["className", 1],
|
|
12
|
+
["style", 2],
|
|
13
|
+
["accessibilityRole", 3],
|
|
14
|
+
["ref", 4]
|
|
15
|
+
],
|
|
16
|
+
"children": [{
|
|
17
|
+
"kind": "slot",
|
|
18
|
+
"slot": 5
|
|
19
|
+
}]
|
|
20
|
+
});
|
|
21
|
+
var Heading = defineUniversalComponent("nativescript", function Heading(props) {
|
|
22
|
+
const level = props.level ?? 2;
|
|
23
|
+
return universalValue(__octaneUniversalPlan0, [
|
|
24
|
+
props.id,
|
|
25
|
+
cx(`vx-h${level}`, props.className),
|
|
26
|
+
props.style,
|
|
27
|
+
AccessibilityRole.Header,
|
|
28
|
+
(el) => applyNativeProps(el, props),
|
|
29
|
+
props.children
|
|
30
|
+
]);
|
|
31
|
+
}, { "module": "@nativescript-community/octane" });
|
|
32
|
+
//#endregion
|
|
33
|
+
export { Heading };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { cx } from "./ui2.js";
|
|
2
|
+
import { defineUniversalComponent, universalPlan, universalValue } from "@nativescript-community/octane";
|
|
3
|
+
//#region src/PlatformBadge.native.tsrx
|
|
4
|
+
var __octaneUniversalPlan0 = universalPlan("nativescript", {
|
|
5
|
+
"kind": "host",
|
|
6
|
+
"type": "label",
|
|
7
|
+
"props": { "text": "ios|android" },
|
|
8
|
+
"bindings": [["className", 0]]
|
|
9
|
+
});
|
|
10
|
+
var PlatformBadge = defineUniversalComponent("nativescript", function PlatformBadge(props) {
|
|
11
|
+
return universalValue(__octaneUniversalPlan0, [cx(props.className)]);
|
|
12
|
+
}, { "module": "@nativescript-community/octane" });
|
|
13
|
+
//#endregion
|
|
14
|
+
export { PlatformBadge };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//#region src/store.ts
|
|
2
|
+
function createStore(initial) {
|
|
3
|
+
let value = initial;
|
|
4
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
5
|
+
return {
|
|
6
|
+
get: () => value,
|
|
7
|
+
set(next) {
|
|
8
|
+
const v = typeof next === "function" ? next(value) : next;
|
|
9
|
+
if (Object.is(v, value)) return;
|
|
10
|
+
value = v;
|
|
11
|
+
for (const l of [...listeners]) l();
|
|
12
|
+
},
|
|
13
|
+
subscribe(notify) {
|
|
14
|
+
listeners.add(notify);
|
|
15
|
+
return () => {
|
|
16
|
+
listeners.delete(notify);
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
export { createStore };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { hookSlots, useSyncExternalStore } from "@nativescript-community/octane";
|
|
2
|
+
//#region src/use-store.native.tsrx
|
|
3
|
+
var _h$0 = /* @__PURE__ */ Symbol(/* @__PURE__ */ hookSlots(1));
|
|
4
|
+
function useStore(store, select) {
|
|
5
|
+
return useSyncExternalStore(store.subscribe, select === void 0 ? store.get : () => select(store.get()), _h$0);
|
|
6
|
+
}
|
|
7
|
+
//#endregion
|
|
8
|
+
export { useStore };
|
package/dist/native/ui6.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { cx } from "./ui2.js";
|
|
2
2
|
import { applyEscapeProps } from "./ui3.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
3
|
+
import { glassClassOf, glassConfigOf } from "./ui4.js";
|
|
4
|
+
import { layoutChildProps } from "./ui5.js";
|
|
5
|
+
import { defineUniversalComponent, hookSlots, universalPlan, universalProps, universalValue, useCallback } from "@nativescript-community/octane";
|
|
6
|
+
//#region src/View.native.tsrx
|
|
7
|
+
var _h$0 = /* @__PURE__ */ Symbol(/* @__PURE__ */ hookSlots(1));
|
|
6
8
|
var __octaneUniversalPlan0 = universalPlan("nativescript", {
|
|
7
9
|
"kind": "host",
|
|
8
10
|
"type": "flexboxlayout",
|
|
@@ -12,30 +14,71 @@ var __octaneUniversalPlan0 = universalPlan("nativescript", {
|
|
|
12
14
|
"slot": 1
|
|
13
15
|
}]
|
|
14
16
|
});
|
|
15
|
-
var
|
|
17
|
+
var PAN_STATE = [
|
|
18
|
+
"cancelled",
|
|
19
|
+
"began",
|
|
20
|
+
"moved",
|
|
21
|
+
"ended"
|
|
22
|
+
];
|
|
23
|
+
var View = defineUniversalComponent("nativescript", function View(props) {
|
|
24
|
+
const onPan = useCallback((e) => props.onPan?.({
|
|
25
|
+
x: e.deltaX,
|
|
26
|
+
y: e.deltaY,
|
|
27
|
+
dx: e.deltaX,
|
|
28
|
+
dy: e.deltaY,
|
|
29
|
+
vx: 0,
|
|
30
|
+
vy: 0,
|
|
31
|
+
state: PAN_STATE[e.state] ?? "moved",
|
|
32
|
+
target: e.view ?? e.object
|
|
33
|
+
}), [props.onPan], _h$0);
|
|
16
34
|
return universalValue(__octaneUniversalPlan0, [universalProps([
|
|
35
|
+
[
|
|
36
|
+
"set",
|
|
37
|
+
"id",
|
|
38
|
+
props.id
|
|
39
|
+
],
|
|
40
|
+
["spread", layoutChildProps(props)],
|
|
17
41
|
[
|
|
18
42
|
"set",
|
|
19
43
|
"ref",
|
|
20
|
-
(v) =>
|
|
44
|
+
(v) => {
|
|
45
|
+
if (v) {
|
|
46
|
+
applyEscapeProps(v, props);
|
|
47
|
+
props.bind?.(v);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
21
50
|
],
|
|
22
51
|
[
|
|
23
52
|
"set",
|
|
24
53
|
"flexDirection",
|
|
25
|
-
"
|
|
54
|
+
"column"
|
|
26
55
|
],
|
|
27
56
|
[
|
|
28
57
|
"set",
|
|
29
58
|
"className",
|
|
30
|
-
cx(props.className)
|
|
59
|
+
cx(glassClassOf(props.glass), props.className)
|
|
31
60
|
],
|
|
32
61
|
[
|
|
33
62
|
"set",
|
|
34
63
|
"style",
|
|
35
64
|
props.style
|
|
36
65
|
],
|
|
37
|
-
[
|
|
66
|
+
[
|
|
67
|
+
"set",
|
|
68
|
+
"iosGlassEffect",
|
|
69
|
+
glassConfigOf(props.glass)
|
|
70
|
+
],
|
|
71
|
+
[
|
|
72
|
+
"set",
|
|
73
|
+
"onPan",
|
|
74
|
+
props.onPan ? onPan : void 0
|
|
75
|
+
],
|
|
76
|
+
[
|
|
77
|
+
"set",
|
|
78
|
+
"onSwipe",
|
|
79
|
+
props.onSwipe
|
|
80
|
+
]
|
|
38
81
|
]), props.children]);
|
|
39
82
|
}, { "module": "@nativescript-community/octane" });
|
|
40
83
|
//#endregion
|
|
41
|
-
export {
|
|
84
|
+
export { View };
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { cx } from "./ui2.js";
|
|
2
|
+
import { applyThemeClasses } from "./ui31.js";
|
|
3
|
+
import { rootLayoutFor } from "./ui34.js";
|
|
4
|
+
import { createNativeScriptRoot, defineUniversalComponent, hookSlots, universalPlan, universalValue, useEffect, useRef } from "@nativescript-community/octane";
|
|
5
|
+
import { GridLayout, isAndroid, isIOS } from "@nativescript/core";
|
|
6
|
+
//#region src/Sheet.native.tsrx
|
|
7
|
+
var _hs$ = /* @__PURE__ */ hookSlots(3);
|
|
8
|
+
var _h$0 = /* @__PURE__ */ Symbol(_hs$);
|
|
9
|
+
var _h$1 = /* @__PURE__ */ Symbol(_hs$ + 1);
|
|
10
|
+
var _h$2 = /* @__PURE__ */ Symbol(_hs$ + 2);
|
|
11
|
+
var __octaneUniversalPlan0 = universalPlan("nativescript", {
|
|
12
|
+
"kind": "range",
|
|
13
|
+
"children": [{
|
|
14
|
+
"kind": "slot",
|
|
15
|
+
"slot": 0
|
|
16
|
+
}]
|
|
17
|
+
});
|
|
18
|
+
var __octaneUniversalPlan1 = universalPlan("nativescript", {
|
|
19
|
+
"kind": "host",
|
|
20
|
+
"type": "stacklayout",
|
|
21
|
+
"bindings": [["ref", 0], ["style", 1]]
|
|
22
|
+
});
|
|
23
|
+
var SheetBody = defineUniversalComponent("nativescript", function SheetBody(props) {
|
|
24
|
+
return universalValue(__octaneUniversalPlan0, [props.children]);
|
|
25
|
+
}, { "module": "@nativescript-community/octane" });
|
|
26
|
+
var Sheet = defineUniversalComponent("nativescript", function Sheet(props) {
|
|
27
|
+
const sentinel = useRef(null, _h$0);
|
|
28
|
+
const shown = useRef(null, _h$1);
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
const cur = shown.current;
|
|
31
|
+
if (!props.open) {
|
|
32
|
+
if (!cur) return;
|
|
33
|
+
shown.current = null;
|
|
34
|
+
cur.programmatic = true;
|
|
35
|
+
cur.unbindTheme?.();
|
|
36
|
+
cur.root.unmount?.();
|
|
37
|
+
const owner = cur.host.parent;
|
|
38
|
+
if (owner?.hasChild?.(cur.host)) owner.close(cur.host).catch((error) => {
|
|
39
|
+
console.error("[Sheet] close failed", error);
|
|
40
|
+
});
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const rl = rootLayoutFor(sentinel.current);
|
|
44
|
+
if (!rl) return;
|
|
45
|
+
if (cur) {
|
|
46
|
+
cur.root.render(SheetBody, { children: props.children });
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const host = new GridLayout();
|
|
50
|
+
const unbindTheme = applyThemeClasses(host, cx("vx-sheet-host", props.className));
|
|
51
|
+
host.horizontalAlignment = "stretch";
|
|
52
|
+
host.verticalAlignment = "bottom";
|
|
53
|
+
if (props.style) Object.assign(host.style, props.style);
|
|
54
|
+
Object.assign(host, isIOS ? props.ios : isAndroid ? props.android : void 0);
|
|
55
|
+
const root = createNativeScriptRoot(host);
|
|
56
|
+
const opened = {
|
|
57
|
+
host,
|
|
58
|
+
root,
|
|
59
|
+
unbindTheme,
|
|
60
|
+
programmatic: false
|
|
61
|
+
};
|
|
62
|
+
shown.current = opened;
|
|
63
|
+
root.render(SheetBody, { children: props.children });
|
|
64
|
+
host.on("closed", () => {
|
|
65
|
+
if (shown.current === opened) shown.current = null;
|
|
66
|
+
opened.unbindTheme?.();
|
|
67
|
+
opened.root.unmount?.();
|
|
68
|
+
if (!opened.programmatic) props.onDismiss?.();
|
|
69
|
+
});
|
|
70
|
+
rl.open(host, {
|
|
71
|
+
...props.shadeCover ?? true ? { shadeCover: {
|
|
72
|
+
opacity: .4,
|
|
73
|
+
tapToClose: true
|
|
74
|
+
} } : {},
|
|
75
|
+
animation: {
|
|
76
|
+
enterFrom: {
|
|
77
|
+
translateY: 400,
|
|
78
|
+
duration: 250
|
|
79
|
+
},
|
|
80
|
+
exitTo: {
|
|
81
|
+
translateY: 400,
|
|
82
|
+
duration: 200
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}).catch((error) => {
|
|
86
|
+
if (shown.current === opened) shown.current = null;
|
|
87
|
+
opened.unbindTheme?.();
|
|
88
|
+
opened.root.unmount?.();
|
|
89
|
+
console.error("[Sheet] open failed", error);
|
|
90
|
+
});
|
|
91
|
+
}, [
|
|
92
|
+
props.open,
|
|
93
|
+
props.children,
|
|
94
|
+
props.className,
|
|
95
|
+
props.style,
|
|
96
|
+
props.shadeCover,
|
|
97
|
+
props.ios,
|
|
98
|
+
props.android
|
|
99
|
+
], _h$2);
|
|
100
|
+
return universalValue(__octaneUniversalPlan1, [(v) => {
|
|
101
|
+
sentinel.current = v;
|
|
102
|
+
}, {
|
|
103
|
+
width: 0,
|
|
104
|
+
height: 0
|
|
105
|
+
}]);
|
|
106
|
+
}, { "module": "@nativescript-community/octane" });
|
|
107
|
+
//#endregion
|
|
108
|
+
export { Sheet };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { applyThemeClasses } from "./ui31.js";
|
|
2
|
+
import { topRootLayout } from "./ui34.js";
|
|
3
|
+
import { createNativeScriptRoot } from "@nativescript-community/octane";
|
|
4
|
+
import { GridLayout } from "@nativescript/core";
|
|
5
|
+
//#region src/sheet-service.native.ts
|
|
6
|
+
var active = /* @__PURE__ */ new Set();
|
|
7
|
+
/** The most recently opened sheet's host view — for harness asserts (view
|
|
8
|
+
* identity beats tree search; the owning rootlayout may unload/reload). */
|
|
9
|
+
function sheetHost() {
|
|
10
|
+
return [...active].pop()?.host ?? null;
|
|
11
|
+
}
|
|
12
|
+
/** Close the most recently opened sheet (resolve with `result`). */
|
|
13
|
+
function closeSheet(result) {
|
|
14
|
+
[...active].pop()?.finish(result);
|
|
15
|
+
}
|
|
16
|
+
/** Imperative in-window sheet: a dedicated Octane root on a bottom-docked
|
|
17
|
+
* GridLayout host opened on the CURRENT rootlayout (topRootLayout — the
|
|
18
|
+
* service has no declaring view). Resolves when the sheet closes. */
|
|
19
|
+
var openSheet = (Component, params, options = {}) => new Promise((resolve) => {
|
|
20
|
+
const rl = topRootLayout();
|
|
21
|
+
if (!rl) {
|
|
22
|
+
console.warn("[openSheet] no RootLayout mounted — sheet skipped");
|
|
23
|
+
resolve(void 0);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const host = new GridLayout();
|
|
27
|
+
const unbindTheme = applyThemeClasses(host, "vx-sheet-host");
|
|
28
|
+
host.horizontalAlignment = "stretch";
|
|
29
|
+
host.verticalAlignment = "bottom";
|
|
30
|
+
const root = createNativeScriptRoot(host);
|
|
31
|
+
let finished = false;
|
|
32
|
+
const finish = (result) => {
|
|
33
|
+
if (finished) return;
|
|
34
|
+
finished = true;
|
|
35
|
+
active.delete(entry);
|
|
36
|
+
unbindTheme();
|
|
37
|
+
root.unmount?.();
|
|
38
|
+
const owner = host.parent;
|
|
39
|
+
if (owner?.hasChild?.(host)) owner.close(host).catch((error) => {
|
|
40
|
+
console.error("[openSheet] close failed", error);
|
|
41
|
+
});
|
|
42
|
+
resolve(result);
|
|
43
|
+
};
|
|
44
|
+
const entry = {
|
|
45
|
+
host,
|
|
46
|
+
root,
|
|
47
|
+
finish
|
|
48
|
+
};
|
|
49
|
+
host.on("closed", () => finish());
|
|
50
|
+
root.render(Component, {
|
|
51
|
+
params,
|
|
52
|
+
close: finish
|
|
53
|
+
});
|
|
54
|
+
active.add(entry);
|
|
55
|
+
rl.open(host, {
|
|
56
|
+
...options.shadeCover ?? true ? { shadeCover: {
|
|
57
|
+
opacity: .4,
|
|
58
|
+
tapToClose: true
|
|
59
|
+
} } : {},
|
|
60
|
+
animation: {
|
|
61
|
+
enterFrom: {
|
|
62
|
+
translateY: 400,
|
|
63
|
+
duration: 250
|
|
64
|
+
},
|
|
65
|
+
exitTo: {
|
|
66
|
+
translateY: 400,
|
|
67
|
+
duration: 200
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}).catch((error) => {
|
|
71
|
+
console.error("[openSheet] open failed", error);
|
|
72
|
+
finish();
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
//#endregion
|
|
76
|
+
export { closeSheet, openSheet, sheetHost };
|