Fix missing tabs - Embed (#2804)
* Fix missing tabs * Fix Eslint error * Fix Eslint errors
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
const withNextra = require("nextra")({
|
||||
theme: "nextra-theme-docs",
|
||||
themeConfig: "./theme.config.js",
|
||||
|
||||
@@ -56,7 +56,6 @@ const NavTabs: FC<NavTabProps> = ({ tabs, linkProps, ...props }) => {
|
||||
|
||||
const Component = tab.adminRequired ? AdminRequired : Fragment;
|
||||
|
||||
if (!href) return null;
|
||||
return (
|
||||
<Component key={tab.name}>
|
||||
<Link key={tab.name} href={href} {...linkProps}>
|
||||
|
||||
@@ -39,8 +39,7 @@ export function ContractsProvider({ children }: Props) {
|
||||
|
||||
return (
|
||||
<>
|
||||
{/* @ts-ignore */}
|
||||
<ContractsContext.Provider value={value}>{children}</ContractsContext.Provider>
|
||||
<ContractsContext.Provider value={value as any}>{children}</ContractsContext.Provider>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ export class FloatingButton extends HTMLElement {
|
||||
].join(" ");
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
//@ts-ignore
|
||||
static get observedAttributes() {
|
||||
return [
|
||||
|
||||
@@ -5,6 +5,7 @@ import { getErrorString } from "../utils";
|
||||
import inlineHtml from "./inlineHtml";
|
||||
|
||||
export class Inline extends HTMLElement {
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
//@ts-ignore
|
||||
static get observedAttributes() {
|
||||
return ["loading"];
|
||||
|
||||
@@ -6,6 +6,7 @@ import modalBoxHtml from "./ModalBoxHtml";
|
||||
|
||||
export class ModalBox extends HTMLElement {
|
||||
static htmlOverflow: string;
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
//@ts-ignore
|
||||
static get observedAttributes() {
|
||||
return ["state"];
|
||||
|
||||
@@ -105,7 +105,7 @@ type ReactEmbedStylesSetter = React.Dispatch<React.SetStateAction<EmbedStyles |
|
||||
|
||||
const setEmbedStyles = (stylesConfig: UiConfig["styles"]) => {
|
||||
embedStore.styles = stylesConfig;
|
||||
for (let [, setEmbedStyle] of Object.entries(embedStore.reactStylesStateSetters)) {
|
||||
for (const [, setEmbedStyle] of Object.entries(embedStore.reactStylesStateSetters)) {
|
||||
(setEmbedStyle as any)((styles: any) => {
|
||||
return {
|
||||
...styles,
|
||||
@@ -132,7 +132,7 @@ function isValidNamespace(ns: string | null | undefined) {
|
||||
|
||||
export const useEmbedTheme = () => {
|
||||
const router = useRouter();
|
||||
let [theme, setTheme] = useState(embedStore.theme || (router.query.theme as string));
|
||||
const [theme, setTheme] = useState(embedStore.theme || (router.query.theme as string));
|
||||
useEffect(() => {
|
||||
router.events.on("routeChangeComplete", () => {
|
||||
sdkActionManager?.fire("__routeChanged", {});
|
||||
@@ -305,8 +305,8 @@ const messageParent = (data: any) => {
|
||||
};
|
||||
|
||||
function keepParentInformedAboutDimensionChanges() {
|
||||
let knownIframeHeight: Number | null = null;
|
||||
let knownIframeWidth: Number | null = null;
|
||||
let knownIframeHeight: number | null = null;
|
||||
let knownIframeWidth: number | null = null;
|
||||
let numDimensionChanges = 0;
|
||||
let isFirstTime = true;
|
||||
let isWindowLoadComplete = false;
|
||||
@@ -344,8 +344,8 @@ function keepParentInformedAboutDimensionChanges() {
|
||||
// During first render let iframe tell parent that how much is the expected height to avoid scroll.
|
||||
// Parent would set the same value as the height of iframe which would prevent scroll.
|
||||
// On subsequent renders, consider html height as the height of the iframe. If we don't do this, then if iframe get's bigger in height, it would never shrink
|
||||
let iframeHeight = isFirstTime ? documentScrollHeight : contentHeight;
|
||||
let iframeWidth = isFirstTime ? documentScrollWidth : contentWidth;
|
||||
const iframeHeight = isFirstTime ? documentScrollHeight : contentHeight;
|
||||
const iframeWidth = isFirstTime ? documentScrollWidth : contentWidth;
|
||||
embedStore.parentInformedAboutContentHeight = true;
|
||||
if (!iframeHeight || !iframeWidth) {
|
||||
runAsap(informAboutScroll);
|
||||
|
||||
@@ -64,7 +64,7 @@ function validate(data: any, schema: Record<"props" | "required", any>) {
|
||||
throw new Error("Argument is required");
|
||||
}
|
||||
|
||||
for (let [prop, propSchema] of Object.entries<Record<"type" | "required", any>>(schema.props)) {
|
||||
for (const [prop, propSchema] of Object.entries<Record<"type" | "required", any>>(schema.props)) {
|
||||
if (propSchema.required && isUndefined(data[prop])) {
|
||||
throw new Error(`"${prop}" is required`);
|
||||
}
|
||||
@@ -130,7 +130,7 @@ export class Cal {
|
||||
log(`Instruction ${method} not FOUND`);
|
||||
}
|
||||
try {
|
||||
(this[method] as Function)(...args);
|
||||
(this[method] as (...args: any[]) => void)(...args);
|
||||
} catch (e) {
|
||||
// Instead of throwing error, log and move forward in the queue
|
||||
log(`Instruction couldn't be executed`, e);
|
||||
@@ -145,6 +145,7 @@ export class Cal {
|
||||
|
||||
queue.splice(0);
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
/** @ts-ignore */ // We changed the definition of push here.
|
||||
queue.push = (instruction) => {
|
||||
this.processInstruction(instruction);
|
||||
@@ -188,8 +189,9 @@ export class Cal {
|
||||
}
|
||||
|
||||
// Merge searchParams from config onto the URL which might have query params already
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
//@ts-ignore
|
||||
for (let [key, value] of searchParams) {
|
||||
for (const [key, value] of searchParams) {
|
||||
urlInstance.searchParams.append(key, value);
|
||||
}
|
||||
iframe.src = urlInstance.toString();
|
||||
@@ -224,6 +226,7 @@ export class Cal {
|
||||
elementOrSelector: string | HTMLElement;
|
||||
config: Record<string, string>;
|
||||
}) {
|
||||
// eslint-disable-next-line prefer-rest-params
|
||||
validate(arguments[0], {
|
||||
required: true,
|
||||
props: {
|
||||
@@ -255,7 +258,7 @@ export class Cal {
|
||||
const iframe = this.createIframe({ calLink, queryObject: Cal.getQueryObject(config) });
|
||||
iframe.style.height = "100%";
|
||||
iframe.style.width = "100%";
|
||||
let element =
|
||||
const element =
|
||||
elementOrSelector instanceof HTMLElement
|
||||
? elementOrSelector
|
||||
: document.querySelector(elementOrSelector);
|
||||
@@ -349,6 +352,7 @@ export class Cal {
|
||||
action: Parameters<SdkActionManager["on"]>[0];
|
||||
callback: Parameters<SdkActionManager["on"]>[1];
|
||||
}) {
|
||||
// eslint-disable-next-line prefer-rest-params
|
||||
validate(arguments[0], {
|
||||
required: true,
|
||||
props: {
|
||||
@@ -366,6 +370,7 @@ export class Cal {
|
||||
}
|
||||
|
||||
preload({ calLink }: { calLink: string }) {
|
||||
// eslint-disable-next-line prefer-rest-params
|
||||
validate(arguments[0], {
|
||||
required: true,
|
||||
props: {
|
||||
@@ -499,7 +504,7 @@ export class Cal {
|
||||
|
||||
globalCal.instance = new Cal("", globalCal.q!);
|
||||
|
||||
for (let [ns, api] of Object.entries(globalCal.ns!)) {
|
||||
for (const [ns, api] of Object.entries(globalCal.ns!)) {
|
||||
api.instance = new Cal(ns, api.q!);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,40 +8,35 @@ const EMBED_LIB_URL = import.meta.env.NEXT_PUBLIC_EMBED_LIB_URL || `${WEBAPP_URL
|
||||
|
||||
// Install Cal Embed Code Snippet
|
||||
(function (C, A, L) {
|
||||
// @ts-ignore
|
||||
let p = function (a, ar) {
|
||||
const p = function (a: any, ar: any) {
|
||||
a.q.push(ar);
|
||||
};
|
||||
let d = C.document;
|
||||
// @ts-ignore
|
||||
const d = C.document;
|
||||
C.Cal =
|
||||
// @ts-ignore
|
||||
C.Cal ||
|
||||
function () {
|
||||
// @ts-ignore
|
||||
let cal = C.Cal;
|
||||
let ar = arguments;
|
||||
const cal = C.Cal!;
|
||||
// eslint-disable-next-line prefer-rest-params
|
||||
const ar = arguments;
|
||||
if (!cal.loaded) {
|
||||
cal.ns = {};
|
||||
cal.q = cal.q || [];
|
||||
// @ts-ignore
|
||||
d.head.appendChild(d.createElement("script")).src = A;
|
||||
cal.loaded = true;
|
||||
}
|
||||
if (ar[0] === L) {
|
||||
const api = function () {
|
||||
const api: { (): void; q?: any[] } = function () {
|
||||
// eslint-disable-next-line prefer-rest-params
|
||||
p(api, arguments);
|
||||
};
|
||||
const namespace = ar[1];
|
||||
// @ts-ignore
|
||||
api.q = api.q || [];
|
||||
// @ts-ignore
|
||||
typeof namespace === "string" ? (cal.ns[namespace] = api) && p(api, ar) : p(cal, ar);
|
||||
api!.q = api.q || [];
|
||||
typeof namespace === "string" ? (cal!.ns![namespace] = api) && p(api, ar) : p(cal, ar);
|
||||
return;
|
||||
}
|
||||
p(cal, ar);
|
||||
};
|
||||
})(window, EMBED_LIB_URL, "init");
|
||||
})(window as CalWindow, EMBED_LIB_URL, "init");
|
||||
|
||||
const previewWindow: CalWindow = window;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user