@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.
Files changed (134) hide show
  1. package/README.md +25 -0
  2. package/fesm2022/nanahoshi-mona-ui-auto-complete.mjs +590 -0
  3. package/fesm2022/nanahoshi-mona-ui-avatar.mjs +168 -0
  4. package/fesm2022/nanahoshi-mona-ui-breadcrumb.mjs +220 -0
  5. package/fesm2022/nanahoshi-mona-ui-button-group.mjs +225 -0
  6. package/fesm2022/nanahoshi-mona-ui-button.mjs +497 -0
  7. package/fesm2022/nanahoshi-mona-ui-calendar.mjs +1569 -0
  8. package/fesm2022/nanahoshi-mona-ui-check-box.mjs +339 -0
  9. package/fesm2022/nanahoshi-mona-ui-chip.mjs +453 -0
  10. package/fesm2022/nanahoshi-mona-ui-circular-progress-bar.mjs +200 -0
  11. package/fesm2022/nanahoshi-mona-ui-color-gradient.mjs +853 -0
  12. package/fesm2022/nanahoshi-mona-ui-color-palette.mjs +923 -0
  13. package/fesm2022/nanahoshi-mona-ui-color-picker.mjs +495 -0
  14. package/fesm2022/nanahoshi-mona-ui-combo-box.mjs +686 -0
  15. package/fesm2022/nanahoshi-mona-ui-common.mjs +642 -0
  16. package/fesm2022/nanahoshi-mona-ui-contextmenu.mjs +485 -0
  17. package/fesm2022/nanahoshi-mona-ui-date-input.mjs +132 -0
  18. package/fesm2022/nanahoshi-mona-ui-date-picker.mjs +460 -0
  19. package/fesm2022/nanahoshi-mona-ui-datetime-picker.mjs +659 -0
  20. package/fesm2022/nanahoshi-mona-ui-dialog.mjs +828 -0
  21. package/fesm2022/nanahoshi-mona-ui-dropdown-button.mjs +523 -0
  22. package/fesm2022/nanahoshi-mona-ui-dropdown-list.mjs +615 -0
  23. package/fesm2022/nanahoshi-mona-ui-dropdowns.mjs +701 -0
  24. package/fesm2022/nanahoshi-mona-ui-editor.mjs +1400 -0
  25. package/fesm2022/nanahoshi-mona-ui-expansion-panel.mjs +245 -0
  26. package/fesm2022/nanahoshi-mona-ui-fieldset.mjs +170 -0
  27. package/fesm2022/nanahoshi-mona-ui-filter.mjs +680 -0
  28. package/fesm2022/nanahoshi-mona-ui-grid-grid-footer-cell.component-B9SQH5N-.mjs +105 -0
  29. package/fesm2022/nanahoshi-mona-ui-grid-grid-footer-table-cell.directive-DlLwcCFT.mjs +42 -0
  30. package/fesm2022/nanahoshi-mona-ui-grid-grid-list.component-Dgea-O0X.mjs +130 -0
  31. package/fesm2022/nanahoshi-mona-ui-grid-grid-toggle.component-DIUutx9s.mjs +773 -0
  32. package/fesm2022/nanahoshi-mona-ui-grid-grid-virtual-list.component-DRHycGIh.mjs +240 -0
  33. package/fesm2022/nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-C3eZIaJK.mjs +5374 -0
  34. package/fesm2022/nanahoshi-mona-ui-grid.mjs +2 -0
  35. package/fesm2022/nanahoshi-mona-ui-internal-filter-input.mjs +87 -0
  36. package/fesm2022/nanahoshi-mona-ui-internal-indicator-icon.mjs +154 -0
  37. package/fesm2022/nanahoshi-mona-ui-internal-list.mjs +1356 -0
  38. package/fesm2022/nanahoshi-mona-ui-internal-tree.mjs +2263 -0
  39. package/fesm2022/nanahoshi-mona-ui-internal.mjs +379 -0
  40. package/fesm2022/nanahoshi-mona-ui-list-box.mjs +630 -0
  41. package/fesm2022/nanahoshi-mona-ui-list-view.mjs +527 -0
  42. package/fesm2022/nanahoshi-mona-ui-list.mjs +4 -0
  43. package/fesm2022/nanahoshi-mona-ui-menubar.mjs +966 -0
  44. package/fesm2022/nanahoshi-mona-ui-multi-select.mjs +641 -0
  45. package/fesm2022/nanahoshi-mona-ui-notification.mjs +536 -0
  46. package/fesm2022/nanahoshi-mona-ui-numeric-text-box.mjs +597 -0
  47. package/fesm2022/nanahoshi-mona-ui-pager.mjs +790 -0
  48. package/fesm2022/nanahoshi-mona-ui-placeholder.mjs +83 -0
  49. package/fesm2022/nanahoshi-mona-ui-popover.mjs +325 -0
  50. package/fesm2022/nanahoshi-mona-ui-popup-menu.mjs +1559 -0
  51. package/fesm2022/nanahoshi-mona-ui-popup.mjs +1321 -0
  52. package/fesm2022/nanahoshi-mona-ui-progress-bar.mjs +294 -0
  53. package/fesm2022/nanahoshi-mona-ui-query.mjs +175 -0
  54. package/fesm2022/nanahoshi-mona-ui-radio-button.mjs +339 -0
  55. package/fesm2022/nanahoshi-mona-ui-scroll-view.mjs +565 -0
  56. package/fesm2022/nanahoshi-mona-ui-slider.mjs +1049 -0
  57. package/fesm2022/nanahoshi-mona-ui-split-button.mjs +636 -0
  58. package/fesm2022/nanahoshi-mona-ui-splitter.mjs +843 -0
  59. package/fesm2022/nanahoshi-mona-ui-stepper.mjs +537 -0
  60. package/fesm2022/nanahoshi-mona-ui-switch.mjs +308 -0
  61. package/fesm2022/nanahoshi-mona-ui-tabs.mjs +664 -0
  62. package/fesm2022/nanahoshi-mona-ui-text-area.mjs +111 -0
  63. package/fesm2022/nanahoshi-mona-ui-text-box.mjs +369 -0
  64. package/fesm2022/nanahoshi-mona-ui-theme.mjs +314 -0
  65. package/fesm2022/nanahoshi-mona-ui-time-picker.mjs +450 -0
  66. package/fesm2022/nanahoshi-mona-ui-time-selector.mjs +723 -0
  67. package/fesm2022/nanahoshi-mona-ui-tooltip.mjs +716 -0
  68. package/fesm2022/nanahoshi-mona-ui-tree-view.mjs +733 -0
  69. package/fesm2022/nanahoshi-mona-ui-window.mjs +1329 -0
  70. package/fesm2022/nanahoshi-mona-ui.mjs +9 -0
  71. package/package.json +289 -0
  72. package/types/nanahoshi-mona-ui-auto-complete.d.ts +223 -0
  73. package/types/nanahoshi-mona-ui-avatar.d.ts +642 -0
  74. package/types/nanahoshi-mona-ui-breadcrumb.d.ts +70 -0
  75. package/types/nanahoshi-mona-ui-button-group.d.ts +77 -0
  76. package/types/nanahoshi-mona-ui-button.d.ts +111 -0
  77. package/types/nanahoshi-mona-ui-calendar.d.ts +262 -0
  78. package/types/nanahoshi-mona-ui-check-box.d.ts +133 -0
  79. package/types/nanahoshi-mona-ui-chip.d.ts +130 -0
  80. package/types/nanahoshi-mona-ui-circular-progress-bar.d.ts +113 -0
  81. package/types/nanahoshi-mona-ui-color-gradient.d.ts +201 -0
  82. package/types/nanahoshi-mona-ui-color-palette.d.ts +102 -0
  83. package/types/nanahoshi-mona-ui-color-picker.d.ts +156 -0
  84. package/types/nanahoshi-mona-ui-combo-box.d.ts +232 -0
  85. package/types/nanahoshi-mona-ui-common.d.ts +386 -0
  86. package/types/nanahoshi-mona-ui-contextmenu.d.ts +129 -0
  87. package/types/nanahoshi-mona-ui-date-input.d.ts +60 -0
  88. package/types/nanahoshi-mona-ui-date-picker.d.ts +177 -0
  89. package/types/nanahoshi-mona-ui-datetime-picker.d.ts +199 -0
  90. package/types/nanahoshi-mona-ui-dialog.d.ts +261 -0
  91. package/types/nanahoshi-mona-ui-dropdown-button.d.ts +159 -0
  92. package/types/nanahoshi-mona-ui-dropdown-list.d.ts +219 -0
  93. package/types/nanahoshi-mona-ui-dropdowns.d.ts +176 -0
  94. package/types/nanahoshi-mona-ui-editor.d.ts +113 -0
  95. package/types/nanahoshi-mona-ui-expansion-panel.d.ts +87 -0
  96. package/types/nanahoshi-mona-ui-fieldset.d.ts +68 -0
  97. package/types/nanahoshi-mona-ui-filter.d.ts +115 -0
  98. package/types/nanahoshi-mona-ui-grid.d.ts +1114 -0
  99. package/types/nanahoshi-mona-ui-internal-filter-input.d.ts +25 -0
  100. package/types/nanahoshi-mona-ui-internal-indicator-icon.d.ts +28 -0
  101. package/types/nanahoshi-mona-ui-internal-list.d.ts +269 -0
  102. package/types/nanahoshi-mona-ui-internal-tree.d.ts +391 -0
  103. package/types/nanahoshi-mona-ui-internal.d.ts +136 -0
  104. package/types/nanahoshi-mona-ui-list-box.d.ts +225 -0
  105. package/types/nanahoshi-mona-ui-list-view.d.ts +188 -0
  106. package/types/nanahoshi-mona-ui-list.d.ts +1 -0
  107. package/types/nanahoshi-mona-ui-menubar.d.ts +198 -0
  108. package/types/nanahoshi-mona-ui-multi-select.d.ts +247 -0
  109. package/types/nanahoshi-mona-ui-notification.d.ts +106 -0
  110. package/types/nanahoshi-mona-ui-numeric-text-box.d.ts +161 -0
  111. package/types/nanahoshi-mona-ui-pager.d.ts +238 -0
  112. package/types/nanahoshi-mona-ui-placeholder.d.ts +35 -0
  113. package/types/nanahoshi-mona-ui-popover.d.ts +130 -0
  114. package/types/nanahoshi-mona-ui-popup-menu.d.ts +412 -0
  115. package/types/nanahoshi-mona-ui-popup.d.ts +485 -0
  116. package/types/nanahoshi-mona-ui-progress-bar.d.ts +139 -0
  117. package/types/nanahoshi-mona-ui-query.d.ts +89 -0
  118. package/types/nanahoshi-mona-ui-radio-button.d.ts +128 -0
  119. package/types/nanahoshi-mona-ui-scroll-view.d.ts +166 -0
  120. package/types/nanahoshi-mona-ui-slider.d.ts +305 -0
  121. package/types/nanahoshi-mona-ui-split-button.d.ts +182 -0
  122. package/types/nanahoshi-mona-ui-splitter.d.ts +70 -0
  123. package/types/nanahoshi-mona-ui-stepper.d.ts +173 -0
  124. package/types/nanahoshi-mona-ui-switch.d.ts +125 -0
  125. package/types/nanahoshi-mona-ui-tabs.d.ts +158 -0
  126. package/types/nanahoshi-mona-ui-text-area.d.ts +42 -0
  127. package/types/nanahoshi-mona-ui-text-box.d.ts +164 -0
  128. package/types/nanahoshi-mona-ui-theme.d.ts +23 -0
  129. package/types/nanahoshi-mona-ui-time-picker.d.ts +184 -0
  130. package/types/nanahoshi-mona-ui-time-selector.d.ts +143 -0
  131. package/types/nanahoshi-mona-ui-tooltip.d.ts +130 -0
  132. package/types/nanahoshi-mona-ui-tree-view.d.ts +274 -0
  133. package/types/nanahoshi-mona-ui-window.d.ts +295 -0
  134. package/types/nanahoshi-mona-ui.d.ts +2 -0
@@ -0,0 +1,536 @@
1
+ import * as i0 from '@angular/core';
2
+ import { inject, DestroyRef, computed, signal, TemplateRef, viewChild, ViewContainerRef, input, afterNextRender, Component, ApplicationRef, DOCUMENT as DOCUMENT$1, createComponent, Injectable } from '@angular/core';
3
+ import { interval, takeWhile, asyncScheduler, Subject, take } from 'rxjs';
4
+ import { v4 } from 'uuid';
5
+ import { ThemeService } from '@nanahoshi/mona-ui/theme';
6
+ import { cva } from 'class-variance-authority';
7
+ import { DOCUMENT, NgTemplateOutlet } from '@angular/common';
8
+ import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
9
+ import { LucideOctagonX, LucideBadgeInfo, LucideCircleCheckBig, LucideOctagonAlert, LucideX } from '@lucide/angular';
10
+ import { ButtonDirective } from '@nanahoshi/mona-ui/button';
11
+ import { ProgressBarComponent } from '@nanahoshi/mona-ui/progress-bar';
12
+
13
+ //---------------------------------
14
+ // Notification Container Component
15
+ //---------------------------------
16
+ const notificationContainerBaseVariants = cva(`p-2 z-40000`, {
17
+ variants: {
18
+ position: {
19
+ bottom: "bottom-0 left-1/2 -translate-x-1/2",
20
+ bottomleft: "bottom-0 left-0",
21
+ bottomright: "bottom-0 right-0",
22
+ top: "top-0 left-1/2 -translate-x-1/2",
23
+ topleft: "top-0 left-0",
24
+ topright: "top-0 right-0"
25
+ },
26
+ positionType: {
27
+ fixed: "fixed",
28
+ absolute: "absolute"
29
+ }
30
+ },
31
+ defaultVariants: {
32
+ positionType: "fixed"
33
+ }
34
+ });
35
+ //-----------------------
36
+ // Notification Component
37
+ //-----------------------
38
+ const notificationActionVariants = cva(`
39
+ absolute top-0 right-0
40
+ flex items-start h-auto
41
+ [&>svg.lucide]:cursor-pointer
42
+ [&>svg.lucide]:-mt-1
43
+ `);
44
+ const notificationBaseVariants = cva(`
45
+ w-fit h-fit relative
46
+ overflow-hidden flex flex-col
47
+ mb-2 bg-background shadow-md
48
+ border border-border
49
+ `);
50
+ const notificationBodyVariants = cva(`
51
+ flex flex-1 p-2 ps-0 pe-8
52
+ `);
53
+ const notificationContentVariants = cva(`
54
+ flex flex-1 w-full items-center
55
+ `);
56
+ const notificationHeaderVariants = cva(`
57
+ w-full flex flex-row items-center
58
+ flex-1 text-sm font-medium
59
+ select-none
60
+ `);
61
+ const notificationIconVariants = cva(`
62
+ flex items-center justify-center px-4
63
+ `, {
64
+ variants: {
65
+ type: {
66
+ info: "text-info",
67
+ success: "text-success",
68
+ warning: "text-warning",
69
+ error: "text-error"
70
+ }
71
+ }
72
+ });
73
+ const notificationTextVariants = cva(`
74
+ text-sm text-foreground
75
+ `);
76
+
77
+ const notificationContainerBaseThemeVariants = (theme) => {
78
+ switch (theme) {
79
+ case "mona":
80
+ return notificationContainerBaseVariants;
81
+ default:
82
+ return notificationContainerBaseVariants;
83
+ }
84
+ };
85
+ const notificationActionThemeVariants = (theme) => {
86
+ switch (theme) {
87
+ case "mona":
88
+ return notificationActionVariants;
89
+ default:
90
+ return notificationActionVariants;
91
+ }
92
+ };
93
+ const notificationBaseThemeVariants = (theme) => {
94
+ switch (theme) {
95
+ case "mona":
96
+ return notificationBaseVariants;
97
+ default:
98
+ return notificationBaseVariants;
99
+ }
100
+ };
101
+ const notificationBodyThemeVariants = (theme) => {
102
+ switch (theme) {
103
+ case "mona":
104
+ return notificationBodyVariants;
105
+ default:
106
+ return notificationBodyVariants;
107
+ }
108
+ };
109
+ const notificationContentThemeVariants = (theme) => {
110
+ switch (theme) {
111
+ case "mona":
112
+ return notificationContentVariants;
113
+ default:
114
+ return notificationContentVariants;
115
+ }
116
+ };
117
+ const notificationHeaderThemeVariants = (theme) => {
118
+ switch (theme) {
119
+ case "mona":
120
+ return notificationHeaderVariants;
121
+ default:
122
+ return notificationHeaderVariants;
123
+ }
124
+ };
125
+ const notificationIconThemeVariants = (theme) => {
126
+ switch (theme) {
127
+ case "mona":
128
+ return notificationIconVariants;
129
+ default:
130
+ return notificationIconVariants;
131
+ }
132
+ };
133
+ const notificationTextThemeVariants = (theme) => {
134
+ switch (theme) {
135
+ case "mona":
136
+ return notificationTextVariants;
137
+ default:
138
+ return notificationTextVariants;
139
+ }
140
+ };
141
+ // type NotificationBaseVariantProps = VariantProps<ReturnType<typeof notificationBaseThemeVariants>>;
142
+ // type NotificationBaseVariantInput = VariantInputs<NotificationBaseVariantProps>;
143
+ //
144
+ // export type NotificationVariantProps = NotificationBaseVariantProps;
145
+ // export type NotificationVariantInput = NotificationBaseVariantInput;
146
+
147
+ class NotificationComponent {
148
+ #destroyRef;
149
+ #document;
150
+ #isUrgent;
151
+ #paused;
152
+ #themeService;
153
+ constructor() {
154
+ this.#destroyRef = inject(DestroyRef);
155
+ this.#document = inject(DOCUMENT);
156
+ this.#isUrgent = computed(() => this.type() === "error" || this.type() === "warning", /* @ts-ignore */
157
+ ...(ngDevMode ? [{ debugName: "#isUrgent" }] : /* istanbul ignore next */ []));
158
+ this.#paused = signal(false, /* @ts-ignore */
159
+ ...(ngDevMode ? [{ debugName: "#paused" }] : /* istanbul ignore next */ []));
160
+ this.#themeService = inject(ThemeService);
161
+ this.actionClass = computed(() => {
162
+ const theme = this.#themeService.theme();
163
+ return notificationActionThemeVariants(theme)();
164
+ }, /* @ts-ignore */
165
+ ...(ngDevMode ? [{ debugName: "actionClass" }] : /* istanbul ignore next */ []));
166
+ this.ariaLive = computed(() => (this.#isUrgent() ? "assertive" : "polite"), /* @ts-ignore */
167
+ ...(ngDevMode ? [{ debugName: "ariaLive" }] : /* istanbul ignore next */ []));
168
+ this.baseClass = computed(() => {
169
+ const theme = this.#themeService.theme();
170
+ return notificationBaseThemeVariants(theme)();
171
+ }, /* @ts-ignore */
172
+ ...(ngDevMode ? [{ debugName: "baseClass" }] : /* istanbul ignore next */ []));
173
+ this.bodyClass = computed(() => {
174
+ const theme = this.#themeService.theme();
175
+ return notificationBodyThemeVariants(theme)();
176
+ }, /* @ts-ignore */
177
+ ...(ngDevMode ? [{ debugName: "bodyClass" }] : /* istanbul ignore next */ []));
178
+ this.contentClass = computed(() => {
179
+ const theme = this.#themeService.theme();
180
+ return notificationContentThemeVariants(theme)();
181
+ }, /* @ts-ignore */
182
+ ...(ngDevMode ? [{ debugName: "contentClass" }] : /* istanbul ignore next */ []));
183
+ this.contentComponent = computed(() => {
184
+ const content = this.data().options.content;
185
+ return typeof content !== "string" && !(content instanceof TemplateRef) ? content : null;
186
+ }, /* @ts-ignore */
187
+ ...(ngDevMode ? [{ debugName: "contentComponent" }] : /* istanbul ignore next */ []));
188
+ this.contentTemplate = computed(() => {
189
+ const content = this.data().options.content;
190
+ return content instanceof TemplateRef ? content : null;
191
+ }, /* @ts-ignore */
192
+ ...(ngDevMode ? [{ debugName: "contentTemplate" }] : /* istanbul ignore next */ []));
193
+ this.contentHost = viewChild("contentHost", { ...(ngDevMode ? { debugName: "contentHost" } : /* istanbul ignore next */ {}), read: ViewContainerRef });
194
+ this.headerClass = computed(() => {
195
+ const theme = this.#themeService.theme();
196
+ return notificationHeaderThemeVariants(theme)();
197
+ }, /* @ts-ignore */
198
+ ...(ngDevMode ? [{ debugName: "headerClass" }] : /* istanbul ignore next */ []));
199
+ this.iconClass = computed(() => {
200
+ const theme = this.#themeService.theme();
201
+ const type = this.type();
202
+ return notificationIconThemeVariants(theme)({ type });
203
+ }, /* @ts-ignore */
204
+ ...(ngDevMode ? [{ debugName: "iconClass" }] : /* istanbul ignore next */ []));
205
+ this.isStringContent = computed(() => typeof this.data().options.content === "string", /* @ts-ignore */
206
+ ...(ngDevMode ? [{ debugName: "isStringContent" }] : /* istanbul ignore next */ []));
207
+ this.progressColor = computed(() => {
208
+ const type = this.type();
209
+ const propertyName = `--color-${type}`;
210
+ return getComputedStyle(this.#document.documentElement).getPropertyValue(propertyName);
211
+ }, /* @ts-ignore */
212
+ ...(ngDevMode ? [{ debugName: "progressColor" }] : /* istanbul ignore next */ []));
213
+ this.progressValue = signal(100, /* @ts-ignore */
214
+ ...(ngDevMode ? [{ debugName: "progressValue" }] : /* istanbul ignore next */ []));
215
+ this.role = computed(() => (this.#isUrgent() ? "alert" : "status"), /* @ts-ignore */
216
+ ...(ngDevMode ? [{ debugName: "role" }] : /* istanbul ignore next */ []));
217
+ this.textClass = computed(() => {
218
+ const theme = this.#themeService.theme();
219
+ return notificationTextThemeVariants(theme)();
220
+ }, /* @ts-ignore */
221
+ ...(ngDevMode ? [{ debugName: "textClass" }] : /* istanbul ignore next */ []));
222
+ this.type = computed(() => this.data().options.type ?? "info", /* @ts-ignore */
223
+ ...(ngDevMode ? [{ debugName: "type" }] : /* istanbul ignore next */ []));
224
+ /**
225
+ * @description The notification's internal state, created and managed by `NotificationService`. Not intended to be provided directly by consumers.
226
+ */
227
+ this.data = input.required(/* @ts-ignore */
228
+ ...(ngDevMode ? [{ debugName: "data" }] : /* istanbul ignore next */ []));
229
+ afterNextRender({
230
+ write: () => {
231
+ this.#setupProgressBar();
232
+ const type = this.contentComponent();
233
+ const vcr = this.contentHost();
234
+ if (type && vcr) {
235
+ this.data().contentComponentRef.set(vcr.createComponent(type));
236
+ }
237
+ }
238
+ });
239
+ this.#destroyRef.onDestroy(() => this.data().componentDestroy$.next(this.data().options.id));
240
+ }
241
+ close() {
242
+ this.data().componentDestroy$.next(this.data().options.id);
243
+ }
244
+ onInteractionEnd() {
245
+ this.#paused.set(false);
246
+ }
247
+ onInteractionStart() {
248
+ this.#paused.set(true);
249
+ }
250
+ #setupProgressBar() {
251
+ const duration = this.data().options.duration;
252
+ if (duration == null) {
253
+ return;
254
+ }
255
+ const progressInterval = Math.max(duration, 100) / 100;
256
+ interval(progressInterval)
257
+ .pipe(takeWhile(() => this.progressValue() > 0), takeUntilDestroyed(this.#destroyRef))
258
+ .subscribe({
259
+ next: () => {
260
+ if (this.#paused()) {
261
+ return;
262
+ }
263
+ this.progressValue.set(this.progressValue() - 1);
264
+ if (this.progressValue() === 0) {
265
+ asyncScheduler.schedule(() => {
266
+ this.close();
267
+ }, 300);
268
+ }
269
+ }
270
+ });
271
+ }
272
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: NotificationComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
273
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: NotificationComponent, isStandalone: true, selector: "mona-notification", inputs: { data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: true, transformFunction: null } }, host: { listeners: { "pointerenter": "onInteractionStart()", "pointerleave": "onInteractionEnd()", "focusin": "onInteractionStart()", "focusout": "onInteractionEnd()" } }, viewQueries: [{ propertyName: "contentHost", first: true, predicate: ["contentHost"], descendants: true, read: ViewContainerRef, isSignal: true }], ngImport: i0, template: "@let width = typeof data().options.width === \"string\" ? data().options.width : `${data().options.width}px`;\r\n@let height = typeof data().options.height === \"string\" ? data().options.height : `${data().options.height}px`;\r\n\r\n<div\r\n [class]=\"baseClass()\"\r\n [style.width]=\"width\"\r\n [style.height]=\"height\"\r\n [attr.role]=\"role()\"\r\n [attr.aria-live]=\"ariaLive()\">\r\n @if (contentTemplate() || contentComponent()) {\r\n @if (contentTemplate()) {\r\n <ng-container [ngTemplateOutlet]=\"contentTemplate()\"></ng-container>\r\n } @else if (contentComponent()) {\r\n <ng-container #contentHost></ng-container>\r\n }\r\n } @else {\r\n <div [class]=\"bodyClass()\">\r\n <div [class]=\"iconClass()\" aria-hidden=\"true\">\r\n @switch (type()) {\r\n @case (\"error\") {\r\n <svg lucideOctagonX aria-hidden=\"true\"></svg>\r\n }\r\n @case (\"info\") {\r\n <svg lucideBadgeInfo aria-hidden=\"true\"></svg>\r\n }\r\n @case (\"success\") {\r\n <svg lucideCircleCheckBig aria-hidden=\"true\"></svg>\r\n }\r\n @case (\"warning\") {\r\n <svg lucideOctagonAlert aria-hidden=\"true\"></svg>\r\n }\r\n }\r\n </div>\r\n <div class=\"flex flex-col flex-1\">\r\n <div [class]=\"headerClass()\">{{ data().options.title }}</div>\r\n <div [class]=\"contentClass()\">\r\n @if (isStringContent()) {\r\n <span [class]=\"textClass()\" title=\"{{ data().options.content }}\">{{\r\n data().options.content\r\n }}</span>\r\n }\r\n </div>\r\n </div>\r\n </div>\r\n @if (data().options.progressBar) {\r\n <div class=\"w-full h-1\">\r\n <mona-progress-bar\r\n [value]=\"progressValue()\"\r\n [color]=\"progressColor()\"\r\n [labelVisible]=\"false\"\r\n [animate]=\"false\"\r\n rounded=\"none\"\r\n class=\"h-full\"></mona-progress-bar>\r\n </div>\r\n }\r\n }\r\n @if (data().options.closable) {\r\n <div [class]=\"actionClass()\">\r\n <button\r\n monaButton\r\n size=\"small\"\r\n look=\"link\"\r\n rounded=\"none\"\r\n [iconOnly]=\"true\"\r\n [title]=\"data().options.closeTitle || 'Close'\"\r\n [attr.aria-label]=\"data().options.closeTitle || 'Close'\"\r\n (click)=\"close()\">\r\n <svg lucideX [size]=\"14\" aria-hidden=\"true\"></svg>\r\n </button>\r\n </div>\r\n }\r\n</div>\r\n", styles: [":host{display:block}@keyframes notification-slide-in-top{0%{clip-path:inset(0 -20px 100% -20px);transform:translateY(-12px);opacity:0}to{clip-path:inset(-20px);transform:translateY(0);opacity:1}}@keyframes notification-slide-out-top{0%{clip-path:inset(-20px);transform:translateY(0);opacity:1}to{clip-path:inset(0 -20px 100% -20px);transform:translateY(-12px);opacity:0}}@keyframes notification-slide-in-bottom{0%{clip-path:inset(100% -20px 0 -20px);transform:translateY(12px);opacity:0}to{clip-path:inset(-20px);transform:translateY(0);opacity:1}}@keyframes notification-slide-out-bottom{0%{clip-path:inset(-20px);transform:translateY(0);opacity:1}to{clip-path:inset(100% -20px 0 -20px);transform:translateY(12px);opacity:0}}:host.notification-enter-top{animation:notification-slide-in-top .3s cubic-bezier(.4,0,.2,1) forwards}:host.notification-enter-bottom{animation:notification-slide-in-bottom .3s cubic-bezier(.4,0,.2,1) forwards}:host.notification-leave-top{animation:notification-slide-out-top .3s cubic-bezier(.4,0,.2,1) forwards}:host.notification-leave-bottom{animation:notification-slide-out-bottom .3s cubic-bezier(.4,0,.2,1) forwards}\n"], dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: ProgressBarComponent, selector: "mona-progress-bar", inputs: ["aria-label", "aria-valuetext", "animate", "color", "disabled", "indeterminate", "labelPosition", "labelStyles", "labelVisible", "max", "min", "rounded", "class", "value"] }, { kind: "directive", type: ButtonDirective, selector: "button[monaButton]", inputs: ["aria-haspopup", "disabled", "iconOnly", "loading", "look", "rounded", "selected", "size", "tabindex", "toggleable", "class"], outputs: ["disabledChange", "loadingChange", "lookChange", "selectedChange"] }, { kind: "component", type: LucideOctagonX, selector: "svg[lucideOctagonX], svg[lucideXOctagon]" }, { kind: "component", type: LucideBadgeInfo, selector: "svg[lucideBadgeInfo]" }, { kind: "component", type: LucideCircleCheckBig, selector: "svg[lucideCircleCheckBig], svg[lucideCheckCircle]" }, { kind: "component", type: LucideOctagonAlert, selector: "svg[lucideOctagonAlert], svg[lucideAlertOctagon]" }, { kind: "component", type: LucideX, selector: "svg[lucideX]" }] }); }
274
+ }
275
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: NotificationComponent, decorators: [{
276
+ type: Component,
277
+ args: [{ selector: "mona-notification", imports: [
278
+ NgTemplateOutlet,
279
+ ProgressBarComponent,
280
+ ButtonDirective,
281
+ LucideOctagonX,
282
+ LucideBadgeInfo,
283
+ LucideCircleCheckBig,
284
+ LucideOctagonAlert,
285
+ LucideX
286
+ ], host: {
287
+ "(pointerenter)": "onInteractionStart()",
288
+ "(pointerleave)": "onInteractionEnd()",
289
+ "(focusin)": "onInteractionStart()",
290
+ "(focusout)": "onInteractionEnd()"
291
+ }, template: "@let width = typeof data().options.width === \"string\" ? data().options.width : `${data().options.width}px`;\r\n@let height = typeof data().options.height === \"string\" ? data().options.height : `${data().options.height}px`;\r\n\r\n<div\r\n [class]=\"baseClass()\"\r\n [style.width]=\"width\"\r\n [style.height]=\"height\"\r\n [attr.role]=\"role()\"\r\n [attr.aria-live]=\"ariaLive()\">\r\n @if (contentTemplate() || contentComponent()) {\r\n @if (contentTemplate()) {\r\n <ng-container [ngTemplateOutlet]=\"contentTemplate()\"></ng-container>\r\n } @else if (contentComponent()) {\r\n <ng-container #contentHost></ng-container>\r\n }\r\n } @else {\r\n <div [class]=\"bodyClass()\">\r\n <div [class]=\"iconClass()\" aria-hidden=\"true\">\r\n @switch (type()) {\r\n @case (\"error\") {\r\n <svg lucideOctagonX aria-hidden=\"true\"></svg>\r\n }\r\n @case (\"info\") {\r\n <svg lucideBadgeInfo aria-hidden=\"true\"></svg>\r\n }\r\n @case (\"success\") {\r\n <svg lucideCircleCheckBig aria-hidden=\"true\"></svg>\r\n }\r\n @case (\"warning\") {\r\n <svg lucideOctagonAlert aria-hidden=\"true\"></svg>\r\n }\r\n }\r\n </div>\r\n <div class=\"flex flex-col flex-1\">\r\n <div [class]=\"headerClass()\">{{ data().options.title }}</div>\r\n <div [class]=\"contentClass()\">\r\n @if (isStringContent()) {\r\n <span [class]=\"textClass()\" title=\"{{ data().options.content }}\">{{\r\n data().options.content\r\n }}</span>\r\n }\r\n </div>\r\n </div>\r\n </div>\r\n @if (data().options.progressBar) {\r\n <div class=\"w-full h-1\">\r\n <mona-progress-bar\r\n [value]=\"progressValue()\"\r\n [color]=\"progressColor()\"\r\n [labelVisible]=\"false\"\r\n [animate]=\"false\"\r\n rounded=\"none\"\r\n class=\"h-full\"></mona-progress-bar>\r\n </div>\r\n }\r\n }\r\n @if (data().options.closable) {\r\n <div [class]=\"actionClass()\">\r\n <button\r\n monaButton\r\n size=\"small\"\r\n look=\"link\"\r\n rounded=\"none\"\r\n [iconOnly]=\"true\"\r\n [title]=\"data().options.closeTitle || 'Close'\"\r\n [attr.aria-label]=\"data().options.closeTitle || 'Close'\"\r\n (click)=\"close()\">\r\n <svg lucideX [size]=\"14\" aria-hidden=\"true\"></svg>\r\n </button>\r\n </div>\r\n }\r\n</div>\r\n", styles: [":host{display:block}@keyframes notification-slide-in-top{0%{clip-path:inset(0 -20px 100% -20px);transform:translateY(-12px);opacity:0}to{clip-path:inset(-20px);transform:translateY(0);opacity:1}}@keyframes notification-slide-out-top{0%{clip-path:inset(-20px);transform:translateY(0);opacity:1}to{clip-path:inset(0 -20px 100% -20px);transform:translateY(-12px);opacity:0}}@keyframes notification-slide-in-bottom{0%{clip-path:inset(100% -20px 0 -20px);transform:translateY(12px);opacity:0}to{clip-path:inset(-20px);transform:translateY(0);opacity:1}}@keyframes notification-slide-out-bottom{0%{clip-path:inset(-20px);transform:translateY(0);opacity:1}to{clip-path:inset(100% -20px 0 -20px);transform:translateY(12px);opacity:0}}:host.notification-enter-top{animation:notification-slide-in-top .3s cubic-bezier(.4,0,.2,1) forwards}:host.notification-enter-bottom{animation:notification-slide-in-bottom .3s cubic-bezier(.4,0,.2,1) forwards}:host.notification-leave-top{animation:notification-slide-out-top .3s cubic-bezier(.4,0,.2,1) forwards}:host.notification-leave-bottom{animation:notification-slide-out-bottom .3s cubic-bezier(.4,0,.2,1) forwards}\n"] }]
292
+ }], ctorParameters: () => [], propDecorators: { contentHost: [{ type: i0.ViewChild, args: ["contentHost", { ...{ read: ViewContainerRef }, isSignal: true }] }], data: [{ type: i0.Input, args: [{ isSignal: true, alias: "data", required: true }] }] } });
293
+
294
+ class NotificationContainerComponent {
295
+ constructor() {
296
+ this.#themeService = inject(ThemeService);
297
+ this.baseClass = computed(() => {
298
+ const theme = this.#themeService.theme();
299
+ const position = this.position();
300
+ const positionType = this.positionType();
301
+ return notificationContainerBaseThemeVariants(theme)({ position, positionType });
302
+ }, /* @ts-ignore */
303
+ ...(ngDevMode ? [{ debugName: "baseClass" }] : /* istanbul ignore next */ []));
304
+ this.enterAnimClass = computed(() => this.position().startsWith("bottom") ? "notification-enter-bottom" : "notification-enter-top", /* @ts-ignore */
305
+ ...(ngDevMode ? [{ debugName: "enterAnimClass" }] : /* istanbul ignore next */ []));
306
+ this.leaveAnimClass = computed(() => this.position().startsWith("bottom") ? "notification-leave-bottom" : "notification-leave-top", /* @ts-ignore */
307
+ ...(ngDevMode ? [{ debugName: "leaveAnimClass" }] : /* istanbul ignore next */ []));
308
+ this.notificationDataList = signal([], /* @ts-ignore */
309
+ ...(ngDevMode ? [{ debugName: "notificationDataList" }] : /* istanbul ignore next */ []));
310
+ this.position = signal("topright", /* @ts-ignore */
311
+ ...(ngDevMode ? [{ debugName: "position" }] : /* istanbul ignore next */ []));
312
+ this.positionType = signal("fixed", /* @ts-ignore */
313
+ ...(ngDevMode ? [{ debugName: "positionType" }] : /* istanbul ignore next */ []));
314
+ }
315
+ #themeService;
316
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: NotificationContainerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
317
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: NotificationContainerComponent, isStandalone: true, selector: "mona-notification-container", host: { properties: { "class": "baseClass()" } }, ngImport: i0, template: "@for (notificationData of notificationDataList(); track notificationData.options.id) {\n <mona-notification [data]=\"notificationData\" [animate.enter]=\"enterAnimClass()\" [animate.leave]=\"leaveAnimClass()\">\n </mona-notification>\n}\n", dependencies: [{ kind: "component", type: NotificationComponent, selector: "mona-notification", inputs: ["data"] }] }); }
318
+ }
319
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: NotificationContainerComponent, decorators: [{
320
+ type: Component,
321
+ args: [{ selector: "mona-notification-container", imports: [NotificationComponent], host: {
322
+ "[class]": "baseClass()"
323
+ }, template: "@for (notificationData of notificationDataList(); track notificationData.options.id) {\n <mona-notification [data]=\"notificationData\" [animate.enter]=\"enterAnimClass()\" [animate.leave]=\"leaveAnimClass()\">\n </mona-notification>\n}\n" }]
324
+ }] });
325
+
326
+ function getDefaultTitle(type) {
327
+ switch (type) {
328
+ case "info":
329
+ return "Info";
330
+ case "success":
331
+ return "Success";
332
+ case "warning":
333
+ return "Warning";
334
+ case "error":
335
+ return "Error";
336
+ }
337
+ }
338
+
339
+ class NotificationService {
340
+ #appRef;
341
+ #document;
342
+ constructor() {
343
+ this.#appRef = inject(ApplicationRef);
344
+ this.#document = inject(DOCUMENT$1);
345
+ this.notificationContainerMap = new Map();
346
+ this.notificationContainerSubscriptions = {
347
+ bottom: null,
348
+ bottomleft: null,
349
+ bottomright: null,
350
+ top: null,
351
+ topleft: null,
352
+ topright: null
353
+ };
354
+ this.initialize();
355
+ }
356
+ hide(id) {
357
+ const notificationData = this.getNotificationDataById(id);
358
+ if (notificationData) {
359
+ notificationData.componentDestroy$.next(id);
360
+ }
361
+ }
362
+ hideAll() {
363
+ this.notificationContainerMap.forEach(container => {
364
+ container.notifications.forEach(notification => {
365
+ this.hide(notification.options.id);
366
+ });
367
+ });
368
+ }
369
+ show(options) {
370
+ const position = options.position ?? "topright";
371
+ const type = options.type ?? "info";
372
+ const resolvedOptions = {
373
+ ...options,
374
+ id: options.id ?? `Notification_${v4()}`,
375
+ position,
376
+ type,
377
+ title: options.title ?? getDefaultTitle(type),
378
+ closable: options.closable ?? (options.duration == null ? true : undefined)
379
+ };
380
+ const containerData = this.notificationContainerMap.get(position);
381
+ if (containerData?.notifications.has(resolvedOptions.id)) {
382
+ const existing = containerData.notifications.get(resolvedOptions.id);
383
+ return {
384
+ afterHide: existing.afterHide$.asObservable(),
385
+ get content() {
386
+ return existing.contentComponentRef();
387
+ },
388
+ hide: () => this.hide(resolvedOptions.id)
389
+ };
390
+ }
391
+ if (this.notificationContainerSubscriptions[position]) {
392
+ return this.createNotification(resolvedOptions);
393
+ }
394
+ else {
395
+ return this.createNotificationContainer(resolvedOptions);
396
+ }
397
+ }
398
+ createContainerComponent(appendTo) {
399
+ const containerSubject = new Subject();
400
+ const notificationContainerComponent = createComponent(NotificationContainerComponent, {
401
+ environmentInjector: this.#appRef.injector
402
+ });
403
+ const host = appendTo ? appendTo.element.nativeElement : this.#document.body;
404
+ notificationContainerComponent.instance.positionType.set(appendTo ? "absolute" : "fixed");
405
+ host.appendChild(notificationContainerComponent.location.nativeElement);
406
+ this.#appRef.attachView(notificationContainerComponent.hostView);
407
+ notificationContainerComponent.changeDetectorRef.detectChanges();
408
+ window.setTimeout(() => {
409
+ containerSubject.next(notificationContainerComponent);
410
+ });
411
+ return containerSubject;
412
+ }
413
+ createNotification(options) {
414
+ const position = options.position;
415
+ const notificationContainerData = this.notificationContainerMap.get(position);
416
+ if (!notificationContainerData) {
417
+ throw new Error(`Notification container for position ${position} was not found.`);
418
+ }
419
+ const componentDestroy$ = new Subject();
420
+ const afterHide$ = new Subject();
421
+ const notificationData = {
422
+ options,
423
+ componentDestroy$,
424
+ afterHide$,
425
+ contentComponentRef: signal(null)
426
+ };
427
+ if (!notificationContainerData.notifications.has(options.id)) {
428
+ notificationContainerData.notifications.set(options.id, notificationData);
429
+ if (notificationContainerData.componentRef) {
430
+ notificationContainerData.componentRef.instance.notificationDataList.set(Array.from(notificationContainerData.notifications.values()));
431
+ }
432
+ }
433
+ componentDestroy$.pipe(take(1)).subscribe(id => {
434
+ afterHide$.next();
435
+ afterHide$.complete();
436
+ this.removeNotificationData(id, position);
437
+ });
438
+ return {
439
+ afterHide: afterHide$.asObservable(),
440
+ get content() {
441
+ return notificationData.contentComponentRef();
442
+ },
443
+ hide: () => this.hide(options.id)
444
+ };
445
+ }
446
+ createNotificationContainer(options) {
447
+ const position = options.position;
448
+ const ref = this.createNotification(options);
449
+ this.notificationContainerSubscriptions[position] = this.createContainerComponent(options.appendTo).subscribe(ncr => {
450
+ ncr.instance.position.set(options.position);
451
+ const notificationContainerData = this.notificationContainerMap.get(position);
452
+ notificationContainerData.componentRef = ncr;
453
+ notificationContainerData.appendTo = options.appendTo;
454
+ notificationContainerData.subscription = this.notificationContainerSubscriptions[position];
455
+ ncr.instance.notificationDataList.set(Array.from(notificationContainerData.notifications.values()));
456
+ });
457
+ return ref;
458
+ }
459
+ getNotificationDataById(id) {
460
+ for (const notificationContainerData of this.notificationContainerMap.values()) {
461
+ const notificationData = notificationContainerData.notifications.get(id);
462
+ if (notificationData) {
463
+ return notificationData;
464
+ }
465
+ }
466
+ return null;
467
+ }
468
+ initialize() {
469
+ this.notificationContainerMap.set("bottom", {
470
+ componentRef: null,
471
+ notifications: new Map()
472
+ });
473
+ this.notificationContainerMap.set("bottomleft", {
474
+ componentRef: null,
475
+ notifications: new Map()
476
+ });
477
+ this.notificationContainerMap.set("bottomright", {
478
+ componentRef: null,
479
+ notifications: new Map()
480
+ });
481
+ this.notificationContainerMap.set("top", {
482
+ componentRef: null,
483
+ notifications: new Map()
484
+ });
485
+ this.notificationContainerMap.set("topleft", {
486
+ componentRef: null,
487
+ notifications: new Map()
488
+ });
489
+ this.notificationContainerMap.set("topright", {
490
+ componentRef: null,
491
+ notifications: new Map()
492
+ });
493
+ }
494
+ removeNotificationData(id, position) {
495
+ const container = this.notificationContainerMap.get(position);
496
+ if (!container) {
497
+ return;
498
+ }
499
+ container.notifications.delete(id);
500
+ if (container.componentRef) {
501
+ container.componentRef.instance.notificationDataList.set(Array.from(container.notifications.values()));
502
+ }
503
+ if (container.notifications.size === 0) {
504
+ container.subscription?.unsubscribe();
505
+ const componentRefToDestroy = container.componentRef;
506
+ container.componentRef = null;
507
+ container.subscription = undefined;
508
+ this.notificationContainerSubscriptions[position] = null;
509
+ window.setTimeout(() => {
510
+ if (componentRefToDestroy) {
511
+ this.#appRef.detachView(componentRefToDestroy.hostView);
512
+ componentRefToDestroy.destroy();
513
+ }
514
+ }, 300);
515
+ }
516
+ }
517
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: NotificationService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
518
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: NotificationService, providedIn: "root" }); }
519
+ }
520
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: NotificationService, decorators: [{
521
+ type: Injectable,
522
+ args: [{
523
+ providedIn: "root"
524
+ }]
525
+ }], ctorParameters: () => [] });
526
+
527
+ /*
528
+ * Public API Surface of @nanahoshi/mona-ui/notification
529
+ */
530
+
531
+ /**
532
+ * Generated bundle index. Do not edit.
533
+ */
534
+
535
+ export { NotificationService };
536
+ //# sourceMappingURL=nanahoshi-mona-ui-notification.mjs.map