Skip to content

Beautiful Open-Source Form Builder

Optimize public form loading and lazy-load editor features (#1290)

Julien Nahum509b7fdb555d
diff --git a/api/app/Http/Requests/AnswerFormRequest.php b/api/app/Http/Requests/AnswerFormRequest.php
index 2e01af69d..1a129c1df 100644
--- a/api/app/Http/Requests/AnswerFormRequest.php
+++ b/api/app/Http/Requests/AnswerFormRequest.php
@@ -59,33 +59,36 @@ class AnswerFormRequest extends FormRequest
$selectionFields = collect($this->form->properties)->filter(function ($pro) {
return in_array($pro['type'], ['select', 'multi_select']);
});
+ $data = $this->toArray();
+
+ // Use option names instead of IDs when evaluating conditional logic. Public
+ // forms expose options at the field root while editor data can still use
+ // the legacy type-specific nesting.
+ foreach ($selectionFields as $field) {
+ $options = $field[$field['type']]['options'] ?? $field['options'] ?? [];
+
+ if (isset($data[$field['id']]) && is_array($data[$field['id']])) {
+ $data[$field['id']] = array_map(function ($val) use ($options) {
+ $tmpop = collect($options)->first(function ($op) use ($val) {
+ return isset($op['id'], $op['name']) && ($op['id'] === $val || $op['name'] === $val);
+ });
+ return isset($tmpop['name']) ? $tmpop['name'] : $val;
+ }, $data[$field['id']]);
+ } elseif (isset($data[$field['id']])) {
+ $tmpop = collect($options)->first(function ($op) use ($field, $data) {
+ return isset($op['id'], $op['name']) && ($op['id'] === $data[$field['id']] || $op['name'] === $data[$field['id']]);
+ });
+ $data[$field['id']] = isset($tmpop['name']) ? $tmpop['name'] : $data[$field['id']];
+ }
+ }
+
foreach ($this->form->properties as $property) {
$rules = [];
- $data = $this->toArray();
-
// User custom validation
if (!(Str::of($property['type'])->startsWith('nf-')) && isset($property['validation'])) {
$rules[] = (new CustomFieldValidationRule($property['validation'], $data, $this->form));
}
-
- // For get values instead of Id for select/multi select options
- foreach ($selectionFields as $field) {
- if (isset($data[$field['id']]) && is_array($data[$field['id']])) {
- $data[$field['id']] = array_map(function ($val) use ($field) {
- $tmpop = collect($field[$field['type']]['options'])->first(function ($op) use ($val) {
- return isset($op['id'], $op['name']) && ($op['id'] === $val || $op['name'] === $val);
- });
- return isset($tmpop['name']) ? $tmpop['name'] : $val;
- }, $data[$field['id']]);
- } elseif (isset($data[$field['id']])) {
- // Handle single select values
- $tmpop = collect($field[$field['type']]['options'])->first(function ($op) use ($field, $data) {
- return isset($op['id'], $op['name']) && ($op['id'] === $data[$field['id']] || $op['name'] === $data[$field['id']]);
- });
- $data[$field['id']] = isset($tmpop['name']) ? $tmpop['name'] : $data[$field['id']];
- }
- }
if (
FormLogicPropertyResolver::isRequired($property, $data, $this->form) &&
!FormLogicPropertyResolver::isHidden($property, $data, $this->form)
@@ -284,11 +287,9 @@ class AnswerFormRequest extends FormRequest
private function getSelectPropertyOptions($property): array
{
$type = $property['type'];
- if (!isset($property[$type])) {
- return [];
- }
+ $options = $property[$type]['options'] ?? $property['options'] ?? [];
- return array_column($property[$type]['options'], 'name');
+ return array_column($options, 'name');
}
protected function prepareForValidation()
diff --git a/api/app/Http/Resources/FormResource.php b/api/app/Http/Resources/FormResource.php
index b89cec43d..5dc6feca6 100644
--- a/api/app/Http/Resources/FormResource.php
+++ b/api/app/Http/Resources/FormResource.php
@@ -20,13 +20,15 @@ class FormResource extends JsonResource
*/
public function toArray($request)
{
- if (!$this->userIsFormOwner() && ProtectedForm::isProtected($request, $this->resource)) {
+ $userIsFormOwner = $this->userIsFormOwner();
+
+ if (!$userIsFormOwner && ProtectedForm::isProtected($request, $this->resource)) {
return $this->getProtectedForm();
}
// Owner/Member view: readonly members can see everything except password
$ownerData = [];
- if ($this->userIsFormOwner()) {
+ if ($userIsFormOwner) {
$ownerData = [
'views_count' => $this->views_count,
'submissions_count' => $this->submissions_count,
@@ -56,7 +58,7 @@ class FormResource extends JsonResource
'plan_tier' => $this->workspace->plan_tier ?? 'free',
'is_trialing' => $this->workspaceIsTrialing(),
'workspace_id' => $this->workspace_id,
- 'workspace' => $this->userIsFormOwner()
+ 'workspace' => $userIsFormOwner
? new WorkspaceResource($this->workspace)
: (new WorkspaceResource($this->workspace))->restrictForGuest(),
'is_closed' => $this->is_closed,
@@ -71,6 +73,7 @@ class FormResource extends JsonResource
'cover_settings' => $this->cover_settings ?? new \stdClass(),
'translations' => $this->translations ?? new \stdClass(),
'computed_variables' => $this->computed_variables ?? [],
+ 'viewer_is_form_creator' => Auth::id() === $this->creator_id,
]);
$data['no_branding'] = app(BrandingPolicy::class)->canRemoveFormBranding($this->resource);
@@ -110,6 +113,7 @@ class FormResource extends JsonResource
'seo_meta' => $this->seo_meta,
'cover_picture' => $this->cover_picture,
'cover_settings' => $this->cover_settings ?? new \stdClass(),
+ 'viewer_is_form_creator' => false,
];
}
diff --git a/api/tests/Feature/Forms/FormTest.php b/api/tests/Feature/Forms/FormTest.php
index fa5c44e0e..a6213fc71 100644
--- a/api/tests/Feature/Forms/FormTest.php
+++ b/api/tests/Feature/Forms/FormTest.php
@@ -123,7 +123,8 @@ it('can fetch a form', function () {
->assertSuccessful()
->assertJson([
'id' => $form->id,
- 'title' => $form->title
+ 'title' => $form->title,
+ 'viewer_is_form_creator' => true,
]);
});
@@ -150,6 +151,7 @@ it('does not leak workspace details on public form fetch', function () {
$response = $this->getJson(route('forms.show', $form->slug))
->assertSuccessful()
->assertJsonPath('id', $form->id)
+ ->assertJsonPath('viewer_is_form_creator', false)
->assertJsonPath('workspace_id', $workspace->id)
->assertJsonPath('workspace.id', $workspace->id)
->assertJsonPath('workspace.max_file_size', $workspace->max_file_size / 1000000);
diff --git a/api/tests/Feature/Submissions/SubmissionTest.php b/api/tests/Feature/Submissions/SubmissionTest.php
index bccc7e589..26c229816 100644
--- a/api/tests/Feature/Submissions/SubmissionTest.php
+++ b/api/tests/Feature/Submissions/SubmissionTest.php
@@ -28,6 +28,32 @@ it('can delete form submission', function () {
expect(Version::query()->whereIn('version_id', $versionIds)->count())->toBe(0);
});
+it('can submit a select whose public options are stored at the field root', function () {
+ $user = $this->actingAsUser();
+ $workspace = $this->createUserWorkspace($user);
+ $form = $this->createForm($user, $workspace);
+ $properties = $form->properties;
+ $selectIndex = collect($properties)->search(fn ($property) => $property['type'] === 'select');
+ $select = $properties[$selectIndex];
+ $select['options'] = $select['select']['options'];
+ $select['options'][0]['id'] = 'first-option-id';
+ $select['options'][0]['name'] = 'First option';
+ unset($select['select']);
+ $properties[$selectIndex] = $select;
+ $form->update(['properties' => $properties]);
+
+ $formData = $this->generateFormSubmissionData($form, [
+ $select['id'] => $select['options'][0]['name'],
+ ]);
+
+ $this->postJson(route('forms.answer', $form->slug), $formData)
+ ->assertSuccessful()
+ ->assertJson([
+ 'type' => 'success',
+ 'message' => 'Form submission saved.',
+ ]);
+});
+
it('can delete multiple form submissions', function () {
$user = $this->actingAsUser();
$workspace = $this->createUserWorkspace($user);
diff --git a/client/app.vue b/client/app.vue
index 712468c15..48144bc3f 100644
--- a/client/app.vue
+++ b/client/app.vue
@@ -15,23 +15,19 @@
class="fixed z-[9999] left-0 bottom-0 p-4" id="admin-actions"
>
<UButtonGroup size="sm">
- <ToolsStopImpersonation />
+ <LazyToolsStopImpersonation />
</UButtonGroup>
</div>
- <Clarity />
- <FeatureBase />
- <SubscriptionModal />
- <QuickRegister />
+ <LazyVendorClarity />
+ <LazyVendorFeatureBase />
+ <LazyQuickRegister />
</ClientOnly>
</div>
</AppProvider>
</template>
<script setup>
-import FeatureBase from "~/components/vendor/FeatureBase.vue"
-import Clarity from "~/components/vendor/Clarity.vue"
-
const config = useRuntimeConfig()
const route = useRoute()
diff --git a/client/components/forms/core/TextBlock.vue b/client/components/forms/core/TextBlock.vue
index 83f401a59..d8c99b800 100644
--- a/client/components/forms/core/TextBlock.vue
+++ b/client/components/forms/core/TextBlock.vue
@@ -17,11 +17,11 @@
</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'
+import { loadMentionParser } from '~/lib/forms/mention-parser-loader.js'
const props = defineProps({
content: { type: String, required: true },
@@ -35,17 +35,27 @@ const props = defineProps({
ui: { type: Object, default: () => ({}) }
})
-// Compute initial value inline to avoid flash of unprocessed content
+const mentionParser = shallowRef(null)
+
+watch(() => [props.content, props.mentionsAllowed], ([content, mentionsAllowed]) => {
+ if (!mentionsAllowed || !content?.includes('mention-field-id') || mentionParser.value) return
+ loadMentionParser()
+ .then((parser) => {
+ mentionParser.value = parser
+ })
+ .catch((error) => console.error('Failed to load the mention parser:', error))
+}, { immediate: true })
+
const computeProcessedContent = () => {
- if (props.mentionsAllowed && props.form && props.formData) {
- return useParseMention(props.content, props.mentionsAllowed, props.form, props.formData, props.computedValues)
+ if (mentionParser.value && props.mentionsAllowed && props.form && props.formData) {
+ return mentionParser.value(props.content, props.mentionsAllowed, props.form, props.formData, props.computedValues)
}
return props.content
}
const processedContent = ref(computeProcessedContent())
-watch(() => [props.content, props.mentionsAllowed, props.form, props.formData, props.computedValues], () => {
+watch(() => [props.content, props.mentionsAllowed, props.form, props.formData, props.computedValues, mentionParser.value], () => {
processedContent.value = computeProcessedContent()
})
diff --git a/client/components/forms/core/components/InputWrapper.vue b/client/components/forms/core/components/InputWrapper.vue
index 6944456be..6a330ee35 100644
--- a/client/components/forms/core/components/InputWrapper.vue
+++ b/client/components/forms/core/components/InputWrapper.vue
@@ -80,7 +80,6 @@
import { computed, inject, ref } from 'vue'
import InputLabel from './InputLabel.vue'
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'
@@ -121,7 +120,7 @@ const ui = computed(() => {
})
// Wrapper classes with twMerge operation - makes sense as computed property
-const wrapperClasses = computed(() => twMerge(ui.value.wrapper(), props.wrapperClass))
+const wrapperClasses = computed(() => ui.value.wrapper({ class: props.wrapperClass }))
const presentationStyle = computed(() => injectedPresentationStyle.value)
</script>
diff --git a/client/components/forms/core/components/VSelect.vue b/client/components/forms/core/components/VSelect.vue
index edfa98ba4..9cea2df3d 100644
--- a/client/components/forms/core/components/VSelect.vue
+++ b/client/components/forms/core/components/VSelect.vue
@@ -264,11 +264,21 @@
</template>
<script>
-import debounce from 'debounce'
-import Fuse from 'fuse.js'
import { tv } from "tailwind-variants"
import { vSelectTheme } from "~/lib/forms/themes/v-select.theme.js"
-import { useVirtualizer } from '@tanstack/vue-virtual'
+
+let fuseModulePromise = null
+let virtualizerModulePromise = null
+
+function createDebounced(callback, delay) {
+ let timeoutId = null
+ const debounced = (...args) => {
+ clearTimeout(timeoutId)
+ timeoutId = setTimeout(() => callback(...args), delay)
+ }
+ debounced.clear = () => clearTimeout(timeoutId)
+ return debounced
+}
export default {
name: 'VSelect',
@@ -310,6 +320,8 @@ export default {
fuseOptions: { type: Object, default: () => ({}) },
searchDebounceMs: { type: Number, default: 150 },
minSearchLength: { type: Number, default: 1 },
+ fuzzySearchThreshold: { type: Number, default: 0 },
+ virtualizationThreshold: { type: Number, default: 100 },
// Explicit popover width control. Accepts number (px) or CSS length string.
popoverWidth: { type: [String, Number], default: null }
},
@@ -389,7 +401,7 @@ export default {
},
debouncedRemote () {
if (this.remote) {
- return debounce(this.remote, 300)
+ return createDebounced(this.remote, 300)
}
return null
},
@@ -406,11 +418,7 @@ export default {
return this.data
}
- // Ensure Fuse is ready
- if (!this.fuse) {
- this.buildFuse()
- }
- if (!this.fuse) return this.data
+ if (!this.fuse) return this.filterOptionsSimply(term)
return this.fuse.search(term).map((res) => res.item)
},
@@ -458,12 +466,15 @@ export default {
} else {
// Local search path: debounce updates
if (this.updateDebouncedTerm) this.updateDebouncedTerm(val)
+ if (val?.length >= this.minSearchLength) this.ensureFuse()
}
},
data () {
// Only (re)build fuse when using local search
if (this.searchable && !this.remote) {
- this.buildFuse()
+ this.fuse = null
+ this.fuseIndex = null
+ if (this.debouncedTerm?.length >= this.minSearchLength) this.ensureFuse()
} else {
this.fuse = null
this.fuseIndex = null
@@ -510,9 +521,7 @@ export default {
}
},
mounted () {
- // Initialize fuse for local search and debounce handler
- this.buildFuse()
- this.updateDebouncedTerm = debounce((val) => {
+ this.updateDebouncedTerm = createDebounced((val) => {
this.debouncedTerm = val
}, this.searchDebounceMs)
},
@@ -529,29 +538,45 @@ export default {
optionId(index) {
return `${this.controlId}-option-${index}`
},
- buildFuse () {
- if (!this.data || !Array.isArray(this.data) || this.data.length === 0) {
- this.fuse = null
- this.fuseIndex = null
- return
+ filterOptionsSimply (term) {
+ const normalizedTerm = String(term).toLocaleLowerCase()
+ return this.data.filter((item) => this.searchKeys.some((key) => {
+ const value = key.split('.').reduce((current, segment) => current?.[segment], item)
+ return String(value ?? '').toLocaleLowerCase().includes(normalizedTerm)
+ }))
+ },
+ ensureFuse () {
+ if (
+ this.fuse ||
+ this.remote ||
+ !this.searchable ||
+ !Array.isArray(this.data) ||
+ this.data.length < this.fuzzySearchThreshold
+ ) {
+ return Promise.resolve(this.fuse)
}
- const options = Object.assign({
- keys: this.searchKeys,
- threshold: 0.3,
- ignoreLocation: true,
- includeScore: false
- }, this.fuseOptions || {})
-
- try {
- const index = Fuse.createIndex(options.keys, this.data)
- this.fuseIndex = index
- this.fuse = new Fuse(this.data, options, index)
- } catch {
- // Fallback without precomputed index
- this.fuse = new Fuse(this.data, options)
- this.fuseIndex = null
- }
+ fuseModulePromise ||= import('fuse.js')
+ return fuseModulePromise.then(({ default: Fuse }) => {
+ if (!this.data?.length) return null
+
+ const options = Object.assign({
+ keys: this.searchKeys,
+ threshold: 0.3,
+ ignoreLocation: true,
+ includeScore: false
+ }, this.fuseOptions || {})
+
+ try {
+ const index = Fuse.createIndex(options.keys, this.data)
+ this.fuseIndex = index
+ this.fuse = new Fuse(this.data, options, index)
+ } catch {
+ this.fuse = new Fuse(this.data, options)
+ this.fuseIndex = null
+ }
+ return this.fuse
+ })
},
setupVirtualizer () {
const scrollEl = this.$refs.scrollRef
@@ -583,14 +608,22 @@ export default {
return
}
- this.virtualizer = useVirtualizer({
- count: this.filteredOptions.length,
- getScrollElement: () => this.$refs.scrollRef,
- estimateSize: () => this.estimatedItemSizePx,
- overscan: 5
- })
+ if (this.filteredOptions.length < this.virtualizationThreshold) {
+ restoreScroll()
+ return
+ }
- restoreScroll()
+ virtualizerModulePromise ||= import('@tanstack/vue-virtual')
+ virtualizerModulePromise.then(({ useVirtualizer }) => {
+ if (!this.isOpen || !this.$refs.scrollRef) return
+ this.virtualizer = useVirtualizer({
+ count: this.filteredOptions.length,
+ getScrollElement: () => this.$refs.scrollRef,
+ estimateSize: () => this.estimatedItemSizePx,
+ overscan: 5
+ })
+ restoreScroll()
+ })
},
isSelected (value) {
if (!this.modelValue) return false
diff --git a/client/components/global/OverlayScrollbarsComponent.client.vue b/client/components/global/OverlayScrollbarsComponent.client.vue
new file mode 100644
index 000000000..6a00404cc
--- /dev/null
+++ b/client/components/global/OverlayScrollbarsComponent.client.vue
@@ -0,0 +1,83 @@
+<template>
+ <div
+ ref="host"
+ v-bind="attrs"
+ >
+ <slot />
+ </div>
+</template>
+
+<script setup>
+defineOptions({ inheritAttrs: false })
+
+const attrs = useAttrs()
+const props = defineProps({
+ defer: { type: Boolean, default: false },
+ options: { type: Object, default: () => ({}) },
+})
+const host = ref(null)
+const instance = shallowRef(null)
+let cancelInitialization = null
+
+const scrollbarOptions = {
+ overflow: { x: 'hidden', y: 'scroll' },
+ scrollbars: {
+ theme: 'os-theme-dark',
+ visibility: 'auto',
+ autoHide: 'never',
+ autoHideDelay: 800,
+ autoHideSuspend: true,
+ },
+}
+
+const mergedOptions = computed(() => ({ ...scrollbarOptions, ...props.options }))
+
+function initialize() {
+ const focusedElement = host.value?.contains(document.activeElement)
+ ? document.activeElement
+ : null
+
+ Promise.all([
+ import('overlayscrollbars/overlayscrollbars.css'),
+ import('overlayscrollbars'),
+ ]).then(([, { OverlayScrollbars }]) => {
+ if (!host.value) return
+ instance.value = OverlayScrollbars(host.value, mergedOptions.value)
+ focusedElement?.focus?.({ preventScroll: true })
+ }).catch((error) => {
+ // Native scrolling remains fully functional if the optional enhancement
+ // cannot be downloaded.
+ console.error('Failed to load OverlayScrollbars:', error)
+ })
+}
+
+onMounted(() => {
+ if (!props.defer) {
+ initialize()
+ return
+ }
+
+ if ('requestIdleCallback' in window) {
+ const idleCallbackId = window.requestIdleCallback(initialize)
+ cancelInitialization = () => window.cancelIdleCallback(idleCallbackId)
+ return
+ }
+
+ const timeoutId = window.setTimeout(initialize, 0)
+ cancelInitialization = () => window.clearTimeout(timeoutId)
+})
+
+watch(mergedOptions, (options) => {
+ instance.value?.options(options)
+}, { deep: true })
+
+onBeforeUnmount(() => {
+ cancelInitialization?.()
+ instance.value?.destroy()
+})
+
+defineExpose({
+ osInstance: () => instance.value,
+ getElement: () => host.value,
+})
+</script>
diff --git a/client/components/open/editors/EditorRightSidebar.vue b/client/components/open/editors/EditorRightSidebar.vue
index 3f6beda2a..bc1189eb7 100644
--- a/client/components/open/editors/EditorRightSidebar.vue
+++ b/client/components/open/editors/EditorRightSidebar.vue
@@ -1,5 +1,5 @@
<template>
- <transition @leave="(el, done) => sidebarMotion?.leave(done)">
+ <transition name="slide-right">
<div
v-if="show"
ref="elementRef"
@@ -27,8 +27,7 @@
</template>
<script setup>
-import { slideRight, useMotion } from '@vueuse/motion'
-import { watch, computed } from 'vue'
+import { computed } from 'vue'
import { useResizable } from '~/composables/components/useResizable'
import ResizeHandle from '@/components/global/ResizeHandle.vue'
@@ -60,21 +59,19 @@ const {
maxWidth: () => Math.min(600, window.innerWidth * 0.6)
})
-// Motion animation
-const sidebarMotion = ref(null)
-
// Enable resizing only when prop is true and breakpoint allows it
const isResizable = computed(() => props.resizable && isResizableBase.value)
-
-// Watch for show prop changes (existing functionality)
-watch(
- () => props.show,
- (newVal) => {
- if (newVal) {
- nextTick(() => {
- sidebarMotion.value = useMotion(elementRef.value, slideRight)
- })
- }
- },
-)
</script>
+
+<style scoped>
+.slide-right-enter-active,
+.slide-right-leave-active {
+ transition: opacity 180ms ease, transform 180ms ease;
+}
+
+.slide-right-enter-from,
+.slide-right-leave-to {
+ opacity: 0;
+ transform: translateX(100%);
+}
+</style>
diff --git a/client/components/open/forms/BlockRenderer.vue b/client/components/open/forms/BlockRenderer.vue
index 6269d7f35..bd0120203 100644
--- a/client/components/open/forms/BlockRenderer.vue
+++ b/client/components/open/forms/BlockRenderer.vue
@@ -95,7 +95,7 @@
@click.prevent="editFieldOptions"
>Open block settings to add video URL.</a>
</div>
- <EmbedMedia
+ <LazyEmbedMedia
v-else
:src="block.video_block"
:is-dark="darkMode"
@@ -119,7 +119,7 @@
@click.prevent="editFieldOptions"
>Open block settings to add audio.</a>
</div>
- <EmbedMedia
+ <LazyEmbedMedia
v-else
:src="block.audio_block"
:force-audio="true"
@@ -135,16 +135,15 @@ import ClientOnlyWrapper from '~/components/global/ClientOnlyWrapper.vue'
import { useComponentRegistry } from '~/composables/components/useComponentRegistry'
import TextBlock from '~/components/forms/core/TextBlock.vue'
import { shuffleArray } from '~/lib/utils.js'
-import { useWorkingFormStore } from '~/stores/working_form'
-import { useParseMention } from '@/composables/components/useParseMention'
+import { getFieldOptions } from '~/lib/forms/field-options.js'
+import { loadMentionParser } from '~/lib/forms/mention-parser-loader.js'
const props = defineProps({
block: { type: Object, required: false, default: null },
formManager: { type: Object, required: true }
})
-const workingFormStore = useWorkingFormStore()
-
+const nuxtApp = useNuxtApp()
const form = computed(() => props.formManager?.config?.value || {})
const dataForm = computed(() => props.formManager?.form || {})
const darkMode = computed(() => props.formManager?.darkMode?.value || false)
@@ -156,6 +155,28 @@ const disableCustomCodeExecution = inject('disableCustomCodeExecution', false)
const formDataForMentions = computed(() => dataForm.value?.data?.() || {})
const debouncedFormData = refDebounced(formDataForMentions, 300)
const computedValues = computed(() => props.formManager?.computedValues?.value || {})
+const mentionParser = shallowRef(null)
+
+const needsMentionParser = computed(() => {
+ const field = props.block || {}
+ return [
+ field.content,
+ field.placeholder,
+ field.help,
+ field.amount,
+ field.prefill_name,
+ field.prefill_email,
+ ].some(value => typeof value === 'string' && value.includes('mention-field-id'))
+})
+
+watch(needsMentionParser, (isNeeded) => {
+ if (!isNeeded || mentionParser.value) return
+ loadMentionParser()
+ .then((parser) => {
+ mentionParser.value = parser
+ })
+ .catch((error) => console.error('Failed to load the mention parser:', error))
+}, { immediate: true })
// Use centralized fieldState from manager
const fieldState = computed(() => props.formManager?.fieldState)
@@ -250,11 +271,7 @@ const roundedClass = computed(() => {
const selectOptions = computed(() => {
const field = props.block
if (!field || !['select', 'multi_select'].includes(field.type)) return null
- const options = field[field.type]?.options?.map(option => ({
- name: option.name,
- value: option.name,
- image: option.image || null // Include image if present
- })) ?? []
+ const options = getFieldOptions(field)
return field.shuffle_options && options.length > 1 ? shuffleArray(options) : options
})
@@ -262,7 +279,9 @@ const selectOptions = computed(() => {
// Set asText=true to strip HTML (for plain text attributes like placeholder)
const processMention = (content, { asText = false } = {}) => {
if (!content) return content
- const processed = useParseMention(content, true, form.value, debouncedFormData.value, computedValues.value)
+ const processed = mentionParser.value
+ ? mentionParser.value(content, true, form.value, debouncedFormData.value, computedValues.value)
+ : content
if (!processed) return content
if (!asText) return processed
// Strip HTML tags to get plain text
@@ -273,7 +292,7 @@ const processMention = (content, { asText = false } = {}) => {
const processedPlaceholder = ref('')
const processedHelp = ref('')
-watch(() => [props.block?.placeholder, props.block?.help, debouncedFormData.value, computedValues.value], () => {
+watch(() => [props.block?.placeholder, props.block?.help, debouncedFormData.value, computedValues.value, mentionParser.value], () => {
const field = props.block
if (!field) {
processedPlaceholder.value = ''
@@ -366,7 +385,7 @@ const boundProps = computed(() => {
inputProperties.direction = form.value.layout_rtl ? 'rtl' : 'ltr'
inputProperties.currency = field.currency
// Parse amount with mentions - field.amount may contain mention HTML
- const parsedAmount = useParseMention(field.amount, true, form.value, dataForm.value)
+ const parsedAmount = processMention(field.amount, { asText: true })
const sanitizedAmount = String(parsedAmount ?? '')
.replace(/<[^>]*>/g, '')
.replace(/,/g, '')
@@ -378,11 +397,11 @@ const boundProps = computed(() => {
// Parse prefill fields with mentions
if (field.prefill_name) {
- const parsed = useParseMention(field.prefill_name, true, form.value, dataForm.value)
+ const parsed = processMention(field.prefill_name, { asText: true })
inputProperties.prefillName = String(parsed ?? '').replace(/<[^>]*>/g, '').trim()
}
if (field.prefill_email) {
- const parsed = useParseMention(field.prefill_email, true, form.value, dataForm.value)
+ const parsed = processMention(field.prefill_email, { asText: true })
inputProperties.prefillEmail = String(parsed ?? '').replace(/<[^>]*>/g, '').trim()
}
if (props.formManager?.payment) {
@@ -394,6 +413,9 @@ const boundProps = computed(() => {
})
const editFieldOptions = () => {
- workingFormStore.openSettingsForField(props.block, true)
+ if (!isAdminPreview.value) return
+ import('~/stores/working_form').then(({ useWorkingFormStore }) => {
+ nuxtApp.runWithContext(() => useWorkingFormStore()).openSettingsForField(props.block, true)
+ })
}
</script>
diff --git a/client/components/open/forms/OpenCompleteForm.vue b/client/components/open/forms/OpenCompleteForm.vue
index 54700255e..29622b367 100644
--- a/client/components/open/forms/OpenCompleteForm.vue
+++ b/client/components/open/forms/OpenCompleteForm.vue
@@ -5,6 +5,15 @@
:dir="form?.layout_rtl ? 'rtl' : 'ltr'"
:style="formStyle"
>
+ <ClientOnly>
+ <LazyOpenFormsComponentsSdkBridgeHost
+ v-if="shouldLoadSdkBridge"
+ :form="form"
+ :form-manager="formManager"
+ :dark-mode="darkMode"
+ @ready="handleSdkBridgeReady"
+ />
+ </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" />
@@ -62,8 +71,9 @@
</template>
<template #cleanings>
- <form-cleanings
- v-if="showFormCleanings"
+ <component
+ :is="FormCleanings"
+ v-if="shouldShowFormCleanings"
:hideable="true"
class="mb-4 mx-2"
:form="form"
@@ -115,8 +125,10 @@
</v-transition>
<template v-if="!isAutoSubmit">
- <FirstSubmissionModal
- :show="showFirstSubmissionModal"
+ <component
+ :is="FirstSubmissionModal"
+ v-if="showFirstSubmissionModal"
+ :show="true"
:form="form"
@close="showFirstSubmissionModal=false"
/>
@@ -127,12 +139,8 @@
<script setup>
import { useFormManager } from '~/lib/forms/composables/useFormManager'
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 { useForm } from '~/composables/useForm'
import { useAlert } from '~/composables/useAlert'
import { useI18n } from 'vue-i18n'
@@ -140,10 +148,14 @@ import { useIsIframe } from '~/composables/useIsIframe'
import Loader from '~/components/global/Loader.vue'
import { tailwindcssPaletteGenerator } from '~/lib/colors.js'
import { useRouter } from 'vue-router'
-import { useSdkBridge } from '~/lib/sdk/useSdkBridge'
import { clearFormatterCache } from '~/components/forms/components/FormSubmissionFormatter.js'
-import { clearMentionCache } from '~/composables/components/useParseMention.js'
import { formsApi } from '~/api'
+import { clearLoadedMentionCache } from '~/lib/forms/mention-parser-loader.js'
+
+const OpenForm = defineAsyncComponent(() => import('./OpenForm.vue'))
+const OpenFormFocused = defineAsyncComponent(() => import('./OpenFormFocused.vue'))
+const FormCleanings = defineAsyncComponent(() => import('../../pages/forms/show/FormCleanings.vue'))
+const FirstSubmissionModal = defineAsyncComponent(() => import('~/components/open/forms/components/FirstSubmissionModal.vue'))
const props = defineProps({
form: { type: Object, required: true },
@@ -163,9 +175,9 @@ const emit = defineEmits(['submitted', 'password-entered', 'restarted'])
const { t, setLocale } = useI18n()
const route = useRoute()
const router = useRouter()
+const nuxtApp = useNuxtApp()
const alert = useAlert()
-const workingFormStore = useWorkingFormStore()
-const { data: user } = useAuth().user()
+const workingFormStore = shallowRef(null)
const passwordForm = useForm({ password: null })
// Removed unused hidePasswordDisabledMsg (was always false and unused)
// submission_id is a public UUID identifier
@@ -191,7 +203,11 @@ provide('formBorderRadius', computed(() => props.form.border_radius || 'small'))
provide('formPresentationStyle', computed(() => props.form.presentation_style || 'classic'))
let formManager = null
-let sdkBridge = null
+const sdkBridge = shallowRef(null)
+let resolveSdkBridgeReady
+const sdkBridgeReady = new Promise((resolve) => {
+ resolveSdkBridgeReady = resolve
+})
if (props.form) {
formManager = useFormManager(props.form, props.mode, {
darkMode: darkModeRef,
@@ -204,18 +220,6 @@ if (props.form) {
urlParams: new URLSearchParams(queryString),
})
- // Initialize SDK bridge for parent window communication
- const formDataRef = computed(() => formManager.form.data())
- const formErrorsRef = computed(() => formManager.form.errors?.all?.() || {})
-
- sdkBridge = useSdkBridge({
- formConfig: computed(() => props.form),
- formData: formDataRef,
- formErrors: formErrorsRef,
- formManager: formManager,
- darkMode: darkModeRef,
- attribution: formManager.attribution,
- })
}
// Watch for changes to the form prop and update formManager
@@ -235,9 +239,12 @@ watch([
() => formManager?.strategy?.value?.admin?.showAdminControls,
() => formManager?.structure?.value
], ([showAdminControls, struct]) => {
- if (workingFormStore && showAdminControls && struct) {
- workingFormStore.setStructureService(struct)
- }
+ if (!showAdminControls || !struct) return
+
+ import('~/stores/working_form').then(({ useWorkingFormStore }) => {
+ workingFormStore.value ||= nuxtApp.runWithContext(() => useWorkingFormStore())
+ workingFormStore.value.setStructureService(struct)
+ })
}, { immediate: true })
// Add a watcher to update formManager's darkMode whenever darkModeRef changes
@@ -252,7 +259,8 @@ onMounted(() => {
if (isAutoSubmit.value && formManager) {
// Using nextTick to ensure form is fully rendered and initialized
nextTick(async () => {
- await sdkBridge?.waitForHandshake?.()
+ const bridge = shouldLoadSdkBridge.value ? await sdkBridgeReady : null
+ await bridge?.waitForHandshake?.()
triggerSubmit()
})
}
@@ -262,6 +270,26 @@ const isPublicFormPage = computed(() => {
return route.name === 'forms-slug'
})
+const shouldLoadSdkBridge = computed(() => {
+ if (!isPublicFormPage.value) return false
+ const workspaceCustomCode = props.form?.workspace?.settings?.custom_code
+ return useIsIframe() || !!workspaceCustomCode || !!props.form?.custom_code
+})
+
+const handleSdkBridgeReady = (bridge) => {
+ sdkBridge.value = bridge
+ resolveSdkBridgeReady(bridge)
+}
+
+const callSdkBridge = (method, ...args) => {
+ if (!shouldLoadSdkBridge.value) return Promise.resolve()
+ if (sdkBridge.value) {
+ sdkBridge.value[method]?.(...args)
+ return Promise.resolve()
+ }
+ return sdkBridgeReady.then((bridge) => bridge?.[method]?.(...args))
+}
+
const getFontUrl = computed(() => {
if(!props.form?.font_family) return null
const family = props.form.font_family.replace(/ /g, '+')
@@ -269,12 +297,16 @@ const getFontUrl = computed(() => {
})
const isFormOwner = computed(() => {
- const { isAuthenticated } = useIsAuthenticated()
- return isAuthenticated.value && props.form && props.form.creator_id === user.value.id
+ return props.form?.viewer_is_form_creator === true
})
const isProcessing = computed(() => formManager?.state.isProcessing ?? false)
const showFormCleanings = computed(() => formManager?.strategy.value.display.showFormCleanings ?? false)
+const shouldShowFormCleanings = computed(() => (
+ showFormCleanings.value &&
+ isFormOwner.value &&
+ Object.keys(props.form?.cleanings || {}).length > 0
+))
const showFontLink = computed(() => formManager?.strategy.value.display.showFontLink ?? false)
const formStyle = computed(() => {
@@ -330,7 +362,7 @@ onBeforeUnmount(() => {
setLocale('en')
// Clear caches for this form to prevent memory leaks
clearFormatterCache(props.form?.slug)
- clearMentionCache()
+ clearLoadedMentionCache()
})
const handleScrollToError = () => {
@@ -355,7 +387,7 @@ const triggerSubmit = () => {
if (!formManager || isProcessing.value) return
// Emit SDK submitStart event
- sdkBridge?.onSubmitStart()
+ callSdkBridge('onSubmitStart')
formManager.submit({
submissionId: submissionId.value
@@ -368,7 +400,7 @@ const triggerSubmit = () => {
}
// Emit SDK submit success event
- sdkBridge?.onSubmitSuccess({
+ callSdkBridge('onSubmitSuccess', {
data: submittedData.value,
submissionId: result?.submission_id,
completionTime: result?.completion_time
@@ -394,7 +426,7 @@ const triggerSubmit = () => {
// Emit SDK submit error event
const errors = error.data?.errors || error.data || { general: error.message }
- sdkBridge?.onSubmitError(errors)
+ callSdkBridge('onSubmitError', errors)
if (error.response && error.response.status === 422 && error.data) {
alert.formValidationError(error.data)
@@ -433,7 +465,7 @@ const restart = async () => {
})
// Emit SDK reset event
- sdkBridge?.onReset()
+ callSdkBridge('onReset')
emit('restarted', true)
}
diff --git a/client/components/open/forms/OpenForm.vue b/client/components/open/forms/OpenForm.vue
index efa7f6505..96a4c1655 100644
--- a/client/components/open/forms/OpenForm.vue
+++ b/client/components/open/forms/OpenForm.vue
@@ -56,41 +56,30 @@
</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>
+ <LazyOpenFormsComponentsFormFieldsDraggable
+ v-if="allowDragging"
+ :fields="currentFields"
+ :form-manager="formManager"
+ />
+ <div v-else class="grid grid-cols-12 relative transition-all w-full">
+ <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>
+ </div>
</div>
</transition>
<!-- Captcha -->
- <CaptchaWrapper v-if="form.use_captcha && !isSubmitted" :form-manager="formManager" />
+ <LazyCaptchaWrapper v-if="form.use_captcha && !isSubmitted" :form-manager="formManager" />
<!-- Submit, Next and previous buttons -->
<div v-if="shouldDisplayForm" class="flex flex-wrap justify-center w-full">
@@ -156,14 +145,11 @@
</template>
<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'
@@ -173,7 +159,6 @@ const props = defineProps({
const emit = defineEmits(['submit'])
-const workingFormStore = useWorkingFormStore()
const isIframe = useIsIframe()
// Derive everything from formManager
@@ -205,7 +190,6 @@ const currentFieldsPageBreak = computed(() => structure.value?.currentPageBreak?
const previousFieldsPageBreak = computed(() => structure.value?.previousPageBreak?.value ?? null)
const allowDragging = computed(() => strategy.value.admin.allowDragging)
-const draggingNewBlock = computed(() => workingFormStore.draggingNewBlock)
const handlePreviousClick = () => {
props.formManager.previousPage()
@@ -218,25 +202,6 @@ const handleNextClick = () => {
})
}
-const getAbsoluteIndex = (relativeIndex) => {
- return structure.value.getTargetDropIndex(relativeIndex, state.value.currentPage)
-}
-
-const handleDragAdd = (evt) => {
- if (!structure.value) return
- const targetIndex = getAbsoluteIndex(evt.newIndex)
- const payload = evt?.clonedData
- workingFormStore.addBlock(payload, targetIndex, false)
-}
-
-const handleDragUpdate = (evt) => {
- if (!structure.value) return
- const oldTargetIndex = getAbsoluteIndex(evt.oldIndex)
- const newTargetIndex = getAbsoluteIndex(evt.newIndex)
- if (oldTargetIndex !== newTargetIndex) {
- workingFormStore.moveField(oldTargetIndex, newTargetIndex)
- }
-}
const isProcessing = computed(() => props.formManager.state.isProcessing)
@@ -283,9 +248,3 @@ const getFieldWidthClasses = (width) => {
// Branding display control comes from strategy; default to true
const showBranding = computed(() => props.formManager?.strategy?.value?.display?.showBranding ?? true)
</script>
-
-<style lang='scss' scoped>
-.ghost-item {
- @apply bg-blue-100 dark:bg-blue-900 rounded-md;
-}
-</style>
diff --git a/client/components/open/forms/OpenFormField.vue b/client/components/open/forms/OpenFormField.vue
index 7f09f3cd7..b690540cc 100644
--- a/client/components/open/forms/OpenFormField.vue
+++ b/client/components/open/forms/OpenFormField.vue
@@ -8,7 +8,7 @@
:class="[
{
'group/nffield hover:bg-neutral-100/50 relative hover:z-10 transition-colors hover:border-neutral-200 border-dashed border border-transparent box-border dark:hover:border-blue-900 dark:hover:bg-blue-950 rounded-md': isAdminPreview,
- 'cursor-pointer':workingFormStore.showEditFieldSidebar && isAdminPreview,
+ 'cursor-pointer':workingFormStore?.showEditFieldSidebar && isAdminPreview,
'bg-blue-50 hover:!bg-blue-50 dark:bg-neutral-700! dark:hover:bg-neutral-700! rounded-md': beingEdited,
}]"
@click="setFieldAsSelected"
@@ -100,7 +100,6 @@
<script setup>
import { FormMode, createFormModeStrategy } from "~/lib/forms/FormModeStrategy.js"
-import { useWorkingFormStore } from '~/stores/working_form'
import BlockRenderer from './BlockRenderer.vue'
// Define props
@@ -120,11 +119,19 @@ const form = computed(() => props.formManager?.config?.value || {})
const showHidden = computed(() => props.formManager?.strategy?.value?.display?.showHiddenFields || false)
// Setup stores and reactive state
-const workingFormStore = useWorkingFormStore()
-const selectedFieldIndex = computed(() => workingFormStore.selectedFieldIndex)
-const showEditFieldSidebar = computed(() => workingFormStore.showEditFieldSidebar)
+const nuxtApp = useNuxtApp()
const strategy = computed(() => props.formManager?.strategy?.value || createFormModeStrategy(FormMode.LIVE))
const isAdminPreview = computed(() => strategy.value?.admin?.showAdminControls || false)
+const workingFormStore = shallowRef(null)
+const selectedFieldIndex = computed(() => workingFormStore.value?.selectedFieldIndex ?? -1)
+const showEditFieldSidebar = computed(() => workingFormStore.value?.showEditFieldSidebar ?? false)
+
+watch(isAdminPreview, (isAdmin) => {
+ if (!isAdmin || workingFormStore.value) return
+ import('~/stores/working_form').then(({ useWorkingFormStore }) => {
+ workingFormStore.value = nuxtApp.runWithContext(() => useWorkingFormStore())
+ })
+}, { immediate: true })
// Computed properties
// Field rendering is delegated to BlockRenderer
@@ -145,27 +152,27 @@ const beingEdited = computed(() =>
// Methods
function editFieldOptions() {
if (!isAdminPreview.value) return
- workingFormStore.openSettingsForField(props.field, true)
+ workingFormStore.value?.openSettingsForField(props.field, true)
}
function setFieldAsSelected() {
- if (!isAdminPreview.value || !workingFormStore.showEditFieldSidebar) return
- workingFormStore.openSettingsForField(props.field)
+ if (!isAdminPreview.value || !workingFormStore.value?.showEditFieldSidebar) return
+ workingFormStore.value.openSettingsForField(props.field)
}
function fieldDoubleClick() {
if (!isAdminPreview.value) return
- workingFormStore.openSettingsForField(props.field)
+ workingFormStore.value?.openSettingsForField(props.field)
}
function openAddFieldSidebar() {
if (!isAdminPreview.value) return
- workingFormStore.openAddFieldSidebar(props.field)
+ workingFormStore.value?.openAddFieldSidebar(props.field)
}
function removeField() {
if (!isAdminPreview.value) return
- workingFormStore.removeField(props.field)
+ workingFormStore.value?.removeField(props.field)
}
/**
diff --git a/client/components/open/forms/OpenFormFocused.vue b/client/components/open/forms/OpenFormFocused.vue
index 268109515..0b37c2ead 100644
--- a/client/components/open/forms/OpenFormFocused.vue
+++ b/client/components/open/forms/OpenFormFocused.vue
@@ -51,7 +51,7 @@
</div>
<div v-if="!props.formManager?.state.isSubmitted" class="mt-2 flex gap-2" :class="[getFieldAlignClasses(currentBlock), {'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" />
+ <LazyCaptchaWrapper v-if="form.use_captcha" :form-manager="formManager" />
<open-form-button
native-type="button"
:form="form"
@@ -105,7 +105,6 @@ 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'
diff --git a/client/components/open/forms/components/FormEditorNavbar.vue b/client/components/open/forms/components/FormEditorNavbar.vue
index bedbde3dc..3d6c9d304 100644
--- a/client/components/open/forms/components/FormEditorNavbar.vue
+++ b/client/components/open/forms/components/FormEditorNavbar.vue
@@ -31,11 +31,11 @@
@click="settingsModal = true"
/>
<FormSettingsModal
+ v-if="settingsModal"
v-model="settingsModal"
v-model:active-tab="settingsModalActiveTab"
:computed-variable-edit-request="computedVariableEditRequest"
@close="settingsModal = false"
- hydrate-on-interaction
/>
<GitHubStar
@@ -124,11 +124,12 @@
import { storeToRefs } from 'pinia'
import FormHistory from '~/components/open/editors/FormHistory.vue'
import UndoRedo from '~/components/open/editors/UndoRedo.vue'
-import FormSettingsModal from '~/components/open/forms/components/form-components/FormSettingsModal.vue'
import EditableTag from '~/components/app/EditableTag.vue'
import TrackClick from '~/components/global/TrackClick.vue'
import { useFeatureFlag } from '~/composables/useFeatureFlag'
+const FormSettingsModal = defineAsyncComponent(() => import('~/components/open/forms/components/form-components/FormSettingsModal.vue'))
+
defineProps({
backButton: {
type: Boolean,
diff --git a/client/components/open/forms/components/FormFieldsDraggable.vue b/client/components/open/forms/components/FormFieldsDraggable.vue
new file mode 100644
index 000000000..84be021c1
--- /dev/null
+++ b/client/components/open/forms/components/FormFieldsDraggable.vue
@@ -0,0 +1,76 @@
+<template>
+ <VueDraggable
+ :model-value="fields"
+ 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"
+ @add="handleDragAdd"
+ @update="handleDragUpdate"
+ >
+ <div
+ v-for="element in fields"
+ :key="element.id"
+ :class="getFieldWidthClasses(element.width)"
+ >
+ <VTransition name="fadeHeight">
+ <OpenFormField
+ :field="element"
+ :form-manager="formManager"
+ />
+ </VTransition>
+ </div>
+ </VueDraggable>
+</template>
+
+<script setup>
+import { VueDraggable } from 'vue-draggable-plus'
+import OpenFormField from '../OpenFormField.vue'
+
+const props = defineProps({
+ fields: { type: Array, required: true },
+ formManager: { type: Object, required: true },
+})
+
+const workingFormStore = useWorkingFormStore()
+const draggingNewBlock = computed(() => workingFormStore.draggingNewBlock)
+
+function getAbsoluteIndex(relativeIndex) {
+ return props.formManager.structure.value.getTargetDropIndex(
+ relativeIndex,
+ props.formManager.state.currentPage,
+ )
+}
+
+function handleDragAdd(event) {
+ const targetIndex = getAbsoluteIndex(event.newIndex)
+ workingFormStore.addBlock(event?.clonedData, targetIndex, false)
+}
+
+function handleDragUpdate(event) {
+ const oldTargetIndex = getAbsoluteIndex(event.oldIndex)
+ const newTargetIndex = getAbsoluteIndex(event.newIndex)
+ if (oldTargetIndex !== newTargetIndex) {
+ workingFormStore.moveField(oldTargetIndex, newTargetIndex)
+ }
+}
+
+function getFieldWidthClasses(width) {
+ return {
+ '1/2': 'sm:col-span-6 col-span-full',
+ '1/3': 'sm:col-span-4 col-span-full',
+ '2/3': 'sm:col-span-8 col-span-full',
+ '1/4': 'sm:col-span-3 col-span-full',
+ '3/4': 'sm:col-span-9 col-span-full',
+ }[width] || 'col-span-full'
+}
+</script>
+
+<style lang="scss" scoped>
+.ghost-item {
+ @apply bg-blue-100 dark:bg-blue-900 rounded-md;
+}
+</style>
diff --git a/client/components/open/forms/components/SdkBridgeHost.client.vue b/client/components/open/forms/components/SdkBridgeHost.client.vue
new file mode 100644
index 000000000..d48b25e3b
--- /dev/null
+++ b/client/components/open/forms/components/SdkBridgeHost.client.vue
@@ -0,0 +1,28 @@
+<template>
+ <span class="hidden" aria-hidden="true" />
+</template>
+
+<script setup>
+import { useSdkBridge } from '~/lib/sdk/useSdkBridge'
+
+const props = defineProps({
+ form: { type: Object, required: true },
+ formManager: { type: Object, required: true },
+ darkMode: { type: Boolean, default: false },
+})
+
+const emit = defineEmits(['ready'])
+
+const bridge = useSdkBridge({
+ formConfig: toRef(props, 'form'),
+ formData: computed(() => props.formManager.form.data()),
+ formErrors: computed(() => props.formManager.form.errors?.all?.() || {}),
+ formManager: props.formManager,
+ darkMode: toRef(props, 'darkMode'),
+ attribution: props.formManager.attribution,
+})
+
+emit('ready', bridge)
+
+defineExpose(bridge)
+</script>
diff --git a/client/components/open/forms/components/form-components/FormEditorSidebar.vue b/client/components/open/forms/components/form-components/FormEditorSidebar.vue
index a1415db06..b682ea04c 100644
--- a/client/components/open/forms/components/form-components/FormEditorSidebar.vue
+++ b/client/components/open/forms/components/form-components/FormEditorSidebar.vue
@@ -8,15 +8,13 @@
size="sm"
@submit.prevent=""
>
- <transition mode="out-in">
+ <transition name="fade" mode="out-in">
<form-field-edit
v-if="showEditFieldSidebar"
:key="editFieldIndex"
- v-motion-fade="'fade'"
/>
<add-form-block
v-else-if="showAddFieldSidebar"
- v-motion-fade="'fade'"
/>
</transition>
</VForm>
diff --git a/client/components/open/forms/components/form-components/FormSettingsModal.vue b/client/components/open/forms/components/form-components/FormSettingsModal.vue
index 2f987c643..33927ab93 100644
--- a/client/components/open/forms/components/form-components/FormSettingsModal.vue
+++ b/client/components/open/forms/components/form-components/FormSettingsModal.vue
@@ -66,13 +66,14 @@
<script setup>
import SettingsModal from '~/components/pages/settings/SettingsModal.vue'
import SettingsModalPage from '~/components/pages/settings/SettingsModalPage.vue'
-import FormInformation from '~/components/open/forms/components/form-components/FormInformation.vue'
-import FormSubmissionSettings from '~/components/open/forms/components/form-components/FormSubmissionSettings.vue'
-import FormSecurityAccess from '~/components/open/forms/components/form-components/FormSecurityAccess.vue'
-import FormCustomSeo from '~/components/open/forms/components/form-components/FormCustomSeo.vue'
-import FormCustomCode from '~/components/open/forms/components/form-components/FormCustomCode.vue'
-import ComputedVariablesTab from '~/components/open/forms/components/computed-variables/ComputedVariablesTab.vue'
-import FormAnalyticsSettings from '~/components/open/forms/components/form-components/FormAnalyticsSettings.vue'
+
+const FormInformation = defineAsyncComponent(() => import('~/components/open/forms/components/form-components/FormInformation.vue'))
+const FormSubmissionSettings = defineAsyncComponent(() => import('~/components/open/forms/components/form-components/FormSubmissionSettings.vue'))
+const FormSecurityAccess = defineAsyncComponent(() => import('~/components/open/forms/components/form-components/FormSecurityAccess.vue'))
+const FormCustomSeo = defineAsyncComponent(() => import('~/components/open/forms/components/form-components/FormCustomSeo.vue'))
+const FormCustomCode = defineAsyncComponent(() => import('~/components/open/forms/components/form-components/FormCustomCode.vue'))
+const ComputedVariablesTab = defineAsyncComponent(() => import('~/components/open/forms/components/computed-variables/ComputedVariablesTab.vue'))
+const FormAnalyticsSettings = defineAsyncComponent(() => import('~/components/open/forms/components/form-components/FormAnalyticsSettings.vue'))
const emit = defineEmits(['close', 'update:activeTab'])
diff --git a/client/components/open/forms/fields/components/BlockOptions.vue b/client/components/open/forms/fields/components/BlockOptions.vue
index 8b7ea6a7f..5b08fba60 100644
--- a/client/components/open/forms/fields/components/BlockOptions.vue
+++ b/client/components/open/forms/fields/components/BlockOptions.vue
@@ -142,7 +142,7 @@
v-else-if="field.type == 'nf-code'"
class="border-t mt-6"
>
- <CodeInput
+ <LazyCodeInput
:allow-fullscreen="true"
name="content"
class="mt-4 mx-4"
diff --git a/client/components/pages/comparisons/ComparisonPage.vue b/client/components/pages/comparisons/ComparisonPage.vue
index 3ffb9088f..6f867d3c1 100644
--- a/client/components/pages/comparisons/ComparisonPage.vue
+++ b/client/components/pages/comparisons/ComparisonPage.vue
@@ -705,7 +705,7 @@
<script setup>
import LiveDemo from "~/components/pages/welcome/LiveDemo.vue"
import Testimonials from "~/components/pages/welcome/Testimonials.vue"
-import { useIsAuthenticated } from "~/composables/useAuthFlow"
+import { useIsAuthenticated } from "~/composables/useIsAuthenticated.js"
const props = defineProps({
competitorName: {
diff --git a/client/components/pages/welcome/LiveDemo.vue b/client/components/pages/welcome/LiveDemo.vue
index b4c986733..c742667dc 100644
--- a/client/components/pages/welcome/LiveDemo.vue
+++ b/client/components/pages/welcome/LiveDemo.vue
@@ -63,7 +63,7 @@
<script setup>
import LiveDemoForm from "~/components/pages/welcome/LiveDemoForm.vue"
-import { useIsAuthenticated } from "~/composables/useAuthFlow"
+import { useIsAuthenticated } from "~/composables/useIsAuthenticated.js"
import {
getLiveDemoMediaPreloads,
getLiveDemoScenario,
diff --git a/client/components/vendor/Clarity.vue b/client/components/vendor/Clarity.vue
index f314a249f..0df2083b3 100644
--- a/client/components/vendor/Clarity.vue
+++ b/client/components/vendor/Clarity.vue
@@ -2,7 +2,7 @@
<script setup>
import Clarity from '@microsoft/clarity'
-import { useIsAuthenticated } from '~/composables/useAuthFlow'
+import { useIsAuthenticated } from '~/composables/useIsAuthenticated.js'
const authStore = useAuthStore()
const user = computed(() => authStore.user)
@@ -49,4 +49,3 @@ onMounted(() => {
})
</script>
-
diff --git a/client/components/workspaces/settings/Modal.vue b/client/components/workspaces/settings/Modal.vue
index ffe4eb213..a257ff63c 100644
--- a/client/components/workspaces/settings/Modal.vue
+++ b/client/components/workspaces/settings/Modal.vue
@@ -73,8 +73,6 @@
import { computed } from 'vue'
import SettingsModal from '~/components/pages/settings/SettingsModal.vue'
import SettingsModalPage from '~/components/pages/settings/SettingsModalPage.vue'
-import LazyWorkspacesSettingsSso from './sso/index.vue'
-import LazyWorkspacesSettingsCustomCode from './CustomCode.vue'
const emit = defineEmits(['update:activeTab'])
diff --git a/client/composables/components/useComponentRegistry.js b/client/composables/components/useComponentRegistry.js
index 3d5c9e8eb..ee7327cd3 100644
--- a/client/composables/components/useComponentRegistry.js
+++ b/client/composables/components/useComponentRegistry.js
@@ -1,6 +1,4 @@
import { defineAsyncComponent } from 'vue'
-import FocusedSelectorInput from '~/components/forms/core/FocusedSelectorInput.vue'
-import FocusedToggleInput from '~/components/forms/core/FocusedToggleInput.vue'
const integrationRegistry = new Map([
['webhook', () => import('~/components/open/integrations/WebhookIntegration.vue')],
@@ -51,8 +49,8 @@ const heavyFormComponentsRegistry = new Map([
])
const focusedFormComponentsRegistry = new Map([
- ['FocusedSelectorInput', FocusedSelectorInput],
- ['FocusedToggleInput', FocusedToggleInput],
+ ['FocusedSelectorInput', () => import('~/components/forms/core/FocusedSelectorInput.vue')],
+ ['FocusedToggleInput', () => import('~/components/forms/core/FocusedToggleInput.vue')],
])
// Component loading cache to avoid duplicate imports
@@ -198,9 +196,9 @@ export function useComponentRegistry() {
}
if (focusedFormComponentsRegistry.has(componentName)) {
- const component = focusedFormComponentsRegistry.get(componentName)
+ const loader = focusedFormComponentsRegistry.get(componentName)
return {
- component,
+ component: createAsyncComponent(loader),
clientOnly: false
}
}
diff --git a/client/composables/query/forms/useForms.js b/client/composables/query/forms/useForms.js
index 08067f706..6e1deb6fa 100644
--- a/client/composables/query/forms/useForms.js
+++ b/client/composables/query/forms/useForms.js
@@ -1,7 +1,7 @@
import { useQueryClient, useQuery, useMutation } from '@tanstack/vue-query'
import { computed, toValue } from 'vue'
import { formsApi } from '~/api/forms'
-import { useIsAuthenticated } from '~/composables/useAuthFlow'
+import { useIsAuthenticated } from '~/composables/useIsAuthenticated.js'
import { useFormsListCache } from './useFormsList'
export function useForms() {
diff --git a/client/composables/query/useAuth.js b/client/composables/query/useAuth.js
index 50920c9d8..05bcf88cb 100644
--- a/client/composables/query/useAuth.js
+++ b/client/composables/query/useAuth.js
@@ -1,11 +1,13 @@
import { useQueryClient, useQuery, useMutation } from '@tanstack/vue-query'
import { authApi } from '~/api/auth'
-import { initServiceClients } from '~/composables/useAuthFlow'
+import { initServiceClients } from '~/composables/useServiceClients.js'
export function useAuth() {
+ const nuxtApp = useNuxtApp()
const queryClient = useQueryClient()
- const { handleAuthSuccess, handleManualLogout, handleTwoFactorError } = useAuthFlow()
const { isAuthenticated } = useIsAuthenticated()
+ const getAuthFlow = () => import('~/composables/useAuthFlow')
+ .then((authFlow) => nuxtApp.runWithContext(() => authFlow.useAuthFlow()))
// Queries
const user = (options = {}) => {
@@ -42,12 +44,13 @@ export function useAuth() {
const deleteAccount = (options = {}) => {
return useMutation({
mutationFn: () => authApi.user.delete(),
- onSuccess: () => {
+ onSuccess: async () => {
// Clear cached data
queryClient.clear()
// Handle logout coordination (token clearing + navigation)
- handleManualLogout()
+ const { handleManualLogout } = await getAuthFlow()
+ return handleManualLogout()
},
...options
})
@@ -56,7 +59,7 @@ export function useAuth() {
const login = (options = {}) => {
return useMutation({
mutationFn: (data) => authApi.login(data),
- onSuccess: (tokenData, variables) => {
+ onSuccess: async (tokenData, variables) => {
// Cache user data if provided
if (tokenData.user) {
queryClient.setQueryData(['user'], tokenData.user)
@@ -68,15 +71,16 @@ export function useAuth() {
queryClient.invalidateQueries({ queryKey: ['workspaces'] })
// Handle auth flow coordination
- handleAuthSuccess(tokenData, variables?.source || 'credentials')
+ const { handleAuthSuccess } = await getAuthFlow()
+ return handleAuthSuccess(tokenData, variables?.source || 'credentials')
},
- onError: (error, variables) => {
+ onError: async (error, variables) => {
+ const { handleAuthSuccess, handleTwoFactorError } = await getAuthFlow()
// Check if this is a 2FA requirement (422 with requires_2fa flag)
const twoFactorData = handleTwoFactorError(error)
if (twoFactorData) {
// Handle auth flow coordination (will show 2FA modal)
- handleAuthSuccess(twoFactorData, variables?.source || 'credentials')
- return
+ return handleAuthSuccess(twoFactorData, variables?.source || 'credentials')
}
// This is a real error, let it propagate
@@ -89,7 +93,7 @@ export function useAuth() {
const register = (options = {}) => {
return useMutation({
mutationFn: (data) => authApi.register(data),
- onSuccess: (tokenData, variables) => {
+ onSuccess: async (tokenData, variables) => {
// Cache user data if provided
if (tokenData.user) {
queryClient.setQueryData(['user'], tokenData.user)
@@ -101,7 +105,8 @@ export function useAuth() {
queryClient.invalidateQueries({ queryKey: ['workspaces'] })
// Handle auth flow coordination (includes AppSumo license handling)
- handleAuthSuccess(tokenData, variables?.source, true)
+ const { handleAuthSuccess } = await getAuthFlow()
+ return handleAuthSuccess(tokenData, variables?.source, true)
},
...options
})
@@ -110,20 +115,22 @@ export function useAuth() {
const logout = (options = {}) => {
return useMutation({
mutationFn: () => authApi.logout(),
- onSuccess: () => {
+ onSuccess: async () => {
// Clear cached data
queryClient.clear()
// Handle manual logout coordination (token clearing + navigation)
- handleManualLogout()
+ const { handleManualLogout } = await getAuthFlow()
+ return handleManualLogout()
},
- onError: (error) => {
+ onError: async (error) => {
console.error(error)
// Even if logout API fails, clear local state
queryClient.clear()
// Handle manual logout coordination (token clearing + navigation)
- handleManualLogout()
+ const { handleManualLogout } = await getAuthFlow()
+ return handleManualLogout()
},
...options
})
@@ -132,7 +139,7 @@ export function useAuth() {
const oauthCallback = (options = {}) => {
return useMutation({
mutationFn: ({ provider, data }) => authApi.oauth.callback(provider, data),
- onSuccess: (response) => {
+ onSuccess: async (response) => {
// Cache user data if provided
if (response.user) {
queryClient.setQueryData(['user'], response.user)
@@ -144,7 +151,8 @@ export function useAuth() {
queryClient.invalidateQueries({ queryKey: ['workspaces'] })
// Handle auth flow coordination (token handling done there)
- handleAuthSuccess(response, 'oauth', response.new_user)
+ const { handleAuthSuccess } = await getAuthFlow()
+ return handleAuthSuccess(response, 'oauth', response.new_user)
},
...options
})
@@ -169,4 +177,4 @@ export function useAuth() {
// Utilities
invalidateUser
}
-}
\ No newline at end of file
+}
diff --git a/client/composables/useAmplitude.js b/client/composables/useAmplitude.js
index 588c38fc4..67f35af36 100644
--- a/client/composables/useAmplitude.js
+++ b/client/composables/useAmplitude.js
@@ -1,11 +1,12 @@
-import amplitude from 'amplitude-js'
-
let amplitudeClient = null
+let amplitudePromise = null
-export function useAmplitude () {
- const config = useRuntimeConfig()
- const amplitudeCode = config.public.amplitudeCode
- if (!amplitudeClient && amplitudeCode && !process.server) {
+function loadAmplitude(amplitudeCode) {
+ if (!amplitudeCode || import.meta.server) return Promise.resolve(null)
+ if (amplitudeClient) return Promise.resolve(amplitudeClient)
+ if (amplitudePromise) return amplitudePromise
+
+ amplitudePromise = import('amplitude-js').then(({ default: amplitude }) => {
amplitudeClient = amplitude.getInstance()
amplitudeClient.init(amplitudeCode, null, {
includeReferrer: true,
@@ -13,32 +14,35 @@ export function useAmplitude () {
includeGclid: true,
includeFbclid: true
})
- }
+ return amplitudeClient
+ })
+
+ return amplitudePromise
+}
+export function useAmplitude () {
+ const config = useRuntimeConfig()
+ const amplitudeCode = config.public.amplitudeCode
const logEvent = function (eventName, eventData) {
if (config.public.env !== 'production') {
console.log('[DEBUG] Amplitude logged event:', eventName, eventData)
}
- if (!amplitudeClient) {
- return
- }
-
if (eventData && typeof eventData !== 'object')
throw new Error('Amplitude event value must be an object.')
- amplitudeClient.logEvent(eventName, eventData)
+ return loadAmplitude(amplitudeCode).then((client) => client?.logEvent(eventName, eventData))
}
const setUser = function (user) {
- if (!amplitudeClient) {
- return
- }
- amplitudeClient.setUserId(user.id)
- amplitudeClient.setUserProperties({
- email: user.email,
- subscribed: user.is_subscribed,
- plan_tier: user.plan_tier ?? 'free'
+ return loadAmplitude(amplitudeCode).then((client) => {
+ if (!client) return
+ client.setUserId(user.id)
+ client.setUserProperties({
+ email: user.email,
+ subscribed: user.is_subscribed,
+ plan_tier: user.plan_tier ?? 'free'
+ })
})
}
diff --git a/client/composables/useAppModals.js b/client/composables/useAppModals.js
index 98627a446..b5c702a28 100644
--- a/client/composables/useAppModals.js
+++ b/client/composables/useAppModals.js
@@ -1,12 +1,11 @@
-import { ref, watch, computed, readonly } from 'vue'
+import { ref, watch, computed, readonly, defineAsyncComponent } from 'vue'
import { useRouteQuery } from '@vueuse/router'
import { createSharedComposable } from '@vueuse/core'
// (No need for explicit imports of auto-imported composables)
-// Pre-import modal components so overlay receives component definitions, not promises
-import UsersSettingsModal from '~/components/users/settings/Modal.vue'
-import WorkspacesSettingsModal from '~/components/workspaces/settings/Modal.vue'
-import SubscriptionModal from '~/components/pages/pricing/SubscriptionModal.vue'
+const UsersSettingsModal = defineAsyncComponent(() => import('~/components/users/settings/Modal.vue'))
+const WorkspacesSettingsModal = defineAsyncComponent(() => import('~/components/workspaces/settings/Modal.vue'))
+const SubscriptionModal = defineAsyncComponent(() => import('~/components/pages/pricing/SubscriptionModal.vue'))
/**
* Factory for creating URL-synced modals.
diff --git a/client/composables/useAuthFlow.js b/client/composables/useAuthFlow.js
index 83a93d26d..b64ef3230 100644
--- a/client/composables/useAuthFlow.js
+++ b/client/composables/useAuthFlow.js
@@ -1,31 +1,6 @@
import { WindowMessageTypes, useWindowMessage } from "~/composables/useWindowMessage"
import { authApi } from "~/api"
-
-/**
- * Lightweight authentication check that doesn't require Vue Query context
- * Use this when you only need to check if user is authenticated
- */
-export const useIsAuthenticated = () => {
- const authStore = useAuthStore()
-
- const isAuthenticated = computed(() => {
- return !!authStore.token
- })
-
- return { isAuthenticated }
-}
-
-/**
- * Initialize vendor clients (Amplitude, Crisp) from the current user.
- * Safe to call from middleware or anywhere outside setup context.
- */
-export const initServiceClients = (userData) => {
- if (import.meta.server) return
- if (!userData) return
-
- useAmplitude().setUser(userData)
- useCrisp().setUser(userData)
-}
+import { initServiceClients } from '~/composables/useServiceClients.js'
// Shared state for 2FA modal - ensures all instances of useAuthFlow share the same state
const showTwoFactorModal = ref(false)
diff --git a/client/composables/useConfetti.js b/client/composables/useConfetti.js
index d07290a37..cd7ff2612 100644
--- a/client/composables/useConfetti.js
+++ b/client/composables/useConfetti.js
@@ -3,17 +3,32 @@ import { ref, onUnmounted } from "vue"
export const useConfetti = () => {
let timeoutId = ref(null)
const nuxtApp = useNuxtApp()
- const $confetti = nuxtApp.vueApp.config.globalProperties.$confetti
+ let confettiPromise = null
+
+ function loadConfetti() {
+ const existingConfetti = nuxtApp.vueApp.config.globalProperties.$confetti
+ if (existingConfetti) return Promise.resolve(existingConfetti)
+ if (confettiPromise) return confettiPromise
+
+ confettiPromise = import('vue-confetti').then(({ default: VueConfetti }) => {
+ nuxtApp.vueApp.use(VueConfetti)
+ return nuxtApp.vueApp.config.globalProperties.$confetti
+ })
+
+ return confettiPromise
+ }
function play(duration = 3000) {
- $confetti.start({ defaultSize: 6 })
- timeoutId.value = setTimeout(() => {
- $confetti.stop()
- }, duration)
+ return loadConfetti().then((confetti) => {
+ confetti.start({ defaultSize: 6 })
+ timeoutId.value = setTimeout(() => {
+ confetti.stop()
+ }, duration)
+ })
}
onUnmounted(() => {
- if (timeoutId.value) clearTimeout(timeoutId)
+ if (timeoutId.value) clearTimeout(timeoutId.value)
})
return {
diff --git a/client/composables/useCrisp.js b/client/composables/useCrisp.js
index 53689868c..b30252e90 100644
--- a/client/composables/useCrisp.js
+++ b/client/composables/useCrisp.js
@@ -1,133 +1,112 @@
export function useCrisp () {
- const crisp = import.meta.client ? window.Crisp : null
+ const ensureCrisp = () => {
+ if (import.meta.server) return Promise.resolve(null)
+ if (window.Crisp) return Promise.resolve(window.Crisp)
+ return useNuxtApp().$ensureCrisp?.() || Promise.resolve(null)
+ }
+
+ const withCrisp = (callback) => ensureCrisp().then((crisp) => {
+ if (crisp) return callback(crisp)
+ })
function onCrispInit () {
- if (!crisp)
- return
- crisp.chat.onChatOpened(() => {
+ return withCrisp((crisp) => {
+ crisp.chat.onChatOpened(() => {
useAppStore().crisp.chatOpened = true
- })
- crisp.chat.onChatClosed(() => {
+ })
+ crisp.chat.onChatClosed(() => {
useAppStore().crisp.chatOpened = false
+ })
})
}
function openChat () {
- if (!crisp)
- return
- showChat()
- crisp.chat.open()
+ return withCrisp((crisp) => {
+ crisp.chat.show()
+ crisp.chat.open()
+ useAppStore().crisp = { ...useAppStore().crisp, hidden: false }
+ })
}
function showChat () {
- if (!crisp)
- return
- crisp.chat.show()
- useAppStore().crisp = {
- ...useAppStore().crisp,
- hidden: false
- }
+ return withCrisp((crisp) => {
+ crisp.chat.show()
+ useAppStore().crisp = { ...useAppStore().crisp, hidden: false }
+ })
}
function hideChat () {
- if (!crisp)
- return
+ const crisp = import.meta.client ? window.Crisp : null
+ if (!crisp) return Promise.resolve()
crisp.chat.hide()
- useAppStore().crisp = {
- ...useAppStore().crisp,
- hidden: true
- }
+ useAppStore().crisp = { ...useAppStore().crisp, hidden: true }
}
function closeChat () {
- if (!crisp)
- return
- crisp.chat.close()
+ return withCrisp((crisp) => crisp.chat.close())
}
function openAndShowChat (message = null) {
- if (!crisp)
- return
- openChat()
- if (message)
- sendTextMessage(message)
+ return openChat().then(() => {
+ if (message) return sendTextMessage(message)
+ })
}
function openHelpdesk () {
- if (!crisp)
- return
- openChat()
- crisp.chat.setHelpdeskView()
+ return openChat().then(() => withCrisp((crisp) => crisp.chat.setHelpdeskView()))
}
function openHelpdeskArticle (articleSlug, locale = 'en') {
- if (!crisp)
- return
- crisp.chat.openHelpdeskArticle(locale, articleSlug)
+ return withCrisp((crisp) => crisp.chat.openHelpdeskArticle(locale, articleSlug))
}
function sendTextMessage (message) {
- if (!crisp)
- return
- crisp.message.send('text', message)
+ return withCrisp((crisp) => crisp.message.send('text', message))
}
function setUser (user) {
- if (!crisp)
- return
- crisp.user.setEmail(user.email)
- crisp.user.setNickname(user.name)
- crisp.session.setData({
+ return withCrisp((crisp) => {
+ crisp.user.setEmail(user.email)
+ crisp.user.setNickname(user.name)
+ crisp.session.setData({
'user_id': user.id,
'pro-subscription': user?.is_subscribed ?? false,
'stripe-id': user?.stripe_id ?? '',
'subscription': user?.plan_tier ?? 'free'
- })
+ })
- if (user?.is_subscribed ?? false) {
- setSegments([
- 'subscribed',
- user?.plan_tier ?? 'free'
- ])
- }
+ if (user?.is_subscribed ?? false) {
+ crisp.session.setSegments(['subscribed', user?.plan_tier ?? 'free'])
+ }
+ })
}
function pushEvent (event, data = {}) {
- if (!crisp)
- return
- crisp.session.pushEvent(event, data)
+ return withCrisp((crisp) => crisp.session.pushEvent(event, data))
}
function setSegments (segments, overwrite = false) {
- if (!crisp)
- return
- crisp.session.setSegments(segments, overwrite)
+ return withCrisp((crisp) => crisp.session.setSegments(segments, overwrite))
}
// Send message as operator
function showMessage (message, delay = 500) {
- if (!crisp)
- return
- setTimeout(() => {
- crisp.message.show('text', message)
- }, delay)
+ return withCrisp((crisp) => {
+ setTimeout(() => crisp.message.show('text', message), delay)
+ })
}
function pauseChatBot () {
- if (!crisp)
- return
- crisp.session.setData({ 'enum': 'pause_chatbot' })
+ return withCrisp((crisp) => crisp.session.setData({ 'enum': 'pause_chatbot' }))
}
function enableChatbot () {
- if (!crisp)
- return
- crisp.session.setData({ 'enum': 'start_chatbot' })
+ return withCrisp((crisp) => crisp.session.setData({ 'enum': 'start_chatbot' }))
}
return {
- crisp,
+ crisp: import.meta.client ? window.Crisp : null,
onCrispInit,
openChat,
showChat,
diff --git a/client/composables/useIsAuthenticated.js b/client/composables/useIsAuthenticated.js
new file mode 100644
index 000000000..b2914bd37
--- /dev/null
+++ b/client/composables/useIsAuthenticated.js
@@ -0,0 +1,10 @@
+/**
+ * Lightweight authentication check that does not pull the full login and 2FA
+ * flow into public routes.
+ */
+export const useIsAuthenticated = () => {
+ const authStore = useAuthStore()
+ const isAuthenticated = computed(() => !!authStore.token)
+
+ return { isAuthenticated }
+}
diff --git a/client/composables/useOpnApi.js b/client/composables/useOpnApi.js
index f060e6cb7..239911276 100644
--- a/client/composables/useOpnApi.js
+++ b/client/composables/useOpnApi.js
@@ -40,6 +40,7 @@ function addCustomDomainHeader(request, options) {
}
export function getOpnRequestsOptions(request, opts) {
+ const nuxtApp = useNuxtApp()
const config = useRuntimeConfig()
if (opts.body && opts.body instanceof FormData) {
@@ -72,7 +73,8 @@ export function getOpnRequestsOptions(request, opts) {
// Do not run token-expiry UX during SSR. Server-side bootstrap requests can
// fail for context-specific reasons and should be retried client-side first.
if (import.meta.client) {
- const { handleTokenExpiry } = useAuthFlow()
+ const authFlow = await import('~/composables/useAuthFlow')
+ const { handleTokenExpiry } = nuxtApp.runWithContext(() => authFlow.useAuthFlow())
await handleTokenExpiry()
}
} else if (status === 420) {
diff --git a/client/composables/useServiceClients.js b/client/composables/useServiceClients.js
new file mode 100644
index 000000000..c9307b129
--- /dev/null
+++ b/client/composables/useServiceClients.js
@@ -0,0 +1,10 @@
+/**
+ * Initialize vendor clients from the current user only after authenticated app
+ * bootstrap has completed.
+ */
+export const initServiceClients = (userData) => {
+ if (import.meta.server || !userData) return
+
+ useAmplitude().setUser(userData)
+ useCrisp().setUser(userData)
+}
diff --git a/client/lib/forms/composables/useFormManager.js b/client/lib/forms/composables/useFormManager.js
index 720e08236..212d84bb8 100644
--- a/client/lib/forms/composables/useFormManager.js
+++ b/client/lib/forms/composables/useFormManager.js
@@ -13,7 +13,6 @@ import { usePartialSubmission } from '~/composables/forms/usePartialSubmission.j
import { useIsIframe } from '~/composables/useIsIframe'
import { useAmplitude } from '~/composables/useAmplitude'
import { useConfetti } from '~/composables/useConfetti'
-import { cloneDeep } from 'lodash'
import { useFieldState } from './useFieldState'
import { useComputedVariables } from '~/composables/forms/useComputedVariables'
import { useSubmissionAttribution } from './useSubmissionAttribution'
@@ -334,6 +333,7 @@ export function useFormManager(initialFormConfig, initialMode = FormMode.LIVE, o
if (import.meta.client) {
const isIframe = useIsIframe()
const formConfig = toValue(config)
+ const { default: cloneDeep } = await import('clone-deep')
const payload = cloneDeep({
type: 'form-submitted',
form: {
diff --git a/client/lib/forms/field-options.js b/client/lib/forms/field-options.js
new file mode 100644
index 000000000..6f28b8884
--- /dev/null
+++ b/client/lib/forms/field-options.js
@@ -0,0 +1,9 @@
+export function getFieldOptions(field) {
+ if (!field || !['select', 'multi_select'].includes(field.type)) return []
+ const rawOptions = field[field.type]?.options ?? field.options ?? []
+ return rawOptions.map(option => ({
+ name: option.name,
+ value: option.name,
+ image: option.image || null,
+ }))
+}
diff --git a/client/lib/forms/mention-parser-loader.js b/client/lib/forms/mention-parser-loader.js
new file mode 100644
index 000000000..57452e953
--- /dev/null
+++ b/client/lib/forms/mention-parser-loader.js
@@ -0,0 +1,23 @@
+let mentionParserModule = null
+let mentionParserModulePromise = null
+
+export function loadMentionParser() {
+ if (mentionParserModule) return Promise.resolve(mentionParserModule.useParseMention)
+ if (mentionParserModulePromise) return mentionParserModulePromise
+
+ mentionParserModulePromise = import('~/composables/components/useParseMention.js')
+ .then((module) => {
+ mentionParserModule = module
+ return module.useParseMention
+ })
+ .catch((error) => {
+ mentionParserModulePromise = null
+ throw error
+ })
+
+ return mentionParserModulePromise
+}
+
+export function clearLoadedMentionCache() {
+ mentionParserModule?.clearMentionCache()
+}
diff --git a/client/middleware/01.check-auth.global.js b/client/middleware/01.check-auth.global.js
index 1900a5dc1..d362e4898 100644
--- a/client/middleware/01.check-auth.global.js
+++ b/client/middleware/01.check-auth.global.js
@@ -1,12 +1,12 @@
import { useQueryClient } from '@tanstack/vue-query'
-import { initServiceClients } from '~/composables/useAuthFlow'
const AUTH_COOKIE_NAME = 'opnform_token'
const LEGACY_AUTH_COOKIE_NAME = 'token'
const ADMIN_AUTH_COOKIE_NAME = 'opnform_admin_token'
const LEGACY_ADMIN_AUTH_COOKIE_NAME = 'admin_token'
-export default defineNuxtRouteMiddleware(async (_to, _from) => {
+export default defineNuxtRouteMiddleware(async (to, _from) => {
+ const nuxtApp = useNuxtApp()
const authStore = useAuthStore()
const queryClient = useQueryClient()
const tokenCookie = useCookie(AUTH_COOKIE_NAME)
@@ -23,6 +23,13 @@ export default defineNuxtRouteMiddleware(async (_to, _from) => {
resolvedAdminToken,
)
+ // Public forms do not need the authenticated application bootstrap. Avoid
+ // fetching the user/workspaces and initializing analytics/support vendors on
+ // the respondent's critical path, even when an auth cookie is present.
+ if (to.name === 'forms-slug') {
+ return
+ }
+
// If no token, nothing to do
if (!authStore.token) {
return
@@ -58,6 +65,8 @@ export default defineNuxtRouteMiddleware(async (_to, _from) => {
// Initialize service clients on client side (no-op on server)
if (userData) {
authStore.updateUser(userData)
- initServiceClients(userData)
+ await import('~/composables/useServiceClients.js').then((serviceClients) => {
+ nuxtApp.runWithContext(() => serviceClients.initServiceClients(userData))
+ })
}
})
diff --git a/client/nuxt.config.ts b/client/nuxt.config.ts
index a444107fb..5403d247b 100644
--- a/client/nuxt.config.ts
+++ b/client/nuxt.config.ts
@@ -16,11 +16,22 @@ export default defineNuxtConfig({
...(viteCacheDir ? {vite: {cacheDir: viteCacheDir}} : {}),
css: ['~/css/app.css'],
+ hooks: {
+ 'build:manifest': (manifest) => {
+ // Nuxt follows every dynamicImports edge while generating resource hints,
+ // including all route middleware, locales and optional form/editor code.
+ // Keep those chunks on-demand; modules actually rendered during SSR are
+ // still tracked and emitted through their regular manifest imports.
+ Object.values(manifest).forEach((entry) => {
+ if (entry.dynamicImports) entry.dynamicImports = []
+ })
+ },
+ },
+
// Disable certain plugins during testing
modules: isUnitTestMode ? [] : [
'@pinia/nuxt',
'@vueuse/nuxt',
- '@vueuse/motion/nuxt',
'@nuxtjs/sitemap',
'@nuxt/ui',
'nuxt-utm',
@@ -96,6 +107,15 @@ export default defineNuxtConfig({
org: "opnform",
project: "opnform-vue",
},
+ unstable_sentryBundlerPluginOptions: {
+ bundleSizeOptimizations: {
+ excludeDebugStatements: true,
+ excludeTracing: true,
+ excludeReplayShadowDom: true,
+ excludeReplayIframe: true,
+ excludeReplayWorker: true,
+ },
+ },
},
sourcemap: { client: 'hidden' },
@@ -148,6 +168,9 @@ export default defineNuxtConfig({
},
icon: {
+ // Managed E2E worktrees place buildDir outside client/node_modules, so
+ // locally-installed JSON collections cannot be resolved at runtime there.
+ serverBundle: (isE2EMode || buildDir) ? 'remote' : 'auto',
customCollections: [
{
prefix: 'opnform',
@@ -159,9 +182,7 @@ export default defineNuxtConfig({
'ix:mandatory',
],
includeCustomCollections: true,
- scan: {
- globInclude: ['**/*.vue', '**/*.json'],
- },
+ scan: false,
},
},
diff --git a/client/package-lock.json b/client/package-lock.json
index 15cc26927..47a3fdd7c 100644
--- a/client/package-lock.json
+++ b/client/package-lock.json
@@ -22,11 +22,9 @@
"@tanstack/vue-query": "^5.81.5",
"@tanstack/vue-query-devtools": "^5.81.5",
"@tanstack/vue-virtual": "^3.13.12",
- "@vueuse/components": "^11.2.0",
"@vueuse/core": "^13.1.0",
- "@vueuse/integrations": "^11.2.0",
- "@vueuse/motion": "^2.2.6",
- "@vueuse/nuxt": "^11.2.0",
+ "@vueuse/integrations": "^13.5.0",
+ "@vueuse/nuxt": "^13.5.0",
"@vueuse/router": "^13.4.0",
"@zadigetvoltaire/nuxt-gtm": "^0.0.13",
"@zxing/library": "^0.21.3",
@@ -44,14 +42,12 @@
"libphonenumber-js": "^1.11.12",
"object-to-formdata": "^4.5.1",
"overlayscrollbars": "^2.15.1",
- "overlayscrollbars-vue": "^0.5.9",
"pdfjs-dist": "^5.4.530",
"pinia": "^3.0.2",
"prismjs": "^1.29.0",
"qrcode": "^1.5.4",
"quill": "^2.0.2",
"quill-resize-module": "^2.1.3",
- "tailwind-merge": "^2.5.4",
"tailwindcss": "^4.1.10",
"tinymotion": "^0.2.0",
"v-calendar": "3.0.1",
@@ -4581,84 +4577,6 @@
}
}
},
- "node_modules/@nuxt/ui/node_modules/@vueuse/integrations": {
- "version": "13.5.0",
- "resolved": "https://registry.npmjs.org/@vueuse/integrations/-/integrations-13.5.0.tgz",
- "integrity": "sha512-7RACJySnlpl0MkSzxbtadioNGSX4TL5/Wl2cUy4nDq/XkeHwPYvVM880HJUSiap/FXhVEup9VKTM9y/n5UspAw==",
- "license": "MIT",
- "dependencies": {
- "@vueuse/core": "13.5.0",
- "@vueuse/shared": "13.5.0"
- },
- "funding": {
- "url": "https://github.com/sponsors/antfu"
- },
- "peerDependencies": {
- "async-validator": "^4",
- "axios": "^1",
- "change-case": "^5",
- "drauu": "^0.4",
- "focus-trap": "^7",
- "fuse.js": "^7",
- "idb-keyval": "^6",
- "jwt-decode": "^4",
- "nprogress": "^0.2",
- "qrcode": "^1.5",
- "sortablejs": "^1",
- "universal-cookie": "^7 || ^8",
- "vue": "^3.5.0"
- },
- "peerDependenciesMeta": {
- "async-validator": {
- "optional": true
- },
- "axios": {
- "optional": true
- },
- "change-case": {
- "optional": true
- },
- "drauu": {
- "optional": true
- },
- "focus-trap": {
- "optional": true
- },
- "fuse.js": {
- "optional": true
- },
- "idb-keyval": {
- "optional": true
- },
- "jwt-decode": {
- "optional": true
- },
- "nprogress": {
- "optional": true
- },
- "qrcode": {
- "optional": true
- },
- "sortablejs": {
- "optional": true
- },
- "universal-cookie": {
- "optional": true
- }
- }
- },
- "node_modules/@nuxt/ui/node_modules/@vueuse/shared": {
- "version": "13.5.0",
- "resolved": "https://registry.npmjs.org/@vueuse/shared/-/shared-13.5.0.tgz",
- "integrity": "sha512-K7GrQIxJ/ANtucxIXbQlUHdB0TPA8c+q5i+zbrjxuhJCnJ9GtBg75sBSnvmLSxHKPg2Yo8w62PWksl9kwH0Q8g==",
- "license": "MIT",
- "funding": {
- "url": "https://github.com/sponsors/antfu"
- },
- "peerDependencies": {
- "vue": "^3.5.0"
- }
- },
"node_modules/@nuxt/vite-builder": {
"version": "3.17.5",
"resolved": "https://registry.npmjs.org/@nuxt/vite-builder/-/vite-builder-3.17.5.tgz",
@@ -9651,73 +9569,6 @@
"vue-component-type-helpers": "^2.0.0"
}
},
- "node_modules/@vueuse/components": {
- "version": "11.3.0",
- "resolved": "https://registry.npmjs.org/@vueuse/components/-/components-11.3.0.tgz",
- "integrity": "sha512-sqaGtWPgobXvZmv3atcjW8YW0ypecFuB286OEKFXaPrLsA5b2Y+xAvHvq5V7d+VJRKt705gCK3BNBjxu3g1PdQ==",
- "license": "MIT",
- "dependencies": {
- "@vueuse/core": "11.3.0",
- "@vueuse/shared": "11.3.0",
- "vue-demi": ">=0.14.10"
- }
- },
- "node_modules/@vueuse/components/node_modules/@types/web-bluetooth": {
- "version": "0.0.20",
- "resolved": "https://registry.npmjs.org/@types/web-bluetooth/-/web-bluetooth-0.0.20.tgz",
- "integrity": "sha512-g9gZnnXVq7gM7v3tJCWV/qw7w+KeOlSHAhgF9RytFyifW6AF61hdT2ucrYhPq9hLs5JIryeupHV3qGk95dH9ow==",
- "license": "MIT"
- },
- "node_modules/@vueuse/components/node_modules/@vueuse/core": {
- "version": "11.3.0",
- "resolved": "https://registry.npmjs.org/@vueuse/core/-/core-11.3.0.tgz",
- "integrity": "sha512-7OC4Rl1f9G8IT6rUfi9JrKiXy4bfmHhZ5x2Ceojy0jnd3mHNEvV4JaRygH362ror6/NZ+Nl+n13LPzGiPN8cKA==",
- "license": "MIT",
- "dependencies": {
- "@types/web-bluetooth": "^0.0.20",
- "@vueuse/metadata": "11.3.0",
- "@vueuse/shared": "11.3.0",
- "vue-demi": ">=0.14.10"
- },
- "funding": {
- "url": "https://github.com/sponsors/antfu"
- }
- },
- "node_modules/@vueuse/components/node_modules/@vueuse/metadata": {
- "version": "11.3.0",
- "resolved": "https://registry.npmjs.org/@vueuse/metadata/-/metadata-11.3.0.tgz",
- "integrity": "sha512-pwDnDspTqtTo2HwfLw4Rp6yywuuBdYnPYDq+mO38ZYKGebCUQC/nVj/PXSiK9HX5otxLz8Fn7ECPbjiRz2CC3g==",
- "license": "MIT",
- "funding": {
- "url": "https://github.com/sponsors/antfu"
- }
- },
- "node_modules/@vueuse/components/node_modules/vue-demi": {
- "version": "0.14.10",
- "resolved": "https://registry.npmjs.org/vue-demi/-/vue-demi-0.14.10.tgz",
- "integrity": "sha512-nMZBOwuzabUO0nLgIcc6rycZEebF6eeUfaiQx9+WSk8e29IbLvPU9feI6tqW4kTo3hvoYAJkMh8n8D0fuISphg==",
- "hasInstallScript": true,
- "license": "MIT",
- "bin": {
- "vue-demi-fix": "bin/vue-demi-fix.js",
- "vue-demi-switch": "bin/vue-demi-switch.js"
- },
- "engines": {
- "node": ">=12"
- },
- "funding": {
- "url": "https://github.com/sponsors/antfu"
- },
- "peerDependencies": {
- "@vue/composition-api": "^1.0.0-rc.1",
- "vue": "^3.0.0-0 || ^2.6.0"
- },
- "peerDependenciesMeta": {
- "@vue/composition-api": {
- "optional": true
- }
- }
- },
"node_modules/@vueuse/core": {
"version": "13.5.0",
"resolved": "https://registry.npmjs.org/@vueuse/core/-/core-13.5.0.tgz",
@@ -9735,27 +9586,14 @@
"vue": "^3.5.0"
}
},
- "node_modules/@vueuse/core/node_modules/@vueuse/shared": {
- "version": "13.5.0",
- "resolved": "https://registry.npmjs.org/@vueuse/shared/-/shared-13.5.0.tgz",
- "integrity": "sha512-K7GrQIxJ/ANtucxIXbQlUHdB0TPA8c+q5i+zbrjxuhJCnJ9GtBg75sBSnvmLSxHKPg2Yo8w62PWksl9kwH0Q8g==",
- "license": "MIT",
- "funding": {
- "url": "https://github.com/sponsors/antfu"
- },
- "peerDependencies": {
- "vue": "^3.5.0"
- }
- },
"node_modules/@vueuse/integrations": {
- "version": "11.3.0",
- "resolved": "https://registry.npmjs.org/@vueuse/integrations/-/integrations-11.3.0.tgz",
- "integrity": "sha512-5fzRl0apQWrDezmobchoiGTkGw238VWESxZHazfhP3RM7pDSiyXy18QbfYkILoYNTd23HPAfQTJpkUc5QbkwTw==",
+ "version": "13.5.0",
+ "resolved": "https://registry.npmjs.org/@vueuse/integrations/-/integrations-13.5.0.tgz",
+ "integrity": "sha512-7RACJySnlpl0MkSzxbtadioNGSX4TL5/Wl2cUy4nDq/XkeHwPYvVM880HJUSiap/FXhVEup9VKTM9y/n5UspAw==",
"license": "MIT",
"dependencies": {
- "@vueuse/core": "11.3.0",
- "@vueuse/shared": "11.3.0",
- "vue-demi": ">=0.14.10"
+ "@vueuse/core": "13.5.0",
+ "@vueuse/shared": "13.5.0"
},
"funding": {
"url": "https://github.com/sponsors/antfu"
@@ -9772,7 +9610,8 @@
"nprogress": "^0.2",
"qrcode": "^1.5",
"sortablejs": "^1",
- "universal-cookie": "^7"
+ "universal-cookie": "^7 || ^8",
+ "vue": "^3.5.0"
},
"peerDependenciesMeta": {
"async-validator": {
@@ -9813,62 +9652,6 @@
}
}
},
- "node_modules/@vueuse/integrations/node_modules/@types/web-bluetooth": {
- "version": "0.0.20",
- "resolved": "https://registry.npmjs.org/@types/web-bluetooth/-/web-bluetooth-0.0.20.tgz",
- "integrity": "sha512-g9gZnnXVq7gM7v3tJCWV/qw7w+KeOlSHAhgF9RytFyifW6AF61hdT2ucrYhPq9hLs5JIryeupHV3qGk95dH9ow==",
- "license": "MIT"
- },
- "node_modules/@vueuse/integrations/node_modules/@vueuse/core": {
- "version": "11.3.0",
- "resolved": "https://registry.npmjs.org/@vueuse/core/-/core-11.3.0.tgz",
- "integrity": "sha512-7OC4Rl1f9G8IT6rUfi9JrKiXy4bfmHhZ5x2Ceojy0jnd3mHNEvV4JaRygH362ror6/NZ+Nl+n13LPzGiPN8cKA==",
- "license": "MIT",
- "dependencies": {
- "@types/web-bluetooth": "^0.0.20",
- "@vueuse/metadata": "11.3.0",
- "@vueuse/shared": "11.3.0",
- "vue-demi": ">=0.14.10"
- },
- "funding": {
- "url": "https://github.com/sponsors/antfu"
- }
- },
- "node_modules/@vueuse/integrations/node_modules/@vueuse/metadata": {
- "version": "11.3.0",
- "resolved": "https://registry.npmjs.org/@vueuse/metadata/-/metadata-11.3.0.tgz",
- "integrity": "sha512-pwDnDspTqtTo2HwfLw4Rp6yywuuBdYnPYDq+mO38ZYKGebCUQC/nVj/PXSiK9HX5otxLz8Fn7ECPbjiRz2CC3g==",
- "license": "MIT",
- "funding": {
- "url": "https://github.com/sponsors/antfu"
- }
- },
- "node_modules/@vueuse/integrations/node_modules/vue-demi": {
- "version": "0.14.10",
- "resolved": "https://registry.npmjs.org/vue-demi/-/vue-demi-0.14.10.tgz",
- "integrity": "sha512-nMZBOwuzabUO0nLgIcc6rycZEebF6eeUfaiQx9+WSk8e29IbLvPU9feI6tqW4kTo3hvoYAJkMh8n8D0fuISphg==",
- "hasInstallScript": true,
- "license": "MIT",
- "bin": {
- "vue-demi-fix": "bin/vue-demi-fix.js",
- "vue-demi-switch": "bin/vue-demi-switch.js"
- },
- "engines": {
- "node": ">=12"
- },
- "funding": {
- "url": "https://github.com/sponsors/antfu"
- },
- "peerDependencies": {
- "@vue/composition-api": "^1.0.0-rc.1",
- "vue": "^3.0.0-0 || ^2.6.0"
- },
- "peerDependenciesMeta": {
- "@vue/composition-api": {
- "optional": true
- }
- }
- },
"node_modules/@vueuse/metadata": {
"version": "13.5.0",
"resolved": "https://registry.npmjs.org/@vueuse/metadata/-/metadata-13.5.0.tgz",
@@ -9878,226 +9661,23 @@
"url": "https://github.com/sponsors/antfu"
}
},
- "node_modules/@vueuse/motion": {
- "version": "2.2.6",
- "resolved": "https://registry.npmjs.org/@vueuse/motion/-/motion-2.2.6.tgz",
- "integrity": "sha512-gKFktPtrdypSv44SaW1oBJKLBiP6kE5NcoQ6RsAU3InemESdiAutgQncfPe/rhLSLCtL4jTAhMmFfxoR6gm5LQ==",
- "license": "MIT",
- "dependencies": {
- "@vueuse/core": "^10.10.0",
- "@vueuse/shared": "^10.10.0",
- "csstype": "^3.1.3",
- "framesync": "^6.1.2",
- "popmotion": "^11.0.5",
- "style-value-types": "^5.1.2"
- },
- "optionalDependencies": {
- "@nuxt/kit": "^3.13.0"
- },
- "peerDependencies": {
- "vue": ">=3.0.0"
- }
- },
- "node_modules/@vueuse/motion/node_modules/@types/web-bluetooth": {
- "version": "0.0.20",
- "resolved": "https://registry.npmjs.org/@types/web-bluetooth/-/web-bluetooth-0.0.20.tgz",
- "integrity": "sha512-g9gZnnXVq7gM7v3tJCWV/qw7w+KeOlSHAhgF9RytFyifW6AF61hdT2ucrYhPq9hLs5JIryeupHV3qGk95dH9ow==",
- "license": "MIT"
- },
- "node_modules/@vueuse/motion/node_modules/@vueuse/core": {
- "version": "10.11.1",
- "resolved": "https://registry.npmjs.org/@vueuse/core/-/core-10.11.1.tgz",
- "integrity": "sha512-guoy26JQktXPcz+0n3GukWIy/JDNKti9v6VEMu6kV2sYBsWuGiTU8OWdg+ADfUbHg3/3DlqySDe7JmdHrktiww==",
- "license": "MIT",
- "dependencies": {
- "@types/web-bluetooth": "^0.0.20",
- "@vueuse/metadata": "10.11.1",
- "@vueuse/shared": "10.11.1",
- "vue-demi": ">=0.14.8"
- },
- "funding": {
- "url": "https://github.com/sponsors/antfu"
- }
- },
- "node_modules/@vueuse/motion/node_modules/@vueuse/core/node_modules/vue-demi": {
- "version": "0.14.10",
- "resolved": "https://registry.npmjs.org/vue-demi/-/vue-demi-0.14.10.tgz",
- "integrity": "sha512-nMZBOwuzabUO0nLgIcc6rycZEebF6eeUfaiQx9+WSk8e29IbLvPU9feI6tqW4kTo3hvoYAJkMh8n8D0fuISphg==",
- "hasInstallScript": true,
- "license": "MIT",
- "bin": {
- "vue-demi-fix": "bin/vue-demi-fix.js",
- "vue-demi-switch": "bin/vue-demi-switch.js"
- },
- "engines": {
- "node": ">=12"
- },
- "funding": {
- "url": "https://github.com/sponsors/antfu"
- },
- "peerDependencies": {
- "@vue/composition-api": "^1.0.0-rc.1",
- "vue": "^3.0.0-0 || ^2.6.0"
- },
- "peerDependenciesMeta": {
- "@vue/composition-api": {
- "optional": true
- }
- }
- },
- "node_modules/@vueuse/motion/node_modules/@vueuse/metadata": {
- "version": "10.11.1",
- "resolved": "https://registry.npmjs.org/@vueuse/metadata/-/metadata-10.11.1.tgz",
- "integrity": "sha512-IGa5FXd003Ug1qAZmyE8wF3sJ81xGLSqTqtQ6jaVfkeZ4i5kS2mwQF61yhVqojRnenVew5PldLyRgvdl4YYuSw==",
- "license": "MIT",
- "funding": {
- "url": "https://github.com/sponsors/antfu"
- }
- },
- "node_modules/@vueuse/motion/node_modules/@vueuse/shared": {
- "version": "10.11.1",
- "resolved": "https://registry.npmjs.org/@vueuse/shared/-/shared-10.11.1.tgz",
- "integrity": "sha512-LHpC8711VFZlDaYUXEBbFBCQ7GS3dVU9mjOhhMhXP6txTV4EhYQg/KGnQuvt/sPAtoUKq7VVUnL6mVtFoL42sA==",
- "license": "MIT",
- "dependencies": {
- "vue-demi": ">=0.14.8"
- },
- "funding": {
- "url": "https://github.com/sponsors/antfu"
- }
- },
- "node_modules/@vueuse/motion/node_modules/@vueuse/shared/node_modules/vue-demi": {
- "version": "0.14.10",
- "resolved": "https://registry.npmjs.org/vue-demi/-/vue-demi-0.14.10.tgz",
- "integrity": "sha512-nMZBOwuzabUO0nLgIcc6rycZEebF6eeUfaiQx9+WSk8e29IbLvPU9feI6tqW4kTo3hvoYAJkMh8n8D0fuISphg==",
- "hasInstallScript": true,
- "license": "MIT",
- "bin": {
- "vue-demi-fix": "bin/vue-demi-fix.js",
- "vue-demi-switch": "bin/vue-demi-switch.js"
- },
- "engines": {
- "node": ">=12"
- },
- "funding": {
- "url": "https://github.com/sponsors/antfu"
- },
- "peerDependencies": {
- "@vue/composition-api": "^1.0.0-rc.1",
- "vue": "^3.0.0-0 || ^2.6.0"
- },
- "peerDependenciesMeta": {
- "@vue/composition-api": {
- "optional": true
- }
- }
- },
"node_modules/@vueuse/nuxt": {
- "version": "11.3.0",
- "resolved": "https://registry.npmjs.org/@vueuse/nuxt/-/nuxt-11.3.0.tgz",
- "integrity": "sha512-FxtRTgFmsoASamR3lOftv/r11o1BojF9zir8obbTnKamVZdlQ5rgJ0hHgVbrgA6dlMuEx/PzwqAmiKNFdU4oCQ==",
- "license": "MIT",
- "dependencies": {
- "@nuxt/kit": "^3.14.1592",
- "@vueuse/core": "11.3.0",
- "@vueuse/metadata": "11.3.0",
- "local-pkg": "^0.5.1",
- "vue-demi": ">=0.14.10"
- },
- "funding": {
- "url": "https://github.com/sponsors/antfu"
- },
- "peerDependencies": {
- "nuxt": "^3.0.0"
- }
- },
- "node_modules/@vueuse/nuxt/node_modules/@types/web-bluetooth": {
- "version": "0.0.20",
- "resolved": "https://registry.npmjs.org/@types/web-bluetooth/-/web-bluetooth-0.0.20.tgz",
- "integrity": "sha512-g9gZnnXVq7gM7v3tJCWV/qw7w+KeOlSHAhgF9RytFyifW6AF61hdT2ucrYhPq9hLs5JIryeupHV3qGk95dH9ow==",
- "license": "MIT"
- },
- "node_modules/@vueuse/nuxt/node_modules/@vueuse/core": {
- "version": "11.3.0",
- "resolved": "https://registry.npmjs.org/@vueuse/core/-/core-11.3.0.tgz",
- "integrity": "sha512-7OC4Rl1f9G8IT6rUfi9JrKiXy4bfmHhZ5x2Ceojy0jnd3mHNEvV4JaRygH362ror6/NZ+Nl+n13LPzGiPN8cKA==",
- "license": "MIT",
- "dependencies": {
- "@types/web-bluetooth": "^0.0.20",
- "@vueuse/metadata": "11.3.0",
- "@vueuse/shared": "11.3.0",
- "vue-demi": ">=0.14.10"
- },
- "funding": {
- "url": "https://github.com/sponsors/antfu"
- }
- },
- "node_modules/@vueuse/nuxt/node_modules/@vueuse/metadata": {
- "version": "11.3.0",
- "resolved": "https://registry.npmjs.org/@vueuse/metadata/-/metadata-11.3.0.tgz",
- "integrity": "sha512-pwDnDspTqtTo2HwfLw4Rp6yywuuBdYnPYDq+mO38ZYKGebCUQC/nVj/PXSiK9HX5otxLz8Fn7ECPbjiRz2CC3g==",
- "license": "MIT",
- "funding": {
- "url": "https://github.com/sponsors/antfu"
- }
- },
- "node_modules/@vueuse/nuxt/node_modules/confbox": {
- "version": "0.1.8",
- "resolved": "https://registry.npmjs.org/confbox/-/confbox-0.1.8.tgz",
- "integrity": "sha512-RMtmw0iFkeR4YV+fUOSucriAQNb9g8zFR52MWCtl+cCZOFRNL6zeB395vPzFhEjjn4fMxXudmELnl/KF/WrK6w==",
- "license": "MIT"
- },
- "node_modules/@vueuse/nuxt/node_modules/local-pkg": {
- "version": "0.5.1",
- "resolved": "https://registry.npmjs.org/local-pkg/-/local-pkg-0.5.1.tgz",
- "integrity": "sha512-9rrA30MRRP3gBD3HTGnC6cDFpaE1kVDWxWgqWJUN0RvDNAo+Nz/9GxB+nHOH0ifbVFy0hSA1V6vFDvnx54lTEQ==",
- "license": "MIT",
- "dependencies": {
- "mlly": "^1.7.3",
- "pkg-types": "^1.2.1"
- },
- "engines": {
- "node": ">=14"
- },
- "funding": {
- "url": "https://github.com/sponsors/antfu"
- }
- },
- "node_modules/@vueuse/nuxt/node_modules/pkg-types": {
- "version": "1.3.1",
- "resolved": "https://registry.npmjs.org/pkg-types/-/pkg-types-1.3.1.tgz",
- "integrity": "sha512-/Jm5M4RvtBFVkKWRu2BLUTNP8/M2a+UwuAX+ae4770q1qVGtfjG+WTCupoZixokjmHiry8uI+dlY8KXYV5HVVQ==",
+ "version": "13.5.0",
+ "resolved": "https://registry.npmjs.org/@vueuse/nuxt/-/nuxt-13.5.0.tgz",
+ "integrity": "sha512-TePmrPlTSTUc9zN0EHu45e6m5UARX3zDy6bSmF47hzbIuqVMG+Vc7ColLA50VZaTNsSdgYc3/Bq3VfYcUEnaEg==",
"license": "MIT",
"dependencies": {
- "confbox": "^0.1.8",
- "mlly": "^1.7.4",
- "pathe": "^2.0.1"
- }
- },
- "node_modules/@vueuse/nuxt/node_modules/vue-demi": {
- "version": "0.14.10",
- "resolved": "https://registry.npmjs.org/vue-demi/-/vue-demi-0.14.10.tgz",
- "integrity": "sha512-nMZBOwuzabUO0nLgIcc6rycZEebF6eeUfaiQx9+WSk8e29IbLvPU9feI6tqW4kTo3hvoYAJkMh8n8D0fuISphg==",
- "hasInstallScript": true,
- "license": "MIT",
- "bin": {
- "vue-demi-fix": "bin/vue-demi-fix.js",
- "vue-demi-switch": "bin/vue-demi-switch.js"
- },
- "engines": {
- "node": ">=12"
+ "@nuxt/kit": "^3.17.6",
+ "@vueuse/core": "13.5.0",
+ "@vueuse/metadata": "13.5.0",
+ "local-pkg": "^1.1.1"
},
"funding": {
"url": "https://github.com/sponsors/antfu"
},
"peerDependencies": {
- "@vue/composition-api": "^1.0.0-rc.1",
- "vue": "^3.0.0-0 || ^2.6.0"
- },
- "peerDependenciesMeta": {
- "@vue/composition-api": {
- "optional": true
- }
+ "nuxt": "^3.0.0 || ^4.0.0-0",
+ "vue": "^3.5.0"
}
},
"node_modules/@vueuse/router": {
@@ -10116,7 +9696,7 @@
"vue-router": "^4.0.0"
}
},
- "node_modules/@vueuse/router/node_modules/@vueuse/shared": {
+ "node_modules/@vueuse/shared": {
"version": "13.5.0",
"resolved": "https://registry.npmjs.org/@vueuse/shared/-/shared-13.5.0.tgz",
"integrity": "sha512-K7GrQIxJ/ANtucxIXbQlUHdB0TPA8c+q5i+zbrjxuhJCnJ9GtBg75sBSnvmLSxHKPg2Yo8w62PWksl9kwH0Q8g==",
@@ -10128,44 +9708,6 @@
"vue": "^3.5.0"
}
},
- "node_modules/@vueuse/shared": {
- "version": "11.3.0",
- "resolved": "https://registry.npmjs.org/@vueuse/shared/-/shared-11.3.0.tgz",
- "integrity": "sha512-P8gSSWQeucH5821ek2mn/ciCk+MS/zoRKqdQIM3bHq6p7GXDAJLmnRRKmF5F65sAVJIfzQlwR3aDzwCn10s8hA==",
- "license": "MIT",
- "dependencies": {
- "vue-demi": ">=0.14.10"
- },
- "funding": {
- "url": "https://github.com/sponsors/antfu"
- }
- },
- "node_modules/@vueuse/shared/node_modules/vue-demi": {
- "version": "0.14.10",
- "resolved": "https://registry.npmjs.org/vue-demi/-/vue-demi-0.14.10.tgz",
- "integrity": "sha512-nMZBOwuzabUO0nLgIcc6rycZEebF6eeUfaiQx9+WSk8e29IbLvPU9feI6tqW4kTo3hvoYAJkMh8n8D0fuISphg==",
- "hasInstallScript": true,
- "license": "MIT",
- "bin": {
- "vue-demi-fix": "bin/vue-demi-fix.js",
- "vue-demi-switch": "bin/vue-demi-switch.js"
- },
- "engines": {
- "node": ">=12"
- },
- "funding": {
- "url": "https://github.com/sponsors/antfu"
- },
- "peerDependencies": {
- "@vue/composition-api": "^1.0.0-rc.1",
- "vue": "^3.0.0-0 || ^2.6.0"
- },
- "peerDependenciesMeta": {
- "@vue/composition-api": {
- "optional": true
- }
- }
- },
"node_modules/@whatwg-node/disposablestack": {
"version": "0.0.6",
"resolved": "https://registry.npmjs.org/@whatwg-node/disposablestack/-/disposablestack-0.0.6.tgz",
@@ -13686,21 +13228,6 @@
"url": "https://github.com/sponsors/rawify"
}
},
- "node_modules/framesync": {
- "version": "6.1.2",
- "resolved": "https://registry.npmjs.org/framesync/-/framesync-6.1.2.tgz",
- "integrity": "sha512-jBTqhX6KaQVDyus8muwZbBeGGP0XgujBRbQ7gM7BRdS3CadCZIHiawyzYLnafYcvZIh5j8WE7cxZKFn7dXhu9g==",
- "license": "MIT",
- "dependencies": {
- "tslib": "2.4.0"
- }
- },
- "node_modules/framesync/node_modules/tslib": {
- "version": "2.4.0",
- "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz",
- "integrity": "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==",
- "license": "0BSD"
- },
"node_modules/fresh": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/fresh/-/fresh-2.0.0.tgz",
@@ -14108,12 +13635,6 @@
"node": ">= 0.4"
}
},
- "node_modules/hey-listen": {
- "version": "1.0.8",
- "resolved": "https://registry.npmjs.org/hey-listen/-/hey-listen-1.0.8.tgz",
- "integrity": "sha512-COpmrF2NOg4TBWUJ5UVyaCU2A88wEMkUPK4hNqyCkqHbxT92BbvfjoSozkAIIm6XhicGlJHhFdullInrdhwU8Q==",
- "license": "MIT"
- },
"node_modules/hookable": {
"version": "5.5.3",
"resolved": "https://registry.npmjs.org/hookable/-/hookable-5.5.3.tgz",
@@ -17959,15 +17480,6 @@
"resolved": "https://registry.npmjs.org/overlayscrollbars/-/overlayscrollbars-2.15.1.tgz",
"integrity": "sha512-glX26JwjL+Tkzv0JNOWdW4VozP5dGXO+Wx8+TPrdTEJTSYT/8eJS8yXM+fewjU0nFq/JeCa+X+BqABNjC4YZSA=="
},
- "node_modules/overlayscrollbars-vue": {
- "version": "0.5.9",
- "resolved": "https://registry.npmjs.org/overlayscrollbars-vue/-/overlayscrollbars-vue-0.5.9.tgz",
- "integrity": "sha512-zZEcsb6llnKaRwXTP44E4RrmwuH+eAi70mgCdiiPwcPBE2H99Vs2V0q7sWnEanqU3462ch38e4SmIMnuH906DQ==",
- "peerDependencies": {
- "overlayscrollbars": "^2.0.0",
- "vue": "^3.2.25"
- }
- },
"node_modules/oxc-parser": {
"version": "0.70.0",
"resolved": "https://registry.npmjs.org/oxc-parser/-/oxc-parser-0.70.0.tgz",
@@ -18511,24 +18023,6 @@
"node": ">=10.13.0"
}
},
- "node_modules/popmotion": {
- "version": "11.0.5",
- "resolved": "https://registry.npmjs.org/popmotion/-/popmotion-11.0.5.tgz",
- "integrity": "sha512-la8gPM1WYeFznb/JqF4GiTkRRPZsfaj2+kCxqQgr2MJylMmIKUwBfWW8Wa5fml/8gmtlD5yI01MP1QCZPWmppA==",
- "license": "MIT",
- "dependencies": {
- "framesync": "6.1.2",
- "hey-listen": "^1.0.8",
- "style-value-types": "5.1.2",
- "tslib": "2.4.0"
- }
- },
- "node_modules/popmotion/node_modules/tslib": {
- "version": "2.4.0",
- "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz",
- "integrity": "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==",
- "license": "0BSD"
- },
"node_modules/postcss": {
"version": "8.5.6",
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.6.tgz",
@@ -20830,22 +20324,6 @@
"integrity": "sha512-wnD1HyVqpJUI2+eKZ+eo1UwghftP6yuFheBqqe+bWCotBjC2K1YnteJILRMs3SM4V/0dLEW1SC27MWP5y+mwmw==",
"license": "MIT"
},
- "node_modules/style-value-types": {
- "version": "5.1.2",
- "resolved": "https://registry.npmjs.org/style-value-types/-/style-value-types-5.1.2.tgz",
- "integrity": "sha512-Vs9fNreYF9j6W2VvuDTP7kepALi7sk0xtk2Tu8Yxi9UoajJdEVpNpCov0HsLTqXvNGKX+Uv09pkozVITi1jf3Q==",
- "license": "MIT",
- "dependencies": {
- "hey-listen": "^1.0.8",
- "tslib": "2.4.0"
- }
- },
- "node_modules/style-value-types/node_modules/tslib": {
- "version": "2.4.0",
- "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz",
- "integrity": "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==",
- "license": "0BSD"
- },
"node_modules/stylehacks": {
"version": "7.0.6",
"resolved": "https://registry.npmjs.org/stylehacks/-/stylehacks-7.0.6.tgz",
@@ -20980,16 +20458,6 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
- "node_modules/tailwind-merge": {
- "version": "2.6.0",
- "resolved": "https://registry.npmjs.org/tailwind-merge/-/tailwind-merge-2.6.0.tgz",
- "integrity": "sha512-P+Vu1qXfzediirmHOC3xKGAYeZtPcV9g76X+xg2FD4tYgR71ewMA35Y3sCz3zhiN/dwefRpJX0yBcgwi1fXNQA==",
- "license": "MIT",
- "funding": {
- "type": "github",
- "url": "https://github.com/sponsors/dcastil"
- }
- },
"node_modules/tailwind-variants": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/tailwind-variants/-/tailwind-variants-1.0.0.tgz",
diff --git a/client/package.json b/client/package.json
index 4d6aba615..0255b8f5a 100644
--- a/client/package.json
+++ b/client/package.json
@@ -3,7 +3,7 @@
"private": true,
"type": "module",
"scripts": {
- "build": "NODE_OPTIONS='--max-old-space-size=8192' nuxt build",
+ "build": "NODE_OPTIONS='--max-old-space-size=8192' nuxt build && npm run check:public-form-bundle",
"build:e2e": "E2E=1 NODE_OPTIONS='--max-old-space-size=8192' nuxt build",
"dev": "export NODE_TLS_REJECT_UNAUTHORIZED=0; node --import ./scripts/node-localstorage-polyfill.mjs ./node_modules/nuxt/bin/nuxt.mjs dev",
"docker-dev": "export NODE_TLS_REJECT_UNAUTHORIZED=0; node --import ./scripts/node-localstorage-polyfill.mjs ./node_modules/nuxt/bin/nuxt.mjs dev --host 0.0.0.0",
@@ -16,10 +16,10 @@
"test:ui": "VITEST=true vitest --ui",
"test:e2e": "playwright test",
"test:e2e:headed": "playwright test --headed",
- "test:e2e:dev": "PLAYWRIGHT_BASE_URL=${PLAYWRIGHT_BASE_URL:-http://127.0.0.1:3100} playwright test"
+ "test:e2e:dev": "PLAYWRIGHT_BASE_URL=${PLAYWRIGHT_BASE_URL:-http://127.0.0.1:3100} playwright test",
+ "check:public-form-bundle": "node scripts/check-public-form-bundle.mjs"
},
"devDependencies": {
- "@playwright/test": "^1.54.2",
"@iconify-json/bxl": "^1.2.2",
"@iconify-json/clarity": "^1.2.1",
"@iconify-json/devicon": "^1.2.56",
@@ -34,6 +34,7 @@
"@nuxt/test-utils": "^3.19.2",
"@nuxtjs/i18n": "^9.0.0",
"@nuxtjs/sitemap": "^7.2.0",
+ "@playwright/test": "^1.54.2",
"@vitest/ui": "^3.2.4",
"@vue/test-utils": "^2.4.6",
"autoprefixer": "^10.4.20",
@@ -68,11 +69,9 @@
"@tanstack/vue-query": "^5.81.5",
"@tanstack/vue-query-devtools": "^5.81.5",
"@tanstack/vue-virtual": "^3.13.12",
- "@vueuse/components": "^11.2.0",
"@vueuse/core": "^13.1.0",
- "@vueuse/integrations": "^11.2.0",
- "@vueuse/motion": "^2.2.6",
- "@vueuse/nuxt": "^11.2.0",
+ "@vueuse/integrations": "^13.5.0",
+ "@vueuse/nuxt": "^13.5.0",
"@vueuse/router": "^13.4.0",
"@zadigetvoltaire/nuxt-gtm": "^0.0.13",
"@zxing/library": "^0.21.3",
@@ -90,14 +89,12 @@
"libphonenumber-js": "^1.11.12",
"object-to-formdata": "^4.5.1",
"overlayscrollbars": "^2.15.1",
- "overlayscrollbars-vue": "^0.5.9",
"pdfjs-dist": "^5.4.530",
"pinia": "^3.0.2",
"prismjs": "^1.29.0",
"qrcode": "^1.5.4",
"quill": "^2.0.2",
"quill-resize-module": "^2.1.3",
- "tailwind-merge": "^2.5.4",
"tailwindcss": "^4.1.10",
"tinymotion": "^0.2.0",
"v-calendar": "3.0.1",
diff --git a/client/pages/forms/[slug]/index.vue b/client/pages/forms/[slug]/index.vue
index fafa04c6c..1104f77b3 100644
--- a/client/pages/forms/[slug]/index.vue
+++ b/client/pages/forms/[slug]/index.vue
@@ -26,7 +26,7 @@
</div>
</div>
<div v-else-if="formNotFound || (!formLoading && !form)">
- <NotFoundForm />
+ <LazyNotFoundForm />
</div>
<div v-else-if="formLoading">
<p class="text-center mt-6 p-4">
@@ -34,7 +34,7 @@
</p>
</div>
<template v-else>
- <FormAnalyticsScript
+ <LazyOpenFormsFormAnalyticsScript
v-if="form.analytics?.provider && form.analytics?.tracking_id"
ref="analyticsScriptRef"
:form="form"
@@ -55,8 +55,6 @@
<script setup>
import OpenCompleteForm from "~/components/open/forms/OpenCompleteForm.vue"
-import FormAnalyticsScript from "~/components/open/forms/FormAnalyticsScript.vue"
-import sha256 from 'js-sha256'
import { onBeforeRouteLeave } from 'vue-router'
import {
disableDarkMode,
@@ -142,19 +140,16 @@ const passwordEntered = function (password) {
sameSite: usesHttps ? 'none' : 'lax',
secure: usesHttps
})
- cookie.value = sha256(password)
-
- // Clear any previous error
- passwordError.value = null
-
- nextTick(() => {
- refetchForm().then(() => {
+ return import('js-sha256').then(({ default: sha256 }) => {
+ cookie.value = sha256(password)
+ passwordError.value = null
+
+ return nextTick().then(() => refetchForm()).then(() => {
if (form.value?.is_password_protected) {
- // Set error message - child component will pick it up
passwordError.value = t('forms.invalid_password')
- } else {
- trackFormView()
+ return
}
+ trackFormView()
})
})
}
@@ -383,7 +378,10 @@ useHead({
},
] : {},
script: computed(() => {
- const scripts = [{ src: '/widgets/iframeResizer.contentWindow.min.js' }]
+ const scripts = []
+ if (isIframe) {
+ scripts.push({ src: '/widgets/iframeResizer.contentWindow.min.js' })
+ }
// Load local SDK stub before custom code if needed
if (shouldLoadLocalSdk.value) {
scripts.unshift({ src: '/widgets/opnform-local.js' })
diff --git a/client/pages/index.vue b/client/pages/index.vue
index de4582b88..935681cf0 100644
--- a/client/pages/index.vue
+++ b/client/pages/index.vue
@@ -171,7 +171,7 @@
import LiveDemo from "~/components/pages/welcome/LiveDemo.vue"
import Features from "~/components/pages/welcome/Features.vue"
import MoreFeatures from "../components/pages/welcome/MoreFeatures.vue"
-import { useIsAuthenticated } from "~/composables/useAuthFlow"
+import { useIsAuthenticated } from "~/composables/useIsAuthenticated.js"
definePageMeta({
layout: "default",
diff --git a/client/pages/pricing.vue b/client/pages/pricing.vue
index ebb22c450..bf23f1577 100644
--- a/client/pages/pricing.vue
+++ b/client/pages/pricing.vue
@@ -733,7 +733,7 @@
<script setup>
import FeatureComparison from "~/components/pages/pricing/FeatureComparison.vue"
import FaqSection from "~/components/pages/FaqSection.vue"
-import { useIsAuthenticated } from "~/composables/useAuthFlow"
+import { useIsAuthenticated } from "~/composables/useIsAuthenticated.js"
definePageMeta({
layout: "default",
diff --git a/client/plugins/00.codex-auto-login.client.js b/client/plugins/00.codex-auto-login.client.js
index 8091ea6d3..ecfe1f2a7 100644
--- a/client/plugins/00.codex-auto-login.client.js
+++ b/client/plugins/00.codex-auto-login.client.js
@@ -1,6 +1,6 @@
import { authApi } from '~/api'
-export default defineNuxtPlugin(() => {
+export default defineNuxtPlugin((nuxtApp) => {
const config = useRuntimeConfig()
const isCodexAutoLoginEnabled = config.public.codexAutoLogin
@@ -20,7 +20,11 @@ export default defineNuxtPlugin(() => {
email: config.public.codexAutoLoginEmail,
password: config.public.codexAutoLoginPassword,
})
- .then((tokenData) => useAuthFlow().handleAuthSuccess(tokenData, 'codex'))
+ .then(async (tokenData) => {
+ const authFlow = await import('~/composables/useAuthFlow')
+ const { handleAuthSuccess } = nuxtApp.runWithContext(() => authFlow.useAuthFlow())
+ return handleAuthSuccess(tokenData, 'codex')
+ })
.then(() => navigateTo({ name: 'home' }))
.catch((error) => {
console.warn('Codex auto-login failed.', error)
diff --git a/client/plugins/app-modals.js b/client/plugins/app-modals.js
deleted file mode 100644
index 69f3fc1cf..000000000
--- a/client/plugins/app-modals.js
+++ /dev/null
@@ -1,12 +0,0 @@
-export default defineNuxtPlugin(() => {
- useAppModals()
-
- return {
- provide: {
- // Provide a lazy getter that initializes on first access
- get appModals() {
- return useAppModals()
- }
- }
- }
-})
\ No newline at end of file
diff --git a/client/plugins/crisp.client.js b/client/plugins/crisp.client.js
index a79b32120..922d76ef0 100644
--- a/client/plugins/crisp.client.js
+++ b/client/plugins/crisp.client.js
@@ -1,6 +1,4 @@
-import { Crisp } from "crisp-sdk-web"
-
-export default defineNuxtPlugin(() => {
+export default defineNuxtPlugin((nuxtApp) => {
const isIframe = useIsIframe()
const router = useRouter()
const crispWebsiteId = useRuntimeConfig().public.crispWebsiteId
@@ -14,24 +12,32 @@ export default defineNuxtPlugin(() => {
const isPublicFormPage = () => currentRoute.name === 'forms-slug'
// Initialize Crisp SDK and set up event listeners
+ let crispPromise = null
const initCrisp = () => {
- if (window.Crisp) return // Already initialized
+ if (window.Crisp) return Promise.resolve(window.Crisp)
+ if (crispPromise) return crispPromise
- Crisp.configure(crispWebsiteId)
- window.Crisp = Crisp
+ crispPromise = import('crisp-sdk-web').then(({ Crisp }) => {
+ Crisp.configure(crispWebsiteId)
+ window.Crisp = Crisp
- // Set up Crisp callbacks (same as useCrisp().onCrispInit() + showChat())
- const appStore = useAppStore()
- Crisp.chat.onChatOpened(() => {
- appStore.crisp.chatOpened = true
- })
- Crisp.chat.onChatClosed(() => {
- appStore.crisp.chatOpened = false
+ const appStore = useAppStore()
+ Crisp.chat.onChatOpened(() => {
+ appStore.crisp.chatOpened = true
+ })
+ Crisp.chat.onChatClosed(() => {
+ appStore.crisp.chatOpened = false
+ })
+ Crisp.chat.show()
+ appStore.crisp.hidden = false
+ return Crisp
})
- Crisp.chat.show()
- appStore.crisp.hidden = false
+
+ return crispPromise
}
+ nuxtApp.provide('ensureCrisp', initCrisp)
+
// If not on public form page, initialize immediately
if (!isPublicFormPage()) {
initCrisp()
diff --git a/client/plugins/overlayscrollbars-global.client.js b/client/plugins/overlayscrollbars-global.client.js
deleted file mode 100644
index 53e0bc0c8..000000000
--- a/client/plugins/overlayscrollbars-global.client.js
+++ /dev/null
@@ -1,38 +0,0 @@
-import 'overlayscrollbars/overlayscrollbars.css'
-import { OverlayScrollbarsComponent } from 'overlayscrollbars-vue'
-import { h, mergeProps } from 'vue'
-
-const scrollbarOptions = {
- overflow: { x: 'hidden', y: 'scroll' },
- scrollbars: {
- theme: 'os-theme-dark',
- visibility: 'auto',
- autoHide: 'never',
- autoHideDelay: 800,
- autoHideSuspend: true,
- },
-}
-
-const OverlayScrollbarsWithDefaults = {
- name: 'OverlayScrollbarsComponent',
- inheritAttrs: false,
- setup (_, { attrs, slots, expose }) {
- const inner = ref(null)
- expose({
- osInstance: () => inner.value?.osInstance(),
- getElement: () => inner.value?.getElement(),
- })
-
- return () => {
- const merged = mergeProps(attrs, {
- options: { ...scrollbarOptions, ...attrs.options },
- ref: inner,
- })
- return h(OverlayScrollbarsComponent, merged, slots)
- }
- },
-}
-
-export default defineNuxtPlugin((nuxtApp) => {
- nuxtApp.vueApp.component('OverlayScrollbarsComponent', OverlayScrollbarsWithDefaults)
-})
diff --git a/client/plugins/vue-confetti.client.js b/client/plugins/vue-confetti.client.js
deleted file mode 100644
index 866d812b4..000000000
--- a/client/plugins/vue-confetti.client.js
+++ /dev/null
@@ -1,5 +0,0 @@
-import VueConfetti from "vue-confetti"
-
-export default defineNuxtPlugin((nuxtApp) => {
- nuxtApp.vueApp.use(VueConfetti)
-})
diff --git a/client/scripts/check-public-form-bundle.mjs b/client/scripts/check-public-form-bundle.mjs
new file mode 100644
index 000000000..e446ebe5e
--- /dev/null
+++ b/client/scripts/check-public-form-bundle.mjs
@@ -0,0 +1,93 @@
+import { readFileSync, existsSync } from 'node:fs'
+import { gzipSync } from 'node:zlib'
+
+const manifestPath = new URL('../.nuxt/dist/server/client.manifest.json', import.meta.url)
+const publicAssetsUrl = new URL('../.output/public/_nuxt/', import.meta.url)
+const buildAssetsUrl = new URL('../.nuxt/dist/client/_nuxt/', import.meta.url)
+const maximumGzipBytes = 420 * 1024
+const routeEntry = 'pages/forms/[slug]/index.vue'
+const scenarios = {
+ classic: ['OpenForm', 'TextInput', 'SelectInput'],
+ focused: ['OpenFormFocused', 'FocusedSelectorInput', 'FocusedToggleInput'],
+}
+const forbiddenSources = [
+ '/@codemirror/',
+ '/codemirror/',
+ '/crisp-sdk-web/',
+ '/amplitude-js/',
+ '/vue-draggable-plus/',
+ '/overlayscrollbars/',
+ '/overlayscrollbars-vue/',
+ '/composables/useAuthFlow.js',
+ '/components/workspaces/settings/',
+ '/components/users/settings/',
+]
+
+if (!existsSync(manifestPath)) {
+ throw new Error('Nuxt client manifest not found. Run this check after `nuxt build`.')
+}
+
+const manifest = JSON.parse(readFileSync(manifestPath, 'utf8'))
+
+if (!manifest[routeEntry]) {
+ throw new Error(`Missing ${routeEntry} from the Nuxt client manifest.`)
+}
+
+function findComponentEntry(componentName) {
+ return Object.entries(manifest).find(([, entry]) => entry.name === componentName)?.[0]
+}
+
+function inspectScenario(scenarioName, componentNames) {
+ const roots = [routeEntry, ...componentNames.map((componentName) => {
+ const entryKey = findComponentEntry(componentName)
+ if (!entryKey) throw new Error(`Missing ${componentName} from the Nuxt client manifest.`)
+ return entryKey
+ })]
+ const entries = new Set()
+
+ function collectImports(key) {
+ if (entries.has(key) || !manifest[key]) return
+ entries.add(key)
+ for (const importedKey of manifest[key].imports || []) collectImports(importedKey)
+ }
+ roots.forEach(collectImports)
+
+ let gzipBytes = 0
+ const forbiddenHits = new Set()
+
+ for (const key of entries) {
+ const entry = manifest[key]
+ if (entry.resourceType !== 'script' || !entry.file) continue
+
+ const assetUrl = new URL(entry.file, publicAssetsUrl)
+ if (!existsSync(assetUrl)) {
+ throw new Error(`Missing built asset for ${key}: ${entry.file}`)
+ }
+ gzipBytes += gzipSync(readFileSync(assetUrl)).length
+
+ const sourceMapUrl = new URL(`${entry.file}.map`, buildAssetsUrl)
+ if (!existsSync(sourceMapUrl)) continue
+ const sourceMap = JSON.parse(readFileSync(sourceMapUrl, 'utf8'))
+ for (const source of sourceMap.sources || []) {
+ const normalizedSource = source.replaceAll('\\', '/')
+ for (const forbiddenSource of forbiddenSources) {
+ if (normalizedSource.includes(forbiddenSource)) forbiddenHits.add(forbiddenSource)
+ }
+ }
+ }
+
+ const gzipKilobytes = (gzipBytes / 1024).toFixed(1)
+ console.log(`Public ${scenarioName} form bundle: ${gzipKilobytes} KiB gzip across ${entries.size} manifest entries.`)
+
+ if (forbiddenHits.size) {
+ throw new Error(`Public ${scenarioName} form bundle contains forbidden eager sources: ${[...forbiddenHits].join(', ')}`)
+ }
+
+ if (gzipBytes > maximumGzipBytes) {
+ throw new Error(`Public ${scenarioName} form bundle exceeds the ${maximumGzipBytes / 1024} KiB gzip budget.`)
+ }
+}
+
+Object.entries(scenarios).forEach(([scenarioName, componentNames]) => {
+ inspectScenario(scenarioName, componentNames)
+})
diff --git a/client/stores/working_form.js b/client/stores/working_form.js
index 43938ade4..ad86eb19b 100644
--- a/client/stores/working_form.js
+++ b/client/stores/working_form.js
@@ -3,7 +3,7 @@ import clonedeep from "clone-deep"
import { generateUUID } from "~/lib/utils.js"
import blocksTypes from "~/data/blocks_types.json"
import { useAlert } from '~/composables/useAlert'
-import { useIsAuthenticated } from '~/composables/useAuthFlow'
+import { useIsAuthenticated } from '~/composables/useIsAuthenticated.js'
import { useForm } from '~/composables/useForm'
diff --git a/client/test/nuxt/select-input-accessibility.spec.ts b/client/test/nuxt/select-input-accessibility.spec.ts
index ec4f3d6ca..76b6740a2 100644
--- a/client/test/nuxt/select-input-accessibility.spec.ts
+++ b/client/test/nuxt/select-input-accessibility.spec.ts
@@ -24,6 +24,7 @@ describe('SelectInput accessibility', () => {
options,
},
global: {
+ mocks: { $t: key => key },
stubs: {
InputWrapper: {
props: ['id', 'name', 'label'],
@@ -129,4 +130,51 @@ describe('VSelect accessibility', () => {
expect(wrapper.get('button[aria-haspopup="listbox"]').attributes('disabled')).toBeDefined()
})
+
+ it('does not load Fuse before the user searches', async () => {
+ const wrapper = mount(VSelect, {
+ props: {
+ data: [
+ { value: 'bug', name: 'Bug report' },
+ { value: 'idea', name: 'Feature idea' },
+ ],
+ searchable: true,
+ searchKeys: ['name'],
+ },
+ global: {
+ mocks: { $t: key => key },
+ stubs: {
+ UPopover: popoverStub,
+ Icon: true,
+ Loader: true,
+ },
+ },
+ })
+
+ expect(wrapper.vm.fuse).toBe(null)
+ })
+
+ it('loads fuzzy search on demand once the user searches', async () => {
+ const data = Array.from({ length: 50 }, (_, index) => ({
+ value: index,
+ name: `Option ${index}`,
+ }))
+ const wrapper = mount(VSelect, {
+ props: { data, searchable: true, searchKeys: ['name'] },
+ global: {
+ mocks: { $t: key => key },
+ stubs: {
+ UPopover: popoverStub,
+ Icon: true,
+ Loader: true,
+ },
+ },
+ })
+
+ wrapper.vm.searchTerm = 'Option 4'
+ await wrapper.vm.$nextTick()
+ await wrapper.vm.ensureFuse()
+
+ expect(wrapper.vm.fuse).not.toBe(null)
+ })
})
diff --git a/client/test/nuxt/subscription-modal-self-hosted.spec.ts b/client/test/nuxt/subscription-modal-self-hosted.spec.ts
index c6a7ddd81..4d535a114 100644
--- a/client/test/nuxt/subscription-modal-self-hosted.spec.ts
+++ b/client/test/nuxt/subscription-modal-self-hosted.spec.ts
@@ -56,7 +56,7 @@ vi.mock('~/composables/query/useAuth.js', async () => {
}
})
-vi.mock('~/composables/useAuthFlow.js', async () => {
+vi.mock('~/composables/useIsAuthenticated.js', async () => {
const vue = await import('vue')
return {
diff --git a/client/test/unit/field-options.test.ts b/client/test/unit/field-options.test.ts
new file mode 100644
index 000000000..95fffd2af
--- /dev/null
+++ b/client/test/unit/field-options.test.ts
@@ -0,0 +1,18 @@
+import { describe, expect, it } from 'vitest'
+import { getFieldOptions } from '../../lib/forms/field-options.js'
+
+describe('getFieldOptions', () => {
+ it('reads public API options from the field root', () => {
+ expect(getFieldOptions({
+ type: 'select',
+ options: [{ name: '1-10', id: 'team-size-small' }],
+ })).toEqual([{ name: '1-10', value: '1-10', image: null }])
+ })
+
+ it('keeps supporting nested editor options', () => {
+ expect(getFieldOptions({
+ type: 'multi_select',
+ multi_select: { options: [{ name: 'Product', image: 'product.png' }] },
+ })).toEqual([{ name: 'Product', value: 'Product', image: 'product.png' }])
+ })
+})
diff --git a/client/test/unit/useForms-detail-options.test.ts b/client/test/unit/useForms-detail-options.test.ts
index 87ceeeb8f..54ae4482f 100644
--- a/client/test/unit/useForms-detail-options.test.ts
+++ b/client/test/unit/useForms-detail-options.test.ts
@@ -27,7 +27,7 @@ vi.mock('~/api/forms', () => ({
},
}))
-vi.mock('~/composables/useAuthFlow', () => ({
+vi.mock('~/composables/useIsAuthenticated.js', () => ({
useIsAuthenticated: () => ({ isAuthenticated: { value: true } }),
}))