@eintrek/erp-shell 0.1.56 → 0.1.58

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.
@@ -18,14 +18,91 @@ export declare function filterNavigationToolsByPermission(tools: Tool[], rulesMa
18
18
  */
19
19
  export declare function filterNavigationModulesByPermission(modules: Module[], rulesMap: PermissionRulesMap, userChildSegments: string[]): Module[];
20
20
  /**
21
- * Find the active top-level module id from `pathname`. Strips the org-code
22
- * prefix from the path (first path segment) before matching.
21
+ * Find the active top-level module id from `pathname`: the module whose URL
22
+ * (or one of whose pages' URLs) is the longest prefix of the path below the
23
+ * org code.
24
+ *
25
+ * Before 0.1.57 this took the first module with a page URL anywhere in the
26
+ * path (`includes`), so "/project" claimed /project/schedule and the sidebar,
27
+ * the trail and the tabs could disagree about where the user was.
23
28
  */
24
29
  export declare function getActiveModule(pathname: string, modules: Module[]): string | null;
25
- /** Find the active sub-module id from `pathname`. */
30
+ /**
31
+ * Find the active sub-module id from `pathname`: the page whose own URL — or
32
+ * one of whose listed `subPages` — is the path itself (below the org code,
33
+ * ignoring a trailing slash). A record, a create or an edit page below a page
34
+ * is no page of the menu, so it has no active sub-module (0.1.58); the module
35
+ * (`getActiveModule`) still says where it belongs.
36
+ *
37
+ * Equal URLs in two modules go to the active module's page.
38
+ */
26
39
  export declare function getActiveSubModule(pathname: string, modules: Module[]): string | null;
27
40
  /** Prepend `code` (org code) to a relative URL so `/sales` → `/O25.../sales`.
28
41
  * Absolute `http(s)://` URLs are left intact; optional `{code}` placeholder is replaced.
29
42
  * Query/hash are preserved: `/?start=1` → `/O25...?start=1` (not `/O25.../?start=1`).
30
43
  */
31
44
  export declare function buildUrlWithCode(code: string | undefined, url: string): string;
45
+ /**
46
+ * The one entry in the sidebar that stands for the current page.
47
+ *
48
+ * `item` is the index of the top-level row. `sub` is the index of the
49
+ * sub-item under it, or null when the row itself is the entry (a one-line
50
+ * item, or a group on its own URL with no page of its own matching).
51
+ * `subPage` is the index of the page inside a sub-item's `subPages`.
52
+ */
53
+ export interface ActiveNavEntry {
54
+ item: number;
55
+ sub: number | null;
56
+ subPage: number | null;
57
+ }
58
+ /** Where the current page sits in the menu, lit or not. */
59
+ export interface SidebarNavState {
60
+ /**
61
+ * The entry lit for this page — only when the page is that entry's own
62
+ * page (its URL, or one of its `subPages`). Null on a record, a create or
63
+ * an edit page below a menu page.
64
+ */
65
+ active: ActiveNavEntry | null;
66
+ /**
67
+ * The group (and sub-item) holding the page: the lit entry's, or else the
68
+ * one with the deepest URL the path sits below. It opens so the user sees
69
+ * where they are, with nothing in it lit.
70
+ */
71
+ open: {
72
+ item: number;
73
+ sub: number | null;
74
+ } | null;
75
+ }
76
+ export interface ResolveActiveNavOptions {
77
+ /** Org code the relative URLs are prefixed with. */
78
+ code?: string;
79
+ /**
80
+ * Kept for callers. Since 0.1.58 every chrome treats "/O1/x/" and "/O1/x"
81
+ * as the same page; this no longer changes anything.
82
+ */
83
+ workspace?: boolean;
84
+ /** See NavMain: a one-line item is lit by `item.isActive` alone. */
85
+ highlightActiveModule?: boolean;
86
+ }
87
+ /** "/O1/" and "/O1" are the same page; a query string never is. */
88
+ export declare function samePage(pathname: string, url: string): boolean;
89
+ /**
90
+ * Where `pathname` sits in the sidebar: the entry to light and the group to
91
+ * open.
92
+ *
93
+ * Lit (0.1.58): only the entry whose own page this is — its URL or one of its
94
+ * `subPages`, exactly. A record, a create or an edit page below a menu page
95
+ * (Plannex /project/detail/<id>/schedule under "โครงการ" /project) lights
96
+ * nothing; an app lists such a page in `subPages` when it should keep its
97
+ * entry lit. At most one entry across every group (0.1.57).
98
+ *
99
+ * Open: the lit entry's group, or else the group with the deepest URL the
100
+ * path sits below.
101
+ *
102
+ * Equal lengths go to the group the app marks active (`item.isActive`, from
103
+ * its `activeModule`), then to a page over a group row, then to the first in
104
+ * menu order.
105
+ */
106
+ export declare function resolveSidebarNav(items: Module[], pathname: string | null | undefined, { code, highlightActiveModule }?: ResolveActiveNavOptions): SidebarNavState;
107
+ /** The entry lit for `pathname` — `resolveSidebarNav(...).active`. */
108
+ export declare function resolveActiveNav(items: Module[], pathname: string | null | undefined, options?: ResolveActiveNavOptions): ActiveNavEntry | null;
@@ -38,6 +38,12 @@ export interface SubModule {
38
38
  isActive?: boolean;
39
39
  icon?: IconType;
40
40
  isCollapsible?: boolean;
41
+ /**
42
+ * Pages that are this item's own: the sidebar lights the item on any of
43
+ * them, exactly as on its URL (0.1.58 lights nothing on other pages below
44
+ * it). A collapsible item also draws them as its children. Each needs a
45
+ * `permissionRouteKey` the user holds — the filter drops one without.
46
+ */
41
47
  subPages?: SubPage[];
42
48
  permissionRouteKey?: string;
43
49
  /**
package/dist/version.d.ts CHANGED
@@ -2,4 +2,4 @@
2
2
  * This package's version, attached to help messages so the back office can
3
3
  * tell which shell a report came from. Keep in step with package.json.
4
4
  */
5
- export declare const SHELL_VERSION = "0.1.53";
5
+ export declare const SHELL_VERSION = "0.1.58";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eintrek/erp-shell",
3
- "version": "0.1.56",
3
+ "version": "0.1.58",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Shared frontend platform for ERP apps — HTTP client, providers, navigation, hooks.",