@taiga-ui/cdk 3.53.0 → 3.54.0-canary.c32771f
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/bundles/taiga-ui-cdk-components-alert-host.umd.js +1 -1
- package/bundles/taiga-ui-cdk-components-alert-host.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-constants.umd.js +3 -3
- package/bundles/taiga-ui-cdk-constants.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-auto-focus.umd.js +4 -16
- package/bundles/taiga-ui-cdk-directives-auto-focus.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-autofilled.umd.js +1 -1
- package/bundles/taiga-ui-cdk-directives-autofilled.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-focus-trap.umd.js +1 -4
- package/bundles/taiga-ui-cdk-directives-focus-trap.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-media.umd.js +1 -2
- package/bundles/taiga-ui-cdk-directives-media.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-pipes-filter.umd.js +1 -1
- package/bundles/taiga-ui-cdk-pipes-filter.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-pipes-keys.umd.js +1 -1
- package/bundles/taiga-ui-cdk-pipes-keys.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-pipes-mapper.umd.js +1 -1
- package/bundles/taiga-ui-cdk-pipes-mapper.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-pipes-replace.umd.js +1 -1
- package/bundles/taiga-ui-cdk-pipes-replace.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-utils-focus.umd.js +6 -2
- package/bundles/taiga-ui-cdk-utils-focus.umd.js.map +1 -1
- package/constants/used-icons.d.ts +1 -1
- package/constants/version.d.ts +1 -1
- package/constants/version.js +1 -1
- package/esm2015/components/alert-host/alert-host.component.js +2 -2
- package/esm2015/constants/used-icons.js +3 -3
- package/esm2015/constants/version.js +2 -2
- package/esm2015/directives/auto-focus/autofocus.options.js +1 -2
- package/esm2015/directives/auto-focus/handlers/ios.handler.js +3 -4
- package/esm2015/directives/autofilled/autofilled.module.js +2 -2
- package/esm2015/directives/focus-trap/focus-trap.directive.js +2 -5
- package/esm2015/directives/media/media.directive.js +2 -3
- package/esm2015/pipes/filter/filter.module.js +2 -2
- package/esm2015/pipes/keys/keys.module.js +2 -2
- package/esm2015/pipes/mapper/mapper.module.js +2 -2
- package/esm2015/pipes/replace/replace.module.js +2 -2
- package/esm2015/utils/focus/is-native-focused-in.js +4 -2
- package/esm2015/utils/focus/is-native-focused.js +4 -2
- package/fesm2015/taiga-ui-cdk-components-alert-host.js +2 -2
- package/fesm2015/taiga-ui-cdk-components-alert-host.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-constants.js +3 -3
- package/fesm2015/taiga-ui-cdk-constants.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-directives-auto-focus.js +2 -3
- package/fesm2015/taiga-ui-cdk-directives-auto-focus.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-directives-autofilled.js +1 -1
- package/fesm2015/taiga-ui-cdk-directives-autofilled.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-directives-focus-trap.js +1 -4
- package/fesm2015/taiga-ui-cdk-directives-focus-trap.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-directives-media.js +1 -2
- package/fesm2015/taiga-ui-cdk-directives-media.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-pipes-filter.js +1 -1
- package/fesm2015/taiga-ui-cdk-pipes-filter.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-pipes-keys.js +1 -1
- package/fesm2015/taiga-ui-cdk-pipes-keys.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-pipes-mapper.js +1 -1
- package/fesm2015/taiga-ui-cdk-pipes-mapper.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-pipes-replace.js +1 -1
- package/fesm2015/taiga-ui-cdk-pipes-replace.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-utils-focus.js +6 -2
- package/fesm2015/taiga-ui-cdk-utils-focus.js.map +1 -1
- package/package.json +68 -68
- package/schematics/ng-add/steps/add-taiga-modules.js +1 -1
- package/schematics/ng-update/steps/replace-identifier.js +1 -1
- package/schematics/ng-update/v3/steps/migrate-progress.js +6 -8
- package/schematics/ng-update/v3/steps/migrate-sliders/migrate-input-range.js +6 -6
- package/schematics/ng-update/v3/steps/migrate-sliders/migrate-input-slider.js +4 -4
- package/schematics/ng-update/v3-40/index.js +2 -3
- package/schematics/ng-update/v4/steps/constants/attrs-to-replace.js +7 -0
- package/schematics/ng-update/v4/steps/constants/html-comments.js +10 -0
- package/schematics/ng-update/v4/steps/constants/identifiers-to-replace.js +4 -0
- package/schematics/ng-update/v4/steps/constants/inputs-to-remove.js +1 -0
- package/schematics/ng-update/v4/steps/migrate-templates.js +1 -0
- package/schematics/ng-update/v4/steps/templates/index.d.ts +1 -0
- package/schematics/ng-update/v4/steps/templates/index.js +1 -0
- package/schematics/ng-update/v4/steps/templates/migrate-avatar.d.ts +8 -0
- package/schematics/ng-update/v4/steps/templates/migrate-avatar.js +75 -0
- package/schematics/ng-update/v4/steps/utils/replace-substrings.js +2 -2
@@ -15,10 +15,7 @@ const PROPERTY_FOR_DEPRECATED_PIPES = `[color]`;
|
|
15
15
|
function migrateProgress(fileSystem, options) {
|
16
16
|
!options[`skip-logs`] &&
|
17
17
|
colored_log_1.infoLog(`${colored_log_1.SMALL_TAB_SYMBOL}${colored_log_1.REPLACE_SYMBOL} migrating progress bars...`);
|
18
|
-
|
19
|
-
for (const templateResource of templateResources) {
|
20
|
-
replaceProgressColorSegmentsPipe(templateResource, fileSystem);
|
21
|
-
}
|
18
|
+
get_component_templates_1.getComponentTemplates(constants_1.ALL_TS_FILES).forEach(templateResource => replaceProgressColorSegmentsPipe(templateResource, fileSystem));
|
22
19
|
fileSystem.commitEdits();
|
23
20
|
ng_morph_1.saveActiveProject();
|
24
21
|
ng_morph_1.setActiveProject(ng_morph_1.createProject(fileSystem.tree, project_root_1.projectRoot(), constants_1.ALL_FILES));
|
@@ -27,13 +24,14 @@ function migrateProgress(fileSystem, options) {
|
|
27
24
|
}
|
28
25
|
exports.migrateProgress = migrateProgress;
|
29
26
|
function replaceProgressColorSegmentsPipe(templateResource, fileSystem) {
|
30
|
-
var _a, _b;
|
31
27
|
const template = template_resource_1.getTemplateFromTemplateResource(templateResource, fileSystem);
|
32
28
|
const templateOffset = template_resource_1.getTemplateOffset(templateResource);
|
33
29
|
const path = fileSystem.resolve(template_resource_1.getPathFromTemplateResource(templateResource));
|
34
30
|
const recorder = fileSystem.edit(path);
|
35
|
-
|
36
|
-
|
31
|
+
elements_1.findElementsWithAttribute(template, PROPERTY_FOR_DEPRECATED_PIPES)
|
32
|
+
.filter(isProgressWithDeprecatedPipe)
|
33
|
+
.forEach(progressEl => {
|
34
|
+
var _a, _b;
|
37
35
|
const oldValue = ((_a = progressEl.attrs.find(attr => attr.name === PROPERTY_FOR_DEPRECATED_PIPES)) === null || _a === void 0 ? void 0 : _a.value) || ``;
|
38
36
|
const newValue = oldValue.replace(exports.DEPRECATED_PROGRESS_PIPES_REG, ``);
|
39
37
|
const attrLocations = (_b = progressEl.sourceCodeLocation) === null || _b === void 0 ? void 0 : _b.attrs;
|
@@ -42,7 +40,7 @@ function replaceProgressColorSegmentsPipe(templateResource, fileSystem) {
|
|
42
40
|
recorder.remove(templateOffset + startOffset, endOffset - startOffset);
|
43
41
|
recorder.insertRight(templateOffset + startOffset, `[tuiProgressColorSegments]="${newValue}"`);
|
44
42
|
}
|
45
|
-
}
|
43
|
+
});
|
46
44
|
}
|
47
45
|
function isProgressWithDeprecatedPipe(element) {
|
48
46
|
return (element.tagName === `progress` &&
|
@@ -21,17 +21,17 @@ function migrateInputRange(fileSystem, options) {
|
|
21
21
|
total: templateResources.length,
|
22
22
|
prefix: `[replaceMinMaxLabel]`,
|
23
23
|
});
|
24
|
-
|
24
|
+
templateResources.forEach(templateResource => {
|
25
25
|
!options[`skip-logs`] && progressLog(templateResource.componentPath);
|
26
26
|
replaceMinLabel(templateResource, fileSystem, COMPONENTS_WITH_MIN_LABELS);
|
27
27
|
replaceMaxLabel(templateResource, fileSystem, COMPONENTS_WITH_MAX_LABELS);
|
28
|
-
}
|
28
|
+
});
|
29
29
|
save(fileSystem);
|
30
30
|
progressLog = progress_1.setupProgressLogger({
|
31
31
|
total: COMPONENTS_WITH_MIN_LABELS.size,
|
32
32
|
prefix: `[COMPONENTS_WITH_MIN_LABELS]`,
|
33
33
|
});
|
34
|
-
|
34
|
+
Array.from(COMPONENTS_WITH_MIN_LABELS).forEach(componentPath => {
|
35
35
|
!options[`skip-logs`] && progressLog(componentPath);
|
36
36
|
addMinMaxLabelMethod(componentPath, MIN_LABELS_MIGRATION_METHOD_NAME, [
|
37
37
|
`const currentValue = context.$implicit;`,
|
@@ -40,12 +40,12 @@ function migrateInputRange(fileSystem, options) {
|
|
40
40
|
`if (currentValue === minValue) return minLabelText;`,
|
41
41
|
`return String(currentValue);`,
|
42
42
|
]);
|
43
|
-
}
|
43
|
+
});
|
44
44
|
progressLog = progress_1.setupProgressLogger({
|
45
45
|
total: COMPONENTS_WITH_MAX_LABELS.size,
|
46
46
|
prefix: `[COMPONENTS_WITH_MAX_LABELS]`,
|
47
47
|
});
|
48
|
-
|
48
|
+
Array.from(COMPONENTS_WITH_MAX_LABELS).forEach(componentPath => {
|
49
49
|
!options[`skip-logs`] && progressLog(componentPath);
|
50
50
|
addMinMaxLabelMethod(componentPath, MAX_LABELS_MIGRATION_METHOD_NAME, [
|
51
51
|
`const currentValue = context.$implicit;`,
|
@@ -54,7 +54,7 @@ function migrateInputRange(fileSystem, options) {
|
|
54
54
|
`if (currentValue === maxValue) return maxLabelText;`,
|
55
55
|
`return String(currentValue);`,
|
56
56
|
]);
|
57
|
-
}
|
57
|
+
});
|
58
58
|
}
|
59
59
|
exports.migrateInputRange = migrateInputRange;
|
60
60
|
function replaceMinLabel(templateResource, fileSystem, modifiedComponentStorage) {
|
@@ -18,10 +18,10 @@ function migrateInputSlider(fileSystem, options) {
|
|
18
18
|
total: templateResources.length,
|
19
19
|
prefix: `[replaceMinMaxLabels]`,
|
20
20
|
});
|
21
|
-
|
21
|
+
templateResources.forEach(templateResource => {
|
22
22
|
!options[`skip-logs`] && progressLog(templateResource.componentPath);
|
23
23
|
replaceMinMaxLabels(templateResource, fileSystem, COMPONENTS_WITH_MIN_MAX_LABELS);
|
24
|
-
}
|
24
|
+
});
|
25
25
|
/**
|
26
26
|
* We should update virtual file tree
|
27
27
|
* otherwise all following ng-morph commands will overwrite all previous template manipulations
|
@@ -33,10 +33,10 @@ function migrateInputSlider(fileSystem, options) {
|
|
33
33
|
total: COMPONENTS_WITH_MIN_MAX_LABELS.size,
|
34
34
|
prefix: `[addMinMaxLabelMethod]`,
|
35
35
|
});
|
36
|
-
|
36
|
+
Array.from(COMPONENTS_WITH_MIN_MAX_LABELS).forEach(componentPath => {
|
37
37
|
!options[`skip-logs`] && progressLog(componentPath);
|
38
38
|
addMinMaxLabelMethod(componentPath);
|
39
|
-
}
|
39
|
+
});
|
40
40
|
}
|
41
41
|
exports.migrateInputSlider = migrateInputSlider;
|
42
42
|
const MIN_MAX_LABELS_MIGRATION_METHOD_NAME = `tuiMigrationMinMaxLabel`;
|
@@ -24,8 +24,7 @@ exports.updateToV3_40 = updateToV3_40;
|
|
24
24
|
function replaceTextareaTag(options, fileSystem) {
|
25
25
|
!options[`skip-logs`] &&
|
26
26
|
colored_log_1.infoLog(`${colored_log_1.SMALL_TAB_SYMBOL}${colored_log_1.REPLACE_SYMBOL} replacing <tui-text-area /> to <tui-textarea />`);
|
27
|
-
|
28
|
-
for (const resource of templateResources) {
|
27
|
+
get_component_templates_1.getComponentTemplates(constants_1.ALL_TS_FILES).forEach(resource => {
|
29
28
|
const template = template_resource_1.getTemplateFromTemplateResource(resource, fileSystem);
|
30
29
|
const elements = elements_1.findElementsByTagName(template, `tui-text-area`);
|
31
30
|
const path = fileSystem.resolve(template_resource_1.getPathFromTemplateResource(resource));
|
@@ -35,7 +34,7 @@ function replaceTextareaTag(options, fileSystem) {
|
|
35
34
|
replace_tag_1.replaceTag(recorder, sourceCodeLocation, `tui-text-area`, `tui-textarea`);
|
36
35
|
}
|
37
36
|
});
|
38
|
-
}
|
37
|
+
});
|
39
38
|
fileSystem.commitEdits();
|
40
39
|
ng_morph_1.saveActiveProject();
|
41
40
|
ng_morph_1.setActiveProject(ng_morph_1.createProject(fileSystem.tree, project_root_1.projectRoot(), constants_1.ALL_FILES));
|
@@ -7,4 +7,14 @@ exports.HTML_COMMENTS = [
|
|
7
7
|
withAttrs: [`singleColor`, `showLoader`],
|
8
8
|
comment: `toggle [singleColor] and [showLoader] inputs have been removed due to design changes`,
|
9
9
|
},
|
10
|
+
{
|
11
|
+
tag: `tui-table-pagination`,
|
12
|
+
withAttrs: [`[(page)]`, `[(size)]`, `(pageChange)`, `(sizeChange)`],
|
13
|
+
comment: `(pageChange) and (sizeChange) outputs have been removed. Use (paginationChange) instead`,
|
14
|
+
},
|
15
|
+
{
|
16
|
+
tag: `tui-radio`,
|
17
|
+
withAttrs: [`identityMatcher`, `showLoader`],
|
18
|
+
comment: `radio [identityMatcher] and [pseudoDisabled] inputs have been removed. If you need a workaround, please start a discussion on GitHub to think together`,
|
19
|
+
},
|
10
20
|
];
|
@@ -25,6 +25,10 @@ exports.IDENTIFIERS_TO_REPLACE = [
|
|
25
25
|
from: { name: `TuiRadioModule`, moduleSpecifier: `@taiga-ui/experimental` },
|
26
26
|
to: { name: `TuiRadioModule`, moduleSpecifier: `@taiga-ui/kit` },
|
27
27
|
},
|
28
|
+
{
|
29
|
+
from: { name: `TuiAvatarModule`, moduleSpecifier: `@taiga-ui/experimental` },
|
30
|
+
to: { name: `TuiAvatarModule`, moduleSpecifier: `@taiga-ui/kit` },
|
31
|
+
},
|
28
32
|
{
|
29
33
|
from: { name: `TuiToggleModule`, moduleSpecifier: `@taiga-ui/experimental` },
|
30
34
|
to: { name: `TuiToggleModule`, moduleSpecifier: `@taiga-ui/kit` },
|
@@ -27,6 +27,7 @@ function migrateTemplates(fileSystem, options) {
|
|
27
27
|
templates_2.migrateCheckbox,
|
28
28
|
templates_2.migrateRadio,
|
29
29
|
templates_2.migrateToggle,
|
30
|
+
templates_2.migrateAvatar,
|
30
31
|
];
|
31
32
|
const progressLog = progress_1.setupProgressLogger({
|
32
33
|
total: componentWithTemplatesPaths.length,
|
@@ -1,5 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
const tslib_1 = require("tslib");
|
4
|
+
tslib_1.__exportStar(require("./migrate-avatar"), exports);
|
4
5
|
tslib_1.__exportStar(require("./migrate-badge"), exports);
|
5
6
|
tslib_1.__exportStar(require("./toggles"), exports);
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { UpdateRecorder } from '@angular-devkit/schematics';
|
2
|
+
import { DevkitFileSystem } from 'ng-morph';
|
3
|
+
import { TemplateResource } from '../../../interfaces';
|
4
|
+
export declare function migrateAvatar({ resource, recorder, fileSystem, }: {
|
5
|
+
fileSystem: DevkitFileSystem;
|
6
|
+
recorder: UpdateRecorder;
|
7
|
+
resource: TemplateResource;
|
8
|
+
}): void;
|
@@ -0,0 +1,75 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.migrateAvatar = void 0;
|
4
|
+
const add_import_to_closest_module_1 = require("../../../../utils/add-import-to-closest-module");
|
5
|
+
const elements_1 = require("../../../../utils/templates/elements");
|
6
|
+
const template_resource_1 = require("../../../../utils/templates/template-resource");
|
7
|
+
function migrateAvatar({ resource, recorder, fileSystem, }) {
|
8
|
+
const template = template_resource_1.getTemplateFromTemplateResource(resource, fileSystem);
|
9
|
+
const templateOffset = template_resource_1.getTemplateOffset(resource);
|
10
|
+
const elements = elements_1.findElementsByTagName(template, `tui-avatar`);
|
11
|
+
elements.forEach(({ attrs, sourceCodeLocation }) => {
|
12
|
+
const avatarUrlAttr = attrs.find(attr => attr.name === `[avatarurl]` || attr.name === `avatarurl`);
|
13
|
+
const fallbackAttr = attrs.find(attr => attr.name === `[fallback]` || attr.name === `fallback`);
|
14
|
+
const textAttr = attrs.find(attr => attr.name === `[text]` || attr.name === `text`);
|
15
|
+
const roundedAttr = attrs.find(attr => attr.name === `[rounded]` || attr.name === `rounded`);
|
16
|
+
if ((!avatarUrlAttr && !textAttr) || !sourceCodeLocation) {
|
17
|
+
return;
|
18
|
+
}
|
19
|
+
const urlAttrValue = (avatarUrlAttr === null || avatarUrlAttr === void 0 ? void 0 : avatarUrlAttr.value) &&
|
20
|
+
normalizeAttrValue(avatarUrlAttr.name, avatarUrlAttr.value);
|
21
|
+
const textAttrValue = (textAttr === null || textAttr === void 0 ? void 0 : textAttr.value) && normalizeAttrValue(textAttr.name, textAttr.value);
|
22
|
+
const fallbackAttrValue = (fallbackAttr === null || fallbackAttr === void 0 ? void 0 : fallbackAttr.value) &&
|
23
|
+
normalizeAttrValue(fallbackAttr.name, fallbackAttr.value);
|
24
|
+
const insertTo = sourceCodeLocation.startTag.startOffset + `<tui-avatar`.length;
|
25
|
+
if (!insertTo) {
|
26
|
+
return;
|
27
|
+
}
|
28
|
+
const mainSrc = urlAttrValue || (textAttrValue ? `${textAttrValue} | tuiInitials` : ``);
|
29
|
+
const fallbackValue = urlAttrValue
|
30
|
+
? getFallbackValue(textAttrValue, fallbackAttrValue)
|
31
|
+
: ``;
|
32
|
+
const fallbackSrc = urlAttrValue && fallbackValue
|
33
|
+
? `| tuiFallbackSrc : ${fallbackValue} | async`
|
34
|
+
: ``;
|
35
|
+
recorder.insertRight(insertTo + templateOffset, ` [src]="${mainSrc}${fallbackSrc ? ` ${fallbackSrc}` : ``}"${!roundedAttr ? ` [round]="false"` : ``}`);
|
36
|
+
const attrsToRemove = [avatarUrlAttr, textAttr, fallbackAttr].filter((attr) => attr !== undefined);
|
37
|
+
const fallbackModule = !!((avatarUrlAttr && textAttrValue) || fallbackAttr);
|
38
|
+
const initialsModule = !!textAttrValue;
|
39
|
+
const modules = [
|
40
|
+
...(fallbackModule
|
41
|
+
? [{ moduleName: `TuiFallbackModule`, moduleSpecifier: `@taiga-ui/cdk` }]
|
42
|
+
: []),
|
43
|
+
...(initialsModule
|
44
|
+
? [{ moduleName: `TuiInitialsModule`, moduleSpecifier: `@taiga-ui/cdk` }]
|
45
|
+
: []),
|
46
|
+
];
|
47
|
+
addModules(resource.componentPath, modules);
|
48
|
+
removeAttrs(attrsToRemove, sourceCodeLocation, recorder, templateOffset);
|
49
|
+
});
|
50
|
+
}
|
51
|
+
exports.migrateAvatar = migrateAvatar;
|
52
|
+
function addModules(componentPath, modules) {
|
53
|
+
modules.forEach(({ moduleName, moduleSpecifier }) => {
|
54
|
+
add_import_to_closest_module_1.addImportToClosestModule(componentPath, moduleName, moduleSpecifier);
|
55
|
+
});
|
56
|
+
}
|
57
|
+
function removeAttrs(attrs, sourceCodeLocation, recorder, templateOffset) {
|
58
|
+
attrs.forEach(attr => {
|
59
|
+
var _a;
|
60
|
+
const attrOffset = (_a = sourceCodeLocation.attrs) === null || _a === void 0 ? void 0 : _a[attr.name];
|
61
|
+
if (attrOffset) {
|
62
|
+
const { startOffset, endOffset } = attrOffset;
|
63
|
+
recorder.remove(templateOffset + startOffset - 1, endOffset - startOffset + 1);
|
64
|
+
}
|
65
|
+
});
|
66
|
+
}
|
67
|
+
function getFallbackValue(textValue, fallbackValue) {
|
68
|
+
if (textValue) {
|
69
|
+
return `(${textValue} | tuiInitials)`;
|
70
|
+
}
|
71
|
+
return textValue ? `(${textValue} | tuiInitials)` : fallbackValue || ``;
|
72
|
+
}
|
73
|
+
function normalizeAttrValue(attrName, attrValue) {
|
74
|
+
return attrName.startsWith(`[`) ? attrValue : `'${attrValue}'`;
|
75
|
+
}
|
@@ -9,11 +9,11 @@ function replaceSubstring(text, replacement) {
|
|
9
9
|
function replaceSubstrings(text, replacements) {
|
10
10
|
let transformed = text;
|
11
11
|
let acc = 0;
|
12
|
-
|
12
|
+
replacements.forEach(replacement => {
|
13
13
|
replacement.start += acc;
|
14
14
|
transformed = replaceSubstring(transformed, replacement);
|
15
15
|
acc += replacement.to.length - replacement.from.length;
|
16
|
-
}
|
16
|
+
});
|
17
17
|
return transformed;
|
18
18
|
}
|
19
19
|
exports.replaceSubstrings = replaceSubstrings;
|