@modelform/react-native 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.
package/dist/index.mjs CHANGED
@@ -46,6 +46,8 @@ import {
46
46
  checkFiles,
47
47
  cleanDashboard,
48
48
  cleanPanelOptions,
49
+ collapseRow,
50
+ compactGrid,
49
51
  dashboardSchema,
50
52
  dashboardSchemaIssues,
51
53
  dashboardSourceIds,
@@ -73,6 +75,7 @@ import {
73
75
  framesToOptions,
74
76
  fromWire,
75
77
  getPath,
78
+ gridOffsetPx,
76
79
  gridUnitsToPx,
77
80
  httpFetchJson,
78
81
  initialVariableValues,
@@ -124,6 +127,7 @@ import {
124
127
  parseLocalDateTime,
125
128
  parseRange,
126
129
  parseTime,
130
+ placePanel,
127
131
  pointerToPath,
128
132
  prepareDashboard,
129
133
  queryPanel,
@@ -158,6 +162,8 @@ import {
158
162
  setOption,
159
163
  setOptionValue,
160
164
  setOverrides,
165
+ settleLayout,
166
+ snapToGrid,
161
167
  splitPath,
162
168
  startOf,
163
169
  stringifyCompact,
@@ -189,7 +195,7 @@ import {
189
195
  variableWithType,
190
196
  visibleVariables,
191
197
  zoomRange
192
- } from "./chunk-MRHC6AEU.mjs";
198
+ } from "./chunk-PU7RRUV4.mjs";
193
199
 
194
200
  // src/ui/theme.tsx
195
201
  import { createContext, useContext } from "react";
@@ -3666,7 +3672,8 @@ function DashboardView({ mode = "auto", header, footer, refreshable }) {
3666
3672
  ]
3667
3673
  }
3668
3674
  ),
3669
- !collapsed && section.rows.map((row, ri) => /* @__PURE__ */ jsx15(View12, { style: styles13.row, children: row.cells.map((cell) => {
3675
+ !collapsed && layoutMode === "grid" && /* @__PURE__ */ jsx15(GridSection, { grid: section.grid, width: contentW, maxPanelH, deferred: !seen.has(section.key) }),
3676
+ !collapsed && layoutMode === "phone" && section.rows.map((row, ri) => /* @__PURE__ */ jsx15(View12, { style: styles13.row, children: row.cells.map((cell) => {
3670
3677
  const w = (contentW + GAP) * (cell.span / GRID_COLUMNS) - GAP;
3671
3678
  return /* @__PURE__ */ jsx15(PanelCard, { panel: cell.panel, width: w, height: Math.min(gridUnitsToPx(row.h), maxPanelH), deferred: !seen.has(section.key) }, cell.key);
3672
3679
  }) }, ri))
@@ -3678,6 +3685,12 @@ function DashboardView({ mode = "auto", header, footer, refreshable }) {
3678
3685
  footer
3679
3686
  ] });
3680
3687
  }
3688
+ function GridSection({ grid, width, maxPanelH, deferred }) {
3689
+ const colW = (width + GAP) / GRID_COLUMNS;
3690
+ const tallest = Math.max(0, ...grid.cells.map((c) => gridUnitsToPx(c.h)));
3691
+ const scale = tallest > maxPanelH ? maxPanelH / tallest : 1;
3692
+ return /* @__PURE__ */ jsx15(View12, { style: { height: gridUnitsToPx(grid.h) * scale }, children: grid.cells.map((cell) => /* @__PURE__ */ jsx15(View12, { style: [styles13.gridCell, { left: cell.x * colW, top: gridOffsetPx(cell.y) * scale }], children: /* @__PURE__ */ jsx15(PanelCard, { panel: cell.panel, width: cell.w * colW - GAP, height: gridUnitsToPx(cell.h) * scale, deferred }) }, cell.key)) });
3693
+ }
3681
3694
  function useSeenSections(viewportHeight) {
3682
3695
  const [seen, setSeen] = useState10(/* @__PURE__ */ new Set());
3683
3696
  const view = useRef4({ y: 0, h: viewportHeight });
@@ -3781,6 +3794,7 @@ var styles13 = StyleSheet13.create({
3781
3794
  chevron: { fontSize: 14, width: 14 },
3782
3795
  rowTitle: { fontSize: 15, fontWeight: "600" },
3783
3796
  row: { flexDirection: "row", gap: GAP },
3797
+ gridCell: { position: "absolute" },
3784
3798
  card: { borderRadius: 10, borderWidth: StyleSheet13.hairlineWidth, paddingHorizontal: 12, paddingVertical: 8, overflow: "hidden" },
3785
3799
  titleRow: { flexDirection: "row", alignItems: "flex-start", gap: 8, height: TITLE_H - 8, marginBottom: 8 },
3786
3800
  title: { flex: 1, fontSize: 13, fontWeight: "600" },
@@ -4007,6 +4021,8 @@ export {
4007
4021
  checkFiles,
4008
4022
  cleanDashboard,
4009
4023
  cleanPanelOptions,
4024
+ collapseRow,
4025
+ compactGrid,
4010
4026
  darkTheme,
4011
4027
  dashboardSchema,
4012
4028
  dashboardSchemaIssues,
@@ -4035,6 +4051,7 @@ export {
4035
4051
  framesToOptions,
4036
4052
  fromWire,
4037
4053
  getPath,
4054
+ gridOffsetPx,
4038
4055
  gridUnitsToPx,
4039
4056
  httpFetchJson,
4040
4057
  initialVariableValues,
@@ -4087,6 +4104,7 @@ export {
4087
4104
  parseLocalDateTime,
4088
4105
  parseRange,
4089
4106
  parseTime,
4107
+ placePanel,
4090
4108
  pointerToPath,
4091
4109
  prepareDashboard,
4092
4110
  queryPanel,
@@ -4122,6 +4140,8 @@ export {
4122
4140
  setOption,
4123
4141
  setOptionValue,
4124
4142
  setOverrides,
4143
+ settleLayout,
4144
+ snapToGrid,
4125
4145
  splitPath,
4126
4146
  startOf,
4127
4147
  stringifyCompact,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modelform/react-native",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Render Grafana-compatible dashboard JSON, and input forms in the same format, as native React Native panels.",
5
5
  "keywords": [
6
6
  "react-native",