@modelform/react-native 0.1.1 → 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,7 +75,9 @@ import {
73
75
  framesToOptions,
74
76
  fromWire,
75
77
  getPath,
78
+ gridOffsetPx,
76
79
  gridUnitsToPx,
80
+ httpFetchJson,
77
81
  initialVariableValues,
78
82
  inputPanels,
79
83
  inputProblem,
@@ -123,6 +127,7 @@ import {
123
127
  parseLocalDateTime,
124
128
  parseRange,
125
129
  parseTime,
130
+ placePanel,
126
131
  pointerToPath,
127
132
  prepareDashboard,
128
133
  queryPanel,
@@ -145,6 +150,7 @@ import {
145
150
  resolveTimezone,
146
151
  resolveUrl,
147
152
  resolveVariables,
153
+ revalidateBundle,
148
154
  rowsToMappings,
149
155
  sampleEntries,
150
156
  screenDocuments,
@@ -156,6 +162,8 @@ import {
156
162
  setOption,
157
163
  setOptionValue,
158
164
  setOverrides,
165
+ settleLayout,
166
+ snapToGrid,
159
167
  splitPath,
160
168
  startOf,
161
169
  stringifyCompact,
@@ -187,7 +195,7 @@ import {
187
195
  variableWithType,
188
196
  visibleVariables,
189
197
  zoomRange
190
- } from "./chunk-PIHXMZ4G.mjs";
198
+ } from "./chunk-PU7RRUV4.mjs";
191
199
 
192
200
  // src/ui/theme.tsx
193
201
  import { createContext, useContext } from "react";
@@ -3664,7 +3672,8 @@ function DashboardView({ mode = "auto", header, footer, refreshable }) {
3664
3672
  ]
3665
3673
  }
3666
3674
  ),
3667
- !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) => {
3668
3677
  const w = (contentW + GAP) * (cell.span / GRID_COLUMNS) - GAP;
3669
3678
  return /* @__PURE__ */ jsx15(PanelCard, { panel: cell.panel, width: w, height: Math.min(gridUnitsToPx(row.h), maxPanelH), deferred: !seen.has(section.key) }, cell.key);
3670
3679
  }) }, ri))
@@ -3676,6 +3685,12 @@ function DashboardView({ mode = "auto", header, footer, refreshable }) {
3676
3685
  footer
3677
3686
  ] });
3678
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
+ }
3679
3694
  function useSeenSections(viewportHeight) {
3680
3695
  const [seen, setSeen] = useState10(/* @__PURE__ */ new Set());
3681
3696
  const view = useRef4({ y: 0, h: viewportHeight });
@@ -3779,6 +3794,7 @@ var styles13 = StyleSheet13.create({
3779
3794
  chevron: { fontSize: 14, width: 14 },
3780
3795
  rowTitle: { fontSize: 15, fontWeight: "600" },
3781
3796
  row: { flexDirection: "row", gap: GAP },
3797
+ gridCell: { position: "absolute" },
3782
3798
  card: { borderRadius: 10, borderWidth: StyleSheet13.hairlineWidth, paddingHorizontal: 12, paddingVertical: 8, overflow: "hidden" },
3783
3799
  titleRow: { flexDirection: "row", alignItems: "flex-start", gap: 8, height: TITLE_H - 8, marginBottom: 8 },
3784
3800
  title: { flex: 1, fontSize: 13, fontWeight: "600" },
@@ -4005,6 +4021,8 @@ export {
4005
4021
  checkFiles,
4006
4022
  cleanDashboard,
4007
4023
  cleanPanelOptions,
4024
+ collapseRow,
4025
+ compactGrid,
4008
4026
  darkTheme,
4009
4027
  dashboardSchema,
4010
4028
  dashboardSchemaIssues,
@@ -4033,7 +4051,9 @@ export {
4033
4051
  framesToOptions,
4034
4052
  fromWire,
4035
4053
  getPath,
4054
+ gridOffsetPx,
4036
4055
  gridUnitsToPx,
4056
+ httpFetchJson,
4037
4057
  initialVariableValues,
4038
4058
  inputPanels,
4039
4059
  inputProblem,
@@ -4084,6 +4104,7 @@ export {
4084
4104
  parseLocalDateTime,
4085
4105
  parseRange,
4086
4106
  parseTime,
4107
+ placePanel,
4087
4108
  pointerToPath,
4088
4109
  prepareDashboard,
4089
4110
  queryPanel,
@@ -4107,6 +4128,7 @@ export {
4107
4128
  resolveTimezone,
4108
4129
  resolveUrl,
4109
4130
  resolveVariables,
4131
+ revalidateBundle,
4110
4132
  rowsToMappings,
4111
4133
  sampleEntries,
4112
4134
  screenDocuments,
@@ -4118,6 +4140,8 @@ export {
4118
4140
  setOption,
4119
4141
  setOptionValue,
4120
4142
  setOverrides,
4143
+ settleLayout,
4144
+ snapToGrid,
4121
4145
  splitPath,
4122
4146
  startOf,
4123
4147
  stringifyCompact,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modelform/react-native",
3
- "version": "0.1.1",
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",