@taiga-ui/cdk 3.52.0 → 3.53.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/bundles/taiga-ui-cdk-constants.umd.js +1 -1
- package/bundles/taiga-ui-cdk-constants.umd.js.map +1 -1
- package/bundles/taiga-ui-cdk-directives-for-async.umd.js +6 -1
- package/bundles/taiga-ui-cdk-directives-for-async.umd.js.map +1 -1
- package/constants/version.d.ts +1 -1
- package/constants/version.js +1 -1
- package/directives/for-async/for-async.directive.d.ts +4 -0
- package/directives/for-async/for-async.module.d.ts +2 -1
- package/esm2015/constants/version.js +2 -2
- package/esm2015/directives/for-async/for-async.directive.js +5 -1
- package/esm2015/directives/for-async/for-async.module.js +3 -2
- package/fesm2015/taiga-ui-cdk-constants.js +1 -1
- package/fesm2015/taiga-ui-cdk-constants.js.map +1 -1
- package/fesm2015/taiga-ui-cdk-directives-for-async.js +6 -1
- package/fesm2015/taiga-ui-cdk-directives-for-async.js.map +1 -1
- package/package.json +4 -6
- package/schematics/ng-update/interfaces/html-comment.d.ts +5 -0
- package/schematics/ng-update/interfaces/index.d.ts +14 -0
- package/schematics/ng-update/interfaces/index.js +17 -0
- package/schematics/ng-update/{v3/interfaces/attribute-to-directive.d.ts → interfaces/replacement-attribute-to-directive.d.ts} +1 -1
- package/schematics/ng-update/interfaces/{replaceable-attribute-value.d.ts → replacement-attribute-value.d.ts} +1 -1
- package/schematics/ng-update/interfaces/{replaceable-attribute.d.ts → replacement-attribute.d.ts} +1 -1
- package/schematics/ng-update/interfaces/{replacement-const.d.ts → replacement-identifier.d.ts} +1 -1
- package/schematics/ng-update/interfaces/replacement-service.d.ts +2 -2
- package/schematics/ng-update/interfaces/{replaceable-tag.d.ts → replacement-tag.d.ts} +1 -1
- package/schematics/ng-update/interfaces/{type-to-rename.d.ts → replacement-type.d.ts} +1 -1
- package/schematics/ng-update/interfaces/replacement-type.js +2 -0
- package/schematics/ng-update/steps/icons/replace-imports.d.ts +2 -2
- package/schematics/ng-update/steps/rename-types.d.ts +2 -2
- package/schematics/ng-update/steps/replace-identifier.d.ts +3 -3
- package/schematics/ng-update/steps/replace-identifier.js +5 -5
- package/schematics/ng-update/utils/templates/index.d.ts +6 -0
- package/schematics/ng-update/utils/templates/index.js +9 -0
- package/schematics/ng-update/utils/templates/remove-inputs.d.ts +2 -2
- package/schematics/ng-update/utils/templates/remove-inputs.js +2 -2
- package/schematics/ng-update/utils/templates/replace-attr-values.d.ts +3 -3
- package/schematics/ng-update/utils/templates/replace-attr-values.js +2 -2
- package/schematics/ng-update/utils/templates/replace-attrs-by-directives.d.ts +7 -0
- package/schematics/ng-update/utils/templates/replace-attrs-by-directives.js +18 -0
- package/schematics/ng-update/utils/templates/replace-attrs.d.ts +10 -0
- package/schematics/ng-update/utils/templates/replace-attrs.js +20 -0
- package/schematics/ng-update/utils/templates/replace-tags.d.ts +3 -3
- package/schematics/ng-update/utils/templates/replace-tags.js +2 -2
- package/schematics/ng-update/utils/templates/template-comments.d.ts +10 -0
- package/schematics/ng-update/utils/templates/template-comments.js +20 -0
- package/schematics/ng-update/v3/constants/constants.d.ts +2 -2
- package/schematics/ng-update/v3/constants/deprecated-functions.d.ts +2 -2
- package/schematics/ng-update/v3/constants/templates.d.ts +8 -8
- package/schematics/ng-update/v3/constants/types.d.ts +2 -2
- package/schematics/ng-update/v3/index.js +1 -1
- package/schematics/ng-update/v3/steps/migrate-templates.js +11 -16
- package/schematics/ng-update/v3-30/constants/constants.d.ts +2 -2
- package/schematics/ng-update/v3-35/constants/constants.d.ts +2 -2
- package/schematics/ng-update/v4/index.js +7 -6
- package/schematics/ng-update/v4/steps/constants/attr-to-directive-replace.d.ts +2 -0
- package/schematics/ng-update/v4/steps/constants/attr-to-directive-replace.js +40 -0
- package/schematics/ng-update/v4/steps/constants/attrs-to-replace.d.ts +2 -0
- package/schematics/ng-update/v4/steps/constants/attrs-to-replace.js +47 -0
- package/schematics/ng-update/v4/steps/constants/html-comments.d.ts +2 -0
- package/schematics/ng-update/v4/steps/constants/html-comments.js +10 -0
- package/schematics/ng-update/v4/steps/constants/identifiers-to-replace.d.ts +2 -0
- package/schematics/ng-update/v4/steps/constants/identifiers-to-replace.js +44 -0
- package/schematics/ng-update/v4/steps/constants/index.d.ts +6 -0
- package/schematics/ng-update/v4/steps/constants/index.js +9 -0
- package/schematics/ng-update/v4/steps/constants/inputs-to-remove.d.ts +2 -0
- package/schematics/ng-update/v4/steps/constants/inputs-to-remove.js +8 -0
- package/schematics/ng-update/v4/steps/constants/tags-to-replace.d.ts +2 -0
- package/schematics/ng-update/v4/steps/constants/tags-to-replace.js +7 -0
- package/schematics/ng-update/v4/steps/index.d.ts +3 -0
- package/schematics/ng-update/v4/steps/index.js +6 -0
- package/schematics/ng-update/v4/steps/migrate-templates.d.ts +3 -0
- package/schematics/ng-update/v4/steps/migrate-templates.js +49 -0
- package/schematics/ng-update/v4/steps/templates/index.d.ts +2 -0
- package/schematics/ng-update/v4/steps/templates/index.js +5 -0
- package/schematics/ng-update/v4/steps/templates/migrate-badge.d.ts +8 -0
- package/schematics/ng-update/v4/steps/templates/migrate-badge.js +29 -0
- package/schematics/ng-update/v4/steps/templates/toggles/common.d.ts +10 -0
- package/schematics/ng-update/v4/steps/templates/toggles/common.js +40 -0
- package/schematics/ng-update/v4/steps/templates/toggles/index.d.ts +3 -0
- package/schematics/ng-update/v4/steps/templates/toggles/index.js +6 -0
- package/schematics/ng-update/v4/steps/templates/toggles/migrate-checkbox.d.ts +8 -0
- package/schematics/ng-update/v4/steps/templates/toggles/migrate-checkbox.js +25 -0
- package/schematics/ng-update/v4/steps/templates/toggles/migrate-radio.d.ts +8 -0
- package/schematics/ng-update/v4/steps/templates/toggles/migrate-radio.js +25 -0
- package/schematics/ng-update/v4/steps/templates/toggles/migrate-toggle.d.ts +8 -0
- package/schematics/ng-update/v4/steps/templates/toggles/migrate-toggle.js +25 -0
- package/schematics/utils/add-import-to-closest-module.js +11 -1
- package/schematics/utils/angular/is-standalone-component.d.ts +2 -0
- package/schematics/utils/angular/is-standalone-component.js +22 -0
- package/schematics/ng-update/v4/steps/replace-thumbnail-card.d.ts +0 -4
- package/schematics/ng-update/v4/steps/replace-thumbnail-card.js +0 -86
- /package/schematics/ng-update/interfaces/{replaceable-attribute-value.js → html-comment.js} +0 -0
- /package/schematics/ng-update/interfaces/{replaceable-attribute.js → replacement-attribute-to-directive.js} +0 -0
- /package/schematics/ng-update/interfaces/{replaceable-tag.js → replacement-attribute-value.js} +0 -0
- /package/schematics/ng-update/interfaces/{replacement-const.js → replacement-attribute.js} +0 -0
- /package/schematics/ng-update/interfaces/{type-to-rename.js → replacement-identifier.js} +0 -0
- /package/schematics/ng-update/{v3/interfaces/attribute-to-directive.js → interfaces/replacement-tag.js} +0 -0
@@ -0,0 +1,6 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const tslib_1 = require("tslib");
|
4
|
+
tslib_1.__exportStar(require("./migrate-templates"), exports);
|
5
|
+
tslib_1.__exportStar(require("./restore-tui-mapper"), exports);
|
6
|
+
tslib_1.__exportStar(require("./restore-tui-matcher"), exports);
|
@@ -0,0 +1,49 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.migrateTemplates = void 0;
|
4
|
+
const constants_1 = require("../../../constants");
|
5
|
+
const colored_log_1 = require("../../../utils/colored-log");
|
6
|
+
const progress_1 = require("../../../utils/progress");
|
7
|
+
const get_component_templates_1 = require("../../../utils/templates/get-component-templates");
|
8
|
+
const template_resource_1 = require("../../../utils/templates/template-resource");
|
9
|
+
const templates_1 = require("../../utils/templates");
|
10
|
+
const replace_attrs_by_directives_1 = require("../../utils/templates/replace-attrs-by-directives");
|
11
|
+
const constants_2 = require("./constants");
|
12
|
+
const templates_2 = require("./templates");
|
13
|
+
function migrateTemplates(fileSystem, options) {
|
14
|
+
!options[`skip-logs`] &&
|
15
|
+
colored_log_1.infoLog(`${colored_log_1.SMALL_TAB_SYMBOL}${colored_log_1.REPLACE_SYMBOL} migrating templates...`);
|
16
|
+
const componentWithTemplatesPaths = get_component_templates_1.getComponentTemplates(constants_1.ALL_TS_FILES);
|
17
|
+
const actions = [
|
18
|
+
getAction({ action: templates_1.addHTMLCommentTags, requiredData: constants_2.HTML_COMMENTS }),
|
19
|
+
getAction({
|
20
|
+
action: replace_attrs_by_directives_1.replaceAttrsByDirective,
|
21
|
+
requiredData: constants_2.ATTRS_TO_DIRECTIVE_REPLACE,
|
22
|
+
}),
|
23
|
+
getAction({ action: templates_1.replaceTags, requiredData: constants_2.TAGS_TO_REPLACE }),
|
24
|
+
getAction({ action: templates_1.replaceAttrs, requiredData: constants_2.ATTRS_TO_REPLACE }),
|
25
|
+
getAction({ action: templates_1.removeInputs, requiredData: constants_2.INPUTS_TO_REMOVE }),
|
26
|
+
templates_2.migrateBadgeValue,
|
27
|
+
templates_2.migrateCheckbox,
|
28
|
+
templates_2.migrateRadio,
|
29
|
+
templates_2.migrateToggle,
|
30
|
+
];
|
31
|
+
const progressLog = progress_1.setupProgressLogger({
|
32
|
+
total: componentWithTemplatesPaths.length,
|
33
|
+
});
|
34
|
+
componentWithTemplatesPaths.forEach(resource => {
|
35
|
+
const path = fileSystem.resolve(template_resource_1.getPathFromTemplateResource(resource));
|
36
|
+
const recorder = fileSystem.edit(path);
|
37
|
+
actions.forEach((action, actionIndex) => {
|
38
|
+
const isLastAction = actionIndex === actions.length - 1;
|
39
|
+
!options[`skip-logs`] && progressLog(action.name, isLastAction);
|
40
|
+
action({ resource, fileSystem, recorder });
|
41
|
+
});
|
42
|
+
});
|
43
|
+
!options[`skip-logs`] &&
|
44
|
+
colored_log_1.successLog(`${colored_log_1.SMALL_TAB_SYMBOL}${colored_log_1.SUCCESS_SYMBOL} templates migrated \n`);
|
45
|
+
}
|
46
|
+
exports.migrateTemplates = migrateTemplates;
|
47
|
+
function getAction({ action, requiredData, }) {
|
48
|
+
return ({ resource, fileSystem, recorder, }) => action({ resource, fileSystem, recorder, data: requiredData });
|
49
|
+
}
|
@@ -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 migrateBadgeValue({ resource, recorder, fileSystem, }: {
|
5
|
+
fileSystem: DevkitFileSystem;
|
6
|
+
recorder: UpdateRecorder;
|
7
|
+
resource: TemplateResource;
|
8
|
+
}): void;
|
@@ -0,0 +1,29 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.migrateBadgeValue = void 0;
|
4
|
+
const elements_1 = require("../../../../utils/templates/elements");
|
5
|
+
const template_resource_1 = require("../../../../utils/templates/template-resource");
|
6
|
+
function migrateBadgeValue({ resource, recorder, fileSystem, }) {
|
7
|
+
const template = template_resource_1.getTemplateFromTemplateResource(resource, fileSystem);
|
8
|
+
const templateOffset = template_resource_1.getTemplateOffset(resource);
|
9
|
+
const elements = elements_1.findElementsWithAttributeOnTag(template, [`[value]`, `value`], [`tui-badge`]);
|
10
|
+
elements.forEach(({ attrs, sourceCodeLocation }) => {
|
11
|
+
var _a;
|
12
|
+
const attr = attrs.find(attr => attr.name === `[value]` || attr.name === `value`);
|
13
|
+
if (!attr) {
|
14
|
+
return;
|
15
|
+
}
|
16
|
+
const attrValue = attr === null || attr === void 0 ? void 0 : attr.value;
|
17
|
+
const insertTo = sourceCodeLocation === null || sourceCodeLocation === void 0 ? void 0 : sourceCodeLocation.endTag.startOffset;
|
18
|
+
if (!attrValue || !insertTo) {
|
19
|
+
return;
|
20
|
+
}
|
21
|
+
recorder.insertRight(insertTo + templateOffset, attr.name === `value` ? attrValue : `{{ ${attrValue} }}`);
|
22
|
+
const attrOffset = (_a = sourceCodeLocation === null || sourceCodeLocation === void 0 ? void 0 : sourceCodeLocation.attrs) === null || _a === void 0 ? void 0 : _a[attr.name];
|
23
|
+
if (attrOffset) {
|
24
|
+
const { startOffset, endOffset } = attrOffset;
|
25
|
+
recorder.remove(templateOffset + startOffset - 1, endOffset - startOffset + 1);
|
26
|
+
}
|
27
|
+
});
|
28
|
+
}
|
29
|
+
exports.migrateBadgeValue = migrateBadgeValue;
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import { UpdateRecorder } from '@angular-devkit/schematics';
|
2
|
+
import { Attribute, ElementLocation } from 'parse5';
|
3
|
+
export declare function replaceOpenTag(sourceCodeLocation: ElementLocation, recorder: UpdateRecorder, templateOffset: number, { tag, directive, type }: {
|
4
|
+
tag: string;
|
5
|
+
directive: string;
|
6
|
+
type: string;
|
7
|
+
}): void;
|
8
|
+
export declare function replaceSizeAttr(attrs: Attribute[], sourceCodeLocation: ElementLocation, recorder: UpdateRecorder, templateOffset: number): void;
|
9
|
+
export declare function removeClosingTag(sourceCodeLocation: ElementLocation, recorder: UpdateRecorder, templateOffset: number): void;
|
10
|
+
export declare function closeStartTag({ startTag }: ElementLocation, recorder: UpdateRecorder, templateOffset: number): void;
|
@@ -0,0 +1,40 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.closeStartTag = exports.removeClosingTag = exports.replaceSizeAttr = exports.replaceOpenTag = void 0;
|
4
|
+
const sizeMap = {
|
5
|
+
l: `m`,
|
6
|
+
m: `s`,
|
7
|
+
};
|
8
|
+
function replaceOpenTag(sourceCodeLocation, recorder, templateOffset, { tag, directive, type }) {
|
9
|
+
const { startTag } = sourceCodeLocation;
|
10
|
+
const { startOffset, startCol } = startTag;
|
11
|
+
const spaces = ` `.repeat(startCol + 3);
|
12
|
+
recorder.remove(templateOffset + startOffset, `<${tag}`.length);
|
13
|
+
recorder.insertRight(templateOffset + startOffset, `<input\n${spaces}${directive}\n${spaces}type="${type}"`);
|
14
|
+
}
|
15
|
+
exports.replaceOpenTag = replaceOpenTag;
|
16
|
+
function replaceSizeAttr(attrs, sourceCodeLocation, recorder, templateOffset) {
|
17
|
+
var _a;
|
18
|
+
const sizeAttr = attrs.find(attr => attr.name === `size`);
|
19
|
+
if (sizeAttr) {
|
20
|
+
const { startOffset, endOffset } = ((_a = sourceCodeLocation.attrs) === null || _a === void 0 ? void 0 : _a[sizeAttr.name]) || {
|
21
|
+
startOffset: 0,
|
22
|
+
endOffset: 0,
|
23
|
+
};
|
24
|
+
recorder.remove(templateOffset + startOffset, endOffset - startOffset);
|
25
|
+
recorder.insertRight(templateOffset + startOffset, `size="${sizeMap[sizeAttr.value] || sizeAttr.value}"`);
|
26
|
+
}
|
27
|
+
}
|
28
|
+
exports.replaceSizeAttr = replaceSizeAttr;
|
29
|
+
function removeClosingTag(sourceCodeLocation, recorder, templateOffset) {
|
30
|
+
const { endTag } = sourceCodeLocation;
|
31
|
+
const { startOffset, endOffset } = endTag;
|
32
|
+
const from = templateOffset + startOffset;
|
33
|
+
const to = endOffset - startOffset;
|
34
|
+
recorder.remove(from, to);
|
35
|
+
}
|
36
|
+
exports.removeClosingTag = removeClosingTag;
|
37
|
+
function closeStartTag({ startTag }, recorder, templateOffset) {
|
38
|
+
recorder.insertRight(templateOffset + startTag.endOffset - 1, `/`);
|
39
|
+
}
|
40
|
+
exports.closeStartTag = closeStartTag;
|
@@ -0,0 +1,6 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const tslib_1 = require("tslib");
|
4
|
+
tslib_1.__exportStar(require("./migrate-checkbox"), exports);
|
5
|
+
tslib_1.__exportStar(require("./migrate-radio"), exports);
|
6
|
+
tslib_1.__exportStar(require("./migrate-toggle"), 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 migrateCheckbox({ resource, recorder, fileSystem, }: {
|
5
|
+
fileSystem: DevkitFileSystem;
|
6
|
+
recorder: UpdateRecorder;
|
7
|
+
resource: TemplateResource;
|
8
|
+
}): void;
|
@@ -0,0 +1,25 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.migrateCheckbox = void 0;
|
4
|
+
const elements_1 = require("../../../../../utils/templates/elements");
|
5
|
+
const template_resource_1 = require("../../../../../utils/templates/template-resource");
|
6
|
+
const common_1 = require("./common");
|
7
|
+
function migrateCheckbox({ 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-checkbox`);
|
11
|
+
elements.forEach(({ attrs, sourceCodeLocation }) => {
|
12
|
+
if (!sourceCodeLocation) {
|
13
|
+
return;
|
14
|
+
}
|
15
|
+
common_1.replaceSizeAttr(attrs, sourceCodeLocation, recorder, templateOffset);
|
16
|
+
common_1.replaceOpenTag(sourceCodeLocation, recorder, templateOffset, {
|
17
|
+
tag: `tui-checkbox`,
|
18
|
+
directive: `tuiCheckbox`,
|
19
|
+
type: `checkbox`,
|
20
|
+
});
|
21
|
+
common_1.closeStartTag(sourceCodeLocation, recorder, templateOffset);
|
22
|
+
common_1.removeClosingTag(sourceCodeLocation, recorder, templateOffset);
|
23
|
+
});
|
24
|
+
}
|
25
|
+
exports.migrateCheckbox = migrateCheckbox;
|
@@ -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 migrateRadio({ resource, recorder, fileSystem, }: {
|
5
|
+
fileSystem: DevkitFileSystem;
|
6
|
+
recorder: UpdateRecorder;
|
7
|
+
resource: TemplateResource;
|
8
|
+
}): void;
|
@@ -0,0 +1,25 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.migrateRadio = void 0;
|
4
|
+
const elements_1 = require("../../../../../utils/templates/elements");
|
5
|
+
const template_resource_1 = require("../../../../../utils/templates/template-resource");
|
6
|
+
const common_1 = require("./common");
|
7
|
+
function migrateRadio({ 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-radio`);
|
11
|
+
elements.forEach(({ attrs, sourceCodeLocation }) => {
|
12
|
+
if (!sourceCodeLocation) {
|
13
|
+
return;
|
14
|
+
}
|
15
|
+
common_1.replaceSizeAttr(attrs, sourceCodeLocation, recorder, templateOffset);
|
16
|
+
common_1.replaceOpenTag(sourceCodeLocation, recorder, templateOffset, {
|
17
|
+
tag: `tui-radio`,
|
18
|
+
directive: `tuiRadio`,
|
19
|
+
type: `radio`,
|
20
|
+
});
|
21
|
+
common_1.closeStartTag(sourceCodeLocation, recorder, templateOffset);
|
22
|
+
common_1.removeClosingTag(sourceCodeLocation, recorder, templateOffset);
|
23
|
+
});
|
24
|
+
}
|
25
|
+
exports.migrateRadio = migrateRadio;
|
@@ -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 migrateToggle({ resource, recorder, fileSystem, }: {
|
5
|
+
fileSystem: DevkitFileSystem;
|
6
|
+
recorder: UpdateRecorder;
|
7
|
+
resource: TemplateResource;
|
8
|
+
}): void;
|
@@ -0,0 +1,25 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.migrateToggle = void 0;
|
4
|
+
const elements_1 = require("../../../../../utils/templates/elements");
|
5
|
+
const template_resource_1 = require("../../../../../utils/templates/template-resource");
|
6
|
+
const common_1 = require("./common");
|
7
|
+
function migrateToggle({ 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-toggle`);
|
11
|
+
elements.forEach(({ attrs, sourceCodeLocation }) => {
|
12
|
+
if (!sourceCodeLocation) {
|
13
|
+
return;
|
14
|
+
}
|
15
|
+
common_1.replaceSizeAttr(attrs, sourceCodeLocation, recorder, templateOffset);
|
16
|
+
common_1.replaceOpenTag(sourceCodeLocation, recorder, templateOffset, {
|
17
|
+
tag: `tui-toggle`,
|
18
|
+
directive: `tuiToggle`,
|
19
|
+
type: `checkbox`,
|
20
|
+
});
|
21
|
+
common_1.closeStartTag(sourceCodeLocation, recorder, templateOffset);
|
22
|
+
common_1.removeClosingTag(sourceCodeLocation, recorder, templateOffset);
|
23
|
+
});
|
24
|
+
}
|
25
|
+
exports.migrateToggle = migrateToggle;
|
@@ -2,12 +2,22 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.addImportToClosestModule = void 0;
|
4
4
|
const ng_morph_1 = require("ng-morph");
|
5
|
+
const add_import_to_component_1 = require("../utils/add-import-to-component");
|
5
6
|
const add_unique_import_1 = require("./add-unique-import");
|
7
|
+
const is_standalone_component_1 = require("./angular/is-standalone-component");
|
6
8
|
const ng_component_1 = require("./angular/ng-component");
|
7
9
|
const ng_module_1 = require("./angular/ng-module");
|
8
10
|
function addImportToClosestModule(componentPath, moduleName, moduleSpecifier) {
|
9
11
|
const [ngComponent] = ng_component_1.getNgComponents(componentPath);
|
10
|
-
|
12
|
+
if (!ngComponent) {
|
13
|
+
return;
|
14
|
+
}
|
15
|
+
if (is_standalone_component_1.isStandaloneComponent(ngComponent)) {
|
16
|
+
add_import_to_component_1.addImportToComponent(ngComponent, moduleName, { unique: true });
|
17
|
+
add_unique_import_1.addUniqueImport(ngComponent.getSourceFile().getFilePath(), moduleName, moduleSpecifier);
|
18
|
+
return;
|
19
|
+
}
|
20
|
+
const ngModule = ng_module_1.findNgModule(ngComponent);
|
11
21
|
if (ngModule) {
|
12
22
|
ng_morph_1.addImportToNgModule(ngModule, moduleName, {
|
13
23
|
unique: true,
|
@@ -0,0 +1,22 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.isStandaloneComponent = void 0;
|
4
|
+
const ng_morph_1 = require("ng-morph");
|
5
|
+
// TODO: add to ng-morph
|
6
|
+
function isStandaloneComponent(component) {
|
7
|
+
var _a;
|
8
|
+
const decorator = component.getDecorator(`Component`);
|
9
|
+
if (!decorator) {
|
10
|
+
return false;
|
11
|
+
}
|
12
|
+
const [metadata] = decorator.getArguments();
|
13
|
+
if (!ng_morph_1.Node.isObjectLiteralExpression(metadata)) {
|
14
|
+
return false;
|
15
|
+
}
|
16
|
+
const property = metadata.getProperty(`standalone`);
|
17
|
+
if (!ng_morph_1.Node.isPropertyAssignment(property)) {
|
18
|
+
return false;
|
19
|
+
}
|
20
|
+
return ((_a = property.getInitializer()) === null || _a === void 0 ? void 0 : _a.getText()) === `true`;
|
21
|
+
}
|
22
|
+
exports.isStandaloneComponent = isStandaloneComponent;
|
@@ -1,4 +0,0 @@
|
|
1
|
-
import { DevkitFileSystem } from 'ng-morph';
|
2
|
-
import { TuiSchema } from '../../../ng-add/schema';
|
3
|
-
export declare function replaceThumbnailCard(options: TuiSchema, fileSystem: DevkitFileSystem): void;
|
4
|
-
export declare function replaceReferenceTypes(options: TuiSchema): void;
|
@@ -1,86 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.replaceReferenceTypes = exports.replaceThumbnailCard = void 0;
|
4
|
-
const constants_1 = require("../../../constants");
|
5
|
-
const colored_log_1 = require("../../../utils/colored-log");
|
6
|
-
const elements_1 = require("../../../utils/templates/elements");
|
7
|
-
const get_component_templates_1 = require("../../../utils/templates/get-component-templates");
|
8
|
-
const template_resource_1 = require("../../../utils/templates/template-resource");
|
9
|
-
const replace_identifier_1 = require("../../steps/replace-identifier");
|
10
|
-
const remove_inputs_1 = require("../../utils/templates/remove-inputs");
|
11
|
-
const replace_tags_1 = require("../../utils/templates/replace-tags");
|
12
|
-
function replaceThumbnailCard(options, fileSystem) {
|
13
|
-
replaceCardTemplate(options, fileSystem);
|
14
|
-
replaceReferenceTypes(options);
|
15
|
-
!options[`skip-logs`] && colored_log_1.titleLog(`${colored_log_1.FINISH_SYMBOL} successfully migrated \n`);
|
16
|
-
}
|
17
|
-
exports.replaceThumbnailCard = replaceThumbnailCard;
|
18
|
-
function replaceCardTemplate(options, fileSystem) {
|
19
|
-
!options[`skip-logs`] &&
|
20
|
-
colored_log_1.infoLog(`${colored_log_1.SMALL_TAB_SYMBOL}${colored_log_1.REPLACE_SYMBOL} replacing <tui-card /> to <tui-thumbnail-card />`);
|
21
|
-
const templateResources = get_component_templates_1.getComponentTemplates(constants_1.ALL_TS_FILES);
|
22
|
-
for (const resource of templateResources) {
|
23
|
-
const template = template_resource_1.getTemplateFromTemplateResource(resource, fileSystem);
|
24
|
-
const templateOffset = template_resource_1.getTemplateOffset(resource);
|
25
|
-
const path = fileSystem.resolve(template_resource_1.getPathFromTemplateResource(resource));
|
26
|
-
const recorder = fileSystem.edit(path);
|
27
|
-
replace_tags_1.replaceTags({
|
28
|
-
resource,
|
29
|
-
recorder,
|
30
|
-
fileSystem,
|
31
|
-
replaceableItems: [{ from: `tui-card`, to: `tui-thumbnail-card` }],
|
32
|
-
});
|
33
|
-
replaceCardInputs({ template, recorder, templateOffset });
|
34
|
-
remove_inputs_1.removeInputs({
|
35
|
-
resource,
|
36
|
-
recorder,
|
37
|
-
fileSystem,
|
38
|
-
replaceableItems: [
|
39
|
-
{ inputName: `active`, tags: [`tui-card`, `tui-thumbnail-card`] },
|
40
|
-
],
|
41
|
-
});
|
42
|
-
}
|
43
|
-
}
|
44
|
-
function replaceCardInputs({ template, recorder, templateOffset, }) {
|
45
|
-
const attrsToReplace = [
|
46
|
-
{
|
47
|
-
from: {
|
48
|
-
attrName: `brandLogo`,
|
49
|
-
withTagNames: [`tui-card`, `tui-thumbnail-card`],
|
50
|
-
},
|
51
|
-
to: { attrName: `iconLeft` },
|
52
|
-
},
|
53
|
-
{
|
54
|
-
from: {
|
55
|
-
attrName: `[brandLogo]`,
|
56
|
-
withTagNames: [`tui-card`, `tui-thumbnail-card`],
|
57
|
-
},
|
58
|
-
to: { attrName: `[iconLeft]` },
|
59
|
-
},
|
60
|
-
];
|
61
|
-
for (const { from, to } of attrsToReplace) {
|
62
|
-
const offsets = [
|
63
|
-
...elements_1.findAttributeOnElementWithTag(template, from.attrName, from.withTagNames || []),
|
64
|
-
];
|
65
|
-
offsets.forEach(offset => {
|
66
|
-
recorder.remove(offset + templateOffset, from.attrName.length);
|
67
|
-
recorder.insertRight(offset + templateOffset, to.attrName);
|
68
|
-
});
|
69
|
-
}
|
70
|
-
}
|
71
|
-
function replaceReferenceTypes(options) {
|
72
|
-
!options[`skip-logs`] &&
|
73
|
-
colored_log_1.infoLog(`${colored_log_1.SMALL_TAB_SYMBOL}${colored_log_1.REPLACE_SYMBOL} replacing TuiCard(Module|Component) to TuiThumbnailCard(Module|Component)`);
|
74
|
-
replace_identifier_1.replaceIdentifier({
|
75
|
-
from: { name: `TuiCardModule`, moduleSpecifier: `@taiga-ui/addon-commerce` },
|
76
|
-
to: { name: `TuiThumbnailCardModule`, moduleSpecifier: `@taiga-ui/addon-commerce` },
|
77
|
-
});
|
78
|
-
replace_identifier_1.replaceIdentifier({
|
79
|
-
from: { name: `TuiCardComponent`, moduleSpecifier: `@taiga-ui/addon-commerce` },
|
80
|
-
to: {
|
81
|
-
name: `TuiThumbnailCardComponent`,
|
82
|
-
moduleSpecifier: `@taiga-ui/addon-commerce`,
|
83
|
-
},
|
84
|
-
});
|
85
|
-
}
|
86
|
-
exports.replaceReferenceTypes = replaceReferenceTypes;
|
File without changes
|
File without changes
|
/package/schematics/ng-update/interfaces/{replaceable-tag.js → replacement-attribute-value.js}
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|