@modelform/react-native 0.4.0 → 0.6.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/README.md +21 -1
- package/dist/{chunk-ATRMUHKJ.mjs → chunk-BW6HKFAB.mjs} +1079 -372
- package/dist/{chunk-WMRDOYPV.js → chunk-YUXA7I4J.js} +1179 -472
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.js +42 -2
- package/dist/core/index.mjs +41 -1
- package/dist/core/inputs.d.ts +71 -1
- package/dist/core/local.d.ts +4 -0
- package/dist/core/snippets.d.ts +4 -0
- package/dist/core/templates.d.ts +74 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +547 -314
- package/dist/index.mjs +508 -275
- package/dist/ui/inputs/InputGroup.d.ts +9 -0
- package/dist/ui/inputs/formContext.d.ts +22 -1
- package/package.json +1 -1
- package/schema/dashboard.schema.json +113 -2
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type InputGroupPanel } from '../../core/inputs';
|
|
2
|
+
/**
|
|
3
|
+
* An input-group panel: a card per item with the group's fields, and buttons to add,
|
|
4
|
+
* duplicate, move and remove items. Each item's fields are the ordinary input components,
|
|
5
|
+
* reading and writing that item through a form context of their own.
|
|
6
|
+
*/
|
|
7
|
+
export declare function InputGroupBody({ panel }: {
|
|
8
|
+
panel: InputGroupPanel;
|
|
9
|
+
}): import("react").JSX.Element | null;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type GroupItem, type InputChoice, type InputGroupPanel, type InputValue } from '../../core/inputs';
|
|
2
2
|
import type { EntryStore } from '../../core/local';
|
|
3
3
|
export interface InputFormState {
|
|
4
4
|
value(metric: string): InputValue;
|
|
@@ -9,6 +9,27 @@ export interface InputFormState {
|
|
|
9
9
|
choices: Record<string, InputChoice[]>;
|
|
10
10
|
/** Why the input's value can't be saved, once that's worth showing. */
|
|
11
11
|
problem?(metric: string): string | undefined;
|
|
12
|
+
/** An input-group's items and what can be done to them. Missing outside an InputForm that supports groups. */
|
|
13
|
+
group?(panel: InputGroupPanel): FormGroup;
|
|
12
14
|
}
|
|
15
|
+
/** One input-group as the form holds it. Indexes are positions in `items`. */
|
|
16
|
+
export interface FormGroup {
|
|
17
|
+
items: {
|
|
18
|
+
key: string;
|
|
19
|
+
values: GroupItem;
|
|
20
|
+
edited: string[];
|
|
21
|
+
}[];
|
|
22
|
+
canAdd: boolean;
|
|
23
|
+
/** Why the group as a whole can't be saved (too few items), once that's worth showing. */
|
|
24
|
+
problem?: string;
|
|
25
|
+
add(): void;
|
|
26
|
+
duplicate(index: number): void;
|
|
27
|
+
remove(index: number): void;
|
|
28
|
+
move(index: number, by: number): void;
|
|
29
|
+
setValue(index: number, metric: string, v: InputValue): void;
|
|
30
|
+
fieldProblem(index: number, metric: string): string | undefined;
|
|
31
|
+
}
|
|
32
|
+
/** Identifies a group within its form: its panel id, or its fields' metrics. */
|
|
33
|
+
export declare const groupKey: (g: InputGroupPanel) => string;
|
|
13
34
|
export declare const InputFormContext: import("react").Context<InputFormState | null>;
|
|
14
35
|
export declare function useInputForm(): InputFormState;
|
package/package.json
CHANGED
|
@@ -129,7 +129,8 @@
|
|
|
129
129
|
"input-rating",
|
|
130
130
|
"input-text",
|
|
131
131
|
"input-counter",
|
|
132
|
-
"input-duration"
|
|
132
|
+
"input-duration",
|
|
133
|
+
"input-group"
|
|
133
134
|
]
|
|
134
135
|
},
|
|
135
136
|
"title": {
|
|
@@ -264,7 +265,7 @@
|
|
|
264
265
|
"if": {
|
|
265
266
|
"properties": {
|
|
266
267
|
"type": {
|
|
267
|
-
"pattern": "^input-"
|
|
268
|
+
"pattern": "^input-(?!group$)"
|
|
268
269
|
}
|
|
269
270
|
},
|
|
270
271
|
"required": [
|
|
@@ -281,6 +282,28 @@
|
|
|
281
282
|
}
|
|
282
283
|
}
|
|
283
284
|
}
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
"if": {
|
|
288
|
+
"properties": {
|
|
289
|
+
"type": {
|
|
290
|
+
"const": "input-group"
|
|
291
|
+
}
|
|
292
|
+
},
|
|
293
|
+
"required": [
|
|
294
|
+
"type"
|
|
295
|
+
]
|
|
296
|
+
},
|
|
297
|
+
"then": {
|
|
298
|
+
"required": [
|
|
299
|
+
"options"
|
|
300
|
+
],
|
|
301
|
+
"properties": {
|
|
302
|
+
"options": {
|
|
303
|
+
"$ref": "#/definitions/InputGroupOptions"
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
284
307
|
}
|
|
285
308
|
]
|
|
286
309
|
},
|
|
@@ -935,6 +958,94 @@
|
|
|
935
958
|
"label",
|
|
936
959
|
"value"
|
|
937
960
|
]
|
|
961
|
+
},
|
|
962
|
+
"InputGroupOptions": {
|
|
963
|
+
"type": "object",
|
|
964
|
+
"properties": {
|
|
965
|
+
"fields": {
|
|
966
|
+
"type": "array",
|
|
967
|
+
"items": {
|
|
968
|
+
"$ref": "#/definitions/GroupField"
|
|
969
|
+
},
|
|
970
|
+
"description": "The inputs each item has. Any input type but input-counter."
|
|
971
|
+
},
|
|
972
|
+
"itemTitle": {
|
|
973
|
+
"type": "string",
|
|
974
|
+
"description": "Items are titled \"<itemTitle> 1\", \"<itemTitle> 2\"… (default \"Item\")."
|
|
975
|
+
},
|
|
976
|
+
"titleFrom": {
|
|
977
|
+
"type": "string",
|
|
978
|
+
"description": "A field's metric whose value titles its item once it has one."
|
|
979
|
+
},
|
|
980
|
+
"min": {
|
|
981
|
+
"type": "number",
|
|
982
|
+
"description": "Fewest items Save accepts (default 0). Items left completely empty don't count."
|
|
983
|
+
},
|
|
984
|
+
"max": {
|
|
985
|
+
"type": "number",
|
|
986
|
+
"description": "Most items the user can add."
|
|
987
|
+
},
|
|
988
|
+
"start": {
|
|
989
|
+
"anyOf": [
|
|
990
|
+
{
|
|
991
|
+
"type": "number"
|
|
992
|
+
},
|
|
993
|
+
{
|
|
994
|
+
"type": "string",
|
|
995
|
+
"const": "last"
|
|
996
|
+
}
|
|
997
|
+
],
|
|
998
|
+
"description": "Empty items a new form starts with (default 1), or \"last\" for the items saved last time."
|
|
999
|
+
},
|
|
1000
|
+
"addLabel": {
|
|
1001
|
+
"type": "string",
|
|
1002
|
+
"description": "Text of the add button (default \"Add <itemTitle>\")."
|
|
1003
|
+
}
|
|
1004
|
+
},
|
|
1005
|
+
"required": [
|
|
1006
|
+
"fields"
|
|
1007
|
+
],
|
|
1008
|
+
"description": "input-group: fields filled in once per item, for as many items as the user adds (the entree and sides of a meal, the sets of a workout). Each field records to its own metric; entries of one item share `save` and `item`."
|
|
1009
|
+
},
|
|
1010
|
+
"GroupField": {
|
|
1011
|
+
"type": "object",
|
|
1012
|
+
"properties": {
|
|
1013
|
+
"type": {
|
|
1014
|
+
"$ref": "#/definitions/InputType"
|
|
1015
|
+
},
|
|
1016
|
+
"title": {
|
|
1017
|
+
"type": "string"
|
|
1018
|
+
},
|
|
1019
|
+
"description": {
|
|
1020
|
+
"type": "string"
|
|
1021
|
+
},
|
|
1022
|
+
"span": {
|
|
1023
|
+
"type": "number",
|
|
1024
|
+
"description": "Width inside an item, out of 24 (default 24)."
|
|
1025
|
+
},
|
|
1026
|
+
"options": {
|
|
1027
|
+
"$ref": "#/definitions/InputOptions"
|
|
1028
|
+
}
|
|
1029
|
+
},
|
|
1030
|
+
"required": [
|
|
1031
|
+
"type",
|
|
1032
|
+
"options"
|
|
1033
|
+
],
|
|
1034
|
+
"description": "One field of an input-group: an input panel without `id` or `gridPos`, `span` columns (of 24) wide in its item."
|
|
1035
|
+
},
|
|
1036
|
+
"InputType": {
|
|
1037
|
+
"type": "string",
|
|
1038
|
+
"enum": [
|
|
1039
|
+
"input-number",
|
|
1040
|
+
"input-slider",
|
|
1041
|
+
"input-select",
|
|
1042
|
+
"input-toggle",
|
|
1043
|
+
"input-rating",
|
|
1044
|
+
"input-text",
|
|
1045
|
+
"input-counter",
|
|
1046
|
+
"input-duration"
|
|
1047
|
+
],
|
|
1048
|
+
"description": "Input forms reuse the dashboard format: a form is a dashboard whose panels have `input-*` types. Layout, rows and gridPos work exactly like visualization panels, so one layout engine (and one hot-reloadable JSON file) drives both tabs.\n\n { \"type\": \"input-number\", \"title\": \"Weight\", \"gridPos\": {\"x\":0,\"y\":0,\"w\":12,\"h\":3}, \"options\": { \"metric\": \"weight\", \"unit\": \"kg\", \"step\": 0.1, \"default\": \"last\" } }"
|
|
938
1049
|
}
|
|
939
1050
|
}
|
|
940
1051
|
}
|