@asgardeo/react 0.13.2 → 0.13.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +828 -428
- package/dist/cjs/index.js.map +4 -4
- package/dist/components/presentation/CreateOrganization/BaseCreateOrganization.d.ts +7 -1
- package/dist/components/presentation/LanguageSwitcher/BaseLanguageSwitcher.d.ts +79 -0
- package/dist/components/presentation/LanguageSwitcher/BaseLanguageSwitcher.styles.d.ts +20 -0
- package/dist/components/presentation/LanguageSwitcher/LanguageSwitcher.d.ts +77 -0
- package/dist/components/presentation/OrganizationList/BaseOrganizationList.d.ts +7 -1
- package/dist/components/presentation/OrganizationProfile/BaseOrganizationProfile.d.ts +7 -1
- package/dist/components/presentation/OrganizationSwitcher/BaseOrganizationSwitcher.d.ts +7 -0
- package/dist/components/presentation/UserProfile/BaseUserProfile.d.ts +7 -1
- package/dist/components/presentation/auth/AcceptInvite/v2/BaseAcceptInvite.d.ts +7 -1
- package/dist/components/presentation/auth/InviteUser/v2/BaseInviteUser.d.ts +7 -1
- package/dist/components/presentation/auth/SignIn/SignIn.d.ts +5 -0
- package/dist/components/presentation/auth/SignIn/v2/BaseSignIn.d.ts +7 -1
- package/dist/components/presentation/auth/SignIn/v2/SignIn.d.ts +7 -1
- package/dist/components/presentation/auth/SignUp/v2/BaseSignUp.d.ts +7 -1
- package/dist/contexts/FlowMeta/FlowMetaContext.d.ts +5 -0
- package/dist/contexts/I18n/ComponentPreferencesContext.d.ts +26 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +485 -69
- package/dist/index.js.map +4 -4
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -844,6 +844,11 @@ var AsgardeoReactClient = class extends AsgardeoBrowserClient {
|
|
|
844
844
|
const config = await this.asgardeo.getConfigData();
|
|
845
845
|
if (config.platform === Platform.AsgardeoV2) {
|
|
846
846
|
this.asgardeo.clearSession();
|
|
847
|
+
if (config.signInUrl) {
|
|
848
|
+
navigate(config.signInUrl);
|
|
849
|
+
} else {
|
|
850
|
+
this.signIn(config.signInOptions);
|
|
851
|
+
}
|
|
847
852
|
args[1]?.(config.afterSignOutUrl || "");
|
|
848
853
|
return Promise.resolve(config.afterSignOutUrl || "");
|
|
849
854
|
}
|
|
@@ -1097,6 +1102,7 @@ var FlowProvider_default = FlowProvider;
|
|
|
1097
1102
|
|
|
1098
1103
|
// src/contexts/FlowMeta/FlowMetaProvider.tsx
|
|
1099
1104
|
import { FlowMetaType, getFlowMetaV2 } from "@asgardeo/browser";
|
|
1105
|
+
import { TranslationBundleConstants } from "@asgardeo/i18n";
|
|
1100
1106
|
import {
|
|
1101
1107
|
useCallback as useCallback3,
|
|
1102
1108
|
useContext as useContext2,
|
|
@@ -1152,6 +1158,7 @@ var FlowMetaProvider = ({
|
|
|
1152
1158
|
const [meta, setMeta] = useState3(null);
|
|
1153
1159
|
const [isLoading, setIsLoading] = useState3(false);
|
|
1154
1160
|
const [error, setError] = useState3(null);
|
|
1161
|
+
const [pendingLanguage, setPendingLanguage] = useState3(null);
|
|
1155
1162
|
const hasFetchedRef = useRef(false);
|
|
1156
1163
|
const fetchFlowMeta = useCallback3(async () => {
|
|
1157
1164
|
if (!enabled) {
|
|
@@ -1169,6 +1176,44 @@ var FlowMetaProvider = ({
|
|
|
1169
1176
|
setIsLoading(false);
|
|
1170
1177
|
}
|
|
1171
1178
|
}, [enabled, baseUrl, applicationId]);
|
|
1179
|
+
const switchLanguage = useCallback3(
|
|
1180
|
+
async (language) => {
|
|
1181
|
+
if (!enabled) return;
|
|
1182
|
+
setIsLoading(true);
|
|
1183
|
+
setError(null);
|
|
1184
|
+
try {
|
|
1185
|
+
const result = await getFlowMetaV2({
|
|
1186
|
+
baseUrl,
|
|
1187
|
+
id: applicationId,
|
|
1188
|
+
language,
|
|
1189
|
+
type: FlowMetaType.App
|
|
1190
|
+
});
|
|
1191
|
+
if (result.i18n?.translations && i18nContext?.injectBundles) {
|
|
1192
|
+
const flatTranslations = {};
|
|
1193
|
+
Object.entries(result.i18n.translations).forEach(([namespace, keys]) => {
|
|
1194
|
+
Object.entries(keys).forEach(([key, value2]) => {
|
|
1195
|
+
flatTranslations[`${namespace}.${key}`] = value2;
|
|
1196
|
+
});
|
|
1197
|
+
});
|
|
1198
|
+
const bundle = { translations: flatTranslations };
|
|
1199
|
+
i18nContext.injectBundles({ [language]: bundle });
|
|
1200
|
+
}
|
|
1201
|
+
setPendingLanguage(language);
|
|
1202
|
+
setMeta(result);
|
|
1203
|
+
} catch (err) {
|
|
1204
|
+
setError(err instanceof Error ? err : new Error(String(err)));
|
|
1205
|
+
} finally {
|
|
1206
|
+
setIsLoading(false);
|
|
1207
|
+
}
|
|
1208
|
+
},
|
|
1209
|
+
[enabled, baseUrl, applicationId, i18nContext]
|
|
1210
|
+
);
|
|
1211
|
+
useEffect2(() => {
|
|
1212
|
+
if (pendingLanguage && i18nContext?.setLanguage) {
|
|
1213
|
+
i18nContext.setLanguage(pendingLanguage);
|
|
1214
|
+
setPendingLanguage(null);
|
|
1215
|
+
}
|
|
1216
|
+
}, [pendingLanguage, i18nContext?.setLanguage]);
|
|
1172
1217
|
useEffect2(() => {
|
|
1173
1218
|
if (!hasFetchedRef.current) {
|
|
1174
1219
|
hasFetchedRef.current = true;
|
|
@@ -1181,7 +1226,7 @@ var FlowMetaProvider = ({
|
|
|
1181
1226
|
if (!meta?.i18n?.translations || !i18nContext?.injectBundles) {
|
|
1182
1227
|
return;
|
|
1183
1228
|
}
|
|
1184
|
-
const metaLanguage = meta.i18n.language ||
|
|
1229
|
+
const metaLanguage = meta.i18n.language || TranslationBundleConstants.FALLBACK_LOCALE;
|
|
1185
1230
|
const flatTranslations = {};
|
|
1186
1231
|
Object.entries(meta.i18n.translations).forEach(([namespace, keys]) => {
|
|
1187
1232
|
Object.entries(keys).forEach(([key, value2]) => {
|
|
@@ -1202,7 +1247,8 @@ var FlowMetaProvider = ({
|
|
|
1202
1247
|
error,
|
|
1203
1248
|
fetchFlowMeta,
|
|
1204
1249
|
isLoading,
|
|
1205
|
-
meta
|
|
1250
|
+
meta,
|
|
1251
|
+
switchLanguage
|
|
1206
1252
|
};
|
|
1207
1253
|
return /* @__PURE__ */ jsx3(FlowMetaContext_default.Provider, { value, children });
|
|
1208
1254
|
};
|
|
@@ -1210,37 +1256,83 @@ var FlowMetaProvider_default = FlowMetaProvider;
|
|
|
1210
1256
|
|
|
1211
1257
|
// src/contexts/I18n/I18nProvider.tsx
|
|
1212
1258
|
import { deepMerge, createPackageComponentLogger } from "@asgardeo/browser";
|
|
1213
|
-
import {
|
|
1259
|
+
import {
|
|
1260
|
+
TranslationBundleConstants as TranslationBundleConstants2,
|
|
1261
|
+
getDefaultI18nBundles,
|
|
1262
|
+
normalizeTranslations
|
|
1263
|
+
} from "@asgardeo/i18n";
|
|
1214
1264
|
import { useCallback as useCallback4, useEffect as useEffect3, useMemo as useMemo2, useState as useState4 } from "react";
|
|
1215
1265
|
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
1216
1266
|
var logger = createPackageComponentLogger(
|
|
1217
1267
|
"@asgardeo/react",
|
|
1218
1268
|
"I18nProvider"
|
|
1219
1269
|
);
|
|
1220
|
-
var
|
|
1270
|
+
var DEFAULT_STORAGE_KEY = "asgardeo-i18n-language";
|
|
1271
|
+
var DEFAULT_URL_PARAM = "lang";
|
|
1221
1272
|
var detectBrowserLanguage = () => {
|
|
1222
1273
|
if (typeof window !== "undefined" && window.navigator) {
|
|
1223
|
-
return window.navigator.language ||
|
|
1274
|
+
return window.navigator.language || TranslationBundleConstants2.FALLBACK_LOCALE;
|
|
1224
1275
|
}
|
|
1225
|
-
return
|
|
1276
|
+
return TranslationBundleConstants2.FALLBACK_LOCALE;
|
|
1226
1277
|
};
|
|
1227
|
-
var
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1278
|
+
var deriveRootDomain = (hostname) => {
|
|
1279
|
+
const parts = hostname.split(".");
|
|
1280
|
+
return parts.length > 1 ? parts.slice(-2).join(".") : hostname;
|
|
1281
|
+
};
|
|
1282
|
+
var getCookie = (name) => {
|
|
1283
|
+
if (typeof document === "undefined") return null;
|
|
1284
|
+
const match = document.cookie.match(
|
|
1285
|
+
new RegExp(`(?:^|; )${name.replace(/([.*+?^${}()|[\]\\])/g, "\\$1")}=([^;]*)`)
|
|
1286
|
+
);
|
|
1287
|
+
return match ? decodeURIComponent(match[1]) : null;
|
|
1288
|
+
};
|
|
1289
|
+
var setCookie = (name, value, domain) => {
|
|
1290
|
+
if (typeof document === "undefined") return;
|
|
1291
|
+
const maxAge = 365 * 24 * 60 * 60;
|
|
1292
|
+
const secure = typeof window !== "undefined" && window.location.protocol === "https:" ? "; Secure" : "";
|
|
1293
|
+
document.cookie = `${encodeURIComponent(name)}=${encodeURIComponent(value)}; Max-Age=${maxAge}; Path=/; Domain=${domain}; SameSite=Lax${secure}`;
|
|
1294
|
+
};
|
|
1295
|
+
var createStorageAdapter = (strategy, key, cookieDomain) => {
|
|
1296
|
+
switch (strategy) {
|
|
1297
|
+
case "cookie":
|
|
1298
|
+
return {
|
|
1299
|
+
read: () => getCookie(key),
|
|
1300
|
+
write: (language) => {
|
|
1301
|
+
const domain = cookieDomain ?? (typeof window !== "undefined" ? deriveRootDomain(window.location.hostname) : "");
|
|
1302
|
+
if (domain) setCookie(key, language, domain);
|
|
1303
|
+
}
|
|
1304
|
+
};
|
|
1305
|
+
case "localStorage":
|
|
1306
|
+
return {
|
|
1307
|
+
read: () => {
|
|
1308
|
+
if (typeof window === "undefined" || !window.localStorage) return null;
|
|
1309
|
+
try {
|
|
1310
|
+
return window.localStorage.getItem(key);
|
|
1311
|
+
} catch {
|
|
1312
|
+
return null;
|
|
1313
|
+
}
|
|
1314
|
+
},
|
|
1315
|
+
write: (language) => {
|
|
1316
|
+
if (typeof window === "undefined" || !window.localStorage) return;
|
|
1317
|
+
try {
|
|
1318
|
+
window.localStorage.setItem(key, language);
|
|
1319
|
+
} catch {
|
|
1320
|
+
logger.warn("Failed to persist language preference to localStorage.");
|
|
1321
|
+
}
|
|
1322
|
+
}
|
|
1323
|
+
};
|
|
1324
|
+
case "none":
|
|
1325
|
+
default:
|
|
1326
|
+
return { read: () => null, write: () => {
|
|
1327
|
+
} };
|
|
1234
1328
|
}
|
|
1235
|
-
return null;
|
|
1236
1329
|
};
|
|
1237
|
-
var
|
|
1238
|
-
if (typeof window
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
}
|
|
1330
|
+
var detectUrlParamLanguage = (paramName) => {
|
|
1331
|
+
if (typeof window === "undefined") return null;
|
|
1332
|
+
try {
|
|
1333
|
+
return new URLSearchParams(window.location.search).get(paramName);
|
|
1334
|
+
} catch {
|
|
1335
|
+
return null;
|
|
1244
1336
|
}
|
|
1245
1337
|
};
|
|
1246
1338
|
var I18nProvider = ({
|
|
@@ -1248,12 +1340,32 @@ var I18nProvider = ({
|
|
|
1248
1340
|
preferences
|
|
1249
1341
|
}) => {
|
|
1250
1342
|
const defaultBundles = getDefaultI18nBundles();
|
|
1343
|
+
const storageStrategy = preferences?.storageStrategy ?? "cookie";
|
|
1344
|
+
const storageKey = preferences?.storageKey ?? DEFAULT_STORAGE_KEY;
|
|
1345
|
+
const urlParamConfig = preferences?.urlParam === void 0 ? DEFAULT_URL_PARAM : preferences.urlParam;
|
|
1346
|
+
const resolvedCookieDomain = useMemo2(() => {
|
|
1347
|
+
if (storageStrategy !== "cookie") return void 0;
|
|
1348
|
+
if (preferences?.cookieDomain) return preferences.cookieDomain;
|
|
1349
|
+
return typeof window !== "undefined" ? deriveRootDomain(window.location.hostname) : void 0;
|
|
1350
|
+
}, [storageStrategy, preferences?.cookieDomain]);
|
|
1351
|
+
const storage = useMemo2(
|
|
1352
|
+
() => createStorageAdapter(storageStrategy, storageKey, resolvedCookieDomain),
|
|
1353
|
+
[storageStrategy, storageKey, resolvedCookieDomain]
|
|
1354
|
+
);
|
|
1251
1355
|
const determineInitialLanguage = () => {
|
|
1252
|
-
|
|
1253
|
-
|
|
1356
|
+
if (preferences?.language) return preferences.language;
|
|
1357
|
+
if (urlParamConfig !== false) {
|
|
1358
|
+
const urlLanguage = detectUrlParamLanguage(urlParamConfig);
|
|
1359
|
+
if (urlLanguage) {
|
|
1360
|
+
storage.write(urlLanguage);
|
|
1361
|
+
return urlLanguage;
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1364
|
+
const storedLanguage = storage.read();
|
|
1365
|
+
if (storedLanguage) return storedLanguage;
|
|
1254
1366
|
const browserLanguage = detectBrowserLanguage();
|
|
1255
|
-
|
|
1256
|
-
return
|
|
1367
|
+
if (browserLanguage) return browserLanguage;
|
|
1368
|
+
return preferences?.fallbackLanguage || TranslationBundleConstants2.FALLBACK_LOCALE;
|
|
1257
1369
|
};
|
|
1258
1370
|
const [currentLanguage, setCurrentLanguage] = useState4(determineInitialLanguage);
|
|
1259
1371
|
const [injectedBundles, setInjectedBundles] = useState4({});
|
|
@@ -1262,13 +1374,16 @@ var I18nProvider = ({
|
|
|
1262
1374
|
setInjectedBundles((prev) => {
|
|
1263
1375
|
const merged = { ...prev };
|
|
1264
1376
|
Object.entries(newBundles).forEach(([key, bundle]) => {
|
|
1377
|
+
const normalizedTranslations = normalizeTranslations(
|
|
1378
|
+
bundle.translations
|
|
1379
|
+
);
|
|
1265
1380
|
if (merged[key]) {
|
|
1266
1381
|
merged[key] = {
|
|
1267
1382
|
...merged[key],
|
|
1268
|
-
translations: deepMerge(merged[key].translations,
|
|
1383
|
+
translations: deepMerge(merged[key].translations, normalizedTranslations)
|
|
1269
1384
|
};
|
|
1270
1385
|
} else {
|
|
1271
|
-
merged[key] = bundle;
|
|
1386
|
+
merged[key] = { ...bundle, translations: normalizedTranslations };
|
|
1272
1387
|
}
|
|
1273
1388
|
});
|
|
1274
1389
|
return merged;
|
|
@@ -1283,34 +1398,40 @@ var I18nProvider = ({
|
|
|
1283
1398
|
merged[languageKey] = bundle;
|
|
1284
1399
|
});
|
|
1285
1400
|
Object.entries(injectedBundles).forEach(([key, bundle]) => {
|
|
1401
|
+
const normalizedTranslations = normalizeTranslations(
|
|
1402
|
+
bundle.translations
|
|
1403
|
+
);
|
|
1286
1404
|
if (merged[key]) {
|
|
1287
1405
|
merged[key] = {
|
|
1288
1406
|
...merged[key],
|
|
1289
|
-
translations: deepMerge(merged[key].translations,
|
|
1407
|
+
translations: deepMerge(merged[key].translations, normalizedTranslations)
|
|
1290
1408
|
};
|
|
1291
1409
|
} else {
|
|
1292
|
-
merged[key] = bundle;
|
|
1410
|
+
merged[key] = { ...bundle, translations: normalizedTranslations };
|
|
1293
1411
|
}
|
|
1294
1412
|
});
|
|
1295
1413
|
if (preferences?.bundles) {
|
|
1296
1414
|
Object.entries(preferences.bundles).forEach(([key, userBundle]) => {
|
|
1415
|
+
const normalizedTranslations = normalizeTranslations(
|
|
1416
|
+
userBundle.translations
|
|
1417
|
+
);
|
|
1297
1418
|
if (merged[key]) {
|
|
1298
1419
|
merged[key] = {
|
|
1299
1420
|
...merged[key],
|
|
1300
1421
|
metadata: userBundle.metadata ? { ...merged[key].metadata, ...userBundle.metadata } : merged[key].metadata,
|
|
1301
|
-
translations: deepMerge(merged[key].translations,
|
|
1422
|
+
translations: deepMerge(merged[key].translations, normalizedTranslations)
|
|
1302
1423
|
};
|
|
1303
1424
|
} else {
|
|
1304
|
-
merged[key] = userBundle;
|
|
1425
|
+
merged[key] = { ...userBundle, translations: normalizedTranslations };
|
|
1305
1426
|
}
|
|
1306
1427
|
});
|
|
1307
1428
|
}
|
|
1308
1429
|
return merged;
|
|
1309
1430
|
}, [defaultBundles, injectedBundles, preferences?.bundles]);
|
|
1310
|
-
const fallbackLanguage = preferences?.fallbackLanguage ||
|
|
1431
|
+
const fallbackLanguage = preferences?.fallbackLanguage || TranslationBundleConstants2.FALLBACK_LOCALE;
|
|
1311
1432
|
useEffect3(() => {
|
|
1312
|
-
|
|
1313
|
-
}, [currentLanguage]);
|
|
1433
|
+
storage.write(currentLanguage);
|
|
1434
|
+
}, [currentLanguage, storage]);
|
|
1314
1435
|
const t = useCallback4(
|
|
1315
1436
|
(key, params) => {
|
|
1316
1437
|
let translation;
|
|
@@ -2387,49 +2508,63 @@ var useTheme_default = useTheme;
|
|
|
2387
2508
|
|
|
2388
2509
|
// src/hooks/useTranslation.ts
|
|
2389
2510
|
import { deepMerge as deepMerge2 } from "@asgardeo/browser";
|
|
2511
|
+
import { normalizeTranslations as normalizeTranslations2 } from "@asgardeo/i18n";
|
|
2390
2512
|
import { useContext as useContext10, useMemo as useMemo8 } from "react";
|
|
2513
|
+
|
|
2514
|
+
// src/contexts/I18n/ComponentPreferencesContext.ts
|
|
2515
|
+
import { createContext as createContext9 } from "react";
|
|
2516
|
+
var ComponentPreferencesContext = createContext9(void 0);
|
|
2517
|
+
var ComponentPreferencesContext_default = ComponentPreferencesContext;
|
|
2518
|
+
|
|
2519
|
+
// src/hooks/useTranslation.ts
|
|
2391
2520
|
var useTranslation = (componentPreferences) => {
|
|
2392
2521
|
const context = useContext10(I18nContext_default);
|
|
2522
|
+
const componentPrefs = useContext10(ComponentPreferencesContext_default);
|
|
2523
|
+
const contextPreferences = componentPrefs?.i18n;
|
|
2393
2524
|
if (!context) {
|
|
2394
2525
|
throw new Error(
|
|
2395
2526
|
"useTranslation must be used within an I18nProvider. Make sure your component is wrapped with AsgardeoProvider which includes I18nProvider."
|
|
2396
2527
|
);
|
|
2397
2528
|
}
|
|
2529
|
+
const effectivePreferences = componentPreferences ?? contextPreferences;
|
|
2398
2530
|
const { t: globalT, currentLanguage, setLanguage, bundles: globalBundles, fallbackLanguage } = context;
|
|
2399
2531
|
const mergedBundles = useMemo8(() => {
|
|
2400
|
-
if (!
|
|
2532
|
+
if (!effectivePreferences?.bundles) {
|
|
2401
2533
|
return globalBundles;
|
|
2402
2534
|
}
|
|
2403
2535
|
const merged = {};
|
|
2404
2536
|
Object.entries(globalBundles).forEach(([key, bundle]) => {
|
|
2405
2537
|
merged[key] = bundle;
|
|
2406
2538
|
});
|
|
2407
|
-
Object.entries(
|
|
2539
|
+
Object.entries(effectivePreferences.bundles).forEach(([key, componentBundle]) => {
|
|
2540
|
+
const normalizedTranslations = normalizeTranslations2(
|
|
2541
|
+
componentBundle.translations
|
|
2542
|
+
);
|
|
2408
2543
|
if (merged[key]) {
|
|
2409
2544
|
merged[key] = {
|
|
2410
2545
|
...merged[key],
|
|
2411
2546
|
metadata: componentBundle.metadata ? { ...merged[key].metadata, ...componentBundle.metadata } : merged[key].metadata,
|
|
2412
|
-
translations: deepMerge2(merged[key].translations,
|
|
2547
|
+
translations: deepMerge2(merged[key].translations, normalizedTranslations)
|
|
2413
2548
|
};
|
|
2414
2549
|
} else {
|
|
2415
|
-
merged[key] = componentBundle;
|
|
2550
|
+
merged[key] = { ...componentBundle, translations: normalizedTranslations };
|
|
2416
2551
|
}
|
|
2417
2552
|
});
|
|
2418
2553
|
return merged;
|
|
2419
|
-
}, [globalBundles,
|
|
2554
|
+
}, [globalBundles, effectivePreferences?.bundles]);
|
|
2420
2555
|
const enhancedT = useMemo8(() => {
|
|
2421
|
-
if (!
|
|
2556
|
+
if (!effectivePreferences?.bundles) {
|
|
2422
2557
|
return globalT;
|
|
2423
2558
|
}
|
|
2424
2559
|
return (key, params) => {
|
|
2425
2560
|
let translation;
|
|
2426
2561
|
const currentBundle = mergedBundles[currentLanguage];
|
|
2427
|
-
if (currentBundle?.translations[key]) {
|
|
2562
|
+
if (currentBundle?.translations?.[key]) {
|
|
2428
2563
|
translation = currentBundle.translations[key];
|
|
2429
2564
|
}
|
|
2430
2565
|
if (!translation && currentLanguage !== fallbackLanguage) {
|
|
2431
2566
|
const fallbackBundle = mergedBundles[fallbackLanguage];
|
|
2432
|
-
if (fallbackBundle?.translations[key]) {
|
|
2567
|
+
if (fallbackBundle?.translations?.[key]) {
|
|
2433
2568
|
translation = fallbackBundle.translations[key];
|
|
2434
2569
|
}
|
|
2435
2570
|
}
|
|
@@ -2444,7 +2579,7 @@ var useTranslation = (componentPreferences) => {
|
|
|
2444
2579
|
}
|
|
2445
2580
|
return translation;
|
|
2446
2581
|
};
|
|
2447
|
-
}, [mergedBundles, currentLanguage, fallbackLanguage, globalT,
|
|
2582
|
+
}, [mergedBundles, currentLanguage, fallbackLanguage, globalT, effectivePreferences?.bundles]);
|
|
2448
2583
|
return {
|
|
2449
2584
|
availableLanguages: Object.keys(mergedBundles),
|
|
2450
2585
|
currentLanguage,
|
|
@@ -5804,7 +5939,7 @@ import { withVendorCSSClassPrefix as withVendorCSSClassPrefix15, bem as bem12 }
|
|
|
5804
5939
|
import { cx as cx15 } from "@emotion/css";
|
|
5805
5940
|
import {
|
|
5806
5941
|
forwardRef as forwardRef8,
|
|
5807
|
-
createContext as
|
|
5942
|
+
createContext as createContext10,
|
|
5808
5943
|
useContext as useContext11
|
|
5809
5944
|
} from "react";
|
|
5810
5945
|
|
|
@@ -5991,7 +6126,7 @@ var getDefaultIcon = (variant) => {
|
|
|
5991
6126
|
return Info_default;
|
|
5992
6127
|
}
|
|
5993
6128
|
};
|
|
5994
|
-
var AlertVariantContext =
|
|
6129
|
+
var AlertVariantContext = createContext10("info");
|
|
5995
6130
|
var useAlertVariant = () => useContext11(AlertVariantContext);
|
|
5996
6131
|
var Alert = forwardRef8(({ variant = "info", showIcon = true, children, className, style, ...rest }, ref) => {
|
|
5997
6132
|
const { theme, colorScheme } = useTheme_default();
|
|
@@ -8298,13 +8433,15 @@ var BaseSignInContent2 = ({
|
|
|
8298
8433
|
] })
|
|
8299
8434
|
] });
|
|
8300
8435
|
};
|
|
8301
|
-
var BaseSignIn2 = ({ showLogo = true, ...rest }) => {
|
|
8436
|
+
var BaseSignIn2 = ({ preferences, showLogo = true, ...rest }) => {
|
|
8302
8437
|
const { theme } = useTheme_default();
|
|
8303
8438
|
const styles = BaseSignIn_styles_default(theme, theme.vars.colors.text.primary);
|
|
8304
|
-
|
|
8439
|
+
const content = /* @__PURE__ */ jsxs28("div", { children: [
|
|
8305
8440
|
showLogo && /* @__PURE__ */ jsx61("div", { className: styles.logoContainer, children: /* @__PURE__ */ jsx61(Logo_default, { size: "large" }) }),
|
|
8306
8441
|
/* @__PURE__ */ jsx61(FlowProvider_default, { children: /* @__PURE__ */ jsx61(BaseSignInContent2, { showLogo, ...rest }) })
|
|
8307
8442
|
] });
|
|
8443
|
+
if (!preferences) return content;
|
|
8444
|
+
return /* @__PURE__ */ jsx61(ComponentPreferencesContext_default.Provider, { value: preferences, children: content });
|
|
8308
8445
|
};
|
|
8309
8446
|
var BaseSignIn_default2 = BaseSignIn2;
|
|
8310
8447
|
|
|
@@ -8610,6 +8747,7 @@ var handlePasskeyAuthentication = async (challengeData) => {
|
|
|
8610
8747
|
import { Fragment as Fragment12, jsx as jsx63 } from "react/jsx-runtime";
|
|
8611
8748
|
var SignIn = ({
|
|
8612
8749
|
className,
|
|
8750
|
+
preferences,
|
|
8613
8751
|
size = "medium",
|
|
8614
8752
|
onSuccess,
|
|
8615
8753
|
onError,
|
|
@@ -8617,7 +8755,7 @@ var SignIn = ({
|
|
|
8617
8755
|
children
|
|
8618
8756
|
}) => {
|
|
8619
8757
|
const { applicationId, afterSignInUrl, signIn, isInitialized, isLoading, meta } = useAsgardeo_default();
|
|
8620
|
-
const { t } = useTranslation_default();
|
|
8758
|
+
const { t } = useTranslation_default(preferences?.i18n);
|
|
8621
8759
|
const [components, setComponents] = useState17([]);
|
|
8622
8760
|
const [currentFlowId, setCurrentFlowId] = useState17(null);
|
|
8623
8761
|
const [isFlowInitialized, setIsFlowInitialized] = useState17(false);
|
|
@@ -8955,7 +9093,8 @@ var SignIn = ({
|
|
|
8955
9093
|
error: flowError,
|
|
8956
9094
|
className,
|
|
8957
9095
|
size,
|
|
8958
|
-
variant
|
|
9096
|
+
variant,
|
|
9097
|
+
preferences
|
|
8959
9098
|
}
|
|
8960
9099
|
);
|
|
8961
9100
|
};
|
|
@@ -8963,7 +9102,7 @@ var SignIn_default = SignIn;
|
|
|
8963
9102
|
|
|
8964
9103
|
// src/components/presentation/auth/SignIn/SignIn.tsx
|
|
8965
9104
|
import { jsx as jsx64 } from "react/jsx-runtime";
|
|
8966
|
-
var SignIn2 = ({ className, size = "medium", children, ...rest }) => {
|
|
9105
|
+
var SignIn2 = ({ className, size = "medium", children, preferences, ...rest }) => {
|
|
8967
9106
|
const { signIn, afterSignInUrl, isInitialized, isLoading, platform } = useAsgardeo_default();
|
|
8968
9107
|
const handleInitialize = async () => await signIn({ response_mode: "direct" });
|
|
8969
9108
|
const handleOnSubmit = async (payload, request) => await signIn(payload, request);
|
|
@@ -8987,6 +9126,7 @@ var SignIn2 = ({ className, size = "medium", children, ...rest }) => {
|
|
|
8987
9126
|
variant: rest.variant,
|
|
8988
9127
|
onSuccess: rest.onSuccess,
|
|
8989
9128
|
onError: rest.onError,
|
|
9129
|
+
preferences,
|
|
8990
9130
|
children
|
|
8991
9131
|
}
|
|
8992
9132
|
);
|
|
@@ -9004,6 +9144,7 @@ var SignIn2 = ({ className, size = "medium", children, ...rest }) => {
|
|
|
9004
9144
|
showLogo: true,
|
|
9005
9145
|
showSubtitle: true,
|
|
9006
9146
|
showTitle: true,
|
|
9147
|
+
preferences,
|
|
9007
9148
|
...rest
|
|
9008
9149
|
}
|
|
9009
9150
|
);
|
|
@@ -10671,13 +10812,15 @@ var BaseSignUpContent2 = ({
|
|
|
10671
10812
|
] })
|
|
10672
10813
|
] });
|
|
10673
10814
|
};
|
|
10674
|
-
var BaseSignUp2 = ({ showLogo = true, ...rest }) => {
|
|
10815
|
+
var BaseSignUp2 = ({ preferences, showLogo = true, ...rest }) => {
|
|
10675
10816
|
const { theme, colorScheme } = useTheme_default();
|
|
10676
10817
|
const styles = BaseSignUp_styles_default(theme, colorScheme);
|
|
10677
|
-
|
|
10818
|
+
const content = /* @__PURE__ */ jsxs30("div", { children: [
|
|
10678
10819
|
showLogo && /* @__PURE__ */ jsx72("div", { className: styles.logoContainer, children: /* @__PURE__ */ jsx72(Logo_default, { size: "large" }) }),
|
|
10679
10820
|
/* @__PURE__ */ jsx72(FlowProvider_default, { children: /* @__PURE__ */ jsx72(BaseSignUpContent2, { showLogo, ...rest }) })
|
|
10680
10821
|
] });
|
|
10822
|
+
if (!preferences) return content;
|
|
10823
|
+
return /* @__PURE__ */ jsx72(ComponentPreferencesContext_default.Provider, { value: preferences, children: content });
|
|
10681
10824
|
};
|
|
10682
10825
|
var BaseSignUp_default2 = BaseSignUp2;
|
|
10683
10826
|
|
|
@@ -10884,13 +11027,14 @@ var BaseInviteUser = ({
|
|
|
10884
11027
|
className = "",
|
|
10885
11028
|
children,
|
|
10886
11029
|
isInitialized = true,
|
|
11030
|
+
preferences,
|
|
10887
11031
|
size = "medium",
|
|
10888
11032
|
variant = "outlined",
|
|
10889
11033
|
showTitle = true,
|
|
10890
11034
|
showSubtitle = true
|
|
10891
11035
|
}) => {
|
|
10892
11036
|
const { meta } = useAsgardeo_default();
|
|
10893
|
-
const { t } = useTranslation_default();
|
|
11037
|
+
const { t } = useTranslation_default(preferences?.i18n);
|
|
10894
11038
|
const { theme } = useTheme_default();
|
|
10895
11039
|
const styles = BaseInviteUser_styles_default(theme, theme.vars.colors.text.primary);
|
|
10896
11040
|
const [isLoading, setIsLoading] = useState20(false);
|
|
@@ -11361,13 +11505,14 @@ var BaseAcceptInvite = ({
|
|
|
11361
11505
|
onGoToSignIn,
|
|
11362
11506
|
className = "",
|
|
11363
11507
|
children,
|
|
11508
|
+
preferences,
|
|
11364
11509
|
size = "medium",
|
|
11365
11510
|
variant = "outlined",
|
|
11366
11511
|
showTitle = true,
|
|
11367
11512
|
showSubtitle = true
|
|
11368
11513
|
}) => {
|
|
11369
11514
|
const { meta } = useAsgardeo_default();
|
|
11370
|
-
const { t } = useTranslation_default();
|
|
11515
|
+
const { t } = useTranslation_default(preferences?.i18n);
|
|
11371
11516
|
const { theme } = useTheme_default();
|
|
11372
11517
|
const styles = BaseAcceptInvite_styles_default(theme, theme.vars.colors.text.primary);
|
|
11373
11518
|
const [isLoading, setIsLoading] = useState21(false);
|
|
@@ -12291,12 +12436,12 @@ var Avatar = ({
|
|
|
12291
12436
|
return (acc << 5) - acc + charCode & 4294967295;
|
|
12292
12437
|
}, 0);
|
|
12293
12438
|
const seed = Math.abs(hash);
|
|
12294
|
-
const generateColor = (
|
|
12295
|
-
const hue1 = (seed +
|
|
12439
|
+
const generateColor = (offset4) => {
|
|
12440
|
+
const hue1 = (seed + offset4) % 360;
|
|
12296
12441
|
const hue2 = (hue1 + 60 + seed % 120) % 360;
|
|
12297
12442
|
const saturation = 70 + seed % 20;
|
|
12298
12443
|
const lightness1 = 55 + seed % 15;
|
|
12299
|
-
const lightness2 = 60 + (seed +
|
|
12444
|
+
const lightness2 = 60 + (seed + offset4) % 15;
|
|
12300
12445
|
return `hsl(${hue1}, ${saturation}%, ${lightness1}%), hsl(${hue2}, ${saturation}%, ${lightness2}%)`;
|
|
12301
12446
|
};
|
|
12302
12447
|
const angle = 45 + seed % 91;
|
|
@@ -12378,7 +12523,7 @@ import {
|
|
|
12378
12523
|
} from "@floating-ui/react";
|
|
12379
12524
|
import {
|
|
12380
12525
|
cloneElement as cloneElement2,
|
|
12381
|
-
createContext as
|
|
12526
|
+
createContext as createContext11,
|
|
12382
12527
|
forwardRef as forwardRef10,
|
|
12383
12528
|
isValidElement,
|
|
12384
12529
|
useContext as useContext12,
|
|
@@ -12581,7 +12726,7 @@ function useDialog({
|
|
|
12581
12726
|
[open, setOpen, interactions, data, labelId, descriptionId]
|
|
12582
12727
|
);
|
|
12583
12728
|
}
|
|
12584
|
-
var DialogContext =
|
|
12729
|
+
var DialogContext = createContext11(null);
|
|
12585
12730
|
var useDialogContext = () => {
|
|
12586
12731
|
const context = useContext12(DialogContext);
|
|
12587
12732
|
if (context == null) {
|
|
@@ -13026,6 +13171,7 @@ var BaseUserProfile = ({
|
|
|
13026
13171
|
open = false,
|
|
13027
13172
|
error = null,
|
|
13028
13173
|
isLoading = false,
|
|
13174
|
+
preferences,
|
|
13029
13175
|
showFields = [],
|
|
13030
13176
|
hideFields = [],
|
|
13031
13177
|
displayNameAttributes = []
|
|
@@ -13033,7 +13179,7 @@ var BaseUserProfile = ({
|
|
|
13033
13179
|
const { theme, colorScheme } = useTheme_default();
|
|
13034
13180
|
const [editedUser, setEditedUser] = useState24(flattenedProfile || profile);
|
|
13035
13181
|
const [editingFields, setEditingFields] = useState24({});
|
|
13036
|
-
const { t } = useTranslation_default();
|
|
13182
|
+
const { t } = useTranslation_default(preferences?.i18n);
|
|
13037
13183
|
const shouldShowField = useCallback17(
|
|
13038
13184
|
(fieldName) => {
|
|
13039
13185
|
if (fieldsToSkip.includes(fieldName)) {
|
|
@@ -13519,10 +13665,10 @@ var updateMeProfile_default = updateMeProfile;
|
|
|
13519
13665
|
|
|
13520
13666
|
// src/components/presentation/UserProfile/UserProfile.tsx
|
|
13521
13667
|
import { jsx as jsx93 } from "react/jsx-runtime";
|
|
13522
|
-
var UserProfile3 = ({ ...rest }) => {
|
|
13668
|
+
var UserProfile3 = ({ preferences, ...rest }) => {
|
|
13523
13669
|
const { baseUrl, instanceId } = useAsgardeo_default();
|
|
13524
13670
|
const { profile, flattenedProfile, schemas, onUpdateProfile } = useUser_default();
|
|
13525
|
-
const { t } = useTranslation_default();
|
|
13671
|
+
const { t } = useTranslation_default(preferences?.i18n);
|
|
13526
13672
|
const [error, setError] = useState25(null);
|
|
13527
13673
|
const handleProfileUpdate = async (payload) => {
|
|
13528
13674
|
setError(null);
|
|
@@ -13545,6 +13691,7 @@ var UserProfile3 = ({ ...rest }) => {
|
|
|
13545
13691
|
schemas,
|
|
13546
13692
|
onUpdate: handleProfileUpdate,
|
|
13547
13693
|
error,
|
|
13694
|
+
preferences,
|
|
13548
13695
|
...rest
|
|
13549
13696
|
}
|
|
13550
13697
|
);
|
|
@@ -14332,13 +14479,14 @@ var BaseOrganizationSwitcher = ({
|
|
|
14332
14479
|
portalId = "asgardeo-organization-switcher",
|
|
14333
14480
|
showTriggerLabel = true,
|
|
14334
14481
|
avatarSize = 24,
|
|
14335
|
-
fallback = null
|
|
14482
|
+
fallback = null,
|
|
14483
|
+
preferences
|
|
14336
14484
|
}) => {
|
|
14337
14485
|
const { theme, colorScheme, direction } = useTheme_default();
|
|
14338
14486
|
const styles = BaseOrganizationSwitcher_styles_default(theme, colorScheme);
|
|
14339
14487
|
const [isOpen, setIsOpen] = useState28(false);
|
|
14340
14488
|
const [hoveredItemIndex, setHoveredItemIndex] = useState28(null);
|
|
14341
|
-
const { t } = useTranslation_default();
|
|
14489
|
+
const { t } = useTranslation_default(preferences?.i18n);
|
|
14342
14490
|
const isRTL = direction === "rtl";
|
|
14343
14491
|
const { refs, floatingStyles, context } = useFloating3({
|
|
14344
14492
|
middleware: [offset2(5), flip2({ fallbackAxisSideDirection: "end" }), shift2({ padding: 5 })],
|
|
@@ -14780,13 +14928,14 @@ var BaseCreateOrganization = ({
|
|
|
14780
14928
|
onSubmit,
|
|
14781
14929
|
onSuccess,
|
|
14782
14930
|
open = false,
|
|
14931
|
+
preferences,
|
|
14783
14932
|
renderAdditionalFields,
|
|
14784
14933
|
style,
|
|
14785
14934
|
title = "Create Organization"
|
|
14786
14935
|
}) => {
|
|
14787
14936
|
const { theme, colorScheme } = useTheme_default();
|
|
14788
14937
|
const styles = BaseCreateOrganization_styles_default(theme, colorScheme);
|
|
14789
|
-
const { t } = useTranslation_default();
|
|
14938
|
+
const { t } = useTranslation_default(preferences?.i18n);
|
|
14790
14939
|
const [formData, setFormData] = useState29({
|
|
14791
14940
|
description: "",
|
|
14792
14941
|
handle: "",
|
|
@@ -15318,11 +15467,12 @@ var BaseOrganizationList = ({
|
|
|
15318
15467
|
renderOrganization,
|
|
15319
15468
|
style,
|
|
15320
15469
|
title = "Organizations",
|
|
15321
|
-
showStatus
|
|
15470
|
+
showStatus,
|
|
15471
|
+
preferences
|
|
15322
15472
|
}) => {
|
|
15323
15473
|
const { theme, colorScheme } = useTheme_default();
|
|
15324
15474
|
const styles = BaseOrganizationList_styles_default(theme, colorScheme);
|
|
15325
|
-
const { t } = useTranslation_default();
|
|
15475
|
+
const { t } = useTranslation_default(preferences?.i18n);
|
|
15326
15476
|
const organizationsWithSwitchAccess = useMemo39(() => {
|
|
15327
15477
|
if (!allOrganizations?.organizations) {
|
|
15328
15478
|
return [];
|
|
@@ -16396,10 +16546,11 @@ var OrganizationProfile = ({
|
|
|
16396
16546
|
popupTitle,
|
|
16397
16547
|
loadingFallback,
|
|
16398
16548
|
errorFallback,
|
|
16549
|
+
preferences,
|
|
16399
16550
|
...rest
|
|
16400
16551
|
}) => {
|
|
16401
16552
|
const { baseUrl, instanceId } = useAsgardeo_default();
|
|
16402
|
-
const { t } = useTranslation_default();
|
|
16553
|
+
const { t } = useTranslation_default(preferences?.i18n);
|
|
16403
16554
|
const [organization, setOrganization] = useState34(null);
|
|
16404
16555
|
const fetchOrganization = async () => {
|
|
16405
16556
|
if (!baseUrl || !organizationId) {
|
|
@@ -16448,6 +16599,7 @@ var OrganizationProfile = ({
|
|
|
16448
16599
|
open,
|
|
16449
16600
|
onOpenChange,
|
|
16450
16601
|
title: popupTitle || t("organization.profile.heading"),
|
|
16602
|
+
preferences,
|
|
16451
16603
|
...rest
|
|
16452
16604
|
}
|
|
16453
16605
|
);
|
|
@@ -16461,6 +16613,7 @@ var OrganizationSwitcher = ({
|
|
|
16461
16613
|
fallback = null,
|
|
16462
16614
|
onOrganizationSwitch: propOnOrganizationSwitch,
|
|
16463
16615
|
organizations: propOrganizations,
|
|
16616
|
+
preferences,
|
|
16464
16617
|
...props
|
|
16465
16618
|
}) => {
|
|
16466
16619
|
const { isSignedIn } = useAsgardeo_default();
|
|
@@ -16474,7 +16627,7 @@ var OrganizationSwitcher = ({
|
|
|
16474
16627
|
const [isCreateOrgOpen, setIsCreateOrgOpen] = useState35(false);
|
|
16475
16628
|
const [isProfileOpen, setIsProfileOpen] = useState35(false);
|
|
16476
16629
|
const [isOrganizationListOpen, setIsOrganizationListOpen] = useState35(false);
|
|
16477
|
-
const { t } = useTranslation_default();
|
|
16630
|
+
const { t } = useTranslation_default(preferences?.i18n);
|
|
16478
16631
|
if (!isSignedIn && fallback) {
|
|
16479
16632
|
return fallback;
|
|
16480
16633
|
}
|
|
@@ -16515,6 +16668,7 @@ var OrganizationSwitcher = ({
|
|
|
16515
16668
|
error,
|
|
16516
16669
|
menuItems,
|
|
16517
16670
|
onManageProfile: handleManageOrganization,
|
|
16671
|
+
preferences,
|
|
16518
16672
|
...props
|
|
16519
16673
|
}
|
|
16520
16674
|
),
|
|
@@ -16563,6 +16717,266 @@ var OrganizationSwitcher = ({
|
|
|
16563
16717
|
};
|
|
16564
16718
|
var OrganizationSwitcher_default = OrganizationSwitcher;
|
|
16565
16719
|
|
|
16720
|
+
// src/components/presentation/LanguageSwitcher/BaseLanguageSwitcher.tsx
|
|
16721
|
+
import { cx as cx36 } from "@emotion/css";
|
|
16722
|
+
import {
|
|
16723
|
+
autoUpdate as autoUpdate3,
|
|
16724
|
+
flip as flip3,
|
|
16725
|
+
FloatingFocusManager as FloatingFocusManager4,
|
|
16726
|
+
FloatingPortal as FloatingPortal4,
|
|
16727
|
+
offset as offset3,
|
|
16728
|
+
shift as shift3,
|
|
16729
|
+
useClick as useClick4,
|
|
16730
|
+
useDismiss as useDismiss4,
|
|
16731
|
+
useFloating as useFloating4,
|
|
16732
|
+
useInteractions as useInteractions4,
|
|
16733
|
+
useRole as useRole4
|
|
16734
|
+
} from "@floating-ui/react";
|
|
16735
|
+
import { useState as useState36 } from "react";
|
|
16736
|
+
|
|
16737
|
+
// src/components/presentation/LanguageSwitcher/BaseLanguageSwitcher.styles.ts
|
|
16738
|
+
import { css as css32 } from "@emotion/css";
|
|
16739
|
+
import { useMemo as useMemo43 } from "react";
|
|
16740
|
+
var useStyles31 = (theme, colorScheme) => useMemo43(() => {
|
|
16741
|
+
const root = css32`
|
|
16742
|
+
display: inline-block;
|
|
16743
|
+
position: relative;
|
|
16744
|
+
font-family: ${theme.vars.typography.fontFamily};
|
|
16745
|
+
`;
|
|
16746
|
+
const trigger = css32`
|
|
16747
|
+
display: inline-flex;
|
|
16748
|
+
align-items: center;
|
|
16749
|
+
gap: calc(${theme.vars.spacing.unit} * 0.5);
|
|
16750
|
+
padding: calc(${theme.vars.spacing.unit} * 0.75) ${theme.vars.spacing.unit};
|
|
16751
|
+
border: 1px solid ${theme.vars.colors.border};
|
|
16752
|
+
background: ${theme.vars.colors.background.surface};
|
|
16753
|
+
cursor: pointer;
|
|
16754
|
+
border-radius: ${theme.vars.borderRadius.medium};
|
|
16755
|
+
min-width: 120px;
|
|
16756
|
+
font-size: 0.875rem;
|
|
16757
|
+
color: ${theme.vars.colors.text.primary};
|
|
16758
|
+
|
|
16759
|
+
&:hover {
|
|
16760
|
+
background-color: ${theme.vars.colors.action?.hover || "rgba(0, 0, 0, 0.04)"};
|
|
16761
|
+
}
|
|
16762
|
+
`;
|
|
16763
|
+
const triggerEmoji = css32`
|
|
16764
|
+
font-size: 1rem;
|
|
16765
|
+
line-height: 1;
|
|
16766
|
+
`;
|
|
16767
|
+
const triggerLabel = css32`
|
|
16768
|
+
flex: 1;
|
|
16769
|
+
overflow: hidden;
|
|
16770
|
+
text-overflow: ellipsis;
|
|
16771
|
+
white-space: nowrap;
|
|
16772
|
+
font-weight: 500;
|
|
16773
|
+
`;
|
|
16774
|
+
const content = css32`
|
|
16775
|
+
min-width: 200px;
|
|
16776
|
+
max-width: 320px;
|
|
16777
|
+
background-color: ${theme.vars.colors.background.surface};
|
|
16778
|
+
border-radius: ${theme.vars.borderRadius.medium};
|
|
16779
|
+
box-shadow: ${theme.vars.shadows.medium};
|
|
16780
|
+
border: 1px solid ${theme.vars.colors.border};
|
|
16781
|
+
outline: none;
|
|
16782
|
+
z-index: 1000;
|
|
16783
|
+
padding: calc(${theme.vars.spacing.unit} * 0.5) 0;
|
|
16784
|
+
`;
|
|
16785
|
+
const option = css32`
|
|
16786
|
+
display: flex;
|
|
16787
|
+
align-items: center;
|
|
16788
|
+
gap: ${theme.vars.spacing.unit};
|
|
16789
|
+
padding: calc(${theme.vars.spacing.unit} * 1) calc(${theme.vars.spacing.unit} * 1.5);
|
|
16790
|
+
width: 100%;
|
|
16791
|
+
border: none;
|
|
16792
|
+
background-color: transparent;
|
|
16793
|
+
cursor: pointer;
|
|
16794
|
+
font-size: 0.875rem;
|
|
16795
|
+
text-align: start;
|
|
16796
|
+
color: ${theme.vars.colors.text.primary};
|
|
16797
|
+
transition: background-color 0.15s ease-in-out;
|
|
16798
|
+
|
|
16799
|
+
&:hover {
|
|
16800
|
+
background-color: ${theme.vars.colors.action?.hover || "rgba(0, 0, 0, 0.04)"};
|
|
16801
|
+
}
|
|
16802
|
+
`;
|
|
16803
|
+
const optionActive = css32`
|
|
16804
|
+
font-weight: 600;
|
|
16805
|
+
color: ${theme.vars.colors.primary?.main || theme.vars.colors.text.primary};
|
|
16806
|
+
`;
|
|
16807
|
+
const optionEmoji = css32`
|
|
16808
|
+
font-size: 1rem;
|
|
16809
|
+
line-height: 1;
|
|
16810
|
+
flex-shrink: 0;
|
|
16811
|
+
`;
|
|
16812
|
+
const optionLabel = css32`
|
|
16813
|
+
flex: 1;
|
|
16814
|
+
overflow: hidden;
|
|
16815
|
+
text-overflow: ellipsis;
|
|
16816
|
+
white-space: nowrap;
|
|
16817
|
+
`;
|
|
16818
|
+
const checkIcon = css32`
|
|
16819
|
+
color: ${theme.vars.colors.primary?.main || theme.vars.colors.text.primary};
|
|
16820
|
+
flex-shrink: 0;
|
|
16821
|
+
margin-inline-start: auto;
|
|
16822
|
+
`;
|
|
16823
|
+
return {
|
|
16824
|
+
checkIcon,
|
|
16825
|
+
content,
|
|
16826
|
+
option,
|
|
16827
|
+
optionActive,
|
|
16828
|
+
optionEmoji,
|
|
16829
|
+
optionLabel,
|
|
16830
|
+
root,
|
|
16831
|
+
trigger,
|
|
16832
|
+
triggerEmoji,
|
|
16833
|
+
triggerLabel
|
|
16834
|
+
};
|
|
16835
|
+
}, [
|
|
16836
|
+
theme.vars.colors.background.surface,
|
|
16837
|
+
theme.vars.colors.text.primary,
|
|
16838
|
+
theme.vars.colors.border,
|
|
16839
|
+
theme.vars.borderRadius.medium,
|
|
16840
|
+
theme.vars.shadows.medium,
|
|
16841
|
+
theme.vars.spacing.unit,
|
|
16842
|
+
theme.vars.colors.action?.hover,
|
|
16843
|
+
theme.vars.typography.fontFamily,
|
|
16844
|
+
theme.vars.colors.primary?.main,
|
|
16845
|
+
colorScheme
|
|
16846
|
+
]);
|
|
16847
|
+
var BaseLanguageSwitcher_styles_default = useStyles31;
|
|
16848
|
+
|
|
16849
|
+
// src/components/presentation/LanguageSwitcher/BaseLanguageSwitcher.tsx
|
|
16850
|
+
import { Fragment as Fragment21, jsx as jsx109, jsxs as jsxs50 } from "react/jsx-runtime";
|
|
16851
|
+
var BaseLanguageSwitcher = ({
|
|
16852
|
+
children,
|
|
16853
|
+
className,
|
|
16854
|
+
currentLanguage,
|
|
16855
|
+
isLoading = false,
|
|
16856
|
+
languages,
|
|
16857
|
+
onLanguageChange
|
|
16858
|
+
}) => {
|
|
16859
|
+
const { theme, colorScheme } = useTheme_default();
|
|
16860
|
+
const styles = BaseLanguageSwitcher_styles_default(theme, colorScheme);
|
|
16861
|
+
const [isOpen, setIsOpen] = useState36(false);
|
|
16862
|
+
const { refs, floatingStyles, context } = useFloating4({
|
|
16863
|
+
middleware: [offset3(4), flip3(), shift3()],
|
|
16864
|
+
onOpenChange: setIsOpen,
|
|
16865
|
+
open: isOpen,
|
|
16866
|
+
whileElementsMounted: autoUpdate3
|
|
16867
|
+
});
|
|
16868
|
+
const click = useClick4(context);
|
|
16869
|
+
const dismiss = useDismiss4(context);
|
|
16870
|
+
const role = useRole4(context, { role: "listbox" });
|
|
16871
|
+
const { getReferenceProps, getFloatingProps } = useInteractions4([click, dismiss, role]);
|
|
16872
|
+
const currentOption = languages.find((l) => l.code === currentLanguage);
|
|
16873
|
+
if (children) {
|
|
16874
|
+
return /* @__PURE__ */ jsx109(Fragment21, { children: children({
|
|
16875
|
+
currentLanguage,
|
|
16876
|
+
isLoading,
|
|
16877
|
+
languages,
|
|
16878
|
+
onLanguageChange
|
|
16879
|
+
}) });
|
|
16880
|
+
}
|
|
16881
|
+
return /* @__PURE__ */ jsxs50("div", { className: cx36(styles["root"], className), children: [
|
|
16882
|
+
/* @__PURE__ */ jsxs50(
|
|
16883
|
+
"button",
|
|
16884
|
+
{
|
|
16885
|
+
ref: refs.setReference,
|
|
16886
|
+
type: "button",
|
|
16887
|
+
disabled: isLoading,
|
|
16888
|
+
"aria-label": "Switch language",
|
|
16889
|
+
...getReferenceProps(),
|
|
16890
|
+
className: styles["trigger"],
|
|
16891
|
+
children: [
|
|
16892
|
+
currentOption && /* @__PURE__ */ jsx109("span", { className: styles["triggerEmoji"], children: currentOption.emoji }),
|
|
16893
|
+
/* @__PURE__ */ jsx109("span", { className: styles["triggerLabel"], children: currentOption?.displayName ?? currentLanguage }),
|
|
16894
|
+
/* @__PURE__ */ jsx109(ChevronDown_default, {})
|
|
16895
|
+
]
|
|
16896
|
+
}
|
|
16897
|
+
),
|
|
16898
|
+
isOpen && /* @__PURE__ */ jsx109(FloatingPortal4, { children: /* @__PURE__ */ jsx109(FloatingFocusManager4, { context, modal: false, children: /* @__PURE__ */ jsx109(
|
|
16899
|
+
"div",
|
|
16900
|
+
{
|
|
16901
|
+
ref: refs.setFloating,
|
|
16902
|
+
style: floatingStyles,
|
|
16903
|
+
...getFloatingProps(),
|
|
16904
|
+
className: styles["content"],
|
|
16905
|
+
role: "listbox",
|
|
16906
|
+
"aria-label": "Select language",
|
|
16907
|
+
children: languages.map((lang) => /* @__PURE__ */ jsxs50(
|
|
16908
|
+
"button",
|
|
16909
|
+
{
|
|
16910
|
+
type: "button",
|
|
16911
|
+
role: "option",
|
|
16912
|
+
"aria-selected": lang.code === currentLanguage,
|
|
16913
|
+
className: cx36(styles["option"], lang.code === currentLanguage && styles["optionActive"]),
|
|
16914
|
+
onClick: () => {
|
|
16915
|
+
onLanguageChange(lang.code);
|
|
16916
|
+
setIsOpen(false);
|
|
16917
|
+
},
|
|
16918
|
+
children: [
|
|
16919
|
+
/* @__PURE__ */ jsx109("span", { className: styles["optionEmoji"], children: lang.emoji }),
|
|
16920
|
+
/* @__PURE__ */ jsx109("span", { className: styles["optionLabel"], children: lang.displayName }),
|
|
16921
|
+
lang.code === currentLanguage && /* @__PURE__ */ jsx109("span", { className: styles["checkIcon"], children: /* @__PURE__ */ jsx109(Check_default, {}) })
|
|
16922
|
+
]
|
|
16923
|
+
},
|
|
16924
|
+
lang.code
|
|
16925
|
+
))
|
|
16926
|
+
}
|
|
16927
|
+
) }) })
|
|
16928
|
+
] });
|
|
16929
|
+
};
|
|
16930
|
+
var BaseLanguageSwitcher_default = BaseLanguageSwitcher;
|
|
16931
|
+
|
|
16932
|
+
// src/components/presentation/LanguageSwitcher/LanguageSwitcher.tsx
|
|
16933
|
+
import { resolveLocaleDisplayName, resolveLocaleEmoji } from "@asgardeo/browser";
|
|
16934
|
+
import { useMemo as useMemo44 } from "react";
|
|
16935
|
+
|
|
16936
|
+
// src/contexts/FlowMeta/useFlowMeta.ts
|
|
16937
|
+
import { useContext as useContext13 } from "react";
|
|
16938
|
+
var useFlowMeta = () => {
|
|
16939
|
+
const context = useContext13(FlowMetaContext_default);
|
|
16940
|
+
if (!context) {
|
|
16941
|
+
throw new Error("useFlowMeta must be used within a FlowMetaProvider");
|
|
16942
|
+
}
|
|
16943
|
+
return context;
|
|
16944
|
+
};
|
|
16945
|
+
var useFlowMeta_default = useFlowMeta;
|
|
16946
|
+
|
|
16947
|
+
// src/components/presentation/LanguageSwitcher/LanguageSwitcher.tsx
|
|
16948
|
+
import { jsx as jsx110 } from "react/jsx-runtime";
|
|
16949
|
+
var LanguageSwitcher = ({ children, className }) => {
|
|
16950
|
+
const { meta, switchLanguage, isLoading } = useFlowMeta_default();
|
|
16951
|
+
const { currentLanguage } = useTranslation_default();
|
|
16952
|
+
const availableLanguageCodes = meta?.i18n?.languages ?? [];
|
|
16953
|
+
const languages = useMemo44(
|
|
16954
|
+
() => availableLanguageCodes.map((code) => ({
|
|
16955
|
+
code,
|
|
16956
|
+
displayName: resolveLocaleDisplayName(code, currentLanguage),
|
|
16957
|
+
emoji: resolveLocaleEmoji(code)
|
|
16958
|
+
})),
|
|
16959
|
+
[availableLanguageCodes, currentLanguage]
|
|
16960
|
+
);
|
|
16961
|
+
const handleLanguageChange = (language) => {
|
|
16962
|
+
if (language !== currentLanguage) {
|
|
16963
|
+
switchLanguage(language);
|
|
16964
|
+
}
|
|
16965
|
+
};
|
|
16966
|
+
return /* @__PURE__ */ jsx110(
|
|
16967
|
+
BaseLanguageSwitcher_default,
|
|
16968
|
+
{
|
|
16969
|
+
currentLanguage,
|
|
16970
|
+
isLoading,
|
|
16971
|
+
languages,
|
|
16972
|
+
onLanguageChange: handleLanguageChange,
|
|
16973
|
+
className,
|
|
16974
|
+
children
|
|
16975
|
+
}
|
|
16976
|
+
);
|
|
16977
|
+
};
|
|
16978
|
+
var LanguageSwitcher_default = LanguageSwitcher;
|
|
16979
|
+
|
|
16566
16980
|
// src/index.ts
|
|
16567
16981
|
import {
|
|
16568
16982
|
AsgardeoRuntimeError as AsgardeoRuntimeError9,
|
|
@@ -16585,6 +16999,7 @@ export {
|
|
|
16585
16999
|
BaseAcceptInvite_default as BaseAcceptInvite,
|
|
16586
17000
|
BaseCreateOrganization,
|
|
16587
17001
|
BaseInviteUser_default as BaseInviteUser,
|
|
17002
|
+
BaseLanguageSwitcher_default as BaseLanguageSwitcher,
|
|
16588
17003
|
BaseOrganization_default as BaseOrganization,
|
|
16589
17004
|
BaseOrganizationList_default as BaseOrganizationList,
|
|
16590
17005
|
BaseOrganizationProfile_default as BaseOrganizationProfile,
|
|
@@ -16632,6 +17047,7 @@ export {
|
|
|
16632
17047
|
InputLabel_default as InputLabel,
|
|
16633
17048
|
InviteUser_default as InviteUser,
|
|
16634
17049
|
KeyValueInput_default as KeyValueInput,
|
|
17050
|
+
LanguageSwitcher_default as LanguageSwitcher,
|
|
16635
17051
|
LinkedInButton_default as LinkedInButton,
|
|
16636
17052
|
Loading_default as Loading,
|
|
16637
17053
|
LogOut_default as LogOut,
|