@taiga-ui/cdk 4.0.0-rc.6 → 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/esm2022/directives/auto-focus/autofocus.options.mjs +3 -3
- package/esm2022/directives/copy-processor/copy-processor.directive.mjs +3 -3
- package/esm2022/directives/high-dpi/high-dpi.directive.mjs +3 -3
- package/esm2022/directives/obscured/obscured.service.mjs +3 -3
- package/esm2022/services/scroll.service.mjs +4 -4
- package/esm2022/tokens/active-element.mjs +3 -3
- package/esm2022/tokens/environment.mjs +8 -8
- package/esm2022/tokens/removed-element.mjs +3 -3
- package/esm2022/tokens/window-size.mjs +3 -3
- package/fesm2022/taiga-ui-cdk-constants.mjs +1 -1
- package/fesm2022/taiga-ui-cdk-constants.mjs.map +1 -1
- package/fesm2022/taiga-ui-cdk-directives-auto-focus.mjs +2 -2
- package/fesm2022/taiga-ui-cdk-directives-auto-focus.mjs.map +1 -1
- package/fesm2022/taiga-ui-cdk-directives-copy-processor.mjs +2 -2
- package/fesm2022/taiga-ui-cdk-directives-copy-processor.mjs.map +1 -1
- package/fesm2022/taiga-ui-cdk-directives-high-dpi.mjs +2 -2
- package/fesm2022/taiga-ui-cdk-directives-high-dpi.mjs.map +1 -1
- package/fesm2022/taiga-ui-cdk-directives-obscured.mjs +2 -2
- package/fesm2022/taiga-ui-cdk-directives-obscured.mjs.map +1 -1
- package/fesm2022/taiga-ui-cdk-services.mjs +3 -3
- package/fesm2022/taiga-ui-cdk-services.mjs.map +1 -1
- package/fesm2022/taiga-ui-cdk-tokens.mjs +11 -11
- package/fesm2022/taiga-ui-cdk-tokens.mjs.map +1 -1
- package/package.json +5 -6
- package/schematics/ng-update/interfaces/replacement-type.d.ts +4 -0
- package/schematics/ng-update/steps/rename-types.js +6 -2
- package/schematics/ng-update/steps/replace-identifier.js +8 -1
- package/schematics/ng-update/v4/index.js +1 -0
- package/schematics/ng-update/v4/migrate-icons/rename-icons.js +5 -5
- package/schematics/ng-update/v4/migrate-icons/rename-proprietary-icons.js +3 -3
- package/schematics/ng-update/v4/steps/constants/attr-to-directive-replace.js +3 -2
- package/schematics/ng-update/v4/steps/constants/attr-with-values-to-replace.js +2 -1
- package/schematics/ng-update/v4/steps/constants/attrs-to-replace.js +49 -19
- package/schematics/ng-update/v4/steps/constants/html-comments.js +5 -0
- package/schematics/ng-update/v4/steps/constants/identifiers-to-replace.js +249 -26
- 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 +8 -0
- package/schematics/ng-update/v4/steps/constants/tags-to-replace.js +14 -2
- package/schematics/ng-update/v4/steps/constants/types.js +21 -1
- 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 +8 -0
- package/schematics/ng-update/v4/steps/{migrate-styles.js → styles/index.js} +8 -1
- 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 +4 -0
- package/schematics/ng-update/v4/steps/templates/index.js +4 -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.d.ts +8 -0
- package/schematics/ng-update/v4/steps/templates/migrate-blocked.js +35 -0
- package/schematics/ng-update/v4/steps/templates/migrate-button-appearance.d.ts +8 -0
- package/schematics/ng-update/v4/steps/templates/migrate-button-appearance.js +41 -0
- 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-labeled.js +2 -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 +36 -0
- 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
@@ -4,9 +4,12 @@ exports.TYPES_TO_RENAME = void 0;
|
|
4
4
|
exports.TYPES_TO_RENAME = [
|
5
5
|
{
|
6
6
|
from: 'TuiDocExample',
|
7
|
-
to: 'Record<string,
|
7
|
+
to: 'Record<string, TuiRawLoaderContent>',
|
8
8
|
moduleSpecifier: ['@taiga-ui/addon-doc'],
|
9
9
|
removeImport: true,
|
10
|
+
newImports: [
|
11
|
+
{ name: 'TuiRawLoaderContent', moduleSpecifier: '@taiga-ui/addon-doc' },
|
12
|
+
],
|
10
13
|
},
|
11
14
|
{
|
12
15
|
from: 'TuiBrightness',
|
@@ -14,4 +17,21 @@ exports.TYPES_TO_RENAME = [
|
|
14
17
|
moduleSpecifier: ['@taiga-ui/core'],
|
15
18
|
removeImport: true,
|
16
19
|
},
|
20
|
+
{
|
21
|
+
from: 'TuiIllustrationName',
|
22
|
+
moduleSpecifier: ['@taiga-ui/proprietary-icons'],
|
23
|
+
to: 'string',
|
24
|
+
removeImport: true,
|
25
|
+
},
|
26
|
+
{
|
27
|
+
from: 'TuiNotificationT',
|
28
|
+
moduleSpecifier: ['@taiga-ui/core'],
|
29
|
+
to: 'string',
|
30
|
+
removeImport: true,
|
31
|
+
},
|
32
|
+
{
|
33
|
+
from: 'TuiOperationIcon',
|
34
|
+
moduleSpecifier: ['@taiga-ui/proprietary-banking'],
|
35
|
+
to: 'TuiFeedItemIcon',
|
36
|
+
},
|
17
37
|
];
|
@@ -1,10 +1,11 @@
|
|
1
|
+
export * from './migrate-alert-service';
|
1
2
|
export * from './migrate-all-country-iso-codes';
|
2
3
|
export * from './migrate-destroy-service';
|
3
4
|
export * from './migrate-legacy-mask';
|
4
5
|
export * from './migrate-option-providers';
|
5
6
|
export * from './migrate-proprietary';
|
6
|
-
export * from './migrate-styles';
|
7
7
|
export * from './migrate-templates';
|
8
8
|
export * from './restore-tui-mapper';
|
9
9
|
export * from './restore-tui-matcher';
|
10
|
+
export * from './styles';
|
10
11
|
export * from './update-packages';
|
@@ -1,13 +1,14 @@
|
|
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-alert-service"), exports);
|
4
5
|
tslib_1.__exportStar(require("./migrate-all-country-iso-codes"), exports);
|
5
6
|
tslib_1.__exportStar(require("./migrate-destroy-service"), exports);
|
6
7
|
tslib_1.__exportStar(require("./migrate-legacy-mask"), exports);
|
7
8
|
tslib_1.__exportStar(require("./migrate-option-providers"), exports);
|
8
9
|
tslib_1.__exportStar(require("./migrate-proprietary"), exports);
|
9
|
-
tslib_1.__exportStar(require("./migrate-styles"), exports);
|
10
10
|
tslib_1.__exportStar(require("./migrate-templates"), exports);
|
11
11
|
tslib_1.__exportStar(require("./restore-tui-mapper"), exports);
|
12
12
|
tslib_1.__exportStar(require("./restore-tui-matcher"), exports);
|
13
|
+
tslib_1.__exportStar(require("./styles"), exports);
|
13
14
|
tslib_1.__exportStar(require("./update-packages"), exports);
|
@@ -0,0 +1,88 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.migrateAlertService = void 0;
|
4
|
+
const ng_morph_1 = require("ng-morph");
|
5
|
+
const colored_log_1 = require("../../../utils/colored-log");
|
6
|
+
const get_named_import_references_1 = require("../../../utils/get-named-import-references");
|
7
|
+
const OPTIONS_MIGRATIONS = {
|
8
|
+
autoClose: (property) => {
|
9
|
+
const [propertyKey, propertyValue] = property.getText().split(/\s?:\s?/);
|
10
|
+
switch (propertyValue) {
|
11
|
+
case 'true':
|
12
|
+
return property.replaceWithText(`${propertyKey}: 3_000`);
|
13
|
+
case 'false':
|
14
|
+
return property.replaceWithText(`${propertyKey}: 0`);
|
15
|
+
default:
|
16
|
+
return null;
|
17
|
+
}
|
18
|
+
},
|
19
|
+
defaultAutoCloseTime: (property) => property.replaceWithText(property.getText().replace('defaultAutoCloseTime', 'autoClose')),
|
20
|
+
status: (property) => property.replaceWithText(property.getText().replace('status', 'appearance')),
|
21
|
+
hasCloseButton: (property) => property.replaceWithText(property.getText().replace('hasCloseButton', 'closeable')),
|
22
|
+
hasIcon: (property) => {
|
23
|
+
const [, propertyValue] = property.getText().split(/\s?:\s?/);
|
24
|
+
switch (propertyValue) {
|
25
|
+
case 'false':
|
26
|
+
return property.replaceWithText("icon: ''");
|
27
|
+
case 'true':
|
28
|
+
return property.remove();
|
29
|
+
default:
|
30
|
+
return property.replaceWithText(`// TODO: (Taiga UI migration) "hasIcon" is deleted. Use "icon: ''" to hide icon. Use "icon: TUI_NOTIFICATION_DEFAULT_OPTIONS['icon']" to show it.\n${property.getText()}`);
|
31
|
+
}
|
32
|
+
},
|
33
|
+
};
|
34
|
+
function migrateAlertService(options) {
|
35
|
+
!options['skip-logs'] &&
|
36
|
+
(0, colored_log_1.infoLog)(`${colored_log_1.SMALL_TAB_SYMBOL}${colored_log_1.REPLACE_SYMBOL} replacing inject(TuiAlertService).open({autoClose: boolean})...`);
|
37
|
+
const alertServiceRefs = (0, get_named_import_references_1.getNamedImportReferences)('TuiAlertService', '@taiga-ui/core');
|
38
|
+
// inject(TuiAlertService).open(...)
|
39
|
+
const viaDirectInjects = alertServiceRefs.map((x) => x.getFirstAncestor((node) => node.isKind(ng_morph_1.SyntaxKind.CallExpression) &&
|
40
|
+
node.getFullText().includes('inject(TuiAlertService') &&
|
41
|
+
node.getFullText().includes('.open(')));
|
42
|
+
// readonly alertService = inject(TuiAlertService);
|
43
|
+
const viaClassProperty = alertServiceRefs
|
44
|
+
.map((x) => {
|
45
|
+
var _a;
|
46
|
+
return (_a = x
|
47
|
+
.getFirstAncestorByKind(ng_morph_1.SyntaxKind.PropertyDeclaration)) === null || _a === void 0 ? void 0 : _a.findReferencesAsNodes();
|
48
|
+
})
|
49
|
+
.flat()
|
50
|
+
.map(toAlertServiceOpenCallExpression);
|
51
|
+
// constructor(private readonly legacyWayService: TuiAlertService) {}
|
52
|
+
const viaConstructorParam = alertServiceRefs
|
53
|
+
.map((x) => { var _a; return (_a = x.getFirstAncestorByKind(ng_morph_1.SyntaxKind.Parameter)) === null || _a === void 0 ? void 0 : _a.findReferencesAsNodes(); })
|
54
|
+
.flat()
|
55
|
+
.map(toAlertServiceOpenCallExpression);
|
56
|
+
[...viaDirectInjects, ...viaClassProperty, ...viaConstructorParam].forEach((callExpression) => {
|
57
|
+
if (!callExpression || callExpression.wasForgotten()) {
|
58
|
+
return;
|
59
|
+
}
|
60
|
+
const [, arg] = callExpression.getArguments();
|
61
|
+
const options = (arg === null || arg === void 0 ? void 0 : arg.isKind(ng_morph_1.SyntaxKind.PropertyAccessExpression))
|
62
|
+
? findOptionsInitializer(arg)
|
63
|
+
: arg;
|
64
|
+
if (!(options === null || options === void 0 ? void 0 : options.isKind(ng_morph_1.SyntaxKind.ObjectLiteralExpression))) {
|
65
|
+
return;
|
66
|
+
}
|
67
|
+
Object.entries(OPTIONS_MIGRATIONS).forEach(([propertyName, migration]) => {
|
68
|
+
const property = options.getProperty(propertyName);
|
69
|
+
if (property) {
|
70
|
+
migration(property);
|
71
|
+
}
|
72
|
+
});
|
73
|
+
});
|
74
|
+
!options['skip-logs'] &&
|
75
|
+
(0, colored_log_1.successLog)(`${colored_log_1.SMALL_TAB_SYMBOL}${colored_log_1.SUCCESS_SYMBOL} "true => 3_000" & "false => 0" were replaced \n`);
|
76
|
+
}
|
77
|
+
exports.migrateAlertService = migrateAlertService;
|
78
|
+
function toAlertServiceOpenCallExpression(node) {
|
79
|
+
return node === null || node === void 0 ? void 0 : node.getFirstAncestor((x) => x.isKind(ng_morph_1.SyntaxKind.CallExpression) && x.getFullText().includes('.open('));
|
80
|
+
}
|
81
|
+
function findOptionsInitializer(ref) {
|
82
|
+
var _a;
|
83
|
+
return (_a = ref === null || ref === void 0 ? void 0 : ref.getFirstChildByKind(ng_morph_1.SyntaxKind.Identifier)) === null || _a === void 0 ? void 0 : _a.findReferencesAsNodes().map((n) => {
|
84
|
+
var _a;
|
85
|
+
return (_a = n
|
86
|
+
.getFirstAncestorByKind(ng_morph_1.SyntaxKind.PropertyDeclaration)) === null || _a === void 0 ? void 0 : _a.getFirstChildByKind(ng_morph_1.SyntaxKind.ObjectLiteralExpression);
|
87
|
+
}).find(Boolean);
|
88
|
+
}
|
@@ -10,6 +10,8 @@ const templates_1 = require("../../utils/templates");
|
|
10
10
|
const replace_attrs_by_directives_1 = require("../../utils/templates/replace-attrs-by-directives");
|
11
11
|
const constants_2 = require("./constants");
|
12
12
|
const templates_2 = require("./templates");
|
13
|
+
const migrate_blocked_1 = require("./templates/migrate-blocked");
|
14
|
+
const migrate_number_precision_1 = require("./templates/migrate-number-precision");
|
13
15
|
function getAction({ action, requiredData, }) {
|
14
16
|
return ({ resource, fileSystem, recorder, }) => action({ resource, fileSystem, recorder, data: requiredData });
|
15
17
|
}
|
@@ -27,6 +29,7 @@ function migrateTemplates(fileSystem, options) {
|
|
27
29
|
getAction({ action: templates_1.replaceAttrs, requiredData: constants_2.ATTRS_TO_REPLACE }),
|
28
30
|
getAction({ action: templates_1.replaceAttrValues, requiredData: constants_2.ATTR_WITH_VALUES_TO_REPLACE }),
|
29
31
|
getAction({ action: templates_1.removeInputs, requiredData: constants_2.INPUTS_TO_REMOVE }),
|
32
|
+
templates_2.migrateAxes,
|
30
33
|
templates_2.migrateBadge,
|
31
34
|
templates_2.migrateCheckbox,
|
32
35
|
templates_2.migrateFocusable,
|
@@ -36,12 +39,17 @@ function migrateTemplates(fileSystem, options) {
|
|
36
39
|
templates_2.migrateExpandable,
|
37
40
|
templates_2.migrateBadgedContent,
|
38
41
|
templates_2.migratePreventDefault,
|
42
|
+
templates_2.migrateMobileTabs,
|
39
43
|
templates_2.migrateMoney,
|
40
44
|
templates_2.migrateLabeled,
|
45
|
+
migrate_blocked_1.migrateBlocked,
|
41
46
|
templates_2.migrateProgressSegmented,
|
42
47
|
templates_2.migrateThumbnailCard,
|
43
48
|
templates_2.migrateOverscroll,
|
49
|
+
templates_2.migrateButtonAppearance,
|
44
50
|
templates_2.migrateLabel,
|
51
|
+
migrate_number_precision_1.migrateNumberPrecision,
|
52
|
+
templates_2.migrateNotification,
|
45
53
|
];
|
46
54
|
const progressLog = (0, progress_1.setupProgressLogger)({
|
47
55
|
total: componentWithTemplatesPaths.length,
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.migrateStyles = exports.TUI_RATING_WARNING = void 0;
|
4
4
|
/// <reference lib="es2021" />
|
5
5
|
const ng_morph_1 = require("ng-morph");
|
6
|
+
const migrate_space_mixins_1 = require("./migrate-space-mixins");
|
6
7
|
exports.TUI_RATING_WARNING = '// TODO: (Taiga UI migration): use css to customize rating gap and size. See https://taiga-ui.dev/components/rating#basic';
|
7
8
|
function migrateStyles() {
|
8
9
|
var _a;
|
@@ -13,7 +14,13 @@ function migrateStyles() {
|
|
13
14
|
.replace(/^(.*--tui-rating-size.*)$/gm, `${exports.TUI_RATING_WARNING}\n$1`)
|
14
15
|
// eslint-disable-next-line
|
15
16
|
.replace(/^(.*--tui-rating-gap.*)$/gm, `${exports.TUI_RATING_WARNING}\n$1`)
|
16
|
-
.replaceAll('--tui-link-icon-size', '--tui-icon-size')
|
17
|
+
.replaceAll('--tui-link-icon-size', '--tui-icon-size')
|
18
|
+
.replaceAll('@taiga-ui/proprietary-core/styles/tinkoff-fonts', '@taiga-ui/proprietary/styles/tbank-fonts')
|
19
|
+
.replaceAll('@taiga-ui/proprietary-core/styles/theme-tinkoff-2023', '@taiga-ui/proprietary/styles/tbank-theme')
|
20
|
+
.replaceAll('@taiga-ui/proprietary-core/styles/theme-tinkoff-mobile-2023', '@taiga-ui/proprietary/styles/tbank-theme-mobile.less')
|
21
|
+
.replaceAll('@taiga-ui/proprietary-core/styles/theme-tinkoff-mobile', '@taiga-ui/proprietary/styles/tbank-theme-mobile.less')
|
22
|
+
.replaceAll('@taiga-ui/proprietary-core/styles/theme-tinkoff', '@taiga-ui/proprietary/styles/tbank-theme');
|
23
|
+
fullText = (0, migrate_space_mixins_1.migrateSpaceMixins)(fullText);
|
17
24
|
sourceFile.replaceWithText(fullText);
|
18
25
|
});
|
19
26
|
(0, ng_morph_1.saveActiveProject)();
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare function migrateSpaceMixins(fileContent: string): string;
|
@@ -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,11 +1,15 @@
|
|
1
1
|
export * from './migrate-avatar';
|
2
|
+
export * from './migrate-axes';
|
2
3
|
export * from './migrate-badge';
|
3
4
|
export * from './migrate-badged-content';
|
5
|
+
export * from './migrate-button-appearance';
|
4
6
|
export * from './migrate-expandable';
|
5
7
|
export * from './migrate-focusable';
|
6
8
|
export * from './migrate-label';
|
7
9
|
export * from './migrate-labeled';
|
10
|
+
export * from './migrate-mobile-tabs';
|
8
11
|
export * from './migrate-money';
|
12
|
+
export * from './migrate-notification';
|
9
13
|
export * from './migrate-overscroll';
|
10
14
|
export * from './migrate-prevent-default';
|
11
15
|
export * from './migrate-progress-segmented';
|
@@ -2,13 +2,17 @@
|
|
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);
|
8
|
+
tslib_1.__exportStar(require("./migrate-button-appearance"), exports);
|
7
9
|
tslib_1.__exportStar(require("./migrate-expandable"), exports);
|
8
10
|
tslib_1.__exportStar(require("./migrate-focusable"), exports);
|
9
11
|
tslib_1.__exportStar(require("./migrate-label"), exports);
|
10
12
|
tslib_1.__exportStar(require("./migrate-labeled"), exports);
|
13
|
+
tslib_1.__exportStar(require("./migrate-mobile-tabs"), exports);
|
11
14
|
tslib_1.__exportStar(require("./migrate-money"), exports);
|
15
|
+
tslib_1.__exportStar(require("./migrate-notification"), exports);
|
12
16
|
tslib_1.__exportStar(require("./migrate-overscroll"), exports);
|
13
17
|
tslib_1.__exportStar(require("./migrate-prevent-default"), exports);
|
14
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;
|
@@ -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 migrateBlocked({ resource, recorder, fileSystem, }: {
|
5
|
+
fileSystem: DevkitFileSystem;
|
6
|
+
recorder: UpdateRecorder;
|
7
|
+
resource: TemplateResource;
|
8
|
+
}): void;
|
@@ -0,0 +1,35 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.migrateBlocked = void 0;
|
4
|
+
const elements_1 = require("../../../../utils/templates/elements");
|
5
|
+
const inputs_1 = require("../../../../utils/templates/inputs");
|
6
|
+
const template_resource_1 = require("../../../../utils/templates/template-resource");
|
7
|
+
function migrateBlocked({ resource, recorder, fileSystem, }) {
|
8
|
+
const template = (0, template_resource_1.getTemplateFromTemplateResource)(resource, fileSystem);
|
9
|
+
const templateOffset = (0, template_resource_1.getTemplateOffset)(resource);
|
10
|
+
const elements = (0, elements_1.findElementsByTagNames)(template, [
|
11
|
+
'tui-checkbox-block',
|
12
|
+
'tui-radio-block',
|
13
|
+
]);
|
14
|
+
elements.forEach(({ sourceCodeLocation, tagName, attrs }) => {
|
15
|
+
var _a, _b, _c, _d;
|
16
|
+
if (!sourceCodeLocation) {
|
17
|
+
return;
|
18
|
+
}
|
19
|
+
const [, hideIconAttrLocation] = Object.entries(sourceCodeLocation.attrs || {}).find(([name]) => name.includes('hideCheckbox'.toLowerCase()) ||
|
20
|
+
name.includes('hideRadio'.toLowerCase())) || [];
|
21
|
+
const [, sizeAttrLocation] = Object.entries(sourceCodeLocation.attrs || {}).find(([name]) => name.includes('size')) || [];
|
22
|
+
const sizeAttr = (0, inputs_1.findAttr)(attrs, 'size');
|
23
|
+
const newBlockAttr = `tuiBlock${sizeAttr ? `="${sizeAttr.value === 'xs' ? 's' : sizeAttr.value}"` : ''}`;
|
24
|
+
recorder.insertRight(templateOffset + (((_a = sourceCodeLocation.startTag) === null || _a === void 0 ? void 0 : _a.startOffset) || 1) - 1, `<label ${newBlockAttr}${hideIconAttrLocation ? ' appearance=""' : ''}>`);
|
25
|
+
recorder.remove(templateOffset + ((_c = (_b = sourceCodeLocation.endTag) === null || _b === void 0 ? void 0 : _b.startOffset) !== null && _c !== void 0 ? _c : 0), `<${tagName}/>`.length);
|
26
|
+
recorder.insertRight(templateOffset + (((_d = sourceCodeLocation.endTag) === null || _d === void 0 ? void 0 : _d.startOffset) || 1), '</label>');
|
27
|
+
if (hideIconAttrLocation) {
|
28
|
+
recorder.remove(templateOffset + hideIconAttrLocation.startOffset, hideIconAttrLocation.endOffset - hideIconAttrLocation.startOffset);
|
29
|
+
}
|
30
|
+
if (sizeAttrLocation) {
|
31
|
+
recorder.remove(templateOffset + sizeAttrLocation.startOffset, sizeAttrLocation.endOffset - sizeAttrLocation.startOffset);
|
32
|
+
}
|
33
|
+
});
|
34
|
+
}
|
35
|
+
exports.migrateBlocked = migrateBlocked;
|
@@ -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 migrateButtonAppearance({ resource, recorder, fileSystem, }: {
|
5
|
+
fileSystem: DevkitFileSystem;
|
6
|
+
recorder: UpdateRecorder;
|
7
|
+
resource: TemplateResource;
|
8
|
+
}): void;
|
@@ -0,0 +1,41 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.migrateButtonAppearance = 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 tuiButtonSelectors = ['tuiButton', 'tuiIconButton'];
|
8
|
+
const appearanceInputName = 'appearance';
|
9
|
+
const appearanceInputNameDict = {
|
10
|
+
[appearanceInputName]: true,
|
11
|
+
[`[${appearanceInputName}]`]: true,
|
12
|
+
};
|
13
|
+
function migrateButtonAppearance({ 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 = tuiButtonSelectors.flatMap((selector) => (0, elements_1.findElementsWithDirective)(template, selector).filter(({ sourceCodeLocation, attrs }) => !!sourceCodeLocation &&
|
17
|
+
attrs.some(({ name }) => appearanceInputNameDict[name])));
|
18
|
+
if (!elements.length) {
|
19
|
+
return;
|
20
|
+
}
|
21
|
+
const whiteBlockValue = 'whiteblock-active';
|
22
|
+
elements.forEach(({ attrs, sourceCodeLocation }) => {
|
23
|
+
var _a;
|
24
|
+
const whiteBlockActiveAttr = attrs.find(({ value, name }) => appearanceInputNameDict[name] &&
|
25
|
+
(value === whiteBlockValue || value === `'${whiteBlockValue}'`));
|
26
|
+
if (whiteBlockActiveAttr) {
|
27
|
+
(0, remove_attrs_1.removeAttrs)([whiteBlockActiveAttr], sourceCodeLocation, recorder, templateOffset);
|
28
|
+
const { startOffset } = ((_a = sourceCodeLocation === null || sourceCodeLocation === void 0 ? void 0 : sourceCodeLocation.attrs) === null || _a === void 0 ? void 0 : _a[whiteBlockActiveAttr.name]) || { startOffset: 0, endOffset: 0 };
|
29
|
+
recorder.insertLeft(startOffset + templateOffset, ` ${appearanceInputName}="whiteblock"`);
|
30
|
+
recorder.insertLeft(startOffset + templateOffset, ' data-mode="checked"');
|
31
|
+
}
|
32
|
+
});
|
33
|
+
const elementWithConditionAppearance = elements.find(({ attrs }) => attrs.some(({ name, value }) => name === `[${appearanceInputName}]` && !value.trim().startsWith("'")));
|
34
|
+
if (elementWithConditionAppearance) {
|
35
|
+
addTodo(recorder, templateOffset);
|
36
|
+
}
|
37
|
+
}
|
38
|
+
exports.migrateButtonAppearance = migrateButtonAppearance;
|
39
|
+
function addTodo(recorder, templateOffset) {
|
40
|
+
recorder.insertRight(templateOffset, '<!-- Taiga migration TODO: tuiButton "whiteblock-active" appearance is no longer available. Use \'appearance="whiteblock" data-mode="checked"\' -->\n');
|
41
|
+
}
|
@@ -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
|
}
|
@@ -34,10 +34,8 @@ function migrateLabeled({ resource, recorder, fileSystem, }) {
|
|
34
34
|
}
|
35
35
|
(0, add_import_to_closest_module_1.addImportToClosestModule)(resource.componentPath, tagName === 'tui-checkbox-labeled' ? 'TuiCheckbox' : 'TuiRadio', '@taiga-ui/kit');
|
36
36
|
recorder.insertRight(templateOffset + (((_a = sourceCodeLocation.startTag) === null || _a === void 0 ? void 0 : _a.startOffset) || 1) - 1, '<label tuiLabel>');
|
37
|
-
recorder.
|
38
|
-
recorder.
|
39
|
-
? '<tui-checkbox-labeled/>'.length
|
40
|
-
: '<tui-radio-labeled/>'.length);
|
37
|
+
recorder.remove(templateOffset + ((_c = (_b = sourceCodeLocation.endTag) === null || _b === void 0 ? void 0 : _b.startOffset) !== null && _c !== void 0 ? _c : 0), `<${tagName}/>`.length);
|
38
|
+
recorder.insertRight(templateOffset + (((_d = sourceCodeLocation.endTag) === null || _d === void 0 ? void 0 : _d.startOffset) || 1), '</label>');
|
41
39
|
});
|
42
40
|
}
|
43
41
|
exports.migrateLabeled = migrateLabeled;
|
@@ -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
|
+
}
|