@greatapps/common 1.1.419 → 1.1.420
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/components/navigation/NavItem.mjs +6 -7
- package/dist/components/navigation/NavItem.mjs.map +1 -1
- package/dist/components/navigation/shells/TabsMobileShell.mjs +4 -2
- package/dist/components/navigation/shells/TabsMobileShell.mjs.map +1 -1
- package/dist/components/navigation/subcomponents/NavItems.mjs +1 -4
- package/dist/components/navigation/subcomponents/NavItems.mjs.map +1 -1
- package/package.json +1 -1
- package/src/components/navigation/NavItem.tsx +9 -11
- package/src/components/navigation/shells/TabsMobileShell.tsx +6 -4
- package/src/components/navigation/subcomponents/NavItems.tsx +1 -3
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import Link from "next/link";
|
|
3
4
|
import { useAppNavigationContext } from "./AppNavigationContext";
|
|
4
5
|
import { useMobileNavbarSheet } from "../../store/useMobileNavbarSheet";
|
|
5
6
|
import { useMdSidebarStore } from "../../store/useMdSidebarStore";
|
|
6
|
-
function NavItem({ icon: Icon, label, href,
|
|
7
|
+
function NavItem({ icon: Icon, label, href, isActive = false }) {
|
|
7
8
|
const { breakpoint } = useAppNavigationContext();
|
|
8
9
|
const { close } = useMobileNavbarSheet();
|
|
9
10
|
const { collapse } = useMdSidebarStore();
|
|
10
|
-
const handleClick = (
|
|
11
|
-
if (e.metaKey || e.ctrlKey || e.shiftKey || e.button === 1) return;
|
|
12
|
-
e.preventDefault();
|
|
13
|
-
onClick();
|
|
11
|
+
const handleClick = () => {
|
|
14
12
|
if (breakpoint === "mobile") {
|
|
15
13
|
close();
|
|
16
14
|
} else if (breakpoint === "md") {
|
|
@@ -18,9 +16,10 @@ function NavItem({ icon: Icon, label, href, onClick, isActive = false }) {
|
|
|
18
16
|
}
|
|
19
17
|
};
|
|
20
18
|
return /* @__PURE__ */ jsxs(
|
|
21
|
-
|
|
19
|
+
Link,
|
|
22
20
|
{
|
|
23
|
-
href
|
|
21
|
+
href,
|
|
22
|
+
prefetch: true,
|
|
24
23
|
className: `rounded-md flex items-center gap-2 p-3 cursor-pointer transition-colors no-underline ${isActive ? "bg-gray-50" : "bg-white hover:bg-gray-100"} active:bg-gray-50`,
|
|
25
24
|
onClick: handleClick,
|
|
26
25
|
children: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/navigation/NavItem.tsx"],"sourcesContent":["'use client';\r\n\r\nimport { ElementType
|
|
1
|
+
{"version":3,"sources":["../../../src/components/navigation/NavItem.tsx"],"sourcesContent":["'use client';\r\n\r\nimport { ElementType } from 'react';\r\nimport Link from 'next/link';\r\nimport { useAppNavigationContext } from './AppNavigationContext';\r\nimport { useMobileNavbarSheet } from '../../store/useMobileNavbarSheet';\r\nimport { useMdSidebarStore } from '../../store/useMdSidebarStore';\r\n\r\ninterface NavItemProps {\r\n icon?: ElementType;\r\n label: string;\r\n href: string;\r\n isActive?: boolean;\r\n}\r\n\r\nexport function NavItem({ icon: Icon, label, href, isActive = false }: NavItemProps) {\r\n const { breakpoint } = useAppNavigationContext();\r\n const { close } = useMobileNavbarSheet();\r\n const { collapse } = useMdSidebarStore();\r\n\r\n const handleClick = () => {\r\n if (breakpoint === 'mobile') {\r\n close();\r\n } else if (breakpoint === 'md') {\r\n collapse();\r\n }\r\n };\r\n\r\n return (\r\n <Link\r\n href={href}\r\n prefetch\r\n className={`rounded-md flex items-center gap-2 p-3 cursor-pointer transition-colors no-underline ${\r\n isActive ? 'bg-gray-50' : 'bg-white hover:bg-gray-100'\r\n } active:bg-gray-50`}\r\n onClick={handleClick}\r\n >\r\n {Icon && (\r\n <Icon\r\n size={20}\r\n className={isActive ? 'text-gray-950' : 'text-gray-400'}\r\n />\r\n )}\r\n <span className={`paragraph-small-medium ${isActive ? 'text-gray-950' : 'text-gray-500'}`}>\r\n {label}\r\n </span>\r\n </Link>\r\n );\r\n}\r\n"],"mappings":";AA6BI,SASI,KATJ;AA1BJ,OAAO,UAAU;AACjB,SAAS,+BAA+B;AACxC,SAAS,4BAA4B;AACrC,SAAS,yBAAyB;AAS3B,SAAS,QAAQ,EAAE,MAAM,MAAM,OAAO,MAAM,WAAW,MAAM,GAAiB;AACnF,QAAM,EAAE,WAAW,IAAI,wBAAwB;AAC/C,QAAM,EAAE,MAAM,IAAI,qBAAqB;AACvC,QAAM,EAAE,SAAS,IAAI,kBAAkB;AAEvC,QAAM,cAAc,MAAM;AACxB,QAAI,eAAe,UAAU;AAC3B,YAAM;AAAA,IACR,WAAW,eAAe,MAAM;AAC9B,eAAS;AAAA,IACX;AAAA,EACF;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA,UAAQ;AAAA,MACR,WAAW,wFACT,WAAW,eAAe,4BAC5B;AAAA,MACA,SAAS;AAAA,MAER;AAAA,gBACC;AAAA,UAAC;AAAA;AAAA,YACC,MAAM;AAAA,YACN,WAAW,WAAW,kBAAkB;AAAA;AAAA,QAC1C;AAAA,QAEF,oBAAC,UAAK,WAAW,0BAA0B,WAAW,kBAAkB,eAAe,IACpF,iBACH;AAAA;AAAA;AAAA,EACF;AAEJ;","names":[]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useRef, useEffect } from "react";
|
|
4
|
+
import Link from "next/link";
|
|
4
5
|
import { AppNavigationContext } from "../AppNavigationContext";
|
|
5
6
|
import { useNavItemsContext } from "../NavItemsContext";
|
|
6
7
|
function InternalTabsBar({ topOffset = "72px" }) {
|
|
@@ -26,10 +27,11 @@ function InternalTabsBar({ topOffset = "72px" }) {
|
|
|
26
27
|
className: "md:hidden fixed left-0 right-0 z-40 bg-white border-b border-gray-200 flex overflow-x-auto scrollbar-hide",
|
|
27
28
|
style: { top: topOffset },
|
|
28
29
|
children: navItems.map((item) => /* @__PURE__ */ jsxs(
|
|
29
|
-
|
|
30
|
+
Link,
|
|
30
31
|
{
|
|
31
32
|
ref: item.isActive ? activeTabRef : void 0,
|
|
32
|
-
|
|
33
|
+
href: item.href,
|
|
34
|
+
prefetch: true,
|
|
33
35
|
className: `flex items-center gap-2 px-4 py-3 shrink-0 border-b-2 transition-colors ${item.isActive ? "border-gray-950 text-gray-950" : "border-transparent text-gray-500 hover:text-gray-900"}`,
|
|
34
36
|
children: [
|
|
35
37
|
item.icon && /* @__PURE__ */ jsx(item.icon, { size: 16, className: "shrink-0" }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/navigation/shells/TabsMobileShell.tsx"],"sourcesContent":["'use client';\n\nimport { ReactNode, useRef, useEffect } from 'react';\nimport { AppNavigationContext } from '../AppNavigationContext';\nimport { useNavItemsContext } from '../NavItemsContext';\n\nfunction InternalTabsBar({ topOffset = '72px' }: { topOffset?: string }) {\n const { navItems } = useNavItemsContext();\n const tabsListRef = useRef<HTMLDivElement>(null);\n const activeTabRef = useRef<
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/navigation/shells/TabsMobileShell.tsx"],"sourcesContent":["'use client';\n\nimport { ReactNode, useRef, useEffect } from 'react';\nimport Link from 'next/link';\nimport { AppNavigationContext } from '../AppNavigationContext';\nimport { useNavItemsContext } from '../NavItemsContext';\n\nfunction InternalTabsBar({ topOffset = '72px' }: { topOffset?: string }) {\n const { navItems } = useNavItemsContext();\n const tabsListRef = useRef<HTMLDivElement>(null);\n const activeTabRef = useRef<HTMLAnchorElement>(null);\n\n const activeLabel = navItems.find((i) => i.isActive)?.label;\n\n // Scroll active tab into center when active item changes\n useEffect(() => {\n if (activeTabRef.current && tabsListRef.current) {\n const tabsList = tabsListRef.current;\n const activeTabElement = activeTabRef.current;\n const tabsListRect = tabsList.getBoundingClientRect();\n const activeTabRect = activeTabElement.getBoundingClientRect();\n const scrollLeft =\n activeTabElement.offsetLeft - tabsListRect.width / 2 + activeTabRect.width / 2;\n tabsList.scrollTo({ left: Math.max(0, scrollLeft), behavior: 'smooth' });\n }\n }, [activeLabel]);\n\n if (!navItems.length) return null;\n\n return (\n <div\n ref={tabsListRef}\n className=\"md:hidden fixed left-0 right-0 z-40 bg-white border-b border-gray-200 flex overflow-x-auto scrollbar-hide\"\n style={{ top: topOffset }}\n >\n {navItems.map((item) => (\n <Link\n key={item.label}\n ref={item.isActive ? activeTabRef : undefined}\n href={item.href}\n prefetch\n className={`flex items-center gap-2 px-4 py-3 shrink-0 border-b-2 transition-colors ${\n item.isActive\n ? 'border-gray-950 text-gray-950'\n : 'border-transparent text-gray-500 hover:text-gray-900'\n }`}\n >\n {item.icon && <item.icon size={16} className=\"shrink-0\" />}\n <span\n className={\n item.isActive ? 'paragraph-small-semibold' : 'paragraph-small-medium'\n }\n >\n {item.label}\n </span>\n </Link>\n ))}\n </div>\n );\n}\n\nexport function TabsMobileShell({ children, topOffset }: { children: ReactNode; topOffset?: string }) {\n return (\n <AppNavigationContext.Provider value={{ breakpoint: 'mobile' }}>\n {/*\n Children are hidden visually, but NavItems' useEffect still fires inside\n display:none — React effects are tied to commit phase, not layout visibility.\n This registers navItems in NavItemsContext so InternalTabsBar can read them.\n */}\n <div className=\"hidden\">{children}</div>\n <InternalTabsBar topOffset={topOffset} />\n </AppNavigationContext.Provider>\n );\n}\n"],"mappings":";AAoCQ,SAWgB,KAXhB;AAlCR,SAAoB,QAAQ,iBAAiB;AAC7C,OAAO,UAAU;AACjB,SAAS,4BAA4B;AACrC,SAAS,0BAA0B;AAEnC,SAAS,gBAAgB,EAAE,YAAY,OAAO,GAA2B;AACvE,QAAM,EAAE,SAAS,IAAI,mBAAmB;AACxC,QAAM,cAAc,OAAuB,IAAI;AAC/C,QAAM,eAAe,OAA0B,IAAI;AAEnD,QAAM,cAAc,SAAS,KAAK,CAAC,MAAM,EAAE,QAAQ,GAAG;AAGtD,YAAU,MAAM;AACd,QAAI,aAAa,WAAW,YAAY,SAAS;AAC/C,YAAM,WAAW,YAAY;AAC7B,YAAM,mBAAmB,aAAa;AACtC,YAAM,eAAe,SAAS,sBAAsB;AACpD,YAAM,gBAAgB,iBAAiB,sBAAsB;AAC7D,YAAM,aACJ,iBAAiB,aAAa,aAAa,QAAQ,IAAI,cAAc,QAAQ;AAC/E,eAAS,SAAS,EAAE,MAAM,KAAK,IAAI,GAAG,UAAU,GAAG,UAAU,SAAS,CAAC;AAAA,IACzE;AAAA,EACF,GAAG,CAAC,WAAW,CAAC;AAEhB,MAAI,CAAC,SAAS,OAAQ,QAAO;AAE7B,SACE;AAAA,IAAC;AAAA;AAAA,MACC,KAAK;AAAA,MACL,WAAU;AAAA,MACV,OAAO,EAAE,KAAK,UAAU;AAAA,MAEvB,mBAAS,IAAI,CAAC,SACb;AAAA,QAAC;AAAA;AAAA,UAEC,KAAK,KAAK,WAAW,eAAe;AAAA,UACpC,MAAM,KAAK;AAAA,UACX,UAAQ;AAAA,UACR,WAAW,2EACT,KAAK,WACD,kCACA,sDACN;AAAA,UAEC;AAAA,iBAAK,QAAQ,oBAAC,KAAK,MAAL,EAAU,MAAM,IAAI,WAAU,YAAW;AAAA,YACxD;AAAA,cAAC;AAAA;AAAA,gBACC,WACE,KAAK,WAAW,6BAA6B;AAAA,gBAG9C,eAAK;AAAA;AAAA,YACR;AAAA;AAAA;AAAA,QAjBK,KAAK;AAAA,MAkBZ,CACD;AAAA;AAAA,EACH;AAEJ;AAEO,SAAS,gBAAgB,EAAE,UAAU,UAAU,GAAgD;AACpG,SACE,qBAAC,qBAAqB,UAArB,EAA8B,OAAO,EAAE,YAAY,SAAS,GAM3D;AAAA,wBAAC,SAAI,WAAU,UAAU,UAAS;AAAA,IAClC,oBAAC,mBAAgB,WAAsB;AAAA,KACzC;AAEJ;","names":[]}
|
|
@@ -3,9 +3,7 @@ import { jsx } from "react/jsx-runtime";
|
|
|
3
3
|
import { useEffect } from "react";
|
|
4
4
|
import { NavItem } from "../NavItem";
|
|
5
5
|
import { useNavItemsContext } from "../NavItemsContext";
|
|
6
|
-
import { useRouter } from "next/navigation";
|
|
7
6
|
function NavItems({ items }) {
|
|
8
|
-
const router = useRouter();
|
|
9
7
|
const { setNavItems } = useNavItemsContext();
|
|
10
8
|
useEffect(() => {
|
|
11
9
|
setNavItems(items);
|
|
@@ -16,8 +14,7 @@ function NavItems({ items }) {
|
|
|
16
14
|
label: item.label,
|
|
17
15
|
icon: item.icon,
|
|
18
16
|
href: item.href,
|
|
19
|
-
isActive: item.isActive
|
|
20
|
-
onClick: () => router.push(item.href ?? "")
|
|
17
|
+
isActive: item.isActive
|
|
21
18
|
},
|
|
22
19
|
item.label
|
|
23
20
|
)) });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/navigation/subcomponents/NavItems.tsx"],"sourcesContent":["'use client';\r\n\r\nimport { ElementType, useEffect } from 'react';\r\nimport { NavItem } from '../NavItem';\r\nimport { useNavItemsContext } from '../NavItemsContext';\r\nimport { useRouter } from 'next/navigation';\r\n\r\nexport interface NavItemConfig {\r\n label: string;\r\n isActive: boolean;\r\n icon: ElementType;\r\n href
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/navigation/subcomponents/NavItems.tsx"],"sourcesContent":["'use client';\r\n\r\nimport { ElementType, useEffect } from 'react';\r\nimport { NavItem } from '../NavItem';\r\nimport { useNavItemsContext } from '../NavItemsContext';\r\nimport { useRouter } from 'next/navigation';\r\n\r\nexport interface NavItemConfig {\r\n label: string;\r\n isActive: boolean;\r\n icon: ElementType;\r\n href: string;\r\n}\r\n\r\ninterface NavItemsProps {\r\n items: NavItemConfig[];\r\n}\r\n\r\nexport function NavItems({ items }: NavItemsProps) {\r\n const { setNavItems } = useNavItemsContext();\r\n\r\n useEffect(() => {\r\n setNavItems(items);\r\n }, [items, setNavItems]);\r\n\r\n return (\r\n <div className=\"flex flex-col\">\r\n {items.map((item) => (\r\n <NavItem\r\n key={item.label}\r\n label={item.label}\r\n icon={item.icon}\r\n href={item.href}\r\n isActive={item.isActive}\r\n />\r\n ))}\r\n </div>\r\n );\r\n}\r\n"],"mappings":";AA4BQ;AA1BR,SAAsB,iBAAiB;AACvC,SAAS,eAAe;AACxB,SAAS,0BAA0B;AAc5B,SAAS,SAAS,EAAE,MAAM,GAAkB;AACjD,QAAM,EAAE,YAAY,IAAI,mBAAmB;AAE3C,YAAU,MAAM;AACd,gBAAY,KAAK;AAAA,EACnB,GAAG,CAAC,OAAO,WAAW,CAAC;AAEvB,SACE,oBAAC,SAAI,WAAU,iBACZ,gBAAM,IAAI,CAAC,SACV;AAAA,IAAC;AAAA;AAAA,MAEC,OAAO,KAAK;AAAA,MACZ,MAAM,KAAK;AAAA,MACX,MAAM,KAAK;AAAA,MACX,UAAU,KAAK;AAAA;AAAA,IAJV,KAAK;AAAA,EAKZ,CACD,GACH;AAEJ;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import { ElementType
|
|
3
|
+
import { ElementType } from 'react';
|
|
4
|
+
import Link from 'next/link';
|
|
4
5
|
import { useAppNavigationContext } from './AppNavigationContext';
|
|
5
6
|
import { useMobileNavbarSheet } from '../../store/useMobileNavbarSheet';
|
|
6
7
|
import { useMdSidebarStore } from '../../store/useMdSidebarStore';
|
|
@@ -8,20 +9,16 @@ import { useMdSidebarStore } from '../../store/useMdSidebarStore';
|
|
|
8
9
|
interface NavItemProps {
|
|
9
10
|
icon?: ElementType;
|
|
10
11
|
label: string;
|
|
11
|
-
href
|
|
12
|
-
onClick: () => void;
|
|
12
|
+
href: string;
|
|
13
13
|
isActive?: boolean;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export function NavItem({ icon: Icon, label, href,
|
|
16
|
+
export function NavItem({ icon: Icon, label, href, isActive = false }: NavItemProps) {
|
|
17
17
|
const { breakpoint } = useAppNavigationContext();
|
|
18
18
|
const { close } = useMobileNavbarSheet();
|
|
19
19
|
const { collapse } = useMdSidebarStore();
|
|
20
20
|
|
|
21
|
-
const handleClick = (
|
|
22
|
-
if (e.metaKey || e.ctrlKey || e.shiftKey || e.button === 1) return;
|
|
23
|
-
e.preventDefault();
|
|
24
|
-
onClick();
|
|
21
|
+
const handleClick = () => {
|
|
25
22
|
if (breakpoint === 'mobile') {
|
|
26
23
|
close();
|
|
27
24
|
} else if (breakpoint === 'md') {
|
|
@@ -30,8 +27,9 @@ export function NavItem({ icon: Icon, label, href, onClick, isActive = false }:
|
|
|
30
27
|
};
|
|
31
28
|
|
|
32
29
|
return (
|
|
33
|
-
<
|
|
34
|
-
href={href
|
|
30
|
+
<Link
|
|
31
|
+
href={href}
|
|
32
|
+
prefetch
|
|
35
33
|
className={`rounded-md flex items-center gap-2 p-3 cursor-pointer transition-colors no-underline ${
|
|
36
34
|
isActive ? 'bg-gray-50' : 'bg-white hover:bg-gray-100'
|
|
37
35
|
} active:bg-gray-50`}
|
|
@@ -46,6 +44,6 @@ export function NavItem({ icon: Icon, label, href, onClick, isActive = false }:
|
|
|
46
44
|
<span className={`paragraph-small-medium ${isActive ? 'text-gray-950' : 'text-gray-500'}`}>
|
|
47
45
|
{label}
|
|
48
46
|
</span>
|
|
49
|
-
</
|
|
47
|
+
</Link>
|
|
50
48
|
);
|
|
51
49
|
}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { ReactNode, useRef, useEffect } from 'react';
|
|
4
|
+
import Link from 'next/link';
|
|
4
5
|
import { AppNavigationContext } from '../AppNavigationContext';
|
|
5
6
|
import { useNavItemsContext } from '../NavItemsContext';
|
|
6
7
|
|
|
7
8
|
function InternalTabsBar({ topOffset = '72px' }: { topOffset?: string }) {
|
|
8
9
|
const { navItems } = useNavItemsContext();
|
|
9
10
|
const tabsListRef = useRef<HTMLDivElement>(null);
|
|
10
|
-
const activeTabRef = useRef<
|
|
11
|
+
const activeTabRef = useRef<HTMLAnchorElement>(null);
|
|
11
12
|
|
|
12
13
|
const activeLabel = navItems.find((i) => i.isActive)?.label;
|
|
13
14
|
|
|
@@ -33,10 +34,11 @@ function InternalTabsBar({ topOffset = '72px' }: { topOffset?: string }) {
|
|
|
33
34
|
style={{ top: topOffset }}
|
|
34
35
|
>
|
|
35
36
|
{navItems.map((item) => (
|
|
36
|
-
<
|
|
37
|
+
<Link
|
|
37
38
|
key={item.label}
|
|
38
39
|
ref={item.isActive ? activeTabRef : undefined}
|
|
39
|
-
|
|
40
|
+
href={item.href}
|
|
41
|
+
prefetch
|
|
40
42
|
className={`flex items-center gap-2 px-4 py-3 shrink-0 border-b-2 transition-colors ${
|
|
41
43
|
item.isActive
|
|
42
44
|
? 'border-gray-950 text-gray-950'
|
|
@@ -51,7 +53,7 @@ function InternalTabsBar({ topOffset = '72px' }: { topOffset?: string }) {
|
|
|
51
53
|
>
|
|
52
54
|
{item.label}
|
|
53
55
|
</span>
|
|
54
|
-
</
|
|
56
|
+
</Link>
|
|
55
57
|
))}
|
|
56
58
|
</div>
|
|
57
59
|
);
|
|
@@ -9,7 +9,7 @@ export interface NavItemConfig {
|
|
|
9
9
|
label: string;
|
|
10
10
|
isActive: boolean;
|
|
11
11
|
icon: ElementType;
|
|
12
|
-
href
|
|
12
|
+
href: string;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
interface NavItemsProps {
|
|
@@ -17,7 +17,6 @@ interface NavItemsProps {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
export function NavItems({ items }: NavItemsProps) {
|
|
20
|
-
const router = useRouter();
|
|
21
20
|
const { setNavItems } = useNavItemsContext();
|
|
22
21
|
|
|
23
22
|
useEffect(() => {
|
|
@@ -33,7 +32,6 @@ export function NavItems({ items }: NavItemsProps) {
|
|
|
33
32
|
icon={item.icon}
|
|
34
33
|
href={item.href}
|
|
35
34
|
isActive={item.isActive}
|
|
36
|
-
onClick={() => router.push(item.href ?? '')}
|
|
37
35
|
/>
|
|
38
36
|
))}
|
|
39
37
|
</div>
|