0.76.5 • Published 2 months ago
@htmlbricks/hb-form-contact
Licence
—
Version
0.76.5
Deps
0
Size
732 kB
Vulns
0
Weekly
0
hb-form-contact
Category: forms · Tags: forms, contact
Summary
Opinionated contact form: JSON informations toggles fields; the component builds an hb-form schema at runtime. Optional privacy_policy checkbox and captcha (reCAPTCHA v2 invisible) before dispatching formContactSubmit or formContactSubmitWithCaptcha.
What it does
- Parse:
informations,privacy_policy,captchaas JSON strings in$effect. - Schema: Derived
schemaarray — name, email, phone, subject, message in order when keys exist; privacy row uses idpolicy. - Submit: On valid
hb-formsubmit, ifcaptcha.siteKey→ mount captcha child; elseformContactSubmit. After v2 response →formContactSubmitWithCaptchawithresponseandtype: "recaptcha-v2-invisible".
Custom element
hb-form-contact
Attributes
| Attribute | Type (logical) | HTML / notes |
|---|---|---|
id |
string (optional) |
Host id. |
style |
string (optional) |
In typings; not read in script. |
informations |
string | object |
Which fields exist and required / label / placeholder / value. Non-object → no form. |
privacy_policy |
string | object |
Needs input for label; optional link, policyId, required. |
captcha |
string | object |
siteKey + type (googlev_recaptchav2_invisible | googlev_recaptchav3); v3 type is typed but UI uses v2 invisible when siteKey is set. |
Custom events
| Event name | detail shape |
|---|---|
formContactSubmit |
{ _valid: boolean; values: Record<string, string | number | boolean> } — no captcha path. |
formContactSubmitWithCaptcha |
Same as above plus response: string and optional type ("recaptcha-v2-invisible"). |
Styling
CSS custom properties (extra/docs.ts)
| Variable | Role |
|---|---|
--bulma-block-spacing |
Vertical rhythm around the form (default 1.5rem in metadata). |
CSS parts / slots
None.
TypeScript
types/webcomponent.type.d.ts — Component, Events.
Dependencies
hb-form, hb-captcha-google-recaptcha-v2-invisible (when captcha used).
Minimal HTML example
<hb-form-contact
informations='{"email":{"required":true},"message":{}}'
privacy_policy='{"input":"I agree to the privacy policy","required":true}'
></hb-form-contact>