@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
@@ -0,0 +1,62 @@
1
+ import { Component, Injectable, signal } from '@angular/core'
2
+
3
+ export interface ToastData {
4
+ id: string
5
+ title?: string
6
+ description?: string
7
+ variant?: 'default' | 'destructive' | 'success'
8
+ }
9
+
10
+ @Injectable({ providedIn: 'root' })
11
+ export class SnxToastService {
12
+ toasts = signal<ToastData[]>([])
13
+ private counter = 0
14
+
15
+ show(toast: Omit<ToastData, 'id'>, duration = 5000): string {
16
+ const id = `toast-${++this.counter}`
17
+ this.toasts.update(t => [...t, { id, ...toast }])
18
+ if (duration > 0) {
19
+ setTimeout(() => this.dismiss(id), duration)
20
+ }
21
+ return id
22
+ }
23
+
24
+ success(title: string, description?: string) {
25
+ return this.show({ title, description, variant: 'success' })
26
+ }
27
+
28
+ error(title: string, description?: string) {
29
+ return this.show({ title, description, variant: 'destructive' })
30
+ }
31
+
32
+ dismiss(id: string) {
33
+ this.toasts.update(t => t.filter(x => x.id !== id))
34
+ }
35
+ }
36
+
37
+ @Component({
38
+ selector: 'mcpe-toaster',
39
+ standalone: true,
40
+ template: `
41
+ <div class="mcpe-toaster mcpe-toaster-bottom-right">
42
+ @for (t of toastService.toasts(); track t.id) {
43
+ <div
44
+ [class]="'mcpe-toast group' + (t.variant === 'destructive' ? ' mcpe-toast-destructive' : '') + (t.variant === 'success' ? ' mcpe-toast-success' : '')"
45
+ >
46
+ <div class="flex-1">
47
+ @if (t.title) { <div class="mcpe-toast-title">{{ t.title }}</div> }
48
+ @if (t.description) { <div class="mcpe-toast-description">{{ t.description }}</div> }
49
+ </div>
50
+ <button class="mcpe-toast-close" (click)="toastService.dismiss(t.id)" aria-label="Close">
51
+ <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">
52
+ <path d="M18 6 6 18" /><path d="m6 6 12 12" />
53
+ </svg>
54
+ </button>
55
+ </div>
56
+ }
57
+ </div>
58
+ `,
59
+ })
60
+ export class SnxToasterComponent {
61
+ constructor(public toastService: SnxToastService) {}
62
+ }
@@ -0,0 +1,63 @@
1
+ import { Directive, input, HostListener, ElementRef, Renderer2, OnDestroy } from '@angular/core'
2
+
3
+ @Directive({
4
+ selector: '[mcpeTooltip]',
5
+ standalone: true,
6
+ })
7
+ export class SnxTooltipDirective implements OnDestroy {
8
+ mcpeTooltip = input<string>('')
9
+ tooltipDelay = input(700)
10
+
11
+ private tooltipEl: HTMLElement | null = null
12
+ private timeoutId: ReturnType<typeof setTimeout> | null = null
13
+
14
+ constructor(private el: ElementRef, private renderer: Renderer2) {}
15
+
16
+ @HostListener('mouseenter')
17
+ @HostListener('focus')
18
+ onShow() {
19
+ this.clearDelay()
20
+ this.timeoutId = setTimeout(() => this.show(), this.tooltipDelay())
21
+ }
22
+
23
+ @HostListener('mouseleave')
24
+ @HostListener('blur')
25
+ onHide() {
26
+ this.clearDelay()
27
+ this.hide()
28
+ }
29
+
30
+ private show() {
31
+ if (this.tooltipEl) return
32
+ this.tooltipEl = this.renderer.createElement('div')
33
+ this.renderer.addClass(this.tooltipEl, 'mcpe-tooltip-content')
34
+ this.renderer.setStyle(this.tooltipEl, 'position', 'absolute')
35
+ this.renderer.setStyle(this.tooltipEl, 'bottom', '100%')
36
+ this.renderer.setStyle(this.tooltipEl, 'left', '50%')
37
+ this.renderer.setStyle(this.tooltipEl, 'transform', 'translateX(-50%)')
38
+ this.renderer.setStyle(this.tooltipEl, 'margin-bottom', '0.5rem')
39
+ const text = this.renderer.createText(this.mcpeTooltip())
40
+ this.renderer.appendChild(this.tooltipEl, text)
41
+ this.renderer.setStyle(this.el.nativeElement, 'position', 'relative')
42
+ this.renderer.appendChild(this.el.nativeElement, this.tooltipEl)
43
+ }
44
+
45
+ private hide() {
46
+ if (this.tooltipEl) {
47
+ this.renderer.removeChild(this.el.nativeElement, this.tooltipEl)
48
+ this.tooltipEl = null
49
+ }
50
+ }
51
+
52
+ private clearDelay() {
53
+ if (this.timeoutId !== null) {
54
+ clearTimeout(this.timeoutId)
55
+ this.timeoutId = null
56
+ }
57
+ }
58
+
59
+ ngOnDestroy() {
60
+ this.clearDelay()
61
+ this.hide()
62
+ }
63
+ }