Download the PHP package uams-web/statamic-alpine-csp-forms without Composer
On this page you can find all versions of the php package uams-web/statamic-alpine-csp-forms. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download uams-web/statamic-alpine-csp-forms
More information about uams-web/statamic-alpine-csp-forms
Files in uams-web/statamic-alpine-csp-forms
Package statamic-alpine-csp-forms
Short Description CSP-safe Alpine form JavaScript driver for Statamic public forms, with its browser-side field-conditions evaluator.
License MIT
Homepage https://github.com/UAMS-Web/statamic-alpine-csp-forms
Informations about the package statamic-alpine-csp-forms
Alpine CSP Forms
A Statamic add-on that gives public forms a JavaScript driver safe under a Content Security Policy without 'unsafe-eval'. It registers the alpine_csp form JS driver, and ships the browser-side field-conditions evaluator the driver's output calls.
Statamic's stock alpine driver emits attribute expressions that the @alpinejs/csp build refuses to evaluate, so every conditional field on a public form fails to render. alpine_csp re-renders the two expressions that matter, and the add-on's front-end script supplies the $showField Alpine magic they call. If Statamic ships a CSP-safe driver of its own, removing this add-on returns the site to the stock driver.
Releases are 0.x pre-releases until 1.0.0: a minor release can carry a breaking change, and its release notes call it out first with the action to take.
Requirements
PHP 8.4 or later and Statamic 6.35 or later. The host loads Alpine itself, using the @alpinejs/csp build.
Installation
The add-on's service provider is discovered by Statamic and registers the driver under the handle alpine_csp. Statamic publishes the front-end script to public/vendor/statamic-alpine-csp-forms/frontend/alpine-csp.js after the install; php artisan vendor:publish --tag=statamic-alpine-csp-forms --force republishes it.
Usage
Select the driver on the form tag. The scoped form is unchanged:
Load the front-end script before the host's own Alpine bundle starts. As classic deferred scripts the two run in document order:
The script registers the $showField magic when Alpine dispatches alpine:init, so the host has to set window.Alpine before it calls Alpine.start(). A host that bundles the evaluator instead can import registerShowFieldMagic from resources/js/alpine-csp.js and call it with its Alpine instance.
Development
Developing against a host application is covered in the submission checklist. npm run build writes both the Control Panel build and the front-end script to resources/dist, which is committed.
License
MIT. See LICENSE.