@webx-ui/module-menu 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 webx-ui
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # @webx-ui/module-menu
2
+
3
+ Menus as a section of the [WebX UI](https://github.com/webx-ui/webx-ui) admin panel: the named
4
+ menus of a site, the tree of items in each one, and what every item points at.
5
+
6
+ The other half is `webx-ui/module-menu` on the server, which holds the menus and renders them.
7
+ Neither is useful alone.
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ pnpm add @webx-ui/module-menu
13
+ ```
14
+
15
+ ```ts
16
+ import { createAdmin } from '@webx-ui/module-admin'
17
+ import { menu } from '@webx-ui/module-menu'
18
+ import '@webx-ui/module-menu/style.css'
19
+
20
+ createAdmin({
21
+ modules: [menu()],
22
+ })
23
+ ```
24
+
25
+ The section appears among the content sections once the Composer half is installed and migrated.
26
+ Permissions: `menu.view`, `menu.manage`.
27
+
28
+ ## What it brings
29
+
30
+ - `/menus` — the menus on the left, the items of the open one on the right. Which menu is open
31
+ travels in the address, so a link to the footer is a link somebody can send.
32
+ - **Dragging** changes both the order and the parent: every level is its own list, and where a
33
+ row ends up is where it is.
34
+ - **An item points at three things** — an entity chosen from the picker, an address of your own,
35
+ or nothing at all, which is what a heading is. The picker is `WxLinkPicker` from
36
+ `@webx-ui/module-admin`, the same one every link field in the panel uses.
37
+ - **The cache** is marked under each menu — "built today at 08:10", "not built", "off" — with a
38
+ reset beside it and one for every menu in the head of the section. It is what somebody presses
39
+ to test the guess that they are looking at something stale.
40
+
41
+ ## Licence
42
+
43
+ MIT
@@ -0,0 +1,22 @@
1
+ import { MenuItemRow } from './types';
2
+ type __VLS_Props = {
3
+ items: MenuItemRow[];
4
+ /** Null for the top level. It travels back out with the new order. */
5
+ parentId?: number | null;
6
+ disabled?: boolean;
7
+ };
8
+ declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
9
+ edit: (item: MenuItemRow) => any;
10
+ duplicate: (item: MenuItemRow) => any;
11
+ reorder: (parentId: number | null, items: MenuItemRow[]) => any;
12
+ remove: (item: MenuItemRow) => any;
13
+ }, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
14
+ onEdit?: ((item: MenuItemRow) => any) | undefined;
15
+ onDuplicate?: ((item: MenuItemRow) => any) | undefined;
16
+ onReorder?: ((parentId: number | null, items: MenuItemRow[]) => any) | undefined;
17
+ onRemove?: ((item: MenuItemRow) => any) | undefined;
18
+ }>, {
19
+ disabled: boolean;
20
+ parentId: number | null;
21
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
22
+ export default _default;
@@ -0,0 +1,10 @@
1
+ import { MenuRow } from './types';
2
+ type __VLS_Props = {
3
+ menu?: MenuRow | null;
4
+ };
5
+ declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
6
+ menu: MenuRow | null;
7
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
8
+ field: HTMLDivElement;
9
+ }, any>;
10
+ export default _default;
@@ -0,0 +1,10 @@
1
+ import { MenuItemRow, MenuRow } from './types';
2
+ type __VLS_Props = {
3
+ menu: MenuRow;
4
+ /** The item being edited, or null for a new one. */
5
+ item?: MenuItemRow | null;
6
+ };
7
+ declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
8
+ item: MenuItemRow | null;
9
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
10
+ export default _default;
@@ -0,0 +1,19 @@
1
+ import { MenuRow } from './types';
2
+ type __VLS_Props = {
3
+ menu: MenuRow;
4
+ /** False in the drawer a narrow screen opens this in. */
5
+ inline?: boolean;
6
+ back?: () => void;
7
+ };
8
+ declare function load(): Promise<void>;
9
+ declare const _default: import('vue').DefineComponent<__VLS_Props, {
10
+ reload: typeof load;
11
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
12
+ changed: () => any;
13
+ }, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
14
+ onChanged?: (() => any) | undefined;
15
+ }>, {
16
+ back: () => void;
17
+ inline: boolean;
18
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
19
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, HTMLDivElement>;
2
+ export default _default;
package/dist/api.d.ts ADDED
@@ -0,0 +1,25 @@
1
+ import { AdminContext } from '@webx-ui/module-admin';
2
+ import { MenuInput, MenuItemInput, MenuItemRow, MenuRow } from './types';
3
+ export interface MenusApi {
4
+ /** Every menu: the ones a template asks for and the ones somebody made. */
5
+ list(): Promise<MenuRow[]>;
6
+ create(input: MenuInput): Promise<MenuRow>;
7
+ /** The name, and for a menu of somebody's own the key as well. */
8
+ update(key: string, input: Partial<MenuInput>): Promise<MenuRow>;
9
+ /** Only a menu of somebody's own, and its items go with it. */
10
+ remove(key: string): Promise<void>;
11
+ /** The whole tree, nested. Menus are small enough that a level at a time would only cost. */
12
+ items(key: string): Promise<MenuItemRow[]>;
13
+ addItem(key: string, input: MenuItemInput): Promise<MenuItemRow>;
14
+ saveItem(key: string, id: number, input: MenuItemInput): Promise<MenuItemRow>;
15
+ /** Under this parent, at this position among its children. */
16
+ moveItem(key: string, id: number, parentId: number | null, index: number): Promise<void>;
17
+ /** With the subtree under it. Answers how many went. */
18
+ removeItem(key: string, id: number): Promise<number>;
19
+ /** Forget one menu's cache, in every language. */
20
+ flush(key: string): Promise<void>;
21
+ /** The same for every menu at once. */
22
+ flushAll(): Promise<void>;
23
+ }
24
+ /** Everything under `/menus`, below the panel's API path. */
25
+ export declare function createMenusApi(admin: AdminContext): MenusApi;
package/dist/i18n.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ /** Puts this package's English under the panel's dictionary, once per panel. */
2
+ export declare function useMenuMessages(): void;
@@ -0,0 +1,10 @@
1
+ export { menu, type MenuOptions } from './module';
2
+ export { createMenusApi, type MenusApi } from './api';
3
+ export { menuMessages } from './messages';
4
+ export { countBranch, findItem, movedId } from './tree';
5
+ export { default as WxMenusPage } from './MenusPage';
6
+ export { default as WxMenuTreePane } from './MenuTreePane';
7
+ export { default as WxMenuBranch } from './MenuBranch';
8
+ export { default as WxMenuItemDialog } from './MenuItemDialog';
9
+ export { default as WxMenuCreateDialog } from './MenuCreateDialog';
10
+ export type { LocalizedText, MenuCacheState, MenuInput, MenuItemInput, MenuItemRow, MenuRow, } from './types';