@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
package/dist/exports/rsc.d.ts
CHANGED
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
declare const SubmissionAnswers: ({
|
|
11
|
-
data,
|
|
12
|
-
req
|
|
13
|
-
}: UIFieldServerProps) => import("react/jsx-runtime").JSX.Element;
|
|
14
|
-
//#endregion
|
|
15
|
-
export { SubmissionAnswers };
|
|
16
|
-
//# sourceMappingURL=rsc.d.ts.map
|
|
1
|
+
import { resolveConsentStatements } from "../consent/resolveConsentStatements.js";
|
|
2
|
+
import { toFormDocument } from "../form/toFormDocument.js";
|
|
3
|
+
import { isPollClosed } from "../form/pollState.js";
|
|
4
|
+
import { resolveEffectivePollOptions } from "../poll/effectivePollOptions.js";
|
|
5
|
+
import { resolvePollOptions } from "../poll/resolvePollOptions.js";
|
|
6
|
+
import { resolvePollOutcome } from "../poll/resolvePollOutcome.js";
|
|
7
|
+
import { SubmissionAnswers } from "../submissions/SubmissionAnswers.js";
|
|
8
|
+
import { hasVotedCookie, votedCookieName } from "../submissions/votedCookie.js";
|
|
9
|
+
export { SubmissionAnswers, hasVotedCookie, isPollClosed, resolveConsentStatements, resolveEffectivePollOptions, resolvePollOptions, resolvePollOutcome, toFormDocument, votedCookieName };
|
package/dist/exports/rsc.js
CHANGED
|
@@ -1,55 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
if (typeof ref.url === "string" && ref.url.length > 0) return {
|
|
11
|
-
url: ref.url,
|
|
12
|
-
filename: typeof ref.filename === "string" ? ref.filename : ref.url
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
return null;
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* Read-only, localized submission view (server component). Renders each answered field's snapshot
|
|
19
|
-
* label next to its type-aware formatted value via the field type's `format`, using the request
|
|
20
|
-
* locale and i18n, with no client bundle. The built-in field types are formatted directly; threading
|
|
21
|
-
* the full resolved registry (custom types) to the view is a future enhancement.
|
|
22
|
-
*/
|
|
23
|
-
const SubmissionAnswers = ({ data, req }) => {
|
|
24
|
-
const doc = data ?? {};
|
|
25
|
-
const descriptors = doc.descriptors ?? [];
|
|
26
|
-
const values = doc.values ?? [];
|
|
27
|
-
const locale = doc.locale ?? req.locale ?? "en";
|
|
28
|
-
const t = asFieldTranslate(req.i18n.t);
|
|
29
|
-
if (descriptors.length === 0) return /* @__PURE__ */ jsx("p", { children: t(keys.submissionNoAnswers) });
|
|
30
|
-
const valueByField = new Map(values.map((entry) => [entry.field, entry.value]));
|
|
31
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
32
|
-
className: "form-builder-submission-answers",
|
|
33
|
-
children: [/* @__PURE__ */ jsx("h4", { children: t(keys.submissionAnswers) }), /* @__PURE__ */ jsx("dl", { children: descriptors.map((descriptor) => {
|
|
34
|
-
const definition = registry.get(descriptor.fieldType);
|
|
35
|
-
const raw = valueByField.get(descriptor.field);
|
|
36
|
-
const formatted = definition?.format ? definition.format({
|
|
37
|
-
value: raw,
|
|
38
|
-
config: {},
|
|
39
|
-
optionLabels: descriptor.optionLabels,
|
|
40
|
-
locale,
|
|
41
|
-
t
|
|
42
|
-
}) : raw == null ? "" : String(raw);
|
|
43
|
-
const href = descriptor.fieldType === "file" ? fileHref(raw) : null;
|
|
44
|
-
return /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("dt", { children: descriptor.label }), /* @__PURE__ */ jsx("dd", { children: href ? /* @__PURE__ */ jsx("a", {
|
|
45
|
-
href: href.url,
|
|
46
|
-
rel: "noreferrer",
|
|
47
|
-
children: href.filename
|
|
48
|
-
}) : formatted })] }, descriptor.field);
|
|
49
|
-
}) })]
|
|
50
|
-
});
|
|
51
|
-
};
|
|
52
|
-
//#endregion
|
|
53
|
-
export { SubmissionAnswers };
|
|
54
|
-
|
|
55
|
-
//# sourceMappingURL=rsc.js.map
|
|
1
|
+
import { resolveConsentStatements } from "../consent/resolveConsentStatements.js";
|
|
2
|
+
import { isPollClosed } from "../form/pollState.js";
|
|
3
|
+
import { resolvePollOptions } from "../poll/resolvePollOptions.js";
|
|
4
|
+
import { resolvePollOutcome } from "../poll/resolvePollOutcome.js";
|
|
5
|
+
import { resolveEffectivePollOptions } from "../poll/effectivePollOptions.js";
|
|
6
|
+
import { hasVotedCookie, votedCookieName } from "../submissions/votedCookie.js";
|
|
7
|
+
import { toFormDocument } from "../form/toFormDocument.js";
|
|
8
|
+
import { SubmissionAnswers } from "../submissions/SubmissionAnswers.js";
|
|
9
|
+
export { SubmissionAnswers, hasVotedCookie, isPollClosed, resolveConsentStatements, resolveEffectivePollOptions, resolvePollOptions, resolvePollOutcome, toFormDocument, votedCookieName };
|
package/dist/exports/types.d.ts
CHANGED
|
@@ -1,5 +1,36 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
1
|
+
import { FormFieldInstance, SubmissionDescriptor, SubmissionFieldError, SubmissionValue, SubmissionWidth } from "../submissions/types.js";
|
|
2
|
+
import { FileFieldConfig, FileRef, FileRefError } from "../uploads/types.js";
|
|
3
|
+
import { AnyFormFieldDefinition, FormFieldDefinition, FormFieldFormat, FormFieldValidate, FormFieldValueKind, OmittableSharedField } from "../fields/types.js";
|
|
4
|
+
import { RichTextBodyOption } from "../actions/body/serializeBody.js";
|
|
5
|
+
import { AggregationBucket, AggregationRow, FieldAggregation, FieldMeta, SubmissionStatusFilter } from "../aggregation/types.js";
|
|
6
|
+
import { CalcExpression } from "../calc/types.js";
|
|
7
|
+
import { ConsentSourceEntry, ConsentSourcePage, ConsentSourcesResolver } from "../consent/types.js";
|
|
8
|
+
import { ConsentStatement, ConsentStatements, ResolveConsentStatementsArgs } from "../consent/resolveConsentStatements.js";
|
|
9
|
+
import { FlowStep, FlowTransition, FormFlow } from "../flow/types.js";
|
|
10
|
+
import { FormButtonSettings, FormDocument, FormPollSettings, FormResponseSettings } from "../form/types.js";
|
|
11
|
+
import { FieldTypeOption, FieldTypeRegistry, FieldTypesConfig } from "../fields/registry.js";
|
|
12
|
+
import { PrefillOptions } from "../prefill/valuesFromSearchParams.js";
|
|
13
|
+
import { FormEvent, FormEventSink } from "../events/types.js";
|
|
14
|
+
import { AnyValidationRuleDefinition, ValidationRuleDefinition, ValidationRuleResult } from "../validation/types.js";
|
|
15
|
+
import { PresentationDensity, PresentationDescriptor, PresentationSurface } from "../presentations/types.js";
|
|
16
|
+
import { RecallResolver } from "../recall/resolver.js";
|
|
17
|
+
import { PollOptionSourceOption, PollOptionSourceRegistry, PollOptionSourcesConfig } from "../poll/registry.js";
|
|
18
|
+
import { ActionDefinition, ActionRunArgs, AnyActionDefinition } from "../actions/defineAction.js";
|
|
19
|
+
import { FromAddressOption, FromAddressesResolver } from "../actions/fromAddresses.js";
|
|
20
|
+
import { ActionOption, ActionRegistry, ActionsConfig } from "../actions/registry.js";
|
|
21
|
+
import { ActionResult } from "../actions/runActions.js";
|
|
22
|
+
import { AggregateFieldResponsesArgs, AggregateFormResponsesArgs } from "../aggregation/aggregateResponses.js";
|
|
23
|
+
import { FormResultsAccess, FormResultsAccessArgs, ResolveResultsRequestArgs, ResolveResultsRequestResult } from "../aggregation/resolveResultsRequest.js";
|
|
24
|
+
import { ButtonFieldsOverride, ButtonsOption, DefaultButtonFields } from "../collections/buttonFields.js";
|
|
25
|
+
import { FieldCondition } from "../conditions/types.js";
|
|
26
|
+
import { ConsentProof } from "../consent/captureConsent.js";
|
|
27
|
+
import { ConsentSourcesFieldOptions } from "../consent/consentSourcesField.js";
|
|
28
|
+
import { ResolveConsentEntriesArgs } from "../consent/resolveConsentEntries.js";
|
|
29
|
+
import { ConsentSourceOption, ResolveConsentSourcesRequestArgs, ResolveConsentSourcesRequestResult } from "../consent/resolveConsentSourcesRequest.js";
|
|
30
|
+
import { ResolvePublishedVersionRefArgs } from "../consent/resolvePublishedVersionRef.js";
|
|
31
|
+
import { CollectionOverrides, FieldsOverride } from "../plugin/collectionOverrides.js";
|
|
32
|
+
import { CaptchaProvider, CaptchaVerifyArgs, IdentifyFn, RateLimitCheckArgs, RateLimitConfig, RateLimitResult, RateLimiter, SpamConfig, SpamMetadataConfig, SpamOption } from "../spam/types.js";
|
|
33
|
+
import { UploadsOption } from "../plugin/uploadsCollection.js";
|
|
34
|
+
import { ValidationRuleOption, ValidationRuleRegistry, ValidationRulesConfig } from "../validation/registry.js";
|
|
35
|
+
import { FormBuilderPluginOptions } from "../options.js";
|
|
36
|
+
export type { ActionDefinition, ActionOption, ActionRegistry, ActionResult, ActionRunArgs, ActionsConfig, AggregateFieldResponsesArgs, AggregateFormResponsesArgs, AggregationBucket, AggregationRow, AnyActionDefinition, AnyFormFieldDefinition, AnyValidationRuleDefinition, ButtonFieldsOverride, ButtonsOption, CalcExpression, CaptchaProvider, CaptchaVerifyArgs, CollectionOverrides, ConsentProof, ConsentSourceEntry, ConsentSourceOption, ConsentSourcePage, ConsentSourcesFieldOptions, ConsentSourcesResolver, ConsentStatement, ConsentStatements, DefaultButtonFields, FieldAggregation, FieldCondition, FieldMeta, FieldTypeOption, FieldTypeRegistry, FieldTypesConfig, FieldsOverride, FileFieldConfig, FileRef, FileRefError, FlowStep, FlowTransition, FormBuilderPluginOptions, FormButtonSettings, FormDocument, FormEvent, FormEventSink, FormFieldDefinition, FormFieldFormat, FormFieldInstance, FormFieldValidate, FormFieldValueKind, FormFlow, FormPollSettings, FormResponseSettings, FormResultsAccess, FormResultsAccessArgs, FromAddressOption, FromAddressesResolver, IdentifyFn, OmittableSharedField, PollOptionSourceOption, PollOptionSourceRegistry, PollOptionSourcesConfig, PrefillOptions, PresentationDensity, PresentationDescriptor, PresentationSurface, RateLimitCheckArgs, RateLimitConfig, RateLimitResult, RateLimiter, RecallResolver, ResolveConsentEntriesArgs, ResolveConsentSourcesRequestArgs, ResolveConsentSourcesRequestResult, ResolveConsentStatementsArgs, ResolvePublishedVersionRefArgs, ResolveResultsRequestArgs, ResolveResultsRequestResult, RichTextBodyOption, SpamConfig, SpamMetadataConfig, SpamOption, SubmissionDescriptor, SubmissionFieldError, SubmissionStatusFilter, SubmissionValue, SubmissionWidth, UploadsOption, ValidationRuleDefinition, ValidationRuleOption, ValidationRuleRegistry, ValidationRuleResult, ValidationRulesConfig };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { keys } from "../translations/keys.js";
|
|
2
|
+
import { labelFor } from "../translations/server.js";
|
|
3
|
+
import { buildConditionTypeMap } from "../conditions/conditionType.js";
|
|
4
|
+
import { buildRuleBlocks } from "../validation/buildRuleBlocks.js";
|
|
5
|
+
import { fieldBlockTabs } from "./sharedConfig.js";
|
|
6
|
+
//#region src/fields/buildFieldBlocks.ts
|
|
7
|
+
const FIELD_BLOCK_LABEL_REF = "@10x-media/form-builder/client#FieldBlockLabel";
|
|
8
|
+
/**
|
|
9
|
+
* Replace Payload's default `blockName` row header (which reads "Untitled" until filled) with the
|
|
10
|
+
* field's own `label`, keyed to the type label as fallback. See `FieldBlockLabel`.
|
|
11
|
+
*/
|
|
12
|
+
const blockLabelAdmin = (typeLabelKey, ref = FIELD_BLOCK_LABEL_REF) => ({ components: { Label: {
|
|
13
|
+
path: ref,
|
|
14
|
+
clientProps: { typeLabelKey }
|
|
15
|
+
} } });
|
|
16
|
+
/** Whether `fields` contains a field named `name`, descending into presentational rows. */
|
|
17
|
+
const hasNameField = (fields) => fields.some((f) => {
|
|
18
|
+
if ("name" in f && f.name === "name") return true;
|
|
19
|
+
return f.type === "row" && hasNameField(f.fields);
|
|
20
|
+
});
|
|
21
|
+
/** The tab whose fields hold the shared basics and type config, found by the `name` field it carries. */
|
|
22
|
+
const fieldTabOf = (block) => {
|
|
23
|
+
return block.fields.find((f) => f.type === "tabs")?.tabs.find((tab) => hasNameField(tab.fields))?.fields;
|
|
24
|
+
};
|
|
25
|
+
const buildFieldBlocks = ({ registry, ruleRegistry, localize = true }) => {
|
|
26
|
+
const conditionTypes = buildConditionTypeMap(registry);
|
|
27
|
+
const blocks = [];
|
|
28
|
+
const bareSlugs = /* @__PURE__ */ new Set();
|
|
29
|
+
for (const definition of registry.values()) {
|
|
30
|
+
const typeConfig = definition.config ?? [];
|
|
31
|
+
if (definition.bare === true) {
|
|
32
|
+
bareSlugs.add(definition.type);
|
|
33
|
+
blocks.push({
|
|
34
|
+
slug: definition.type,
|
|
35
|
+
labels: {
|
|
36
|
+
singular: labelFor(definition.label),
|
|
37
|
+
plural: labelFor(definition.label)
|
|
38
|
+
},
|
|
39
|
+
admin: blockLabelAdmin(definition.label, definition.blockLabel),
|
|
40
|
+
fields: typeConfig
|
|
41
|
+
});
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
blocks.push({
|
|
45
|
+
slug: definition.type,
|
|
46
|
+
labels: {
|
|
47
|
+
singular: labelFor(definition.label),
|
|
48
|
+
plural: labelFor(definition.label)
|
|
49
|
+
},
|
|
50
|
+
admin: blockLabelAdmin(definition.label, definition.blockLabel),
|
|
51
|
+
fields: [fieldBlockTabs({
|
|
52
|
+
conditionTypes,
|
|
53
|
+
typeConfig,
|
|
54
|
+
validations: {
|
|
55
|
+
name: "validations",
|
|
56
|
+
type: "blocks",
|
|
57
|
+
label: labelFor(keys.validationsLabel),
|
|
58
|
+
blocks: buildRuleBlocks(ruleRegistry, definition.type)
|
|
59
|
+
},
|
|
60
|
+
localize,
|
|
61
|
+
omitShared: definition.omitShared
|
|
62
|
+
})]
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
const repeaterBlock = blocks.find((b) => b.slug === "repeater");
|
|
66
|
+
if (repeaterBlock) {
|
|
67
|
+
const subFieldsField = {
|
|
68
|
+
name: "subFields",
|
|
69
|
+
type: "blocks",
|
|
70
|
+
label: labelFor(keys.configSubFields),
|
|
71
|
+
blocks: blocks.filter((b) => b.slug !== "repeater" && !bareSlugs.has(b.slug))
|
|
72
|
+
};
|
|
73
|
+
(fieldTabOf(repeaterBlock) ?? repeaterBlock.fields).push(subFieldsField);
|
|
74
|
+
}
|
|
75
|
+
return blocks;
|
|
76
|
+
};
|
|
77
|
+
//#endregion
|
|
78
|
+
export { buildFieldBlocks };
|
|
79
|
+
|
|
80
|
+
//# sourceMappingURL=buildFieldBlocks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildFieldBlocks.js","names":[],"sources":["../../src/fields/buildFieldBlocks.ts"],"sourcesContent":["import type { Block, Field, TabsField } from 'payload'\nimport { buildConditionTypeMap } from '../conditions/conditionType'\nimport { keys } from '../translations/keys'\nimport { labelFor } from '../translations/server'\nimport { buildRuleBlocks } from '../validation/buildRuleBlocks'\nimport type { ValidationRuleRegistry } from '../validation/registry'\nimport type { FieldTypeRegistry } from './registry'\nimport { fieldBlockTabs } from './sharedConfig'\n\nconst FIELD_BLOCK_LABEL_REF = '@10x-media/form-builder/client#FieldBlockLabel'\n\n/**\n * Replace Payload's default `blockName` row header (which reads \"Untitled\" until filled) with the\n * field's own `label`, keyed to the type label as fallback. See `FieldBlockLabel`.\n */\nconst blockLabelAdmin = (\n\ttypeLabelKey: string,\n\tref: string = FIELD_BLOCK_LABEL_REF\n): NonNullable<Block['admin']> => ({\n\tcomponents: { Label: { path: ref, clientProps: { typeLabelKey } } },\n})\n\n/** Whether `fields` contains a field named `name`, descending into presentational rows. */\nconst hasNameField = (fields: Field[]): boolean =>\n\tfields.some((f) => {\n\t\tif ('name' in f && f.name === 'name') {\n\t\t\treturn true\n\t\t}\n\t\treturn f.type === 'row' && hasNameField(f.fields)\n\t})\n\n/** The tab whose fields hold the shared basics and type config, found by the `name` field it carries. */\nconst fieldTabOf = (block: Block): Field[] | undefined => {\n\tconst tabsField = block.fields.find((f): f is TabsField => f.type === 'tabs')\n\treturn tabsField?.tabs.find((tab) => hasNameField(tab.fields))?.fields\n}\n\n/**\n * One add-field block per registered type: tabs holding shared config, type config, and\n * validations. Bare definitions (e.g. `message`) skip all of that: their block is the\n * definition's `config` alone, no name/shared basics/tabs. `localize` controls whether the\n * shared content fields carry `localized: true`; per-type config fields carry their own flag\n * from the registry definitions.\n */\ntype BuildFieldBlocksArgs = {\n\tregistry: FieldTypeRegistry\n\truleRegistry: ValidationRuleRegistry\n\tlocalize?: boolean\n}\n\nexport const buildFieldBlocks = ({\n\tregistry,\n\truleRegistry,\n\tlocalize = true,\n}: BuildFieldBlocksArgs): Block[] => {\n\tconst conditionTypes = buildConditionTypeMap(registry)\n\tconst blocks: Block[] = []\n\tconst bareSlugs = new Set<string>()\n\tfor (const definition of registry.values()) {\n\t\tconst typeConfig: Field[] = definition.config ?? []\n\n\t\tif (definition.bare === true) {\n\t\t\tbareSlugs.add(definition.type)\n\t\t\tblocks.push({\n\t\t\t\tslug: definition.type,\n\t\t\t\tlabels: { singular: labelFor(definition.label), plural: labelFor(definition.label) },\n\t\t\t\tadmin: blockLabelAdmin(definition.label, definition.blockLabel),\n\t\t\t\tfields: typeConfig,\n\t\t\t})\n\t\t\tcontinue\n\t\t}\n\n\t\tblocks.push({\n\t\t\tslug: definition.type,\n\t\t\tlabels: { singular: labelFor(definition.label), plural: labelFor(definition.label) },\n\t\t\tadmin: blockLabelAdmin(definition.label, definition.blockLabel),\n\t\t\tfields: [\n\t\t\t\tfieldBlockTabs({\n\t\t\t\t\tconditionTypes,\n\t\t\t\t\ttypeConfig,\n\t\t\t\t\tvalidations: {\n\t\t\t\t\t\tname: 'validations',\n\t\t\t\t\t\ttype: 'blocks',\n\t\t\t\t\t\tlabel: labelFor(keys.validationsLabel),\n\t\t\t\t\t\tblocks: buildRuleBlocks(ruleRegistry, definition.type),\n\t\t\t\t\t},\n\t\t\t\t\tlocalize,\n\t\t\t\t\tomitShared: definition.omitShared,\n\t\t\t\t}),\n\t\t\t],\n\t\t})\n\t}\n\n\t// Second pass: inject subFields into the repeater block using all non-repeater blocks.\n\t// Done after the main loop so every sibling block is already built.\n\t// Repeater-in-repeater is not supported in v1; the repeater block is excluded from subFields.\n\t// Bare blocks are excluded too: repeater row plumbing (values, composite error paths) is name-keyed.\n\tconst repeaterBlock = blocks.find((b) => b.slug === 'repeater')\n\tif (repeaterBlock) {\n\t\tconst subFieldsField: Field = {\n\t\t\tname: 'subFields',\n\t\t\ttype: 'blocks',\n\t\t\tlabel: labelFor(keys.configSubFields),\n\t\t\tblocks: blocks.filter((b) => b.slug !== 'repeater' && !bareSlugs.has(b.slug)),\n\t\t}\n\t\tconst fieldTabFields = fieldTabOf(repeaterBlock)\n\t\t;(fieldTabFields ?? (repeaterBlock.fields as Field[])).push(subFieldsField)\n\t}\n\n\treturn blocks\n}\n"],"mappings":";;;;;;AASA,MAAM,wBAAwB;;;;;AAM9B,MAAM,mBACL,cACA,MAAc,2BACoB,EAClC,YAAY,EAAE,OAAO;CAAE,MAAM;CAAK,aAAa,EAAE,aAAa;AAAE,EAAE,EACnE;;AAGA,MAAM,gBAAgB,WACrB,OAAO,MAAM,MAAM;CAClB,IAAI,UAAU,KAAK,EAAE,SAAS,QAC7B,OAAO;CAER,OAAO,EAAE,SAAS,SAAS,aAAa,EAAE,MAAM;AACjD,CAAC;;AAGF,MAAM,cAAc,UAAsC;CAEzD,OADkB,MAAM,OAAO,MAAM,MAAsB,EAAE,SAAS,MACvD,GAAG,KAAK,MAAM,QAAQ,aAAa,IAAI,MAAM,CAAC,GAAG;AACjE;AAeA,MAAa,oBAAoB,EAChC,UACA,cACA,WAAW,WACyB;CACpC,MAAM,iBAAiB,sBAAsB,QAAQ;CACrD,MAAM,SAAkB,CAAC;CACzB,MAAM,4BAAY,IAAI,IAAY;CAClC,KAAK,MAAM,cAAc,SAAS,OAAO,GAAG;EAC3C,MAAM,aAAsB,WAAW,UAAU,CAAC;EAElD,IAAI,WAAW,SAAS,MAAM;GAC7B,UAAU,IAAI,WAAW,IAAI;GAC7B,OAAO,KAAK;IACX,MAAM,WAAW;IACjB,QAAQ;KAAE,UAAU,SAAS,WAAW,KAAK;KAAG,QAAQ,SAAS,WAAW,KAAK;IAAE;IACnF,OAAO,gBAAgB,WAAW,OAAO,WAAW,UAAU;IAC9D,QAAQ;GACT,CAAC;GACD;EACD;EAEA,OAAO,KAAK;GACX,MAAM,WAAW;GACjB,QAAQ;IAAE,UAAU,SAAS,WAAW,KAAK;IAAG,QAAQ,SAAS,WAAW,KAAK;GAAE;GACnF,OAAO,gBAAgB,WAAW,OAAO,WAAW,UAAU;GAC9D,QAAQ,CACP,eAAe;IACd;IACA;IACA,aAAa;KACZ,MAAM;KACN,MAAM;KACN,OAAO,SAAS,KAAK,gBAAgB;KACrC,QAAQ,gBAAgB,cAAc,WAAW,IAAI;IACtD;IACA;IACA,YAAY,WAAW;GACxB,CAAC,CACF;EACD,CAAC;CACF;CAMA,MAAM,gBAAgB,OAAO,MAAM,MAAM,EAAE,SAAS,UAAU;CAC9D,IAAI,eAAe;EAClB,MAAM,iBAAwB;GAC7B,MAAM;GACN,MAAM;GACN,OAAO,SAAS,KAAK,eAAe;GACpC,QAAQ,OAAO,QAAQ,MAAM,EAAE,SAAS,cAAc,CAAC,UAAU,IAAI,EAAE,IAAI,CAAC;EAC7E;EAEC,CADsB,WAAW,aACnB,KAAM,cAAc,QAAoB,KAAK,cAAc;CAC3E;CAEA,OAAO;AACR"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { keys } from "../../translations/keys.js";
|
|
2
|
+
import { asTranslate, labelFor } from "../../translations/server.js";
|
|
3
|
+
import { CALC_FNS, CALC_OPS } from "../../calc/types.js";
|
|
4
|
+
import { normalizeCalc } from "../../calc/normalizeCalc.js";
|
|
5
|
+
import { defineFormField } from "../defineFormField.js";
|
|
6
|
+
//#region src/fields/builtin/calculation.ts
|
|
7
|
+
/**
|
|
8
|
+
* Editor-facing JSON schema for `CalcExpression` (src/calc/types.ts), used by the admin JSON
|
|
9
|
+
* field's Monaco editor for autocomplete and inline diagnostics. The real validity gate is
|
|
10
|
+
* `validateExpression`/`normalizeCalc`; this schema is a convenience, not the source of truth.
|
|
11
|
+
*/
|
|
12
|
+
const calcExpressionSchema = {
|
|
13
|
+
uri: "https://10xmedia.de/schemas/form-builder/calc-expression.json",
|
|
14
|
+
fileMatch: ["https://10xmedia.de/schemas/form-builder/calc-expression.json"],
|
|
15
|
+
schema: {
|
|
16
|
+
$ref: "#/definitions/expr",
|
|
17
|
+
definitions: {
|
|
18
|
+
expr: { oneOf: [
|
|
19
|
+
{ $ref: "#/definitions/lit" },
|
|
20
|
+
{ $ref: "#/definitions/ref" },
|
|
21
|
+
{ $ref: "#/definitions/op" },
|
|
22
|
+
{ $ref: "#/definitions/neg" },
|
|
23
|
+
{ $ref: "#/definitions/fn" },
|
|
24
|
+
{ $ref: "#/definitions/weight" }
|
|
25
|
+
] },
|
|
26
|
+
lit: {
|
|
27
|
+
type: "object",
|
|
28
|
+
properties: {
|
|
29
|
+
type: { enum: ["lit"] },
|
|
30
|
+
value: { type: "number" }
|
|
31
|
+
},
|
|
32
|
+
required: ["type", "value"],
|
|
33
|
+
additionalProperties: false
|
|
34
|
+
},
|
|
35
|
+
ref: {
|
|
36
|
+
type: "object",
|
|
37
|
+
properties: {
|
|
38
|
+
type: { enum: ["ref"] },
|
|
39
|
+
field: { type: "string" }
|
|
40
|
+
},
|
|
41
|
+
required: ["type", "field"],
|
|
42
|
+
additionalProperties: false
|
|
43
|
+
},
|
|
44
|
+
op: {
|
|
45
|
+
type: "object",
|
|
46
|
+
properties: {
|
|
47
|
+
type: { enum: ["op"] },
|
|
48
|
+
op: { enum: [...CALC_OPS] },
|
|
49
|
+
left: { $ref: "#/definitions/expr" },
|
|
50
|
+
right: { $ref: "#/definitions/expr" }
|
|
51
|
+
},
|
|
52
|
+
required: [
|
|
53
|
+
"type",
|
|
54
|
+
"op",
|
|
55
|
+
"left",
|
|
56
|
+
"right"
|
|
57
|
+
],
|
|
58
|
+
additionalProperties: false
|
|
59
|
+
},
|
|
60
|
+
neg: {
|
|
61
|
+
type: "object",
|
|
62
|
+
properties: {
|
|
63
|
+
type: { enum: ["neg"] },
|
|
64
|
+
operand: { $ref: "#/definitions/expr" }
|
|
65
|
+
},
|
|
66
|
+
required: ["type", "operand"],
|
|
67
|
+
additionalProperties: false
|
|
68
|
+
},
|
|
69
|
+
fn: {
|
|
70
|
+
type: "object",
|
|
71
|
+
properties: {
|
|
72
|
+
type: { enum: ["fn"] },
|
|
73
|
+
fn: { enum: [...CALC_FNS] },
|
|
74
|
+
args: {
|
|
75
|
+
type: "array",
|
|
76
|
+
items: { $ref: "#/definitions/expr" }
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
required: [
|
|
80
|
+
"type",
|
|
81
|
+
"fn",
|
|
82
|
+
"args"
|
|
83
|
+
],
|
|
84
|
+
additionalProperties: false
|
|
85
|
+
},
|
|
86
|
+
weight: {
|
|
87
|
+
type: "object",
|
|
88
|
+
properties: {
|
|
89
|
+
type: { enum: ["weight"] },
|
|
90
|
+
field: { type: "string" },
|
|
91
|
+
weights: {
|
|
92
|
+
type: "object",
|
|
93
|
+
additionalProperties: { type: "number" }
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
required: [
|
|
97
|
+
"type",
|
|
98
|
+
"field",
|
|
99
|
+
"weights"
|
|
100
|
+
],
|
|
101
|
+
additionalProperties: false
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* Validates the calculation field's `expression`: unset/empty is fine, otherwise it must
|
|
108
|
+
* normalize into a well-formed `CalcExpression` tree. Exported for unit testing.
|
|
109
|
+
*/
|
|
110
|
+
const validateExpression = (value, { req }) => {
|
|
111
|
+
if (value == null || value === "") return true;
|
|
112
|
+
return normalizeCalc(value) !== void 0 ? true : asTranslate(req.t)(keys.validationCalcExpressionInvalid);
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* A calculation is derived and read-only: it renders disabled with no text affordance (no
|
|
116
|
+
* `placeholder`), and it is never validated (`runSubmission` stores its computed value and skips
|
|
117
|
+
* `runValidation` entirely), so an authored `required` could never fire. Both are omitted rather
|
|
118
|
+
* than offered as settings that do nothing.
|
|
119
|
+
*/
|
|
120
|
+
const calculationField = defineFormField({
|
|
121
|
+
type: "calculation",
|
|
122
|
+
label: keys.fieldTypeCalculation,
|
|
123
|
+
value: "number",
|
|
124
|
+
omitShared: ["placeholder", "required"],
|
|
125
|
+
config: [{
|
|
126
|
+
name: "expression",
|
|
127
|
+
type: "json",
|
|
128
|
+
label: labelFor(keys.configExpression),
|
|
129
|
+
admin: { description: labelFor(keys.configExpressionDescription) },
|
|
130
|
+
jsonSchema: calcExpressionSchema,
|
|
131
|
+
typescriptSchema: [() => ({ type: "object" })],
|
|
132
|
+
validate: validateExpression
|
|
133
|
+
}, {
|
|
134
|
+
name: "calcDisplay",
|
|
135
|
+
type: "checkbox",
|
|
136
|
+
defaultValue: true,
|
|
137
|
+
label: labelFor(keys.configCalcDisplay)
|
|
138
|
+
}],
|
|
139
|
+
format: ({ value }) => value == null ? "" : String(value)
|
|
140
|
+
});
|
|
141
|
+
//#endregion
|
|
142
|
+
export { calculationField };
|
|
143
|
+
|
|
144
|
+
//# sourceMappingURL=calculation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calculation.js","names":[],"sources":["../../../src/fields/builtin/calculation.ts"],"sourcesContent":["import type { JSONField, PayloadRequest } from 'payload'\nimport { normalizeCalc } from '../../calc/normalizeCalc'\nimport { CALC_FNS, CALC_OPS } from '../../calc/types'\nimport { keys } from '../../translations/keys'\nimport { asTranslate, labelFor } from '../../translations/server'\nimport { defineFormField } from '../defineFormField'\n\ntype CalcExpressionSchema = NonNullable<JSONField['jsonSchema']>\n\n/**\n * Editor-facing JSON schema for `CalcExpression` (src/calc/types.ts), used by the admin JSON\n * field's Monaco editor for autocomplete and inline diagnostics. The real validity gate is\n * `validateExpression`/`normalizeCalc`; this schema is a convenience, not the source of truth.\n */\nconst calcExpressionSchema: CalcExpressionSchema = {\n\turi: 'https://10xmedia.de/schemas/form-builder/calc-expression.json',\n\tfileMatch: ['https://10xmedia.de/schemas/form-builder/calc-expression.json'],\n\tschema: {\n\t\t$ref: '#/definitions/expr',\n\t\tdefinitions: {\n\t\t\texpr: {\n\t\t\t\toneOf: [\n\t\t\t\t\t{ $ref: '#/definitions/lit' },\n\t\t\t\t\t{ $ref: '#/definitions/ref' },\n\t\t\t\t\t{ $ref: '#/definitions/op' },\n\t\t\t\t\t{ $ref: '#/definitions/neg' },\n\t\t\t\t\t{ $ref: '#/definitions/fn' },\n\t\t\t\t\t{ $ref: '#/definitions/weight' },\n\t\t\t\t],\n\t\t\t},\n\t\t\tlit: {\n\t\t\t\ttype: 'object',\n\t\t\t\tproperties: { type: { enum: ['lit'] }, value: { type: 'number' } },\n\t\t\t\trequired: ['type', 'value'],\n\t\t\t\tadditionalProperties: false,\n\t\t\t},\n\t\t\tref: {\n\t\t\t\ttype: 'object',\n\t\t\t\tproperties: { type: { enum: ['ref'] }, field: { type: 'string' } },\n\t\t\t\trequired: ['type', 'field'],\n\t\t\t\tadditionalProperties: false,\n\t\t\t},\n\t\t\top: {\n\t\t\t\ttype: 'object',\n\t\t\t\tproperties: {\n\t\t\t\t\ttype: { enum: ['op'] },\n\t\t\t\t\top: { enum: [...CALC_OPS] },\n\t\t\t\t\tleft: { $ref: '#/definitions/expr' },\n\t\t\t\t\tright: { $ref: '#/definitions/expr' },\n\t\t\t\t},\n\t\t\t\trequired: ['type', 'op', 'left', 'right'],\n\t\t\t\tadditionalProperties: false,\n\t\t\t},\n\t\t\tneg: {\n\t\t\t\ttype: 'object',\n\t\t\t\tproperties: { type: { enum: ['neg'] }, operand: { $ref: '#/definitions/expr' } },\n\t\t\t\trequired: ['type', 'operand'],\n\t\t\t\tadditionalProperties: false,\n\t\t\t},\n\t\t\tfn: {\n\t\t\t\ttype: 'object',\n\t\t\t\tproperties: {\n\t\t\t\t\ttype: { enum: ['fn'] },\n\t\t\t\t\tfn: { enum: [...CALC_FNS] },\n\t\t\t\t\targs: { type: 'array', items: { $ref: '#/definitions/expr' } },\n\t\t\t\t},\n\t\t\t\trequired: ['type', 'fn', 'args'],\n\t\t\t\tadditionalProperties: false,\n\t\t\t},\n\t\t\tweight: {\n\t\t\t\ttype: 'object',\n\t\t\t\tproperties: {\n\t\t\t\t\ttype: { enum: ['weight'] },\n\t\t\t\t\tfield: { type: 'string' },\n\t\t\t\t\tweights: { type: 'object', additionalProperties: { type: 'number' } },\n\t\t\t\t},\n\t\t\t\trequired: ['type', 'field', 'weights'],\n\t\t\t\tadditionalProperties: false,\n\t\t\t},\n\t\t},\n\t},\n}\n\n/**\n * Validates the calculation field's `expression`: unset/empty is fine, otherwise it must\n * normalize into a well-formed `CalcExpression` tree. Exported for unit testing.\n */\nexport const validateExpression = (\n\tvalue: unknown,\n\t{ req }: { data?: unknown; req: PayloadRequest }\n): string | true => {\n\tif (value == null || value === '') {\n\t\treturn true\n\t}\n\treturn normalizeCalc(value) !== undefined\n\t\t? true\n\t\t: asTranslate(req.t)(keys.validationCalcExpressionInvalid)\n}\n\n/**\n * A calculation is derived and read-only: it renders disabled with no text affordance (no\n * `placeholder`), and it is never validated (`runSubmission` stores its computed value and skips\n * `runValidation` entirely), so an authored `required` could never fire. Both are omitted rather\n * than offered as settings that do nothing.\n */\nexport const calculationField = defineFormField<'number'>({\n\ttype: 'calculation',\n\tlabel: keys.fieldTypeCalculation,\n\tvalue: 'number',\n\tomitShared: ['placeholder', 'required'],\n\tconfig: [\n\t\t{\n\t\t\tname: 'expression',\n\t\t\ttype: 'json',\n\t\t\tlabel: labelFor(keys.configExpression),\n\t\t\tadmin: { description: labelFor(keys.configExpressionDescription) },\n\t\t\tjsonSchema: calcExpressionSchema,\n\t\t\t// generate:types embeds jsonSchema.schema into the config-level schema, where its\n\t\t\t// document-root-relative $refs cannot resolve; hand type generation a flat shape instead.\n\t\t\ttypescriptSchema: [() => ({ type: 'object' })],\n\t\t\tvalidate: validateExpression,\n\t\t},\n\t\t{\n\t\t\tname: 'calcDisplay',\n\t\t\ttype: 'checkbox',\n\t\t\tdefaultValue: true,\n\t\t\tlabel: labelFor(keys.configCalcDisplay),\n\t\t},\n\t],\n\tformat: ({ value }) => (value == null ? '' : String(value)),\n})\n"],"mappings":";;;;;;;;;;;AAcA,MAAM,uBAA6C;CAClD,KAAK;CACL,WAAW,CAAC,+DAA+D;CAC3E,QAAQ;EACP,MAAM;EACN,aAAa;GACZ,MAAM,EACL,OAAO;IACN,EAAE,MAAM,oBAAoB;IAC5B,EAAE,MAAM,oBAAoB;IAC5B,EAAE,MAAM,mBAAmB;IAC3B,EAAE,MAAM,oBAAoB;IAC5B,EAAE,MAAM,mBAAmB;IAC3B,EAAE,MAAM,uBAAuB;GAChC,EACD;GACA,KAAK;IACJ,MAAM;IACN,YAAY;KAAE,MAAM,EAAE,MAAM,CAAC,KAAK,EAAE;KAAG,OAAO,EAAE,MAAM,SAAS;IAAE;IACjE,UAAU,CAAC,QAAQ,OAAO;IAC1B,sBAAsB;GACvB;GACA,KAAK;IACJ,MAAM;IACN,YAAY;KAAE,MAAM,EAAE,MAAM,CAAC,KAAK,EAAE;KAAG,OAAO,EAAE,MAAM,SAAS;IAAE;IACjE,UAAU,CAAC,QAAQ,OAAO;IAC1B,sBAAsB;GACvB;GACA,IAAI;IACH,MAAM;IACN,YAAY;KACX,MAAM,EAAE,MAAM,CAAC,IAAI,EAAE;KACrB,IAAI,EAAE,MAAM,CAAC,GAAG,QAAQ,EAAE;KAC1B,MAAM,EAAE,MAAM,qBAAqB;KACnC,OAAO,EAAE,MAAM,qBAAqB;IACrC;IACA,UAAU;KAAC;KAAQ;KAAM;KAAQ;IAAO;IACxC,sBAAsB;GACvB;GACA,KAAK;IACJ,MAAM;IACN,YAAY;KAAE,MAAM,EAAE,MAAM,CAAC,KAAK,EAAE;KAAG,SAAS,EAAE,MAAM,qBAAqB;IAAE;IAC/E,UAAU,CAAC,QAAQ,SAAS;IAC5B,sBAAsB;GACvB;GACA,IAAI;IACH,MAAM;IACN,YAAY;KACX,MAAM,EAAE,MAAM,CAAC,IAAI,EAAE;KACrB,IAAI,EAAE,MAAM,CAAC,GAAG,QAAQ,EAAE;KAC1B,MAAM;MAAE,MAAM;MAAS,OAAO,EAAE,MAAM,qBAAqB;KAAE;IAC9D;IACA,UAAU;KAAC;KAAQ;KAAM;IAAM;IAC/B,sBAAsB;GACvB;GACA,QAAQ;IACP,MAAM;IACN,YAAY;KACX,MAAM,EAAE,MAAM,CAAC,QAAQ,EAAE;KACzB,OAAO,EAAE,MAAM,SAAS;KACxB,SAAS;MAAE,MAAM;MAAU,sBAAsB,EAAE,MAAM,SAAS;KAAE;IACrE;IACA,UAAU;KAAC;KAAQ;KAAS;IAAS;IACrC,sBAAsB;GACvB;EACD;CACD;AACD;;;;;AAMA,MAAa,sBACZ,OACA,EAAE,UACiB;CACnB,IAAI,SAAS,QAAQ,UAAU,IAC9B,OAAO;CAER,OAAO,cAAc,KAAK,MAAM,KAAA,IAC7B,OACA,YAAY,IAAI,CAAC,EAAE,KAAK,+BAA+B;AAC3D;;;;;;;AAQA,MAAa,mBAAmB,gBAA0B;CACzD,MAAM;CACN,OAAO,KAAK;CACZ,OAAO;CACP,YAAY,CAAC,eAAe,UAAU;CACtC,QAAQ,CACP;EACC,MAAM;EACN,MAAM;EACN,OAAO,SAAS,KAAK,gBAAgB;EACrC,OAAO,EAAE,aAAa,SAAS,KAAK,2BAA2B,EAAE;EACjE,YAAY;EAGZ,kBAAkB,QAAQ,EAAE,MAAM,SAAS,EAAE;EAC7C,UAAU;CACX,GACA;EACC,MAAM;EACN,MAAM;EACN,cAAc;EACd,OAAO,SAAS,KAAK,iBAAiB;CACvC,CACD;CACA,SAAS,EAAE,YAAa,SAAS,OAAO,KAAK,OAAO,KAAK;AAC1D,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { keys } from "../../translations/keys.js";
|
|
2
|
+
import { defineFormField } from "../defineFormField.js";
|
|
3
|
+
//#region src/fields/builtin/checkbox.ts
|
|
4
|
+
/**
|
|
5
|
+
* A checkbox renders as a lone box with no free-text affordance, so `placeholder` is never read.
|
|
6
|
+
* The intrinsic validator owns `required`: the engine's shared required guard only fires on an
|
|
7
|
+
* empty value, and `false` (checked, then unchecked) is a present one, so without this a required
|
|
8
|
+
* checkbox would accept an explicit refusal.
|
|
9
|
+
*/
|
|
10
|
+
const checkboxField = defineFormField({
|
|
11
|
+
type: "checkbox",
|
|
12
|
+
label: keys.fieldTypeCheckbox,
|
|
13
|
+
value: "boolean",
|
|
14
|
+
omitShared: ["placeholder"],
|
|
15
|
+
validate: ({ value, config, t }) => config.required === true && value !== true ? t(keys.validationRequired) : true,
|
|
16
|
+
format: ({ value, t }) => value ? t(keys.formatYes) : t(keys.formatNo)
|
|
17
|
+
});
|
|
18
|
+
//#endregion
|
|
19
|
+
export { checkboxField };
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=checkbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkbox.js","names":[],"sources":["../../../src/fields/builtin/checkbox.ts"],"sourcesContent":["import { keys } from '../../translations/keys'\nimport { defineFormField } from '../defineFormField'\n\ntype CheckboxConfig = { required?: boolean }\n\n/**\n * A checkbox renders as a lone box with no free-text affordance, so `placeholder` is never read.\n * The intrinsic validator owns `required`: the engine's shared required guard only fires on an\n * empty value, and `false` (checked, then unchecked) is a present one, so without this a required\n * checkbox would accept an explicit refusal.\n */\nexport const checkboxField = defineFormField<'boolean', CheckboxConfig>({\n\ttype: 'checkbox',\n\tlabel: keys.fieldTypeCheckbox,\n\tvalue: 'boolean',\n\tomitShared: ['placeholder'],\n\tvalidate: ({ value, config, t }) =>\n\t\tconfig.required === true && value !== true ? t(keys.validationRequired) : true,\n\tformat: ({ value, t }) => (value ? t(keys.formatYes) : t(keys.formatNo)),\n})\n"],"mappings":";;;;;;;;;AAWA,MAAa,gBAAgB,gBAA2C;CACvE,MAAM;CACN,OAAO,KAAK;CACZ,OAAO;CACP,YAAY,CAAC,aAAa;CAC1B,WAAW,EAAE,OAAO,QAAQ,QAC3B,OAAO,aAAa,QAAQ,UAAU,OAAO,EAAE,KAAK,kBAAkB,IAAI;CAC3E,SAAS,EAAE,OAAO,QAAS,QAAQ,EAAE,KAAK,SAAS,IAAI,EAAE,KAAK,QAAQ;AACvE,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { keys } from "../../translations/keys.js";
|
|
2
|
+
import { labelForKey } from "../../translations/server.js";
|
|
3
|
+
import { defineFormField } from "../defineFormField.js";
|
|
4
|
+
/**
|
|
5
|
+
* Consent is a reference, so the field is a reference: the author picks a source and nothing else.
|
|
6
|
+
* The statement, the policy page, and its version all live with the source (see
|
|
7
|
+
* `consentSourcesField`), so there is no wording to copy per form, no URL to paste, and no version
|
|
8
|
+
* to type; correcting a statement corrects every form pointing at it. `label` and `placeholder` are
|
|
9
|
+
* dropped for the same reason: the statement is the visible text and the checkbox's accessible name.
|
|
10
|
+
*
|
|
11
|
+
* Registered only when the plugin's `consent.sources` resolver is set, since a consent field with
|
|
12
|
+
* no source to reference has nothing to say and nothing to prove.
|
|
13
|
+
*
|
|
14
|
+
* The intrinsic validator owns `required`: the engine's shared required guard only fires on an
|
|
15
|
+
* empty value, and `false` (the coerced state of both an unchecked box and an absent answer) is a
|
|
16
|
+
* present one, so without this a required consent would accept an explicit refusal.
|
|
17
|
+
*/
|
|
18
|
+
const consentField = defineFormField({
|
|
19
|
+
type: "consent",
|
|
20
|
+
label: keys.fieldTypeConsent,
|
|
21
|
+
value: "boolean",
|
|
22
|
+
omitShared: [
|
|
23
|
+
"label",
|
|
24
|
+
"placeholder",
|
|
25
|
+
"description"
|
|
26
|
+
],
|
|
27
|
+
blockLabel: "@10x-media/form-builder/client#ConsentBlockLabel",
|
|
28
|
+
config: [{
|
|
29
|
+
name: "source",
|
|
30
|
+
type: "text",
|
|
31
|
+
label: labelForKey(keys.consentConfigSource),
|
|
32
|
+
admin: { components: { Field: {
|
|
33
|
+
path: "@10x-media/form-builder/client#EndpointOptionsSelect",
|
|
34
|
+
clientProps: {
|
|
35
|
+
endpoint: "consent-sources",
|
|
36
|
+
descriptionKey: keys.consentConfigSourceDescription,
|
|
37
|
+
isClearable: false
|
|
38
|
+
}
|
|
39
|
+
} } }
|
|
40
|
+
}],
|
|
41
|
+
validate: ({ value, config, t }) => config.required === true && value !== true ? t(keys.validationRequired) : true,
|
|
42
|
+
format: ({ value, t }) => t(value === true ? keys.formatYes : keys.formatNo)
|
|
43
|
+
});
|
|
44
|
+
//#endregion
|
|
45
|
+
export { consentField };
|
|
46
|
+
|
|
47
|
+
//# sourceMappingURL=consent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consent.js","names":[],"sources":["../../../src/fields/builtin/consent.ts"],"sourcesContent":["import { keys } from '../../translations/keys'\nimport { labelForKey } from '../../translations/server'\nimport { defineFormField } from '../defineFormField'\n\ntype ConsentConfig = { source?: string; required?: boolean }\n\nconst SOURCE_FIELD_REF = '@10x-media/form-builder/client#EndpointOptionsSelect'\n\n/**\n * Consent is a reference, so the field is a reference: the author picks a source and nothing else.\n * The statement, the policy page, and its version all live with the source (see\n * `consentSourcesField`), so there is no wording to copy per form, no URL to paste, and no version\n * to type; correcting a statement corrects every form pointing at it. `label` and `placeholder` are\n * dropped for the same reason: the statement is the visible text and the checkbox's accessible name.\n *\n * Registered only when the plugin's `consent.sources` resolver is set, since a consent field with\n * no source to reference has nothing to say and nothing to prove.\n *\n * The intrinsic validator owns `required`: the engine's shared required guard only fires on an\n * empty value, and `false` (the coerced state of both an unchecked box and an absent answer) is a\n * present one, so without this a required consent would accept an explicit refusal.\n */\nexport const consentField = defineFormField<'boolean', ConsentConfig>({\n\ttype: 'consent',\n\tlabel: keys.fieldTypeConsent,\n\tvalue: 'boolean',\n\tomitShared: ['label', 'placeholder', 'description'],\n\tblockLabel: '@10x-media/form-builder/client#ConsentBlockLabel',\n\tconfig: [\n\t\t{\n\t\t\tname: 'source',\n\t\t\ttype: 'text',\n\t\t\tlabel: labelForKey(keys.consentConfigSource),\n\t\t\tadmin: {\n\t\t\t\tcomponents: {\n\t\t\t\t\tField: {\n\t\t\t\t\t\tpath: SOURCE_FIELD_REF,\n\t\t\t\t\t\tclientProps: {\n\t\t\t\t\t\t\tendpoint: 'consent-sources',\n\t\t\t\t\t\t\tdescriptionKey: keys.consentConfigSourceDescription,\n\t\t\t\t\t\t\tisClearable: false,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t],\n\tvalidate: ({ value, config, t }) =>\n\t\tconfig.required === true && value !== true ? t(keys.validationRequired) : true,\n\tformat: ({ value, t }) => t(value === true ? keys.formatYes : keys.formatNo),\n})\n"],"mappings":";;;;;;;;;;;;;;;;;AAsBA,MAAa,eAAe,gBAA0C;CACrE,MAAM;CACN,OAAO,KAAK;CACZ,OAAO;CACP,YAAY;EAAC;EAAS;EAAe;CAAa;CAClD,YAAY;CACZ,QAAQ,CACP;EACC,MAAM;EACN,MAAM;EACN,OAAO,YAAY,KAAK,mBAAmB;EAC3C,OAAO,EACN,YAAY,EACX,OAAO;GACN,MAAM;GACN,aAAa;IACZ,UAAU;IACV,gBAAgB,KAAK;IACrB,aAAa;GACd;EACD,EACD,EACD;CACD,CACD;CACA,WAAW,EAAE,OAAO,QAAQ,QAC3B,OAAO,aAAa,QAAQ,UAAU,OAAO,EAAE,KAAK,kBAAkB,IAAI;CAC3E,SAAS,EAAE,OAAO,QAAQ,EAAE,UAAU,OAAO,KAAK,YAAY,KAAK,QAAQ;AAC5E,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FormFieldConfigValues, FormFieldDefinition } from "../types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/fields/builtin/country.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* A country picker fronted by the fixed ISO 3166-1 alpha-2 set (see {@link COUNTRIES}). Unlike
|
|
6
|
+
* `select` the author does not author options, so there is no `config`; the stored value is the
|
|
7
|
+
* two-letter code and `format` resolves it to the English name. `resolveOptions` exposes the same
|
|
8
|
+
* set as poll choices so a country field can back a poll despite carrying no authored options.
|
|
9
|
+
*/
|
|
10
|
+
declare const countryField: FormFieldDefinition<"text", FormFieldConfigValues>;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { countryField };
|
|
13
|
+
//# sourceMappingURL=country.d.ts.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { keys } from "../../translations/keys.js";
|
|
2
|
+
import { defineFormField } from "../defineFormField.js";
|
|
3
|
+
import { COUNTRIES, countryLabel, isCountryCode } from "../data/regions.js";
|
|
4
|
+
//#region src/fields/builtin/country.ts
|
|
5
|
+
/**
|
|
6
|
+
* A country picker fronted by the fixed ISO 3166-1 alpha-2 set (see {@link COUNTRIES}). Unlike
|
|
7
|
+
* `select` the author does not author options, so there is no `config`; the stored value is the
|
|
8
|
+
* two-letter code and `format` resolves it to the English name. `resolveOptions` exposes the same
|
|
9
|
+
* set as poll choices so a country field can back a poll despite carrying no authored options.
|
|
10
|
+
*/
|
|
11
|
+
const countryField = defineFormField({
|
|
12
|
+
type: "country",
|
|
13
|
+
label: keys.fieldTypeCountry,
|
|
14
|
+
value: "text",
|
|
15
|
+
conditionType: "select",
|
|
16
|
+
pollEligible: true,
|
|
17
|
+
resolveOptions: () => COUNTRIES,
|
|
18
|
+
validate: ({ value, t }) => {
|
|
19
|
+
if (value == null || value === "") return true;
|
|
20
|
+
return isCountryCode(value) ? true : t(keys.validationCountry);
|
|
21
|
+
},
|
|
22
|
+
format: ({ value }) => {
|
|
23
|
+
if (value == null || value === "") return "";
|
|
24
|
+
return countryLabel(value) ?? String(value);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
//#endregion
|
|
28
|
+
export { countryField };
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=country.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"country.js","names":[],"sources":["../../../src/fields/builtin/country.ts"],"sourcesContent":["import { keys } from '../../translations/keys'\nimport { COUNTRIES, countryLabel, isCountryCode } from '../data/regions'\nimport { defineFormField } from '../defineFormField'\n\n/**\n * A country picker fronted by the fixed ISO 3166-1 alpha-2 set (see {@link COUNTRIES}). Unlike\n * `select` the author does not author options, so there is no `config`; the stored value is the\n * two-letter code and `format` resolves it to the English name. `resolveOptions` exposes the same\n * set as poll choices so a country field can back a poll despite carrying no authored options.\n */\nexport const countryField = defineFormField<'text'>({\n\ttype: 'country',\n\tlabel: keys.fieldTypeCountry,\n\tvalue: 'text',\n\tconditionType: 'select',\n\tpollEligible: true,\n\tresolveOptions: () => COUNTRIES,\n\tvalidate: ({ value, t }) => {\n\t\tif (value == null || value === '') {\n\t\t\treturn true\n\t\t}\n\t\treturn isCountryCode(value) ? true : t(keys.validationCountry)\n\t},\n\tformat: ({ value }) => {\n\t\tif (value == null || value === '') {\n\t\t\treturn ''\n\t\t}\n\t\treturn countryLabel(value) ?? String(value)\n\t},\n})\n"],"mappings":";;;;;;;;;;AAUA,MAAa,eAAe,gBAAwB;CACnD,MAAM;CACN,OAAO,KAAK;CACZ,OAAO;CACP,eAAe;CACf,cAAc;CACd,sBAAsB;CACtB,WAAW,EAAE,OAAO,QAAQ;EAC3B,IAAI,SAAS,QAAQ,UAAU,IAC9B,OAAO;EAER,OAAO,cAAc,KAAK,IAAI,OAAO,EAAE,KAAK,iBAAiB;CAC9D;CACA,SAAS,EAAE,YAAY;EACtB,IAAI,SAAS,QAAQ,UAAU,IAC9B,OAAO;EAER,OAAO,aAAa,KAAK,KAAK,OAAO,KAAK;CAC3C;AACD,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { keys } from "../../translations/keys.js";
|
|
2
|
+
import { defineFormField } from "../defineFormField.js";
|
|
3
|
+
//#region src/fields/builtin/date.ts
|
|
4
|
+
const DATE_PATTERN = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
5
|
+
/** True calendar-date check for `YYYY-MM-DD` strings (rejects e.g. `2024-02-30`). */
|
|
6
|
+
const isValidCalendarDate = (value) => {
|
|
7
|
+
const match = DATE_PATTERN.exec(value);
|
|
8
|
+
if (!match) return false;
|
|
9
|
+
const [, yearStr, monthStr, dayStr] = match;
|
|
10
|
+
const year = Number(yearStr);
|
|
11
|
+
const month = Number(monthStr);
|
|
12
|
+
const day = Number(dayStr);
|
|
13
|
+
const date = new Date(Date.UTC(year, month - 1, day));
|
|
14
|
+
return date.getUTCFullYear() === year && date.getUTCMonth() === month - 1 && date.getUTCDate() === day;
|
|
15
|
+
};
|
|
16
|
+
/** `placeholder` is omitted: browsers ignore it on `<input type="date">`, which renders its own picker. */
|
|
17
|
+
const dateField = defineFormField({
|
|
18
|
+
type: "date",
|
|
19
|
+
label: keys.fieldTypeDate,
|
|
20
|
+
value: "date",
|
|
21
|
+
omitShared: ["placeholder"],
|
|
22
|
+
validate: ({ value, t }) => {
|
|
23
|
+
if (value == null || value === "") return true;
|
|
24
|
+
return isValidCalendarDate(value) ? true : t(keys.validationDate);
|
|
25
|
+
},
|
|
26
|
+
format: ({ value }) => value == null ? "" : String(value)
|
|
27
|
+
});
|
|
28
|
+
//#endregion
|
|
29
|
+
export { dateField, isValidCalendarDate };
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=date.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date.js","names":[],"sources":["../../../src/fields/builtin/date.ts"],"sourcesContent":["import { keys } from '../../translations/keys'\nimport { defineFormField } from '../defineFormField'\n\nconst DATE_PATTERN = /^(\\d{4})-(\\d{2})-(\\d{2})$/\n\n/** True calendar-date check for `YYYY-MM-DD` strings (rejects e.g. `2024-02-30`). */\nexport const isValidCalendarDate = (value: string): boolean => {\n\tconst match = DATE_PATTERN.exec(value)\n\tif (!match) {\n\t\treturn false\n\t}\n\tconst [, yearStr, monthStr, dayStr] = match\n\tconst year = Number(yearStr)\n\tconst month = Number(monthStr)\n\tconst day = Number(dayStr)\n\tconst date = new Date(Date.UTC(year, month - 1, day))\n\treturn (\n\t\tdate.getUTCFullYear() === year && date.getUTCMonth() === month - 1 && date.getUTCDate() === day\n\t)\n}\n\n/** `placeholder` is omitted: browsers ignore it on `<input type=\"date\">`, which renders its own picker. */\nexport const dateField = defineFormField<'date'>({\n\ttype: 'date',\n\tlabel: keys.fieldTypeDate,\n\tvalue: 'date',\n\tomitShared: ['placeholder'],\n\tvalidate: ({ value, t }) => {\n\t\tif (value == null || value === '') {\n\t\t\treturn true\n\t\t}\n\t\treturn isValidCalendarDate(value) ? true : t(keys.validationDate)\n\t},\n\tformat: ({ value }) => (value == null ? '' : String(value)),\n})\n"],"mappings":";;;AAGA,MAAM,eAAe;;AAGrB,MAAa,uBAAuB,UAA2B;CAC9D,MAAM,QAAQ,aAAa,KAAK,KAAK;CACrC,IAAI,CAAC,OACJ,OAAO;CAER,MAAM,GAAG,SAAS,UAAU,UAAU;CACtC,MAAM,OAAO,OAAO,OAAO;CAC3B,MAAM,QAAQ,OAAO,QAAQ;CAC7B,MAAM,MAAM,OAAO,MAAM;CACzB,MAAM,OAAO,IAAI,KAAK,KAAK,IAAI,MAAM,QAAQ,GAAG,GAAG,CAAC;CACpD,OACC,KAAK,eAAe,MAAM,QAAQ,KAAK,YAAY,MAAM,QAAQ,KAAK,KAAK,WAAW,MAAM;AAE9F;;AAGA,MAAa,YAAY,gBAAwB;CAChD,MAAM;CACN,OAAO,KAAK;CACZ,OAAO;CACP,YAAY,CAAC,aAAa;CAC1B,WAAW,EAAE,OAAO,QAAQ;EAC3B,IAAI,SAAS,QAAQ,UAAU,IAC9B,OAAO;EAER,OAAO,oBAAoB,KAAK,IAAI,OAAO,EAAE,KAAK,cAAc;CACjE;CACA,SAAS,EAAE,YAAa,SAAS,OAAO,KAAK,OAAO,KAAK;AAC1D,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { keys } from "../../translations/keys.js";
|
|
2
|
+
import { defineFormField } from "../defineFormField.js";
|
|
3
|
+
import { EMAIL_PATTERN } from "../../validation/emailPattern.js";
|
|
4
|
+
//#region src/fields/builtin/email.ts
|
|
5
|
+
const emailField = defineFormField({
|
|
6
|
+
type: "email",
|
|
7
|
+
label: keys.fieldTypeEmail,
|
|
8
|
+
value: "text",
|
|
9
|
+
validate: ({ value, t }) => {
|
|
10
|
+
if (value == null || value === "") return true;
|
|
11
|
+
return EMAIL_PATTERN.test(value) ? true : t(keys.validationEmail);
|
|
12
|
+
},
|
|
13
|
+
format: ({ value }) => value == null ? "" : String(value)
|
|
14
|
+
});
|
|
15
|
+
//#endregion
|
|
16
|
+
export { emailField };
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=email.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email.js","names":[],"sources":["../../../src/fields/builtin/email.ts"],"sourcesContent":["import { keys } from '../../translations/keys'\nimport { EMAIL_PATTERN } from '../../validation/emailPattern'\nimport { defineFormField } from '../defineFormField'\n\nexport const emailField = defineFormField<'text'>({\n\ttype: 'email',\n\tlabel: keys.fieldTypeEmail,\n\tvalue: 'text',\n\tvalidate: ({ value, t }) => {\n\t\tif (value == null || value === '') {\n\t\t\treturn true\n\t\t}\n\t\treturn EMAIL_PATTERN.test(value) ? true : t(keys.validationEmail)\n\t},\n\tformat: ({ value }) => (value == null ? '' : String(value)),\n})\n"],"mappings":";;;;AAIA,MAAa,aAAa,gBAAwB;CACjD,MAAM;CACN,OAAO,KAAK;CACZ,OAAO;CACP,WAAW,EAAE,OAAO,QAAQ;EAC3B,IAAI,SAAS,QAAQ,UAAU,IAC9B,OAAO;EAER,OAAO,cAAc,KAAK,KAAK,IAAI,OAAO,EAAE,KAAK,eAAe;CACjE;CACA,SAAS,EAAE,YAAa,SAAS,OAAO,KAAK,OAAO,KAAK;AAC1D,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region src/fields/builtin/file.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Curated MIME type choices for the file field's `mimeTypes` select. Values are raw MIME strings or
|
|
4
|
+
* trailing-`*` prefix wildcards, exactly the patterns `resolveFileRef` matches server-side; `type/*`
|
|
5
|
+
* values double as the file input's `accept` attribute (browsers ignore other prefix patterns, which
|
|
6
|
+
* is fine since the server stays authoritative). Every value must be 63 bytes or less: Payload's
|
|
7
|
+
* db-postgres adapter stores select options as a pg enum, and pg enum labels cap at 63 bytes.
|
|
8
|
+
*/
|
|
9
|
+
declare const fileMimeTypeOptions: {
|
|
10
|
+
label: string;
|
|
11
|
+
value: string;
|
|
12
|
+
}[];
|
|
13
|
+
//#endregion
|
|
14
|
+
export { fileMimeTypeOptions };
|
|
15
|
+
//# sourceMappingURL=file.d.ts.map
|