@octane-xplat/ui 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -0
- package/dist/native/octane-client-build.json +1 -1
- package/dist/native/ui.js +55 -40
- package/dist/native/ui10.js +20 -11
- package/dist/native/ui11.js +42 -109
- package/dist/native/ui12.js +17 -84
- package/dist/native/ui13.js +11 -41
- package/dist/native/ui14.js +133 -76
- package/dist/native/ui15.js +43 -92
- package/dist/native/ui16.js +106 -45
- package/dist/native/ui17.js +29 -42
- package/dist/native/ui18.js +34 -53
- package/dist/native/ui19.js +246 -32
- package/dist/native/ui20.js +27 -16
- package/dist/native/ui21.js +376 -86
- package/dist/native/ui22.js +26 -114
- package/dist/native/ui23.js +49 -97
- package/dist/native/ui24.js +79 -53
- package/dist/native/ui25.js +138 -16
- package/dist/native/ui26.js +8 -23
- package/dist/native/ui27.js +60 -34
- package/dist/native/ui28.js +36 -142
- package/dist/native/ui29.js +101 -21
- package/dist/native/ui3.js +22 -1
- package/dist/native/ui30.js +14 -31
- package/dist/native/ui31.js +55 -36
- package/dist/native/ui32.js +49 -61
- package/dist/native/ui33.js +36 -28
- package/dist/native/ui34.js +51 -8
- package/dist/native/ui35.js +98 -20
- package/dist/native/ui36.js +9 -33
- package/dist/native/ui37.js +42 -15
- package/dist/native/ui38.js +186 -57
- package/dist/native/ui39.js +96 -26
- package/dist/native/ui4.js +22 -20
- package/dist/native/ui40.js +179 -8
- package/dist/native/ui41.js +52 -98
- package/dist/native/ui42.js +14 -145
- package/dist/native/ui43.js +16 -19
- package/dist/native/ui44.js +6 -6
- package/dist/native/ui45.js +38 -0
- package/dist/native/ui46.js +267 -0
- package/dist/native/ui47.js +28 -0
- package/dist/native/ui48.js +35 -0
- package/dist/native/ui49.js +41 -0
- package/dist/native/ui5.js +37 -77
- package/dist/native/ui50.js +72 -0
- package/dist/native/ui51.js +66 -0
- package/dist/native/ui52.js +64 -0
- package/dist/native/ui53.js +27 -0
- package/dist/native/ui54.js +13 -0
- package/dist/native/ui55.js +92 -0
- package/dist/native/ui56.js +34 -0
- package/dist/native/ui57.js +19 -0
- package/dist/native/ui58.js +156 -0
- package/dist/native/ui59.js +33 -0
- package/dist/native/ui6.js +94 -9
- package/dist/native/ui60.js +14 -0
- package/dist/native/ui61.js +22 -0
- package/dist/native/ui62.js +8 -0
- package/dist/native/ui63.js +108 -0
- package/dist/native/ui64.js +76 -0
- package/dist/native/ui7.js +42 -26
- package/dist/native/ui8.js +22 -12
- package/dist/native/ui9.js +18 -9
- package/dist/web/octane-client-build.json +1 -1
- package/dist/web/ui.js +53 -40
- package/dist/web/ui10.js +33 -186
- package/dist/web/ui11.js +28 -409
- package/dist/web/ui12.js +21 -68
- package/dist/web/ui13.js +265 -96
- package/dist/web/ui14.js +85 -95
- package/dist/web/ui15.js +368 -25
- package/dist/web/ui16.js +13 -101
- package/dist/web/ui17.js +246 -42
- package/dist/web/ui18.js +237 -28
- package/dist/web/ui19.js +36 -10
- package/dist/web/ui20.js +73 -102
- package/dist/web/ui21.js +102 -73
- package/dist/web/ui22.js +95 -55
- package/dist/web/ui23.js +94 -55
- package/dist/web/ui24.js +31 -15
- package/dist/web/ui25.js +105 -19
- package/dist/web/ui26.js +29 -23
- package/dist/web/ui27.js +12 -123
- package/dist/web/ui28.js +9 -110
- package/dist/web/ui29.js +52 -102
- package/dist/web/ui3.js +29 -18
- package/dist/web/ui30.js +32 -41
- package/dist/web/ui31.js +120 -39
- package/dist/web/ui32.js +41 -74
- package/dist/web/ui33.js +148 -32
- package/dist/web/ui34.js +145 -62
- package/dist/web/ui35.js +140 -7
- package/dist/web/ui36.js +86 -41
- package/dist/web/ui37.js +19 -44
- package/dist/web/ui38.js +5 -15
- package/dist/web/ui39.js +24 -86
- package/dist/web/ui4.js +46 -152
- package/dist/web/ui40.js +150 -37
- package/dist/web/ui41.js +36 -10
- package/dist/web/ui42.js +40 -7
- package/dist/web/ui43.js +73 -19
- package/dist/web/ui44.js +40 -6
- package/dist/web/ui45.js +62 -0
- package/dist/web/ui46.js +50 -0
- package/dist/web/ui47.js +9 -0
- package/dist/web/ui48.js +45 -0
- package/dist/web/ui49.js +13 -0
- package/dist/web/ui5.js +131 -27
- package/dist/web/ui50.js +63 -0
- package/dist/web/ui51.js +47 -0
- package/dist/web/ui52.js +19 -0
- package/dist/web/ui53.js +273 -0
- package/dist/web/ui54.js +42 -0
- package/dist/web/ui55.js +17 -0
- package/dist/web/ui56.js +9 -0
- package/dist/web/ui57.js +22 -0
- package/dist/web/ui58.js +8 -0
- package/dist/web/ui59.js +44 -0
- package/dist/web/ui6.js +81 -45
- package/dist/web/ui60.js +46 -0
- package/dist/web/ui7.js +43 -21
- package/dist/web/ui8.js +27 -21
- package/dist/web/ui9.js +29 -18
- package/package.json +17 -4
- package/src/theme/tokens.css +597 -141
- package/types/index.d.ts +112 -58
- package/types/props.d.ts +291 -16
package/dist/native/ui5.js
CHANGED
|
@@ -1,78 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
props.id
|
|
38
|
-
],
|
|
39
|
-
["spread", layoutChildProps(props)],
|
|
40
|
-
[
|
|
41
|
-
"set",
|
|
42
|
-
"ref",
|
|
43
|
-
(v) => {
|
|
44
|
-
if (v) {
|
|
45
|
-
applyEscapeProps(v, props);
|
|
46
|
-
props.bind?.(v);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
],
|
|
50
|
-
[
|
|
51
|
-
"set",
|
|
52
|
-
"flexDirection",
|
|
53
|
-
"column"
|
|
54
|
-
],
|
|
55
|
-
[
|
|
56
|
-
"set",
|
|
57
|
-
"className",
|
|
58
|
-
cx(props.className)
|
|
59
|
-
],
|
|
60
|
-
[
|
|
61
|
-
"set",
|
|
62
|
-
"style",
|
|
63
|
-
props.style
|
|
64
|
-
],
|
|
65
|
-
[
|
|
66
|
-
"set",
|
|
67
|
-
"onPan",
|
|
68
|
-
props.onPan ? onPan : void 0
|
|
69
|
-
],
|
|
70
|
-
[
|
|
71
|
-
"set",
|
|
72
|
-
"onSwipe",
|
|
73
|
-
props.onSwipe
|
|
74
|
-
]
|
|
75
|
-
]), props.children]);
|
|
76
|
-
}, { "module": "@nativescript-community/octane" });
|
|
1
|
+
//#region src/layout-child.native.ts
|
|
2
|
+
var FLEX_JUSTIFY = {
|
|
3
|
+
start: "flex-start",
|
|
4
|
+
end: "flex-end"
|
|
5
|
+
};
|
|
6
|
+
var FLEX_ALIGN = {
|
|
7
|
+
start: "flex-start",
|
|
8
|
+
end: "flex-end"
|
|
9
|
+
};
|
|
10
|
+
/** NativeScript reads these attributes from each child view during parent
|
|
11
|
+
* layout. Values are forwarded with NativeScript's own property names.
|
|
12
|
+
* The flex-container props (justifyContent/alignItems/flexWrap/gap) land on
|
|
13
|
+
* the host flexboxlayout itself — its own attributes, not child metadata. */
|
|
14
|
+
function layoutChildProps(props) {
|
|
15
|
+
const result = {};
|
|
16
|
+
for (const key of [
|
|
17
|
+
"row",
|
|
18
|
+
"col",
|
|
19
|
+
"rowSpan",
|
|
20
|
+
"colSpan",
|
|
21
|
+
"dock",
|
|
22
|
+
"left",
|
|
23
|
+
"top",
|
|
24
|
+
"flexGrow",
|
|
25
|
+
"flexShrink",
|
|
26
|
+
"alignSelf",
|
|
27
|
+
"order"
|
|
28
|
+
]) if (props[key] !== void 0) result[key] = props[key];
|
|
29
|
+
if (props.justifyContent !== void 0) result.justifyContent = FLEX_JUSTIFY[props.justifyContent] ?? props.justifyContent;
|
|
30
|
+
if (props.alignItems !== void 0) result.alignItems = FLEX_ALIGN[props.alignItems] ?? props.alignItems;
|
|
31
|
+
if (props.flexWrap !== void 0) result.flexWrap = props.flexWrap === true ? "wrap" : props.flexWrap === false ? "nowrap" : props.flexWrap;
|
|
32
|
+
if (props.gap !== void 0) result.gap = props.gap;
|
|
33
|
+
if (props.rowGap !== void 0) result.rowGap = props.rowGap;
|
|
34
|
+
if (props.columnGap !== void 0) result.columnGap = props.columnGap;
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
77
37
|
//#endregion
|
|
78
|
-
export {
|
|
38
|
+
export { layoutChildProps };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { cx } from "./ui2.js";
|
|
2
|
+
import { defineUniversalComponent, hookSlots, universalPlan, universalValue, useEffect, useState, withSlot } from "@nativescript-community/octane";
|
|
3
|
+
import { Application } from "@nativescript/core";
|
|
4
|
+
//#region src/KeyboardAvoiding.native.tsrx
|
|
5
|
+
var _hs$ = /* @__PURE__ */ hookSlots(5);
|
|
6
|
+
var _h$0 = /* @__PURE__ */ Symbol(_hs$);
|
|
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
|
+
var __octaneUniversalPlan0 = universalPlan("nativescript", {
|
|
12
|
+
"kind": "host",
|
|
13
|
+
"type": "scrollview",
|
|
14
|
+
"bindings": [
|
|
15
|
+
["id", 0],
|
|
16
|
+
["className", 1],
|
|
17
|
+
["style", 2],
|
|
18
|
+
["ref", 3]
|
|
19
|
+
],
|
|
20
|
+
"children": [{
|
|
21
|
+
"kind": "host",
|
|
22
|
+
"type": "flexboxlayout",
|
|
23
|
+
"props": { "flexDirection": "column" },
|
|
24
|
+
"bindings": [["style", 4]],
|
|
25
|
+
"children": [{
|
|
26
|
+
"kind": "slot",
|
|
27
|
+
"slot": 5
|
|
28
|
+
}]
|
|
29
|
+
}]
|
|
30
|
+
});
|
|
31
|
+
function useKeyboardInset() {
|
|
32
|
+
const [inset, setInset] = useState(0, _h$0);
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
if (!Application.ios) return;
|
|
35
|
+
const center = NSNotificationCenter.defaultCenter;
|
|
36
|
+
const token = center.addObserverForNameObjectQueueUsingBlock(UIKeyboardWillChangeFrameNotification, null, NSOperationQueue.mainQueue, (note) => {
|
|
37
|
+
const frame = note.userInfo.objectForKey(UIKeyboardFrameEndUserInfoKey);
|
|
38
|
+
const screenHeight = UIScreen.mainScreen.bounds.size.height;
|
|
39
|
+
setInset(Math.max(0, screenHeight - frame.origin.y));
|
|
40
|
+
});
|
|
41
|
+
return () => center.removeObserver(token);
|
|
42
|
+
}, [], _h$1);
|
|
43
|
+
return inset;
|
|
44
|
+
}
|
|
45
|
+
function useAndroidResize() {
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
const nativeWindow = Application.android?.foregroundActivity?.window;
|
|
48
|
+
if (!nativeWindow) return;
|
|
49
|
+
const params = android.view.WindowManager.LayoutParams;
|
|
50
|
+
const previous = nativeWindow.attributes.softInputMode;
|
|
51
|
+
const adjusted = previous & ~params.SOFT_INPUT_MASK_ADJUST | params.SOFT_INPUT_ADJUST_RESIZE;
|
|
52
|
+
nativeWindow.setSoftInputMode(adjusted);
|
|
53
|
+
return () => nativeWindow.setSoftInputMode(previous);
|
|
54
|
+
}, [], _h$2);
|
|
55
|
+
}
|
|
56
|
+
var KeyboardAvoiding = defineUniversalComponent("nativescript", function KeyboardAvoiding(props) {
|
|
57
|
+
const keyboardInset = withSlot(_h$3, useKeyboardInset);
|
|
58
|
+
withSlot(_h$4, useAndroidResize);
|
|
59
|
+
const platformProps = Application.ios != null ? props.ios : props.android;
|
|
60
|
+
return universalValue(__octaneUniversalPlan0, [
|
|
61
|
+
props.id,
|
|
62
|
+
cx("vx-keyboard-avoiding", props.className),
|
|
63
|
+
props.style,
|
|
64
|
+
(host) => {
|
|
65
|
+
if (host && platformProps) Object.assign(host, platformProps);
|
|
66
|
+
},
|
|
67
|
+
keyboardInset ? { paddingBottom: keyboardInset } : void 0,
|
|
68
|
+
props.children
|
|
69
|
+
]);
|
|
70
|
+
}, { "module": "@nativescript-community/octane" });
|
|
71
|
+
//#endregion
|
|
72
|
+
export { KeyboardAvoiding };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { cx } from "./ui2.js";
|
|
2
|
+
import { defineUniversalComponent, hookSlots, registerElement, universalIf, universalPlan, universalValue, useEffect, useRef } from "@nativescript-community/octane";
|
|
3
|
+
import { Application } from "@nativescript/core";
|
|
4
|
+
import { Drawer, install } from "@nativescript-community/ui-drawer";
|
|
5
|
+
//#region src/Drawer.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": "gridlayout",
|
|
12
|
+
"props": { "hostSlot": "leftDrawer" },
|
|
13
|
+
"children": [{
|
|
14
|
+
"kind": "slot",
|
|
15
|
+
"slot": 0
|
|
16
|
+
}]
|
|
17
|
+
});
|
|
18
|
+
var __octaneUniversalPlan1 = universalPlan("nativescript", {
|
|
19
|
+
"kind": "host",
|
|
20
|
+
"type": "drawer",
|
|
21
|
+
"bindings": [
|
|
22
|
+
["id", 0],
|
|
23
|
+
["ref", 1],
|
|
24
|
+
["className", 2],
|
|
25
|
+
["style", 3]
|
|
26
|
+
],
|
|
27
|
+
"children": [{
|
|
28
|
+
"kind": "host",
|
|
29
|
+
"type": "gridlayout",
|
|
30
|
+
"props": { "hostSlot": "mainContent" },
|
|
31
|
+
"children": [{
|
|
32
|
+
"kind": "slot",
|
|
33
|
+
"slot": 4
|
|
34
|
+
}]
|
|
35
|
+
}, {
|
|
36
|
+
"kind": "slot",
|
|
37
|
+
"slot": 5
|
|
38
|
+
}]
|
|
39
|
+
});
|
|
40
|
+
install();
|
|
41
|
+
registerElement("drawer", Drawer);
|
|
42
|
+
var Drawer$1 = defineUniversalComponent("nativescript", function Drawer(props) {
|
|
43
|
+
const host = useRef(null, _h$0);
|
|
44
|
+
const platformProps = Application.ios != null ? props.ios : props.android;
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
const d = host.current;
|
|
47
|
+
if (!d) return;
|
|
48
|
+
if (props.open && !d.isOpened("left")) d.open("left").catch(() => {});
|
|
49
|
+
else if (!props.open && d.isOpened("left")) d.close("left").catch(() => {});
|
|
50
|
+
}, [props.open], _h$1);
|
|
51
|
+
return universalValue(__octaneUniversalPlan1, [
|
|
52
|
+
props.id,
|
|
53
|
+
(d) => {
|
|
54
|
+
host.current = d;
|
|
55
|
+
if (d && platformProps) Object.assign(d, platformProps);
|
|
56
|
+
},
|
|
57
|
+
cx("vx-drawer", props.className),
|
|
58
|
+
props.style,
|
|
59
|
+
props.main,
|
|
60
|
+
universalIf(props.drawer != null, () => {
|
|
61
|
+
return universalValue(__octaneUniversalPlan0, [props.drawer]);
|
|
62
|
+
})
|
|
63
|
+
]);
|
|
64
|
+
}, { "module": "@nativescript-community/octane" });
|
|
65
|
+
//#endregion
|
|
66
|
+
export { Drawer$1 as Drawer };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { hookSlots, useCallback, useEffect, useState } from "@nativescript-community/octane";
|
|
2
|
+
//#region src/useMeasure.native.tsrx
|
|
3
|
+
var _hs$ = /* @__PURE__ */ hookSlots(4);
|
|
4
|
+
var _h$0 = /* @__PURE__ */ Symbol(_hs$);
|
|
5
|
+
var _h$1 = /* @__PURE__ */ Symbol(_hs$ + 1);
|
|
6
|
+
var _h$2 = /* @__PURE__ */ Symbol(_hs$ + 2);
|
|
7
|
+
var _h$3 = /* @__PURE__ */ Symbol(_hs$ + 3);
|
|
8
|
+
function readBounds(view) {
|
|
9
|
+
const point = view?.getLocationOnScreen?.();
|
|
10
|
+
const size = view?.getActualSize?.();
|
|
11
|
+
if (!point || !size) return null;
|
|
12
|
+
return {
|
|
13
|
+
x: point.x,
|
|
14
|
+
y: point.y,
|
|
15
|
+
width: size.width,
|
|
16
|
+
height: size.height
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
function useMeasure(options = {}) {
|
|
20
|
+
const [view, setView] = useState(null, _h$0);
|
|
21
|
+
const [bounds, setBounds] = useState(null, _h$1);
|
|
22
|
+
const observe = options.observe ?? true;
|
|
23
|
+
const bind = useCallback((next) => {
|
|
24
|
+
setView((current) => current === next ? current : next);
|
|
25
|
+
}, [], _h$2);
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
if (!view) {
|
|
28
|
+
setBounds(null);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const update = () => {
|
|
32
|
+
const next = readBounds(view);
|
|
33
|
+
if (next) setBounds(next);
|
|
34
|
+
};
|
|
35
|
+
const onLoaded = update;
|
|
36
|
+
view.on?.("loaded", onLoaded);
|
|
37
|
+
update();
|
|
38
|
+
if (observe) {
|
|
39
|
+
view.on?.("layoutChanged", update);
|
|
40
|
+
let parent = view.parent;
|
|
41
|
+
while (parent) {
|
|
42
|
+
parent.on?.("scroll", update);
|
|
43
|
+
parent = parent.parent;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return () => {
|
|
47
|
+
view.off?.("loaded", onLoaded);
|
|
48
|
+
if (observe) {
|
|
49
|
+
view.off?.("layoutChanged", update);
|
|
50
|
+
let parent = view.parent;
|
|
51
|
+
while (parent) {
|
|
52
|
+
parent.off?.("scroll", update);
|
|
53
|
+
parent = parent.parent;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
}, [view, observe], _h$3);
|
|
58
|
+
return {
|
|
59
|
+
bind,
|
|
60
|
+
bounds
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
//#endregion
|
|
64
|
+
export { useMeasure };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { cx } from "./ui2.js";
|
|
2
|
+
import { applyNativeProps } from "./ui36.js";
|
|
3
|
+
import { defineUniversalComponent, universalPlan, universalValue } from "@nativescript-community/octane";
|
|
4
|
+
//#region src/ActivityIndicator.native.tsrx
|
|
5
|
+
var __octaneUniversalPlan0 = universalPlan("nativescript", {
|
|
6
|
+
"kind": "host",
|
|
7
|
+
"type": "activityindicator",
|
|
8
|
+
"bindings": [
|
|
9
|
+
["id", 0],
|
|
10
|
+
["className", 1],
|
|
11
|
+
["style", 2],
|
|
12
|
+
["busy", 3],
|
|
13
|
+
["ref", 4]
|
|
14
|
+
]
|
|
15
|
+
});
|
|
16
|
+
var ActivityIndicator = defineUniversalComponent("nativescript", function ActivityIndicator(props) {
|
|
17
|
+
if (props.busy === false) return null;
|
|
18
|
+
return universalValue(__octaneUniversalPlan0, [
|
|
19
|
+
props.id,
|
|
20
|
+
cx(props.className),
|
|
21
|
+
props.style,
|
|
22
|
+
props.busy ?? true,
|
|
23
|
+
(el) => applyNativeProps(el, props)
|
|
24
|
+
]);
|
|
25
|
+
}, { "module": "@nativescript-community/octane" });
|
|
26
|
+
//#endregion
|
|
27
|
+
export { ActivityIndicator };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region src/meter-math.ts
|
|
2
|
+
/** Clamp a progress value to its declared range for drawing and accessibility. */
|
|
3
|
+
function meterRange(value, max) {
|
|
4
|
+
const safeMax = Number.isFinite(max) && max > 0 ? max : 100;
|
|
5
|
+
const safeValue = Number.isFinite(value) ? Math.min(safeMax, Math.max(0, value)) : 0;
|
|
6
|
+
return {
|
|
7
|
+
max: safeMax,
|
|
8
|
+
value: safeValue,
|
|
9
|
+
ratio: safeValue / safeMax
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
export { meterRange };
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { cx } from "./ui2.js";
|
|
2
|
+
import { meterRange } from "./ui54.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,19 @@
|
|
|
1
|
+
//#region src/icons.ts
|
|
2
|
+
/**
|
|
3
|
+
* App-owned icon registry. `svg` is SVG path `d` data (not a full SVG
|
|
4
|
+
* markup string). `src` can carry an image or an SVG source; the leaves only
|
|
5
|
+
* infer SVG from inline markup, SVG data URIs, and `.svg` paths/URLs. Native
|
|
6
|
+
* `font` glyphs render only when the app ships and registers that font.
|
|
7
|
+
*/
|
|
8
|
+
var icons = /* @__PURE__ */ new Map();
|
|
9
|
+
function registerIcon(name, glyph) {
|
|
10
|
+
icons.set(name, glyph);
|
|
11
|
+
}
|
|
12
|
+
function registerIcons(record) {
|
|
13
|
+
for (const [name, glyph] of Object.entries(record)) icons.set(name, glyph);
|
|
14
|
+
}
|
|
15
|
+
function getIcon(name) {
|
|
16
|
+
return icons.get(name);
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
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 "./ui57.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 };
|