@snack-uikit/locale 0.12.3-preview-efee8b3e.0 → 0.13.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.
Files changed (36) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +17 -70
  3. package/dist/cjs/components/LocaleProvider/LocaleProvider.d.ts +8 -36
  4. package/dist/cjs/components/LocaleProvider/LocaleProvider.js +34 -78
  5. package/dist/cjs/components/LocaleProvider/hooks.d.ts +16 -0
  6. package/dist/cjs/components/LocaleProvider/hooks.js +38 -0
  7. package/dist/cjs/components/LocaleProvider/index.d.ts +2 -1
  8. package/dist/cjs/components/LocaleProvider/index.js +3 -8
  9. package/dist/cjs/locales/en_GB.d.ts +9 -0
  10. package/dist/cjs/locales/en_GB.js +9 -0
  11. package/dist/cjs/locales/index.d.ts +18 -0
  12. package/dist/cjs/locales/ru_RU.js +9 -0
  13. package/dist/cjs/types.d.ts +5 -10
  14. package/dist/esm/components/LocaleProvider/LocaleProvider.d.ts +8 -36
  15. package/dist/esm/components/LocaleProvider/LocaleProvider.js +23 -62
  16. package/dist/esm/components/LocaleProvider/hooks.d.ts +16 -0
  17. package/dist/esm/components/LocaleProvider/hooks.js +30 -0
  18. package/dist/esm/components/LocaleProvider/index.d.ts +2 -1
  19. package/dist/esm/components/LocaleProvider/index.js +2 -1
  20. package/dist/esm/locales/en_GB.d.ts +9 -0
  21. package/dist/esm/locales/en_GB.js +9 -0
  22. package/dist/esm/locales/index.d.ts +18 -0
  23. package/dist/esm/locales/ru_RU.js +9 -0
  24. package/dist/esm/types.d.ts +5 -10
  25. package/package.json +2 -2
  26. package/src/components/LocaleProvider/LocaleProvider.tsx +32 -113
  27. package/src/components/LocaleProvider/hooks.ts +62 -0
  28. package/src/components/LocaleProvider/index.ts +3 -1
  29. package/src/locales/en_GB.ts +10 -3
  30. package/src/locales/ru_RU.ts +9 -0
  31. package/src/types.ts +8 -18
  32. package/dist/cjs/components/LocaleProvider/Sample.d.ts +0 -10
  33. package/dist/cjs/components/LocaleProvider/Sample.js +0 -111
  34. package/dist/esm/components/LocaleProvider/Sample.d.ts +0 -10
  35. package/dist/esm/components/LocaleProvider/Sample.js +0 -62
  36. package/src/components/LocaleProvider/Sample.tsx +0 -95
@@ -1,111 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.SampleWrapper = SampleWrapper;
7
- exports.OldDictionaryItemSample = OldDictionaryItemSample;
8
- exports.NewDictionarySample = NewDictionarySample;
9
- exports.NewDictSimpleTranslationComponent = NewDictSimpleTranslationComponent;
10
- exports.NewDictDeepTranslationComponent = NewDictDeepTranslationComponent;
11
- const jsx_runtime_1 = require("react/jsx-runtime");
12
- const LocaleProvider_1 = require("./LocaleProvider");
13
- const sampleExtensionEn = {
14
- ButtonPredefined: {
15
- create: 'Create',
16
- cancel: 'Cancel',
17
- refetch: 'Refetch'
18
- },
19
- Site: {
20
- Section: {
21
- Basic: {
22
- ShowMore: 'Show More'
23
- },
24
- PersonalManager: {
25
- title: 'More than regular support',
26
- subtitle: 'Full support for solving your problems and achieving business results'
27
- }
28
- }
29
- }
30
- };
31
- const sampleExtensionRu = {
32
- ButtonPredefined: {
33
- create: 'Создать',
34
- cancel: 'Отмена',
35
- refetch: 'Обновить'
36
- },
37
- Site: {
38
- Section: {
39
- Basic: {
40
- ShowMore: 'Показать еще'
41
- },
42
- PersonalManager: {
43
- title: 'Больше чем просто поддержка',
44
- subtitle: 'Полное сопровождение для решения ваших задач и понятный бизнес-результат'
45
- }
46
- }
47
- }
48
- };
49
- const extension = {
50
- en_GB: sampleExtensionEn,
51
- ru_RU: sampleExtensionRu
52
- };
53
- const {
54
- LocaleProvider,
55
- useLocale
56
- } = (0, LocaleProvider_1.createLocaleContext)({
57
- extendedDictionary: extension
58
- });
59
- function SampleWrapper(_ref) {
60
- let {
61
- children
62
- } = _ref;
63
- return (0, jsx_runtime_1.jsx)(LocaleProvider, {
64
- lang: 'ru_RU',
65
- children: children
66
- });
67
- }
68
- function OldDictionaryItemSample() {
69
- const {
70
- t
71
- } = useLocale('Table');
72
- return (0, jsx_runtime_1.jsxs)("div", {
73
- children: [(0, jsx_runtime_1.jsx)("div", {
74
- children: t('searchPlaceholder')
75
- }), (0, jsx_runtime_1.jsx)("div", {
76
- children: t('noResults.title')
77
- })]
78
- });
79
- }
80
- function NewDictionarySample() {
81
- const {
82
- t
83
- } = useLocale();
84
- return (0, jsx_runtime_1.jsxs)("div", {
85
- children: [(0, jsx_runtime_1.jsx)("div", {
86
- children: t('Table.searchPlaceholder')
87
- }), (0, jsx_runtime_1.jsx)("div", {
88
- children: t('Table.noResults.title')
89
- }), (0, jsx_runtime_1.jsx)("div", {
90
- children: t('ButtonPredefined.create')
91
- }), (0, jsx_runtime_1.jsx)("div", {
92
- children: t('Site.Section.PersonalManager.title')
93
- })]
94
- });
95
- }
96
- function NewDictSimpleTranslationComponent() {
97
- const {
98
- t
99
- } = useLocale('ButtonPredefined');
100
- return (0, jsx_runtime_1.jsx)("div", {
101
- children: t('create')
102
- });
103
- }
104
- function NewDictDeepTranslationComponent() {
105
- const {
106
- t
107
- } = useLocale('Site');
108
- return (0, jsx_runtime_1.jsx)("div", {
109
- children: t('Section.PersonalManager.title')
110
- });
111
- }
@@ -1,10 +0,0 @@
1
- import { ReactNode } from 'react';
2
- type SampleWrapperProps = {
3
- children: ReactNode;
4
- };
5
- export declare function SampleWrapper({ children }: SampleWrapperProps): import("react/jsx-runtime").JSX.Element;
6
- export declare function OldDictionaryItemSample(): import("react/jsx-runtime").JSX.Element;
7
- export declare function NewDictionarySample(): import("react/jsx-runtime").JSX.Element;
8
- export declare function NewDictSimpleTranslationComponent(): import("react/jsx-runtime").JSX.Element;
9
- export declare function NewDictDeepTranslationComponent(): import("react/jsx-runtime").JSX.Element;
10
- export {};
@@ -1,62 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { createLocaleContext } from './LocaleProvider';
3
- const sampleExtensionEn = {
4
- ButtonPredefined: {
5
- create: 'Create',
6
- cancel: 'Cancel',
7
- refetch: 'Refetch',
8
- },
9
- Site: {
10
- Section: {
11
- Basic: {
12
- ShowMore: 'Show More',
13
- },
14
- PersonalManager: {
15
- title: 'More than regular support',
16
- subtitle: 'Full support for solving your problems and achieving business results',
17
- },
18
- },
19
- },
20
- };
21
- const sampleExtensionRu = {
22
- ButtonPredefined: {
23
- create: 'Создать',
24
- cancel: 'Отмена',
25
- refetch: 'Обновить',
26
- },
27
- Site: {
28
- Section: {
29
- Basic: {
30
- ShowMore: 'Показать еще',
31
- },
32
- PersonalManager: {
33
- title: 'Больше чем просто поддержка',
34
- subtitle: 'Полное сопровождение для решения ваших задач и понятный бизнес-результат',
35
- },
36
- },
37
- },
38
- };
39
- const extension = {
40
- en_GB: sampleExtensionEn,
41
- ru_RU: sampleExtensionRu,
42
- };
43
- const { LocaleProvider, useLocale } = createLocaleContext({ extendedDictionary: extension });
44
- export function SampleWrapper({ children }) {
45
- return _jsx(LocaleProvider, { lang: 'ru_RU', children: children });
46
- }
47
- export function OldDictionaryItemSample() {
48
- const { t } = useLocale('Table');
49
- return (_jsxs("div", { children: [_jsx("div", { children: t('searchPlaceholder') }), _jsx("div", { children: t('noResults.title') })] }));
50
- }
51
- export function NewDictionarySample() {
52
- const { t } = useLocale();
53
- return (_jsxs("div", { children: [_jsx("div", { children: t('Table.searchPlaceholder') }), _jsx("div", { children: t('Table.noResults.title') }), _jsx("div", { children: t('ButtonPredefined.create') }), _jsx("div", { children: t('Site.Section.PersonalManager.title') })] }));
54
- }
55
- export function NewDictSimpleTranslationComponent() {
56
- const { t } = useLocale('ButtonPredefined');
57
- return _jsx("div", { children: t('create') });
58
- }
59
- export function NewDictDeepTranslationComponent() {
60
- const { t } = useLocale('Site');
61
- return _jsx("div", { children: t('Section.PersonalManager.title') });
62
- }
@@ -1,95 +0,0 @@
1
- import { ReactNode } from 'react';
2
-
3
- import { Dictionary, ExtendedDictionary } from '../../types';
4
- import { createLocaleContext } from './LocaleProvider';
5
-
6
- const sampleExtensionEn = {
7
- ButtonPredefined: {
8
- create: 'Create',
9
- cancel: 'Cancel',
10
- refetch: 'Refetch',
11
- },
12
- Site: {
13
- Section: {
14
- Basic: {
15
- ShowMore: 'Show More',
16
- },
17
- PersonalManager: {
18
- title: 'More than regular support',
19
- subtitle: 'Full support for solving your problems and achieving business results',
20
- },
21
- },
22
- },
23
- } satisfies Dictionary;
24
-
25
- type ExtensionDictionary = typeof sampleExtensionEn;
26
-
27
- const sampleExtensionRu: ExtensionDictionary = {
28
- ButtonPredefined: {
29
- create: 'Создать',
30
- cancel: 'Отмена',
31
- refetch: 'Обновить',
32
- },
33
- Site: {
34
- Section: {
35
- Basic: {
36
- ShowMore: 'Показать еще',
37
- },
38
- PersonalManager: {
39
- title: 'Больше чем просто поддержка',
40
- subtitle: 'Полное сопровождение для решения ваших задач и понятный бизнес-результат',
41
- },
42
- },
43
- },
44
- };
45
-
46
- const extension: ExtendedDictionary<ExtensionDictionary> = {
47
- en_GB: sampleExtensionEn,
48
- ru_RU: sampleExtensionRu,
49
- } as const;
50
-
51
- type SampleWrapperProps = {
52
- children: ReactNode;
53
- };
54
-
55
- const { LocaleProvider, useLocale } = createLocaleContext({ extendedDictionary: extension });
56
-
57
- export function SampleWrapper({ children }: SampleWrapperProps) {
58
- return <LocaleProvider lang={'ru_RU'}>{children}</LocaleProvider>;
59
- }
60
-
61
- export function OldDictionaryItemSample() {
62
- const { t } = useLocale('Table');
63
-
64
- return (
65
- <div>
66
- <div>{t('searchPlaceholder')}</div>
67
- <div>{t('noResults.title')}</div>
68
- </div>
69
- );
70
- }
71
-
72
- export function NewDictionarySample() {
73
- const { t } = useLocale();
74
-
75
- return (
76
- <div>
77
- <div>{t('Table.searchPlaceholder')}</div>
78
- <div>{t('Table.noResults.title')}</div>
79
- <div>{t('ButtonPredefined.create')}</div>
80
- <div>{t('Site.Section.PersonalManager.title')}</div>
81
- </div>
82
- );
83
- }
84
-
85
- export function NewDictSimpleTranslationComponent() {
86
- const { t } = useLocale('ButtonPredefined');
87
-
88
- return <div>{t('create')}</div>;
89
- }
90
-
91
- export function NewDictDeepTranslationComponent() {
92
- const { t } = useLocale('Site');
93
-
94
- return <div>{t('Section.PersonalManager.title')}</div>;
95
- }