chore: bump atoms 1.0.35 and wrap context (#14744)
This commit is contained in:
1 parent
d8adc8eeb1
commit
8fbb1ed426
3 files changed
+49
-32
No files matched your search
@@ -62,6 +62,35 @@ export function BaseCalProvider({
|
||||
clientId,
|
||||
});
|
||||
|
||||
const translations = {
|
||||
t: (key: string, values: Record<string, string | number | null | undefined>) => {
|
||||
let translation = String(enTranslations[key as translationKeys] ?? "");
|
||||
if (!translation) {
|
||||
return "";
|
||||
}
|
||||
if (values) {
|
||||
const valueKeys = Object.keys(values) as (keyof typeof values)[];
|
||||
if (valueKeys.length) {
|
||||
valueKeys.forEach((valueKey) => {
|
||||
if (translation)
|
||||
translation = translation.replace(
|
||||
`{{${String(valueKey)}}}`,
|
||||
values[valueKey]?.toString() ?? `{{${String(valueKey)}}}`
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return replaceOccurrences(translation, enTranslations) ?? "";
|
||||
},
|
||||
i18n: {
|
||||
language: "en",
|
||||
defaultLocale: "en",
|
||||
locales: ["en"],
|
||||
exists: (key: translationKeys | string) => Boolean(enTranslations[key as translationKeys]),
|
||||
},
|
||||
};
|
||||
|
||||
return isInit ? (
|
||||
<AtomsContext.Provider
|
||||
value={{
|
||||
@@ -74,41 +103,29 @@ export function BaseCalProvider({
|
||||
isInit: isInit,
|
||||
isValidClient: Boolean(!error && clientId && isInit),
|
||||
isAuth: Boolean(isInit && !error && clientId && currentAccessToken && http.getAuthorizationHeader()),
|
||||
t: (key, values) => {
|
||||
let translation = String(enTranslations[key as translationKeys] ?? "");
|
||||
if (!translation) {
|
||||
return "";
|
||||
}
|
||||
if (values) {
|
||||
const valueKeys = Object.keys(values) as (keyof typeof values)[];
|
||||
if (valueKeys.length) {
|
||||
valueKeys.forEach((valueKey) => {
|
||||
if (translation)
|
||||
translation = translation.replace(
|
||||
`{{${String(valueKey)}}}`,
|
||||
values[valueKey]?.toString() ?? `{{${String(valueKey)}}}`
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return replaceOccurrences(translation, enTranslations) ?? "";
|
||||
},
|
||||
i18n: {
|
||||
language: "en",
|
||||
defaultLocale: "en",
|
||||
locales: ["en"],
|
||||
exists: (key: translationKeys | string) => Boolean(enTranslations[key as translationKeys]),
|
||||
},
|
||||
...translations,
|
||||
}}>
|
||||
<TooltipProvider>{children}</TooltipProvider>
|
||||
<Toaster />
|
||||
</AtomsContext.Provider>
|
||||
) : (
|
||||
<>
|
||||
{children}
|
||||
<Toaster />
|
||||
</>
|
||||
<AtomsContext.Provider
|
||||
value={{
|
||||
clientId,
|
||||
options,
|
||||
error,
|
||||
getClient: () => http,
|
||||
isAuth: false,
|
||||
isValidClient: Boolean(!error && clientId),
|
||||
isInit: false,
|
||||
isRefreshing: false,
|
||||
...translations,
|
||||
}}>
|
||||
<>
|
||||
<TooltipProvider>{children}</TooltipProvider>
|
||||
<Toaster />
|
||||
</>
|
||||
</AtomsContext.Provider>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ export interface IAtomsContext {
|
||||
i18n: {
|
||||
language: string;
|
||||
defaultLocale: string;
|
||||
locales: [string];
|
||||
locales: string[];
|
||||
exists: (key: translationKeys | string) => boolean;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"type": "module",
|
||||
"description": "Customizable UI components to integrate scheduling into your product.",
|
||||
"authors": "Cal.com, Inc.",
|
||||
"version": "1.0.30",
|
||||
"version": "1.0.35",
|
||||
"scripts": {
|
||||
"dev": "yarn vite build --watch & npx tailwindcss -i ./globals.css -o ./globals.min.css --postcss --minify --watch",
|
||||
"build": "yarn vite build && npx tailwindcss -i ./globals.css -o ./globals.min.css --postcss --minify",
|
||||
|
||||
Reference in new issue
Block a user