@10x-media/form-builder 0.1.0-beta.2 → 0.1.0-beta.4
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/CHANGELOG.md +60 -0
- package/README.md +4 -4
- package/dist/actions/body/converters.d.ts +20 -0
- package/dist/actions/body/converters.js +57 -0
- package/dist/actions/body/converters.js.map +1 -0
- package/dist/actions/body/escapeHtml.d.ts +6 -0
- package/dist/actions/body/escapeHtml.js +14 -0
- package/dist/actions/body/escapeHtml.js.map +1 -0
- package/dist/actions/body/serializeBody.d.ts +50 -0
- package/dist/actions/body/serializeBody.js +78 -0
- package/dist/actions/body/serializeBody.js.map +1 -0
- package/dist/actions/body/serializeSlate.js +31 -0
- package/dist/actions/body/serializeSlate.js.map +1 -0
- package/dist/actions/body/wildcards.d.ts +10 -0
- package/dist/actions/body/wildcards.js +33 -0
- package/dist/actions/body/wildcards.js.map +1 -0
- package/dist/actions/builtin/confirmation.js +40 -15
- package/dist/actions/builtin/confirmation.js.map +1 -1
- package/dist/actions/builtin/emailTeam.js +19 -12
- package/dist/actions/builtin/emailTeam.js.map +1 -1
- package/dist/actions/builtin/index.d.ts +13 -1
- package/dist/actions/builtin/index.js +18 -7
- package/dist/actions/builtin/index.js.map +1 -1
- package/dist/actions/builtin/signedWebhook.js +6 -2
- package/dist/actions/builtin/signedWebhook.js.map +1 -1
- package/dist/actions/defineAction.d.ts +2 -1
- package/dist/actions/defineAction.js.map +1 -1
- package/dist/actions/dispatch.js +2 -1
- package/dist/actions/dispatch.js.map +1 -1
- package/dist/actions/runActions.js +10 -1
- package/dist/actions/runActions.js.map +1 -1
- package/dist/actions/task.js +7 -5
- package/dist/actions/task.js.map +1 -1
- package/dist/aggregation/resolveResultsRequest.d.ts +22 -6
- package/dist/aggregation/resolveResultsRequest.js +18 -7
- package/dist/aggregation/resolveResultsRequest.js.map +1 -1
- package/dist/calc/normalizeCalc.js +5 -17
- package/dist/calc/normalizeCalc.js.map +1 -1
- package/dist/calc/types.d.ts +8 -2
- package/dist/calc/types.js +22 -0
- package/dist/calc/types.js.map +1 -0
- package/dist/client/ByteSizeField.d.ts +21 -0
- package/dist/client/ByteSizeField.js +56 -0
- package/dist/client/ByteSizeField.js.map +1 -0
- package/dist/client/ConditionBuilder.js +2 -1
- package/dist/client/ConditionBuilder.js.map +1 -1
- package/dist/client/FieldNameSelect.d.ts +20 -0
- package/dist/client/FieldNameSelect.js +58 -0
- package/dist/client/FieldNameSelect.js.map +1 -0
- package/dist/client/FlowBuilder.d.ts +0 -1
- package/dist/client/FlowBuilder.js +102 -59
- package/dist/client/FlowBuilder.js.map +1 -1
- package/dist/client/FormConditionField.js +1 -4
- package/dist/client/FormConditionField.js.map +1 -1
- package/dist/client/admin.css +234 -0
- package/dist/client/flowAuthoring.js +35 -0
- package/dist/client/flowAuthoring.js.map +1 -0
- package/dist/client/synthesizeClientField.js +6 -2
- package/dist/client/synthesizeClientField.js.map +1 -1
- package/dist/client/toStaticLabel.js +13 -0
- package/dist/client/toStaticLabel.js.map +1 -0
- package/dist/collections/formSubmissions.js +49 -9
- package/dist/collections/formSubmissions.js.map +1 -1
- package/dist/collections/forms.js +251 -88
- package/dist/collections/forms.js.map +1 -1
- package/dist/conditions/conditionType.js +9 -2
- package/dist/conditions/conditionType.js.map +1 -1
- package/dist/conditions/normalizeConditions.js +2 -1
- package/dist/conditions/normalizeConditions.js.map +1 -1
- package/dist/consent/builtin/index.d.ts +11 -1
- package/dist/consent/builtin/index.js +15 -5
- package/dist/consent/builtin/index.js.map +1 -1
- package/dist/consent/builtin/static.js +7 -3
- package/dist/consent/builtin/static.js.map +1 -1
- package/dist/exports/client.d.ts +3 -1
- package/dist/exports/client.js +3 -1
- package/dist/exports/react.d.ts +15 -6
- package/dist/exports/react.js +10 -2
- package/dist/exports/rsc.d.ts +6 -1
- package/dist/exports/rsc.js +6 -1
- package/dist/exports/types.d.ts +4 -4
- package/dist/fields/buildFieldBlocks.js +20 -15
- package/dist/fields/buildFieldBlocks.js.map +1 -1
- package/dist/fields/builtin/calculation.js +115 -2
- package/dist/fields/builtin/calculation.js.map +1 -1
- package/dist/fields/builtin/consent.js +8 -4
- package/dist/fields/builtin/consent.js.map +1 -1
- package/dist/fields/builtin/date.js +29 -0
- package/dist/fields/builtin/date.js.map +1 -0
- package/dist/fields/builtin/file.d.ts +15 -0
- package/dist/fields/builtin/file.js +87 -7
- package/dist/fields/builtin/file.js.map +1 -1
- package/dist/fields/builtin/index.d.ts +24 -0
- package/dist/fields/builtin/index.js +29 -8
- package/dist/fields/builtin/index.js.map +1 -1
- package/dist/fields/builtin/message.js +26 -0
- package/dist/fields/builtin/message.js.map +1 -0
- package/dist/fields/builtin/repeater.js +7 -3
- package/dist/fields/builtin/repeater.js.map +1 -1
- package/dist/fields/builtin/select.js +7 -3
- package/dist/fields/builtin/select.js.map +1 -1
- package/dist/fields/fieldNamesOfType.js +25 -0
- package/dist/fields/fieldNamesOfType.js.map +1 -0
- package/dist/fields/localizedIf.d.ts +13 -0
- package/dist/fields/localizedIf.js +12 -0
- package/dist/fields/localizedIf.js.map +1 -0
- package/dist/fields/sharedConfig.js +82 -57
- package/dist/fields/sharedConfig.js.map +1 -1
- package/dist/fields/types.d.ts +7 -2
- package/dist/flow/normalizeFlow.js +7 -1
- package/dist/flow/normalizeFlow.js.map +1 -1
- package/dist/flow/stepLabel.js +15 -0
- package/dist/flow/stepLabel.js.map +1 -0
- package/dist/form/pollState.d.ts +22 -0
- package/dist/form/pollState.js +17 -0
- package/dist/form/pollState.js.map +1 -0
- package/dist/form/toFormDocument.d.ts +60 -0
- package/dist/form/toFormDocument.js +39 -0
- package/dist/form/toFormDocument.js.map +1 -0
- package/dist/form/types.d.ts +48 -0
- package/dist/index.d.ts +81 -13
- package/dist/index.js +36 -15
- package/dist/index.js.map +1 -1
- package/dist/plugin/registerCollections.js +17 -37
- package/dist/plugin/registerCollections.js.map +1 -1
- package/dist/plugin/uploadsCollection.d.ts +11 -0
- package/dist/plugin/uploadsCollection.js +44 -0
- package/dist/plugin/uploadsCollection.js.map +1 -0
- package/dist/poll/applyPollOptions.js +17 -0
- package/dist/poll/applyPollOptions.js.map +1 -0
- package/dist/poll/buildPollOptionSourceFields.js +53 -0
- package/dist/poll/buildPollOptionSourceFields.js.map +1 -0
- package/dist/poll/definePollOptionSource.d.ts +35 -0
- package/dist/poll/definePollOptionSource.js +6 -0
- package/dist/poll/definePollOptionSource.js.map +1 -0
- package/dist/poll/registry.d.ts +16 -0
- package/dist/poll/registry.js +16 -0
- package/dist/poll/registry.js.map +1 -0
- package/dist/poll/resolvePollOptions.d.ts +28 -0
- package/dist/poll/resolvePollOptions.js +64 -0
- package/dist/poll/resolvePollOptions.js.map +1 -0
- package/dist/poll/resolvePollOutcome.d.ts +21 -0
- package/dist/poll/resolvePollOutcome.js +36 -0
- package/dist/poll/resolvePollOutcome.js.map +1 -0
- package/dist/prefill/valuesFromSearchParams.js +1 -1
- package/dist/prefill/valuesFromSearchParams.js.map +1 -1
- package/dist/presentations/types.d.ts +3 -2
- package/dist/react/Form.d.ts +13 -31
- package/dist/react/Form.js +98 -85
- package/dist/react/Form.js.map +1 -1
- package/dist/react/FormContext.d.ts +35 -1
- package/dist/react/FormContext.js.map +1 -1
- package/dist/react/FormControls.d.ts +55 -0
- package/dist/react/FormControls.js +56 -0
- package/dist/react/FormControls.js.map +1 -0
- package/dist/react/FormResults.d.ts +6 -3
- package/dist/react/FormResults.js +37 -29
- package/dist/react/FormResults.js.map +1 -1
- package/dist/react/FormSteps.d.ts +17 -0
- package/dist/react/FormSteps.js +35 -0
- package/dist/react/FormSteps.js.map +1 -0
- package/dist/react/Poll.d.ts +17 -6
- package/dist/react/Poll.js +66 -18
- package/dist/react/Poll.js.map +1 -1
- package/dist/react/captcha/HcaptchaCaptcha.d.ts +28 -0
- package/dist/react/captcha/HcaptchaCaptcha.js +53 -0
- package/dist/react/captcha/HcaptchaCaptcha.js.map +1 -0
- package/dist/react/captcha/RecaptchaCaptcha.d.ts +41 -0
- package/dist/react/captcha/RecaptchaCaptcha.js +93 -0
- package/dist/react/captcha/RecaptchaCaptcha.js.map +1 -0
- package/dist/react/captcha/TurnstileCaptcha.d.ts +28 -0
- package/dist/react/captcha/TurnstileCaptcha.js +53 -0
- package/dist/react/captcha/TurnstileCaptcha.js.map +1 -0
- package/dist/react/captcha/types.d.ts +8 -0
- package/dist/react/captcha/useCaptchaScript.js +45 -0
- package/dist/react/captcha/useCaptchaScript.js.map +1 -0
- package/dist/react/captcha/vendors.js +8 -0
- package/dist/react/captcha/vendors.js.map +1 -0
- package/dist/react/fetchResults.d.ts +1 -1
- package/dist/react/fetchResults.js +1 -1
- package/dist/react/fetchResults.js.map +1 -1
- package/dist/react/primitives/Input.d.ts +1 -1
- package/dist/react/primitives/Input.js.map +1 -1
- package/dist/react/renderers/calculation.js +1 -1
- package/dist/react/renderers/checkbox.js +1 -1
- package/dist/react/renderers/consent.js +1 -1
- package/dist/react/renderers/date.js +37 -0
- package/dist/react/renderers/date.js.map +1 -0
- package/dist/react/renderers/email.js +1 -1
- package/dist/react/renderers/file.js +25 -8
- package/dist/react/renderers/file.js.map +1 -1
- package/dist/react/renderers/index.js +4 -0
- package/dist/react/renderers/index.js.map +1 -1
- package/dist/react/renderers/message.js +35 -0
- package/dist/react/renderers/message.js.map +1 -0
- package/dist/react/renderers/number.js +1 -1
- package/dist/react/renderers/repeater.js +1 -1
- package/dist/react/renderers/select.js +1 -1
- package/dist/react/renderers/text.js +1 -1
- package/dist/react/renderers/textarea.js +1 -1
- package/dist/react/state.d.ts +25 -1
- package/dist/react/state.js +14 -1
- package/dist/react/state.js.map +1 -1
- package/dist/react/uploadFile.d.ts +2 -2
- package/dist/react/uploadFile.js +1 -1
- package/dist/react/uploadFile.js.map +1 -1
- package/dist/spam/captcha.d.ts +3 -2
- package/dist/spam/captcha.js +3 -2
- package/dist/spam/captcha.js.map +1 -1
- package/dist/spam/clientIp.js +9 -0
- package/dist/spam/clientIp.js.map +1 -0
- package/dist/spam/identify.js +3 -6
- package/dist/spam/identify.js.map +1 -1
- package/dist/spam/providers/hcaptcha.d.ts +17 -0
- package/dist/spam/providers/hcaptcha.js +18 -0
- package/dist/spam/providers/hcaptcha.js.map +1 -0
- package/dist/spam/providers/recaptcha.d.ts +23 -0
- package/dist/spam/providers/recaptcha.js +23 -0
- package/dist/spam/providers/recaptcha.js.map +1 -0
- package/dist/spam/providers/siteverify.js +34 -0
- package/dist/spam/providers/siteverify.js.map +1 -0
- package/dist/spam/providers/turnstile.d.ts +17 -0
- package/dist/spam/providers/turnstile.js +18 -0
- package/dist/spam/providers/turnstile.js.map +1 -0
- package/dist/spam/spamGuard.js +2 -5
- package/dist/spam/spamGuard.js.map +1 -1
- package/dist/spam/types.d.ts +2 -2
- package/dist/submissions/runSubmission.js +70 -33
- package/dist/submissions/runSubmission.js.map +1 -1
- package/dist/submissions/validateSubmission.js +41 -7
- package/dist/submissions/validateSubmission.js.map +1 -1
- package/dist/submissions/votedCookie.d.ts +13 -0
- package/dist/submissions/votedCookie.js +27 -0
- package/dist/submissions/votedCookie.js.map +1 -0
- package/dist/translations/de.js +219 -0
- package/dist/translations/de.js.map +1 -0
- package/dist/translations/en.js +71 -10
- package/dist/translations/en.js.map +1 -1
- package/dist/translations/index.d.ts +2 -1
- package/dist/translations/index.js +6 -2
- package/dist/translations/index.js.map +1 -1
- package/dist/translations/keys.d.ts +69 -8
- package/dist/translations/keys.js +70 -9
- package/dist/translations/keys.js.map +1 -1
- package/dist/uploads/formatBytes.d.ts +9 -0
- package/dist/uploads/formatBytes.js +25 -0
- package/dist/uploads/formatBytes.js.map +1 -0
- package/dist/uploads/resolveFileRef.js +1 -1
- package/dist/uploads/resolveFileRef.js.map +1 -1
- package/dist/uploads/types.d.ts +1 -2
- package/dist/validation/builtin/index.d.ts +14 -0
- package/dist/validation/builtin/index.js +12 -1
- package/dist/validation/builtin/index.js.map +1 -1
- package/dist/validation/builtin/maxDate.js +23 -0
- package/dist/validation/builtin/maxDate.js.map +1 -0
- package/dist/validation/builtin/minDate.js +23 -0
- package/dist/validation/builtin/minDate.js.map +1 -0
- package/dist/validation/builtin/validateDateBound.js +18 -0
- package/dist/validation/builtin/validateDateBound.js.map +1 -0
- package/dist/validation/validateUrl.js +22 -0
- package/dist/validation/validateUrl.js.map +1 -0
- package/package.json +4 -2
- package/styles/form-builder.css +10 -190
- package/dist/collections/uploads.d.ts +0 -30
- package/dist/collections/uploads.js +0 -55
- package/dist/collections/uploads.js.map +0 -1
- package/dist/presentations/registry.d.ts +0 -15
- package/dist/presentations/registry.js +0 -15
- package/dist/presentations/registry.js.map +0 -1
- package/dist/react/toFormDocument.d.ts +0 -24
- package/dist/react/toFormDocument.js +0 -22
- package/dist/react/toFormDocument.js.map +0 -1
package/dist/fields/types.d.ts
CHANGED
|
@@ -4,8 +4,12 @@ import { Field } from "payload";
|
|
|
4
4
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
5
5
|
|
|
6
6
|
//#region src/fields/types.d.ts
|
|
7
|
-
/**
|
|
8
|
-
|
|
7
|
+
/**
|
|
8
|
+
* The stored value shapes a field type can declare. Drives `validate`/`format` typing and value
|
|
9
|
+
* coercion. `'none'` marks a display-only type (e.g. `message`): the engine never seeds, validates,
|
|
10
|
+
* or stores a value for it, and a client-sent value under its name is dropped.
|
|
11
|
+
*/
|
|
12
|
+
type FormFieldValueKind = 'text' | 'number' | 'boolean' | 'date' | 'text[]' | 'file' | 'repeater' | 'none';
|
|
9
13
|
type ValueKindTypeMap = {
|
|
10
14
|
text: string;
|
|
11
15
|
number: number;
|
|
@@ -14,6 +18,7 @@ type ValueKindTypeMap = {
|
|
|
14
18
|
'text[]': string[];
|
|
15
19
|
file: FileRef;
|
|
16
20
|
repeater: Array<Record<string, unknown>>;
|
|
21
|
+
none: never;
|
|
17
22
|
};
|
|
18
23
|
type ValueOfKind<K extends FormFieldValueKind> = ValueKindTypeMap[K];
|
|
19
24
|
/** Resolved per-instance config values for a field type (loose at the DB boundary, narrowed by the author's generic). */
|
|
@@ -4,6 +4,7 @@ const isRecord = (v) => v !== null && typeof v === "object" && !Array.isArray(v)
|
|
|
4
4
|
* Pure guard that normalizes a raw (possibly untrusted) flow value against the
|
|
5
5
|
* form's current field list. Returns `undefined` when the flow is absent, empty,
|
|
6
6
|
* or resolves to fewer than two steps (a single step is an ordinary form).
|
|
7
|
+
* A field assigned to multiple steps keeps only its first occurrence in step order.
|
|
7
8
|
*/
|
|
8
9
|
const normalizeFlow = (raw, fieldNames) => {
|
|
9
10
|
if (!isRecord(raw) || !Array.isArray(raw.steps)) return;
|
|
@@ -11,9 +12,14 @@ const normalizeFlow = (raw, fieldNames) => {
|
|
|
11
12
|
const rawSteps = raw.steps.filter((s) => isRecord(s) && typeof s.id === "string");
|
|
12
13
|
const knownIds = new Set(rawSteps.map((s) => s.id));
|
|
13
14
|
if (knownIds.size < 2) return;
|
|
15
|
+
const seenFields = /* @__PURE__ */ new Set();
|
|
14
16
|
return { steps: rawSteps.map((s) => {
|
|
15
17
|
const id = s.id;
|
|
16
|
-
const fields = Array.isArray(s.fields) ? s.fields.filter((f) =>
|
|
18
|
+
const fields = Array.isArray(s.fields) ? s.fields.filter((f) => {
|
|
19
|
+
if (typeof f !== "string" || !knownFields.has(f) || seenFields.has(f)) return false;
|
|
20
|
+
seenFields.add(f);
|
|
21
|
+
return true;
|
|
22
|
+
}) : [];
|
|
17
23
|
const transitions = (Array.isArray(s.transitions) ? s.transitions : []).filter((t) => isRecord(t) && typeof t.to === "string" && knownIds.has(t.to) && isRecord(t.when)).map((t) => ({
|
|
18
24
|
when: t.when,
|
|
19
25
|
to: t.to
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalizeFlow.js","names":[],"sources":["../../src/flow/normalizeFlow.ts"],"sourcesContent":["import type { Where } from 'payload'\nimport type { FlowStep, FormFlow } from './types'\n\nconst isRecord = (v: unknown): v is Record<string, unknown> =>\n\tv !== null && typeof v === 'object' && !Array.isArray(v)\n\n/**\n * Pure guard that normalizes a raw (possibly untrusted) flow value against the\n * form's current field list. Returns `undefined` when the flow is absent, empty,\n * or resolves to fewer than two steps (a single step is an ordinary form).\n */\nexport const normalizeFlow = (raw: unknown, fieldNames: string[]): FormFlow | undefined => {\n\tif (!isRecord(raw) || !Array.isArray(raw.steps)) {\n\t\treturn undefined\n\t}\n\n\tconst knownFields = new Set(fieldNames)\n\n\tconst rawSteps = raw.steps.filter(\n\t\t(s): s is Record<string, unknown> => isRecord(s) && typeof s.id === 'string'\n\t)\n\n\tconst knownIds = new Set(rawSteps.map((s) => s.id as string))\n\n\tif (knownIds.size < 2) {\n\t\treturn undefined\n\t}\n\n\tconst steps: FlowStep[] = rawSteps.map((s) => {\n\t\tconst id = s.id as string\n\n\t\tconst fields = Array.isArray(s.fields)\n\t\t\t? s.fields.filter((f): f is string => typeof f
|
|
1
|
+
{"version":3,"file":"normalizeFlow.js","names":[],"sources":["../../src/flow/normalizeFlow.ts"],"sourcesContent":["import type { Where } from 'payload'\nimport type { FlowStep, FormFlow } from './types'\n\nconst isRecord = (v: unknown): v is Record<string, unknown> =>\n\tv !== null && typeof v === 'object' && !Array.isArray(v)\n\n/**\n * Pure guard that normalizes a raw (possibly untrusted) flow value against the\n * form's current field list. Returns `undefined` when the flow is absent, empty,\n * or resolves to fewer than two steps (a single step is an ordinary form).\n * A field assigned to multiple steps keeps only its first occurrence in step order.\n */\nexport const normalizeFlow = (raw: unknown, fieldNames: string[]): FormFlow | undefined => {\n\tif (!isRecord(raw) || !Array.isArray(raw.steps)) {\n\t\treturn undefined\n\t}\n\n\tconst knownFields = new Set(fieldNames)\n\n\tconst rawSteps = raw.steps.filter(\n\t\t(s): s is Record<string, unknown> => isRecord(s) && typeof s.id === 'string'\n\t)\n\n\tconst knownIds = new Set(rawSteps.map((s) => s.id as string))\n\n\tif (knownIds.size < 2) {\n\t\treturn undefined\n\t}\n\n\tconst seenFields = new Set<string>()\n\n\tconst steps: FlowStep[] = rawSteps.map((s) => {\n\t\tconst id = s.id as string\n\n\t\tconst fields = Array.isArray(s.fields)\n\t\t\t? s.fields.filter((f): f is string => {\n\t\t\t\t\tif (typeof f !== 'string' || !knownFields.has(f) || seenFields.has(f)) return false\n\t\t\t\t\tseenFields.add(f)\n\t\t\t\t\treturn true\n\t\t\t\t})\n\t\t\t: []\n\n\t\tconst rawTransitions = Array.isArray(s.transitions) ? s.transitions : []\n\t\tconst transitions = rawTransitions\n\t\t\t.filter(\n\t\t\t\t(t): t is Record<string, unknown> =>\n\t\t\t\t\tisRecord(t) &&\n\t\t\t\t\ttypeof t.to === 'string' &&\n\t\t\t\t\tknownIds.has(t.to as string) &&\n\t\t\t\t\tisRecord(t.when)\n\t\t\t)\n\t\t\t.map((t) => ({ when: t.when as Where, to: t.to as string }))\n\n\t\tconst next = typeof s.next === 'string' && knownIds.has(s.next) ? (s.next as string) : undefined\n\n\t\tconst step: FlowStep = { id, fields }\n\t\tif (typeof s.title === 'string') step.title = s.title\n\t\tif (transitions.length > 0) step.transitions = transitions\n\t\tif (next !== undefined) step.next = next\n\n\t\treturn step\n\t})\n\n\treturn { steps }\n}\n"],"mappings":";AAGA,MAAM,YAAY,MACjB,MAAM,QAAQ,OAAO,MAAM,YAAY,CAAC,MAAM,QAAQ,CAAC;;;;;;;AAQxD,MAAa,iBAAiB,KAAc,eAA+C;CAC1F,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,MAAM,QAAQ,IAAI,KAAK,GAC7C;CAGD,MAAM,cAAc,IAAI,IAAI,UAAU;CAEtC,MAAM,WAAW,IAAI,MAAM,QACzB,MAAoC,SAAS,CAAC,KAAK,OAAO,EAAE,OAAO,QACrE;CAEA,MAAM,WAAW,IAAI,IAAI,SAAS,KAAK,MAAM,EAAE,EAAY,CAAC;CAE5D,IAAI,SAAS,OAAO,GACnB;CAGD,MAAM,6BAAa,IAAI,IAAY;CAkCnC,OAAO,EAAE,OAhCiB,SAAS,KAAK,MAAM;EAC7C,MAAM,KAAK,EAAE;EAEb,MAAM,SAAS,MAAM,QAAQ,EAAE,MAAM,IAClC,EAAE,OAAO,QAAQ,MAAmB;GACpC,IAAI,OAAO,MAAM,YAAY,CAAC,YAAY,IAAI,CAAC,KAAK,WAAW,IAAI,CAAC,GAAG,OAAO;GAC9E,WAAW,IAAI,CAAC;GAChB,OAAO;EACR,CAAC,IACA,CAAC;EAGJ,MAAM,eADiB,MAAM,QAAQ,EAAE,WAAW,IAAI,EAAE,cAAc,CAAC,GAErE,QACC,MACA,SAAS,CAAC,KACV,OAAO,EAAE,OAAO,YAChB,SAAS,IAAI,EAAE,EAAY,KAC3B,SAAS,EAAE,IAAI,CACjB,EACC,KAAK,OAAO;GAAE,MAAM,EAAE;GAAe,IAAI,EAAE;EAAa,EAAE;EAE5D,MAAM,OAAO,OAAO,EAAE,SAAS,YAAY,SAAS,IAAI,EAAE,IAAI,IAAK,EAAE,OAAkB,KAAA;EAEvF,MAAM,OAAiB;GAAE;GAAI;EAAO;EACpC,IAAI,OAAO,EAAE,UAAU,UAAU,KAAK,QAAQ,EAAE;EAChD,IAAI,YAAY,SAAS,GAAG,KAAK,cAAc;EAC/C,IAAI,SAAS,KAAA,GAAW,KAAK,OAAO;EAEpC,OAAO;CACR,CAEa,EAAE;AAChB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region src/flow/stepLabel.ts
|
|
2
|
+
/**
|
|
3
|
+
* Display label for a step: its trimmed title, else the fallback template with
|
|
4
|
+
* `{n}` replaced by the 1-based index. Step ids never surface in the UI.
|
|
5
|
+
* Lives with the flow engine (not the admin client module) because the frontend
|
|
6
|
+
* `<FormSteps>` indicator resolves labels with the same semantics.
|
|
7
|
+
*/
|
|
8
|
+
const stepLabel = (step, index, fallbackTemplate) => {
|
|
9
|
+
const title = step.title?.trim();
|
|
10
|
+
return title !== void 0 && title.length > 0 ? title : fallbackTemplate.replace("{n}", String(index + 1));
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { stepLabel };
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=stepLabel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stepLabel.js","names":[],"sources":["../../src/flow/stepLabel.ts"],"sourcesContent":["import type { FlowStep } from './types'\n\n/**\n * Display label for a step: its trimmed title, else the fallback template with\n * `{n}` replaced by the 1-based index. Step ids never surface in the UI.\n * Lives with the flow engine (not the admin client module) because the frontend\n * `<FormSteps>` indicator resolves labels with the same semantics.\n */\nexport const stepLabel = (\n\tstep: Pick<FlowStep, 'title'>,\n\tindex: number,\n\tfallbackTemplate: string\n): string => {\n\tconst title = step.title?.trim()\n\treturn title !== undefined && title.length > 0\n\t\t? title\n\t\t: fallbackTemplate.replace('{n}', String(index + 1))\n}\n"],"mappings":";;;;;;;AAQA,MAAa,aACZ,MACA,OACA,qBACY;CACZ,MAAM,QAAQ,KAAK,OAAO,KAAK;CAC/B,OAAO,UAAU,KAAA,KAAa,MAAM,SAAS,IAC1C,QACA,iBAAiB,QAAQ,OAAO,OAAO,QAAQ,CAAC,CAAC;AACrD"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//#region src/form/pollState.d.ts
|
|
2
|
+
/** Poll settings as loaded from a forms document (server) or a `FormDocument` (client). */
|
|
3
|
+
type PollConfigLike = {
|
|
4
|
+
enabled?: boolean | null;
|
|
5
|
+
resultsField?: string | null;
|
|
6
|
+
resultsVisibility?: string | null;
|
|
7
|
+
closesAt?: string | null;
|
|
8
|
+
optionSource?: string | null;
|
|
9
|
+
sourceConfig?: Record<string, unknown> | null;
|
|
10
|
+
outcome?: {
|
|
11
|
+
winningValue?: string | null;
|
|
12
|
+
resolvedAt?: string | null;
|
|
13
|
+
} | null;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Whether the poll's `closesAt` has passed. An unset or unparseable `closesAt` never closes;
|
|
17
|
+
* framework-agnostic so the server guard, the results gate, and the client `<Poll>` agree.
|
|
18
|
+
*/
|
|
19
|
+
declare const isPollClosed: (poll: PollConfigLike | null | undefined, now?: number) => boolean;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { isPollClosed };
|
|
22
|
+
//# sourceMappingURL=pollState.d.ts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region src/form/pollState.ts
|
|
2
|
+
/** Narrow a forms document's untyped `poll` member. */
|
|
3
|
+
const pollConfigOf = (poll) => poll != null && typeof poll === "object" ? poll : void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Whether the poll's `closesAt` has passed. An unset or unparseable `closesAt` never closes;
|
|
6
|
+
* framework-agnostic so the server guard, the results gate, and the client `<Poll>` agree.
|
|
7
|
+
*/
|
|
8
|
+
const isPollClosed = (poll, now = Date.now()) => {
|
|
9
|
+
const closesAt = poll?.closesAt;
|
|
10
|
+
if (typeof closesAt !== "string" || closesAt.length === 0) return false;
|
|
11
|
+
const ts = Date.parse(closesAt);
|
|
12
|
+
return Number.isFinite(ts) && ts <= now;
|
|
13
|
+
};
|
|
14
|
+
//#endregion
|
|
15
|
+
export { isPollClosed, pollConfigOf };
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=pollState.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pollState.js","names":[],"sources":["../../src/form/pollState.ts"],"sourcesContent":["/** Poll settings as loaded from a forms document (server) or a `FormDocument` (client). */\nexport type PollConfigLike = {\n\tenabled?: boolean | null\n\tresultsField?: string | null\n\tresultsVisibility?: string | null\n\tclosesAt?: string | null\n\toptionSource?: string | null\n\tsourceConfig?: Record<string, unknown> | null\n\toutcome?: { winningValue?: string | null; resolvedAt?: string | null } | null\n}\n\n/** Narrow a forms document's untyped `poll` member. */\nexport const pollConfigOf = (poll: unknown): PollConfigLike | undefined =>\n\tpoll != null && typeof poll === 'object' ? (poll as PollConfigLike) : undefined\n\n/**\n * Whether the poll's `closesAt` has passed. An unset or unparseable `closesAt` never closes;\n * framework-agnostic so the server guard, the results gate, and the client `<Poll>` agree.\n */\nexport const isPollClosed = (\n\tpoll: PollConfigLike | null | undefined,\n\tnow: number = Date.now()\n): boolean => {\n\tconst closesAt = poll?.closesAt\n\tif (typeof closesAt !== 'string' || closesAt.length === 0) {\n\t\treturn false\n\t}\n\tconst ts = Date.parse(closesAt)\n\treturn Number.isFinite(ts) && ts <= now\n}\n"],"mappings":";;AAYA,MAAa,gBAAgB,SAC5B,QAAQ,QAAQ,OAAO,SAAS,WAAY,OAA0B,KAAA;;;;;AAMvE,MAAa,gBACZ,MACA,MAAc,KAAK,IAAI,MACV;CACb,MAAM,WAAW,MAAM;CACvB,IAAI,OAAO,aAAa,YAAY,SAAS,WAAW,GACvD,OAAO;CAER,MAAM,KAAK,KAAK,MAAM,QAAQ;CAC9B,OAAO,OAAO,SAAS,EAAE,KAAK,MAAM;AACrC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { PollOption } from "../poll/definePollOptionSource.js";
|
|
2
|
+
import { FormDocument } from "./types.js";
|
|
3
|
+
|
|
4
|
+
//#region src/form/toFormDocument.d.ts
|
|
5
|
+
type ToFormDocumentOptions = {
|
|
6
|
+
/**
|
|
7
|
+
* Source-resolved poll options (from `resolvePollOptions`), injected as the options of the
|
|
8
|
+
* field instance named by the form's `poll.resultsField` so the client renders the host's
|
|
9
|
+
* current choices instead of hand-authored ones.
|
|
10
|
+
*/
|
|
11
|
+
pollOptions?: PollOption[];
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Narrows a Payload-generated form document (from `getPayload().findByID()` or `fetch`) to
|
|
15
|
+
* `FormDocument` without an unsafe `as` cast. Handles the small structural mismatches between
|
|
16
|
+
* the auto-generated collection types and what `<Form>` expects:
|
|
17
|
+
* - `fields` may be a typed blocks-union array or null; normalized to `FormFieldInstance[]`
|
|
18
|
+
* - `flow` is stored as opaque JSON; typed as `FormFlow | undefined`
|
|
19
|
+
* - `response` may be null; coerced to `undefined`
|
|
20
|
+
* - `display` may be null; coerced to `undefined`
|
|
21
|
+
* - `poll` may be null; coerced to `undefined` (`resultsField`, `optionSource`, and
|
|
22
|
+
* `sourceConfig` are dropped: server-side only; `outcome` passes through `winningValue` only)
|
|
23
|
+
*
|
|
24
|
+
* Pure and framework-agnostic (no 'use client'): safe to call from a Server Component or any
|
|
25
|
+
* other server-side code before handing the result to the client `<Form>`.
|
|
26
|
+
*/
|
|
27
|
+
declare function toFormDocument(form: {
|
|
28
|
+
id: number | string;
|
|
29
|
+
fields?: {
|
|
30
|
+
blockType: string;
|
|
31
|
+
name: string;
|
|
32
|
+
[key: string]: unknown;
|
|
33
|
+
}[] | null;
|
|
34
|
+
flow?: unknown;
|
|
35
|
+
response?: {
|
|
36
|
+
type?: string | null;
|
|
37
|
+
message?: unknown;
|
|
38
|
+
redirect?: {
|
|
39
|
+
url?: string | null;
|
|
40
|
+
} | null;
|
|
41
|
+
submitLabel?: string | null;
|
|
42
|
+
} | null;
|
|
43
|
+
display?: {
|
|
44
|
+
showTitle?: boolean | null;
|
|
45
|
+
title?: string | null;
|
|
46
|
+
intro?: unknown;
|
|
47
|
+
} | null;
|
|
48
|
+
poll?: {
|
|
49
|
+
enabled?: boolean | null;
|
|
50
|
+
resultsField?: string | null;
|
|
51
|
+
resultsVisibility?: string | null;
|
|
52
|
+
closesAt?: string | null;
|
|
53
|
+
outcome?: {
|
|
54
|
+
winningValue?: string | null;
|
|
55
|
+
} | null;
|
|
56
|
+
} | null;
|
|
57
|
+
}, options?: ToFormDocumentOptions): FormDocument;
|
|
58
|
+
//#endregion
|
|
59
|
+
export { ToFormDocumentOptions, toFormDocument };
|
|
60
|
+
//# sourceMappingURL=toFormDocument.d.ts.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { applyPollOptions } from "../poll/applyPollOptions.js";
|
|
2
|
+
//#region src/form/toFormDocument.ts
|
|
3
|
+
/**
|
|
4
|
+
* Narrows a Payload-generated form document (from `getPayload().findByID()` or `fetch`) to
|
|
5
|
+
* `FormDocument` without an unsafe `as` cast. Handles the small structural mismatches between
|
|
6
|
+
* the auto-generated collection types and what `<Form>` expects:
|
|
7
|
+
* - `fields` may be a typed blocks-union array or null; normalized to `FormFieldInstance[]`
|
|
8
|
+
* - `flow` is stored as opaque JSON; typed as `FormFlow | undefined`
|
|
9
|
+
* - `response` may be null; coerced to `undefined`
|
|
10
|
+
* - `display` may be null; coerced to `undefined`
|
|
11
|
+
* - `poll` may be null; coerced to `undefined` (`resultsField`, `optionSource`, and
|
|
12
|
+
* `sourceConfig` are dropped: server-side only; `outcome` passes through `winningValue` only)
|
|
13
|
+
*
|
|
14
|
+
* Pure and framework-agnostic (no 'use client'): safe to call from a Server Component or any
|
|
15
|
+
* other server-side code before handing the result to the client `<Form>`.
|
|
16
|
+
*/
|
|
17
|
+
function toFormDocument(form, options) {
|
|
18
|
+
const winningValue = form.poll?.outcome?.winningValue;
|
|
19
|
+
const poll = form.poll ? {
|
|
20
|
+
enabled: form.poll.enabled ?? void 0,
|
|
21
|
+
resultsVisibility: form.poll.resultsVisibility ?? void 0,
|
|
22
|
+
closesAt: form.poll.closesAt ?? void 0,
|
|
23
|
+
...typeof winningValue === "string" && winningValue.length > 0 ? { outcome: { winningValue } } : {}
|
|
24
|
+
} : void 0;
|
|
25
|
+
let fields = form.fields ?? [];
|
|
26
|
+
if (options?.pollOptions) fields = applyPollOptions(fields, form.poll?.resultsField, options.pollOptions);
|
|
27
|
+
return {
|
|
28
|
+
id: form.id,
|
|
29
|
+
fields,
|
|
30
|
+
flow: form.flow,
|
|
31
|
+
response: form.response ?? void 0,
|
|
32
|
+
display: form.display ?? void 0,
|
|
33
|
+
poll
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
//#endregion
|
|
37
|
+
export { toFormDocument };
|
|
38
|
+
|
|
39
|
+
//# sourceMappingURL=toFormDocument.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toFormDocument.js","names":[],"sources":["../../src/form/toFormDocument.ts"],"sourcesContent":["import type { FormFlow } from '../flow/types'\nimport { applyPollOptions } from '../poll/applyPollOptions'\nimport type { PollOption } from '../poll/definePollOptionSource'\nimport type { FormFieldInstance } from '../submissions/types'\nimport type { FormDisplaySettings, FormDocument, FormResponseSettings } from './types'\n\nexport type ToFormDocumentOptions = {\n\t/**\n\t * Source-resolved poll options (from `resolvePollOptions`), injected as the options of the\n\t * field instance named by the form's `poll.resultsField` so the client renders the host's\n\t * current choices instead of hand-authored ones.\n\t */\n\tpollOptions?: PollOption[]\n}\n\n/**\n * Narrows a Payload-generated form document (from `getPayload().findByID()` or `fetch`) to\n * `FormDocument` without an unsafe `as` cast. Handles the small structural mismatches between\n * the auto-generated collection types and what `<Form>` expects:\n * - `fields` may be a typed blocks-union array or null; normalized to `FormFieldInstance[]`\n * - `flow` is stored as opaque JSON; typed as `FormFlow | undefined`\n * - `response` may be null; coerced to `undefined`\n * - `display` may be null; coerced to `undefined`\n * - `poll` may be null; coerced to `undefined` (`resultsField`, `optionSource`, and\n * `sourceConfig` are dropped: server-side only; `outcome` passes through `winningValue` only)\n *\n * Pure and framework-agnostic (no 'use client'): safe to call from a Server Component or any\n * other server-side code before handing the result to the client `<Form>`.\n */\nexport function toFormDocument(\n\tform: {\n\t\tid: number | string\n\t\tfields?: { blockType: string; name: string; [key: string]: unknown }[] | null\n\t\tflow?: unknown\n\t\tresponse?: {\n\t\t\ttype?: string | null\n\t\t\tmessage?: unknown\n\t\t\tredirect?: { url?: string | null } | null\n\t\t\tsubmitLabel?: string | null\n\t\t} | null\n\t\tdisplay?: {\n\t\t\tshowTitle?: boolean | null\n\t\t\ttitle?: string | null\n\t\t\tintro?: unknown\n\t\t} | null\n\t\tpoll?: {\n\t\t\tenabled?: boolean | null\n\t\t\tresultsField?: string | null\n\t\t\tresultsVisibility?: string | null\n\t\t\tclosesAt?: string | null\n\t\t\toutcome?: { winningValue?: string | null } | null\n\t\t} | null\n\t},\n\toptions?: ToFormDocumentOptions\n): FormDocument {\n\tconst winningValue = form.poll?.outcome?.winningValue\n\tconst poll = form.poll\n\t\t? {\n\t\t\t\tenabled: form.poll.enabled ?? undefined,\n\t\t\t\tresultsVisibility: (form.poll.resultsVisibility ?? undefined) as\n\t\t\t\t\t| 'afterVote'\n\t\t\t\t\t| 'afterClose'\n\t\t\t\t\t| undefined,\n\t\t\t\tclosesAt: form.poll.closesAt ?? undefined,\n\t\t\t\t...(typeof winningValue === 'string' && winningValue.length > 0\n\t\t\t\t\t? { outcome: { winningValue } }\n\t\t\t\t\t: {}),\n\t\t\t}\n\t\t: undefined\n\tlet fields = (form.fields ?? []) as FormFieldInstance[]\n\tif (options?.pollOptions) {\n\t\tfields = applyPollOptions(fields, form.poll?.resultsField, options.pollOptions)\n\t}\n\treturn {\n\t\tid: form.id,\n\t\tfields,\n\t\tflow: form.flow as FormFlow | undefined,\n\t\tresponse: (form.response as FormResponseSettings | null | undefined) ?? undefined,\n\t\tdisplay: (form.display as FormDisplaySettings | null | undefined) ?? undefined,\n\t\tpoll,\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA6BA,SAAgB,eACf,MAuBA,SACe;CACf,MAAM,eAAe,KAAK,MAAM,SAAS;CACzC,MAAM,OAAO,KAAK,OACf;EACA,SAAS,KAAK,KAAK,WAAW,KAAA;EAC9B,mBAAoB,KAAK,KAAK,qBAAqB,KAAA;EAInD,UAAU,KAAK,KAAK,YAAY,KAAA;EAChC,GAAI,OAAO,iBAAiB,YAAY,aAAa,SAAS,IAC3D,EAAE,SAAS,EAAE,aAAa,EAAE,IAC5B,CAAC;CACL,IACC,KAAA;CACH,IAAI,SAAU,KAAK,UAAU,CAAC;CAC9B,IAAI,SAAS,aACZ,SAAS,iBAAiB,QAAQ,KAAK,MAAM,cAAc,QAAQ,WAAW;CAE/E,OAAO;EACN,IAAI,KAAK;EACT;EACA,MAAM,KAAK;EACX,UAAW,KAAK,YAAwD,KAAA;EACxE,SAAU,KAAK,WAAsD,KAAA;EACrE;CACD;AACD"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { FormFieldInstance } from "../submissions/types.js";
|
|
2
|
+
import { FormFlow } from "../flow/types.js";
|
|
3
|
+
|
|
4
|
+
//#region src/form/types.d.ts
|
|
5
|
+
/** Serializable per-form response settings: what the visitor gets after a successful submit. */
|
|
6
|
+
type FormResponseSettings = {
|
|
7
|
+
type?: 'message' | 'redirect' | null; /** Rich text state serialized via `serializeBody`; shown instead of the plain `successMessage`. */
|
|
8
|
+
message?: unknown; /** Applies on the custom-`children` path too (part of submit handling); `message`/`submitLabel` only affect default rendering. */
|
|
9
|
+
redirect?: {
|
|
10
|
+
url?: string | null;
|
|
11
|
+
} | null;
|
|
12
|
+
submitLabel?: string | null;
|
|
13
|
+
};
|
|
14
|
+
/** Serializable per-form display settings: what the visitor sees above the fields, before submit. */
|
|
15
|
+
type FormDisplaySettings = {
|
|
16
|
+
showTitle?: boolean;
|
|
17
|
+
title?: string; /** Rich text state serialized via `serializeBody`; rendered above the fields when non-empty. */
|
|
18
|
+
intro?: unknown;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Serializable per-form poll settings the client needs for lifecycle rendering (open/voted/closed).
|
|
22
|
+
* `resultsField` intentionally stays server-side: the results endpoint resolves the public field
|
|
23
|
+
* itself, so the client never needs it from the document.
|
|
24
|
+
*/
|
|
25
|
+
type FormPollSettings = {
|
|
26
|
+
enabled?: boolean; /** When anonymous callers may read aggregate results. Default 'afterVote'. */
|
|
27
|
+
resultsVisibility?: 'afterVote' | 'afterClose' | null; /** ISO date after which submissions are rejected and the poll renders as closed. */
|
|
28
|
+
closesAt?: string | null; /** Present once the host recorded a final outcome via `resolvePollOutcome`; `<Poll>` renders the final state. */
|
|
29
|
+
outcome?: {
|
|
30
|
+
winningValue?: string;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Serializable shape `<Form>` expects, and what `toFormDocument` narrows a Payload-generated
|
|
35
|
+
* document to. Framework-agnostic (no React, no 'use client') so it can be constructed and
|
|
36
|
+
* consumed on the server, e.g. in a Server Component before handing it to the client `<Form>`.
|
|
37
|
+
*/
|
|
38
|
+
type FormDocument = {
|
|
39
|
+
id: number | string;
|
|
40
|
+
fields: FormFieldInstance[];
|
|
41
|
+
flow?: FormFlow;
|
|
42
|
+
response?: FormResponseSettings;
|
|
43
|
+
display?: FormDisplaySettings;
|
|
44
|
+
poll?: FormPollSettings;
|
|
45
|
+
};
|
|
46
|
+
//#endregion
|
|
47
|
+
export { FormDisplaySettings, FormDocument, FormPollSettings, FormResponseSettings };
|
|
48
|
+
//# sourceMappingURL=types.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { FileFieldConfig, FileRef, FileRefError } from "./uploads/types.js";
|
|
2
2
|
import { AnyFormFieldDefinition, FormFieldDefinition, FormFieldFormat, FormFieldValidate, FormFieldValueKind } from "./fields/types.js";
|
|
3
3
|
import { TranslationsOption } from "./translations/index.js";
|
|
4
|
+
import { BodyConverter, BodyConverterArgs, BodyRender, defaultBodyConverters, sanitizeUrl } from "./actions/body/converters.js";
|
|
5
|
+
import { BodyContext, RichTextBodyOption, SerializeBodyArgs, serializeBody } from "./actions/body/serializeBody.js";
|
|
4
6
|
import { AggregationBucket, AggregationRow, FieldAggregation, FieldMeta, SubmissionStatusFilter } from "./aggregation/types.js";
|
|
5
7
|
import { CalcExpression } from "./calc/types.js";
|
|
6
8
|
import { calcExpressionOf, computeCalcFields } from "./calc/computeCalcFields.js";
|
|
7
9
|
import { evaluateCalc } from "./calc/evaluate.js";
|
|
8
10
|
import { evaluateCondition } from "./conditions/evaluate.js";
|
|
11
|
+
import { AnyPollOptionSource, PollOption, PollOptionResolveArgs, PollOptionSource, definePollOptionSource } from "./poll/definePollOptionSource.js";
|
|
12
|
+
import { FormDisplaySettings, FormDocument, FormPollSettings, FormResponseSettings } from "./form/types.js";
|
|
13
|
+
import { ToFormDocumentOptions, toFormDocument } from "./form/toFormDocument.js";
|
|
9
14
|
import { FieldTypeOption, FieldTypeRegistry, FieldTypesConfig } from "./fields/registry.js";
|
|
10
15
|
import { PrefillOptions, valuesFromSearchParams } from "./prefill/valuesFromSearchParams.js";
|
|
11
16
|
import { FormEventSink } from "./events/types.js";
|
|
@@ -14,35 +19,49 @@ import { PresentationDensity, PresentationDescriptor, PresentationSurface } from
|
|
|
14
19
|
import { interpolate } from "./recall/interpolate.js";
|
|
15
20
|
import { RecallResolver, buildRecallResolver, optionLabelsFor } from "./recall/resolver.js";
|
|
16
21
|
import { CAPTCHA_TOKEN_KEY, DEFAULT_HONEYPOT_FIELD } from "./spam/constants.js";
|
|
22
|
+
import { formatBytes } from "./uploads/formatBytes.js";
|
|
23
|
+
import { isPollClosed } from "./form/pollState.js";
|
|
24
|
+
import { PollOptionSourceOption, PollOptionSourceRegistry, PollOptionSourcesConfig, resolvePollOptionSources } from "./poll/registry.js";
|
|
25
|
+
import { ResolvePollOptionsArgs, resolvePollOptions } from "./poll/resolvePollOptions.js";
|
|
26
|
+
import { ResolvePollOutcomeArgs, resolvePollOutcome } from "./poll/resolvePollOutcome.js";
|
|
27
|
+
import { hasVotedCookie, votedCookieName } from "./submissions/votedCookie.js";
|
|
17
28
|
import { ActionDefinition, ActionRunArgs, AnyActionDefinition, defineAction } from "./actions/defineAction.js";
|
|
18
29
|
import { ActionOption, ActionRegistry, ActionsConfig, resolveActions } from "./actions/registry.js";
|
|
19
30
|
import { ActionResult } from "./actions/runActions.js";
|
|
20
31
|
import { AggregateFieldResponsesArgs, AggregateFormResponsesArgs, aggregateFieldResponses, aggregateFormResponses, fieldHasOptions } from "./aggregation/aggregateResponses.js";
|
|
21
|
-
import { ResolveResultsRequestArgs, ResolveResultsRequestResult, resolveFormResultsRequest } from "./aggregation/resolveResultsRequest.js";
|
|
22
|
-
import { CollectionOverrides } from "./plugin/collectionOverrides.js";
|
|
23
|
-
import { FORM_UPLOADS_SLUG, UploadsCollectionConfig, UploadsOption, buildUploadsCollection, resolveUploads } from "./collections/uploads.js";
|
|
32
|
+
import { FormResultsAccess, FormResultsAccessArgs, ResolveResultsRequestArgs, ResolveResultsRequestResult, resolveFormResultsRequest } from "./aggregation/resolveResultsRequest.js";
|
|
24
33
|
import { FieldCondition } from "./conditions/types.js";
|
|
25
34
|
import { AnyConsentSource, ConsentLink, ConsentResolveArgs, ConsentResolved, ConsentSource, defineConsentSource } from "./consent/defineConsentSource.js";
|
|
26
35
|
import { ConsentSourceOption, ConsentSourceRegistry, ConsentSourcesConfig, resolveConsentSources } from "./consent/registry.js";
|
|
27
36
|
import { ConsentProof, captureConsent } from "./consent/captureConsent.js";
|
|
28
|
-
import {
|
|
37
|
+
import { CollectionOverrides } from "./plugin/collectionOverrides.js";
|
|
29
38
|
import { CaptchaProvider, CaptchaVerifyArgs, IdentifyFn, RateLimitCheckArgs, RateLimitConfig, RateLimitResult, RateLimiter, SpamConfig, SpamMetadataConfig, SpamOption } from "./spam/types.js";
|
|
39
|
+
import { UploadsOption } from "./plugin/uploadsCollection.js";
|
|
30
40
|
import { ValidationRuleOption, ValidationRuleRegistry, ValidationRulesConfig } from "./validation/registry.js";
|
|
31
|
-
import {
|
|
41
|
+
import { escapeHtml } from "./actions/body/escapeHtml.js";
|
|
42
|
+
import { renderAllValues, renderAllValuesTable } from "./actions/body/wildcards.js";
|
|
43
|
+
import { buildDefaultActionDefinitions, defaultActionDefinitions } from "./actions/builtin/index.js";
|
|
32
44
|
import { SIGNATURE_HEADER, signPayload } from "./actions/sign.js";
|
|
33
45
|
import { aggregateRowForField, aggregateRowsForFields } from "./aggregation/aggregateRows.js";
|
|
34
46
|
import { normalizeCalc } from "./calc/normalizeCalc.js";
|
|
35
|
-
import { defaultConsentSources } from "./consent/builtin/index.js";
|
|
47
|
+
import { buildDefaultConsentSources, defaultConsentSources } from "./consent/builtin/index.js";
|
|
36
48
|
import { resolveConsentLinks } from "./consent/resolveConsentLinks.js";
|
|
37
49
|
import { resolvePublishedVersionRef } from "./consent/resolvePublishedVersionRef.js";
|
|
50
|
+
import { buildDefaultFieldDefinitions, defaultFieldDefinitions, defaultFieldDefinitionsByType } from "./fields/builtin/index.js";
|
|
51
|
+
import { fileMimeTypeOptions } from "./fields/builtin/file.js";
|
|
38
52
|
import { defineFormField } from "./fields/defineFormField.js";
|
|
53
|
+
import { localizedIf } from "./fields/localizedIf.js";
|
|
39
54
|
import { DEFAULT_PRESENTATION_NAME, defaultPresentationDescriptors } from "./presentations/defaults.js";
|
|
40
55
|
import { defineCaptchaProvider } from "./spam/captcha.js";
|
|
41
56
|
import { defaultIdentify } from "./spam/identify.js";
|
|
57
|
+
import { HcaptchaProviderOptions, hcaptchaProvider } from "./spam/providers/hcaptcha.js";
|
|
58
|
+
import { RecaptchaProviderOptions, recaptchaProvider } from "./spam/providers/recaptcha.js";
|
|
59
|
+
import { TurnstileProviderOptions, turnstileProvider } from "./spam/providers/turnstile.js";
|
|
42
60
|
import { createKvRateLimiter } from "./spam/rateLimiter.js";
|
|
43
61
|
import { resolveSpamConfig } from "./spam/resolveSpam.js";
|
|
44
62
|
import { resolveFileRef } from "./uploads/resolveFileRef.js";
|
|
45
63
|
import { captureFileRef } from "./uploads/captureFileRef.js";
|
|
64
|
+
import { defaultValidationRules, defaultValidationRulesByType } from "./validation/builtin/index.js";
|
|
46
65
|
import { defineValidationRule } from "./validation/defineValidationRule.js";
|
|
47
66
|
|
|
48
67
|
//#region src/index.d.ts
|
|
@@ -55,14 +74,64 @@ type FormBuilderPluginOptions = {
|
|
|
55
74
|
* added whole. App-level `i18n.translations` still wins over both.
|
|
56
75
|
*/
|
|
57
76
|
translations?: TranslationsOption; /** Pluggable sink for form lifecycle events. Defaults to a no-op; analytics adapters or a future analytics plugin subscribe here. */
|
|
58
|
-
events?: FormEventSink;
|
|
59
|
-
|
|
60
|
-
|
|
77
|
+
events?: FormEventSink;
|
|
78
|
+
/**
|
|
79
|
+
* Content-bearing author fields (labels, placeholders, option labels, consent statements,
|
|
80
|
+
* action subjects and bodies) are localized by default. Payload strips the `localized` flag
|
|
81
|
+
* on hosts without `localization` configured, so the default is safe everywhere. Set `false`
|
|
82
|
+
* to keep form content single-locale even on localized hosts. Spread-overrides of the prebuilt
|
|
83
|
+
* default exports (`defaultFieldDefinitionsByType`, `defaultActionDefinitions`,
|
|
84
|
+
* `defaultConsentSources`) carry `localized` flags from the default-true set; when opting out,
|
|
85
|
+
* derive overrides from `buildDefaultFieldDefinitions(false)` /
|
|
86
|
+
* `buildDefaultActionDefinitions(false)` / `buildDefaultConsentSources(false)` instead.
|
|
87
|
+
*/
|
|
88
|
+
localizeContent?: boolean; /** Add, override, or remove field types. `false` removes a built-in, `true` keeps it, an object adds or replaces one. */
|
|
89
|
+
fields?: FieldTypesConfig; /** Add, override, or remove validation rule types. `false` removes a built-in, `true` keeps it, an object adds or replaces one. */
|
|
61
90
|
rules?: ValidationRulesConfig; /** Add, override, or remove post-submit action types. `false` removes a built-in, `true` keeps it, an object adds or replaces one. */
|
|
62
|
-
actions?: ActionsConfig;
|
|
63
|
-
|
|
91
|
+
actions?: ActionsConfig;
|
|
92
|
+
/**
|
|
93
|
+
* Customize how rich text action bodies are authored and rendered. `editor` overrides the
|
|
94
|
+
* Lexical/richText editor on both the emailTeam and confirmation action body fields.
|
|
95
|
+
* `converters` spread over the default Lexical node converters; `serialize` replaces the
|
|
96
|
+
* whole pipeline (e.g. to target chat or plain-text channels instead of email HTML). A
|
|
97
|
+
* custom `serialize` receives the submitted `form` (id/title) and `req`, enabling per-tenant
|
|
98
|
+
* lookups or handing the raw body off to a renderer like react-email.
|
|
99
|
+
*/
|
|
100
|
+
richText?: RichTextBodyOption; /** Add, override, or remove consent source types. `false` removes a built-in, `true` keeps it, an object adds or replaces one. */
|
|
101
|
+
consentSources?: ConsentSourcesConfig;
|
|
102
|
+
/**
|
|
103
|
+
* File uploads are bring-your-own. Default `false`: no upload collection is involved and the
|
|
104
|
+
* built-in `file` field type is removed from the registry, so form authors cannot add a field
|
|
105
|
+
* with nowhere to land (a developer-registered custom `file` type via `fields` still wins).
|
|
106
|
+
* `{ collection: 'slug' }` points at a host-owned upload collection (created by the app with
|
|
107
|
+
* its storage adapter); the plugin validates it at boot, appends its hidden `owner` field when
|
|
108
|
+
* absent, and prepends the spam upload hooks.
|
|
109
|
+
*/
|
|
64
110
|
uploads?: UploadsOption; /** Honeypot + rate-limiting (on by default) + a captcha adapter seam + upload-ownership scoping. `false` disables the whole subsystem. */
|
|
65
111
|
spam?: SpamOption;
|
|
112
|
+
/**
|
|
113
|
+
* Aggregate-results endpoint options. `access` gates anonymous reads after the form is loaded
|
|
114
|
+
* and before anything is served; absent keeps the plugin-default gating (poll opt-in +
|
|
115
|
+
* visibility + enumerable-field guard). Multi-tenant hosts should compare `form.tenant` against
|
|
116
|
+
* the tenant derived from `req` so one tenant's poll counts are never readable under another
|
|
117
|
+
* tenant's id. Authenticated callers bypass this seam.
|
|
118
|
+
*/
|
|
119
|
+
results?: {
|
|
120
|
+
access?: FormResultsAccess;
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* Poll behavior. `votedCookie: true` sets an httpOnly `fb-voted-{formId}=1` cookie on each
|
|
124
|
+
* successful submission to a poll-enabled form, letting SSR hosts read the voted state via
|
|
125
|
+
* `hasVotedCookie` and pass it to `<Poll hasVoted>`. Default `false`.
|
|
126
|
+
* `sources` registers poll option sources (`definePollOptionSource`), letting authors populate
|
|
127
|
+
* a poll's choices from host domain data with stable values; there are no built-ins. With at
|
|
128
|
+
* least one source registered, the forms poll group gains an `optionSource` select plus its
|
|
129
|
+
* per-source `sourceConfig`, and submissions to a sourced poll only accept resolved values.
|
|
130
|
+
*/
|
|
131
|
+
poll?: {
|
|
132
|
+
votedCookie?: boolean;
|
|
133
|
+
sources?: PollOptionSourcesConfig;
|
|
134
|
+
};
|
|
66
135
|
/**
|
|
67
136
|
* When `true`, the raw `values`, `descriptors`, and `consent` JSON fields are visible in the
|
|
68
137
|
* submission admin view. Default `false` — those fields are fully represented by the
|
|
@@ -79,7 +148,6 @@ type FormBuilderPluginOptions = {
|
|
|
79
148
|
overrides?: {
|
|
80
149
|
forms?: CollectionOverrides;
|
|
81
150
|
formSubmissions?: CollectionOverrides;
|
|
82
|
-
uploads?: CollectionOverrides;
|
|
83
151
|
};
|
|
84
152
|
};
|
|
85
153
|
declare module 'payload' {
|
|
@@ -89,5 +157,5 @@ declare module 'payload' {
|
|
|
89
157
|
}
|
|
90
158
|
declare const formBuilder: (options: FormBuilderPluginOptions) => import("payload").Plugin;
|
|
91
159
|
//#endregion
|
|
92
|
-
export { type ActionDefinition, type ActionOption, type ActionRegistry, type ActionResult, type ActionRunArgs, type ActionsConfig, type AggregateFieldResponsesArgs, type AggregateFormResponsesArgs, type AggregationBucket, type AggregationRow, type AnyActionDefinition, type AnyConsentSource, type AnyFormFieldDefinition, type AnyValidationRuleDefinition, CAPTCHA_TOKEN_KEY, type CalcExpression, type CaptchaProvider, type CaptchaVerifyArgs, type ConsentLink, type ConsentProof, type ConsentResolveArgs, type ConsentResolved, type ConsentSource, type ConsentSourceOption, type ConsentSourceRegistry, type ConsentSourcesConfig, DEFAULT_HONEYPOT_FIELD, DEFAULT_PRESENTATION_NAME,
|
|
160
|
+
export { type ActionDefinition, type ActionOption, type ActionRegistry, type ActionResult, type ActionRunArgs, type ActionsConfig, type AggregateFieldResponsesArgs, type AggregateFormResponsesArgs, type AggregationBucket, type AggregationRow, type AnyActionDefinition, type AnyConsentSource, type AnyFormFieldDefinition, type AnyPollOptionSource, type AnyValidationRuleDefinition, type BodyContext, type BodyConverter, type BodyConverterArgs, type BodyRender, CAPTCHA_TOKEN_KEY, type CalcExpression, type CaptchaProvider, type CaptchaVerifyArgs, type ConsentLink, type ConsentProof, type ConsentResolveArgs, type ConsentResolved, type ConsentSource, type ConsentSourceOption, type ConsentSourceRegistry, type ConsentSourcesConfig, DEFAULT_HONEYPOT_FIELD, DEFAULT_PRESENTATION_NAME, type FieldAggregation, type FieldCondition, type FieldMeta, type FieldTypeOption, type FieldTypeRegistry, type FieldTypesConfig, type FileFieldConfig, type FileRef, type FileRefError, FormBuilderPluginOptions, type FormBuilderPluginOptions as PluginOptions, type FormDisplaySettings, type FormDocument, type FormFieldDefinition, type FormFieldFormat, type FormFieldValidate, type FormFieldValueKind, type FormPollSettings, type FormResponseSettings, type FormResultsAccess, type FormResultsAccessArgs, type HcaptchaProviderOptions, type IdentifyFn, type PollOption, type PollOptionResolveArgs, type PollOptionSource, type PollOptionSourceOption, type PollOptionSourceRegistry, type PollOptionSourcesConfig, type PrefillOptions, type PresentationDensity, type PresentationDescriptor, type PresentationSurface, type RateLimitCheckArgs, type RateLimitConfig, type RateLimitResult, type RateLimiter, type RecallResolver, type RecaptchaProviderOptions, type ResolvePollOptionsArgs, type ResolvePollOutcomeArgs, type ResolveResultsRequestArgs, type ResolveResultsRequestResult, type RichTextBodyOption, SIGNATURE_HEADER, type SerializeBodyArgs, type SpamConfig, type SpamMetadataConfig, type SpamOption, type SubmissionStatusFilter, type ToFormDocumentOptions, type TurnstileProviderOptions, type UploadsOption, type ValidationRuleDefinition, type ValidationRuleOption, type ValidationRuleRegistry, type ValidationRuleResult, type ValidationRulesConfig, type ValidationSeverity, aggregateFieldResponses, aggregateFormResponses, aggregateRowForField, aggregateRowsForFields, buildDefaultActionDefinitions, buildDefaultConsentSources, buildDefaultFieldDefinitions, buildRecallResolver, calcExpressionOf, captureConsent, captureFileRef, computeCalcFields, createKvRateLimiter, defaultActionDefinitions, defaultBodyConverters, defaultConsentSources, defaultFieldDefinitions, defaultFieldDefinitionsByType, defaultIdentify, defaultPresentationDescriptors, defaultValidationRules, defaultValidationRulesByType, defineAction, defineCaptchaProvider, defineConsentSource, defineFormField, definePollOptionSource, defineValidationRule, escapeHtml, evaluateCalc, evaluateCondition, fieldHasOptions, fileMimeTypeOptions, formBuilder, formatBytes, hasVotedCookie, hcaptchaProvider, interpolate, isPollClosed, localizedIf, normalizeCalc, optionLabelsFor, recaptchaProvider, renderAllValues, renderAllValuesTable, resolveActions, resolveConsentLinks, resolveConsentSources, resolveFileRef, resolveFormResultsRequest, resolvePollOptionSources, resolvePollOptions, resolvePollOutcome, resolvePublishedVersionRef, resolveSpamConfig, sanitizeUrl, serializeBody, signPayload, toFormDocument, turnstileProvider, valuesFromSearchParams, votedCookieName };
|
|
93
161
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,22 +1,28 @@
|
|
|
1
|
+
import { localizedIf } from "./fields/localizedIf.js";
|
|
1
2
|
import { interpolate } from "./recall/interpolate.js";
|
|
3
|
+
import { escapeHtml } from "./actions/body/escapeHtml.js";
|
|
4
|
+
import { defaultBodyConverters, sanitizeUrl } from "./actions/body/converters.js";
|
|
5
|
+
import { renderAllValues, renderAllValuesTable } from "./actions/body/wildcards.js";
|
|
6
|
+
import { serializeBody } from "./actions/body/serializeBody.js";
|
|
2
7
|
import { defineAction } from "./actions/defineAction.js";
|
|
3
8
|
import { SIGNATURE_HEADER, signPayload } from "./actions/sign.js";
|
|
4
|
-
import { defaultActionDefinitions } from "./actions/builtin/index.js";
|
|
9
|
+
import { buildDefaultActionDefinitions, defaultActionDefinitions } from "./actions/builtin/index.js";
|
|
5
10
|
import { resolveActions } from "./actions/registry.js";
|
|
6
|
-
import { FORM_UPLOADS_SLUG, buildUploadsCollection, resolveUploads } from "./collections/uploads.js";
|
|
7
11
|
import { defineConsentSource } from "./consent/defineConsentSource.js";
|
|
8
12
|
import { resolvePublishedVersionRef } from "./consent/resolvePublishedVersionRef.js";
|
|
9
|
-
import { defaultConsentSources } from "./consent/builtin/index.js";
|
|
13
|
+
import { buildDefaultConsentSources, defaultConsentSources } from "./consent/builtin/index.js";
|
|
10
14
|
import { resolveConsentSources } from "./consent/registry.js";
|
|
15
|
+
import { normalizeCalc } from "./calc/normalizeCalc.js";
|
|
11
16
|
import { defineFormField } from "./fields/defineFormField.js";
|
|
12
|
-
import {
|
|
17
|
+
import { fileMimeTypeOptions } from "./fields/builtin/file.js";
|
|
18
|
+
import { buildDefaultFieldDefinitions, defaultFieldDefinitions, defaultFieldDefinitionsByType } from "./fields/builtin/index.js";
|
|
13
19
|
import { resolveFieldTypes } from "./fields/registry.js";
|
|
20
|
+
import { isPollClosed } from "./form/pollState.js";
|
|
14
21
|
import { CAPTCHA_TOKEN_KEY, DEFAULT_HONEYPOT_FIELD } from "./spam/constants.js";
|
|
15
22
|
import { aggregateRowForField, aggregateRowsForFields } from "./aggregation/aggregateRows.js";
|
|
16
23
|
import { aggregateFieldResponses, aggregateFormResponses, fieldHasOptions } from "./aggregation/aggregateResponses.js";
|
|
17
24
|
import { resolveFormResultsRequest } from "./aggregation/resolveResultsRequest.js";
|
|
18
|
-
import {
|
|
19
|
-
import { DEFAULT_PRESENTATION_NAME, defaultPresentationDescriptors } from "./presentations/defaults.js";
|
|
25
|
+
import { resolvePollOptions, stashPollOptionSources } from "./poll/resolvePollOptions.js";
|
|
20
26
|
import { evaluateCalc } from "./calc/evaluate.js";
|
|
21
27
|
import { calcExpressionOf, computeCalcFields } from "./calc/computeCalcFields.js";
|
|
22
28
|
import { evaluateCondition } from "./conditions/evaluate.js";
|
|
@@ -24,18 +30,27 @@ import { resolveConsentLinks } from "./consent/resolveConsentLinks.js";
|
|
|
24
30
|
import { captureConsent } from "./consent/captureConsent.js";
|
|
25
31
|
import { resolveFileRef } from "./uploads/resolveFileRef.js";
|
|
26
32
|
import { captureFileRef } from "./uploads/captureFileRef.js";
|
|
33
|
+
import { hasVotedCookie, votedCookieName } from "./submissions/votedCookie.js";
|
|
27
34
|
import { registerCollections } from "./plugin/registerCollections.js";
|
|
28
35
|
import { registerTranslations } from "./plugin/registerTranslations.js";
|
|
29
|
-
import {
|
|
36
|
+
import { resolvePollOptionSources } from "./poll/registry.js";
|
|
30
37
|
import { defaultIdentify } from "./spam/identify.js";
|
|
31
38
|
import { createKvRateLimiter } from "./spam/rateLimiter.js";
|
|
32
39
|
import { resolveSpamConfig } from "./spam/resolveSpam.js";
|
|
33
40
|
import { defineValidationRule } from "./validation/defineValidationRule.js";
|
|
34
|
-
import { defaultValidationRules } from "./validation/builtin/index.js";
|
|
41
|
+
import { defaultValidationRules, defaultValidationRulesByType } from "./validation/builtin/index.js";
|
|
35
42
|
import { resolveValidationRules } from "./validation/registry.js";
|
|
43
|
+
import { toFormDocument } from "./form/toFormDocument.js";
|
|
44
|
+
import { definePollOptionSource } from "./poll/definePollOptionSource.js";
|
|
45
|
+
import { resolvePollOutcome } from "./poll/resolvePollOutcome.js";
|
|
36
46
|
import { valuesFromSearchParams } from "./prefill/valuesFromSearchParams.js";
|
|
47
|
+
import { DEFAULT_PRESENTATION_NAME, defaultPresentationDescriptors } from "./presentations/defaults.js";
|
|
37
48
|
import { buildRecallResolver, optionLabelsFor } from "./recall/resolver.js";
|
|
38
49
|
import { defineCaptchaProvider } from "./spam/captcha.js";
|
|
50
|
+
import { hcaptchaProvider } from "./spam/providers/hcaptcha.js";
|
|
51
|
+
import { recaptchaProvider } from "./spam/providers/recaptcha.js";
|
|
52
|
+
import { turnstileProvider } from "./spam/providers/turnstile.js";
|
|
53
|
+
import { formatBytes } from "./uploads/formatBytes.js";
|
|
39
54
|
import { definePlugin } from "payload";
|
|
40
55
|
//#region src/index.ts
|
|
41
56
|
const formBuilder = definePlugin({
|
|
@@ -43,32 +58,38 @@ const formBuilder = definePlugin({
|
|
|
43
58
|
order: 50,
|
|
44
59
|
plugin: ({ config, plugins, ...options }) => {
|
|
45
60
|
if (options.disabled === true) return config;
|
|
46
|
-
const
|
|
61
|
+
const localizeContent = options.localizeContent !== false;
|
|
62
|
+
const uploads = options.uploads ?? false;
|
|
63
|
+
const registry = resolveFieldTypes(buildDefaultFieldDefinitions(localizeContent).filter((definition) => uploads !== false || definition.type !== "file"), options.fields);
|
|
47
64
|
const ruleRegistry = resolveValidationRules(defaultValidationRules, options.rules);
|
|
48
|
-
const consentRegistry = resolveConsentSources(
|
|
49
|
-
const
|
|
50
|
-
const actionRegistry = resolveActions(defaultActionDefinitions, options.actions);
|
|
51
|
-
const uploads = resolveUploads(options.uploads);
|
|
65
|
+
const consentRegistry = resolveConsentSources(buildDefaultConsentSources(localizeContent), options.consentSources);
|
|
66
|
+
const actionRegistry = resolveActions(buildDefaultActionDefinitions(localizeContent, options.richText?.editor), options.actions);
|
|
52
67
|
const spam = resolveSpamConfig(options.spam);
|
|
68
|
+
const pollSourceRegistry = resolvePollOptionSources(options.poll?.sources);
|
|
69
|
+
config.custom = stashPollOptionSources(config.custom, pollSourceRegistry);
|
|
53
70
|
registerTranslations(config, options.translations);
|
|
54
71
|
registerCollections({
|
|
55
72
|
config,
|
|
56
73
|
registry,
|
|
57
74
|
ruleRegistry,
|
|
58
75
|
consentRegistry,
|
|
59
|
-
presentationRegistry,
|
|
60
76
|
actionRegistry,
|
|
77
|
+
richText: options.richText,
|
|
61
78
|
hasJobsPlugin: Boolean(plugins["@10x-media/jobs"]),
|
|
62
79
|
events: options.events,
|
|
63
80
|
uploads,
|
|
64
81
|
spam,
|
|
65
82
|
showSubmissionRawFields: options.showSubmissionRawFields ?? false,
|
|
83
|
+
localizeContent,
|
|
84
|
+
resultsAccess: options.results?.access,
|
|
85
|
+
votedCookie: options.poll?.votedCookie === true,
|
|
86
|
+
pollSourceRegistry,
|
|
66
87
|
overrides: options.overrides
|
|
67
88
|
});
|
|
68
89
|
return config;
|
|
69
90
|
}
|
|
70
91
|
});
|
|
71
92
|
//#endregion
|
|
72
|
-
export { CAPTCHA_TOKEN_KEY, DEFAULT_HONEYPOT_FIELD, DEFAULT_PRESENTATION_NAME,
|
|
93
|
+
export { CAPTCHA_TOKEN_KEY, DEFAULT_HONEYPOT_FIELD, DEFAULT_PRESENTATION_NAME, SIGNATURE_HEADER, aggregateFieldResponses, aggregateFormResponses, aggregateRowForField, aggregateRowsForFields, buildDefaultActionDefinitions, buildDefaultConsentSources, buildDefaultFieldDefinitions, buildRecallResolver, calcExpressionOf, captureConsent, captureFileRef, computeCalcFields, createKvRateLimiter, defaultActionDefinitions, defaultBodyConverters, defaultConsentSources, defaultFieldDefinitions, defaultFieldDefinitionsByType, defaultIdentify, defaultPresentationDescriptors, defaultValidationRules, defaultValidationRulesByType, defineAction, defineCaptchaProvider, defineConsentSource, defineFormField, definePollOptionSource, defineValidationRule, escapeHtml, evaluateCalc, evaluateCondition, fieldHasOptions, fileMimeTypeOptions, formBuilder, formatBytes, hasVotedCookie, hcaptchaProvider, interpolate, isPollClosed, localizedIf, normalizeCalc, optionLabelsFor, recaptchaProvider, renderAllValues, renderAllValuesTable, resolveActions, resolveConsentLinks, resolveConsentSources, resolveFileRef, resolveFormResultsRequest, resolvePollOptionSources, resolvePollOptions, resolvePollOutcome, resolvePublishedVersionRef, resolveSpamConfig, sanitizeUrl, serializeBody, signPayload, toFormDocument, turnstileProvider, valuesFromSearchParams, votedCookieName };
|
|
73
94
|
|
|
74
95
|
//# sourceMappingURL=index.js.map
|