@10x-media/form-builder 0.1.0-beta.10 → 0.1.0-beta.12
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 +25 -0
- package/dist/actions/assertNoBlockCollision.js +18 -0
- package/dist/actions/assertNoBlockCollision.js.map +1 -0
- package/dist/actions/builtin/confirmation.js +2 -1
- package/dist/actions/builtin/confirmation.js.map +1 -1
- package/dist/actions/builtin/emailAction.d.ts +3 -1
- package/dist/actions/builtin/emailAction.js +43 -12
- package/dist/actions/builtin/emailAction.js.map +1 -1
- package/dist/actions/builtin/emailTeam.js +11 -5
- package/dist/actions/builtin/emailTeam.js.map +1 -1
- package/dist/actions/defineAction.d.ts +3 -1
- package/dist/actions/defineAction.js.map +1 -1
- package/dist/actions/dispatch.js +1 -1
- package/dist/actions/dispatch.js.map +1 -1
- package/dist/actions/emailRecipients.js +34 -7
- package/dist/actions/emailRecipients.js.map +1 -1
- package/dist/actions/recipientSources.d.ts +34 -0
- package/dist/actions/recipientSources.js +11 -0
- package/dist/actions/recipientSources.js.map +1 -0
- package/dist/actions/task.js +20 -0
- package/dist/actions/task.js.map +1 -1
- package/dist/aggregation/resolveResultsRequest.d.ts +6 -0
- package/dist/aggregation/resolveResultsRequest.js +32 -3
- package/dist/aggregation/resolveResultsRequest.js.map +1 -1
- package/dist/calc/computeCalcFields.d.ts +5 -3
- package/dist/calc/computeCalcFields.js +4 -3
- package/dist/calc/computeCalcFields.js.map +1 -1
- package/dist/calc/evaluate.d.ts +26 -3
- package/dist/calc/evaluate.js +33 -11
- package/dist/calc/evaluate.js.map +1 -1
- package/dist/calc/formatCalc.d.ts +11 -0
- package/dist/calc/formatCalc.js +35 -0
- package/dist/calc/formatCalc.js.map +1 -0
- package/dist/calc/formatCalcValue.d.ts +17 -0
- package/dist/calc/formatCalcValue.js +17 -0
- package/dist/calc/formatCalcValue.js.map +1 -0
- package/dist/calc/normalizeCalc.d.ts +17 -3
- package/dist/calc/normalizeCalc.js +39 -17
- package/dist/calc/normalizeCalc.js.map +1 -1
- package/dist/calc/registry.d.ts +43 -0
- package/dist/calc/registry.js +27 -0
- package/dist/calc/registry.js.map +1 -0
- package/dist/calc/resolveCalcContext.d.ts +36 -0
- package/dist/calc/resolveCalcContext.js +87 -0
- package/dist/calc/resolveCalcContext.js.map +1 -0
- package/dist/calc/types.d.ts +18 -3
- package/dist/calc/types.js +2 -1
- package/dist/calc/types.js.map +1 -1
- package/dist/client/CalcExpressionBuilder.d.ts +20 -0
- package/dist/client/CalcExpressionBuilder.js +890 -0
- package/dist/client/CalcExpressionBuilder.js.map +1 -0
- package/dist/client/RecipientsSelect.d.ts +5 -1
- package/dist/client/RecipientsSelect.js +22 -3
- package/dist/client/RecipientsSelect.js.map +1 -1
- package/dist/client/admin.css +282 -0
- package/dist/collections/formSubmissions.js +34 -16
- package/dist/collections/formSubmissions.js.map +1 -1
- package/dist/collections/forms.js +59 -27
- package/dist/collections/forms.js.map +1 -1
- package/dist/collections/formsEndpoints.js +4 -2
- package/dist/collections/formsEndpoints.js.map +1 -1
- package/dist/collections/settingsFields.d.ts +31 -0
- package/dist/collections/settingsFields.js +45 -0
- package/dist/collections/settingsFields.js.map +1 -0
- package/dist/context/formContext.d.ts +30 -0
- package/dist/context/formContext.js +54 -0
- package/dist/context/formContext.js.map +1 -0
- package/dist/exports/client.d.ts +2 -1
- package/dist/exports/client.js +2 -1
- package/dist/exports/react.d.ts +7 -3
- package/dist/exports/react.js +6 -2
- package/dist/exports/rsc.d.ts +2 -1
- package/dist/exports/rsc.js +3 -2
- package/dist/exports/types.d.ts +1 -1
- package/dist/fields/buildFieldBlocks.js +2 -1
- package/dist/fields/buildFieldBlocks.js.map +1 -1
- package/dist/fields/builtin/calculation.d.ts +17 -0
- package/dist/fields/builtin/calculation.js +170 -115
- package/dist/fields/builtin/calculation.js.map +1 -1
- package/dist/fields/builtin/checkbox.js +15 -0
- package/dist/fields/builtin/checkbox.js.map +1 -1
- package/dist/fields/builtin/email.js +7 -0
- package/dist/fields/builtin/email.js.map +1 -1
- package/dist/fields/builtin/index.d.ts +6 -2
- package/dist/fields/builtin/index.js +9 -4
- package/dist/fields/builtin/index.js.map +1 -1
- package/dist/fields/builtin/select.js +20 -1
- package/dist/fields/builtin/select.js.map +1 -1
- package/dist/fields/builtin/text.js +7 -0
- package/dist/fields/builtin/text.js.map +1 -1
- package/dist/fields/instanceOptions.js +1 -1
- package/dist/fields/instanceOptions.js.map +1 -1
- package/dist/fields/sharedConfig.js +15 -11
- package/dist/fields/sharedConfig.js.map +1 -1
- package/dist/fields/types.d.ts +8 -2
- package/dist/form/toFormDocument.d.ts +7 -0
- package/dist/form/toFormDocument.js +2 -1
- package/dist/form/toFormDocument.js.map +1 -1
- package/dist/form/types.d.ts +7 -0
- package/dist/index.d.ts +14 -4
- package/dist/index.js +40 -9
- package/dist/index.js.map +1 -1
- package/dist/options.d.ts +42 -0
- package/dist/plugin/registerCollections.js +29 -19
- package/dist/plugin/registerCollections.js.map +1 -1
- package/dist/poll/closeJob.d.ts +4 -3
- package/dist/poll/closeJob.js +6 -4
- package/dist/poll/closeJob.js.map +1 -1
- package/dist/poll/pollTypeRegistry.js +1 -1
- package/dist/poll/resolvePollCloseRequest.js +2 -1
- package/dist/poll/resolvePollCloseRequest.js.map +1 -1
- package/dist/poll/resolvePollOutcome.d.ts +6 -0
- package/dist/poll/resolvePollOutcome.js +17 -3
- package/dist/poll/resolvePollOutcome.js.map +1 -1
- package/dist/poll/votes/aggregateFromVotes.d.ts +27 -0
- package/dist/poll/votes/aggregateFromVotes.js +53 -0
- package/dist/poll/votes/aggregateFromVotes.js.map +1 -0
- package/dist/poll/votes/bumpPollVote.js +72 -0
- package/dist/poll/votes/bumpPollVote.js.map +1 -0
- package/dist/poll/votes/recountPollVotes.d.ts +20 -0
- package/dist/poll/votes/recountPollVotes.js +63 -0
- package/dist/poll/votes/recountPollVotes.js.map +1 -0
- package/dist/poll/votes/voteTallyHook.js +58 -0
- package/dist/poll/votes/voteTallyHook.js.map +1 -0
- package/dist/poll/votes/votesCollection.d.ts +19 -0
- package/dist/poll/votes/votesCollection.js +89 -0
- package/dist/poll/votes/votesCollection.js.map +1 -0
- package/dist/react/Form.d.ts +15 -1
- package/dist/react/Form.js +24 -3
- package/dist/react/Form.js.map +1 -1
- package/dist/react/FormContext.d.ts +8 -1
- package/dist/react/FormContext.js.map +1 -1
- package/dist/react/primitives/Checkbox.d.ts +4 -2
- package/dist/react/primitives/Checkbox.js +3 -2
- package/dist/react/primitives/Checkbox.js.map +1 -1
- package/dist/react/primitives/ChoiceGroup.d.ts +40 -0
- package/dist/react/primitives/ChoiceGroup.js +33 -0
- package/dist/react/primitives/ChoiceGroup.js.map +1 -0
- package/dist/react/primitives/FieldShell.d.ts +11 -1
- package/dist/react/primitives/FieldShell.js +43 -33
- package/dist/react/primitives/FieldShell.js.map +1 -1
- package/dist/react/primitives/Input.d.ts +3 -1
- package/dist/react/primitives/Input.js +2 -1
- package/dist/react/primitives/Input.js.map +1 -1
- package/dist/react/renderers/calculation.js +6 -1
- package/dist/react/renderers/calculation.js.map +1 -1
- package/dist/react/renderers/checkbox.js +2 -1
- package/dist/react/renderers/checkbox.js.map +1 -1
- package/dist/react/renderers/email.js +3 -1
- package/dist/react/renderers/email.js.map +1 -1
- package/dist/react/renderers/select.js +20 -2
- package/dist/react/renderers/select.js.map +1 -1
- package/dist/react/renderers/text.js +3 -1
- package/dist/react/renderers/text.js.map +1 -1
- package/dist/react/useCalcValues.d.ts +10 -0
- package/dist/react/useCalcValues.js +13 -0
- package/dist/react/useCalcValues.js.map +1 -0
- package/dist/recall/resolver.js +1 -1
- package/dist/recall/resolver.js.map +1 -1
- package/dist/spam/constants.js +7 -1
- package/dist/spam/constants.js.map +1 -1
- package/dist/submissions/formIdOf.js +13 -0
- package/dist/submissions/formIdOf.js.map +1 -0
- package/dist/submissions/runSubmission.js +3 -3
- package/dist/submissions/runSubmission.js.map +1 -1
- package/dist/submissions/validateSubmission.js +26 -2
- package/dist/submissions/validateSubmission.js.map +1 -1
- package/dist/submissions/verifyContext.js +35 -0
- package/dist/submissions/verifyContext.js.map +1 -0
- package/dist/translations/de.js +62 -3
- package/dist/translations/de.js.map +1 -1
- package/dist/translations/en.js +62 -3
- package/dist/translations/en.js.map +1 -1
- package/dist/translations/keys.d.ts +60 -1
- package/dist/translations/keys.js +60 -1
- package/dist/translations/keys.js.map +1 -1
- package/dist/validation/builtin/index.js +2 -0
- package/dist/validation/builtin/index.js.map +1 -1
- package/dist/validation/builtin/integer.js +15 -0
- package/dist/validation/builtin/integer.js.map +1 -0
- package/package.json +11 -5
- package/styles/form-builder.css +84 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { keys } from "../translations/keys.js";
|
|
2
|
+
import { labelForKey } from "../translations/server.js";
|
|
3
|
+
//#region src/collections/settingsFields.ts
|
|
4
|
+
/**
|
|
5
|
+
* The three flags: behavior, never localized, sidebar checkboxes by default. `multistep` gates the
|
|
6
|
+
* Flow tab and the client's step navigation; `pollEnabled` gates the Poll tab and marks the form a
|
|
7
|
+
* poll; `persistSubmissions` (default checked) tells the plugin whether to keep a submission's row
|
|
8
|
+
* after its actions run, or prune it (a pure signup form's opt-out).
|
|
9
|
+
*/
|
|
10
|
+
const buildDefaultSettingsFields = () => ({
|
|
11
|
+
multistep: {
|
|
12
|
+
name: "multistep",
|
|
13
|
+
type: "checkbox",
|
|
14
|
+
defaultValue: false,
|
|
15
|
+
label: labelForKey(keys.formMultistep),
|
|
16
|
+
admin: { position: "sidebar" }
|
|
17
|
+
},
|
|
18
|
+
pollEnabled: {
|
|
19
|
+
name: "pollEnabled",
|
|
20
|
+
type: "checkbox",
|
|
21
|
+
defaultValue: false,
|
|
22
|
+
label: labelForKey(keys.formPollEnabled),
|
|
23
|
+
admin: { position: "sidebar" }
|
|
24
|
+
},
|
|
25
|
+
persistSubmissions: {
|
|
26
|
+
name: "persistSubmissions",
|
|
27
|
+
type: "checkbox",
|
|
28
|
+
defaultValue: true,
|
|
29
|
+
label: labelForKey(keys.formPersistSubmissions),
|
|
30
|
+
admin: { position: "sidebar" }
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
const composeSettingsFields = (settings) => {
|
|
34
|
+
const defaultFields = buildDefaultSettingsFields();
|
|
35
|
+
if (settings?.fields) return settings.fields({ defaultFields });
|
|
36
|
+
return [
|
|
37
|
+
defaultFields.multistep,
|
|
38
|
+
defaultFields.pollEnabled,
|
|
39
|
+
defaultFields.persistSubmissions
|
|
40
|
+
];
|
|
41
|
+
};
|
|
42
|
+
//#endregion
|
|
43
|
+
export { buildDefaultSettingsFields, composeSettingsFields };
|
|
44
|
+
|
|
45
|
+
//# sourceMappingURL=settingsFields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settingsFields.js","names":[],"sources":["../../src/collections/settingsFields.ts"],"sourcesContent":["import type { Field } from 'payload'\nimport { keys } from '../translations/keys'\nimport { labelForKey } from '../translations/server'\n\n/** The default form-level flag fields, keyed by flag. What the `settings.fields` seam receives. */\nexport type DefaultSettingsFields = {\n\tmultistep: Field\n\tpollEnabled: Field\n\tpersistSubmissions: Field\n}\n\n/**\n * Composes the three form-level flag fields. Receives the defaults and returns the final field\n * array placed verbatim at the forms collection root, so a host can relocate a flag (strip\n * `admin.position`), wrap them in a row, append its own, or drop one.\n */\nexport type SettingsFieldsOverride = (args: { defaultFields: DefaultSettingsFields }) => Field[]\n\n/** The plugin `settings` option: the three form-level flags and their composition seam. */\nexport type SettingsOption = {\n\tfields?: SettingsFieldsOverride\n}\n\n/**\n * The three flags: behavior, never localized, sidebar checkboxes by default. `multistep` gates the\n * Flow tab and the client's step navigation; `pollEnabled` gates the Poll tab and marks the form a\n * poll; `persistSubmissions` (default checked) tells the plugin whether to keep a submission's row\n * after its actions run, or prune it (a pure signup form's opt-out).\n */\nexport const buildDefaultSettingsFields = (): DefaultSettingsFields => ({\n\tmultistep: {\n\t\tname: 'multistep',\n\t\ttype: 'checkbox',\n\t\tdefaultValue: false,\n\t\tlabel: labelForKey(keys.formMultistep),\n\t\tadmin: { position: 'sidebar' },\n\t},\n\tpollEnabled: {\n\t\tname: 'pollEnabled',\n\t\ttype: 'checkbox',\n\t\tdefaultValue: false,\n\t\tlabel: labelForKey(keys.formPollEnabled),\n\t\tadmin: { position: 'sidebar' },\n\t},\n\tpersistSubmissions: {\n\t\tname: 'persistSubmissions',\n\t\ttype: 'checkbox',\n\t\tdefaultValue: true,\n\t\tlabel: labelForKey(keys.formPersistSubmissions),\n\t\tadmin: { position: 'sidebar' },\n\t},\n})\n\nexport const composeSettingsFields = (settings: SettingsOption | undefined): Field[] => {\n\tconst defaultFields = buildDefaultSettingsFields()\n\tif (settings?.fields) {\n\t\treturn settings.fields({ defaultFields })\n\t}\n\treturn [defaultFields.multistep, defaultFields.pollEnabled, defaultFields.persistSubmissions]\n}\n"],"mappings":";;;;;;;;;AA6BA,MAAa,oCAA2D;CACvE,WAAW;EACV,MAAM;EACN,MAAM;EACN,cAAc;EACd,OAAO,YAAY,KAAK,aAAa;EACrC,OAAO,EAAE,UAAU,UAAU;CAC9B;CACA,aAAa;EACZ,MAAM;EACN,MAAM;EACN,cAAc;EACd,OAAO,YAAY,KAAK,eAAe;EACvC,OAAO,EAAE,UAAU,UAAU;CAC9B;CACA,oBAAoB;EACnB,MAAM;EACN,MAAM;EACN,cAAc;EACd,OAAO,YAAY,KAAK,sBAAsB;EAC9C,OAAO,EAAE,UAAU,UAAU;CAC9B;AACD;AAEA,MAAa,yBAAyB,aAAkD;CACvF,MAAM,gBAAgB,2BAA2B;CACjD,IAAI,UAAU,QACb,OAAO,SAAS,OAAO,EAAE,cAAc,CAAC;CAEzC,OAAO;EAAC,cAAc;EAAW,cAAc;EAAa,cAAc;CAAkB;AAC7F"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Payload } from "payload";
|
|
2
|
+
|
|
3
|
+
//#region src/context/formContext.d.ts
|
|
4
|
+
/** A verified reference to the document a form was rendered for. Never a secret: the id is already public. */
|
|
5
|
+
type FormContextReference = {
|
|
6
|
+
relationTo: string;
|
|
7
|
+
value: string | number;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Sign a `{ relationTo, value }` reference into a compact `v1.<base64url(payload)>.<hmac>` token: a
|
|
11
|
+
* rendering surface mints one per document it renders a form for, the client carries it, and the plugin
|
|
12
|
+
* verifies it on submit. Signed (HMAC-SHA256 over the payload with `secret ?? payload.secret`), not
|
|
13
|
+
* encrypted: the reference is not a secret, the signature only stops rewriting. `expiresIn` (seconds,
|
|
14
|
+
* default one day) bounds replay.
|
|
15
|
+
*/
|
|
16
|
+
declare const signFormContext: (args: {
|
|
17
|
+
payload: Payload;
|
|
18
|
+
relationTo: string;
|
|
19
|
+
value: string | number;
|
|
20
|
+
expiresIn?: number;
|
|
21
|
+
secret?: string;
|
|
22
|
+
}) => string;
|
|
23
|
+
/**
|
|
24
|
+
* Verify a token minted by `signFormContext` and return its reference, or null on any failure (wrong
|
|
25
|
+
* version, malformed, bad signature, or expired). Never throws, and the signature check is constant-time.
|
|
26
|
+
*/
|
|
27
|
+
declare const verifyFormContext: (token: string, secret: string, nowMs?: number) => FormContextReference | null;
|
|
28
|
+
//#endregion
|
|
29
|
+
export { FormContextReference, signFormContext, verifyFormContext };
|
|
30
|
+
//# sourceMappingURL=formContext.d.ts.map
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { createHmac, timingSafeEqual } from "node:crypto";
|
|
2
|
+
//#region src/context/formContext.ts
|
|
3
|
+
const VERSION = "v1";
|
|
4
|
+
const DEFAULT_EXPIRES_IN_SECONDS = 86400;
|
|
5
|
+
const hmacHex = (body, secret) => createHmac("sha256", secret).update(body).digest("hex");
|
|
6
|
+
/**
|
|
7
|
+
* Sign a `{ relationTo, value }` reference into a compact `v1.<base64url(payload)>.<hmac>` token: a
|
|
8
|
+
* rendering surface mints one per document it renders a form for, the client carries it, and the plugin
|
|
9
|
+
* verifies it on submit. Signed (HMAC-SHA256 over the payload with `secret ?? payload.secret`), not
|
|
10
|
+
* encrypted: the reference is not a secret, the signature only stops rewriting. `expiresIn` (seconds,
|
|
11
|
+
* default one day) bounds replay.
|
|
12
|
+
*/
|
|
13
|
+
const signFormContext = (args) => {
|
|
14
|
+
const { payload, relationTo, value, expiresIn, secret } = args;
|
|
15
|
+
const exp = Math.floor(Date.now() / 1e3) + (expiresIn ?? DEFAULT_EXPIRES_IN_SECONDS);
|
|
16
|
+
const body = Buffer.from(JSON.stringify({
|
|
17
|
+
relationTo,
|
|
18
|
+
value,
|
|
19
|
+
exp
|
|
20
|
+
})).toString("base64url");
|
|
21
|
+
return `${VERSION}.${body}.${hmacHex(body, secret ?? payload.secret)}`;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Verify a token minted by `signFormContext` and return its reference, or null on any failure (wrong
|
|
25
|
+
* version, malformed, bad signature, or expired). Never throws, and the signature check is constant-time.
|
|
26
|
+
*/
|
|
27
|
+
const verifyFormContext = (token, secret, nowMs = Date.now()) => {
|
|
28
|
+
const parts = token.split(".");
|
|
29
|
+
if (parts.length !== 3 || parts[0] !== VERSION) return null;
|
|
30
|
+
const [, body, signature] = parts;
|
|
31
|
+
const expected = hmacHex(body ?? "", secret);
|
|
32
|
+
const given = Buffer.from(signature ?? "");
|
|
33
|
+
const want = Buffer.from(expected);
|
|
34
|
+
if (given.byteLength !== want.byteLength || !timingSafeEqual(given, want)) return null;
|
|
35
|
+
let parsed;
|
|
36
|
+
try {
|
|
37
|
+
parsed = JSON.parse(Buffer.from(body ?? "", "base64url").toString("utf8"));
|
|
38
|
+
} catch {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
if (!parsed || typeof parsed !== "object") return null;
|
|
42
|
+
const { relationTo, value, exp } = parsed;
|
|
43
|
+
if (typeof relationTo !== "string" || relationTo.length === 0) return null;
|
|
44
|
+
if (typeof value !== "string" && typeof value !== "number") return null;
|
|
45
|
+
if (typeof exp !== "number" || exp * 1e3 <= nowMs) return null;
|
|
46
|
+
return {
|
|
47
|
+
relationTo,
|
|
48
|
+
value
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
//#endregion
|
|
52
|
+
export { signFormContext, verifyFormContext };
|
|
53
|
+
|
|
54
|
+
//# sourceMappingURL=formContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formContext.js","names":[],"sources":["../../src/context/formContext.ts"],"sourcesContent":["import { createHmac, timingSafeEqual } from 'node:crypto'\nimport type { Payload } from 'payload'\n\n/** A verified reference to the document a form was rendered for. Never a secret: the id is already public. */\nexport type FormContextReference = { relationTo: string; value: string | number }\n\nconst VERSION = 'v1'\nconst DEFAULT_EXPIRES_IN_SECONDS = 86_400\n\nconst hmacHex = (body: string, secret: string): string =>\n\tcreateHmac('sha256', secret).update(body).digest('hex')\n\n/**\n * Sign a `{ relationTo, value }` reference into a compact `v1.<base64url(payload)>.<hmac>` token: a\n * rendering surface mints one per document it renders a form for, the client carries it, and the plugin\n * verifies it on submit. Signed (HMAC-SHA256 over the payload with `secret ?? payload.secret`), not\n * encrypted: the reference is not a secret, the signature only stops rewriting. `expiresIn` (seconds,\n * default one day) bounds replay.\n */\nexport const signFormContext = (args: {\n\tpayload: Payload\n\trelationTo: string\n\tvalue: string | number\n\texpiresIn?: number\n\tsecret?: string\n}): string => {\n\tconst { payload, relationTo, value, expiresIn, secret } = args\n\tconst exp = Math.floor(Date.now() / 1000) + (expiresIn ?? DEFAULT_EXPIRES_IN_SECONDS)\n\tconst body = Buffer.from(JSON.stringify({ relationTo, value, exp })).toString('base64url')\n\treturn `${VERSION}.${body}.${hmacHex(body, secret ?? payload.secret)}`\n}\n\n/**\n * Verify a token minted by `signFormContext` and return its reference, or null on any failure (wrong\n * version, malformed, bad signature, or expired). Never throws, and the signature check is constant-time.\n */\nexport const verifyFormContext = (\n\ttoken: string,\n\tsecret: string,\n\tnowMs: number = Date.now()\n): FormContextReference | null => {\n\tconst parts = token.split('.')\n\tif (parts.length !== 3 || parts[0] !== VERSION) {\n\t\treturn null\n\t}\n\tconst [, body, signature] = parts\n\tconst expected = hmacHex(body ?? '', secret)\n\tconst given = Buffer.from(signature ?? '')\n\tconst want = Buffer.from(expected)\n\tif (given.byteLength !== want.byteLength || !timingSafeEqual(given, want)) {\n\t\treturn null\n\t}\n\tlet parsed: unknown\n\ttry {\n\t\tparsed = JSON.parse(Buffer.from(body ?? '', 'base64url').toString('utf8'))\n\t} catch {\n\t\treturn null\n\t}\n\tif (!parsed || typeof parsed !== 'object') {\n\t\treturn null\n\t}\n\tconst { relationTo, value, exp } = parsed as Record<string, unknown>\n\tif (typeof relationTo !== 'string' || relationTo.length === 0) {\n\t\treturn null\n\t}\n\tif (typeof value !== 'string' && typeof value !== 'number') {\n\t\treturn null\n\t}\n\tif (typeof exp !== 'number' || exp * 1000 <= nowMs) {\n\t\treturn null\n\t}\n\treturn { relationTo, value }\n}\n"],"mappings":";;AAMA,MAAM,UAAU;AAChB,MAAM,6BAA6B;AAEnC,MAAM,WAAW,MAAc,WAC9B,WAAW,UAAU,MAAM,EAAE,OAAO,IAAI,EAAE,OAAO,KAAK;;;;;;;;AASvD,MAAa,mBAAmB,SAMlB;CACb,MAAM,EAAE,SAAS,YAAY,OAAO,WAAW,WAAW;CAC1D,MAAM,MAAM,KAAK,MAAM,KAAK,IAAI,IAAI,GAAI,KAAK,aAAa;CAC1D,MAAM,OAAO,OAAO,KAAK,KAAK,UAAU;EAAE;EAAY;EAAO;CAAI,CAAC,CAAC,EAAE,SAAS,WAAW;CACzF,OAAO,GAAG,QAAQ,GAAG,KAAK,GAAG,QAAQ,MAAM,UAAU,QAAQ,MAAM;AACpE;;;;;AAMA,MAAa,qBACZ,OACA,QACA,QAAgB,KAAK,IAAI,MACQ;CACjC,MAAM,QAAQ,MAAM,MAAM,GAAG;CAC7B,IAAI,MAAM,WAAW,KAAK,MAAM,OAAO,SACtC,OAAO;CAER,MAAM,GAAG,MAAM,aAAa;CAC5B,MAAM,WAAW,QAAQ,QAAQ,IAAI,MAAM;CAC3C,MAAM,QAAQ,OAAO,KAAK,aAAa,EAAE;CACzC,MAAM,OAAO,OAAO,KAAK,QAAQ;CACjC,IAAI,MAAM,eAAe,KAAK,cAAc,CAAC,gBAAgB,OAAO,IAAI,GACvE,OAAO;CAER,IAAI;CACJ,IAAI;EACH,SAAS,KAAK,MAAM,OAAO,KAAK,QAAQ,IAAI,WAAW,EAAE,SAAS,MAAM,CAAC;CAC1E,QAAQ;EACP,OAAO;CACR;CACA,IAAI,CAAC,UAAU,OAAO,WAAW,UAChC,OAAO;CAER,MAAM,EAAE,YAAY,OAAO,QAAQ;CACnC,IAAI,OAAO,eAAe,YAAY,WAAW,WAAW,GAC3D,OAAO;CAER,IAAI,OAAO,UAAU,YAAY,OAAO,UAAU,UACjD,OAAO;CAER,IAAI,OAAO,QAAQ,YAAY,MAAM,OAAQ,OAC5C,OAAO;CAER,OAAO;EAAE;EAAY;CAAM;AAC5B"}
|
package/dist/exports/client.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ByteSizeField } from "../client/ByteSizeField.js";
|
|
2
|
+
import { CalcExpressionBuilder } from "../client/CalcExpressionBuilder.js";
|
|
2
3
|
import { ClosePollButton } from "../client/ClosePollButton.js";
|
|
3
4
|
import { CondensedArray } from "../client/CondensedArray.js";
|
|
4
5
|
import { ConsentBlockLabel } from "../client/ConsentBlockLabel.js";
|
|
@@ -12,4 +13,4 @@ import { RecipientsSelect } from "../client/RecipientsSelect.js";
|
|
|
12
13
|
import { RuleDescription } from "../client/RuleDescription.js";
|
|
13
14
|
import { FieldCountCell } from "../collections/cells/FieldCountCell.js";
|
|
14
15
|
import { FlowStepsCell } from "../collections/cells/FlowStepsCell.js";
|
|
15
|
-
export { ByteSizeField, ClosePollButton, CondensedArray, ConsentBlockLabel, ConsentSourceRowLabel, EndpointOptionsSelect, FieldBlockLabel, FieldCountCell, FieldNameSelect, FlowBuilder, FlowStepsCell, FormConditionField, RecipientsSelect, RuleDescription };
|
|
16
|
+
export { ByteSizeField, CalcExpressionBuilder, ClosePollButton, CondensedArray, ConsentBlockLabel, ConsentSourceRowLabel, EndpointOptionsSelect, FieldBlockLabel, FieldCountCell, FieldNameSelect, FlowBuilder, FlowStepsCell, FormConditionField, RecipientsSelect, RuleDescription };
|
package/dist/exports/client.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { ByteSizeField } from "../client/ByteSizeField.js";
|
|
3
|
+
import { CalcExpressionBuilder } from "../client/CalcExpressionBuilder.js";
|
|
3
4
|
import { ClosePollButton } from "../client/ClosePollButton.js";
|
|
4
5
|
import { CondensedArray } from "../client/CondensedArray.js";
|
|
5
6
|
import { ConsentBlockLabel } from "../client/ConsentBlockLabel.js";
|
|
@@ -13,4 +14,4 @@ import { RecipientsSelect } from "../client/RecipientsSelect.js";
|
|
|
13
14
|
import { RuleDescription } from "../client/RuleDescription.js";
|
|
14
15
|
import { FieldCountCell } from "../collections/cells/FieldCountCell.js";
|
|
15
16
|
import { FlowStepsCell } from "../collections/cells/FlowStepsCell.js";
|
|
16
|
-
export { ByteSizeField, ClosePollButton, CondensedArray, ConsentBlockLabel, ConsentSourceRowLabel, EndpointOptionsSelect, FieldBlockLabel, FieldCountCell, FieldNameSelect, FlowBuilder, FlowStepsCell, FormConditionField, RecipientsSelect, RuleDescription };
|
|
17
|
+
export { ByteSizeField, CalcExpressionBuilder, ClosePollButton, CondensedArray, ConsentBlockLabel, ConsentSourceRowLabel, EndpointOptionsSelect, FieldBlockLabel, FieldCountCell, FieldNameSelect, FlowBuilder, FlowStepsCell, FormConditionField, RecipientsSelect, RuleDescription };
|
package/dist/exports/react.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CalcExpression } from "../calc/types.js";
|
|
1
2
|
import { FormFieldInstance, SubmissionValue } from "../submissions/types.js";
|
|
2
3
|
import { de } from "../translations/de.js";
|
|
3
4
|
import { en } from "../translations/en.js";
|
|
@@ -7,9 +8,10 @@ import { BodyConverter, BodyConverterArgs, BodyRender, sanitizeUrl } from "../ac
|
|
|
7
8
|
import { BodyContext, serializeBody } from "../actions/body/serializeBody.js";
|
|
8
9
|
import { textOfBody } from "../actions/body/textOfBody.js";
|
|
9
10
|
import { AggregationBucket, FieldAggregation } from "../aggregation/types.js";
|
|
10
|
-
import {
|
|
11
|
+
import { CalcResolved, evaluateCalc } from "../calc/evaluate.js";
|
|
11
12
|
import { computeCalcFields } from "../calc/computeCalcFields.js";
|
|
12
|
-
import {
|
|
13
|
+
import { formatCalc } from "../calc/formatCalc.js";
|
|
14
|
+
import { CalcDisplayConfig, formatCalcValue } from "../calc/formatCalcValue.js";
|
|
13
15
|
import { evaluateCondition } from "../conditions/evaluate.js";
|
|
14
16
|
import { ConsentStatement, ConsentStatements } from "../consent/resolveConsentStatements.js";
|
|
15
17
|
import { COUNTRIES, US_STATES } from "../fields/data/regions.js";
|
|
@@ -47,12 +49,14 @@ import { UseDismissOptions, useDismiss } from "../react/presentation/useDismiss.
|
|
|
47
49
|
import { useFocusTrap } from "../react/presentation/useFocusTrap.js";
|
|
48
50
|
import { useScrollLock } from "../react/presentation/useScrollLock.js";
|
|
49
51
|
import { Checkbox, CheckboxProps } from "../react/primitives/Checkbox.js";
|
|
52
|
+
import { ChoiceGroup, ChoiceGroupProps, ChoiceOption } from "../react/primitives/ChoiceGroup.js";
|
|
50
53
|
import { FieldShell, FieldShellProps } from "../react/primitives/FieldShell.js";
|
|
51
54
|
import { Input, InputProps } from "../react/primitives/Input.js";
|
|
52
55
|
import { Select, SelectOption, SelectProps } from "../react/primitives/Select.js";
|
|
53
56
|
import { Textarea, TextareaProps } from "../react/primitives/Textarea.js";
|
|
54
57
|
import { defaultRenderers } from "../react/renderers/index.js";
|
|
55
58
|
import { UploadFileInput, UploadFileResult, uploadFile } from "../react/uploadFile.js";
|
|
59
|
+
import { useCalcValues } from "../react/useCalcValues.js";
|
|
56
60
|
import { UseFieldResult, useField } from "../react/useField.js";
|
|
57
61
|
import { useFormState } from "../react/useFormState.js";
|
|
58
62
|
import { useFormStep } from "../react/useFormStep.js";
|
|
@@ -60,4 +64,4 @@ import { interpolate } from "../recall/interpolate.js";
|
|
|
60
64
|
import { CAPTCHA_TOKEN_KEY, DEFAULT_HONEYPOT_FIELD } from "../spam/constants.js";
|
|
61
65
|
import { makeTranslate } from "../translations/makeTranslate.js";
|
|
62
66
|
import { formatBytes } from "../uploads/formatBytes.js";
|
|
63
|
-
export { type AggregationBucket, type BackButtonRenderProps, Backdrop, type BackdropProps, type BodyContext, type BodyConverter, type BodyConverterArgs, type BodyRender, CAPTCHA_TOKEN_KEY, COUNTRIES, type CalcExpression, type CaptchaWidgetHandle, Checkbox, type CheckboxProps, type ConsentStatement, type ConsentStatements, DEFAULT_HONEYPOT_FIELD, DialogSurface, type DialogSurfaceProps, type FetchResultsInput, type FetchResultsResult, type FieldAggregation, type FieldErrors, type FieldRenderer, type FieldRendererProps, FieldShell, type FieldShellProps, type FieldWidth, Form, type FormAction, type FormButtonSettings, type FormContextValue, type FormControlLabels, FormControls, type FormControlsProps, type FormDocument, type FormFieldInstance, FormFields, type FormFieldsProps, FormLayout, type FormLayoutProps, type FormPollSettings, type FormPresentation, type FormProps, type FormResponseSettings, FormResults, type FormResultsProps, type FormState, type FormStepInfo, FormSteps, type FormStepsProps, type FormSuccessResponse, type FormSuccessResult, HCAPTCHA_SCRIPT_URL, HcaptchaCaptcha, type HcaptchaCaptchaProps, Honeypot, type HoneypotProps, Input, type InputProps, type NextButtonRenderProps, Poll, type PollProps, type PrefillOptions, type PresentationOption, type PresentationRegistry, type PresentationWrapperProps, type PresentationsConfig, RECAPTCHA_SCRIPT_URL, type RecallResolver, RecaptchaCaptcha, type RecaptchaCaptchaHandle, type RecaptchaCaptchaProps, type RendererOption, type RendererRegistry, type RendererTranslate, type RenderersConfig, Select, type SelectOption, type SelectProps, type SubmissionValue, type SubmitButtonRenderProps, type SubmitFormResult, type SubmitHandler, TURNSTILE_SCRIPT_URL, Textarea, type TextareaProps, type ToFormDocumentOptions, type TranslationBundle, TurnstileCaptcha, type TurnstileCaptchaProps, US_STATES, type UploadFileInput, type UploadFileResult, type UseDismissOptions, type UseFieldResult, buildRecallResolver, bundles, clientRuntimeKeys, cn, computeCalcFields, de, defaultPresentations, defaultRenderers, defineFieldRenderer, en, evaluateCalc, evaluateCondition, fetchFormResults, fieldKey, firstStepId, formatBytes, interpolate, isTerminalStepId, makeTranslate, resolveNextStepId, resolvePresentations, resolveRenderers, sanitizeUrl, serializeBody, stepFieldNames, submitForm, textOfBody, toFormDocument, uploadFile, useDismiss, useField, useFocusTrap, useFormContext, useFormState, useFormStep, useScrollLock, valuesFromSearchParams, widthProps };
|
|
67
|
+
export { type AggregationBucket, type BackButtonRenderProps, Backdrop, type BackdropProps, type BodyContext, type BodyConverter, type BodyConverterArgs, type BodyRender, CAPTCHA_TOKEN_KEY, COUNTRIES, type CalcDisplayConfig, type CalcExpression, type CalcResolved, type CaptchaWidgetHandle, Checkbox, type CheckboxProps, ChoiceGroup, type ChoiceGroupProps, type ChoiceOption, type ConsentStatement, type ConsentStatements, DEFAULT_HONEYPOT_FIELD, DialogSurface, type DialogSurfaceProps, type FetchResultsInput, type FetchResultsResult, type FieldAggregation, type FieldErrors, type FieldRenderer, type FieldRendererProps, FieldShell, type FieldShellProps, type FieldWidth, Form, type FormAction, type FormButtonSettings, type FormContextValue, type FormControlLabels, FormControls, type FormControlsProps, type FormDocument, type FormFieldInstance, FormFields, type FormFieldsProps, FormLayout, type FormLayoutProps, type FormPollSettings, type FormPresentation, type FormProps, type FormResponseSettings, FormResults, type FormResultsProps, type FormState, type FormStepInfo, FormSteps, type FormStepsProps, type FormSuccessResponse, type FormSuccessResult, HCAPTCHA_SCRIPT_URL, HcaptchaCaptcha, type HcaptchaCaptchaProps, Honeypot, type HoneypotProps, Input, type InputProps, type NextButtonRenderProps, Poll, type PollProps, type PrefillOptions, type PresentationOption, type PresentationRegistry, type PresentationWrapperProps, type PresentationsConfig, RECAPTCHA_SCRIPT_URL, type RecallResolver, RecaptchaCaptcha, type RecaptchaCaptchaHandle, type RecaptchaCaptchaProps, type RendererOption, type RendererRegistry, type RendererTranslate, type RenderersConfig, Select, type SelectOption, type SelectProps, type SubmissionValue, type SubmitButtonRenderProps, type SubmitFormResult, type SubmitHandler, TURNSTILE_SCRIPT_URL, Textarea, type TextareaProps, type ToFormDocumentOptions, type TranslationBundle, TurnstileCaptcha, type TurnstileCaptchaProps, US_STATES, type UploadFileInput, type UploadFileResult, type UseDismissOptions, type UseFieldResult, buildRecallResolver, bundles, clientRuntimeKeys, cn, computeCalcFields, de, defaultPresentations, defaultRenderers, defineFieldRenderer, en, evaluateCalc, evaluateCondition, fetchFormResults, fieldKey, firstStepId, formatBytes, formatCalc, formatCalcValue, interpolate, isTerminalStepId, makeTranslate, resolveNextStepId, resolvePresentations, resolveRenderers, sanitizeUrl, serializeBody, stepFieldNames, submitForm, textOfBody, toFormDocument, uploadFile, useCalcValues, useDismiss, useField, useFocusTrap, useFormContext, useFormState, useFormStep, useScrollLock, valuesFromSearchParams, widthProps };
|
package/dist/exports/react.js
CHANGED
|
@@ -2,15 +2,17 @@
|
|
|
2
2
|
import { interpolate } from "../recall/interpolate.js";
|
|
3
3
|
import { sanitizeUrl } from "../actions/body/converters.js";
|
|
4
4
|
import { serializeBody } from "../actions/body/serializeBody.js";
|
|
5
|
-
import {
|
|
5
|
+
import { formatCalcValue } from "../calc/formatCalcValue.js";
|
|
6
6
|
import { fieldKey } from "../fields/fieldKey.js";
|
|
7
7
|
import { evaluateCalc } from "../calc/evaluate.js";
|
|
8
8
|
import { computeCalcFields } from "../calc/computeCalcFields.js";
|
|
9
|
+
import { CAPTCHA_TOKEN_KEY, DEFAULT_HONEYPOT_FIELD } from "../spam/constants.js";
|
|
9
10
|
import { evaluateCondition } from "../conditions/evaluate.js";
|
|
10
11
|
import { textOfBody } from "../actions/body/textOfBody.js";
|
|
11
12
|
import { de } from "../translations/de.js";
|
|
12
13
|
import { en } from "../translations/en.js";
|
|
13
14
|
import { bundles } from "../translations/index.js";
|
|
15
|
+
import { formatCalc } from "../calc/formatCalc.js";
|
|
14
16
|
import { COUNTRIES, US_STATES } from "../fields/data/regions.js";
|
|
15
17
|
import { toFormDocument } from "../form/toFormDocument.js";
|
|
16
18
|
import { valuesFromSearchParams } from "../prefill/valuesFromSearchParams.js";
|
|
@@ -42,6 +44,7 @@ import { Checkbox } from "../react/primitives/Checkbox.js";
|
|
|
42
44
|
import { Input } from "../react/primitives/Input.js";
|
|
43
45
|
import { uploadFile } from "../react/uploadFile.js";
|
|
44
46
|
import { Select } from "../react/primitives/Select.js";
|
|
47
|
+
import { ChoiceGroup } from "../react/primitives/ChoiceGroup.js";
|
|
45
48
|
import { Textarea } from "../react/primitives/Textarea.js";
|
|
46
49
|
import { defaultRenderers } from "../react/renderers/index.js";
|
|
47
50
|
import { submitForm } from "../react/submitForm.js";
|
|
@@ -50,7 +53,8 @@ import { FormResults } from "../react/FormResults.js";
|
|
|
50
53
|
import { FormSteps } from "../react/FormSteps.js";
|
|
51
54
|
import { fetchFormResults } from "../react/fetchResults.js";
|
|
52
55
|
import { Poll } from "../react/Poll.js";
|
|
56
|
+
import { useCalcValues } from "../react/useCalcValues.js";
|
|
53
57
|
import { useFormState } from "../react/useFormState.js";
|
|
54
58
|
import { useFormStep } from "../react/useFormStep.js";
|
|
55
59
|
import { clientRuntimeKeys } from "../translations/clientRuntimeKeys.js";
|
|
56
|
-
export { Backdrop, CAPTCHA_TOKEN_KEY, COUNTRIES, Checkbox, DEFAULT_HONEYPOT_FIELD, DialogSurface, FieldShell, Form, FormControls, FormFields, FormLayout, FormResults, FormSteps, HCAPTCHA_SCRIPT_URL, HcaptchaCaptcha, Honeypot, Input, Poll, RECAPTCHA_SCRIPT_URL, RecaptchaCaptcha, Select, TURNSTILE_SCRIPT_URL, Textarea, TurnstileCaptcha, US_STATES, buildRecallResolver, bundles, clientRuntimeKeys, cn, computeCalcFields, de, defaultPresentations, defaultRenderers, defineFieldRenderer, en, evaluateCalc, evaluateCondition, fetchFormResults, fieldKey, firstStepId, formatBytes, interpolate, isTerminalStepId, makeTranslate, resolveNextStepId, resolvePresentations, resolveRenderers, sanitizeUrl, serializeBody, stepFieldNames, submitForm, textOfBody, toFormDocument, uploadFile, useDismiss, useField, useFocusTrap, useFormContext, useFormState, useFormStep, useScrollLock, valuesFromSearchParams, widthProps };
|
|
60
|
+
export { Backdrop, CAPTCHA_TOKEN_KEY, COUNTRIES, Checkbox, ChoiceGroup, DEFAULT_HONEYPOT_FIELD, DialogSurface, FieldShell, Form, FormControls, FormFields, FormLayout, FormResults, FormSteps, HCAPTCHA_SCRIPT_URL, HcaptchaCaptcha, Honeypot, Input, Poll, RECAPTCHA_SCRIPT_URL, RecaptchaCaptcha, Select, TURNSTILE_SCRIPT_URL, Textarea, TurnstileCaptcha, US_STATES, buildRecallResolver, bundles, clientRuntimeKeys, cn, computeCalcFields, de, defaultPresentations, defaultRenderers, defineFieldRenderer, en, evaluateCalc, evaluateCondition, fetchFormResults, fieldKey, firstStepId, formatBytes, formatCalc, formatCalcValue, interpolate, isTerminalStepId, makeTranslate, resolveNextStepId, resolvePresentations, resolveRenderers, sanitizeUrl, serializeBody, stepFieldNames, submitForm, textOfBody, toFormDocument, uploadFile, useCalcValues, useDismiss, useField, useFocusTrap, useFormContext, useFormState, useFormStep, useScrollLock, valuesFromSearchParams, widthProps };
|
package/dist/exports/rsc.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { resolveConsentStatements } from "../consent/resolveConsentStatements.js";
|
|
2
2
|
import { toFormDocument } from "../form/toFormDocument.js";
|
|
3
|
+
import { FormContextReference, signFormContext, verifyFormContext } from "../context/formContext.js";
|
|
3
4
|
import { isPollClosed } from "../form/pollState.js";
|
|
4
5
|
import { resolveEffectivePollOptions } from "../poll/effectivePollOptions.js";
|
|
5
6
|
import { resolvePollOptions } from "../poll/resolvePollOptions.js";
|
|
6
7
|
import { resolvePollOutcome } from "../poll/resolvePollOutcome.js";
|
|
7
8
|
import { SubmissionAnswers } from "../submissions/SubmissionAnswers.js";
|
|
8
9
|
import { hasVotedCookie, votedCookieName } from "../submissions/votedCookie.js";
|
|
9
|
-
export { SubmissionAnswers, hasVotedCookie, isPollClosed, resolveConsentStatements, resolveEffectivePollOptions, resolvePollOptions, resolvePollOutcome, toFormDocument, votedCookieName };
|
|
10
|
+
export { type FormContextReference, SubmissionAnswers, hasVotedCookie, isPollClosed, resolveConsentStatements, resolveEffectivePollOptions, resolvePollOptions, resolvePollOutcome, signFormContext, toFormDocument, verifyFormContext, votedCookieName };
|
package/dist/exports/rsc.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { resolveConsentStatements } from "../consent/resolveConsentStatements.js";
|
|
2
2
|
import { isPollClosed } from "../form/pollState.js";
|
|
3
3
|
import { resolvePollOptions } from "../poll/resolvePollOptions.js";
|
|
4
|
-
import { resolvePollOutcome } from "../poll/resolvePollOutcome.js";
|
|
5
4
|
import { resolveEffectivePollOptions } from "../poll/effectivePollOptions.js";
|
|
5
|
+
import { resolvePollOutcome } from "../poll/resolvePollOutcome.js";
|
|
6
6
|
import { hasVotedCookie, votedCookieName } from "../submissions/votedCookie.js";
|
|
7
|
+
import { signFormContext, verifyFormContext } from "../context/formContext.js";
|
|
7
8
|
import { toFormDocument } from "../form/toFormDocument.js";
|
|
8
9
|
import { SubmissionAnswers } from "../submissions/SubmissionAnswers.js";
|
|
9
|
-
export { SubmissionAnswers, hasVotedCookie, isPollClosed, resolveConsentStatements, resolveEffectivePollOptions, resolvePollOptions, resolvePollOutcome, toFormDocument, votedCookieName };
|
|
10
|
+
export { SubmissionAnswers, hasVotedCookie, isPollClosed, resolveConsentStatements, resolveEffectivePollOptions, resolvePollOptions, resolvePollOutcome, signFormContext, toFormDocument, verifyFormContext, votedCookieName };
|
package/dist/exports/types.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { CalcExpression } from "../calc/types.js";
|
|
1
2
|
import { FormFieldInstance, SubmissionDescriptor, SubmissionFieldError, SubmissionValue, SubmissionWidth } from "../submissions/types.js";
|
|
2
3
|
import { FileFieldConfig, FileRef, FileRefError } from "../uploads/types.js";
|
|
3
4
|
import { AnyFormFieldDefinition, FormFieldDefinition, FormFieldFormat, FormFieldValidate, FormFieldValueKind, OmittableSharedField } from "../fields/types.js";
|
|
4
5
|
import { RichTextBodyOption } from "../actions/body/serializeBody.js";
|
|
5
6
|
import { AggregationBucket, AggregationRow, FieldAggregation, FieldMeta, SubmissionStatusFilter } from "../aggregation/types.js";
|
|
6
|
-
import { CalcExpression } from "../calc/types.js";
|
|
7
7
|
import { ConsentSourceEntry, ConsentSourcePage, ConsentSourcesResolver } from "../consent/types.js";
|
|
8
8
|
import { ConsentStatement, ConsentStatements, ResolveConsentStatementsArgs } from "../consent/resolveConsentStatements.js";
|
|
9
9
|
import { FlowStep, FlowTransition, FormFlow } from "../flow/types.js";
|
|
@@ -58,7 +58,8 @@ const buildFieldBlocks = ({ registry, ruleRegistry, localize = true }) => {
|
|
|
58
58
|
blocks: buildRuleBlocks(ruleRegistry, definition.type)
|
|
59
59
|
},
|
|
60
60
|
localize,
|
|
61
|
-
omitShared: definition.omitShared
|
|
61
|
+
omitShared: definition.omitShared,
|
|
62
|
+
advancedConfig: definition.advancedConfig
|
|
62
63
|
})]
|
|
63
64
|
});
|
|
64
65
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildFieldBlocks.js","names":[],"sources":["../../src/fields/buildFieldBlocks.ts"],"sourcesContent":["import type { Block, Field, TabsField } from 'payload'\nimport { buildConditionTypeMap } from '../conditions/conditionType'\nimport { keys } from '../translations/keys'\nimport { labelFor } from '../translations/server'\nimport { buildRuleBlocks } from '../validation/buildRuleBlocks'\nimport type { ValidationRuleRegistry } from '../validation/registry'\nimport type { FieldTypeRegistry } from './registry'\nimport { fieldBlockTabs } from './sharedConfig'\n\nconst FIELD_BLOCK_LABEL_REF = '@10x-media/form-builder/client#FieldBlockLabel'\n\n/**\n * Replace Payload's default `blockName` row header (which reads \"Untitled\" until filled) with the\n * field's own `label`, keyed to the type label as fallback. See `FieldBlockLabel`.\n */\nconst blockLabelAdmin = (\n\ttypeLabelKey: string,\n\tref: string = FIELD_BLOCK_LABEL_REF\n): NonNullable<Block['admin']> => ({\n\tcomponents: { Label: { path: ref, clientProps: { typeLabelKey } } },\n})\n\n/** Whether `fields` contains a field named `name`, descending into presentational rows. */\nconst hasNameField = (fields: Field[]): boolean =>\n\tfields.some((f) => {\n\t\tif ('name' in f && f.name === 'name') {\n\t\t\treturn true\n\t\t}\n\t\treturn f.type === 'row' && hasNameField(f.fields)\n\t})\n\n/** The tab whose fields hold the shared basics and type config, found by the `name` field it carries. */\nconst fieldTabOf = (block: Block): Field[] | undefined => {\n\tconst tabsField = block.fields.find((f): f is TabsField => f.type === 'tabs')\n\treturn tabsField?.tabs.find((tab) => hasNameField(tab.fields))?.fields\n}\n\n/**\n * One add-field block per registered type: tabs holding shared config, type config, and\n * validations. Bare definitions (e.g. `message`) skip all of that: their block is the\n * definition's `config` alone, no name/shared basics/tabs. `localize` controls whether the\n * shared content fields carry `localized: true`; per-type config fields carry their own flag\n * from the registry definitions.\n */\ntype BuildFieldBlocksArgs = {\n\tregistry: FieldTypeRegistry\n\truleRegistry: ValidationRuleRegistry\n\tlocalize?: boolean\n}\n\nexport const buildFieldBlocks = ({\n\tregistry,\n\truleRegistry,\n\tlocalize = true,\n}: BuildFieldBlocksArgs): Block[] => {\n\tconst conditionTypes = buildConditionTypeMap(registry)\n\tconst blocks: Block[] = []\n\tconst bareSlugs = new Set<string>()\n\tfor (const definition of registry.values()) {\n\t\tconst typeConfig: Field[] = definition.config ?? []\n\n\t\tif (definition.bare === true) {\n\t\t\tbareSlugs.add(definition.type)\n\t\t\tblocks.push({\n\t\t\t\tslug: definition.type,\n\t\t\t\tlabels: { singular: labelFor(definition.label), plural: labelFor(definition.label) },\n\t\t\t\tadmin: blockLabelAdmin(definition.label, definition.blockLabel),\n\t\t\t\tfields: typeConfig,\n\t\t\t})\n\t\t\tcontinue\n\t\t}\n\n\t\tblocks.push({\n\t\t\tslug: definition.type,\n\t\t\tlabels: { singular: labelFor(definition.label), plural: labelFor(definition.label) },\n\t\t\tadmin: blockLabelAdmin(definition.label, definition.blockLabel),\n\t\t\tfields: [\n\t\t\t\tfieldBlockTabs({\n\t\t\t\t\tconditionTypes,\n\t\t\t\t\ttypeConfig,\n\t\t\t\t\tvalidations: {\n\t\t\t\t\t\tname: 'validations',\n\t\t\t\t\t\ttype: 'blocks',\n\t\t\t\t\t\tlabel: labelFor(keys.validationsLabel),\n\t\t\t\t\t\tblocks: buildRuleBlocks(ruleRegistry, definition.type),\n\t\t\t\t\t},\n\t\t\t\t\tlocalize,\n\t\t\t\t\tomitShared: definition.omitShared,\n\t\t\t\t}),\n\t\t\t],\n\t\t})\n\t}\n\n\t// Second pass: inject subFields into the repeater block using all non-repeater blocks.\n\t// Done after the main loop so every sibling block is already built.\n\t// Repeater-in-repeater is not supported in v1; the repeater block is excluded from subFields.\n\t// Bare blocks are excluded too: repeater row plumbing (values, composite error paths) is name-keyed.\n\tconst repeaterBlock = blocks.find((b) => b.slug === 'repeater')\n\tif (repeaterBlock) {\n\t\tconst subFieldsField: Field = {\n\t\t\tname: 'subFields',\n\t\t\ttype: 'blocks',\n\t\t\tlabel: labelFor(keys.configSubFields),\n\t\t\tblocks: blocks.filter((b) => b.slug !== 'repeater' && !bareSlugs.has(b.slug)),\n\t\t}\n\t\tconst fieldTabFields = fieldTabOf(repeaterBlock)\n\t\t;(fieldTabFields ?? (repeaterBlock.fields as Field[])).push(subFieldsField)\n\t}\n\n\treturn blocks\n}\n"],"mappings":";;;;;;AASA,MAAM,wBAAwB;;;;;AAM9B,MAAM,mBACL,cACA,MAAc,2BACoB,EAClC,YAAY,EAAE,OAAO;CAAE,MAAM;CAAK,aAAa,EAAE,aAAa;AAAE,EAAE,EACnE;;AAGA,MAAM,gBAAgB,WACrB,OAAO,MAAM,MAAM;CAClB,IAAI,UAAU,KAAK,EAAE,SAAS,QAC7B,OAAO;CAER,OAAO,EAAE,SAAS,SAAS,aAAa,EAAE,MAAM;AACjD,CAAC;;AAGF,MAAM,cAAc,UAAsC;CAEzD,OADkB,MAAM,OAAO,MAAM,MAAsB,EAAE,SAAS,MACvD,GAAG,KAAK,MAAM,QAAQ,aAAa,IAAI,MAAM,CAAC,GAAG;AACjE;AAeA,MAAa,oBAAoB,EAChC,UACA,cACA,WAAW,WACyB;CACpC,MAAM,iBAAiB,sBAAsB,QAAQ;CACrD,MAAM,SAAkB,CAAC;CACzB,MAAM,4BAAY,IAAI,IAAY;CAClC,KAAK,MAAM,cAAc,SAAS,OAAO,GAAG;EAC3C,MAAM,aAAsB,WAAW,UAAU,CAAC;EAElD,IAAI,WAAW,SAAS,MAAM;GAC7B,UAAU,IAAI,WAAW,IAAI;GAC7B,OAAO,KAAK;IACX,MAAM,WAAW;IACjB,QAAQ;KAAE,UAAU,SAAS,WAAW,KAAK;KAAG,QAAQ,SAAS,WAAW,KAAK;IAAE;IACnF,OAAO,gBAAgB,WAAW,OAAO,WAAW,UAAU;IAC9D,QAAQ;GACT,CAAC;GACD;EACD;EAEA,OAAO,KAAK;GACX,MAAM,WAAW;GACjB,QAAQ;IAAE,UAAU,SAAS,WAAW,KAAK;IAAG,QAAQ,SAAS,WAAW,KAAK;GAAE;GACnF,OAAO,gBAAgB,WAAW,OAAO,WAAW,UAAU;GAC9D,QAAQ,CACP,eAAe;IACd;IACA;IACA,aAAa;KACZ,MAAM;KACN,MAAM;KACN,OAAO,SAAS,KAAK,gBAAgB;KACrC,QAAQ,gBAAgB,cAAc,WAAW,IAAI;IACtD;IACA;IACA,YAAY,WAAW;
|
|
1
|
+
{"version":3,"file":"buildFieldBlocks.js","names":[],"sources":["../../src/fields/buildFieldBlocks.ts"],"sourcesContent":["import type { Block, Field, TabsField } from 'payload'\nimport { buildConditionTypeMap } from '../conditions/conditionType'\nimport { keys } from '../translations/keys'\nimport { labelFor } from '../translations/server'\nimport { buildRuleBlocks } from '../validation/buildRuleBlocks'\nimport type { ValidationRuleRegistry } from '../validation/registry'\nimport type { FieldTypeRegistry } from './registry'\nimport { fieldBlockTabs } from './sharedConfig'\n\nconst FIELD_BLOCK_LABEL_REF = '@10x-media/form-builder/client#FieldBlockLabel'\n\n/**\n * Replace Payload's default `blockName` row header (which reads \"Untitled\" until filled) with the\n * field's own `label`, keyed to the type label as fallback. See `FieldBlockLabel`.\n */\nconst blockLabelAdmin = (\n\ttypeLabelKey: string,\n\tref: string = FIELD_BLOCK_LABEL_REF\n): NonNullable<Block['admin']> => ({\n\tcomponents: { Label: { path: ref, clientProps: { typeLabelKey } } },\n})\n\n/** Whether `fields` contains a field named `name`, descending into presentational rows. */\nconst hasNameField = (fields: Field[]): boolean =>\n\tfields.some((f) => {\n\t\tif ('name' in f && f.name === 'name') {\n\t\t\treturn true\n\t\t}\n\t\treturn f.type === 'row' && hasNameField(f.fields)\n\t})\n\n/** The tab whose fields hold the shared basics and type config, found by the `name` field it carries. */\nconst fieldTabOf = (block: Block): Field[] | undefined => {\n\tconst tabsField = block.fields.find((f): f is TabsField => f.type === 'tabs')\n\treturn tabsField?.tabs.find((tab) => hasNameField(tab.fields))?.fields\n}\n\n/**\n * One add-field block per registered type: tabs holding shared config, type config, and\n * validations. Bare definitions (e.g. `message`) skip all of that: their block is the\n * definition's `config` alone, no name/shared basics/tabs. `localize` controls whether the\n * shared content fields carry `localized: true`; per-type config fields carry their own flag\n * from the registry definitions.\n */\ntype BuildFieldBlocksArgs = {\n\tregistry: FieldTypeRegistry\n\truleRegistry: ValidationRuleRegistry\n\tlocalize?: boolean\n}\n\nexport const buildFieldBlocks = ({\n\tregistry,\n\truleRegistry,\n\tlocalize = true,\n}: BuildFieldBlocksArgs): Block[] => {\n\tconst conditionTypes = buildConditionTypeMap(registry)\n\tconst blocks: Block[] = []\n\tconst bareSlugs = new Set<string>()\n\tfor (const definition of registry.values()) {\n\t\tconst typeConfig: Field[] = definition.config ?? []\n\n\t\tif (definition.bare === true) {\n\t\t\tbareSlugs.add(definition.type)\n\t\t\tblocks.push({\n\t\t\t\tslug: definition.type,\n\t\t\t\tlabels: { singular: labelFor(definition.label), plural: labelFor(definition.label) },\n\t\t\t\tadmin: blockLabelAdmin(definition.label, definition.blockLabel),\n\t\t\t\tfields: typeConfig,\n\t\t\t})\n\t\t\tcontinue\n\t\t}\n\n\t\tblocks.push({\n\t\t\tslug: definition.type,\n\t\t\tlabels: { singular: labelFor(definition.label), plural: labelFor(definition.label) },\n\t\t\tadmin: blockLabelAdmin(definition.label, definition.blockLabel),\n\t\t\tfields: [\n\t\t\t\tfieldBlockTabs({\n\t\t\t\t\tconditionTypes,\n\t\t\t\t\ttypeConfig,\n\t\t\t\t\tvalidations: {\n\t\t\t\t\t\tname: 'validations',\n\t\t\t\t\t\ttype: 'blocks',\n\t\t\t\t\t\tlabel: labelFor(keys.validationsLabel),\n\t\t\t\t\t\tblocks: buildRuleBlocks(ruleRegistry, definition.type),\n\t\t\t\t\t},\n\t\t\t\t\tlocalize,\n\t\t\t\t\tomitShared: definition.omitShared,\n\t\t\t\t\tadvancedConfig: definition.advancedConfig,\n\t\t\t\t}),\n\t\t\t],\n\t\t})\n\t}\n\n\t// Second pass: inject subFields into the repeater block using all non-repeater blocks.\n\t// Done after the main loop so every sibling block is already built.\n\t// Repeater-in-repeater is not supported in v1; the repeater block is excluded from subFields.\n\t// Bare blocks are excluded too: repeater row plumbing (values, composite error paths) is name-keyed.\n\tconst repeaterBlock = blocks.find((b) => b.slug === 'repeater')\n\tif (repeaterBlock) {\n\t\tconst subFieldsField: Field = {\n\t\t\tname: 'subFields',\n\t\t\ttype: 'blocks',\n\t\t\tlabel: labelFor(keys.configSubFields),\n\t\t\tblocks: blocks.filter((b) => b.slug !== 'repeater' && !bareSlugs.has(b.slug)),\n\t\t}\n\t\tconst fieldTabFields = fieldTabOf(repeaterBlock)\n\t\t;(fieldTabFields ?? (repeaterBlock.fields as Field[])).push(subFieldsField)\n\t}\n\n\treturn blocks\n}\n"],"mappings":";;;;;;AASA,MAAM,wBAAwB;;;;;AAM9B,MAAM,mBACL,cACA,MAAc,2BACoB,EAClC,YAAY,EAAE,OAAO;CAAE,MAAM;CAAK,aAAa,EAAE,aAAa;AAAE,EAAE,EACnE;;AAGA,MAAM,gBAAgB,WACrB,OAAO,MAAM,MAAM;CAClB,IAAI,UAAU,KAAK,EAAE,SAAS,QAC7B,OAAO;CAER,OAAO,EAAE,SAAS,SAAS,aAAa,EAAE,MAAM;AACjD,CAAC;;AAGF,MAAM,cAAc,UAAsC;CAEzD,OADkB,MAAM,OAAO,MAAM,MAAsB,EAAE,SAAS,MACvD,GAAG,KAAK,MAAM,QAAQ,aAAa,IAAI,MAAM,CAAC,GAAG;AACjE;AAeA,MAAa,oBAAoB,EAChC,UACA,cACA,WAAW,WACyB;CACpC,MAAM,iBAAiB,sBAAsB,QAAQ;CACrD,MAAM,SAAkB,CAAC;CACzB,MAAM,4BAAY,IAAI,IAAY;CAClC,KAAK,MAAM,cAAc,SAAS,OAAO,GAAG;EAC3C,MAAM,aAAsB,WAAW,UAAU,CAAC;EAElD,IAAI,WAAW,SAAS,MAAM;GAC7B,UAAU,IAAI,WAAW,IAAI;GAC7B,OAAO,KAAK;IACX,MAAM,WAAW;IACjB,QAAQ;KAAE,UAAU,SAAS,WAAW,KAAK;KAAG,QAAQ,SAAS,WAAW,KAAK;IAAE;IACnF,OAAO,gBAAgB,WAAW,OAAO,WAAW,UAAU;IAC9D,QAAQ;GACT,CAAC;GACD;EACD;EAEA,OAAO,KAAK;GACX,MAAM,WAAW;GACjB,QAAQ;IAAE,UAAU,SAAS,WAAW,KAAK;IAAG,QAAQ,SAAS,WAAW,KAAK;GAAE;GACnF,OAAO,gBAAgB,WAAW,OAAO,WAAW,UAAU;GAC9D,QAAQ,CACP,eAAe;IACd;IACA;IACA,aAAa;KACZ,MAAM;KACN,MAAM;KACN,OAAO,SAAS,KAAK,gBAAgB;KACrC,QAAQ,gBAAgB,cAAc,WAAW,IAAI;IACtD;IACA;IACA,YAAY,WAAW;IACvB,gBAAgB,WAAW;GAC5B,CAAC,CACF;EACD,CAAC;CACF;CAMA,MAAM,gBAAgB,OAAO,MAAM,MAAM,EAAE,SAAS,UAAU;CAC9D,IAAI,eAAe;EAClB,MAAM,iBAAwB;GAC7B,MAAM;GACN,MAAM;GACN,OAAO,SAAS,KAAK,eAAe;GACpC,QAAQ,OAAO,QAAQ,MAAM,EAAE,SAAS,cAAc,CAAC,UAAU,IAAI,EAAE,IAAI,CAAC;EAC7E;EAEC,CADsB,WAAW,aACnB,KAAM,cAAc,QAAoB,KAAK,cAAc;CAC3E;CAEA,OAAO;AACR"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { PayloadRequest } from "payload";
|
|
2
|
+
|
|
3
|
+
//#region src/fields/builtin/calculation.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Serializable calc-source metadata for the admin builder (threaded as clientProps): key, display
|
|
6
|
+
* label, and which modes the source implements (`scalar` = has `resolve`, `weights` = has
|
|
7
|
+
* `resolveWeights`). Derived where the registry is resolved; resolver functions never serialize.
|
|
8
|
+
*/
|
|
9
|
+
type CalcSourceClientMeta = {
|
|
10
|
+
key: string;
|
|
11
|
+
label: string | Record<string, string>;
|
|
12
|
+
scalar: boolean;
|
|
13
|
+
weights: boolean;
|
|
14
|
+
};
|
|
15
|
+
//#endregion
|
|
16
|
+
export { CalcSourceClientMeta };
|
|
17
|
+
//# sourceMappingURL=calculation.d.ts.map
|