@radix-ng/primitives 0.51.0 → 1.0.0-beta.1

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 (186) hide show
  1. package/fesm2022/radix-ng-primitives-accordion.mjs +105 -38
  2. package/fesm2022/radix-ng-primitives-accordion.mjs.map +1 -1
  3. package/fesm2022/radix-ng-primitives-alert-dialog.mjs +221 -129
  4. package/fesm2022/radix-ng-primitives-alert-dialog.mjs.map +1 -1
  5. package/fesm2022/radix-ng-primitives-arrow.mjs +20 -4
  6. package/fesm2022/radix-ng-primitives-arrow.mjs.map +1 -1
  7. package/fesm2022/radix-ng-primitives-aspect-ratio.mjs.map +1 -1
  8. package/fesm2022/radix-ng-primitives-avatar.mjs +54 -61
  9. package/fesm2022/radix-ng-primitives-avatar.mjs.map +1 -1
  10. package/fesm2022/radix-ng-primitives-button.mjs +123 -0
  11. package/fesm2022/radix-ng-primitives-button.mjs.map +1 -0
  12. package/fesm2022/radix-ng-primitives-calendar.mjs +95 -83
  13. package/fesm2022/radix-ng-primitives-calendar.mjs.map +1 -1
  14. package/fesm2022/radix-ng-primitives-checkbox.mjs +378 -54
  15. package/fesm2022/radix-ng-primitives-checkbox.mjs.map +1 -1
  16. package/fesm2022/radix-ng-primitives-collapsible.mjs +182 -81
  17. package/fesm2022/radix-ng-primitives-collapsible.mjs.map +1 -1
  18. package/fesm2022/radix-ng-primitives-collection.mjs +40 -57
  19. package/fesm2022/radix-ng-primitives-collection.mjs.map +1 -1
  20. package/fesm2022/radix-ng-primitives-config.mjs.map +1 -1
  21. package/fesm2022/radix-ng-primitives-context-menu.mjs +140 -424
  22. package/fesm2022/radix-ng-primitives-context-menu.mjs.map +1 -1
  23. package/fesm2022/radix-ng-primitives-core.mjs +845 -744
  24. package/fesm2022/radix-ng-primitives-core.mjs.map +1 -1
  25. package/fesm2022/radix-ng-primitives-cropper.mjs +288 -308
  26. package/fesm2022/radix-ng-primitives-cropper.mjs.map +1 -1
  27. package/fesm2022/radix-ng-primitives-date-field.mjs +104 -58
  28. package/fesm2022/radix-ng-primitives-date-field.mjs.map +1 -1
  29. package/fesm2022/radix-ng-primitives-dialog.mjs +655 -327
  30. package/fesm2022/radix-ng-primitives-dialog.mjs.map +1 -1
  31. package/fesm2022/radix-ng-primitives-dismissable-layer.mjs +70 -46
  32. package/fesm2022/radix-ng-primitives-dismissable-layer.mjs.map +1 -1
  33. package/fesm2022/radix-ng-primitives-drawer.mjs +960 -0
  34. package/fesm2022/radix-ng-primitives-drawer.mjs.map +1 -0
  35. package/fesm2022/radix-ng-primitives-editable.mjs +304 -23
  36. package/fesm2022/radix-ng-primitives-editable.mjs.map +1 -1
  37. package/fesm2022/radix-ng-primitives-field.mjs +363 -0
  38. package/fesm2022/radix-ng-primitives-field.mjs.map +1 -0
  39. package/fesm2022/radix-ng-primitives-fieldset.mjs +79 -0
  40. package/fesm2022/radix-ng-primitives-fieldset.mjs.map +1 -0
  41. package/fesm2022/radix-ng-primitives-focus-scope.mjs +23 -8
  42. package/fesm2022/radix-ng-primitives-focus-scope.mjs.map +1 -1
  43. package/fesm2022/radix-ng-primitives-input.mjs +172 -0
  44. package/fesm2022/radix-ng-primitives-input.mjs.map +1 -0
  45. package/fesm2022/radix-ng-primitives-label.mjs +6 -6
  46. package/fesm2022/radix-ng-primitives-label.mjs.map +1 -1
  47. package/fesm2022/radix-ng-primitives-menu.mjs +1907 -363
  48. package/fesm2022/radix-ng-primitives-menu.mjs.map +1 -1
  49. package/fesm2022/radix-ng-primitives-menubar.mjs +290 -162
  50. package/fesm2022/radix-ng-primitives-menubar.mjs.map +1 -1
  51. package/fesm2022/radix-ng-primitives-meter.mjs +271 -0
  52. package/fesm2022/radix-ng-primitives-meter.mjs.map +1 -0
  53. package/fesm2022/radix-ng-primitives-navigation-menu.mjs +1052 -1553
  54. package/fesm2022/radix-ng-primitives-navigation-menu.mjs.map +1 -1
  55. package/fesm2022/radix-ng-primitives-number-field.mjs +1102 -367
  56. package/fesm2022/radix-ng-primitives-number-field.mjs.map +1 -1
  57. package/fesm2022/radix-ng-primitives-pagination.mjs.map +1 -1
  58. package/fesm2022/radix-ng-primitives-popover.mjs +978 -989
  59. package/fesm2022/radix-ng-primitives-popover.mjs.map +1 -1
  60. package/fesm2022/radix-ng-primitives-popper.mjs +111 -44
  61. package/fesm2022/radix-ng-primitives-popper.mjs.map +1 -1
  62. package/fesm2022/radix-ng-primitives-portal.mjs +34 -10
  63. package/fesm2022/radix-ng-primitives-portal.mjs.map +1 -1
  64. package/fesm2022/radix-ng-primitives-presence.mjs +134 -246
  65. package/fesm2022/radix-ng-primitives-presence.mjs.map +1 -1
  66. package/fesm2022/radix-ng-primitives-preview-card.mjs +997 -0
  67. package/fesm2022/radix-ng-primitives-preview-card.mjs.map +1 -0
  68. package/fesm2022/radix-ng-primitives-progress.mjs +223 -84
  69. package/fesm2022/radix-ng-primitives-progress.mjs.map +1 -1
  70. package/fesm2022/radix-ng-primitives-radio.mjs +191 -51
  71. package/fesm2022/radix-ng-primitives-radio.mjs.map +1 -1
  72. package/fesm2022/radix-ng-primitives-roving-focus.mjs +96 -50
  73. package/fesm2022/radix-ng-primitives-roving-focus.mjs.map +1 -1
  74. package/fesm2022/radix-ng-primitives-scroll-area.mjs +923 -0
  75. package/fesm2022/radix-ng-primitives-scroll-area.mjs.map +1 -0
  76. package/fesm2022/radix-ng-primitives-select.mjs +791 -509
  77. package/fesm2022/radix-ng-primitives-select.mjs.map +1 -1
  78. package/fesm2022/radix-ng-primitives-separator.mjs +12 -35
  79. package/fesm2022/radix-ng-primitives-separator.mjs.map +1 -1
  80. package/fesm2022/radix-ng-primitives-slider.mjs +969 -717
  81. package/fesm2022/radix-ng-primitives-slider.mjs.map +1 -1
  82. package/fesm2022/radix-ng-primitives-stepper.mjs +15 -19
  83. package/fesm2022/radix-ng-primitives-stepper.mjs.map +1 -1
  84. package/fesm2022/radix-ng-primitives-switch.mjs +125 -113
  85. package/fesm2022/radix-ng-primitives-switch.mjs.map +1 -1
  86. package/fesm2022/radix-ng-primitives-tabs.mjs +390 -108
  87. package/fesm2022/radix-ng-primitives-tabs.mjs.map +1 -1
  88. package/fesm2022/radix-ng-primitives-time-field.mjs +55 -46
  89. package/fesm2022/radix-ng-primitives-time-field.mjs.map +1 -1
  90. package/fesm2022/radix-ng-primitives-toast.mjs +839 -0
  91. package/fesm2022/radix-ng-primitives-toast.mjs.map +1 -0
  92. package/fesm2022/radix-ng-primitives-toggle-group.mjs +121 -247
  93. package/fesm2022/radix-ng-primitives-toggle-group.mjs.map +1 -1
  94. package/fesm2022/radix-ng-primitives-toggle.mjs +98 -61
  95. package/fesm2022/radix-ng-primitives-toggle.mjs.map +1 -1
  96. package/fesm2022/radix-ng-primitives-toolbar.mjs +303 -92
  97. package/fesm2022/radix-ng-primitives-toolbar.mjs.map +1 -1
  98. package/fesm2022/radix-ng-primitives-tooltip.mjs +699 -1072
  99. package/fesm2022/radix-ng-primitives-tooltip.mjs.map +1 -1
  100. package/fesm2022/radix-ng-primitives-visually-hidden.mjs +25 -66
  101. package/fesm2022/radix-ng-primitives-visually-hidden.mjs.map +1 -1
  102. package/meter/README.md +3 -0
  103. package/navigation-menu/README.md +2 -1
  104. package/package.json +39 -18
  105. package/portal/README.md +2 -0
  106. package/preview-card/README.md +3 -0
  107. package/schematics/collection.json +1 -0
  108. package/schematics/ng-add/index.d.ts +3 -2
  109. package/schematics/ng-add/index.js +62 -31
  110. package/schematics/ng-add/index.js.map +1 -1
  111. package/schematics/ng-add/package-config.d.ts +4 -2
  112. package/schematics/ng-add/package-config.js +10 -2
  113. package/schematics/ng-add/package-config.js.map +1 -1
  114. package/schematics/ng-add/schema.d.ts +3 -0
  115. package/schematics/ng-add/schema.js +3 -0
  116. package/schematics/ng-add/schema.js.map +1 -0
  117. package/schematics/ng-add/schema.json +14 -0
  118. package/select/README.md +2 -0
  119. package/types/radix-ng-primitives-accordion.d.ts +51 -16
  120. package/types/radix-ng-primitives-alert-dialog.d.ts +95 -38
  121. package/types/radix-ng-primitives-arrow.d.ts +1 -1
  122. package/types/radix-ng-primitives-aspect-ratio.d.ts +1 -1
  123. package/types/radix-ng-primitives-avatar.d.ts +7 -11
  124. package/types/radix-ng-primitives-button.d.ts +73 -0
  125. package/types/radix-ng-primitives-calendar.d.ts +39 -20
  126. package/types/radix-ng-primitives-checkbox.d.ts +204 -35
  127. package/types/radix-ng-primitives-collapsible.d.ts +114 -40
  128. package/types/radix-ng-primitives-collection.d.ts +38 -34
  129. package/types/radix-ng-primitives-config.d.ts +1 -1
  130. package/types/radix-ng-primitives-context-menu.d.ts +61 -116
  131. package/types/radix-ng-primitives-core.d.ts +345 -235
  132. package/types/radix-ng-primitives-cropper.d.ts +89 -56
  133. package/types/radix-ng-primitives-date-field.d.ts +49 -28
  134. package/types/radix-ng-primitives-dialog.d.ts +283 -165
  135. package/types/radix-ng-primitives-dismissable-layer.d.ts +15 -7
  136. package/types/radix-ng-primitives-drawer.d.ts +426 -0
  137. package/types/radix-ng-primitives-editable.d.ts +91 -14
  138. package/types/radix-ng-primitives-field.d.ts +374 -0
  139. package/types/radix-ng-primitives-fieldset.d.ts +49 -0
  140. package/types/radix-ng-primitives-focus-scope.d.ts +15 -6
  141. package/types/radix-ng-primitives-input.d.ts +87 -0
  142. package/types/radix-ng-primitives-label.d.ts +0 -1
  143. package/types/radix-ng-primitives-menu.d.ts +584 -99
  144. package/types/radix-ng-primitives-menubar.d.ts +61 -50
  145. package/types/radix-ng-primitives-meter.d.ts +194 -0
  146. package/types/radix-ng-primitives-navigation-menu.d.ts +422 -340
  147. package/types/radix-ng-primitives-number-field.d.ts +405 -145
  148. package/types/radix-ng-primitives-pagination.d.ts +2 -2
  149. package/types/radix-ng-primitives-popover.d.ts +366 -351
  150. package/types/radix-ng-primitives-popper.d.ts +68 -11
  151. package/types/radix-ng-primitives-portal.d.ts +14 -6
  152. package/types/radix-ng-primitives-presence.d.ts +28 -76
  153. package/types/radix-ng-primitives-preview-card.d.ts +359 -0
  154. package/types/radix-ng-primitives-progress.d.ts +175 -48
  155. package/types/radix-ng-primitives-radio.d.ts +55 -25
  156. package/types/radix-ng-primitives-roving-focus.d.ts +33 -23
  157. package/types/radix-ng-primitives-scroll-area.d.ts +253 -0
  158. package/types/radix-ng-primitives-select.d.ts +475 -177
  159. package/types/radix-ng-primitives-separator.d.ts +7 -32
  160. package/types/radix-ng-primitives-slider.d.ts +315 -201
  161. package/types/radix-ng-primitives-stepper.d.ts +5 -7
  162. package/types/radix-ng-primitives-switch.d.ts +86 -71
  163. package/types/radix-ng-primitives-tabs.d.ts +213 -79
  164. package/types/radix-ng-primitives-time-field.d.ts +42 -27
  165. package/types/radix-ng-primitives-toast.d.ts +378 -0
  166. package/types/radix-ng-primitives-toggle-group.d.ts +86 -164
  167. package/types/radix-ng-primitives-toggle.d.ts +43 -53
  168. package/types/radix-ng-primitives-toolbar.d.ts +164 -38
  169. package/types/radix-ng-primitives-tooltip.d.ts +348 -384
  170. package/types/radix-ng-primitives-visually-hidden.d.ts +19 -19
  171. package/dropdown-menu/README.md +0 -1
  172. package/fesm2022/radix-ng-primitives-dropdown-menu.mjs +0 -581
  173. package/fesm2022/radix-ng-primitives-dropdown-menu.mjs.map +0 -1
  174. package/fesm2022/radix-ng-primitives-hover-card.mjs +0 -1238
  175. package/fesm2022/radix-ng-primitives-hover-card.mjs.map +0 -1
  176. package/fesm2022/radix-ng-primitives-select2.mjs +0 -897
  177. package/fesm2022/radix-ng-primitives-select2.mjs.map +0 -1
  178. package/fesm2022/radix-ng-primitives-tooltip2.mjs +0 -735
  179. package/fesm2022/radix-ng-primitives-tooltip2.mjs.map +0 -1
  180. package/hover-card/README.md +0 -3
  181. package/select2/README.md +0 -3
  182. package/tooltip2/README.md +0 -3
  183. package/types/radix-ng-primitives-dropdown-menu.d.ts +0 -171
  184. package/types/radix-ng-primitives-hover-card.d.ts +0 -471
  185. package/types/radix-ng-primitives-select2.d.ts +0 -511
  186. package/types/radix-ng-primitives-tooltip2.d.ts +0 -325
@@ -35,14 +35,14 @@ class RdxCalendarCellTriggerDirective {
35
35
  * Current selected state
36
36
  */
37
37
  this.isSelectedDate = computed(() => this.rootContext.isDateSelected(this.day()), ...(ngDevMode ? [{ debugName: "isSelectedDate" }] : /* istanbul ignore next */ []));
38
- this.isDisabled = computed(() => this.rootContext.isDateDisabled(this.day()), ...(ngDevMode ? [{ debugName: "isDisabled" }] : /* istanbul ignore next */ []));
38
+ this.isDisabled = computed(() => this.rootContext.dateDisabled(this.day()), ...(ngDevMode ? [{ debugName: "isDisabled" }] : /* istanbul ignore next */ []));
39
39
  this.isOutsideView = computed(() => {
40
40
  return !isSameMonth(this.day(), this.month());
41
41
  }, ...(ngDevMode ? [{ debugName: "isOutsideView" }] : /* istanbul ignore next */ []));
42
42
  this.isFocusedDate = computed(() => {
43
43
  return !this.rootContext.disabled() && isSameDay(this.day(), this.rootContext.placeholder());
44
44
  }, ...(ngDevMode ? [{ debugName: "isFocusedDate" }] : /* istanbul ignore next */ []));
45
- this.isUnavailable = computed(() => this.rootContext.isDateUnavailable?.(this.day()) ?? false, ...(ngDevMode ? [{ debugName: "isUnavailable" }] : /* istanbul ignore next */ []));
45
+ this.isUnavailable = computed(() => this.rootContext.dateUnavailable(this.day()), ...(ngDevMode ? [{ debugName: "isUnavailable" }] : /* istanbul ignore next */ []));
46
46
  this.labelText = computed(() => {
47
47
  return this.rootContext.formatter.custom(toDate(this.day()), {
48
48
  weekday: 'long',
@@ -55,12 +55,21 @@ class RdxCalendarCellTriggerDirective {
55
55
  * @ignore
56
56
  */
57
57
  this.SELECTOR = '[data-rdx-calendar-cell-trigger]:not([data-outside-view]):not([data-outside-visible-view])';
58
- }
59
- ngAfterViewInit() {
58
+ // Host element is available in the constructor; no AfterViewInit needed.
60
59
  this.currentElement = this.elementRef.nativeElement;
61
60
  }
62
61
  onClick() {
63
- this.changeDate(this.day());
62
+ this.select();
63
+ }
64
+ /** Select the date unless the cell is disabled/unavailable or the calendar is readonly. */
65
+ select() {
66
+ if (this.isDisabled() || this.isUnavailable() || this.rootContext.readonly()) {
67
+ return;
68
+ }
69
+ const day = this.day();
70
+ if (day) {
71
+ this.changeDate(day);
72
+ }
64
73
  }
65
74
  onArrowKey(event) {
66
75
  const keyEvent = event;
@@ -87,7 +96,7 @@ class RdxCalendarCellTriggerDirective {
87
96
  break;
88
97
  case kbd.ENTER:
89
98
  case kbd.SPACE_CODE:
90
- this.changeDate(this.day());
99
+ this.select();
91
100
  }
92
101
  }
93
102
  shiftFocus(node, add) {
@@ -98,10 +107,7 @@ class RdxCalendarCellTriggerDirective {
98
107
  const index = allCollectionItems.indexOf(node);
99
108
  const newIndex = index + add;
100
109
  if (newIndex >= 0 && newIndex < allCollectionItems.length) {
101
- if (allCollectionItems[newIndex].hasAttribute('data-disabled')) {
102
- this.shiftFocus(allCollectionItems[newIndex], add);
103
- }
104
- allCollectionItems[newIndex].focus();
110
+ this.focusCell(allCollectionItems, newIndex, add);
105
111
  return;
106
112
  }
107
113
  if (newIndex < 0) {
@@ -109,50 +115,46 @@ class RdxCalendarCellTriggerDirective {
109
115
  return;
110
116
  this.rootContext.prevPage();
111
117
  setTimeout(() => {
112
- const newCollectionItems = this.getSelectableCells(parentElement);
113
- if (!newCollectionItems.length)
118
+ const cells = this.getSelectableCells(parentElement);
119
+ if (!cells.length)
114
120
  return;
115
- if (!this.rootContext.pagedNavigation && this.rootContext.numberOfMonths() > 1) {
116
- // Placeholder is set to the first month of the new page
117
- const numberOfDays = getDaysInMonth(this.rootContext.placeholder());
118
- const computedIndex = numberOfDays - Math.abs(newIndex);
119
- if (newCollectionItems[computedIndex].hasAttribute('data-disabled')) {
120
- this.shiftFocus(newCollectionItems[computedIndex], add);
121
- }
122
- newCollectionItems[computedIndex].focus();
123
- return;
124
- }
125
- const computedIndex = newCollectionItems.length - Math.abs(newIndex);
126
- if (newCollectionItems[computedIndex].hasAttribute('data-disabled')) {
127
- this.shiftFocus(newCollectionItems[computedIndex], add);
128
- }
129
- newCollectionItems[computedIndex].focus();
121
+ const computedIndex = !this.rootContext.pagedNavigation() && this.rootContext.numberOfMonths() > 1
122
+ ? // placeholder is the first month of the new page
123
+ getDaysInMonth(this.rootContext.placeholder()) - Math.abs(newIndex)
124
+ : cells.length - Math.abs(newIndex);
125
+ this.focusCell(cells, computedIndex, add);
130
126
  });
127
+ return;
131
128
  }
132
- if (newIndex >= allCollectionItems.length) {
133
- if (!this.rootContext.nextPage)
129
+ // newIndex >= allCollectionItems.length
130
+ if (!this.rootContext.nextPage)
131
+ return;
132
+ this.rootContext.nextPage();
133
+ setTimeout(() => {
134
+ const cells = this.getSelectableCells(parentElement);
135
+ if (!cells.length)
134
136
  return;
135
- this.rootContext.nextPage();
136
- setTimeout(() => {
137
- const newCollectionItems = this.getSelectableCells(parentElement);
138
- if (!newCollectionItems.length)
139
- return;
140
- if (!this.rootContext.pagedNavigation && this.rootContext.numberOfMonths() > 1) {
141
- const numberOfDays = getDaysInMonth(this.rootContext.placeholder().add({ months: this.rootContext.numberOfMonths() - 1 }));
142
- const computedIndex = newIndex - allCollectionItems.length + (newCollectionItems.length - numberOfDays);
143
- if (newCollectionItems[computedIndex].hasAttribute('data-disabled')) {
144
- this.shiftFocus(newCollectionItems[computedIndex], add);
145
- }
146
- newCollectionItems[computedIndex].focus();
147
- return;
148
- }
149
- const computedIndex = newIndex - allCollectionItems.length;
150
- if (newCollectionItems[computedIndex].hasAttribute('data-disabled')) {
151
- this.shiftFocus(newCollectionItems[computedIndex], add);
152
- }
153
- newCollectionItems[computedIndex].focus();
154
- });
137
+ let computedIndex;
138
+ if (!this.rootContext.pagedNavigation() && this.rootContext.numberOfMonths() > 1) {
139
+ const numberOfDays = getDaysInMonth(this.rootContext.placeholder().add({ months: this.rootContext.numberOfMonths() - 1 }));
140
+ computedIndex = newIndex - allCollectionItems.length + (cells.length - numberOfDays);
141
+ }
142
+ else {
143
+ computedIndex = newIndex - allCollectionItems.length;
144
+ }
145
+ this.focusCell(cells, computedIndex, add);
146
+ });
147
+ }
148
+ /** Focus the cell at `index`, skipping over a disabled cell in the same direction. */
149
+ focusCell(cells, index, add) {
150
+ const cell = cells[index];
151
+ if (!cell)
152
+ return;
153
+ if (cell.hasAttribute('data-disabled')) {
154
+ this.shiftFocus(cell, add);
155
+ return;
155
156
  }
157
+ cell.focus();
156
158
  }
157
159
  /**
158
160
  * @ignore
@@ -191,7 +193,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImpor
191
193
  '(keydown)': 'onArrowKey($event)'
192
194
  }
193
195
  }]
194
- }], propDecorators: { day: [{ type: i0.Input, args: [{ isSignal: true, alias: "day", required: false }] }], month: [{ type: i0.Input, args: [{ isSignal: true, alias: "month", required: false }] }] } });
196
+ }], ctorParameters: () => [], propDecorators: { day: [{ type: i0.Input, args: [{ isSignal: true, alias: "day", required: false }] }], month: [{ type: i0.Input, args: [{ isSignal: true, alias: "month", required: false }] }] } });
195
197
 
196
198
  class RdxCalendarCellDirective {
197
199
  constructor() {
@@ -202,7 +204,7 @@ class RdxCalendarCellDirective {
202
204
  this.date = input(...(ngDevMode ? [undefined, { debugName: "date" }] : /* istanbul ignore next */ []));
203
205
  }
204
206
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxCalendarCellDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
205
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.9", type: RdxCalendarCellDirective, isStandalone: true, selector: "td[rdxCalendarCell]", inputs: { date: { classPropertyName: "date", publicName: "date", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "gridcell" }, properties: { "attr.aria-selected": "rootContext.isDateSelected?.(date()!) ? true : undefined", "attr.aria-disabled": "rootContext.isDateSelected?.(date()!) || rootContext.isDateUnavailable?.(date()!)", "attr.data-disabled": "rootContext.isDateSelected?.(date()!) ? \"\" : undefined" } }, ngImport: i0 }); }
207
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.9", type: RdxCalendarCellDirective, isStandalone: true, selector: "td[rdxCalendarCell]", inputs: { date: { classPropertyName: "date", publicName: "date", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "gridcell" }, properties: { "attr.aria-selected": "rootContext.isDateSelected(date()!) ? true : undefined", "attr.aria-disabled": "rootContext.dateDisabled(date()!) || rootContext.dateUnavailable(date()!) ? true : undefined", "attr.data-disabled": "rootContext.dateDisabled(date()!) ? \"\" : undefined" } }, ngImport: i0 }); }
206
208
  }
207
209
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxCalendarCellDirective, decorators: [{
208
210
  type: Directive,
@@ -210,9 +212,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImpor
210
212
  selector: 'td[rdxCalendarCell]',
211
213
  host: {
212
214
  role: 'gridcell',
213
- '[attr.aria-selected]': 'rootContext.isDateSelected?.(date()!) ? true : undefined',
214
- '[attr.aria-disabled]': 'rootContext.isDateSelected?.(date()!) || rootContext.isDateUnavailable?.(date()!)',
215
- '[attr.data-disabled]': 'rootContext.isDateSelected?.(date()!) ? "" : undefined'
215
+ '[attr.aria-selected]': 'rootContext.isDateSelected(date()!) ? true : undefined',
216
+ '[attr.aria-disabled]': 'rootContext.dateDisabled(date()!) || rootContext.dateUnavailable(date()!) ? true : undefined',
217
+ '[attr.data-disabled]': 'rootContext.dateDisabled(date()!) ? "" : undefined'
216
218
  }
217
219
  }]
218
220
  }], propDecorators: { date: [{ type: i0.Input, args: [{ isSignal: true, alias: "date", required: false }] }] } });
@@ -257,7 +259,7 @@ class RdxCalendarGridDirective {
257
259
  constructor() {
258
260
  this.rootContext = injectCalendarRootContext();
259
261
  this.disabled = computed(() => (this.rootContext.disabled() ? true : undefined), ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
260
- this.readonly = computed(() => (this.rootContext.readonly ? true : undefined), ...(ngDevMode ? [{ debugName: "readonly" }] : /* istanbul ignore next */ []));
262
+ this.readonly = computed(() => (this.rootContext.readonly() ? true : undefined), ...(ngDevMode ? [{ debugName: "readonly" }] : /* istanbul ignore next */ []));
261
263
  }
262
264
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxCalendarGridDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
263
265
  static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.9", type: RdxCalendarGridDirective, isStandalone: true, selector: "table[rdxCalendarGrid]", host: { attributes: { "tabindex": "-1", "role": "grid" }, properties: { "attr.aria-readonly": "readonly()", "attr.aria-disabled": "disabled()", "attr.data-readonly": "readonly() && \"\"", "attr.data-disabled": "disabled() && \"\"" } }, ngImport: i0 }); }
@@ -361,7 +363,7 @@ class RdxCalendarPrevDirective {
361
363
  /**
362
364
  * @ignore
363
365
  */
364
- this.disabled = computed(() => this.rootContext.disabled() || this.rootContext.isNextButtonDisabled(this.prevPage()), ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
366
+ this.disabled = computed(() => this.rootContext.disabled() || this.rootContext.isPrevButtonDisabled(this.prevPage()), ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
365
367
  }
366
368
  onClick() {
367
369
  this.rootContext.prevPage(this.prevPage());
@@ -663,16 +665,16 @@ class RdxCalendarRootDirective {
663
665
  */
664
666
  this.defaultPlaceholder = model(...(ngDevMode ? [undefined, { debugName: "defaultPlaceholder" }] : /* istanbul ignore next */ []));
665
667
  this.locale = input('en', ...(ngDevMode ? [{ debugName: "locale" }] : /* istanbul ignore next */ []));
666
- this.defaultDate = getDefaultDate({
668
+ this.defaultDate = computed(() => getDefaultDate({
667
669
  defaultPlaceholder: this.defaultPlaceholder(),
668
670
  defaultValue: this.value(),
669
671
  locale: this.locale()
670
- });
672
+ }), ...(ngDevMode ? [{ debugName: "defaultDate" }] : /* istanbul ignore next */ []));
671
673
  /**
672
674
  * The placeholder date, which is used to determine what month to display when no date is selected.
673
675
  * This updates as the user navigates the calendar and can be used to programmatically control the calendar view
674
676
  */
675
- this.placeholder = model(this.defaultPlaceholder() ?? this.defaultDate.copy(), ...(ngDevMode ? [{ debugName: "placeholder" }] : /* istanbul ignore next */ []));
677
+ this.placeholder = model(this.defaultPlaceholder() ?? this.defaultDate().copy(), ...(ngDevMode ? [{ debugName: "placeholder" }] : /* istanbul ignore next */ []));
676
678
  this.multiple = input(false, { ...(ngDevMode ? { debugName: "multiple" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
677
679
  /**
678
680
  * Whether to always display 6 weeks in the calendar
@@ -742,14 +744,13 @@ class RdxCalendarRootDirective {
742
744
  this._disabled = linkedSignal(this.disabled, ...(ngDevMode ? [{ debugName: "_disabled" }] : /* istanbul ignore next */ []));
743
745
  this._pagedNavigation = linkedSignal(this.pagedNavigation, ...(ngDevMode ? [{ debugName: "_pagedNavigation" }] : /* istanbul ignore next */ []));
744
746
  this.startingWeekNumber = computed(() => {
745
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
746
- // @ts-expect-error
747
- const firstDayOfGrid = startOfWeek(this.months()[0].weeks[0][0], this.locale());
748
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
749
- // @ts-expect-error
750
- return Array.from({ length: this.months()[0].weeks.length })
751
- .fill(null)
752
- .map((_, idx) => {
747
+ const months = this.months();
748
+ const firstWeek = months?.[0]?.weeks;
749
+ if (!firstWeek?.length) {
750
+ return [];
751
+ }
752
+ const firstDayOfGrid = startOfWeek(firstWeek[0][0], this.locale());
753
+ return Array.from({ length: firstWeek.length }).map((_, idx) => {
753
754
  const firstDayOfWeek = firstDayOfGrid.add({ weeks: idx });
754
755
  const thursday = firstDayOfWeek.add({ days: 3 });
755
756
  const firstDayOfYear = startOfYear(thursday);
@@ -759,11 +760,28 @@ class RdxCalendarRootDirective {
759
760
  /**
760
761
  * @ignore
761
762
  */
762
- this.headingValue = signal('', ...(ngDevMode ? [{ debugName: "headingValue" }] : /* istanbul ignore next */ []));
763
+ this.headingValue = computed(() => this.calendar.headingValue(), ...(ngDevMode ? [{ debugName: "headingValue" }] : /* istanbul ignore next */ []));
764
+ /**
765
+ * @ignore
766
+ */
767
+ this.fullCalendarLabel = computed(() => this.calendar.fullCalendarLabel(), ...(ngDevMode ? [{ debugName: "fullCalendarLabel" }] : /* istanbul ignore next */ []));
763
768
  /**
769
+ * Selection + validity state, recomputed when the value or the matchers change.
764
770
  * @ignore
765
771
  */
766
- this.fullCalendarLabel = signal('', ...(ngDevMode ? [{ debugName: "fullCalendarLabel" }] : /* istanbul ignore next */ []));
772
+ this._state = computed(() => calendarState({
773
+ date: this.value,
774
+ isDateDisabled: this.isDateDisabled(),
775
+ isDateUnavailable: this.isDateUnavailable()
776
+ }), ...(ngDevMode ? [{ debugName: "_state" }] : /* istanbul ignore next */ []));
777
+ /**
778
+ * @ignore
779
+ */
780
+ this.isDateSelected = (date) => this._state().isDateSelected(date);
781
+ /**
782
+ * @ignore
783
+ */
784
+ this.isInvalid = computed(() => this._state().isInvalid(), ...(ngDevMode ? [{ debugName: "isInvalid" }] : /* istanbul ignore next */ []));
767
785
  this.calendar = calendar({
768
786
  locale: this.locale,
769
787
  placeholder: this.placeholder,
@@ -781,24 +799,21 @@ class RdxCalendarRootDirective {
781
799
  nextPage: this.propsNextPage,
782
800
  prevPage: this.propsPrevPage
783
801
  });
802
+ // Host element exists in the constructor; no need for AfterViewInit.
803
+ this.currentElement = this.elementRef.nativeElement;
784
804
  this.nextPage = this.calendar.nextPage;
785
805
  this.prevPage = this.calendar.prevPage;
786
806
  this.isOutsideVisibleView = this.calendar.isOutsideVisibleView;
787
807
  this.isNextButtonDisabled = this.calendar.isNextButtonDisabled;
788
808
  this.isPrevButtonDisabled = this.calendar.isPrevButtonDisabled;
789
809
  this.formatter = this.calendar.formatter;
810
+ // Resolved matchers (fold in `disabled`, min/max and the input matchers).
811
+ this.dateDisabled = this.calendar.isDateDisabled;
812
+ this.dateUnavailable = this.calendar.isDateUnavailable;
813
+ // Bridge the composable's grid output into the exposed models.
790
814
  effect(() => {
791
815
  this.months.set(this.calendar.month());
792
816
  this.weekDays.set(this.calendar.weekdays());
793
- this.fullCalendarLabel.set(this.calendar.fullCalendarLabel());
794
- this.headingValue.set(this.calendar.headingValue());
795
- const { isInvalid, isDateSelected } = calendarState({
796
- date: this.value,
797
- isDateDisabled: this.isDateDisabled(),
798
- isDateUnavailable: this.isDateUnavailable()
799
- });
800
- this.isDateSelected = isDateSelected;
801
- this.isInvalid = isInvalid();
802
817
  });
803
818
  watch([this.value], ([_modelValue]) => {
804
819
  if (Array.isArray(_modelValue) && _modelValue.length) {
@@ -812,9 +827,6 @@ class RdxCalendarRootDirective {
812
827
  }
813
828
  });
814
829
  }
815
- ngAfterViewInit() {
816
- this.currentElement = this.elementRef.nativeElement;
817
- }
818
830
  /**
819
831
  * @ignore
820
832
  */
@@ -861,7 +873,7 @@ class RdxCalendarRootDirective {
861
873
  }
862
874
  }
863
875
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxCalendarRootDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
864
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.9", type: RdxCalendarRootDirective, isStandalone: true, selector: "[rdxCalendarRoot]", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, defaultPlaceholder: { classPropertyName: "defaultPlaceholder", publicName: "defaultPlaceholder", isSignal: true, isRequired: false, transformFunction: null }, locale: { classPropertyName: "locale", publicName: "locale", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, multiple: { classPropertyName: "multiple", publicName: "multiple", isSignal: true, isRequired: false, transformFunction: null }, fixedWeeks: { classPropertyName: "fixedWeeks", publicName: "fixedWeeks", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, preventDeselect: { classPropertyName: "preventDeselect", publicName: "preventDeselect", isSignal: true, isRequired: false, transformFunction: null }, weekStartsOn: { classPropertyName: "weekStartsOn", publicName: "weekStartsOn", isSignal: true, isRequired: false, transformFunction: null }, numberOfMonths: { classPropertyName: "numberOfMonths", publicName: "numberOfMonths", isSignal: true, isRequired: false, transformFunction: null }, dir: { classPropertyName: "dir", publicName: "dir", isSignal: true, isRequired: false, transformFunction: null }, minValue: { classPropertyName: "minValue", publicName: "minValue", isSignal: true, isRequired: false, transformFunction: null }, maxValue: { classPropertyName: "maxValue", publicName: "maxValue", isSignal: true, isRequired: false, transformFunction: null }, weekdayFormat: { classPropertyName: "weekdayFormat", publicName: "weekdayFormat", isSignal: true, isRequired: false, transformFunction: null }, calendarLabel: { classPropertyName: "calendarLabel", publicName: "calendarLabel", isSignal: true, isRequired: false, transformFunction: null }, readonly: { classPropertyName: "readonly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null }, pagedNavigation: { classPropertyName: "pagedNavigation", publicName: "pagedNavigation", isSignal: true, isRequired: false, transformFunction: null }, propsNextPage: { classPropertyName: "propsNextPage", publicName: "propsNextPage", isSignal: true, isRequired: false, transformFunction: null }, propsPrevPage: { classPropertyName: "propsPrevPage", publicName: "propsPrevPage", isSignal: true, isRequired: false, transformFunction: null }, isDateDisabled: { classPropertyName: "isDateDisabled", publicName: "isDateDisabled", isSignal: true, isRequired: false, transformFunction: null }, isDateUnavailable: { classPropertyName: "isDateUnavailable", publicName: "isDateUnavailable", isSignal: true, isRequired: false, transformFunction: null }, initialFocus: { classPropertyName: "initialFocus", publicName: "initialFocus", isSignal: true, isRequired: false, transformFunction: null }, months: { classPropertyName: "months", publicName: "months", isSignal: true, isRequired: false, transformFunction: null }, weekDays: { classPropertyName: "weekDays", publicName: "weekDays", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange", defaultPlaceholder: "defaultPlaceholderChange", placeholder: "placeholderChange", months: "monthsChange", weekDays: "weekDaysChange" }, host: { attributes: { "role": "application" }, properties: { "attr.aria-label": "fullCalendarLabel()", "attr.data-disabled": "disabled() ? \"\" : undefined", "attr.data-readonly": "readonly() ? \"\" : undefined", "attr.data-invalid": "isInvalid ? \"\" : undefined", "attr.dir": "dir()" } }, providers: [{ provide: CALENDAR_ROOT_CONTEXT, useExisting: forwardRef(() => RdxCalendarRootDirective) }], exportAs: ["rdxCalendarRoot"], ngImport: i0 }); }
876
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.9", type: RdxCalendarRootDirective, isStandalone: true, selector: "[rdxCalendarRoot]", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, defaultPlaceholder: { classPropertyName: "defaultPlaceholder", publicName: "defaultPlaceholder", isSignal: true, isRequired: false, transformFunction: null }, locale: { classPropertyName: "locale", publicName: "locale", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, multiple: { classPropertyName: "multiple", publicName: "multiple", isSignal: true, isRequired: false, transformFunction: null }, fixedWeeks: { classPropertyName: "fixedWeeks", publicName: "fixedWeeks", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, preventDeselect: { classPropertyName: "preventDeselect", publicName: "preventDeselect", isSignal: true, isRequired: false, transformFunction: null }, weekStartsOn: { classPropertyName: "weekStartsOn", publicName: "weekStartsOn", isSignal: true, isRequired: false, transformFunction: null }, numberOfMonths: { classPropertyName: "numberOfMonths", publicName: "numberOfMonths", isSignal: true, isRequired: false, transformFunction: null }, dir: { classPropertyName: "dir", publicName: "dir", isSignal: true, isRequired: false, transformFunction: null }, minValue: { classPropertyName: "minValue", publicName: "minValue", isSignal: true, isRequired: false, transformFunction: null }, maxValue: { classPropertyName: "maxValue", publicName: "maxValue", isSignal: true, isRequired: false, transformFunction: null }, weekdayFormat: { classPropertyName: "weekdayFormat", publicName: "weekdayFormat", isSignal: true, isRequired: false, transformFunction: null }, calendarLabel: { classPropertyName: "calendarLabel", publicName: "calendarLabel", isSignal: true, isRequired: false, transformFunction: null }, readonly: { classPropertyName: "readonly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null }, pagedNavigation: { classPropertyName: "pagedNavigation", publicName: "pagedNavigation", isSignal: true, isRequired: false, transformFunction: null }, propsNextPage: { classPropertyName: "propsNextPage", publicName: "propsNextPage", isSignal: true, isRequired: false, transformFunction: null }, propsPrevPage: { classPropertyName: "propsPrevPage", publicName: "propsPrevPage", isSignal: true, isRequired: false, transformFunction: null }, isDateDisabled: { classPropertyName: "isDateDisabled", publicName: "isDateDisabled", isSignal: true, isRequired: false, transformFunction: null }, isDateUnavailable: { classPropertyName: "isDateUnavailable", publicName: "isDateUnavailable", isSignal: true, isRequired: false, transformFunction: null }, initialFocus: { classPropertyName: "initialFocus", publicName: "initialFocus", isSignal: true, isRequired: false, transformFunction: null }, months: { classPropertyName: "months", publicName: "months", isSignal: true, isRequired: false, transformFunction: null }, weekDays: { classPropertyName: "weekDays", publicName: "weekDays", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange", defaultPlaceholder: "defaultPlaceholderChange", placeholder: "placeholderChange", months: "monthsChange", weekDays: "weekDaysChange" }, host: { attributes: { "role": "application" }, properties: { "attr.aria-label": "fullCalendarLabel()", "attr.data-disabled": "disabled() ? \"\" : undefined", "attr.data-readonly": "readonly() ? \"\" : undefined", "attr.data-invalid": "isInvalid() ? \"\" : undefined", "attr.dir": "dir()" } }, providers: [{ provide: CALENDAR_ROOT_CONTEXT, useExisting: forwardRef(() => RdxCalendarRootDirective) }], exportAs: ["rdxCalendarRoot"], ngImport: i0 }); }
865
877
  }
866
878
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxCalendarRootDirective, decorators: [{
867
879
  type: Directive,
@@ -874,7 +886,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImpor
874
886
  '[attr.aria-label]': 'fullCalendarLabel()',
875
887
  '[attr.data-disabled]': 'disabled() ? "" : undefined',
876
888
  '[attr.data-readonly]': 'readonly() ? "" : undefined',
877
- '[attr.data-invalid]': 'isInvalid ? "" : undefined',
889
+ '[attr.data-invalid]': 'isInvalid() ? "" : undefined',
878
890
  '[attr.dir]': 'dir()'
879
891
  }
880
892
  }]