@10x-media/form-builder 0.1.0-beta.0 → 0.1.0-beta.2
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 +68 -0
- package/README.md +45 -1402
- package/dist/actions/buildActionBlocks.js +19 -0
- package/dist/actions/buildActionBlocks.js.map +1 -0
- package/dist/actions/builtin/confirmation.js +49 -0
- package/dist/actions/builtin/confirmation.js.map +1 -0
- package/dist/actions/builtin/emailTeam.js +46 -0
- package/dist/actions/builtin/emailTeam.js.map +1 -0
- package/dist/actions/builtin/index.d.ts +7 -0
- package/dist/actions/builtin/index.js +13 -0
- package/dist/actions/builtin/index.js.map +1 -0
- package/dist/actions/builtin/signedWebhook.js +49 -0
- package/dist/actions/builtin/signedWebhook.js.map +1 -0
- package/dist/actions/defineAction.d.ts +36 -0
- package/dist/actions/defineAction.js +6 -0
- package/dist/actions/defineAction.js.map +1 -0
- package/dist/actions/dispatch.js +48 -0
- package/dist/actions/dispatch.js.map +1 -0
- package/dist/actions/registry.d.ts +16 -0
- package/dist/actions/registry.js +16 -0
- package/dist/actions/registry.js.map +1 -0
- package/dist/actions/runActions.d.ts +9 -0
- package/dist/actions/runActions.js +34 -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 +82 -0
- package/dist/actions/task.js.map +1 -0
- package/dist/aggregation/aggregateResponses.d.ts +31 -0
- package/dist/aggregation/aggregateResponses.js +86 -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 +32 -0
- package/dist/aggregation/resolveResultsRequest.js +56 -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 +27 -0
- package/dist/calc/computeCalcFields.js.map +1 -0
- package/dist/calc/evaluate.d.ts +8 -0
- package/dist/calc/evaluate.js +59 -0
- package/dist/calc/evaluate.js.map +1 -0
- package/dist/calc/normalizeCalc.d.ts +8 -0
- package/dist/calc/normalizeCalc.js +100 -0
- package/dist/calc/normalizeCalc.js.map +1 -0
- package/dist/calc/types.d.ts +28 -0
- package/dist/client/ConditionBuilder.js +121 -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/FlowBuilder.d.ts +15 -0
- package/dist/client/FlowBuilder.js +408 -0
- package/dist/client/FlowBuilder.js.map +1 -0
- package/dist/client/FormConditionField.d.ts +21 -0
- package/dist/client/FormConditionField.js +33 -0
- package/dist/client/FormConditionField.js.map +1 -0
- package/dist/client/synthesizeClientField.js +46 -0
- package/dist/client/synthesizeClientField.js.map +1 -0
- package/dist/collections/formSubmissions.js +157 -0
- package/dist/collections/formSubmissions.js.map +1 -0
- package/dist/collections/forms.js +198 -0
- package/dist/collections/forms.js.map +1 -0
- package/dist/collections/uploads.d.ts +30 -0
- package/dist/collections/uploads.js +55 -0
- package/dist/collections/uploads.js.map +1 -0
- package/dist/conditions/conditionType.js +14 -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 +9 -0
- package/dist/{fieldTypes-CzhhJXjg.js → conditions/fieldTypes.js} +2 -2
- package/dist/conditions/fieldTypes.js.map +1 -0
- package/dist/conditions/normalizeConditions.js +47 -0
- package/dist/conditions/normalizeConditions.js.map +1 -0
- package/dist/conditions/types.d.ts +8 -0
- package/dist/consent/buildConsentSourceConfig.js +49 -0
- package/dist/consent/buildConsentSourceConfig.js.map +1 -0
- package/dist/consent/builtin/index.d.ts +7 -0
- package/dist/consent/builtin/index.js +11 -0
- package/dist/consent/builtin/index.js.map +1 -0
- package/dist/consent/builtin/pageReference.js +75 -0
- package/dist/consent/builtin/pageReference.js.map +1 -0
- package/dist/consent/builtin/static.js +44 -0
- package/dist/consent/builtin/static.js.map +1 -0
- package/dist/consent/captureConsent.d.ts +28 -0
- package/dist/consent/captureConsent.js +26 -0
- package/dist/consent/captureConsent.js.map +1 -0
- package/dist/consent/defineConsentSource.d.ts +35 -0
- package/dist/consent/defineConsentSource.js +6 -0
- package/dist/consent/defineConsentSource.js.map +1 -0
- package/dist/consent/registry.d.ts +16 -0
- package/dist/consent/registry.js +16 -0
- package/dist/consent/registry.js.map +1 -0
- package/dist/consent/resolveConsentLinks.d.ts +19 -0
- package/dist/consent/resolveConsentLinks.js +26 -0
- package/dist/consent/resolveConsentLinks.js.map +1 -0
- package/dist/consent/resolvePublishedVersionRef.d.ts +17 -0
- package/dist/consent/resolvePublishedVersionRef.js +27 -0
- package/dist/consent/resolvePublishedVersionRef.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 +3 -21
- package/dist/exports/client.js +3 -319
- package/dist/exports/i18n.d.ts +3 -138
- package/dist/exports/i18n.js +2 -2
- package/dist/exports/react.d.ts +45 -550
- package/dist/exports/react.js +39 -1563
- package/dist/exports/rsc.d.ts +2 -16
- package/dist/exports/rsc.js +1 -54
- package/dist/exports/types.d.ts +28 -5
- package/dist/fields/buildFieldBlocks.js +60 -0
- package/dist/fields/buildFieldBlocks.js.map +1 -0
- package/dist/fields/builtin/calculation.js +24 -0
- package/dist/fields/builtin/calculation.js.map +1 -0
- package/dist/fields/builtin/checkbox.js +13 -0
- package/dist/fields/builtin/checkbox.js.map +1 -0
- package/dist/fields/builtin/consent.js +32 -0
- package/dist/fields/builtin/consent.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.js +40 -0
- package/dist/fields/builtin/file.js.map +1 -0
- package/dist/fields/builtin/index.js +27 -0
- package/dist/fields/builtin/index.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 +44 -0
- package/dist/fields/builtin/repeater.js.map +1 -0
- package/dist/fields/builtin/select.js +44 -0
- package/dist/fields/builtin/select.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/defineFormField.d.ts +13 -0
- package/dist/fields/defineFormField.js +12 -0
- package/dist/fields/defineFormField.js.map +1 -0
- package/dist/fields/registry.d.ts +10 -0
- package/dist/fields/registry.js +24 -0
- package/dist/fields/registry.js.map +1 -0
- package/dist/fields/sharedConfig.js +89 -0
- package/dist/fields/sharedConfig.js.map +1 -0
- package/dist/fields/types.d.ts +89 -0
- package/dist/flow/engine.d.ts +17 -0
- package/dist/flow/engine.js +24 -0
- package/dist/flow/engine.js.map +1 -0
- package/dist/flow/normalizeFlow.js +35 -0
- package/dist/flow/normalizeFlow.js.map +1 -0
- package/dist/{types-DsJ_6kGJ.d.ts → flow/types.d.ts} +2 -2
- package/dist/index.d.ts +93 -4
- package/dist/index.js +43 -1890
- package/dist/index.js.map +1 -1
- package/dist/plugin/access.js +12 -0
- package/dist/plugin/access.js.map +1 -0
- package/dist/plugin/collectionOverrides.d.ts +22 -0
- package/dist/plugin/registerCollections.js +68 -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/prefill/valuesFromSearchParams.d.ts +18 -0
- package/dist/prefill/valuesFromSearchParams.js +45 -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/registry.d.ts +15 -0
- package/dist/presentations/registry.js +15 -0
- package/dist/presentations/registry.js.map +1 -0
- package/dist/presentations/types.d.ts +18 -0
- package/dist/react/Form.d.ts +110 -0
- package/dist/react/Form.js +499 -0
- package/dist/react/Form.js.map +1 -0
- package/dist/react/FormContext.d.ts +16 -0
- package/dist/react/FormContext.js +14 -0
- package/dist/react/FormContext.js.map +1 -0
- package/dist/react/FormLayout.d.ts +20 -0
- package/dist/react/FormLayout.js +14 -0
- package/dist/react/FormLayout.js.map +1 -0
- package/dist/react/FormResults.d.ts +25 -0
- package/dist/react/FormResults.js +85 -0
- package/dist/react/FormResults.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 +32 -0
- package/dist/react/Poll.js +77 -0
- package/dist/react/Poll.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 +32 -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 +56 -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 +26 -0
- package/dist/react/primitives/Checkbox.js +20 -0
- package/dist/react/primitives/Checkbox.js.map +1 -0
- package/dist/react/primitives/FieldShell.d.ts +31 -0
- package/dist/react/primitives/FieldShell.js +51 -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 +30 -0
- package/dist/react/renderers/calculation.js.map +1 -0
- package/dist/react/renderers/checkbox.js +35 -0
- package/dist/react/renderers/checkbox.js.map +1 -0
- package/dist/react/renderers/consent.js +54 -0
- package/dist/react/renderers/consent.js.map +1 -0
- package/dist/react/renderers/email.js +37 -0
- package/dist/react/renderers/email.js.map +1 -0
- package/dist/react/renderers/file.js +92 -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 +28 -0
- package/dist/react/renderers/index.js.map +1 -0
- package/dist/react/renderers/number.js +40 -0
- package/dist/react/renderers/number.js.map +1 -0
- package/dist/react/renderers/repeater.js +113 -0
- package/dist/react/renderers/repeater.js.map +1 -0
- package/dist/react/renderers/select.js +38 -0
- package/dist/react/renderers/select.js.map +1 -0
- package/dist/react/renderers/text.js +37 -0
- package/dist/react/renderers/text.js.map +1 -0
- package/dist/react/renderers/textarea.js +36 -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 +15 -0
- package/dist/react/state.js +70 -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/toFormDocument.d.ts +24 -0
- package/dist/react/toFormDocument.js +22 -0
- package/dist/react/toFormDocument.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 +14 -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 +30 -0
- package/dist/react/validateField.js.map +1 -0
- package/dist/recall/interpolate.d.ts +10 -0
- package/dist/recall/interpolate.js +16 -0
- package/dist/recall/interpolate.js.map +1 -0
- package/dist/recall/resolver.d.ts +22 -0
- package/dist/recall/resolver.js +36 -0
- package/dist/recall/resolver.js.map +1 -0
- package/dist/spam/captcha.d.ts +12 -0
- package/dist/spam/captcha.js +11 -0
- package/dist/spam/captcha.js.map +1 -0
- package/dist/spam/constants.d.ts +12 -0
- package/dist/spam/constants.js +15 -0
- package/dist/spam/constants.js.map +1 -0
- package/dist/spam/identify.d.ts +12 -0
- package/dist/spam/identify.js +20 -0
- package/dist/spam/identify.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 +42 -0
- package/dist/spam/resolveSpam.js.map +1 -0
- package/dist/spam/spamGuard.js +68 -0
- package/dist/spam/spamGuard.js.map +1 -0
- package/dist/spam/types.d.ts +73 -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 +133 -0
- package/dist/submissions/SubmissionAnswers.js.map +1 -0
- package/dist/submissions/SubmissionAnswersClient.js +142 -0
- package/dist/submissions/SubmissionAnswersClient.js.map +1 -0
- package/dist/submissions/runSubmission.js +257 -0
- package/dist/submissions/runSubmission.js.map +1 -0
- package/dist/submissions/types.d.ts +34 -0
- package/dist/submissions/validateSubmission.js +59 -0
- package/dist/submissions/validateSubmission.js.map +1 -0
- package/dist/translations/en.d.ts +12 -0
- package/dist/{translations-edMqq_2e.js → translations/en.js} +29 -23
- package/dist/translations/en.js.map +1 -0
- package/dist/translations/index.d.ts +14 -0
- package/dist/translations/index.js +26 -0
- package/dist/translations/index.js.map +1 -0
- package/dist/translations/keys.d.ts +157 -0
- package/dist/{keys-N5xGiUsh.js → translations/keys.js} +28 -3
- package/dist/translations/keys.js.map +1 -0
- package/dist/translations/makeTranslate.d.ts +11 -0
- package/dist/translations/makeTranslate.js +11 -0
- package/dist/translations/makeTranslate.js.map +1 -0
- package/dist/translations/server.js +25 -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 +27 -0
- package/dist/uploads/captureFileRef.js +34 -0
- package/dist/uploads/captureFileRef.js.map +1 -0
- package/dist/uploads/resolveFileRef.d.ts +26 -0
- package/dist/uploads/resolveFileRef.js +44 -0
- package/dist/uploads/resolveFileRef.js.map +1 -0
- package/dist/uploads/types.d.ts +20 -0
- package/dist/validation/buildRuleBlocks.js +46 -0
- package/dist/validation/buildRuleBlocks.js.map +1 -0
- package/dist/validation/builtin/email.js +19 -0
- package/dist/validation/builtin/email.js.map +1 -0
- package/dist/validation/builtin/index.js +27 -0
- package/dist/validation/builtin/index.js.map +1 -0
- package/dist/validation/builtin/matchesField.js +20 -0
- package/dist/validation/builtin/matchesField.js.map +1 -0
- package/dist/validation/builtin/max.js +21 -0
- package/dist/validation/builtin/max.js.map +1 -0
- package/dist/validation/builtin/maxLength.js +26 -0
- package/dist/validation/builtin/maxLength.js.map +1 -0
- package/dist/validation/builtin/min.js +21 -0
- package/dist/validation/builtin/min.js.map +1 -0
- package/dist/validation/builtin/minLength.js +26 -0
- package/dist/validation/builtin/minLength.js.map +1 -0
- package/dist/validation/builtin/notAlreadySubmitted.js +32 -0
- package/dist/validation/builtin/notAlreadySubmitted.js.map +1 -0
- package/dist/validation/builtin/oneOf.js +34 -0
- package/dist/validation/builtin/oneOf.js.map +1 -0
- package/dist/validation/builtin/pattern.js +41 -0
- package/dist/validation/builtin/pattern.js.map +1 -0
- package/dist/validation/builtin/url.js +22 -0
- package/dist/validation/builtin/url.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/message.js +14 -0
- package/dist/validation/message.js.map +1 -0
- package/dist/validation/registry.d.ts +10 -0
- package/dist/validation/registry.js +20 -0
- package/dist/validation/registry.js.map +1 -0
- package/dist/validation/runValidation.js +111 -0
- package/dist/validation/runValidation.js.map +1 -0
- package/dist/validation/types.d.ts +76 -0
- package/package.json +8 -5
- package/styles/form-builder.css +201 -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.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.map +0 -1
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { FormFieldInstance } from "../submissions/types.js";
|
|
2
|
+
import { Field, Payload, PayloadRequest } from "payload";
|
|
3
|
+
|
|
4
|
+
//#region src/validation/types.d.ts
|
|
5
|
+
type ValidationSeverity = 'error' | 'warning';
|
|
6
|
+
/** A rule outcome: pass, a plain error string, or an explicit message + severity. */
|
|
7
|
+
type ValidationRuleResult = true | string | {
|
|
8
|
+
message: string;
|
|
9
|
+
severity?: ValidationSeverity;
|
|
10
|
+
};
|
|
11
|
+
/** Resolves this rule instance's message (custom override or localized default) with `{var}` interpolation. */
|
|
12
|
+
type MessageFn = (vars?: Record<string, unknown>) => string;
|
|
13
|
+
/** Resolved per-instance rule params (loose at the DB boundary, narrowed by the author's generic). */
|
|
14
|
+
type ValidationParams = Record<string, unknown>;
|
|
15
|
+
type ValidationRuleValidateArgs<TParams extends ValidationParams, TValue, TData extends Record<string, unknown> = Record<string, unknown>> = {
|
|
16
|
+
value: TValue | null | undefined;
|
|
17
|
+
params: TParams;
|
|
18
|
+
siblingData: TData;
|
|
19
|
+
data: TData;
|
|
20
|
+
field: FormFieldInstance;
|
|
21
|
+
fieldType: string;
|
|
22
|
+
operation: 'create' | 'update';
|
|
23
|
+
event: 'onChange' | 'submit';
|
|
24
|
+
locale: string;
|
|
25
|
+
message: MessageFn; /** Server only. Absent in the client (req-less) context, so a server-only rule cannot run there. */
|
|
26
|
+
req?: PayloadRequest;
|
|
27
|
+
payload?: Payload; /** Server only. The form being submitted, for form-scoped lookups (e.g. notAlreadySubmitted). */
|
|
28
|
+
formId?: number | string;
|
|
29
|
+
};
|
|
30
|
+
type ValidationRuleValidate<TParams extends ValidationParams, TValue, TData extends Record<string, unknown> = Record<string, unknown>> = (args: ValidationRuleValidateArgs<TParams, TValue, TData>) => Promise<ValidationRuleResult> | ValidationRuleResult;
|
|
31
|
+
/**
|
|
32
|
+
* A validation rule type, authored once. `params` is a Payload `Field[]` rendered in the per-field
|
|
33
|
+
* constraint list; `validate` returns `true | string | { message, severity }`. `client` defaults from
|
|
34
|
+
* whether the rule is pure (a rule that is async or uses `req`/`payload` must set `client: false`).
|
|
35
|
+
*/
|
|
36
|
+
type ValidationRuleDefinition<TParams extends ValidationParams = ValidationParams, TValue = unknown, TData extends Record<string, unknown> = Record<string, unknown>> = {
|
|
37
|
+
type: string;
|
|
38
|
+
label: string;
|
|
39
|
+
description?: string; /** Field type slugs this rule may be added to. Omit for all field types. */
|
|
40
|
+
appliesTo?: string[];
|
|
41
|
+
params?: Field[];
|
|
42
|
+
defaultMessage: string; /** Runs client-side too. Defaults to `true`; set `false` for async or `req`/`payload`-using rules. */
|
|
43
|
+
client?: boolean; /** Default severity when `validate` returns a bare string. Defaults to `error`. */
|
|
44
|
+
severity?: ValidationSeverity;
|
|
45
|
+
validate: ValidationRuleValidate<TParams, TValue, TData>;
|
|
46
|
+
};
|
|
47
|
+
/** Erased shape stored in the heterogeneous registry; params re-narrow per matched rule at execution. */
|
|
48
|
+
type AnyValidationRuleValidate = (args: {
|
|
49
|
+
value: unknown;
|
|
50
|
+
params: ValidationParams;
|
|
51
|
+
siblingData: Record<string, unknown>;
|
|
52
|
+
data: Record<string, unknown>;
|
|
53
|
+
field: FormFieldInstance;
|
|
54
|
+
fieldType: string;
|
|
55
|
+
operation: 'create' | 'update';
|
|
56
|
+
event: 'onChange' | 'submit';
|
|
57
|
+
locale: string;
|
|
58
|
+
message: MessageFn;
|
|
59
|
+
req?: PayloadRequest;
|
|
60
|
+
payload?: Payload;
|
|
61
|
+
formId?: number | string;
|
|
62
|
+
}) => Promise<ValidationRuleResult> | ValidationRuleResult;
|
|
63
|
+
type AnyValidationRuleDefinition = {
|
|
64
|
+
type: string;
|
|
65
|
+
label: string;
|
|
66
|
+
description?: string;
|
|
67
|
+
appliesTo?: string[];
|
|
68
|
+
params?: Field[];
|
|
69
|
+
defaultMessage: string;
|
|
70
|
+
client?: boolean;
|
|
71
|
+
severity?: ValidationSeverity;
|
|
72
|
+
validate: AnyValidationRuleValidate;
|
|
73
|
+
};
|
|
74
|
+
//#endregion
|
|
75
|
+
export { AnyValidationRuleDefinition, ValidationParams, ValidationRuleDefinition, ValidationRuleResult, ValidationSeverity };
|
|
76
|
+
//# sourceMappingURL=types.d.ts.map
|
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.2",
|
|
4
4
|
"description": "End-to-end forms platform for Payload: author, validate, render, collect, aggregate, and act.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -67,14 +67,15 @@
|
|
|
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",
|
|
75
77
|
"@payloadcms/ui": "3.85.0",
|
|
76
78
|
"@playwright/test": "1.60.0",
|
|
77
|
-
"@standard-schema/spec": "^1.0.0",
|
|
78
79
|
"@testing-library/jest-dom": "^6.6.3",
|
|
79
80
|
"@testing-library/react": "^16.1.0",
|
|
80
81
|
"@types/node": "22.19.19",
|
|
@@ -86,12 +87,14 @@
|
|
|
86
87
|
"playwright": "1.60.0",
|
|
87
88
|
"react": "19.2.6",
|
|
88
89
|
"react-dom": "19.2.6",
|
|
90
|
+
"shadcn": "^2.4.0",
|
|
89
91
|
"tsdown": "0.22.1",
|
|
90
92
|
"typescript": "5.9.3",
|
|
91
93
|
"vitest": "4.1.7",
|
|
92
94
|
"@10x-media/payload-test-harness": "0.0.0",
|
|
93
|
-
"@10x-media/
|
|
94
|
-
"@10x-media/vitest-config": "0.0.0"
|
|
95
|
+
"@10x-media/tsdown-config": "0.0.0",
|
|
96
|
+
"@10x-media/vitest-config": "0.0.0",
|
|
97
|
+
"@10x-media/tsconfig": "0.0.0"
|
|
95
98
|
},
|
|
96
99
|
"publishConfig": {
|
|
97
100
|
"access": "public"
|
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;
|
|
@@ -106,3 +106,193 @@
|
|
|
106
106
|
opacity: 0.7;
|
|
107
107
|
font-size: 0.875em;
|
|
108
108
|
}
|
|
109
|
+
|
|
110
|
+
/* Flow builder (admin UI only, requires Payload theme variables). */
|
|
111
|
+
.fb-flow-builder {
|
|
112
|
+
display: flex;
|
|
113
|
+
flex-direction: column;
|
|
114
|
+
gap: 0.5rem;
|
|
115
|
+
margin-block-end: 1rem;
|
|
116
|
+
}
|
|
117
|
+
.fb-flow-builder__hint {
|
|
118
|
+
color: var(--theme-elevation-400);
|
|
119
|
+
font-size: 0.875rem;
|
|
120
|
+
margin: 0;
|
|
121
|
+
}
|
|
122
|
+
.fb-flow-builder__steps {
|
|
123
|
+
display: flex;
|
|
124
|
+
flex-direction: column;
|
|
125
|
+
gap: 0.5rem;
|
|
126
|
+
}
|
|
127
|
+
.fb-flow-builder__actions {
|
|
128
|
+
margin-block-start: 0.25rem;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.fb-flow-step__header-content {
|
|
132
|
+
display: flex;
|
|
133
|
+
align-items: center;
|
|
134
|
+
gap: 0.5rem;
|
|
135
|
+
overflow: hidden;
|
|
136
|
+
}
|
|
137
|
+
.fb-flow-step__index {
|
|
138
|
+
font-size: 0.6875rem;
|
|
139
|
+
font-weight: 600;
|
|
140
|
+
text-transform: uppercase;
|
|
141
|
+
letter-spacing: 0.04em;
|
|
142
|
+
color: var(--theme-elevation-400);
|
|
143
|
+
flex-shrink: 0;
|
|
144
|
+
}
|
|
145
|
+
.fb-flow-step__id-preview {
|
|
146
|
+
font-size: 0.875rem;
|
|
147
|
+
overflow: hidden;
|
|
148
|
+
text-overflow: ellipsis;
|
|
149
|
+
white-space: nowrap;
|
|
150
|
+
}
|
|
151
|
+
.fb-flow-step__id-preview em {
|
|
152
|
+
color: var(--theme-elevation-400);
|
|
153
|
+
font-style: italic;
|
|
154
|
+
}
|
|
155
|
+
.fb-flow-step__body {
|
|
156
|
+
padding: 0.75rem;
|
|
157
|
+
display: flex;
|
|
158
|
+
flex-direction: column;
|
|
159
|
+
gap: 0.25rem;
|
|
160
|
+
}
|
|
161
|
+
.fb-flow-step__row {
|
|
162
|
+
display: flex;
|
|
163
|
+
flex-direction: column;
|
|
164
|
+
gap: 0.25rem;
|
|
165
|
+
}
|
|
166
|
+
.fb-flow-step__hint {
|
|
167
|
+
font-size: 0.75rem;
|
|
168
|
+
color: var(--theme-elevation-400);
|
|
169
|
+
margin: 0;
|
|
170
|
+
}
|
|
171
|
+
.fb-flow-step__field-picker {
|
|
172
|
+
display: flex;
|
|
173
|
+
flex-wrap: wrap;
|
|
174
|
+
gap: 0.25rem 1.25rem;
|
|
175
|
+
padding-block: 0.25rem;
|
|
176
|
+
}
|
|
177
|
+
.fb-flow-step__transitions {
|
|
178
|
+
display: flex;
|
|
179
|
+
flex-direction: column;
|
|
180
|
+
gap: 0.5rem;
|
|
181
|
+
padding-block-start: 0.5rem;
|
|
182
|
+
}
|
|
183
|
+
.fb-flow-step__transitions-header {
|
|
184
|
+
display: flex;
|
|
185
|
+
align-items: baseline;
|
|
186
|
+
gap: 0.5rem;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.fb-flow-transition {
|
|
190
|
+
border: 1px solid var(--theme-border-color);
|
|
191
|
+
border-radius: var(--style-radius-s);
|
|
192
|
+
padding: 0.5rem 0.75rem;
|
|
193
|
+
display: flex;
|
|
194
|
+
flex-direction: column;
|
|
195
|
+
gap: 0.5rem;
|
|
196
|
+
}
|
|
197
|
+
.fb-flow-transition__header {
|
|
198
|
+
display: flex;
|
|
199
|
+
align-items: center;
|
|
200
|
+
gap: 0.5rem;
|
|
201
|
+
}
|
|
202
|
+
.fb-flow-transition__label {
|
|
203
|
+
font-size: 0.6875rem;
|
|
204
|
+
font-weight: 600;
|
|
205
|
+
text-transform: uppercase;
|
|
206
|
+
letter-spacing: 0.04em;
|
|
207
|
+
color: var(--theme-elevation-400);
|
|
208
|
+
flex-shrink: 0;
|
|
209
|
+
}
|
|
210
|
+
.fb-flow-transition__goto {
|
|
211
|
+
flex: 1;
|
|
212
|
+
min-width: 0;
|
|
213
|
+
}
|
|
214
|
+
.fb-flow-transition__actions {
|
|
215
|
+
display: flex;
|
|
216
|
+
align-items: center;
|
|
217
|
+
gap: 0.25rem;
|
|
218
|
+
flex-shrink: 0;
|
|
219
|
+
}
|
|
220
|
+
.fb-flow-transition__when-label {
|
|
221
|
+
font-size: 0.6875rem;
|
|
222
|
+
font-weight: 600;
|
|
223
|
+
text-transform: uppercase;
|
|
224
|
+
letter-spacing: 0.04em;
|
|
225
|
+
color: var(--theme-elevation-400);
|
|
226
|
+
}
|
|
227
|
+
.fb-flow-transition__condition {
|
|
228
|
+
padding-inline-start: 0.25rem;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/* Condition builder (admin UI only, requires Payload theme variables). */
|
|
232
|
+
.fb-condition-builder {
|
|
233
|
+
display: flex;
|
|
234
|
+
flex-direction: column;
|
|
235
|
+
gap: 0.5rem;
|
|
236
|
+
}
|
|
237
|
+
.fb-condition-builder__hint {
|
|
238
|
+
color: var(--theme-elevation-400);
|
|
239
|
+
font-size: 0.875rem;
|
|
240
|
+
margin: 0;
|
|
241
|
+
}
|
|
242
|
+
.fb-condition-builder__group {
|
|
243
|
+
display: flex;
|
|
244
|
+
flex-direction: column;
|
|
245
|
+
gap: 0.375rem;
|
|
246
|
+
padding: 0.75rem;
|
|
247
|
+
border: 1px solid var(--theme-border-color);
|
|
248
|
+
border-radius: var(--style-radius-m);
|
|
249
|
+
}
|
|
250
|
+
.fb-condition-builder__or-label {
|
|
251
|
+
display: inline-block;
|
|
252
|
+
font-size: 11px;
|
|
253
|
+
font-weight: 500;
|
|
254
|
+
text-transform: uppercase;
|
|
255
|
+
margin-block: 0.125rem;
|
|
256
|
+
}
|
|
257
|
+
.fb-condition-builder__and-row {
|
|
258
|
+
display: flex;
|
|
259
|
+
flex-direction: column;
|
|
260
|
+
gap: 0.25rem;
|
|
261
|
+
}
|
|
262
|
+
.fb-condition-builder__and-label {
|
|
263
|
+
font-size: 10px;
|
|
264
|
+
font-weight: 500;
|
|
265
|
+
text-transform: uppercase;
|
|
266
|
+
padding-inline-start: 0.125rem;
|
|
267
|
+
}
|
|
268
|
+
.fb-condition-builder__add-condition {
|
|
269
|
+
align-self: flex-start;
|
|
270
|
+
margin-block-start: 0.25rem;
|
|
271
|
+
}
|
|
272
|
+
.fb-condition-builder__actions {
|
|
273
|
+
display: flex;
|
|
274
|
+
gap: 0.5rem;
|
|
275
|
+
margin-top: 0.5rem;
|
|
276
|
+
}
|
|
277
|
+
.fb-condition-row {
|
|
278
|
+
display: flex;
|
|
279
|
+
align-items: flex-start;
|
|
280
|
+
gap: 0.5rem;
|
|
281
|
+
flex-wrap: nowrap;
|
|
282
|
+
}
|
|
283
|
+
.fb-condition-row__field {
|
|
284
|
+
flex: 1 1 9rem;
|
|
285
|
+
min-width: 0;
|
|
286
|
+
}
|
|
287
|
+
.fb-condition-row__operator {
|
|
288
|
+
flex: 0 1 9rem;
|
|
289
|
+
min-width: 0;
|
|
290
|
+
}
|
|
291
|
+
.fb-condition-row__value {
|
|
292
|
+
flex: 1 1 9rem;
|
|
293
|
+
min-width: 0;
|
|
294
|
+
}
|
|
295
|
+
.fb-condition-row__remove {
|
|
296
|
+
flex-shrink: 0;
|
|
297
|
+
align-self: center;
|
|
298
|
+
}
|
|
@@ -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
|