@modelform/react-native 0.0.0-stage → 0.1.1

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 (65) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +103 -2
  3. package/dist/chunk-L4SQVIJV.js +10630 -0
  4. package/dist/chunk-PIHXMZ4G.mjs +10630 -0
  5. package/dist/core/configSchema.d.ts +29 -0
  6. package/dist/core/dashboardSettings.d.ts +34 -0
  7. package/dist/core/datasource.d.ts +61 -0
  8. package/dist/core/documents.d.ts +35 -0
  9. package/dist/core/editing.d.ts +129 -0
  10. package/dist/core/fieldconfig.d.ts +12 -0
  11. package/dist/core/format.d.ts +29 -0
  12. package/dist/core/frame.d.ts +51 -0
  13. package/dist/core/gazetteer.d.ts +25 -0
  14. package/dist/core/grafana.d.ts +85 -0
  15. package/dist/core/index.d.ts +27 -0
  16. package/dist/core/index.js +380 -0
  17. package/dist/core/index.mjs +380 -0
  18. package/dist/core/inputs.d.ts +99 -0
  19. package/dist/core/jsonEdit.d.ts +30 -0
  20. package/dist/core/layout.d.ts +49 -0
  21. package/dist/core/layoutEdit.d.ts +87 -0
  22. package/dist/core/links.d.ts +56 -0
  23. package/dist/core/local.d.ts +95 -0
  24. package/dist/core/manifest.d.ts +201 -0
  25. package/dist/core/mappings.d.ts +46 -0
  26. package/dist/core/navigation.d.ts +19 -0
  27. package/dist/core/panelOptions.d.ts +109 -0
  28. package/dist/core/reduce.d.ts +6 -0
  29. package/dist/core/resolveVariables.d.ts +38 -0
  30. package/dist/core/sample.d.ts +13 -0
  31. package/dist/core/schema.d.ts +202 -0
  32. package/dist/core/time.d.ts +66 -0
  33. package/dist/core/transform.d.ts +12 -0
  34. package/dist/core/variables.d.ts +76 -0
  35. package/dist/index.d.ts +11 -0
  36. package/dist/index.js +4156 -0
  37. package/dist/index.mjs +4156 -0
  38. package/dist/ui/Chip.d.ts +5 -0
  39. package/dist/ui/DashboardView.d.ts +22 -0
  40. package/dist/ui/RenderBoundary.d.ts +25 -0
  41. package/dist/ui/TimeRangeSheet.d.ts +24 -0
  42. package/dist/ui/Toolbar.d.ts +6 -0
  43. package/dist/ui/chart.d.ts +69 -0
  44. package/dist/ui/context.d.ts +68 -0
  45. package/dist/ui/geomap.d.ts +157 -0
  46. package/dist/ui/inputs/InputForm.d.ts +36 -0
  47. package/dist/ui/inputs/InputPanels.d.ts +4 -0
  48. package/dist/ui/inputs/formContext.d.ts +14 -0
  49. package/dist/ui/links.d.ts +28 -0
  50. package/dist/ui/panels/GaugePanels.d.ts +5 -0
  51. package/dist/ui/panels/GeomapPanel.d.ts +6 -0
  52. package/dist/ui/panels/OtherPanels.d.ts +18 -0
  53. package/dist/ui/panels/StatPanel.d.ts +14 -0
  54. package/dist/ui/panels/TimeSeriesPanel.d.ts +8 -0
  55. package/dist/ui/panels/XYChartPanel.d.ts +6 -0
  56. package/dist/ui/panels/common.d.ts +78 -0
  57. package/dist/ui/panels/registry.d.ts +5 -0
  58. package/dist/ui/table.d.ts +62 -0
  59. package/dist/ui/theme.d.ts +21 -0
  60. package/dist/ui/xychart.d.ts +27 -0
  61. package/package.json +89 -3
  62. package/schema/app.schema.json +184 -0
  63. package/schema/dashboard.schema.json +940 -0
  64. package/tools/dashboards.js +90 -0
  65. package/tools/metro.js +21 -0
@@ -0,0 +1,62 @@
1
+ import { type DataFrame, type Field } from '../core/frame';
2
+ import type { FieldConfig, Panel } from '../core/schema';
3
+ export type CellType = 'auto' | 'color-text' | 'color-background' | 'gauge';
4
+ export interface TableColumn {
5
+ key: string;
6
+ field: Field;
7
+ name: string;
8
+ config: FieldConfig;
9
+ width: number;
10
+ align: 'left' | 'center' | 'right';
11
+ cellType: CellType;
12
+ /** color-background only: the whole row takes this column's color. */
13
+ applyToRow: boolean;
14
+ wrap: boolean;
15
+ /** Numeric range of the column, for gauges and continuous colors without min/max. */
16
+ extent?: [number, number];
17
+ /** Footer calculations for this column (`custom.footer.reducers`, or the older `options.footer`). */
18
+ reducers: string[];
19
+ }
20
+ export interface CellDisplay {
21
+ text: string;
22
+ /** Text color, for color-text cells. */
23
+ color?: string;
24
+ /** Cell (or row) background, for color-background cells. */
25
+ background?: string;
26
+ /** 0..1 fill, for gauge cells. */
27
+ gauge?: number;
28
+ gaugeColor?: string;
29
+ }
30
+ /** The visible columns of a table frame, with each field's effective config. */
31
+ export declare function tableColumns(panel: Panel, frame: DataFrame, multipleFrames?: boolean): TableColumn[];
32
+ export interface FooterLine {
33
+ /** The calculation's name, shown when a column has more than one. */
34
+ label?: string;
35
+ text: string;
36
+ }
37
+ /**
38
+ * Footer text per column, or null when no column has a footer. "countAll" (the total row count) is shown once,
39
+ * in the first column that asks for it. Calculations that need numbers are left blank on text columns.
40
+ */
41
+ export declare function tableFooter(columns: TableColumn[]): FooterLine[][] | null;
42
+ /**
43
+ * How one cell reads: mapped text, else the value formatted with the field's unit and decimals, else `noValue`
44
+ * for a null. Colored cell types take the mapping's color, else the thresholds' (or color scheme's).
45
+ */
46
+ export declare function cellDisplay(col: TableColumn, raw: unknown, fallbackColor: string): CellDisplay;
47
+ /** Black or white, whichever reads better on a background color. */
48
+ export declare function contrastText(background: string, fallback: string): string;
49
+ export interface TableSort {
50
+ /** TableColumn.key */
51
+ key: string;
52
+ desc: boolean;
53
+ }
54
+ /** The panel's starting sort, from `options.sortBy` (matched by display name, as Grafana saves it). */
55
+ export declare function initialSort(panel: Panel, columns: TableColumn[]): TableSort | null;
56
+ /** Tapping a header: ascending, then descending, then back to the query's order. */
57
+ export declare function nextSort(current: TableSort | null, key: string): TableSort | null;
58
+ /**
59
+ * Row indexes in display order. Numbers and times sort numerically, text naturally ("L9" before "L10"), and
60
+ * empty cells go last either way. Ties keep the query's order.
61
+ */
62
+ export declare function sortedRows(columns: TableColumn[], length: number, sort: TableSort | null): number[];
@@ -0,0 +1,21 @@
1
+ import { type ReactNode } from 'react';
2
+ export interface DashTheme {
3
+ scheme: 'light' | 'dark';
4
+ background: string;
5
+ surface: string;
6
+ border: string;
7
+ grid: string;
8
+ text: string;
9
+ textSecondary: string;
10
+ textMuted: string;
11
+ accent: string;
12
+ danger: string;
13
+ }
14
+ export declare const lightTheme: DashTheme;
15
+ export declare const darkTheme: DashTheme;
16
+ /** Optional: wrap to force or customize a theme. Without it, modelform follows the system color scheme. */
17
+ export declare function DashThemeProvider({ theme, children }: {
18
+ theme: DashTheme;
19
+ children: ReactNode;
20
+ }): import("react").JSX.Element;
21
+ export declare function useDashTheme(): DashTheme;
@@ -0,0 +1,27 @@
1
+ import { type DataFrame, type Field } from '../core/frame';
2
+ import type { FieldConfig, Panel } from '../core/schema';
3
+ export type XYShow = 'points' | 'lines' | 'points+lines';
4
+ export interface XYSeries {
5
+ key: string;
6
+ name: string;
7
+ /** Legend and line color. */
8
+ color: string;
9
+ frame: DataFrame;
10
+ xField: Field;
11
+ yField: Field;
12
+ xConfig: FieldConfig;
13
+ yConfig: FieldConfig;
14
+ /** Row indexes with both x and y set, in data order. */
15
+ rows: number[];
16
+ xs: number[];
17
+ ys: number[];
18
+ /** Per point, parallel to rows. */
19
+ colors: string[];
20
+ /** Point diameters in px, parallel to rows. */
21
+ sizes: number[];
22
+ show: XYShow;
23
+ lineWidth: number;
24
+ }
25
+ export declare function xySeries(panel: Panel, frames: DataFrame[], scheme: 'light' | 'dark'): XYSeries[];
26
+ /** [min, max] of an axis: the field config's min/max where set, else the data's, padded so no point sits on the edge. */
27
+ export declare function xyDomain(values: number[][], config: FieldConfig): [number, number];
package/package.json CHANGED
@@ -1,6 +1,92 @@
1
1
  {
2
2
  "name": "@modelform/react-native",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.1",
4
+ "description": "Render Grafana-compatible dashboard JSON, and input forms in the same format, as native React Native panels.",
5
+ "keywords": [
6
+ "react-native",
7
+ "expo",
8
+ "grafana",
9
+ "dashboard",
10
+ "charts",
11
+ "forms",
12
+ "json"
13
+ ],
14
+ "license": "MIT",
15
+ "author": "Todd Winstanley",
16
+ "homepage": "https://github.com/toddwinstanley/modelform#readme",
17
+ "bugs": {
18
+ "url": "https://github.com/toddwinstanley/modelform/issues"
19
+ },
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/toddwinstanley/modelform.git"
23
+ },
24
+ "main": "./dist/index.js",
25
+ "types": "./dist/index.d.ts",
26
+ "exports": {
27
+ ".": {
28
+ "types": "./dist/index.d.ts",
29
+ "import": "./dist/index.mjs",
30
+ "require": "./dist/index.js"
31
+ },
32
+ "./core": {
33
+ "types": "./dist/core/index.d.ts",
34
+ "import": "./dist/core/index.mjs",
35
+ "require": "./dist/core/index.js"
36
+ },
37
+ "./metro": "./tools/metro.js",
38
+ "./dashboards": "./tools/dashboards.js",
39
+ "./schema/*": "./schema/*",
40
+ "./package.json": "./package.json"
41
+ },
42
+ "bin": {
43
+ "modelform": "tools/dashboards.js"
44
+ },
45
+ "files": [
46
+ "dist",
47
+ "schema",
48
+ "tools/metro.js",
49
+ "tools/dashboards.js"
50
+ ],
51
+ "publishConfig": {
52
+ "access": "public"
53
+ },
54
+ "peerDependencies": {
55
+ "react": ">=19.0.0",
56
+ "react-native": ">=0.79.0",
57
+ "react-native-safe-area-context": ">=5.0.0",
58
+ "react-native-svg": ">=15.0.0"
59
+ },
60
+ "devDependencies": {
61
+ "@changesets/cli": "2.31.1",
62
+ "@types/react": "~19.3.0",
63
+ "eslint": "^9.39.5",
64
+ "eslint-config-expo": "~58.0.4",
65
+ "globals": "^14.0.0",
66
+ "jsdom": "30.1.3",
67
+ "react": "19.3.0",
68
+ "react-dom": "19.3.0",
69
+ "react-native": "0.88.0",
70
+ "react-native-safe-area-context": "~5.10.1",
71
+ "react-native-svg": "15.16.0",
72
+ "react-native-web": "~0.21.4",
73
+ "ts-json-schema-generator": "2.9.0",
74
+ "tsup": "8.5.1",
75
+ "typescript": "~6.0.3",
76
+ "vitest": "^4.0.0"
77
+ },
78
+ "dependencies": {
79
+ "ajv": "8.20.0",
80
+ "jsonc-parser": "3.3.1"
81
+ },
82
+ "scripts": {
83
+ "build": "tsup && tsc -p tsconfig.build.json",
84
+ "test": "vitest run",
85
+ "typecheck": "tsc --noEmit",
86
+ "lint": "eslint .",
87
+ "schema": "node tools/schema.js",
88
+ "changeset": "changeset",
89
+ "release": "changeset publish"
90
+ },
91
+ "module": "./dist/index.mjs"
6
92
  }
@@ -0,0 +1,184 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "urn:modelform:app",
4
+ "title": "modelform app config",
5
+ "$ref": "#/definitions/AppManifest",
6
+ "definitions": {
7
+ "AppManifest": {
8
+ "type": "object",
9
+ "properties": {
10
+ "version": {
11
+ "description": "Format version. Always 1 for now.",
12
+ "const": 1
13
+ },
14
+ "title": {
15
+ "type": "string",
16
+ "description": "The app's name.",
17
+ "minLength": 1
18
+ },
19
+ "tabs": {
20
+ "type": "array",
21
+ "items": {
22
+ "$ref": "#/definitions/Tab"
23
+ },
24
+ "description": "The bottom tabs, in order.",
25
+ "minItems": 1
26
+ },
27
+ "documents": {
28
+ "type": "object",
29
+ "additionalProperties": {
30
+ "anyOf": [
31
+ {
32
+ "type": "string"
33
+ },
34
+ {
35
+ "$ref": "#/definitions/Dashboard"
36
+ }
37
+ ]
38
+ },
39
+ "description": "Dashboards and forms by id: a path relative to this file, or the dashboard JSON inline."
40
+ }
41
+ },
42
+ "required": [
43
+ "version",
44
+ "title",
45
+ "tabs",
46
+ "documents"
47
+ ],
48
+ "additionalProperties": false,
49
+ "description": "The root of an app config: navigation, plus the documents it shows. Annotations here feed schema/app.schema.json."
50
+ },
51
+ "Tab": {
52
+ "type": "object",
53
+ "properties": {
54
+ "id": {
55
+ "type": "string",
56
+ "description": "Also the tab's route, so keep it URL-safe and stable.",
57
+ "pattern": "^[A-Za-z0-9_-]+$"
58
+ },
59
+ "title": {
60
+ "type": "string",
61
+ "minLength": 1
62
+ },
63
+ "icon": {
64
+ "anyOf": [
65
+ {
66
+ "type": "string"
67
+ },
68
+ {
69
+ "type": "object",
70
+ "properties": {
71
+ "ios": {
72
+ "type": "string"
73
+ },
74
+ "android": {
75
+ "type": "string"
76
+ },
77
+ "web": {
78
+ "type": "string"
79
+ }
80
+ },
81
+ "additionalProperties": false
82
+ }
83
+ ],
84
+ "description": "A name from the app's icon set (e.g. \"edit\", \"chart\"), or per-platform symbol names."
85
+ },
86
+ "screen": {
87
+ "$ref": "#/definitions/Screen"
88
+ }
89
+ },
90
+ "required": [
91
+ "id",
92
+ "title",
93
+ "screen"
94
+ ],
95
+ "additionalProperties": false
96
+ },
97
+ "Screen": {
98
+ "anyOf": [
99
+ {
100
+ "type": "object",
101
+ "properties": {
102
+ "type": {
103
+ "type": "string",
104
+ "const": "dashboard"
105
+ },
106
+ "dashboard": {
107
+ "type": "string"
108
+ }
109
+ },
110
+ "required": [
111
+ "type",
112
+ "dashboard"
113
+ ],
114
+ "additionalProperties": false
115
+ },
116
+ {
117
+ "type": "object",
118
+ "properties": {
119
+ "type": {
120
+ "type": "string",
121
+ "const": "forms"
122
+ },
123
+ "forms": {
124
+ "type": "array",
125
+ "items": {
126
+ "type": "string"
127
+ },
128
+ "minItems": 1
129
+ }
130
+ },
131
+ "required": [
132
+ "type",
133
+ "forms"
134
+ ],
135
+ "additionalProperties": false
136
+ },
137
+ {
138
+ "type": "object",
139
+ "properties": {
140
+ "type": {
141
+ "type": "string",
142
+ "const": "menu"
143
+ },
144
+ "items": {
145
+ "type": "array",
146
+ "items": {
147
+ "$ref": "#/definitions/MenuItem"
148
+ }
149
+ }
150
+ },
151
+ "required": [
152
+ "type",
153
+ "items"
154
+ ],
155
+ "additionalProperties": false
156
+ }
157
+ ]
158
+ },
159
+ "MenuItem": {
160
+ "type": "object",
161
+ "properties": {
162
+ "title": {
163
+ "type": "string",
164
+ "description": "Defaults to the document's title."
165
+ },
166
+ "description": {
167
+ "type": "string"
168
+ },
169
+ "dashboard": {
170
+ "type": "string",
171
+ "description": "A dashboard to open. Give this or `form`, not both."
172
+ },
173
+ "form": {
174
+ "type": "string",
175
+ "description": "A form to open. Give this or `dashboard`, not both."
176
+ }
177
+ },
178
+ "additionalProperties": false
179
+ },
180
+ "Dashboard": {
181
+ "$ref": "urn:modelform:dashboard"
182
+ }
183
+ }
184
+ }