@eintrek/erp-shell 0.1.55 → 0.1.56

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/index.esm.js CHANGED
@@ -743,6 +743,7 @@ function getActiveSubModule(pathname, modules) {
743
743
  }
744
744
  /** Prepend `code` (org code) to a relative URL so `/sales` → `/O25.../sales`.
745
745
  * Absolute `http(s)://` URLs are left intact; optional `{code}` placeholder is replaced.
746
+ * Query/hash are preserved: `/?start=1` → `/O25...?start=1` (not `/O25.../?start=1`).
746
747
  */
747
748
  function buildUrlWithCode(code, url) {
748
749
  if (/^https?:\/\//i.test(url)) {
@@ -752,8 +753,13 @@ function buildUrlWithCode(code, url) {
752
753
  }
753
754
  if (!code)
754
755
  return url;
755
- const cleanUrl = url.startsWith("/") ? url.slice(1) : url;
756
- return `/${code}/${cleanUrl}`;
756
+ const match = url.match(/^([^?#]*)(\?[^#]*)?(#.*)?$/);
757
+ const path = match?.[1] ?? url;
758
+ const query = match?.[2] ?? "";
759
+ const hash = match?.[3] ?? "";
760
+ const cleanPath = path.startsWith("/") ? path.slice(1) : path;
761
+ const base = cleanPath ? `/${code}/${cleanPath}` : `/${code}`;
762
+ return `${base}${query}${hash}`;
757
763
  }
758
764
 
759
765
  function NavTools({ tools, closeOnNavigation = false }) {
@@ -1844,10 +1850,14 @@ function NavMain({ items, orgCode, closeOnNavigation = false, approvalCounts, ch
1844
1850
  !!item.subModules?.some(subItem => subItem.subPages?.some(subPage => isPathActive(pathname, buildUrlWithCode(code, subPage.url)) ||
1845
1851
  isPathActive(pathname, subPage.url)));
1846
1852
  // Parent only active when path matches its URL exactly AND no child
1847
- // is active (so parent+child don't both light up).
1848
- const isItemActive = (highlightActiveModule && !item.subModules?.length && !!item.isActive) ||
1849
- ((workspace ? samePage(pathname, itemUrl) : pathname === itemUrl) &&
1850
- !hasActiveSubItem);
1853
+ // is active (so parent+child don't both light up). When the app opts
1854
+ // into highlightActiveModule, leaf items trust `item.isActive` alone —
1855
+ // needed for query-only hub actions (`/?start=1`) that share a path
1856
+ // with another leaf (e.g. "แอปของฉัน" at `/`).
1857
+ const isItemActive = highlightActiveModule && !item.subModules?.length
1858
+ ? !!item.isActive
1859
+ : (workspace ? samePage(pathname, itemUrl) : pathname === itemUrl) &&
1860
+ !hasActiveSubItem;
1851
1861
  return { itemUrl, activeSubItemUrl, hasActiveSubItem, isItemActive };
1852
1862
  });
1853
1863
  // A group opens when its page becomes current and otherwise stays as the