@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
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
export type EditingLocale =
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
|
|
1
|
+
export type EditingLocale = string;
|
|
2
|
+
export declare const editingLocales: readonly ["en", "fr"];
|
|
3
|
+
export type EditingLocaleSwitcherMessages = Partial<Record<string, string>>;
|
|
4
|
+
export type EditingLocaleSwitcherMessageTranslations = Partial<Record<string, EditingLocaleSwitcherMessages>>;
|
|
5
|
+
export declare function EditingLocaleSwitcher({ locale: localeOverride, locales: localeOverrides, messages, value, onValueChange, }: {
|
|
6
|
+
locale?: string;
|
|
7
|
+
locales?: readonly string[];
|
|
8
|
+
messages?: EditingLocaleSwitcherMessageTranslations;
|
|
5
9
|
value: EditingLocale;
|
|
6
10
|
onValueChange: (value: EditingLocale) => void;
|
|
7
11
|
}): import("react").JSX.Element;
|
|
@@ -131,469 +131,46 @@ function SelectScrollDownButton({
|
|
|
131
131
|
});
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
-
// ../../src/paraglide/runtime.js
|
|
135
|
-
import"@inlang/paraglide-js/urlpattern-polyfill";
|
|
136
|
-
var baseLocale = "en";
|
|
137
|
-
var locales = ["en", "fr"];
|
|
138
|
-
var cookieName = "locale";
|
|
139
|
-
var cookieMaxAge = 34560000;
|
|
140
|
-
var cookieDomain = "";
|
|
141
|
-
var localStorageKey = "PARAGLIDE_LOCALE";
|
|
142
|
-
var strategy = [
|
|
143
|
-
"url",
|
|
144
|
-
"cookie",
|
|
145
|
-
"preferredLanguage",
|
|
146
|
-
"baseLocale"
|
|
147
|
-
];
|
|
148
|
-
var routeStrategies = [
|
|
149
|
-
{
|
|
150
|
-
match: "/api/:path(.*)?",
|
|
151
|
-
exclude: true
|
|
152
|
-
},
|
|
153
|
-
{
|
|
154
|
-
match: "/sitemap.xml",
|
|
155
|
-
exclude: true
|
|
156
|
-
},
|
|
157
|
-
{
|
|
158
|
-
match: "/llms.txt",
|
|
159
|
-
exclude: true
|
|
160
|
-
}
|
|
161
|
-
];
|
|
162
|
-
var urlPatterns = [
|
|
163
|
-
{
|
|
164
|
-
pattern: "/:path(.*)?",
|
|
165
|
-
localized: [
|
|
166
|
-
[
|
|
167
|
-
"en",
|
|
168
|
-
"/en/:path(.*)?"
|
|
169
|
-
],
|
|
170
|
-
[
|
|
171
|
-
"fr",
|
|
172
|
-
"/fr/:path(.*)?"
|
|
173
|
-
]
|
|
174
|
-
]
|
|
175
|
-
}
|
|
176
|
-
];
|
|
177
|
-
var cachedRouteStrategyUrl;
|
|
178
|
-
var cachedRouteStrategy;
|
|
179
|
-
function findMatchingRouteStrategy(url) {
|
|
180
|
-
if (routeStrategies.length === 0) {
|
|
181
|
-
return;
|
|
182
|
-
}
|
|
183
|
-
const urlString = typeof url === "string" ? url : url.href;
|
|
184
|
-
if (cachedRouteStrategyUrl === urlString) {
|
|
185
|
-
return cachedRouteStrategy;
|
|
186
|
-
}
|
|
187
|
-
const urlObject = new URL(urlString, "http://dummy.com");
|
|
188
|
-
let match;
|
|
189
|
-
for (const routeStrategy of routeStrategies) {
|
|
190
|
-
const pattern = new URLPattern(routeStrategy.match, urlObject.href);
|
|
191
|
-
if (pattern.exec(urlObject.href)) {
|
|
192
|
-
match = routeStrategy;
|
|
193
|
-
break;
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
cachedRouteStrategyUrl = urlString;
|
|
197
|
-
cachedRouteStrategy = match;
|
|
198
|
-
return match;
|
|
199
|
-
}
|
|
200
|
-
function getStrategyForUrl(url) {
|
|
201
|
-
const routeStrategy = findMatchingRouteStrategy(url);
|
|
202
|
-
if (routeStrategy && routeStrategy.exclude !== true && Array.isArray(routeStrategy.strategy)) {
|
|
203
|
-
return routeStrategy.strategy;
|
|
204
|
-
}
|
|
205
|
-
return strategy;
|
|
206
|
-
}
|
|
207
|
-
var serverAsyncLocalStorage = undefined;
|
|
208
|
-
var isServer = import.meta.env?.SSR ?? typeof window === "undefined";
|
|
209
|
-
var experimentalStaticLocale = undefined;
|
|
210
|
-
var TREE_SHAKE_COOKIE_STRATEGY_USED = true;
|
|
211
|
-
var TREE_SHAKE_URL_STRATEGY_USED = true;
|
|
212
|
-
var TREE_SHAKE_GLOBAL_VARIABLE_STRATEGY_USED = false;
|
|
213
|
-
var TREE_SHAKE_PREFERRED_LANGUAGE_STRATEGY_USED = true;
|
|
214
|
-
var TREE_SHAKE_DEFAULT_URL_PATTERN_USED = false;
|
|
215
|
-
var TREE_SHAKE_LOCAL_STORAGE_STRATEGY_USED = false;
|
|
216
|
-
globalThis.__paraglide = globalThis.__paraglide ?? {};
|
|
217
|
-
globalThis.__paraglide.ssr = globalThis.__paraglide.ssr ?? {};
|
|
218
|
-
var _locale;
|
|
219
|
-
var localeInitiallySet = false;
|
|
220
|
-
var getLocale = () => {
|
|
221
|
-
if (experimentalStaticLocale !== undefined) {
|
|
222
|
-
return experimentalStaticLocale;
|
|
223
|
-
}
|
|
224
|
-
if (serverAsyncLocalStorage) {
|
|
225
|
-
const locale = serverAsyncLocalStorage?.getStore()?.locale;
|
|
226
|
-
if (locale) {
|
|
227
|
-
return locale;
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
let strategyToUse = strategy;
|
|
231
|
-
if (!isServer && typeof window !== "undefined" && window.location?.href) {
|
|
232
|
-
strategyToUse = getStrategyForUrl(window.location.href);
|
|
233
|
-
}
|
|
234
|
-
const resolved = resolveLocaleWithStrategies(strategyToUse, typeof window !== "undefined" ? window.location?.href : undefined);
|
|
235
|
-
if (resolved) {
|
|
236
|
-
if (!localeInitiallySet) {
|
|
237
|
-
_locale = resolved;
|
|
238
|
-
localeInitiallySet = true;
|
|
239
|
-
setLocale(resolved, { reload: false });
|
|
240
|
-
}
|
|
241
|
-
return resolved;
|
|
242
|
-
}
|
|
243
|
-
throw new Error("No locale found. Read the docs https://paraglidejs.com/errors#no-locale-found");
|
|
244
|
-
};
|
|
245
|
-
function resolveLocaleWithStrategies(strategyToUse, urlForUrlStrategy) {
|
|
246
|
-
let locale;
|
|
247
|
-
for (const strat of strategyToUse) {
|
|
248
|
-
if (TREE_SHAKE_COOKIE_STRATEGY_USED && strat === "cookie") {
|
|
249
|
-
locale = extractLocaleFromCookie();
|
|
250
|
-
} else if (strat === "baseLocale") {
|
|
251
|
-
locale = baseLocale;
|
|
252
|
-
} else if (TREE_SHAKE_URL_STRATEGY_USED && strat === "url" && !isServer && typeof urlForUrlStrategy === "string") {
|
|
253
|
-
locale = extractLocaleFromUrl(urlForUrlStrategy);
|
|
254
|
-
} else if (TREE_SHAKE_GLOBAL_VARIABLE_STRATEGY_USED && strat === "globalVariable" && _locale !== undefined) {
|
|
255
|
-
locale = _locale;
|
|
256
|
-
} else if (TREE_SHAKE_PREFERRED_LANGUAGE_STRATEGY_USED && strat === "preferredLanguage" && !isServer) {
|
|
257
|
-
locale = extractLocaleFromNavigator();
|
|
258
|
-
} else if (TREE_SHAKE_LOCAL_STORAGE_STRATEGY_USED && strat === "localStorage" && !isServer) {
|
|
259
|
-
locale = localStorage.getItem(localStorageKey) ?? undefined;
|
|
260
|
-
} else if (isCustomStrategy(strat) && customClientStrategies.has(strat)) {
|
|
261
|
-
const handler = customClientStrategies.get(strat);
|
|
262
|
-
if (handler) {
|
|
263
|
-
const result = handler.getLocale();
|
|
264
|
-
if (result instanceof Promise) {
|
|
265
|
-
continue;
|
|
266
|
-
}
|
|
267
|
-
if (result !== undefined) {
|
|
268
|
-
return assertIsLocale(result);
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
const matchedLocale = toLocale(locale);
|
|
273
|
-
if (matchedLocale) {
|
|
274
|
-
return matchedLocale;
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
return;
|
|
278
|
-
}
|
|
279
|
-
var rtlLanguages = new Set([
|
|
280
|
-
"ar",
|
|
281
|
-
"dv",
|
|
282
|
-
"fa",
|
|
283
|
-
"he",
|
|
284
|
-
"ks",
|
|
285
|
-
"ku",
|
|
286
|
-
"ps",
|
|
287
|
-
"sd",
|
|
288
|
-
"ug",
|
|
289
|
-
"ur",
|
|
290
|
-
"yi"
|
|
291
|
-
]);
|
|
292
|
-
var navigateOrReload = (newLocation) => {
|
|
293
|
-
if (newLocation) {
|
|
294
|
-
window.location.href = newLocation;
|
|
295
|
-
} else {
|
|
296
|
-
window.location.reload();
|
|
297
|
-
}
|
|
298
|
-
};
|
|
299
|
-
var setLocale = (newLocale, options) => {
|
|
300
|
-
const optionsWithDefaults = {
|
|
301
|
-
reload: true,
|
|
302
|
-
...options
|
|
303
|
-
};
|
|
304
|
-
let currentLocale;
|
|
305
|
-
try {
|
|
306
|
-
currentLocale = getLocale();
|
|
307
|
-
} catch {}
|
|
308
|
-
const customSetLocalePromises = [];
|
|
309
|
-
let newLocation = undefined;
|
|
310
|
-
let strategyToUse = strategy;
|
|
311
|
-
if (!isServer && typeof window !== "undefined" && window.location?.href) {
|
|
312
|
-
strategyToUse = getStrategyForUrl(window.location.href);
|
|
313
|
-
}
|
|
314
|
-
for (const strat of strategyToUse) {
|
|
315
|
-
if (TREE_SHAKE_GLOBAL_VARIABLE_STRATEGY_USED && strat === "globalVariable") {
|
|
316
|
-
_locale = newLocale;
|
|
317
|
-
} else if (TREE_SHAKE_COOKIE_STRATEGY_USED && strat === "cookie") {
|
|
318
|
-
if (isServer || typeof document === "undefined" || typeof window === "undefined") {
|
|
319
|
-
continue;
|
|
320
|
-
}
|
|
321
|
-
const cookieString = `${cookieName}=${newLocale}; path=/; max-age=${cookieMaxAge}`;
|
|
322
|
-
document.cookie = cookieDomain ? `${cookieString}; domain=${cookieDomain}` : cookieString;
|
|
323
|
-
} else if (strat === "baseLocale") {
|
|
324
|
-
continue;
|
|
325
|
-
} else if (TREE_SHAKE_URL_STRATEGY_USED && strat === "url" && typeof window !== "undefined") {
|
|
326
|
-
newLocation = localizeUrl(window.location.href, {
|
|
327
|
-
locale: newLocale
|
|
328
|
-
}).href;
|
|
329
|
-
} else if (TREE_SHAKE_LOCAL_STORAGE_STRATEGY_USED && strat === "localStorage" && typeof window !== "undefined") {
|
|
330
|
-
localStorage.setItem(localStorageKey, newLocale);
|
|
331
|
-
} else if (isCustomStrategy(strat) && customClientStrategies.has(strat)) {
|
|
332
|
-
const handler = customClientStrategies.get(strat);
|
|
333
|
-
if (handler) {
|
|
334
|
-
let result = handler.setLocale(newLocale);
|
|
335
|
-
if (result instanceof Promise) {
|
|
336
|
-
result = result.catch((error) => {
|
|
337
|
-
throw new Error(`Custom strategy "${strat}" setLocale failed.`, {
|
|
338
|
-
cause: error
|
|
339
|
-
});
|
|
340
|
-
});
|
|
341
|
-
customSetLocalePromises.push(result);
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
const runReload = () => {
|
|
347
|
-
if (!isServer && optionsWithDefaults.reload && window.location && newLocale !== currentLocale) {
|
|
348
|
-
navigateOrReload(newLocation);
|
|
349
|
-
}
|
|
350
|
-
};
|
|
351
|
-
if (customSetLocalePromises.length) {
|
|
352
|
-
return Promise.all(customSetLocalePromises).then(() => {
|
|
353
|
-
runReload();
|
|
354
|
-
});
|
|
355
|
-
}
|
|
356
|
-
runReload();
|
|
357
|
-
return;
|
|
358
|
-
};
|
|
359
|
-
var getUrlOrigin = () => {
|
|
360
|
-
if (serverAsyncLocalStorage) {
|
|
361
|
-
return serverAsyncLocalStorage.getStore()?.origin ?? "http://fallback.com";
|
|
362
|
-
} else if (typeof window !== "undefined") {
|
|
363
|
-
return window.location.origin;
|
|
364
|
-
}
|
|
365
|
-
return "http://fallback.com";
|
|
366
|
-
};
|
|
367
|
-
function toLocale(value) {
|
|
368
|
-
if (typeof value !== "string") {
|
|
369
|
-
return;
|
|
370
|
-
}
|
|
371
|
-
const lowerValue = value.toLowerCase();
|
|
372
|
-
for (const locale of locales) {
|
|
373
|
-
if (locale.toLowerCase() === lowerValue) {
|
|
374
|
-
return locale;
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
return;
|
|
378
|
-
}
|
|
379
|
-
function assertIsLocale(input) {
|
|
380
|
-
const locale = toLocale(input);
|
|
381
|
-
if (locale)
|
|
382
|
-
return locale;
|
|
383
|
-
throw new Error(`Invalid locale: ${input}. Expected one of: ${locales.join(", ")}`);
|
|
384
|
-
}
|
|
385
|
-
function extractLocaleFromCookie() {
|
|
386
|
-
if (typeof document === "undefined" || !document.cookie) {
|
|
387
|
-
return;
|
|
388
|
-
}
|
|
389
|
-
const match = document.cookie.match(new RegExp(`(^| )${cookieName}=([^;]+)`));
|
|
390
|
-
const locale = match?.[2];
|
|
391
|
-
return toLocale(locale);
|
|
392
|
-
}
|
|
393
|
-
function extractLocaleFromNavigator() {
|
|
394
|
-
if (!navigator?.languages?.length) {
|
|
395
|
-
return;
|
|
396
|
-
}
|
|
397
|
-
const languages = navigator.languages.map((lang) => ({
|
|
398
|
-
fullTag: lang,
|
|
399
|
-
baseTag: lang.split("-")[0]
|
|
400
|
-
}));
|
|
401
|
-
for (const lang of languages) {
|
|
402
|
-
const fullLocale = toLocale(lang.fullTag);
|
|
403
|
-
if (fullLocale) {
|
|
404
|
-
return fullLocale;
|
|
405
|
-
}
|
|
406
|
-
const baseLocale2 = toLocale(lang.baseTag);
|
|
407
|
-
if (baseLocale2) {
|
|
408
|
-
return baseLocale2;
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
return;
|
|
412
|
-
}
|
|
413
|
-
var cachedUrl;
|
|
414
|
-
var cachedLocale;
|
|
415
|
-
function extractLocaleFromUrl(url) {
|
|
416
|
-
const urlString = typeof url === "string" ? url : url.href;
|
|
417
|
-
if (cachedUrl === urlString) {
|
|
418
|
-
return cachedLocale;
|
|
419
|
-
}
|
|
420
|
-
let result;
|
|
421
|
-
if (TREE_SHAKE_DEFAULT_URL_PATTERN_USED) {
|
|
422
|
-
result = defaultUrlPatternExtractLocale(url);
|
|
423
|
-
} else {
|
|
424
|
-
const urlObj = typeof url === "string" ? new URL(url) : url;
|
|
425
|
-
for (const element of urlPatterns) {
|
|
426
|
-
for (const [locale, localizedPattern] of element.localized) {
|
|
427
|
-
const match = new URLPattern(localizedPattern, urlObj.href).exec(urlObj.href);
|
|
428
|
-
if (match) {
|
|
429
|
-
result = locale;
|
|
430
|
-
break;
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
if (result)
|
|
434
|
-
break;
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
cachedUrl = urlString;
|
|
438
|
-
cachedLocale = result;
|
|
439
|
-
return result;
|
|
440
|
-
}
|
|
441
|
-
function defaultUrlPatternExtractLocale(url) {
|
|
442
|
-
const urlObj = new URL(url, "http://dummy.com");
|
|
443
|
-
const pathSegments = urlObj.pathname.split("/").filter(Boolean);
|
|
444
|
-
return toLocale(pathSegments[0]) || baseLocale;
|
|
445
|
-
}
|
|
446
|
-
function localizeUrl(url, options) {
|
|
447
|
-
const targetLocale = options?.locale ? assertIsLocale(options?.locale) : getLocale();
|
|
448
|
-
if (TREE_SHAKE_DEFAULT_URL_PATTERN_USED) {
|
|
449
|
-
return localizeUrlDefaultPattern(url, targetLocale);
|
|
450
|
-
}
|
|
451
|
-
const urlObj = typeof url === "string" ? new URL(url) : url;
|
|
452
|
-
for (const element of urlPatterns) {
|
|
453
|
-
for (const [, localizedPattern] of element.localized) {
|
|
454
|
-
const match = new URLPattern(localizedPattern, urlObj.href).exec(urlObj.href);
|
|
455
|
-
if (!match) {
|
|
456
|
-
continue;
|
|
457
|
-
}
|
|
458
|
-
const targetPattern = element.localized.find(([locale]) => locale === targetLocale)?.[1];
|
|
459
|
-
if (!targetPattern) {
|
|
460
|
-
continue;
|
|
461
|
-
}
|
|
462
|
-
const localizedUrl = fillPattern(targetPattern, aggregateGroups(match), urlObj.origin);
|
|
463
|
-
return fillMissingUrlParts(localizedUrl, match);
|
|
464
|
-
}
|
|
465
|
-
const unlocalizedMatch = new URLPattern(element.pattern, urlObj.href).exec(urlObj.href);
|
|
466
|
-
if (unlocalizedMatch) {
|
|
467
|
-
const targetPattern = element.localized.find(([locale]) => locale === targetLocale)?.[1];
|
|
468
|
-
if (targetPattern) {
|
|
469
|
-
const localizedUrl = fillPattern(targetPattern, aggregateGroups(unlocalizedMatch), urlObj.origin);
|
|
470
|
-
return fillMissingUrlParts(localizedUrl, unlocalizedMatch);
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
return urlObj;
|
|
475
|
-
}
|
|
476
|
-
function localizeUrlDefaultPattern(url, locale) {
|
|
477
|
-
const urlObj = typeof url === "string" ? new URL(url, getUrlOrigin()) : new URL(url);
|
|
478
|
-
const currentLocale = extractLocaleFromUrl(urlObj);
|
|
479
|
-
if (currentLocale === locale) {
|
|
480
|
-
return urlObj;
|
|
481
|
-
}
|
|
482
|
-
const pathSegments = urlObj.pathname.split("/").filter(Boolean);
|
|
483
|
-
if (pathSegments.length > 0 && toLocale(pathSegments[0])) {
|
|
484
|
-
pathSegments.shift();
|
|
485
|
-
}
|
|
486
|
-
if (locale === baseLocale) {
|
|
487
|
-
urlObj.pathname = "/" + pathSegments.join("/");
|
|
488
|
-
} else {
|
|
489
|
-
urlObj.pathname = "/" + locale + "/" + pathSegments.join("/");
|
|
490
|
-
}
|
|
491
|
-
return urlObj;
|
|
492
|
-
}
|
|
493
|
-
function fillMissingUrlParts(url, match) {
|
|
494
|
-
if (match.protocol.groups["0"]) {
|
|
495
|
-
url.protocol = match.protocol.groups["0"] ?? "";
|
|
496
|
-
}
|
|
497
|
-
if (match.hostname.groups["0"]) {
|
|
498
|
-
url.hostname = match.hostname.groups["0"] ?? "";
|
|
499
|
-
}
|
|
500
|
-
if (match.username.groups["0"]) {
|
|
501
|
-
url.username = match.username.groups["0"] ?? "";
|
|
502
|
-
}
|
|
503
|
-
if (match.password.groups["0"]) {
|
|
504
|
-
url.password = match.password.groups["0"] ?? "";
|
|
505
|
-
}
|
|
506
|
-
if (match.port.groups["0"]) {
|
|
507
|
-
url.port = match.port.groups["0"] ?? "";
|
|
508
|
-
}
|
|
509
|
-
if (match.pathname.groups["0"]) {
|
|
510
|
-
url.pathname = match.pathname.groups["0"] ?? "";
|
|
511
|
-
}
|
|
512
|
-
if (match.search.groups["0"]) {
|
|
513
|
-
url.search = match.search.groups["0"] ?? "";
|
|
514
|
-
}
|
|
515
|
-
if (match.hash.groups["0"]) {
|
|
516
|
-
url.hash = match.hash.groups["0"] ?? "";
|
|
517
|
-
}
|
|
518
|
-
return url;
|
|
519
|
-
}
|
|
520
|
-
function fillPattern(pattern, values, origin) {
|
|
521
|
-
let processedPattern = pattern.replace(/(https?:\/\/[^:/]+):(\d+)(\/|$)/g, (_, protocol, port, slash) => {
|
|
522
|
-
return `${protocol}#PORT-${port}#${slash}`;
|
|
523
|
-
});
|
|
524
|
-
let processedGroupDelimiters = processedPattern.replace(/\{([^{}]*)\}([?+*]?)/g, (_, content, modifier) => {
|
|
525
|
-
if (modifier === "?") {
|
|
526
|
-
return content;
|
|
527
|
-
}
|
|
528
|
-
return content;
|
|
529
|
-
});
|
|
530
|
-
let filled = processedGroupDelimiters.replace(/(\/?):([a-zA-Z0-9_]+)(\([^)]*\))?([?+*]?)/g, (_, slash, name, __, modifier) => {
|
|
531
|
-
const value = values[name];
|
|
532
|
-
if (value === null) {
|
|
533
|
-
return "";
|
|
534
|
-
}
|
|
535
|
-
if (modifier === "?") {
|
|
536
|
-
return value !== undefined ? `${slash}${value}` : "";
|
|
537
|
-
}
|
|
538
|
-
if (modifier === "+" || modifier === "*") {
|
|
539
|
-
if (value === undefined && modifier === "+") {
|
|
540
|
-
throw new Error(`Missing value for "${name}" (one or more required)`);
|
|
541
|
-
}
|
|
542
|
-
return value ? `${slash}${value}` : "";
|
|
543
|
-
}
|
|
544
|
-
if (value === undefined) {
|
|
545
|
-
throw new Error(`Missing value for "${name}"`);
|
|
546
|
-
}
|
|
547
|
-
return `${slash}${value}`;
|
|
548
|
-
});
|
|
549
|
-
filled = filled.replace(/#PORT-(\d+)#/g, ":$1");
|
|
550
|
-
return new URL(filled, origin);
|
|
551
|
-
}
|
|
552
|
-
function aggregateGroups(match) {
|
|
553
|
-
return {
|
|
554
|
-
...match.hash.groups,
|
|
555
|
-
...match.hostname.groups,
|
|
556
|
-
...match.password.groups,
|
|
557
|
-
...match.pathname.groups,
|
|
558
|
-
...match.port.groups,
|
|
559
|
-
...match.protocol.groups,
|
|
560
|
-
...match.search.groups,
|
|
561
|
-
...match.username.groups
|
|
562
|
-
};
|
|
563
|
-
}
|
|
564
|
-
var customServerStrategies = new Map;
|
|
565
|
-
var customClientStrategies = new Map;
|
|
566
|
-
function isCustomStrategy(strategy2) {
|
|
567
|
-
return typeof strategy2 === "string" && /^custom-[A-Za-z0-9_-]+$/.test(strategy2);
|
|
568
|
-
}
|
|
569
|
-
|
|
570
134
|
// ../../src/components/ui/editing-locale-switcher.tsx
|
|
135
|
+
import {
|
|
136
|
+
useKrakstackLocale,
|
|
137
|
+
useKrakstackLocales
|
|
138
|
+
} from "@krak-stack/registry/krakstack-provider";
|
|
571
139
|
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
140
|
+
var editingLocales = ["en", "fr"];
|
|
572
141
|
var messages = {
|
|
573
142
|
en: { label: "Editing", en: "English", fr: "French" },
|
|
574
143
|
fr: { label: "Modification", en: "Anglais", fr: "Français" }
|
|
575
144
|
};
|
|
576
|
-
var editingLocaleMessages = (
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
145
|
+
var editingLocaleMessages = (locale, translations) => {
|
|
146
|
+
const defaults = locale.startsWith("fr") ? messages.fr : messages.en;
|
|
147
|
+
const base = translations?.[locale.split("-")[0] ?? locale];
|
|
148
|
+
const exact = translations?.[locale];
|
|
149
|
+
return {
|
|
150
|
+
label: exact?.label ?? base?.label ?? defaults.label,
|
|
151
|
+
localeName: (option) => exact?.[option] ?? base?.[option] ?? (option === "en" ? defaults.en : option === "fr" ? defaults.fr : option)
|
|
152
|
+
};
|
|
153
|
+
};
|
|
580
154
|
function EditingLocaleSwitcher({
|
|
155
|
+
locale: localeOverride,
|
|
156
|
+
locales: localeOverrides,
|
|
581
157
|
messages: messages2,
|
|
582
158
|
value,
|
|
583
159
|
onValueChange
|
|
584
160
|
}) {
|
|
585
|
-
const
|
|
586
|
-
const
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
161
|
+
const locale = useKrakstackLocale(localeOverride);
|
|
162
|
+
const locales = useKrakstackLocales(localeOverrides);
|
|
163
|
+
const labels = editingLocaleMessages(locale, messages2);
|
|
164
|
+
const localeOptions = locales.map((value2) => ({
|
|
165
|
+
value: value2,
|
|
166
|
+
label: labels.localeName(value2)
|
|
167
|
+
}));
|
|
590
168
|
return /* @__PURE__ */ jsxs2(Select, {
|
|
591
169
|
items: localeOptions,
|
|
592
170
|
value,
|
|
593
171
|
onValueChange: (nextValue) => {
|
|
594
|
-
if (nextValue
|
|
172
|
+
if (nextValue !== null)
|
|
595
173
|
onValueChange(nextValue);
|
|
596
|
-
}
|
|
597
174
|
},
|
|
598
175
|
children: [
|
|
599
176
|
/* @__PURE__ */ jsxs2(SelectTrigger, {
|
|
@@ -626,5 +203,6 @@ function EditingLocaleSwitcher({
|
|
|
626
203
|
});
|
|
627
204
|
}
|
|
628
205
|
export {
|
|
629
|
-
EditingLocaleSwitcher
|
|
206
|
+
EditingLocaleSwitcher,
|
|
207
|
+
editingLocales
|
|
630
208
|
};
|
|
@@ -2,7 +2,8 @@ import type { ComponentProps, JSX, ReactNode } from "react";
|
|
|
2
2
|
import { FormReact } from "@lucas-barake/effect-form-react";
|
|
3
3
|
import { Option } from "effect";
|
|
4
4
|
import { AsyncResult, Atom } from "effect/unstable/reactivity";
|
|
5
|
-
import { type
|
|
5
|
+
import { type FilePickerMessageTranslations } from "./file-picker.js";
|
|
6
|
+
import { type VirtualizedComboboxMessageTranslations, type VirtualizedComboboxOption } from "./virtualized-combobox.js";
|
|
6
7
|
export type EffectFormMessages = {
|
|
7
8
|
add: string;
|
|
8
9
|
blockNavigationCancel: string;
|
|
@@ -21,7 +22,8 @@ export type EffectFormMessages = {
|
|
|
21
22
|
value: string;
|
|
22
23
|
};
|
|
23
24
|
export type EffectFormMessageOverrides = Partial<EffectFormMessages>;
|
|
24
|
-
export
|
|
25
|
+
export type EffectFormMessageTranslations = Partial<Record<string, EffectFormMessageOverrides>>;
|
|
26
|
+
export declare const effectFormMessages: (locale?: string, translations?: EffectFormMessageTranslations) => EffectFormMessages;
|
|
25
27
|
export type FieldOptions = {
|
|
26
28
|
label: JSX.Element | string;
|
|
27
29
|
description?: string;
|
|
@@ -51,26 +53,36 @@ export type SubmitForm<A, E> = {
|
|
|
51
53
|
lastSubmittedValues: Atom.Atom<Option.Option<unknown>>;
|
|
52
54
|
submit: Atom.AtomResultFn<void, A, E>;
|
|
53
55
|
};
|
|
54
|
-
export declare const SubmitButton: <A, E>({ children, form, onSubmit, }: {
|
|
56
|
+
export declare const SubmitButton: <A, E>({ children, form, locale, messages, onSubmit, }: {
|
|
55
57
|
children?: ReactNode;
|
|
56
58
|
form: SubmitForm<A, E>;
|
|
59
|
+
locale?: string;
|
|
60
|
+
messages?: EffectFormMessageTranslations;
|
|
57
61
|
onSubmit?: () => void;
|
|
58
62
|
}) => JSX.Element;
|
|
59
63
|
type TextFieldOptions = FieldOptions & Omit<ComponentProps<"input">, "children" | "defaultValue" | "id" | "name" | "onBlur" | "onChange" | "value"> & {
|
|
60
64
|
errorMessage?: string;
|
|
61
65
|
};
|
|
62
66
|
export declare const TextField: FormReact.FieldComponent<string, TextFieldOptions>;
|
|
63
|
-
type NameFieldOptions = Omit<TextFieldOptions, "label"
|
|
67
|
+
type NameFieldOptions = Omit<TextFieldOptions, "label"> & {
|
|
68
|
+
locale?: string;
|
|
69
|
+
messages?: EffectFormMessageTranslations;
|
|
70
|
+
};
|
|
64
71
|
export declare const NameField: FormReact.FieldComponent<string, NameFieldOptions>;
|
|
65
72
|
type TextAreaFieldOptions = FieldOptions & Omit<ComponentProps<"textarea">, "children" | "defaultValue" | "id" | "name" | "onBlur" | "onChange" | "value"> & {
|
|
66
73
|
original?: string;
|
|
67
74
|
};
|
|
68
75
|
export declare const TextAreaField: FormReact.FieldComponent<string, TextAreaFieldOptions>;
|
|
69
|
-
type DescriptionFieldOptions = Omit<TextAreaFieldOptions, "label"
|
|
76
|
+
type DescriptionFieldOptions = Omit<TextAreaFieldOptions, "label"> & {
|
|
77
|
+
locale?: string;
|
|
78
|
+
messages?: EffectFormMessageTranslations;
|
|
79
|
+
};
|
|
70
80
|
export declare const DescriptionField: FormReact.FieldComponent<string, DescriptionFieldOptions>;
|
|
71
81
|
type FileFieldOptions = FieldOptions & {
|
|
72
82
|
accept: ComponentProps<"input">["accept"];
|
|
83
|
+
messages?: FilePickerMessageTranslations;
|
|
73
84
|
onFileChange?: (file: File | undefined) => void;
|
|
85
|
+
locale?: string;
|
|
74
86
|
required?: boolean;
|
|
75
87
|
};
|
|
76
88
|
export declare const FileField: FormReact.FieldComponent<File | undefined, FileFieldOptions>;
|
|
@@ -84,7 +96,10 @@ type SelectFieldOptions<T extends string> = FieldOptions & {
|
|
|
84
96
|
placeholder?: string;
|
|
85
97
|
};
|
|
86
98
|
export declare const SelectField: <T extends string>({ field, props, }: FormReact.FieldComponentProps<T, SelectFieldOptions<T>>) => JSX.Element;
|
|
87
|
-
type FolderFieldOptions<T extends string> = Omit<SelectFieldOptions<T>, "label"
|
|
99
|
+
type FolderFieldOptions<T extends string> = Omit<SelectFieldOptions<T>, "label"> & {
|
|
100
|
+
locale?: string;
|
|
101
|
+
messages?: EffectFormMessageTranslations;
|
|
102
|
+
};
|
|
88
103
|
export declare const FolderField: <T extends string>({ field, props, }: FormReact.FieldComponentProps<T, FolderFieldOptions<T>>) => JSX.Element;
|
|
89
104
|
type MultiSelectFieldOptions<T extends string> = FieldOptions & {
|
|
90
105
|
options: ReadonlyArray<{
|
|
@@ -99,7 +114,8 @@ type SearchableSelectFieldSharedOptions<TData> = FieldOptions & {
|
|
|
99
114
|
emptyLabel: ReactNode;
|
|
100
115
|
initialItems?: readonly VirtualizedComboboxOption<TData>[];
|
|
101
116
|
items: readonly VirtualizedComboboxOption<TData>[];
|
|
102
|
-
|
|
117
|
+
locale?: string;
|
|
118
|
+
messages?: VirtualizedComboboxMessageTranslations;
|
|
103
119
|
onSearchValueChange?: (value: string) => void;
|
|
104
120
|
placeholder: ReactNode;
|
|
105
121
|
renderItem?: (item: VirtualizedComboboxOption<TData>) => ReactNode;
|
|
@@ -111,19 +127,30 @@ export declare const SearchableSelectField: <TData>({ field, props, }: FormReact
|
|
|
111
127
|
export declare const SingleSearchableSelectField: <TData>({ field, props, }: FormReact.FieldComponentProps<string, SearchableSelectFieldSharedOptions<TData> & {
|
|
112
128
|
multiple?: false;
|
|
113
129
|
}>) => JSX.Element;
|
|
114
|
-
export declare const NullableKeyValueField: ({ field, props, }: FormReact.FieldComponentProps<Readonly<Record<string, string>> | null, FieldOptions
|
|
115
|
-
|
|
130
|
+
export declare const NullableKeyValueField: ({ field, props, }: FormReact.FieldComponentProps<Readonly<Record<string, string>> | null, FieldOptions & {
|
|
131
|
+
locale?: string;
|
|
132
|
+
messages?: EffectFormMessageTranslations;
|
|
133
|
+
}>) => JSX.Element;
|
|
134
|
+
export declare const KeyValueField: ({ field, props, }: FormReact.FieldComponentProps<Readonly<Record<string, string>>, FieldOptions & {
|
|
135
|
+
locale?: string;
|
|
136
|
+
messages?: EffectFormMessageTranslations;
|
|
137
|
+
}>) => JSX.Element;
|
|
116
138
|
export declare const RevertButton: ({ field, props, }: {
|
|
117
139
|
field: {
|
|
118
140
|
value: string;
|
|
119
141
|
onChange: (value: string) => void;
|
|
120
142
|
};
|
|
121
143
|
props: {
|
|
144
|
+
locale?: string;
|
|
145
|
+
messages?: EffectFormMessageTranslations;
|
|
122
146
|
original: string;
|
|
123
147
|
};
|
|
124
148
|
}) => JSX.Element | null;
|
|
125
149
|
type ImageFieldOptions = {
|
|
126
150
|
label: string;
|
|
151
|
+
locale?: string;
|
|
152
|
+
messages?: EffectFormMessageTranslations;
|
|
153
|
+
filePickerMessages?: FilePickerMessageTranslations;
|
|
127
154
|
size: {
|
|
128
155
|
width: number;
|
|
129
156
|
height: number;
|
|
@@ -132,7 +159,9 @@ type ImageFieldOptions = {
|
|
|
132
159
|
};
|
|
133
160
|
};
|
|
134
161
|
export declare const ImageField: FormReact.FieldComponent<File | string | null | undefined, ImageFieldOptions>;
|
|
135
|
-
export declare const BlockNavigation: <A, E>(
|
|
162
|
+
export declare const BlockNavigation: <A, E>(props: {
|
|
136
163
|
form: SubmitForm<A, E>;
|
|
164
|
+
locale?: string;
|
|
165
|
+
messages?: EffectFormMessageTranslations;
|
|
137
166
|
}) => JSX.Element;
|
|
138
167
|
export {};
|