@mcp-elements/angular 0.1.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.
Files changed (42) hide show
  1. package/LICENSE +21 -0
  2. package/package.json +22 -0
  3. package/src/accordion.component.ts +74 -0
  4. package/src/ai-badge.component.ts +26 -0
  5. package/src/alert.component.ts +25 -0
  6. package/src/avatar.component.ts +24 -0
  7. package/src/badge.component.ts +17 -0
  8. package/src/button.component.ts +27 -0
  9. package/src/card.component.ts +46 -0
  10. package/src/chat-bubble.component.ts +53 -0
  11. package/src/chips.component.ts +33 -0
  12. package/src/counter.component.ts +48 -0
  13. package/src/dialog.component.ts +42 -0
  14. package/src/drawer.component.ts +48 -0
  15. package/src/dropdown-menu.component.ts +62 -0
  16. package/src/feedback.component.ts +71 -0
  17. package/src/index.ts +86 -0
  18. package/src/input.component.ts +46 -0
  19. package/src/loader.component.ts +12 -0
  20. package/src/mcp/index.ts +9 -0
  21. package/src/mcp/mcp-app-frame.component.ts +60 -0
  22. package/src/mcp/mcp-consent-dialog.component.ts +63 -0
  23. package/src/mcp/mcp-resource-browser.component.ts +86 -0
  24. package/src/mcp/mcp-scope-inspector.component.ts +81 -0
  25. package/src/mcp/mcp-server-status.component.ts +44 -0
  26. package/src/mcp/mcp-tool-call.component.ts +105 -0
  27. package/src/mcp/mcp-tool-form.component.ts +127 -0
  28. package/src/password-input.component.ts +35 -0
  29. package/src/popover.component.ts +40 -0
  30. package/src/progress.component.ts +20 -0
  31. package/src/prompt-input.component.ts +70 -0
  32. package/src/select.component.ts +106 -0
  33. package/src/separator.component.ts +15 -0
  34. package/src/skeleton.component.ts +11 -0
  35. package/src/source-card.component.ts +34 -0
  36. package/src/streaming-text.component.ts +43 -0
  37. package/src/suggestion-chips.component.ts +23 -0
  38. package/src/switch.component.ts +32 -0
  39. package/src/tabs.component.ts +95 -0
  40. package/src/textarea.component.ts +22 -0
  41. package/src/toast.component.ts +62 -0
  42. package/src/tooltip.directive.ts +63 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Mayur Rawte
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/package.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "@mcp-elements/angular",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "main": "./src/index.ts",
6
+ "dependencies": {
7
+ "@mcp-elements/core": "0.1.0"
8
+ },
9
+ "peerDependencies": {
10
+ "@angular/core": "^19.0.0",
11
+ "@angular/common": "^19.0.0"
12
+ },
13
+ "files": [
14
+ "src"
15
+ ],
16
+ "types": "./src/index.ts",
17
+ "scripts": {
18
+ "build": "echo 'Angular components are source-distributed via CLI'",
19
+ "test": "echo 'Angular tests run in example app'",
20
+ "clean": "echo 'nothing to clean'"
21
+ }
22
+ }
@@ -0,0 +1,74 @@
1
+ import { Component, input, signal, computed } from '@angular/core'
2
+ import { createAccordion, type AccordionItemConfig } from '@mcp-elements/core'
3
+
4
+ @Component({
5
+ selector: 'mcpe-accordion',
6
+ standalone: true,
7
+ template: `<div><ng-content /></div>`,
8
+ })
9
+ export class SnxAccordionComponent {
10
+ items = input<AccordionItemConfig[]>([])
11
+ type = input<'single' | 'multiple'>('single')
12
+ collapsible = input(false)
13
+ expandedValues = signal<string[]>([])
14
+
15
+ private api = computed(() =>
16
+ createAccordion(this.items(), {
17
+ type: this.type(),
18
+ collapsible: this.collapsible(),
19
+ onValueChange: (v) => this.expandedValues.set(v),
20
+ })
21
+ )
22
+
23
+ isExpanded(value: string): boolean {
24
+ return this.expandedValues().includes(value)
25
+ }
26
+
27
+ toggle(value: string) {
28
+ const props = this.api().getTriggerProps(value, this.expandedValues())
29
+ props.onClick()
30
+ }
31
+ }
32
+
33
+ @Component({
34
+ selector: 'mcpe-accordion-item',
35
+ standalone: true,
36
+ template: `<div class="mcpe-accordion-item"><ng-content /></div>`,
37
+ })
38
+ export class SnxAccordionItemComponent {}
39
+
40
+ @Component({
41
+ selector: 'mcpe-accordion-trigger',
42
+ standalone: true,
43
+ template: `
44
+ <h3>
45
+ <button
46
+ [class]="'mcpe-accordion-trigger'"
47
+ [attr.aria-expanded]="isExpanded()"
48
+ (click)="onClick.emit()"
49
+ >
50
+ <ng-content />
51
+ <svg class="mcpe-accordion-chevron" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
52
+ <path d="m6 9 6 6 6-6" />
53
+ </svg>
54
+ </button>
55
+ </h3>
56
+ `,
57
+ })
58
+ export class SnxAccordionTriggerComponent {
59
+ isExpanded = input(false)
60
+ onClick = output<void>()
61
+ }
62
+
63
+ @Component({
64
+ selector: 'mcpe-accordion-content',
65
+ standalone: true,
66
+ template: `
67
+ @if (isExpanded()) {
68
+ <div role="region" class="mcpe-accordion-content"><ng-content /></div>
69
+ }
70
+ `,
71
+ })
72
+ export class SnxAccordionContentComponent {
73
+ isExpanded = input(false)
74
+ }
@@ -0,0 +1,26 @@
1
+ import { Component, input, computed } from '@angular/core'
2
+
3
+ type AiBadgeVariant = 'default' | 'prominent' | 'subtle'
4
+
5
+ @Component({
6
+ selector: 'mcpe-ai-badge',
7
+ standalone: true,
8
+ template: `
9
+ <span [class]="classes()">
10
+ @if (showIcon()) {
11
+ <svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
12
+ <path d="M12 3l1.912 5.813a2 2 0 0 0 1.275 1.275L21 12l-5.813 1.912a2 2 0 0 0-1.275 1.275L12 21l-1.912-5.813a2 2 0 0 1-1.275-1.275L3 12l5.813-1.912a2 2 0 0 1 1.275-1.275L12 3z" />
13
+ </svg>
14
+ }
15
+ <ng-content />
16
+ </span>
17
+ `,
18
+ })
19
+ export class SnxAiBadgeComponent {
20
+ variant = input<AiBadgeVariant>('default')
21
+ showIcon = input(true)
22
+ class = input('')
23
+ classes = computed(() =>
24
+ ['mcpe-ai-badge', `mcpe-ai-badge-${this.variant()}`, this.class()].filter(Boolean).join(' ')
25
+ )
26
+ }
@@ -0,0 +1,25 @@
1
+ import { Component, input, computed } from '@angular/core'
2
+
3
+ @Component({
4
+ selector: 'mcpe-alert',
5
+ standalone: true,
6
+ template: `<div [class]="classes()" role="alert"><ng-content /></div>`,
7
+ })
8
+ export class SnxAlertComponent {
9
+ variant = input<'default' | 'destructive' | 'success' | 'warning'>('default')
10
+ classes = computed(() => `mcpe-alert mcpe-alert-${this.variant()}`)
11
+ }
12
+
13
+ @Component({
14
+ selector: 'mcpe-alert-title',
15
+ standalone: true,
16
+ template: `<h5 class="mcpe-alert-title"><ng-content /></h5>`,
17
+ })
18
+ export class SnxAlertTitleComponent {}
19
+
20
+ @Component({
21
+ selector: 'mcpe-alert-description',
22
+ standalone: true,
23
+ template: `<div class="mcpe-alert-description"><ng-content /></div>`,
24
+ })
25
+ export class SnxAlertDescriptionComponent {}
@@ -0,0 +1,24 @@
1
+ import { Component, input, computed, signal } from '@angular/core'
2
+
3
+ @Component({
4
+ selector: 'mcpe-avatar',
5
+ standalone: true,
6
+ template: `
7
+ <div [class]="classes()">
8
+ @if (src() && !hasError()) {
9
+ <img [src]="src()" [alt]="alt()" class="mcpe-avatar-image" (error)="hasError.set(true)" />
10
+ } @else {
11
+ <span class="mcpe-avatar-fallback">{{ fallback() }}</span>
12
+ }
13
+ </div>
14
+ `,
15
+ })
16
+ export class SnxAvatarComponent {
17
+ src = input<string>('')
18
+ alt = input('')
19
+ fallback = input('')
20
+ class = input('')
21
+ hasError = signal(false)
22
+
23
+ classes = computed(() => ['mcpe-avatar', this.class()].filter(Boolean).join(' '))
24
+ }
@@ -0,0 +1,17 @@
1
+ import { Component, computed, input } from '@angular/core'
2
+
3
+ type BadgeVariant = 'default' | 'secondary' | 'outline' | 'destructive'
4
+
5
+ @Component({
6
+ selector: 'mcpe-badge',
7
+ standalone: true,
8
+ template: `<span [class]="classes()"><ng-content /></span>`,
9
+ })
10
+ export class SnxBadgeComponent {
11
+ variant = input<BadgeVariant>('default')
12
+ class = input('')
13
+
14
+ classes = computed(() =>
15
+ ['mcpe-badge', `mcpe-badge-${this.variant()}`, this.class()].filter(Boolean).join(' ')
16
+ )
17
+ }
@@ -0,0 +1,27 @@
1
+ import { Component, computed, input } from '@angular/core'
2
+
3
+ type ButtonVariant = 'primary' | 'secondary' | 'outline' | 'ghost' | 'destructive' | 'link'
4
+ type ButtonSize = 'sm' | 'md' | 'lg' | 'icon'
5
+
6
+ @Component({
7
+ selector: 'mcpe-button',
8
+ standalone: true,
9
+ template: `
10
+ <button [class]="classes()" [disabled]="disabled()" [type]="type()">
11
+ <ng-content />
12
+ </button>
13
+ `,
14
+ })
15
+ export class SnxButtonComponent {
16
+ variant = input<ButtonVariant>('primary')
17
+ size = input<ButtonSize>('md')
18
+ disabled = input(false)
19
+ type = input<'button' | 'submit' | 'reset'>('button')
20
+ class = input('')
21
+
22
+ classes = computed(() =>
23
+ ['mcpe-btn', `mcpe-btn-${this.variant()}`, `mcpe-btn-${this.size()}`, this.class()]
24
+ .filter(Boolean)
25
+ .join(' ')
26
+ )
27
+ }
@@ -0,0 +1,46 @@
1
+ import { Component, input, computed } from '@angular/core'
2
+
3
+ @Component({
4
+ selector: 'mcpe-card',
5
+ standalone: true,
6
+ template: `<div [class]="classes()"><ng-content /></div>`,
7
+ })
8
+ export class SnxCardComponent {
9
+ class = input('')
10
+ classes = computed(() => ['mcpe-card', this.class()].filter(Boolean).join(' '))
11
+ }
12
+
13
+ @Component({
14
+ selector: 'mcpe-card-header',
15
+ standalone: true,
16
+ template: `<div class="mcpe-card-header"><ng-content /></div>`,
17
+ })
18
+ export class SnxCardHeaderComponent {}
19
+
20
+ @Component({
21
+ selector: 'mcpe-card-title',
22
+ standalone: true,
23
+ template: `<h3 class="mcpe-card-title"><ng-content /></h3>`,
24
+ })
25
+ export class SnxCardTitleComponent {}
26
+
27
+ @Component({
28
+ selector: 'mcpe-card-description',
29
+ standalone: true,
30
+ template: `<p class="mcpe-card-description"><ng-content /></p>`,
31
+ })
32
+ export class SnxCardDescriptionComponent {}
33
+
34
+ @Component({
35
+ selector: 'mcpe-card-content',
36
+ standalone: true,
37
+ template: `<div class="mcpe-card-content"><ng-content /></div>`,
38
+ })
39
+ export class SnxCardContentComponent {}
40
+
41
+ @Component({
42
+ selector: 'mcpe-card-footer',
43
+ standalone: true,
44
+ template: `<div class="mcpe-card-footer"><ng-content /></div>`,
45
+ })
46
+ export class SnxCardFooterComponent {}
@@ -0,0 +1,53 @@
1
+ import { Component, input, computed } from '@angular/core'
2
+
3
+ type ChatBubbleVariant = 'user' | 'ai'
4
+
5
+ @Component({
6
+ selector: 'mcpe-chat-bubble',
7
+ standalone: true,
8
+ template: `<div [class]="classes()"><ng-content /></div>`,
9
+ })
10
+ export class SnxChatBubbleComponent {
11
+ variant = input<ChatBubbleVariant>('ai')
12
+ class = input('')
13
+ classes = computed(() =>
14
+ ['mcpe-chat-bubble', `mcpe-chat-bubble-${this.variant()}`, this.class()].filter(Boolean).join(' ')
15
+ )
16
+ }
17
+
18
+ @Component({
19
+ selector: 'mcpe-chat-bubble-avatar',
20
+ standalone: true,
21
+ template: `<img class="mcpe-chat-bubble-avatar" [src]="src()" [alt]="alt()" />`,
22
+ })
23
+ export class SnxChatBubbleAvatarComponent {
24
+ src = input.required<string>()
25
+ alt = input('')
26
+ }
27
+
28
+ @Component({
29
+ selector: 'mcpe-chat-bubble-content',
30
+ standalone: true,
31
+ template: `<div class="mcpe-chat-bubble-content"><ng-content /></div>`,
32
+ })
33
+ export class SnxChatBubbleContentComponent {}
34
+
35
+ @Component({
36
+ selector: 'mcpe-chat-bubble-timestamp',
37
+ standalone: true,
38
+ template: `<span class="mcpe-chat-bubble-timestamp"><ng-content /></span>`,
39
+ })
40
+ export class SnxChatBubbleTimestampComponent {}
41
+
42
+ @Component({
43
+ selector: 'mcpe-chat-bubble-typing',
44
+ standalone: true,
45
+ template: `
46
+ <div class="mcpe-chat-bubble-typing">
47
+ <span class="mcpe-chat-bubble-typing-dot"></span>
48
+ <span class="mcpe-chat-bubble-typing-dot"></span>
49
+ <span class="mcpe-chat-bubble-typing-dot"></span>
50
+ </div>
51
+ `,
52
+ })
53
+ export class SnxChatBubbleTypingComponent {}
@@ -0,0 +1,33 @@
1
+ import { Component, input, output, computed } from '@angular/core'
2
+
3
+ @Component({
4
+ selector: 'mcpe-chip',
5
+ standalone: true,
6
+ template: `
7
+ <span [class]="classes()">
8
+ <ng-content />
9
+ @if (removable()) {
10
+ <button type="button" class="mcpe-chip-remove" (click)="remove.emit()" aria-label="Remove">
11
+ <svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
12
+ <path d="M18 6 6 18" /><path d="m6 6 12 12" />
13
+ </svg>
14
+ </button>
15
+ }
16
+ </span>
17
+ `,
18
+ })
19
+ export class SnxChipComponent {
20
+ variant = input<'default' | 'primary' | 'outline' | 'destructive'>('default')
21
+ removable = input(false)
22
+ remove = output<void>()
23
+ classes = computed(() =>
24
+ ['mcpe-chip', `mcpe-chip-${this.variant()}`, this.removable() ? 'mcpe-chip-removable' : ''].filter(Boolean).join(' ')
25
+ )
26
+ }
27
+
28
+ @Component({
29
+ selector: 'mcpe-chips',
30
+ standalone: true,
31
+ template: `<div class="mcpe-chips"><ng-content /></div>`,
32
+ })
33
+ export class SnxChipsComponent {}
@@ -0,0 +1,48 @@
1
+ import { Component, input, output, signal } from '@angular/core'
2
+
3
+ @Component({
4
+ selector: 'mcpe-counter',
5
+ standalone: true,
6
+ template: `
7
+ <div class="mcpe-counter">
8
+ <button type="button" class="mcpe-counter-button" (click)="decrement()"
9
+ [disabled]="disabled() || value() <= min()" aria-label="Decrease">
10
+ <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
11
+ <path d="M5 12h14" />
12
+ </svg>
13
+ </button>
14
+ <input type="text" inputmode="numeric" class="mcpe-counter-input"
15
+ [value]="value()" (change)="onInput($event)" [disabled]="disabled()" aria-label="Count" />
16
+ <button type="button" class="mcpe-counter-button" (click)="increment()"
17
+ [disabled]="disabled() || value() >= max()" aria-label="Increase">
18
+ <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
19
+ <path d="M5 12h14" /><path d="M12 5v14" />
20
+ </svg>
21
+ </button>
22
+ </div>
23
+ `,
24
+ })
25
+ export class SnxCounterComponent {
26
+ value = signal(0)
27
+ min = input(0)
28
+ max = input(99)
29
+ step = input(1)
30
+ disabled = input(false)
31
+ valueChange = output<number>()
32
+
33
+ decrement() {
34
+ this.value.update(v => Math.max(this.min(), v - this.step()))
35
+ this.valueChange.emit(this.value())
36
+ }
37
+ increment() {
38
+ this.value.update(v => Math.min(this.max(), v + this.step()))
39
+ this.valueChange.emit(this.value())
40
+ }
41
+ onInput(event: Event) {
42
+ const num = parseInt((event.target as HTMLInputElement).value, 10)
43
+ if (!isNaN(num)) {
44
+ this.value.set(Math.max(this.min(), Math.min(this.max(), num)))
45
+ this.valueChange.emit(this.value())
46
+ }
47
+ }
48
+ }
@@ -0,0 +1,42 @@
1
+ import { Component, input, output, signal, computed, effect, ElementRef, viewChild } from '@angular/core'
2
+ import { createDialog } from '@mcp-elements/core'
3
+
4
+ @Component({
5
+ selector: 'mcpe-dialog',
6
+ standalone: true,
7
+ template: `
8
+ @if (open()) {
9
+ <div class="mcpe-dialog-overlay" (click)="close()"></div>
10
+ <div
11
+ #content
12
+ class="mcpe-dialog-content"
13
+ role="dialog"
14
+ [attr.aria-modal]="modal()"
15
+ (keydown.escape)="close()"
16
+ >
17
+ <ng-content />
18
+ <button class="mcpe-dialog-close" (click)="close()" aria-label="Close">&#x2715;</button>
19
+ </div>
20
+ }
21
+ `,
22
+ })
23
+ export class SnxDialogComponent {
24
+ modal = input(true)
25
+ open = signal(false)
26
+ openChange = output<boolean>()
27
+
28
+ toggle() {
29
+ this.open.update(v => !v)
30
+ this.openChange.emit(this.open())
31
+ }
32
+
33
+ close() {
34
+ this.open.set(false)
35
+ this.openChange.emit(false)
36
+ }
37
+
38
+ show() {
39
+ this.open.set(true)
40
+ this.openChange.emit(true)
41
+ }
42
+ }
@@ -0,0 +1,48 @@
1
+ import { Component, input, output, signal } from '@angular/core'
2
+
3
+ @Component({
4
+ selector: 'mcpe-drawer',
5
+ standalone: true,
6
+ template: `
7
+ @if (open()) {
8
+ <div class="mcpe-drawer-overlay" (click)="close()"></div>
9
+ <div
10
+ [class]="'mcpe-drawer-content mcpe-drawer-content-' + side()"
11
+ role="dialog"
12
+ aria-modal="true"
13
+ (keydown.escape)="close()"
14
+ >
15
+ <ng-content />
16
+ <button class="mcpe-drawer-close" (click)="close()" aria-label="Close">
17
+ <svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
18
+ <path d="M18 6 6 18" /><path d="m6 6 12 12" />
19
+ </svg>
20
+ </button>
21
+ </div>
22
+ }
23
+ `,
24
+ })
25
+ export class SnxDrawerComponent {
26
+ side = input<'left' | 'right' | 'top' | 'bottom'>('right')
27
+ open = signal(false)
28
+ openChange = output<boolean>()
29
+
30
+ show() { this.open.set(true); this.openChange.emit(true) }
31
+ close() { this.open.set(false); this.openChange.emit(false) }
32
+ toggle() { this.open.update(v => !v); this.openChange.emit(this.open()) }
33
+ }
34
+
35
+ @Component({ selector: 'mcpe-drawer-header', standalone: true, template: `<div class="mcpe-drawer-header"><ng-content /></div>` })
36
+ export class SnxDrawerHeaderComponent {}
37
+
38
+ @Component({ selector: 'mcpe-drawer-footer', standalone: true, template: `<div class="mcpe-drawer-footer"><ng-content /></div>` })
39
+ export class SnxDrawerFooterComponent {}
40
+
41
+ @Component({ selector: 'mcpe-drawer-title', standalone: true, template: `<h2 class="mcpe-drawer-title"><ng-content /></h2>` })
42
+ export class SnxDrawerTitleComponent {}
43
+
44
+ @Component({ selector: 'mcpe-drawer-description', standalone: true, template: `<p class="mcpe-drawer-description"><ng-content /></p>` })
45
+ export class SnxDrawerDescriptionComponent {}
46
+
47
+ @Component({ selector: 'mcpe-drawer-body', standalone: true, template: `<div class="mcpe-drawer-body"><ng-content /></div>` })
48
+ export class SnxDrawerBodyComponent {}
@@ -0,0 +1,62 @@
1
+ import { Component, input, signal, ElementRef, viewChild } from '@angular/core'
2
+
3
+ export interface DropdownItem {
4
+ id: string
5
+ label: string
6
+ disabled?: boolean
7
+ type?: 'item' | 'separator' | 'label'
8
+ shortcut?: string
9
+ }
10
+
11
+ @Component({
12
+ selector: 'mcpe-dropdown-menu',
13
+ standalone: true,
14
+ template: `
15
+ <div class="relative inline-block" #container>
16
+ <div (click)="toggle()">
17
+ <ng-content select="[trigger]" />
18
+ </div>
19
+ @if (isOpen()) {
20
+ <div class="mcpe-dropdown-menu-content absolute top-full mt-1 right-0" role="menu">
21
+ @for (item of items(); track item.id) {
22
+ @if (item.type === 'separator') {
23
+ <div class="mcpe-dropdown-menu-separator" role="separator"></div>
24
+ } @else if (item.type === 'label') {
25
+ <div class="mcpe-dropdown-menu-label">{{ item.label }}</div>
26
+ } @else {
27
+ <div
28
+ role="menuitem"
29
+ [class]="'mcpe-dropdown-menu-item' + (item.disabled ? ' opacity-50 pointer-events-none' : '')"
30
+ (click)="selectItem(item)"
31
+ [attr.aria-disabled]="item.disabled"
32
+ >
33
+ <span class="flex-1">{{ item.label }}</span>
34
+ @if (item.shortcut) {
35
+ <span class="mcpe-dropdown-menu-shortcut">{{ item.shortcut }}</span>
36
+ }
37
+ </div>
38
+ }
39
+ }
40
+ </div>
41
+ }
42
+ </div>
43
+ `,
44
+ host: { '(document:click)': 'onDocumentClick($event)' },
45
+ })
46
+ export class SnxDropdownMenuComponent {
47
+ items = input<DropdownItem[]>([])
48
+ isOpen = signal(false)
49
+ container = viewChild<ElementRef>('container')
50
+
51
+ toggle() { this.isOpen.update(v => !v) }
52
+ close() { this.isOpen.set(false) }
53
+
54
+ selectItem(item: DropdownItem) {
55
+ if (!item.disabled) this.isOpen.set(false)
56
+ }
57
+
58
+ onDocumentClick(event: MouseEvent) {
59
+ const el = this.container()?.nativeElement
60
+ if (el && !el.contains(event.target as Node)) this.isOpen.set(false)
61
+ }
62
+ }
@@ -0,0 +1,71 @@
1
+ import { Component, input, computed } from '@angular/core'
2
+
3
+ @Component({
4
+ selector: 'mcpe-feedback',
5
+ standalone: true,
6
+ template: `<div class="mcpe-feedback"><ng-content /></div>`,
7
+ })
8
+ export class SnxFeedbackComponent {}
9
+
10
+ type FeedbackType = 'up' | 'down'
11
+
12
+ @Component({
13
+ selector: 'mcpe-feedback-btn',
14
+ standalone: true,
15
+ template: `
16
+ <button [class]="classes()" type="button">
17
+ @if (feedbackType() === 'up') {
18
+ <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
19
+ <path d="M7 10v12"/><path d="M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z"/>
20
+ </svg>
21
+ } @else {
22
+ <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
23
+ <path d="M17 14V2"/><path d="M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z"/>
24
+ </svg>
25
+ }
26
+ </button>
27
+ `,
28
+ })
29
+ export class SnxFeedbackButtonComponent {
30
+ feedbackType = input.required<FeedbackType>({ alias: 'type' })
31
+ selected = input(false)
32
+ class = input('')
33
+ classes = computed(() =>
34
+ [
35
+ 'mcpe-feedback-btn',
36
+ `mcpe-feedback-btn-${this.feedbackType()}`,
37
+ this.selected() ? 'mcpe-feedback-btn-selected' : '',
38
+ this.class(),
39
+ ].filter(Boolean).join(' ')
40
+ )
41
+ }
42
+
43
+ @Component({
44
+ selector: 'mcpe-feedback-separator',
45
+ standalone: true,
46
+ template: `<span class="mcpe-feedback-separator"></span>`,
47
+ })
48
+ export class SnxFeedbackSeparatorComponent {}
49
+
50
+ @Component({
51
+ selector: 'mcpe-feedback-form',
52
+ standalone: true,
53
+ template: `<div class="mcpe-feedback-form"><ng-content /></div>`,
54
+ })
55
+ export class SnxFeedbackFormComponent {}
56
+
57
+ @Component({
58
+ selector: 'mcpe-feedback-input',
59
+ standalone: true,
60
+ template: `<input class="mcpe-feedback-input" [placeholder]="placeholder()" />`,
61
+ })
62
+ export class SnxFeedbackInputComponent {
63
+ placeholder = input('Add a comment...')
64
+ }
65
+
66
+ @Component({
67
+ selector: 'mcpe-feedback-submit',
68
+ standalone: true,
69
+ template: `<button class="mcpe-feedback-submit" type="button"><ng-content /></button>`,
70
+ })
71
+ export class SnxFeedbackSubmitComponent {}