@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
@@ -182,443 +182,8 @@ function SelectScrollDownButton({
182
182
  });
183
183
  }
184
184
 
185
- // ../../src/paraglide/runtime.js
186
- import"@inlang/paraglide-js/urlpattern-polyfill";
187
- var baseLocale = "en";
188
- var locales = ["en", "fr"];
189
- var cookieName = "locale";
190
- var cookieMaxAge = 34560000;
191
- var cookieDomain = "";
192
- var localStorageKey = "PARAGLIDE_LOCALE";
193
- var strategy = [
194
- "url",
195
- "cookie",
196
- "preferredLanguage",
197
- "baseLocale"
198
- ];
199
- var routeStrategies = [
200
- {
201
- match: "/api/:path(.*)?",
202
- exclude: true
203
- },
204
- {
205
- match: "/sitemap.xml",
206
- exclude: true
207
- },
208
- {
209
- match: "/llms.txt",
210
- exclude: true
211
- }
212
- ];
213
- var urlPatterns = [
214
- {
215
- pattern: "/:path(.*)?",
216
- localized: [
217
- [
218
- "en",
219
- "/en/:path(.*)?"
220
- ],
221
- [
222
- "fr",
223
- "/fr/:path(.*)?"
224
- ]
225
- ]
226
- }
227
- ];
228
- var cachedRouteStrategyUrl;
229
- var cachedRouteStrategy;
230
- function findMatchingRouteStrategy(url) {
231
- if (routeStrategies.length === 0) {
232
- return;
233
- }
234
- const urlString = typeof url === "string" ? url : url.href;
235
- if (cachedRouteStrategyUrl === urlString) {
236
- return cachedRouteStrategy;
237
- }
238
- const urlObject = new URL(urlString, "http://dummy.com");
239
- let match;
240
- for (const routeStrategy of routeStrategies) {
241
- const pattern = new URLPattern(routeStrategy.match, urlObject.href);
242
- if (pattern.exec(urlObject.href)) {
243
- match = routeStrategy;
244
- break;
245
- }
246
- }
247
- cachedRouteStrategyUrl = urlString;
248
- cachedRouteStrategy = match;
249
- return match;
250
- }
251
- function getStrategyForUrl(url) {
252
- const routeStrategy = findMatchingRouteStrategy(url);
253
- if (routeStrategy && routeStrategy.exclude !== true && Array.isArray(routeStrategy.strategy)) {
254
- return routeStrategy.strategy;
255
- }
256
- return strategy;
257
- }
258
- var serverAsyncLocalStorage = undefined;
259
- var isServer = import.meta.env?.SSR ?? typeof window === "undefined";
260
- var experimentalStaticLocale = undefined;
261
- var TREE_SHAKE_COOKIE_STRATEGY_USED = true;
262
- var TREE_SHAKE_URL_STRATEGY_USED = true;
263
- var TREE_SHAKE_GLOBAL_VARIABLE_STRATEGY_USED = false;
264
- var TREE_SHAKE_PREFERRED_LANGUAGE_STRATEGY_USED = true;
265
- var TREE_SHAKE_DEFAULT_URL_PATTERN_USED = false;
266
- var TREE_SHAKE_LOCAL_STORAGE_STRATEGY_USED = false;
267
- globalThis.__paraglide = globalThis.__paraglide ?? {};
268
- globalThis.__paraglide.ssr = globalThis.__paraglide.ssr ?? {};
269
- var _locale;
270
- var localeInitiallySet = false;
271
- var getLocale = () => {
272
- if (experimentalStaticLocale !== undefined) {
273
- return experimentalStaticLocale;
274
- }
275
- if (serverAsyncLocalStorage) {
276
- const locale = serverAsyncLocalStorage?.getStore()?.locale;
277
- if (locale) {
278
- return locale;
279
- }
280
- }
281
- let strategyToUse = strategy;
282
- if (!isServer && typeof window !== "undefined" && window.location?.href) {
283
- strategyToUse = getStrategyForUrl(window.location.href);
284
- }
285
- const resolved = resolveLocaleWithStrategies(strategyToUse, typeof window !== "undefined" ? window.location?.href : undefined);
286
- if (resolved) {
287
- if (!localeInitiallySet) {
288
- _locale = resolved;
289
- localeInitiallySet = true;
290
- setLocale(resolved, { reload: false });
291
- }
292
- return resolved;
293
- }
294
- throw new Error("No locale found. Read the docs https://paraglidejs.com/errors#no-locale-found");
295
- };
296
- function resolveLocaleWithStrategies(strategyToUse, urlForUrlStrategy) {
297
- let locale;
298
- for (const strat of strategyToUse) {
299
- if (TREE_SHAKE_COOKIE_STRATEGY_USED && strat === "cookie") {
300
- locale = extractLocaleFromCookie();
301
- } else if (strat === "baseLocale") {
302
- locale = baseLocale;
303
- } else if (TREE_SHAKE_URL_STRATEGY_USED && strat === "url" && !isServer && typeof urlForUrlStrategy === "string") {
304
- locale = extractLocaleFromUrl(urlForUrlStrategy);
305
- } else if (TREE_SHAKE_GLOBAL_VARIABLE_STRATEGY_USED && strat === "globalVariable" && _locale !== undefined) {
306
- locale = _locale;
307
- } else if (TREE_SHAKE_PREFERRED_LANGUAGE_STRATEGY_USED && strat === "preferredLanguage" && !isServer) {
308
- locale = extractLocaleFromNavigator();
309
- } else if (TREE_SHAKE_LOCAL_STORAGE_STRATEGY_USED && strat === "localStorage" && !isServer) {
310
- locale = localStorage.getItem(localStorageKey) ?? undefined;
311
- } else if (isCustomStrategy(strat) && customClientStrategies.has(strat)) {
312
- const handler = customClientStrategies.get(strat);
313
- if (handler) {
314
- const result = handler.getLocale();
315
- if (result instanceof Promise) {
316
- continue;
317
- }
318
- if (result !== undefined) {
319
- return assertIsLocale(result);
320
- }
321
- }
322
- }
323
- const matchedLocale = toLocale(locale);
324
- if (matchedLocale) {
325
- return matchedLocale;
326
- }
327
- }
328
- return;
329
- }
330
- var rtlLanguages = new Set([
331
- "ar",
332
- "dv",
333
- "fa",
334
- "he",
335
- "ks",
336
- "ku",
337
- "ps",
338
- "sd",
339
- "ug",
340
- "ur",
341
- "yi"
342
- ]);
343
- var navigateOrReload = (newLocation) => {
344
- if (newLocation) {
345
- window.location.href = newLocation;
346
- } else {
347
- window.location.reload();
348
- }
349
- };
350
- var setLocale = (newLocale, options) => {
351
- const optionsWithDefaults = {
352
- reload: true,
353
- ...options
354
- };
355
- let currentLocale;
356
- try {
357
- currentLocale = getLocale();
358
- } catch {}
359
- const customSetLocalePromises = [];
360
- let newLocation = undefined;
361
- let strategyToUse = strategy;
362
- if (!isServer && typeof window !== "undefined" && window.location?.href) {
363
- strategyToUse = getStrategyForUrl(window.location.href);
364
- }
365
- for (const strat of strategyToUse) {
366
- if (TREE_SHAKE_GLOBAL_VARIABLE_STRATEGY_USED && strat === "globalVariable") {
367
- _locale = newLocale;
368
- } else if (TREE_SHAKE_COOKIE_STRATEGY_USED && strat === "cookie") {
369
- if (isServer || typeof document === "undefined" || typeof window === "undefined") {
370
- continue;
371
- }
372
- const cookieString = `${cookieName}=${newLocale}; path=/; max-age=${cookieMaxAge}`;
373
- document.cookie = cookieDomain ? `${cookieString}; domain=${cookieDomain}` : cookieString;
374
- } else if (strat === "baseLocale") {
375
- continue;
376
- } else if (TREE_SHAKE_URL_STRATEGY_USED && strat === "url" && typeof window !== "undefined") {
377
- newLocation = localizeUrl(window.location.href, {
378
- locale: newLocale
379
- }).href;
380
- } else if (TREE_SHAKE_LOCAL_STORAGE_STRATEGY_USED && strat === "localStorage" && typeof window !== "undefined") {
381
- localStorage.setItem(localStorageKey, newLocale);
382
- } else if (isCustomStrategy(strat) && customClientStrategies.has(strat)) {
383
- const handler = customClientStrategies.get(strat);
384
- if (handler) {
385
- let result = handler.setLocale(newLocale);
386
- if (result instanceof Promise) {
387
- result = result.catch((error) => {
388
- throw new Error(`Custom strategy "${strat}" setLocale failed.`, {
389
- cause: error
390
- });
391
- });
392
- customSetLocalePromises.push(result);
393
- }
394
- }
395
- }
396
- }
397
- const runReload = () => {
398
- if (!isServer && optionsWithDefaults.reload && window.location && newLocale !== currentLocale) {
399
- navigateOrReload(newLocation);
400
- }
401
- };
402
- if (customSetLocalePromises.length) {
403
- return Promise.all(customSetLocalePromises).then(() => {
404
- runReload();
405
- });
406
- }
407
- runReload();
408
- return;
409
- };
410
- var getUrlOrigin = () => {
411
- if (serverAsyncLocalStorage) {
412
- return serverAsyncLocalStorage.getStore()?.origin ?? "http://fallback.com";
413
- } else if (typeof window !== "undefined") {
414
- return window.location.origin;
415
- }
416
- return "http://fallback.com";
417
- };
418
- function toLocale(value) {
419
- if (typeof value !== "string") {
420
- return;
421
- }
422
- const lowerValue = value.toLowerCase();
423
- for (const locale of locales) {
424
- if (locale.toLowerCase() === lowerValue) {
425
- return locale;
426
- }
427
- }
428
- return;
429
- }
430
- function assertIsLocale(input) {
431
- const locale = toLocale(input);
432
- if (locale)
433
- return locale;
434
- throw new Error(`Invalid locale: ${input}. Expected one of: ${locales.join(", ")}`);
435
- }
436
- function extractLocaleFromCookie() {
437
- if (typeof document === "undefined" || !document.cookie) {
438
- return;
439
- }
440
- const match = document.cookie.match(new RegExp(`(^| )${cookieName}=([^;]+)`));
441
- const locale = match?.[2];
442
- return toLocale(locale);
443
- }
444
- function extractLocaleFromNavigator() {
445
- if (!navigator?.languages?.length) {
446
- return;
447
- }
448
- const languages = navigator.languages.map((lang) => ({
449
- fullTag: lang,
450
- baseTag: lang.split("-")[0]
451
- }));
452
- for (const lang of languages) {
453
- const fullLocale = toLocale(lang.fullTag);
454
- if (fullLocale) {
455
- return fullLocale;
456
- }
457
- const baseLocale2 = toLocale(lang.baseTag);
458
- if (baseLocale2) {
459
- return baseLocale2;
460
- }
461
- }
462
- return;
463
- }
464
- var cachedUrl;
465
- var cachedLocale;
466
- function extractLocaleFromUrl(url) {
467
- const urlString = typeof url === "string" ? url : url.href;
468
- if (cachedUrl === urlString) {
469
- return cachedLocale;
470
- }
471
- let result;
472
- if (TREE_SHAKE_DEFAULT_URL_PATTERN_USED) {
473
- result = defaultUrlPatternExtractLocale(url);
474
- } else {
475
- const urlObj = typeof url === "string" ? new URL(url) : url;
476
- for (const element of urlPatterns) {
477
- for (const [locale, localizedPattern] of element.localized) {
478
- const match = new URLPattern(localizedPattern, urlObj.href).exec(urlObj.href);
479
- if (match) {
480
- result = locale;
481
- break;
482
- }
483
- }
484
- if (result)
485
- break;
486
- }
487
- }
488
- cachedUrl = urlString;
489
- cachedLocale = result;
490
- return result;
491
- }
492
- function defaultUrlPatternExtractLocale(url) {
493
- const urlObj = new URL(url, "http://dummy.com");
494
- const pathSegments = urlObj.pathname.split("/").filter(Boolean);
495
- return toLocale(pathSegments[0]) || baseLocale;
496
- }
497
- function localizeUrl(url, options) {
498
- const targetLocale = options?.locale ? assertIsLocale(options?.locale) : getLocale();
499
- if (TREE_SHAKE_DEFAULT_URL_PATTERN_USED) {
500
- return localizeUrlDefaultPattern(url, targetLocale);
501
- }
502
- const urlObj = typeof url === "string" ? new URL(url) : url;
503
- for (const element of urlPatterns) {
504
- for (const [, localizedPattern] of element.localized) {
505
- const match = new URLPattern(localizedPattern, urlObj.href).exec(urlObj.href);
506
- if (!match) {
507
- continue;
508
- }
509
- const targetPattern = element.localized.find(([locale]) => locale === targetLocale)?.[1];
510
- if (!targetPattern) {
511
- continue;
512
- }
513
- const localizedUrl = fillPattern(targetPattern, aggregateGroups(match), urlObj.origin);
514
- return fillMissingUrlParts(localizedUrl, match);
515
- }
516
- const unlocalizedMatch = new URLPattern(element.pattern, urlObj.href).exec(urlObj.href);
517
- if (unlocalizedMatch) {
518
- const targetPattern = element.localized.find(([locale]) => locale === targetLocale)?.[1];
519
- if (targetPattern) {
520
- const localizedUrl = fillPattern(targetPattern, aggregateGroups(unlocalizedMatch), urlObj.origin);
521
- return fillMissingUrlParts(localizedUrl, unlocalizedMatch);
522
- }
523
- }
524
- }
525
- return urlObj;
526
- }
527
- function localizeUrlDefaultPattern(url, locale) {
528
- const urlObj = typeof url === "string" ? new URL(url, getUrlOrigin()) : new URL(url);
529
- const currentLocale = extractLocaleFromUrl(urlObj);
530
- if (currentLocale === locale) {
531
- return urlObj;
532
- }
533
- const pathSegments = urlObj.pathname.split("/").filter(Boolean);
534
- if (pathSegments.length > 0 && toLocale(pathSegments[0])) {
535
- pathSegments.shift();
536
- }
537
- if (locale === baseLocale) {
538
- urlObj.pathname = "/" + pathSegments.join("/");
539
- } else {
540
- urlObj.pathname = "/" + locale + "/" + pathSegments.join("/");
541
- }
542
- return urlObj;
543
- }
544
- function fillMissingUrlParts(url, match) {
545
- if (match.protocol.groups["0"]) {
546
- url.protocol = match.protocol.groups["0"] ?? "";
547
- }
548
- if (match.hostname.groups["0"]) {
549
- url.hostname = match.hostname.groups["0"] ?? "";
550
- }
551
- if (match.username.groups["0"]) {
552
- url.username = match.username.groups["0"] ?? "";
553
- }
554
- if (match.password.groups["0"]) {
555
- url.password = match.password.groups["0"] ?? "";
556
- }
557
- if (match.port.groups["0"]) {
558
- url.port = match.port.groups["0"] ?? "";
559
- }
560
- if (match.pathname.groups["0"]) {
561
- url.pathname = match.pathname.groups["0"] ?? "";
562
- }
563
- if (match.search.groups["0"]) {
564
- url.search = match.search.groups["0"] ?? "";
565
- }
566
- if (match.hash.groups["0"]) {
567
- url.hash = match.hash.groups["0"] ?? "";
568
- }
569
- return url;
570
- }
571
- function fillPattern(pattern, values, origin) {
572
- let processedPattern = pattern.replace(/(https?:\/\/[^:/]+):(\d+)(\/|$)/g, (_, protocol, port, slash) => {
573
- return `${protocol}#PORT-${port}#${slash}`;
574
- });
575
- let processedGroupDelimiters = processedPattern.replace(/\{([^{}]*)\}([?+*]?)/g, (_, content, modifier) => {
576
- if (modifier === "?") {
577
- return content;
578
- }
579
- return content;
580
- });
581
- let filled = processedGroupDelimiters.replace(/(\/?):([a-zA-Z0-9_]+)(\([^)]*\))?([?+*]?)/g, (_, slash, name, __, modifier) => {
582
- const value = values[name];
583
- if (value === null) {
584
- return "";
585
- }
586
- if (modifier === "?") {
587
- return value !== undefined ? `${slash}${value}` : "";
588
- }
589
- if (modifier === "+" || modifier === "*") {
590
- if (value === undefined && modifier === "+") {
591
- throw new Error(`Missing value for "${name}" (one or more required)`);
592
- }
593
- return value ? `${slash}${value}` : "";
594
- }
595
- if (value === undefined) {
596
- throw new Error(`Missing value for "${name}"`);
597
- }
598
- return `${slash}${value}`;
599
- });
600
- filled = filled.replace(/#PORT-(\d+)#/g, ":$1");
601
- return new URL(filled, origin);
602
- }
603
- function aggregateGroups(match) {
604
- return {
605
- ...match.hash.groups,
606
- ...match.hostname.groups,
607
- ...match.password.groups,
608
- ...match.pathname.groups,
609
- ...match.port.groups,
610
- ...match.protocol.groups,
611
- ...match.search.groups,
612
- ...match.username.groups
613
- };
614
- }
615
- var customServerStrategies = new Map;
616
- var customClientStrategies = new Map;
617
- function isCustomStrategy(strategy2) {
618
- return typeof strategy2 === "string" && /^custom-[A-Za-z0-9_-]+$/.test(strategy2);
619
- }
620
-
621
185
  // ../../src/components/ui/pagination.tsx
186
+ import { useKrakstackLocale } from "@krak-stack/registry/krakstack-provider";
622
187
  import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
623
188
  var messages = {
624
189
  en: {
@@ -642,12 +207,14 @@ var messages = {
642
207
  goToLastPage: "Aller à la dernière page"
643
208
  }
644
209
  };
645
- var paginationMessages = (locale = getLocale(), overrides) => ({
210
+ var paginationMessages = (locale = "en", translations) => ({
646
211
  ...locale.startsWith("fr") ? messages.fr : messages.en,
647
- ...overrides
212
+ ...translations?.[locale.split("-")[0] ?? locale],
213
+ ...translations?.[locale]
648
214
  });
649
215
  function Pagination({
650
216
  compact = false,
217
+ locale: localeOverride,
651
218
  messages: messageOverrides,
652
219
  onPageChange,
653
220
  onPageSizeChange,
@@ -659,7 +226,8 @@ function Pagination({
659
226
  showResults = true,
660
227
  totalRows
661
228
  }) {
662
- const labels = paginationMessages(getLocale(), messageOverrides);
229
+ const locale = useKrakstackLocale(localeOverride);
230
+ const labels = paginationMessages(locale, messageOverrides);
663
231
  const pageSizeId = useId();
664
232
  const canGoBack = page > 0;
665
233
  const canGoForward = page + 1 < pageCount;
@@ -1,5 +1,6 @@
1
1
  import type { ReactNode } from "react";
2
2
  export type SearchMenuMessages = Partial<Record<"title" | "description" | "placeholder" | "inputPlaceholder" | "emptyMessage", string>>;
3
+ export type SearchMenuMessageTranslations = Partial<Record<string, SearchMenuMessages>>;
3
4
  export type SearchMenuItem = {
4
5
  id: string;
5
6
  label: string;
@@ -16,12 +17,13 @@ export type SearchMenuGroup = {
16
17
  };
17
18
  export type SearchMenuProps = {
18
19
  groups: SearchMenuGroup[];
20
+ locale?: string;
19
21
  title?: string;
20
22
  description?: string;
21
23
  placeholder?: string;
22
24
  inputPlaceholder?: string;
23
25
  emptyMessage?: string;
24
- messages?: SearchMenuMessages;
26
+ messages?: SearchMenuMessageTranslations;
25
27
  shortcutLabel?: string;
26
28
  className?: string;
27
29
  open?: boolean;
@@ -31,4 +33,4 @@ export type SearchMenuProps = {
31
33
  onQueryChange?: (query: string) => void;
32
34
  shouldFilter?: boolean;
33
35
  };
34
- export declare function SearchMenu({ groups, title, description, placeholder, inputPlaceholder, emptyMessage, messages, shortcutLabel, className, open, onOpenChange, onSelect, query, onQueryChange, shouldFilter, }: SearchMenuProps): import("react").JSX.Element;
36
+ export declare function SearchMenu({ groups, locale: localeOverride, title, description, placeholder, inputPlaceholder, emptyMessage, messages, shortcutLabel, className, open, onOpenChange, onSelect, query, onQueryChange, shouldFilter, }: SearchMenuProps): import("react").JSX.Element;