@octane-xplat/ui 0.7.2 → 0.7.3

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 (43) hide show
  1. package/dist/native/CommandPalette.tsrx.js +7 -1
  2. package/dist/native/Grid.tsrx.js +31 -2
  3. package/dist/native/Pagination.tsrx.js +15 -12
  4. package/dist/native/Popover.tsrx.js +18 -7
  5. package/dist/native/Screen.tsrx.js +1 -1
  6. package/dist/native/Sheet.tsrx.js +1 -1
  7. package/dist/native/Slider.tsrx.js +23 -14
  8. package/dist/native/Text.tsrx.js +16 -0
  9. package/dist/native/WebView.tsrx.js +17 -2
  10. package/dist/native/_virtual/_@oxc-project_runtime@0.150.0/helpers/esm/decorate.js +9 -0
  11. package/dist/native/escape-props.js +2 -0
  12. package/dist/native/grid-auto-placement.js +83 -0
  13. package/dist/native/grid-placement.js +20 -0
  14. package/dist/native/octane-client-build.json +1 -1
  15. package/dist/native/sheet-service.js +1 -1
  16. package/dist/native/{tap-to-blur.mobile.js → tap-to-blur.ios.js} +20 -32
  17. package/dist/native/useMeasure.tsrx.js +17 -18
  18. package/dist/web/octane-client-build.json +1 -1
  19. package/package.json +1 -1
  20. package/src/CommandPalette.tsrx +7 -1
  21. package/src/Grid.tsrx +30 -1
  22. package/src/Pagination.tsrx +6 -4
  23. package/src/Popover.tsrx +20 -6
  24. package/src/Screen.tsrx +1 -1
  25. package/src/Sheet.tsrx +1 -1
  26. package/src/Slider.tsrx +13 -11
  27. package/src/Text.tsrx +34 -0
  28. package/src/WebView.tsrx +19 -10
  29. package/src/escape-props.ts +11 -1
  30. package/src/grid-auto-placement.ts +121 -0
  31. package/src/grid-placement.ts +29 -0
  32. package/src/sheet-service.ts +1 -1
  33. package/src/tap-to-blur.ios.ts +90 -0
  34. package/src/tap-to-blur.mobile.ts +12 -94
  35. package/src/theme/tokens.css +24 -8
  36. package/src/useMeasure.tsrx +20 -21
  37. package/types/generated/.tsrx-typegen-manifest.json +3 -0
  38. package/types/generated/Grid.d.ts +0 -1
  39. package/types/generated/escape-props.d.ts +4 -0
  40. package/types/generated/grid-auto-placement.d.ts +13 -0
  41. package/types/generated/grid-placement.d.ts +5 -0
  42. package/types/generated/tap-to-blur.ios.d.ts +13 -0
  43. package/types/generated/tap-to-blur.mobile.d.ts +1 -15
@@ -3,6 +3,7 @@ import { Icon } from "./Icon.tsrx.js";
3
3
  import { TextInput } from "./TextInput.tsrx.js";
4
4
  import { Overlay } from "./Overlay.tsrx.js";
5
5
  import { defineUniversalComponent, hookSlots, universalChildren, universalComponent, universalFor, universalPlan, universalProps, universalValue, useState } from "@nativescript-community/octane";
6
+ import { Screen } from "@nativescript/core";
6
7
  //#region src/CommandPalette.tsrx
7
8
  var _h$0 = /* @__PURE__ */ Symbol(/* @__PURE__ */ hookSlots(1));
8
9
  var __octaneUniversalPlan0 = universalPlan("nativescript", {
@@ -31,6 +32,7 @@ var __octaneUniversalPlan3 = universalPlan("nativescript", {
31
32
  "kind": "host",
32
33
  "type": "flexboxlayout",
33
34
  "props": {
35
+ "flexDirection": "column",
34
36
  "horizontalAlignment": "center",
35
37
  "verticalAlignment": "top",
36
38
  "marginTop": 80
@@ -64,6 +66,10 @@ var CommandPalette = defineUniversalComponent("nativescript", function CommandPa
64
66
  props.onOpenChange?.(next);
65
67
  };
66
68
  const shown = query ? props.items.filter((i) => (i.label ?? i.key).toLowerCase().includes(query.toLowerCase())) : props.items;
69
+ const panelStyle = {
70
+ ...props.style,
71
+ maxWidth: props.style?.maxWidth ?? Screen.mainScreen.widthDIPs * .9
72
+ };
67
73
  const select = (item) => {
68
74
  if (item.disabled) return;
69
75
  setOpen(false);
@@ -93,7 +99,7 @@ var CommandPalette = defineUniversalComponent("nativescript", function CommandPa
93
99
  ], universalChildren("nativescript", () => {
94
100
  return universalValue(__octaneUniversalPlan3, [
95
101
  cx("vx-commandpalette", props.className),
96
- props.style,
102
+ panelStyle,
97
103
  props.id,
98
104
  universalComponent("nativescript", TextInput, universalProps([
99
105
  [
@@ -1,7 +1,12 @@
1
1
  import { cx } from "./cx.js";
2
+ import { gridChildPlacement } from "./grid-placement.js";
2
3
  import { applyEscapeProps, nativeAccessibilityRole, nativeAccessibilityState } from "./escape-props.js";
3
- import { defineUniversalComponent, universalPlan, universalValue } from "@nativescript-community/octane";
4
+ import { autoPlaceGridChildren, ensureGridTracks } from "./grid-auto-placement.js";
5
+ import { defineUniversalComponent, hookSlots, universalPlan, universalValue, useEffect, useRef } from "@nativescript-community/octane";
4
6
  //#region src/Grid.tsrx
7
+ var _hs$ = /* @__PURE__ */ hookSlots(2);
8
+ var _h$0 = /* @__PURE__ */ Symbol(_hs$);
9
+ var _h$1 = /* @__PURE__ */ Symbol(_hs$ + 1);
5
10
  var __octaneUniversalPlan0 = universalPlan("nativescript", {
6
11
  "kind": "host",
7
12
  "type": "gridlayout",
@@ -27,13 +32,37 @@ var __octaneUniversalPlan0 = universalPlan("nativescript", {
27
32
  });
28
33
  var warnedAboutGap = false;
29
34
  var Grid = defineUniversalComponent("nativescript", function Grid(props) {
35
+ const grid = useRef(null, _h$0);
30
36
  if (props.gap != null && !warnedAboutGap) {
31
37
  warnedAboutGap = true;
32
38
  console.warn("[Grid] gap was removed; use child margins");
33
39
  }
40
+ useEffect(() => {
41
+ const host = grid.current;
42
+ if (!host) return;
43
+ const views = [];
44
+ host.eachChildView((child) => {
45
+ views.push(child);
46
+ return true;
47
+ });
48
+ const placement = autoPlaceGridChildren(views.map(gridChildPlacement), props.rows, props.columns);
49
+ host.rows = ensureGridTracks(props.rows, placement.rowCount);
50
+ host.columns = ensureGridTracks(props.columns, placement.columnCount);
51
+ for (let index = 0; index < views.length; index++) {
52
+ views[index].row = placement.cells[index].row;
53
+ views[index].col = placement.cells[index].col;
54
+ }
55
+ }, [
56
+ props.children,
57
+ props.rows,
58
+ props.columns
59
+ ], _h$1);
34
60
  return universalValue(__octaneUniversalPlan0, [
35
61
  props.id,
36
- (view) => applyEscapeProps(view, props),
62
+ (view) => {
63
+ grid.current = view;
64
+ applyEscapeProps(view, props);
65
+ },
37
66
  props.rows,
38
67
  props.columns,
39
68
  cx("vx-grid", props.className),
@@ -1,12 +1,8 @@
1
1
  import { cx } from "./cx.js";
2
2
  import { applyEscapeProps } from "./escape-props.js";
3
- import { defineUniversalComponent, universalFor, universalPlan, universalValue } from "@nativescript-community/octane";
3
+ import { defineUniversalComponent, universalFor, universalIf, universalPlan, universalValue } from "@nativescript-community/octane";
4
4
  //#region src/Pagination.tsrx
5
5
  var __octaneUniversalPlan0 = universalPlan("nativescript", {
6
- "kind": "range",
7
- "children": []
8
- });
9
- var __octaneUniversalPlan1 = universalPlan("nativescript", {
10
6
  "kind": "host",
11
7
  "type": "label",
12
8
  "props": {
@@ -14,7 +10,7 @@ var __octaneUniversalPlan1 = universalPlan("nativescript", {
14
10
  "text": "…"
15
11
  }
16
12
  });
17
- var __octaneUniversalPlan2 = universalPlan("nativescript", {
13
+ var __octaneUniversalPlan1 = universalPlan("nativescript", {
18
14
  "kind": "host",
19
15
  "type": "flexboxlayout",
20
16
  "bindings": [["className", 0], ["onTap", 1]],
@@ -24,6 +20,10 @@ var __octaneUniversalPlan2 = universalPlan("nativescript", {
24
20
  "bindings": [["text", 2]]
25
21
  }]
26
22
  });
23
+ var __octaneUniversalPlan2 = universalPlan("nativescript", {
24
+ "kind": "slot",
25
+ "slot": 0
26
+ });
27
27
  var __octaneUniversalPlan3 = universalPlan("nativescript", {
28
28
  "kind": "host",
29
29
  "type": "flexboxlayout",
@@ -93,12 +93,15 @@ var Pagination = defineUniversalComponent("nativescript", function Pagination(pr
93
93
  props.style,
94
94
  () => go(current - 1),
95
95
  universalFor(pages, (e, __octaneUniversalIndex) => e.key, (e, __octaneUniversalIndex) => {
96
- e.page == null ? universalValue(__octaneUniversalPlan1, []) : universalValue(__octaneUniversalPlan2, [
97
- cx("vx-page-btn", e.page === current && "vx-page-btn--on"),
98
- () => go(e.page),
99
- String(e.page)
100
- ]);
101
- return universalValue(__octaneUniversalPlan0, []);
96
+ return universalValue(__octaneUniversalPlan2, [universalIf(e.page == null, () => {
97
+ return universalValue(__octaneUniversalPlan0, []);
98
+ }, () => {
99
+ return universalValue(__octaneUniversalPlan1, [
100
+ cx("vx-page-btn", e.page === current && "vx-page-btn--on"),
101
+ () => go(e.page),
102
+ String(e.page)
103
+ ]);
104
+ })]);
102
105
  }),
103
106
  () => go(current + 1)
104
107
  ]);
@@ -4,9 +4,9 @@ import { positionPopover } from "./popover-position.js";
4
4
  import { applyThemeClasses, useThemeScheme } from "./theme/theme-scheme.js";
5
5
  import { rootLayoutFor } from "./root-layout.mobile.js";
6
6
  import { createNativeScriptRoot, defineUniversalComponent, hookSlots, universalPlan, universalValue, useEffect, useRef, useState, withSlot } from "@nativescript-community/octane";
7
- import { GridLayout } from "@nativescript/core";
7
+ import { GridLayout, Screen, isIOS } from "@nativescript/core";
8
8
  //#region src/Popover.tsrx
9
- var _hs$ = /* @__PURE__ */ hookSlots(8);
9
+ var _hs$ = /* @__PURE__ */ hookSlots(9);
10
10
  var _h$0 = /* @__PURE__ */ Symbol(_hs$);
11
11
  var _h$1 = /* @__PURE__ */ Symbol(_hs$ + 1);
12
12
  var _h$2 = /* @__PURE__ */ Symbol(_hs$ + 2);
@@ -15,6 +15,7 @@ var _h$4 = /* @__PURE__ */ Symbol(_hs$ + 4);
15
15
  var _h$5 = /* @__PURE__ */ Symbol(_hs$ + 5);
16
16
  var _h$6 = /* @__PURE__ */ Symbol(_hs$ + 6);
17
17
  var _h$7 = /* @__PURE__ */ Symbol(_hs$ + 7);
18
+ var _h$8 = /* @__PURE__ */ Symbol(_hs$ + 8);
18
19
  var __octaneUniversalPlan0 = universalPlan("nativescript", {
19
20
  "kind": "host",
20
21
  "type": "gridlayout",
@@ -85,7 +86,14 @@ var PopoverLayer = defineUniversalComponent("nativescript", function PopoverLaye
85
86
  width: coordinateRoot.getActualSize().width,
86
87
  height: coordinateRoot.getActualSize().height
87
88
  }, props.placement ?? "bottom");
88
- setPosition((current) => current?.left === next.left && current?.top === next.top && current?.placement === next.placement ? current : next);
89
+ const insets = isIOS ? panelRef.current?.parent?.getSafeAreaInsets?.() : void 0;
90
+ const scale = isIOS ? Number(Screen.mainScreen.scale) || 1 : 1;
91
+ const panelPosition = {
92
+ ...next,
93
+ left: next.left - Number(insets?.left ?? 0) / scale,
94
+ top: next.top - Number(insets?.top ?? 0) / scale
95
+ };
96
+ setPosition((current) => current?.left === panelPosition.left && current?.top === panelPosition.top && current?.placement === panelPosition.placement ? current : panelPosition);
89
97
  if (panelSize?.width > 0 && panelSize?.height > 0) setSettled(true);
90
98
  };
91
99
  useEffect(() => {
@@ -116,16 +124,19 @@ var PopoverLayer = defineUniversalComponent("nativescript", function PopoverLaye
116
124
  props.children,
117
125
  props.style
118
126
  ], _h$3);
127
+ useEffect(() => {
128
+ if (position) (panelRef.current?.parent)?.requestLayout?.();
129
+ }, [position], _h$4);
119
130
  useEffect(() => {
120
131
  applyNativeProps(panelRef.current, props);
121
132
  }, [
122
133
  props.ios,
123
134
  props.android,
124
135
  settled
125
- ], _h$4);
136
+ ], _h$5);
126
137
  const dismiss = () => props.onDismiss?.();
127
138
  return universalValue(__octaneUniversalPlan1, [
128
- cx("vx-popover-layer", withSlot(_h$5, useThemeScheme) === "dark" && "ns-dark"),
139
+ cx("vx-popover-layer", withSlot(_h$6, useThemeScheme) === "dark" && "ns-dark"),
129
140
  (props.dismissOnOutsideTap ?? true) && universalValue(__octaneUniversalPlan0, ["transparent", dismiss]),
130
141
  panelRef,
131
142
  position?.left ?? 0,
@@ -139,7 +150,7 @@ var PopoverLayer = defineUniversalComponent("nativescript", function PopoverLaye
139
150
  ]);
140
151
  }, { "module": "@nativescript-community/octane" });
141
152
  var Popover = defineUniversalComponent("nativescript", function Popover(props) {
142
- const shown = useRef(null, _h$6);
153
+ const shown = useRef(null, _h$7);
143
154
  useEffect(() => {
144
155
  const cur = shown.current;
145
156
  if (!props.open) {
@@ -190,7 +201,7 @@ var Popover = defineUniversalComponent("nativescript", function Popover(props) {
190
201
  props.className,
191
202
  props.style,
192
203
  props.dismissOnOutsideTap
193
- ], _h$7);
204
+ ], _h$8);
194
205
  return universalValue(__octaneUniversalPlan2, []);
195
206
  }, { "module": "@nativescript-community/octane" });
196
207
  //#endregion
@@ -1,7 +1,7 @@
1
1
  import { cx } from "./cx.js";
2
2
  import { applyEscapeProps } from "./escape-props.js";
3
3
  import { registerRootLayout, unregisterRootLayout } from "./root-layout.mobile.js";
4
- import { attachTapToBlur } from "./tap-to-blur.mobile.js";
4
+ import { attachTapToBlur } from "./tap-to-blur.ios.js";
5
5
  import { defineUniversalComponent, universalPlan, universalValue } from "@nativescript-community/octane";
6
6
  //#region src/Screen.tsrx
7
7
  var __octaneUniversalPlan0 = universalPlan("nativescript", {
@@ -1,7 +1,7 @@
1
1
  import { cx } from "./cx.js";
2
2
  import { applyThemeClasses } from "./theme/theme-scheme.js";
3
3
  import { rootLayoutFor } from "./root-layout.mobile.js";
4
- import { attachTapToBlur } from "./tap-to-blur.mobile.js";
4
+ import { attachTapToBlur } from "./tap-to-blur.ios.js";
5
5
  import { attachSheetDetents } from "./sheet-detents.js";
6
6
  import { bindBottomInsetToKeyboard } from "./keyboard-inset.mobile.js";
7
7
  import { createNativeScriptRoot, defineUniversalComponent, hookSlots, universalPlan, universalValue, useEffect, useRef } from "@nativescript-community/octane";
@@ -15,7 +15,7 @@ var _h$5 = /* @__PURE__ */ Symbol(_hs$ + 5);
15
15
  var _h$6 = /* @__PURE__ */ Symbol(_hs$ + 6);
16
16
  var __octaneUniversalPlan0 = universalPlan("nativescript", {
17
17
  "kind": "host",
18
- "type": "gridlayout",
18
+ "type": "absolutelayout",
19
19
  "bindings": [
20
20
  ["id", 0],
21
21
  ["className", 1],
@@ -28,25 +28,20 @@ var __octaneUniversalPlan0 = universalPlan("nativescript", {
28
28
  {
29
29
  "kind": "host",
30
30
  "type": "flexboxlayout",
31
- "props": { "className": "vx-slider-track" }
31
+ "props": { "className": "vx-slider-track" },
32
+ "bindings": [["style", 6]]
32
33
  },
33
34
  {
34
35
  "kind": "host",
35
36
  "type": "flexboxlayout",
36
- "props": {
37
- "className": "vx-slider-fill",
38
- "horizontalAlignment": "left"
39
- },
40
- "bindings": [["style", 6]]
37
+ "props": { "className": "vx-slider-fill" },
38
+ "bindings": [["style", 7]]
41
39
  },
42
40
  {
43
41
  "kind": "host",
44
42
  "type": "flexboxlayout",
45
- "props": {
46
- "className": "vx-slider-thumb",
47
- "horizontalAlignment": "left"
48
- },
49
- "bindings": [["style", 7]]
43
+ "props": { "className": "vx-slider-thumb" },
44
+ "bindings": [["style", 8]]
50
45
  }
51
46
  ]
52
47
  });
@@ -64,6 +59,10 @@ var Slider = defineUniversalComponent("nativescript", function Slider(props) {
64
59
  host.current = el;
65
60
  measure.bind(el);
66
61
  }, [], _h$4);
62
+ const thumbSize = 20;
63
+ const trackTop = 12;
64
+ const thumbTop = 4;
65
+ const thumbLeft = Math.min(Math.max(ratio * width - thumbSize / 2, 0), Math.max(width - thumbSize, 0));
67
66
  useEffect(() => {
68
67
  applyNativeProps(host.current, props);
69
68
  }, [props], _h$5);
@@ -90,8 +89,18 @@ var Slider = defineUniversalComponent("nativescript", function Slider(props) {
90
89
  nativeAccessibilityRole("adjustable"),
91
90
  onPan,
92
91
  bindHost,
93
- { width: ratio * width },
94
- { marginLeft: Math.min(Math.max(ratio * width - 10, 0), Math.max(width - 20, 0)) }
92
+ {
93
+ width,
94
+ translateY: trackTop
95
+ },
96
+ {
97
+ width: ratio * width,
98
+ translateY: trackTop
99
+ },
100
+ {
101
+ translateX: thumbLeft,
102
+ translateY: thumbTop
103
+ }
95
104
  ]);
96
105
  }, { "module": "@nativescript-community/octane" });
97
106
  //#endregion
@@ -2,6 +2,7 @@ import { cx } from "./cx.js";
2
2
  import { applyEscapeProps, nativeAccessibilityRole, nativeAccessibilityState } from "./escape-props.js";
3
3
  import { layoutChildProps } from "./layout-child.js";
4
4
  import { createContext, defineUniversalComponent, universalComponent, universalIf, universalPlan, universalProps, universalValue, useContext } from "@nativescript-community/octane";
5
+ import { Application } from "@nativescript/core";
5
6
  //#region src/Text.tsrx
6
7
  var __octaneUniversalPlan0 = universalPlan("nativescript", {
7
8
  "kind": "host",
@@ -34,8 +35,23 @@ var TextScope = defineUniversalComponent("nativescript", function TextScope(prop
34
35
  }, { "module": "@nativescript-community/octane" });
35
36
  var Text = defineUniversalComponent("nativescript", function Text(props) {
36
37
  const inText = useContext(InText);
38
+ const fontWeightValue = String(props.style?.fontWeight ?? "").toLowerCase();
39
+ const fontWeight = /^\d+$/.test(fontWeightValue) ? Number(fontWeightValue) : {
40
+ normal: 400,
41
+ bold: 700,
42
+ thin: 100,
43
+ "extra-light": 200,
44
+ light: 300,
45
+ medium: 500,
46
+ "semi-bold": 600,
47
+ "extra-bold": 800,
48
+ black: 900
49
+ }[fontWeightValue];
50
+ const lineHeight = props.style?.lineHeight;
37
51
  const textStyle = {
38
52
  ...props.style,
53
+ ...(Application.ios || Application.android) && typeof lineHeight === "number" && Number.isFinite(lineHeight) && lineHeight > 0 && props.style?.height == null && props.style?.minHeight == null ? { minHeight: lineHeight } : {},
54
+ ...Application.ios && props.style?.fontVariationSettings == null && fontWeight !== void 0 && fontWeight >= 100 && fontWeight <= 900 ? { fontVariationSettings: `'wght' ${fontWeight}` } : {},
39
55
  ...props.ellipsize || props.numberOfLines ? { flexShrink: 1 } : {},
40
56
  ...props.ellipsize ? {
41
57
  whiteSpace: "nowrap",
@@ -31,14 +31,23 @@ function reportContentLayout(view, props) {
31
31
  view.style.height = height;
32
32
  }
33
33
  }
34
+ function applyNativeScrollEnabled(view, enabled) {
35
+ if (isIOS) {
36
+ const scrollView = view?.ios?.scrollView;
37
+ if (scrollView) scrollView.scrollEnabled = enabled !== false;
38
+ } else if (isAndroid) {
39
+ const nativeView = view?.android;
40
+ if (!nativeView?.setOnTouchListener) return;
41
+ nativeView.setOnTouchListener(enabled === false ? new android.view.View.OnTouchListener({ onTouch: (_view, event) => event.getActionMasked() === android.view.MotionEvent.ACTION_MOVE }) : null);
42
+ }
43
+ }
34
44
  var WebView = defineUniversalComponent("nativescript", function WebView(props) {
35
45
  const el = useRef(null, _h$0);
36
46
  const loaded = useRef(false, _h$1);
37
47
  useEffect(() => {
38
48
  const v = el.current;
39
49
  if (!v) return;
40
- if (isIOS) v.ios.scrollView.scrollEnabled = props.scrollEnabled !== false;
41
- else if (isAndroid) v.android.setOnTouchListener(props.scrollEnabled === false ? new android.view.View.OnTouchListener({ onTouch: (_view, event) => event.getActionMasked() === android.view.MotionEvent.ACTION_MOVE }) : null);
50
+ applyNativeScrollEnabled(v, props.scrollEnabled);
42
51
  if (props.matchContents && loaded.current) reportContentLayout(v, props);
43
52
  }, [props.scrollEnabled, props.matchContents], _h$2);
44
53
  return universalValue(__octaneUniversalPlan0, [universalProps([
@@ -79,10 +88,16 @@ var WebView = defineUniversalComponent("nativescript", function WebView(props) {
79
88
  "src",
80
89
  props.html !== void 0 ? props.html : props.src
81
90
  ],
91
+ [
92
+ "set",
93
+ "onLoaded",
94
+ () => applyNativeScrollEnabled(el.current, props.scrollEnabled)
95
+ ],
82
96
  [
83
97
  "set",
84
98
  "onLoadFinished",
85
99
  (e) => {
100
+ applyNativeScrollEnabled(e.object ?? el.current, props.scrollEnabled);
86
101
  if (e.error) props.onError?.({
87
102
  url: e.url,
88
103
  error: e.error
@@ -0,0 +1,9 @@
1
+ //#region \0@oxc-project+runtime@0.150.0/helpers/esm/decorate.js
2
+ function __decorate(decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ }
8
+ //#endregion
9
+ export { __decorate as default };
@@ -1,9 +1,11 @@
1
1
  import { applyNativeModifiers } from "./apply-native-modifiers.native.js";
2
+ import { rememberGridChildPlacement } from "./grid-placement.js";
2
3
  import { isAndroid, isIOS } from "@nativescript/core";
3
4
  //#region src/escape-props.ts
4
5
  /** Apply only the active device's escape bag after the primitive's own props. */
5
6
  function applyEscapeProps(view, props) {
6
7
  if (!view) return;
8
+ rememberGridChildPlacement(view, props);
7
9
  const bag = isIOS ? props.ios : isAndroid ? props.android : void 0;
8
10
  if (bag) Object.assign(view, bag);
9
11
  applyNativeModifiers(view, props.modifiers);
@@ -0,0 +1,83 @@
1
+ //#region src/grid-auto-placement.ts
2
+ function gridIndex(value) {
3
+ if (value == null || value === "") return null;
4
+ const index = Number(value);
5
+ return Number.isInteger(index) && index >= 0 ? index : null;
6
+ }
7
+ function gridSpan(value) {
8
+ const span = Number(value);
9
+ return Number.isInteger(span) && span > 0 ? span : 1;
10
+ }
11
+ function trackCount(spec) {
12
+ return spec?.split(",").filter((track) => track.trim().length > 0).length ?? 0;
13
+ }
14
+ /** Match CSS Grid's row-flow placement for NativeScript GridLayout children. */
15
+ function autoPlaceGridChildren(items, rowTracks, columnTracks) {
16
+ const placements = items.map((item) => ({
17
+ row: gridIndex(item.row),
18
+ col: gridIndex(item.col),
19
+ rowSpan: gridSpan(item.rowSpan),
20
+ colSpan: gridSpan(item.colSpan)
21
+ }));
22
+ const columnCount = Math.max(1, trackCount(columnTracks), ...placements.filter((placement) => placement.col != null).map((placement) => placement.col + placement.colSpan), ...placements.map((placement) => placement.colSpan));
23
+ const occupied = /* @__PURE__ */ new Set();
24
+ const isFree = (row, col, rowSpan, colSpan) => {
25
+ for (let y = row; y < row + rowSpan; y++) for (let x = col; x < col + colSpan; x++) if (occupied.has(`${y},${x}`)) return false;
26
+ return true;
27
+ };
28
+ const occupy = (row, col, rowSpan, colSpan) => {
29
+ for (let y = row; y < row + rowSpan; y++) for (let x = col; x < col + colSpan; x++) occupied.add(`${y},${x}`);
30
+ };
31
+ for (const placement of placements) if (placement.row != null && placement.col != null) occupy(placement.row, placement.col, placement.rowSpan, placement.colSpan);
32
+ for (const placement of placements) {
33
+ if (placement.row == null || placement.col != null) continue;
34
+ let col = 0;
35
+ while (!isFree(placement.row, col, placement.rowSpan, placement.colSpan)) col++;
36
+ placement.col = col;
37
+ occupy(placement.row, col, placement.rowSpan, placement.colSpan);
38
+ }
39
+ for (const placement of placements) {
40
+ if (placement.col == null || placement.row != null) continue;
41
+ let row = 0;
42
+ while (!isFree(row, placement.col, placement.rowSpan, placement.colSpan)) row++;
43
+ placement.row = row;
44
+ occupy(row, placement.col, placement.rowSpan, placement.colSpan);
45
+ }
46
+ let cursorRow = 0;
47
+ let cursorCol = 0;
48
+ for (const placement of placements) {
49
+ if (placement.row != null && placement.col != null) continue;
50
+ while (true) {
51
+ if (cursorCol + placement.colSpan > columnCount) {
52
+ cursorRow++;
53
+ cursorCol = 0;
54
+ continue;
55
+ }
56
+ if (isFree(cursorRow, cursorCol, placement.rowSpan, placement.colSpan)) break;
57
+ cursorCol++;
58
+ }
59
+ placement.row = cursorRow;
60
+ placement.col = cursorCol;
61
+ occupy(cursorRow, cursorCol, placement.rowSpan, placement.colSpan);
62
+ cursorCol += placement.colSpan;
63
+ if (cursorCol >= columnCount) {
64
+ cursorRow++;
65
+ cursorCol = 0;
66
+ }
67
+ }
68
+ return {
69
+ cells: placements.map(({ row, col }) => ({
70
+ row,
71
+ col
72
+ })),
73
+ rowCount: Math.max(trackCount(rowTracks), ...placements.map((item) => item.row + item.rowSpan)),
74
+ columnCount: Math.max(columnCount, ...placements.map((item) => item.col + item.colSpan))
75
+ };
76
+ }
77
+ function ensureGridTracks(spec, requiredCount) {
78
+ const tracks = spec?.split(",").map((track) => track.trim()).filter(Boolean) ?? [];
79
+ while (tracks.length < requiredCount) tracks.push("auto");
80
+ return tracks.join(",");
81
+ }
82
+ //#endregion
83
+ export { autoPlaceGridChildren, ensureGridTracks };
@@ -0,0 +1,20 @@
1
+ //#region src/grid-placement.ts
2
+ var placements = /* @__PURE__ */ new WeakMap();
3
+ /** Keep the authored Grid placement next to its mounted NativeScript view. */
4
+ function rememberGridChildPlacement(view, props) {
5
+ if ((typeof view !== "object" || view === null) && typeof view !== "function") return;
6
+ const placement = {};
7
+ for (const key of [
8
+ "row",
9
+ "col",
10
+ "rowSpan",
11
+ "colSpan"
12
+ ]) if (props[key] !== void 0) placement[key] = props[key];
13
+ if (Object.keys(placement).length) placements.set(view, placement);
14
+ else placements.delete(view);
15
+ }
16
+ function gridChildPlacement(view) {
17
+ return typeof view === "object" && view !== null ? placements.get(view) ?? {} : {};
18
+ }
19
+ //#endregion
20
+ export { gridChildPlacement, rememberGridChildPlacement };
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 1,
3
- "buildId": "397eabd3-87de-49d4-adf0-133ab9697510",
3
+ "buildId": "f5c4c58c-23aa-430f-84c7-e26b75109c60",
4
4
  "mode": "production",
5
5
  "capabilities": {
6
6
  "independentHydration": false
@@ -1,6 +1,6 @@
1
1
  import { applyThemeClasses } from "./theme/theme-scheme.js";
2
2
  import { topRootLayout } from "./root-layout.mobile.js";
3
- import { attachTapToBlur } from "./tap-to-blur.mobile.js";
3
+ import { attachTapToBlur } from "./tap-to-blur.ios.js";
4
4
  import { attachSheetDetents } from "./sheet-detents.js";
5
5
  import { bindBottomInsetToKeyboard } from "./keyboard-inset.mobile.js";
6
6
  import { createNativeScriptRoot } from "@nativescript-community/octane";
@@ -1,5 +1,5 @@
1
- import { Application } from "@nativescript/core";
2
- //#region src/tap-to-blur.mobile.ts
1
+ import __decorate from "./_virtual/_@oxc-project_runtime@0.150.0/helpers/esm/decorate.js";
2
+ //#region src/tap-to-blur.ios.ts
3
3
  /** Tap-outside-to-blur: iOS keeps a focused UITextField/UITextView as first
4
4
  * responder until something else takes it, so a tap on blank chrome never
5
5
  * dismisses the keyboard on its own.
@@ -11,36 +11,15 @@ import { Application } from "@nativescript/core";
11
11
  * editable text view (otherwise the field would focus-then-blur in the same
12
12
  * tap — recognizers fire on touch-up, after the field's touch-down focus).
13
13
  * Keyboard taps live in a separate UIWindow, so they never reach it.
14
- * `cancelsTouchesInView` stays false so taps still reach buttons.
15
- *
16
- * Android: hides the soft keyboard from the currently focused view when a
17
- * tap lands on the attached container. */
14
+ * `cancelsTouchesInView` stays false so taps still reach buttons. */
18
15
  function attachTapToBlur(view) {
19
16
  const marker = "__xplatTapToBlur";
20
17
  if (!view || view[marker]) return () => {};
21
18
  view[marker] = true;
22
- if (Application.ios) {
23
- iosAttach();
24
- return () => {
25
- view[marker] = false;
26
- iosDetach();
27
- };
28
- }
29
- if (Application.android) {
30
- const handler = (_args) => {
31
- const activity = Application.android.foregroundActivity;
32
- const focused = activity?.currentFocus;
33
- if (!focused) return;
34
- activity.getSystemService(android.content.Context.INPUT_METHOD_SERVICE)?.hideSoftInputFromWindow(focused.getWindowToken(), 0);
35
- };
36
- view.on("tap", handler);
37
- return () => {
38
- view[marker] = false;
39
- view.off("tap", handler);
40
- };
41
- }
19
+ iosAttach();
42
20
  return () => {
43
21
  view[marker] = false;
22
+ iosDetach();
44
23
  };
45
24
  }
46
25
  var iosCount = 0;
@@ -53,25 +32,34 @@ function iosAttach() {
53
32
  const appWin = appWindow();
54
33
  if (!appWin) return;
55
34
  iosWindow = appWin;
56
- const Owner = class extends NSObject {
35
+ let TapToBlurRecognizerTarget = class TapToBlurRecognizerTarget extends NSObject {
36
+ static {
37
+ this.ObjCProtocols = [UIGestureRecognizerDelegate];
38
+ }
57
39
  static {
58
40
  this.ObjCExposedMethods = { tap: {
59
41
  returns: interop.types.void,
60
42
  params: [UITapGestureRecognizer]
61
43
  } };
62
44
  }
63
- tap(recognizer) {
64
- const point = recognizer.locationInView(iosWindow);
65
- let hit = iosWindow.hitTest(point, null);
45
+ gestureRecognizerShouldReceiveTouch(_recognizer, touch) {
46
+ let hit = touch.view;
66
47
  while (hit) {
67
- if (hit instanceof UITextField || hit instanceof UITextView) return;
48
+ const textField = hit.isKindOfClass(UITextField.class());
49
+ const textView = hit.isKindOfClass(UITextView.class());
50
+ if (textField || textView) return false;
68
51
  hit = hit.superview;
69
52
  }
53
+ return true;
54
+ }
55
+ tap(_recognizer) {
70
56
  iosWindow.endEditing(true);
71
57
  }
72
58
  };
73
- iosTarget = Owner.new();
59
+ TapToBlurRecognizerTarget = __decorate([NativeClass], TapToBlurRecognizerTarget);
60
+ iosTarget = TapToBlurRecognizerTarget.new();
74
61
  iosRecognizer = UITapGestureRecognizer.alloc().initWithTargetAction(iosTarget, "tap");
62
+ iosRecognizer.delegate = iosTarget;
75
63
  iosRecognizer.cancelsTouchesInView = false;
76
64
  appWin.addGestureRecognizer(iosRecognizer);
77
65
  }