surveys-embed -> surveys package

This commit is contained in:
Dhruwang
2025-11-25 15:17:03 +05:30
parent ed70c5fb73
commit c65ee80066
127 changed files with 47 additions and 72 deletions

View File

@@ -369,7 +369,7 @@ const nextConfig = {
destination: "/js/formbricks.umd.cjs",
},
{
source: "/api/packages/survey-embed",
source: "/api/packages/surveys",
destination: "/js/surveys.umd.cjs",
},
{

View File

@@ -32,7 +32,7 @@
"@formbricks/js-core": "workspace:*",
"@formbricks/logger": "workspace:*",
"@formbricks/storage": "workspace:*",
"@formbricks/survey-embed": "workspace:*",
"@formbricks/surveys": "workspace:*",
"@formbricks/types": "workspace:*",
"@hookform/resolvers": "5.0.1",
"@intercom/messenger-js-sdk": "0.0.14",

View File

@@ -104,7 +104,7 @@ The `packages/` directory contains shared libraries and utilities:
* Survey rendering logic and UI components
* Used in web app, Storybook, and compiled to Preact for embeds
### packages/survey-embed/
### packages/surveys/
* Preact-compiled survey embed bundle
* Lightweight widget for embedding surveys into customer websites

View File

@@ -34,7 +34,7 @@
"prepare": "husky install",
"storybook": "turbo run storybook",
"fb-migrate-dev": "pnpm --filter @formbricks/database create-migration && pnpm prisma generate",
"i18n:generate": " pnpm --filter @formbricks/survey-embed i18n:generate",
"i18n:generate": " pnpm --filter @formbricks/surveys i18n:generate",
"generate-translations": "cd apps/web && npx lingo.dev@latest i18n",
"scan-translations": "pnpm --filter @formbricks/i18n-utils scan-translations",
"i18n": "pnpm generate-translations && pnpm scan-translations",

View File

@@ -8,7 +8,7 @@ This package serves as the source of truth for survey UI components that are use
- **Storybook** (React) - Component documentation and visual testing
- **Next.js web app** (React) - Main application UI
- **Embed bundle** (Preact) - Compiled via `@formbricks/survey-embed` using `preact/compat`
- **Embed bundle** (Preact) - Compiled via `@formbricks/surveys` using `preact/compat`
## Architecture
@@ -23,7 +23,7 @@ All components are authored using standard React patterns:
### Build Strategy
- **survey-core**: React components, treated as a normal React library
- **survey-embed**: Build step aliases `react``preact/compat`, producing a small Preact-powered widget
- **surveys**: Build step aliases `react``preact/compat`, producing a small Preact-powered widget
- **Web app + Storybook**: Continue using real React with no changes
## Features
@@ -79,5 +79,5 @@ Components from this package are automatically available in Storybook for visual
### In Embed Bundle
The `@formbricks/survey-embed` package imports from this package and compiles it to Preact for lightweight embeds.
The `@formbricks/surveys` package imports from this package and compiles it to Preact for lightweight embeds.

View File

@@ -4,7 +4,7 @@
// This package exports React components that can be used in:
// - Storybook (React)
// - Next.js web app (React)
// - Embed bundle (compiled to Preact via @formbricks/survey-embed)
// - Embed bundle (compiled to Preact via @formbricks/surveys)
// Common components
export { BackButton } from "./components/common/back-button";

View File

@@ -1,21 +1,21 @@
import i18n from "i18next";
import ICU from "i18next-icu";
import { initReactI18next } from "react-i18next";
// Import translations from survey-embed (shared translations)
import arTranslations from "../../../survey-embed/locales/ar.json";
import deTranslations from "../../../survey-embed/locales/de.json";
import enTranslations from "../../../survey-embed/locales/en.json";
import esTranslations from "../../../survey-embed/locales/es.json";
import frTranslations from "../../../survey-embed/locales/fr.json";
import hiTranslations from "../../../survey-embed/locales/hi.json";
import itTranslations from "../../../survey-embed/locales/it.json";
import jaTranslations from "../../../survey-embed/locales/ja.json";
import nlTranslations from "../../../survey-embed/locales/nl.json";
import ptTranslations from "../../../survey-embed/locales/pt.json";
import roTranslations from "../../../survey-embed/locales/ro.json";
import ruTranslations from "../../../survey-embed/locales/ru.json";
import uzTranslations from "../../../survey-embed/locales/uz.json";
import zhHansTranslations from "../../../survey-embed/locales/zh-Hans.json";
// Import translations from surveys (shared translations)
import arTranslations from "../../../surveys/locales/ar.json";
import deTranslations from "../../../surveys/locales/de.json";
import enTranslations from "../../../surveys/locales/en.json";
import esTranslations from "../../../surveys/locales/es.json";
import frTranslations from "../../../surveys/locales/fr.json";
import hiTranslations from "../../../surveys/locales/hi.json";
import itTranslations from "../../../surveys/locales/it.json";
import jaTranslations from "../../../surveys/locales/ja.json";
import nlTranslations from "../../../surveys/locales/nl.json";
import ptTranslations from "../../../surveys/locales/pt.json";
import roTranslations from "../../../surveys/locales/ro.json";
import ruTranslations from "../../../surveys/locales/ru.json";
import uzTranslations from "../../../surveys/locales/uz.json";
import zhHansTranslations from "../../../surveys/locales/zh-Hans.json";
i18n
.use(ICU)

View File

@@ -1,4 +0,0 @@
module.exports = {
extends: ["@formbricks/eslint-config/legacy-react.js"],
parser: "@typescript-eslint/parser",
};

View File

@@ -1,24 +0,0 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
dist
dist-ssr
*.local
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

View File

@@ -1,6 +1,6 @@
## Overview
The `@formbricks/survey-embed` package provides a complete survey rendering system built with Preact. It features automated translation management through Lingo.dev and is compiled from React-style components in `@formbricks/survey-core`.
The `@formbricks/surveys` package provides a complete survey rendering system built with Preact. It features automated translation management through Lingo.dev and is compiled from React-style components in `@formbricks/survey-core`.
## Features
@@ -16,7 +16,7 @@ The `@formbricks/survey-embed` package provides a complete survey rendering syst
### File Structure
```text
packages/survey-embed/
packages/surveys/
├── locales/ # Translation files
│ ├── en.json # Source translations (English)
│ ├── de.json # Generated translations (German)
@@ -65,7 +65,7 @@ packages/survey-embed/
In the surveys package directory, create a `.env` file:
```bash
# packages/survey-embed/.env
# packages/surveys/.env
LINGODOTDEV_API_KEY=<YOUR_API_KEY>
```
@@ -84,14 +84,14 @@ This will execute the auto-translate script and update translation files if need
### Adding New Translation Keys
1. **Update Source File**: Add new keys to `packages/survey-embed/locales/en.json`
1. **Update Source File**: Add new keys to `packages/surveys/locales/en.json`
2. **Generate Translations**: Run `pnpm run i18n:generate`
3. **Update Components**: Use the new translation keys in your components with `useTranslation` hook
4. **Test**: Verify translations work across all supported languages
### Updating Existing Translations
1. **Update Target File**: Update the translation keys in the target language file (`packages/survey-embed/locales/<target-language>.json`)
1. **Update Target File**: Update the translation keys in the target language file (`packages/surveys/locales/<target-language>.json`)
2. **Test**: Verify translations work across all supported languages
3. You don't need to run the `i18n:generate` command as it is only required when the source language is updated.
@@ -99,7 +99,7 @@ This will execute the auto-translate script and update translation files if need
#### 1. Update lingo.dev Configuration
Edit `packages/survey-embed/i18n.json` to include new target languages:
Edit `packages/surveys/i18n.json` to include new target languages:
```json
{
@@ -112,7 +112,7 @@ Edit `packages/survey-embed/i18n.json` to include new target languages:
#### 2. Update i18n Configuration
Modify `packages/survey-embed/src/lib/i18n.config.ts`:
Modify `packages/surveys/src/lib/i18n.config.ts`:
```tsx
// Add new import

View File

@@ -1,9 +1,9 @@
{
"name": "@formbricks/survey-embed",
"name": "@formbricks/surveys",
"license": "MIT",
"version": "1.0.0",
"private": true,
"description": "Formbricks survey embed bundle - Preact-compiled widget for embedding surveys into customer websites.",
"description": "Formbricks surveys package - Preact-compiled widget for embedding surveys into customer websites.",
"homepage": "https://formbricks.com",
"type": "module",
"repository": {

View File

@@ -1,5 +1,5 @@
/**
* Adds the 'fb-' prefix to Tailwind CSS classes for survey-embed
* Adds the 'fb-' prefix to Tailwind CSS classes for surveys
* Handles pseudo-classes, responsive prefixes, and negative values
*/
export function addFbPrefix(className: string): string {

Some files were not shown because too many files have changed in this diff Show More