Skip to content

Beautiful Open-Source Form Builder

Focused style (#887)

Julien Nahuma913868b9371
diff --git a/.cursor/rules/opnform-overview.mdc b/.cursor/rules/opnform-overview.mdc
new file mode 100644
index 000000000..5a98f197b
--- /dev/null
+++ b/.cursor/rules/opnform-overview.mdc
@@ -0,0 +1,202 @@
+---
+description: Overview of the opnform project and its structure - use when a user request is too broad as a pointer
+alwaysApply: false
+---
+
+# OpnForm overview: product, features, and code map
+
+## What OpnForm is
+
+OpnForm is a flexible, privacy‑respecting form builder with logic, embeds, analytics, and integrations (Zapier, webhooks, etc.). It’s built with a Nuxt client (Vue 3) and a Laravel API.
+
+## High‑level architecture
+
+- Client (Nuxt) — `client/`
+ - UI, editor, preview, public rendering, embeds, analytics UI
+ - API clients — `client/api/*.js`
+ - Form editor — `client/components/open/forms/components/FormEditor.vue`
+ - Public renderers — `client/components/open/forms/OpenForm.vue` (Classic), `client/components/open/forms/OpenFormFocused.vue` (Focused)
+ - Block/field metadata — `client/data/blocks_types.json`
+ - Form initialization/composables — `client/lib/forms/composables/*`, `client/composables/forms/initForm.js`
+ - Styling — `client/css/*`, icons — `client/public/icons/*`
+- API (Laravel) — `api/`
+ - Models/resources/requests — `api/app/Models/**`, `api/app/Http/Resources/**`, `api/app/Http/Requests/**`
+ - Routes — `api/routes/*.php`
+ - Migrations — `api/database/migrations/*`
+ - Business services & jobs — `api/app/Service/**`, `api/app/Jobs/**`
+
+## Core features (product)
+
+- Form builder with blocks/fields, conditional logic, validations, and themes
+- Two presentation styles (Classic, Focused)
+- Sharing & embeds (inline, popup)
+- Notifications, integrations (Zapier, webhooks), exports
+- Analytics and submission browsing
+
+## Presentation styles
+
+OpnForm supports two `presentation_style` values on forms: `classic` and `focused`.
+
+- Classic
+
+ - Multi‑input pages; supports pages and layout/media blocks.
+ - Rendered by `client/components/open/forms/OpenForm.vue` and `OpenFormField.vue`.
+ - Default input size is medium (`md`).
+
+- Focused (Typeform‑style)
+ - One question per step; large input size (`lg`).
+ - Rendered by `client/components/open/forms/OpenFormFocused.vue`.
+ - Per‑question media and layout options are available when an image is added:
+ - Layouts: `between`, `left-small`, `right-small`, `left-split`, `right-split`, `background`.
+ - Defaults and settings are managed in `client/components/open/forms/components/media/BlockMediaOptions.vue`.
+ - Controls include focal point, brightness, and alt; default layout is `between`.
+ - Colors & background: one theme color, plus optional background image with adjustable opacity (configured alongside per‑question media settings).
+
+### Switching styles (editor behavior)
+
+- UI control: `client/components/open/forms/components/form-components/PresentationStyleSwitch.vue`.
+- When switching, unsupported blocks for the target mode are detected using `available_in` from `client/data/blocks_types.json`.
+- If there are unsupported blocks, the editor shows a confirmation modal that lists affected blocks; confirming removes them.
+- Input size auto‑adjusts: `lg` in Focused, `md` in Classic.
+- Questions, responses, logic, integrations, and sharing continue to work after switching.
+
+## Editor & preview
+
+- Main editor: `client/components/open/forms/components/FormEditor.vue`
+- Live preview: `client/components/open/forms/components/form-components/FormEditorPreview.vue`
+- Customization panel (theme, size, etc.): `client/components/open/forms/components/form-components/FormCustomization.vue`
+- Per‑step media/layout for Focused: `client/components/open/forms/components/media/BlockMediaOptions.vue`
+
+## Logic, blocks, fields
+
+- Block/field registry & availability: `client/data/blocks_types.json` (includes `available_in` for Classic/Focused)
+- Logic editors: `client/components/open/forms/components/form-logic-components/*`
+- Field option editors: `client/components/open/forms/fields/components/*`
+
+## API data flow (simplified)
+
+- Form loading/initialization: `client/lib/forms/composables/useFormInitialization.js`, `client/lib/forms/composables/useFormManager.js`, `client/composables/forms/initForm.js`
+- API endpoints used by client: `client/api/forms.js` and related modules
+- Server model/resource layer: `api/app/Models/Forms/Form.php`, `api/app/Http/Resources/FormResource.php`
+- `presentation_style` storage: migration adds column — `api/database/migrations/*add_presentation_style_to_forms_table.php`
+
+## Embeds & sharing
+
+- Embed helpers and UI: `client/components/pages/forms/show/EmbedCode.vue`, `client/components/pages/forms/show/EmbedFormAsPopupModal.vue`
+- Public form routes/pages: `client/pages/forms/[slug]/**`
+
+## Notifications & integrations
+
+- Integrations: Zapier app in `integrations/zapier/`
+- Webhooks and notifications: implemented on the API side under `api/app/Http/**`, `api/app/Service/**`, and related events/listeners
+- Client‑side settings UIs are in the form editor components under `client/components/open/forms/components/**`
+
+## Analytics & submissions
+
+- Submission viewing and stats: `client/components/open/forms/components/FormSubmissions.vue`, `client/components/open/forms/components/FormStats.vue`, `FormTrafficBreakdown.vue`
+- Exports: `client/components/open/forms/components/FormExportModal.vue`
+
+## Testing
+
+We currently only test the back-end laravel app.
+
+- Laravel tests: `api/tests/**` (Feature, Unit, Browser/Dusk)
+
+# OpnForm overview: product, features, and code map
+
+## What OpnForm is
+
+OpnForm is a flexible, privacy‑respecting form builder with logic, embeds, analytics, and integrations (Zapier, webhooks, etc.). It’s built with a Nuxt client (Vue 3) and a Laravel API.
+
+## High‑level architecture
+
+- Client (Nuxt) — `client/`
+ - UI, editor, preview, public rendering, embeds, analytics UI
+ - API clients — `client/api/*.js`
+ - Form editor — `client/components/open/forms/components/FormEditor.vue`
+ - Public renderers — `client/components/open/forms/OpenForm.vue` (Classic), `client/components/open/forms/OpenFormFocused.vue` (Focused)
+ - Block/field metadata — `client/data/blocks_types.json`
+ - Form initialization/composables — `client/lib/forms/composables/*`, `client/composables/forms/initForm.js`
+ - Styling — `client/css/*`, icons — `client/public/icons/*`
+- API (Laravel) — `api/`
+ - Models/resources/requests — `api/app/Models/**`, `api/app/Http/Resources/**`, `api/app/Http/Requests/**`
+ - Routes — `api/routes/*.php`
+ - Migrations — `api/database/migrations/*`
+ - Business services & jobs — `api/app/Service/**`, `api/app/Jobs/**`
+
+## Core features (product)
+
+- Form builder with blocks/fields, conditional logic, validations, and themes
+- Two presentation styles (Classic, Focused)
+- Sharing & embeds (inline, popup)
+- Notifications, integrations (Zapier, webhooks), exports
+- Analytics and submission browsing
+
+## Presentation styles
+
+OpnForm supports two `presentation_style` values on forms: `classic` and `focused`.
+
+- Classic
+
+ - Multi‑input pages; supports pages and layout/media blocks.
+ - Rendered by `client/components/open/forms/OpenForm.vue` and `OpenFormField.vue`.
+ - Default input size is medium (`md`).
+
+- Focused (Typeform‑style)
+ - One question per step; large input size (`lg`).
+ - Rendered by `client/components/open/forms/OpenFormFocused.vue`.
+ - Per‑question media and layout options are available when an image is added:
+ - Layouts: `between`, `left-small`, `right-small`, `left-split`, `right-split`, `background`.
+ - Defaults and settings are managed in `client/components/open/forms/components/media/BlockMediaOptions.vue`.
+ - Controls include focal point, brightness, and alt; default layout is `between`.
+ - Colors & background: one theme color, plus optional background image with adjustable opacity (configured alongside per‑question media settings).
+
+### Switching styles (editor behavior)
+
+- UI control: `client/components/open/forms/components/form-components/PresentationStyleSwitch.vue`.
+- When switching, unsupported blocks for the target mode are detected using `available_in` from `client/data/blocks_types.json`.
+- If there are unsupported blocks, the editor shows a confirmation modal that lists affected blocks; confirming removes them.
+- Input size auto‑adjusts: `lg` in Focused, `md` in Classic.
+- Questions, responses, logic, integrations, and sharing continue to work after switching.
+
+## Editor & preview
+
+- Main editor: `client/components/open/forms/components/FormEditor.vue`
+- Live preview: `client/components/open/forms/components/form-components/FormEditorPreview.vue`
+- Customization panel (theme, size, etc.): `client/components/open/forms/components/form-components/FormCustomization.vue`
+- Per‑step media/layout for Focused: `client/components/open/forms/components/media/BlockMediaOptions.vue`
+
+## Logic, blocks, fields
+
+- Block/field registry & availability: `client/data/blocks_types.json` (includes `available_in` for Classic/Focused)
+- Logic editors: `client/components/open/forms/components/form-logic-components/*`
+- Field option editors: `client/components/open/forms/fields/components/*`
+
+## API data flow (simplified)
+
+- Form loading/initialization: `client/lib/forms/composables/useFormInitialization.js`, `client/lib/forms/composables/useFormManager.js`, `client/composables/forms/initForm.js`
+- API endpoints used by client: `client/api/forms.js` and related modules
+- Server model/resource layer: `api/app/Models/Forms/Form.php`, `api/app/Http/Resources/FormResource.php`
+- `presentation_style` storage: migration adds column — `api/database/migrations/*add_presentation_style_to_forms_table.php`
+
+## Embeds & sharing
+
+- Embed helpers and UI: `client/components/pages/forms/show/EmbedCode.vue`, `client/components/pages/forms/show/EmbedFormAsPopupModal.vue`
+- Public form routes/pages: `client/pages/forms/[slug]/**`
+
+## Notifications & integrations
+
+- Integrations: Zapier app in `integrations/zapier/`
+- Webhooks and notifications: implemented on the API side under `api/app/Http/**`, `api/app/Service/**`, and related events/listeners
+- Client‑side settings UIs are in the form editor components under `client/components/open/forms/components/**`
+
+## Analytics & submissions
+
+- Submission viewing and stats: `client/components/open/forms/components/FormSubmissions.vue`, `client/components/open/forms/components/FormStats.vue`, `FormTrafficBreakdown.vue`
+- Exports: `client/components/open/forms/components/FormExportModal.vue`
+
+## Testing
+
+We currently only test the back-end laravel app.
+
+- Laravel tests: `api/tests/**` (Feature, Unit, Browser/Dusk)
diff --git a/api/app/Http/Controllers/Forms/AiFormController.php b/api/app/Http/Controllers/Forms/AiFormController.php
index 356a44e0b..92dfb3312 100644
--- a/api/app/Http/Controllers/Forms/AiFormController.php
+++ b/api/app/Http/Controllers/Forms/AiFormController.php
@@ -17,6 +17,7 @@ class AiFormController extends Controller
'message' => 'We\'re working on your form, please wait ~1 min.',
'ai_form_completion_id' => AiFormCompletion::create([
'form_prompt' => $request->input('form_prompt'),
+ 'generation_params' => $request->input('generation_params', []),
'ip' => $request->ip(),
])->id,
]);
@@ -44,6 +45,7 @@ class AiFormController extends Controller
'type' => AiFormCompletion::TYPE_FIELDS,
'form_prompt' => $request->input('fields_prompt'),
'context' => $request->input('current_form_structure'),
+ 'generation_params' => $request->input('generation_params', []),
'ip' => $request->ip(),
])->id,
]);
diff --git a/api/app/Http/Requests/AiGenerateFieldsRequest.php b/api/app/Http/Requests/AiGenerateFieldsRequest.php
index a443b6671..c042dbd25 100644
--- a/api/app/Http/Requests/AiGenerateFieldsRequest.php
+++ b/api/app/Http/Requests/AiGenerateFieldsRequest.php
@@ -18,6 +18,8 @@ class AiGenerateFieldsRequest extends FormRequest
return [
'fields_prompt' => 'required|string|max:' . $maxLength,
'current_form_structure' => 'nullable|array',
+ 'generation_params' => 'nullable|array',
+ 'generation_params.presentation_style' => 'nullable|in:classic,focused',
];
}
}
diff --git a/api/app/Http/Requests/AiGenerateFormRequest.php b/api/app/Http/Requests/AiGenerateFormRequest.php
index 8cb08d1f6..0a160bb1d 100644
--- a/api/app/Http/Requests/AiGenerateFormRequest.php
+++ b/api/app/Http/Requests/AiGenerateFormRequest.php
@@ -17,6 +17,8 @@ class AiGenerateFormRequest extends FormRequest
return [
'form_prompt' => 'required|string|max:' . $maxLength,
+ 'generation_params' => 'nullable|array',
+ 'generation_params.presentation_style' => 'nullable|in:classic,focused',
];
}
}
diff --git a/api/app/Http/Requests/UserFormRequest.php b/api/app/Http/Requests/UserFormRequest.php
index 70db5775d..844c0c46d 100644
--- a/api/app/Http/Requests/UserFormRequest.php
+++ b/api/app/Http/Requests/UserFormRequest.php
@@ -112,19 +112,28 @@ abstract class UserFormRequest extends \Illuminate\Foundation\Http\FormRequest
'language' => ['required', Rule::in(Form::LANGUAGES)],
'font_family' => 'string|nullable',
'theme' => ['required', Rule::in(Form::THEMES)],
+ 'presentation_style' => ['required', Rule::in(Form::PRESENTATION_STYLES)],
'width' => ['required', Rule::in(Form::WIDTHS)],
'size' => ['required', Rule::in(Form::SIZES)],
'layout_rtl' => 'boolean',
'border_radius' => ['required', Rule::in(Form::BORDER_RADIUS)],
- 'cover_picture' => 'url|nullable',
- 'logo_picture' => 'url|nullable',
'dark_mode' => ['required', Rule::in(Form::DARK_MODE_VALUES)],
'color' => 'required|string',
'uppercase_labels' => 'required|boolean',
'no_branding' => 'required|boolean',
'transparent_background' => 'required|boolean',
+ 'translations' => 'nullable|array',
'closes_at' => 'date|nullable',
'closed_text' => 'string|nullable',
+ 'logo_picture' => 'url|nullable',
+
+ // Cover
+ 'cover_picture' => 'url|nullable',
+ 'cover_settings' => 'nullable|array',
+ 'cover_settings.focal_point' => 'sometimes|nullable|array',
+ 'cover_settings.focal_point.x' => 'sometimes|nullable|numeric|min:0|max:100',
+ 'cover_settings.focal_point.y' => 'sometimes|nullable|numeric|min:0|max:100',
+ 'cover_settings.brightness' => 'sometimes|nullable|integer|min:-100|max:100',
// Custom Code
'custom_code' => 'string|nullable',
@@ -165,6 +174,23 @@ abstract class UserFormRequest extends \Illuminate\Foundation\Http\FormRequest
'properties.*.allowed_file_types' => 'sometimes|nullable',
'properties.*.use_toggle_switch' => 'boolean|nullable',
+ // Media (Focused mode only)
+ 'properties.*.image' => 'sometimes|nullable|array',
+ 'properties.*.image.url' => 'sometimes|nullable|url',
+ 'properties.*.image.alt' => 'sometimes|nullable|string|max:125',
+ 'properties.*.image.layout' => ['sometimes', 'nullable', Rule::in([
+ 'between',
+ 'left-small',
+ 'right-small',
+ 'left-split',
+ 'right-split',
+ 'background'
+ ])],
+ 'properties.*.image.focal_point' => 'sometimes|nullable|array',
+ 'properties.*.image.focal_point.x' => 'sometimes|nullable|numeric|min:0|max:100',
+ 'properties.*.image.focal_point.y' => 'sometimes|nullable|numeric|min:0|max:100',
+ 'properties.*.image.brightness' => 'sometimes|nullable|integer|min:-100|max:100',
+
// Logic
'properties.*.logic' => ['array', 'nullable', new FormPropertyLogicRule()],
@@ -207,6 +233,10 @@ abstract class UserFormRequest extends \Illuminate\Foundation\Http\FormRequest
// Custom SEO
'seo_meta' => 'nullable|array',
'custom_domain' => 'sometimes|nullable|regex:' . CustomDomainRequest::CUSTOM_DOMAINS_REGEX,
+
+ // Settings
+ 'settings' => 'nullable|array',
+ 'settings.navigation_arrows' => 'sometimes|boolean',
];
}
diff --git a/api/app/Http/Resources/FormResource.php b/api/app/Http/Resources/FormResource.php
index d8b25f4d4..9e21c4db0 100644
--- a/api/app/Http/Resources/FormResource.php
+++ b/api/app/Http/Resources/FormResource.php
@@ -48,17 +48,22 @@ class FormResource extends JsonResource
}
return array_merge(parent::toArray($request), $ownerData, [
+ 'settings' => $this->settings ?? new \stdClass(),
'is_pro' => $this->workspaceIsPro(),
'is_trialing' => $this->workspaceIsTrialing(),
'workspace_id' => $this->workspace_id,
'workspace' => new WorkspaceResource($this->workspace),
'is_closed' => $this->is_closed,
+ 'size' => $this->size,
'is_password_protected' => false,
'has_password' => $this->has_password,
'max_number_of_submissions_reached' => $this->max_number_of_submissions_reached,
'form_pending_submission_key' => $this->form_pending_submission_key,
'max_file_size' => $this->workspace->max_file_size / 1000000,
'auto_save' => $this->getAutoSave(),
+ 'presentation_style' => $this->presentation_style ?? 'classic',
+ 'cover_settings' => $this->cover_settings ?? new \stdClass(),
+ 'translations' => $this->translations ?? new \stdClass(),
]);
}
@@ -84,6 +89,7 @@ class FormResource extends JsonResource
'language' => $this->language,
'theme' => $this->theme,
'is_password_protected' => true,
+ 'presentation_style' => $this->presentation_style,
'has_password' => $this->has_password,
'width' => 'centered',
'layout_rtl' => $this->layout_rtl,
@@ -92,7 +98,7 @@ class FormResource extends JsonResource
'logo_picture' => $this->logo_picture,
'seo_meta' => $this->seo_meta,
'cover_picture' => $this->cover_picture,
-
+ 'cover_settings' => $this->cover_settings ?? new \stdClass(),
];
}
diff --git a/api/app/Jobs/Form/GenerateAiForm.php b/api/app/Jobs/Form/GenerateAiForm.php
index fb5324e9c..86d786bbc 100644
--- a/api/app/Jobs/Form/GenerateAiForm.php
+++ b/api/app/Jobs/Form/GenerateAiForm.php
@@ -40,8 +40,9 @@ class GenerateAiForm implements ShouldQueue
]);
try {
- // Use the static run method to execute the prompt
- $formData = GenerateFormPrompt::run($this->completion->form_prompt);
+ // Use the static run method to execute the prompt with params
+ $params = $this->completion->generation_params ?? [];
+ $formData = GenerateFormPrompt::run($this->completion->form_prompt, $params);
$this->completion->update([
'status' => AiFormCompletion::STATUS_COMPLETED,
diff --git a/api/app/Jobs/Form/GenerateAiFormFields.php b/api/app/Jobs/Form/GenerateAiFormFields.php
index eba9c2cd8..d06cac73c 100644
--- a/api/app/Jobs/Form/GenerateAiFormFields.php
+++ b/api/app/Jobs/Form/GenerateAiFormFields.php
@@ -43,11 +43,13 @@ class GenerateAiFormFields implements ShouldQueue
$formTitle = $context['title'] ?? '';
$existingFields = $context['properties'] ?? [];
- // Use the static run method to execute the prompt
+ // Use the static run method to execute the prompt with params
+ $params = $this->completion->generation_params ?? [];
$fieldsData = GenerateFormFieldsPrompt::run(
$this->completion->form_prompt,
$formTitle,
- $existingFields
+ $existingFields,
+ $params
);
$this->completion->update([
diff --git a/api/app/Models/Forms/AI/AiFormCompletion.php b/api/app/Models/Forms/AI/AiFormCompletion.php
index 0773ea4fe..b3f7929f4 100644
--- a/api/app/Models/Forms/AI/AiFormCompletion.php
+++ b/api/app/Models/Forms/AI/AiFormCompletion.php
@@ -29,6 +29,7 @@ class AiFormCompletion extends Model
'error',
'type',
'context',
+ 'generation_params',
];
protected $attributes = [
@@ -40,6 +41,7 @@ class AiFormCompletion extends Model
{
return [
'context' => 'array',
+ 'generation_params' => 'array',
];
}
diff --git a/api/app/Models/Forms/Form.php b/api/app/Models/Forms/Form.php
index 45af64d38..d23bea8f0 100644
--- a/api/app/Models/Forms/Form.php
+++ b/api/app/Models/Forms/Form.php
@@ -38,6 +38,8 @@ class Form extends Model implements CachableAttributes
public const THEMES = ['default', 'simple', 'notion', 'minimal'];
+ public const PRESENTATION_STYLES = ['classic', 'focused'];
+
public const WIDTHS = ['centered', 'full'];
public const VISIBILITY = ['public', 'draft', 'closed'];
@@ -61,15 +63,21 @@ class Form extends Model implements CachableAttributes
'size',
'border_radius',
'theme',
+ 'presentation_style',
'width',
'layout_rtl',
'cover_picture',
+ 'cover_settings',
'logo_picture',
'dark_mode',
'color',
'uppercase_labels',
'no_branding',
'transparent_background',
+ 'translations',
+
+ // Settings
+ 'settings',
// Custom Code
'custom_code',
@@ -113,8 +121,12 @@ class Form extends Model implements CachableAttributes
'tags' => 'array',
'removed_properties' => 'array',
'seo_meta' => 'object',
+ 'cover_settings' => 'array',
+ 'translations' => 'array',
'enable_partial_submissions' => 'boolean',
'auto_save' => 'boolean',
+ 'presentation_style' => 'string',
+ 'settings' => 'array',
];
}
diff --git a/api/app/Service/AI/Prompts/Form/GenerateFormFieldsPrompt.php b/api/app/Service/AI/Prompts/Form/GenerateFormFieldsPrompt.php
index e7a1cfaf1..7244ef292 100644
--- a/api/app/Service/AI/Prompts/Form/GenerateFormFieldsPrompt.php
+++ b/api/app/Service/AI/Prompts/Form/GenerateFormFieldsPrompt.php
@@ -29,29 +29,11 @@ class GenerateFormFieldsPrompt extends Prompt
Return an array of field objects that fit the context and complement the existing form structure. Consider the form's purpose and existing fields when generating new fields.
- Available field types:
- - text: Text input (use multi_lines: true for multi-line text)
- - rich_text: Rich text input
- - date: Date picker (use with_time: true to include time selection)
- - url: URL input with validation
- - phone_number: Phone number input
- - email: Email input with validation
- - checkbox: Single checkbox for yes/no (use use_toggle_switch: true for toggle switch)
- - select: Dropdown selection (use without_dropdown: true for radio buttons, recommended for <5 options)
- - multi_select: Multiple selection (use without_dropdown: true for checkboxes, recommended for <5 options)
- - matrix: Matrix input with rows and columns
- - number: Numeric input
- - rating: Star rating
- - scale: Numeric scale
- - slider: Slider selection
- - files: File upload
- - signature: Signature pad
- - barcode: Barcode scanner
- - nf-text: Rich text content (not an input field)
- - nf-page-break: Page break for multi-page forms
- - nf-divider: Visual divider (not an input field)
- - nf-image: Image element
- - nf-code: Code block
+ Presentation mode and constraints:
+ {modeConstraints}
+
+ Available field types (mode-aware):
+ {allowedFieldTypesList}
HTML formatting for nf-text:
- Headers: <h1>, <h2> for section titles and subtitles
@@ -62,18 +44,7 @@ class GenerateFormFieldsPrompt extends Prompt
- Paragraphs: <p>paragraph text</p> for text blocks with spacing
Use these HTML tags to create well-structured and visually appealing form content.
- Field width options:
- - width: "full" (default, takes entire width)
- - width: "1/2" (takes half width)
- - width: "1/3" (takes a third of the width)
- - width: "2/3" (takes two thirds of the width)
- - width: "1/4" (takes a quarter of the width)
- - width: "3/4" (takes three quarters of the width)
- Fields with width less than "full" will be placed on the same line if there's enough room. For example:
- - Two 1/2 width fields will be placed side by side
- - Three 1/3 width fields will be placed on the same line
- - etc.
- No need for lines width to be complete. Don't abuse putting multiple fields on the same line if it doesn't make sense. For First name and Last name, it works well for instance.
+ {widthGuidance}
Field generation guidelines:
- Choose the most appropriate field type based on the data being collected
@@ -133,7 +104,8 @@ class GenerateFormFieldsPrompt extends Prompt
public function __construct(
public string $formPrompt,
public string $formTitle = '',
- public array $existingFields = []
+ public array $existingFields = [],
+ public array $params = []
) {
parent::__construct();
}
@@ -167,9 +139,50 @@ class GenerateFormFieldsPrompt extends Prompt
// Add the formatted existing fields
$variables['{existingFields}'] = $this->formatExistingFields();
+ $rules = PresentationRules::buildContext($this->params);
+ $variables['{modeConstraints}'] = $rules['constraintsText'];
+ $variables['{widthGuidance}'] = $rules['mode'] === PresentationRules::MODE_FOCUSED
+ ? 'In focused mode, do not use width options. Each step contains a single full-width question.'
+ : 'Field width options:\n- width: "full" (default)\n- width: "1/2"\n- width: "1/3"\n- width: "2/3"\n- width: "1/4"\n- width: "3/4"\nFields can share rows when room allows.';
+ $variables['{allowedFieldTypesList}'] = $this->formatAllowedTypes($rules['allowedFieldTypes']);
+
return $variables;
}
+ private function formatAllowedTypes(array $types): string
+ {
+ $map = [
+ 'text' => 'text: Text input (use multi_lines: true for multi-line text)',
+ 'rich_text' => 'rich_text: Rich text input',
+ 'date' => 'date: Date picker (use with_time: true to include time selection)',
+ 'url' => 'url: URL input with validation',
+ 'phone_number' => 'phone_number: Phone number input',
+ 'email' => 'email: Email input with validation',
+ 'checkbox' => 'checkbox: Single checkbox for yes/no (use use_toggle_switch: true for toggle switch)',
+ 'select' => 'select: Dropdown selection (use without_dropdown: true for radio buttons, recommended for <5 options)',
+ 'multi_select' => 'multi_select: Multiple selection (use without_dropdown: true for checkboxes, recommended for <5 options)',
+ 'matrix' => 'matrix: Matrix input with rows and columns',
+ 'number' => 'number: Numeric input',
+ 'rating' => 'rating: Star rating',
+ 'scale' => 'scale: Numeric scale',
+ 'slider' => 'slider: Slider selection',
+ 'files' => 'files: File upload',
+ 'signature' => 'signature: Signature pad',
+ 'barcode' => 'barcode: Barcode scanner',
+ 'nf-text' => 'nf-text: Rich text content (not an input field)',
+ 'nf-page-break' => 'nf-page-break: Page break for multi-page forms',
+ 'nf-divider' => 'nf-divider: Visual divider (not an input field)',
+ 'nf-image' => 'nf-image: Image element',
+ 'nf-code' => 'nf-code: Code block',
+ ];
+
+ $lines = array_map(function ($t) use ($map) {
+ return '- ' . ($map[$t] ?? $t);
+ }, $types);
+
+ return implode("\n", $lines);
+ }
+
/**
* Format existing fields for display in the prompt
*/
diff --git a/api/app/Service/AI/Prompts/Form/GenerateFormPrompt.php b/api/app/Service/AI/Prompts/Form/GenerateFormPrompt.php
index f92fc1f47..2e555ad41 100644
--- a/api/app/Service/AI/Prompts/Form/GenerateFormPrompt.php
+++ b/api/app/Service/AI/Prompts/Form/GenerateFormPrompt.php
@@ -26,29 +26,11 @@ class GenerateFormPrompt extends Prompt
You can use for instance nf-text to add a title or text to the form using some basic html (h1, p, b, i, u etc).
Order of blocks matters.
- Available field types:
- - text: Text input (use multi_lines: true for multi-line text)
- - rich_text: Rich text input
- - date: Date picker (use with_time: true to include time selection)
- - url: URL input with validation
- - phone_number: Phone number input
- - email: Email input with validation
- - checkbox: Single checkbox for yes/no (use use_toggle_switch: true for toggle switch)
- - select: Dropdown selection (use without_dropdown: true for radio buttons, recommended for <5 options)
- - multi_select: Multiple selection (use without_dropdown: true for checkboxes, recommended for <5 options)
- - matrix: Matrix input with rows and columns
- - number: Numeric input
- - rating: Star rating
- - scale: Numeric scale
- - slider: Slider selection
- - files: File upload
- - signature: Signature pad
- - barcode: Barcode scanner
- - nf-text: Rich text content (not an input field)
- - nf-page-break: Page break for multi-page forms
- - nf-divider: Visual divider (not an input field)
- - nf-image: Image element
- - nf-code: Code block
+ Presentation mode and constraints:
+ {modeConstraints}
+
+ Available field types (mode-aware):
+ {allowedFieldTypesList}
HTML formatting for nf-text:
- Headers: <h1>, <h2> for section titles and subtitles
@@ -59,18 +41,7 @@ class GenerateFormPrompt extends Prompt
- Paragraphs: <p>paragraph text</p> for text blocks with spacing
Use these HTML tags to create well-structured and visually appealing form content.
- Field width options:
- - width: "full" (default, takes entire width)
- - width: "1/2" (takes half width)
- - width: "1/3" (takes a third of the width)
- - width: "2/3" (takes two thirds of the width)
- - width: "1/4" (takes a quarter of the width)
- - width: "3/4" (takes three quarters of the width)
- Fields with width less than "full" will be placed on the same line if there's enough room. For example:
- - Two 1/2 width fields will be placed side by side
- - Three 1/3 width fields will be placed on the same line
- - etc.
- No need for lines width to be complete. Don't abuse putting multiple fields on the same line if it doens't make sense. For First name and Last name, it works well for instance.
+ {widthGuidance}
If the form is too long, you can paginate it by adding one or multiple page breaks (nf-page-break).
@@ -163,7 +134,8 @@ class GenerateFormPrompt extends Prompt
];
public function __construct(
- public string $formPrompt
+ public string $formPrompt,
+ public array $params = []
) {
parent::__construct();
}
@@ -204,4 +176,55 @@ class GenerateFormPrompt extends Prompt
return $formData;
}
+
+ protected function getPromptVariables(): array
+ {
+ $vars = parent::getPromptVariables();
+ $rules = PresentationRules::buildContext($this->params);
+
+ $modeConstraints = $rules['constraintsText'];
+
+ $widthGuidance = $rules['mode'] === PresentationRules::MODE_FOCUSED
+ ? 'In focused mode, do not use width options. Each step contains a single full-width question.'
+ : 'Field width options:\n- width: "full" (default, takes entire width)\n- width: "1/2" (takes half width)\n- width: "1/3" (takes a third of the width)\n- width: "2/3" (takes two thirds of the width)\n- width: "1/4" (takes a quarter of the width)\n- width: "3/4" (takes three quarters of the width)\nFields with width less than "full" may share a row when room allows.';
+
+ $vars['{modeConstraints}'] = $modeConstraints;
+ $vars['{widthGuidance}'] = $widthGuidance;
+ $vars['{allowedFieldTypesList}'] = $this->formatAllowedTypes($rules['allowedFieldTypes']);
+ return $vars;
+ }
+
+ private function formatAllowedTypes(array $types): string
+ {
+ $map = [
+ 'text' => 'text: Text input (use multi_lines: true for multi-line text)',
+ 'rich_text' => 'rich_text: Rich text input',
+ 'date' => 'date: Date picker (use with_time: true to include time selection)',
+ 'url' => 'url: URL input with validation',
+ 'phone_number' => 'phone_number: Phone number input',
+ 'email' => 'email: Email input with validation',
+ 'checkbox' => 'checkbox: Single checkbox for yes/no (use use_toggle_switch: true for toggle switch)',
+ 'select' => 'select: Dropdown selection (use without_dropdown: true for radio buttons, recommended for <5 options)',
+ 'multi_select' => 'multi_select: Multiple selection (use without_dropdown: true for checkboxes, recommended for <5 options)',
+ 'matrix' => 'matrix: Matrix input with rows and columns',
+ 'number' => 'number: Numeric input',
+ 'rating' => 'rating: Star rating',
+ 'scale' => 'scale: Numeric scale',
+ 'slider' => 'slider: Slider selection',
+ 'files' => 'files: File upload',
+ 'signature' => 'signature: Signature pad',
+ 'barcode' => 'barcode: Barcode scanner',
+ 'nf-text' => 'nf-text: Rich text content (not an input field)',
+ 'nf-page-break' => 'nf-page-break: Page break for multi-page forms',
+ 'nf-divider' => 'nf-divider: Visual divider (not an input field)',
+ 'nf-image' => 'nf-image: Image element',
+ 'nf-code' => 'nf-code: Code block',
+ ];
+
+ $lines = array_map(function ($t) use ($map) {
+ return '- ' . ($map[$t] ?? $t);
+ }, $types);
+
+ return implode("\n", $lines);
+ }
}
diff --git a/api/app/Service/AI/Prompts/Form/PresentationRules.php b/api/app/Service/AI/Prompts/Form/PresentationRules.php
new file mode 100644
index 000000000..85ce3d146
--- /dev/null
+++ b/api/app/Service/AI/Prompts/Form/PresentationRules.php
@@ -0,0 +1,39 @@
+<?php
+
+namespace App\Service\AI\Prompts\Form;
+
+class PresentationRules
+{
+ public const MODE_CLASSIC = 'classic';
+ public const MODE_FOCUSED = 'focused';
+
+ public static function buildContext(array $params = []): array
+ {
+ $mode = $params['presentation_style'] ?? self::MODE_CLASSIC;
+
+ if ($mode === self::MODE_FOCUSED) {
+ return [
+ 'mode' => self::MODE_FOCUSED,
+ 'allowedFieldTypes' => [
+ 'text','rich_text','date','url','phone_number','email','checkbox','select','multi_select','matrix','number','rating','scale','slider','files','signature','barcode','nf-text'
+ ],
+ 'constraintsText' => implode("\n", [
+ 'Focused mode (Typeform-like):',
+ '- Display one question per page/step, sequentially.',
+ '- Do not use widths (all inputs are full width).',
+ '- Do not use page breaks (nf-page-break).',
+ '- Do not include image (nf-image) or code (nf-code) blocks.',
+ '- Keep copy concise and engaging for each step.'
+ ])
+ ];
+ }
+
+ return [
+ 'mode' => self::MODE_CLASSIC,
+ 'allowedFieldTypes' => [
+ 'text','rich_text','date','url','phone_number','email','checkbox','select','multi_select','matrix','number','rating','scale','slider','files','signature','barcode','nf-text','nf-page-break','nf-divider','nf-image','nf-code'
+ ],
+ 'constraintsText' => 'Classic mode: you can use layout widths and optional page breaks.'
+ ];
+ }
+}
diff --git a/api/database/factories/FormFactory.php b/api/database/factories/FormFactory.php
index 905ae847b..b899e2d7e 100644
--- a/api/database/factories/FormFactory.php
+++ b/api/database/factories/FormFactory.php
@@ -52,6 +52,7 @@ class FormFactory extends Factory
'visibility' => 'public',
'language' => 'en',
'theme' => $this->faker->randomElement(Form::THEMES),
+ 'presentation_style' => 'classic',
'size' => $this->faker->randomElement(Form::SIZES),
'border_radius' => $this->faker->randomElement(Form::BORDER_RADIUS),
'width' => $this->faker->randomElement(Form::WIDTHS),
diff --git a/api/database/migrations/2025_09_17_000001_add_presentation_style_to_forms_table.php b/api/database/migrations/2025_09_17_000001_add_presentation_style_to_forms_table.php
new file mode 100644
index 000000000..859dd97d9
--- /dev/null
+++ b/api/database/migrations/2025_09_17_000001_add_presentation_style_to_forms_table.php
@@ -0,0 +1,21 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class () extends Migration {
+ public function up(): void
+ {
+ Schema::table('forms', function (Blueprint $table) {
+ $table->string('presentation_style')->default('classic')->after('theme');
+ });
+ }
+
+ public function down(): void
+ {
+ Schema::table('forms', function (Blueprint $table) {
+ $table->dropColumn('presentation_style');
+ });
+ }
+};
diff --git a/api/database/migrations/2025_09_19_000001_add_cover_settings_to_forms_table.php b/api/database/migrations/2025_09_19_000001_add_cover_settings_to_forms_table.php
new file mode 100644
index 000000000..22c37633d
--- /dev/null
+++ b/api/database/migrations/2025_09_19_000001_add_cover_settings_to_forms_table.php
@@ -0,0 +1,28 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Query\Expression;
+
+return new class () extends Migration {
+ public function up(): void
+ {
+ $driver = config('database.default');
+
+ Schema::table('forms', function (Blueprint $table) use ($driver) {
+ if ($driver === 'mysql') {
+ $table->json('cover_settings')->default(new Expression('(JSON_OBJECT())'))->nullable(true);
+ } else {
+ $table->json('cover_settings')->default('{}')->nullable(true);
+ }
+ });
+ }
+
+ public function down(): void
+ {
+ Schema::table('forms', function (Blueprint $table) {
+ $table->dropColumn('cover_settings');
+ });
+ }
+};
diff --git a/api/database/migrations/2025_10_08_000001_add_translations_to_forms_table.php b/api/database/migrations/2025_10_08_000001_add_translations_to_forms_table.php
new file mode 100644
index 000000000..ebeb0b382
--- /dev/null
+++ b/api/database/migrations/2025_10_08_000001_add_translations_to_forms_table.php
@@ -0,0 +1,23 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class () extends Migration {
+ public function up(): void
+ {
+ Schema::table('forms', function (Blueprint $table) {
+ $table->json('translations')->nullable();
+ });
+ }
+
+ public function down(): void
+ {
+ Schema::table('forms', function (Blueprint $table) {
+ if (Schema::hasColumn('forms', 'translations')) {
+ $table->dropColumn('translations');
+ }
+ });
+ }
+};
diff --git a/api/database/migrations/2025_10_11_000001_add_generation_params_to_ai_form_completions_table.php b/api/database/migrations/2025_10_11_000001_add_generation_params_to_ai_form_completions_table.php
new file mode 100644
index 000000000..284f23f3a
--- /dev/null
+++ b/api/database/migrations/2025_10_11_000001_add_generation_params_to_ai_form_completions_table.php
@@ -0,0 +1,21 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class () extends Migration {
+ public function up(): void
+ {
+ Schema::table('ai_form_completions', function (Blueprint $table) {
+ $table->json('generation_params')->nullable();
+ });
+ }
+
+ public function down(): void
+ {
+ Schema::table('ai_form_completions', function (Blueprint $table) {
+ $table->dropColumn('generation_params');
+ });
+ }
+};
diff --git a/api/database/migrations/2025_10_11_000001_add_settings_to_forms_table.php b/api/database/migrations/2025_10_11_000001_add_settings_to_forms_table.php
new file mode 100644
index 000000000..1528c82b3
--- /dev/null
+++ b/api/database/migrations/2025_10_11_000001_add_settings_to_forms_table.php
@@ -0,0 +1,21 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class () extends Migration {
+ public function up(): void
+ {
+ Schema::table('forms', function (Blueprint $table) {
+ $table->json('settings')->nullable()->after('transparent_background');
+ });
+ }
+
+ public function down(): void
+ {
+ Schema::table('forms', function (Blueprint $table) {
+ $table->dropColumn('settings');
+ });
+ }
+};
diff --git a/client/app.config.ts b/client/app.config.ts
index c8d70148e..fbf6aee9c 100644
--- a/client/app.config.ts
+++ b/client/app.config.ts
@@ -1,4 +1,7 @@
export default defineAppConfig({
+ icon: {
+ cssLayer: 'base',
+ },
ui: {
colors: {
primary: 'blue',
diff --git a/client/components/forms/core/OptionSelectorInput.vue b/client/components/forms/core/OptionSelectorInput.vue
index 27f5d3e64..e6f0b0cca 100644
--- a/client/components/forms/core/OptionSelectorInput.vue
+++ b/client/components/forms/core/OptionSelectorInput.vue
@@ -24,7 +24,7 @@
:class="optionClasses(isSelected(option))"
>
<button
- class="flex flex-col items-center justify-center transition-colors focus:outline-hidden w-full h-full"
+ class="group flex flex-col items-center justify-center transition-colors focus:outline-hidden w-full h-full"
:class="[buttonClasses(disabled || option.disabled), option.class ? (typeof option.class === 'function' ? option.class(isSelected(option)) : option.class) : {}, isSelected(option) ? 'text-form-color' : 'text-inherit']"
:aria-selected="isSelected(option) ? 'true' : 'false'"
:tabindex="disabled || option.disabled ? -1 : 0"
@@ -38,11 +38,13 @@
<Icon
v-if="option.icon"
:name="isSelected(option) && option.selectedIcon ? option.selectedIcon : option.icon"
+ mode="svg"
:class="[
'w-4 h-4',
option.label ? 'mb-1' : '',
isSelected(option) ? 'text-form-color' : 'text-inherit',
- option.iconClass ? (typeof option.iconClass === 'function' ? option.iconClass(isSelected(option)) : option.iconClass) : {}
+ option.iconClass ? (typeof option.iconClass === 'function' ? option.iconClass(isSelected(option)) : option.iconClass) : {},
+ isSelected(option) && option.iconSelectedClass ? (typeof option.iconSelectedClass === 'function' ? option.iconSelectedClass(true) : option.iconSelectedClass) : {}
]"
/>
</slot>
@@ -97,7 +99,8 @@ const props = defineProps({
multiple: { type: Boolean, default: false },
optionKey: { type: String, default: 'name' },
columns: { type: Number, default: 3 },
- seamless: { type: Boolean, default: false }
+ seamless: { type: Boolean, default: false },
+ clearable: { type: Boolean, default: false }
})
const emit = defineEmits(['update:modelValue', 'focus', 'blur'])
@@ -150,13 +153,22 @@ function selectOption(option) {
let newValue = Array.isArray(compVal.value) ? [...compVal.value] : []
const idx = newValue.indexOf(option[props.optionKey])
if (idx > -1) {
+ // If removing would result in empty selection and not clearable, block
+ const nextLen = newValue.length - 1
+ if (!props.clearable && nextLen < 1) return
newValue.splice(idx, 1)
} else {
newValue.push(option[props.optionKey])
}
compVal.value = newValue
} else {
- compVal.value = isSelected(option) ? null : option[props.optionKey]
+ // Only allow clearing (setting to null) if clearable is true
+ if (isSelected(option)) {
+ if (!props.clearable) return
+ compVal.value = null
+ } else {
+ compVal.value = option[props.optionKey]
+ }
}
}
diff --git a/client/components/forms/core/SliderInput.vue b/client/components/forms/core/SliderInput.vue
index b9ea62a91..d103bae72 100644
--- a/client/components/forms/core/SliderInput.vue
+++ b/client/components/forms/core/SliderInput.vue
@@ -14,7 +14,8 @@
</div>
</div>
<input
- v-model="compVal"
+ ref="range"
+ v-model.number="compVal"
type="range"
:class="[ui.slider(), 'slider']"
:style="{ '--thumb-color': color }"
@@ -57,6 +58,7 @@ export default {
minSlider: { type: Number, default: 0 },
maxSlider: { type: Number, default: 50 },
stepSlider: { type: Number, default: 5 },
+ thumbSize: { type: Number, default: 16 },
},
setup(props, context) {
@@ -71,14 +73,20 @@ export default {
...formInput
}
},
+ data() {
+ return {
+ inputWidth: 0,
+ }
+ },
computed: {
labelStyle() {
const ratio =
- ((this.compVal - this.minSlider) / (this.maxSlider - this.minSlider)) *
- 100
+ (Number(this.compVal) - this.minSlider) / (this.maxSlider - this.minSlider)
+ const width = this.inputWidth || (this.$refs.range ? this.$refs.range.offsetWidth : 0)
+ const x = (ratio * (width - this.thumbSize)) + (this.thumbSize / 2)
return {
- left: `${ratio}%`,
- marginLeft: `-${(ratio / 100) * 15}px`,
+ left: `${x}px`,
+ transform: 'translateX(-50%)',
}
},
sliderLabelsList() {
@@ -101,8 +109,26 @@ export default {
},
},
mounted() {
- this.compVal = parseInt(this.compVal ?? this.minSlider)
+ // Initialize only if no value provided; don't override an existing model value
+ if (this.compVal === undefined || this.compVal === null || isNaN(Number(this.compVal))) {
+ const initial = (this.modelValue !== undefined && this.modelValue !== null && !isNaN(Number(this.modelValue)))
+ ? Number(this.modelValue)
+ : 0
+ this.compVal = initial
+ }
+ this.updateInputWidth()
+ window.addEventListener('resize', this.updateInputWidth)
},
+ beforeUnmount() {
+ window.removeEventListener('resize', this.updateInputWidth)
+ },
+ methods: {
+ updateInputWidth() {
+ this.$nextTick(() => {
+ this.inputWidth = this.$refs.range ? this.$refs.range.offsetWidth : 0
+ })
+ }
+ }
}
</script>
diff --git a/client/components/forms/core/TextBlock.vue b/client/components/forms/core/TextBlock.vue
index 4e4e13c49..f56fc6501 100644
--- a/client/components/forms/core/TextBlock.vue
+++ b/client/components/forms/core/TextBlock.vue
@@ -1,14 +1,27 @@
<template>
<div
+ class="text-block"
:class="classes"
- v-html="processedContent"
- />
+ >
+ <div v-if="media && media.url" class="mb-3" :class="ui.media()">
+ <BlockMediaLayout
+ :image="media"
+ :fallback-height="''"
+ :class="ui.mediaComponent()"
+ :img-class="ui.mediaImg()"
+ />
+ </div>
+ <div v-html="processedContent" />
+ </div>
+
</template>
<script setup>
import { useParseMention } from '@/composables/components/useParseMention'
import { tv } from 'tailwind-variants'
import { textBlockTheme } from '~/lib/forms/themes/text-block.theme.js'
+import BlockMediaLayout from '~/components/open/forms/components/BlockMediaLayout.vue'
+import { inputWrapperTheme } from '~/lib/forms/themes/input-wrapper.theme.js'
const props = defineProps({
content: { type: String, required: true },
@@ -16,6 +29,8 @@ const props = defineProps({
form: { type: Object, default: null },
formData: { type: Object, default: null },
size: { type: String, default: null },
+ media: { type: Object, default: null },
+ borderRadius: { type: String, default: null },
})
const processedContent = computed(() => {
@@ -23,7 +38,28 @@ const processedContent = computed(() => {
})
const injectedSize = inject('formSize', null)
+const injectedBorderRadius = inject('formBorderRadius', null)
const resolvedSize = computed(() => props.size || injectedSize?.value || 'md')
const variants = computed(() => tv(textBlockTheme))
const classes = computed(() => variants.value({ size: resolvedSize.value }).root())
+
+// Media UI (reuse input wrapper theme for border radius handling)
+const resolvedBorderRadius = computed(() => props.borderRadius || injectedBorderRadius?.value || 'small')
+const ui = computed(() => {
+ return tv(inputWrapperTheme)({
+ borderRadius: resolvedBorderRadius.value,
+ mediaStyle: 'intrinsic'
+ })
+})
</script>
+
+<style>
+@reference '~/css/app.css';
+
+.text-block h1 {
+ @apply mb-2;
+}
+.text-block h2 {
+ @apply mb-1;
+}
+</style>
diff --git a/client/components/forms/core/components/InputWrapper.vue b/client/components/forms/core/components/InputWrapper.vue
index 15cac9677..6c0c3d5d3 100644
--- a/client/components/forms/core/components/InputWrapper.vue
+++ b/client/components/forms/core/components/InputWrapper.vue
@@ -13,6 +13,7 @@
:uppercase-labels="uppercaseLabels"
:theme="theme"
:size="resolvedSize"
+ :presentation="presentationStyle"
:ui="ui?.label"
/>
</VTransition>
@@ -27,12 +28,23 @@
:help="help"
:help-classes="ui.help()"
>
- <template #after-help>
+ <template #after-help v-if="!!$slots['bottom_after_help']">
<slot name="bottom_after_help" />
</template>
</InputHelp>
</VTransition>
</slot>
+ <template v-if="media && media.url">
+ <div :class="ui.media()">
+ <BlockMediaLayout
+ :image="media"
+ :fallback-height="''"
+ :class="ui.mediaComponent()"
+ :img-class="ui.mediaImg()"
+ />
+ </div>
+ </template>
+
<slot />
<slot
@@ -44,7 +56,7 @@
:help="help"
:help-classes="ui.help()"
>
- <template #after-help>
+ <template #after-help v-if="!!$slots['bottom_after_help']">
<slot name="bottom_after_help" />
</template>
</InputHelp>
@@ -57,6 +69,7 @@
:form="form"
:field-id="name"
:field-name="label"
+ :error-classes="ui.error()"
/>
</VTransition>
</slot>
@@ -69,6 +82,7 @@ import InputHelp from './InputHelp.vue'
import {twMerge} from "tailwind-merge"
import { tv } from "tailwind-variants"
import { inputWrapperTheme } from "~/lib/forms/themes/input-wrapper.theme.js"
+import BlockMediaLayout from '~/components/open/forms/components/BlockMediaLayout.vue'
const props = defineProps({
id: { type: String, required: false },
@@ -83,28 +97,43 @@ const props = defineProps({
hideFieldName: { type: Boolean, default: true },
required: { type: Boolean, default: false },
hasValidation: { type: Boolean, default: true },
+ media: { type: Object, default: null },
// Theme configuration as strings for tailwind-variants
theme: {type: String, default: 'default'},
size: {type: String, default: null},
+ borderRadius: {type: String, default: null},
ui: {type: Object, default: () => ({})}
})
// Inject theme values for centralized resolution
const injectedSize = inject('formSize', null)
+const injectedBorderRadius = inject('formBorderRadius', null)
// Resolve size with proper reactivity
const resolvedSize = computed(() => {
return props.size || injectedSize?.value || 'md'
})
+const resolvedBorderRadius = computed(() => {
+ return props.borderRadius || injectedBorderRadius?.value || 'small'
+})
+
+const injectedPresentationStyle = computed(() => {
+ return inject('formPresentationStyle', ref('classic'))?.value || 'classic'
+})
+
// OPTIMIZED: Single computed following Nuxt UI pattern
const ui = computed(() => {
return tv(inputWrapperTheme, props.ui)({
- size: resolvedSize.value
+ size: resolvedSize.value,
+ borderRadius: resolvedBorderRadius.value,
+ mediaStyle: 'intrinsic',
+ presentation: injectedPresentationStyle.value
})
})
// Wrapper classes with twMerge operation - makes sense as computed property
const wrapperClasses = computed(() => twMerge(ui.value.wrapper(), props.wrapperClass))
+const presentationStyle = computed(() => injectedPresentationStyle.value)
</script>
diff --git a/client/components/forms/core/validation/HasError.vue b/client/components/forms/core/validation/HasError.vue
index 800b04656..7b2246d90 100644
--- a/client/components/forms/core/validation/HasError.vue
+++ b/client/components/forms/core/validation/HasError.vue
@@ -2,7 +2,7 @@
<transition name="fade">
<div
v-if="errorMessage"
- class="has-error text-xs text-red-500 mt-1 break-words whitespace-break-spaces"
+ :class="errorClasses"
v-html="errorMessage"
/>
</transition>
@@ -24,6 +24,10 @@ export default {
type: String,
required: false,
},
+ errorClasses: {
+ type: String,
+ default: 'has-error text-xs text-red-500 mt-1 break-words whitespace-break-spaces',
+ },
},
computed: {
errorMessage() {
diff --git a/client/components/forms/heavy/ImageInput.vue b/client/components/forms/heavy/ImageInput.vue
index 7b8421e07..774198f1c 100644
--- a/client/components/forms/heavy/ImageInput.vue
+++ b/client/components/forms/heavy/ImageInput.vue
@@ -34,14 +34,15 @@
>
<div class="flex-grow">
<img
- :src="tmpFile ?? currentUrl"
+ :src="currentUrl"
class="h-5 rounded-sm shadow-sm border"
>
</div>
+ <slot name="left-action" />
<a
href="#"
class="text-neutral-500 hover:text-red-500 flex items-center"
- @click.prevent="clearUrl"
+ @click.stop.prevent="clearUrl"
>
<Icon
name="heroicons:trash"
diff --git a/client/components/forms/heavy/PaymentInput.client.vue b/client/components/forms/heavy/PaymentInput.client.vue
index d68592ada..9bcf00b5a 100644
--- a/client/components/forms/heavy/PaymentInput.client.vue
+++ b/client/components/forms/heavy/PaymentInput.client.vue
@@ -19,7 +19,7 @@
</div>
<div
v-else-if="showSuccessState"
- class="my-4 p-4 text-center text-sm text-green-700 bg-green-100 dark:bg-green-900/50 dark:text-green-300 rounded-md"
+ :class="ui.section() + ' p-4 text-center text-sm text-green-700 bg-green-100 dark:bg-green-900/50 dark:text-green-300 rounded-md'"
>
<div class="flex items-center justify-center gap-2">
<Icon
@@ -32,7 +32,7 @@
<template v-else>
<div
v-if="shouldShowPreviewMessage || (props.isAdminPreview && (!stripeState.stripeAccountId || !publishableKey || !isStripeJsLoaded))"
- class="my-4 p-4 text-center text-sm text-blue-700 bg-blue-100 dark:bg-blue-900/50 dark:text-blue-300 rounded-md"
+ :class="ui.section() + ' p-4 text-center text-sm text-blue-700 bg-blue-100 dark:bg-blue-900/50 dark:text-blue-300 rounded-md'"
>
<p v-if="shouldShowPreviewMessage">Please save the form to activate the payment preview.</p>
<p v-else>
@@ -45,19 +45,19 @@
</div>
<div
v-else-if="stripeState && stripeState.isLoadingAccount"
- class="my-4 flex justify-center"
+ :class="ui.section() + ' flex justify-center'"
>
<Loader class="mx-auto h-6 w-6" />
</div>
<div
v-else-if="stripeState && stripeState.hasAccountLoadingError"
- class="my-4 p-4 text-center text-sm text-red-700 bg-red-100 dark:bg-red-900/50 dark:text-red-300 rounded-md"
+ :class="ui.section() + ' p-4 text-center text-sm text-red-700 bg-red-100 dark:bg-red-900/50 dark:text-red-300 rounded-md'"
>
<p>{{ stripeState.errorMessage || 'Failed to load payment configuration' }}</p>
</div>
<div
v-else-if="stripeState && stripeState.stripeAccountId && isStripeJsLoaded && publishableKey"
- class="my-2"
+ :class="ui.section()"
>
<div :class="ui.amountBar()">
<span class="text-sm font-medium text-neutral-700 dark:text-neutral-300">{{ $t('forms.payment.amount_to_pay') }}</span>
@@ -73,8 +73,8 @@
@error="onStripeError"
>
<template #default="{ elements }">
- <div class="space-y-4">
- <div :class="[ui.container(), isCardFocused && !hasError ? 'ring-2 ring-form border-transparent' : '']">
+ <div :class="ui.stack()">
+ <div :class="[ui.card(), isCardFocused && !hasError ? 'ring-2 ring-form border-transparent' : '']">
<StripeElement
v-if="elements"
ref="card"
@@ -92,6 +92,8 @@
:placeholder="$t('forms.payment.name_on_card')"
class="w-full"
:disabled="disabled"
+ wrapper-class="my-0"
+ :color="color"
/>
<TextInput
v-model="cardHolderEmail"
@@ -99,6 +101,8 @@
:placeholder="$t('forms.payment.billing_email')"
class="w-full"
:disabled="disabled"
+ wrapper-class="my-0"
+ :color="color"
/>
</div>
</template>
diff --git a/client/components/forms/heavy/components/CaptchaWrapper.vue b/client/components/forms/heavy/components/CaptchaWrapper.vue
index 14f1abe5b..1f724313d 100644
--- a/client/components/forms/heavy/components/CaptchaWrapper.vue
+++ b/client/components/forms/heavy/components/CaptchaWrapper.vue
@@ -32,8 +32,8 @@ const runtimeConfig = useRuntimeConfig().public
// Get form and config from the formManager
const form = computed(() => props.formManager.form)
const config = computed(() => props.formManager.config.value)
-const structure = computed(() => props.formManager.structure)
-const isLastPage = computed(() => structure.value?.isLastPage.value ?? true)
+const structure = props.formManager.structure
+const isLastPage = computed(() => structure.value?.isLastPage?.value ?? true)
const language = computed(() => config.value?.language || 'en')
const provider = computed(() => config.value?.captcha_provider || 'recaptcha')
const darkMode = computed(() => props.formManager.darkMode.value)
diff --git a/client/components/forms/useFormInput.js b/client/components/forms/useFormInput.js
index cef8c30a5..e1478c7aa 100644
--- a/client/components/forms/useFormInput.js
+++ b/client/components/forms/useFormInput.js
@@ -25,6 +25,7 @@ export const inputProps = {
helpPosition: {type: String, default: "below_input"},
color: {type: String, default: "#3B82F6"},
wrapperClass: { type: String, default: "" },
+ media: { type: Object, default: null },
isDark: { type: Boolean, default: false },
locale: { type: String, default: "en" },
isAdminPreview: { type: Boolean, default: false }
diff --git a/client/components/global/Navbar.vue b/client/components/global/Navbar.vue
index ca708f08d..49e9e1f3d 100644
--- a/client/components/global/Navbar.vue
+++ b/client/components/global/Navbar.vue
@@ -129,7 +129,7 @@
:src="user.photo_url"
class="rounded-full w-6 h-6"
>
- <p class="ml-2 hidden sm:inline">
+ <p class="ml-2 hidden sm:inline max-w-20 truncate">
{{ user.name }}
</p>
</button>
diff --git a/client/components/global/transitions/SlidingTransition.vue b/client/components/global/transitions/SlidingTransition.vue
index 57f8bb21c..a4a9b6f40 100644
--- a/client/components/global/transitions/SlidingTransition.vue
+++ b/client/components/global/transitions/SlidingTransition.vue
@@ -1,13 +1,9 @@
<template>
- <transition
- :name="transitionName"
- @enter="enter"
- @leave="leave"
- @after-enter="resetStyles"
- @after-leave="resetStyles"
- >
- <slot />
- </transition>
+ <div class="sliding-wrapper" :style="{ '--transition-speed': transitionSpeed }">
+ <transition :name="transitionName">
+ <slot />
+ </transition>
+ </div>
</template>
<script setup>
@@ -22,6 +18,10 @@ const props = defineProps({
step: {
type: Number,
default: 1
+ },
+ speed: {
+ type: [Number, String],
+ default: 800
}
})
@@ -31,65 +31,111 @@ const transitionName = computed(() => {
return `${baseTransition}-${props.step > previousStep.value ? 'forward' : 'backward'}`
})
+const transitionSpeed = computed(() => {
+ return typeof props.speed === 'number' ? `${props.speed}ms` : props.speed
+})
+
watch(() => props.step, (newStep, oldStep) => {
previousStep.value = oldStep
})
-const enter = (el, done) => {
- const { height } = el.getBoundingClientRect()
- el.style.height = '0'
- el.offsetHeight // force reflow
- el.style.height = `${height}px`
- el.addEventListener('transitionend', done, { once: true })
-}
-
-const leave = (el, done) => {
- const { height } = el.getBoundingClientRect()
- el.style.height = `${height}px`
- el.offsetHeight // force reflow
- el.style.height = '0'
- el.addEventListener('transitionend', done, { once: true })
-}
-
-const resetStyles = (el) => {
- el.style.height = ''
-}
+// No JS animation hooks; CSS handles both enter/leave transforms in sync
</script>
<style scoped>
-.slide-horizontal-forward-enter-active,
-.slide-horizontal-forward-leave-active,
-.slide-horizontal-backward-enter-active,
-.slide-horizontal-backward-leave-active,
-.slide-vertical-forward-enter-active,
-.slide-vertical-forward-leave-active,
-.slide-vertical-backward-enter-active,
-.slide-vertical-backward-leave-active {
- transition: all 0.3s ease-out;
+.sliding-wrapper {
+ position: relative;
overflow: hidden;
}
-.slide-horizontal-forward-enter-from,
-.slide-horizontal-backward-leave-to {
- opacity: 0;
- transform: translateX(30px);
+/* Active: absolutely stack and animate transform + opacity */
+:deep(.slide-horizontal-forward-enter-active),
+:deep(.slide-horizontal-forward-leave-active),
+:deep(.slide-horizontal-backward-enter-active),
+:deep(.slide-horizontal-backward-leave-active),
+:deep(.slide-vertical-forward-enter-active),
+:deep(.slide-vertical-forward-leave-active),
+:deep(.slide-vertical-backward-enter-active),
+:deep(.slide-vertical-backward-leave-active) {
+ position: absolute;
+ left: 0;
+ right: 0;
+ top: 0;
+ bottom: 0;
+ transition: transform var(--transition-speed, 800ms) ease-in-out, opacity var(--transition-speed, 800ms) ease-in-out;
+ will-change: transform, opacity;
+}
+
+/* Enter on top */
+:deep(.slide-horizontal-forward-enter-active),
+:deep(.slide-horizontal-backward-enter-active),
+:deep(.slide-vertical-forward-enter-active),
+:deep(.slide-vertical-backward-enter-active) {
+ z-index: 2;
+}
+:deep(.slide-horizontal-forward-leave-active),
+:deep(.slide-horizontal-backward-leave-active),
+:deep(.slide-vertical-forward-leave-active),
+:deep(.slide-vertical-backward-leave-active) {
+ z-index: 1;
}
-.slide-horizontal-forward-leave-to,
-.slide-horizontal-backward-enter-from {
- opacity: 0;
- transform: translateX(-30px);
+/* Horizontal */
+:deep(.slide-horizontal-forward-enter-from),
+:deep(.slide-horizontal-backward-leave-to) {
+ transform: translateX(100%);
+ opacity: 0.5;
+}
+:deep(.slide-horizontal-forward-enter-to),
+:deep(.slide-horizontal-backward-leave-from) {
+ transform: translateX(0%);
+ opacity: 1;
+}
+:deep(.slide-horizontal-forward-leave-to),
+:deep(.slide-horizontal-backward-enter-from) {
+ transform: translateX(-100%);
+ opacity: 0.5;
+}
+:deep(.slide-horizontal-forward-leave-from),
+:deep(.slide-horizontal-backward-enter-to) {
+ transform: translateX(0%);
+ opacity: 1;
}
-.slide-vertical-forward-enter-from,
-.slide-vertical-backward-leave-to {
- opacity: 0;
- transform: translateY(30px);
+/* Vertical */
+/* Forward: old goes up, new comes from bottom */
+:deep(.slide-vertical-forward-enter-from) {
+ transform: translateY(100%);
+ opacity: 0.5;
+}
+:deep(.slide-vertical-forward-enter-to) {
+ transform: translateY(0%);
+ opacity: 1;
+}
+:deep(.slide-vertical-forward-leave-to) {
+ transform: translateY(-100%);
+ opacity: 0.5;
+}
+:deep(.slide-vertical-forward-leave-from) {
+ transform: translateY(0%);
+ opacity: 1;
}
-.slide-vertical-forward-leave-to,
-.slide-vertical-backward-enter-from {
- opacity: 0;
- transform: translateY(-30px);
+/* Backward: old goes down, new comes from top */
+:deep(.slide-vertical-backward-enter-from) {
+ transform: translateY(-100%);
+ opacity: 0.5;
+}
+:deep(.slide-vertical-backward-enter-to) {
+ transform: translateY(0%);
+ opacity: 1;
+}
+:deep(.slide-vertical-backward-leave-to) {
+ transform: translateY(100%);
+ opacity: 0.5;
+}
+:deep(.slide-vertical-backward-leave-from) {
+ transform: translateY(0%);
+ opacity: 1;
}
</style>
\ No newline at end of file
diff --git a/client/components/open/components/EditSubmissionModal.vue b/client/components/open/components/EditSubmissionModal.vue
index 3112e6b5f..f5983a10e 100644
--- a/client/components/open/components/EditSubmissionModal.vue
+++ b/client/components/open/components/EditSubmissionModal.vue
@@ -1,7 +1,7 @@
<template>
<UModal
v-model:open="isModalOpen"
- :ui="{ content: 'sm:max-w-2xl' }"
+ :ui="{ content: 'sm:max-w-2xl', body: 'p-0!' }"
>
<template #header>
<div class="flex items-center justify-between w-full">
diff --git a/client/components/open/components/ViewSubmissionModal.vue b/client/components/open/components/ViewSubmissionModal.vue
index 225bd93bb..eb5f15b90 100644
--- a/client/components/open/components/ViewSubmissionModal.vue
+++ b/client/components/open/components/ViewSubmissionModal.vue
@@ -1,7 +1,7 @@
<template>
<UModal
v-model:open="isModalOpen"
- :ui="{ content: 'sm:max-w-2xl' }"
+ :ui="{ content: 'sm:max-w-4xl', body: 'p-0!' }"
>
<template #header>
<div class="flex items-center justify-between w-full">
diff --git a/client/components/open/forms/BlockRenderer.vue b/client/components/open/forms/BlockRenderer.vue
new file mode 100644
index 000000000..09573feae
--- /dev/null
+++ b/client/components/open/forms/BlockRenderer.vue
@@ -0,0 +1,218 @@
+<template>
+ <ClientOnlyWrapper v-if="block && hasComponent" :client-only="clientOnlyVal" :key="'dyn-' + (block?.id || 'dyn')">
+ <Suspense>
+ <component
+ :is="componentVal"
+ v-bind="boundProps"
+ />
+ <template #fallback>
+ <USkeleton class="w-full h-16 my-1.5" />
+ </template>
+ </Suspense>
+ <template #fallback>
+ <USkeleton class="w-full h-16 my-1.5" />
+ </template>
+ </ClientOnlyWrapper>
+ <div v-else-if="block" :key="'static-' + (block?.id || 'static')">
+ <div
+ v-if="block.type === 'nf-text' && block.content"
+ :id="block.id"
+ :key="'text-' + block.id"
+ class="nf-text w-full my-1.5 break-words whitespace-break-spaces"
+ :class="[getFieldAlignClasses(block)]"
+ >
+ <TextBlock
+ :content="block.content"
+ :form="form"
+ :form-data="dataForm"
+ :media="shouldInjectBetweenMedia ? block.image : null"
+ />
+ </div>
+ <div
+ v-else-if="block.type === 'nf-code' && block.content"
+ :id="block.id"
+ :key="'code-' + block.id"
+ class="nf-code w-full px-2 my-1.5"
+ v-html="block.content"
+ />
+ <div
+ v-else-if="block.type === 'nf-divider'"
+ :id="block.id"
+ :key="'divider-' + block.id"
+ class="border-b my-4 w-full mx-2"
+ />
+ </div>
+</template>
+
+<script setup>
+import ClientOnlyWrapper from '~/components/global/ClientOnlyWrapper.vue'
+import { useComponentRegistry } from '~/composables/components/useComponentRegistry'
+import TextBlock from '~/components/forms/core/TextBlock.vue'
+
+const props = defineProps({
+ block: { type: Object, required: false, default: null },
+ formManager: { type: Object, required: true }
+})
+
+const form = computed(() => props.formManager?.config?.value || {})
+const dataForm = computed(() => props.formManager?.form || {})
+const darkMode = computed(() => props.formManager?.darkMode?.value || false)
+const strategy = computed(() => props.formManager?.strategy?.value || {})
+
+const { getFormComponent } = useComponentRegistry()
+
+const componentInfo = computed(() => {
+ const field = props.block
+ if (!field || !field.type) return null
+ let componentName
+ if (field.type === 'text' && field.multi_lines) componentName = 'TextAreaInput'
+ else if (field.type === 'url' && field.file_upload) componentName = 'FileInput'
+ else if (['select','multi_select'].includes(field.type) && field.without_dropdown) componentName = 'FlatSelectInput'
+ else if (field.type === 'checkbox' && field.use_toggle_switch) componentName = 'ToggleSwitchInput'
+ else if (field.type === 'signature') componentName = 'SignatureInput'
+ else if (field.type === 'phone_number' && !field.use_simple_text_input) componentName = 'PhoneInput'
+ else {
+ componentName = {
+ text: 'TextInput',
+ rich_text: 'RichTextAreaInput',
+ number: 'TextInput',
+ rating: 'RatingInput',
+ scale: 'ScaleInput',
+ slider: 'SliderInput',
+ select: 'SelectInput',
+ multi_select: 'SelectInput',
+ date: 'DateInput',
+ files: 'FileInput',
+ checkbox: 'CheckboxInput',
+ url: 'TextInput',
+ email: 'TextInput',
+ phone_number: 'TextInput',
+ matrix: 'MatrixInput',
+ barcode: 'BarcodeInput',
+ payment: 'PaymentInput',
+ code: 'CodeInput'
+ }[field.type]
+ }
+ return getFormComponent(componentName)
+})
+
+const componentVal = computed(() => {
+ const val = componentInfo.value
+ if (!val) return null
+ // Registry may return a string/async component directly OR an object { component, clientOnly }
+ if (typeof val === 'string' || typeof val === 'function') return val
+ if (typeof val === 'object' && val) {
+ return val.component || val // if it already is a component
+ }
+ return null
+})
+
+const clientOnlyVal = computed(() => {
+ const val = componentInfo.value
+ if (val && typeof val === 'object' && 'clientOnly' in val) return !!val.clientOnly
+ return false
+})
+
+const hasComponent = computed(() => !!componentVal.value)
+
+function getFieldAlignClasses(field) {
+ if (!field.align || field.align === 'left') return 'text-left'
+ else if (field.align === 'right') return 'text-right'
+ else if (field.align === 'center') return 'text-center'
+ else if (field.align === 'justify') return 'text-justify'
+}
+
+const shouldInjectBetweenMedia = computed(() => (
+ props.block?.image &&
+ props.block.image.url &&
+ props.block.image.layout === 'between' &&
+ form.value?.presentation_style === 'focused' &&
+ !(strategy.value?.display?.forceClassicPresentation === true)
+))
+
+const boundProps = computed(() => {
+ const field = props.block
+ if (!field) return {}
+ const inputProperties = {
+ key: field.id,
+ name: field.id,
+ form: dataForm.value,
+ label: (field.hide_field_name) ? null : field.name + ((field.hidden) ? ' (Hidden Field)' : ''),
+ color: form.value.color,
+ placeholder: field.placeholder,
+ help: field.help,
+ helpPosition: (field.help_position) ? field.help_position : 'below_input',
+ uppercaseLabels: form.value.uppercase_labels == 1 || form.value.uppercase_labels == true,
+ maxCharLimit: (field.max_char_limit) ? parseInt(field.max_char_limit) : null,
+ showCharLimit: field.show_char_limit || false,
+ isDark: darkMode.value,
+ locale: (form.value?.language) ? form.value.language : 'en',
+ media: shouldInjectBetweenMedia.value ? field.image : null,
+ presentation: form.value?.presentation_style || 'classic',
+ required: field.required || false,
+ // Respect global disable flag from form mode (e.g., READ_ONLY)
+ disabled: (strategy.value?.display?.disableFields === true) || (field.disabled || false)
+ }
+
+ if (field.type === 'matrix') {
+ inputProperties.rows = field.rows
+ inputProperties.columns = field.columns
+ }
+ if (field.type === 'barcode') inputProperties.decoders = field.decoders
+
+ if (['select', 'multi_select'].includes(field.type)) {
+ inputProperties.options = (field[field.type])
+ ? field[field.type].options.map(option => ({ name: option.name, value: option.name }))
+ : []
+ inputProperties.multiple = (field.type === 'multi_select')
+ inputProperties.allowCreation = (field.allow_creation === true)
+ inputProperties.searchable = (inputProperties.options.length > 4)
+ if (field.type === 'multi_select') {
+ inputProperties.minSelection = field.min_selection || null
+ inputProperties.maxSelection = field.max_selection || null
+ }
+ } else if (field.type === 'date') {
+ inputProperties.dateFormat = field.date_format
+ inputProperties.timeFormat = field.time_format
+ if (field.with_time) inputProperties.withTime = true
+ if (field.date_range) inputProperties.dateRange = true
+ if (field.disable_past_dates) inputProperties.disablePastDates = true
+ else if (field.disable_future_dates) inputProperties.disableFutureDates = true
+ } else if (field.type === 'files' || (field.type === 'url' && field.file_upload)) {
+ inputProperties.multiple = (field.multiple !== undefined && field.multiple)
+ inputProperties.cameraUpload = (field.camera_upload !== undefined && field.camera_upload)
+ let maxFileSize = (form.value?.workspace && form.value?.workspace.max_file_size) ? form.value?.workspace?.max_file_size : 10
+ if (field?.max_file_size > 0) maxFileSize = Math.min(field.max_file_size, maxFileSize)
+ inputProperties.mbLimit = maxFileSize
+ inputProperties.accept = (form.value.is_pro && field.allowed_file_types) ? field.allowed_file_types : ''
+ } else if (field.type === 'rating') {
+ inputProperties.numberOfStars = parseInt(field.rating_max_value) ?? 5
+ } else if (field.type === 'scale') {
+ inputProperties.minScale = parseFloat(field.scale_min_value) ?? 1
+ inputProperties.maxScale = parseFloat(field.scale_max_value) ?? 5
+ inputProperties.stepScale = parseFloat(field.scale_step_value) ?? 1
+ } else if (field.type === 'slider') {
+ inputProperties.minSlider = parseInt(field.slider_min_value) ?? 0
+ inputProperties.maxSlider = parseInt(field.slider_max_value) ?? 50
+ inputProperties.stepSlider = parseInt(field.slider_step_value) ?? 5
+ } else if (field.type === 'number' || (field.type === 'phone_number' && field.use_simple_text_input)) {
+ inputProperties.pattern = '/d*'
+ } else if (field.type === 'phone_number' && !field.use_simple_text_input) {
+ inputProperties.unavailableCountries = field.unavailable_countries ?? []
+ } else if (field.type === 'text' && field.secret_input) {
+ inputProperties.nativeType = 'password'
+ } else if (field.type === 'payment') {
+ inputProperties.direction = form.value.layout_rtl ? 'rtl' : 'ltr'
+ inputProperties.currency = field.currency
+ inputProperties.amount = field.amount
+ inputProperties.oauthProviderId = field.stripe_account_id
+ if (props.formManager?.payment) {
+ try { inputProperties.paymentData = props.formManager.payment.getPaymentData(field) } catch (e) { console.error(e) }
+ }
+ }
+
+ return inputProperties
+})
+</script>
+
+
diff --git a/client/components/open/forms/OpenCompleteForm.vue b/client/components/open/forms/OpenCompleteForm.vue
index fa2710eca..ab3a0ef84 100644
--- a/client/components/open/forms/OpenCompleteForm.vue
+++ b/client/components/open/forms/OpenCompleteForm.vue
@@ -1,153 +1,96 @@
<template>
<div
v-if="form"
- class="open-complete-form"
+ class="open-complete-form flex flex-col min-h-full"
:dir="form?.layout_rtl ? 'rtl' : 'ltr'"
:style="formStyle"
>
- <ClientOnly>
- <Teleport to="head">
- <link
- v-if="showFontLink && form.font_family"
- :key="form.font_family"
- :href="getFontUrl"
- rel="stylesheet"
- crossorigin="anonymous"
- referrerpolicy="no-referrer"
- >
- </Teleport>
- </ClientOnly>
-
<v-transition name="fade" mode="out-in">
<div v-if="isAutoSubmit" key="auto-submit" class="text-center p-6">
<Loader class="h-6 w-6 text-blue-500 mx-auto" />
</div>
- <div v-else key="form-content">
- <div v-if="isPublicFormPage && form.is_password_protected">
- <p class="form-description text-neutral-700 dark:text-neutral-300 px-2">
- {{ t('forms.password_protected') }}
- </p>
- <div class="form-group flex flex-wrap w-full">
- <div class="relative w-full px-2">
- <text-input
- :form="passwordForm"
- name="password"
- native-type="password"
- label="Password"
- />
+ <component
+ v-else-if="form && formManager && form"
+ :key="'form'+form.presentation_style"
+ :is="FormComponent"
+ :form-manager="formManager"
+ @submit="triggerSubmit"
+ class="flex flex-col grow"
+ >
+ <template #password v-if="isPublicFormPage && form.is_password_protected" >
+ <div class="w-full">
+ <div class="form-group flex flex-wrap w-full max-w-sm mx-auto">
+ <div class="relative w-full px-2">
+ <text-input :form="passwordForm" name="password" native-type="password" label="Password" :help="t('forms.password_protected')" />
+ </div>
+ </div>
+ <div class="flex flex-wrap justify-center w-full text-center">
+ <open-form-button :form="form" class="my-4 px-8" @click="passwordEntered">
+ {{ t('forms.submit') }}
+ </open-form-button>
</div>
</div>
- <div class="flex flex-wrap justify-center w-full text-center">
- <open-form-button
- :form="form"
- class="my-4"
- @click="passwordEntered"
- >
- {{ t('forms.submit') }}
- </open-form-button>
- </div>
- </div>
-
- <div v-if="!form.is_password_protected && form.password && !hidePasswordDisabledMsg"
- class="m-2 my-4">
+ </template>
+
+ <template
+ #alerts
+ v-if="isPublicFormPage && (form.is_closed || form.visibility=='closed' || form.max_number_of_submissions_reached)"
+ >
<UAlert
- :close-button="{ icon: 'i-heroicons-x-mark-20-solid', color: 'neutral', variant: 'link', padded: false }"
+ v-if="form.is_closed || form.visibility=='closed'"
+ icon="i-heroicons-lock-closed-20-solid"
color="warning"
variant="subtle"
- icon="i-material-symbols-info-outline"
- @close="hidePasswordDisabledMsg = true"
- title="Password protection has been disabled since you are the owner of this form."
- />
- </div>
-
-
- <UAlert
- v-if="isPublicFormPage && (form.is_closed || form.visibility=='closed')"
- icon="i-heroicons-lock-closed-20-solid"
- color="warning"
- variant="subtle"
- class="m-2 my-4"
- >
- <template #description>
- <div
- class="break-words whitespace-break-spaces"
- v-html="form.closed_text"
- />
- </template>
- </UAlert>
-
- <UAlert
- v-else-if="isPublicFormPage && form.max_number_of_submissions_reached"
- icon="i-heroicons-lock-closed-20-solid"
- color="warning"
- variant="subtle"
- class="m-2 my-4"
- >
- <template #description>
- <div
- class="break-words whitespace-break-spaces"
- v-html="form.max_submissions_reached_text"
- />
- </template>
- </UAlert>
-
- <form-cleanings
- v-if="showFormCleanings"
- :hideable="true"
- class="mb-4 mx-2"
- :form="form"
- :specify-form-owner="true"
- :use-cookie-dismissal="true"
- />
-
- <v-transition name="fade" v-if="form && !form.is_password_protected">
- <div
- v-if="!isFormSubmitted"
- key="form"
+ class="m-2 my-4"
>
- <open-form
- v-if="formManager && form && shouldDisplayForm"
- :form-manager="formManager"
- @submit="triggerSubmit"
- >
- <template #submit-btn="{loading}">
- <open-form-button
- :loading="loading || isProcessing"
- :form="form"
- class="mt-2 px-8 mx-1"
- :class="submitButtonClass"
- @click.prevent="triggerSubmit"
- >
- {{ form.submit_button_text || t('forms.buttons.submit') }}
- </open-form-button>
- </template>
- </open-form>
- <PoweredBy v-if="!form.no_branding && formModeStrategy.display.showBranding" :color="form.color" />
- </div>
- <div
+ <template #description>
+ <div class="break-words whitespace-break-spaces" v-html="form.closed_text" />
+ </template>
+ </UAlert>
+ <UAlert
v-else
- key="submitted"
- class="px-2"
+ icon="i-heroicons-lock-closed-20-solid"
+ color="warning"
+ variant="subtle"
+ class="m-2 my-4"
>
- <TextBlock
- v-if="form.submitted_text"
- class="form-description text-neutral-700 dark:text-neutral-300 whitespace-pre-wrap"
- :content="form.submitted_text"
- :mentions-allowed="true"
+ <template #description>
+ <div class="break-words whitespace-break-spaces" v-html="form.max_submissions_reached_text" />
+ </template>
+ </UAlert>
+ </template>
+
+ <template #cleanings>
+ <form-cleanings
+ v-if="showFormCleanings"
+ :hideable="true"
+ class="mb-4 mx-2"
+ :form="form"
+ :specify-form-owner="true"
+ :use-cookie-dismissal="true"
+ />
+ </template>
+
+ <!-- Submitted view provided to renderer -->
+ <template #after-submit>
+ <TextBlock
+ v-if="form.submitted_text"
+ class="form-description text-neutral-700 dark:text-neutral-300 whitespace-pre-wrap"
+ :content="form.submitted_text"
+ :mentions-allowed="true"
+ :form="form"
+ :form-data="submittedData"
+ />
+ <div class="flex w-full gap-2 items-center mt-4">
+ <open-form-button
+ v-if="form.re_fillable"
:form="form"
- :form-data="submittedData"
- />
- <div class="flex w-full gap-2 items-center mt-4">
-
- <open-form-button
- v-if="form.re_fillable"
- :form="form"
- icon="i-lucide-rotate-ccw"
- @click="restart"
- >
- {{ form.re_fill_button_text || t('forms.buttons.re_fill') }}
- </open-form-button>
+ icon="i-lucide-rotate-ccw"
+ @click="restart"
+ >
+ {{ form.re_fill_button_text || t('forms.buttons.re_fill') }}
+ </open-form-button>
<open-form-button
v-if="form.editable_submissions && submissionId"
:form="form"
@@ -155,29 +98,30 @@
>
{{ form.editable_submissions_button_text }}
</open-form-button>
- </div>
- <PoweredBy v-if="!form.no_branding && formModeStrategy.display.showBranding" :color="form.color" />
</div>
- </v-transition>
- <FirstSubmissionModal
- :show="showFirstSubmissionModal"
- :form="form"
- @close="showFirstSubmissionModal=false"
- />
- </div>
+ </template>
+ </component>
</v-transition>
+
+ <template v-if="!isAutoSubmit">
+ <FirstSubmissionModal
+ :show="showFirstSubmissionModal"
+ :form="form"
+ @close="showFirstSubmissionModal=false"
+ />
+ </template>
</div>
</template>
<script setup>
import { useFormManager } from '~/lib/forms/composables/useFormManager'
-import { FormMode, createFormModeStrategy } from "~/lib/forms/FormModeStrategy.js"
+import { FormMode } from "~/lib/forms/FormModeStrategy.js"
import OpenForm from './OpenForm.vue'
+import OpenFormFocused from './OpenFormFocused.vue'
import OpenFormButton from './OpenFormButton.vue'
import FormCleanings from '../../pages/forms/show/FormCleanings.vue'
import VTransition from '~/components/global/transitions/VTransition.vue'
import FirstSubmissionModal from '~/components/open/forms/components/FirstSubmissionModal.vue'
-import PoweredBy from '~/components/pages/forms/show/PoweredBy.vue'
import { useForm } from '~/composables/useForm'
import { useAlert } from '~/composables/useAlert'
import { useI18n } from 'vue-i18n'
@@ -192,7 +136,6 @@ const props = defineProps({
default: FormMode.LIVE,
validator: (value) => Object.values(FormMode).includes(value)
},
- submitButtonClass: { type: String, default: '' },
darkMode: {
type: Boolean,
default: false
@@ -207,7 +150,7 @@ const alert = useAlert()
const workingFormStore = useWorkingFormStore()
const { data: user } = useAuth().user()
const passwordForm = useForm({ password: null })
-const hidePasswordDisabledMsg = ref(false)
+// Removed unused hidePasswordDisabledMsg (was always false and unused)
const submissionId = ref(route.query.submission_id || null)
const submittedData = ref(null)
const showFirstSubmissionModal = ref(false)
@@ -217,7 +160,6 @@ const queryString = route.fullPath.split('?')[1] || ''
// Check for auto_submit parameter during setup
const isAutoSubmit = ref(import.meta.client && window.location.href.includes('auto_submit=true'))
-const formModeStrategy = computed(() => createFormModeStrategy(props.mode))
// Create a reactive reference directly from the prop
const darkModeRef = toRef(props, 'darkMode')
@@ -228,6 +170,7 @@ const modeRef = toRef(props, 'mode')
provide('formTheme', computed(() => props.form.theme || 'default'))
provide('formSize', computed(() => props.form.size || 'md'))
provide('formBorderRadius', computed(() => props.form.border_radius || 'small'))
+provide('formPresentationStyle', computed(() => props.form.presentation_style || 'classic'))
let formManager = null
if (props.form) {
@@ -236,8 +179,8 @@ if (props.form) {
mode: modeRef
})
- // Await the initialization for SSR
- formManager.initialize({
+ // Await initialization so SSR includes form structure and fields
+ await formManager.initialize({
submissionId: submissionId.value,
urlParams: new URLSearchParams(queryString),
})
@@ -255,12 +198,15 @@ watch(() => props.form, (newForm) => {
}
})
-// Share the structure service with the working form store only when in admin edit context
-watch(() => formManager?.strategy?.value?.admin?.showAdminControls, (showAdminControls) => {
- if (workingFormStore && formManager?.structure && showAdminControls) {
- workingFormStore.setStructureService(formManager.structure)
+// Keep the builder's structureService in sync whenever admin preview is on and the adapter changes
+watch([
+ () => formManager?.strategy?.value?.admin?.showAdminControls,
+ () => formManager?.structure?.value
+], ([showAdminControls, struct]) => {
+ if (workingFormStore && showAdminControls && struct) {
+ workingFormStore.setStructureService(struct)
}
-}, { immediate: true })
+}, { immediate: true })
// Add a watcher to update formManager's darkMode whenever darkModeRef changes
watch(darkModeRef, (newDarkMode) => {
@@ -294,13 +240,9 @@ const isFormOwner = computed(() => {
return isAuthenticated.value && props.form && props.form.creator_id === user.value.id
})
-const isFormSubmitted = computed(() => formManager?.state.isSubmitted ?? false)
const isProcessing = computed(() => formManager?.state.isProcessing ?? false)
const showFormCleanings = computed(() => formManager?.strategy.value.display.showFormCleanings ?? false)
const showFontLink = computed(() => formManager?.strategy.value.display.showFontLink ?? false)
-const shouldDisplayForm = computed(() => {
- return (!props.form.is_closed && !props.form.max_number_of_submissions_reached) || formManager?.strategy?.value.admin?.showAdminControls
-})
const formStyle = computed(() => {
const baseStyle = {
@@ -321,6 +263,25 @@ const formStyle = computed(() => {
return baseStyle
})
+const FormComponent = computed(() => {
+ return props.form?.presentation_style === 'focused' ? OpenFormFocused : OpenForm
+})
+
+// Conditionally add font link to the page head (SSR-friendly)
+useHead({
+ link: computed(() =>
+ (showFontLink.value && props.form?.font_family && getFontUrl.value) ? [
+ {
+ key: `form-font-${props.form.font_family}`,
+ rel: 'stylesheet',
+ href: getFontUrl.value,
+ crossorigin: 'anonymous',
+ referrerpolicy: 'no-referrer'
+ }
+ ] : []
+ )
+})
+
watch(() => props.form.language, (newLanguage) => {
if (newLanguage && typeof newLanguage === 'string') {
setLocale(newLanguage)
@@ -407,6 +368,7 @@ const editSubmission = () => {
}
const passwordEntered = () => {
+ console.log('passwordEntered', passwordForm.password)
if (passwordForm.password) {
emit('password-entered', passwordForm.password)
} else {
diff --git a/client/components/open/forms/OpenForm.vue b/client/components/open/forms/OpenForm.vue
index 6e2eb5115..9a138a740 100644
--- a/client/components/open/forms/OpenForm.vue
+++ b/client/components/open/forms/OpenForm.vue
@@ -1,96 +1,156 @@
<template>
<form
v-if="form"
+ class="@container pb-20"
@submit.prevent=""
>
- <FormProgressbar
- :form-manager="formManager"
- />
- <transition
- name="fade"
- mode="out-in"
- >
+ <!-- Classic cover/logo rendering -->
+ <div v-if="showBrandingMedia" class="mb-2">
+ <div v-if="form.cover_picture">
+ <div id="cover-picture" class="h-56 w-full overflow-hidden pointer-events-none">
+ <BlockMediaLayout :image="coverMedia" img-class="w-full h-full object-cover" alt="Form cover image" />
+ </div>
+ </div>
<div
- :key="formPageIndex"
- class="form-group flex flex-wrap w-full"
+ v-if="form.logo_picture"
+ class="w-full p-5 relative mx-auto"
+ :class="[
+ !form.cover_picture ? 'pt-20' : '',
+ form.width === 'centered' ? (isPreviewMode ? 'max-w-lg' : '@3xl:w-3/5 @5xl:w-1/2 @3xl:max-w-2xl') : '',
+ (form.width === 'full' && !isIframe) ? 'max-w-7xl' : ''
+ ]"
+ :style="{ direction: form?.layout_rtl ? 'rtl' : 'ltr' }"
>
- <VueDraggable
- :model-value="currentFields"
- group="form-elements"
- item-key="id"
- class="grid grid-cols-12 relative transition-all w-full"
- :class="[
- draggingNewBlock ? 'rounded-md bg-blue-50 dark:bg-neutral-800' : '',
- ]"
- ghost-class="ghost-item"
- filter=".not-draggable"
- :animation="200"
- :disabled="!allowDragging"
- @add="handleDragAdd"
- @update="handleDragUpdate"
+ <img
+ :src="form.logo_picture"
+ :alt="form.seo_meta?.site_name ? `${form.seo_meta.site_name} logo` : 'Form logo'"
+ :class="{ 'top-5': !form.cover_picture, '-top-10': form.cover_picture }"
+ class="w-20 h-20 object-contain absolute transition-all"
>
- <template #default>
- <div
- v-for="element in currentFields"
- :key="element.id"
- :class="getFieldWidthClasses(element.width)"
- >
- <VTransition name="fadeHeight">
- <open-form-field
- :field="element"
- :form-manager="formManager"
- />
- </VTransition>
- </div>
- </template>
- </VueDraggable>
</div>
- </transition>
-
- <!-- Replace Captcha with CaptchaWrapper -->
- <CaptchaWrapper
- v-if="form.use_captcha"
- :form-manager="formManager"
- />
-
- <!-- Submit, Next and previous buttons -->
- <div class="flex flex-wrap justify-center w-full">
- <open-form-button
- v-if="formPageIndex>0 && previousFieldsPageBreak"
- native-type="button"
- :form="form"
- class="mt-2 px-8 mx-1"
- @click.stop="handlePreviousClick"
- >
- {{ previousFieldsPageBreak.previous_btn_text || $t('forms.buttons.previous') }}
- </open-form-button>
-
- <slot
- v-if="isLastPage"
- name="submit-btn"
- :loading="isProcessing"
- />
- <open-form-button
- v-else-if="currentFieldsPageBreak"
- native-type="button"
- :form="form"
- class="mt-2 px-8 mx-1"
- :loading="isProcessing"
- @click.stop="handleNextClick"
+ </div>
+
+ <div
+ class="w-full mx-auto px-4"
+ :class="[
+ (!isIframe && !showBrandingMedia) ? 'mt-6' : '',
+ form && form.width === 'centered' ? (isPreviewMode ? 'max-w-lg' : '@3xl:w-3/5 @5xl:w-1/2 @3xl:max-w-2xl') : '',
+ (form && form.width === 'full' && !isIframe) ? 'max-w-7xl' : ''
+ ]"
+ >
+ <FormProgressbar :form-manager="formManager" />
+ <transition
+ name="fade"
+ mode="out-in"
>
- {{ currentFieldsPageBreak.next_btn_text || $t('forms.buttons.next') }}
- </open-form-button>
- <div v-if="!currentFieldsPageBreak && !isLastPage">
- {{ $t('forms.wrong_form_structure') }}
+ <div v-if="$slots.password" key="password" class="w-full">
+ <slot name="password" />
+ </div>
+
+ <div v-else-if="$slots.alerts" key="alerts" class="w-full">
+ <slot name="alerts" />
+ </div>
+
+ <div v-else-if="isSubmitted" key="submitted" class="px-2 w-full">
+ <slot name="after-submit" :submittedData="submittedData" />
+ </div>
+
+ <div v-else-if="shouldDisplayForm" :key="formPageIndex" class="form-group flex flex-wrap w-full">
+ <VueDraggable
+ :model-value="currentFields"
+ group="form-elements"
+ item-key="id"
+ class="grid grid-cols-12 relative transition-all w-full"
+ :class="[
+ draggingNewBlock ? 'rounded-md bg-blue-50 dark:bg-neutral-800' : '',
+ ]"
+ ghost-class="ghost-item"
+ filter=".not-draggable"
+ :animation="200"
+ :disabled="!allowDragging"
+ @add="handleDragAdd"
+ @update="handleDragUpdate"
+ >
+ <template #default>
+ <div
+ v-for="element in currentFields"
+ :key="element.id"
+ :class="getFieldWidthClasses(element.width)"
+ >
+ <VTransition name="fadeHeight">
+ <open-form-field
+ :field="element"
+ :form-manager="formManager"
+ />
+ </VTransition>
+ </div>
+ </template>
+ </VueDraggable>
+ </div>
+ </transition>
+
+ <!-- Captcha -->
+ <CaptchaWrapper v-if="form.use_captcha" :form-manager="formManager" />
+
+ <!-- Submit, Next and previous buttons -->
+ <div v-if="!isSubmitted" class="flex flex-wrap justify-center w-full">
+ <open-form-button
+ v-if="formPageIndex>0 && previousFieldsPageBreak"
+ native-type="button"
+ :form="form"
+ class="mt-2 px-8 mx-1"
+ @click.stop="handlePreviousClick"
+ >
+ {{ previousFieldsPageBreak.previous_btn_text || $t('forms.buttons.previous') }}
+ </open-form-button>
+
+ <template v-if="isLastPage">
+ <slot name="submit-btn" :loading="isProcessing">
+ <open-form-button
+ :form="form"
+ class="mt-2 px-8 mx-1"
+ :loading="isProcessing"
+ @click.prevent="emit('submit')"
+ >
+ {{ form.submit_button_text || $t('forms.buttons.submit') }}
+ </open-form-button>
+ </slot>
+ </template>
+ <open-form-button
+ v-else-if="currentFieldsPageBreak"
+ native-type="button"
+ :form="form"
+ class="mt-2 px-8 mx-1"
+ :loading="isProcessing"
+ @click.stop="handleNextClick"
+ >
+ {{ currentFieldsPageBreak.next_btn_text || $t('forms.buttons.next') }}
+ </open-form-button>
+ <div v-if="structure && !currentFieldsPageBreak && !isLastPage">
+ {{ $t('forms.wrong_form_structure') }}
+ </div>
+ <div v-if="hasPaymentBlock" class="mt-6 flex justify-center w-full">
+ <p class="text-xs text-neutral-400 dark:text-neutral-500 flex text-center max-w-md">
+ {{ $t('forms.payment.payment_disclaimer') }}
+ </p>
+ </div>
</div>
- <div
- v-if="hasPaymentBlock"
- class="mt-6 flex justify-center w-full"
- >
- <p class="text-xs text-neutral-400 dark:text-neutral-500 flex text-center max-w-md">
- {{ $t('forms.payment.payment_disclaimer') }}
- </p>
+
+ <!-- Branding slot (renderer placement) -->
+ <slot name="branding" />
+
+ <!-- Cleanings slot -->
+ <div class="fixed bottom-4 left-4 max-w-full z-10" v-if="$slots.cleanings">
+ <div class="max-w-lg">
+ <slot name="cleanings" />
+ </div>
</div>
+
+ </div>
+
+ <!-- Branding button -->
+ <div v-if="!form.no_branding && showBranding" class="fixed z-10 bottom-4 right-4">
+ <PoweredBy :color="form.color" />
</div>
</form>
</template>
@@ -98,48 +158,49 @@
<script setup>
import { VueDraggable } from 'vue-draggable-plus'
import OpenFormButton from './OpenFormButton.vue'
+import BlockMediaLayout from './components/BlockMediaLayout.vue'
import CaptchaWrapper from '~/components/forms/heavy/components/CaptchaWrapper.vue'
import OpenFormField from './OpenFormField.vue'
import FormProgressbar from './FormProgressbar.vue'
+import PoweredBy from '~/components/pages/forms/show/PoweredBy.vue'
import { useWorkingFormStore } from '~/stores/working_form'
+import { FormMode } from '~/lib/forms/FormModeStrategy.js'
+import { useIsIframe } from '~/composables/useIsIframe'
const props = defineProps({
formManager: { type: Object, required: true }
})
+const emit = defineEmits(['submit'])
+
const workingFormStore = useWorkingFormStore()
+const isIframe = useIsIframe()
// Derive everything from formManager
const state = computed(() => props.formManager.state)
const form = computed(() => props.formManager.config.value)
const formPageIndex = computed(() => props.formManager.state.currentPage)
const strategy = computed(() => props.formManager.strategy.value)
-const structure = computed(() => props.formManager.structure)
+const structure = props.formManager.structure
-// Provide theme context for all child form components
-provide('formTheme', computed(() => form.value?.theme || 'default'))
-provide('formSize', computed(() => form.value?.size || 'md'))
-provide('formBorderRadius', computed(() => form.value?.border_radius || 'small'))
-const hasPaymentBlock = computed(() => {
- return structure.value?.currentPageHasPaymentBlock.value ?? false
-})
+const hasPaymentBlock = computed(() => structure.value?.currentPageHasPaymentBlock?.value ?? false)
-const currentFields = computed(() => {
- return structure.value?.getPageFields(state.value.currentPage) ?? []
-})
+const currentFields = computed(() => structure.value?.getPageFields?.(state.value.currentPage) ?? [])
const isLastPage = computed(() => {
- const result = structure.value?.isLastPage.value ?? true
- return result
+ const s = structure.value
+ if (!s) return true
+ if (s.isLastPage && 'value' in s.isLastPage) return s.isLastPage.value
+ if (s.pageCount && 'value' in s.pageCount) {
+ const count = s.pageCount.value || 0
+ return state.value.currentPage >= Math.max(0, count - 1)
+ }
+ return true
})
-const currentFieldsPageBreak = computed(() =>
- structure.value?.currentPageBreak.value
-)
-const previousFieldsPageBreak = computed(() =>
- structure.value?.previousPageBreak.value
-)
+const currentFieldsPageBreak = computed(() => structure.value?.currentPageBreak?.value ?? null)
+const previousFieldsPageBreak = computed(() => structure.value?.previousPageBreak?.value ?? null)
const allowDragging = computed(() => strategy.value.admin.allowDragging)
const draggingNewBlock = computed(() => workingFormStore.draggingNewBlock)
@@ -177,6 +238,30 @@ const handleDragUpdate = (evt) => {
const isProcessing = computed(() => props.formManager.state.isProcessing)
+// Renderer-level gates
+const isSubmitted = computed(() => !!props.formManager?.state.isSubmitted)
+const shouldDisplayForm = computed(() => {
+ const showAdminControls = !!props.formManager?.strategy?.value?.admin?.showAdminControls
+ return (!form.value?.is_closed && !form.value?.max_number_of_submissions_reached) || showAdminControls
+})
+const submittedData = computed(() => props.formManager?.form?.data?.() ?? null)
+
+// Preview mode width override (FormEditorPreview uses PREVIEW mode)
+const isPreviewMode = computed(() => props.formManager?.mode?.value === FormMode.PREVIEW)
+
+const coverMedia = computed(() => ({
+ url: form.value?.cover_picture,
+ focal_point: form.value?.cover_settings?.focal_point,
+ brightness: form.value?.cover_settings?.brightness
+}))
+
+// Hide logo/cover in READ_ONLY and EDIT modes
+const showBrandingMedia = computed(() => {
+ const mode = props.formManager?.mode?.value
+ if (mode === FormMode.READ_ONLY || mode === FormMode.EDIT) return false
+ return !!(form.value && (form.value.logo_picture || form.value.cover_picture))
+})
+
const getFieldWidthClasses = (width) => {
if (!width || width === 'full') return 'col-span-full'
else if (width === '1/2') {
@@ -192,6 +277,9 @@ const getFieldWidthClasses = (width) => {
}
return 'col-span-full'
}
+
+// Branding display control comes from strategy; default to true
+const showBranding = computed(() => props.formManager?.strategy?.value?.display?.showBranding ?? true)
</script>
<style lang='scss' scoped>
diff --git a/client/components/open/forms/OpenFormField.vue b/client/components/open/forms/OpenFormField.vue
index 2327d5cfd..513feb7a6 100644
--- a/client/components/open/forms/OpenFormField.vue
+++ b/client/components/open/forms/OpenFormField.vue
@@ -22,7 +22,7 @@
class="absolute translate-y-full lg:translate-y-0 -bottom-1 left-1/2 -translate-x-1/2 lg:-translate-x-full lg:-left-1 lg:top-1 lg:bottom-0 hidden group-hover/nffield:block z-10"
>
<div
- class="flex lg:flex-col bg-white !bg-white dark:!bg-white border rounded-sm shadow-xs z-50 p-[1px] relative"
+ class="flex lg:flex-col bg-white dark:!bg-white border rounded-sm shadow-xs z-50 p-[1px] relative"
>
<div
class="p-1 hover:!text-blue-500 dark:hover:!text-blue-500 hover:bg-blue-50 cursor-pointer !text-neutral-500 dark:!text-neutral-500 flex items-center justify-center rounded-md"
@@ -77,24 +77,8 @@
</div>
</div>
</div>
- <div v-if="fieldComponentInfo && fieldComponentInfo.component">
- <ClientOnlyWrapper :client-only="fieldComponentInfo.clientOnly">
- <Suspense>
- <component
- :is="fieldComponentInfo.component"
- v-bind="inputProperties(field)"
- :required="isFieldRequired"
- :disabled="isFieldDisabled"
- :is-admin-preview="isAdminPreview"
- />
- <template #fallback>
- <USkeleton class="w-full h-16 my-1.5" />
- </template>
- </Suspense>
- <template #fallback>
- <USkeleton class="w-full h-16 my-1.5" />
- </template>
- </ClientOnlyWrapper>
+ <div v-if="field">
+ <BlockRenderer :block="field" :form-manager="formManager" />
</div>
<template v-else>
<div
@@ -163,10 +147,9 @@
<script setup>
import FormLogicPropertyResolver from "~/lib/forms/FormLogicPropertyResolver.js"
-import { default as _has } from 'lodash/has'
import { FormMode, createFormModeStrategy } from "~/lib/forms/FormModeStrategy.js"
import { useWorkingFormStore } from '~/stores/working_form'
-import { useComponentRegistry } from '~/composables/components/useComponentRegistry'
+import BlockRenderer from './BlockRenderer.vue'
// Define props
const props = defineProps({
@@ -183,62 +166,17 @@ const props = defineProps({
// Derive everything from formManager
const form = computed(() => props.formManager?.config?.value || {})
const dataForm = computed(() => props.formManager?.form || {})
-const darkMode = computed(() => props.formManager?.darkMode?.value || false)
const showHidden = computed(() => props.formManager?.strategy?.value?.display?.showHiddenFields || false)
-const enableDisabledFields = computed(() => props.formManager?.strategy?.value?.display?.enableDisabledFields || false)
-const isReadOnlyMode = computed(() => props.formManager?.strategy?.value?.display?.disableFields || false)
// Setup stores and reactive state
const workingFormStore = useWorkingFormStore()
-const { getFormComponent } = useComponentRegistry()
const selectedFieldIndex = computed(() => workingFormStore.selectedFieldIndex)
const showEditFieldSidebar = computed(() => workingFormStore.showEditFieldSidebar)
const strategy = computed(() => props.formManager?.strategy?.value || createFormModeStrategy(FormMode.LIVE))
const isAdminPreview = computed(() => strategy.value?.admin?.showAdminControls || false)
// Computed properties
-const fieldComponentInfo = computed(() => {
- const field = props.field
- let componentName
-
- if (field.type === 'text' && field.multi_lines) {
- componentName = 'TextAreaInput'
- } else if (field.type === 'url' && field.file_upload) {
- componentName = 'FileInput'
- } else if (['select', 'multi_select'].includes(field.type) && field.without_dropdown) {
- componentName = 'FlatSelectInput'
- } else if (field.type === 'checkbox' && field.use_toggle_switch) {
- componentName = 'ToggleSwitchInput'
- } else if (field.type === 'signature') {
- componentName = 'SignatureInput'
- } else if (field.type === 'phone_number' && !field.use_simple_text_input) {
- componentName = 'PhoneInput'
- } else {
- componentName = {
- text: 'TextInput',
- rich_text: 'RichTextAreaInput',
- number: 'TextInput',
- rating: 'RatingInput',
- scale: 'ScaleInput',
- slider: 'SliderInput',
- select: 'SelectInput',
- multi_select: 'SelectInput',
- date: 'DateInput',
- files: 'FileInput',
- checkbox: 'CheckboxInput',
- url: 'TextInput',
- email: 'TextInput',
- phone_number: 'TextInput',
- matrix: 'MatrixInput',
- barcode: 'BarcodeInput',
- payment: 'PaymentInput',
- code: 'CodeInput'
- }[field.type]
- }
-
- // Let the component registry handle whether to return a string or an async component
- return getFormComponent(componentName)
-})
+// Field rendering is delegated to BlockRenderer
const isPublicFormPage = computed(() => useRoute().name === 'forms-slug')
@@ -248,15 +186,8 @@ const shouldBeHidden = computed(() =>
(new FormLogicPropertyResolver(props.field, dataForm.value)).isHidden()
)
-const isFieldRequired = computed(() =>
- (new FormLogicPropertyResolver(props.field, dataForm.value)).isRequired()
-)
-
-const isFieldDisabled = computed(() => {
- if (isReadOnlyMode.value) return true
- if (enableDisabledFields.value) return false
- return (new FormLogicPropertyResolver(props.field, dataForm.value)).isDisabled()
-})
+// Required/props now handled inside BlockRenderer
+/* noop */
const beingEdited = computed(() =>
isAdminPreview.value &&
@@ -267,7 +198,7 @@ const beingEdited = computed(() =>
// Methods
function editFieldOptions() {
if (!isAdminPreview.value) return
- workingFormStore.openSettingsForField(props.field)
+ workingFormStore.openSettingsForField(props.field, true)
}
function setFieldAsSelected() {
@@ -304,112 +235,7 @@ function getFieldAlignClasses(field) {
/**
* Get the right input component options for the field/options
*/
-function inputProperties(field) {
- const inputProperties = {
- key: field.id,
- name: field.id,
- form: dataForm.value,
- label: (field.hide_field_name) ? null : field.name + ((shouldBeHidden.value) ? ' (Hidden Field)' : ''),
- color: form.value.color,
- placeholder: field.placeholder,
- help: field.help,
- helpPosition: (field.help_position) ? field.help_position : 'below_input',
- uppercaseLabels: form.value.uppercase_labels == 1 || form.value.uppercase_labels == true,
- maxCharLimit: (field.max_char_limit) ? parseInt(field.max_char_limit) : null,
- showCharLimit: field.show_char_limit || false,
- isDark: darkMode.value,
- locale: (form.value?.language) ? form.value.language : 'en'
- }
-
- if (field.type === 'matrix') {
- inputProperties.rows = field.rows
- inputProperties.columns = field.columns
- }
-
- if (field.type === 'barcode') {
- inputProperties.decoders = field.decoders
- }
-
- if (['select','multi_select'].includes(field.type) && !isFieldRequired.value) {
- inputProperties.clearable = true
- }
-
- if (['select', 'multi_select'].includes(field.type)) {
- inputProperties.options = (_has(field, field.type))
- ? field[field.type].options.map(option => {
- return {
- name: option.name,
- value: option.name
- }
- })
- : []
- inputProperties.multiple = (field.type === 'multi_select')
- inputProperties.allowCreation = (field.allow_creation === true)
- inputProperties.searchable = (inputProperties.options.length > 4)
-
- // Add min/max selection constraints for multi_select
- if (field.type === 'multi_select') {
- inputProperties.minSelection = field.min_selection || null
- inputProperties.maxSelection = field.max_selection || null
- }
- } else if (field.type === 'date') {
- inputProperties.dateFormat = field.date_format
- inputProperties.timeFormat = field.time_format
- if (field.with_time) {
- inputProperties.withTime = true
- }
- if (field.date_range) {
- inputProperties.dateRange = true
- }
- if (field.disable_past_dates) {
- inputProperties.disablePastDates = true
- } else if (field.disable_future_dates) {
- inputProperties.disableFutureDates = true
- }
- } else if (field.type === 'files' || (field.type === 'url' && field.file_upload)) {
- inputProperties.multiple = (field.multiple !== undefined && field.multiple)
- inputProperties.cameraUpload = (field.camera_upload !== undefined && field.camera_upload)
- let maxFileSize = (form.value?.workspace && form.value?.workspace.max_file_size) ? form.value?.workspace?.max_file_size : 10
- if (field?.max_file_size > 0) {
- maxFileSize = Math.min(field.max_file_size, maxFileSize)
- }
- inputProperties.mbLimit = maxFileSize
- inputProperties.accept = (form.value.is_pro && field.allowed_file_types) ? field.allowed_file_types : ''
- } else if (field.type === 'rating') {
- inputProperties.numberOfStars = parseInt(field.rating_max_value) ?? 5
- } else if (field.type === 'scale') {
- inputProperties.minScale = parseFloat(field.scale_min_value) ?? 1
- inputProperties.maxScale = parseFloat(field.scale_max_value) ?? 5
- inputProperties.stepScale = parseFloat(field.scale_step_value) ?? 1
- } else if (field.type === 'slider') {
- inputProperties.minSlider = parseInt(field.slider_min_value) ?? 0
- inputProperties.maxSlider = parseInt(field.slider_max_value) ?? 50
- inputProperties.stepSlider = parseInt(field.slider_step_value) ?? 5
- } else if (field.type === 'number' || (field.type === 'phone_number' && field.use_simple_text_input)) {
- inputProperties.pattern = '/d*'
- } else if (field.type === 'phone_number' && !field.use_simple_text_input) {
- inputProperties.unavailableCountries = field.unavailable_countries ?? []
- } else if (field.type === 'text' && field.secret_input) {
- inputProperties.nativeType = 'password'
- } else if (field.type === 'payment') {
- inputProperties.direction = form.value.layout_rtl ? 'rtl' : 'ltr'
- inputProperties.currency = field.currency
- inputProperties.amount = field.amount
- inputProperties.oauthProviderId = field.stripe_account_id
-
- // Get paymentData from formManager if available
- if (props.formManager?.payment) {
- try {
- inputProperties.paymentData = props.formManager.payment.getPaymentData(field)
- } catch (error) {
- console.error("Error getting payment data:", error)
- }
- }
- }
-
- return inputProperties
-}
</script>
diff --git a/client/components/open/forms/OpenFormFocused.vue b/client/components/open/forms/OpenFormFocused.vue
new file mode 100644
index 000000000..bb7ad1485
--- /dev/null
+++ b/client/components/open/forms/OpenFormFocused.vue
@@ -0,0 +1,222 @@
+<template>
+ <form v-if="form" @submit.prevent="" class="@container w-full relative overflow-hidden flex flex-col min-h-full">
+ <!-- Fixed fullscreen background from form cover -->
+ <div v-if="form.cover_picture" class="absolute inset-0 pointer-events-none">
+ <BlockMediaLayout :image="coverMedia" alt="Form cover image" />
+ </div>
+
+ <!-- Fixed logo in top-left -->
+ <div v-if="form.logo_picture" class="absolute top-10 left-10 z-10">
+ <img :src="form.logo_picture" :alt="form.seo_meta?.site_name ? `${form.seo_meta.site_name} logo` : 'Form logo'" class="size-16 object-contain">
+ </div>
+
+ <!-- Progressbar -->
+ <FormProgressbar :form-manager="formManager" />
+
+ <!-- Slide: question vertically centered, next/submit button slides with it -->
+ <SlidingTransition
+ direction="vertical"
+ :step="currentIndex"
+ :auto-height="false"
+ class="grow min-h-0 flex"
+ :speed="500"
+ >
+ <!-- Password view (exclusive) -->
+ <template v-if="$slots.password && form?.is_password_protected" key="password">
+ <div key="pwd" class="w-full flex items-center px-6 grow min-h-0 z-10">
+ <div class="w-full max-w-xl mx-auto p-4">
+ <slot name="password" />
+ </div>
+ </div>
+ </template>
+ <!-- Alerts view (exclusive) -->
+ <template v-else-if="$slots.alerts" key="alerts">
+ <div key="alerts" class="w-full flex items-center px-6 grow min-h-0 z-10">
+ <div class="w-full max-w-2xl mx-auto p-4">
+ <slot name="alerts" />
+ </div>
+ </div>
+ </template>
+ <!-- After-submit view (exclusive) -->
+ <template v-else-if="props.formManager?.state.isSubmitted && $slots['after-submit']" key="submitted">
+ <div key="submitted" class="w-full flex items-center px-6 grow min-h-0 z-10">
+ <div class="w-full max-w-2xl mx-auto p-4">
+ <slot name="after-submit" :submittedData="props.formManager?.form?.data?.()" />
+ </div>
+ </div>
+ </template>
+ <component v-else :is="currentLayoutComponent" v-bind="currentLayoutProps" :key="currentIndex">
+ <div class="relative">
+ <BlockRenderer :block="currentBlock" :form-manager="formManager" />
+ </div>
+ <div class="mt-2 flex gap-2 justify-start" :class="{'flex-col justify-normal! items-center': isLast &&form.use_captcha}">
+ <slot name="submit-btn" v-if="isLast" :loading="isProcessing">
+ <CaptchaWrapper v-if="form.use_captcha" :form-manager="formManager" />
+ <open-form-button :form="form" class="mt-0.5 px-6" :loading="isProcessing" @click.prevent="emit('submit')">
+ {{ form.submit_button_text || $t('forms.buttons.submit') }}
+ </open-form-button>
+ </slot>
+ <open-form-button v-else native-type="button" :form="form" class="mt-0.5 px-6" :loading="isProcessing" @click.stop="handleNextClick">
+ {{ form?.translations?.focused_next_button_text || $t('forms.buttons.next') }}
+ </open-form-button>
+ </div>
+ <div v-if="hasPaymentBlock" class="mt-2">
+ <p class="text-xs text-neutral-400 dark:text-neutral-500 max-w-md">
+ {{ $t('forms.payment.payment_disclaimer') }}
+ </p>
+ </div>
+ </component>
+ </SlidingTransition>
+
+ <!-- Cleanings slot -->
+ <div class="fixed bottom-4 left-4 max-w-full z-10" v-if="$slots.cleanings">
+ <div class="max-w-lg">
+ <slot name="cleanings" />
+ </div>
+ </div>
+
+ <!-- Bottom right controls: arrows and branding -->
+ <div class="hidden sm:flex gap-2 fixed bottom-8 right-8 z-10" aria-label="Form controls">
+ <!-- Focused nav arrows with fade transition -->
+ <Transition name="fade" mode="out-in">
+ <div v-if="shouldShowArrows && showArrowsOnCurrentPage" class="flex gap-2">
+ <UButton color="form" square variant="solid" icon="i-heroicons-chevron-up-20-solid" :disabled="!canGoPrev" @click="goPrev" />
+ <UButton color="form" square variant="solid" icon="i-heroicons-chevron-down-20-solid" :disabled="isLast" @click="goNext" />
+ </div>
+ </Transition>
+ <!-- Branding button -->
+ <PoweredBy v-if="!form.no_branding && showBranding" :color="form.color" />
+ </div>
+ </form>
+</template>
+
+<script setup>
+import BlockRenderer from './BlockRenderer.vue'
+import BlockMediaLayout from './components/BlockMediaLayout.vue'
+import SideMediaSplit from './components/layouts/SideMediaSplit.vue'
+import SideMediaSmall from './components/layouts/SideMediaSmall.vue'
+import CenteredStep from './components/layouts/CenteredStep.vue'
+import FormProgressbar from './FormProgressbar.vue'
+import OpenFormButton from './OpenFormButton.vue'
+import SlidingTransition from '../../global/transitions/SlidingTransition.vue'
+import CaptchaWrapper from '~/components/forms/heavy/components/CaptchaWrapper.vue'
+import { FormMode } from '~/lib/forms/FormModeStrategy.js'
+import { useFormImagePreloader } from '~/composables/forms/useFormImagePreloader.js'
+import PoweredBy from '~/components/pages/forms/show/PoweredBy.vue'
+
+const props = defineProps({
+ formManager: { type: Object, required: true }
+})
+
+const emit = defineEmits(['submit'])
+
+const form = computed(() => props.formManager.config.value)
+const structure = props.formManager.structure
+const state = computed(() => props.formManager.state)
+const isTemplateMode = computed(() => props.formManager?.mode?.value === FormMode.TEMPLATE)
+
+const currentIndex = computed(() => state.value.currentPage)
+const currentFields = computed(() => structure?.value?.getPageFields
+ ? structure.value.getPageFields(currentIndex.value)
+ : [])
+const currentBlock = computed(() => currentFields.value?.[0] || null)
+const currentMedia = computed(() => currentBlock.value?.image || null)
+
+const isLast = computed(() => structure?.value?.isLastPage?.value ?? false)
+const isProcessing = computed(() => props.formManager.state.isProcessing)
+const hasPaymentBlock = computed(() => structure.value?.currentPageHasPaymentBlock?.value ?? false)
+
+// Reserved for future gating if focused renderer wants to branch
+// const isSubmitted = computed(() => !!props.formManager?.state.isSubmitted)
+// const isPasswordProtected = computed(() => !!form.value?.is_password_protected)
+
+const layoutName = computed(() => currentMedia.value?.layout || null)
+
+// Lookup table for layout -> component + props
+const layoutConfig = {
+ 'left-split': {
+ component: SideMediaSplit,
+ props: () => ({ image: currentMedia.value, side: 'left' })
+ },
+ 'right-split': {
+ component: SideMediaSplit,
+ props: () => ({ image: currentMedia.value, side: 'right' })
+ },
+ 'left-small': {
+ component: SideMediaSmall,
+ props: () => ({ image: currentMedia.value, side: 'left', borderRadius: borderRadius.value })
+ },
+ 'right-small': {
+ component: SideMediaSmall,
+ props: () => ({ image: currentMedia.value, side: 'right', borderRadius: borderRadius.value })
+ },
+ 'background': {
+ component: CenteredStep,
+ props: () => ({ background: currentMedia.value })
+ }
+}
+
+// Single dynamic component + props for active layout
+const currentLayoutComponent = computed(() => layoutConfig[layoutName.value]?.component || CenteredStep)
+const currentLayoutProps = computed(() => layoutConfig[layoutName.value]?.props() || { background: null })
+
+const handleNextClick = () => {
+ props.formManager.nextPage().then((moved) => {
+ if (moved && import.meta.client && !isTemplateMode.value) window.scrollTo({ top: 0, behavior: 'smooth' })
+ })
+}
+
+const coverMedia = computed(() => ({
+ url: form.value?.cover_picture,
+ focal_point: form.value?.cover_settings?.focal_point,
+ brightness: form.value?.cover_settings?.brightness
+}))
+
+const borderRadius = computed(() => form.value?.border_radius || 'small')
+
+// Preload images used by the form (cover/logo/blocks)
+useFormImagePreloader(form, state)
+
+// Slots/utilities
+const slots = useSlots()
+
+// Branding gating from strategy; defaults to true when not present
+const showBranding = computed(() => props.formManager?.strategy?.value?.display?.showBranding ?? true)
+
+// Focused arrows logic and gating
+const showArrowsSetting = computed(() => (form.value?.settings?.navigation_arrows !== false))
+const canGoPrev = computed(() => state.value.currentPage > 0)
+const hasExclusiveView = computed(() => (
+ !!(form.value?.is_password_protected && slots.password) ||
+ !!slots.alerts ||
+ (!!props.formManager?.state.isSubmitted && !!slots['after-submit'])
+))
+const shouldShowArrows = computed(() => showArrowsSetting.value && !hasExclusiveView.value)
+const showArrowsOnCurrentPage = computed(() => {
+ // Don't show arrows on first page (page 0) - only show when there are multiple pages and we're not on the first
+ return state.value.currentPage > 0 || !isLast.value
+})
+const goPrev = () => {
+ if (canGoPrev.value && props.formManager?.previousPage) {
+ try {
+ const result = props.formManager.previousPage()
+ if (result && typeof result.then === 'function') {
+ result.then(() => {
+ // Navigation successful
+ }).catch(error => {
+ console.warn('Error in previousPage:', error)
+ }).finally(() => {
+ if (import.meta.client) window.scrollTo({ top: 0, behavior: 'smooth' })
+ })
+ } else {
+ // Synchronous result, scroll immediately
+ if (import.meta.client) window.scrollTo({ top: 0, behavior: 'smooth' })
+ }
+ } catch (error) {
+ console.warn('Error calling previousPage:', error)
+ if (import.meta.client) window.scrollTo({ top: 0, behavior: 'smooth' })
+ }
+ }
+}
+const goNext = () => { if (!isLast.value) handleNextClick() }
+</script>
diff --git a/client/components/open/forms/components/BlockMediaLayout.vue b/client/components/open/forms/components/BlockMediaLayout.vue
new file mode 100644
index 000000000..696999365
--- /dev/null
+++ b/client/components/open/forms/components/BlockMediaLayout.vue
@@ -0,0 +1,99 @@
+<template>
+ <div class="relative w-full h-full" :style="wrapperStyle">
+ <VTransition name="fade">
+ <div
+ v-if="image && image.url && !isLoaded"
+ class="absolute inset-0 bg-neutral-500"
+ />
+ </VTransition>
+ <img
+ v-if="image && image.url"
+ :src="image.url"
+ :alt="(image.alt && image.alt.length > 0) ? image.alt : alt"
+ :class="[imgClass, { 'opacity-0': !isLoaded }]"
+ :style="imageStyle"
+ draggable="false"
+ ref="imgEl"
+ @dragstart.prevent
+ @load="onLoad"
+ @error="onError"
+ >
+ </div>
+
+</template>
+
+<script setup>
+/*
+ BlockMediaLayout
+ Props:
+ - image: {
+ url: string,
+ alt?: string,
+ layout?: 'between'|'right-small'|'left-small'|'right-split'|'left-split'|'background',
+ focal_point?: { x: number, y: number }, // 0..100
+ brightness?: number // -100..100
+ }
+*/
+
+const props = defineProps({
+ image: { type: Object, required: false },
+ // min-height to reserve space before image loads; accepts number (px) or CSS size string
+ fallbackHeight: { type: [String, Number], default: '12rem' },
+ // classes applied to the <img> element
+ imgClass: { type: String, default: 'w-full h-full object-cover transition-opacity duration-300' },
+ alt: { type: String, default: '' }
+})
+
+const isLoaded = ref(false)
+const imgEl = ref(null)
+
+const onLoad = () => {
+ isLoaded.value = true
+}
+
+const onError = () => {
+ isLoaded.value = false
+}
+
+watch(() => props.image?.url, () => {
+ isLoaded.value = false
+})
+
+onMounted(() => {
+ // If SSR rendered and image is already cached/loaded, mark as loaded
+ if (imgEl.value && imgEl.value.complete) {
+ isLoaded.value = true
+ }
+})
+
+const imageStyle = computed(() => {
+ const x = props.image?.focal_point?.x ?? 50
+ const y = props.image?.focal_point?.y ?? 50
+ const b = props.image?.brightness ?? 0 // -100..100
+ let filter = ''
+ if (b > 0) {
+ // Positive values: combine brightness (1..2) and contrast (1..0)
+ const brightnessScale = Math.max(1, Math.min(2, 1 + (b / 100)))
+ const contrastScale = Math.max(0, Math.min(1, 1 - (b / 100)))
+ filter = `contrast(${contrastScale}) brightness(${brightnessScale})`
+ } else {
+ // Negative values: brightness only (0..1)
+ const brightnessScale = Math.max(0, Math.min(1, (b + 100) / 100))
+ filter = `brightness(${brightnessScale})`
+ }
+ return {
+ objectPosition: `${x}% ${y}%`,
+ filter
+ }
+})
+
+const wrapperStyle = computed(() => {
+ const h = props.fallbackHeight
+ if (h === null || h === undefined || h === '') return {}
+ const value = typeof h === 'number' ? `${h}px` : h
+ return { minHeight: value }
+})
+</script>
+
+
+
diff --git a/client/components/open/forms/components/FormEditor.vue b/client/components/open/forms/components/FormEditor.vue
index 6f6a35826..befbaa824 100644
--- a/client/components/open/forms/components/FormEditor.vue
+++ b/client/components/open/forms/components/FormEditor.vue
@@ -224,9 +224,9 @@ const displayFormModificationAlert = (responseData) => {
responseData.form.cleanings &&
Object.keys(responseData.form.cleanings).length > 0
) {
- alert.warning(responseData.message)
+ alert.warning(responseData.message, 10000, { form: responseData.form })
} else if (responseData.message) {
- alert.success(responseData.message)
+ alert.success(responseData.message, 10000, { form: responseData.form })
}
}
diff --git a/client/components/open/forms/components/FormSubmissions.vue b/client/components/open/forms/components/FormSubmissions.vue
index 76d24f328..2a3cb834e 100644
--- a/client/components/open/forms/components/FormSubmissions.vue
+++ b/client/components/open/forms/components/FormSubmissions.vue
@@ -4,6 +4,7 @@
<OpenTable
v-if="form"
ref="table"
+ class="border-b"
:data="submissions"
:loading="isLoading || isFetching"
:form="form"
diff --git a/client/components/open/forms/components/form-components/AddFormBlock.vue b/client/components/open/forms/components/form-components/AddFormBlock.vue
index c664458d2..8c9319fb2 100644
--- a/client/components/open/forms/components/form-components/AddFormBlock.vue
+++ b/client/components/open/forms/components/form-components/AddFormBlock.vue
@@ -102,8 +102,18 @@ import AiFieldGenerator from './components/AiFieldGenerator.vue'
const workingFormStore = useWorkingFormStore()
const { isAuthenticated: authenticated } = useIsAuthenticated()
-const inputBlocks = computed(() => Object.values(blocksTypes).filter(block => !block.name.startsWith('nf-')))
-const layoutBlocks = computed(() => Object.values(blocksTypes).filter(block => block.name.startsWith('nf-')))
+const formStyle = computed(() => workingFormStore.content?.presentation_style || 'classic')
+
+const allowedBlocks = computed(() => {
+ const all = Object.values(blocksTypes)
+ return all.filter(block => {
+ const modes = block.available_in || ['classic', 'focused']
+ return modes.includes(formStyle.value)
+ })
+})
+
+const inputBlocks = computed(() => allowedBlocks.value.filter(block => !block.name.startsWith('nf-')))
+const layoutBlocks = computed(() => allowedBlocks.value.filter(block => block.name.startsWith('nf-')))
const closeSidebar = () => {
workingFormStore.closeAddFieldSidebar()
diff --git a/client/components/open/forms/components/form-components/EditorSectionHeader.vue b/client/components/open/forms/components/form-components/EditorSectionHeader.vue
index b9fa1fdbd..96c988d62 100644
--- a/client/components/open/forms/components/form-components/EditorSectionHeader.vue
+++ b/client/components/open/forms/components/form-components/EditorSectionHeader.vue
@@ -12,7 +12,7 @@
>
<Icon
:name="icon"
- class="w-4 h-4 text-neutral-400"
+ :class="['w-4 h-4 text-neutral-400', iconClass]"
/>
<h3 class="text-sm font-semibold text-neutral-500">
{{ title }}
@@ -34,6 +34,10 @@ title: {
showLine: {
type: Boolean,
default: true
+},
+iconClass: {
+ type: String,
+ default: ''
}
})
</script>
\ No newline at end of file
diff --git a/client/components/open/forms/components/form-components/FormCustomization.vue b/client/components/open/forms/components/form-components/FormCustomization.vue
index 249761637..5929969ac 100644
--- a/client/components/open/forms/components/form-components/FormCustomization.vue
+++ b/client/components/open/forms/components/form-components/FormCustomization.vue
@@ -6,6 +6,8 @@
:show-line="false"
/>
+ <PresentationStyleSwitch />
+
<select-input
name="theme"
class="mt-4"
@@ -54,7 +56,7 @@
/>
<div class="grid grid-cols-2 gap-4">
<div class="flex-grow my-1" v-if="useFeatureFlag('services.google.fonts')">
- <label class="text-neutral-700 font-semibold text-sm mb-1 block">Font Family</label>
+ <label class="text-neutral-700 font-semibold text-xs mb-0.5 block">Font Family</label>
<UButton
color="neutral"
variant="outline"
@@ -87,14 +89,12 @@
<ToggleSwitchInput
name="layout_rtl"
:form="form"
- class="mt-4"
label="Right-to-Left Layout"
/>
<toggle-switch-input
name="uppercase_labels"
:form="form"
- class="mt-4"
label="Uppercase Input Labels"
/>
@@ -141,6 +141,7 @@
:form="form"
name="width"
seamless
+ v-if="!isFocused"
:options="[
{ name: 'centered', label: 'Centered' },
{ name: 'full', label: 'Full Width' },
@@ -152,7 +153,7 @@
<EditorSectionHeader
icon="heroicons:tag-16-solid"
- title="Branding & Media"
+ title="Branding"
/>
<div class="grid grid-cols-2 gap-4">
<image-input
@@ -162,12 +163,7 @@
:required="false"
/>
- <image-input
- name="cover_picture"
- :form="form"
- label="Cover (~1500px)"
- :required="false"
- />
+ <ImageWithSettings :form="form" name="cover_picture" :label="isFocused ? 'Background' : 'Cover (~1500px)'" kind="cover" />
</div>
<toggle-switch-input
@@ -177,9 +173,11 @@
@update:model-value="onChangeNoBranding"
>
<template #label>
- <span class="text-sm">
- Hide OpnForm Branding
- </span>
+ <InputLabel
+ :label="'Hide OpnForm Branding'"
+ :native-for="'no_branding'"
+ class="text-sm font-medium!"
+ />
<pro-tag
upgrade-modal-title="Upgrade today to remove OpnForm branding"
class="-mt-1"
@@ -191,6 +189,14 @@
icon="heroicons:cog-6-tooth-16-solid"
title="Advanced Options"
/>
+
+ <toggle-switch-input
+ v-if="isFocused"
+ v-model="navigationArrows"
+ :form="form"
+ class="mt-2"
+ label="Show navigation arrows"
+ />
<toggle-switch-input
name="show_progress_bar"
:form="form"
@@ -227,6 +233,8 @@ import { useWorkingFormStore } from "../../../../../stores/working_form"
import GoogleFontPicker from "../../../editors/GoogleFontPicker.vue"
import ProTag from "~/components/app/ProTag.vue"
import { DEFAULT_COLOR } from "@/composables/forms/initForm"
+import PresentationStyleSwitch from "./PresentationStyleSwitch.vue"
+import ImageWithSettings from "../media/ImageWithSettings.vue"
const workingFormStore = useWorkingFormStore()
@@ -246,10 +254,25 @@ const isPro = computed(() => {
return workspace.value.is_pro
})
+const isFocused = computed(() => form.value?.presentation_style === 'focused')
+
const availableLocales = computed(() => {
return $i18n.locales?.value.map(locale => ({ name: locale.name, value: locale.code })) ?? []
})
+// Bind navigation arrows robustly even if settings is missing
+const navigationArrows = computed({
+ get() {
+ return form.value?.settings?.navigation_arrows ?? true
+ },
+ set(val) {
+ if (!form.value) return
+ const currentSettings = form.value.settings ?? {}
+ // Reassign the whole settings object to ensure reactivity
+ form.value.settings = { ...currentSettings, navigation_arrows: val }
+ }
+})
+
onMounted(() => {
isMounted.value = true
})
diff --git a/client/components/open/forms/components/form-components/FormEditorPreview.vue b/client/components/open/forms/components/form-components/FormEditorPreview.vue
index 9d5af67b7..2297e0320 100644
--- a/client/components/open/forms/components/form-components/FormEditorPreview.vue
+++ b/client/components/open/forms/components/form-components/FormEditorPreview.vue
@@ -2,7 +2,7 @@
<!-- Backdrop -->
<div
v-if="isExpanded"
- class="fixed inset-0 z-40 bg-white/30 dark:bg-neutral-900/30 backdrop-blur-xs"
+ class="fixed inset-0 z-40 bg-white/30 dark:bg-neutral-900/30 backdrop-blur-xs"
@click="toggleExpand"
/>
@@ -12,12 +12,12 @@
ref="parent"
:class="{
'fixed inset-8 z-50 !flex': isExpanded,
- 'bg-neutral-50 dark:bg-notion-dark-light hidden md:flex flex-grow p-4 flex-col items-center overflow-y-scroll shadow-inner': !isExpanded
+ 'bg-neutral-50 dark:bg-notion-dark-light hidden md:flex flex-grow p-4 flex-col items-center shadow-inner': !isExpanded
}"
>
<div
- class="border rounded-lg bg-white dark:bg-notion-dark w-full block shadow-xs transition-all flex flex-col"
- :class="{ 'max-w-5xl': !isExpanded, 'h-full': isExpanded }"
+ class="border rounded-lg bg-white dark:bg-notion-dark w-full grow shadow-xs transition-all overflow-y-scroll flex flex-col"
+ :class="{ 'h-full': isExpanded }"
>
<div class="w-full bg-white dark:bg-neutral-950 border-b border-neutral-300 dark:border-blue-900 dark:border-neutral-700 rounded-t-lg p-1.5 pl-4 pr-1.5 flex items-center gap-x-1.5">
<div class="bg-red-500 rounded-full w-2.5 h-2.5" />
@@ -28,7 +28,7 @@
</p>
<div class="flex-grow" />
<UButton
- v-if="previewFormSubmitted"
+ v-if="previewFormSubmitted || (form && form.presentation_style === 'focused' && workingFormStore.formPageIndex !== 0)"
icon="i-heroicons-arrow-path-rounded-square"
color="neutral"
variant="outline"
@@ -53,53 +53,55 @@
</UTooltip>
</TrackClick>
</div>
- <div class="flex-grow overflow-y-auto">
- <transition
- enter-active-class="linear duration-100 overflow-hidden"
- enter-from-class="max-h-0"
- enter-to-class="max-h-56"
- leave-active-class="linear duration-100 overflow-hidden"
- leave-from-class="max-h-56"
- leave-to-class="max-h-0"
- >
- <div v-if="(form.logo_picture || form.cover_picture)">
- <div v-if="form.cover_picture">
- <div
- id="cover-picture"
- class="h-[30vh] w-full overflow-hidden flex items-center justify-center"
- >
- <img
- alt="Form Cover Picture"
- :src="coverPictureSrc(form.cover_picture)"
- class="object-cover w-full h-[30vh] object-center"
- >
- </div>
- </div>
- <div
- v-if="form.logo_picture"
- class="w-full mx-auto py-5 relative"
- :class="{'pt-20':!form.cover_picture, 'max-w-lg': form && (form.width === 'centered'),'px-7': !isExpanded, 'px-3': isExpanded}"
- :style="{ 'direction': form?.layout_rtl ? 'rtl' : 'ltr' }"
- >
- <img
- alt="Logo Picture"
- :src="coverPictureSrc(form.logo_picture)"
- :class="{'top-5':!form.cover_picture, '-top-10':form.cover_picture}"
- class="max-w-60 h-20 object-contain absolute transition-all"
- >
- </div>
- </div>
- </transition>
+ <div class="flex-grow overflow-y-auto relative flex flex-col transform-gpu">
+ <!-- The transform creates a containing block so descendants with position: fixed
+ are anchored to this preview container instead of the page viewport. -->
<open-complete-form
ref="formPreview"
- class="w-full mx-auto py-5"
- :class="{'max-w-lg': form && (form.width === 'centered'),'px-7': !isExpanded, 'px-3': isExpanded}"
+ class="w-full grow min-h-0"
:form="form"
:dark-mode="darkMode"
:mode="formMode"
@restarted="previewFormSubmitted=false"
@submitted="previewFormSubmitted=true"
/>
+ <!-- Quick actions for focused presentation (only when not expanded) -->
+
+ <VTransition name="fade">
+ <div
+ v-if="!isExpanded && form && form.presentation_style === 'focused'"
+ class="absolute top-2 right-2 z-20 flex items-center gap-2"
+ >
+ <UTooltip text="Add block">
+ <UButton
+ icon="i-heroicons-plus"
+ color="neutral"
+ variant="outline"
+ size="sm"
+ @click.stop="handleAddBlock"
+ />
+ </UTooltip>
+ <UButtonGroup size="sm">
+ <UTooltip text="Edit question">
+ <UButton
+ icon="i-heroicons-cog-6-tooth"
+ color="neutral"
+ variant="outline"
+ label="Edit"
+ @click.stop="handleEditCurrent"
+ />
+ </UTooltip>
+ <UDropdownMenu :items="moreMenuItems" :content="{ align: 'end' }">
+ <UButton
+ color="neutral"
+ variant="outline"
+ icon="i-heroicons-ellipsis-vertical"
+ @click.stop
+ />
+ </UDropdownMenu>
+ </UButtonGroup>
+ </div>
+ </VTransition>
</div>
</div>
</div>
@@ -163,17 +165,6 @@ onMounted(() => {
handleDarkModeChange()
})
-function coverPictureSrc(val) {
- try {
- // Is valid url
- new URL(val)
- } catch {
- // Is file
- return URL.createObjectURL(val)
- }
- return val
-}
-
function handleDarkModeChange() {
handleDarkMode(form.value.dark_mode, parent.value)
}
@@ -195,6 +186,109 @@ function restartForm() {
function toggleExpand() {
isExpanded.value = !isExpanded.value
}
+
+// Helpers to get current focused slide index
+const currentSlideIndex = computed(() => {
+ try {
+ // Prefer structure service from store if available
+ const struct = workingFormStore.structureService
+ if (struct && struct.currentPage !== undefined) {
+ const cp = struct.currentPage
+ return (typeof cp === 'number') ? cp : (cp?.value ?? 0)
+ }
+ // Fallback to formPreview's formManager
+ return formPreview.value?.formManager?.state?.currentPage ?? 0
+ } catch {
+ return 0
+ }
+})
+
+// Shared guards/helpers
+const isFocusedEditing = computed(() => {
+ return !!(
+ form.value &&
+ form.value.presentation_style === 'focused' &&
+ workingFormStore.showEditFieldSidebar
+ )
+})
+
+function isValidIndex(index) {
+ const total = (workingFormStore.content?.properties?.length) || 0
+ return typeof index === 'number' && index >= 0 && index < total
+}
+
+// Sync selected field with current page in focused mode while editing
+watch(() => currentSlideIndex.value, (newIndex) => {
+ try {
+ if (isFocusedEditing.value && isValidIndex(newIndex) && workingFormStore.selectedFieldIndex !== newIndex) {
+ // Update the selected field to follow the currently focused slide
+ workingFormStore.setEditingField(newIndex)
+ }
+ } catch (e) {
+ console.error(e)
+ }
+})
+
+// Also keep the preview page aligned when selection changes externally
+watch(() => workingFormStore.selectedFieldIndex, (newIndex) => {
+ try {
+ if (isFocusedEditing.value && isValidIndex(newIndex)) {
+ const struct = workingFormStore.structureService
+ if (struct && typeof struct.setPageForField === 'function') {
+ struct.setPageForField(newIndex)
+ }
+ }
+ } catch (e) {
+ console.error(e)
+ }
+})
+
+function handleAddBlock() {
+ try {
+ workingFormStore.activeTab = 'build'
+ workingFormStore.openAddFieldSidebar(currentSlideIndex.value)
+ } catch (e) {
+ console.error(e)
+ }
+}
+
+function handleEditCurrent() {
+ try {
+ workingFormStore.activeTab = 'build'
+ workingFormStore.openSettingsForField(currentSlideIndex.value, true)
+ } catch (e) {
+ console.error(e)
+ }
+}
+
+// Dropdown items and actions for current slide
+const moreMenuItems = computed(() => ([
+ [
+ {
+ label: 'Duplicate',
+ icon: 'i-heroicons-document-duplicate-20-solid',
+ onClick: handleDuplicateCurrent
+ }
+ ],
+ [
+ {
+ label: 'Delete',
+ icon: 'i-heroicons-trash-20-solid',
+ color: 'error',
+ onClick: handleDeleteCurrent
+ }
+ ]
+]))
+
+function handleDuplicateCurrent() {
+ const index = currentSlideIndex.value
+ workingFormStore.duplicateField(index)
+}
+
+function handleDeleteCurrent() {
+ const index = currentSlideIndex.value
+ workingFormStore.removeField(index)
+}
</script>
<style scoped>
diff --git a/client/components/open/forms/components/form-components/FormSubmissionSettings.vue b/client/components/open/forms/components/form-components/FormSubmissionSettings.vue
index 511d51744..262c582db 100644
--- a/client/components/open/forms/components/form-components/FormSubmissionSettings.vue
+++ b/client/components/open/forms/components/form-components/FormSubmissionSettings.vue
@@ -10,12 +10,22 @@
</div>
</div>
- <TextInput
- name="submit_button_text"
- :form="form"
- class="max-w-xs"
- label="Submit button text"
- />
+ <div class="flex flex-wrap items-end gap-4">
+ <TextInput
+ name="submit_button_text"
+ :form="form"
+ class="max-w-xs"
+ label="Submit button text"
+ />
+ <TextInput
+ v-if="isFocused"
+ v-model="focusedNextText"
+ name="focused_next_button_text"
+ class="max-w-xs"
+ label="Next button text"
+ :placeholder="$t('forms.buttons.next')"
+ />
+ </div>
<ToggleSwitchInput
name="auto_save"
:form="form"
@@ -263,4 +273,27 @@ watch(submissionOptions, (val) => {
const hasPaymentBlock = computed(() => {
return form.value.properties.some(property => property.type === 'payment')
})
+
+const isFocused = computed(() => form.value?.presentation_style === 'focused')
+
+onMounted(() => {
+ // Ensure translations is a plain, writable object (avoid writing into readonly proxies)
+ const t = form.value?.translations
+ if (!t || typeof t !== 'object' || Array.isArray(t)) {
+ form.value.translations = {}
+ } else {
+ form.value.translations = { ...t }
+ }
+})
+
+const focusedNextText = computed({
+ get() {
+ return form.value?.translations?.focused_next_button_text || ''
+ },
+ set(val) {
+ const current = form.value?.translations && typeof form.value.translations === 'object' ? form.value.translations : {}
+ // Replace the entire translations object to avoid setting into a readonly proxy
+ form.value.translations = { ...current, focused_next_button_text: val }
+ }
+})
</script>
diff --git a/client/components/open/forms/components/form-components/PresentationStyleSwitch.vue b/client/components/open/forms/components/form-components/PresentationStyleSwitch.vue
new file mode 100644
index 000000000..039401e6c
--- /dev/null
+++ b/client/components/open/forms/components/form-components/PresentationStyleSwitch.vue
@@ -0,0 +1,182 @@
+<template>
+ <div class="my-4">
+ <OptionSelectorInput
+ :key="selectorKey"
+ :model-value="currentStyle"
+ name="presentation_style_switch"
+ :options="styleOptions"
+ :multiple="false"
+ :columns="2"
+ @update:modelValue="onSelectStyle"
+ >
+ <template #label>
+ <div class="flex items-center gap-0.5">
+ <span class="text-neutral-700 font-semibold text-xs">Form Style</span>
+ <UButton
+ color="neutral"
+ variant="ghost"
+ size="xs"
+ icon="i-heroicons-question-mark-circle"
+ class="text-neutral-500"
+ @click="openHelpArticle"
+ />
+ </div>
+ </template>
+ </OptionSelectorInput>
+
+ <UModal
+ v-model:open="showConfirmModal"
+ :dismissible="false"
+ :title="`Switch to ${pendingStyleLabel} style?`"
+ :description="modalDescription"
+ >
+ <template #body>
+ <div class="space-y-2" v-if="removalList.length">
+ <div
+ v-for="(item, idx) in removalList"
+ :key="idx"
+ class="flex items-center gap-2 p-2 border border-gray-200 rounded-md bg-gray-50/50"
+ >
+ <BlockTypeIcon :type="item.type" />
+ <div class="flex flex-col">
+ <span class="text-sm font-medium text-neutral-700">{{ item.name || item.title }}</span>
+ <span class="text-xs text-neutral-500">{{ item.title }}</span>
+ </div>
+ </div>
+ </div>
+ <div v-else class="text-sm text-neutral-600">No blocks will be removed.</div>
+ </template>
+ <template #footer>
+ <div class="flex justify-between w-full">
+ <UButton color="neutral" variant="outline" label="Cancel" @click="cancelSwitch" />
+ <UButton color="primary" :label="`Switch to ${pendingStyleLabel}`" @click="confirmSwitch" />
+ </div>
+ </template>
+ </UModal>
+ </div>
+
+</template>
+
+<script setup>
+import blocksTypes from '~/data/blocks_types.json'
+import BlockTypeIcon from '../BlockTypeIcon.vue'
+
+const workingFormStore = useWorkingFormStore()
+const formRef = storeToRefs(workingFormStore).content
+const crisp = useCrisp()
+
+const form = computed(() => formRef.value || {})
+const currentStyle = computed(() => form.value.presentation_style || 'classic')
+
+const styleOptions = [
+ {
+ name: 'classic',
+ label: 'Classic',
+ icon: 'opnform:form-style-classic',
+ iconClass: 'w-[91px] h-[65px] rounded shadow *:transition-colors duration-150 ease-out [--icon-fg:#737373] [--icon-muted:#D4D4D4] group-hover:[--icon-fg:#1d4ed8] group-hover:[--icon-muted:#60a5fa] group-aria-selected:[--icon-fg:#1d4ed8] group-aria-selected:[--icon-muted:#60a5fa] group-[aria-selected=true]:[--icon-fg:#1d4ed8] group-[aria-selected=true]:[--icon-muted:#60a5fa]',
+ tooltip: 'Classic form: multiple inputs per page, multi-line layout, supports multiple pages and layout blocks.'
+ },
+ {
+ name: 'focused',
+ label: 'Focused',
+ icon: 'opnform:form-style-focused',
+ iconClass: 'w-[91px] h-[65px] rounded shadow *:transition-colors duration-150 ease-out [--icon-fg:#737373] [--icon-muted:#D4D4D4] group-hover:[--icon-fg:#1d4ed8] group-hover:[--icon-muted:#60a5fa] group-aria-selected:[--icon-fg:#1d4ed8] group-aria-selected:[--icon-muted:#60a5fa] group-[aria-selected=true]:[--icon-fg:#1d4ed8] group-[aria-selected=true]:[--icon-muted:#60a5fa]',
+ tooltip: 'Typeform-like, one question per step.'
+ }
+]
+
+const showConfirmModal = ref(false)
+const removalList = ref([])
+const pendingStyle = ref(null)
+const selectorKey = ref(0)
+
+// No local selection state. Display follows the actual form style (currentStyle).
+
+const pendingStyleLabel = computed(() => pendingStyle.value === 'focused' ? 'Focused' : 'Classic')
+
+const modalDescription = computed(() => {
+ const count = removalList.value.length
+ return count > 0
+ ? `Switching to Focused will remove ${count} block${count>1?'s':''} not supported in this mode.`
+ : 'Switch to Focused style.'
+})
+
+function onSelectStyle(newVal) {
+ if (!form.value) return
+ const oldVal = currentStyle.value
+ if (newVal === oldVal) return
+
+ // Compute blocks to remove for both directions
+ const unsupportedIn = (target) => {
+ return Object.values(blocksTypes)
+ .filter(def => !(def.available_in || ['classic', 'focused']).includes(target))
+ .map(def => def.name)
+ }
+
+ const disallowedNames = new Set(unsupportedIn(newVal))
+ const props = Array.isArray(form.value.properties) ? form.value.properties : []
+ removalList.value = props
+ .filter(p => p && disallowedNames.has(p.type))
+ .map(p => ({ type: p.type, title: blocksTypes[p.type]?.title || p.type, name: p.name }))
+
+ pendingStyle.value = newVal
+
+ if (newVal === 'classic' && removalList.value.length === 0) {
+ // No removal, apply immediately
+ form.value.presentation_style = 'classic'
+ // Reset input size when returning to classic
+ form.value.size = 'md'
+ workingFormStore.closeAllSidebars()
+ return
+ }
+
+ if (newVal === 'focused' && removalList.value.length === 0) {
+ form.value.presentation_style = 'focused'
+ // Ensure large input size in focused mode
+ form.value.size = 'lg'
+ workingFormStore.closeAllSidebars()
+ return
+ }
+
+ // Show modal; do not change selection until confirm
+ showConfirmModal.value = true
+ // Force re-mount so the internal local state of OptionSelectorInput resets to props.modelValue
+ nextTick(() => { selectorKey.value++ })
+}
+
+function confirmSwitch() {
+ if (!form.value) return
+ const target = pendingStyle.value
+ const disallowedNames = new Set(
+ Object.values(blocksTypes)
+ .filter(def => !(def.available_in || ['classic', 'focused']).includes(target))
+ .map(def => def.name)
+ )
+ const props = Array.isArray(form.value.properties) ? form.value.properties : []
+ form.value.properties = props.filter(p => !(p && disallowedNames.has(p.type)))
+ form.value.presentation_style = target
+ // Ensure large input size in focused mode
+ if (target === 'focused') {
+ form.value.size = 'lg'
+ } else if (target === 'classic') {
+ // Reset input size when returning to classic
+ form.value.size = 'md'
+ }
+ workingFormStore.closeAllSidebars()
+ showConfirmModal.value = false
+ pendingStyle.value = null
+ removalList.value = []
+}
+
+function cancelSwitch() {
+ showConfirmModal.value = false
+ pendingStyle.value = null
+ removalList.value = []
+}
+
+function openHelpArticle() {
+ crisp.openHelpdeskArticle('how-to-create-a-typeformstyle-onequestionatatime-form-focused-mode-1d5r5x')
+}
+</script>
+
+
diff --git a/client/components/open/forms/components/form-components/components/AiFieldGenerator.vue b/client/components/open/forms/components/form-components/components/AiFieldGenerator.vue
index ab8fbdb59..f40b752ac 100644
--- a/client/components/open/forms/components/form-components/components/AiFieldGenerator.vue
+++ b/client/components/open/forms/components/form-components/components/AiFieldGenerator.vue
@@ -90,7 +90,11 @@ const handleGenerate = () => {
loading.value = true
aiRequestId.value = null
- formsApi.ai.generateFields(aiFields).then(data => {
+ const presentationStyle = form.value?.presentation_style || 'classic'
+ formsApi.ai.generateFields({
+ ...aiFields.data(),
+ generation_params: { presentation_style: presentationStyle }
+ }).then(data => {
aiRequestId.value = data.ai_form_completion_id
fetchGeneratedForm(data.ai_form_completion_id)
}).catch(error => {
diff --git a/client/components/open/forms/components/layouts/CenteredStep.vue b/client/components/open/forms/components/layouts/CenteredStep.vue
new file mode 100644
index 000000000..c6eebf0c5
--- /dev/null
+++ b/client/components/open/forms/components/layouts/CenteredStep.vue
@@ -0,0 +1,20 @@
+<template>
+ <div class="w-full flex items-center px-6 @2xl:px-12 grow min-h-0 z-10 relative">
+ <div v-if="background && background.url" class="absolute inset-0 -z-10 pointer-events-none">
+ <BlockMediaLayout :image="background" :fallback-height="null" />
+ </div>
+ <div class="w-full max-w-2xl mx-auto py-4">
+ <slot />
+ </div>
+ </div>
+</template>
+
+<script setup>
+import BlockMediaLayout from '../BlockMediaLayout.vue'
+
+defineProps({
+ background: { type: Object, required: false, default: null }
+})
+</script>
+
+
diff --git a/client/components/open/forms/components/layouts/SideMediaSmall.vue b/client/components/open/forms/components/layouts/SideMediaSmall.vue
new file mode 100644
index 000000000..a21fddb2b
--- /dev/null
+++ b/client/components/open/forms/components/layouts/SideMediaSmall.vue
@@ -0,0 +1,50 @@
+<template>
+ <div class="w-full flex items-center px-6 @2xl:px-12 grow min-h-0 z-10">
+ <div class="w-full max-w-6xl mx-auto flex items-stretch @3xl:items-center justify-between gap-6 @3xl:gap-8 flex-col @3xl:flex-row">
+ <!-- Content -->
+ <div
+ class="w-full max-w-2xl order-1 py-4 @2xl:px-8 @3xl:px-4 @4xl:px-8 "
+ :class="isLeft ? '@3xl:order-2' : '@3xl:order-1'"
+ >
+ <slot />
+ </div>
+
+ <!-- Media: below content on mobile; left/right on desktop -->
+ <div
+ class="w-full @3xl:max-w-1/2 order-2"
+ :class="isLeft ? '@3xl:order-1' : '@3xl:order-2'"
+ >
+ <div class="@3xl:p-4 @7xl:p-6 mb-4" :class="ui.mediaContainer()">
+ <BlockMediaLayout
+ :image="image"
+ :fallback-height="null"
+ :class="ui.mediaComponent()"
+ :img-class="ui.mediaImg()"
+ />
+ </div>
+ </div>
+ </div>
+ </div>
+</template>
+
+<script setup>
+import BlockMediaLayout from '../BlockMediaLayout.vue'
+import { tv } from 'tailwind-variants'
+import { sideMediaSmallTheme } from '~/lib/forms/themes/side-media-small.theme.js'
+
+const props = defineProps({
+ image: { type: Object, required: true },
+ side: { type: String, default: 'left' }, // 'left' | 'right'
+ borderRadius: { type: String, default: 'small' } // 'none' | 'small' | 'full'
+})
+
+const isLeft = computed(() => (props.side || 'left') === 'left')
+
+const ui = computed(() => {
+ return tv(sideMediaSmallTheme)({
+ borderRadius: props.borderRadius || 'small'
+ })
+})
+</script>
+
+
diff --git a/client/components/open/forms/components/layouts/SideMediaSplit.vue b/client/components/open/forms/components/layouts/SideMediaSplit.vue
new file mode 100644
index 000000000..f059c0cdd
--- /dev/null
+++ b/client/components/open/forms/components/layouts/SideMediaSplit.vue
@@ -0,0 +1,44 @@
+<template>
+ <div class="w-full flex z-10 flex-col @3xl:flex-row">
+ <!-- Mobile: media as background on top, content dictates scroll -->
+ <div class="relative block @3xl:hidden w-full">
+ <!-- Spacer for 50vh visual band -->
+ <div class="pt-[50vh]"></div>
+ <!-- Absolute background image so it doesn't affect layout height beyond spacer -->
+ <div class="absolute inset-0 pointer-events-none">
+ <BlockMediaLayout :image="image" :fallback-height="null" />
+ </div>
+ </div>
+
+ <!-- Desktop: media on the left -->
+ <div v-if="isLeft" class="hidden @3xl:block w-1/2 relative overflow-hidden h-screen">
+ <BlockMediaLayout :image="image" :fallback-height="null" />
+ </div>
+
+ <!-- Content -->
+ <div class="w-full @3xl:w-1/2 flex items-center px-6">
+ <div class="w-full max-w-2xl mx-auto mt-4 @3xl:mt-0 py-4 @2xl:px-8 @3xl:px-4 @4xl:px-8">
+ <slot />
+ </div>
+ </div>
+
+ <!-- Desktop: media on the right -->
+ <div v-if="!isLeft" class="hidden @3xl:block w-1/2 relative overflow-hidden h-screen">
+ <BlockMediaLayout :image="image" :fallback-height="null" />
+ </div>
+ </div>
+
+</template>
+
+<script setup>
+import BlockMediaLayout from '../BlockMediaLayout.vue'
+
+const props = defineProps({
+ image: { type: Object, required: true },
+ side: { type: String, default: 'left' } // 'left' | 'right'
+})
+
+const isLeft = computed(() => (props.side || 'left') === 'left')
+</script>
+
+
diff --git a/client/components/open/forms/components/media/BlockMediaOptions.vue b/client/components/open/forms/components/media/BlockMediaOptions.vue
new file mode 100644
index 000000000..b6870aa06
--- /dev/null
+++ b/client/components/open/forms/components/media/BlockMediaOptions.vue
@@ -0,0 +1,74 @@
+<template>
+ <div v-if="isFocusedMode" class="px-4 mt-6">
+ <EditorSectionHeader icon="i-heroicons-photo" :icon-class="headerIconClass" title="Image" />
+
+ <!-- Unified image input with settings popover (focus/brightness/alt) -->
+ <ImageWithSettings :form="model" name="image.url" label="Image" kind="block" />
+
+ <!-- Layout selection appears only when an image is present -->
+ <template v-if="model?.image && model.image.url">
+ <OptionSelectorInput
+ v-model="model.image.layout"
+ name="image.layout"
+ :form="model"
+ label="Layout"
+ :options="layoutOptions"
+ :multiple="false"
+ :columns="3"
+ />
+ </template>
+ </div>
+</template>
+
+<script setup>
+import EditorSectionHeader from '~/components/open/forms/components/form-components/EditorSectionHeader.vue'
+import ImageWithSettings from './ImageWithSettings.vue'
+
+const props = defineProps({
+ model: { type: Object, required: true },
+ form: { type: Object, required: false }
+})
+
+const isFocusedMode = computed(() => (props.form?.presentation_style || 'classic') === 'focused')
+
+const isEmpty = computed(() => !props.model?.image || !props.model.image?.url)
+const headerIconClass = computed(() => isEmpty.value ? 'text-blue-500! animate-pulse' : '')
+
+// DRY icon classes
+const iconBaseClass = 'w-[70px] h-[50px] rounded transition-colors duration-150 ease-out [--icon-fg:#737373] [--icon-muted:#D4D4D4] group-hover:[--icon-fg:#3b82f6] group-hover:[--icon-muted:#60a5fa] text-neutral-500 group-hover:text-blue-500 group-aria-selected:[--icon-fg:#3b82f6] group-aria-selected:[--icon-muted:#60a5fa] group-[aria-selected=true]:[--icon-fg:#3b82f6] group-[aria-selected=true]:[--icon-muted:#60a5fa] group-aria-selected:text-blue-500 group-[aria-selected=true]:text-blue-500'
+const iconSelectedClass = '[--icon-fg:#3b82f6] [--icon-muted:#60a5fa] text-blue-500'
+
+const layoutOptions = [
+ { name: 'between', icon: 'opnform:form-layout-between', iconClass: iconBaseClass, iconSelectedClass },
+ { name: 'left-small', icon: 'opnform:form-layout-left-small', iconClass: iconBaseClass, iconSelectedClass },
+ { name: 'left-split', icon: 'opnform:form-layout-left-split', iconClass: iconBaseClass, iconSelectedClass },
+ { name: 'background', icon: 'opnform:form-layout-background', iconClass: iconBaseClass, iconSelectedClass },
+ { name: 'right-small', icon: 'opnform:form-layout-right-small', iconClass: iconBaseClass, iconSelectedClass },
+ { name: 'right-split', icon: 'opnform:form-layout-right-split', iconClass: iconBaseClass, iconSelectedClass },
+]
+
+function setDefaultImageSettings() {
+ if (!props.model.image) props.model.image = {}
+ props.model.image.layout = props.model.image.layout ?? 'between'
+ props.model.image.focal_point = props.model.image.focal_point ?? { x: 50, y: 50 }
+ props.model.image.brightness = typeof props.model.image.brightness === 'number' ? props.model.image.brightness : 0
+}
+
+function clearImageSettings() {
+ if (!props.model.image) return
+ props.model.image.alt = null
+ props.model.image.layout = null
+ props.model.image.focal_point = null
+ props.model.image.brightness = 0
+}
+
+watch(() => props.model?.image?.url, (val) => {
+ if (val) {
+ setDefaultImageSettings()
+ } else {
+ clearImageSettings()
+ }
+})
+</script>
+
+
diff --git a/client/components/open/forms/components/media/FocalPointPicker.vue b/client/components/open/forms/components/media/FocalPointPicker.vue
new file mode 100644
index 000000000..25cea63e1
--- /dev/null
+++ b/client/components/open/forms/components/media/FocalPointPicker.vue
@@ -0,0 +1,97 @@
+<template>
+ <input-wrapper v-bind="inputWrapperProps">
+ <template #label>
+ <slot name="label" />
+ </template>
+
+ <div
+ ref="container"
+ class="relative inline-block overflow-hidden rounded-md border select-none"
+ @mousedown.prevent="startDrag"
+ @touchstart.prevent="startDrag"
+ @mousemove.prevent="onMoveIfDragging"
+ @touchmove.prevent="onTouchMove"
+ @mouseup.prevent="endDrag"
+ @mouseleave="endDrag"
+ @touchend.prevent="endDrag"
+ @click.prevent="onClickSet"
+ >
+ <img :src="src" class="block max-w-full h-auto select-none" draggable="false" @dragstart.prevent />
+ <button
+ class="absolute -translate-x-1/2 -translate-y-1/2 w-6 h-6 rounded-full border-2 border-white bg-neutral-700/80 shadow"
+ :style="{ left: x + '%', top: y + '%' }"
+ aria-label="Focal point"
+ />
+ </div>
+
+ <template #help>
+ <slot name="help" />
+ </template>
+ <template #error>
+ <slot name="error" />
+ </template>
+ </input-wrapper>
+</template>
+
+<script setup>
+import InputWrapper from '~/components/forms/core/components/InputWrapper.vue'
+import { inputProps, useFormInput } from '~/components/forms/useFormInput.js'
+
+const props = defineProps({
+ ...inputProps,
+ modelValue: { type: Object, default: () => ({ x: 50, y: 50 }) },
+ src: { type: String, required: true }
+})
+const emit = defineEmits(['update:modelValue', 'focus', 'blur'])
+
+const { compVal, inputWrapperProps } = useFormInput(props, { emit })
+
+const container = ref(null)
+
+const safePoint = (val, _axis = 'x') => {
+ const num = typeof val === 'number' ? val : 50
+ return Math.max(0, Math.min(100, num))
+}
+
+const x = computed(() => safePoint((compVal.value && compVal.value.x) ?? props.modelValue?.x))
+const y = computed(() => safePoint((compVal.value && compVal.value.y) ?? props.modelValue?.y, 'y'))
+
+let dragging = false
+
+function setFromEvent(e) {
+ const root = container.value
+ if (!root) return
+ const img = root.querySelector('img')
+ if (!img) return
+ const rect = img.getBoundingClientRect()
+ const clientX = e.touches ? e.touches[0].clientX : e.clientX
+ const clientY = e.touches ? e.touches[0].clientY : e.clientY
+ const nx = ((clientX - rect.left) / rect.width) * 100
+ const ny = ((clientY - rect.top) / rect.height) * 100
+ compVal.value = { x: safePoint(nx), y: safePoint(ny, 'y') }
+}
+
+function onMoveIfDragging(e) {
+ if (!dragging) return
+ setFromEvent(e)
+}
+
+function onTouchMove(e) {
+ if (!dragging) return
+ setFromEvent(e)
+}
+
+function startDrag(_e) {
+ dragging = true
+}
+
+function endDrag() {
+ dragging = false
+}
+
+function onClickSet(e) {
+ setFromEvent(e)
+}
+</script>
+
+
diff --git a/client/components/open/forms/components/media/ImageWithSettings.vue b/client/components/open/forms/components/media/ImageWithSettings.vue
new file mode 100644
index 000000000..bfed50cba
--- /dev/null
+++ b/client/components/open/forms/components/media/ImageWithSettings.vue
@@ -0,0 +1,167 @@
+<template>
+ <image-input
+ :form="form"
+ :name="name"
+ :label="label"
+ :required="false"
+ >
+ <template #left-action>
+ <UPopover
+ v-if="hasImage"
+ arrow
+ :content="{ side: 'bottom', align: 'start' }"
+ >
+ <button
+ class="text-neutral-500 hover:text-neutral-700 flex items-center mr-2"
+ type="button"
+ :aria-label="settingsAriaLabel"
+ @click.stop
+ >
+ <Icon name="heroicons:cog-6-tooth" class="h-5 w-5" />
+ </button>
+
+ <template #content>
+ <div class="p-3 w-80">
+ <FocalPointPicker :name="focalName" :label="focalLabel" v-model="focalPointModel" :src="imageUrl" />
+
+ <div class="mt-4">
+ <SliderInput
+ v-model="brightnessModel"
+ :name="brightnessName"
+ :form="form"
+ :min-slider="-100"
+ :max-slider="100"
+ :step-slider="1"
+ :label="brightnessLabel"
+ />
+ </div>
+
+ <div v-if="showAlt" class="mt-4">
+ <text-input
+ :form="form"
+ :name="altName"
+ label="Alt text"
+ placeholder="Describe the image for accessibility (max 125 characters)"
+ :max-char-limit="125"
+ :show-char-limit="true"
+ />
+ </div>
+ </div>
+ </template>
+ </UPopover>
+ </template>
+ </image-input>
+</template>
+
+<script setup>
+import FocalPointPicker from './FocalPointPicker.vue'
+import SliderInput from '~/components/forms/core/SliderInput.vue'
+
+const props = defineProps({
+ // The vForm object to bind ImageInput and text-input/slider to
+ form: { type: Object, required: true },
+ // The field path for the ImageInput (e.g. 'cover_picture' or 'image.url')
+ name: { type: String, required: true },
+ // UI label for the ImageInput
+ label: { type: String, required: true },
+ // Kind controls default paths for settings handling
+ kind: { type: String, default: 'block' } // 'block' | 'cover'
+})
+
+const settingsAriaLabel = computed(() => props.kind === 'cover' ? 'Cover image settings' : 'Image settings')
+const focalLabel = computed(() => 'Focal point')
+const brightnessLabel = computed(() => 'Brightness')
+
+// Derived paths based on kind
+const showAlt = computed(() => props.kind === 'block')
+const altName = computed(() => props.kind === 'block' ? 'image.alt' : null)
+const brightnessName = computed(() => props.kind === 'block' ? 'image.brightness' : 'cover_picture_brightness')
+const focalName = computed(() => props.kind === 'cover' ? 'cover_focal_point' : 'image.focal_point')
+
+// Resolve current image URL from form + name path (simple cases only)
+const imageUrl = computed(() => {
+ try {
+ if (!props.form || !props.name) return null
+ const parts = props.name.split('.')
+ let ref = props.form
+ for (const p of parts) {
+ ref = ref && ref[p]
+ }
+ return ref || null
+ } catch {
+ return null
+ }
+})
+
+const hasImage = computed(() => !!imageUrl.value)
+
+// Focal point mapping
+const focalPointModel = computed({
+ get() {
+ if (props.kind === 'cover') {
+ const s = props.form?.cover_settings || {}
+ return s.focal_point ?? { x: 50, y: 50 }
+ } else {
+ const img = props.form?.image || {}
+ return img.focal_point ?? { x: 50, y: 50 }
+ }
+ },
+ set(val) {
+ if (props.kind === 'cover') {
+ const base = props.form?.cover_settings ? { ...props.form.cover_settings } : {}
+ base.focal_point = val
+ props.form.cover_settings = base
+ } else {
+ if (!props.form.image) props.form.image = {}
+ props.form.image.focal_point = val
+ }
+ }
+})
+
+// Brightness mapping
+const brightnessModel = computed({
+ get() {
+ if (props.kind === 'cover') {
+ const s = props.form?.cover_settings
+ return (s && typeof s.brightness === 'number') ? s.brightness : 0
+ } else {
+ const img = props.form?.image
+ return (img && typeof img.brightness === 'number') ? img.brightness : 0
+ }
+ },
+ set(val) {
+ const num = typeof val === 'number' ? val : 0
+ if (props.kind === 'cover') {
+ const base = props.form?.cover_settings ? { ...props.form.cover_settings } : {}
+ base.brightness = num
+ props.form.cover_settings = base
+ } else {
+ if (!props.form.image) props.form.image = {}
+ props.form.image.brightness = num
+ }
+ }
+})
+
+watch(imageUrl, (val) => {
+ // Reset settings when image cleared
+ if (!val) {
+ if (props.kind === 'cover') {
+ props.form.cover_settings = {}
+ } else if (props.form?.image) {
+ props.form.image.alt = null
+ props.form.image.layout = null
+ props.form.image.focal_point = null
+ props.form.image.brightness = 0
+ }
+ } else {
+ // Ensure defaults exist when an image is set
+ if (props.kind !== 'cover') {
+ if (!props.form.image) props.form.image = {}
+ props.form.image.focal_point = props.form.image.focal_point ?? { x: 50, y: 50 }
+ props.form.image.brightness = typeof props.form.image.brightness === 'number' ? props.form.image.brightness : 0
+ }
+ }
+})
+</script>
+
+
diff --git a/client/components/open/forms/fields/FormFieldEdit.vue b/client/components/open/forms/fields/FormFieldEdit.vue
index fe1e3d180..06a3c22c1 100644
--- a/client/components/open/forms/fields/FormFieldEdit.vue
+++ b/client/components/open/forms/fields/FormFieldEdit.vue
@@ -1,5 +1,8 @@
<template>
- <div>
+ <div
+ :class="{ 'sidebar-bounce': sidebarBounce }"
+ class="sidebar-container"
+ >
<div class="p-2 border-b sticky top-0 z-20 bg-white">
<UButton
v-if="!field"
@@ -96,17 +99,15 @@
<script setup>
import { storeToRefs } from 'pinia'
-import clonedeep from 'clone-deep'
import FieldOptions from './components/FieldOptions.vue'
import BlockOptions from './components/BlockOptions.vue'
import BlockTypeIcon from '../components/BlockTypeIcon.vue'
import blocksTypes from '~/data/blocks_types.json'
import FormBlockLogicEditor from '../components/form-logic-components/FormBlockLogicEditor.vue'
import CustomFieldValidation from '../components/CustomFieldValidation.vue'
-import { generateUUID } from '~/lib/utils'
const workingFormStore = useWorkingFormStore()
-const { content: form } = storeToRefs(workingFormStore)
+const { content: form, sidebarBounce } = storeToRefs(workingFormStore)
const selectedFieldIndex = computed(() => workingFormStore.selectedFieldIndex)
@@ -222,14 +223,7 @@ const dropdownItems = computed(() => {
label: 'Duplicate',
icon: 'i-heroicons-document-duplicate-20-solid',
kbds: ['meta', 'd'],
- onClick: () => {
- const newField = clonedeep(field.value)
- newField.id = generateUUID()
- newField.name = 'Copy of ' + newField.name
- const newFields = [...form.value.properties]
- newFields.splice(selectedFieldIndex.value + 1, 0, newField)
- form.value.properties = newFields
- }
+ onClick: () => workingFormStore.duplicateField(field.value)
}]
]
@@ -276,3 +270,37 @@ const tabItems = computed(() => {
})
</script>
+
+<style scoped>
+.sidebar-container {
+ transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
+}
+
+.sidebar-bounce {
+ animation: bounce-left 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
+}
+
+@keyframes bounce-left {
+ 0% {
+ transform: translateX(0);
+ }
+ 20% {
+ transform: translateX(-6px);
+ }
+ 40% {
+ transform: translateX(0);
+ }
+ 60% {
+ transform: translateX(-3px);
+ }
+ 80% {
+ transform: translateX(0);
+ }
+ 90% {
+ transform: translateX(-1px);
+ }
+ 100% {
+ transform: translateX(0);
+ }
+}
+</style>
diff --git a/client/components/open/forms/fields/components/BlockOptions.vue b/client/components/open/forms/fields/components/BlockOptions.vue
index 6b2547d00..7d8d42311 100644
--- a/client/components/open/forms/fields/components/BlockOptions.vue
+++ b/client/components/open/forms/fields/components/BlockOptions.vue
@@ -27,6 +27,7 @@
:form="field"
label="Block Width"
seamless
+ v-if="!isFocused"
:options="[
{ name: 'full', label: 'Full' },
{ name: '1/2', label: '1/2' },
@@ -57,6 +58,11 @@
/>
</div>
+ <!-- Focused Mode: Media settings (high priority under general) -->
+ <div v-if="isFocused && field.type==='nf-text'" class="mt-2">
+ <BlockMediaOptions :model="field" :form="form" />
+ </div>
+
<div
v-if="field.type == 'nf-text'"
class="border-t mt-4"
@@ -117,10 +123,13 @@
/>
</div>
</div>
+
+ <!-- (moved above for focused mode) -->
</template>
<script setup>
import HiddenRequiredDisabled from './HiddenRequiredDisabled.vue'
+import BlockMediaOptions from '~/components/open/forms/components/media/BlockMediaOptions.vue'
const props = defineProps({
field: {
@@ -133,6 +142,8 @@ const props = defineProps({
}
})
+const isFocused = computed(() => props.form?.presentation_style === 'focused')
+
watch(() => props.field?.width, (val) => {
if (val === undefined || val === null) {
props.field.width = 'full'
diff --git a/client/components/open/forms/fields/components/FieldOptions.vue b/client/components/open/forms/fields/components/FieldOptions.vue
index a5105b57e..5f0035cc2 100644
--- a/client/components/open/forms/fields/components/FieldOptions.vue
+++ b/client/components/open/forms/fields/components/FieldOptions.vue
@@ -19,6 +19,11 @@
/>
</div>
+ <!-- Focused Mode: Media settings (high priority under general) -->
+ <div v-if="isFocused" class="mt-2">
+ <BlockMediaOptions :model="field" :form="form" />
+ </div>
+
<!-- Checkbox -->
<div
v-if="field.type === 'checkbox'"
@@ -571,6 +576,7 @@
:form="field"
label="Block Width"
seamless
+ v-if="!isFocused"
:options="[
{ name: 'full', label: 'Full' },
{ name: '1/2', label: '1/2' },
@@ -674,6 +680,8 @@
@update:model-value="onFieldGenAutoIdChange"
/>
</div>
+
+ <!-- (moved above for focused mode) -->
</div>
</template>
@@ -689,10 +697,11 @@ import ProTag from '~/components/app/ProTag.vue'
import { format } from 'date-fns'
import { default as _has } from 'lodash/has'
import blocksTypes from '~/data/blocks_types.json'
+import BlockMediaOptions from '~/components/open/forms/components/media/BlockMediaOptions.vue'
export default {
name: 'FieldOptions',
- components: { CountryFlag, MatrixFieldOptions, HiddenRequiredDisabled, EditorSectionHeader, PaymentFieldOptions, ProTag },
+ components: { CountryFlag, MatrixFieldOptions, HiddenRequiredDisabled, EditorSectionHeader, PaymentFieldOptions, ProTag, BlockMediaOptions },
props: {
field: {
type: Object,
@@ -724,6 +733,9 @@ export default {
},
computed: {
+ isFocused() {
+ return this.form?.presentation_style === 'focused'
+ },
hasPlaceholder() {
return !this.typesWithoutPlaceholder.includes(this.field.type)
},
diff --git a/client/components/pages/forms/create/CreateFormBaseModal.vue b/client/components/pages/forms/create/CreateFormBaseModal.vue
index cd760061a..7b9eebab6 100644
--- a/client/components/pages/forms/create/CreateFormBaseModal.vue
+++ b/client/components/pages/forms/create/CreateFormBaseModal.vue
@@ -1,122 +1,199 @@
<template>
<UModal
v-model:open="isOpen"
- :ui="{ content: state === 'default' ? 'sm:max-w-3xl' : 'sm:max-w-2xl' }"
- :title="state === 'default' ? 'Choose a base for your form' : 'AI-powered form generator'"
+ :ui="{ content: 'sm:max-w-3xl' }"
:dismissible="!aiForm.busy"
>
- <template #body>
- <div
- v-if="state === 'default'"
- class="grid grid-cols-1 sm:grid-cols-3 gap-4"
- >
- <TrackClick
- name="select_form_base"
- :properties="{ base: 'contact-form' }"
+ <template #content>
+ <div class="overflow-hidden p-6">
+ <SlidingTransition
+ :style="transitionContainerStyle"
+ direction="horizontal"
+ :step="currentStep"
+ :speed="transitionDurationMs"
>
<div
- role="button"
- class="rounded-md border p-6 flex flex-col items-center cursor-pointer hover:bg-neutral-50"
- @click="$emit('close')"
+ :key="currentStep"
+ class="w-full"
>
- <div class="p-4">
- <UIcon
- name="i-heroicons-envelope"
- class="w-8 h-8 text-blue-500"
- />
- </div>
- <p class="font-medium">
- Simple contact form
- </p>
- </div>
- </TrackClick>
- <TrackClick
- v-if="useFeatureFlag('ai_features')"
- name="select_form_base"
- :properties="{ base: 'ai' }"
- >
- <div
- class="rounded-md border p-6 flex flex-col items-center cursor-pointer hover:bg-neutral-50"
- role="button"
- @click="state = 'ai'"
- >
- <div class="p-4">
- <UIcon
- name="i-heroicons-bolt"
- class="w-8 h-8 text-blue-500"
- />
- </div>
- <p class="font-medium text-blue-700">
- AI Form Generator
- </p>
- </div>
- </TrackClick>
- <div
- class="rounded-md border p-6 flex flex-col items-center cursor-pointer hover:bg-neutral-50 relative"
- >
- <div class="p-4">
- <UIcon
- name="i-heroicons-squares-2x2"
- class="w-8 h-8 text-blue-500"
- />
+ <!-- Step 1: Choose style -->
+ <div
+ v-if="currentStep === 1"
+ key="step1"
+ class="px-2"
+ ref="step1Ref"
+ >
+ <div class="text-center mb-4">
+ <h2 class="text-xl font-bold text-slate-800">Choose a form style</h2>
+ <p class="text-slate-500 text-sm">Choose how your form appears to respondents.</p>
+ </div>
+ <div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
+ <div
+ role="button"
+ class="group rounded-md border p-6 flex flex-col items-center cursor-pointer hover:bg-neutral-50"
+ @click="selectStyle('classic')"
+ >
+ <div class="p-4">
+ <Icon
+ name="opnform:form-style-classic"
+ mode="svg"
+ class="w-[140px] h-[100px] rounded-md shadow **:transition-colors duration-100 ease-out [--icon-fg:#737373] [--icon-muted:#D4D4D4] group-hover:[--icon-fg:#2563eb] group-hover:[--icon-muted:#93c5fd]"
+ />
+ </div>
+ <p class="font-medium">Classic</p>
+ <p class="text-xs text-neutral-500 text-center mt-1">Multiple inputs per page; supports layout blocks and multi-page flows.</p>
+ </div>
+ <div
+ role="button"
+ class="group rounded-md border p-6 flex flex-col items-center cursor-pointer hover:bg-neutral-50"
+ @click="selectStyle('focused')"
+ >
+ <div class="p-4">
+ <Icon
+ name="opnform:form-style-focused"
+ mode="svg"
+ class="w-[140px] h-[100px] rounded-md shadow **:transition-colors duration-100 ease-out [--icon-fg:#737373] [--icon-muted:#D4D4D4] group-hover:[--icon-fg:#2563eb] group-hover:[--icon-muted:#93c5fd]"
+ />
+ </div>
+ <p class="font-medium">Focused</p>
+ <p class="text-xs text-neutral-500 text-center mt-1">Typeform-style: one question per step for a streamlined flow.</p>
+ </div>
+ </div>
+ </div>
+
+ <!-- Step 2: Choose base -->
+ <div
+ v-else-if="currentStep === 2"
+ key="step2"
+ class="px-2"
+ ref="step1Ref"
+ >
+ <div class="text-center mb-4">
+ <h2 class="text-xl font-bold text-slate-800">Choose a base for your form</h2>
+ </div>
+ <div class="flex gap-2 mb-2">
+ <UButton
+ variant="ghost"
+ color="neutral"
+ icon="i-heroicons-arrow-left"
+ @click="goBackToStep1"
+ label="Back to styles"
+ />
+ </div>
+ <div class="grid grid-cols-1 sm:grid-cols-3 gap-4">
+ <TrackClick name="select_form_base" :properties="{ base: 'contact-form' }">
+ <div
+ role="button"
+ class="rounded-md border p-6 flex flex-col items-center cursor-pointer hover:bg-neutral-50"
+ @click="$emit('close')"
+ >
+ <div class="p-4">
+ <UIcon
+ name="i-heroicons-envelope"
+ class="w-8 h-8 text-blue-500"
+ />
+ </div>
+ <p class="font-medium">
+ Simple contact form
+ </p>
+ </div>
+ </TrackClick>
+ <TrackClick v-if="useFeatureFlag('ai_features')" name="select_form_base" :properties="{ base: 'ai' }">
+ <div
+ class="rounded-md border p-6 flex flex-col items-center cursor-pointer hover:bg-neutral-50"
+ role="button"
+ @click="currentStep = 3"
+ >
+ <div class="p-4">
+ <UIcon
+ name="i-heroicons-bolt"
+ class="w-8 h-8 text-blue-500"
+ />
+ </div>
+ <p class="font-medium text-blue-700">
+ AI Form Generator
+ </p>
+ </div>
+ </TrackClick>
+ <div
+ class="rounded-md border p-6 flex flex-col items-center cursor-pointer hover:bg-neutral-50 relative"
+ >
+ <div class="p-4">
+ <UIcon
+ name="i-heroicons-squares-2x2"
+ class="w-8 h-8 text-blue-500"
+ />
+ </div>
+ <p class="font-medium">
+ Browse templates <Icon name="heroicons:arrow-top-right-on-square-20-solid" class="w-3 h-3 text-neutral-500" />
+ </p>
+ <TrackClick name="select_form_base" :properties="{ base: 'template' }">
+ <NuxtLink
+ :to="{ name: 'templates' }"
+ class="absolute inset-0"
+ />
+ </TrackClick>
+ </div>
+ </div>
+ </div>
+
+ <!-- Step 3: AI generation -->
+ <div
+ v-else-if="currentStep === 3"
+ key="step3"
+ class="px-2"
+ ref="step1Ref"
+ >
+ <div class="text-center mb-4">
+ <h2 class="text-xl font-bold text-slate-800">AI-powered form generator</h2>
+ </div>
+ <text-area-input
+ label="Form Description"
+ :disabled="loading ? true : null"
+ :form="aiForm"
+ name="form_prompt"
+ help="Give us a description of the form you want to build (the more details the better)"
+ placeholder="A simple contact form, with a name, email and message field"
+ />
+ <UButton
+ class="mt-4"
+ block
+ :loading="loading"
+ @click="generateForm"
+ label="Generate a form"
+ />
+ <p class="text-neutral-500 text-xs text-center mt-1">
+ ~30 sec
+ </p>
+ <div
+ v-if="loading"
+ class="my-4"
+ >
+ <AIFormLoadingMessages />
+ </div>
+ <div class="flex gap-2 mt-4">
+ <UButton
+ variant="ghost"
+ color="neutral"
+ icon="i-heroicons-arrow-left"
+ @click="currentStep = 2"
+ label="Back to form types"
+ />
+ </div>
+ </div>
</div>
- <p class="font-medium">
- Browse templates <Icon name="heroicons:arrow-top-right-on-square-20-solid" class="w-3 h-3 text-neutral-500" />
- </p>
- <TrackClick
- name="select_form_base"
- :properties="{ base: 'template' }"
- >
- <NuxtLink
- :to="{ name: 'templates' }"
- class="absolute inset-0"
- />
- </TrackClick>
- </div>
- </div>
- <div v-else-if="state === 'ai'">
- <text-area-input
- label="Form Description"
- :disabled="loading ? true : null"
- :form="aiForm"
- name="form_prompt"
- help="Give us a description of the form you want to build (the more details the better)"
- placeholder="A simple contact form, with a name, email and message field"
- />
- <UButton
- class="mt-4"
- block
- :loading="loading"
- @click="generateForm"
- label="Generate a form"
- />
- <p class="text-neutral-500 text-xs text-center mt-1">
- ~30 sec
- </p>
- <div
- v-if="loading"
- class="my-4"
- >
- <AIFormLoadingMessages />
- </div>
- <div class="flex gap-2 mt-4">
- <UButton
- variant="ghost"
- color="neutral"
- icon="i-heroicons-arrow-left"
- @click="state = 'default'"
- label="Back to form types"
- />
- </div>
+ </SlidingTransition>
</div>
</template>
</UModal>
</template>
<script setup>
+import SlidingTransition from '~/components/global/transitions/SlidingTransition.vue'
import AIFormLoadingMessages from "~/components/open/forms/components/AIFormLoadingMessages.vue"
import { formsApi } from "~/api/forms"
-import TrackClick from "~/components/global/TrackClick.vue"
+import { useElementSize } from '@vueuse/core'
+import TrackClick from '~/components/global/TrackClick.vue'
const props = defineProps({
show: { type: Boolean, required: true },
@@ -136,18 +213,72 @@ const isOpen = computed({
}
})
-const state = ref("default")
+// Steps: 1) style, 2) base, 3) ai
+const currentStep = ref(1)
+const selectedStyle = ref('classic')
+
const aiForm = useForm({
form_prompt: "",
})
const loading = ref(false)
+const transitionDurationMs = 300
+const step1Ref = ref(null)
+const { height: step1Height } = useElementSize(step1Ref)
+const cachedStep1Height = ref(0)
+watchEffect(() => {
+ if (step1Height?.value) {
+ cachedStep1Height.value = step1Height.value
+ }
+})
+const transitionContainerStyle = computed(() => {
+ const h = cachedStep1Height.value
+ return h ? { height: h + 'px' } : {}
+})
+
+watch(() => props.show, (open) => {
+ if (open) {
+ currentStep.value = 1
+ selectedStyle.value = 'classic'
+ }
+})
+
+function selectStyle(style) {
+ selectedStyle.value = style
+ // Apply immediately to working form
+ const workingFormStore = useWorkingFormStore()
+ if (workingFormStore?.content) {
+ workingFormStore.content.presentation_style = style
+ if (style === 'focused') {
+ workingFormStore.content.size = 'lg'
+ // Ensure navigation arrows are enabled by default in focused mode
+ if (!workingFormStore.content.settings) {
+ workingFormStore.content.settings = {}
+ }
+ if (workingFormStore.content.settings.navigation_arrows === undefined) {
+ workingFormStore.content.settings.navigation_arrows = true
+ }
+ }
+ // Close any open sidebars since layout may change
+ workingFormStore.closeAllSidebars()
+ }
+ currentStep.value = 2
+}
+
+function goBackToStep1() {
+ currentStep.value = 1
+}
+
const generateForm = () => {
if (loading.value) return
loading.value = true
aiForm
- .post("/forms/ai/generate")
+ .post("/forms/ai/generate", {
+ body: {
+ generation_params: { presentation_style: selectedStyle.value }
+ }
+ })
.then((response) => {
useAlert().success(response.message)
fetchGeneratedForm(response.ai_form_completion_id)
@@ -155,7 +286,7 @@ const generateForm = () => {
.catch((error) => {
console.error(error)
loading.value = false
- state.value = "ai"
+ currentStep.value = 3
})
}
@@ -173,7 +304,7 @@ const fetchGeneratedForm = (generationId) => {
emit("close")
} else if (data.ai_form_completion.status === "failed") {
useAlert().error("Something went wrong, please try again.")
- state.value = "default"
+ currentStep.value = 2
loading.value = false
} else {
fetchGeneratedForm(generationId)
@@ -183,7 +314,7 @@ const fetchGeneratedForm = (generationId) => {
if (error?.data?.message) {
useAlert().error(error.data.message)
}
- state.value = "default"
+ currentStep.value = 2
loading.value = false
})
}, 4000)
diff --git a/client/components/pages/forms/show/EmbedCode.vue b/client/components/pages/forms/show/EmbedCode.vue
index 10e00545d..301e57378 100644
--- a/client/components/pages/forms/show/EmbedCode.vue
+++ b/client/components/pages/forms/show/EmbedCode.vue
@@ -27,14 +27,21 @@ export default {
computed: {
embedCode() {
// eslint-disable no-useless-escape
- return `${this.iframeCode}<script type="text/javascript" onload="initEmbed('${this.form.slug}')" src="${appUrl("/widgets/iframe.min.js")}"><\/script>`
+ const isFocused = this.form?.presentation_style === 'focused'
+ return isFocused
+ ? this.iframeCode
+ : `${this.iframeCode}<script type="text/javascript" onload="initEmbed('${this.form.slug}')" src="${appUrl("/widgets/iframe.min.js")}"><\/script>`
},
iframeCode() {
const share_url = this.extraQueryParam
? this.form.share_url + "?" + this.extraQueryParam
: this.form.share_url + this.extraQueryParam
+ const isFocused = this.form?.presentation_style === 'focused'
+ const style = isFocused
+ ? 'border:none;width:100%;height:700px;max-height:90vh;'
+ : 'border:none;width:100%;'
return (
- '<iframe style="border:none;width:100%;" id="' + this.form.slug + '" src="' + share_url + '"></iframe>'
+ '<iframe style="' + style + '" id="' + this.form.slug + '" src="' + share_url + '"></iframe>'
)
}
},
diff --git a/client/components/pages/forms/show/EmbedFormAsPopupModal.vue b/client/components/pages/forms/show/EmbedFormAsPopupModal.vue
index ff65993ea..3289fcd2f 100644
--- a/client/components/pages/forms/show/EmbedFormAsPopupModal.vue
+++ b/client/components/pages/forms/show/EmbedFormAsPopupModal.vue
@@ -11,7 +11,7 @@
variant="outline"
color="neutral"
icon="i-heroicons-chat-bubble-bottom-center-text"
- @click="showEmbedFormAsPopupModal = true"
+ @click="onOpenClick"
>
Embed as popup
</UButton>
@@ -165,6 +165,14 @@ const onClose = () => {
crisp.showChat()
showEmbedFormAsPopupModal.value = false
}
+const onOpenClick = () => {
+ const style = props.form?.presentation_style || 'classic'
+ if (style === 'focused') {
+ useAlert().warning('Popup mode is not currently supported for forms in Focused mode.')
+ return
+ }
+ showEmbedFormAsPopupModal.value = true
+}
const copyToClipboard = () => {
if (import.meta.server) return
copy(embedPopupCode.value)
diff --git a/client/components/pages/forms/show/PoweredBy.vue b/client/components/pages/forms/show/PoweredBy.vue
index d44c8692f..bc1f32183 100644
--- a/client/components/pages/forms/show/PoweredBy.vue
+++ b/client/components/pages/forms/show/PoweredBy.vue
@@ -4,8 +4,9 @@
color="form"
:label="props.label"
trailing-icon="i-heroicons-arrow-up-right-20-solid"
- class="fixed bottom-4 right-4 hover:no-underline powered-by-button"
+ class="hover:no-underline hover:shadow-lg hover:scale-105 transition-all powered-by-button"
:class="textColorClass"
+ size="sm"
target="_blank"
/>
</template>
@@ -59,3 +60,9 @@ const textColorClass = computed(() => {
return 'text-white hover:text-white'
})
</script>
+
+<style>
+.powered-by-button, .powered-by-button span {
+ font-family: Inter, sans-serif !important;
+}
+</style>
diff --git a/client/components/pages/pricing/SubscriptionModal.vue b/client/components/pages/pricing/SubscriptionModal.vue
index ea71464e8..df9c710dd 100644
--- a/client/components/pages/pricing/SubscriptionModal.vue
+++ b/client/components/pages/pricing/SubscriptionModal.vue
@@ -8,8 +8,10 @@
<template #body>
<div class="overflow-hidden">
<SlidingTransition
+ :style="transitionContainerStyle"
direction="horizontal"
:step="currentStep"
+ :speed="transitionDurationMs"
>
<div
:key="currentStep"
@@ -19,6 +21,7 @@
v-if="currentStep === 1"
key="step1"
class="flex flex-col items-center px-4 rounded-2xl relative"
+ ref="step1Ref"
>
<main class="flex flex-col mt-4 max-w-full text-center w-[591px] max-md:mt-10">
<img
@@ -233,7 +236,7 @@
OpnForm - {{ currentPlan == 'default' ? 'Pro' : 'Team' }} plan
</p>
<UBadge
- :color="isYearly?'green':'amber'"
+ :color="isYearly?'success':'warning'"
variant="subtle"
>
{{ !isYearly ? 'No Discount' : 'Discount Applied' }}
@@ -297,6 +300,7 @@
>
<TrackClick
name="upgrade_modal_confirm_submit"
+ class="grow flex"
:properties="{plan: currentPlan.value, period: isYearly?'yearly':'monthly'}"
>
<UButton
@@ -340,6 +344,8 @@ import TrackClick from '~/components/global/TrackClick.vue'
import { useCheckoutUrl } from '@/composables/components/stripe/useCheckoutUrl'
import { authApi } from '~/api'
+import { computed, watchEffect } from 'vue'
+import { useElementSize } from '@vueuse/core'
const props = defineProps({
modelValue: {
@@ -396,6 +402,21 @@ const { data: user } = useAuth().user()
const isSubscribed = computed(() => user.value.is_pro)
const currency = 'usd'
+const transitionDurationMs = 300
+// Measure Step 1 height and apply as fixed height to the container
+const step1Ref = ref(null)
+const { height: step1Height } = useElementSize(step1Ref)
+const cachedStep1Height = ref(0)
+watchEffect(() => {
+ if (step1Height?.value) {
+ cachedStep1Height.value = step1Height.value
+ }
+})
+const transitionContainerStyle = computed(() => {
+ const h = cachedStep1Height.value
+ return h ? { height: h + 'px' } : {}
+})
+
const checkoutUrl = useCheckoutUrl(
computed(() => form.name),
computed(() => form.email),
@@ -418,8 +439,8 @@ watch(() => props.modelValue, () => {
}
isYearly.value = props.yearly
shouldShowUpsell.value = !isYearly.value
- currentStep.value = 2
currentPlan.value = props.plan
+ currentStep.value = 2
}
}
})
diff --git a/client/composables/forms/initForm.js b/client/composables/forms/initForm.js
index 6b69d6b9d..80c86da23 100644
--- a/client/composables/forms/initForm.js
+++ b/client/composables/forms/initForm.js
@@ -4,12 +4,13 @@ export const DEFAULT_COLOR = '#3B82F6'
export const initForm = (defaultValue = {}, withDefaultProperties = false) => {
return useForm({
- title: "My Form",
+ title: "Contact Form",
visibility: "public",
workspace_id: null,
properties: withDefaultProperties ? getDefaultProperties() : [],
// Customization
+ presentation_style: 'classic',
language: 'en',
font_family: null,
theme: "default",
@@ -56,7 +57,7 @@ function getDefaultProperties() {
return [
{
type: "nf-text",
- content: "<h1>My Form</h1>",
+ content: "<h1>Contact Form</h1><p>Please fill out this form to contact us.</p>",
name: "Title",
id: generateUUID(),
},
diff --git a/client/composables/forms/useFormImagePreloader.js b/client/composables/forms/useFormImagePreloader.js
new file mode 100644
index 000000000..993f5fa85
--- /dev/null
+++ b/client/composables/forms/useFormImagePreloader.js
@@ -0,0 +1,68 @@
+export const useFormImagePreloader = (formRef, stateRef) => {
+ const form = computed(() => formRef?.value || {})
+ const state = computed(() => stateRef?.value || {})
+
+ const allBlockImages = computed(() => {
+ const properties = form.value?.properties || []
+ return properties
+ .map(f => f?.image?.url)
+ .filter((u) => typeof u === 'string' && u.length > 0)
+ })
+
+ const staticImages = computed(() => {
+ const imgs = []
+ if (form.value?.cover_picture) imgs.push(form.value.cover_picture)
+ if (form.value?.logo_picture) imgs.push(form.value.logo_picture)
+ return imgs
+ })
+
+ const allImageUrls = computed(() => {
+ const set = new Set([...(staticImages.value || []), ...(allBlockImages.value || [])])
+ return Array.from(set)
+ })
+
+ const criticalImageUrls = computed(() => {
+ const urls = []
+ if (form.value?.cover_picture) urls.push(form.value.cover_picture)
+ if (form.value?.logo_picture) urls.push(form.value.logo_picture)
+ const properties = form.value?.properties || []
+ const start = state.value?.currentPage ?? 0
+ for (let i = start; i < Math.min(properties.length, start + 3); i++) {
+ const url = properties[i]?.image?.url
+ if (url) urls.push(url)
+ }
+ return Array.from(new Set(urls))
+ })
+
+ useHead(() => ({
+ link: (criticalImageUrls.value || []).map((href) => ({ rel: 'preload', as: 'image', href }))
+ }))
+
+ function warmImageCache(urls) {
+ if (!urls || urls.length === 0) return
+ urls.forEach((u) => {
+ try {
+ const img = new Image()
+ img.decoding = 'async'
+ img.src = u
+ } catch { /* no-op */ }
+ })
+ }
+
+ onMounted(() => {
+ if (import.meta.client) {
+ warmImageCache(allImageUrls.value)
+ }
+ })
+
+ watch(allImageUrls, (urls) => {
+ if (import.meta.client) warmImageCache(urls)
+ })
+
+ return {
+ allImageUrls,
+ criticalImageUrls,
+ }
+}
+
+
diff --git a/client/composables/useAlert.js b/client/composables/useAlert.js
index b3c7a4654..7d21334fe 100644
--- a/client/composables/useAlert.js
+++ b/client/composables/useAlert.js
@@ -7,6 +7,31 @@ export function useAlert() {
options = { ...message, ...options }
message = options.description || options.message || ''
}
+ // Compose actions, optionally appending an "Open form" action when a form is provided
+ const composedActions = Array.isArray(options.actions) ? [...options.actions] : []
+ const form = options.form || options.openForm
+ const shareUrl = form?.share_url || options.shareUrl
+ if (form && shareUrl) {
+ composedActions.push({
+ label: options.openFormLabel ?? 'Open form',
+ icon: 'i-heroicons-arrow-top-right-on-square',
+ onClick: () => {
+ if (form.visibility === 'draft') {
+ useAlert().warning(
+ 'This form is currently in Draft mode and is not publicly accessible, You can change the form status on the edit form page.'
+ )
+ } else if (import.meta.client) {
+ window.open(shareUrl, '_blank')
+ }
+ }
+ })
+ }
+
+ const extraOptions = { ...options }
+ if (composedActions.length > 0) {
+ extraOptions.actions = composedActions
+ }
+
return useToast().add({
icon: 'i-heroicons-check-circle',
title: options.title ?? 'Success',
@@ -14,7 +39,7 @@ export function useAlert() {
color: 'success',
closeIcon: 'i-heroicons-x-mark-20-solid',
duration: autoClose,
- ...options
+ ...extraOptions
})
}
diff --git a/client/data/blocks_types.json b/client/data/blocks_types.json
index 59e592720..3e989b113 100644
--- a/client/data/blocks_types.json
+++ b/client/data/blocks_types.json
@@ -6,10 +6,12 @@
"default_block_name": "Your name",
"bg_class": "bg-blue-100",
"text_class": "text-blue-900",
+ "available_in": ["classic", "focused"],
"is_input": true,
"default_values": {
"multi_lines": false,
- "max_char_limit": 2000
+ "max_char_limit": 2000,
+ "placeholder": "Type your answer"
}
},
"rich_text": {
@@ -19,9 +21,11 @@
"default_block_name": "Description",
"bg_class": "bg-blue-100",
"text_class": "text-blue-900",
+ "available_in": ["classic", "focused"],
"is_input": true,
"default_values": {
- "max_char_limit": 2000
+ "max_char_limit": 2000,
+ "placeholder": "Write your answer"
}
},
"date": {
@@ -31,6 +35,7 @@
"default_block_name": "Date",
"bg_class": "bg-green-100",
"text_class": "text-green-900",
+ "available_in": ["classic", "focused"],
"is_input": true,
"default_values": {}
},
@@ -41,9 +46,11 @@
"default_block_name": "Link",
"bg_class": "bg-blue-100",
"text_class": "text-blue-900",
+ "available_in": ["classic", "focused"],
"is_input": true,
"default_values": {
- "max_char_limit": 2000
+ "max_char_limit": 2000,
+ "placeholder": "https://example.com"
}
},
"phone_number": {
@@ -53,8 +60,11 @@
"default_block_name": "Phone Number",
"bg_class": "bg-blue-100",
"text_class": "text-blue-900",
+ "available_in": ["classic", "focused"],
"is_input": true,
- "default_values": {}
+ "default_values": {
+ "placeholder": "+1 202 555 0142"
+ }
},
"email": {
"name": "email",
@@ -63,9 +73,11 @@
"default_block_name": "Email",
"bg_class": "bg-blue-100",
"text_class": "text-blue-900",
+ "available_in": ["classic", "focused"],
"is_input": true,
"default_values": {
- "max_char_limit": 2000
+ "max_char_limit": 2000,
+ "placeholder": "[email protected]"
}
},
"checkbox": {
@@ -75,6 +87,7 @@
"default_block_name": "Checkbox",
"bg_class": "bg-red-100",
"text_class": "text-red-900",
+ "available_in": ["classic", "focused"],
"is_input": true,
"default_values": {}
},
@@ -85,8 +98,10 @@
"default_block_name": "Select",
"bg_class": "bg-red-100",
"text_class": "text-red-900",
+ "available_in": ["classic", "focused"],
"is_input": true,
"default_values": {
+ "placeholder": "Select an option",
"select": {
"options": [
{ "name": "Option 1", "id": "Option 1" },
@@ -102,8 +117,10 @@
"default_block_name": "Multi Select",
"bg_class": "bg-red-100",
"text_class": "text-red-900",
+ "available_in": ["classic", "focused"],
"is_input": true,
"default_values": {
+ "placeholder": "Select options",
"multi_select": {
"options": [
{ "name": "Option 1", "id": "Option 1" },
@@ -119,6 +136,7 @@
"default_block_name": "Matrix",
"bg_class": "bg-red-100",
"text_class": "text-red-900",
+ "available_in": ["classic", "focused"],
"is_input": true,
"default_values": {
"rows": ["Row 1"],
@@ -135,8 +153,11 @@
"default_block_name": "Number",
"bg_class": "bg-purple-100",
"text_class": "text-purple-900",
+ "available_in": ["classic", "focused"],
"is_input": true,
- "default_values": {}
+ "default_values": {
+ "placeholder": "Type a number"
+ }
},
"rating": {
"name": "rating",
@@ -145,6 +166,7 @@
"default_block_name": "Rating",
"bg_class": "bg-purple-100",
"text_class": "text-purple-900",
+ "available_in": ["classic", "focused"],
"is_input": true,
"default_values": {
"rating_max_value": 5
@@ -157,6 +179,7 @@
"default_block_name": "Scale",
"bg_class": "bg-purple-100",
"text_class": "text-purple-900",
+ "available_in": ["classic", "focused"],
"is_input": true,
"default_values": {
"scale_min_value": 1,
@@ -171,6 +194,7 @@
"default_block_name": "Slider",
"bg_class": "bg-purple-100",
"text_class": "text-purple-900",
+ "available_in": ["classic", "focused"],
"is_input": true,
"default_values": {
"slider_min_value": 0,
@@ -185,6 +209,7 @@
"default_block_name": "Files",
"bg_class": "bg-pink-100",
"text_class": "text-pink-900",
+ "available_in": ["classic", "focused"],
"is_input": true,
"default_values": {}
},
@@ -195,6 +220,7 @@
"default_block_name": "Signature",
"bg_class": "bg-pink-100",
"text_class": "text-pink-900",
+ "available_in": ["classic", "focused"],
"is_input": true,
"default_values": {}
},
@@ -205,6 +231,7 @@
"default_block_name": "Scan Barcode",
"bg_class": "bg-pink-100",
"text_class": "text-pink-900",
+ "available_in": ["classic", "focused"],
"is_input": true,
"default_values": {
"decoders": ["qr_reader", "ean_reader", "ean_8_reader"]
@@ -217,9 +244,10 @@
"default_block_name": "Scan QR Code",
"bg_class": "bg-pink-100",
"text_class": "text-pink-900",
+ "available_in": ["classic", "focused"],
"is_input": true,
"default_values": {
- "decoders": ["qr_reader", "ean_reader", "ean_8_reader"]
+ "decoders": ["qr_reader"]
},
"actual_input": "barcode"
},
@@ -230,6 +258,7 @@
"default_block_name": "Payment",
"bg_class": "bg-green-100",
"text_class": "text-green-900",
+ "available_in": ["classic", "focused"],
"is_input": true,
"self_hosted": false,
"max_count": 1,
@@ -242,6 +271,7 @@
"default_block_name": "Text",
"bg_class": "bg-yellow-100",
"text_class": "text-yellow-900",
+ "available_in": ["classic", "focused"],
"is_input": false,
"default_values": {}
},
@@ -252,6 +282,7 @@
"default_block_name": "Page Break",
"bg_class": "bg-gray-100",
"text_class": "text-gray-900",
+ "available_in": ["classic"],
"is_input": false,
"default_values": {}
},
@@ -262,6 +293,7 @@
"default_block_name": "Divider",
"bg_class": "bg-gray-100",
"text_class": "text-gray-900",
+ "available_in": ["classic"],
"is_input": false,
"default_values": {}
},
@@ -272,6 +304,7 @@
"default_block_name": "Image",
"bg_class": "bg-yellow-100",
"text_class": "text-yellow-900",
+ "available_in": ["classic"],
"is_input": false,
"default_values": {}
},
@@ -282,6 +315,7 @@
"default_block_name": "Code Block",
"bg_class": "bg-yellow-100",
"text_class": "text-yellow-900",
+ "available_in": ["classic", "focused"],
"is_input": false,
"default_values": {}
}
diff --git a/client/lib/forms/FormModeStrategy.js b/client/lib/forms/FormModeStrategy.js
index bc955268b..d1538b915 100644
--- a/client/lib/forms/FormModeStrategy.js
+++ b/client/lib/forms/FormModeStrategy.js
@@ -35,7 +35,9 @@ export function createFormModeStrategy(mode) {
showFormCleanings: true,
showFontLink: false,
showBranding: true,
- disableFields: false
+ disableFields: false,
+ // When true, UI should force classic presentation regardless of form config
+ forceClassicPresentation: false
},
// Admin behaviors
@@ -92,6 +94,7 @@ export function createFormModeStrategy(mode) {
// Editing submission - same validation as LIVE mode, but show hidden fields
// This ensures edit mode behaves like live mode for validation
strategy.display.showHiddenFields = true
+ strategy.display.forceClassicPresentation = true
strategy.submission.enablePartialSubmissions = false
break
@@ -113,9 +116,11 @@ export function createFormModeStrategy(mode) {
case FormMode.READ_ONLY:
// Read only mode - no validation, no submission, fields are disabled
strategy.validation.validateOnNextPage = false
+ strategy.display.showHiddenFields = true
strategy.validation.validateOnSubmit = false
strategy.validation.performActualSubmission = false
strategy.display.disableFields = true
+ strategy.display.forceClassicPresentation = true
strategy.submission.enablePartialSubmissions = false
break
diff --git a/client/lib/forms/composables/useFocusedStructure.js b/client/lib/forms/composables/useFocusedStructure.js
new file mode 100644
index 000000000..ba70c54dc
--- /dev/null
+++ b/client/lib/forms/composables/useFocusedStructure.js
@@ -0,0 +1,96 @@
+import { computed, toValue } from 'vue'
+
+export function useFocusedStructure(formConfig, managerState, _formData) {
+ const form = computed(() => toValue(formConfig) || { properties: [] })
+
+ const fieldGroups = computed(() => {
+ const properties = form.value.properties || []
+ if (properties.length === 0) return [[]]
+ // One field per page
+ return properties.map(field => [field])
+ })
+
+ const pageCount = computed(() => {
+ const groups = fieldGroups.value
+ return groups ? groups.length : 0
+ })
+
+ const isLastPage = computed(() => {
+ if (managerState?.currentPage === undefined || managerState?.currentPage === null || pageCount.value === undefined) {
+ return true
+ }
+ return managerState.currentPage === pageCount.value - 1
+ })
+
+ const getPageFields = (pageIndex) => {
+ const groups = fieldGroups.value
+ if (!groups) return []
+ return groups[pageIndex] || []
+ }
+
+ const hasPaymentBlock = (pageIndex) => {
+ return getPageFields(pageIndex).some(field => field?.type === 'payment')
+ }
+
+ const getPaymentBlock = (pageIndex) => {
+ return getPageFields(pageIndex).find(field => field?.type === 'payment')
+ }
+
+ const currentPageHasPaymentBlock = computed(() => {
+ if (managerState?.currentPage === undefined || managerState?.currentPage === null) return false
+ return hasPaymentBlock(managerState.currentPage)
+ })
+
+ const currentPagePaymentBlock = computed(() => {
+ if (managerState?.currentPage === undefined || managerState?.currentPage === null) return undefined
+ return getPaymentBlock(managerState.currentPage)
+ })
+
+ // Utilities used by editor/drag in classic; provide no-ops or simple mapping
+ const getPageForField = (fieldIndex) => {
+ const properties = form.value.properties || []
+ if (properties.length === 0) return 0
+ if (fieldIndex < 0 || fieldIndex >= properties.length) return 0
+ return fieldIndex
+ }
+
+ const setPageForField = (fieldIndex) => {
+ const pageIndex = getPageForField(fieldIndex)
+ if (typeof pageIndex === 'number' && !isNaN(pageIndex) && pageIndex >= 0) {
+ if (managerState && managerState.currentPage !== undefined) managerState.currentPage = pageIndex
+ }
+ return pageIndex
+ }
+
+ const getTargetDropIndex = (relativeDropIndex, targetPageIndex) => {
+ // In focused mode each page has exactly one field; drop index maps directly
+ return Math.max(0, Math.min(targetPageIndex, (form.value.properties || []).length))
+ }
+
+ const determineInsertIndex = (selectedFieldIndex, currentPageIndex, explicitIndex = null, _insertOnSamePage = false) => {
+ if (explicitIndex !== null && typeof explicitIndex === 'number') return explicitIndex
+ if (selectedFieldIndex !== null && selectedFieldIndex !== undefined && selectedFieldIndex >= 0) return selectedFieldIndex + 1
+ const properties = form.value.properties || []
+ if (properties.length === 0) return 0
+ const pageIdx = currentPageIndex ?? managerState?.currentPage ?? 0
+ return Math.max(0, Math.min(properties.length, pageIdx + 1))
+ }
+
+ return {
+ fieldGroups,
+ pageCount,
+ isLastPage,
+ currentPage: computed(() => managerState?.currentPage ?? 0),
+ currentPageHasPaymentBlock,
+ currentPagePaymentBlock,
+ getPageFields,
+ getPageForField,
+ hasPaymentBlock,
+ getPaymentBlock,
+ getTargetDropIndex,
+ determineInsertIndex,
+ setPageForField
+ }
+}
+
+
diff --git a/client/lib/forms/composables/useFormInitialization.js b/client/lib/forms/composables/useFormInitialization.js
index 452a08818..d52f0ccbd 100644
--- a/client/lib/forms/composables/useFormInitialization.js
+++ b/client/lib/forms/composables/useFormInitialization.js
@@ -25,6 +25,14 @@ export function useFormInitialization(formConfig, form, pendingSubmission) {
const initialize = async (options = {}) => {
const config = toValue(formConfig)
+ // Ensure focused mode shows navigation arrows by default when unset
+ if (config?.presentation_style === 'focused') {
+ if (!config.settings) config.settings = {}
+ if (config.settings.navigation_arrows === undefined) {
+ config.settings.navigation_arrows = true
+ }
+ }
+
// 1. Reset form state
form.reset()
form.errors.clear()
diff --git a/client/lib/forms/composables/useFormManager.js b/client/lib/forms/composables/useFormManager.js
index c486fdc51..dabd0e357 100644
--- a/client/lib/forms/composables/useFormManager.js
+++ b/client/lib/forms/composables/useFormManager.js
@@ -1,7 +1,8 @@
-import { reactive, computed, ref, toValue, onBeforeUnmount } from 'vue'
+import { reactive, computed, ref, toValue, onBeforeUnmount, shallowRef, watch } from 'vue'
import { useForm } from '~/composables/useForm.js' // Assuming useForm handles vForm setup
import { FormMode, createFormModeStrategy } from '../FormModeStrategy'
import { useFormStructure } from './useFormStructure'
+import { useFocusedStructure } from './useFocusedStructure'
import { useFormInitialization } from './useFormInitialization'
import { useFormValidation } from './useFormValidation'
import { useFormSubmission } from './useFormSubmission'
@@ -55,7 +56,32 @@ export function useFormManager(initialFormConfig, initialMode = FormMode.LIVE, o
// --- Instantiate Other Composables (Services) ---
const timer = useFormTimer(pendingSubmissionService)
const initialization = useFormInitialization(config, form, pendingSubmissionService)
- const structure = useFormStructure(config, state, form)
+ // Structure adapter (hot-swappable)
+ const structure = shallowRef(null)
+
+ function buildStructureAdapter() {
+ const forceClassic = !!strategy.value?.display?.forceClassicPresentation
+ const style = forceClassic ? 'classic' : ((toValue(config)?.presentation_style) || 'classic')
+ return style === 'focused'
+ ? useFocusedStructure(config, state, form)
+ : useFormStructure(config, state, form)
+ }
+
+ function replaceStructure() {
+ structure.value = buildStructureAdapter()
+ // Clamp current page to valid range for the new structure
+ try {
+ const totalPages = structure.value?.pageCount?.value ?? 1
+ if (typeof totalPages === 'number' && totalPages >= 1) {
+ if (state.currentPage >= totalPages) {
+ state.currentPage = Math.max(0, totalPages - 1)
+ } else if (state.currentPage < 0) {
+ state.currentPage = 0
+ }
+ }
+ } catch { /* no-op */ }
+ }
+
const validation = useFormValidation(config, form, state)
const payment = useFormPayment(config, form)
const submission = useFormSubmission(config, form)
@@ -95,6 +121,9 @@ export function useFormManager(initialFormConfig, initialMode = FormMode.LIVE, o
timer.reset()
timer.start()
+
+ // Ensure structure is built after initialization
+ replaceStructure()
// Start partial submission sync if enabled in both config and strategy
if (import.meta.client && config.value.enable_partial_submissions && strategy.value.submission.enablePartialSubmissions) {
@@ -104,23 +133,41 @@ export function useFormManager(initialFormConfig, initialMode = FormMode.LIVE, o
state.isProcessing = false
}
+ // React to presentation_style changes
+ watch(() => toValue(config)?.presentation_style, () => {
+ replaceStructure()
+ })
+
/**
* Navigates to the next page, handling validation and payment intent creation.
*/
const nextPage = async () => {
if (state.isProcessing) return false
+
+ // Derive fields and conditions up-front so we can decide if we need a loading state
+ const currentPageFields = structure.value.getPageFields(state.currentPage)
+ const isCurrentlyLastPage = structure.value.isLastPage.value
+ const paymentBlock = structure.value.currentPagePaymentBlock.value
+
+ // Determine if this step requires validation via validation helper filtering
+ const validatableFields = validation.filterValidatableFields(currentPageFields)
+ const needsValidation = !!(strategy.value?.validation?.validateOnNextPage) && validatableFields.length > 0
+
+ // If no validation and no payment work is needed, skip loading and just advance
+ if (!needsValidation && !paymentBlock) {
+ if (!isCurrentlyLastPage) {
+ state.currentPage++
+ }
+ return true
+ }
+
state.isProcessing = true
try {
- const currentPageFields = structure.getPageFields(state.currentPage)
- // Use computed isLastPage directly from structure composable
- const isCurrentlyLastPage = structure.isLastPage.value
-
- // 1. Validate current page
- await validation.validateCurrentPage(currentPageFields, strategy.value)
+ // 1. Validate current page if needed
+ if (needsValidation) await validation.validateCurrentPage(currentPageFields, strategy.value)
// 2. Process payment (Create Payment Intent if applicable)
- const paymentBlock = structure.currentPagePaymentBlock.value
if (paymentBlock) {
// In editor/test mode (not LIVE), skip payment validation
const isPaymentRequired = mode.value === FormMode.LIVE ? !!paymentBlock.required : false
@@ -142,7 +189,7 @@ export function useFormManager(initialFormConfig, initialMode = FormMode.LIVE, o
} catch {
// Use validation composable's failure handler
validation.onValidationFailure({
- fieldGroups: structure.fieldGroups.value, // Pass reactive groups
+ fieldGroups: structure.value.fieldGroups.value, // Pass reactive groups
setPageIndexCallback: (index) => { state.currentPage = index },
timerService: timer // Pass the timer composable instance
})
@@ -181,7 +228,7 @@ export function useFormManager(initialFormConfig, initialMode = FormMode.LIVE, o
const completionTime = timer.getCompletionTime()
// 2. Process payment if applicable
- const paymentBlock = structure.currentPagePaymentBlock.value
+ const paymentBlock = structure.value.currentPagePaymentBlock.value
if (paymentBlock) {
// In editor/test mode (not LIVE), skip payment validation
@@ -274,7 +321,7 @@ export function useFormManager(initialFormConfig, initialMode = FormMode.LIVE, o
// Handle validation or submission errors using validation composable's handler
validation.onValidationFailure({
- fieldGroups: structure.fieldGroups.value,
+ fieldGroups: structure.value.fieldGroups.value,
setPageIndexCallback: (index) => { state.currentPage = index },
timerService: timer
})
diff --git a/client/lib/forms/composables/useFormValidation.js b/client/lib/forms/composables/useFormValidation.js
index 657162d42..f7865ce2c 100644
--- a/client/lib/forms/composables/useFormValidation.js
+++ b/client/lib/forms/composables/useFormValidation.js
@@ -7,6 +7,12 @@ export function useFormValidation(formConfig, form, managerState) {
const formRef = computed(() => toValue(form)) // Ensure reactivity with the form instance
const configRef = computed(() => toValue(formConfig)) // Ensure reactivity with config
+ // Treat Notion-style layout/display blocks (nf-*) as non-validated elements
+ const isLayoutBlock = (field) => {
+ const t = field?.type
+ return typeof t === 'string' && t.startsWith('nf-')
+ }
+
/**
* Validates specific fields using the vForm instance's validate method.
@@ -40,14 +46,17 @@ export function useFormValidation(formConfig, form, managerState) {
* @param {Object} formModeStrategy - The strategy object for the current mode.
* @returns {Promise<boolean>} Resolves true if validation passes or isn't required, rejects otherwise.
*/
+ // Shared filter to remove layout/payment blocks from validation
+ const filterValidatableFields = (fields) => {
+ return (fields || []).filter(field => field && field.id && field.type !== 'payment' && !isLayoutBlock(field))
+ }
+
const validateCurrentPage = async (currentPageFields, formModeStrategy) => {
if (!formModeStrategy?.validation?.validateOnNextPage) {
return true
}
- const fieldIdsToValidate = currentPageFields
- .filter(field => field && field.id && field.type !== 'payment')
- .map(field => field.id)
+ const fieldIdsToValidate = filterValidatableFields(currentPageFields).map(field => field.id)
if (fieldIdsToValidate.length === 0) {
return true
@@ -75,9 +84,7 @@ export function useFormValidation(formConfig, form, managerState) {
return true
}
- const fieldIdsToValidate = allFields
- .filter(field => field && field.id && field.type !== 'payment')
- .map(field => field.id)
+ const fieldIdsToValidate = filterValidatableFields(allFields).map(field => field.id)
if (fieldIdsToValidate.length === 0) {
return true
@@ -135,6 +142,7 @@ export function useFormValidation(formConfig, form, managerState) {
validateFields,
validateCurrentPage,
validateSubmissionIfNotLastPage,
+ filterValidatableFields,
findFirstPageWithError,
onValidationFailure,
}
diff --git a/client/lib/forms/themes/input-label.theme.js b/client/lib/forms/themes/input-label.theme.js
index c3d084646..2b11751fb 100644
--- a/client/lib/forms/themes/input-label.theme.js
+++ b/client/lib/forms/themes/input-label.theme.js
@@ -11,6 +11,12 @@ export const inputLabelTheme = {
requiredDot: 'text-red-500 required-dot'
},
variants: {
+ presentation: {
+ classic: {},
+ focused: {
+ label: 'leading-none'
+ }
+ },
theme: {
default: {
label: 'font-semibold'
@@ -48,9 +54,17 @@ export const inputLabelTheme = {
}
}
},
+ compoundVariants: [
+ // Label font size adjustments for focused presentation (increase by 1 step)
+ { presentation: 'focused', size: 'xs', class: { label: 'text-sm leading-none' } },
+ { presentation: 'focused', size: 'sm', class: { label: 'text-sm leading-none' } },
+ { presentation: 'focused', size: 'md', class: { label: 'text-base leading-none' } },
+ { presentation: 'focused', size: 'lg', class: { label: 'text-xl leading-none' } }
+ ],
defaultVariants: {
theme: 'default',
size: 'md',
- uppercaseLabels: false
+ uppercaseLabels: false,
+ presentation: 'classic'
}
}
\ No newline at end of file
diff --git a/client/lib/forms/themes/input-wrapper.theme.js b/client/lib/forms/themes/input-wrapper.theme.js
index a79480cfa..9e3887ced 100644
--- a/client/lib/forms/themes/input-wrapper.theme.js
+++ b/client/lib/forms/themes/input-wrapper.theme.js
@@ -5,27 +5,72 @@
export const inputWrapperTheme = {
slots: {
wrapper: [
- 'relative'
+ 'relative flex flex-col gap-1'
],
- help: 'text-neutral-500'
+ help: 'text-neutral-500',
+ error: 'has-error text-xs text-red-500 mt-1 break-words whitespace-break-spaces',
+ media: '',
+ // classes for the media component root (e.g., <BlockMediaLayout />)
+ mediaComponent: '',
+ // classes for the underlying <img> inside BlockMediaLayout
+ mediaImg: ''
},
variants: {
+ presentation: {
+ classic: {},
+ focused: {
+ wrapper: 'gap-2',
+ }
+ },
+ borderRadius: {
+ none: {},
+ small: {},
+ full: {}
+ },
size: {
xs: {
- wrapper: 'my-0.5'
+ wrapper: 'my-0.5',
},
sm: {
- wrapper: 'my-1'
+ wrapper: 'my-1',
},
md: {
- wrapper: 'my-1.5'
+ wrapper: 'my-1.5',
},
lg: {
- wrapper: 'my-1.5'
+ wrapper: 'my-1.5',
+ }
+ },
+ mediaStyle: {
+ default: {},
+ intrinsic: {
+ // apply intrinsic sizing to the component root and the image itself
+ mediaComponent: 'inline-block align-top !w-auto !h-auto',
+ mediaImg: 'inline-block h-auto w-auto max-w-[75%] max-h-120 object-contain transition-opacity duration-300'
}
}
},
+ compoundVariants: [
+ // Default style: border radius on the container with overflow clipping
+ { mediaStyle: 'default', borderRadius: 'none', class: { media: 'rounded-none overflow-hidden' } },
+ { mediaStyle: 'default', borderRadius: 'small', class: { media: 'rounded-md overflow-hidden' } },
+ { mediaStyle: 'default', borderRadius: 'full', class: { media: 'rounded-[20px] overflow-hidden' } },
+
+ // Intrinsic style: border radius applied directly to the image
+ { mediaStyle: 'intrinsic', borderRadius: 'none', class: { mediaImg: 'rounded-none' } },
+ { mediaStyle: 'intrinsic', borderRadius: 'small', class: { mediaImg: 'rounded-md' } },
+ { mediaStyle: 'intrinsic', borderRadius: 'full', class: { mediaImg: 'rounded-[20px]' } },
+
+ // Text size adjustments for focused presentation (help and error)
+ { presentation: 'focused', size: 'xs', class: { help: 'text-sm', error: 'text-sm text-red-500 mt-0 leading-none' } },
+ { presentation: 'focused', size: 'sm', class: { help: 'text-sm', error: 'text-sm mt-0 leading-none' } },
+ { presentation: 'focused', size: 'md', class: { help: 'text-base', error: 'text-sm mt-0 leading-none' } },
+ { presentation: 'focused', size: 'lg', class: { help: 'text-lg', error: 'text-base mt-0 leading-none' } }
+ ],
defaultVariants: {
- size: 'md'
+ size: 'md',
+ borderRadius: 'small',
+ mediaStyle: 'default',
+ presentation: 'classic'
}
}
\ No newline at end of file
diff --git a/client/lib/forms/themes/option-selector-input.theme.js b/client/lib/forms/themes/option-selector-input.theme.js
index 195941339..af6df15dd 100644
--- a/client/lib/forms/themes/option-selector-input.theme.js
+++ b/client/lib/forms/themes/option-selector-input.theme.js
@@ -36,7 +36,7 @@ export const optionSelectorInputTheme = {
false: { option: 'rounded-lg' }
},
selected: {
- true: { option: ['bg-form/10', 'border-form', 'relative z-10'] }
+ true: { option: ['bg-form/10', 'hover:bg-form/10', 'border-form', 'relative z-10'] }
},
disabled: {
true: { button: 'opacity-50 pointer-events-none' }
diff --git a/client/lib/forms/themes/payment-input.theme.js b/client/lib/forms/themes/payment-input.theme.js
index b3ed07c48..0ac0da3c5 100644
--- a/client/lib/forms/themes/payment-input.theme.js
+++ b/client/lib/forms/themes/payment-input.theme.js
@@ -4,7 +4,10 @@
export const paymentInputTheme = {
slots: {
container: [],
- amountBar: ['mb-4 flex items-center justify-between']
+ card: [],
+ amountBar: ['flex items-center justify-between'],
+ section: [],
+ stack: ['flex flex-col']
},
variants: {
theme: {
@@ -14,20 +17,42 @@ export const paymentInputTheme = {
'bg-white dark:bg-neutral-900',
'text-neutral-700 dark:text-neutral-200'
],
+ card: [
+ 'border border-neutral-300 dark:border-neutral-600',
+ 'bg-white dark:bg-neutral-900',
+ 'text-neutral-700 dark:text-neutral-200'
+ ],
amountBar: [
'border border-neutral-300 dark:border-neutral-600',
'bg-neutral-50 dark:bg-neutral-800'
+ ],
+ },
+ simple: {
+ container: [
+ 'bg-neutral-50 dark:bg-neutral-800',
+ ],
+ card: [
+ 'bg-white dark:bg-neutral-900 border border-neutral-300 dark:border-neutral-600',
+ ],
+ amountBar: [
+ 'border border-neutral-300 dark:border-neutral-600',
+ 'bg-neutral-100/50 dark:bg-neutral-700'
]
},
minimal: {
container: [
+ 'border-2 border-transparent',
+ 'bg-neutral-50 dark:bg-notion-dark-light',
+ 'text-neutral-700 dark:text-neutral-300'
+ ],
+ card: [
'border-2 border-transparent',
'bg-neutral-100 dark:bg-notion-dark-light',
'text-neutral-700 dark:text-neutral-300'
],
amountBar: [
'border-2 border-transparent',
- 'bg-neutral-200/50 dark:bg-neutral-900'
+ 'bg-neutral-100 dark:bg-neutral-900'
]
},
notion: {
@@ -36,6 +61,11 @@ export const paymentInputTheme = {
'bg-notion-input-background dark:bg-notion-dark-light',
'text-neutral-900 dark:text-neutral-100'
],
+ card: [
+ 'border border-notion-input-border dark:border-notion-input-borderDark',
+ 'bg-notion-input-background dark:bg-notion-dark-light',
+ 'text-neutral-900 dark:text-neutral-100'
+ ],
amountBar: [
'border border-notion-input-border dark:border-notion-input-borderDark',
'bg-notion-input-background dark:bg-notion-dark-light'
@@ -43,21 +73,21 @@ export const paymentInputTheme = {
}
},
size: {
- xs: { container: 'px-2.5 py-1.5 text-xs', amountBar: 'px-2.5 py-1.5 text-xs' },
- sm: { container: 'px-2 py-1.5 text-sm', amountBar: 'px-2 py-1.5 text-sm' },
- md: { container: 'px-4 py-2 text-base', amountBar: 'px-4 py-2 text-base' },
- lg: { container: 'px-5 py-3 text-lg', amountBar: 'px-5 py-3 text-lg' }
+ xs: { container: 'px-2.5 py-1.5 text-xs', card: 'px-2.5 py-1.5 text-xs', amountBar: 'px-2.5 py-1.5 text-xs mb-2', section: 'my-2', stack: 'gap-2' },
+ sm: { container: 'px-2 py-1.5 text-sm', card: 'px-2 py-1.5 text-sm', amountBar: 'px-2 py-1.5 text-sm mb-2', section: 'my-2', stack: 'gap-2' },
+ md: { container: 'px-4 py-2 text-base', card: 'px-4 py-2 text-base', amountBar: 'px-4 py-2 text-base mb-3', section: 'my-3', stack: 'gap-3' },
+ lg: { container: 'px-5 py-3 text-lg', card: 'px-5 py-3 text-lg', amountBar: 'px-5 py-3 text-lg mb-4', section: 'my-4', stack: 'gap-4' }
},
borderRadius: {
- none: { container: 'rounded-none', amountBar: 'rounded-none' },
- small: { container: 'rounded-lg', amountBar: 'rounded-lg' },
- full: { container: 'rounded-[20px]', amountBar: 'rounded-[20px]' }
+ none: { container: 'rounded-none', card: 'rounded-none', amountBar: 'rounded-none' },
+ small: { container: 'rounded-lg', card: 'rounded-lg', amountBar: 'rounded-lg' },
+ full: { container: 'rounded-[20px]', card: 'rounded-[20px]', amountBar: 'rounded-[20px]' }
},
hasError: {
- true: { container: '!ring-red-500 !ring-2 !border-transparent' }
+ true: { container: '!ring-red-500 !ring-2 !border-transparent', card: '!ring-red-500 !ring-2 !border-transparent' }
},
disabled: {
- true: { container: '!cursor-not-allowed !bg-neutral-200 dark:!bg-neutral-800' }
+ true: { container: '!cursor-not-allowed !bg-neutral-200 dark:!bg-neutral-800', card: '!cursor-not-allowed !bg-neutral-200 dark:!bg-neutral-800' }
}
},
defaultVariants: {
diff --git a/client/lib/forms/themes/side-media-small.theme.js b/client/lib/forms/themes/side-media-small.theme.js
new file mode 100644
index 000000000..7ddfeb185
--- /dev/null
+++ b/client/lib/forms/themes/side-media-small.theme.js
@@ -0,0 +1,28 @@
+/**
+ * SideMediaSmall tailwind-variants configuration
+ */
+export const sideMediaSmallTheme = {
+ slots: {
+ mediaContainer: '',
+ mediaComponent: 'flex @3xl:justify-center align-top',
+ mediaImg: 'inline-block h-auto w-auto max-w-full max-h-[236px] xl:max-h-[292px] object-contain transition-opacity duration-300'
+ },
+ variants: {
+ borderRadius: {
+ none: {
+ mediaImg: 'rounded-none'
+ },
+ small: {
+ mediaImg: 'rounded-md'
+ },
+ full: {
+ mediaImg: 'rounded-[20px]'
+ }
+ }
+ },
+ defaultVariants: {
+ borderRadius: 'small'
+ }
+}
+
+
diff --git a/client/lib/forms/themes/text-block.theme.js b/client/lib/forms/themes/text-block.theme.js
index 814c50986..7e3bed890 100644
--- a/client/lib/forms/themes/text-block.theme.js
+++ b/client/lib/forms/themes/text-block.theme.js
@@ -3,7 +3,7 @@
*/
export const textBlockTheme = {
slots: {
- root: 'break-words whitespace-break-spaces'
+ root: 'break-words whitespace-break-spaces [&>h1]:mb-2 [&>h2]:mb-1'
},
variants: {
size: {
diff --git a/client/nuxt.config.ts b/client/nuxt.config.ts
index 6f85526a8..27c28717f 100644
--- a/client/nuxt.config.ts
+++ b/client/nuxt.config.ts
@@ -128,7 +128,14 @@ export default defineNuxtConfig({
},
icon: {
+ customCollections: [
+ {
+ prefix: 'opnform',
+ dir: './public/icons'
+ },
+ ],
clientBundle: {
+ includeCustomCollections: true,
scan: {
globInclude: ['**/*.vue', '**/*.json'],
},
diff --git a/client/pages/forms/[slug]/index.vue b/client/pages/forms/[slug]/index.vue
index 5df60d645..4172fd524 100644
--- a/client/pages/forms/[slug]/index.vue
+++ b/client/pages/forms/[slug]/index.vue
@@ -1,39 +1,9 @@
<template>
<div
id="public-form"
- class="flex flex-col"
+ class="flex flex-col min-h-screen"
>
- <div v-if="form && !isIframe && (form.logo_picture || form.cover_picture)">
- <div v-if="form.cover_picture">
- <div
- id="cover-picture"
- class="max-h-56 w-full overflow-hidden flex items-center justify-center"
- >
- <img
- alt="Form Cover Picture"
- :src="form.cover_picture"
- class="w-full"
- >
- </div>
- </div>
- <div
- v-if="form.logo_picture"
- class="w-full p-5 relative mx-auto"
- :class="{'pt-20':!form.cover_picture, 'md:w-3/5 lg:w-1/2 md:max-w-2xl': form.width === 'centered', 'max-w-7xl': (form.width === 'full' && !isIframe) }"
- :style="{ 'direction': form?.layout_rtl ? 'rtl' : 'ltr' }"
- >
- <img
- alt="Logo Picture"
- :src="form.logo_picture"
- :class="{'top-5':!form.cover_picture, '-top-10':form.cover_picture}"
- class="w-20 h-20 object-contain absolute transition-all"
- >
- </div>
- </div>
- <div
- class="w-full mx-auto px-4"
- :class="{'mt-6':!isIframe, 'md:w-3/5 lg:w-1/2 md:max-w-2xl': form && (form.width === 'centered'), 'max-w-7xl': (form && form.width === 'full' && !isIframe)}"
- >
+ <div class="w-full mx-auto flex flex-col grow h-full">
<div v-if="!formLoading && !form">
<NotFoundForm />
</div>
@@ -46,7 +16,7 @@
<OpenCompleteForm
ref="openCompleteForm"
:form="form"
- class="mb-20"
+ class="w-full grow min-h-0"
:dark-mode="darkMode"
:mode="FormMode.LIVE"
@password-entered="passwordEntered"
@@ -92,6 +62,7 @@ if (import.meta.server) {
const openCompleteForm = ref(null)
const passwordEntered = function (password) {
+ console.log('passwordEntered', password)
const cookie = useCookie('password-' + slug, {
maxAge: 60 * 60 * 7,
sameSite: 'none',
@@ -100,6 +71,7 @@ const passwordEntered = function (password) {
cookie.value = sha256(password)
nextTick(() => {
refetchForm().then(() => {
+ console.log('form.value', form.value)
if (form.value?.is_password_protected) {
openCompleteForm.value.addPasswordError(t('forms.invalid_password'))
} else {
diff --git a/client/pages/templates/[slug].vue b/client/pages/templates/[slug].vue
index 33bc244e7..a199f4960 100644
--- a/client/pages/templates/[slug].vue
+++ b/client/pages/templates/[slug].vue
@@ -91,19 +91,36 @@
</div>
</section>
- <section class="w-full max-w-4xl relative px-4 mx-auto sm:px-6 lg:px-8 -mt-[210px]">
+ <section class="w-full max-w-5xl relative px-4 mx-auto sm:px-6 lg:px-8 -mt-[210px]">
<div
class="p-4 mx-auto bg-white shadow-lg sm:p-6 lg:p-8 rounded-xl ring ring-inset ring-neutral-200 isolate"
>
<p class="text-sm font-medium text-center text-neutral-500 -mt-2 mb-2">
Template Preview
</p>
- <OpenCompleteForm
- ref="open-complete-form"
- :form="form"
- :mode="FormMode.TEMPLATE"
- class="mb-4 p-4 bg-neutral-50 border border-neutral-200 border-dashed rounded-lg"
- />
+ <div class="mb-4">
+ <div
+ ref="templatePreviewParent"
+ class="border rounded-lg bg-white dark:bg-notion-dark w-full shadow-xs transition-all overflow-y-auto flex flex-col"
+ >
+ <div
+ :class="[
+ 'flex flex-col',
+ form?.presentation_style === 'focused'
+ ? 'h-[650px] sm:h-[830px]'
+ : 'min-h-[520px]'
+ ]"
+ >
+ <OpenCompleteForm
+ ref="open-complete-form"
+ :form="form"
+ :mode="FormMode.TEMPLATE"
+ :dark-mode="darkMode"
+ class="w-full grow min-h-0"
+ />
+ </div>
+ </div>
+ </div>
</div>
<div class="absolute bottom-0 translate-y-full inset-x-0">
@@ -271,7 +288,7 @@
</template>
<script setup>
-import { computed, ref } from "vue"
+import { computed, ref, onMounted } from "vue"
import { useRoute } from "vue-router"
import FormTemplateModal from "~/components/open/forms/components/templates/FormTemplateModal.vue"
import TemplateTags from "~/components/pages/templates/TemplateTags.vue"
@@ -281,13 +298,19 @@ import { cleanQuotes } from "~/lib/utils"
import OpenCompleteForm from "~/components/open/forms/OpenCompleteForm.vue"
import Breadcrumb from "~/components/app/Breadcrumb.vue"
import TrackClick from "~/components/global/TrackClick.vue"
+import { handleDarkMode, useDarkMode } from "~/lib/forms/public-page.js"
const route = useRoute()
const { detail, list } = useTemplates()
-const { data: template } = detail(route.params.slug)
+const { data: template, suspense: templateSuspense } = detail(route.params.slug)
const { data: allTemplates } = list()
+// Handle SSR suspense to prevent flash of error message
+if (import.meta.server) {
+ await templateSuspense()
+}
+
const form = computed(() => {
if (!template.value) {
return null
@@ -295,6 +318,15 @@ const form = computed(() => {
return template.value.structure
})
+// Dark mode handling like editor preview
+const templatePreviewParent = ref(null)
+const darkMode = useDarkMode(templatePreviewParent)
+onMounted(() => {
+ if (template.value?.structure?.dark_mode) {
+ handleDarkMode(template.value.structure.dark_mode, templatePreviewParent.value)
+ }
+})
+
const relatedTemplates = computed(() => {
if (!template.value?.related_templates || !allTemplates.value) {
return []
diff --git a/client/public/icons/form-layout-background.svg b/client/public/icons/form-layout-background.svg
new file mode 100644
index 000000000..a6d917fe3
--- /dev/null
+++ b/client/public/icons/form-layout-background.svg
@@ -0,0 +1,13 @@
+<svg width="70" height="50" viewBox="0 0 70 50" fill="none" xmlns="http://www.w3.org/2000/svg">
+<g clip-path="url(#clip0_3911_121)">
+<rect width="70" height="50" fill="white"/>
+<rect width="70" height="50" fill="var(--icon-fg, currentColor)"/>
+<rect x="18" y="21" width="34" height="3" rx="1.5" fill="white"/>
+<rect x="18" y="27" width="11" height="3" rx="1.5" fill="white"/>
+</g>
+<defs>
+<clipPath id="clip0_3911_121">
+<rect width="70" height="50" fill="white"/>
+</clipPath>
+</defs>
+</svg>
diff --git a/client/public/icons/form-layout-between.svg b/client/public/icons/form-layout-between.svg
new file mode 100644
index 000000000..dc976aaf2
--- /dev/null
+++ b/client/public/icons/form-layout-between.svg
@@ -0,0 +1,6 @@
+<svg width="70" height="50" viewBox="0 0 70 50" fill="none" xmlns="http://www.w3.org/2000/svg">
+<rect width="70" height="50" fill="white"/>
+<rect x="18" y="16" width="33" height="17" rx="2" fill="var(--icon-fg, currentColor)"/>
+<rect x="18" y="10" width="22" height="3" rx="1.5" fill="var(--icon-fg, currentColor)"/>
+<rect x="18" y="36" width="11" height="3" rx="1.5" fill="var(--icon-fg, currentColor)"/>
+</svg>
diff --git a/client/public/icons/form-layout-left-small.svg b/client/public/icons/form-layout-left-small.svg
new file mode 100644
index 000000000..140f5123b
--- /dev/null
+++ b/client/public/icons/form-layout-left-small.svg
@@ -0,0 +1,6 @@
+<svg width="70" height="50" viewBox="0 0 70 50" fill="none" xmlns="http://www.w3.org/2000/svg">
+<rect width="70" height="50" fill="white"/>
+<rect x="10" y="16" width="22" height="17" rx="2" fill="var(--icon-fg, currentColor)"/>
+<rect x="39" y="20" width="22" height="3" rx="1.5" fill="var(--icon-fg, currentColor)"/>
+<rect x="39" y="26" width="11" height="3" rx="1.5" fill="var(--icon-fg, currentColor)"/>
+</svg>
diff --git a/client/public/icons/form-layout-left-split.svg b/client/public/icons/form-layout-left-split.svg
new file mode 100644
index 000000000..74bb411c9
--- /dev/null
+++ b/client/public/icons/form-layout-left-split.svg
@@ -0,0 +1,6 @@
+<svg width="70" height="50" viewBox="0 0 70 50" fill="none" xmlns="http://www.w3.org/2000/svg">
+<rect width="70" height="50" fill="white"/>
+<rect width="35" height="50" fill="var(--icon-fg, currentColor)"/>
+<rect x="42" y="20" width="22" height="3" rx="1.5" fill="var(--icon-fg, currentColor)"/>
+<rect x="42" y="26" width="11" height="3" rx="1.5" fill="var(--icon-fg, currentColor)"/>
+</svg>
diff --git a/client/public/icons/form-layout-right-small.svg b/client/public/icons/form-layout-right-small.svg
new file mode 100644
index 000000000..8fb01b4a2
--- /dev/null
+++ b/client/public/icons/form-layout-right-small.svg
@@ -0,0 +1,6 @@
+<svg width="70" height="50" viewBox="0 0 70 50" fill="none" xmlns="http://www.w3.org/2000/svg">
+<rect width="70" height="50" fill="white"/>
+<rect width="22" height="17" rx="2" transform="matrix(-1 0 0 1 61 16)" fill="var(--icon-fg, currentColor)"/>
+<rect width="22" height="3" rx="1.5" transform="matrix(-1 0 0 1 32 20)" fill="var(--icon-fg, currentColor)"/>
+<rect width="11" height="3" rx="1.5" transform="matrix(-1 0 0 1 32 26)" fill="var(--icon-fg, currentColor)"/>
+</svg>
diff --git a/client/public/icons/form-layout-right-split.svg b/client/public/icons/form-layout-right-split.svg
new file mode 100644
index 000000000..03477fe81
--- /dev/null
+++ b/client/public/icons/form-layout-right-split.svg
@@ -0,0 +1,6 @@
+<svg width="70" height="50" viewBox="0 0 70 50" fill="none" xmlns="http://www.w3.org/2000/svg">
+<rect width="70" height="50" fill="white"/>
+<rect width="35" height="50" transform="matrix(-1 0 0 1 70 0)" fill="var(--icon-fg, currentColor)"/>
+<rect width="22" height="3" rx="1.5" transform="matrix(-1 0 0 1 28 20)" fill="var(--icon-fg, currentColor)"/>
+<rect width="11" height="3" rx="1.5" transform="matrix(-1 0 0 1 17 26)" fill="var(--icon-fg, currentColor)"/>
+</svg>
diff --git a/client/public/icons/form-style-classic.svg b/client/public/icons/form-style-classic.svg
new file mode 100644
index 000000000..dbd17a8c3
--- /dev/null
+++ b/client/public/icons/form-style-classic.svg
@@ -0,0 +1,23 @@
+<svg width="70" height="50" viewBox="0 0 70 50" fill="none" xmlns="http://www.w3.org/2000/svg">
+<g clip-path="url(#clip0_3912_149)">
+<rect width="70" height="50" fill="white"/>
+<rect width="70" height="15" fill="var(--icon-fg, currentColor)"/>
+<mask id="mask0_3912_149" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="70" height="15">
+<rect width="70" height="15" fill="#737373"/>
+</mask>
+<g mask="url(#mask0_3912_149)">
+<path d="M18.5 5.5C13.5 5.5 5.99997 10.0499 -2.86102e-05 11.0999C-1.6667 11.2999 -5.20003 11.7599 -6.00003 11.9999C-6.80003 12.2399 -4.33336 14.4999 -3.00003 15.5999H73L72 10.9499C63.3387 9.82554 62.8267 8.00018 58.5 8C54.1733 7.99982 49 13.5 42 13C28 10.75 23.0111 5.5 18.5 5.5Z" fill="var(--icon-muted, currentColor)"/>
+</g>
+<rect x="19" y="20" width="32" height="3" rx="1.5" fill="var(--icon-fg, currentColor)"/>
+<rect x="19" y="32" width="32" height="3" rx="1.5" fill="var(--icon-fg, currentColor)"/>
+<rect x="19" y="26" width="15" height="3" rx="1.5" fill="var(--icon-fg, currentColor)"/>
+<rect x="28" y="38" width="14" height="3" rx="1.5" fill="var(--icon-fg, currentColor)"/>
+<rect x="36" y="26" width="15" height="3" rx="1.5" fill="var(--icon-fg, currentColor)"/>
+<path d="M54 2C54 4.20914 52.2091 6 50 6C47.7909 6 46 4.20914 46 2C46 -0.209139 47.7909 -2 50 -2C52.2091 -2 54 -0.209139 54 2Z" fill="var(--icon-soft, var(--icon-muted, currentColor))"/>
+</g>
+<defs>
+<clipPath id="clip0_3912_149">
+<rect width="70" height="50" fill="white"/>
+</clipPath>
+</defs>
+</svg>
diff --git a/client/public/icons/form-style-focused.svg b/client/public/icons/form-style-focused.svg
new file mode 100644
index 000000000..f2c12c3cc
--- /dev/null
+++ b/client/public/icons/form-style-focused.svg
@@ -0,0 +1,13 @@
+<svg width="70" height="50" viewBox="0 0 70 50" fill="none" xmlns="http://www.w3.org/2000/svg">
+<rect width="70" height="50" fill="white"/>
+<rect width="35" height="50" fill="var(--icon-fg, currentColor)"/>
+<mask id="mask0_3912_138" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="35" height="50">
+<rect width="35" height="50" fill="#737373"/>
+</mask>
+<g mask="url(#mask0_3912_138)">
+<path d="M12 25.5C9.49999 25.5 2.99999 33.5 -1.43051e-05 37C-0.833348 37.6667 -2.60001 39.2 -3.00001 40C-3.40001 40.8 -2.16668 48.3333 -1.50001 52H36.5L36 36.5C31.6694 32.7521 29.5 29.5 28 29.5C26.5 29.5 22 33.5 22 33.5C15 26 14.2555 25.5 12 25.5Z" fill="var(--icon-muted, currentColor)"/>
+</g>
+<rect x="41" y="20" width="23" height="3" rx="1.5" fill="var(--icon-fg, currentColor)"/>
+<rect x="41" y="26" width="12" height="3" rx="1.5" fill="var(--icon-fg, currentColor)"/>
+<circle cx="26" cy="19" r="4" fill="var(--icon-soft, var(--icon-muted, currentColor))"/>
+</svg>
diff --git a/client/stores/working_form.js b/client/stores/working_form.js
index f52376c43..993cc6eb9 100644
--- a/client/stores/working_form.js
+++ b/client/stores/working_form.js
@@ -21,6 +21,9 @@ export const useWorkingFormStore = defineStore("working_form", {
// Structure service instance - will be set from useFormManager
structureService: null,
+
+ // Animation state
+ sidebarBounce: false,
}),
getters: {
// Get all blocks/properties in the form
@@ -44,7 +47,8 @@ export const useWorkingFormStore = defineStore("working_form", {
// Current page index from structure service
formPageIndex() {
if (!this.structureService) return 0
- return this.structureService.currentPage
+ const cp = this.structureService.currentPage
+ return (typeof cp === 'number') ? cp : (cp?.value || 0)
}
},
actions: {
@@ -99,10 +103,16 @@ export const useWorkingFormStore = defineStore("working_form", {
setEditingField(field) {
this.selectedFieldIndex = this.objectToIndex(field)
},
- openSettingsForField(field) {
+ openSettingsForField(field, triggerBounce = false) {
const targetIndex = this.objectToIndex(field)
const previousIndex = this.selectedFieldIndex
+ // Check if sidebar is already open for the same field and bounce is requested
+ if (triggerBounce && this.showEditFieldSidebar && targetIndex === previousIndex) {
+ this.triggerSidebarBounce()
+ return
+ }
+
this.selectedFieldIndex = targetIndex
this.showEditFieldSidebar = true
this.showAddFieldSidebar = false
@@ -130,6 +140,11 @@ export const useWorkingFormStore = defineStore("working_form", {
this.selectedFieldIndex = null
this.showAddFieldSidebar = false
},
+ closeAllSidebars() {
+ this.selectedFieldIndex = null
+ this.showEditFieldSidebar = false
+ this.showAddFieldSidebar = false
+ },
reset() {
this.content = null
this.selectedFieldIndex = null
@@ -275,6 +290,19 @@ export const useWorkingFormStore = defineStore("working_form", {
removeField(field) {
this.internalRemoveField(field)
},
+ duplicateField(fieldOrIndex) {
+ if (!this.content?.properties) return
+ const index = this.objectToIndex(fieldOrIndex)
+ if (index === -1) return
+ const fields = clonedeep(this.content.properties)
+ const source = fields[index]
+ const cloned = clonedeep(source)
+ cloned.id = generateUUID()
+ if (cloned.name) cloned.name = `Copy of ${cloned.name}`
+ fields.splice(index + 1, 0, cloned)
+ this.setProperties(fields)
+ this.openSettingsForField(index + 1)
+ },
internalRemoveField(field) {
const index = this.objectToIndex(field)
@@ -306,6 +334,15 @@ export const useWorkingFormStore = defineStore("working_form", {
newFields.splice(validNewIndex, 0, field)
this.setProperties(newFields)
+ },
+
+ // Trigger sidebar bounce animation
+ triggerSidebarBounce() {
+ this.sidebarBounce = true
+ // Reset after animation duration
+ setTimeout(() => {
+ this.sidebarBounce = false
+ }, 600)
}
},
history: {