@10x-media/form-builder 0.1.0-beta.2 → 0.1.0-beta.21
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 +360 -0
- package/README.md +7 -5
- package/dist/actions/assertNoBlockCollision.js +18 -0
- package/dist/actions/assertNoBlockCollision.js.map +1 -0
- package/dist/actions/body/converters.d.ts +20 -0
- package/dist/actions/body/converters.js +57 -0
- package/dist/actions/body/converters.js.map +1 -0
- package/dist/actions/body/escapeHtml.d.ts +6 -0
- package/dist/actions/body/escapeHtml.js +14 -0
- package/dist/actions/body/escapeHtml.js.map +1 -0
- package/dist/actions/body/serializeBody.d.ts +55 -0
- package/dist/actions/body/serializeBody.js +78 -0
- package/dist/actions/body/serializeBody.js.map +1 -0
- package/dist/actions/body/serializeSlate.js +31 -0
- package/dist/actions/body/serializeSlate.js.map +1 -0
- package/dist/actions/body/textOfBody.d.ts +13 -0
- package/dist/actions/body/textOfBody.js +35 -0
- package/dist/actions/body/textOfBody.js.map +1 -0
- package/dist/actions/body/wildcards.d.ts +10 -0
- package/dist/actions/body/wildcards.js +33 -0
- package/dist/actions/body/wildcards.js.map +1 -0
- package/dist/actions/buildActionBlocks.js +12 -9
- package/dist/actions/buildActionBlocks.js.map +1 -1
- package/dist/actions/builtin/confirmation.js +47 -43
- package/dist/actions/builtin/confirmation.js.map +1 -1
- package/dist/actions/builtin/emailAction.d.ts +20 -0
- package/dist/actions/builtin/emailAction.js +120 -0
- package/dist/actions/builtin/emailAction.js.map +1 -0
- package/dist/actions/builtin/emailTeam.js +20 -38
- package/dist/actions/builtin/emailTeam.js.map +1 -1
- package/dist/actions/builtin/index.d.ts +16 -1
- package/dist/actions/builtin/index.js +21 -7
- package/dist/actions/builtin/index.js.map +1 -1
- package/dist/actions/builtin/signedWebhook.js +6 -2
- package/dist/actions/builtin/signedWebhook.js.map +1 -1
- package/dist/actions/defineAction.d.ts +17 -5
- package/dist/actions/defineAction.js.map +1 -1
- package/dist/actions/dispatch.js +51 -6
- package/dist/actions/dispatch.js.map +1 -1
- package/dist/actions/dispatchContext.js +13 -0
- package/dist/actions/dispatchContext.js.map +1 -0
- package/dist/actions/emailRecipients.d.ts +12 -0
- package/dist/actions/emailRecipients.js +146 -0
- package/dist/actions/emailRecipients.js.map +1 -0
- package/dist/actions/fromAddresses.d.ts +37 -0
- package/dist/actions/fromAddresses.js +131 -0
- package/dist/actions/fromAddresses.js.map +1 -0
- 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/registry.d.ts +2 -1
- package/dist/actions/registry.js +5 -7
- package/dist/actions/registry.js.map +1 -1
- package/dist/actions/runActions.js +10 -1
- package/dist/actions/runActions.js.map +1 -1
- package/dist/actions/task.js +47 -16
- package/dist/actions/task.js.map +1 -1
- package/dist/aggregation/aggregateResponses.d.ts +9 -0
- package/dist/aggregation/aggregateResponses.js +8 -14
- package/dist/aggregation/aggregateResponses.js.map +1 -1
- package/dist/aggregation/resolveResultsRequest.d.ts +41 -6
- package/dist/aggregation/resolveResultsRequest.js +97 -11
- package/dist/aggregation/resolveResultsRequest.js.map +1 -1
- package/dist/calc/computeCalcFields.d.ts +5 -3
- package/dist/calc/computeCalcFields.js +6 -4
- package/dist/calc/computeCalcFields.js.map +1 -1
- package/dist/calc/evaluate.d.ts +26 -3
- package/dist/calc/evaluate.js +34 -13
- 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 +42 -33
- 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 +25 -4
- package/dist/calc/types.js +23 -0
- package/dist/calc/types.js.map +1 -0
- package/dist/client/ByteSizeField.d.ts +29 -0
- package/dist/client/ByteSizeField.js +58 -0
- package/dist/client/ByteSizeField.js.map +1 -0
- 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/ClosePollButton.d.ts +15 -0
- package/dist/client/ClosePollButton.js +80 -0
- package/dist/client/ClosePollButton.js.map +1 -0
- package/dist/client/CondensedArray.d.ts +15 -0
- package/dist/client/CondensedArray.js +97 -0
- package/dist/client/CondensedArray.js.map +1 -0
- package/dist/client/ConditionBuilder.js +2 -1
- package/dist/client/ConditionBuilder.js.map +1 -1
- package/dist/client/ConsentBlockLabel.d.ts +15 -0
- package/dist/client/ConsentBlockLabel.js +71 -0
- package/dist/client/ConsentBlockLabel.js.map +1 -0
- package/dist/client/ConsentSourceRowLabel.d.ts +9 -0
- package/dist/client/ConsentSourceRowLabel.js +21 -0
- package/dist/client/ConsentSourceRowLabel.js.map +1 -0
- package/dist/client/EndpointOptionsSelect.d.ts +55 -0
- package/dist/client/EndpointOptionsSelect.js +112 -0
- package/dist/client/EndpointOptionsSelect.js.map +1 -0
- package/dist/client/FieldBlockLabel.d.ts +18 -0
- package/dist/client/FieldBlockLabel.js +34 -0
- package/dist/client/FieldBlockLabel.js.map +1 -0
- package/dist/client/FieldNameSelect.d.ts +37 -0
- package/dist/client/FieldNameSelect.js +72 -0
- package/dist/client/FieldNameSelect.js.map +1 -0
- package/dist/client/FlowBuilder.d.ts +2 -2
- package/dist/client/FlowBuilder.js +137 -88
- package/dist/client/FlowBuilder.js.map +1 -1
- package/dist/client/FormConditionField.js +1 -4
- package/dist/client/FormConditionField.js.map +1 -1
- package/dist/client/RecipientsSelect.d.ts +37 -0
- package/dist/client/RecipientsSelect.js +197 -0
- package/dist/client/RecipientsSelect.js.map +1 -0
- package/dist/client/RuleDescription.d.ts +21 -0
- package/dist/client/RuleDescription.js +19 -0
- package/dist/client/RuleDescription.js.map +1 -0
- package/dist/client/admin.css +557 -0
- package/dist/client/endpointOptions.d.ts +11 -0
- package/dist/client/endpointOptions.js +38 -0
- package/dist/client/endpointOptions.js.map +1 -0
- package/dist/client/flowAuthoring.js +142 -0
- package/dist/client/flowAuthoring.js.map +1 -0
- package/dist/client/synthesizeClientField.js +21 -10
- package/dist/client/synthesizeClientField.js.map +1 -1
- package/dist/client/toStaticLabel.js +13 -0
- package/dist/client/toStaticLabel.js.map +1 -0
- package/dist/collections/buttonFields.d.ts +34 -0
- package/dist/collections/buttonFields.js +35 -0
- package/dist/collections/buttonFields.js.map +1 -0
- package/dist/collections/cells/FieldCountCell.d.ts +15 -0
- package/dist/collections/cells/FieldCountCell.js +18 -0
- package/dist/collections/cells/FieldCountCell.js.map +1 -0
- package/dist/collections/cells/FlowStepsCell.d.ts +14 -0
- package/dist/collections/cells/FlowStepsCell.js +17 -0
- package/dist/collections/cells/FlowStepsCell.js.map +1 -0
- package/dist/collections/formSubmissions.js +114 -28
- package/dist/collections/formSubmissions.js.map +1 -1
- package/dist/collections/forms.js +449 -112
- package/dist/collections/forms.js.map +1 -1
- package/dist/collections/formsEndpoints.js +106 -0
- package/dist/collections/formsEndpoints.js.map +1 -0
- package/dist/collections/redirectFields.d.ts +29 -0
- 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/conditions/conditionType.js +9 -2
- package/dist/conditions/conditionType.js.map +1 -1
- package/dist/conditions/evaluate.js +1 -1
- package/dist/conditions/evaluate.js.map +1 -1
- package/dist/conditions/fieldTypes.d.ts +3 -1
- package/dist/conditions/fieldTypes.js +4 -1
- package/dist/conditions/fieldTypes.js.map +1 -1
- package/dist/conditions/normalizeConditions.js +20 -6
- package/dist/conditions/normalizeConditions.js.map +1 -1
- package/dist/consent/applyConsentStatements.d.ts +14 -0
- package/dist/consent/applyConsentStatements.js +17 -0
- package/dist/consent/applyConsentStatements.js.map +1 -0
- package/dist/consent/captureConsent.d.ts +39 -11
- package/dist/consent/captureConsent.js +63 -13
- package/dist/consent/captureConsent.js.map +1 -1
- package/dist/consent/consentSourcesField.d.ts +66 -0
- package/dist/consent/consentSourcesField.js +98 -0
- package/dist/consent/consentSourcesField.js.map +1 -0
- package/dist/consent/effectiveStatement.js +16 -0
- package/dist/consent/effectiveStatement.js.map +1 -0
- package/dist/consent/resolveConsentEntries.d.ts +24 -0
- package/dist/consent/resolveConsentEntries.js +40 -0
- package/dist/consent/resolveConsentEntries.js.map +1 -0
- package/dist/consent/resolveConsentSourcesRequest.d.ts +37 -0
- package/dist/consent/resolveConsentSourcesRequest.js +54 -0
- package/dist/consent/resolveConsentSourcesRequest.js.map +1 -0
- package/dist/consent/resolveConsentStatements.d.ts +45 -0
- package/dist/consent/resolveConsentStatements.js +46 -0
- package/dist/consent/resolveConsentStatements.js.map +1 -0
- package/dist/consent/resolvePublishedVersionRef.d.ts +17 -11
- package/dist/consent/resolvePublishedVersionRef.js +13 -10
- package/dist/consent/resolvePublishedVersionRef.js.map +1 -1
- package/dist/consent/types.d.ts +69 -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/departments.d.ts +59 -0
- package/dist/email/departments.js +87 -0
- package/dist/email/departments.js.map +1 -0
- package/dist/email/departmentsField.d.ts +53 -0
- package/dist/email/departmentsField.js +73 -0
- package/dist/email/departmentsField.js.map +1 -0
- package/dist/exports/client.d.ts +14 -1
- package/dist/exports/client.js +14 -1
- package/dist/exports/i18n.d.ts +5 -2
- package/dist/exports/i18n.js +5 -2
- package/dist/exports/react.d.ts +34 -10
- package/dist/exports/react.js +24 -4
- package/dist/exports/rsc.d.ts +10 -1
- package/dist/exports/rsc.js +10 -1
- package/dist/exports/types.d.ts +20 -12
- package/dist/fields/buildFieldBlocks.js +46 -25
- package/dist/fields/buildFieldBlocks.js.map +1 -1
- package/dist/fields/builtin/calculation.d.ts +17 -0
- package/dist/fields/builtin/calculation.js +193 -18
- package/dist/fields/builtin/calculation.js.map +1 -1
- package/dist/fields/builtin/checkbox.js +23 -0
- package/dist/fields/builtin/checkbox.js.map +1 -1
- package/dist/fields/builtin/consent.js +49 -14
- package/dist/fields/builtin/consent.js.map +1 -1
- package/dist/fields/builtin/country.d.ts +13 -0
- package/dist/fields/builtin/country.js +30 -0
- package/dist/fields/builtin/country.js.map +1 -0
- package/dist/fields/builtin/date.js +31 -0
- package/dist/fields/builtin/date.js.map +1 -0
- package/dist/fields/builtin/email.js +8 -1
- package/dist/fields/builtin/email.js.map +1 -1
- package/dist/fields/builtin/file.d.ts +15 -0
- package/dist/fields/builtin/file.js +95 -8
- package/dist/fields/builtin/file.js.map +1 -1
- package/dist/fields/builtin/index.d.ts +30 -0
- package/dist/fields/builtin/index.js +37 -10
- package/dist/fields/builtin/index.js.map +1 -1
- package/dist/fields/builtin/message.js +30 -0
- package/dist/fields/builtin/message.js.map +1 -0
- package/dist/fields/builtin/repeater.js +8 -3
- package/dist/fields/builtin/repeater.js.map +1 -1
- package/dist/fields/builtin/select.js +28 -4
- package/dist/fields/builtin/select.js.map +1 -1
- package/dist/fields/builtin/state.d.ts +13 -0
- package/dist/fields/builtin/state.js +30 -0
- package/dist/fields/builtin/state.js.map +1 -0
- package/dist/fields/builtin/text.js +7 -0
- package/dist/fields/builtin/text.js.map +1 -1
- package/dist/fields/data/regions.d.ts +21 -0
- package/dist/fields/data/regions.js +1238 -0
- package/dist/fields/data/regions.js.map +1 -0
- package/dist/fields/fieldKey.d.ts +15 -0
- package/dist/fields/fieldKey.js +16 -0
- package/dist/fields/fieldKey.js.map +1 -0
- package/dist/fields/fieldNamesOfType.js +30 -0
- package/dist/fields/fieldNamesOfType.js.map +1 -0
- package/dist/fields/instanceOptions.js +20 -0
- package/dist/fields/instanceOptions.js.map +1 -0
- package/dist/fields/localizedIf.d.ts +13 -0
- package/dist/fields/localizedIf.js +12 -0
- package/dist/fields/localizedIf.js.map +1 -0
- package/dist/fields/registry.d.ts +3 -1
- package/dist/fields/registry.js +23 -8
- package/dist/fields/registry.js.map +1 -1
- package/dist/fields/sharedConfig.js +125 -59
- package/dist/fields/sharedConfig.js.map +1 -1
- package/dist/fields/types.d.ts +78 -9
- package/dist/flow/engine.d.ts +6 -4
- package/dist/flow/engine.js +11 -6
- package/dist/flow/engine.js.map +1 -1
- package/dist/flow/normalizeFlow.js +28 -9
- package/dist/flow/normalizeFlow.js.map +1 -1
- package/dist/flow/stepLabel.js +15 -0
- package/dist/flow/stepLabel.js.map +1 -0
- package/dist/flow/types.d.ts +12 -3
- package/dist/flow/types.js +11 -0
- package/dist/flow/types.js.map +1 -0
- package/dist/form/pollState.d.ts +23 -0
- package/dist/form/pollState.js +17 -0
- package/dist/form/pollState.js.map +1 -0
- package/dist/form/toFormDocument.d.ts +110 -0
- package/dist/form/toFormDocument.js +89 -0
- package/dist/form/toFormDocument.js.map +1 -0
- package/dist/form/types.d.ts +73 -0
- package/dist/index.d.ts +67 -61
- package/dist/index.js +120 -25
- package/dist/index.js.map +1 -1
- package/dist/options.d.ts +281 -0
- package/dist/plugin/applyRegistryConfig.d.ts +11 -0
- package/dist/plugin/applyRegistryConfig.js +20 -0
- package/dist/plugin/applyRegistryConfig.js.map +1 -0
- package/dist/plugin/customState.js +26 -0
- package/dist/plugin/customState.js.map +1 -0
- package/dist/plugin/registerCollections.js +43 -40
- package/dist/plugin/registerCollections.js.map +1 -1
- package/dist/plugin/uploadsCollection.d.ts +16 -0
- package/dist/plugin/uploadsCollection.js +53 -0
- package/dist/plugin/uploadsCollection.js.map +1 -0
- package/dist/poll/applyPollOptions.js +18 -0
- package/dist/poll/applyPollOptions.js.map +1 -0
- package/dist/poll/buildPollOptionSourceFields.js +50 -0
- package/dist/poll/buildPollOptionSourceFields.js.map +1 -0
- package/dist/poll/closeJob.d.ts +53 -0
- package/dist/poll/closeJob.js +121 -0
- package/dist/poll/closeJob.js.map +1 -0
- package/dist/poll/definePollOptionSource.d.ts +44 -0
- package/dist/poll/definePollOptionSource.js +6 -0
- package/dist/poll/definePollOptionSource.js.map +1 -0
- package/dist/poll/definePollType.d.ts +34 -0
- package/dist/poll/definePollType.js +6 -0
- package/dist/poll/definePollType.js.map +1 -0
- package/dist/poll/effectivePollOptions.d.ts +38 -0
- package/dist/poll/effectivePollOptions.js +64 -0
- package/dist/poll/effectivePollOptions.js.map +1 -0
- package/dist/poll/mostVoted.d.ts +21 -0
- package/dist/poll/mostVoted.js +32 -0
- package/dist/poll/mostVoted.js.map +1 -0
- package/dist/poll/outcomeBeforeChange.js +91 -0
- package/dist/poll/outcomeBeforeChange.js.map +1 -0
- package/dist/poll/outcomeFields.d.ts +38 -0
- package/dist/poll/outcomeFields.js +52 -0
- package/dist/poll/outcomeFields.js.map +1 -0
- package/dist/poll/pollTypeRegistry.d.ts +34 -0
- package/dist/poll/pollTypeRegistry.js +69 -0
- package/dist/poll/pollTypeRegistry.js.map +1 -0
- package/dist/poll/registry.d.ts +17 -0
- package/dist/poll/registry.js +12 -0
- package/dist/poll/registry.js.map +1 -0
- package/dist/poll/resolvePollCloseRequest.js +106 -0
- package/dist/poll/resolvePollCloseRequest.js.map +1 -0
- package/dist/poll/resolvePollOptions.d.ts +29 -0
- package/dist/poll/resolvePollOptions.js +52 -0
- package/dist/poll/resolvePollOptions.js.map +1 -0
- package/dist/poll/resolvePollOptionsRequest.js +50 -0
- package/dist/poll/resolvePollOptionsRequest.js.map +1 -0
- package/dist/poll/resolvePollOutcome.d.ts +40 -0
- package/dist/poll/resolvePollOutcome.js +90 -0
- package/dist/poll/resolvePollOutcome.js.map +1 -0
- package/dist/poll/resultsField.js +21 -0
- package/dist/poll/resultsField.js.map +1 -0
- package/dist/poll/votes/aggregateFromVotes.d.ts +27 -0
- package/dist/poll/votes/aggregateFromVotes.js +54 -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 +88 -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 +19 -0
- package/dist/poll/votes/votesCollection.js +89 -0
- package/dist/poll/votes/votesCollection.js.map +1 -0
- package/dist/prefill/valuesFromSearchParams.js +5 -9
- package/dist/prefill/valuesFromSearchParams.js.map +1 -1
- package/dist/presentations/types.d.ts +3 -2
- package/dist/react/Form.d.ts +77 -35
- package/dist/react/Form.js +368 -222
- package/dist/react/Form.js.map +1 -1
- package/dist/react/FormContext.d.ts +51 -1
- package/dist/react/FormContext.js.map +1 -1
- package/dist/react/FormControls.d.ts +55 -0
- package/dist/react/FormControls.js +56 -0
- package/dist/react/FormControls.js.map +1 -0
- package/dist/react/FormFields.d.ts +18 -0
- package/dist/react/FormFields.js +114 -0
- package/dist/react/FormFields.js.map +1 -0
- package/dist/react/FormLayout.d.ts +4 -2
- package/dist/react/FormLayout.js +3 -2
- package/dist/react/FormLayout.js.map +1 -1
- package/dist/react/FormResults.d.ts +8 -3
- package/dist/react/FormResults.js +50 -29
- package/dist/react/FormResults.js.map +1 -1
- package/dist/react/FormSteps.d.ts +17 -0
- package/dist/react/FormSteps.js +35 -0
- package/dist/react/FormSteps.js.map +1 -0
- package/dist/react/Poll.d.ts +40 -6
- package/dist/react/Poll.js +137 -33
- 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 +31 -0
- package/dist/react/captcha/HcaptchaCaptcha.js +53 -0
- package/dist/react/captcha/HcaptchaCaptcha.js.map +1 -0
- package/dist/react/captcha/RecaptchaCaptcha.d.ts +44 -0
- package/dist/react/captcha/RecaptchaCaptcha.js +93 -0
- package/dist/react/captcha/RecaptchaCaptcha.js.map +1 -0
- package/dist/react/captcha/TurnstileCaptcha.d.ts +31 -0
- package/dist/react/captcha/TurnstileCaptcha.js +53 -0
- package/dist/react/captcha/TurnstileCaptcha.js.map +1 -0
- package/dist/react/captcha/types.d.ts +8 -0
- package/dist/react/captcha/useCaptchaScript.js +63 -0
- package/dist/react/captcha/useCaptchaScript.js.map +1 -0
- package/dist/react/captcha/vendors.js +8 -0
- package/dist/react/captcha/vendors.js.map +1 -0
- package/dist/react/contract.d.ts +2 -3
- package/dist/react/contract.js.map +1 -1
- package/dist/react/fetchResults.d.ts +1 -1
- package/dist/react/fetchResults.js +1 -1
- package/dist/react/fetchResults.js.map +1 -1
- package/dist/react/presentation/DialogSurface.js +1 -4
- package/dist/react/presentation/DialogSurface.js.map +1 -1
- package/dist/react/primitives/Checkbox.d.ts +6 -2
- package/dist/react/primitives/Checkbox.js +4 -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 +13 -5
- package/dist/react/primitives/FieldShell.js +35 -32
- package/dist/react/primitives/FieldShell.js.map +1 -1
- package/dist/react/primitives/Input.d.ts +4 -2
- package/dist/react/primitives/Input.js +2 -1
- package/dist/react/primitives/Input.js.map +1 -1
- package/dist/react/renderers/calculation.js +7 -5
- package/dist/react/renderers/calculation.js.map +1 -1
- package/dist/react/renderers/checkbox.js +3 -5
- package/dist/react/renderers/checkbox.js.map +1 -1
- package/dist/react/renderers/consent.js +84 -36
- package/dist/react/renderers/consent.js.map +1 -1
- package/dist/react/renderers/date.js +33 -0
- package/dist/react/renderers/date.js.map +1 -0
- package/dist/react/renderers/email.js +4 -5
- package/dist/react/renderers/email.js.map +1 -1
- package/dist/react/renderers/file.js +29 -14
- package/dist/react/renderers/file.js.map +1 -1
- package/dist/react/renderers/index.js +7 -0
- package/dist/react/renderers/index.js.map +1 -1
- package/dist/react/renderers/message.js +41 -0
- package/dist/react/renderers/message.js.map +1 -0
- package/dist/react/renderers/number.js +1 -4
- package/dist/react/renderers/number.js.map +1 -1
- package/dist/react/renderers/region.js +43 -0
- package/dist/react/renderers/region.js.map +1 -0
- package/dist/react/renderers/repeater.js +32 -14
- package/dist/react/renderers/repeater.js.map +1 -1
- package/dist/react/renderers/select.js +21 -6
- package/dist/react/renderers/select.js.map +1 -1
- package/dist/react/renderers/text.js +4 -5
- package/dist/react/renderers/text.js.map +1 -1
- package/dist/react/renderers/textarea.js +1 -4
- package/dist/react/renderers/textarea.js.map +1 -1
- package/dist/react/state.d.ts +46 -3
- package/dist/react/state.js +73 -10
- package/dist/react/state.js.map +1 -1
- package/dist/react/submitForm.js +1 -1
- package/dist/react/submitForm.js.map +1 -1
- package/dist/react/uploadFile.d.ts +2 -2
- package/dist/react/uploadFile.js +1 -1
- package/dist/react/uploadFile.js.map +1 -1
- package/dist/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.d.ts +0 -1
- package/dist/react/useField.js +7 -6
- package/dist/react/useField.js.map +1 -1
- package/dist/react/useFormState.d.ts +1 -1
- package/dist/react/useFormState.js +1 -1
- package/dist/react/useFormState.js.map +1 -1
- package/dist/react/validateField.js +3 -6
- package/dist/react/validateField.js.map +1 -1
- package/dist/recall/interpolate.d.ts +4 -3
- package/dist/recall/interpolate.js +5 -4
- package/dist/recall/interpolate.js.map +1 -1
- package/dist/recall/resolver.d.ts +1 -1
- package/dist/recall/resolver.js +15 -3
- package/dist/recall/resolver.js.map +1 -1
- package/dist/spam/captcha.d.ts +4 -3
- package/dist/spam/captcha.js +4 -3
- package/dist/spam/captcha.js.map +1 -1
- package/dist/spam/clientIp.js +9 -0
- package/dist/spam/clientIp.js.map +1 -0
- package/dist/spam/constants.js +13 -1
- package/dist/spam/constants.js.map +1 -1
- package/dist/spam/identify.js +3 -6
- package/dist/spam/identify.js.map +1 -1
- package/dist/spam/providers/hcaptcha.d.ts +17 -0
- package/dist/spam/providers/hcaptcha.js +18 -0
- package/dist/spam/providers/hcaptcha.js.map +1 -0
- package/dist/spam/providers/recaptcha.d.ts +23 -0
- package/dist/spam/providers/recaptcha.js +23 -0
- package/dist/spam/providers/recaptcha.js.map +1 -0
- package/dist/spam/providers/siteverify.js +34 -0
- package/dist/spam/providers/siteverify.js.map +1 -0
- package/dist/spam/providers/turnstile.d.ts +17 -0
- package/dist/spam/providers/turnstile.js +18 -0
- package/dist/spam/providers/turnstile.js.map +1 -0
- package/dist/spam/resolveSpam.js +2 -1
- package/dist/spam/resolveSpam.js.map +1 -1
- package/dist/spam/spamGuard.js +25 -11
- package/dist/spam/spamGuard.js.map +1 -1
- package/dist/spam/types.d.ts +19 -4
- package/dist/submissions/SubmissionAnswers.js +6 -2
- package/dist/submissions/SubmissionAnswers.js.map +1 -1
- package/dist/submissions/SubmissionAnswersClient.js +100 -64
- package/dist/submissions/SubmissionAnswersClient.js.map +1 -1
- package/dist/submissions/coerceBoolean.js +14 -0
- package/dist/submissions/coerceBoolean.js.map +1 -0
- package/dist/submissions/createSubmission.d.ts +36 -0
- package/dist/submissions/createSubmission.js +26 -0
- package/dist/submissions/createSubmission.js.map +1 -0
- 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.d.ts +10 -0
- package/dist/submissions/runSubmission.js +104 -54
- package/dist/submissions/runSubmission.js.map +1 -1
- package/dist/submissions/types.d.ts +11 -4
- package/dist/submissions/validateSubmission.js +99 -13
- 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/voteChangeEndpoint.js +105 -0
- package/dist/submissions/voteChangeEndpoint.js.map +1 -0
- package/dist/submissions/votedCookie.d.ts +15 -0
- package/dist/submissions/votedCookie.js +74 -0
- package/dist/submissions/votedCookie.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 +380 -0
- package/dist/translations/de.js.map +1 -0
- package/dist/translations/en.js +250 -28
- package/dist/translations/en.js.map +1 -1
- package/dist/translations/index.d.ts +14 -5
- package/dist/translations/index.js +14 -3
- package/dist/translations/index.js.map +1 -1
- package/dist/translations/keys.d.ts +245 -23
- package/dist/translations/keys.js +246 -24
- package/dist/translations/keys.js.map +1 -1
- 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/server.js +8 -1
- package/dist/translations/server.js.map +1 -1
- package/dist/uploads/captureFileRef.d.ts +10 -3
- package/dist/uploads/captureFileRef.js +18 -9
- package/dist/uploads/captureFileRef.js.map +1 -1
- package/dist/uploads/formatBytes.d.ts +9 -0
- package/dist/uploads/formatBytes.js +25 -0
- package/dist/uploads/formatBytes.js.map +1 -0
- package/dist/uploads/resolveFileRef.js +3 -2
- package/dist/uploads/resolveFileRef.js.map +1 -1
- package/dist/uploads/types.d.ts +1 -2
- package/dist/validation/buildRuleBlocks.js +18 -17
- package/dist/validation/buildRuleBlocks.js.map +1 -1
- package/dist/validation/builtin/email.js +2 -1
- package/dist/validation/builtin/email.js.map +1 -1
- package/dist/validation/builtin/index.d.ts +14 -0
- package/dist/validation/builtin/index.js +14 -1
- 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/matchesField.js +3 -7
- package/dist/validation/builtin/matchesField.js.map +1 -1
- package/dist/validation/builtin/max.js +1 -0
- package/dist/validation/builtin/max.js.map +1 -1
- package/dist/validation/builtin/maxDate.js +24 -0
- package/dist/validation/builtin/maxDate.js.map +1 -0
- package/dist/validation/builtin/maxLength.js +1 -0
- package/dist/validation/builtin/maxLength.js.map +1 -1
- package/dist/validation/builtin/min.js +1 -0
- package/dist/validation/builtin/min.js.map +1 -1
- package/dist/validation/builtin/minDate.js +24 -0
- package/dist/validation/builtin/minDate.js.map +1 -0
- package/dist/validation/builtin/minLength.js +1 -0
- package/dist/validation/builtin/minLength.js.map +1 -1
- package/dist/validation/builtin/notAlreadySubmitted.js +5 -1
- package/dist/validation/builtin/notAlreadySubmitted.js.map +1 -1
- package/dist/validation/builtin/oneOf.js +1 -0
- package/dist/validation/builtin/oneOf.js.map +1 -1
- package/dist/validation/builtin/pattern.js +11 -2
- package/dist/validation/builtin/pattern.js.map +1 -1
- package/dist/validation/builtin/url.js +1 -0
- package/dist/validation/builtin/url.js.map +1 -1
- package/dist/validation/builtin/validateDateBound.js +18 -0
- package/dist/validation/builtin/validateDateBound.js.map +1 -0
- package/dist/validation/builtin/validateRegexParams.js +44 -0
- package/dist/validation/builtin/validateRegexParams.js.map +1 -0
- package/dist/validation/emailPattern.js +10 -0
- package/dist/validation/emailPattern.js.map +1 -0
- package/dist/validation/fieldTargetParam.d.ts +22 -0
- package/dist/validation/fieldTargetParam.js +38 -0
- package/dist/validation/fieldTargetParam.js.map +1 -0
- package/dist/validation/registry.d.ts +2 -1
- package/dist/validation/registry.js +2 -9
- package/dist/validation/registry.js.map +1 -1
- package/dist/validation/runValidation.js +8 -29
- package/dist/validation/runValidation.js.map +1 -1
- package/dist/validation/types.d.ts +5 -11
- package/dist/validation/validateUrl.js +22 -0
- package/dist/validation/validateUrl.js.map +1 -0
- package/package.json +14 -6
- package/styles/form-builder.css +94 -190
- package/dist/collections/uploads.d.ts +0 -30
- package/dist/collections/uploads.js +0 -55
- package/dist/collections/uploads.js.map +0 -1
- package/dist/consent/buildConsentSourceConfig.js +0 -49
- package/dist/consent/buildConsentSourceConfig.js.map +0 -1
- package/dist/consent/builtin/index.d.ts +0 -7
- package/dist/consent/builtin/index.js +0 -11
- package/dist/consent/builtin/index.js.map +0 -1
- package/dist/consent/builtin/pageReference.js +0 -75
- package/dist/consent/builtin/pageReference.js.map +0 -1
- package/dist/consent/builtin/static.js +0 -44
- package/dist/consent/builtin/static.js.map +0 -1
- package/dist/consent/defineConsentSource.d.ts +0 -35
- package/dist/consent/defineConsentSource.js +0 -6
- package/dist/consent/defineConsentSource.js.map +0 -1
- package/dist/consent/registry.d.ts +0 -16
- package/dist/consent/registry.js +0 -16
- package/dist/consent/registry.js.map +0 -1
- package/dist/consent/resolveConsentLinks.d.ts +0 -19
- package/dist/consent/resolveConsentLinks.js +0 -26
- package/dist/consent/resolveConsentLinks.js.map +0 -1
- package/dist/presentations/registry.d.ts +0 -15
- package/dist/presentations/registry.js +0 -15
- package/dist/presentations/registry.js.map +0 -1
- package/dist/react/toFormDocument.d.ts +0 -24
- package/dist/react/toFormDocument.js +0 -22
- package/dist/react/toFormDocument.js.map +0 -1
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
import { TranslationsOption } from "./translations/index.js";
|
|
2
|
+
import { RichTextBodyOption } from "./actions/body/serializeBody.js";
|
|
3
|
+
import { ConsentSourcesResolver } from "./consent/types.js";
|
|
4
|
+
import { FieldTypesConfig } from "./fields/registry.js";
|
|
5
|
+
import { FormEventSink } from "./events/types.js";
|
|
6
|
+
import { PollOptionSourcesConfig } from "./poll/registry.js";
|
|
7
|
+
import { RecipientSourceRegistry } from "./actions/recipientSources.js";
|
|
8
|
+
import { FromAddressSourceRegistry, FromAddressesResolver } from "./actions/fromAddresses.js";
|
|
9
|
+
import { ActionsConfig } from "./actions/registry.js";
|
|
10
|
+
import { FormResultsAccess } from "./aggregation/resolveResultsRequest.js";
|
|
11
|
+
import { ButtonsOption } from "./collections/buttonFields.js";
|
|
12
|
+
import { ConsentSnapshotMode } from "./consent/captureConsent.js";
|
|
13
|
+
import { DepartmentEmailsResolver } from "./email/departments.js";
|
|
14
|
+
import { RecipientsConfig } from "./actions/emailRecipients.js";
|
|
15
|
+
import { CalcFunction, CalcSource } from "./calc/registry.js";
|
|
16
|
+
import { ResponseOption } from "./collections/redirectFields.js";
|
|
17
|
+
import { SettingsOption } from "./collections/settingsFields.js";
|
|
18
|
+
import { CollectionOverrides } from "./plugin/collectionOverrides.js";
|
|
19
|
+
import { SpamOption } from "./spam/types.js";
|
|
20
|
+
import { UploadsOption } from "./plugin/uploadsCollection.js";
|
|
21
|
+
import { OutcomeFieldsOverride } from "./poll/outcomeFields.js";
|
|
22
|
+
import { PollTypesConfig } from "./poll/pollTypeRegistry.js";
|
|
23
|
+
import { ValidationRulesConfig } from "./validation/registry.js";
|
|
24
|
+
import { CollectionSlug } from "payload";
|
|
25
|
+
|
|
26
|
+
//#region src/options.d.ts
|
|
27
|
+
type FormBuilderPluginOptions = {
|
|
28
|
+
disabled?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Per-locale overrides for this plugin's UI strings, keyed by the typed
|
|
31
|
+
* translation keys exported from `@10x-media/form-builder/i18n`. Values win
|
|
32
|
+
* over the built-in locales key-by-key; locales the plugin does not ship are
|
|
33
|
+
* added whole. App-level `i18n.translations` still wins over both.
|
|
34
|
+
*/
|
|
35
|
+
translations?: TranslationsOption; /** Pluggable sink for form lifecycle events. Defaults to a no-op; analytics adapters or a future analytics plugin subscribe here. */
|
|
36
|
+
events?: FormEventSink;
|
|
37
|
+
/**
|
|
38
|
+
* Content-bearing author fields (labels, placeholders, option labels, action subjects and
|
|
39
|
+
* bodies) are localized by default. Payload strips the `localized` flag on hosts without
|
|
40
|
+
* `localization` configured, so the default is safe everywhere. Set `false` to keep form
|
|
41
|
+
* content single-locale even on localized hosts. Spread-overrides of the prebuilt default
|
|
42
|
+
* exports (`defaultFieldDefinitionsByType`, `defaultActionDefinitions`) carry `localized`
|
|
43
|
+
* flags from the default-true set; when opting out, derive overrides from
|
|
44
|
+
* `buildDefaultFieldDefinitions(false)` / `buildDefaultActionDefinitions({ localize: false })` instead.
|
|
45
|
+
* Consent statements are unaffected either way: they live on the host's own
|
|
46
|
+
* `consentSourcesField()`, which carries its own `localized` option.
|
|
47
|
+
*/
|
|
48
|
+
localizeContent?: boolean; /** Add, override, or remove field types. `false` removes a built-in, `true` keeps it, an object adds or replaces one. */
|
|
49
|
+
fields?: FieldTypesConfig; /** Add, override, or remove validation rule types. `false` removes a built-in, `true` keeps it, an object adds or replaces one. */
|
|
50
|
+
rules?: ValidationRulesConfig; /** Add, override, or remove post-submit action types. `false` removes a built-in, `true` keeps it, an object adds or replaces one. */
|
|
51
|
+
actions?: ActionsConfig;
|
|
52
|
+
/**
|
|
53
|
+
* Calculation extensions. `sources` registers named value resolvers the calculation field can
|
|
54
|
+
* reference: `resolve` supplies one number per render/submission (a tax rate, a member
|
|
55
|
+
* discount), `resolveWeights` supplies per-option numbers for a chosen field (a product's
|
|
56
|
+
* price per selectable product). Values resolve server-side, ride the form document for the
|
|
57
|
+
* client's live preview, and re-resolve at submit, so the client never supplies them.
|
|
58
|
+
* `functions` registers extra calculation functions; client-side live preview additionally
|
|
59
|
+
* needs the same map passed to the Form component.
|
|
60
|
+
*
|
|
61
|
+
* Resolvers receive an unauthenticated visitor `req` on public reads and submits: never feed
|
|
62
|
+
* data derived from it into access-escalated queries, and gate per-user-sensitive numbers on
|
|
63
|
+
* `req.user`, because resolved values are embedded on every readable form document.
|
|
64
|
+
*/
|
|
65
|
+
calc?: {
|
|
66
|
+
sources?: Record<string, CalcSource>;
|
|
67
|
+
functions?: Record<string, CalcFunction>;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Customize how the plugin's rich text is authored and rendered. `editor` is the default
|
|
71
|
+
* Lexical/richText editor for every plugin richText field (message content, consent
|
|
72
|
+
* statement, response message, action bodies); `bodyEditor` overrides the action body
|
|
73
|
+
* fields and `responseEditor` overrides the success response message field, each falling
|
|
74
|
+
* back to `editor`. `converters` spread over the default
|
|
75
|
+
* Lexical node converters; `serialize` replaces the whole action-body pipeline (e.g. to
|
|
76
|
+
* target chat or plain-text channels instead of email HTML). A custom `serialize` receives
|
|
77
|
+
* the submitted `form` (id/title) and `req`, enabling per-tenant lookups or handing the raw
|
|
78
|
+
* body off to a renderer like react-email.
|
|
79
|
+
*/
|
|
80
|
+
richText?: RichTextBodyOption;
|
|
81
|
+
/**
|
|
82
|
+
* Email routing for the `emailTeam` and `confirmation` actions. Both sub-options are opt-in by the
|
|
83
|
+
* presence of a resolver (not a `false`/`true`/object flag) and share a shape: a `req`-scoped
|
|
84
|
+
* resolver, evaluated per request via an endpoint, whose choice is validated at save time only and
|
|
85
|
+
* never re-checked when the action sends (the config is admin-authored, not visitor-controlled).
|
|
86
|
+
*
|
|
87
|
+
* `fromAddresses` gives both actions a `from` select whose options come from the resolver; absent,
|
|
88
|
+
* neither action has a `from` field and every send uses the email adapter's default sender. The
|
|
89
|
+
* intended use is multi-tenant hosts where each tenant may only send from particular addresses
|
|
90
|
+
* (derive the tenant from `req`, return its allowed senders). Values are the literal string
|
|
91
|
+
* `payload.sendEmail` accepts as `from` (e.g. `'Name <addr@x.com>'` or a plain address).
|
|
92
|
+
*
|
|
93
|
+
* `departments` turns the `emailTeam` `to` into a select whose options come from the resolver
|
|
94
|
+
* (a `/:id/departments` endpoint); the intended use is to place `departmentsField()` on a document
|
|
95
|
+
* you own and read it back with `resolveDepartmentOptions`, which resolves each department's address
|
|
96
|
+
* for the requesting locale. Because `to` is localized, each admin locale stores its own resolved
|
|
97
|
+
* address and a submission's locale selects the address it routes to (Payload-native, no per-send
|
|
98
|
+
* lookup). Storing the resolved address, rather than a department id resolved live at send (consent's
|
|
99
|
+
* model), is deliberate: the routing target a form was saved with stays audit-stable even if the
|
|
100
|
+
* resolver's data later changes, so do not "fix" it into a live lookup. Multi-tenant hosts scope
|
|
101
|
+
* which document they read by the tenant derived from `req`; absent, the recipient fields simply
|
|
102
|
+
* offer no preset department options (still free-typed emails and field tokens).
|
|
103
|
+
*/
|
|
104
|
+
email?: {
|
|
105
|
+
fromAddresses?: FromAddressesResolver;
|
|
106
|
+
/**
|
|
107
|
+
* Senders resolved at send time, offered in the `from` select alongside (and ahead of) the
|
|
108
|
+
* `fromAddresses` literals. Where a literal freezes the address an action was saved with, a
|
|
109
|
+
* source stores its namespaced `value` (e.g. `tenant:default`) and re-resolves the address on
|
|
110
|
+
* every send, so sender identity follows the host: a tenant that changes its from-address
|
|
111
|
+
* changes it for every existing form at once. `resolve` receives the same run-time args as a
|
|
112
|
+
* recipient source (the form, the submission, the request); the form document is the stable
|
|
113
|
+
* tenant handle on the queued path. See {@link FromAddressSource}.
|
|
114
|
+
*/
|
|
115
|
+
fromSources?: FromAddressSourceRegistry;
|
|
116
|
+
departments?: DepartmentEmailsResolver; /** Narrows the recipient fields' behavior (free-typed emails, field tokens). See {@link RecipientsConfig}. */
|
|
117
|
+
recipients?: RecipientsConfig;
|
|
118
|
+
/**
|
|
119
|
+
* Server-resolved recipients, offered in every recipient field as their own option group and
|
|
120
|
+
* resolved to addresses at send time. Each source's `value` is a namespaced string (so it cannot
|
|
121
|
+
* collide with an address); its `resolve` receives the verified form context. See {@link RecipientSource}.
|
|
122
|
+
*/
|
|
123
|
+
recipientSources?: RecipientSourceRegistry;
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* Where the consent statements a form can reference come from. Absent (the default): no sources,
|
|
127
|
+
* so the built-in `consent` field type is not registered at all and authors cannot add a consent
|
|
128
|
+
* field with nothing to reference (a developer-registered custom `consent` type via `fields`
|
|
129
|
+
* still wins).
|
|
130
|
+
*
|
|
131
|
+
* `sources` is an async `req`-scoped resolver returning the sources available to this request.
|
|
132
|
+
* The intended shape: place `consentSourcesField()` on a collection or global you own and read it
|
|
133
|
+
* back here. Multi-tenant hosts scope that read by the tenant derived from `req`, so a tenant's
|
|
134
|
+
* authors only ever see, and their visitors only ever agree to, their own statements. A form
|
|
135
|
+
* stores only a source's row `id`; the statement is resolved live per request (see
|
|
136
|
+
* `resolveConsentStatements`) and the proof is rebuilt from the source at submit, so neither is
|
|
137
|
+
* ever a copy the client could stale or forge.
|
|
138
|
+
*/
|
|
139
|
+
consent?: {
|
|
140
|
+
sources: ConsentSourcesResolver;
|
|
141
|
+
/**
|
|
142
|
+
* What each submission snapshots of the agreed consent wording, for a versioned audit trail.
|
|
143
|
+
* `'both'` (default) stores a `statementHash`, the plain `statementText`, and the source name;
|
|
144
|
+
* `'hash'` keeps only the tamper-evident hash; `'text'` only the readable text; `false` keeps the
|
|
145
|
+
* lean id-only proof. The proof stays id-based regardless; this only adds the wording snapshot.
|
|
146
|
+
*/
|
|
147
|
+
snapshot?: ConsentSnapshotMode;
|
|
148
|
+
/**
|
|
149
|
+
* Whether to resolve each form's consent statements on every read via an afterRead hook (the
|
|
150
|
+
* default, `true`). It attaches `consentStatements` to the form doc so a host can render the
|
|
151
|
+
* wording without a second call, at the cost of one source lookup per form read (N on a list).
|
|
152
|
+
* Set `false` to skip that hook and resolve statements yourself with the exported
|
|
153
|
+
* `resolveConsentStatements` when you render a form; submit-time proof capture is unaffected either
|
|
154
|
+
* way (it always re-resolves from the source).
|
|
155
|
+
*/
|
|
156
|
+
resolveOnRead?: boolean;
|
|
157
|
+
};
|
|
158
|
+
/**
|
|
159
|
+
* Form-level button labels: `submitLabel` at the bottom of the Fields tab, `prevLabel` and
|
|
160
|
+
* `nextLabel` in a row at the bottom of the Flow tab (shown once the flow has a step). The
|
|
161
|
+
* rendered chrome resolves each label as `<Form>` prop, then the stored value, then the
|
|
162
|
+
* translated default. `fields` composes them: it receives the three default fields as a
|
|
163
|
+
* `{ submit, prev, next }` map with the content localization flag already applied and returns
|
|
164
|
+
* the map, so wrapping a default in a row with a host field (e.g. an icon select) or replacing
|
|
165
|
+
* one is explicit. `FormDocument.buttons` reassembles only those three known labels, so a
|
|
166
|
+
* host-added sibling field is still stored but is read off the raw document, not `doc.buttons`.
|
|
167
|
+
*/
|
|
168
|
+
buttons?: ButtonsOption;
|
|
169
|
+
/**
|
|
170
|
+
* Form-level flag fields (`multistep`, `pollEnabled`, `persistSubmissions`), sidebar
|
|
171
|
+
* checkboxes by default. `fields` composes them from the defaults so a host can
|
|
172
|
+
* relocate, wrap, extend, or drop them.
|
|
173
|
+
*/
|
|
174
|
+
settings?: SettingsOption;
|
|
175
|
+
/**
|
|
176
|
+
* The success-response group. `redirect.fields` composes the fields inside the `response.redirect`
|
|
177
|
+
* group, mirroring `buttons.fields`: it receives the default fields (the `url` text field, plus the
|
|
178
|
+
* polymorphic `reference` relationship when `redirectRelationships` is set) and returns the group's
|
|
179
|
+
* final field array, so a host can prepend a custom link field (the pattern most projects already
|
|
180
|
+
* have), swap `url` for their own picker, reorder, or filter. Omit it and the group stays the
|
|
181
|
+
* built-in `url` (+ optional `reference`), unchanged.
|
|
182
|
+
*
|
|
183
|
+
* The plugin's built-in redirect handling reads `redirect.url` (and `redirect.reference` when
|
|
184
|
+
* configured); `toFormDocument` passes the whole `response` group through, so a host that replaces
|
|
185
|
+
* `url` with their own link field owns resolving it to a destination in their frontend, the same as
|
|
186
|
+
* the internal-reference case.
|
|
187
|
+
*/
|
|
188
|
+
response?: ResponseOption;
|
|
189
|
+
/**
|
|
190
|
+
* Collections whose documents `response.redirect` can reference (`response.redirect.reference`),
|
|
191
|
+
* letting an author redirect a visitor to an internal document instead of a URL after a
|
|
192
|
+
* successful submit. Absent (the default): no `reference` field exists at all, matching today's
|
|
193
|
+
* URL-only redirect. Always polymorphic, even for a single slug (a `CollectionSlug[]` array, not
|
|
194
|
+
* a bare `CollectionSlug`), so a host adding a second collection later never changes the stored
|
|
195
|
+
* shape, the same precedent as `consentSourcesField()`'s `page` picker. The plugin never resolves
|
|
196
|
+
* the reference to a URL itself (it has no notion of the host's routing); `toFormDocument` passes
|
|
197
|
+
* the raw `{ relationTo, value }` pair through on `FormDocument.response.redirect.reference` for
|
|
198
|
+
* the host to resolve. Mirrors the `redirectRelationships` option of Payload's native
|
|
199
|
+
* `plugin-form-builder`.
|
|
200
|
+
*/
|
|
201
|
+
redirectRelationships?: CollectionSlug[];
|
|
202
|
+
/**
|
|
203
|
+
* File uploads are bring-your-own. Default `false`: no upload collection is involved and the
|
|
204
|
+
* built-in `file` field type is removed from the registry, so form authors cannot add a field
|
|
205
|
+
* with nowhere to land (a developer-registered custom `file` type via `fields` still wins).
|
|
206
|
+
* `{ collection: 'slug' }` points at a host-owned upload collection (created by the app with
|
|
207
|
+
* its storage adapter); the plugin validates it at boot, appends its hidden `owner` field when
|
|
208
|
+
* absent, and prepends the spam upload hooks.
|
|
209
|
+
*/
|
|
210
|
+
uploads?: UploadsOption; /** Honeypot + rate-limiting (on by default) + a captcha adapter seam + upload-ownership scoping. `false` disables the whole subsystem. */
|
|
211
|
+
spam?: SpamOption;
|
|
212
|
+
/**
|
|
213
|
+
* Aggregate-results endpoint options. `access` gates anonymous reads after the form is loaded
|
|
214
|
+
* and before anything is served; absent keeps the plugin-default gating (poll opt-in +
|
|
215
|
+
* visibility + enumerable-field guard). Multi-tenant hosts should compare `form.tenant` against
|
|
216
|
+
* the tenant derived from `req` so one tenant's poll counts are never readable under another
|
|
217
|
+
* tenant's id. Authenticated callers bypass this seam.
|
|
218
|
+
*/
|
|
219
|
+
results?: {
|
|
220
|
+
access?: FormResultsAccess;
|
|
221
|
+
};
|
|
222
|
+
/**
|
|
223
|
+
* Poll behavior. `votedCookie: true` sets an httpOnly `fb-voted-{formId}=1` cookie on each
|
|
224
|
+
* successful submission to a poll-enabled form, letting SSR hosts read the voted state via
|
|
225
|
+
* `hasVotedCookie` and pass it to `<Poll hasVoted>`. Default `false`.
|
|
226
|
+
* `sources` registers poll option sources (`definePollOptionSource`), letting authors populate
|
|
227
|
+
* a poll's choices from host domain data with stable values; there are no built-ins. With at
|
|
228
|
+
* least one source registered, the forms poll group gains an `optionSource` select plus its
|
|
229
|
+
* per-source `sourceConfig`, and submissions to a sourced poll only accept resolved values.
|
|
230
|
+
* `outcomeFields` composes the poll `outcome` group: it receives the two default fields
|
|
231
|
+
* (`winningValues`, `resolvedAt`) and returns the group's final field array verbatim, so a host
|
|
232
|
+
* can swap `winningValues` for its own component (e.g. a relationship picker over the voteable
|
|
233
|
+
* records). Membership validation runs server-side regardless, so a swap cannot bypass it.
|
|
234
|
+
* `types` registers outcome strategies (`definePollType`) shown in the poll `type` select. The
|
|
235
|
+
* built-ins `manual` (default, hand-picked), `mostVoted` (auto-resolves to the top choice(s) on
|
|
236
|
+
* close), and `source` (delegates to the option source) are always registered; a host entry keyed
|
|
237
|
+
* by (or carrying) a built-in slug replaces it. A closed poll whose strategy is not `manual`
|
|
238
|
+
* auto-resolves via a scheduled job when a runner is present, or on the next results read otherwise.
|
|
239
|
+
*/
|
|
240
|
+
poll?: {
|
|
241
|
+
votedCookie?: boolean;
|
|
242
|
+
sources?: PollOptionSourcesConfig;
|
|
243
|
+
types?: PollTypesConfig;
|
|
244
|
+
outcomeFields?: OutcomeFieldsOverride;
|
|
245
|
+
/**
|
|
246
|
+
* Poll vote tally store (default on). Votes are counted into an append-only hidden
|
|
247
|
+
* collection of aggregate rows at submit time, so results reads are O(options), never
|
|
248
|
+
* truncate, and survive `persistSubmissions: false`. `false` restores scan-based results
|
|
249
|
+
* (and then a persist-off poll is rejected at save). `overrides` opens the tally
|
|
250
|
+
* collection (slug stays `form-poll-votes`).
|
|
251
|
+
*/
|
|
252
|
+
votes?: false | {
|
|
253
|
+
overrides?: CollectionOverrides;
|
|
254
|
+
};
|
|
255
|
+
};
|
|
256
|
+
/**
|
|
257
|
+
* When `true`, the raw `values`, `descriptors`, and `consent` JSON fields are visible in the
|
|
258
|
+
* submission admin view. Default `false`, because the `SubmissionAnswers` UI component already
|
|
259
|
+
* represents those fields fully and they are noisy shown alongside it.
|
|
260
|
+
*/
|
|
261
|
+
showSubmissionRawFields?: boolean;
|
|
262
|
+
/**
|
|
263
|
+
* Override individual plugin-managed collections using explicit spreads. Each key accepts a
|
|
264
|
+
* `CollectionOverrides` object: top-level keys are spread with the plugin's defaults (spread
|
|
265
|
+
* order per key determines who wins), hooks are appended after the plugin's own hooks, and
|
|
266
|
+
* `fields` is a function that receives the default fields and returns the final array so
|
|
267
|
+
* additions/removals are always intentional.
|
|
268
|
+
*/
|
|
269
|
+
overrides?: {
|
|
270
|
+
forms?: CollectionOverrides;
|
|
271
|
+
formSubmissions?: CollectionOverrides;
|
|
272
|
+
};
|
|
273
|
+
};
|
|
274
|
+
declare module 'payload' {
|
|
275
|
+
interface RegisteredPlugins {
|
|
276
|
+
'@10x-media/form-builder': FormBuilderPluginOptions;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
//#endregion
|
|
280
|
+
export { FormBuilderPluginOptions };
|
|
281
|
+
//# sourceMappingURL=options.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/plugin/applyRegistryConfig.d.ts
|
|
2
|
+
/** Any registry entry: an object carrying a string `type` discriminator, keyed by that type. */
|
|
3
|
+
type TypedDefinition = {
|
|
4
|
+
type: string;
|
|
5
|
+
};
|
|
6
|
+
/** Per-type opt-in: `false` removes a type, `true` keeps the seeded default, a definition adds or replaces one. */
|
|
7
|
+
type RegistryOption<T extends TypedDefinition> = boolean | T;
|
|
8
|
+
type RegistryConfig<T extends TypedDefinition> = Record<string, RegistryOption<T>>;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { RegistryConfig };
|
|
11
|
+
//# sourceMappingURL=applyRegistryConfig.d.ts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//#region src/plugin/applyRegistryConfig.ts
|
|
2
|
+
/**
|
|
3
|
+
* Apply a per-type opt-in override map onto a seeded registry, in place. `false` removes the type,
|
|
4
|
+
* `true` keeps whatever default is already seeded (a no-op when none exists), and a definition adds
|
|
5
|
+
* or replaces one with its `type` forced to the config key, so the authored slug (derived from
|
|
6
|
+
* `type`) and the lookup key can never drift apart and silently orphan the entry. Shared by the
|
|
7
|
+
* field-type, validation-rule, action, poll-source, and poll-type registries.
|
|
8
|
+
*/
|
|
9
|
+
const applyRegistryConfig = (registry, config) => {
|
|
10
|
+
for (const [type, option] of Object.entries(config)) if (option === false) registry.delete(type);
|
|
11
|
+
else if (option !== true) registry.set(type, {
|
|
12
|
+
...option,
|
|
13
|
+
type
|
|
14
|
+
});
|
|
15
|
+
return registry;
|
|
16
|
+
};
|
|
17
|
+
//#endregion
|
|
18
|
+
export { applyRegistryConfig };
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=applyRegistryConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"applyRegistryConfig.js","names":[],"sources":["../../src/plugin/applyRegistryConfig.ts"],"sourcesContent":["/** Any registry entry: an object carrying a string `type` discriminator, keyed by that type. */\nexport type TypedDefinition = { type: string }\n\n/** Per-type opt-in: `false` removes a type, `true` keeps the seeded default, a definition adds or replaces one. */\nexport type RegistryOption<T extends TypedDefinition> = boolean | T\n\nexport type RegistryConfig<T extends TypedDefinition> = Record<string, RegistryOption<T>>\n\n/**\n * Apply a per-type opt-in override map onto a seeded registry, in place. `false` removes the type,\n * `true` keeps whatever default is already seeded (a no-op when none exists), and a definition adds\n * or replaces one with its `type` forced to the config key, so the authored slug (derived from\n * `type`) and the lookup key can never drift apart and silently orphan the entry. Shared by the\n * field-type, validation-rule, action, poll-source, and poll-type registries.\n */\nexport const applyRegistryConfig = <T extends TypedDefinition>(\n\tregistry: Map<string, T>,\n\tconfig: RegistryConfig<T>\n): Map<string, T> => {\n\tfor (const [type, option] of Object.entries(config)) {\n\t\tif (option === false) {\n\t\t\tregistry.delete(type)\n\t\t} else if (option !== true) {\n\t\t\tregistry.set(type, { ...option, type })\n\t\t}\n\t}\n\treturn registry\n}\n"],"mappings":";;;;;;;;AAeA,MAAa,uBACZ,UACA,WACoB;CACpB,KAAK,MAAM,CAAC,MAAM,WAAW,OAAO,QAAQ,MAAM,GACjD,IAAI,WAAW,OACd,SAAS,OAAO,IAAI;MACd,IAAI,WAAW,MACrB,SAAS,IAAI,MAAM;EAAE,GAAG;EAAQ;CAAK,CAAC;CAGxC,OAAO;AACR"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//#region src/plugin/customState.ts
|
|
2
|
+
/** Root key under `config.custom` where the plugin stashes runtime state for root-level helpers. */
|
|
3
|
+
const CUSTOM_KEY = "@10x-media/form-builder";
|
|
4
|
+
/**
|
|
5
|
+
* Merge `patch` into the plugin's slice of `config.custom`, leaving every other key untouched.
|
|
6
|
+
* Root-level helpers (`resolvePollOptions`, `resolveConsentStatements`) are called by hosts with a
|
|
7
|
+
* `payload` instance and no plugin state, so the plugin parks what they need on the config at boot
|
|
8
|
+
* and they read it back through `payload.config`. Both readers share one key, so the plugin's slice
|
|
9
|
+
* is patched rather than replaced.
|
|
10
|
+
*/
|
|
11
|
+
const stashCustomState = (custom, patch) => {
|
|
12
|
+
const existing = custom?.[CUSTOM_KEY] != null && typeof custom[CUSTOM_KEY] === "object" ? custom[CUSTOM_KEY] : {};
|
|
13
|
+
return {
|
|
14
|
+
...custom ?? {},
|
|
15
|
+
[CUSTOM_KEY]: {
|
|
16
|
+
...existing,
|
|
17
|
+
...patch
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
/** The plugin's slice of `payload.config.custom`, or an empty object when the plugin never booted. */
|
|
22
|
+
const customStateOf = (payload) => payload.config.custom?.[CUSTOM_KEY] ?? {};
|
|
23
|
+
//#endregion
|
|
24
|
+
export { customStateOf, stashCustomState };
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=customState.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customState.js","names":[],"sources":["../../src/plugin/customState.ts"],"sourcesContent":["import type { Payload } from 'payload'\n\n/** Root key under `config.custom` where the plugin stashes runtime state for root-level helpers. */\nconst CUSTOM_KEY = '@10x-media/form-builder'\n\n/**\n * Merge `patch` into the plugin's slice of `config.custom`, leaving every other key untouched.\n * Root-level helpers (`resolvePollOptions`, `resolveConsentStatements`) are called by hosts with a\n * `payload` instance and no plugin state, so the plugin parks what they need on the config at boot\n * and they read it back through `payload.config`. Both readers share one key, so the plugin's slice\n * is patched rather than replaced.\n */\nexport const stashCustomState = <TState extends Record<string, unknown>>(\n\tcustom: Record<string, unknown> | undefined,\n\tpatch: TState\n): Record<string, unknown> => {\n\tconst existing =\n\t\tcustom?.[CUSTOM_KEY] != null && typeof custom[CUSTOM_KEY] === 'object'\n\t\t\t? (custom[CUSTOM_KEY] as Record<string, unknown>)\n\t\t\t: {}\n\treturn { ...(custom ?? {}), [CUSTOM_KEY]: { ...existing, ...patch } }\n}\n\n/** The plugin's slice of `payload.config.custom`, or an empty object when the plugin never booted. */\nexport const customStateOf = <TState extends Record<string, unknown>>(\n\tpayload: Payload\n): Partial<TState> => (payload.config.custom?.[CUSTOM_KEY] as Partial<TState> | undefined) ?? {}\n"],"mappings":";;AAGA,MAAM,aAAa;;;;;;;;AASnB,MAAa,oBACZ,QACA,UAC6B;CAC7B,MAAM,WACL,SAAS,eAAe,QAAQ,OAAO,OAAO,gBAAgB,WAC1D,OAAO,cACR,CAAC;CACL,OAAO;EAAE,GAAI,UAAU,CAAC;GAAK,aAAa;GAAE,GAAG;GAAU,GAAG;EAAM;CAAE;AACrE;;AAGA,MAAa,iBACZ,YACsB,QAAQ,OAAO,SAAS,eAA+C,CAAC"}
|
|
@@ -1,65 +1,68 @@
|
|
|
1
|
+
import { buildPollVotesCollection } from "../poll/votes/votesCollection.js";
|
|
2
|
+
import { registerPollCloseTask } from "../poll/closeJob.js";
|
|
1
3
|
import { buildFormsCollection } from "../collections/forms.js";
|
|
2
4
|
import { buildSubmissionsCollection } from "../collections/formSubmissions.js";
|
|
3
5
|
import { registerActionsTask } from "../actions/task.js";
|
|
4
|
-
import {
|
|
6
|
+
import { attachUploadsCollection } from "./uploadsCollection.js";
|
|
5
7
|
//#region src/plugin/registerCollections.ts
|
|
6
|
-
const registerCollections = ({ config, registry, ruleRegistry,
|
|
7
|
-
|
|
8
|
+
const registerCollections = ({ config, registry, ruleRegistry, calcAllowed, calcSources, calcFunctions, consentSources, consentSnapshot, consentResolveOnRead, actionRegistry, richText, hasJobsPlugin, events, uploads, spam, showSubmissionRawFields, localizeContent, resultsAccess, votedCookie, pollSourceRegistry, pollTypeRegistry, outcomeFields, pollVotes, buttons, settings, response, fromAddresses, fromSources, departments, redirectRelationships, overrides }) => {
|
|
9
|
+
const pollVotesEnabled = pollVotes !== false;
|
|
10
|
+
registerActionsTask(config, actionRegistry, richText);
|
|
11
|
+
registerPollCloseTask(config, pollVotesEnabled);
|
|
8
12
|
const hasRunner = Boolean(config.jobs?.autoRun) || hasJobsPlugin;
|
|
9
|
-
|
|
10
|
-
if (uploads
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
col.hooks.beforeValidate = [...col.hooks.beforeValidate ?? [], buildUploadOwnerStamp(spam)];
|
|
16
|
-
}
|
|
17
|
-
const ov = overrides?.uploads;
|
|
18
|
-
if (ov) {
|
|
19
|
-
const defaultFields = col.fields ?? [];
|
|
20
|
-
uploadsCollection = {
|
|
21
|
-
...col,
|
|
22
|
-
...ov ?? {},
|
|
23
|
-
access: {
|
|
24
|
-
...col.access ?? {},
|
|
25
|
-
...ov.access ?? {}
|
|
26
|
-
},
|
|
27
|
-
admin: {
|
|
28
|
-
...col.admin ?? {},
|
|
29
|
-
...ov.admin ?? {}
|
|
30
|
-
},
|
|
31
|
-
hooks: {
|
|
32
|
-
...ov.hooks ?? {},
|
|
33
|
-
beforeOperation: [...col.hooks?.beforeOperation ?? [], ...ov.hooks?.beforeOperation ?? []],
|
|
34
|
-
beforeValidate: [...col.hooks?.beforeValidate ?? [], ...ov.hooks?.beforeValidate ?? []]
|
|
35
|
-
},
|
|
36
|
-
fields: ov.fields ? ov.fields({ defaultFields }) : defaultFields
|
|
37
|
-
};
|
|
38
|
-
} else uploadsCollection = col;
|
|
39
|
-
}
|
|
13
|
+
const uploadSlug = uploads === false ? void 0 : uploads.collection;
|
|
14
|
+
if (uploads !== false) attachUploadsCollection({
|
|
15
|
+
config,
|
|
16
|
+
slug: uploads.collection,
|
|
17
|
+
spam
|
|
18
|
+
});
|
|
40
19
|
config.collections = [
|
|
41
20
|
...config.collections ?? [],
|
|
42
|
-
...uploadsCollection ? [uploadsCollection] : [],
|
|
43
21
|
buildFormsCollection({
|
|
44
22
|
registry,
|
|
45
23
|
ruleRegistry,
|
|
46
|
-
|
|
47
|
-
|
|
24
|
+
calcAllowed,
|
|
25
|
+
calcSources,
|
|
26
|
+
consentSources,
|
|
27
|
+
consentResolveOnRead,
|
|
48
28
|
actionRegistry,
|
|
29
|
+
localizeContent,
|
|
30
|
+
richText,
|
|
31
|
+
uploadsCollectionSlug: uploadSlug,
|
|
32
|
+
resultsAccess,
|
|
33
|
+
pollVotesEnabled,
|
|
34
|
+
pollSourceRegistry,
|
|
35
|
+
pollTypeRegistry,
|
|
36
|
+
outcomeFields,
|
|
37
|
+
buttons,
|
|
38
|
+
settings,
|
|
39
|
+
response,
|
|
40
|
+
fromAddresses,
|
|
41
|
+
fromSources,
|
|
42
|
+
departments,
|
|
43
|
+
redirectRelationships,
|
|
49
44
|
overrides: overrides?.forms
|
|
50
45
|
}),
|
|
51
46
|
buildSubmissionsCollection({
|
|
52
47
|
registry,
|
|
53
48
|
ruleRegistry,
|
|
54
|
-
|
|
49
|
+
calcSources,
|
|
50
|
+
calcFunctions,
|
|
51
|
+
consentSources,
|
|
52
|
+
consentSnapshot,
|
|
55
53
|
actionRegistry,
|
|
54
|
+
richText,
|
|
56
55
|
events,
|
|
57
56
|
hasRunner,
|
|
58
|
-
uploadSlug
|
|
57
|
+
uploadSlug,
|
|
59
58
|
spam,
|
|
59
|
+
votedCookie,
|
|
60
|
+
pollSourceRegistry,
|
|
61
|
+
pollVotes,
|
|
60
62
|
showRawFields: showSubmissionRawFields,
|
|
61
63
|
overrides: overrides?.formSubmissions
|
|
62
|
-
})
|
|
64
|
+
}),
|
|
65
|
+
...pollVotes === false ? [] : [buildPollVotesCollection({ overrides: pollVotes.overrides })]
|
|
63
66
|
];
|
|
64
67
|
};
|
|
65
68
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registerCollections.js","names":[],"sources":["../../src/plugin/registerCollections.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"registerCollections.js","names":[],"sources":["../../src/plugin/registerCollections.ts"],"sourcesContent":["import type { CollectionSlug, Config } from 'payload'\nimport type { RichTextBodyOption } from '../actions/body/serializeBody'\nimport type { FromAddressesResolver, FromAddressSourceRegistry } from '../actions/fromAddresses'\nimport type { ActionRegistry } from '../actions/registry'\nimport { registerActionsTask } from '../actions/task'\nimport type { FormResultsAccess } from '../aggregation/resolveResultsRequest'\nimport type { CalcAllowed } from '../calc/normalizeCalc'\nimport type { CalcFunction, CalcSource } from '../calc/registry'\nimport type { ButtonsOption } from '../collections/buttonFields'\nimport { buildSubmissionsCollection } from '../collections/formSubmissions'\nimport { buildFormsCollection } from '../collections/forms'\nimport type { ResponseOption } from '../collections/redirectFields'\nimport type { SettingsOption } from '../collections/settingsFields'\nimport type { ConsentSnapshotMode } from '../consent/captureConsent'\nimport type { ConsentSourcesResolver } from '../consent/types'\nimport type { DepartmentEmailsResolver } from '../email/departments'\nimport type { FormEventSink } from '../events/types'\nimport type { FieldTypeRegistry } from '../fields/registry'\nimport { registerPollCloseTask } from '../poll/closeJob'\nimport type { OutcomeFieldsOverride } from '../poll/outcomeFields'\nimport type { PollTypeRegistry } from '../poll/pollTypeRegistry'\nimport type { PollOptionSourceRegistry } from '../poll/registry'\nimport { buildPollVotesCollection } from '../poll/votes/votesCollection'\nimport type { ResolvedSpamConfig } from '../spam/types'\nimport type { ValidationRuleRegistry } from '../validation/registry'\nimport type { CollectionOverrides } from './collectionOverrides'\nimport { attachUploadsCollection, type UploadsOption } from './uploadsCollection'\n\ntype RegisterCollectionsArgs = {\n\tconfig: Config\n\tregistry: FieldTypeRegistry\n\truleRegistry: ValidationRuleRegistry\n\t/** Registered calc extension names; gates which expressions the forms beforeValidate accepts. */\n\tcalcAllowed?: CalcAllowed\n\t/** Registered calc sources (plugin option `calc.sources`); resolved on form reads and at submit. */\n\tcalcSources?: Record<string, CalcSource>\n\t/** Registered calc functions (plugin option `calc.functions`); threaded into submit-time evaluation. */\n\tcalcFunctions?: Record<string, CalcFunction>\n\tconsentSources?: ConsentSourcesResolver\n\tconsentSnapshot?: ConsentSnapshotMode\n\t/** Plugin `consent.resolveOnRead` (default true); false skips the per-read consent afterRead hook. */\n\tconsentResolveOnRead?: boolean\n\tactionRegistry: ActionRegistry\n\trichText?: RichTextBodyOption\n\thasJobsPlugin: boolean\n\tevents?: FormEventSink\n\tuploads: UploadsOption\n\tspam: ResolvedSpamConfig | false\n\tshowSubmissionRawFields: boolean\n\tlocalizeContent: boolean\n\tresultsAccess?: FormResultsAccess\n\tvotedCookie: boolean\n\tpollSourceRegistry: PollOptionSourceRegistry\n\tpollTypeRegistry: PollTypeRegistry\n\toutcomeFields?: OutcomeFieldsOverride\n\t/** Resolved `poll.votes` option; `false` skips registering the hidden tally collection. */\n\tpollVotes: false | { overrides?: CollectionOverrides }\n\tbuttons?: ButtonsOption\n\tsettings?: SettingsOption\n\tresponse?: ResponseOption\n\tfromAddresses?: FromAddressesResolver\n\tfromSources?: FromAddressSourceRegistry\n\tdepartments?: DepartmentEmailsResolver\n\tredirectRelationships?: CollectionSlug[]\n\toverrides?: {\n\t\tforms?: CollectionOverrides\n\t\tformSubmissions?: CollectionOverrides\n\t}\n}\n\nexport const registerCollections = ({\n\tconfig,\n\tregistry,\n\truleRegistry,\n\tcalcAllowed,\n\tcalcSources,\n\tcalcFunctions,\n\tconsentSources,\n\tconsentSnapshot,\n\tconsentResolveOnRead,\n\tactionRegistry,\n\trichText,\n\thasJobsPlugin,\n\tevents,\n\tuploads,\n\tspam,\n\tshowSubmissionRawFields,\n\tlocalizeContent,\n\tresultsAccess,\n\tvotedCookie,\n\tpollSourceRegistry,\n\tpollTypeRegistry,\n\toutcomeFields,\n\tpollVotes,\n\tbuttons,\n\tsettings,\n\tresponse,\n\tfromAddresses,\n\tfromSources,\n\tdepartments,\n\tredirectRelationships,\n\toverrides,\n}: RegisterCollectionsArgs): void => {\n\tconst pollVotesEnabled = pollVotes !== false\n\tregisterActionsTask(config, actionRegistry, richText)\n\tregisterPollCloseTask(config, pollVotesEnabled)\n\tconst hasRunner = Boolean(config.jobs?.autoRun) || hasJobsPlugin\n\n\tconst uploadSlug = uploads === false ? undefined : uploads.collection\n\tif (uploads !== false) {\n\t\tattachUploadsCollection({ config, slug: uploads.collection, spam })\n\t}\n\n\t// Payload lists nav entries in registration order (no nav-sort option). The primary\n\t// collection leads: forms, then form-submissions. Ordering the plugin's nav group against\n\t// host collections (including a BYO uploads collection) stays a host concern.\n\tconfig.collections = [\n\t\t...(config.collections ?? []),\n\t\tbuildFormsCollection({\n\t\t\tregistry,\n\t\t\truleRegistry,\n\t\t\tcalcAllowed,\n\t\t\tcalcSources,\n\t\t\tconsentSources,\n\t\t\tconsentResolveOnRead,\n\t\t\tactionRegistry,\n\t\t\tlocalizeContent,\n\t\t\trichText,\n\t\t\tuploadsCollectionSlug: uploadSlug,\n\t\t\tresultsAccess,\n\t\t\tpollVotesEnabled,\n\t\t\tpollSourceRegistry,\n\t\t\tpollTypeRegistry,\n\t\t\toutcomeFields,\n\t\t\tbuttons,\n\t\t\tsettings,\n\t\t\tresponse,\n\t\t\tfromAddresses,\n\t\t\tfromSources,\n\t\t\tdepartments,\n\t\t\tredirectRelationships,\n\t\t\toverrides: overrides?.forms,\n\t\t}),\n\t\tbuildSubmissionsCollection({\n\t\t\tregistry,\n\t\t\truleRegistry,\n\t\t\tcalcSources,\n\t\t\tcalcFunctions,\n\t\t\tconsentSources,\n\t\t\tconsentSnapshot,\n\t\t\tactionRegistry,\n\t\t\trichText,\n\t\t\tevents,\n\t\t\thasRunner,\n\t\t\tuploadSlug,\n\t\t\tspam,\n\t\t\tvotedCookie,\n\t\t\tpollSourceRegistry,\n\t\t\tpollVotes,\n\t\t\tshowRawFields: showSubmissionRawFields,\n\t\t\toverrides: overrides?.formSubmissions,\n\t\t}),\n\t\t...(pollVotes === false ? [] : [buildPollVotesCollection({ overrides: pollVotes.overrides })]),\n\t]\n}\n"],"mappings":";;;;;;;AAsEA,MAAa,uBAAuB,EACnC,QACA,UACA,cACA,aACA,aACA,eACA,gBACA,iBACA,sBACA,gBACA,UACA,eACA,QACA,SACA,MACA,yBACA,iBACA,eACA,aACA,oBACA,kBACA,eACA,WACA,SACA,UACA,UACA,eACA,aACA,aACA,uBACA,gBACoC;CACpC,MAAM,mBAAmB,cAAc;CACvC,oBAAoB,QAAQ,gBAAgB,QAAQ;CACpD,sBAAsB,QAAQ,gBAAgB;CAC9C,MAAM,YAAY,QAAQ,OAAO,MAAM,OAAO,KAAK;CAEnD,MAAM,aAAa,YAAY,QAAQ,KAAA,IAAY,QAAQ;CAC3D,IAAI,YAAY,OACf,wBAAwB;EAAE;EAAQ,MAAM,QAAQ;EAAY;CAAK,CAAC;CAMnE,OAAO,cAAc;EACpB,GAAI,OAAO,eAAe,CAAC;EAC3B,qBAAqB;GACpB;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA,uBAAuB;GACvB;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA,WAAW,WAAW;EACvB,CAAC;EACD,2BAA2B;GAC1B;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA,eAAe;GACf,WAAW,WAAW;EACvB,CAAC;EACD,GAAI,cAAc,QAAQ,CAAC,IAAI,CAAC,yBAAyB,EAAE,WAAW,UAAU,UAAU,CAAC,CAAC;CAC7F;AACD"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Config } from "payload";
|
|
2
|
+
|
|
3
|
+
//#region src/plugin/uploadsCollection.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Uploads are bring-your-own: `false` (the default) disables file fields entirely, an object points
|
|
6
|
+
* at a host-owned upload collection (created by the app with its storage adapter of choice).
|
|
7
|
+
* `mimeTypes` optionally constrains the file field's MIME picker for hosts that enforce types by other
|
|
8
|
+
* means than the collection's own `upload.mimeTypes` (which is read automatically when this is absent).
|
|
9
|
+
*/
|
|
10
|
+
type UploadsOption = false | {
|
|
11
|
+
collection: string;
|
|
12
|
+
mimeTypes?: string[];
|
|
13
|
+
};
|
|
14
|
+
//#endregion
|
|
15
|
+
export { UploadsOption };
|
|
16
|
+
//# sourceMappingURL=uploadsCollection.d.ts.map
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { buildUploadOwnerStamp, buildUploadRateLimit } from "../spam/uploadHooks.js";
|
|
2
|
+
//#region src/plugin/uploadsCollection.ts
|
|
3
|
+
/**
|
|
4
|
+
* The MIME types the file field's picker should offer: the host upload collection's own
|
|
5
|
+
* `upload.mimeTypes`, or undefined (no constraint, so the picker keeps its full list). Read at
|
|
6
|
+
* plugin-factory time, before the field registry freezes; `attachUploadsCollection` runs too late.
|
|
7
|
+
*/
|
|
8
|
+
const readUploadCollectionMimeTypes = (config, slug) => {
|
|
9
|
+
const upload = (config.collections?.find((collection) => collection.slug === slug))?.upload;
|
|
10
|
+
return typeof upload === "object" && Array.isArray(upload.mimeTypes) ? upload.mimeTypes : void 0;
|
|
11
|
+
};
|
|
12
|
+
/** Descends presentational rows only: an `owner` field nested in a group/tabs/collapsible is not detected, so a top-level one gets appended alongside it. */
|
|
13
|
+
const hasFieldNamed = (fields, name) => fields.some((field) => {
|
|
14
|
+
if ("name" in field && field.name === name) return true;
|
|
15
|
+
return field.type === "row" && hasFieldNamed(field.fields, name);
|
|
16
|
+
});
|
|
17
|
+
/**
|
|
18
|
+
* Wire the plugin's upload concerns into the host-owned upload collection named by
|
|
19
|
+
* `uploads.collection`. The collection must already exist in `config.collections` and carry an
|
|
20
|
+
* `upload` config; anything else is a plugin misconfiguration and throws at boot. The plugin
|
|
21
|
+
* appends its hidden `owner` text field unless the host already defines a field named `owner`
|
|
22
|
+
* (then that field is reused and must stay a text-compatible identity slot), and prepends the
|
|
23
|
+
* spam upload hooks (rate limit, owner stamp) ahead of the host's own hooks so abuse checks run
|
|
24
|
+
* first. The host entry is replaced with a new object; the host's config is never mutated.
|
|
25
|
+
*/
|
|
26
|
+
const attachUploadsCollection = ({ config, slug, spam }) => {
|
|
27
|
+
const collections = config.collections ?? [];
|
|
28
|
+
const target = collections.find((collection) => collection.slug === slug);
|
|
29
|
+
if (!target) throw new Error(`@10x-media/form-builder: uploads.collection "${slug}" was not found in config.collections. Create an upload-enabled collection (with your storage adapter) and pass its slug, e.g. formBuilder({ uploads: { collection: 'media' } }).`);
|
|
30
|
+
if (!target.upload) throw new Error(`@10x-media/form-builder: uploads.collection "${slug}" has no \`upload\` config. File fields store Payload uploads, so the collection must be an upload collection (set \`upload: true\` or an upload options object on it).`);
|
|
31
|
+
const fields = hasFieldNamed(target.fields, "owner") ? target.fields : [...target.fields, {
|
|
32
|
+
name: "owner",
|
|
33
|
+
type: "text",
|
|
34
|
+
admin: {
|
|
35
|
+
readOnly: true,
|
|
36
|
+
hidden: true
|
|
37
|
+
}
|
|
38
|
+
}];
|
|
39
|
+
const attached = {
|
|
40
|
+
...target,
|
|
41
|
+
fields,
|
|
42
|
+
...spam ? { hooks: {
|
|
43
|
+
...target.hooks ?? {},
|
|
44
|
+
beforeOperation: [buildUploadRateLimit(spam), ...target.hooks?.beforeOperation ?? []],
|
|
45
|
+
beforeValidate: [buildUploadOwnerStamp(spam), ...target.hooks?.beforeValidate ?? []]
|
|
46
|
+
} } : {}
|
|
47
|
+
};
|
|
48
|
+
config.collections = collections.map((collection) => collection.slug === slug ? attached : collection);
|
|
49
|
+
};
|
|
50
|
+
//#endregion
|
|
51
|
+
export { attachUploadsCollection, readUploadCollectionMimeTypes };
|
|
52
|
+
|
|
53
|
+
//# sourceMappingURL=uploadsCollection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uploadsCollection.js","names":[],"sources":["../../src/plugin/uploadsCollection.ts"],"sourcesContent":["import type { CollectionConfig, Config, Field } from 'payload'\nimport type { ResolvedSpamConfig } from '../spam/types'\nimport { buildUploadOwnerStamp, buildUploadRateLimit } from '../spam/uploadHooks'\n\n/**\n * Uploads are bring-your-own: `false` (the default) disables file fields entirely, an object points\n * at a host-owned upload collection (created by the app with its storage adapter of choice).\n * `mimeTypes` optionally constrains the file field's MIME picker for hosts that enforce types by other\n * means than the collection's own `upload.mimeTypes` (which is read automatically when this is absent).\n */\nexport type UploadsOption = false | { collection: string; mimeTypes?: string[] }\n\n/**\n * The MIME types the file field's picker should offer: the host upload collection's own\n * `upload.mimeTypes`, or undefined (no constraint, so the picker keeps its full list). Read at\n * plugin-factory time, before the field registry freezes; `attachUploadsCollection` runs too late.\n */\nexport const readUploadCollectionMimeTypes = (\n\tconfig: Config,\n\tslug: string\n): string[] | undefined => {\n\tconst target = config.collections?.find((collection) => collection.slug === slug)\n\tconst upload = target?.upload\n\treturn typeof upload === 'object' && Array.isArray(upload.mimeTypes)\n\t\t? upload.mimeTypes\n\t\t: undefined\n}\n\n/** Descends presentational rows only: an `owner` field nested in a group/tabs/collapsible is not detected, so a top-level one gets appended alongside it. */\nconst hasFieldNamed = (fields: Field[], name: string): boolean =>\n\tfields.some((field) => {\n\t\tif ('name' in field && field.name === name) {\n\t\t\treturn true\n\t\t}\n\t\treturn field.type === 'row' && hasFieldNamed(field.fields, name)\n\t})\n\ntype AttachUploadsCollectionArgs = {\n\tconfig: Config\n\tslug: string\n\tspam: ResolvedSpamConfig | false\n}\n\n/**\n * Wire the plugin's upload concerns into the host-owned upload collection named by\n * `uploads.collection`. The collection must already exist in `config.collections` and carry an\n * `upload` config; anything else is a plugin misconfiguration and throws at boot. The plugin\n * appends its hidden `owner` text field unless the host already defines a field named `owner`\n * (then that field is reused and must stay a text-compatible identity slot), and prepends the\n * spam upload hooks (rate limit, owner stamp) ahead of the host's own hooks so abuse checks run\n * first. The host entry is replaced with a new object; the host's config is never mutated.\n */\nexport const attachUploadsCollection = ({\n\tconfig,\n\tslug,\n\tspam,\n}: AttachUploadsCollectionArgs): void => {\n\tconst collections = config.collections ?? []\n\tconst target = collections.find((collection) => collection.slug === slug)\n\tif (!target) {\n\t\tthrow new Error(\n\t\t\t`@10x-media/form-builder: uploads.collection \"${slug}\" was not found in config.collections. ` +\n\t\t\t\t`Create an upload-enabled collection (with your storage adapter) and pass its slug, ` +\n\t\t\t\t`e.g. formBuilder({ uploads: { collection: 'media' } }).`\n\t\t)\n\t}\n\tif (!target.upload) {\n\t\tthrow new Error(\n\t\t\t`@10x-media/form-builder: uploads.collection \"${slug}\" has no \\`upload\\` config. ` +\n\t\t\t\t`File fields store Payload uploads, so the collection must be an upload collection ` +\n\t\t\t\t`(set \\`upload: true\\` or an upload options object on it).`\n\t\t)\n\t}\n\n\tconst fields = hasFieldNamed(target.fields, 'owner')\n\t\t? target.fields\n\t\t: [\n\t\t\t\t...target.fields,\n\t\t\t\t{ name: 'owner', type: 'text', admin: { readOnly: true, hidden: true } } as Field,\n\t\t\t]\n\n\tconst attached: CollectionConfig = {\n\t\t...target,\n\t\tfields,\n\t\t...(spam\n\t\t\t? {\n\t\t\t\t\thooks: {\n\t\t\t\t\t\t...(target.hooks ?? {}),\n\t\t\t\t\t\tbeforeOperation: [buildUploadRateLimit(spam), ...(target.hooks?.beforeOperation ?? [])],\n\t\t\t\t\t\tbeforeValidate: [buildUploadOwnerStamp(spam), ...(target.hooks?.beforeValidate ?? [])],\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t: {}),\n\t}\n\n\tconfig.collections = collections.map((collection) =>\n\t\tcollection.slug === slug ? attached : collection\n\t)\n}\n"],"mappings":";;;;;;;AAiBA,MAAa,iCACZ,QACA,SAC0B;CAE1B,MAAM,UADS,OAAO,aAAa,MAAM,eAAe,WAAW,SAAS,IAAI,IACzD;CACvB,OAAO,OAAO,WAAW,YAAY,MAAM,QAAQ,OAAO,SAAS,IAChE,OAAO,YACP,KAAA;AACJ;;AAGA,MAAM,iBAAiB,QAAiB,SACvC,OAAO,MAAM,UAAU;CACtB,IAAI,UAAU,SAAS,MAAM,SAAS,MACrC,OAAO;CAER,OAAO,MAAM,SAAS,SAAS,cAAc,MAAM,QAAQ,IAAI;AAChE,CAAC;;;;;;;;;;AAiBF,MAAa,2BAA2B,EACvC,QACA,MACA,WACwC;CACxC,MAAM,cAAc,OAAO,eAAe,CAAC;CAC3C,MAAM,SAAS,YAAY,MAAM,eAAe,WAAW,SAAS,IAAI;CACxE,IAAI,CAAC,QACJ,MAAM,IAAI,MACT,gDAAgD,KAAK,kLAGtD;CAED,IAAI,CAAC,OAAO,QACX,MAAM,IAAI,MACT,gDAAgD,KAAK,wKAGtD;CAGD,MAAM,SAAS,cAAc,OAAO,QAAQ,OAAO,IAChD,OAAO,SACP,CACA,GAAG,OAAO,QACV;EAAE,MAAM;EAAS,MAAM;EAAQ,OAAO;GAAE,UAAU;GAAM,QAAQ;EAAK;CAAE,CACxE;CAEF,MAAM,WAA6B;EAClC,GAAG;EACH;EACA,GAAI,OACD,EACA,OAAO;GACN,GAAI,OAAO,SAAS,CAAC;GACrB,iBAAiB,CAAC,qBAAqB,IAAI,GAAG,GAAI,OAAO,OAAO,mBAAmB,CAAC,CAAE;GACtF,gBAAgB,CAAC,sBAAsB,IAAI,GAAG,GAAI,OAAO,OAAO,kBAAkB,CAAC,CAAE;EACtF,EACD,IACC,CAAC;CACL;CAEA,OAAO,cAAc,YAAY,KAAK,eACrC,WAAW,SAAS,OAAO,WAAW,UACvC;AACD"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region src/poll/applyPollOptions.ts
|
|
2
|
+
/**
|
|
3
|
+
* Replace the options of the field instance named `resultsField` with source-resolved options,
|
|
4
|
+
* without mutating the input. No-op when `resultsField` is unset or matches no instance
|
|
5
|
+
* (nameless bare rows never match), so hand-authored options stay untouched on forms without
|
|
6
|
+
* an option source.
|
|
7
|
+
*/
|
|
8
|
+
const applyPollOptions = (fields, resultsField, options) => {
|
|
9
|
+
if (typeof resultsField !== "string" || resultsField.length === 0) return fields;
|
|
10
|
+
return fields.map((instance) => instance.name === resultsField ? {
|
|
11
|
+
...instance,
|
|
12
|
+
options
|
|
13
|
+
} : instance);
|
|
14
|
+
};
|
|
15
|
+
//#endregion
|
|
16
|
+
export { applyPollOptions };
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=applyPollOptions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"applyPollOptions.js","names":[],"sources":["../../src/poll/applyPollOptions.ts"],"sourcesContent":["import type { PollOption } from './definePollOptionSource'\n\n/**\n * Replace the options of the field instance named `resultsField` with source-resolved options,\n * without mutating the input. No-op when `resultsField` is unset or matches no instance\n * (nameless bare rows never match), so hand-authored options stay untouched on forms without\n * an option source.\n */\nexport const applyPollOptions = <T extends { name?: string }>(\n\tfields: T[],\n\tresultsField: string | null | undefined,\n\toptions: PollOption[]\n): T[] => {\n\tif (typeof resultsField !== 'string' || resultsField.length === 0) {\n\t\treturn fields\n\t}\n\treturn fields.map((instance) =>\n\t\tinstance.name === resultsField ? { ...instance, options } : instance\n\t)\n}\n"],"mappings":";;;;;;;AAQA,MAAa,oBACZ,QACA,cACA,YACS;CACT,IAAI,OAAO,iBAAiB,YAAY,aAAa,WAAW,GAC/D,OAAO;CAER,OAAO,OAAO,KAAK,aAClB,SAAS,SAAS,eAAe;EAAE,GAAG;EAAU;CAAQ,IAAI,QAC7D;AACD"}
|