@10x-media/form-builder 0.1.0-beta.3 → 0.1.0-beta.5
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 +125 -0
- package/README.md +4 -4
- package/dist/actions/body/serializeBody.d.ts +22 -4
- package/dist/actions/body/serializeBody.js +3 -1
- package/dist/actions/body/serializeBody.js.map +1 -1
- 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/builtin/confirmation.js +51 -12
- package/dist/actions/builtin/confirmation.js.map +1 -1
- package/dist/actions/builtin/emailTeam.js +82 -34
- package/dist/actions/builtin/emailTeam.js.map +1 -1
- package/dist/actions/builtin/index.d.ts +18 -1
- package/dist/actions/builtin/index.js +21 -7
- package/dist/actions/builtin/index.js.map +1 -1
- package/dist/actions/builtin/signedWebhook.js +2 -16
- package/dist/actions/builtin/signedWebhook.js.map +1 -1
- package/dist/actions/defineAction.d.ts +1 -1
- 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/runActions.js +2 -0
- package/dist/actions/runActions.js.map +1 -1
- package/dist/actions/task.js +9 -8
- package/dist/actions/task.js.map +1 -1
- package/dist/aggregation/aggregateResponses.d.ts +9 -0
- package/dist/aggregation/aggregateResponses.js +8 -14
- package/dist/aggregation/aggregateResponses.js.map +1 -1
- package/dist/aggregation/resolveResultsRequest.d.ts +35 -6
- package/dist/aggregation/resolveResultsRequest.js +68 -11
- package/dist/aggregation/resolveResultsRequest.js.map +1 -1
- package/dist/calc/computeCalcFields.js +2 -1
- package/dist/calc/computeCalcFields.js.map +1 -1
- package/dist/client/ByteSizeField.d.ts +8 -0
- package/dist/client/ByteSizeField.js +3 -1
- package/dist/client/ByteSizeField.js.map +1 -1
- 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/EndpointOptionsSelect.d.ts +45 -0
- package/dist/client/EndpointOptionsSelect.js +103 -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 +20 -4
- package/dist/client/FieldNameSelect.js +25 -14
- package/dist/client/FieldNameSelect.js.map +1 -1
- package/dist/client/FlowBuilder.d.ts +2 -1
- package/dist/client/FlowBuilder.js +134 -83
- package/dist/client/FlowBuilder.js.map +1 -1
- 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 +83 -5
- package/dist/client/endpointOptions.js +29 -0
- package/dist/client/endpointOptions.js.map +1 -0
- package/dist/client/flowAuthoring.js +142 -0
- package/dist/client/flowAuthoring.js.map +1 -0
- package/dist/client/synthesizeClientField.js +21 -10
- package/dist/client/synthesizeClientField.js.map +1 -1
- package/dist/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 +55 -12
- package/dist/collections/formSubmissions.js.map +1 -1
- package/dist/collections/forms.js +376 -57
- package/dist/collections/forms.js.map +1 -1
- package/dist/collections/redirectFields.d.ts +29 -0
- package/dist/conditions/conditionType.js +9 -2
- package/dist/conditions/conditionType.js.map +1 -1
- package/dist/conditions/normalizeConditions.js +2 -1
- package/dist/conditions/normalizeConditions.js.map +1 -1
- package/dist/consent/applyConsentStatements.d.ts +14 -0
- package/dist/consent/applyConsentStatements.js +17 -0
- package/dist/consent/applyConsentStatements.js.map +1 -0
- package/dist/consent/captureConsent.d.ts +19 -8
- package/dist/consent/captureConsent.js +34 -11
- package/dist/consent/captureConsent.js.map +1 -1
- package/dist/consent/consentSourcesField.d.ts +58 -0
- package/dist/consent/consentSourcesField.js +79 -0
- package/dist/consent/consentSourcesField.js.map +1 -0
- package/dist/consent/resolveConsentEntries.d.ts +24 -0
- package/dist/consent/resolveConsentEntries.js +43 -0
- package/dist/consent/resolveConsentEntries.js.map +1 -0
- package/dist/consent/resolveConsentSourcesRequest.d.ts +37 -0
- package/dist/consent/resolveConsentSourcesRequest.js +55 -0
- package/dist/consent/resolveConsentSourcesRequest.js.map +1 -0
- package/dist/consent/resolveConsentStatements.d.ts +45 -0
- package/dist/consent/resolveConsentStatements.js +44 -0
- package/dist/consent/resolveConsentStatements.js.map +1 -0
- package/dist/consent/resolvePublishedVersionRef.d.ts +17 -11
- package/dist/consent/resolvePublishedVersionRef.js +13 -10
- package/dist/consent/resolvePublishedVersionRef.js.map +1 -1
- package/dist/consent/types.d.ts +49 -0
- package/dist/email/departments.d.ts +55 -0
- package/dist/email/departments.js +130 -0
- package/dist/email/departments.js.map +1 -0
- package/dist/email/departmentsField.d.ts +49 -0
- package/dist/email/departmentsField.js +69 -0
- package/dist/email/departmentsField.js.map +1 -0
- package/dist/exports/client.d.ts +8 -1
- package/dist/exports/client.js +8 -1
- package/dist/exports/react.d.ts +15 -6
- package/dist/exports/react.js +11 -3
- package/dist/exports/rsc.d.ts +8 -1
- package/dist/exports/rsc.js +8 -1
- package/dist/exports/types.d.ts +18 -10
- package/dist/fields/buildFieldBlocks.js +43 -19
- package/dist/fields/buildFieldBlocks.js.map +1 -1
- package/dist/fields/builtin/calculation.js +7 -0
- package/dist/fields/builtin/calculation.js.map +1 -1
- package/dist/fields/builtin/checkbox.js +8 -0
- package/dist/fields/builtin/checkbox.js.map +1 -1
- package/dist/fields/builtin/consent.js +25 -15
- package/dist/fields/builtin/consent.js.map +1 -1
- package/dist/fields/builtin/country.d.ts +13 -0
- package/dist/fields/builtin/country.js +30 -0
- package/dist/fields/builtin/country.js.map +1 -0
- package/dist/fields/builtin/date.js +2 -0
- package/dist/fields/builtin/date.js.map +1 -1
- package/dist/fields/builtin/file.js +13 -8
- package/dist/fields/builtin/file.js.map +1 -1
- package/dist/fields/builtin/index.d.ts +13 -1
- package/dist/fields/builtin/index.js +20 -7
- package/dist/fields/builtin/index.js.map +1 -1
- package/dist/fields/builtin/message.js +30 -0
- package/dist/fields/builtin/message.js.map +1 -0
- package/dist/fields/builtin/repeater.js +8 -3
- package/dist/fields/builtin/repeater.js.map +1 -1
- package/dist/fields/builtin/select.js +8 -3
- package/dist/fields/builtin/select.js.map +1 -1
- package/dist/fields/builtin/state.d.ts +13 -0
- package/dist/fields/builtin/state.js +30 -0
- package/dist/fields/builtin/state.js.map +1 -0
- package/dist/fields/data/regions.d.ts +21 -0
- package/dist/fields/data/regions.js +1238 -0
- package/dist/fields/data/regions.js.map +1 -0
- package/dist/fields/fieldKey.d.ts +15 -0
- package/dist/fields/fieldKey.js +16 -0
- package/dist/fields/fieldKey.js.map +1 -0
- package/dist/fields/fieldNamesOfType.js +13 -8
- package/dist/fields/fieldNamesOfType.js.map +1 -1
- 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 +1 -0
- package/dist/fields/registry.js +21 -2
- package/dist/fields/registry.js.map +1 -1
- package/dist/fields/sharedConfig.js +101 -51
- package/dist/fields/sharedConfig.js.map +1 -1
- package/dist/fields/types.d.ts +61 -5
- package/dist/flow/engine.d.ts +6 -4
- package/dist/flow/engine.js +11 -6
- package/dist/flow/engine.js.map +1 -1
- package/dist/flow/normalizeFlow.js +22 -7
- package/dist/flow/normalizeFlow.js.map +1 -1
- package/dist/flow/stepLabel.js +15 -0
- package/dist/flow/stepLabel.js.map +1 -0
- package/dist/flow/types.d.ts +12 -3
- package/dist/flow/types.js +11 -0
- package/dist/flow/types.js.map +1 -0
- package/dist/form/pollState.d.ts +22 -0
- package/dist/form/pollState.js +17 -0
- package/dist/form/pollState.js.map +1 -0
- package/dist/form/toFormDocument.d.ts +85 -0
- package/dist/form/toFormDocument.js +75 -0
- package/dist/form/toFormDocument.js.map +1 -0
- package/dist/form/types.d.ts +65 -0
- package/dist/index.d.ts +193 -27
- package/dist/index.js +59 -19
- package/dist/index.js.map +1 -1
- package/dist/plugin/customState.js +26 -0
- package/dist/plugin/customState.js.map +1 -0
- package/dist/plugin/registerCollections.js +33 -44
- package/dist/plugin/registerCollections.js.map +1 -1
- package/dist/plugin/uploadsCollection.d.ts +13 -0
- package/dist/plugin/uploadsCollection.js +44 -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 +71 -0
- package/dist/poll/pollTypeRegistry.js.map +1 -0
- package/dist/poll/registry.d.ts +16 -0
- package/dist/poll/registry.js +16 -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 +51 -0
- package/dist/poll/resolvePollOptionsRequest.js.map +1 -0
- package/dist/poll/resolvePollOutcome.d.ts +34 -0
- package/dist/poll/resolvePollOutcome.js +76 -0
- package/dist/poll/resolvePollOutcome.js.map +1 -0
- package/dist/poll/resultsField.js +21 -0
- package/dist/poll/resultsField.js.map +1 -0
- package/dist/prefill/valuesFromSearchParams.js +3 -2
- package/dist/prefill/valuesFromSearchParams.js.map +1 -1
- package/dist/presentations/types.d.ts +3 -2
- package/dist/react/Form.d.ts +15 -33
- package/dist/react/Form.js +144 -119
- package/dist/react/Form.js.map +1 -1
- package/dist/react/FormContext.d.ts +37 -1
- package/dist/react/FormContext.js.map +1 -1
- package/dist/react/FormControls.d.ts +55 -0
- package/dist/react/FormControls.js +56 -0
- package/dist/react/FormControls.js.map +1 -0
- package/dist/react/FormResults.d.ts +6 -3
- package/dist/react/FormResults.js +37 -29
- package/dist/react/FormResults.js.map +1 -1
- package/dist/react/FormSteps.d.ts +17 -0
- package/dist/react/FormSteps.js +35 -0
- package/dist/react/FormSteps.js.map +1 -0
- package/dist/react/Poll.d.ts +17 -6
- package/dist/react/Poll.js +66 -18
- package/dist/react/Poll.js.map +1 -1
- package/dist/react/contract.d.ts +2 -3
- package/dist/react/contract.js.map +1 -1
- package/dist/react/fetchResults.d.ts +1 -1
- package/dist/react/fetchResults.js +1 -1
- package/dist/react/fetchResults.js.map +1 -1
- package/dist/react/primitives/Checkbox.d.ts +4 -2
- package/dist/react/primitives/Checkbox.js +2 -1
- package/dist/react/primitives/Checkbox.js.map +1 -1
- package/dist/react/primitives/FieldShell.d.ts +2 -4
- package/dist/react/primitives/FieldShell.js +12 -19
- package/dist/react/primitives/FieldShell.js.map +1 -1
- package/dist/react/renderers/calculation.js +1 -2
- package/dist/react/renderers/calculation.js.map +1 -1
- package/dist/react/renderers/checkbox.js +1 -2
- package/dist/react/renderers/checkbox.js.map +1 -1
- package/dist/react/renderers/consent.js +78 -34
- package/dist/react/renderers/consent.js.map +1 -1
- package/dist/react/renderers/date.js +1 -3
- package/dist/react/renderers/date.js.map +1 -1
- package/dist/react/renderers/email.js +1 -2
- package/dist/react/renderers/email.js.map +1 -1
- package/dist/react/renderers/file.js +6 -3
- package/dist/react/renderers/file.js.map +1 -1
- package/dist/react/renderers/index.js +5 -0
- package/dist/react/renderers/index.js.map +1 -1
- package/dist/react/renderers/message.js +35 -0
- package/dist/react/renderers/message.js.map +1 -0
- package/dist/react/renderers/number.js +1 -2
- package/dist/react/renderers/number.js.map +1 -1
- package/dist/react/renderers/region.js +45 -0
- package/dist/react/renderers/region.js.map +1 -0
- package/dist/react/renderers/repeater.js +7 -10
- package/dist/react/renderers/repeater.js.map +1 -1
- package/dist/react/renderers/select.js +1 -2
- package/dist/react/renderers/select.js.map +1 -1
- package/dist/react/renderers/text.js +1 -2
- package/dist/react/renderers/text.js.map +1 -1
- package/dist/react/renderers/textarea.js +1 -2
- package/dist/react/renderers/textarea.js.map +1 -1
- package/dist/react/state.d.ts +23 -2
- package/dist/react/state.js +16 -7
- package/dist/react/state.js.map +1 -1
- package/dist/react/uploadFile.d.ts +2 -2
- package/dist/react/uploadFile.js +1 -1
- package/dist/react/uploadFile.js.map +1 -1
- package/dist/react/useField.d.ts +0 -1
- package/dist/react/useField.js +0 -1
- package/dist/react/useField.js.map +1 -1
- package/dist/react/useFormState.d.ts +1 -1
- package/dist/react/useFormState.js +1 -1
- package/dist/react/useFormState.js.map +1 -1
- package/dist/react/validateField.js +3 -6
- package/dist/react/validateField.js.map +1 -1
- package/dist/recall/interpolate.d.ts +4 -3
- package/dist/recall/interpolate.js +5 -4
- package/dist/recall/interpolate.js.map +1 -1
- package/dist/recall/resolver.d.ts +1 -1
- package/dist/recall/resolver.js +14 -2
- package/dist/recall/resolver.js.map +1 -1
- package/dist/spam/captcha.d.ts +1 -1
- package/dist/spam/captcha.js +1 -1
- package/dist/spam/captcha.js.map +1 -1
- package/dist/submissions/SubmissionAnswers.js +6 -2
- package/dist/submissions/SubmissionAnswers.js.map +1 -1
- package/dist/submissions/SubmissionAnswersClient.js +91 -62
- package/dist/submissions/SubmissionAnswersClient.js.map +1 -1
- 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 +92 -44
- package/dist/submissions/runSubmission.js.map +1 -1
- package/dist/submissions/types.d.ts +11 -4
- package/dist/submissions/validateSubmission.js +59 -10
- package/dist/submissions/validateSubmission.js.map +1 -1
- package/dist/submissions/votedCookie.d.ts +13 -0
- package/dist/submissions/votedCookie.js +27 -0
- package/dist/submissions/votedCookie.js.map +1 -0
- package/dist/translations/de.js +295 -0
- package/dist/translations/de.js.map +1 -0
- package/dist/translations/en.js +138 -23
- package/dist/translations/en.js.map +1 -1
- package/dist/translations/index.d.ts +2 -1
- package/dist/translations/index.js +6 -2
- package/dist/translations/index.js.map +1 -1
- package/dist/translations/keys.d.ts +134 -19
- package/dist/translations/keys.js +135 -20
- package/dist/translations/keys.js.map +1 -1
- package/dist/uploads/types.d.ts +1 -2
- package/dist/validation/buildRuleBlocks.js +18 -17
- package/dist/validation/buildRuleBlocks.js.map +1 -1
- package/dist/validation/builtin/email.js +1 -0
- package/dist/validation/builtin/email.js.map +1 -1
- package/dist/validation/builtin/matchesField.js +3 -7
- package/dist/validation/builtin/matchesField.js.map +1 -1
- package/dist/validation/builtin/max.js +1 -0
- package/dist/validation/builtin/max.js.map +1 -1
- package/dist/validation/builtin/maxDate.js +1 -0
- package/dist/validation/builtin/maxDate.js.map +1 -1
- package/dist/validation/builtin/maxLength.js +1 -0
- package/dist/validation/builtin/maxLength.js.map +1 -1
- package/dist/validation/builtin/min.js +1 -0
- package/dist/validation/builtin/min.js.map +1 -1
- package/dist/validation/builtin/minDate.js +1 -0
- package/dist/validation/builtin/minDate.js.map +1 -1
- package/dist/validation/builtin/minLength.js +1 -0
- package/dist/validation/builtin/minLength.js.map +1 -1
- package/dist/validation/builtin/notAlreadySubmitted.js +1 -0
- package/dist/validation/builtin/notAlreadySubmitted.js.map +1 -1
- package/dist/validation/builtin/oneOf.js +1 -0
- package/dist/validation/builtin/oneOf.js.map +1 -1
- package/dist/validation/builtin/pattern.js +11 -2
- package/dist/validation/builtin/pattern.js.map +1 -1
- package/dist/validation/builtin/url.js +1 -0
- package/dist/validation/builtin/url.js.map +1 -1
- package/dist/validation/builtin/validateRegexParams.js +44 -0
- package/dist/validation/builtin/validateRegexParams.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/runValidation.js +8 -29
- package/dist/validation/runValidation.js.map +1 -1
- package/dist/validation/types.d.ts +5 -11
- package/dist/validation/validateUrl.js +22 -0
- package/dist/validation/validateUrl.js.map +1 -0
- package/package.json +7 -6
- package/styles/form-builder.css +10 -0
- package/dist/collections/uploads.d.ts +0 -30
- package/dist/collections/uploads.js +0 -55
- package/dist/collections/uploads.js.map +0 -1
- package/dist/consent/buildConsentSourceConfig.js +0 -49
- package/dist/consent/buildConsentSourceConfig.js.map +0 -1
- package/dist/consent/builtin/index.d.ts +0 -7
- package/dist/consent/builtin/index.js +0 -11
- package/dist/consent/builtin/index.js.map +0 -1
- package/dist/consent/builtin/pageReference.js +0 -75
- package/dist/consent/builtin/pageReference.js.map +0 -1
- package/dist/consent/builtin/static.js +0 -44
- package/dist/consent/builtin/static.js.map +0 -1
- package/dist/consent/defineConsentSource.d.ts +0 -35
- package/dist/consent/defineConsentSource.js +0 -6
- package/dist/consent/defineConsentSource.js.map +0 -1
- package/dist/consent/registry.d.ts +0 -16
- package/dist/consent/registry.js +0 -16
- package/dist/consent/registry.js.map +0 -1
- package/dist/consent/resolveConsentLinks.d.ts +0 -19
- package/dist/consent/resolveConsentLinks.js +0 -26
- package/dist/consent/resolveConsentLinks.js.map +0 -1
- package/dist/presentations/registry.d.ts +0 -15
- package/dist/presentations/registry.js +0 -15
- package/dist/presentations/registry.js.map +0 -1
- package/dist/react/toFormDocument.d.ts +0 -24
- package/dist/react/toFormDocument.js +0 -22
- package/dist/react/toFormDocument.js.map +0 -1
|
@@ -1,29 +1,39 @@
|
|
|
1
1
|
import { keys } from "../../translations/keys.js";
|
|
2
|
-
import {
|
|
2
|
+
import { labelForKey } from "../../translations/server.js";
|
|
3
3
|
import { defineFormField } from "../defineFormField.js";
|
|
4
|
-
//#region src/fields/builtin/consent.ts
|
|
5
4
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
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.
|
|
9
17
|
*/
|
|
10
18
|
const consentField = defineFormField({
|
|
11
19
|
type: "consent",
|
|
12
20
|
label: keys.fieldTypeConsent,
|
|
13
21
|
value: "boolean",
|
|
22
|
+
omitShared: ["label", "placeholder"],
|
|
14
23
|
config: [{
|
|
15
|
-
name: "
|
|
24
|
+
name: "source",
|
|
16
25
|
type: "text",
|
|
17
|
-
label:
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
26
|
+
label: labelForKey(keys.consentConfigSource),
|
|
27
|
+
admin: { components: { Field: {
|
|
28
|
+
path: "@10x-media/form-builder/client#EndpointOptionsSelect",
|
|
29
|
+
clientProps: {
|
|
30
|
+
endpoint: "consent-sources",
|
|
31
|
+
descriptionKey: keys.consentConfigSourceDescription,
|
|
32
|
+
isClearable: false
|
|
33
|
+
}
|
|
34
|
+
} } }
|
|
22
35
|
}],
|
|
23
|
-
validate: ({ value, config, t }) =>
|
|
24
|
-
if (!(config.optional === true) && value !== true) return t(keys.validationRequired);
|
|
25
|
-
return true;
|
|
26
|
-
},
|
|
36
|
+
validate: ({ value, config, t }) => config.required === true && value !== true ? t(keys.validationRequired) : true,
|
|
27
37
|
format: ({ value, t }) => t(value === true ? keys.formatYes : keys.formatNo)
|
|
28
38
|
});
|
|
29
39
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consent.js","names":[],"sources":["../../../src/fields/builtin/consent.ts"],"sourcesContent":["import { keys } from '../../translations/keys'\nimport {
|
|
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'],\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,CAAC,SAAS,aAAa;CACnC,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"}
|
|
@@ -13,10 +13,12 @@ const isValidCalendarDate = (value) => {
|
|
|
13
13
|
const date = new Date(Date.UTC(year, month - 1, day));
|
|
14
14
|
return date.getUTCFullYear() === year && date.getUTCMonth() === month - 1 && date.getUTCDate() === day;
|
|
15
15
|
};
|
|
16
|
+
/** `placeholder` is omitted: browsers ignore it on `<input type="date">`, which renders its own picker. */
|
|
16
17
|
const dateField = defineFormField({
|
|
17
18
|
type: "date",
|
|
18
19
|
label: keys.fieldTypeDate,
|
|
19
20
|
value: "date",
|
|
21
|
+
omitShared: ["placeholder"],
|
|
20
22
|
validate: ({ value, t }) => {
|
|
21
23
|
if (value == null || value === "") return true;
|
|
22
24
|
return isValidCalendarDate(value) ? true : t(keys.validationDate);
|
|
@@ -1 +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\nexport const dateField = defineFormField<'date'>({\n\ttype: 'date',\n\tlabel: keys.fieldTypeDate,\n\tvalue: 'date',\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
|
|
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"}
|
|
@@ -77,18 +77,23 @@ const fileMimeTypeOptions = [
|
|
|
77
77
|
* The `file` field type. Its stored value is a server-captured {@link FileRef}; the client only ever submits
|
|
78
78
|
* the upload id, and `runSubmission` re-reads filename/mimeType/filesize from the upload doc at the trust
|
|
79
79
|
* boundary (see `captureFileRef`). The intrinsic validator is intentionally a no-op: MIME/size/existence are
|
|
80
|
-
* enforced authoritatively server-side against the stored doc, never against client metadata. `
|
|
81
|
-
*
|
|
80
|
+
* enforced authoritatively server-side against the stored doc, never against client metadata. `mimeTypes`
|
|
81
|
+
* and `maxSize` persist on the block so the capture can enforce them. `uploadsCollection` is not
|
|
82
|
+
* author-editable: a forms hook stamps the plugin-configured uploads collection slug onto it on every save
|
|
83
|
+
* so the client renderer knows where to POST; the server never trusts it at submit time (plugin config
|
|
84
|
+
* stays the source of truth). Named `uploadsCollection` because `collection` is a mongoose-reserved
|
|
85
|
+
* schema pathname.
|
|
82
86
|
*/
|
|
83
87
|
const fileField = defineFormField({
|
|
84
88
|
type: "file",
|
|
85
89
|
label: keys.fieldTypeFile,
|
|
86
90
|
value: "file",
|
|
91
|
+
omitShared: ["placeholder"],
|
|
87
92
|
config: [
|
|
88
93
|
{
|
|
89
|
-
name: "
|
|
94
|
+
name: "uploadsCollection",
|
|
90
95
|
type: "text",
|
|
91
|
-
|
|
96
|
+
admin: { hidden: true }
|
|
92
97
|
},
|
|
93
98
|
{
|
|
94
99
|
name: "mimeTypes",
|
|
@@ -102,10 +107,10 @@ const fileField = defineFormField({
|
|
|
102
107
|
type: "number",
|
|
103
108
|
min: 0,
|
|
104
109
|
label: labelFor(keys.fileConfigMaxSize),
|
|
105
|
-
admin: {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
110
|
+
admin: { components: { Field: {
|
|
111
|
+
path: MAX_SIZE_REF,
|
|
112
|
+
clientProps: { descriptionKey: keys.fileConfigMaxSizeDescription }
|
|
113
|
+
} } }
|
|
109
114
|
}
|
|
110
115
|
],
|
|
111
116
|
format: ({ value }) => isFileRef(value) ? value.filename : ""
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file.js","names":[],"sources":["../../../src/fields/builtin/file.ts"],"sourcesContent":["import { keys } from '../../translations/keys'\nimport { labelFor } from '../../translations/server'\nimport type { FileRef } from '../../uploads/types'\nimport { defineFormField } from '../defineFormField'\n\ntype FileConfig = {\n\
|
|
1
|
+
{"version":3,"file":"file.js","names":[],"sources":["../../../src/fields/builtin/file.ts"],"sourcesContent":["import { keys } from '../../translations/keys'\nimport { labelFor } from '../../translations/server'\nimport type { FileRef } from '../../uploads/types'\nimport { defineFormField } from '../defineFormField'\n\ntype FileConfig = {\n\tuploadsCollection?: string\n\tmimeTypes?: string[]\n\tmaxSize?: number\n}\n\nconst isFileRef = (value: unknown): value is FileRef =>\n\ttypeof value === 'object' && value !== null && 'filename' in value\n\nconst MAX_SIZE_REF = '@10x-media/form-builder/client#ByteSizeField'\n\n/**\n * Curated MIME type choices for the file field's `mimeTypes` select. Values are raw MIME strings or\n * trailing-`*` prefix wildcards, exactly the patterns `resolveFileRef` matches server-side; `type/*`\n * values double as the file input's `accept` attribute (browsers ignore other prefix patterns, which\n * is fine since the server stays authoritative). Every value must be 63 bytes or less: Payload's\n * db-postgres adapter stores select options as a pg enum, and pg enum labels cap at 63 bytes.\n */\nexport const fileMimeTypeOptions = [\n\t{ label: 'Any image', value: 'image/*' },\n\t{ label: 'PNG image', value: 'image/png' },\n\t{ label: 'JPEG image', value: 'image/jpeg' },\n\t{ label: 'WebP image', value: 'image/webp' },\n\t{ label: 'GIF image', value: 'image/gif' },\n\t{ label: 'SVG image', value: 'image/svg+xml' },\n\t{ label: 'PDF', value: 'application/pdf' },\n\t{ label: 'Plain text', value: 'text/plain' },\n\t{ label: 'CSV', value: 'text/csv' },\n\t{ label: 'ZIP archive', value: 'application/zip' },\n\t{ label: 'Word document (.doc)', value: 'application/msword' },\n\t{ label: 'Excel spreadsheet (.xls)', value: 'application/vnd.ms-excel' },\n\t{\n\t\tlabel: 'Office documents (docx, xlsx, pptx)',\n\t\tvalue: 'application/vnd.openxmlformats-officedocument.*',\n\t},\n\t{ label: 'Any audio', value: 'audio/*' },\n\t{ label: 'Any video', value: 'video/*' },\n]\n\n/**\n * The `file` field type. Its stored value is a server-captured {@link FileRef}; the client only ever submits\n * the upload id, and `runSubmission` re-reads filename/mimeType/filesize from the upload doc at the trust\n * boundary (see `captureFileRef`). The intrinsic validator is intentionally a no-op: MIME/size/existence are\n * enforced authoritatively server-side against the stored doc, never against client metadata. `mimeTypes`\n * and `maxSize` persist on the block so the capture can enforce them. `uploadsCollection` is not\n * author-editable: a forms hook stamps the plugin-configured uploads collection slug onto it on every save\n * so the client renderer knows where to POST; the server never trusts it at submit time (plugin config\n * stays the source of truth). Named `uploadsCollection` because `collection` is a mongoose-reserved\n * schema pathname.\n */\nexport const fileField = defineFormField<'file', FileConfig>({\n\ttype: 'file',\n\tlabel: keys.fieldTypeFile,\n\tvalue: 'file',\n\tomitShared: ['placeholder'],\n\tconfig: [\n\t\t{ name: 'uploadsCollection', type: 'text', admin: { hidden: true } },\n\t\t{\n\t\t\tname: 'mimeTypes',\n\t\t\ttype: 'select',\n\t\t\thasMany: true,\n\t\t\toptions: fileMimeTypeOptions,\n\t\t\tlabel: labelFor(keys.fileConfigMimeTypes),\n\t\t},\n\t\t{\n\t\t\tname: 'maxSize',\n\t\t\ttype: 'number',\n\t\t\tmin: 0,\n\t\t\tlabel: labelFor(keys.fileConfigMaxSize),\n\t\t\tadmin: {\n\t\t\t\tcomponents: {\n\t\t\t\t\tField: {\n\t\t\t\t\t\tpath: MAX_SIZE_REF,\n\t\t\t\t\t\tclientProps: { descriptionKey: keys.fileConfigMaxSizeDescription },\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t],\n\tformat: ({ value }) => (isFileRef(value) ? value.filename : ''),\n})\n"],"mappings":";;;;AAWA,MAAM,aAAa,UAClB,OAAO,UAAU,YAAY,UAAU,QAAQ,cAAc;AAE9D,MAAM,eAAe;;;;;;;;AASrB,MAAa,sBAAsB;CAClC;EAAE,OAAO;EAAa,OAAO;CAAU;CACvC;EAAE,OAAO;EAAa,OAAO;CAAY;CACzC;EAAE,OAAO;EAAc,OAAO;CAAa;CAC3C;EAAE,OAAO;EAAc,OAAO;CAAa;CAC3C;EAAE,OAAO;EAAa,OAAO;CAAY;CACzC;EAAE,OAAO;EAAa,OAAO;CAAgB;CAC7C;EAAE,OAAO;EAAO,OAAO;CAAkB;CACzC;EAAE,OAAO;EAAc,OAAO;CAAa;CAC3C;EAAE,OAAO;EAAO,OAAO;CAAW;CAClC;EAAE,OAAO;EAAe,OAAO;CAAkB;CACjD;EAAE,OAAO;EAAwB,OAAO;CAAqB;CAC7D;EAAE,OAAO;EAA4B,OAAO;CAA2B;CACvE;EACC,OAAO;EACP,OAAO;CACR;CACA;EAAE,OAAO;EAAa,OAAO;CAAU;CACvC;EAAE,OAAO;EAAa,OAAO;CAAU;AACxC;;;;;;;;;;;;AAaA,MAAa,YAAY,gBAAoC;CAC5D,MAAM;CACN,OAAO,KAAK;CACZ,OAAO;CACP,YAAY,CAAC,aAAa;CAC1B,QAAQ;EACP;GAAE,MAAM;GAAqB,MAAM;GAAQ,OAAO,EAAE,QAAQ,KAAK;EAAE;EACnE;GACC,MAAM;GACN,MAAM;GACN,SAAS;GACT,SAAS;GACT,OAAO,SAAS,KAAK,mBAAmB;EACzC;EACA;GACC,MAAM;GACN,MAAM;GACN,KAAK;GACL,OAAO,SAAS,KAAK,iBAAiB;GACtC,OAAO,EACN,YAAY,EACX,OAAO;IACN,MAAM;IACN,aAAa,EAAE,gBAAgB,KAAK,6BAA6B;GAClE,EACD,EACD;EACD;CACD;CACA,SAAS,EAAE,YAAa,UAAU,KAAK,IAAI,MAAM,WAAW;AAC7D,CAAC"}
|
|
@@ -1,14 +1,26 @@
|
|
|
1
1
|
import { AnyFormFieldDefinition } from "../types.js";
|
|
2
|
+
import { RichTextField } from "payload";
|
|
2
3
|
|
|
3
4
|
//#region src/fields/builtin/index.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Built-in field definitions with content-bearing config fields (select option labels, repeater add
|
|
7
|
+
* label) carrying `localized: true` when `localize` is true. `editor`, when given, overrides the
|
|
8
|
+
* richText editor on the message content field (from the plugin's `richText.editor` option). Field
|
|
9
|
+
* types without content config are shared static definitions. Definitions are authored with precise
|
|
10
|
+
* value/config generics; the registry stores them erased (config is re-narrowed per matched type at
|
|
11
|
+
* execution), hence one cast per built-in, no `any`.
|
|
12
|
+
*/
|
|
13
|
+
declare const buildDefaultFieldDefinitions: (localize: boolean, editor?: RichTextField["editor"]) => AnyFormFieldDefinition[];
|
|
4
14
|
declare const defaultFieldDefinitions: AnyFormFieldDefinition[];
|
|
5
15
|
/**
|
|
6
16
|
* `defaultFieldDefinitions` indexed by `type`, so a single built-in can be spread and tweaked
|
|
7
17
|
* without hand-rolling a `.find()`, e.g.
|
|
8
18
|
* `fields: { text: { ...defaultFieldDefinitionsByType.text, validate: myValidate } }`. The
|
|
9
19
|
* `fields` plugin option replaces a built-in of the same `type`; `false` removes it, `true` keeps it.
|
|
20
|
+
* Prebuilt with content localization on; with `localizeContent: false`, derive overrides from
|
|
21
|
+
* `buildDefaultFieldDefinitions(false)` instead so the spread does not reintroduce `localized`.
|
|
10
22
|
*/
|
|
11
23
|
declare const defaultFieldDefinitionsByType: Record<string, AnyFormFieldDefinition>;
|
|
12
24
|
//#endregion
|
|
13
|
-
export { defaultFieldDefinitions, defaultFieldDefinitionsByType };
|
|
25
|
+
export { buildDefaultFieldDefinitions, defaultFieldDefinitions, defaultFieldDefinitionsByType };
|
|
14
26
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -4,33 +4,46 @@ import { consentField } from "./consent.js";
|
|
|
4
4
|
import { dateField } from "./date.js";
|
|
5
5
|
import { emailField } from "./email.js";
|
|
6
6
|
import { fileField } from "./file.js";
|
|
7
|
+
import { buildMessageField } from "./message.js";
|
|
7
8
|
import { numberField } from "./number.js";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
9
|
+
import { buildRepeaterField } from "./repeater.js";
|
|
10
|
+
import { buildSelectField } from "./select.js";
|
|
10
11
|
import { textField } from "./text.js";
|
|
11
12
|
import { textareaField } from "./textarea.js";
|
|
12
13
|
//#region src/fields/builtin/index.ts
|
|
13
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Built-in field definitions with content-bearing config fields (select option labels, repeater add
|
|
16
|
+
* label) carrying `localized: true` when `localize` is true. `editor`, when given, overrides the
|
|
17
|
+
* richText editor on the message content field (from the plugin's `richText.editor` option). Field
|
|
18
|
+
* types without content config are shared static definitions. Definitions are authored with precise
|
|
19
|
+
* value/config generics; the registry stores them erased (config is re-narrowed per matched type at
|
|
20
|
+
* execution), hence one cast per built-in, no `any`.
|
|
21
|
+
*/
|
|
22
|
+
const buildDefaultFieldDefinitions = (localize, editor) => [
|
|
14
23
|
textField,
|
|
15
24
|
textareaField,
|
|
16
25
|
emailField,
|
|
17
26
|
numberField,
|
|
18
|
-
|
|
27
|
+
buildSelectField(localize),
|
|
19
28
|
checkboxField,
|
|
20
29
|
calculationField,
|
|
21
30
|
consentField,
|
|
22
31
|
fileField,
|
|
23
|
-
|
|
24
|
-
dateField
|
|
32
|
+
buildRepeaterField(localize),
|
|
33
|
+
dateField,
|
|
34
|
+
buildMessageField(localize, editor)
|
|
25
35
|
];
|
|
36
|
+
const defaultFieldDefinitions = buildDefaultFieldDefinitions(true);
|
|
26
37
|
/**
|
|
27
38
|
* `defaultFieldDefinitions` indexed by `type`, so a single built-in can be spread and tweaked
|
|
28
39
|
* without hand-rolling a `.find()`, e.g.
|
|
29
40
|
* `fields: { text: { ...defaultFieldDefinitionsByType.text, validate: myValidate } }`. The
|
|
30
41
|
* `fields` plugin option replaces a built-in of the same `type`; `false` removes it, `true` keeps it.
|
|
42
|
+
* Prebuilt with content localization on; with `localizeContent: false`, derive overrides from
|
|
43
|
+
* `buildDefaultFieldDefinitions(false)` instead so the spread does not reintroduce `localized`.
|
|
31
44
|
*/
|
|
32
45
|
const defaultFieldDefinitionsByType = Object.fromEntries(defaultFieldDefinitions.map((definition) => [definition.type, definition]));
|
|
33
46
|
//#endregion
|
|
34
|
-
export { defaultFieldDefinitions, defaultFieldDefinitionsByType };
|
|
47
|
+
export { buildDefaultFieldDefinitions, defaultFieldDefinitions, defaultFieldDefinitionsByType };
|
|
35
48
|
|
|
36
49
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/fields/builtin/index.ts"],"sourcesContent":["import type { AnyFormFieldDefinition } from '../types'\nimport { calculationField } from './calculation'\nimport { checkboxField } from './checkbox'\nimport { consentField } from './consent'\nimport { dateField } from './date'\nimport { emailField } from './email'\nimport { fileField } from './file'\nimport { numberField } from './number'\nimport {
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/fields/builtin/index.ts"],"sourcesContent":["import type { RichTextField } from 'payload'\nimport type { AnyFormFieldDefinition } from '../types'\nimport { calculationField } from './calculation'\nimport { checkboxField } from './checkbox'\nimport { consentField } from './consent'\nimport { dateField } from './date'\nimport { emailField } from './email'\nimport { fileField } from './file'\nimport { buildMessageField } from './message'\nimport { numberField } from './number'\nimport { buildRepeaterField } from './repeater'\nimport { buildSelectField } from './select'\nimport { textField } from './text'\nimport { textareaField } from './textarea'\n\n/**\n * Built-in field definitions with content-bearing config fields (select option labels, repeater add\n * label) carrying `localized: true` when `localize` is true. `editor`, when given, overrides the\n * richText editor on the message content field (from the plugin's `richText.editor` option). Field\n * types without content config are shared static definitions. Definitions are authored with precise\n * value/config generics; the registry stores them erased (config is re-narrowed per matched type at\n * execution), hence one cast per built-in, no `any`.\n */\nexport const buildDefaultFieldDefinitions = (\n\tlocalize: boolean,\n\teditor?: RichTextField['editor']\n): AnyFormFieldDefinition[] => [\n\ttextField as AnyFormFieldDefinition,\n\ttextareaField as AnyFormFieldDefinition,\n\temailField as AnyFormFieldDefinition,\n\tnumberField as AnyFormFieldDefinition,\n\tbuildSelectField(localize) as AnyFormFieldDefinition,\n\tcheckboxField as AnyFormFieldDefinition,\n\tcalculationField as AnyFormFieldDefinition,\n\tconsentField as AnyFormFieldDefinition,\n\tfileField as AnyFormFieldDefinition,\n\tbuildRepeaterField(localize) as AnyFormFieldDefinition,\n\tdateField as AnyFormFieldDefinition,\n\tbuildMessageField(localize, editor) as AnyFormFieldDefinition,\n]\n\nexport const defaultFieldDefinitions: AnyFormFieldDefinition[] = buildDefaultFieldDefinitions(true)\n\n/**\n * `defaultFieldDefinitions` indexed by `type`, so a single built-in can be spread and tweaked\n * without hand-rolling a `.find()`, e.g.\n * `fields: { text: { ...defaultFieldDefinitionsByType.text, validate: myValidate } }`. The\n * `fields` plugin option replaces a built-in of the same `type`; `false` removes it, `true` keeps it.\n * Prebuilt with content localization on; with `localizeContent: false`, derive overrides from\n * `buildDefaultFieldDefinitions(false)` instead so the spread does not reintroduce `localized`.\n */\nexport const defaultFieldDefinitionsByType: Record<string, AnyFormFieldDefinition> =\n\tObject.fromEntries(defaultFieldDefinitions.map((definition) => [definition.type, definition]))\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAuBA,MAAa,gCACZ,UACA,WAC8B;CAC9B;CACA;CACA;CACA;CACA,iBAAiB,QAAQ;CACzB;CACA;CACA;CACA;CACA,mBAAmB,QAAQ;CAC3B;CACA,kBAAkB,UAAU,MAAM;AACnC;AAEA,MAAa,0BAAoD,6BAA6B,IAAI;;;;;;;;;AAUlG,MAAa,gCACZ,OAAO,YAAY,wBAAwB,KAAK,eAAe,CAAC,WAAW,MAAM,UAAU,CAAC,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { localizedIf } from "../localizedIf.js";
|
|
2
|
+
import { keys } from "../../translations/keys.js";
|
|
3
|
+
import { labelFor } from "../../translations/server.js";
|
|
4
|
+
import { defineFormField } from "../defineFormField.js";
|
|
5
|
+
//#region src/fields/builtin/message.ts
|
|
6
|
+
/**
|
|
7
|
+
* Display-only inline rich text rendered between fields. Bare: the block is just the `content`
|
|
8
|
+
* richText, no name/label/width/validation chrome, and instances are identified by their block
|
|
9
|
+
* row id (see `fieldKey`). Value kind `'none'`: the engine never validates it and never writes it
|
|
10
|
+
* to submissions. `content` is authored copy and follows `localize`; `editor`, when given,
|
|
11
|
+
* overrides the host config's default richText editor (from the plugin's `richText.editor`).
|
|
12
|
+
*/
|
|
13
|
+
const buildMessageField = (localize, editor) => defineFormField({
|
|
14
|
+
type: "message",
|
|
15
|
+
label: keys.fieldTypeMessage,
|
|
16
|
+
value: "none",
|
|
17
|
+
bare: true,
|
|
18
|
+
config: [{
|
|
19
|
+
name: "content",
|
|
20
|
+
type: "richText",
|
|
21
|
+
label: labelFor(keys.configContent),
|
|
22
|
+
...editor ? { editor } : {},
|
|
23
|
+
...localizedIf(localize)
|
|
24
|
+
}]
|
|
25
|
+
});
|
|
26
|
+
buildMessageField(true);
|
|
27
|
+
//#endregion
|
|
28
|
+
export { buildMessageField };
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=message.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message.js","names":[],"sources":["../../../src/fields/builtin/message.ts"],"sourcesContent":["import type { RichTextField } from 'payload'\nimport { keys } from '../../translations/keys'\nimport { labelFor } from '../../translations/server'\nimport { defineFormField } from '../defineFormField'\nimport { localizedIf } from '../localizedIf'\n\n/**\n * Display-only inline rich text rendered between fields. Bare: the block is just the `content`\n * richText, no name/label/width/validation chrome, and instances are identified by their block\n * row id (see `fieldKey`). Value kind `'none'`: the engine never validates it and never writes it\n * to submissions. `content` is authored copy and follows `localize`; `editor`, when given,\n * overrides the host config's default richText editor (from the plugin's `richText.editor`).\n */\nexport const buildMessageField = (localize: boolean, editor?: RichTextField['editor']) =>\n\tdefineFormField<'none'>({\n\t\ttype: 'message',\n\t\tlabel: keys.fieldTypeMessage,\n\t\tvalue: 'none',\n\t\tbare: true,\n\t\tconfig: [\n\t\t\t{\n\t\t\t\tname: 'content',\n\t\t\t\ttype: 'richText',\n\t\t\t\tlabel: labelFor(keys.configContent),\n\t\t\t\t...(editor ? { editor } : {}),\n\t\t\t\t...localizedIf(localize),\n\t\t\t},\n\t\t],\n\t})\n\nexport const messageField = buildMessageField(true)\n"],"mappings":";;;;;;;;;;;;AAaA,MAAa,qBAAqB,UAAmB,WACpD,gBAAwB;CACvB,MAAM;CACN,OAAO,KAAK;CACZ,OAAO;CACP,MAAM;CACN,QAAQ,CACP;EACC,MAAM;EACN,MAAM;EACN,OAAO,SAAS,KAAK,aAAa;EAClC,GAAI,SAAS,EAAE,OAAO,IAAI,CAAC;EAC3B,GAAG,YAAY,QAAQ;CACxB,CACD;AACD,CAAC;AAE0B,kBAAkB,IAAI"}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
+
import { localizedIf } from "../localizedIf.js";
|
|
1
2
|
import { keys } from "../../translations/keys.js";
|
|
2
3
|
import { labelFor } from "../../translations/server.js";
|
|
3
4
|
import { defineFormField } from "../defineFormField.js";
|
|
4
5
|
//#region src/fields/builtin/repeater.ts
|
|
5
|
-
|
|
6
|
+
/** `addLabel` is the visitor-facing add-row button text and follows `localize`; row bounds never do. */
|
|
7
|
+
const buildRepeaterField = (localize) => defineFormField({
|
|
6
8
|
type: "repeater",
|
|
7
9
|
label: keys.fieldTypeRepeater,
|
|
8
10
|
value: "repeater",
|
|
11
|
+
omitShared: ["placeholder"],
|
|
9
12
|
config: [
|
|
10
13
|
{
|
|
11
14
|
name: "minRows",
|
|
@@ -22,7 +25,8 @@ const repeaterField = defineFormField({
|
|
|
22
25
|
{
|
|
23
26
|
name: "addLabel",
|
|
24
27
|
type: "text",
|
|
25
|
-
label: labelFor(keys.configAddLabel)
|
|
28
|
+
label: labelFor(keys.configAddLabel),
|
|
29
|
+
...localizedIf(localize)
|
|
26
30
|
}
|
|
27
31
|
],
|
|
28
32
|
validate: ({ value, config, t }) => {
|
|
@@ -38,7 +42,8 @@ const repeaterField = defineFormField({
|
|
|
38
42
|
return t(keys.repeaterRowCount).replace("{count}", String(count));
|
|
39
43
|
}
|
|
40
44
|
});
|
|
45
|
+
buildRepeaterField(true);
|
|
41
46
|
//#endregion
|
|
42
|
-
export {
|
|
47
|
+
export { buildRepeaterField };
|
|
43
48
|
|
|
44
49
|
//# sourceMappingURL=repeater.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repeater.js","names":[],"sources":["../../../src/fields/builtin/repeater.ts"],"sourcesContent":["import { keys } from '../../translations/keys'\nimport { labelFor } from '../../translations/server'\nimport { defineFormField } from '../defineFormField'\n\ntype RepeaterConfig = {\n\tminRows?: number\n\tmaxRows?: number\n\taddLabel?: string\n}\n\nexport const
|
|
1
|
+
{"version":3,"file":"repeater.js","names":[],"sources":["../../../src/fields/builtin/repeater.ts"],"sourcesContent":["import { keys } from '../../translations/keys'\nimport { labelFor } from '../../translations/server'\nimport { defineFormField } from '../defineFormField'\nimport { localizedIf } from '../localizedIf'\n\ntype RepeaterConfig = {\n\tminRows?: number\n\tmaxRows?: number\n\taddLabel?: string\n}\n\n/** `addLabel` is the visitor-facing add-row button text and follows `localize`; row bounds never do. */\nexport const buildRepeaterField = (localize: boolean) =>\n\tdefineFormField<'repeater', RepeaterConfig>({\n\t\ttype: 'repeater',\n\t\tlabel: keys.fieldTypeRepeater,\n\t\tvalue: 'repeater',\n\t\tomitShared: ['placeholder'],\n\t\tconfig: [\n\t\t\t{\n\t\t\t\tname: 'minRows',\n\t\t\t\ttype: 'number',\n\t\t\t\tmin: 0,\n\t\t\t\tlabel: labelFor(keys.configMinRows),\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'maxRows',\n\t\t\t\ttype: 'number',\n\t\t\t\tmin: 1,\n\t\t\t\tlabel: labelFor(keys.configMaxRows),\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'addLabel',\n\t\t\t\ttype: 'text',\n\t\t\t\tlabel: labelFor(keys.configAddLabel),\n\t\t\t\t...localizedIf(localize),\n\t\t\t},\n\t\t\t// subFields blocks field is injected by buildFieldBlocks after the main loop,\n\t\t\t// so all non-repeater blocks are available and repeater-in-repeater is excluded.\n\t\t],\n\t\tvalidate: ({ value, config, t }) => {\n\t\t\tconst rows = Array.isArray(value) ? value : []\n\t\t\tconst min = typeof config.minRows === 'number' ? config.minRows : 0\n\t\t\tif (rows.length < min) {\n\t\t\t\treturn t(keys.validationRepeaterMin).replace('{min}', String(min))\n\t\t\t}\n\t\t\tconst max = typeof config.maxRows === 'number' ? config.maxRows : undefined\n\t\t\tif (max != null && rows.length > max) {\n\t\t\t\treturn t(keys.validationRepeaterMax).replace('{max}', String(max))\n\t\t\t}\n\t\t\treturn true\n\t\t},\n\t\tformat: ({ value, t }) => {\n\t\t\tconst count = Array.isArray(value) ? value.length : 0\n\t\t\treturn t(keys.repeaterRowCount).replace('{count}', String(count))\n\t\t},\n\t})\n\nexport const repeaterField = buildRepeaterField(true)\n"],"mappings":";;;;;;AAYA,MAAa,sBAAsB,aAClC,gBAA4C;CAC3C,MAAM;CACN,OAAO,KAAK;CACZ,OAAO;CACP,YAAY,CAAC,aAAa;CAC1B,QAAQ;EACP;GACC,MAAM;GACN,MAAM;GACN,KAAK;GACL,OAAO,SAAS,KAAK,aAAa;EACnC;EACA;GACC,MAAM;GACN,MAAM;GACN,KAAK;GACL,OAAO,SAAS,KAAK,aAAa;EACnC;EACA;GACC,MAAM;GACN,MAAM;GACN,OAAO,SAAS,KAAK,cAAc;GACnC,GAAG,YAAY,QAAQ;EACxB;CAGD;CACA,WAAW,EAAE,OAAO,QAAQ,QAAQ;EACnC,MAAM,OAAO,MAAM,QAAQ,KAAK,IAAI,QAAQ,CAAC;EAC7C,MAAM,MAAM,OAAO,OAAO,YAAY,WAAW,OAAO,UAAU;EAClE,IAAI,KAAK,SAAS,KACjB,OAAO,EAAE,KAAK,qBAAqB,EAAE,QAAQ,SAAS,OAAO,GAAG,CAAC;EAElE,MAAM,MAAM,OAAO,OAAO,YAAY,WAAW,OAAO,UAAU,KAAA;EAClE,IAAI,OAAO,QAAQ,KAAK,SAAS,KAChC,OAAO,EAAE,KAAK,qBAAqB,EAAE,QAAQ,SAAS,OAAO,GAAG,CAAC;EAElE,OAAO;CACR;CACA,SAAS,EAAE,OAAO,QAAQ;EACzB,MAAM,QAAQ,MAAM,QAAQ,KAAK,IAAI,MAAM,SAAS;EACpD,OAAO,EAAE,KAAK,gBAAgB,EAAE,QAAQ,WAAW,OAAO,KAAK,CAAC;CACjE;AACD,CAAC;AAE2B,mBAAmB,IAAI"}
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
+
import { localizedIf } from "../localizedIf.js";
|
|
1
2
|
import { keys } from "../../translations/keys.js";
|
|
2
3
|
import { labelFor } from "../../translations/server.js";
|
|
3
4
|
import { defineFormField } from "../defineFormField.js";
|
|
4
5
|
//#region src/fields/builtin/select.ts
|
|
5
|
-
|
|
6
|
+
/** Option `label` is author-facing content and follows `localize`; `value` is an identifier and never does. */
|
|
7
|
+
const buildSelectField = (localize) => defineFormField({
|
|
6
8
|
type: "select",
|
|
7
9
|
label: keys.fieldTypeSelect,
|
|
8
10
|
value: "text",
|
|
9
11
|
conditionType: "select",
|
|
12
|
+
pollEligible: true,
|
|
10
13
|
config: [{
|
|
11
14
|
name: "options",
|
|
12
15
|
type: "array",
|
|
@@ -19,7 +22,8 @@ const selectField = defineFormField({
|
|
|
19
22
|
name: "label",
|
|
20
23
|
type: "text",
|
|
21
24
|
required: true,
|
|
22
|
-
label: labelFor(keys.configOptionLabel)
|
|
25
|
+
label: labelFor(keys.configOptionLabel),
|
|
26
|
+
...localizedIf(localize)
|
|
23
27
|
}, {
|
|
24
28
|
name: "value",
|
|
25
29
|
type: "text",
|
|
@@ -38,7 +42,8 @@ const selectField = defineFormField({
|
|
|
38
42
|
return optionLabels?.[value] ?? String(value);
|
|
39
43
|
}
|
|
40
44
|
});
|
|
45
|
+
buildSelectField(true);
|
|
41
46
|
//#endregion
|
|
42
|
-
export {
|
|
47
|
+
export { buildSelectField };
|
|
43
48
|
|
|
44
49
|
//# sourceMappingURL=select.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select.js","names":[],"sources":["../../../src/fields/builtin/select.ts"],"sourcesContent":["import { keys } from '../../translations/keys'\nimport { labelFor } from '../../translations/server'\nimport { defineFormField } from '../defineFormField'\n\ntype SelectOption = { label: string; value: string }\ntype SelectConfig = { options?: SelectOption[] }\n\nexport const
|
|
1
|
+
{"version":3,"file":"select.js","names":[],"sources":["../../../src/fields/builtin/select.ts"],"sourcesContent":["import { keys } from '../../translations/keys'\nimport { labelFor } from '../../translations/server'\nimport { defineFormField } from '../defineFormField'\nimport { localizedIf } from '../localizedIf'\n\ntype SelectOption = { label: string; value: string }\ntype SelectConfig = { options?: SelectOption[] }\n\n/** Option `label` is author-facing content and follows `localize`; `value` is an identifier and never does. */\nexport const buildSelectField = (localize: boolean) =>\n\tdefineFormField<'text', SelectConfig>({\n\t\ttype: 'select',\n\t\tlabel: keys.fieldTypeSelect,\n\t\tvalue: 'text',\n\t\tconditionType: 'select',\n\t\tpollEligible: true,\n\t\tconfig: [\n\t\t\t{\n\t\t\t\tname: 'options',\n\t\t\t\ttype: 'array',\n\t\t\t\tlabel: labelFor(keys.configOptions),\n\t\t\t\tlabels: { singular: labelFor(keys.configOption), plural: labelFor(keys.configOptions) },\n\t\t\t\tfields: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'label',\n\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\trequired: true,\n\t\t\t\t\t\tlabel: labelFor(keys.configOptionLabel),\n\t\t\t\t\t\t...localizedIf(localize),\n\t\t\t\t\t},\n\t\t\t\t\t{ name: 'value', type: 'text', required: true, label: labelFor(keys.configOptionValue) },\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t\tvalidate: ({ value, config, t }) => {\n\t\t\tif (value == null || value === '') {\n\t\t\t\treturn true\n\t\t\t}\n\t\t\tconst options = config.options ?? []\n\t\t\tif (options.length === 0) {\n\t\t\t\treturn true\n\t\t\t}\n\t\t\treturn options.some((option) => option.value === value) ? true : t(keys.validationSelect)\n\t\t},\n\t\tformat: ({ value, optionLabels }) => {\n\t\t\tif (value == null || value === '') {\n\t\t\t\treturn ''\n\t\t\t}\n\t\t\treturn optionLabels?.[value] ?? String(value)\n\t\t},\n\t})\n\nexport const selectField = buildSelectField(true)\n"],"mappings":";;;;;;AASA,MAAa,oBAAoB,aAChC,gBAAsC;CACrC,MAAM;CACN,OAAO,KAAK;CACZ,OAAO;CACP,eAAe;CACf,cAAc;CACd,QAAQ,CACP;EACC,MAAM;EACN,MAAM;EACN,OAAO,SAAS,KAAK,aAAa;EAClC,QAAQ;GAAE,UAAU,SAAS,KAAK,YAAY;GAAG,QAAQ,SAAS,KAAK,aAAa;EAAE;EACtF,QAAQ,CACP;GACC,MAAM;GACN,MAAM;GACN,UAAU;GACV,OAAO,SAAS,KAAK,iBAAiB;GACtC,GAAG,YAAY,QAAQ;EACxB,GACA;GAAE,MAAM;GAAS,MAAM;GAAQ,UAAU;GAAM,OAAO,SAAS,KAAK,iBAAiB;EAAE,CACxF;CACD,CACD;CACA,WAAW,EAAE,OAAO,QAAQ,QAAQ;EACnC,IAAI,SAAS,QAAQ,UAAU,IAC9B,OAAO;EAER,MAAM,UAAU,OAAO,WAAW,CAAC;EACnC,IAAI,QAAQ,WAAW,GACtB,OAAO;EAER,OAAO,QAAQ,MAAM,WAAW,OAAO,UAAU,KAAK,IAAI,OAAO,EAAE,KAAK,gBAAgB;CACzF;CACA,SAAS,EAAE,OAAO,mBAAmB;EACpC,IAAI,SAAS,QAAQ,UAAU,IAC9B,OAAO;EAER,OAAO,eAAe,UAAU,OAAO,KAAK;CAC7C;AACD,CAAC;AAEyB,iBAAiB,IAAI"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FormFieldConfigValues, FormFieldDefinition } from "../types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/fields/builtin/state.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* A US state/DC picker fronted by the fixed USPS-code set (see {@link US_STATES}), scoped US-only to
|
|
6
|
+
* match native's `state` block. Like `country` the author authors no options; the stored value is the
|
|
7
|
+
* state code and `format` resolves it to the state name. `resolveOptions` exposes the set as poll
|
|
8
|
+
* choices so a state field can back a poll despite carrying no authored options.
|
|
9
|
+
*/
|
|
10
|
+
declare const stateField: FormFieldDefinition<"text", FormFieldConfigValues>;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { stateField };
|
|
13
|
+
//# sourceMappingURL=state.d.ts.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { keys } from "../../translations/keys.js";
|
|
2
|
+
import { defineFormField } from "../defineFormField.js";
|
|
3
|
+
import { US_STATES, isUsStateCode, usStateLabel } from "../data/regions.js";
|
|
4
|
+
//#region src/fields/builtin/state.ts
|
|
5
|
+
/**
|
|
6
|
+
* A US state/DC picker fronted by the fixed USPS-code set (see {@link US_STATES}), scoped US-only to
|
|
7
|
+
* match native's `state` block. Like `country` the author authors no options; the stored value is the
|
|
8
|
+
* state code and `format` resolves it to the state name. `resolveOptions` exposes the set as poll
|
|
9
|
+
* choices so a state field can back a poll despite carrying no authored options.
|
|
10
|
+
*/
|
|
11
|
+
const stateField = defineFormField({
|
|
12
|
+
type: "state",
|
|
13
|
+
label: keys.fieldTypeState,
|
|
14
|
+
value: "text",
|
|
15
|
+
conditionType: "select",
|
|
16
|
+
pollEligible: true,
|
|
17
|
+
resolveOptions: () => US_STATES,
|
|
18
|
+
validate: ({ value, t }) => {
|
|
19
|
+
if (value == null || value === "") return true;
|
|
20
|
+
return isUsStateCode(value) ? true : t(keys.validationState);
|
|
21
|
+
},
|
|
22
|
+
format: ({ value }) => {
|
|
23
|
+
if (value == null || value === "") return "";
|
|
24
|
+
return usStateLabel(value) ?? String(value);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
//#endregion
|
|
28
|
+
export { stateField };
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.js","names":[],"sources":["../../../src/fields/builtin/state.ts"],"sourcesContent":["import { keys } from '../../translations/keys'\nimport { isUsStateCode, US_STATES, usStateLabel } from '../data/regions'\nimport { defineFormField } from '../defineFormField'\n\n/**\n * A US state/DC picker fronted by the fixed USPS-code set (see {@link US_STATES}), scoped US-only to\n * match native's `state` block. Like `country` the author authors no options; the stored value is the\n * state code and `format` resolves it to the state name. `resolveOptions` exposes the set as poll\n * choices so a state field can back a poll despite carrying no authored options.\n */\nexport const stateField = defineFormField<'text'>({\n\ttype: 'state',\n\tlabel: keys.fieldTypeState,\n\tvalue: 'text',\n\tconditionType: 'select',\n\tpollEligible: true,\n\tresolveOptions: () => US_STATES,\n\tvalidate: ({ value, t }) => {\n\t\tif (value == null || value === '') {\n\t\t\treturn true\n\t\t}\n\t\treturn isUsStateCode(value) ? true : t(keys.validationState)\n\t},\n\tformat: ({ value }) => {\n\t\tif (value == null || value === '') {\n\t\t\treturn ''\n\t\t}\n\t\treturn usStateLabel(value) ?? String(value)\n\t},\n})\n"],"mappings":";;;;;;;;;;AAUA,MAAa,aAAa,gBAAwB;CACjD,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,eAAe;CAC5D;CACA,SAAS,EAAE,YAAY;EACtB,IAAI,SAAS,QAAQ,UAAU,IAC9B,OAAO;EAER,OAAO,aAAa,KAAK,KAAK,OAAO,KAAK;CAC3C;AACD,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//#region src/fields/data/regions.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Fixed option sets for the built-in `country` and `state` field types: the author never authors
|
|
4
|
+
* these, so unlike `select` they live in code, not per-instance config. A plain data module with no
|
|
5
|
+
* dependencies, imported on both the server (validation, `format`, poll options) and the client (the
|
|
6
|
+
* frontend renderer, the condition builder), so it must stay isomorphic. `value` is the stored code
|
|
7
|
+
* and is the stable identity contract (never localize it); `label` is the English display name.
|
|
8
|
+
*/
|
|
9
|
+
/** ISO 3166-1 alpha-2 codes with their English short names (every officially assigned code). */
|
|
10
|
+
declare const COUNTRIES: {
|
|
11
|
+
label: string;
|
|
12
|
+
value: string;
|
|
13
|
+
}[];
|
|
14
|
+
/** The 50 US states plus the District of Columbia, keyed by USPS code. Matches native's US-only `state` block. */
|
|
15
|
+
declare const US_STATES: {
|
|
16
|
+
label: string;
|
|
17
|
+
value: string;
|
|
18
|
+
}[];
|
|
19
|
+
//#endregion
|
|
20
|
+
export { COUNTRIES, US_STATES };
|
|
21
|
+
//# sourceMappingURL=regions.d.ts.map
|