clean ups

This commit is contained in:
Dhruwang
2025-11-25 16:25:48 +05:30
parent ef601a5437
commit 57a5b40717
17 changed files with 51 additions and 218 deletions
+1 -14
View File
@@ -1,6 +1,5 @@
import type { Preview } from "@storybook/react-vite";
import React from "react";
import { I18nProvider as UiI18nProvider } from "../../../packages/ui/src/components/i18n/provider";
import { I18nProvider as WebI18nProvider } from "../../web/lingodotdev/client";
import "../../web/modules/ui/globals.css";
@@ -15,18 +14,6 @@ const withLingodotDev = (Story: any) => {
React.createElement(Story)
);
};
// Create a Storybook-specific i18n decorator for ui package components
const withUiI18n = (Story: any) => {
return React.createElement(
UiI18nProvider,
{
language: "en",
} as any,
React.createElement(Story)
);
};
const preview: Preview = {
parameters: {
controls: {
@@ -36,7 +23,7 @@ const preview: Preview = {
},
},
},
decorators: [withLingodotDev, withUiI18n],
decorators: [withLingodotDev],
};
export default preview;
+4
View File
@@ -0,0 +1,4 @@
module.exports = {
extends: ["@formbricks/eslint-config/legacy-react.js"],
parser: "@typescript-eslint/parser",
};
+24
View File
@@ -0,0 +1,24 @@
# 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?
+1 -1
View File
@@ -1,6 +1,6 @@
## Overview
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/ui`.
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 components in `@formbricks/ui`.
## Features
+1 -1
View File
@@ -3,7 +3,7 @@
"license": "MIT",
"version": "1.0.0",
"private": true,
"description": "Formbricks surveys package - Preact-compiled widget for embedding surveys into customer websites.",
"description": "Formbricks-surveys is a helper library to embed surveys into your application.",
"homepage": "https://formbricks.com",
"type": "module",
"repository": {
-33
View File
@@ -1,33 +0,0 @@
/**
* Adds the 'fb-' prefix to Tailwind CSS classes for surveys
* Handles pseudo-classes, responsive prefixes, and negative values
*/
export function addFbPrefix(className: string): string {
if (!className) return className;
return className
.split(/\s+/)
.map((cls) => {
if (!cls || cls.startsWith("fb-")) return cls;
// Handle pseudo-classes and responsive prefixes (hover:, focus:, sm:, etc.)
const pseudoMatch = cls.match(/^([a-z-]+:)(.+)$/);
if (pseudoMatch) {
const [, prefix, rest] = pseudoMatch;
// Add fb- prefix to the class part, handling negative values
if (rest.startsWith("-")) {
return `${prefix}-fb-${rest.slice(1)}`;
}
return `${prefix}fb-${rest}`;
}
// Handle negative values (e.g., -translate-x-1/2)
if (cls.startsWith("-")) {
return `-fb-${cls.slice(1)}`;
}
// Regular class
return `fb-${cls}`;
})
.join(" ");
}
@@ -1,15 +0,0 @@
import { addFbPrefix } from "./add-fb-prefix";
/**
* Enhanced cn utility that automatically adds fb- prefix to classes
* This replaces ui package's cn utility via Vite alias
* All ui package components will automatically get fb- prefixed classes
*/
export function cn(...classes: (string | undefined | null | false)[]): string {
// Filter out falsy values and join
const combined = classes.filter((cls): cls is string => Boolean(cls)).join(" ");
// Add fb- prefix to all Tailwind classes
// Handle empty string case (when all classes are falsy)
if (!combined) return "";
return addFbPrefix(combined);
}
+1 -1
View File
@@ -14,5 +14,5 @@
"resolveJsonModule": true
},
"extends": "@formbricks/config-typescript/js-library.json",
"include": ["src", "../types/surveys.d.ts"]
"include": ["src", "../types/surveys.d.ts", "vite-env.d.ts"]
}
+6
View File
@@ -0,0 +1,6 @@
/// <reference types="vite/client" />
declare module "*.css?inline" {
const content: string;
export default content;
}
+2 -41
View File
@@ -17,7 +17,6 @@ const __dirname = dirname(__filename);
*/
function addFbPrefixPlugin(): Plugin {
const uiUtilsPath = resolve(__dirname, "../ui/src/lib/utils.ts");
const embedCnPath = resolve(__dirname, "src/lib/cn-with-prefix.ts");
const uiSrcPath = resolve(__dirname, "../ui/src");
return {
@@ -38,47 +37,9 @@ function addFbPrefixPlugin(): Plugin {
normalizedImporter.includes("/ui/") ||
normalizedImporter.includes("\\ui\\");
if (isFromUi) {
// Handle @/lib/utils alias
if (id === "@/lib/utils" || id === "@/lib/utils.ts") {
return embedCnPath;
}
// Plugin functionality removed - cn-with-prefix.ts file was deleted
// If prefix functionality is needed, it should be reimplemented
// Handle relative imports like "../../lib/utils" or "../lib/utils"
if (id.includes("lib/utils")) {
try {
const resolved = resolve(dirname(importer), id);
const normalizedResolved = resolved.replace(/\\/g, "/");
const normalizedTarget = uiUtilsPath.replace(/\\/g, "/");
if (normalizedResolved === normalizedTarget) {
return embedCnPath;
}
} catch {
// Ignore resolution errors
}
}
}
// Also intercept direct imports of ui package's utils file
const normalizedId = id.replace(/\\/g, "/");
const normalizedTarget = uiUtilsPath.replace(/\\/g, "/");
if (normalizedId === normalizedTarget) {
return embedCnPath;
}
return null;
},
load(id) {
// Intercept when the actual utils file is loaded
const normalizedId = id.replace(/\\/g, "/");
const normalizedTarget = surveyCoreUtilsPath.replace(/\\/g, "/");
if (normalizedId === normalizedTarget) {
// Return our prefixed version - use relative path from embed
const relativePath = embedCnPath.replace(/\\/g, "/");
return `export { cn } from "${relativePath}";`;
}
return null;
},
};
+1 -9
View File
@@ -37,15 +37,7 @@
"test:coverage": "vitest run --coverage"
},
"dependencies": {
"@calcom/embed-snippet": "1.3.3",
"@formkit/auto-animate": "0.8.2",
"i18next": "25.5.2",
"i18next-icu": "2.4.0",
"isomorphic-dompurify": "2.24.0",
"react": "19.1.0",
"react-calendar": "5.1.0",
"react-date-picker": "11.0.0",
"react-i18next": "15.7.3"
"react": "19.1.0"
},
"devDependencies": {
"@formbricks/config-typescript": "workspace:*",
@@ -1,4 +1,3 @@
import { useTranslation } from "react-i18next";
import { cn } from "../../lib/utils";
interface BackButtonProps {
@@ -9,7 +8,6 @@ interface BackButtonProps {
}
export function BackButton({ onClick, backButtonLabel, tabIndex = 2 }: BackButtonProps) {
const { t } = useTranslation();
return (
<button
dir="auto"
@@ -19,7 +17,7 @@ export function BackButton({ onClick, backButtonLabel, tabIndex = 2 }: BackButto
"hover:bg-input-bg text-heading focus:ring-focus rounded-custom mb-1 flex items-center px-3 py-3 text-base font-medium leading-4 focus:outline-none focus:ring-2 focus:ring-offset-2"
)}
onClick={onClick}>
{backButtonLabel || t("common.back")}
{backButtonLabel}
</button>
);
}
@@ -1,16 +0,0 @@
import { useEffect } from "react";
import { I18nextProvider } from "react-i18next";
import i18n from "../../lib/i18n.config";
interface I18nProviderProps {
language?: string;
children: React.ReactNode;
}
export const I18nProvider = ({ language = "en", children }: I18nProviderProps) => {
useEffect(() => {
i18n.changeLanguage(language);
}, [language]);
return <I18nextProvider i18n={i18n}>{children}</I18nextProvider>;
};
-3
View File
@@ -9,8 +9,5 @@
// Common components
export { BackButton } from "./components/common/back-button";
// i18n provider
export { I18nProvider } from "./components/i18n/provider";
// Utilities
export { cn } from "./lib/utils";
-47
View File
@@ -1,47 +0,0 @@
import i18n from "i18next";
import ICU from "i18next-icu";
import { initReactI18next } from "react-i18next";
// 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)
.use(initReactI18next)
.init({
fallbackLng: "en",
supportedLngs: ["en", "de", "it", "fr", "es", "ar", "pt", "ro", "ja", "ru", "uz", "zh-Hans", "hi", "nl"],
resources: {
en: { translation: enTranslations },
de: { translation: deTranslations },
it: { translation: itTranslations },
fr: { translation: frTranslations },
es: { translation: esTranslations },
ar: { translation: arTranslations },
pt: { translation: ptTranslations },
ro: { translation: roTranslations },
ja: { translation: jaTranslations },
nl: { translation: nlTranslations },
ru: { translation: ruTranslations },
uz: { translation: uzTranslations },
"zh-Hans": { translation: zhHansTranslations },
hi: { translation: hiTranslations },
},
interpolation: { escapeValue: false },
});
export default i18n;
+1 -1
View File
@@ -2,9 +2,9 @@
"compilerOptions": {
"allowImportingTsExtensions": true,
"baseUrl": ".",
"emitDeclarationOnly": true,
"isolatedModules": true,
"jsx": "react-jsx",
"noEmit": true,
"paths": {
"@/*": ["./src/*"]
},
+8 -33
View File
@@ -826,7 +826,7 @@ importers:
version: 5.1.0(@types/react@19.1.4)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)
react-date-picker:
specifier: 11.0.0
version: 11.0.0(@types/react-dom@19.1.5(@types/react@19.1.4))(@types/react@19.1.4)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)
version: 11.0.0(@types/react@19.1.4)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)
react-i18next:
specifier: 15.7.3
version: 15.7.3(i18next@25.5.2(typescript@5.8.3))(react-dom@19.1.0(react@19.1.0))(react@19.1.0)(typescript@5.8.3)
@@ -898,36 +898,12 @@ importers:
packages/ui:
dependencies:
'@calcom/embed-snippet':
specifier: 1.3.3
version: 1.3.3
'@formkit/auto-animate':
specifier: 0.8.2
version: 0.8.2
i18next:
specifier: 25.5.2
version: 25.5.2(typescript@5.8.3)
i18next-icu:
specifier: 2.4.0
version: 2.4.0(intl-messageformat@10.7.18)
isomorphic-dompurify:
specifier: 2.24.0
version: 2.24.0
react:
specifier: 19.1.0
version: 19.1.0
react-calendar:
specifier: 5.1.0
version: 5.1.0(@types/react@19.1.4)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)
react-date-picker:
specifier: 11.0.0
version: 11.0.0(@types/react-dom@19.1.5(@types/react@19.1.4))(@types/react@19.1.4)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)
react-dom:
specifier: ^19.0.0
version: 19.1.0(react@19.1.0)
react-i18next:
specifier: 15.7.3
version: 15.7.3(i18next@25.5.2(typescript@5.8.3))(react-dom@19.1.0(react@19.1.0))(react@19.1.0)(typescript@5.8.3)
devDependencies:
'@formbricks/config-typescript':
specifier: workspace:*
@@ -16887,7 +16863,7 @@ snapshots:
eslint: 8.57.0
eslint-import-resolver-node: 0.3.9
eslint-import-resolver-typescript: 3.10.1(eslint-plugin-import@2.32.0)(eslint@8.57.0)
eslint-plugin-import: 2.32.0(@typescript-eslint/parser@8.32.1(eslint@8.57.0)(typescript@5.8.3))(eslint-import-resolver-typescript@3.10.1)(eslint@8.57.0)
eslint-plugin-import: 2.32.0(@typescript-eslint/parser@8.32.1(eslint@8.57.0)(typescript@5.8.3))(eslint@8.57.0)
eslint-plugin-jsx-a11y: 6.10.2(eslint@8.57.0)
eslint-plugin-react: 7.37.5(eslint@8.57.0)
eslint-plugin-react-hooks: 5.2.0(eslint@8.57.0)
@@ -16914,7 +16890,7 @@ snapshots:
eslint-import-resolver-alias@1.1.2(eslint-plugin-import@2.32.0):
dependencies:
eslint-plugin-import: 2.32.0(@typescript-eslint/parser@8.32.1(eslint@8.57.0)(typescript@5.8.3))(eslint-import-resolver-typescript@3.10.1)(eslint@8.57.0)
eslint-plugin-import: 2.32.0(@typescript-eslint/parser@8.32.1(eslint@8.57.0)(typescript@5.8.3))(eslint@8.57.0)
eslint-import-resolver-node@0.3.9:
dependencies:
@@ -16935,7 +16911,7 @@ snapshots:
tinyglobby: 0.2.15
unrs-resolver: 1.11.1
optionalDependencies:
eslint-plugin-import: 2.32.0(@typescript-eslint/parser@8.32.1(eslint@8.57.0)(typescript@5.8.3))(eslint-import-resolver-typescript@3.10.1)(eslint@8.57.0)
eslint-plugin-import: 2.32.0(@typescript-eslint/parser@8.32.1(eslint@8.57.0)(typescript@5.8.3))(eslint@8.57.0)
transitivePeerDependencies:
- supports-color
@@ -17009,7 +16985,7 @@ snapshots:
- eslint-import-resolver-webpack
- supports-color
eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.32.1(eslint@8.57.0)(typescript@5.8.3))(eslint-import-resolver-typescript@3.10.1)(eslint@8.57.0):
eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.32.1(eslint@8.57.0)(typescript@5.8.3))(eslint@8.57.0):
dependencies:
'@rtsao/scc': 1.1.0
array-includes: 3.1.9
@@ -19407,7 +19383,7 @@ snapshots:
react: 19.1.0
tween-functions: 1.2.0
react-date-picker@11.0.0(@types/react-dom@19.1.5(@types/react@19.1.4))(@types/react@19.1.4)(react-dom@19.1.0(react@19.1.0))(react@19.1.0):
react-date-picker@11.0.0(@types/react@19.1.4)(react-dom@19.1.0(react@19.1.0))(react@19.1.0):
dependencies:
'@wojtekmaj/date-utils': 1.5.1
clsx: 2.1.1
@@ -19416,7 +19392,7 @@ snapshots:
react: 19.1.0
react-calendar: 5.1.0(@types/react@19.1.4)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)
react-dom: 19.1.0(react@19.1.0)
react-fit: 2.0.1(@types/react-dom@19.1.5(@types/react@19.1.4))(@types/react@19.1.4)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)
react-fit: 2.0.1(@types/react@19.1.4)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)
update-input-width: 1.4.2
optionalDependencies:
'@types/react': 19.1.4
@@ -19459,7 +19435,7 @@ snapshots:
'@babel/runtime': 7.28.4
react: 19.1.0
react-fit@2.0.1(@types/react-dom@19.1.5(@types/react@19.1.4))(@types/react@19.1.4)(react-dom@19.1.0(react@19.1.0))(react@19.1.0):
react-fit@2.0.1(@types/react@19.1.4)(react-dom@19.1.0(react@19.1.0))(react@19.1.0):
dependencies:
detect-element-overflow: 1.4.2
react: 19.1.0
@@ -19467,7 +19443,6 @@ snapshots:
warning: 4.0.3
optionalDependencies:
'@types/react': 19.1.4
'@types/react-dom': 19.1.5(@types/react@19.1.4)
react-hook-form@7.56.2(react@19.1.0):
dependencies: