@marcoschwartz/lite-ui 0.25.2 → 0.25.3
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.d.mts +7 -3
- package/dist/index.d.ts +7 -3
- package/dist/index.js +34 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +34 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -68,9 +68,13 @@ interface SidebarNavProps {
|
|
|
68
68
|
collapsible?: boolean;
|
|
69
69
|
defaultCollapsed?: boolean;
|
|
70
70
|
collapsed?: boolean;
|
|
71
|
-
onCollapseChange?: (collapsed: boolean) => void;
|
|
71
|
+
onCollapseChange?: (collapsed: boolean, width: number) => void;
|
|
72
72
|
storageKey?: string;
|
|
73
73
|
className?: string;
|
|
74
|
+
/** Width in pixels when expanded (default: 256) */
|
|
75
|
+
expandedWidth?: number;
|
|
76
|
+
/** Width in pixels when collapsed (default: 64) */
|
|
77
|
+
collapsedWidth?: number;
|
|
74
78
|
}
|
|
75
79
|
interface SidebarNavItemProps {
|
|
76
80
|
/** Icon element (alias: leftSection) */
|
|
@@ -155,7 +159,7 @@ interface AppShellHeaderConfig {
|
|
|
155
159
|
}
|
|
156
160
|
interface AppShellNavbarConfig {
|
|
157
161
|
content: React.ReactNode;
|
|
158
|
-
width?: 'sm' | 'md' | 'lg';
|
|
162
|
+
width?: 'sm' | 'md' | 'lg' | number;
|
|
159
163
|
breakpoint?: 'sm' | 'md' | 'lg' | 'xl';
|
|
160
164
|
variant?: 'solid' | 'glass' | 'transparent';
|
|
161
165
|
collapsed?: {
|
|
@@ -166,7 +170,7 @@ interface AppShellNavbarConfig {
|
|
|
166
170
|
}
|
|
167
171
|
interface AppShellAsideConfig {
|
|
168
172
|
content: React.ReactNode;
|
|
169
|
-
width?: 'sm' | 'md' | 'lg';
|
|
173
|
+
width?: 'sm' | 'md' | 'lg' | number;
|
|
170
174
|
breakpoint?: 'sm' | 'md' | 'lg' | 'xl';
|
|
171
175
|
variant?: 'solid' | 'glass' | 'transparent';
|
|
172
176
|
collapsed?: {
|
package/dist/index.d.ts
CHANGED
|
@@ -68,9 +68,13 @@ interface SidebarNavProps {
|
|
|
68
68
|
collapsible?: boolean;
|
|
69
69
|
defaultCollapsed?: boolean;
|
|
70
70
|
collapsed?: boolean;
|
|
71
|
-
onCollapseChange?: (collapsed: boolean) => void;
|
|
71
|
+
onCollapseChange?: (collapsed: boolean, width: number) => void;
|
|
72
72
|
storageKey?: string;
|
|
73
73
|
className?: string;
|
|
74
|
+
/** Width in pixels when expanded (default: 256) */
|
|
75
|
+
expandedWidth?: number;
|
|
76
|
+
/** Width in pixels when collapsed (default: 64) */
|
|
77
|
+
collapsedWidth?: number;
|
|
74
78
|
}
|
|
75
79
|
interface SidebarNavItemProps {
|
|
76
80
|
/** Icon element (alias: leftSection) */
|
|
@@ -155,7 +159,7 @@ interface AppShellHeaderConfig {
|
|
|
155
159
|
}
|
|
156
160
|
interface AppShellNavbarConfig {
|
|
157
161
|
content: React.ReactNode;
|
|
158
|
-
width?: 'sm' | 'md' | 'lg';
|
|
162
|
+
width?: 'sm' | 'md' | 'lg' | number;
|
|
159
163
|
breakpoint?: 'sm' | 'md' | 'lg' | 'xl';
|
|
160
164
|
variant?: 'solid' | 'glass' | 'transparent';
|
|
161
165
|
collapsed?: {
|
|
@@ -166,7 +170,7 @@ interface AppShellNavbarConfig {
|
|
|
166
170
|
}
|
|
167
171
|
interface AppShellAsideConfig {
|
|
168
172
|
content: React.ReactNode;
|
|
169
|
-
width?: 'sm' | 'md' | 'lg';
|
|
173
|
+
width?: 'sm' | 'md' | 'lg' | number;
|
|
170
174
|
breakpoint?: 'sm' | 'md' | 'lg' | 'xl';
|
|
171
175
|
variant?: 'solid' | 'glass' | 'transparent';
|
|
172
176
|
collapsed?: {
|
package/dist/index.js
CHANGED
|
@@ -779,33 +779,44 @@ var SidebarNav = ({
|
|
|
779
779
|
collapsed: controlledCollapsed,
|
|
780
780
|
onCollapseChange,
|
|
781
781
|
storageKey = "sidebar-nav-collapsed",
|
|
782
|
-
className = ""
|
|
782
|
+
className = "",
|
|
783
|
+
expandedWidth = 256,
|
|
784
|
+
collapsedWidth = 64
|
|
783
785
|
}) => {
|
|
784
786
|
const [internalCollapsed, setInternalCollapsed] = (0, import_react4.useState)(defaultCollapsed);
|
|
785
787
|
const [mounted, setMounted] = (0, import_react4.useState)(false);
|
|
786
788
|
const isControlled = controlledCollapsed !== void 0;
|
|
787
789
|
const collapsed = isControlled ? controlledCollapsed : internalCollapsed;
|
|
790
|
+
const currentWidth = collapsible && collapsed ? collapsedWidth : expandedWidth;
|
|
788
791
|
(0, import_react4.useEffect)(() => {
|
|
789
792
|
setMounted(true);
|
|
790
793
|
if (!isControlled && collapsible && typeof window !== "undefined") {
|
|
791
794
|
const stored = localStorage.getItem(storageKey);
|
|
792
795
|
if (stored !== null) {
|
|
793
|
-
|
|
796
|
+
const isCollapsed = stored === "true";
|
|
797
|
+
setInternalCollapsed(isCollapsed);
|
|
798
|
+
onCollapseChange?.(isCollapsed, isCollapsed ? collapsedWidth : expandedWidth);
|
|
794
799
|
}
|
|
795
800
|
}
|
|
796
801
|
}, [isControlled, collapsible, storageKey]);
|
|
802
|
+
(0, import_react4.useEffect)(() => {
|
|
803
|
+
if (mounted && collapsible) {
|
|
804
|
+
onCollapseChange?.(collapsed, currentWidth);
|
|
805
|
+
}
|
|
806
|
+
}, [mounted]);
|
|
797
807
|
const setCollapsed = (0, import_react4.useCallback)((value) => {
|
|
798
808
|
if (!collapsible) return;
|
|
809
|
+
const newWidth = value ? collapsedWidth : expandedWidth;
|
|
799
810
|
if (isControlled) {
|
|
800
|
-
onCollapseChange?.(value);
|
|
811
|
+
onCollapseChange?.(value, newWidth);
|
|
801
812
|
} else {
|
|
802
813
|
setInternalCollapsed(value);
|
|
803
814
|
if (typeof window !== "undefined") {
|
|
804
815
|
localStorage.setItem(storageKey, String(value));
|
|
805
816
|
}
|
|
817
|
+
onCollapseChange?.(value, newWidth);
|
|
806
818
|
}
|
|
807
|
-
|
|
808
|
-
}, [collapsible, isControlled, onCollapseChange, storageKey]);
|
|
819
|
+
}, [collapsible, isControlled, onCollapseChange, storageKey, collapsedWidth, expandedWidth]);
|
|
809
820
|
const toggleCollapsed = (0, import_react4.useCallback)(() => {
|
|
810
821
|
setCollapsed(!collapsed);
|
|
811
822
|
}, [collapsed, setCollapsed]);
|
|
@@ -814,16 +825,15 @@ var SidebarNav = ({
|
|
|
814
825
|
setCollapsed,
|
|
815
826
|
toggleCollapsed
|
|
816
827
|
};
|
|
817
|
-
const widthClass = collapsible && collapsed ? "w-16" : "w-64";
|
|
818
828
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(SidebarNavContext.Provider, { value: contextValue, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
819
829
|
"nav",
|
|
820
830
|
{
|
|
821
831
|
className: `
|
|
822
|
-
flex flex-col h-full
|
|
823
|
-
${widthClass}
|
|
832
|
+
flex flex-col h-full overflow-hidden
|
|
824
833
|
transition-[width] duration-200 ease-in-out
|
|
825
834
|
${className}
|
|
826
835
|
`,
|
|
836
|
+
style: { width: currentWidth },
|
|
827
837
|
"data-collapsed": collapsed,
|
|
828
838
|
children
|
|
829
839
|
}
|
|
@@ -1648,6 +1658,14 @@ var widthClasses2 = {
|
|
|
1648
1658
|
lg: "w-80"
|
|
1649
1659
|
// 320px
|
|
1650
1660
|
};
|
|
1661
|
+
var getWidthClass = (width) => {
|
|
1662
|
+
if (typeof width === "number") return "";
|
|
1663
|
+
return widthClasses2[width || "md"];
|
|
1664
|
+
};
|
|
1665
|
+
var getWidthStyle = (width) => {
|
|
1666
|
+
if (typeof width === "number") return { width, transition: "width 200ms ease-in-out" };
|
|
1667
|
+
return {};
|
|
1668
|
+
};
|
|
1651
1669
|
var paddingClasses = {
|
|
1652
1670
|
none: "p-0",
|
|
1653
1671
|
sm: "p-2",
|
|
@@ -1790,7 +1808,8 @@ var AppShell = ({
|
|
|
1790
1808
|
navbar && !navbarCollapsedDesktop && /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)(
|
|
1791
1809
|
"aside",
|
|
1792
1810
|
{
|
|
1793
|
-
className: `${navbarDesktopShowClass} ${
|
|
1811
|
+
className: `${navbarDesktopShowClass} ${getWidthClass(navbarWidth)} ${getVariantClasses(navbarVariant, navbarWithBorder)} ${navbarWithBorder ? "border-r" : ""} flex-col shrink-0`,
|
|
1812
|
+
style: getWidthStyle(navbarWidth),
|
|
1794
1813
|
children: [
|
|
1795
1814
|
(logo || title) && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("div", { className: `${heightClasses[headerHeight]} px-4 flex items-center border-b border-[hsl(var(--border))] shrink-0`, children: logo || /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("span", { className: "text-xl font-bold text-[hsl(var(--foreground))]", children: title }) }),
|
|
1796
1815
|
/* @__PURE__ */ (0, import_jsx_runtime79.jsx)("nav", { className: "flex-1 overflow-y-auto", children: navbar.content })
|
|
@@ -1837,7 +1856,8 @@ var AppShell = ({
|
|
|
1837
1856
|
aside && !asideCollapsedDesktop && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
|
|
1838
1857
|
"aside",
|
|
1839
1858
|
{
|
|
1840
|
-
className: `${asideDesktopShowClass} ${
|
|
1859
|
+
className: `${asideDesktopShowClass} ${getWidthClass(asideWidth)} ${getVariantClasses(asideVariant, asideWithBorder)} ${asideWithBorder ? "border-l" : ""} flex-col shrink-0 overflow-y-auto`,
|
|
1860
|
+
style: getWidthStyle(asideWidth),
|
|
1841
1861
|
children: aside.content
|
|
1842
1862
|
}
|
|
1843
1863
|
),
|
|
@@ -1919,7 +1939,8 @@ var AppShell = ({
|
|
|
1919
1939
|
navbar && !navbarCollapsedDesktop && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
|
|
1920
1940
|
"nav",
|
|
1921
1941
|
{
|
|
1922
|
-
className: `${navbarDesktopShowClass} ${
|
|
1942
|
+
className: `${navbarDesktopShowClass} ${getWidthClass(navbarWidth)} ${getVariantClasses(navbarVariant, navbarWithBorder)} ${navbarWithBorder ? "border-r" : ""} flex-col shrink-0 overflow-y-auto`,
|
|
1943
|
+
style: getWidthStyle(navbarWidth),
|
|
1923
1944
|
children: navbar.content
|
|
1924
1945
|
}
|
|
1925
1946
|
),
|
|
@@ -1927,7 +1948,8 @@ var AppShell = ({
|
|
|
1927
1948
|
aside && !asideCollapsedDesktop && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
|
|
1928
1949
|
"aside",
|
|
1929
1950
|
{
|
|
1930
|
-
className: `${asideDesktopShowClass} ${
|
|
1951
|
+
className: `${asideDesktopShowClass} ${getWidthClass(asideWidth)} ${getVariantClasses(asideVariant, asideWithBorder)} ${asideWithBorder ? "border-l" : ""} flex-col shrink-0 overflow-y-auto`,
|
|
1952
|
+
style: getWidthStyle(asideWidth),
|
|
1931
1953
|
children: aside.content
|
|
1932
1954
|
}
|
|
1933
1955
|
)
|