@radix-ng/primitives 0.29.0 → 0.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/checkbox/src/checkbox.directive.d.ts +11 -0
  2. package/core/index.d.ts +2 -0
  3. package/core/src/isNumber.d.ts +1 -0
  4. package/core/src/nullish.d.ts +1 -0
  5. package/dialog/src/dialog.config.d.ts +1 -0
  6. package/fesm2022/radix-ng-primitives-accordion.mjs +20 -20
  7. package/fesm2022/radix-ng-primitives-alert-dialog.mjs +22 -22
  8. package/fesm2022/radix-ng-primitives-aspect-ratio.mjs +3 -3
  9. package/fesm2022/radix-ng-primitives-avatar.mjs +16 -16
  10. package/fesm2022/radix-ng-primitives-checkbox.mjs +28 -17
  11. package/fesm2022/radix-ng-primitives-checkbox.mjs.map +1 -1
  12. package/fesm2022/radix-ng-primitives-collapsible.mjs +10 -10
  13. package/fesm2022/radix-ng-primitives-context-menu.mjs +36 -36
  14. package/fesm2022/radix-ng-primitives-core.mjs +14 -8
  15. package/fesm2022/radix-ng-primitives-core.mjs.map +1 -1
  16. package/fesm2022/radix-ng-primitives-dialog.mjs +40 -38
  17. package/fesm2022/radix-ng-primitives-dialog.mjs.map +1 -1
  18. package/fesm2022/radix-ng-primitives-dropdown-menu.mjs +35 -35
  19. package/fesm2022/radix-ng-primitives-hover-card.mjs +30 -33
  20. package/fesm2022/radix-ng-primitives-hover-card.mjs.map +1 -1
  21. package/fesm2022/radix-ng-primitives-label.mjs +3 -3
  22. package/fesm2022/radix-ng-primitives-menu.mjs +429 -62
  23. package/fesm2022/radix-ng-primitives-menu.mjs.map +1 -1
  24. package/fesm2022/radix-ng-primitives-menubar.mjs +87 -139
  25. package/fesm2022/radix-ng-primitives-menubar.mjs.map +1 -1
  26. package/fesm2022/radix-ng-primitives-popover.mjs +30 -33
  27. package/fesm2022/radix-ng-primitives-popover.mjs.map +1 -1
  28. package/fesm2022/radix-ng-primitives-progress.mjs +68 -90
  29. package/fesm2022/radix-ng-primitives-progress.mjs.map +1 -1
  30. package/fesm2022/radix-ng-primitives-radio.mjs +13 -13
  31. package/fesm2022/radix-ng-primitives-roving-focus.mjs +7 -7
  32. package/fesm2022/radix-ng-primitives-select.mjs +36 -36
  33. package/fesm2022/radix-ng-primitives-separator.mjs +3 -3
  34. package/fesm2022/radix-ng-primitives-slider.mjs +32 -32
  35. package/fesm2022/radix-ng-primitives-switch.mjs +13 -13
  36. package/fesm2022/radix-ng-primitives-tabs.mjs +16 -16
  37. package/fesm2022/radix-ng-primitives-toggle-group.mjs +9 -9
  38. package/fesm2022/radix-ng-primitives-toggle.mjs +6 -6
  39. package/fesm2022/radix-ng-primitives-toolbar.mjs +22 -22
  40. package/fesm2022/radix-ng-primitives-tooltip.mjs +30 -33
  41. package/fesm2022/radix-ng-primitives-tooltip.mjs.map +1 -1
  42. package/fesm2022/radix-ng-primitives-visually-hidden.mjs +9 -9
  43. package/hover-card/src/hover-card-root.directive.d.ts +4 -4
  44. package/menu/index.d.ts +20 -9
  45. package/menu/src/menu-content.directive.d.ts +1 -1
  46. package/menu/src/menu-directive.d.ts +1 -1
  47. package/menu/src/menu-group.directive.d.ts +1 -1
  48. package/menu/src/menu-item-checkbox.directive.d.ts +21 -0
  49. package/menu/src/menu-item-indicator.directive.d.ts +10 -0
  50. package/menu/src/menu-item-radio.directive.d.ts +20 -0
  51. package/menu/src/menu-item.directive.d.ts +8 -2
  52. package/menu/src/menu-label.directive.d.ts +1 -1
  53. package/menu/src/menu-radio-group.directive.d.ts +6 -0
  54. package/menu/src/menu-separator.directive.d.ts +1 -2
  55. package/menu/src/menu-trigger.directive.d.ts +35 -0
  56. package/menu/src/utils.d.ts +3 -0
  57. package/menubar/index.d.ts +1 -1
  58. package/menubar/src/menubar-content.directive.d.ts +2 -2
  59. package/menubar/src/menubar-item-checkbox.directive.d.ts +2 -10
  60. package/menubar/src/menubar-item-indicator.directive.d.ts +2 -1
  61. package/menubar/src/menubar-item-radio.directive.d.ts +2 -10
  62. package/menubar/src/menubar-item.directive.d.ts +1 -3
  63. package/menubar/src/menubar-radio-group.directive.d.ts +1 -1
  64. package/menubar/src/menubar-root.directive.d.ts +3 -4
  65. package/menubar/src/menubar-separator.directive.d.ts +1 -1
  66. package/menubar/src/menubar-trigger.directive.d.ts +2 -7
  67. package/package.json +9 -133
  68. package/popover/src/popover-root.directive.d.ts +4 -4
  69. package/progress/src/progress-root.directive.d.ts +19 -33
  70. package/schematics/collection.json +2 -3
  71. package/schematics/ng-add/index.d.ts +1 -2
  72. package/schematics/ng-add/index.js +48 -18
  73. package/schematics/ng-add/index.js.map +1 -1
  74. package/schematics/ng-add/package-config.d.ts +18 -0
  75. package/schematics/ng-add/package-config.js +51 -0
  76. package/schematics/ng-add/package-config.js.map +1 -0
  77. package/tooltip/src/tooltip-root.directive.d.ts +4 -4
  78. package/schematics/ng-add/schema.d.ts +0 -3
  79. package/schematics/ng-add/schema.js +0 -3
  80. package/schematics/ng-add/schema.js.map +0 -1
@@ -1,46 +1,45 @@
1
1
  import * as i0 from '@angular/core';
2
- import { Directive, inject, input, booleanAttribute, computed, effect, Output, NgModule } from '@angular/core';
2
+ import { Directive, inject, input, booleanAttribute, computed, signal, effect, numberAttribute, untracked, SimpleChange, NgModule } from '@angular/core';
3
3
  import * as i1 from '@angular/cdk/menu';
4
- import { CdkMenu, CdkMenuGroup, CdkMenuItem } from '@angular/cdk/menu';
5
- import * as i1$1 from '@radix-ng/primitives/separator';
6
- import { RdxSeparatorRootDirective } from '@radix-ng/primitives/separator';
4
+ import { CdkMenu, CdkMenuGroup, CdkMenuItemCheckbox, CdkMenuItemRadio, CdkMenuItem, CdkMenuTrigger } from '@angular/cdk/menu';
5
+ import { outputFromObservable } from '@angular/core/rxjs-interop';
7
6
 
8
7
  class RdxMenuContentDirective {
9
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: RdxMenuContentDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
10
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.0.5", type: RdxMenuContentDirective, isStandalone: true, selector: "[MenuContent]", hostDirectives: [{ directive: i1.CdkMenu }], ngImport: i0 }); }
8
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: RdxMenuContentDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
9
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.1.4", type: RdxMenuContentDirective, isStandalone: true, selector: "[RdxMenuContent]", host: { attributes: { "role": "menu" }, properties: { "attr.aria-orientation": "\"vertical\"" } }, hostDirectives: [{ directive: i1.CdkMenu }], ngImport: i0 }); }
11
10
  }
12
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: RdxMenuContentDirective, decorators: [{
11
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: RdxMenuContentDirective, decorators: [{
13
12
  type: Directive,
14
13
  args: [{
15
- selector: '[MenuContent]',
16
- standalone: true,
17
- hostDirectives: [CdkMenu]
14
+ selector: '[RdxMenuContent]',
15
+ hostDirectives: [CdkMenu],
16
+ host: {
17
+ role: 'menu',
18
+ '[attr.aria-orientation]': '"vertical"'
19
+ }
18
20
  }]
19
21
  }] });
20
22
 
21
23
  class RdxMenuDirective {
22
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: RdxMenuDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
23
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.0.5", type: RdxMenuDirective, isStandalone: true, selector: "[Menu],[MenuSub]", hostDirectives: [{ directive: i1.CdkMenu }], ngImport: i0 }); }
24
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: RdxMenuDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
25
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.1.4", type: RdxMenuDirective, isStandalone: true, selector: "[RdxMenuRoot],[RdxMenuSub]", hostDirectives: [{ directive: i1.CdkMenu }], ngImport: i0 }); }
24
26
  }
25
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: RdxMenuDirective, decorators: [{
27
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: RdxMenuDirective, decorators: [{
26
28
  type: Directive,
27
29
  args: [{
28
- selector: '[Menu],[MenuSub]',
29
- standalone: true,
30
- host: {},
30
+ selector: '[RdxMenuRoot],[RdxMenuSub]',
31
31
  hostDirectives: [CdkMenu]
32
32
  }]
33
33
  }] });
34
34
 
35
35
  class RdxMenuGroupDirective {
36
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: RdxMenuGroupDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
37
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.0.5", type: RdxMenuGroupDirective, isStandalone: true, selector: "[MenuGroup]", host: { attributes: { "role": "group" } }, hostDirectives: [{ directive: i1.CdkMenuGroup }], ngImport: i0 }); }
36
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: RdxMenuGroupDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
37
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.1.4", type: RdxMenuGroupDirective, isStandalone: true, selector: "[RdxMenuGroup]", host: { attributes: { "role": "group" } }, hostDirectives: [{ directive: i1.CdkMenuGroup }], ngImport: i0 }); }
38
38
  }
39
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: RdxMenuGroupDirective, decorators: [{
39
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: RdxMenuGroupDirective, decorators: [{
40
40
  type: Directive,
41
41
  args: [{
42
- selector: '[MenuGroup]',
43
- standalone: true,
42
+ selector: '[RdxMenuGroup]',
44
43
  hostDirectives: [CdkMenuGroup],
45
44
  host: {
46
45
  role: 'group'
@@ -48,70 +47,255 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.5", ngImpor
48
47
  }]
49
48
  }] });
50
49
 
51
- // type radixProps = {
52
- // disabled: boolean;
53
- // onSelect: () => {};
54
- // };
50
+ function isIndeterminate(checked) {
51
+ return checked === 'indeterminate';
52
+ }
53
+ function getCheckedState(checked) {
54
+ return isIndeterminate(checked) ? 'indeterminate' : checked ? 'checked' : 'unchecked';
55
+ }
56
+
57
+ class RdxMenuItemCheckboxDirective {
58
+ constructor() {
59
+ this.cdkMenuItemCheckbox = inject(CdkMenuItemCheckbox, { host: true });
60
+ this.disabled = input(false, { transform: booleanAttribute });
61
+ this.checked = input(false);
62
+ this.onCheckedChange = outputFromObservable(this.cdkMenuItemCheckbox.triggered);
63
+ this.disabledState = computed(() => this.disabled);
64
+ this.highlightedState = computed(() => this.isFocused());
65
+ this.isFocused = signal(false);
66
+ this.isIndeterminate = isIndeterminate;
67
+ this.getCheckedState = getCheckedState;
68
+ effect(() => {
69
+ if (isIndeterminate(this.checked())) {
70
+ this.cdkMenuItemCheckbox.checked = true;
71
+ }
72
+ else {
73
+ this.cdkMenuItemCheckbox.checked = !this.checked();
74
+ }
75
+ this.cdkMenuItemCheckbox.disabled = this.disabled();
76
+ });
77
+ }
78
+ onFocus() {
79
+ if (!this.disabled()) {
80
+ this.isFocused.set(true);
81
+ }
82
+ }
83
+ onBlur() {
84
+ this.isFocused.set(false);
85
+ }
86
+ onPointerMove(event) {
87
+ if (event.defaultPrevented)
88
+ return;
89
+ if (!(event.pointerType === 'mouse'))
90
+ return;
91
+ if (!this.disabled()) {
92
+ const item = event.currentTarget;
93
+ item?.focus({ preventScroll: true });
94
+ }
95
+ }
96
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: RdxMenuItemCheckboxDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
97
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.1.4", type: RdxMenuItemCheckboxDirective, isStandalone: true, selector: "[RdxMenuItemCheckbox]", inputs: { disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, checked: { classPropertyName: "checked", publicName: "checked", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { onCheckedChange: "onCheckedChange" }, host: { attributes: { "role": "menuitemcheckbox" }, listeners: { "focus": "onFocus()", "blur": "onBlur()", "pointermove": "onPointerMove($event)" }, properties: { "attr.aria-checked": "isIndeterminate(checked()) ? \"mixed\" : checked()", "attr.data-state": "getCheckedState(checked())", "attr.data-highlighted": "highlightedState() ? '' : undefined" } }, hostDirectives: [{ directive: i1.CdkMenuItemCheckbox, outputs: ["cdkMenuItemTriggered", "menuItemTriggered"] }], ngImport: i0 }); }
98
+ }
99
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: RdxMenuItemCheckboxDirective, decorators: [{
100
+ type: Directive,
101
+ args: [{
102
+ selector: '[RdxMenuItemCheckbox]',
103
+ hostDirectives: [
104
+ {
105
+ directive: CdkMenuItemCheckbox,
106
+ outputs: ['cdkMenuItemTriggered: menuItemTriggered']
107
+ }
108
+ ],
109
+ host: {
110
+ role: 'menuitemcheckbox',
111
+ '[attr.aria-checked]': 'isIndeterminate(checked()) ? "mixed" : checked()',
112
+ '[attr.data-state]': 'getCheckedState(checked())',
113
+ '[attr.data-highlighted]': "highlightedState() ? '' : undefined",
114
+ '(focus)': 'onFocus()',
115
+ '(blur)': 'onBlur()',
116
+ '(pointermove)': 'onPointerMove($event)'
117
+ }
118
+ }]
119
+ }], ctorParameters: () => [] });
120
+
121
+ class RdxMenuItemRadioDirective {
122
+ constructor() {
123
+ this.cdkMenuItemRadio = inject(CdkMenuItemRadio, { host: true });
124
+ this.disabled = input(false, { transform: booleanAttribute });
125
+ this.checked = input(false, { transform: booleanAttribute });
126
+ this.onValueChange = outputFromObservable(this.cdkMenuItemRadio.triggered);
127
+ this.disabledState = computed(() => this.disabled());
128
+ this.highlightedState = computed(() => this.isFocused());
129
+ this.isFocused = signal(false);
130
+ this.getCheckedState = getCheckedState;
131
+ effect(() => {
132
+ this.cdkMenuItemRadio.checked = this.checked();
133
+ this.cdkMenuItemRadio.disabled = this.disabled();
134
+ });
135
+ }
136
+ onFocus() {
137
+ if (!this.disabled()) {
138
+ this.isFocused.set(true);
139
+ }
140
+ }
141
+ onBlur() {
142
+ this.isFocused.set(false);
143
+ }
144
+ onPointerMove(event) {
145
+ if (event.defaultPrevented)
146
+ return;
147
+ if (!(event.pointerType === 'mouse'))
148
+ return;
149
+ if (!this.disabled()) {
150
+ const item = event.currentTarget;
151
+ item?.focus({ preventScroll: true });
152
+ }
153
+ }
154
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: RdxMenuItemRadioDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
155
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.1.4", type: RdxMenuItemRadioDirective, isStandalone: true, selector: "[RdxMenuItemRadio]", inputs: { disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, checked: { classPropertyName: "checked", publicName: "checked", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { onValueChange: "onValueChange" }, host: { attributes: { "role": "menuitemradio" }, listeners: { "focus": "onFocus()", "blur": "onBlur()", "pointermove": "onPointerMove($event)" }, properties: { "attr.aria-checked": "checked()", "attr.data-state": "getCheckedState(checked())", "attr.data-highlighted": "highlightedState() ? '' : undefined" } }, hostDirectives: [{ directive: i1.CdkMenuItemRadio, outputs: ["cdkMenuItemTriggered", "menuItemTriggered"] }], ngImport: i0 }); }
156
+ }
157
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: RdxMenuItemRadioDirective, decorators: [{
158
+ type: Directive,
159
+ args: [{
160
+ selector: '[RdxMenuItemRadio]',
161
+ hostDirectives: [
162
+ {
163
+ directive: CdkMenuItemRadio,
164
+ outputs: ['cdkMenuItemTriggered: menuItemTriggered']
165
+ }
166
+ ],
167
+ host: {
168
+ role: 'menuitemradio',
169
+ '[attr.aria-checked]': 'checked()',
170
+ '[attr.data-state]': 'getCheckedState(checked())',
171
+ '[attr.data-highlighted]': "highlightedState() ? '' : undefined",
172
+ '(focus)': 'onFocus()',
173
+ '(blur)': 'onBlur()',
174
+ '(pointermove)': 'onPointerMove($event)'
175
+ }
176
+ }]
177
+ }], ctorParameters: () => [] });
178
+
179
+ class RdxMenuItemIndicatorDirective {
180
+ constructor() {
181
+ this.menuItemRadio = inject(RdxMenuItemRadioDirective, { host: true, optional: true });
182
+ this.menuCheckboxItem = inject(RdxMenuItemCheckboxDirective, { host: true, optional: true });
183
+ this.getCheckedState = getCheckedState;
184
+ }
185
+ get isChecked() {
186
+ if (this.menuItemRadio) {
187
+ return this.menuItemRadio.checked();
188
+ }
189
+ if (this.menuCheckboxItem) {
190
+ return isIndeterminate(this.menuCheckboxItem.checked()) || this.menuCheckboxItem.checked() === true;
191
+ }
192
+ return false;
193
+ }
194
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: RdxMenuItemIndicatorDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
195
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.1.4", type: RdxMenuItemIndicatorDirective, isStandalone: true, selector: "[RdxMenuItemIndicator]", host: { properties: { "attr.data-state": "getCheckedState(isChecked)", "style.display": "isChecked ? \"\" : \"none\"" } }, ngImport: i0 }); }
196
+ }
197
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: RdxMenuItemIndicatorDirective, decorators: [{
198
+ type: Directive,
199
+ args: [{
200
+ selector: '[RdxMenuItemIndicator]',
201
+ host: {
202
+ '[attr.data-state]': 'getCheckedState(isChecked)',
203
+ '[style.display]': 'isChecked ? "" : "none"'
204
+ }
205
+ }]
206
+ }] });
207
+
55
208
  class RdxMenuItemDirective {
56
209
  constructor() {
57
210
  this.cdkMenuItem = inject(CdkMenuItem, { host: true });
58
- // When true, prevents the user from interacting with the item.
59
- this.disabled = input(false, {
60
- transform: booleanAttribute,
61
- alias: 'rdxDisabled'
62
- });
211
+ this.disabled = input(false, { transform: booleanAttribute });
212
+ this.onSelect = outputFromObservable(this.cdkMenuItem.triggered);
213
+ this.isFocused = signal(false);
63
214
  this.disabledState = computed(() => this.disabled());
64
- // Event handler called when the user selects an item (via mouse or keyboard).
65
- this.onSelect = this.cdkMenuItem.triggered;
215
+ this.isOpenState = signal(false);
216
+ this.highlightedState = computed(() => this.isFocused());
66
217
  effect(() => {
67
218
  this.cdkMenuItem.disabled = this.disabled();
219
+ this.isOpenState.set(this.cdkMenuItem.isMenuOpen());
68
220
  });
69
221
  }
70
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: RdxMenuItemDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
71
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.0.5", type: RdxMenuItemDirective, isStandalone: true, selector: "[MenuItem]", inputs: { disabled: { classPropertyName: "disabled", publicName: "rdxDisabled", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { onSelect: "onSelect" }, host: { attributes: { "role": "menuitem", "type": "button", "tabindex": "0" }, properties: { "attr.data-orientation": "'horizontal'", "attr.data-disabled": "disabledState() ? '' : undefined", "disabled": "disabledState()" } }, hostDirectives: [{ directive: i1.CdkMenuItem }], ngImport: i0 }); }
222
+ onFocus() {
223
+ if (!this.disabled()) {
224
+ this.isFocused.set(true);
225
+ }
226
+ }
227
+ onBlur() {
228
+ this.isFocused.set(false);
229
+ }
230
+ onPointerMove(event) {
231
+ if (event.defaultPrevented)
232
+ return;
233
+ if (!(event.pointerType === 'mouse'))
234
+ return;
235
+ if (!this.disabled()) {
236
+ const item = event.currentTarget;
237
+ item?.focus({ preventScroll: true });
238
+ }
239
+ }
240
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: RdxMenuItemDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
241
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.1.4", type: RdxMenuItemDirective, isStandalone: true, selector: "[RdxMenuItem]", inputs: { disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { onSelect: "onSelect" }, host: { attributes: { "role": "menuitem", "tabindex": "-1" }, listeners: { "focus": "onFocus()", "blur": "onBlur()", "pointermove": "onPointerMove($event)" }, properties: { "attr.data-orientation": "'horizontal'", "attr.data-state": "isOpenState()", "attr.aria-disabled": "disabledState() ? '' : undefined", "attr.data-disabled": "disabledState() ? '' : undefined", "attr.data-highlighted": "highlightedState() ? '' : undefined" } }, hostDirectives: [{ directive: i1.CdkMenuItem, outputs: ["cdkMenuItemTriggered", "menuItemTriggered"] }], ngImport: i0 }); }
72
242
  }
73
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: RdxMenuItemDirective, decorators: [{
243
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: RdxMenuItemDirective, decorators: [{
74
244
  type: Directive,
75
245
  args: [{
76
- selector: '[MenuItem]',
77
- standalone: true,
78
- hostDirectives: [CdkMenuItem],
246
+ selector: '[RdxMenuItem]',
247
+ hostDirectives: [
248
+ {
249
+ directive: CdkMenuItem,
250
+ outputs: ['cdkMenuItemTriggered: menuItemTriggered']
251
+ }
252
+ ],
79
253
  host: {
80
254
  role: 'menuitem',
81
- type: 'button',
82
- tabindex: '0',
255
+ tabindex: '-1',
83
256
  '[attr.data-orientation]': "'horizontal'",
84
- //'[attr.data-highlighted]': "",
257
+ '[attr.data-state]': 'isOpenState()',
258
+ '[attr.aria-disabled]': "disabledState() ? '' : undefined",
85
259
  '[attr.data-disabled]': "disabledState() ? '' : undefined",
86
- '[disabled]': 'disabledState()'
260
+ '[attr.data-highlighted]': "highlightedState() ? '' : undefined",
261
+ '(focus)': 'onFocus()',
262
+ '(blur)': 'onBlur()',
263
+ '(pointermove)': 'onPointerMove($event)'
87
264
  }
88
265
  }]
89
- }], ctorParameters: () => [], propDecorators: { onSelect: [{
90
- type: Output
91
- }] } });
266
+ }], ctorParameters: () => [] });
92
267
 
93
268
  class RdxMenuLabelDirective {
94
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: RdxMenuLabelDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
95
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.0.5", type: RdxMenuLabelDirective, isStandalone: true, selector: "div[MenuLabel]", ngImport: i0 }); }
269
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: RdxMenuLabelDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
270
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.1.4", type: RdxMenuLabelDirective, isStandalone: true, selector: "[RdxMenuLabel]", ngImport: i0 }); }
271
+ }
272
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: RdxMenuLabelDirective, decorators: [{
273
+ type: Directive,
274
+ args: [{
275
+ selector: '[RdxMenuLabel]'
276
+ }]
277
+ }] });
278
+
279
+ class RdxMenuRadioGroupDirective {
280
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: RdxMenuRadioGroupDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
281
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.1.4", type: RdxMenuRadioGroupDirective, isStandalone: true, selector: "[RdxMenuRadioGroup]", hostDirectives: [{ directive: i1.CdkMenuGroup }], ngImport: i0 }); }
96
282
  }
97
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: RdxMenuLabelDirective, decorators: [{
283
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: RdxMenuRadioGroupDirective, decorators: [{
98
284
  type: Directive,
99
285
  args: [{
100
- selector: 'div[MenuLabel]',
101
- standalone: true
286
+ selector: '[RdxMenuRadioGroup]',
287
+ hostDirectives: [CdkMenuGroup]
102
288
  }]
103
289
  }] });
104
290
 
105
291
  class RdxMenuSeparatorDirective {
106
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: RdxMenuSeparatorDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
107
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.0.5", type: RdxMenuSeparatorDirective, isStandalone: true, selector: "[MenuSeparator]", host: { attributes: { "role": "separator" }, properties: { "attr.aria-orientation": "'horizontal'" } }, hostDirectives: [{ directive: i1$1.RdxSeparatorRootDirective }], ngImport: i0 }); }
292
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: RdxMenuSeparatorDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
293
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.1.4", type: RdxMenuSeparatorDirective, isStandalone: true, selector: "[RdxMenuSeparator]", host: { attributes: { "role": "separator" }, properties: { "attr.aria-orientation": "'horizontal'" } }, ngImport: i0 }); }
108
294
  }
109
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: RdxMenuSeparatorDirective, decorators: [{
295
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: RdxMenuSeparatorDirective, decorators: [{
110
296
  type: Directive,
111
297
  args: [{
112
- selector: '[MenuSeparator]',
113
- standalone: true,
114
- hostDirectives: [RdxSeparatorRootDirective],
298
+ selector: '[RdxMenuSeparator]',
115
299
  host: {
116
300
  role: 'separator',
117
301
  '[attr.aria-orientation]': "'horizontal'"
@@ -119,30 +303,213 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.5", ngImpor
119
303
  }]
120
304
  }] });
121
305
 
306
+ class RdxMenuTriggerDirective {
307
+ computePositions() {
308
+ if (this.align() || this.sideOffset() || this.alignOffset() || this.side()) {
309
+ this.enablePositions = true;
310
+ }
311
+ const side = this.side() || 'bottom';
312
+ const align = this.align() || 'center';
313
+ const sideOffset = this.sideOffset() || 0;
314
+ const alignOffset = this.alignOffset() || 0;
315
+ let originX = 'center';
316
+ let originY = 'center';
317
+ let overlayX = 'center';
318
+ let overlayY = 'center';
319
+ let offsetX = 0;
320
+ let offsetY = 0;
321
+ switch (side) {
322
+ case 'top':
323
+ originY = 'top';
324
+ overlayY = 'bottom';
325
+ offsetY = -sideOffset;
326
+ break;
327
+ case 'bottom':
328
+ originY = 'bottom';
329
+ overlayY = 'top';
330
+ offsetY = sideOffset;
331
+ break;
332
+ case 'left':
333
+ originX = 'start';
334
+ overlayX = 'end';
335
+ offsetX = -sideOffset;
336
+ break;
337
+ case 'right':
338
+ originX = 'end';
339
+ overlayX = 'start';
340
+ offsetX = sideOffset;
341
+ break;
342
+ }
343
+ switch (align) {
344
+ case 'start':
345
+ if (side === 'top' || side === 'bottom') {
346
+ originX = 'start';
347
+ overlayX = 'start';
348
+ offsetX = alignOffset;
349
+ }
350
+ else {
351
+ originY = 'top';
352
+ overlayY = 'top';
353
+ offsetY = alignOffset;
354
+ }
355
+ break;
356
+ case 'end':
357
+ if (side === 'top' || side === 'bottom') {
358
+ originX = 'end';
359
+ overlayX = 'end';
360
+ offsetX = -alignOffset;
361
+ }
362
+ else {
363
+ originY = 'bottom';
364
+ overlayY = 'bottom';
365
+ offsetY = -alignOffset;
366
+ }
367
+ break;
368
+ case 'center':
369
+ default:
370
+ if (side === 'top' || side === 'bottom') {
371
+ originX = 'center';
372
+ overlayX = 'center';
373
+ }
374
+ else {
375
+ originY = 'center';
376
+ overlayY = 'center';
377
+ }
378
+ break;
379
+ }
380
+ return {
381
+ originX,
382
+ originY,
383
+ overlayX,
384
+ overlayY,
385
+ offsetX,
386
+ offsetY
387
+ };
388
+ }
389
+ constructor() {
390
+ this.cdkTrigger = inject(CdkMenuTrigger, { host: true });
391
+ this.menuTriggerFor = input.required();
392
+ /**
393
+ * @description The preferred side of the trigger to render against when open. Will be reversed when collisions occur and avoidCollisions is enabled.
394
+ */
395
+ this.side = input();
396
+ this.align = input();
397
+ /**
398
+ * @description The distance in pixels from the trigger.
399
+ */
400
+ this.sideOffset = input(NaN, {
401
+ transform: numberAttribute
402
+ });
403
+ /**
404
+ * @description An offset in pixels from the "start" or "end" alignment options.
405
+ */
406
+ this.alignOffset = input(NaN, {
407
+ transform: numberAttribute
408
+ });
409
+ this.disabled = input(false, {
410
+ transform: booleanAttribute
411
+ });
412
+ this.enablePositions = false;
413
+ // TODO
414
+ this.positions = computed(() => this.computePositions());
415
+ this.onMenuPositionEffect();
416
+ }
417
+ /** @ignore */
418
+ onPointerDown($event) {
419
+ // only call handler if it's the left button (mousedown gets triggered by all mouse buttons)
420
+ // but not when the control key is pressed (avoiding MacOS right click)
421
+ if (!this.disabled() && $event.button === 0 && !$event.ctrlKey) {
422
+ /* empty */
423
+ if (!this.cdkTrigger.isOpen()) {
424
+ // prevent trigger focusing when opening
425
+ // this allows the content to be given focus without competition
426
+ $event.preventDefault();
427
+ }
428
+ }
429
+ }
430
+ onMenuPositionEffect() {
431
+ effect(() => {
432
+ const positions = this.positions();
433
+ untracked(() => {
434
+ if (this.enablePositions) {
435
+ this.setMenuPositions([positions]);
436
+ }
437
+ });
438
+ });
439
+ }
440
+ setMenuPositions(positions) {
441
+ const prevMenuPosition = this.cdkTrigger.menuPosition;
442
+ this.cdkTrigger.menuPosition = positions;
443
+ this.fireNgOnChanges('menuPosition', this.cdkTrigger.menuPosition, prevMenuPosition);
444
+ }
445
+ fireNgOnChanges(input, currentValue, previousValue, firstChange = false) {
446
+ this.cdkTrigger.ngOnChanges({
447
+ [input]: new SimpleChange(previousValue, currentValue, firstChange)
448
+ });
449
+ }
450
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: RdxMenuTriggerDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
451
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.1.4", type: RdxMenuTriggerDirective, isStandalone: true, selector: "[RdxMenuTrigger]", inputs: { menuTriggerFor: { classPropertyName: "menuTriggerFor", publicName: "menuTriggerFor", isSignal: true, isRequired: true, transformFunction: null }, side: { classPropertyName: "side", publicName: "side", isSignal: true, isRequired: false, transformFunction: null }, align: { classPropertyName: "align", publicName: "align", isSignal: true, isRequired: false, transformFunction: null }, sideOffset: { classPropertyName: "sideOffset", publicName: "sideOffset", isSignal: true, isRequired: false, transformFunction: null }, alignOffset: { classPropertyName: "alignOffset", publicName: "alignOffset", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "menuitem" }, listeners: { "pointerdown": "onPointerDown($event)" }, properties: { "attr.aria-haspopup": "'menu'", "attr.aria-expanded": "cdkTrigger.isOpen()", "attr.data-state": "cdkTrigger.isOpen() ? 'open': 'closed'", "attr.data-disabled": "disabled() ? '' : undefined" } }, hostDirectives: [{ directive: i1.CdkMenuTrigger, inputs: ["cdkMenuTriggerFor", "menuTriggerFor", "cdkMenuPosition", "menuPosition"] }], ngImport: i0 }); }
452
+ }
453
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: RdxMenuTriggerDirective, decorators: [{
454
+ type: Directive,
455
+ args: [{
456
+ selector: '[RdxMenuTrigger]',
457
+ hostDirectives: [
458
+ {
459
+ directive: CdkMenuTrigger,
460
+ inputs: ['cdkMenuTriggerFor: menuTriggerFor', 'cdkMenuPosition: menuPosition']
461
+ }
462
+ ],
463
+ host: {
464
+ role: 'menuitem',
465
+ '[attr.aria-haspopup]': "'menu'",
466
+ '[attr.aria-expanded]': 'cdkTrigger.isOpen()',
467
+ '[attr.data-state]': "cdkTrigger.isOpen() ? 'open': 'closed'",
468
+ '[attr.data-disabled]': "disabled() ? '' : undefined",
469
+ '(pointerdown)': 'onPointerDown($event)'
470
+ }
471
+ }]
472
+ }], ctorParameters: () => [] });
473
+
122
474
  const menuImports = [
123
475
  RdxMenuDirective,
476
+ RdxMenuItemCheckboxDirective,
477
+ RdxMenuItemRadioDirective,
478
+ RdxMenuItemIndicatorDirective,
479
+ RdxMenuTriggerDirective,
124
480
  RdxMenuGroupDirective,
481
+ RdxMenuRadioGroupDirective,
125
482
  RdxMenuItemDirective,
126
483
  RdxMenuSeparatorDirective,
127
484
  RdxMenuContentDirective,
128
485
  RdxMenuLabelDirective
129
486
  ];
130
- class MenuModule {
131
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: MenuModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
132
- static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.0.5", ngImport: i0, type: MenuModule, imports: [RdxMenuDirective,
487
+ class RdxMenuModule {
488
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: RdxMenuModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
489
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.1.4", ngImport: i0, type: RdxMenuModule, imports: [RdxMenuDirective,
490
+ RdxMenuItemCheckboxDirective,
491
+ RdxMenuItemRadioDirective,
492
+ RdxMenuItemIndicatorDirective,
493
+ RdxMenuTriggerDirective,
133
494
  RdxMenuGroupDirective,
495
+ RdxMenuRadioGroupDirective,
134
496
  RdxMenuItemDirective,
135
497
  RdxMenuSeparatorDirective,
136
498
  RdxMenuContentDirective,
137
499
  RdxMenuLabelDirective], exports: [RdxMenuDirective,
500
+ RdxMenuItemCheckboxDirective,
501
+ RdxMenuItemRadioDirective,
502
+ RdxMenuItemIndicatorDirective,
503
+ RdxMenuTriggerDirective,
138
504
  RdxMenuGroupDirective,
505
+ RdxMenuRadioGroupDirective,
139
506
  RdxMenuItemDirective,
140
507
  RdxMenuSeparatorDirective,
141
508
  RdxMenuContentDirective,
142
509
  RdxMenuLabelDirective] }); }
143
- static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: MenuModule }); }
510
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: RdxMenuModule }); }
144
511
  }
145
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: MenuModule, decorators: [{
512
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: RdxMenuModule, decorators: [{
146
513
  type: NgModule,
147
514
  args: [{
148
515
  imports: [...menuImports],
@@ -154,5 +521,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.5", ngImpor
154
521
  * Generated bundle index. Do not edit.
155
522
  */
156
523
 
157
- export { MenuModule, RdxMenuContentDirective, RdxMenuDirective, RdxMenuGroupDirective, RdxMenuItemDirective, RdxMenuLabelDirective, RdxMenuSeparatorDirective };
524
+ export { RdxMenuContentDirective, RdxMenuDirective, RdxMenuGroupDirective, RdxMenuItemCheckboxDirective, RdxMenuItemDirective, RdxMenuItemIndicatorDirective, RdxMenuItemRadioDirective, RdxMenuLabelDirective, RdxMenuModule, RdxMenuRadioGroupDirective, RdxMenuSeparatorDirective, RdxMenuTriggerDirective };
158
525
  //# sourceMappingURL=radix-ng-primitives-menu.mjs.map