vira 30.3.0 → 30.4.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.
|
@@ -34,6 +34,12 @@ export type ViraMenuItemEntry = {
|
|
|
34
34
|
selected: boolean;
|
|
35
35
|
/** Called when any item is activated. */
|
|
36
36
|
onClick: MenuItemClickCallback;
|
|
37
|
+
/**
|
|
38
|
+
* If set to `true`, this menu item won't show up at all.
|
|
39
|
+
*
|
|
40
|
+
* @default false
|
|
41
|
+
*/
|
|
42
|
+
hidden: boolean;
|
|
37
43
|
}> & typeof ViraMenuItem.InputsType;
|
|
38
44
|
/**
|
|
39
45
|
* A callback for menu items getting activated, to be used with {@link renderMenuItemEntries}.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { joinWithFinalConjunction, } from '@augment-vir/common';
|
|
1
|
+
import { filterMap, joinWithFinalConjunction, } from '@augment-vir/common';
|
|
2
2
|
import { html, listen } from 'element-vir';
|
|
3
3
|
import { ViraMenuItem } from '../elements/pop-up/vira-menu-item.element.js';
|
|
4
4
|
/**
|
|
@@ -42,20 +42,20 @@ export function triggerPopUpState({ open, callback, popUpManager, host, options,
|
|
|
42
42
|
* @category PopUp
|
|
43
43
|
*/
|
|
44
44
|
export function renderMenuItemEntries(items) {
|
|
45
|
-
return items
|
|
45
|
+
return filterMap(items, (item, index) => {
|
|
46
46
|
return html `
|
|
47
|
-
|
|
47
|
+
<${ViraMenuItem.assign({
|
|
48
48
|
...item,
|
|
49
49
|
})}
|
|
50
|
-
|
|
50
|
+
${listen('click', async (event) => {
|
|
51
51
|
await item.onClick?.({
|
|
52
52
|
event,
|
|
53
53
|
index,
|
|
54
54
|
});
|
|
55
55
|
})}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
});
|
|
56
|
+
>
|
|
57
|
+
${item.content}
|
|
58
|
+
</${ViraMenuItem}>
|
|
59
|
+
`;
|
|
60
|
+
}, (template, menuItem) => !menuItem.hidden);
|
|
61
61
|
}
|