@dskripchenko/laravel-admin 1.41.0 → 1.42.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/dist/.vite/manifest.json +2 -2
- package/dist/assets/{app-OKWENaxo.js → app-BnJi_4Ki.js} +28 -28
- package/dist/assets/{app-eVNtxHfU.css → app-Ct6vVuq2.css} +1 -1
- package/dist/components/shell/breadcrumbs.d.ts +5 -19
- package/dist/components/shell/menuTrail.d.ts +51 -0
- package/dist/components/shell/menuTrail.test.d.ts +1 -0
- package/dist/index.cjs +22 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +11613 -11594
- package/dist/index.mjs.map +1 -1
- package/dist/source-hash.txt +1 -1
- package/dist/style.css +1 -1
- package/package.json +3 -3
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The top bar's breadcrumbs, derived from where the visitor is.
|
|
3
3
|
*
|
|
4
|
-
* The trail is the sidebar's: the menu item that matches the route — the
|
|
5
|
-
* AdminSidebarNode marks
|
|
6
|
-
* parent items. A resource route adds what lies below the list: the record
|
|
4
|
+
* The trail is the sidebar's: the menu item that matches the route — the very
|
|
5
|
+
* one AdminSidebarNode marks active, through the shared findMenuTrail() —
|
|
6
|
+
* preceded by its group and its parent items. A resource route adds what lies below the list: the record
|
|
7
7
|
* (named by its title, name or label, else #id) and "Editing" or "Creating".
|
|
8
8
|
* A page the menu does not hold is named by its own title.
|
|
9
9
|
*
|
|
@@ -11,24 +11,10 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import { type ComputedRef } from 'vue';
|
|
13
13
|
import { type RouteLocationRaw } from 'vue-router';
|
|
14
|
-
import {
|
|
14
|
+
import { findMenuTrail, menuMatchScore } from './menuTrail';
|
|
15
15
|
export interface Crumb {
|
|
16
16
|
label: string;
|
|
17
17
|
to?: RouteLocationRaw | null;
|
|
18
18
|
}
|
|
19
|
-
|
|
20
|
-
name?: unknown;
|
|
21
|
-
path: string;
|
|
22
|
-
params: Record<string, unknown>;
|
|
23
|
-
meta: Record<string, unknown>;
|
|
24
|
-
}
|
|
25
|
-
/** How well a menu item matches the route: 0 is no match, an exact one beats a prefix. */
|
|
26
|
-
export declare function menuMatchScore(item: MenuItem, route: RouteLike): number;
|
|
27
|
-
/**
|
|
28
|
-
* The best-matching menu item with the chain of its parents, outermost first.
|
|
29
|
-
* When several items lead to the same page, the shallowest one wins, then the
|
|
30
|
-
* first in menu order.
|
|
31
|
-
*/
|
|
32
|
-
export declare function findMenuTrail(items: MenuItem[], route: RouteLike): MenuItem[];
|
|
19
|
+
export { findMenuTrail, menuMatchScore };
|
|
33
20
|
export declare function useBreadcrumbs(): ComputedRef<Crumb[]>;
|
|
34
|
-
export {};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which menu item the current page belongs to — one answer for the whole shell.
|
|
3
|
+
*
|
|
4
|
+
* The sidebar and the breadcrumbs used to decide this each on their own: the
|
|
5
|
+
* sidebar lit up every item that matched the route, the breadcrumbs picked one.
|
|
6
|
+
* With the same page reachable from two places (`/r/orders` under Shop and
|
|
7
|
+
* again under Showcase › Navigation › Nested menu) the sidebar opened one
|
|
8
|
+
* branch and the breadcrumbs named the other. Both now ask findMenuTrail().
|
|
9
|
+
*
|
|
10
|
+
* The rule, in order:
|
|
11
|
+
* 1. the most specific match: an exact one (route name or url) beats a
|
|
12
|
+
* prefix one, and a longer prefix beats a shorter one;
|
|
13
|
+
* 2. the canonical node: one that points at the page by its route name (what
|
|
14
|
+
* MenuNode::resource()/screen() produce) beats one that only repeats its
|
|
15
|
+
* url;
|
|
16
|
+
* 3. the shallowest node: the page's home section rather than a shortcut
|
|
17
|
+
* to it from deep inside another branch;
|
|
18
|
+
* 4. the first declared, in the menu's own order.
|
|
19
|
+
*/
|
|
20
|
+
import { type ComputedRef, type InjectionKey } from 'vue';
|
|
21
|
+
import { type MenuItem } from '../../stores/menu';
|
|
22
|
+
export interface RouteLike {
|
|
23
|
+
name?: unknown;
|
|
24
|
+
path: string;
|
|
25
|
+
params: Record<string, unknown>;
|
|
26
|
+
meta: Record<string, unknown>;
|
|
27
|
+
}
|
|
28
|
+
/** How well a menu item matches the route: 0 is no match, an exact one beats a prefix. */
|
|
29
|
+
export declare function menuMatchScore(item: MenuItem, route: RouteLike): number;
|
|
30
|
+
/**
|
|
31
|
+
* The best-matching menu item with the chain of its parents, outermost first;
|
|
32
|
+
* empty when no item matches. See the module's comment for the rule.
|
|
33
|
+
*/
|
|
34
|
+
export declare function findMenuTrail(items: MenuItem[], route: RouteLike): MenuItem[];
|
|
35
|
+
/**
|
|
36
|
+
* Where a sidebar node sits: the keys from the root down to it.
|
|
37
|
+
*
|
|
38
|
+
* The nodes are matched against the trail by this path, not by object
|
|
39
|
+
* identity: the menu store rebuilds its items whenever the permissions are
|
|
40
|
+
* re-read, and the same key may appear in two branches (MenuNode::resource()
|
|
41
|
+
* gives every copy of a resource the key `resource.{slug}`).
|
|
42
|
+
*/
|
|
43
|
+
export declare const MENU_NODE_PATH: InjectionKey<string[]>;
|
|
44
|
+
/** Whether the node at `path` lies on the trail; `exact` — whether it is its last item. */
|
|
45
|
+
export declare function pathOnTrail(path: string[], trail: MenuItem[], exact?: boolean): boolean;
|
|
46
|
+
/** The active trail the sidebar shares with its nodes. */
|
|
47
|
+
export declare const ACTIVE_MENU_TRAIL: InjectionKey<ComputedRef<MenuItem[]>>;
|
|
48
|
+
/** The active trail over the whole visible menu, for the current route. */
|
|
49
|
+
export declare function useActiveMenuTrail(): ComputedRef<MenuItem[]>;
|
|
50
|
+
/** The trail provided by the sidebar, or null outside of one. */
|
|
51
|
+
export declare function injectActiveMenuTrail(): ComputedRef<MenuItem[]> | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|