semmet-angular 0.14.0 → 0.16.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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "semmet-angular",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.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",
|
|
@@ -4,6 +4,7 @@ Usage from a parent component template:
|
|
|
4
4
|
Import <%= classify(name) %> in that parent component.
|
|
5
5
|
|
|
6
6
|
<<%= selector %> label="View options" />
|
|
7
|
+
<<%= selector %> label="View options" [items]="views" [(selectedIds)]="selectedViewIds" />
|
|
7
8
|
<<%= selector %> [items]="views">
|
|
8
9
|
<ng-template <%= camelize(name) %>Item let-item let-pressed="pressed">
|
|
9
10
|
{{ item.label }}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NgTemplateOutlet } from '@angular/common';
|
|
2
|
-
import { Component, Directive, TemplateRef, booleanAttribute, computed, contentChild, inject, input,
|
|
2
|
+
import { Component, Directive, TemplateRef, booleanAttribute, computed, contentChild, inject, input, model } from '@angular/core';
|
|
3
3
|
|
|
4
4
|
type <%= classify(name) %>Orientation = 'horizontal' | 'vertical';
|
|
5
5
|
type <%= classify(name) %>SelectionMode = 'none' | 'single' | 'multiple';
|
|
@@ -17,6 +17,7 @@ const DEFAULT_ITEMS: readonly <%= classify(name) %>Item[] = [
|
|
|
17
17
|
{ id: 'week', label: 'Week' },
|
|
18
18
|
{ id: 'month', label: 'Month' },
|
|
19
19
|
];
|
|
20
|
+
const DEFAULT_SELECTED_IDS = DEFAULT_ITEMS.filter((item) => item.pressed).map((item) => item.id);
|
|
20
21
|
|
|
21
22
|
let nextId = 0;
|
|
22
23
|
|
|
@@ -43,10 +44,9 @@ export class <%= classify(name) %> {
|
|
|
43
44
|
readonly size = input<<%= classify(name) %>Size>('md');
|
|
44
45
|
readonly disabled = input(false, { transform: booleanAttribute });
|
|
45
46
|
readonly items = input<readonly <%= classify(name) %>Item[]>(DEFAULT_ITEMS);
|
|
47
|
+
readonly selectedIds = model<readonly string[]>(DEFAULT_SELECTED_IDS);
|
|
46
48
|
|
|
47
|
-
protected readonly
|
|
48
|
-
new Set(DEFAULT_ITEMS.filter((item) => item.pressed).map((item) => item.id)),
|
|
49
|
-
);
|
|
49
|
+
protected readonly selectedIdSet = computed<ReadonlySet<string>>(() => new Set(this.selectedIds()));
|
|
50
50
|
|
|
51
51
|
protected readonly groupClasses = computed(() => [
|
|
52
52
|
'semmet-button-group',
|
|
@@ -59,7 +59,7 @@ export class <%= classify(name) %> {
|
|
|
59
59
|
return item.pressed ?? null;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
return this.
|
|
62
|
+
return this.selectedIdSet().has(item.id);
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
protected ariaPressed(item: <%= classify(name) %>Item): string | null {
|
|
@@ -77,7 +77,7 @@ export class <%= classify(name) %> {
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
if (this.selectionMode() === 'single') {
|
|
80
|
-
this.selectedIds.set(
|
|
80
|
+
this.selectedIds.set([item.id]);
|
|
81
81
|
return;
|
|
82
82
|
}
|
|
83
83
|
|
|
@@ -88,7 +88,7 @@ export class <%= classify(name) %> {
|
|
|
88
88
|
} else {
|
|
89
89
|
next.add(item.id);
|
|
90
90
|
}
|
|
91
|
-
return next;
|
|
91
|
+
return Array.from(next);
|
|
92
92
|
});
|
|
93
93
|
}
|
|
94
94
|
}
|