@komensal/ui 0.2.2 → 0.4.0
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/README.md +92 -0
- package/dist/index.d.ts +550 -3
- package/dist/index.js +101 -20
- package/dist/index.js.map +1 -1
- package/package.json +11 -7
package/dist/index.d.ts
CHANGED
|
@@ -10,6 +10,9 @@ import * as LabelPrimitive from '@radix-ui/react-label';
|
|
|
10
10
|
import { OTPInput } from 'input-otp';
|
|
11
11
|
import * as PopoverPrimitive from '@radix-ui/react-popover';
|
|
12
12
|
import * as SelectPrimitive from '@radix-ui/react-select';
|
|
13
|
+
import { $NormalizeIntoArray } from './typescript/helpers.js';
|
|
14
|
+
import { DefaultNamespace, FlatNamespace, InitOptions, InterpolationOptions, Resource, FormatFunction, ResourceKey, ResourceLanguage, TOptions, Namespace, TypeOptions } from './typescript/options.js';
|
|
15
|
+
import { TFunction, SelectorKey, KeyPrefixSelector, KeyPrefix } from './typescript/t.js';
|
|
13
16
|
import { ClassValue } from 'clsx';
|
|
14
17
|
|
|
15
18
|
interface AlertProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
@@ -130,6 +133,7 @@ declare const DialogOverlay: React.ForwardRefExoticComponent<Omit<DialogPrimitiv
|
|
|
130
133
|
isAbsolute?: boolean;
|
|
131
134
|
} & React.RefAttributes<HTMLDivElement>>;
|
|
132
135
|
interface DialogContentProps extends React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content> {
|
|
136
|
+
closeLabel?: string;
|
|
133
137
|
container?: HTMLElement | null;
|
|
134
138
|
isAbsolute?: boolean;
|
|
135
139
|
isCloseIcon?: boolean;
|
|
@@ -170,8 +174,10 @@ declare const FormDescription: React.ForwardRefExoticComponent<React.HTMLAttribu
|
|
|
170
174
|
declare const FormMessage: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLParagraphElement> & React.RefAttributes<HTMLParagraphElement>>;
|
|
171
175
|
|
|
172
176
|
interface InputFieldProps<T extends FieldValues = FieldValues> {
|
|
177
|
+
clearLabel?: string;
|
|
173
178
|
control: Control<T>;
|
|
174
179
|
disabled?: boolean;
|
|
180
|
+
hidePasswordLabel?: string;
|
|
175
181
|
inputClassName?: string;
|
|
176
182
|
isClearable?: boolean;
|
|
177
183
|
label?: string;
|
|
@@ -180,10 +186,11 @@ interface InputFieldProps<T extends FieldValues = FieldValues> {
|
|
|
180
186
|
name: Path<T>;
|
|
181
187
|
onClear?: () => void;
|
|
182
188
|
placeholder?: string;
|
|
189
|
+
showPasswordLabel?: string;
|
|
183
190
|
type?: string;
|
|
184
191
|
visualRequired?: boolean;
|
|
185
192
|
}
|
|
186
|
-
declare const InputField: <T extends FieldValues = FieldValues>({ control, disabled, inputClassName, isClearable, label, labelClassName, mainClassName, name, onClear, placeholder, type, visualRequired }: InputFieldProps<T>) => React.JSX.Element;
|
|
193
|
+
declare const InputField: <T extends FieldValues = FieldValues>({ clearLabel, control, disabled, hidePasswordLabel, inputClassName, isClearable, label, labelClassName, mainClassName, name, onClear, placeholder, showPasswordLabel, type, visualRequired }: InputFieldProps<T>) => React.JSX.Element;
|
|
187
194
|
|
|
188
195
|
interface LabelFieldProps {
|
|
189
196
|
label?: string;
|
|
@@ -193,12 +200,23 @@ interface LabelFieldProps {
|
|
|
193
200
|
}
|
|
194
201
|
declare const LabelField: ({ label, labelClassName, name, visualRequired }: LabelFieldProps) => React.JSX.Element;
|
|
195
202
|
|
|
203
|
+
interface ResolvedAddress {
|
|
204
|
+
address: string;
|
|
205
|
+
city: null | string;
|
|
206
|
+
country: null | string;
|
|
207
|
+
countryName: null | string;
|
|
208
|
+
department: null | string;
|
|
209
|
+
lat: null | number;
|
|
210
|
+
lng: null | number;
|
|
211
|
+
}
|
|
196
212
|
interface GoogleMapPickerProps {
|
|
197
213
|
centerOn?: google.maps.LatLngLiteral;
|
|
214
|
+
countryCode?: string;
|
|
198
215
|
disabled?: boolean;
|
|
199
216
|
hasError?: boolean;
|
|
200
217
|
locationQuery?: string;
|
|
201
218
|
locationZoom?: number;
|
|
219
|
+
onAddressResolved?: (resolved: ResolvedAddress) => void;
|
|
202
220
|
onChange: (address: string) => void;
|
|
203
221
|
placeholder?: string;
|
|
204
222
|
value: string;
|
|
@@ -312,6 +330,8 @@ interface SelectInputProps<Label extends string, Value extends string> {
|
|
|
312
330
|
labelKey?: string;
|
|
313
331
|
leftIcon?: JSX.Element;
|
|
314
332
|
loading?: boolean;
|
|
333
|
+
loadingLabel?: string;
|
|
334
|
+
noResultsLabel?: string;
|
|
315
335
|
onBlur?: Noop;
|
|
316
336
|
onChange?: (...event: unknown[]) => void;
|
|
317
337
|
onValueChangeCallBack?: (item: {
|
|
@@ -321,6 +341,7 @@ interface SelectInputProps<Label extends string, Value extends string> {
|
|
|
321
341
|
placeholder?: string;
|
|
322
342
|
placeholderClassName?: string;
|
|
323
343
|
search?: boolean;
|
|
344
|
+
searchPlaceholder?: string;
|
|
324
345
|
timeField?: boolean;
|
|
325
346
|
value?: string;
|
|
326
347
|
valueKey?: string;
|
|
@@ -341,10 +362,11 @@ declare const variants: {
|
|
|
341
362
|
};
|
|
342
363
|
interface SpinnerProps {
|
|
343
364
|
className?: string;
|
|
365
|
+
loadingLabel?: string;
|
|
344
366
|
size?: keyof typeof sizes;
|
|
345
367
|
variant?: keyof typeof variants;
|
|
346
368
|
}
|
|
347
|
-
declare const Spinner: ({ className, size, variant }: SpinnerProps) => React.JSX.Element;
|
|
369
|
+
declare const Spinner: ({ className, loadingLabel, size, variant }: SpinnerProps) => React.JSX.Element;
|
|
348
370
|
|
|
349
371
|
interface StepHeaderProps {
|
|
350
372
|
subtitle?: ReactNode;
|
|
@@ -400,6 +422,531 @@ interface WrapperProps {
|
|
|
400
422
|
}
|
|
401
423
|
declare const Wrapper: ({ children, className }: WrapperProps) => React.JSX.Element;
|
|
402
424
|
|
|
425
|
+
// Internal Helpers
|
|
426
|
+
|
|
427
|
+
|
|
428
|
+
interface Interpolator {
|
|
429
|
+
init(options: InterpolationOptions, reset: boolean): undefined;
|
|
430
|
+
reset(): undefined;
|
|
431
|
+
resetRegExp(): undefined;
|
|
432
|
+
interpolate(str: string, data: object, lng: string, options: InterpolationOptions): string;
|
|
433
|
+
nest(str: string, fc: (...args: any[]) => any, options: InterpolationOptions): string;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
declare class ResourceStore {
|
|
437
|
+
constructor(data: Resource, options: InitOptions);
|
|
438
|
+
|
|
439
|
+
public data: Resource;
|
|
440
|
+
|
|
441
|
+
public options: InitOptions;
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* Gets fired when resources got added or removed
|
|
445
|
+
*/
|
|
446
|
+
on(event: 'added' | 'removed', callback: (lng: string, ns: string) => void): void;
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* Remove event listener
|
|
450
|
+
* removes all callback when callback not specified
|
|
451
|
+
*/
|
|
452
|
+
off(event: 'added' | 'removed', callback?: (lng: string, ns: string) => void): void;
|
|
453
|
+
|
|
454
|
+
/**
|
|
455
|
+
* Subscribe to an event, but only once. The listener is removed after the first call.
|
|
456
|
+
*/
|
|
457
|
+
once(event: 'added' | 'removed', callback: (lng: string, ns: string) => void): this;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
interface Formatter {
|
|
461
|
+
init(services: Services, i18nextOptions: InitOptions): void;
|
|
462
|
+
add(name: string, fc: (value: any, lng: string | undefined, options: any) => string): void;
|
|
463
|
+
addCached(
|
|
464
|
+
name: string,
|
|
465
|
+
fc: (lng: string | undefined, options: any) => (value: any) => string,
|
|
466
|
+
): void;
|
|
467
|
+
format: FormatFunction;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
interface Services {
|
|
471
|
+
backendConnector: any;
|
|
472
|
+
i18nFormat: any;
|
|
473
|
+
interpolator: Interpolator;
|
|
474
|
+
languageDetector: any;
|
|
475
|
+
languageUtils: any;
|
|
476
|
+
logger: any;
|
|
477
|
+
pluralResolver: any;
|
|
478
|
+
resourceStore: ResourceStore;
|
|
479
|
+
formatter?: Formatter;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
type ModuleType =
|
|
483
|
+
| 'backend'
|
|
484
|
+
| 'logger'
|
|
485
|
+
| 'languageDetector'
|
|
486
|
+
| 'postProcessor'
|
|
487
|
+
| 'i18nFormat'
|
|
488
|
+
| 'formatter'
|
|
489
|
+
| '3rdParty';
|
|
490
|
+
|
|
491
|
+
interface Module {
|
|
492
|
+
type: ModuleType;
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
type CallbackError = Error | string | null | undefined;
|
|
496
|
+
type ReadCallback = (
|
|
497
|
+
err: CallbackError,
|
|
498
|
+
data: ResourceKey | boolean | null | undefined,
|
|
499
|
+
) => void;
|
|
500
|
+
type MultiReadCallback = (err: CallbackError, data: Resource | null | undefined) => void;
|
|
501
|
+
|
|
502
|
+
/**
|
|
503
|
+
* Used to load data for i18next.
|
|
504
|
+
* Can be provided as a singleton or as a prototype constructor (preferred for supporting multiple instances of i18next).
|
|
505
|
+
* For singleton set property `type` to `'backend'` For a prototype constructor set static property.
|
|
506
|
+
*/
|
|
507
|
+
interface BackendModule<Options = object> extends Module {
|
|
508
|
+
type: 'backend';
|
|
509
|
+
init(services: Services, backendOptions: Options, i18nextOptions: InitOptions): void;
|
|
510
|
+
read(language: string, namespace: string, callback: ReadCallback): void;
|
|
511
|
+
/** Save the missing translation */
|
|
512
|
+
create?(
|
|
513
|
+
languages: readonly string[],
|
|
514
|
+
namespace: string,
|
|
515
|
+
key: string,
|
|
516
|
+
fallbackValue: string,
|
|
517
|
+
): void;
|
|
518
|
+
/** Load multiple languages and namespaces. For backends supporting multiple resources loading */
|
|
519
|
+
readMulti?(
|
|
520
|
+
languages: readonly string[],
|
|
521
|
+
namespaces: readonly string[],
|
|
522
|
+
callback: MultiReadCallback,
|
|
523
|
+
): void;
|
|
524
|
+
/** Store the translation. For backends acting as cache layer */
|
|
525
|
+
save?(language: string, namespace: string, data: ResourceLanguage): void;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
/**
|
|
529
|
+
* Used to detect language in user land.
|
|
530
|
+
* Can be provided as a singleton or as a prototype constructor (preferred for supporting multiple instances of i18next).
|
|
531
|
+
* For singleton set property `type` to `'languageDetector'` For a prototype constructor set static property.
|
|
532
|
+
*/
|
|
533
|
+
interface LanguageDetectorModule extends Module {
|
|
534
|
+
type: 'languageDetector';
|
|
535
|
+
init?(services: Services, detectorOptions: object, i18nextOptions: InitOptions): void;
|
|
536
|
+
/** Must return detected language */
|
|
537
|
+
detect(): string | readonly string[] | undefined;
|
|
538
|
+
cacheUserLanguage?(lng: string): void;
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
/**
|
|
542
|
+
* Used to detect language in user land.
|
|
543
|
+
* Can be provided as a singleton or as a prototype constructor (preferred for supporting multiple instances of i18next).
|
|
544
|
+
* For singleton set property `type` to `'languageDetector'` For a prototype constructor set static property.
|
|
545
|
+
*/
|
|
546
|
+
interface LanguageDetectorAsyncModule extends Module {
|
|
547
|
+
type: 'languageDetector';
|
|
548
|
+
/** Set to true to enable async detection */
|
|
549
|
+
async: true;
|
|
550
|
+
init?(services: Services, detectorOptions: object, i18nextOptions: InitOptions): void;
|
|
551
|
+
/** Must call callback passing detected language or return a Promise */
|
|
552
|
+
detect(
|
|
553
|
+
callback: (lng: string | readonly string[] | undefined) => void | undefined,
|
|
554
|
+
): void | Promise<string | readonly string[] | undefined>;
|
|
555
|
+
cacheUserLanguage?(lng: string): void | Promise<void>;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
/**
|
|
559
|
+
* Override the built-in console logger.
|
|
560
|
+
* Do not need to be a prototype function.
|
|
561
|
+
*/
|
|
562
|
+
interface LoggerModule extends Module {
|
|
563
|
+
type: 'logger';
|
|
564
|
+
log(...args: any[]): void;
|
|
565
|
+
warn(...args: any[]): void;
|
|
566
|
+
error(...args: any[]): void;
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
interface I18nFormatModule extends Module {
|
|
570
|
+
type: 'i18nFormat';
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
interface FormatterModule extends Module, Formatter {
|
|
574
|
+
type: 'formatter';
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
interface ThirdPartyModule extends Module {
|
|
578
|
+
type: '3rdParty';
|
|
579
|
+
init(i18next: i18n): void;
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
interface Modules {
|
|
583
|
+
backend?: BackendModule;
|
|
584
|
+
logger?: LoggerModule;
|
|
585
|
+
languageDetector?: LanguageDetectorModule | LanguageDetectorAsyncModule;
|
|
586
|
+
i18nFormat?: I18nFormatModule;
|
|
587
|
+
formatter?: FormatterModule;
|
|
588
|
+
external: ThirdPartyModule[];
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
// helper to identify class https://stackoverflow.com/a/45983481/2363935
|
|
592
|
+
interface Newable<T> {
|
|
593
|
+
new (...args: any[]): T;
|
|
594
|
+
}
|
|
595
|
+
interface NewableModule<T extends Module> extends Newable<T> {
|
|
596
|
+
type: T['type'];
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
type Callback = (error: any, t: TFunction) => void;
|
|
600
|
+
|
|
601
|
+
interface CloneOptions extends InitOptions {
|
|
602
|
+
/**
|
|
603
|
+
* Will create a new instance of the resource store and import the existing translation resources.
|
|
604
|
+
* This way it will not shared the resource store instance.
|
|
605
|
+
* @default false
|
|
606
|
+
*/
|
|
607
|
+
forkResourceStore?: boolean;
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
interface CustomInstanceExtensions {}
|
|
611
|
+
|
|
612
|
+
// Used just here to exclude `DefaultNamespace` which can be both string or array from `FlatNamespace`
|
|
613
|
+
// in TFunction declaration below.
|
|
614
|
+
// Due to this only very special usage I'm not moving this inside helpers.
|
|
615
|
+
type InferArrayValuesElseReturnType<T> = T extends (infer A)[] ? A : T;
|
|
616
|
+
|
|
617
|
+
interface i18n extends CustomInstanceExtensions {
|
|
618
|
+
// Expose parameterized t in the i18next interface hierarchy
|
|
619
|
+
t: TFunction<
|
|
620
|
+
[
|
|
621
|
+
...$NormalizeIntoArray<DefaultNamespace>,
|
|
622
|
+
...Exclude<FlatNamespace, InferArrayValuesElseReturnType<DefaultNamespace>>[],
|
|
623
|
+
]
|
|
624
|
+
>;
|
|
625
|
+
|
|
626
|
+
/**
|
|
627
|
+
* The default of the i18next module is an i18next instance ready to be initialized by calling init.
|
|
628
|
+
* You can create additional instances using the createInstance function.
|
|
629
|
+
*
|
|
630
|
+
* @param options - Initial options.
|
|
631
|
+
* @param callback - will be called after all translations were loaded or with an error when failed (in case of using a backend).
|
|
632
|
+
*/
|
|
633
|
+
init(callback?: Callback): Promise<TFunction>;
|
|
634
|
+
init<T>(options: InitOptions<T>, callback?: Callback): Promise<TFunction>;
|
|
635
|
+
|
|
636
|
+
loadResources(callback?: (err: any) => void): void;
|
|
637
|
+
|
|
638
|
+
/**
|
|
639
|
+
* The use function is there to load additional plugins to i18next.
|
|
640
|
+
* For available module see the plugins page and don't forget to read the documentation of the plugin.
|
|
641
|
+
*
|
|
642
|
+
* @param module Accepts a class or object
|
|
643
|
+
*/
|
|
644
|
+
use<T extends Module>(module: T | NewableModule<T> | Newable<T>): this;
|
|
645
|
+
|
|
646
|
+
/**
|
|
647
|
+
* List of modules used
|
|
648
|
+
*/
|
|
649
|
+
modules: Modules;
|
|
650
|
+
|
|
651
|
+
/**
|
|
652
|
+
* Internal container for all used plugins and implementation details like languageUtils, pluralResolvers, etc.
|
|
653
|
+
*/
|
|
654
|
+
services: Services;
|
|
655
|
+
|
|
656
|
+
/**
|
|
657
|
+
* Internal container for translation resources
|
|
658
|
+
*/
|
|
659
|
+
store: ResourceStore;
|
|
660
|
+
|
|
661
|
+
/**
|
|
662
|
+
* Uses similar args as the t function and returns true if a key exists.
|
|
663
|
+
* Acts as a type guard on single-key calls, narrowing the key to
|
|
664
|
+
* {@link SelectorKey} so it can be passed to `t()`.
|
|
665
|
+
*/
|
|
666
|
+
exists: {
|
|
667
|
+
<K extends string>(key: K, options?: TOptions): key is K & SelectorKey;
|
|
668
|
+
(key: string | string[], options?: TOptions): boolean;
|
|
669
|
+
};
|
|
670
|
+
|
|
671
|
+
/**
|
|
672
|
+
* Returns a resource data by language.
|
|
673
|
+
*/
|
|
674
|
+
getDataByLanguage(lng: string): { [key: string]: { [key: string]: string } } | undefined;
|
|
675
|
+
|
|
676
|
+
/**
|
|
677
|
+
* Returns a t function that defaults to given language or namespace.
|
|
678
|
+
* Both params could be arrays of languages or namespaces and will be treated as fallbacks in that case.
|
|
679
|
+
* On the returned function you can like in the t function override the languages or namespaces by passing them in options or by prepending namespace.
|
|
680
|
+
*
|
|
681
|
+
* Accepts optional keyPrefix that will be automatically applied to returned t function.
|
|
682
|
+
*/
|
|
683
|
+
getFixedT<
|
|
684
|
+
Ns extends Namespace | null,
|
|
685
|
+
const TKPrefixFn extends TypeOptions['enableSelector'] extends true | 'optimize'
|
|
686
|
+
? KeyPrefixSelector<ActualNs>
|
|
687
|
+
: never,
|
|
688
|
+
ActualNs extends Namespace = Ns extends null ? DefaultNamespace : Ns,
|
|
689
|
+
>(
|
|
690
|
+
lng: string | readonly string[] | null,
|
|
691
|
+
ns: Ns,
|
|
692
|
+
keyPrefix: TKPrefixFn,
|
|
693
|
+
): TFunction<ActualNs, TKPrefixFn>;
|
|
694
|
+
|
|
695
|
+
getFixedT<
|
|
696
|
+
Ns extends Namespace | null = DefaultNamespace,
|
|
697
|
+
TKPrefix extends KeyPrefix<ActualNs> = undefined,
|
|
698
|
+
ActualNs extends Namespace = Ns extends null ? DefaultNamespace : Ns,
|
|
699
|
+
>(
|
|
700
|
+
...args:
|
|
701
|
+
| [lng: string | readonly string[], ns?: Ns, keyPrefix?: TKPrefix | (($: any) => any)]
|
|
702
|
+
| [lng: null, ns: Ns, keyPrefix?: TKPrefix | (($: any) => any)]
|
|
703
|
+
): TFunction<ActualNs, TKPrefix>;
|
|
704
|
+
|
|
705
|
+
/**
|
|
706
|
+
* Changes the language. The callback will be called as soon translations were loaded or an error occurs while loading.
|
|
707
|
+
* HINT: For easy testing - setting lng to 'cimode' will set t function to always return the key.
|
|
708
|
+
*/
|
|
709
|
+
changeLanguage(lng?: string, callback?: Callback): Promise<TFunction>;
|
|
710
|
+
|
|
711
|
+
/**
|
|
712
|
+
* Is set to the current detected or set language.
|
|
713
|
+
* If you need the primary used language depending on your configuration (supportedLngs, load) you will prefer using i18next.languages[0].
|
|
714
|
+
*/
|
|
715
|
+
language: string;
|
|
716
|
+
|
|
717
|
+
/**
|
|
718
|
+
* Is set to an array of language-codes that will be used it order to lookup the translation value.
|
|
719
|
+
*/
|
|
720
|
+
languages: readonly string[];
|
|
721
|
+
|
|
722
|
+
/**
|
|
723
|
+
* Is set to the current resolved language.
|
|
724
|
+
* It can be used as primary used language, for example in a language switcher.
|
|
725
|
+
*/
|
|
726
|
+
resolvedLanguage?: string;
|
|
727
|
+
|
|
728
|
+
/**
|
|
729
|
+
* Checks if namespace has loaded yet.
|
|
730
|
+
* i.e. used by react-i18next
|
|
731
|
+
*/
|
|
732
|
+
hasLoadedNamespace(
|
|
733
|
+
ns: string | readonly string[],
|
|
734
|
+
options?: {
|
|
735
|
+
lng?: string | readonly string[];
|
|
736
|
+
fallbackLng?: InitOptions['fallbackLng'];
|
|
737
|
+
/**
|
|
738
|
+
* if `undefined` is returned default checks are performed.
|
|
739
|
+
*/
|
|
740
|
+
precheck?: (
|
|
741
|
+
i18n: i18n,
|
|
742
|
+
/**
|
|
743
|
+
* Check if the language namespace provided are not in loading status:
|
|
744
|
+
* returns `true` if load is completed successfully or with an error.
|
|
745
|
+
*/
|
|
746
|
+
loadNotPending: (
|
|
747
|
+
lng: string | readonly string[],
|
|
748
|
+
ns: string | readonly string[],
|
|
749
|
+
) => boolean,
|
|
750
|
+
) => boolean | undefined;
|
|
751
|
+
},
|
|
752
|
+
): boolean;
|
|
753
|
+
|
|
754
|
+
/**
|
|
755
|
+
* Loads additional namespaces not defined in init options.
|
|
756
|
+
*/
|
|
757
|
+
loadNamespaces(ns: string | readonly string[], callback?: Callback): Promise<void>;
|
|
758
|
+
|
|
759
|
+
/**
|
|
760
|
+
* Loads additional languages not defined in init options (preload).
|
|
761
|
+
*/
|
|
762
|
+
loadLanguages(lngs: string | readonly string[], callback?: Callback): Promise<void>;
|
|
763
|
+
|
|
764
|
+
/**
|
|
765
|
+
* Reloads resources on given state. Optionally you can pass an array of languages and namespaces as params if you don't want to reload all.
|
|
766
|
+
*/
|
|
767
|
+
reloadResources(
|
|
768
|
+
lngs?: string | readonly string[],
|
|
769
|
+
ns?: string | readonly string[],
|
|
770
|
+
callback?: () => void,
|
|
771
|
+
): Promise<void>;
|
|
772
|
+
reloadResources(lngs: null, ns: string | readonly string[], callback?: () => void): Promise<void>;
|
|
773
|
+
|
|
774
|
+
/**
|
|
775
|
+
* Changes the default namespace.
|
|
776
|
+
*/
|
|
777
|
+
setDefaultNamespace(ns: string | readonly string[]): void;
|
|
778
|
+
|
|
779
|
+
/**
|
|
780
|
+
* Returns rtl or ltr depending on languages read direction.
|
|
781
|
+
*/
|
|
782
|
+
dir(lng?: string): 'ltr' | 'rtl';
|
|
783
|
+
|
|
784
|
+
/**
|
|
785
|
+
* Exposes interpolation.format function added on init.
|
|
786
|
+
*/
|
|
787
|
+
format: FormatFunction;
|
|
788
|
+
|
|
789
|
+
/**
|
|
790
|
+
* Will return a new i18next instance.
|
|
791
|
+
* Please read the options page for details on configuration options.
|
|
792
|
+
* Providing a callback will automatically call init.
|
|
793
|
+
* The callback will be called after all translations were loaded or with an error when failed (in case of using a backend).
|
|
794
|
+
*/
|
|
795
|
+
createInstance(options?: InitOptions, callback?: Callback): i18n;
|
|
796
|
+
|
|
797
|
+
/**
|
|
798
|
+
* Creates a clone of the current instance. Shares store, plugins and initial configuration.
|
|
799
|
+
* Can be used to create an instance sharing storage but being independent on set language or namespaces.
|
|
800
|
+
*/
|
|
801
|
+
cloneInstance(options?: CloneOptions, callback?: Callback): i18n;
|
|
802
|
+
|
|
803
|
+
/**
|
|
804
|
+
* Returns a JSON representation of the i18next instance for serialization.
|
|
805
|
+
*/
|
|
806
|
+
toJSON(): {
|
|
807
|
+
options: InitOptions;
|
|
808
|
+
store: ResourceStore;
|
|
809
|
+
language: string;
|
|
810
|
+
languages: readonly string[];
|
|
811
|
+
resolvedLanguage?: string;
|
|
812
|
+
};
|
|
813
|
+
|
|
814
|
+
/**
|
|
815
|
+
* Gets fired after initialization.
|
|
816
|
+
*/
|
|
817
|
+
on(event: 'initialized', callback: (options: InitOptions) => void): this;
|
|
818
|
+
|
|
819
|
+
/**
|
|
820
|
+
* Gets fired on loaded resources.
|
|
821
|
+
*/
|
|
822
|
+
on(
|
|
823
|
+
event: 'loaded',
|
|
824
|
+
callback: (loaded: { [language: string]: { [namespace: string]: boolean } }) => void,
|
|
825
|
+
): this;
|
|
826
|
+
|
|
827
|
+
/**
|
|
828
|
+
* Gets fired if loading resources failed.
|
|
829
|
+
*/
|
|
830
|
+
on(event: 'failedLoading', callback: (lng: string, ns: string, msg: string) => void): this;
|
|
831
|
+
|
|
832
|
+
/**
|
|
833
|
+
* Gets fired on accessing a key not existing.
|
|
834
|
+
*/
|
|
835
|
+
on(
|
|
836
|
+
event: 'missingKey',
|
|
837
|
+
callback: (lngs: readonly string[], namespace: string, key: string, res: string) => void,
|
|
838
|
+
): this;
|
|
839
|
+
|
|
840
|
+
/**
|
|
841
|
+
* Gets fired when changeLanguage got called.
|
|
842
|
+
*/
|
|
843
|
+
on(event: 'languageChanged', callback: (lng: string) => void): this;
|
|
844
|
+
|
|
845
|
+
/**
|
|
846
|
+
* Event listener
|
|
847
|
+
*/
|
|
848
|
+
on(event: string, listener: (...args: any[]) => void): this;
|
|
849
|
+
|
|
850
|
+
/**
|
|
851
|
+
* Remove event listener
|
|
852
|
+
* removes all callback when callback not specified
|
|
853
|
+
*/
|
|
854
|
+
off(event: string, listener?: (...args: any[]) => void): void;
|
|
855
|
+
|
|
856
|
+
/**
|
|
857
|
+
* Subscribe to an event, but only once. The listener is removed after the first call.
|
|
858
|
+
*/
|
|
859
|
+
once(event: string, listener: (...args: any[]) => void): this;
|
|
860
|
+
|
|
861
|
+
/**
|
|
862
|
+
* Gets one value by given key.
|
|
863
|
+
*/
|
|
864
|
+
getResource(
|
|
865
|
+
lng: string,
|
|
866
|
+
ns: string,
|
|
867
|
+
key: string,
|
|
868
|
+
options?: Pick<InitOptions, 'keySeparator' | 'ignoreJSONStructure'>,
|
|
869
|
+
): any;
|
|
870
|
+
|
|
871
|
+
/**
|
|
872
|
+
* Adds one key/value.
|
|
873
|
+
*/
|
|
874
|
+
addResource(
|
|
875
|
+
lng: string,
|
|
876
|
+
ns: string,
|
|
877
|
+
key: string,
|
|
878
|
+
value: string,
|
|
879
|
+
options?: { keySeparator?: string; silent?: boolean },
|
|
880
|
+
): i18n;
|
|
881
|
+
|
|
882
|
+
/**
|
|
883
|
+
* Adds multiple key/values.
|
|
884
|
+
*/
|
|
885
|
+
addResources(lng: string, ns: string, resources: any): i18n;
|
|
886
|
+
|
|
887
|
+
/**
|
|
888
|
+
* Adds a complete bundle.
|
|
889
|
+
* Setting deep param to true will extend existing translations in that file.
|
|
890
|
+
* Setting overwrite to true it will overwrite existing translations in that file.
|
|
891
|
+
*/
|
|
892
|
+
addResourceBundle(
|
|
893
|
+
lng: string,
|
|
894
|
+
ns: string,
|
|
895
|
+
resources: any,
|
|
896
|
+
deep?: boolean,
|
|
897
|
+
overwrite?: boolean,
|
|
898
|
+
options?: { silent?: boolean; skipCopy?: boolean },
|
|
899
|
+
): i18n;
|
|
900
|
+
|
|
901
|
+
/**
|
|
902
|
+
* Checks if a resource bundle exists.
|
|
903
|
+
*/
|
|
904
|
+
hasResourceBundle(lng: string, ns: string): boolean;
|
|
905
|
+
|
|
906
|
+
/**
|
|
907
|
+
* Returns a resource bundle.
|
|
908
|
+
*/
|
|
909
|
+
getResourceBundle(lng: string, ns: string): any;
|
|
910
|
+
|
|
911
|
+
/**
|
|
912
|
+
* Removes an existing bundle.
|
|
913
|
+
*/
|
|
914
|
+
removeResourceBundle(lng: string, ns: string): i18n;
|
|
915
|
+
|
|
916
|
+
/**
|
|
917
|
+
* Current options
|
|
918
|
+
*/
|
|
919
|
+
options: InitOptions;
|
|
920
|
+
|
|
921
|
+
/**
|
|
922
|
+
* Is initialized
|
|
923
|
+
*/
|
|
924
|
+
isInitialized: boolean;
|
|
925
|
+
|
|
926
|
+
/**
|
|
927
|
+
* Is initializing
|
|
928
|
+
*/
|
|
929
|
+
isInitializing: boolean;
|
|
930
|
+
|
|
931
|
+
/**
|
|
932
|
+
* Store was initialized
|
|
933
|
+
*/
|
|
934
|
+
initializedStoreOnce: boolean;
|
|
935
|
+
|
|
936
|
+
/**
|
|
937
|
+
* Language was initialized
|
|
938
|
+
*/
|
|
939
|
+
initializedLanguageOnce: boolean;
|
|
940
|
+
|
|
941
|
+
/**
|
|
942
|
+
* Emit event
|
|
943
|
+
*/
|
|
944
|
+
emit(eventName: string, ...args: any[]): void;
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
declare const uiI18n: i18n;
|
|
948
|
+
declare const setUiLanguage: (lng: string) => Promise<unknown>;
|
|
949
|
+
|
|
403
950
|
declare function cn(...inputs: ClassValue[]): string;
|
|
404
951
|
|
|
405
952
|
declare const inputBase: string;
|
|
@@ -417,4 +964,4 @@ declare const toast: {
|
|
|
417
964
|
};
|
|
418
965
|
declare function registerToastEmitter(fn: ToastEmitter): void;
|
|
419
966
|
|
|
420
|
-
export { Alert, AuthHeader, Button, type ButtonProps, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, GoogleMapPicker, type GoogleMapPickerProps, Input, InputField, InputOTP, InputOTPGroup, InputOTPSlot, type InputProps, Label, LabelField, Loading, MapPickerField, OTPField, type Options, PasswordChecklist, type PasswordRule, type PasswordRulesConfig, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, Select, SelectContent, SelectField, SelectGroup, SelectInput, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Spinner, type SpinnerProps, StepHeader, Stepper, type StepperStep, Toast, type ToastOptions, type ToastPosition, ToastProvider, type ToastType, Tooltip, Wrapper, type WrapperProps, buttonVariants, cn, inputBase, inputDisabled, inputFocus, inputPlaceholder, registerToastEmitter, toast, useFormField };
|
|
967
|
+
export { Alert, AuthHeader, Button, type ButtonProps, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, GoogleMapPicker, type GoogleMapPickerProps, Input, InputField, InputOTP, InputOTPGroup, InputOTPSlot, type InputProps, Label, LabelField, Loading, MapPickerField, OTPField, type Options, PasswordChecklist, type PasswordRule, type PasswordRulesConfig, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, type ResolvedAddress, Select, SelectContent, SelectField, SelectGroup, SelectInput, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Spinner, type SpinnerProps, StepHeader, Stepper, type StepperStep, Toast, type ToastOptions, type ToastPosition, ToastProvider, type ToastType, Tooltip, Wrapper, type WrapperProps, buttonVariants, cn, inputBase, inputDisabled, inputFocus, inputPlaceholder, registerToastEmitter, setUiLanguage, toast, uiI18n, useFormField };
|