@foundrykit/form-plugin 0.0.0-stage → 1.16.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +486 -2
- package/dist/assets/flags/AD.svg +8 -0
- package/dist/assets/flags/AE.svg +8 -0
- package/dist/assets/flags/AF.svg +7 -0
- package/dist/assets/flags/AG.svg +8 -0
- package/dist/assets/flags/AI.svg +17 -0
- package/dist/assets/flags/AL.svg +4 -0
- package/dist/assets/flags/AM.svg +5 -0
- package/dist/assets/flags/AO.svg +7 -0
- package/dist/assets/flags/AQ.svg +4 -0
- package/dist/assets/flags/AR.svg +6 -0
- package/dist/assets/flags/AS.svg +7 -0
- package/dist/assets/flags/AT.svg +5 -0
- package/dist/assets/flags/AU.svg +20 -0
- package/dist/assets/flags/AW.svg +7 -0
- package/dist/assets/flags/AX.svg +5 -0
- package/dist/assets/flags/AZ.svg +7 -0
- package/dist/assets/flags/BA.svg +16 -0
- package/dist/assets/flags/BB.svg +6 -0
- package/dist/assets/flags/BD.svg +4 -0
- package/dist/assets/flags/BE.svg +5 -0
- package/dist/assets/flags/BF.svg +5 -0
- package/dist/assets/flags/BG.svg +5 -0
- package/dist/assets/flags/BH.svg +4 -0
- package/dist/assets/flags/BI.svg +11 -0
- package/dist/assets/flags/BJ.svg +5 -0
- package/dist/assets/flags/BM.svg +27 -0
- package/dist/assets/flags/BN.svg +11 -0
- package/dist/assets/flags/BO.svg +5 -0
- package/dist/assets/flags/BQ-SA.svg +6 -0
- package/dist/assets/flags/BQ-SE.svg +11 -0
- package/dist/assets/flags/BQ.svg +7 -0
- package/dist/assets/flags/BR.svg +7 -0
- package/dist/assets/flags/BS.svg +6 -0
- package/dist/assets/flags/BT.svg +5 -0
- package/dist/assets/flags/BW.svg +6 -0
- package/dist/assets/flags/BY.svg +13 -0
- package/dist/assets/flags/BZ.svg +10 -0
- package/dist/assets/flags/CA-BC.svg +26 -0
- package/dist/assets/flags/CA.svg +6 -0
- package/dist/assets/flags/CC.svg +12 -0
- package/dist/assets/flags/CD.svg +6 -0
- package/dist/assets/flags/CF.svg +10 -0
- package/dist/assets/flags/CG.svg +5 -0
- package/dist/assets/flags/CH.svg +6 -0
- package/dist/assets/flags/CI.svg +5 -0
- package/dist/assets/flags/CK.svg +20 -0
- package/dist/assets/flags/CL-EI.svg +4 -0
- package/dist/assets/flags/CL.svg +6 -0
- package/dist/assets/flags/CM.svg +6 -0
- package/dist/assets/flags/CN.svg +8 -0
- package/dist/assets/flags/CO.svg +5 -0
- package/dist/assets/flags/CR.svg +6 -0
- package/dist/assets/flags/CU.svg +8 -0
- package/dist/assets/flags/CV.svg +16 -0
- package/dist/assets/flags/CW.svg +6 -0
- package/dist/assets/flags/CX.svg +12 -0
- package/dist/assets/flags/CY.svg +5 -0
- package/dist/assets/flags/CZ.svg +5 -0
- package/dist/assets/flags/DE.svg +5 -0
- package/dist/assets/flags/DJ.svg +6 -0
- package/dist/assets/flags/DK.svg +4 -0
- package/dist/assets/flags/DM.svg +21 -0
- package/dist/assets/flags/DO.svg +10 -0
- package/dist/assets/flags/DZ.svg +6 -0
- package/dist/assets/flags/EA-ML.svg +18 -0
- package/dist/assets/flags/EC-W.svg +5 -0
- package/dist/assets/flags/EC.svg +8 -0
- package/dist/assets/flags/EE.svg +5 -0
- package/dist/assets/flags/EG.svg +6 -0
- package/dist/assets/flags/EH.svg +8 -0
- package/dist/assets/flags/ER.svg +6 -0
- package/dist/assets/flags/ES-BV.svg +5 -0
- package/dist/assets/flags/ES-CE.svg +22 -0
- package/dist/assets/flags/ES-IB.svg +10 -0
- package/dist/assets/flags/ES.svg +7 -0
- package/dist/assets/flags/ET.svg +8 -0
- package/dist/assets/flags/EU.svg +11 -0
- package/dist/assets/flags/FI.svg +4 -0
- package/dist/assets/flags/FJ.svg +13 -0
- package/dist/assets/flags/FK.svg +17 -0
- package/dist/assets/flags/FL-BR.svg +11 -0
- package/dist/assets/flags/FM.svg +7 -0
- package/dist/assets/flags/FO.svg +5 -0
- package/dist/assets/flags/FR-COR.svg +5 -0
- package/dist/assets/flags/FR.svg +5 -0
- package/dist/assets/flags/GA.svg +5 -0
- package/dist/assets/flags/GB-ORK.svg +5 -0
- package/dist/assets/flags/GB-SCT.svg +7 -0
- package/dist/assets/flags/GB-WLS.svg +7 -0
- package/dist/assets/flags/GB.svg +22 -0
- package/dist/assets/flags/GD.svg +17 -0
- package/dist/assets/flags/GE-AB.svg +16 -0
- package/dist/assets/flags/GE.svg +8 -0
- package/dist/assets/flags/GG.svg +5 -0
- package/dist/assets/flags/GH.svg +6 -0
- package/dist/assets/flags/GI.svg +6 -0
- package/dist/assets/flags/GL.svg +6 -0
- package/dist/assets/flags/GM.svg +6 -0
- package/dist/assets/flags/GN.svg +5 -0
- package/dist/assets/flags/GQ.svg +9 -0
- package/dist/assets/flags/GR.svg +10 -0
- package/dist/assets/flags/GT.svg +7 -0
- package/dist/assets/flags/GU.svg +10 -0
- package/dist/assets/flags/GW.svg +6 -0
- package/dist/assets/flags/GY.svg +8 -0
- package/dist/assets/flags/HK.svg +8 -0
- package/dist/assets/flags/HN.svg +10 -0
- package/dist/assets/flags/HR.svg +24 -0
- package/dist/assets/flags/HT.svg +10 -0
- package/dist/assets/flags/HU.svg +5 -0
- package/dist/assets/flags/IC.svg +5 -0
- package/dist/assets/flags/ID.svg +4 -0
- package/dist/assets/flags/IE.svg +5 -0
- package/dist/assets/flags/IL.svg +6 -0
- package/dist/assets/flags/IM.svg +4 -0
- package/dist/assets/flags/IN.svg +6 -0
- package/dist/assets/flags/IO.svg +35 -0
- package/dist/assets/flags/IQ.svg +8 -0
- package/dist/assets/flags/IR.svg +30 -0
- package/dist/assets/flags/IS.svg +5 -0
- package/dist/assets/flags/IT.svg +5 -0
- package/dist/assets/flags/JE.svg +6 -0
- package/dist/assets/flags/JM.svg +7 -0
- package/dist/assets/flags/JO.svg +7 -0
- package/dist/assets/flags/JP.svg +4 -0
- package/dist/assets/flags/KE.svg +12 -0
- package/dist/assets/flags/KG.svg +10 -0
- package/dist/assets/flags/KH.svg +6 -0
- package/dist/assets/flags/KI.svg +9 -0
- package/dist/assets/flags/KM.svg +12 -0
- package/dist/assets/flags/KN.svg +8 -0
- package/dist/assets/flags/KP.svg +9 -0
- package/dist/assets/flags/KR.svg +25 -0
- package/dist/assets/flags/KW.svg +6 -0
- package/dist/assets/flags/KY.svg +17 -0
- package/dist/assets/flags/KZ.svg +6 -0
- package/dist/assets/flags/LA.svg +6 -0
- package/dist/assets/flags/LB.svg +6 -0
- package/dist/assets/flags/LC.svg +8 -0
- package/dist/assets/flags/LI.svg +5 -0
- package/dist/assets/flags/LK.svg +16 -0
- package/dist/assets/flags/LR.svg +11 -0
- package/dist/assets/flags/LS.svg +6 -0
- package/dist/assets/flags/LT.svg +5 -0
- package/dist/assets/flags/LU.svg +5 -0
- package/dist/assets/flags/LV.svg +5 -0
- package/dist/assets/flags/LY.svg +7 -0
- package/dist/assets/flags/MA.svg +4 -0
- package/dist/assets/flags/MC.svg +4 -0
- package/dist/assets/flags/MD-SN.svg +7 -0
- package/dist/assets/flags/MD.svg +8 -0
- package/dist/assets/flags/ME.svg +8 -0
- package/dist/assets/flags/MG.svg +5 -0
- package/dist/assets/flags/MH.svg +6 -0
- package/dist/assets/flags/MK.svg +13 -0
- package/dist/assets/flags/ML.svg +5 -0
- package/dist/assets/flags/MM.svg +6 -0
- package/dist/assets/flags/MN.svg +12 -0
- package/dist/assets/flags/MO.svg +11 -0
- package/dist/assets/flags/MQ.svg +8 -0
- package/dist/assets/flags/MR.svg +5 -0
- package/dist/assets/flags/MS.svg +16 -0
- package/dist/assets/flags/MT.svg +5 -0
- package/dist/assets/flags/MU.svg +6 -0
- package/dist/assets/flags/MV.svg +5 -0
- package/dist/assets/flags/MW.svg +6 -0
- package/dist/assets/flags/MX.svg +7 -0
- package/dist/assets/flags/MY.svg +10 -0
- package/dist/assets/flags/MZ.svg +10 -0
- package/dist/assets/flags/NA.svg +7 -0
- package/dist/assets/flags/NE.svg +6 -0
- package/dist/assets/flags/NF.svg +6 -0
- package/dist/assets/flags/NG.svg +5 -0
- package/dist/assets/flags/NI.svg +9 -0
- package/dist/assets/flags/NL.svg +5 -0
- package/dist/assets/flags/NO.svg +5 -0
- package/dist/assets/flags/NP.svg +8 -0
- package/dist/assets/flags/NR.svg +5 -0
- package/dist/assets/flags/NU.svg +29 -0
- package/dist/assets/flags/NZ.svg +17 -0
- package/dist/assets/flags/OM.svg +7 -0
- package/dist/assets/flags/PA.svg +7 -0
- package/dist/assets/flags/PE.svg +5 -0
- package/dist/assets/flags/PF.svg +10 -0
- package/dist/assets/flags/PG.svg +10 -0
- package/dist/assets/flags/PH.svg +9 -0
- package/dist/assets/flags/PK.svg +7 -0
- package/dist/assets/flags/PL.svg +5 -0
- package/dist/assets/flags/PN.svg +17 -0
- package/dist/assets/flags/PR.svg +8 -0
- package/dist/assets/flags/PS.svg +6 -0
- package/dist/assets/flags/PT.svg +7 -0
- package/dist/assets/flags/PW.svg +4 -0
- package/dist/assets/flags/PY.svg +7 -0
- package/dist/assets/flags/QA.svg +4 -0
- package/dist/assets/flags/RO.svg +5 -0
- package/dist/assets/flags/RS.svg +11 -0
- package/dist/assets/flags/RU.svg +6 -0
- package/dist/assets/flags/RW.svg +6 -0
- package/dist/assets/flags/SA.svg +11 -0
- package/dist/assets/flags/SB.svg +12 -0
- package/dist/assets/flags/SC.svg +9 -0
- package/dist/assets/flags/SD.svg +8 -0
- package/dist/assets/flags/SE.svg +6 -0
- package/dist/assets/flags/SG.svg +12 -0
- package/dist/assets/flags/SI.svg +10 -0
- package/dist/assets/flags/SK.svg +11 -0
- package/dist/assets/flags/SL.svg +7 -0
- package/dist/assets/flags/SM.svg +9 -0
- package/dist/assets/flags/SN.svg +8 -0
- package/dist/assets/flags/SO.svg +6 -0
- package/dist/assets/flags/SR.svg +9 -0
- package/dist/assets/flags/SS.svg +10 -0
- package/dist/assets/flags/ST.svg +8 -0
- package/dist/assets/flags/SV.svg +8 -0
- package/dist/assets/flags/SX.svg +12 -0
- package/dist/assets/flags/SY.svg +9 -0
- package/dist/assets/flags/SZ.svg +16 -0
- package/dist/assets/flags/TB.svg +32 -0
- package/dist/assets/flags/TC.svg +20 -0
- package/dist/assets/flags/TD.svg +5 -0
- package/dist/assets/flags/TG.svg +10 -0
- package/dist/assets/flags/TH.svg +8 -0
- package/dist/assets/flags/TJ.svg +15 -0
- package/dist/assets/flags/TK.svg +11 -0
- package/dist/assets/flags/TL.svg +6 -0
- package/dist/assets/flags/TM.svg +24 -0
- package/dist/assets/flags/TN.svg +8 -0
- package/dist/assets/flags/TO.svg +7 -0
- package/dist/assets/flags/TR.svg +7 -0
- package/dist/assets/flags/TT.svg +7 -0
- package/dist/assets/flags/TV.svg +32 -0
- package/dist/assets/flags/TW.svg +9 -0
- package/dist/assets/flags/TZ.svg +8 -0
- package/dist/assets/flags/UA.svg +6 -0
- package/dist/assets/flags/UG.svg +11 -0
- package/dist/assets/flags/UN.svg +7 -0
- package/dist/assets/flags/US-HI.svg +26 -0
- package/dist/assets/flags/US-MP.svg +7 -0
- package/dist/assets/flags/US.svg +22 -0
- package/dist/assets/flags/UY.svg +11 -0
- package/dist/assets/flags/UZ.svg +22 -0
- package/dist/assets/flags/VA.svg +8 -0
- package/dist/assets/flags/VC.svg +10 -0
- package/dist/assets/flags/VE.svg +15 -0
- package/dist/assets/flags/VG.svg +23 -0
- package/dist/assets/flags/VI.svg +13 -0
- package/dist/assets/flags/VN.svg +6 -0
- package/dist/assets/flags/VU.svg +12 -0
- package/dist/assets/flags/WS.svg +9 -0
- package/dist/assets/flags/XC.svg +7 -0
- package/dist/assets/flags/XO.svg +5 -0
- package/dist/assets/flags/XS.svg +13 -0
- package/dist/assets/flags/YE.svg +7 -0
- package/dist/assets/flags/ZA.svg +10 -0
- package/dist/assets/flags/ZM.svg +9 -0
- package/dist/assets/flags/ZW.svg +15 -0
- package/dist/blocks/fields/Address.d.ts +11 -0
- package/dist/blocks/fields/Address.js +46 -0
- package/dist/blocks/fields/Address.js.map +1 -0
- package/dist/blocks/fields/Checkbox.d.ts +2 -0
- package/dist/blocks/fields/Checkbox.js +31 -0
- package/dist/blocks/fields/Checkbox.js.map +1 -0
- package/dist/blocks/fields/CheckboxGroup.d.ts +2 -0
- package/dist/blocks/fields/CheckboxGroup.js +29 -0
- package/dist/blocks/fields/CheckboxGroup.js.map +1 -0
- package/dist/blocks/fields/Date.d.ts +2 -0
- package/dist/blocks/fields/Date.js +46 -0
- package/dist/blocks/fields/Date.js.map +1 -0
- package/dist/blocks/fields/Email.d.ts +2 -0
- package/dist/blocks/fields/Email.js +36 -0
- package/dist/blocks/fields/Email.js.map +1 -0
- package/dist/blocks/fields/File.d.ts +2 -0
- package/dist/blocks/fields/File.js +34 -0
- package/dist/blocks/fields/File.js.map +1 -0
- package/dist/blocks/fields/Number.d.ts +2 -0
- package/dist/blocks/fields/Number.js +34 -0
- package/dist/blocks/fields/Number.js.map +1 -0
- package/dist/blocks/fields/Phone.d.ts +2 -0
- package/dist/blocks/fields/Phone.js +62 -0
- package/dist/blocks/fields/Phone.js.map +1 -0
- package/dist/blocks/fields/RadioGroup.d.ts +2 -0
- package/dist/blocks/fields/RadioGroup.js +29 -0
- package/dist/blocks/fields/RadioGroup.js.map +1 -0
- package/dist/blocks/fields/Select.d.ts +2 -0
- package/dist/blocks/fields/Select.js +37 -0
- package/dist/blocks/fields/Select.js.map +1 -0
- package/dist/blocks/fields/Text.d.ts +2 -0
- package/dist/blocks/fields/Text.js +36 -0
- package/dist/blocks/fields/Text.js.map +1 -0
- package/dist/blocks/fields/Textarea.d.ts +2 -0
- package/dist/blocks/fields/Textarea.js +22 -0
- package/dist/blocks/fields/Textarea.js.map +1 -0
- package/dist/blocks/fields/TravelDate.d.ts +10 -0
- package/dist/blocks/fields/TravelDate.js +30 -0
- package/dist/blocks/fields/TravelDate.js.map +1 -0
- package/dist/blocks/fields/shared.d.ts +8 -0
- package/dist/blocks/fields/shared.js +158 -0
- package/dist/blocks/fields/shared.js.map +1 -0
- package/dist/blocks/fields/visibility.d.ts +9 -0
- package/dist/blocks/fields/visibility.js +203 -0
- package/dist/blocks/fields/visibility.js.map +1 -0
- package/dist/blocks/submissionActions/ConfirmationMessage.d.ts +7 -0
- package/dist/blocks/submissionActions/ConfirmationMessage.js +25 -0
- package/dist/blocks/submissionActions/ConfirmationMessage.js.map +1 -0
- package/dist/blocks/submissionActions/Redirect.d.ts +2 -0
- package/dist/blocks/submissionActions/Redirect.js +29 -0
- package/dist/blocks/submissionActions/Redirect.js.map +1 -0
- package/dist/blocks/submissionActions/SendEmail.d.ts +2 -0
- package/dist/blocks/submissionActions/SendEmail.js +50 -0
- package/dist/blocks/submissionActions/SendEmail.js.map +1 -0
- package/dist/collections/Forms.d.ts +12 -0
- package/dist/collections/Forms.js +327 -0
- package/dist/collections/Forms.js.map +1 -0
- package/dist/collections/Submissions.d.ts +8 -0
- package/dist/collections/Submissions.js +137 -0
- package/dist/collections/Submissions.js.map +1 -0
- package/dist/components/BeforeDashboardClient.d.ts +1 -0
- package/dist/components/BeforeDashboardClient.js +40 -0
- package/dist/components/BeforeDashboardClient.js.map +1 -0
- package/dist/components/BeforeDashboardServer.d.ts +2 -0
- package/dist/components/BeforeDashboardServer.js +22 -0
- package/dist/components/BeforeDashboardServer.js.map +1 -0
- package/dist/components/BeforeDashboardServer.module.css +5 -0
- package/dist/components/EnquiryForm/FieldTooltip.d.ts +5 -0
- package/dist/components/EnquiryForm/FieldTooltip.js +33 -0
- package/dist/components/EnquiryForm/FieldTooltip.js.map +1 -0
- package/dist/components/EnquiryForm/Step.d.ts +8 -0
- package/dist/components/EnquiryForm/Step.js +157 -0
- package/dist/components/EnquiryForm/Step.js.map +1 -0
- package/dist/components/EnquiryForm/StepIndicator.d.ts +17 -0
- package/dist/components/EnquiryForm/StepIndicator.js +59 -0
- package/dist/components/EnquiryForm/StepIndicator.js.map +1 -0
- package/dist/components/EnquiryForm/fields/AddressField.d.ts +20 -0
- package/dist/components/EnquiryForm/fields/AddressField.js +253 -0
- package/dist/components/EnquiryForm/fields/AddressField.js.map +1 -0
- package/dist/components/EnquiryForm/fields/BudgetRangeField.d.ts +8 -0
- package/dist/components/EnquiryForm/fields/BudgetRangeField.js +48 -0
- package/dist/components/EnquiryForm/fields/BudgetRangeField.js.map +1 -0
- package/dist/components/EnquiryForm/fields/CheckboxField.d.ts +8 -0
- package/dist/components/EnquiryForm/fields/CheckboxField.js +68 -0
- package/dist/components/EnquiryForm/fields/CheckboxField.js.map +1 -0
- package/dist/components/EnquiryForm/fields/CountrySelect.d.ts +27 -0
- package/dist/components/EnquiryForm/fields/CountrySelect.js +208 -0
- package/dist/components/EnquiryForm/fields/CountrySelect.js.map +1 -0
- package/dist/components/EnquiryForm/fields/DateInputField.d.ts +18 -0
- package/dist/components/EnquiryForm/fields/DateInputField.js +69 -0
- package/dist/components/EnquiryForm/fields/DateInputField.js.map +1 -0
- package/dist/components/EnquiryForm/fields/EmailInputField.d.ts +8 -0
- package/dist/components/EnquiryForm/fields/EmailInputField.js +56 -0
- package/dist/components/EnquiryForm/fields/EmailInputField.js.map +1 -0
- package/dist/components/EnquiryForm/fields/MultiCounterField.d.ts +8 -0
- package/dist/components/EnquiryForm/fields/MultiCounterField.js +97 -0
- package/dist/components/EnquiryForm/fields/MultiCounterField.js.map +1 -0
- package/dist/components/EnquiryForm/fields/NumberStepperField.d.ts +8 -0
- package/dist/components/EnquiryForm/fields/NumberStepperField.js +71 -0
- package/dist/components/EnquiryForm/fields/NumberStepperField.js.map +1 -0
- package/dist/components/EnquiryForm/fields/OptionCardsField.d.ts +8 -0
- package/dist/components/EnquiryForm/fields/OptionCardsField.js +51 -0
- package/dist/components/EnquiryForm/fields/OptionCardsField.js.map +1 -0
- package/dist/components/EnquiryForm/fields/PhoneInputField.d.ts +14 -0
- package/dist/components/EnquiryForm/fields/PhoneInputField.js +170 -0
- package/dist/components/EnquiryForm/fields/PhoneInputField.js.map +1 -0
- package/dist/components/EnquiryForm/fields/SelectField.d.ts +13 -0
- package/dist/components/EnquiryForm/fields/SelectField.js +245 -0
- package/dist/components/EnquiryForm/fields/SelectField.js.map +1 -0
- package/dist/components/EnquiryForm/fields/TextInputField.d.ts +8 -0
- package/dist/components/EnquiryForm/fields/TextInputField.js +46 -0
- package/dist/components/EnquiryForm/fields/TextInputField.js.map +1 -0
- package/dist/components/EnquiryForm/fields/TextareaField.d.ts +8 -0
- package/dist/components/EnquiryForm/fields/TextareaField.js +46 -0
- package/dist/components/EnquiryForm/fields/TextareaField.js.map +1 -0
- package/dist/components/EnquiryForm/fields/TravelDateField.d.ts +16 -0
- package/dist/components/EnquiryForm/fields/TravelDateField.js +351 -0
- package/dist/components/EnquiryForm/fields/TravelDateField.js.map +1 -0
- package/dist/components/EnquiryForm/fields/YesNoField.d.ts +8 -0
- package/dist/components/EnquiryForm/fields/YesNoField.js +51 -0
- package/dist/components/EnquiryForm/fields/YesNoField.js.map +1 -0
- package/dist/components/EnquiryForm/index.d.ts +2 -0
- package/dist/components/EnquiryForm/index.js +173 -0
- package/dist/components/EnquiryForm/index.js.map +1 -0
- package/dist/components/EnquiryForm/useEnquiryForm.d.ts +19 -0
- package/dist/components/EnquiryForm/useEnquiryForm.js +136 -0
- package/dist/components/EnquiryForm/useEnquiryForm.js.map +1 -0
- package/dist/components/SubmissionAnswers.d.ts +12 -0
- package/dist/components/SubmissionAnswers.js +33 -0
- package/dist/components/SubmissionAnswers.js.map +1 -0
- package/dist/components/SubmissionPanel.d.ts +25 -0
- package/dist/components/SubmissionPanel.js +188 -0
- package/dist/components/SubmissionPanel.js.map +1 -0
- package/dist/components/SubmissionPanel.module.css +147 -0
- package/dist/endpoints/customEndpointHandler.d.ts +2 -0
- package/dist/endpoints/customEndpointHandler.js +7 -0
- package/dist/endpoints/customEndpointHandler.js.map +1 -0
- package/dist/endpoints/fetchFormHandler.d.ts +3 -0
- package/dist/endpoints/fetchFormHandler.js +54 -0
- package/dist/endpoints/fetchFormHandler.js.map +1 -0
- package/dist/endpoints/submitFormHandler.d.ts +3 -0
- package/dist/endpoints/submitFormHandler.js +156 -0
- package/dist/endpoints/submitFormHandler.js.map +1 -0
- package/dist/exports/client.d.ts +5 -0
- package/dist/exports/client.js +10 -0
- package/dist/exports/client.js.map +1 -0
- package/dist/exports/frontend.d.ts +10 -0
- package/dist/exports/frontend.js +18 -0
- package/dist/exports/frontend.js.map +1 -0
- package/dist/exports/rich-text.d.ts +18 -0
- package/dist/exports/rich-text.js +20 -0
- package/dist/exports/rich-text.js.map +1 -0
- package/dist/exports/rsc.d.ts +5 -0
- package/dist/exports/rsc.js +6 -0
- package/dist/exports/rsc.js.map +1 -0
- package/dist/fields/conditions/ConditionSourceField.d.ts +7 -0
- package/dist/fields/conditions/ConditionSourceField.js +36 -0
- package/dist/fields/conditions/ConditionSourceField.js.map +1 -0
- package/dist/fields/conditions/ConditionValueField.d.ts +9 -0
- package/dist/fields/conditions/ConditionValueField.js +82 -0
- package/dist/fields/conditions/ConditionValueField.js.map +1 -0
- package/dist/fields/conditions/collectSourceFields.d.ts +30 -0
- package/dist/fields/conditions/collectSourceFields.js +67 -0
- package/dist/fields/conditions/collectSourceFields.js.map +1 -0
- package/dist/fields/conditions/describeSource.d.ts +15 -0
- package/dist/fields/conditions/describeSource.js +32 -0
- package/dist/fields/conditions/describeSource.js.map +1 -0
- package/dist/fields/lockable/LockableTextField.d.ts +11 -0
- package/dist/fields/lockable/LockableTextField.js +96 -0
- package/dist/fields/lockable/LockableTextField.js.map +1 -0
- package/dist/fields/lockable/formatSlug.d.ts +17 -0
- package/dist/fields/lockable/formatSlug.js +27 -0
- package/dist/fields/lockable/formatSlug.js.map +1 -0
- package/dist/fields/lockable/index.d.ts +28 -0
- package/dist/fields/lockable/index.js +58 -0
- package/dist/fields/lockable/index.js.map +1 -0
- package/dist/fields/lockable/index.scss +24 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +102 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +432 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/utilities/buildFieldRules.d.ts +19 -0
- package/dist/utilities/buildFieldRules.js +54 -0
- package/dist/utilities/buildFieldRules.js.map +1 -0
- package/dist/utilities/buildFormURL.d.ts +5 -0
- package/dist/utilities/buildFormURL.js +6 -0
- package/dist/utilities/buildFormURL.js.map +1 -0
- package/dist/utilities/buildIndicatorSteps.d.ts +15 -0
- package/dist/utilities/buildIndicatorSteps.js +33 -0
- package/dist/utilities/buildIndicatorSteps.js.map +1 -0
- package/dist/utilities/buildSubmitURL.d.ts +11 -0
- package/dist/utilities/buildSubmitURL.js +9 -0
- package/dist/utilities/buildSubmitURL.js.map +1 -0
- package/dist/utilities/buildZodSchemaFromForm.d.ts +40 -0
- package/dist/utilities/buildZodSchemaFromForm.js +218 -0
- package/dist/utilities/buildZodSchemaFromForm.js.map +1 -0
- package/dist/utilities/conditions/evaluateRule.d.ts +9 -0
- package/dist/utilities/conditions/evaluateRule.js +93 -0
- package/dist/utilities/conditions/evaluateRule.js.map +1 -0
- package/dist/utilities/conditions/index.d.ts +2 -0
- package/dist/utilities/conditions/index.js +4 -0
- package/dist/utilities/conditions/index.js.map +1 -0
- package/dist/utilities/conditions/visibility.d.ts +8 -0
- package/dist/utilities/conditions/visibility.js +40 -0
- package/dist/utilities/conditions/visibility.js.map +1 -0
- package/dist/utilities/countryFromLabel.d.ts +7 -0
- package/dist/utilities/countryFromLabel.js +37 -0
- package/dist/utilities/countryFromLabel.js.map +1 -0
- package/dist/utilities/countryFromLabel.test.d.ts +1 -0
- package/dist/utilities/countryFromLabel.test.js +40 -0
- package/dist/utilities/countryFromLabel.test.js.map +1 -0
- package/dist/utilities/describeSubmission.d.ts +82 -0
- package/dist/utilities/describeSubmission.js +291 -0
- package/dist/utilities/describeSubmission.js.map +1 -0
- package/dist/utilities/fetchEnquiryForm.d.ts +6 -0
- package/dist/utilities/fetchEnquiryForm.js +19 -0
- package/dist/utilities/fetchEnquiryForm.js.map +1 -0
- package/dist/utilities/flagAssets.d.ts +2 -0
- package/dist/utilities/flagAssets.js +19 -0
- package/dist/utilities/flagAssets.js.map +1 -0
- package/dist/utilities/lookupPostcode.d.ts +37 -0
- package/dist/utilities/lookupPostcode.js +49 -0
- package/dist/utilities/lookupPostcode.js.map +1 -0
- package/dist/utilities/normalizeFormSteps.d.ts +25 -0
- package/dist/utilities/normalizeFormSteps.js +27 -0
- package/dist/utilities/normalizeFormSteps.js.map +1 -0
- package/dist/utilities/normalizeSubmitError.d.ts +10 -0
- package/dist/utilities/normalizeSubmitError.js +24 -0
- package/dist/utilities/normalizeSubmitError.js.map +1 -0
- package/dist/utilities/recaptchaClient.d.ts +30 -0
- package/dist/utilities/recaptchaClient.js +68 -0
- package/dist/utilities/recaptchaClient.js.map +1 -0
- package/dist/utilities/sanitizeSubmission.d.ts +4 -0
- package/dist/utilities/sanitizeSubmission.js +8 -0
- package/dist/utilities/sanitizeSubmission.js.map +1 -0
- package/dist/utilities/toDateInputValue.d.ts +15 -0
- package/dist/utilities/toDateInputValue.js +27 -0
- package/dist/utilities/toDateInputValue.js.map +1 -0
- package/dist/utilities/toDateInputValue.test.d.ts +1 -0
- package/dist/utilities/toDateInputValue.test.js +39 -0
- package/dist/utilities/toDateInputValue.test.js.map +1 -0
- package/dist/utilities/travelDate.d.ts +14 -0
- package/dist/utilities/travelDate.js +56 -0
- package/dist/utilities/travelDate.js.map +1 -0
- package/dist/utilities/validateVisibleSubmission.d.ts +10 -0
- package/dist/utilities/validateVisibleSubmission.js +28 -0
- package/dist/utilities/validateVisibleSubmission.js.map +1 -0
- package/dist/utilities/verifyCaptcha.d.ts +55 -0
- package/dist/utilities/verifyCaptcha.js +98 -0
- package/dist/utilities/verifyCaptcha.js.map +1 -0
- package/package.json +123 -3
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,432 @@
|
|
|
1
|
+
import type { Block, RichTextField } from 'payload';
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
3
|
+
import type { Resolver, UseFormReturn } from 'react-hook-form';
|
|
4
|
+
export type FieldTooltip = {
|
|
5
|
+
enabled?: boolean | null;
|
|
6
|
+
text?: string | null;
|
|
7
|
+
};
|
|
8
|
+
export type MediaObject = {
|
|
9
|
+
id: string;
|
|
10
|
+
url?: string | null;
|
|
11
|
+
alt?: string | null;
|
|
12
|
+
};
|
|
13
|
+
export type SelectOption = {
|
|
14
|
+
id?: string;
|
|
15
|
+
label: string;
|
|
16
|
+
value: string;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Optional, admin-configurable validation rules. Applied via `buildFieldRules`
|
|
20
|
+
* to RHF's `register(..., rules)` and merged with the form-level resolver if
|
|
21
|
+
* one is provided.
|
|
22
|
+
*/
|
|
23
|
+
export type FieldValidation = {
|
|
24
|
+
requiredMessage?: string | null;
|
|
25
|
+
minLength?: number | null;
|
|
26
|
+
maxLength?: number | null;
|
|
27
|
+
pattern?: string | null;
|
|
28
|
+
patternMessage?: string | null;
|
|
29
|
+
min?: number | null;
|
|
30
|
+
max?: number | null;
|
|
31
|
+
minMessage?: string | null;
|
|
32
|
+
maxMessage?: string | null;
|
|
33
|
+
};
|
|
34
|
+
export type ConditionOperator = 'equals' | 'notEquals' | 'gt' | 'gte' | 'lt' | 'lte' | 'isChecked' | 'isNotChecked' | 'contains' | 'isEmpty' | 'isNotEmpty';
|
|
35
|
+
export type ConditionMatch = 'all' | 'any';
|
|
36
|
+
export type Condition = {
|
|
37
|
+
blockType?: 'condition';
|
|
38
|
+
id?: string;
|
|
39
|
+
/** Name (or dot-path e.g. `guests.adults`) of the field to test. */
|
|
40
|
+
source: string;
|
|
41
|
+
operator: ConditionOperator;
|
|
42
|
+
/** Compared value. Ignored for unary operators (isChecked/isEmpty/etc). */
|
|
43
|
+
value?: string | null;
|
|
44
|
+
};
|
|
45
|
+
/** One level of nesting only: a group holds plain conditions, never groups. */
|
|
46
|
+
export type ConditionGroup = {
|
|
47
|
+
blockType: 'group';
|
|
48
|
+
id?: string;
|
|
49
|
+
match?: ConditionMatch | null;
|
|
50
|
+
conditions?: Condition[] | null;
|
|
51
|
+
};
|
|
52
|
+
export type ConditionNode = Condition | ConditionGroup;
|
|
53
|
+
export type VisibilityAction = 'show' | 'require';
|
|
54
|
+
export type VisibilityRule = {
|
|
55
|
+
enabled?: boolean | null;
|
|
56
|
+
/** What happens when the rule matches. Steps always behave as 'show'. */
|
|
57
|
+
action?: VisibilityAction | null;
|
|
58
|
+
match?: ConditionMatch | null;
|
|
59
|
+
conditions?: ConditionNode[] | null;
|
|
60
|
+
};
|
|
61
|
+
export type BaseFieldBlock = {
|
|
62
|
+
id?: string;
|
|
63
|
+
name: string;
|
|
64
|
+
label: string;
|
|
65
|
+
required?: boolean | null;
|
|
66
|
+
tooltip?: FieldTooltip | null;
|
|
67
|
+
validation?: FieldValidation | null;
|
|
68
|
+
visibility?: VisibilityRule | null;
|
|
69
|
+
};
|
|
70
|
+
/** Width of an input within a step. Consecutive non-`'full'` fields in `Step`
|
|
71
|
+
* are grouped into the same row. */
|
|
72
|
+
export type FieldWidth = 'full' | 'half' | 'third';
|
|
73
|
+
export type TextBlock = BaseFieldBlock & {
|
|
74
|
+
blockType: 'text';
|
|
75
|
+
placeholder?: string | null;
|
|
76
|
+
width?: FieldWidth | null;
|
|
77
|
+
};
|
|
78
|
+
export type EmailBlock = BaseFieldBlock & {
|
|
79
|
+
blockType: 'email';
|
|
80
|
+
placeholder?: string | null;
|
|
81
|
+
width?: FieldWidth | null;
|
|
82
|
+
};
|
|
83
|
+
export type PhoneBlock = BaseFieldBlock & {
|
|
84
|
+
blockType: 'phone';
|
|
85
|
+
placeholder?: string | null;
|
|
86
|
+
width?: FieldWidth | null;
|
|
87
|
+
/** ISO/dial value of the default selected country (e.g. `"+44"`). */
|
|
88
|
+
defaultCountry?: string | null;
|
|
89
|
+
/** Country options for the picker. `value` should be the dial code so the
|
|
90
|
+
* field can build an E.164 number. Defaults to a small built-in list. */
|
|
91
|
+
countries?: SelectOption[] | null;
|
|
92
|
+
};
|
|
93
|
+
export type TextareaBlock = BaseFieldBlock & {
|
|
94
|
+
blockType: 'textarea';
|
|
95
|
+
placeholder?: string | null;
|
|
96
|
+
rows?: number | null;
|
|
97
|
+
};
|
|
98
|
+
export type CheckboxBlock = BaseFieldBlock & {
|
|
99
|
+
blockType: 'checkbox';
|
|
100
|
+
/** Visual presentation. Defaults to `'checkbox'`. Data shape is unchanged. */
|
|
101
|
+
appearance?: 'checkbox' | 'switch' | null;
|
|
102
|
+
};
|
|
103
|
+
export type RadioGroupBlock = BaseFieldBlock & {
|
|
104
|
+
blockType: 'radioGroup';
|
|
105
|
+
options?: SelectOption[] | null;
|
|
106
|
+
layout?: 'row' | 'grid' | null;
|
|
107
|
+
};
|
|
108
|
+
export type CheckboxGroupBlock = BaseFieldBlock & {
|
|
109
|
+
blockType: 'checkboxGroup';
|
|
110
|
+
options?: SelectOption[] | null;
|
|
111
|
+
layout?: 'row' | 'grid' | null;
|
|
112
|
+
};
|
|
113
|
+
export type SelectBlock = BaseFieldBlock & {
|
|
114
|
+
blockType: 'select';
|
|
115
|
+
placeholder?: string | null;
|
|
116
|
+
options?: SelectOption[] | null;
|
|
117
|
+
width?: FieldWidth | null;
|
|
118
|
+
};
|
|
119
|
+
export type NumberBlock = BaseFieldBlock & {
|
|
120
|
+
blockType: 'number';
|
|
121
|
+
placeholder?: string | null;
|
|
122
|
+
defaultValue?: number | null;
|
|
123
|
+
min?: number | null;
|
|
124
|
+
max?: number | null;
|
|
125
|
+
step?: number | null;
|
|
126
|
+
};
|
|
127
|
+
export type DateBlock = BaseFieldBlock & {
|
|
128
|
+
blockType: 'date';
|
|
129
|
+
placeholder?: string | null;
|
|
130
|
+
min?: string | null;
|
|
131
|
+
max?: string | null;
|
|
132
|
+
};
|
|
133
|
+
export type FileBlock = BaseFieldBlock & {
|
|
134
|
+
blockType: 'file';
|
|
135
|
+
accept?: string | null;
|
|
136
|
+
maxSizeMB?: number | null;
|
|
137
|
+
collection?: string | null;
|
|
138
|
+
};
|
|
139
|
+
export type YesNoBlock = BaseFieldBlock & {
|
|
140
|
+
blockType: 'yesNo';
|
|
141
|
+
};
|
|
142
|
+
/**
|
|
143
|
+
* A month or an exact date, the visitor's choice. Stored as `YYYY-MM` or `YYYY-MM-DD`, so
|
|
144
|
+
* an answer is still readable as plain text wherever it ends up (emails, CRMs, exports).
|
|
145
|
+
*/
|
|
146
|
+
export type TravelDateBlock = BaseFieldBlock & {
|
|
147
|
+
blockType: 'travelDate';
|
|
148
|
+
/** How many years after this one the month picker offers. */
|
|
149
|
+
yearsAhead?: number | null;
|
|
150
|
+
};
|
|
151
|
+
export type OptionCardsBlock = BaseFieldBlock & {
|
|
152
|
+
blockType: 'optionCards';
|
|
153
|
+
options?: SelectOption[] | null;
|
|
154
|
+
layout?: 'row' | 'grid' | null;
|
|
155
|
+
};
|
|
156
|
+
export type NumberStepperBlock = BaseFieldBlock & {
|
|
157
|
+
blockType: 'numberStepper';
|
|
158
|
+
placeholder?: string | null;
|
|
159
|
+
defaultValue?: number | null;
|
|
160
|
+
min?: number | null;
|
|
161
|
+
max?: number | null;
|
|
162
|
+
step?: number | null;
|
|
163
|
+
};
|
|
164
|
+
export type MultiCounterItem = {
|
|
165
|
+
name: string;
|
|
166
|
+
label: string;
|
|
167
|
+
defaultValue?: number | null;
|
|
168
|
+
min?: number | null;
|
|
169
|
+
max?: number | null;
|
|
170
|
+
};
|
|
171
|
+
export type MultiCounterBlock = BaseFieldBlock & {
|
|
172
|
+
blockType: 'multiCounter';
|
|
173
|
+
counters?: MultiCounterItem[] | null;
|
|
174
|
+
};
|
|
175
|
+
export type BudgetRangeBlock = BaseFieldBlock & {
|
|
176
|
+
blockType: 'budgetRange';
|
|
177
|
+
options?: SelectOption[] | null;
|
|
178
|
+
};
|
|
179
|
+
/** Composite runtime value of an address field. */
|
|
180
|
+
export type AddressValue = {
|
|
181
|
+
line1: string;
|
|
182
|
+
line2: string;
|
|
183
|
+
city: string;
|
|
184
|
+
county: string;
|
|
185
|
+
postcode: string;
|
|
186
|
+
country: string;
|
|
187
|
+
};
|
|
188
|
+
export type AddressBlock = BaseFieldBlock & {
|
|
189
|
+
blockType: 'address';
|
|
190
|
+
/** Pre-filled country, used until a postcode lookup overwrites it. */
|
|
191
|
+
defaultCountry?: string | null;
|
|
192
|
+
/** Whether the second address line is shown. Defaults to true. */
|
|
193
|
+
showLine2?: boolean | null;
|
|
194
|
+
/** Label on the lookup button. Defaults to "Find address". */
|
|
195
|
+
lookupLabel?: string | null;
|
|
196
|
+
};
|
|
197
|
+
export type FormFieldBlock = TextBlock | EmailBlock | PhoneBlock | TextareaBlock | CheckboxBlock | RadioGroupBlock | CheckboxGroupBlock | SelectBlock | NumberBlock | DateBlock | FileBlock | YesNoBlock | TravelDateBlock | OptionCardsBlock | NumberStepperBlock | MultiCounterBlock | BudgetRangeBlock | AddressBlock;
|
|
198
|
+
export type SendEmailActionBlock = {
|
|
199
|
+
id?: string;
|
|
200
|
+
blockType: 'sendEmail';
|
|
201
|
+
to: string;
|
|
202
|
+
replyTo?: string | null;
|
|
203
|
+
subject: string;
|
|
204
|
+
includeSubmissionData?: boolean | null;
|
|
205
|
+
};
|
|
206
|
+
export type ConfirmationMessageActionBlock = {
|
|
207
|
+
id?: string;
|
|
208
|
+
blockType: 'confirmationMessage';
|
|
209
|
+
message?: unknown;
|
|
210
|
+
};
|
|
211
|
+
export type RedirectActionBlock = {
|
|
212
|
+
id?: string;
|
|
213
|
+
blockType: 'redirect';
|
|
214
|
+
url: string;
|
|
215
|
+
delay?: number | null;
|
|
216
|
+
};
|
|
217
|
+
export type SubmissionActionBlock = SendEmailActionBlock | ConfirmationMessageActionBlock | RedirectActionBlock;
|
|
218
|
+
export type FormStep = {
|
|
219
|
+
id?: string;
|
|
220
|
+
title: string;
|
|
221
|
+
icon?: MediaObject | null;
|
|
222
|
+
/** Optional icon shown in the StepIndicator when this step is complete.
|
|
223
|
+
* Falls back to a built-in tick icon. */
|
|
224
|
+
completedIcon?: MediaObject | null;
|
|
225
|
+
introContent?: unknown;
|
|
226
|
+
fields: FormFieldBlock[];
|
|
227
|
+
visibility?: VisibilityRule | null;
|
|
228
|
+
/** Per-step override for the "Back" button label. */
|
|
229
|
+
backLabel?: string | null;
|
|
230
|
+
/** Per-step override for the "Next" (or "Submit" on the final step) button label. */
|
|
231
|
+
nextLabel?: string | null;
|
|
232
|
+
};
|
|
233
|
+
export type FormButtonLabels = {
|
|
234
|
+
back?: string | null;
|
|
235
|
+
next?: string | null;
|
|
236
|
+
submit?: string | null;
|
|
237
|
+
/** Label for the "Back" button on the final step. Falls back to `back`. */
|
|
238
|
+
backLast?: string | null;
|
|
239
|
+
};
|
|
240
|
+
export type AdditionalContent = {
|
|
241
|
+
enabled?: boolean | null;
|
|
242
|
+
position?: 'above' | 'below' | null;
|
|
243
|
+
content?: unknown;
|
|
244
|
+
};
|
|
245
|
+
/** Optional synthetic final stage shown in the step indicator (only) of a
|
|
246
|
+
* multi-stage form, representing the post-submit confirmation screen. It is
|
|
247
|
+
* never a navigable field step. */
|
|
248
|
+
export type ConfirmationStage = {
|
|
249
|
+
enabled?: boolean | null;
|
|
250
|
+
/** Label shown under the stage dot. Falls back to "Confirmation". */
|
|
251
|
+
label?: string | null;
|
|
252
|
+
/** Icon shown in the indicator for the confirmation stage. */
|
|
253
|
+
icon?: MediaObject | null;
|
|
254
|
+
};
|
|
255
|
+
export type FormDocument = {
|
|
256
|
+
id: string;
|
|
257
|
+
title: string;
|
|
258
|
+
slug: string;
|
|
259
|
+
/**
|
|
260
|
+
* Captcha details for this form, added by the fetch endpoint when the plugin
|
|
261
|
+
* has a complete captcha config. Absent when captcha is off, which is how
|
|
262
|
+
* the client decides whether to mint a token at all. Not a stored field.
|
|
263
|
+
*/
|
|
264
|
+
captcha?: PublicCaptchaConfig | null;
|
|
265
|
+
/** Whether this form is authored as multiple stages. When false (the
|
|
266
|
+
* default), fields live on the top-level `fields` array instead of `steps`. */
|
|
267
|
+
multiStep?: boolean | null;
|
|
268
|
+
/** Flat field list used by single-stage forms (`multiStep` falsy). The API
|
|
269
|
+
* response always also exposes a normalized `steps` array. */
|
|
270
|
+
fields?: FormFieldBlock[] | null;
|
|
271
|
+
steps: FormStep[];
|
|
272
|
+
/** Optional confirmation stage appended to the step indicator only (does not
|
|
273
|
+
* add a navigable step). Only meaningful for multi-stage forms. */
|
|
274
|
+
confirmationStage?: ConfirmationStage | null;
|
|
275
|
+
additionalContent?: AdditionalContent | null;
|
|
276
|
+
/** Document-level overrides for navigation button labels. Per-step `backLabel`
|
|
277
|
+
* / `nextLabel` take precedence over these. */
|
|
278
|
+
buttonLabels?: FormButtonLabels | null;
|
|
279
|
+
submissionActions: SubmissionActionBlock[];
|
|
280
|
+
updatedAt: string;
|
|
281
|
+
createdAt: string;
|
|
282
|
+
};
|
|
283
|
+
/** Arbitrary, JSON-serialisable context recorded against the submission.
|
|
284
|
+
* Not rendered; not part of `data`. Stored verbatim on the submission. */
|
|
285
|
+
export type EnquirySubmissionContext = Record<string, unknown>;
|
|
286
|
+
export type SubmitResult = {
|
|
287
|
+
success: true;
|
|
288
|
+
actions: {
|
|
289
|
+
confirmationMessage?: unknown;
|
|
290
|
+
redirectUrl?: string;
|
|
291
|
+
};
|
|
292
|
+
/** ID of the created submission, when the endpoint returns it. */
|
|
293
|
+
submissionId?: string;
|
|
294
|
+
};
|
|
295
|
+
export type SubmitError = {
|
|
296
|
+
success: false;
|
|
297
|
+
errors: Array<{
|
|
298
|
+
field: string;
|
|
299
|
+
message: string;
|
|
300
|
+
}>;
|
|
301
|
+
};
|
|
302
|
+
export type BuiltInFieldSlug = 'text' | 'email' | 'phone' | 'textarea' | 'checkbox' | 'radioGroup' | 'checkboxGroup' | 'select' | 'number' | 'date' | 'file';
|
|
303
|
+
export type FieldsConfig = Record<string, boolean | {
|
|
304
|
+
block: Block;
|
|
305
|
+
} | undefined>;
|
|
306
|
+
/**
|
|
307
|
+
* reCAPTCHA v3 settings. Both keys must be present for the captcha to be
|
|
308
|
+
* enforced — with either missing, forms behave exactly as they did before, so
|
|
309
|
+
* a site can ship this config before its keys exist.
|
|
310
|
+
*
|
|
311
|
+
* `siteKey` is public by design (it is served to the browser with the form);
|
|
312
|
+
* `secretKey` must come from the server environment and never be committed.
|
|
313
|
+
*/
|
|
314
|
+
export type CaptchaConfig = {
|
|
315
|
+
/** Only reCAPTCHA v3 is supported today; named so other providers can be added. */
|
|
316
|
+
provider?: 'recaptcha-v3';
|
|
317
|
+
/** Public site key, sent to the browser. */
|
|
318
|
+
siteKey?: string;
|
|
319
|
+
/** Secret key, server-side only. */
|
|
320
|
+
secretKey?: string;
|
|
321
|
+
/** Reject submissions scoring below this (0–1). Defaults to 0.5. */
|
|
322
|
+
minScore?: number;
|
|
323
|
+
/** Action name minted into the token and asserted on verify. Defaults to 'form_submit'. */
|
|
324
|
+
action?: string;
|
|
325
|
+
};
|
|
326
|
+
/** Captcha details safe to expose to the browser alongside a form. */
|
|
327
|
+
export type PublicCaptchaConfig = {
|
|
328
|
+
provider: 'recaptcha-v3';
|
|
329
|
+
siteKey: string;
|
|
330
|
+
action: string;
|
|
331
|
+
};
|
|
332
|
+
export type FormPluginConfig = {
|
|
333
|
+
disabled?: boolean;
|
|
334
|
+
baseUrl?: string;
|
|
335
|
+
/** Slug of the Payload media collection used for step icons. Defaults to 'media'. */
|
|
336
|
+
mediaCollection?: string;
|
|
337
|
+
collections?: {
|
|
338
|
+
/** Slug for the forms collection. Defaults to 'forms'. */
|
|
339
|
+
forms?: string;
|
|
340
|
+
/** Slug for the submissions collection. Defaults to 'form-submissions'. */
|
|
341
|
+
submissions?: string;
|
|
342
|
+
};
|
|
343
|
+
/** Override admin labels for the plugin's collections. */
|
|
344
|
+
labels?: {
|
|
345
|
+
/** Singular label for the forms collection. Defaults to 'Form'. */
|
|
346
|
+
forms?: string;
|
|
347
|
+
/** Singular label for the submissions collection. Defaults to 'Form Submission'. */
|
|
348
|
+
submissions?: string;
|
|
349
|
+
};
|
|
350
|
+
/**
|
|
351
|
+
* Configure which field blocks are available in the form builder.
|
|
352
|
+
* - Omit key or set to `true`: include default block
|
|
353
|
+
* - Set to `false`: exclude block
|
|
354
|
+
* - Set to `{ block: MyBlock }`: replace default block with custom
|
|
355
|
+
* - Add a new key with `{ block: MyBlock }`: add custom block type
|
|
356
|
+
*/
|
|
357
|
+
fields?: FieldsConfig;
|
|
358
|
+
/**
|
|
359
|
+
* Editor applied to the consumer-facing rich-text fields — the confirmation
|
|
360
|
+
* message and the additional content. Pass a configured `lexicalEditor(...)`
|
|
361
|
+
* to enable custom Lexical blocks/features in those fields. When omitted, the
|
|
362
|
+
* fields fall back to the Payload root editor. Does not affect a step's intro
|
|
363
|
+
* content (which keeps its own headings-enabled editor).
|
|
364
|
+
*/
|
|
365
|
+
richTextEditor?: RichTextField['editor'];
|
|
366
|
+
/**
|
|
367
|
+
* Protect every form's submit endpoint with reCAPTCHA v3. Omit it, or leave
|
|
368
|
+
* either key unset, and nothing changes — no script is loaded and no token
|
|
369
|
+
* is required.
|
|
370
|
+
*/
|
|
371
|
+
captcha?: CaptchaConfig;
|
|
372
|
+
};
|
|
373
|
+
export type FormProps = {
|
|
374
|
+
form: FormDocument;
|
|
375
|
+
apiBase?: string;
|
|
376
|
+
className?: string;
|
|
377
|
+
onSuccess?: (result: SubmitResult) => void;
|
|
378
|
+
onError?: (error: SubmitError) => void;
|
|
379
|
+
additionalContent?: ReactNode;
|
|
380
|
+
/**
|
|
381
|
+
* Optional render function for the per-step `introContent` rich text.
|
|
382
|
+
* Called for each step; return `null`/`undefined` to render nothing.
|
|
383
|
+
*/
|
|
384
|
+
renderStepIntro?: (step: FormStep, index: number) => ReactNode;
|
|
385
|
+
/**
|
|
386
|
+
* Optional render function for the confirmation message after a successful
|
|
387
|
+
* submission. Receives the raw `confirmationMessage` payload (typically
|
|
388
|
+
* Lexical JSON) plus the full `SubmitResult`. If omitted, a default
|
|
389
|
+
* "Form submitted successfully." message is shown.
|
|
390
|
+
*/
|
|
391
|
+
renderConfirmation?: (message: unknown, result: SubmitResult) => ReactNode;
|
|
392
|
+
/**
|
|
393
|
+
* Optional react-hook-form `Resolver` (e.g. `zodResolver(schema)`). Runs
|
|
394
|
+
* alongside the per-field admin rules — RHF natively merges both, so either
|
|
395
|
+
* source can flag a field as invalid.
|
|
396
|
+
*/
|
|
397
|
+
resolver?: Resolver<Record<string, unknown>>;
|
|
398
|
+
/**
|
|
399
|
+
* Arbitrary, JSON-serialisable context recorded against the submission
|
|
400
|
+
* (e.g. hotel/itinerary/offer reference). Not rendered and not part of
|
|
401
|
+
* `data` — stored verbatim on the submission.
|
|
402
|
+
*/
|
|
403
|
+
context?: EnquirySubmissionContext;
|
|
404
|
+
};
|
|
405
|
+
export type UseEnquiryFormReturn = {
|
|
406
|
+
currentStep: number;
|
|
407
|
+
totalSteps: number;
|
|
408
|
+
stepData: FormStep;
|
|
409
|
+
form: UseFormReturn<Record<string, unknown>>;
|
|
410
|
+
goNext: () => Promise<boolean>;
|
|
411
|
+
goBack: () => void;
|
|
412
|
+
submit: () => Promise<SubmitResult>;
|
|
413
|
+
isSubmitting: boolean;
|
|
414
|
+
isComplete: boolean;
|
|
415
|
+
result: SubmitResult | null;
|
|
416
|
+
error: SubmitError | null;
|
|
417
|
+
/**
|
|
418
|
+
* The form values captured at the moment of a successful submit. `null` until
|
|
419
|
+
* then. The live form is reset on success, so this is the only remaining
|
|
420
|
+
* record of the path the visitor took — the confirmation screen's step
|
|
421
|
+
* indicator is built from it.
|
|
422
|
+
*/
|
|
423
|
+
submittedValues: null | Record<string, unknown>;
|
|
424
|
+
};
|
|
425
|
+
export type TextInputBlock = TextBlock;
|
|
426
|
+
export type EmailInputBlock = EmailBlock;
|
|
427
|
+
export type CheckboxInputBlock = CheckboxBlock;
|
|
428
|
+
export type SelectInputBlock = SelectBlock;
|
|
429
|
+
export type TextareaInputBlock = TextareaBlock;
|
|
430
|
+
export type EnquiryFormProps = FormProps;
|
|
431
|
+
export type EnquiryFormStep = FormStep;
|
|
432
|
+
export type EnquiryForm = FormDocument;
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type { Block, RichTextField } from 'payload';\nimport type { ReactNode } from 'react';\nimport type { Resolver, UseFormReturn } from 'react-hook-form';\n\n// ---------------------------------------------------------------------------\n// Shared sub-types\n// ---------------------------------------------------------------------------\n\nexport type FieldTooltip = {\n enabled?: boolean | null;\n text?: string | null;\n};\n\nexport type MediaObject = {\n id: string;\n url?: string | null;\n alt?: string | null;\n};\n\nexport type SelectOption = {\n id?: string;\n label: string;\n value: string;\n};\n\n/**\n * Optional, admin-configurable validation rules. Applied via `buildFieldRules`\n * to RHF's `register(..., rules)` and merged with the form-level resolver if\n * one is provided.\n */\nexport type FieldValidation = {\n requiredMessage?: string | null;\n // Text-shaped (text, email, phone, textarea, select)\n minLength?: number | null;\n maxLength?: number | null;\n pattern?: string | null;\n patternMessage?: string | null;\n // Numeric-shaped (number, numberStepper, multiCounter total)\n min?: number | null;\n max?: number | null;\n minMessage?: string | null;\n maxMessage?: string | null;\n};\n\n// ---------------------------------------------------------------------------\n// Conditional visibility (see docs/superpowers/plans/2026-07-03-conditional-fields.md)\n// ---------------------------------------------------------------------------\n\nexport type ConditionOperator =\n | 'equals'\n | 'notEquals'\n | 'gt'\n | 'gte'\n | 'lt'\n | 'lte'\n | 'isChecked'\n | 'isNotChecked'\n | 'contains'\n | 'isEmpty'\n | 'isNotEmpty';\n\nexport type ConditionMatch = 'all' | 'any';\n\nexport type Condition = {\n blockType?: 'condition';\n id?: string;\n /** Name (or dot-path e.g. `guests.adults`) of the field to test. */\n source: string;\n operator: ConditionOperator;\n /** Compared value. Ignored for unary operators (isChecked/isEmpty/etc). */\n value?: string | null;\n};\n\n/** One level of nesting only: a group holds plain conditions, never groups. */\nexport type ConditionGroup = {\n blockType: 'group';\n id?: string;\n match?: ConditionMatch | null;\n conditions?: Condition[] | null;\n};\n\nexport type ConditionNode = Condition | ConditionGroup;\n\nexport type VisibilityAction = 'show' | 'require';\n\nexport type VisibilityRule = {\n enabled?: boolean | null;\n /** What happens when the rule matches. Steps always behave as 'show'. */\n action?: VisibilityAction | null;\n match?: ConditionMatch | null;\n conditions?: ConditionNode[] | null;\n};\n\n// ---------------------------------------------------------------------------\n// Base — all field blocks extend this\n// ---------------------------------------------------------------------------\n\nexport type BaseFieldBlock = {\n id?: string;\n name: string;\n label: string;\n required?: boolean | null;\n tooltip?: FieldTooltip | null;\n validation?: FieldValidation | null;\n visibility?: VisibilityRule | null;\n};\n\n// ---------------------------------------------------------------------------\n// Field block types (discriminated union on blockType)\n// ---------------------------------------------------------------------------\n\n/** Width of an input within a step. Consecutive non-`'full'` fields in `Step`\n * are grouped into the same row. */\nexport type FieldWidth = 'full' | 'half' | 'third';\n\nexport type TextBlock = BaseFieldBlock & {\n blockType: 'text';\n placeholder?: string | null;\n width?: FieldWidth | null;\n};\n\nexport type EmailBlock = BaseFieldBlock & {\n blockType: 'email';\n placeholder?: string | null;\n width?: FieldWidth | null;\n};\n\nexport type PhoneBlock = BaseFieldBlock & {\n blockType: 'phone';\n placeholder?: string | null;\n width?: FieldWidth | null;\n /** ISO/dial value of the default selected country (e.g. `\"+44\"`). */\n defaultCountry?: string | null;\n /** Country options for the picker. `value` should be the dial code so the\n * field can build an E.164 number. Defaults to a small built-in list. */\n countries?: SelectOption[] | null;\n};\n\nexport type TextareaBlock = BaseFieldBlock & {\n blockType: 'textarea';\n placeholder?: string | null;\n rows?: number | null;\n};\n\nexport type CheckboxBlock = BaseFieldBlock & {\n blockType: 'checkbox';\n /** Visual presentation. Defaults to `'checkbox'`. Data shape is unchanged. */\n appearance?: 'checkbox' | 'switch' | null;\n};\n\nexport type RadioGroupBlock = BaseFieldBlock & {\n blockType: 'radioGroup';\n options?: SelectOption[] | null;\n layout?: 'row' | 'grid' | null;\n};\n\nexport type CheckboxGroupBlock = BaseFieldBlock & {\n blockType: 'checkboxGroup';\n options?: SelectOption[] | null;\n layout?: 'row' | 'grid' | null;\n};\n\nexport type SelectBlock = BaseFieldBlock & {\n blockType: 'select';\n placeholder?: string | null;\n options?: SelectOption[] | null;\n width?: FieldWidth | null;\n};\n\nexport type NumberBlock = BaseFieldBlock & {\n blockType: 'number';\n placeholder?: string | null;\n defaultValue?: number | null;\n min?: number | null;\n max?: number | null;\n step?: number | null;\n};\n\nexport type DateBlock = BaseFieldBlock & {\n blockType: 'date';\n placeholder?: string | null;\n min?: string | null;\n max?: string | null;\n};\n\nexport type FileBlock = BaseFieldBlock & {\n blockType: 'file';\n accept?: string | null;\n maxSizeMB?: number | null;\n collection?: string | null;\n};\n\n// Custom / extension field block types (can be used via the `fields` config option)\n\nexport type YesNoBlock = BaseFieldBlock & { blockType: 'yesNo' };\n\n/**\n * A month or an exact date, the visitor's choice. Stored as `YYYY-MM` or `YYYY-MM-DD`, so\n * an answer is still readable as plain text wherever it ends up (emails, CRMs, exports).\n */\nexport type TravelDateBlock = BaseFieldBlock & {\n blockType: 'travelDate';\n /** How many years after this one the month picker offers. */\n yearsAhead?: number | null;\n};\n\nexport type OptionCardsBlock = BaseFieldBlock & {\n blockType: 'optionCards';\n options?: SelectOption[] | null;\n layout?: 'row' | 'grid' | null;\n};\n\nexport type NumberStepperBlock = BaseFieldBlock & {\n blockType: 'numberStepper';\n placeholder?: string | null;\n defaultValue?: number | null;\n min?: number | null;\n max?: number | null;\n step?: number | null;\n};\n\nexport type MultiCounterItem = {\n name: string;\n label: string;\n defaultValue?: number | null;\n min?: number | null;\n max?: number | null;\n};\n\nexport type MultiCounterBlock = BaseFieldBlock & {\n blockType: 'multiCounter';\n counters?: MultiCounterItem[] | null;\n};\n\nexport type BudgetRangeBlock = BaseFieldBlock & {\n blockType: 'budgetRange';\n options?: SelectOption[] | null;\n};\n\n/** Composite runtime value of an address field. */\nexport type AddressValue = {\n line1: string;\n line2: string;\n city: string;\n county: string;\n postcode: string;\n country: string;\n};\n\nexport type AddressBlock = BaseFieldBlock & {\n blockType: 'address';\n /** Pre-filled country, used until a postcode lookup overwrites it. */\n defaultCountry?: string | null;\n /** Whether the second address line is shown. Defaults to true. */\n showLine2?: boolean | null;\n /** Label on the lookup button. Defaults to \"Find address\". */\n lookupLabel?: string | null;\n};\n\nexport type FormFieldBlock =\n | TextBlock\n | EmailBlock\n | PhoneBlock\n | TextareaBlock\n | CheckboxBlock\n | RadioGroupBlock\n | CheckboxGroupBlock\n | SelectBlock\n | NumberBlock\n | DateBlock\n | FileBlock\n | YesNoBlock\n | TravelDateBlock\n | OptionCardsBlock\n | NumberStepperBlock\n | MultiCounterBlock\n | BudgetRangeBlock\n | AddressBlock;\n\n// ---------------------------------------------------------------------------\n// Submission action block types\n// ---------------------------------------------------------------------------\n\nexport type SendEmailActionBlock = {\n id?: string;\n blockType: 'sendEmail';\n to: string;\n replyTo?: string | null;\n subject: string;\n includeSubmissionData?: boolean | null;\n};\n\nexport type ConfirmationMessageActionBlock = {\n id?: string;\n blockType: 'confirmationMessage';\n message?: unknown;\n};\n\nexport type RedirectActionBlock = {\n id?: string;\n blockType: 'redirect';\n url: string;\n delay?: number | null;\n};\n\nexport type SubmissionActionBlock =\n | SendEmailActionBlock\n | ConfirmationMessageActionBlock\n | RedirectActionBlock;\n\n// ---------------------------------------------------------------------------\n// FormDocument aggregate (formerly EnquiryForm)\n// ---------------------------------------------------------------------------\n\nexport type FormStep = {\n id?: string;\n title: string;\n icon?: MediaObject | null;\n /** Optional icon shown in the StepIndicator when this step is complete.\n * Falls back to a built-in tick icon. */\n completedIcon?: MediaObject | null;\n introContent?: unknown;\n fields: FormFieldBlock[];\n visibility?: VisibilityRule | null;\n /** Per-step override for the \"Back\" button label. */\n backLabel?: string | null;\n /** Per-step override for the \"Next\" (or \"Submit\" on the final step) button label. */\n nextLabel?: string | null;\n};\n\nexport type FormButtonLabels = {\n back?: string | null;\n next?: string | null;\n submit?: string | null;\n /** Label for the \"Back\" button on the final step. Falls back to `back`. */\n backLast?: string | null;\n};\n\nexport type AdditionalContent = {\n enabled?: boolean | null;\n position?: 'above' | 'below' | null;\n content?: unknown;\n};\n\n/** Optional synthetic final stage shown in the step indicator (only) of a\n * multi-stage form, representing the post-submit confirmation screen. It is\n * never a navigable field step. */\nexport type ConfirmationStage = {\n enabled?: boolean | null;\n /** Label shown under the stage dot. Falls back to \"Confirmation\". */\n label?: string | null;\n /** Icon shown in the indicator for the confirmation stage. */\n icon?: MediaObject | null;\n};\n\nexport type FormDocument = {\n id: string;\n title: string;\n slug: string;\n /**\n * Captcha details for this form, added by the fetch endpoint when the plugin\n * has a complete captcha config. Absent when captcha is off, which is how\n * the client decides whether to mint a token at all. Not a stored field.\n */\n captcha?: PublicCaptchaConfig | null;\n /** Whether this form is authored as multiple stages. When false (the\n * default), fields live on the top-level `fields` array instead of `steps`. */\n multiStep?: boolean | null;\n /** Flat field list used by single-stage forms (`multiStep` falsy). The API\n * response always also exposes a normalized `steps` array. */\n fields?: FormFieldBlock[] | null;\n steps: FormStep[];\n /** Optional confirmation stage appended to the step indicator only (does not\n * add a navigable step). Only meaningful for multi-stage forms. */\n confirmationStage?: ConfirmationStage | null;\n additionalContent?: AdditionalContent | null;\n /** Document-level overrides for navigation button labels. Per-step `backLabel`\n * / `nextLabel` take precedence over these. */\n buttonLabels?: FormButtonLabels | null;\n submissionActions: SubmissionActionBlock[];\n updatedAt: string;\n createdAt: string;\n};\n\n// ---------------------------------------------------------------------------\n// API response types\n// ---------------------------------------------------------------------------\n\n/** Arbitrary, JSON-serialisable context recorded against the submission.\n * Not rendered; not part of `data`. Stored verbatim on the submission. */\nexport type EnquirySubmissionContext = Record<string, unknown>;\n\nexport type SubmitResult = {\n success: true;\n actions: {\n confirmationMessage?: unknown;\n redirectUrl?: string;\n };\n /** ID of the created submission, when the endpoint returns it. */\n submissionId?: string;\n};\n\nexport type SubmitError = {\n success: false;\n errors: Array<{ field: string; message: string }>;\n};\n\n// ---------------------------------------------------------------------------\n// Plugin config\n// ---------------------------------------------------------------------------\n\nexport type BuiltInFieldSlug =\n | 'text'\n | 'email'\n | 'phone'\n | 'textarea'\n | 'checkbox'\n | 'radioGroup'\n | 'checkboxGroup'\n | 'select'\n | 'number'\n | 'date'\n | 'file';\n\nexport type FieldsConfig = Record<\n string,\n boolean | { block: Block } | undefined\n>;\n\n/**\n * reCAPTCHA v3 settings. Both keys must be present for the captcha to be\n * enforced — with either missing, forms behave exactly as they did before, so\n * a site can ship this config before its keys exist.\n *\n * `siteKey` is public by design (it is served to the browser with the form);\n * `secretKey` must come from the server environment and never be committed.\n */\nexport type CaptchaConfig = {\n /** Only reCAPTCHA v3 is supported today; named so other providers can be added. */\n provider?: 'recaptcha-v3';\n /** Public site key, sent to the browser. */\n siteKey?: string;\n /** Secret key, server-side only. */\n secretKey?: string;\n /** Reject submissions scoring below this (0–1). Defaults to 0.5. */\n minScore?: number;\n /** Action name minted into the token and asserted on verify. Defaults to 'form_submit'. */\n action?: string;\n};\n\n/** Captcha details safe to expose to the browser alongside a form. */\nexport type PublicCaptchaConfig = {\n provider: 'recaptcha-v3';\n siteKey: string;\n action: string;\n};\n\nexport type FormPluginConfig = {\n disabled?: boolean;\n baseUrl?: string;\n /** Slug of the Payload media collection used for step icons. Defaults to 'media'. */\n mediaCollection?: string;\n collections?: {\n /** Slug for the forms collection. Defaults to 'forms'. */\n forms?: string;\n /** Slug for the submissions collection. Defaults to 'form-submissions'. */\n submissions?: string;\n };\n /** Override admin labels for the plugin's collections. */\n labels?: {\n /** Singular label for the forms collection. Defaults to 'Form'. */\n forms?: string;\n /** Singular label for the submissions collection. Defaults to 'Form Submission'. */\n submissions?: string;\n };\n /**\n * Configure which field blocks are available in the form builder.\n * - Omit key or set to `true`: include default block\n * - Set to `false`: exclude block\n * - Set to `{ block: MyBlock }`: replace default block with custom\n * - Add a new key with `{ block: MyBlock }`: add custom block type\n */\n fields?: FieldsConfig;\n /**\n * Editor applied to the consumer-facing rich-text fields — the confirmation\n * message and the additional content. Pass a configured `lexicalEditor(...)`\n * to enable custom Lexical blocks/features in those fields. When omitted, the\n * fields fall back to the Payload root editor. Does not affect a step's intro\n * content (which keeps its own headings-enabled editor).\n */\n richTextEditor?: RichTextField['editor'];\n /**\n * Protect every form's submit endpoint with reCAPTCHA v3. Omit it, or leave\n * either key unset, and nothing changes — no script is loaded and no token\n * is required.\n */\n captcha?: CaptchaConfig;\n};\n\n// ---------------------------------------------------------------------------\n// Frontend component props\n// ---------------------------------------------------------------------------\n\nexport type FormProps = {\n form: FormDocument;\n apiBase?: string;\n className?: string;\n onSuccess?: (result: SubmitResult) => void;\n onError?: (error: SubmitError) => void;\n additionalContent?: ReactNode;\n /**\n * Optional render function for the per-step `introContent` rich text.\n * Called for each step; return `null`/`undefined` to render nothing.\n */\n renderStepIntro?: (step: FormStep, index: number) => ReactNode;\n /**\n * Optional render function for the confirmation message after a successful\n * submission. Receives the raw `confirmationMessage` payload (typically\n * Lexical JSON) plus the full `SubmitResult`. If omitted, a default\n * \"Form submitted successfully.\" message is shown.\n */\n renderConfirmation?: (message: unknown, result: SubmitResult) => ReactNode;\n /**\n * Optional react-hook-form `Resolver` (e.g. `zodResolver(schema)`). Runs\n * alongside the per-field admin rules — RHF natively merges both, so either\n * source can flag a field as invalid.\n */\n resolver?: Resolver<Record<string, unknown>>;\n /**\n * Arbitrary, JSON-serialisable context recorded against the submission\n * (e.g. hotel/itinerary/offer reference). Not rendered and not part of\n * `data` — stored verbatim on the submission.\n */\n context?: EnquirySubmissionContext;\n};\n\n// ---------------------------------------------------------------------------\n// Frontend component hook return type\n// ---------------------------------------------------------------------------\n\nexport type UseEnquiryFormReturn = {\n currentStep: number;\n totalSteps: number;\n stepData: FormStep;\n form: UseFormReturn<Record<string, unknown>>;\n goNext: () => Promise<boolean>;\n goBack: () => void;\n submit: () => Promise<SubmitResult>;\n isSubmitting: boolean;\n isComplete: boolean;\n result: SubmitResult | null;\n error: SubmitError | null;\n /**\n * The form values captured at the moment of a successful submit. `null` until\n * then. The live form is reset on success, so this is the only remaining\n * record of the path the visitor took — the confirmation screen's step\n * indicator is built from it.\n */\n submittedValues: null | Record<string, unknown>;\n};\n\n// ---------------------------------------------------------------------------\n// Legacy type aliases (renamed from earlier versions)\n// ---------------------------------------------------------------------------\n\nexport type TextInputBlock = TextBlock;\nexport type EmailInputBlock = EmailBlock;\nexport type CheckboxInputBlock = CheckboxBlock;\nexport type SelectInputBlock = SelectBlock;\nexport type TextareaInputBlock = TextareaBlock;\nexport type EnquiryFormProps = FormProps;\nexport type EnquiryFormStep = FormStep;\nexport type EnquiryForm = FormDocument;\n"],"names":[],"mappings":"AA4jBA,WAAuC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { RegisterOptions } from 'react-hook-form';
|
|
2
|
+
import type { BaseFieldBlock } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Subset of RHF's `RegisterOptions` we populate from admin-configured rules.
|
|
5
|
+
* Picking a subset avoids TypeScript collisions with the discriminated union
|
|
6
|
+
* branches of the full `RegisterOptions` type (e.g. `valueAsNumber` /
|
|
7
|
+
* `valueAsDate` clobber `pattern`).
|
|
8
|
+
*/
|
|
9
|
+
export type FieldRules = Pick<RegisterOptions, 'required' | 'min' | 'max' | 'minLength' | 'maxLength' | 'pattern'>;
|
|
10
|
+
/**
|
|
11
|
+
* Translate a field block's admin-configured `validation` group into RHF
|
|
12
|
+
* `register(..., rules)` options. Returns an empty object when the field has
|
|
13
|
+
* no rules — safe to spread into `register` unconditionally.
|
|
14
|
+
*
|
|
15
|
+
* Use with text-shaped fields (text, email, phone, textarea, select). Numeric
|
|
16
|
+
* fields receive `min`/`max` rules; multi-counter fields should compose this
|
|
17
|
+
* with a custom `validate` callback for total-based limits.
|
|
18
|
+
*/
|
|
19
|
+
export declare function buildFieldRules(field: Pick<BaseFieldBlock, 'label' | 'required' | 'validation'>, requiredOverride?: boolean): FieldRules;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Translate a field block's admin-configured `validation` group into RHF
|
|
3
|
+
* `register(..., rules)` options. Returns an empty object when the field has
|
|
4
|
+
* no rules — safe to spread into `register` unconditionally.
|
|
5
|
+
*
|
|
6
|
+
* Use with text-shaped fields (text, email, phone, textarea, select). Numeric
|
|
7
|
+
* fields receive `min`/`max` rules; multi-counter fields should compose this
|
|
8
|
+
* with a custom `validate` callback for total-based limits.
|
|
9
|
+
*/ export function buildFieldRules(field, requiredOverride) {
|
|
10
|
+
const v = field.validation ?? {};
|
|
11
|
+
const rules = {};
|
|
12
|
+
const required = requiredOverride ?? field.required;
|
|
13
|
+
if (required) {
|
|
14
|
+
rules.required = v.requiredMessage ?? `${field.label} is required`;
|
|
15
|
+
}
|
|
16
|
+
if (typeof v.minLength === 'number') {
|
|
17
|
+
rules.minLength = {
|
|
18
|
+
value: v.minLength,
|
|
19
|
+
message: `${field.label} must be at least ${v.minLength} characters`
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
if (typeof v.maxLength === 'number') {
|
|
23
|
+
rules.maxLength = {
|
|
24
|
+
value: v.maxLength,
|
|
25
|
+
message: `${field.label} must be at most ${v.maxLength} characters`
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
if (typeof v.min === 'number') {
|
|
29
|
+
rules.min = {
|
|
30
|
+
value: v.min,
|
|
31
|
+
message: v.minMessage ?? `${field.label} must be ≥ ${v.min}`
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
if (typeof v.max === 'number') {
|
|
35
|
+
rules.max = {
|
|
36
|
+
value: v.max,
|
|
37
|
+
message: v.maxMessage ?? `${field.label} must be ≤ ${v.max}`
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
if (v.pattern) {
|
|
41
|
+
try {
|
|
42
|
+
rules.pattern = {
|
|
43
|
+
value: new RegExp(v.pattern),
|
|
44
|
+
message: v.patternMessage ?? `${field.label} is not valid`
|
|
45
|
+
};
|
|
46
|
+
} catch {
|
|
47
|
+
// Silently ignore an invalid regex source coming from the CMS so a
|
|
48
|
+
// bad rule can't break the entire form.
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return rules;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
//# sourceMappingURL=buildFieldRules.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/buildFieldRules.ts"],"sourcesContent":["import type { RegisterOptions } from 'react-hook-form';\nimport type { BaseFieldBlock } from '../types.js';\n\n/**\n * Subset of RHF's `RegisterOptions` we populate from admin-configured rules.\n * Picking a subset avoids TypeScript collisions with the discriminated union\n * branches of the full `RegisterOptions` type (e.g. `valueAsNumber` /\n * `valueAsDate` clobber `pattern`).\n */\nexport type FieldRules = Pick<\n RegisterOptions,\n 'required' | 'min' | 'max' | 'minLength' | 'maxLength' | 'pattern'\n>;\n\n/**\n * Translate a field block's admin-configured `validation` group into RHF\n * `register(..., rules)` options. Returns an empty object when the field has\n * no rules — safe to spread into `register` unconditionally.\n *\n * Use with text-shaped fields (text, email, phone, textarea, select). Numeric\n * fields receive `min`/`max` rules; multi-counter fields should compose this\n * with a custom `validate` callback for total-based limits.\n */\nexport function buildFieldRules(\n field: Pick<BaseFieldBlock, 'label' | 'required' | 'validation'>,\n requiredOverride?: boolean\n): FieldRules {\n const v = field.validation ?? {};\n const rules: FieldRules = {};\n\n const required = requiredOverride ?? field.required;\n if (required) {\n rules.required = v.requiredMessage ?? `${field.label} is required`;\n }\n\n if (typeof v.minLength === 'number') {\n rules.minLength = {\n value: v.minLength,\n message: `${field.label} must be at least ${v.minLength} characters`,\n };\n }\n\n if (typeof v.maxLength === 'number') {\n rules.maxLength = {\n value: v.maxLength,\n message: `${field.label} must be at most ${v.maxLength} characters`,\n };\n }\n\n if (typeof v.min === 'number') {\n rules.min = {\n value: v.min,\n message: v.minMessage ?? `${field.label} must be ≥ ${v.min}`,\n };\n }\n\n if (typeof v.max === 'number') {\n rules.max = {\n value: v.max,\n message: v.maxMessage ?? `${field.label} must be ≤ ${v.max}`,\n };\n }\n\n if (v.pattern) {\n try {\n rules.pattern = {\n value: new RegExp(v.pattern),\n message: v.patternMessage ?? `${field.label} is not valid`,\n };\n } catch {\n // Silently ignore an invalid regex source coming from the CMS so a\n // bad rule can't break the entire form.\n }\n }\n\n return rules;\n}\n"],"names":["buildFieldRules","field","requiredOverride","v","validation","rules","required","requiredMessage","label","minLength","value","message","maxLength","min","minMessage","max","maxMessage","pattern","RegExp","patternMessage"],"mappings":"AAcA;;;;;;;;CAQC,GACD,OAAO,SAASA,gBACdC,KAAgE,EAChEC,gBAA0B;IAE1B,MAAMC,IAAIF,MAAMG,UAAU,IAAI,CAAC;IAC/B,MAAMC,QAAoB,CAAC;IAE3B,MAAMC,WAAWJ,oBAAoBD,MAAMK,QAAQ;IACnD,IAAIA,UAAU;QACZD,MAAMC,QAAQ,GAAGH,EAAEI,eAAe,IAAI,GAAGN,MAAMO,KAAK,CAAC,YAAY,CAAC;IACpE;IAEA,IAAI,OAAOL,EAAEM,SAAS,KAAK,UAAU;QACnCJ,MAAMI,SAAS,GAAG;YAChBC,OAAOP,EAAEM,SAAS;YAClBE,SAAS,GAAGV,MAAMO,KAAK,CAAC,kBAAkB,EAAEL,EAAEM,SAAS,CAAC,WAAW,CAAC;QACtE;IACF;IAEA,IAAI,OAAON,EAAES,SAAS,KAAK,UAAU;QACnCP,MAAMO,SAAS,GAAG;YAChBF,OAAOP,EAAES,SAAS;YAClBD,SAAS,GAAGV,MAAMO,KAAK,CAAC,iBAAiB,EAAEL,EAAES,SAAS,CAAC,WAAW,CAAC;QACrE;IACF;IAEA,IAAI,OAAOT,EAAEU,GAAG,KAAK,UAAU;QAC7BR,MAAMQ,GAAG,GAAG;YACVH,OAAOP,EAAEU,GAAG;YACZF,SAASR,EAAEW,UAAU,IAAI,GAAGb,MAAMO,KAAK,CAAC,WAAW,EAAEL,EAAEU,GAAG,EAAE;QAC9D;IACF;IAEA,IAAI,OAAOV,EAAEY,GAAG,KAAK,UAAU;QAC7BV,MAAMU,GAAG,GAAG;YACVL,OAAOP,EAAEY,GAAG;YACZJ,SAASR,EAAEa,UAAU,IAAI,GAAGf,MAAMO,KAAK,CAAC,WAAW,EAAEL,EAAEY,GAAG,EAAE;QAC9D;IACF;IAEA,IAAIZ,EAAEc,OAAO,EAAE;QACb,IAAI;YACFZ,MAAMY,OAAO,GAAG;gBACdP,OAAO,IAAIQ,OAAOf,EAAEc,OAAO;gBAC3BN,SAASR,EAAEgB,cAAc,IAAI,GAAGlB,MAAMO,KAAK,CAAC,aAAa,CAAC;YAC5D;QACF,EAAE,OAAM;QACN,mEAAmE;QACnE,wCAAwC;QAC1C;IACF;IAEA,OAAOH;AACT"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/buildFormURL.ts"],"sourcesContent":["export function buildFormURL({\n baseUrl,\n slug,\n formsSlug = 'form-data',\n}: {\n baseUrl?: string;\n slug: string;\n formsSlug?: string;\n}): string {\n const path = `/api/${formsSlug}/${slug}`;\n return baseUrl ? new URL(path, baseUrl).toString() : path;\n}\n"],"names":["buildFormURL","baseUrl","slug","formsSlug","path","URL","toString"],"mappings":"AAAA,OAAO,SAASA,aAAa,EAC3BC,OAAO,EACPC,IAAI,EACJC,YAAY,WAAW,EAKxB;IACC,MAAMC,OAAO,CAAC,KAAK,EAAED,UAAU,CAAC,EAAED,MAAM;IACxC,OAAOD,UAAU,IAAII,IAAID,MAAMH,SAASK,QAAQ,KAAKF;AACvD"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { FormDocument, FormStep } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Build the list of steps shown in the progress indicator.
|
|
4
|
+
*
|
|
5
|
+
* This is intentionally separate from the navigable steps used by
|
|
6
|
+
* `useEnquiryForm` (which come from `normalizeFormSteps`). When a multi-stage
|
|
7
|
+
* form enables a confirmation stage, a synthetic, non-navigable stage is
|
|
8
|
+
* appended so the indicator can show the post-submit confirmation screen as a
|
|
9
|
+
* final step — without adding an extra empty page or moving the Submit button.
|
|
10
|
+
*
|
|
11
|
+
* Pass the current form `values` so that steps hidden by a visibility rule are
|
|
12
|
+
* excluded from the indicator, keeping it in sync with the actual navigation
|
|
13
|
+
* path.
|
|
14
|
+
*/
|
|
15
|
+
export declare function buildIndicatorSteps(form: FormDocument, values?: Record<string, unknown>): FormStep[];
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { getVisibleSteps } from './conditions/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Build the list of steps shown in the progress indicator.
|
|
4
|
+
*
|
|
5
|
+
* This is intentionally separate from the navigable steps used by
|
|
6
|
+
* `useEnquiryForm` (which come from `normalizeFormSteps`). When a multi-stage
|
|
7
|
+
* form enables a confirmation stage, a synthetic, non-navigable stage is
|
|
8
|
+
* appended so the indicator can show the post-submit confirmation screen as a
|
|
9
|
+
* final step — without adding an extra empty page or moving the Submit button.
|
|
10
|
+
*
|
|
11
|
+
* Pass the current form `values` so that steps hidden by a visibility rule are
|
|
12
|
+
* excluded from the indicator, keeping it in sync with the actual navigation
|
|
13
|
+
* path.
|
|
14
|
+
*/ export function buildIndicatorSteps(form, values = {}) {
|
|
15
|
+
const steps = getVisibleSteps(form.steps ?? [], values);
|
|
16
|
+
const stage = form.confirmationStage;
|
|
17
|
+
// Only meaningful when there's more than one stage to indicate.
|
|
18
|
+
if (steps.length > 1 && stage?.enabled) {
|
|
19
|
+
const icon = stage.icon ?? null;
|
|
20
|
+
return [
|
|
21
|
+
...steps,
|
|
22
|
+
{
|
|
23
|
+
completedIcon: icon,
|
|
24
|
+
fields: [],
|
|
25
|
+
icon,
|
|
26
|
+
title: stage.label?.trim() || 'Confirmation'
|
|
27
|
+
}
|
|
28
|
+
];
|
|
29
|
+
}
|
|
30
|
+
return steps;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=buildIndicatorSteps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/buildIndicatorSteps.ts"],"sourcesContent":["import type { FormDocument, FormStep } from '../types.js';\nimport { getVisibleSteps } from './conditions/index.js';\n\n/**\n * Build the list of steps shown in the progress indicator.\n *\n * This is intentionally separate from the navigable steps used by\n * `useEnquiryForm` (which come from `normalizeFormSteps`). When a multi-stage\n * form enables a confirmation stage, a synthetic, non-navigable stage is\n * appended so the indicator can show the post-submit confirmation screen as a\n * final step — without adding an extra empty page or moving the Submit button.\n *\n * Pass the current form `values` so that steps hidden by a visibility rule are\n * excluded from the indicator, keeping it in sync with the actual navigation\n * path.\n */\nexport function buildIndicatorSteps(\n form: FormDocument,\n values: Record<string, unknown> = {}\n): FormStep[] {\n const steps = getVisibleSteps(form.steps ?? [], values);\n const stage = form.confirmationStage;\n\n // Only meaningful when there's more than one stage to indicate.\n if (steps.length > 1 && stage?.enabled) {\n const icon = stage.icon ?? null;\n return [\n ...steps,\n {\n completedIcon: icon,\n fields: [],\n icon,\n title: stage.label?.trim() || 'Confirmation',\n },\n ];\n }\n\n return steps;\n}\n"],"names":["getVisibleSteps","buildIndicatorSteps","form","values","steps","stage","confirmationStage","length","enabled","icon","completedIcon","fields","title","label","trim"],"mappings":"AACA,SAASA,eAAe,QAAQ,wBAAwB;AAExD;;;;;;;;;;;;CAYC,GACD,OAAO,SAASC,oBACdC,IAAkB,EAClBC,SAAkC,CAAC,CAAC;IAEpC,MAAMC,QAAQJ,gBAAgBE,KAAKE,KAAK,IAAI,EAAE,EAAED;IAChD,MAAME,QAAQH,KAAKI,iBAAiB;IAEpC,gEAAgE;IAChE,IAAIF,MAAMG,MAAM,GAAG,KAAKF,OAAOG,SAAS;QACtC,MAAMC,OAAOJ,MAAMI,IAAI,IAAI;QAC3B,OAAO;eACFL;YACH;gBACEM,eAAeD;gBACfE,QAAQ,EAAE;gBACVF;gBACAG,OAAOP,MAAMQ,KAAK,EAAEC,UAAU;YAChC;SACD;IACH;IAEA,OAAOV;AACT"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Path segment (under Payload's `/api`) for the form-submit endpoint.
|
|
2
|
+
* Shared by the endpoint registration (see `formPlugin`) and the client so the
|
|
3
|
+
* two can never drift. */
|
|
4
|
+
export declare const FORM_SUBMIT_PATH = "form-submit";
|
|
5
|
+
/** Build the URL the client POSTs a submission to. Mirrors the registered
|
|
6
|
+
* endpoint at `/api/${FORM_SUBMIT_PATH}/:formSlug`. */
|
|
7
|
+
export declare function buildSubmitURL({ apiBase, formSlug, submitPath, }: {
|
|
8
|
+
apiBase?: string;
|
|
9
|
+
formSlug: string;
|
|
10
|
+
submitPath?: string;
|
|
11
|
+
}): string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Path segment (under Payload's `/api`) for the form-submit endpoint.
|
|
2
|
+
* Shared by the endpoint registration (see `formPlugin`) and the client so the
|
|
3
|
+
* two can never drift. */ export const FORM_SUBMIT_PATH = 'form-submit';
|
|
4
|
+
/** Build the URL the client POSTs a submission to. Mirrors the registered
|
|
5
|
+
* endpoint at `/api/${FORM_SUBMIT_PATH}/:formSlug`. */ export function buildSubmitURL({ apiBase = '', formSlug, submitPath = FORM_SUBMIT_PATH }) {
|
|
6
|
+
return `${apiBase}/api/${submitPath}/${formSlug}`;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
//# sourceMappingURL=buildSubmitURL.js.map
|