@public-ui/kolibri-cli 4.2.0-rc.1 → 4.2.0-rc.2

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.
@@ -0,0 +1,128 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.AbstractMapPropertyValueToBooleanTask = void 0;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const types_1 = require("../../../../types");
9
+ const reuse_1 = require("../../../shares/reuse");
10
+ const abstract_task_1 = require("../../abstract-task");
11
+ class AbstractMapPropertyValueToBooleanTask extends abstract_task_1.AbstractTask {
12
+ tag;
13
+ sourceProperty;
14
+ targetProperty;
15
+ mappings;
16
+ preserveExistingTarget;
17
+ bareSourceResult;
18
+ componentTagRegExp;
19
+ customElementTagRegExp;
20
+ sourcePropertyCamelCase;
21
+ tagCapitalCase;
22
+ targetPropertyCamelCase;
23
+ constructor(identifier, title, tag, sourceProperty, targetProperty, mappings, versionRange, dependentTasks = [], preserveExistingTarget = false, bareSourceResult, options = {}) {
24
+ super(identifier, title, types_1.MARKUP_EXTENSIONS, versionRange, dependentTasks, options);
25
+ this.tag = tag;
26
+ this.sourceProperty = sourceProperty;
27
+ this.targetProperty = targetProperty;
28
+ this.mappings = mappings;
29
+ this.preserveExistingTarget = preserveExistingTarget;
30
+ this.bareSourceResult = bareSourceResult;
31
+ if (!reuse_1.isTagKebabCaseRegExp.test(tag)) {
32
+ throw (0, reuse_1.logAndCreateError)(`Tag "${tag}" is not in kebab case.`);
33
+ }
34
+ if (!reuse_1.isPropertyKebabCaseRegExp.test(sourceProperty)) {
35
+ throw (0, reuse_1.logAndCreateError)(`Source property "${sourceProperty}" is not in kebab case.`);
36
+ }
37
+ if (!reuse_1.isPropertyKebabCaseRegExp.test(targetProperty)) {
38
+ throw (0, reuse_1.logAndCreateError)(`Target property "${targetProperty}" is not in kebab case.`);
39
+ }
40
+ this.sourcePropertyCamelCase = (0, reuse_1.kebabToCamelCase)(sourceProperty);
41
+ this.targetPropertyCamelCase = (0, reuse_1.kebabToCamelCase)(targetProperty);
42
+ this.tagCapitalCase = (0, reuse_1.kebabToCapitalCase)(tag);
43
+ this.componentTagRegExp = new RegExp(`<${this.tagCapitalCase}[^>]*${this.sourcePropertyCamelCase}[^>]*>`, 'g');
44
+ this.customElementTagRegExp = new RegExp(`<${this.tag}[^>]*${this.sourceProperty}[^>]*>`, 'g');
45
+ }
46
+ run(baseDir) {
47
+ this.transpileComponentFiles(baseDir);
48
+ this.transpileCustomElementFiles(baseDir);
49
+ }
50
+ transpileComponentFiles(baseDir) {
51
+ (0, reuse_1.filterFilesByExt)(baseDir, types_1.COMPONENT_FILE_EXTENSIONS).forEach((file) => {
52
+ const content = fs_1.default.readFileSync(file, 'utf8');
53
+ const newContent = content.replace(this.componentTagRegExp, (componentTag) => this.rewriteTag(componentTag, true));
54
+ if (newContent !== content) {
55
+ reuse_1.MODIFIED_FILES.add(file);
56
+ fs_1.default.writeFileSync(file, newContent);
57
+ }
58
+ });
59
+ }
60
+ transpileCustomElementFiles(baseDir) {
61
+ (0, reuse_1.filterFilesByExt)(baseDir, types_1.CUSTOM_ELEMENT_FILE_EXTENSIONS).forEach((file) => {
62
+ const content = fs_1.default.readFileSync(file, 'utf8');
63
+ const newContent = content.replace(this.customElementTagRegExp, (componentTag) => this.rewriteTag(componentTag, false));
64
+ if (newContent !== content) {
65
+ reuse_1.MODIFIED_FILES.add(file);
66
+ fs_1.default.writeFileSync(file, newContent);
67
+ }
68
+ });
69
+ }
70
+ rewriteTag(componentTag, isComponent) {
71
+ const sourcePropertyName = isComponent ? this.sourcePropertyCamelCase : this.sourceProperty;
72
+ const targetPropertyName = isComponent ? this.targetPropertyCamelCase : this.targetProperty;
73
+ for (const mapping of this.mappings) {
74
+ const sourceValueRegExp = this.getSourceValueRegExp(sourcePropertyName, mapping.fromValue, isComponent);
75
+ if (!sourceValueRegExp.test(componentTag)) {
76
+ continue;
77
+ }
78
+ if (this.preserveExistingTarget && this.hasTargetProperty(componentTag, targetPropertyName)) {
79
+ return componentTag.replace(sourceValueRegExp, '');
80
+ }
81
+ if (mapping.result === 'remove') {
82
+ return componentTag.replace(sourceValueRegExp, '');
83
+ }
84
+ const replacement = this.getBooleanReplacement(targetPropertyName, mapping.result, isComponent);
85
+ return componentTag.replace(sourceValueRegExp, replacement);
86
+ }
87
+ if (this.bareSourceResult !== undefined) {
88
+ const bareSourceRegExp = this.getBareSourceRegExp(sourcePropertyName);
89
+ if (bareSourceRegExp.test(componentTag)) {
90
+ if (this.preserveExistingTarget && this.hasTargetProperty(componentTag, targetPropertyName)) {
91
+ return componentTag.replace(bareSourceRegExp, '');
92
+ }
93
+ if (this.bareSourceResult === 'remove') {
94
+ return componentTag.replace(bareSourceRegExp, '');
95
+ }
96
+ const replacement = this.getBooleanReplacement(targetPropertyName, this.bareSourceResult, isComponent);
97
+ return componentTag.replace(bareSourceRegExp, replacement);
98
+ }
99
+ }
100
+ return componentTag;
101
+ }
102
+ hasTargetProperty(componentTag, targetPropertyName) {
103
+ const targetRegExp = new RegExp(`\\s${targetPropertyName}(?:\\s*=\\s*(?:\\{[^\\}]+\\}|["'][^"']+["']))?(?=[\\s/>])`);
104
+ return targetRegExp.test(componentTag);
105
+ }
106
+ getSourceValueRegExp(sourcePropertyName, fromValue, isComponent) {
107
+ const escapedValue = this.escapeRegExp(fromValue);
108
+ if (isComponent) {
109
+ const quotedValue = `\\{\\s*(?:"${escapedValue}"|'${escapedValue}')\\s*\\}|(?:"${escapedValue}"|'${escapedValue}')`;
110
+ const booleanLiteral = fromValue === 'true' || fromValue === 'false' ? `|\\{\\s*${escapedValue}\\s*\\}` : '';
111
+ return new RegExp(`\\s${sourcePropertyName}\\s*=\\s*(?:${quotedValue}${booleanLiteral})`);
112
+ }
113
+ return new RegExp(`\\s${sourcePropertyName}\\s*=\\s*["']${escapedValue}["']`);
114
+ }
115
+ getBareSourceRegExp(sourcePropertyName) {
116
+ return new RegExp(`\\s${sourcePropertyName}(?!\\s*=)(?=[\\s/>])`);
117
+ }
118
+ getBooleanReplacement(targetPropertyName, result, isComponent) {
119
+ if (isComponent) {
120
+ return ` ${targetPropertyName}={${result}}`;
121
+ }
122
+ return ` ${targetPropertyName}="${result}"`;
123
+ }
124
+ escapeRegExp(input) {
125
+ return input.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
126
+ }
127
+ }
128
+ exports.AbstractMapPropertyValueToBooleanTask = AbstractMapPropertyValueToBooleanTask;
@@ -1,54 +1,23 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.RenameClearButtonPropTasks = exports.RenameClearButtonPropTask = void 0;
7
- const fs_1 = __importDefault(require("fs"));
8
- const types_1 = require("../../../../types");
9
- const reuse_1 = require("../../../shares/reuse");
10
- const abstract_task_1 = require("../../abstract-task");
11
- class RenameClearButtonPropTask extends abstract_task_1.AbstractTask {
12
- constructor(identifier, versionRange) {
13
- super(identifier, 'Rename _hide-clear-button to _has-clear-button', types_1.MARKUP_EXTENSIONS, versionRange);
4
+ const AbstractMapPropertyValueToBooleanTask_1 = require("../common/AbstractMapPropertyValueToBooleanTask");
5
+ class RenameClearButtonPropTask extends AbstractMapPropertyValueToBooleanTask_1.AbstractMapPropertyValueToBooleanTask {
6
+ static supportedTags = ['kol-combobox', 'kol-single-select'];
7
+ static mappings = [
8
+ { fromValue: 'false', result: 'true' },
9
+ { fromValue: 'true', result: 'false' },
10
+ ];
11
+ constructor(identifier, tag, versionRange) {
12
+ super(identifier, `Rename _hide-clear-button to _has-clear-button for "${tag}"`, tag, '_hide-clear-button', '_has-clear-button', RenameClearButtonPropTask.mappings, versionRange, [], false, 'false');
14
13
  }
15
- static getInstance(versionRange) {
16
- const identifier = 'rename-clear-button-prop';
14
+ static getInstance(versionRange, tag = 'kol-combobox') {
15
+ const identifier = `rename-clear-button-prop-${tag}`;
17
16
  if (!this.instances.has(identifier)) {
18
- this.instances.set(identifier, new RenameClearButtonPropTask(identifier, versionRange));
17
+ this.instances.set(identifier, new RenameClearButtonPropTask(identifier, tag, versionRange));
19
18
  }
20
19
  return this.instances.get(identifier);
21
20
  }
22
- run(baseDir) {
23
- (0, reuse_1.filterFilesByExt)(baseDir, types_1.MARKUP_EXTENSIONS).forEach((file) => {
24
- const content = fs_1.default.readFileSync(file, 'utf8');
25
- const newContent = content
26
- .replace(/_hide-clear-button\s*=\s*"(true|false)"/g, (_match, value) => {
27
- return `_has-clear-button="${value === 'true' ? 'false' : 'true'}"`;
28
- })
29
- .replace(/_hide-clear-button\s*=\s*'(true|false)'/g, (_match, value) => {
30
- return `_has-clear-button='${value === 'true' ? 'false' : 'true'}'`;
31
- })
32
- .replace(/_hide-clear-button\s*=\s*\{\s*(true|false)\s*\}/g, (_match, value) => {
33
- return `_has-clear-button={${value === 'true' ? 'false' : 'true'}}`;
34
- })
35
- .replace(/_hideClearButton\s*=\s*"(true|false)"/g, (_match, value) => {
36
- return `_hasClearButton="${value === 'true' ? 'false' : 'true'}"`;
37
- })
38
- .replace(/_hideClearButton\s*=\s*'(true|false)'/g, (_match, value) => {
39
- return `_hasClearButton='${value === 'true' ? 'false' : 'true'}'`;
40
- })
41
- .replace(/_hideClearButton\s*=\s*\{\s*(true|false)\s*\}/g, (_match, value) => {
42
- return `_hasClearButton={${value === 'true' ? 'false' : 'true'}}`;
43
- })
44
- .replace(/_hide-clear-button(?=[\s/>])/g, '_has-clear-button="false"')
45
- .replace(/_hideClearButton(?=[\s/>])/g, '_hasClearButton={false}');
46
- if (content !== newContent) {
47
- fs_1.default.writeFileSync(file, newContent);
48
- reuse_1.MODIFIED_FILES.add(file);
49
- }
50
- });
51
- }
52
21
  }
53
22
  exports.RenameClearButtonPropTask = RenameClearButtonPropTask;
54
- exports.RenameClearButtonPropTasks = [RenameClearButtonPropTask.getInstance('^4')];
23
+ exports.RenameClearButtonPropTasks = RenameClearButtonPropTask.supportedTags.map((tag) => RenameClearButtonPropTask.getInstance('^4', tag));
@@ -9,6 +9,7 @@ const link_1 = require("./link");
9
9
  const loader_1 = require("./loader");
10
10
  const modal_1 = require("./modal");
11
11
  const msg_1 = require("./msg");
12
+ const password_variant_1 = require("./password-variant");
12
13
  const toast_1 = require("./toast");
13
14
  const toaster_1 = require("./toaster");
14
15
  exports.v4Tasks = [];
@@ -22,3 +23,4 @@ exports.v4Tasks.push(...events_1.RenameKolEventNamesTasks);
22
23
  exports.v4Tasks.push(toast_1.RemoveToastVariantTask.getInstance('^4'));
23
24
  exports.v4Tasks.push(toaster_1.RemoveToasterGetInstanceOptionsTask.getInstance('^4'));
24
25
  exports.v4Tasks.push(loader_1.UpdateLoaderImportPathTask.getInstance('^4'));
26
+ exports.v4Tasks.push(...password_variant_1.RenamePasswordVariantToVisibilityToggleTasks);
@@ -1,21 +1,11 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.MapVariantStandaloneToInlineTasks = exports.MapLinkVariantStandaloneToInlineTask = exports.MapButtonLinkVariantStandaloneToInlineTask = void 0;
7
- const fs_1 = __importDefault(require("fs"));
8
- const types_1 = require("../../../../types");
9
- const reuse_1 = require("../../../shares/reuse");
10
- const abstract_task_1 = require("../../abstract-task");
11
- class MapVariantStandaloneToInlineTask extends abstract_task_1.AbstractTask {
12
- tag;
13
- tagCapitalCase;
14
- variantStandaloneRegExp = /\s_variant\s*=\s*(\{["'`]standalone["'`]\}|["'`]standalone["'`])/;
4
+ const AbstractMapPropertyValueToBooleanTask_1 = require("../common/AbstractMapPropertyValueToBooleanTask");
5
+ class MapVariantStandaloneToInlineTask extends AbstractMapPropertyValueToBooleanTask_1.AbstractMapPropertyValueToBooleanTask {
6
+ static mappings = [{ fromValue: 'standalone', result: 'false' }];
15
7
  constructor(identifier, tag, versionRange, dependentTasks, options) {
16
- super(identifier, `Map "_variant=standalone" to "_inline" for "${tag}"`, types_1.MARKUP_EXTENSIONS, versionRange, dependentTasks, options);
17
- this.tag = tag;
18
- this.tagCapitalCase = (0, reuse_1.kebabToCapitalCase)(tag);
8
+ super(identifier, `Map "_variant=standalone" to "_inline" for "${tag}"`, tag, '_variant', '_inline', MapVariantStandaloneToInlineTask.mappings, versionRange, dependentTasks, true, undefined, options);
19
9
  }
20
10
  static getInstance(tag, versionRange, dependentTasks, options) {
21
11
  const identifier = `${tag}-map-variant-standalone-to-inline`;
@@ -24,42 +14,6 @@ class MapVariantStandaloneToInlineTask extends abstract_task_1.AbstractTask {
24
14
  }
25
15
  return this.instances.get(identifier);
26
16
  }
27
- run(baseDir) {
28
- this.transpileComponentFiles(baseDir);
29
- this.transpileCustomElementFiles(baseDir);
30
- }
31
- transpileComponentFiles(baseDir) {
32
- const tagRegExp = new RegExp(`<${this.tagCapitalCase}[^>]*_variant[^>]*>`, 'g');
33
- (0, reuse_1.filterFilesByExt)(baseDir, types_1.COMPONENT_FILE_EXTENSIONS).forEach((file) => {
34
- const content = fs_1.default.readFileSync(file, 'utf8');
35
- const newContent = content.replace(tagRegExp, (componentTag) => this.rewriteTag(componentTag, true));
36
- if (content !== newContent) {
37
- reuse_1.MODIFIED_FILES.add(file);
38
- fs_1.default.writeFileSync(file, newContent);
39
- }
40
- });
41
- }
42
- transpileCustomElementFiles(baseDir) {
43
- const tagRegExp = new RegExp(`<${this.tag}[^>]*_variant[^>]*>`, 'g');
44
- (0, reuse_1.filterFilesByExt)(baseDir, types_1.CUSTOM_ELEMENT_FILE_EXTENSIONS).forEach((file) => {
45
- const content = fs_1.default.readFileSync(file, 'utf8');
46
- const newContent = content.replace(tagRegExp, (componentTag) => this.rewriteTag(componentTag, false));
47
- if (content !== newContent) {
48
- reuse_1.MODIFIED_FILES.add(file);
49
- fs_1.default.writeFileSync(file, newContent);
50
- }
51
- });
52
- }
53
- rewriteTag(componentTag, isComponent) {
54
- if (!this.variantStandaloneRegExp.test(componentTag)) {
55
- return componentTag;
56
- }
57
- const inlineReplacement = isComponent ? ' _inline={false}' : ' _inline="false"';
58
- if (/\s_inline\s*=/.test(componentTag)) {
59
- return componentTag.replace(this.variantStandaloneRegExp, '');
60
- }
61
- return componentTag.replace(this.variantStandaloneRegExp, inlineReplacement);
62
- }
63
17
  }
64
18
  exports.MapButtonLinkVariantStandaloneToInlineTask = MapVariantStandaloneToInlineTask.getInstance('kol-button-link', '^4');
65
19
  exports.MapLinkVariantStandaloneToInlineTask = MapVariantStandaloneToInlineTask.getInstance('kol-link', '^4');
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RenamePasswordVariantToVisibilityToggleTasks = void 0;
4
+ const AbstractMapPropertyValueToBooleanTask_1 = require("../common/AbstractMapPropertyValueToBooleanTask");
5
+ const RemovePropertyNameTask_1 = require("../common/RemovePropertyNameTask");
6
+ const RenamePropertyNameTask_1 = require("../common/RenamePropertyNameTask");
7
+ const RenameVariantPropTask = RenamePropertyNameTask_1.RenamePropertyNameTask.getInstance('kol-input-password', '_variant', '_visibility-toggle', '^4');
8
+ class MapVisibilityToggleTask extends AbstractMapPropertyValueToBooleanTask_1.AbstractMapPropertyValueToBooleanTask {
9
+ static mappings = [
10
+ { fromValue: 'default', result: 'remove' },
11
+ { fromValue: 'visibility-toggle', result: 'true' },
12
+ ];
13
+ constructor(identifier, versionRange, dependentTasks = []) {
14
+ super(identifier, 'Map password variant values to visibility-toggle boolean semantics', 'kol-input-password', '_visibility-toggle', '_visibility-toggle', MapVisibilityToggleTask.mappings, versionRange, dependentTasks, false);
15
+ }
16
+ static getInstance(versionRange, dependentTasks = []) {
17
+ const identifier = 'kol-input-password-map-variant-to-visibility-toggle';
18
+ if (!this.instances.has(identifier)) {
19
+ this.instances.set(identifier, new MapVisibilityToggleTask(identifier, versionRange, dependentTasks));
20
+ }
21
+ return this.instances.get(identifier);
22
+ }
23
+ }
24
+ const MapVisibilityToggle = MapVisibilityToggleTask.getInstance('^4', [RenameVariantPropTask]);
25
+ const RemoveVariantPropTask = RemovePropertyNameTask_1.RemovePropertyNameTask.getInstance('kol-input-password', '_variant', '^4', [MapVisibilityToggle]);
26
+ exports.RenamePasswordVariantToVisibilityToggleTasks = [RenameVariantPropTask, MapVisibilityToggle, RemoveVariantPropTask];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@public-ui/kolibri-cli",
3
- "version": "4.2.0-rc.1",
3
+ "version": "4.2.0-rc.2",
4
4
  "license": "EUPL-1.2",
5
5
  "homepage": "https://public-ui.github.io",
6
6
  "repository": {
@@ -28,13 +28,13 @@
28
28
  "loglevel": "1.9.2",
29
29
  "prettier": "3.8.3",
30
30
  "prettier-plugin-organize-imports": "4.3.0",
31
- "semver": "7.8.0",
31
+ "semver": "7.8.1",
32
32
  "typed-bem": "1.0.2",
33
- "@public-ui/components": "4.2.0-rc.1"
33
+ "@public-ui/components": "4.2.0-rc.2"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@eslint/js": "9.39.4",
37
- "@types/node": "25.9.0",
37
+ "@types/node": "25.9.1",
38
38
  "@types/semver": "7.7.1",
39
39
  "@typescript-eslint/eslint-plugin": "8.58.2",
40
40
  "@typescript-eslint/parser": "8.58.2",
@@ -42,12 +42,12 @@
42
42
  "eslint": "9.39.4",
43
43
  "eslint-plugin-html": "8.1.4",
44
44
  "eslint-plugin-jsx-a11y": "6.10.2",
45
- "knip": "6.14.1",
46
- "mocha": "11.7.5",
45
+ "knip": "6.14.2",
46
+ "mocha": "11.7.6",
47
47
  "nodemon": "3.1.14",
48
48
  "ts-node": "10.9.2",
49
49
  "typescript": "5.9.3",
50
- "@public-ui/components": "4.2.0-rc.1"
50
+ "@public-ui/components": "4.2.0-rc.2"
51
51
  },
52
52
  "engines": {
53
53
  "node": ">=22"