@spartan-ng/cli 0.0.1-alpha.326 → 0.0.1-alpha.327

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 (69) hide show
  1. package/package.json +1 -1
  2. package/src/generators/ui/libs/ui-accordion-helm/files/index.ts.template +3 -3
  3. package/src/generators/ui/libs/ui-accordion-helm/files/lib/hlm-accordion-content.directive.ts.template +12 -67
  4. package/src/generators/ui/libs/ui-accordion-helm/files/lib/hlm-accordion-icon.directive.ts.template +31 -0
  5. package/src/generators/ui/libs/ui-accordion-helm/files/lib/hlm-accordion-item.directive.ts.template +7 -6
  6. package/src/generators/ui/libs/ui-accordion-helm/files/lib/hlm-accordion-trigger.directive.ts.template +12 -23
  7. package/src/generators/ui/libs/ui-accordion-helm/files/lib/hlm-accordion.directive.ts.template +10 -7
  8. package/src/generators/ui/libs/ui-alert-dialog-helm/files/index.ts.template +6 -6
  9. package/src/generators/ui/libs/ui-alert-dialog-helm/files/lib/hlm-alert-dialog-cancel-button.directive.ts.template +3 -6
  10. package/src/generators/ui/libs/ui-alert-dialog-helm/files/lib/{hlm-alert-dialog-content.directive.ts.template → hlm-alert-dialog-content.component.ts.template} +19 -20
  11. package/src/generators/ui/libs/ui-alert-dialog-helm/files/lib/hlm-alert-dialog-description.directive.ts.template +5 -6
  12. package/src/generators/ui/libs/ui-alert-dialog-helm/files/lib/hlm-alert-dialog-footer.component.ts.template +6 -6
  13. package/src/generators/ui/libs/ui-alert-dialog-helm/files/lib/hlm-alert-dialog-header.component.ts.template +6 -6
  14. package/src/generators/ui/libs/ui-alert-dialog-helm/files/lib/hlm-alert-dialog-overlay.directive.ts.template +10 -16
  15. package/src/generators/ui/libs/ui-alert-dialog-helm/files/lib/hlm-alert-dialog-title.directive.ts.template +4 -6
  16. package/src/generators/ui/libs/ui-alert-dialog-helm/files/lib/hlm-alert-dialog.component.ts.template +30 -0
  17. package/src/generators/ui/libs/ui-alert-helm/files/lib/hlm-alert-description.directive.ts.template +3 -3
  18. package/src/generators/ui/libs/ui-alert-helm/files/lib/hlm-alert-title.directive.ts.template +3 -3
  19. package/src/generators/ui/libs/ui-alert-helm/files/lib/hlm-alert.directive.ts.template +3 -3
  20. package/src/generators/ui/libs/ui-aspect-ratio-helm/files/lib/helm-aspect-ratio.directive.ts.template +7 -9
  21. package/src/generators/ui/libs/ui-avatar-helm/files/lib/hlm-avatar.component.ts.template +11 -14
  22. package/src/generators/ui/libs/ui-badge-helm/files/lib/hlm-badge.directive.ts.template +3 -3
  23. package/src/generators/ui/libs/ui-button-helm/files/lib/hlm-button.directive.ts.template +3 -3
  24. package/src/generators/ui/libs/ui-card-helm/files/lib/hlm-card-content.directive.ts.template +3 -3
  25. package/src/generators/ui/libs/ui-card-helm/files/lib/hlm-card-description.directive.ts.template +3 -3
  26. package/src/generators/ui/libs/ui-card-helm/files/lib/hlm-card-footer.directive.ts.template +3 -3
  27. package/src/generators/ui/libs/ui-card-helm/files/lib/hlm-card-header.directive.ts.template +3 -3
  28. package/src/generators/ui/libs/ui-card-helm/files/lib/hlm-card-title.directive.ts.template +3 -3
  29. package/src/generators/ui/libs/ui-card-helm/files/lib/hlm-card.directive.ts.template +3 -3
  30. package/src/generators/ui/libs/ui-checkbox-helm/files/index.ts.template +14 -0
  31. package/src/generators/ui/libs/ui-checkbox-helm/files/lib/hlm-checkbox-checkicon.component.ts.template +37 -0
  32. package/src/generators/ui/libs/ui-checkbox-helm/files/lib/hlm-checkbox.directive.ts.template +30 -0
  33. package/src/generators/ui/libs/ui-checkbox-helm/generator.d.ts +3 -0
  34. package/src/generators/ui/libs/ui-checkbox-helm/generator.js +12 -0
  35. package/src/generators/ui/libs/ui-checkbox-helm/generator.js.map +1 -0
  36. package/src/generators/ui/libs/ui-dialog-helm/files/index.ts.template +6 -3
  37. package/src/generators/ui/libs/ui-dialog-helm/files/lib/hlm-dialog-content.component.ts.template +44 -0
  38. package/src/generators/ui/libs/ui-dialog-helm/files/lib/hlm-dialog-overlay.directive.ts.template +10 -16
  39. package/src/generators/ui/libs/ui-dialog-helm/files/lib/hlm-dialog.component.ts.template +29 -0
  40. package/src/generators/ui/libs/ui-icon-helm/files/lib/hlm-icon.component.ts.template +50 -5
  41. package/src/generators/ui/libs/ui-input-helm/files/lib/hlm-input-error.directive.ts.template +3 -3
  42. package/src/generators/ui/libs/ui-input-helm/files/lib/hlm-input.directive.ts.template +3 -3
  43. package/src/generators/ui/libs/ui-label-helm/files/lib/hlm-label.directive.ts.template +37 -8
  44. package/src/generators/ui/libs/ui-menu-helm/files/index.ts.template +18 -9
  45. package/src/generators/ui/libs/ui-menu-helm/files/lib/hlm-menu-bar-item.directive.ts.template +3 -1
  46. package/src/generators/ui/libs/ui-menu-helm/files/lib/{hlm-menu-bar.directive.ts.template → hlm-menu-bar.component.ts.template} +7 -4
  47. package/src/generators/ui/libs/ui-menu-helm/files/lib/hlm-menu-group.component.ts.template +15 -0
  48. package/src/generators/ui/libs/ui-menu-helm/files/lib/hlm-menu-item-check.component.ts.template +1 -1
  49. package/src/generators/ui/libs/ui-menu-helm/files/lib/hlm-menu-item-checkbox.directive.ts.template +41 -0
  50. package/src/generators/ui/libs/ui-menu-helm/files/lib/hlm-menu-item-radio.component.ts.template +1 -1
  51. package/src/generators/ui/libs/ui-menu-helm/files/lib/hlm-menu-item-radio.directive.ts.template +41 -0
  52. package/src/generators/ui/libs/ui-menu-helm/files/lib/hlm-menu-item.directive.ts.template +24 -7
  53. package/src/generators/ui/libs/ui-menu-helm/files/lib/{hlm-menu.directive.ts.template → hlm-menu.component.ts.template} +11 -6
  54. package/src/generators/ui/libs/ui-menu-helm/files/lib/{hlm-sub-menu.directive.ts.template → hlm-sub-menu.component.ts.template} +9 -4
  55. package/src/generators/ui/libs/ui-sheet-helm/files/lib/hlm-sheet-content.directive.ts.template +1 -1
  56. package/src/generators/ui/libs/ui-spinner-helm/files/lib/hlm-spinner.component.ts.template +3 -3
  57. package/src/generators/ui/libs/ui-table-helm/files/index.ts.template +3 -0
  58. package/src/generators/ui/libs/ui-table-helm/files/lib/hlm-caption.component.ts.template +73 -0
  59. package/src/generators/ui/libs/ui-table-helm/files/lib/hlm-table.component.ts.template +20 -2
  60. package/src/generators/ui/libs/ui-table-helm/files/lib/hlm-table.directive.ts.template +4 -3
  61. package/src/generators/ui/libs/ui-table-helm/files/lib/hlm-td.component.ts.template +23 -11
  62. package/src/generators/ui/libs/ui-table-helm/files/lib/hlm-th.component.ts.template +12 -2
  63. package/src/generators/ui/libs/ui-table-helm/files/lib/hlm-trow.component.ts.template +11 -1
  64. package/src/generators/ui/libs/ui-tabs-helm/files/lib/hlm-tabs-list.directive.ts.template +14 -11
  65. package/src/generators/ui/libs/ui-toggle-helm/files/lib/hlm-toggle.directive.ts.template +3 -3
  66. package/src/generators/ui/supported-ui-libraries.json +51 -34
  67. package/src/generators/ui/libs/ui-accordion-helm/files/lib/hlm-accordion-icon.component.ts.template +0 -28
  68. package/src/generators/ui/libs/ui-alert-dialog-helm/files/lib/hlm-alert-dialog-close.directive.ts.template +0 -26
  69. package/src/generators/ui/libs/ui-dialog-helm/files/lib/hlm-dialog-content.directive.ts.template +0 -37
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spartan-ng/cli",
3
- "version": "0.0.1-alpha.326",
3
+ "version": "0.0.1-alpha.327",
4
4
  "type": "commonjs",
5
5
  "dependencies": {
6
6
  "@nx/js": "^17.1.0",
@@ -1,13 +1,13 @@
1
1
  import { NgModule } from '@angular/core';
2
2
 
3
3
  import { HlmAccordionContentDirective } from './lib/hlm-accordion-content.directive';
4
- import { HlmAccordionIconComponent } from './lib/hlm-accordion-icon.component';
4
+ import { HlmAccordionIconDirective } from './lib/hlm-accordion-icon.directive';
5
5
  import { HlmAccordionItemDirective } from './lib/hlm-accordion-item.directive';
6
6
  import { HlmAccordionTriggerDirective } from './lib/hlm-accordion-trigger.directive';
7
7
  import { HlmAccordionDirective } from './lib/hlm-accordion.directive';
8
8
 
9
9
  export * from './lib/hlm-accordion-content.directive';
10
- export * from './lib/hlm-accordion-icon.component';
10
+ export * from './lib/hlm-accordion-icon.directive';
11
11
  export * from './lib/hlm-accordion-item.directive';
12
12
  export * from './lib/hlm-accordion-trigger.directive';
13
13
  export * from './lib/hlm-accordion.directive';
@@ -17,7 +17,7 @@ export const HlmAccordionImports = [
17
17
  HlmAccordionItemDirective,
18
18
  HlmAccordionTriggerDirective,
19
19
  HlmAccordionContentDirective,
20
- HlmAccordionIconComponent,
20
+ HlmAccordionIconDirective,
21
21
  ] as const;
22
22
 
23
23
  @NgModule({
@@ -1,85 +1,30 @@
1
- import { isPlatformBrowser } from '@angular/common';
2
- import {
3
- computed,
4
- Directive,
5
- effect,
6
- ElementRef,
7
- inject,
8
- Injector,
9
- Input,
10
- OnInit,
11
- PLATFORM_ID,
12
- signal,
13
- } from '@angular/core';
14
- import { hlm, injectCustomClassSettable } from '@spartan-ng/ui-core';
1
+ import { computed, Directive, inject, Input, signal } from '@angular/core';
2
+ import { BrnAccordionContentComponent } from '@spartan-ng/ui-accordion-brain';
3
+ import { hlm } from '@spartan-ng/ui-core';
15
4
  import { ClassValue } from 'clsx';
16
5
 
17
6
  @Directive({
18
7
  selector: '[hlmAccordionContent],brn-accordion-content[hlm]',
19
8
  standalone: true,
20
9
  host: {
21
- '[style.height]': 'cssHeight()',
22
10
  '[class]': '_computedClass()',
23
11
  },
24
12
  })
25
- export class HlmAccordionContentDirective implements OnInit {
26
- private readonly _host = injectCustomClassSettable({ optional: true });
27
- private readonly _element = inject(ElementRef).nativeElement;
28
- private readonly _injector = inject(Injector);
29
- private readonly _platformId = inject(PLATFORM_ID);
30
-
31
- private _changes?: MutationObserver;
32
-
33
- public readonly height = signal('-1');
34
- public readonly cssHeight = computed(() => (this.height() === '-1' ? 'auto' : this.height()));
35
- public readonly state = signal('closed');
13
+ export class HlmAccordionContentDirective {
14
+ private readonly _brn = inject(BrnAccordionContentComponent, { optional: true });
36
15
 
37
16
  private readonly _userCls = signal<ClassValue>('');
17
+ protected readonly _computedClass = computed(() => {
18
+ const gridRows = this._brn?.state() === 'open' ? 'grid-rows-[1fr]' : 'grid-rows-[0fr]';
19
+ return hlm('text-sm transition-all grid', gridRows, this._userCls());
20
+ });
21
+
38
22
  @Input()
39
23
  set class(userCls: ClassValue) {
40
24
  this._userCls.set(userCls);
41
25
  }
42
26
 
43
- protected _computedClass = computed(() => this._generateClass());
44
- private _generateClass() {
45
- return hlm('overflow-hidden text-sm transition-all', this._userCls());
46
- }
47
-
48
- public ngOnInit() {
49
- this._host?.setClassToCustomElement('pt-1 pb-4');
50
-
51
- if (isPlatformBrowser(this._platformId)) {
52
- this._changes = new MutationObserver((mutations: MutationRecord[]) => {
53
- mutations.forEach((mutation: MutationRecord) => {
54
- if (mutation.attributeName !== 'data-state') return;
55
- // eslint-disable-next-line
56
- const state = (mutation.target as any).attributes.getNamedItem(mutation.attributeName)?.value;
57
- this.state.set(state);
58
- });
59
- });
60
- }
61
-
62
- Promise.resolve().then(() => {
63
- this._changes?.observe(this._element, {
64
- attributes: true,
65
- childList: true,
66
- characterData: true,
67
- });
68
- });
69
-
70
- effect(
71
- () => {
72
- const isOpen = this.state() === 'open';
73
- Promise.resolve().then(() => {
74
- this.height.set(
75
- isOpen ? getComputedStyle(this._element).getPropertyValue('--brn-collapsible-content-height') : '0px',
76
- );
77
- });
78
- },
79
- {
80
- injector: this._injector,
81
- allowSignalWrites: true,
82
- },
83
- );
27
+ constructor() {
28
+ this._brn?.setClassToCustomElement('pt-1 pb-4');
84
29
  }
85
30
  }
@@ -0,0 +1,31 @@
1
+ import { computed, Directive, inject, Input, signal } from '@angular/core';
2
+ import { radixChevronDown } from '@ng-icons/radix-icons';
3
+ import { hlm } from '@spartan-ng/ui-core';
4
+ import { HlmIconComponent, provideIcons } from '@spartan-ng/ui-icon-helm';
5
+ import { ClassValue } from 'clsx';
6
+
7
+ @Directive({
8
+ selector: 'hlm-icon[hlmAccordionIcon], hlm-icon[hlmAccIcon]',
9
+ standalone: true,
10
+ providers: [provideIcons({ radixChevronDown })],
11
+ host: {
12
+ '[class]': '_computedClass()',
13
+ },
14
+ })
15
+ export class HlmAccordionIconDirective {
16
+ private readonly _hlmIcon = inject(HlmIconComponent);
17
+
18
+ private readonly _userCls = signal<ClassValue>('');
19
+ protected _computedClass = computed(() =>
20
+ hlm('inline-block h-4 w-4 transition-transform duration-200', this._userCls()),
21
+ );
22
+
23
+ @Input()
24
+ set class(userCls: ClassValue) {
25
+ this._userCls.set(userCls);
26
+ }
27
+
28
+ constructor() {
29
+ this._hlmIcon.name = 'radixChevronDown';
30
+ }
31
+ }
@@ -1,4 +1,5 @@
1
- import { Directive, Input, computed, signal } from '@angular/core';
1
+ import { computed, Directive, Input, signal } from '@angular/core';
2
+ import { BrnAccordionItemDirective } from '@spartan-ng/ui-accordion-brain';
2
3
  import { hlm } from '@spartan-ng/ui-core';
3
4
  import { ClassValue } from 'clsx';
4
5
 
@@ -8,16 +9,16 @@ import { ClassValue } from 'clsx';
8
9
  host: {
9
10
  '[class]': '_computedClass()',
10
11
  },
12
+ hostDirectives: [BrnAccordionItemDirective],
11
13
  })
12
14
  export class HlmAccordionItemDirective {
13
15
  private readonly _userCls = signal<ClassValue>('');
16
+ protected readonly _computedClass = computed(() =>
17
+ hlm('flex flex-1 flex-col border-b border-border', this._userCls()),
18
+ );
19
+
14
20
  @Input()
15
21
  set class(userCls: ClassValue) {
16
22
  this._userCls.set(userCls);
17
23
  }
18
-
19
- protected _computedClass = computed(() => this._generateClass());
20
- private _generateClass() {
21
- return hlm('flex flex-1 flex-col border-b border-border', this._userCls());
22
- }
23
24
  }
@@ -1,39 +1,28 @@
1
- import { Directive, Input, computed, signal } from '@angular/core';
2
- import { hlm, injectCustomClassSettable } from '@spartan-ng/ui-core';
1
+ import { computed, Directive, Input, signal } from '@angular/core';
2
+ import { BrnAccordionTriggerDirective } from '@spartan-ng/ui-accordion-brain';
3
+ import { hlm } from '@spartan-ng/ui-core';
3
4
  import { ClassValue } from 'clsx';
4
5
 
5
6
  @Directive({
6
- selector: '[hlmAccordionTrigger],brn-accordion-trigger[hlm]',
7
+ selector: '[hlmAccordionTrigger]',
7
8
  standalone: true,
8
9
  host: {
9
10
  '[style.--tw-ring-offset-shadow]': '"0 0 #000"',
10
11
  '[class]': '_computedClass()',
11
12
  },
13
+ hostDirectives: [BrnAccordionTriggerDirective],
12
14
  })
13
15
  export class HlmAccordionTriggerDirective {
14
- private _host = injectCustomClassSettable({ optional: true });
15
-
16
- constructor() {
17
- this._host?.setClassToCustomElement(this._generateClass());
18
- }
19
-
20
16
  private readonly _userCls = signal<ClassValue>('');
17
+ protected _computedClass = computed(() =>
18
+ hlm(
19
+ 'w-full focus-visible:outline-none text-sm focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-2 flex flex-1 items-center justify-between py-4 px-0.5 font-medium underline-offset-4 hover:underline [&[data-state=open]>[hlmAccordionIcon]]:rotate-180 [&[data-state=open]>[hlmAccIcon]]:rotate-180',
20
+ this._userCls(),
21
+ ),
22
+ );
23
+
21
24
  @Input()
22
25
  set class(inputs: ClassValue) {
23
26
  this._userCls.set(inputs);
24
- // cannot set in effect because it sets a signal
25
- if (this._host) {
26
- this._host.setClassToCustomElement(this._generateClass());
27
- }
28
- }
29
-
30
- protected _computedClass = computed(() => {
31
- return !this._host ? this._generateClass() : '';
32
- });
33
- private _generateClass() {
34
- return hlm(
35
- 'w-full focus-visible:outline-none text-sm focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-2 flex flex-1 items-center justify-between py-4 px-0.5 font-medium underline-offset-4 hover:underline [&[data-state=open]>hlm-accordion-icon]:rotate-180',
36
- this._userCls(),
37
- );
38
27
  }
39
28
  }
@@ -1,23 +1,26 @@
1
- import { Directive, Input, computed, signal } from '@angular/core';
1
+ import { computed, Directive, inject, Input, signal } from '@angular/core';
2
+ import { BrnAccordionDirective } from '@spartan-ng/ui-accordion-brain';
2
3
  import { hlm } from '@spartan-ng/ui-core';
3
4
  import { ClassValue } from 'clsx';
4
5
 
5
6
  @Directive({
6
- selector: '[hlmAccordion],brn-accordion[hlm]',
7
+ selector: '[hlmAccordion]',
7
8
  standalone: true,
8
9
  host: {
9
10
  '[class]': '_computedClass()',
10
11
  },
12
+ hostDirectives: [BrnAccordionDirective],
11
13
  })
12
14
  export class HlmAccordionDirective {
15
+ private readonly _brn = inject(BrnAccordionDirective);
16
+
13
17
  private readonly _userCls = signal<ClassValue>('');
18
+ protected readonly _computedClass = computed(() =>
19
+ hlm('flex', this._brn.orientation === 'horizontal' ? 'flex-row' : 'flex-col', this._userCls()),
20
+ );
21
+
14
22
  @Input()
15
23
  set class(userCls: ClassValue) {
16
24
  this._userCls.set(userCls);
17
25
  }
18
-
19
- protected _computedClass = computed(() => this._generateClass());
20
- private _generateClass() {
21
- return hlm('flex flex-col', this._userCls());
22
- }
23
26
  }
@@ -2,27 +2,26 @@ import { NgModule } from '@angular/core';
2
2
 
3
3
  import { HlmAlertDialogActionButtonDirective } from './lib/hlm-alert-dialog-action-button.directive';
4
4
  import { HlmAlertDialogCancelButtonDirective } from './lib/hlm-alert-dialog-cancel-button.directive';
5
- import { HlmAlertDialogCloseDirective } from './lib/hlm-alert-dialog-close.directive';
6
- import { HlmAlertDialogContentDirective } from './lib/hlm-alert-dialog-content.directive';
5
+ import { HlmAlertDialogContentComponent } from './lib/hlm-alert-dialog-content.component';
7
6
  import { HlmAlertDialogDescriptionDirective } from './lib/hlm-alert-dialog-description.directive';
8
7
  import { HlmAlertDialogFooterComponent } from './lib/hlm-alert-dialog-footer.component';
9
8
  import { HlmAlertDialogHeaderComponent } from './lib/hlm-alert-dialog-header.component';
10
9
  import { HlmAlertDialogOverlayDirective } from './lib/hlm-alert-dialog-overlay.directive';
11
10
  import { HlmAlertDialogTitleDirective } from './lib/hlm-alert-dialog-title.directive';
11
+ import { HlmAlertDialogComponent } from './lib/hlm-alert-dialog.component';
12
12
 
13
13
  export * from './lib/hlm-alert-dialog-action-button.directive';
14
14
  export * from './lib/hlm-alert-dialog-cancel-button.directive';
15
- export * from './lib/hlm-alert-dialog-close.directive';
16
- export * from './lib/hlm-alert-dialog-content.directive';
15
+ export * from './lib/hlm-alert-dialog-content.component';
17
16
  export * from './lib/hlm-alert-dialog-description.directive';
18
17
  export * from './lib/hlm-alert-dialog-footer.component';
19
18
  export * from './lib/hlm-alert-dialog-header.component';
20
19
  export * from './lib/hlm-alert-dialog-overlay.directive';
21
20
  export * from './lib/hlm-alert-dialog-title.directive';
21
+ export * from './lib/hlm-alert-dialog.component';
22
22
 
23
23
  export const HlmAlertDialogImports = [
24
- HlmAlertDialogCloseDirective,
25
- HlmAlertDialogContentDirective,
24
+ HlmAlertDialogContentComponent,
26
25
  HlmAlertDialogDescriptionDirective,
27
26
  HlmAlertDialogFooterComponent,
28
27
  HlmAlertDialogHeaderComponent,
@@ -30,6 +29,7 @@ export const HlmAlertDialogImports = [
30
29
  HlmAlertDialogTitleDirective,
31
30
  HlmAlertDialogActionButtonDirective,
32
31
  HlmAlertDialogCancelButtonDirective,
32
+ HlmAlertDialogComponent,
33
33
  ] as const;
34
34
 
35
35
  @NgModule({
@@ -12,9 +12,11 @@ import { ClassValue } from 'clsx';
12
12
  },
13
13
  })
14
14
  export class HlmAlertDialogCancelButtonDirective {
15
- private _hlmBtn = inject(HlmButtonDirective, { host: true });
15
+ private readonly _hlmBtn = inject(HlmButtonDirective, { host: true });
16
16
 
17
17
  private readonly _userCls = signal<ClassValue>('');
18
+ protected readonly _computedClass = computed(() => hlm('mt-2 sm:mt-0', this._userCls()));
19
+
18
20
  @Input()
19
21
  set class(userCls: ClassValue) {
20
22
  this._userCls.set(userCls);
@@ -23,9 +25,4 @@ export class HlmAlertDialogCancelButtonDirective {
23
25
  constructor() {
24
26
  this._hlmBtn.variant = 'outline';
25
27
  }
26
-
27
- protected _computedClass = computed(() => this._generateClass());
28
- private _generateClass() {
29
- return hlm('mt-2 sm:mt-0', this._userCls());
30
- }
31
28
  }
@@ -1,35 +1,34 @@
1
- import { computed, Directive, effect, ElementRef, inject, Input, Renderer2, signal } from '@angular/core';
1
+ import { ChangeDetectionStrategy, Component, computed, Input, signal, ViewEncapsulation } from '@angular/core';
2
2
  import { hlm, injectExposesStateProvider } from '@spartan-ng/ui-core';
3
3
  import { ClassValue } from 'clsx';
4
4
 
5
- @Directive({
6
- selector: '[hlmAlertDialogContent],[brnAlertDialogContent][hlm]',
5
+ @Component({
6
+ selector: 'hlm-alert-dialog-content',
7
7
  standalone: true,
8
8
  host: {
9
9
  '[class]': '_computedClass()',
10
+ '[attr.data-state]': 'state()',
10
11
  },
12
+ template: `
13
+ <ng-content />
14
+ `,
15
+ changeDetection: ChangeDetectionStrategy.OnPush,
16
+ encapsulation: ViewEncapsulation.None,
11
17
  })
12
- export class HlmAlertDialogContentDirective {
13
- private _stateProvider = injectExposesStateProvider({ optional: true, host: true });
14
- public state = this._stateProvider?.state ?? signal('closed');
15
- private _renderer = inject(Renderer2);
16
- private _element = inject(ElementRef);
17
-
18
- constructor() {
19
- effect(() => this._renderer.setAttribute(this._element.nativeElement, 'data-state', this.state()));
20
- }
18
+ export class HlmAlertDialogContentComponent {
19
+ private readonly _stateProvider = injectExposesStateProvider({ optional: true, host: true });
20
+ public readonly state = this._stateProvider?.state ?? signal('closed');
21
21
 
22
22
  private readonly _userCls = signal<ClassValue>('');
23
+ protected readonly _computedClass = computed(() =>
24
+ hlm(
25
+ 'relative grid w-full max-w-lg gap-4 border-border border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-top-[2%] data-[state=open]:slide-in-from-top-[2%] sm:rounded-lg md:w-full',
26
+ this._userCls(),
27
+ ),
28
+ );
29
+
23
30
  @Input()
24
31
  set class(userCls: ClassValue) {
25
32
  this._userCls.set(userCls);
26
33
  }
27
-
28
- protected _computedClass = computed(() => this._generateClass());
29
- private _generateClass() {
30
- return hlm(
31
- 'relative grid w-full max-w-lg gap-4 border-border border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-top-[2%] data-[state=open]:slide-in-from-top-[2%] sm:rounded-lg md:w-full',
32
- this._userCls(),
33
- );
34
- }
35
34
  }
@@ -1,4 +1,5 @@
1
- import { Directive, Input, computed, signal } from '@angular/core';
1
+ import { computed, Directive, Input, signal } from '@angular/core';
2
+ import { BrnAlertDialogDescriptionDirective } from '@spartan-ng/ui-alertdialog-brain';
2
3
  import { hlm } from '@spartan-ng/ui-core';
3
4
  import { ClassValue } from 'clsx';
4
5
 
@@ -8,16 +9,14 @@ import { ClassValue } from 'clsx';
8
9
  host: {
9
10
  '[class]': '_computedClass()',
10
11
  },
12
+ hostDirectives: [BrnAlertDialogDescriptionDirective],
11
13
  })
12
14
  export class HlmAlertDialogDescriptionDirective {
13
15
  private readonly _userCls = signal<ClassValue>('');
16
+ protected readonly _computedClass = computed(() => hlm('text-sm text-muted-foreground', this._userCls()));
17
+
14
18
  @Input()
15
19
  set class(userCls: ClassValue) {
16
20
  this._userCls.set(userCls);
17
21
  }
18
-
19
- protected _computedClass = computed(() => this._generateClass());
20
- private _generateClass() {
21
- return hlm('text-sm text-muted-foreground', this._userCls());
22
- }
23
22
  }
@@ -1,4 +1,4 @@
1
- import { Component, Input, computed, signal } from '@angular/core';
1
+ import { ChangeDetectionStrategy, Component, computed, Input, signal, ViewEncapsulation } from '@angular/core';
2
2
  import { hlm } from '@spartan-ng/ui-core';
3
3
  import { ClassValue } from 'clsx';
4
4
 
@@ -11,16 +11,16 @@ import { ClassValue } from 'clsx';
11
11
  host: {
12
12
  '[class]': '_computedClass()',
13
13
  },
14
+ changeDetection: ChangeDetectionStrategy.OnPush,
15
+ encapsulation: ViewEncapsulation.None,
14
16
  })
15
17
  export class HlmAlertDialogFooterComponent {
16
18
  private readonly _userCls = signal<ClassValue>('');
19
+ protected readonly _computedClass = computed(() =>
20
+ hlm('flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2', this._userCls()),
21
+ );
17
22
  @Input()
18
23
  set class(userCls: ClassValue) {
19
24
  this._userCls.set(userCls);
20
25
  }
21
-
22
- protected _computedClass = computed(() => this._generateClass());
23
- private _generateClass() {
24
- return hlm('flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2', this._userCls());
25
- }
26
26
  }
@@ -1,4 +1,4 @@
1
- import { Component, Input, computed, signal } from '@angular/core';
1
+ import { ChangeDetectionStrategy, Component, computed, Input, signal, ViewEncapsulation } from '@angular/core';
2
2
  import { hlm } from '@spartan-ng/ui-core';
3
3
  import { ClassValue } from 'clsx';
4
4
 
@@ -11,16 +11,16 @@ import { ClassValue } from 'clsx';
11
11
  host: {
12
12
  '[class]': '_computedClass()',
13
13
  },
14
+ changeDetection: ChangeDetectionStrategy.OnPush,
15
+ encapsulation: ViewEncapsulation.None,
14
16
  })
15
17
  export class HlmAlertDialogHeaderComponent {
16
18
  private readonly _userCls = signal<ClassValue>('');
19
+ protected readonly _computedClass = computed(() =>
20
+ hlm('flex flex-col space-y-2 text-center sm:text-left', this._userCls()),
21
+ );
17
22
  @Input()
18
23
  set class(userCls: ClassValue) {
19
24
  this._userCls.set(userCls);
20
25
  }
21
-
22
- protected _computedClass = computed(() => this._generateClass());
23
- private _generateClass() {
24
- return hlm('flex flex-col space-y-2 text-center sm:text-left', this._userCls());
25
- }
26
26
  }
@@ -1,33 +1,27 @@
1
- import { Directive, Input, computed, signal } from '@angular/core';
1
+ import { computed, Directive, effect, Input, signal } from '@angular/core';
2
2
  import { hlm, injectCustomClassSettable } from '@spartan-ng/ui-core';
3
3
  import { ClassValue } from 'clsx';
4
4
 
5
5
  @Directive({
6
6
  selector: '[hlmAlertDialogOverlay],brn-alert-dialog-overlay[hlm]',
7
7
  standalone: true,
8
- host: {
9
- '[class]': '_computedClass()',
10
- },
11
8
  })
12
9
  export class HlmAlertDialogOverlayDirective {
13
- private _classSettable = injectCustomClassSettable({ optional: true, host: true });
14
-
15
- constructor() {
16
- this._classSettable?.setClassToCustomElement(this._computedClass());
17
- }
10
+ private readonly _classSettable = injectCustomClassSettable({ optional: true, host: true });
18
11
 
19
12
  private readonly _userCls = signal<ClassValue>('');
13
+ protected readonly _computedClass = computed(() =>
14
+ hlm(
15
+ 'bg-background/80 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',
16
+ this._userCls(),
17
+ ),
18
+ );
20
19
  @Input()
21
20
  set class(userCls: ClassValue) {
22
21
  this._userCls.set(userCls);
23
- this._classSettable?.setClassToCustomElement(this._computedClass());
24
22
  }
25
23
 
26
- protected _computedClass = computed(() => this._generateClass());
27
- private _generateClass() {
28
- return hlm(
29
- 'bg-background/80 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',
30
- this._userCls(),
31
- );
24
+ constructor() {
25
+ effect(() => this._classSettable?.setClassToCustomElement(this._computedClass()));
32
26
  }
33
27
  }
@@ -1,4 +1,5 @@
1
- import { Directive, Input, computed, signal } from '@angular/core';
1
+ import { computed, Directive, Input, signal } from '@angular/core';
2
+ import { BrnAlertDialogTitleDirective } from '@spartan-ng/ui-alertdialog-brain';
2
3
  import { hlm } from '@spartan-ng/ui-core';
3
4
  import { ClassValue } from 'clsx';
4
5
 
@@ -8,16 +9,13 @@ import { ClassValue } from 'clsx';
8
9
  host: {
9
10
  '[class]': '_computedClass()',
10
11
  },
12
+ hostDirectives: [BrnAlertDialogTitleDirective],
11
13
  })
12
14
  export class HlmAlertDialogTitleDirective {
13
15
  private readonly _userCls = signal<ClassValue>('');
16
+ protected readonly _computedClass = computed(() => hlm('text-lg font-semibold', this._userCls()));
14
17
  @Input()
15
18
  set class(userCls: ClassValue) {
16
19
  this._userCls.set(userCls);
17
20
  }
18
-
19
- protected _computedClass = computed(() => this._generateClass());
20
- private _generateClass() {
21
- return hlm('text-lg font-semibold', this._userCls());
22
- }
23
21
  }
@@ -0,0 +1,30 @@
1
+ import { ChangeDetectionStrategy, Component, forwardRef, ViewEncapsulation } from '@angular/core';
2
+ import { BrnAlertDialogComponent, BrnAlertDialogOverlayComponent } from '@spartan-ng/ui-alertdialog-brain';
3
+ import { BrnDialogComponent, provideBrnDialog } from '@spartan-ng/ui-dialog-brain';
4
+ import { HlmAlertDialogOverlayDirective } from './hlm-alert-dialog-overlay.directive';
5
+
6
+ @Component({
7
+ selector: 'hlm-alert-dialog',
8
+ standalone: true,
9
+ template: `
10
+ <brn-alert-dialog-overlay hlm />
11
+ <ng-content />
12
+ `,
13
+ providers: [
14
+ provideBrnDialog(),
15
+ {
16
+ provide: BrnDialogComponent,
17
+ useExisting: forwardRef(() => HlmAlertDialogComponent),
18
+ },
19
+ ],
20
+ changeDetection: ChangeDetectionStrategy.OnPush,
21
+ encapsulation: ViewEncapsulation.None,
22
+ exportAs: 'hlmAlertDialog',
23
+ imports: [BrnAlertDialogOverlayComponent, HlmAlertDialogOverlayDirective],
24
+ })
25
+ export class HlmAlertDialogComponent extends BrnAlertDialogComponent {
26
+ constructor() {
27
+ super();
28
+ this.closeDelay = 100;
29
+ }
30
+ }
@@ -1,9 +1,9 @@
1
- import { Directive, Input, computed, signal } from '@angular/core';
1
+ import { computed, Directive, Input, signal } from '@angular/core';
2
2
  import { hlm } from '@spartan-ng/ui-core';
3
- import { VariantProps, cva } from 'class-variance-authority';
3
+ import { cva, VariantProps } from 'class-variance-authority';
4
4
  import { ClassValue } from 'clsx';
5
5
 
6
- const alertDescriptionVariants = cva('text-sm [&_p]:leading-relaxed', {
6
+ export const alertDescriptionVariants = cva('text-sm [&_p]:leading-relaxed', {
7
7
  variants: {},
8
8
  });
9
9
  export type AlertDescriptionVariants = VariantProps<typeof alertDescriptionVariants>;
@@ -1,9 +1,9 @@
1
- import { Directive, Input, computed, signal } from '@angular/core';
1
+ import { computed, Directive, Input, signal } from '@angular/core';
2
2
  import { hlm } from '@spartan-ng/ui-core';
3
- import { VariantProps, cva } from 'class-variance-authority';
3
+ import { cva, VariantProps } from 'class-variance-authority';
4
4
  import { ClassValue } from 'clsx';
5
5
 
6
- const alertTitleVariants = cva('mb-1 font-medium leading-none tracking-tight', {
6
+ export const alertTitleVariants = cva('mb-1 font-medium leading-none tracking-tight', {
7
7
  variants: {},
8
8
  });
9
9
  export type AlertTitleVariants = VariantProps<typeof alertTitleVariants>;
@@ -1,9 +1,9 @@
1
- import { Directive, Input, computed, signal } from '@angular/core';
1
+ import { computed, Directive, Input, signal } from '@angular/core';
2
2
  import { hlm } from '@spartan-ng/ui-core';
3
- import { VariantProps, cva } from 'class-variance-authority';
3
+ import { cva, VariantProps } from 'class-variance-authority';
4
4
  import { ClassValue } from 'clsx';
5
5
 
6
- const alertVariants = cva(
6
+ export const alertVariants = cva(
7
7
  'relative w-full rounded-lg border border-border p-4 [&>[hlmAlertIcon]]:absolute [&>[hlmAlertIcon]]:text-foreground [&>[hlmAlertIcon]]:left-4 [&>[hlmAlertIcon]]:top-4 [&>[hlmAlertIcon]+div]:translate-y-[-3px] [&>[hlmAlertIcon]~*]:pl-7',
8
8
  {
9
9
  variants: {