@nanahoshi/mona-ui 0.34.0 → 0.36.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 (87) hide show
  1. package/alert/package.json +4 -0
  2. package/badge/package.json +4 -0
  3. package/docs/alert.md +219 -0
  4. package/docs/api/alert.md +78 -0
  5. package/docs/api/avatar.md +25 -0
  6. package/docs/api/badge.md +24 -0
  7. package/docs/api/common.md +3 -3
  8. package/docs/api/i18n.md +71 -5
  9. package/docs/api/locales.md +14 -14
  10. package/docs/api/masked-text-box.md +137 -0
  11. package/docs/api/multi-select.md +3 -0
  12. package/docs/api/separator.md +23 -0
  13. package/docs/api/toolbar.md +81 -0
  14. package/docs/avatar.md +108 -6
  15. package/docs/badge.md +181 -0
  16. package/docs/masked-textbox.md +334 -0
  17. package/docs/multi-select.md +120 -0
  18. package/docs/separator.md +147 -0
  19. package/docs/sidebar-menus.md +1 -1
  20. package/docs/toolbar.md +327 -0
  21. package/fesm2022/nanahoshi-mona-ui-alert.mjs +422 -0
  22. package/fesm2022/nanahoshi-mona-ui-avatar.mjs +182 -3
  23. package/fesm2022/nanahoshi-mona-ui-badge.mjs +273 -0
  24. package/fesm2022/nanahoshi-mona-ui-i18n-icu.mjs +20 -1
  25. package/fesm2022/nanahoshi-mona-ui-internal-list.mjs +54 -15
  26. package/fesm2022/nanahoshi-mona-ui-locales-ar-sa.mjs +13 -1
  27. package/fesm2022/nanahoshi-mona-ui-locales-de-de.mjs +13 -1
  28. package/fesm2022/nanahoshi-mona-ui-locales-es-es.mjs +13 -1
  29. package/fesm2022/nanahoshi-mona-ui-locales-fr-fr.mjs +13 -1
  30. package/fesm2022/nanahoshi-mona-ui-locales-id-id.mjs +13 -1
  31. package/fesm2022/nanahoshi-mona-ui-locales-it-it.mjs +13 -1
  32. package/fesm2022/nanahoshi-mona-ui-locales-ja-jp.mjs +13 -1
  33. package/fesm2022/nanahoshi-mona-ui-locales-ko-kr.mjs +13 -1
  34. package/fesm2022/nanahoshi-mona-ui-locales-pl-pl.mjs +13 -1
  35. package/fesm2022/nanahoshi-mona-ui-locales-pt-br.mjs +13 -1
  36. package/fesm2022/nanahoshi-mona-ui-locales-ru-ru.mjs +13 -1
  37. package/fesm2022/nanahoshi-mona-ui-locales-tr-tr.mjs +13 -1
  38. package/fesm2022/nanahoshi-mona-ui-locales-zh-cn.mjs +13 -1
  39. package/fesm2022/nanahoshi-mona-ui-locales-zh-tw.mjs +13 -1
  40. package/fesm2022/nanahoshi-mona-ui-masked-text-box.mjs +1302 -0
  41. package/fesm2022/nanahoshi-mona-ui-multi-select.mjs +112 -3
  42. package/fesm2022/nanahoshi-mona-ui-separator.mjs +165 -0
  43. package/fesm2022/nanahoshi-mona-ui-sidebar.mjs +3 -3
  44. package/fesm2022/nanahoshi-mona-ui-toolbar.mjs +536 -0
  45. package/i18n/catalogs/en-US.messages.json +19 -1
  46. package/llms.txt +13 -3
  47. package/locales/ar-sa/ar-sa.messages.json +19 -1
  48. package/locales/de-de/de-de.messages.json +19 -1
  49. package/locales/es-es/es-es.messages.json +19 -1
  50. package/locales/fr-fr/fr-fr.messages.json +19 -1
  51. package/locales/id-id/id-id.messages.json +19 -1
  52. package/locales/it-it/it-it.messages.json +19 -1
  53. package/locales/ja-jp/ja-jp.messages.json +19 -1
  54. package/locales/ko-kr/ko-kr.messages.json +19 -1
  55. package/locales/pl-pl/pl-pl.messages.json +19 -1
  56. package/locales/pt-br/pt-br.messages.json +19 -1
  57. package/locales/ru-ru/ru-ru.messages.json +19 -1
  58. package/locales/tr-tr/tr-tr.messages.json +19 -1
  59. package/locales/zh-cn/zh-cn.messages.json +19 -1
  60. package/locales/zh-tw/zh-tw.messages.json +19 -1
  61. package/masked-text-box/package.json +4 -0
  62. package/package.json +21 -1
  63. package/separator/package.json +4 -0
  64. package/toolbar/package.json +4 -0
  65. package/types/nanahoshi-mona-ui-alert.d.ts +144 -0
  66. package/types/nanahoshi-mona-ui-avatar.d.ts +66 -0
  67. package/types/nanahoshi-mona-ui-badge.d.ts +82 -0
  68. package/types/nanahoshi-mona-ui-i18n.d.ts +44 -0
  69. package/types/nanahoshi-mona-ui-internal-list.d.ts +12 -0
  70. package/types/nanahoshi-mona-ui-locales-ar-sa.d.ts +18 -0
  71. package/types/nanahoshi-mona-ui-locales-de-de.d.ts +18 -0
  72. package/types/nanahoshi-mona-ui-locales-es-es.d.ts +18 -0
  73. package/types/nanahoshi-mona-ui-locales-fr-fr.d.ts +18 -0
  74. package/types/nanahoshi-mona-ui-locales-id-id.d.ts +18 -0
  75. package/types/nanahoshi-mona-ui-locales-it-it.d.ts +18 -0
  76. package/types/nanahoshi-mona-ui-locales-ja-jp.d.ts +18 -0
  77. package/types/nanahoshi-mona-ui-locales-ko-kr.d.ts +18 -0
  78. package/types/nanahoshi-mona-ui-locales-pl-pl.d.ts +18 -0
  79. package/types/nanahoshi-mona-ui-locales-pt-br.d.ts +18 -0
  80. package/types/nanahoshi-mona-ui-locales-ru-ru.d.ts +18 -0
  81. package/types/nanahoshi-mona-ui-locales-tr-tr.d.ts +18 -0
  82. package/types/nanahoshi-mona-ui-locales-zh-cn.d.ts +18 -0
  83. package/types/nanahoshi-mona-ui-locales-zh-tw.d.ts +18 -0
  84. package/types/nanahoshi-mona-ui-masked-text-box.d.ts +391 -0
  85. package/types/nanahoshi-mona-ui-multi-select.d.ts +38 -0
  86. package/types/nanahoshi-mona-ui-separator.d.ts +66 -0
  87. package/types/nanahoshi-mona-ui-toolbar.d.ts +183 -0
@@ -0,0 +1,422 @@
1
+ import { NgTemplateOutlet } from "@angular/common";
2
+ import * as i0 from "@angular/core";
3
+ import { Component, Directive, TemplateRef, afterNextRender, booleanAttribute, computed, contentChild, inject, input, output, viewChild } from "@angular/core";
4
+ import { LucideCircleCheck, LucideCircleX, LucideInfo, LucideTriangleAlert, LucideX } from "@lucide/angular";
5
+ import { ButtonDirective } from "@nanahoshi/mona-ui/button";
6
+ import { classInputToClass } from "@nanahoshi/mona-ui/common";
7
+ import { MonaI18nService } from "@nanahoshi/mona-ui/i18n";
8
+ import { injectLiveAnnouncer } from "@nanahoshi/mona-ui/internal/live-announcer";
9
+ import { twMerge } from "tailwind-merge";
10
+ import { cva } from "class-variance-authority";
11
+ const ALERT_DEFAULT_MESSAGES = { dismissLabel: (title) => title ? `Dismiss, ${title}` : "Dismiss" };
12
+ var AlertIconTemplateDirective = class AlertIconTemplateDirective {
13
+ static {
14
+ this.ɵfac = i0.ɵɵngDeclareFactory({
15
+ minVersion: "12.0.0",
16
+ version: "22.2.6",
17
+ ngImport: i0,
18
+ type: AlertIconTemplateDirective,
19
+ deps: [],
20
+ target: i0.ɵɵFactoryTarget.Directive
21
+ });
22
+ }
23
+ static {
24
+ this.ɵdir = i0.ɵɵngDeclareDirective({
25
+ minVersion: "14.0.0",
26
+ version: "22.2.6",
27
+ type: AlertIconTemplateDirective,
28
+ isStandalone: true,
29
+ selector: "ng-template[monaAlertIconTemplate]",
30
+ ngImport: i0
31
+ });
32
+ }
33
+ };
34
+ i0.ɵɵngDeclareClassMetadata({
35
+ minVersion: "12.0.0",
36
+ version: "22.2.6",
37
+ ngImport: i0,
38
+ type: AlertIconTemplateDirective,
39
+ decorators: [{
40
+ type: Directive,
41
+ args: [{ selector: "ng-template[monaAlertIconTemplate]" }]
42
+ }]
43
+ });
44
+ const alertThemeVariants = cva(`
45
+ relative flex w-full items-start gap-3
46
+ rounded-lg border p-4 text-sm
47
+ `, {
48
+ variants: { look: {
49
+ error: "bg-error-subtle text-error-subtle-foreground border-error-border",
50
+ info: "bg-info-subtle text-info-subtle-foreground border-info-border",
51
+ neutral: "bg-secondary-subtle text-secondary-subtle-foreground border-secondary-border",
52
+ success: "bg-success-subtle text-success-subtle-foreground border-success-border",
53
+ warning: "bg-warning-subtle text-warning-subtle-foreground border-warning-border"
54
+ } },
55
+ defaultVariants: { look: "info" }
56
+ });
57
+ const ALERT_ICON_CLASSES = "flex h-5 shrink-0 items-center [&>svg]:size-4";
58
+ const ALERT_BODY_CLASSES = "flex min-w-0 flex-1 flex-col gap-1 leading-5";
59
+ const ALERT_TITLE_CLASSES = "font-semibold";
60
+ const ALERT_DISMISS_CLASSES = "-my-1.5 -me-2 shrink-0 text-current";
61
+ const alertActionsThemeVariants = cva("mt-2 flex flex-wrap items-center gap-2");
62
+ var AlertComponent = class AlertComponent {
63
+ #announcer;
64
+ #i18n;
65
+ constructor() {
66
+ this.#announcer = injectLiveAnnouncer();
67
+ this.#i18n = inject(MonaI18nService);
68
+ this.baseClass = computed(() => twMerge(alertThemeVariants({ look: this.look() }), this.userClass()), ...ngDevMode ? [{ debugName: "baseClass" }] : /* istanbul ignore next */ []);
69
+ this.bodyClass = ALERT_BODY_CLASSES;
70
+ this.descriptionElement = viewChild.required("descriptionElement", ...ngDevMode ? [{ debugName: "descriptionElement" }] : /* istanbul ignore next */ []);
71
+ this.dismissClass = ALERT_DISMISS_CLASSES;
72
+ this.iconClass = ALERT_ICON_CLASSES;
73
+ this.iconTemplate = contentChild(AlertIconTemplateDirective, {
74
+ ...ngDevMode ? { debugName: "iconTemplate" } : /* istanbul ignore next */ {},
75
+ read: TemplateRef
76
+ });
77
+ this.messages = this.#i18n.componentMessages("alert", ALERT_DEFAULT_MESSAGES);
78
+ this.titleClass = ALERT_TITLE_CLASSES;
79
+ this.titleElement = viewChild("titleElement", ...ngDevMode ? [{ debugName: "titleElement" }] : /* istanbul ignore next */ []);
80
+ this.announce = input("off", ...ngDevMode ? [{ debugName: "announce" }] : /* istanbul ignore next */ []);
81
+ this.dismiss = output();
82
+ this.dismissLabel = input("", ...ngDevMode ? [{ debugName: "dismissLabel" }] : /* istanbul ignore next */ []);
83
+ this.dismissible = input(false, {
84
+ ...ngDevMode ? { debugName: "dismissible" } : /* istanbul ignore next */ {},
85
+ transform: booleanAttribute
86
+ });
87
+ this.look = input("info", ...ngDevMode ? [{ debugName: "look" }] : /* istanbul ignore next */ []);
88
+ this.showIcon = input(true, {
89
+ ...ngDevMode ? { debugName: "showIcon" } : /* istanbul ignore next */ {},
90
+ transform: booleanAttribute
91
+ });
92
+ this.title = input("", ...ngDevMode ? [{ debugName: "title" }] : /* istanbul ignore next */ []);
93
+ this.userClass = input("", {
94
+ ...ngDevMode ? { debugName: "userClass" } : /* istanbul ignore next */ {},
95
+ alias: "class",
96
+ transform: (value) => classInputToClass(value)
97
+ });
98
+ afterNextRender({ read: () => this.#announceOnShow() });
99
+ }
100
+ #announceOnShow() {
101
+ const politeness = this.announce();
102
+ if (politeness === "off") return;
103
+ const message = [this.titleElement()?.nativeElement, this.descriptionElement().nativeElement].map((element) => element?.textContent?.replace(/\s+/g, " ").trim() ?? "").filter((text) => text !== "").join(". ");
104
+ if (message !== "") this.#announcer.announce(message, politeness);
105
+ }
106
+ static {
107
+ this.ɵfac = i0.ɵɵngDeclareFactory({
108
+ minVersion: "12.0.0",
109
+ version: "22.2.6",
110
+ ngImport: i0,
111
+ type: AlertComponent,
112
+ deps: [],
113
+ target: i0.ɵɵFactoryTarget.Component
114
+ });
115
+ }
116
+ static {
117
+ this.ɵcmp = i0.ɵɵngDeclareComponent({
118
+ minVersion: "17.0.0",
119
+ version: "22.2.6",
120
+ type: AlertComponent,
121
+ isStandalone: true,
122
+ selector: "mona-alert",
123
+ inputs: {
124
+ announce: {
125
+ classPropertyName: "announce",
126
+ publicName: "announce",
127
+ isSignal: true,
128
+ isRequired: false,
129
+ transformFunction: null
130
+ },
131
+ dismissLabel: {
132
+ classPropertyName: "dismissLabel",
133
+ publicName: "dismissLabel",
134
+ isSignal: true,
135
+ isRequired: false,
136
+ transformFunction: null
137
+ },
138
+ dismissible: {
139
+ classPropertyName: "dismissible",
140
+ publicName: "dismissible",
141
+ isSignal: true,
142
+ isRequired: false,
143
+ transformFunction: null
144
+ },
145
+ look: {
146
+ classPropertyName: "look",
147
+ publicName: "look",
148
+ isSignal: true,
149
+ isRequired: false,
150
+ transformFunction: null
151
+ },
152
+ showIcon: {
153
+ classPropertyName: "showIcon",
154
+ publicName: "showIcon",
155
+ isSignal: true,
156
+ isRequired: false,
157
+ transformFunction: null
158
+ },
159
+ title: {
160
+ classPropertyName: "title",
161
+ publicName: "title",
162
+ isSignal: true,
163
+ isRequired: false,
164
+ transformFunction: null
165
+ },
166
+ userClass: {
167
+ classPropertyName: "userClass",
168
+ publicName: "class",
169
+ isSignal: true,
170
+ isRequired: false,
171
+ transformFunction: null
172
+ }
173
+ },
174
+ outputs: { dismiss: "dismiss" },
175
+ host: { properties: { "class": "baseClass()" } },
176
+ queries: [{
177
+ propertyName: "iconTemplate",
178
+ first: true,
179
+ predicate: AlertIconTemplateDirective,
180
+ descendants: true,
181
+ read: TemplateRef,
182
+ isSignal: true
183
+ }],
184
+ viewQueries: [{
185
+ propertyName: "descriptionElement",
186
+ first: true,
187
+ predicate: ["descriptionElement"],
188
+ descendants: true,
189
+ isSignal: true
190
+ }, {
191
+ propertyName: "titleElement",
192
+ first: true,
193
+ predicate: ["titleElement"],
194
+ descendants: true,
195
+ isSignal: true
196
+ }],
197
+ ngImport: i0,
198
+ template: "@if (showIcon()) {\n <span [class]=\"iconClass\" aria-hidden=\"true\">\n @if (iconTemplate(); as template) {\n <ng-container [ngTemplateOutlet]=\"template\"></ng-container>\n } @else {\n @switch (look()) {\n @case (\"success\") {\n <svg lucideCircleCheck></svg>\n }\n @case (\"warning\") {\n <svg lucideTriangleAlert></svg>\n }\n @case (\"error\") {\n <svg lucideCircleX></svg>\n }\n @default {\n <svg lucideInfo></svg>\n }\n }\n }\n </span>\n}\n\n<div [class]=\"bodyClass\">\n @if (title()) {\n <div #titleElement [class]=\"titleClass\">{{ title() }}</div>\n }\n <div #descriptionElement>\n <ng-content></ng-content>\n </div>\n <ng-content select=\"[monaAlertActions]\"></ng-content>\n</div>\n\n@if (dismissible()) {\n <button\n monaButton\n type=\"button\"\n look=\"ghost\"\n size=\"small\"\n [iconOnly]=\"true\"\n [class]=\"dismissClass\"\n [attr.aria-label]=\"dismissLabel() || messages().dismissLabel(title() || undefined)\"\n (click)=\"dismiss.emit($event)\">\n <svg lucideX [size]=\"16\"></svg>\n </button>\n}\n",
199
+ dependencies: [
200
+ {
201
+ kind: "directive",
202
+ type: ButtonDirective,
203
+ selector: "button[monaButton]",
204
+ inputs: [
205
+ "aria-haspopup",
206
+ "disabled",
207
+ "iconOnly",
208
+ "loading",
209
+ "look",
210
+ "rounded",
211
+ "selected",
212
+ "size",
213
+ "tabindex",
214
+ "toggleable",
215
+ "type",
216
+ "class",
217
+ "value"
218
+ ],
219
+ outputs: ["lookChange", "selectedChange"]
220
+ },
221
+ {
222
+ kind: "component",
223
+ type: LucideCircleCheck,
224
+ selector: "svg[lucideCircleCheck], svg[lucideCheckCircle2]"
225
+ },
226
+ {
227
+ kind: "component",
228
+ type: LucideCircleX,
229
+ selector: "svg[lucideCircleX], svg[lucideXCircle]"
230
+ },
231
+ {
232
+ kind: "component",
233
+ type: LucideInfo,
234
+ selector: "svg[lucideInfo]"
235
+ },
236
+ {
237
+ kind: "component",
238
+ type: LucideTriangleAlert,
239
+ selector: "svg[lucideTriangleExclamationPoint], svg[lucideAlertTriangle], svg[lucideTriangleAlert]"
240
+ },
241
+ {
242
+ kind: "component",
243
+ type: LucideX,
244
+ selector: "svg[lucideX]"
245
+ },
246
+ {
247
+ kind: "directive",
248
+ type: NgTemplateOutlet,
249
+ selector: "[ngTemplateOutlet]",
250
+ inputs: [
251
+ "ngTemplateOutletContext",
252
+ "ngTemplateOutlet",
253
+ "ngTemplateOutletInjector"
254
+ ]
255
+ }
256
+ ]
257
+ });
258
+ }
259
+ };
260
+ i0.ɵɵngDeclareClassMetadata({
261
+ minVersion: "12.0.0",
262
+ version: "22.2.6",
263
+ ngImport: i0,
264
+ type: AlertComponent,
265
+ decorators: [{
266
+ type: Component,
267
+ args: [{
268
+ selector: "mona-alert",
269
+ imports: [
270
+ ButtonDirective,
271
+ LucideCircleCheck,
272
+ LucideCircleX,
273
+ LucideInfo,
274
+ LucideTriangleAlert,
275
+ LucideX,
276
+ NgTemplateOutlet
277
+ ],
278
+ host: { "[class]": "baseClass()" },
279
+ template: "@if (showIcon()) {\n <span [class]=\"iconClass\" aria-hidden=\"true\">\n @if (iconTemplate(); as template) {\n <ng-container [ngTemplateOutlet]=\"template\"></ng-container>\n } @else {\n @switch (look()) {\n @case (\"success\") {\n <svg lucideCircleCheck></svg>\n }\n @case (\"warning\") {\n <svg lucideTriangleAlert></svg>\n }\n @case (\"error\") {\n <svg lucideCircleX></svg>\n }\n @default {\n <svg lucideInfo></svg>\n }\n }\n }\n </span>\n}\n\n<div [class]=\"bodyClass\">\n @if (title()) {\n <div #titleElement [class]=\"titleClass\">{{ title() }}</div>\n }\n <div #descriptionElement>\n <ng-content></ng-content>\n </div>\n <ng-content select=\"[monaAlertActions]\"></ng-content>\n</div>\n\n@if (dismissible()) {\n <button\n monaButton\n type=\"button\"\n look=\"ghost\"\n size=\"small\"\n [iconOnly]=\"true\"\n [class]=\"dismissClass\"\n [attr.aria-label]=\"dismissLabel() || messages().dismissLabel(title() || undefined)\"\n (click)=\"dismiss.emit($event)\">\n <svg lucideX [size]=\"16\"></svg>\n </button>\n}\n"
280
+ }]
281
+ }],
282
+ ctorParameters: () => [],
283
+ propDecorators: {
284
+ descriptionElement: [{
285
+ type: i0.ViewChild,
286
+ args: ["descriptionElement", { isSignal: true }]
287
+ }],
288
+ iconTemplate: [{
289
+ type: i0.ContentChild,
290
+ args: [i0.forwardRef(() => AlertIconTemplateDirective), {
291
+ read: TemplateRef,
292
+ isSignal: true
293
+ }]
294
+ }],
295
+ titleElement: [{
296
+ type: i0.ViewChild,
297
+ args: ["titleElement", { isSignal: true }]
298
+ }],
299
+ announce: [{
300
+ type: i0.Input,
301
+ args: [{
302
+ isSignal: true,
303
+ alias: "announce",
304
+ required: false
305
+ }]
306
+ }],
307
+ dismiss: [{
308
+ type: i0.Output,
309
+ args: ["dismiss"]
310
+ }],
311
+ dismissLabel: [{
312
+ type: i0.Input,
313
+ args: [{
314
+ isSignal: true,
315
+ alias: "dismissLabel",
316
+ required: false
317
+ }]
318
+ }],
319
+ dismissible: [{
320
+ type: i0.Input,
321
+ args: [{
322
+ isSignal: true,
323
+ alias: "dismissible",
324
+ required: false
325
+ }]
326
+ }],
327
+ look: [{
328
+ type: i0.Input,
329
+ args: [{
330
+ isSignal: true,
331
+ alias: "look",
332
+ required: false
333
+ }]
334
+ }],
335
+ showIcon: [{
336
+ type: i0.Input,
337
+ args: [{
338
+ isSignal: true,
339
+ alias: "showIcon",
340
+ required: false
341
+ }]
342
+ }],
343
+ title: [{
344
+ type: i0.Input,
345
+ args: [{
346
+ isSignal: true,
347
+ alias: "title",
348
+ required: false
349
+ }]
350
+ }],
351
+ userClass: [{
352
+ type: i0.Input,
353
+ args: [{
354
+ isSignal: true,
355
+ alias: "class",
356
+ required: false
357
+ }]
358
+ }]
359
+ }
360
+ });
361
+ var AlertActionsDirective = class AlertActionsDirective {
362
+ constructor() {
363
+ this.baseClass = computed(() => twMerge(alertActionsThemeVariants(), this.userClass()), ...ngDevMode ? [{ debugName: "baseClass" }] : /* istanbul ignore next */ []);
364
+ this.userClass = input("", {
365
+ ...ngDevMode ? { debugName: "userClass" } : /* istanbul ignore next */ {},
366
+ alias: "class",
367
+ transform: (value) => classInputToClass(value)
368
+ });
369
+ }
370
+ static {
371
+ this.ɵfac = i0.ɵɵngDeclareFactory({
372
+ minVersion: "12.0.0",
373
+ version: "22.2.6",
374
+ ngImport: i0,
375
+ type: AlertActionsDirective,
376
+ deps: [],
377
+ target: i0.ɵɵFactoryTarget.Directive
378
+ });
379
+ }
380
+ static {
381
+ this.ɵdir = i0.ɵɵngDeclareDirective({
382
+ minVersion: "17.1.0",
383
+ version: "22.2.6",
384
+ type: AlertActionsDirective,
385
+ isStandalone: true,
386
+ selector: "[monaAlertActions]",
387
+ inputs: { userClass: {
388
+ classPropertyName: "userClass",
389
+ publicName: "class",
390
+ isSignal: true,
391
+ isRequired: false,
392
+ transformFunction: null
393
+ } },
394
+ host: { properties: { "class": "baseClass()" } },
395
+ ngImport: i0
396
+ });
397
+ }
398
+ };
399
+ i0.ɵɵngDeclareClassMetadata({
400
+ minVersion: "12.0.0",
401
+ version: "22.2.6",
402
+ ngImport: i0,
403
+ type: AlertActionsDirective,
404
+ decorators: [{
405
+ type: Directive,
406
+ args: [{
407
+ selector: "[monaAlertActions]",
408
+ host: { "[class]": "baseClass()" }
409
+ }]
410
+ }],
411
+ propDecorators: { userClass: [{
412
+ type: i0.Input,
413
+ args: [{
414
+ isSignal: true,
415
+ alias: "class",
416
+ required: false
417
+ }]
418
+ }] }
419
+ });
420
+ export { ALERT_DEFAULT_MESSAGES, AlertActionsDirective, AlertComponent, AlertIconTemplateDirective };
421
+
422
+ //# sourceMappingURL=nanahoshi-mona-ui-alert.mjs.map
@@ -1,7 +1,17 @@
1
+ import { MonaI18nService, formatNumber } from "@nanahoshi/mona-ui/i18n";
1
2
  import * as i0 from "@angular/core";
2
- import { Component, computed, input, linkedSignal } from "@angular/core";
3
+ import { Component, InjectionToken, computed, contentChildren, inject, input, linkedSignal, numberAttribute } from "@angular/core";
4
+ import { classInputToClass } from "@nanahoshi/mona-ui/common";
5
+ import { twMerge } from "tailwind-merge";
6
+ import { cva } from "class-variance-authority";
7
+ function localizeNumber(value, options) {
8
+ return formatNumber(value, "en-US", options);
9
+ }
10
+ const AVATAR_DEFAULT_MESSAGES = { moreLabel: (count) => `${localizeNumber(count)} more` };
11
+ const AVATAR_GROUP = new InjectionToken("MONA_AVATAR_GROUP");
3
12
  var AvatarComponent = class AvatarComponent {
4
13
  constructor() {
14
+ this.#collapsed = inject(AVATAR_GROUP, { optional: true })?.isCollapsed(this);
5
15
  this.#imageFailed = linkedSignal({
6
16
  ...ngDevMode ? { debugName: "#imageFailed" } : /* istanbul ignore next */ {},
7
17
  source: () => this.image(),
@@ -27,7 +37,7 @@ var AvatarComponent = class AvatarComponent {
27
37
  borderStyle: "solid",
28
38
  borderRadius: this.borderRadius(),
29
39
  backgroundColor,
30
- display: "inline-block",
40
+ display: this.#collapsed?.() ? "none" : "inline-block",
31
41
  height: this.height(),
32
42
  width: this.width(),
33
43
  ...this.customStyles()
@@ -85,6 +95,7 @@ var AvatarComponent = class AvatarComponent {
85
95
  }
86
96
  });
87
97
  }
98
+ #collapsed;
88
99
  #imageFailed;
89
100
  onImageError() {
90
101
  this.#imageFailed.set(true);
@@ -365,6 +376,174 @@ i0.ɵɵngDeclareClassMetadata({
365
376
  }]
366
377
  }
367
378
  });
368
- export { AvatarComponent };
379
+ const avatarGroupThemeVariants = cva(`
380
+ inline-flex items-center
381
+ [&>*]:ring-2 [&>*]:ring-background
382
+ [&>*:not(:first-child)]:ms-(--mona-avatar-group-overlap)
383
+ `);
384
+ const AVATAR_GROUP_MORE_CLASSES = `
385
+ inline-flex items-center justify-center overflow-hidden
386
+ border-solid border-border bg-secondary text-secondary-foreground
387
+ font-semibold tabular-nums leading-none select-none
388
+ `;
389
+ var AvatarGroupComponent = class AvatarGroupComponent {
390
+ constructor() {
391
+ this.#i18n = inject(MonaI18nService);
392
+ this.avatars = contentChildren(AvatarComponent, ...ngDevMode ? [{ debugName: "avatars" }] : /* istanbul ignore next */ []);
393
+ this.baseClass = computed(() => twMerge(avatarGroupThemeVariants(), this.userClass()), ...ngDevMode ? [{ debugName: "baseClass" }] : /* istanbul ignore next */ []);
394
+ this.collapsedCount = computed(() => {
395
+ const max = this.max();
396
+ return max == null ? 0 : Math.max(0, this.avatars().length - max);
397
+ }, ...ngDevMode ? [{ debugName: "collapsedCount" }] : /* istanbul ignore next */ []);
398
+ this.messages = this.#i18n.componentMessages("avatar", AVATAR_DEFAULT_MESSAGES);
399
+ this.moreClass = AVATAR_GROUP_MORE_CLASSES;
400
+ this.moreStyles = computed(() => {
401
+ const first = this.avatars()[0];
402
+ const height = first?.height() ?? "64px";
403
+ return {
404
+ borderRadius: first?.borderRadius() ?? "0",
405
+ borderWidth: first?.borderWidth() ?? "1px",
406
+ fontSize: `calc(${height} * 0.36)`,
407
+ height,
408
+ width: first?.width() ?? "64px"
409
+ };
410
+ }, ...ngDevMode ? [{ debugName: "moreStyles" }] : /* istanbul ignore next */ []);
411
+ this.moreText = computed(() => formatNumber(this.collapsedCount(), this.#i18n.localeId(), { signDisplay: "always" }), ...ngDevMode ? [{ debugName: "moreText" }] : /* istanbul ignore next */ []);
412
+ this.overlap = computed(() => `calc(${this.avatars()[0]?.width() ?? "64px"} * -0.25)`, ...ngDevMode ? [{ debugName: "overlap" }] : /* istanbul ignore next */ []);
413
+ this.ariaLabel = input("", {
414
+ ...ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {},
415
+ alias: "aria-label"
416
+ });
417
+ this.max = input(null, {
418
+ ...ngDevMode ? { debugName: "max" } : /* istanbul ignore next */ {},
419
+ transform: (value) => value == null || value === "" ? null : Math.max(0, Math.floor(numberAttribute(value)))
420
+ });
421
+ this.userClass = input("", {
422
+ ...ngDevMode ? { debugName: "userClass" } : /* istanbul ignore next */ {},
423
+ alias: "class",
424
+ transform: (value) => classInputToClass(value)
425
+ });
426
+ }
427
+ #i18n;
428
+ isCollapsed(avatar) {
429
+ return computed(() => {
430
+ const max = this.max();
431
+ return max != null && this.avatars().indexOf(avatar) >= max;
432
+ });
433
+ }
434
+ static {
435
+ this.ɵfac = i0.ɵɵngDeclareFactory({
436
+ minVersion: "12.0.0",
437
+ version: "22.2.6",
438
+ ngImport: i0,
439
+ type: AvatarGroupComponent,
440
+ deps: [],
441
+ target: i0.ɵɵFactoryTarget.Component
442
+ });
443
+ }
444
+ static {
445
+ this.ɵcmp = i0.ɵɵngDeclareComponent({
446
+ minVersion: "17.0.0",
447
+ version: "22.2.6",
448
+ type: AvatarGroupComponent,
449
+ isStandalone: true,
450
+ selector: "mona-avatar-group",
451
+ inputs: {
452
+ ariaLabel: {
453
+ classPropertyName: "ariaLabel",
454
+ publicName: "aria-label",
455
+ isSignal: true,
456
+ isRequired: false,
457
+ transformFunction: null
458
+ },
459
+ max: {
460
+ classPropertyName: "max",
461
+ publicName: "max",
462
+ isSignal: true,
463
+ isRequired: false,
464
+ transformFunction: null
465
+ },
466
+ userClass: {
467
+ classPropertyName: "userClass",
468
+ publicName: "class",
469
+ isSignal: true,
470
+ isRequired: false,
471
+ transformFunction: null
472
+ }
473
+ },
474
+ host: { properties: {
475
+ "attr.aria-label": "ariaLabel() || null",
476
+ "attr.role": "'group'",
477
+ "class": "baseClass()",
478
+ "style.--mona-avatar-group-overlap": "overlap()"
479
+ } },
480
+ providers: [{
481
+ provide: AVATAR_GROUP,
482
+ useExisting: AvatarGroupComponent
483
+ }],
484
+ queries: [{
485
+ propertyName: "avatars",
486
+ predicate: AvatarComponent,
487
+ isSignal: true
488
+ }],
489
+ ngImport: i0,
490
+ template: "<ng-content></ng-content>\n@if (collapsedCount() > 0) {\n <span\n role=\"img\"\n [class]=\"moreClass\"\n [style]=\"moreStyles()\"\n [attr.aria-label]=\"messages().moreLabel(collapsedCount())\">\n {{ moreText() }}\n </span>\n}\n"
491
+ });
492
+ }
493
+ };
494
+ i0.ɵɵngDeclareClassMetadata({
495
+ minVersion: "12.0.0",
496
+ version: "22.2.6",
497
+ ngImport: i0,
498
+ type: AvatarGroupComponent,
499
+ decorators: [{
500
+ type: Component,
501
+ args: [{
502
+ selector: "mona-avatar-group",
503
+ providers: [{
504
+ provide: AVATAR_GROUP,
505
+ useExisting: AvatarGroupComponent
506
+ }],
507
+ host: {
508
+ "[attr.aria-label]": "ariaLabel() || null",
509
+ "[attr.role]": "'group'",
510
+ "[class]": "baseClass()",
511
+ "[style.--mona-avatar-group-overlap]": "overlap()"
512
+ },
513
+ template: "<ng-content></ng-content>\n@if (collapsedCount() > 0) {\n <span\n role=\"img\"\n [class]=\"moreClass\"\n [style]=\"moreStyles()\"\n [attr.aria-label]=\"messages().moreLabel(collapsedCount())\">\n {{ moreText() }}\n </span>\n}\n"
514
+ }]
515
+ }],
516
+ propDecorators: {
517
+ avatars: [{
518
+ type: i0.ContentChildren,
519
+ args: [i0.forwardRef(() => AvatarComponent), { isSignal: true }]
520
+ }],
521
+ ariaLabel: [{
522
+ type: i0.Input,
523
+ args: [{
524
+ isSignal: true,
525
+ alias: "aria-label",
526
+ required: false
527
+ }]
528
+ }],
529
+ max: [{
530
+ type: i0.Input,
531
+ args: [{
532
+ isSignal: true,
533
+ alias: "max",
534
+ required: false
535
+ }]
536
+ }],
537
+ userClass: [{
538
+ type: i0.Input,
539
+ args: [{
540
+ isSignal: true,
541
+ alias: "class",
542
+ required: false
543
+ }]
544
+ }]
545
+ }
546
+ });
547
+ export { AVATAR_DEFAULT_MESSAGES, AvatarComponent, AvatarGroupComponent };
369
548
 
370
549
  //# sourceMappingURL=nanahoshi-mona-ui-avatar.mjs.map