@nanahoshi/mona-ui 0.24.10 → 0.25.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 (165) hide show
  1. package/README.md +9 -0
  2. package/chart/README.md +223 -77
  3. package/fesm2022/nanahoshi-mona-ui-auto-complete.mjs +11 -10
  4. package/fesm2022/nanahoshi-mona-ui-avatar.mjs +37 -20
  5. package/fesm2022/nanahoshi-mona-ui-breadcrumb.mjs +239 -47
  6. package/fesm2022/nanahoshi-mona-ui-button-group.mjs +184 -31
  7. package/fesm2022/nanahoshi-mona-ui-button.mjs +47 -11
  8. package/fesm2022/nanahoshi-mona-ui-calendar.mjs +17 -13
  9. package/fesm2022/nanahoshi-mona-ui-card.mjs +54 -30
  10. package/fesm2022/nanahoshi-mona-ui-chart.mjs +1909 -666
  11. package/fesm2022/nanahoshi-mona-ui-check-box.mjs +112 -31
  12. package/fesm2022/nanahoshi-mona-ui-chip.mjs +131 -89
  13. package/fesm2022/nanahoshi-mona-ui-circular-progress-bar.mjs +59 -19
  14. package/fesm2022/nanahoshi-mona-ui-collapsible.mjs +118 -41
  15. package/fesm2022/nanahoshi-mona-ui-color-gradient.mjs +243 -212
  16. package/fesm2022/nanahoshi-mona-ui-color-palette.mjs +155 -86
  17. package/fesm2022/nanahoshi-mona-ui-color-picker.mjs +161 -131
  18. package/fesm2022/nanahoshi-mona-ui-combo-box.mjs +12 -11
  19. package/fesm2022/nanahoshi-mona-ui-common.mjs +18 -1
  20. package/fesm2022/nanahoshi-mona-ui-date-picker.mjs +10 -9
  21. package/fesm2022/nanahoshi-mona-ui-datetime-picker.mjs +10 -9
  22. package/fesm2022/nanahoshi-mona-ui-dialog.mjs +2 -2
  23. package/fesm2022/nanahoshi-mona-ui-dropdown-button.mjs +2 -2
  24. package/fesm2022/nanahoshi-mona-ui-dropdown-list.mjs +10 -9
  25. package/fesm2022/nanahoshi-mona-ui-editor.mjs +25 -24
  26. package/fesm2022/nanahoshi-mona-ui-expansion-panel.mjs +202 -33
  27. package/fesm2022/nanahoshi-mona-ui-fieldset.mjs +31 -10
  28. package/fesm2022/nanahoshi-mona-ui-filter.mjs +1 -1
  29. package/fesm2022/{nanahoshi-mona-ui-grid-grid-footer-row.component-DhKLnW06.mjs → nanahoshi-mona-ui-grid-grid-footer-row.component-2tVhD2hK.mjs} +2 -2
  30. package/fesm2022/{nanahoshi-mona-ui-grid-grid-list.component-voGbKOiB.mjs → nanahoshi-mona-ui-grid-grid-list.component-BAN70Wcn.mjs} +4 -4
  31. package/fesm2022/{nanahoshi-mona-ui-grid-grid-row.component-HQ1Kv6R9.mjs → nanahoshi-mona-ui-grid-grid-row.component-C_kCaA5b.mjs} +7 -7
  32. package/fesm2022/{nanahoshi-mona-ui-grid-grid-virtual-list.component-PNLJFcuH.mjs → nanahoshi-mona-ui-grid-grid-virtual-list.component-BsNfrAHz.mjs} +4 -4
  33. package/fesm2022/{nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-BO19AVwC.mjs → nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-CEfVa7eo.mjs} +27 -29
  34. package/fesm2022/nanahoshi-mona-ui-grid.mjs +1 -1
  35. package/fesm2022/nanahoshi-mona-ui-i18n-icu.mjs +146 -5
  36. package/fesm2022/nanahoshi-mona-ui-internal-filter-input.mjs +2 -2
  37. package/fesm2022/nanahoshi-mona-ui-internal-indicator-icon.mjs +1 -1
  38. package/fesm2022/nanahoshi-mona-ui-internal-list.mjs +5 -5
  39. package/fesm2022/nanahoshi-mona-ui-internal-tree.mjs +7 -7
  40. package/fesm2022/nanahoshi-mona-ui-internal.mjs +183 -47
  41. package/fesm2022/nanahoshi-mona-ui-label.mjs +111 -15
  42. package/fesm2022/nanahoshi-mona-ui-list-box.mjs +1 -1
  43. package/fesm2022/nanahoshi-mona-ui-list-view.mjs +1 -1
  44. package/fesm2022/nanahoshi-mona-ui-locales-ar-sa.mjs +111 -5
  45. package/fesm2022/nanahoshi-mona-ui-locales-de-de.mjs +103 -5
  46. package/fesm2022/nanahoshi-mona-ui-locales-es-es.mjs +103 -5
  47. package/fesm2022/nanahoshi-mona-ui-locales-fr-fr.mjs +100 -6
  48. package/fesm2022/nanahoshi-mona-ui-locales-id-id.mjs +90 -5
  49. package/fesm2022/nanahoshi-mona-ui-locales-it-it.mjs +103 -5
  50. package/fesm2022/nanahoshi-mona-ui-locales-ja-jp.mjs +90 -5
  51. package/fesm2022/nanahoshi-mona-ui-locales-ko-kr.mjs +90 -5
  52. package/fesm2022/nanahoshi-mona-ui-locales-pt-br.mjs +103 -5
  53. package/fesm2022/nanahoshi-mona-ui-locales-ru-ru.mjs +105 -5
  54. package/fesm2022/nanahoshi-mona-ui-locales-tr-tr.mjs +103 -5
  55. package/fesm2022/nanahoshi-mona-ui-locales-zh-cn.mjs +90 -5
  56. package/fesm2022/nanahoshi-mona-ui-locales-zh-tw.mjs +90 -5
  57. package/fesm2022/nanahoshi-mona-ui-menubar.mjs +2 -2
  58. package/fesm2022/nanahoshi-mona-ui-multi-select.mjs +14 -13
  59. package/fesm2022/nanahoshi-mona-ui-notification.mjs +1 -1
  60. package/fesm2022/nanahoshi-mona-ui-numeric-text-box.mjs +13 -12
  61. package/fesm2022/nanahoshi-mona-ui-otp-input.mjs +192 -56
  62. package/fesm2022/nanahoshi-mona-ui-pager.mjs +1 -1
  63. package/fesm2022/nanahoshi-mona-ui-placeholder.mjs +3 -1
  64. package/fesm2022/nanahoshi-mona-ui-popup-menu.mjs +2 -2
  65. package/fesm2022/nanahoshi-mona-ui-progress-bar.mjs +60 -29
  66. package/fesm2022/nanahoshi-mona-ui-radio-button.mjs +334 -37
  67. package/fesm2022/nanahoshi-mona-ui-rating.mjs +84 -30
  68. package/fesm2022/nanahoshi-mona-ui-scroll-view.mjs +274 -108
  69. package/fesm2022/nanahoshi-mona-ui-segmented.mjs +127 -37
  70. package/fesm2022/nanahoshi-mona-ui-sheet.mjs +2 -2
  71. package/fesm2022/nanahoshi-mona-ui-sidebar.mjs +595 -170
  72. package/fesm2022/nanahoshi-mona-ui-skeleton.mjs +3 -2
  73. package/fesm2022/nanahoshi-mona-ui-slider.mjs +323 -166
  74. package/fesm2022/nanahoshi-mona-ui-spinner.mjs +167 -82
  75. package/fesm2022/nanahoshi-mona-ui-split-button.mjs +3 -3
  76. package/fesm2022/nanahoshi-mona-ui-splitter.mjs +273 -165
  77. package/fesm2022/nanahoshi-mona-ui-stepper.mjs +219 -132
  78. package/fesm2022/nanahoshi-mona-ui-switch.mjs +84 -32
  79. package/fesm2022/nanahoshi-mona-ui-tabs.mjs +337 -116
  80. package/fesm2022/nanahoshi-mona-ui-text-area.mjs +10 -12
  81. package/fesm2022/nanahoshi-mona-ui-text-box.mjs +21 -8
  82. package/fesm2022/nanahoshi-mona-ui-theme.mjs +444 -88
  83. package/fesm2022/nanahoshi-mona-ui-time-picker.mjs +10 -9
  84. package/fesm2022/nanahoshi-mona-ui-time-selector.mjs +15 -14
  85. package/fesm2022/nanahoshi-mona-ui-tooltip.mjs +17 -3
  86. package/fesm2022/nanahoshi-mona-ui-window.mjs +1 -1
  87. package/i18n/catalogs/en-US.messages.json +90 -5
  88. package/locales/ar-sa/ar-sa.messages.json +90 -5
  89. package/locales/de-de/de-de.messages.json +90 -5
  90. package/locales/es-es/es-es.messages.json +90 -5
  91. package/locales/fr-fr/fr-fr.messages.json +91 -6
  92. package/locales/id-id/id-id.messages.json +90 -5
  93. package/locales/it-it/it-it.messages.json +90 -5
  94. package/locales/ja-jp/ja-jp.messages.json +90 -5
  95. package/locales/ko-kr/ko-kr.messages.json +90 -5
  96. package/locales/pt-br/pt-br.messages.json +90 -5
  97. package/locales/ru-ru/ru-ru.messages.json +90 -5
  98. package/locales/tr-tr/tr-tr.messages.json +90 -5
  99. package/locales/zh-cn/zh-cn.messages.json +90 -5
  100. package/locales/zh-tw/zh-tw.messages.json +90 -5
  101. package/package.json +2 -1
  102. package/styles.css +156 -0
  103. package/types/nanahoshi-mona-ui-auto-complete.d.ts +1 -0
  104. package/types/nanahoshi-mona-ui-avatar.d.ts +18 -11
  105. package/types/nanahoshi-mona-ui-breadcrumb.d.ts +62 -14
  106. package/types/nanahoshi-mona-ui-button-group.d.ts +86 -16
  107. package/types/nanahoshi-mona-ui-button.d.ts +26 -3
  108. package/types/nanahoshi-mona-ui-calendar.d.ts +1 -0
  109. package/types/nanahoshi-mona-ui-card.d.ts +22 -6
  110. package/types/nanahoshi-mona-ui-chart.d.ts +519 -527
  111. package/types/nanahoshi-mona-ui-check-box.d.ts +54 -13
  112. package/types/nanahoshi-mona-ui-chip.d.ts +31 -18
  113. package/types/nanahoshi-mona-ui-circular-progress-bar.d.ts +21 -5
  114. package/types/nanahoshi-mona-ui-collapsible.d.ts +20 -11
  115. package/types/nanahoshi-mona-ui-color-gradient.d.ts +62 -36
  116. package/types/nanahoshi-mona-ui-color-palette.d.ts +65 -27
  117. package/types/nanahoshi-mona-ui-color-picker.d.ts +64 -23
  118. package/types/nanahoshi-mona-ui-combo-box.d.ts +1 -0
  119. package/types/nanahoshi-mona-ui-common.d.ts +28 -2
  120. package/types/nanahoshi-mona-ui-date-picker.d.ts +1 -0
  121. package/types/nanahoshi-mona-ui-datetime-picker.d.ts +1 -0
  122. package/types/nanahoshi-mona-ui-dropdown-list.d.ts +1 -0
  123. package/types/nanahoshi-mona-ui-editor.d.ts +1 -0
  124. package/types/nanahoshi-mona-ui-expansion-panel.d.ts +51 -7
  125. package/types/nanahoshi-mona-ui-fieldset.d.ts +18 -4
  126. package/types/nanahoshi-mona-ui-grid.d.ts +0 -1
  127. package/types/nanahoshi-mona-ui-i18n.d.ts +130 -3
  128. package/types/nanahoshi-mona-ui-internal.d.ts +95 -14
  129. package/types/nanahoshi-mona-ui-label.d.ts +17 -2
  130. package/types/nanahoshi-mona-ui-locales-ar-sa.d.ts +85 -0
  131. package/types/nanahoshi-mona-ui-locales-de-de.d.ts +85 -0
  132. package/types/nanahoshi-mona-ui-locales-es-es.d.ts +85 -0
  133. package/types/nanahoshi-mona-ui-locales-fr-fr.d.ts +85 -0
  134. package/types/nanahoshi-mona-ui-locales-id-id.d.ts +85 -0
  135. package/types/nanahoshi-mona-ui-locales-it-it.d.ts +85 -0
  136. package/types/nanahoshi-mona-ui-locales-ja-jp.d.ts +85 -0
  137. package/types/nanahoshi-mona-ui-locales-ko-kr.d.ts +85 -0
  138. package/types/nanahoshi-mona-ui-locales-pt-br.d.ts +85 -0
  139. package/types/nanahoshi-mona-ui-locales-ru-ru.d.ts +85 -0
  140. package/types/nanahoshi-mona-ui-locales-tr-tr.d.ts +85 -0
  141. package/types/nanahoshi-mona-ui-locales-zh-cn.d.ts +85 -0
  142. package/types/nanahoshi-mona-ui-locales-zh-tw.d.ts +85 -0
  143. package/types/nanahoshi-mona-ui-multi-select.d.ts +1 -0
  144. package/types/nanahoshi-mona-ui-numeric-text-box.d.ts +1 -0
  145. package/types/nanahoshi-mona-ui-otp-input.d.ts +49 -12
  146. package/types/nanahoshi-mona-ui-placeholder.d.ts +2 -1
  147. package/types/nanahoshi-mona-ui-progress-bar.d.ts +21 -9
  148. package/types/nanahoshi-mona-ui-radio-button.d.ts +165 -20
  149. package/types/nanahoshi-mona-ui-rating.d.ts +21 -6
  150. package/types/nanahoshi-mona-ui-scroll-view.d.ts +59 -27
  151. package/types/nanahoshi-mona-ui-segmented.d.ts +52 -24
  152. package/types/nanahoshi-mona-ui-sidebar.d.ts +104 -41
  153. package/types/nanahoshi-mona-ui-skeleton.d.ts +1 -1
  154. package/types/nanahoshi-mona-ui-slider.d.ts +99 -35
  155. package/types/nanahoshi-mona-ui-spinner.d.ts +9 -5
  156. package/types/nanahoshi-mona-ui-splitter.d.ts +31 -10
  157. package/types/nanahoshi-mona-ui-stepper.d.ts +58 -12
  158. package/types/nanahoshi-mona-ui-switch.d.ts +32 -10
  159. package/types/nanahoshi-mona-ui-tabs.d.ts +75 -20
  160. package/types/nanahoshi-mona-ui-text-area.d.ts +7 -7
  161. package/types/nanahoshi-mona-ui-text-box.d.ts +2 -0
  162. package/types/nanahoshi-mona-ui-theme.d.ts +392 -15
  163. package/types/nanahoshi-mona-ui-time-picker.d.ts +1 -0
  164. package/types/nanahoshi-mona-ui-time-selector.d.ts +1 -0
  165. package/types/nanahoshi-mona-ui-tooltip.d.ts +7 -1
@@ -1,7 +1,9 @@
1
1
  import { NgTemplateOutlet } from '@angular/common';
2
2
  import * as i0 from '@angular/core';
3
- import { inject, TemplateRef, Directive, computed, contentChild, input, Component } from '@angular/core';
4
- import { getPercentage } from '@nanahoshi/mona-ui/common';
3
+ import { inject, TemplateRef, Directive, computed, contentChild, input, isDevMode, effect, Component } from '@angular/core';
4
+ import { normalizeProgressRange, getPercentage } from '@nanahoshi/mona-ui/common';
5
+ import { MonaI18nService, formatNumber } from '@nanahoshi/mona-ui/i18n';
6
+ import { PROGRESS_BAR_DEFAULT_MESSAGES } from '@nanahoshi/mona-ui/progress-bar';
5
7
  import { twMerge } from 'tailwind-merge';
6
8
  import { cva } from 'class-variance-authority';
7
9
 
@@ -9,6 +11,9 @@ class CircularProgressBarLabelTemplateDirective {
9
11
  constructor() {
10
12
  this.templateRef = inject(TemplateRef);
11
13
  }
14
+ static ngTemplateContextGuard(_dir, _ctx) {
15
+ return true;
16
+ }
12
17
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: CircularProgressBarLabelTemplateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
13
18
  static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: CircularProgressBarLabelTemplateDirective, isStandalone: true, selector: "ng-template[monaCircularProgressBarLabelTemplate]", ngImport: i0 }); }
14
19
  }
@@ -26,8 +31,12 @@ const circularProgressBarBaseThemeVariants = cva(`
26
31
  [&_svg]:h-full [&_svg]:w-full
27
32
  [&_svg_circle]:origin-center
28
33
  [&_svg_circle]:-rotate-90
29
- [&_svg_circle]:transition-[stroke-dashoffset,stroke] duration-(--mona-motion-fast) ease-in
34
+ [&_svg_circle]:transition-[stroke-dashoffset,stroke]
35
+ [&_svg_circle]:duration-(--mona-motion-fast)
36
+ [&_svg_circle]:ease-in
30
37
  [&_svg_circle]:data-[stroke-trail='true']:stroke-surface-muted
38
+ forced-colors:[&_svg_circle]:stroke-[Highlight]
39
+ forced-colors:[&_svg_circle]:data-[stroke-trail='true']:stroke-[GrayText]
31
40
  `, {
32
41
  variants: {
33
42
  disabled: {
@@ -38,7 +47,13 @@ const circularProgressBarBaseThemeVariants = cva(`
38
47
  });
39
48
 
40
49
  class CircularProgressBarComponent {
50
+ #i18n;
41
51
  constructor() {
52
+ this.#i18n = inject(MonaI18nService);
53
+ this.ariaRange = computed(() => {
54
+ return this.indeterminate() ? null : normalizeProgressRange(this.value(), this.min(), this.max());
55
+ }, /* @ts-ignore */
56
+ ...(ngDevMode ? [{ debugName: "ariaRange" }] : /* istanbul ignore next */ []));
42
57
  this.baseClasses = computed(() => {
43
58
  const disabled = this.disabled();
44
59
  const classes = circularProgressBarBaseThemeVariants({ disabled });
@@ -51,19 +66,29 @@ class CircularProgressBarComponent {
51
66
  y: this.size() / 2
52
67
  }), /* @ts-ignore */
53
68
  ...(ngDevMode ? [{ debugName: "center" }] : /* istanbul ignore next */ []));
54
- this.circumference = computed(() => 2 * Math.PI * (this.size() / 2 - this.thickness()), /* @ts-ignore */
69
+ this.circumference = computed(() => 2 * Math.PI * this.radius(), /* @ts-ignore */
55
70
  ...(ngDevMode ? [{ debugName: "circumference" }] : /* istanbul ignore next */ []));
71
+ this.formattedProgress = computed(() => {
72
+ return formatNumber(this.progress() / 100, this.#i18n.localeId(), {
73
+ maximumFractionDigits: 2,
74
+ minimumFractionDigits: 0,
75
+ style: "percent",
76
+ useGrouping: false
77
+ });
78
+ }, /* @ts-ignore */
79
+ ...(ngDevMode ? [{ debugName: "formattedProgress" }] : /* istanbul ignore next */ []));
56
80
  this.labelTemplate = contentChild(CircularProgressBarLabelTemplateDirective, /* @ts-ignore */
57
81
  ...(ngDevMode ? [{ debugName: "labelTemplate" }] : /* istanbul ignore next */ []));
82
+ this.messages = this.#i18n.componentMessages("progressBar", PROGRESS_BAR_DEFAULT_MESSAGES);
58
83
  this.pixelSize = computed(() => `${this.size()}px`, /* @ts-ignore */
59
84
  ...(ngDevMode ? [{ debugName: "pixelSize" }] : /* istanbul ignore next */ []));
60
85
  this.progress = computed(() => getPercentage(this.value(), this.min(), this.max()), /* @ts-ignore */
61
86
  ...(ngDevMode ? [{ debugName: "progress" }] : /* istanbul ignore next */ []));
62
- this.radius = computed(() => this.size() / 2 - this.thickness(), /* @ts-ignore */
87
+ this.radius = computed(() => Math.max(0, this.size() / 2 - this.thickness() / 2), /* @ts-ignore */
63
88
  ...(ngDevMode ? [{ debugName: "radius" }] : /* istanbul ignore next */ []));
64
89
  this.strokeColor = computed(() => {
65
90
  if (typeof this.color() === "string") {
66
- return this.color() || "var(--color-primary)";
91
+ return this.color() || "var(--mona-indicator-color, var(--color-primary))";
67
92
  }
68
93
  const colorize = this.color();
69
94
  return colorize(this.progress());
@@ -84,7 +109,7 @@ class CircularProgressBarComponent {
84
109
  ...(ngDevMode ? [{ debugName: "animate" }] : /* istanbul ignore next */ []));
85
110
  /**
86
111
  * @description Accessible name for the host element. Describe what the component represents (e.g., "Upload progress").
87
- * When empty, assistive technology announces the role without a label.
112
+ * When empty, falls back to the localized "Progress". An `aria-labelledby` on the host takes precedence over both.
88
113
  * @default ""
89
114
  */
90
115
  this.ariaLabel = input("", { ...(ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {}), alias: "aria-label" });
@@ -111,13 +136,21 @@ class CircularProgressBarComponent {
111
136
  ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
112
137
  /**
113
138
  * @description Activates indeterminate mode when the completion value is unknown.
114
- * ARIA value attributes are removed and `aria-busy` is set on the host element.
139
+ * ARIA value attributes are removed.
115
140
  * @default false
116
141
  */
117
142
  this.indeterminate = input(false, /* @ts-ignore */
118
143
  ...(ngDevMode ? [{ debugName: "indeterminate" }] : /* istanbul ignore next */ []));
119
144
  /**
120
- * @description Upper bound of the value range. Must be greater than `min`.
145
+ * @description Controls label visibility in determinate mode.
146
+ * Has no effect in indeterminate mode, where the label is always hidden.
147
+ * @default true
148
+ */
149
+ this.labelVisible = input(true, /* @ts-ignore */
150
+ ...(ngDevMode ? [{ debugName: "labelVisible" }] : /* istanbul ignore next */ []));
151
+ /**
152
+ * @description Upper bound of the value range. Must be greater than `min`; otherwise the bar reports no values and a
153
+ * warning is logged in development.
121
154
  * @default 100
122
155
  */
123
156
  this.max = input(100, /* @ts-ignore */
@@ -146,32 +179,39 @@ class CircularProgressBarComponent {
146
179
  */
147
180
  this.userClass = input("", { ...(ngDevMode ? { debugName: "userClass" } : /* istanbul ignore next */ {}), alias: "class" });
148
181
  /**
149
- * @description Current progress value within `[min, max]`. Values outside the range are clamped before rendering; non-finite values are treated as `0`.
182
+ * @description Current progress value within `[min, max]`. Values outside the range are clamped, for the ring and
183
+ * for `aria-valuenow`; non-finite values count as `min`.
150
184
  * @default 0
151
185
  */
152
186
  this.value = input(0, /* @ts-ignore */
153
187
  ...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
188
+ if (isDevMode()) {
189
+ effect(() => {
190
+ if (!this.indeterminate() && this.ariaRange() === null) {
191
+ console.warn(`mona-circular-progress-bar: [${this.min()}, ${this.max()}] isn't a valid range.`);
192
+ }
193
+ });
194
+ }
154
195
  }
155
196
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: CircularProgressBarComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
156
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: CircularProgressBarComponent, isStandalone: true, selector: "mona-circular-progress-bar", inputs: { animate: { classPropertyName: "animate", publicName: "animate", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "aria-label", isSignal: true, isRequired: false, transformFunction: null }, ariaValueText: { classPropertyName: "ariaValueText", publicName: "aria-valuetext", isSignal: true, isRequired: false, transformFunction: null }, color: { classPropertyName: "color", publicName: "color", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, indeterminate: { classPropertyName: "indeterminate", publicName: "indeterminate", isSignal: true, isRequired: false, transformFunction: null }, max: { classPropertyName: "max", publicName: "max", isSignal: true, isRequired: false, transformFunction: null }, min: { classPropertyName: "min", publicName: "min", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, thickness: { classPropertyName: "thickness", publicName: "thickness", isSignal: true, isRequired: false, transformFunction: null }, userClass: { classPropertyName: "userClass", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "progressbar" }, properties: { "class": "baseClasses()", "attr.aria-busy": "indeterminate() || null", "attr.aria-label": "ariaLabel() || null", "attr.aria-valuemin": "indeterminate() ? null : min()", "attr.aria-valuemax": "indeterminate() ? null : max()", "attr.aria-valuenow": "indeterminate() ? null : value()", "attr.aria-valuetext": "ariaValueText() || null", "attr.aria-disabled": "disabled() || null", "attr.data-disabled": "disabled() || null", "style.width": "pixelSize()", "style.height": "pixelSize()" } }, queries: [{ propertyName: "labelTemplate", first: true, predicate: CircularProgressBarLabelTemplateDirective, descendants: true, isSignal: true }], ngImport: i0, template: "<svg>\n <circle\n [attr.cx]=\"center().x\"\n [attr.cy]=\"center().y\"\n [attr.r]=\"radius()\"\n [attr.data-stroke-trail]=\"true\"\n [attr.stroke-dasharray]=\"circumference()\"\n [attr.stroke-width]=\"thickness()\"\n fill=\"transparent\" />\n <circle\n [attr.cx]=\"center().x\"\n [attr.cy]=\"center().y\"\n [attr.r]=\"radius()\"\n [attr.stroke]=\"strokeColor()\"\n [attr.stroke-dasharray]=\"circumference()\"\n [attr.stroke-dashoffset]=\"strokeDashOffset()\"\n [attr.stroke-width]=\"thickness()\"\n fill=\"transparent\"\n [class.indeterminate]=\"indeterminate()\" />\n</svg>\n@if (!indeterminate()) {\n <div class=\"mona-circular-progress-bar-label\">\n @if (labelTemplate()) {\n <ng-container\n [ngTemplateOutlet]=\"labelTemplate()?.templateRef\"\n [ngTemplateOutletContext]=\"{ $implicit: value(), min: min(), max: max(), percent: progress() }\">\n </ng-container>\n } @else {\n {{ progress() }}\n }\n </div>\n}\n", styles: [".indeterminate{animation:rotate 2s linear infinite}@keyframes rotate{0%{transform:rotate(0)}50%{transform:rotate(180deg)}to{transform:rotate(360deg)}}\n"], dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }] }); }
197
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: CircularProgressBarComponent, isStandalone: true, selector: "mona-circular-progress-bar", inputs: { animate: { classPropertyName: "animate", publicName: "animate", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "aria-label", isSignal: true, isRequired: false, transformFunction: null }, ariaValueText: { classPropertyName: "ariaValueText", publicName: "aria-valuetext", isSignal: true, isRequired: false, transformFunction: null }, color: { classPropertyName: "color", publicName: "color", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, indeterminate: { classPropertyName: "indeterminate", publicName: "indeterminate", isSignal: true, isRequired: false, transformFunction: null }, labelVisible: { classPropertyName: "labelVisible", publicName: "labelVisible", isSignal: true, isRequired: false, transformFunction: null }, max: { classPropertyName: "max", publicName: "max", isSignal: true, isRequired: false, transformFunction: null }, min: { classPropertyName: "min", publicName: "min", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, thickness: { classPropertyName: "thickness", publicName: "thickness", isSignal: true, isRequired: false, transformFunction: null }, userClass: { classPropertyName: "userClass", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "progressbar" }, properties: { "class": "baseClasses()", "attr.aria-label": "ariaLabel() || messages().label", "attr.aria-valuemin": "ariaRange()?.min", "attr.aria-valuemax": "ariaRange()?.max", "attr.aria-valuenow": "ariaRange()?.now", "attr.aria-valuetext": "ariaValueText() || null", "attr.aria-disabled": "disabled() || null", "attr.data-disabled": "disabled()", "style.width": "pixelSize()", "style.height": "pixelSize()" } }, queries: [{ propertyName: "labelTemplate", first: true, predicate: CircularProgressBarLabelTemplateDirective, descendants: true, isSignal: true }], ngImport: i0, template: "<svg>\n <circle\n [attr.cx]=\"center().x\"\n [attr.cy]=\"center().y\"\n [attr.r]=\"radius()\"\n [attr.data-stroke-trail]=\"true\"\n [attr.stroke-dasharray]=\"circumference()\"\n [attr.stroke-width]=\"thickness()\"\n fill=\"transparent\" />\n <circle\n [attr.cx]=\"center().x\"\n [attr.cy]=\"center().y\"\n [attr.r]=\"radius()\"\n [attr.stroke]=\"strokeColor()\"\n [attr.stroke-dasharray]=\"circumference()\"\n [attr.stroke-dashoffset]=\"strokeDashOffset()\"\n [attr.stroke-width]=\"thickness()\"\n fill=\"transparent\"\n [class.indeterminate]=\"indeterminate()\" />\n</svg>\n@if (!indeterminate() && labelVisible()) {\n <div class=\"mona-circular-progress-bar-label\">\n @if (labelTemplate()) {\n <ng-container\n [ngTemplateOutlet]=\"labelTemplate()?.templateRef\"\n [ngTemplateOutletContext]=\"{ $implicit: value(), min: min(), max: max(), percent: progress() }\">\n </ng-container>\n } @else {\n {{ formattedProgress() }}\n }\n </div>\n}\n", styles: [".indeterminate{animation:rotate 2s linear infinite}@keyframes rotate{0%{transform:rotate(0)}50%{transform:rotate(180deg)}to{transform:rotate(360deg)}}@keyframes fade{50%{opacity:.4}}@media(prefers-reduced-motion:reduce){.indeterminate{animation:fade 2s ease-in-out infinite}}\n"], dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }] }); }
157
198
  }
158
199
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: CircularProgressBarComponent, decorators: [{
159
200
  type: Component,
160
201
  args: [{ selector: "mona-circular-progress-bar", imports: [NgTemplateOutlet], host: {
161
202
  "[class]": "baseClasses()",
162
- "[attr.aria-busy]": "indeterminate() || null",
163
- "[attr.aria-label]": "ariaLabel() || null",
164
- "[attr.aria-valuemin]": "indeterminate() ? null : min()",
165
- "[attr.aria-valuemax]": "indeterminate() ? null : max()",
166
- "[attr.aria-valuenow]": "indeterminate() ? null : value()",
203
+ "[attr.aria-label]": "ariaLabel() || messages().label",
204
+ "[attr.aria-valuemin]": "ariaRange()?.min",
205
+ "[attr.aria-valuemax]": "ariaRange()?.max",
206
+ "[attr.aria-valuenow]": "ariaRange()?.now",
167
207
  "[attr.aria-valuetext]": "ariaValueText() || null",
168
208
  "[attr.aria-disabled]": "disabled() || null",
169
- "[attr.data-disabled]": "disabled() || null",
209
+ "[attr.data-disabled]": "disabled()",
170
210
  role: "progressbar",
171
211
  "[style.width]": "pixelSize()",
172
212
  "[style.height]": "pixelSize()"
173
- }, template: "<svg>\n <circle\n [attr.cx]=\"center().x\"\n [attr.cy]=\"center().y\"\n [attr.r]=\"radius()\"\n [attr.data-stroke-trail]=\"true\"\n [attr.stroke-dasharray]=\"circumference()\"\n [attr.stroke-width]=\"thickness()\"\n fill=\"transparent\" />\n <circle\n [attr.cx]=\"center().x\"\n [attr.cy]=\"center().y\"\n [attr.r]=\"radius()\"\n [attr.stroke]=\"strokeColor()\"\n [attr.stroke-dasharray]=\"circumference()\"\n [attr.stroke-dashoffset]=\"strokeDashOffset()\"\n [attr.stroke-width]=\"thickness()\"\n fill=\"transparent\"\n [class.indeterminate]=\"indeterminate()\" />\n</svg>\n@if (!indeterminate()) {\n <div class=\"mona-circular-progress-bar-label\">\n @if (labelTemplate()) {\n <ng-container\n [ngTemplateOutlet]=\"labelTemplate()?.templateRef\"\n [ngTemplateOutletContext]=\"{ $implicit: value(), min: min(), max: max(), percent: progress() }\">\n </ng-container>\n } @else {\n {{ progress() }}\n }\n </div>\n}\n", styles: [".indeterminate{animation:rotate 2s linear infinite}@keyframes rotate{0%{transform:rotate(0)}50%{transform:rotate(180deg)}to{transform:rotate(360deg)}}\n"] }]
174
- }], propDecorators: { labelTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CircularProgressBarLabelTemplateDirective), { isSignal: true }] }], animate: [{ type: i0.Input, args: [{ isSignal: true, alias: "animate", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-label", required: false }] }], ariaValueText: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-valuetext", required: false }] }], color: [{ type: i0.Input, args: [{ isSignal: true, alias: "color", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], indeterminate: [{ type: i0.Input, args: [{ isSignal: true, alias: "indeterminate", required: false }] }], max: [{ type: i0.Input, args: [{ isSignal: true, alias: "max", required: false }] }], min: [{ type: i0.Input, args: [{ isSignal: true, alias: "min", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], thickness: [{ type: i0.Input, args: [{ isSignal: true, alias: "thickness", required: false }] }], userClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }] } });
213
+ }, template: "<svg>\n <circle\n [attr.cx]=\"center().x\"\n [attr.cy]=\"center().y\"\n [attr.r]=\"radius()\"\n [attr.data-stroke-trail]=\"true\"\n [attr.stroke-dasharray]=\"circumference()\"\n [attr.stroke-width]=\"thickness()\"\n fill=\"transparent\" />\n <circle\n [attr.cx]=\"center().x\"\n [attr.cy]=\"center().y\"\n [attr.r]=\"radius()\"\n [attr.stroke]=\"strokeColor()\"\n [attr.stroke-dasharray]=\"circumference()\"\n [attr.stroke-dashoffset]=\"strokeDashOffset()\"\n [attr.stroke-width]=\"thickness()\"\n fill=\"transparent\"\n [class.indeterminate]=\"indeterminate()\" />\n</svg>\n@if (!indeterminate() && labelVisible()) {\n <div class=\"mona-circular-progress-bar-label\">\n @if (labelTemplate()) {\n <ng-container\n [ngTemplateOutlet]=\"labelTemplate()?.templateRef\"\n [ngTemplateOutletContext]=\"{ $implicit: value(), min: min(), max: max(), percent: progress() }\">\n </ng-container>\n } @else {\n {{ formattedProgress() }}\n }\n </div>\n}\n", styles: [".indeterminate{animation:rotate 2s linear infinite}@keyframes rotate{0%{transform:rotate(0)}50%{transform:rotate(180deg)}to{transform:rotate(360deg)}}@keyframes fade{50%{opacity:.4}}@media(prefers-reduced-motion:reduce){.indeterminate{animation:fade 2s ease-in-out infinite}}\n"] }]
214
+ }], ctorParameters: () => [], propDecorators: { labelTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CircularProgressBarLabelTemplateDirective), { isSignal: true }] }], animate: [{ type: i0.Input, args: [{ isSignal: true, alias: "animate", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-label", required: false }] }], ariaValueText: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-valuetext", required: false }] }], color: [{ type: i0.Input, args: [{ isSignal: true, alias: "color", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], indeterminate: [{ type: i0.Input, args: [{ isSignal: true, alias: "indeterminate", required: false }] }], labelVisible: [{ type: i0.Input, args: [{ isSignal: true, alias: "labelVisible", required: false }] }], max: [{ type: i0.Input, args: [{ isSignal: true, alias: "max", required: false }] }], min: [{ type: i0.Input, args: [{ isSignal: true, alias: "min", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], thickness: [{ type: i0.Input, args: [{ isSignal: true, alias: "thickness", required: false }] }], userClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }] } });
175
215
 
176
216
  /*
177
217
  * Public API Surface of @nanahoshi/mona-ui/circular-progress-bar
@@ -1,8 +1,8 @@
1
1
  import * as i0 from '@angular/core';
2
- import { InjectionToken, computed, input, model, forwardRef, Directive, inject, ElementRef, signal, DestroyRef, afterNextRender, effect, untracked } from '@angular/core';
2
+ import { InjectionToken, signal, computed, input, booleanAttribute, model, forwardRef, Directive, inject, ElementRef, DestroyRef, afterNextRender, effect, untracked } from '@angular/core';
3
3
  import { createElementControlId } from '@nanahoshi/mona-ui/internal';
4
4
 
5
- const CollapsibleToken = new InjectionToken("MONA_COLLAPSIBLE");
5
+ const COLLAPSIBLE_CONFIG = new InjectionToken("COLLAPSIBLE_CONFIG");
6
6
 
7
7
  /**
8
8
  * @description
@@ -11,24 +11,21 @@ const CollapsibleToken = new InjectionToken("MONA_COLLAPSIBLE");
11
11
  */
12
12
  class CollapsibleDirective {
13
13
  constructor() {
14
+ this.#contentIdFromContent = signal(null, /* @ts-ignore */
15
+ ...(ngDevMode ? [{ debugName: "#contentIdFromContent" }] : /* istanbul ignore next */ []));
16
+ this.#generatedContentId = createElementControlId();
14
17
  this.state = computed(() => (this.expanded() ? "open" : "closed"), /* @ts-ignore */
15
18
  ...(ngDevMode ? [{ debugName: "state" }] : /* istanbul ignore next */ []));
16
19
  /**
17
20
  * @description Enables the height transition applied to the collapsible content.
18
21
  * @default true
19
22
  */
20
- this.animate = input(true, /* @ts-ignore */
21
- ...(ngDevMode ? [{ debugName: "animate" }] : /* istanbul ignore next */ []));
22
- /**
23
- * @description Id assigned to the content element and referenced by the trigger through `aria-controls`.
24
- */
25
- this.contentId = createElementControlId();
23
+ this.animate = input(true, { ...(ngDevMode ? { debugName: "animate" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
26
24
  /**
27
25
  * @description Suppresses toggling through the trigger. `expand()` and `collapse()` still apply.
28
26
  * @default false
29
27
  */
30
- this.disabled = input(false, /* @ts-ignore */
31
- ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
28
+ this.disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
32
29
  /**
33
30
  * @description Sets whether the content is expanded. Supports two-way binding.
34
31
  * @default false
@@ -36,12 +33,24 @@ class CollapsibleDirective {
36
33
  this.expanded = model(false, /* @ts-ignore */
37
34
  ...(ngDevMode ? [{ debugName: "expanded" }] : /* istanbul ignore next */ []));
38
35
  }
36
+ #contentIdFromContent;
37
+ #generatedContentId;
38
+ /**
39
+ * @description Id of the content element, which the trigger references through `aria-controls`. Generated, unless the
40
+ * content element has its own `id`.
41
+ */
42
+ get contentId() {
43
+ return this.#contentIdFromContent() ?? this.#generatedContentId;
44
+ }
39
45
  collapse() {
40
46
  this.expanded.set(false);
41
47
  }
42
48
  expand() {
43
49
  this.expanded.set(true);
44
50
  }
51
+ setContentId(id) {
52
+ this.#contentIdFromContent.set(id);
53
+ }
45
54
  toggle() {
46
55
  if (this.disabled()) {
47
56
  return;
@@ -49,7 +58,7 @@ class CollapsibleDirective {
49
58
  this.expanded.update(expanded => !expanded);
50
59
  }
51
60
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: CollapsibleDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
52
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.6", type: CollapsibleDirective, isStandalone: true, selector: "[monaCollapsible]", inputs: { animate: { classPropertyName: "animate", publicName: "animate", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, expanded: { classPropertyName: "expanded", publicName: "expanded", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { expanded: "expandedChange" }, host: { properties: { "attr.data-state": "state()" } }, providers: [{ provide: CollapsibleToken, useExisting: forwardRef(() => CollapsibleDirective) }], exportAs: ["monaCollapsible"], ngImport: i0 }); }
61
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.6", type: CollapsibleDirective, isStandalone: true, selector: "[monaCollapsible]", inputs: { animate: { classPropertyName: "animate", publicName: "animate", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, expanded: { classPropertyName: "expanded", publicName: "expanded", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { expanded: "expandedChange" }, host: { properties: { "attr.data-state": "state()" } }, providers: [{ provide: COLLAPSIBLE_CONFIG, useExisting: forwardRef(() => CollapsibleDirective) }], exportAs: ["monaCollapsible"], ngImport: i0 }); }
53
62
  }
54
63
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: CollapsibleDirective, decorators: [{
55
64
  type: Directive,
@@ -59,11 +68,18 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
59
68
  host: {
60
69
  "[attr.data-state]": "state()"
61
70
  },
62
- providers: [{ provide: CollapsibleToken, useExisting: forwardRef(() => CollapsibleDirective) }]
71
+ providers: [{ provide: COLLAPSIBLE_CONFIG, useExisting: forwardRef(() => CollapsibleDirective) }]
63
72
  }]
64
73
  }], propDecorators: { animate: [{ type: i0.Input, args: [{ isSignal: true, alias: "animate", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], expanded: [{ type: i0.Input, args: [{ isSignal: true, alias: "expanded", required: false }] }, { type: i0.Output, args: ["expandedChange"] }] } });
65
74
 
66
75
  const CONTENT_HEIGHT_VARIABLE = "--mona-collapsible-content-height";
76
+ /** A box can't get below its padding and border, so a height of 0 needs these at 0 as well. */
77
+ const BOX_PROPERTIES = [
78
+ "padding-block-start",
79
+ "padding-block-end",
80
+ "border-block-start-width",
81
+ "border-block-end-width"
82
+ ];
67
83
  /**
68
84
  * @description
69
85
  * Animates the height of the collapsible content between `0` and its measured size. Adds no wrapper
@@ -84,11 +100,16 @@ class CollapsibleContentDirective {
84
100
  this.#reducedMotion = signal(false, /* @ts-ignore */
85
101
  ...(ngDevMode ? [{ debugName: "#reducedMotion" }] : /* istanbul ignore next */ []));
86
102
  this.#fallbackId = null;
87
- this.collapsible = inject(CollapsibleToken);
103
+ this.collapsible = inject(COLLAPSIBLE_CONFIG);
88
104
  this.inert = computed(() => (this.collapsible.expanded() ? null : true), /* @ts-ignore */
89
105
  ...(ngDevMode ? [{ debugName: "inert" }] : /* istanbul ignore next */ []));
90
106
  this.state = computed(() => (this.collapsible.expanded() ? "open" : "closed"), /* @ts-ignore */
91
107
  ...(ngDevMode ? [{ debugName: "state" }] : /* istanbul ignore next */ []));
108
+ /**
109
+ * @description The content's id, for when it has to be something in particular. Generated if not given.
110
+ */
111
+ this.id = input(null, /* @ts-ignore */
112
+ ...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
92
113
  const destroyRef = inject(DestroyRef);
93
114
  if (typeof window !== "undefined" && typeof window.matchMedia === "function") {
94
115
  const query = window.matchMedia("(prefers-reduced-motion: reduce)");
@@ -116,11 +137,17 @@ class CollapsibleContentDirective {
116
137
  const expanded = this.collapsible.expanded();
117
138
  untracked(() => {
118
139
  if (!this.#initialized()) {
140
+ // This also runs on the server, so collapsed content isn't sent out open.
141
+ this.#settle();
119
142
  return;
120
143
  }
121
144
  this.#animateTo(expanded);
122
145
  });
123
146
  });
147
+ effect(() => {
148
+ const id = this.id();
149
+ untracked(() => this.collapsible.setContentId?.(id));
150
+ });
124
151
  }
125
152
  /** Runs the height transition towards the requested state. */
126
153
  #animateTo(expanded) {
@@ -130,20 +157,22 @@ class CollapsibleContentDirective {
130
157
  return;
131
158
  }
132
159
  const element = this.#element;
133
- const contentHeight = element.scrollHeight;
160
+ const computed = getComputedStyle(element);
161
+ // Not the resting shape: a toggle mid-animation carries on from where it got to.
162
+ const startHeight = element.offsetHeight;
163
+ const startBox = BOX_PROPERTIES.map(property => computed.getPropertyValue(property));
164
+ this.#setTransitionEnabled(false);
165
+ const contentHeight = this.#measure();
134
166
  element.style.setProperty(CONTENT_HEIGHT_VARIABLE, `${contentHeight}px`);
135
167
  this.#clip();
168
+ element.style.height = `${startHeight}px`;
169
+ BOX_PROPERTIES.forEach((property, index) => element.style.setProperty(property, startBox[index]));
170
+ void element.offsetHeight; // force a reflow so the browser has a start value to animate from
136
171
  this.#setTransitionEnabled(true);
172
+ this.#rest(expanded);
137
173
  if (expanded) {
138
- element.style.height = "0px";
139
- void element.offsetHeight; // force a reflow so the browser has a start value to animate from
140
174
  element.style.height = `${contentHeight}px`;
141
175
  }
142
- else {
143
- element.style.height = `${element.offsetHeight}px`;
144
- void element.offsetHeight;
145
- element.style.height = "0px";
146
- }
147
176
  this.#scheduleFallback();
148
177
  }
149
178
  #clearFallback() {
@@ -164,15 +193,39 @@ class CollapsibleContentDirective {
164
193
  #getTransitionDuration() {
165
194
  const declared = getComputedStyle(this.#element).transitionDuration;
166
195
  const durations = declared.split(",").map(part => {
167
- const trimmed = part.trim();
168
- const parsed = Number.parseFloat(trimmed);
169
- if (!Number.isFinite(parsed)) {
196
+ // Only a resolved time counts. Where nothing resolves `var()`, as in jsdom, its fallback isn't one.
197
+ const match = /^([\d.]+)(ms|s)$/.exec(part.trim());
198
+ if (!match) {
170
199
  return 0;
171
200
  }
172
- return trimmed.endsWith("ms") ? parsed : parsed * 1000;
201
+ return match[2] === "ms" ? Number(match[1]) : Number(match[1]) * 1000;
173
202
  });
174
203
  return Math.max(0, ...durations);
175
204
  }
205
+ /** Measures the element open, since closed it has no padding or border to count. */
206
+ #measure() {
207
+ this.#rest(true);
208
+ // No layout on the server, where this also runs, and perhaps no `getComputedStyle` either.
209
+ if (typeof getComputedStyle !== "function") {
210
+ return 0;
211
+ }
212
+ const computed = getComputedStyle(this.#element);
213
+ const border = BOX_PROPERTIES.slice(2).map(property => parseFloat(computed.getPropertyValue(property)) || 0);
214
+ return this.#element.scrollHeight + border[0] + border[1] || 0;
215
+ }
216
+ /** Sets what makes the element open or closed. */
217
+ #rest(expanded) {
218
+ const { style } = this.#element;
219
+ style.height = expanded ? "" : "0px";
220
+ for (const property of BOX_PROPERTIES) {
221
+ if (expanded) {
222
+ style.removeProperty(property);
223
+ }
224
+ else {
225
+ style.setProperty(property, "0px");
226
+ }
227
+ }
228
+ }
176
229
  /** Guards against a `transitionend` that never arrives, e.g. when an ancestor hides the element mid-flight. */
177
230
  #scheduleFallback() {
178
231
  this.#fallbackId = setTimeout(() => this.#settle(), this.#getTransitionDuration() + 50);
@@ -180,12 +233,15 @@ class CollapsibleContentDirective {
180
233
  #setTransitionEnabled(enabled) {
181
234
  const style = this.#element.style;
182
235
  if (!enabled) {
236
+ // Just clearing it would leave what's running to finish, since the property's initial value is `all`.
237
+ style.transitionProperty = "none";
238
+ void this.#element.offsetHeight;
183
239
  style.transitionProperty = "";
184
240
  style.transitionDuration = "";
185
241
  style.transitionTimingFunction = "";
186
242
  return;
187
243
  }
188
- style.transitionProperty = "height";
244
+ style.transitionProperty = ["height", ...BOX_PROPERTIES].join(", ");
189
245
  style.transitionDuration = `var(--mona-motion-standard, 300ms)`;
190
246
  style.transitionTimingFunction = "ease-out";
191
247
  }
@@ -194,19 +250,19 @@ class CollapsibleContentDirective {
194
250
  this.#clearFallback();
195
251
  this.#setTransitionEnabled(false);
196
252
  const element = this.#element;
253
+ const contentHeight = this.#measure();
197
254
  if (this.collapsible.expanded()) {
198
- element.style.height = "";
199
255
  element.style.overflow = "";
200
256
  element.style.minHeight = "";
201
257
  }
202
258
  else {
203
- element.style.height = "0px";
259
+ this.#rest(false);
204
260
  this.#clip();
205
261
  }
206
- element.style.setProperty(CONTENT_HEIGHT_VARIABLE, `${element.scrollHeight}px`);
262
+ element.style.setProperty(CONTENT_HEIGHT_VARIABLE, `${contentHeight}px`);
207
263
  }
208
264
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: CollapsibleContentDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
209
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: CollapsibleContentDirective, isStandalone: true, selector: "[monaCollapsibleContent]", host: { properties: { "attr.data-state": "state()", "attr.id": "collapsible.contentId", "attr.inert": "inert()" } }, ngImport: i0 }); }
265
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.6", type: CollapsibleContentDirective, isStandalone: true, selector: "[monaCollapsibleContent]", inputs: { id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "attr.data-state": "state()", "attr.id": "collapsible.contentId", "attr.inert": "inert()" } }, ngImport: i0 }); }
210
266
  }
211
267
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: CollapsibleContentDirective, decorators: [{
212
268
  type: Directive,
@@ -218,8 +274,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
218
274
  "[attr.inert]": "inert()"
219
275
  }
220
276
  }]
221
- }], ctorParameters: () => [] });
277
+ }], ctorParameters: () => [], propDecorators: { id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }] } });
222
278
 
279
+ /** What inside a trigger keeps its own clicks and keys. */
280
+ const NESTED_CONTROL_SELECTOR = "a[href], button, input, select, summary, textarea, [contenteditable], [tabindex]";
223
281
  /**
224
282
  * @description
225
283
  * Toggles the closest `monaCollapsible`. Wires `aria-expanded` / `aria-controls` automatically and
@@ -230,19 +288,24 @@ class CollapsibleTriggerDirective {
230
288
  this.#element = inject(ElementRef).nativeElement;
231
289
  this.#nativeAnchor = this.#element.tagName === "A";
232
290
  this.#nativeButton = this.#element.tagName === "BUTTON" || this.#element.tagName === "INPUT" || this.#element.tagName === "SUMMARY";
291
+ this.#nativeDisableable = this.#element.tagName === "BUTTON" || this.#element.tagName === "INPUT";
292
+ this.#nativeSummary = this.#element.tagName === "SUMMARY";
233
293
  this.ariaDisabled = computed(() => (this.collapsible.disabled() ? "true" : null), /* @ts-ignore */
234
294
  ...(ngDevMode ? [{ debugName: "ariaDisabled" }] : /* istanbul ignore next */ []));
235
- this.collapsible = inject(CollapsibleToken);
236
- this.nativeDisabled = computed(() => this.#element.tagName === "BUTTON" && this.collapsible.disabled() ? "" : null, /* @ts-ignore */
295
+ this.collapsible = inject(COLLAPSIBLE_CONFIG);
296
+ this.nativeDisabled = computed(() => this.#nativeDisableable && this.collapsible.disabled() ? "" : null, /* @ts-ignore */
237
297
  ...(ngDevMode ? [{ debugName: "nativeDisabled" }] : /* istanbul ignore next */ []));
238
298
  this.role = this.#nativeButton || this.#nativeAnchor ? null : "button";
239
299
  this.state = computed(() => (this.collapsible.expanded() ? "open" : "closed"), /* @ts-ignore */
240
300
  ...(ngDevMode ? [{ debugName: "state" }] : /* istanbul ignore next */ []));
241
301
  this.tabIndex = computed(() => {
242
- if (this.#nativeButton || this.#nativeAnchor) {
302
+ if (this.#nativeButton) {
243
303
  return null;
244
304
  }
245
- return this.collapsible.disabled() ? -1 : 0;
305
+ if (this.collapsible.disabled()) {
306
+ return -1;
307
+ }
308
+ return this.#nativeAnchor ? null : 0;
246
309
  }, /* @ts-ignore */
247
310
  ...(ngDevMode ? [{ debugName: "tabIndex" }] : /* istanbul ignore next */ []));
248
311
  this.type = this.#element.tagName === "BUTTON" ? "button" : null;
@@ -250,12 +313,22 @@ class CollapsibleTriggerDirective {
250
313
  #element;
251
314
  #nativeAnchor;
252
315
  #nativeButton;
253
- onClick() {
316
+ #nativeDisableable;
317
+ #nativeSummary;
318
+ onClick(event) {
319
+ if (this.#isFromNestedControl(event)) {
320
+ return;
321
+ }
322
+ if ((this.#nativeAnchor || this.#nativeSummary) && this.collapsible.disabled()) {
323
+ // A button's `disabled` stops this by itself. An anchor would follow its `href`, and a summary open its details.
324
+ event.preventDefault();
325
+ return;
326
+ }
254
327
  this.collapsible.toggle();
255
328
  }
256
329
  onEnterKeydown(event) {
257
330
  // Buttons and anchors already synthesise a click for Enter.
258
- if (this.#nativeButton || this.#nativeAnchor) {
331
+ if (this.#nativeButton || this.#nativeAnchor || this.#isFromNestedControl(event)) {
259
332
  return;
260
333
  }
261
334
  event.preventDefault();
@@ -263,14 +336,18 @@ class CollapsibleTriggerDirective {
263
336
  }
264
337
  onSpaceKeydown(event) {
265
338
  // Buttons already synthesise a click for Space; anchors scroll the page instead.
266
- if (this.#nativeButton) {
339
+ if (this.#nativeButton || this.#isFromNestedControl(event)) {
267
340
  return;
268
341
  }
269
342
  event.preventDefault();
270
343
  this.collapsible.toggle();
271
344
  }
345
+ #isFromNestedControl(event) {
346
+ const control = event.target.closest(NESTED_CONTROL_SELECTOR);
347
+ return control !== null && control !== this.#element && this.#element.contains(control);
348
+ }
272
349
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: CollapsibleTriggerDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
273
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: CollapsibleTriggerDirective, isStandalone: true, selector: "[monaCollapsibleTrigger]", host: { listeners: { "click": "onClick()", "keydown.enter": "onEnterKeydown($event)", "keydown.space": "onSpaceKeydown($event)" }, properties: { "attr.aria-controls": "collapsible.contentId", "attr.aria-disabled": "ariaDisabled()", "attr.aria-expanded": "collapsible.expanded()", "attr.data-state": "state()", "attr.disabled": "nativeDisabled()", "attr.role": "role", "attr.tabindex": "tabIndex()", "attr.type": "type" } }, ngImport: i0 }); }
350
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: CollapsibleTriggerDirective, isStandalone: true, selector: "[monaCollapsibleTrigger]", host: { listeners: { "click": "onClick($event)", "keydown.enter": "onEnterKeydown($event)", "keydown.space": "onSpaceKeydown($event)" }, properties: { "attr.aria-controls": "collapsible.contentId", "attr.aria-disabled": "ariaDisabled()", "attr.aria-expanded": "collapsible.expanded()", "attr.data-state": "state()", "attr.disabled": "nativeDisabled()", "attr.role": "role", "attr.tabindex": "tabIndex()", "attr.type": "type" } }, ngImport: i0 }); }
274
351
  }
275
352
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: CollapsibleTriggerDirective, decorators: [{
276
353
  type: Directive,
@@ -285,7 +362,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
285
362
  "[attr.role]": "role",
286
363
  "[attr.tabindex]": "tabIndex()",
287
364
  "[attr.type]": "type",
288
- "(click)": "onClick()",
365
+ "(click)": "onClick($event)",
289
366
  "(keydown.enter)": "onEnterKeydown($event)",
290
367
  "(keydown.space)": "onSpaceKeydown($event)"
291
368
  }
@@ -300,5 +377,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
300
377
  * Generated bundle index. Do not edit.
301
378
  */
302
379
 
303
- export { CollapsibleContentDirective, CollapsibleDirective, CollapsibleToken, CollapsibleTriggerDirective };
380
+ export { COLLAPSIBLE_CONFIG, CollapsibleContentDirective, CollapsibleDirective, CollapsibleTriggerDirective };
304
381
  //# sourceMappingURL=nanahoshi-mona-ui-collapsible.mjs.map