@10x-media/form-builder 0.1.0-beta.9 → 4.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +173 -0
- package/README.md +11 -3
- package/dist/actions/assertNoBlockCollision.js +18 -0
- package/dist/actions/assertNoBlockCollision.js.map +1 -0
- package/dist/actions/body/serializeBody.d.ts +16 -14
- package/dist/actions/body/serializeBody.js +5 -8
- package/dist/actions/body/serializeBody.js.map +1 -1
- package/dist/actions/builtin/confirmation.js +2 -1
- package/dist/actions/builtin/confirmation.js.map +1 -1
- package/dist/actions/builtin/emailAction.d.ts +15 -3
- package/dist/actions/builtin/emailAction.js +72 -20
- 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 +37 -6
- package/dist/actions/defineAction.js +14 -1
- package/dist/actions/defineAction.js.map +1 -1
- package/dist/actions/dispatch.d.ts +12 -0
- package/dist/actions/dispatch.js +103 -30
- package/dist/actions/dispatch.js.map +1 -1
- package/dist/actions/dispatchContext.js +19 -0
- package/dist/actions/dispatchContext.js.map +1 -0
- package/dist/actions/emailRecipients.js +38 -8
- package/dist/actions/emailRecipients.js.map +1 -1
- package/dist/actions/emailRender.d.ts +27 -0
- package/dist/actions/fromAddresses.d.ts +19 -1
- package/dist/actions/fromAddresses.js +66 -9
- package/dist/actions/fromAddresses.js.map +1 -1
- package/dist/actions/recipientSources.d.ts +23 -0
- package/dist/actions/recipientSources.js +11 -0
- package/dist/actions/recipientSources.js.map +1 -0
- package/dist/actions/registry.js +3 -1
- package/dist/actions/registry.js.map +1 -1
- package/dist/actions/runActions.d.ts +2 -0
- package/dist/actions/runActions.js +13 -8
- package/dist/actions/runActions.js.map +1 -1
- package/dist/actions/sign.js.map +1 -1
- package/dist/actions/submissionContext.d.ts +34 -0
- package/dist/actions/task.js +43 -16
- package/dist/actions/task.js.map +1 -1
- package/dist/aggregation/aggregateResponses.js +3 -4
- package/dist/aggregation/aggregateResponses.js.map +1 -1
- package/dist/aggregation/resolveResultsRequest.d.ts +6 -0
- package/dist/aggregation/resolveResultsRequest.js +69 -26
- 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 +19 -4
- package/dist/calc/types.js +3 -2
- package/dist/calc/types.js.map +1 -1
- package/dist/client/ByteSizeField.js +11 -8
- package/dist/client/ByteSizeField.js.map +1 -1
- package/dist/client/CalcExpressionBuilder.d.ts +20 -0
- package/dist/client/CalcExpressionBuilder.js +888 -0
- package/dist/client/CalcExpressionBuilder.js.map +1 -0
- package/dist/client/ClosePollButton.js +3 -3
- package/dist/client/ClosePollButton.js.map +1 -1
- package/dist/client/CondensedArray.d.ts +2 -2
- package/dist/client/CondensedArray.js +5 -7
- package/dist/client/CondensedArray.js.map +1 -1
- package/dist/client/ConditionBuilder.js +5 -7
- package/dist/client/ConditionBuilder.js.map +1 -1
- package/dist/client/ConditionRow.js +3 -3
- package/dist/client/ConditionRow.js.map +1 -1
- package/dist/client/ConsentBlockLabel.js +2 -2
- package/dist/client/ConsentBlockLabel.js.map +1 -1
- package/dist/client/ConsentRetentionNotice.d.ts +11 -0
- package/dist/client/ConsentRetentionNotice.js +23 -0
- package/dist/client/ConsentRetentionNotice.js.map +1 -0
- package/dist/client/EndpointOptionsSelect.d.ts +17 -7
- package/dist/client/EndpointOptionsSelect.js +18 -14
- package/dist/client/EndpointOptionsSelect.js.map +1 -1
- package/dist/client/FieldBlockLabel.js +2 -2
- package/dist/client/FieldBlockLabel.js.map +1 -1
- package/dist/client/FieldNameSelect.d.ts +1 -0
- package/dist/client/FieldNameSelect.js +2 -4
- package/dist/client/FieldNameSelect.js.map +1 -1
- package/dist/client/FlowBuilder.js +31 -23
- package/dist/client/FlowBuilder.js.map +1 -1
- package/dist/client/FormConditionField.js +0 -1
- package/dist/client/FormConditionField.js.map +1 -1
- package/dist/client/RecipientsSelect.d.ts +9 -2
- package/dist/client/RecipientsSelect.js +31 -10
- package/dist/client/RecipientsSelect.js.map +1 -1
- package/dist/client/admin.css +345 -72
- package/dist/client/endpointOptions.d.ts +11 -0
- package/dist/client/endpointOptions.js +17 -8
- package/dist/client/endpointOptions.js.map +1 -1
- package/dist/collections/formSubmissions.js +145 -51
- package/dist/collections/formSubmissions.js.map +1 -1
- package/dist/collections/forms.js +170 -65
- package/dist/collections/forms.js.map +1 -1
- package/dist/collections/formsEndpoints.js +31 -26
- package/dist/collections/formsEndpoints.js.map +1 -1
- package/dist/collections/settingsFields.d.ts +32 -0
- package/dist/collections/settingsFields.js +55 -0
- package/dist/collections/settingsFields.js.map +1 -0
- package/dist/consent/captureConsent.d.ts +2 -1
- package/dist/consent/captureConsent.js +4 -1
- package/dist/consent/captureConsent.js.map +1 -1
- package/dist/consent/consentSourcesField.d.ts +7 -1
- package/dist/consent/consentSourcesField.js +15 -1
- package/dist/consent/consentSourcesField.js.map +1 -1
- package/dist/consent/effectiveStatement.js +16 -0
- package/dist/consent/effectiveStatement.js.map +1 -0
- package/dist/consent/resolveConsentSourcesRequest.js +2 -2
- package/dist/consent/resolveConsentSourcesRequest.js.map +1 -1
- package/dist/consent/resolveConsentStatements.js +3 -1
- package/dist/consent/resolveConsentStatements.js.map +1 -1
- package/dist/consent/resolvePublishedVersionRef.js +1 -0
- package/dist/consent/resolvePublishedVersionRef.js.map +1 -1
- package/dist/consent/types.d.ts +8 -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/email/departmentsField.d.ts +6 -1
- package/dist/email/departmentsField.js +6 -1
- package/dist/email/departmentsField.js.map +1 -1
- package/dist/exports/client.d.ts +3 -1
- package/dist/exports/client.js +3 -1
- package/dist/exports/i18n.d.ts +14 -2
- package/dist/exports/i18n.js +14 -2
- package/dist/exports/react.d.ts +23 -5
- package/dist/exports/react.js +17 -1
- package/dist/exports/rsc.d.ts +4 -1
- package/dist/exports/rsc.js +7 -4
- package/dist/exports/types.d.ts +4 -3
- 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 +70 -127
- 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/consent.js +21 -1
- package/dist/fields/builtin/consent.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/findFormAtLocale.d.ts +30 -0
- package/dist/form/findFormAtLocale.js +88 -0
- package/dist/form/findFormAtLocale.js.map +1 -0
- package/dist/form/pollState.d.ts +2 -1
- package/dist/form/pollState.js.map +1 -1
- package/dist/form/toFormDocument.d.ts +8 -0
- package/dist/form/toFormDocument.js +3 -1
- package/dist/form/toFormDocument.js.map +1 -1
- package/dist/form/types.d.ts +9 -1
- package/dist/index.d.ts +22 -6
- package/dist/index.js +63 -17
- package/dist/index.js.map +1 -1
- package/dist/options.d.ts +113 -4
- package/dist/plugin/collectionSlugs.d.ts +28 -0
- package/dist/plugin/collectionSlugs.js +65 -0
- package/dist/plugin/collectionSlugs.js.map +1 -0
- package/dist/plugin/customState.js +1 -1
- package/dist/plugin/customState.js.map +1 -1
- package/dist/plugin/registerCollections.js +38 -21
- package/dist/plugin/registerCollections.js.map +1 -1
- package/dist/poll/closeJob.d.ts +4 -3
- package/dist/poll/closeJob.js +13 -10
- package/dist/poll/closeJob.js.map +1 -1
- package/dist/poll/outcomeBeforeChange.js +2 -2
- package/dist/poll/outcomeBeforeChange.js.map +1 -1
- package/dist/poll/pollTypeRegistry.js +1 -1
- package/dist/poll/resolvePollCloseRequest.js +5 -4
- package/dist/poll/resolvePollCloseRequest.js.map +1 -1
- package/dist/poll/resolvePollOptionsRequest.js +2 -2
- package/dist/poll/resolvePollOptionsRequest.js.map +1 -1
- package/dist/poll/resolvePollOutcome.d.ts +6 -0
- package/dist/poll/resolvePollOutcome.js +20 -6
- package/dist/poll/resolvePollOutcome.js.map +1 -1
- package/dist/poll/votes/aggregateFromVotes.d.ts +27 -0
- package/dist/poll/votes/aggregateFromVotes.js +55 -0
- package/dist/poll/votes/aggregateFromVotes.js.map +1 -0
- package/dist/poll/votes/answerValues.js +16 -0
- package/dist/poll/votes/answerValues.js.map +1 -0
- package/dist/poll/votes/bumpPollVote.js +91 -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 +76 -0
- package/dist/poll/votes/voteTallyHook.js.map +1 -0
- package/dist/poll/votes/votesCollection.d.ts +23 -0
- package/dist/poll/votes/votesCollection.js +96 -0
- package/dist/poll/votes/votesCollection.js.map +1 -0
- package/dist/react/Form.d.ts +49 -7
- package/dist/react/Form.js +48 -13
- 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/FormResults.d.ts +4 -2
- package/dist/react/FormResults.js +21 -8
- package/dist/react/FormResults.js.map +1 -1
- package/dist/react/Poll.d.ts +25 -2
- package/dist/react/Poll.js +76 -25
- package/dist/react/Poll.js.map +1 -1
- package/dist/react/adapters.d.ts +35 -0
- package/dist/react/adapters.js +11 -0
- package/dist/react/adapters.js.map +1 -0
- package/dist/react/captcha/HcaptchaCaptcha.d.ts +4 -1
- package/dist/react/captcha/HcaptchaCaptcha.js +2 -2
- package/dist/react/captcha/HcaptchaCaptcha.js.map +1 -1
- package/dist/react/captcha/RecaptchaCaptcha.d.ts +4 -1
- package/dist/react/captcha/RecaptchaCaptcha.js +2 -2
- package/dist/react/captcha/RecaptchaCaptcha.js.map +1 -1
- package/dist/react/captcha/TurnstileCaptcha.d.ts +4 -1
- package/dist/react/captcha/TurnstileCaptcha.js +2 -2
- package/dist/react/captcha/TurnstileCaptcha.js.map +1 -1
- package/dist/react/captcha/useCaptchaScript.js +23 -5
- package/dist/react/captcha/useCaptchaScript.js.map +1 -1
- package/dist/react/fetchResults.d.ts +6 -3
- package/dist/react/fetchResults.js +10 -5
- package/dist/react/fetchResults.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/consent.js +8 -3
- package/dist/react/renderers/consent.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/repeater.js +5 -0
- package/dist/react/renderers/repeater.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/state.d.ts +10 -0
- package/dist/react/state.js +45 -1
- package/dist/react/state.js.map +1 -1
- package/dist/react/submitForm.d.ts +20 -3
- package/dist/react/submitForm.js +8 -4
- package/dist/react/submitForm.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/react/useField.js +2 -1
- package/dist/react/useField.js.map +1 -1
- 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/spam/spamGuard.js +2 -1
- package/dist/spam/spamGuard.js.map +1 -1
- package/dist/submissions/SubmissionAnswersClient.js +14 -14
- package/dist/submissions/SubmissionAnswersClient.js.map +1 -1
- package/dist/submissions/createSubmission.d.ts +7 -1
- package/dist/submissions/createSubmission.js +10 -5
- package/dist/submissions/createSubmission.js.map +1 -1
- package/dist/submissions/formIdOf.js +13 -0
- package/dist/submissions/formIdOf.js.map +1 -0
- package/dist/submissions/resolveVotedSubmission.d.ts +27 -0
- package/dist/submissions/resolveVotedSubmission.js +51 -0
- package/dist/submissions/resolveVotedSubmission.js.map +1 -0
- package/dist/submissions/runSubmission.js +6 -5
- package/dist/submissions/runSubmission.js.map +1 -1
- package/dist/submissions/submissionLocale.js +39 -0
- package/dist/submissions/submissionLocale.js.map +1 -0
- package/dist/submissions/validateSubmission.js +125 -79
- 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/submissions/voteChange.js +21 -0
- package/dist/submissions/voteChange.js.map +1 -0
- package/dist/submissions/voteChangeEndpoint.js +110 -0
- package/dist/submissions/voteChangeEndpoint.js.map +1 -0
- package/dist/submissions/votedCookie.d.ts +10 -4
- package/dist/submissions/votedCookie.js +49 -11
- package/dist/submissions/votedCookie.js.map +1 -1
- package/dist/translations/ar.d.ts +7 -0
- package/dist/translations/ar.js +379 -0
- package/dist/translations/ar.js.map +1 -0
- package/dist/translations/clientRuntimeKeys.d.ts +17 -0
- package/dist/translations/clientRuntimeKeys.js +48 -0
- package/dist/translations/clientRuntimeKeys.js.map +1 -0
- package/dist/translations/de.d.ts +12 -0
- package/dist/translations/de.js +78 -3
- package/dist/translations/de.js.map +1 -1
- package/dist/translations/en.js +78 -3
- package/dist/translations/en.js.map +1 -1
- package/dist/translations/es.d.ts +7 -0
- package/dist/translations/es.js +379 -0
- package/dist/translations/es.js.map +1 -0
- package/dist/translations/fr.d.ts +7 -0
- package/dist/translations/fr.js +379 -0
- package/dist/translations/fr.js.map +1 -0
- package/dist/translations/id.d.ts +7 -0
- package/dist/translations/id.js +379 -0
- package/dist/translations/id.js.map +1 -0
- package/dist/translations/index.d.ts +23 -6
- package/dist/translations/index.js +31 -6
- package/dist/translations/index.js.map +1 -1
- package/dist/translations/keys.d.ts +76 -1
- package/dist/translations/keys.js +76 -1
- package/dist/translations/keys.js.map +1 -1
- package/dist/translations/ko.d.ts +7 -0
- package/dist/translations/ko.js +379 -0
- package/dist/translations/ko.js.map +1 -0
- package/dist/translations/makeTranslate.d.ts +7 -3
- package/dist/translations/makeTranslate.js +12 -3
- package/dist/translations/makeTranslate.js.map +1 -1
- package/dist/translations/pt.d.ts +7 -0
- package/dist/translations/pt.js +379 -0
- package/dist/translations/pt.js.map +1 -0
- package/dist/translations/ru.d.ts +7 -0
- package/dist/translations/ru.js +379 -0
- package/dist/translations/ru.js.map +1 -0
- package/dist/translations/uk.d.ts +7 -0
- package/dist/translations/uk.js +379 -0
- package/dist/translations/uk.js.map +1 -0
- package/dist/translations/zh.d.ts +7 -0
- package/dist/translations/zh.js +379 -0
- package/dist/translations/zh.js.map +1 -0
- 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/dist/validation/builtin/notAlreadySubmitted.js +5 -3
- package/dist/validation/builtin/notAlreadySubmitted.js.map +1 -1
- package/package.json +24 -16
- package/styles/form-builder.css +84 -0
|
@@ -36,7 +36,12 @@ type DepartmentsFieldOptions = {
|
|
|
36
36
|
* formBuilder({
|
|
37
37
|
* email: {
|
|
38
38
|
* departments: async ({ req }) => {
|
|
39
|
-
* const settings = await req.payload.findGlobal({
|
|
39
|
+
* const settings = await req.payload.findGlobal({
|
|
40
|
+
* slug: 'settings',
|
|
41
|
+
* depth: 0,
|
|
42
|
+
* locale: 'all',
|
|
43
|
+
* overrideAccess: true,
|
|
44
|
+
* })
|
|
40
45
|
* return resolveDepartmentOptions({ payload: req.payload, req, doc: settings })
|
|
41
46
|
* },
|
|
42
47
|
* },
|
|
@@ -27,7 +27,12 @@ import { localizedIf } from "../fields/localizedIf.js";
|
|
|
27
27
|
* formBuilder({
|
|
28
28
|
* email: {
|
|
29
29
|
* departments: async ({ req }) => {
|
|
30
|
-
* const settings = await req.payload.findGlobal({
|
|
30
|
+
* const settings = await req.payload.findGlobal({
|
|
31
|
+
* slug: 'settings',
|
|
32
|
+
* depth: 0,
|
|
33
|
+
* locale: 'all',
|
|
34
|
+
* overrideAccess: true,
|
|
35
|
+
* })
|
|
31
36
|
* return resolveDepartmentOptions({ payload: req.payload, req, doc: settings })
|
|
32
37
|
* },
|
|
33
38
|
* },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"departmentsField.js","names":[],"sources":["../../src/email/departmentsField.ts"],"sourcesContent":["import type { ArrayField } from 'payload'\nimport { localizedIf } from '../fields/localizedIf'\nimport { keys } from '../translations/keys'\nimport { labelForKey } from '../translations/server'\n\nexport type DepartmentsFieldOptions = {\n\t/** Field name, i.e. what the row array is stored under. Defaults to `departmentEmails`. */\n\tname?: string\n\t/** Field label. Defaults to the plugin's translated one. */\n\tlabel?: ArrayField['label']\n\t/**\n\t * Whether each row's `email` (and its `label`) carry `localized: true`, so the same field can\n\t * hold a different address per locale. Default `true`; Payload strips the flag on hosts without\n\t * `localization`, so it is safe either way.\n\t */\n\tlocalized?: boolean\n}\n\n/**\n * The department-emails array, for the host to place on any collection or global they own: a\n * settings global, a tenants collection, a departments parent, wherever the addresses belong. The\n * plugin never registers it and never guesses where it lives; the `email.departments` resolver reads\n * it back, which is also where multi-tenant scoping goes: place this on the tenant-scoped document\n * and have the resolver return only that tenant's addresses, derived from `req`.\n *\n * A row is a `label` (how the address is named when routing a submission to it) and the `email` it\n * resolves to. Because `email` is `localized` by default, a host can hold a different address per\n * locale without changing the stored shape. The array itself is not localized, so per-locale edits\n * must address existing rows by their own auto-assigned `id` rather than re-sending id-less rows.\n *\n * It renders condensed: `admin.components.Field` is {@link CondensedArray}, which lays each row out\n * flat as `[label, email]` at 50% each with no per-row collapsible, while keeping Payload's native\n * per-locale storage and row ids.\n *\n * ```ts\n * // The host's own collection or global:\n * fields: [departmentsField()]\n *\n * // The plugin, reading it back to route a submission. `resolveDepartmentOptions` reads the array\n * // (fetched at `locale: 'all'`) and resolves each row's address for the requesting locale:\n * formBuilder({\n * email: {\n * departments: async ({ req }) => {\n * const settings = await req.payload.findGlobal({ slug: 'settings'
|
|
1
|
+
{"version":3,"file":"departmentsField.js","names":[],"sources":["../../src/email/departmentsField.ts"],"sourcesContent":["import type { ArrayField } from 'payload'\nimport { localizedIf } from '../fields/localizedIf'\nimport { keys } from '../translations/keys'\nimport { labelForKey } from '../translations/server'\n\nexport type DepartmentsFieldOptions = {\n\t/** Field name, i.e. what the row array is stored under. Defaults to `departmentEmails`. */\n\tname?: string\n\t/** Field label. Defaults to the plugin's translated one. */\n\tlabel?: ArrayField['label']\n\t/**\n\t * Whether each row's `email` (and its `label`) carry `localized: true`, so the same field can\n\t * hold a different address per locale. Default `true`; Payload strips the flag on hosts without\n\t * `localization`, so it is safe either way.\n\t */\n\tlocalized?: boolean\n}\n\n/**\n * The department-emails array, for the host to place on any collection or global they own: a\n * settings global, a tenants collection, a departments parent, wherever the addresses belong. The\n * plugin never registers it and never guesses where it lives; the `email.departments` resolver reads\n * it back, which is also where multi-tenant scoping goes: place this on the tenant-scoped document\n * and have the resolver return only that tenant's addresses, derived from `req`.\n *\n * A row is a `label` (how the address is named when routing a submission to it) and the `email` it\n * resolves to. Because `email` is `localized` by default, a host can hold a different address per\n * locale without changing the stored shape. The array itself is not localized, so per-locale edits\n * must address existing rows by their own auto-assigned `id` rather than re-sending id-less rows.\n *\n * It renders condensed: `admin.components.Field` is {@link CondensedArray}, which lays each row out\n * flat as `[label, email]` at 50% each with no per-row collapsible, while keeping Payload's native\n * per-locale storage and row ids.\n *\n * ```ts\n * // The host's own collection or global:\n * fields: [departmentsField()]\n *\n * // The plugin, reading it back to route a submission. `resolveDepartmentOptions` reads the array\n * // (fetched at `locale: 'all'`) and resolves each row's address for the requesting locale:\n * formBuilder({\n * email: {\n * departments: async ({ req }) => {\n * const settings = await req.payload.findGlobal({\n * slug: 'settings',\n * depth: 0,\n * locale: 'all',\n * overrideAccess: true,\n * })\n * return resolveDepartmentOptions({ payload: req.payload, req, doc: settings })\n * },\n * },\n * })\n * ```\n *\n * The read above omits the save's `req` on purpose: threading it into a `locale: 'all'` read from\n * within a form's save validation flips `req.locale` to `all` and corrupts the localized write of the\n * document being saved. It reads already-committed data, so no transaction (`req`) is needed.\n */\nexport const departmentsField = (options: DepartmentsFieldOptions = {}): ArrayField => {\n\tconst localize = options.localized !== false\n\n\treturn {\n\t\tname: options.name ?? 'departmentEmails',\n\t\ttype: 'array',\n\t\tlabel: options.label ?? labelForKey(keys.departmentsField),\n\t\tlabels: {\n\t\t\tsingular: labelForKey(keys.departmentSingular),\n\t\t\tplural: labelForKey(keys.departmentPlural),\n\t\t},\n\t\tadmin: {\n\t\t\tdescription: labelForKey(keys.departmentsFieldDescription),\n\t\t\tcomponents: { Field: '@10x-media/form-builder/client#CondensedArray' },\n\t\t},\n\t\tfields: [\n\t\t\t{\n\t\t\t\tname: 'label',\n\t\t\t\ttype: 'text',\n\t\t\t\tlabel: labelForKey(keys.departmentLabel),\n\t\t\t\tadmin: { width: '50%' },\n\t\t\t\t...localizedIf(localize),\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'email',\n\t\t\t\ttype: 'text',\n\t\t\t\tlabel: labelForKey(keys.departmentEmail),\n\t\t\t\tadmin: { width: '50%' },\n\t\t\t\t...localizedIf(localize),\n\t\t\t},\n\t\t],\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2DA,MAAa,oBAAoB,UAAmC,CAAC,MAAkB;CACtF,MAAM,WAAW,QAAQ,cAAc;CAEvC,OAAO;EACN,MAAM,QAAQ,QAAQ;EACtB,MAAM;EACN,OAAO,QAAQ,SAAS,YAAY,KAAK,gBAAgB;EACzD,QAAQ;GACP,UAAU,YAAY,KAAK,kBAAkB;GAC7C,QAAQ,YAAY,KAAK,gBAAgB;EAC1C;EACA,OAAO;GACN,aAAa,YAAY,KAAK,2BAA2B;GACzD,YAAY,EAAE,OAAO,gDAAgD;EACtE;EACA,QAAQ,CACP;GACC,MAAM;GACN,MAAM;GACN,OAAO,YAAY,KAAK,eAAe;GACvC,OAAO,EAAE,OAAO,MAAM;GACtB,GAAG,YAAY,QAAQ;EACxB,GACA;GACC,MAAM;GACN,MAAM;GACN,OAAO,YAAY,KAAK,eAAe;GACvC,OAAO,EAAE,OAAO,MAAM;GACtB,GAAG,YAAY,QAAQ;EACxB,CACD;CACD;AACD"}
|
package/dist/exports/client.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
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";
|
|
6
|
+
import { ConsentRetentionNotice } from "../client/ConsentRetentionNotice.js";
|
|
5
7
|
import { ConsentSourceRowLabel } from "../client/ConsentSourceRowLabel.js";
|
|
6
8
|
import { EndpointOptionsSelect } from "../client/EndpointOptionsSelect.js";
|
|
7
9
|
import { FieldBlockLabel } from "../client/FieldBlockLabel.js";
|
|
@@ -12,4 +14,4 @@ import { RecipientsSelect } from "../client/RecipientsSelect.js";
|
|
|
12
14
|
import { RuleDescription } from "../client/RuleDescription.js";
|
|
13
15
|
import { FieldCountCell } from "../collections/cells/FieldCountCell.js";
|
|
14
16
|
import { FlowStepsCell } from "../collections/cells/FlowStepsCell.js";
|
|
15
|
-
export { ByteSizeField, ClosePollButton, CondensedArray, ConsentBlockLabel, ConsentSourceRowLabel, EndpointOptionsSelect, FieldBlockLabel, FieldCountCell, FieldNameSelect, FlowBuilder, FlowStepsCell, FormConditionField, RecipientsSelect, RuleDescription };
|
|
17
|
+
export { ByteSizeField, CalcExpressionBuilder, ClosePollButton, CondensedArray, ConsentBlockLabel, ConsentRetentionNotice, ConsentSourceRowLabel, EndpointOptionsSelect, FieldBlockLabel, FieldCountCell, FieldNameSelect, FlowBuilder, FlowStepsCell, FormConditionField, RecipientsSelect, RuleDescription };
|
package/dist/exports/client.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
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";
|
|
7
|
+
import { ConsentRetentionNotice } from "../client/ConsentRetentionNotice.js";
|
|
6
8
|
import { ConsentSourceRowLabel } from "../client/ConsentSourceRowLabel.js";
|
|
7
9
|
import { EndpointOptionsSelect } from "../client/EndpointOptionsSelect.js";
|
|
8
10
|
import { FieldBlockLabel } from "../client/FieldBlockLabel.js";
|
|
@@ -13,4 +15,4 @@ import { RecipientsSelect } from "../client/RecipientsSelect.js";
|
|
|
13
15
|
import { RuleDescription } from "../client/RuleDescription.js";
|
|
14
16
|
import { FieldCountCell } from "../collections/cells/FieldCountCell.js";
|
|
15
17
|
import { FlowStepsCell } from "../collections/cells/FlowStepsCell.js";
|
|
16
|
-
export { ByteSizeField, ClosePollButton, CondensedArray, ConsentBlockLabel, ConsentSourceRowLabel, EndpointOptionsSelect, FieldBlockLabel, FieldCountCell, FieldNameSelect, FlowBuilder, FlowStepsCell, FormConditionField, RecipientsSelect, RuleDescription };
|
|
18
|
+
export { ByteSizeField, CalcExpressionBuilder, ClosePollButton, CondensedArray, ConsentBlockLabel, ConsentRetentionNotice, ConsentSourceRowLabel, EndpointOptionsSelect, FieldBlockLabel, FieldCountCell, FieldNameSelect, FlowBuilder, FlowStepsCell, FormConditionField, RecipientsSelect, RuleDescription };
|
package/dist/exports/i18n.d.ts
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
1
|
import { TranslationKey, keys } from "../translations/keys.js";
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { ar } from "../translations/ar.js";
|
|
3
|
+
import { de } from "../translations/de.js";
|
|
4
|
+
import { en } from "../translations/en.js";
|
|
5
|
+
import { es } from "../translations/es.js";
|
|
6
|
+
import { fr } from "../translations/fr.js";
|
|
7
|
+
import { id } from "../translations/id.js";
|
|
8
|
+
import { ko } from "../translations/ko.js";
|
|
9
|
+
import { pt } from "../translations/pt.js";
|
|
10
|
+
import { ru } from "../translations/ru.js";
|
|
11
|
+
import { uk } from "../translations/uk.js";
|
|
12
|
+
import { zh } from "../translations/zh.js";
|
|
13
|
+
import { TranslationBundle, TranslationsOption, bundles, translations } from "../translations/index.js";
|
|
14
|
+
import { clientRuntimeKeys } from "../translations/clientRuntimeKeys.js";
|
|
15
|
+
export { type TranslationKey as FormBuilderTranslationKeys, type TranslationBundle, type TranslationKey, type TranslationsOption, ar, bundles, clientRuntimeKeys, de, en, es, fr, id, keys, ko, pt, ru, translations, uk, zh };
|
package/dist/exports/i18n.js
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
1
|
import { keys } from "../translations/keys.js";
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { ar } from "../translations/ar.js";
|
|
3
|
+
import { de } from "../translations/de.js";
|
|
4
|
+
import { en } from "../translations/en.js";
|
|
5
|
+
import { es } from "../translations/es.js";
|
|
6
|
+
import { fr } from "../translations/fr.js";
|
|
7
|
+
import { id } from "../translations/id.js";
|
|
8
|
+
import { ko } from "../translations/ko.js";
|
|
9
|
+
import { pt } from "../translations/pt.js";
|
|
10
|
+
import { ru } from "../translations/ru.js";
|
|
11
|
+
import { uk } from "../translations/uk.js";
|
|
12
|
+
import { zh } from "../translations/zh.js";
|
|
13
|
+
import { bundles, translations } from "../translations/index.js";
|
|
14
|
+
import { clientRuntimeKeys } from "../translations/clientRuntimeKeys.js";
|
|
15
|
+
export { ar, bundles, clientRuntimeKeys, de, en, es, fr, id, keys, ko, pt, ru, translations, uk, zh };
|
package/dist/exports/react.d.ts
CHANGED
|
@@ -1,11 +1,26 @@
|
|
|
1
|
+
import { CalcExpression } from "../calc/types.js";
|
|
1
2
|
import { FormFieldInstance, SubmissionValue } from "../submissions/types.js";
|
|
3
|
+
import { ar } from "../translations/ar.js";
|
|
4
|
+
import { de } from "../translations/de.js";
|
|
5
|
+
import { en } from "../translations/en.js";
|
|
6
|
+
import { es } from "../translations/es.js";
|
|
7
|
+
import { fr } from "../translations/fr.js";
|
|
8
|
+
import { id } from "../translations/id.js";
|
|
9
|
+
import { ko } from "../translations/ko.js";
|
|
10
|
+
import { pt } from "../translations/pt.js";
|
|
11
|
+
import { ru } from "../translations/ru.js";
|
|
12
|
+
import { uk } from "../translations/uk.js";
|
|
13
|
+
import { zh } from "../translations/zh.js";
|
|
14
|
+
import { TranslationBundle, bundles } from "../translations/index.js";
|
|
15
|
+
import { clientRuntimeKeys } from "../translations/clientRuntimeKeys.js";
|
|
2
16
|
import { BodyConverter, BodyConverterArgs, BodyRender, sanitizeUrl } from "../actions/body/converters.js";
|
|
3
17
|
import { BodyContext, serializeBody } from "../actions/body/serializeBody.js";
|
|
4
18
|
import { textOfBody } from "../actions/body/textOfBody.js";
|
|
5
19
|
import { AggregationBucket, FieldAggregation } from "../aggregation/types.js";
|
|
6
|
-
import {
|
|
20
|
+
import { CalcResolved, evaluateCalc } from "../calc/evaluate.js";
|
|
7
21
|
import { computeCalcFields } from "../calc/computeCalcFields.js";
|
|
8
|
-
import {
|
|
22
|
+
import { formatCalc } from "../calc/formatCalc.js";
|
|
23
|
+
import { CalcDisplayConfig, formatCalcValue } from "../calc/formatCalcValue.js";
|
|
9
24
|
import { evaluateCondition } from "../conditions/evaluate.js";
|
|
10
25
|
import { ConsentStatement, ConsentStatements } from "../consent/resolveConsentStatements.js";
|
|
11
26
|
import { COUNTRIES, US_STATES } from "../fields/data/regions.js";
|
|
@@ -14,6 +29,7 @@ import { firstStepId, isTerminalStepId, resolveNextStepId, stepFieldNames } from
|
|
|
14
29
|
import { FormButtonSettings, FormDocument, FormPollSettings, FormResponseSettings } from "../form/types.js";
|
|
15
30
|
import { ToFormDocumentOptions, toFormDocument } from "../form/toFormDocument.js";
|
|
16
31
|
import { PrefillOptions, valuesFromSearchParams } from "../prefill/valuesFromSearchParams.js";
|
|
32
|
+
import { FormAdapters, LoadScript, NavigateOptions, VoteStorage } from "../react/adapters.js";
|
|
17
33
|
import { CaptchaWidgetHandle } from "../react/captcha/types.js";
|
|
18
34
|
import { HCAPTCHA_SCRIPT_URL, HcaptchaCaptcha, HcaptchaCaptchaProps } from "../react/captcha/HcaptchaCaptcha.js";
|
|
19
35
|
import { RECAPTCHA_SCRIPT_URL, RecaptchaCaptcha, RecaptchaCaptchaHandle, RecaptchaCaptchaProps } from "../react/captcha/RecaptchaCaptcha.js";
|
|
@@ -25,7 +41,7 @@ import { FormPresentation, PresentationWrapperProps } from "../react/presentatio
|
|
|
25
41
|
import { PresentationOption, PresentationRegistry, PresentationsConfig, resolvePresentations } from "../react/presentation/registry.js";
|
|
26
42
|
import { RendererOption, RendererRegistry, RenderersConfig, resolveRenderers } from "../react/registry.js";
|
|
27
43
|
import { SubmitFormResult, SubmitHandler, submitForm } from "../react/submitForm.js";
|
|
28
|
-
import { Form, FormProps, FormSuccessResponse, FormSuccessResult } from "../react/Form.js";
|
|
44
|
+
import { Form, FormCollections, FormProps, FormSuccessResponse, FormSuccessResult } from "../react/Form.js";
|
|
29
45
|
import { RecallResolver, buildRecallResolver } from "../recall/resolver.js";
|
|
30
46
|
import { FieldErrors, FormAction, FormState } from "../react/state.js";
|
|
31
47
|
import { FormContextValue, FormControlLabels, FormStepInfo, useFormContext } from "../react/FormContext.js";
|
|
@@ -35,6 +51,7 @@ import { FormResults, FormResultsProps } from "../react/FormResults.js";
|
|
|
35
51
|
import { FormSteps, FormStepsProps } from "../react/FormSteps.js";
|
|
36
52
|
import { FetchResultsInput, FetchResultsResult, fetchFormResults } from "../react/fetchResults.js";
|
|
37
53
|
import { Honeypot, HoneypotProps } from "../react/Honeypot.js";
|
|
54
|
+
import { VotedSubmission } from "../submissions/resolveVotedSubmission.js";
|
|
38
55
|
import { Poll, PollProps } from "../react/Poll.js";
|
|
39
56
|
import { Backdrop, BackdropProps } from "../react/presentation/Backdrop.js";
|
|
40
57
|
import { DialogSurface, DialogSurfaceProps } from "../react/presentation/DialogSurface.js";
|
|
@@ -43,18 +60,19 @@ import { UseDismissOptions, useDismiss } from "../react/presentation/useDismiss.
|
|
|
43
60
|
import { useFocusTrap } from "../react/presentation/useFocusTrap.js";
|
|
44
61
|
import { useScrollLock } from "../react/presentation/useScrollLock.js";
|
|
45
62
|
import { Checkbox, CheckboxProps } from "../react/primitives/Checkbox.js";
|
|
63
|
+
import { ChoiceGroup, ChoiceGroupProps, ChoiceOption } from "../react/primitives/ChoiceGroup.js";
|
|
46
64
|
import { FieldShell, FieldShellProps } from "../react/primitives/FieldShell.js";
|
|
47
65
|
import { Input, InputProps } from "../react/primitives/Input.js";
|
|
48
66
|
import { Select, SelectOption, SelectProps } from "../react/primitives/Select.js";
|
|
49
67
|
import { Textarea, TextareaProps } from "../react/primitives/Textarea.js";
|
|
50
68
|
import { defaultRenderers } from "../react/renderers/index.js";
|
|
51
69
|
import { UploadFileInput, UploadFileResult, uploadFile } from "../react/uploadFile.js";
|
|
70
|
+
import { useCalcValues } from "../react/useCalcValues.js";
|
|
52
71
|
import { UseFieldResult, useField } from "../react/useField.js";
|
|
53
72
|
import { useFormState } from "../react/useFormState.js";
|
|
54
73
|
import { useFormStep } from "../react/useFormStep.js";
|
|
55
74
|
import { interpolate } from "../recall/interpolate.js";
|
|
56
75
|
import { CAPTCHA_TOKEN_KEY, DEFAULT_HONEYPOT_FIELD } from "../spam/constants.js";
|
|
57
|
-
import { en } from "../translations/en.js";
|
|
58
76
|
import { makeTranslate } from "../translations/makeTranslate.js";
|
|
59
77
|
import { formatBytes } from "../uploads/formatBytes.js";
|
|
60
|
-
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, TurnstileCaptcha, type TurnstileCaptchaProps, US_STATES, type UploadFileInput, type UploadFileResult, type UseDismissOptions, type UseFieldResult, buildRecallResolver, cn, computeCalcFields, 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 };
|
|
78
|
+
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 FormAdapters, type FormButtonSettings, type FormCollections, 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 LoadScript, type NavigateOptions, 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, type VoteStorage, type VotedSubmission, ar, buildRecallResolver, bundles, clientRuntimeKeys, cn, computeCalcFields, de, defaultPresentations, defaultRenderers, defineFieldRenderer, en, es, evaluateCalc, evaluateCondition, fetchFormResults, fieldKey, firstStepId, formatBytes, formatCalc, formatCalcValue, fr, id, interpolate, isTerminalStepId, ko, makeTranslate, pt, resolveNextStepId, resolvePresentations, resolveRenderers, ru, sanitizeUrl, serializeBody, stepFieldNames, submitForm, textOfBody, toFormDocument, uk, uploadFile, useCalcValues, useDismiss, useField, useFocusTrap, useFormContext, useFormState, useFormStep, useScrollLock, valuesFromSearchParams, widthProps, zh };
|
package/dist/exports/react.js
CHANGED
|
@@ -2,13 +2,26 @@
|
|
|
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 { formatCalcValue } from "../calc/formatCalcValue.js";
|
|
5
6
|
import { CAPTCHA_TOKEN_KEY, DEFAULT_HONEYPOT_FIELD } from "../spam/constants.js";
|
|
6
7
|
import { fieldKey } from "../fields/fieldKey.js";
|
|
7
8
|
import { evaluateCalc } from "../calc/evaluate.js";
|
|
8
9
|
import { computeCalcFields } from "../calc/computeCalcFields.js";
|
|
9
10
|
import { evaluateCondition } from "../conditions/evaluate.js";
|
|
10
11
|
import { textOfBody } from "../actions/body/textOfBody.js";
|
|
12
|
+
import { ar } from "../translations/ar.js";
|
|
13
|
+
import { de } from "../translations/de.js";
|
|
11
14
|
import { en } from "../translations/en.js";
|
|
15
|
+
import { es } from "../translations/es.js";
|
|
16
|
+
import { fr } from "../translations/fr.js";
|
|
17
|
+
import { id } from "../translations/id.js";
|
|
18
|
+
import { ko } from "../translations/ko.js";
|
|
19
|
+
import { pt } from "../translations/pt.js";
|
|
20
|
+
import { ru } from "../translations/ru.js";
|
|
21
|
+
import { uk } from "../translations/uk.js";
|
|
22
|
+
import { zh } from "../translations/zh.js";
|
|
23
|
+
import { bundles } from "../translations/index.js";
|
|
24
|
+
import { formatCalc } from "../calc/formatCalc.js";
|
|
12
25
|
import { COUNTRIES, US_STATES } from "../fields/data/regions.js";
|
|
13
26
|
import { toFormDocument } from "../form/toFormDocument.js";
|
|
14
27
|
import { valuesFromSearchParams } from "../prefill/valuesFromSearchParams.js";
|
|
@@ -40,6 +53,7 @@ import { Checkbox } from "../react/primitives/Checkbox.js";
|
|
|
40
53
|
import { Input } from "../react/primitives/Input.js";
|
|
41
54
|
import { uploadFile } from "../react/uploadFile.js";
|
|
42
55
|
import { Select } from "../react/primitives/Select.js";
|
|
56
|
+
import { ChoiceGroup } from "../react/primitives/ChoiceGroup.js";
|
|
43
57
|
import { Textarea } from "../react/primitives/Textarea.js";
|
|
44
58
|
import { defaultRenderers } from "../react/renderers/index.js";
|
|
45
59
|
import { submitForm } from "../react/submitForm.js";
|
|
@@ -48,6 +62,8 @@ import { FormResults } from "../react/FormResults.js";
|
|
|
48
62
|
import { FormSteps } from "../react/FormSteps.js";
|
|
49
63
|
import { fetchFormResults } from "../react/fetchResults.js";
|
|
50
64
|
import { Poll } from "../react/Poll.js";
|
|
65
|
+
import { useCalcValues } from "../react/useCalcValues.js";
|
|
51
66
|
import { useFormState } from "../react/useFormState.js";
|
|
52
67
|
import { useFormStep } from "../react/useFormStep.js";
|
|
53
|
-
|
|
68
|
+
import { clientRuntimeKeys } from "../translations/clientRuntimeKeys.js";
|
|
69
|
+
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, ar, buildRecallResolver, bundles, clientRuntimeKeys, cn, computeCalcFields, de, defaultPresentations, defaultRenderers, defineFieldRenderer, en, es, evaluateCalc, evaluateCondition, fetchFormResults, fieldKey, firstStepId, formatBytes, formatCalc, formatCalcValue, fr, id, interpolate, isTerminalStepId, ko, makeTranslate, pt, resolveNextStepId, resolvePresentations, resolveRenderers, ru, sanitizeUrl, serializeBody, stepFieldNames, submitForm, textOfBody, toFormDocument, uk, uploadFile, useCalcValues, useDismiss, useField, useFocusTrap, useFormContext, useFormState, useFormStep, useScrollLock, valuesFromSearchParams, widthProps, zh };
|
package/dist/exports/rsc.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import { FormContextReference, signFormContext, verifyFormContext } from "../context/formContext.js";
|
|
1
2
|
import { resolveConsentStatements } from "../consent/resolveConsentStatements.js";
|
|
2
3
|
import { toFormDocument } from "../form/toFormDocument.js";
|
|
4
|
+
import { collectionSlugsOf } from "../plugin/collectionSlugs.js";
|
|
5
|
+
import { VotedSubmission, resolveVotedSubmission } from "../submissions/resolveVotedSubmission.js";
|
|
3
6
|
import { isPollClosed } from "../form/pollState.js";
|
|
4
7
|
import { resolveEffectivePollOptions } from "../poll/effectivePollOptions.js";
|
|
5
8
|
import { resolvePollOptions } from "../poll/resolvePollOptions.js";
|
|
6
9
|
import { resolvePollOutcome } from "../poll/resolvePollOutcome.js";
|
|
7
10
|
import { SubmissionAnswers } from "../submissions/SubmissionAnswers.js";
|
|
8
11
|
import { hasVotedCookie, votedCookieName } from "../submissions/votedCookie.js";
|
|
9
|
-
export { SubmissionAnswers, hasVotedCookie, isPollClosed, resolveConsentStatements, resolveEffectivePollOptions, resolvePollOptions, resolvePollOutcome, toFormDocument, votedCookieName };
|
|
12
|
+
export { type FormContextReference, SubmissionAnswers, type VotedSubmission, collectionSlugsOf, hasVotedCookie, isPollClosed, resolveConsentStatements, resolveEffectivePollOptions, resolvePollOptions, resolvePollOutcome, resolveVotedSubmission, signFormContext, toFormDocument, verifyFormContext, votedCookieName };
|
package/dist/exports/rsc.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { collectionSlugsOf } from "../plugin/collectionSlugs.js";
|
|
2
2
|
import { isPollClosed } from "../form/pollState.js";
|
|
3
|
+
import { signFormContext, verifyFormContext } from "../context/formContext.js";
|
|
4
|
+
import { hasVotedCookie, votedCookieName } from "../submissions/votedCookie.js";
|
|
3
5
|
import { resolvePollOptions } from "../poll/resolvePollOptions.js";
|
|
4
|
-
import { resolvePollOutcome } from "../poll/resolvePollOutcome.js";
|
|
5
6
|
import { resolveEffectivePollOptions } from "../poll/effectivePollOptions.js";
|
|
6
|
-
import {
|
|
7
|
+
import { resolveConsentStatements } from "../consent/resolveConsentStatements.js";
|
|
8
|
+
import { resolvePollOutcome } from "../poll/resolvePollOutcome.js";
|
|
7
9
|
import { toFormDocument } from "../form/toFormDocument.js";
|
|
10
|
+
import { resolveVotedSubmission } from "../submissions/resolveVotedSubmission.js";
|
|
8
11
|
import { SubmissionAnswers } from "../submissions/SubmissionAnswers.js";
|
|
9
|
-
export { SubmissionAnswers, hasVotedCookie, isPollClosed, resolveConsentStatements, resolveEffectivePollOptions, resolvePollOptions, resolvePollOutcome, toFormDocument, votedCookieName };
|
|
12
|
+
export { SubmissionAnswers, collectionSlugsOf, hasVotedCookie, isPollClosed, resolveConsentStatements, resolveEffectivePollOptions, resolvePollOptions, resolvePollOutcome, resolveVotedSubmission, 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";
|
|
@@ -11,11 +11,12 @@ import { FormButtonSettings, FormDocument, FormPollSettings, FormResponseSetting
|
|
|
11
11
|
import { FieldTypeOption, FieldTypeRegistry, FieldTypesConfig } from "../fields/registry.js";
|
|
12
12
|
import { PrefillOptions } from "../prefill/valuesFromSearchParams.js";
|
|
13
13
|
import { FormEvent, FormEventSink } from "../events/types.js";
|
|
14
|
+
import { FormBuilderCollectionSlugs } from "../plugin/collectionSlugs.js";
|
|
14
15
|
import { AnyValidationRuleDefinition, ValidationRuleDefinition, ValidationRuleResult } from "../validation/types.js";
|
|
15
16
|
import { PresentationDensity, PresentationDescriptor, PresentationSurface } from "../presentations/types.js";
|
|
16
17
|
import { RecallResolver } from "../recall/resolver.js";
|
|
17
18
|
import { PollOptionSourceOption, PollOptionSourceRegistry, PollOptionSourcesConfig } from "../poll/registry.js";
|
|
18
|
-
import { ActionDefinition, ActionRunArgs, AnyActionDefinition } from "../actions/defineAction.js";
|
|
19
|
+
import { ActionDefinition, ActionRunArgs, ActionValidateArgs, AnyActionDefinition } from "../actions/defineAction.js";
|
|
19
20
|
import { FromAddressOption, FromAddressesResolver } from "../actions/fromAddresses.js";
|
|
20
21
|
import { ActionOption, ActionRegistry, ActionsConfig } from "../actions/registry.js";
|
|
21
22
|
import { ActionResult } from "../actions/runActions.js";
|
|
@@ -33,4 +34,4 @@ import { CaptchaProvider, CaptchaVerifyArgs, IdentifyFn, RateLimitCheckArgs, Rat
|
|
|
33
34
|
import { UploadsOption } from "../plugin/uploadsCollection.js";
|
|
34
35
|
import { ValidationRuleOption, ValidationRuleRegistry, ValidationRulesConfig } from "../validation/registry.js";
|
|
35
36
|
import { FormBuilderPluginOptions } from "../options.js";
|
|
36
|
-
export type { ActionDefinition, ActionOption, ActionRegistry, ActionResult, ActionRunArgs, ActionsConfig, AggregateFieldResponsesArgs, AggregateFormResponsesArgs, AggregationBucket, AggregationRow, AnyActionDefinition, AnyFormFieldDefinition, AnyValidationRuleDefinition, ButtonFieldsOverride, ButtonsOption, CalcExpression, CaptchaProvider, CaptchaVerifyArgs, CollectionOverrides, ConsentProof, ConsentSourceEntry, ConsentSourceOption, ConsentSourcePage, ConsentSourcesFieldOptions, ConsentSourcesResolver, ConsentStatement, ConsentStatements, DefaultButtonFields, FieldAggregation, FieldCondition, FieldMeta, FieldTypeOption, FieldTypeRegistry, FieldTypesConfig, FieldsOverride, FileFieldConfig, FileRef, FileRefError, FlowStep, FlowTransition, FormBuilderPluginOptions, FormButtonSettings, FormDocument, FormEvent, FormEventSink, FormFieldDefinition, FormFieldFormat, FormFieldInstance, FormFieldValidate, FormFieldValueKind, FormFlow, FormPollSettings, FormResponseSettings, FormResultsAccess, FormResultsAccessArgs, FromAddressOption, FromAddressesResolver, IdentifyFn, OmittableSharedField, PollOptionSourceOption, PollOptionSourceRegistry, PollOptionSourcesConfig, PrefillOptions, PresentationDensity, PresentationDescriptor, PresentationSurface, RateLimitCheckArgs, RateLimitConfig, RateLimitResult, RateLimiter, RecallResolver, ResolveConsentEntriesArgs, ResolveConsentSourcesRequestArgs, ResolveConsentSourcesRequestResult, ResolveConsentStatementsArgs, ResolvePublishedVersionRefArgs, ResolveResultsRequestArgs, ResolveResultsRequestResult, RichTextBodyOption, SpamConfig, SpamMetadataConfig, SpamOption, SubmissionDescriptor, SubmissionFieldError, SubmissionStatusFilter, SubmissionValue, SubmissionWidth, UploadsOption, ValidationRuleDefinition, ValidationRuleOption, ValidationRuleRegistry, ValidationRuleResult, ValidationRulesConfig };
|
|
37
|
+
export type { ActionDefinition, ActionOption, ActionRegistry, ActionResult, ActionRunArgs, ActionValidateArgs, ActionsConfig, AggregateFieldResponsesArgs, AggregateFormResponsesArgs, AggregationBucket, AggregationRow, AnyActionDefinition, AnyFormFieldDefinition, AnyValidationRuleDefinition, ButtonFieldsOverride, ButtonsOption, CalcExpression, CaptchaProvider, CaptchaVerifyArgs, CollectionOverrides, ConsentProof, ConsentSourceEntry, ConsentSourceOption, ConsentSourcePage, ConsentSourcesFieldOptions, ConsentSourcesResolver, ConsentStatement, ConsentStatements, DefaultButtonFields, FieldAggregation, FieldCondition, FieldMeta, FieldTypeOption, FieldTypeRegistry, FieldTypesConfig, FieldsOverride, FileFieldConfig, FileRef, FileRefError, FlowStep, FlowTransition, FormBuilderCollectionSlugs, FormBuilderPluginOptions, FormButtonSettings, FormDocument, FormEvent, FormEventSink, FormFieldDefinition, FormFieldFormat, FormFieldInstance, FormFieldValidate, FormFieldValueKind, FormFlow, FormPollSettings, FormResponseSettings, FormResultsAccess, FormResultsAccessArgs, FromAddressOption, FromAddressesResolver, IdentifyFn, OmittableSharedField, PollOptionSourceOption, PollOptionSourceRegistry, PollOptionSourcesConfig, PrefillOptions, PresentationDensity, PresentationDescriptor, PresentationSurface, RateLimitCheckArgs, RateLimitConfig, RateLimitResult, RateLimiter, RecallResolver, ResolveConsentEntriesArgs, ResolveConsentSourcesRequestArgs, ResolveConsentSourcesRequestResult, ResolveConsentStatementsArgs, ResolvePublishedVersionRefArgs, ResolveResultsRequestArgs, ResolveResultsRequestResult, RichTextBodyOption, SpamConfig, SpamMetadataConfig, SpamOption, SubmissionDescriptor, SubmissionFieldError, SubmissionStatusFilter, SubmissionValue, SubmissionWidth, UploadsOption, ValidationRuleDefinition, ValidationRuleOption, ValidationRuleRegistry, ValidationRuleResult, ValidationRulesConfig };
|
|
@@ -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
|
|
@@ -1,144 +1,87 @@
|
|
|
1
1
|
import { keys } from "../../translations/keys.js";
|
|
2
2
|
import { asTranslate, labelFor } from "../../translations/server.js";
|
|
3
|
-
import {
|
|
3
|
+
import { localizedIf } from "../localizedIf.js";
|
|
4
|
+
import { formatCalcValue } from "../../calc/formatCalcValue.js";
|
|
4
5
|
import { normalizeCalc } from "../../calc/normalizeCalc.js";
|
|
5
6
|
import { defineFormField } from "../defineFormField.js";
|
|
6
7
|
//#region src/fields/builtin/calculation.ts
|
|
8
|
+
const CALC_SCHEMA_URI = "https://10xmedia.de/schemas/form-builder/calc-expression.json";
|
|
7
9
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* `validateExpression`/`normalizeCalc`; this schema is a convenience, not the source of truth.
|
|
10
|
+
* Validates the calculation field's `expression` against the registered extension names: unset/empty
|
|
11
|
+
* is fine, otherwise it must normalize into a well-formed `CalcExpression` tree.
|
|
11
12
|
*/
|
|
12
|
-
const
|
|
13
|
-
uri: "https://10xmedia.de/schemas/form-builder/calc-expression.json",
|
|
14
|
-
fileMatch: ["https://10xmedia.de/schemas/form-builder/calc-expression.json"],
|
|
15
|
-
schema: {
|
|
16
|
-
$ref: "#/definitions/expr",
|
|
17
|
-
definitions: {
|
|
18
|
-
expr: { oneOf: [
|
|
19
|
-
{ $ref: "#/definitions/lit" },
|
|
20
|
-
{ $ref: "#/definitions/ref" },
|
|
21
|
-
{ $ref: "#/definitions/op" },
|
|
22
|
-
{ $ref: "#/definitions/neg" },
|
|
23
|
-
{ $ref: "#/definitions/fn" },
|
|
24
|
-
{ $ref: "#/definitions/weight" }
|
|
25
|
-
] },
|
|
26
|
-
lit: {
|
|
27
|
-
type: "object",
|
|
28
|
-
properties: {
|
|
29
|
-
type: { enum: ["lit"] },
|
|
30
|
-
value: { type: "number" }
|
|
31
|
-
},
|
|
32
|
-
required: ["type", "value"],
|
|
33
|
-
additionalProperties: false
|
|
34
|
-
},
|
|
35
|
-
ref: {
|
|
36
|
-
type: "object",
|
|
37
|
-
properties: {
|
|
38
|
-
type: { enum: ["ref"] },
|
|
39
|
-
field: { type: "string" }
|
|
40
|
-
},
|
|
41
|
-
required: ["type", "field"],
|
|
42
|
-
additionalProperties: false
|
|
43
|
-
},
|
|
44
|
-
op: {
|
|
45
|
-
type: "object",
|
|
46
|
-
properties: {
|
|
47
|
-
type: { enum: ["op"] },
|
|
48
|
-
op: { enum: [...CALC_OPS] },
|
|
49
|
-
left: { $ref: "#/definitions/expr" },
|
|
50
|
-
right: { $ref: "#/definitions/expr" }
|
|
51
|
-
},
|
|
52
|
-
required: [
|
|
53
|
-
"type",
|
|
54
|
-
"op",
|
|
55
|
-
"left",
|
|
56
|
-
"right"
|
|
57
|
-
],
|
|
58
|
-
additionalProperties: false
|
|
59
|
-
},
|
|
60
|
-
neg: {
|
|
61
|
-
type: "object",
|
|
62
|
-
properties: {
|
|
63
|
-
type: { enum: ["neg"] },
|
|
64
|
-
operand: { $ref: "#/definitions/expr" }
|
|
65
|
-
},
|
|
66
|
-
required: ["type", "operand"],
|
|
67
|
-
additionalProperties: false
|
|
68
|
-
},
|
|
69
|
-
fn: {
|
|
70
|
-
type: "object",
|
|
71
|
-
properties: {
|
|
72
|
-
type: { enum: ["fn"] },
|
|
73
|
-
fn: { enum: [...CALC_FNS] },
|
|
74
|
-
args: {
|
|
75
|
-
type: "array",
|
|
76
|
-
items: { $ref: "#/definitions/expr" }
|
|
77
|
-
}
|
|
78
|
-
},
|
|
79
|
-
required: [
|
|
80
|
-
"type",
|
|
81
|
-
"fn",
|
|
82
|
-
"args"
|
|
83
|
-
],
|
|
84
|
-
additionalProperties: false
|
|
85
|
-
},
|
|
86
|
-
weight: {
|
|
87
|
-
type: "object",
|
|
88
|
-
properties: {
|
|
89
|
-
type: { enum: ["weight"] },
|
|
90
|
-
field: { type: "string" },
|
|
91
|
-
weights: {
|
|
92
|
-
type: "object",
|
|
93
|
-
additionalProperties: { type: "number" }
|
|
94
|
-
}
|
|
95
|
-
},
|
|
96
|
-
required: [
|
|
97
|
-
"type",
|
|
98
|
-
"field",
|
|
99
|
-
"weights"
|
|
100
|
-
],
|
|
101
|
-
additionalProperties: false
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
|
-
/**
|
|
107
|
-
* Validates the calculation field's `expression`: unset/empty is fine, otherwise it must
|
|
108
|
-
* normalize into a well-formed `CalcExpression` tree. Exported for unit testing.
|
|
109
|
-
*/
|
|
110
|
-
const validateExpression = (value, { req }) => {
|
|
13
|
+
const buildValidateExpression = (allowed) => (value, { req }) => {
|
|
111
14
|
if (value == null || value === "") return true;
|
|
112
|
-
return normalizeCalc(value) !== void 0 ? true : asTranslate(req.t)(keys.validationCalcExpressionInvalid);
|
|
15
|
+
return normalizeCalc(value, allowed) !== void 0 ? true : asTranslate(req.t)(keys.validationCalcExpressionInvalid);
|
|
113
16
|
};
|
|
114
17
|
/**
|
|
115
18
|
* A calculation is derived and read-only: it renders disabled with no text affordance (no
|
|
116
19
|
* `placeholder`), and it is never validated (`runSubmission` stores its computed value and skips
|
|
117
20
|
* `runValidation` entirely), so an authored `required` could never fire. Both are omitted rather
|
|
118
|
-
* than offered as settings that do nothing.
|
|
21
|
+
* than offered as settings that do nothing. `allowed` threads the registered calc extension names
|
|
22
|
+
* (plugin option `calc`) into the expression validate; `extras.sources`
|
|
23
|
+
* carries serializable source metadata to the builder component as clientProps (custom function
|
|
24
|
+
* names travel too, so the client-side normalize accepts every expression the server accepts).
|
|
119
25
|
*/
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
}
|
|
26
|
+
const buildCalculationField = (allowed, extras) => {
|
|
27
|
+
const sources = extras?.sources ?? [];
|
|
28
|
+
const functions = [...allowed?.functions ?? []];
|
|
29
|
+
const builderRef = "@10x-media/form-builder/client#CalcExpressionBuilder";
|
|
30
|
+
return defineFormField({
|
|
31
|
+
type: "calculation",
|
|
32
|
+
label: keys.fieldTypeCalculation,
|
|
33
|
+
value: "number",
|
|
34
|
+
omitShared: ["placeholder", "required"],
|
|
35
|
+
config: [
|
|
36
|
+
{
|
|
37
|
+
name: "expression",
|
|
38
|
+
type: "json",
|
|
39
|
+
label: labelFor(keys.configExpression),
|
|
40
|
+
admin: { components: { Field: sources.length > 0 || functions.length > 0 ? {
|
|
41
|
+
path: builderRef,
|
|
42
|
+
clientProps: {
|
|
43
|
+
sources,
|
|
44
|
+
functions
|
|
45
|
+
}
|
|
46
|
+
} : builderRef } },
|
|
47
|
+
jsonSchema: {
|
|
48
|
+
uri: CALC_SCHEMA_URI,
|
|
49
|
+
fileMatch: [CALC_SCHEMA_URI],
|
|
50
|
+
schema: { type: "object" }
|
|
51
|
+
},
|
|
52
|
+
validate: buildValidateExpression(allowed)
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: "calcDisplay",
|
|
56
|
+
type: "checkbox",
|
|
57
|
+
defaultValue: true,
|
|
58
|
+
label: labelFor(keys.configCalcDisplay)
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: "decimals",
|
|
62
|
+
type: "number",
|
|
63
|
+
min: 0,
|
|
64
|
+
max: 6,
|
|
65
|
+
label: labelFor(keys.calcConfigDecimals)
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: "prefix",
|
|
69
|
+
type: "text",
|
|
70
|
+
label: labelFor(keys.calcConfigPrefix),
|
|
71
|
+
...localizedIf(extras?.localize === true)
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
name: "suffix",
|
|
75
|
+
type: "text",
|
|
76
|
+
label: labelFor(keys.calcConfigSuffix),
|
|
77
|
+
...localizedIf(extras?.localize === true)
|
|
78
|
+
}
|
|
79
|
+
],
|
|
80
|
+
format: ({ value, config }) => value == null ? "" : formatCalcValue(value, config)
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
buildCalculationField();
|
|
141
84
|
//#endregion
|
|
142
|
-
export {
|
|
85
|
+
export { buildCalculationField };
|
|
143
86
|
|
|
144
87
|
//# sourceMappingURL=calculation.js.map
|