semmet-angular 0.1.0 → 0.2.0
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/package.json +1 -1
- package/src/accordion/files/__name@dasherize__/__name@dasherize__.html.template +1 -1
- package/src/accordion/files/__name@dasherize__/__name@dasherize__.ts.template +6 -6
- package/src/dialog/files/__name@dasherize__/__name@dasherize__.html.template +1 -1
- package/src/dialog/files/__name@dasherize__/__name@dasherize__.ts.template +3 -3
- package/src/disclosure/files/__name@dasherize__/__name@dasherize__.ts.template +1 -1
- package/src/tabs/files/__name@dasherize__/__name@dasherize__.html.template +1 -1
- package/src/tabs/files/__name@dasherize__/__name@dasherize__.ts.template +6 -6
- package/src/tooltip/files/__name@dasherize__/__name@dasherize__.html.template +1 -1
- package/src/tooltip/files/__name@dasherize__/__name@dasherize__.ts.template +3 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "semmet-angular",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Angular schematics that generate real, ARIA-conformant standalone components (Accordion, Tabs, Dialog, Disclosure, Tooltip...) with signals-based state and keyboard interaction built in.",
|
|
5
5
|
"publisher": "danilodevsilva",
|
|
6
6
|
"license": "MIT",
|
|
@@ -15,21 +15,21 @@ let nextId = 0;
|
|
|
15
15
|
styleUrl: './<%= dasherize(name) %>.css',
|
|
16
16
|
})
|
|
17
17
|
export class <%= classify(name) %> {
|
|
18
|
-
|
|
18
|
+
private readonly headerButtons = viewChildren<ElementRef<HTMLButtonElement>>('headerButton');
|
|
19
19
|
|
|
20
|
-
readonly
|
|
20
|
+
protected readonly instanceId = `<%= dasherize(name) %>-${nextId++}`;
|
|
21
|
+
protected readonly items: <%= classify(name) %>Item[] = [
|
|
21
22
|
{ id: 1, title: 'First section title', content: 'First panel content' },
|
|
22
23
|
{ id: 2, title: 'Second section title', content: 'Second panel content' },
|
|
23
24
|
];
|
|
24
25
|
|
|
25
26
|
private readonly expandedIds = signal<ReadonlySet<number>>(new Set([1]));
|
|
26
|
-
private readonly headerButtons = viewChildren<ElementRef<HTMLButtonElement>>('headerButton');
|
|
27
27
|
|
|
28
|
-
isExpanded(id: number): boolean {
|
|
28
|
+
protected isExpanded(id: number): boolean {
|
|
29
29
|
return this.expandedIds().has(id);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
toggle(id: number): void {
|
|
32
|
+
protected toggle(id: number): void {
|
|
33
33
|
const next = new Set(this.expandedIds());
|
|
34
34
|
if (next.has(id)) {
|
|
35
35
|
next.delete(id);
|
|
@@ -40,7 +40,7 @@ export class <%= classify(name) %> {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
// Up/Down/Home/End move focus between headers — optional but APG-recommended keyboard support.
|
|
43
|
-
|
|
43
|
+
protected navigateHeaders(event: KeyboardEvent, index: number): void {
|
|
44
44
|
const buttons = this.headerButtons();
|
|
45
45
|
if (buttons.length === 0) {
|
|
46
46
|
return;
|
|
@@ -19,19 +19,19 @@ export class <%= classify(name) %> {
|
|
|
19
19
|
protected readonly instanceId = `<%= dasherize(name) %>-${nextId++}`;
|
|
20
20
|
protected readonly isOpen = signal(false);
|
|
21
21
|
|
|
22
|
-
open(event: MouseEvent): void {
|
|
22
|
+
protected open(event: MouseEvent): void {
|
|
23
23
|
this.triggerElement = event.currentTarget as HTMLElement;
|
|
24
24
|
this.isOpen.set(true);
|
|
25
25
|
// Focus moves into the dialog only after Angular flushes the DOM update that un-hides it.
|
|
26
26
|
afterNextRender(() => this.focusFirstElement(), { injector: this.injector });
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
close(): void {
|
|
29
|
+
protected close(): void {
|
|
30
30
|
this.isOpen.set(false);
|
|
31
31
|
this.triggerElement?.focus();
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
protected handleDialogKeydown(event: KeyboardEvent): void {
|
|
35
35
|
if (event.key === 'Escape') {
|
|
36
36
|
this.close();
|
|
37
37
|
return;
|
|
@@ -12,7 +12,7 @@ export class <%= classify(name) %> {
|
|
|
12
12
|
protected readonly instanceId = `<%= dasherize(name) %>-${nextId++}`;
|
|
13
13
|
protected readonly expanded = signal(false);
|
|
14
14
|
|
|
15
|
-
toggle(): void {
|
|
15
|
+
protected toggle(): void {
|
|
16
16
|
this.expanded.update((value) => !value);
|
|
17
17
|
}
|
|
18
18
|
}
|
|
@@ -15,26 +15,26 @@ let nextId = 0;
|
|
|
15
15
|
styleUrl: './<%= dasherize(name) %>.css',
|
|
16
16
|
})
|
|
17
17
|
export class <%= classify(name) %> {
|
|
18
|
-
|
|
18
|
+
private readonly tabButtons = viewChildren<ElementRef<HTMLButtonElement>>('tabButton');
|
|
19
19
|
|
|
20
|
-
readonly
|
|
20
|
+
protected readonly instanceId = `<%= dasherize(name) %>-${nextId++}`;
|
|
21
|
+
protected readonly items: <%= classify(name) %>Item[] = [
|
|
21
22
|
{ id: 1, label: 'First tab', content: 'First panel content' },
|
|
22
23
|
{ id: 2, label: 'Second tab', content: 'Second panel content' },
|
|
23
24
|
];
|
|
24
25
|
|
|
25
26
|
private readonly activeId = signal(this.items[0].id);
|
|
26
|
-
private readonly tabButtons = viewChildren<ElementRef<HTMLButtonElement>>('tabButton');
|
|
27
27
|
|
|
28
|
-
isActive(id: number): boolean {
|
|
28
|
+
protected isActive(id: number): boolean {
|
|
29
29
|
return this.activeId() === id;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
select(id: number): void {
|
|
32
|
+
protected select(id: number): void {
|
|
33
33
|
this.activeId.set(id);
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
// Left/Right/Home/End move focus AND selection (automatic activation model, per APG tabs pattern).
|
|
37
|
-
|
|
37
|
+
protected navigateTabs(event: KeyboardEvent, index: number): void {
|
|
38
38
|
const buttons = this.tabButtons();
|
|
39
39
|
if (buttons.length === 0) {
|
|
40
40
|
return;
|
|
@@ -12,15 +12,15 @@ export class <%= classify(name) %> {
|
|
|
12
12
|
protected readonly instanceId = `<%= dasherize(name) %>-${nextId++}`;
|
|
13
13
|
protected readonly visible = signal(false);
|
|
14
14
|
|
|
15
|
-
show(): void {
|
|
15
|
+
protected show(): void {
|
|
16
16
|
this.visible.set(true);
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
hide(): void {
|
|
19
|
+
protected hide(): void {
|
|
20
20
|
this.visible.set(false);
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
protected closeOnEscape(event: KeyboardEvent): void {
|
|
24
24
|
if (event.key === 'Escape') {
|
|
25
25
|
this.hide();
|
|
26
26
|
}
|