@nanahoshi/mona-ui 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -0
- package/fesm2022/nanahoshi-mona-ui-auto-complete.mjs +590 -0
- package/fesm2022/nanahoshi-mona-ui-avatar.mjs +168 -0
- package/fesm2022/nanahoshi-mona-ui-breadcrumb.mjs +220 -0
- package/fesm2022/nanahoshi-mona-ui-button-group.mjs +225 -0
- package/fesm2022/nanahoshi-mona-ui-button.mjs +497 -0
- package/fesm2022/nanahoshi-mona-ui-calendar.mjs +1569 -0
- package/fesm2022/nanahoshi-mona-ui-check-box.mjs +339 -0
- package/fesm2022/nanahoshi-mona-ui-chip.mjs +453 -0
- package/fesm2022/nanahoshi-mona-ui-circular-progress-bar.mjs +200 -0
- package/fesm2022/nanahoshi-mona-ui-color-gradient.mjs +853 -0
- package/fesm2022/nanahoshi-mona-ui-color-palette.mjs +923 -0
- package/fesm2022/nanahoshi-mona-ui-color-picker.mjs +495 -0
- package/fesm2022/nanahoshi-mona-ui-combo-box.mjs +686 -0
- package/fesm2022/nanahoshi-mona-ui-common.mjs +642 -0
- package/fesm2022/nanahoshi-mona-ui-contextmenu.mjs +485 -0
- package/fesm2022/nanahoshi-mona-ui-date-input.mjs +132 -0
- package/fesm2022/nanahoshi-mona-ui-date-picker.mjs +460 -0
- package/fesm2022/nanahoshi-mona-ui-datetime-picker.mjs +659 -0
- package/fesm2022/nanahoshi-mona-ui-dialog.mjs +828 -0
- package/fesm2022/nanahoshi-mona-ui-dropdown-button.mjs +523 -0
- package/fesm2022/nanahoshi-mona-ui-dropdown-list.mjs +615 -0
- package/fesm2022/nanahoshi-mona-ui-dropdowns.mjs +701 -0
- package/fesm2022/nanahoshi-mona-ui-editor.mjs +1400 -0
- package/fesm2022/nanahoshi-mona-ui-expansion-panel.mjs +245 -0
- package/fesm2022/nanahoshi-mona-ui-fieldset.mjs +170 -0
- package/fesm2022/nanahoshi-mona-ui-filter.mjs +680 -0
- package/fesm2022/nanahoshi-mona-ui-grid-grid-footer-cell.component-B9SQH5N-.mjs +105 -0
- package/fesm2022/nanahoshi-mona-ui-grid-grid-footer-table-cell.directive-DlLwcCFT.mjs +42 -0
- package/fesm2022/nanahoshi-mona-ui-grid-grid-list.component-Dgea-O0X.mjs +130 -0
- package/fesm2022/nanahoshi-mona-ui-grid-grid-toggle.component-DIUutx9s.mjs +773 -0
- package/fesm2022/nanahoshi-mona-ui-grid-grid-virtual-list.component-DRHycGIh.mjs +240 -0
- package/fesm2022/nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-C3eZIaJK.mjs +5374 -0
- package/fesm2022/nanahoshi-mona-ui-grid.mjs +2 -0
- package/fesm2022/nanahoshi-mona-ui-internal-filter-input.mjs +87 -0
- package/fesm2022/nanahoshi-mona-ui-internal-indicator-icon.mjs +154 -0
- package/fesm2022/nanahoshi-mona-ui-internal-list.mjs +1356 -0
- package/fesm2022/nanahoshi-mona-ui-internal-tree.mjs +2263 -0
- package/fesm2022/nanahoshi-mona-ui-internal.mjs +379 -0
- package/fesm2022/nanahoshi-mona-ui-list-box.mjs +630 -0
- package/fesm2022/nanahoshi-mona-ui-list-view.mjs +527 -0
- package/fesm2022/nanahoshi-mona-ui-list.mjs +4 -0
- package/fesm2022/nanahoshi-mona-ui-menubar.mjs +966 -0
- package/fesm2022/nanahoshi-mona-ui-multi-select.mjs +641 -0
- package/fesm2022/nanahoshi-mona-ui-notification.mjs +536 -0
- package/fesm2022/nanahoshi-mona-ui-numeric-text-box.mjs +597 -0
- package/fesm2022/nanahoshi-mona-ui-pager.mjs +790 -0
- package/fesm2022/nanahoshi-mona-ui-placeholder.mjs +83 -0
- package/fesm2022/nanahoshi-mona-ui-popover.mjs +325 -0
- package/fesm2022/nanahoshi-mona-ui-popup-menu.mjs +1559 -0
- package/fesm2022/nanahoshi-mona-ui-popup.mjs +1321 -0
- package/fesm2022/nanahoshi-mona-ui-progress-bar.mjs +294 -0
- package/fesm2022/nanahoshi-mona-ui-query.mjs +175 -0
- package/fesm2022/nanahoshi-mona-ui-radio-button.mjs +339 -0
- package/fesm2022/nanahoshi-mona-ui-scroll-view.mjs +565 -0
- package/fesm2022/nanahoshi-mona-ui-slider.mjs +1049 -0
- package/fesm2022/nanahoshi-mona-ui-split-button.mjs +636 -0
- package/fesm2022/nanahoshi-mona-ui-splitter.mjs +843 -0
- package/fesm2022/nanahoshi-mona-ui-stepper.mjs +537 -0
- package/fesm2022/nanahoshi-mona-ui-switch.mjs +308 -0
- package/fesm2022/nanahoshi-mona-ui-tabs.mjs +664 -0
- package/fesm2022/nanahoshi-mona-ui-text-area.mjs +111 -0
- package/fesm2022/nanahoshi-mona-ui-text-box.mjs +369 -0
- package/fesm2022/nanahoshi-mona-ui-theme.mjs +314 -0
- package/fesm2022/nanahoshi-mona-ui-time-picker.mjs +450 -0
- package/fesm2022/nanahoshi-mona-ui-time-selector.mjs +723 -0
- package/fesm2022/nanahoshi-mona-ui-tooltip.mjs +716 -0
- package/fesm2022/nanahoshi-mona-ui-tree-view.mjs +733 -0
- package/fesm2022/nanahoshi-mona-ui-window.mjs +1329 -0
- package/fesm2022/nanahoshi-mona-ui.mjs +9 -0
- package/package.json +289 -0
- package/types/nanahoshi-mona-ui-auto-complete.d.ts +223 -0
- package/types/nanahoshi-mona-ui-avatar.d.ts +642 -0
- package/types/nanahoshi-mona-ui-breadcrumb.d.ts +70 -0
- package/types/nanahoshi-mona-ui-button-group.d.ts +77 -0
- package/types/nanahoshi-mona-ui-button.d.ts +111 -0
- package/types/nanahoshi-mona-ui-calendar.d.ts +262 -0
- package/types/nanahoshi-mona-ui-check-box.d.ts +133 -0
- package/types/nanahoshi-mona-ui-chip.d.ts +130 -0
- package/types/nanahoshi-mona-ui-circular-progress-bar.d.ts +113 -0
- package/types/nanahoshi-mona-ui-color-gradient.d.ts +201 -0
- package/types/nanahoshi-mona-ui-color-palette.d.ts +102 -0
- package/types/nanahoshi-mona-ui-color-picker.d.ts +156 -0
- package/types/nanahoshi-mona-ui-combo-box.d.ts +232 -0
- package/types/nanahoshi-mona-ui-common.d.ts +386 -0
- package/types/nanahoshi-mona-ui-contextmenu.d.ts +129 -0
- package/types/nanahoshi-mona-ui-date-input.d.ts +60 -0
- package/types/nanahoshi-mona-ui-date-picker.d.ts +177 -0
- package/types/nanahoshi-mona-ui-datetime-picker.d.ts +199 -0
- package/types/nanahoshi-mona-ui-dialog.d.ts +261 -0
- package/types/nanahoshi-mona-ui-dropdown-button.d.ts +159 -0
- package/types/nanahoshi-mona-ui-dropdown-list.d.ts +219 -0
- package/types/nanahoshi-mona-ui-dropdowns.d.ts +176 -0
- package/types/nanahoshi-mona-ui-editor.d.ts +113 -0
- package/types/nanahoshi-mona-ui-expansion-panel.d.ts +87 -0
- package/types/nanahoshi-mona-ui-fieldset.d.ts +68 -0
- package/types/nanahoshi-mona-ui-filter.d.ts +115 -0
- package/types/nanahoshi-mona-ui-grid.d.ts +1114 -0
- package/types/nanahoshi-mona-ui-internal-filter-input.d.ts +25 -0
- package/types/nanahoshi-mona-ui-internal-indicator-icon.d.ts +28 -0
- package/types/nanahoshi-mona-ui-internal-list.d.ts +269 -0
- package/types/nanahoshi-mona-ui-internal-tree.d.ts +391 -0
- package/types/nanahoshi-mona-ui-internal.d.ts +136 -0
- package/types/nanahoshi-mona-ui-list-box.d.ts +225 -0
- package/types/nanahoshi-mona-ui-list-view.d.ts +188 -0
- package/types/nanahoshi-mona-ui-list.d.ts +1 -0
- package/types/nanahoshi-mona-ui-menubar.d.ts +198 -0
- package/types/nanahoshi-mona-ui-multi-select.d.ts +247 -0
- package/types/nanahoshi-mona-ui-notification.d.ts +106 -0
- package/types/nanahoshi-mona-ui-numeric-text-box.d.ts +161 -0
- package/types/nanahoshi-mona-ui-pager.d.ts +238 -0
- package/types/nanahoshi-mona-ui-placeholder.d.ts +35 -0
- package/types/nanahoshi-mona-ui-popover.d.ts +130 -0
- package/types/nanahoshi-mona-ui-popup-menu.d.ts +412 -0
- package/types/nanahoshi-mona-ui-popup.d.ts +485 -0
- package/types/nanahoshi-mona-ui-progress-bar.d.ts +139 -0
- package/types/nanahoshi-mona-ui-query.d.ts +89 -0
- package/types/nanahoshi-mona-ui-radio-button.d.ts +128 -0
- package/types/nanahoshi-mona-ui-scroll-view.d.ts +166 -0
- package/types/nanahoshi-mona-ui-slider.d.ts +305 -0
- package/types/nanahoshi-mona-ui-split-button.d.ts +182 -0
- package/types/nanahoshi-mona-ui-splitter.d.ts +70 -0
- package/types/nanahoshi-mona-ui-stepper.d.ts +173 -0
- package/types/nanahoshi-mona-ui-switch.d.ts +125 -0
- package/types/nanahoshi-mona-ui-tabs.d.ts +158 -0
- package/types/nanahoshi-mona-ui-text-area.d.ts +42 -0
- package/types/nanahoshi-mona-ui-text-box.d.ts +164 -0
- package/types/nanahoshi-mona-ui-theme.d.ts +23 -0
- package/types/nanahoshi-mona-ui-time-picker.d.ts +184 -0
- package/types/nanahoshi-mona-ui-time-selector.d.ts +143 -0
- package/types/nanahoshi-mona-ui-tooltip.d.ts +130 -0
- package/types/nanahoshi-mona-ui-tree-view.d.ts +274 -0
- package/types/nanahoshi-mona-ui-window.d.ts +295 -0
- package/types/nanahoshi-mona-ui.d.ts +2 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { inject, computed, input, Component } from '@angular/core';
|
|
3
|
+
import { ThemeService } from '@nanahoshi/mona-ui/theme';
|
|
4
|
+
import { twMerge } from 'tailwind-merge';
|
|
5
|
+
import { cva } from 'class-variance-authority';
|
|
6
|
+
|
|
7
|
+
const placeholderBaseVariants = cva(`
|
|
8
|
+
flex items-center justify-center
|
|
9
|
+
w-full h-full
|
|
10
|
+
p-2
|
|
11
|
+
`);
|
|
12
|
+
const placeholderTextVariants = cva(`
|
|
13
|
+
text-muted-foreground
|
|
14
|
+
uppercase
|
|
15
|
+
`);
|
|
16
|
+
|
|
17
|
+
const placeholderBaseThemeVariants = (theme) => {
|
|
18
|
+
switch (theme) {
|
|
19
|
+
case "mona":
|
|
20
|
+
return placeholderBaseVariants;
|
|
21
|
+
default:
|
|
22
|
+
return placeholderBaseVariants;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
const placeholderTextThemeVariants = (theme) => {
|
|
26
|
+
switch (theme) {
|
|
27
|
+
case "mona":
|
|
28
|
+
return placeholderTextVariants;
|
|
29
|
+
default:
|
|
30
|
+
return placeholderTextVariants;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
class PlaceholderComponent {
|
|
35
|
+
constructor() {
|
|
36
|
+
this.#themeService = inject(ThemeService);
|
|
37
|
+
this.baseClass = computed(() => {
|
|
38
|
+
const theme = this.#themeService.theme();
|
|
39
|
+
const variantClass = placeholderBaseThemeVariants(theme)();
|
|
40
|
+
const userClass = this.userClass();
|
|
41
|
+
return twMerge(variantClass, userClass);
|
|
42
|
+
}, /* @ts-ignore */
|
|
43
|
+
...(ngDevMode ? [{ debugName: "baseClass" }] : /* istanbul ignore next */ []));
|
|
44
|
+
this.textClass = computed(() => {
|
|
45
|
+
const theme = this.#themeService.theme();
|
|
46
|
+
return placeholderTextThemeVariants(theme)();
|
|
47
|
+
}, /* @ts-ignore */
|
|
48
|
+
...(ngDevMode ? [{ debugName: "textClass" }] : /* istanbul ignore next */ []));
|
|
49
|
+
/**
|
|
50
|
+
* @description The text to display inside the placeholder.
|
|
51
|
+
* Takes precedence over projected content if both are provided.
|
|
52
|
+
* @default ""
|
|
53
|
+
*/
|
|
54
|
+
this.text = input("", /* @ts-ignore */
|
|
55
|
+
...(ngDevMode ? [{ debugName: "text" }] : /* istanbul ignore next */ []));
|
|
56
|
+
/**
|
|
57
|
+
* @description Additional CSS classes merged onto the host element via `tailwind-merge`.
|
|
58
|
+
* Bind this input with the public `class` alias.
|
|
59
|
+
* @default ""
|
|
60
|
+
*/
|
|
61
|
+
this.userClass = input("", { ...(ngDevMode ? { debugName: "userClass" } : /* istanbul ignore next */ {}), alias: "class" });
|
|
62
|
+
}
|
|
63
|
+
#themeService;
|
|
64
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: PlaceholderComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
65
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: PlaceholderComponent, isStandalone: true, selector: "mona-placeholder", inputs: { text: { classPropertyName: "text", publicName: "text", isSignal: true, isRequired: false, transformFunction: null }, userClass: { classPropertyName: "userClass", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "baseClass()" } }, ngImport: i0, template: "@if (text()) {\r\n <span [class]=\"textClass()\">{{ text() }}</span>\r\n} @else {\r\n <ng-content></ng-content>\r\n}\r\n" }); }
|
|
66
|
+
}
|
|
67
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: PlaceholderComponent, decorators: [{
|
|
68
|
+
type: Component,
|
|
69
|
+
args: [{ selector: "mona-placeholder", host: {
|
|
70
|
+
"[class]": "baseClass()"
|
|
71
|
+
}, template: "@if (text()) {\r\n <span [class]=\"textClass()\">{{ text() }}</span>\r\n} @else {\r\n <ng-content></ng-content>\r\n}\r\n" }]
|
|
72
|
+
}], propDecorators: { text: [{ type: i0.Input, args: [{ isSignal: true, alias: "text", required: false }] }], userClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
73
|
+
|
|
74
|
+
/*
|
|
75
|
+
* Public API Surface of @nanahoshi/mona-ui/placeholder
|
|
76
|
+
*/
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Generated bundle index. Do not edit.
|
|
80
|
+
*/
|
|
81
|
+
|
|
82
|
+
export { PlaceholderComponent };
|
|
83
|
+
//# sourceMappingURL=nanahoshi-mona-ui-placeholder.mjs.map
|
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
import { NgTemplateOutlet } from '@angular/common';
|
|
2
|
+
import * as i0 from '@angular/core';
|
|
3
|
+
import { Directive, inject, DestroyRef, Renderer2, computed, contentChild, TemplateRef, viewChild, input, output, effect, ElementRef, Component } from '@angular/core';
|
|
4
|
+
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
5
|
+
import { PopupService, fadePopupAnimation } from '@nanahoshi/mona-ui/popup';
|
|
6
|
+
import { ThemeService } from '@nanahoshi/mona-ui/theme';
|
|
7
|
+
import { tooltipArrowThemeVariants, getPositionConnectionPoints, getOffsetForPosition } from '@nanahoshi/mona-ui/tooltip';
|
|
8
|
+
import { takeUntil, take, fromEvent, filter, tap } from 'rxjs';
|
|
9
|
+
import { twMerge } from 'tailwind-merge';
|
|
10
|
+
import { v4 } from 'uuid';
|
|
11
|
+
import { PreventableEvent } from '@nanahoshi/mona-ui/common';
|
|
12
|
+
import { cva } from 'class-variance-authority';
|
|
13
|
+
|
|
14
|
+
class PopoverFooterTemplateDirective {
|
|
15
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: PopoverFooterTemplateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
16
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: PopoverFooterTemplateDirective, isStandalone: true, selector: "ng-template[monaPopoverFooterTemplate]", ngImport: i0 }); }
|
|
17
|
+
}
|
|
18
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: PopoverFooterTemplateDirective, decorators: [{
|
|
19
|
+
type: Directive,
|
|
20
|
+
args: [{
|
|
21
|
+
selector: "ng-template[monaPopoverFooterTemplate]"
|
|
22
|
+
}]
|
|
23
|
+
}] });
|
|
24
|
+
|
|
25
|
+
class PopoverTitleTemplateDirective {
|
|
26
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: PopoverTitleTemplateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
27
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: PopoverTitleTemplateDirective, isStandalone: true, selector: "ng-template[monaPopoverTitleTemplate]", ngImport: i0 }); }
|
|
28
|
+
}
|
|
29
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: PopoverTitleTemplateDirective, decorators: [{
|
|
30
|
+
type: Directive,
|
|
31
|
+
args: [{
|
|
32
|
+
selector: "ng-template[monaPopoverTitleTemplate]"
|
|
33
|
+
}]
|
|
34
|
+
}] });
|
|
35
|
+
|
|
36
|
+
class PopoverHideEvent extends PreventableEvent {
|
|
37
|
+
constructor(target, popupRef) {
|
|
38
|
+
super("popoverHide");
|
|
39
|
+
this.target = target;
|
|
40
|
+
this.popupRef = popupRef;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
class PopoverShowEvent extends PreventableEvent {
|
|
45
|
+
constructor(target) {
|
|
46
|
+
super("popoverShow");
|
|
47
|
+
this.target = target;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
class PopoverShownEvent {
|
|
52
|
+
constructor(target, popupRef) {
|
|
53
|
+
this.target = target;
|
|
54
|
+
this.popupRef = popupRef;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const popoverBaseVariants = cva(`
|
|
59
|
+
flex flex-col items-center justify-center relative
|
|
60
|
+
bg-background border border-border
|
|
61
|
+
shadow-[0_2px_8px_rgba(0,0,0,0.12)] z-1
|
|
62
|
+
`, {
|
|
63
|
+
variants: {
|
|
64
|
+
rounded: {
|
|
65
|
+
large: "rounded-lg",
|
|
66
|
+
medium: "rounded-md",
|
|
67
|
+
none: "rounded-none",
|
|
68
|
+
small: "rounded-sm"
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
const popoverHeaderVariants = cva(`
|
|
73
|
+
flex items-center justify-between w-full
|
|
74
|
+
font-semibold overflow-hidden
|
|
75
|
+
`, {
|
|
76
|
+
variants: {
|
|
77
|
+
rounded: {
|
|
78
|
+
large: "rounded-t-lg",
|
|
79
|
+
medium: "rounded-t-md",
|
|
80
|
+
none: "rounded-t-none",
|
|
81
|
+
small: "rounded-t-sm"
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
const popoverContentVariants = cva(`
|
|
86
|
+
flex-1 w-full h-full
|
|
87
|
+
overflow-hidden
|
|
88
|
+
`);
|
|
89
|
+
|
|
90
|
+
const popoverBaseThemeVariants = (theme) => {
|
|
91
|
+
switch (theme) {
|
|
92
|
+
case "mona":
|
|
93
|
+
return popoverBaseVariants;
|
|
94
|
+
default:
|
|
95
|
+
return popoverBaseVariants;
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
const popoverHeaderThemeVariants = (theme) => {
|
|
99
|
+
switch (theme) {
|
|
100
|
+
case "mona":
|
|
101
|
+
return popoverHeaderVariants;
|
|
102
|
+
default:
|
|
103
|
+
return popoverHeaderVariants;
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
const popoverContentThemeVariants = (theme) => {
|
|
107
|
+
switch (theme) {
|
|
108
|
+
case "mona":
|
|
109
|
+
return popoverContentVariants;
|
|
110
|
+
default:
|
|
111
|
+
return popoverContentVariants;
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
const popoverArrowThemeVariants = (theme) => {
|
|
115
|
+
return tooltipArrowThemeVariants(theme);
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
class PopoverComponent {
|
|
119
|
+
#destroyRef;
|
|
120
|
+
#popupService;
|
|
121
|
+
#renderer;
|
|
122
|
+
#themeService;
|
|
123
|
+
#subscription;
|
|
124
|
+
constructor() {
|
|
125
|
+
this.#destroyRef = inject(DestroyRef);
|
|
126
|
+
this.#popupService = inject(PopupService);
|
|
127
|
+
this.#renderer = inject(Renderer2);
|
|
128
|
+
this.#themeService = inject(ThemeService);
|
|
129
|
+
this.#subscription = null;
|
|
130
|
+
this.arrowClasses = computed(() => {
|
|
131
|
+
const theme = this.#themeService.theme();
|
|
132
|
+
return popoverArrowThemeVariants(theme)();
|
|
133
|
+
}, /* @ts-ignore */
|
|
134
|
+
...(ngDevMode ? [{ debugName: "arrowClasses" }] : /* istanbul ignore next */ []));
|
|
135
|
+
this.baseClasses = computed(() => {
|
|
136
|
+
const theme = this.#themeService.theme();
|
|
137
|
+
const rounded = this.rounded();
|
|
138
|
+
return popoverBaseThemeVariants(theme)({ rounded });
|
|
139
|
+
}, /* @ts-ignore */
|
|
140
|
+
...(ngDevMode ? [{ debugName: "baseClasses" }] : /* istanbul ignore next */ []));
|
|
141
|
+
this.contentClasses = computed(() => {
|
|
142
|
+
const theme = this.#themeService.theme();
|
|
143
|
+
return popoverContentThemeVariants(theme)();
|
|
144
|
+
}, /* @ts-ignore */
|
|
145
|
+
...(ngDevMode ? [{ debugName: "contentClasses" }] : /* istanbul ignore next */ []));
|
|
146
|
+
this.currentArrowPosition = computed(() => this.position(), /* @ts-ignore */
|
|
147
|
+
...(ngDevMode ? [{ debugName: "currentArrowPosition" }] : /* istanbul ignore next */ []));
|
|
148
|
+
this.footerTemplateRef = contentChild(PopoverFooterTemplateDirective, { ...(ngDevMode ? { debugName: "footerTemplateRef" } : /* istanbul ignore next */ {}), read: TemplateRef });
|
|
149
|
+
this.headerClasses = computed(() => {
|
|
150
|
+
const theme = this.#themeService.theme();
|
|
151
|
+
const rounded = this.rounded();
|
|
152
|
+
const hasTemplate = !!this.titleTemplateRef();
|
|
153
|
+
const padding = hasTemplate ? "p-0" : "p-2";
|
|
154
|
+
const variants = popoverHeaderThemeVariants(theme)({ rounded });
|
|
155
|
+
return twMerge(variants, padding);
|
|
156
|
+
}, /* @ts-ignore */
|
|
157
|
+
...(ngDevMode ? [{ debugName: "headerClasses" }] : /* istanbul ignore next */ []));
|
|
158
|
+
this.headerId = computed(() => this.title() || this.titleTemplateRef() ? `${this.uid}-title` : null, /* @ts-ignore */
|
|
159
|
+
...(ngDevMode ? [{ debugName: "headerId" }] : /* istanbul ignore next */ []));
|
|
160
|
+
this.titleTemplateRef = contentChild(PopoverTitleTemplateDirective, { ...(ngDevMode ? { debugName: "titleTemplateRef" } : /* istanbul ignore next */ {}), read: TemplateRef });
|
|
161
|
+
this.templateRef = viewChild.required(TemplateRef, /* @ts-ignore */
|
|
162
|
+
...(ngDevMode ? [{ debugName: "templateRef" }] : /* istanbul ignore next */ []));
|
|
163
|
+
this.uid = v4();
|
|
164
|
+
this.popupRef = null;
|
|
165
|
+
/**
|
|
166
|
+
* @description Display the arrow of the popover.
|
|
167
|
+
*/
|
|
168
|
+
this.displayArrow = input(false, /* @ts-ignore */
|
|
169
|
+
...(ngDevMode ? [{ debugName: "displayArrow" }] : /* istanbul ignore next */ []));
|
|
170
|
+
/**
|
|
171
|
+
* @description Emits when the popover is about to be closed.
|
|
172
|
+
* This event is preventable.
|
|
173
|
+
*/
|
|
174
|
+
this.hide = output();
|
|
175
|
+
/**
|
|
176
|
+
* @description Emits when the popover is hidden.
|
|
177
|
+
*/
|
|
178
|
+
this.hidden = output();
|
|
179
|
+
/**
|
|
180
|
+
* @description The position of the popover relative to the target element.
|
|
181
|
+
*/
|
|
182
|
+
this.position = input("top", /* @ts-ignore */
|
|
183
|
+
...(ngDevMode ? [{ debugName: "position" }] : /* istanbul ignore next */ []));
|
|
184
|
+
/**
|
|
185
|
+
* @description The border radius of the popover.
|
|
186
|
+
*/
|
|
187
|
+
this.rounded = input("medium", /* @ts-ignore */
|
|
188
|
+
...(ngDevMode ? [{ debugName: "rounded" }] : /* istanbul ignore next */ []));
|
|
189
|
+
/**
|
|
190
|
+
* @description Emits when the popover is about to be shown.
|
|
191
|
+
* This event is preventable.
|
|
192
|
+
*/
|
|
193
|
+
this.show = output();
|
|
194
|
+
/**
|
|
195
|
+
* @description Emits when the popover is shown.
|
|
196
|
+
*/
|
|
197
|
+
this.shown = output();
|
|
198
|
+
/**
|
|
199
|
+
* @description The target element or ElementRef to which the popover is attached.
|
|
200
|
+
*/
|
|
201
|
+
this.target = input.required(/* @ts-ignore */
|
|
202
|
+
...(ngDevMode ? [{ debugName: "target" }] : /* istanbul ignore next */ []));
|
|
203
|
+
/**
|
|
204
|
+
* @description The title of the popover.
|
|
205
|
+
*/
|
|
206
|
+
this.title = input("", /* @ts-ignore */
|
|
207
|
+
...(ngDevMode ? [{ debugName: "title" }] : /* istanbul ignore next */ []));
|
|
208
|
+
/**
|
|
209
|
+
* @description The trigger that opens/closes the popover.
|
|
210
|
+
* "click" toggles on click, "hover" opens on pointer enter and closes on
|
|
211
|
+
* pointer leave, "none" disables automatic triggering (use `open()`/`close()`
|
|
212
|
+
* instead). Any other DOM event name is also accepted and used as-is.
|
|
213
|
+
*/
|
|
214
|
+
this.trigger = input("click", /* @ts-ignore */
|
|
215
|
+
...(ngDevMode ? [{ debugName: "trigger" }] : /* istanbul ignore next */ []));
|
|
216
|
+
effect(() => {
|
|
217
|
+
if (this.#subscription) {
|
|
218
|
+
this.#subscription.unsubscribe();
|
|
219
|
+
this.#subscription = null;
|
|
220
|
+
}
|
|
221
|
+
this.#setSubscriptions();
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
close() {
|
|
225
|
+
if (this.popupRef) {
|
|
226
|
+
this.popupRef.close();
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
open() {
|
|
230
|
+
if (this.popupRef) {
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
this.#createPopover();
|
|
234
|
+
}
|
|
235
|
+
#createPopover() {
|
|
236
|
+
const position = this.position();
|
|
237
|
+
const connectionPoints = getPositionConnectionPoints(position);
|
|
238
|
+
const offset = getOffsetForPosition(position, this.displayArrow());
|
|
239
|
+
const anchor = this.target();
|
|
240
|
+
const content = this.templateRef();
|
|
241
|
+
const targetElement = this.#popoverTargetElement;
|
|
242
|
+
this.popupRef = this.#popupService.create({
|
|
243
|
+
anchor,
|
|
244
|
+
anchorConnectionPoint: connectionPoints.anchor,
|
|
245
|
+
animation: fadePopupAnimation,
|
|
246
|
+
closeOnMouseLeave: this.trigger() === "hover",
|
|
247
|
+
closeOnOutsideClick: true,
|
|
248
|
+
content,
|
|
249
|
+
hasBackdrop: false,
|
|
250
|
+
offset,
|
|
251
|
+
popupConnectionPoint: connectionPoints.popup,
|
|
252
|
+
withPush: true
|
|
253
|
+
});
|
|
254
|
+
this.#renderer.setAttribute(targetElement, "aria-haspopup", "dialog");
|
|
255
|
+
this.#renderer.setAttribute(targetElement, "aria-controls", this.uid);
|
|
256
|
+
this.#renderer.setAttribute(targetElement, "aria-expanded", "true");
|
|
257
|
+
this.popupRef.beforeClose.pipe(takeUntil(this.popupRef.closed)).subscribe(event => {
|
|
258
|
+
const hideEvent = new PopoverHideEvent(this.#popoverTargetElement, this.popupRef);
|
|
259
|
+
this.hide.emit(hideEvent);
|
|
260
|
+
if (hideEvent.isDefaultPrevented()) {
|
|
261
|
+
event.preventDefault();
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
this.popupRef.closed.pipe(take(1)).subscribe(() => {
|
|
266
|
+
this.popupRef = null;
|
|
267
|
+
this.#renderer.setAttribute(targetElement, "aria-expanded", "false");
|
|
268
|
+
this.hidden.emit();
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
#openViaTrigger() {
|
|
272
|
+
const showEvent = new PopoverShowEvent(this.#popoverTargetElement);
|
|
273
|
+
this.show.emit(showEvent);
|
|
274
|
+
if (showEvent.isDefaultPrevented()) {
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
this.#createPopover();
|
|
278
|
+
if (this.popupRef) {
|
|
279
|
+
const shownEvent = new PopoverShownEvent(this.#popoverTargetElement, this.popupRef);
|
|
280
|
+
this.shown.emit(shownEvent);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
#setSubscriptions() {
|
|
284
|
+
const trigger = this.trigger();
|
|
285
|
+
if (trigger === "none") {
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
if (trigger === "hover") {
|
|
289
|
+
this.#subscription = fromEvent(this.#popoverTargetElement, "pointerenter")
|
|
290
|
+
.pipe(filter(() => !this.popupRef), tap(() => this.#openViaTrigger()), takeUntilDestroyed(this.#destroyRef))
|
|
291
|
+
.subscribe();
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
this.#subscription = fromEvent(this.#popoverTargetElement, trigger)
|
|
295
|
+
.pipe(tap(event => event.preventDefault()), filter(() => {
|
|
296
|
+
if (this.popupRef) {
|
|
297
|
+
this.close();
|
|
298
|
+
return false;
|
|
299
|
+
}
|
|
300
|
+
return true;
|
|
301
|
+
}), tap(() => this.#openViaTrigger()), takeUntilDestroyed(this.#destroyRef))
|
|
302
|
+
.subscribe();
|
|
303
|
+
}
|
|
304
|
+
get #popoverTargetElement() {
|
|
305
|
+
const target = this.target();
|
|
306
|
+
return target instanceof ElementRef ? target.nativeElement : target;
|
|
307
|
+
}
|
|
308
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: PopoverComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
309
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: PopoverComponent, isStandalone: true, selector: "mona-popover", inputs: { displayArrow: { classPropertyName: "displayArrow", publicName: "displayArrow", isSignal: true, isRequired: false, transformFunction: null }, position: { classPropertyName: "position", publicName: "position", isSignal: true, isRequired: false, transformFunction: null }, rounded: { classPropertyName: "rounded", publicName: "rounded", isSignal: true, isRequired: false, transformFunction: null }, target: { classPropertyName: "target", publicName: "target", isSignal: true, isRequired: true, transformFunction: null }, title: { classPropertyName: "title", publicName: "title", isSignal: true, isRequired: false, transformFunction: null }, trigger: { classPropertyName: "trigger", publicName: "trigger", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { hide: "hide", hidden: "hidden", show: "show", shown: "shown" }, queries: [{ propertyName: "footerTemplateRef", first: true, predicate: PopoverFooterTemplateDirective, descendants: true, read: TemplateRef, isSignal: true }, { propertyName: "titleTemplateRef", first: true, predicate: PopoverTitleTemplateDirective, descendants: true, read: TemplateRef, isSignal: true }], viewQueries: [{ propertyName: "templateRef", first: true, predicate: TemplateRef, descendants: true, isSignal: true }], exportAs: ["monaPopover"], ngImport: i0, template: "<ng-template>\r\n <div [class]=\"baseClasses()\" [id]=\"uid\" role=\"dialog\" [attr.aria-labelledby]=\"headerId()\" [attr.data-uid]=\"uid\">\r\n <div>\r\n @if (title() || titleTemplateRef()) {\r\n <div [class]=\"headerClasses()\" [id]=\"headerId()\">\r\n @if (titleTemplateRef()) {\r\n <ng-container [ngTemplateOutlet]=\"titleTemplateRef()\"></ng-container>\r\n } @else {\r\n <span>{{ title() }}</span>\r\n }\r\n </div>\r\n }\r\n <div [class]=\"contentClasses()\">\r\n <ng-content></ng-content>\r\n </div>\r\n @if (footerTemplateRef()) {\r\n <div class=\"mona-popover-footer\">\r\n <ng-container [ngTemplateOutlet]=\"footerTemplateRef()\"></ng-container>\r\n </div>\r\n }\r\n </div>\r\n @if (displayArrow()) {\r\n <div [class]=\"arrowClasses()\" [attr.data-position]=\"currentArrowPosition()\"></div>\r\n }\r\n </div>\r\n</ng-template>\r\n", dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }] }); }
|
|
310
|
+
}
|
|
311
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: PopoverComponent, decorators: [{
|
|
312
|
+
type: Component,
|
|
313
|
+
args: [{ selector: "mona-popover", exportAs: "monaPopover", imports: [NgTemplateOutlet], template: "<ng-template>\r\n <div [class]=\"baseClasses()\" [id]=\"uid\" role=\"dialog\" [attr.aria-labelledby]=\"headerId()\" [attr.data-uid]=\"uid\">\r\n <div>\r\n @if (title() || titleTemplateRef()) {\r\n <div [class]=\"headerClasses()\" [id]=\"headerId()\">\r\n @if (titleTemplateRef()) {\r\n <ng-container [ngTemplateOutlet]=\"titleTemplateRef()\"></ng-container>\r\n } @else {\r\n <span>{{ title() }}</span>\r\n }\r\n </div>\r\n }\r\n <div [class]=\"contentClasses()\">\r\n <ng-content></ng-content>\r\n </div>\r\n @if (footerTemplateRef()) {\r\n <div class=\"mona-popover-footer\">\r\n <ng-container [ngTemplateOutlet]=\"footerTemplateRef()\"></ng-container>\r\n </div>\r\n }\r\n </div>\r\n @if (displayArrow()) {\r\n <div [class]=\"arrowClasses()\" [attr.data-position]=\"currentArrowPosition()\"></div>\r\n }\r\n </div>\r\n</ng-template>\r\n" }]
|
|
314
|
+
}], ctorParameters: () => [], propDecorators: { footerTemplateRef: [{ type: i0.ContentChild, args: [i0.forwardRef(() => PopoverFooterTemplateDirective), { ...{ read: TemplateRef }, isSignal: true }] }], titleTemplateRef: [{ type: i0.ContentChild, args: [i0.forwardRef(() => PopoverTitleTemplateDirective), { ...{ read: TemplateRef }, isSignal: true }] }], templateRef: [{ type: i0.ViewChild, args: [i0.forwardRef(() => TemplateRef), { isSignal: true }] }], displayArrow: [{ type: i0.Input, args: [{ isSignal: true, alias: "displayArrow", required: false }] }], hide: [{ type: i0.Output, args: ["hide"] }], hidden: [{ type: i0.Output, args: ["hidden"] }], position: [{ type: i0.Input, args: [{ isSignal: true, alias: "position", required: false }] }], rounded: [{ type: i0.Input, args: [{ isSignal: true, alias: "rounded", required: false }] }], show: [{ type: i0.Output, args: ["show"] }], shown: [{ type: i0.Output, args: ["shown"] }], target: [{ type: i0.Input, args: [{ isSignal: true, alias: "target", required: true }] }], title: [{ type: i0.Input, args: [{ isSignal: true, alias: "title", required: false }] }], trigger: [{ type: i0.Input, args: [{ isSignal: true, alias: "trigger", required: false }] }] } });
|
|
315
|
+
|
|
316
|
+
/*
|
|
317
|
+
* Public API Surface of @nanahoshi/mona-ui/popover
|
|
318
|
+
*/
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Generated bundle index. Do not edit.
|
|
322
|
+
*/
|
|
323
|
+
|
|
324
|
+
export { PopoverComponent, PopoverFooterTemplateDirective, PopoverHideEvent, PopoverShowEvent, PopoverShownEvent, PopoverTitleTemplateDirective };
|
|
325
|
+
//# sourceMappingURL=nanahoshi-mona-ui-popover.mjs.map
|