@pega/cosmos-react-core 2.0.0-dev.14.3 → 2.0.0-dev.15.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/lib/components/AppShell/AppShell.styles.js +1 -1
- package/lib/components/AppShell/AppShell.styles.js.map +1 -1
- package/lib/components/AppShell/Drawer.js +1 -1
- package/lib/components/AppShell/Drawer.js.map +1 -1
- package/lib/components/Badges/Status.d.ts +2 -2
- package/lib/components/Badges/Status.d.ts.map +1 -1
- package/lib/components/Badges/Status.js.map +1 -1
- package/lib/components/Configuration/Configuration.js +1 -1
- package/lib/components/Configuration/Configuration.js.map +1 -1
- package/lib/components/Currency/CurrencyDisplay.d.ts.map +1 -1
- package/lib/components/Currency/CurrencyDisplay.js +9 -1
- package/lib/components/Currency/CurrencyDisplay.js.map +1 -1
- package/lib/components/DateTime/DateTimeDisplay.js +1 -1
- package/lib/components/DateTime/DateTimeDisplay.js.map +1 -1
- package/lib/components/FieldGroup/FieldGroup.js +1 -1
- package/lib/components/FieldGroup/FieldGroup.js.map +1 -1
- package/lib/components/File/FileInput.d.ts.map +1 -1
- package/lib/components/File/FileInput.js +3 -1
- package/lib/components/File/FileInput.js.map +1 -1
- package/lib/components/File/FileUploadItem.js +1 -1
- package/lib/components/File/FileUploadItem.js.map +1 -1
- package/lib/components/List/List.d.ts.map +1 -1
- package/lib/components/List/List.js +2 -2
- package/lib/components/List/List.js.map +1 -1
- package/lib/components/Location/LocationInput.js +1 -1
- package/lib/components/Location/LocationInput.js.map +1 -1
- package/lib/components/Menu/MenuItem.js +5 -5
- package/lib/components/Menu/MenuItem.js.map +1 -1
- package/lib/components/Menu/MenuListHeader.js +1 -1
- package/lib/components/Menu/MenuListHeader.js.map +1 -1
- package/lib/components/MetaList/MetaList.d.ts +11 -2
- package/lib/components/MetaList/MetaList.d.ts.map +1 -1
- package/lib/components/MetaList/MetaList.js +32 -18
- package/lib/components/MetaList/MetaList.js.map +1 -1
- package/lib/components/MultiStep/MultiStep.d.ts.map +1 -1
- package/lib/components/MultiStep/MultiStep.js +3 -2
- package/lib/components/MultiStep/MultiStep.js.map +1 -1
- package/lib/components/Number/NumberInput.js +2 -2
- package/lib/components/Number/NumberInput.js.map +1 -1
- package/lib/components/PageTemplates/DashboardPage.d.ts +1 -1
- package/lib/components/PageTemplates/DashboardPage.d.ts.map +1 -1
- package/lib/components/PageTemplates/DashboardPage.js +9 -7
- package/lib/components/PageTemplates/DashboardPage.js.map +1 -1
- package/lib/components/PageTemplates/PageTemplates.d.ts +15 -8
- package/lib/components/PageTemplates/PageTemplates.d.ts.map +1 -1
- package/lib/components/PageTemplates/PageTemplates.js +81 -61
- package/lib/components/PageTemplates/PageTemplates.js.map +1 -1
- package/lib/components/PageTemplates/index.d.ts +2 -0
- package/lib/components/PageTemplates/index.d.ts.map +1 -1
- package/lib/components/PageTemplates/index.js.map +1 -1
- package/lib/components/Pagination/Pagination.js +1 -1
- package/lib/components/Pagination/Pagination.js.map +1 -1
- package/lib/components/Phone/PhoneInput.d.ts.map +1 -1
- package/lib/components/Phone/PhoneInput.js +5 -5
- package/lib/components/Phone/PhoneInput.js.map +1 -1
- package/lib/components/SearchInput/SearchInput.d.ts +2 -2
- package/lib/components/SearchInput/SearchInput.js.map +1 -1
- package/lib/components/SummaryList/SummaryList.js +1 -1
- package/lib/components/SummaryList/SummaryList.js.map +1 -1
- package/lib/components/Tabs/Tabs.d.ts +1 -0
- package/lib/components/Tabs/Tabs.d.ts.map +1 -1
- package/lib/components/Tabs/Tabs.js +4 -5
- package/lib/components/Tabs/Tabs.js.map +1 -1
- package/lib/components/TextArea/TextArea.js +1 -1
- package/lib/components/TextArea/TextArea.js.map +1 -1
- package/lib/components/Tree/StandardTree.js +1 -1
- package/lib/components/Tree/StandardTree.js.map +1 -1
- package/lib/hooks/useI18n.d.ts +218 -55
- package/lib/hooks/useI18n.d.ts.map +1 -1
- package/lib/hooks/useI18n.js +2 -2
- package/lib/hooks/useI18n.js.map +1 -1
- package/lib/i18n/default.json +234 -71
- package/lib/i18n/i18n.d.ts +436 -110
- package/lib/i18n/i18n.d.ts.map +1 -1
- package/lib/i18n/translate.d.ts +29 -4
- package/lib/i18n/translate.d.ts.map +1 -1
- package/lib/i18n/translate.js +21 -8
- package/lib/i18n/translate.js.map +1 -1
- package/package.json +1 -1
package/lib/i18n/i18n.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../src/i18n/i18n.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,MAAM,gBAAgB,CAAC;AAEhD,oBAAY,eAAe,GAAG,QAAQ,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAClE,oBAAY,WAAW,GAAG,OAAO,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE7D,QAAA,MAAM,MAAM
|
|
1
|
+
{"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../src/i18n/i18n.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,MAAM,gBAAgB,CAAC;AAEhD,oBAAY,eAAe,GAAG,QAAQ,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAClE,oBAAY,WAAW,GAAG,OAAO,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE7D,QAAA,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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
|
|
4
|
-
|
|
3
|
+
declare type TranslationTemplate = string | Record<Intl.LDMLPluralRule, string>;
|
|
4
|
+
/**
|
|
5
|
+
* Interface for advanced translation options, like plural forms.
|
|
6
|
+
*/
|
|
7
|
+
export interface TranslationOptions {
|
|
8
|
+
/**
|
|
9
|
+
* Value that determines which plural form will be chosen during translation.
|
|
10
|
+
* @default 0
|
|
11
|
+
*/
|
|
12
|
+
count?: number;
|
|
13
|
+
pluralType?: Intl.PluralRuleType;
|
|
5
14
|
}
|
|
6
|
-
|
|
15
|
+
/**
|
|
16
|
+
* Function that takes translation key with optional tokens and translation options to drive the translation process.
|
|
17
|
+
* Returns translated string with tokens inserted at defined slots.
|
|
18
|
+
*/
|
|
19
|
+
export interface TranslationFunction<T extends Record<string, TranslationTemplate>> {
|
|
20
|
+
(literal: keyof T): string;
|
|
21
|
+
(literal: keyof T, tokens: ReactText[], options?: TranslationOptions): string;
|
|
22
|
+
(literal: keyof T, tokens: ReactChild[], options?: TranslationOptions): ReactFragment[];
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Function returns a function capable to translate tokens based on given translation pack and given locale.
|
|
26
|
+
* The passed translation object should be correlated to given locale.
|
|
27
|
+
* @param translation a translation pack (might be default or completely/partially overridden).
|
|
28
|
+
* @param locale locale as BCP 47 language tag. Used for pluralization rules.
|
|
29
|
+
* @returns
|
|
30
|
+
*/
|
|
31
|
+
declare const translatorFor: <T extends Record<string, TranslationTemplate>>(translation: T, locale: string) => TranslationFunction<T>;
|
|
7
32
|
export default translatorFor;
|
|
8
33
|
//# sourceMappingURL=translate.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"translate.d.ts","sourceRoot":"","sources":["../../src/i18n/translate.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"translate.d.ts","sourceRoot":"","sources":["../../src/i18n/translate.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAY,aAAa,EAAE,MAAM,OAAO,CAAC;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAInD,aAAK,mBAAmB,GAAG,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;AAExE;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,UAAU,CAAC,EAAE,IAAI,CAAC,cAAc,CAAC;CAClC;AAED;;;GAGG;AACH,MAAM,WAAW,mBAAmB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC;IAChF,CAAC,OAAO,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC;IAC3B,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,MAAM,CAAC;IAC9E,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,aAAa,EAAE,CAAC;CACzF;AAED;;;;;;GAMG;AACH,QAAA,MAAM,aAAa,0EAET,MAAM,2BA6Bf,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
package/lib/i18n/translate.js
CHANGED
|
@@ -1,18 +1,31 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Fragment } from 'react';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Function returns a function capable to translate tokens based on given translation pack and given locale.
|
|
5
|
+
* The passed translation object should be correlated to given locale.
|
|
6
|
+
* @param translation a translation pack (might be default or completely/partially overridden).
|
|
7
|
+
* @param locale locale as BCP 47 language tag. Used for pluralization rules.
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
const translatorFor = (translation, locale) => {
|
|
11
|
+
const cardinalRules = new Intl.PluralRules(locale);
|
|
12
|
+
const ordinalRules = new Intl.PluralRules(locale, { type: 'ordinal' });
|
|
13
|
+
return ((literal, tokens = [], options) => {
|
|
14
|
+
let template = translation[literal];
|
|
6
15
|
if (!template)
|
|
7
|
-
return
|
|
16
|
+
return `!unknown key: ${literal}`;
|
|
8
17
|
const result = [];
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
|
|
18
|
+
if (typeof template === 'object') {
|
|
19
|
+
const type = (options?.pluralType === 'ordinal' ? ordinalRules : cardinalRules).select(options?.count || 0);
|
|
20
|
+
template = template[type];
|
|
21
|
+
}
|
|
22
|
+
template.split(/\{(\d+)\}/g).forEach((chunk, index) => {
|
|
23
|
+
const part = index % 2 ? tokens[Number(chunk)] : chunk;
|
|
24
|
+
if (part !== undefined && part !== '')
|
|
12
25
|
result.push(part);
|
|
13
26
|
});
|
|
14
27
|
if (result.every(part => typeof part === 'string' || typeof part === 'number'))
|
|
15
|
-
return result.join('');
|
|
28
|
+
return result.join('').trim();
|
|
16
29
|
// eslint-disable-next-line react/no-array-index-key
|
|
17
30
|
return result.map((part, i) => _jsx(Fragment, { children: part }, i));
|
|
18
31
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"translate.js","sourceRoot":"","sources":["../../src/i18n/translate.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,
|
|
1
|
+
{"version":3,"file":"translate.js","sourceRoot":"","sources":["../../src/i18n/translate.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAiB,MAAM,OAAO,CAAC;AA8BhD;;;;;;GAMG;AACH,MAAM,aAAa,GAAG,CACpB,WAAc,EACd,MAAc,EACU,EAAE;IAC1B,MAAM,aAAa,GAAG,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IACnD,MAAM,YAAY,GAAG,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;IACv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C;AAC/B,CAAC,CAAC;AAEF,eAAe,aAAa,CAAC","sourcesContent":["import { Fragment, ReactFragment } from 'react';\nimport type { ReactChild, ReactText } from 'react';\n\nimport { TranslationPack } from './i18n';\n\ntype TranslationTemplate = string | Record<Intl.LDMLPluralRule, string>;\n\n/**\n * Interface for advanced translation options, like plural forms.\n */\nexport interface TranslationOptions {\n /**\n * Value that determines which plural form will be chosen during translation.\n * @default 0\n */\n count?: number;\n // Descriminator for pluralization type: 'cardinal' or 'ordinal'.\n pluralType?: Intl.PluralRuleType;\n}\n\n/**\n * Function that takes translation key with optional tokens and translation options to drive the translation process.\n * Returns translated string with tokens inserted at defined slots.\n */\nexport interface TranslationFunction<T extends Record<string, TranslationTemplate>> {\n (literal: keyof T): string;\n (literal: keyof T, tokens: ReactText[], options?: TranslationOptions): string;\n (literal: keyof T, tokens: ReactChild[], options?: TranslationOptions): ReactFragment[];\n}\n\n/**\n * Function returns a function capable to translate tokens based on given translation pack and given locale.\n * The passed translation object should be correlated to given locale.\n * @param translation a translation pack (might be default or completely/partially overridden).\n * @param locale locale as BCP 47 language tag. Used for pluralization rules.\n * @returns\n */\nconst translatorFor = <T extends Record<string, TranslationTemplate>>(\n translation: T,\n locale: string\n): TranslationFunction<T> => {\n const cardinalRules = new Intl.PluralRules(locale);\n const ordinalRules = new Intl.PluralRules(locale, { type: 'ordinal' });\n return ((\n literal: keyof TranslationPack,\n tokens: (ReactChild | ReactText)[] = [],\n options?: TranslationOptions\n ): string | ReactFragment[] => {\n let template: TranslationTemplate = translation[literal];\n if (!template) return `!unknown key: ${literal}`;\n const result: ReactChild[] = [];\n if (typeof template === 'object') {\n const type = (options?.pluralType === 'ordinal' ? ordinalRules : cardinalRules).select(\n options?.count || 0\n );\n template = template[type];\n }\n template.split(/\\{(\\d+)\\}/g).forEach((chunk, index) => {\n const part = index % 2 ? tokens[Number(chunk)] : chunk;\n if (part !== undefined && part !== '') result.push(part);\n });\n\n if (result.every(part => typeof part === 'string' || typeof part === 'number'))\n return result.join('').trim();\n\n // eslint-disable-next-line react/no-array-index-key\n return result.map((part, i) => <Fragment key={i}>{part}</Fragment>);\n }) as TranslationFunction<T>;\n};\n\nexport default translatorFor;\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pega/cosmos-react-core",
|
|
3
|
-
"version": "2.0.0-dev.
|
|
3
|
+
"version": "2.0.0-dev.15.0",
|
|
4
4
|
"description": "Cosmos is a visual design system and UI component collection. Its goal is to empower application developers in their pursuit to create engaging and rewarding user experiences.",
|
|
5
5
|
"author": "Pegasystems",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|