@10x-media/form-builder 0.1.0-beta.0 → 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 +345 -0
- package/README.md +45 -1402
- 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 +22 -0
- package/dist/actions/buildActionBlocks.js.map +1 -0
- package/dist/actions/builtin/confirmation.js +52 -0
- package/dist/actions/builtin/confirmation.js.map +1 -0
- 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 +22 -0
- package/dist/actions/builtin/emailTeam.js.map +1 -0
- package/dist/actions/builtin/index.d.ts +22 -0
- package/dist/actions/builtin/index.js +27 -0
- package/dist/actions/builtin/index.js.map +1 -0
- package/dist/actions/builtin/signedWebhook.js +53 -0
- package/dist/actions/builtin/signedWebhook.js.map +1 -0
- package/dist/actions/defineAction.d.ts +37 -0
- package/dist/actions/defineAction.js +6 -0
- package/dist/actions/defineAction.js.map +1 -0
- package/dist/actions/dispatch.js +49 -0
- package/dist/actions/dispatch.js.map +1 -0
- 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 +17 -0
- package/dist/actions/registry.js +12 -0
- package/dist/actions/registry.js.map +1 -0
- package/dist/actions/runActions.d.ts +9 -0
- package/dist/actions/runActions.js +43 -0
- package/dist/actions/runActions.js.map +1 -0
- package/dist/actions/sign.d.ts +7 -0
- package/dist/actions/sign.js +9 -0
- package/dist/actions/sign.js.map +1 -0
- package/dist/actions/task.js +87 -0
- package/dist/actions/task.js.map +1 -0
- package/dist/aggregation/aggregateResponses.d.ts +40 -0
- package/dist/aggregation/aggregateResponses.js +80 -0
- package/dist/aggregation/aggregateResponses.js.map +1 -0
- package/dist/aggregation/aggregateRows.d.ts +10 -0
- package/dist/aggregation/aggregateRows.js +64 -0
- package/dist/aggregation/aggregateRows.js.map +1 -0
- package/dist/aggregation/resolveResultsRequest.d.ts +61 -0
- package/dist/aggregation/resolveResultsRequest.js +113 -0
- package/dist/aggregation/resolveResultsRequest.js.map +1 -0
- package/dist/aggregation/types.d.ts +39 -0
- package/dist/calc/computeCalcFields.d.ts +15 -0
- package/dist/calc/computeCalcFields.js +28 -0
- package/dist/calc/computeCalcFields.js.map +1 -0
- package/dist/calc/evaluate.d.ts +8 -0
- package/dist/calc/evaluate.js +58 -0
- package/dist/calc/evaluate.js.map +1 -0
- package/dist/calc/normalizeCalc.d.ts +8 -0
- package/dist/calc/normalizeCalc.js +87 -0
- package/dist/calc/normalizeCalc.js.map +1 -0
- package/dist/calc/types.d.ts +34 -0
- 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 +122 -0
- package/dist/client/ConditionBuilder.js.map +1 -0
- package/dist/client/ConditionRow.js +150 -0
- package/dist/client/ConditionRow.js.map +1 -0
- 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 +15 -0
- package/dist/client/FlowBuilder.js +457 -0
- package/dist/client/FlowBuilder.js.map +1 -0
- package/dist/client/FormConditionField.d.ts +21 -0
- package/dist/client/FormConditionField.js +30 -0
- package/dist/client/FormConditionField.js.map +1 -0
- 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 +57 -0
- package/dist/client/synthesizeClientField.js.map +1 -0
- 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 +204 -0
- package/dist/collections/formSubmissions.js.map +1 -0
- package/dist/collections/forms.js +482 -0
- package/dist/collections/forms.js.map +1 -0
- 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 +21 -0
- package/dist/conditions/conditionType.js.map +1 -0
- package/dist/conditions/evaluate.d.ts +17 -0
- package/dist/conditions/evaluate.js +94 -0
- package/dist/conditions/evaluate.js.map +1 -0
- package/dist/conditions/fieldTypes.d.ts +11 -0
- package/dist/{fieldTypes-CzhhJXjg.js → conditions/fieldTypes.js} +6 -3
- package/dist/conditions/fieldTypes.js.map +1 -0
- package/dist/conditions/normalizeConditions.js +61 -0
- package/dist/conditions/normalizeConditions.js.map +1 -0
- package/dist/conditions/types.d.ts +8 -0
- 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 +55 -0
- package/dist/consent/captureConsent.js +73 -0
- package/dist/consent/captureConsent.js.map +1 -0
- 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 +23 -0
- package/dist/consent/resolvePublishedVersionRef.js +30 -0
- package/dist/consent/resolvePublishedVersionRef.js.map +1 -0
- 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/events/noopSink.js +6 -0
- package/dist/events/noopSink.js.map +1 -0
- package/dist/events/resolveEventSink.js +8 -0
- package/dist/events/resolveEventSink.js.map +1 -0
- package/dist/events/types.d.ts +31 -0
- package/dist/exports/client.d.ts +15 -21
- package/dist/exports/client.js +15 -319
- package/dist/exports/i18n.d.ts +6 -138
- package/dist/exports/i18n.js +6 -3
- package/dist/exports/react.d.ts +63 -550
- package/dist/exports/react.js +55 -1563
- package/dist/exports/rsc.d.ts +9 -16
- package/dist/exports/rsc.js +9 -55
- package/dist/exports/types.d.ts +36 -5
- package/dist/fields/buildFieldBlocks.js +80 -0
- package/dist/fields/buildFieldBlocks.js.map +1 -0
- package/dist/fields/builtin/calculation.js +144 -0
- package/dist/fields/builtin/calculation.js.map +1 -0
- package/dist/fields/builtin/checkbox.js +21 -0
- package/dist/fields/builtin/checkbox.js.map +1 -0
- package/dist/fields/builtin/consent.js +47 -0
- package/dist/fields/builtin/consent.js.map +1 -0
- 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 +18 -0
- package/dist/fields/builtin/email.js.map +1 -0
- package/dist/fields/builtin/file.d.ts +15 -0
- package/dist/fields/builtin/file.js +127 -0
- package/dist/fields/builtin/file.js.map +1 -0
- package/dist/fields/builtin/index.d.ts +26 -0
- package/dist/fields/builtin/index.js +49 -0
- package/dist/fields/builtin/index.js.map +1 -0
- package/dist/fields/builtin/message.js +30 -0
- package/dist/fields/builtin/message.js.map +1 -0
- package/dist/fields/builtin/number.js +17 -0
- package/dist/fields/builtin/number.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 +49 -0
- package/dist/fields/builtin/select.js.map +1 -0
- 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 +13 -0
- package/dist/fields/builtin/text.js.map +1 -0
- package/dist/fields/builtin/textarea.js +13 -0
- package/dist/fields/builtin/textarea.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/defineFormField.d.ts +13 -0
- package/dist/fields/defineFormField.js +12 -0
- package/dist/fields/defineFormField.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 +12 -0
- package/dist/fields/registry.js +39 -0
- package/dist/fields/registry.js.map +1 -0
- package/dist/fields/sharedConfig.js +151 -0
- package/dist/fields/sharedConfig.js.map +1 -0
- package/dist/fields/types.d.ts +152 -0
- package/dist/flow/engine.d.ts +19 -0
- package/dist/flow/engine.js +29 -0
- package/dist/flow/engine.js.map +1 -0
- package/dist/flow/normalizeFlow.js +54 -0
- package/dist/flow/normalizeFlow.js.map +1 -0
- package/dist/flow/stepLabel.js +15 -0
- package/dist/flow/stepLabel.js.map +1 -0
- package/dist/flow/types.d.ts +32 -0
- 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 +88 -4
- package/dist/index.js +111 -1898
- package/dist/index.js.map +1 -1
- package/dist/options.d.ts +229 -0
- package/dist/plugin/access.js +12 -0
- package/dist/plugin/access.js.map +1 -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 +60 -0
- package/dist/plugin/registerCollections.js.map +1 -0
- package/dist/plugin/registerTranslations.js +19 -0
- package/dist/plugin/registerTranslations.js.map +1 -0
- 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.d.ts +18 -0
- package/dist/prefill/valuesFromSearchParams.js +41 -0
- package/dist/prefill/valuesFromSearchParams.js.map +1 -0
- package/dist/presentations/defaults.d.ts +33 -0
- package/dist/presentations/defaults.js +35 -0
- package/dist/presentations/defaults.js.map +1 -0
- package/dist/presentations/types.d.ts +19 -0
- package/dist/react/Form.d.ts +128 -0
- package/dist/react/Form.js +619 -0
- package/dist/react/Form.js.map +1 -0
- package/dist/react/FormContext.d.ts +59 -0
- package/dist/react/FormContext.js +14 -0
- package/dist/react/FormContext.js.map +1 -0
- 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 +22 -0
- package/dist/react/FormLayout.js +15 -0
- package/dist/react/FormLayout.js.map +1 -0
- package/dist/react/FormResults.d.ts +28 -0
- package/dist/react/FormResults.js +93 -0
- package/dist/react/FormResults.js.map +1 -0
- 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/Honeypot.d.ts +22 -0
- package/dist/react/Honeypot.js +38 -0
- package/dist/react/Honeypot.js.map +1 -0
- package/dist/react/Poll.d.ts +43 -0
- package/dist/react/Poll.js +135 -0
- package/dist/react/Poll.js.map +1 -0
- 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/cn.d.ts +6 -0
- package/dist/react/cn.js +8 -0
- package/dist/react/cn.js.map +1 -0
- package/dist/react/contract.d.ts +31 -0
- package/dist/react/contract.js +7 -0
- package/dist/react/contract.js.map +1 -0
- package/dist/react/events.js +14 -0
- package/dist/react/events.js.map +1 -0
- package/dist/react/fetchResults.d.ts +25 -0
- package/dist/react/fetchResults.js +31 -0
- package/dist/react/fetchResults.js.map +1 -0
- package/dist/react/presentation/Backdrop.d.ts +18 -0
- package/dist/react/presentation/Backdrop.js +14 -0
- package/dist/react/presentation/Backdrop.js.map +1 -0
- package/dist/react/presentation/DialogSurface.d.ts +35 -0
- package/dist/react/presentation/DialogSurface.js +53 -0
- package/dist/react/presentation/DialogSurface.js.map +1 -0
- package/dist/react/presentation/presentations.d.ts +7 -0
- package/dist/react/presentation/presentations.js +32 -0
- package/dist/react/presentation/presentations.js.map +1 -0
- package/dist/react/presentation/registry.d.ts +11 -0
- package/dist/react/presentation/registry.js +12 -0
- package/dist/react/presentation/registry.js.map +1 -0
- package/dist/react/presentation/types.d.ts +19 -0
- package/dist/react/presentation/useDismiss.d.ts +19 -0
- package/dist/react/presentation/useDismiss.js +33 -0
- package/dist/react/presentation/useDismiss.js.map +1 -0
- package/dist/react/presentation/useFocusTrap.d.ts +8 -0
- package/dist/react/presentation/useFocusTrap.js +35 -0
- package/dist/react/presentation/useFocusTrap.js.map +1 -0
- package/dist/react/presentation/useScrollLock.d.ts +6 -0
- package/dist/react/presentation/useScrollLock.js +18 -0
- package/dist/react/presentation/useScrollLock.js.map +1 -0
- package/dist/react/primitives/Checkbox.d.ts +28 -0
- package/dist/react/primitives/Checkbox.js +21 -0
- package/dist/react/primitives/Checkbox.js.map +1 -0
- package/dist/react/primitives/FieldShell.d.ts +29 -0
- package/dist/react/primitives/FieldShell.js +44 -0
- package/dist/react/primitives/FieldShell.js.map +1 -0
- package/dist/react/primitives/Input.d.ts +30 -0
- package/dist/react/primitives/Input.js +21 -0
- package/dist/react/primitives/Input.js.map +1 -0
- package/dist/react/primitives/Select.d.ts +34 -0
- package/dist/react/primitives/Select.js +26 -0
- package/dist/react/primitives/Select.js.map +1 -0
- package/dist/react/primitives/Textarea.d.ts +28 -0
- package/dist/react/primitives/Textarea.js +20 -0
- package/dist/react/primitives/Textarea.js.map +1 -0
- package/dist/react/recall.js +20 -0
- package/dist/react/recall.js.map +1 -0
- package/dist/react/registry.d.ts +16 -0
- package/dist/react/registry.js +16 -0
- package/dist/react/registry.js.map +1 -0
- package/dist/react/renderers/calculation.js +27 -0
- package/dist/react/renderers/calculation.js.map +1 -0
- package/dist/react/renderers/checkbox.js +32 -0
- package/dist/react/renderers/checkbox.js.map +1 -0
- package/dist/react/renderers/consent.js +97 -0
- package/dist/react/renderers/consent.js.map +1 -0
- package/dist/react/renderers/date.js +33 -0
- package/dist/react/renderers/date.js.map +1 -0
- package/dist/react/renderers/email.js +34 -0
- package/dist/react/renderers/email.js.map +1 -0
- package/dist/react/renderers/file.js +107 -0
- package/dist/react/renderers/file.js.map +1 -0
- package/dist/react/renderers/index.d.ts +8 -0
- package/dist/react/renderers/index.js +35 -0
- package/dist/react/renderers/index.js.map +1 -0
- package/dist/react/renderers/message.js +41 -0
- package/dist/react/renderers/message.js.map +1 -0
- package/dist/react/renderers/number.js +37 -0
- package/dist/react/renderers/number.js.map +1 -0
- 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 +35 -0
- package/dist/react/renderers/select.js.map +1 -0
- package/dist/react/renderers/text.js +34 -0
- package/dist/react/renderers/text.js.map +1 -0
- package/dist/react/renderers/textarea.js +33 -0
- package/dist/react/renderers/textarea.js.map +1 -0
- package/dist/react/resolveForm.js +16 -0
- package/dist/react/resolveForm.js.map +1 -0
- package/dist/react/state.d.ts +52 -0
- package/dist/react/state.js +125 -0
- package/dist/react/state.js.map +1 -0
- package/dist/react/submitForm.d.ts +31 -0
- package/dist/react/submitForm.js +58 -0
- package/dist/react/submitForm.js.map +1 -0
- package/dist/react/uploadFile.d.ts +23 -0
- package/dist/react/uploadFile.js +39 -0
- package/dist/react/uploadFile.js.map +1 -0
- package/dist/react/useField.d.ts +13 -0
- package/dist/react/useField.js +49 -0
- package/dist/react/useField.js.map +1 -0
- package/dist/react/useFormState.d.ts +8 -0
- package/dist/react/useFormState.js +9 -0
- package/dist/react/useFormState.js.map +1 -0
- package/dist/react/useFormStep.d.ts +8 -0
- package/dist/react/useFormStep.js +9 -0
- package/dist/react/useFormStep.js.map +1 -0
- package/dist/react/validateField.js +27 -0
- package/dist/react/validateField.js.map +1 -0
- package/dist/recall/interpolate.d.ts +11 -0
- package/dist/recall/interpolate.js +17 -0
- package/dist/recall/interpolate.js.map +1 -0
- package/dist/recall/resolver.d.ts +22 -0
- package/dist/recall/resolver.js +48 -0
- package/dist/recall/resolver.js.map +1 -0
- package/dist/spam/captcha.d.ts +13 -0
- package/dist/spam/captcha.js +12 -0
- package/dist/spam/captcha.js.map +1 -0
- package/dist/spam/clientIp.js +9 -0
- package/dist/spam/clientIp.js.map +1 -0
- package/dist/spam/constants.d.ts +12 -0
- package/dist/spam/constants.js +21 -0
- package/dist/spam/constants.js.map +1 -0
- package/dist/spam/identify.d.ts +12 -0
- package/dist/spam/identify.js +17 -0
- package/dist/spam/identify.js.map +1 -0
- 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/rateLimiter.d.ts +18 -0
- package/dist/spam/rateLimiter.js +41 -0
- package/dist/spam/rateLimiter.js.map +1 -0
- package/dist/spam/reserved.js +30 -0
- package/dist/spam/reserved.js.map +1 -0
- package/dist/spam/resolveSpam.d.ts +12 -0
- package/dist/spam/resolveSpam.js +43 -0
- package/dist/spam/resolveSpam.js.map +1 -0
- package/dist/spam/spamGuard.js +81 -0
- package/dist/spam/spamGuard.js.map +1 -0
- package/dist/spam/types.d.ts +88 -0
- package/dist/spam/uploadHooks.js +33 -0
- package/dist/spam/uploadHooks.js.map +1 -0
- package/dist/submissions/SubmissionAnswers.d.ts +14 -0
- package/dist/submissions/SubmissionAnswers.js +137 -0
- package/dist/submissions/SubmissionAnswers.js.map +1 -0
- 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 +306 -0
- package/dist/submissions/runSubmission.js.map +1 -0
- package/dist/submissions/types.d.ts +41 -0
- package/dist/submissions/validateSubmission.js +110 -0
- package/dist/submissions/validateSubmission.js.map +1 -0
- 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.d.ts +12 -0
- package/dist/translations/en.js +309 -0
- package/dist/translations/en.js.map +1 -0
- package/dist/translations/index.d.ts +23 -0
- package/dist/translations/index.js +37 -0
- package/dist/translations/index.js.map +1 -0
- package/dist/translations/keys.d.ts +308 -0
- package/dist/translations/keys.js +308 -0
- package/dist/translations/keys.js.map +1 -0
- package/dist/translations/makeTranslate.d.ts +15 -0
- package/dist/translations/makeTranslate.js +20 -0
- package/dist/translations/makeTranslate.js.map +1 -0
- package/dist/translations/server.js +32 -0
- package/dist/translations/server.js.map +1 -0
- package/dist/translations/useTranslation.js +12 -0
- package/dist/translations/useTranslation.js.map +1 -0
- package/dist/uploads/captureFileRef.d.ts +34 -0
- package/dist/uploads/captureFileRef.js +43 -0
- package/dist/uploads/captureFileRef.js.map +1 -0
- 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.d.ts +26 -0
- package/dist/uploads/resolveFileRef.js +45 -0
- package/dist/uploads/resolveFileRef.js.map +1 -0
- package/dist/uploads/types.d.ts +19 -0
- package/dist/validation/buildRuleBlocks.js +47 -0
- package/dist/validation/buildRuleBlocks.js.map +1 -0
- package/dist/validation/builtin/email.js +20 -0
- package/dist/validation/builtin/email.js.map +1 -0
- package/dist/validation/builtin/index.d.ts +14 -0
- package/dist/validation/builtin/index.js +38 -0
- package/dist/validation/builtin/index.js.map +1 -0
- package/dist/validation/builtin/matchesField.js +16 -0
- package/dist/validation/builtin/matchesField.js.map +1 -0
- package/dist/validation/builtin/max.js +22 -0
- package/dist/validation/builtin/max.js.map +1 -0
- package/dist/validation/builtin/maxDate.js +24 -0
- package/dist/validation/builtin/maxDate.js.map +1 -0
- package/dist/validation/builtin/maxLength.js +27 -0
- package/dist/validation/builtin/maxLength.js.map +1 -0
- package/dist/validation/builtin/min.js +22 -0
- package/dist/validation/builtin/min.js.map +1 -0
- package/dist/validation/builtin/minDate.js +24 -0
- package/dist/validation/builtin/minDate.js.map +1 -0
- package/dist/validation/builtin/minLength.js +27 -0
- package/dist/validation/builtin/minLength.js.map +1 -0
- package/dist/validation/builtin/notAlreadySubmitted.js +34 -0
- package/dist/validation/builtin/notAlreadySubmitted.js.map +1 -0
- package/dist/validation/builtin/oneOf.js +35 -0
- package/dist/validation/builtin/oneOf.js.map +1 -0
- package/dist/validation/builtin/pattern.js +50 -0
- package/dist/validation/builtin/pattern.js.map +1 -0
- package/dist/validation/builtin/url.js +23 -0
- package/dist/validation/builtin/url.js.map +1 -0
- 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/defineValidationRule.d.ts +12 -0
- package/dist/validation/defineValidationRule.js +11 -0
- package/dist/validation/defineValidationRule.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/message.js +14 -0
- package/dist/validation/message.js.map +1 -0
- package/dist/validation/registry.d.ts +11 -0
- package/dist/validation/registry.js +13 -0
- package/dist/validation/registry.js.map +1 -0
- package/dist/validation/runValidation.js +90 -0
- package/dist/validation/runValidation.js.map +1 -0
- package/dist/validation/types.d.ts +70 -0
- package/dist/validation/validateUrl.js +22 -0
- package/dist/validation/validateUrl.js.map +1 -0
- package/package.json +12 -7
- package/styles/form-builder.css +21 -11
- package/dist/constants-B-BUfetP.d.ts +0 -288
- package/dist/exports/client.js.map +0 -1
- package/dist/exports/react.js.map +0 -1
- package/dist/exports/rsc.js.map +0 -1
- package/dist/fieldTypes-B8jkNRob.d.ts +0 -188
- package/dist/fieldTypes-CzhhJXjg.js.map +0 -1
- package/dist/index-DfFYGbVF.d.ts +0 -481
- package/dist/keys-N5xGiUsh.js +0 -132
- package/dist/keys-N5xGiUsh.js.map +0 -1
- package/dist/registry-CoCyhtvB.js +0 -282
- package/dist/registry-CoCyhtvB.js.map +0 -1
- package/dist/resolver-OeQyVH2N.js +0 -665
- package/dist/resolver-OeQyVH2N.js.map +0 -1
- package/dist/translations-edMqq_2e.js +0 -152
- package/dist/translations-edMqq_2e.js.map +0 -1
- package/dist/types-DsJ_6kGJ.d.ts +0 -23
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { keys } from "../translations/keys.js";
|
|
2
|
+
import { resolveMessage, withTimeout } from "./message.js";
|
|
3
|
+
//#region src/validation/runValidation.ts
|
|
4
|
+
const RULE_TIMEOUT_MS = 5e3;
|
|
5
|
+
const isEmpty = (value) => value == null || value === "" || Array.isArray(value) && value.length === 0;
|
|
6
|
+
/** Build the per-instance message resolver: custom override (a literal template) or the localized default. */
|
|
7
|
+
const makeMessage = (instance, defaultMessageKey, t) => {
|
|
8
|
+
const { blockType: _blockType, message: _message, ...params } = instance;
|
|
9
|
+
const template = typeof instance.message === "string" && instance.message.length > 0 ? instance.message : t(defaultMessageKey);
|
|
10
|
+
return (vars = {}) => resolveMessage(template, {
|
|
11
|
+
...params,
|
|
12
|
+
...vars
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* The one validation engine, run per field on client and server. Order: required, the field type's
|
|
17
|
+
* intrinsic validator, then each declarative rule instance. Server-only rules are skipped in client
|
|
18
|
+
* mode; every rule is wrapped in try/catch + a timeout so a bad rule cannot crash or stall the submit
|
|
19
|
+
* path (a thrown or timed-out rule fails open, logged on the server). Every returned message is a
|
|
20
|
+
* blocking error.
|
|
21
|
+
*/
|
|
22
|
+
const runValidation = async (input) => {
|
|
23
|
+
const { field, fieldDefinition, value, fieldType, ruleRegistry, answers, locale, t, operation, event, mode, req, payload, formId, timeoutMs } = input;
|
|
24
|
+
const timeout = timeoutMs ?? RULE_TIMEOUT_MS;
|
|
25
|
+
const errors = [];
|
|
26
|
+
if (field.required && isEmpty(value)) return { errors: [t(keys.validationRequired)] };
|
|
27
|
+
if (isEmpty(value) && field.blockType !== "repeater") return { errors: [] };
|
|
28
|
+
if (fieldDefinition?.validate) try {
|
|
29
|
+
const ran = fieldDefinition.validate({
|
|
30
|
+
value,
|
|
31
|
+
config: field,
|
|
32
|
+
siblingData: answers,
|
|
33
|
+
data: answers,
|
|
34
|
+
locale,
|
|
35
|
+
t
|
|
36
|
+
});
|
|
37
|
+
const result = ran instanceof Promise ? await withTimeout(ran, timeout, true) : ran;
|
|
38
|
+
if (result !== true) errors.push(result);
|
|
39
|
+
} catch (error) {
|
|
40
|
+
req?.payload?.logger?.error?.({
|
|
41
|
+
err: error,
|
|
42
|
+
field: field.name
|
|
43
|
+
}, "form-builder intrinsic field validator threw");
|
|
44
|
+
}
|
|
45
|
+
if (fieldDefinition?.schema) try {
|
|
46
|
+
const outcome = await fieldDefinition.schema["~standard"].validate(value);
|
|
47
|
+
if (outcome.issues) for (const issue of outcome.issues) errors.push(issue.message);
|
|
48
|
+
} catch (error) {
|
|
49
|
+
req?.payload?.logger?.error?.({
|
|
50
|
+
err: error,
|
|
51
|
+
field: field.name
|
|
52
|
+
}, "form-builder field schema threw");
|
|
53
|
+
}
|
|
54
|
+
const instances = Array.isArray(field.validations) ? field.validations : [];
|
|
55
|
+
for (const instance of instances) {
|
|
56
|
+
const rule = ruleRegistry.get(instance.blockType);
|
|
57
|
+
if (!rule) continue;
|
|
58
|
+
if (mode === "client" && rule.client === false) continue;
|
|
59
|
+
const message = makeMessage(instance, rule.defaultMessage, t);
|
|
60
|
+
try {
|
|
61
|
+
const ran = rule.validate({
|
|
62
|
+
value,
|
|
63
|
+
params: instance,
|
|
64
|
+
siblingData: answers,
|
|
65
|
+
data: answers,
|
|
66
|
+
field,
|
|
67
|
+
fieldType,
|
|
68
|
+
operation,
|
|
69
|
+
event,
|
|
70
|
+
locale,
|
|
71
|
+
message,
|
|
72
|
+
req: mode === "server" ? req : void 0,
|
|
73
|
+
payload: mode === "server" ? payload : void 0,
|
|
74
|
+
formId: mode === "server" ? formId : void 0
|
|
75
|
+
});
|
|
76
|
+
const result = ran instanceof Promise ? await withTimeout(ran, timeout, true) : ran;
|
|
77
|
+
if (result !== true) errors.push(result);
|
|
78
|
+
} catch (error) {
|
|
79
|
+
req?.payload?.logger?.error?.({
|
|
80
|
+
err: error,
|
|
81
|
+
rule: rule.type
|
|
82
|
+
}, "form-builder validation rule threw");
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return { errors };
|
|
86
|
+
};
|
|
87
|
+
//#endregion
|
|
88
|
+
export { runValidation };
|
|
89
|
+
|
|
90
|
+
//# sourceMappingURL=runValidation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runValidation.js","names":[],"sources":["../../src/validation/runValidation.ts"],"sourcesContent":["import type { Payload, PayloadRequest } from 'payload'\nimport type { AnyFormFieldDefinition, Translate } from '../fields/types'\nimport type { FormFieldInstance } from '../submissions/types'\nimport { keys } from '../translations/keys'\nimport { resolveMessage, withTimeout } from './message'\nimport type { ValidationRuleRegistry } from './registry'\nimport type { MessageFn } from './types'\n\nconst RULE_TIMEOUT_MS = 5000\n\nexport type RunValidationInput = {\n\tfield: FormFieldInstance\n\tfieldDefinition?: AnyFormFieldDefinition\n\tvalue: unknown\n\tfieldType: string\n\truleRegistry: ValidationRuleRegistry\n\tanswers: Record<string, unknown>\n\tlocale: string\n\tt: Translate\n\toperation: 'create' | 'update'\n\tevent: 'onChange' | 'submit'\n\tmode: 'client' | 'server'\n\treq?: PayloadRequest\n\tpayload?: Payload\n\tformId?: number | string\n\t/** Override the per-rule timeout in ms. Defaults to RULE_TIMEOUT_MS; primarily for tests. */\n\ttimeoutMs?: number\n}\n\nexport type RunValidationResult = { errors: string[] }\n\nconst isEmpty = (value: unknown): boolean =>\n\tvalue == null || value === '' || (Array.isArray(value) && value.length === 0)\n\ntype RuleInstance = { blockType: string; message?: string } & Record<string, unknown>\n\n/** Build the per-instance message resolver: custom override (a literal template) or the localized default. */\nconst makeMessage = (\n\tinstance: RuleInstance,\n\tdefaultMessageKey: string,\n\tt: Translate\n): MessageFn => {\n\tconst { blockType: _blockType, message: _message, ...params } = instance\n\tconst template =\n\t\ttypeof instance.message === 'string' && instance.message.length > 0\n\t\t\t? instance.message\n\t\t\t: t(defaultMessageKey)\n\treturn (vars = {}) => resolveMessage(template, { ...params, ...vars })\n}\n\n/**\n * The one validation engine, run per field on client and server. Order: required, the field type's\n * intrinsic validator, then each declarative rule instance. Server-only rules are skipped in client\n * mode; every rule is wrapped in try/catch + a timeout so a bad rule cannot crash or stall the submit\n * path (a thrown or timed-out rule fails open, logged on the server). Every returned message is a\n * blocking error.\n */\nexport const runValidation = async (input: RunValidationInput): Promise<RunValidationResult> => {\n\tconst {\n\t\tfield,\n\t\tfieldDefinition,\n\t\tvalue,\n\t\tfieldType,\n\t\truleRegistry,\n\t\tanswers,\n\t\tlocale,\n\t\tt,\n\t\toperation,\n\t\tevent,\n\t\tmode,\n\t\treq,\n\t\tpayload,\n\t\tformId,\n\t\ttimeoutMs,\n\t} = input\n\tconst timeout = timeoutMs ?? RULE_TIMEOUT_MS\n\tconst errors: string[] = []\n\n\tif (field.required && isEmpty(value)) {\n\t\treturn { errors: [t(keys.validationRequired)] }\n\t}\n\t// Repeaters coerced to [] must reach fieldDefinition.validate so minRows is enforced;\n\t// all other empty fields have no intrinsic rules to run.\n\tif (isEmpty(value) && field.blockType !== 'repeater') {\n\t\treturn { errors: [] }\n\t}\n\n\tif (fieldDefinition?.validate) {\n\t\ttry {\n\t\t\tconst ran = fieldDefinition.validate({\n\t\t\t\tvalue,\n\t\t\t\tconfig: field,\n\t\t\t\tsiblingData: answers,\n\t\t\t\tdata: answers,\n\t\t\t\tlocale,\n\t\t\t\tt,\n\t\t\t})\n\t\t\tconst result = ran instanceof Promise ? await withTimeout(ran, timeout, true) : ran\n\t\t\tif (result !== true) {\n\t\t\t\terrors.push(result)\n\t\t\t}\n\t\t} catch (error) {\n\t\t\treq?.payload?.logger?.error?.(\n\t\t\t\t{ err: error, field: field.name },\n\t\t\t\t'form-builder intrinsic field validator threw'\n\t\t\t)\n\t\t}\n\t}\n\n\tif (fieldDefinition?.schema) {\n\t\ttry {\n\t\t\tconst outcome = await fieldDefinition.schema['~standard'].validate(value)\n\t\t\tif (outcome.issues) {\n\t\t\t\tfor (const issue of outcome.issues) {\n\t\t\t\t\terrors.push(issue.message)\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (error) {\n\t\t\treq?.payload?.logger?.error?.(\n\t\t\t\t{ err: error, field: field.name },\n\t\t\t\t'form-builder field schema threw'\n\t\t\t)\n\t\t}\n\t}\n\n\tconst instances = (Array.isArray(field.validations) ? field.validations : []) as RuleInstance[]\n\tfor (const instance of instances) {\n\t\tconst rule = ruleRegistry.get(instance.blockType)\n\t\tif (!rule) {\n\t\t\tcontinue\n\t\t}\n\t\tif (mode === 'client' && rule.client === false) {\n\t\t\tcontinue\n\t\t}\n\t\tconst message = makeMessage(instance, rule.defaultMessage, t)\n\t\ttry {\n\t\t\tconst ran = rule.validate({\n\t\t\t\tvalue,\n\t\t\t\tparams: instance,\n\t\t\t\tsiblingData: answers,\n\t\t\t\tdata: answers,\n\t\t\t\tfield,\n\t\t\t\tfieldType,\n\t\t\t\toperation,\n\t\t\t\tevent,\n\t\t\t\tlocale,\n\t\t\t\tmessage,\n\t\t\t\treq: mode === 'server' ? req : undefined,\n\t\t\t\tpayload: mode === 'server' ? payload : undefined,\n\t\t\t\tformId: mode === 'server' ? formId : undefined,\n\t\t\t})\n\t\t\tconst result = ran instanceof Promise ? await withTimeout(ran, timeout, true) : ran\n\t\t\tif (result !== true) {\n\t\t\t\terrors.push(result)\n\t\t\t}\n\t\t} catch (error) {\n\t\t\treq?.payload?.logger?.error?.(\n\t\t\t\t{ err: error, rule: rule.type },\n\t\t\t\t'form-builder validation rule threw'\n\t\t\t)\n\t\t}\n\t}\n\n\treturn { errors }\n}\n"],"mappings":";;;AAQA,MAAM,kBAAkB;AAuBxB,MAAM,WAAW,UAChB,SAAS,QAAQ,UAAU,MAAO,MAAM,QAAQ,KAAK,KAAK,MAAM,WAAW;;AAK5E,MAAM,eACL,UACA,mBACA,MACe;CACf,MAAM,EAAE,WAAW,YAAY,SAAS,UAAU,GAAG,WAAW;CAChE,MAAM,WACL,OAAO,SAAS,YAAY,YAAY,SAAS,QAAQ,SAAS,IAC/D,SAAS,UACT,EAAE,iBAAiB;CACvB,QAAQ,OAAO,CAAC,MAAM,eAAe,UAAU;EAAE,GAAG;EAAQ,GAAG;CAAK,CAAC;AACtE;;;;;;;;AASA,MAAa,gBAAgB,OAAO,UAA4D;CAC/F,MAAM,EACL,OACA,iBACA,OACA,WACA,cACA,SACA,QACA,GACA,WACA,OACA,MACA,KACA,SACA,QACA,cACG;CACJ,MAAM,UAAU,aAAa;CAC7B,MAAM,SAAmB,CAAC;CAE1B,IAAI,MAAM,YAAY,QAAQ,KAAK,GAClC,OAAO,EAAE,QAAQ,CAAC,EAAE,KAAK,kBAAkB,CAAC,EAAE;CAI/C,IAAI,QAAQ,KAAK,KAAK,MAAM,cAAc,YACzC,OAAO,EAAE,QAAQ,CAAC,EAAE;CAGrB,IAAI,iBAAiB,UACpB,IAAI;EACH,MAAM,MAAM,gBAAgB,SAAS;GACpC;GACA,QAAQ;GACR,aAAa;GACb,MAAM;GACN;GACA;EACD,CAAC;EACD,MAAM,SAAS,eAAe,UAAU,MAAM,YAAY,KAAK,SAAS,IAAI,IAAI;EAChF,IAAI,WAAW,MACd,OAAO,KAAK,MAAM;CAEpB,SAAS,OAAO;EACf,KAAK,SAAS,QAAQ,QACrB;GAAE,KAAK;GAAO,OAAO,MAAM;EAAK,GAChC,8CACD;CACD;CAGD,IAAI,iBAAiB,QACpB,IAAI;EACH,MAAM,UAAU,MAAM,gBAAgB,OAAO,aAAa,SAAS,KAAK;EACxE,IAAI,QAAQ,QACX,KAAK,MAAM,SAAS,QAAQ,QAC3B,OAAO,KAAK,MAAM,OAAO;CAG5B,SAAS,OAAO;EACf,KAAK,SAAS,QAAQ,QACrB;GAAE,KAAK;GAAO,OAAO,MAAM;EAAK,GAChC,iCACD;CACD;CAGD,MAAM,YAAa,MAAM,QAAQ,MAAM,WAAW,IAAI,MAAM,cAAc,CAAC;CAC3E,KAAK,MAAM,YAAY,WAAW;EACjC,MAAM,OAAO,aAAa,IAAI,SAAS,SAAS;EAChD,IAAI,CAAC,MACJ;EAED,IAAI,SAAS,YAAY,KAAK,WAAW,OACxC;EAED,MAAM,UAAU,YAAY,UAAU,KAAK,gBAAgB,CAAC;EAC5D,IAAI;GACH,MAAM,MAAM,KAAK,SAAS;IACzB;IACA,QAAQ;IACR,aAAa;IACb,MAAM;IACN;IACA;IACA;IACA;IACA;IACA;IACA,KAAK,SAAS,WAAW,MAAM,KAAA;IAC/B,SAAS,SAAS,WAAW,UAAU,KAAA;IACvC,QAAQ,SAAS,WAAW,SAAS,KAAA;GACtC,CAAC;GACD,MAAM,SAAS,eAAe,UAAU,MAAM,YAAY,KAAK,SAAS,IAAI,IAAI;GAChF,IAAI,WAAW,MACd,OAAO,KAAK,MAAM;EAEpB,SAAS,OAAO;GACf,KAAK,SAAS,QAAQ,QACrB;IAAE,KAAK;IAAO,MAAM,KAAK;GAAK,GAC9B,oCACD;EACD;CACD;CAEA,OAAO,EAAE,OAAO;AACjB"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { FormFieldInstance } from "../submissions/types.js";
|
|
2
|
+
import { Field, Payload, PayloadRequest } from "payload";
|
|
3
|
+
|
|
4
|
+
//#region src/validation/types.d.ts
|
|
5
|
+
/** A rule outcome: pass (`true`) or a blocking error message. */
|
|
6
|
+
type ValidationRuleResult = true | string;
|
|
7
|
+
/** Resolves this rule instance's message (custom override or localized default) with `{var}` interpolation. */
|
|
8
|
+
type MessageFn = (vars?: Record<string, unknown>) => string;
|
|
9
|
+
/** Resolved per-instance rule params (loose at the DB boundary, narrowed by the author's generic). */
|
|
10
|
+
type ValidationParams = Record<string, unknown>;
|
|
11
|
+
type ValidationRuleValidateArgs<TParams extends ValidationParams, TValue, TData extends Record<string, unknown> = Record<string, unknown>> = {
|
|
12
|
+
value: TValue | null | undefined;
|
|
13
|
+
params: TParams;
|
|
14
|
+
siblingData: TData;
|
|
15
|
+
data: TData;
|
|
16
|
+
field: FormFieldInstance;
|
|
17
|
+
fieldType: string;
|
|
18
|
+
operation: 'create' | 'update';
|
|
19
|
+
event: 'onChange' | 'submit';
|
|
20
|
+
locale: string;
|
|
21
|
+
message: MessageFn; /** Server only. Absent in the client (req-less) context, so a server-only rule cannot run there. */
|
|
22
|
+
req?: PayloadRequest;
|
|
23
|
+
payload?: Payload; /** Server only. The form being submitted, for form-scoped lookups (e.g. notAlreadySubmitted). */
|
|
24
|
+
formId?: number | string;
|
|
25
|
+
};
|
|
26
|
+
type ValidationRuleValidate<TParams extends ValidationParams, TValue, TData extends Record<string, unknown> = Record<string, unknown>> = (args: ValidationRuleValidateArgs<TParams, TValue, TData>) => Promise<ValidationRuleResult> | ValidationRuleResult;
|
|
27
|
+
/**
|
|
28
|
+
* A validation rule type, authored once. `params` is a Payload `Field[]` rendered in the per-field
|
|
29
|
+
* constraint list; `validate` returns `true | string`. `client` defaults from
|
|
30
|
+
* whether the rule is pure (a rule that is async or uses `req`/`payload` must set `client: false`).
|
|
31
|
+
*/
|
|
32
|
+
type ValidationRuleDefinition<TParams extends ValidationParams = ValidationParams, TValue = unknown, TData extends Record<string, unknown> = Record<string, unknown>> = {
|
|
33
|
+
type: string;
|
|
34
|
+
label: string;
|
|
35
|
+
description?: string; /** Field type slugs this rule may be added to. Omit for all field types. */
|
|
36
|
+
appliesTo?: string[];
|
|
37
|
+
params?: Field[];
|
|
38
|
+
defaultMessage: string; /** Runs client-side too. Defaults to `true`; set `false` for async or `req`/`payload`-using rules. */
|
|
39
|
+
client?: boolean;
|
|
40
|
+
validate: ValidationRuleValidate<TParams, TValue, TData>;
|
|
41
|
+
};
|
|
42
|
+
/** Erased shape stored in the heterogeneous registry; params re-narrow per matched rule at execution. */
|
|
43
|
+
type AnyValidationRuleValidate = (args: {
|
|
44
|
+
value: unknown;
|
|
45
|
+
params: ValidationParams;
|
|
46
|
+
siblingData: Record<string, unknown>;
|
|
47
|
+
data: Record<string, unknown>;
|
|
48
|
+
field: FormFieldInstance;
|
|
49
|
+
fieldType: string;
|
|
50
|
+
operation: 'create' | 'update';
|
|
51
|
+
event: 'onChange' | 'submit';
|
|
52
|
+
locale: string;
|
|
53
|
+
message: MessageFn;
|
|
54
|
+
req?: PayloadRequest;
|
|
55
|
+
payload?: Payload;
|
|
56
|
+
formId?: number | string;
|
|
57
|
+
}) => Promise<ValidationRuleResult> | ValidationRuleResult;
|
|
58
|
+
type AnyValidationRuleDefinition = {
|
|
59
|
+
type: string;
|
|
60
|
+
label: string;
|
|
61
|
+
description?: string;
|
|
62
|
+
appliesTo?: string[];
|
|
63
|
+
params?: Field[];
|
|
64
|
+
defaultMessage: string;
|
|
65
|
+
client?: boolean;
|
|
66
|
+
validate: AnyValidationRuleValidate;
|
|
67
|
+
};
|
|
68
|
+
//#endregion
|
|
69
|
+
export { AnyValidationRuleDefinition, ValidationParams, ValidationRuleDefinition, ValidationRuleResult };
|
|
70
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { keys } from "../translations/keys.js";
|
|
2
|
+
import { asTranslate } from "../translations/server.js";
|
|
3
|
+
//#region src/validation/validateUrl.ts
|
|
4
|
+
/**
|
|
5
|
+
* Payload field validator for URL config fields (signed-webhook `url`, response redirect `url`):
|
|
6
|
+
* unset is fine (the consumer enforces presence where it matters), otherwise the value must parse
|
|
7
|
+
* as an absolute http(s) URL.
|
|
8
|
+
*/
|
|
9
|
+
const validateUrl = (value, { req }) => {
|
|
10
|
+
if (typeof value !== "string" || value.length === 0) return true;
|
|
11
|
+
let parsed;
|
|
12
|
+
try {
|
|
13
|
+
parsed = new URL(value);
|
|
14
|
+
} catch {
|
|
15
|
+
return asTranslate(req.t)(keys.validationUrlInvalid);
|
|
16
|
+
}
|
|
17
|
+
return parsed.protocol === "http:" || parsed.protocol === "https:" ? true : asTranslate(req.t)(keys.validationUrlInvalid);
|
|
18
|
+
};
|
|
19
|
+
//#endregion
|
|
20
|
+
export { validateUrl };
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=validateUrl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateUrl.js","names":[],"sources":["../../src/validation/validateUrl.ts"],"sourcesContent":["import type { PayloadRequest } from 'payload'\nimport { keys } from '../translations/keys'\nimport { asTranslate } from '../translations/server'\n\n/**\n * Payload field validator for URL config fields (signed-webhook `url`, response redirect `url`):\n * unset is fine (the consumer enforces presence where it matters), otherwise the value must parse\n * as an absolute http(s) URL.\n */\nexport const validateUrl = (\n\tvalue: unknown,\n\t{ req }: { data?: unknown; req: PayloadRequest }\n): string | true => {\n\tif (typeof value !== 'string' || value.length === 0) {\n\t\treturn true\n\t}\n\tlet parsed: URL\n\ttry {\n\t\tparsed = new URL(value)\n\t} catch {\n\t\treturn asTranslate(req.t)(keys.validationUrlInvalid)\n\t}\n\treturn parsed.protocol === 'http:' || parsed.protocol === 'https:'\n\t\t? true\n\t\t: asTranslate(req.t)(keys.validationUrlInvalid)\n}\n"],"mappings":";;;;;;;;AASA,MAAa,eACZ,OACA,EAAE,UACiB;CACnB,IAAI,OAAO,UAAU,YAAY,MAAM,WAAW,GACjD,OAAO;CAER,IAAI;CACJ,IAAI;EACH,SAAS,IAAI,IAAI,KAAK;CACvB,QAAQ;EACP,OAAO,YAAY,IAAI,CAAC,EAAE,KAAK,oBAAoB;CACpD;CACA,OAAO,OAAO,aAAa,WAAW,OAAO,aAAa,WACvD,OACA,YAAY,IAAI,CAAC,EAAE,KAAK,oBAAoB;AAChD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@10x-media/form-builder",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.10",
|
|
4
4
|
"description": "End-to-end forms platform for Payload: author, validate, render, collect, aggregate, and act.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -62,19 +62,21 @@
|
|
|
62
62
|
"LICENSE"
|
|
63
63
|
],
|
|
64
64
|
"peerDependencies": {
|
|
65
|
-
"@payloadcms/ui": "^3.
|
|
66
|
-
"payload": "^3.
|
|
65
|
+
"@payloadcms/ui": "^3.83.0",
|
|
66
|
+
"payload": "^3.83.0",
|
|
67
67
|
"react": "^19.0.0",
|
|
68
68
|
"react-dom": "^19.0.0"
|
|
69
69
|
},
|
|
70
|
+
"dependencies": {
|
|
71
|
+
"@standard-schema/spec": "^1.0.0"
|
|
72
|
+
},
|
|
70
73
|
"devDependencies": {
|
|
71
|
-
"shadcn": "^2.4.0",
|
|
72
74
|
"@axe-core/playwright": "^4.11.3",
|
|
73
75
|
"@payloadcms/db-mongodb": "3.85.0",
|
|
74
76
|
"@payloadcms/db-postgres": "3.85.0",
|
|
77
|
+
"@payloadcms/richtext-lexical": "3.85.0",
|
|
75
78
|
"@payloadcms/ui": "3.85.0",
|
|
76
79
|
"@playwright/test": "1.60.0",
|
|
77
|
-
"@standard-schema/spec": "^1.0.0",
|
|
78
80
|
"@testing-library/jest-dom": "^6.6.3",
|
|
79
81
|
"@testing-library/react": "^16.1.0",
|
|
80
82
|
"@types/node": "22.19.19",
|
|
@@ -82,16 +84,19 @@
|
|
|
82
84
|
"@types/react-dom": "19.2.3",
|
|
83
85
|
"axe-core": "^4.12.1",
|
|
84
86
|
"jsdom": "^25.0.1",
|
|
87
|
+
"msw": "^2.14.6",
|
|
85
88
|
"payload": "3.85.0",
|
|
86
89
|
"playwright": "1.60.0",
|
|
87
90
|
"react": "19.2.6",
|
|
88
91
|
"react-dom": "19.2.6",
|
|
92
|
+
"shadcn": "^2.4.0",
|
|
89
93
|
"tsdown": "0.22.1",
|
|
90
94
|
"typescript": "5.9.3",
|
|
91
95
|
"vitest": "4.1.7",
|
|
92
96
|
"@10x-media/payload-test-harness": "0.0.0",
|
|
97
|
+
"@10x-media/vitest-config": "0.0.0",
|
|
93
98
|
"@10x-media/tsconfig": "0.0.0",
|
|
94
|
-
"@10x-media/
|
|
99
|
+
"@10x-media/tsdown-config": "0.0.0"
|
|
95
100
|
},
|
|
96
101
|
"publishConfig": {
|
|
97
102
|
"access": "public"
|
|
@@ -105,7 +110,7 @@
|
|
|
105
110
|
"test": "vitest run",
|
|
106
111
|
"test:unit": "vitest run src",
|
|
107
112
|
"test:int": "vitest run tests/int",
|
|
108
|
-
"test:matrix": "DB_MATRIX=mongo vitest run tests/int/matrix.int.spec.ts && DB_MATRIX=postgres vitest run tests/int/matrix.int.spec.ts",
|
|
113
|
+
"test:matrix": "DB_MATRIX=mongo vitest run tests/int/matrix.int.spec.ts tests/int/messageResponse.int.spec.ts tests/int/pollAutoClose.int.spec.ts && DB_MATRIX=postgres vitest run tests/int/matrix.int.spec.ts tests/int/messageResponse.int.spec.ts tests/int/pollAutoClose.int.spec.ts",
|
|
109
114
|
"test:container": "TEST_DB=container DB_MATRIX=mongo vitest run tests/int/matrix.int.spec.ts && TEST_DB=container DB_MATRIX=postgres vitest run tests/int/matrix.int.spec.ts",
|
|
110
115
|
"test:e2e": "bash scripts/e2e.sh",
|
|
111
116
|
"dev": "pnpm --filter @10x-media/form-builder-dev dev",
|
package/styles/form-builder.css
CHANGED
|
@@ -7,37 +7,37 @@
|
|
|
7
7
|
gap: 1rem;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
.fb-form--grid > [data-width=
|
|
10
|
+
.fb-form--grid > [data-width="full"] {
|
|
11
11
|
grid-column: span 6;
|
|
12
12
|
}
|
|
13
|
-
.fb-form--grid > [data-width=
|
|
13
|
+
.fb-form--grid > [data-width="half"] {
|
|
14
14
|
grid-column: span 6;
|
|
15
15
|
}
|
|
16
|
-
.fb-form--grid > [data-width=
|
|
16
|
+
.fb-form--grid > [data-width="third"] {
|
|
17
17
|
grid-column: span 6;
|
|
18
18
|
}
|
|
19
|
-
.fb-form--grid > [data-width=
|
|
19
|
+
.fb-form--grid > [data-width="twoThirds"] {
|
|
20
20
|
grid-column: span 6;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
@container (min-width: 30rem) {
|
|
24
|
-
.fb-form--grid > [data-width=
|
|
24
|
+
.fb-form--grid > [data-width="half"] {
|
|
25
25
|
grid-column: span 3;
|
|
26
26
|
}
|
|
27
|
-
.fb-form--grid > [data-width=
|
|
27
|
+
.fb-form--grid > [data-width="third"] {
|
|
28
28
|
grid-column: span 2;
|
|
29
29
|
}
|
|
30
|
-
.fb-form--grid > [data-width=
|
|
30
|
+
.fb-form--grid > [data-width="twoThirds"] {
|
|
31
31
|
grid-column: span 4;
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
/* Presentations: density + overlay surfaces (page/inline carry no chrome). */
|
|
36
36
|
|
|
37
|
-
.fb-form-root[data-fb-density=
|
|
37
|
+
.fb-form-root[data-fb-density="compact"] .fb-form--grid {
|
|
38
38
|
gap: 0.5rem;
|
|
39
39
|
}
|
|
40
|
-
.fb-form-root[data-fb-presentation=
|
|
40
|
+
.fb-form-root[data-fb-presentation="page"] {
|
|
41
41
|
max-width: 40rem;
|
|
42
42
|
margin-inline: auto;
|
|
43
43
|
}
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
background: var(--fb-surface, #fff);
|
|
53
53
|
overflow: auto;
|
|
54
54
|
}
|
|
55
|
-
[data-fb-dialog=
|
|
55
|
+
[data-fb-dialog="modal"] {
|
|
56
56
|
inset: 50% auto auto 50%;
|
|
57
57
|
transform: translate(-50%, -50%);
|
|
58
58
|
width: min(32rem, calc(100vw - 2rem));
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
border-radius: 0.5rem;
|
|
61
61
|
padding: 1.5rem;
|
|
62
62
|
}
|
|
63
|
-
[data-fb-dialog=
|
|
63
|
+
[data-fb-dialog="drawer"] {
|
|
64
64
|
inset: 0 0 0 auto;
|
|
65
65
|
width: min(28rem, 100vw);
|
|
66
66
|
max-height: 100dvh;
|
|
@@ -101,6 +101,16 @@
|
|
|
101
101
|
height: 100%;
|
|
102
102
|
background: var(--fb-results-fill, currentColor);
|
|
103
103
|
}
|
|
104
|
+
.fb-results__bucket--winner {
|
|
105
|
+
font-weight: 600;
|
|
106
|
+
}
|
|
107
|
+
.fb-results__winner-badge {
|
|
108
|
+
margin-inline-start: 0.375rem;
|
|
109
|
+
font-size: 0.75em;
|
|
110
|
+
text-transform: uppercase;
|
|
111
|
+
letter-spacing: 0.05em;
|
|
112
|
+
opacity: 0.7;
|
|
113
|
+
}
|
|
104
114
|
.fb-results__total {
|
|
105
115
|
margin-block-start: 0.5rem;
|
|
106
116
|
opacity: 0.7;
|
|
@@ -1,288 +0,0 @@
|
|
|
1
|
-
import { n as AnyFormFieldDefinition } from "./fieldTypes-B8jkNRob.js";
|
|
2
|
-
import { Field, Payload, PayloadRequest, Where } from "payload";
|
|
3
|
-
|
|
4
|
-
//#region src/submissions/types.d.ts
|
|
5
|
-
/** A single answered field: the field's machine name and its typed value. */
|
|
6
|
-
type SubmissionValue = {
|
|
7
|
-
field: string;
|
|
8
|
-
value: unknown;
|
|
9
|
-
};
|
|
10
|
-
/** A localized, self-describing snapshot of an answered field, taken at submit time. */
|
|
11
|
-
type SubmissionDescriptor = {
|
|
12
|
-
field: string;
|
|
13
|
-
label: string;
|
|
14
|
-
fieldType: string;
|
|
15
|
-
optionLabels?: Record<string, string>;
|
|
16
|
-
};
|
|
17
|
-
/** A per-field validation failure (`path` is the field name, for renderer error mapping). */
|
|
18
|
-
type SubmissionFieldError = {
|
|
19
|
-
path: string;
|
|
20
|
-
message: string;
|
|
21
|
-
};
|
|
22
|
-
/** A field instance as stored in a form's `fields` blocks array (shared config plus type-specific keys). */
|
|
23
|
-
type FormFieldInstance = {
|
|
24
|
-
blockType: string;
|
|
25
|
-
name: string;
|
|
26
|
-
label?: string;
|
|
27
|
-
required?: boolean;
|
|
28
|
-
visibleWhen?: Where;
|
|
29
|
-
validateWhen?: Where;
|
|
30
|
-
[key: string]: unknown;
|
|
31
|
-
};
|
|
32
|
-
//#endregion
|
|
33
|
-
//#region src/aggregation/types.d.ts
|
|
34
|
-
/** Which submission statuses to count. `complete` (default) excludes partials; `all` counts everything. */
|
|
35
|
-
type SubmissionStatusFilter = 'complete' | 'partial' | 'all';
|
|
36
|
-
/** One answer option (or distinct value) with its tally. */
|
|
37
|
-
type AggregationBucket = {
|
|
38
|
-
/** The answer value, stringified (the grouping key). */value: string; /** Display label: current option label, else the submitted snapshot label, else the raw value. */
|
|
39
|
-
label: string;
|
|
40
|
-
count: number; /** Share of respondents, 0-100, rounded to one decimal. Can sum past 100 for multi-value fields. */
|
|
41
|
-
percentage: number;
|
|
42
|
-
};
|
|
43
|
-
/** Aggregated responses for one field across a form's submissions. */
|
|
44
|
-
type FieldAggregation = {
|
|
45
|
-
field: string;
|
|
46
|
-
label?: string;
|
|
47
|
-
fieldType?: string; /** Respondents: submissions with a non-empty answer for this field. The percentage denominator. */
|
|
48
|
-
total: number;
|
|
49
|
-
buckets: AggregationBucket[]; /** True when the `maxSubmissions` cap was hit, so the tallies are a (large) sample, not the full set. */
|
|
50
|
-
truncated: boolean;
|
|
51
|
-
};
|
|
52
|
-
/** The slice of a submission the reducer reads. */
|
|
53
|
-
type AggregationRow = {
|
|
54
|
-
values?: SubmissionValue[];
|
|
55
|
-
descriptors?: SubmissionDescriptor[];
|
|
56
|
-
};
|
|
57
|
-
/** Field metadata the reducer needs to label and order buckets, derived from the live form definition. */
|
|
58
|
-
type FieldMeta = {
|
|
59
|
-
field: string;
|
|
60
|
-
label?: string;
|
|
61
|
-
fieldType?: string; /** Ordered known options with current labels; drives bucket order and label resolution. */
|
|
62
|
-
options?: {
|
|
63
|
-
value: string;
|
|
64
|
-
label: string;
|
|
65
|
-
}[];
|
|
66
|
-
};
|
|
67
|
-
//#endregion
|
|
68
|
-
//#region src/calc/types.d.ts
|
|
69
|
-
/** A serializable, safe-by-construction calculation expression. No strings are parsed; the evaluator tree-walks this closed node set (never `eval`). */
|
|
70
|
-
type CalcExpression = {
|
|
71
|
-
type: 'lit';
|
|
72
|
-
value: number;
|
|
73
|
-
} | {
|
|
74
|
-
type: 'ref';
|
|
75
|
-
field: string;
|
|
76
|
-
} | {
|
|
77
|
-
type: 'op';
|
|
78
|
-
op: '+' | '-' | '*' | '/' | '%';
|
|
79
|
-
left: CalcExpression;
|
|
80
|
-
right: CalcExpression;
|
|
81
|
-
} | {
|
|
82
|
-
type: 'neg';
|
|
83
|
-
operand: CalcExpression;
|
|
84
|
-
} | {
|
|
85
|
-
type: 'fn';
|
|
86
|
-
fn: 'min' | 'max' | 'round' | 'abs' | 'ceil' | 'floor';
|
|
87
|
-
args: CalcExpression[];
|
|
88
|
-
} | {
|
|
89
|
-
type: 'weight';
|
|
90
|
-
field: string;
|
|
91
|
-
weights: Record<string, number>;
|
|
92
|
-
};
|
|
93
|
-
//#endregion
|
|
94
|
-
//#region src/calc/computeCalcFields.d.ts
|
|
95
|
-
/** Returns the calc expression if the field carries one (non-null object), otherwise undefined. */
|
|
96
|
-
declare const calcExpressionOf: (field: FormFieldInstance) => CalcExpression | undefined;
|
|
97
|
-
/**
|
|
98
|
-
* Returns answers with every calc field's value derived from its expression,
|
|
99
|
-
* folded in declaration order so a calc may reference an earlier calc's result.
|
|
100
|
-
* Identity when no field carries an expression.
|
|
101
|
-
*/
|
|
102
|
-
declare const computeCalcFields: (fields: FormFieldInstance[], answers: Record<string, unknown>) => Record<string, unknown>;
|
|
103
|
-
//#endregion
|
|
104
|
-
//#region src/calc/evaluate.d.ts
|
|
105
|
-
/** Evaluate a calc expression against form answers. Total + safe: no `eval`, always finite, div/mod by zero -> 0, missing ref -> 0, depth-guarded. Isomorphic (client + server). */
|
|
106
|
-
declare const evaluateCalc: (expr: CalcExpression | null | undefined, answers: Record<string, unknown>) => number;
|
|
107
|
-
//#endregion
|
|
108
|
-
//#region src/conditions/evaluate.d.ts
|
|
109
|
-
/**
|
|
110
|
-
* Evaluate a serializable `Where`-shaped condition against a flat map of (already coerced) form answers.
|
|
111
|
-
* An absent or empty condition matches (returns true). Operator semantics mirror Payload's query
|
|
112
|
-
* adapters: coerce then compare; `not_equals`/`not_in` are null-inclusive; `exists` treats `''`/absent
|
|
113
|
-
* as not-existing; `like` is case-insensitive and space-splits (every word must be a substring), and
|
|
114
|
-
* `not_like` is its logical negation (at least one word absent); `contains` is a single case-insensitive
|
|
115
|
-
* substring; comma-delimited `in`/`not_in` string values are split and trimmed. Geo (`near`/`within`/
|
|
116
|
-
* `intersects`) and `all` are out of scope and evaluate to false. Isomorphic: no `req`/DB access, so the
|
|
117
|
-
* renderer reuses it client-side.
|
|
118
|
-
*/
|
|
119
|
-
declare const evaluateCondition: (where: Where | null | undefined, answers: Record<string, unknown>) => boolean;
|
|
120
|
-
//#endregion
|
|
121
|
-
//#region src/fields/registry.d.ts
|
|
122
|
-
type FieldTypeRegistry = Map<string, AnyFormFieldDefinition>;
|
|
123
|
-
/** Per-type opt-in: `false` removes a built-in, `true` keeps it, an object adds a new type or replaces one. */
|
|
124
|
-
type FieldTypeOption = boolean | AnyFormFieldDefinition;
|
|
125
|
-
type FieldTypesConfig = Record<string, FieldTypeOption>;
|
|
126
|
-
//#endregion
|
|
127
|
-
//#region src/prefill/valuesFromSearchParams.d.ts
|
|
128
|
-
type PrefillOptions = {
|
|
129
|
-
/** Map a query-param name to a field name. Unmapped params use their own name. */map?: Record<string, string>; /** If set, only these field names may be prefilled. */
|
|
130
|
-
allow?: string[]; /** These field names may never be prefilled. */
|
|
131
|
-
deny?: string[];
|
|
132
|
-
};
|
|
133
|
-
/**
|
|
134
|
-
* Map URL/query params to typed initial values for KNOWN fields only, coerced by each field's value
|
|
135
|
-
* kind. Unknown, denied, or un-allowed params are ignored; invalid numbers are dropped. Prefilled
|
|
136
|
-
* values are never trusted -- they still validate on submit. Pass the result to `<Form initialValues>`.
|
|
137
|
-
*/
|
|
138
|
-
declare const valuesFromSearchParams: (params: URLSearchParams | Record<string, string>, fields: FormFieldInstance[], registry: FieldTypeRegistry, options?: PrefillOptions) => Record<string, unknown>;
|
|
139
|
-
//#endregion
|
|
140
|
-
//#region src/events/types.d.ts
|
|
141
|
-
type FormEventBase = {
|
|
142
|
-
formId: string;
|
|
143
|
-
at: string;
|
|
144
|
-
};
|
|
145
|
-
type FormEvent = (FormEventBase & {
|
|
146
|
-
type: 'form.viewed';
|
|
147
|
-
}) | (FormEventBase & {
|
|
148
|
-
type: 'form.started';
|
|
149
|
-
}) | (FormEventBase & {
|
|
150
|
-
type: 'step.viewed';
|
|
151
|
-
stepId: string;
|
|
152
|
-
}) | (FormEventBase & {
|
|
153
|
-
type: 'step.completed';
|
|
154
|
-
stepId: string;
|
|
155
|
-
}) | (FormEventBase & {
|
|
156
|
-
type: 'field.errored';
|
|
157
|
-
field: string;
|
|
158
|
-
message: string;
|
|
159
|
-
}) | (FormEventBase & {
|
|
160
|
-
type: 'form.abandoned';
|
|
161
|
-
}) | (FormEventBase & {
|
|
162
|
-
type: 'submission.created';
|
|
163
|
-
submissionId?: string;
|
|
164
|
-
});
|
|
165
|
-
type FormEventSink = {
|
|
166
|
-
emit: (event: FormEvent) => Promise<void> | void;
|
|
167
|
-
};
|
|
168
|
-
//#endregion
|
|
169
|
-
//#region src/validation/types.d.ts
|
|
170
|
-
type ValidationSeverity = 'error' | 'warning';
|
|
171
|
-
/** A rule outcome: pass, a plain error string, or an explicit message + severity. */
|
|
172
|
-
type ValidationRuleResult = true | string | {
|
|
173
|
-
message: string;
|
|
174
|
-
severity?: ValidationSeverity;
|
|
175
|
-
};
|
|
176
|
-
/** Resolves this rule instance's message (custom override or localized default) with `{var}` interpolation. */
|
|
177
|
-
type MessageFn = (vars?: Record<string, unknown>) => string;
|
|
178
|
-
/** Resolved per-instance rule params (loose at the DB boundary, narrowed by the author's generic). */
|
|
179
|
-
type ValidationParams = Record<string, unknown>;
|
|
180
|
-
type ValidationRuleValidateArgs<TParams extends ValidationParams, TValue, TData extends Record<string, unknown> = Record<string, unknown>> = {
|
|
181
|
-
value: TValue | null | undefined;
|
|
182
|
-
params: TParams;
|
|
183
|
-
siblingData: TData;
|
|
184
|
-
data: TData;
|
|
185
|
-
field: FormFieldInstance;
|
|
186
|
-
fieldType: string;
|
|
187
|
-
operation: 'create' | 'update';
|
|
188
|
-
event: 'onChange' | 'submit';
|
|
189
|
-
locale: string;
|
|
190
|
-
message: MessageFn; /** Server only. Absent in the client (req-less) context, so a server-only rule cannot run there. */
|
|
191
|
-
req?: PayloadRequest;
|
|
192
|
-
payload?: Payload; /** Server only. The form being submitted, for form-scoped lookups (e.g. notAlreadySubmitted). */
|
|
193
|
-
formId?: number | string;
|
|
194
|
-
};
|
|
195
|
-
type ValidationRuleValidate<TParams extends ValidationParams, TValue, TData extends Record<string, unknown> = Record<string, unknown>> = (args: ValidationRuleValidateArgs<TParams, TValue, TData>) => Promise<ValidationRuleResult> | ValidationRuleResult;
|
|
196
|
-
/**
|
|
197
|
-
* A validation rule type, authored once. `params` is a Payload `Field[]` rendered in the per-field
|
|
198
|
-
* constraint list; `validate` returns `true | string | { message, severity }`. `client` defaults from
|
|
199
|
-
* whether the rule is pure (a rule that is async or uses `req`/`payload` must set `client: false`).
|
|
200
|
-
*/
|
|
201
|
-
type ValidationRuleDefinition<TParams extends ValidationParams = ValidationParams, TValue = unknown, TData extends Record<string, unknown> = Record<string, unknown>> = {
|
|
202
|
-
type: string;
|
|
203
|
-
label: string;
|
|
204
|
-
description?: string; /** Field type slugs this rule may be added to. Omit for all field types. */
|
|
205
|
-
appliesTo?: string[];
|
|
206
|
-
params?: Field[];
|
|
207
|
-
defaultMessage: string; /** Runs client-side too. Defaults to `true`; set `false` for async or `req`/`payload`-using rules. */
|
|
208
|
-
client?: boolean; /** Default severity when `validate` returns a bare string. Defaults to `error`. */
|
|
209
|
-
severity?: ValidationSeverity;
|
|
210
|
-
validate: ValidationRuleValidate<TParams, TValue, TData>;
|
|
211
|
-
};
|
|
212
|
-
/** Erased shape stored in the heterogeneous registry; params re-narrow per matched rule at execution. */
|
|
213
|
-
type AnyValidationRuleValidate = (args: {
|
|
214
|
-
value: unknown;
|
|
215
|
-
params: ValidationParams;
|
|
216
|
-
siblingData: Record<string, unknown>;
|
|
217
|
-
data: Record<string, unknown>;
|
|
218
|
-
field: FormFieldInstance;
|
|
219
|
-
fieldType: string;
|
|
220
|
-
operation: 'create' | 'update';
|
|
221
|
-
event: 'onChange' | 'submit';
|
|
222
|
-
locale: string;
|
|
223
|
-
message: MessageFn;
|
|
224
|
-
req?: PayloadRequest;
|
|
225
|
-
payload?: Payload;
|
|
226
|
-
formId?: number | string;
|
|
227
|
-
}) => Promise<ValidationRuleResult> | ValidationRuleResult;
|
|
228
|
-
type AnyValidationRuleDefinition = {
|
|
229
|
-
type: string;
|
|
230
|
-
label: string;
|
|
231
|
-
description?: string;
|
|
232
|
-
appliesTo?: string[];
|
|
233
|
-
params?: Field[];
|
|
234
|
-
defaultMessage: string;
|
|
235
|
-
client?: boolean;
|
|
236
|
-
severity?: ValidationSeverity;
|
|
237
|
-
validate: AnyValidationRuleValidate;
|
|
238
|
-
};
|
|
239
|
-
//#endregion
|
|
240
|
-
//#region src/presentations/types.d.ts
|
|
241
|
-
/** How a presentation surfaces the form. Drives wrapper selection and CSS. */
|
|
242
|
-
type PresentationSurface = 'inline' | 'page' | 'overlay';
|
|
243
|
-
type PresentationDensity = 'comfortable' | 'compact';
|
|
244
|
-
/**
|
|
245
|
-
* Serializable, framework-agnostic description of a presentation. The admin select and the
|
|
246
|
-
* stored `defaultPresentation` use only this; the React `Wrapper` is added in `./react`. No React here.
|
|
247
|
-
*/
|
|
248
|
-
type PresentationDescriptor = {
|
|
249
|
-
name: string; /** i18n key or literal shown in the admin select. */
|
|
250
|
-
label: string;
|
|
251
|
-
surface: PresentationSurface;
|
|
252
|
-
density: PresentationDensity; /** Overlay surfaces request dismissal after a successful submit. */
|
|
253
|
-
dismissOnSuccess?: boolean;
|
|
254
|
-
};
|
|
255
|
-
//#endregion
|
|
256
|
-
//#region src/recall/interpolate.d.ts
|
|
257
|
-
/**
|
|
258
|
-
* Replace `{{ name }}` and `{{ name|fallback }}` tokens. `resolve` returns the recalled value (''
|
|
259
|
-
* when absent); the fallback (or '') is substituted when `resolve` yields ''. Token-free input is
|
|
260
|
-
* returned unchanged, so this is a no-op for ordinary text.
|
|
261
|
-
*/
|
|
262
|
-
declare const interpolate: (template: string, resolve: (name: string) => string) => string;
|
|
263
|
-
//#endregion
|
|
264
|
-
//#region src/recall/resolver.d.ts
|
|
265
|
-
type RecallResolver = (name: string) => string;
|
|
266
|
-
/** Derive a value->label map from a select-like field instance's `options`. */
|
|
267
|
-
declare const optionLabelsFor: (field: FormFieldInstance) => Record<string, string> | undefined;
|
|
268
|
-
/**
|
|
269
|
-
* Build a recall resolver: `{{name}}` -> the field's current value, formatted via its type's `format`
|
|
270
|
-
* (so a select shows its option label, a checkbox Yes/No, a date localized). Missing field or empty
|
|
271
|
-
* value -> ''. Pure and isomorphic; the renderer and server templates share it.
|
|
272
|
-
*/
|
|
273
|
-
declare const buildRecallResolver: (args: {
|
|
274
|
-
fields: FormFieldInstance[];
|
|
275
|
-
values: Record<string, unknown>;
|
|
276
|
-
registry: Map<string, AnyFormFieldDefinition>;
|
|
277
|
-
locale: string;
|
|
278
|
-
t: (key: string) => string;
|
|
279
|
-
}) => RecallResolver;
|
|
280
|
-
//#endregion
|
|
281
|
-
//#region src/spam/constants.d.ts
|
|
282
|
-
/** Default honeypot decoy field name. Plausible to bots, unlikely to collide with a real field name. */
|
|
283
|
-
declare const DEFAULT_HONEYPOT_FIELD = "confirm_email";
|
|
284
|
-
/** Reserved `values` entry carrying a captcha token from the client. */
|
|
285
|
-
declare const CAPTCHA_TOKEN_KEY = "__fb_captcha";
|
|
286
|
-
//#endregion
|
|
287
|
-
export { FieldMeta as A, evaluateCalc as C, AggregationBucket as D, CalcExpression as E, SubmissionValue as F, FormFieldInstance as M, SubmissionDescriptor as N, AggregationRow as O, SubmissionFieldError as P, evaluateCondition as S, computeCalcFields as T, PrefillOptions as _, optionLabelsFor as a, FieldTypeRegistry as b, PresentationDescriptor as c, ValidationParams as d, ValidationRuleDefinition as f, FormEventSink as g, FormEvent as h, buildRecallResolver as i, SubmissionStatusFilter as j, FieldAggregation as k, PresentationSurface as l, ValidationSeverity as m, DEFAULT_HONEYPOT_FIELD as n, interpolate as o, ValidationRuleResult as p, RecallResolver as r, PresentationDensity as s, CAPTCHA_TOKEN_KEY as t, AnyValidationRuleDefinition as u, valuesFromSearchParams as v, calcExpressionOf as w, FieldTypesConfig as x, FieldTypeOption as y };
|
|
288
|
-
//# sourceMappingURL=constants-B-BUfetP.d.ts.map
|