@taiga-ui/cdk 3.52.0-canary.164e55d → 3.52.0-canary.ca866a4

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.
Files changed (29) hide show
  1. package/package.json +4 -4
  2. package/schematics/ng-update/interfaces/html-comment.d.ts +5 -0
  3. package/schematics/ng-update/interfaces/html-comment.js +2 -0
  4. package/schematics/ng-update/interfaces/index.d.ts +1 -0
  5. package/schematics/ng-update/interfaces/index.js +1 -0
  6. package/schematics/ng-update/utils/templates/index.d.ts +6 -0
  7. package/schematics/ng-update/utils/templates/index.js +9 -0
  8. package/schematics/ng-update/utils/templates/template-comments.d.ts +10 -0
  9. package/schematics/ng-update/utils/templates/template-comments.js +20 -0
  10. package/schematics/ng-update/v4/steps/constants/attrs-to-replace.js +14 -0
  11. package/schematics/ng-update/v4/steps/constants/html-comments.d.ts +2 -0
  12. package/schematics/ng-update/v4/steps/constants/html-comments.js +10 -0
  13. package/schematics/ng-update/v4/steps/constants/identifiers-to-replace.js +12 -0
  14. package/schematics/ng-update/v4/steps/constants/index.d.ts +5 -0
  15. package/schematics/ng-update/v4/steps/constants/index.js +8 -0
  16. package/schematics/ng-update/v4/steps/constants/inputs-to-remove.js +2 -0
  17. package/schematics/ng-update/v4/steps/migrate-templates.js +11 -11
  18. package/schematics/ng-update/v4/steps/templates/index.d.ts +2 -0
  19. package/schematics/ng-update/v4/steps/templates/index.js +5 -0
  20. package/schematics/ng-update/v4/steps/templates/toggles/common.d.ts +10 -0
  21. package/schematics/ng-update/v4/steps/templates/toggles/common.js +40 -0
  22. package/schematics/ng-update/v4/steps/templates/toggles/index.d.ts +3 -0
  23. package/schematics/ng-update/v4/steps/templates/toggles/index.js +6 -0
  24. package/schematics/ng-update/v4/steps/templates/toggles/migrate-checkbox.d.ts +8 -0
  25. package/schematics/ng-update/v4/steps/templates/toggles/migrate-checkbox.js +25 -0
  26. package/schematics/ng-update/v4/steps/templates/toggles/migrate-radio.d.ts +8 -0
  27. package/schematics/ng-update/v4/steps/templates/toggles/migrate-radio.js +25 -0
  28. package/schematics/ng-update/v4/steps/templates/toggles/migrate-toggle.d.ts +8 -0
  29. package/schematics/ng-update/v4/steps/templates/toggles/migrate-toggle.js +25 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taiga-ui/cdk",
3
- "version": "3.52.0-canary.164e55d",
3
+ "version": "3.52.0-canary.ca866a4",
4
4
  "description": "Base library for creating Angular components and applications using Taiga UI principles regarding of actual visual appearance",
5
5
  "keywords": [
6
6
  "angular",
@@ -16,9 +16,9 @@
16
16
  "license": "Apache-2.0",
17
17
  "dependencies": {
18
18
  "@angular-devkit/schematics": "12.2.18",
19
- "@ng-web-apis/common": "3.0.5",
20
- "@ng-web-apis/mutation-observer": "3.0.5",
21
- "@ng-web-apis/resize-observer": "3.0.5",
19
+ "@ng-web-apis/common": "3.0.6",
20
+ "@ng-web-apis/mutation-observer": "3.0.6",
21
+ "@ng-web-apis/resize-observer": "3.0.6",
22
22
  "@schematics/angular": "12.2.18",
23
23
  "@tinkoff/ng-event-plugins": "3.1.0",
24
24
  "@tinkoff/ng-polymorpheus": "4.2.0",
@@ -0,0 +1,5 @@
1
+ export interface HtmlComment {
2
+ readonly tag: string;
3
+ readonly withAttrs: string[];
4
+ readonly comment: string;
5
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,4 +1,5 @@
1
1
  export * from './asset';
2
+ export * from './html-comment';
2
3
  export * from './migration-warning';
3
4
  export * from './removable-input';
4
5
  export * from './removed-module';
@@ -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("./asset"), exports);
5
+ tslib_1.__exportStar(require("./html-comment"), exports);
5
6
  tslib_1.__exportStar(require("./migration-warning"), exports);
6
7
  tslib_1.__exportStar(require("./removable-input"), exports);
7
8
  tslib_1.__exportStar(require("./removed-module"), exports);
@@ -0,0 +1,6 @@
1
+ export * from './remove-inputs';
2
+ export * from './replace-attr-values';
3
+ export * from './replace-attrs';
4
+ export * from './replace-tag';
5
+ export * from './replace-tags';
6
+ export * from './template-comments';
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./remove-inputs"), exports);
5
+ tslib_1.__exportStar(require("./replace-attr-values"), exports);
6
+ tslib_1.__exportStar(require("./replace-attrs"), exports);
7
+ tslib_1.__exportStar(require("./replace-tag"), exports);
8
+ tslib_1.__exportStar(require("./replace-tags"), exports);
9
+ tslib_1.__exportStar(require("./template-comments"), exports);
@@ -0,0 +1,10 @@
1
+ import { UpdateRecorder } from '@angular-devkit/schematics';
2
+ import { DevkitFileSystem } from 'ng-morph';
3
+ import { TemplateResource } from '../../interfaces';
4
+ import { HtmlComment } from '../../interfaces';
5
+ export declare function addHTMLCommentTags({ resource, recorder, fileSystem, data, }: {
6
+ fileSystem: DevkitFileSystem;
7
+ recorder: UpdateRecorder;
8
+ data: readonly HtmlComment[];
9
+ resource: TemplateResource;
10
+ }): void;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addHTMLCommentTags = void 0;
4
+ const insert_todo_1 = require("../../../utils/insert-todo");
5
+ const elements_1 = require("../../../utils/templates/elements");
6
+ const template_resource_1 = require("../../../utils/templates/template-resource");
7
+ function addHTMLCommentTags({ resource, recorder, fileSystem, data, }) {
8
+ const template = template_resource_1.getTemplateFromTemplateResource(resource, fileSystem);
9
+ const templateOffset = template_resource_1.getTemplateOffset(resource);
10
+ data.forEach(({ comment, tag, withAttrs }) => {
11
+ const elementStartOffsets = [
12
+ ...elements_1.findElementsWithAttributeOnTag(template, withAttrs, [tag]),
13
+ ...elements_1.findElementsWithAttributeOnTag(template, withAttrs.map(attr => `[${attr}]`), [tag]),
14
+ ].map(({ sourceCodeLocation }) => ((sourceCodeLocation === null || sourceCodeLocation === void 0 ? void 0 : sourceCodeLocation.startOffset) || 0) + templateOffset);
15
+ elementStartOffsets.forEach(offset => {
16
+ recorder.insertRight(offset, `<!-- ${insert_todo_1.TODO_MARK} ${comment} -->\n`);
17
+ });
18
+ });
19
+ }
20
+ exports.addHTMLCommentTags = addHTMLCommentTags;
@@ -30,4 +30,18 @@ exports.ATTRS_TO_REPLACE = [
30
30
  },
31
31
  to: { attrName: `appearance` },
32
32
  },
33
+ {
34
+ from: {
35
+ attrName: `item`,
36
+ withTagNames: [`tui-radio`],
37
+ },
38
+ to: { attrName: `value` },
39
+ },
40
+ {
41
+ from: {
42
+ attrName: `[item]`,
43
+ withTagNames: [`tui-radio`],
44
+ },
45
+ to: { attrName: `[value]` },
46
+ },
33
47
  ];
@@ -0,0 +1,2 @@
1
+ import { HtmlComment } from '../../../interfaces';
2
+ export declare const HTML_COMMENTS: HtmlComment[];
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HTML_COMMENTS = void 0;
4
+ exports.HTML_COMMENTS = [
5
+ {
6
+ tag: `tui-toggle`,
7
+ withAttrs: [`singleColor`, `showLoader`],
8
+ comment: `toggle [singleColor] and [showLoader] inputs have been removed due to design changes`,
9
+ },
10
+ ];
@@ -17,6 +17,18 @@ exports.IDENTIFIERS_TO_REPLACE = [
17
17
  from: { name: `TuiBadgeModule`, moduleSpecifier: `@taiga-ui/experimental` },
18
18
  to: { name: `TuiBadgeModule`, moduleSpecifier: `@taiga-ui/kit` },
19
19
  },
20
+ {
21
+ from: { name: `TuiCheckboxModule`, moduleSpecifier: `@taiga-ui/experimental` },
22
+ to: { name: `TuiCheckboxModule`, moduleSpecifier: `@taiga-ui/kit` },
23
+ },
24
+ {
25
+ from: { name: `TuiRadioModule`, moduleSpecifier: `@taiga-ui/experimental` },
26
+ to: { name: `TuiRadioModule`, moduleSpecifier: `@taiga-ui/kit` },
27
+ },
28
+ {
29
+ from: { name: `TuiToggleModule`, moduleSpecifier: `@taiga-ui/experimental` },
30
+ to: { name: `TuiToggleModule`, moduleSpecifier: `@taiga-ui/kit` },
31
+ },
20
32
  {
21
33
  from: { name: `TuiTextAreaModule`, moduleSpecifier: `@taiga-ui/kit` },
22
34
  to: { name: `TuiTextareaModule`, moduleSpecifier: `@taiga-ui/kit` },
@@ -0,0 +1,5 @@
1
+ export * from './attrs-to-replace';
2
+ export * from './html-comments';
3
+ export * from './identifiers-to-replace';
4
+ export * from './inputs-to-remove';
5
+ export * from './tags-to-replace';
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./attrs-to-replace"), exports);
5
+ tslib_1.__exportStar(require("./html-comments"), exports);
6
+ tslib_1.__exportStar(require("./identifiers-to-replace"), exports);
7
+ tslib_1.__exportStar(require("./inputs-to-remove"), exports);
8
+ tslib_1.__exportStar(require("./tags-to-replace"), exports);
@@ -3,4 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.INPUTS_TO_REMOVE = void 0;
4
4
  exports.INPUTS_TO_REMOVE = [
5
5
  { inputName: `active`, tags: [`tui-card`, `tui-thumbnail-card`] },
6
+ { inputName: `showLoader`, tags: [`tui-toggle`] },
7
+ { inputName: `singleColor`, tags: [`tui-toggle`] },
6
8
  ];
@@ -6,22 +6,22 @@ const colored_log_1 = require("../../../utils/colored-log");
6
6
  const progress_1 = require("../../../utils/progress");
7
7
  const get_component_templates_1 = require("../../../utils/templates/get-component-templates");
8
8
  const template_resource_1 = require("../../../utils/templates/template-resource");
9
- const remove_inputs_1 = require("../../utils/templates/remove-inputs");
10
- const replace_attrs_1 = require("../../utils/templates/replace-attrs");
11
- const replace_tags_1 = require("../../utils/templates/replace-tags");
12
- const attrs_to_replace_1 = require("./constants/attrs-to-replace");
13
- const inputs_to_remove_1 = require("./constants/inputs-to-remove");
14
- const tags_to_replace_1 = require("./constants/tags-to-replace");
15
- const migrate_badge_1 = require("./templates/migrate-badge");
9
+ const templates_1 = require("../../utils/templates");
10
+ const constants_2 = require("./constants");
11
+ const templates_2 = require("./templates");
16
12
  function migrateTemplates(fileSystem, options) {
17
13
  !options[`skip-logs`] &&
18
14
  colored_log_1.infoLog(`${colored_log_1.SMALL_TAB_SYMBOL}${colored_log_1.REPLACE_SYMBOL} migrating templates...`);
19
15
  const componentWithTemplatesPaths = get_component_templates_1.getComponentTemplates(constants_1.ALL_TS_FILES);
20
16
  const actions = [
21
- getAction({ action: replace_tags_1.replaceTags, requiredData: tags_to_replace_1.TAGS_TO_REPLACE }),
22
- getAction({ action: replace_attrs_1.replaceAttrs, requiredData: attrs_to_replace_1.ATTRS_TO_REPLACE }),
23
- getAction({ action: remove_inputs_1.removeInputs, requiredData: inputs_to_remove_1.INPUTS_TO_REMOVE }),
24
- migrate_badge_1.migrateBadgeValue,
17
+ getAction({ action: templates_1.addHTMLCommentTags, requiredData: constants_2.HTML_COMMENTS }),
18
+ getAction({ action: templates_1.replaceTags, requiredData: constants_2.TAGS_TO_REPLACE }),
19
+ getAction({ action: templates_1.replaceAttrs, requiredData: constants_2.ATTRS_TO_REPLACE }),
20
+ getAction({ action: templates_1.removeInputs, requiredData: constants_2.INPUTS_TO_REMOVE }),
21
+ templates_2.migrateBadgeValue,
22
+ templates_2.migrateCheckbox,
23
+ templates_2.migrateRadio,
24
+ templates_2.migrateToggle,
25
25
  ];
26
26
  const progressLog = progress_1.setupProgressLogger({
27
27
  total: componentWithTemplatesPaths.length,
@@ -0,0 +1,2 @@
1
+ export * from './migrate-badge';
2
+ export * from './toggles';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./migrate-badge"), exports);
5
+ tslib_1.__exportStar(require("./toggles"), exports);
@@ -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,3 @@
1
+ export * from './migrate-checkbox';
2
+ export * from './migrate-radio';
3
+ export * from './migrate-toggle';
@@ -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;