@ngbase/adk 0.1.3 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +13 -13
- package/schematics/collection.json +15 -0
- package/schematics/components/files/accordion/accordion.ts.template +53 -0
- package/schematics/components/files/accordion/index.ts.template +5 -0
- package/schematics/components/files/alert/alert.ts.template +62 -0
- package/schematics/components/files/alert/index.ts.template +1 -0
- package/schematics/components/files/autocomplete/autocomplete.ts.template +44 -0
- package/schematics/components/files/autocomplete/index.ts.template +5 -0
- package/schematics/components/files/avatar/avatar.ts.template +31 -0
- package/schematics/components/files/avatar/index.ts.template +1 -0
- package/schematics/components/files/badge/badge.ts.template +11 -0
- package/schematics/components/files/badge/index.ts.template +1 -0
- package/schematics/components/files/breadcrumb/breadcrumb.ts.template +53 -0
- package/schematics/components/files/breadcrumb/index.ts.template +1 -0
- package/schematics/components/files/button/button.ts.template +29 -0
- package/schematics/components/files/button/index.ts.template +5 -0
- package/schematics/components/files/card/card.ts.template +11 -0
- package/schematics/components/files/card/index.ts.template +5 -0
- package/schematics/components/files/carousel/carousel.ts.template +44 -0
- package/schematics/components/files/carousel/index.ts.template +1 -0
- package/schematics/components/files/checkbox/checkbox.ts.template +36 -0
- package/schematics/components/files/checkbox/focus-style.directive.ts.template +12 -0
- package/schematics/components/files/checkbox/index.ts.template +6 -0
- package/schematics/components/files/chip/chip.ts.template +38 -0
- package/schematics/components/files/chip/index.ts.template +1 -0
- package/schematics/components/files/color-picker/color-picker.ts.template +104 -0
- package/schematics/components/files/color-picker/index.ts.template +5 -0
- package/schematics/components/files/command/command.ts.template +82 -0
- package/schematics/components/files/command/index.ts.template +1 -0
- package/schematics/components/files/datepicker/calendar.ts.template +117 -0
- package/schematics/components/files/datepicker/datepicker.ts.template +59 -0
- package/schematics/components/files/datepicker/index.ts.template +2 -0
- package/schematics/components/files/datepicker/time.ts.template +54 -0
- package/schematics/components/files/dialog/dialog.ts.template +89 -0
- package/schematics/components/files/dialog/index.ts.template +5 -0
- package/schematics/components/files/drawer/drawer.ts.template +104 -0
- package/schematics/components/files/drawer/index.ts.template +5 -0
- package/schematics/components/files/form-field/form-field.ts.template +111 -0
- package/schematics/components/files/form-field/index.ts.template +6 -0
- package/schematics/components/files/form-field/input-style.directive.ts.template +11 -0
- package/schematics/components/files/hover-card/hover-card.ts.template +13 -0
- package/schematics/components/files/hover-card/index.ts.template +5 -0
- package/schematics/components/files/icon/icon.ts.template +16 -0
- package/schematics/components/files/icon/index.ts.template +1 -0
- package/schematics/components/files/inline-edit/index.ts.template +1 -0
- package/schematics/components/files/inline-edit/inline-edit.ts.template +24 -0
- package/schematics/components/files/keys/index.ts.template +5 -0
- package/schematics/components/files/keys/key.ts.template +35 -0
- package/schematics/components/files/list/index.ts.template +5 -0
- package/schematics/components/files/list/list.ts.template +28 -0
- package/schematics/components/files/mask/index.ts.template +1 -0
- package/schematics/components/files/mask/mask.ts.template +8 -0
- package/schematics/components/files/menu/context-menu.ts.template +14 -0
- package/schematics/components/files/menu/index.ts.template +8 -0
- package/schematics/components/files/menu/mention.ts.template +14 -0
- package/schematics/components/files/menu/menu.ts.template +37 -0
- package/schematics/components/files/menu/navigation-menu.ts.template +8 -0
- package/schematics/components/files/otp/index.ts.template +5 -0
- package/schematics/components/files/otp/otp.ts.template +37 -0
- package/schematics/components/files/pagination/index.ts.template +1 -0
- package/schematics/components/files/pagination/pagination.ts.template +75 -0
- package/schematics/components/files/picasa/index.ts.template +1 -0
- package/schematics/components/files/picasa/picasa-base.component.ts.template +80 -0
- package/schematics/components/files/picasa/picasa.component.ts.template +57 -0
- package/schematics/components/files/picasa/picasa.directive.ts.template +41 -0
- package/schematics/components/files/picasa/picase.service.ts.template +24 -0
- package/schematics/components/files/popover/index.ts.template +1 -0
- package/schematics/components/files/popover/popover.ts.template +64 -0
- package/schematics/components/files/progress/index.ts.template +5 -0
- package/schematics/components/files/progress/progress.ts.template +14 -0
- package/schematics/components/files/radio/index.ts.template +5 -0
- package/schematics/components/files/radio/radio.ts.template +37 -0
- package/schematics/components/files/resizable/index.ts.template +5 -0
- package/schematics/components/files/resizable/resizable.ts.template +59 -0
- package/schematics/components/files/scroll-area/index.ts.template +1 -0
- package/schematics/components/files/scroll-area/scroll-area.ts.template +40 -0
- package/schematics/components/files/select/index.ts.template +8 -0
- package/schematics/components/files/select/list-selection.ts.template +15 -0
- package/schematics/components/files/select/option.ts.template +35 -0
- package/schematics/components/files/select/select-input.ts.template +21 -0
- package/schematics/components/files/select/select.ts.template +96 -0
- package/schematics/components/files/selectable/index.ts.template +1 -0
- package/schematics/components/files/selectable/selectable.ts.template +34 -0
- package/schematics/components/files/separator/index.ts.template +5 -0
- package/schematics/components/files/separator/separator.ts.template +19 -0
- package/schematics/components/files/sheet/index.ts.template +5 -0
- package/schematics/components/files/sheet/sheet.ts.template +69 -0
- package/schematics/components/files/sidenav/index.ts.template +1 -0
- package/schematics/components/files/sidenav/sidenav.ts.template +48 -0
- package/schematics/components/files/skeleton/index.ts.template +1 -0
- package/schematics/components/files/skeleton/skeleton.ts.template +15 -0
- package/schematics/components/files/slider/index.ts.template +5 -0
- package/schematics/components/files/slider/slider.ts.template +35 -0
- package/schematics/components/files/sonner/index.ts.template +5 -0
- package/schematics/components/files/sonner/sonner.ts.template +59 -0
- package/schematics/components/files/spinner/index.ts.template +1 -0
- package/schematics/components/files/spinner/spinner.ts.template +79 -0
- package/schematics/components/files/stepper/index.ts.template +1 -0
- package/schematics/components/files/stepper/stepper.ts.template +88 -0
- package/schematics/components/files/switch/index.ts.template +5 -0
- package/schematics/components/files/switch/switch.ts.template +29 -0
- package/schematics/components/files/table/index.ts.template +27 -0
- package/schematics/components/files/table/table.ts.template +122 -0
- package/schematics/components/files/tabs/index.ts.template +5 -0
- package/schematics/components/files/tabs/tab.ts.template +92 -0
- package/schematics/components/files/theme/index.ts.template +2 -0
- package/schematics/components/files/theme/theme-button.component.ts.template +26 -0
- package/schematics/components/files/theme/theme.service.ts.template +33 -0
- package/schematics/components/files/toggle/index.ts.template +5 -0
- package/schematics/components/files/toggle/toggle.ts.template +13 -0
- package/schematics/components/files/toggle-group/index.ts.template +5 -0
- package/schematics/components/files/toggle-group/toggle-group.ts.template +25 -0
- package/schematics/components/files/tooltip/index.ts.template +5 -0
- package/schematics/components/files/tooltip/tooltip.ts.template +45 -0
- package/schematics/components/files/tour/index.ts.template +1 -0
- package/schematics/components/files/tour/tour.ts.template +19 -0
- package/schematics/components/files/tree/index.ts.template +1 -0
- package/schematics/components/files/tree/tree.ts.template +66 -0
- package/schematics/components/index.d.ts +3 -0
- package/schematics/components/index.js +23 -0
- package/schematics/components/index.js.map +1 -0
- package/schematics/components/index.ts +39 -0
- package/schematics/components/schema.d.ts +6 -0
- package/schematics/components/schema.js +3 -0
- package/schematics/components/schema.js.map +1 -0
- package/schematics/components/schema.json +142 -0
- package/schematics/components/schema.ts +6 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component } from '@angular/core';
|
|
2
|
+
import {
|
|
3
|
+
ColorAlpha,
|
|
4
|
+
ColorAlphaThumb,
|
|
5
|
+
ColorHue,
|
|
6
|
+
ColorHueThumb,
|
|
7
|
+
ColorPickerTrigger,
|
|
8
|
+
ColorSelected,
|
|
9
|
+
ColorSpectrum,
|
|
10
|
+
ColorSpectrumSelector,
|
|
11
|
+
NgbColorInput,
|
|
12
|
+
NgbColorPicker,
|
|
13
|
+
registerColorPicker,
|
|
14
|
+
} from '@ngbase/adk/color-picker';
|
|
15
|
+
import { InputBase } from '@ngbase/adk/form-field';
|
|
16
|
+
|
|
17
|
+
@Component({
|
|
18
|
+
selector: '<%= name %>-color-picker-container',
|
|
19
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
20
|
+
imports: [
|
|
21
|
+
ColorSpectrum,
|
|
22
|
+
ColorSpectrumSelector,
|
|
23
|
+
ColorSelected,
|
|
24
|
+
ColorHue,
|
|
25
|
+
ColorHueThumb,
|
|
26
|
+
ColorAlpha,
|
|
27
|
+
ColorAlphaThumb,
|
|
28
|
+
],
|
|
29
|
+
template: `
|
|
30
|
+
<div class="flex w-full flex-col">
|
|
31
|
+
<div ngbColorSpectrum class="relative h-[160px] w-full overflow-hidden rounded-md border-b">
|
|
32
|
+
<button
|
|
33
|
+
ngbColorSpectrumSelector
|
|
34
|
+
class="pointer-events-none absolute -left-2 -top-2 h-4 w-4 cursor-pointer rounded-full border"
|
|
35
|
+
></button>
|
|
36
|
+
</div>
|
|
37
|
+
<div class="flex gap-4 p-3">
|
|
38
|
+
<div ngbColorSelected class="aspect-square w-10 rounded-md border bg-slate-500"></div>
|
|
39
|
+
<div class="flex flex-1 flex-col gap-4">
|
|
40
|
+
<div ngbColorHue class="relative h-3">
|
|
41
|
+
<button
|
|
42
|
+
ngbColorHueThumb
|
|
43
|
+
class="border-red pointer-events-none absolute -top-1 h-5 w-5 -translate-x-2.5 cursor-pointer rounded-full border-2"
|
|
44
|
+
></button>
|
|
45
|
+
</div>
|
|
46
|
+
|
|
47
|
+
<div ngbColorAlpha class="relative h-3">
|
|
48
|
+
<button
|
|
49
|
+
ngbColorAlphaThumb
|
|
50
|
+
class="alpha-selector border-red pointer-events-none absolute -top-1 h-5 w-5 -translate-x-2.5 cursor-pointer rounded-full border-2"
|
|
51
|
+
></button>
|
|
52
|
+
</div>
|
|
53
|
+
</div>
|
|
54
|
+
</div>
|
|
55
|
+
@if (presetColors().length) {
|
|
56
|
+
<div class="flex flex-wrap gap-2 border-t p-2 pt-3">
|
|
57
|
+
@for (color of presetColors(); track color) {
|
|
58
|
+
<button
|
|
59
|
+
type="button"
|
|
60
|
+
class="aspect-square w-4 rounded-md border"
|
|
61
|
+
[style.backgroundColor]="color"
|
|
62
|
+
(click)="setValue(color, true)"
|
|
63
|
+
></button>
|
|
64
|
+
}
|
|
65
|
+
</div>
|
|
66
|
+
}
|
|
67
|
+
</div>
|
|
68
|
+
`,
|
|
69
|
+
host: {
|
|
70
|
+
class: 'inline-block min-w-[245px]',
|
|
71
|
+
},
|
|
72
|
+
})
|
|
73
|
+
export class ColorPicker extends NgbColorPicker {}
|
|
74
|
+
|
|
75
|
+
@Component({
|
|
76
|
+
selector: '<%= name %>-color-input',
|
|
77
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
78
|
+
providers: [registerColorPicker({ picker: ColorPicker, accessor: ColorInput })],
|
|
79
|
+
imports: [ColorPickerTrigger, InputBase],
|
|
80
|
+
template: `
|
|
81
|
+
<input
|
|
82
|
+
ngbInputBase
|
|
83
|
+
type="text"
|
|
84
|
+
[value]="value()"
|
|
85
|
+
(valueChange)="updateValue($event)"
|
|
86
|
+
class="w-full flex-1 bg-transparent outline-none"
|
|
87
|
+
/>
|
|
88
|
+
<button
|
|
89
|
+
#color
|
|
90
|
+
type="button"
|
|
91
|
+
ngbColorPickerTrigger
|
|
92
|
+
[value]="value()"
|
|
93
|
+
[format]="format()"
|
|
94
|
+
[presetColors]="presetColors()"
|
|
95
|
+
(valueChange)="updateValue($event)"
|
|
96
|
+
class="h-5 w-5 flex-none rounded-full border"
|
|
97
|
+
[style.backgroundColor]="value()"
|
|
98
|
+
></button>
|
|
99
|
+
`,
|
|
100
|
+
host: {
|
|
101
|
+
class: '!inline-flex gap-2 items-center',
|
|
102
|
+
},
|
|
103
|
+
})
|
|
104
|
+
export class ColorInput extends NgbColorInput {}
|
|
@@ -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,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,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>;
|