@easy-cms/plugin-form-builder 0.23.0 → 0.25.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/dist/index.d.ts +112 -3
- package/dist/index.js +3 -2
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TypedPlugin } from '@easy-cms/core';
|
|
2
2
|
import { F as FieldKind } from './shared-BP_sUDqY.js';
|
|
3
3
|
export { C as Confirmation, c as FIELD_KINDS, b as PublicField, P as PublicForm, S as Submission, a as SubmitResult } from './shared-BP_sUDqY.js';
|
|
4
4
|
|
|
@@ -38,6 +38,115 @@ interface FormBuilderOptions {
|
|
|
38
38
|
* Forms editors build in the admin from field blocks, with submissions, email notifications and
|
|
39
39
|
* spam protection. Pages render them with `<easy-form>` or the `getForm` / `submitForm` client.
|
|
40
40
|
*/
|
|
41
|
-
|
|
41
|
+
/** The forms and submissions collections, as the inferred document types see them. */
|
|
42
|
+
type FormBuilderPluginTypes<F extends string, S extends string> = {
|
|
43
|
+
readonly collections: readonly [
|
|
44
|
+
{
|
|
45
|
+
readonly slug: F;
|
|
46
|
+
readonly drafts: true;
|
|
47
|
+
readonly fields: readonly [
|
|
48
|
+
{
|
|
49
|
+
readonly name: 'title';
|
|
50
|
+
readonly type: 'text';
|
|
51
|
+
readonly required: true;
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
readonly name: 'slug';
|
|
55
|
+
readonly type: 'slug';
|
|
56
|
+
},
|
|
57
|
+
/** The form's field blocks (see `PublicForm` from the client for their shape). */
|
|
58
|
+
{
|
|
59
|
+
readonly name: 'fields';
|
|
60
|
+
readonly type: 'json';
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
readonly name: 'submitLabel';
|
|
64
|
+
readonly type: 'text';
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
readonly name: 'confirmationType';
|
|
68
|
+
readonly type: 'select';
|
|
69
|
+
readonly options: readonly ['message', 'redirect'];
|
|
70
|
+
readonly defaultValue: 'message';
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
readonly name: 'confirmationMessage';
|
|
74
|
+
readonly type: 'richText';
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
readonly name: 'redirectUrl';
|
|
78
|
+
readonly type: 'text';
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
readonly name: 'emails';
|
|
82
|
+
readonly type: 'array';
|
|
83
|
+
readonly fields: readonly [
|
|
84
|
+
{
|
|
85
|
+
readonly name: 'to';
|
|
86
|
+
readonly type: 'text';
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
readonly name: 'cc';
|
|
90
|
+
readonly type: 'text';
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
readonly name: 'bcc';
|
|
94
|
+
readonly type: 'text';
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
readonly name: 'replyTo';
|
|
98
|
+
readonly type: 'text';
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
readonly name: 'from';
|
|
102
|
+
readonly type: 'text';
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
readonly name: 'subject';
|
|
106
|
+
readonly type: 'text';
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
readonly name: 'message';
|
|
110
|
+
readonly type: 'richText';
|
|
111
|
+
}
|
|
112
|
+
];
|
|
113
|
+
}
|
|
114
|
+
];
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
readonly slug: S;
|
|
118
|
+
readonly fields: readonly [
|
|
119
|
+
{
|
|
120
|
+
readonly name: 'form';
|
|
121
|
+
readonly type: 'relationship';
|
|
122
|
+
readonly to: F;
|
|
123
|
+
readonly required: true;
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
readonly name: 'summary';
|
|
127
|
+
readonly type: 'text';
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
readonly name: 'data';
|
|
131
|
+
readonly type: 'json';
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
readonly name: 'locale';
|
|
135
|
+
readonly type: 'text';
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
readonly name: 'page';
|
|
139
|
+
readonly type: 'text';
|
|
140
|
+
}
|
|
141
|
+
];
|
|
142
|
+
}
|
|
143
|
+
];
|
|
144
|
+
};
|
|
145
|
+
declare function formBuilderPlugin<const F extends string = 'forms', const S extends string = 'form-submissions'>(options?: FormBuilderOptions & {
|
|
146
|
+
readonly slugs?: {
|
|
147
|
+
readonly forms?: F;
|
|
148
|
+
readonly submissions?: S;
|
|
149
|
+
};
|
|
150
|
+
}): TypedPlugin<FormBuilderPluginTypes<F, S>>;
|
|
42
151
|
|
|
43
|
-
export { FieldKind, type FormBuilderOptions, formBuilderPlugin };
|
|
152
|
+
export { FieldKind, type FormBuilderOptions, type FormBuilderPluginTypes, formBuilderPlugin };
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
// src/plugin.ts
|
|
6
6
|
import { readFile } from "fs/promises";
|
|
7
7
|
import {
|
|
8
|
+
definePlugin,
|
|
8
9
|
resolveAdminModule
|
|
9
10
|
} from "@easy-cms/core";
|
|
10
11
|
import { renderRichText as renderRichText2 } from "@easy-cms/richtext";
|
|
@@ -339,7 +340,7 @@ var optionValues = (row) => (Array.isArray(row.options) ? row.options : []).map(
|
|
|
339
340
|
// src/plugin.ts
|
|
340
341
|
var ADMIN_MODULE = "@easy-cms/plugin-form-builder/admin";
|
|
341
342
|
function formBuilderPlugin(options = {}) {
|
|
342
|
-
return (config) => {
|
|
343
|
+
return definePlugin((config) => {
|
|
343
344
|
const forms = options.slugs?.forms ?? "forms";
|
|
344
345
|
const submissions = options.slugs?.submissions ?? "form-submissions";
|
|
345
346
|
for (const slug of [forms, submissions])
|
|
@@ -721,7 +722,7 @@ function formBuilderPlugin(options = {}) {
|
|
|
721
722
|
elementEndpoint
|
|
722
723
|
]
|
|
723
724
|
};
|
|
724
|
-
};
|
|
725
|
+
});
|
|
725
726
|
}
|
|
726
727
|
function summarize(rows, values) {
|
|
727
728
|
const parts = rows.filter((r) => r.blockType !== "message" && typeof r.name === "string").map((r) => cell(values[r.name])).filter(Boolean);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@easy-cms/plugin-form-builder",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.25.0",
|
|
4
4
|
"description": "Forms for Easy CMS: build forms in the admin, collect submissions, email notifications, spam protection and an <easy-form> element",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -23,15 +23,15 @@
|
|
|
23
23
|
"dist"
|
|
24
24
|
],
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@easy-cms/richtext": "^0.
|
|
26
|
+
"@easy-cms/richtext": "^0.25.0"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
|
-
"@easy-cms/core": "^0.
|
|
29
|
+
"@easy-cms/core": "^0.25.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"happy-dom": "^20.14.5",
|
|
33
|
-
"@easy-cms/core": "^0.
|
|
34
|
-
"@easy-cms/db-sqlite": "^0.
|
|
33
|
+
"@easy-cms/core": "^0.25.0",
|
|
34
|
+
"@easy-cms/db-sqlite": "^0.25.0"
|
|
35
35
|
},
|
|
36
36
|
"engines": {
|
|
37
37
|
"node": ">=22.12"
|