Scheduling infrastructure for absolutely everyone.
fix: Remove Email embed from Routing Form[Stacked PR] (#10389)
Hariom Balhara89808cb4f6d1
diff --git a/apps/web/components/eventtype/EventTypeSingleLayout.tsx b/apps/web/components/eventtype/EventTypeSingleLayout.tsxindex 1bbd8bf0b4f..da9015e7d4a 100644--- a/apps/web/components/eventtype/EventTypeSingleLayout.tsx+++ b/apps/web/components/eventtype/EventTypeSingleLayout.tsx@@ -8,6 +8,7 @@ import type { UseFormReturn } from "react-hook-form";import useLockedFieldsManager from "@calcom/features/ee/managed-event-types/hooks/useLockedFieldsManager";import { useOrgBranding } from "@calcom/features/ee/organizations/context/provider";+import { EventTypeEmbedButton, EventTypeEmbedDialog } from "@calcom/features/embed/EventTypeEmbed";import Shell from "@calcom/features/shell/Shell";import { classNames } from "@calcom/lib";import { CAL_URL } from "@calcom/lib/constants";@@ -51,7 +52,6 @@ import {Loader,} from "@calcom/ui/components/icon";-import { EmbedButton, EmbedDialog } from "@components/Embed";import type { AvailabilityOption } from "@components/eventtype/EventAvailabilityTab";type Props = {@@ -310,7 +310,7 @@ function EventTypeSingleLayout({showToast("Link copied!", "success");}}/>- <EmbedButton+ <EventTypeEmbedButtonembedUrl={encodeURIComponent(embedLink)}StartIcon={Code}color="secondary"@@ -450,7 +450,7 @@ function EventTypeSingleLayout({</p></ConfirmationDialogContent></Dialog>- <EmbedDialog />+ <EventTypeEmbedDialog /></Shell>);}diff --git a/apps/web/pages/event-types/index.tsx b/apps/web/pages/event-types/index.tsxindex dedc08d7a27..6b6bad74500 100644--- a/apps/web/pages/event-types/index.tsx+++ b/apps/web/pages/event-types/index.tsx@@ -9,6 +9,7 @@ import { z } from "zod";import { useOrgBranding } from "@calcom/features/ee/organizations/context/provider";import useIntercom from "@calcom/features/ee/support/lib/intercom/useIntercom";+import { EventTypeEmbedButton, EventTypeEmbedDialog } from "@calcom/features/embed/EventTypeEmbed";import { EventTypeDescriptionLazy as EventTypeDescription } from "@calcom/features/eventtypes/components";import CreateEventTypeDialog from "@calcom/features/eventtypes/components/CreateEventTypeDialog";import { DuplicateDialog } from "@calcom/features/eventtypes/components/DuplicateDialog";@@ -70,7 +71,6 @@ import {import useMeQuery from "@lib/hooks/useMeQuery";-import { EmbedButton, EmbedDialog } from "@components/Embed";import PageWrapper from "@components/PageWrapper";import SkeletonLoader from "@components/eventtype/SkeletonLoader";@@ -507,7 +507,7 @@ export const EventTypeList = ({ group, groupIndex, readOnly, types }: EventTypeL)}{!isManagedEventType && (<DropdownMenuItem className="outline-none">- <EmbedButton+ <EventTypeEmbedButtonas={DropdownItem}type="button"StartIcon={Code}@@ -515,7 +515,7 @@ export const EventTypeList = ({ group, groupIndex, readOnly, types }: EventTypeLembedUrl={encodeURIComponent(embedLink)}eventId={type.id}>{t("embed")}- </EmbedButton>+ </EventTypeEmbedButton></DropdownMenuItem>)}{/* readonly is only set when we are on a team - if we are on a user event type null will be the value. */}@@ -892,7 +892,7 @@ const Main = ({))}{data.eventTypeGroups.length === 0 && <CreateFirstEventTypeView />}- <EmbedDialog />+ <EventTypeEmbedDialog />{searchParams?.get("dialog") === "duplicate" && <DuplicateDialog />}</>);diff --git a/apps/web/playwright/embed-code-generator.e2e.ts b/apps/web/playwright/embed-code-generator.e2e.tsindex 6988073cf39..f49b853259c 100644--- a/apps/web/playwright/embed-code-generator.e2e.ts+++ b/apps/web/playwright/embed-code-generator.e2e.ts@@ -1,6 +1,8 @@import type { Page } from "@playwright/test";import { expect } from "@playwright/test";+import { EMBED_LIB_URL, WEBAPP_URL } from "@calcom/lib/constants";+import { test } from "./lib/fixtures";function chooseEmbedType(page: Page, embedType: string) {@@ -81,12 +83,16 @@ async function expectToContainValidCode(page: Page, { embedType }: { embedType:};}+/**+ * Let's just check if iframe is opened with preview.html. preview.html tests are responsibility of embed-core+ */async function expectToContainValidPreviewIframe(page: Page,{ embedType, calLink }: { embedType: string; calLink: string }) {+ const bookerUrl = `${WEBAPP_URL}`;expect(await page.locator("[data-testid=embed-preview]").getAttribute("src")).toContain(- `/preview.html?embedType=${embedType}&calLink=${calLink}`+ `/preview.html?embedType=${embedType}&calLink=${calLink}&embedLibUrl=${EMBED_LIB_URL}&bookerUrl=${bookerUrl}`);}diff --git a/packages/app-store/routing-forms/components/FormActions.tsx b/packages/app-store/routing-forms/components/FormActions.tsxindex f12433ed799..17a2932d1c1 100644--- a/packages/app-store/routing-forms/components/FormActions.tsx+++ b/packages/app-store/routing-forms/components/FormActions.tsx@@ -6,6 +6,7 @@ import { v4 as uuidv4 } from "uuid";import { z } from "zod";import { useOrgBranding } from "@calcom/features/ee/organizations/context/provider";+import { RoutingFormEmbedButton, RoutingFormEmbedDialog } from "@calcom/features/embed/RoutingFormEmbed";import { classNames } from "@calcom/lib";import { CAL_URL } from "@calcom/lib/constants";import { useLocale } from "@calcom/lib/hooks/useLocale";@@ -32,8 +33,6 @@ import {} from "@calcom/ui";import { MoreHorizontal } from "@calcom/ui/components/icon";-import { EmbedButton, EmbedDialog } from "@components/Embed";-import getFieldIdentifier from "../lib/getFieldIdentifier";import type { SerializableForm } from "../types/types";@@ -230,7 +229,7 @@ function Dialogs({});return (<div id="form-dialogs">- <EmbedDialog />+ <RoutingFormEmbedDialog /><Dialog open={deleteDialogOpen} onOpenChange={setDeleteDialogOpen}><ConfirmationDialogContentisLoading={deleteMutation.isLoading}@@ -430,7 +429,7 @@ export const FormAction = forwardRef(function FormAction<T extends typeof ButtononClick: () => openModal({ action: "duplicate", target: routingForm?.id }),},embed: {- as: EmbedButton,+ as: RoutingFormEmbedButton,// eslint-disable-next-line @typescript-eslint/ban-ts-comment//@ts-ignoreembedUrl: embedLink,diff --git a/apps/web/components/Embed.tsx b/packages/features/embed/Embed.tsxsimilarity index 53%rename from apps/web/components/Embed.tsxrename to packages/features/embed/Embed.tsxindex f906aed757e..b91106302ee 100644--- a/apps/web/components/Embed.tsx+++ b/packages/features/embed/Embed.tsx@@ -1,10 +1,9 @@import { Collapsible, CollapsibleContent } from "@radix-ui/react-collapsible";import classNames from "classnames";import { useSession } from "next-auth/react";-import type { TFunction } from "next-i18next";import { usePathname, useRouter, useSearchParams } from "next/navigation";-import type { MutableRefObject, RefObject } from "react";-import { createRef, forwardRef, useRef, useState } from "react";+import type { RefObject } from "react";+import { createRef, useRef, useState } from "react";import type { ControlProps } from "react-select";import { components } from "react-select";import { shallow } from "zustand/shallow";@@ -13,16 +12,14 @@ import type { Dayjs } from "@calcom/dayjs";import dayjs from "@calcom/dayjs";import { AvailableTimes } from "@calcom/features/bookings";import { useBookerStore, useInitializeBookerStore } from "@calcom/features/bookings/Booker/store";-import type { BookerLayout } from "@calcom/features/bookings/Booker/types";import { useEvent, useScheduleForEvent } from "@calcom/features/bookings/Booker/utils/event";import { useTimePreferences } from "@calcom/features/bookings/lib/timePreferences";import DatePicker from "@calcom/features/calendars/DatePicker";import { useFlagMap } from "@calcom/features/flags/context/provider";import { useNonEmptyScheduleDays } from "@calcom/features/schedules";import { useSlotsForDate } from "@calcom/features/schedules/lib/use-schedule/useSlotsForDate";-import { APP_NAME, CAL_URL, EMBED_LIB_URL, IS_SELF_HOSTED, WEBAPP_URL } from "@calcom/lib/constants";+import { APP_NAME, CAL_URL } from "@calcom/lib/constants";import { weekdayToWeekIndex } from "@calcom/lib/date-fns";-import { useBookerUrl } from "@calcom/lib/hooks/useBookerUrl";import { useLocale } from "@calcom/lib/hooks/useLocale";import { BookerLayouts } from "@calcom/prisma/zod-utils";import type { RouterOutputs } from "@calcom/trpc/react";@@ -39,15 +36,15 @@ import {Select,showToast,Switch,- TextArea,TextField,TimezoneSelect,} from "@calcom/ui";-import { ArrowDown, ArrowLeft, ArrowUp, Code, Sun, Trello } from "@calcom/ui/components/icon";+import { ArrowDown, ArrowLeft, ArrowUp, Sun } from "@calcom/ui/components/icon";++import { getDimension } from "./lib/getDimension";+import type { EmbedTabs, EmbedType, EmbedTypes, PreviewState } from "./types";type EventType = RouterOutputs["viewer"]["eventTypes"]["get"]["eventType"] | undefined;-type EmbedType = "inline" | "floating-popup" | "element-click" | "email";-type EmbedFramework = "react" | "HTML";const enum Theme {auto = "auto",@@ -55,43 +52,8 @@ const enum Theme {dark = "dark",}-// Preview HTML and embed lib doesn't need org context. They are static per instance-const EMBED_PREVIEW_HTML_URL = `${WEBAPP_URL}/embed/preview.html`;-const embedLibUrl = EMBED_LIB_URL;--const useEmbedCalOrigin = () => {- const bookerUrl = useBookerUrl();- return bookerUrl;-};--type PreviewState = {- inline: {- width: string;- height: string;- };- theme: Theme;- floatingPopup: {- config?: {- layout: BookerLayouts;- };- [key: string]: string | boolean | undefined | Record<string, string>;- };- elementClick: Record<string, string>;- palette: {- brandColor: string;- };- hideEventTypeDetails: boolean;- layout: BookerLayouts;-};const queryParamsForDialog = ["embedType", "embedTabName", "embedUrl", "eventId"];-const getDimension = (dimension: string) => {- if (dimension.match(/^\d+$/)) {- dimension = `${dimension}%`;- }- return dimension;-};-function useRouterHelpers() {const router = useRouter();const searchParams = useSearchParams();@@ -102,6 +64,7 @@ function useRouterHelpers() {Object.keys(newSearchParams).forEach((key) => {newQuery.set(key, newSearchParams[key]);});+router.push(`${pathname}?${newQuery.toString()}`);};@@ -124,867 +87,7 @@ const getQueryParam = (queryParam: string) => {return params.get(queryParam);};-/**- * It allows us to show code with certain reusable blocks indented according to the block variable placement- * So, if you add a variable ${abc} with indentation of 4 spaces, it will automatically indent all newlines in `abc` with the same indent before constructing the final string- * `A${var}C` with var = "B" -> partsWithoutBlock=['A','C'] blocksOrVariables=['B']- */-const code = (partsWithoutBlock: TemplateStringsArray, ...blocksOrVariables: string[]) => {- const constructedCode: string[] = [];- for (let i = 0; i < partsWithoutBlock.length; i++) {- const partWithoutBlock = partsWithoutBlock[i];- // blocksOrVariables length would always be 1 less than partsWithoutBlock- // So, last item should be concatenated as is.- if (i >= blocksOrVariables.length) {- constructedCode.push(partWithoutBlock);- continue;- }- const block = blocksOrVariables[i];- const indentedBlock: string[] = [];- let indent = "";- block.split("\n").forEach((line) => {- indentedBlock.push(line);- });- // non-null assertion is okay because we know that we are referencing last element.- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion- const indentationMatch = partWithoutBlock- .split("\n")- .at(-1)!- .match(/(^[\t ]*).*$/);- if (indentationMatch) {- indent = indentationMatch[1];- }- constructedCode.push(partWithoutBlock + indentedBlock.join("\n" + indent));- }- return constructedCode.join("");-};--const getInstructionString = ({- apiName,- instructionName,- instructionArg,-}: {- apiName: string;- instructionName: string;- instructionArg: Record<string, unknown>;-}) => {- return `${apiName}("${instructionName}", ${JSON.stringify(instructionArg)});`;-};--const getEmbedUIInstructionString = ({- apiName,- theme,- brandColor,- hideEventTypeDetails,- layout,-}: {- apiName: string;- theme?: string;- brandColor: string;- hideEventTypeDetails: boolean;- layout?: string;-}) => {- theme = theme !== "auto" ? theme : undefined;- return getInstructionString({- apiName,- instructionName: "ui",- instructionArg: {- theme,- styles: {- branding: {- brandColor,- },- },- hideEventTypeDetails: hideEventTypeDetails,- layout,- },- });-};--// eslint-disable-next-line @typescript-eslint/no-explicit-any-const Codes = {- react: {- inline: ({- calLink,- uiInstructionCode,- previewState,- embedCalOrigin,- }: {- calLink: string;- uiInstructionCode: string;- previewState: PreviewState;- embedCalOrigin: string;- }) => {- const width = getDimension(previewState.inline.width);- const height = getDimension(previewState.inline.height);- return code`-import Cal, { getCalApi } from "@calcom/embed-react";-import { useEffect } from "react";-export default function MyApp() {- useEffect(()=>{- (async function () {- const cal = await getCalApi();- ${uiInstructionCode}- })();- }, [])- return <Cal- calLink="${calLink}"- style={{width:"${width}",height:"${height}",overflow:"scroll"}}- ${previewState.layout ? "config={{layout: '" + previewState.layout + "'}}" : ""}${- IS_SELF_HOSTED- ? `- calOrigin="${embedCalOrigin}"- calJsUrl="${embedLibUrl}"`- : ""- }- />;-};`;- },- "floating-popup": ({- floatingButtonArg,- uiInstructionCode,- }: {- floatingButtonArg: string;- uiInstructionCode: string;- }) => {- return code`-import { getCalApi } from "@calcom/embed-react";-import { useEffect } from "react";-export default function App() {- useEffect(()=>{- (async function () {- const cal = await getCalApi(${IS_SELF_HOSTED ? `"${embedLibUrl}"` : ""});- cal("floatingButton", ${floatingButtonArg});- ${uiInstructionCode}- })();- }, [])-};`;- },- "element-click": ({- calLink,- uiInstructionCode,- previewState,- embedCalOrigin,- }: {- calLink: string;- uiInstructionCode: string;- previewState: PreviewState;- embedCalOrigin: string;- }) => {- return code`-import { getCalApi } from "@calcom/embed-react";-import { useEffect } from "react";-export default function App() {- useEffect(()=>{- (async function () {- const cal = await getCalApi(${IS_SELF_HOSTED ? `"${embedLibUrl}"` : ""});- ${uiInstructionCode}- })();- }, [])- return <button- data-cal-link="${calLink}"${IS_SELF_HOSTED ? `\ndata-cal-origin="${embedCalOrigin}"` : ""}- ${`data-cal-config='${JSON.stringify({- layout: previewState.layout,- })}'`}- >Click me</button>;-};`;- },- },- HTML: {- inline: ({- calLink,- uiInstructionCode,- previewState,- }: {- calLink: string;- uiInstructionCode: string;- previewState: PreviewState;- }) => {- return code`Cal("inline", {- elementOrSelector:"#my-cal-inline",- calLink: "${calLink}",- layout: "${previewState.layout}"-});--${uiInstructionCode}`;- },-- "floating-popup": ({- floatingButtonArg,- uiInstructionCode,- }: {- floatingButtonArg: string;- uiInstructionCode: string;- }) => {- return code`Cal("floatingButton", ${floatingButtonArg});-${uiInstructionCode}`;- },- "element-click": ({- calLink,- uiInstructionCode,- previewState,- }: {- calLink: string;- uiInstructionCode: string;- previewState: PreviewState;- }) => {- return code`-// Important: Please add following attributes to the element you want to open Cal on click-// \`data-cal-link="${calLink}"\`-// \`data-cal-config='${JSON.stringify({- layout: previewState.layout,- })}'\`--${uiInstructionCode}`;- },- },-} satisfies Record<string, Record<string, (...args: any[]) => string>>;--type EmbedCommonProps = { embedType: EmbedType; calLink: string; previewState: PreviewState };--const getEmbedTypeSpecificString = ({- embedFramework,- embedType,- calLink,- previewState,- embedCalOrigin,-}: {- embedFramework: EmbedFramework;- embedCalOrigin: string;-} & EmbedCommonProps) => {- const frameworkCodes = Codes[embedFramework];- if (!frameworkCodes) {- throw new Error(`No code available for the framework:${embedFramework}`);- }- if (embedType === "email") return "";- let uiInstructionStringArg: {- apiName: string;- theme: PreviewState["theme"];- brandColor: string;- hideEventTypeDetails: boolean;- layout?: BookerLayout;- };- if (embedFramework === "react") {- uiInstructionStringArg = {- apiName: "cal",- theme: previewState.theme,- brandColor: previewState.palette.brandColor,- hideEventTypeDetails: previewState.hideEventTypeDetails,- layout: previewState.layout,- };- } else {- uiInstructionStringArg = {- apiName: "Cal",- theme: previewState.theme,- brandColor: previewState.palette.brandColor,- hideEventTypeDetails: previewState.hideEventTypeDetails,- layout: previewState.layout,- };- }- if (!frameworkCodes[embedType]) {- throw new Error(`Code not available for framework:${embedFramework} and embedType:${embedType}`);- }- if (embedType === "inline") {- return frameworkCodes[embedType]({- calLink,- uiInstructionCode: getEmbedUIInstructionString(uiInstructionStringArg),- previewState,- embedCalOrigin,- });- } else if (embedType === "floating-popup") {- const floatingButtonArg = {- calLink,- ...(IS_SELF_HOSTED ? { calOrigin: embedCalOrigin } : null),- ...previewState.floatingPopup,- };- return frameworkCodes[embedType]({- floatingButtonArg: JSON.stringify(floatingButtonArg),- uiInstructionCode: getEmbedUIInstructionString(uiInstructionStringArg),- });- } else if (embedType === "element-click") {- return frameworkCodes[embedType]({- calLink,- uiInstructionCode: getEmbedUIInstructionString(uiInstructionStringArg),- previewState,- embedCalOrigin,- });- }- return "";-};--const embeds = (t: TFunction) =>- (() => {- return [- {- title: t("inline_embed"),- subtitle: t("load_inline_content"),- type: "inline",- illustration: (- <svg- width="100%"- height="100%"- className="rounded-md"- viewBox="0 0 308 265"- fill="none"- xmlns="http://www.w3.org/2000/svg">- <path- d="M0 1.99999C0 0.895423 0.895431 0 2 0H306C307.105 0 308 0.895431 308 2V263C308 264.105 307.105 265 306 265H2C0.895431 265 0 264.105 0 263V1.99999Z"- fill="white"- />- <rect x="24" width="260" height="38.5" rx="6" fill="#F3F4F6" />- <rect x="24.5" y="51" width="139" height="163" rx="1.5" fill="#F8F8F8" />- <rect opacity="0.8" x="48" y="74.5" width="80" height="8" rx="6" fill="#F3F4F6" />- <rect x="48" y="86.5" width="48" height="4" rx="6" fill="#F3F4F6" />- <rect x="49" y="99.5" width="6" height="6" rx="1" fill="#C6C6C6" />- <rect x="61" y="99.5" width="6" height="6" rx="1" fill="#3E3E3E" />- <rect x="73" y="99.5" width="6" height="6" rx="1" fill="#C6C6C6" />- <rect x="85" y="99.5" width="6" height="6" rx="1" fill="#C6C6C6" />- <rect x="97" y="99.5" width="6" height="6" rx="1" fill="#C6C6C6" />- <rect x="109" y="99.5" width="6" height="6" rx="1" fill="#C6C6C6" />- <rect x="121" y="99.5" width="6" height="6" rx="1" fill="#C6C6C6" />- <rect x="133" y="99.5" width="6" height="6" rx="1" fill="#C6C6C6" />- <rect x="85" y="113.5" width="6" height="6" rx="1" fill="#C6C6C6" />- <rect x="97" y="113.5" width="6" height="6" rx="1" fill="#C6C6C6" />- <rect x="109" y="113.5" width="6" height="6" rx="1" fill="#C6C6C6" />- <rect x="121" y="113.5" width="6" height="6" rx="1" fill="#C6C6C6" />- <rect x="133" y="113.5" width="6" height="6" rx="1" fill="#C6C6C6" />- <rect x="49" y="125.5" width="6" height="6" rx="1" fill="#C6C6C6" />- <rect x="61" y="125.5" width="6" height="6" rx="1" fill="#3E3E3E" />- <path- d="M61 124.5H67V122.5H61V124.5ZM68 125.5V131.5H70V125.5H68ZM67 132.5H61V134.5H67V132.5ZM60 131.5V125.5H58V131.5H60ZM61 132.5C60.4477 132.5 60 132.052 60 131.5H58C58 133.157 59.3431 134.5 61 134.5V132.5ZM68 131.5C68 132.052 67.5523 132.5 67 132.5V134.5C68.6569 134.5 70 133.157 70 131.5H68ZM67 124.5C67.5523 124.5 68 124.948 68 125.5H70C70 123.843 68.6569 122.5 67 122.5V124.5ZM61 122.5C59.3431 122.5 58 123.843 58 125.5H60C60 124.948 60.4477 124.5 61 124.5V122.5Z"- fill="#3E3E3E"- />- <rect x="73" y="125.5" width="6" height="6" rx="1" fill="#C6C6C6" />- <rect x="85" y="125.5" width="6" height="6" rx="1" fill="#C6C6C6" />- <rect x="97" y="125.5" width="6" height="6" rx="1" fill="#C6C6C6" />- <rect x="109" y="125.5" width="6" height="6" rx="1" fill="#C6C6C6" />- <rect x="121" y="125.5" width="6" height="6" rx="1" fill="#C6C6C6" />- <rect x="133" y="125.5" width="6" height="6" rx="1" fill="#C6C6C6" />- <rect x="49" y="137.5" width="6" height="6" rx="1" fill="#C6C6C6" />- <rect x="61" y="137.5" width="6" height="6" rx="1" fill="#C6C6C6" />- <rect x="73" y="137.5" width="6" height="6" rx="1" fill="#C6C6C6" />- <rect x="85" y="137.5" width="6" height="6" rx="1" fill="#C6C6C6" />- <rect x="97" y="137.5" width="6" height="6" rx="1" fill="#3E3E3E" />- <rect x="109" y="137.5" width="6" height="6" rx="1" fill="#3E3E3E" />- <rect x="121" y="137.5" width="6" height="6" rx="1" fill="#C6C6C6" />- <rect x="133" y="137.5" width="6" height="6" rx="1" fill="#C6C6C6" />- <rect x="49" y="149.5" width="6" height="6" rx="1" fill="#C6C6C6" />- <rect x="61" y="149.5" width="6" height="6" rx="1" fill="#C6C6C6" />- <rect x="73" y="149.5" width="6" height="6" rx="1" fill="#C6C6C6" />- <rect x="85" y="149.5" width="6" height="6" rx="1" fill="#C6C6C6" />- <rect x="97" y="149.5" width="6" height="6" rx="1" fill="#3E3E3E" />- <rect x="109" y="149.5" width="6" height="6" rx="1" fill="#3E3E3E" />- <rect x="121" y="149.5" width="6" height="6" rx="1" fill="#C6C6C6" />- <rect x="133" y="149.5" width="6" height="6" rx="1" fill="#C6C6C6" />- <rect x="49" y="161.5" width="6" height="6" rx="1" fill="#C6C6C6" />- <rect x="61" y="161.5" width="6" height="6" rx="1" fill="#C6C6C6" />- <rect x="73" y="161.5" width="6" height="6" rx="1" fill="#C6C6C6" />- <rect x="85" y="161.5" width="6" height="6" rx="1" fill="#C6C6C6" />- <rect x="97" y="161.5" width="6" height="6" rx="1" fill="#3E3E3E" />- <rect x="109" y="161.5" width="6" height="6" rx="1" fill="#C6C6C6" />- <rect x="24.5" y="51" width="139" height="163" rx="6" stroke="#292929" />- <rect x="176" y="50.5" width="108" height="164" rx="6" fill="#F3F4F6" />- <rect x="24" y="226.5" width="260" height="38.5" rx="6" fill="#F3F4F6" />- </svg>- ),- },- {- title: t("floating_pop_up_button"),- subtitle: t("floating_button_trigger_modal"),- type: "floating-popup",- illustration: (- <svg- width="100%"- height="100%"- className="rounded-md"- viewBox="0 0 308 265"- fill="none"- xmlns="http://www.w3.org/2000/svg">- <path- d="M0 1.99999C0 0.895423 0.895431 0 2 0H306C307.105 0 308 0.895431 308 2V263C308 264.105 307.105 265 306 265H2C0.895431 265 0 264.105 0 263V1.99999Z"- fill="white"- />- <rect x="24" width="260" height="38.5" rx="6" fill="#F3F4F6" />- <rect x="24" y="50.5" width="120" height="76" rx="6" fill="#F3F4F6" />- <rect x="24" y="138.5" width="120" height="76" rx="6" fill="#F3F4F6" />- <rect x="156" y="50.5" width="128" height="164" rx="6" fill="#F3F4F6" />- <rect x="24" y="226.5" width="260" height="38.5" rx="6" fill="#F3F4F6" />- <rect x="226" y="223.5" width="66" height="26" rx="6" fill="#292929" />- <rect x="242" y="235.5" width="34" height="2" rx="1" fill="white" />- </svg>- ),- },- {- title: t("pop_up_element_click"),- subtitle: t("open_dialog_with_element_click"),- type: "element-click",- illustration: (- <svg- width="100%"- height="100%"- className="rounded-md"- viewBox="0 0 308 265"- fill="none"- xmlns="http://www.w3.org/2000/svg">- <path- d="M0 1.99999C0 0.895423 0.895431 0 2 0H306C307.105 0 308 0.895431 308 2V263C308 264.105 307.105 265 306 265H2C0.895431 265 0 264.105 0 263V1.99999Z"- fill="white"- />- <rect x="24" y="0.50293" width="260" height="24" rx="6" fill="#F3F4F6" />- <rect x="24" y="35" width="259" height="192" rx="5.5" fill="#F9FAFB" />- <g filter="url(#filter0_i_3223_14162)">- <rect opacity="0.8" x="40" y="99" width="24" height="24" rx="2" fill="#E5E7EB" />- <rect x="40" y="127" width="48" height="8" rx="1" fill="#E5E7EB" />- <rect x="40" y="139" width="82" height="8" rx="1" fill="#E5E7EB" />- <rect x="40" y="151" width="34" height="4" rx="1" fill="#E5E7EB" />- <rect x="40" y="159" width="34" height="4" rx="1" fill="#E5E7EB" />- </g>- <rect x="152" y="48" width="2" height="169" rx="2" fill="#E5E7EB" />-- <rect opacity="0.8" x="176" y="84" width="80" height="8" rx="2" fill="#E5E7EB" />- <rect x="176" y="96" width="48" height="4" rx="1" fill="#E5E7EB" />- <rect x="177" y="109" width="6" height="6" rx="1" fill="#E5E7EB" />- <rect x="189" y="109" width="6" height="6" rx="1" fill="#0D121D" />- <rect x="201" y="109" width="6" height="6" rx="1" fill="#E5E7EB" />- <rect x="213" y="109" width="6" height="6" rx="1" fill="#E5E7EB" />- <rect x="225" y="109" width="6" height="6" rx="1" fill="#E5E7EB" />- <rect x="237" y="109" width="6" height="6" rx="1" fill="#E5E7EB" />- <rect x="249" y="109" width="6" height="6" rx="1" fill="#E5E7EB" />- <rect x="261" y="109" width="6" height="6" rx="1" fill="#E5E7EB" />- <rect x="213" y="123" width="6" height="6" rx="1" fill="#E5E7EB" />- <rect x="225" y="123" width="6" height="6" rx="1" fill="#E5E7EB" />- <rect x="237" y="123" width="6" height="6" rx="1" fill="#E5E7EB" />- <rect x="249" y="123" width="6" height="6" rx="1" fill="#E5E7EB" />- <rect x="261" y="123" width="6" height="6" rx="1" fill="#E5E7EB" />- <rect x="177" y="135" width="6" height="6" rx="1" fill="#E5E7EB" />- <rect x="189" y="135" width="6" height="6" rx="1" fill="#0D121D" />- <rect x="187.3" y="133.4" width="9" height="9" rx="1.5" stroke="#0D121D" />- <rect x="201" y="135" width="6" height="6" rx="1" fill="#E5E7EB" />- <rect x="213" y="135" width="6" height="6" rx="1" fill="#E5E7EB" />- <rect x="225" y="135" width="6" height="6" rx="1" fill="#E5E7EB" />- <rect x="237" y="135" width="6" height="6" rx="1" fill="#E5E7EB" />- <rect x="249" y="135" width="6" height="6" rx="1" fill="#E5E7EB" />- <rect x="261" y="135" width="6" height="6" rx="1" fill="#E5E7EB" />- <rect x="177" y="147" width="6" height="6" rx="1" fill="#E5E7EB" />- <rect x="189" y="147" width="6" height="6" rx="1" fill="#E5E7EB" />- <rect x="201" y="147" width="6" height="6" rx="1" fill="#E5E7EB" />- <rect x="213" y="147" width="6" height="6" rx="1" fill="#E5E7EB" />- <rect x="225" y="147" width="6" height="6" rx="1" fill="#0D121D" />- <rect x="237" y="147" width="6" height="6" rx="1" fill="#0D121D" />- <rect x="249" y="147" width="6" height="6" rx="1" fill="#E5E7EB" />- <rect x="261" y="147" width="6" height="6" rx="1" fill="#E5E7EB" />- <rect x="177" y="159" width="6" height="6" rx="1" fill="#E5E7EB" />- <rect x="189" y="159" width="6" height="6" rx="1" fill="#E5E7EB" />- <rect x="201" y="159" width="6" height="6" rx="1" fill="#E5E7EB" />- <rect x="213" y="159" width="6" height="6" rx="1" fill="#E5E7EB" />- <rect x="225" y="159" width="6" height="6" rx="1" fill="#0D121D" />- <rect x="237" y="159" width="6" height="6" rx="1" fill="#0D121D" />- <rect x="249" y="159" width="6" height="6" rx="1" fill="#E5E7EB" />- <rect x="261" y="159" width="6" height="6" rx="1" fill="#E5E7EB" />- <rect x="177" y="171" width="6" height="6" rx="1" fill="#E5E7EB" />- <rect x="189" y="171" width="6" height="6" rx="1" fill="#E5E7EB" />- <rect x="201" y="171" width="6" height="6" rx="1" fill="#E5E7EB" />- <rect x="213" y="171" width="6" height="6" rx="1" fill="#E5E7EB" />- <rect x="225" y="171" width="6" height="6" rx="1" fill="#0D121D" />- <rect x="237" y="171" width="6" height="6" rx="1" fill="#E5E7EB" />- <rect x="24" y="35" width="259" height="192" rx="5.5" stroke="#101010" />- <rect x="24" y="241.503" width="260" height="24" rx="6" fill="#F3F4F6" />- </svg>- ),- },- {- title: t("email_embed"),- subtitle: t("add_times_to_your_email"),- type: "email",- illustration: (- <svg- width="100%"- height="100%"- className="rounded-md"- viewBox="0 0 308 265"- fill="none"- xmlns="http://www.w3.org/2000/svg">- <g clip-path="url(#clip0_457_1339)">- <rect width="308" height="265" rx="8" fill="white" />- <rect width="308" height="18" rx="4" fill="#F3F4F6" />- <rect y="19" width="308" height="18" rx="4" fill="#F3F4F6" />- <rect y="38" width="308" height="18" rx="4" fill="#F3F4F6" />- <rect y="57" width="308" height="18" rx="4" fill="#F3F4F6" />- <rect y="76" width="308" height="18" rx="4" fill="#F3F4F6" />- <rect y="95" width="308" height="18" rx="4" fill="#F3F4F6" />- <rect y="114" width="308" height="18" rx="4" fill="#F3F4F6" />- <rect y="133" width="308" height="18" rx="4" fill="#F3F4F6" />- <rect y="152" width="308" height="18" rx="4" fill="#F3F4F6" />- <rect y="171" width="308" height="18" rx="4" fill="#F3F4F6" />- <rect y="190" width="308" height="18" rx="4" fill="#F3F4F6" />- <rect y="209" width="308" height="18" rx="4" fill="#F3F4F6" />- <rect y="228" width="308" height="18" rx="4" fill="#F3F4F6" />- <rect y="247" width="308" height="18" rx="4" fill="#F3F4F6" />- <g clip-path="url(#clip1_457_1339)">- <rect x="107" y="64" width="189" height="189" rx="6" fill="white" />- <g clip-path="url(#clip2_457_1339)">- <path- d="M124.671 75.5243C124.671 75.1018 124.325 74.756 123.902 74.756H117.756C117.334 74.756 116.988 75.1018 116.988 75.5243M124.671 75.5243V80.1341C124.671 80.5567 124.325 80.9024 123.902 80.9024H117.756C117.334 80.9024 116.988 80.5567 116.988 80.1341V75.5243M124.671 75.5243L120.829 78.2134L116.988 75.5243"- stroke="#9CA3AF"- stroke-width="1.15244"- stroke-linecap="round"- stroke-linejoin="round"- />- </g>- <rect x="130.049" y="75.5244" width="92.1951" height="4.60976" rx="2.30488" fill="#D1D5DB" />- <rect x="130.049" y="84.7439" width="55.3171" height="4.60976" rx="2.30488" fill="#E5E7EB" />- <rect- opacity="0.8"- x="107"- y="98.5732"- width="189"- height="1.15244"- rx="0.576219"- fill="#E5E7EB"- />- <rect x="116.219" y="113.555" width="92.1951" height="4.60976" rx="2.30488" fill="#D1D5DB" />- <rect x="116.219" y="122.774" width="42.6402" height="4.60976" rx="2.30488" fill="#E5E7EB" />- <rect x="116.219" y="136.604" width="55.3171" height="4.60976" rx="2.30488" fill="#D1D5DB" />- <rect- x="116.719"- y="145.171"- width="22.0488"- height="5.91463"- rx="2.95732"- stroke="#9CA3AF"- />- <rect- x="142.073"- y="145.171"- width="22.0488"- height="5.91463"- rx="2.95732"- stroke="#9CA3AF"- />- <rect- x="167.427"- y="145.171"- width="22.0488"- height="5.91463"- rx="2.95732"- stroke="#9CA3AF"- />- <rect- x="192.781"- y="145.171"- width="22.0488"- height="5.91463"- rx="2.95732"- stroke="#9CA3AF"- />- <rect- x="218.134"- y="145.171"- width="22.0488"- height="5.91463"- rx="2.95732"- stroke="#9CA3AF"- />- <rect x="116.219" y="160.805" width="55.3171" height="4.60976" rx="2.30488" fill="#D1D5DB" />- <rect- x="116.719"- y="169.372"- width="22.0488"- height="5.91463"- rx="2.95732"- stroke="#9CA3AF"- />- <rect- x="142.073"- y="169.372"- width="22.0488"- height="5.91463"- rx="2.95732"- stroke="#9CA3AF"- />- <rect- x="167.427"- y="169.372"- width="22.0488"- height="5.91463"- rx="2.95732"- stroke="#9CA3AF"- />- <rect- x="192.781"- y="169.372"- width="22.0488"- height="5.91463"- rx="2.95732"- stroke="#9CA3AF"- />- <rect- x="218.134"- y="169.372"- width="22.0488"- height="5.91463"- rx="2.95732"- stroke="#9CA3AF"- />- <rect x="116.219" y="185.006" width="55.3171" height="4.60976" rx="2.30488" fill="#D1D5DB" />- <rect- x="116.719"- y="193.573"- width="22.0488"- height="5.91463"- rx="2.95732"- stroke="#9CA3AF"- />- <rect- x="142.073"- y="193.573"- width="22.0488"- height="5.91463"- rx="2.95732"- stroke="#9CA3AF"- />- <rect- x="167.427"- y="193.573"- width="22.0488"- height="5.91463"- rx="2.95732"- stroke="#9CA3AF"- />- <rect- x="192.781"- y="193.573"- width="22.0488"- height="5.91463"- rx="2.95732"- stroke="#9CA3AF"- />- <rect- x="218.134"- y="193.573"- width="22.0488"- height="5.91463"- rx="2.95732"- stroke="#9CA3AF"- />- <rect- opacity="0.8"- x="107"- y="223.037"- width="189"- height="1.15244"- rx="0.576219"- fill="#E5E7EB"- />- <rect width="189" height="28.811" transform="translate(107 224.189)" fill="#F9FAFB" />- <rect x="116.219" y="233.985" width="23.0488" height="9.21951" rx="2.30488" fill="#9CA3AF" />- <rect- opacity="0.8"- x="141.573"- y="233.985"- width="9.21951"- height="9.21951"- rx="2.30488"- fill="#E5E7EB"- />- <rect- opacity="0.8"- x="153.098"- y="233.985"- width="9.21951"- height="9.21951"- rx="2.30488"- fill="#E5E7EB"- />- <rect- opacity="0.8"- x="164.622"- y="233.985"- width="9.21951"- height="9.21951"- rx="2.30488"- fill="#E5E7EB"- />- </g>- <rect- x="106.424"- y="63.4238"- width="190.152"- height="190.152"- rx="6.57622"- stroke="#101010"- stroke-width="1.15244"- />- </g>- <rect x="0.5" y="0.5" width="307" height="264" rx="7.5" stroke="#E5E7EB" />- <defs>- <clipPath id="clip0_457_1339">- <rect width="308" height="265" rx="8" fill="white" />- </clipPath>- <clipPath id="clip1_457_1339">- <rect x="107" y="64" width="189" height="189" rx="6" fill="white" />- </clipPath>- <clipPath id="clip2_457_1339">- <rect width="9.21951" height="9.21951" fill="white" transform="translate(116.219 73.2195)" />- </clipPath>- </defs>- </svg>- ),- },- ];- })();--const tabs = [- {- name: "HTML",- href: "embedTabName=embed-code",- icon: Code,- type: "code",- Component: forwardRef<HTMLTextAreaElement | HTMLIFrameElement | null, EmbedCommonProps>(- function EmbedHtml({ embedType, calLink, previewState }, ref) {- const { t } = useLocale();- const embedSnippetString = useGetEmbedSnippetString();- const embedCalOrigin = useEmbedCalOrigin();- if (ref instanceof Function || !ref) {- return null;- }- if (ref.current && !(ref.current instanceof HTMLTextAreaElement)) {- return null;- }- return (- <>- <div>- <small className="text-subtle flex py-4">- {t("place_where_cal_widget_appear", { appName: APP_NAME })}- </small>- </div>- <TextArea- data-testid="embed-code"- ref={ref as typeof ref & MutableRefObject<HTMLTextAreaElement>}- name="embed-code"- className="text-default bg-default selection:bg-subtle h-[calc(100%-50px)] font-mono"- style={{ resize: "none", overflow: "auto" }}- readOnly- value={- `<!-- Cal ${embedType} embed code begins -->\n` +- (embedType === "inline"- ? `<div style="width:${getDimension(previewState.inline.width)};height:${getDimension(- previewState.inline.height- )};overflow:scroll" id="my-cal-inline"></div>\n`- : "") +- `<script type="text/javascript">-${embedSnippetString}-${getEmbedTypeSpecificString({- embedFramework: "HTML",- embedType,- calLink,- previewState,- embedCalOrigin,-})}-</script>-<!-- Cal ${embedType} embed code ends -->`- }- />- <p className="text-subtle hidden text-sm">{t("need_help_embedding")}</p>- </>- );- }- ),- },- {- name: "React",- href: "embedTabName=embed-react",- icon: Code,- type: "code",- Component: forwardRef<HTMLTextAreaElement | HTMLIFrameElement | null, EmbedCommonProps>(- function EmbedReact({ embedType, calLink, previewState }, ref) {- const embedCalOrigin = useEmbedCalOrigin();- const { t } = useLocale();- if (ref instanceof Function || !ref) {- return null;- }- if (ref.current && !(ref.current instanceof HTMLTextAreaElement)) {- return null;- }- return (- <>- <small className="text-subtle flex py-4">{t("create_update_react_component")}</small>- <TextArea- data-testid="embed-react"- ref={ref as typeof ref & MutableRefObject<HTMLTextAreaElement>}- name="embed-react"- className="text-default bg-default selection:bg-subtle h-[calc(100%-50px)] font-mono"- readOnly- style={{ resize: "none", overflow: "auto" }}- value={`/* First make sure that you have installed the package */--/* If you are using yarn */-// yarn add @calcom/embed-react--/* If you are using npm */-// npm install @calcom/embed-react-${getEmbedTypeSpecificString({- embedFramework: "react",- embedType,- calLink,- previewState,- embedCalOrigin,-})}-`}- />- </>- );- }- ),- },- {- name: "Preview",- href: "embedTabName=embed-preview",- icon: Trello,- type: "iframe",- Component: forwardRef<HTMLIFrameElement | HTMLTextAreaElement | null, EmbedCommonProps>(function Preview(- { calLink, embedType },- ref- ) {- const bookerUrl = useBookerUrl();- if (ref instanceof Function || !ref) {- return null;- }- if (ref.current && !(ref.current instanceof HTMLIFrameElement)) {- return null;- }- return (- <iframe- ref={ref as typeof ref & MutableRefObject<HTMLIFrameElement>}- data-testid="embed-preview"- className="h-[100vh] border"- width="100%"- height="100%"- src={`${EMBED_PREVIEW_HTML_URL}?embedType=${embedType}&calLink=${calLink}&embedLibUrl=${embedLibUrl}&bookerUrl=${bookerUrl}`}- />- );- }),- },-];--function useGetEmbedSnippetString() {- const bookerUrl = useBookerUrl();- // TODO: Import this string from @calcom/embed-snippet- return `(function (C, A, L) { let p = function (a, ar) { a.q.push(ar); }; let d = C.document; C.Cal = C.Cal || function () { let cal = C.Cal; let ar = arguments; if (!cal.loaded) { cal.ns = {}; cal.q = cal.q || []; d.head.appendChild(d.createElement("script")).src = A; cal.loaded = true; } if (ar[0] === L) { const api = function () { p(api, arguments); }; const namespace = ar[1]; api.q = api.q || []; typeof namespace === "string" ? (cal.ns[namespace] = api) && p(api, ar) : p(cal, ar); return; } p(cal, ar); }; })(window, "${embedLibUrl}", "init");-Cal("init", {origin:"${bookerUrl}"});-`;-}--const ThemeSelectControl = ({- children,- ...props-}: ControlProps<- {- value: Theme;- label: string;- },- false->) => {+const ThemeSelectControl = ({ children, ...props }: ControlProps<{ value: Theme; label: string }, false>) => {return (<components.Control {...props}><Sun className="text-subtle mr-2 h-4 w-4" />@@ -993,7 +96,7 @@ const ThemeSelectControl = ({);};-const ChooseEmbedTypesDialogContent = () => {+const ChooseEmbedTypesDialogContent = ({ types }: { types: EmbedTypes }) => {const { t } = useLocale();const { goto } = useRouterHelpers();return (@@ -1007,7 +110,7 @@ const ChooseEmbedTypesDialogContent = () => {</div></div><div className="items-start space-y-2 md:flex md:space-y-0">- {embeds(t).map((embed, index) => (+ {types.map((embed, index) => (<buttonclassName="hover:bg-subtle bg-muted w-full self-stretch rounded-md border border-transparent p-6 text-left hover:rounded-md ltr:mr-4 ltr:last:mr-0 rtl:ml-4 rtl:last:ml-0 lg:w-1/3"key={index}@@ -1041,7 +144,6 @@ const EmailEmbed = ({ eventType, username }: { eventType?: EventType; username:eventSlug: eventType?.slug ?? "",eventId: eventType?.id,layout: BookerLayouts.MONTH_VIEW,- durationConfig: eventType?.metadata?.multipleDuration,});const [month, selectedDate, selectedDatesAndTimes] = useBookerStore(@@ -1412,13 +514,19 @@ const EmailEmbedPreview = ({const EmbedTypeCodeAndPreviewDialogContent = ({embedType,embedUrl,+ tabs,+ eventTypeHideOptionDisabled,+ types,}: {embedType: EmbedType;embedUrl: string;+ tabs: EmbedTabs;+ eventTypeHideOptionDisabled: boolean;+ types: EmbedTypes;}) => {+ const { t } = useLocale();const searchParams = useSearchParams();const pathname = usePathname();- const { t } = useLocale();const { goto, removeQueryParams } = useRouterHelpers();const iframeRef = useRef<HTMLIFrameElement>(null);const dialogContentRef = useRef<HTMLDivElement>(null);@@ -1452,7 +560,7 @@ const EmbedTypeCodeAndPreviewDialogContent = ({});const refOfEmbedCodesRefs = useRef(embedCodeRefs);- const embed = embeds(t).find((embed) => embed.type === embedType);+ const embed = types.find((embed) => embed.type === embedType);const [isEmbedCustomizationOpen, setIsEmbedCustomizationOpen] = useState(true);const [isBookingCustomizationOpen, setIsBookingCustomizationOpen] = useState(true);@@ -1823,20 +931,22 @@ const EmbedTypeCodeAndPreviewDialogContent = ({options={ThemeOptions}/></Label>- <div className="mb-6 flex items-center justify-start space-x-2 rtl:space-x-reverse">- <Switch- checked={previewState.hideEventTypeDetails}- onCheckedChange={(checked) => {- setPreviewState((previewState) => {- return {- ...previewState,- hideEventTypeDetails: checked,- };- });- }}- />- <div className="text-default text-sm">{t("hide_eventtype_details")}</div>- </div>+ {!eventTypeHideOptionDisabled ? (+ <div className="mb-6 flex items-center justify-start space-x-2 rtl:space-x-reverse">+ <Switch+ checked={previewState.hideEventTypeDetails}+ onCheckedChange={(checked) => {+ setPreviewState((previewState) => {+ return {+ ...previewState,+ hideEventTypeDetails: checked,+ };+ });+ }}+ />+ <div className="text-default text-sm">{t("hide_eventtype_details")}</div>+ </div>+ ) : null}{[{ name: "brandColor", title: "Brand Color" },// { name: "lightColor", title: "Light Color" },@@ -1993,22 +1103,34 @@ const EmbedTypeCodeAndPreviewDialogContent = ({);};-export const EmbedDialog = () => {+export const EmbedDialog = ({+ types,+ tabs,+ eventTypeHideOptionDisabled,+}: {+ types: EmbedTypes;+ tabs: EmbedTabs;+ eventTypeHideOptionDisabled: boolean;+}) => {const searchParams = useSearchParams();const embedUrl = searchParams?.get("embedUrl") as string;return (<Dialog name="embed" clearQueryParamsOnClose={queryParamsForDialog}>{!searchParams?.get("embedType") ? (- <ChooseEmbedTypesDialogContent />+ <ChooseEmbedTypesDialogContent types={types} />) : (<EmbedTypeCodeAndPreviewDialogContentembedType={searchParams?.get("embedType") as EmbedType}embedUrl={embedUrl}+ tabs={tabs}+ types={types}+ eventTypeHideOptionDisabled={eventTypeHideOptionDisabled}/>)}</Dialog>);};+type EmbedButtonProps<T> = {embedUrl: string;children?: React.ReactNode;diff --git a/packages/features/embed/EventTypeEmbed.tsx b/packages/features/embed/EventTypeEmbed.tsxnew file mode 100644index 00000000000..5cb78e78f04--- /dev/null+++ b/packages/features/embed/EventTypeEmbed.tsx@@ -0,0 +1,15 @@+import type { ComponentProps } from "react";++import { EmbedButton, EmbedDialog } from "./Embed";+import { tabs } from "./lib/EmbedTabs";+import { useEmbedTypes } from "./lib/hooks";++export const EventTypeEmbedDialog = () => {+ const types = useEmbedTypes();++ return <EmbedDialog types={types} tabs={tabs} eventTypeHideOptionDisabled={false} />;+};++export const EventTypeEmbedButton = (props: ComponentProps<typeof EmbedButton>) => {+ return <EmbedButton {...props} />;+};diff --git a/packages/features/embed/RoutingFormEmbed.tsx b/packages/features/embed/RoutingFormEmbed.tsxnew file mode 100644index 00000000000..3002eb6eae0--- /dev/null+++ b/packages/features/embed/RoutingFormEmbed.tsx@@ -0,0 +1,16 @@+import type { ComponentProps } from "react";++import { EmbedDialog, EmbedButton } from "@calcom/features/embed/Embed";++import { tabs } from "./lib/EmbedTabs";+import { useEmbedTypes } from "./lib/hooks";++export const RoutingFormEmbedDialog = () => {+ const types = useEmbedTypes();+ const routingFormTypes = types.filter((type) => type.type !== "email");+ return <EmbedDialog types={routingFormTypes} tabs={tabs} eventTypeHideOptionDisabled={true} />;+};++export const RoutingFormEmbedButton = (props: ComponentProps<typeof EmbedButton>) => {+ return <EmbedButton {...props} />;+};diff --git a/packages/features/embed/lib/EmbedCodes.tsx b/packages/features/embed/lib/EmbedCodes.tsxnew file mode 100644index 00000000000..464b122abbc--- /dev/null+++ b/packages/features/embed/lib/EmbedCodes.tsx@@ -0,0 +1,180 @@+import { IS_SELF_HOSTED } from "@calcom/lib/constants";++import type { PreviewState } from "../types";+import { embedLibUrl } from "./constants";+import { getDimension } from "./getDimension";++// eslint-disable-next-line @typescript-eslint/no-explicit-any+export const Codes = {+ react: {+ inline: ({+ calLink,+ uiInstructionCode,+ previewState,+ embedCalOrigin,+ }: {+ calLink: string;+ uiInstructionCode: string;+ previewState: PreviewState;+ embedCalOrigin: string;+ }) => {+ const width = getDimension(previewState.inline.width);+ const height = getDimension(previewState.inline.height);+ return code`+ import Cal, { getCalApi } from "@calcom/embed-react";+ import { useEffect } from "react";+ export default function MyApp() {+ useEffect(()=>{+ (async function () {+ const cal = await getCalApi();+ ${uiInstructionCode}+ })();+ }, [])+ return <Cal+ calLink="${calLink}"+ style={{width:"${width}",height:"${height}",overflow:"scroll"}}+ ${previewState.layout ? "config={{layout: '" + previewState.layout + "'}}" : ""}${+ IS_SELF_HOSTED+ ? `+ calOrigin="${embedCalOrigin}"+ calJsUrl="${embedLibUrl}"`+ : ""+ }+ />;+ };`;+ },+ "floating-popup": ({+ floatingButtonArg,+ uiInstructionCode,+ }: {+ floatingButtonArg: string;+ uiInstructionCode: string;+ }) => {+ return code`+ import { getCalApi } from "@calcom/embed-react";+ import { useEffect } from "react";+ export default function App() {+ useEffect(()=>{+ (async function () {+ const cal = await getCalApi(${IS_SELF_HOSTED ? `"${embedLibUrl}"` : ""});+ cal("floatingButton", ${floatingButtonArg});+ ${uiInstructionCode}+ })();+ }, [])+ };`;+ },+ "element-click": ({+ calLink,+ uiInstructionCode,+ previewState,+ embedCalOrigin,+ }: {+ calLink: string;+ uiInstructionCode: string;+ previewState: PreviewState;+ embedCalOrigin: string;+ }) => {+ return code`+ import { getCalApi } from "@calcom/embed-react";+ import { useEffect } from "react";+ export default function App() {+ useEffect(()=>{+ (async function () {+ const cal = await getCalApi(${IS_SELF_HOSTED ? `"${embedLibUrl}"` : ""});+ ${uiInstructionCode}+ })();+ }, [])+ return <button+ data-cal-link="${calLink}"${IS_SELF_HOSTED ? `\ndata-cal-origin="${embedCalOrigin}"` : ""}+ ${`data-cal-config='${JSON.stringify({+ layout: previewState.layout,+ })}'`}+ >Click me</button>;+ };`;+ },+ },+ HTML: {+ inline: ({+ calLink,+ uiInstructionCode,+ previewState,+ }: {+ calLink: string;+ uiInstructionCode: string;+ previewState: PreviewState;+ }) => {+ return code`Cal("inline", {+ elementOrSelector:"#my-cal-inline",+ calLink: "${calLink}",+ layout: "${previewState.layout}"+ });++ ${uiInstructionCode}`;+ },++ "floating-popup": ({+ floatingButtonArg,+ uiInstructionCode,+ }: {+ floatingButtonArg: string;+ uiInstructionCode: string;+ }) => {+ return code`Cal("floatingButton", ${floatingButtonArg});+ ${uiInstructionCode}`;+ },+ "element-click": ({+ calLink,+ uiInstructionCode,+ previewState,+ }: {+ calLink: string;+ uiInstructionCode: string;+ previewState: PreviewState;+ }) => {+ return code`+ // Important: Please add following attributes to the element you want to open Cal on click+ // \`data-cal-link="${calLink}"\`+ // \`data-cal-config='${JSON.stringify({+ layout: previewState.layout,+ })}'\`++ ${uiInstructionCode}`;+ },+ },+ // eslint-disable-next-line @typescript-eslint/no-explicit-any+} satisfies Record<string, Record<string, (...args: any[]) => string>>;++/**+ * It allows us to show code with certain reusable blocks indented according to the block variable placement+ * So, if you add a variable ${abc} with indentation of 4 spaces, it will automatically indent all newlines in `abc` with the same indent before constructing the final string+ * `A${var}C` with var = "B" -> partsWithoutBlock=['A','C'] blocksOrVariables=['B']+ */+const code = (partsWithoutBlock: TemplateStringsArray, ...blocksOrVariables: string[]) => {+ const constructedCode: string[] = [];+ for (let i = 0; i < partsWithoutBlock.length; i++) {+ const partWithoutBlock = partsWithoutBlock[i];+ // blocksOrVariables length would always be 1 less than partsWithoutBlock+ // So, last item should be concatenated as is.+ if (i >= blocksOrVariables.length) {+ constructedCode.push(partWithoutBlock);+ continue;+ }+ const block = blocksOrVariables[i];+ const indentedBlock: string[] = [];+ let indent = "";+ block.split("\n").forEach((line) => {+ indentedBlock.push(line);+ });+ // non-null assertion is okay because we know that we are referencing last element.+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion+ const indentationMatch = partWithoutBlock+ .split("\n")+ .at(-1)!+ .match(/(^[\t ]*).*$/);+ if (indentationMatch) {+ indent = indentationMatch[1];+ }+ constructedCode.push(partWithoutBlock + indentedBlock.join("\n" + indent));+ }+ return constructedCode.join("");+};diff --git a/packages/features/embed/lib/EmbedTabs.tsx b/packages/features/embed/lib/EmbedTabs.tsxnew file mode 100644index 00000000000..0671d0c599d--- /dev/null+++ b/packages/features/embed/lib/EmbedTabs.tsx@@ -0,0 +1,262 @@+import { forwardRef } from "react";+import type { MutableRefObject } from "react";++import type { BookerLayout } from "@calcom/features/bookings/Booker/types";+import { APP_NAME, IS_SELF_HOSTED } from "@calcom/lib/constants";+import { useBookerUrl } from "@calcom/lib/hooks/useBookerUrl";+import { useLocale } from "@calcom/lib/hooks/useLocale";+import { TextArea } from "@calcom/ui";+import { Code, Trello } from "@calcom/ui/components/icon";++import type { EmbedType, PreviewState, EmbedFramework } from "../types";+import { Codes } from "./EmbedCodes";+import { EMBED_PREVIEW_HTML_URL, embedLibUrl } from "./constants";+import { getDimension } from "./getDimension";+import { useEmbedCalOrigin } from "./hooks";++export const tabs = [+ {+ name: "HTML",+ href: "embedTabName=embed-code",+ icon: Code,+ type: "code",+ Component: forwardRef<+ HTMLTextAreaElement | HTMLIFrameElement | null,+ { embedType: EmbedType; calLink: string; previewState: PreviewState }+ >(function EmbedHtml({ embedType, calLink, previewState }, ref) {+ const { t } = useLocale();+ const embedSnippetString = useGetEmbedSnippetString();+ const embedCalOrigin = useEmbedCalOrigin();+ if (ref instanceof Function || !ref) {+ return null;+ }+ if (ref.current && !(ref.current instanceof HTMLTextAreaElement)) {+ return null;+ }+ return (+ <>+ <div>+ <small className="text-subtle flex py-4">+ {t("place_where_cal_widget_appear", { appName: APP_NAME })}+ </small>+ </div>+ <TextArea+ data-testid="embed-code"+ ref={ref as typeof ref & MutableRefObject<HTMLTextAreaElement>}+ name="embed-code"+ className="text-default bg-default selection:bg-subtle h-[calc(100%-50px)] font-mono"+ style={{ resize: "none", overflow: "auto" }}+ readOnly+ value={+ `<!-- Cal ${embedType} embed code begins -->\n` ++ (embedType === "inline"+ ? `<div style="width:${getDimension(previewState.inline.width)};height:${getDimension(+ previewState.inline.height+ )};overflow:scroll" id="my-cal-inline"></div>\n`+ : "") ++ `<script type="text/javascript">+ ${embedSnippetString}+ ${getEmbedTypeSpecificString({ embedFramework: "HTML", embedType, calLink, previewState, embedCalOrigin })}+ </script>+ <!-- Cal ${embedType} embed code ends -->`+ }+ />+ <p className="text-subtle hidden text-sm">{t("need_help_embedding")}</p>+ </>+ );+ }),+ },+ {+ name: "React",+ href: "embedTabName=embed-react",+ icon: Code,+ type: "code",+ Component: forwardRef<+ HTMLTextAreaElement | HTMLIFrameElement | null,+ { embedType: EmbedType; calLink: string; previewState: PreviewState }+ >(function EmbedReact({ embedType, calLink, previewState }, ref) {+ const { t } = useLocale();+ const embedCalOrigin = useEmbedCalOrigin();++ if (ref instanceof Function || !ref) {+ return null;+ }+ if (ref.current && !(ref.current instanceof HTMLTextAreaElement)) {+ return null;+ }+ return (+ <>+ <small className="text-subtle flex py-4">{t("create_update_react_component")}</small>+ <TextArea+ data-testid="embed-react"+ ref={ref as typeof ref & MutableRefObject<HTMLTextAreaElement>}+ name="embed-react"+ className="text-default bg-default selection:bg-subtle h-[calc(100%-50px)] font-mono"+ readOnly+ style={{ resize: "none", overflow: "auto" }}+ value={`/* First make sure that you have installed the package */++ /* If you are using yarn */+ // yarn add @calcom/embed-react++ /* If you are using npm */+ // npm install @calcom/embed-react+ ${getEmbedTypeSpecificString({ embedFramework: "react", embedType, calLink, previewState, embedCalOrigin })}+ `}+ />+ </>+ );+ }),+ },+ {+ name: "Preview",+ href: "embedTabName=embed-preview",+ icon: Trello,+ type: "iframe",+ Component: forwardRef<+ HTMLIFrameElement | HTMLTextAreaElement | null,+ { calLink: string; embedType: EmbedType; previewState: PreviewState }+ >(function Preview({ calLink, embedType }, ref) {+ const bookerUrl = useBookerUrl();+ if (ref instanceof Function || !ref) {+ return null;+ }+ if (ref.current && !(ref.current instanceof HTMLIFrameElement)) {+ return null;+ }+ return (+ <iframe+ ref={ref as typeof ref & MutableRefObject<HTMLIFrameElement>}+ data-testid="embed-preview"+ className="h-[100vh] border"+ width="100%"+ height="100%"+ src={`${EMBED_PREVIEW_HTML_URL}?embedType=${embedType}&calLink=${calLink}&embedLibUrl=${embedLibUrl}&bookerUrl=${bookerUrl}`}+ />+ );+ }),+ },+];++const getEmbedTypeSpecificString = ({+ embedFramework,+ embedType,+ calLink,+ embedCalOrigin,+ previewState,+}: {+ embedFramework: EmbedFramework;+ embedType: EmbedType;+ calLink: string;+ previewState: PreviewState;+ embedCalOrigin: string;+}) => {+ const frameworkCodes = Codes[embedFramework];+ if (!frameworkCodes) {+ throw new Error(`No code available for the framework:${embedFramework}`);+ }+ if (embedType === "email") return "";+ let uiInstructionStringArg: {+ apiName: string;+ theme: PreviewState["theme"];+ brandColor: string;+ hideEventTypeDetails: boolean;+ layout?: BookerLayout;+ };+ if (embedFramework === "react") {+ uiInstructionStringArg = {+ apiName: "cal",+ theme: previewState.theme,+ brandColor: previewState.palette.brandColor,+ hideEventTypeDetails: previewState.hideEventTypeDetails,+ layout: previewState.layout,+ };+ } else {+ uiInstructionStringArg = {+ apiName: "Cal",+ theme: previewState.theme,+ brandColor: previewState.palette.brandColor,+ hideEventTypeDetails: previewState.hideEventTypeDetails,+ layout: previewState.layout,+ };+ }+ if (!frameworkCodes[embedType]) {+ throw new Error(`Code not available for framework:${embedFramework} and embedType:${embedType}`);+ }+ if (embedType === "inline") {+ return frameworkCodes[embedType]({+ calLink,+ uiInstructionCode: getEmbedUIInstructionString(uiInstructionStringArg),+ previewState,+ embedCalOrigin,+ });+ } else if (embedType === "floating-popup") {+ const floatingButtonArg = {+ calLink,+ ...(IS_SELF_HOSTED ? { calOrigin: embedCalOrigin } : null),+ ...previewState.floatingPopup,+ };+ return frameworkCodes[embedType]({+ floatingButtonArg: JSON.stringify(floatingButtonArg),+ uiInstructionCode: getEmbedUIInstructionString(uiInstructionStringArg),+ });+ } else if (embedType === "element-click") {+ return frameworkCodes[embedType]({+ calLink,+ uiInstructionCode: getEmbedUIInstructionString(uiInstructionStringArg),+ previewState,+ embedCalOrigin,+ });+ }+ return "";+};++const getEmbedUIInstructionString = ({+ apiName,+ theme,+ brandColor,+ hideEventTypeDetails,+ layout,+}: {+ apiName: string;+ theme?: string;+ brandColor: string;+ hideEventTypeDetails: boolean;+ layout?: string;+}) => {+ theme = theme !== "auto" ? theme : undefined;+ return getInstructionString({+ apiName,+ instructionName: "ui",+ instructionArg: {+ theme,+ styles: {+ branding: {+ brandColor,+ },+ },+ hideEventTypeDetails: hideEventTypeDetails,+ layout,+ },+ });+};++const getInstructionString = ({+ apiName,+ instructionName,+ instructionArg,+}: {+ apiName: string;+ instructionName: string;+ instructionArg: Record<string, unknown>;+}) => {+ return `${apiName}("${instructionName}", ${JSON.stringify(instructionArg)});`;+};++function useGetEmbedSnippetString() {+ const bookerUrl = useBookerUrl();+ // TODO: Import this string from @calcom/embed-snippet+ return `(function (C, A, L) { let p = function (a, ar) { a.q.push(ar); }; let d = C.document; C.Cal = C.Cal || function () { let cal = C.Cal; let ar = arguments; if (!cal.loaded) { cal.ns = {}; cal.q = cal.q || []; d.head.appendChild(d.createElement("script")).src = A; cal.loaded = true; } if (ar[0] === L) { const api = function () { p(api, arguments); }; const namespace = ar[1]; api.q = api.q || []; typeof namespace === "string" ? (cal.ns[namespace] = api) && p(api, ar) : p(cal, ar); return; } p(cal, ar); }; })(window, "${embedLibUrl}", "init");+Cal("init", {origin:"${bookerUrl}"});+`;+}diff --git a/packages/features/embed/lib/constants.ts b/packages/features/embed/lib/constants.tsnew file mode 100644index 00000000000..aa62ce2c761--- /dev/null+++ b/packages/features/embed/lib/constants.ts@@ -0,0 +1,4 @@+import { EMBED_LIB_URL, WEBAPP_URL } from "@calcom/lib/constants";++export const embedLibUrl = EMBED_LIB_URL;+export const EMBED_PREVIEW_HTML_URL = `${WEBAPP_URL}/embed/preview.html`;diff --git a/packages/features/embed/lib/getDimension.tsx b/packages/features/embed/lib/getDimension.tsxnew file mode 100644index 00000000000..cdbddfd69d9--- /dev/null+++ b/packages/features/embed/lib/getDimension.tsx@@ -0,0 +1,6 @@+export const getDimension = (dimension: string) => {+ if (dimension.match(/^\d+$/)) {+ dimension = `${dimension}%`;+ }+ return dimension;+};diff --git a/packages/features/embed/lib/hooks/index.tsx b/packages/features/embed/lib/hooks/index.tsxnew file mode 100644index 00000000000..ea7f659bbec--- /dev/null+++ b/packages/features/embed/lib/hooks/index.tsx@@ -0,0 +1,324 @@+import { useBookerUrl } from "@calcom/lib/hooks/useBookerUrl";+import { useLocale } from "@calcom/lib/hooks/useLocale";++export const useEmbedTypes = () => {+ const { t } = useLocale();+ return [+ {+ title: t("inline_embed"),+ subtitle: t("load_inline_content"),+ type: "inline",+ illustration: (+ <svg+ width="100%"+ height="100%"+ className="rounded-md"+ viewBox="0 0 308 265"+ fill="none"+ xmlns="http://www.w3.org/2000/svg">+ <path+ d="M0 1.99999C0 0.895423 0.895431 0 2 0H306C307.105 0 308 0.895431 308 2V263C308 264.105 307.105 265 306 265H2C0.895431 265 0 264.105 0 263V1.99999Z"+ fill="white"+ />+ <rect x="24" width="260" height="38.5" rx="6" fill="#F3F4F6" />+ <rect x="24.5" y="51" width="139" height="163" rx="1.5" fill="#F8F8F8" />+ <rect opacity="0.8" x="48" y="74.5" width="80" height="8" rx="6" fill="#F3F4F6" />+ <rect x="48" y="86.5" width="48" height="4" rx="6" fill="#F3F4F6" />+ <rect x="49" y="99.5" width="6" height="6" rx="1" fill="#C6C6C6" />+ <rect x="61" y="99.5" width="6" height="6" rx="1" fill="#3E3E3E" />+ <rect x="73" y="99.5" width="6" height="6" rx="1" fill="#C6C6C6" />+ <rect x="85" y="99.5" width="6" height="6" rx="1" fill="#C6C6C6" />+ <rect x="97" y="99.5" width="6" height="6" rx="1" fill="#C6C6C6" />+ <rect x="109" y="99.5" width="6" height="6" rx="1" fill="#C6C6C6" />+ <rect x="121" y="99.5" width="6" height="6" rx="1" fill="#C6C6C6" />+ <rect x="133" y="99.5" width="6" height="6" rx="1" fill="#C6C6C6" />+ <rect x="85" y="113.5" width="6" height="6" rx="1" fill="#C6C6C6" />+ <rect x="97" y="113.5" width="6" height="6" rx="1" fill="#C6C6C6" />+ <rect x="109" y="113.5" width="6" height="6" rx="1" fill="#C6C6C6" />+ <rect x="121" y="113.5" width="6" height="6" rx="1" fill="#C6C6C6" />+ <rect x="133" y="113.5" width="6" height="6" rx="1" fill="#C6C6C6" />+ <rect x="49" y="125.5" width="6" height="6" rx="1" fill="#C6C6C6" />+ <rect x="61" y="125.5" width="6" height="6" rx="1" fill="#3E3E3E" />+ <path+ d="M61 124.5H67V122.5H61V124.5ZM68 125.5V131.5H70V125.5H68ZM67 132.5H61V134.5H67V132.5ZM60 131.5V125.5H58V131.5H60ZM61 132.5C60.4477 132.5 60 132.052 60 131.5H58C58 133.157 59.3431 134.5 61 134.5V132.5ZM68 131.5C68 132.052 67.5523 132.5 67 132.5V134.5C68.6569 134.5 70 133.157 70 131.5H68ZM67 124.5C67.5523 124.5 68 124.948 68 125.5H70C70 123.843 68.6569 122.5 67 122.5V124.5ZM61 122.5C59.3431 122.5 58 123.843 58 125.5H60C60 124.948 60.4477 124.5 61 124.5V122.5Z"+ fill="#3E3E3E"+ />+ <rect x="73" y="125.5" width="6" height="6" rx="1" fill="#C6C6C6" />+ <rect x="85" y="125.5" width="6" height="6" rx="1" fill="#C6C6C6" />+ <rect x="97" y="125.5" width="6" height="6" rx="1" fill="#C6C6C6" />+ <rect x="109" y="125.5" width="6" height="6" rx="1" fill="#C6C6C6" />+ <rect x="121" y="125.5" width="6" height="6" rx="1" fill="#C6C6C6" />+ <rect x="133" y="125.5" width="6" height="6" rx="1" fill="#C6C6C6" />+ <rect x="49" y="137.5" width="6" height="6" rx="1" fill="#C6C6C6" />+ <rect x="61" y="137.5" width="6" height="6" rx="1" fill="#C6C6C6" />+ <rect x="73" y="137.5" width="6" height="6" rx="1" fill="#C6C6C6" />+ <rect x="85" y="137.5" width="6" height="6" rx="1" fill="#C6C6C6" />+ <rect x="97" y="137.5" width="6" height="6" rx="1" fill="#3E3E3E" />+ <rect x="109" y="137.5" width="6" height="6" rx="1" fill="#3E3E3E" />+ <rect x="121" y="137.5" width="6" height="6" rx="1" fill="#C6C6C6" />+ <rect x="133" y="137.5" width="6" height="6" rx="1" fill="#C6C6C6" />+ <rect x="49" y="149.5" width="6" height="6" rx="1" fill="#C6C6C6" />+ <rect x="61" y="149.5" width="6" height="6" rx="1" fill="#C6C6C6" />+ <rect x="73" y="149.5" width="6" height="6" rx="1" fill="#C6C6C6" />+ <rect x="85" y="149.5" width="6" height="6" rx="1" fill="#C6C6C6" />+ <rect x="97" y="149.5" width="6" height="6" rx="1" fill="#3E3E3E" />+ <rect x="109" y="149.5" width="6" height="6" rx="1" fill="#3E3E3E" />+ <rect x="121" y="149.5" width="6" height="6" rx="1" fill="#C6C6C6" />+ <rect x="133" y="149.5" width="6" height="6" rx="1" fill="#C6C6C6" />+ <rect x="49" y="161.5" width="6" height="6" rx="1" fill="#C6C6C6" />+ <rect x="61" y="161.5" width="6" height="6" rx="1" fill="#C6C6C6" />+ <rect x="73" y="161.5" width="6" height="6" rx="1" fill="#C6C6C6" />+ <rect x="85" y="161.5" width="6" height="6" rx="1" fill="#C6C6C6" />+ <rect x="97" y="161.5" width="6" height="6" rx="1" fill="#3E3E3E" />+ <rect x="109" y="161.5" width="6" height="6" rx="1" fill="#C6C6C6" />+ <rect x="24.5" y="51" width="139" height="163" rx="6" stroke="#292929" />+ <rect x="176" y="50.5" width="108" height="164" rx="6" fill="#F3F4F6" />+ <rect x="24" y="226.5" width="260" height="38.5" rx="6" fill="#F3F4F6" />+ </svg>+ ),+ },+ {+ title: t("floating_pop_up_button"),+ subtitle: t("floating_button_trigger_modal"),+ type: "floating-popup",+ illustration: (+ <svg+ width="100%"+ height="100%"+ className="rounded-md"+ viewBox="0 0 308 265"+ fill="none"+ xmlns="http://www.w3.org/2000/svg">+ <path+ d="M0 1.99999C0 0.895423 0.895431 0 2 0H306C307.105 0 308 0.895431 308 2V263C308 264.105 307.105 265 306 265H2C0.895431 265 0 264.105 0 263V1.99999Z"+ fill="white"+ />+ <rect x="24" width="260" height="38.5" rx="6" fill="#F3F4F6" />+ <rect x="24" y="50.5" width="120" height="76" rx="6" fill="#F3F4F6" />+ <rect x="24" y="138.5" width="120" height="76" rx="6" fill="#F3F4F6" />+ <rect x="156" y="50.5" width="128" height="164" rx="6" fill="#F3F4F6" />+ <rect x="24" y="226.5" width="260" height="38.5" rx="6" fill="#F3F4F6" />+ <rect x="226" y="223.5" width="66" height="26" rx="6" fill="#292929" />+ <rect x="242" y="235.5" width="34" height="2" rx="1" fill="white" />+ </svg>+ ),+ },+ {+ title: t("pop_up_element_click"),+ subtitle: t("open_dialog_with_element_click"),+ type: "element-click",+ illustration: (+ <svg+ width="100%"+ height="100%"+ className="rounded-md"+ viewBox="0 0 308 265"+ fill="none"+ xmlns="http://www.w3.org/2000/svg">+ <path+ d="M0 1.99999C0 0.895423 0.895431 0 2 0H306C307.105 0 308 0.895431 308 2V263C308 264.105 307.105 265 306 265H2C0.895431 265 0 264.105 0 263V1.99999Z"+ fill="white"+ />+ <rect x="24" y="0.50293" width="260" height="24" rx="6" fill="#F3F4F6" />+ <rect x="24" y="35" width="259" height="192" rx="5.5" fill="#F9FAFB" />+ <g filter="url(#filter0_i_3223_14162)">+ <rect opacity="0.8" x="40" y="99" width="24" height="24" rx="2" fill="#E5E7EB" />+ <rect x="40" y="127" width="48" height="8" rx="1" fill="#E5E7EB" />+ <rect x="40" y="139" width="82" height="8" rx="1" fill="#E5E7EB" />+ <rect x="40" y="151" width="34" height="4" rx="1" fill="#E5E7EB" />+ <rect x="40" y="159" width="34" height="4" rx="1" fill="#E5E7EB" />+ </g>+ <rect x="152" y="48" width="2" height="169" rx="2" fill="#E5E7EB" />++ <rect opacity="0.8" x="176" y="84" width="80" height="8" rx="2" fill="#E5E7EB" />+ <rect x="176" y="96" width="48" height="4" rx="1" fill="#E5E7EB" />+ <rect x="177" y="109" width="6" height="6" rx="1" fill="#E5E7EB" />+ <rect x="189" y="109" width="6" height="6" rx="1" fill="#0D121D" />+ <rect x="201" y="109" width="6" height="6" rx="1" fill="#E5E7EB" />+ <rect x="213" y="109" width="6" height="6" rx="1" fill="#E5E7EB" />+ <rect x="225" y="109" width="6" height="6" rx="1" fill="#E5E7EB" />+ <rect x="237" y="109" width="6" height="6" rx="1" fill="#E5E7EB" />+ <rect x="249" y="109" width="6" height="6" rx="1" fill="#E5E7EB" />+ <rect x="261" y="109" width="6" height="6" rx="1" fill="#E5E7EB" />+ <rect x="213" y="123" width="6" height="6" rx="1" fill="#E5E7EB" />+ <rect x="225" y="123" width="6" height="6" rx="1" fill="#E5E7EB" />+ <rect x="237" y="123" width="6" height="6" rx="1" fill="#E5E7EB" />+ <rect x="249" y="123" width="6" height="6" rx="1" fill="#E5E7EB" />+ <rect x="261" y="123" width="6" height="6" rx="1" fill="#E5E7EB" />+ <rect x="177" y="135" width="6" height="6" rx="1" fill="#E5E7EB" />+ <rect x="189" y="135" width="6" height="6" rx="1" fill="#0D121D" />+ <rect x="187.3" y="133.4" width="9" height="9" rx="1.5" stroke="#0D121D" />+ <rect x="201" y="135" width="6" height="6" rx="1" fill="#E5E7EB" />+ <rect x="213" y="135" width="6" height="6" rx="1" fill="#E5E7EB" />+ <rect x="225" y="135" width="6" height="6" rx="1" fill="#E5E7EB" />+ <rect x="237" y="135" width="6" height="6" rx="1" fill="#E5E7EB" />+ <rect x="249" y="135" width="6" height="6" rx="1" fill="#E5E7EB" />+ <rect x="261" y="135" width="6" height="6" rx="1" fill="#E5E7EB" />+ <rect x="177" y="147" width="6" height="6" rx="1" fill="#E5E7EB" />+ <rect x="189" y="147" width="6" height="6" rx="1" fill="#E5E7EB" />+ <rect x="201" y="147" width="6" height="6" rx="1" fill="#E5E7EB" />+ <rect x="213" y="147" width="6" height="6" rx="1" fill="#E5E7EB" />+ <rect x="225" y="147" width="6" height="6" rx="1" fill="#0D121D" />+ <rect x="237" y="147" width="6" height="6" rx="1" fill="#0D121D" />+ <rect x="249" y="147" width="6" height="6" rx="1" fill="#E5E7EB" />+ <rect x="261" y="147" width="6" height="6" rx="1" fill="#E5E7EB" />+ <rect x="177" y="159" width="6" height="6" rx="1" fill="#E5E7EB" />+ <rect x="189" y="159" width="6" height="6" rx="1" fill="#E5E7EB" />+ <rect x="201" y="159" width="6" height="6" rx="1" fill="#E5E7EB" />+ <rect x="213" y="159" width="6" height="6" rx="1" fill="#E5E7EB" />+ <rect x="225" y="159" width="6" height="6" rx="1" fill="#0D121D" />+ <rect x="237" y="159" width="6" height="6" rx="1" fill="#0D121D" />+ <rect x="249" y="159" width="6" height="6" rx="1" fill="#E5E7EB" />+ <rect x="261" y="159" width="6" height="6" rx="1" fill="#E5E7EB" />+ <rect x="177" y="171" width="6" height="6" rx="1" fill="#E5E7EB" />+ <rect x="189" y="171" width="6" height="6" rx="1" fill="#E5E7EB" />+ <rect x="201" y="171" width="6" height="6" rx="1" fill="#E5E7EB" />+ <rect x="213" y="171" width="6" height="6" rx="1" fill="#E5E7EB" />+ <rect x="225" y="171" width="6" height="6" rx="1" fill="#0D121D" />+ <rect x="237" y="171" width="6" height="6" rx="1" fill="#E5E7EB" />+ <rect x="24" y="35" width="259" height="192" rx="5.5" stroke="#101010" />+ <rect x="24" y="241.503" width="260" height="24" rx="6" fill="#F3F4F6" />+ </svg>+ ),+ },+ {+ title: t("email_embed"),+ subtitle: t("add_times_to_your_email"),+ type: "email",+ illustration: (+ <svg+ width="100%"+ height="100%"+ className="rounded-md"+ viewBox="0 0 308 265"+ fill="none"+ xmlns="http://www.w3.org/2000/svg">+ <g clip-path="url(#clip0_457_1339)">+ <rect width="308" height="265" rx="8" fill="white" />+ <rect width="308" height="18" rx="4" fill="#F3F4F6" />+ <rect y="19" width="308" height="18" rx="4" fill="#F3F4F6" />+ <rect y="38" width="308" height="18" rx="4" fill="#F3F4F6" />+ <rect y="57" width="308" height="18" rx="4" fill="#F3F4F6" />+ <rect y="76" width="308" height="18" rx="4" fill="#F3F4F6" />+ <rect y="95" width="308" height="18" rx="4" fill="#F3F4F6" />+ <rect y="114" width="308" height="18" rx="4" fill="#F3F4F6" />+ <rect y="133" width="308" height="18" rx="4" fill="#F3F4F6" />+ <rect y="152" width="308" height="18" rx="4" fill="#F3F4F6" />+ <rect y="171" width="308" height="18" rx="4" fill="#F3F4F6" />+ <rect y="190" width="308" height="18" rx="4" fill="#F3F4F6" />+ <rect y="209" width="308" height="18" rx="4" fill="#F3F4F6" />+ <rect y="228" width="308" height="18" rx="4" fill="#F3F4F6" />+ <rect y="247" width="308" height="18" rx="4" fill="#F3F4F6" />+ <g clip-path="url(#clip1_457_1339)">+ <rect x="107" y="64" width="189" height="189" rx="6" fill="white" />+ <g clip-path="url(#clip2_457_1339)">+ <path+ d="M124.671 75.5243C124.671 75.1018 124.325 74.756 123.902 74.756H117.756C117.334 74.756 116.988 75.1018 116.988 75.5243M124.671 75.5243V80.1341C124.671 80.5567 124.325 80.9024 123.902 80.9024H117.756C117.334 80.9024 116.988 80.5567 116.988 80.1341V75.5243M124.671 75.5243L120.829 78.2134L116.988 75.5243"+ stroke="#9CA3AF"+ stroke-width="1.15244"+ stroke-linecap="round"+ stroke-linejoin="round"+ />+ </g>+ <rect x="130.049" y="75.5244" width="92.1951" height="4.60976" rx="2.30488" fill="#D1D5DB" />+ <rect x="130.049" y="84.7439" width="55.3171" height="4.60976" rx="2.30488" fill="#E5E7EB" />+ <rect+ opacity="0.8"+ x="107"+ y="98.5732"+ width="189"+ height="1.15244"+ rx="0.576219"+ fill="#E5E7EB"+ />+ <rect x="116.219" y="113.555" width="92.1951" height="4.60976" rx="2.30488" fill="#D1D5DB" />+ <rect x="116.219" y="122.774" width="42.6402" height="4.60976" rx="2.30488" fill="#E5E7EB" />+ <rect x="116.219" y="136.604" width="55.3171" height="4.60976" rx="2.30488" fill="#D1D5DB" />+ <rect x="116.719" y="145.171" width="22.0488" height="5.91463" rx="2.95732" stroke="#9CA3AF" />+ <rect x="142.073" y="145.171" width="22.0488" height="5.91463" rx="2.95732" stroke="#9CA3AF" />+ <rect x="167.427" y="145.171" width="22.0488" height="5.91463" rx="2.95732" stroke="#9CA3AF" />+ <rect x="192.781" y="145.171" width="22.0488" height="5.91463" rx="2.95732" stroke="#9CA3AF" />+ <rect x="218.134" y="145.171" width="22.0488" height="5.91463" rx="2.95732" stroke="#9CA3AF" />+ <rect x="116.219" y="160.805" width="55.3171" height="4.60976" rx="2.30488" fill="#D1D5DB" />+ <rect x="116.719" y="169.372" width="22.0488" height="5.91463" rx="2.95732" stroke="#9CA3AF" />+ <rect x="142.073" y="169.372" width="22.0488" height="5.91463" rx="2.95732" stroke="#9CA3AF" />+ <rect x="167.427" y="169.372" width="22.0488" height="5.91463" rx="2.95732" stroke="#9CA3AF" />+ <rect x="192.781" y="169.372" width="22.0488" height="5.91463" rx="2.95732" stroke="#9CA3AF" />+ <rect x="218.134" y="169.372" width="22.0488" height="5.91463" rx="2.95732" stroke="#9CA3AF" />+ <rect x="116.219" y="185.006" width="55.3171" height="4.60976" rx="2.30488" fill="#D1D5DB" />+ <rect x="116.719" y="193.573" width="22.0488" height="5.91463" rx="2.95732" stroke="#9CA3AF" />+ <rect x="142.073" y="193.573" width="22.0488" height="5.91463" rx="2.95732" stroke="#9CA3AF" />+ <rect x="167.427" y="193.573" width="22.0488" height="5.91463" rx="2.95732" stroke="#9CA3AF" />+ <rect x="192.781" y="193.573" width="22.0488" height="5.91463" rx="2.95732" stroke="#9CA3AF" />+ <rect x="218.134" y="193.573" width="22.0488" height="5.91463" rx="2.95732" stroke="#9CA3AF" />+ <rect+ opacity="0.8"+ x="107"+ y="223.037"+ width="189"+ height="1.15244"+ rx="0.576219"+ fill="#E5E7EB"+ />+ <rect width="189" height="28.811" transform="translate(107 224.189)" fill="#F9FAFB" />+ <rect x="116.219" y="233.985" width="23.0488" height="9.21951" rx="2.30488" fill="#9CA3AF" />+ <rect+ opacity="0.8"+ x="141.573"+ y="233.985"+ width="9.21951"+ height="9.21951"+ rx="2.30488"+ fill="#E5E7EB"+ />+ <rect+ opacity="0.8"+ x="153.098"+ y="233.985"+ width="9.21951"+ height="9.21951"+ rx="2.30488"+ fill="#E5E7EB"+ />+ <rect+ opacity="0.8"+ x="164.622"+ y="233.985"+ width="9.21951"+ height="9.21951"+ rx="2.30488"+ fill="#E5E7EB"+ />+ </g>+ <rect+ x="106.424"+ y="63.4238"+ width="190.152"+ height="190.152"+ rx="6.57622"+ stroke="#101010"+ stroke-width="1.15244"+ />+ </g>+ <rect x="0.5" y="0.5" width="307" height="264" rx="7.5" stroke="#E5E7EB" />+ <defs>+ <clipPath id="clip0_457_1339">+ <rect width="308" height="265" rx="8" fill="white" />+ </clipPath>+ <clipPath id="clip1_457_1339">+ <rect x="107" y="64" width="189" height="189" rx="6" fill="white" />+ </clipPath>+ <clipPath id="clip2_457_1339">+ <rect width="9.21951" height="9.21951" fill="white" transform="translate(116.219 73.2195)" />+ </clipPath>+ </defs>+ </svg>+ ),+ },+ ];+};++export const useEmbedCalOrigin = () => {+ const bookerUrl = useBookerUrl();+ return bookerUrl;+};diff --git a/packages/features/embed/types/index.d.ts b/packages/features/embed/types/index.d.tsnew file mode 100644index 00000000000..e8dda02e0da--- /dev/null+++ b/packages/features/embed/types/index.d.ts@@ -0,0 +1,27 @@+import type { tabs } from "../lib/EmbedTabs";+import type { useEmbedTypes } from "../lib/hooks";++export type EmbedType = "inline" | "floating-popup" | "element-click" | "email";+export type PreviewState = {+ inline: {+ width: string;+ height: string;+ };+ theme: Theme;+ floatingPopup: {+ config?: {+ layout: BookerLayouts;+ };+ [key: string]: string | boolean | undefined | Record<string, string>;+ };+ elementClick: Record<string, string>;+ palette: {+ brandColor: string;+ };+ hideEventTypeDetails: boolean;+ layout: BookerLayouts;+};++export type EmbedFramework = "react" | "HTML";+export type EmbedTabs = typeof tabs;+export type EmbedTypes = ReturnType<typeof useEmbedTypes>;