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