@formio/js 5.1.0-dev.5936.81a1533 → 5.1.0-dev.5939.f5aa9d6
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/formio.builder.css +1 -0
- package/dist/formio.builder.min.css +1 -1
- package/dist/formio.form.css +1 -0
- package/dist/formio.form.js +20 -42
- package/dist/formio.form.min.css +1 -1
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.full.css +1 -0
- package/dist/formio.full.js +22 -44
- package/dist/formio.full.min.css +1 -1
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.js +7 -7
- package/dist/formio.min.js +1 -1
- package/dist/formio.utils.js +8 -8
- package/dist/formio.utils.min.js +1 -1
- package/lib/cjs/Element.d.ts +2 -1
- package/lib/cjs/Element.js +6 -4
- package/lib/cjs/PDFBuilder.d.ts +1 -0
- package/lib/cjs/PDFBuilder.js +8 -8
- package/lib/cjs/Webform.d.ts +2 -2
- package/lib/cjs/Webform.js +4 -3
- package/lib/cjs/WebformBuilder.d.ts +1 -1
- package/lib/cjs/WebformBuilder.js +27 -8
- package/lib/cjs/components/_classes/component/Component.js +5 -0
- package/lib/cjs/components/_classes/input/Input.d.ts +1 -1
- package/lib/cjs/components/_classes/input/Input.js +2 -2
- package/lib/cjs/components/_classes/nested/NestedComponent.js +4 -2
- package/lib/cjs/components/address/Address.js +1 -1
- package/lib/cjs/components/editgrid/EditGrid.d.ts +0 -1
- package/lib/cjs/components/editgrid/EditGrid.js +0 -8
- package/lib/cjs/components/radio/Radio.d.ts +9 -4
- package/lib/cjs/components/radio/Radio.js +40 -76
- package/lib/cjs/components/select/Select.d.ts +1 -0
- package/lib/cjs/components/select/Select.js +19 -3
- package/lib/cjs/components/selectboxes/SelectBoxes.d.ts +6 -0
- package/lib/cjs/components/textfield/TextField.js +6 -1
- package/lib/cjs/formio.form.js +2 -2
- package/lib/cjs/translations/en.d.ts +1 -232
- package/lib/cjs/translations/en.js +4 -2
- package/lib/cjs/utils/formUtils.d.ts +2 -2
- package/lib/cjs/utils/index.d.ts +2 -2
- package/lib/cjs/utils/utils.js +10 -3
- package/lib/mjs/Element.d.ts +2 -1
- package/lib/mjs/Element.js +6 -4
- package/lib/mjs/PDFBuilder.d.ts +1 -0
- package/lib/mjs/PDFBuilder.js +8 -8
- package/lib/mjs/Webform.d.ts +2 -2
- package/lib/mjs/Webform.js +4 -3
- package/lib/mjs/WebformBuilder.d.ts +1 -1
- package/lib/mjs/WebformBuilder.js +26 -8
- package/lib/mjs/components/_classes/component/Component.js +5 -0
- package/lib/mjs/components/_classes/input/Input.d.ts +1 -1
- package/lib/mjs/components/_classes/input/Input.js +2 -2
- package/lib/mjs/components/_classes/nested/NestedComponent.js +4 -2
- package/lib/mjs/components/address/Address.js +1 -1
- package/lib/mjs/components/editgrid/EditGrid.d.ts +0 -1
- package/lib/mjs/components/editgrid/EditGrid.js +0 -8
- package/lib/mjs/components/radio/Radio.d.ts +9 -4
- package/lib/mjs/components/radio/Radio.js +40 -75
- package/lib/mjs/components/select/Select.d.ts +1 -0
- package/lib/mjs/components/select/Select.js +19 -3
- package/lib/mjs/components/selectboxes/SelectBoxes.d.ts +6 -0
- package/lib/mjs/components/textfield/TextField.js +6 -1
- package/lib/mjs/formio.form.js +1 -1
- package/lib/mjs/translations/en.d.ts +1 -232
- package/lib/mjs/translations/en.js +8 -47
- package/lib/mjs/utils/formUtils.d.ts +2 -2
- package/lib/mjs/utils/index.d.ts +2 -2
- package/lib/mjs/utils/utils.js +10 -2
- package/package.json +2 -2
- package/lib/cjs/i18n.d.ts +0 -13
- package/lib/cjs/i18n.js +0 -19
- package/lib/cjs/utils/i18n.d.ts +0 -19
- package/lib/cjs/utils/i18n.js +0 -120
- package/lib/mjs/i18n.d.ts +0 -13
- package/lib/mjs/i18n.js +0 -14
- package/lib/mjs/utils/i18n.d.ts +0 -19
- package/lib/mjs/utils/i18n.js +0 -112
@@ -1,59 +1,26 @@
|
|
1
1
|
import bootstrap from '@formio/bootstrap';
|
2
|
+
import { coreEnTranslation } from '@formio/core';
|
3
|
+
import _ from 'lodash';
|
2
4
|
export default {
|
3
5
|
...(bootstrap?.translations?.en || {}),
|
6
|
+
// these keys contain a '-' to strip whitespace in core
|
7
|
+
// which is not handled correctly in the renderer, so we redefine them
|
8
|
+
..._.omit(coreEnTranslation, ['maxDate', 'minDate']),
|
4
9
|
unsavedRowsError: 'Please save all rows before proceeding.',
|
5
10
|
invalidRowsError: 'Please correct invalid rows before proceeding.',
|
6
11
|
invalidRowError: 'Invalid row. Please correct it or delete.',
|
7
12
|
invalidOption: '{{field}} is an invalid value.',
|
8
13
|
invalidDay: '{{field}} is not a valid day.',
|
14
|
+
alertMessageWithLabel: '{{label}}: {{message}}',
|
15
|
+
alertMessage: '{{message}}',
|
9
16
|
complete: 'Submission Complete',
|
10
17
|
error: 'Please fix the following errors before submitting.',
|
11
18
|
errorListHotkey: 'Press Ctrl + Alt + X to go back to the error list.',
|
12
19
|
errorsListNavigationMessage: 'Click to navigate to the field with following error.',
|
13
20
|
submitError: 'Please check the form and correct all errors before submitting.',
|
14
|
-
required: '{{field}} is required',
|
15
|
-
unique: '{{field}} must be unique',
|
16
|
-
array: '{{field}} must be an array',
|
17
|
-
array_nonempty: '{{field}} must be a non-empty array', // eslint-disable-line camelcase
|
18
|
-
nonarray: '{{field}} must not be an array',
|
19
|
-
select: '{{field}} contains an invalid selection',
|
20
|
-
pattern: '{{field}} does not match the pattern {{pattern}}',
|
21
|
-
minLength: '{{field}} must have at least {{length}} characters.',
|
22
|
-
maxLength: '{{field}} must have no more than {{length}} characters.',
|
23
|
-
minWords: '{{field}} must have at least {{length}} words.',
|
24
|
-
maxWords: '{{field}} must have no more than {{length}} words.',
|
25
|
-
min: '{{field}} cannot be less than {{min}}.',
|
26
|
-
max: '{{field}} cannot be greater than {{max}}.',
|
27
21
|
maxDate: '{{field}} should not contain date after {{maxDate}}',
|
28
22
|
minDate: '{{field}} should not contain date before {{minDate}}',
|
29
|
-
maxYear: '{{field}} should not contain year greater than {{maxYear}}',
|
30
|
-
minYear: '{{field}} should not contain year less than {{minYear}}',
|
31
|
-
minSelectedCount: 'You must select at least {{minCount}} items',
|
32
|
-
maxSelectedCount: 'You may only select up to {{maxCount}} items',
|
33
|
-
invalid_email: '{{field}} must be a valid email.', // eslint-disable-line camelcase
|
34
|
-
invalid_url: '{{field}} must be a valid url.', // eslint-disable-line camelcase
|
35
|
-
invalid_regex: '{{field}} does not match the pattern {{regex}}.', // eslint-disable-line camelcase
|
36
|
-
invalid_date: '{{field}} is not a valid date.', // eslint-disable-line camelcase
|
37
|
-
invalid_day: '{{field}} is not a valid day.', // eslint-disable-line camelcase
|
38
|
-
invalidValueProperty: 'Invalid Value Property',
|
39
|
-
mask: '{{field}} does not match the mask.',
|
40
|
-
valueIsNotAvailable: '{{ field }} is an invalid value.',
|
41
23
|
stripe: '{{stripe}}',
|
42
|
-
month: 'Month',
|
43
|
-
day: 'Day',
|
44
|
-
year: 'Year',
|
45
|
-
january: 'January',
|
46
|
-
february: 'February',
|
47
|
-
march: 'March',
|
48
|
-
april: 'April',
|
49
|
-
may: 'May',
|
50
|
-
june: 'June',
|
51
|
-
july: 'July',
|
52
|
-
august: 'August',
|
53
|
-
september: 'September',
|
54
|
-
october: 'October',
|
55
|
-
november: 'November',
|
56
|
-
december: 'December',
|
57
24
|
next: 'Next',
|
58
25
|
previous: 'Previous',
|
59
26
|
cancel: 'Cancel',
|
@@ -72,12 +39,10 @@ export default {
|
|
72
39
|
reCaptchaTokenValidationError: 'ReCAPTCHA: Token validation error',
|
73
40
|
reCaptchaTokenNotSpecifiedError: 'ReCAPTCHA: Token is not specified in submission',
|
74
41
|
apiKey: 'API Key is not unique: {{key}}',
|
42
|
+
apiKeyNotValid: 'API Key is not valid: {{key}}',
|
75
43
|
typeRemaining: '{{ remaining }} {{ type }} remaining.',
|
76
44
|
typeCount: '{{ count }} {{ type }}',
|
77
|
-
requiredDayField: '{{ field }} is required',
|
78
45
|
requiredDayEmpty: '{{ field }} is required',
|
79
|
-
requiredMonthField: '{{ field }} is required',
|
80
|
-
requiredYearField: '{{ field }} is required',
|
81
46
|
formNotReady: 'Form not ready. Use form.ready promise',
|
82
47
|
noFormElement: 'No DOM element for form.',
|
83
48
|
notUniqueKey: 'API Key is not unique',
|
@@ -137,8 +102,6 @@ export default {
|
|
137
102
|
words: 'words',
|
138
103
|
characters: 'characters',
|
139
104
|
addAnother: 'Add Another',
|
140
|
-
yes: 'Yes',
|
141
|
-
no: 'No',
|
142
105
|
wantToClearData: 'Do you want to clear data?',
|
143
106
|
yesDelete: 'Yes, delete it',
|
144
107
|
waitFileProcessing: 'Processing file. Please wait...',
|
@@ -155,8 +118,6 @@ export default {
|
|
155
118
|
maxSelectItems: 'You may only select up to {{maxCount}} items',
|
156
119
|
minSelectItems: 'You must select at least {{minCount}} items',
|
157
120
|
clickToSign: 'Click to Sign',
|
158
|
-
surveyQuestion: 'Question',
|
159
|
-
surveyQuestionValue: 'Value',
|
160
121
|
success: 'Success',
|
161
122
|
noResultsFound: 'No results found',
|
162
123
|
noChoices: 'No choices to choose from',
|
@@ -26,8 +26,8 @@ export const getBestMatch: typeof Utils.getBestMatch;
|
|
26
26
|
export const getComponentFromPath: typeof Utils.getComponentFromPath;
|
27
27
|
export const getComponentValue: typeof Utils.getComponentValue;
|
28
28
|
export const findComponents: typeof Utils.findComponents;
|
29
|
-
export const eachComponentDataAsync: (components: import("@formio/core").Component[], data: import("@formio/core").DataObject, fn: import("@formio/core").EachComponentDataAsyncCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: import("@formio/core").Component | undefined, parentPaths?: import("@formio/core").ComponentPaths | undefined) => Promise<void>;
|
30
|
-
export const eachComponentData: (components: import("@formio/core").Component[], data: import("@formio/core").DataObject, fn: import("@formio/core").EachComponentDataCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: import("@formio/core").Component | undefined, parentPaths?: import("@formio/core").ComponentPaths | undefined) => void;
|
29
|
+
export const eachComponentDataAsync: (components: import("@formio/core").Component[], data: import("@formio/core").DataObject, fn: import("@formio/core").EachComponentDataAsyncCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: import("@formio/core").Component | undefined, parentPaths?: import("@formio/core").ComponentPaths | undefined, noScopeReset?: boolean | undefined) => Promise<void>;
|
30
|
+
export const eachComponentData: (components: import("@formio/core").Component[], data: import("@formio/core").DataObject, fn: import("@formio/core").EachComponentDataCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: import("@formio/core").Component | undefined, parentPaths?: import("@formio/core").ComponentPaths | undefined, noScopeReset?: boolean | undefined) => void;
|
31
31
|
export const getComponentKey: typeof Utils.getComponentKey;
|
32
32
|
export const getContextualRowPath: typeof Utils.getContextualRowPath;
|
33
33
|
export const getContextualRowData: typeof Utils.getContextualRowData;
|
package/lib/mjs/utils/index.d.ts
CHANGED
@@ -37,8 +37,8 @@ declare const FormioUtils: {
|
|
37
37
|
getComponentFromPath: typeof import("@formio/core/lib/utils/formUtil").getComponentFromPath;
|
38
38
|
getComponentValue: typeof import("@formio/core/lib/utils/formUtil").getComponentValue;
|
39
39
|
findComponents: typeof import("@formio/core/lib/utils/formUtil").findComponents;
|
40
|
-
eachComponentDataAsync: (components: import("@formio/core").Component[], data: import("@formio/core").DataObject, fn: import("@formio/core").EachComponentDataAsyncCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: import("@formio/core").Component | undefined, parentPaths?: import("@formio/core").ComponentPaths | undefined) => Promise<void>;
|
41
|
-
eachComponentData: (components: import("@formio/core").Component[], data: import("@formio/core").DataObject, fn: import("@formio/core").EachComponentDataCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: import("@formio/core").Component | undefined, parentPaths?: import("@formio/core").ComponentPaths | undefined) => void;
|
40
|
+
eachComponentDataAsync: (components: import("@formio/core").Component[], data: import("@formio/core").DataObject, fn: import("@formio/core").EachComponentDataAsyncCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: import("@formio/core").Component | undefined, parentPaths?: import("@formio/core").ComponentPaths | undefined, noScopeReset?: boolean | undefined) => Promise<void>;
|
41
|
+
eachComponentData: (components: import("@formio/core").Component[], data: import("@formio/core").DataObject, fn: import("@formio/core").EachComponentDataCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: import("@formio/core").Component | undefined, parentPaths?: import("@formio/core").ComponentPaths | undefined, noScopeReset?: boolean | undefined) => void;
|
42
42
|
getComponentKey: typeof import("@formio/core/lib/utils/formUtil").getComponentKey;
|
43
43
|
getContextualRowPath: typeof import("@formio/core/lib/utils/formUtil").getContextualRowPath;
|
44
44
|
getContextualRowData: typeof import("@formio/core/lib/utils/formUtil").getContextualRowData;
|
package/lib/mjs/utils/utils.js
CHANGED
@@ -199,7 +199,15 @@ export function checkSimpleConditional(component, condition, row, data, instance
|
|
199
199
|
return true;
|
200
200
|
}
|
201
201
|
const splittedConditionPath = conditionComponentPath.split('.');
|
202
|
-
const
|
202
|
+
const checkParentTypeInTree = (instance, componentType) => {
|
203
|
+
if (!instance?.parent) {
|
204
|
+
return false;
|
205
|
+
}
|
206
|
+
return instance?.parent.type === componentType || checkParentTypeInTree(instance.parent, componentType);
|
207
|
+
};
|
208
|
+
const conditionalPaths = checkParentTypeInTree(instance, 'datagrid') || checkParentTypeInTree(instance, 'editgrid')
|
209
|
+
? []
|
210
|
+
: getConditionalPathsRecursive(splittedConditionPath, data);
|
203
211
|
if (conditionalPaths.length > 0) {
|
204
212
|
return conditionalPaths.map((path) => {
|
205
213
|
const value = getComponentActualValue(path, data, row);
|
@@ -313,7 +321,7 @@ function getRow(component, row, instance, conditional) {
|
|
313
321
|
}
|
314
322
|
const dataParent = getDataParentComponent(instance);
|
315
323
|
if (dataParent) {
|
316
|
-
const parentPath = dataParent.paths?.
|
324
|
+
const parentPath = dataParent.paths?.localPath;
|
317
325
|
const isTriggerCondtionComponentPath = condition.when || !condition.conditions
|
318
326
|
? condition.when?.startsWith(dataParent.paths?.localPath)
|
319
327
|
: _.some(condition.conditions, cond => cond.component.startsWith(dataParent.paths?.localPath));
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@formio/js",
|
3
|
-
"version": "5.1.0-dev.
|
3
|
+
"version": "5.1.0-dev.5939.f5aa9d6",
|
4
4
|
"description": "JavaScript powered Forms with JSON Form Builder",
|
5
5
|
"main": "lib/cjs/index.js",
|
6
6
|
"exports": {
|
@@ -81,7 +81,7 @@
|
|
81
81
|
"homepage": "https://github.com/formio/formio.js#readme",
|
82
82
|
"dependencies": {
|
83
83
|
"@formio/bootstrap": "v3.0.0-dev.121.085d187",
|
84
|
-
"@formio/core": "
|
84
|
+
"@formio/core": "2.4.0-dev.267.2866472",
|
85
85
|
"@formio/text-mask-addons": "3.8.0-formio.4",
|
86
86
|
"@formio/vanilla-text-mask": "^5.1.1-formio.1",
|
87
87
|
"abortcontroller-polyfill": "^1.7.5",
|
package/lib/cjs/i18n.d.ts
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
declare namespace _default {
|
2
|
-
let lng: string;
|
3
|
-
let nsSeparator: string;
|
4
|
-
let keySeparator: string;
|
5
|
-
let pluralSeparator: string;
|
6
|
-
let contextSeparator: string;
|
7
|
-
namespace resources {
|
8
|
-
namespace en {
|
9
|
-
let translation: any;
|
10
|
-
}
|
11
|
-
}
|
12
|
-
}
|
13
|
-
export default _default;
|
package/lib/cjs/i18n.js
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
-
};
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
const en_1 = __importDefault(require("./translations/en"));
|
7
|
-
const utils_1 = require("./utils");
|
8
|
-
exports.default = {
|
9
|
-
lng: 'en',
|
10
|
-
nsSeparator: '::',
|
11
|
-
keySeparator: '.|.',
|
12
|
-
pluralSeparator: '._.',
|
13
|
-
contextSeparator: '._.',
|
14
|
-
resources: {
|
15
|
-
en: {
|
16
|
-
translation: (0, utils_1.fastCloneDeep)(en_1.default)
|
17
|
-
}
|
18
|
-
}
|
19
|
-
};
|
package/lib/cjs/utils/i18n.d.ts
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* This file is used to mimic the i18n library interface.
|
3
|
-
*/
|
4
|
-
export class I18n {
|
5
|
-
static languages: {};
|
6
|
-
static setDefaultTranslations(languages: any): void;
|
7
|
-
static init(languages?: {}): I18n;
|
8
|
-
static createInstance(): I18n;
|
9
|
-
constructor(languages?: {});
|
10
|
-
languages: any;
|
11
|
-
defaultKeys: any;
|
12
|
-
language: string;
|
13
|
-
currentLanguage: any;
|
14
|
-
setLanguages(languages: any, noDefaultOverride: any): void;
|
15
|
-
dir(lang?: string): "rtl" | "ltr";
|
16
|
-
changeLanguage(language: any, ready?: null): void;
|
17
|
-
addResourceBundle(language: any, type: any, strings: any): void;
|
18
|
-
t(text: any, ...args: any[]): any;
|
19
|
-
}
|
package/lib/cjs/utils/i18n.js
DELETED
@@ -1,120 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
-
};
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.I18n = void 0;
|
7
|
-
const Evaluator_1 = require("./Evaluator");
|
8
|
-
const i18n_1 = __importDefault(require("../i18n"));
|
9
|
-
const lodash_1 = require("lodash");
|
10
|
-
const core_1 = require("@formio/core");
|
11
|
-
const i18Defaults = {};
|
12
|
-
for (const lang in i18n_1.default.resources) {
|
13
|
-
if (i18n_1.default.resources.hasOwnProperty(lang)) {
|
14
|
-
i18Defaults[lang] = i18n_1.default.resources[lang].translation;
|
15
|
-
}
|
16
|
-
}
|
17
|
-
/**
|
18
|
-
* This file is used to mimic the i18n library interface.
|
19
|
-
*/
|
20
|
-
class I18n {
|
21
|
-
constructor(languages = {}) {
|
22
|
-
var _a;
|
23
|
-
this.languages = (0, core_1.fastCloneDeep)(I18n.languages || {});
|
24
|
-
this.defaultKeys = ((_a = I18n.languages) === null || _a === void 0 ? void 0 : _a.en) || {};
|
25
|
-
this.language = 'en';
|
26
|
-
this.currentLanguage = i18Defaults.en;
|
27
|
-
this.setLanguages(languages);
|
28
|
-
this.changeLanguage(this.language);
|
29
|
-
}
|
30
|
-
static setDefaultTranslations(languages) {
|
31
|
-
if ((0, lodash_1.isEmpty)(languages)) {
|
32
|
-
return;
|
33
|
-
}
|
34
|
-
for (const lang in languages) {
|
35
|
-
if (lang !== 'language' && languages.hasOwnProperty(lang)) {
|
36
|
-
if (!this.languages[lang]) {
|
37
|
-
this.languages[lang] = {};
|
38
|
-
}
|
39
|
-
this.languages[lang] = Object.assign(Object.assign({}, languages[lang]), this.languages[lang]);
|
40
|
-
}
|
41
|
-
}
|
42
|
-
}
|
43
|
-
setLanguages(languages, noDefaultOverride) {
|
44
|
-
if (languages.resources) {
|
45
|
-
for (const lang in languages.resources) {
|
46
|
-
if (languages.resources.hasOwnProperty(lang)) {
|
47
|
-
languages[lang] = languages.resources[lang].translation;
|
48
|
-
}
|
49
|
-
}
|
50
|
-
delete languages.resources;
|
51
|
-
}
|
52
|
-
if (languages.lng) {
|
53
|
-
languages.language = languages.lng;
|
54
|
-
delete languages.lng;
|
55
|
-
}
|
56
|
-
// Do not use these configurations.
|
57
|
-
delete languages.nsSeparator;
|
58
|
-
delete languages.keySeparator;
|
59
|
-
delete languages.pluralSeparator;
|
60
|
-
delete languages.contextSeparator;
|
61
|
-
// Now establish the languages default.
|
62
|
-
if (languages.language) {
|
63
|
-
this.language = languages.language;
|
64
|
-
}
|
65
|
-
for (const lang in languages) {
|
66
|
-
if (lang !== 'language' && languages.hasOwnProperty(lang)) {
|
67
|
-
if (!this.languages[lang]) {
|
68
|
-
this.languages[lang] = {};
|
69
|
-
}
|
70
|
-
this.languages[lang] = noDefaultOverride
|
71
|
-
? Object.assign(Object.assign({}, languages[lang]), this.languages[lang]) : Object.assign(Object.assign({}, this.languages[lang]), languages[lang]);
|
72
|
-
}
|
73
|
-
}
|
74
|
-
}
|
75
|
-
static init(languages = {}) {
|
76
|
-
return new I18n(languages);
|
77
|
-
}
|
78
|
-
dir(lang = '') {
|
79
|
-
lang = lang || this.language;
|
80
|
-
const rtls = ['ar', 'he', 'fa', 'ps', 'ur'];
|
81
|
-
return rtls.includes(lang) ? 'rtl' : 'ltr';
|
82
|
-
}
|
83
|
-
static createInstance() {
|
84
|
-
return new I18n();
|
85
|
-
}
|
86
|
-
changeLanguage(language, ready = null) {
|
87
|
-
if (!this.languages[language]) {
|
88
|
-
language = 'en';
|
89
|
-
}
|
90
|
-
this.language = language;
|
91
|
-
this.currentLanguage = this.languages[language] ? this.languages[language] : {};
|
92
|
-
if (ready) {
|
93
|
-
ready();
|
94
|
-
}
|
95
|
-
}
|
96
|
-
addResourceBundle(language, type, strings) {
|
97
|
-
this.languages[language] = strings;
|
98
|
-
}
|
99
|
-
t(text, ...args) {
|
100
|
-
var _a;
|
101
|
-
let currentTranslation = this.currentLanguage[text];
|
102
|
-
// provide compatibility with cases where the entire phrase is used as a key
|
103
|
-
// get the phrase that is possibly being used as a key
|
104
|
-
const defaultKey = this.defaultKeys[text];
|
105
|
-
if (defaultKey && this.currentLanguage[defaultKey]) {
|
106
|
-
// get translation using the phrase as a key
|
107
|
-
currentTranslation = this.currentLanguage[defaultKey];
|
108
|
-
}
|
109
|
-
if (currentTranslation) {
|
110
|
-
const customTranslationFieldName = (_a = args[0]) === null || _a === void 0 ? void 0 : _a.field;
|
111
|
-
if (customTranslationFieldName && this.currentLanguage[customTranslationFieldName]) {
|
112
|
-
args[0].field = this.currentLanguage[customTranslationFieldName];
|
113
|
-
}
|
114
|
-
return Evaluator_1.Evaluator.interpolateString(currentTranslation, ...args);
|
115
|
-
}
|
116
|
-
return Evaluator_1.Evaluator.interpolateString(text, ...args);
|
117
|
-
}
|
118
|
-
}
|
119
|
-
exports.I18n = I18n;
|
120
|
-
I18n.languages = i18Defaults;
|
package/lib/mjs/i18n.d.ts
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
declare namespace _default {
|
2
|
-
let lng: string;
|
3
|
-
let nsSeparator: string;
|
4
|
-
let keySeparator: string;
|
5
|
-
let pluralSeparator: string;
|
6
|
-
let contextSeparator: string;
|
7
|
-
namespace resources {
|
8
|
-
namespace en {
|
9
|
-
let translation: any;
|
10
|
-
}
|
11
|
-
}
|
12
|
-
}
|
13
|
-
export default _default;
|
package/lib/mjs/i18n.js
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
import enTranslation from './translations/en';
|
2
|
-
import { fastCloneDeep } from './utils';
|
3
|
-
export default {
|
4
|
-
lng: 'en',
|
5
|
-
nsSeparator: '::',
|
6
|
-
keySeparator: '.|.',
|
7
|
-
pluralSeparator: '._.',
|
8
|
-
contextSeparator: '._.',
|
9
|
-
resources: {
|
10
|
-
en: {
|
11
|
-
translation: fastCloneDeep(enTranslation)
|
12
|
-
}
|
13
|
-
}
|
14
|
-
};
|
package/lib/mjs/utils/i18n.d.ts
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* This file is used to mimic the i18n library interface.
|
3
|
-
*/
|
4
|
-
export class I18n {
|
5
|
-
static languages: {};
|
6
|
-
static setDefaultTranslations(languages: any): void;
|
7
|
-
static init(languages?: {}): I18n;
|
8
|
-
static createInstance(): I18n;
|
9
|
-
constructor(languages?: {});
|
10
|
-
languages: any;
|
11
|
-
defaultKeys: any;
|
12
|
-
language: string;
|
13
|
-
currentLanguage: any;
|
14
|
-
setLanguages(languages: any, noDefaultOverride: any): void;
|
15
|
-
dir(lang?: string): "rtl" | "ltr";
|
16
|
-
changeLanguage(language: any, ready?: null): void;
|
17
|
-
addResourceBundle(language: any, type: any, strings: any): void;
|
18
|
-
t(text: any, ...args: any[]): any;
|
19
|
-
}
|
package/lib/mjs/utils/i18n.js
DELETED
@@ -1,112 +0,0 @@
|
|
1
|
-
import { Evaluator } from './Evaluator';
|
2
|
-
import i18n from '../i18n';
|
3
|
-
import { isEmpty } from 'lodash';
|
4
|
-
import { fastCloneDeep } from '@formio/core';
|
5
|
-
const i18Defaults = {};
|
6
|
-
for (const lang in i18n.resources) {
|
7
|
-
if (i18n.resources.hasOwnProperty(lang)) {
|
8
|
-
i18Defaults[lang] = i18n.resources[lang].translation;
|
9
|
-
}
|
10
|
-
}
|
11
|
-
/**
|
12
|
-
* This file is used to mimic the i18n library interface.
|
13
|
-
*/
|
14
|
-
export class I18n {
|
15
|
-
static languages = i18Defaults;
|
16
|
-
languages = fastCloneDeep(I18n.languages || {});
|
17
|
-
defaultKeys = I18n.languages?.en || {};
|
18
|
-
language = 'en';
|
19
|
-
currentLanguage = i18Defaults.en;
|
20
|
-
constructor(languages = {}) {
|
21
|
-
this.setLanguages(languages);
|
22
|
-
this.changeLanguage(this.language);
|
23
|
-
}
|
24
|
-
static setDefaultTranslations(languages) {
|
25
|
-
if (isEmpty(languages)) {
|
26
|
-
return;
|
27
|
-
}
|
28
|
-
for (const lang in languages) {
|
29
|
-
if (lang !== 'language' && languages.hasOwnProperty(lang)) {
|
30
|
-
if (!this.languages[lang]) {
|
31
|
-
this.languages[lang] = {};
|
32
|
-
}
|
33
|
-
this.languages[lang] = { ...languages[lang], ...this.languages[lang], };
|
34
|
-
}
|
35
|
-
}
|
36
|
-
}
|
37
|
-
setLanguages(languages, noDefaultOverride) {
|
38
|
-
if (languages.resources) {
|
39
|
-
for (const lang in languages.resources) {
|
40
|
-
if (languages.resources.hasOwnProperty(lang)) {
|
41
|
-
languages[lang] = languages.resources[lang].translation;
|
42
|
-
}
|
43
|
-
}
|
44
|
-
delete languages.resources;
|
45
|
-
}
|
46
|
-
if (languages.lng) {
|
47
|
-
languages.language = languages.lng;
|
48
|
-
delete languages.lng;
|
49
|
-
}
|
50
|
-
// Do not use these configurations.
|
51
|
-
delete languages.nsSeparator;
|
52
|
-
delete languages.keySeparator;
|
53
|
-
delete languages.pluralSeparator;
|
54
|
-
delete languages.contextSeparator;
|
55
|
-
// Now establish the languages default.
|
56
|
-
if (languages.language) {
|
57
|
-
this.language = languages.language;
|
58
|
-
}
|
59
|
-
for (const lang in languages) {
|
60
|
-
if (lang !== 'language' && languages.hasOwnProperty(lang)) {
|
61
|
-
if (!this.languages[lang]) {
|
62
|
-
this.languages[lang] = {};
|
63
|
-
}
|
64
|
-
this.languages[lang] = noDefaultOverride
|
65
|
-
? { ...languages[lang], ...this.languages[lang] }
|
66
|
-
: { ...this.languages[lang], ...languages[lang] };
|
67
|
-
}
|
68
|
-
}
|
69
|
-
}
|
70
|
-
static init(languages = {}) {
|
71
|
-
return new I18n(languages);
|
72
|
-
}
|
73
|
-
dir(lang = '') {
|
74
|
-
lang = lang || this.language;
|
75
|
-
const rtls = ['ar', 'he', 'fa', 'ps', 'ur'];
|
76
|
-
return rtls.includes(lang) ? 'rtl' : 'ltr';
|
77
|
-
}
|
78
|
-
static createInstance() {
|
79
|
-
return new I18n();
|
80
|
-
}
|
81
|
-
changeLanguage(language, ready = null) {
|
82
|
-
if (!this.languages[language]) {
|
83
|
-
language = 'en';
|
84
|
-
}
|
85
|
-
this.language = language;
|
86
|
-
this.currentLanguage = this.languages[language] ? this.languages[language] : {};
|
87
|
-
if (ready) {
|
88
|
-
ready();
|
89
|
-
}
|
90
|
-
}
|
91
|
-
addResourceBundle(language, type, strings) {
|
92
|
-
this.languages[language] = strings;
|
93
|
-
}
|
94
|
-
t(text, ...args) {
|
95
|
-
let currentTranslation = this.currentLanguage[text];
|
96
|
-
// provide compatibility with cases where the entire phrase is used as a key
|
97
|
-
// get the phrase that is possibly being used as a key
|
98
|
-
const defaultKey = this.defaultKeys[text];
|
99
|
-
if (defaultKey && this.currentLanguage[defaultKey]) {
|
100
|
-
// get translation using the phrase as a key
|
101
|
-
currentTranslation = this.currentLanguage[defaultKey];
|
102
|
-
}
|
103
|
-
if (currentTranslation) {
|
104
|
-
const customTranslationFieldName = args[0]?.field;
|
105
|
-
if (customTranslationFieldName && this.currentLanguage[customTranslationFieldName]) {
|
106
|
-
args[0].field = this.currentLanguage[customTranslationFieldName];
|
107
|
-
}
|
108
|
-
return Evaluator.interpolateString(currentTranslation, ...args);
|
109
|
-
}
|
110
|
-
return Evaluator.interpolateString(text, ...args);
|
111
|
-
}
|
112
|
-
}
|