@joanroucoux/cairn-ui 0.8.2 → 0.9.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.
- package/CHANGELOG.md +114 -0
- package/fesm2022/joanroucoux-cairn-ui-action-bar.mjs +57 -53
- package/fesm2022/joanroucoux-cairn-ui-action-bar.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-alert.mjs +155 -47
- package/fesm2022/joanroucoux-cairn-ui-alert.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-amount.mjs +220 -110
- package/fesm2022/joanroucoux-cairn-ui-amount.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-async.mjs +392 -216
- package/fesm2022/joanroucoux-cairn-ui-async.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-avatar.mjs +145 -68
- package/fesm2022/joanroucoux-cairn-ui-avatar.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-back-link.mjs +87 -47
- package/fesm2022/joanroucoux-cairn-ui-back-link.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-badge.mjs +83 -43
- package/fesm2022/joanroucoux-cairn-ui-badge.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-button.mjs +184 -104
- package/fesm2022/joanroucoux-cairn-ui-button.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-card.mjs +232 -137
- package/fesm2022/joanroucoux-cairn-ui-card.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-choice-chips.mjs +298 -102
- package/fesm2022/joanroucoux-cairn-ui-choice-chips.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-control.mjs +4 -17
- package/fesm2022/joanroucoux-cairn-ui-control.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-delta.mjs +150 -83
- package/fesm2022/joanroucoux-cairn-ui-delta.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-dialog.mjs +508 -471
- package/fesm2022/joanroucoux-cairn-ui-dialog.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-donut.mjs +255 -157
- package/fesm2022/joanroucoux-cairn-ui-donut.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-drawer.mjs +303 -0
- package/fesm2022/joanroucoux-cairn-ui-drawer.mjs.map +1 -0
- package/fesm2022/joanroucoux-cairn-ui-empty.mjs +76 -35
- package/fesm2022/joanroucoux-cairn-ui-empty.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-external-link.mjs +40 -31
- package/fesm2022/joanroucoux-cairn-ui-external-link.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-fact.mjs +188 -79
- package/fesm2022/joanroucoux-cairn-ui-fact.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-field.mjs +309 -173
- package/fesm2022/joanroucoux-cairn-ui-field.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-filter-chips.mjs +165 -87
- package/fesm2022/joanroucoux-cairn-ui-filter-chips.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-group-header.mjs +269 -0
- package/fesm2022/joanroucoux-cairn-ui-group-header.mjs.map +1 -0
- package/fesm2022/joanroucoux-cairn-ui-input.mjs +205 -85
- package/fesm2022/joanroucoux-cairn-ui-input.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-line-chart.mjs +838 -512
- package/fesm2022/joanroucoux-cairn-ui-line-chart.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-menu.mjs +401 -225
- package/fesm2022/joanroucoux-cairn-ui-menu.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-meter.mjs +143 -57
- package/fesm2022/joanroucoux-cairn-ui-meter.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-motion.mjs +367 -399
- package/fesm2022/joanroucoux-cairn-ui-motion.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-nav-item.mjs +73 -44
- package/fesm2022/joanroucoux-cairn-ui-nav-item.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-result-group.mjs +191 -0
- package/fesm2022/joanroucoux-cairn-ui-result-group.mjs.map +1 -0
- package/fesm2022/joanroucoux-cairn-ui-row.mjs +408 -146
- package/fesm2022/joanroucoux-cairn-ui-row.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-segmented.mjs +183 -81
- package/fesm2022/joanroucoux-cairn-ui-segmented.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-select-pill.mjs +270 -0
- package/fesm2022/joanroucoux-cairn-ui-select-pill.mjs.map +1 -0
- package/fesm2022/joanroucoux-cairn-ui-select.mjs +121 -67
- package/fesm2022/joanroucoux-cairn-ui-select.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-skeleton.mjs +129 -51
- package/fesm2022/joanroucoux-cairn-ui-skeleton.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-stale-link.mjs +80 -39
- package/fesm2022/joanroucoux-cairn-ui-stale-link.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-stat.mjs +85 -55
- package/fesm2022/joanroucoux-cairn-ui-stat.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-switch.mjs +48 -35
- package/fesm2022/joanroucoux-cairn-ui-switch.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-tab-bar.mjs +113 -69
- package/fesm2022/joanroucoux-cairn-ui-tab-bar.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-table.mjs +1036 -310
- package/fesm2022/joanroucoux-cairn-ui-table.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-toast.mjs +240 -127
- package/fesm2022/joanroucoux-cairn-ui-toast.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui.mjs +0 -4
- package/package.json +17 -1
- package/styles/motion.css +1 -13
- package/styles/tokens.css +35 -64
- package/types/joanroucoux-cairn-ui-action-bar.d.ts +9 -14
- package/types/joanroucoux-cairn-ui-alert.d.ts +29 -15
- package/types/joanroucoux-cairn-ui-amount.d.ts +64 -32
- package/types/joanroucoux-cairn-ui-async.d.ts +85 -38
- package/types/joanroucoux-cairn-ui-avatar.d.ts +34 -22
- package/types/joanroucoux-cairn-ui-back-link.d.ts +20 -15
- package/types/joanroucoux-cairn-ui-badge.d.ts +22 -14
- package/types/joanroucoux-cairn-ui-button.d.ts +36 -18
- package/types/joanroucoux-cairn-ui-card.d.ts +48 -23
- package/types/joanroucoux-cairn-ui-choice-chips.d.ts +91 -35
- package/types/joanroucoux-cairn-ui-control.d.ts +9 -18
- package/types/joanroucoux-cairn-ui-delta.d.ts +46 -24
- package/types/joanroucoux-cairn-ui-dialog.d.ts +124 -57
- package/types/joanroucoux-cairn-ui-donut.d.ts +83 -46
- package/types/joanroucoux-cairn-ui-drawer.d.ts +73 -0
- package/types/joanroucoux-cairn-ui-empty.d.ts +20 -13
- package/types/joanroucoux-cairn-ui-external-link.d.ts +6 -10
- package/types/joanroucoux-cairn-ui-fact.d.ts +49 -25
- package/types/joanroucoux-cairn-ui-field.d.ts +72 -49
- package/types/joanroucoux-cairn-ui-filter-chips.d.ts +35 -20
- package/types/joanroucoux-cairn-ui-group-header.d.ts +58 -0
- package/types/joanroucoux-cairn-ui-input.d.ts +59 -37
- package/types/joanroucoux-cairn-ui-line-chart.d.ts +199 -89
- package/types/joanroucoux-cairn-ui-menu.d.ts +81 -44
- package/types/joanroucoux-cairn-ui-meter.d.ts +44 -22
- package/types/joanroucoux-cairn-ui-motion.d.ts +61 -75
- package/types/joanroucoux-cairn-ui-nav-item.d.ts +15 -13
- package/types/joanroucoux-cairn-ui-result-group.d.ts +52 -0
- package/types/joanroucoux-cairn-ui-row.d.ts +92 -37
- package/types/joanroucoux-cairn-ui-segmented.d.ts +51 -27
- package/types/joanroucoux-cairn-ui-select-pill.d.ts +59 -0
- package/types/joanroucoux-cairn-ui-select.d.ts +28 -18
- package/types/joanroucoux-cairn-ui-skeleton.d.ts +35 -18
- package/types/joanroucoux-cairn-ui-stale-link.d.ts +23 -16
- package/types/joanroucoux-cairn-ui-stat.d.ts +26 -21
- package/types/joanroucoux-cairn-ui-switch.d.ts +7 -11
- package/types/joanroucoux-cairn-ui-tab-bar.d.ts +20 -17
- package/types/joanroucoux-cairn-ui-table.d.ts +251 -89
- package/types/joanroucoux-cairn-ui-toast.d.ts +46 -36
- package/types/joanroucoux-cairn-ui.d.ts +1 -2
- package/fesm2022/joanroucoux-cairn-ui.mjs.map +0 -1
|
@@ -1,183 +1,293 @@
|
|
|
1
|
-
import * as i0 from
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import { Component, Directive, ElementRef, booleanAttribute, computed, contentChildren, inject, input, numberAttribute, signal } from "@angular/core";
|
|
3
|
+
const MENU_CLASSES = "m-0 min-w-44 p-1 rounded-container bg-(--elevated) shadow-[0_8px_24px_rgb(0_0_0/0.16),inset_0_0_0_1px_var(--border)] text-(--foreground) transition-[opacity,scale,overlay,display] transition-discrete duration-(--duration-fast) not-open:duration-[120ms] ease-out starting:open:opacity-0 starting:open:scale-(--enter-scale) opacity-0 scale-(--enter-scale) open:opacity-100 open:scale-100";
|
|
4
|
+
const SHEET_CLASSES = "max-lg:fixed max-lg:inset-x-4 max-lg:top-auto max-lg:w-auto max-lg:bottom-[calc(76px+env(safe-area-inset-bottom))] max-lg:min-w-0 max-lg:p-1.5 max-lg:bg-(--card) max-lg:shadow-[0_12px_32px_rgb(0_0_0/0.2),inset_0_0_0_1px_var(--border)] max-lg:backdrop:bg-[rgb(0_0_0/0.36)] max-lg:transition-[opacity,translate,overlay,display] max-lg:scale-100 max-lg:translate-y-4 max-lg:open:translate-y-0 max-lg:starting:open:scale-100 max-lg:starting:open:translate-y-4 max-lg:motion-reduce:translate-y-0 max-lg:motion-reduce:starting:open:translate-y-0";
|
|
5
|
+
const SHEET_ITEM_CLASSES = "flex w-full items-center gap-3 lg:pointer-fine:gap-2.5 min-h-12 lg:min-h-11 lg:pointer-fine:min-h-9 px-3 lg:pointer-fine:px-2.5 rounded-[calc(var(--radius-container)-6px)] lg:rounded-[calc(var(--radius-container)-4px)] text-body lg:pointer-fine:text-label text-left whitespace-nowrap hover:bg-(--glow) focus-visible:bg-(--glow) active:bg-(--soft) transition-[background-color] duration-(--duration-fast) ease-out outline-none focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-(--ring) [:where(&>svg)]:size-5 [:where(&>svg)]:flex-none lg:[:where(&>svg)]:size-[18px] lg:pointer-fine:[:where(&>svg)]:size-4";
|
|
6
|
+
const ITEM_CLASSES = "flex w-full items-center gap-3 pointer-fine:gap-2.5 min-h-11 pointer-fine:min-h-9 px-3 pointer-fine:px-2.5 rounded-[calc(var(--radius-container)-4px)] text-body pointer-fine:text-label text-left whitespace-nowrap hover:bg-(--glow) focus-visible:bg-(--glow) active:bg-(--soft) transition-[background-color] duration-(--duration-fast) ease-out outline-none focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-(--ring) [:where(&>svg)]:size-[18px] [:where(&>svg)]:flex-none pointer-fine:[:where(&>svg)]:size-4";
|
|
7
|
+
const CHECK_CLASSES = "after:ms-auto after:block after:h-3 after:w-1.5 after:flex-none after:rotate-45 after:border-r-2 after:border-b-2 after:border-current after:content-['']";
|
|
8
8
|
const nextId = (() => {
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
let count = 0;
|
|
10
|
+
return () => `ui-menu-${++count}`;
|
|
11
11
|
})();
|
|
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
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
12
|
+
var UiMenuItem = class UiMenuItem {
|
|
13
|
+
destructive = input(false, {
|
|
14
|
+
...ngDevMode ? { debugName: "destructive" } : /* istanbul ignore next */ {},
|
|
15
|
+
transform: booleanAttribute
|
|
16
|
+
});
|
|
17
|
+
checked = input(...ngDevMode ? [void 0, { debugName: "checked" }] : /* istanbul ignore next */ []);
|
|
18
|
+
#host = inject(ElementRef).nativeElement;
|
|
19
|
+
#menu = inject(UiMenu);
|
|
20
|
+
role = computed(() => this.checked() === void 0 ? "menuitem" : "menuitemradio", ...ngDevMode ? [{ debugName: "role" }] : /* istanbul ignore next */ []);
|
|
21
|
+
classes = computed(() => `${this.#menu.sheet() ? SHEET_ITEM_CLASSES : ITEM_CLASSES}${this.destructive() ? " text-(--negative)" : ""}${this.checked() ? ` ${CHECK_CLASSES}` : ""}`, ...ngDevMode ? [{ debugName: "classes" }] : /* istanbul ignore next */ []);
|
|
22
|
+
focus() {
|
|
23
|
+
this.#host.focus();
|
|
24
|
+
}
|
|
25
|
+
hasFocus() {
|
|
26
|
+
return this.#host === document.activeElement;
|
|
27
|
+
}
|
|
28
|
+
onClick() {
|
|
29
|
+
this.#menu.close();
|
|
30
|
+
}
|
|
31
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
32
|
+
minVersion: "12.0.0",
|
|
33
|
+
version: "22.2.0",
|
|
34
|
+
ngImport: i0,
|
|
35
|
+
type: UiMenuItem,
|
|
36
|
+
deps: [],
|
|
37
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
38
|
+
});
|
|
39
|
+
static ɵdir = i0.ɵɵngDeclareDirective({
|
|
40
|
+
minVersion: "17.1.0",
|
|
41
|
+
version: "22.2.0",
|
|
42
|
+
type: UiMenuItem,
|
|
43
|
+
isStandalone: true,
|
|
44
|
+
selector: "button[uiMenuItem]",
|
|
45
|
+
inputs: {
|
|
46
|
+
destructive: {
|
|
47
|
+
classPropertyName: "destructive",
|
|
48
|
+
publicName: "destructive",
|
|
49
|
+
isSignal: true,
|
|
50
|
+
isRequired: false,
|
|
51
|
+
transformFunction: null
|
|
52
|
+
},
|
|
53
|
+
checked: {
|
|
54
|
+
classPropertyName: "checked",
|
|
55
|
+
publicName: "checked",
|
|
56
|
+
isSignal: true,
|
|
57
|
+
isRequired: false,
|
|
58
|
+
transformFunction: null
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
host: {
|
|
62
|
+
attributes: { "tabindex": "-1" },
|
|
63
|
+
listeners: { "click": "onClick()" },
|
|
64
|
+
properties: {
|
|
65
|
+
"attr.role": "role()",
|
|
66
|
+
"attr.aria-checked": "checked() === undefined ? null : checked()",
|
|
67
|
+
"class": "classes()"
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
ngImport: i0
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
74
|
+
minVersion: "12.0.0",
|
|
75
|
+
version: "22.2.0",
|
|
76
|
+
ngImport: i0,
|
|
77
|
+
type: UiMenuItem,
|
|
78
|
+
decorators: [{
|
|
79
|
+
type: Directive,
|
|
80
|
+
args: [{
|
|
81
|
+
selector: "button[uiMenuItem]",
|
|
82
|
+
host: {
|
|
83
|
+
"[attr.role]": "role()",
|
|
84
|
+
"[attr.aria-checked]": "checked() === undefined ? null : checked()",
|
|
85
|
+
tabindex: "-1",
|
|
86
|
+
"[class]": "classes()",
|
|
87
|
+
"(click)": "onClick()"
|
|
88
|
+
}
|
|
89
|
+
}]
|
|
90
|
+
}],
|
|
91
|
+
propDecorators: {
|
|
92
|
+
destructive: [{
|
|
93
|
+
type: i0.Input,
|
|
94
|
+
args: [{
|
|
95
|
+
isSignal: true,
|
|
96
|
+
alias: "destructive",
|
|
97
|
+
required: false
|
|
98
|
+
}]
|
|
99
|
+
}],
|
|
100
|
+
checked: [{
|
|
101
|
+
type: i0.Input,
|
|
102
|
+
args: [{
|
|
103
|
+
isSignal: true,
|
|
104
|
+
alias: "checked",
|
|
105
|
+
required: false
|
|
106
|
+
}]
|
|
107
|
+
}]
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
var UiMenu = class UiMenu {
|
|
111
|
+
label = input.required(...ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []);
|
|
112
|
+
sheet = input(false, {
|
|
113
|
+
...ngDevMode ? { debugName: "sheet" } : /* istanbul ignore next */ {},
|
|
114
|
+
transform: booleanAttribute
|
|
115
|
+
});
|
|
116
|
+
heading = input(...ngDevMode ? [void 0, { debugName: "heading" }] : /* istanbul ignore next */ []);
|
|
117
|
+
width = input(void 0, {
|
|
118
|
+
...ngDevMode ? { debugName: "width" } : /* istanbul ignore next */ {},
|
|
119
|
+
transform: numberAttribute
|
|
120
|
+
});
|
|
121
|
+
menuId = nextId();
|
|
122
|
+
isOpen = signal(false, ...ngDevMode ? [{ debugName: "isOpen" }] : /* istanbul ignore next */ []);
|
|
123
|
+
hasWidth = computed(() => Number.isFinite(this.width()), ...ngDevMode ? [{ debugName: "hasWidth" }] : /* istanbul ignore next */ []);
|
|
124
|
+
widthVar = computed(() => this.hasWidth() ? `${this.width()}px` : null, ...ngDevMode ? [{ debugName: "widthVar" }] : /* istanbul ignore next */ []);
|
|
125
|
+
classes = computed(() => {
|
|
126
|
+
const width = !this.hasWidth() ? "" : this.sheet() ? " lg:w-(--ui-menu-width)" : " w-(--ui-menu-width)";
|
|
127
|
+
return `${MENU_CLASSES}${this.sheet() ? ` ${SHEET_CLASSES}` : ""}${width}`;
|
|
128
|
+
}, ...ngDevMode ? [{ debugName: "classes" }] : /* istanbul ignore next */ []);
|
|
129
|
+
items = contentChildren(UiMenuItem, ...ngDevMode ? [{ debugName: "items" }] : /* istanbul ignore next */ []);
|
|
130
|
+
#host = inject(ElementRef).nativeElement;
|
|
131
|
+
#trigger = null;
|
|
132
|
+
open(trigger) {
|
|
133
|
+
this.#trigger = trigger;
|
|
134
|
+
this.isOpen.set(true);
|
|
135
|
+
if (typeof this.#host.showPopover === "function") this.#host.showPopover();
|
|
136
|
+
if (this.#isSheet()) {
|
|
137
|
+
this.#host.style.position = "";
|
|
138
|
+
this.#host.style.top = "";
|
|
139
|
+
this.#host.style.left = "";
|
|
140
|
+
this.#host.style.right = "";
|
|
141
|
+
this.#host.style.bottom = "";
|
|
142
|
+
} else this.#position(trigger);
|
|
143
|
+
(this.items().find((item) => item.checked()) ?? this.items()[0])?.focus();
|
|
144
|
+
}
|
|
145
|
+
close() {
|
|
146
|
+
const wasOpen = this.isOpen();
|
|
147
|
+
this.#applyClosed();
|
|
148
|
+
if (wasOpen && typeof this.#host.hidePopover === "function") this.#host.hidePopover();
|
|
149
|
+
}
|
|
150
|
+
#applyClosed() {
|
|
151
|
+
this.isOpen.set(false);
|
|
152
|
+
this.#trigger?.focus();
|
|
153
|
+
this.#trigger = null;
|
|
154
|
+
}
|
|
155
|
+
onToggle(event) {
|
|
156
|
+
if (event.newState === "closed") this.#applyClosed();
|
|
157
|
+
}
|
|
158
|
+
onKeydown(event) {
|
|
159
|
+
if (event.key === "Tab" || event.key === "Escape") {
|
|
160
|
+
event.preventDefault();
|
|
161
|
+
this.close();
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
const items = this.items();
|
|
165
|
+
const currentIndex = items.findIndex((item) => item.hasFocus());
|
|
166
|
+
const lastIndex = items.length - 1;
|
|
167
|
+
let nextIndex;
|
|
168
|
+
switch (event.key) {
|
|
169
|
+
case "ArrowDown":
|
|
170
|
+
nextIndex = currentIndex >= lastIndex ? 0 : currentIndex + 1;
|
|
171
|
+
break;
|
|
172
|
+
case "ArrowUp":
|
|
173
|
+
nextIndex = currentIndex <= 0 ? lastIndex : currentIndex - 1;
|
|
174
|
+
break;
|
|
175
|
+
case "Home":
|
|
176
|
+
nextIndex = 0;
|
|
177
|
+
break;
|
|
178
|
+
case "End": nextIndex = lastIndex;
|
|
179
|
+
}
|
|
180
|
+
if (nextIndex === void 0) return;
|
|
181
|
+
event.preventDefault();
|
|
182
|
+
items[nextIndex]?.focus();
|
|
183
|
+
}
|
|
184
|
+
#isSheet() {
|
|
185
|
+
return this.sheet() && typeof window.matchMedia === "function" && !window.matchMedia("(min-width: 64rem)").matches;
|
|
186
|
+
}
|
|
187
|
+
#position(trigger) {
|
|
188
|
+
const margin = 8;
|
|
189
|
+
const triggerRect = trigger.getBoundingClientRect();
|
|
190
|
+
const menuRect = {
|
|
191
|
+
width: this.#host.offsetWidth,
|
|
192
|
+
height: this.#host.offsetHeight
|
|
193
|
+
};
|
|
194
|
+
const fitsBelow = window.innerHeight - triggerRect.bottom >= menuRect.height + margin;
|
|
195
|
+
const top = fitsBelow ? triggerRect.bottom + 4 : Math.max(margin, triggerRect.top - menuRect.height - 4);
|
|
196
|
+
const left = Math.min(Math.max(triggerRect.right - menuRect.width, margin), window.innerWidth - menuRect.width - margin);
|
|
197
|
+
this.#host.style.position = "fixed";
|
|
198
|
+
this.#host.style.top = `${Math.min(top, window.innerHeight - menuRect.height - margin)}px`;
|
|
199
|
+
this.#host.style.left = `${left}px`;
|
|
200
|
+
this.#host.style.right = "auto";
|
|
201
|
+
this.#host.style.bottom = "auto";
|
|
202
|
+
this.#host.style.transformOrigin = fitsBelow ? "top right" : "bottom right";
|
|
203
|
+
}
|
|
204
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
205
|
+
minVersion: "12.0.0",
|
|
206
|
+
version: "22.2.0",
|
|
207
|
+
ngImport: i0,
|
|
208
|
+
type: UiMenu,
|
|
209
|
+
deps: [],
|
|
210
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
211
|
+
});
|
|
212
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
213
|
+
minVersion: "17.0.0",
|
|
214
|
+
version: "22.2.0",
|
|
215
|
+
type: UiMenu,
|
|
216
|
+
isStandalone: true,
|
|
217
|
+
selector: "ui-menu",
|
|
218
|
+
inputs: {
|
|
219
|
+
label: {
|
|
220
|
+
classPropertyName: "label",
|
|
221
|
+
publicName: "label",
|
|
222
|
+
isSignal: true,
|
|
223
|
+
isRequired: true,
|
|
224
|
+
transformFunction: null
|
|
225
|
+
},
|
|
226
|
+
sheet: {
|
|
227
|
+
classPropertyName: "sheet",
|
|
228
|
+
publicName: "sheet",
|
|
229
|
+
isSignal: true,
|
|
230
|
+
isRequired: false,
|
|
231
|
+
transformFunction: null
|
|
232
|
+
},
|
|
233
|
+
heading: {
|
|
234
|
+
classPropertyName: "heading",
|
|
235
|
+
publicName: "heading",
|
|
236
|
+
isSignal: true,
|
|
237
|
+
isRequired: false,
|
|
238
|
+
transformFunction: null
|
|
239
|
+
},
|
|
240
|
+
width: {
|
|
241
|
+
classPropertyName: "width",
|
|
242
|
+
publicName: "width",
|
|
243
|
+
isSignal: true,
|
|
244
|
+
isRequired: false,
|
|
245
|
+
transformFunction: null
|
|
246
|
+
}
|
|
247
|
+
},
|
|
248
|
+
host: {
|
|
249
|
+
attributes: {
|
|
250
|
+
"role": "menu",
|
|
251
|
+
"popover": "auto"
|
|
252
|
+
},
|
|
253
|
+
listeners: {
|
|
254
|
+
"toggle": "onToggle($event)",
|
|
255
|
+
"keydown": "onKeydown($event)"
|
|
256
|
+
},
|
|
257
|
+
properties: {
|
|
258
|
+
"id": "menuId",
|
|
259
|
+
"style.--ui-menu-width": "widthVar()",
|
|
260
|
+
"class": "classes()",
|
|
261
|
+
"attr.aria-label": "label()"
|
|
262
|
+
}
|
|
263
|
+
},
|
|
264
|
+
queries: [{
|
|
265
|
+
propertyName: "items",
|
|
266
|
+
predicate: UiMenuItem,
|
|
267
|
+
isSignal: true
|
|
268
|
+
}],
|
|
269
|
+
ngImport: i0,
|
|
270
|
+
template: `
|
|
168
271
|
@if (sheet() && heading()) {
|
|
169
272
|
<div aria-hidden="true" class="text-label px-3 pt-2 pb-1.5 leading-[17px] text-(--muted-foreground) lg:hidden">
|
|
170
273
|
{{ heading() }}
|
|
171
274
|
</div>
|
|
172
275
|
}
|
|
173
276
|
<ng-content />
|
|
174
|
-
`,
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
277
|
+
`,
|
|
278
|
+
isInline: true
|
|
279
|
+
});
|
|
280
|
+
};
|
|
281
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
282
|
+
minVersion: "12.0.0",
|
|
283
|
+
version: "22.2.0",
|
|
284
|
+
ngImport: i0,
|
|
285
|
+
type: UiMenu,
|
|
286
|
+
decorators: [{
|
|
287
|
+
type: Component,
|
|
288
|
+
args: [{
|
|
289
|
+
selector: "ui-menu",
|
|
290
|
+
template: `
|
|
181
291
|
@if (sheet() && heading()) {
|
|
182
292
|
<div aria-hidden="true" class="text-label px-3 pt-2 pb-1.5 leading-[17px] text-(--muted-foreground) lg:hidden">
|
|
183
293
|
{{ heading() }}
|
|
@@ -185,57 +295,123 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImpor
|
|
|
185
295
|
}
|
|
186
296
|
<ng-content />
|
|
187
297
|
`,
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
298
|
+
host: {
|
|
299
|
+
role: "menu",
|
|
300
|
+
popover: "auto",
|
|
301
|
+
"[id]": "menuId",
|
|
302
|
+
"[style.--ui-menu-width]": "widthVar()",
|
|
303
|
+
"[class]": "classes()",
|
|
304
|
+
"[attr.aria-label]": "label()",
|
|
305
|
+
"(toggle)": "onToggle($event)",
|
|
306
|
+
"(keydown)": "onKeydown($event)"
|
|
307
|
+
}
|
|
308
|
+
}]
|
|
309
|
+
}],
|
|
310
|
+
propDecorators: {
|
|
311
|
+
label: [{
|
|
312
|
+
type: i0.Input,
|
|
313
|
+
args: [{
|
|
314
|
+
isSignal: true,
|
|
315
|
+
alias: "label",
|
|
316
|
+
required: true
|
|
317
|
+
}]
|
|
318
|
+
}],
|
|
319
|
+
sheet: [{
|
|
320
|
+
type: i0.Input,
|
|
321
|
+
args: [{
|
|
322
|
+
isSignal: true,
|
|
323
|
+
alias: "sheet",
|
|
324
|
+
required: false
|
|
325
|
+
}]
|
|
326
|
+
}],
|
|
327
|
+
heading: [{
|
|
328
|
+
type: i0.Input,
|
|
329
|
+
args: [{
|
|
330
|
+
isSignal: true,
|
|
331
|
+
alias: "heading",
|
|
332
|
+
required: false
|
|
333
|
+
}]
|
|
334
|
+
}],
|
|
335
|
+
width: [{
|
|
336
|
+
type: i0.Input,
|
|
337
|
+
args: [{
|
|
338
|
+
isSignal: true,
|
|
339
|
+
alias: "width",
|
|
340
|
+
required: false
|
|
341
|
+
}]
|
|
342
|
+
}],
|
|
343
|
+
items: [{
|
|
344
|
+
type: i0.ContentChildren,
|
|
345
|
+
args: [i0.forwardRef(() => UiMenuItem), { isSignal: true }]
|
|
346
|
+
}]
|
|
347
|
+
}
|
|
348
|
+
});
|
|
349
|
+
var UiMenuTrigger = class UiMenuTrigger {
|
|
350
|
+
uiMenuTrigger = input.required(...ngDevMode ? [{ debugName: "uiMenuTrigger" }] : /* istanbul ignore next */ []);
|
|
351
|
+
#host = inject(ElementRef).nativeElement;
|
|
352
|
+
toggle() {
|
|
353
|
+
const menu = this.uiMenuTrigger();
|
|
354
|
+
if (menu.isOpen()) menu.close();
|
|
355
|
+
else menu.open(this.#host);
|
|
356
|
+
}
|
|
357
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
358
|
+
minVersion: "12.0.0",
|
|
359
|
+
version: "22.2.0",
|
|
360
|
+
ngImport: i0,
|
|
361
|
+
type: UiMenuTrigger,
|
|
362
|
+
deps: [],
|
|
363
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
364
|
+
});
|
|
365
|
+
static ɵdir = i0.ɵɵngDeclareDirective({
|
|
366
|
+
minVersion: "17.1.0",
|
|
367
|
+
version: "22.2.0",
|
|
368
|
+
type: UiMenuTrigger,
|
|
369
|
+
isStandalone: true,
|
|
370
|
+
selector: "[uiMenuTrigger]",
|
|
371
|
+
inputs: { uiMenuTrigger: {
|
|
372
|
+
classPropertyName: "uiMenuTrigger",
|
|
373
|
+
publicName: "uiMenuTrigger",
|
|
374
|
+
isSignal: true,
|
|
375
|
+
isRequired: true,
|
|
376
|
+
transformFunction: null
|
|
377
|
+
} },
|
|
378
|
+
host: {
|
|
379
|
+
attributes: { "aria-haspopup": "menu" },
|
|
380
|
+
listeners: { "click": "toggle()" },
|
|
381
|
+
properties: {
|
|
382
|
+
"attr.aria-expanded": "uiMenuTrigger().isOpen()",
|
|
383
|
+
"attr.aria-controls": "uiMenuTrigger().menuId"
|
|
384
|
+
}
|
|
385
|
+
},
|
|
386
|
+
ngImport: i0
|
|
387
|
+
});
|
|
388
|
+
};
|
|
389
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
390
|
+
minVersion: "12.0.0",
|
|
391
|
+
version: "22.2.0",
|
|
392
|
+
ngImport: i0,
|
|
393
|
+
type: UiMenuTrigger,
|
|
394
|
+
decorators: [{
|
|
395
|
+
type: Directive,
|
|
396
|
+
args: [{
|
|
397
|
+
selector: "[uiMenuTrigger]",
|
|
398
|
+
host: {
|
|
399
|
+
"aria-haspopup": "menu",
|
|
400
|
+
"[attr.aria-expanded]": "uiMenuTrigger().isOpen()",
|
|
401
|
+
"[attr.aria-controls]": "uiMenuTrigger().menuId",
|
|
402
|
+
"(click)": "toggle()"
|
|
403
|
+
}
|
|
404
|
+
}]
|
|
405
|
+
}],
|
|
406
|
+
propDecorators: { uiMenuTrigger: [{
|
|
407
|
+
type: i0.Input,
|
|
408
|
+
args: [{
|
|
409
|
+
isSignal: true,
|
|
410
|
+
alias: "uiMenuTrigger",
|
|
411
|
+
required: true
|
|
412
|
+
}]
|
|
413
|
+
}] }
|
|
414
|
+
});
|
|
240
415
|
export { UiMenu, UiMenuItem, UiMenuTrigger };
|
|
241
|
-
|
|
416
|
+
|
|
417
|
+
//# sourceMappingURL=joanroucoux-cairn-ui-menu.mjs.map
|