Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

version the form definition #96

Merged
merged 6 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
330 changes: 330 additions & 0 deletions fixtures/data-v0.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,330 @@
{
"editorPosition": "mainView",
"formDefinitions": [
{
"title": "Kill bugs softly",
"name": "kill-bugs",
"fields": [
{
"name": "num",
"label": "Number of people",
"description": "Be nice",
"input": {
"type": "number",
"source": "notes",
"options": [
{
"label": "",
"value": ""
},
{
"label": "",
"value": ""
}
],
"folder": "Books"
}
},
{
"name": "lol",
"label": "Lol",
"description": "Super lol",
"input": {
"type": "select",
"source": "fixed",
"options": [
{
"label": "First",
"value": "1"
},
{
"label": "Second",
"value": "2"
}
],
"folder": "People"
}
}
]
},
{
"title": "Is example",
"name": "example-form",
"fields": [
{
"name": "second",
"label": "Second",
"description": "Slide it",
"input": {
"type": "slider",
"min": 1,
"max": 12
}
},
{
"name": "dataview",
"label": "persons",
"description": "This is persons dv",
"input": {
"type": "dataview",
"query": "dv.pages('#person').map(p=>p.file.name)"
}
},
{
"name": "toggle",
"label": "Toggle",
"description": "Yes or no",
"input": {
"type": "toggle"
}
},
{
"name": "multi_books",
"label": "Books read",
"description": "they are nice",
"input": {
"type": "multiselect",
"source": "notes",
"folder": "Books",
"min": 1,
"max": 11
}
},
{
"name": "select",
"label": "Select",
"description": "Pick a value",
"input": {
"type": "select",
"source": "fixed",
"options": [
{
"label": "First",
"value": "first"
},
{
"label": "Second",
"value": "second"
}
]
}
},
{
"name": "multi_2",
"label": "Multi select fixed",
"description": "Pick some values",
"input": {
"type": "multiselect",
"source": "fixed",
"options": [
"static one",
"static two",
""
],
"multi_select_options": [
"first",
"second",
"LOL"
]
}
},
{
"name": "text_area",
"label": "",
"description": "Multi line",
"input": {
"type": "textarea"
}
},
{
"name": "text_area_1",
"label": "",
"description": "Multi line",
"input": {
"type": "textarea"
}
}
]
},
{
"title": "New form",
"name": "Suggesters",
"fields": [
{
"name": "automata",
"label": "Automata type",
"description": "LOL",
"input": {
"type": "select",
"source": "fixed",
"multi_select_options": [
""
],
"options": [
{
"value": "robot",
"label": "🤖 Robot"
},
{
"value": "huan",
"label": "Human"
}
]
}
},
{
"name": "select_notes",
"label": "Select notes",
"description": "Les notes",
"input": {
"type": "select",
"source": "notes",
"multi_select_options": [
""
],
"options": [
{
"value": "robot",
"label": "🤖 Robot"
},
{
"value": "huan",
"label": "Human"
}
],
"folder": "Books"
}
},
{
"name": "note",
"label": "Suggest note",
"description": "pick a note",
"input": {
"type": "note",
"folder": "People"
}
}
]
},
{
"title": "New form",
"name": "Suggesters-copy",
"fields": [
{
"name": "automata",
"label": "Automata type",
"description": "LOL",
"input": {
"type": "select",
"source": "fixed",
"multi_select_options": [
""
],
"options": [
{
"value": "robot",
"label": "🤖 Robot"
},
{
"value": "huan",
"label": "Human"
}
]
}
},
{
"name": "select_notes",
"label": "Select notes",
"description": "Les notes",
"input": {
"type": "select",
"source": "notes",
"multi_select_options": [
""
],
"options": [
{
"value": "robot",
"label": "🤖 Robot"
},
{
"value": "huan",
"label": "Human"
}
],
"folder": "Books"
}
},
{
"name": "note",
"label": "Suggest note",
"description": "pick a note",
"input": {
"type": "note",
"folder": "People"
}
}
]
},
{
"title": "New form",
"name": "Suggesters renamed",
"fields": [
{
"name": "automata",
"label": "Automata type",
"description": "LOL",
"input": {
"type": "select",
"source": "fixed",
"multi_select_options": [
""
],
"options": [
{
"value": "robot",
"label": "🤖 Robot"
},
{
"value": "huan",
"label": "Human"
}
]
}
},
{
"name": "select_notes",
"label": "Select notes",
"description": "Les notes",
"input": {
"type": "select",
"source": "notes",
"multi_select_options": [
""
],
"options": [
{
"value": "robot",
"label": "🤖 Robot"
},
{
"value": "huan",
"label": "Human"
}
],
"folder": "Books"
}
},
{
"name": "note",
"label": "Suggest note",
"description": "pick a note",
"input": {
"type": "note",
"folder": "People"
}
}
]
}
]
}
10 changes: 8 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
"typescript": "^5.2.2"
},
"dependencies": {
"fp-ts": "^2.16.1",
"fuse.js": "^6.6.2",
"valibot": "^0.19.0"
}
}
}
17 changes: 0 additions & 17 deletions src/core/formDefinition.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,6 @@ import {
} from "./formDefinition";
import { parse } from "valibot";

describe("FieldTypeReadable", () => {
it("should have the correct readable names for field types", () => {
expect(FieldTypeReadable.text).toBe("Text");
expect(FieldTypeReadable.number).toBe("Number");
expect(FieldTypeReadable.date).toBe("Date");
expect(FieldTypeReadable.time).toBe("Time");
expect(FieldTypeReadable.datetime).toBe("DateTime");
expect(FieldTypeReadable.textarea).toBe("Text area");
expect(FieldTypeReadable.toggle).toBe("Toggle");
expect(FieldTypeReadable.note).toBe("Note");
expect(FieldTypeReadable.slider).toBe("Slider");
expect(FieldTypeReadable.select).toBe("Select");
expect(FieldTypeReadable.dataview).toBe("Dataview");
expect(FieldTypeReadable.multiselect).toBe("Multiselect");
});
});

describe("isDataViewSource", () => {
it("should return true for valid inputDataviewSource objects", () => {
expect(
Expand Down
Loading