@nanahoshi/mona-ui 0.34.0 → 0.35.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 (80) 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 +2 -2
  8. package/docs/api/i18n.md +45 -0
  9. package/docs/api/locales.md +14 -14
  10. package/docs/api/multi-select.md +2 -0
  11. package/docs/api/separator.md +23 -0
  12. package/docs/api/toolbar.md +81 -0
  13. package/docs/avatar.md +108 -6
  14. package/docs/badge.md +181 -0
  15. package/docs/multi-select.md +54 -0
  16. package/docs/separator.md +147 -0
  17. package/docs/sidebar-menus.md +1 -1
  18. package/docs/toolbar.md +327 -0
  19. package/fesm2022/nanahoshi-mona-ui-alert.mjs +422 -0
  20. package/fesm2022/nanahoshi-mona-ui-avatar.mjs +182 -3
  21. package/fesm2022/nanahoshi-mona-ui-badge.mjs +273 -0
  22. package/fesm2022/nanahoshi-mona-ui-i18n-icu.mjs +10 -0
  23. package/fesm2022/nanahoshi-mona-ui-locales-ar-sa.mjs +3 -0
  24. package/fesm2022/nanahoshi-mona-ui-locales-de-de.mjs +3 -0
  25. package/fesm2022/nanahoshi-mona-ui-locales-es-es.mjs +3 -0
  26. package/fesm2022/nanahoshi-mona-ui-locales-fr-fr.mjs +3 -0
  27. package/fesm2022/nanahoshi-mona-ui-locales-id-id.mjs +3 -0
  28. package/fesm2022/nanahoshi-mona-ui-locales-it-it.mjs +3 -0
  29. package/fesm2022/nanahoshi-mona-ui-locales-ja-jp.mjs +3 -0
  30. package/fesm2022/nanahoshi-mona-ui-locales-ko-kr.mjs +3 -0
  31. package/fesm2022/nanahoshi-mona-ui-locales-pl-pl.mjs +3 -0
  32. package/fesm2022/nanahoshi-mona-ui-locales-pt-br.mjs +3 -0
  33. package/fesm2022/nanahoshi-mona-ui-locales-ru-ru.mjs +3 -0
  34. package/fesm2022/nanahoshi-mona-ui-locales-tr-tr.mjs +3 -0
  35. package/fesm2022/nanahoshi-mona-ui-locales-zh-cn.mjs +3 -0
  36. package/fesm2022/nanahoshi-mona-ui-locales-zh-tw.mjs +3 -0
  37. package/fesm2022/nanahoshi-mona-ui-multi-select.mjs +83 -2
  38. package/fesm2022/nanahoshi-mona-ui-separator.mjs +165 -0
  39. package/fesm2022/nanahoshi-mona-ui-sidebar.mjs +3 -3
  40. package/fesm2022/nanahoshi-mona-ui-toolbar.mjs +536 -0
  41. package/i18n/catalogs/en-US.messages.json +9 -0
  42. package/llms.txt +11 -3
  43. package/locales/ar-sa/ar-sa.messages.json +9 -0
  44. package/locales/de-de/de-de.messages.json +9 -0
  45. package/locales/es-es/es-es.messages.json +9 -0
  46. package/locales/fr-fr/fr-fr.messages.json +9 -0
  47. package/locales/id-id/id-id.messages.json +9 -0
  48. package/locales/it-it/it-it.messages.json +9 -0
  49. package/locales/ja-jp/ja-jp.messages.json +9 -0
  50. package/locales/ko-kr/ko-kr.messages.json +9 -0
  51. package/locales/pl-pl/pl-pl.messages.json +9 -0
  52. package/locales/pt-br/pt-br.messages.json +9 -0
  53. package/locales/ru-ru/ru-ru.messages.json +9 -0
  54. package/locales/tr-tr/tr-tr.messages.json +9 -0
  55. package/locales/zh-cn/zh-cn.messages.json +9 -0
  56. package/locales/zh-tw/zh-tw.messages.json +9 -0
  57. package/package.json +17 -1
  58. package/separator/package.json +4 -0
  59. package/toolbar/package.json +4 -0
  60. package/types/nanahoshi-mona-ui-alert.d.ts +144 -0
  61. package/types/nanahoshi-mona-ui-avatar.d.ts +66 -0
  62. package/types/nanahoshi-mona-ui-badge.d.ts +82 -0
  63. package/types/nanahoshi-mona-ui-i18n.d.ts +24 -0
  64. package/types/nanahoshi-mona-ui-locales-ar-sa.d.ts +9 -0
  65. package/types/nanahoshi-mona-ui-locales-de-de.d.ts +9 -0
  66. package/types/nanahoshi-mona-ui-locales-es-es.d.ts +9 -0
  67. package/types/nanahoshi-mona-ui-locales-fr-fr.d.ts +9 -0
  68. package/types/nanahoshi-mona-ui-locales-id-id.d.ts +9 -0
  69. package/types/nanahoshi-mona-ui-locales-it-it.d.ts +9 -0
  70. package/types/nanahoshi-mona-ui-locales-ja-jp.d.ts +9 -0
  71. package/types/nanahoshi-mona-ui-locales-ko-kr.d.ts +9 -0
  72. package/types/nanahoshi-mona-ui-locales-pl-pl.d.ts +9 -0
  73. package/types/nanahoshi-mona-ui-locales-pt-br.d.ts +9 -0
  74. package/types/nanahoshi-mona-ui-locales-ru-ru.d.ts +9 -0
  75. package/types/nanahoshi-mona-ui-locales-tr-tr.d.ts +9 -0
  76. package/types/nanahoshi-mona-ui-locales-zh-cn.d.ts +9 -0
  77. package/types/nanahoshi-mona-ui-locales-zh-tw.d.ts +9 -0
  78. package/types/nanahoshi-mona-ui-multi-select.d.ts +27 -0
  79. package/types/nanahoshi-mona-ui-separator.d.ts +66 -0
  80. package/types/nanahoshi-mona-ui-toolbar.d.ts +183 -0
@@ -1,6 +1,6 @@
1
1
  import { NgTemplateOutlet } from "@angular/common";
2
2
  import * as i0 from "@angular/core";
3
- import { Component, DestroyRef, Directive, ElementRef, Injectable, TemplateRef, afterNextRender, booleanAttribute, computed, contentChild, effect, forwardRef, inject, input, model, output, signal, untracked, viewChild } from "@angular/core";
3
+ import { Component, DestroyRef, Directive, ElementRef, Injectable, TemplateRef, afterNextRender, booleanAttribute, computed, contentChild, effect, forwardRef, inject, input, isDevMode, model, output, signal, untracked, viewChild } from "@angular/core";
4
4
  import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
5
5
  import { none } from "@mirei/ts-collections";
6
6
  import { CHIP_DEFAULT_MESSAGES, ChipComponent } from "@nanahoshi/mona-ui/chip";
@@ -147,6 +147,7 @@ var MultiSelectComponent = class MultiSelectComponent {
147
147
  #listService;
148
148
  #multiSelectService;
149
149
  #popupRef;
150
+ #navigatedByArrows;
150
151
  constructor() {
151
152
  this.#destroyRef = inject(DestroyRef);
152
153
  this.#dropdownService = inject(DropdownService);
@@ -162,6 +163,7 @@ var MultiSelectComponent = class MultiSelectComponent {
162
163
  this.#listService = inject(ListService);
163
164
  this.#multiSelectService = inject(MultiSelectService);
164
165
  this.#popupRef = this.#dropdownService.popupRef;
166
+ this.#navigatedByArrows = false;
165
167
  this.activeDescendant = computed(() => {
166
168
  const highlightedItem = this.#listService.highlightedItem();
167
169
  return highlightedItem ? highlightedItem.uid : null;
@@ -261,6 +263,10 @@ var MultiSelectComponent = class MultiSelectComponent {
261
263
  if (tagCount < 0) return itemCount;
262
264
  return tagCount;
263
265
  }, ...ngDevMode ? [{ debugName: "visibleTagCount" }] : /* istanbul ignore next */ []);
266
+ this.allowCustomValue = input(false, {
267
+ ...ngDevMode ? { debugName: "allowCustomValue" } : /* istanbul ignore next */ {},
268
+ transform: booleanAttribute
269
+ });
264
270
  this.ariaDescribedBy = input("", {
265
271
  ...ngDevMode ? { debugName: "ariaDescribedBy" } : /* istanbul ignore next */ {},
266
272
  alias: "aria-describedby"
@@ -328,6 +334,7 @@ var MultiSelectComponent = class MultiSelectComponent {
328
334
  alias: "class"
329
335
  });
330
336
  this.value = model([], ...ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []);
337
+ this.valueAdd = output();
331
338
  this.valueField = input(...ngDevMode ? [void 0, { debugName: "valueField" }] : /* istanbul ignore next */ []);
332
339
  this.valuePrimitive = input(false, {
333
340
  ...ngDevMode ? { debugName: "valuePrimitive" } : /* istanbul ignore next */ {},
@@ -337,6 +344,7 @@ var MultiSelectComponent = class MultiSelectComponent {
337
344
  this.initialize();
338
345
  this.setEventListeners();
339
346
  this.setSubscriptions();
347
+ this.warnIfCustomValueHasNoFilter();
340
348
  } });
341
349
  effect(() => {
342
350
  const popupTemplate = this.popupTemplate();
@@ -355,6 +363,21 @@ var MultiSelectComponent = class MultiSelectComponent {
355
363
  const checkboxVisible = this.checkboxes();
356
364
  untracked(() => this.#listService.setSelectableOptions({ checkboxes: checkboxVisible }));
357
365
  });
366
+ effect((onCleanup) => {
367
+ const popupElement = this.#popupRef()?.overlayRef.overlayElement;
368
+ if (popupElement == null) return;
369
+ this.#navigatedByArrows = false;
370
+ const onKeydown = (event) => this.handlePopupKeydown(event);
371
+ const onInput = () => {
372
+ this.#navigatedByArrows = false;
373
+ };
374
+ popupElement.addEventListener("keydown", onKeydown, true);
375
+ popupElement.addEventListener("input", onInput, true);
376
+ onCleanup(() => {
377
+ popupElement.removeEventListener("keydown", onKeydown, true);
378
+ popupElement.removeEventListener("input", onInput, true);
379
+ });
380
+ });
358
381
  }
359
382
  focus(options) {
360
383
  this.#hostElementRef.nativeElement.focus(options);
@@ -399,6 +422,21 @@ var MultiSelectComponent = class MultiSelectComponent {
399
422
  this.#listService.clearSelections();
400
423
  this.focus();
401
424
  }
425
+ addCustomValue(input, text) {
426
+ const caseSensitive = this.#listService.filterableOptions().caseSensitive;
427
+ const match = this.#listService.getMatchingFilteredItem(text);
428
+ const matchText = match ? this.#listService.getItemText(match) : null;
429
+ const exact = matchText != null && (caseSensitive ? matchText === text : matchText.toLowerCase() === text.toLowerCase());
430
+ if (match && exact) {
431
+ if (!this.#listService.isSelected(match)) {
432
+ this.#listService.selectItem(match);
433
+ this.updateValue(this.getSelectedControlValues());
434
+ }
435
+ } else this.valueAdd.emit(text);
436
+ input.value = "";
437
+ input.dispatchEvent(new Event("input", { bubbles: true }));
438
+ if (this.autoClose()) this.#popupRef()?.close();
439
+ }
402
440
  getSelectedControlValues() {
403
441
  return this.selectedListItems().select((item) => {
404
442
  return this.valuePrimitive() ? this.#listService.getDataItemValue(item.data) : item.data;
@@ -411,6 +449,26 @@ var MultiSelectComponent = class MultiSelectComponent {
411
449
  }
412
450
  this.toggleHighlightedItem();
413
451
  }
452
+ handlePopupKeydown(event) {
453
+ if (event.key === "ArrowDown" || event.key === "ArrowUp") {
454
+ this.#navigatedByArrows = true;
455
+ return;
456
+ }
457
+ const input = event.target;
458
+ if (event.key !== "Enter" || event.isComposing || event.keyCode === 229 || !(input instanceof HTMLInputElement)) return;
459
+ const text = input.value.trim();
460
+ const highlightedItem = this.#listService.highlightedItem();
461
+ if (this.allowCustomValue() && text !== "" && !(this.#navigatedByArrows && highlightedItem != null)) {
462
+ event.preventDefault();
463
+ event.stopPropagation();
464
+ this.addCustomValue(input, text);
465
+ return;
466
+ }
467
+ if (highlightedItem == null) {
468
+ event.preventDefault();
469
+ event.stopPropagation();
470
+ }
471
+ }
414
472
  handlePopupPositionUpdate() {
415
473
  const popupRef = this.#popupRef();
416
474
  if (!popupRef) return;
@@ -475,6 +533,9 @@ var MultiSelectComponent = class MultiSelectComponent {
475
533
  updateValue(value) {
476
534
  this.value.set(value);
477
535
  }
536
+ warnIfCustomValueHasNoFilter() {
537
+ if (isDevMode() && this.allowCustomValue() && !this.#listService.filterableOptions().enabled) console.warn("[Mona MultiSelect] allowCustomValue needs monaDropDownFilterable: custom values are typed in its filter box.", this.#hostElementRef.nativeElement);
538
+ }
478
539
  static {
479
540
  this.ɵfac = i0.ɵɵngDeclareFactory({
480
541
  minVersion: "12.0.0",
@@ -493,6 +554,13 @@ var MultiSelectComponent = class MultiSelectComponent {
493
554
  isStandalone: true,
494
555
  selector: "mona-multi-select",
495
556
  inputs: {
557
+ allowCustomValue: {
558
+ classPropertyName: "allowCustomValue",
559
+ publicName: "allowCustomValue",
560
+ isSignal: true,
561
+ isRequired: false,
562
+ transformFunction: null
563
+ },
496
564
  ariaDescribedBy: {
497
565
  classPropertyName: "ariaDescribedBy",
498
566
  publicName: "aria-describedby",
@@ -675,7 +743,8 @@ var MultiSelectComponent = class MultiSelectComponent {
675
743
  open: "open",
676
744
  opened: "opened",
677
745
  touch: "touch",
678
- value: "valueChange"
746
+ value: "valueChange",
747
+ valueAdd: "valueAdd"
679
748
  },
680
749
  host: {
681
750
  listeners: { "focusout": "onFocusOut($event)" },
@@ -1013,6 +1082,14 @@ i0.ɵɵngDeclareClassMetadata({
1013
1082
  isSignal: true
1014
1083
  }]
1015
1084
  }],
1085
+ allowCustomValue: [{
1086
+ type: i0.Input,
1087
+ args: [{
1088
+ isSignal: true,
1089
+ alias: "allowCustomValue",
1090
+ required: false
1091
+ }]
1092
+ }],
1016
1093
  ariaDescribedBy: [{
1017
1094
  type: i0.Input,
1018
1095
  args: [{
@@ -1220,6 +1297,10 @@ i0.ɵɵngDeclareClassMetadata({
1220
1297
  type: i0.Output,
1221
1298
  args: ["valueChange"]
1222
1299
  }],
1300
+ valueAdd: [{
1301
+ type: i0.Output,
1302
+ args: ["valueAdd"]
1303
+ }],
1223
1304
  valueField: [{
1224
1305
  type: i0.Input,
1225
1306
  args: [{
@@ -0,0 +1,165 @@
1
+ import * as i0 from "@angular/core";
2
+ import { Component, booleanAttribute, computed, input } from "@angular/core";
3
+ import { classInputToClass } from "@nanahoshi/mona-ui/common";
4
+ import { twMerge } from "tailwind-merge";
5
+ import { cva } from "class-variance-authority";
6
+ const LINE_CLASSES = "bg-border forced-colors:bg-[CanvasText]";
7
+ const separatorThemeVariants = cva("shrink-0", {
8
+ variants: {
9
+ labelled: {
10
+ false: LINE_CLASSES,
11
+ true: "flex w-full items-center gap-3 text-xs text-muted-foreground"
12
+ },
13
+ orientation: {
14
+ horizontal: "",
15
+ vertical: ""
16
+ }
17
+ },
18
+ compoundVariants: [{
19
+ labelled: false,
20
+ orientation: "horizontal",
21
+ class: "block h-px w-full"
22
+ }, {
23
+ labelled: false,
24
+ orientation: "vertical",
25
+ class: "inline-block w-px self-stretch"
26
+ }],
27
+ defaultVariants: {
28
+ labelled: false,
29
+ orientation: "horizontal"
30
+ }
31
+ });
32
+ const SEPARATOR_LABEL_LINE_CLASSES = `h-px flex-1 ${LINE_CLASSES}`;
33
+ var SeparatorComponent = class SeparatorComponent {
34
+ constructor() {
35
+ this.baseClass = computed(() => twMerge(separatorThemeVariants({
36
+ labelled: this.labelled(),
37
+ orientation: this.labelled() ? "horizontal" : this.orientation()
38
+ }), this.userClass()), ...ngDevMode ? [{ debugName: "baseClass" }] : /* istanbul ignore next */ []);
39
+ this.labelled = computed(() => this.label() !== "", ...ngDevMode ? [{ debugName: "labelled" }] : /* istanbul ignore next */ []);
40
+ this.lineClass = SEPARATOR_LABEL_LINE_CLASSES;
41
+ this.role = computed(() => this.decorative() || this.labelled() ? null : "separator", ...ngDevMode ? [{ debugName: "role" }] : /* istanbul ignore next */ []);
42
+ this.decorative = input(false, {
43
+ ...ngDevMode ? { debugName: "decorative" } : /* istanbul ignore next */ {},
44
+ transform: booleanAttribute
45
+ });
46
+ this.label = input("", ...ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []);
47
+ this.orientation = input("horizontal", ...ngDevMode ? [{ debugName: "orientation" }] : /* istanbul ignore next */ []);
48
+ this.userClass = input("", {
49
+ ...ngDevMode ? { debugName: "userClass" } : /* istanbul ignore next */ {},
50
+ alias: "class",
51
+ transform: (value) => classInputToClass(value)
52
+ });
53
+ }
54
+ static {
55
+ this.ɵfac = i0.ɵɵngDeclareFactory({
56
+ minVersion: "12.0.0",
57
+ version: "22.2.6",
58
+ ngImport: i0,
59
+ type: SeparatorComponent,
60
+ deps: [],
61
+ target: i0.ɵɵFactoryTarget.Component
62
+ });
63
+ }
64
+ static {
65
+ this.ɵcmp = i0.ɵɵngDeclareComponent({
66
+ minVersion: "17.0.0",
67
+ version: "22.2.6",
68
+ type: SeparatorComponent,
69
+ isStandalone: true,
70
+ selector: "mona-separator",
71
+ inputs: {
72
+ decorative: {
73
+ classPropertyName: "decorative",
74
+ publicName: "decorative",
75
+ isSignal: true,
76
+ isRequired: false,
77
+ transformFunction: null
78
+ },
79
+ label: {
80
+ classPropertyName: "label",
81
+ publicName: "label",
82
+ isSignal: true,
83
+ isRequired: false,
84
+ transformFunction: null
85
+ },
86
+ orientation: {
87
+ classPropertyName: "orientation",
88
+ publicName: "orientation",
89
+ isSignal: true,
90
+ isRequired: false,
91
+ transformFunction: null
92
+ },
93
+ userClass: {
94
+ classPropertyName: "userClass",
95
+ publicName: "class",
96
+ isSignal: true,
97
+ isRequired: false,
98
+ transformFunction: null
99
+ }
100
+ },
101
+ host: { properties: {
102
+ "attr.aria-orientation": "role() === 'separator' && orientation() === 'vertical' ? 'vertical' : null",
103
+ "attr.role": "role()",
104
+ "class": "baseClass()"
105
+ } },
106
+ ngImport: i0,
107
+ template: "@if (labelled()) {\n <span [class]=\"lineClass\" aria-hidden=\"true\"></span>\n <span>{{ label() }}</span>\n <span [class]=\"lineClass\" aria-hidden=\"true\"></span>\n}\n"
108
+ });
109
+ }
110
+ };
111
+ i0.ɵɵngDeclareClassMetadata({
112
+ minVersion: "12.0.0",
113
+ version: "22.2.6",
114
+ ngImport: i0,
115
+ type: SeparatorComponent,
116
+ decorators: [{
117
+ type: Component,
118
+ args: [{
119
+ selector: "mona-separator",
120
+ host: {
121
+ "[attr.aria-orientation]": "role() === 'separator' && orientation() === 'vertical' ? 'vertical' : null",
122
+ "[attr.role]": "role()",
123
+ "[class]": "baseClass()"
124
+ },
125
+ template: "@if (labelled()) {\n <span [class]=\"lineClass\" aria-hidden=\"true\"></span>\n <span>{{ label() }}</span>\n <span [class]=\"lineClass\" aria-hidden=\"true\"></span>\n}\n"
126
+ }]
127
+ }],
128
+ propDecorators: {
129
+ decorative: [{
130
+ type: i0.Input,
131
+ args: [{
132
+ isSignal: true,
133
+ alias: "decorative",
134
+ required: false
135
+ }]
136
+ }],
137
+ label: [{
138
+ type: i0.Input,
139
+ args: [{
140
+ isSignal: true,
141
+ alias: "label",
142
+ required: false
143
+ }]
144
+ }],
145
+ orientation: [{
146
+ type: i0.Input,
147
+ args: [{
148
+ isSignal: true,
149
+ alias: "orientation",
150
+ required: false
151
+ }]
152
+ }],
153
+ userClass: [{
154
+ type: i0.Input,
155
+ args: [{
156
+ isSignal: true,
157
+ alias: "class",
158
+ required: false
159
+ }]
160
+ }]
161
+ }
162
+ });
163
+ export { SeparatorComponent };
164
+
165
+ //# sourceMappingURL=nanahoshi-mona-ui-separator.mjs.map
@@ -10,6 +10,7 @@ import { TooltipDirective } from "@nanahoshi/mona-ui/tooltip";
10
10
  import { twMerge } from "tailwind-merge";
11
11
  import { isPlatformBrowser } from "@angular/common";
12
12
  import { cva } from "class-variance-authority";
13
+ import { BADGE_BASE_CLASSES } from "@nanahoshi/mona-ui/badge";
13
14
  import { SkeletonComponent } from "@nanahoshi/mona-ui/skeleton";
14
15
  import * as i1$1 from "@nanahoshi/mona-ui/text-box";
15
16
  import { TextBoxDirective } from "@nanahoshi/mona-ui/text-box";
@@ -613,9 +614,8 @@ const sidebarBackdropThemeVariants = cva(`
613
614
  false: "opacity-0 pointer-events-none"
614
615
  } } });
615
616
  const sidebarMenuBadgeThemeVariants = cva(`
616
- ms-auto flex items-center justify-center shrink-0
617
- min-w-5 h-5 px-1.5
618
- rounded-md text-xs font-medium tabular-nums
617
+ ${BADGE_BASE_CLASSES}
618
+ ms-auto h-5 min-w-5 px-1.5 rounded-md text-xs
619
619
  bg-(--color-sidebar-accent) text-(--color-sidebar-accent-foreground)
620
620
  pointer-events-none select-none
621
621
  `, { variants: { hidden: {