@10x-media/form-builder 0.1.0-beta.5 → 0.1.0-beta.6

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.
Files changed (87) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/dist/actions/builtin/confirmation.js +75 -72
  3. package/dist/actions/builtin/confirmation.js.map +1 -1
  4. package/dist/actions/builtin/emailTeam.js +31 -41
  5. package/dist/actions/builtin/emailTeam.js.map +1 -1
  6. package/dist/actions/builtin/index.d.ts +2 -1
  7. package/dist/actions/builtin/index.js +3 -3
  8. package/dist/actions/builtin/index.js.map +1 -1
  9. package/dist/actions/emailRecipients.d.ts +12 -0
  10. package/dist/actions/emailRecipients.js +72 -0
  11. package/dist/actions/emailRecipients.js.map +1 -0
  12. package/dist/client/ConsentBlockLabel.d.ts +15 -0
  13. package/dist/client/ConsentBlockLabel.js +71 -0
  14. package/dist/client/ConsentBlockLabel.js.map +1 -0
  15. package/dist/client/ConsentSourceRowLabel.d.ts +9 -0
  16. package/dist/client/ConsentSourceRowLabel.js +21 -0
  17. package/dist/client/ConsentSourceRowLabel.js.map +1 -0
  18. package/dist/client/EndpointOptionsSelect.d.ts +1 -0
  19. package/dist/client/EndpointOptionsSelect.js +4 -1
  20. package/dist/client/EndpointOptionsSelect.js.map +1 -1
  21. package/dist/client/FieldNameSelect.d.ts +1 -0
  22. package/dist/client/FieldNameSelect.js +4 -1
  23. package/dist/client/FieldNameSelect.js.map +1 -1
  24. package/dist/client/RecipientsSelect.d.ts +31 -0
  25. package/dist/client/RecipientsSelect.js +174 -0
  26. package/dist/client/RecipientsSelect.js.map +1 -0
  27. package/dist/client/admin.css +5 -0
  28. package/dist/collections/formSubmissions.js +2 -1
  29. package/dist/collections/formSubmissions.js.map +1 -1
  30. package/dist/collections/forms.js +18 -2
  31. package/dist/collections/forms.js.map +1 -1
  32. package/dist/consent/captureConsent.d.ts +14 -5
  33. package/dist/consent/captureConsent.js +24 -7
  34. package/dist/consent/captureConsent.js.map +1 -1
  35. package/dist/consent/consentSourcesField.d.ts +4 -0
  36. package/dist/consent/consentSourcesField.js +8 -1
  37. package/dist/consent/consentSourcesField.js.map +1 -1
  38. package/dist/consent/types.d.ts +4 -0
  39. package/dist/email/departments.d.ts +13 -9
  40. package/dist/email/departments.js +7 -50
  41. package/dist/email/departments.js.map +1 -1
  42. package/dist/email/departmentsField.d.ts +4 -0
  43. package/dist/email/departmentsField.js +4 -0
  44. package/dist/email/departmentsField.js.map +1 -1
  45. package/dist/exports/client.d.ts +4 -1
  46. package/dist/exports/client.js +4 -1
  47. package/dist/exports/react.js +1 -1
  48. package/dist/exports/rsc.js +1 -1
  49. package/dist/fields/buildFieldBlocks.js +4 -4
  50. package/dist/fields/buildFieldBlocks.js.map +1 -1
  51. package/dist/fields/builtin/consent.js +6 -1
  52. package/dist/fields/builtin/consent.js.map +1 -1
  53. package/dist/fields/builtin/file.js +9 -3
  54. package/dist/fields/builtin/file.js.map +1 -1
  55. package/dist/fields/builtin/index.d.ts +1 -1
  56. package/dist/fields/builtin/index.js +3 -3
  57. package/dist/fields/builtin/index.js.map +1 -1
  58. package/dist/fields/types.d.ts +9 -2
  59. package/dist/form/toFormDocument.d.ts +20 -3
  60. package/dist/form/toFormDocument.js +16 -4
  61. package/dist/form/toFormDocument.js.map +1 -1
  62. package/dist/form/types.d.ts +5 -5
  63. package/dist/index.d.ts +14 -5
  64. package/dist/index.js +9 -6
  65. package/dist/index.js.map +1 -1
  66. package/dist/plugin/registerCollections.js +2 -1
  67. package/dist/plugin/registerCollections.js.map +1 -1
  68. package/dist/plugin/uploadsCollection.d.ts +3 -0
  69. package/dist/plugin/uploadsCollection.js +10 -1
  70. package/dist/plugin/uploadsCollection.js.map +1 -1
  71. package/dist/submissions/SubmissionAnswers.js.map +1 -1
  72. package/dist/submissions/SubmissionAnswersClient.js +33 -26
  73. package/dist/submissions/SubmissionAnswersClient.js.map +1 -1
  74. package/dist/submissions/runSubmission.js +3 -2
  75. package/dist/submissions/runSubmission.js.map +1 -1
  76. package/dist/submissions/validateSubmission.js +2 -1
  77. package/dist/submissions/validateSubmission.js.map +1 -1
  78. package/dist/translations/de.js +4 -2
  79. package/dist/translations/de.js.map +1 -1
  80. package/dist/translations/en.js +4 -2
  81. package/dist/translations/en.js.map +1 -1
  82. package/dist/translations/keys.d.ts +4 -2
  83. package/dist/translations/keys.js +4 -2
  84. package/dist/translations/keys.js.map +1 -1
  85. package/dist/uploads/resolveFileRef.js +2 -1
  86. package/dist/uploads/resolveFileRef.js.map +1 -1
  87. package/package.json +4 -4
package/dist/index.d.ts CHANGED
@@ -38,11 +38,12 @@ import { AggregateFieldResponsesArgs, AggregateFormResponsesArgs, aggregateField
38
38
  import { FormResultsAccess, FormResultsAccessArgs, ResolveResultsRequestArgs, ResolveResultsRequestResult, resolveFormResultsRequest } from "./aggregation/resolveResultsRequest.js";
39
39
  import { ButtonFieldsOverride, ButtonsOption, DefaultButtonFields, buildDefaultButtonFields, buildNextLabelField, buildPrevLabelField, buildSubmitLabelField } from "./collections/buttonFields.js";
40
40
  import { FieldCondition } from "./conditions/types.js";
41
- import { ConsentProof, captureConsent } from "./consent/captureConsent.js";
41
+ import { ConsentProof, ConsentSnapshotMode, captureConsent } from "./consent/captureConsent.js";
42
42
  import { ConsentSourcesFieldOptions, consentSourcesField } from "./consent/consentSourcesField.js";
43
43
  import { ResolveConsentEntriesArgs, resolveConsentEntries } from "./consent/resolveConsentEntries.js";
44
44
  import { ConsentSourceOption, ResolveConsentSourcesRequestArgs, ResolveConsentSourcesRequestResult, resolveConsentSourcesRequest } from "./consent/resolveConsentSourcesRequest.js";
45
45
  import { ResolvePublishedVersionRefArgs, resolvePublishedVersionRef } from "./consent/resolvePublishedVersionRef.js";
46
+ import { RecipientsConfig } from "./actions/emailRecipients.js";
46
47
  import { RedirectFieldsOverride, RedirectOption, ResponseOption } from "./collections/redirectFields.js";
47
48
  import { DepartmentEmailsResolver, DepartmentOption, ResolveDepartmentOptionsArgs, ResolveDepartmentsRequestArgs, ResolveDepartmentsRequestResult, resolveDepartmentOptions } from "./email/departments.js";
48
49
  import { CollectionOverrides } from "./plugin/collectionOverrides.js";
@@ -141,12 +142,13 @@ type FormBuilderPluginOptions = {
141
142
  * lookup). Storing the resolved address, rather than a department id resolved live at send (consent's
142
143
  * model), is deliberate: the routing target a form was saved with stays audit-stable even if the
143
144
  * resolver's data later changes, so do not "fix" it into a live lookup. Multi-tenant hosts scope
144
- * which document they read by the tenant derived from `req`; absent, `to` stays a plain localized
145
- * text field.
145
+ * which document they read by the tenant derived from `req`; absent, the recipient fields simply
146
+ * offer no preset department options (still free-typed emails and field tokens).
146
147
  */
147
148
  email?: {
148
149
  fromAddresses?: FromAddressesResolver;
149
- departments?: DepartmentEmailsResolver;
150
+ departments?: DepartmentEmailsResolver; /** Narrows the recipient fields' behavior (free-typed emails, field tokens). See {@link RecipientsConfig}. */
151
+ recipients?: RecipientsConfig;
150
152
  };
151
153
  /**
152
154
  * Where the consent statements a form can reference come from. Absent (the default): no sources,
@@ -164,6 +166,13 @@ type FormBuilderPluginOptions = {
164
166
  */
165
167
  consent?: {
166
168
  sources: ConsentSourcesResolver;
169
+ /**
170
+ * What each submission snapshots of the agreed consent wording, for a versioned audit trail.
171
+ * `'both'` (default) stores a `statementHash`, the plain `statementText`, and the source name;
172
+ * `'hash'` keeps only the tamper-evident hash; `'text'` only the readable text; `false` keeps the
173
+ * lean id-only proof. The proof stays id-based regardless; this only adds the wording snapshot.
174
+ */
175
+ snapshot?: ConsentSnapshotMode;
167
176
  };
168
177
  /**
169
178
  * Form-level button labels: `submitLabel` at the bottom of the Fields tab, `prevLabel` and
@@ -272,5 +281,5 @@ declare module 'payload' {
272
281
  }
273
282
  declare const formBuilder: (options: FormBuilderPluginOptions) => import("payload").Plugin;
274
283
  //#endregion
275
- export { type ActionDefinition, type ActionOption, type ActionRegistry, type ActionResult, type ActionRunArgs, type ActionsConfig, type AggregateFieldResponsesArgs, type AggregateFormResponsesArgs, type AggregationBucket, type AggregationRow, type AnyActionDefinition, type AnyFormFieldDefinition, type AnyPollOptionSource, type AnyValidationRuleDefinition, type BodyContext, type BodyConverter, type BodyConverterArgs, type BodyRender, type ButtonFieldsOverride, type ButtonsOption, CAPTCHA_TOKEN_KEY, type CalcExpression, type CaptchaProvider, type CaptchaVerifyArgs, type ConsentProof, type ConsentSourceEntry, type ConsentSourceOption, type ConsentSourcePage, type ConsentSourcesFieldOptions, type ConsentSourcesResolver, type ConsentStatement, type ConsentStatements, type CreateSubmissionArgs, type CreatedSubmission, DEFAULT_HONEYPOT_FIELD, DEFAULT_PRESENTATION_NAME, type DefaultButtonFields, type DefaultOutcomeFields, type DepartmentEmailsResolver, type DepartmentOption, type DepartmentsFieldOptions, type FieldAggregation, type FieldCondition, type FieldMeta, type FieldTargetParamOptions, type FieldTypeOption, type FieldTypeRegistry, type FieldTypesConfig, type FileFieldConfig, type FileRef, type FileRefError, FormBuilderPluginOptions, type FormBuilderPluginOptions as PluginOptions, type FormButtonSettings, type FormDocument, type FormFieldDefinition, type FormFieldFormat, type FormFieldValidate, type FormFieldValueKind, type FormPollSettings, type FormResponseSettings, type FormResultsAccess, type FormResultsAccessArgs, type FromAddressOption, type FromAddressesResolver, type HcaptchaProviderOptions, type IdentifyFn, type OmittableSharedField, type OutcomeFieldsOverride, POLL_CLOSE_TASK_SLUG, type PollCloseTaskInput, type PollOption, type PollOptionResolveArgs, type PollOptionSource, type PollOptionSourceOption, type PollOptionSourceRegistry, type PollOptionSourcesConfig, type PollOutcomeStrategy, type PollOutcomeStrategyArgs, type PollTypeRegistry, type PollTypesConfig, type PrefillOptions, type PresentationDensity, type PresentationDescriptor, type PresentationSurface, type RateLimitCheckArgs, type RateLimitConfig, type RateLimitResult, type RateLimiter, type RecallResolver, type RecaptchaProviderOptions, type RedirectFieldsOverride, type RedirectOption, type ResolveConsentEntriesArgs, type ResolveConsentSourcesRequestArgs, type ResolveConsentSourcesRequestResult, type ResolveConsentStatementsArgs, type ResolveDepartmentOptionsArgs, type ResolveDepartmentsRequestArgs, type ResolveDepartmentsRequestResult, type ResolveEffectivePollOptionsArgs, type ResolveFieldOptionsArgs, type ResolvePollOptionsArgs, type ResolvePollOutcomeArgs, type ResolvePublishedVersionRefArgs, type ResolveResultsRequestArgs, type ResolveResultsRequestResult, type ResponseOption, type RichTextBodyOption, SIGNATURE_HEADER, type SerializeBodyArgs, type SpamConfig, type SpamMetadataConfig, type SpamOption, type SubmissionStatusFilter, type ToFormDocumentOptions, type TurnstileProviderOptions, type UploadsOption, type ValidationRuleDefinition, type ValidationRuleOption, type ValidationRuleRegistry, type ValidationRuleResult, type ValidationRulesConfig, aggregateFieldResponses, aggregateFormResponses, aggregateRowForField, aggregateRowsForFields, applyConsentStatements, buildDefaultActionDefinitions, buildDefaultButtonFields, buildDefaultFieldDefinitions, buildDefaultOutcomeFields, buildNextLabelField, buildPollCloseTask, buildPrevLabelField, buildRecallResolver, buildResolvedAtField, buildSubmitLabelField, buildWinningValuesField, calcExpressionOf, captureConsent, captureFileRef, computeCalcFields, consentSourcesField, countryField, createKvRateLimiter, createSubmission, defaultActionDefinitions, defaultBodyConverters, defaultFieldDefinitions, defaultFieldDefinitionsByType, defaultIdentify, defaultPresentationDescriptors, defaultValidationRules, defaultValidationRulesByType, defineAction, defineCaptchaProvider, defineFormField, definePollOptionSource, definePollType, defineValidationRule, departmentsField, enqueuePollClose, escapeHtml, evaluateCalc, evaluateCondition, fieldHasOptions, fieldKey, fieldTargetParam, fileMimeTypeOptions, formBuilder, formatBytes, hasVotedCookie, hcaptchaProvider, interpolate, isPollClosed, localizedIf, manualStrategy, mostVotedStrategy, normalizeCalc, optionLabelsFor, pollTypesOf, recaptchaProvider, registerPollCloseTask, renderAllValues, renderAllValuesTable, resolveActions, resolveConsentEntries, resolveConsentSourcesRequest, resolveConsentStatements, resolveDepartmentOptions, resolveEffectivePollOptions, resolveFileRef, resolveFormResultsRequest, resolvePollOptionSources, resolvePollOptions, resolvePollOutcome, resolvePollTypes, resolvePublishedVersionRef, resolveSpamConfig, runPollClose, sanitizeUrl, serializeBody, shouldAutoResolvePoll, signPayload, sourceStrategy, stashPollTypes, stateField, textOfBody, toFormDocument, topBucketValues, turnstileProvider, valuesFromSearchParams, votedCookieName };
284
+ export { type ActionDefinition, type ActionOption, type ActionRegistry, type ActionResult, type ActionRunArgs, type ActionsConfig, type AggregateFieldResponsesArgs, type AggregateFormResponsesArgs, type AggregationBucket, type AggregationRow, type AnyActionDefinition, type AnyFormFieldDefinition, type AnyPollOptionSource, type AnyValidationRuleDefinition, type BodyContext, type BodyConverter, type BodyConverterArgs, type BodyRender, type ButtonFieldsOverride, type ButtonsOption, CAPTCHA_TOKEN_KEY, type CalcExpression, type CaptchaProvider, type CaptchaVerifyArgs, type ConsentProof, type ConsentSnapshotMode, type ConsentSourceEntry, type ConsentSourceOption, type ConsentSourcePage, type ConsentSourcesFieldOptions, type ConsentSourcesResolver, type ConsentStatement, type ConsentStatements, type CreateSubmissionArgs, type CreatedSubmission, DEFAULT_HONEYPOT_FIELD, DEFAULT_PRESENTATION_NAME, type DefaultButtonFields, type DefaultOutcomeFields, type DepartmentEmailsResolver, type DepartmentOption, type DepartmentsFieldOptions, type FieldAggregation, type FieldCondition, type FieldMeta, type FieldTargetParamOptions, type FieldTypeOption, type FieldTypeRegistry, type FieldTypesConfig, type FileFieldConfig, type FileRef, type FileRefError, FormBuilderPluginOptions, type FormBuilderPluginOptions as PluginOptions, type FormButtonSettings, type FormDocument, type FormFieldDefinition, type FormFieldFormat, type FormFieldValidate, type FormFieldValueKind, type FormPollSettings, type FormResponseSettings, type FormResultsAccess, type FormResultsAccessArgs, type FromAddressOption, type FromAddressesResolver, type HcaptchaProviderOptions, type IdentifyFn, type OmittableSharedField, type OutcomeFieldsOverride, POLL_CLOSE_TASK_SLUG, type PollCloseTaskInput, type PollOption, type PollOptionResolveArgs, type PollOptionSource, type PollOptionSourceOption, type PollOptionSourceRegistry, type PollOptionSourcesConfig, type PollOutcomeStrategy, type PollOutcomeStrategyArgs, type PollTypeRegistry, type PollTypesConfig, type PrefillOptions, type PresentationDensity, type PresentationDescriptor, type PresentationSurface, type RateLimitCheckArgs, type RateLimitConfig, type RateLimitResult, type RateLimiter, type RecallResolver, type RecaptchaProviderOptions, type RedirectFieldsOverride, type RedirectOption, type ResolveConsentEntriesArgs, type ResolveConsentSourcesRequestArgs, type ResolveConsentSourcesRequestResult, type ResolveConsentStatementsArgs, type ResolveDepartmentOptionsArgs, type ResolveDepartmentsRequestArgs, type ResolveDepartmentsRequestResult, type ResolveEffectivePollOptionsArgs, type ResolveFieldOptionsArgs, type ResolvePollOptionsArgs, type ResolvePollOutcomeArgs, type ResolvePublishedVersionRefArgs, type ResolveResultsRequestArgs, type ResolveResultsRequestResult, type ResponseOption, type RichTextBodyOption, SIGNATURE_HEADER, type SerializeBodyArgs, type SpamConfig, type SpamMetadataConfig, type SpamOption, type SubmissionStatusFilter, type ToFormDocumentOptions, type TurnstileProviderOptions, type UploadsOption, type ValidationRuleDefinition, type ValidationRuleOption, type ValidationRuleRegistry, type ValidationRuleResult, type ValidationRulesConfig, aggregateFieldResponses, aggregateFormResponses, aggregateRowForField, aggregateRowsForFields, applyConsentStatements, buildDefaultActionDefinitions, buildDefaultButtonFields, buildDefaultFieldDefinitions, buildDefaultOutcomeFields, buildNextLabelField, buildPollCloseTask, buildPrevLabelField, buildRecallResolver, buildResolvedAtField, buildSubmitLabelField, buildWinningValuesField, calcExpressionOf, captureConsent, captureFileRef, computeCalcFields, consentSourcesField, countryField, createKvRateLimiter, createSubmission, defaultActionDefinitions, defaultBodyConverters, defaultFieldDefinitions, defaultFieldDefinitionsByType, defaultIdentify, defaultPresentationDescriptors, defaultValidationRules, defaultValidationRulesByType, defineAction, defineCaptchaProvider, defineFormField, definePollOptionSource, definePollType, defineValidationRule, departmentsField, enqueuePollClose, escapeHtml, evaluateCalc, evaluateCondition, fieldHasOptions, fieldKey, fieldTargetParam, fileMimeTypeOptions, formBuilder, formatBytes, hasVotedCookie, hcaptchaProvider, interpolate, isPollClosed, localizedIf, manualStrategy, mostVotedStrategy, normalizeCalc, optionLabelsFor, pollTypesOf, recaptchaProvider, registerPollCloseTask, renderAllValues, renderAllValuesTable, resolveActions, resolveConsentEntries, resolveConsentSourcesRequest, resolveConsentStatements, resolveDepartmentOptions, resolveEffectivePollOptions, resolveFileRef, resolveFormResultsRequest, resolvePollOptionSources, resolvePollOptions, resolvePollOutcome, resolvePollTypes, resolvePublishedVersionRef, resolveSpamConfig, runPollClose, sanitizeUrl, serializeBody, shouldAutoResolvePoll, signPayload, sourceStrategy, stashPollTypes, stateField, textOfBody, toFormDocument, topBucketValues, turnstileProvider, valuesFromSearchParams, votedCookieName };
276
285
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -5,13 +5,13 @@ import { defaultBodyConverters, sanitizeUrl } from "./actions/body/converters.js
5
5
  import { renderAllValues, renderAllValuesTable } from "./actions/body/wildcards.js";
6
6
  import { serializeBody } from "./actions/body/serializeBody.js";
7
7
  import { defineAction } from "./actions/defineAction.js";
8
- import { resolveDepartmentOptions } from "./email/departments.js";
9
8
  import { SIGNATURE_HEADER, signPayload } from "./actions/sign.js";
10
9
  import { buildDefaultActionDefinitions, defaultActionDefinitions } from "./actions/builtin/index.js";
11
10
  import { resolveActions } from "./actions/registry.js";
12
11
  import { resolveConsentEntries, stashConsentSources } from "./consent/resolveConsentEntries.js";
13
12
  import { normalizeCalc } from "./calc/normalizeCalc.js";
14
13
  import { defineFormField } from "./fields/defineFormField.js";
14
+ import { resolveFileRef } from "./uploads/resolveFileRef.js";
15
15
  import { fileMimeTypeOptions } from "./fields/builtin/file.js";
16
16
  import { buildDefaultFieldDefinitions, defaultFieldDefinitions, defaultFieldDefinitionsByType } from "./fields/builtin/index.js";
17
17
  import { resolveFieldTypes, stashFieldTypes } from "./fields/registry.js";
@@ -29,16 +29,19 @@ import { POLL_CLOSE_TASK_SLUG, buildPollCloseTask, enqueuePollClose, registerPol
29
29
  import { resolveEffectivePollOptions } from "./poll/effectivePollOptions.js";
30
30
  import { resolveFormResultsRequest } from "./aggregation/resolveResultsRequest.js";
31
31
  import { resolveConsentSourcesRequest } from "./consent/resolveConsentSourcesRequest.js";
32
+ import { resolveConsentStatements } from "./consent/resolveConsentStatements.js";
33
+ import { resolveDepartmentOptions } from "./email/departments.js";
32
34
  import { buildDefaultOutcomeFields, buildResolvedAtField, buildWinningValuesField } from "./poll/outcomeFields.js";
33
35
  import { buildDefaultButtonFields, buildNextLabelField, buildPrevLabelField, buildSubmitLabelField } from "./collections/buttonFields.js";
34
36
  import { evaluateCalc } from "./calc/evaluate.js";
35
37
  import { calcExpressionOf, computeCalcFields } from "./calc/computeCalcFields.js";
36
38
  import { evaluateCondition } from "./conditions/evaluate.js";
39
+ import { textOfBody } from "./actions/body/textOfBody.js";
37
40
  import { resolvePublishedVersionRef } from "./consent/resolvePublishedVersionRef.js";
38
41
  import { captureConsent } from "./consent/captureConsent.js";
39
- import { resolveFileRef } from "./uploads/resolveFileRef.js";
40
42
  import { captureFileRef } from "./uploads/captureFileRef.js";
41
43
  import { hasVotedCookie, votedCookieName } from "./submissions/votedCookie.js";
44
+ import { readUploadCollectionMimeTypes } from "./plugin/uploadsCollection.js";
42
45
  import { registerCollections } from "./plugin/registerCollections.js";
43
46
  import { registerTranslations } from "./plugin/registerTranslations.js";
44
47
  import { resolvePollOptionSources } from "./poll/registry.js";
@@ -49,10 +52,8 @@ import { defineValidationRule } from "./validation/defineValidationRule.js";
49
52
  import { fieldTargetParam } from "./validation/fieldTargetParam.js";
50
53
  import { defaultValidationRules, defaultValidationRulesByType } from "./validation/builtin/index.js";
51
54
  import { resolveValidationRules } from "./validation/registry.js";
52
- import { textOfBody } from "./actions/body/textOfBody.js";
53
55
  import { applyConsentStatements } from "./consent/applyConsentStatements.js";
54
56
  import { consentSourcesField } from "./consent/consentSourcesField.js";
55
- import { resolveConsentStatements } from "./consent/resolveConsentStatements.js";
56
57
  import { departmentsField } from "./email/departmentsField.js";
57
58
  import { countryField } from "./fields/builtin/country.js";
58
59
  import { stateField } from "./fields/builtin/state.js";
@@ -76,12 +77,13 @@ const formBuilder = definePlugin({
76
77
  if (options.disabled === true) return config;
77
78
  const localizeContent = options.localizeContent !== false;
78
79
  const uploads = options.uploads ?? false;
80
+ const uploadMimeTypes = uploads === false ? void 0 : uploads.mimeTypes ?? readUploadCollectionMimeTypes(config, uploads.collection);
79
81
  const consentSources = options.consent?.sources;
80
- const registry = resolveFieldTypes(buildDefaultFieldDefinitions(localizeContent, options.richText?.editor).filter((definition) => (uploads !== false || definition.type !== "file") && (consentSources !== void 0 || definition.type !== "consent")), options.fields);
82
+ const registry = resolveFieldTypes(buildDefaultFieldDefinitions(localizeContent, options.richText?.editor, uploadMimeTypes).filter((definition) => (uploads !== false || definition.type !== "file") && (consentSources !== void 0 || definition.type !== "consent")), options.fields);
81
83
  const ruleRegistry = resolveValidationRules(defaultValidationRules, options.rules);
82
84
  const fromAddresses = options.email?.fromAddresses;
83
85
  const departments = options.email?.departments;
84
- const actionRegistry = resolveActions(buildDefaultActionDefinitions(localizeContent, options.richText?.bodyEditor ?? options.richText?.editor, fromAddresses, departments), options.actions);
86
+ const actionRegistry = resolveActions(buildDefaultActionDefinitions(localizeContent, options.richText?.bodyEditor ?? options.richText?.editor, fromAddresses, departments, options.email?.recipients), options.actions);
85
87
  const spam = resolveSpamConfig(options.spam);
86
88
  const pollSourceRegistry = resolvePollOptionSources(options.poll?.sources);
87
89
  const pollTypeRegistry = resolvePollTypes(options.poll?.types);
@@ -95,6 +97,7 @@ const formBuilder = definePlugin({
95
97
  registry,
96
98
  ruleRegistry,
97
99
  consentSources,
100
+ consentSnapshot: options.consent?.snapshot ?? "both",
98
101
  actionRegistry,
99
102
  richText: options.richText,
100
103
  hasJobsPlugin: Boolean(plugins["@10x-media/jobs"]),
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { type CollectionSlug, type Config, definePlugin } from 'payload'\nimport type { RichTextBodyOption } from './actions/body/serializeBody'\nimport { buildDefaultActionDefinitions } from './actions/builtin'\nimport type { FromAddressesResolver } from './actions/fromAddresses'\nimport type { ActionsConfig } from './actions/registry'\nimport { resolveActions } from './actions/registry'\nimport type { FormResultsAccess } from './aggregation/resolveResultsRequest'\nimport type { ButtonsOption } from './collections/buttonFields'\nimport type { ResponseOption } from './collections/redirectFields'\nimport { stashConsentSources } from './consent/resolveConsentEntries'\nimport type { ConsentSourcesResolver } from './consent/types'\nimport type { DepartmentEmailsResolver } from './email/departments'\nimport type { FormEventSink } from './events/types'\nimport { buildDefaultFieldDefinitions } from './fields/builtin'\nimport { type FieldTypesConfig, resolveFieldTypes, stashFieldTypes } from './fields/registry'\nimport type { CollectionOverrides } from './plugin/collectionOverrides'\nimport { registerCollections } from './plugin/registerCollections'\nimport { registerTranslations } from './plugin/registerTranslations'\nimport type { UploadsOption } from './plugin/uploadsCollection'\nimport type { OutcomeFieldsOverride } from './poll/outcomeFields'\nimport type { PollTypesConfig } from './poll/pollTypeRegistry'\nimport { resolvePollTypes, stashPollTypes } from './poll/pollTypeRegistry'\nimport type { PollOptionSourcesConfig } from './poll/registry'\nimport { resolvePollOptionSources } from './poll/registry'\nimport { stashPollOptionSources } from './poll/resolvePollOptions'\nimport { resolveSpamConfig } from './spam/resolveSpam'\nimport type { SpamOption } from './spam/types'\nimport type { TranslationsOption } from './translations'\nimport { defaultValidationRules } from './validation/builtin'\nimport { resolveValidationRules, type ValidationRulesConfig } from './validation/registry'\n\nexport type FormBuilderPluginOptions = {\n\tdisabled?: boolean\n\t/**\n\t * Per-locale overrides for this plugin's UI strings, keyed by the typed\n\t * translation keys exported from `@10x-media/form-builder/i18n`. Values win\n\t * over the built-in locales key-by-key; locales the plugin does not ship are\n\t * added whole. App-level `i18n.translations` still wins over both.\n\t */\n\ttranslations?: TranslationsOption\n\t/** Pluggable sink for form lifecycle events. Defaults to a no-op; analytics adapters or a future analytics plugin subscribe here. */\n\tevents?: FormEventSink\n\t/**\n\t * Content-bearing author fields (labels, placeholders, option labels, action subjects and\n\t * bodies) are localized by default. Payload strips the `localized` flag on hosts without\n\t * `localization` configured, so the default is safe everywhere. Set `false` to keep form\n\t * content single-locale even on localized hosts. Spread-overrides of the prebuilt default\n\t * exports (`defaultFieldDefinitionsByType`, `defaultActionDefinitions`) carry `localized`\n\t * flags from the default-true set; when opting out, derive overrides from\n\t * `buildDefaultFieldDefinitions(false)` / `buildDefaultActionDefinitions(false)` instead.\n\t * Consent statements are unaffected either way: they live on the host's own\n\t * `consentSourcesField()`, which carries its own `localized` option.\n\t */\n\tlocalizeContent?: boolean\n\t/** Add, override, or remove field types. `false` removes a built-in, `true` keeps it, an object adds or replaces one. */\n\tfields?: FieldTypesConfig\n\t/** Add, override, or remove validation rule types. `false` removes a built-in, `true` keeps it, an object adds or replaces one. */\n\trules?: ValidationRulesConfig\n\t/** Add, override, or remove post-submit action types. `false` removes a built-in, `true` keeps it, an object adds or replaces one. */\n\tactions?: ActionsConfig\n\t/**\n\t * Customize how the plugin's rich text is authored and rendered. `editor` is the default\n\t * Lexical/richText editor for every plugin richText field (message content, consent\n\t * statement, response message, action bodies); `bodyEditor` overrides the action body\n\t * fields specifically, falling back to `editor`. `converters` spread over the default\n\t * Lexical node converters; `serialize` replaces the whole action-body pipeline (e.g. to\n\t * target chat or plain-text channels instead of email HTML). A custom `serialize` receives\n\t * the submitted `form` (id/title) and `req`, enabling per-tenant lookups or handing the raw\n\t * body off to a renderer like react-email.\n\t */\n\trichText?: RichTextBodyOption\n\t/**\n\t * Email routing for the `emailTeam` and `confirmation` actions. Both sub-options are opt-in by the\n\t * presence of a resolver (not a `false`/`true`/object flag) and share a shape: a `req`-scoped\n\t * resolver, evaluated per request via an endpoint, whose choice is validated at save time only and\n\t * never re-checked when the action sends (the config is admin-authored, not visitor-controlled).\n\t *\n\t * `fromAddresses` gives both actions a `from` select whose options come from the resolver; absent,\n\t * neither action has a `from` field and every send uses the email adapter's default sender. The\n\t * intended use is multi-tenant hosts where each tenant may only send from particular addresses\n\t * (derive the tenant from `req`, return its allowed senders). Values are the literal string\n\t * `payload.sendEmail` accepts as `from` (e.g. `'Name <addr@x.com>'` or a plain address).\n\t *\n\t * `departments` turns the `emailTeam` `to` into a select whose options come from the resolver\n\t * (a `/:id/departments` endpoint); the intended use is to place `departmentsField()` on a document\n\t * you own and read it back with `resolveDepartmentOptions`, which resolves each department's address\n\t * for the requesting locale. Because `to` is localized, each admin locale stores its own resolved\n\t * address and a submission's locale selects the address it routes to (Payload-native, no per-send\n\t * lookup). Storing the resolved address, rather than a department id resolved live at send (consent's\n\t * model), is deliberate: the routing target a form was saved with stays audit-stable even if the\n\t * resolver's data later changes, so do not \"fix\" it into a live lookup. Multi-tenant hosts scope\n\t * which document they read by the tenant derived from `req`; absent, `to` stays a plain localized\n\t * text field.\n\t */\n\temail?: { fromAddresses?: FromAddressesResolver; departments?: DepartmentEmailsResolver }\n\t/**\n\t * Where the consent statements a form can reference come from. Absent (the default): no sources,\n\t * so the built-in `consent` field type is not registered at all and authors cannot add a consent\n\t * field with nothing to reference (a developer-registered custom `consent` type via `fields`\n\t * still wins).\n\t *\n\t * `sources` is an async `req`-scoped resolver returning the sources available to this request.\n\t * The intended shape: place `consentSourcesField()` on a collection or global you own and read it\n\t * back here. Multi-tenant hosts scope that read by the tenant derived from `req`, so a tenant's\n\t * authors only ever see, and their visitors only ever agree to, their own statements. A form\n\t * stores only a source's row `id`; the statement is resolved live per request (see\n\t * `resolveConsentStatements`) and the proof is rebuilt from the source at submit, so neither is\n\t * ever a copy the client could stale or forge.\n\t */\n\tconsent?: { sources: ConsentSourcesResolver }\n\t/**\n\t * Form-level button labels: `submitLabel` at the bottom of the Fields tab, `prevLabel` and\n\t * `nextLabel` in a row at the bottom of the Flow tab (shown once the flow has a step). The\n\t * rendered chrome resolves each label as `<Form>` prop, then the stored value, then the\n\t * translated default. `fields` composes them: it receives the three default fields as a\n\t * `{ submit, prev, next }` map with the content localization flag already applied and returns\n\t * the map, so wrapping a default in a row with a host field (e.g. an icon select) or replacing\n\t * one is explicit. `FormDocument.buttons` reassembles only those three known labels, so a\n\t * host-added sibling field is still stored but is read off the raw document, not `doc.buttons`.\n\t */\n\tbuttons?: ButtonsOption\n\t/**\n\t * The success-response group. `redirect.fields` composes the fields inside the `response.redirect`\n\t * group, mirroring `buttons.fields`: it receives the default fields (the `url` text field, plus the\n\t * polymorphic `reference` relationship when `redirectRelationships` is set) and returns the group's\n\t * final field array, so a host can prepend a custom link field (the pattern most projects already\n\t * have), swap `url` for their own picker, reorder, or filter. Omit it and the group stays the\n\t * built-in `url` (+ optional `reference`), unchanged.\n\t *\n\t * The plugin's built-in redirect handling reads `redirect.url` (and `redirect.reference` when\n\t * configured); `toFormDocument` passes the whole `response` group through, so a host that replaces\n\t * `url` with their own link field owns resolving it to a destination in their frontend, the same as\n\t * the internal-reference case.\n\t */\n\tresponse?: ResponseOption\n\t/**\n\t * Collections whose documents `response.redirect` can reference (`response.redirect.reference`),\n\t * letting an author redirect a visitor to an internal document instead of a URL after a\n\t * successful submit. Absent (the default): no `reference` field exists at all, matching today's\n\t * URL-only redirect. Always polymorphic, even for a single slug (a `CollectionSlug[]` array, not\n\t * a bare `CollectionSlug`), so a host adding a second collection later never changes the stored\n\t * shape, the same precedent as `consentSourcesField()`'s `page` picker. The plugin never resolves\n\t * the reference to a URL itself (it has no notion of the host's routing); `toFormDocument` passes\n\t * the raw `{ relationTo, value }` pair through on `FormDocument.response.redirect.reference` for\n\t * the host to resolve. Mirrors the `redirectRelationships` option of Payload's native\n\t * `plugin-form-builder`.\n\t */\n\tredirectRelationships?: CollectionSlug[]\n\t/**\n\t * File uploads are bring-your-own. Default `false`: no upload collection is involved and the\n\t * built-in `file` field type is removed from the registry, so form authors cannot add a field\n\t * with nowhere to land (a developer-registered custom `file` type via `fields` still wins).\n\t * `{ collection: 'slug' }` points at a host-owned upload collection (created by the app with\n\t * its storage adapter); the plugin validates it at boot, appends its hidden `owner` field when\n\t * absent, and prepends the spam upload hooks.\n\t */\n\tuploads?: UploadsOption\n\t/** Honeypot + rate-limiting (on by default) + a captcha adapter seam + upload-ownership scoping. `false` disables the whole subsystem. */\n\tspam?: SpamOption\n\t/**\n\t * Aggregate-results endpoint options. `access` gates anonymous reads after the form is loaded\n\t * and before anything is served; absent keeps the plugin-default gating (poll opt-in +\n\t * visibility + enumerable-field guard). Multi-tenant hosts should compare `form.tenant` against\n\t * the tenant derived from `req` so one tenant's poll counts are never readable under another\n\t * tenant's id. Authenticated callers bypass this seam.\n\t */\n\tresults?: { access?: FormResultsAccess }\n\t/**\n\t * Poll behavior. `votedCookie: true` sets an httpOnly `fb-voted-{formId}=1` cookie on each\n\t * successful submission to a poll-enabled form, letting SSR hosts read the voted state via\n\t * `hasVotedCookie` and pass it to `<Poll hasVoted>`. Default `false`.\n\t * `sources` registers poll option sources (`definePollOptionSource`), letting authors populate\n\t * a poll's choices from host domain data with stable values; there are no built-ins. With at\n\t * least one source registered, the forms poll group gains an `optionSource` select plus its\n\t * per-source `sourceConfig`, and submissions to a sourced poll only accept resolved values.\n\t * `outcomeFields` composes the poll `outcome` group: it receives the two default fields\n\t * (`winningValues`, `resolvedAt`) and returns the group's final field array verbatim, so a host\n\t * can swap `winningValues` for its own component (e.g. a relationship picker over the voteable\n\t * records). Membership validation runs server-side regardless, so a swap cannot bypass it.\n\t * `types` registers outcome strategies (`definePollType`) shown in the poll `type` select. The\n\t * built-ins `manual` (default, hand-picked), `mostVoted` (auto-resolves to the top choice(s) on\n\t * close), and `source` (delegates to the option source) are always registered; a host entry keyed\n\t * by (or carrying) a built-in slug replaces it. A closed poll whose strategy is not `manual`\n\t * auto-resolves via a scheduled job when a runner is present, or on the next results read otherwise.\n\t */\n\tpoll?: {\n\t\tvotedCookie?: boolean\n\t\tsources?: PollOptionSourcesConfig\n\t\ttypes?: PollTypesConfig\n\t\toutcomeFields?: OutcomeFieldsOverride\n\t}\n\t/**\n\t * When `true`, the raw `values`, `descriptors`, and `consent` JSON fields are visible in the\n\t * submission admin view. Default `false`, because the `SubmissionAnswers` UI component already\n\t * represents those fields fully and they are noisy shown alongside it.\n\t */\n\tshowSubmissionRawFields?: boolean\n\t/**\n\t * Override individual plugin-managed collections using explicit spreads. Each key accepts a\n\t * `CollectionOverrides` object: top-level keys are spread with the plugin's defaults (spread\n\t * order per key determines who wins), hooks are appended after the plugin's own hooks, and\n\t * `fields` is a function that receives the default fields and returns the final array so\n\t * additions/removals are always intentional.\n\t */\n\toverrides?: {\n\t\tforms?: CollectionOverrides\n\t\tformSubmissions?: CollectionOverrides\n\t}\n}\n\ndeclare module 'payload' {\n\tinterface RegisteredPlugins {\n\t\t'@10x-media/form-builder': FormBuilderPluginOptions\n\t}\n}\n\nexport const formBuilder = definePlugin<FormBuilderPluginOptions>({\n\tslug: '@10x-media/form-builder',\n\torder: 50,\n\tplugin: ({ config, plugins, ...options }): Config => {\n\t\tif (options.disabled === true) {\n\t\t\treturn config\n\t\t}\n\t\tconst localizeContent = options.localizeContent !== false\n\t\tconst uploads = options.uploads ?? false\n\t\tconst consentSources = options.consent?.sources\n\t\t// A built-in with nowhere to point never enters the registry, so an author is never offered a\n\t\t// field that cannot work: file without an uploads collection has nowhere to store anything,\n\t\t// consent without sources has no statement to reference. An explicit `fields.file` /\n\t\t// `fields.consent` definition remains a developer choice.\n\t\tconst defaultFieldDefinitions = buildDefaultFieldDefinitions(\n\t\t\tlocalizeContent,\n\t\t\toptions.richText?.editor\n\t\t).filter(\n\t\t\t(definition) =>\n\t\t\t\t(uploads !== false || definition.type !== 'file') &&\n\t\t\t\t(consentSources !== undefined || definition.type !== 'consent')\n\t\t)\n\t\tconst registry = resolveFieldTypes(defaultFieldDefinitions, options.fields)\n\t\tconst ruleRegistry = resolveValidationRules(defaultValidationRules, options.rules)\n\t\tconst fromAddresses = options.email?.fromAddresses\n\t\tconst departments = options.email?.departments\n\t\tconst actionRegistry = resolveActions(\n\t\t\tbuildDefaultActionDefinitions(\n\t\t\t\tlocalizeContent,\n\t\t\t\toptions.richText?.bodyEditor ?? options.richText?.editor,\n\t\t\t\tfromAddresses,\n\t\t\t\tdepartments\n\t\t\t),\n\t\t\toptions.actions\n\t\t)\n\t\tconst spam = resolveSpamConfig(options.spam)\n\t\tconst pollSourceRegistry = resolvePollOptionSources(options.poll?.sources)\n\t\tconst pollTypeRegistry = resolvePollTypes(options.poll?.types)\n\t\t// Stashed on config.custom so the root-level resolvePollOptions, resolveEffectivePollOptions,\n\t\t// resolvePollOutcome, and resolveConsentStatements helpers can reach these through\n\t\t// `payload.config` at request time, without threading plugin state through the host's own\n\t\t// server code. The field-type registry rides along so resolveEffectivePollOptions can look up a\n\t\t// results field's definition (and its `resolveOptions`) from a bare `payload` instance.\n\t\tconfig.custom = stashPollOptionSources(config.custom, pollSourceRegistry)\n\t\tconfig.custom = stashPollTypes(config.custom, pollTypeRegistry)\n\t\tconfig.custom = stashFieldTypes(config.custom, registry)\n\t\tif (consentSources) {\n\t\t\tconfig.custom = stashConsentSources(config.custom, consentSources)\n\t\t}\n\t\tregisterTranslations(config, options.translations)\n\t\tregisterCollections({\n\t\t\tconfig,\n\t\t\tregistry,\n\t\t\truleRegistry,\n\t\t\tconsentSources,\n\t\t\tactionRegistry,\n\t\t\trichText: options.richText,\n\t\t\thasJobsPlugin: Boolean(plugins['@10x-media/jobs']),\n\t\t\tevents: options.events,\n\t\t\tuploads,\n\t\t\tspam,\n\t\t\tshowSubmissionRawFields: options.showSubmissionRawFields ?? false,\n\t\t\tlocalizeContent,\n\t\t\tresultsAccess: options.results?.access,\n\t\t\tvotedCookie: options.poll?.votedCookie === true,\n\t\t\tpollSourceRegistry,\n\t\t\tpollTypeRegistry,\n\t\t\toutcomeFields: options.poll?.outcomeFields,\n\t\t\tbuttons: options.buttons,\n\t\t\tresponse: options.response,\n\t\t\tfromAddresses,\n\t\t\tdepartments,\n\t\t\tredirectRelationships: options.redirectRelationships,\n\t\t\toverrides: options.overrides,\n\t\t})\n\t\treturn config\n\t},\n})\n\nexport type {\n\tBodyConverter,\n\tBodyConverterArgs,\n\tBodyRender,\n} from './actions/body/converters'\nexport { defaultBodyConverters, sanitizeUrl } from './actions/body/converters'\nexport { escapeHtml } from './actions/body/escapeHtml'\nexport type {\n\tBodyContext,\n\tRichTextBodyOption,\n\tSerializeBodyArgs,\n} from './actions/body/serializeBody'\nexport { serializeBody } from './actions/body/serializeBody'\nexport { textOfBody } from './actions/body/textOfBody'\nexport { renderAllValues, renderAllValuesTable } from './actions/body/wildcards'\nexport { buildDefaultActionDefinitions, defaultActionDefinitions } from './actions/builtin'\nexport type { ActionDefinition, ActionRunArgs, AnyActionDefinition } from './actions/defineAction'\nexport { defineAction } from './actions/defineAction'\nexport type { FromAddressesResolver, FromAddressOption } from './actions/fromAddresses'\nexport type { ActionOption, ActionRegistry, ActionsConfig } from './actions/registry'\nexport { resolveActions } from './actions/registry'\nexport type { ActionResult } from './actions/runActions'\nexport { SIGNATURE_HEADER, signPayload } from './actions/sign'\nexport type {\n\tAggregateFieldResponsesArgs,\n\tAggregateFormResponsesArgs,\n} from './aggregation/aggregateResponses'\nexport {\n\taggregateFieldResponses,\n\taggregateFormResponses,\n\tfieldHasOptions,\n} from './aggregation/aggregateResponses'\nexport { aggregateRowForField, aggregateRowsForFields } from './aggregation/aggregateRows'\nexport type {\n\tFormResultsAccess,\n\tFormResultsAccessArgs,\n\tResolveResultsRequestArgs,\n\tResolveResultsRequestResult,\n} from './aggregation/resolveResultsRequest'\nexport { resolveFormResultsRequest } from './aggregation/resolveResultsRequest'\nexport type {\n\tAggregationBucket,\n\tAggregationRow,\n\tFieldAggregation,\n\tFieldMeta,\n\tSubmissionStatusFilter,\n} from './aggregation/types'\nexport { calcExpressionOf, computeCalcFields } from './calc/computeCalcFields'\nexport { evaluateCalc } from './calc/evaluate'\nexport { normalizeCalc } from './calc/normalizeCalc'\nexport type { CalcExpression } from './calc/types'\nexport type {\n\tButtonFieldsOverride,\n\tButtonsOption,\n\tDefaultButtonFields,\n} from './collections/buttonFields'\nexport {\n\tbuildDefaultButtonFields,\n\tbuildNextLabelField,\n\tbuildPrevLabelField,\n\tbuildSubmitLabelField,\n} from './collections/buttonFields'\nexport type {\n\tRedirectFieldsOverride,\n\tRedirectOption,\n\tResponseOption,\n} from './collections/redirectFields'\nexport { evaluateCondition } from './conditions/evaluate'\nexport type { FieldCondition } from './conditions/types'\nexport { applyConsentStatements } from './consent/applyConsentStatements'\nexport type { ConsentProof } from './consent/captureConsent'\nexport { captureConsent } from './consent/captureConsent'\nexport type { ConsentSourcesFieldOptions } from './consent/consentSourcesField'\nexport { consentSourcesField } from './consent/consentSourcesField'\nexport type { ResolveConsentEntriesArgs } from './consent/resolveConsentEntries'\nexport { resolveConsentEntries } from './consent/resolveConsentEntries'\nexport type {\n\tConsentSourceOption,\n\tResolveConsentSourcesRequestArgs,\n\tResolveConsentSourcesRequestResult,\n} from './consent/resolveConsentSourcesRequest'\nexport { resolveConsentSourcesRequest } from './consent/resolveConsentSourcesRequest'\nexport type {\n\tConsentStatement,\n\tConsentStatements,\n\tResolveConsentStatementsArgs,\n} from './consent/resolveConsentStatements'\nexport { resolveConsentStatements } from './consent/resolveConsentStatements'\nexport type { ResolvePublishedVersionRefArgs } from './consent/resolvePublishedVersionRef'\nexport { resolvePublishedVersionRef } from './consent/resolvePublishedVersionRef'\nexport type {\n\tConsentSourceEntry,\n\tConsentSourcePage,\n\tConsentSourcesResolver,\n} from './consent/types'\nexport type {\n\tDepartmentEmailsResolver,\n\tDepartmentOption,\n\tResolveDepartmentOptionsArgs,\n\tResolveDepartmentsRequestArgs,\n\tResolveDepartmentsRequestResult,\n} from './email/departments'\nexport { resolveDepartmentOptions } from './email/departments'\nexport type { DepartmentsFieldOptions } from './email/departmentsField'\nexport { departmentsField } from './email/departmentsField'\nexport {\n\tbuildDefaultFieldDefinitions,\n\tdefaultFieldDefinitions,\n\tdefaultFieldDefinitionsByType,\n} from './fields/builtin'\nexport { countryField } from './fields/builtin/country'\nexport { fileMimeTypeOptions } from './fields/builtin/file'\nexport { stateField } from './fields/builtin/state'\nexport { defineFormField } from './fields/defineFormField'\nexport { fieldKey } from './fields/fieldKey'\nexport { localizedIf } from './fields/localizedIf'\nexport type { FieldTypeOption, FieldTypeRegistry, FieldTypesConfig } from './fields/registry'\nexport type {\n\tAnyFormFieldDefinition,\n\tFormFieldDefinition,\n\tFormFieldFormat,\n\tFormFieldValidate,\n\tFormFieldValueKind,\n\tOmittableSharedField,\n\tResolveFieldOptionsArgs,\n} from './fields/types'\nexport { isPollClosed } from './form/pollState'\nexport type { ToFormDocumentOptions } from './form/toFormDocument'\nexport { toFormDocument } from './form/toFormDocument'\nexport type {\n\tFormButtonSettings,\n\tFormDocument,\n\tFormPollSettings,\n\tFormResponseSettings,\n} from './form/types'\nexport type { UploadsOption } from './plugin/uploadsCollection'\nexport type { PollCloseTaskInput } from './poll/closeJob'\nexport {\n\tbuildPollCloseTask,\n\tenqueuePollClose,\n\tPOLL_CLOSE_TASK_SLUG,\n\tregisterPollCloseTask,\n\trunPollClose,\n\tshouldAutoResolvePoll,\n} from './poll/closeJob'\nexport type {\n\tAnyPollOptionSource,\n\tPollOption,\n\tPollOptionResolveArgs,\n\tPollOptionSource,\n} from './poll/definePollOptionSource'\nexport { definePollOptionSource } from './poll/definePollOptionSource'\nexport type { PollOutcomeStrategy, PollOutcomeStrategyArgs } from './poll/definePollType'\nexport { definePollType } from './poll/definePollType'\nexport type { ResolveEffectivePollOptionsArgs } from './poll/effectivePollOptions'\nexport { resolveEffectivePollOptions } from './poll/effectivePollOptions'\nexport { mostVotedStrategy, topBucketValues } from './poll/mostVoted'\nexport type { DefaultOutcomeFields, OutcomeFieldsOverride } from './poll/outcomeFields'\nexport {\n\tbuildDefaultOutcomeFields,\n\tbuildResolvedAtField,\n\tbuildWinningValuesField,\n} from './poll/outcomeFields'\nexport type { PollTypeRegistry, PollTypesConfig } from './poll/pollTypeRegistry'\nexport {\n\tmanualStrategy,\n\tpollTypesOf,\n\tresolvePollTypes,\n\tsourceStrategy,\n\tstashPollTypes,\n} from './poll/pollTypeRegistry'\nexport type {\n\tPollOptionSourceOption,\n\tPollOptionSourceRegistry,\n\tPollOptionSourcesConfig,\n} from './poll/registry'\nexport { resolvePollOptionSources } from './poll/registry'\nexport type { ResolvePollOptionsArgs } from './poll/resolvePollOptions'\nexport { resolvePollOptions } from './poll/resolvePollOptions'\nexport type { ResolvePollOutcomeArgs } from './poll/resolvePollOutcome'\nexport { resolvePollOutcome } from './poll/resolvePollOutcome'\nexport type { PrefillOptions } from './prefill/valuesFromSearchParams'\nexport { valuesFromSearchParams } from './prefill/valuesFromSearchParams'\nexport { DEFAULT_PRESENTATION_NAME, defaultPresentationDescriptors } from './presentations/defaults'\nexport type {\n\tPresentationDensity,\n\tPresentationDescriptor,\n\tPresentationSurface,\n} from './presentations/types'\nexport { interpolate } from './recall/interpolate'\nexport type { RecallResolver } from './recall/resolver'\nexport { buildRecallResolver, optionLabelsFor } from './recall/resolver'\nexport { defineCaptchaProvider } from './spam/captcha'\nexport { CAPTCHA_TOKEN_KEY, DEFAULT_HONEYPOT_FIELD } from './spam/constants'\nexport { defaultIdentify } from './spam/identify'\nexport type { HcaptchaProviderOptions } from './spam/providers/hcaptcha'\nexport { hcaptchaProvider } from './spam/providers/hcaptcha'\nexport type { RecaptchaProviderOptions } from './spam/providers/recaptcha'\nexport { recaptchaProvider } from './spam/providers/recaptcha'\nexport type { TurnstileProviderOptions } from './spam/providers/turnstile'\nexport { turnstileProvider } from './spam/providers/turnstile'\nexport { createKvRateLimiter } from './spam/rateLimiter'\nexport { resolveSpamConfig } from './spam/resolveSpam'\nexport type {\n\tCaptchaProvider,\n\tCaptchaVerifyArgs,\n\tIdentifyFn,\n\tRateLimitCheckArgs,\n\tRateLimitConfig,\n\tRateLimiter,\n\tRateLimitResult,\n\tSpamConfig,\n\tSpamMetadataConfig,\n\tSpamOption,\n} from './spam/types'\nexport type { CreatedSubmission, CreateSubmissionArgs } from './submissions/createSubmission'\nexport { createSubmission } from './submissions/createSubmission'\nexport { hasVotedCookie, votedCookieName } from './submissions/votedCookie'\nexport { captureFileRef } from './uploads/captureFileRef'\nexport { formatBytes } from './uploads/formatBytes'\nexport { resolveFileRef } from './uploads/resolveFileRef'\nexport type { FileFieldConfig, FileRef, FileRefError } from './uploads/types'\nexport { defaultValidationRules, defaultValidationRulesByType } from './validation/builtin'\nexport { defineValidationRule } from './validation/defineValidationRule'\nexport type { FieldTargetParamOptions } from './validation/fieldTargetParam'\nexport { fieldTargetParam } from './validation/fieldTargetParam'\nexport type {\n\tValidationRuleOption,\n\tValidationRuleRegistry,\n\tValidationRulesConfig,\n} from './validation/registry'\nexport type {\n\tAnyValidationRuleDefinition,\n\tValidationRuleDefinition,\n\tValidationRuleResult,\n} from './validation/types'\nexport type { FormBuilderPluginOptions as PluginOptions }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwNA,MAAa,cAAc,aAAuC;CACjE,MAAM;CACN,OAAO;CACP,SAAS,EAAE,QAAQ,SAAS,GAAG,cAAsB;EACpD,IAAI,QAAQ,aAAa,MACxB,OAAO;EAER,MAAM,kBAAkB,QAAQ,oBAAoB;EACpD,MAAM,UAAU,QAAQ,WAAW;EACnC,MAAM,iBAAiB,QAAQ,SAAS;EAaxC,MAAM,WAAW,kBARe,6BAC/B,iBACA,QAAQ,UAAU,MACnB,EAAE,QACA,gBACC,YAAY,SAAS,WAAW,SAAS,YACzC,mBAAmB,KAAA,KAAa,WAAW,SAAS,UAEE,GAAG,QAAQ,MAAM;EAC1E,MAAM,eAAe,uBAAuB,wBAAwB,QAAQ,KAAK;EACjF,MAAM,gBAAgB,QAAQ,OAAO;EACrC,MAAM,cAAc,QAAQ,OAAO;EACnC,MAAM,iBAAiB,eACtB,8BACC,iBACA,QAAQ,UAAU,cAAc,QAAQ,UAAU,QAClD,eACA,WACD,GACA,QAAQ,OACT;EACA,MAAM,OAAO,kBAAkB,QAAQ,IAAI;EAC3C,MAAM,qBAAqB,yBAAyB,QAAQ,MAAM,OAAO;EACzE,MAAM,mBAAmB,iBAAiB,QAAQ,MAAM,KAAK;EAM7D,OAAO,SAAS,uBAAuB,OAAO,QAAQ,kBAAkB;EACxE,OAAO,SAAS,eAAe,OAAO,QAAQ,gBAAgB;EAC9D,OAAO,SAAS,gBAAgB,OAAO,QAAQ,QAAQ;EACvD,IAAI,gBACH,OAAO,SAAS,oBAAoB,OAAO,QAAQ,cAAc;EAElE,qBAAqB,QAAQ,QAAQ,YAAY;EACjD,oBAAoB;GACnB;GACA;GACA;GACA;GACA;GACA,UAAU,QAAQ;GAClB,eAAe,QAAQ,QAAQ,kBAAkB;GACjD,QAAQ,QAAQ;GAChB;GACA;GACA,yBAAyB,QAAQ,2BAA2B;GAC5D;GACA,eAAe,QAAQ,SAAS;GAChC,aAAa,QAAQ,MAAM,gBAAgB;GAC3C;GACA;GACA,eAAe,QAAQ,MAAM;GAC7B,SAAS,QAAQ;GACjB,UAAU,QAAQ;GAClB;GACA;GACA,uBAAuB,QAAQ;GAC/B,WAAW,QAAQ;EACpB,CAAC;EACD,OAAO;CACR;AACD,CAAC"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { type CollectionSlug, type Config, definePlugin } from 'payload'\nimport type { RichTextBodyOption } from './actions/body/serializeBody'\nimport { buildDefaultActionDefinitions } from './actions/builtin'\nimport type { RecipientsConfig } from './actions/emailRecipients'\nimport type { FromAddressesResolver } from './actions/fromAddresses'\nimport type { ActionsConfig } from './actions/registry'\nimport { resolveActions } from './actions/registry'\nimport type { FormResultsAccess } from './aggregation/resolveResultsRequest'\nimport type { ButtonsOption } from './collections/buttonFields'\nimport type { ResponseOption } from './collections/redirectFields'\nimport type { ConsentSnapshotMode } from './consent/captureConsent'\nimport { stashConsentSources } from './consent/resolveConsentEntries'\nimport type { ConsentSourcesResolver } from './consent/types'\nimport type { DepartmentEmailsResolver } from './email/departments'\nimport type { FormEventSink } from './events/types'\nimport { buildDefaultFieldDefinitions } from './fields/builtin'\nimport { type FieldTypesConfig, resolveFieldTypes, stashFieldTypes } from './fields/registry'\nimport type { CollectionOverrides } from './plugin/collectionOverrides'\nimport { registerCollections } from './plugin/registerCollections'\nimport { registerTranslations } from './plugin/registerTranslations'\nimport { readUploadCollectionMimeTypes, type UploadsOption } from './plugin/uploadsCollection'\nimport type { OutcomeFieldsOverride } from './poll/outcomeFields'\nimport type { PollTypesConfig } from './poll/pollTypeRegistry'\nimport { resolvePollTypes, stashPollTypes } from './poll/pollTypeRegistry'\nimport type { PollOptionSourcesConfig } from './poll/registry'\nimport { resolvePollOptionSources } from './poll/registry'\nimport { stashPollOptionSources } from './poll/resolvePollOptions'\nimport { resolveSpamConfig } from './spam/resolveSpam'\nimport type { SpamOption } from './spam/types'\nimport type { TranslationsOption } from './translations'\nimport { defaultValidationRules } from './validation/builtin'\nimport { resolveValidationRules, type ValidationRulesConfig } from './validation/registry'\n\nexport type FormBuilderPluginOptions = {\n\tdisabled?: boolean\n\t/**\n\t * Per-locale overrides for this plugin's UI strings, keyed by the typed\n\t * translation keys exported from `@10x-media/form-builder/i18n`. Values win\n\t * over the built-in locales key-by-key; locales the plugin does not ship are\n\t * added whole. App-level `i18n.translations` still wins over both.\n\t */\n\ttranslations?: TranslationsOption\n\t/** Pluggable sink for form lifecycle events. Defaults to a no-op; analytics adapters or a future analytics plugin subscribe here. */\n\tevents?: FormEventSink\n\t/**\n\t * Content-bearing author fields (labels, placeholders, option labels, action subjects and\n\t * bodies) are localized by default. Payload strips the `localized` flag on hosts without\n\t * `localization` configured, so the default is safe everywhere. Set `false` to keep form\n\t * content single-locale even on localized hosts. Spread-overrides of the prebuilt default\n\t * exports (`defaultFieldDefinitionsByType`, `defaultActionDefinitions`) carry `localized`\n\t * flags from the default-true set; when opting out, derive overrides from\n\t * `buildDefaultFieldDefinitions(false)` / `buildDefaultActionDefinitions(false)` instead.\n\t * Consent statements are unaffected either way: they live on the host's own\n\t * `consentSourcesField()`, which carries its own `localized` option.\n\t */\n\tlocalizeContent?: boolean\n\t/** Add, override, or remove field types. `false` removes a built-in, `true` keeps it, an object adds or replaces one. */\n\tfields?: FieldTypesConfig\n\t/** Add, override, or remove validation rule types. `false` removes a built-in, `true` keeps it, an object adds or replaces one. */\n\trules?: ValidationRulesConfig\n\t/** Add, override, or remove post-submit action types. `false` removes a built-in, `true` keeps it, an object adds or replaces one. */\n\tactions?: ActionsConfig\n\t/**\n\t * Customize how the plugin's rich text is authored and rendered. `editor` is the default\n\t * Lexical/richText editor for every plugin richText field (message content, consent\n\t * statement, response message, action bodies); `bodyEditor` overrides the action body\n\t * fields specifically, falling back to `editor`. `converters` spread over the default\n\t * Lexical node converters; `serialize` replaces the whole action-body pipeline (e.g. to\n\t * target chat or plain-text channels instead of email HTML). A custom `serialize` receives\n\t * the submitted `form` (id/title) and `req`, enabling per-tenant lookups or handing the raw\n\t * body off to a renderer like react-email.\n\t */\n\trichText?: RichTextBodyOption\n\t/**\n\t * Email routing for the `emailTeam` and `confirmation` actions. Both sub-options are opt-in by the\n\t * presence of a resolver (not a `false`/`true`/object flag) and share a shape: a `req`-scoped\n\t * resolver, evaluated per request via an endpoint, whose choice is validated at save time only and\n\t * never re-checked when the action sends (the config is admin-authored, not visitor-controlled).\n\t *\n\t * `fromAddresses` gives both actions a `from` select whose options come from the resolver; absent,\n\t * neither action has a `from` field and every send uses the email adapter's default sender. The\n\t * intended use is multi-tenant hosts where each tenant may only send from particular addresses\n\t * (derive the tenant from `req`, return its allowed senders). Values are the literal string\n\t * `payload.sendEmail` accepts as `from` (e.g. `'Name <addr@x.com>'` or a plain address).\n\t *\n\t * `departments` turns the `emailTeam` `to` into a select whose options come from the resolver\n\t * (a `/:id/departments` endpoint); the intended use is to place `departmentsField()` on a document\n\t * you own and read it back with `resolveDepartmentOptions`, which resolves each department's address\n\t * for the requesting locale. Because `to` is localized, each admin locale stores its own resolved\n\t * address and a submission's locale selects the address it routes to (Payload-native, no per-send\n\t * lookup). Storing the resolved address, rather than a department id resolved live at send (consent's\n\t * model), is deliberate: the routing target a form was saved with stays audit-stable even if the\n\t * resolver's data later changes, so do not \"fix\" it into a live lookup. Multi-tenant hosts scope\n\t * which document they read by the tenant derived from `req`; absent, the recipient fields simply\n\t * offer no preset department options (still free-typed emails and field tokens).\n\t */\n\temail?: {\n\t\tfromAddresses?: FromAddressesResolver\n\t\tdepartments?: DepartmentEmailsResolver\n\t\t/** Narrows the recipient fields' behavior (free-typed emails, field tokens). See {@link RecipientsConfig}. */\n\t\trecipients?: RecipientsConfig\n\t}\n\t/**\n\t * Where the consent statements a form can reference come from. Absent (the default): no sources,\n\t * so the built-in `consent` field type is not registered at all and authors cannot add a consent\n\t * field with nothing to reference (a developer-registered custom `consent` type via `fields`\n\t * still wins).\n\t *\n\t * `sources` is an async `req`-scoped resolver returning the sources available to this request.\n\t * The intended shape: place `consentSourcesField()` on a collection or global you own and read it\n\t * back here. Multi-tenant hosts scope that read by the tenant derived from `req`, so a tenant's\n\t * authors only ever see, and their visitors only ever agree to, their own statements. A form\n\t * stores only a source's row `id`; the statement is resolved live per request (see\n\t * `resolveConsentStatements`) and the proof is rebuilt from the source at submit, so neither is\n\t * ever a copy the client could stale or forge.\n\t */\n\tconsent?: {\n\t\tsources: ConsentSourcesResolver\n\t\t/**\n\t\t * What each submission snapshots of the agreed consent wording, for a versioned audit trail.\n\t\t * `'both'` (default) stores a `statementHash`, the plain `statementText`, and the source name;\n\t\t * `'hash'` keeps only the tamper-evident hash; `'text'` only the readable text; `false` keeps the\n\t\t * lean id-only proof. The proof stays id-based regardless; this only adds the wording snapshot.\n\t\t */\n\t\tsnapshot?: ConsentSnapshotMode\n\t}\n\t/**\n\t * Form-level button labels: `submitLabel` at the bottom of the Fields tab, `prevLabel` and\n\t * `nextLabel` in a row at the bottom of the Flow tab (shown once the flow has a step). The\n\t * rendered chrome resolves each label as `<Form>` prop, then the stored value, then the\n\t * translated default. `fields` composes them: it receives the three default fields as a\n\t * `{ submit, prev, next }` map with the content localization flag already applied and returns\n\t * the map, so wrapping a default in a row with a host field (e.g. an icon select) or replacing\n\t * one is explicit. `FormDocument.buttons` reassembles only those three known labels, so a\n\t * host-added sibling field is still stored but is read off the raw document, not `doc.buttons`.\n\t */\n\tbuttons?: ButtonsOption\n\t/**\n\t * The success-response group. `redirect.fields` composes the fields inside the `response.redirect`\n\t * group, mirroring `buttons.fields`: it receives the default fields (the `url` text field, plus the\n\t * polymorphic `reference` relationship when `redirectRelationships` is set) and returns the group's\n\t * final field array, so a host can prepend a custom link field (the pattern most projects already\n\t * have), swap `url` for their own picker, reorder, or filter. Omit it and the group stays the\n\t * built-in `url` (+ optional `reference`), unchanged.\n\t *\n\t * The plugin's built-in redirect handling reads `redirect.url` (and `redirect.reference` when\n\t * configured); `toFormDocument` passes the whole `response` group through, so a host that replaces\n\t * `url` with their own link field owns resolving it to a destination in their frontend, the same as\n\t * the internal-reference case.\n\t */\n\tresponse?: ResponseOption\n\t/**\n\t * Collections whose documents `response.redirect` can reference (`response.redirect.reference`),\n\t * letting an author redirect a visitor to an internal document instead of a URL after a\n\t * successful submit. Absent (the default): no `reference` field exists at all, matching today's\n\t * URL-only redirect. Always polymorphic, even for a single slug (a `CollectionSlug[]` array, not\n\t * a bare `CollectionSlug`), so a host adding a second collection later never changes the stored\n\t * shape, the same precedent as `consentSourcesField()`'s `page` picker. The plugin never resolves\n\t * the reference to a URL itself (it has no notion of the host's routing); `toFormDocument` passes\n\t * the raw `{ relationTo, value }` pair through on `FormDocument.response.redirect.reference` for\n\t * the host to resolve. Mirrors the `redirectRelationships` option of Payload's native\n\t * `plugin-form-builder`.\n\t */\n\tredirectRelationships?: CollectionSlug[]\n\t/**\n\t * File uploads are bring-your-own. Default `false`: no upload collection is involved and the\n\t * built-in `file` field type is removed from the registry, so form authors cannot add a field\n\t * with nowhere to land (a developer-registered custom `file` type via `fields` still wins).\n\t * `{ collection: 'slug' }` points at a host-owned upload collection (created by the app with\n\t * its storage adapter); the plugin validates it at boot, appends its hidden `owner` field when\n\t * absent, and prepends the spam upload hooks.\n\t */\n\tuploads?: UploadsOption\n\t/** Honeypot + rate-limiting (on by default) + a captcha adapter seam + upload-ownership scoping. `false` disables the whole subsystem. */\n\tspam?: SpamOption\n\t/**\n\t * Aggregate-results endpoint options. `access` gates anonymous reads after the form is loaded\n\t * and before anything is served; absent keeps the plugin-default gating (poll opt-in +\n\t * visibility + enumerable-field guard). Multi-tenant hosts should compare `form.tenant` against\n\t * the tenant derived from `req` so one tenant's poll counts are never readable under another\n\t * tenant's id. Authenticated callers bypass this seam.\n\t */\n\tresults?: { access?: FormResultsAccess }\n\t/**\n\t * Poll behavior. `votedCookie: true` sets an httpOnly `fb-voted-{formId}=1` cookie on each\n\t * successful submission to a poll-enabled form, letting SSR hosts read the voted state via\n\t * `hasVotedCookie` and pass it to `<Poll hasVoted>`. Default `false`.\n\t * `sources` registers poll option sources (`definePollOptionSource`), letting authors populate\n\t * a poll's choices from host domain data with stable values; there are no built-ins. With at\n\t * least one source registered, the forms poll group gains an `optionSource` select plus its\n\t * per-source `sourceConfig`, and submissions to a sourced poll only accept resolved values.\n\t * `outcomeFields` composes the poll `outcome` group: it receives the two default fields\n\t * (`winningValues`, `resolvedAt`) and returns the group's final field array verbatim, so a host\n\t * can swap `winningValues` for its own component (e.g. a relationship picker over the voteable\n\t * records). Membership validation runs server-side regardless, so a swap cannot bypass it.\n\t * `types` registers outcome strategies (`definePollType`) shown in the poll `type` select. The\n\t * built-ins `manual` (default, hand-picked), `mostVoted` (auto-resolves to the top choice(s) on\n\t * close), and `source` (delegates to the option source) are always registered; a host entry keyed\n\t * by (or carrying) a built-in slug replaces it. A closed poll whose strategy is not `manual`\n\t * auto-resolves via a scheduled job when a runner is present, or on the next results read otherwise.\n\t */\n\tpoll?: {\n\t\tvotedCookie?: boolean\n\t\tsources?: PollOptionSourcesConfig\n\t\ttypes?: PollTypesConfig\n\t\toutcomeFields?: OutcomeFieldsOverride\n\t}\n\t/**\n\t * When `true`, the raw `values`, `descriptors`, and `consent` JSON fields are visible in the\n\t * submission admin view. Default `false`, because the `SubmissionAnswers` UI component already\n\t * represents those fields fully and they are noisy shown alongside it.\n\t */\n\tshowSubmissionRawFields?: boolean\n\t/**\n\t * Override individual plugin-managed collections using explicit spreads. Each key accepts a\n\t * `CollectionOverrides` object: top-level keys are spread with the plugin's defaults (spread\n\t * order per key determines who wins), hooks are appended after the plugin's own hooks, and\n\t * `fields` is a function that receives the default fields and returns the final array so\n\t * additions/removals are always intentional.\n\t */\n\toverrides?: {\n\t\tforms?: CollectionOverrides\n\t\tformSubmissions?: CollectionOverrides\n\t}\n}\n\ndeclare module 'payload' {\n\tinterface RegisteredPlugins {\n\t\t'@10x-media/form-builder': FormBuilderPluginOptions\n\t}\n}\n\nexport const formBuilder = definePlugin<FormBuilderPluginOptions>({\n\tslug: '@10x-media/form-builder',\n\torder: 50,\n\tplugin: ({ config, plugins, ...options }): Config => {\n\t\tif (options.disabled === true) {\n\t\t\treturn config\n\t\t}\n\t\tconst localizeContent = options.localizeContent !== false\n\t\tconst uploads = options.uploads ?? false\n\t\t// The file field's MIME picker is constrained to what the host upload collection accepts: the\n\t\t// explicit `uploads.mimeTypes` override, else the collection's own `upload.mimeTypes`. Read here,\n\t\t// before the field registry freezes below (attachUploadsCollection runs too late).\n\t\tconst uploadMimeTypes =\n\t\t\tuploads === false\n\t\t\t\t? undefined\n\t\t\t\t: (uploads.mimeTypes ?? readUploadCollectionMimeTypes(config, uploads.collection))\n\t\tconst consentSources = options.consent?.sources\n\t\t// A built-in with nowhere to point never enters the registry, so an author is never offered a\n\t\t// field that cannot work: file without an uploads collection has nowhere to store anything,\n\t\t// consent without sources has no statement to reference. An explicit `fields.file` /\n\t\t// `fields.consent` definition remains a developer choice.\n\t\tconst defaultFieldDefinitions = buildDefaultFieldDefinitions(\n\t\t\tlocalizeContent,\n\t\t\toptions.richText?.editor,\n\t\t\tuploadMimeTypes\n\t\t).filter(\n\t\t\t(definition) =>\n\t\t\t\t(uploads !== false || definition.type !== 'file') &&\n\t\t\t\t(consentSources !== undefined || definition.type !== 'consent')\n\t\t)\n\t\tconst registry = resolveFieldTypes(defaultFieldDefinitions, options.fields)\n\t\tconst ruleRegistry = resolveValidationRules(defaultValidationRules, options.rules)\n\t\tconst fromAddresses = options.email?.fromAddresses\n\t\tconst departments = options.email?.departments\n\t\tconst actionRegistry = resolveActions(\n\t\t\tbuildDefaultActionDefinitions(\n\t\t\t\tlocalizeContent,\n\t\t\t\toptions.richText?.bodyEditor ?? options.richText?.editor,\n\t\t\t\tfromAddresses,\n\t\t\t\tdepartments,\n\t\t\t\toptions.email?.recipients\n\t\t\t),\n\t\t\toptions.actions\n\t\t)\n\t\tconst spam = resolveSpamConfig(options.spam)\n\t\tconst pollSourceRegistry = resolvePollOptionSources(options.poll?.sources)\n\t\tconst pollTypeRegistry = resolvePollTypes(options.poll?.types)\n\t\t// Stashed on config.custom so the root-level resolvePollOptions, resolveEffectivePollOptions,\n\t\t// resolvePollOutcome, and resolveConsentStatements helpers can reach these through\n\t\t// `payload.config` at request time, without threading plugin state through the host's own\n\t\t// server code. The field-type registry rides along so resolveEffectivePollOptions can look up a\n\t\t// results field's definition (and its `resolveOptions`) from a bare `payload` instance.\n\t\tconfig.custom = stashPollOptionSources(config.custom, pollSourceRegistry)\n\t\tconfig.custom = stashPollTypes(config.custom, pollTypeRegistry)\n\t\tconfig.custom = stashFieldTypes(config.custom, registry)\n\t\tif (consentSources) {\n\t\t\tconfig.custom = stashConsentSources(config.custom, consentSources)\n\t\t}\n\t\tregisterTranslations(config, options.translations)\n\t\tregisterCollections({\n\t\t\tconfig,\n\t\t\tregistry,\n\t\t\truleRegistry,\n\t\t\tconsentSources,\n\t\t\tconsentSnapshot: options.consent?.snapshot ?? 'both',\n\t\t\tactionRegistry,\n\t\t\trichText: options.richText,\n\t\t\thasJobsPlugin: Boolean(plugins['@10x-media/jobs']),\n\t\t\tevents: options.events,\n\t\t\tuploads,\n\t\t\tspam,\n\t\t\tshowSubmissionRawFields: options.showSubmissionRawFields ?? false,\n\t\t\tlocalizeContent,\n\t\t\tresultsAccess: options.results?.access,\n\t\t\tvotedCookie: options.poll?.votedCookie === true,\n\t\t\tpollSourceRegistry,\n\t\t\tpollTypeRegistry,\n\t\t\toutcomeFields: options.poll?.outcomeFields,\n\t\t\tbuttons: options.buttons,\n\t\t\tresponse: options.response,\n\t\t\tfromAddresses,\n\t\t\tdepartments,\n\t\t\tredirectRelationships: options.redirectRelationships,\n\t\t\toverrides: options.overrides,\n\t\t})\n\t\treturn config\n\t},\n})\n\nexport type {\n\tBodyConverter,\n\tBodyConverterArgs,\n\tBodyRender,\n} from './actions/body/converters'\nexport { defaultBodyConverters, sanitizeUrl } from './actions/body/converters'\nexport { escapeHtml } from './actions/body/escapeHtml'\nexport type {\n\tBodyContext,\n\tRichTextBodyOption,\n\tSerializeBodyArgs,\n} from './actions/body/serializeBody'\nexport { serializeBody } from './actions/body/serializeBody'\nexport { textOfBody } from './actions/body/textOfBody'\nexport { renderAllValues, renderAllValuesTable } from './actions/body/wildcards'\nexport { buildDefaultActionDefinitions, defaultActionDefinitions } from './actions/builtin'\nexport type { ActionDefinition, ActionRunArgs, AnyActionDefinition } from './actions/defineAction'\nexport { defineAction } from './actions/defineAction'\nexport type { FromAddressesResolver, FromAddressOption } from './actions/fromAddresses'\nexport type { ActionOption, ActionRegistry, ActionsConfig } from './actions/registry'\nexport { resolveActions } from './actions/registry'\nexport type { ActionResult } from './actions/runActions'\nexport { SIGNATURE_HEADER, signPayload } from './actions/sign'\nexport type {\n\tAggregateFieldResponsesArgs,\n\tAggregateFormResponsesArgs,\n} from './aggregation/aggregateResponses'\nexport {\n\taggregateFieldResponses,\n\taggregateFormResponses,\n\tfieldHasOptions,\n} from './aggregation/aggregateResponses'\nexport { aggregateRowForField, aggregateRowsForFields } from './aggregation/aggregateRows'\nexport type {\n\tFormResultsAccess,\n\tFormResultsAccessArgs,\n\tResolveResultsRequestArgs,\n\tResolveResultsRequestResult,\n} from './aggregation/resolveResultsRequest'\nexport { resolveFormResultsRequest } from './aggregation/resolveResultsRequest'\nexport type {\n\tAggregationBucket,\n\tAggregationRow,\n\tFieldAggregation,\n\tFieldMeta,\n\tSubmissionStatusFilter,\n} from './aggregation/types'\nexport { calcExpressionOf, computeCalcFields } from './calc/computeCalcFields'\nexport { evaluateCalc } from './calc/evaluate'\nexport { normalizeCalc } from './calc/normalizeCalc'\nexport type { CalcExpression } from './calc/types'\nexport type {\n\tButtonFieldsOverride,\n\tButtonsOption,\n\tDefaultButtonFields,\n} from './collections/buttonFields'\nexport {\n\tbuildDefaultButtonFields,\n\tbuildNextLabelField,\n\tbuildPrevLabelField,\n\tbuildSubmitLabelField,\n} from './collections/buttonFields'\nexport type {\n\tRedirectFieldsOverride,\n\tRedirectOption,\n\tResponseOption,\n} from './collections/redirectFields'\nexport { evaluateCondition } from './conditions/evaluate'\nexport type { FieldCondition } from './conditions/types'\nexport { applyConsentStatements } from './consent/applyConsentStatements'\nexport type { ConsentProof, ConsentSnapshotMode } from './consent/captureConsent'\nexport { captureConsent } from './consent/captureConsent'\nexport type { ConsentSourcesFieldOptions } from './consent/consentSourcesField'\nexport { consentSourcesField } from './consent/consentSourcesField'\nexport type { ResolveConsentEntriesArgs } from './consent/resolveConsentEntries'\nexport { resolveConsentEntries } from './consent/resolveConsentEntries'\nexport type {\n\tConsentSourceOption,\n\tResolveConsentSourcesRequestArgs,\n\tResolveConsentSourcesRequestResult,\n} from './consent/resolveConsentSourcesRequest'\nexport { resolveConsentSourcesRequest } from './consent/resolveConsentSourcesRequest'\nexport type {\n\tConsentStatement,\n\tConsentStatements,\n\tResolveConsentStatementsArgs,\n} from './consent/resolveConsentStatements'\nexport { resolveConsentStatements } from './consent/resolveConsentStatements'\nexport type { ResolvePublishedVersionRefArgs } from './consent/resolvePublishedVersionRef'\nexport { resolvePublishedVersionRef } from './consent/resolvePublishedVersionRef'\nexport type {\n\tConsentSourceEntry,\n\tConsentSourcePage,\n\tConsentSourcesResolver,\n} from './consent/types'\nexport type {\n\tDepartmentEmailsResolver,\n\tDepartmentOption,\n\tResolveDepartmentOptionsArgs,\n\tResolveDepartmentsRequestArgs,\n\tResolveDepartmentsRequestResult,\n} from './email/departments'\nexport { resolveDepartmentOptions } from './email/departments'\nexport type { DepartmentsFieldOptions } from './email/departmentsField'\nexport { departmentsField } from './email/departmentsField'\nexport {\n\tbuildDefaultFieldDefinitions,\n\tdefaultFieldDefinitions,\n\tdefaultFieldDefinitionsByType,\n} from './fields/builtin'\nexport { countryField } from './fields/builtin/country'\nexport { fileMimeTypeOptions } from './fields/builtin/file'\nexport { stateField } from './fields/builtin/state'\nexport { defineFormField } from './fields/defineFormField'\nexport { fieldKey } from './fields/fieldKey'\nexport { localizedIf } from './fields/localizedIf'\nexport type { FieldTypeOption, FieldTypeRegistry, FieldTypesConfig } from './fields/registry'\nexport type {\n\tAnyFormFieldDefinition,\n\tFormFieldDefinition,\n\tFormFieldFormat,\n\tFormFieldValidate,\n\tFormFieldValueKind,\n\tOmittableSharedField,\n\tResolveFieldOptionsArgs,\n} from './fields/types'\nexport { isPollClosed } from './form/pollState'\nexport type { ToFormDocumentOptions } from './form/toFormDocument'\nexport { toFormDocument } from './form/toFormDocument'\nexport type {\n\tFormButtonSettings,\n\tFormDocument,\n\tFormPollSettings,\n\tFormResponseSettings,\n} from './form/types'\nexport type { UploadsOption } from './plugin/uploadsCollection'\nexport type { PollCloseTaskInput } from './poll/closeJob'\nexport {\n\tbuildPollCloseTask,\n\tenqueuePollClose,\n\tPOLL_CLOSE_TASK_SLUG,\n\tregisterPollCloseTask,\n\trunPollClose,\n\tshouldAutoResolvePoll,\n} from './poll/closeJob'\nexport type {\n\tAnyPollOptionSource,\n\tPollOption,\n\tPollOptionResolveArgs,\n\tPollOptionSource,\n} from './poll/definePollOptionSource'\nexport { definePollOptionSource } from './poll/definePollOptionSource'\nexport type { PollOutcomeStrategy, PollOutcomeStrategyArgs } from './poll/definePollType'\nexport { definePollType } from './poll/definePollType'\nexport type { ResolveEffectivePollOptionsArgs } from './poll/effectivePollOptions'\nexport { resolveEffectivePollOptions } from './poll/effectivePollOptions'\nexport { mostVotedStrategy, topBucketValues } from './poll/mostVoted'\nexport type { DefaultOutcomeFields, OutcomeFieldsOverride } from './poll/outcomeFields'\nexport {\n\tbuildDefaultOutcomeFields,\n\tbuildResolvedAtField,\n\tbuildWinningValuesField,\n} from './poll/outcomeFields'\nexport type { PollTypeRegistry, PollTypesConfig } from './poll/pollTypeRegistry'\nexport {\n\tmanualStrategy,\n\tpollTypesOf,\n\tresolvePollTypes,\n\tsourceStrategy,\n\tstashPollTypes,\n} from './poll/pollTypeRegistry'\nexport type {\n\tPollOptionSourceOption,\n\tPollOptionSourceRegistry,\n\tPollOptionSourcesConfig,\n} from './poll/registry'\nexport { resolvePollOptionSources } from './poll/registry'\nexport type { ResolvePollOptionsArgs } from './poll/resolvePollOptions'\nexport { resolvePollOptions } from './poll/resolvePollOptions'\nexport type { ResolvePollOutcomeArgs } from './poll/resolvePollOutcome'\nexport { resolvePollOutcome } from './poll/resolvePollOutcome'\nexport type { PrefillOptions } from './prefill/valuesFromSearchParams'\nexport { valuesFromSearchParams } from './prefill/valuesFromSearchParams'\nexport { DEFAULT_PRESENTATION_NAME, defaultPresentationDescriptors } from './presentations/defaults'\nexport type {\n\tPresentationDensity,\n\tPresentationDescriptor,\n\tPresentationSurface,\n} from './presentations/types'\nexport { interpolate } from './recall/interpolate'\nexport type { RecallResolver } from './recall/resolver'\nexport { buildRecallResolver, optionLabelsFor } from './recall/resolver'\nexport { defineCaptchaProvider } from './spam/captcha'\nexport { CAPTCHA_TOKEN_KEY, DEFAULT_HONEYPOT_FIELD } from './spam/constants'\nexport { defaultIdentify } from './spam/identify'\nexport type { HcaptchaProviderOptions } from './spam/providers/hcaptcha'\nexport { hcaptchaProvider } from './spam/providers/hcaptcha'\nexport type { RecaptchaProviderOptions } from './spam/providers/recaptcha'\nexport { recaptchaProvider } from './spam/providers/recaptcha'\nexport type { TurnstileProviderOptions } from './spam/providers/turnstile'\nexport { turnstileProvider } from './spam/providers/turnstile'\nexport { createKvRateLimiter } from './spam/rateLimiter'\nexport { resolveSpamConfig } from './spam/resolveSpam'\nexport type {\n\tCaptchaProvider,\n\tCaptchaVerifyArgs,\n\tIdentifyFn,\n\tRateLimitCheckArgs,\n\tRateLimitConfig,\n\tRateLimiter,\n\tRateLimitResult,\n\tSpamConfig,\n\tSpamMetadataConfig,\n\tSpamOption,\n} from './spam/types'\nexport type { CreatedSubmission, CreateSubmissionArgs } from './submissions/createSubmission'\nexport { createSubmission } from './submissions/createSubmission'\nexport { hasVotedCookie, votedCookieName } from './submissions/votedCookie'\nexport { captureFileRef } from './uploads/captureFileRef'\nexport { formatBytes } from './uploads/formatBytes'\nexport { resolveFileRef } from './uploads/resolveFileRef'\nexport type { FileFieldConfig, FileRef, FileRefError } from './uploads/types'\nexport { defaultValidationRules, defaultValidationRulesByType } from './validation/builtin'\nexport { defineValidationRule } from './validation/defineValidationRule'\nexport type { FieldTargetParamOptions } from './validation/fieldTargetParam'\nexport { fieldTargetParam } from './validation/fieldTargetParam'\nexport type {\n\tValidationRuleOption,\n\tValidationRuleRegistry,\n\tValidationRulesConfig,\n} from './validation/registry'\nexport type {\n\tAnyValidationRuleDefinition,\n\tValidationRuleDefinition,\n\tValidationRuleResult,\n} from './validation/types'\nexport type { FormBuilderPluginOptions as PluginOptions }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwOA,MAAa,cAAc,aAAuC;CACjE,MAAM;CACN,OAAO;CACP,SAAS,EAAE,QAAQ,SAAS,GAAG,cAAsB;EACpD,IAAI,QAAQ,aAAa,MACxB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ACA,eAAe,QAAQ,MAAM;GAC7B,SAAS,QAAQ;GACjB,UAAU,QAAQ;GAClB;GACA;GACA,uBAAuB,QAAQ;GAC/B,WAAW,QAAQ;EACpB,CAAC;EACD,OAAO;CACR;AACD,CAAC"}
@@ -4,7 +4,7 @@ import { buildSubmissionsCollection } from "../collections/formSubmissions.js";
4
4
  import { registerActionsTask } from "../actions/task.js";
5
5
  import { attachUploadsCollection } from "./uploadsCollection.js";
6
6
  //#region src/plugin/registerCollections.ts
7
- const registerCollections = ({ config, registry, ruleRegistry, consentSources, actionRegistry, richText, hasJobsPlugin, events, uploads, spam, showSubmissionRawFields, localizeContent, resultsAccess, votedCookie, pollSourceRegistry, pollTypeRegistry, outcomeFields, buttons, response, fromAddresses, departments, redirectRelationships, overrides }) => {
7
+ const registerCollections = ({ config, registry, ruleRegistry, consentSources, consentSnapshot, actionRegistry, richText, hasJobsPlugin, events, uploads, spam, showSubmissionRawFields, localizeContent, resultsAccess, votedCookie, pollSourceRegistry, pollTypeRegistry, outcomeFields, buttons, response, fromAddresses, departments, redirectRelationships, overrides }) => {
8
8
  registerActionsTask(config, actionRegistry, richText);
9
9
  registerPollCloseTask(config);
10
10
  const hasRunner = Boolean(config.jobs?.autoRun) || hasJobsPlugin;
@@ -20,6 +20,7 @@ const registerCollections = ({ config, registry, ruleRegistry, consentSources, a
20
20
  registry,
21
21
  ruleRegistry,
22
22
  consentSources,
23
+ consentSnapshot,
23
24
  actionRegistry,
24
25
  richText,
25
26
  events,
@@ -1 +1 @@
1
- {"version":3,"file":"registerCollections.js","names":[],"sources":["../../src/plugin/registerCollections.ts"],"sourcesContent":["import type { CollectionSlug, Config } from 'payload'\nimport type { RichTextBodyOption } from '../actions/body/serializeBody'\nimport type { FromAddressesResolver } from '../actions/fromAddresses'\nimport type { ActionRegistry } from '../actions/registry'\nimport { registerActionsTask } from '../actions/task'\nimport type { FormResultsAccess } from '../aggregation/resolveResultsRequest'\nimport type { ButtonsOption } from '../collections/buttonFields'\nimport { buildSubmissionsCollection } from '../collections/formSubmissions'\nimport { buildFormsCollection } from '../collections/forms'\nimport type { ResponseOption } from '../collections/redirectFields'\nimport type { ConsentSourcesResolver } from '../consent/types'\nimport type { DepartmentEmailsResolver } from '../email/departments'\nimport type { FormEventSink } from '../events/types'\nimport type { FieldTypeRegistry } from '../fields/registry'\nimport { registerPollCloseTask } from '../poll/closeJob'\nimport type { OutcomeFieldsOverride } from '../poll/outcomeFields'\nimport type { PollTypeRegistry } from '../poll/pollTypeRegistry'\nimport type { PollOptionSourceRegistry } from '../poll/registry'\nimport type { ResolvedSpamConfig } from '../spam/types'\nimport type { ValidationRuleRegistry } from '../validation/registry'\nimport type { CollectionOverrides } from './collectionOverrides'\nimport { attachUploadsCollection, type UploadsOption } from './uploadsCollection'\n\ntype RegisterCollectionsArgs = {\n\tconfig: Config\n\tregistry: FieldTypeRegistry\n\truleRegistry: ValidationRuleRegistry\n\tconsentSources?: ConsentSourcesResolver\n\tactionRegistry: ActionRegistry\n\trichText?: RichTextBodyOption\n\thasJobsPlugin: boolean\n\tevents?: FormEventSink\n\tuploads: UploadsOption\n\tspam: ResolvedSpamConfig | false\n\tshowSubmissionRawFields: boolean\n\tlocalizeContent: boolean\n\tresultsAccess?: FormResultsAccess\n\tvotedCookie: boolean\n\tpollSourceRegistry: PollOptionSourceRegistry\n\tpollTypeRegistry: PollTypeRegistry\n\toutcomeFields?: OutcomeFieldsOverride\n\tbuttons?: ButtonsOption\n\tresponse?: ResponseOption\n\tfromAddresses?: FromAddressesResolver\n\tdepartments?: DepartmentEmailsResolver\n\tredirectRelationships?: CollectionSlug[]\n\toverrides?: {\n\t\tforms?: CollectionOverrides\n\t\tformSubmissions?: CollectionOverrides\n\t}\n}\n\nexport const registerCollections = ({\n\tconfig,\n\tregistry,\n\truleRegistry,\n\tconsentSources,\n\tactionRegistry,\n\trichText,\n\thasJobsPlugin,\n\tevents,\n\tuploads,\n\tspam,\n\tshowSubmissionRawFields,\n\tlocalizeContent,\n\tresultsAccess,\n\tvotedCookie,\n\tpollSourceRegistry,\n\tpollTypeRegistry,\n\toutcomeFields,\n\tbuttons,\n\tresponse,\n\tfromAddresses,\n\tdepartments,\n\tredirectRelationships,\n\toverrides,\n}: RegisterCollectionsArgs): void => {\n\tregisterActionsTask(config, actionRegistry, richText)\n\tregisterPollCloseTask(config)\n\tconst hasRunner = Boolean(config.jobs?.autoRun) || hasJobsPlugin\n\n\tconst uploadSlug = uploads === false ? undefined : uploads.collection\n\tif (uploads !== false) {\n\t\tattachUploadsCollection({ config, slug: uploads.collection, spam })\n\t}\n\n\t// Payload has no nav-sort option, so it lists collections in registration order. Register\n\t// `form-submissions` before `forms` so the \"Forms\" nav group reads alphabetically\n\t// (`form-submissions` < `forms`); ordering plugin nav groups against a host's own collections\n\t// stays a host concern.\n\tconfig.collections = [\n\t\t...(config.collections ?? []),\n\t\tbuildSubmissionsCollection({\n\t\t\tregistry,\n\t\t\truleRegistry,\n\t\t\tconsentSources,\n\t\t\tactionRegistry,\n\t\t\trichText,\n\t\t\tevents,\n\t\t\thasRunner,\n\t\t\tuploadSlug,\n\t\t\tspam,\n\t\t\tvotedCookie,\n\t\t\tpollSourceRegistry,\n\t\t\tshowRawFields: showSubmissionRawFields,\n\t\t\toverrides: overrides?.formSubmissions,\n\t\t}),\n\t\tbuildFormsCollection({\n\t\t\tregistry,\n\t\t\truleRegistry,\n\t\t\tconsentSources,\n\t\t\tactionRegistry,\n\t\t\tlocalizeContent,\n\t\t\trichText,\n\t\t\tuploadsCollectionSlug: uploadSlug,\n\t\t\tresultsAccess,\n\t\t\tpollSourceRegistry,\n\t\t\tpollTypeRegistry,\n\t\t\toutcomeFields,\n\t\t\tbuttons,\n\t\t\tresponse,\n\t\t\tfromAddresses,\n\t\t\tdepartments,\n\t\t\tredirectRelationships,\n\t\t\toverrides: overrides?.forms,\n\t\t}),\n\t]\n}\n"],"mappings":";;;;;;AAoDA,MAAa,uBAAuB,EACnC,QACA,UACA,cACA,gBACA,gBACA,UACA,eACA,QACA,SACA,MACA,yBACA,iBACA,eACA,aACA,oBACA,kBACA,eACA,SACA,UACA,eACA,aACA,uBACA,gBACoC;CACpC,oBAAoB,QAAQ,gBAAgB,QAAQ;CACpD,sBAAsB,MAAM;CAC5B,MAAM,YAAY,QAAQ,OAAO,MAAM,OAAO,KAAK;CAEnD,MAAM,aAAa,YAAY,QAAQ,KAAA,IAAY,QAAQ;CAC3D,IAAI,YAAY,OACf,wBAAwB;EAAE;EAAQ,MAAM,QAAQ;EAAY;CAAK,CAAC;CAOnE,OAAO,cAAc;EACpB,GAAI,OAAO,eAAe,CAAC;EAC3B,2BAA2B;GAC1B;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA,eAAe;GACf,WAAW,WAAW;EACvB,CAAC;EACD,qBAAqB;GACpB;GACA;GACA;GACA;GACA;GACA;GACA,uBAAuB;GACvB;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA,WAAW,WAAW;EACvB,CAAC;CACF;AACD"}
1
+ {"version":3,"file":"registerCollections.js","names":[],"sources":["../../src/plugin/registerCollections.ts"],"sourcesContent":["import type { CollectionSlug, Config } from 'payload'\nimport type { RichTextBodyOption } from '../actions/body/serializeBody'\nimport type { FromAddressesResolver } from '../actions/fromAddresses'\nimport type { ActionRegistry } from '../actions/registry'\nimport { registerActionsTask } from '../actions/task'\nimport type { FormResultsAccess } from '../aggregation/resolveResultsRequest'\nimport type { ButtonsOption } from '../collections/buttonFields'\nimport { buildSubmissionsCollection } from '../collections/formSubmissions'\nimport { buildFormsCollection } from '../collections/forms'\nimport type { ResponseOption } from '../collections/redirectFields'\nimport type { ConsentSnapshotMode } from '../consent/captureConsent'\nimport type { ConsentSourcesResolver } from '../consent/types'\nimport type { DepartmentEmailsResolver } from '../email/departments'\nimport type { FormEventSink } from '../events/types'\nimport type { FieldTypeRegistry } from '../fields/registry'\nimport { registerPollCloseTask } from '../poll/closeJob'\nimport type { OutcomeFieldsOverride } from '../poll/outcomeFields'\nimport type { PollTypeRegistry } from '../poll/pollTypeRegistry'\nimport type { PollOptionSourceRegistry } from '../poll/registry'\nimport type { ResolvedSpamConfig } from '../spam/types'\nimport type { ValidationRuleRegistry } from '../validation/registry'\nimport type { CollectionOverrides } from './collectionOverrides'\nimport { attachUploadsCollection, type UploadsOption } from './uploadsCollection'\n\ntype RegisterCollectionsArgs = {\n\tconfig: Config\n\tregistry: FieldTypeRegistry\n\truleRegistry: ValidationRuleRegistry\n\tconsentSources?: ConsentSourcesResolver\n\tconsentSnapshot?: ConsentSnapshotMode\n\tactionRegistry: ActionRegistry\n\trichText?: RichTextBodyOption\n\thasJobsPlugin: boolean\n\tevents?: FormEventSink\n\tuploads: UploadsOption\n\tspam: ResolvedSpamConfig | false\n\tshowSubmissionRawFields: boolean\n\tlocalizeContent: boolean\n\tresultsAccess?: FormResultsAccess\n\tvotedCookie: boolean\n\tpollSourceRegistry: PollOptionSourceRegistry\n\tpollTypeRegistry: PollTypeRegistry\n\toutcomeFields?: OutcomeFieldsOverride\n\tbuttons?: ButtonsOption\n\tresponse?: ResponseOption\n\tfromAddresses?: FromAddressesResolver\n\tdepartments?: DepartmentEmailsResolver\n\tredirectRelationships?: CollectionSlug[]\n\toverrides?: {\n\t\tforms?: CollectionOverrides\n\t\tformSubmissions?: CollectionOverrides\n\t}\n}\n\nexport const registerCollections = ({\n\tconfig,\n\tregistry,\n\truleRegistry,\n\tconsentSources,\n\tconsentSnapshot,\n\tactionRegistry,\n\trichText,\n\thasJobsPlugin,\n\tevents,\n\tuploads,\n\tspam,\n\tshowSubmissionRawFields,\n\tlocalizeContent,\n\tresultsAccess,\n\tvotedCookie,\n\tpollSourceRegistry,\n\tpollTypeRegistry,\n\toutcomeFields,\n\tbuttons,\n\tresponse,\n\tfromAddresses,\n\tdepartments,\n\tredirectRelationships,\n\toverrides,\n}: RegisterCollectionsArgs): void => {\n\tregisterActionsTask(config, actionRegistry, richText)\n\tregisterPollCloseTask(config)\n\tconst hasRunner = Boolean(config.jobs?.autoRun) || hasJobsPlugin\n\n\tconst uploadSlug = uploads === false ? undefined : uploads.collection\n\tif (uploads !== false) {\n\t\tattachUploadsCollection({ config, slug: uploads.collection, spam })\n\t}\n\n\t// Payload has no nav-sort option, so it lists collections in registration order. Register\n\t// `form-submissions` before `forms` so the \"Forms\" nav group reads alphabetically\n\t// (`form-submissions` < `forms`); ordering plugin nav groups against a host's own collections\n\t// stays a host concern.\n\tconfig.collections = [\n\t\t...(config.collections ?? []),\n\t\tbuildSubmissionsCollection({\n\t\t\tregistry,\n\t\t\truleRegistry,\n\t\t\tconsentSources,\n\t\t\tconsentSnapshot,\n\t\t\tactionRegistry,\n\t\t\trichText,\n\t\t\tevents,\n\t\t\thasRunner,\n\t\t\tuploadSlug,\n\t\t\tspam,\n\t\t\tvotedCookie,\n\t\t\tpollSourceRegistry,\n\t\t\tshowRawFields: showSubmissionRawFields,\n\t\t\toverrides: overrides?.formSubmissions,\n\t\t}),\n\t\tbuildFormsCollection({\n\t\t\tregistry,\n\t\t\truleRegistry,\n\t\t\tconsentSources,\n\t\t\tactionRegistry,\n\t\t\tlocalizeContent,\n\t\t\trichText,\n\t\t\tuploadsCollectionSlug: uploadSlug,\n\t\t\tresultsAccess,\n\t\t\tpollSourceRegistry,\n\t\t\tpollTypeRegistry,\n\t\t\toutcomeFields,\n\t\t\tbuttons,\n\t\t\tresponse,\n\t\t\tfromAddresses,\n\t\t\tdepartments,\n\t\t\tredirectRelationships,\n\t\t\toverrides: overrides?.forms,\n\t\t}),\n\t]\n}\n"],"mappings":";;;;;;AAsDA,MAAa,uBAAuB,EACnC,QACA,UACA,cACA,gBACA,iBACA,gBACA,UACA,eACA,QACA,SACA,MACA,yBACA,iBACA,eACA,aACA,oBACA,kBACA,eACA,SACA,UACA,eACA,aACA,uBACA,gBACoC;CACpC,oBAAoB,QAAQ,gBAAgB,QAAQ;CACpD,sBAAsB,MAAM;CAC5B,MAAM,YAAY,QAAQ,OAAO,MAAM,OAAO,KAAK;CAEnD,MAAM,aAAa,YAAY,QAAQ,KAAA,IAAY,QAAQ;CAC3D,IAAI,YAAY,OACf,wBAAwB;EAAE;EAAQ,MAAM,QAAQ;EAAY;CAAK,CAAC;CAOnE,OAAO,cAAc;EACpB,GAAI,OAAO,eAAe,CAAC;EAC3B,2BAA2B;GAC1B;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA,eAAe;GACf,WAAW,WAAW;EACvB,CAAC;EACD,qBAAqB;GACpB;GACA;GACA;GACA;GACA;GACA;GACA,uBAAuB;GACvB;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA,WAAW,WAAW;EACvB,CAAC;CACF;AACD"}
@@ -4,9 +4,12 @@ import { Config } from "payload";
4
4
  /**
5
5
  * Uploads are bring-your-own: `false` (the default) disables file fields entirely, an object points
6
6
  * at a host-owned upload collection (created by the app with its storage adapter of choice).
7
+ * `mimeTypes` optionally constrains the file field's MIME picker for hosts that enforce types by other
8
+ * means than the collection's own `upload.mimeTypes` (which is read automatically when this is absent).
7
9
  */
8
10
  type UploadsOption = false | {
9
11
  collection: string;
12
+ mimeTypes?: string[];
10
13
  };
11
14
  //#endregion
12
15
  export { UploadsOption };
@@ -1,5 +1,14 @@
1
1
  import { buildUploadOwnerStamp, buildUploadRateLimit } from "../spam/uploadHooks.js";
2
2
  //#region src/plugin/uploadsCollection.ts
3
+ /**
4
+ * The MIME types the file field's picker should offer: the host upload collection's own
5
+ * `upload.mimeTypes`, or undefined (no constraint, so the picker keeps its full list). Read at
6
+ * plugin-factory time, before the field registry freezes; `attachUploadsCollection` runs too late.
7
+ */
8
+ const readUploadCollectionMimeTypes = (config, slug) => {
9
+ const upload = (config.collections?.find((collection) => collection.slug === slug))?.upload;
10
+ return typeof upload === "object" && Array.isArray(upload.mimeTypes) ? upload.mimeTypes : void 0;
11
+ };
3
12
  /** Descends presentational rows only: an `owner` field nested in a group/tabs/collapsible is not detected, so a top-level one gets appended alongside it. */
4
13
  const hasFieldNamed = (fields, name) => fields.some((field) => {
5
14
  if ("name" in field && field.name === name) return true;
@@ -39,6 +48,6 @@ const attachUploadsCollection = ({ config, slug, spam }) => {
39
48
  config.collections = collections.map((collection) => collection.slug === slug ? attached : collection);
40
49
  };
41
50
  //#endregion
42
- export { attachUploadsCollection };
51
+ export { attachUploadsCollection, readUploadCollectionMimeTypes };
43
52
 
44
53
  //# sourceMappingURL=uploadsCollection.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"uploadsCollection.js","names":[],"sources":["../../src/plugin/uploadsCollection.ts"],"sourcesContent":["import type { CollectionConfig, Config, Field } from 'payload'\nimport type { ResolvedSpamConfig } from '../spam/types'\nimport { buildUploadOwnerStamp, buildUploadRateLimit } from '../spam/uploadHooks'\n\n/**\n * Uploads are bring-your-own: `false` (the default) disables file fields entirely, an object points\n * at a host-owned upload collection (created by the app with its storage adapter of choice).\n */\nexport type UploadsOption = false | { collection: string }\n\n/** Descends presentational rows only: an `owner` field nested in a group/tabs/collapsible is not detected, so a top-level one gets appended alongside it. */\nconst hasFieldNamed = (fields: Field[], name: string): boolean =>\n\tfields.some((field) => {\n\t\tif ('name' in field && field.name === name) {\n\t\t\treturn true\n\t\t}\n\t\treturn field.type === 'row' && hasFieldNamed(field.fields, name)\n\t})\n\ntype AttachUploadsCollectionArgs = {\n\tconfig: Config\n\tslug: string\n\tspam: ResolvedSpamConfig | false\n}\n\n/**\n * Wire the plugin's upload concerns into the host-owned upload collection named by\n * `uploads.collection`. The collection must already exist in `config.collections` and carry an\n * `upload` config; anything else is a plugin misconfiguration and throws at boot. The plugin\n * appends its hidden `owner` text field unless the host already defines a field named `owner`\n * (then that field is reused and must stay a text-compatible identity slot), and prepends the\n * spam upload hooks (rate limit, owner stamp) ahead of the host's own hooks so abuse checks run\n * first. The host entry is replaced with a new object; the host's config is never mutated.\n */\nexport const attachUploadsCollection = ({\n\tconfig,\n\tslug,\n\tspam,\n}: AttachUploadsCollectionArgs): void => {\n\tconst collections = config.collections ?? []\n\tconst target = collections.find((collection) => collection.slug === slug)\n\tif (!target) {\n\t\tthrow new Error(\n\t\t\t`@10x-media/form-builder: uploads.collection \"${slug}\" was not found in config.collections. ` +\n\t\t\t\t`Create an upload-enabled collection (with your storage adapter) and pass its slug, ` +\n\t\t\t\t`e.g. formBuilder({ uploads: { collection: 'media' } }).`\n\t\t)\n\t}\n\tif (!target.upload) {\n\t\tthrow new Error(\n\t\t\t`@10x-media/form-builder: uploads.collection \"${slug}\" has no \\`upload\\` config. ` +\n\t\t\t\t`File fields store Payload uploads, so the collection must be an upload collection ` +\n\t\t\t\t`(set \\`upload: true\\` or an upload options object on it).`\n\t\t)\n\t}\n\n\tconst fields = hasFieldNamed(target.fields, 'owner')\n\t\t? target.fields\n\t\t: [\n\t\t\t\t...target.fields,\n\t\t\t\t{ name: 'owner', type: 'text', admin: { readOnly: true, hidden: true } } as Field,\n\t\t\t]\n\n\tconst attached: CollectionConfig = {\n\t\t...target,\n\t\tfields,\n\t\t...(spam\n\t\t\t? {\n\t\t\t\t\thooks: {\n\t\t\t\t\t\t...(target.hooks ?? {}),\n\t\t\t\t\t\tbeforeOperation: [buildUploadRateLimit(spam), ...(target.hooks?.beforeOperation ?? [])],\n\t\t\t\t\t\tbeforeValidate: [buildUploadOwnerStamp(spam), ...(target.hooks?.beforeValidate ?? [])],\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t: {}),\n\t}\n\n\tconfig.collections = collections.map((collection) =>\n\t\tcollection.slug === slug ? attached : collection\n\t)\n}\n"],"mappings":";;;AAWA,MAAM,iBAAiB,QAAiB,SACvC,OAAO,MAAM,UAAU;CACtB,IAAI,UAAU,SAAS,MAAM,SAAS,MACrC,OAAO;CAER,OAAO,MAAM,SAAS,SAAS,cAAc,MAAM,QAAQ,IAAI;AAChE,CAAC;;;;;;;;;;AAiBF,MAAa,2BAA2B,EACvC,QACA,MACA,WACwC;CACxC,MAAM,cAAc,OAAO,eAAe,CAAC;CAC3C,MAAM,SAAS,YAAY,MAAM,eAAe,WAAW,SAAS,IAAI;CACxE,IAAI,CAAC,QACJ,MAAM,IAAI,MACT,gDAAgD,KAAK,kLAGtD;CAED,IAAI,CAAC,OAAO,QACX,MAAM,IAAI,MACT,gDAAgD,KAAK,wKAGtD;CAGD,MAAM,SAAS,cAAc,OAAO,QAAQ,OAAO,IAChD,OAAO,SACP,CACA,GAAG,OAAO,QACV;EAAE,MAAM;EAAS,MAAM;EAAQ,OAAO;GAAE,UAAU;GAAM,QAAQ;EAAK;CAAE,CACxE;CAEF,MAAM,WAA6B;EAClC,GAAG;EACH;EACA,GAAI,OACD,EACA,OAAO;GACN,GAAI,OAAO,SAAS,CAAC;GACrB,iBAAiB,CAAC,qBAAqB,IAAI,GAAG,GAAI,OAAO,OAAO,mBAAmB,CAAC,CAAE;GACtF,gBAAgB,CAAC,sBAAsB,IAAI,GAAG,GAAI,OAAO,OAAO,kBAAkB,CAAC,CAAE;EACtF,EACD,IACC,CAAC;CACL;CAEA,OAAO,cAAc,YAAY,KAAK,eACrC,WAAW,SAAS,OAAO,WAAW,UACvC;AACD"}
1
+ {"version":3,"file":"uploadsCollection.js","names":[],"sources":["../../src/plugin/uploadsCollection.ts"],"sourcesContent":["import type { CollectionConfig, Config, Field } from 'payload'\nimport type { ResolvedSpamConfig } from '../spam/types'\nimport { buildUploadOwnerStamp, buildUploadRateLimit } from '../spam/uploadHooks'\n\n/**\n * Uploads are bring-your-own: `false` (the default) disables file fields entirely, an object points\n * at a host-owned upload collection (created by the app with its storage adapter of choice).\n * `mimeTypes` optionally constrains the file field's MIME picker for hosts that enforce types by other\n * means than the collection's own `upload.mimeTypes` (which is read automatically when this is absent).\n */\nexport type UploadsOption = false | { collection: string; mimeTypes?: string[] }\n\n/**\n * The MIME types the file field's picker should offer: the host upload collection's own\n * `upload.mimeTypes`, or undefined (no constraint, so the picker keeps its full list). Read at\n * plugin-factory time, before the field registry freezes; `attachUploadsCollection` runs too late.\n */\nexport const readUploadCollectionMimeTypes = (\n\tconfig: Config,\n\tslug: string\n): string[] | undefined => {\n\tconst target = config.collections?.find((collection) => collection.slug === slug)\n\tconst upload = target?.upload\n\treturn typeof upload === 'object' && Array.isArray(upload.mimeTypes)\n\t\t? upload.mimeTypes\n\t\t: undefined\n}\n\n/** Descends presentational rows only: an `owner` field nested in a group/tabs/collapsible is not detected, so a top-level one gets appended alongside it. */\nconst hasFieldNamed = (fields: Field[], name: string): boolean =>\n\tfields.some((field) => {\n\t\tif ('name' in field && field.name === name) {\n\t\t\treturn true\n\t\t}\n\t\treturn field.type === 'row' && hasFieldNamed(field.fields, name)\n\t})\n\ntype AttachUploadsCollectionArgs = {\n\tconfig: Config\n\tslug: string\n\tspam: ResolvedSpamConfig | false\n}\n\n/**\n * Wire the plugin's upload concerns into the host-owned upload collection named by\n * `uploads.collection`. The collection must already exist in `config.collections` and carry an\n * `upload` config; anything else is a plugin misconfiguration and throws at boot. The plugin\n * appends its hidden `owner` text field unless the host already defines a field named `owner`\n * (then that field is reused and must stay a text-compatible identity slot), and prepends the\n * spam upload hooks (rate limit, owner stamp) ahead of the host's own hooks so abuse checks run\n * first. The host entry is replaced with a new object; the host's config is never mutated.\n */\nexport const attachUploadsCollection = ({\n\tconfig,\n\tslug,\n\tspam,\n}: AttachUploadsCollectionArgs): void => {\n\tconst collections = config.collections ?? []\n\tconst target = collections.find((collection) => collection.slug === slug)\n\tif (!target) {\n\t\tthrow new Error(\n\t\t\t`@10x-media/form-builder: uploads.collection \"${slug}\" was not found in config.collections. ` +\n\t\t\t\t`Create an upload-enabled collection (with your storage adapter) and pass its slug, ` +\n\t\t\t\t`e.g. formBuilder({ uploads: { collection: 'media' } }).`\n\t\t)\n\t}\n\tif (!target.upload) {\n\t\tthrow new Error(\n\t\t\t`@10x-media/form-builder: uploads.collection \"${slug}\" has no \\`upload\\` config. ` +\n\t\t\t\t`File fields store Payload uploads, so the collection must be an upload collection ` +\n\t\t\t\t`(set \\`upload: true\\` or an upload options object on it).`\n\t\t)\n\t}\n\n\tconst fields = hasFieldNamed(target.fields, 'owner')\n\t\t? target.fields\n\t\t: [\n\t\t\t\t...target.fields,\n\t\t\t\t{ name: 'owner', type: 'text', admin: { readOnly: true, hidden: true } } as Field,\n\t\t\t]\n\n\tconst attached: CollectionConfig = {\n\t\t...target,\n\t\tfields,\n\t\t...(spam\n\t\t\t? {\n\t\t\t\t\thooks: {\n\t\t\t\t\t\t...(target.hooks ?? {}),\n\t\t\t\t\t\tbeforeOperation: [buildUploadRateLimit(spam), ...(target.hooks?.beforeOperation ?? [])],\n\t\t\t\t\t\tbeforeValidate: [buildUploadOwnerStamp(spam), ...(target.hooks?.beforeValidate ?? [])],\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t: {}),\n\t}\n\n\tconfig.collections = collections.map((collection) =>\n\t\tcollection.slug === slug ? attached : collection\n\t)\n}\n"],"mappings":";;;;;;;AAiBA,MAAa,iCACZ,QACA,SAC0B;CAE1B,MAAM,UADS,OAAO,aAAa,MAAM,eAAe,WAAW,SAAS,IAAI,IACzD;CACvB,OAAO,OAAO,WAAW,YAAY,MAAM,QAAQ,OAAO,SAAS,IAChE,OAAO,YACP,KAAA;AACJ;;AAGA,MAAM,iBAAiB,QAAiB,SACvC,OAAO,MAAM,UAAU;CACtB,IAAI,UAAU,SAAS,MAAM,SAAS,MACrC,OAAO;CAER,OAAO,MAAM,SAAS,SAAS,cAAc,MAAM,QAAQ,IAAI;AAChE,CAAC;;;;;;;;;;AAiBF,MAAa,2BAA2B,EACvC,QACA,MACA,WACwC;CACxC,MAAM,cAAc,OAAO,eAAe,CAAC;CAC3C,MAAM,SAAS,YAAY,MAAM,eAAe,WAAW,SAAS,IAAI;CACxE,IAAI,CAAC,QACJ,MAAM,IAAI,MACT,gDAAgD,KAAK,kLAGtD;CAED,IAAI,CAAC,OAAO,QACX,MAAM,IAAI,MACT,gDAAgD,KAAK,wKAGtD;CAGD,MAAM,SAAS,cAAc,OAAO,QAAQ,OAAO,IAChD,OAAO,SACP,CACA,GAAG,OAAO,QACV;EAAE,MAAM;EAAS,MAAM;EAAQ,OAAO;GAAE,UAAU;GAAM,QAAQ;EAAK;CAAE,CACxE;CAEF,MAAM,WAA6B;EAClC,GAAG;EACH;EACA,GAAI,OACD,EACA,OAAO;GACN,GAAI,OAAO,SAAS,CAAC;GACrB,iBAAiB,CAAC,qBAAqB,IAAI,GAAG,GAAI,OAAO,OAAO,mBAAmB,CAAC,CAAE;GACtF,gBAAgB,CAAC,sBAAsB,IAAI,GAAG,GAAI,OAAO,OAAO,kBAAkB,CAAC,CAAE;EACtF,EACD,IACC,CAAC;CACL;CAEA,OAAO,cAAc,YAAY,KAAK,eACrC,WAAW,SAAS,OAAO,WAAW,UACvC;AACD"}
@@ -1 +1 @@
1
- {"version":3,"file":"SubmissionAnswers.js","names":[],"sources":["../../src/submissions/SubmissionAnswers.tsx"],"sourcesContent":["import type { UIFieldServerProps } from 'payload'\nimport { defaultFieldDefinitions } from '../fields/builtin'\nimport { buildRegistry } from '../fields/registry'\nimport { keys } from '../translations/keys'\nimport { asFieldTranslate } from '../translations/server'\nimport type {\n\tAnswerItem,\n\tConsentItem,\n\tMetaItem,\n\tRepeaterItem,\n\tSubmissionAnswersLabels,\n} from './SubmissionAnswersClient'\nimport { SubmissionAnswersClient } from './SubmissionAnswersClient'\nimport type { SubmissionDescriptor, SubmissionValue } from './types'\n\nconst registry = buildRegistry(defaultFieldDefinitions)\n\ntype ConsentEntry = {\n\tfield: string\n\tagreed: boolean\n\tref?: string\n\tversionRef?: string\n\tat: string\n}\n\ntype MetaSpam = { captcha?: string }\n\ntype SubmissionMeta = {\n\tat?: string\n\tip?: string\n\tua?: string\n\tspam?: MetaSpam\n\t[key: string]: unknown\n}\n\ntype SubmissionDoc = {\n\tvalues?: SubmissionValue[]\n\tdescriptors?: SubmissionDescriptor[]\n\tlocale?: string\n\tconsent?: ConsentEntry[]\n\tmeta?: SubmissionMeta\n}\n\nconst formatDate = (iso: string, locale: string): string => {\n\ttry {\n\t\treturn new Intl.DateTimeFormat(locale, { dateStyle: 'medium', timeStyle: 'short' }).format(\n\t\t\tnew Date(iso)\n\t\t)\n\t} catch {\n\t\treturn iso\n\t}\n}\n\n/**\n * Server component. Formats submission data into serializable props and delegates\n * rendering to the client component which uses Payload's UI components.\n */\nexport const SubmissionAnswers = ({ data, req }: UIFieldServerProps) => {\n\tconst doc = (data ?? {}) as SubmissionDoc\n\tconst descriptors = doc.descriptors ?? []\n\tconst values = doc.values ?? []\n\tconst locale = doc.locale ?? req.locale ?? 'en'\n\tconst t = asFieldTranslate(req.i18n.t)\n\tconst rawConsent = doc.consent ?? []\n\tconst meta = doc.meta\n\n\tconst valueByField = new Map(values.map((entry) => [entry.field, entry.value]))\n\n\tconst answers: AnswerItem[] = []\n\tconst repeaters: RepeaterItem[] = []\n\n\tfor (const descriptor of descriptors) {\n\t\tconst raw = valueByField.get(descriptor.field)\n\n\t\tif (descriptor.fieldType === 'repeater') {\n\t\t\tconst rows = Array.isArray(raw) ? (raw as Array<Record<string, unknown>>) : []\n\t\t\tconst subDescs = descriptor.subFieldDescriptors ?? []\n\t\t\trepeaters.push({\n\t\t\t\tfield: descriptor.field,\n\t\t\t\tlabel: descriptor.label,\n\t\t\t\trows: rows.map((row, rowIndex) => ({\n\t\t\t\t\tid: String(rowIndex),\n\t\t\t\t\tsubFields: subDescs.map((sub) => {\n\t\t\t\t\t\tconst subDef = registry.get(sub.fieldType)\n\t\t\t\t\t\tconst subRaw = row[sub.field]\n\t\t\t\t\t\tconst formatted = subDef?.format\n\t\t\t\t\t\t\t? subDef.format({\n\t\t\t\t\t\t\t\t\tvalue: subRaw,\n\t\t\t\t\t\t\t\t\tconfig: {},\n\t\t\t\t\t\t\t\t\toptionLabels: sub.optionLabels,\n\t\t\t\t\t\t\t\t\tlocale,\n\t\t\t\t\t\t\t\t\tt,\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t: subRaw == null\n\t\t\t\t\t\t\t\t? ''\n\t\t\t\t\t\t\t\t: String(subRaw)\n\t\t\t\t\t\treturn { label: sub.label, value: formatted || '—' }\n\t\t\t\t\t}),\n\t\t\t\t})),\n\t\t\t})\n\t\t\tcontinue\n\t\t}\n\n\t\tconst def = registry.get(descriptor.fieldType)\n\t\tconst formatted = def?.format\n\t\t\t? def.format({ value: raw, config: {}, optionLabels: descriptor.optionLabels, locale, t })\n\t\t\t: raw == null\n\t\t\t\t? ''\n\t\t\t\t: String(raw)\n\n\t\tif (descriptor.fieldType === 'file') {\n\t\t\tconst ref =\n\t\t\t\traw && typeof raw === 'object' && 'url' in raw\n\t\t\t\t\t? (raw as { url?: string; filename?: string })\n\t\t\t\t\t: null\n\t\t\tconst url = typeof ref?.url === 'string' ? ref.url : undefined\n\t\t\tconst filename = typeof ref?.filename === 'string' ? ref.filename : (url ?? '')\n\t\t\tanswers.push({ field: descriptor.field, label: descriptor.label, value: filename, href: url })\n\t\t} else {\n\t\t\tanswers.push({\n\t\t\t\tfield: descriptor.field,\n\t\t\t\tlabel: descriptor.label,\n\t\t\t\tvalue: formatted || '—',\n\t\t\t\tmultiline: descriptor.fieldType === 'textarea',\n\t\t\t\t...(descriptor.width ? { width: descriptor.width } : {}),\n\t\t\t})\n\t\t}\n\t}\n\n\tconst consent: ConsentItem[] = rawConsent.map((entry) => ({\n\t\t...entry,\n\t\tat: formatDate(entry.at, locale),\n\t}))\n\n\tconst metaItems: MetaItem[] = [{ label: t(keys.submissionMetaLocale), value: locale }]\n\tif (meta) {\n\t\tif (meta.at)\n\t\t\tmetaItems.push({\n\t\t\t\tlabel: t(keys.submissionMetaReceivedAt),\n\t\t\t\tvalue: formatDate(meta.at, locale),\n\t\t\t})\n\t\tif (meta.ip) metaItems.push({ label: t(keys.submissionMetaIp), value: meta.ip })\n\t\tif (meta.ua) metaItems.push({ label: t(keys.submissionMetaUserAgent), value: String(meta.ua) })\n\t\tif (meta.spam) {\n\t\t\tconst captcha =\n\t\t\t\ttypeof meta.spam === 'object' && 'captcha' in meta.spam\n\t\t\t\t\t? String((meta.spam as MetaSpam).captcha)\n\t\t\t\t\t: '—'\n\t\t\tmetaItems.push({ label: t(keys.submissionMetaCaptcha), value: captcha })\n\t\t}\n\t}\n\n\tconst labels: SubmissionAnswersLabels = {\n\t\tanswers: t(keys.submissionAnswers),\n\t\tconsent: t(keys.submissionConsent),\n\t\tsubmissionDetails: t(keys.submissionDetails),\n\t\tagreed: t(keys.submissionConsentAgreed),\n\t\tdeclined: t(keys.submissionConsentDeclined),\n\t\trow: t(keys.repeaterRow),\n\t\tempty: t(keys.submissionNoAnswers),\n\t}\n\n\treturn (\n\t\t<SubmissionAnswersClient\n\t\t\tanswers={answers}\n\t\t\trepeaters={repeaters}\n\t\t\tconsent={consent}\n\t\t\tmeta={metaItems}\n\t\t\tlabels={labels}\n\t\t/>\n\t)\n}\n"],"mappings":";;;;;;;AAeA,MAAM,WAAW,cAAc,uBAAuB;AA4BtD,MAAM,cAAc,KAAa,WAA2B;CAC3D,IAAI;EACH,OAAO,IAAI,KAAK,eAAe,QAAQ;GAAE,WAAW;GAAU,WAAW;EAAQ,CAAC,EAAE,OACnF,IAAI,KAAK,GAAG,CACb;CACD,QAAQ;EACP,OAAO;CACR;AACD;;;;;AAMA,MAAa,qBAAqB,EAAE,MAAM,UAA8B;CACvE,MAAM,MAAO,QAAQ,CAAC;CACtB,MAAM,cAAc,IAAI,eAAe,CAAC;CACxC,MAAM,SAAS,IAAI,UAAU,CAAC;CAC9B,MAAM,SAAS,IAAI,UAAU,IAAI,UAAU;CAC3C,MAAM,IAAI,iBAAiB,IAAI,KAAK,CAAC;CACrC,MAAM,aAAa,IAAI,WAAW,CAAC;CACnC,MAAM,OAAO,IAAI;CAEjB,MAAM,eAAe,IAAI,IAAI,OAAO,KAAK,UAAU,CAAC,MAAM,OAAO,MAAM,KAAK,CAAC,CAAC;CAE9E,MAAM,UAAwB,CAAC;CAC/B,MAAM,YAA4B,CAAC;CAEnC,KAAK,MAAM,cAAc,aAAa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ACpC,GAAI,WAAW,QAAQ,EAAE,OAAO,WAAW,MAAM,IAAI,CAAC;EACvD,CAAC;CAEH;CAEA,MAAM,UAAyB,WAAW,KAAK,WAAW;EACzD,GAAG;EACH,IAAI,WAAW,MAAM,IAAI,MAAM;CAChC,EAAE;CAEF,MAAM,YAAwB,CAAC;EAAE,OAAO,EAAE,KAAK,oBAAoB;EAAG,OAAO;CAAO,CAAC;CACrF,IAAI,MAAM;EACT,IAAI,KAAK,IACR,UAAU,KAAK;GACd,OAAO,EAAE,KAAK,wBAAwB;GACtC,OAAO,WAAW,KAAK,IAAI,MAAM;EAClC,CAAC;EACF,IAAI,KAAK,IAAI,UAAU,KAAK;GAAE,OAAO,EAAE,KAAK,gBAAgB;GAAG,OAAO,KAAK;EAAG,CAAC;EAC/E,IAAI,KAAK,IAAI,UAAU,KAAK;GAAE,OAAO,EAAE,KAAK,uBAAuB;GAAG,OAAO,OAAO,KAAK,EAAE;EAAE,CAAC;EAC9F,IAAI,KAAK,MAAM;GACd,MAAM,UACL,OAAO,KAAK,SAAS,YAAY,aAAa,KAAK,OAChD,OAAQ,KAAK,KAAkB,OAAO,IACtC;GACJ,UAAU,KAAK;IAAE,OAAO,EAAE,KAAK,qBAAqB;IAAG,OAAO;GAAQ,CAAC;EACxE;CACD;CAYA,OACC,oBAAC,yBAAD;EACU;EACE;EACF;EACT,MAAM;EACN,QAAQ;GAfT,SAAS,EAAE,KAAK,iBAAiB;GACjC,SAAS,EAAE,KAAK,iBAAiB;GACjC,mBAAmB,EAAE,KAAK,iBAAiB;GAC3C,QAAQ,EAAE,KAAK,uBAAuB;GACtC,UAAU,EAAE,KAAK,yBAAyB;GAC1C,KAAK,EAAE,KAAK,WAAW;GACvB,OAAO,EAAE,KAAK,mBAAmB;EASnB;CACb,CAAA;AAEH"}
1
+ {"version":3,"file":"SubmissionAnswers.js","names":[],"sources":["../../src/submissions/SubmissionAnswers.tsx"],"sourcesContent":["import type { UIFieldServerProps } from 'payload'\nimport { defaultFieldDefinitions } from '../fields/builtin'\nimport { buildRegistry } from '../fields/registry'\nimport { keys } from '../translations/keys'\nimport { asFieldTranslate } from '../translations/server'\nimport type {\n\tAnswerItem,\n\tConsentItem,\n\tMetaItem,\n\tRepeaterItem,\n\tSubmissionAnswersLabels,\n} from './SubmissionAnswersClient'\nimport { SubmissionAnswersClient } from './SubmissionAnswersClient'\nimport type { SubmissionDescriptor, SubmissionValue } from './types'\n\nconst registry = buildRegistry(defaultFieldDefinitions)\n\ntype ConsentEntry = {\n\tfield: string\n\tagreed: boolean\n\t/** The consent source's name at submit time (see `ConsentProof.name`). */\n\tname?: string\n\t/** The plain-text snapshot of the wording agreed to (see `ConsentProof.statementText`). */\n\tstatementText?: string\n\tversionRef?: string\n\tat: string\n}\n\ntype MetaSpam = { captcha?: string }\n\ntype SubmissionMeta = {\n\tat?: string\n\tip?: string\n\tua?: string\n\tspam?: MetaSpam\n\t[key: string]: unknown\n}\n\ntype SubmissionDoc = {\n\tvalues?: SubmissionValue[]\n\tdescriptors?: SubmissionDescriptor[]\n\tlocale?: string\n\tconsent?: ConsentEntry[]\n\tmeta?: SubmissionMeta\n}\n\nconst formatDate = (iso: string, locale: string): string => {\n\ttry {\n\t\treturn new Intl.DateTimeFormat(locale, { dateStyle: 'medium', timeStyle: 'short' }).format(\n\t\t\tnew Date(iso)\n\t\t)\n\t} catch {\n\t\treturn iso\n\t}\n}\n\n/**\n * Server component. Formats submission data into serializable props and delegates\n * rendering to the client component which uses Payload's UI components.\n */\nexport const SubmissionAnswers = ({ data, req }: UIFieldServerProps) => {\n\tconst doc = (data ?? {}) as SubmissionDoc\n\tconst descriptors = doc.descriptors ?? []\n\tconst values = doc.values ?? []\n\tconst locale = doc.locale ?? req.locale ?? 'en'\n\tconst t = asFieldTranslate(req.i18n.t)\n\tconst rawConsent = doc.consent ?? []\n\tconst meta = doc.meta\n\n\tconst valueByField = new Map(values.map((entry) => [entry.field, entry.value]))\n\n\tconst answers: AnswerItem[] = []\n\tconst repeaters: RepeaterItem[] = []\n\n\tfor (const descriptor of descriptors) {\n\t\tconst raw = valueByField.get(descriptor.field)\n\n\t\tif (descriptor.fieldType === 'repeater') {\n\t\t\tconst rows = Array.isArray(raw) ? (raw as Array<Record<string, unknown>>) : []\n\t\t\tconst subDescs = descriptor.subFieldDescriptors ?? []\n\t\t\trepeaters.push({\n\t\t\t\tfield: descriptor.field,\n\t\t\t\tlabel: descriptor.label,\n\t\t\t\trows: rows.map((row, rowIndex) => ({\n\t\t\t\t\tid: String(rowIndex),\n\t\t\t\t\tsubFields: subDescs.map((sub) => {\n\t\t\t\t\t\tconst subDef = registry.get(sub.fieldType)\n\t\t\t\t\t\tconst subRaw = row[sub.field]\n\t\t\t\t\t\tconst formatted = subDef?.format\n\t\t\t\t\t\t\t? subDef.format({\n\t\t\t\t\t\t\t\t\tvalue: subRaw,\n\t\t\t\t\t\t\t\t\tconfig: {},\n\t\t\t\t\t\t\t\t\toptionLabels: sub.optionLabels,\n\t\t\t\t\t\t\t\t\tlocale,\n\t\t\t\t\t\t\t\t\tt,\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t: subRaw == null\n\t\t\t\t\t\t\t\t? ''\n\t\t\t\t\t\t\t\t: String(subRaw)\n\t\t\t\t\t\treturn { label: sub.label, value: formatted || '—' }\n\t\t\t\t\t}),\n\t\t\t\t})),\n\t\t\t})\n\t\t\tcontinue\n\t\t}\n\n\t\tconst def = registry.get(descriptor.fieldType)\n\t\tconst formatted = def?.format\n\t\t\t? def.format({ value: raw, config: {}, optionLabels: descriptor.optionLabels, locale, t })\n\t\t\t: raw == null\n\t\t\t\t? ''\n\t\t\t\t: String(raw)\n\n\t\tif (descriptor.fieldType === 'file') {\n\t\t\tconst ref =\n\t\t\t\traw && typeof raw === 'object' && 'url' in raw\n\t\t\t\t\t? (raw as { url?: string; filename?: string })\n\t\t\t\t\t: null\n\t\t\tconst url = typeof ref?.url === 'string' ? ref.url : undefined\n\t\t\tconst filename = typeof ref?.filename === 'string' ? ref.filename : (url ?? '')\n\t\t\tanswers.push({ field: descriptor.field, label: descriptor.label, value: filename, href: url })\n\t\t} else {\n\t\t\tanswers.push({\n\t\t\t\tfield: descriptor.field,\n\t\t\t\tlabel: descriptor.label,\n\t\t\t\tvalue: formatted || '—',\n\t\t\t\tmultiline: descriptor.fieldType === 'textarea',\n\t\t\t\t...(descriptor.width ? { width: descriptor.width } : {}),\n\t\t\t})\n\t\t}\n\t}\n\n\tconst consent: ConsentItem[] = rawConsent.map((entry) => ({\n\t\t...entry,\n\t\tat: formatDate(entry.at, locale),\n\t}))\n\n\tconst metaItems: MetaItem[] = [{ label: t(keys.submissionMetaLocale), value: locale }]\n\tif (meta) {\n\t\tif (meta.at)\n\t\t\tmetaItems.push({\n\t\t\t\tlabel: t(keys.submissionMetaReceivedAt),\n\t\t\t\tvalue: formatDate(meta.at, locale),\n\t\t\t})\n\t\tif (meta.ip) metaItems.push({ label: t(keys.submissionMetaIp), value: meta.ip })\n\t\tif (meta.ua) metaItems.push({ label: t(keys.submissionMetaUserAgent), value: String(meta.ua) })\n\t\tif (meta.spam) {\n\t\t\tconst captcha =\n\t\t\t\ttypeof meta.spam === 'object' && 'captcha' in meta.spam\n\t\t\t\t\t? String((meta.spam as MetaSpam).captcha)\n\t\t\t\t\t: '—'\n\t\t\tmetaItems.push({ label: t(keys.submissionMetaCaptcha), value: captcha })\n\t\t}\n\t}\n\n\tconst labels: SubmissionAnswersLabels = {\n\t\tanswers: t(keys.submissionAnswers),\n\t\tconsent: t(keys.submissionConsent),\n\t\tsubmissionDetails: t(keys.submissionDetails),\n\t\tagreed: t(keys.submissionConsentAgreed),\n\t\tdeclined: t(keys.submissionConsentDeclined),\n\t\trow: t(keys.repeaterRow),\n\t\tempty: t(keys.submissionNoAnswers),\n\t}\n\n\treturn (\n\t\t<SubmissionAnswersClient\n\t\t\tanswers={answers}\n\t\t\trepeaters={repeaters}\n\t\t\tconsent={consent}\n\t\t\tmeta={metaItems}\n\t\t\tlab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I,KAAK,IAAI,UAAU,KAAK;GAAE,OAAO,EAAE,KAAK,uBAAuB;GAAG,OAAO,OAAO,KAAK,EAAE;EAAE,CAAC;EAC9F,IAAI,KAAK,MAAM;GACd,MAAM,UACL,OAAO,KAAK,SAAS,YAAY,aAAa,KAAK,OAChD,OAAQ,KAAK,KAAkB,OAAO,IACtC;GACJ,UAAU,KAAK;IAAE,OAAO,EAAE,KAAK,qBAAqB;IAAG,OAAO;GAAQ,CAAC;EACxE;CACD;CAYA,OACC,oBAAC,yBAAD;EACU;EACE;EACF;EACT,MAAM;EACN,QAAQ;GAfT,SAAS,EAAE,KAAK,iBAAiB;GACjC,SAAS,EAAE,KAAK,iBAAiB;GACjC,mBAAmB,EAAE,KAAK,iBAAiB;GAC3C,QAAQ,EAAE,KAAK,uBAAuB;GACtC,UAAU,EAAE,KAAK,yBAAyB;GAC1C,KAAK,EAAE,KAAK,WAAW;GACvB,OAAO,EAAE,KAAK,mBAAmB;EASnB;CACb,CAAA;AAEH"}
@@ -120,35 +120,42 @@ const SubmissionAnswersClient = ({ answers, repeaters, consent, meta, labels })
120
120
  flexDirection: "column",
121
121
  gap: "4px"
122
122
  },
123
- children: [/* @__PURE__ */ jsxs("div", {
124
- style: {
125
- display: "flex",
126
- alignItems: "center",
127
- gap: "8px",
128
- flexWrap: "wrap"
129
- },
130
- children: [/* @__PURE__ */ jsx(Pill, {
131
- pillStyle: entry.agreed ? "success" : "error",
132
- size: "small",
133
- rounded: true,
134
- children: entry.agreed ? labels.agreed : labels.declined
135
- }), entry.ref ? /* @__PURE__ */ jsxs("a", {
136
- href: entry.ref,
137
- target: "_blank",
138
- rel: "noreferrer",
123
+ children: [
124
+ /* @__PURE__ */ jsxs("div", {
125
+ style: {
126
+ display: "flex",
127
+ alignItems: "center",
128
+ gap: "8px",
129
+ flexWrap: "wrap"
130
+ },
131
+ children: [/* @__PURE__ */ jsx(Pill, {
132
+ pillStyle: entry.agreed ? "success" : "error",
133
+ size: "small",
134
+ rounded: true,
135
+ children: entry.agreed ? labels.agreed : labels.declined
136
+ }), entry.name ? /* @__PURE__ */ jsxs("span", {
137
+ style: {
138
+ fontSize: "0.8rem",
139
+ color: "var(--theme-text)"
140
+ },
141
+ children: [entry.name, entry.versionRef ? ` (v${entry.versionRef})` : ""]
142
+ }) : null]
143
+ }),
144
+ entry.statementText ? /* @__PURE__ */ jsx("span", {
139
145
  style: {
140
146
  fontSize: "0.8rem",
141
- color: "var(--theme-text)"
147
+ color: "var(--theme-elevation-600)"
142
148
  },
143
- children: [entry.ref, entry.versionRef ? ` (v${entry.versionRef})` : ""]
144
- }) : null]
145
- }), /* @__PURE__ */ jsx("span", {
146
- style: {
147
- fontSize: "0.75rem",
148
- color: "var(--theme-elevation-500)"
149
- },
150
- children: entry.at
151
- })]
149
+ children: entry.statementText
150
+ }) : null,
151
+ /* @__PURE__ */ jsx("span", {
152
+ style: {
153
+ fontSize: "0.75rem",
154
+ color: "var(--theme-elevation-500)"
155
+ },
156
+ children: entry.at
157
+ })
158
+ ]
152
159
  })]
153
160
  }, entry.field))
154
161
  })] }),
@@ -1 +1 @@
1
- {"version":3,"file":"SubmissionAnswersClient.js","names":[],"sources":["../../src/submissions/SubmissionAnswersClient.tsx"],"sourcesContent":["'use client'\n\nimport { FieldLabel, Pill, TextInput } from '@payloadcms/ui'\nimport type { ChangeEvent } from 'react'\nimport type { SubmissionWidth } from './types'\n\nexport type AnswerItem = {\n\tfield: string\n\tlabel: string\n\tvalue: string\n\thref?: string\n\tmultiline?: boolean\n\twidth?: SubmissionWidth\n}\n\nexport type RepeaterRow = {\n\tid: string\n\tsubFields: Array<{ label: string; value: string }>\n}\n\nexport type RepeaterItem = {\n\tfield: string\n\tlabel: string\n\trows: RepeaterRow[]\n}\n\nexport type ConsentItem = {\n\tfield: string\n\tagreed: boolean\n\tref?: string\n\tversionRef?: string\n\tat: string\n}\n\nexport type MetaItem = {\n\tlabel: string\n\tvalue: string\n}\n\nexport type SubmissionAnswersLabels = {\n\tanswers: string\n\tconsent: string\n\tsubmissionDetails: string\n\tagreed: string\n\tdeclined: string\n\t/** Row heading template containing `{n}`, the 1-based row number. */\n\trow: string\n\tempty: string\n}\n\ntype Props = {\n\tanswers: AnswerItem[]\n\trepeaters: RepeaterItem[]\n\tconsent: ConsentItem[]\n\tmeta: MetaItem[]\n\tlabels: SubmissionAnswersLabels\n}\n\nconst noop = (_e: ChangeEvent<HTMLInputElement>) => {}\n\n/** Horizontal gutter between fields sharing a row; also trimmed from each fractional basis so widths wrap cleanly rather than overflow. */\nconst FIELD_GAP = 'calc(var(--base, 20px) / 2)'\n\nconst BASIS: Record<SubmissionWidth, string> = {\n\tfull: '100%',\n\thalf: '50%',\n\tthird: '33.333%',\n\ttwoThirds: '66.666%',\n}\n\n/**\n * Flex sizing for one answer field. Full fields (and file links / repeaters) claim a whole row;\n * fractional ones sit side by side, their basis trimmed by the gutter and floored by `min-width`\n * so a half or third never collapses on a narrow admin panel (it wraps to its own row instead).\n */\nconst widthStyle = (width?: SubmissionWidth): React.CSSProperties => {\n\tconst basis = BASIS[width ?? 'full']\n\treturn basis === '100%'\n\t\t? { flex: '1 1 100%' }\n\t\t: { flex: `0 1 calc(${basis} - ${FIELD_GAP})`, minWidth: 'min(100%, 12rem)' }\n}\n\nconst answersGrid: React.CSSProperties = {\n\tdisplay: 'flex',\n\tflexWrap: 'wrap',\n\tcolumnGap: FIELD_GAP,\n}\n\nconst fullWidth: React.CSSProperties = { flex: '1 1 100%' }\n\nconst rowHeading: React.CSSProperties = {\n\tfontSize: '0.75rem',\n\tfontWeight: 600,\n\tcolor: 'var(--theme-elevation-500)',\n\tmargin: '0 0 4px',\n}\n\nconst linkStyle: React.CSSProperties = {\n\tdisplay: 'block',\n\tpadding: '8px 0',\n\tcolor: 'var(--theme-text)',\n\ttextDecoration: 'underline',\n}\n\nexport const SubmissionAnswersClient = ({ answers, repeaters, consent, meta, labels }: Props) => {\n\tconst hasContent =\n\t\tanswers.length > 0 || repeaters.length > 0 || consent.length > 0 || meta.length > 0\n\n\tif (!hasContent) {\n\t\treturn <p style={{ color: 'var(--theme-elevation-500)' }}>{labels.empty}</p>\n\t}\n\n\treturn (\n\t\t<div className=\"field-type\" style={{ display: 'flex', flexDirection: 'column', gap: '32px' }}>\n\t\t\t{(answers.length > 0 || repeaters.length > 0) && (\n\t\t\t\t<section>\n\t\t\t\t\t<FieldLabel label={labels.answers} />\n\t\t\t\t\t<div className=\"render-fields\" style={answersGrid}>\n\t\t\t\t\t\t{answers.map(({ field, label, value, href, width }) =>\n\t\t\t\t\t\t\thref ? (\n\t\t\t\t\t\t\t\t<div key={field} className=\"field-type\" style={fullWidth}>\n\t\t\t\t\t\t\t\t\t<FieldLabel label={label} />\n\t\t\t\t\t\t\t\t\t<a href={href} target=\"_blank\" rel=\"noreferrer\" style={linkStyle}>\n\t\t\t\t\t\t\t\t\t\t{value}\n\t\t\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t<TextInput\n\t\t\t\t\t\t\t\t\tkey={field}\n\t\t\t\t\t\t\t\t\tpath={`sa-${field}`}\n\t\t\t\t\t\t\t\t\tlabel={label}\n\t\t\t\t\t\t\t\t\tvalue={value}\n\t\t\t\t\t\t\t\t\treadOnly\n\t\t\t\t\t\t\t\t\tonChange={noop}\n\t\t\t\t\t\t\t\t\tstyle={widthStyle(width)}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t)}\n\n\t\t\t\t\t\t{repeaters.map(({ field, label, rows }) => (\n\t\t\t\t\t\t\t<div key={field} className=\"field-type\" style={fullWidth}>\n\t\t\t\t\t\t\t\t<FieldLabel label={label} />\n\t\t\t\t\t\t\t\t{rows.length === 0 ? (\n\t\t\t\t\t\t\t\t\t<TextInput\n\t\t\t\t\t\t\t\t\t\tpath={`sa-${field}-empty`}\n\t\t\t\t\t\t\t\t\t\tlabel=\"\"\n\t\t\t\t\t\t\t\t\t\tvalue=\"—\"\n\t\t\t\t\t\t\t\t\t\treadOnly\n\t\t\t\t\t\t\t\t\t\tonChange={noop}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t\t\t\t\tdisplay: 'flex',\n\t\t\t\t\t\t\t\t\t\t\tflexDirection: 'column',\n\t\t\t\t\t\t\t\t\t\t\tgap: '8px',\n\t\t\t\t\t\t\t\t\t\t\tmarginTop: '4px',\n\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{rows.map((row) => (\n\t\t\t\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\t\t\t\tkey={row.id}\n\t\t\t\t\t\t\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t\t\t\t\t\t\tborder: '1px solid var(--theme-elevation-150)',\n\t\t\t\t\t\t\t\t\t\t\t\t\tborderRadius: '4px',\n\t\t\t\t\t\t\t\t\t\t\t\t\tpadding: '4px 12px 0',\n\t\t\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t<p style={rowHeading}>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{labels.row.replace('{n}', String(Number(row.id) + 1))}\n\t\t\t\t\t\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t\t\t\t\t\t\t{row.subFields.map((subField) => (\n\t\t\t\t\t\t\t\t\t\t\t\t\t<TextInput\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tkey={subField.label}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tpath={`sa-${field}-${row.id}-${subField.label}`}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tlabel={subField.label}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tvalue={subField.value}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\treadOnly\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tonChange={noop}\n\t\t\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t))}\n\t\t\t\t\t</div>\n\t\t\t\t</section>\n\t\t\t)}\n\n\t\t\t{consent.length > 0 && (\n\t\t\t\t<section>\n\t\t\t\t\t<FieldLabel label={labels.consent} />\n\t\t\t\t\t<div className=\"render-fields\">\n\t\t\t\t\t\t{consent.map((entry) => (\n\t\t\t\t\t\t\t<div key={entry.field} className=\"field-type\">\n\t\t\t\t\t\t\t\t<FieldLabel label={entry.field} />\n\t\t\t\t\t\t\t\t<div style={{ display: 'flex', flexDirection: 'column', gap: '4px' }}>\n\t\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\t\tstyle={{ display: 'flex', alignItems: 'center', gap: '8px', flexWrap: 'wrap' }}\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<Pill pillStyle={entry.agreed ? 'success' : 'error'} size=\"small\" rounded>\n\t\t\t\t\t\t\t\t\t\t\t{entry.agreed ? labels.agreed : labels.declined}\n\t\t\t\t\t\t\t\t\t\t</Pill>\n\t\t\t\t\t\t\t\t\t\t{entry.ref ? (\n\t\t\t\t\t\t\t\t\t\t\t<a\n\t\t\t\t\t\t\t\t\t\t\t\thref={entry.ref}\n\t\t\t\t\t\t\t\t\t\t\t\ttarget=\"_blank\"\n\t\t\t\t\t\t\t\t\t\t\t\trel=\"noreferrer\"\n\t\t\t\t\t\t\t\t\t\t\t\tstyle={{ fontSize: '0.8rem', color: 'var(--theme-text)' }}\n\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t{entry.ref}\n\t\t\t\t\t\t\t\t\t\t\t\t{entry.versionRef ? ` (v${entry.versionRef})` : ''}\n\t\t\t\t\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t<span style={{ fontSize: '0.75rem', color: 'var(--theme-elevation-500)' }}>\n\t\t\t\t\t\t\t\t\t\t{entry.at}\n\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t))}\n\t\t\t\t\t</div>\n\t\t\t\t</section>\n\t\t\t)}\n\n\t\t\t{meta.length > 0 && (\n\t\t\t\t<section>\n\t\t\t\t\t<FieldLabel label={labels.submissionDetails} />\n\t\t\t\t\t<div className=\"render-fields\">\n\t\t\t\t\t\t{meta.map((item) => (\n\t\t\t\t\t\t\t<TextInput\n\t\t\t\t\t\t\t\tkey={item.label}\n\t\t\t\t\t\t\t\tpath={`sa-meta-${item.label}`}\n\t\t\t\t\t\t\t\tlabel={item.label}\n\t\t\t\t\t\t\t\tvalue={item.value}\n\t\t\t\t\t\t\t\treadOnly\n\t\t\t\t\t\t\t\tonChange={noop}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t))}\n\t\t\t\t\t</div>\n\t\t\t\t</section>\n\t\t\t)}\n\t\t</div>\n\t)\n}\n"],"mappings":";;;;AA0DA,MAAM,QAAQ,OAAsC,CAAC;;AAGrD,MAAM,YAAY;AAElB,MAAM,QAAyC;CAC9C,MAAM;CACN,MAAM;CACN,OAAO;CACP,WAAW;AACZ;;;;;;AAOA,MAAM,cAAc,UAAiD;CACpE,MAAM,QAAQ,MAAM,SAAS;CAC7B,OAAO,UAAU,SACd,EAAE,MAAM,WAAW,IACnB;EAAE,MAAM,YAAY,MAAM,KAAK,UAAU;EAAI,UAAU;CAAmB;AAC9E;AAEA,MAAM,cAAmC;CACxC,SAAS;CACT,UAAU;C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AO;SAAE,UAAU;SAAU,OAAO;QAAoB;kBAJzD,CAME,MAAM,KACN,MAAM,aAAa,MAAM,MAAM,WAAW,KAAK,EAC9C;YACA,IACA;UACL,oBAAC,QAAD;OAAM,OAAO;QAAE,UAAU;QAAW,OAAO;OAA6B;iBACtE,MAAM;MACF,CAAA,CACF;OACD;OAzBK,MAAM,KAyBX,CACL;GACG,CAAA,CACG,EAAA,CAAA;GAGT,KAAK,SAAS,KACd,qBAAC,WAAD,EAAA,UAAA,CACC,oBAAC,YAAD,EAAY,OAAO,OAAO,kBAAoB,CAAA,GAC9C,oBAAC,OAAD;IAAK,WAAU;cACb,KAAK,KAAK,SACV,oBAAC,WAAD;KAEC,MAAM,WAAW,KAAK;KACtB,OAAO,KAAK;KACZ,OAAO,KAAK;KACZ,UAAA;KACA,UAAU;IACV,GANK,KAAK,KAMV,CACD;GACG,CAAA,CACG,EAAA,CAAA;EAEN;;AAEP"}
1
+ {"version":3,"file":"SubmissionAnswersClient.js","names":[],"sources":["../../src/submissions/SubmissionAnswersClient.tsx"],"sourcesContent":["'use client'\n\nimport { FieldLabel, Pill, TextInput } from '@payloadcms/ui'\nimport type { ChangeEvent } from 'react'\nimport type { SubmissionWidth } from './types'\n\nexport type AnswerItem = {\n\tfield: string\n\tlabel: string\n\tvalue: string\n\thref?: string\n\tmultiline?: boolean\n\twidth?: SubmissionWidth\n}\n\nexport type RepeaterRow = {\n\tid: string\n\tsubFields: Array<{ label: string; value: string }>\n}\n\nexport type RepeaterItem = {\n\tfield: string\n\tlabel: string\n\trows: RepeaterRow[]\n}\n\nexport type ConsentItem = {\n\tfield: string\n\tagreed: boolean\n\t/** The consent source's name at submit time (see `ConsentProof.name`). */\n\tname?: string\n\t/** The plain-text snapshot of the wording agreed to (see `ConsentProof.statementText`). */\n\tstatementText?: string\n\tversionRef?: string\n\tat: string\n}\n\nexport type MetaItem = {\n\tlabel: string\n\tvalue: string\n}\n\nexport type SubmissionAnswersLabels = {\n\tanswers: string\n\tconsent: string\n\tsubmissionDetails: string\n\tagreed: string\n\tdeclined: string\n\t/** Row heading template containing `{n}`, the 1-based row number. */\n\trow: string\n\tempty: string\n}\n\ntype Props = {\n\tanswers: AnswerItem[]\n\trepeaters: RepeaterItem[]\n\tconsent: ConsentItem[]\n\tmeta: MetaItem[]\n\tlabels: SubmissionAnswersLabels\n}\n\nconst noop = (_e: ChangeEvent<HTMLInputElement>) => {}\n\n/** Horizontal gutter between fields sharing a row; also trimmed from each fractional basis so widths wrap cleanly rather than overflow. */\nconst FIELD_GAP = 'calc(var(--base, 20px) / 2)'\n\nconst BASIS: Record<SubmissionWidth, string> = {\n\tfull: '100%',\n\thalf: '50%',\n\tthird: '33.333%',\n\ttwoThirds: '66.666%',\n}\n\n/**\n * Flex sizing for one answer field. Full fields (and file links / repeaters) claim a whole row;\n * fractional ones sit side by side, their basis trimmed by the gutter and floored by `min-width`\n * so a half or third never collapses on a narrow admin panel (it wraps to its own row instead).\n */\nconst widthStyle = (width?: SubmissionWidth): React.CSSProperties => {\n\tconst basis = BASIS[width ?? 'full']\n\treturn basis === '100%'\n\t\t? { flex: '1 1 100%' }\n\t\t: { flex: `0 1 calc(${basis} - ${FIELD_GAP})`, minWidth: 'min(100%, 12rem)' }\n}\n\nconst answersGrid: React.CSSProperties = {\n\tdisplay: 'flex',\n\tflexWrap: 'wrap',\n\tcolumnGap: FIELD_GAP,\n}\n\nconst fullWidth: React.CSSProperties = { flex: '1 1 100%' }\n\nconst rowHeading: React.CSSProperties = {\n\tfontSize: '0.75rem',\n\tfontWeight: 600,\n\tcolor: 'var(--theme-elevation-500)',\n\tmargin: '0 0 4px',\n}\n\nconst linkStyle: React.CSSProperties = {\n\tdisplay: 'block',\n\tpadding: '8px 0',\n\tcolor: 'var(--theme-text)',\n\ttextDecoration: 'underline',\n}\n\nexport const SubmissionAnswersClient = ({ answers, repeaters, consent, meta, labels }: Props) => {\n\tconst hasContent =\n\t\tanswers.length > 0 || repeaters.length > 0 || consent.length > 0 || meta.length > 0\n\n\tif (!hasContent) {\n\t\treturn <p style={{ color: 'var(--theme-elevation-500)' }}>{labels.empty}</p>\n\t}\n\n\treturn (\n\t\t<div className=\"field-type\" style={{ display: 'flex', flexDirection: 'column', gap: '32px' }}>\n\t\t\t{(answers.length > 0 || repeaters.length > 0) && (\n\t\t\t\t<section>\n\t\t\t\t\t<FieldLabel label={labels.answers} />\n\t\t\t\t\t<div className=\"render-fields\" style={answersGrid}>\n\t\t\t\t\t\t{answers.map(({ field, label, value, href, width }) =>\n\t\t\t\t\t\t\thref ? (\n\t\t\t\t\t\t\t\t<div key={field} className=\"field-type\" style={fullWidth}>\n\t\t\t\t\t\t\t\t\t<FieldLabel label={label} />\n\t\t\t\t\t\t\t\t\t<a href={href} target=\"_blank\" rel=\"noreferrer\" style={linkStyle}>\n\t\t\t\t\t\t\t\t\t\t{value}\n\t\t\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t<TextInput\n\t\t\t\t\t\t\t\t\tkey={field}\n\t\t\t\t\t\t\t\t\tpath={`sa-${field}`}\n\t\t\t\t\t\t\t\t\tlabel={label}\n\t\t\t\t\t\t\t\t\tvalue={value}\n\t\t\t\t\t\t\t\t\treadOnly\n\t\t\t\t\t\t\t\t\tonChange={noop}\n\t\t\t\t\t\t\t\t\tstyle={widthStyle(width)}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t)}\n\n\t\t\t\t\t\t{repeaters.map(({ field, label, rows }) => (\n\t\t\t\t\t\t\t<div key={field} className=\"field-type\" style={fullWidth}>\n\t\t\t\t\t\t\t\t<FieldLabel label={label} />\n\t\t\t\t\t\t\t\t{rows.length === 0 ? (\n\t\t\t\t\t\t\t\t\t<TextInput\n\t\t\t\t\t\t\t\t\t\tpath={`sa-${field}-empty`}\n\t\t\t\t\t\t\t\t\t\tlabel=\"\"\n\t\t\t\t\t\t\t\t\t\tvalue=\"—\"\n\t\t\t\t\t\t\t\t\t\treadOnly\n\t\t\t\t\t\t\t\t\t\tonChange={noop}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t\t\t\t\tdisplay: 'flex',\n\t\t\t\t\t\t\t\t\t\t\tflexDirection: 'column',\n\t\t\t\t\t\t\t\t\t\t\tgap: '8px',\n\t\t\t\t\t\t\t\t\t\t\tmarginTop: '4px',\n\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{rows.map((row) => (\n\t\t\t\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\t\t\t\tkey={row.id}\n\t\t\t\t\t\t\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t\t\t\t\t\t\tborder: '1px solid var(--theme-elevation-150)',\n\t\t\t\t\t\t\t\t\t\t\t\t\tborderRadius: '4px',\n\t\t\t\t\t\t\t\t\t\t\t\t\tpadding: '4px 12px 0',\n\t\t\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t<p style={rowHeading}>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{labels.row.replace('{n}', String(Number(row.id) + 1))}\n\t\t\t\t\t\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t\t\t\t\t\t\t{row.subFields.map((subField) => (\n\t\t\t\t\t\t\t\t\t\t\t\t\t<TextInput\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tkey={subField.label}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tpath={`sa-${field}-${row.id}-${subField.label}`}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tlabel={subField.label}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tvalue={subField.value}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\treadOnly\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tonChange={noop}\n\t\t\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t))}\n\t\t\t\t\t</div>\n\t\t\t\t</section>\n\t\t\t)}\n\n\t\t\t{consent.length > 0 && (\n\t\t\t\t<section>\n\t\t\t\t\t<FieldLabel label={labels.consent} />\n\t\t\t\t\t<div className=\"render-fields\">\n\t\t\t\t\t\t{consent.map((entry) => (\n\t\t\t\t\t\t\t<div key={entry.field} className=\"field-type\">\n\t\t\t\t\t\t\t\t<FieldLabel label={entry.field} />\n\t\t\t\t\t\t\t\t<div style={{ display: 'flex', flexDirection: 'column', gap: '4px' }}>\n\t\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\t\tstyle={{ display: 'flex', alignItems: 'center', gap: '8px', flexWrap: 'wrap' }}\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<Pill pillStyle={entry.agreed ? 'success' : 'error'} size=\"small\" rounded>\n\t\t\t\t\t\t\t\t\t\t\t{entry.agreed ? labels.agreed : labels.declined}\n\t\t\t\t\t\t\t\t\t\t</Pill>\n\t\t\t\t\t\t\t\t\t\t{entry.name ? (\n\t\t\t\t\t\t\t\t\t\t\t<span style={{ fontSize: '0.8rem', color: 'var(--theme-text)' }}>\n\t\t\t\t\t\t\t\t\t\t\t\t{entry.name}\n\t\t\t\t\t\t\t\t\t\t\t\t{entry.versionRef ? ` (v${entry.versionRef})` : ''}\n\t\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t{entry.statementText ? (\n\t\t\t\t\t\t\t\t\t\t<span style={{ fontSize: '0.8rem', color: 'var(--theme-elevation-600)' }}>\n\t\t\t\t\t\t\t\t\t\t\t{entry.statementText}\n\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t\t\t\t<span style={{ fontSize: '0.75rem', color: 'var(--theme-elevation-500)' }}>\n\t\t\t\t\t\t\t\t\t\t{entry.at}\n\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t))}\n\t\t\t\t\t</div>\n\t\t\t\t</section>\n\t\t\t)}\n\n\t\t\t{meta.length > 0 && (\n\t\t\t\t<section>\n\t\t\t\t\t<FieldLabel label={labels.submissionDetails} />\n\t\t\t\t\t<div className=\"render-fields\">\n\t\t\t\t\t\t{meta.map((item) => (\n\t\t\t\t\t\t\t<TextInput\n\t\t\t\t\t\t\t\tkey={item.label}\n\t\t\t\t\t\t\t\tpath={`sa-meta-${item.label}`}\n\t\t\t\t\t\t\t\tlabel={item.label}\n\t\t\t\t\t\t\t\tvalue={item.value}\n\t\t\t\t\t\t\t\treadOnly\n\t\t\t\t\t\t\t\tonChange={noop}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t))}\n\t\t\t\t\t</div>\n\t\t\t\t</section>\n\t\t\t)}\n\t\t</div>\n\t)\n}\n"],"mappings":";;;;AA6DA,MAAM,QAAQ,OAAsC,CAAC;;AAGrD,MAAM,YAAY;AAElB,MAAM,QAAyC;CAC9C,MAAM;CACN,MAAM;CACN,OAAO;CACP,WAAW;AACZ;;;;;;AAOA,MAAM,cAAc,UAAiD;CACpE,MAAM,QAAQ,MAAM,SAAS;CAC7B,OAAO,UAAU,SACd,EAAE,MAAM,WAAW,IACnB;EAAE,MAAM,YAAY,MAAM,KAAK,UAAU;EAAI,UAAU;CAAmB;AAC9E;AAEA,MAAM,cAAmC;CACxC,SAAS;CACT,UAAU;C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