@net-advantage/nabs-ui-layout 0.44.0 → 0.45.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/README.md +11 -0
- package/dist/Layout.d.ts +1 -1
- package/dist/Layout.types.d.ts +3 -0
- package/dist/nabs-ui-layout.cjs +1 -1
- package/dist/nabs-ui-layout.css +1 -1
- package/dist/nabs-ui-layout.js +37 -26
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,6 +13,8 @@ export function Example() {
|
|
|
13
13
|
className="app-shell"
|
|
14
14
|
header={<div>Header</div>}
|
|
15
15
|
leftSidePanel={<div>Nav</div>}
|
|
16
|
+
leftSidePanelWidth="18rem"
|
|
17
|
+
rightSidePanelWidth="20rem"
|
|
16
18
|
footer={<div>Footer</div>}
|
|
17
19
|
>
|
|
18
20
|
<div>Main content</div>
|
|
@@ -21,6 +23,15 @@ export function Example() {
|
|
|
21
23
|
}
|
|
22
24
|
```
|
|
23
25
|
|
|
26
|
+
## Side Panel Widths
|
|
27
|
+
|
|
28
|
+
- `leftSidePanelWidth` and `rightSidePanelWidth` accept CSS length values (for example `"18rem"`, `"280px"`) or numbers (treated as pixels).
|
|
29
|
+
- When omitted, side panels use content-driven width.
|
|
30
|
+
- You can still tune defaults through CSS variables:
|
|
31
|
+
- `--nabs-ui-layout-left-panel-width`
|
|
32
|
+
- `--nabs-ui-layout-right-panel-width`
|
|
33
|
+
- `--nabs-ui-layout-side-panel-max-width`
|
|
34
|
+
|
|
24
35
|
## Styling
|
|
25
36
|
|
|
26
37
|
Use CSS to tune the shell and the slot regions:
|
package/dist/Layout.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { LayoutProps } from './Layout.types';
|
|
2
|
-
export declare function Layout({ header, footer, leftSidePanel, rightSidePanel, children, className, headerClassName, footerClassName, leftSidePanelClassName, rightSidePanelClassName, contentClassName, ...props }: LayoutProps): import("react").JSX.Element;
|
|
2
|
+
export declare function Layout({ header, footer, leftSidePanel, rightSidePanel, leftSidePanelWidth, rightSidePanelWidth, children, className, headerClassName, footerClassName, leftSidePanelClassName, rightSidePanelClassName, contentClassName, style, ...props }: LayoutProps): import("react").JSX.Element;
|
package/dist/Layout.types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ComponentPropsWithoutRef, ReactNode } from 'react';
|
|
2
|
+
export type LayoutPanelWidth = string | number;
|
|
2
3
|
export interface LayoutSlotProps extends ComponentPropsWithoutRef<"div"> {
|
|
3
4
|
as?: "div" | "header" | "footer" | "aside" | "section";
|
|
4
5
|
}
|
|
@@ -7,6 +8,8 @@ export interface LayoutProps extends ComponentPropsWithoutRef<"div"> {
|
|
|
7
8
|
footer?: ReactNode;
|
|
8
9
|
leftSidePanel?: ReactNode;
|
|
9
10
|
rightSidePanel?: ReactNode;
|
|
11
|
+
leftSidePanelWidth?: LayoutPanelWidth;
|
|
12
|
+
rightSidePanelWidth?: LayoutPanelWidth;
|
|
10
13
|
children?: ReactNode;
|
|
11
14
|
headerClassName?: string;
|
|
12
15
|
footerClassName?: string;
|
package/dist/nabs-ui-layout.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("react/jsx-runtime");function t({as:t=`div`,className:n=``,children:r,...i}){return(0,e.jsx)(t,{className:n,...i,children:r})}function
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("react/jsx-runtime");function t(e){if(e==null)return;if(typeof e==`number`)return`${e}px`;let t=e.trim();return t.length>0?t:void 0}function n({as:t=`div`,className:n=``,children:r,...i}){return(0,e.jsx)(t,{className:n,...i,children:r})}function r({header:r,footer:i,leftSidePanel:a,rightSidePanel:o,leftSidePanelWidth:s,rightSidePanelWidth:c,children:l,className:u=``,headerClassName:d=``,footerClassName:f=``,leftSidePanelClassName:p=``,rightSidePanelClassName:m=``,contentClassName:h=``,style:g,..._}){let v=r!=null&&r!==!1,y=i!=null&&i!==!1,b=a!=null&&a!==!1,x=o!=null&&o!==!1,S=[`nabs-ui-layout__body`,b&&x?`nabs-ui-layout__body--with-both-panels`:``,b&&!x?`nabs-ui-layout__body--with-left-panel`:``,!b&&x?`nabs-ui-layout__body--with-right-panel`:``].filter(Boolean).join(` `),C=[`nabs-ui-layout`,u].filter(Boolean).join(` `),w=t(s),T=t(c);return(0,e.jsxs)(`div`,{className:C,style:{...g??{},...w?{"--nabs-ui-layout-left-panel-width":w}:{},...T?{"--nabs-ui-layout-right-panel-width":T}:{}},..._,children:[v?(0,e.jsx)(n,{as:`header`,className:`nabs-ui-layout__headerWrapper`,children:(0,e.jsx)(`div`,{className:[`nabs-ui-layout__header`,d].filter(Boolean).join(` `),children:r})}):null,(0,e.jsxs)(`div`,{className:S,children:[b?(0,e.jsx)(n,{as:`aside`,className:[`nabs-ui-layout__panel`,`nabs-ui-layout__panel--left`,p].filter(Boolean).join(` `),children:a}):null,(0,e.jsx)(n,{as:`section`,className:[`nabs-ui-layout__content`,h].filter(Boolean).join(` `),children:l}),x?(0,e.jsx)(n,{as:`aside`,className:[`nabs-ui-layout__panel`,`nabs-ui-layout__panel--right`,m].filter(Boolean).join(` `),children:o}):null]}),y?(0,e.jsx)(n,{as:`footer`,className:`nabs-ui-layout__footerWrapper`,children:(0,e.jsx)(`div`,{className:[`nabs-ui-layout__footer`,f].filter(Boolean).join(` `),children:i})}):null]})}exports.Layout=r;
|
package/dist/nabs-ui-layout.css
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
.nabs-ui-layout{gap:var(--nabs-ui-layout-gap,1rem);grid-template-rows:auto minmax(0,1fr) auto;width:100%;min-width:0;min-height:100%;display:grid}.nabs-ui-layout__headerWrapper,.nabs-ui-layout__footerWrapper{min-width:0}.nabs-ui-layout__header,.nabs-ui-layout__footer,.nabs-ui-layout__panel,.nabs-ui-layout__content{border:1px solid var(--nabs-ui-layout-border);border-radius:var(--nabs-ui-layout-radius,1rem);box-sizing:border-box;min-width:0}.nabs-ui-layout__header,.nabs-ui-layout__footer{padding:var(--nabs-ui-density-layout-chrome-padding-y,.75rem) var(--nabs-ui-density-layout-chrome-padding-x,.9rem)}.nabs-ui-layout__panel,.nabs-ui-layout__content{padding:var(--nabs-ui-density-layout-body-padding-y,1rem) var(--nabs-ui-density-layout-body-padding-x,1rem)}.nabs-ui-layout__header,.nabs-ui-layout__footer{background:var(--nabs-ui-layout-surface)}.nabs-ui-layout__footer{font-size:var(--nabs-ui-density-layout-footer-font-size,.76rem);line-height:var(--nabs-ui-density-layout-footer-line-height,1.25)}.nabs-ui-layout__body{gap:var(--nabs-ui-layout-gap,1rem);min-width:0;min-height:0;display:grid}.nabs-ui-layout__body--with-both-panels{grid-template-columns:max-content minmax(0,1fr) max-content}.nabs-ui-layout__body--with-left-panel{grid-template-columns:max-content minmax(0,1fr)}.nabs-ui-layout__body--with-right-panel{grid-template-columns:minmax(0,1fr) max-content}.nabs-ui-layout__panel{background:var(--nabs-ui-layout-panel-surface)}.nabs-ui-layout__content{background:var(--nabs-ui-layout-content-surface)}.nabs-ui-layout__content>:first-child{margin-top:0}.nabs-ui-layout__content>:last-child{margin-bottom:0}
|
|
1
|
+
.nabs-ui-layout{gap:var(--nabs-ui-layout-gap,1rem);grid-template-rows:auto minmax(0,1fr) auto;width:100%;min-width:0;min-height:100%;display:grid}.nabs-ui-layout__headerWrapper,.nabs-ui-layout__footerWrapper{min-width:0}.nabs-ui-layout__header,.nabs-ui-layout__footer,.nabs-ui-layout__panel,.nabs-ui-layout__content{border:1px solid var(--nabs-ui-layout-border);border-radius:var(--nabs-ui-layout-radius,1rem);box-sizing:border-box;min-width:0}.nabs-ui-layout__header,.nabs-ui-layout__footer{padding:var(--nabs-ui-density-layout-chrome-padding-y,.75rem) var(--nabs-ui-density-layout-chrome-padding-x,.9rem)}.nabs-ui-layout__panel,.nabs-ui-layout__content{padding:var(--nabs-ui-density-layout-body-padding-y,1rem) var(--nabs-ui-density-layout-body-padding-x,1rem)}.nabs-ui-layout__header,.nabs-ui-layout__footer{background:var(--nabs-ui-layout-surface)}.nabs-ui-layout__footer{font-size:var(--nabs-ui-density-layout-footer-font-size,.76rem);line-height:var(--nabs-ui-density-layout-footer-line-height,1.25)}.nabs-ui-layout__body{gap:var(--nabs-ui-layout-gap,1rem);min-width:0;min-height:0;display:grid}.nabs-ui-layout__body--with-both-panels{grid-template-columns:var(--nabs-ui-layout-left-panel-width,max-content) minmax(0, 1fr) var(--nabs-ui-layout-right-panel-width,max-content)}.nabs-ui-layout__body--with-left-panel{grid-template-columns:var(--nabs-ui-layout-left-panel-width,max-content) minmax(0, 1fr)}.nabs-ui-layout__body--with-right-panel{grid-template-columns:minmax(0, 1fr) var(--nabs-ui-layout-right-panel-width,max-content)}.nabs-ui-layout__panel{background:var(--nabs-ui-layout-panel-surface);max-inline-size:min(100%, var(--nabs-ui-layout-side-panel-max-width,22rem))}.nabs-ui-layout__content{background:var(--nabs-ui-layout-content-surface)}.nabs-ui-layout__content>:first-child{margin-top:0}.nabs-ui-layout__content>:last-child{margin-bottom:0}
|
|
2
2
|
/*$vite$:1*/
|
package/dist/nabs-ui-layout.js
CHANGED
|
@@ -1,69 +1,80 @@
|
|
|
1
1
|
import { jsx as e, jsxs as t } from "react/jsx-runtime";
|
|
2
2
|
//#region src/Layout.tsx
|
|
3
|
-
function n(
|
|
3
|
+
function n(e) {
|
|
4
|
+
if (e == null) return;
|
|
5
|
+
if (typeof e == "number") return `${e}px`;
|
|
6
|
+
let t = e.trim();
|
|
7
|
+
return t.length > 0 ? t : void 0;
|
|
8
|
+
}
|
|
9
|
+
function r({ as: t = "div", className: n = "", children: r, ...i }) {
|
|
4
10
|
return /* @__PURE__ */ e(t, {
|
|
5
11
|
className: n,
|
|
6
12
|
...i,
|
|
7
13
|
children: r
|
|
8
14
|
});
|
|
9
15
|
}
|
|
10
|
-
function
|
|
11
|
-
let
|
|
16
|
+
function i({ header: i, footer: a, leftSidePanel: o, rightSidePanel: s, leftSidePanelWidth: c, rightSidePanelWidth: l, children: u, className: d = "", headerClassName: f = "", footerClassName: p = "", leftSidePanelClassName: m = "", rightSidePanelClassName: h = "", contentClassName: g = "", style: _, ...v }) {
|
|
17
|
+
let y = i != null && i !== !1, b = a != null && a !== !1, x = o != null && o !== !1, S = s != null && s !== !1, C = [
|
|
12
18
|
"nabs-ui-layout__body",
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
!
|
|
16
|
-
].filter(Boolean).join(" ");
|
|
19
|
+
x && S ? "nabs-ui-layout__body--with-both-panels" : "",
|
|
20
|
+
x && !S ? "nabs-ui-layout__body--with-left-panel" : "",
|
|
21
|
+
!x && S ? "nabs-ui-layout__body--with-right-panel" : ""
|
|
22
|
+
].filter(Boolean).join(" "), w = ["nabs-ui-layout", d].filter(Boolean).join(" "), T = n(c), E = n(l);
|
|
17
23
|
return /* @__PURE__ */ t("div", {
|
|
18
|
-
className:
|
|
19
|
-
|
|
24
|
+
className: w,
|
|
25
|
+
style: {
|
|
26
|
+
..._ ?? {},
|
|
27
|
+
...T ? { "--nabs-ui-layout-left-panel-width": T } : {},
|
|
28
|
+
...E ? { "--nabs-ui-layout-right-panel-width": E } : {}
|
|
29
|
+
},
|
|
30
|
+
...v,
|
|
20
31
|
children: [
|
|
21
|
-
|
|
32
|
+
y ? /* @__PURE__ */ e(r, {
|
|
22
33
|
as: "header",
|
|
23
34
|
className: "nabs-ui-layout__headerWrapper",
|
|
24
35
|
children: /* @__PURE__ */ e("div", {
|
|
25
|
-
className: ["nabs-ui-layout__header",
|
|
26
|
-
children:
|
|
36
|
+
className: ["nabs-ui-layout__header", f].filter(Boolean).join(" "),
|
|
37
|
+
children: i
|
|
27
38
|
})
|
|
28
39
|
}) : null,
|
|
29
40
|
/* @__PURE__ */ t("div", {
|
|
30
|
-
className:
|
|
41
|
+
className: C,
|
|
31
42
|
children: [
|
|
32
|
-
|
|
43
|
+
x ? /* @__PURE__ */ e(r, {
|
|
33
44
|
as: "aside",
|
|
34
45
|
className: [
|
|
35
46
|
"nabs-ui-layout__panel",
|
|
36
47
|
"nabs-ui-layout__panel--left",
|
|
37
|
-
|
|
48
|
+
m
|
|
38
49
|
].filter(Boolean).join(" "),
|
|
39
|
-
children:
|
|
50
|
+
children: o
|
|
40
51
|
}) : null,
|
|
41
|
-
/* @__PURE__ */ e(
|
|
52
|
+
/* @__PURE__ */ e(r, {
|
|
42
53
|
as: "section",
|
|
43
|
-
className: ["nabs-ui-layout__content",
|
|
44
|
-
children:
|
|
54
|
+
className: ["nabs-ui-layout__content", g].filter(Boolean).join(" "),
|
|
55
|
+
children: u
|
|
45
56
|
}),
|
|
46
|
-
|
|
57
|
+
S ? /* @__PURE__ */ e(r, {
|
|
47
58
|
as: "aside",
|
|
48
59
|
className: [
|
|
49
60
|
"nabs-ui-layout__panel",
|
|
50
61
|
"nabs-ui-layout__panel--right",
|
|
51
|
-
|
|
62
|
+
h
|
|
52
63
|
].filter(Boolean).join(" "),
|
|
53
|
-
children:
|
|
64
|
+
children: s
|
|
54
65
|
}) : null
|
|
55
66
|
]
|
|
56
67
|
}),
|
|
57
|
-
|
|
68
|
+
b ? /* @__PURE__ */ e(r, {
|
|
58
69
|
as: "footer",
|
|
59
70
|
className: "nabs-ui-layout__footerWrapper",
|
|
60
71
|
children: /* @__PURE__ */ e("div", {
|
|
61
|
-
className: ["nabs-ui-layout__footer",
|
|
62
|
-
children:
|
|
72
|
+
className: ["nabs-ui-layout__footer", p].filter(Boolean).join(" "),
|
|
73
|
+
children: a
|
|
63
74
|
})
|
|
64
75
|
}) : null
|
|
65
76
|
]
|
|
66
77
|
});
|
|
67
78
|
}
|
|
68
79
|
//#endregion
|
|
69
|
-
export {
|
|
80
|
+
export { i as Layout };
|