You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/interface.md
+52-4Lines changed: 52 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -73,6 +73,7 @@ For instance:
73
73
- `number`: A numeric input field for entering numbers.
74
74
- `rating`: A component that allows users to provide feedback or evaluate an item using a star or point system, typically ranging from 1 to 5, visually represented through icons or bars.
75
75
- `slider`: A slider component that allows you to select a number.
76
+
- `range`: A range slider component that allows you to select a range of number.
76
77
- `select`: A dropdown menu that allows users to choose one or multiple items from a predefined list.
77
78
- `checkbox`: A binary input that allows users to select one or more items from a set of choices.
78
79
- `radio`: A set of options where only one can be selected at a time, typically displayed as buttons.
@@ -87,25 +88,44 @@ For instance:
87
88
#### All Field Properties:
88
89
- `type`: Specifies a supported field type as defined earlier.
89
90
- `label`: The title that will be displayed within the field.
91
+
- `default`: A optional default value for the current field.
90
92
- `multiple`: A boolean value that indicates whether the field can accept multiple values (e.g., for `select`, `checkbox` or `file` types).
93
+
- `icon`: (Optional) An icon that will be displayed next to the menu item.
91
94
- `accept`: For `file` field only. It takes as its value a comma-separated list of one or more file types. You can add file extensions `*.jpg,*.gif` or even mime types `application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document`.
95
+
- `rules`: An optional list of rules (regex) to be applied to the field. See rules section for explanation.
92
96
- `prepend`: An optional string that will be displayed before the input field.
93
97
- `append`: An optional string that will be displayed after the input field.
94
98
- `prepend-inner`: An optional string that will be displayed inside and before the input field. Can be used with `string`, `number`, `select`, `textarea` and `date` fields.'
95
99
- `append-inner`: An optional string that will be displayed inside and after the input field. Can be used with `string`, `number`, `select`, `textarea` and `date` fields.'
96
100
- `hint`: An optional string that provides additional information or guidance to the user about the field, displayed below the field.
97
-
- `icon`: (Optional) An icon that will be displayed next to the menu item.
98
101
- Make sure to prefix all icons with "mdi-". For instance: mdi-check will show the "check" icon.
- `required`: (Optional) It ensures that the user must provide a value, preventing the form from being submitted until the field is completed.
101
104
- `fields`: This is applicable only for `array` and `node` types. You can use any supported type here, and you can nest sub-arrays as needed to create complex data structures and hierarchies.
102
105
- `items`: This is applicable only for `select`, `checkbox` and `radio` types. You can list all available values or even use an enum.
103
-
- `min`: An optional minimum number. Works with `number`and `slider` fields.
104
-
- `max`: An optional maximum number. Works with `number`and `slider` fields.
106
+
- `min`: An optional minimum number. Works with `array`, `number`, `slider` and `range` fields.
107
+
- `max`: An optional maximum number. Works with `array`, `number`, `slider` and `range` fields.
105
108
- `length`: An optional length amount of stars in `rating` field.
106
-
- `step`: An optional incremental amount when using `number`and `slider` fields.
109
+
- `step`: An optional incremental amount when using `number`, `slider` and `range` fields.
107
110
- `half-increments`: (Optional) Allows half-increments of stars when using the `rating` field.
108
111
112
+
### Rules
113
+
114
+
You can create validation for your form using regex expressions. Here's an example of two rules for a field `title`. It will validate that the value of the title starts with `abc` and ends with `123`.
115
+
116
+
```yaml
117
+
title:
118
+
type: string
119
+
label: Title
120
+
rules:
121
+
- regex: /^abc/
122
+
message: The string must start with abc
123
+
- regex: /123$/
124
+
message: The string must end with 123
125
+
```
126
+
127
+
Fields `number` automatically includes a rule for checking number values.
128
+
109
129
### Paths
110
130
111
131
If you want to synchronize your sections with your website or app pages, you need to define paths. By default, if you do not set this parameter, JSON.ms will still try to find a route name matching the section key (in this case, "about").
@@ -202,3 +222,31 @@ Here's an example of a field using an enum:
202
222
label: Title
203
223
items: enums.countries
204
224
```
225
+
226
+
## Schemas
227
+
228
+
Reusable schemas (fieldset) are a powerful feature that allows you to define a set of predefined fields that can be referenced multiple times throughout your interface. This promotes consistency in your data definitions and reduces redundancy, making your code cleaner and easier to maintain.
229
+
230
+
```yaml
231
+
schemas:
232
+
meta:
233
+
title:
234
+
type: string
235
+
label: Title
236
+
required: true
237
+
description:
238
+
type: string
239
+
label: Description
240
+
```
241
+
242
+
You can later use these schemas as a field type like any other widget using the `schemas.[NAME]` syntax.
243
+
244
+
Here's an example of a field using an schema:
245
+
246
+
```yaml
247
+
meta:
248
+
type: schemas.meta
249
+
label: Meta data # (Optional) A title for your collapsable group
0 commit comments