commit 8fe27cfa5eadf9a87f4403bf8080cc95132b29e9
Author: Meghdad <61308304+MeghdadFadaee@users.noreply.github.com>
Date: Fri Jul 10 04:20:13 2026 +0330
init
diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..83e8576
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,15 @@
+root = true
+
+[*]
+charset = utf-8
+end_of_line = lf
+indent_style = space
+indent_size = 4
+insert_final_newline = true
+trim_trailing_whitespace = true
+
+[*.{json,md,yml,yaml}]
+indent_size = 2
+
+[*.md]
+trim_trailing_whitespace = false
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..c8916a9
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,14 @@
+* text=auto
+
+/.codex export-ignore
+/.cursor export-ignore
+/.github export-ignore
+/.idea export-ignore
+/.nova export-ignore
+/.phpunit.cache export-ignore
+/.vscode export-ignore
+/.zed export-ignore
+/node_modules export-ignore
+/tests export-ignore
+/vendor export-ignore
+/phpunit.xml.dist export-ignore
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..81ef9ef
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,30 @@
+*.log
+.DS_Store
+.env
+.env.backup
+.env.production
+.phpactor.json
+.phpunit.result.cache
+/.codex
+/.cursor/
+/.idea
+/.nova
+/.phpunit.cache
+/.vscode
+/.zed
+/auth.json
+/composer.lock
+/node_modules
+/public/build
+/public/fonts-manifest.dev.json
+/public/hot
+/public/storage
+/storage/*.key
+/storage/pail
+/vendor
+_ide_helper.php
+Homestead.json
+Homestead.yaml
+Thumbs.db
+screenshots/
+packages/
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000..39d2eb6
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,20 @@
+# Changelog
+
+All notable changes to `nova-form-card` will be documented in this file.
+
+## 0.1.0 - 2026-07-10
+
+- Initial standalone Laravel Nova 5 form card package.
+- Added `FormCard`, `FormFields`, signed submit tokens, package routes, submit controller, and structured responses.
+- Added Nova-native rendering and submission for supported form fields, including text, choice, date, upload, password, color, code, key-value, and display-only fields.
+- Added Nova `dependsOn()` sync support, validation errors, loading/disabled submit states, custom submit text, `canSee()`, and `authorizedToSubmit()`.
+- Added translatable backend PHP messages and Nova frontend JSON messages.
+- Added Vite-built Nova card assets and card styling fixes for Nova detail/display components.
+- Added concise README, full documentation, demo screenshot, minimal example card, and full demo card.
+- Added Pest coverage for serialization, authorization, validation, successful submit, failed submit, uploads, dependent fields, password confirmation, and response formatting.
+
+### Notes
+
+- Unsupported in this release: `Trix`, `Markdown`, `Repeater`, Vapor fields, relationship fields, and custom fields.
+- Display-only fields render but are not validated or submitted.
+- File-like fields are passed to `handle()` as `UploadedFile` instances; storage is handled by the card author.
diff --git a/LICENSE.md b/LICENSE.md
new file mode 100644
index 0000000..9ef4933
--- /dev/null
+++ b/LICENSE.md
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2026 MeghdadFadaee
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..dd1d00b
--- /dev/null
+++ b/README.md
@@ -0,0 +1,93 @@
+# Nova Form Card
+
+Submit-capable Laravel Nova 5 cards powered by standard Nova fields.
+
+`nova-form-card` gives Nova cards an Action-like flow: define fields, validate input, submit to a card endpoint, run `handle()`, and return a structured response.
+
+
+
+## Why
+
+Nova cards are great for dashboards, but they are usually display-only. This package lets you build reusable form cards without creating a Nova resource page or a custom tool.
+
+## Features
+
+- Use native Nova fields inside a card
+- Submit data to a package route
+- Validate with Nova field `rules()` / `creationRules()`
+- Receive values through `FormFields`
+- Show validation errors beside fields
+- Support `dependsOn()`, uploads, loading state, custom submit text, and authorization
+- Return success, error, redirect, or refresh responses
+- Render display-only Nova fields such as `Badge`, `Heading`, `Stack`, `Status`, and `Sparkline`
+
+## Requirements
+
+- PHP `^8.2`
+- Laravel `^11|^12|^13`
+- Laravel Nova `^5`
+
+## Installation
+
+```bash
+composer require meghdadfadaee/nova-form-card
+```
+
+Laravel auto-discovers the service provider.
+
+Optional publishes:
+
+```bash
+php artisan vendor:publish --tag=nova-form-card-config
+php artisan vendor:publish --tag=nova-form-card-translations
+```
+
+## Quick Look
+
+```php
+class InviteUserCard extends FormCard
+{
+ public function fields(NovaRequest $request): array
+ {
+ return [
+ Text::make(__('Email'))->rules('required', 'email'),
+ ];
+ }
+
+ public function handle(FormFields $fields, NovaRequest $request): mixed
+ {
+ return static::message(__('Invitation sent.'));
+ }
+}
+```
+
+Register it anywhere Nova accepts cards.
+
+```php
+public function cards(NovaRequest $request): array
+{
+ return [
+ new InviteUserCard(),
+ ];
+}
+```
+
+## Documentation
+
+Read the full documentation in [docs/documentation.md](docs/documentation.md).
+
+Useful files:
+
+- [Minimal card example](examples/InviteUserCard.php)
+- [Full demo card](examples/NovaFormCardDemo.php)
+
+## Testing
+
+```bash
+composer install
+vendor/bin/pest
+```
+
+## License
+
+Nova Form Card is open-sourced software licensed under the [MIT license](LICENSE.md).
diff --git a/bin/copy-css.mjs b/bin/copy-css.mjs
new file mode 100644
index 0000000..f818597
--- /dev/null
+++ b/bin/copy-css.mjs
@@ -0,0 +1,4 @@
+import { copyFile, mkdir } from 'node:fs/promises'
+
+await mkdir('dist/css', { recursive: true })
+await copyFile('resources/css/card.css', 'dist/css/card.css')
diff --git a/composer.json b/composer.json
new file mode 100644
index 0000000..bd18953
--- /dev/null
+++ b/composer.json
@@ -0,0 +1,74 @@
+{
+ "name": "meghdadfadaee/nova-form-card",
+ "description": "Submit-capable Laravel Nova 5 cards built with standard Nova fields.",
+ "type": "library",
+ "keywords": [
+ "laravel",
+ "nova",
+ "nova-card",
+ "form",
+ "card"
+ ],
+ "homepage": "https://github.com/MeghdadFadaee/nova-form-card",
+ "license": "MIT",
+ "authors": [
+ {
+ "name": "MeghdadFadaee"
+ }
+ ],
+ "support": {
+ "issues": "https://github.com/MeghdadFadaee/nova-form-card/issues",
+ "source": "https://github.com/MeghdadFadaee/nova-form-card"
+ },
+ "require": {
+ "php": "^8.2",
+ "illuminate/contracts": "^11.0|^12.0|^13.0",
+ "illuminate/http": "^11.0|^12.0|^13.0",
+ "illuminate/routing": "^11.0|^12.0|^13.0",
+ "illuminate/support": "^11.0|^12.0|^13.0",
+ "illuminate/validation": "^11.0|^12.0|^13.0",
+ "laravel/nova": "^5.0"
+ },
+ "require-dev": {
+ "nunomaduro/collision": "^8.0|^9.0|^10.0",
+ "orchestra/testbench": "^9.0|^10.0|^11.0",
+ "pestphp/pest": "^3.0|^4.0",
+ "pestphp/pest-plugin-laravel": "^3.0|^4.0"
+ },
+ "repositories": [
+ {
+ "type": "artifact",
+ "url": "packages"
+ }
+ ],
+ "autoload": {
+ "psr-4": {
+ "MeghdadFadaee\\NovaFormCard\\": "src/"
+ }
+ },
+ "autoload-dev": {
+ "psr-4": {
+ "MeghdadFadaee\\NovaFormCard\\Tests\\": "tests/"
+ }
+ },
+ "scripts": {
+ "test": "vendor/bin/pest",
+ "test:feature": "vendor/bin/pest --testsuite=Feature",
+ "test:unit": "vendor/bin/pest --testsuite=Unit"
+ },
+ "extra": {
+ "laravel": {
+ "providers": [
+ "MeghdadFadaee\\NovaFormCard\\FormCardServiceProvider"
+ ]
+ }
+ },
+ "config": {
+ "sort-packages": true,
+ "allow-plugins": {
+ "pestphp/pest-plugin": true
+ }
+ },
+ "minimum-stability": "stable",
+ "prefer-stable": true
+}
diff --git a/config/nova-form-card.php b/config/nova-form-card.php
new file mode 100644
index 0000000..bb38d3f
--- /dev/null
+++ b/config/nova-form-card.php
@@ -0,0 +1,27 @@
+ 'nova-vendor/nova-form-card',
+
+ /*
+ |--------------------------------------------------------------------------
+ | Submit Token TTL
+ |--------------------------------------------------------------------------
+ |
+ | A signed token is embedded when a card is serialized. The submit route
+ | requires this token before it will instantiate and run a form card.
+ |
+ */
+
+ 'token_ttl_minutes' => 120,
+];
diff --git a/dist/css/card.css b/dist/css/card.css
new file mode 100644
index 0000000..dfe4ca2
--- /dev/null
+++ b/dist/css/card.css
@@ -0,0 +1,72 @@
+.nova-form-card {
+ overflow: hidden;
+}
+
+.nova-form-card__form {
+ display: flex;
+ flex-direction: column;
+ min-height: 100%;
+}
+
+.nova-form-card__header {
+ border-bottom: 1px solid rgba(229, 231, 235, 1);
+ padding: 1rem 1.5rem;
+}
+
+.dark .nova-form-card__header {
+ border-bottom-color: rgba(55, 65, 81, 1);
+}
+
+.nova-form-card__title {
+ font-size: 1rem;
+ font-weight: 700;
+ line-height: 1.5rem;
+ margin: 0;
+}
+
+.nova-form-card__fieldset {
+ border: 0;
+ margin: 0;
+ min-width: 0;
+ padding: 0;
+}
+
+.nova-form-card__body {
+ padding: 0.75rem 0;
+}
+
+.nova-form-card__display-field {
+ padding-left: 1.5rem;
+ padding-right: 1.5rem;
+}
+
+.nova-form-card__footer {
+ align-items: center;
+ border-top: 1px solid rgba(229, 231, 235, 1);
+ display: flex;
+ justify-content: flex-end;
+ padding: 1rem 1.5rem;
+}
+
+.dark .nova-form-card__footer {
+ border-top-color: rgba(55, 65, 81, 1);
+}
+
+.nova-form-card__fallback-submit {
+ align-items: center;
+ background-color: rgb(14, 165, 233);
+ border-radius: 0.25rem;
+ color: #fff;
+ cursor: pointer;
+ display: inline-flex;
+ font-size: 0.875rem;
+ font-weight: 700;
+ height: 2.25rem;
+ justify-content: center;
+ padding: 0 0.75rem;
+}
+
+.nova-form-card__fallback-submit:disabled {
+ cursor: not-allowed;
+ opacity: 0.65;
+}
diff --git a/dist/js/card.js b/dist/js/card.js
new file mode 100644
index 0000000..fa9a83f
--- /dev/null
+++ b/dist/js/card.js
@@ -0,0 +1 @@
+(function(t){"use strict";const d=(r,e)=>{const o=r.__vccOpts||r;for(const[c,i]of e)o[c]=i;return o};class l{constructor(e={}){this.record(e)}all(){return this.errors}has(e){return e?Object.prototype.hasOwnProperty.call(this.errors,e)||Object.keys(this.errors).some(o=>o.startsWith(`${e}.`)||o.startsWith(`${e}[`)):!1}first(e){return this.get(e)[0]}get(e){return this.errors[e]||[]}record(e={}){this.errors=e}clear(e=null){if(!e){this.errors={};return}Object.keys(this.errors).filter(o=>o===e||o.startsWith(`${e}.`)||o.startsWith(`${e}[`)).forEach(o=>delete this.errors[o])}}function m(){return typeof LaravelNova<"u"&&LaravelNova.Errors?LaravelNova.Errors:l}function a(r={}){const e=m();return new e(r)}const u={provide(){return{removeFile:this.removeFile}},props:{card:{type:Object,required:!0}},data(){return{fields:[],errors:a(),processing:!1,formUniqueId:`nova-form-card-${Math.random().toString(36).slice(2)}`}},computed:{form(){return this.card.formCard||{}},resourceName(){return this.card.resourceName||this.form.resourceName||"nova-form-card"},resourceId(){return this.card.resourceId||this.form.resourceId||"form-card"},resource(){return this.form.resource||{}},submitText(){return this.form.submitText||this.translate("nova-form-card.submit","Submit")},loadingText(){return this.translate("nova-form-card.submitting","Submitting...")},canSubmit(){return this.form.canSubmit!==!1},submitDisabled(){return this.processing||!this.canSubmit},syncEndpoint(){if(!this.form.syncEndpoint||!this.form.token)return;const r=this.form.syncEndpoint.includes("?")?"&":"?";return`${this.form.syncEndpoint}${r}token=${encodeURIComponent(this.form.token)}`},buttonComponent(){return this.resolveNovaUi("Button")||"button"},hasNovaButton(){return this.buttonComponent!=="button"},buttonText(){return this.processing&&!this.hasNovaButton?this.loadingText:this.submitText},validationErrors(){return this.errors}},created(){this.syncFields()},watch:{"card.formCard.fields":{deep:!0,handler(){this.syncFields()}}},methods:{syncFields(){this.fields=(this.form.fields||[]).map(r=>({...r}))},componentName(r){return r.prefixComponent===!1?r.component:r.displayOnly?r.component==="line-field"?`index-${r.component}`:`detail-${r.component}`:`form-${r.component}`},fieldComponent(r){const e=this.componentName(r);return this.resolveNovaComponent(e)||e},fieldWrapperClass(r){return{"nova-form-card__display-field":r.displayOnly}},resolveNovaComponent(r){const e=typeof Nova<"u"?Nova.app?._context?.components:null,o=this.$?.appContext?.components||e||{};return o[r]||o[this.camelize(r)]||o[this.upperFirst(this.camelize(r))]},resolveNovaUi(r){return typeof LaravelNovaUi<"u"?LaravelNovaUi[r]:null},camelize(r){return String(r).replace(/-(\w)/g,(e,o)=>o.toUpperCase())},upperFirst(r){return r=String(r),r.charAt(0).toUpperCase()+r.slice(1)},clearFieldError(r){const e=r.validationKey||r.attribute;e&&this.errors&&typeof this.errors.clear=="function"&&this.errors.clear(e)},formDataFromFields(){const r=new FormData;return this.fields.forEach(e=>{if(!e.displayOnly){if(typeof e.fill=="function"){e.fill(r);return}r.append(e.attribute,e.value??"")}}),r},submissionPayload(){const r=new FormData;return r.append("token",this.form.token),this.formDataFromFields().forEach((e,o)=>{r.append(`fields[${o}]`,e)}),r},submit(){this.submitDisabled||(this.processing=!0,this.errors=a(),Nova.request().post(this.form.endpoint,this.submissionPayload()).then(r=>{this.handleResponse(r.data||{})}).catch(r=>{const e=r.response||{};if(e.status===422){this.errors=a(e.data?.errors||{});return}Nova.error(e.data?.message||this.couldNotSubmitMessage())}).finally(()=>{this.processing=!1}))},removeFile(){return Nova.error(this.translate("nova-form-card.could_not_submit","The form could not be submitted.")),Promise.reject(new Error("Form cards do not delete existing files."))},handleResponse(r){if(r.type==="error"){Nova.error(r.message||this.couldNotSubmitMessage());return}if(r.message&&Nova.success(r.message),r.type==="redirect"&&r.redirect?.url){const e=r.redirect;if(e.remote){Nova.visit({url:e.url,remote:!0});return}Nova.visit(e.url,e.options||{});return}r.refresh&&this.refreshPage()},refreshPage(){if(typeof Nova.visit=="function"){Nova.visit(window.location.pathname+window.location.search,{preserveScroll:!0});return}window.location.reload()},couldNotSubmitMessage(){return this.translate("nova-form-card.could_not_submit","The form could not be submitted.")},translate(r,e){if(typeof this.__=="function"){const o=this.__(r);return o===r?e:o}if(typeof window<"u"&&typeof window.__=="function"){const o=window.__(r);return o===r?e:o}if(typeof Nova<"u"&&typeof Nova.__=="function"){const o=Nova.__(r);return o===r?e:o}return e}}},f={class:"nova-form-card bg-white dark:bg-gray-800 rounded-lg shadow"},h={key:0,class:"nova-form-card__header"},p={class:"nova-form-card__title"},b=["disabled"],_={key:0,class:"nova-form-card__body"},y={class:"nova-form-card__footer"};function v(r,e,o,c,i,s){return t.openBlock(),t.createElementBlock("div",f,[t.createElementVNode("form",{class:"nova-form-card__form",onSubmit:e[0]||(e[0]=t.withModifiers((...n)=>s.submit&&s.submit(...n),["prevent"])),autocomplete:"off"},[s.form.title?(t.openBlock(),t.createElementBlock("div",h,[t.createElementVNode("h3",p,t.toDisplayString(s.form.title),1)])):t.createCommentVNode("",!0),t.createElementVNode("fieldset",{class:"nova-form-card__fieldset",disabled:s.submitDisabled},[i.fields.length?(t.openBlock(),t.createElementBlock("div",_,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(i.fields,(n,g)=>(t.openBlock(),t.createElementBlock("div",{key:n.uniqueKey||n.attribute,class:t.normalizeClass(s.fieldWrapperClass(n))},[(t.openBlock(),t.createBlock(t.resolveDynamicComponent(s.fieldComponent(n)),{index:g,resource:s.resource,"resource-name":s.resourceName,"resource-id":s.resourceId,field:n,errors:s.validationErrors,"form-unique-id":i.formUniqueId,"show-help-text":!0,"sync-endpoint":s.syncEndpoint,mode:"form-card",onFieldChanged:C=>s.clearFieldError(n)},null,40,["index","resource","resource-name","resource-id","field","errors","form-unique-id","sync-endpoint","onFieldChanged"]))],2))),128))])):t.createCommentVNode("",!0)],8,b),t.createElementVNode("div",y,[(t.openBlock(),t.createBlock(t.resolveDynamicComponent(s.buttonComponent),{as:"button",class:t.normalizeClass({"nova-form-card__fallback-submit":!s.hasNovaButton}),label:s.submitText,loading:i.processing,size:"large",type:"submit",variant:"solid",disabled:s.submitDisabled,onClick:t.withModifiers(s.submit,["prevent"])},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(s.buttonText),1)]),_:1},8,["class","label","loading","disabled","onClick"]))])],32)])}const N=d(u,[["render",v]]);Nova.booting(r=>{r.component("nova-form-card",N)})})(Vue);
diff --git a/docs/Screenshot.png b/docs/Screenshot.png
new file mode 100644
index 0000000..06092b9
Binary files /dev/null and b/docs/Screenshot.png differ
diff --git a/docs/documentation.md b/docs/documentation.md
new file mode 100644
index 0000000..4a63d3c
--- /dev/null
+++ b/docs/documentation.md
@@ -0,0 +1,283 @@
+# Documentation
+
+This document covers package usage, supported fields, responses, authorization, and development notes for `meghdadfadaee/nova-form-card`.
+
+## Installation
+
+```bash
+composer require meghdadfadaee/nova-form-card
+```
+
+The service provider is auto-discovered and registers:
+
+- Nova card assets from `dist/js/card.js` and `dist/css/card.css`
+- Submit route at `/nova-vendor/nova-form-card/submit`
+- Sync route for Nova `dependsOn()`
+
+Optional publishes:
+
+```bash
+php artisan vendor:publish --tag=nova-form-card-config
+php artisan vendor:publish --tag=nova-form-card-translations
+```
+
+Translations include PHP backend messages and Nova frontend JSON messages.
+
+## Creating A Card
+
+Create a class extending `MeghdadFadaee\NovaFormCard\FormCard`.
+
+```php
+rules('required', 'email'),
+ ];
+ }
+
+ public function handle(FormFields $fields, NovaRequest $request): mixed
+ {
+ // Custom submit logic...
+
+ return static::message(__('Invitation sent.'));
+ }
+}
+```
+
+Register the card anywhere Nova accepts cards:
+
+```php
+use App\Nova\Cards\InviteUserCard;
+use Laravel\Nova\Http\Requests\NovaRequest;
+
+public function cards(NovaRequest $request): array
+{
+ return [
+ new InviteUserCard(),
+ ];
+}
+```
+
+## Card API
+
+Common methods:
+
+```php
+public function title(): string;
+public function fields(NovaRequest $request): array;
+public function handle(FormFields $fields, NovaRequest $request): mixed;
+public function authorizedToSubmit(NovaRequest $request): bool;
+public function submitButtonText(): string;
+```
+
+Per-instance submit text:
+
+```php
+(new InviteUserCard())->withSubmitButtonText(__('Send Invite'));
+```
+
+## Responses
+
+Return one of the helper responses from `handle()`.
+
+```php
+return static::message(__('Saved.'));
+return static::success(__('Saved.'));
+return static::error(__('Could not save.'));
+return static::danger(__('Could not save.'));
+return static::refresh(__('Updated.'));
+return static::visit('/resources/users');
+return static::redirect('https://example.com', remote: true);
+```
+
+Other return values:
+
+- `string`: success message
+- `false`: generic error response
+- `Responsable` or Symfony `Response`: returned directly
+
+## Authorization
+
+Use Nova's `canSee()` to control whether the card is visible.
+
+```php
+(new InviteUserCard())->canSee(
+ fn (NovaRequest $request) => $request->user()->can('inviteUsers')
+);
+```
+
+Use `authorizedToSubmit()` to protect the submit endpoint.
+
+```php
+public function authorizedToSubmit(NovaRequest $request): bool
+{
+ return $request->user()->can('inviteUsers');
+}
+```
+
+The package embeds a signed token when the card is serialized and rechecks submit authorization on every request.
+
+## Validation
+
+Nova field `rules()` and `creationRules()` are applied where possible.
+
+Validation failures return HTTP `422`:
+
+```json
+{
+ "message": "The given data was invalid.",
+ "errors": {
+ "email": ["The email field must be a valid email address."]
+ }
+}
+```
+
+Errors are displayed beside matching fields in the card.
+
+## Supported Fields
+
+Submit-capable fields:
+
+`Text`, `Textarea`, `Select`, `Boolean`, `Number`, `Date`, `DateTime`, `File`, `Image`, `Avatar`, `Audio`, `Email`, `URL`, `Password`, `PasswordConfirmation`, `Hidden`, `ID`, `Currency`, `Color`, `Code`, `Country`, `Timezone`, `MultiSelect`, `BooleanGroup`, `KeyValue`, `Slug`, `Token`.
+
+Display-only fields:
+
+`Badge`, `Heading`, `Line`, `Stack`, `Sparkline`, `Status`, `Gravatar`, `UiAvatar`.
+
+Unsupported fields throw `UnsupportedFieldException` during card serialization.
+
+## Field Notes
+
+- `FormFields` extends Nova's `ActionFields`.
+- `Password` uses Nova's native fill behavior, so non-empty submitted values are hashed before they appear in `FormFields`.
+- `PasswordConfirmation` validates but does not appear in `FormFields`, matching Nova.
+- File-like fields submit as `Illuminate\Http\UploadedFile` instances. Your `handle()` method owns storage and cleanup.
+- Display-only fields render through Nova native detail/index components and are not validated or submitted.
+- `Slug` is supported as a manual field. `Slug::from()` requires Nova resource preview endpoints and is not supported.
+
+## dependsOn
+
+Nova `dependsOn()` is supported through the package sync endpoint.
+
+```php
+use Laravel\Nova\Fields\FormData;
+use Laravel\Nova\Fields\Number;
+use Laravel\Nova\Fields\Select;
+
+Select::make(__('Plan'))->options([
+ 'starter' => __('Starter'),
+ 'enterprise' => __('Enterprise'),
+]);
+
+Number::make(__('Seats'))
+ ->hide()
+ ->dependsOn(['plan'], function (Number $field, NovaRequest $request, FormData $data): void {
+ $data->get('plan') === 'enterprise'
+ ? $field->show()->rules('required', 'integer', 'min:50')
+ : $field->hide()->rules('nullable', 'integer');
+ });
+```
+
+## Demo Card
+
+The demo card at `examples/NovaFormCardDemo.php` shows:
+
+- basic fields
+- structured fields
+- display-only fields
+- uploads
+- `dependsOn()`
+- password confirmation
+- custom submit text
+- submit authorization
+- all response helpers
+
+Register it like any Nova card:
+
+```php
+use App\Nova\Cards\NovaFormCardDemo;
+
+(new NovaFormCardDemo())->width('full');
+```
+
+## Limitations
+
+Unsupported in this version:
+
+- `Trix`
+- `Markdown`
+- `Repeater`
+- Vapor fields
+- relationship fields
+- custom fields
+
+Other limits:
+
+- The package does not recreate Nova resource create/update pages.
+- Cards should be container-resolvable; per-instance constructor state is not reconstructed on submit.
+- Existing file delete/download actions are not resource-backed inside form cards.
+
+Nova does not expose a fully public API for arbitrary field rendering outside resources/actions. Nova-specific behavior is isolated in:
+
+- `MeghdadFadaee\NovaFormCard\Support\NovaFieldSerializer`
+- `MeghdadFadaee\NovaFormCard\Support\NovaFieldValidator`
+- `MeghdadFadaee\NovaFormCard\Support\NovaFieldIntrospector`
+
+## Translations
+
+Package messages are translatable. Publish translations with:
+
+```bash
+php artisan vendor:publish --tag=nova-form-card-translations
+```
+
+Card titles, field labels, and custom response messages should use your app translations:
+
+```php
+Text::make(__('Email'));
+
+return static::message(__('Invitation sent.'));
+```
+
+## Development
+
+Build assets:
+
+```bash
+npm install
+npm run build
+```
+
+Run tests:
+
+```bash
+composer install
+vendor/bin/pest
+```
+
+Before release:
+
+```bash
+composer validate --strict
+find . -name '*.php' -not -path './vendor/*' -print0 | xargs -0 -n1 php -l
+npm run build
+vendor/bin/pest
+```
+
+Nova is distributed from Laravel's private Composer repository, so local and CI environments need valid Nova credentials.
diff --git a/examples/InviteUserCard.php b/examples/InviteUserCard.php
new file mode 100644
index 0000000..5ede808
--- /dev/null
+++ b/examples/InviteUserCard.php
@@ -0,0 +1,31 @@
+rules('required', 'email'),
+ ];
+ }
+
+ public function handle(FormFields $fields, NovaRequest $request): mixed
+ {
+ // InviteUser::dispatch($fields->email);
+
+ return static::message(__('Invitation sent.'));
+ }
+}
diff --git a/examples/NovaFormCardDemo.php b/examples/NovaFormCardDemo.php
new file mode 100644
index 0000000..25019e4
--- /dev/null
+++ b/examples/NovaFormCardDemo.php
@@ -0,0 +1,269 @@
+user() !== null;
+ }
+
+ public function fields(NovaRequest $request): array
+ {
+ return [
+ Heading::make(__('Package Status')),
+
+ Badge::make(__('Health'))->map([
+ 'ready' => 'success',
+ ])->labels([
+ 'ready' => __('Ready'),
+ ])->default('ready'),
+
+ Status::make(__('Queue'))->loadingWhen([
+ 'waiting',
+ ])->failedWhen([
+ 'failed',
+ ])->default('processed'),
+
+ Line::make(__('Build'))->asSmall()->default(__('Using Nova native field components')),
+
+ Stack::make(__('Snapshot'), [
+ Line::make(__('Fields'))->asHeading()->default(__('Inputs, uploads, display fields')),
+ Line::make(__('Submit'))->default(__('Validation, loading state, and structured responses')),
+ ]),
+
+ Sparkline::make(__('Activity'))->data([2, 4, 3, 7, 6, 9, 11])->height(48),
+
+ Gravatar::make(__('User Gravatar'), 'demo_gravatar_email')
+ ->default($request->user()?->email ?? 'demo@example.com'),
+
+ UiAvatar::make(__('User Initials'), 'demo_avatar_name')
+ ->default($request->user()?->name ?? 'Nova User'),
+
+ Heading::make(__('Basic Inputs')),
+
+ Text::make(__('Name'))
+ ->default($request->user()?->name ?? __('Ada Lovelace'))
+ ->rules('required', 'string', 'max:255'),
+
+ Email::make(__('Email'))
+ ->default($request->user()?->email ?? 'ada@example.com')
+ ->rules('required', 'email'),
+
+ URL::make(__('Website'))
+ ->default('https://example.com')
+ ->rules('nullable', 'url'),
+
+ Textarea::make(__('Notes'))
+ ->alwaysShow()
+ ->rules('nullable', 'string', 'max:1000'),
+
+ Select::make(__('Plan'))
+ ->options([
+ 'starter' => __('Starter'),
+ 'growth' => __('Growth'),
+ 'enterprise' => __('Enterprise'),
+ ])
+ ->displayUsingLabels()
+ ->default('growth')
+ ->rules('required', 'in:starter,growth,enterprise'),
+
+ Number::make(__('Enterprise Seats'), 'enterprise_seats')
+ ->hide()
+ ->min(50)
+ ->step(1)
+ ->dependsOn(['plan'], function (Number $field, NovaRequest $request, FormData $data): void {
+ if ($data->get('plan') === 'enterprise') {
+ $field->show()->rules('required', 'integer', 'min:50');
+
+ return;
+ }
+
+ $field->hide()->rules('nullable', 'integer', 'min:50');
+ }),
+
+ Boolean::make(__('Send Welcome Email'), 'send_welcome_email')
+ ->default(true),
+
+ MultiSelect::make(__('Channels'))
+ ->options([
+ 'email' => __('Email'),
+ 'sms' => __('SMS'),
+ 'push' => __('Push'),
+ ])
+ ->default(['email'])
+ ->rules('nullable', 'array'),
+
+ BooleanGroup::make(__('Permissions'))
+ ->options([
+ 'read' => __('Read'),
+ 'write' => __('Write'),
+ 'export' => __('Export'),
+ ])
+ ->default([
+ 'read' => true,
+ 'write' => false,
+ 'export' => false,
+ ]),
+
+ Heading::make(__('Dates And Structured Values')),
+
+ Date::make(__('Start Date'), 'start_date')
+ ->default(now()->toDateString())
+ ->rules('required', 'date'),
+
+ DateTime::make(__('Reminder At'), 'reminder_at')
+ ->default(now()->addDay())
+ ->rules('nullable', 'date'),
+
+ Timezone::make(__('Timezone'))
+ ->default(config('app.timezone', 'UTC')),
+
+ Country::make(__('Country'))
+ ->default('US'),
+
+ Currency::make(__('Budget'))
+ ->default('249.00')
+ ->rules('nullable', 'numeric', 'min:0'),
+
+ Color::make(__('Accent Color'), 'accent_color')
+ ->default('#10b981'),
+
+ Code::make(__('Payload'))
+ ->json()
+ ->default(json_encode([
+ 'source' => 'nova-form-card',
+ 'demo' => true,
+ ], JSON_PRETTY_PRINT)),
+
+ KeyValue::make(__('Metadata'))
+ ->default([
+ 'campaign' => 'Demo',
+ 'owner' => 'Nova',
+ ]),
+
+ Slug::make(__('Workspace Slug'), 'workspace_slug')
+ ->default('nova-form-card-demo')
+ ->rules('required', 'alpha_dash'),
+
+ Token::make(__('Access Token'), 'access_token')
+ ->default('demo-token'),
+
+ Hidden::make(__('Tracking Code'), 'tracking_code')
+ ->default('demo-card'),
+
+ ID::make(__('Record ID'), 'record_id')
+ ->default(1001),
+
+ Heading::make(__('Security And Uploads')),
+
+ Password::make(__('Secret'), 'secret')
+ ->rules('nullable'),
+
+ PasswordConfirmation::make(__('Secret Confirmation'), 'secret_confirmation')
+ ->rules('nullable', 'same:secret'),
+
+ File::make(__('Attachment'))
+ ->rules('nullable', 'file'),
+
+ Image::make(__('Image'))
+ ->rules('nullable', 'image'),
+
+ Avatar::make(__('Profile Photo'), 'profile_photo')
+ ->rules('nullable', 'image'),
+
+ Audio::make(__('Audio Note'), 'audio_note')
+ ->rules('nullable', 'file'),
+
+ Heading::make(__('Response Demo')),
+
+ Select::make(__('Response Type'), 'response_type')
+ ->options([
+ 'success' => __('Success message'),
+ 'error' => __('Error toast'),
+ 'refresh' => __('Refresh page'),
+ 'redirect' => __('Visit Nova home'),
+ ])
+ ->displayUsingLabels()
+ ->default('success')
+ ->rules('required', 'in:success,error,refresh,redirect'),
+ ];
+ }
+
+ public function handle(FormFields $fields, NovaRequest $request): mixed
+ {
+ $uploads = collect(['attachment', 'image', 'profile_photo', 'audio_note'])
+ ->mapWithKeys(fn (string $key): array => [$key => $fields->get($key)])
+ ->filter(fn (mixed $value): bool => $value instanceof UploadedFile)
+ ->map(fn (UploadedFile $file): string => $file->getClientOriginalName())
+ ->all();
+
+ $count = collect($fields->all())
+ ->reject(fn (mixed $value): bool => $value === null || $value === '' || $value === [])
+ ->count();
+
+ $message = __('Demo submitted with :count handled values and :uploads upload(s).', [
+ 'count' => $count,
+ 'uploads' => count($uploads),
+ ]);
+
+ return match ($fields->get('response_type', 'success')) {
+ 'error' => static::error(__('Demo error response selected.')),
+ 'refresh' => static::refresh($message),
+ 'redirect' => static::visit('/'.trim((string) config('nova.path', 'nova'), '/')),
+ default => static::message($message),
+ };
+ }
+}
diff --git a/package-lock.json b/package-lock.json
new file mode 100644
index 0000000..fae6364
--- /dev/null
+++ b/package-lock.json
@@ -0,0 +1,1353 @@
+{
+ "name": "nova-form-card",
+ "lockfileVersion": 3,
+ "requires": true,
+ "packages": {
+ "": {
+ "name": "nova-form-card",
+ "devDependencies": {
+ "@vitejs/plugin-vue": "^5.0.0 || ^6.0.0",
+ "vite": "^6.0.0 || ^7.0.0",
+ "vue": "^3.5.0"
+ }
+ },
+ "node_modules/@babel/helper-string-parser": {
+ "version": "7.29.7",
+ "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.29.7.tgz",
+ "integrity": "sha512-Pb5ijPrZ89GDH8223L4UP8i6QApWxs04RbPQJTeWDV0/keR2E36MeKnyr6LYmUUvqRRI+Iv87SuF1W6ErINzYw==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=6.9.0"
+ }
+ },
+ "node_modules/@babel/helper-validator-identifier": {
+ "version": "7.29.7",
+ "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.29.7.tgz",
+ "integrity": "sha512-qehxGkRj55h/ff8EMaJ+cYhyaKlHIxqYDn682wQD7RNp9UujOQsHog2uS0r2vzr4pW+sXf90NeeayjcNaX3fFg==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=6.9.0"
+ }
+ },
+ "node_modules/@babel/parser": {
+ "version": "7.29.7",
+ "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.7.tgz",
+ "integrity": "sha512-hnORnjP/1P/zFEndoeX+n+t1RwWRJiJpM/jO7FW32Kn9r5+sJB2JWOdYo4L6k78j15eCwY3Gm/7364B1EMwtNg==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@babel/types": "^7.29.7"
+ },
+ "bin": {
+ "parser": "bin/babel-parser.js"
+ },
+ "engines": {
+ "node": ">=6.0.0"
+ }
+ },
+ "node_modules/@babel/types": {
+ "version": "7.29.7",
+ "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.29.7.tgz",
+ "integrity": "sha512-4zBIxpPzowiZpusoFkyGVwakdRJUyuH5PxQ/PrqghfdFWWasvnCdPfQXHrenDai+gyLARulZjZowCOj6fjT4pA==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@babel/helper-string-parser": "^7.29.7",
+ "@babel/helper-validator-identifier": "^7.29.7"
+ },
+ "engines": {
+ "node": ">=6.9.0"
+ }
+ },
+ "node_modules/@esbuild/aix-ppc64": {
+ "version": "0.28.1",
+ "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.28.1.tgz",
+ "integrity": "sha512-Svl7tq8k/08+p6CXPpRjQ1fKX+1odH/BQbb48fV6fj3CWHhsoIOoY87w1oHXm0qEpkIK3ZfVgp0hed3XBXzXMQ==",
+ "cpu": [
+ "ppc64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "aix"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/android-arm": {
+ "version": "0.28.1",
+ "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.28.1.tgz",
+ "integrity": "sha512-0k2F129Xdio1TdJfzJ8sy1Q47vUD2NnwdhiAf7drUN1EBTfPf4hsFCtmMgu/6m8JSzsBrlmVjudMBQqOfG8usQ==",
+ "cpu": [
+ "arm"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "android"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/android-arm64": {
+ "version": "0.28.1",
+ "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.28.1.tgz",
+ "integrity": "sha512-34EGEbCIAgosYz6goLcopX6Mo7NyGv9tfwEM2/7Ce2VcVRk568iSvniGWcUXIy7wEDR1wzolcxcriFVrWYcwBg==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "android"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/android-x64": {
+ "version": "0.28.1",
+ "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.28.1.tgz",
+ "integrity": "sha512-dbwY7ltSMDWsRatcRpCnES4F+im88OCUgGZjy52shC7GqHRE/cYlxNbB4Z4UpJswpcc4Qxd2oE/ufM0p61IKng==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "android"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/darwin-arm64": {
+ "version": "0.28.1",
+ "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.28.1.tgz",
+ "integrity": "sha512-TZbWkQY7kvTAXbXUT7uVACR5cMHsDiSz9z7ZKAX/RTq/WJEk3QyRr0wZpNhBDX+/0CtdqUIJlOiodQcta6tY3Q==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "darwin"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/darwin-x64": {
+ "version": "0.28.1",
+ "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.28.1.tgz",
+ "integrity": "sha512-zfdzgK9ACBNZLI/CyHTOx81SyNbM6YXn7rxSgX97VjyiPl9W1i4Ka4fgKECEoFCKGpvBj5qArWIGgQjOwkgskQ==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "darwin"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/freebsd-arm64": {
+ "version": "0.28.1",
+ "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.28.1.tgz",
+ "integrity": "sha512-wG2EA8ENdEI0qhkSZMjfqrdY+ziCYCPMmtZjjIwOmXFjmyzEHn+UUxk5of+SYsjtfs3VpnlC7QLzSI5hY/rOAw==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "freebsd"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/freebsd-x64": {
+ "version": "0.28.1",
+ "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.28.1.tgz",
+ "integrity": "sha512-i7dZ9vQgnvSCzi/rYCXNgtF/U+eKZNJBzu3eTQbRgHnM7tNSizLOkRFAl3qzVc/Op/u5YkHHa4pf/3DOYHthLQ==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "freebsd"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/linux-arm": {
+ "version": "0.28.1",
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.28.1.tgz",
+ "integrity": "sha512-qVXBOHQS+d5Y722GwJzJUtOLlX7km3CraOaGormF1pDtPd2C/l1SHRPgjLunLGe51Sh5YYWKMFDyV4SxgMQYTQ==",
+ "cpu": [
+ "arm"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/linux-arm64": {
+ "version": "0.28.1",
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.28.1.tgz",
+ "integrity": "sha512-yHs+0uc8+nvEAfAfxrWQKK5peSNzBc4PegcMO0EJ2hT71uA7vB8Ihg2e77R2P7SG5uYjPbHlLLmve4LLLRCf0g==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/linux-ia32": {
+ "version": "0.28.1",
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.28.1.tgz",
+ "integrity": "sha512-d1z4ZuP0ajrfz/FhGT4vv278rX8KnPPJx8i5+AtK7TYbx9Le9F1hyzurZpkEyjkGa9dUGhQow4C1NmeGvqxN2w==",
+ "cpu": [
+ "ia32"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/linux-loong64": {
+ "version": "0.28.1",
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.28.1.tgz",
+ "integrity": "sha512-M5sRjUVZrkm1OAPR3dlOYzNmN+loZKGVi1VUQGrwuqLcbR6qeAz+famMhjASeH3YVKvZz+zT1jlh/keC3Rj/lg==",
+ "cpu": [
+ "loong64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/linux-mips64el": {
+ "version": "0.28.1",
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.28.1.tgz",
+ "integrity": "sha512-mRObBZeHh2OxcBFPWE/FjylkRgZdYuiTR3vaTozquCGOH14iP9oN4x4Ge81CoIDYQrXmIxpFumJBu5MtZpnQJQ==",
+ "cpu": [
+ "mips64el"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/linux-ppc64": {
+ "version": "0.28.1",
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.28.1.tgz",
+ "integrity": "sha512-slScBsMAb3GFDcdrCgLwZtPYRoH2H/youv10QiZyRjmsP48fznoveWytSgCI/R0ZcUgpc0ZhIUEx6LHts8yrfQ==",
+ "cpu": [
+ "ppc64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/linux-riscv64": {
+ "version": "0.28.1",
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.28.1.tgz",
+ "integrity": "sha512-kw0owk1o0GFETUJyW0jc0G4Yzs0BHZn0JDZ8JRT088vjJYX777BAs1fDGxAC+q831qOs2DTC96mNsG2opdfyyQ==",
+ "cpu": [
+ "riscv64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/linux-s390x": {
+ "version": "0.28.1",
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.28.1.tgz",
+ "integrity": "sha512-/lAIjX8aYFRByhh6L5rYtPEDRqa9de/4V/juOXcta5frjvzXO4/sqEtyytse0g3zZFuWu5cDN0MkLz2qRDD2Ag==",
+ "cpu": [
+ "s390x"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/linux-x64": {
+ "version": "0.28.1",
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.28.1.tgz",
+ "integrity": "sha512-u/anNYF2mmVOEDwLtnQ1wOr3EZ9sTNGLWrsYGYwHWzGA3Si84IOkHXlbWTD1NB+9/1lcnweYKO54uhxZydNzfA==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/netbsd-arm64": {
+ "version": "0.28.1",
+ "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.28.1.tgz",
+ "integrity": "sha512-oks0DYbLwWMmaakTsCb+zL4E+aHRVLom9IJZOAthMQEPiQmydXHkziYEsGYRx0uNV/IjEKGAV941JzH02pflqw==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "netbsd"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/netbsd-x64": {
+ "version": "0.28.1",
+ "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.28.1.tgz",
+ "integrity": "sha512-aeL6lAnN89Hz43Mlh1G8ARasbuoYvSITDEx0tHh5b7jJnHcssqgjy9Yx430GDpmCa6OyrKoS0aNRjKundRizGg==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "netbsd"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/openbsd-arm64": {
+ "version": "0.28.1",
+ "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.28.1.tgz",
+ "integrity": "sha512-MEFJe5C3R8pwXdZ5Y21oo6m7ePiS0d9pWucn99O/wvyJZChoIQKrQDxKrGeW8F5+T0okTHesAmDeiHDTIq0V/Q==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "openbsd"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/openbsd-x64": {
+ "version": "0.28.1",
+ "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.28.1.tgz",
+ "integrity": "sha512-i/ZLIOafE0Z8cI/XANJAixoJL/uRAoS2xOA3rb0xN+KK0K177cMAsQYkzHtBrtMXAKuAc7HGgcWiZ/sRC1Nxgw==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "openbsd"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/openharmony-arm64": {
+ "version": "0.28.1",
+ "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.28.1.tgz",
+ "integrity": "sha512-ge+Z7EXFNt2BO1oAMsVpiQ8EwndV9i1xXerAeTIK7AtPs3bKFXQM7nlRxDSIUIMeueR1CNXxqztLzdNeReKBJg==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "openharmony"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/sunos-x64": {
+ "version": "0.28.1",
+ "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.28.1.tgz",
+ "integrity": "sha512-BEjgtECkL3vY+SaSQ6nzVfiALUeFxpawyp8Jmf5PtYhf1Ug40N1h/hxlhts+f1FvSvarEigdxS3BlSMI2PJLcQ==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "sunos"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/win32-arm64": {
+ "version": "0.28.1",
+ "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.28.1.tgz",
+ "integrity": "sha512-lCv9eK/H6ZJWbE7bh2nw54CZ9M2nupBxJcTsdk/QQnWkdSjKGuxmmH8/GWrlT1eMmZfn4dGcCjRte397WqfQXA==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "win32"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/win32-ia32": {
+ "version": "0.28.1",
+ "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.28.1.tgz",
+ "integrity": "sha512-zvb/mB2bSCoJOpoCBgYKKpX6YM6mJBlBUVUtVj41DlZJVEB6/0CKlRYxP5wWl1C1ILiCoAU5wZZ4q1P3qeS6Eg==",
+ "cpu": [
+ "ia32"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "win32"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/win32-x64": {
+ "version": "0.28.1",
+ "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.28.1.tgz",
+ "integrity": "sha512-bm4Mowrv+GXMlpWX++EcXw/iLyd1o3+bJkC2DkWXYVvgZCqD/bSj9ctZeAMC3cIxgjRVR2Dufaiu4YPxr5gW1A==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "win32"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@jridgewell/sourcemap-codec": {
+ "version": "1.5.5",
+ "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz",
+ "integrity": "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/@rolldown/pluginutils": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.1.tgz",
+ "integrity": "sha512-2j9bGt5Jh8hj+vPtgzPtl72j0yRxHAyumoo6TNfAjsLB04UtpSvPbPcDcBMxz7n+9CYB0c1GxQFxYRg2jimqGw==",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/@rollup/rollup-android-arm-eabi": {
+ "version": "4.62.2",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.62.2.tgz",
+ "integrity": "sha512-6o7ZLZK+BeenkZCFNDXqpbjw9bD6nuWonvS/lwQJp7NoVVxm6p3qE7qQ5jGuBjiFsgvqjD8mZAU5oWxTmbOeOg==",
+ "cpu": [
+ "arm"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "android"
+ ]
+ },
+ "node_modules/@rollup/rollup-android-arm64": {
+ "version": "4.62.2",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.62.2.tgz",
+ "integrity": "sha512-BaH7BllCACHoH1LguOU56UItGfUWjujlO65kS9LAodViaN4bwIKd7oeW/ZHJ/4ljr/7MIiENnNy3HJ0zXv8Zkw==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "android"
+ ]
+ },
+ "node_modules/@rollup/rollup-darwin-arm64": {
+ "version": "4.62.2",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.62.2.tgz",
+ "integrity": "sha512-v39RCCvj4He82I9sFmk+M1VZ0PLM9sfsLVikjfx2hYBNALhrrOR2D3JjQA6AhlaSOgcR+RzrKY7e1+bT6SUO/A==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "darwin"
+ ]
+ },
+ "node_modules/@rollup/rollup-darwin-x64": {
+ "version": "4.62.2",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.62.2.tgz",
+ "integrity": "sha512-yl0y2vq3S3lHeuXhEdss6TWfKW8vkujImO12tn4ZkG/4oghr09LvdYm2RElVjokTQiUvDUGXLGsYeLqUMCKpGA==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "darwin"
+ ]
+ },
+ "node_modules/@rollup/rollup-freebsd-arm64": {
+ "version": "4.62.2",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.62.2.tgz",
+ "integrity": "sha512-tT4pvt4qXD+vEoezupCWi+a1F0vvDiksiHc+PxRlYTOH1I6/X4id9jPxTP+Fg+545euaFT1jJVs4CEdHZAU1vw==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "freebsd"
+ ]
+ },
+ "node_modules/@rollup/rollup-freebsd-x64": {
+ "version": "4.62.2",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.62.2.tgz",
+ "integrity": "sha512-6nU5F2wCW+qvCBhTn1pdIU3bzsIoF7EUwsCDRxilWGprQR6yd508YnH9+OKFCwpfS8pjZqDUmnCAr7exax0XCg==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "freebsd"
+ ]
+ },
+ "node_modules/@rollup/rollup-linux-arm-gnueabihf": {
+ "version": "4.62.2",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.62.2.tgz",
+ "integrity": "sha512-n1GJHPOvpIfhi3TmrCeh6S6URt9BFCt0KQE3qvexyGCTAKpR4Lg+eWvNZEqu7epxwus/8ElT3hacYEucm49SZg==",
+ "cpu": [
+ "arm"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ]
+ },
+ "node_modules/@rollup/rollup-linux-arm-musleabihf": {
+ "version": "4.62.2",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.62.2.tgz",
+ "integrity": "sha512-JqgflS8wEB+UXV/vS1RpRbifGBeN4D5lz8D8oOFbFZw4vedvdOgCFAjfBmIMdW3yL10XpQQ0Ambepw6MXrhOnA==",
+ "cpu": [
+ "arm"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ]
+ },
+ "node_modules/@rollup/rollup-linux-arm64-gnu": {
+ "version": "4.62.2",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.62.2.tgz",
+ "integrity": "sha512-wnFJkogWvN4jm/hQRF2UBaeUmk20j5+DmHvoyWii2b8HJDyvz1MF2OU/6ynXt2KR63rbZLWkFpoytpdc/yBuSA==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ]
+ },
+ "node_modules/@rollup/rollup-linux-arm64-musl": {
+ "version": "4.62.2",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.62.2.tgz",
+ "integrity": "sha512-HVu2bp0zhvJ8xHEV9+UUs7S90VadmBSY3LcIMvozbPo4AuMGDWlz3ymHLHZPX4hR67TKTt8Qp5PJ5RBg/i+RMQ==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ]
+ },
+ "node_modules/@rollup/rollup-linux-loong64-gnu": {
+ "version": "4.62.2",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-gnu/-/rollup-linux-loong64-gnu-4.62.2.tgz",
+ "integrity": "sha512-mQqqAV8QaoSgr9I2fKDLY2BAVvmKjWoGiu/cSYQonsLvtqwEn1E4QYfnCOcp5zoEqNhsDYin1s6jx/VJmrxlZg==",
+ "cpu": [
+ "loong64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ]
+ },
+ "node_modules/@rollup/rollup-linux-loong64-musl": {
+ "version": "4.62.2",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-musl/-/rollup-linux-loong64-musl-4.62.2.tgz",
+ "integrity": "sha512-IxKLoxCQ2IWi6bT2akyDUBGsOImDKB+sPp4EsTmwFQ/fMwpCKm8uLSSgP/Kx/QYUgKis6SEZ5/Nlhup0DIA0PQ==",
+ "cpu": [
+ "loong64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ]
+ },
+ "node_modules/@rollup/rollup-linux-ppc64-gnu": {
+ "version": "4.62.2",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.62.2.tgz",
+ "integrity": "sha512-Mk5ha2RQSgyFfmYYLkBpPnUk8D8FriBxesO1u9O75X0mHgXL1UQcH5Itl2lurWL2tj0RxV9b9tJgipac0hRY9A==",
+ "cpu": [
+ "ppc64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ]
+ },
+ "node_modules/@rollup/rollup-linux-ppc64-musl": {
+ "version": "4.62.2",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-musl/-/rollup-linux-ppc64-musl-4.62.2.tgz",
+ "integrity": "sha512-CjvEnqJL/0/TQ3TXX3OPIJ/kmBellrWd4heXUmHeJlTnmwjKpSJzoehLaL6Xk0ZnMHBu9dZuFADNOrtjF4v+2w==",
+ "cpu": [
+ "ppc64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ]
+ },
+ "node_modules/@rollup/rollup-linux-riscv64-gnu": {
+ "version": "4.62.2",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.62.2.tgz",
+ "integrity": "sha512-1SiZbzwdkaDURsew/tSOrooKiYy7EQGT6m8ufavAi9NEyQb/6VuIxFXAL1fqa4iZe3g4NbNk4P7J32z2tw5Mgg==",
+ "cpu": [
+ "riscv64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ]
+ },
+ "node_modules/@rollup/rollup-linux-riscv64-musl": {
+ "version": "4.62.2",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.62.2.tgz",
+ "integrity": "sha512-nQts12zJ3NQRoE6uYljOH89v7szzLDvG2JD/vsX+vGXU8w/At1GowTZ5/7qeFQ8m7L55rpR8Okugnuo5bgjy2Q==",
+ "cpu": [
+ "riscv64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ]
+ },
+ "node_modules/@rollup/rollup-linux-s390x-gnu": {
+ "version": "4.62.2",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.62.2.tgz",
+ "integrity": "sha512-E9/ll019jhPIJgpzfZoIkBGhcz+kKNgVWYRY0zr9srBdPPFVpvOKW8VaJKUbeK+eZXyQF9ltME+Kk6affeaPgg==",
+ "cpu": [
+ "s390x"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ]
+ },
+ "node_modules/@rollup/rollup-linux-x64-gnu": {
+ "version": "4.62.2",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.62.2.tgz",
+ "integrity": "sha512-5BqxR/pshjey51iliyzTD5Xi3EN0aLmQ2lZ3lvefVV9c82BvrLo2/6OT55iifpWBufs6kdwWbuOKS841DrmK9A==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ]
+ },
+ "node_modules/@rollup/rollup-linux-x64-musl": {
+ "version": "4.62.2",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.62.2.tgz",
+ "integrity": "sha512-uNN83XxQrRAh/w0/pmAfibcwyb6YWt4gP+dpnQKPVJshAloQ785ii8CT8ZCIxkGg9opVsvAlGhFitSm6D1Jjpg==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ]
+ },
+ "node_modules/@rollup/rollup-openbsd-x64": {
+ "version": "4.62.2",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-openbsd-x64/-/rollup-openbsd-x64-4.62.2.tgz",
+ "integrity": "sha512-srjEIxSH3LRnJN6THczDHWQplqEMFiAJrTab0msUryh9kwNpkICf3Ea6q6MN/2cZwRFUNx5w+h6Hpi4QuHS6Zg==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "openbsd"
+ ]
+ },
+ "node_modules/@rollup/rollup-openharmony-arm64": {
+ "version": "4.62.2",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.62.2.tgz",
+ "integrity": "sha512-8hOJnxgbyObnCm5AlRA3A931xX19xq80RjVTKgJOvEKWqJruP/Uf12IbAOaDjjEXYRewwHLfmF0YRIdK3OwKWA==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "openharmony"
+ ]
+ },
+ "node_modules/@rollup/rollup-win32-arm64-msvc": {
+ "version": "4.62.2",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.62.2.tgz",
+ "integrity": "sha512-mmF4AY1i0hG/bLWUctUq59gtmgaSIRa3cu/A3JFRp/sCNEme2bgDEiDS22P9FbnJB8NJNF4jPJiSP5RHQpUTDg==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "win32"
+ ]
+ },
+ "node_modules/@rollup/rollup-win32-ia32-msvc": {
+ "version": "4.62.2",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.62.2.tgz",
+ "integrity": "sha512-DZgkknc6jhHrk46V25vbAM0zZkyP0nSDkJB8/dRkLTxv470dOmWDqGoEJl/9A0dFfS7yE3REOwNDxpHwSLSt0Q==",
+ "cpu": [
+ "ia32"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "win32"
+ ]
+ },
+ "node_modules/@rollup/rollup-win32-x64-gnu": {
+ "version": "4.62.2",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-gnu/-/rollup-win32-x64-gnu-4.62.2.tgz",
+ "integrity": "sha512-T6xr6ucWSFto+VGajA8YH26LdpHRuP4YLHEKAtCWvJDOlnmWcDZVCI2Jmjr+IFHDlt2zRaTAKE4tfjTaWLgJBg==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "win32"
+ ]
+ },
+ "node_modules/@rollup/rollup-win32-x64-msvc": {
+ "version": "4.62.2",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.62.2.tgz",
+ "integrity": "sha512-BfzEnDJOt9T8M989/lA37EcJgat01wLRnoi5dQf3QzOH7jzpqTAzdDbVfRljVr5r+jzKqpbHeyOfAaXxAd0PAA==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "win32"
+ ]
+ },
+ "node_modules/@types/estree": {
+ "version": "1.0.9",
+ "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.9.tgz",
+ "integrity": "sha512-GhdPgy1el4/ImP05X05Uw4cw2/M93BCUmnEvWZNStlCzEKME4Fkk+YpoA5OiHNQmoS7Cafb8Xa3Pya8m1Qrzeg==",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/@vitejs/plugin-vue": {
+ "version": "6.0.7",
+ "resolved": "https://registry.npmjs.org/@vitejs/plugin-vue/-/plugin-vue-6.0.7.tgz",
+ "integrity": "sha512-km+p+XdSz9Sxm5rqUbqcSfZYaAniKxWBj1KURl+Jr7UaPvvX7BmaWMdP69I5rrFDeQGyxAG7NXdc57vz+snhWg==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@rolldown/pluginutils": "^1.0.1"
+ },
+ "engines": {
+ "node": "^20.19.0 || >=22.12.0"
+ },
+ "peerDependencies": {
+ "vite": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0",
+ "vue": "^3.2.25"
+ }
+ },
+ "node_modules/@vue/compiler-core": {
+ "version": "3.5.39",
+ "resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.5.39.tgz",
+ "integrity": "sha512-16KBTEXAJCpDr0mwlw+AZyhu8iyC7R3S2vBwsI7QnWJU6X3WKc9VKeNEZpiMdZ569qWhz9574L3vV55qRL0Vtw==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@babel/parser": "^7.29.7",
+ "@vue/shared": "3.5.39",
+ "entities": "^7.0.1",
+ "estree-walker": "^2.0.2",
+ "source-map-js": "^1.2.1"
+ }
+ },
+ "node_modules/@vue/compiler-dom": {
+ "version": "3.5.39",
+ "resolved": "https://registry.npmjs.org/@vue/compiler-dom/-/compiler-dom-3.5.39.tgz",
+ "integrity": "sha512-oQPigALqYbNxTNPvNgSOe+czwVExfbVF02lz8jP0S3AXJiu3jxYDygNUiqSep4ezzW8XgnubqH63My2A7JR/vg==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@vue/compiler-core": "3.5.39",
+ "@vue/shared": "3.5.39"
+ }
+ },
+ "node_modules/@vue/compiler-sfc": {
+ "version": "3.5.39",
+ "resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-3.5.39.tgz",
+ "integrity": "sha512-d0ki86iOyN8LoZPBmk5SJWNwHP19CnDDCfuo//+2WJa2g5Ke0Jay983PIBIcSSzldC68I8DrD5GrHV3OSDfodg==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@babel/parser": "^7.29.7",
+ "@vue/compiler-core": "3.5.39",
+ "@vue/compiler-dom": "3.5.39",
+ "@vue/compiler-ssr": "3.5.39",
+ "@vue/shared": "3.5.39",
+ "estree-walker": "^2.0.2",
+ "magic-string": "^0.30.21",
+ "postcss": "^8.5.15",
+ "source-map-js": "^1.2.1"
+ }
+ },
+ "node_modules/@vue/compiler-ssr": {
+ "version": "3.5.39",
+ "resolved": "https://registry.npmjs.org/@vue/compiler-ssr/-/compiler-ssr-3.5.39.tgz",
+ "integrity": "sha512-Ce7/wvwMHai74bdszfXExdazFigYnlF9zgCmEQUcM1j0fOymlouZ7XilTYNo8oUjhlnjYOZbGrcYKuqjz89Ucw==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@vue/compiler-dom": "3.5.39",
+ "@vue/shared": "3.5.39"
+ }
+ },
+ "node_modules/@vue/reactivity": {
+ "version": "3.5.39",
+ "resolved": "https://registry.npmjs.org/@vue/reactivity/-/reactivity-3.5.39.tgz",
+ "integrity": "sha512-TpsuBJ9gGlZa5d23XcM2y8EXanz9dZeVDQBXRwzy46ItgvM+rWpzs+UVM0wcRLxGvcav0HE5jz2gNL53xlRAog==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@vue/shared": "3.5.39"
+ }
+ },
+ "node_modules/@vue/runtime-core": {
+ "version": "3.5.39",
+ "resolved": "https://registry.npmjs.org/@vue/runtime-core/-/runtime-core-3.5.39.tgz",
+ "integrity": "sha512-9GLtNyRvPAUMbX+7ono0RC2j0guo2LXVi8LvcmAooImACUKm0oFf0jjwbX8/H0AE/t1nxhAkn8RSl9PMCzzxZw==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@vue/reactivity": "3.5.39",
+ "@vue/shared": "3.5.39"
+ }
+ },
+ "node_modules/@vue/runtime-dom": {
+ "version": "3.5.39",
+ "resolved": "https://registry.npmjs.org/@vue/runtime-dom/-/runtime-dom-3.5.39.tgz",
+ "integrity": "sha512-7Y6aAGboKcXAZ3ECuUy7RrS5yy2r47dhTp2SKaJmYxjopImaVFaNa5Ne66NwGovsrxVAl5S5rwc7m22UG7Lmww==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@vue/reactivity": "3.5.39",
+ "@vue/runtime-core": "3.5.39",
+ "@vue/shared": "3.5.39",
+ "csstype": "^3.2.3"
+ }
+ },
+ "node_modules/@vue/server-renderer": {
+ "version": "3.5.39",
+ "resolved": "https://registry.npmjs.org/@vue/server-renderer/-/server-renderer-3.5.39.tgz",
+ "integrity": "sha512-yZSakiAGw85rZfG7UM8akMnIF+FmeiNk47uvHf2nVBBSe+dIKUhZuZq9+XgJhbV3nS5Z4ALH23/MpXofW+mbcw==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@vue/compiler-ssr": "3.5.39",
+ "@vue/shared": "3.5.39"
+ },
+ "peerDependencies": {
+ "vue": "3.5.39"
+ }
+ },
+ "node_modules/@vue/shared": {
+ "version": "3.5.39",
+ "resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.5.39.tgz",
+ "integrity": "sha512-l1rrBtBfTnmxvtsvdQDXltUUy8S1Y+ZaqdfUzmAnJkTd8Z8rv5v/ytW+TKiqEOWyHPoqtPlNFSs0lhRmYVSHVA==",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/csstype": {
+ "version": "3.2.3",
+ "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz",
+ "integrity": "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/entities": {
+ "version": "7.0.1",
+ "resolved": "https://registry.npmjs.org/entities/-/entities-7.0.1.tgz",
+ "integrity": "sha512-TWrgLOFUQTH994YUyl1yT4uyavY5nNB5muff+RtWaqNVCAK408b5ZnnbNAUEWLTCpum9w6arT70i1XdQ4UeOPA==",
+ "dev": true,
+ "license": "BSD-2-Clause",
+ "engines": {
+ "node": ">=0.12"
+ },
+ "funding": {
+ "url": "https://github.com/fb55/entities?sponsor=1"
+ }
+ },
+ "node_modules/esbuild": {
+ "version": "0.28.1",
+ "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.28.1.tgz",
+ "integrity": "sha512-HrJrvZv5ayxBzPfwphOoNzkzOIIlifzk0KJrGK2c8R4+LKpMtpYLQeUdjnwjWv/LZlkH2laZk+4w78pi99D4Vw==",
+ "dev": true,
+ "hasInstallScript": true,
+ "license": "MIT",
+ "bin": {
+ "esbuild": "bin/esbuild"
+ },
+ "engines": {
+ "node": ">=18"
+ },
+ "optionalDependencies": {
+ "@esbuild/aix-ppc64": "0.28.1",
+ "@esbuild/android-arm": "0.28.1",
+ "@esbuild/android-arm64": "0.28.1",
+ "@esbuild/android-x64": "0.28.1",
+ "@esbuild/darwin-arm64": "0.28.1",
+ "@esbuild/darwin-x64": "0.28.1",
+ "@esbuild/freebsd-arm64": "0.28.1",
+ "@esbuild/freebsd-x64": "0.28.1",
+ "@esbuild/linux-arm": "0.28.1",
+ "@esbuild/linux-arm64": "0.28.1",
+ "@esbuild/linux-ia32": "0.28.1",
+ "@esbuild/linux-loong64": "0.28.1",
+ "@esbuild/linux-mips64el": "0.28.1",
+ "@esbuild/linux-ppc64": "0.28.1",
+ "@esbuild/linux-riscv64": "0.28.1",
+ "@esbuild/linux-s390x": "0.28.1",
+ "@esbuild/linux-x64": "0.28.1",
+ "@esbuild/netbsd-arm64": "0.28.1",
+ "@esbuild/netbsd-x64": "0.28.1",
+ "@esbuild/openbsd-arm64": "0.28.1",
+ "@esbuild/openbsd-x64": "0.28.1",
+ "@esbuild/openharmony-arm64": "0.28.1",
+ "@esbuild/sunos-x64": "0.28.1",
+ "@esbuild/win32-arm64": "0.28.1",
+ "@esbuild/win32-ia32": "0.28.1",
+ "@esbuild/win32-x64": "0.28.1"
+ }
+ },
+ "node_modules/estree-walker": {
+ "version": "2.0.2",
+ "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz",
+ "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/fdir": {
+ "version": "6.5.0",
+ "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz",
+ "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=12.0.0"
+ },
+ "peerDependencies": {
+ "picomatch": "^3 || ^4"
+ },
+ "peerDependenciesMeta": {
+ "picomatch": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/fsevents": {
+ "version": "2.3.3",
+ "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
+ "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==",
+ "dev": true,
+ "hasInstallScript": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "darwin"
+ ],
+ "engines": {
+ "node": "^8.16.0 || ^10.6.0 || >=11.0.0"
+ }
+ },
+ "node_modules/magic-string": {
+ "version": "0.30.21",
+ "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz",
+ "integrity": "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@jridgewell/sourcemap-codec": "^1.5.5"
+ }
+ },
+ "node_modules/nanoid": {
+ "version": "3.3.15",
+ "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.15.tgz",
+ "integrity": "sha512-y7Wygv/7mEOvxTuEQDB8StXdMRBWf1kR/tlhAzBRUFkB2jfcLOAxO/SHmOO2zgz1pVgK29/kyupn059/bCHdjA==",
+ "dev": true,
+ "funding": [
+ {
+ "type": "github",
+ "url": "https://github.com/sponsors/ai"
+ }
+ ],
+ "license": "MIT",
+ "bin": {
+ "nanoid": "bin/nanoid.cjs"
+ },
+ "engines": {
+ "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"
+ }
+ },
+ "node_modules/picocolors": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",
+ "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==",
+ "dev": true,
+ "license": "ISC"
+ },
+ "node_modules/picomatch": {
+ "version": "4.0.5",
+ "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.5.tgz",
+ "integrity": "sha512-RvwwcruNjI1ncT5xRakeyS9Lf8lcItv34KD+aif+VH9kduAyfYBipGh12274xtenIPZ119/R9BdTBa8gAwSh0A==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=12"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/jonschlinkert"
+ }
+ },
+ "node_modules/postcss": {
+ "version": "8.5.16",
+ "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.16.tgz",
+ "integrity": "sha512-vuwillviilfKZsg0VGj5R/YwwcHx4SLsIOI/7K6mQkWx+l5cUHTjj5g0AasTBcyXsbfTgrwsUNmVUb5xVwyPwg==",
+ "dev": true,
+ "funding": [
+ {
+ "type": "opencollective",
+ "url": "https://opencollective.com/postcss/"
+ },
+ {
+ "type": "tidelift",
+ "url": "https://tidelift.com/funding/github/npm/postcss"
+ },
+ {
+ "type": "github",
+ "url": "https://github.com/sponsors/ai"
+ }
+ ],
+ "license": "MIT",
+ "dependencies": {
+ "nanoid": "^3.3.12",
+ "picocolors": "^1.1.1",
+ "source-map-js": "^1.2.1"
+ },
+ "engines": {
+ "node": "^10 || ^12 || >=14"
+ }
+ },
+ "node_modules/rollup": {
+ "version": "4.62.2",
+ "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.62.2.tgz",
+ "integrity": "sha512-RFnrW4lhXA3s3eqHDZvN654g8OTjzRfqpIRJYczCGB6HzphckVAi/Qh4tbPUbRuDi7s1Llv8g/NspLkttY3gTA==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@types/estree": "1.0.9"
+ },
+ "bin": {
+ "rollup": "dist/bin/rollup"
+ },
+ "engines": {
+ "node": ">=18.0.0",
+ "npm": ">=8.0.0"
+ },
+ "optionalDependencies": {
+ "@rollup/rollup-android-arm-eabi": "4.62.2",
+ "@rollup/rollup-android-arm64": "4.62.2",
+ "@rollup/rollup-darwin-arm64": "4.62.2",
+ "@rollup/rollup-darwin-x64": "4.62.2",
+ "@rollup/rollup-freebsd-arm64": "4.62.2",
+ "@rollup/rollup-freebsd-x64": "4.62.2",
+ "@rollup/rollup-linux-arm-gnueabihf": "4.62.2",
+ "@rollup/rollup-linux-arm-musleabihf": "4.62.2",
+ "@rollup/rollup-linux-arm64-gnu": "4.62.2",
+ "@rollup/rollup-linux-arm64-musl": "4.62.2",
+ "@rollup/rollup-linux-loong64-gnu": "4.62.2",
+ "@rollup/rollup-linux-loong64-musl": "4.62.2",
+ "@rollup/rollup-linux-ppc64-gnu": "4.62.2",
+ "@rollup/rollup-linux-ppc64-musl": "4.62.2",
+ "@rollup/rollup-linux-riscv64-gnu": "4.62.2",
+ "@rollup/rollup-linux-riscv64-musl": "4.62.2",
+ "@rollup/rollup-linux-s390x-gnu": "4.62.2",
+ "@rollup/rollup-linux-x64-gnu": "4.62.2",
+ "@rollup/rollup-linux-x64-musl": "4.62.2",
+ "@rollup/rollup-openbsd-x64": "4.62.2",
+ "@rollup/rollup-openharmony-arm64": "4.62.2",
+ "@rollup/rollup-win32-arm64-msvc": "4.62.2",
+ "@rollup/rollup-win32-ia32-msvc": "4.62.2",
+ "@rollup/rollup-win32-x64-gnu": "4.62.2",
+ "@rollup/rollup-win32-x64-msvc": "4.62.2",
+ "fsevents": "~2.3.2"
+ }
+ },
+ "node_modules/source-map-js": {
+ "version": "1.2.1",
+ "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz",
+ "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==",
+ "dev": true,
+ "license": "BSD-3-Clause",
+ "engines": {
+ "node": ">=0.10.0"
+ }
+ },
+ "node_modules/tinyglobby": {
+ "version": "0.2.17",
+ "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.17.tgz",
+ "integrity": "sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "fdir": "^6.5.0",
+ "picomatch": "^4.0.4"
+ },
+ "engines": {
+ "node": ">=12.0.0"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/SuperchupuDev"
+ }
+ },
+ "node_modules/vite": {
+ "version": "7.3.6",
+ "resolved": "https://registry.npmjs.org/vite/-/vite-7.3.6.tgz",
+ "integrity": "sha512-4XP60spRGjSZFf1qYH+dJIkK2znL3zQfl9KkOV9MkkRR/3Dls0dxaBsQPTloEc5BLXWPL9vsOxopxyKoMmDueg==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "esbuild": "^0.27.0 || ^0.28.0",
+ "fdir": "^6.5.0",
+ "picomatch": "^4.0.3",
+ "postcss": "^8.5.6",
+ "rollup": "^4.43.0",
+ "tinyglobby": "^0.2.15"
+ },
+ "bin": {
+ "vite": "bin/vite.js"
+ },
+ "engines": {
+ "node": "^20.19.0 || >=22.12.0"
+ },
+ "funding": {
+ "url": "https://github.com/vitejs/vite?sponsor=1"
+ },
+ "optionalDependencies": {
+ "fsevents": "~2.3.3"
+ },
+ "peerDependencies": {
+ "@types/node": "^20.19.0 || >=22.12.0",
+ "jiti": ">=1.21.0",
+ "less": "^4.0.0",
+ "lightningcss": "^1.21.0",
+ "sass": "^1.70.0",
+ "sass-embedded": "^1.70.0",
+ "stylus": ">=0.54.8",
+ "sugarss": "^5.0.0",
+ "terser": "^5.16.0",
+ "tsx": "^4.8.1",
+ "yaml": "^2.4.2"
+ },
+ "peerDependenciesMeta": {
+ "@types/node": {
+ "optional": true
+ },
+ "jiti": {
+ "optional": true
+ },
+ "less": {
+ "optional": true
+ },
+ "lightningcss": {
+ "optional": true
+ },
+ "sass": {
+ "optional": true
+ },
+ "sass-embedded": {
+ "optional": true
+ },
+ "stylus": {
+ "optional": true
+ },
+ "sugarss": {
+ "optional": true
+ },
+ "terser": {
+ "optional": true
+ },
+ "tsx": {
+ "optional": true
+ },
+ "yaml": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/vue": {
+ "version": "3.5.39",
+ "resolved": "https://registry.npmjs.org/vue/-/vue-3.5.39.tgz",
+ "integrity": "sha512-xmZCYabFGcirU8r0fTuvl/LICc1OU620rnqepaJDL/a141ZigkG7AyaxQLdqJ02ZRYzWe6YPaDHeQx7MfknQfA==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@vue/compiler-dom": "3.5.39",
+ "@vue/compiler-sfc": "3.5.39",
+ "@vue/runtime-dom": "3.5.39",
+ "@vue/server-renderer": "3.5.39",
+ "@vue/shared": "3.5.39"
+ },
+ "peerDependencies": {
+ "typescript": "*"
+ },
+ "peerDependenciesMeta": {
+ "typescript": {
+ "optional": true
+ }
+ }
+ }
+ }
+}
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..4003941
--- /dev/null
+++ b/package.json
@@ -0,0 +1,15 @@
+{
+ "name": "nova-form-card",
+ "private": true,
+ "type": "module",
+ "scripts": {
+ "dev": "vite build --watch",
+ "build": "vite build && node bin/copy-css.mjs",
+ "prod": "npm run build"
+ },
+ "devDependencies": {
+ "@vitejs/plugin-vue": "^5.0.0 || ^6.0.0",
+ "vite": "^6.0.0 || ^7.0.0",
+ "vue": "^3.5.0"
+ }
+}
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
new file mode 100644
index 0000000..6cdbda6
--- /dev/null
+++ b/phpunit.xml.dist
@@ -0,0 +1,20 @@
+
+
+
+
+ tests/Feature
+
+
+ tests/Unit
+
+
+
+
+
+
+
diff --git a/resources/css/card.css b/resources/css/card.css
new file mode 100644
index 0000000..dfe4ca2
--- /dev/null
+++ b/resources/css/card.css
@@ -0,0 +1,72 @@
+.nova-form-card {
+ overflow: hidden;
+}
+
+.nova-form-card__form {
+ display: flex;
+ flex-direction: column;
+ min-height: 100%;
+}
+
+.nova-form-card__header {
+ border-bottom: 1px solid rgba(229, 231, 235, 1);
+ padding: 1rem 1.5rem;
+}
+
+.dark .nova-form-card__header {
+ border-bottom-color: rgba(55, 65, 81, 1);
+}
+
+.nova-form-card__title {
+ font-size: 1rem;
+ font-weight: 700;
+ line-height: 1.5rem;
+ margin: 0;
+}
+
+.nova-form-card__fieldset {
+ border: 0;
+ margin: 0;
+ min-width: 0;
+ padding: 0;
+}
+
+.nova-form-card__body {
+ padding: 0.75rem 0;
+}
+
+.nova-form-card__display-field {
+ padding-left: 1.5rem;
+ padding-right: 1.5rem;
+}
+
+.nova-form-card__footer {
+ align-items: center;
+ border-top: 1px solid rgba(229, 231, 235, 1);
+ display: flex;
+ justify-content: flex-end;
+ padding: 1rem 1.5rem;
+}
+
+.dark .nova-form-card__footer {
+ border-top-color: rgba(55, 65, 81, 1);
+}
+
+.nova-form-card__fallback-submit {
+ align-items: center;
+ background-color: rgb(14, 165, 233);
+ border-radius: 0.25rem;
+ color: #fff;
+ cursor: pointer;
+ display: inline-flex;
+ font-size: 0.875rem;
+ font-weight: 700;
+ height: 2.25rem;
+ justify-content: center;
+ padding: 0 0.75rem;
+}
+
+.nova-form-card__fallback-submit:disabled {
+ cursor: not-allowed;
+ opacity: 0.65;
+}
diff --git a/resources/js/card.js b/resources/js/card.js
new file mode 100644
index 0000000..b2fc171
--- /dev/null
+++ b/resources/js/card.js
@@ -0,0 +1,5 @@
+import Card from './components/Card.vue'
+
+Nova.booting(app => {
+ app.component('nova-form-card', Card)
+})
diff --git a/resources/js/components/Card.vue b/resources/js/components/Card.vue
new file mode 100644
index 0000000..b614c51
--- /dev/null
+++ b/resources/js/components/Card.vue
@@ -0,0 +1,409 @@
+
+
+
+
+
diff --git a/resources/lang/README.md b/resources/lang/README.md
new file mode 100644
index 0000000..039f1d7
--- /dev/null
+++ b/resources/lang/README.md
@@ -0,0 +1,9 @@
+# Translation Notes
+
+`messages.php` contains backend translation strings and supports normal PHP translator comments.
+
+`card.json` files are loaded by `Nova::translations()` for the Vue card. JSON does not support comments, so keep those files as valid JSON. The current frontend keys are:
+
+- `nova-form-card.submit`: default submit button text.
+- `nova-form-card.submitting`: loading text while a submission is in progress.
+- `nova-form-card.could_not_submit`: fallback error toast when a request fails without a server message.
diff --git a/resources/lang/en/card.json b/resources/lang/en/card.json
new file mode 100644
index 0000000..507c6a9
--- /dev/null
+++ b/resources/lang/en/card.json
@@ -0,0 +1,5 @@
+{
+ "nova-form-card.submit": "Submit",
+ "nova-form-card.submitting": "Submitting...",
+ "nova-form-card.could_not_submit": "The form could not be submitted."
+}
diff --git a/resources/lang/en/messages.php b/resources/lang/en/messages.php
new file mode 100644
index 0000000..5484e53
--- /dev/null
+++ b/resources/lang/en/messages.php
@@ -0,0 +1,113 @@
+ 'Submit',
+ 'submitting' => 'Submitting...',
+
+ /*
+ |--------------------------------------------------------------------------
+ | Submission Errors
+ |--------------------------------------------------------------------------
+ |
+ | These messages are returned by the submit endpoint. Keep them short enough
+ | to work in Nova toast notifications and validation responses.
+ |
+ */
+
+ 'cannot_submit' => 'This form card cannot be submitted.',
+ 'not_authorized_to_submit' => 'This form card is not authorized for submission.',
+ 'fields_payload_must_be_object' => 'The fields payload must be an object.',
+ 'invalid_data' => 'The given data was invalid.',
+ 'could_not_submit' => 'The form could not be submitted.',
+
+ /*
+ |--------------------------------------------------------------------------
+ | Developer-Facing Exceptions
+ |--------------------------------------------------------------------------
+ |
+ | The unsupported_field message is shown to developers during serialization.
+ | Preserve the :field and :supported placeholders in custom translations.
+ |
+ */
+
+ 'unsupported_field' => 'The [:field] field is not supported by nova-form-card. Supported fields are: :supported.',
+ 'app_key_required' => 'An application key is required to sign form card submissions.',
+
+ /*
+ |--------------------------------------------------------------------------
+ | Signed Submit Token Errors
+ |--------------------------------------------------------------------------
+ |
+ | These describe why a submitted form token could not be trusted. They are
+ | intentionally specific for logs and debugging, but are usually returned as
+ | a generic authorization failure to users.
+ |
+ */
+
+ 'token' => [
+ 'missing' => 'The form card token is missing.',
+ 'invalid_signature' => 'The form card token signature is invalid.',
+ 'missing_card_class' => 'The form card token does not contain a card class.',
+ 'expired' => 'The form card token has expired.',
+ 'wrong_user' => 'The form card token belongs to another user.',
+ 'invalid_card_class' => 'The form card token references an invalid card class.',
+ 'invalid_payload' => 'The form card token payload is invalid.',
+ ],
+
+ /*
+ |--------------------------------------------------------------------------
+ | Supported Field Names
+ |--------------------------------------------------------------------------
+ |
+ | These names are only used in developer-facing unsupported-field messages.
+ |
+ */
+
+ 'fields' => [
+ 'text' => 'Text',
+ 'textarea' => 'Textarea',
+ 'select' => 'Select',
+ 'boolean' => 'Boolean',
+ 'number' => 'Number',
+ 'date' => 'Date',
+ 'file' => 'File',
+ 'image' => 'Image',
+ 'audio' => 'Audio',
+ 'avatar' => 'Avatar',
+ 'email' => 'Email',
+ 'url' => 'URL',
+ 'password' => 'Password',
+ 'hidden' => 'Hidden',
+ 'id' => 'ID',
+ 'date_time' => 'DateTime',
+ 'currency' => 'Currency',
+ 'color' => 'Color',
+ 'code' => 'Code',
+ 'country' => 'Country',
+ 'timezone' => 'Timezone',
+ 'multi_select' => 'MultiSelect',
+ 'boolean_group' => 'BooleanGroup',
+ 'key_value' => 'KeyValue',
+ 'slug' => 'Slug',
+ 'token' => 'Token',
+ 'badge' => 'Badge',
+ 'heading' => 'Heading',
+ 'line' => 'Line',
+ 'stack' => 'Stack',
+ 'sparkline' => 'Sparkline',
+ 'status' => 'Status',
+ 'gravatar' => 'Gravatar',
+ 'ui_avatar' => 'UiAvatar',
+ 'password_confirmation' => 'PasswordConfirmation',
+ ],
+];
diff --git a/routes/api.php b/routes/api.php
new file mode 100644
index 0000000..28b066b
--- /dev/null
+++ b/routes/api.php
@@ -0,0 +1,11 @@
+name('nova-form-card.sync');
+
+Route::post('/submit', SubmitFormCardController::class)
+ ->name('nova-form-card.submit');
diff --git a/src/Exceptions/InvalidFormCardToken.php b/src/Exceptions/InvalidFormCardToken.php
new file mode 100644
index 0000000..d7f4a43
--- /dev/null
+++ b/src/Exceptions/InvalidFormCardToken.php
@@ -0,0 +1,9 @@
+ $field::class,
+ 'supported' => implode(', ', SupportedField::names()),
+ ]));
+ }
+}
diff --git a/src/FormCard.php b/src/FormCard.php
new file mode 100644
index 0000000..3a79f54
--- /dev/null
+++ b/src/FormCard.php
@@ -0,0 +1,139 @@
+
+ */
+ public function fields(NovaRequest $request): array
+ {
+ return [];
+ }
+
+ abstract public function handle(FormFields $fields, NovaRequest $request): mixed;
+
+ public function authorizedToSubmit(NovaRequest $request): bool
+ {
+ return true;
+ }
+
+ public function submitButtonText(): string
+ {
+ return $this->submitButtonText ?? __('nova-form-card::messages.submit');
+ }
+
+ public function withSubmitButtonText(string $text): static
+ {
+ $this->submitButtonText = $text;
+
+ return $this;
+ }
+
+ /**
+ * @return array
+ */
+ public function jsonSerialize(): array
+ {
+ $request = $this->currentNovaRequest();
+
+ app()->instance(NovaRequest::class, $request);
+
+ $this->withMeta([
+ 'formCard' => $this->serializeForFormCard($request),
+ ]);
+
+ return parent::jsonSerialize();
+ }
+
+ /**
+ * @return array
+ */
+ protected function serializeForFormCard(NovaRequest $request): array
+ {
+ $prefix = trim((string) config('nova-form-card.route_prefix', 'nova-vendor/nova-form-card'), '/');
+ $token = app(FormCardToken::class)->issue($this, $request);
+
+ return [
+ 'title' => $this->title(),
+ 'fields' => app(NovaFieldSerializer::class)->serialize($this->fields($request), $request),
+ 'endpoint' => "/{$prefix}/submit",
+ 'syncEndpoint' => "/{$prefix}/sync",
+ 'submitText' => $this->submitButtonText(),
+ 'canSubmit' => $this->authorizedToSubmit($request),
+ 'token' => $token,
+ ];
+ }
+
+ protected function currentNovaRequest(): NovaRequest
+ {
+ if (app()->bound(NovaRequest::class) && app(NovaRequest::class) instanceof NovaRequest) {
+ return app(NovaRequest::class);
+ }
+
+ $request = request();
+
+ if ($request instanceof NovaRequest) {
+ return $request;
+ }
+
+ return NovaRequest::createFrom($request);
+ }
+
+ public static function message(string $message): FormCardResponse
+ {
+ return FormCardResponse::message($message);
+ }
+
+ public static function success(?string $message = null): FormCardResponse
+ {
+ return FormCardResponse::success($message);
+ }
+
+ public static function error(string $message): FormCardResponse
+ {
+ return FormCardResponse::error($message);
+ }
+
+ public static function danger(string $message): FormCardResponse
+ {
+ return FormCardResponse::error($message);
+ }
+
+ public static function redirect(string $url, bool $remote = false): FormCardResponse
+ {
+ return FormCardResponse::redirect($url, $remote);
+ }
+
+ public static function visit(string $path, array $options = []): FormCardResponse
+ {
+ return FormCardResponse::visit($path, $options);
+ }
+
+ public static function refresh(?string $message = null): FormCardResponse
+ {
+ return FormCardResponse::refresh($message);
+ }
+}
diff --git a/src/FormCardServiceProvider.php b/src/FormCardServiceProvider.php
new file mode 100644
index 0000000..21361c8
--- /dev/null
+++ b/src/FormCardServiceProvider.php
@@ -0,0 +1,71 @@
+mergeConfigFrom(__DIR__.'/../config/nova-form-card.php', 'nova-form-card');
+ }
+
+ public function boot(): void
+ {
+ $this->loadTranslationsFrom(__DIR__.'/../resources/lang', 'nova-form-card');
+
+ if ($this->app->runningInConsole()) {
+ $this->publishes([
+ __DIR__.'/../config/nova-form-card.php' => config_path('nova-form-card.php'),
+ ], 'nova-form-card-config');
+
+ $this->publishes([
+ __DIR__.'/../resources/lang' => lang_path('vendor/nova-form-card'),
+ ], 'nova-form-card-translations');
+ }
+
+ $this->app->booted(function (): void {
+ $this->routes();
+ });
+
+ Nova::serving(function (ServingNova $event): void {
+ Nova::script('nova-form-card', __DIR__.'/../dist/js/card.js');
+ Nova::style('nova-form-card', __DIR__.'/../dist/css/card.css');
+ Nova::translations($this->frontendTranslationsPath());
+ });
+ }
+
+ protected function frontendTranslationsPath(): string
+ {
+ $locale = (string) $this->app->getLocale();
+
+ $paths = [
+ lang_path("vendor/nova-form-card/{$locale}/card.json"),
+ __DIR__."/../resources/lang/{$locale}/card.json",
+ __DIR__.'/../resources/lang/en/card.json',
+ ];
+
+ foreach ($paths as $path) {
+ if (is_file($path)) {
+ return $path;
+ }
+ }
+
+ return __DIR__.'/../resources/lang/en/card.json';
+ }
+
+ protected function routes(): void
+ {
+ if ($this->app->routesAreCached()) {
+ return;
+ }
+
+ Route::middleware(['nova'])
+ ->prefix(trim((string) config('nova-form-card.route_prefix', 'nova-vendor/nova-form-card'), '/'))
+ ->group(__DIR__.'/../routes/api.php');
+ }
+}
diff --git a/src/FormFields.php b/src/FormFields.php
new file mode 100644
index 0000000..54b2967
--- /dev/null
+++ b/src/FormFields.php
@@ -0,0 +1,80 @@
+|\Illuminate\Support\Collection $values
+ */
+ public function __construct(array|Collection $values = [], ?Collection $callbacks = null)
+ {
+ parent::__construct(collect($values), $callbacks ?? collect());
+ }
+
+ public function get($key, $default = null): mixed
+ {
+ if (! is_string($key)) {
+ return parent::get($key, $default);
+ }
+
+ $attributes = $this->getAttributes();
+
+ if (array_key_exists($key, $attributes)) {
+ return $attributes[$key];
+ }
+
+ $snake = Str::snake($key);
+
+ if (array_key_exists($snake, $attributes)) {
+ return $attributes[$snake];
+ }
+
+ return value($default);
+ }
+
+ public function has($key): bool
+ {
+ if (! is_string($key)) {
+ return parent::has($key);
+ }
+
+ $attributes = $this->getAttributes();
+
+ return array_key_exists($key, $attributes)
+ || array_key_exists(Str::snake($key), $attributes);
+ }
+
+ public function __get($key): mixed
+ {
+ return $this->get($key);
+ }
+
+ public function __isset($key): bool
+ {
+ return $this->has($key);
+ }
+
+ public function offsetExists($offset): bool
+ {
+ return is_string($offset) && $this->has($offset);
+ }
+
+ public function offsetGet($offset): mixed
+ {
+ return is_string($offset) ? $this->get($offset) : null;
+ }
+
+ public function count(): int
+ {
+ return count($this->getAttributes());
+ }
+}
diff --git a/src/Http/Controllers/SubmitFormCardController.php b/src/Http/Controllers/SubmitFormCardController.php
new file mode 100644
index 0000000..cc314f5
--- /dev/null
+++ b/src/Http/Controllers/SubmitFormCardController.php
@@ -0,0 +1,122 @@
+novaRequest($request);
+
+ app()->instance(NovaRequest::class, $novaRequest);
+
+ $token = (string) $request->input('token', '');
+
+ try {
+ $cardClass = $tokens->resolve($token, $novaRequest);
+ } catch (InvalidFormCardToken) {
+ abort(403, __('nova-form-card::messages.cannot_submit'));
+ }
+
+ $card = app($cardClass);
+
+ if (! $card instanceof FormCard) {
+ abort(403, __('nova-form-card::messages.cannot_submit'));
+ }
+
+ if (! $card->authorizedToSubmit($novaRequest)) {
+ abort(403, __('nova-form-card::messages.not_authorized_to_submit'));
+ }
+
+ $payload = $this->fieldsPayload($request);
+
+ if ($payload === null) {
+ return response()->json([
+ 'message' => __('nova-form-card::messages.fields_payload_must_be_object'),
+ 'errors' => [
+ 'fields' => [__('nova-form-card::messages.fields_payload_must_be_object')],
+ ],
+ ], 422);
+ }
+
+ $submissionRequest = $fields->requestForPayload($novaRequest, $payload);
+
+ app()->instance(NovaRequest::class, $submissionRequest);
+
+ $cardFields = $card->fields($submissionRequest);
+
+ $validator = Validator::make(
+ $payload,
+ $fields->rules($cardFields, $submissionRequest),
+ [],
+ $fields->attributes($cardFields, $submissionRequest),
+ );
+
+ if ($validator->fails()) {
+ return response()->json([
+ 'message' => __('nova-form-card::messages.invalid_data'),
+ 'errors' => $validator->errors()->toArray(),
+ ], 422);
+ }
+
+ $result = $card->handle(
+ $fields->resolve($cardFields, $payload, $submissionRequest),
+ $submissionRequest,
+ );
+
+ if ($result instanceof Responsable) {
+ return $result->toResponse($request);
+ }
+
+ if ($result instanceof Response) {
+ return $result;
+ }
+
+ $response = FormCardResponse::from($result);
+
+ return response()->json($response->toArray(), $response->status());
+ }
+
+ protected function novaRequest(Request $request): NovaRequest
+ {
+ if ($request instanceof NovaRequest) {
+ return $request;
+ }
+
+ return NovaRequest::createFrom($request);
+ }
+
+ /**
+ * @return array|null
+ */
+ protected function fieldsPayload(Request $request): ?array
+ {
+ $input = $request->input('fields', []);
+
+ if (! is_array($input)) {
+ return null;
+ }
+
+ $files = $request->file('fields', []);
+
+ if (! is_array($files)) {
+ return $input;
+ }
+
+ return array_replace_recursive($input, $files);
+ }
+}
diff --git a/src/Http/Controllers/SyncFormCardFieldController.php b/src/Http/Controllers/SyncFormCardFieldController.php
new file mode 100644
index 0000000..d0ba02b
--- /dev/null
+++ b/src/Http/Controllers/SyncFormCardFieldController.php
@@ -0,0 +1,64 @@
+novaRequest($request);
+
+ app()->instance('request', $novaRequest);
+ app()->instance(NovaRequest::class, $novaRequest);
+
+ try {
+ $cardClass = $tokens->resolve((string) $request->query('token', ''), $novaRequest);
+ } catch (InvalidFormCardToken) {
+ abort(Response::HTTP_FORBIDDEN, __('nova-form-card::messages.cannot_submit'));
+ }
+
+ $card = app($cardClass);
+
+ if (! $card instanceof FormCard || ! $card->authorizedToSubmit($novaRequest)) {
+ abort(Response::HTTP_FORBIDDEN, __('nova-form-card::messages.not_authorized_to_submit'));
+ }
+
+ $field = FieldCollection::make($card->fields($novaRequest))
+ ->authorized($novaRequest)
+ ->first(static function (object $field) use ($novaRequest): bool {
+ return $novaRequest->query('field') === ($field->attribute ?? null)
+ && $novaRequest->query('component') === $field->dependentComponentKey();
+ });
+
+ abort_if($field === null, Response::HTTP_NOT_FOUND);
+
+ $field->syncDependsOn($novaRequest);
+
+ return response()->json($serializer->serializeField($field, $novaRequest));
+ }
+
+ protected function novaRequest(Request $request): NovaRequest
+ {
+ if ($request instanceof NovaRequest) {
+ return $request;
+ }
+
+ $novaRequest = NovaRequest::createFrom($request);
+ $novaRequest->setUserResolver($request->getUserResolver());
+
+ return $novaRequest;
+ }
+}
diff --git a/src/Http/Responses/FormCardResponse.php b/src/Http/Responses/FormCardResponse.php
new file mode 100644
index 0000000..300a67e
--- /dev/null
+++ b/src/Http/Responses/FormCardResponse.php
@@ -0,0 +1,131 @@
+
+ */
+class FormCardResponse implements Arrayable, JsonSerializable, Responsable
+{
+ /**
+ * @param array|null $redirect
+ */
+ public function __construct(
+ protected string $type = 'success',
+ protected ?string $message = null,
+ protected ?array $redirect = null,
+ protected bool $refresh = false,
+ protected int $status = 200,
+ ) {
+ }
+
+ public static function success(?string $message = null): self
+ {
+ return new self('success', $message);
+ }
+
+ public static function message(string $message): self
+ {
+ return self::success($message);
+ }
+
+ public static function error(string $message, int $status = 200): self
+ {
+ return new self('error', $message, status: $status);
+ }
+
+ public static function redirect(string $url, bool $remote = false): self
+ {
+ return new self('redirect', redirect: [
+ 'url' => $url,
+ 'remote' => $remote,
+ ]);
+ }
+
+ /**
+ * @param array $options
+ */
+ public static function visit(string $path, array $options = []): self
+ {
+ return new self('redirect', redirect: [
+ 'url' => $path,
+ 'remote' => false,
+ 'options' => $options,
+ ]);
+ }
+
+ public static function refresh(?string $message = null): self
+ {
+ return new self('refresh', $message, refresh: true);
+ }
+
+ /**
+ * @param array $payload
+ */
+ public static function fromArray(array $payload): self
+ {
+ return new self(
+ type: (string) ($payload['type'] ?? 'success'),
+ message: isset($payload['message']) ? (string) $payload['message'] : null,
+ redirect: isset($payload['redirect']) && is_array($payload['redirect']) ? $payload['redirect'] : null,
+ refresh: (bool) ($payload['refresh'] ?? false),
+ status: (int) ($payload['status'] ?? 200),
+ );
+ }
+
+ public static function from(mixed $value): self
+ {
+ if ($value instanceof self) {
+ return $value;
+ }
+
+ if (is_array($value)) {
+ return self::fromArray($value);
+ }
+
+ if (is_string($value)) {
+ return self::message($value);
+ }
+
+ if ($value === false) {
+ return self::error(__('nova-form-card::messages.could_not_submit'));
+ }
+
+ return self::success();
+ }
+
+ public function status(): int
+ {
+ return $this->status;
+ }
+
+ /**
+ * @return array
+ */
+ public function toArray(): array
+ {
+ return array_filter([
+ 'type' => $this->type,
+ 'message' => $this->message,
+ 'redirect' => $this->redirect,
+ 'refresh' => $this->refresh,
+ ], static fn (mixed $value): bool => $value !== null && $value !== false);
+ }
+
+ /**
+ * @return array
+ */
+ public function jsonSerialize(): array
+ {
+ return $this->toArray();
+ }
+
+ public function toResponse($request)
+ {
+ return response()->json($this->toArray(), $this->status);
+ }
+}
diff --git a/src/Support/FormCardToken.php b/src/Support/FormCardToken.php
new file mode 100644
index 0000000..feab63a
--- /dev/null
+++ b/src/Support/FormCardToken.php
@@ -0,0 +1,129 @@
+encode([
+ 'class' => $card::class,
+ 'user_id' => $this->userIdentifier($request),
+ 'expires_at' => now()
+ ->addMinutes((int) config('nova-form-card.token_ttl_minutes', 120))
+ ->getTimestamp(),
+ ]);
+
+ return $payload.'.'.$this->signature($payload);
+ }
+
+ /**
+ * @return class-string
+ */
+ public function resolve(string $token, NovaRequest $request): string
+ {
+ if ($token === '' || ! str_contains($token, '.')) {
+ throw new InvalidFormCardToken(__('nova-form-card::messages.token.missing'));
+ }
+
+ [$payload, $signature] = explode('.', $token, 2);
+
+ if (! hash_equals($this->signature($payload), $signature)) {
+ throw new InvalidFormCardToken(__('nova-form-card::messages.token.invalid_signature'));
+ }
+
+ $data = $this->decode($payload);
+
+ if (! isset($data['class']) || ! is_string($data['class'])) {
+ throw new InvalidFormCardToken(__('nova-form-card::messages.token.missing_card_class'));
+ }
+
+ if (! isset($data['expires_at']) || (int) $data['expires_at'] < time()) {
+ throw new InvalidFormCardToken(__('nova-form-card::messages.token.expired'));
+ }
+
+ if (($data['user_id'] ?? null) !== $this->userIdentifier($request)) {
+ throw new InvalidFormCardToken(__('nova-form-card::messages.token.wrong_user'));
+ }
+
+ if (! is_subclass_of($data['class'], FormCard::class)) {
+ throw new InvalidFormCardToken(__('nova-form-card::messages.token.invalid_card_class'));
+ }
+
+ return $data['class'];
+ }
+
+ /**
+ * @param array $payload
+ */
+ protected function encode(array $payload): string
+ {
+ return rtrim(strtr(base64_encode(json_encode($payload, JSON_THROW_ON_ERROR)), '+/', '-_'), '=');
+ }
+
+ /**
+ * @return array
+ */
+ protected function decode(string $payload): array
+ {
+ $payload .= str_repeat('=', (4 - strlen($payload) % 4) % 4);
+ $json = base64_decode(strtr($payload, '-_', '+/'), true);
+
+ if ($json === false) {
+ throw new InvalidFormCardToken(__('nova-form-card::messages.token.invalid_payload'));
+ }
+
+ try {
+ $decoded = json_decode($json, true, flags: JSON_THROW_ON_ERROR);
+ } catch (JsonException $exception) {
+ throw new InvalidFormCardToken(__('nova-form-card::messages.token.invalid_payload'), previous: $exception);
+ }
+
+ if (! is_array($decoded)) {
+ throw new InvalidFormCardToken(__('nova-form-card::messages.token.invalid_payload'));
+ }
+
+ return $decoded;
+ }
+
+ protected function signature(string $payload): string
+ {
+ return hash_hmac('sha256', $payload, $this->key());
+ }
+
+ protected function key(): string
+ {
+ $key = (string) config('app.key');
+
+ if ($key === '') {
+ throw new RuntimeException(__('nova-form-card::messages.app_key_required'));
+ }
+
+ if (str_starts_with($key, 'base64:')) {
+ $decoded = base64_decode(substr($key, 7), true);
+
+ if ($decoded !== false) {
+ return $decoded;
+ }
+ }
+
+ return $key;
+ }
+
+ protected function userIdentifier(NovaRequest $request): ?string
+ {
+ $user = $request->user();
+
+ if ($user === null) {
+ return null;
+ }
+
+ return (string) $user->getAuthIdentifier();
+ }
+}
diff --git a/src/Support/NovaFieldIntrospector.php b/src/Support/NovaFieldIntrospector.php
new file mode 100644
index 0000000..e4ac99f
--- /dev/null
+++ b/src/Support/NovaFieldIntrospector.php
@@ -0,0 +1,63 @@
+
+ */
+ public function toArray(object $field): array
+ {
+ if ($field instanceof JsonSerializable) {
+ $serialized = $field->jsonSerialize();
+
+ if (is_array($serialized)) {
+ return $serialized;
+ }
+ }
+
+ if ($field instanceof Arrayable) {
+ return $field->toArray();
+ }
+
+ return [];
+ }
+
+ public function property(object $object, string $property, mixed $default = null): mixed
+ {
+ $class = new ReflectionClass($object);
+
+ while ($class) {
+ if ($class->hasProperty($property)) {
+ $reflection = $class->getProperty($property);
+ $reflection->setAccessible(true);
+
+ return $reflection->getValue($object);
+ }
+
+ $class = $class->getParentClass();
+ }
+
+ return $default;
+ }
+
+ public function evaluate(mixed $value, NovaRequest $request, object $field): mixed
+ {
+ if (! $value instanceof \Closure) {
+ return $value;
+ }
+
+ $reflection = new ReflectionFunction($value);
+
+ return $reflection->getNumberOfParameters() === 0
+ ? $value->call($field)
+ : $value->call($field, $request);
+ }
+}
diff --git a/src/Support/NovaFieldSerializer.php b/src/Support/NovaFieldSerializer.php
new file mode 100644
index 0000000..79cdf7b
--- /dev/null
+++ b/src/Support/NovaFieldSerializer.php
@@ -0,0 +1,188 @@
+introspector ??= new NovaFieldIntrospector();
+ $this->validator ??= new NovaFieldValidator($this->introspector);
+ }
+
+ /**
+ * @param array $fields
+ * @return array>
+ */
+ public function serialize(array $fields, NovaRequest $request): array
+ {
+ return $this->validator
+ ->fieldsForSerialization($fields, $request)
+ ->map(fn (object $field): array => $this->serializeField($field, $request))
+ ->values()
+ ->all();
+ }
+
+ /**
+ * @return array
+ */
+ public function serializeField(object $field, NovaRequest $request): array
+ {
+ $type = SupportedField::typeFor($field);
+
+ if ($type === null) {
+ throw UnsupportedFieldException::forField($field);
+ }
+
+ $this->prepareFieldForSerialization($field, $request);
+
+ $raw = $this->introspector->toArray($field);
+ $attribute = $this->validator->attributeForField($field) ?? (string) ($raw['name'] ?? 'field');
+ $value = $raw['value'] ?? $this->defaultValue($field, $request);
+
+ $raw['formCardType'] = $type;
+ $raw['type'] = $this->fieldTypeForNovaComponent($type, $raw, $field);
+ $raw['displayOnly'] = SupportedField::isDisplayOnly($field);
+ $raw['name'] = (string) ($raw['name'] ?? $attribute);
+ $raw['attribute'] = $attribute;
+ $raw['value'] = $this->initialValue($type, $value);
+ $raw['required'] = (bool) ($raw['required'] ?? false)
+ || $this->validator->fieldIsRequired($field, $request);
+ $raw['readonly'] = (bool) ($raw['readonly'] ?? $this->resolvedProperty($field, 'readonlyCallback', $request, false));
+ $raw['visible'] = (bool) ($raw['visible'] ?? true);
+ $raw['withLabel'] = (bool) ($raw['withLabel'] ?? true);
+ $raw['validationKey'] = (string) ($raw['validationKey'] ?? $attribute);
+ $raw['uniqueKey'] = (string) ($raw['uniqueKey'] ?? "{$attribute}-form-card-field");
+
+ return $raw;
+ }
+
+ protected function prepareFieldForSerialization(object $field, NovaRequest $request): void
+ {
+ if (! SupportedField::isDisplayOnly($field) || ! method_exists($field, 'resolveForDisplay')) {
+ return;
+ }
+
+ $field->resolveForDisplay($this->displayResourceFor($field, $request));
+ }
+
+ /**
+ * @return array
+ */
+ protected function displayResourceFor(object $field, NovaRequest $request): array
+ {
+ $resource = [];
+
+ foreach ($this->fieldsUsedForDisplayResource($field) as $displayField) {
+ $attribute = $this->rawAttributeFor($displayField);
+
+ if ($attribute === null || $attribute === 'ComputedField') {
+ continue;
+ }
+
+ $resource[$attribute] = $this->displayValueFor($displayField, $request);
+ }
+
+ return $resource;
+ }
+
+ /**
+ * @return array
+ */
+ protected function fieldsUsedForDisplayResource(object $field): array
+ {
+ $fields = [$field];
+ $lines = $this->introspector->property($field, 'lines');
+
+ if ($lines instanceof Traversable) {
+ $lines = iterator_to_array($lines);
+ }
+
+ if (is_array($lines)) {
+ foreach ($lines as $line) {
+ if (is_object($line)) {
+ $fields[] = $line;
+ }
+ }
+ }
+
+ return $fields;
+ }
+
+ protected function displayValueFor(object $field, NovaRequest $request): mixed
+ {
+ $value = $this->introspector->property($field, 'value');
+
+ return $value ?? $this->defaultValue($field, $request);
+ }
+
+ protected function rawAttributeFor(object $field): ?string
+ {
+ $attribute = $this->introspector->property($field, 'attribute');
+
+ return is_string($attribute) && $attribute !== '' ? $attribute : null;
+ }
+
+ /**
+ * @param array $raw
+ */
+ protected function fieldTypeForNovaComponent(string $type, array $raw, object $field): string
+ {
+ if ($type === 'password-confirmation') {
+ return 'password';
+ }
+
+ if (SupportedField::isDisplayOnly($field) && is_string($raw['type'] ?? null)) {
+ return $raw['type'];
+ }
+
+ return $type;
+ }
+
+ protected function initialValue(string $type, mixed $value): mixed
+ {
+ return match ($type) {
+ 'boolean' => (bool) $value,
+ 'number' => $value,
+ default => $value ?? '',
+ };
+ }
+
+ protected function defaultValue(object $field, NovaRequest $request): mixed
+ {
+ if (method_exists($field, 'resolveDefaultValue')) {
+ $value = $field->resolveDefaultValue($this->defaultResolvingRequest($request));
+
+ if ($value !== null) {
+ return $value;
+ }
+ }
+
+ return $this->resolvedProperty($field, 'defaultCallback', $request);
+ }
+
+ protected function defaultResolvingRequest(NovaRequest $request): NovaRequest
+ {
+ $defaultRequest = NovaRequest::createFrom($request);
+ $defaultRequest->setUserResolver($request->getUserResolver());
+ $defaultRequest->merge([
+ 'editing' => 'true',
+ 'editMode' => 'create',
+ ]);
+
+ return $defaultRequest;
+ }
+
+ protected function resolvedProperty(object $field, string $property, NovaRequest $request, mixed $default = null): mixed
+ {
+ $value = $this->introspector->property($field, $property, $default);
+
+ return $this->introspector->evaluate($value, $request, $field);
+ }
+}
diff --git a/src/Support/NovaFieldValidator.php b/src/Support/NovaFieldValidator.php
new file mode 100644
index 0000000..c311756
--- /dev/null
+++ b/src/Support/NovaFieldValidator.php
@@ -0,0 +1,309 @@
+introspector ??= new NovaFieldIntrospector();
+ }
+
+ /**
+ * @param array $fields
+ * @return array>
+ */
+ public function rules(array $fields, NovaRequest $request): array
+ {
+ $rules = [];
+
+ foreach ($this->fieldsForSubmission($fields, $request) as $field) {
+ foreach ($this->ruleMapForField($field, $request) as $attribute => $fieldRules) {
+ if (! is_string($attribute) || $attribute === '') {
+ continue;
+ }
+
+ $normalized = $this->normalizeRules($fieldRules, $attribute, $request);
+
+ if ($normalized !== []) {
+ $rules[$attribute] = array_merge($rules[$attribute] ?? [], $normalized);
+ }
+ }
+ }
+
+ return $rules;
+ }
+
+ /**
+ * @param array $fields
+ * @return array
+ */
+ public function attributes(array $fields, NovaRequest $request): array
+ {
+ $attributes = [];
+
+ foreach ($this->fieldsForSubmission($fields, $request) as $field) {
+ if (method_exists($field, 'getValidationAttributeNames')) {
+ $attributes = array_merge($attributes, $field->getValidationAttributeNames($request));
+
+ continue;
+ }
+
+ $attribute = $this->attributeForField($field);
+
+ if ($attribute === null) {
+ continue;
+ }
+
+ $attributes[$attribute] = (string) ($this->introspector->toArray($field)['name']
+ ?? $this->introspector->property($field, 'name', $attribute));
+ }
+
+ return $attributes;
+ }
+
+ /**
+ * @param array $fields
+ * @param array $payload
+ * @return array
+ */
+ public function values(array $fields, array $payload, NovaRequest $request): array
+ {
+ return $this->resolve($fields, $payload, $request)->all();
+ }
+
+ /**
+ * @param array $fields
+ * @param array $payload
+ */
+ public function resolve(array $fields, array $payload, NovaRequest $request): FormFields
+ {
+ $submissionRequest = $this->requestForPayload($request, $payload);
+ $resolved = new Fluent;
+ $callbacks = $this->fieldsForSubmission($fields, $submissionRequest)
+ ->mapWithKeys(fn (object $field): array => [
+ $field->attribute => $field->fillForAction($submissionRequest, $resolved),
+ ])
+ ->filter(static fn (mixed $callback): bool => is_callable($callback));
+
+ return new FormFields($resolved->getAttributes(), $callbacks);
+ }
+
+ /**
+ * @param array $fields
+ */
+ public function fieldsForSerialization(array $fields, NovaRequest $request): FieldCollection
+ {
+ $collection = FieldCollection::make($fields)
+ ->authorized($request);
+
+ if (method_exists($collection, 'applyDependsOnWithDefaultValues')) {
+ $collection = $collection->applyDependsOnWithDefaultValues($request);
+ }
+
+ return $collection->values();
+ }
+
+ /**
+ * @param array $fields
+ */
+ public function fieldsForSubmission(array $fields, NovaRequest $request): FieldCollection
+ {
+ return FieldCollection::make($fields)
+ ->authorized($request)
+ ->applyDependsOn($request)
+ ->reject(static fn (object $field): bool => SupportedField::isDisplayOnly($field))
+ ->withoutReadonly($request)
+ ->withoutUnfillable()
+ ->values();
+ }
+
+ /**
+ * @param array $payload
+ */
+ public function requestForPayload(NovaRequest $request, array $payload): NovaRequest
+ {
+ $submissionRequest = NovaRequest::createFrom($request);
+ $submissionRequest->setUserResolver($request->getUserResolver());
+ $submissionRequest->merge($payload);
+ $submissionRequest->merge([
+ 'editing' => 'true',
+ 'editMode' => 'create',
+ ]);
+
+ return $submissionRequest;
+ }
+
+ public function attributeForField(object $field): ?string
+ {
+ $raw = $this->introspector->toArray($field);
+ $attribute = $raw['attribute'] ?? $this->introspector->property($field, 'attribute');
+
+ return is_string($attribute) && $attribute !== '' ? $attribute : null;
+ }
+
+ /**
+ * @return array
+ */
+ public function rulesForField(object $field, NovaRequest $request): array
+ {
+ $attribute = $this->attributeForField($field);
+
+ if ($attribute === null) {
+ return [];
+ }
+
+ return $this->normalizeRules(
+ $this->ruleMapForField($field, $request)[$attribute] ?? [],
+ $attribute,
+ $request
+ );
+ }
+
+ public function fieldIsRequired(object $field, NovaRequest $request): bool
+ {
+ foreach ($this->rulesForField($field, $request) as $rule) {
+ if (! is_string($rule)) {
+ continue;
+ }
+
+ foreach (explode('|', $rule) as $part) {
+ if (strtolower(trim(strtok($part, ':'))) === 'required') {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * @return array
+ */
+ protected function ruleMapForField(object $field, NovaRequest $request): array
+ {
+ if (method_exists($field, 'getCreationRules')) {
+ return $this->normalizeRuleMap($field->getCreationRules($request), $field, $request);
+ }
+
+ if (method_exists($field, 'getRules')) {
+ return $this->normalizeRuleMap($field->getRules($request), $field, $request);
+ }
+
+ $attribute = $this->attributeForField($field);
+
+ if ($attribute === null) {
+ return [];
+ }
+
+ return [
+ $attribute => $this->introspector->property($field, 'rules', []),
+ ];
+ }
+
+ /**
+ * @return array
+ */
+ protected function normalizeRuleMap(mixed $rules, object $field, NovaRequest $request): array
+ {
+ $rules = $this->evaluateRuleCallback($rules, $request);
+
+ if ($rules instanceof Arrayable) {
+ $rules = $rules->toArray();
+ }
+
+ if ($rules instanceof Collection) {
+ $rules = $rules->all();
+ }
+
+ if ($rules instanceof \Traversable) {
+ $rules = iterator_to_array($rules);
+ }
+
+ $attribute = $this->attributeForField($field);
+
+ if (! is_array($rules)) {
+ return $attribute === null ? [] : [$attribute => $rules];
+ }
+
+ if (array_is_list($rules)) {
+ return $attribute === null ? [] : [$attribute => $rules];
+ }
+
+ return $rules;
+ }
+
+ /**
+ * @return array
+ */
+ protected function normalizeRules(mixed $rules, string $attribute, NovaRequest $request): array
+ {
+ $rules = $this->evaluateRuleCallback($rules, $request);
+
+ if ($rules instanceof Arrayable) {
+ $rules = $rules->toArray();
+ }
+
+ if ($rules instanceof \Traversable) {
+ $rules = iterator_to_array($rules);
+ }
+
+ if (is_array($rules) && array_key_exists($attribute, $rules)) {
+ $rules = $rules[$attribute];
+ }
+
+ if ($rules === null || $rules === []) {
+ return [];
+ }
+
+ if (! is_array($rules)) {
+ return [$rules];
+ }
+
+ $normalized = [];
+
+ foreach ($rules as $rule) {
+ $rule = $this->evaluateRuleCallback($rule, $request);
+
+ if ($rule instanceof Arrayable) {
+ $rule = $rule->toArray();
+ }
+
+ if (is_array($rule)) {
+ array_push($normalized, ...$this->normalizeRules($rule, $attribute, $request));
+
+ continue;
+ }
+
+ if ($rule !== null) {
+ $normalized[] = $rule;
+ }
+ }
+
+ return $normalized;
+ }
+
+ protected function evaluateRuleCallback(mixed $rule, NovaRequest $request): mixed
+ {
+ if (! $rule instanceof Closure) {
+ return $rule;
+ }
+
+ $reflection = new ReflectionFunction($rule);
+
+ if ($reflection->getNumberOfParameters() <= 1) {
+ return $rule($request);
+ }
+
+ return $rule;
+ }
+}
diff --git a/src/Support/SupportedField.php b/src/Support/SupportedField.php
new file mode 100644
index 0000000..b777f32
--- /dev/null
+++ b/src/Support/SupportedField.php
@@ -0,0 +1,173 @@
+
+ */
+ protected const TYPES = [
+ PasswordConfirmation::class => 'password-confirmation',
+ KeyValue::class => 'key-value',
+ BooleanGroup::class => 'boolean-group',
+ MultiSelect::class => 'multi-select',
+ DateTime::class => 'date-time',
+ Currency::class => 'currency',
+ Textarea::class => 'textarea',
+ Timezone::class => 'timezone',
+ Country::class => 'country',
+ Sparkline::class => 'sparkline',
+ Gravatar::class => 'gravatar',
+ UiAvatar::class => 'ui-avatar',
+ Heading::class => 'heading',
+ Status::class => 'status',
+ Badge::class => 'badge',
+ Stack::class => 'stack',
+ Line::class => 'line',
+ Select::class => 'select',
+ Boolean::class => 'boolean',
+ Number::class => 'number',
+ Date::class => 'date',
+ Avatar::class => 'avatar',
+ Image::class => 'image',
+ Audio::class => 'audio',
+ File::class => 'file',
+ Password::class => 'password',
+ Hidden::class => 'hidden',
+ ID::class => 'id',
+ Email::class => 'email',
+ URL::class => 'url',
+ Slug::class => 'slug',
+ Token::class => 'token',
+ Color::class => 'color',
+ Code::class => 'code',
+ Text::class => 'text',
+ ];
+
+ /**
+ * @var array
+ */
+ protected const DISPLAY_ONLY = [
+ Badge::class => true,
+ Gravatar::class => true,
+ Heading::class => true,
+ Line::class => true,
+ Sparkline::class => true,
+ Stack::class => true,
+ Status::class => true,
+ UiAvatar::class => true,
+ ];
+
+ public static function typeFor(object $field): ?string
+ {
+ if ($field instanceof Unfillable && ! self::isDisplayOnly($field)) {
+ return null;
+ }
+
+ foreach (self::TYPES as $class => $type) {
+ if ($field instanceof $class) {
+ return $type;
+ }
+ }
+
+ return null;
+ }
+
+ public static function isSupported(object $field): bool
+ {
+ return self::typeFor($field) !== null;
+ }
+
+ public static function isDisplayOnly(object $field): bool
+ {
+ foreach (self::DISPLAY_ONLY as $class => $supported) {
+ if ($field instanceof $class) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * @return array
+ */
+ public static function names(): array
+ {
+ return [
+ __('nova-form-card::messages.fields.text'),
+ __('nova-form-card::messages.fields.textarea'),
+ __('nova-form-card::messages.fields.select'),
+ __('nova-form-card::messages.fields.boolean'),
+ __('nova-form-card::messages.fields.number'),
+ __('nova-form-card::messages.fields.date'),
+ __('nova-form-card::messages.fields.file'),
+ __('nova-form-card::messages.fields.image'),
+ __('nova-form-card::messages.fields.audio'),
+ __('nova-form-card::messages.fields.avatar'),
+ __('nova-form-card::messages.fields.email'),
+ __('nova-form-card::messages.fields.url'),
+ __('nova-form-card::messages.fields.password'),
+ __('nova-form-card::messages.fields.hidden'),
+ __('nova-form-card::messages.fields.id'),
+ __('nova-form-card::messages.fields.date_time'),
+ __('nova-form-card::messages.fields.currency'),
+ __('nova-form-card::messages.fields.color'),
+ __('nova-form-card::messages.fields.code'),
+ __('nova-form-card::messages.fields.country'),
+ __('nova-form-card::messages.fields.timezone'),
+ __('nova-form-card::messages.fields.multi_select'),
+ __('nova-form-card::messages.fields.boolean_group'),
+ __('nova-form-card::messages.fields.key_value'),
+ __('nova-form-card::messages.fields.slug'),
+ __('nova-form-card::messages.fields.token'),
+ __('nova-form-card::messages.fields.badge'),
+ __('nova-form-card::messages.fields.heading'),
+ __('nova-form-card::messages.fields.line'),
+ __('nova-form-card::messages.fields.stack'),
+ __('nova-form-card::messages.fields.sparkline'),
+ __('nova-form-card::messages.fields.status'),
+ __('nova-form-card::messages.fields.gravatar'),
+ __('nova-form-card::messages.fields.ui_avatar'),
+ __('nova-form-card::messages.fields.password_confirmation'),
+ ];
+ }
+}
diff --git a/tests/Feature/FormCardSerializationTest.php b/tests/Feature/FormCardSerializationTest.php
new file mode 100644
index 0000000..e1d64a2
--- /dev/null
+++ b/tests/Feature/FormCardSerializationTest.php
@@ -0,0 +1,157 @@
+serializeFormCard(new SerializableCard());
+ $form = $serialized['formCard'];
+
+ expect($form['title'])->toBe('Invite User')
+ ->and($form['endpoint'])->toBe('/nova-vendor/nova-form-card/submit')
+ ->and($form['submitText'])->toBe('Submit')
+ ->and($form['canSubmit'])->toBeTrue()
+ ->and($form['token'])->toBeString()->not->toBeEmpty();
+
+ $types = collect($form['fields'])->pluck('formCardType', 'attribute')->all();
+ $components = collect($form['fields'])->pluck('component', 'attribute')->all();
+
+ expect($types)->not->toHaveKey('hidden_secret');
+
+ expect($types)->toMatchArray([
+ 'email' => 'text',
+ 'message' => 'textarea',
+ 'role' => 'select',
+ 'active' => 'boolean',
+ 'seats' => 'number',
+ 'starts_at' => 'date',
+ 'starts_at_time' => 'date-time',
+ 'work_email' => 'email',
+ 'website' => 'url',
+ 'password' => 'password',
+ 'password_confirmation' => 'password-confirmation',
+ 'tracking_code' => 'hidden',
+ 'record_id' => 'id',
+ 'price' => 'currency',
+ 'brand_color' => 'color',
+ 'payload' => 'code',
+ 'country' => 'country',
+ 'timezone' => 'timezone',
+ 'tags' => 'multi-select',
+ 'permissions' => 'boolean-group',
+ 'metadata' => 'key-value',
+ 'slug' => 'slug',
+ 'api_token' => 'token',
+ 'attachment' => 'file',
+ 'avatar' => 'image',
+ 'profile_photo' => 'avatar',
+ 'voice_note' => 'audio',
+ 'invite_summary' => 'heading',
+ 'queue_label' => 'line',
+ 'invite_stats' => 'stack',
+ 'invite_trend' => 'sparkline',
+ 'health' => 'badge',
+ 'import_status' => 'status',
+ 'sender_email' => 'gravatar',
+ 'sender_name' => 'ui-avatar',
+ ])->and($components)->toMatchArray([
+ 'email' => 'text-field',
+ 'message' => 'textarea-field',
+ 'role' => 'select-field',
+ 'active' => 'boolean-field',
+ 'seats' => 'text-field',
+ 'starts_at' => 'date-field',
+ 'starts_at_time' => 'date-time-field',
+ 'work_email' => 'email-field',
+ 'website' => 'url-field',
+ 'password' => 'password-field',
+ 'password_confirmation' => 'password-field',
+ 'tracking_code' => 'hidden-field',
+ 'record_id' => 'id-field',
+ 'price' => 'currency-field',
+ 'brand_color' => 'color-field',
+ 'payload' => 'code-field',
+ 'country' => 'select-field',
+ 'timezone' => 'select-field',
+ 'tags' => 'multi-select-field',
+ 'permissions' => 'boolean-group-field',
+ 'metadata' => 'key-value-field',
+ 'slug' => 'slug-field',
+ 'api_token' => 'text-field',
+ 'attachment' => 'file-field',
+ 'avatar' => 'file-field',
+ 'profile_photo' => 'file-field',
+ 'voice_note' => 'audio-field',
+ 'invite_summary' => 'heading-field',
+ 'queue_label' => 'line-field',
+ 'invite_stats' => 'stack-field',
+ 'invite_trend' => 'sparkline-field',
+ 'health' => 'badge-field',
+ 'import_status' => 'status-field',
+ 'sender_email' => 'file-field',
+ 'sender_name' => 'file-field',
+ ]);
+
+ $displayOnly = collect($form['fields'])->pluck('displayOnly', 'attribute')->all();
+
+ expect($displayOnly)->toMatchArray([
+ 'password' => false,
+ 'password_confirmation' => false,
+ 'invite_summary' => true,
+ 'queue_label' => true,
+ 'invite_stats' => true,
+ 'invite_trend' => true,
+ 'health' => true,
+ 'import_status' => true,
+ 'sender_email' => true,
+ 'sender_name' => true,
+ ]);
+
+ $email = collect($form['fields'])->firstWhere('attribute', 'email');
+ $role = collect($form['fields'])->firstWhere('attribute', 'role');
+ $passwordConfirmation = collect($form['fields'])->firstWhere('attribute', 'password_confirmation');
+ $line = collect($form['fields'])->firstWhere('attribute', 'queue_label');
+ $badge = collect($form['fields'])->firstWhere('attribute', 'health');
+ $status = collect($form['fields'])->firstWhere('attribute', 'import_status');
+ $stack = collect($form['fields'])->firstWhere('attribute', 'invite_stats');
+
+ expect($email['required'])->toBeTrue()
+ ->and($email['value'])->toBe('taylor@example.com')
+ ->and($role['options'])->toContain([
+ 'label' => 'Admin',
+ 'value' => 'admin',
+ ])
+ ->and($badge['label'])->toBe('OK')
+ ->and($passwordConfirmation['type'])->toBe('password')
+ ->and($line['type'])->toBe('line')
+ ->and($status['type'])->toBe('success')
+ ->and($stack['lines'])->toHaveCount(2);
+});
+
+it('serializes and syncs Nova dependent fields', function (): void {
+ $serialized = $this->serializeFormCard(new DependentCard());
+ $form = $serialized['formCard'];
+ $email = collect($form['fields'])->firstWhere('attribute', 'email');
+
+ expect($form['syncEndpoint'])->toBe('/nova-vendor/nova-form-card/sync')
+ ->and($email['visible'])->toBeFalse()
+ ->and($email['dependsOn'])->toHaveKey('role')
+ ->and($email['dependentComponentKey'])->toBeString()->not->toBeEmpty();
+
+ $this->patchJson($form['syncEndpoint'].'?'.http_build_query([
+ 'token' => $form['token'],
+ 'editing' => 'true',
+ 'editMode' => 'create',
+ 'field' => 'email',
+ 'component' => $email['dependentComponentKey'],
+ ]), [
+ 'email' => '',
+ 'role' => 'admin',
+ ])
+ ->assertOk()
+ ->assertJson([
+ 'attribute' => 'email',
+ 'visible' => true,
+ 'type' => 'text',
+ ]);
+});
diff --git a/tests/Feature/FormCardSubmitTest.php b/tests/Feature/FormCardSubmitTest.php
new file mode 100644
index 0000000..264e946
--- /dev/null
+++ b/tests/Feature/FormCardSubmitTest.php
@@ -0,0 +1,200 @@
+tokenFor(new UnauthorizedCard());
+
+ $this->postJson('/nova-vendor/nova-form-card/submit', [
+ 'token' => $token,
+ 'fields' => [
+ 'email' => 'taylor@example.com',
+ ],
+ ])->assertForbidden();
+});
+
+it('validates submitted values using Nova field rules', function (): void {
+ $token = $this->tokenFor(new SuccessfulCard());
+
+ $this->postJson('/nova-vendor/nova-form-card/submit', [
+ 'token' => $token,
+ 'fields' => [
+ 'email' => 'not-an-email',
+ ],
+ ])
+ ->assertStatus(422)
+ ->assertJsonValidationErrors(['email']);
+});
+
+it('validates submitted values using Nova creation rules', function (): void {
+ $token = $this->tokenFor(new CreationRulesCard());
+
+ $this->postJson('/nova-vendor/nova-form-card/submit', [
+ 'token' => $token,
+ 'fields' => [
+ 'email' => 'taylor@example.com',
+ ],
+ ])
+ ->assertStatus(422)
+ ->assertJsonValidationErrors(['invite_code'])
+ ->assertJsonMissingValidationErrors(['hidden_secret']);
+});
+
+it('ignores hidden fields during submit validation', function (): void {
+ $token = $this->tokenFor(new CreationRulesCard());
+
+ $this->postJson('/nova-vendor/nova-form-card/submit', [
+ 'token' => $token,
+ 'fields' => [
+ 'email' => 'taylor@example.com',
+ 'invite_code' => 'NOVA',
+ ],
+ ])
+ ->assertOk()
+ ->assertJson([
+ 'type' => 'success',
+ 'message' => 'Created.',
+ ]);
+});
+
+it('passes validated field values to handle and returns a success response', function (): void {
+ $token = $this->tokenFor(new SuccessfulCard());
+
+ $this->postJson('/nova-vendor/nova-form-card/submit', [
+ 'token' => $token,
+ 'fields' => [
+ 'email' => 'taylor@example.com',
+ ],
+ ])
+ ->assertOk()
+ ->assertJson([
+ 'type' => 'success',
+ 'message' => 'Invitation sent.',
+ ]);
+
+ expect(SuccessfulCard::$handled)->toBe([
+ 'email' => 'taylor@example.com',
+ ]);
+});
+
+it('passes uploaded file fields to handle', function (): void {
+ $token = $this->tokenFor(new FileUploadCard());
+
+ $this->post('/nova-vendor/nova-form-card/submit', [
+ 'token' => $token,
+ 'fields' => [
+ 'attachment' => UploadedFile::fake()->create('terms.pdf', 12, 'application/pdf'),
+ 'avatar' => UploadedFile::fake()->image('avatar.jpg'),
+ 'voice_note' => UploadedFile::fake()->create('voice.mp3', 12, 'audio/mpeg'),
+ ],
+ ])
+ ->assertOk()
+ ->assertJson([
+ 'type' => 'success',
+ 'message' => 'Files received.',
+ ]);
+
+ expect(FileUploadCard::$handled)->toBe([
+ 'attachment' => 'terms.pdf',
+ 'avatar' => 'avatar.jpg',
+ 'voice_note' => 'voice.mp3',
+ ]);
+});
+
+it('passes additional supported field values to handle', function (): void {
+ $token = $this->tokenFor(new AdditionalFieldsCard());
+
+ $this->postJson('/nova-vendor/nova-form-card/submit', [
+ 'token' => $token,
+ 'fields' => [
+ 'work_email' => 'person@example.com',
+ 'website' => 'https://example.com',
+ 'secret' => 'super-secret',
+ 'secret_confirmation' => 'super-secret',
+ 'tracking_code' => 'abc123',
+ 'record_id' => '123',
+ 'starts_at_time' => '2026-07-10T10:30:00',
+ 'price' => '12.34',
+ 'brand_color' => '#ff0000',
+ 'payload' => '{"enabled":true}',
+ 'country' => 'IR',
+ 'timezone' => 'Asia/Tehran',
+ 'tags' => '["news","events"]',
+ 'permissions' => '{"read":true,"write":false}',
+ 'metadata' => '{"source":"nova"}',
+ 'slug' => 'person-example',
+ 'api_token' => 'secret-token',
+ ],
+ ])
+ ->assertOk()
+ ->assertJson([
+ 'type' => 'success',
+ 'message' => 'Additional fields received.',
+ ]);
+
+ expect(AdditionalFieldsCard::$handled)->toMatchArray([
+ 'work_email' => 'person@example.com',
+ 'website' => 'https://example.com',
+ 'tracking_code' => 'abc123',
+ 'record_id' => '123',
+ 'starts_at_time' => '2026-07-10T10:30:00',
+ 'price' => '12.34',
+ 'brand_color' => '#ff0000',
+ 'payload' => ['enabled' => true],
+ 'country' => 'IR',
+ 'timezone' => 'Asia/Tehran',
+ 'tags' => ['news', 'events'],
+ 'permissions' => ['read' => true, 'write' => false],
+ 'metadata' => ['source' => 'nova'],
+ 'slug' => 'person-example',
+ 'api_token' => 'secret-token',
+ ]);
+
+ expect(Hash::check('super-secret', AdditionalFieldsCard::$handled['secret']))->toBeTrue()
+ ->and(AdditionalFieldsCard::$handled)->not->toHaveKey('secret_confirmation');
+});
+
+it('validates password confirmation fields', function (): void {
+ $token = $this->tokenFor(new AdditionalFieldsCard());
+
+ $this->postJson('/nova-vendor/nova-form-card/submit', [
+ 'token' => $token,
+ 'fields' => [
+ 'work_email' => 'person@example.com',
+ 'website' => 'https://example.com',
+ 'secret' => 'super-secret',
+ 'secret_confirmation' => 'different-secret',
+ ],
+ ])
+ ->assertStatus(422)
+ ->assertJsonValidationErrors(['secret_confirmation']);
+});
+
+it('returns structured error responses from handle', function (): void {
+ $token = $this->tokenFor(new FailingCard());
+
+ $this->postJson('/nova-vendor/nova-form-card/submit', [
+ 'token' => $token,
+ 'fields' => [
+ 'email' => 'taylor@example.com',
+ ],
+ ])
+ ->assertOk()
+ ->assertJson([
+ 'type' => 'error',
+ 'message' => 'No invitation was sent.',
+ ]);
+});
diff --git a/tests/Fixtures/AdditionalFieldsCard.php b/tests/Fixtures/AdditionalFieldsCard.php
new file mode 100644
index 0000000..ffb7254
--- /dev/null
+++ b/tests/Fixtures/AdditionalFieldsCard.php
@@ -0,0 +1,68 @@
+
+ */
+ public static array $handled = [];
+
+ public function fields(NovaRequest $request): array
+ {
+ return [
+ Email::make('Work Email', 'work_email')->rules('required', 'email'),
+ URL::make('Website')->rules('required', 'url'),
+ Password::make('Secret')->rules('required'),
+ PasswordConfirmation::make('Secret Confirmation', 'secret_confirmation')->rules('required', 'same:secret'),
+ Hidden::make('Tracking Code'),
+ ID::make('Record ID', 'record_id'),
+ DateTime::make('Starts At Time'),
+ Currency::make('Price'),
+ Color::make('Brand Color'),
+ Code::make('Payload')->json(),
+ Country::make('Country'),
+ Timezone::make('Timezone'),
+ MultiSelect::make('Tags')->options([
+ 'news' => 'News',
+ 'events' => 'Events',
+ ]),
+ BooleanGroup::make('Permissions')->options([
+ 'read' => 'Read',
+ 'write' => 'Write',
+ ]),
+ KeyValue::make('Metadata'),
+ Slug::make('Slug'),
+ Token::make('Api Token'),
+ ];
+ }
+
+ public function handle(FormFields $fields, NovaRequest $request): mixed
+ {
+ self::$handled = $fields->all();
+
+ return static::message('Additional fields received.');
+ }
+}
diff --git a/tests/Fixtures/CreationRulesCard.php b/tests/Fixtures/CreationRulesCard.php
new file mode 100644
index 0000000..4bafaa9
--- /dev/null
+++ b/tests/Fixtures/CreationRulesCard.php
@@ -0,0 +1,25 @@
+rules('required', 'email'),
+ Text::make('Invite Code')->creationRules('required'),
+ Text::make('Hidden Secret')->canSee(fn (): bool => false)->rules('required'),
+ ];
+ }
+
+ public function handle(FormFields $fields, NovaRequest $request): mixed
+ {
+ return static::message('Created.');
+ }
+}
diff --git a/tests/Fixtures/DependentCard.php b/tests/Fixtures/DependentCard.php
new file mode 100644
index 0000000..1eca458
--- /dev/null
+++ b/tests/Fixtures/DependentCard.php
@@ -0,0 +1,33 @@
+hide()
+ ->dependsOn(['role'], function (Text $field, NovaRequest $request, $data): void {
+ $field->visible = $data['role'] === 'admin';
+ }),
+
+ Select::make('Role')->options([
+ 'admin' => 'Admin',
+ 'staff' => 'Staff',
+ ]),
+ ];
+ }
+
+ public function handle(FormFields $fields, NovaRequest $request): mixed
+ {
+ return static::message('Synced.');
+ }
+}
diff --git a/tests/Fixtures/FailingCard.php b/tests/Fixtures/FailingCard.php
new file mode 100644
index 0000000..fa69aaf
--- /dev/null
+++ b/tests/Fixtures/FailingCard.php
@@ -0,0 +1,23 @@
+rules('required', 'email'),
+ ];
+ }
+
+ public function handle(FormFields $fields, NovaRequest $request): mixed
+ {
+ return static::error('No invitation was sent.');
+ }
+}
diff --git a/tests/Fixtures/FileUploadCard.php b/tests/Fixtures/FileUploadCard.php
new file mode 100644
index 0000000..ca974c4
--- /dev/null
+++ b/tests/Fixtures/FileUploadCard.php
@@ -0,0 +1,45 @@
+
+ */
+ public static array $handled = [];
+
+ public function fields(NovaRequest $request): array
+ {
+ return [
+ File::make('Attachment')->rules('required', 'file'),
+ Image::make('Avatar')->rules('required', 'image'),
+ Audio::make('Voice Note')->rules('required', 'file'),
+ ];
+ }
+
+ public function handle(FormFields $fields, NovaRequest $request): mixed
+ {
+ self::$handled = [
+ 'attachment' => $fields->attachment instanceof UploadedFile
+ ? $fields->attachment->getClientOriginalName()
+ : null,
+ 'avatar' => $fields->avatar instanceof UploadedFile
+ ? $fields->avatar->getClientOriginalName()
+ : null,
+ 'voice_note' => $fields->voice_note instanceof UploadedFile
+ ? $fields->voice_note->getClientOriginalName()
+ : null,
+ ];
+
+ return static::message('Files received.');
+ }
+}
diff --git a/tests/Fixtures/SerializableCard.php b/tests/Fixtures/SerializableCard.php
new file mode 100644
index 0000000..47fb6d3
--- /dev/null
+++ b/tests/Fixtures/SerializableCard.php
@@ -0,0 +1,113 @@
+default('taylor@example.com')->rules('required', 'email'),
+ Textarea::make('Message'),
+ Select::make('Role')->options([
+ 'admin' => 'Admin',
+ 'member' => 'Member',
+ ]),
+ Boolean::make('Active'),
+ Number::make('Seats')->rules('nullable', 'integer', 'min:1'),
+ Date::make('Starts At'),
+ DateTime::make('Starts At Time'),
+ Email::make('Work Email', 'work_email'),
+ URL::make('Website'),
+ Password::make('Password'),
+ PasswordConfirmation::make('Password Confirmation', 'password_confirmation'),
+ Hidden::make('Tracking Code')->default('abc123'),
+ ID::make('Record ID', 'record_id'),
+ Currency::make('Price'),
+ Color::make('Brand Color'),
+ Code::make('Payload')->json(),
+ Country::make('Country'),
+ Timezone::make('Timezone'),
+ MultiSelect::make('Tags')->options([
+ 'news' => 'News',
+ 'events' => 'Events',
+ ]),
+ BooleanGroup::make('Permissions')->options([
+ 'read' => 'Read',
+ 'write' => 'Write',
+ ]),
+ KeyValue::make('Metadata'),
+ Slug::make('Slug'),
+ Token::make('Api Token'),
+ File::make('Attachment'),
+ Image::make('Avatar'),
+ Avatar::make('Profile Photo'),
+ Audio::make('Voice Note'),
+ Heading::make('Invite Summary'),
+ Line::make('Queue Label')->default('Queue healthy'),
+ Stack::make('Invite Stats', [
+ Line::make('Pending Invites')->asHeading()->default('3 pending'),
+ Line::make('Last Invite')->default('Today'),
+ ]),
+ Sparkline::make('Invite Trend')->data([1, 3, 2, 5])->height(48),
+ Badge::make('Health')->map([
+ 'ok' => 'success',
+ ])->labels([
+ 'ok' => 'OK',
+ ])->default('ok'),
+ Status::make('Import Status')->loadingWhen(['waiting'])->failedWhen(['failed'])->default('finished'),
+ Gravatar::make('Sender Gravatar', 'sender_email')->default('sender@example.com'),
+ UiAvatar::make('Sender Initials', 'sender_name')->default('Taylor Otwell'),
+ Text::make('Hidden Secret')->canSee(fn (): bool => false)->rules('required'),
+ ];
+ }
+
+ public function handle(FormFields $fields, NovaRequest $request): mixed
+ {
+ return static::message('Serialized.');
+ }
+}
diff --git a/tests/Fixtures/SuccessfulCard.php b/tests/Fixtures/SuccessfulCard.php
new file mode 100644
index 0000000..e12c2af
--- /dev/null
+++ b/tests/Fixtures/SuccessfulCard.php
@@ -0,0 +1,30 @@
+
+ */
+ public static array $handled = [];
+
+ public function fields(NovaRequest $request): array
+ {
+ return [
+ Text::make('Email')->rules('required', 'email'),
+ ];
+ }
+
+ public function handle(FormFields $fields, NovaRequest $request): mixed
+ {
+ self::$handled = $fields->all();
+
+ return static::message('Invitation sent.');
+ }
+}
diff --git a/tests/Fixtures/UnauthorizedCard.php b/tests/Fixtures/UnauthorizedCard.php
new file mode 100644
index 0000000..f4112ae
--- /dev/null
+++ b/tests/Fixtures/UnauthorizedCard.php
@@ -0,0 +1,13 @@
+in('Feature', 'Unit');
diff --git a/tests/TestCase.php b/tests/TestCase.php
new file mode 100644
index 0000000..d8a88ea
--- /dev/null
+++ b/tests/TestCase.php
@@ -0,0 +1,52 @@
+set('app.key', 'base64:MDEyMzQ1Njc4OWFiY2RlZjAxMjM0NTY3ODlhYmNkZWY=');
+ $app['config']->set('nova-form-card.token_ttl_minutes', 120);
+
+ $app['router']->aliasMiddleware('nova', SubstituteBindings::class);
+ }
+
+ protected function novaRequest(string $method = 'GET', string $uri = '/nova'): NovaRequest
+ {
+ $request = NovaRequest::create($uri, $method);
+
+ $this->app->instance('request', $request);
+ $this->app->instance(NovaRequest::class, $request);
+
+ return $request;
+ }
+
+ /**
+ * @return array
+ */
+ protected function serializeFormCard(FormCard $card): array
+ {
+ $this->novaRequest();
+
+ return $card->jsonSerialize();
+ }
+
+ protected function tokenFor(FormCard $card): string
+ {
+ return (string) data_get($this->serializeFormCard($card), 'formCard.token');
+ }
+}
diff --git a/tests/Unit/FormCardResponseTest.php b/tests/Unit/FormCardResponseTest.php
new file mode 100644
index 0000000..fb4aee3
--- /dev/null
+++ b/tests/Unit/FormCardResponseTest.php
@@ -0,0 +1,38 @@
+toArray())->toBe([
+ 'type' => 'success',
+ 'message' => 'Done.',
+ ]);
+});
+
+it('formats error responses', function (): void {
+ expect(FormCardResponse::error('Failed.')->toArray())->toBe([
+ 'type' => 'error',
+ 'message' => 'Failed.',
+ ]);
+});
+
+it('formats redirect responses', function (): void {
+ expect(FormCardResponse::visit('/resources/users', ['preserveScroll' => true])->toArray())->toBe([
+ 'type' => 'redirect',
+ 'redirect' => [
+ 'url' => '/resources/users',
+ 'remote' => false,
+ 'options' => [
+ 'preserveScroll' => true,
+ ],
+ ],
+ ]);
+});
+
+it('formats refresh responses', function (): void {
+ expect(FormCardResponse::refresh('Updated.')->toArray())->toBe([
+ 'type' => 'refresh',
+ 'message' => 'Updated.',
+ 'refresh' => true,
+ ]);
+});
diff --git a/vite.config.js b/vite.config.js
new file mode 100644
index 0000000..d400705
--- /dev/null
+++ b/vite.config.js
@@ -0,0 +1,36 @@
+import { defineConfig } from 'vite'
+import vue from '@vitejs/plugin-vue'
+import path from 'node:path'
+
+export default defineConfig({
+ plugins: [vue()],
+ define: {
+ 'process.env.NODE_ENV': JSON.stringify('production'),
+ },
+ build: {
+ outDir: 'dist',
+ emptyOutDir: false,
+ cssCodeSplit: true,
+ lib: {
+ entry: path.resolve(process.cwd(), 'resources/js/card.js'),
+ name: 'NovaFormCard',
+ formats: ['iife'],
+ fileName: () => 'js/card.js',
+ },
+ rollupOptions: {
+ external: ['vue'],
+ output: {
+ globals: {
+ vue: 'Vue',
+ },
+ assetFileNames: assetInfo => {
+ if (assetInfo.name && assetInfo.name.endsWith('.css')) {
+ return 'css/card.css'
+ }
+
+ return 'assets/[name][extname]'
+ },
+ },
+ },
+ },
+})