@tsed/schema-formio 8.11.1 → 8.12.0-rc.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.
- package/lib/esm/components/anyToComponent.js +0 -1
- package/lib/esm/components/arrayToComponent.js +0 -1
- package/lib/esm/components/booleanToComponent.js +0 -1
- package/lib/esm/components/dateToComponent.js +0 -1
- package/lib/esm/components/defaultToComponent.js +0 -1
- package/lib/esm/components/enumToComponent.js +0 -1
- package/lib/esm/components/mapToComponent.js +0 -1
- package/lib/esm/components/nestedToComponent.js +0 -1
- package/lib/esm/components/numberToComponent.js +0 -1
- package/lib/esm/components/objectToEditGrid.js +0 -1
- package/lib/esm/components/panelToComponent.js +0 -1
- package/lib/esm/components/propertiesToComponents.js +0 -1
- package/lib/esm/components/stringToComponent.js +0 -1
- package/lib/esm/decorators/component.js +0 -1
- package/lib/esm/decorators/conditional.js +0 -1
- package/lib/esm/decorators/currency.js +0 -1
- package/lib/esm/decorators/customClass.js +0 -1
- package/lib/esm/decorators/customConditional.js +0 -1
- package/lib/esm/decorators/dataSourceJson.js +0 -1
- package/lib/esm/decorators/dataSourceUrl.js +0 -1
- package/lib/esm/decorators/errorLabel.js +0 -1
- package/lib/esm/decorators/errorMessage.js +0 -1
- package/lib/esm/decorators/form.js +0 -1
- package/lib/esm/decorators/hidden.js +0 -1
- package/lib/esm/decorators/inputTags.js +0 -1
- package/lib/esm/decorators/label.js +0 -1
- package/lib/esm/decorators/mask.js +0 -1
- package/lib/esm/decorators/maxWords.js +0 -1
- package/lib/esm/decorators/minWords.js +0 -1
- package/lib/esm/decorators/modalEdit.js +0 -1
- package/lib/esm/decorators/multiple.js +0 -1
- package/lib/esm/decorators/openWhenEmpty.js +0 -1
- package/lib/esm/decorators/password.js +0 -1
- package/lib/esm/decorators/placeholder.js +0 -1
- package/lib/esm/decorators/prefix.js +0 -1
- package/lib/esm/decorators/select.js +0 -1
- package/lib/esm/decorators/suffix.js +0 -1
- package/lib/esm/decorators/tableView.js +0 -1
- package/lib/esm/decorators/tabs.js +0 -1
- package/lib/esm/decorators/textCase.js +0 -1
- package/lib/esm/decorators/textarea.js +0 -1
- package/lib/esm/decorators/tooltip.js +0 -1
- package/lib/esm/decorators/validate.js +0 -1
- package/lib/esm/index.js +0 -1
- package/lib/esm/interfaces/FormioDataResolver.js +0 -1
- package/lib/esm/registries/FormioMappersContainer.js +0 -1
- package/lib/esm/registries/FormsContainer.js +0 -1
- package/lib/esm/utils/getFormioProps.js +0 -1
- package/lib/esm/utils/getFormioSchema.js +0 -1
- package/lib/esm/utils/getRef.js +0 -1
- package/package.json +14 -12
- package/lib/browser/components/anyToComponent.js +0 -23
- package/lib/browser/components/anyToComponent.js.map +0 -1
- package/lib/browser/components/arrayToComponent.js +0 -36
- package/lib/browser/components/arrayToComponent.js.map +0 -1
- package/lib/browser/components/booleanToComponent.js +0 -12
- package/lib/browser/components/booleanToComponent.js.map +0 -1
- package/lib/browser/components/dateToComponent.js +0 -57
- package/lib/browser/components/dateToComponent.js.map +0 -1
- package/lib/browser/components/defaultToComponent.js +0 -17
- package/lib/browser/components/defaultToComponent.js.map +0 -1
- package/lib/browser/components/enumToComponent.js +0 -27
- package/lib/browser/components/enumToComponent.js.map +0 -1
- package/lib/browser/components/mapToComponent.js +0 -19
- package/lib/browser/components/mapToComponent.js.map +0 -1
- package/lib/browser/components/nestedToComponent.js +0 -24
- package/lib/browser/components/nestedToComponent.js.map +0 -1
- package/lib/browser/components/numberToComponent.js +0 -20
- package/lib/browser/components/numberToComponent.js.map +0 -1
- package/lib/browser/components/objectToEditGrid.js +0 -15
- package/lib/browser/components/objectToEditGrid.js.map +0 -1
- package/lib/browser/components/panelToComponent.js +0 -15
- package/lib/browser/components/panelToComponent.js.map +0 -1
- package/lib/browser/components/propertiesToComponents.js +0 -66
- package/lib/browser/components/propertiesToComponents.js.map +0 -1
- package/lib/browser/components/stringToComponent.js +0 -42
- package/lib/browser/components/stringToComponent.js.map +0 -1
- package/lib/browser/decorators/component.js +0 -18
- package/lib/browser/decorators/component.js.map +0 -1
- package/lib/browser/decorators/conditional.js +0 -26
- package/lib/browser/decorators/conditional.js.map +0 -1
- package/lib/browser/decorators/currency.js +0 -16
- package/lib/browser/decorators/currency.js.map +0 -1
- package/lib/browser/decorators/customClass.js +0 -10
- package/lib/browser/decorators/customClass.js.map +0 -1
- package/lib/browser/decorators/customConditional.js +0 -16
- package/lib/browser/decorators/customConditional.js.map +0 -1
- package/lib/browser/decorators/dataSourceJson.js +0 -20
- package/lib/browser/decorators/dataSourceJson.js.map +0 -1
- package/lib/browser/decorators/dataSourceUrl.js +0 -15
- package/lib/browser/decorators/dataSourceUrl.js.map +0 -1
- package/lib/browser/decorators/errorLabel.js +0 -10
- package/lib/browser/decorators/errorLabel.js.map +0 -1
- package/lib/browser/decorators/errorMessage.js +0 -8
- package/lib/browser/decorators/errorMessage.js.map +0 -1
- package/lib/browser/decorators/form.js +0 -20
- package/lib/browser/decorators/form.js.map +0 -1
- package/lib/browser/decorators/hidden.js +0 -10
- package/lib/browser/decorators/hidden.js.map +0 -1
- package/lib/browser/decorators/inputTags.js +0 -18
- package/lib/browser/decorators/inputTags.js.map +0 -1
- package/lib/browser/decorators/label.js +0 -11
- package/lib/browser/decorators/label.js.map +0 -1
- package/lib/browser/decorators/mask.js +0 -17
- package/lib/browser/decorators/mask.js.map +0 -1
- package/lib/browser/decorators/maxWords.js +0 -8
- package/lib/browser/decorators/maxWords.js.map +0 -1
- package/lib/browser/decorators/minWords.js +0 -8
- package/lib/browser/decorators/minWords.js.map +0 -1
- package/lib/browser/decorators/modalEdit.js +0 -10
- package/lib/browser/decorators/modalEdit.js.map +0 -1
- package/lib/browser/decorators/multiple.js +0 -10
- package/lib/browser/decorators/multiple.js.map +0 -1
- package/lib/browser/decorators/openWhenEmpty.js +0 -10
- package/lib/browser/decorators/openWhenEmpty.js.map +0 -1
- package/lib/browser/decorators/password.js +0 -12
- package/lib/browser/decorators/password.js.map +0 -1
- package/lib/browser/decorators/placeholder.js +0 -10
- package/lib/browser/decorators/placeholder.js.map +0 -1
- package/lib/browser/decorators/prefix.js +0 -10
- package/lib/browser/decorators/prefix.js.map +0 -1
- package/lib/browser/decorators/select.js +0 -14
- package/lib/browser/decorators/select.js.map +0 -1
- package/lib/browser/decorators/suffix.js +0 -10
- package/lib/browser/decorators/suffix.js.map +0 -1
- package/lib/browser/decorators/tableView.js +0 -10
- package/lib/browser/decorators/tableView.js.map +0 -1
- package/lib/browser/decorators/tabs.js +0 -14
- package/lib/browser/decorators/tabs.js.map +0 -1
- package/lib/browser/decorators/textCase.js +0 -10
- package/lib/browser/decorators/textCase.js.map +0 -1
- package/lib/browser/decorators/textarea.js +0 -12
- package/lib/browser/decorators/textarea.js.map +0 -1
- package/lib/browser/decorators/tooltip.js +0 -10
- package/lib/browser/decorators/tooltip.js.map +0 -1
- package/lib/browser/decorators/validate.js +0 -12
- package/lib/browser/decorators/validate.js.map +0 -1
- package/lib/browser/index.js +0 -102
- package/lib/browser/index.js.map +0 -1
- package/lib/browser/registries/FormioMappersContainer.js +0 -18
- package/lib/browser/registries/FormioMappersContainer.js.map +0 -1
- package/lib/browser/registries/FormsContainer.js +0 -5
- package/lib/browser/registries/FormsContainer.js.map +0 -1
- package/lib/browser/utils/getFormioProps.js +0 -10
- package/lib/browser/utils/getFormioProps.js.map +0 -1
- package/lib/browser/utils/getFormioSchema.js +0 -45
- package/lib/browser/utils/getFormioSchema.js.map +0 -1
- package/lib/browser/utils/getRef.js +0 -8
- package/lib/browser/utils/getRef.js.map +0 -1
- package/lib/esm/components/anyToComponent.js.map +0 -1
- package/lib/esm/components/arrayToComponent.js.map +0 -1
- package/lib/esm/components/booleanToComponent.js.map +0 -1
- package/lib/esm/components/dateToComponent.js.map +0 -1
- package/lib/esm/components/defaultToComponent.js.map +0 -1
- package/lib/esm/components/enumToComponent.js.map +0 -1
- package/lib/esm/components/mapToComponent.js.map +0 -1
- package/lib/esm/components/nestedToComponent.js.map +0 -1
- package/lib/esm/components/numberToComponent.js.map +0 -1
- package/lib/esm/components/objectToEditGrid.js.map +0 -1
- package/lib/esm/components/panelToComponent.js.map +0 -1
- package/lib/esm/components/propertiesToComponents.js.map +0 -1
- package/lib/esm/components/stringToComponent.js.map +0 -1
- package/lib/esm/decorators/component.js.map +0 -1
- package/lib/esm/decorators/conditional.js.map +0 -1
- package/lib/esm/decorators/currency.js.map +0 -1
- package/lib/esm/decorators/customClass.js.map +0 -1
- package/lib/esm/decorators/customConditional.js.map +0 -1
- package/lib/esm/decorators/dataSourceJson.js.map +0 -1
- package/lib/esm/decorators/dataSourceUrl.js.map +0 -1
- package/lib/esm/decorators/errorLabel.js.map +0 -1
- package/lib/esm/decorators/errorMessage.js.map +0 -1
- package/lib/esm/decorators/form.js.map +0 -1
- package/lib/esm/decorators/hidden.js.map +0 -1
- package/lib/esm/decorators/inputTags.js.map +0 -1
- package/lib/esm/decorators/label.js.map +0 -1
- package/lib/esm/decorators/mask.js.map +0 -1
- package/lib/esm/decorators/maxWords.js.map +0 -1
- package/lib/esm/decorators/minWords.js.map +0 -1
- package/lib/esm/decorators/modalEdit.js.map +0 -1
- package/lib/esm/decorators/multiple.js.map +0 -1
- package/lib/esm/decorators/openWhenEmpty.js.map +0 -1
- package/lib/esm/decorators/password.js.map +0 -1
- package/lib/esm/decorators/placeholder.js.map +0 -1
- package/lib/esm/decorators/prefix.js.map +0 -1
- package/lib/esm/decorators/select.js.map +0 -1
- package/lib/esm/decorators/suffix.js.map +0 -1
- package/lib/esm/decorators/tableView.js.map +0 -1
- package/lib/esm/decorators/tabs.js.map +0 -1
- package/lib/esm/decorators/textCase.js.map +0 -1
- package/lib/esm/decorators/textarea.js.map +0 -1
- package/lib/esm/decorators/tooltip.js.map +0 -1
- package/lib/esm/decorators/validate.js.map +0 -1
- package/lib/esm/index.js.map +0 -1
- package/lib/esm/interfaces/FormioDataResolver.js.map +0 -1
- package/lib/esm/registries/FormioMappersContainer.js.map +0 -1
- package/lib/esm/registries/FormsContainer.js.map +0 -1
- package/lib/esm/utils/getFormioProps.js.map +0 -1
- package/lib/esm/utils/getFormioSchema.js.map +0 -1
- package/lib/esm/utils/getRef.js.map +0 -1
- package/src/components/anyToComponent.ts +0 -28
- package/src/components/arrayToComponent.ts +0 -43
- package/src/components/booleanToComponent.ts +0 -15
- package/src/components/dateToComponent.ts +0 -66
- package/src/components/defaultToComponent.ts +0 -17
- package/src/components/enumToComponent.ts +0 -33
- package/src/components/mapToComponent.ts +0 -17
- package/src/components/nestedToComponent.ts +0 -23
- package/src/components/numberToComponent.ts +0 -20
- package/src/components/objectToEditGrid.ts +0 -13
- package/src/components/panelToComponent.ts +0 -13
- package/src/components/propertiesToComponents.ts +0 -106
- package/src/components/stringToComponent.ts +0 -44
- package/src/decorators/component.ts +0 -34
- package/src/decorators/conditional.spec.ts +0 -73
- package/src/decorators/conditional.ts +0 -49
- package/src/decorators/currency.spec.ts +0 -40
- package/src/decorators/currency.ts +0 -19
- package/src/decorators/customClass.spec.ts +0 -35
- package/src/decorators/customClass.ts +0 -14
- package/src/decorators/customConditional.spec.ts +0 -95
- package/src/decorators/customConditional.ts +0 -85
- package/src/decorators/dataSourceJson.spec.ts +0 -88
- package/src/decorators/dataSourceJson.ts +0 -26
- package/src/decorators/dataSourceUrl.spec.ts +0 -111
- package/src/decorators/dataSourceUrl.ts +0 -19
- package/src/decorators/errorLabel.spec.ts +0 -35
- package/src/decorators/errorLabel.ts +0 -14
- package/src/decorators/errorMessage.spec.ts +0 -35
- package/src/decorators/errorMessage.ts +0 -13
- package/src/decorators/form.ts +0 -25
- package/src/decorators/hidden.spec.ts +0 -35
- package/src/decorators/hidden.ts +0 -18
- package/src/decorators/inputTags.spec.ts +0 -36
- package/src/decorators/inputTags.ts +0 -22
- package/src/decorators/label.spec.ts +0 -34
- package/src/decorators/label.ts +0 -21
- package/src/decorators/mask.spec.ts +0 -105
- package/src/decorators/mask.ts +0 -46
- package/src/decorators/maxWords.spec.ts +0 -35
- package/src/decorators/maxWords.ts +0 -13
- package/src/decorators/minWords.spec.ts +0 -35
- package/src/decorators/minWords.ts +0 -13
- package/src/decorators/modalEdit.spec.ts +0 -35
- package/src/decorators/modalEdit.ts +0 -14
- package/src/decorators/multiple.spec.ts +0 -35
- package/src/decorators/multiple.ts +0 -14
- package/src/decorators/openWhenEmpty.ts +0 -14
- package/src/decorators/password.spec.ts +0 -35
- package/src/decorators/password.ts +0 -20
- package/src/decorators/placeholder.spec.ts +0 -35
- package/src/decorators/placeholder.ts +0 -15
- package/src/decorators/prefix.spec.ts +0 -35
- package/src/decorators/prefix.ts +0 -14
- package/src/decorators/select.spec.ts +0 -82
- package/src/decorators/select.ts +0 -25
- package/src/decorators/suffix.spec.ts +0 -35
- package/src/decorators/suffix.ts +0 -14
- package/src/decorators/tableView.spec.ts +0 -35
- package/src/decorators/tableView.ts +0 -15
- package/src/decorators/tabs.ts +0 -18
- package/src/decorators/textCase.spec.ts +0 -35
- package/src/decorators/textCase.ts +0 -15
- package/src/decorators/textarea.spec.ts +0 -35
- package/src/decorators/textarea.ts +0 -21
- package/src/decorators/tooltip.spec.ts +0 -35
- package/src/decorators/tooltip.ts +0 -15
- package/src/decorators/validate.ts +0 -18
- package/src/index.ts +0 -52
- package/src/interfaces/FormioDataResolver.ts +0 -5
- package/src/registries/FormioMappersContainer.ts +0 -21
- package/src/registries/FormsContainer.ts +0 -4
- package/src/utils/getFormioProps.ts +0 -12
- package/src/utils/getFormioSchema.spec.ts +0 -84
- package/src/utils/getFormioSchema.ts +0 -62
- package/src/utils/getRef.ts +0 -8
- package/vite.config.mts +0 -45
- package/vitest.config.mts +0 -21
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import {Enum} from "@tsed/schema";
|
|
2
|
-
|
|
3
|
-
import {getFormioSchema} from "../utils/getFormioSchema.js";
|
|
4
|
-
import {Select} from "./select.js";
|
|
5
|
-
|
|
6
|
-
describe("Select", () => {
|
|
7
|
-
it("should declare a model with select field", async () => {
|
|
8
|
-
class Model {
|
|
9
|
-
@Select()
|
|
10
|
-
test: string;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
expect(await getFormioSchema(Model)).toEqual({
|
|
14
|
-
components: [
|
|
15
|
-
{
|
|
16
|
-
disabled: false,
|
|
17
|
-
input: true,
|
|
18
|
-
key: "test",
|
|
19
|
-
label: "Test",
|
|
20
|
-
selectThreshold: 0.3,
|
|
21
|
-
type: "select",
|
|
22
|
-
validate: {
|
|
23
|
-
required: false
|
|
24
|
-
},
|
|
25
|
-
widget: "choicesjs"
|
|
26
|
-
}
|
|
27
|
-
],
|
|
28
|
-
display: "form",
|
|
29
|
-
machineName: "model",
|
|
30
|
-
name: "model",
|
|
31
|
-
title: "Model",
|
|
32
|
-
type: "form",
|
|
33
|
-
submissionAccess: [],
|
|
34
|
-
access: [],
|
|
35
|
-
tags: []
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
it("should with enum", async () => {
|
|
39
|
-
enum MyEnum {
|
|
40
|
-
TEST1 = "TEST1",
|
|
41
|
-
TEST2 = "TEST2"
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
class Model {
|
|
45
|
-
@Select()
|
|
46
|
-
@Enum(MyEnum)
|
|
47
|
-
test: MyEnum;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
expect(await getFormioSchema(Model)).toEqual({
|
|
51
|
-
access: [],
|
|
52
|
-
components: [
|
|
53
|
-
{
|
|
54
|
-
data: {
|
|
55
|
-
json: '[{"label":"TEST1","value":"TEST1"},{"label":"TEST2","value":"TEST2"}]'
|
|
56
|
-
},
|
|
57
|
-
dataSrc: "json",
|
|
58
|
-
disabled: false,
|
|
59
|
-
idPath: "value",
|
|
60
|
-
input: true,
|
|
61
|
-
key: "test",
|
|
62
|
-
label: "Test",
|
|
63
|
-
selectThreshold: 0.3,
|
|
64
|
-
template: "<span>{{ item.label }}</span>",
|
|
65
|
-
type: "select",
|
|
66
|
-
validate: {
|
|
67
|
-
required: false
|
|
68
|
-
},
|
|
69
|
-
valueProperty: "value",
|
|
70
|
-
widget: "choicesjs"
|
|
71
|
-
}
|
|
72
|
-
],
|
|
73
|
-
display: "form",
|
|
74
|
-
machineName: "model",
|
|
75
|
-
name: "model",
|
|
76
|
-
submissionAccess: [],
|
|
77
|
-
tags: [],
|
|
78
|
-
title: "Model",
|
|
79
|
-
type: "form"
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
});
|
package/src/decorators/select.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import {Component} from "./component.js";
|
|
2
|
-
|
|
3
|
-
export interface SelectOpts extends Record<string, any> {
|
|
4
|
-
idPath?: string;
|
|
5
|
-
valueProperty?: string;
|
|
6
|
-
template?: string;
|
|
7
|
-
multiple?: boolean;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Configure the property as Select component.
|
|
12
|
-
* @decorator
|
|
13
|
-
* @formio
|
|
14
|
-
* @property
|
|
15
|
-
* @schema
|
|
16
|
-
*/
|
|
17
|
-
export function Select(props: SelectOpts = {}): PropertyDecorator {
|
|
18
|
-
return Component({
|
|
19
|
-
selectThreshold: 0.3,
|
|
20
|
-
input: true,
|
|
21
|
-
widget: "choicesjs",
|
|
22
|
-
...props,
|
|
23
|
-
type: "select"
|
|
24
|
-
});
|
|
25
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import {getFormioSchema} from "../utils/getFormioSchema.js";
|
|
2
|
-
import {Suffix} from "./suffix.js";
|
|
3
|
-
|
|
4
|
-
describe("@Suffix", () => {
|
|
5
|
-
it("should add a suffix on field", async () => {
|
|
6
|
-
class Model {
|
|
7
|
-
@Suffix("The suffix")
|
|
8
|
-
test: string;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
expect(await getFormioSchema(Model)).toEqual({
|
|
12
|
-
access: [],
|
|
13
|
-
components: [
|
|
14
|
-
{
|
|
15
|
-
disabled: false,
|
|
16
|
-
input: true,
|
|
17
|
-
key: "test",
|
|
18
|
-
label: "Test",
|
|
19
|
-
suffix: "The suffix",
|
|
20
|
-
type: "textfield",
|
|
21
|
-
validate: {
|
|
22
|
-
required: false
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
],
|
|
26
|
-
display: "form",
|
|
27
|
-
machineName: "model",
|
|
28
|
-
name: "model",
|
|
29
|
-
submissionAccess: [],
|
|
30
|
-
tags: [],
|
|
31
|
-
title: "Model",
|
|
32
|
-
type: "form"
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
});
|
package/src/decorators/suffix.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import {getFormioSchema} from "../utils/getFormioSchema.js";
|
|
2
|
-
import {TableView} from "./tableView.js";
|
|
3
|
-
|
|
4
|
-
describe("@TableView", () => {
|
|
5
|
-
it("should change the table view option", async () => {
|
|
6
|
-
class Model {
|
|
7
|
-
@TableView(false)
|
|
8
|
-
test: string;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
expect(await getFormioSchema(Model)).toEqual({
|
|
12
|
-
access: [],
|
|
13
|
-
components: [
|
|
14
|
-
{
|
|
15
|
-
disabled: false,
|
|
16
|
-
input: true,
|
|
17
|
-
key: "test",
|
|
18
|
-
label: "Test",
|
|
19
|
-
type: "textfield",
|
|
20
|
-
tableView: false,
|
|
21
|
-
validate: {
|
|
22
|
-
required: false
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
],
|
|
26
|
-
display: "form",
|
|
27
|
-
machineName: "model",
|
|
28
|
-
name: "model",
|
|
29
|
-
submissionAccess: [],
|
|
30
|
-
tags: [],
|
|
31
|
-
title: "Model",
|
|
32
|
-
type: "form"
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
});
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import {Component} from "./component.js";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Change the visibility of the current property on a table.
|
|
5
|
-
* @param bool
|
|
6
|
-
* @decorator
|
|
7
|
-
* @formio
|
|
8
|
-
* @property
|
|
9
|
-
* @schema
|
|
10
|
-
*/
|
|
11
|
-
export function TableView(bool: boolean): PropertyDecorator {
|
|
12
|
-
return Component({
|
|
13
|
-
tableView: bool
|
|
14
|
-
});
|
|
15
|
-
}
|
package/src/decorators/tabs.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import {JsonEntityFn, JsonEntityStore} from "@tsed/schema";
|
|
2
|
-
import {camelCase} from "change-case";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Group the current property in tabs components.
|
|
6
|
-
* @decorator
|
|
7
|
-
* @formio
|
|
8
|
-
* @property
|
|
9
|
-
* @schema
|
|
10
|
-
*/
|
|
11
|
-
export function Tabs(label: string) {
|
|
12
|
-
return JsonEntityFn((store: JsonEntityStore) => {
|
|
13
|
-
store.schema.customKey("x-formiotabs", {
|
|
14
|
-
key: camelCase(label),
|
|
15
|
-
label
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import {getFormioSchema} from "../utils/getFormioSchema.js";
|
|
2
|
-
import {TextCase} from "./textCase.js";
|
|
3
|
-
|
|
4
|
-
describe("@TextCase", () => {
|
|
5
|
-
it("should change the case", async () => {
|
|
6
|
-
class Model {
|
|
7
|
-
@TextCase("lowercase")
|
|
8
|
-
test: string;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
expect(await getFormioSchema(Model)).toEqual({
|
|
12
|
-
access: [],
|
|
13
|
-
components: [
|
|
14
|
-
{
|
|
15
|
-
disabled: false,
|
|
16
|
-
input: true,
|
|
17
|
-
key: "test",
|
|
18
|
-
label: "Test",
|
|
19
|
-
case: "lowercase",
|
|
20
|
-
type: "textfield",
|
|
21
|
-
validate: {
|
|
22
|
-
required: false
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
],
|
|
26
|
-
display: "form",
|
|
27
|
-
machineName: "model",
|
|
28
|
-
name: "model",
|
|
29
|
-
submissionAccess: [],
|
|
30
|
-
tags: [],
|
|
31
|
-
title: "Model",
|
|
32
|
-
type: "form"
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
});
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import {Component} from "./component.js";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Force the output of this field to be sanitized in a specific format.
|
|
5
|
-
* @decorator
|
|
6
|
-
* @formio
|
|
7
|
-
* @property
|
|
8
|
-
* @schema
|
|
9
|
-
* @param textCase
|
|
10
|
-
*/
|
|
11
|
-
export function TextCase(textCase: "uppercase" | "lowercase") {
|
|
12
|
-
return Component({
|
|
13
|
-
case: textCase
|
|
14
|
-
});
|
|
15
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import {getFormioSchema} from "../utils/getFormioSchema.js";
|
|
2
|
-
import {Textarea} from "./textarea.js";
|
|
3
|
-
|
|
4
|
-
describe("Textarea", () => {
|
|
5
|
-
it("should declare a model with Textarea field", async () => {
|
|
6
|
-
class Model {
|
|
7
|
-
@Textarea()
|
|
8
|
-
test: string;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
expect(await getFormioSchema(Model)).toEqual({
|
|
12
|
-
components: [
|
|
13
|
-
{
|
|
14
|
-
autoExpand: false,
|
|
15
|
-
disabled: false,
|
|
16
|
-
input: true,
|
|
17
|
-
label: "Test",
|
|
18
|
-
key: "test",
|
|
19
|
-
type: "textarea",
|
|
20
|
-
validate: {
|
|
21
|
-
required: false
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
],
|
|
25
|
-
display: "form",
|
|
26
|
-
machineName: "model",
|
|
27
|
-
name: "model",
|
|
28
|
-
title: "Model",
|
|
29
|
-
type: "form",
|
|
30
|
-
submissionAccess: [],
|
|
31
|
-
access: [],
|
|
32
|
-
tags: []
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
});
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import {Component} from "./component.js";
|
|
2
|
-
|
|
3
|
-
export interface TextareaOpts extends Record<string, any> {
|
|
4
|
-
showCharCount?: boolean;
|
|
5
|
-
showWordCount?: boolean;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Configure the property as Textarea component.
|
|
10
|
-
* @decorator
|
|
11
|
-
* @formio
|
|
12
|
-
* @property
|
|
13
|
-
* @schema
|
|
14
|
-
*/
|
|
15
|
-
export function Textarea(props: TextareaOpts = {}): PropertyDecorator {
|
|
16
|
-
return Component({
|
|
17
|
-
autoExpand: false,
|
|
18
|
-
...props,
|
|
19
|
-
type: "textarea"
|
|
20
|
-
});
|
|
21
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import {getFormioSchema} from "../utils/getFormioSchema.js";
|
|
2
|
-
import {Tooltip} from "./tooltip.js";
|
|
3
|
-
|
|
4
|
-
describe("@Tooltip", () => {
|
|
5
|
-
it("should add a tooltip on field", async () => {
|
|
6
|
-
class Model {
|
|
7
|
-
@Tooltip("The tooltip")
|
|
8
|
-
test: string;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
expect(await getFormioSchema(Model)).toEqual({
|
|
12
|
-
access: [],
|
|
13
|
-
components: [
|
|
14
|
-
{
|
|
15
|
-
disabled: false,
|
|
16
|
-
input: true,
|
|
17
|
-
key: "test",
|
|
18
|
-
label: "Test",
|
|
19
|
-
tooltip: "The tooltip",
|
|
20
|
-
type: "textfield",
|
|
21
|
-
validate: {
|
|
22
|
-
required: false
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
],
|
|
26
|
-
display: "form",
|
|
27
|
-
machineName: "model",
|
|
28
|
-
name: "model",
|
|
29
|
-
submissionAccess: [],
|
|
30
|
-
tags: [],
|
|
31
|
-
title: "Model",
|
|
32
|
-
type: "form"
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
});
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import {Component} from "./component.js";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Adds a tooltip to the side of this field.
|
|
5
|
-
* @decorator
|
|
6
|
-
* @formio
|
|
7
|
-
* @property
|
|
8
|
-
* @schema
|
|
9
|
-
* @param tooltip
|
|
10
|
-
*/
|
|
11
|
-
export function Tooltip(tooltip: string) {
|
|
12
|
-
return Component({
|
|
13
|
-
tooltip
|
|
14
|
-
});
|
|
15
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import {Component} from "./component.js";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Add validation rules.
|
|
5
|
-
* @decorator
|
|
6
|
-
* @formio
|
|
7
|
-
* @property
|
|
8
|
-
* @schema
|
|
9
|
-
* @param key
|
|
10
|
-
* @param value
|
|
11
|
-
*/
|
|
12
|
-
export function Validate(key: string, value: any) {
|
|
13
|
-
return Component({
|
|
14
|
-
validate: {
|
|
15
|
-
[key]: value
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file Automatically generated by @tsed/barrels.
|
|
3
|
-
*/
|
|
4
|
-
export * from "./components/anyToComponent.js";
|
|
5
|
-
export * from "./components/arrayToComponent.js";
|
|
6
|
-
export * from "./components/booleanToComponent.js";
|
|
7
|
-
export * from "./components/dateToComponent.js";
|
|
8
|
-
export * from "./components/defaultToComponent.js";
|
|
9
|
-
export * from "./components/enumToComponent.js";
|
|
10
|
-
export * from "./components/mapToComponent.js";
|
|
11
|
-
export * from "./components/nestedToComponent.js";
|
|
12
|
-
export * from "./components/numberToComponent.js";
|
|
13
|
-
export * from "./components/objectToEditGrid.js";
|
|
14
|
-
export * from "./components/panelToComponent.js";
|
|
15
|
-
export * from "./components/propertiesToComponents.js";
|
|
16
|
-
export * from "./components/stringToComponent.js";
|
|
17
|
-
export * from "./decorators/component.js";
|
|
18
|
-
export * from "./decorators/conditional.js";
|
|
19
|
-
export * from "./decorators/currency.js";
|
|
20
|
-
export * from "./decorators/customClass.js";
|
|
21
|
-
export * from "./decorators/customConditional.js";
|
|
22
|
-
export * from "./decorators/dataSourceJson.js";
|
|
23
|
-
export * from "./decorators/dataSourceUrl.js";
|
|
24
|
-
export * from "./decorators/errorLabel.js";
|
|
25
|
-
export * from "./decorators/errorMessage.js";
|
|
26
|
-
export * from "./decorators/form.js";
|
|
27
|
-
export * from "./decorators/hidden.js";
|
|
28
|
-
export * from "./decorators/inputTags.js";
|
|
29
|
-
export * from "./decorators/label.js";
|
|
30
|
-
export * from "./decorators/mask.js";
|
|
31
|
-
export * from "./decorators/maxWords.js";
|
|
32
|
-
export * from "./decorators/minWords.js";
|
|
33
|
-
export * from "./decorators/modalEdit.js";
|
|
34
|
-
export * from "./decorators/multiple.js";
|
|
35
|
-
export * from "./decorators/openWhenEmpty.js";
|
|
36
|
-
export * from "./decorators/password.js";
|
|
37
|
-
export * from "./decorators/placeholder.js";
|
|
38
|
-
export * from "./decorators/prefix.js";
|
|
39
|
-
export * from "./decorators/select.js";
|
|
40
|
-
export * from "./decorators/suffix.js";
|
|
41
|
-
export * from "./decorators/tableView.js";
|
|
42
|
-
export * from "./decorators/tabs.js";
|
|
43
|
-
export * from "./decorators/textarea.js";
|
|
44
|
-
export * from "./decorators/textCase.js";
|
|
45
|
-
export * from "./decorators/tooltip.js";
|
|
46
|
-
export * from "./decorators/validate.js";
|
|
47
|
-
export * from "./interfaces/FormioDataResolver.js";
|
|
48
|
-
export * from "./registries/FormioMappersContainer.js";
|
|
49
|
-
export * from "./registries/FormsContainer.js";
|
|
50
|
-
export * from "./utils/getFormioProps.js";
|
|
51
|
-
export * from "./utils/getFormioSchema.js";
|
|
52
|
-
export * from "./utils/getRef.js";
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import {FormioComponent, FormioForm} from "@tsed/formio-types";
|
|
2
|
-
import {JsonSchemaOptions} from "@tsed/schema";
|
|
3
|
-
|
|
4
|
-
export type FormioDataResolverCtx = {component: FormioComponent; form: FormioForm} & JsonSchemaOptions;
|
|
5
|
-
export type FormioDataResolver = (ctx: FormioDataResolverCtx) => Promise<any> | any;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export interface FormioMapper {
|
|
2
|
-
(schema: any, options: any): any;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
const FormioMappersContainer: Map<string, FormioMapper> = new Map();
|
|
6
|
-
|
|
7
|
-
export function registerFormioMapper(type: string, mapper: FormioMapper) {
|
|
8
|
-
return FormioMappersContainer.set(type, mapper);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export function getFormioMapper(type: string): FormioMapper {
|
|
12
|
-
// istanbul ignore next
|
|
13
|
-
if (!FormioMappersContainer.has(type)) {
|
|
14
|
-
throw new Error(`Formio ${type} mapper doesn't exists`);
|
|
15
|
-
}
|
|
16
|
-
return FormioMappersContainer.get(type)!;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function execMapper(type: string, schema: any, options: any): any {
|
|
20
|
-
return getFormioMapper(type)(schema, options);
|
|
21
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export function getFormioProps(schema: any) {
|
|
2
|
-
const formioProps: any = Object.entries(schema).reduce((props, [key, value]) => {
|
|
3
|
-
if (key.startsWith("x-formio-")) {
|
|
4
|
-
return {
|
|
5
|
-
...props,
|
|
6
|
-
[key.replace("x-formio-", "")]: value
|
|
7
|
-
};
|
|
8
|
-
}
|
|
9
|
-
return props;
|
|
10
|
-
}, {});
|
|
11
|
-
return formioProps;
|
|
12
|
-
}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import {JsonEntityStore, Property} from "@tsed/schema";
|
|
2
|
-
|
|
3
|
-
import {Form} from "../decorators/form.js";
|
|
4
|
-
import {getFormioSchema} from "../utils/getFormioSchema.js";
|
|
5
|
-
|
|
6
|
-
const schema = {
|
|
7
|
-
access: [],
|
|
8
|
-
components: [
|
|
9
|
-
{
|
|
10
|
-
disabled: false,
|
|
11
|
-
input: true,
|
|
12
|
-
key: "test",
|
|
13
|
-
label: "Test",
|
|
14
|
-
type: "textfield",
|
|
15
|
-
validate: {
|
|
16
|
-
required: false
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
],
|
|
20
|
-
display: "form",
|
|
21
|
-
machineName: "model",
|
|
22
|
-
name: "model",
|
|
23
|
-
submissionAccess: [],
|
|
24
|
-
tags: [],
|
|
25
|
-
title: "Model",
|
|
26
|
-
type: "form"
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
describe("getFormioSchema", () => {
|
|
30
|
-
it("should return undefined when the schema is unknown", async () => {
|
|
31
|
-
expect(await getFormioSchema("unknown")).toEqual(undefined);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it("should return schema by his machineName", async () => {
|
|
35
|
-
@Form()
|
|
36
|
-
class Model {
|
|
37
|
-
@Property()
|
|
38
|
-
test: string;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
expect(await getFormioSchema("model")).toEqual(schema);
|
|
42
|
-
expect(await getFormioSchema("Model")).toEqual(schema);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it("should return schema by his custom machine name", async () => {
|
|
46
|
-
@Form({name: "CustomModel"})
|
|
47
|
-
class Model {
|
|
48
|
-
@Property()
|
|
49
|
-
test: string;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
expect(await getFormioSchema("custom-model")).toEqual({
|
|
53
|
-
...schema,
|
|
54
|
-
machineName: "custom-model",
|
|
55
|
-
name: "custom-model",
|
|
56
|
-
title: "CustomModel"
|
|
57
|
-
});
|
|
58
|
-
expect(await getFormioSchema("CustomModel")).toEqual({
|
|
59
|
-
...schema,
|
|
60
|
-
machineName: "custom-model",
|
|
61
|
-
name: "custom-model",
|
|
62
|
-
title: "CustomModel"
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
it("should return schema by his type", async () => {
|
|
67
|
-
@Form()
|
|
68
|
-
class Model {
|
|
69
|
-
@Property()
|
|
70
|
-
test: string;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
expect(await getFormioSchema(Model)).toEqual(schema);
|
|
74
|
-
});
|
|
75
|
-
it("should return schema by his store", async () => {
|
|
76
|
-
@Form()
|
|
77
|
-
class Model {
|
|
78
|
-
@Property()
|
|
79
|
-
test: string;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
expect(await getFormioSchema(JsonEntityStore.from(Model))).toEqual(schema);
|
|
83
|
-
});
|
|
84
|
-
});
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import "../components/anyToComponent.js";
|
|
2
|
-
import "../components/arrayToComponent.js";
|
|
3
|
-
import "../components/booleanToComponent.js";
|
|
4
|
-
import "../components/dateToComponent.js";
|
|
5
|
-
import "../components/defaultToComponent.js";
|
|
6
|
-
import "../components/enumToComponent.js";
|
|
7
|
-
import "../components/mapToComponent.js";
|
|
8
|
-
import "../components/nestedToComponent.js";
|
|
9
|
-
import "../components/numberToComponent.js";
|
|
10
|
-
import "../components/objectToEditGrid.js";
|
|
11
|
-
import "../components/panelToComponent.js";
|
|
12
|
-
import "../components/propertiesToComponents.js";
|
|
13
|
-
import "../components/stringToComponent.js";
|
|
14
|
-
|
|
15
|
-
import {isString, Type} from "@tsed/core";
|
|
16
|
-
import {FormioForm} from "@tsed/formio-types";
|
|
17
|
-
import {getJsonSchema, JsonEntityStore, JsonSchemaOptions} from "@tsed/schema";
|
|
18
|
-
import {kebabCase} from "change-case";
|
|
19
|
-
|
|
20
|
-
import {execMapper} from "../registries/FormioMappersContainer.js";
|
|
21
|
-
import {FormsContainer} from "../registries/FormsContainer.js";
|
|
22
|
-
|
|
23
|
-
export async function getFormioSchema(
|
|
24
|
-
model: string | any | undefined,
|
|
25
|
-
options: JsonSchemaOptions = {}
|
|
26
|
-
): Promise<Omit<FormioForm, "_id" | "deleted" | "owner"> | undefined> {
|
|
27
|
-
if (!model) {
|
|
28
|
-
return undefined;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
if (isString(model)) {
|
|
32
|
-
return getFormioSchema(FormsContainer.get(model) as Type<any>, options);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const entity = JsonEntityStore.from(model);
|
|
36
|
-
const schema = getJsonSchema(entity, {
|
|
37
|
-
...options,
|
|
38
|
-
inlineEnums: true,
|
|
39
|
-
customKeys: true
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
const name = entity.schema.getName();
|
|
43
|
-
const machineName = kebabCase(name);
|
|
44
|
-
const resolvers: Promise<any>[] = [];
|
|
45
|
-
const components = execMapper("properties", schema, {...options, definitions: schema.definitions, resolvers});
|
|
46
|
-
const form = {
|
|
47
|
-
title: name,
|
|
48
|
-
type: "form",
|
|
49
|
-
display: "form",
|
|
50
|
-
tags: [],
|
|
51
|
-
access: [],
|
|
52
|
-
submissionAccess: [],
|
|
53
|
-
...entity.store.get<any>("formio:form", {}),
|
|
54
|
-
name: machineName,
|
|
55
|
-
machineName,
|
|
56
|
-
components
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
await Promise.all(resolvers.map((resolver: any) => resolver(form, options)));
|
|
60
|
-
|
|
61
|
-
return form as unknown as FormioForm;
|
|
62
|
-
}
|