@krak-stack/registry 0.1.32 → 0.1.34
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/components/ui/code-block.d.ts +8 -6
- package/dist/components/ui/code-block.js +44 -19
- package/dist/components/ui/copy-button.d.ts +9 -6
- package/dist/components/ui/copy-button.js +17 -8
- package/dist/components/ui/data-table.d.ts +9 -5
- package/dist/components/ui/data-table.js +90 -486
- package/dist/components/ui/editing-locale-switcher.d.ts +8 -4
- package/dist/components/ui/editing-locale-switcher.js +26 -448
- package/dist/components/ui/effect-form.d.ts +39 -10
- package/dist/components/ui/effect-form.js +171 -541
- package/dist/components/ui/error-component.d.ts +4 -2
- package/dist/components/ui/error-component.js +28 -450
- package/dist/components/ui/file-picker.d.ts +4 -2
- package/dist/components/ui/file-picker.js +27 -452
- package/dist/components/ui/form.d.ts +123 -71
- package/dist/components/ui/form.js +95 -476
- package/dist/components/ui/google-map.d.ts +3 -2
- package/dist/components/ui/google-map.js +6 -439
- package/dist/components/ui/icon-input.d.ts +50 -1
- package/dist/components/ui/icon-input.js +38 -448
- package/dist/components/ui/krakstack-provider.d.ts +9 -0
- package/dist/components/ui/krakstack-provider.js +28 -0
- package/dist/components/ui/loading.d.ts +7 -1
- package/dist/components/ui/loading.js +6 -438
- package/dist/components/ui/locale-switcher.d.ts +8 -4
- package/dist/components/ui/locale-switcher.js +35 -453
- package/dist/components/ui/pagination.d.ts +5 -3
- package/dist/components/ui/pagination.js +7 -439
- package/dist/components/ui/search-menu.d.ts +4 -2
- package/dist/components/ui/search-menu.js +8 -440
- package/dist/components/ui/theme-switcher.d.ts +5 -3
- package/dist/components/ui/theme-switcher.js +8 -440
- package/dist/components/ui/virtualized-combobox.d.ts +4 -2
- package/dist/components/ui/virtualized-combobox.js +17 -445
- package/dist/lib/docs.d.ts +2 -0
- package/dist/lib/docs.js +92 -481
- package/dist/lib/docs.server.js +4 -20
- package/dist/lib/documentation-toolkit.js +4 -20
- package/dist/lib/markdown/content.d.ts +4 -5
- package/dist/services/agent/client/index.js +81 -463
- package/dist/services/agent/client/widget.d.ts +6 -3
- package/dist/services/notification/client/index.js +11 -440
- package/dist/services/notification/client/notification-menu.d.ts +7 -4
- package/dist/services/notification/public.js +11 -440
- package/package.json +5 -1
- package/dist/paraglide/runtime.d.ts +0 -978
|
@@ -314,444 +314,7 @@ function Input({ className, type, ...props }) {
|
|
|
314
314
|
|
|
315
315
|
// ../../src/components/ui/loading.tsx
|
|
316
316
|
import { Loader2 } from "lucide-react";
|
|
317
|
-
|
|
318
|
-
// ../../src/paraglide/runtime.js
|
|
319
|
-
import"@inlang/paraglide-js/urlpattern-polyfill";
|
|
320
|
-
var baseLocale = "en";
|
|
321
|
-
var locales = ["en", "fr"];
|
|
322
|
-
var cookieName = "locale";
|
|
323
|
-
var cookieMaxAge = 34560000;
|
|
324
|
-
var cookieDomain = "";
|
|
325
|
-
var localStorageKey = "PARAGLIDE_LOCALE";
|
|
326
|
-
var strategy = [
|
|
327
|
-
"url",
|
|
328
|
-
"cookie",
|
|
329
|
-
"preferredLanguage",
|
|
330
|
-
"baseLocale"
|
|
331
|
-
];
|
|
332
|
-
var routeStrategies = [
|
|
333
|
-
{
|
|
334
|
-
match: "/api/:path(.*)?",
|
|
335
|
-
exclude: true
|
|
336
|
-
},
|
|
337
|
-
{
|
|
338
|
-
match: "/sitemap.xml",
|
|
339
|
-
exclude: true
|
|
340
|
-
},
|
|
341
|
-
{
|
|
342
|
-
match: "/llms.txt",
|
|
343
|
-
exclude: true
|
|
344
|
-
}
|
|
345
|
-
];
|
|
346
|
-
var urlPatterns = [
|
|
347
|
-
{
|
|
348
|
-
pattern: "/:path(.*)?",
|
|
349
|
-
localized: [
|
|
350
|
-
[
|
|
351
|
-
"en",
|
|
352
|
-
"/en/:path(.*)?"
|
|
353
|
-
],
|
|
354
|
-
[
|
|
355
|
-
"fr",
|
|
356
|
-
"/fr/:path(.*)?"
|
|
357
|
-
]
|
|
358
|
-
]
|
|
359
|
-
}
|
|
360
|
-
];
|
|
361
|
-
var cachedRouteStrategyUrl;
|
|
362
|
-
var cachedRouteStrategy;
|
|
363
|
-
function findMatchingRouteStrategy(url) {
|
|
364
|
-
if (routeStrategies.length === 0) {
|
|
365
|
-
return;
|
|
366
|
-
}
|
|
367
|
-
const urlString = typeof url === "string" ? url : url.href;
|
|
368
|
-
if (cachedRouteStrategyUrl === urlString) {
|
|
369
|
-
return cachedRouteStrategy;
|
|
370
|
-
}
|
|
371
|
-
const urlObject = new URL(urlString, "http://dummy.com");
|
|
372
|
-
let match;
|
|
373
|
-
for (const routeStrategy of routeStrategies) {
|
|
374
|
-
const pattern = new URLPattern(routeStrategy.match, urlObject.href);
|
|
375
|
-
if (pattern.exec(urlObject.href)) {
|
|
376
|
-
match = routeStrategy;
|
|
377
|
-
break;
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
cachedRouteStrategyUrl = urlString;
|
|
381
|
-
cachedRouteStrategy = match;
|
|
382
|
-
return match;
|
|
383
|
-
}
|
|
384
|
-
function getStrategyForUrl(url) {
|
|
385
|
-
const routeStrategy = findMatchingRouteStrategy(url);
|
|
386
|
-
if (routeStrategy && routeStrategy.exclude !== true && Array.isArray(routeStrategy.strategy)) {
|
|
387
|
-
return routeStrategy.strategy;
|
|
388
|
-
}
|
|
389
|
-
return strategy;
|
|
390
|
-
}
|
|
391
|
-
var serverAsyncLocalStorage = undefined;
|
|
392
|
-
var isServer = import.meta.env?.SSR ?? typeof window === "undefined";
|
|
393
|
-
var experimentalStaticLocale = undefined;
|
|
394
|
-
var TREE_SHAKE_COOKIE_STRATEGY_USED = true;
|
|
395
|
-
var TREE_SHAKE_URL_STRATEGY_USED = true;
|
|
396
|
-
var TREE_SHAKE_GLOBAL_VARIABLE_STRATEGY_USED = false;
|
|
397
|
-
var TREE_SHAKE_PREFERRED_LANGUAGE_STRATEGY_USED = true;
|
|
398
|
-
var TREE_SHAKE_DEFAULT_URL_PATTERN_USED = false;
|
|
399
|
-
var TREE_SHAKE_LOCAL_STORAGE_STRATEGY_USED = false;
|
|
400
|
-
globalThis.__paraglide = globalThis.__paraglide ?? {};
|
|
401
|
-
globalThis.__paraglide.ssr = globalThis.__paraglide.ssr ?? {};
|
|
402
|
-
var _locale;
|
|
403
|
-
var localeInitiallySet = false;
|
|
404
|
-
var getLocale = () => {
|
|
405
|
-
if (experimentalStaticLocale !== undefined) {
|
|
406
|
-
return experimentalStaticLocale;
|
|
407
|
-
}
|
|
408
|
-
if (serverAsyncLocalStorage) {
|
|
409
|
-
const locale = serverAsyncLocalStorage?.getStore()?.locale;
|
|
410
|
-
if (locale) {
|
|
411
|
-
return locale;
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
let strategyToUse = strategy;
|
|
415
|
-
if (!isServer && typeof window !== "undefined" && window.location?.href) {
|
|
416
|
-
strategyToUse = getStrategyForUrl(window.location.href);
|
|
417
|
-
}
|
|
418
|
-
const resolved = resolveLocaleWithStrategies(strategyToUse, typeof window !== "undefined" ? window.location?.href : undefined);
|
|
419
|
-
if (resolved) {
|
|
420
|
-
if (!localeInitiallySet) {
|
|
421
|
-
_locale = resolved;
|
|
422
|
-
localeInitiallySet = true;
|
|
423
|
-
setLocale(resolved, { reload: false });
|
|
424
|
-
}
|
|
425
|
-
return resolved;
|
|
426
|
-
}
|
|
427
|
-
throw new Error("No locale found. Read the docs https://paraglidejs.com/errors#no-locale-found");
|
|
428
|
-
};
|
|
429
|
-
function resolveLocaleWithStrategies(strategyToUse, urlForUrlStrategy) {
|
|
430
|
-
let locale;
|
|
431
|
-
for (const strat of strategyToUse) {
|
|
432
|
-
if (TREE_SHAKE_COOKIE_STRATEGY_USED && strat === "cookie") {
|
|
433
|
-
locale = extractLocaleFromCookie();
|
|
434
|
-
} else if (strat === "baseLocale") {
|
|
435
|
-
locale = baseLocale;
|
|
436
|
-
} else if (TREE_SHAKE_URL_STRATEGY_USED && strat === "url" && !isServer && typeof urlForUrlStrategy === "string") {
|
|
437
|
-
locale = extractLocaleFromUrl(urlForUrlStrategy);
|
|
438
|
-
} else if (TREE_SHAKE_GLOBAL_VARIABLE_STRATEGY_USED && strat === "globalVariable" && _locale !== undefined) {
|
|
439
|
-
locale = _locale;
|
|
440
|
-
} else if (TREE_SHAKE_PREFERRED_LANGUAGE_STRATEGY_USED && strat === "preferredLanguage" && !isServer) {
|
|
441
|
-
locale = extractLocaleFromNavigator();
|
|
442
|
-
} else if (TREE_SHAKE_LOCAL_STORAGE_STRATEGY_USED && strat === "localStorage" && !isServer) {
|
|
443
|
-
locale = localStorage.getItem(localStorageKey) ?? undefined;
|
|
444
|
-
} else if (isCustomStrategy(strat) && customClientStrategies.has(strat)) {
|
|
445
|
-
const handler = customClientStrategies.get(strat);
|
|
446
|
-
if (handler) {
|
|
447
|
-
const result = handler.getLocale();
|
|
448
|
-
if (result instanceof Promise) {
|
|
449
|
-
continue;
|
|
450
|
-
}
|
|
451
|
-
if (result !== undefined) {
|
|
452
|
-
return assertIsLocale(result);
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
const matchedLocale = toLocale(locale);
|
|
457
|
-
if (matchedLocale) {
|
|
458
|
-
return matchedLocale;
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
return;
|
|
462
|
-
}
|
|
463
|
-
var rtlLanguages = new Set([
|
|
464
|
-
"ar",
|
|
465
|
-
"dv",
|
|
466
|
-
"fa",
|
|
467
|
-
"he",
|
|
468
|
-
"ks",
|
|
469
|
-
"ku",
|
|
470
|
-
"ps",
|
|
471
|
-
"sd",
|
|
472
|
-
"ug",
|
|
473
|
-
"ur",
|
|
474
|
-
"yi"
|
|
475
|
-
]);
|
|
476
|
-
var navigateOrReload = (newLocation) => {
|
|
477
|
-
if (newLocation) {
|
|
478
|
-
window.location.href = newLocation;
|
|
479
|
-
} else {
|
|
480
|
-
window.location.reload();
|
|
481
|
-
}
|
|
482
|
-
};
|
|
483
|
-
var setLocale = (newLocale, options) => {
|
|
484
|
-
const optionsWithDefaults = {
|
|
485
|
-
reload: true,
|
|
486
|
-
...options
|
|
487
|
-
};
|
|
488
|
-
let currentLocale;
|
|
489
|
-
try {
|
|
490
|
-
currentLocale = getLocale();
|
|
491
|
-
} catch {}
|
|
492
|
-
const customSetLocalePromises = [];
|
|
493
|
-
let newLocation = undefined;
|
|
494
|
-
let strategyToUse = strategy;
|
|
495
|
-
if (!isServer && typeof window !== "undefined" && window.location?.href) {
|
|
496
|
-
strategyToUse = getStrategyForUrl(window.location.href);
|
|
497
|
-
}
|
|
498
|
-
for (const strat of strategyToUse) {
|
|
499
|
-
if (TREE_SHAKE_GLOBAL_VARIABLE_STRATEGY_USED && strat === "globalVariable") {
|
|
500
|
-
_locale = newLocale;
|
|
501
|
-
} else if (TREE_SHAKE_COOKIE_STRATEGY_USED && strat === "cookie") {
|
|
502
|
-
if (isServer || typeof document === "undefined" || typeof window === "undefined") {
|
|
503
|
-
continue;
|
|
504
|
-
}
|
|
505
|
-
const cookieString = `${cookieName}=${newLocale}; path=/; max-age=${cookieMaxAge}`;
|
|
506
|
-
document.cookie = cookieDomain ? `${cookieString}; domain=${cookieDomain}` : cookieString;
|
|
507
|
-
} else if (strat === "baseLocale") {
|
|
508
|
-
continue;
|
|
509
|
-
} else if (TREE_SHAKE_URL_STRATEGY_USED && strat === "url" && typeof window !== "undefined") {
|
|
510
|
-
newLocation = localizeUrl(window.location.href, {
|
|
511
|
-
locale: newLocale
|
|
512
|
-
}).href;
|
|
513
|
-
} else if (TREE_SHAKE_LOCAL_STORAGE_STRATEGY_USED && strat === "localStorage" && typeof window !== "undefined") {
|
|
514
|
-
localStorage.setItem(localStorageKey, newLocale);
|
|
515
|
-
} else if (isCustomStrategy(strat) && customClientStrategies.has(strat)) {
|
|
516
|
-
const handler = customClientStrategies.get(strat);
|
|
517
|
-
if (handler) {
|
|
518
|
-
let result = handler.setLocale(newLocale);
|
|
519
|
-
if (result instanceof Promise) {
|
|
520
|
-
result = result.catch((error) => {
|
|
521
|
-
throw new Error(`Custom strategy "${strat}" setLocale failed.`, {
|
|
522
|
-
cause: error
|
|
523
|
-
});
|
|
524
|
-
});
|
|
525
|
-
customSetLocalePromises.push(result);
|
|
526
|
-
}
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
}
|
|
530
|
-
const runReload = () => {
|
|
531
|
-
if (!isServer && optionsWithDefaults.reload && window.location && newLocale !== currentLocale) {
|
|
532
|
-
navigateOrReload(newLocation);
|
|
533
|
-
}
|
|
534
|
-
};
|
|
535
|
-
if (customSetLocalePromises.length) {
|
|
536
|
-
return Promise.all(customSetLocalePromises).then(() => {
|
|
537
|
-
runReload();
|
|
538
|
-
});
|
|
539
|
-
}
|
|
540
|
-
runReload();
|
|
541
|
-
return;
|
|
542
|
-
};
|
|
543
|
-
var getUrlOrigin = () => {
|
|
544
|
-
if (serverAsyncLocalStorage) {
|
|
545
|
-
return serverAsyncLocalStorage.getStore()?.origin ?? "http://fallback.com";
|
|
546
|
-
} else if (typeof window !== "undefined") {
|
|
547
|
-
return window.location.origin;
|
|
548
|
-
}
|
|
549
|
-
return "http://fallback.com";
|
|
550
|
-
};
|
|
551
|
-
function toLocale(value) {
|
|
552
|
-
if (typeof value !== "string") {
|
|
553
|
-
return;
|
|
554
|
-
}
|
|
555
|
-
const lowerValue = value.toLowerCase();
|
|
556
|
-
for (const locale of locales) {
|
|
557
|
-
if (locale.toLowerCase() === lowerValue) {
|
|
558
|
-
return locale;
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
return;
|
|
562
|
-
}
|
|
563
|
-
function assertIsLocale(input) {
|
|
564
|
-
const locale = toLocale(input);
|
|
565
|
-
if (locale)
|
|
566
|
-
return locale;
|
|
567
|
-
throw new Error(`Invalid locale: ${input}. Expected one of: ${locales.join(", ")}`);
|
|
568
|
-
}
|
|
569
|
-
function extractLocaleFromCookie() {
|
|
570
|
-
if (typeof document === "undefined" || !document.cookie) {
|
|
571
|
-
return;
|
|
572
|
-
}
|
|
573
|
-
const match = document.cookie.match(new RegExp(`(^| )${cookieName}=([^;]+)`));
|
|
574
|
-
const locale = match?.[2];
|
|
575
|
-
return toLocale(locale);
|
|
576
|
-
}
|
|
577
|
-
function extractLocaleFromNavigator() {
|
|
578
|
-
if (!navigator?.languages?.length) {
|
|
579
|
-
return;
|
|
580
|
-
}
|
|
581
|
-
const languages = navigator.languages.map((lang) => ({
|
|
582
|
-
fullTag: lang,
|
|
583
|
-
baseTag: lang.split("-")[0]
|
|
584
|
-
}));
|
|
585
|
-
for (const lang of languages) {
|
|
586
|
-
const fullLocale = toLocale(lang.fullTag);
|
|
587
|
-
if (fullLocale) {
|
|
588
|
-
return fullLocale;
|
|
589
|
-
}
|
|
590
|
-
const baseLocale2 = toLocale(lang.baseTag);
|
|
591
|
-
if (baseLocale2) {
|
|
592
|
-
return baseLocale2;
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
|
-
return;
|
|
596
|
-
}
|
|
597
|
-
var cachedUrl;
|
|
598
|
-
var cachedLocale;
|
|
599
|
-
function extractLocaleFromUrl(url) {
|
|
600
|
-
const urlString = typeof url === "string" ? url : url.href;
|
|
601
|
-
if (cachedUrl === urlString) {
|
|
602
|
-
return cachedLocale;
|
|
603
|
-
}
|
|
604
|
-
let result;
|
|
605
|
-
if (TREE_SHAKE_DEFAULT_URL_PATTERN_USED) {
|
|
606
|
-
result = defaultUrlPatternExtractLocale(url);
|
|
607
|
-
} else {
|
|
608
|
-
const urlObj = typeof url === "string" ? new URL(url) : url;
|
|
609
|
-
for (const element of urlPatterns) {
|
|
610
|
-
for (const [locale, localizedPattern] of element.localized) {
|
|
611
|
-
const match = new URLPattern(localizedPattern, urlObj.href).exec(urlObj.href);
|
|
612
|
-
if (match) {
|
|
613
|
-
result = locale;
|
|
614
|
-
break;
|
|
615
|
-
}
|
|
616
|
-
}
|
|
617
|
-
if (result)
|
|
618
|
-
break;
|
|
619
|
-
}
|
|
620
|
-
}
|
|
621
|
-
cachedUrl = urlString;
|
|
622
|
-
cachedLocale = result;
|
|
623
|
-
return result;
|
|
624
|
-
}
|
|
625
|
-
function defaultUrlPatternExtractLocale(url) {
|
|
626
|
-
const urlObj = new URL(url, "http://dummy.com");
|
|
627
|
-
const pathSegments = urlObj.pathname.split("/").filter(Boolean);
|
|
628
|
-
return toLocale(pathSegments[0]) || baseLocale;
|
|
629
|
-
}
|
|
630
|
-
function localizeUrl(url, options) {
|
|
631
|
-
const targetLocale = options?.locale ? assertIsLocale(options?.locale) : getLocale();
|
|
632
|
-
if (TREE_SHAKE_DEFAULT_URL_PATTERN_USED) {
|
|
633
|
-
return localizeUrlDefaultPattern(url, targetLocale);
|
|
634
|
-
}
|
|
635
|
-
const urlObj = typeof url === "string" ? new URL(url) : url;
|
|
636
|
-
for (const element of urlPatterns) {
|
|
637
|
-
for (const [, localizedPattern] of element.localized) {
|
|
638
|
-
const match = new URLPattern(localizedPattern, urlObj.href).exec(urlObj.href);
|
|
639
|
-
if (!match) {
|
|
640
|
-
continue;
|
|
641
|
-
}
|
|
642
|
-
const targetPattern = element.localized.find(([locale]) => locale === targetLocale)?.[1];
|
|
643
|
-
if (!targetPattern) {
|
|
644
|
-
continue;
|
|
645
|
-
}
|
|
646
|
-
const localizedUrl = fillPattern(targetPattern, aggregateGroups(match), urlObj.origin);
|
|
647
|
-
return fillMissingUrlParts(localizedUrl, match);
|
|
648
|
-
}
|
|
649
|
-
const unlocalizedMatch = new URLPattern(element.pattern, urlObj.href).exec(urlObj.href);
|
|
650
|
-
if (unlocalizedMatch) {
|
|
651
|
-
const targetPattern = element.localized.find(([locale]) => locale === targetLocale)?.[1];
|
|
652
|
-
if (targetPattern) {
|
|
653
|
-
const localizedUrl = fillPattern(targetPattern, aggregateGroups(unlocalizedMatch), urlObj.origin);
|
|
654
|
-
return fillMissingUrlParts(localizedUrl, unlocalizedMatch);
|
|
655
|
-
}
|
|
656
|
-
}
|
|
657
|
-
}
|
|
658
|
-
return urlObj;
|
|
659
|
-
}
|
|
660
|
-
function localizeUrlDefaultPattern(url, locale) {
|
|
661
|
-
const urlObj = typeof url === "string" ? new URL(url, getUrlOrigin()) : new URL(url);
|
|
662
|
-
const currentLocale = extractLocaleFromUrl(urlObj);
|
|
663
|
-
if (currentLocale === locale) {
|
|
664
|
-
return urlObj;
|
|
665
|
-
}
|
|
666
|
-
const pathSegments = urlObj.pathname.split("/").filter(Boolean);
|
|
667
|
-
if (pathSegments.length > 0 && toLocale(pathSegments[0])) {
|
|
668
|
-
pathSegments.shift();
|
|
669
|
-
}
|
|
670
|
-
if (locale === baseLocale) {
|
|
671
|
-
urlObj.pathname = "/" + pathSegments.join("/");
|
|
672
|
-
} else {
|
|
673
|
-
urlObj.pathname = "/" + locale + "/" + pathSegments.join("/");
|
|
674
|
-
}
|
|
675
|
-
return urlObj;
|
|
676
|
-
}
|
|
677
|
-
function fillMissingUrlParts(url, match) {
|
|
678
|
-
if (match.protocol.groups["0"]) {
|
|
679
|
-
url.protocol = match.protocol.groups["0"] ?? "";
|
|
680
|
-
}
|
|
681
|
-
if (match.hostname.groups["0"]) {
|
|
682
|
-
url.hostname = match.hostname.groups["0"] ?? "";
|
|
683
|
-
}
|
|
684
|
-
if (match.username.groups["0"]) {
|
|
685
|
-
url.username = match.username.groups["0"] ?? "";
|
|
686
|
-
}
|
|
687
|
-
if (match.password.groups["0"]) {
|
|
688
|
-
url.password = match.password.groups["0"] ?? "";
|
|
689
|
-
}
|
|
690
|
-
if (match.port.groups["0"]) {
|
|
691
|
-
url.port = match.port.groups["0"] ?? "";
|
|
692
|
-
}
|
|
693
|
-
if (match.pathname.groups["0"]) {
|
|
694
|
-
url.pathname = match.pathname.groups["0"] ?? "";
|
|
695
|
-
}
|
|
696
|
-
if (match.search.groups["0"]) {
|
|
697
|
-
url.search = match.search.groups["0"] ?? "";
|
|
698
|
-
}
|
|
699
|
-
if (match.hash.groups["0"]) {
|
|
700
|
-
url.hash = match.hash.groups["0"] ?? "";
|
|
701
|
-
}
|
|
702
|
-
return url;
|
|
703
|
-
}
|
|
704
|
-
function fillPattern(pattern, values, origin) {
|
|
705
|
-
let processedPattern = pattern.replace(/(https?:\/\/[^:/]+):(\d+)(\/|$)/g, (_, protocol, port, slash) => {
|
|
706
|
-
return `${protocol}#PORT-${port}#${slash}`;
|
|
707
|
-
});
|
|
708
|
-
let processedGroupDelimiters = processedPattern.replace(/\{([^{}]*)\}([?+*]?)/g, (_, content, modifier) => {
|
|
709
|
-
if (modifier === "?") {
|
|
710
|
-
return content;
|
|
711
|
-
}
|
|
712
|
-
return content;
|
|
713
|
-
});
|
|
714
|
-
let filled = processedGroupDelimiters.replace(/(\/?):([a-zA-Z0-9_]+)(\([^)]*\))?([?+*]?)/g, (_, slash, name, __, modifier) => {
|
|
715
|
-
const value = values[name];
|
|
716
|
-
if (value === null) {
|
|
717
|
-
return "";
|
|
718
|
-
}
|
|
719
|
-
if (modifier === "?") {
|
|
720
|
-
return value !== undefined ? `${slash}${value}` : "";
|
|
721
|
-
}
|
|
722
|
-
if (modifier === "+" || modifier === "*") {
|
|
723
|
-
if (value === undefined && modifier === "+") {
|
|
724
|
-
throw new Error(`Missing value for "${name}" (one or more required)`);
|
|
725
|
-
}
|
|
726
|
-
return value ? `${slash}${value}` : "";
|
|
727
|
-
}
|
|
728
|
-
if (value === undefined) {
|
|
729
|
-
throw new Error(`Missing value for "${name}"`);
|
|
730
|
-
}
|
|
731
|
-
return `${slash}${value}`;
|
|
732
|
-
});
|
|
733
|
-
filled = filled.replace(/#PORT-(\d+)#/g, ":$1");
|
|
734
|
-
return new URL(filled, origin);
|
|
735
|
-
}
|
|
736
|
-
function aggregateGroups(match) {
|
|
737
|
-
return {
|
|
738
|
-
...match.hash.groups,
|
|
739
|
-
...match.hostname.groups,
|
|
740
|
-
...match.password.groups,
|
|
741
|
-
...match.pathname.groups,
|
|
742
|
-
...match.port.groups,
|
|
743
|
-
...match.protocol.groups,
|
|
744
|
-
...match.search.groups,
|
|
745
|
-
...match.username.groups
|
|
746
|
-
};
|
|
747
|
-
}
|
|
748
|
-
var customServerStrategies = new Map;
|
|
749
|
-
var customClientStrategies = new Map;
|
|
750
|
-
function isCustomStrategy(strategy2) {
|
|
751
|
-
return typeof strategy2 === "string" && /^custom-[A-Za-z0-9_-]+$/.test(strategy2);
|
|
752
|
-
}
|
|
753
|
-
|
|
754
|
-
// ../../src/components/ui/loading.tsx
|
|
317
|
+
import { useKrakstackLocale } from "@krak-stack/registry/krakstack-provider";
|
|
755
318
|
import { jsx as jsx6, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
756
319
|
var labels = {
|
|
757
320
|
en: {
|
|
@@ -761,19 +324,22 @@ var labels = {
|
|
|
761
324
|
loading: "Chargement..."
|
|
762
325
|
}
|
|
763
326
|
};
|
|
764
|
-
var loadingLabel = () =>
|
|
327
|
+
var loadingLabel = (locale, messages) => messages?.[locale]?.loading ?? messages?.[locale.split("-")[0] ?? locale]?.loading ?? (locale.startsWith("fr") ? labels.fr.loading : labels.en.loading);
|
|
765
328
|
function Loading({
|
|
766
329
|
className,
|
|
767
330
|
label,
|
|
331
|
+
locale: localeOverride,
|
|
332
|
+
messages,
|
|
768
333
|
variant = "inline"
|
|
769
334
|
}) {
|
|
335
|
+
const locale = useKrakstackLocale(localeOverride);
|
|
770
336
|
return /* @__PURE__ */ jsxs2("div", {
|
|
771
337
|
className: cn("text-muted-foreground flex items-center justify-center gap-2 text-sm", variant === "centered" && "min-h-[50svh] w-full", className),
|
|
772
338
|
children: [
|
|
773
339
|
/* @__PURE__ */ jsx6(Loader2, {
|
|
774
340
|
className: "size-4 animate-spin"
|
|
775
341
|
}),
|
|
776
|
-
label ?? loadingLabel()
|
|
342
|
+
label ?? loadingLabel(locale, messages)
|
|
777
343
|
]
|
|
778
344
|
});
|
|
779
345
|
}
|
|
@@ -1089,6 +655,7 @@ function SelectScrollDownButton({
|
|
|
1089
655
|
}
|
|
1090
656
|
|
|
1091
657
|
// ../../src/components/ui/pagination.tsx
|
|
658
|
+
import { useKrakstackLocale as useKrakstackLocale2 } from "@krak-stack/registry/krakstack-provider";
|
|
1092
659
|
import { jsx as jsx10, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1093
660
|
var messages = {
|
|
1094
661
|
en: {
|
|
@@ -1112,12 +679,14 @@ var messages = {
|
|
|
1112
679
|
goToLastPage: "Aller à la dernière page"
|
|
1113
680
|
}
|
|
1114
681
|
};
|
|
1115
|
-
var paginationMessages = (locale =
|
|
682
|
+
var paginationMessages = (locale = "en", translations) => ({
|
|
1116
683
|
...locale.startsWith("fr") ? messages.fr : messages.en,
|
|
1117
|
-
...
|
|
684
|
+
...translations?.[locale.split("-")[0] ?? locale],
|
|
685
|
+
...translations?.[locale]
|
|
1118
686
|
});
|
|
1119
687
|
function Pagination({
|
|
1120
688
|
compact = false,
|
|
689
|
+
locale: localeOverride,
|
|
1121
690
|
messages: messageOverrides,
|
|
1122
691
|
onPageChange,
|
|
1123
692
|
onPageSizeChange,
|
|
@@ -1129,7 +698,8 @@ function Pagination({
|
|
|
1129
698
|
showResults = true,
|
|
1130
699
|
totalRows
|
|
1131
700
|
}) {
|
|
1132
|
-
const
|
|
701
|
+
const locale = useKrakstackLocale2(localeOverride);
|
|
702
|
+
const labels2 = paginationMessages(locale, messageOverrides);
|
|
1133
703
|
const pageSizeId = useId();
|
|
1134
704
|
const canGoBack = page > 0;
|
|
1135
705
|
const canGoForward = page + 1 < pageCount;
|
|
@@ -1404,6 +974,7 @@ function TooltipContent({
|
|
|
1404
974
|
}
|
|
1405
975
|
|
|
1406
976
|
// ../../src/components/ui/data-table.tsx
|
|
977
|
+
import { useKrakstackLocale as useKrakstackLocale3 } from "@krak-stack/registry/krakstack-provider";
|
|
1407
978
|
import { jsx as jsx14, jsxs as jsxs8, Fragment } from "react/jsx-runtime";
|
|
1408
979
|
var DataTablePersistedUiStateSchema = Schema.Struct({
|
|
1409
980
|
columnVisibility: Schema.Record(Schema.String, Schema.Boolean),
|
|
@@ -1475,9 +1046,10 @@ var messages2 = {
|
|
|
1475
1046
|
selected: "Sélectionnés"
|
|
1476
1047
|
}
|
|
1477
1048
|
};
|
|
1478
|
-
var dataTableMessages = (
|
|
1479
|
-
...
|
|
1480
|
-
...
|
|
1049
|
+
var dataTableMessages = (locale = "en", translations) => ({
|
|
1050
|
+
...locale.startsWith("fr") ? messages2.fr : messages2.en,
|
|
1051
|
+
...translations?.[locale.split("-")[0] ?? locale],
|
|
1052
|
+
...translations?.[locale]
|
|
1481
1053
|
});
|
|
1482
1054
|
var DEFAULT_MIN_WIDTH = 96;
|
|
1483
1055
|
var DEFAULT_WIDTH = 208;
|
|
@@ -1561,8 +1133,8 @@ var resolveDate = (value, type) => Option.getOrUndefined(Option.flatMap(decodeDa
|
|
|
1561
1133
|
calendarOnly
|
|
1562
1134
|
}));
|
|
1563
1135
|
}));
|
|
1564
|
-
var formatDateValue = (date, column) => DateTime.format(date.instant, {
|
|
1565
|
-
locale: column.typeOptions?.locale ??
|
|
1136
|
+
var formatDateValue = (date, column, locale = "en") => DateTime.format(date.instant, {
|
|
1137
|
+
locale: column.typeOptions?.locale ?? locale,
|
|
1566
1138
|
timeZone: date.calendarOnly ? "UTC" : column.typeOptions?.timeZone ?? "UTC",
|
|
1567
1139
|
dateStyle: column.typeOptions?.dateStyle ?? "medium",
|
|
1568
1140
|
timeStyle: column.type === "dateTime" ? column.typeOptions?.timeStyle ?? "short" : undefined,
|
|
@@ -1577,7 +1149,7 @@ var BooleanValue = Schema.Boolean.annotate({
|
|
|
1577
1149
|
});
|
|
1578
1150
|
var decodeNumberValue = Schema.decodeUnknownOption(NumberValue);
|
|
1579
1151
|
var decodeBooleanValue = Schema.decodeUnknownOption(BooleanValue);
|
|
1580
|
-
var formatNumberValue = (value, options = {}) => {
|
|
1152
|
+
var formatNumberValue = (value, options = {}, defaultLocale = "en") => {
|
|
1581
1153
|
const {
|
|
1582
1154
|
locale,
|
|
1583
1155
|
emptyLabel: _emptyLabel,
|
|
@@ -1585,17 +1157,17 @@ var formatNumberValue = (value, options = {}) => {
|
|
|
1585
1157
|
exportFormat: _exportFormat,
|
|
1586
1158
|
...format
|
|
1587
1159
|
} = options;
|
|
1588
|
-
return new Intl.NumberFormat(locale ??
|
|
1160
|
+
return new Intl.NumberFormat(locale ?? defaultLocale, format).format(value);
|
|
1589
1161
|
};
|
|
1590
1162
|
var booleanLabel = (value, options) => value ? options?.trueLabel : options?.falseLabel;
|
|
1591
|
-
var getDataTableExportValue = (row, column) => {
|
|
1163
|
+
var getDataTableExportValue = (row, column, locale = "en") => {
|
|
1592
1164
|
const value = row.values.get(column.id);
|
|
1593
1165
|
const colDef = column.colDef;
|
|
1594
1166
|
if (colDef.type === "number") {
|
|
1595
1167
|
const number = Option.getOrUndefined(decodeNumberValue(value));
|
|
1596
1168
|
if (number === undefined)
|
|
1597
1169
|
return null;
|
|
1598
|
-
return colDef.typeOptions?.exportFormat === "formatted" ? formatNumberValue(number, colDef.typeOptions) : number;
|
|
1170
|
+
return colDef.typeOptions?.exportFormat === "formatted" ? formatNumberValue(number, colDef.typeOptions, locale) : number;
|
|
1599
1171
|
}
|
|
1600
1172
|
if (colDef.type === "boolean") {
|
|
1601
1173
|
const boolean = Option.getOrUndefined(decodeBooleanValue(value));
|
|
@@ -1608,9 +1180,9 @@ var getDataTableExportValue = (row, column) => {
|
|
|
1608
1180
|
const date = resolveDate(value, colDef.type);
|
|
1609
1181
|
if (!date)
|
|
1610
1182
|
return null;
|
|
1611
|
-
return colDef.typeOptions?.exportFormat === "formatted" ? formatDateValue(date, colDef) : dateIsoValue(date);
|
|
1183
|
+
return colDef.typeOptions?.exportFormat === "formatted" ? formatDateValue(date, colDef, locale) : dateIsoValue(date);
|
|
1612
1184
|
};
|
|
1613
|
-
var filterDataTableRows = (rows, columns, globalFilter) => {
|
|
1185
|
+
var filterDataTableRows = (rows, columns, globalFilter, locale = "en") => {
|
|
1614
1186
|
const query = globalFilter.trim().toLocaleLowerCase();
|
|
1615
1187
|
if (!query)
|
|
1616
1188
|
return [...rows];
|
|
@@ -1621,10 +1193,10 @@ var filterDataTableRows = (rows, columns, globalFilter) => {
|
|
|
1621
1193
|
let text = String(value ?? "");
|
|
1622
1194
|
if (colDef.type === "date" || colDef.type === "dateTime") {
|
|
1623
1195
|
const date = resolveDate(value, colDef.type);
|
|
1624
|
-
text = date ? `${formatDateValue(date, colDef)} ${dateIsoValue(date)}` : "";
|
|
1196
|
+
text = date ? `${formatDateValue(date, colDef, locale)} ${dateIsoValue(date)}` : "";
|
|
1625
1197
|
} else if (colDef.type === "number") {
|
|
1626
1198
|
const number = Option.getOrUndefined(decodeNumberValue(value));
|
|
1627
|
-
text = number === undefined ? "" : `${formatNumberValue(number, colDef.typeOptions)} ${number}`;
|
|
1199
|
+
text = number === undefined ? "" : `${formatNumberValue(number, colDef.typeOptions, locale)} ${number}`;
|
|
1628
1200
|
} else if (colDef.type === "boolean") {
|
|
1629
1201
|
const boolean = Option.getOrUndefined(decodeBooleanValue(value));
|
|
1630
1202
|
text = boolean === undefined ? "" : `${booleanLabel(boolean, colDef.typeOptions) ?? ""} ${boolean}`;
|
|
@@ -1744,7 +1316,8 @@ var resolveConfig = (props, onUiStateChange) => {
|
|
|
1744
1316
|
status: props.status ?? {},
|
|
1745
1317
|
features,
|
|
1746
1318
|
onRowClicked: props.onRowClicked,
|
|
1747
|
-
labels: dataTableMessages(props.messages)
|
|
1319
|
+
labels: dataTableMessages(props.locale, props.messages),
|
|
1320
|
+
locale: props.locale ?? "en"
|
|
1748
1321
|
};
|
|
1749
1322
|
};
|
|
1750
1323
|
var queryFromState = (state) => ({
|
|
@@ -1776,7 +1349,7 @@ var buildDataTableModel = (store) => {
|
|
|
1776
1349
|
const rows = buildDataTableRows(store.rowData, columns, rowId);
|
|
1777
1350
|
const pagination = store.config.features.pagination ?? { mode: "client" };
|
|
1778
1351
|
const server = pagination !== false && pagination.mode === "server";
|
|
1779
|
-
const filteredRows = server ? [...rows] : filterDataTableRows(rows, columns, store.state.globalFilter ?? "");
|
|
1352
|
+
const filteredRows = server ? [...rows] : filterDataTableRows(rows, columns, store.state.globalFilter ?? "", store.config.locale);
|
|
1780
1353
|
const sortedRows = server ? filteredRows : sortDataTableRows(filteredRows, columns, store.state.sort ?? []);
|
|
1781
1354
|
const pageRows = pagination === false || server ? sortedRows : paginateDataTableRows(sortedRows, store.state);
|
|
1782
1355
|
const totalRows = server ? pagination.rowCount : sortedRows.length;
|
|
@@ -1854,7 +1427,7 @@ var canMoveRowsToGroups = (store) => getActiveGrouping(store).some((field) => !!
|
|
|
1854
1427
|
var canDragRows = (store) => getActiveGrouping(store).length ? canMoveRowsToGroups(store) : canReorderRows(store);
|
|
1855
1428
|
var hasRowActionMenu = (store) => !!store.config.features.rowActions || canReorderRows(store);
|
|
1856
1429
|
var getSelectedRows = (store, model) => model.rows.filter((row) => store.state.rowSelection[row.id]).map((row) => row.data);
|
|
1857
|
-
var renderCell = (row, column) => {
|
|
1430
|
+
var renderCell = (row, column, locale = "en", labels2 = dataTableMessages(locale)) => {
|
|
1858
1431
|
const value = row.values.get(column.id);
|
|
1859
1432
|
const params = {
|
|
1860
1433
|
data: row.data,
|
|
@@ -1875,7 +1448,7 @@ var renderCell = (row, column) => {
|
|
|
1875
1448
|
const number = Option.getOrUndefined(decodeNumberValue(value));
|
|
1876
1449
|
return /* @__PURE__ */ jsx14("span", {
|
|
1877
1450
|
className: "block text-left tabular-nums",
|
|
1878
|
-
children: number === undefined ? colDef.typeOptions?.emptyLabel ?? "—" : formatNumberValue(number, colDef.typeOptions)
|
|
1451
|
+
children: number === undefined ? colDef.typeOptions?.emptyLabel ?? "—" : formatNumberValue(number, colDef.typeOptions, locale)
|
|
1879
1452
|
});
|
|
1880
1453
|
}
|
|
1881
1454
|
if (colDef.type === "boolean") {
|
|
@@ -1906,7 +1479,7 @@ var renderCell = (row, column) => {
|
|
|
1906
1479
|
const date = resolveDate(value, colDef.type);
|
|
1907
1480
|
return date ? /* @__PURE__ */ jsx14("time", {
|
|
1908
1481
|
dateTime: dateIsoValue(date),
|
|
1909
|
-
children: formatDateValue(date, colDef)
|
|
1482
|
+
children: formatDateValue(date, colDef, locale)
|
|
1910
1483
|
}) : colDef.typeOptions?.emptyLabel ?? "—";
|
|
1911
1484
|
}
|
|
1912
1485
|
if (colDef.type === "list") {
|
|
@@ -1922,6 +1495,8 @@ var renderCell = (row, column) => {
|
|
|
1922
1495
|
...config,
|
|
1923
1496
|
itemActions,
|
|
1924
1497
|
items: config.getItems(row.data),
|
|
1498
|
+
locale,
|
|
1499
|
+
messages: { [locale]: labels2 },
|
|
1925
1500
|
options: config.getOptions(row.data),
|
|
1926
1501
|
totalCount: config.getTotalCount?.(row.data),
|
|
1927
1502
|
onAdd: config.onAdd ? (value2) => config.onAdd?.({ value: value2, row: row.data }) : undefined,
|
|
@@ -1932,6 +1507,8 @@ var renderCell = (row, column) => {
|
|
|
1932
1507
|
...config,
|
|
1933
1508
|
itemActions,
|
|
1934
1509
|
items: config.getItems(row.data),
|
|
1510
|
+
locale,
|
|
1511
|
+
messages: { [locale]: labels2 },
|
|
1935
1512
|
totalCount: config.getTotalCount?.(row.data)
|
|
1936
1513
|
});
|
|
1937
1514
|
}
|
|
@@ -2227,7 +1804,7 @@ var DataTableToolbar = ({
|
|
|
2227
1804
|
}),
|
|
2228
1805
|
/* @__PURE__ */ jsx14(MenubarSeparator, {}),
|
|
2229
1806
|
/* @__PURE__ */ jsxs8(MenubarItem, {
|
|
2230
|
-
onClick: () => downloadCsv(model.visibleColumns.map(columnLabel), exportRows.map((row) => model.visibleColumns.map((column) => String(getDataTableExportValue(row, column) ?? ""))), features.export ? features.export.baseName : "table"),
|
|
1807
|
+
onClick: () => downloadCsv(model.visibleColumns.map(columnLabel), exportRows.map((row) => model.visibleColumns.map((column) => String(getDataTableExportValue(row, column, store.config.locale) ?? ""))), features.export ? features.export.baseName : "table"),
|
|
2231
1808
|
children: [
|
|
2232
1809
|
/* @__PURE__ */ jsx14(FileText, {}),
|
|
2233
1810
|
labels2.exportCsv
|
|
@@ -2236,7 +1813,7 @@ var DataTableToolbar = ({
|
|
|
2236
1813
|
/* @__PURE__ */ jsxs8(MenubarItem, {
|
|
2237
1814
|
onClick: () => downloadJson(exportRows.map((row) => Object.fromEntries(model.visibleColumns.map((column) => [
|
|
2238
1815
|
column.id,
|
|
2239
|
-
getDataTableExportValue(row, column)
|
|
1816
|
+
getDataTableExportValue(row, column, store.config.locale)
|
|
2240
1817
|
]))), features.export ? features.export.baseName : "table"),
|
|
2241
1818
|
children: [
|
|
2242
1819
|
/* @__PURE__ */ jsx14(FileJson, {}),
|
|
@@ -2671,7 +2248,7 @@ var TableDataRow = ({
|
|
|
2671
2248
|
style: { width: column.width },
|
|
2672
2249
|
children: /* @__PURE__ */ jsx14("div", {
|
|
2673
2250
|
className: cn("min-w-0", column.colDef.truncate && "truncate"),
|
|
2674
|
-
children: renderCell(row, column)
|
|
2251
|
+
children: renderCell(row, column, store.config.locale, store.config.labels)
|
|
2675
2252
|
})
|
|
2676
2253
|
}, column.id)),
|
|
2677
2254
|
hasRowActionMenu(store) ? /* @__PURE__ */ jsx14(TableCell, {
|
|
@@ -3050,17 +2627,17 @@ var GalleryCard = ({
|
|
|
3050
2627
|
variant: "secondary",
|
|
3051
2628
|
children: [
|
|
3052
2629
|
gallery.tagIcon,
|
|
3053
|
-
renderCell(row, tag)
|
|
2630
|
+
renderCell(row, tag, store.config.locale, store.config.labels)
|
|
3054
2631
|
]
|
|
3055
2632
|
}) : null
|
|
3056
2633
|
]
|
|
3057
2634
|
}),
|
|
3058
2635
|
/* @__PURE__ */ jsx14(CardTitle, {
|
|
3059
|
-
children: name ? renderCell(row, name) : row.id
|
|
2636
|
+
children: name ? renderCell(row, name, store.config.locale, store.config.labels) : row.id
|
|
3060
2637
|
}),
|
|
3061
2638
|
description ? /* @__PURE__ */ jsx14("div", {
|
|
3062
2639
|
className: "text-muted-foreground line-clamp-3 text-sm",
|
|
3063
|
-
children: renderCell(row, description)
|
|
2640
|
+
children: renderCell(row, description, store.config.locale, store.config.labels)
|
|
3064
2641
|
}) : null,
|
|
3065
2642
|
hasRowActionMenu(store) ? /* @__PURE__ */ jsx14("div", {
|
|
3066
2643
|
className: "absolute top-4 right-4",
|
|
@@ -3201,7 +2778,8 @@ var DataTablePagination = ({
|
|
|
3201
2778
|
return /* @__PURE__ */ jsx14("div", {
|
|
3202
2779
|
className: "pt-4",
|
|
3203
2780
|
children: /* @__PURE__ */ jsx14(Pagination, {
|
|
3204
|
-
|
|
2781
|
+
locale: store.config.locale,
|
|
2782
|
+
messages: { [store.config.locale]: store.config.labels },
|
|
3205
2783
|
onPageChange: (page) => setPagination({ page, pageSize: store.state.pageSize }),
|
|
3206
2784
|
onPageSizeChange: (pageSize) => setPagination({ page: 0, pageSize }),
|
|
3207
2785
|
page: Math.min(store.state.page, model.pageCount - 1),
|
|
@@ -3260,7 +2838,8 @@ var HydratedDataTable = ({
|
|
|
3260
2838
|
status: props.status ?? {},
|
|
3261
2839
|
features,
|
|
3262
2840
|
onRowClicked: props.onRowClicked,
|
|
3263
|
-
labels: dataTableMessages(props.messages)
|
|
2841
|
+
labels: dataTableMessages(props.locale, props.messages),
|
|
2842
|
+
locale: props.locale ?? "en"
|
|
3264
2843
|
};
|
|
3265
2844
|
const state = { ...store.state, ...uiState, ...props.state };
|
|
3266
2845
|
const modelChanged = store.rowData !== props.rowData || store.columnDefs !== props.columnDefs || !sameDataTableState(store.state, state) || store.config.getRowId !== config.getRowId || store.config.features.pagination !== config.features.pagination;
|
|
@@ -3278,6 +2857,7 @@ var HydratedDataTable = ({
|
|
|
3278
2857
|
props.columnDefs,
|
|
3279
2858
|
props.features,
|
|
3280
2859
|
props.getRowId,
|
|
2860
|
+
props.locale,
|
|
3281
2861
|
props.messages,
|
|
3282
2862
|
props.onRowClicked,
|
|
3283
2863
|
props.onStateChange,
|
|
@@ -3305,6 +2885,7 @@ var HydratedDataTable = ({
|
|
|
3305
2885
|
});
|
|
3306
2886
|
};
|
|
3307
2887
|
var DataTable = (props) => {
|
|
2888
|
+
const locale = useKrakstackLocale3(props.locale);
|
|
3308
2889
|
const persistedUiAtomRef = useRef(null);
|
|
3309
2890
|
if (!persistedUiAtomRef.current) {
|
|
3310
2891
|
const pathname = globalThis.window?.location.pathname ?? "/";
|
|
@@ -3328,6 +2909,7 @@ var DataTable = (props) => {
|
|
|
3328
2909
|
}
|
|
3329
2910
|
return /* @__PURE__ */ jsx14(HydratedDataTable, {
|
|
3330
2911
|
...props,
|
|
2912
|
+
locale,
|
|
3331
2913
|
persistedUiState: persistedUiResult.value,
|
|
3332
2914
|
setPersistedUiState
|
|
3333
2915
|
});
|
|
@@ -3365,20 +2947,23 @@ var DataTableContent = ({
|
|
|
3365
2947
|
});
|
|
3366
2948
|
};
|
|
3367
2949
|
var DataTableListCell = (props) => {
|
|
3368
|
-
|
|
2950
|
+
const locale = useKrakstackLocale3(props.locale);
|
|
2951
|
+
const resolvedProps = { ...props, locale };
|
|
2952
|
+
if (resolvedProps.options && (resolvedProps.onAdd || resolvedProps.onRemove)) {
|
|
3369
2953
|
return /* @__PURE__ */ jsx14(EditableDataTableListCell, {
|
|
3370
|
-
...
|
|
2954
|
+
...resolvedProps
|
|
3371
2955
|
});
|
|
3372
2956
|
}
|
|
3373
|
-
const { actionsLabel, itemActions, ...summaryProps } =
|
|
3374
|
-
const
|
|
3375
|
-
const
|
|
2957
|
+
const { actionsLabel, itemActions, ...summaryProps } = resolvedProps;
|
|
2958
|
+
const labels2 = dataTableMessages(locale, resolvedProps.messages);
|
|
2959
|
+
const totalCount = resolvedProps.totalCount ?? resolvedProps.items.length;
|
|
2960
|
+
const overflow = totalCount > Math.min(resolvedProps.items.length, resolvedProps.visibleCount ?? 3);
|
|
3376
2961
|
if (!itemActions?.length && !overflow) {
|
|
3377
2962
|
return /* @__PURE__ */ jsx14(DataTableListSummary, {
|
|
3378
2963
|
...summaryProps
|
|
3379
2964
|
});
|
|
3380
2965
|
}
|
|
3381
|
-
const menuLabel = actionsLabel ?? (itemActions?.length ?
|
|
2966
|
+
const menuLabel = actionsLabel ?? (itemActions?.length ? labels2.actions : labels2.listDetails);
|
|
3382
2967
|
return /* @__PURE__ */ jsx14("div", {
|
|
3383
2968
|
className: "grid min-h-16 in-[[data-slot=table-cell]]:absolute in-[[data-slot=table-cell]]:inset-0 in-[[data-slot=table-cell]]:min-h-0",
|
|
3384
2969
|
"data-slot": "data-table-list-cell",
|
|
@@ -3386,10 +2971,12 @@ var DataTableListCell = (props) => {
|
|
|
3386
2971
|
onPointerDown: (event) => event.stopPropagation(),
|
|
3387
2972
|
children: /* @__PURE__ */ jsx14(DataTableListMenu, {
|
|
3388
2973
|
actions: itemActions ?? [],
|
|
3389
|
-
display:
|
|
2974
|
+
display: resolvedProps.display,
|
|
3390
2975
|
force: overflow,
|
|
3391
2976
|
label: menuLabel,
|
|
3392
|
-
items:
|
|
2977
|
+
items: resolvedProps.items,
|
|
2978
|
+
locale,
|
|
2979
|
+
messages: resolvedProps.messages,
|
|
3393
2980
|
trigger: /* @__PURE__ */ jsxs8(Button, {
|
|
3394
2981
|
"aria-label": menuLabel,
|
|
3395
2982
|
className: "h-full w-full min-w-0 justify-between rounded-none px-2 focus-visible:ring-inset",
|
|
@@ -3416,7 +3003,9 @@ var EditableDataTableListCell = ({
|
|
|
3416
3003
|
visibleCount,
|
|
3417
3004
|
totalCount,
|
|
3418
3005
|
actionsLabel,
|
|
3419
|
-
itemActions
|
|
3006
|
+
itemActions,
|
|
3007
|
+
locale = "en",
|
|
3008
|
+
messages: messages3
|
|
3420
3009
|
}) => {
|
|
3421
3010
|
const [selected, setSelected] = useState([...items]);
|
|
3422
3011
|
useLayoutEffect(() => setSelected([...items]), [items]);
|
|
@@ -3424,7 +3013,7 @@ var EditableDataTableListCell = ({
|
|
|
3424
3013
|
const available = options.filter((item) => !selectedValues.has(item.value));
|
|
3425
3014
|
const canAdd = !!onAdd && available.length > 0;
|
|
3426
3015
|
const selectedTotal = totalCount === undefined ? selected.length : totalCount + selected.length - items.length;
|
|
3427
|
-
const labels2 = dataTableMessages();
|
|
3016
|
+
const labels2 = dataTableMessages(locale, messages3);
|
|
3428
3017
|
const actions = [
|
|
3429
3018
|
...itemActions ?? [],
|
|
3430
3019
|
...onRemove ? [
|
|
@@ -3458,6 +3047,8 @@ var EditableDataTableListCell = ({
|
|
|
3458
3047
|
force: true,
|
|
3459
3048
|
items: selected,
|
|
3460
3049
|
label: actionsLabel ?? manageLabel,
|
|
3050
|
+
locale,
|
|
3051
|
+
messages: messages3,
|
|
3461
3052
|
onAdd: canAdd ? (item) => {
|
|
3462
3053
|
onAdd(item.value);
|
|
3463
3054
|
setSelected((current) => [...current, item]);
|
|
@@ -3492,6 +3083,8 @@ var DataTableListMenu = ({
|
|
|
3492
3083
|
force = false,
|
|
3493
3084
|
items,
|
|
3494
3085
|
label,
|
|
3086
|
+
locale = "en",
|
|
3087
|
+
messages: messages3,
|
|
3495
3088
|
onAdd,
|
|
3496
3089
|
trigger
|
|
3497
3090
|
}) => {
|
|
@@ -3503,7 +3096,8 @@ var DataTableListMenu = ({
|
|
|
3503
3096
|
const hasActions = entries.some(({ visibleActions }) => visibleActions.length);
|
|
3504
3097
|
if (!force && !hasActions && !onAdd)
|
|
3505
3098
|
return null;
|
|
3506
|
-
const
|
|
3099
|
+
const labels2 = dataTableMessages(locale, messages3);
|
|
3100
|
+
const resolvedLabel = label ?? (hasActions ? labels2.actions : labels2.listDetails);
|
|
3507
3101
|
return /* @__PURE__ */ jsxs8(DropdownMenu, {
|
|
3508
3102
|
children: [
|
|
3509
3103
|
/* @__PURE__ */ jsx14(DropdownMenuTrigger, {
|
|
@@ -3565,10 +3159,12 @@ var DataTableListMenu = ({
|
|
|
3565
3159
|
entries.length ? /* @__PURE__ */ jsx14(DropdownMenuSeparator, {}) : null,
|
|
3566
3160
|
/* @__PURE__ */ jsx14(DataTableListAddMenu, {
|
|
3567
3161
|
emptyLabel: addEmptyLabel,
|
|
3568
|
-
label: addLabel ??
|
|
3162
|
+
label: addLabel ?? labels2.addItem,
|
|
3163
|
+
locale,
|
|
3164
|
+
messages: messages3,
|
|
3569
3165
|
onAdd,
|
|
3570
3166
|
options: addOptions,
|
|
3571
|
-
searchLabel: addSearchLabel ??
|
|
3167
|
+
searchLabel: addSearchLabel ?? labels2.filter,
|
|
3572
3168
|
display
|
|
3573
3169
|
})
|
|
3574
3170
|
]
|
|
@@ -3583,6 +3179,8 @@ var DataTableListAddMenu = ({
|
|
|
3583
3179
|
emptyLabel,
|
|
3584
3180
|
display,
|
|
3585
3181
|
label,
|
|
3182
|
+
locale = "en",
|
|
3183
|
+
messages: messages3,
|
|
3586
3184
|
onAdd,
|
|
3587
3185
|
options,
|
|
3588
3186
|
searchLabel
|
|
@@ -3591,7 +3189,7 @@ var DataTableListAddMenu = ({
|
|
|
3591
3189
|
const focusSearch = useCallback((input) => {
|
|
3592
3190
|
input?.focus({ preventScroll: true });
|
|
3593
3191
|
}, []);
|
|
3594
|
-
const
|
|
3192
|
+
const labels2 = dataTableMessages(locale, messages3);
|
|
3595
3193
|
const normalizedSearch = search.trim().toLocaleLowerCase(locale);
|
|
3596
3194
|
const filtered = normalizedSearch ? options.filter((item) => item.label.toLocaleLowerCase(locale).includes(normalizedSearch)) : options;
|
|
3597
3195
|
return /* @__PURE__ */ jsxs8(DropdownMenuSub, {
|
|
@@ -3623,7 +3221,7 @@ var DataTableListAddMenu = ({
|
|
|
3623
3221
|
if (event.key !== "Escape")
|
|
3624
3222
|
event.stopPropagation();
|
|
3625
3223
|
},
|
|
3626
|
-
placeholder:
|
|
3224
|
+
placeholder: labels2.filter,
|
|
3627
3225
|
ref: focusSearch,
|
|
3628
3226
|
value: search
|
|
3629
3227
|
})
|
|
@@ -3649,6 +3247,8 @@ var DataTableListAddMenu = ({
|
|
|
3649
3247
|
var DataTableListSummaryContent = ({
|
|
3650
3248
|
emptyLabel,
|
|
3651
3249
|
items,
|
|
3250
|
+
locale,
|
|
3251
|
+
messages: messages3,
|
|
3652
3252
|
totalCount = items.length,
|
|
3653
3253
|
display = "list",
|
|
3654
3254
|
showMenu,
|
|
@@ -3682,7 +3282,9 @@ var DataTableListSummaryContent = ({
|
|
|
3682
3282
|
actions: [],
|
|
3683
3283
|
display,
|
|
3684
3284
|
force: true,
|
|
3685
|
-
items: normalized
|
|
3285
|
+
items: normalized,
|
|
3286
|
+
locale,
|
|
3287
|
+
messages: messages3
|
|
3686
3288
|
}) : null
|
|
3687
3289
|
]
|
|
3688
3290
|
})
|
|
@@ -3702,7 +3304,9 @@ var DataTableListSummaryContent = ({
|
|
|
3702
3304
|
actions: [],
|
|
3703
3305
|
display,
|
|
3704
3306
|
force: true,
|
|
3705
|
-
items: normalized
|
|
3307
|
+
items: normalized,
|
|
3308
|
+
locale,
|
|
3309
|
+
messages: messages3
|
|
3706
3310
|
}) : null
|
|
3707
3311
|
]
|
|
3708
3312
|
});
|