@10x-media/form-builder 0.1.0-beta.1 → 0.1.0-beta.10
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 +293 -0
- package/README.md +6 -4
- package/dist/actions/body/converters.d.ts +20 -0
- package/dist/actions/body/converters.js +57 -0
- package/dist/actions/body/converters.js.map +1 -0
- package/dist/actions/body/escapeHtml.d.ts +6 -0
- package/dist/actions/body/escapeHtml.js +14 -0
- package/dist/actions/body/escapeHtml.js.map +1 -0
- package/dist/actions/body/serializeBody.d.ts +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 +46 -43
- package/dist/actions/builtin/confirmation.js.map +1 -1
- package/dist/actions/builtin/emailAction.d.ts +17 -0
- package/dist/actions/builtin/emailAction.js +83 -0
- package/dist/actions/builtin/emailAction.js.map +1 -0
- package/dist/actions/builtin/emailTeam.js +14 -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 +5 -4
- package/dist/actions/defineAction.js.map +1 -1
- package/dist/actions/dispatch.js +2 -1
- package/dist/actions/dispatch.js.map +1 -1
- package/dist/actions/emailRecipients.d.ts +12 -0
- package/dist/actions/emailRecipients.js +116 -0
- package/dist/actions/emailRecipients.js.map +1 -0
- package/dist/actions/fromAddresses.d.ts +21 -0
- package/dist/actions/fromAddresses.js +74 -0
- package/dist/actions/fromAddresses.js.map +1 -0
- package/dist/actions/registry.d.ts +2 -1
- package/dist/actions/registry.js +2 -6
- 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 +20 -15
- 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 +35 -6
- package/dist/aggregation/resolveResultsRequest.js +68 -11
- package/dist/aggregation/resolveResultsRequest.js.map +1 -1
- package/dist/calc/computeCalcFields.js +2 -1
- package/dist/calc/computeCalcFields.js.map +1 -1
- package/dist/calc/evaluate.js +1 -2
- package/dist/calc/evaluate.js.map +1 -1
- package/dist/calc/normalizeCalc.js +6 -19
- package/dist/calc/normalizeCalc.js.map +1 -1
- package/dist/calc/types.d.ts +8 -2
- package/dist/calc/types.js +22 -0
- package/dist/calc/types.js.map +1 -0
- package/dist/client/ByteSizeField.d.ts +29 -0
- package/dist/client/ByteSizeField.js +58 -0
- package/dist/client/ByteSizeField.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 +46 -0
- package/dist/client/EndpointOptionsSelect.js +106 -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 +31 -0
- package/dist/client/RecipientsSelect.js +174 -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 +275 -0
- package/dist/client/endpointOptions.js +29 -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 +108 -42
- package/dist/collections/formSubmissions.js.map +1 -1
- package/dist/collections/forms.js +409 -114
- package/dist/collections/forms.js.map +1 -1
- package/dist/collections/formsEndpoints.js +101 -0
- package/dist/collections/formsEndpoints.js.map +1 -0
- package/dist/collections/redirectFields.d.ts +29 -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 +38 -11
- package/dist/consent/captureConsent.js +60 -13
- package/dist/consent/captureConsent.js.map +1 -1
- package/dist/consent/consentSourcesField.d.ts +66 -0
- package/dist/consent/consentSourcesField.js +90 -0
- package/dist/consent/consentSourcesField.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 +44 -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 +61 -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 +13 -1
- package/dist/exports/client.js +13 -1
- package/dist/exports/i18n.d.ts +5 -2
- package/dist/exports/i18n.js +5 -2
- package/dist/exports/react.d.ts +26 -8
- package/dist/exports/react.js +19 -3
- package/dist/exports/rsc.d.ts +8 -1
- package/dist/exports/rsc.js +8 -1
- package/dist/exports/types.d.ts +19 -10
- package/dist/fields/buildFieldBlocks.js +53 -19
- package/dist/fields/buildFieldBlocks.js.map +1 -1
- package/dist/fields/builtin/calculation.js +122 -2
- package/dist/fields/builtin/calculation.js.map +1 -1
- package/dist/fields/builtin/checkbox.js +8 -0
- package/dist/fields/builtin/checkbox.js.map +1 -1
- package/dist/fields/builtin/consent.js +30 -15
- 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 +1 -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 +26 -0
- package/dist/fields/builtin/index.js +30 -6
- 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 +49 -0
- package/dist/fields/builtin/repeater.js.map +1 -0
- package/dist/fields/builtin/select.js +8 -3
- 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/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 +120 -58
- package/dist/fields/sharedConfig.js.map +1 -1
- package/dist/fields/types.d.ts +71 -7
- 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 +22 -0
- package/dist/form/pollState.js +17 -0
- package/dist/form/pollState.js.map +1 -0
- package/dist/form/toFormDocument.d.ts +102 -0
- package/dist/form/toFormDocument.js +87 -0
- package/dist/form/toFormDocument.js.map +1 -0
- package/dist/form/types.d.ts +65 -0
- package/dist/index.d.ts +53 -39
- package/dist/index.js +85 -23
- package/dist/index.js.map +1 -1
- package/dist/options.d.ts +229 -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/collectionOverrides.d.ts +22 -0
- package/dist/plugin/customState.js +26 -0
- package/dist/plugin/customState.js.map +1 -0
- package/dist/plugin/registerCollections.js +40 -20
- 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 +52 -0
- package/dist/poll/closeJob.js +119 -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 +105 -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 +34 -0
- package/dist/poll/resolvePollOutcome.js +76 -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/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 +66 -19
- package/dist/react/Form.js +342 -180
- package/dist/react/Form.js.map +1 -1
- package/dist/react/FormContext.d.ts +44 -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 +6 -3
- package/dist/react/FormResults.js +37 -29
- package/dist/react/FormResults.js.map +1 -1
- package/dist/react/FormSteps.d.ts +17 -0
- package/dist/react/FormSteps.js +35 -0
- package/dist/react/FormSteps.js.map +1 -0
- package/dist/react/Poll.d.ts +17 -6
- package/dist/react/Poll.js +79 -21
- package/dist/react/Poll.js.map +1 -1
- package/dist/react/captcha/HcaptchaCaptcha.d.ts +28 -0
- package/dist/react/captcha/HcaptchaCaptcha.js +53 -0
- package/dist/react/captcha/HcaptchaCaptcha.js.map +1 -0
- package/dist/react/captcha/RecaptchaCaptcha.d.ts +41 -0
- package/dist/react/captcha/RecaptchaCaptcha.js +93 -0
- package/dist/react/captcha/RecaptchaCaptcha.js.map +1 -0
- package/dist/react/captcha/TurnstileCaptcha.d.ts +28 -0
- package/dist/react/captcha/TurnstileCaptcha.js +53 -0
- package/dist/react/captcha/TurnstileCaptcha.js.map +1 -0
- package/dist/react/captcha/types.d.ts +8 -0
- package/dist/react/captcha/useCaptchaScript.js +45 -0
- package/dist/react/captcha/useCaptchaScript.js.map +1 -0
- package/dist/react/captcha/vendors.js +8 -0
- package/dist/react/captcha/vendors.js.map +1 -0
- package/dist/react/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 +4 -2
- package/dist/react/primitives/Checkbox.js +2 -1
- package/dist/react/primitives/Checkbox.js.map +1 -1
- package/dist/react/primitives/FieldShell.d.ts +2 -4
- package/dist/react/primitives/FieldShell.js +12 -19
- package/dist/react/primitives/FieldShell.js.map +1 -1
- package/dist/react/primitives/Input.d.ts +1 -1
- package/dist/react/primitives/Input.js.map +1 -1
- package/dist/react/renderers/calculation.js +1 -4
- package/dist/react/renderers/calculation.js.map +1 -1
- package/dist/react/renderers/checkbox.js +1 -4
- package/dist/react/renderers/checkbox.js.map +1 -1
- package/dist/react/renderers/consent.js +78 -35
- 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 +1 -4
- 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 +9 -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 +131 -0
- package/dist/react/renderers/repeater.js.map +1 -0
- package/dist/react/renderers/select.js +1 -4
- package/dist/react/renderers/select.js.map +1 -1
- package/dist/react/renderers/text.js +1 -4
- 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 +40 -3
- package/dist/react/state.js +64 -9
- package/dist/react/state.js.map +1 -1
- package/dist/react/uploadFile.d.ts +2 -2
- package/dist/react/uploadFile.js +1 -1
- package/dist/react/uploadFile.js.map +1 -1
- package/dist/react/useField.d.ts +0 -1
- package/dist/react/useField.js +6 -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 +14 -2
- 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 +7 -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 +23 -10
- package/dist/spam/spamGuard.js.map +1 -1
- package/dist/spam/types.d.ts +19 -4
- package/dist/submissions/SubmissionAnswers.d.ts +2 -4
- package/dist/submissions/SubmissionAnswers.js +114 -34
- package/dist/submissions/SubmissionAnswers.js.map +1 -1
- package/dist/submissions/SubmissionAnswersClient.js +178 -0
- package/dist/submissions/SubmissionAnswersClient.js.map +1 -0
- 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/runSubmission.d.ts +10 -0
- package/dist/submissions/runSubmission.js +128 -27
- package/dist/submissions/runSubmission.js.map +1 -1
- package/dist/submissions/types.d.ts +12 -4
- package/dist/submissions/validateSubmission.js +62 -11
- package/dist/submissions/validateSubmission.js.map +1 -1
- package/dist/submissions/votedCookie.d.ts +13 -0
- package/dist/submissions/votedCookie.js +27 -0
- package/dist/submissions/votedCookie.js.map +1 -0
- package/dist/translations/clientRuntimeKeys.d.ts +17 -0
- package/dist/translations/clientRuntimeKeys.js +46 -0
- package/dist/translations/clientRuntimeKeys.js.map +1 -0
- package/dist/translations/de.d.ts +12 -0
- package/dist/translations/de.js +309 -0
- package/dist/translations/de.js.map +1 -0
- package/dist/translations/en.js +203 -27
- 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 +199 -23
- package/dist/translations/keys.js +200 -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 +12 -1
- package/dist/validation/builtin/index.js.map +1 -1
- 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 +2 -0
- 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 +9 -30
- 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 +7 -5
- package/styles/form-builder.css +10 -190
- package/dist/collections/uploads.d.ts +0 -29
- package/dist/collections/uploads.js +0 -46
- 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
|
@@ -1,17 +1,23 @@
|
|
|
1
|
-
import { Payload } from "payload";
|
|
1
|
+
import { Payload, PayloadRequest } from "payload";
|
|
2
2
|
|
|
3
3
|
//#region src/consent/resolvePublishedVersionRef.d.ts
|
|
4
|
+
type ResolvePublishedVersionRefArgs = {
|
|
5
|
+
payload: Payload;
|
|
6
|
+
collection: string;
|
|
7
|
+
id: number | string; /** Threaded into `findVersions` so a version written earlier in the same transaction is visible. */
|
|
8
|
+
req?: PayloadRequest;
|
|
9
|
+
};
|
|
4
10
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
11
|
+
* The id of a document's latest published version, or null when nothing is published.
|
|
12
|
+
*
|
|
13
|
+
* Drafts-only, and deliberately not a versions check: `_status` exists only where
|
|
14
|
+
* `versions.drafts` is on (Payload adds the base version fields inside that branch when
|
|
15
|
+
* sanitizing), so on a collection with plain versions and no drafts this query matches nothing and
|
|
16
|
+
* returns null, which is indistinguishable from having no versions at all. Callers must decide the
|
|
17
|
+
* difference themselves with `hasDraftsEnabled` rather than reading null as "no versions" (see
|
|
18
|
+
* `captureConsent`). Never throws.
|
|
7
19
|
*/
|
|
8
|
-
declare const resolvePublishedVersionRef: (
|
|
9
|
-
collection: string;
|
|
10
|
-
id: string | number;
|
|
11
|
-
}) => Promise<{
|
|
12
|
-
versionId: string;
|
|
13
|
-
updatedAt: string;
|
|
14
|
-
} | null>;
|
|
20
|
+
declare const resolvePublishedVersionRef: (args: ResolvePublishedVersionRefArgs) => Promise<string | null>;
|
|
15
21
|
//#endregion
|
|
16
|
-
export { resolvePublishedVersionRef };
|
|
22
|
+
export { ResolvePublishedVersionRefArgs, resolvePublishedVersionRef };
|
|
17
23
|
//# sourceMappingURL=resolvePublishedVersionRef.d.ts.map
|
|
@@ -1,22 +1,25 @@
|
|
|
1
1
|
//#region src/consent/resolvePublishedVersionRef.ts
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
3
|
+
* The id of a document's latest published version, or null when nothing is published.
|
|
4
|
+
*
|
|
5
|
+
* Drafts-only, and deliberately not a versions check: `_status` exists only where
|
|
6
|
+
* `versions.drafts` is on (Payload adds the base version fields inside that branch when
|
|
7
|
+
* sanitizing), so on a collection with plain versions and no drafts this query matches nothing and
|
|
8
|
+
* returns null, which is indistinguishable from having no versions at all. Callers must decide the
|
|
9
|
+
* difference themselves with `hasDraftsEnabled` rather than reading null as "no versions" (see
|
|
10
|
+
* `captureConsent`). Never throws.
|
|
5
11
|
*/
|
|
6
|
-
const resolvePublishedVersionRef = async (
|
|
12
|
+
const resolvePublishedVersionRef = async (args) => {
|
|
7
13
|
try {
|
|
8
|
-
const doc = (await payload.findVersions({
|
|
14
|
+
const doc = (await args.payload.findVersions({
|
|
9
15
|
collection: args.collection,
|
|
10
16
|
where: { and: [{ parent: { equals: args.id } }, { "version._status": { equals: "published" } }] },
|
|
11
17
|
sort: "-updatedAt",
|
|
12
18
|
limit: 1,
|
|
13
|
-
depth: 0
|
|
19
|
+
depth: 0,
|
|
20
|
+
req: args.req
|
|
14
21
|
}))?.docs?.[0];
|
|
15
|
-
|
|
16
|
-
return {
|
|
17
|
-
versionId: String(doc.id),
|
|
18
|
-
updatedAt: String(doc.updatedAt)
|
|
19
|
-
};
|
|
22
|
+
return doc ? String(doc.id) : null;
|
|
20
23
|
} catch {
|
|
21
24
|
return null;
|
|
22
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolvePublishedVersionRef.js","names":[],"sources":["../../src/consent/resolvePublishedVersionRef.ts"],"sourcesContent":["import type { Payload } from 'payload'\n\n
|
|
1
|
+
{"version":3,"file":"resolvePublishedVersionRef.js","names":[],"sources":["../../src/consent/resolvePublishedVersionRef.ts"],"sourcesContent":["import type { Payload, PayloadRequest } from 'payload'\n\nexport type ResolvePublishedVersionRefArgs = {\n\tpayload: Payload\n\tcollection: string\n\tid: number | string\n\t/** Threaded into `findVersions` so a version written earlier in the same transaction is visible. */\n\treq?: PayloadRequest\n}\n\n/**\n * The id of a document's latest published version, or null when nothing is published.\n *\n * Drafts-only, and deliberately not a versions check: `_status` exists only where\n * `versions.drafts` is on (Payload adds the base version fields inside that branch when\n * sanitizing), so on a collection with plain versions and no drafts this query matches nothing and\n * returns null, which is indistinguishable from having no versions at all. Callers must decide the\n * difference themselves with `hasDraftsEnabled` rather than reading null as \"no versions\" (see\n * `captureConsent`). Never throws.\n */\nexport const resolvePublishedVersionRef = async (\n\targs: ResolvePublishedVersionRefArgs\n): Promise<string | null> => {\n\ttry {\n\t\tconst result = await args.payload.findVersions({\n\t\t\tcollection: args.collection as never,\n\t\t\twhere: {\n\t\t\t\tand: [{ parent: { equals: args.id } }, { 'version._status': { equals: 'published' } }],\n\t\t\t},\n\t\t\tsort: '-updatedAt',\n\t\t\tlimit: 1,\n\t\t\tdepth: 0,\n\t\t\treq: args.req,\n\t\t})\n\t\tconst doc = result?.docs?.[0]\n\t\treturn doc ? String(doc.id) : null\n\t} catch {\n\t\treturn null\n\t}\n}\n"],"mappings":";;;;;;;;;;;AAoBA,MAAa,6BAA6B,OACzC,SAC4B;CAC5B,IAAI;EAWH,MAAM,OAAM,MAVS,KAAK,QAAQ,aAAa;GAC9C,YAAY,KAAK;GACjB,OAAO,EACN,KAAK,CAAC,EAAE,QAAQ,EAAE,QAAQ,KAAK,GAAG,EAAE,GAAG,EAAE,mBAAmB,EAAE,QAAQ,YAAY,EAAE,CAAC,EACtF;GACA,MAAM;GACN,OAAO;GACP,OAAO;GACP,KAAK,KAAK;EACX,CAAC,IACmB,OAAO;EAC3B,OAAO,MAAM,OAAO,IAAI,EAAE,IAAI;CAC/B,QAAQ;EACP,OAAO;CACR;AACD"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { PayloadRequest } from "payload";
|
|
2
|
+
|
|
3
|
+
//#region src/consent/types.d.ts
|
|
4
|
+
/** A document reference, kept id-based so renaming or re-slugging the page never breaks it. */
|
|
5
|
+
type ConsentSourcePage = {
|
|
6
|
+
relationTo: string;
|
|
7
|
+
id: number | string;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* One consent source a form author can reference by `id`: the statement the visitor agrees to, and
|
|
11
|
+
* optionally the policy document that statement belongs to. Produced by the host's
|
|
12
|
+
* {@link ConsentSourcesResolver}, normally by mapping the rows of a placed `consentSourcesField()`.
|
|
13
|
+
*
|
|
14
|
+
* `id` is the array row's own auto-assigned identifier, so it survives name edits and reordering
|
|
15
|
+
* and is the stable reference stored on the consent field and in every proof. `statement` is rich
|
|
16
|
+
* text state (the visitor-facing sentence), already resolved for the request's locale by virtue of
|
|
17
|
+
* the resolver reading its own localized field under `req.locale`. `page` drives proof: an id and
|
|
18
|
+
* its collection, never a URL, so the document can be renamed, re-slugged, or re-routed without
|
|
19
|
+
* stranding past proofs. `url` is the visitor-facing link the renderer shows beside the statement;
|
|
20
|
+
* only the host knows how a document id maps to a public route, so the plugin never derives one.
|
|
21
|
+
*/
|
|
22
|
+
type ConsentSourceEntry = {
|
|
23
|
+
id: string;
|
|
24
|
+
name?: string;
|
|
25
|
+
statement?: unknown;
|
|
26
|
+
page?: ConsentSourcePage;
|
|
27
|
+
url?: string;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Host seam resolving the consent sources a form's authors can reference (plugin option
|
|
31
|
+
* `consent.sources`). Without it there are no sources, so the `consent` field type is not
|
|
32
|
+
* registered at all.
|
|
33
|
+
*
|
|
34
|
+
* The intended shape: place `consentSourcesField()` on a collection or global you own, then read it
|
|
35
|
+
* back here. Multi-tenant hosts scope the read by the tenant derived from `req` (host header,
|
|
36
|
+
* cookie, or auth context) and return only that tenant's sources, so one tenant's statements are
|
|
37
|
+
* never selectable, resolvable, or provable under another's. Read under `req.locale` so the
|
|
38
|
+
* statement the visitor agrees to is the one they were shown.
|
|
39
|
+
*
|
|
40
|
+
* Do not thread the save's `req` into a `find({ locale: 'all' })` from within a form's save
|
|
41
|
+
* validation: it flips `req.locale` to `all` and corrupts the localized write of the document being
|
|
42
|
+
* saved. Read the settings document without the save's `req` (already-committed data, no transaction).
|
|
43
|
+
*/
|
|
44
|
+
type ConsentSourcesResolver = (args: {
|
|
45
|
+
req: PayloadRequest;
|
|
46
|
+
/**
|
|
47
|
+
* The form document being read: `id`, `title`, and (at runtime) every other field. Derive
|
|
48
|
+
* multi-tenant scoping from a field on it, casting for non-standard fields (e.g.
|
|
49
|
+
* `(form as { tenant?: string }).tenant`), rather than reading the form back: reading the same
|
|
50
|
+
* `forms` collection from within this resolver re-enters the form's afterRead hook. The type is
|
|
51
|
+
* kept index-signature-free so a generated `Form` interface assigns without a cast. Treat `form`
|
|
52
|
+
* as read-only.
|
|
53
|
+
*/
|
|
54
|
+
form: {
|
|
55
|
+
id: number | string;
|
|
56
|
+
title?: string | null;
|
|
57
|
+
};
|
|
58
|
+
}) => ConsentSourceEntry[] | Promise<ConsentSourceEntry[]>;
|
|
59
|
+
//#endregion
|
|
60
|
+
export { ConsentSourceEntry, ConsentSourcePage, ConsentSourcesResolver };
|
|
61
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Payload, PayloadRequest } from "payload";
|
|
2
|
+
|
|
3
|
+
//#region src/email/departments.d.ts
|
|
4
|
+
/** One selectable department for the `emailTeam` recipients; `value` is the email address routed to. */
|
|
5
|
+
type DepartmentOption = {
|
|
6
|
+
label: string;
|
|
7
|
+
value: string;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Host seam resolving the selectable departments for `emailTeam`'s recipient fields (plugin option
|
|
11
|
+
* `email.departments`). Req-scoped, so multi-tenant hosts derive tenant scoping from `req` (host
|
|
12
|
+
* header, cookie, or auth context) and return only that tenant's departments. `value` is the literal
|
|
13
|
+
* string `payload.sendEmail` accepts (an email address); `label` is how the department is named in the
|
|
14
|
+
* admin select. Mirrors {@link FromAddressesResolver}. {@link resolveDepartmentOptions} builds this
|
|
15
|
+
* from a `departmentsField()`-bearing document with the reusable locale fallback, so a host does not
|
|
16
|
+
* reimplement it.
|
|
17
|
+
*
|
|
18
|
+
* Do not thread the save's `req` into a `find({ locale: 'all' })` from within a form's save
|
|
19
|
+
* validation: it flips `req.locale` to `all` and corrupts the localized write of the document being
|
|
20
|
+
* saved. Read the settings document without the save's `req` (already-committed data, no transaction).
|
|
21
|
+
*/
|
|
22
|
+
type DepartmentEmailsResolver = (args: {
|
|
23
|
+
req: PayloadRequest;
|
|
24
|
+
}) => Promise<DepartmentOption[]> | DepartmentOption[];
|
|
25
|
+
type ResolveDepartmentsRequestArgs = {
|
|
26
|
+
/** Whether the caller is authenticated (an admin/user). */isAuthed: boolean;
|
|
27
|
+
req: PayloadRequest;
|
|
28
|
+
resolver: DepartmentEmailsResolver;
|
|
29
|
+
};
|
|
30
|
+
type ResolveDepartmentsRequestResult = {
|
|
31
|
+
status: number;
|
|
32
|
+
body: {
|
|
33
|
+
options: DepartmentOption[];
|
|
34
|
+
} | {
|
|
35
|
+
errors: {
|
|
36
|
+
message: string;
|
|
37
|
+
}[];
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
type ResolveDepartmentOptionsArgs = {
|
|
41
|
+
payload: Payload;
|
|
42
|
+
req: PayloadRequest; /** A document fetched at `locale: 'all'`, so each localized subfield is a `{ locale: value }` map. */
|
|
43
|
+
doc: Record<string, unknown>; /** The array field name the departments live under; defaults to `departmentEmails`. */
|
|
44
|
+
field?: string;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Build the `emailTeam` recipient options from a `departmentsField()`-bearing document (a settings
|
|
48
|
+
* global, a tenants row, wherever the host placed it), fetched at `locale: 'all'`. Each row's `label`
|
|
49
|
+
* and `email` are resolved for `req.locale` via the current -> default -> next-available chain (see
|
|
50
|
+
* {@link pickLocaleValue}), reading `defaultLocale`/`localeCodes` from `payload.config.localization`
|
|
51
|
+
* (a bare string is used as-is when localization is disabled). Rows with no resolvable email are
|
|
52
|
+
* dropped; a row's label is resolved independently of its email and falls back to the email when
|
|
53
|
+
* absent. This is the reusable seam a host's `email.departments` resolver returns, so tenant scoping
|
|
54
|
+
* (which document is read) stays the host's call while the locale fallback stays consistent.
|
|
55
|
+
*/
|
|
56
|
+
declare const resolveDepartmentOptions: (args: ResolveDepartmentOptionsArgs) => DepartmentOption[];
|
|
57
|
+
//#endregion
|
|
58
|
+
export { DepartmentEmailsResolver, DepartmentOption, ResolveDepartmentOptionsArgs, ResolveDepartmentsRequestArgs, ResolveDepartmentsRequestResult, resolveDepartmentOptions };
|
|
59
|
+
//# sourceMappingURL=departments.d.ts.map
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
//#region src/email/departments.ts
|
|
2
|
+
/**
|
|
3
|
+
* Authorize and resolve the `GET /:id/departments` request backing the recipient selects: authenticated
|
|
4
|
+
* callers get the host resolver's current options for this request; anonymous callers are always
|
|
5
|
+
* refused. The route id is unused (the option set is request-scoped, not per-form). Statuses mirror
|
|
6
|
+
* `resolveFromAddressesRequest`: 403 unauthenticated, 503 when the resolver throws (fail closed).
|
|
7
|
+
*/
|
|
8
|
+
const resolveDepartmentsRequest = async (args) => {
|
|
9
|
+
const { isAuthed, req, resolver } = args;
|
|
10
|
+
if (!isAuthed) return {
|
|
11
|
+
status: 403,
|
|
12
|
+
body: { errors: [{ message: "Forbidden" }] }
|
|
13
|
+
};
|
|
14
|
+
try {
|
|
15
|
+
return {
|
|
16
|
+
status: 200,
|
|
17
|
+
body: { options: await resolver({ req }) }
|
|
18
|
+
};
|
|
19
|
+
} catch {
|
|
20
|
+
return {
|
|
21
|
+
status: 503,
|
|
22
|
+
body: { errors: [{ message: "Departments unavailable" }] }
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Resolve one localized subfield value for `reqLocale` with the current -> default -> next-available
|
|
28
|
+
* chain. A non-localized subfield (fetched at `locale: 'all'` on a host without localization) is a
|
|
29
|
+
* bare string, used as-is; a localized one is a `{ [locale]: value }` map, from which `reqLocale`,
|
|
30
|
+
* then `defaultLocale`, then the first non-empty configured locale wins. Empty strings are skipped
|
|
31
|
+
* (they fall through the chain), and undefined is returned when nothing resolves.
|
|
32
|
+
*/
|
|
33
|
+
const pickLocaleValue = (value, reqLocale, defaultLocale, localeCodes) => {
|
|
34
|
+
if (typeof value === "string") return value.length > 0 ? value : void 0;
|
|
35
|
+
if (value == null || typeof value !== "object") return;
|
|
36
|
+
const map = value;
|
|
37
|
+
const nonEmpty = (entry) => typeof entry === "string" && entry.length > 0 ? entry : void 0;
|
|
38
|
+
const ordered = [
|
|
39
|
+
reqLocale,
|
|
40
|
+
defaultLocale,
|
|
41
|
+
...localeCodes
|
|
42
|
+
].filter((code) => typeof code === "string" && code.length > 0);
|
|
43
|
+
for (const code of ordered) {
|
|
44
|
+
const hit = nonEmpty(map[code]);
|
|
45
|
+
if (hit !== void 0) return hit;
|
|
46
|
+
}
|
|
47
|
+
for (const key of Object.keys(map)) {
|
|
48
|
+
const hit = nonEmpty(map[key]);
|
|
49
|
+
if (hit !== void 0) return hit;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Build the `emailTeam` recipient options from a `departmentsField()`-bearing document (a settings
|
|
54
|
+
* global, a tenants row, wherever the host placed it), fetched at `locale: 'all'`. Each row's `label`
|
|
55
|
+
* and `email` are resolved for `req.locale` via the current -> default -> next-available chain (see
|
|
56
|
+
* {@link pickLocaleValue}), reading `defaultLocale`/`localeCodes` from `payload.config.localization`
|
|
57
|
+
* (a bare string is used as-is when localization is disabled). Rows with no resolvable email are
|
|
58
|
+
* dropped; a row's label is resolved independently of its email and falls back to the email when
|
|
59
|
+
* absent. This is the reusable seam a host's `email.departments` resolver returns, so tenant scoping
|
|
60
|
+
* (which document is read) stays the host's call while the locale fallback stays consistent.
|
|
61
|
+
*/
|
|
62
|
+
const resolveDepartmentOptions = (args) => {
|
|
63
|
+
const { payload, req, doc, field } = args;
|
|
64
|
+
const rows = doc[field ?? "departmentEmails"];
|
|
65
|
+
if (!Array.isArray(rows)) return [];
|
|
66
|
+
const localization = payload.config.localization;
|
|
67
|
+
const localeCodes = localization ? localization.localeCodes : [];
|
|
68
|
+
const defaultLocale = localization ? localization.defaultLocale : void 0;
|
|
69
|
+
const reqLocale = typeof req.locale === "string" ? req.locale : void 0;
|
|
70
|
+
const options = [];
|
|
71
|
+
for (const row of rows) {
|
|
72
|
+
if (row == null || typeof row !== "object") continue;
|
|
73
|
+
const entry = row;
|
|
74
|
+
const email = pickLocaleValue(entry.email, reqLocale, defaultLocale, localeCodes);
|
|
75
|
+
if (email === void 0) continue;
|
|
76
|
+
const label = pickLocaleValue(entry.label, reqLocale, defaultLocale, localeCodes) ?? email;
|
|
77
|
+
options.push({
|
|
78
|
+
label,
|
|
79
|
+
value: email
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
return options;
|
|
83
|
+
};
|
|
84
|
+
//#endregion
|
|
85
|
+
export { resolveDepartmentOptions, resolveDepartmentsRequest };
|
|
86
|
+
|
|
87
|
+
//# sourceMappingURL=departments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"departments.js","names":[],"sources":["../../src/email/departments.ts"],"sourcesContent":["import type { Payload, PayloadRequest } from 'payload'\n\n/** One selectable department for the `emailTeam` recipients; `value` is the email address routed to. */\nexport type DepartmentOption = { label: string; value: string }\n\n/**\n * Host seam resolving the selectable departments for `emailTeam`'s recipient fields (plugin option\n * `email.departments`). Req-scoped, so multi-tenant hosts derive tenant scoping from `req` (host\n * header, cookie, or auth context) and return only that tenant's departments. `value` is the literal\n * string `payload.sendEmail` accepts (an email address); `label` is how the department is named in the\n * admin select. Mirrors {@link FromAddressesResolver}. {@link resolveDepartmentOptions} builds this\n * from a `departmentsField()`-bearing document with the reusable locale fallback, so a host does not\n * reimplement it.\n *\n * Do not thread the save's `req` into a `find({ locale: 'all' })` from within a form's save\n * validation: it flips `req.locale` to `all` and corrupts the localized write of the document being\n * saved. Read the settings document without the save's `req` (already-committed data, no transaction).\n */\nexport type DepartmentEmailsResolver = (args: {\n\treq: PayloadRequest\n}) => Promise<DepartmentOption[]> | DepartmentOption[]\n\nexport type ResolveDepartmentsRequestArgs = {\n\t/** Whether the caller is authenticated (an admin/user). */\n\tisAuthed: boolean\n\treq: PayloadRequest\n\tresolver: DepartmentEmailsResolver\n}\n\nexport type ResolveDepartmentsRequestResult = {\n\tstatus: number\n\tbody: { options: DepartmentOption[] } | { errors: { message: string }[] }\n}\n\n/**\n * Authorize and resolve the `GET /:id/departments` request backing the recipient selects: authenticated\n * callers get the host resolver's current options for this request; anonymous callers are always\n * refused. The route id is unused (the option set is request-scoped, not per-form). Statuses mirror\n * `resolveFromAddressesRequest`: 403 unauthenticated, 503 when the resolver throws (fail closed).\n */\nexport const resolveDepartmentsRequest = async (\n\targs: ResolveDepartmentsRequestArgs\n): Promise<ResolveDepartmentsRequestResult> => {\n\tconst { isAuthed, req, resolver } = args\n\tif (!isAuthed) {\n\t\treturn { status: 403, body: { errors: [{ message: 'Forbidden' }] } }\n\t}\n\ttry {\n\t\tconst options = await resolver({ req })\n\t\treturn { status: 200, body: { options } }\n\t} catch {\n\t\treturn { status: 503, body: { errors: [{ message: 'Departments unavailable' }] } }\n\t}\n}\n\n/**\n * Resolve one localized subfield value for `reqLocale` with the current -> default -> next-available\n * chain. A non-localized subfield (fetched at `locale: 'all'` on a host without localization) is a\n * bare string, used as-is; a localized one is a `{ [locale]: value }` map, from which `reqLocale`,\n * then `defaultLocale`, then the first non-empty configured locale wins. Empty strings are skipped\n * (they fall through the chain), and undefined is returned when nothing resolves.\n */\n// biome-ignore lint/complexity/useMaxParams: the locale-fallback inputs are the minimal surface (value, reqLocale, defaultLocale, localeCodes)\nexport const pickLocaleValue = (\n\tvalue: unknown,\n\treqLocale: string | undefined,\n\tdefaultLocale: string | undefined,\n\tlocaleCodes: string[]\n): string | undefined => {\n\tif (typeof value === 'string') {\n\t\treturn value.length > 0 ? value : undefined\n\t}\n\tif (value == null || typeof value !== 'object') {\n\t\treturn undefined\n\t}\n\tconst map = value as Record<string, unknown>\n\tconst nonEmpty = (entry: unknown): string | undefined =>\n\t\ttypeof entry === 'string' && entry.length > 0 ? entry : undefined\n\tconst ordered = [reqLocale, defaultLocale, ...localeCodes].filter(\n\t\t(code): code is string => typeof code === 'string' && code.length > 0\n\t)\n\tfor (const code of ordered) {\n\t\tconst hit = nonEmpty(map[code])\n\t\tif (hit !== undefined) {\n\t\t\treturn hit\n\t\t}\n\t}\n\t// Defensive: a `locale: 'all'` fetch keys by configured locales, but a key outside them still\n\t// counts toward \"next available\" so a value is never silently dropped.\n\tfor (const key of Object.keys(map)) {\n\t\tconst hit = nonEmpty(map[key])\n\t\tif (hit !== undefined) {\n\t\t\treturn hit\n\t\t}\n\t}\n\treturn undefined\n}\n\nexport type ResolveDepartmentOptionsArgs = {\n\tpayload: Payload\n\treq: PayloadRequest\n\t/** A document fetched at `locale: 'all'`, so each localized subfield is a `{ locale: value }` map. */\n\tdoc: Record<string, unknown>\n\t/** The array field name the departments live under; defaults to `departmentEmails`. */\n\tfield?: string\n}\n\n/**\n * Build the `emailTeam` recipient options from a `departmentsField()`-bearing document (a settings\n * global, a tenants row, wherever the host placed it), fetched at `locale: 'all'`. Each row's `label`\n * and `email` are resolved for `req.locale` via the current -> default -> next-available chain (see\n * {@link pickLocaleValue}), reading `defaultLocale`/`localeCodes` from `payload.config.localization`\n * (a bare string is used as-is when localization is disabled). Rows with no resolvable email are\n * dropped; a row's label is resolved independently of its email and falls back to the email when\n * absent. This is the reusable seam a host's `email.departments` resolver returns, so tenant scoping\n * (which document is read) stays the host's call while the locale fallback stays consistent.\n */\nexport const resolveDepartmentOptions = (\n\targs: ResolveDepartmentOptionsArgs\n): DepartmentOption[] => {\n\tconst { payload, req, doc, field } = args\n\tconst rows = doc[field ?? 'departmentEmails']\n\tif (!Array.isArray(rows)) {\n\t\treturn []\n\t}\n\tconst localization = payload.config.localization\n\tconst localeCodes = localization ? localization.localeCodes : []\n\tconst defaultLocale = localization ? localization.defaultLocale : undefined\n\tconst reqLocale = typeof req.locale === 'string' ? req.locale : undefined\n\tconst options: DepartmentOption[] = []\n\tfor (const row of rows) {\n\t\tif (row == null || typeof row !== 'object') {\n\t\t\tcontinue\n\t\t}\n\t\tconst entry = row as Record<string, unknown>\n\t\tconst email = pickLocaleValue(entry.email, reqLocale, defaultLocale, localeCodes)\n\t\tif (email === undefined) {\n\t\t\tcontinue\n\t\t}\n\t\tconst label = pickLocaleValue(entry.label, reqLocale, defaultLocale, localeCodes) ?? email\n\t\toptions.push({ label, value: email })\n\t}\n\treturn options\n}\n"],"mappings":";;;;;;;AAwCA,MAAa,4BAA4B,OACxC,SAC8C;CAC9C,MAAM,EAAE,UAAU,KAAK,aAAa;CACpC,IAAI,CAAC,UACJ,OAAO;EAAE,QAAQ;EAAK,MAAM,EAAE,QAAQ,CAAC,EAAE,SAAS,YAAY,CAAC,EAAE;CAAE;CAEpE,IAAI;EAEH,OAAO;GAAE,QAAQ;GAAK,MAAM,EAAE,SAAA,MADR,SAAS,EAAE,IAAI,CAAC,EACA;EAAE;CACzC,QAAQ;EACP,OAAO;GAAE,QAAQ;GAAK,MAAM,EAAE,QAAQ,CAAC,EAAE,SAAS,0BAA0B,CAAC,EAAE;EAAE;CAClF;AACD;;;;;;;;AAUA,MAAa,mBACZ,OACA,WACA,eACA,gBACwB;CACxB,IAAI,OAAO,UAAU,UACpB,OAAO,MAAM,SAAS,IAAI,QAAQ,KAAA;CAEnC,IAAI,SAAS,QAAQ,OAAO,UAAU,UACrC;CAED,MAAM,MAAM;CACZ,MAAM,YAAY,UACjB,OAAO,UAAU,YAAY,MAAM,SAAS,IAAI,QAAQ,KAAA;CACzD,MAAM,UAAU;EAAC;EAAW;EAAe,GAAG;CAAW,EAAE,QACzD,SAAyB,OAAO,SAAS,YAAY,KAAK,SAAS,CACrE;CACA,KAAK,MAAM,QAAQ,SAAS;EAC3B,MAAM,MAAM,SAAS,IAAI,KAAK;EAC9B,IAAI,QAAQ,KAAA,GACX,OAAO;CAET;CAGA,KAAK,MAAM,OAAO,OAAO,KAAK,GAAG,GAAG;EACnC,MAAM,MAAM,SAAS,IAAI,IAAI;EAC7B,IAAI,QAAQ,KAAA,GACX,OAAO;CAET;AAED;;;;;;;;;;;AAqBA,MAAa,4BACZ,SACwB;CACxB,MAAM,EAAE,SAAS,KAAK,KAAK,UAAU;CACrC,MAAM,OAAO,IAAI,SAAS;CAC1B,IAAI,CAAC,MAAM,QAAQ,IAAI,GACtB,OAAO,CAAC;CAET,MAAM,eAAe,QAAQ,OAAO;CACpC,MAAM,cAAc,eAAe,aAAa,cAAc,CAAC;CAC/D,MAAM,gBAAgB,eAAe,aAAa,gBAAgB,KAAA;CAClE,MAAM,YAAY,OAAO,IAAI,WAAW,WAAW,IAAI,SAAS,KAAA;CAChE,MAAM,UAA8B,CAAC;CACrC,KAAK,MAAM,OAAO,MAAM;EACvB,IAAI,OAAO,QAAQ,OAAO,QAAQ,UACjC;EAED,MAAM,QAAQ;EACd,MAAM,QAAQ,gBAAgB,MAAM,OAAO,WAAW,eAAe,WAAW;EAChF,IAAI,UAAU,KAAA,GACb;EAED,MAAM,QAAQ,gBAAgB,MAAM,OAAO,WAAW,eAAe,WAAW,KAAK;EACrF,QAAQ,KAAK;GAAE;GAAO,OAAO;EAAM,CAAC;CACrC;CACA,OAAO;AACR"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { ArrayField } from "payload";
|
|
2
|
+
|
|
3
|
+
//#region src/email/departmentsField.d.ts
|
|
4
|
+
type DepartmentsFieldOptions = {
|
|
5
|
+
/** Field name, i.e. what the row array is stored under. Defaults to `departmentEmails`. */name?: string; /** Field label. Defaults to the plugin's translated one. */
|
|
6
|
+
label?: ArrayField['label'];
|
|
7
|
+
/**
|
|
8
|
+
* Whether each row's `email` (and its `label`) carry `localized: true`, so the same field can
|
|
9
|
+
* hold a different address per locale. Default `true`; Payload strips the flag on hosts without
|
|
10
|
+
* `localization`, so it is safe either way.
|
|
11
|
+
*/
|
|
12
|
+
localized?: boolean;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* The department-emails array, for the host to place on any collection or global they own: a
|
|
16
|
+
* settings global, a tenants collection, a departments parent, wherever the addresses belong. The
|
|
17
|
+
* plugin never registers it and never guesses where it lives; the `email.departments` resolver reads
|
|
18
|
+
* it back, which is also where multi-tenant scoping goes: place this on the tenant-scoped document
|
|
19
|
+
* and have the resolver return only that tenant's addresses, derived from `req`.
|
|
20
|
+
*
|
|
21
|
+
* A row is a `label` (how the address is named when routing a submission to it) and the `email` it
|
|
22
|
+
* resolves to. Because `email` is `localized` by default, a host can hold a different address per
|
|
23
|
+
* locale without changing the stored shape. The array itself is not localized, so per-locale edits
|
|
24
|
+
* must address existing rows by their own auto-assigned `id` rather than re-sending id-less rows.
|
|
25
|
+
*
|
|
26
|
+
* It renders condensed: `admin.components.Field` is {@link CondensedArray}, which lays each row out
|
|
27
|
+
* flat as `[label, email]` at 50% each with no per-row collapsible, while keeping Payload's native
|
|
28
|
+
* per-locale storage and row ids.
|
|
29
|
+
*
|
|
30
|
+
* ```ts
|
|
31
|
+
* // The host's own collection or global:
|
|
32
|
+
* fields: [departmentsField()]
|
|
33
|
+
*
|
|
34
|
+
* // The plugin, reading it back to route a submission. `resolveDepartmentOptions` reads the array
|
|
35
|
+
* // (fetched at `locale: 'all'`) and resolves each row's address for the requesting locale:
|
|
36
|
+
* formBuilder({
|
|
37
|
+
* email: {
|
|
38
|
+
* departments: async ({ req }) => {
|
|
39
|
+
* const settings = await req.payload.findGlobal({ slug: 'settings', depth: 0, locale: 'all' })
|
|
40
|
+
* return resolveDepartmentOptions({ payload: req.payload, req, doc: settings })
|
|
41
|
+
* },
|
|
42
|
+
* },
|
|
43
|
+
* })
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* The read above omits the save's `req` on purpose: threading it into a `locale: 'all'` read from
|
|
47
|
+
* within a form's save validation flips `req.locale` to `all` and corrupts the localized write of the
|
|
48
|
+
* document being saved. It reads already-committed data, so no transaction (`req`) is needed.
|
|
49
|
+
*/
|
|
50
|
+
declare const departmentsField: (options?: DepartmentsFieldOptions) => ArrayField;
|
|
51
|
+
//#endregion
|
|
52
|
+
export { DepartmentsFieldOptions, departmentsField };
|
|
53
|
+
//# sourceMappingURL=departmentsField.d.ts.map
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { keys } from "../translations/keys.js";
|
|
2
|
+
import { labelForKey } from "../translations/server.js";
|
|
3
|
+
import { localizedIf } from "../fields/localizedIf.js";
|
|
4
|
+
//#region src/email/departmentsField.ts
|
|
5
|
+
/**
|
|
6
|
+
* The department-emails array, for the host to place on any collection or global they own: a
|
|
7
|
+
* settings global, a tenants collection, a departments parent, wherever the addresses belong. The
|
|
8
|
+
* plugin never registers it and never guesses where it lives; the `email.departments` resolver reads
|
|
9
|
+
* it back, which is also where multi-tenant scoping goes: place this on the tenant-scoped document
|
|
10
|
+
* and have the resolver return only that tenant's addresses, derived from `req`.
|
|
11
|
+
*
|
|
12
|
+
* A row is a `label` (how the address is named when routing a submission to it) and the `email` it
|
|
13
|
+
* resolves to. Because `email` is `localized` by default, a host can hold a different address per
|
|
14
|
+
* locale without changing the stored shape. The array itself is not localized, so per-locale edits
|
|
15
|
+
* must address existing rows by their own auto-assigned `id` rather than re-sending id-less rows.
|
|
16
|
+
*
|
|
17
|
+
* It renders condensed: `admin.components.Field` is {@link CondensedArray}, which lays each row out
|
|
18
|
+
* flat as `[label, email]` at 50% each with no per-row collapsible, while keeping Payload's native
|
|
19
|
+
* per-locale storage and row ids.
|
|
20
|
+
*
|
|
21
|
+
* ```ts
|
|
22
|
+
* // The host's own collection or global:
|
|
23
|
+
* fields: [departmentsField()]
|
|
24
|
+
*
|
|
25
|
+
* // The plugin, reading it back to route a submission. `resolveDepartmentOptions` reads the array
|
|
26
|
+
* // (fetched at `locale: 'all'`) and resolves each row's address for the requesting locale:
|
|
27
|
+
* formBuilder({
|
|
28
|
+
* email: {
|
|
29
|
+
* departments: async ({ req }) => {
|
|
30
|
+
* const settings = await req.payload.findGlobal({ slug: 'settings', depth: 0, locale: 'all' })
|
|
31
|
+
* return resolveDepartmentOptions({ payload: req.payload, req, doc: settings })
|
|
32
|
+
* },
|
|
33
|
+
* },
|
|
34
|
+
* })
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* The read above omits the save's `req` on purpose: threading it into a `locale: 'all'` read from
|
|
38
|
+
* within a form's save validation flips `req.locale` to `all` and corrupts the localized write of the
|
|
39
|
+
* document being saved. It reads already-committed data, so no transaction (`req`) is needed.
|
|
40
|
+
*/
|
|
41
|
+
const departmentsField = (options = {}) => {
|
|
42
|
+
const localize = options.localized !== false;
|
|
43
|
+
return {
|
|
44
|
+
name: options.name ?? "departmentEmails",
|
|
45
|
+
type: "array",
|
|
46
|
+
label: options.label ?? labelForKey(keys.departmentsField),
|
|
47
|
+
labels: {
|
|
48
|
+
singular: labelForKey(keys.departmentSingular),
|
|
49
|
+
plural: labelForKey(keys.departmentPlural)
|
|
50
|
+
},
|
|
51
|
+
admin: {
|
|
52
|
+
description: labelForKey(keys.departmentsFieldDescription),
|
|
53
|
+
components: { Field: "@10x-media/form-builder/client#CondensedArray" }
|
|
54
|
+
},
|
|
55
|
+
fields: [{
|
|
56
|
+
name: "label",
|
|
57
|
+
type: "text",
|
|
58
|
+
label: labelForKey(keys.departmentLabel),
|
|
59
|
+
admin: { width: "50%" },
|
|
60
|
+
...localizedIf(localize)
|
|
61
|
+
}, {
|
|
62
|
+
name: "email",
|
|
63
|
+
type: "text",
|
|
64
|
+
label: labelForKey(keys.departmentEmail),
|
|
65
|
+
admin: { width: "50%" },
|
|
66
|
+
...localizedIf(localize)
|
|
67
|
+
}]
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
//#endregion
|
|
71
|
+
export { departmentsField };
|
|
72
|
+
|
|
73
|
+
//# sourceMappingURL=departmentsField.js.map
|
|
@@ -0,0 +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', depth: 0, locale: 'all' })\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsDA,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,3 +1,15 @@
|
|
|
1
|
+
import { ByteSizeField } from "../client/ByteSizeField.js";
|
|
2
|
+
import { ClosePollButton } from "../client/ClosePollButton.js";
|
|
3
|
+
import { CondensedArray } from "../client/CondensedArray.js";
|
|
4
|
+
import { ConsentBlockLabel } from "../client/ConsentBlockLabel.js";
|
|
5
|
+
import { ConsentSourceRowLabel } from "../client/ConsentSourceRowLabel.js";
|
|
6
|
+
import { EndpointOptionsSelect } from "../client/EndpointOptionsSelect.js";
|
|
7
|
+
import { FieldBlockLabel } from "../client/FieldBlockLabel.js";
|
|
8
|
+
import { FieldNameSelect } from "../client/FieldNameSelect.js";
|
|
1
9
|
import { FlowBuilder } from "../client/FlowBuilder.js";
|
|
2
10
|
import { FormConditionField } from "../client/FormConditionField.js";
|
|
3
|
-
|
|
11
|
+
import { RecipientsSelect } from "../client/RecipientsSelect.js";
|
|
12
|
+
import { RuleDescription } from "../client/RuleDescription.js";
|
|
13
|
+
import { FieldCountCell } from "../collections/cells/FieldCountCell.js";
|
|
14
|
+
import { FlowStepsCell } from "../collections/cells/FlowStepsCell.js";
|
|
15
|
+
export { ByteSizeField, ClosePollButton, CondensedArray, ConsentBlockLabel, ConsentSourceRowLabel, EndpointOptionsSelect, FieldBlockLabel, FieldCountCell, FieldNameSelect, FlowBuilder, FlowStepsCell, FormConditionField, RecipientsSelect, RuleDescription };
|
package/dist/exports/client.js
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import { ByteSizeField } from "../client/ByteSizeField.js";
|
|
3
|
+
import { ClosePollButton } from "../client/ClosePollButton.js";
|
|
4
|
+
import { CondensedArray } from "../client/CondensedArray.js";
|
|
5
|
+
import { ConsentBlockLabel } from "../client/ConsentBlockLabel.js";
|
|
6
|
+
import { ConsentSourceRowLabel } from "../client/ConsentSourceRowLabel.js";
|
|
7
|
+
import { EndpointOptionsSelect } from "../client/EndpointOptionsSelect.js";
|
|
8
|
+
import { FieldBlockLabel } from "../client/FieldBlockLabel.js";
|
|
9
|
+
import { FieldNameSelect } from "../client/FieldNameSelect.js";
|
|
2
10
|
import { FlowBuilder } from "../client/FlowBuilder.js";
|
|
3
11
|
import { FormConditionField } from "../client/FormConditionField.js";
|
|
4
|
-
|
|
12
|
+
import { RecipientsSelect } from "../client/RecipientsSelect.js";
|
|
13
|
+
import { RuleDescription } from "../client/RuleDescription.js";
|
|
14
|
+
import { FieldCountCell } from "../collections/cells/FieldCountCell.js";
|
|
15
|
+
import { FlowStepsCell } from "../collections/cells/FlowStepsCell.js";
|
|
16
|
+
export { ByteSizeField, ClosePollButton, CondensedArray, ConsentBlockLabel, ConsentSourceRowLabel, EndpointOptionsSelect, FieldBlockLabel, FieldCountCell, FieldNameSelect, FlowBuilder, FlowStepsCell, FormConditionField, RecipientsSelect, RuleDescription };
|
package/dist/exports/i18n.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import { TranslationKey, keys } from "../translations/keys.js";
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { de } from "../translations/de.js";
|
|
3
|
+
import { en } from "../translations/en.js";
|
|
4
|
+
import { TranslationBundle, TranslationsOption, bundles, translations } from "../translations/index.js";
|
|
5
|
+
import { clientRuntimeKeys } from "../translations/clientRuntimeKeys.js";
|
|
6
|
+
export { type TranslationKey as FormBuilderTranslationKeys, type TranslationBundle, type TranslationKey, type TranslationsOption, bundles, clientRuntimeKeys, de, en, keys, translations };
|
package/dist/exports/i18n.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import { keys } from "../translations/keys.js";
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { de } from "../translations/de.js";
|
|
3
|
+
import { en } from "../translations/en.js";
|
|
4
|
+
import { bundles, translations } from "../translations/index.js";
|
|
5
|
+
import { clientRuntimeKeys } from "../translations/clientRuntimeKeys.js";
|
|
6
|
+
export { bundles, clientRuntimeKeys, de, en, keys, translations };
|
package/dist/exports/react.d.ts
CHANGED
|
@@ -1,22 +1,42 @@
|
|
|
1
|
-
import { FormFieldInstance } from "../submissions/types.js";
|
|
1
|
+
import { FormFieldInstance, SubmissionValue } from "../submissions/types.js";
|
|
2
|
+
import { de } from "../translations/de.js";
|
|
3
|
+
import { en } from "../translations/en.js";
|
|
4
|
+
import { TranslationBundle, bundles } from "../translations/index.js";
|
|
5
|
+
import { clientRuntimeKeys } from "../translations/clientRuntimeKeys.js";
|
|
6
|
+
import { BodyConverter, BodyConverterArgs, BodyRender, sanitizeUrl } from "../actions/body/converters.js";
|
|
7
|
+
import { BodyContext, serializeBody } from "../actions/body/serializeBody.js";
|
|
8
|
+
import { textOfBody } from "../actions/body/textOfBody.js";
|
|
2
9
|
import { AggregationBucket, FieldAggregation } from "../aggregation/types.js";
|
|
3
10
|
import { CalcExpression } from "../calc/types.js";
|
|
4
11
|
import { computeCalcFields } from "../calc/computeCalcFields.js";
|
|
5
12
|
import { evaluateCalc } from "../calc/evaluate.js";
|
|
6
13
|
import { evaluateCondition } from "../conditions/evaluate.js";
|
|
14
|
+
import { ConsentStatement, ConsentStatements } from "../consent/resolveConsentStatements.js";
|
|
15
|
+
import { COUNTRIES, US_STATES } from "../fields/data/regions.js";
|
|
16
|
+
import { fieldKey } from "../fields/fieldKey.js";
|
|
7
17
|
import { firstStepId, isTerminalStepId, resolveNextStepId, stepFieldNames } from "../flow/engine.js";
|
|
18
|
+
import { FormButtonSettings, FormDocument, FormPollSettings, FormResponseSettings } from "../form/types.js";
|
|
19
|
+
import { ToFormDocumentOptions, toFormDocument } from "../form/toFormDocument.js";
|
|
8
20
|
import { PrefillOptions, valuesFromSearchParams } from "../prefill/valuesFromSearchParams.js";
|
|
21
|
+
import { CaptchaWidgetHandle } from "../react/captcha/types.js";
|
|
22
|
+
import { HCAPTCHA_SCRIPT_URL, HcaptchaCaptcha, HcaptchaCaptchaProps } from "../react/captcha/HcaptchaCaptcha.js";
|
|
23
|
+
import { RECAPTCHA_SCRIPT_URL, RecaptchaCaptcha, RecaptchaCaptchaHandle, RecaptchaCaptchaProps } from "../react/captcha/RecaptchaCaptcha.js";
|
|
24
|
+
import { TURNSTILE_SCRIPT_URL, TurnstileCaptcha, TurnstileCaptchaProps } from "../react/captcha/TurnstileCaptcha.js";
|
|
9
25
|
import { cn } from "../react/cn.js";
|
|
10
26
|
import { FieldRenderer, FieldRendererProps, RendererTranslate, defineFieldRenderer } from "../react/contract.js";
|
|
27
|
+
import { BackButtonRenderProps, FormControls, FormControlsProps, NextButtonRenderProps, SubmitButtonRenderProps } from "../react/FormControls.js";
|
|
11
28
|
import { FormPresentation, PresentationWrapperProps } from "../react/presentation/types.js";
|
|
12
29
|
import { PresentationOption, PresentationRegistry, PresentationsConfig, resolvePresentations } from "../react/presentation/registry.js";
|
|
13
30
|
import { RendererOption, RendererRegistry, RenderersConfig, resolveRenderers } from "../react/registry.js";
|
|
14
31
|
import { SubmitFormResult, SubmitHandler, submitForm } from "../react/submitForm.js";
|
|
15
|
-
import { Form,
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
32
|
+
import { Form, FormProps, FormSuccessResponse, FormSuccessResult } from "../react/Form.js";
|
|
33
|
+
import { RecallResolver, buildRecallResolver } from "../recall/resolver.js";
|
|
34
|
+
import { FieldErrors, FormAction, FormState } from "../react/state.js";
|
|
35
|
+
import { FormContextValue, FormControlLabels, FormStepInfo, useFormContext } from "../react/FormContext.js";
|
|
36
|
+
import { FormFields, FormFieldsProps } from "../react/FormFields.js";
|
|
18
37
|
import { FieldWidth, FormLayout, FormLayoutProps, widthProps } from "../react/FormLayout.js";
|
|
19
38
|
import { FormResults, FormResultsProps } from "../react/FormResults.js";
|
|
39
|
+
import { FormSteps, FormStepsProps } from "../react/FormSteps.js";
|
|
20
40
|
import { FetchResultsInput, FetchResultsResult, fetchFormResults } from "../react/fetchResults.js";
|
|
21
41
|
import { Honeypot, HoneypotProps } from "../react/Honeypot.js";
|
|
22
42
|
import { Poll, PollProps } from "../react/Poll.js";
|
|
@@ -32,14 +52,12 @@ import { Input, InputProps } from "../react/primitives/Input.js";
|
|
|
32
52
|
import { Select, SelectOption, SelectProps } from "../react/primitives/Select.js";
|
|
33
53
|
import { Textarea, TextareaProps } from "../react/primitives/Textarea.js";
|
|
34
54
|
import { defaultRenderers } from "../react/renderers/index.js";
|
|
35
|
-
import { toFormDocument } from "../react/toFormDocument.js";
|
|
36
55
|
import { UploadFileInput, UploadFileResult, uploadFile } from "../react/uploadFile.js";
|
|
37
56
|
import { UseFieldResult, useField } from "../react/useField.js";
|
|
38
57
|
import { useFormState } from "../react/useFormState.js";
|
|
39
58
|
import { useFormStep } from "../react/useFormStep.js";
|
|
40
59
|
import { interpolate } from "../recall/interpolate.js";
|
|
41
|
-
import { RecallResolver, buildRecallResolver } from "../recall/resolver.js";
|
|
42
60
|
import { CAPTCHA_TOKEN_KEY, DEFAULT_HONEYPOT_FIELD } from "../spam/constants.js";
|
|
43
|
-
import { en } from "../translations/en.js";
|
|
44
61
|
import { makeTranslate } from "../translations/makeTranslate.js";
|
|
45
|
-
|
|
62
|
+
import { formatBytes } from "../uploads/formatBytes.js";
|
|
63
|
+
export { type AggregationBucket, type BackButtonRenderProps, Backdrop, type BackdropProps, type BodyContext, type BodyConverter, type BodyConverterArgs, type BodyRender, CAPTCHA_TOKEN_KEY, COUNTRIES, type CalcExpression, type CaptchaWidgetHandle, Checkbox, type CheckboxProps, type ConsentStatement, type ConsentStatements, DEFAULT_HONEYPOT_FIELD, DialogSurface, type DialogSurfaceProps, type FetchResultsInput, type FetchResultsResult, type FieldAggregation, type FieldErrors, type FieldRenderer, type FieldRendererProps, FieldShell, type FieldShellProps, type FieldWidth, Form, type FormAction, type FormButtonSettings, type FormContextValue, type FormControlLabels, FormControls, type FormControlsProps, type FormDocument, type FormFieldInstance, FormFields, type FormFieldsProps, FormLayout, type FormLayoutProps, type FormPollSettings, type FormPresentation, type FormProps, type FormResponseSettings, FormResults, type FormResultsProps, type FormState, type FormStepInfo, FormSteps, type FormStepsProps, type FormSuccessResponse, type FormSuccessResult, HCAPTCHA_SCRIPT_URL, HcaptchaCaptcha, type HcaptchaCaptchaProps, Honeypot, type HoneypotProps, Input, type InputProps, type NextButtonRenderProps, Poll, type PollProps, type PrefillOptions, type PresentationOption, type PresentationRegistry, type PresentationWrapperProps, type PresentationsConfig, RECAPTCHA_SCRIPT_URL, type RecallResolver, RecaptchaCaptcha, type RecaptchaCaptchaHandle, type RecaptchaCaptchaProps, type RendererOption, type RendererRegistry, type RendererTranslate, type RenderersConfig, Select, type SelectOption, type SelectProps, type SubmissionValue, type SubmitButtonRenderProps, type SubmitFormResult, type SubmitHandler, TURNSTILE_SCRIPT_URL, Textarea, type TextareaProps, type ToFormDocumentOptions, type TranslationBundle, TurnstileCaptcha, type TurnstileCaptchaProps, US_STATES, type UploadFileInput, type UploadFileResult, type UseDismissOptions, type UseFieldResult, buildRecallResolver, bundles, clientRuntimeKeys, cn, computeCalcFields, de, defaultPresentations, defaultRenderers, defineFieldRenderer, en, evaluateCalc, evaluateCondition, fetchFormResults, fieldKey, firstStepId, formatBytes, interpolate, isTerminalStepId, makeTranslate, resolveNextStepId, resolvePresentations, resolveRenderers, sanitizeUrl, serializeBody, stepFieldNames, submitForm, textOfBody, toFormDocument, uploadFile, useDismiss, useField, useFocusTrap, useFormContext, useFormState, useFormStep, useScrollLock, valuesFromSearchParams, widthProps };
|