@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.
Files changed (46) hide show
  1. package/dist/components/ui/code-block.d.ts +8 -6
  2. package/dist/components/ui/code-block.js +44 -19
  3. package/dist/components/ui/copy-button.d.ts +9 -6
  4. package/dist/components/ui/copy-button.js +17 -8
  5. package/dist/components/ui/data-table.d.ts +9 -5
  6. package/dist/components/ui/data-table.js +90 -486
  7. package/dist/components/ui/editing-locale-switcher.d.ts +8 -4
  8. package/dist/components/ui/editing-locale-switcher.js +26 -448
  9. package/dist/components/ui/effect-form.d.ts +39 -10
  10. package/dist/components/ui/effect-form.js +171 -541
  11. package/dist/components/ui/error-component.d.ts +4 -2
  12. package/dist/components/ui/error-component.js +28 -450
  13. package/dist/components/ui/file-picker.d.ts +4 -2
  14. package/dist/components/ui/file-picker.js +27 -452
  15. package/dist/components/ui/form.d.ts +123 -71
  16. package/dist/components/ui/form.js +95 -476
  17. package/dist/components/ui/google-map.d.ts +3 -2
  18. package/dist/components/ui/google-map.js +6 -439
  19. package/dist/components/ui/icon-input.d.ts +50 -1
  20. package/dist/components/ui/icon-input.js +38 -448
  21. package/dist/components/ui/krakstack-provider.d.ts +9 -0
  22. package/dist/components/ui/krakstack-provider.js +28 -0
  23. package/dist/components/ui/loading.d.ts +7 -1
  24. package/dist/components/ui/loading.js +6 -438
  25. package/dist/components/ui/locale-switcher.d.ts +8 -4
  26. package/dist/components/ui/locale-switcher.js +35 -453
  27. package/dist/components/ui/pagination.d.ts +5 -3
  28. package/dist/components/ui/pagination.js +7 -439
  29. package/dist/components/ui/search-menu.d.ts +4 -2
  30. package/dist/components/ui/search-menu.js +8 -440
  31. package/dist/components/ui/theme-switcher.d.ts +5 -3
  32. package/dist/components/ui/theme-switcher.js +8 -440
  33. package/dist/components/ui/virtualized-combobox.d.ts +4 -2
  34. package/dist/components/ui/virtualized-combobox.js +17 -445
  35. package/dist/lib/docs.d.ts +2 -0
  36. package/dist/lib/docs.js +92 -481
  37. package/dist/lib/docs.server.js +4 -20
  38. package/dist/lib/documentation-toolkit.js +4 -20
  39. package/dist/lib/markdown/content.d.ts +4 -5
  40. package/dist/services/agent/client/index.js +81 -463
  41. package/dist/services/agent/client/widget.d.ts +6 -3
  42. package/dist/services/notification/client/index.js +11 -440
  43. package/dist/services/notification/client/notification-menu.d.ts +7 -4
  44. package/dist/services/notification/public.js +11 -440
  45. package/package.json +5 -1
  46. package/dist/paraglide/runtime.d.ts +0 -978
@@ -395,443 +395,8 @@ function TabsTrigger({ className, ...props }) {
395
395
  });
396
396
  }
397
397
 
398
- // ../../src/paraglide/runtime.js
399
- import"@inlang/paraglide-js/urlpattern-polyfill";
400
- var baseLocale = "en";
401
- var locales = ["en", "fr"];
402
- var cookieName = "locale";
403
- var cookieMaxAge = 34560000;
404
- var cookieDomain = "";
405
- var localStorageKey = "PARAGLIDE_LOCALE";
406
- var strategy = [
407
- "url",
408
- "cookie",
409
- "preferredLanguage",
410
- "baseLocale"
411
- ];
412
- var routeStrategies = [
413
- {
414
- match: "/api/:path(.*)?",
415
- exclude: true
416
- },
417
- {
418
- match: "/sitemap.xml",
419
- exclude: true
420
- },
421
- {
422
- match: "/llms.txt",
423
- exclude: true
424
- }
425
- ];
426
- var urlPatterns = [
427
- {
428
- pattern: "/:path(.*)?",
429
- localized: [
430
- [
431
- "en",
432
- "/en/:path(.*)?"
433
- ],
434
- [
435
- "fr",
436
- "/fr/:path(.*)?"
437
- ]
438
- ]
439
- }
440
- ];
441
- var cachedRouteStrategyUrl;
442
- var cachedRouteStrategy;
443
- function findMatchingRouteStrategy(url) {
444
- if (routeStrategies.length === 0) {
445
- return;
446
- }
447
- const urlString = typeof url === "string" ? url : url.href;
448
- if (cachedRouteStrategyUrl === urlString) {
449
- return cachedRouteStrategy;
450
- }
451
- const urlObject = new URL(urlString, "http://dummy.com");
452
- let match;
453
- for (const routeStrategy of routeStrategies) {
454
- const pattern = new URLPattern(routeStrategy.match, urlObject.href);
455
- if (pattern.exec(urlObject.href)) {
456
- match = routeStrategy;
457
- break;
458
- }
459
- }
460
- cachedRouteStrategyUrl = urlString;
461
- cachedRouteStrategy = match;
462
- return match;
463
- }
464
- function getStrategyForUrl(url) {
465
- const routeStrategy = findMatchingRouteStrategy(url);
466
- if (routeStrategy && routeStrategy.exclude !== true && Array.isArray(routeStrategy.strategy)) {
467
- return routeStrategy.strategy;
468
- }
469
- return strategy;
470
- }
471
- var serverAsyncLocalStorage = undefined;
472
- var isServer = import.meta.env?.SSR ?? typeof window === "undefined";
473
- var experimentalStaticLocale = undefined;
474
- var TREE_SHAKE_COOKIE_STRATEGY_USED = true;
475
- var TREE_SHAKE_URL_STRATEGY_USED = true;
476
- var TREE_SHAKE_GLOBAL_VARIABLE_STRATEGY_USED = false;
477
- var TREE_SHAKE_PREFERRED_LANGUAGE_STRATEGY_USED = true;
478
- var TREE_SHAKE_DEFAULT_URL_PATTERN_USED = false;
479
- var TREE_SHAKE_LOCAL_STORAGE_STRATEGY_USED = false;
480
- globalThis.__paraglide = globalThis.__paraglide ?? {};
481
- globalThis.__paraglide.ssr = globalThis.__paraglide.ssr ?? {};
482
- var _locale;
483
- var localeInitiallySet = false;
484
- var getLocale = () => {
485
- if (experimentalStaticLocale !== undefined) {
486
- return experimentalStaticLocale;
487
- }
488
- if (serverAsyncLocalStorage) {
489
- const locale = serverAsyncLocalStorage?.getStore()?.locale;
490
- if (locale) {
491
- return locale;
492
- }
493
- }
494
- let strategyToUse = strategy;
495
- if (!isServer && typeof window !== "undefined" && window.location?.href) {
496
- strategyToUse = getStrategyForUrl(window.location.href);
497
- }
498
- const resolved = resolveLocaleWithStrategies(strategyToUse, typeof window !== "undefined" ? window.location?.href : undefined);
499
- if (resolved) {
500
- if (!localeInitiallySet) {
501
- _locale = resolved;
502
- localeInitiallySet = true;
503
- setLocale(resolved, { reload: false });
504
- }
505
- return resolved;
506
- }
507
- throw new Error("No locale found. Read the docs https://paraglidejs.com/errors#no-locale-found");
508
- };
509
- function resolveLocaleWithStrategies(strategyToUse, urlForUrlStrategy) {
510
- let locale;
511
- for (const strat of strategyToUse) {
512
- if (TREE_SHAKE_COOKIE_STRATEGY_USED && strat === "cookie") {
513
- locale = extractLocaleFromCookie();
514
- } else if (strat === "baseLocale") {
515
- locale = baseLocale;
516
- } else if (TREE_SHAKE_URL_STRATEGY_USED && strat === "url" && !isServer && typeof urlForUrlStrategy === "string") {
517
- locale = extractLocaleFromUrl(urlForUrlStrategy);
518
- } else if (TREE_SHAKE_GLOBAL_VARIABLE_STRATEGY_USED && strat === "globalVariable" && _locale !== undefined) {
519
- locale = _locale;
520
- } else if (TREE_SHAKE_PREFERRED_LANGUAGE_STRATEGY_USED && strat === "preferredLanguage" && !isServer) {
521
- locale = extractLocaleFromNavigator();
522
- } else if (TREE_SHAKE_LOCAL_STORAGE_STRATEGY_USED && strat === "localStorage" && !isServer) {
523
- locale = localStorage.getItem(localStorageKey) ?? undefined;
524
- } else if (isCustomStrategy(strat) && customClientStrategies.has(strat)) {
525
- const handler = customClientStrategies.get(strat);
526
- if (handler) {
527
- const result = handler.getLocale();
528
- if (result instanceof Promise) {
529
- continue;
530
- }
531
- if (result !== undefined) {
532
- return assertIsLocale(result);
533
- }
534
- }
535
- }
536
- const matchedLocale = toLocale(locale);
537
- if (matchedLocale) {
538
- return matchedLocale;
539
- }
540
- }
541
- return;
542
- }
543
- var rtlLanguages = new Set([
544
- "ar",
545
- "dv",
546
- "fa",
547
- "he",
548
- "ks",
549
- "ku",
550
- "ps",
551
- "sd",
552
- "ug",
553
- "ur",
554
- "yi"
555
- ]);
556
- var navigateOrReload = (newLocation) => {
557
- if (newLocation) {
558
- window.location.href = newLocation;
559
- } else {
560
- window.location.reload();
561
- }
562
- };
563
- var setLocale = (newLocale, options) => {
564
- const optionsWithDefaults = {
565
- reload: true,
566
- ...options
567
- };
568
- let currentLocale;
569
- try {
570
- currentLocale = getLocale();
571
- } catch {}
572
- const customSetLocalePromises = [];
573
- let newLocation = undefined;
574
- let strategyToUse = strategy;
575
- if (!isServer && typeof window !== "undefined" && window.location?.href) {
576
- strategyToUse = getStrategyForUrl(window.location.href);
577
- }
578
- for (const strat of strategyToUse) {
579
- if (TREE_SHAKE_GLOBAL_VARIABLE_STRATEGY_USED && strat === "globalVariable") {
580
- _locale = newLocale;
581
- } else if (TREE_SHAKE_COOKIE_STRATEGY_USED && strat === "cookie") {
582
- if (isServer || typeof document === "undefined" || typeof window === "undefined") {
583
- continue;
584
- }
585
- const cookieString = `${cookieName}=${newLocale}; path=/; max-age=${cookieMaxAge}`;
586
- document.cookie = cookieDomain ? `${cookieString}; domain=${cookieDomain}` : cookieString;
587
- } else if (strat === "baseLocale") {
588
- continue;
589
- } else if (TREE_SHAKE_URL_STRATEGY_USED && strat === "url" && typeof window !== "undefined") {
590
- newLocation = localizeUrl(window.location.href, {
591
- locale: newLocale
592
- }).href;
593
- } else if (TREE_SHAKE_LOCAL_STORAGE_STRATEGY_USED && strat === "localStorage" && typeof window !== "undefined") {
594
- localStorage.setItem(localStorageKey, newLocale);
595
- } else if (isCustomStrategy(strat) && customClientStrategies.has(strat)) {
596
- const handler = customClientStrategies.get(strat);
597
- if (handler) {
598
- let result = handler.setLocale(newLocale);
599
- if (result instanceof Promise) {
600
- result = result.catch((error) => {
601
- throw new Error(`Custom strategy "${strat}" setLocale failed.`, {
602
- cause: error
603
- });
604
- });
605
- customSetLocalePromises.push(result);
606
- }
607
- }
608
- }
609
- }
610
- const runReload = () => {
611
- if (!isServer && optionsWithDefaults.reload && window.location && newLocale !== currentLocale) {
612
- navigateOrReload(newLocation);
613
- }
614
- };
615
- if (customSetLocalePromises.length) {
616
- return Promise.all(customSetLocalePromises).then(() => {
617
- runReload();
618
- });
619
- }
620
- runReload();
621
- return;
622
- };
623
- var getUrlOrigin = () => {
624
- if (serverAsyncLocalStorage) {
625
- return serverAsyncLocalStorage.getStore()?.origin ?? "http://fallback.com";
626
- } else if (typeof window !== "undefined") {
627
- return window.location.origin;
628
- }
629
- return "http://fallback.com";
630
- };
631
- function toLocale(value) {
632
- if (typeof value !== "string") {
633
- return;
634
- }
635
- const lowerValue = value.toLowerCase();
636
- for (const locale of locales) {
637
- if (locale.toLowerCase() === lowerValue) {
638
- return locale;
639
- }
640
- }
641
- return;
642
- }
643
- function assertIsLocale(input) {
644
- const locale = toLocale(input);
645
- if (locale)
646
- return locale;
647
- throw new Error(`Invalid locale: ${input}. Expected one of: ${locales.join(", ")}`);
648
- }
649
- function extractLocaleFromCookie() {
650
- if (typeof document === "undefined" || !document.cookie) {
651
- return;
652
- }
653
- const match = document.cookie.match(new RegExp(`(^| )${cookieName}=([^;]+)`));
654
- const locale = match?.[2];
655
- return toLocale(locale);
656
- }
657
- function extractLocaleFromNavigator() {
658
- if (!navigator?.languages?.length) {
659
- return;
660
- }
661
- const languages = navigator.languages.map((lang) => ({
662
- fullTag: lang,
663
- baseTag: lang.split("-")[0]
664
- }));
665
- for (const lang of languages) {
666
- const fullLocale = toLocale(lang.fullTag);
667
- if (fullLocale) {
668
- return fullLocale;
669
- }
670
- const baseLocale2 = toLocale(lang.baseTag);
671
- if (baseLocale2) {
672
- return baseLocale2;
673
- }
674
- }
675
- return;
676
- }
677
- var cachedUrl;
678
- var cachedLocale;
679
- function extractLocaleFromUrl(url) {
680
- const urlString = typeof url === "string" ? url : url.href;
681
- if (cachedUrl === urlString) {
682
- return cachedLocale;
683
- }
684
- let result;
685
- if (TREE_SHAKE_DEFAULT_URL_PATTERN_USED) {
686
- result = defaultUrlPatternExtractLocale(url);
687
- } else {
688
- const urlObj = typeof url === "string" ? new URL(url) : url;
689
- for (const element of urlPatterns) {
690
- for (const [locale, localizedPattern] of element.localized) {
691
- const match = new URLPattern(localizedPattern, urlObj.href).exec(urlObj.href);
692
- if (match) {
693
- result = locale;
694
- break;
695
- }
696
- }
697
- if (result)
698
- break;
699
- }
700
- }
701
- cachedUrl = urlString;
702
- cachedLocale = result;
703
- return result;
704
- }
705
- function defaultUrlPatternExtractLocale(url) {
706
- const urlObj = new URL(url, "http://dummy.com");
707
- const pathSegments = urlObj.pathname.split("/").filter(Boolean);
708
- return toLocale(pathSegments[0]) || baseLocale;
709
- }
710
- function localizeUrl(url, options) {
711
- const targetLocale = options?.locale ? assertIsLocale(options?.locale) : getLocale();
712
- if (TREE_SHAKE_DEFAULT_URL_PATTERN_USED) {
713
- return localizeUrlDefaultPattern(url, targetLocale);
714
- }
715
- const urlObj = typeof url === "string" ? new URL(url) : url;
716
- for (const element of urlPatterns) {
717
- for (const [, localizedPattern] of element.localized) {
718
- const match = new URLPattern(localizedPattern, urlObj.href).exec(urlObj.href);
719
- if (!match) {
720
- continue;
721
- }
722
- const targetPattern = element.localized.find(([locale]) => locale === targetLocale)?.[1];
723
- if (!targetPattern) {
724
- continue;
725
- }
726
- const localizedUrl = fillPattern(targetPattern, aggregateGroups(match), urlObj.origin);
727
- return fillMissingUrlParts(localizedUrl, match);
728
- }
729
- const unlocalizedMatch = new URLPattern(element.pattern, urlObj.href).exec(urlObj.href);
730
- if (unlocalizedMatch) {
731
- const targetPattern = element.localized.find(([locale]) => locale === targetLocale)?.[1];
732
- if (targetPattern) {
733
- const localizedUrl = fillPattern(targetPattern, aggregateGroups(unlocalizedMatch), urlObj.origin);
734
- return fillMissingUrlParts(localizedUrl, unlocalizedMatch);
735
- }
736
- }
737
- }
738
- return urlObj;
739
- }
740
- function localizeUrlDefaultPattern(url, locale) {
741
- const urlObj = typeof url === "string" ? new URL(url, getUrlOrigin()) : new URL(url);
742
- const currentLocale = extractLocaleFromUrl(urlObj);
743
- if (currentLocale === locale) {
744
- return urlObj;
745
- }
746
- const pathSegments = urlObj.pathname.split("/").filter(Boolean);
747
- if (pathSegments.length > 0 && toLocale(pathSegments[0])) {
748
- pathSegments.shift();
749
- }
750
- if (locale === baseLocale) {
751
- urlObj.pathname = "/" + pathSegments.join("/");
752
- } else {
753
- urlObj.pathname = "/" + locale + "/" + pathSegments.join("/");
754
- }
755
- return urlObj;
756
- }
757
- function fillMissingUrlParts(url, match) {
758
- if (match.protocol.groups["0"]) {
759
- url.protocol = match.protocol.groups["0"] ?? "";
760
- }
761
- if (match.hostname.groups["0"]) {
762
- url.hostname = match.hostname.groups["0"] ?? "";
763
- }
764
- if (match.username.groups["0"]) {
765
- url.username = match.username.groups["0"] ?? "";
766
- }
767
- if (match.password.groups["0"]) {
768
- url.password = match.password.groups["0"] ?? "";
769
- }
770
- if (match.port.groups["0"]) {
771
- url.port = match.port.groups["0"] ?? "";
772
- }
773
- if (match.pathname.groups["0"]) {
774
- url.pathname = match.pathname.groups["0"] ?? "";
775
- }
776
- if (match.search.groups["0"]) {
777
- url.search = match.search.groups["0"] ?? "";
778
- }
779
- if (match.hash.groups["0"]) {
780
- url.hash = match.hash.groups["0"] ?? "";
781
- }
782
- return url;
783
- }
784
- function fillPattern(pattern, values, origin) {
785
- let processedPattern = pattern.replace(/(https?:\/\/[^:/]+):(\d+)(\/|$)/g, (_, protocol, port, slash) => {
786
- return `${protocol}#PORT-${port}#${slash}`;
787
- });
788
- let processedGroupDelimiters = processedPattern.replace(/\{([^{}]*)\}([?+*]?)/g, (_, content, modifier) => {
789
- if (modifier === "?") {
790
- return content;
791
- }
792
- return content;
793
- });
794
- let filled = processedGroupDelimiters.replace(/(\/?):([a-zA-Z0-9_]+)(\([^)]*\))?([?+*]?)/g, (_, slash, name, __, modifier) => {
795
- const value = values[name];
796
- if (value === null) {
797
- return "";
798
- }
799
- if (modifier === "?") {
800
- return value !== undefined ? `${slash}${value}` : "";
801
- }
802
- if (modifier === "+" || modifier === "*") {
803
- if (value === undefined && modifier === "+") {
804
- throw new Error(`Missing value for "${name}" (one or more required)`);
805
- }
806
- return value ? `${slash}${value}` : "";
807
- }
808
- if (value === undefined) {
809
- throw new Error(`Missing value for "${name}"`);
810
- }
811
- return `${slash}${value}`;
812
- });
813
- filled = filled.replace(/#PORT-(\d+)#/g, ":$1");
814
- return new URL(filled, origin);
815
- }
816
- function aggregateGroups(match) {
817
- return {
818
- ...match.hash.groups,
819
- ...match.hostname.groups,
820
- ...match.password.groups,
821
- ...match.pathname.groups,
822
- ...match.port.groups,
823
- ...match.protocol.groups,
824
- ...match.search.groups,
825
- ...match.username.groups
826
- };
827
- }
828
- var customServerStrategies = new Map;
829
- var customClientStrategies = new Map;
830
- function isCustomStrategy(strategy2) {
831
- return typeof strategy2 === "string" && /^custom-[A-Za-z0-9_-]+$/.test(strategy2);
832
- }
833
-
834
398
  // ../../src/services/notification/client/notification-menu.tsx
399
+ import { useKrakstackLocale } from "@krak-stack/registry/krakstack-provider";
835
400
  import { jsx as jsx7, jsxs as jsxs2 } from "react/jsx-runtime";
836
401
  var defaultMessages = {
837
402
  en: {
@@ -867,16 +432,17 @@ var defaultMessages = {
867
432
  unread: (count) => `${count} notification${count === 1 ? "" : "s"} non lue${count === 1 ? "" : "s"}`
868
433
  }
869
434
  };
870
- var notificationMenuMessages = (locale = getLocale(), overrides) => ({
435
+ var notificationMenuMessages = (locale = "en", translations) => ({
871
436
  ...locale.startsWith("fr") ? defaultMessages.fr : defaultMessages.en,
872
- ...overrides
437
+ ...translations?.[locale.split("-")[0] ?? locale],
438
+ ...translations?.[locale]
873
439
  });
874
440
  function NotificationMenu({
875
441
  className,
876
442
  defaultOpen = false,
877
443
  error = false,
878
444
  isLoading = false,
879
- locale = getLocale(),
445
+ locale: localeOverride,
880
446
  markReadOnOpen = true,
881
447
  messages: messageOverrides,
882
448
  notifications,
@@ -888,6 +454,7 @@ function NotificationMenu({
888
454
  renderItem,
889
455
  renderTrigger
890
456
  }) {
457
+ const locale = useKrakstackLocale(localeOverride);
891
458
  const [uncontrolledOpen, setUncontrolledOpen] = useState(defaultOpen);
892
459
  const [tab, setTab] = useState("inbox");
893
460
  const open = controlledOpen ?? uncontrolledOpen;
@@ -989,9 +556,13 @@ function NotificationMenu({
989
556
  });
990
557
  }
991
558
  function NotificationMenuTrigger({
992
- labels = notificationMenuMessages(),
559
+ labels: providedLabels,
560
+ locale: localeOverride,
561
+ messages,
993
562
  unreadCount
994
563
  }) {
564
+ const locale = useKrakstackLocale(localeOverride);
565
+ const labels = providedLabels ?? notificationMenuMessages(locale, messages);
995
566
  return /* @__PURE__ */ jsxs2(PopoverTrigger, {
996
567
  "aria-label": unreadCount > 0 ? `${labels.notifications}, ${labels.unread(unreadCount)}` : labels.notifications,
997
568
  className: cn(buttonVariants({ variant: "outline", size: "icon" }), "relative rounded-full"),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@krak-stack/registry",
3
- "version": "0.1.32",
3
+ "version": "0.1.34",
4
4
  "description": "Tree-shakable KrakStack components and Effect services.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -127,6 +127,10 @@
127
127
  "types": "./dist/components/ui/icon-input.d.ts",
128
128
  "import": "./dist/components/ui/icon-input.js"
129
129
  },
130
+ "./krakstack-provider": {
131
+ "types": "./dist/components/ui/krakstack-provider.d.ts",
132
+ "import": "./dist/components/ui/krakstack-provider.js"
133
+ },
130
134
  "./loading": {
131
135
  "types": "./dist/components/ui/loading.d.ts",
132
136
  "import": "./dist/components/ui/loading.js"