@vygruppen/spor-react 2.3.1 → 2.3.4

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/index.d.ts CHANGED
@@ -10,7 +10,6 @@ import { DateValue } from '@internationalized/date';
10
10
  export { Time } from '@internationalized/date';
11
11
  import { AriaDatePickerProps, AriaDateRangePickerProps, AriaPositionProps, AriaListBoxOptions } from 'react-aria';
12
12
  import { TimeValue } from '@react-types/datepicker';
13
- import * as _leile_lobo_t from '@leile/lobo-t';
14
13
  import { SelectState, ListState } from 'react-stately';
15
14
  export { Item as SelectItem } from 'react-stately';
16
15
  import * as _chakra_ui_theme_tools_dist_component from '@chakra-ui/theme-tools/dist/component';
@@ -505,17 +504,69 @@ declare enum Language {
505
504
  Swedish = "sv",
506
505
  English = "en"
507
506
  }
508
- declare const LanguageProvider: React.Provider<Language>;
509
- declare const useTranslation: () => {
510
- t: _leile_lobo_t.TFunc<typeof Language>;
511
- language: Language;
512
- };
513
- type LanguageObject = {
514
- [key in Language]: string;
507
+ type TranslationObject = {
508
+ [key in Language]: string | React__default.ReactElement;
515
509
  };
516
- type LanguageFunction = (...args: (string | number)[]) => LanguageObject;
510
+ type TranslationFunction = (...args: Array<string | number>) => TranslationObject;
511
+ type Translation = TranslationObject | TranslationFunction;
517
512
  type Translations = {
518
- [key: string]: LanguageObject | LanguageFunction;
513
+ [key: string]: Translation | Translations;
514
+ };
515
+ type LanguageProviderProps = {
516
+ language: Language;
517
+ children: React__default.ReactElement;
518
+ };
519
+ /**
520
+ * A language provider component.
521
+ *
522
+ * This component should wrap your entire application. It will provide the language to all components that use it.
523
+ *
524
+ * This is done by the SporProvider component, so most likely, you won't need to use it directly, unless you want to use a specific language for a specific part of your application.
525
+ *
526
+ * ```tsx
527
+ * import { LanguageProvider, Language } from "@vygruppen/spor-react";
528
+ *
529
+ * const App = () => {
530
+ * return (
531
+ * <LanguageProvider language={Language.NorwegianBokmal}>
532
+ * <Routes />
533
+ * </LanguageProvider>
534
+ * );
535
+ * }
536
+ * ```
537
+ *
538
+ */
539
+ declare function LanguageProvider({ language, children, }: LanguageProviderProps): React__default.JSX.Element;
540
+ /**
541
+ * A hook that returns translation utilities. Typically used to translate text.
542
+ *
543
+ * ```tsx
544
+ * const Example = () => {
545
+ * const { t } = useTranslation();
546
+ * return <p>{t(texts.greeting)}</p>;
547
+ * }
548
+ * const texts = {
549
+ * greeting: {
550
+ * nb: "Hei",
551
+ * nn: "Hei",
552
+ * sv: "Hej",
553
+ * en: "Hello",
554
+ * }
555
+ * }
556
+ * ```
557
+ *
558
+ * You can also use it to fetch the current language:
559
+ *
560
+ * ```tsx
561
+ * const Example = () => {
562
+ * const { language } = useTranslation();
563
+ * return <p>{language}</p>;
564
+ * };
565
+ * ```
566
+ */
567
+ declare function useTranslation(): {
568
+ readonly t: (text: TranslationObject) => string;
569
+ readonly language: Language;
519
570
  };
520
571
  /** Utility function that creates type safe text objects with useTranslation
521
572
  *
@@ -526,6 +577,14 @@ type Translations = {
526
577
  * nn: "Døme",
527
578
  * sv: "Exempel",
528
579
  * en: "Example",
580
+ * },
581
+ * another: {
582
+ * example: {
583
+ * nb: <strong>Eksempel</strong>,
584
+ * nn: <strong>Døme</strong>,
585
+ * sv: <strong>Exempel</strong>,
586
+ * en: <strong>Example</strong>,
587
+ * }
529
588
  * }
530
589
  * })
531
590
  * ```
@@ -692,7 +751,7 @@ type NumericStepperProps = {
692
751
  maxValue?: number;
693
752
  /** Whether the stepper is disabled or not */
694
753
  isDisabled?: boolean;
695
- } & BoxProps;
754
+ } & Omit<BoxProps, "onChange">;
696
755
  /** A simple stepper component for integer values
697
756
  *
698
757
  * Allows you to choose a given integer value, like for example the number of
@@ -1006,7 +1065,7 @@ type CountryCodeAndPhoneNumber = {
1006
1065
  countryCode: string;
1007
1066
  nationalNumber: string;
1008
1067
  };
1009
- type PhoneNumberInputProps = BoxProps & {
1068
+ type PhoneNumberInputProps = Omit<BoxProps, "onChange"> & {
1010
1069
  /** The root name.
1011
1070
  *
1012
1071
  * Please note that when specifying the name, the rendered names will be `${name}-country-code` and `${name}-phone-number`, respectively