@radix-ng/primitives 0.50.0 → 1.0.0-beta.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.
- package/collection/README.md +1 -0
- package/fesm2022/radix-ng-primitives-accordion.mjs +134 -66
- package/fesm2022/radix-ng-primitives-accordion.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-alert-dialog.mjs +224 -132
- package/fesm2022/radix-ng-primitives-alert-dialog.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-arrow.mjs +26 -10
- package/fesm2022/radix-ng-primitives-arrow.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-aspect-ratio.mjs +6 -6
- package/fesm2022/radix-ng-primitives-aspect-ratio.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-avatar.mjs +68 -75
- package/fesm2022/radix-ng-primitives-avatar.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-button.mjs +123 -0
- package/fesm2022/radix-ng-primitives-button.mjs.map +1 -0
- package/fesm2022/radix-ng-primitives-calendar.mjs +104 -103
- package/fesm2022/radix-ng-primitives-calendar.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-checkbox.mjs +414 -80
- package/fesm2022/radix-ng-primitives-checkbox.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-collapsible.mjs +193 -92
- package/fesm2022/radix-ng-primitives-collapsible.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-collection.mjs +72 -0
- package/fesm2022/radix-ng-primitives-collection.mjs.map +1 -0
- package/fesm2022/radix-ng-primitives-config.mjs +5 -5
- package/fesm2022/radix-ng-primitives-config.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-context-menu.mjs +143 -427
- package/fesm2022/radix-ng-primitives-context-menu.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-core.mjs +757 -757
- package/fesm2022/radix-ng-primitives-core.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-cropper.mjs +55 -53
- package/fesm2022/radix-ng-primitives-cropper.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-date-field.mjs +93 -86
- package/fesm2022/radix-ng-primitives-date-field.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-dialog.mjs +658 -330
- package/fesm2022/radix-ng-primitives-dialog.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-dismissable-layer.mjs +98 -76
- package/fesm2022/radix-ng-primitives-dismissable-layer.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-drawer.mjs +1059 -0
- package/fesm2022/radix-ng-primitives-drawer.mjs.map +1 -0
- package/fesm2022/radix-ng-primitives-editable.mjs +20 -20
- package/fesm2022/radix-ng-primitives-editable.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-field.mjs +363 -0
- package/fesm2022/radix-ng-primitives-field.mjs.map +1 -0
- package/fesm2022/radix-ng-primitives-fieldset.mjs +79 -0
- package/fesm2022/radix-ng-primitives-fieldset.mjs.map +1 -0
- package/fesm2022/radix-ng-primitives-focus-guards.mjs +3 -3
- package/fesm2022/radix-ng-primitives-focus-guards.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-focus-scope.mjs +29 -14
- package/fesm2022/radix-ng-primitives-focus-scope.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-input.mjs +172 -0
- package/fesm2022/radix-ng-primitives-input.mjs.map +1 -0
- package/fesm2022/radix-ng-primitives-label.mjs +11 -11
- package/fesm2022/radix-ng-primitives-label.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-menu.mjs +1484 -353
- package/fesm2022/radix-ng-primitives-menu.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-menubar.mjs +290 -162
- package/fesm2022/radix-ng-primitives-menubar.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-meter.mjs +271 -0
- package/fesm2022/radix-ng-primitives-meter.mjs.map +1 -0
- package/fesm2022/radix-ng-primitives-navigation-menu.mjs +1060 -1553
- package/fesm2022/radix-ng-primitives-navigation-menu.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-number-field.mjs +1102 -366
- package/fesm2022/radix-ng-primitives-number-field.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-pagination.mjs +51 -51
- package/fesm2022/radix-ng-primitives-pagination.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-popover.mjs +980 -995
- package/fesm2022/radix-ng-primitives-popover.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-popper.mjs +137 -82
- package/fesm2022/radix-ng-primitives-popper.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-portal.mjs +40 -16
- package/fesm2022/radix-ng-primitives-portal.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-presence.mjs +134 -246
- package/fesm2022/radix-ng-primitives-presence.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-preview-card.mjs +997 -0
- package/fesm2022/radix-ng-primitives-preview-card.mjs.map +1 -0
- package/fesm2022/radix-ng-primitives-progress.mjs +231 -92
- package/fesm2022/radix-ng-primitives-progress.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-radio.mjs +211 -70
- package/fesm2022/radix-ng-primitives-radio.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-roving-focus.mjs +127 -77
- package/fesm2022/radix-ng-primitives-roving-focus.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-select.mjs +791 -511
- package/fesm2022/radix-ng-primitives-select.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-separator.mjs +16 -45
- package/fesm2022/radix-ng-primitives-separator.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-slider.mjs +976 -720
- package/fesm2022/radix-ng-primitives-slider.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-stepper.mjs +69 -71
- package/fesm2022/radix-ng-primitives-stepper.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-switch.mjs +128 -124
- package/fesm2022/radix-ng-primitives-switch.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-tabs.mjs +388 -115
- package/fesm2022/radix-ng-primitives-tabs.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-time-field.mjs +111 -117
- package/fesm2022/radix-ng-primitives-time-field.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-toggle-group.mjs +122 -248
- package/fesm2022/radix-ng-primitives-toggle-group.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-toggle.mjs +99 -62
- package/fesm2022/radix-ng-primitives-toggle.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-toolbar.mjs +307 -94
- package/fesm2022/radix-ng-primitives-toolbar.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-tooltip.mjs +690 -1079
- package/fesm2022/radix-ng-primitives-tooltip.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-visually-hidden.mjs +46 -87
- package/fesm2022/radix-ng-primitives-visually-hidden.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives.mjs.map +1 -1
- package/meter/README.md +3 -0
- package/navigation-menu/README.md +2 -1
- package/package.json +85 -63
- package/portal/README.md +2 -0
- package/preview-card/README.md +3 -0
- package/schematics/collection.json +1 -0
- package/schematics/ng-add/index.d.ts +3 -2
- package/schematics/ng-add/index.js +62 -31
- package/schematics/ng-add/index.js.map +1 -1
- package/schematics/ng-add/package-config.d.ts +4 -2
- package/schematics/ng-add/package-config.js +10 -2
- package/schematics/ng-add/package-config.js.map +1 -1
- package/schematics/ng-add/schema.d.ts +3 -0
- package/schematics/ng-add/schema.js +3 -0
- package/schematics/ng-add/schema.js.map +1 -0
- package/schematics/ng-add/schema.json +14 -0
- package/select/README.md +2 -0
- package/{accordion/index.d.ts → types/radix-ng-primitives-accordion.d.ts} +102 -67
- package/types/radix-ng-primitives-alert-dialog.d.ts +114 -0
- package/{arrow/index.d.ts → types/radix-ng-primitives-arrow.d.ts} +1 -1
- package/{aspect-ratio/index.d.ts → types/radix-ng-primitives-aspect-ratio.d.ts} +1 -1
- package/{avatar/index.d.ts → types/radix-ng-primitives-avatar.d.ts} +7 -11
- package/types/radix-ng-primitives-button.d.ts +73 -0
- package/{calendar/index.d.ts → types/radix-ng-primitives-calendar.d.ts} +2 -3
- package/types/radix-ng-primitives-checkbox.d.ts +337 -0
- package/types/radix-ng-primitives-collapsible.d.ts +159 -0
- package/types/radix-ng-primitives-collection.d.ts +44 -0
- package/{config/index.d.ts → types/radix-ng-primitives-config.d.ts} +1 -1
- package/types/radix-ng-primitives-context-menu.d.ts +73 -0
- package/{core/index.d.ts → types/radix-ng-primitives-core.d.ts} +311 -236
- package/{cropper/index.d.ts → types/radix-ng-primitives-cropper.d.ts} +6 -5
- package/{date-field/index.d.ts → types/radix-ng-primitives-date-field.d.ts} +42 -27
- package/types/radix-ng-primitives-dialog.d.ts +323 -0
- package/{dismissable-layer/index.d.ts → types/radix-ng-primitives-dismissable-layer.d.ts} +15 -7
- package/types/radix-ng-primitives-drawer.d.ts +448 -0
- package/{editable/index.d.ts → types/radix-ng-primitives-editable.d.ts} +1 -1
- package/types/radix-ng-primitives-field.d.ts +373 -0
- package/types/radix-ng-primitives-fieldset.d.ts +48 -0
- package/{focus-scope/index.d.ts → types/radix-ng-primitives-focus-scope.d.ts} +13 -5
- package/types/radix-ng-primitives-input.d.ts +87 -0
- package/{label/index.d.ts → types/radix-ng-primitives-label.d.ts} +0 -1
- package/types/radix-ng-primitives-menu.d.ts +612 -0
- package/types/radix-ng-primitives-menubar.d.ts +66 -0
- package/types/radix-ng-primitives-meter.d.ts +193 -0
- package/types/radix-ng-primitives-navigation-menu.d.ts +488 -0
- package/types/radix-ng-primitives-number-field.d.ts +464 -0
- package/{pagination/index.d.ts → types/radix-ng-primitives-pagination.d.ts} +2 -2
- package/types/radix-ng-primitives-popover.d.ts +416 -0
- package/{popper/index.d.ts → types/radix-ng-primitives-popper.d.ts} +50 -9
- package/types/radix-ng-primitives-portal.d.ts +30 -0
- package/types/radix-ng-primitives-presence.d.ts +55 -0
- package/types/radix-ng-primitives-preview-card.d.ts +359 -0
- package/types/radix-ng-primitives-progress.d.ts +206 -0
- package/{radio/index.d.ts → types/radix-ng-primitives-radio.d.ts} +56 -26
- package/{roving-focus/index.d.ts → types/radix-ng-primitives-roving-focus.d.ts} +38 -27
- package/types/radix-ng-primitives-select.d.ts +512 -0
- package/types/radix-ng-primitives-separator.d.ts +38 -0
- package/types/radix-ng-primitives-slider.d.ts +377 -0
- package/{stepper/index.d.ts → types/radix-ng-primitives-stepper.d.ts} +21 -22
- package/types/radix-ng-primitives-switch.d.ts +121 -0
- package/types/radix-ng-primitives-tabs.d.ts +247 -0
- package/{time-field/index.d.ts → types/radix-ng-primitives-time-field.d.ts} +46 -31
- package/types/radix-ng-primitives-toggle-group.d.ts +116 -0
- package/types/radix-ng-primitives-toggle.d.ts +65 -0
- package/types/radix-ng-primitives-toolbar.d.ts +180 -0
- package/types/radix-ng-primitives-tooltip.d.ts +395 -0
- package/{visually-hidden/index.d.ts → types/radix-ng-primitives-visually-hidden.d.ts} +19 -19
- package/alert-dialog/index.d.ts +0 -57
- package/checkbox/index.d.ts +0 -164
- package/collapsible/index.d.ts +0 -85
- package/context-menu/index.d.ts +0 -129
- package/dialog/index.d.ts +0 -205
- package/dropdown-menu/README.md +0 -1
- package/dropdown-menu/index.d.ts +0 -171
- package/fesm2022/radix-ng-primitives-dropdown-menu.mjs +0 -583
- package/fesm2022/radix-ng-primitives-dropdown-menu.mjs.map +0 -1
- package/fesm2022/radix-ng-primitives-hover-card.mjs +0 -1246
- package/fesm2022/radix-ng-primitives-hover-card.mjs.map +0 -1
- package/fesm2022/radix-ng-primitives-tooltip2.mjs +0 -740
- package/fesm2022/radix-ng-primitives-tooltip2.mjs.map +0 -1
- package/hover-card/README.md +0 -3
- package/hover-card/index.d.ts +0 -472
- package/menu/index.d.ts +0 -139
- package/menubar/index.d.ts +0 -56
- package/navigation-menu/index.d.ts +0 -405
- package/number-field/index.d.ts +0 -203
- package/popover/index.d.ts +0 -403
- package/portal/index.d.ts +0 -22
- package/presence/index.d.ts +0 -103
- package/progress/index.d.ts +0 -79
- package/select/index.d.ts +0 -214
- package/separator/index.d.ts +0 -63
- package/slider/index.d.ts +0 -263
- package/switch/index.d.ts +0 -105
- package/tabs/index.d.ts +0 -112
- package/toggle/index.d.ts +0 -75
- package/toggle-group/index.d.ts +0 -194
- package/toolbar/index.d.ts +0 -55
- package/tooltip/index.d.ts +0 -433
- package/tooltip2/README.md +0 -3
- package/tooltip2/index.d.ts +0 -325
- /package/{focus-guards/index.d.ts → types/radix-ng-primitives-focus-guards.d.ts} +0 -0
- /package/{index.d.ts → types/radix-ng-primitives.d.ts} +0 -0
|
@@ -1,176 +1,304 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { Directive, NgModule } from '@angular/core';
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import * as i1$1 from '@angular/cdk/menu';
|
|
6
|
-
import { CdkMenuGroup, CdkMenuBar } from '@angular/cdk/menu';
|
|
2
|
+
import { inject, contentChildren, input, booleanAttribute, signal, computed, effect, Directive, NgModule } from '@angular/core';
|
|
3
|
+
import { createContext } from '@radix-ng/primitives/core';
|
|
4
|
+
import { RdxMenuRoot } from '@radix-ng/primitives/menu';
|
|
7
5
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
const [injectRdxMenubarContext, provideRdxMenubarContext] = createContext('RdxMenubarContext');
|
|
7
|
+
const contextFactory = () => buildContext(inject(RdxMenubarRoot));
|
|
8
|
+
function buildContext(root) {
|
|
9
|
+
return {
|
|
10
|
+
activeId: root.activeId.asReadonly(),
|
|
11
|
+
isAnyOpen: root.isAnyOpen,
|
|
12
|
+
disabled: root.disabled,
|
|
13
|
+
orientation: root.orientation,
|
|
14
|
+
registerItem: (id, el, open, close, disabled) => root.registerItem(id, el, open, close, disabled),
|
|
15
|
+
activateItem: (id) => root.activateItem(id),
|
|
16
|
+
deactivateAll: () => root.deactivateAll(),
|
|
17
|
+
focusAdjacent: (id, offset, open) => root.focusAdjacent(id, offset, open),
|
|
18
|
+
focusBoundary: (boundary, open) => root.focusBoundary(boundary, open)
|
|
19
|
+
};
|
|
11
20
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
21
|
+
let nextMenubarItemId = 0;
|
|
22
|
+
/**
|
|
23
|
+
* Container for a horizontal application menu bar.
|
|
24
|
+
* Coordinates open/close state across multiple menus and provides arrow-key navigation.
|
|
25
|
+
*/
|
|
26
|
+
class RdxMenubarRoot {
|
|
27
|
+
constructor() {
|
|
28
|
+
this.menuRoots = contentChildren(RdxMenuRoot, ...(ngDevMode ? [{ debugName: "menuRoots" }] : /* istanbul ignore next */ []));
|
|
29
|
+
this.ids = new WeakMap();
|
|
30
|
+
this.items = [];
|
|
31
|
+
/** Whether every menubar trigger is disabled. */
|
|
32
|
+
this.disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
33
|
+
/** Whether arrow-key navigation wraps at the first/last trigger. */
|
|
34
|
+
this.loopFocus = input(true, { ...(ngDevMode ? { debugName: "loopFocus" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
35
|
+
/** The menubar orientation. */
|
|
36
|
+
this.orientation = input('horizontal', ...(ngDevMode ? [{ debugName: "orientation" }] : /* istanbul ignore next */ []));
|
|
37
|
+
this.activeId = signal(null, ...(ngDevMode ? [{ debugName: "activeId" }] : /* istanbul ignore next */ []));
|
|
38
|
+
this.isAnyOpen = computed(() => this.activeId() !== null, ...(ngDevMode ? [{ debugName: "isAnyOpen" }] : /* istanbul ignore next */ []));
|
|
39
|
+
effect((onCleanup) => {
|
|
40
|
+
const roots = this.menuRoots();
|
|
41
|
+
const registered = [];
|
|
42
|
+
roots.forEach((root) => {
|
|
43
|
+
const trigger = root.trigger();
|
|
44
|
+
if (!trigger || trigger.closest('[rdxMenuPopup]')) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
registered.push(this.registerMenuRoot(root, trigger));
|
|
48
|
+
});
|
|
49
|
+
onCleanup(() => {
|
|
50
|
+
registered.forEach((cleanup) => cleanup());
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
effect(() => {
|
|
54
|
+
const activeId = this.activeId();
|
|
55
|
+
if (!activeId) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
this.menuRoots().forEach((root) => {
|
|
59
|
+
const trigger = root.trigger();
|
|
60
|
+
if (!trigger || trigger.closest('[rdxMenuPopup]')) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
if (this.idFor(root) === activeId && !root.open()) {
|
|
64
|
+
this.deactivateAll();
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
registerItem(id, el, open, close, disabled) {
|
|
70
|
+
this.items.push({ id, el, root: undefined, open, close, disabled });
|
|
71
|
+
// Keep items in DOM order
|
|
72
|
+
this.items.sort((a, b) => (a.el.compareDocumentPosition(b.el) & 4 ? -1 : 1));
|
|
73
|
+
return () => {
|
|
74
|
+
this.items = this.items.filter((item) => item.id !== id);
|
|
75
|
+
if (this.activeId() === id)
|
|
76
|
+
this.activeId.set(null);
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
activateItem(id) {
|
|
80
|
+
if (this.disabled()) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
// Close every other open menu
|
|
84
|
+
this.items.forEach((item) => {
|
|
85
|
+
if (item.id !== id)
|
|
86
|
+
item.close();
|
|
87
|
+
});
|
|
88
|
+
this.activeId.set(id);
|
|
89
|
+
}
|
|
90
|
+
deactivateAll() {
|
|
91
|
+
this.activeId.set(null);
|
|
92
|
+
}
|
|
93
|
+
focusBoundary(boundary, openOnMove) {
|
|
94
|
+
const enabled = this.enabledItems();
|
|
95
|
+
this.focusItem(boundary === 'first' ? enabled[0] : enabled[enabled.length - 1], openOnMove);
|
|
96
|
+
}
|
|
97
|
+
generateId() {
|
|
98
|
+
return `rdx-menubar-item-${nextMenubarItemId++}`;
|
|
99
|
+
}
|
|
100
|
+
idFor(root) {
|
|
101
|
+
let id = this.ids.get(root);
|
|
102
|
+
if (!id) {
|
|
103
|
+
id = this.generateId();
|
|
104
|
+
this.ids.set(root, id);
|
|
105
|
+
}
|
|
106
|
+
return id;
|
|
107
|
+
}
|
|
108
|
+
registerMenuRoot(root, trigger) {
|
|
109
|
+
const id = this.idFor(root);
|
|
110
|
+
const unregisterPopupArrowNavigation = root.registerPopupArrowNavigationHandler((offset) => {
|
|
111
|
+
if (this.disabled()) {
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
this.focusAdjacent(id, offset, true);
|
|
115
|
+
return true;
|
|
116
|
+
});
|
|
117
|
+
const unregisterTriggerInteraction = root.registerTriggerInteractionHandler((interaction) => this.handleTriggerInteraction(id, root, trigger, interaction));
|
|
118
|
+
const unregisterItem = this.registerResolvedItem(id, trigger, root);
|
|
119
|
+
return () => {
|
|
120
|
+
unregisterItem();
|
|
121
|
+
unregisterTriggerInteraction();
|
|
122
|
+
unregisterPopupArrowNavigation();
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
registerResolvedItem(id, el, root) {
|
|
126
|
+
this.items.push({
|
|
127
|
+
id,
|
|
128
|
+
el,
|
|
129
|
+
root,
|
|
130
|
+
open: () => root.show(false),
|
|
131
|
+
close: () => root.close(),
|
|
132
|
+
disabled: () => this.disabled() || root.disabled() || el.hasAttribute('disabled')
|
|
133
|
+
});
|
|
134
|
+
this.items.sort((a, b) => (a.el.compareDocumentPosition(b.el) & 4 ? -1 : 1));
|
|
135
|
+
this.updateTriggerTabStops();
|
|
136
|
+
return () => {
|
|
137
|
+
this.items = this.items.filter((item) => item.id !== id);
|
|
138
|
+
if (this.activeId() === id)
|
|
139
|
+
this.activeId.set(null);
|
|
140
|
+
this.updateTriggerTabStops();
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
handleTriggerInteraction(id, root, trigger, interaction) {
|
|
144
|
+
if (this.disabled()) {
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
147
|
+
switch (interaction.type) {
|
|
148
|
+
case 'click': {
|
|
149
|
+
if (root.open()) {
|
|
150
|
+
root.close();
|
|
151
|
+
this.deactivateAll();
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
root.show();
|
|
155
|
+
this.activateItem(id);
|
|
156
|
+
}
|
|
157
|
+
return true;
|
|
158
|
+
}
|
|
159
|
+
case 'pointerenter': {
|
|
160
|
+
if (interaction.event.pointerType === 'touch' || !this.hasOpenMenu()) {
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
if (root.open()) {
|
|
164
|
+
return true;
|
|
165
|
+
}
|
|
166
|
+
trigger.focus({ preventScroll: true });
|
|
167
|
+
root.show(false);
|
|
168
|
+
this.activateItem(id);
|
|
169
|
+
return true;
|
|
170
|
+
}
|
|
171
|
+
case 'arrowdown': {
|
|
172
|
+
interaction.event.preventDefault();
|
|
173
|
+
root.show('first');
|
|
174
|
+
this.activateItem(id);
|
|
175
|
+
return true;
|
|
176
|
+
}
|
|
177
|
+
case 'arrowup': {
|
|
178
|
+
interaction.event.preventDefault();
|
|
179
|
+
root.show('last');
|
|
180
|
+
this.activateItem(id);
|
|
181
|
+
return true;
|
|
182
|
+
}
|
|
183
|
+
case 'arrowleft': {
|
|
184
|
+
this.handleTriggerArrow(interaction.event, id, -1, root.open());
|
|
185
|
+
return true;
|
|
186
|
+
}
|
|
187
|
+
case 'arrowright': {
|
|
188
|
+
this.handleTriggerArrow(interaction.event, id, 1, root.open());
|
|
189
|
+
return true;
|
|
190
|
+
}
|
|
191
|
+
case 'home': {
|
|
192
|
+
this.handleTriggerBoundary(interaction.event, 'first', root.open());
|
|
193
|
+
return true;
|
|
194
|
+
}
|
|
195
|
+
case 'end': {
|
|
196
|
+
this.handleTriggerBoundary(interaction.event, 'last', root.open());
|
|
197
|
+
return true;
|
|
198
|
+
}
|
|
199
|
+
case 'escape': {
|
|
200
|
+
interaction.event.preventDefault();
|
|
201
|
+
interaction.event.stopPropagation();
|
|
202
|
+
root.close();
|
|
203
|
+
this.deactivateAll();
|
|
204
|
+
trigger.focus({ preventScroll: true });
|
|
205
|
+
return true;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
handleTriggerArrow(event, id, offset, openOnMove) {
|
|
210
|
+
event.preventDefault();
|
|
211
|
+
event.stopPropagation();
|
|
212
|
+
event.stopImmediatePropagation();
|
|
213
|
+
this.focusAdjacent(id, offset, openOnMove);
|
|
214
|
+
}
|
|
215
|
+
handleTriggerBoundary(event, boundary, openOnMove) {
|
|
216
|
+
event.preventDefault();
|
|
217
|
+
event.stopPropagation();
|
|
218
|
+
event.stopImmediatePropagation();
|
|
219
|
+
this.focusBoundary(boundary, openOnMove);
|
|
220
|
+
}
|
|
221
|
+
focusAdjacent(currentId, offset, openOnMove) {
|
|
222
|
+
const enabled = this.enabledItems();
|
|
223
|
+
const currentIndex = enabled.findIndex((item) => item.id === currentId);
|
|
224
|
+
if (currentIndex === -1 || enabled.length === 0)
|
|
225
|
+
return;
|
|
226
|
+
const nextIndex = currentIndex + offset;
|
|
227
|
+
if (!this.loopFocus() && (nextIndex < 0 || nextIndex >= enabled.length)) {
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
const next = enabled[(nextIndex + enabled.length) % enabled.length];
|
|
231
|
+
this.focusItem(next, openOnMove);
|
|
232
|
+
}
|
|
233
|
+
handleArrowLeft(event) {
|
|
234
|
+
this.handleOpenMenuNavigation(event, -1);
|
|
235
|
+
}
|
|
236
|
+
handleArrowRight(event) {
|
|
237
|
+
this.handleOpenMenuNavigation(event, 1);
|
|
238
|
+
}
|
|
239
|
+
handleOpenMenuNavigation(event, offset) {
|
|
240
|
+
const activeId = this.activeId();
|
|
241
|
+
if (!activeId || this.disabled() || !this.hasOpenMenu()) {
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
event.preventDefault();
|
|
245
|
+
event.stopPropagation();
|
|
246
|
+
event.stopImmediatePropagation();
|
|
247
|
+
this.focusAdjacent(activeId, offset, true);
|
|
248
|
+
}
|
|
249
|
+
focusItem(item, openOnMove) {
|
|
250
|
+
if (!item || this.disabled())
|
|
251
|
+
return;
|
|
252
|
+
item.el.focus();
|
|
253
|
+
if (openOnMove) {
|
|
254
|
+
item.open();
|
|
255
|
+
this.activateItem(item.id);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
updateTriggerTabStops() {
|
|
259
|
+
this.items.forEach((item) => item.el.setAttribute('tabindex', '-1'));
|
|
260
|
+
}
|
|
261
|
+
enabledItems() {
|
|
262
|
+
return this.items.filter((item) => !item.disabled());
|
|
263
|
+
}
|
|
264
|
+
hasOpenMenu() {
|
|
265
|
+
return this.items.some((item) => item.root?.open());
|
|
266
|
+
}
|
|
267
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxMenubarRoot, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
268
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "21.2.9", type: RdxMenubarRoot, isStandalone: true, selector: "[rdxMenubarRoot]", inputs: { disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, loopFocus: { classPropertyName: "loopFocus", publicName: "loopFocus", isSignal: true, isRequired: false, transformFunction: null }, orientation: { classPropertyName: "orientation", publicName: "orientation", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "menubar", "tabindex": "0" }, listeners: { "keydown.arrowleft": "handleArrowLeft($event)", "keydown.arrowright": "handleArrowRight($event)" }, properties: { "attr.aria-orientation": "orientation()", "attr.data-orientation": "orientation()", "attr.data-disabled": "disabled() ? \"\" : undefined", "attr.data-has-submenu-open": "isAnyOpen() ? \"\" : undefined" } }, providers: [provideRdxMenubarContext(contextFactory)], queries: [{ propertyName: "menuRoots", predicate: RdxMenuRoot, isSignal: true }], exportAs: ["rdxMenubarRoot"], ngImport: i0 }); }
|
|
99
269
|
}
|
|
100
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
270
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxMenubarRoot, decorators: [{
|
|
101
271
|
type: Directive,
|
|
102
272
|
args: [{
|
|
103
|
-
selector: '[
|
|
104
|
-
|
|
273
|
+
selector: '[rdxMenubarRoot]',
|
|
274
|
+
exportAs: 'rdxMenubarRoot',
|
|
275
|
+
providers: [provideRdxMenubarContext(contextFactory)],
|
|
105
276
|
host: {
|
|
277
|
+
role: 'menubar',
|
|
106
278
|
tabindex: '0',
|
|
107
|
-
'[attr.
|
|
279
|
+
'[attr.aria-orientation]': 'orientation()',
|
|
280
|
+
'[attr.data-orientation]': 'orientation()',
|
|
281
|
+
'[attr.data-disabled]': 'disabled() ? "" : undefined',
|
|
282
|
+
'[attr.data-has-submenu-open]': 'isAnyOpen() ? "" : undefined',
|
|
283
|
+
'(keydown.arrowleft)': 'handleArrowLeft($event)',
|
|
284
|
+
'(keydown.arrowright)': 'handleArrowRight($event)'
|
|
108
285
|
}
|
|
109
286
|
}]
|
|
110
|
-
}] });
|
|
111
|
-
|
|
112
|
-
class RdxMenubarSeparatorDirective {
|
|
113
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: RdxMenubarSeparatorDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
114
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.3", type: RdxMenubarSeparatorDirective, isStandalone: true, selector: "[RdxMenuBarSeparator]", hostDirectives: [{ directive: i1.RdxMenuSeparatorDirective }], ngImport: i0 }); }
|
|
115
|
-
}
|
|
116
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: RdxMenubarSeparatorDirective, decorators: [{
|
|
117
|
-
type: Directive,
|
|
118
|
-
args: [{
|
|
119
|
-
selector: '[RdxMenuBarSeparator]',
|
|
120
|
-
hostDirectives: [RdxMenuSeparatorDirective]
|
|
121
|
-
}]
|
|
122
|
-
}] });
|
|
287
|
+
}], ctorParameters: () => [], propDecorators: { menuRoots: [{ type: i0.ContentChildren, args: [i0.forwardRef(() => RdxMenuRoot), { isSignal: true }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], loopFocus: [{ type: i0.Input, args: [{ isSignal: true, alias: "loopFocus", required: false }] }], orientation: [{ type: i0.Input, args: [{ isSignal: true, alias: "orientation", required: false }] }] } });
|
|
123
288
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
inputs: ['disabled', 'menuTriggerFor', 'sideOffset', 'side', 'align', 'alignOffset']
|
|
136
|
-
}
|
|
137
|
-
]
|
|
138
|
-
}]
|
|
139
|
-
}] });
|
|
140
|
-
|
|
141
|
-
const menubarImports = [
|
|
142
|
-
RdxMenuBarContentDirective,
|
|
143
|
-
RdxMenuBarTriggerDirective,
|
|
144
|
-
RdxMenubarSeparatorDirective,
|
|
145
|
-
RdxMenubarItemCheckboxDirective,
|
|
146
|
-
RdxMenuBarRootDirective,
|
|
147
|
-
RdxMenuBarItemDirective,
|
|
148
|
-
RdxMenubarItemIndicatorDirective,
|
|
149
|
-
RdxMenubarItemRadioDirective,
|
|
150
|
-
RdxMenubarRadioGroupDirective
|
|
151
|
-
];
|
|
152
|
-
class MenubarModule {
|
|
153
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: MenubarModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
154
|
-
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.3", ngImport: i0, type: MenubarModule, imports: [RdxMenuBarContentDirective,
|
|
155
|
-
RdxMenuBarTriggerDirective,
|
|
156
|
-
RdxMenubarSeparatorDirective,
|
|
157
|
-
RdxMenubarItemCheckboxDirective,
|
|
158
|
-
RdxMenuBarRootDirective,
|
|
159
|
-
RdxMenuBarItemDirective,
|
|
160
|
-
RdxMenubarItemIndicatorDirective,
|
|
161
|
-
RdxMenubarItemRadioDirective,
|
|
162
|
-
RdxMenubarRadioGroupDirective], exports: [RdxMenuBarContentDirective,
|
|
163
|
-
RdxMenuBarTriggerDirective,
|
|
164
|
-
RdxMenubarSeparatorDirective,
|
|
165
|
-
RdxMenubarItemCheckboxDirective,
|
|
166
|
-
RdxMenuBarRootDirective,
|
|
167
|
-
RdxMenuBarItemDirective,
|
|
168
|
-
RdxMenubarItemIndicatorDirective,
|
|
169
|
-
RdxMenubarItemRadioDirective,
|
|
170
|
-
RdxMenubarRadioGroupDirective] }); }
|
|
171
|
-
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: MenubarModule }); }
|
|
289
|
+
/**
|
|
290
|
+
* Menubar-specific parts. Triggers use the standard `rdxMenuTrigger` from
|
|
291
|
+
* `@radix-ng/primitives/menu`; the menubar root wires them for roving focus,
|
|
292
|
+
* hover switching, and ArrowLeft / ArrowRight navigation. The menu popup, items,
|
|
293
|
+
* checkbox/radio, submenu, separator, etc. also come from `RdxMenuModule`.
|
|
294
|
+
*/
|
|
295
|
+
const menubarImports = [RdxMenubarRoot];
|
|
296
|
+
class RdxMenubarModule {
|
|
297
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxMenubarModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
298
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "21.2.9", ngImport: i0, type: RdxMenubarModule, imports: [RdxMenubarRoot], exports: [RdxMenubarRoot] }); }
|
|
299
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxMenubarModule }); }
|
|
172
300
|
}
|
|
173
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
301
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxMenubarModule, decorators: [{
|
|
174
302
|
type: NgModule,
|
|
175
303
|
args: [{
|
|
176
304
|
imports: [...menubarImports],
|
|
@@ -182,5 +310,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.3", ngImpor
|
|
|
182
310
|
* Generated bundle index. Do not edit.
|
|
183
311
|
*/
|
|
184
312
|
|
|
185
|
-
export {
|
|
313
|
+
export { RdxMenubarModule, RdxMenubarRoot, injectRdxMenubarContext, provideRdxMenubarContext };
|
|
186
314
|
//# sourceMappingURL=radix-ng-primitives-menubar.mjs.map
|