@progress/kendo-angular-scheduler 25.4.0-develop.8 → 26.0.0-develop.1

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.
@@ -4,9 +4,11 @@
4
4
  *-------------------------------------------------------------------------------------------*/
5
5
  "use strict";
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.tsInterfaceTransformer = exports.tsPropertyValueTransformer = exports.tsPropertyTransformer = exports.tsComponentPropertyRemoval = exports.attributeConditionalRemoval = exports.attributeRemoval = exports.attributeValueUpdate = exports.attributeNameValueUpdate = exports.attributeNameUpdate = exports.eventUpdate = exports.htmlTransformer = exports.blockTextElements = void 0;
7
+ exports.tsInterfaceTransformer = exports.tsPropertyValueTransformer = exports.tsPropertyTransformer = exports.tsComponentPropertyRemoval = exports.valuelessAttributeRemoval = exports.attributeConditionalRemoval = exports.attributeRemoval = exports.attributeValueUpdate = exports.attributeNameValueUpdate = exports.attributeNameUpdate = exports.eventUpdate = exports.htmlTransformer = exports.blockTextElements = void 0;
8
8
  exports.hasKendoInTemplate = hasKendoInTemplate;
9
9
  exports.isImportedFromPackage = isImportedFromPackage;
10
+ exports.getImportedLocalName = getImportedLocalName;
11
+ exports.containsIdentifier = containsIdentifier;
10
12
  exports.tsPropertyRemoval = tsPropertyRemoval;
11
13
  exports.makePattern = makePattern;
12
14
  exports.writeInstructionMarker = writeInstructionMarker;
@@ -38,21 +40,53 @@ function hasKendoInTemplate(source) {
38
40
  * @returns true if the type is imported from the package, false otherwise
39
41
  */
40
42
  function isImportedFromPackage(root, j, packageName, typeName) {
41
- let isImported = false;
43
+ return getImportedLocalName(root, j, packageName, typeName) !== undefined;
44
+ }
45
+ /**
46
+ * Resolves the local binding for a named import from the given package.
47
+ * @param root - The JSCodeshift collection
48
+ * @param j - JSCodeshift instance
49
+ * @param packageName - The package name to check
50
+ * @param importedName - The imported symbol name
51
+ * @returns The local binding name, or undefined if the symbol is not imported from the package
52
+ */
53
+ function getImportedLocalName(root, j, packageName, importedName) {
54
+ let localName;
42
55
  root.find(j.ImportDeclaration).forEach((path) => {
43
- if (path.node.source &&
44
- path.node.source.value === packageName &&
45
- path.node.specifiers) {
46
- path.node.specifiers.forEach((specifier) => {
47
- if (specifier.type === 'ImportSpecifier' &&
48
- specifier.imported.type === 'Identifier' &&
49
- specifier.imported.name === typeName) {
50
- isImported = true;
51
- }
52
- });
56
+ if (localName || path.node.source?.value !== packageName || !path.node.specifiers) {
57
+ return;
53
58
  }
59
+ path.node.specifiers.forEach((specifier) => {
60
+ if (specifier.type === 'ImportSpecifier' &&
61
+ specifier.imported?.type === 'Identifier' &&
62
+ specifier.imported.name === importedName) {
63
+ localName = specifier.local?.name || specifier.imported.name;
64
+ }
65
+ });
66
+ });
67
+ return localName;
68
+ }
69
+ /**
70
+ * Checks if an AST node or one of its descendants contains an identifier with the given name.
71
+ * @param node - The AST node to inspect
72
+ * @param identifierName - The identifier name to find
73
+ * @returns true if the identifier is present, false otherwise
74
+ */
75
+ function containsIdentifier(node, identifierName) {
76
+ if (typeof node !== 'object' || node === null) {
77
+ return false;
78
+ }
79
+ if ('type' in node && node.type === 'Identifier' && 'name' in node && node.name === identifierName) {
80
+ return true;
81
+ }
82
+ return Object.entries(node).some(([key, value]) => {
83
+ if (key === 'loc' || key === 'comments' || key === 'tokens' || key === 'start' || key === 'end') {
84
+ return false;
85
+ }
86
+ return Array.isArray(value)
87
+ ? value.some((child) => containsIdentifier(child, identifierName))
88
+ : containsIdentifier(value, identifierName);
54
89
  });
55
- return isImported;
56
90
  }
57
91
  /**
58
92
  * Transforms HTML files and inline templates using a provided transformer function
@@ -374,6 +408,21 @@ const attributeConditionalRemoval = (templateContent, tagName, attributeName, va
374
408
  return result;
375
409
  };
376
410
  exports.attributeConditionalRemoval = attributeConditionalRemoval;
411
+ /**
412
+ * Removes an attribute from a tag regardless of whether it has a value.
413
+ * Handles valueless directive selectors (`<ng-template kendoDirective>`) and static values (`attr="value"`).
414
+ *
415
+ * @param templateContent - The template string content to transform
416
+ * @param tagName - The HTML tag name to target (e.g., 'ng-template')
417
+ * @param attributeName - The attribute name to remove
418
+ * @returns The transformed template content
419
+ */
420
+ const valuelessAttributeRemoval = (templateContent, tagName, attributeName) => {
421
+ const escapeRegex = (str) => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
422
+ const pattern = new RegExp(`(<${escapeRegex(tagName)}\\b(?:[^>"']|"[^"]*"|'[^']*')*?)\\s+${escapeRegex(attributeName)}(?:\\s*=\\s*(?:"[^"]*"|'[^']*'|[^\\s>]+))?(?=\\s|\\/?>)`, 'gi');
423
+ return templateContent.replace(pattern, '$1');
424
+ };
425
+ exports.valuelessAttributeRemoval = valuelessAttributeRemoval;
377
426
  function tsPropertyRemoval(source, rootSource, j, packageName, typeName, propertyName) {
378
427
  if (source.includes(typeName)) {
379
428
  if (!isImportedFromPackage(rootSource, j, packageName, typeName)) {
@@ -0,0 +1,86 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2026 Progress Software Corporation. All rights reserved.
3
+ * Licensed under commercial license. See LICENSE.md in the project root for more information
4
+ *-------------------------------------------------------------------------------------------*/
5
+ "use strict";
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.default = default_1;
8
+ const tslib_1 = require("tslib");
9
+ const fs = tslib_1.__importStar(require("fs"));
10
+ const codemods_1 = require("@progress/kendo-angular-common/codemods");
11
+ const directiveName = 'RecurrenceButtonTextTemplateDirective';
12
+ const directiveSelector = 'kendoSchedulerRecurrenceButtonTextTemplate';
13
+ const schedulerPackage = '@progress/kendo-angular-scheduler';
14
+ const removeDirectiveSelector = (templateContent) => (0, codemods_1.valuelessAttributeRemoval)(templateContent, 'ng-template', directiveSelector);
15
+ const removeDirectiveSymbolReferences = (rootSource, j) => {
16
+ const directiveLocalName = (0, codemods_1.getImportedLocalName)(rootSource, j, schedulerPackage, directiveName);
17
+ if (!directiveLocalName) {
18
+ return;
19
+ }
20
+ rootSource.find(j.ClassProperty)
21
+ .filter((path) => (0, codemods_1.containsIdentifier)(path.node, directiveLocalName))
22
+ .remove();
23
+ rootSource.find(j.ArrayExpression).forEach((path) => {
24
+ path.node.elements = path.node.elements.filter((element) => !(element?.type === 'Identifier' && element.name === directiveLocalName));
25
+ });
26
+ rootSource.find(j.TSTypeReference)
27
+ .filter((path) => (0, codemods_1.containsIdentifier)(path.node.typeName, directiveLocalName))
28
+ .replaceWith(() => j.tsUnknownKeyword());
29
+ rootSource.find(j.Identifier)
30
+ .filter((path) => path.node.name === directiveLocalName)
31
+ .forEach((path) => {
32
+ const parent = path.parentPath.node;
33
+ if (parent.type === 'ImportSpecifier') {
34
+ return;
35
+ }
36
+ if (parent.type === 'ObjectProperty') {
37
+ path.parentPath.remove();
38
+ return;
39
+ }
40
+ if (parent.type === 'VariableDeclarator' || parent.type === 'ExpressionStatement') {
41
+ path.parentPath.remove();
42
+ return;
43
+ }
44
+ if (parent.type === 'CallExpression' || parent.type === 'NewExpression') {
45
+ const argumentIndex = parent.arguments.indexOf(path.node);
46
+ if (argumentIndex >= 0) {
47
+ parent.arguments.splice(argumentIndex, 1);
48
+ return;
49
+ }
50
+ }
51
+ path.replace(j.identifier('undefined'));
52
+ });
53
+ rootSource.find(j.ImportDeclaration).forEach((path) => {
54
+ if (path.node.source?.value !== schedulerPackage) {
55
+ return;
56
+ }
57
+ const specifiers = path.node.specifiers || [];
58
+ path.node.specifiers = specifiers.filter((specifier) => specifier.type !== 'ImportSpecifier' ||
59
+ specifier.imported.type !== 'Identifier' ||
60
+ specifier.imported.name !== directiveName);
61
+ if (specifiers.length > 0 && path.node.specifiers.length === 0) {
62
+ path.parentPath.remove();
63
+ }
64
+ });
65
+ rootSource.find(j.VariableDeclaration)
66
+ .filter((path) => path.node.declarations.length === 0)
67
+ .remove();
68
+ };
69
+ function default_1(fileInfo, api) {
70
+ const filePath = fileInfo.path;
71
+ if (!(0, codemods_1.isApiChangeTarget)(filePath)) {
72
+ return fileInfo.source;
73
+ }
74
+ const htmlResult = (0, codemods_1.htmlTransformer)(fileInfo, api, removeDirectiveSelector);
75
+ if (filePath.endsWith('.html')) {
76
+ if (htmlResult && htmlResult !== fileInfo.source) {
77
+ fs.writeFileSync(filePath, htmlResult, 'utf-8');
78
+ return htmlResult;
79
+ }
80
+ return fileInfo.source;
81
+ }
82
+ const j = api.jscodeshift;
83
+ const rootSource = j(htmlResult || fileInfo.source);
84
+ removeDirectiveSymbolReferences(rootSource, j);
85
+ return rootSource.toSource();
86
+ }
@@ -0,0 +1,28 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2026 Progress Software Corporation. All rights reserved.
3
+ * Licensed under commercial license. See LICENSE.md in the project root for more information
4
+ *-------------------------------------------------------------------------------------------*/
5
+ "use strict";
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.default = default_1;
8
+ const tslib_1 = require("tslib");
9
+ const fs = tslib_1.__importStar(require("fs"));
10
+ const codemods_1 = require("@progress/kendo-angular-common/codemods");
11
+ function default_1(fileInfo, api) {
12
+ const filePath = fileInfo.path;
13
+ if (!(0, codemods_1.isApiChangeTarget)(filePath)) {
14
+ return fileInfo.source;
15
+ }
16
+ const htmlResult = (0, codemods_1.htmlTransformer)(fileInfo, api, (templateContent) => (0, codemods_1.attributeNameUpdate)(templateContent, 'kendo-scheduler-messages', 'editorRecurrenceEdit', 'editorRecurrenceEditRecurring'));
17
+ if (filePath.endsWith('.html')) {
18
+ if (htmlResult && htmlResult !== fileInfo.source) {
19
+ fs.writeFileSync(filePath, htmlResult, 'utf-8');
20
+ return htmlResult;
21
+ }
22
+ return fileInfo.source;
23
+ }
24
+ const j = api.jscodeshift;
25
+ const rootSource = j(htmlResult || fileInfo.source);
26
+ (0, codemods_1.tsPropertyTransformer)(fileInfo.source, rootSource, j, '@progress/kendo-angular-scheduler', 'SchedulerCustomMessagesComponent', 'editorRecurrenceEdit', 'editorRecurrenceEditRecurring');
27
+ return rootSource.toSource();
28
+ }