@spartan-ng/cli 0.0.1-alpha.512 → 0.0.1-alpha.514
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/generators.json +129 -85
- package/package.json +2 -1
- package/src/generators/healthcheck/generator.js +6 -0
- package/src/generators/healthcheck/generator.js.map +1 -1
- package/src/generators/healthcheck/healthchecks/brn-accordion-trigger.d.ts +2 -0
- package/src/generators/healthcheck/healthchecks/brn-accordion-trigger.js +110 -0
- package/src/generators/healthcheck/healthchecks/brn-accordion-trigger.js.map +1 -0
- package/src/generators/healthcheck/healthchecks/brn-checkbox-changed-event-rename.d.ts +2 -0
- package/src/generators/healthcheck/healthchecks/brn-checkbox-changed-event-rename.js +32 -0
- package/src/generators/healthcheck/healthchecks/brn-checkbox-changed-event-rename.js.map +1 -0
- package/src/generators/healthcheck/healthchecks/brn-switch-changed-event-rename.d.ts +2 -0
- package/src/generators/healthcheck/healthchecks/brn-switch-changed-event-rename.js +32 -0
- package/src/generators/healthcheck/healthchecks/brn-switch-changed-event-rename.js.map +1 -0
- package/src/generators/migrate-brain-accordion-trigger/compat.d.ts +2 -0
- package/src/generators/migrate-brain-accordion-trigger/compat.js +7 -0
- package/src/generators/migrate-brain-accordion-trigger/compat.js.map +1 -0
- package/src/generators/migrate-brain-accordion-trigger/generator.d.ts +3 -0
- package/src/generators/migrate-brain-accordion-trigger/generator.js +126 -0
- package/src/generators/migrate-brain-accordion-trigger/generator.js.map +1 -0
- package/src/generators/migrate-brain-accordion-trigger/schema.d.ts +4 -0
- package/src/generators/migrate-brain-accordion-trigger/schema.json +14 -0
- package/src/generators/migrate-brain-accordion-trigger/utils/html-utils.d.ts +15 -0
- package/src/generators/migrate-brain-accordion-trigger/utils/html-utils.js +71 -0
- package/src/generators/migrate-brain-accordion-trigger/utils/html-utils.js.map +1 -0
- package/src/generators/migrate-brain-accordion-trigger/utils/shared-utils.d.ts +35 -0
- package/src/generators/migrate-brain-accordion-trigger/utils/shared-utils.js +111 -0
- package/src/generators/migrate-brain-accordion-trigger/utils/shared-utils.js.map +1 -0
- package/src/generators/migrate-brn-checkbox-changed-event/compat.d.ts +2 -0
- package/src/generators/migrate-brn-checkbox-changed-event/compat.js +7 -0
- package/src/generators/migrate-brn-checkbox-changed-event/compat.js.map +1 -0
- package/src/generators/migrate-brn-checkbox-changed-event/generator.d.ts +4 -0
- package/src/generators/migrate-brn-checkbox-changed-event/generator.js +29 -0
- package/src/generators/migrate-brn-checkbox-changed-event/generator.js.map +1 -0
- package/src/generators/migrate-brn-checkbox-changed-event/schema.d.ts +3 -0
- package/src/generators/migrate-brn-checkbox-changed-event/schema.json +14 -0
- package/src/generators/migrate-brn-switch-changed-event/compat.d.ts +2 -0
- package/src/generators/migrate-brn-switch-changed-event/compat.js +7 -0
- package/src/generators/migrate-brn-switch-changed-event/compat.js.map +1 -0
- package/src/generators/migrate-brn-switch-changed-event/generator.d.ts +4 -0
- package/src/generators/migrate-brn-switch-changed-event/generator.js +29 -0
- package/src/generators/migrate-brn-switch-changed-event/generator.js.map +1 -0
- package/src/generators/migrate-brn-switch-changed-event/schema.d.ts +3 -0
- package/src/generators/migrate-brn-switch-changed-event/schema.json +14 -0
- package/src/generators/migrate-date-picker/schema.json +1 -1
- package/src/generators/ui/libs/ui-accordion-helm/files/lib/hlm-accordion-content.ts.template +3 -1
- package/src/generators/ui/libs/ui-checkbox-helm/files/lib/hlm-checkbox.ts.template +2 -5
- package/src/generators/ui/libs/ui-switch-helm/files/lib/hlm-switch.ts.template +3 -6
- package/src/generators/ui/supported-ui-libraries.json +27 -27
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = migrateAccordionTriggerGenerator;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const node_html_parser_1 = require("node-html-parser");
|
|
6
|
+
const ts_morph_1 = require("ts-morph");
|
|
7
|
+
const visit_files_1 = require("../../utils/visit-files");
|
|
8
|
+
const html_utils_1 = require("./utils/html-utils");
|
|
9
|
+
const shared_utils_1 = require("./utils/shared-utils");
|
|
10
|
+
async function migrateAccordionTriggerGenerator(tree, { skipFormat }) {
|
|
11
|
+
const issues = [];
|
|
12
|
+
const project = new ts_morph_1.Project({ useInMemoryFileSystem: true });
|
|
13
|
+
wrapAccordionTriggers(tree, project, issues);
|
|
14
|
+
if (issues.length > 0) {
|
|
15
|
+
reportManualFixesNeeded(issues);
|
|
16
|
+
}
|
|
17
|
+
if (!skipFormat) {
|
|
18
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function wrapAccordionTriggers(tree, project, issues) {
|
|
22
|
+
(0, visit_files_1.visitFiles)(tree, '.', (path) => {
|
|
23
|
+
console.log('Processing ' + path + '...');
|
|
24
|
+
if (!(0, shared_utils_1.shouldProcessFile)(path))
|
|
25
|
+
return;
|
|
26
|
+
const content = tree.read(path, 'utf-8');
|
|
27
|
+
if (!content || !(0, shared_utils_1.hasAccordionTriggers)(content))
|
|
28
|
+
return;
|
|
29
|
+
const result = path.endsWith('.html')
|
|
30
|
+
? fixTemplate(content, path, issues)
|
|
31
|
+
: fixComponentFile(content, path, project, issues);
|
|
32
|
+
if (result?.modified) {
|
|
33
|
+
tree.write(path, result.content);
|
|
34
|
+
console.log(`Fixed ${result.fixedCount} accordion trigger(s) in ${path}`);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
function fixTemplate(content, filePath, issues, options = { noContentsClass: false }) {
|
|
39
|
+
const root = (0, html_utils_1.parseHtmlForAccordionMigration)(content);
|
|
40
|
+
const buttons = (0, html_utils_1.findAccordionButtons)(root);
|
|
41
|
+
let fixedCount = 0;
|
|
42
|
+
for (const button of buttons) {
|
|
43
|
+
const analysis = (0, shared_utils_1.analyzeButton)(button);
|
|
44
|
+
switch (analysis.issue) {
|
|
45
|
+
case 'NotInHeading':
|
|
46
|
+
(0, html_utils_1.wrapButtonInHeading)(button, !options.noContentsClass);
|
|
47
|
+
fixedCount++;
|
|
48
|
+
break;
|
|
49
|
+
case 'HasSiblings':
|
|
50
|
+
logSiblingIssue(analysis, filePath, issues);
|
|
51
|
+
break;
|
|
52
|
+
case 'NoIssue':
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
if (fixedCount > 0) {
|
|
57
|
+
return {
|
|
58
|
+
content: formatHtmlOutput(root),
|
|
59
|
+
modified: true,
|
|
60
|
+
fixedCount,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
return { content, modified: false, fixedCount: 0 };
|
|
64
|
+
}
|
|
65
|
+
function fixComponentFile(content, filePath, project, issues) {
|
|
66
|
+
const sourceFile = project.createSourceFile(filePath, content, { overwrite: true });
|
|
67
|
+
const templateInfo = (0, shared_utils_1.extractInlineTemplate)(sourceFile);
|
|
68
|
+
if (!templateInfo) {
|
|
69
|
+
return { content, modified: false, fixedCount: 0 };
|
|
70
|
+
}
|
|
71
|
+
// Fix the template content
|
|
72
|
+
const result = fixTemplate(templateInfo.text, filePath, issues);
|
|
73
|
+
if (result.modified && templateInfo.propertyAssignment.getInitializer()) {
|
|
74
|
+
// Replace template in source file
|
|
75
|
+
const quoteStyle = templateInfo.originalQuoteStyle || '`';
|
|
76
|
+
let newTemplateValue;
|
|
77
|
+
if (quoteStyle === '`') {
|
|
78
|
+
newTemplateValue = `\`${result.content}\``;
|
|
79
|
+
}
|
|
80
|
+
else if (quoteStyle === '"') {
|
|
81
|
+
newTemplateValue = `"${result.content.replace(/"/g, '\\"')}"`;
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
newTemplateValue = `'${result.content.replace(/'/g, "\\'")}'`;
|
|
85
|
+
}
|
|
86
|
+
templateInfo.propertyAssignment.getInitializer().replaceWithText(newTemplateValue);
|
|
87
|
+
return {
|
|
88
|
+
content: sourceFile.getFullText(),
|
|
89
|
+
modified: true,
|
|
90
|
+
fixedCount: result.fixedCount,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
return { content, modified: false, fixedCount: 0 };
|
|
94
|
+
}
|
|
95
|
+
function logSiblingIssue(analysis, filePath, issues) {
|
|
96
|
+
const parent = analysis.parent;
|
|
97
|
+
const siblingContent = getSiblingPreview(analysis.button, parent);
|
|
98
|
+
issues.push(`! ${filePath}\n` +
|
|
99
|
+
` - Button "${analysis.buttonText}" in <${parent.tagName.toLowerCase()}> ` +
|
|
100
|
+
`has siblings that need to be moved: ${siblingContent}...\n`);
|
|
101
|
+
}
|
|
102
|
+
function getSiblingPreview(button, parent) {
|
|
103
|
+
return parent.childNodes
|
|
104
|
+
.filter((child) => child !== button)
|
|
105
|
+
.map((child) => {
|
|
106
|
+
if (child.nodeType === node_html_parser_1.NodeType.TEXT_NODE) {
|
|
107
|
+
return child.text?.trim();
|
|
108
|
+
}
|
|
109
|
+
return child.toString();
|
|
110
|
+
})
|
|
111
|
+
.filter(Boolean)
|
|
112
|
+
.join(', ')
|
|
113
|
+
.substring(0, 50);
|
|
114
|
+
}
|
|
115
|
+
function formatHtmlOutput(root) {
|
|
116
|
+
const output = root.toString();
|
|
117
|
+
// Convert empty tags to self-closing
|
|
118
|
+
return output.replace(/<([^>\s]+)([^>]*)><\/\1>/g, '<$1$2/>');
|
|
119
|
+
}
|
|
120
|
+
function reportManualFixesNeeded(issues) {
|
|
121
|
+
console.log(`We also detected ${issues.length} accordion trigger buttons ` +
|
|
122
|
+
`that have siblings that need to be manually moved:`);
|
|
123
|
+
issues.forEach((issue) => console.log(issue));
|
|
124
|
+
console.log('To learn more about this pattern see: ' + 'https://www.w3.org/WAI/ARIA/apg/patterns/accordion/');
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../libs/cli/src/generators/migrate-brain-accordion-trigger/generator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ChD,OAAO,CAAC,GAAG,CACV,oBAAoB,MAAM,CAAC,MAAM,6BAA6B;QAC7D,oDAAoD,CACrD,CAAC;IACF,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;IAC9C,OAAO,CAAC,GAAG,CAAC,wCAAwC,GAAG,qDAAqD,CAAC,CAAC;AAC/G,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema",
|
|
3
|
+
"$id": "MigrateAccordionTrigger",
|
|
4
|
+
"title": "",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"skipFormat": {
|
|
8
|
+
"type": "boolean",
|
|
9
|
+
"default": false,
|
|
10
|
+
"description": "Skip formatting files"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"required": []
|
|
14
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { HTMLElement as ParsedHTMLElement } from 'node-html-parser';
|
|
2
|
+
export type HTMLElement = ParsedHTMLElement;
|
|
3
|
+
export declare const HTML_PARSE_CONFIG: {
|
|
4
|
+
lowerCaseTagName: boolean;
|
|
5
|
+
comment: boolean;
|
|
6
|
+
voidTag: {
|
|
7
|
+
tags: string[];
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export declare function parseHtmlForAccordionMigration(content: string): ParsedHTMLElement;
|
|
11
|
+
export declare function findAccordionButtons(root: HTMLElement): HTMLElement[];
|
|
12
|
+
export declare function isInHeading(button: HTMLElement): boolean;
|
|
13
|
+
export declare function hasSignificantSiblings(button: HTMLElement): boolean;
|
|
14
|
+
export declare function getButtonText(button: HTMLElement, maxLength?: number): string;
|
|
15
|
+
export declare function wrapButtonInHeading(button: HTMLElement, useContentsClass?: boolean): void;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HTML_PARSE_CONFIG = void 0;
|
|
4
|
+
exports.parseHtmlForAccordionMigration = parseHtmlForAccordionMigration;
|
|
5
|
+
exports.findAccordionButtons = findAccordionButtons;
|
|
6
|
+
exports.isInHeading = isInHeading;
|
|
7
|
+
exports.hasSignificantSiblings = hasSignificantSiblings;
|
|
8
|
+
exports.getButtonText = getButtonText;
|
|
9
|
+
exports.wrapButtonInHeading = wrapButtonInHeading;
|
|
10
|
+
const tslib_1 = require("tslib");
|
|
11
|
+
const node_html_parser_1 = tslib_1.__importStar(require("node-html-parser"));
|
|
12
|
+
exports.HTML_PARSE_CONFIG = {
|
|
13
|
+
lowerCaseTagName: false,
|
|
14
|
+
comment: false,
|
|
15
|
+
voidTag: {
|
|
16
|
+
tags: [
|
|
17
|
+
'img',
|
|
18
|
+
'br',
|
|
19
|
+
'hr',
|
|
20
|
+
'area',
|
|
21
|
+
'base',
|
|
22
|
+
'col',
|
|
23
|
+
'embed',
|
|
24
|
+
'input',
|
|
25
|
+
'link',
|
|
26
|
+
'meta',
|
|
27
|
+
'param',
|
|
28
|
+
'source',
|
|
29
|
+
'track',
|
|
30
|
+
'wbr',
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
function parseHtmlForAccordionMigration(content) {
|
|
35
|
+
return (0, node_html_parser_1.default)(content, exports.HTML_PARSE_CONFIG);
|
|
36
|
+
}
|
|
37
|
+
function findAccordionButtons(root) {
|
|
38
|
+
return root.querySelectorAll('button[brnAccordionTrigger], button[hlmAccordionTrigger]');
|
|
39
|
+
}
|
|
40
|
+
function isInHeading(button) {
|
|
41
|
+
const parent = button.parentNode;
|
|
42
|
+
return !!(parent && /^h[1-6]$/i.test(parent.tagName));
|
|
43
|
+
}
|
|
44
|
+
function hasSignificantSiblings(button) {
|
|
45
|
+
const parent = button.parentNode;
|
|
46
|
+
if (!parent)
|
|
47
|
+
return false;
|
|
48
|
+
const siblings = parent.childNodes.filter((child) => {
|
|
49
|
+
if (child === button)
|
|
50
|
+
return false;
|
|
51
|
+
if (child.nodeType === node_html_parser_1.NodeType.TEXT_NODE) {
|
|
52
|
+
return child.text?.trim().length > 0;
|
|
53
|
+
}
|
|
54
|
+
return true;
|
|
55
|
+
});
|
|
56
|
+
return siblings.length > 0;
|
|
57
|
+
}
|
|
58
|
+
function getButtonText(button, maxLength = 50) {
|
|
59
|
+
return button.innerText?.trim()?.substring(0, maxLength) || '';
|
|
60
|
+
}
|
|
61
|
+
function wrapButtonInHeading(button, useContentsClass = true) {
|
|
62
|
+
const h3Html = useContentsClass ? '<h3 class="contents"></h3>' : '<h3></h3>';
|
|
63
|
+
const h3 = parseHtmlForAccordionMigration(h3Html).firstChild;
|
|
64
|
+
const parent = button.parentNode;
|
|
65
|
+
button.remove();
|
|
66
|
+
h3.appendChild(button);
|
|
67
|
+
if (parent) {
|
|
68
|
+
parent.prepend(h3);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=html-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html-utils.js","sourceRoot":"","sources":["../../../../../../../libs/cli/src/generators/migrate-brain-accordion-trigger/utils/html-utils.ts"],"names":[],"mappings":";;;AA0BA,wEAEC;AAED,oDAEC;AAED,kCAGC;AAED,wDAaC;AAED,sCAEC;AAED,kDAWC;;AArED,6EAAqF;AAGxE,QAAA,iBAAiB,GAAG;IAChC,gBAAgB,EAAE,KAAK;IACvB,OAAO,EAAE,KAAK;IACd,OAAO,EAAE;QACR,IAAI,EAAE;YACL,KAAK;YACL,IAAI;YACJ,IAAI;YACJ,MAAM;YACN,MAAM;YACN,KAAK;YACL,OAAO;YACP,OAAO;YACP,MAAM;YACN,MAAM;YACN,OAAO;YACP,QAAQ;YACR,OAAO;YACP,KAAK;SACL;KACD;CACD,CAAC;AAEF,SAAgB,8BAA8B,CAAC,OAAe;IAC7D,OAAO,IAAA,0B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MAAM,EAAE,GAAG,8BAA8B,CAAC,MAAM,CAAC,CAAC,UAAyB,CAAC;IAE5E,MAAM,MAAM,GAAG,MAAM,CAAC,UAAyB,CAAC;IAChD,MAAM,CAAC,MAAM,EAAE,CAAC;IAChB,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IAEvB,IAAI,MAAM,EAAE,CAAC;QACZ,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACpB,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Decorator, PropertyAssignment, SourceFile } from 'ts-morph';
|
|
2
|
+
import { HTMLElement } from './html-utils';
|
|
3
|
+
export declare function shouldProcessFile(file: string): boolean;
|
|
4
|
+
export declare function hasAccordionTriggers(content: string): boolean;
|
|
5
|
+
export interface TemplateInfo {
|
|
6
|
+
text: string;
|
|
7
|
+
startLine: number;
|
|
8
|
+
propertyAssignment?: PropertyAssignment;
|
|
9
|
+
originalQuoteStyle?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function extractInlineTemplate(sourceFile: SourceFile): TemplateInfo | null;
|
|
12
|
+
/**
|
|
13
|
+
* Checks if a decorator is @Component and extracts its template
|
|
14
|
+
*
|
|
15
|
+
* The AST (Abstract Syntax Tree) structure looks like this:
|
|
16
|
+
*
|
|
17
|
+
* Decorator (@Component)
|
|
18
|
+
* └── CallExpression (Component(...))
|
|
19
|
+
* └── ObjectLiteralExpression ({...})
|
|
20
|
+
* └── PropertyAssignment (template: '...')
|
|
21
|
+
* ├── Identifier (the word "template")
|
|
22
|
+
* └── StringLiteral (the actual template string)
|
|
23
|
+
*
|
|
24
|
+
* We need to navigate down this tree to find the template!
|
|
25
|
+
*/
|
|
26
|
+
export declare function findComponentTemplate(decorator: Decorator): TemplateInfo | null;
|
|
27
|
+
export type ButtonIssue = 'NotInHeading' | 'HasSiblings' | 'NoIssue';
|
|
28
|
+
export interface ButtonAnalysis {
|
|
29
|
+
issue: ButtonIssue;
|
|
30
|
+
button: HTMLElement;
|
|
31
|
+
buttonText: string;
|
|
32
|
+
parent: HTMLElement | null;
|
|
33
|
+
line: number;
|
|
34
|
+
}
|
|
35
|
+
export declare function analyzeButton(button: HTMLElement): ButtonAnalysis;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.shouldProcessFile = shouldProcessFile;
|
|
4
|
+
exports.hasAccordionTriggers = hasAccordionTriggers;
|
|
5
|
+
exports.extractInlineTemplate = extractInlineTemplate;
|
|
6
|
+
exports.findComponentTemplate = findComponentTemplate;
|
|
7
|
+
exports.analyzeButton = analyzeButton;
|
|
8
|
+
const ts_morph_1 = require("ts-morph");
|
|
9
|
+
const html_utils_1 = require("./html-utils");
|
|
10
|
+
function shouldProcessFile(file) {
|
|
11
|
+
return file.endsWith('.ts') || file.endsWith('.html');
|
|
12
|
+
}
|
|
13
|
+
function hasAccordionTriggers(content) {
|
|
14
|
+
return content.includes('brnAccordionTrigger') || content.includes('hlmAccordionTrigger');
|
|
15
|
+
}
|
|
16
|
+
function extractInlineTemplate(sourceFile) {
|
|
17
|
+
// Find all @Something decorators in the file
|
|
18
|
+
// (like @Component, @Directive, etc.)
|
|
19
|
+
const decorators = sourceFile.getDescendantsOfKind(ts_morph_1.SyntaxKind.Decorator);
|
|
20
|
+
for (const decorator of decorators) {
|
|
21
|
+
const template = findComponentTemplate(decorator);
|
|
22
|
+
if (template)
|
|
23
|
+
return template;
|
|
24
|
+
}
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Checks if a decorator is @Component and extracts its template
|
|
29
|
+
*
|
|
30
|
+
* The AST (Abstract Syntax Tree) structure looks like this:
|
|
31
|
+
*
|
|
32
|
+
* Decorator (@Component)
|
|
33
|
+
* └── CallExpression (Component(...))
|
|
34
|
+
* └── ObjectLiteralExpression ({...})
|
|
35
|
+
* └── PropertyAssignment (template: '...')
|
|
36
|
+
* ├── Identifier (the word "template")
|
|
37
|
+
* └── StringLiteral (the actual template string)
|
|
38
|
+
*
|
|
39
|
+
* We need to navigate down this tree to find the template!
|
|
40
|
+
*/
|
|
41
|
+
function findComponentTemplate(decorator) {
|
|
42
|
+
// Step 1: Get the function call part of @Component(...)
|
|
43
|
+
// We want the Component(...) part
|
|
44
|
+
const callExpression = decorator.getCallExpression();
|
|
45
|
+
// Make sure this is @Component, not @Injectable or something else
|
|
46
|
+
if (callExpression?.getExpression().getText() !== 'Component') {
|
|
47
|
+
return null; // Not a component decorator, skip it
|
|
48
|
+
}
|
|
49
|
+
// Step 2: Get the arguments passed to Component(...)
|
|
50
|
+
// Usually it's Component({ template: '...', selector: '...' })
|
|
51
|
+
const args = callExpression.getArguments();
|
|
52
|
+
// Make sure there's an object literal as first argument
|
|
53
|
+
if (args.length === 0 || args[0].getKind() !== ts_morph_1.SyntaxKind.ObjectLiteralExpression) {
|
|
54
|
+
return null; // Component() with no args or weird args, skip
|
|
55
|
+
}
|
|
56
|
+
// Step 3: Get the object literal { template: '...', ... }
|
|
57
|
+
const objLiteral = args[0].asKindOrThrow(ts_morph_1.SyntaxKind.ObjectLiteralExpression);
|
|
58
|
+
// Step 4: Find the "template" property in the object
|
|
59
|
+
// We're looking for: template: '...' or template: `...`
|
|
60
|
+
const templateProp = objLiteral.getProperty('template');
|
|
61
|
+
// Make sure we found a template property and it's an assignment
|
|
62
|
+
if (!templateProp || templateProp.getKind() !== ts_morph_1.SyntaxKind.PropertyAssignment) {
|
|
63
|
+
return null; // No template property, must use templateUrl or external file
|
|
64
|
+
}
|
|
65
|
+
// Step 5: Cast to PropertyAssignment so TypeScript knows what we have
|
|
66
|
+
// PropertyAssignment means something like: key: value
|
|
67
|
+
const propAssignment = templateProp.asKindOrThrow(ts_morph_1.SyntaxKind.PropertyAssignment);
|
|
68
|
+
// Step 6: Get the value part of template: VALUE
|
|
69
|
+
// This is the actual template string
|
|
70
|
+
const initializer = propAssignment.getInitializer();
|
|
71
|
+
if (!initializer)
|
|
72
|
+
return null; // Shouldn't happen but be safe
|
|
73
|
+
// Step 7: Get the full text including quotes
|
|
74
|
+
// Could be: `<div>...</div>` or "<div>...</div>" or '<div>...</div>'
|
|
75
|
+
const fullText = initializer.getText();
|
|
76
|
+
// Step 8: Check what kind of string it is
|
|
77
|
+
const isStringLiteral = initializer.getKind() === ts_morph_1.SyntaxKind.StringLiteral; // "..." or '...'
|
|
78
|
+
const isTemplateLiteral = initializer.getKind() === ts_morph_1.SyntaxKind.NoSubstitutionTemplateLiteral; // `...`
|
|
79
|
+
if (!isStringLiteral && !isTemplateLiteral) {
|
|
80
|
+
return null; // template is something weird like a variable or function call
|
|
81
|
+
}
|
|
82
|
+
// Step 9: Figure out what quotes were used (we want to preserve them)
|
|
83
|
+
const quoteStyle = fullText[0]; // First character is the quote
|
|
84
|
+
// Step 10: Return all the info we gathered!
|
|
85
|
+
return {
|
|
86
|
+
text: fullText.slice(1, -1), // Remove first and last character (the quotes)
|
|
87
|
+
startLine: initializer.getStartLineNumber(), // For error messages
|
|
88
|
+
propertyAssignment: propAssignment, // Save this so we can modify it later!
|
|
89
|
+
originalQuoteStyle: quoteStyle, // Remember if it was ` or " or '
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
function analyzeButton(button) {
|
|
93
|
+
const buttonText = (0, html_utils_1.getButtonText)(button);
|
|
94
|
+
const parent = button.parentNode;
|
|
95
|
+
// Check what's wrong (if anything)
|
|
96
|
+
let issue = 'NoIssue';
|
|
97
|
+
if (!(0, html_utils_1.isInHeading)(button)) {
|
|
98
|
+
issue = 'NotInHeading';
|
|
99
|
+
}
|
|
100
|
+
else if ((0, html_utils_1.hasSignificantSiblings)(button)) {
|
|
101
|
+
issue = 'HasSiblings';
|
|
102
|
+
}
|
|
103
|
+
return {
|
|
104
|
+
issue,
|
|
105
|
+
button,
|
|
106
|
+
buttonText,
|
|
107
|
+
parent,
|
|
108
|
+
line: button.range?.[0] || 0,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=shared-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared-utils.js","sourceRoot":"","sources":["../../../../../../../libs/cli/src/generators/migrate-brain-accordion-trigger/utils/shared-utils.ts"],"names":[],"mappings":";;AAGA,8CAEC;AAED,oDAEC;AASD,sDAWC;AAgBD,sDA+DC;AAYD,sCAoBC;AA5ID,uCAAiF;AACjF,6CAA+F;AAE/F,SAAgB,iBAAiB,CAAC,IAAY;IAC7C,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;AACvD,CAAC;AAED,SAAgB,oBAAoB,CAAC,OAAe;IACnD,OAAO,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAC,CAAC;AAC3F,CAAC;AASD,SAAgB,qBAAqB,CAAC,UAAsB;IAC3D,6CAA6C;IAC7C,sCAAsC;IACtC,MAAM,UAAU,GAAG,UAAU,CAAC,oBAAoB,CAAC,qBAAU,CAAC,SAAS,CAAC,CAAC;IAEzE,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACpC,MAAM,QAAQ,GAAG,qBAAqB,CAAC,SAAS,CAAC,CAAC;QAClD,IAAI,QAAQ;YAAE,OAAO,QAAQ,CAAC;IAC/B,CAAC;IAED,OAAO,IAAI,CAAC;AACb,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,SAAgB,qBAAqB,CAAC,SAAoB;IACzD,wDAAwD;IACxD,0CAA0C;IAC1C,MAAM,cAAc,GAAG,SAAS,CAAC,iBAAiB,EAAE,CAAC;IAErD,kEAAkE;IAClE,IAAI,cAAc,EAAE,aAAa,EAAE,CAAC,OAAO,EAAE,KAAK,WAAW,EAAE,CAAC;QAC/D,OAAO,IAAI,CAAC,CAAC,qCAAqC;IACn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AC,eAAe,IAAI,CAAC,iBAAiB,EAAE,CAAC;QAC5C,OAAO,IAAI,CAAC,CAAC,+DAA+D;IAC7E,CAAC;IAED,sEAAsE;IACtE,MAAM,UAAU,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,+BAA+B;IAE/D,4CAA4C;IAC5C,OAAO;QACN,IAAI,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,+CAA+C;QAC5E,SAAS,EAAE,WAAW,CAAC,kBAAkB,EAAE,EAAE,qBAAqB;QAClE,kBAAkB,EAAE,cAAc,EAAE,uCAAuC;QAC3E,kBAAkB,EAAE,UAAU,EAAE,iCAAiC;KACjE,CAAC;AACH,CAAC;AAYD,SAAgB,aAAa,CAAC,MAAmB;IAChD,MAAM,UAAU,GAAG,IAAA,0BAAa,EAAC,MAAM,CAAC,CAAC;IACzC,MAAM,MAAM,GAAG,MAAM,CAAC,UAAyB,CAAC;IAEhD,mCAAmC;IACnC,IAAI,KAAK,GAAgB,SAAS,CAAC;IAEnC,IAAI,CAAC,IAAA,wBAAW,EAAC,MAAM,CAAC,EAAE,CAAC;QAC1B,KAAK,GAAG,cAAc,CAAC;IACxB,CAAC;SAAM,IAAI,IAAA,mCAAsB,EAAC,MAAM,CAAC,EAAE,CAAC;QAC3C,KAAK,GAAG,aAAa,CAAC;IACvB,CAAC;IAED,OAAO;QACN,KAAK;QACL,MAAM;QACN,UAAU;QACV,MAAM;QACN,IAAI,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;KAC5B,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const generator_1 = tslib_1.__importDefault(require("./generator"));
|
|
6
|
+
exports.default = (0, devkit_1.convertNxGenerator)(generator_1.default);
|
|
7
|
+
//# sourceMappingURL=compat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compat.js","sourceRoot":"","sources":["../../../../../../libs/cli/src/generators/migrate-brn-checkbox-changed-event/compat.ts"],"names":[],"mappings":";;;AAAA,uCAAgD;AAChD,oEAAyD;AAEzD,kBAAe,IAAA,2BAAkB,EAAC,mBAA8B,CAAC,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Tree } from '@nx/devkit';
|
|
2
|
+
import { MigrateBrnCheckboxChangedEvent } from './schema';
|
|
3
|
+
export declare function migrateBrnCheckboxChangedEvent(tree: Tree, { skipFormat }: MigrateBrnCheckboxChangedEvent): Promise<void>;
|
|
4
|
+
export default migrateBrnCheckboxChangedEvent;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.migrateBrnCheckboxChangedEvent = migrateBrnCheckboxChangedEvent;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const visit_files_1 = require("../../utils/visit-files");
|
|
6
|
+
async function migrateBrnCheckboxChangedEvent(tree, { skipFormat }) {
|
|
7
|
+
replaceOpenChangeEvent(tree);
|
|
8
|
+
if (!skipFormat) {
|
|
9
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
function replaceOpenChangeEvent(tree) {
|
|
13
|
+
// if the element is `'<hlm-select' and it has an `(openedChange)` event, we need to replace it with `(openChange)`
|
|
14
|
+
(0, visit_files_1.visitFiles)(tree, '.', (path) => {
|
|
15
|
+
// if this is not an html file or typescript file (inline templates) then skip
|
|
16
|
+
if (!path.endsWith('.html') && !path.endsWith('.ts')) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
let content = tree.read(path, 'utf-8');
|
|
20
|
+
if (!content) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
// find all the brn-select or hlm-select elements that have an `(openedChange)` event
|
|
24
|
+
content = content.replace(/<(brn-checkbox)[^>]*\(\s*changed\s*\)=/g, (match) => match.replace(/\(\s*changed\s*\)/, '(checkedChange)'));
|
|
25
|
+
tree.write(path, content);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
exports.default = migrateBrnCheckboxChangedEvent;
|
|
29
|
+
//# sourceMappingURL=generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../libs/cli/src/generators/migrate-brn-checkbox-changed-event/generator.ts"],"names":[],"mappings":";;AAIA,wEAMC;AAVD,uCAA+C;AAC/C,yDAAqD;AAG9C,KAAK,UAAU,8BAA8B,CAAC,IAAU,EAAE,EAAE,UAAU,EAAkC;IAC9G,sBAAsB,CAAC,IAAI,CAAC,CAAC;IAE7B,IAAI,CAAC,UAAU,EAAE,CAAC;QACjB,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;IACzB,CAAC;AACF,CAAC;AAED,SAAS,sBAAsB,CAAC,IAAU;IACzC,mHAAmH;IACnH,IAAA,wBAAU,EAAC,IAAI,EAAE,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE;QAC9B,8EAA8E;QAC9E,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YACtD,OAAO;QACR,CAAC;QAED,IAAI,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAEvC,IAAI,CAAC,OAAO,EAAE,CAAC;YACd,OAAO;QACR,CAAC;QAED,qFAAqF;QACrF,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,yCAAyC,EAAE,CAAC,KAAK,EAAE,EAAE,CAC9E,KAAK,CAAC,OAAO,CAAC,mBAAmB,EAAE,iBAAiB,CAAC,CACrD,CAAC;QAEF,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC3B,CAAC,CAAC,CAAC;AACJ,CAAC;AAED,kBAAe,8BAA8B,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema",
|
|
3
|
+
"$id": "MigrateBrnCheckboxChangedEvent",
|
|
4
|
+
"title": "",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"skipFormat": {
|
|
8
|
+
"type": "boolean",
|
|
9
|
+
"default": false,
|
|
10
|
+
"description": "Skip formatting files"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"required": []
|
|
14
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const generator_1 = tslib_1.__importDefault(require("./generator"));
|
|
6
|
+
exports.default = (0, devkit_1.convertNxGenerator)(generator_1.default);
|
|
7
|
+
//# sourceMappingURL=compat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compat.js","sourceRoot":"","sources":["../../../../../../libs/cli/src/generators/migrate-brn-switch-changed-event/compat.ts"],"names":[],"mappings":";;;AAAA,uCAAgD;AAChD,oEAAuD;AAEvD,kBAAe,IAAA,2BAAkB,EAAC,mBAA4B,CAAC,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.migrateBrnSwitchChangedEvent = migrateBrnSwitchChangedEvent;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const visit_files_1 = require("../../utils/visit-files");
|
|
6
|
+
async function migrateBrnSwitchChangedEvent(tree, { skipFormat }) {
|
|
7
|
+
replaceOpenChangeEvent(tree);
|
|
8
|
+
if (!skipFormat) {
|
|
9
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
function replaceOpenChangeEvent(tree) {
|
|
13
|
+
// if the element is `'<hlm-select' and it has an `(openedChange)` event, we need to replace it with `(openChange)`
|
|
14
|
+
(0, visit_files_1.visitFiles)(tree, '.', (path) => {
|
|
15
|
+
// if this is not an html file or typescript file (inline templates) then skip
|
|
16
|
+
if (!path.endsWith('.html') && !path.endsWith('.ts')) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
let content = tree.read(path, 'utf-8');
|
|
20
|
+
if (!content) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
// find all the brn-select or hlm-select elements that have an `(openedChange)` event
|
|
24
|
+
content = content.replace(/<(brn-switch)[^>]*\(\s*changed\s*\)=/g, (match) => match.replace(/\(\s*changed\s*\)/, '(checkedChange)'));
|
|
25
|
+
tree.write(path, content);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
exports.default = migrateBrnSwitchChangedEvent;
|
|
29
|
+
//# sourceMappingURL=generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../libs/cli/src/generators/migrate-brn-switch-changed-event/generator.ts"],"names":[],"mappings":";;AAIA,oEAMC;AAVD,uCAA+C;AAC/C,yDAAqD;AAG9C,KAAK,UAAU,4BAA4B,CAAC,IAAU,EAAE,EAAE,UAAU,EAAgC;IAC1G,sBAAsB,CAAC,IAAI,CAAC,CAAC;IAE7B,IAAI,CAAC,UAAU,EAAE,CAAC;QACjB,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;IACzB,CAAC;AACF,CAAC;AAED,SAAS,sBAAsB,CAAC,IAAU;IACzC,mHAAmH;IACnH,IAAA,wBAAU,EAAC,IAAI,EAAE,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE;QAC9B,8EAA8E;QAC9E,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YACtD,OAAO;QACR,CAAC;QAED,IAAI,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAEvC,IAAI,CAAC,OAAO,EAAE,CAAC;YACd,OAAO;QACR,CAAC;QAED,qFAAqF;QACrF,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,uCAAuC,EAAE,CAAC,KAAK,EAAE,EAAE,CAC5E,KAAK,CAAC,OAAO,CAAC,mBAAmB,EAAE,iBAAiB,CAAC,CACrD,CAAC;QAEF,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC3B,CAAC,CAAC,CAAC;AACJ,CAAC;AAED,kBAAe,4BAA4B,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema",
|
|
3
|
+
"$id": "MigrateBrnSwitchChangedEvent",
|
|
4
|
+
"title": "",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"skipFormat": {
|
|
8
|
+
"type": "boolean",
|
|
9
|
+
"default": false,
|
|
10
|
+
"description": "Skip formatting files"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"required": []
|
|
14
|
+
}
|
package/src/generators/ui/libs/ui-accordion-helm/files/lib/hlm-accordion-content.ts.template
CHANGED
|
@@ -6,7 +6,7 @@ import type { ClassValue } from 'clsx';
|
|
|
6
6
|
@Component({
|
|
7
7
|
selector: 'hlm-accordion-content',
|
|
8
8
|
template: `
|
|
9
|
-
<div [attr.inert]="_addInert()" style="
|
|
9
|
+
<div [attr.inert]="_addInert()" [style]="contentStyle()">
|
|
10
10
|
<div class="flex flex-col gap-4 text-balance pb-4 pt-0">
|
|
11
11
|
<ng-content />
|
|
12
12
|
</div>
|
|
@@ -20,6 +20,8 @@ import type { ClassValue } from 'clsx';
|
|
|
20
20
|
})
|
|
21
21
|
export class HlmAccordionContent extends BrnAccordionContent {
|
|
22
22
|
public readonly userClass = input<ClassValue>('', { alias: 'class' });
|
|
23
|
+
public readonly contentStyle = input<string>('overflow: hidden');
|
|
24
|
+
|
|
23
25
|
protected readonly _computedClass = computed(() => {
|
|
24
26
|
const gridRows = this.state() === 'open' ? 'grid-rows-[1fr]' : 'grid-rows-[0fr]';
|
|
25
27
|
return hlm('grid text-sm transition-all', gridRows, this.userClass());
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { BooleanInput } from '@angular/cdk/coercion';
|
|
2
2
|
import {
|
|
3
|
+
booleanAttribute,
|
|
3
4
|
ChangeDetectionStrategy,
|
|
4
5
|
Component,
|
|
5
|
-
booleanAttribute,
|
|
6
6
|
computed,
|
|
7
7
|
forwardRef,
|
|
8
8
|
input,
|
|
@@ -39,7 +39,7 @@ export const HLM_CHECKBOX_VALUE_ACCESSOR = {
|
|
|
39
39
|
[aria-label]="ariaLabel()"
|
|
40
40
|
[aria-labelledby]="ariaLabelledby()"
|
|
41
41
|
[aria-describedby]="ariaDescribedby()"
|
|
42
|
-
(
|
|
42
|
+
(checkedChange)="_handleChange()"
|
|
43
43
|
(touched)="_onTouched?.()"
|
|
44
44
|
>
|
|
45
45
|
@if (checked()) {
|
|
@@ -103,8 +103,6 @@ export class HlmCheckbox implements ControlValueAccessor {
|
|
|
103
103
|
disabled: signal(this.disabled()),
|
|
104
104
|
}));
|
|
105
105
|
|
|
106
|
-
public readonly changed = output<boolean>();
|
|
107
|
-
|
|
108
106
|
protected _onChange?: ChangeFn<CheckboxValue>;
|
|
109
107
|
protected _onTouched?: TouchFn;
|
|
110
108
|
|
|
@@ -114,7 +112,6 @@ export class HlmCheckbox implements ControlValueAccessor {
|
|
|
114
112
|
const previousChecked = this.checked();
|
|
115
113
|
this.checked.set(previousChecked === 'indeterminate' ? true : !previousChecked);
|
|
116
114
|
this._onChange?.(!previousChecked);
|
|
117
|
-
this.changed.emit(!previousChecked);
|
|
118
115
|
this.checkedChange.emit(!previousChecked);
|
|
119
116
|
}
|
|
120
117
|
|