@modelform/react-native 0.2.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/dist/index.mjs CHANGED
@@ -28,6 +28,7 @@ import {
28
28
  REFRESH_CHOICES,
29
29
  RELATIVE_RANGES,
30
30
  SERIES_PALETTE,
31
+ SNIPPET_VERSION,
31
32
  SPECIAL_MATCHES,
32
33
  SaveConflictError,
33
34
  TIME_PRESETS,
@@ -46,6 +47,9 @@ import {
46
47
  checkFiles,
47
48
  cleanDashboard,
48
49
  cleanPanelOptions,
50
+ collapseRow,
51
+ compactGrid,
52
+ copyPanels,
49
53
  dashboardSchema,
50
54
  dashboardSchemaIssues,
51
55
  dashboardSourceIds,
@@ -73,6 +77,7 @@ import {
73
77
  framesToOptions,
74
78
  fromWire,
75
79
  getPath,
80
+ gridOffsetPx,
76
81
  gridUnitsToPx,
77
82
  httpFetchJson,
78
83
  initialVariableValues,
@@ -123,9 +128,13 @@ import {
123
128
  parseJsonText,
124
129
  parseLocalDateTime,
125
130
  parseRange,
131
+ parseSnippet,
126
132
  parseTime,
133
+ pasteSnippet,
134
+ placePanel,
127
135
  pointerToPath,
128
136
  prepareDashboard,
137
+ previewPaste,
129
138
  queryPanel,
130
139
  queryParam,
131
140
  readConfigFiles,
@@ -158,6 +167,8 @@ import {
158
167
  setOption,
159
168
  setOptionValue,
160
169
  setOverrides,
170
+ settleLayout,
171
+ snapToGrid,
161
172
  splitPath,
162
173
  startOf,
163
174
  stringifyCompact,
@@ -189,7 +200,7 @@ import {
189
200
  variableWithType,
190
201
  visibleVariables,
191
202
  zoomRange
192
- } from "./chunk-MRHC6AEU.mjs";
203
+ } from "./chunk-ATRMUHKJ.mjs";
193
204
 
194
205
  // src/ui/theme.tsx
195
206
  import { createContext, useContext } from "react";
@@ -3666,7 +3677,8 @@ function DashboardView({ mode = "auto", header, footer, refreshable }) {
3666
3677
  ]
3667
3678
  }
3668
3679
  ),
3669
- !collapsed && section.rows.map((row, ri) => /* @__PURE__ */ jsx15(View12, { style: styles13.row, children: row.cells.map((cell) => {
3680
+ !collapsed && layoutMode === "grid" && /* @__PURE__ */ jsx15(GridSection, { grid: section.grid, width: contentW, maxPanelH, deferred: !seen.has(section.key) }),
3681
+ !collapsed && layoutMode === "phone" && section.rows.map((row, ri) => /* @__PURE__ */ jsx15(View12, { style: styles13.row, children: row.cells.map((cell) => {
3670
3682
  const w = (contentW + GAP) * (cell.span / GRID_COLUMNS) - GAP;
3671
3683
  return /* @__PURE__ */ jsx15(PanelCard, { panel: cell.panel, width: w, height: Math.min(gridUnitsToPx(row.h), maxPanelH), deferred: !seen.has(section.key) }, cell.key);
3672
3684
  }) }, ri))
@@ -3678,6 +3690,12 @@ function DashboardView({ mode = "auto", header, footer, refreshable }) {
3678
3690
  footer
3679
3691
  ] });
3680
3692
  }
3693
+ function GridSection({ grid, width, maxPanelH, deferred }) {
3694
+ const colW = (width + GAP) / GRID_COLUMNS;
3695
+ const tallest = Math.max(0, ...grid.cells.map((c) => gridUnitsToPx(c.h)));
3696
+ const scale = tallest > maxPanelH ? maxPanelH / tallest : 1;
3697
+ 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)) });
3698
+ }
3681
3699
  function useSeenSections(viewportHeight) {
3682
3700
  const [seen, setSeen] = useState10(/* @__PURE__ */ new Set());
3683
3701
  const view = useRef4({ y: 0, h: viewportHeight });
@@ -3781,6 +3799,7 @@ var styles13 = StyleSheet13.create({
3781
3799
  chevron: { fontSize: 14, width: 14 },
3782
3800
  rowTitle: { fontSize: 15, fontWeight: "600" },
3783
3801
  row: { flexDirection: "row", gap: GAP },
3802
+ gridCell: { position: "absolute" },
3784
3803
  card: { borderRadius: 10, borderWidth: StyleSheet13.hairlineWidth, paddingHorizontal: 12, paddingVertical: 8, overflow: "hidden" },
3785
3804
  titleRow: { flexDirection: "row", alignItems: "flex-start", gap: 8, height: TITLE_H - 8, marginBottom: 8 },
3786
3805
  title: { flex: 1, fontSize: 13, fontWeight: "600" },
@@ -3989,6 +4008,7 @@ export {
3989
4008
  RELATIVE_RANGES,
3990
4009
  RenderBoundary,
3991
4010
  SERIES_PALETTE,
4011
+ SNIPPET_VERSION,
3992
4012
  SPECIAL_MATCHES,
3993
4013
  SaveConflictError,
3994
4014
  TIME_PRESETS,
@@ -4007,6 +4027,9 @@ export {
4007
4027
  checkFiles,
4008
4028
  cleanDashboard,
4009
4029
  cleanPanelOptions,
4030
+ collapseRow,
4031
+ compactGrid,
4032
+ copyPanels,
4010
4033
  darkTheme,
4011
4034
  dashboardSchema,
4012
4035
  dashboardSchemaIssues,
@@ -4035,6 +4058,7 @@ export {
4035
4058
  framesToOptions,
4036
4059
  fromWire,
4037
4060
  getPath,
4061
+ gridOffsetPx,
4038
4062
  gridUnitsToPx,
4039
4063
  httpFetchJson,
4040
4064
  initialVariableValues,
@@ -4086,9 +4110,13 @@ export {
4086
4110
  parseJsonText,
4087
4111
  parseLocalDateTime,
4088
4112
  parseRange,
4113
+ parseSnippet,
4089
4114
  parseTime,
4115
+ pasteSnippet,
4116
+ placePanel,
4090
4117
  pointerToPath,
4091
4118
  prepareDashboard,
4119
+ previewPaste,
4092
4120
  queryPanel,
4093
4121
  queryParam,
4094
4122
  readConfigFiles,
@@ -4122,6 +4150,8 @@ export {
4122
4150
  setOption,
4123
4151
  setOptionValue,
4124
4152
  setOverrides,
4153
+ settleLayout,
4154
+ snapToGrid,
4125
4155
  splitPath,
4126
4156
  startOf,
4127
4157
  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.4.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",