@taiga-ui/cdk 4.0.0-rc.7 → 4.0.0-rc.8
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/constants/version.d.ts +1 -1
- package/constants/version.js +1 -1
- package/esm2022/constants/version.mjs +2 -2
- package/fesm2022/taiga-ui-cdk-constants.mjs +1 -1
- package/fesm2022/taiga-ui-cdk-constants.mjs.map +1 -1
- package/package.json +2 -3
- package/schematics/ng-update/steps/replace-identifier.js +2 -3
- package/schematics/ng-update/v4/index.js +1 -0
- package/schematics/ng-update/v4/migrate-icons/rename-proprietary-icons.js +3 -3
- package/schematics/ng-update/v4/steps/constants/attrs-to-replace.js +26 -3
- package/schematics/ng-update/v4/steps/constants/html-comments.js +5 -0
- package/schematics/ng-update/v4/steps/constants/identifiers-to-replace.js +63 -22
- package/schematics/ng-update/v4/steps/constants/inputs-to-remove.js +1 -0
- package/schematics/ng-update/v4/steps/constants/migration-warnings.js +10 -0
- package/schematics/ng-update/v4/steps/constants/modules-to-remove.js +4 -0
- package/schematics/ng-update/v4/steps/constants/tags-to-replace.js +3 -2
- package/schematics/ng-update/v4/steps/constants/types.js +17 -0
- package/schematics/ng-update/v4/steps/index.d.ts +2 -1
- package/schematics/ng-update/v4/steps/index.js +2 -1
- package/schematics/ng-update/v4/steps/migrate-alert-service.d.ts +2 -0
- package/schematics/ng-update/v4/steps/migrate-alert-service.js +88 -0
- package/schematics/ng-update/v4/steps/migrate-templates.js +5 -0
- package/schematics/ng-update/v4/steps/{migrate-styles.js → styles/index.js} +2 -0
- package/schematics/ng-update/v4/steps/styles/migrate-space-mixins.d.ts +1 -0
- package/schematics/ng-update/v4/steps/styles/migrate-space-mixins.js +20 -0
- package/schematics/ng-update/v4/steps/templates/index.d.ts +3 -0
- package/schematics/ng-update/v4/steps/templates/index.js +3 -0
- package/schematics/ng-update/v4/steps/templates/migrate-avatar.js +10 -5
- package/schematics/ng-update/v4/steps/templates/migrate-axes.d.ts +8 -0
- package/schematics/ng-update/v4/steps/templates/migrate-axes.js +26 -0
- package/schematics/ng-update/v4/steps/templates/migrate-badge.js +7 -6
- package/schematics/ng-update/v4/steps/templates/migrate-blocked.js +2 -1
- package/schematics/ng-update/v4/steps/templates/migrate-expandable.js +3 -2
- package/schematics/ng-update/v4/steps/templates/migrate-focusable.js +7 -4
- package/schematics/ng-update/v4/steps/templates/migrate-mobile-tabs.d.ts +8 -0
- package/schematics/ng-update/v4/steps/templates/migrate-mobile-tabs.js +45 -0
- package/schematics/ng-update/v4/steps/templates/migrate-notification.d.ts +8 -0
- package/schematics/ng-update/v4/steps/templates/migrate-notification.js +46 -0
- package/schematics/ng-update/v4/steps/templates/migrate-number-precision.d.ts +8 -0
- package/schematics/ng-update/v4/steps/templates/migrate-number-precision.js +36 -0
- package/schematics/ng-update/v4/steps/templates/migrate-overscroll.js +4 -6
- package/schematics/ng-update/v4/steps/templates/migrate-thumbnail-card.js +2 -1
- package/schematics/ng-update/v4/steps/templates/toggles/common.js +3 -2
- package/schematics/ng-update/v4/steps/templates/toggles/migrate-checkbox.js +2 -1
- package/schematics/ng-update/v4/steps/update-packages.js +13 -4
- package/schematics/utils/templates/elements.js +2 -1
- package/schematics/utils/templates/inputs.js +2 -1
- /package/schematics/ng-update/v4/steps/{migrate-styles.d.ts → styles/index.d.ts} +0 -0
@@ -0,0 +1,20 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.migrateSpaceMixins = void 0;
|
4
|
+
const DIRECTION_MAPPING = {
|
5
|
+
all: ['margin'],
|
6
|
+
top: ['margin-top'],
|
7
|
+
bottom: ['margin-bottom'],
|
8
|
+
left: ['margin-left'],
|
9
|
+
right: ['margin-right'],
|
10
|
+
vertical: ['margin-top', 'margin-bottom'],
|
11
|
+
horizontal: ['margin-left', 'margin-right'],
|
12
|
+
};
|
13
|
+
const SPACE = 0.25;
|
14
|
+
// .tui-space(top, 4);
|
15
|
+
// @include tui-space(top, 4);
|
16
|
+
const MIXIN_RE = new RegExp(`(?:@include\\s|\\.)tui-space\\((?<direction>${Object.keys(DIRECTION_MAPPING).join('|')}),\\s?(?<size>-?\\d+)\\);`, 'g');
|
17
|
+
function migrateSpaceMixins(fileContent) {
|
18
|
+
return fileContent.replaceAll(MIXIN_RE, (_, direction, size) => `${DIRECTION_MAPPING[direction].map((property) => `${property}: ${Number(size) * SPACE}rem;`).join('\n')}`);
|
19
|
+
}
|
20
|
+
exports.migrateSpaceMixins = migrateSpaceMixins;
|
@@ -1,4 +1,5 @@
|
|
1
1
|
export * from './migrate-avatar';
|
2
|
+
export * from './migrate-axes';
|
2
3
|
export * from './migrate-badge';
|
3
4
|
export * from './migrate-badged-content';
|
4
5
|
export * from './migrate-button-appearance';
|
@@ -6,7 +7,9 @@ export * from './migrate-expandable';
|
|
6
7
|
export * from './migrate-focusable';
|
7
8
|
export * from './migrate-label';
|
8
9
|
export * from './migrate-labeled';
|
10
|
+
export * from './migrate-mobile-tabs';
|
9
11
|
export * from './migrate-money';
|
12
|
+
export * from './migrate-notification';
|
10
13
|
export * from './migrate-overscroll';
|
11
14
|
export * from './migrate-prevent-default';
|
12
15
|
export * from './migrate-progress-segmented';
|
@@ -2,6 +2,7 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
const tslib_1 = require("tslib");
|
4
4
|
tslib_1.__exportStar(require("./migrate-avatar"), exports);
|
5
|
+
tslib_1.__exportStar(require("./migrate-axes"), exports);
|
5
6
|
tslib_1.__exportStar(require("./migrate-badge"), exports);
|
6
7
|
tslib_1.__exportStar(require("./migrate-badged-content"), exports);
|
7
8
|
tslib_1.__exportStar(require("./migrate-button-appearance"), exports);
|
@@ -9,7 +10,9 @@ tslib_1.__exportStar(require("./migrate-expandable"), exports);
|
|
9
10
|
tslib_1.__exportStar(require("./migrate-focusable"), exports);
|
10
11
|
tslib_1.__exportStar(require("./migrate-label"), exports);
|
11
12
|
tslib_1.__exportStar(require("./migrate-labeled"), exports);
|
13
|
+
tslib_1.__exportStar(require("./migrate-mobile-tabs"), exports);
|
12
14
|
tslib_1.__exportStar(require("./migrate-money"), exports);
|
15
|
+
tslib_1.__exportStar(require("./migrate-notification"), exports);
|
13
16
|
tslib_1.__exportStar(require("./migrate-overscroll"), exports);
|
14
17
|
tslib_1.__exportStar(require("./migrate-prevent-default"), exports);
|
15
18
|
tslib_1.__exportStar(require("./migrate-progress-segmented"), exports);
|
@@ -22,9 +22,6 @@ function addModules(componentPath, modules) {
|
|
22
22
|
});
|
23
23
|
}
|
24
24
|
function getFallbackValue(textValue, fallbackValue) {
|
25
|
-
if (textValue) {
|
26
|
-
return `(${textValue} | tuiInitials)`;
|
27
|
-
}
|
28
25
|
return textValue ? `(${textValue} | tuiInitials)` : fallbackValue || '';
|
29
26
|
}
|
30
27
|
function normalizeAttrValue(attrName, attrValue) {
|
@@ -47,6 +44,7 @@ function migrateAvatar({ resource, recorder, fileSystem, }) {
|
|
47
44
|
const fallbackAttr = (0, inputs_1.findAttr)(attrs, 'fallback');
|
48
45
|
const textAttr = (0, inputs_1.findAttr)(attrs, 'text');
|
49
46
|
const roundedAttr = (0, inputs_1.findAttr)(attrs, 'rounded');
|
47
|
+
const autoColorAttr = (0, inputs_1.findAttr)(attrs, 'autoColor');
|
50
48
|
if ((!avatarUrlAttr && !textAttr) || !sourceCodeLocation) {
|
51
49
|
return;
|
52
50
|
}
|
@@ -55,6 +53,8 @@ function migrateAvatar({ resource, recorder, fileSystem, }) {
|
|
55
53
|
const textAttrValue = (textAttr === null || textAttr === void 0 ? void 0 : textAttr.value) && normalizeAttrValue(textAttr.name, textAttr.value);
|
56
54
|
const fallbackAttrValue = (fallbackAttr === null || fallbackAttr === void 0 ? void 0 : fallbackAttr.value) &&
|
57
55
|
normalizeAttrValue(fallbackAttr.name, fallbackAttr.value);
|
56
|
+
const autoColorValue = (autoColorAttr === null || autoColorAttr === void 0 ? void 0 : autoColorAttr.value) &&
|
57
|
+
normalizeAttrValue(autoColorAttr.name, autoColorAttr.value);
|
58
58
|
const insertTo = ((_b = (_a = sourceCodeLocation.startTag) === null || _a === void 0 ? void 0 : _a.startOffset) !== null && _b !== void 0 ? _b : 0) + '<tui-avatar'.length;
|
59
59
|
if (!insertTo) {
|
60
60
|
return;
|
@@ -66,8 +66,13 @@ function migrateAvatar({ resource, recorder, fileSystem, }) {
|
|
66
66
|
const fallbackSrc = urlAttrValue && fallbackValue
|
67
67
|
? `| tuiFallbackSrc : ${fallbackValue} | async`
|
68
68
|
: '';
|
69
|
-
recorder.insertRight(insertTo + templateOffset, ` [src]="${mainSrc}${fallbackSrc ? ` ${fallbackSrc}` : ''}"${!roundedAttr ? ' [round]="false"' : ''}`);
|
70
|
-
const attrsToRemove = [
|
69
|
+
recorder.insertRight(insertTo + templateOffset, ` [src]="${mainSrc}${fallbackSrc ? ` ${fallbackSrc}` : ''}"${!roundedAttr ? ' [round]="false"' : ''}${autoColorValue === 'true' ? ` [style.background]="${textAttrValue} | tuiAutoColor"` : ''}`);
|
70
|
+
const attrsToRemove = [
|
71
|
+
avatarUrlAttr,
|
72
|
+
textAttr,
|
73
|
+
fallbackAttr,
|
74
|
+
autoColorAttr,
|
75
|
+
].filter((attr) => attr !== undefined);
|
71
76
|
const fallbackModule = !!((avatarUrlAttr && textAttrValue) || fallbackAttr);
|
72
77
|
const initialsModule = !!textAttrValue;
|
73
78
|
const modules = [
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import type { UpdateRecorder } from '@angular-devkit/schematics';
|
2
|
+
import type { DevkitFileSystem } from 'ng-morph';
|
3
|
+
import type { TemplateResource } from '../../../interfaces';
|
4
|
+
export declare function migrateAxes({ resource, recorder, fileSystem, }: {
|
5
|
+
fileSystem: DevkitFileSystem;
|
6
|
+
recorder: UpdateRecorder;
|
7
|
+
resource: TemplateResource;
|
8
|
+
}): void;
|
@@ -0,0 +1,26 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.migrateAxes = void 0;
|
4
|
+
const elements_1 = require("../../../../utils/templates/elements");
|
5
|
+
const template_resource_1 = require("../../../../utils/templates/template-resource");
|
6
|
+
const remove_attrs_1 = require("../utils/remove-attrs");
|
7
|
+
const AXES_TAG_NAME = 'tui-axes';
|
8
|
+
const AXES_NEW_ATTRIBUTE = 'new';
|
9
|
+
function migrateAxes({ resource, recorder, fileSystem, }) {
|
10
|
+
const template = (0, template_resource_1.getTemplateFromTemplateResource)(resource, fileSystem);
|
11
|
+
const templateOffset = (0, template_resource_1.getTemplateOffset)(resource);
|
12
|
+
const elements = (0, elements_1.findElementsByTagName)(template, AXES_TAG_NAME);
|
13
|
+
elements.forEach(({ attrs, sourceCodeLocation }) => {
|
14
|
+
const axesNewAttr = attrs.find((attr) => attr.name === AXES_NEW_ATTRIBUTE);
|
15
|
+
if (!sourceCodeLocation) {
|
16
|
+
return;
|
17
|
+
}
|
18
|
+
if (axesNewAttr) {
|
19
|
+
(0, remove_attrs_1.removeAttrs)([axesNewAttr], sourceCodeLocation, recorder, templateOffset);
|
20
|
+
}
|
21
|
+
else {
|
22
|
+
recorder.insertLeft(sourceCodeLocation.startOffset + templateOffset, '<!-- TODO: (Taiga UI migration) labels positioning on x axes were updated. Add empty string to axisXLabels array. See https://taiga-ui.dev/charts/axes -->\n');
|
23
|
+
}
|
24
|
+
});
|
25
|
+
}
|
26
|
+
exports.migrateAxes = migrateAxes;
|
@@ -2,6 +2,7 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.migrateBadge = void 0;
|
4
4
|
const elements_1 = require("../../../../utils/templates/elements");
|
5
|
+
const inputs_1 = require("../../../../utils/templates/inputs");
|
5
6
|
const template_resource_1 = require("../../../../utils/templates/template-resource");
|
6
7
|
const common_1 = require("./toggles/common");
|
7
8
|
const badgeSizeMap = {
|
@@ -19,7 +20,7 @@ function migrateBadge({ resource, recorder, fileSystem, }) {
|
|
19
20
|
return;
|
20
21
|
}
|
21
22
|
(0, common_1.replaceSizeAttr)(attrs, sourceCodeLocation, recorder, templateOffset, badgeSizeMap);
|
22
|
-
const valueAttr =
|
23
|
+
const valueAttr = (0, inputs_1.findAttr)(attrs, 'value');
|
23
24
|
// migration for icon-only badges
|
24
25
|
if (!valueAttr) {
|
25
26
|
addTodo(recorder, sourceCodeLocation, templateOffset);
|
@@ -39,16 +40,16 @@ function migrateBadge({ resource, recorder, fileSystem, }) {
|
|
39
40
|
}
|
40
41
|
exports.migrateBadge = migrateBadge;
|
41
42
|
function migrateIcon({ svg, sourceCodeLocation, recorder, templateOffset, }) {
|
42
|
-
var _a, _b, _c, _d
|
43
|
-
const src = (
|
43
|
+
var _a, _b, _c, _d;
|
44
|
+
const src = (0, inputs_1.findAttr)(svg.attrs, 'src');
|
44
45
|
const srcValue = src === null || src === void 0 ? void 0 : src.value;
|
45
46
|
if (!srcValue) {
|
46
47
|
return;
|
47
48
|
}
|
48
|
-
const insertTo = templateOffset + (((
|
49
|
+
const insertTo = templateOffset + (((_a = sourceCodeLocation === null || sourceCodeLocation === void 0 ? void 0 : sourceCodeLocation.startTag) === null || _a === void 0 ? void 0 : _a.endOffset) || 0) - 1;
|
49
50
|
recorder.insertRight(insertTo, `${(src === null || src === void 0 ? void 0 : src.name) === 'src' ? 'iconStart' : '[iconStart]'}="${srcValue}"`);
|
50
|
-
recorder.remove(((
|
51
|
-
(((
|
51
|
+
recorder.remove(((_b = svg.sourceCodeLocation) === null || _b === void 0 ? void 0 : _b.startOffset) || 0, (((_c = svg.sourceCodeLocation) === null || _c === void 0 ? void 0 : _c.endOffset) || 0) -
|
52
|
+
(((_d = svg.sourceCodeLocation) === null || _d === void 0 ? void 0 : _d.startOffset) || 0));
|
52
53
|
}
|
53
54
|
function migrateBadgeValue({ valueAttr, sourceCodeLocation, recorder, templateOffset, }) {
|
54
55
|
var _a, _b, _c, _d, _e;
|
@@ -2,6 +2,7 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.migrateBlocked = void 0;
|
4
4
|
const elements_1 = require("../../../../utils/templates/elements");
|
5
|
+
const inputs_1 = require("../../../../utils/templates/inputs");
|
5
6
|
const template_resource_1 = require("../../../../utils/templates/template-resource");
|
6
7
|
function migrateBlocked({ resource, recorder, fileSystem, }) {
|
7
8
|
const template = (0, template_resource_1.getTemplateFromTemplateResource)(resource, fileSystem);
|
@@ -18,7 +19,7 @@ function migrateBlocked({ resource, recorder, fileSystem, }) {
|
|
18
19
|
const [, hideIconAttrLocation] = Object.entries(sourceCodeLocation.attrs || {}).find(([name]) => name.includes('hideCheckbox'.toLowerCase()) ||
|
19
20
|
name.includes('hideRadio'.toLowerCase())) || [];
|
20
21
|
const [, sizeAttrLocation] = Object.entries(sourceCodeLocation.attrs || {}).find(([name]) => name.includes('size')) || [];
|
21
|
-
const sizeAttr =
|
22
|
+
const sizeAttr = (0, inputs_1.findAttr)(attrs, 'size');
|
22
23
|
const newBlockAttr = `tuiBlock${sizeAttr ? `="${sizeAttr.value === 'xs' ? 's' : sizeAttr.value}"` : ''}`;
|
23
24
|
recorder.insertRight(templateOffset + (((_a = sourceCodeLocation.startTag) === null || _a === void 0 ? void 0 : _a.startOffset) || 1) - 1, `<label ${newBlockAttr}${hideIconAttrLocation ? ' appearance=""' : ''}>`);
|
24
25
|
recorder.remove(templateOffset + ((_c = (_b = sourceCodeLocation.endTag) === null || _b === void 0 ? void 0 : _b.startOffset) !== null && _c !== void 0 ? _c : 0), `<${tagName}/>`.length);
|
@@ -2,6 +2,7 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.migrateExpandable = void 0;
|
4
4
|
const elements_1 = require("../../../../utils/templates/elements");
|
5
|
+
const inputs_1 = require("../../../../utils/templates/inputs");
|
5
6
|
const template_resource_1 = require("../../../../utils/templates/template-resource");
|
6
7
|
function migrateExpandable({ resource, recorder, fileSystem, }) {
|
7
8
|
const template = (0, template_resource_1.getTemplateFromTemplateResource)(resource, fileSystem);
|
@@ -9,7 +10,7 @@ function migrateExpandable({ resource, recorder, fileSystem, }) {
|
|
9
10
|
const elements = (0, elements_1.findElementsWithAttributeOnTag)(template, ['[expandable]'], ['tui-input-tag', 'tui-multi-select', 'tui-input-date']);
|
10
11
|
elements.forEach(({ attrs, sourceCodeLocation }) => {
|
11
12
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
12
|
-
const expandableAttr =
|
13
|
+
const expandableAttr = (0, inputs_1.findAttr)(attrs, 'expandable');
|
13
14
|
if (!expandableAttr) {
|
14
15
|
return;
|
15
16
|
}
|
@@ -17,7 +18,7 @@ function migrateExpandable({ resource, recorder, fileSystem, }) {
|
|
17
18
|
const expandableStart = (_c = (_b = (_a = sourceCodeLocation === null || sourceCodeLocation === void 0 ? void 0 : sourceCodeLocation.attrs) === null || _a === void 0 ? void 0 : _a[expandableAttr.name]) === null || _b === void 0 ? void 0 : _b.startOffset) !== null && _c !== void 0 ? _c : 0;
|
18
19
|
const expandableEnd = (_f = (_e = (_d = sourceCodeLocation === null || sourceCodeLocation === void 0 ? void 0 : sourceCodeLocation.attrs) === null || _d === void 0 ? void 0 : _d[expandableAttr.name]) === null || _e === void 0 ? void 0 : _e.endOffset) !== null && _f !== void 0 ? _f : 0;
|
19
20
|
if (expandableValue === 'false') {
|
20
|
-
const rowsAttr =
|
21
|
+
const rowsAttr = (0, inputs_1.findAttr)(attrs, 'rows');
|
21
22
|
const insertTo = ((_h = (_g = sourceCodeLocation === null || sourceCodeLocation === void 0 ? void 0 : sourceCodeLocation.startTag) === null || _g === void 0 ? void 0 : _g.endOffset) !== null && _h !== void 0 ? _h : 0) - 1;
|
22
23
|
recorder.insertRight(templateOffset + insertTo, rowsAttr ? '' : '[rows]="1"');
|
23
24
|
}
|
@@ -2,19 +2,22 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.migrateFocusable = void 0;
|
4
4
|
const elements_1 = require("../../../../utils/templates/elements");
|
5
|
+
const inputs_1 = require("../../../../utils/templates/inputs");
|
5
6
|
const template_resource_1 = require("../../../../utils/templates/template-resource");
|
6
|
-
const LEGACY_ATTRIBUTE_NAME = '
|
7
|
+
const LEGACY_ATTRIBUTE_NAME = 'tuiFocusable';
|
7
8
|
function migrateFocusable({ resource, recorder, fileSystem, }) {
|
8
9
|
const template = (0, template_resource_1.getTemplateFromTemplateResource)(resource, fileSystem);
|
9
10
|
const templateOffset = (0, template_resource_1.getTemplateOffset)(resource);
|
10
|
-
const elements = (0, elements_1.findElementsWithAttributeOnTag)(template, [
|
11
|
+
const elements = (0, elements_1.findElementsWithAttributeOnTag)(template, [
|
12
|
+
`[${LEGACY_ATTRIBUTE_NAME}]`,
|
13
|
+
]);
|
11
14
|
elements.forEach(({ attrs, sourceCodeLocation }) => {
|
12
15
|
var _a;
|
13
16
|
if (!sourceCodeLocation) {
|
14
17
|
return;
|
15
18
|
}
|
16
|
-
const focusableAttr =
|
17
|
-
const attributeLocation = (_a = sourceCodeLocation.attrs) === null || _a === void 0 ? void 0 : _a[
|
19
|
+
const focusableAttr = (0, inputs_1.findAttr)(attrs, LEGACY_ATTRIBUTE_NAME);
|
20
|
+
const attributeLocation = (_a = sourceCodeLocation.attrs) === null || _a === void 0 ? void 0 : _a[focusableAttr.name];
|
18
21
|
if (!focusableAttr || !attributeLocation) {
|
19
22
|
return;
|
20
23
|
}
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import type { UpdateRecorder } from '@angular-devkit/schematics';
|
2
|
+
import type { DevkitFileSystem } from 'ng-morph';
|
3
|
+
import type { TemplateResource } from '../../../interfaces';
|
4
|
+
export declare function migrateMobileTabs({ resource, recorder, fileSystem, }: {
|
5
|
+
fileSystem: DevkitFileSystem;
|
6
|
+
recorder: UpdateRecorder;
|
7
|
+
resource: TemplateResource;
|
8
|
+
}): void;
|
@@ -0,0 +1,45 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.migrateMobileTabs = 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
|
+
const templates_1 = require("../../../utils/templates");
|
8
|
+
const remove_attrs_1 = require("../utils/remove-attrs");
|
9
|
+
const TABS_TAG_NAME = 'tui-tabs';
|
10
|
+
const SEGMENTED_TAG_NAME = 'tui-segmented';
|
11
|
+
const TAB_ATTRIBUTE_NAME = 'tuiTab'.toLowerCase();
|
12
|
+
const MOBILE_TABS_ATTRIBUTE_NAME = 'tuiMobileTabs'.toLowerCase();
|
13
|
+
function migrateMobileTabs({ resource, recorder, fileSystem, }) {
|
14
|
+
const template = (0, template_resource_1.getTemplateFromTemplateResource)(resource, fileSystem);
|
15
|
+
const templateOffset = (0, template_resource_1.getTemplateOffset)(resource);
|
16
|
+
const elements = (0, elements_1.findElementsWithAttributeOnTag)(template, [MOBILE_TABS_ATTRIBUTE_NAME], [TABS_TAG_NAME]);
|
17
|
+
if (elements.length > 0) {
|
18
|
+
(0, add_import_to_closest_module_1.addImportToClosestModule)(resource.componentPath, 'TuiSegmented', '@taiga-ui/kit');
|
19
|
+
}
|
20
|
+
elements.forEach((element) => {
|
21
|
+
(0, templates_1.replaceTag)(recorder, element.sourceCodeLocation, TABS_TAG_NAME, SEGMENTED_TAG_NAME, templateOffset);
|
22
|
+
removeMobileTabsAttribute(element, recorder, templateOffset);
|
23
|
+
element.childNodes
|
24
|
+
.filter(isElement)
|
25
|
+
.forEach((element) => removeTabAttribute(element, recorder, templateOffset));
|
26
|
+
});
|
27
|
+
}
|
28
|
+
exports.migrateMobileTabs = migrateMobileTabs;
|
29
|
+
function removeTabAttribute({ attrs, sourceCodeLocation }, recorder, templateOffset) {
|
30
|
+
const tabAttr = attrs.find((attr) => attr.name === TAB_ATTRIBUTE_NAME);
|
31
|
+
if (!tabAttr || !sourceCodeLocation) {
|
32
|
+
return;
|
33
|
+
}
|
34
|
+
(0, remove_attrs_1.removeAttrs)([tabAttr], sourceCodeLocation, recorder, templateOffset);
|
35
|
+
}
|
36
|
+
function removeMobileTabsAttribute({ attrs, sourceCodeLocation }, recorder, templateOffset) {
|
37
|
+
const mobileTabsAttr = attrs.find((attr) => attr.name === MOBILE_TABS_ATTRIBUTE_NAME);
|
38
|
+
if (!mobileTabsAttr || !sourceCodeLocation) {
|
39
|
+
return;
|
40
|
+
}
|
41
|
+
(0, remove_attrs_1.removeAttrs)([mobileTabsAttr], sourceCodeLocation, recorder, templateOffset);
|
42
|
+
}
|
43
|
+
function isElement(node) {
|
44
|
+
return Boolean(node.attrs);
|
45
|
+
}
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import type { UpdateRecorder } from '@angular-devkit/schematics';
|
2
|
+
import type { DevkitFileSystem } from 'ng-morph';
|
3
|
+
import type { TemplateResource } from '../../../interfaces';
|
4
|
+
export declare function migrateNotification({ resource, recorder, fileSystem, }: {
|
5
|
+
fileSystem: DevkitFileSystem;
|
6
|
+
recorder: UpdateRecorder;
|
7
|
+
resource: TemplateResource;
|
8
|
+
}): void;
|
@@ -0,0 +1,46 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.migrateNotification = void 0;
|
4
|
+
const ng_morph_1 = require("ng-morph");
|
5
|
+
const add_import_to_closest_module_1 = require("../../../../utils/add-import-to-closest-module");
|
6
|
+
const elements_1 = require("../../../../utils/templates/elements");
|
7
|
+
const inputs_1 = require("../../../../utils/templates/inputs");
|
8
|
+
const template_resource_1 = require("../../../../utils/templates/template-resource");
|
9
|
+
function migrateNotification({ resource, recorder, fileSystem, }) {
|
10
|
+
const template = (0, template_resource_1.getTemplateFromTemplateResource)(resource, fileSystem);
|
11
|
+
const templateOffset = (0, template_resource_1.getTemplateOffset)(resource);
|
12
|
+
const elements = [
|
13
|
+
...(0, elements_1.findElementsByTagNames)(template, ['tui-notification']),
|
14
|
+
...(0, elements_1.findElementsWithAttributeOnTag)(template, ['tuiNotification'], ['button', 'a']),
|
15
|
+
];
|
16
|
+
elements.forEach(({ attrs, sourceCodeLocation, tagName, childNodes }) => {
|
17
|
+
var _a, _b, _c;
|
18
|
+
const sizeAttr = (0, inputs_1.findAttr)(attrs, 'size');
|
19
|
+
const hideCloseAttr = (0, inputs_1.findAttr)(attrs, 'hideClose');
|
20
|
+
const closeListener = (0, inputs_1.findAttr)(attrs, '(close)');
|
21
|
+
const { startTag, endTag } = sourceCodeLocation || {};
|
22
|
+
const hideCloseAttrLocation = (_a = sourceCodeLocation === null || sourceCodeLocation === void 0 ? void 0 : sourceCodeLocation.attrs) === null || _a === void 0 ? void 0 : _a[(hideCloseAttr === null || hideCloseAttr === void 0 ? void 0 : hideCloseAttr.name) || ''];
|
23
|
+
if (!sizeAttr) {
|
24
|
+
recorder.insertRight(templateOffset + ((_b = startTag === null || startTag === void 0 ? void 0 : startTag.startOffset) !== null && _b !== void 0 ? _b : 0) + `<${tagName}`.length, ' size="m"');
|
25
|
+
}
|
26
|
+
if (closeListener) {
|
27
|
+
const hasProprietaryPackages = !!(0, ng_morph_1.getPackageJsonDependency)(fileSystem.tree, '@taiga-ui/proprietary-core');
|
28
|
+
(0, add_import_to_closest_module_1.addImportToClosestModule)(resource.componentPath, 'NgIf', '@angular/common');
|
29
|
+
const ifCondition = hideCloseAttr ? ` *ngIf="!${hideCloseAttr.value}"` : '';
|
30
|
+
const closeIconName = hasProprietaryPackages
|
31
|
+
? '@tui.pragmatic.small.cross'
|
32
|
+
: '@tui.x';
|
33
|
+
const closeButtonTemplate = ` <button${ifCondition} tuiIconButton iconStart="${closeIconName}"></button>`;
|
34
|
+
recorder.insertRight(templateOffset + ((_c = endTag === null || endTag === void 0 ? void 0 : endTag.startOffset) !== null && _c !== void 0 ? _c : 0), closeButtonTemplate);
|
35
|
+
if (hideCloseAttrLocation) {
|
36
|
+
const { startOffset, endOffset } = hideCloseAttrLocation;
|
37
|
+
recorder.remove(templateOffset + startOffset, endOffset - startOffset);
|
38
|
+
}
|
39
|
+
}
|
40
|
+
if (childNodes.length > 1 && startTag && endTag) {
|
41
|
+
recorder.insertRight(templateOffset + startTag.endOffset, '<div>');
|
42
|
+
recorder.insertLeft(templateOffset + endTag.startOffset, '</div>');
|
43
|
+
}
|
44
|
+
});
|
45
|
+
}
|
46
|
+
exports.migrateNotification = migrateNotification;
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import type { UpdateRecorder } from '@angular-devkit/schematics';
|
2
|
+
import type { DevkitFileSystem } from 'ng-morph';
|
3
|
+
import type { TemplateResource } from '../../../../ng-update/interfaces';
|
4
|
+
export declare function migrateNumberPrecision({ resource, recorder, fileSystem, }: {
|
5
|
+
fileSystem: DevkitFileSystem;
|
6
|
+
recorder: UpdateRecorder;
|
7
|
+
resource: TemplateResource;
|
8
|
+
}): void;
|
@@ -0,0 +1,36 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.migrateNumberPrecision = void 0;
|
4
|
+
const remove_attrs_1 = require("../../../../ng-update/v4/steps/utils/remove-attrs");
|
5
|
+
const add_import_to_closest_module_1 = require("../../../../utils/add-import-to-closest-module");
|
6
|
+
const elements_1 = require("../../../../utils/templates/elements");
|
7
|
+
const inputs_1 = require("../../../../utils/templates/inputs");
|
8
|
+
const template_resource_1 = require("../../../../utils/templates/template-resource");
|
9
|
+
const clean_object_1 = require("../utils/clean-object");
|
10
|
+
function migrateNumberPrecision({ resource, recorder, fileSystem, }) {
|
11
|
+
const template = (0, template_resource_1.getTemplateFromTemplateResource)(resource, fileSystem);
|
12
|
+
const templateOffset = (0, template_resource_1.getTemplateOffset)(resource);
|
13
|
+
const elements = (0, elements_1.findElementsByTagName)(template, 'tui-input-number');
|
14
|
+
elements.forEach(({ attrs, sourceCodeLocation }) => {
|
15
|
+
var _a;
|
16
|
+
if (!sourceCodeLocation) {
|
17
|
+
return;
|
18
|
+
}
|
19
|
+
const decimalAttr = (0, inputs_1.findAttr)(attrs, 'decimal');
|
20
|
+
const precisionAttr = (0, inputs_1.findAttr)(attrs, 'precision');
|
21
|
+
if (decimalAttr || precisionAttr) {
|
22
|
+
(0, add_import_to_closest_module_1.addImportToClosestModule)(resource.componentPath, 'TuiNumberFormat', '@taiga-ui/core');
|
23
|
+
const format = JSON.stringify((0, clean_object_1.cleanObject)({
|
24
|
+
decimalMode: decimalAttr === null || decimalAttr === void 0 ? void 0 : decimalAttr.value,
|
25
|
+
precision: precisionAttr === null || precisionAttr === void 0 ? void 0 : precisionAttr.value,
|
26
|
+
}));
|
27
|
+
const formatPart = `[tuiNumberFormat]='${format}'`;
|
28
|
+
const insertTo = (((_a = sourceCodeLocation === null || sourceCodeLocation === void 0 ? void 0 : sourceCodeLocation.startTag) === null || _a === void 0 ? void 0 : _a.startOffset) || 0) +
|
29
|
+
'<tui-input-number '.length;
|
30
|
+
recorder.insertRight(templateOffset + insertTo, formatPart);
|
31
|
+
}
|
32
|
+
const attrsToRemove = [decimalAttr, precisionAttr].filter((attr) => attr !== undefined);
|
33
|
+
(0, remove_attrs_1.removeAttrs)(attrsToRemove, sourceCodeLocation, recorder, templateOffset);
|
34
|
+
});
|
35
|
+
}
|
36
|
+
exports.migrateNumberPrecision = migrateNumberPrecision;
|
@@ -2,13 +2,10 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.migrateOverscroll = void 0;
|
4
4
|
const elements_1 = require("../../../../utils/templates/elements");
|
5
|
+
const inputs_1 = require("../../../../utils/templates/inputs");
|
5
6
|
const template_resource_1 = require("../../../../utils/templates/template-resource");
|
6
7
|
const remove_attrs_1 = require("../utils/remove-attrs");
|
7
8
|
const overscrollAttrName = 'tuiOverscroll';
|
8
|
-
const overscrollAttrNameDict = {
|
9
|
-
[overscrollAttrName.toLowerCase()]: true,
|
10
|
-
[`[${overscrollAttrName.toLowerCase()}]`]: true,
|
11
|
-
};
|
12
9
|
function migrateOverscroll({ resource, recorder, fileSystem, }) {
|
13
10
|
const template = (0, template_resource_1.getTemplateFromTemplateResource)(resource, fileSystem);
|
14
11
|
const templateOffset = (0, template_resource_1.getTemplateOffset)(resource);
|
@@ -17,8 +14,9 @@ function migrateOverscroll({ resource, recorder, fileSystem, }) {
|
|
17
14
|
return;
|
18
15
|
}
|
19
16
|
elements.forEach(({ attrs, sourceCodeLocation }) => {
|
20
|
-
const
|
21
|
-
|
17
|
+
const attrToRemove = (0, inputs_1.findAttr)(attrs, overscrollAttrName);
|
18
|
+
attrToRemove &&
|
19
|
+
(0, remove_attrs_1.removeAttrs)([attrToRemove], sourceCodeLocation, recorder, templateOffset);
|
22
20
|
});
|
23
21
|
addTodo(recorder, elements[0].sourceCodeLocation, templateOffset);
|
24
22
|
}
|
@@ -2,6 +2,7 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.migrateThumbnailCard = void 0;
|
4
4
|
const elements_1 = require("../../../../utils/templates/elements");
|
5
|
+
const inputs_1 = require("../../../../utils/templates/inputs");
|
5
6
|
const template_resource_1 = require("../../../../utils/templates/template-resource");
|
6
7
|
function migrateThumbnailCard({ resource, recorder, fileSystem, }) {
|
7
8
|
const template = (0, template_resource_1.getTemplateFromTemplateResource)(resource, fileSystem);
|
@@ -11,7 +12,7 @@ function migrateThumbnailCard({ resource, recorder, fileSystem, }) {
|
|
11
12
|
if (!sourceCodeLocation) {
|
12
13
|
return;
|
13
14
|
}
|
14
|
-
const valueAttr =
|
15
|
+
const valueAttr = (0, inputs_1.findAttr)(attrs, 'cardNumber');
|
15
16
|
if (!valueAttr) {
|
16
17
|
return;
|
17
18
|
}
|
@@ -1,6 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.closeStartTag = exports.removeClosingTag = exports.replaceSizeAttr = exports.replaceOpenTag = void 0;
|
4
|
+
const inputs_1 = require("../../../../../utils/templates/inputs");
|
4
5
|
const sizeMap = {
|
5
6
|
l: 'm',
|
6
7
|
m: 's',
|
@@ -17,14 +18,14 @@ function replaceOpenTag(sourceCodeLocation, recorder, templateOffset, { tag, dir
|
|
17
18
|
exports.replaceOpenTag = replaceOpenTag;
|
18
19
|
function replaceSizeAttr(attrs, sourceCodeLocation, recorder, templateOffset, map = sizeMap) {
|
19
20
|
var _a;
|
20
|
-
const sizeAttr =
|
21
|
+
const sizeAttr = (0, inputs_1.findAttr)(attrs, 'size');
|
21
22
|
if (sizeAttr) {
|
22
23
|
const { startOffset, endOffset } = ((_a = sourceCodeLocation.attrs) === null || _a === void 0 ? void 0 : _a[sizeAttr.name]) || {
|
23
24
|
startOffset: 0,
|
24
25
|
endOffset: 0,
|
25
26
|
};
|
26
27
|
recorder.remove(templateOffset + startOffset, endOffset - startOffset);
|
27
|
-
recorder.insertRight(templateOffset + startOffset,
|
28
|
+
recorder.insertRight(templateOffset + startOffset, `${sizeAttr.name}="${map[sizeAttr.value] || sizeAttr.value}"`);
|
28
29
|
}
|
29
30
|
}
|
30
31
|
exports.replaceSizeAttr = replaceSizeAttr;
|
@@ -2,6 +2,7 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.migrateCheckbox = void 0;
|
4
4
|
const elements_1 = require("../../../../../utils/templates/elements");
|
5
|
+
const inputs_1 = require("../../../../../utils/templates/inputs");
|
5
6
|
const template_resource_1 = require("../../../../../utils/templates/template-resource");
|
6
7
|
const common_1 = require("./common");
|
7
8
|
function migrateCheckbox({ resource, recorder, fileSystem, }) {
|
@@ -39,7 +40,7 @@ function migrateCheckbox({ resource, recorder, fileSystem, }) {
|
|
39
40
|
exports.migrateCheckbox = migrateCheckbox;
|
40
41
|
function replaceValueAttr(attrs, sourceCodeLocation, recorder, templateOffset) {
|
41
42
|
var _a;
|
42
|
-
const valueAttr =
|
43
|
+
const valueAttr = (0, inputs_1.findAttr)(attrs, 'value');
|
43
44
|
if (valueAttr) {
|
44
45
|
const { startOffset, endOffset } = ((_a = sourceCodeLocation.attrs) === null || _a === void 0 ? void 0 : _a[valueAttr.name]) || {
|
45
46
|
startOffset: 0,
|
@@ -3,16 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.updatePackages = void 0;
|
4
4
|
const ng_morph_1 = require("ng-morph");
|
5
5
|
const version_1 = require("../../../../constants/version");
|
6
|
+
const constants_1 = require("../../../constants");
|
6
7
|
const steps_1 = require("../../steps");
|
7
8
|
function updatePackages({ tree }, _) {
|
8
9
|
const packagesToRemove = ['@taiga-ui/addon-tablebars', '@taiga-ui/addon-preview'];
|
9
10
|
packagesToRemove.forEach((pkg) => {
|
10
11
|
(0, ng_morph_1.removePackageJsonDependency)(tree, pkg);
|
11
12
|
});
|
12
|
-
(0, ng_morph_1.addPackageJsonDependency)(tree, {
|
13
|
-
name: '@taiga-ui/legacy',
|
14
|
-
version: version_1.TUI_VERSION,
|
15
|
-
});
|
16
13
|
(0, steps_1.replacePackageName)('@tinkoff/ng-polymorpheus', {
|
17
14
|
name: '@taiga-ui/polymorpheus',
|
18
15
|
version: '^4.6.4',
|
@@ -31,5 +28,17 @@ function updatePackages({ tree }, _) {
|
|
31
28
|
version: '^4.0.1',
|
32
29
|
});
|
33
30
|
}
|
31
|
+
if ((0, ng_morph_1.getImports)(constants_1.ALL_TS_FILES, { moduleSpecifier: '@taiga-ui/layout' }).length) {
|
32
|
+
(0, ng_morph_1.addPackageJsonDependency)(tree, {
|
33
|
+
name: '@taiga-ui/layout',
|
34
|
+
version: version_1.TUI_VERSION,
|
35
|
+
});
|
36
|
+
}
|
37
|
+
if ((0, ng_morph_1.getImports)(constants_1.ALL_TS_FILES, { moduleSpecifier: '@taiga-ui/legacy' }).length) {
|
38
|
+
(0, ng_morph_1.addPackageJsonDependency)(tree, {
|
39
|
+
name: '@taiga-ui/legacy',
|
40
|
+
version: version_1.TUI_VERSION,
|
41
|
+
});
|
42
|
+
}
|
34
43
|
}
|
35
44
|
exports.updatePackages = updatePackages;
|
@@ -104,7 +104,8 @@ exports.findAttributeOnElementWithAttrs = findAttributeOnElementWithAttrs;
|
|
104
104
|
/** Shorthand function that checks if the specified element contains the given attribute. */
|
105
105
|
function hasElementAttribute(element, attributeName) {
|
106
106
|
var _a;
|
107
|
-
|
107
|
+
const lowercasedAttrName = attributeName.toLowerCase();
|
108
|
+
return (_a = element.attrs) === null || _a === void 0 ? void 0 : _a.some((attr) => attr.name === lowercasedAttrName || attr.name === `[${lowercasedAttrName}]`);
|
108
109
|
}
|
109
110
|
exports.hasElementAttribute = hasElementAttribute;
|
110
111
|
/** Gets the start offset of the given attribute from a Parse5 element. */
|
@@ -2,7 +2,8 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.isBinding = exports.findAttr = void 0;
|
4
4
|
function findAttr(attrs, name) {
|
5
|
-
|
5
|
+
const lowercasedName = name.toLowerCase();
|
6
|
+
return attrs.find((attr) => attr.name === lowercasedName || attr.name === `[${lowercasedName}]`);
|
6
7
|
}
|
7
8
|
exports.findAttr = findAttr;
|
8
9
|
function isBinding(attr) {
|
File without changes
|