@ngbase/adk 0.1.3 → 0.1.4

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 (127) hide show
  1. package/package.json +9 -9
  2. package/schematics/collection.json +15 -0
  3. package/schematics/components/files/accordion/accordion.ts.template +53 -0
  4. package/schematics/components/files/accordion/index.ts.template +5 -0
  5. package/schematics/components/files/alert/alert.ts.template +62 -0
  6. package/schematics/components/files/alert/index.ts.template +1 -0
  7. package/schematics/components/files/autocomplete/autocomplete.ts.template +44 -0
  8. package/schematics/components/files/autocomplete/index.ts.template +5 -0
  9. package/schematics/components/files/avatar/avatar.ts.template +31 -0
  10. package/schematics/components/files/avatar/index.ts.template +1 -0
  11. package/schematics/components/files/badge/badge.ts.template +11 -0
  12. package/schematics/components/files/badge/index.ts.template +1 -0
  13. package/schematics/components/files/breadcrumb/breadcrumb.ts.template +53 -0
  14. package/schematics/components/files/breadcrumb/index.ts.template +1 -0
  15. package/schematics/components/files/button/button.ts.template +29 -0
  16. package/schematics/components/files/button/index.ts.template +5 -0
  17. package/schematics/components/files/card/card.ts.template +11 -0
  18. package/schematics/components/files/card/index.ts.template +5 -0
  19. package/schematics/components/files/carousel/carousel.ts.template +44 -0
  20. package/schematics/components/files/carousel/index.ts.template +1 -0
  21. package/schematics/components/files/checkbox/checkbox.ts.template +36 -0
  22. package/schematics/components/files/checkbox/focus-style.directive.ts.template +12 -0
  23. package/schematics/components/files/checkbox/index.ts.template +6 -0
  24. package/schematics/components/files/chip/chip.ts.template +38 -0
  25. package/schematics/components/files/chip/index.ts.template +1 -0
  26. package/schematics/components/files/color-picker/color-picker.ts.template +104 -0
  27. package/schematics/components/files/color-picker/index.ts.template +5 -0
  28. package/schematics/components/files/command/command.ts.template +82 -0
  29. package/schematics/components/files/command/index.ts.template +1 -0
  30. package/schematics/components/files/datepicker/calendar.ts.template +117 -0
  31. package/schematics/components/files/datepicker/datepicker.ts.template +59 -0
  32. package/schematics/components/files/datepicker/index.ts.template +2 -0
  33. package/schematics/components/files/datepicker/time.ts.template +54 -0
  34. package/schematics/components/files/dialog/dialog.ts.template +89 -0
  35. package/schematics/components/files/dialog/index.ts.template +5 -0
  36. package/schematics/components/files/drawer/drawer.ts.template +104 -0
  37. package/schematics/components/files/drawer/index.ts.template +5 -0
  38. package/schematics/components/files/form-field/form-field.ts.template +111 -0
  39. package/schematics/components/files/form-field/index.ts.template +6 -0
  40. package/schematics/components/files/form-field/input-style.directive.ts.template +11 -0
  41. package/schematics/components/files/hover-card/hover-card.ts.template +13 -0
  42. package/schematics/components/files/hover-card/index.ts.template +5 -0
  43. package/schematics/components/files/icon/icon.ts.template +16 -0
  44. package/schematics/components/files/icon/index.ts.template +1 -0
  45. package/schematics/components/files/inline-edit/index.ts.template +1 -0
  46. package/schematics/components/files/inline-edit/inline-edit.ts.template +24 -0
  47. package/schematics/components/files/keys/index.ts.template +5 -0
  48. package/schematics/components/files/keys/key.ts.template +35 -0
  49. package/schematics/components/files/list/index.ts.template +5 -0
  50. package/schematics/components/files/list/list.ts.template +28 -0
  51. package/schematics/components/files/mask/index.ts.template +1 -0
  52. package/schematics/components/files/mask/mask.ts.template +8 -0
  53. package/schematics/components/files/menu/context-menu.ts.template +14 -0
  54. package/schematics/components/files/menu/index.ts.template +8 -0
  55. package/schematics/components/files/menu/mention.ts.template +14 -0
  56. package/schematics/components/files/menu/menu.ts.template +37 -0
  57. package/schematics/components/files/menu/navigation-menu.ts.template +8 -0
  58. package/schematics/components/files/otp/index.ts.template +5 -0
  59. package/schematics/components/files/otp/otp.ts.template +37 -0
  60. package/schematics/components/files/pagination/index.ts.template +1 -0
  61. package/schematics/components/files/pagination/pagination.ts.template +75 -0
  62. package/schematics/components/files/picasa/index.ts.template +1 -0
  63. package/schematics/components/files/picasa/picasa-base.component.ts.template +80 -0
  64. package/schematics/components/files/picasa/picasa.component.ts.template +57 -0
  65. package/schematics/components/files/picasa/picasa.directive.ts.template +41 -0
  66. package/schematics/components/files/picasa/picase.service.ts.template +24 -0
  67. package/schematics/components/files/popover/index.ts.template +1 -0
  68. package/schematics/components/files/popover/popover.ts.template +64 -0
  69. package/schematics/components/files/progress/index.ts.template +5 -0
  70. package/schematics/components/files/progress/progress.ts.template +14 -0
  71. package/schematics/components/files/radio/index.ts.template +5 -0
  72. package/schematics/components/files/radio/radio.ts.template +37 -0
  73. package/schematics/components/files/resizable/index.ts.template +5 -0
  74. package/schematics/components/files/resizable/resizable.ts.template +59 -0
  75. package/schematics/components/files/scroll-area/index.ts.template +1 -0
  76. package/schematics/components/files/scroll-area/scroll-area.ts.template +40 -0
  77. package/schematics/components/files/select/index.ts.template +8 -0
  78. package/schematics/components/files/select/list-selection.ts.template +15 -0
  79. package/schematics/components/files/select/option.ts.template +35 -0
  80. package/schematics/components/files/select/select-input.ts.template +21 -0
  81. package/schematics/components/files/select/select.ts.template +96 -0
  82. package/schematics/components/files/selectable/index.ts.template +1 -0
  83. package/schematics/components/files/selectable/selectable.ts.template +34 -0
  84. package/schematics/components/files/separator/index.ts.template +5 -0
  85. package/schematics/components/files/separator/separator.ts.template +19 -0
  86. package/schematics/components/files/sheet/index.ts.template +5 -0
  87. package/schematics/components/files/sheet/sheet.ts.template +69 -0
  88. package/schematics/components/files/sidenav/index.ts.template +1 -0
  89. package/schematics/components/files/sidenav/sidenav.ts.template +48 -0
  90. package/schematics/components/files/skeleton/index.ts.template +1 -0
  91. package/schematics/components/files/skeleton/skeleton.ts.template +15 -0
  92. package/schematics/components/files/slider/index.ts.template +5 -0
  93. package/schematics/components/files/slider/slider.ts.template +35 -0
  94. package/schematics/components/files/sonner/index.ts.template +5 -0
  95. package/schematics/components/files/sonner/sonner.ts.template +59 -0
  96. package/schematics/components/files/spinner/index.ts.template +1 -0
  97. package/schematics/components/files/spinner/spinner.ts.template +79 -0
  98. package/schematics/components/files/stepper/index.ts.template +1 -0
  99. package/schematics/components/files/stepper/stepper.ts.template +88 -0
  100. package/schematics/components/files/switch/index.ts.template +5 -0
  101. package/schematics/components/files/switch/switch.ts.template +29 -0
  102. package/schematics/components/files/table/index.ts.template +27 -0
  103. package/schematics/components/files/table/table.ts.template +122 -0
  104. package/schematics/components/files/tabs/index.ts.template +5 -0
  105. package/schematics/components/files/tabs/tab.ts.template +92 -0
  106. package/schematics/components/files/theme/index.ts.template +2 -0
  107. package/schematics/components/files/theme/theme-button.component.ts.template +26 -0
  108. package/schematics/components/files/theme/theme.service.ts.template +33 -0
  109. package/schematics/components/files/toggle/index.ts.template +5 -0
  110. package/schematics/components/files/toggle/toggle.ts.template +13 -0
  111. package/schematics/components/files/toggle-group/index.ts.template +5 -0
  112. package/schematics/components/files/toggle-group/toggle-group.ts.template +25 -0
  113. package/schematics/components/files/tooltip/index.ts.template +5 -0
  114. package/schematics/components/files/tooltip/tooltip.ts.template +45 -0
  115. package/schematics/components/files/tour/index.ts.template +1 -0
  116. package/schematics/components/files/tour/tour.ts.template +19 -0
  117. package/schematics/components/files/tree/index.ts.template +1 -0
  118. package/schematics/components/files/tree/tree.ts.template +66 -0
  119. package/schematics/components/index.d.ts +3 -0
  120. package/schematics/components/index.js +41 -0
  121. package/schematics/components/index.js.map +1 -0
  122. package/schematics/components/index.ts +59 -0
  123. package/schematics/components/schema.d.ts +6 -0
  124. package/schematics/components/schema.js +3 -0
  125. package/schematics/components/schema.js.map +1 -0
  126. package/schematics/components/schema.json +145 -0
  127. package/schematics/components/schema.ts +6 -0
@@ -0,0 +1,82 @@
1
+ import { ChangeDetectionStrategy, Component, inject } from '@angular/core';
2
+ import { FormsModule } from '@angular/forms';
3
+ import { RouterLink } from '@angular/router';
4
+ import { AccessibleGroup, AccessibleItem, Autofocus } from '@ngbase/adk/a11y';
5
+ import { DialogRef } from '@ngbase/adk/portal';
6
+ import { filterFunction, uniqueId } from '@ngbase/adk/utils';
7
+ import { List } from '<%= basepath %>/list';
8
+
9
+ export interface CommandGroup {
10
+ name: string;
11
+ items: CommandItem[];
12
+ }
13
+
14
+ export interface CommandItem {
15
+ name: string;
16
+ link: string;
17
+ }
18
+
19
+ @Component({
20
+ selector: '<%= name %>-command',
21
+ changeDetection: ChangeDetectionStrategy.OnPush,
22
+ imports: [FormsModule, List, AccessibleGroup, AccessibleItem, Autofocus, RouterLink],
23
+ template: `
24
+ <div ngbAccessibleGroup [ayId]="ayId" [isPopup]="true" class="static w-full">
25
+ <input
26
+ ngbAutofocus
27
+ [(ngModel)]="filter.search"
28
+ type="text"
29
+ placeholder="Search for apps and commands"
30
+ class="sticky -top-4 w-full border-b bg-background p-4 outline-none"
31
+ />
32
+ @for (group of filter.filteredList(); track group.name) {
33
+ <h4 class="mx-4 my-2 text-sm text-gray-500">{{ group.name }}</h4>
34
+ <div class="flex flex-col px-2">
35
+ @for (item of group.items; track item.name) {
36
+ <a
37
+ <%= name %>List
38
+ class="w-full"
39
+ [ayId]="ayId"
40
+ [routerLink]="item.link || null"
41
+ (click)="close()"
42
+ >
43
+ <svg
44
+ xmlns="http://www.w3.org/2000/svg"
45
+ width="24"
46
+ height="24"
47
+ viewBox="0 0 24 24"
48
+ fill="none"
49
+ stroke="currentColor"
50
+ stroke-width="2"
51
+ stroke-linecap="round"
52
+ stroke-linejoin="round"
53
+ class="mr-2"
54
+ >
55
+ <path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" />
56
+ </svg>
57
+ <span>{{ item.name }}</span>
58
+ </a>
59
+ }
60
+ </div>
61
+ }
62
+ </div>
63
+ `,
64
+ host: {
65
+ class: 'block -m-4',
66
+ },
67
+ })
68
+ export class Command {
69
+ private dialogRef = inject<DialogRef<CommandGroup[]>>(DialogRef);
70
+
71
+ readonly ayId = uniqueId();
72
+
73
+ readonly filter = filterFunction<CommandGroup, CommandItem>(this.dialogRef.data!, {
74
+ filter: item => item.name,
75
+ key: 'items',
76
+ childrenFilter: item => item.items,
77
+ });
78
+
79
+ close() {
80
+ this.dialogRef.close();
81
+ }
82
+ }
@@ -0,0 +1 @@
1
+ export * from './command';
@@ -0,0 +1,117 @@
1
+ import { NgClass } from '@angular/common';
2
+ import { ChangeDetectionStrategy, Component } from '@angular/core';
3
+ import { Button } from '<%= basepath %>/button';
4
+ import { Icon } from '<%= basepath %>/icon';
5
+ import { provideIcons } from '@ng-icons/core';
6
+ import { lucideChevronLeft, lucideChevronRight } from '@ng-icons/lucide';
7
+ import {
8
+ CalendarBtn,
9
+ CalendarDayBtn,
10
+ CalendarMonthBtn,
11
+ CalendarTitle,
12
+ CalendarYearBtn,
13
+ NgbCalendar,
14
+ aliasCalendar,
15
+ } from '@ngbase/adk/datepicker';
16
+ import { TimePicker } from './time';
17
+
18
+ @Component({
19
+ selector: '<%= name %>-calendar',
20
+ changeDetection: ChangeDetectionStrategy.OnPush,
21
+ providers: [aliasCalendar(Calendar)],
22
+ viewProviders: [provideIcons({ lucideChevronLeft, lucideChevronRight })],
23
+ imports: [
24
+ NgClass,
25
+ Button,
26
+ Icon,
27
+ TimePicker,
28
+ CalendarBtn,
29
+ CalendarTitle,
30
+ CalendarYearBtn,
31
+ CalendarMonthBtn,
32
+ CalendarDayBtn,
33
+ ],
34
+ template: `
35
+ <div class="mb-2 flex items-center justify-between">
36
+ <button ngbCalendarBtn="left" <%= name %>Button="outline" class="h-6 w-6 rounded-md !px-0">
37
+ <<%= name %>-icon [name]="dir.isRtl() ? 'lucideChevronRight' : 'lucideChevronLeft'" />
38
+ </button>
39
+ <button ngbCalendarTitle <%= name %>Button="ghost" class="small rounded-md">
40
+ {{ title() }}
41
+ </button>
42
+ <button ngbCalendarBtn="right" <%= name %>Button="outline" class="h-6 w-6 rounded-md !px-0">
43
+ <<%= name %>-icon [name]="dir.isRtl() ? 'lucideChevronLeft' : 'lucideChevronRight'" />
44
+ </button>
45
+ </div>
46
+
47
+ @if (datePicker.showType() === 'year') {
48
+ <div class="grid grid-cols-3">
49
+ @for (year of years(); track year.year) {
50
+ <button
51
+ [ngbCalYearBtn]="year"
52
+ #yearBtn="ngbCalYearBtn"
53
+ class="items-center justify-center rounded-md py-2 h-9 w-[84px] {{
54
+ year.disabled ? 'cursor-default opacity-50' : 'hover:bg-muted'
55
+ }}"
56
+ [ngClass]="{
57
+ 'border bg-muted': yearBtn.selected(),
58
+ '!bg-primary text-background': yearBtn.active(),
59
+ }"
60
+ >
61
+ {{ year.year }}
62
+ </button>
63
+ }
64
+ </div>
65
+ } @else if (datePicker.showType() === 'month') {
66
+ <div class="grid grid-cols-3">
67
+ @for (month of months(); track month.value) {
68
+ <button
69
+ [ngbCalMonthBtn]="month"
70
+ #monthBtn="ngbCalMonthBtn"
71
+ class="items-center justify-center rounded-md py-2 h-9 w-[84px] {{
72
+ month.disabled ? 'cursor-default opacity-50' : 'hover:bg-muted'
73
+ }}"
74
+ [ngClass]="{
75
+ 'border bg-muted': monthBtn.selected(),
76
+ '!bg-primary text-background': monthBtn.active(),
77
+ }"
78
+ >
79
+ {{ month.name }}
80
+ </button>
81
+ }
82
+ </div>
83
+ } @else {
84
+ <div class="day-names grid grid-cols-7">
85
+ @for (dayName of dayNames; track dayName) {
86
+ <div class="text-muted-foreground p-1 text-center">{{ dayName }}</div>
87
+ }
88
+ </div>
89
+ <div class="grid grid-cols-7 gap-y-2">
90
+ @for (day of getDaysArray(); track day.day + '-' + day.mon) {
91
+ <button
92
+ #days="ngbCalDayBtn"
93
+ [ngbCalDayBtn]="day"
94
+ class="mx-auto flex h-9 w-9 items-center justify-center text-center {{
95
+ day.disabled ? 'cursor-default opacity-50' : 'hover:bg-muted'
96
+ }}"
97
+ [ngClass]="{
98
+ 'bg-muted': days.selected(),
99
+ 'opacity-40': days.dummy(),
100
+ '!bg-primary text-background': days.active(),
101
+ }"
102
+ >
103
+ {{ day.day }}
104
+ </button>
105
+ }
106
+ </div>
107
+ @if (datePicker.time() && datePicker.range()) {
108
+ <<%= name %>-time class="mt-5 w-full" [(value)]="time1" (valueChange)="timeChanged(0, time1()!)" />
109
+ <<%= name %>-time class="mt-5 w-full" [(value)]="time2" (valueChange)="timeChanged(1, time2()!)" />
110
+ }
111
+ }
112
+ `,
113
+ host: {
114
+ class: 'inline-flex flex-col min-h-[18.75rem] p-2 w-full',
115
+ },
116
+ })
117
+ export class Calendar<D> extends NgbCalendar<D> {}
@@ -0,0 +1,59 @@
1
+ import { NgTemplateOutlet } from '@angular/common';
2
+ import { ChangeDetectionStrategy, Component, Directive } from '@angular/core';
3
+ import {
4
+ DatepickerGroup,
5
+ NgbDatePicker,
6
+ NgbDatepickerTrigger,
7
+ NgbEndDate,
8
+ aliasDatePicker,
9
+ aliasDatePickerTrigger,
10
+ registerDatePicker,
11
+ } from '@ngbase/adk/datepicker';
12
+ import { RangePipe } from '@ngbase/adk/utils';
13
+ import { Calendar } from './calendar';
14
+
15
+ @Component({
16
+ selector: '<%= name %>-date-picker',
17
+ changeDetection: ChangeDetectionStrategy.OnPush,
18
+ providers: [aliasDatePicker(DatePicker)],
19
+ imports: [Calendar, RangePipe, NgTemplateOutlet, DatepickerGroup],
20
+ template: `
21
+ <div class="flex" ngbDatepickerGroup>
22
+ @for (no of noOfCalendar() | range; track no) {
23
+ <<%= name %>-calendar [first]="$first" [last]="$last" [index]="$index" />
24
+ }
25
+ </div>
26
+ @if (template()) {
27
+ <div class="px-2 pb-2">
28
+ <ng-container *ngTemplateOutlet="template()" />
29
+ </div>
30
+ }
31
+ `,
32
+ host: {
33
+ class: 'inline-block',
34
+ },
35
+ })
36
+ export class DatePicker<D> extends NgbDatePicker<D> {}
37
+
38
+ @Directive({
39
+ selector: '[<%= name %>DatepickerTrigger]',
40
+ exportAs: '<%= name %>DatepickerTrigger',
41
+ providers: [registerDatePicker(DatePicker), aliasDatePickerTrigger(DatepickerTrigger)],
42
+ host: {
43
+ class: 'cursor-pointer hover:bg-muted outline-none w-full bg-transparent',
44
+ },
45
+ })
46
+ export class DatepickerTrigger<D> extends NgbDatepickerTrigger<D> {}
47
+
48
+ @Directive({
49
+ selector: '[<%= name %>EndDate]',
50
+ hostDirectives: [{ directive: NgbEndDate, inputs: ['ngbEndDate: <%= name %>EndDate'] }],
51
+ host: {
52
+ class: 'hidden',
53
+ },
54
+ })
55
+ export class EndDate {
56
+ constructor() {
57
+ inject(NgbEndDate).hidden = true;
58
+ }
59
+ }
@@ -0,0 +1,2 @@
1
+ export * from './datepicker';
2
+ export * from './time';
@@ -0,0 +1,54 @@
1
+ import { ChangeDetectionStrategy, Component } from '@angular/core';
2
+ import { NgbTimeInput, NgbTimePicker, aliasTimePicker } from '@ngbase/adk/datepicker';
3
+ import { Button } from '<%= basepath %>/button';
4
+
5
+ @Component({
6
+ selector: '<%= name %>-time',
7
+ changeDetection: ChangeDetectionStrategy.OnPush,
8
+ providers: [aliasTimePicker(TimePicker)],
9
+ imports: [Button, NgbTimeInput],
10
+ template: `
11
+ <input
12
+ ngbTimeInput="hours"
13
+ [(value)]="hours"
14
+ (valueChange)="updateValue()"
15
+ class="w-7 px-1 text-center font-semibold focus:bg-muted"
16
+ />
17
+ <span>:</span>
18
+ <input
19
+ ngbTimeInput="minutes"
20
+ [(value)]="minutes"
21
+ (valueChange)="updateValue()"
22
+ class="w-7 px-1 text-center font-semibold focus:bg-muted"
23
+ />
24
+ <span>:</span>
25
+ <input
26
+ ngbTimeInput="seconds"
27
+ [(value)]="seconds"
28
+ (valueChange)="updateValue()"
29
+ class="w-7 px-1 text-center font-semibold focus:bg-muted"
30
+ />
31
+ @if (!is24()) {
32
+ <div class="ml-1 flex gap-2">
33
+ <button
34
+ [<%= name %>Button]="am() ? 'primary' : 'ghost'"
35
+ class="small !px-1 !py-0"
36
+ (click)="changeAm(true)"
37
+ >
38
+ AM
39
+ </button>
40
+ <button
41
+ [<%= name %>Button]="!am() ? 'primary' : 'ghost'"
42
+ class="small !px-1 !py-0"
43
+ (click)="changeAm(false)"
44
+ >
45
+ PM
46
+ </button>
47
+ </div>
48
+ }
49
+ `,
50
+ host: {
51
+ class: 'inline-flex gap-1 items-center justify-center',
52
+ },
53
+ })
54
+ export class TimePicker extends NgbTimePicker {}
@@ -0,0 +1,89 @@
1
+ import { ChangeDetectionStrategy, Component, Directive } from '@angular/core';
2
+ import { Button } from '<%= basepath %>/button';
3
+ import { Icon } from '<%= basepath %>/icon';
4
+ import { provideIcons } from '@ng-icons/core';
5
+ import { lucideX } from '@ng-icons/lucide';
6
+ import {
7
+ aliasDialog,
8
+ NgbDialog,
9
+ NgbDialogBackdrop,
10
+ NgbDialogClose,
11
+ NgbDialogContainer,
12
+ NgbDialogMain,
13
+ ngbDialogPortal,
14
+ } from '@ngbase/adk/dialog';
15
+ import { DragMove } from '@ngbase/adk/drag';
16
+
17
+ @Component({
18
+ selector: '<%= name %>-dialog',
19
+ changeDetection: ChangeDetectionStrategy.OnPush,
20
+ providers: [aliasDialog(DialogContainer)],
21
+ viewProviders: [provideIcons({ lucideX })],
22
+ imports: [Button, Icon, DragMove, NgbDialogMain, NgbDialogBackdrop],
23
+ template: `
24
+ <div class="pointer-events-none flex h-full items-center justify-center">
25
+ <div
26
+ #myDialog
27
+ ngbDialogMain
28
+ [@viewAnimation]
29
+ class="{{
30
+ 'pointer-events-auto relative flex max-w-[100vw] flex-col overflow-hidden border bg-background shadow-lg' +
31
+ (options().fullWindow
32
+ ? ' h-screen w-screen border-none'
33
+ : ' max-w-[calc(100vw-30px)] rounded-lg')
34
+ }}"
35
+ >
36
+ @if (!isHideHeader) {
37
+ <div
38
+ class="flex items-center justify-between border-b px-4 py-2"
39
+ ngbDragMove
40
+ [target]="myDialog"
41
+ >
42
+ <h2 class="flex-1 text-base font-bold">{{ options().title }}</h2>
43
+ @if (!options().disableClose) {
44
+ <button <%= name %>Button="ghost" class="-mr-2 !p-2" (click)="close()">
45
+ <<%= name %>-icon name="lucideX" />
46
+ </button>
47
+ }
48
+ </div>
49
+ }
50
+ <div class="h-full overflow-auto p-4">
51
+ <ng-container #contentContainer />
52
+ </div>
53
+ </div>
54
+ @if (showBackdrop()) {
55
+ <div
56
+ class="pointer-events-auto absolute top-0 -z-10 h-full w-full bg-black bg-opacity-30"
57
+ ngbDialogBackdrop
58
+ [@fadeAnimation]
59
+ ></div>
60
+ }
61
+ </div>
62
+ `,
63
+ host: {
64
+ class: 'fixed block top-0 bottom-0 left-0 right-0 overflow-auto pointer-events-none z-p',
65
+ },
66
+ })
67
+ export class DialogContainer extends NgbDialogContainer {}
68
+
69
+ @Directive({
70
+ selector: '[<%= name %>DialogClose]',
71
+ hostDirectives: [NgbDialogClose],
72
+ })
73
+ export class DialogClose {}
74
+
75
+ @Component({
76
+ selector: '[<%= name %>DialogTitle]',
77
+ changeDetection: ChangeDetectionStrategy.OnPush,
78
+ template: `<ng-content />`,
79
+ host: {
80
+ class: 'text-lg font-semibold',
81
+ },
82
+ })
83
+ export class DialogTitle {}
84
+
85
+ export function dialogPortal() {
86
+ return ngbDialogPortal(DialogContainer);
87
+ }
88
+
89
+ export type Dialog = NgbDialog;
@@ -0,0 +1,5 @@
1
+ /*
2
+ * Public API Surface of dialog
3
+ */
4
+
5
+ export * from './dialog';
@@ -0,0 +1,104 @@
1
+ import { animate, state, style, transition, trigger } from '@angular/animations';
2
+ import {
3
+ ChangeDetectionStrategy,
4
+ Component,
5
+ ViewContainerRef,
6
+ afterNextRender,
7
+ viewChild,
8
+ } from '@angular/core';
9
+ import { FocusTrap } from '@ngbase/adk/a11y';
10
+ import { BaseDialog, basePortal, DialogInput, DialogOptions } from '@ngbase/adk/portal';
11
+ import { createHostAnimation, fadeAnimation } from '@ngbase/adk/utils';
12
+
13
+ @Component({
14
+ selector: '<%= name %>-drawer',
15
+ template: `
16
+ <div class="pointer-events-none flex h-full flex-col justify-end">
17
+ <div
18
+ class="pointer-events-auto flex max-h-[90vh] flex-col overflow-hidden rounded-tl-2xl rounded-tr-2xl border-t bg-background p-4 shadow-2xl"
19
+ [@bottomAnimation]
20
+ >
21
+ <button class="bg-muted-foreground mx-auto h-2 w-20 rounded-full"></button>
22
+ @if (!isHideHeader) {
23
+ <div class="flex h-8 items-center">
24
+ <h2 class="flex-1 font-bold">{{ options.title }}</h2>
25
+ <!-- <button <%= name %>Button (click)="close()" class="mr-1"></button> -->
26
+ </div>
27
+ }
28
+ <div class="h-full overflow-auto">
29
+ <ng-container #myDialog />
30
+ </div>
31
+ </div>
32
+ </div>
33
+ @if (backdropColor) {
34
+ <div
35
+ class="absolute top-0 -z-10 h-full w-full bg-black bg-opacity-30"
36
+ [@fadeAnimation]
37
+ (click)="close()"
38
+ ></div>
39
+ }
40
+ `,
41
+ host: {
42
+ class: 'fixed block top-0 bottom-0 left-0 right-0 overflow-hidden z-p',
43
+ '[@parentAnimation]': '',
44
+ '(@parentAnimation.done)': 'animationDone()',
45
+ },
46
+ hostDirectives: [FocusTrap],
47
+ changeDetection: ChangeDetectionStrategy.OnPush,
48
+ animations: [
49
+ createHostAnimation(['@bottomAnimation', '@fadeAnimation']),
50
+ trigger('bottomAnimation', [
51
+ state('1', style({ transform: 'none' })),
52
+ state('void', style({ transform: 'translate3d(0, 100%, 0)' })),
53
+ state('0', style({ transform: 'translate3d(0, 100%, 0)' })),
54
+ transition('* => *', animate('200ms ease')),
55
+ ]),
56
+ fadeAnimation('200ms'),
57
+ ],
58
+ })
59
+ export class DrawerContainer extends BaseDialog {
60
+ myDialog = viewChild('myDialog', { read: ViewContainerRef });
61
+ backdropColor = true;
62
+ options!: DialogOptions;
63
+ classNames = '';
64
+ isHideHeader = false;
65
+
66
+ constructor() {
67
+ super();
68
+ afterNextRender(() => {
69
+ this._afterViewSource.next(this.myDialog()!);
70
+ });
71
+ }
72
+
73
+ override setOptions(options: DialogOptions): void {
74
+ this.options = options;
75
+ this.classNames = this.options.classNames?.join(' ') || '';
76
+ this.isHideHeader = this.options.header || false;
77
+ this.backdropColor = this.options.backdropColor || true;
78
+ }
79
+ }
80
+
81
+ export function drawerPortal() {
82
+ const NAME = 'sheet';
83
+ const base = basePortal(NAME, DrawerContainer);
84
+
85
+ function open<T>(component: DialogInput<T>, opt?: DialogOptions) {
86
+ const { diaRef } = base.open(
87
+ component,
88
+ (comp, options) => {
89
+ comp.instance.setOptions(options);
90
+ },
91
+ opt,
92
+ );
93
+
94
+ const { afterClosed } = diaRef;
95
+ return { afterClosed };
96
+ }
97
+
98
+ function closeAll() {
99
+ base.closeAll();
100
+ }
101
+ return { open, closeAll };
102
+ }
103
+
104
+ export type Drawer = ReturnType<typeof drawerPortal>;
@@ -0,0 +1,5 @@
1
+ /*
2
+ * Public API Surface of drawer
3
+ */
4
+
5
+ export * from './drawer';
@@ -0,0 +1,111 @@
1
+ import {
2
+ ChangeDetectionStrategy,
3
+ Component,
4
+ Directive,
5
+ effect,
6
+ ElementRef,
7
+ inject,
8
+ viewChild,
9
+ } from '@angular/core';
10
+ import {
11
+ InputBase,
12
+ NgbFormField,
13
+ NgbInputError,
14
+ NgbLabel,
15
+ toggleDiv,
16
+ } from '@ngbase/adk/form-field';
17
+ import { InputStyle } from './input-style.directive';
18
+ import { NgbSelectTarget } from '@ngbase/adk/select';
19
+
20
+ @Component({
21
+ selector: '<%= name %>-form-field, [<%= name %>FormField]',
22
+ changeDetection: ChangeDetectionStrategy.OnPush,
23
+ hostDirectives: [NgbFormField, NgbSelectTarget],
24
+ imports: [InputStyle],
25
+ template: `
26
+ <ng-content select="[<%= name %>Label]" />
27
+ <ng-content select="[<%= name %>Description]" />
28
+ <div class="mt-1 flex items-center" #target <%= name %>InputStyle>
29
+ <ng-content select="[<%= name %>Prefix]" />
30
+ <ng-content />
31
+ <ng-content select="[<%= name %>Suffix]" />
32
+ </div>
33
+ <ng-content select="[<%= name %>Error]" />
34
+ `,
35
+ host: {
36
+ class: 'inline-flex flex-col font-medium gap-1',
37
+ },
38
+ })
39
+ export class FormField {
40
+ readonly selectTarget = inject(NgbSelectTarget);
41
+ readonly target = viewChild.required<ElementRef<HTMLDivElement>>('target');
42
+ private _ = effect(() => {
43
+ this.selectTarget.target.set(this.target().nativeElement);
44
+ });
45
+ }
46
+
47
+ @Directive({
48
+ selector: '[<%= name %>Input]',
49
+ hostDirectives: [{ directive: InputBase, inputs: ['value'], outputs: ['valueChange'] }],
50
+ host: {
51
+ class: 'outline-none w-full bg-transparent',
52
+ '[class.border-red-500]': 'formField?.hasErrors()',
53
+ },
54
+ })
55
+ export class Input {
56
+ readonly formField = inject(NgbFormField, { optional: true });
57
+ }
58
+
59
+ @Component({
60
+ selector: '[<%= name %>Label]',
61
+ changeDetection: ChangeDetectionStrategy.OnPush,
62
+ hostDirectives: [NgbLabel],
63
+ template: `<ng-content />`,
64
+ host: {
65
+ class: 'block font-medium mx-0.5',
66
+ },
67
+ })
68
+ export class Label {}
69
+
70
+ @Directive({
71
+ selector: '[<%= name %>Description]',
72
+ host: {
73
+ class: 'text-sm text-muted-foreground',
74
+ },
75
+ })
76
+ export class Description {}
77
+
78
+ @Directive({
79
+ selector: '[<%= name %>Prefix]',
80
+ host: {
81
+ class: 'mr-2.5',
82
+ },
83
+ })
84
+ export class InputPrefix {}
85
+
86
+ @Directive({
87
+ selector: '[<%= name %>Suffix]',
88
+ host: {
89
+ class: 'ml-2.5',
90
+ },
91
+ })
92
+ export class InputSuffix {}
93
+
94
+ @Component({
95
+ selector: '[<%= name %>Error]',
96
+ hostDirectives: [{ directive: NgbInputError, inputs: ['ngbError: <%= name %>Error'] }],
97
+ template: `<ng-content />`,
98
+ host: {
99
+ class: 'text-red-500 mx-0.5',
100
+ '[@toggleDiv]': 'isInvalid() ? "visible" : "hidden"',
101
+ },
102
+ animations: [toggleDiv],
103
+ })
104
+ export class InputError {
105
+ readonly error = inject(NgbInputError);
106
+ readonly isInvalid = this.error.isInvalid;
107
+
108
+ constructor() {
109
+ this.error.animate.set(true);
110
+ }
111
+ }
@@ -0,0 +1,6 @@
1
+ /*
2
+ * Public API Surface of input
3
+ */
4
+
5
+ export * from './form-field';
6
+ export * from './input-style.directive';
@@ -0,0 +1,11 @@
1
+ import { Directive } from '@angular/core';
2
+ import { ɵFocusStyle as FocusStyle } from '<%= basepath %>/checkbox';
3
+
4
+ @Directive({
5
+ selector: '[<%= name %>InputStyle]',
6
+ hostDirectives: [{ directive: FocusStyle, inputs: ['unfocus'] }],
7
+ host: {
8
+ class: 'inline-block rounded-lg bg-transparent px-2.5 py-2 border font-normal min-h-10',
9
+ },
10
+ })
11
+ export class InputStyle {}
@@ -0,0 +1,13 @@
1
+ import { Directive } from '@angular/core';
2
+ import { NgbHoverCard } from '@ngbase/adk/hover-card';
3
+
4
+ @Directive({
5
+ selector: '[<%= name %>HoverCard]',
6
+ hostDirectives: [
7
+ {
8
+ directive: NgbHoverCard,
9
+ inputs: ['ngbHoverCard: <%= name %>HoverCard', 'options', 'delay'],
10
+ },
11
+ ],
12
+ })
13
+ export class HoverCard<T = any> {}
@@ -0,0 +1,5 @@
1
+ /*
2
+ * Public API Surface of hover-card
3
+ */
4
+
5
+ export * from './hover-card';