@progress/kendo-react-intl 6.1.1 → 7.0.0-develop.2

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 (92) hide show
  1. package/{dist/es/Intl → Intl}/IntlProvider.d.ts +5 -1
  2. package/Intl/IntlProviderProps.d.ts +17 -0
  3. package/{dist/es/Intl → Intl}/IntlService.d.ts +8 -0
  4. package/Intl/main.d.ts +8 -0
  5. package/LICENSE.md +1 -1
  6. package/{dist/es/Localization → Localization}/LocalizationProvider.d.ts +5 -1
  7. package/Localization/LocalizationProviderProps.d.ts +17 -0
  8. package/{dist/npm/Localization → Localization}/LocalizationService.d.ts +4 -0
  9. package/Localization/loadMessages.d.ts +11 -0
  10. package/Localization/main.d.ts +9 -0
  11. package/Localization/messages.d.ts +8 -0
  12. package/coreExports.d.ts +6 -0
  13. package/dist/cdn/js/kendo-react-intl.js +8 -1
  14. package/globalization/GlobalizationContext.d.ts +14 -0
  15. package/hooks/index.d.ts +6 -0
  16. package/hooks/useInternationalization.d.ts +9 -0
  17. package/hooks/useLocalization.d.ts +9 -0
  18. package/index.d.ts +11 -0
  19. package/index.js +8 -0
  20. package/index.mjs +261 -0
  21. package/{dist/npm/intlUtils.d.ts → intlUtils.d.ts} +4 -0
  22. package/package-metadata.d.ts +9 -0
  23. package/package.json +27 -27
  24. package/about.md +0 -3
  25. package/dist/es/Intl/IntlProvider.js +0 -62
  26. package/dist/es/Intl/IntlProviderProps.d.ts +0 -14
  27. package/dist/es/Intl/IntlProviderProps.js +0 -1
  28. package/dist/es/Intl/IntlService.js +0 -149
  29. package/dist/es/Intl/main.d.ts +0 -4
  30. package/dist/es/Intl/main.js +0 -3
  31. package/dist/es/Localization/LocalizationProvider.js +0 -62
  32. package/dist/es/Localization/LocalizationProviderProps.d.ts +0 -14
  33. package/dist/es/Localization/LocalizationProviderProps.js +0 -1
  34. package/dist/es/Localization/LocalizationService.d.ts +0 -16
  35. package/dist/es/Localization/LocalizationService.js +0 -34
  36. package/dist/es/Localization/loadMessages.d.ts +0 -7
  37. package/dist/es/Localization/loadMessages.js +0 -35
  38. package/dist/es/Localization/main.d.ts +0 -5
  39. package/dist/es/Localization/main.js +0 -4
  40. package/dist/es/Localization/messages.d.ts +0 -4
  41. package/dist/es/Localization/messages.js +0 -4
  42. package/dist/es/coreExports.d.ts +0 -1
  43. package/dist/es/coreExports.js +0 -1
  44. package/dist/es/globalization/GlobalizationContext.d.ts +0 -10
  45. package/dist/es/globalization/GlobalizationContext.js +0 -8
  46. package/dist/es/hooks/index.d.ts +0 -2
  47. package/dist/es/hooks/index.js +0 -2
  48. package/dist/es/hooks/useInternationalization.d.ts +0 -5
  49. package/dist/es/hooks/useInternationalization.js +0 -6
  50. package/dist/es/hooks/useLocalization.d.ts +0 -5
  51. package/dist/es/hooks/useLocalization.js +0 -6
  52. package/dist/es/intlUtils.d.ts +0 -27
  53. package/dist/es/intlUtils.js +0 -49
  54. package/dist/es/main.d.ts +0 -7
  55. package/dist/es/main.js +0 -7
  56. package/dist/es/package-metadata.d.ts +0 -5
  57. package/dist/es/package-metadata.js +0 -11
  58. package/dist/npm/Intl/IntlProvider.d.ts +0 -23
  59. package/dist/npm/Intl/IntlProvider.js +0 -65
  60. package/dist/npm/Intl/IntlProviderProps.d.ts +0 -14
  61. package/dist/npm/Intl/IntlProviderProps.js +0 -2
  62. package/dist/npm/Intl/IntlService.d.ts +0 -98
  63. package/dist/npm/Intl/IntlService.js +0 -152
  64. package/dist/npm/Intl/main.d.ts +0 -4
  65. package/dist/npm/Intl/main.js +0 -7
  66. package/dist/npm/Localization/LocalizationProvider.d.ts +0 -23
  67. package/dist/npm/Localization/LocalizationProvider.js +0 -65
  68. package/dist/npm/Localization/LocalizationProviderProps.d.ts +0 -14
  69. package/dist/npm/Localization/LocalizationProviderProps.js +0 -2
  70. package/dist/npm/Localization/LocalizationService.js +0 -37
  71. package/dist/npm/Localization/loadMessages.d.ts +0 -7
  72. package/dist/npm/Localization/loadMessages.js +0 -39
  73. package/dist/npm/Localization/main.d.ts +0 -5
  74. package/dist/npm/Localization/main.js +0 -9
  75. package/dist/npm/Localization/messages.d.ts +0 -4
  76. package/dist/npm/Localization/messages.js +0 -7
  77. package/dist/npm/coreExports.d.ts +0 -1
  78. package/dist/npm/coreExports.js +0 -5
  79. package/dist/npm/globalization/GlobalizationContext.d.ts +0 -10
  80. package/dist/npm/globalization/GlobalizationContext.js +0 -11
  81. package/dist/npm/hooks/index.d.ts +0 -2
  82. package/dist/npm/hooks/index.js +0 -18
  83. package/dist/npm/hooks/useInternationalization.d.ts +0 -5
  84. package/dist/npm/hooks/useInternationalization.js +0 -10
  85. package/dist/npm/hooks/useLocalization.d.ts +0 -5
  86. package/dist/npm/hooks/useLocalization.js +0 -10
  87. package/dist/npm/intlUtils.js +0 -56
  88. package/dist/npm/main.d.ts +0 -7
  89. package/dist/npm/main.js +0 -26
  90. package/dist/npm/package-metadata.d.ts +0 -5
  91. package/dist/npm/package-metadata.js +0 -14
  92. package/dist/systemjs/kendo-react-intl.js +0 -1
@@ -1,49 +0,0 @@
1
- import { IntlService } from './Intl/IntlService';
2
- import { LocalizationService } from './Localization/LocalizationService';
3
- import { GlobalizationContext } from './globalization/GlobalizationContext';
4
- /* eslint-disable max-len */
5
- /**
6
- * Provides an internationalization service. When the passed component is a direct or indirect child of `IntlProvider`, the returned service uses the locale of the provider. Otherwise, uses `en` as a default locale. To handle locale changes, call the method on each `render`.
7
- *
8
- * @param componentClass - The React component class that will use the internationalization service.
9
- */
10
- export function provideIntlService(component) {
11
- if (!component && process.env.NODE_ENV !== 'production') {
12
- throw "Passed component - ".concat(component, " is invalid.");
13
- }
14
- var context = component.context;
15
- return context && context.intl
16
- ? context.intl
17
- : new IntlService('en');
18
- }
19
- /**
20
- * Provides a localization service. When the passed component is a direct or indirect child of `LocalizationProvider`, the returned service uses the language of the provider. To handle locale changes, call the method on each `render`.
21
- *
22
- * @param componentClass - The React component class that will use the internationalization service.
23
- */
24
- export function provideLocalizationService(component) {
25
- if (!component && process.env.NODE_ENV !== 'production') {
26
- throw "Passed component - ".concat(component, " is invalid.");
27
- }
28
- var context = component.context;
29
- return context && context.localization
30
- ? context.localization
31
- : new LocalizationService();
32
- }
33
- /**
34
- * A method which registers a component class or a functional stateless component for internationalization. When a component of that type is a direct or indirect child of `IntlProvider`, the locale of the provider is used. Otherwise, uses `en` as a default locale.
35
- *
36
- * @param component - The React component class that will use the internationalization methods.
37
- */
38
- export function registerForIntl(component) {
39
- component.contextType = GlobalizationContext;
40
- }
41
- /**
42
- * A method which registers a component class or a stateless functional component for localization. When a component of that type is a direct or indirect child of `LocalizationProvider`, the language of the provider is used.
43
- *
44
- * @param component - The React component class that will use the internationalization methods.
45
- */
46
- export function registerForLocalization(component) {
47
- component.contextType = GlobalizationContext;
48
- }
49
- // tslint:enable:max-line-length
package/dist/es/main.d.ts DELETED
@@ -1,7 +0,0 @@
1
- export { GlobalizationContext } from './globalization/GlobalizationContext';
2
- export { messages as localizationMessages } from './Localization/messages';
3
- export * from './Intl/main';
4
- export * from './Localization/main';
5
- export * from './coreExports';
6
- export * from './intlUtils';
7
- export * from './hooks';
package/dist/es/main.js DELETED
@@ -1,7 +0,0 @@
1
- export { GlobalizationContext } from './globalization/GlobalizationContext';
2
- export { messages as localizationMessages } from './Localization/messages';
3
- export * from './Intl/main';
4
- export * from './Localization/main';
5
- export * from './coreExports';
6
- export * from './intlUtils';
7
- export * from './hooks';
@@ -1,5 +0,0 @@
1
- import { PackageMetadata } from '@progress/kendo-licensing';
2
- /**
3
- * @hidden
4
- */
5
- export declare const packageMetadata: PackageMetadata;
@@ -1,11 +0,0 @@
1
- /**
2
- * @hidden
3
- */
4
- export var packageMetadata = {
5
- name: '@progress/kendo-react-intl',
6
- productName: 'KendoReact',
7
- productCodes: ['KENDOUIREACT', 'KENDOUICOMPLETE'],
8
- publishDate: 1700063373,
9
- version: '',
10
- licensingDocsUrl: 'https://www.telerik.com/kendo-react-ui/my-license/?utm_medium=product&utm_source=kendoreact&utm_campaign=kendo-ui-react-purchase-license-keys-warning'
11
- };
@@ -1,23 +0,0 @@
1
- import * as React from 'react';
2
- import * as PropTypes from 'prop-types';
3
- import { IntlService } from './IntlService';
4
- import { IntlProviderProps } from './IntlProviderProps';
5
- /**
6
- * A React component which provides an internationalization service. Expects a locale string as a property of the component.
7
- */
8
- export declare class IntlProvider extends React.Component<IntlProviderProps, {}> {
9
- /**
10
- * @hidden
11
- */
12
- static propTypes: {
13
- locale: PropTypes.Requireable<string>;
14
- };
15
- /**
16
- * Returns an internationalization service. The method is suitable for overriding when you implement custom internationalization behavior.
17
- */
18
- getIntlService(): IntlService;
19
- /**
20
- * @hidden
21
- */
22
- render(): JSX.Element;
23
- }
@@ -1,65 +0,0 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- var __assign = (this && this.__assign) || function () {
18
- __assign = Object.assign || function(t) {
19
- for (var s, i = 1, n = arguments.length; i < n; i++) {
20
- s = arguments[i];
21
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
22
- t[p] = s[p];
23
- }
24
- return t;
25
- };
26
- return __assign.apply(this, arguments);
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.IntlProvider = void 0;
30
- var React = require("react");
31
- var PropTypes = require("prop-types");
32
- var IntlService_1 = require("./IntlService");
33
- var GlobalizationContext_1 = require("../globalization/GlobalizationContext");
34
- /* eslint-disable max-len */
35
- /**
36
- * A React component which provides an internationalization service. Expects a locale string as a property of the component.
37
- */
38
- var IntlProvider = /** @class */ (function (_super) {
39
- __extends(IntlProvider, _super);
40
- function IntlProvider() {
41
- return _super !== null && _super.apply(this, arguments) || this;
42
- }
43
- /**
44
- * Returns an internationalization service. The method is suitable for overriding when you implement custom internationalization behavior.
45
- */
46
- IntlProvider.prototype.getIntlService = function () {
47
- return new IntlService_1.IntlService(this.props.locale);
48
- };
49
- /**
50
- * @hidden
51
- */
52
- IntlProvider.prototype.render = function () {
53
- var _this = this;
54
- return (React.createElement(GlobalizationContext_1.GlobalizationContext.Consumer, null, function (glob) { return (React.createElement(GlobalizationContext_1.GlobalizationContext.Provider, { value: __assign(__assign({}, glob), { intl: _this.getIntlService() }) }, _this.props.children)); }));
55
- };
56
- /**
57
- * @hidden
58
- */
59
- IntlProvider.propTypes = {
60
- locale: PropTypes.string
61
- };
62
- return IntlProvider;
63
- }(React.Component));
64
- exports.IntlProvider = IntlProvider;
65
- // tslint:enable:max-line-length
@@ -1,14 +0,0 @@
1
- /// <reference types="react" />
2
- /**
3
- * Represents the props of the KendoReact IntlProvider component.
4
- */
5
- export interface IntlProviderProps {
6
- /**
7
- * The locale that will be used by the child components.
8
- */
9
- locale: string;
10
- /**
11
- * @hidden
12
- */
13
- children?: React.ReactNode;
14
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,98 +0,0 @@
1
- import { DateFormatOptions, NumberFormatOptions, DateFieldNameOptions, DateFormatNameOptions, DateFormatPart } from './../coreExports';
2
- /**
3
- * A service which provides internationalization methods and is bound to a specific locale.
4
- */
5
- export declare class IntlService {
6
- locale: string;
7
- /**
8
- * Creates a new instance of the internationalization service.
9
- *
10
- * @param locale - The locale that will be used by the internationalization methods.
11
- */
12
- constructor(locale: string);
13
- /**
14
- * Formats a string with placeholders such as `Total amount {0:c}`.
15
- *
16
- * @param format - The format string.
17
- * @param values - One or more values to output in the format string placeholders.
18
- * @return - The formatted string.
19
- */
20
- format(format: string, ...values: any[]): string;
21
- /**
22
- * Converts a `Date` object to a string based on the specified format. If no format is provided, the default short date format is used.
23
- *
24
- * @param value - The date which will be formatted.
25
- * @param format - The format string or options.
26
- * @return - The formatted date.
27
- */
28
- formatDate(value: Date, format?: string | DateFormatOptions): string;
29
- /**
30
- * Converts an object to a string based on the specified format.
31
- *
32
- * @param value - The value which will be formatted.
33
- * @param format - The format to use.
34
- * @return - The formatted object.
35
- */
36
- toString(value: any, format: string | any): string;
37
- /**
38
- * Converts a string to a `Number`.
39
- *
40
- * @param value - The string which will be parsed.
41
- * @param format - The format string or options.
42
- * @return - The parsed number.
43
- */
44
- parseNumber(value: string, format?: string | NumberFormatOptions): number;
45
- /**
46
- * Converts a string to a `Date` object based on the specified format.
47
- *
48
- * @param value - The string which will be converted.
49
- * @param format - The format strings or options.
50
- * @return - The parsed date.
51
- */
52
- parseDate(value: string, format?: string | DateFormatOptions | string[] | DateFormatOptions[]): Date;
53
- /**
54
- * Converts a `Number` to a string based on the specified format.
55
- *
56
- * @param value - The number which will be formatted.
57
- * @param format - The format string or options.
58
- * @return - The formatted number.
59
- */
60
- formatNumber(value: number, format: string | NumberFormatOptions): string;
61
- /**
62
- * Returns a localized date field name based on specific `dateFieldName` options.
63
- *
64
- * @param options - The detailed configuration for the desired date field name.
65
- * @returns - The localized date field name from the current locale based on the option.
66
- */
67
- dateFieldName(options: DateFieldNameOptions): string;
68
- /**
69
- * Returns the day names from the current locale based on the option.
70
- *
71
- * @param options - The detailed configuration for the desired date format.
72
- * @return - The day names from the current locale based on the option.
73
- */
74
- dateFormatNames(options: DateFormatNameOptions): any;
75
- /**
76
- * Splits the date format into objects which contain information about each part of the pattern.
77
- *
78
- * @param format - The format string or options.
79
- * @returns - The date format parts.
80
- */
81
- splitDateFormat(format: string | DateFormatOptions): DateFormatPart[];
82
- /**
83
- * Returns the number symbols from the current locale.
84
- *
85
- * @return - The number symbols from the current locale.
86
- */
87
- numberSymbols(): any;
88
- /**
89
- * Returns the first day index, starting from Sunday.
90
- *
91
- * @return - The index of the first day of the week (0 == Sunday).
92
- */
93
- firstDay(): number;
94
- /**
95
- * @hidden
96
- */
97
- localeInfo(): any;
98
- }
@@ -1,152 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.IntlService = void 0;
4
- var coreIntl = require("@progress/kendo-intl");
5
- var licensing = require("@progress/kendo-licensing");
6
- var package_metadata_1 = require("../package-metadata");
7
- /* eslint-disable max-len */
8
- /**
9
- * A service which provides internationalization methods and is bound to a specific locale.
10
- */
11
- var IntlService = /** @class */ (function () {
12
- /**
13
- * Creates a new instance of the internationalization service.
14
- *
15
- * @param locale - The locale that will be used by the internationalization methods.
16
- */
17
- function IntlService(locale) {
18
- this.locale = locale;
19
- if (typeof licensing !== 'undefined') {
20
- licensing.validatePackage(package_metadata_1.packageMetadata);
21
- }
22
- else {
23
- var message = "License activation failed for ".concat(package_metadata_1.packageMetadata.name, "\n");
24
- message += 'The @progress/kendo-licensing script is not loaded.\n';
25
- message += "See ".concat(package_metadata_1.packageMetadata.licensingDocsUrl, " for more information.\n");
26
- console.warn(message);
27
- }
28
- if (locale === '' && process.env.NODE_ENV !== 'production') {
29
- throw 'Locale should not be empty string';
30
- }
31
- }
32
- /**
33
- * Formats a string with placeholders such as `Total amount {0:c}`.
34
- *
35
- * @param format - The format string.
36
- * @param values - One or more values to output in the format string placeholders.
37
- * @return - The formatted string.
38
- */
39
- IntlService.prototype.format = function (format) {
40
- var values = [];
41
- for (var _i = 1; _i < arguments.length; _i++) {
42
- values[_i - 1] = arguments[_i];
43
- }
44
- /* The following code retains backward compatibility with the old API */
45
- if (values.length === 1 && Array.isArray(values[0])) {
46
- return coreIntl.format(format, values[0], this.locale);
47
- }
48
- return coreIntl.format(format, values, this.locale);
49
- };
50
- /**
51
- * Converts a `Date` object to a string based on the specified format. If no format is provided, the default short date format is used.
52
- *
53
- * @param value - The date which will be formatted.
54
- * @param format - The format string or options.
55
- * @return - The formatted date.
56
- */
57
- IntlService.prototype.formatDate = function (value, format) {
58
- return coreIntl.formatDate(value, format, this.locale);
59
- };
60
- /**
61
- * Converts an object to a string based on the specified format.
62
- *
63
- * @param value - The value which will be formatted.
64
- * @param format - The format to use.
65
- * @return - The formatted object.
66
- */
67
- IntlService.prototype.toString = function (value, format) {
68
- return coreIntl.toString(value, format, this.locale);
69
- };
70
- /**
71
- * Converts a string to a `Number`.
72
- *
73
- * @param value - The string which will be parsed.
74
- * @param format - The format string or options.
75
- * @return - The parsed number.
76
- */
77
- IntlService.prototype.parseNumber = function (value, format) {
78
- return coreIntl.parseNumber(value, this.locale, format);
79
- };
80
- /**
81
- * Converts a string to a `Date` object based on the specified format.
82
- *
83
- * @param value - The string which will be converted.
84
- * @param format - The format strings or options.
85
- * @return - The parsed date.
86
- */
87
- IntlService.prototype.parseDate = function (value, format) {
88
- return coreIntl.parseDate(value, format, this.locale);
89
- };
90
- /**
91
- * Converts a `Number` to a string based on the specified format.
92
- *
93
- * @param value - The number which will be formatted.
94
- * @param format - The format string or options.
95
- * @return - The formatted number.
96
- */
97
- IntlService.prototype.formatNumber = function (value, format) {
98
- return coreIntl.formatNumber(value, format, this.locale);
99
- };
100
- /**
101
- * Returns a localized date field name based on specific `dateFieldName` options.
102
- *
103
- * @param options - The detailed configuration for the desired date field name.
104
- * @returns - The localized date field name from the current locale based on the option.
105
- */
106
- IntlService.prototype.dateFieldName = function (options) {
107
- return coreIntl.dateFieldName(options, this.locale);
108
- };
109
- /**
110
- * Returns the day names from the current locale based on the option.
111
- *
112
- * @param options - The detailed configuration for the desired date format.
113
- * @return - The day names from the current locale based on the option.
114
- */
115
- IntlService.prototype.dateFormatNames = function (options) {
116
- return coreIntl.dateFormatNames(this.locale, options);
117
- };
118
- /**
119
- * Splits the date format into objects which contain information about each part of the pattern.
120
- *
121
- * @param format - The format string or options.
122
- * @returns - The date format parts.
123
- */
124
- IntlService.prototype.splitDateFormat = function (format) {
125
- return coreIntl.splitDateFormat(format, this.locale);
126
- };
127
- /**
128
- * Returns the number symbols from the current locale.
129
- *
130
- * @return - The number symbols from the current locale.
131
- */
132
- IntlService.prototype.numberSymbols = function () {
133
- return coreIntl.numberSymbols(this.locale);
134
- };
135
- /**
136
- * Returns the first day index, starting from Sunday.
137
- *
138
- * @return - The index of the first day of the week (0 == Sunday).
139
- */
140
- IntlService.prototype.firstDay = function () {
141
- return coreIntl.firstDay(this.locale);
142
- };
143
- /**
144
- * @hidden
145
- */
146
- IntlService.prototype.localeInfo = function () {
147
- return coreIntl.localeInfo(this.locale);
148
- };
149
- return IntlService;
150
- }());
151
- exports.IntlService = IntlService;
152
- // tslint:enable:max-line-length
@@ -1,4 +0,0 @@
1
- import { IntlProvider } from './IntlProvider';
2
- import { IntlProviderProps } from './IntlProviderProps';
3
- import { IntlService } from './IntlService';
4
- export { IntlProvider, IntlProviderProps, IntlService };
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.IntlService = exports.IntlProvider = void 0;
4
- var IntlProvider_1 = require("./IntlProvider");
5
- Object.defineProperty(exports, "IntlProvider", { enumerable: true, get: function () { return IntlProvider_1.IntlProvider; } });
6
- var IntlService_1 = require("./IntlService");
7
- Object.defineProperty(exports, "IntlService", { enumerable: true, get: function () { return IntlService_1.IntlService; } });
@@ -1,23 +0,0 @@
1
- import * as React from 'react';
2
- import * as PropTypes from 'prop-types';
3
- import { LocalizationProviderProps } from './LocalizationProviderProps';
4
- import { LocalizationService } from './LocalizationService';
5
- /**
6
- * A React component which provides a localization service. Expects a language string as a property of the component.
7
- */
8
- export declare class LocalizationProvider extends React.Component<LocalizationProviderProps, {}> {
9
- /**
10
- * @hidden
11
- */
12
- static propTypes: {
13
- language: PropTypes.Requireable<string>;
14
- };
15
- /**
16
- * Returns a localization service. The method is suitable for overriding when you implement custom localization behavior.
17
- */
18
- getLocalizationService(): LocalizationService;
19
- /**
20
- * @hidden
21
- */
22
- render(): JSX.Element;
23
- }
@@ -1,65 +0,0 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- var __assign = (this && this.__assign) || function () {
18
- __assign = Object.assign || function(t) {
19
- for (var s, i = 1, n = arguments.length; i < n; i++) {
20
- s = arguments[i];
21
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
22
- t[p] = s[p];
23
- }
24
- return t;
25
- };
26
- return __assign.apply(this, arguments);
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.LocalizationProvider = void 0;
30
- var React = require("react");
31
- var PropTypes = require("prop-types");
32
- var LocalizationService_1 = require("./LocalizationService");
33
- var GlobalizationContext_1 = require("../globalization/GlobalizationContext");
34
- /* eslint-disable max-len */
35
- /**
36
- * A React component which provides a localization service. Expects a language string as a property of the component.
37
- */
38
- var LocalizationProvider = /** @class */ (function (_super) {
39
- __extends(LocalizationProvider, _super);
40
- function LocalizationProvider() {
41
- return _super !== null && _super.apply(this, arguments) || this;
42
- }
43
- /**
44
- * Returns a localization service. The method is suitable for overriding when you implement custom localization behavior.
45
- */
46
- LocalizationProvider.prototype.getLocalizationService = function () {
47
- return new LocalizationService_1.LocalizationService(this.props.language);
48
- };
49
- /**
50
- * @hidden
51
- */
52
- LocalizationProvider.prototype.render = function () {
53
- var _this = this;
54
- return (React.createElement(GlobalizationContext_1.GlobalizationContext.Consumer, null, function (glob) { return (React.createElement(GlobalizationContext_1.GlobalizationContext.Provider, { value: __assign(__assign({}, glob), { localization: _this.getLocalizationService() }) }, _this.props.children)); }));
55
- };
56
- /**
57
- * @hidden
58
- */
59
- LocalizationProvider.propTypes = {
60
- language: PropTypes.string
61
- };
62
- return LocalizationProvider;
63
- }(React.Component));
64
- exports.LocalizationProvider = LocalizationProvider;
65
- // tslint:enable:max-line-length
@@ -1,14 +0,0 @@
1
- /// <reference types="react" />
2
- /**
3
- * Represents the props of the KendoReact LocalizationProvider component.
4
- */
5
- export interface LocalizationProviderProps {
6
- /**
7
- * The language that will be used by the child components.
8
- */
9
- language: string;
10
- /**
11
- * @hidden
12
- */
13
- children?: React.ReactNode;
14
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,37 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LocalizationService = void 0;
4
- var messages_1 = require("./messages");
5
- /**
6
- * A service which provides localization methods.
7
- */
8
- var LocalizationService = /** @class */ (function () {
9
- function LocalizationService(language) {
10
- this.language = language;
11
- if (language === '' && process.env.NODE_ENV !== 'production') {
12
- throw 'Language should not be an empty string';
13
- }
14
- }
15
- /* eslint-disable max-len */
16
- /**
17
- * Provides a string based on a key for the current language. When no string for the current language is available under this key, the `defaultValue` is returned.
18
- *
19
- * @param key - The key which identifies the string for the current language.
20
- * @param defaultValue - The default value which will be returned when no string
21
- * for the current language is available under the key.
22
- * @return - The string for the current language.
23
- */
24
- // tslint:enable:max-line-length
25
- LocalizationService.prototype.toLanguageString = function (key, defaultValue) {
26
- if (this.language &&
27
- messages_1.messages[this.language] &&
28
- messages_1.messages[this.language].hasOwnProperty(key)) {
29
- return messages_1.messages[this.language][key];
30
- }
31
- else {
32
- return defaultValue;
33
- }
34
- };
35
- return LocalizationService;
36
- }());
37
- exports.LocalizationService = LocalizationService;
@@ -1,7 +0,0 @@
1
- /**
2
- * Provides mechanism to load language-specific messages for the KendoReact components.
3
- *
4
- * @param messages - An iterable object which contains key-value pairs.
5
- * @param languages - The language to which the messages are associated.
6
- */
7
- export declare function loadMessages(messages: any, language: string): void;
@@ -1,39 +0,0 @@
1
- "use strict";
2
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
3
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4
- if (ar || !(i in from)) {
5
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
6
- ar[i] = from[i];
7
- }
8
- }
9
- return to.concat(ar || Array.prototype.slice.call(from));
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.loadMessages = void 0;
13
- var messages_1 = require("./messages");
14
- var traverse = function (iterable, langInfo, acc) {
15
- for (var key in iterable) {
16
- if (iterable.hasOwnProperty(key)) {
17
- var accumulator = __spreadArray([], acc, true);
18
- accumulator.push(key);
19
- if (typeof iterable[key] !== 'string') {
20
- traverse(iterable[key], langInfo, accumulator);
21
- }
22
- else {
23
- var value = iterable[key];
24
- Object.defineProperty(langInfo, accumulator.join('.'), { value: value });
25
- }
26
- }
27
- }
28
- };
29
- /**
30
- * Provides mechanism to load language-specific messages for the KendoReact components.
31
- *
32
- * @param messages - An iterable object which contains key-value pairs.
33
- * @param languages - The language to which the messages are associated.
34
- */
35
- function loadMessages(messages, language) {
36
- var langInfo = messages_1.messages[language] = messages_1.messages[language] || {};
37
- traverse(messages, langInfo, []);
38
- }
39
- exports.loadMessages = loadMessages;
@@ -1,5 +0,0 @@
1
- import { loadMessages } from './loadMessages';
2
- import { LocalizationProvider } from './LocalizationProvider';
3
- import { LocalizationProviderProps } from './LocalizationProviderProps';
4
- import { LocalizationService } from './LocalizationService';
5
- export { loadMessages, LocalizationProvider, LocalizationProviderProps, LocalizationService };