@modelform/react-native 0.3.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.
@@ -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,
@@ -48,6 +49,7 @@ import {
48
49
  cleanPanelOptions,
49
50
  collapseRow,
50
51
  compactGrid,
52
+ copyPanels,
51
53
  dashboardSchema,
52
54
  dashboardSchemaIssues,
53
55
  dashboardSourceIds,
@@ -126,10 +128,13 @@ import {
126
128
  parseJsonText,
127
129
  parseLocalDateTime,
128
130
  parseRange,
131
+ parseSnippet,
129
132
  parseTime,
133
+ pasteSnippet,
130
134
  placePanel,
131
135
  pointerToPath,
132
136
  prepareDashboard,
137
+ previewPaste,
133
138
  queryPanel,
134
139
  queryParam,
135
140
  readConfigFiles,
@@ -195,7 +200,7 @@ import {
195
200
  variableWithType,
196
201
  visibleVariables,
197
202
  zoomRange
198
- } from "../chunk-PU7RRUV4.mjs";
203
+ } from "../chunk-ATRMUHKJ.mjs";
199
204
  export {
200
205
  ALL,
201
206
  BUNDLE_ACCEPT,
@@ -226,6 +231,7 @@ export {
226
231
  REFRESH_CHOICES,
227
232
  RELATIVE_RANGES,
228
233
  SERIES_PALETTE,
234
+ SNIPPET_VERSION,
229
235
  SPECIAL_MATCHES,
230
236
  SaveConflictError,
231
237
  TIME_PRESETS,
@@ -246,6 +252,7 @@ export {
246
252
  cleanPanelOptions,
247
253
  collapseRow,
248
254
  compactGrid,
255
+ copyPanels,
249
256
  dashboardSchema,
250
257
  dashboardSchemaIssues,
251
258
  dashboardSourceIds,
@@ -324,10 +331,13 @@ export {
324
331
  parseJsonText,
325
332
  parseLocalDateTime,
326
333
  parseRange,
334
+ parseSnippet,
327
335
  parseTime,
336
+ pasteSnippet,
328
337
  placePanel,
329
338
  pointerToPath,
330
339
  prepareDashboard,
340
+ previewPaste,
331
341
  queryPanel,
332
342
  queryParam,
333
343
  readConfigFiles,
@@ -112,10 +112,10 @@ export declare function collapseRow(panels: Panel[], index: number): {
112
112
  };
113
113
  /**
114
114
  * Floats every panel up the way the app shows them, so the file says what the app shows. With
115
- * `fixed`, that panel keeps its place (just moved or resized) and any it now covers move down
116
- * first. Panels already in place are left as the same objects.
115
+ * `fixed`, that panel (or those panels, e.g. a pasted block) keeps its place and any it now
116
+ * covers move down first. Panels already in place are left as the same objects.
117
117
  */
118
- export declare function settleLayout(panels: Panel[], fixed?: number): Panel[];
118
+ export declare function settleLayout(panels: Panel[], fixed?: number | number[]): Panel[];
119
119
  /** Puts a panel with its top left at column x, line y; panels in the way move down, then everything floats up. */
120
120
  export declare function placePanel(panels: Panel[], index: number, x: number, y: number): Panel[];
121
121
  /** The grid cell a panel `w` columns wide would take with its top left at pixel (x, y) on a canvas `width` wide. */
@@ -0,0 +1,64 @@
1
+ import type { Dashboard, Panel, TemplateVariable } from './schema';
2
+ export declare const SNIPPET_VERSION = 1;
3
+ export interface PanelSnippet {
4
+ $modelform: 'panels';
5
+ version: number;
6
+ /** "form" when any panel is an input, which only forms can show. */
7
+ kind: 'form' | 'dashboard';
8
+ /** Top-level panels. A row brings its panels: inside it when collapsed, after it when not. */
9
+ panels: Panel[];
10
+ /** The dashboard variables the panels use, and the variables those use. */
11
+ variables: TemplateVariable[];
12
+ /** Every metric the panels record (inputs) or read (local queries). */
13
+ metrics: string[];
14
+ }
15
+ /**
16
+ * The top-level panels at `indices` as a snippet. A row brings the panels under it, down to the
17
+ * next row; a collapsed row already holds them. Ids go, positions become relative to the block.
18
+ */
19
+ export declare function copyPanels(dashboard: Dashboard, indices: number[]): PanelSnippet;
20
+ /**
21
+ * Reads clipboard text as a snippet: a snippet itself, one Grafana panel, an array of panels, or
22
+ * a whole dashboard (its panels and variables). Positions, ids, variables and metrics are worked
23
+ * out again from the panels, so hand-edited or foreign JSON comes out consistent.
24
+ */
25
+ export declare function parseSnippet(text: string): {
26
+ snippet: PanelSnippet;
27
+ } | {
28
+ error: string;
29
+ };
30
+ export interface PasteOptions {
31
+ /** Put the block under this top-level panel; otherwise at the bottom. */
32
+ after?: number | null;
33
+ /** Metrics to rename on the way in, e.g. { weight: 'body-weight' }. */
34
+ metrics?: Record<string, string>;
35
+ /** What's being pasted into. Inputs only go into forms. Defaults to a form if it has inputs. */
36
+ kind?: 'form' | 'dashboard';
37
+ }
38
+ export interface PasteResult {
39
+ panels: Panel[];
40
+ /** The dashboard's variables after the paste. */
41
+ variables: TemplateVariable[];
42
+ /** Index in `panels` of the first pasted panel; the rest follow it. */
43
+ index: number;
44
+ /** How many top-level panels were pasted. */
45
+ count: number;
46
+ /** Variables the dashboard didn't have, by name as added. */
47
+ added: string[];
48
+ /** Variables added under a new name because the dashboard has a different one of the same name. */
49
+ renamed: Record<string, string>;
50
+ /** Titles of panels left out: inputs going into a dashboard. */
51
+ skipped: string[];
52
+ }
53
+ /** What a paste would add and rename, without doing it: for asking first. */
54
+ export declare function previewPaste(dashboard: Dashboard, snippet: PanelSnippet): {
55
+ added: string[];
56
+ renamed: Record<string, string>;
57
+ };
58
+ /**
59
+ * Drops a snippet into a dashboard: fresh ids, metrics renamed per `options.metrics`, variables
60
+ * added (or added under a new name where one of the same name differs), and the block placed as
61
+ * a unit under `options.after` or at the bottom, with the panels below moving down. Pasted
62
+ * panels go at the end of the panels array, so the rest of the file stays as it is.
63
+ */
64
+ export declare function pasteSnippet(dashboard: Dashboard, snippet: PanelSnippet, options?: PasteOptions): PasteResult;