@mich8060/unified-design-system 0.2.47 → 0.2.48
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.
|
@@ -44,6 +44,10 @@ export interface AppShellProps {
|
|
|
44
44
|
/** Slot wrapper props used by AppShell compound regions. */
|
|
45
45
|
export interface AppShellSectionProps {
|
|
46
46
|
children?: React.ReactNode;
|
|
47
|
+
/** Optional width for rail regions like AppShell.SidePanel (e.g. 420 or "28rem"). */
|
|
48
|
+
width?: number | string;
|
|
49
|
+
/** Optional maximum width for rail regions like AppShell.SidePanel (e.g. 480 or "32rem"). */
|
|
50
|
+
maxWidth?: number | string;
|
|
47
51
|
}
|
|
48
52
|
type AppShellSlotName = "Menu" | "Content" | "Listview" | "Main" | "SidePanel" | "Footer";
|
|
49
53
|
type AppShellSlotComponent = React.FC<AppShellSectionProps> & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),s=require("react"),te=require("./layout.types.cjs"),ae=require("../../components/Avatar/Avatar.cjs"),se=require("../../components/ActionMenu/ActionMenu.cjs"),oe=require("../../components/Button/Button.cjs"),ie=require("../../components/Branding/Branding.cjs"),re=require("../../components/Toolbar/Toolbar.cjs");;/* empty css */const i=l=>{const t=({children:f})=>n.jsx(n.Fragment,{children:f});return t.__appShellSlot=l,t},P=l=>{if(l&&(typeof l=="function"||typeof l=="object"&&l!==null))return l.__appShellSlot},L=i("Menu"),$=i("Content"),q=i("Listview"),F=i("Main"),E=i("SidePanel"),O=i("Footer"),m=l=>s.Children.toArray(l).some(t=>typeof t=="string"?t.trim().length>0:t!=null&&t!==!1);function pe({layout:l,slots:t,children:f,standalone:W=!1,brand:b="default",theme:I="light",className:B="",skipToContent:R=!0,skipToContentLabel:T="Skip to content",mainContentId:z,mobileBrandLabel:D,mobileUserName:S="Jane Doe",mobileUserInitials:J="JD",mobileUserAvatarSrc:G,mobileAccountMenuItems:v=[]}){const r=s.useMemo(()=>({...te.defaultLayout,...l}),[l]),H=s.useId().replace(/[:]/g,""),C=z??`app-shell-main-${H}`,[p,j]=s.useState(!1),K=D??(b==="default"?"design-system":b),Q=s.useMemo(()=>Array.isArray(v)?v:[],[v]),c=s.useCallback(()=>j(!1),[]),V=s.useCallback(()=>j(e=>!e),[]);s.useEffect(()=>{if(!p)return;const e=a=>{a.key==="Escape"&&c()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[c,p]);const X=s.useCallback(e=>{const a=e.target;a&&a.closest("a")&&c()},[c]);let y=null,w=null,_=null,A=null,g=null,k=null,d,u;const Y=s.Children.toArray(f);for(const e of Y){const a=P(e.type);if(e.type===L||a==="Menu"){y=e.props.children;continue}if(e.type===$||a==="Content"){w=e.props.children;continue}(e.type===O||a==="Footer")&&(k=e.props.children)}const Z=s.Children.toArray(w);for(const e of Z){const a=P(e.type);if(e.type===q||a==="Listview"){_=e.props.children;continue}if(e.type===F||a==="Main"){A=e.props.children;continue}(e.type===E||a==="SidePanel")&&(g=e.props.children,d=e.props.width,u=e.props.maxWidth)}const M=typeof d=="number"?`${d}px`:d,x=typeof u=="number"?`${u}px`:u,U=M||x?{...M?{"--app-shell-side-panel-width":M}:{},...x?{"--app-shell-side-panel-max-width":x}:{}}:void 0,N=(t==null?void 0:t.Footer)??k,h=!W&&r.sidebar&&m(y),ee=m(_),ne=m(g),le=["app-shell",`brand-${b}`,`theme-${I}`,`density-${r.density}`,`container-${r.container}`,`padding-${r.padding}`,h?"app-shell--has-nav":"app-shell--standalone",p?"app-shell--mobile-menu-open":"",B].join(" ");return n.jsxs("div",{className:le,children:[R?n.jsx("a",{className:"app-shell__skip-link",href:`#${C}`,children:T}):null,h?n.jsx("div",{className:"app-shell__mobile-toolbar-wrap",children:n.jsx(re.Toolbar,{className:"app-shell__mobile-toolbar",left:n.jsx(oe.default,{appearance:"text",icon:"List",label:p?"Close navigation menu":"Open navigation menu",layout:"icon-only","aria-label":p?"Close navigation menu":"Open navigation menu",onClick:V}),center:n.jsx(ie.default,{brand:K,symbol:!0}),right:n.jsx(se.default,{placement:"bottom-end",items:Q,trigger:n.jsx("button",{type:"button",className:"app-shell__mobile-avatar-trigger","aria-label":`${S} account menu`,children:n.jsx(ae.default,{src:G,initials:J,alt:S?`${S} avatar`:"User avatar",size:"default"})})})})}):null,n.jsxs("div",{className:"app-shell__body",children:[h?n.jsx("aside",{className:"app-shell__sidebar","aria-label":"Primary",onClickCapture:X,children:y}):null,n.jsxs("div",{className:"app-shell__main",children:[n.jsxs("main",{className:"app-shell__content",id:C,tabIndex:-1,children:[ee?n.jsx("aside",{className:"app-shell__listview",children:_}):null,n.jsx("section",{className:"app-shell__main-content",children:A}),ne?n.jsx("aside",{className:"app-shell__side-panel",style:U,children:g}):null]}),r.footer&&m(N)?N:null]})]}),h?n.jsx("button",{type:"button",className:"app-shell__mobile-backdrop",onClick:c,"aria-label":"Close navigation menu"}):null]})}const o=pe;o.Menu=L;o.Content=$;o.Listview=q;o.Main=F;o.SidePanel=E;o.Footer=O;exports.AppShell=o;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as
|
|
1
|
+
import{jsxs as h,jsx as n,Fragment as ie}from"react/jsx-runtime";import A,{useMemo as F,useId as se,useState as re,useCallback as w,useEffect as pe}from"react";import{defaultLayout as ce}from"./layout.types.js";import de from"../../components/Avatar/Avatar.js";import ue from"../../components/ActionMenu/ActionMenu.js";import he from"../../components/Button/Button.js";import me from"../../components/Branding/Branding.js";import{Toolbar as fe}from"../../components/Toolbar/Toolbar.js";/* empty css */const a=t=>{const l=({children:f})=>n(ie,{children:f});return l.__appShellSlot=t,l},E=t=>{if(t&&(typeof t=="function"||typeof t=="object"&&t!==null))return t.__appShellSlot},W=a("Menu"),j=a("Content"),I=a("Listview"),O=a("Main"),B=a("SidePanel"),z=a("Footer"),m=t=>A.Children.toArray(t).some(l=>typeof l=="string"?l.trim().length>0:l!=null&&l!==!1);function Se({layout:t,slots:l,children:f,standalone:D=!1,brand:S="default",theme:J="light",className:R="",skipToContent:T=!0,skipToContentLabel:q="Skip to content",mainContentId:G,mobileBrandLabel:H,mobileUserName:v="Jane Doe",mobileUserInitials:K="JD",mobileUserAvatarSrc:Q,mobileAccountMenuItems:b=[]}){const s=F(()=>({...ce,...t}),[t]),V=se().replace(/[:]/g,""),N=G??`app-shell-main-${V}`,[r,k]=re(!1),X=H??(S==="default"?"design-system":S),Y=F(()=>Array.isArray(b)?b:[],[b]),p=w(()=>k(!1),[]),Z=w(()=>k(e=>!e),[]);pe(()=>{if(!r)return;const e=o=>{o.key==="Escape"&&p()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[p,r]);const U=w(e=>{const o=e.target;o&&o.closest("a")&&p()},[p]);let y=null,L=null,_=null,P=null,g=null,x=null,c,d;const ee=A.Children.toArray(f);for(const e of ee){const o=E(e.type);if(e.type===W||o==="Menu"){y=e.props.children;continue}if(e.type===j||o==="Content"){L=e.props.children;continue}(e.type===z||o==="Footer")&&(x=e.props.children)}const ne=A.Children.toArray(L);for(const e of ne){const o=E(e.type);if(e.type===I||o==="Listview"){_=e.props.children;continue}if(e.type===O||o==="Main"){P=e.props.children;continue}(e.type===B||o==="SidePanel")&&(g=e.props.children,c=e.props.width,d=e.props.maxWidth)}const M=typeof c=="number"?`${c}px`:c,C=typeof d=="number"?`${d}px`:d,te=M||C?{...M?{"--app-shell-side-panel-width":M}:{},...C?{"--app-shell-side-panel-max-width":C}:{}}:void 0,$=(l==null?void 0:l.Footer)??x,u=!D&&s.sidebar&&m(y),le=m(_),oe=m(g),ae=["app-shell",`brand-${S}`,`theme-${J}`,`density-${s.density}`,`container-${s.container}`,`padding-${s.padding}`,u?"app-shell--has-nav":"app-shell--standalone",r?"app-shell--mobile-menu-open":"",R].join(" ");return h("div",{className:ae,children:[T?n("a",{className:"app-shell__skip-link",href:`#${N}`,children:q}):null,u?n("div",{className:"app-shell__mobile-toolbar-wrap",children:n(fe,{className:"app-shell__mobile-toolbar",left:n(he,{appearance:"text",icon:"List",label:r?"Close navigation menu":"Open navigation menu",layout:"icon-only","aria-label":r?"Close navigation menu":"Open navigation menu",onClick:Z}),center:n(me,{brand:X,symbol:!0}),right:n(ue,{placement:"bottom-end",items:Y,trigger:n("button",{type:"button",className:"app-shell__mobile-avatar-trigger","aria-label":`${v} account menu`,children:n(de,{src:Q,initials:K,alt:v?`${v} avatar`:"User avatar",size:"default"})})})})}):null,h("div",{className:"app-shell__body",children:[u?n("aside",{className:"app-shell__sidebar","aria-label":"Primary",onClickCapture:U,children:y}):null,h("div",{className:"app-shell__main",children:[h("main",{className:"app-shell__content",id:N,tabIndex:-1,children:[le?n("aside",{className:"app-shell__listview",children:_}):null,n("section",{className:"app-shell__main-content",children:P}),oe?n("aside",{className:"app-shell__side-panel",style:te,children:g}):null]}),s.footer&&m($)?$:null]})]}),u?n("button",{type:"button",className:"app-shell__mobile-backdrop",onClick:p,"aria-label":"Close navigation menu"}):null]})}const i=Se;i.Menu=W;i.Content=j;i.Listview=I;i.Main=O;i.SidePanel=B;i.Footer=z;export{i as AppShell};
|