@webority/ui-react 0.143.0 → 0.143.1
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/canvas-kit/kit.js +15952 -15943
- package/dist/canvas-kit/manifest.json +1 -1
- package/dist/canvas-kit/release.json +5 -5
- package/dist/components/AppShell.js +1 -1
- package/dist/guidance.json +1 -1
- package/package.json +7 -7
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webority-web",
|
|
3
|
-
"version": "0.143.
|
|
3
|
+
"version": "0.143.1",
|
|
4
4
|
"platform": "Web",
|
|
5
5
|
"kitModuleVersion": 2,
|
|
6
6
|
"rendererProtocolVersion": 13,
|
|
7
7
|
"library": {
|
|
8
8
|
"name": "@webority/ui-react",
|
|
9
|
-
"version": "0.143.
|
|
9
|
+
"version": "0.143.1"
|
|
10
10
|
},
|
|
11
11
|
"files": {
|
|
12
12
|
"manifest.json": {
|
|
13
|
-
"sha256": "
|
|
13
|
+
"sha256": "da6a4639010b0205e66b4e27baac6af7ba50447dccc0c753759cb4fafe2f4d55",
|
|
14
14
|
"bytes": 980118
|
|
15
15
|
},
|
|
16
16
|
"kit.js": {
|
|
17
|
-
"sha256": "
|
|
18
|
-
"bytes":
|
|
17
|
+
"sha256": "eedb09c6c03581a3764199d86022f2369ab959ca2f9e04064227021a1958d41d",
|
|
18
|
+
"bytes": 11172701
|
|
19
19
|
},
|
|
20
20
|
"kit.css": {
|
|
21
21
|
"sha256": "13b14f71fb6ea024945f95cba617b4f1d49f44a65ba7c7ed05d2354805539ef6",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{devWarn as e}from"../lib/devWarn.js";import t from"../lib/fillLabel.js";import{navMatchScore as n}from"../lib/navMatch.js";import{SHELL_FOLDED_COOKIE as r,readNavFolded as i,readShellCollapsed as a,writeNavFolded as o,writeShellCollapsed as s}from"../lib/shellCookie.js";import{splitMarkerProps as c}from"../lib/wuiMarker.js";import l from"./AppAvatar.js";import u from"./AppButton.js";import d from"./AppIcon.js";import f from"./AppNavigationMenu.js";import p from"./warnInvalidValue.js";import m from"./warnUnknownProps.js";import{initScrollEdges as h}from"@webority/ui-elements/helpers";import{useEffect as g,useId as _,useMemo as v,useRef as y,useState as b}from"react";import{Fragment as x,jsx as S,jsxs as C}from"react/jsx-runtime";var w=99,T=4,E=5,D=/^[a-z0-9-]+$/,O=[`prefix`,`exact`],k=[`comfortable`,`compact`],A=[`neutral`,`primary`],j=[`side`,`top`],M=[`linear`,`outline`,`bold`,`bulk`,`broken`,`twotone`],N=/* @__PURE__ */ new Set([`key`,`label`,`icon`,`iconVariant`,`iconSize`,`href`,`badge`,`badgeTone`,`badgeTitle`,`newUntil`,`trailingIcon`,`active`,`match`,`matchAlso`,`tab`,`tabLabel`,`children`]),P=e=>e>w?`${w}+`:String(e),F=new Intl.DateTimeFormat(`en-CA`,{timeZone:`Asia/Kolkata`}),I=e=>{if(typeof e!=`string`||!/^\d{4}-\d{2}-\d{2}$/.test(e))return!1;let t=/* @__PURE__ */ new Date(`${e}T00:00:00Z`);return Number.isNaN(t.getTime())||t.toISOString().slice(0,10)!==e?!1:F.format(/* @__PURE__ */ new Date)<=e},L=({logoLight:e,logoDark:t,markLight:n,markDark:r})=>{let i=!!(n||r);return[`app-sidebar-brand`,i&&`wui-brand-has-mark`,i&&!e&&!t&&`wui-brand-mark-only`,(t||r)&&`wui-brand-themed`].filter(Boolean).join(` `)},ee=({logoLight:e,logoDark:t,markLight:n,markDark:r,brandName:i})=>{let a=i??``,o=[e&&/* @__PURE__ */ S(`img`,{className:`wui-brand-logo wui-brand-light`,src:e,alt:a},`logo-light`),t&&/* @__PURE__ */ S(`img`,{className:`wui-brand-logo wui-brand-dark`,src:t,alt:``,"aria-hidden":`true`},`logo-dark`)],s=[n&&[`mark-light`,`wui-brand-mark wui-brand-light`,n],r&&[`mark-dark`,`wui-brand-mark wui-brand-dark`,r]].filter(Boolean).map(([t,n,r],i)=>i===0&&!e?/* @__PURE__ */ S(`img`,{className:n,src:r,alt:a},t):/* @__PURE__ */ S(`img`,{className:n,src:r,alt:``,"aria-hidden":`true`},t));return[...o,...s].filter(Boolean)};function R(e){let{marker:t,props:n}=c(`AppShell`,e),{groups:l=[],brand:u,logoLight:_,logoDark:x,markLight:w,markDark:T,brandName:E,sidebarStart:D,sidebarStartCompact:O,sidebarFooter:N,topbarStart:P,topbarEnd:F,footer:I,launcher:R,children:ne,collapsed:z,onCollapsedChange:re,noSidebar:B=!1,nav:V=`side`,density:U=`comfortable`,itemHeight:W,iconVariant:G,topbarTone:de=`neutral`,navLabel:fe=`Main navigation`,linkComponent:K,currentPath:pe,rememberCollapsed:me=!1,collapsedCookie:he=`wui-shell-collapsed`,foldedCookie:q=r,tabBarLabel:ge=`Quick navigation`,moreLabel:_e=`More`,skipLabel:ve=`Skip to content`,openNavLabel:ye=`Open navigation`,closeNavLabel:be=`Close navigation`,expandNavLabel:xe=`Expand navigation`,collapseNavLabel:Se=`Collapse navigation`,newLabel:Ce=`New`,togglePagesLabel:we=`Show or hide {name} pages`,accountMenuLabel:Te=`Account menu for {name}`,roleLabel:Ee=`Role:`,rolesLabel:De=`Roles:`,unreadLabel:Oe=`Unread`,markAllReadLabel:ke=`Mark all read`,viewAllLabel:Ae=`View all`,loadingNotificationsText:je=`Loading…`,noUnreadText:Me=`No unread notifications`,unreadNotificationsText:Ne=`{count} unread notifications`,unreadBellLabel:Pe=`{label}, {count} unread`,searchResultsLabel:Fe=`Search results`,noResultsText:Ie=`No results`,noResultsForText:Le=`No results for “{value}”`,resultsCountText:Re=`{count} results`,resultCountText:ze=`{count} result`,userMenu:Be,notifications:Ve,search:He,className:Ue=``,style:We,...Ge}=n;m(`AppShell`,Ge),p(`AppShell`,`density`,U,k),p(`AppShell`,`topbarTone`,de,A),p(`AppShell`,`nav`,V,j),p(`AppShell`,`iconVariant`,G,M);let Ke=W>0?{...We,"--wui-nav-item-height":`${W}px`}:We,[qe,Je]=b(()=>me&&z===void 0&&typeof document<`u`?a(he)??!1:!1),[J,Y]=b(!1),[Ye,Xe]=b(!1),[Ze,Qe]=b(!1),X=y(null),$e=y(null),et=y(null),Z=z??qe,tt=()=>{let e=!Z;z===void 0&&Je(e),me&&s(e,he),re?.(e)},nt=l.some(e=>e.collapsible),[rt,it]=b(()=>nt&&typeof document<`u`?i(q):/* @__PURE__ */ new Set),at=e=>{let t=new Set(rt);t.has(e)?t.delete(e):t.add(e),it(t),o(t,q)},Q=v(()=>te(l,pe),[l,pe]),$=B?null:ie(Q);g(()=>{let e=()=>Xe(window.scrollY>4);return e(),window.addEventListener(`scroll`,e,{passive:!0}),()=>window.removeEventListener(`scroll`,e)},[]),g(()=>{h()},[]),g(()=>{let e=X.current,t=e?.querySelector(`.app-nav-item[aria-current="page"]`);if(!e||!t)return;let n=t.getBoundingClientRect(),r=e.getBoundingClientRect();n.top<r.top?e.scrollTop-=r.top-n.top:n.bottom>r.bottom&&(e.scrollTop+=n.bottom-r.bottom)},[]),g(()=>{let e=X.current;if(!e)return;let t=()=>Qe(e.scrollHeight>e.clientHeight);if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[Q]);let ot=!!I;g(()=>{let e=et.current,t=$e.current;if(!ot||!e||!t)return;let n=()=>t.style.setProperty(`--app-footer-h`,`${e.offsetHeight}px`);n();let r=typeof ResizeObserver>`u`?null:new ResizeObserver(n);return r?.observe(e),()=>{r?.disconnect(),t.style.removeProperty(`--app-footer-h`)}},[ot]),g(()=>{if(!J)return;let e=e=>{e.key===`Escape`&&Y(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[J]);let st=[`app-shell`,Z?`collapsed`:``,B?`no-sidebar`:``,V===`top`?`wui-shell-top`:``,J?`mobile-open`:``,Ue].filter(Boolean).join(` `);return/* @__PURE__ */ C(`div`,{ref:$e,className:st,"data-density":U===`compact`?`compact`:void 0,"data-wui-folded-cookie":nt?q:void 0,style:Ke,...t,...Ge,children:[/* @__PURE__ */ S(`a`,{className:`wui-skip-link`,href:`#main-content`,children:ve}),/* @__PURE__ */ C(`aside`,{className:`app-sidebar`,children:[(u||_||x||w||T)&&/* @__PURE__ */ C(`div`,{className:L({logoLight:_,logoDark:x,markLight:w,markDark:T}),children:[ee({logoLight:_,logoDark:x,markLight:w,markDark:T,brandName:E}),u]}),D&&/* @__PURE__ */ S(`div`,{className:`app-sidebar-start`,children:D}),O&&/* @__PURE__ */ S(`div`,{className:`app-sidebar-start-compact`,children:O}),/* @__PURE__ */ S(`nav`,{className:`app-sidebar-scroll`,"aria-label":fe,ref:X,tabIndex:Ze?0:void 0,children:Q.map((e,t)=>{let n=e.items.map(e=>e.header==null?/* @__PURE__ */ S(se,{item:e,linkComponent:K,onNavigate:()=>Y(!1),iconVariant:G,newLabel:Ce,togglePagesLabel:we},e.key??e.href??e.label):/* @__PURE__ */ S(`div`,{className:`wui-nav-header`,children:e.header},e.key??e.header));if(!e.collapsible)return/* @__PURE__ */ C(`div`,{className:`app-nav-group`,children:[e.label&&/* @__PURE__ */ S(`div`,{className:`app-nav-group-label`,children:e.label}),n,e.after&&/* @__PURE__ */ S(`div`,{className:`wui-nav-group-after`,children:e.after})]},e.key??e.label??`group-${t}`);let r=!rt.has(e.key)||!!H(e.items),i=`wui-nav-group-${e.key}`;return/* @__PURE__ */ C(`div`,{className:`app-nav-group wui-nav-group-collapsible${r?``:` wui-nav-group-folded`}`,"data-wui-nav-group":e.key,children:[/* @__PURE__ */ C(`button`,{type:`button`,className:`app-nav-group-label wui-nav-group-toggle`,"aria-expanded":r,"aria-controls":i,onClick:()=>at(e.key),children:[/* @__PURE__ */ S(`span`,{className:`wui-nav-group-text`,children:e.label}),/* @__PURE__ */ S(`span`,{className:`wui-nav-group-caret`,children:/* @__PURE__ */ S(d,{name:`chevron-down`,size:16})})]}),/* @__PURE__ */ C(`div`,{className:`wui-nav-group-body`,id:i,children:[n,e.after&&/* @__PURE__ */ S(`div`,{className:`wui-nav-group-after`,children:e.after})]})]},e.key??`group-${t}`)})}),N&&/* @__PURE__ */ S(`div`,{className:`app-sidebar-foot`,children:N}),!B&&/* @__PURE__ */ S(`button`,{type:`button`,className:`app-sidebar-toggle`,onClick:tt,"aria-label":Z?xe:Se,"aria-expanded":!Z,children:/* @__PURE__ */ S(d,{name:`chevrons-left`,size:20})})]}),/* @__PURE__ */ C(`div`,{className:`app-main`,children:[/* @__PURE__ */ C(`header`,{className:`app-topbar${Ye?` scrolled`:``}`,"data-tone":de===`primary`?`primary`:void 0,children:[/* @__PURE__ */ C(`div`,{className:`app-topbar-start`,children:[/* @__PURE__ */ S(`button`,{type:`button`,className:`app-topbar-menu`,onClick:()=>Y(!0),"aria-label":ye,"aria-expanded":J,children:/* @__PURE__ */ S(d,{name:`menu`,size:18})}),V===`top`&&u&&/* @__PURE__ */ S(`div`,{className:`wui-shell-top-brand`,children:u}),V===`top`&&/* @__PURE__ */ S(`div`,{className:`wui-shell-top-nav`,children:/* @__PURE__ */ S(f,{items:ae(Q),ariaLabel:fe,linkComponent:K})}),P,He&&/* @__PURE__ */ S(ue,{config:He,searchResultsLabel:Fe,noResultsText:Ie,noResultsForText:Le,resultsCountText:Re,resultCountText:ze})]}),/* @__PURE__ */ C(`div`,{className:`app-topbar-end`,children:[F,Ve&&/* @__PURE__ */ S(le,{config:Ve,unreadLabel:Oe,markAllReadLabel:ke,viewAllLabel:Ae,loadingNotificationsText:je,noUnreadText:Me,unreadNotificationsText:Ne,unreadBellLabel:Pe}),Be&&/* @__PURE__ */ S(ce,{config:Be,linkComponent:K,accountMenuLabel:Te,roleLabel:Ee,rolesLabel:De})]})]}),/* @__PURE__ */ S(`main`,{className:`app-content`,id:`main-content`,children:ne}),I&&/* @__PURE__ */ S(`footer`,{className:`app-footer`,ref:et,children:I})]}),R&&/* @__PURE__ */ S(`div`,{className:`wui-shell-launcher`,children:R}),$&&/* @__PURE__ */ C(`nav`,{className:`wui-tabbar`,"aria-label":ge,children:[$.tabs.map(e=>/* @__PURE__ */ S(oe,{tab:e,linkComponent:K,iconVariant:G},e.key??e.href)),$.hasMore&&/* @__PURE__ */ C(`button`,{type:`button`,className:`wui-tabbar-item${$.moreActive?` active`:``}`,onClick:()=>Y(!0),children:[/* @__PURE__ */ S(`span`,{className:`wui-tabbar-icon`,children:/* @__PURE__ */ S(d,{name:`more`,size:24})}),/* @__PURE__ */ S(`span`,{className:`wui-tabbar-label`,children:_e})]})]}),/* @__PURE__ */ S(`button`,{type:`button`,className:`app-scrim`,onClick:()=>Y(!1),"aria-label":be,tabIndex:J?0:-1})]})}function te(e,t){for(let t of e)t.collapsible&&V(t);let r=(e,t=!1)=>(e??[]).map(e=>Array.isArray(e.children)?{...e,children:r(e.children)}:{...e}).filter(e=>z(e)?t:(e.children?.length??0)>0||!!e.href),i=e.map(e=>({...e,items:re(r(e.items,!0))})).filter(e=>e.items.some(e=>!z(e))),a=[],o=e=>{for(let t of e)z(t)||(a.push(t),t.children&&o(t.children))};for(let e of i)o(e.items);for(let e of a)m(`AppShell items`,ne(e)),p(`AppShell`,`match`,e.match,O),p(`AppShell`,`iconVariant`,e.iconVariant,M);let s=null;if(t!=null&&!a.some(e=>e.active===!0)){let e=-1;for(let r of a){if(r.active!=null||r.children?.length&&!r.href)continue;let i=n(t,r.href,{exact:r.match===`exact`,also:r.matchAlso});if(i<0)continue;let a=r.match===`exact`&&n(t,r.href,{exact:!0})>=0?1/0:i;a>e&&(e=a,s=r)}}for(let e of a)e.active=e.active??e===s;return i}function ne(e){return Object.fromEntries(Object.entries(e).filter(([e])=>!N.has(e)))}var z=e=>e.header!=null;function re(e){return e.filter((t,n)=>{if(!z(t))return!0;let r=e.findIndex((e,t)=>t>n&&z(e));return e.slice(n+1,r<0?void 0:r).length>0})}var B=/* @__PURE__ */ new Set;function V(t){if(t.key!=null&&D.test(t.key))return;let n=t.key==null?`<AppShell> a collapsible group needs a key so its folded state can be remembered.`:`<AppShell> collapsible group key "${t.key}" must use lower-case letters, digits and hyphens.`,r=!0;try{r=process.env.NODE_ENV!==`production`}catch{r=!0}r&&!B.has(n)&&(B.add(n),e(n))}function ie(e){let t=[],n=e=>{for(let r of e)z(r)||(r.children?.length?n(r.children):t.push(r))};for(let t of e)n(t.items);let r=t.filter(e=>e.tab);if(r.length===0)return null;let i=r.length<t.length,a=i?T:E;if(r.length>a)throw Error(`<AppShell>: ${r.length} items carry tab: true, but the phone tab bar holds ${a} (${i?`4 plus More, because other items exist`:`5 when every item is a tab`}). Flag fewer items.`);return{tabs:r,hasMore:i,moreActive:t.some(e=>!e.tab&&e.active)}}function ae(e){let t=e=>({key:e.key??e.href??e.label,label:e.label,to:e.href,current:!!e.active}),n=e=>e.flatMap(e=>z(e)?[]:[...e.href?[{...t(e),icon:e.icon}]:[],...n(e.children??[])]),r=[];for(let i of e.flatMap(e=>e.items)){if(z(i))continue;let e=n(i.children??[]);if(e.length>0){let n=i.href?[{...t(i),icon:i.icon}]:[];r.push({key:t(i).key,label:i.label,links:[...n,...e]})}else i.href&&r.push(t(i))}return r}function oe({tab:e,linkComponent:t,iconVariant:n}){let r=`wui-tabbar-item${e.active?` active`:``}`,i=/* @__PURE__ */ C(x,{children:[e.icon&&/* @__PURE__ */ S(`span`,{className:`wui-tabbar-icon`,children:typeof e.icon==`string`?/* @__PURE__ */ S(d,{name:e.icon,size:24,variant:e.iconVariant??n}):e.icon}),/* @__PURE__ */ S(`span`,{className:`wui-tabbar-label`,children:e.tabLabel??e.label}),e.badge!=null&&/* @__PURE__ */ S(`span`,{className:`wui-tabbar-badge${e.badgeTone?` tone-${e.badgeTone}`:``}`,title:e.badgeTitle||void 0,children:e.badge})]}),a=e.active?`page`:void 0;return t?/* @__PURE__ */ S(t,{className:r,to:e.href,"aria-current":a,children:i}):/* @__PURE__ */ S(`a`,{className:r,href:e.href,"aria-current":a,children:i})}function H(e){for(let t of e){if(t.active)return t;let e=t.children?.length?H(t.children):void 0;if(e)return e}}function se({item:e,linkComponent:n,onNavigate:r,depth:i=0,iconVariant:a,newLabel:o,togglePagesLabel:s}){let c=i>0,l=i>1?` wui-nav-depth-${Math.min(i,6)}`:``,u=Array.isArray(e.children)&&e.children.length>0,f=u?H(e.children):void 0,p=!!f,m=f?f.key??f.href??f.label:null,[h,_]=b(p);g(()=>{m!=null&&_(!0)},[m]);let v=typeof e.label==`string`?e.label:void 0,y=!c&&e.icon&&/* @__PURE__ */ S(`span`,{className:`app-nav-icon`,children:typeof e.icon==`string`?/* @__PURE__ */ S(d,{name:e.icon,size:e.iconSize??22,variant:e.iconVariant??a}):e.icon}),w=e.badge!=null&&/* @__PURE__ */ S(`span`,{className:`app-nav-badge${e.badgeTone?` tone-${e.badgeTone}`:``}`,title:e.badgeTitle||void 0,children:e.badge}),T=I(e.newUntil)&&/* @__PURE__ */ S(`span`,{className:`wui-nav-new`,children:o}),E=/* @__PURE__ */ C(x,{children:[y,/* @__PURE__ */ S(`span`,{className:`app-nav-text`,children:e.label}),T,w,e.trailingIcon&&/* @__PURE__ */ S(`span`,{className:`app-nav-trailing`,children:typeof e.trailingIcon==`string`?/* @__PURE__ */ S(d,{name:e.trailingIcon,size:16}):e.trailingIcon})]}),D=e.active?`page`:void 0;if(u){let u=/* @__PURE__ */ S(`div`,{className:`app-nav-sub${h?` expanded`:``}`,inert:!h,"aria-hidden":!h||void 0,children:/* @__PURE__ */ S(`div`,{className:`app-nav-sub-inner`,children:e.children.map(e=>/* @__PURE__ */ S(se,{item:e,linkComponent:n,onNavigate:r,depth:i+1,iconVariant:a,newLabel:o,togglePagesLabel:s},e.key??e.href))})});if(e.href){let i=n?/* @__PURE__ */ S(n,{className:`wui-nav-split-link`,to:e.href,"aria-current":D,onClick:r,children:E}):/* @__PURE__ */ S(`a`,{className:`wui-nav-split-link`,href:e.href,"aria-current":D,onClick:r,children:E});return/* @__PURE__ */ C(x,{children:[/* @__PURE__ */ C(`div`,{className:`app-nav-item has-children wui-nav-split${c?` app-nav-subitem`:``}${p||e.active?` active`:``}${l}`,"data-label":v,children:[i,/* @__PURE__ */ S(`button`,{type:`button`,className:`app-nav-caret wui-nav-split-toggle`,"aria-expanded":h,"aria-label":t(s,{name:v??``}),onClick:()=>_(e=>!e),children:/* @__PURE__ */ S(d,{name:`chevron-right`,size:16})})]}),u]})}return/* @__PURE__ */ C(x,{children:[/* @__PURE__ */ C(`button`,{type:`button`,className:`app-nav-item${c?` app-nav-subitem`:``} has-children${p?` active`:``}${l}`,"aria-expanded":h,"data-label":v,onClick:()=>_(e=>!e),children:[y,/* @__PURE__ */ S(`span`,{className:`app-nav-text`,children:e.label}),T,w,/* @__PURE__ */ S(`span`,{className:`app-nav-caret`,children:/* @__PURE__ */ S(d,{name:`chevron-right`,size:16})})]}),u]})}let O=`app-nav-item${c?` app-nav-subitem`:``}${e.active?` active`:``}${l}`;return n?/* @__PURE__ */ S(n,{className:O,to:e.href,"aria-current":D,"data-label":v,onClick:r,children:E}):/* @__PURE__ */ S(`a`,{className:O,href:e.href,"aria-current":D,"data-label":v,onClick:r,children:E})}function U(){let[e,t]=b(!1),n=y(null);return g(()=>{if(!e)return;let r=e=>{n.current?.contains(e.target)||t(!1)},i=e=>{e.key===`Escape`&&(t(!1),n.current?.querySelector(`button`)?.focus())};return document.addEventListener(`mousedown`,r),document.addEventListener(`keydown`,i),()=>{document.removeEventListener(`mousedown`,r),document.removeEventListener(`keydown`,i)}},[e]),{open:e,setOpen:t,ref:n}}function ce({config:e,linkComponent:n,accountMenuLabel:r,roleLabel:i,rolesLabel:a}){let o=_(),{open:s,setOpen:c,ref:f}=U(),{name:m,role:h,roles:g=[],photo:v,profileHref:y,profileLabel:b=`My profile`,onLogout:w,logoutAction:T,logoutLabel:E=`Sign out`,head:D,section:O,logoutVariant:k=`item`,items:A=[]}=e;if(p(`AppShell`,`userMenu.logoutVariant`,k,[`item`,`button`]),!m)throw Error(`<AppShell> userMenu.name is required; the trigger and the avatar are named from it.`);let j=g.map(e=>(e??``).trim()).filter(Boolean),M=()=>c(!1),N=(e,t,r,i)=>n?/* @__PURE__ */ S(n,{className:`dropdown-item`,to:e,onClick:i,children:t},r):/* @__PURE__ */ S(`a`,{className:`dropdown-item`,href:e,onClick:i,children:t},r),P=/* @__PURE__ */ S(d,{name:`log-out`,size:18}),F=/* @__PURE__ */ C(x,{children:[P,E]});return/* @__PURE__ */ C(`div`,{className:`dropdown wui-usermenu`,ref:f,children:[/* @__PURE__ */ C(`button`,{type:`button`,id:o,className:`wui-usermenu-trigger`,"aria-expanded":s,"aria-label":t(r,{name:m}),onClick:()=>c(e=>!e),children:[/* @__PURE__ */ S(l,{name:m,src:v,tone:`auto`}),/* @__PURE__ */ C(`span`,{className:`wui-usermenu-text`,children:[/* @__PURE__ */ S(`span`,{className:`wui-usermenu-name`,children:m}),h&&/* @__PURE__ */ S(`span`,{className:`wui-usermenu-role`,children:h})]}),/* @__PURE__ */ S(d,{name:`chevron-down`,size:14,className:`wui-usermenu-caret`})]}),/* @__PURE__ */ C(`div`,{className:`dropdown-menu dropdown-menu-end wui-usermenu-menu${s?` show`:``}`,"aria-labelledby":o,"data-bs-popper":s?`static`:void 0,children:[/* @__PURE__ */ C(`div`,{className:`wui-usermenu-head`,children:[/* @__PURE__ */ S(l,{name:m,src:v,size:`lg`,tone:`auto`}),/* @__PURE__ */ C(`div`,{className:`wui-usermenu-who`,children:[/* @__PURE__ */ S(`div`,{className:`wui-usermenu-name`,children:m}),h&&/* @__PURE__ */ S(`div`,{className:`wui-usermenu-role`,children:h}),j.length>0&&/* @__PURE__ */ C(`div`,{className:`wui-usermenu-roles`,children:[/* @__PURE__ */ S(`span`,{className:`wui-usermenu-roles-label`,children:j.length===1?i:a}),` ${j.join(`, `)}`]}),D?/* @__PURE__ */ S(`div`,{className:`wui-usermenu-extra`,children:D}):null]})]}),O?/* @__PURE__ */ S(`div`,{className:`wui-usermenu-section`,children:O}):null,y&&N(y,/* @__PURE__ */ C(x,{children:[/* @__PURE__ */ S(d,{name:`user`,size:18}),b]}),void 0,M),A.map(e=>{if(e.divider)return/* @__PURE__ */ S(`hr`,{className:`dropdown-divider`},e.key);let t=/* @__PURE__ */ C(x,{children:[e.icon&&/* @__PURE__ */ S(d,{name:e.icon,size:18}),e.label]}),n=()=>{e.onClick?.(),M()};return e.href?N(e.href,t,e.key,n):/* @__PURE__ */ S(`button`,{type:`button`,className:`dropdown-item`,onClick:n,children:t},e.key)}),k===`button`?(T||w)&&/* @__PURE__ */ S(`div`,{className:`wui-usermenu-foot`,children:T?/* @__PURE__ */ S(`form`,{method:`post`,action:T,className:`wui-usermenu-logout`,children:/* @__PURE__ */ S(u,{type:`submit`,tone:`danger`,variant:`soft`,block:!0,leftIcon:P,children:E})}):/* @__PURE__ */ S(u,{type:`button`,tone:`danger`,variant:`soft`,block:!0,leftIcon:P,onClick:()=>{M(),w()},children:E})}):T?/* @__PURE__ */ S(`form`,{method:`post`,action:T,className:`wui-usermenu-logout`,children:/* @__PURE__ */ S(`button`,{type:`submit`,className:`dropdown-item danger`,children:F})}):w&&/* @__PURE__ */ S(`button`,{type:`button`,className:`dropdown-item danger`,onClick:()=>{M(),w()},children:F})]})]})}function le({config:e,unreadLabel:n,markAllReadLabel:r,viewAllLabel:i,loadingNotificationsText:a,noUnreadText:o,unreadNotificationsText:s,unreadBellLabel:c}){let l=_(),{open:u,setOpen:f,ref:p}=U(),{unread:m=0,items:h,loading:v=!1,onOpen:w,onMarkAllRead:T,viewAllHref:E,label:D=`Notifications`,emptyText:O=`You are all caught up.`}=e,[k,A]=b(``),j=y(m);g(()=>{j.current!==m&&(j.current=m,A(m===0?o:t(s,{count:P(m)})))},[m,o,s]);let M=null;return h?.length?M=/* @__PURE__ */ S(`div`,{className:`wui-bell-items`,children:h.map((e,t)=>{let r=`wui-bell-item${e.read?` wui-bell-item-read`:``}`,i=/* @__PURE__ */ C(x,{children:[/* @__PURE__ */ S(`span`,{className:`wui-bell-dot`,"aria-hidden":`true`}),e.icon&&/* @__PURE__ */ S(`span`,{className:`wui-bell-icon`,children:/* @__PURE__ */ S(d,{name:e.icon,size:18})}),/* @__PURE__ */ C(`span`,{className:`wui-bell-body`,children:[!e.read&&/* @__PURE__ */ C(`span`,{className:`visually-hidden`,children:[n,`: `]}),/* @__PURE__ */ S(`span`,{className:`wui-bell-item-title`,children:e.title}),e.time&&/* @__PURE__ */ S(`span`,{className:`wui-bell-when`,children:e.time})]})]});return e.href?/* @__PURE__ */ S(`a`,{className:r,href:e.href,"data-id":e.id,children:i},e.id??t):/* @__PURE__ */ S(`div`,{className:r,"data-id":e.id,children:i},e.id??t)})}):v?M=/* @__PURE__ */ S(`div`,{className:`wui-bell-state`,children:a}):h&&(M=/* @__PURE__ */ S(`div`,{className:`wui-bell-state`,children:O})),/* @__PURE__ */ C(`div`,{className:`dropdown wui-bell`,ref:p,children:[/* @__PURE__ */ C(`button`,{type:`button`,id:l,className:`topbar-icon-btn wui-bell-trigger`,"aria-expanded":u,"aria-label":m===0?D:t(c,{label:D,count:P(m)}),onClick:()=>{let e=!u;f(e),e&&w?.()},children:[/* @__PURE__ */ S(d,{name:`notification`,size:20}),/* @__PURE__ */ S(`span`,{className:`wui-bell-count`,"aria-hidden":`true`,hidden:m===0,children:P(m)})]}),/* @__PURE__ */ S(`span`,{className:`visually-hidden`,"aria-live":`polite`,children:k}),/* @__PURE__ */ C(`div`,{className:`dropdown-menu dropdown-menu-end wui-bell-menu${u?` show`:``}`,"aria-labelledby":l,"data-bs-popper":u?`static`:void 0,children:[/* @__PURE__ */ C(`div`,{className:`wui-bell-head`,children:[/* @__PURE__ */ S(`span`,{className:`wui-bell-title`,children:D}),T&&/* @__PURE__ */ S(`button`,{type:`button`,className:`wui-bell-markall`,onClick:T,children:r})]}),/* @__PURE__ */ S(`div`,{className:`wui-bell-list`,"aria-busy":v||void 0,children:M}),E&&/* @__PURE__ */ S(`a`,{className:`wui-bell-foot`,href:E,children:i})]})]})}var W=e=>!!e&&(e.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(e.tagName));function ue({config:e,searchResultsLabel:n,noResultsText:r,noResultsForText:i,resultsCountText:a,resultCountText:o}){let s=_(),{value:c=``,onChange:l,results:u=null,loading:f=!1,onSelect:p,onSubmit:m,onFocus:h,placeholder:x=`Search`}=e,[w,T]=b(!1),[E,D]=b(!1),[O,k]=b({results:null,index:-1}),A=O.results===u?O.index:-1,j=e=>k({results:u,index:e}),M=y(null),N=y(null),P=y([]),F=v(()=>(u??[]).flatMap(e=>e.hits??[]),[u]),I=u!=null&&!E,L=F.length;g(()=>{let e=e=>{e.key!==`/`||e.ctrlKey||e.metaKey||e.altKey||W(e.target)||(e.preventDefault(),T(!0),N.current?.focus())},t=e=>{M.current?.contains(e.target)||(D(!0),T(!1))};return document.addEventListener(`keydown`,e),document.addEventListener(`pointerdown`,t),()=>{document.removeEventListener(`keydown`,e),document.removeEventListener(`pointerdown`,t)}},[]);let ee=e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){if(!I||L===0)return;e.preventDefault(),j((A+(e.key===`ArrowDown`?1:-1)+L)%L)}else e.key===`Enter`?I&&A>=0&&P.current[A]?(e.preventDefault(),P.current[A].click()):m&&c.trim()!==``&&(e.preventDefault(),m(c.trim())):e.key===`Escape`&&(I?(e.preventDefault(),D(!0)):w&&(e.preventDefault(),T(!1)))},R=-1;return P.current=[],/* @__PURE__ */ C(`div`,{className:`wui-topsearch${w?` is-open`:``}${f?` is-loading`:``}`,ref:M,children:[/* @__PURE__ */ S(`button`,{type:`button`,className:`topbar-icon-btn wui-topsearch-open`,"aria-label":x,"aria-expanded":w,"aria-controls":`${s}-panel`,onClick:()=>{let e=!w;T(e),e&&N.current?.focus()},children:/* @__PURE__ */ S(d,{name:`search`,size:20})}),/* @__PURE__ */ C(`div`,{className:`wui-topsearch-panel`,id:`${s}-panel`,children:[/* @__PURE__ */ C(`div`,{className:`search-wrap`,children:[/* @__PURE__ */ S(d,{name:`search`,size:18,className:`search-icon`}),/* @__PURE__ */ S(`input`,{ref:N,type:`search`,className:`form-control input search-input`,id:`${s}-input`,placeholder:x,"aria-label":x,role:`combobox`,"aria-autocomplete":`list`,"aria-expanded":I,"aria-controls":`${s}-list`,"aria-activedescendant":I&&A>=0?`${s}-opt-${A}`:void 0,autoComplete:`off`,value:c,onChange:e=>{D(!1),l?.(e.target.value)},onKeyDown:ee,onFocus:h})]}),/* @__PURE__ */ S(`div`,{className:`wui-topsearch-results`,id:`${s}-list`,role:`listbox`,"aria-label":n,hidden:!I,children:I&&/* @__PURE__ */ C(`div`,{className:`wui-topsearch-groups`,role:`presentation`,children:[L===0&&/* @__PURE__ */ S(`div`,{className:`wui-topsearch-empty`,role:`option`,"aria-disabled":`true`,"aria-selected":`false`,children:t(i,{value:c})}),u.filter(e=>e.hits?.length).map((e,t)=>/* @__PURE__ */ C(`div`,{className:`wui-topsearch-group`,role:`group`,"aria-label":e.label??``,children:[e.label&&/* @__PURE__ */ S(`div`,{className:`wui-topsearch-group-label`,role:`presentation`,children:e.label}),e.hits.map(e=>{R+=1;let t=R;return/* @__PURE__ */ C(`a`,{className:`wui-topsearch-hit${t===A?` is-active`:``}`,role:`option`,"aria-selected":t===A,id:`${s}-opt-${t}`,href:e.href,ref:e=>{P.current[t]=e},onClick:t=>p?.(e,t),children:[e.icon&&/* @__PURE__ */ S(`span`,{className:`wui-topsearch-hit-icon`,children:/* @__PURE__ */ S(d,{name:e.icon,size:18})}),/* @__PURE__ */ C(`span`,{className:`wui-topsearch-hit-text`,children:[/* @__PURE__ */ S(`span`,{className:`wui-topsearch-hit-title`,children:e.title}),e.subtitle&&/* @__PURE__ */ S(`span`,{className:`wui-topsearch-hit-sub`,children:e.subtitle})]})]},`${e.href}-${t}`)})]},e.label??t))]})})]}),/* @__PURE__ */ S(`span`,{className:`visually-hidden`,"aria-live":`polite`,children:I?L===0?r:t(L===1?o:a,{count:L}):``})]})}export{R as default};
|
|
1
|
+
import{devWarn as e}from"../lib/devWarn.js";import t from"../lib/fillLabel.js";import{navMatchScore as n}from"../lib/navMatch.js";import{SHELL_FOLDED_COOKIE as r,readNavFolded as i,readShellCollapsed as a,writeNavFolded as o,writeShellCollapsed as s}from"../lib/shellCookie.js";import{splitMarkerProps as c}from"../lib/wuiMarker.js";import l from"./AppAvatar.js";import u from"./AppButton.js";import d from"./AppIcon.js";import f from"./AppNavigationMenu.js";import p from"./warnInvalidValue.js";import m from"./warnUnknownProps.js";import{initScrollEdges as h,revealActiveNavItem as g}from"@webority/ui-elements/helpers";import{useEffect as _,useId as v,useMemo as y,useRef as b,useState as x}from"react";import{Fragment as S,jsx as C,jsxs as w}from"react/jsx-runtime";var T=99,E=4,D=5,O=/^[a-z0-9-]+$/,k=[`prefix`,`exact`],A=[`comfortable`,`compact`],j=[`neutral`,`primary`],M=[`side`,`top`],N=[`linear`,`outline`,`bold`,`bulk`,`broken`,`twotone`],P=/* @__PURE__ */ new Set([`key`,`label`,`icon`,`iconVariant`,`iconSize`,`href`,`badge`,`badgeTone`,`badgeTitle`,`newUntil`,`trailingIcon`,`active`,`match`,`matchAlso`,`tab`,`tabLabel`,`children`]),F=e=>e>T?`${T}+`:String(e),I=new Intl.DateTimeFormat(`en-CA`,{timeZone:`Asia/Kolkata`}),L=e=>{if(typeof e!=`string`||!/^\d{4}-\d{2}-\d{2}$/.test(e))return!1;let t=/* @__PURE__ */ new Date(`${e}T00:00:00Z`);return Number.isNaN(t.getTime())||t.toISOString().slice(0,10)!==e?!1:I.format(/* @__PURE__ */ new Date)<=e},ee=({logoLight:e,logoDark:t,markLight:n,markDark:r})=>{let i=!!(n||r);return[`app-sidebar-brand`,i&&`wui-brand-has-mark`,i&&!e&&!t&&`wui-brand-mark-only`,(t||r)&&`wui-brand-themed`].filter(Boolean).join(` `)},R=({logoLight:e,logoDark:t,markLight:n,markDark:r,brandName:i})=>{let a=i??``,o=[e&&/* @__PURE__ */ C(`img`,{className:`wui-brand-logo wui-brand-light`,src:e,alt:a},`logo-light`),t&&/* @__PURE__ */ C(`img`,{className:`wui-brand-logo wui-brand-dark`,src:t,alt:``,"aria-hidden":`true`},`logo-dark`)],s=[n&&[`mark-light`,`wui-brand-mark wui-brand-light`,n],r&&[`mark-dark`,`wui-brand-mark wui-brand-dark`,r]].filter(Boolean).map(([t,n,r],i)=>i===0&&!e?/* @__PURE__ */ C(`img`,{className:n,src:r,alt:a},t):/* @__PURE__ */ C(`img`,{className:n,src:r,alt:``,"aria-hidden":`true`},t));return[...o,...s].filter(Boolean)};function z(e){let{marker:t,props:n}=c(`AppShell`,e),{groups:l=[],brand:u,logoLight:v,logoDark:S,markLight:T,markDark:E,brandName:D,sidebarStart:O,sidebarStartCompact:k,sidebarFooter:P,topbarStart:F,topbarEnd:I,footer:L,launcher:z,children:ne,collapsed:B,onCollapsedChange:re,noSidebar:V=!1,nav:H=`side`,density:W=`comfortable`,itemHeight:G,iconVariant:K,topbarTone:de=`neutral`,navLabel:fe=`Main navigation`,linkComponent:q,currentPath:pe,rememberCollapsed:me=!1,collapsedCookie:he=`wui-shell-collapsed`,foldedCookie:J=r,tabBarLabel:ge=`Quick navigation`,moreLabel:_e=`More`,skipLabel:ve=`Skip to content`,openNavLabel:ye=`Open navigation`,closeNavLabel:be=`Close navigation`,expandNavLabel:xe=`Expand navigation`,collapseNavLabel:Se=`Collapse navigation`,newLabel:Ce=`New`,togglePagesLabel:we=`Show or hide {name} pages`,accountMenuLabel:Te=`Account menu for {name}`,roleLabel:Ee=`Role:`,rolesLabel:De=`Roles:`,unreadLabel:Oe=`Unread`,markAllReadLabel:ke=`Mark all read`,viewAllLabel:Ae=`View all`,loadingNotificationsText:je=`Loading…`,noUnreadText:Me=`No unread notifications`,unreadNotificationsText:Ne=`{count} unread notifications`,unreadBellLabel:Pe=`{label}, {count} unread`,searchResultsLabel:Fe=`Search results`,noResultsText:Ie=`No results`,noResultsForText:Le=`No results for “{value}”`,resultsCountText:Re=`{count} results`,resultCountText:ze=`{count} result`,userMenu:Be,notifications:Ve,search:He,className:Ue=``,style:We,...Ge}=n;m(`AppShell`,Ge),p(`AppShell`,`density`,W,A),p(`AppShell`,`topbarTone`,de,j),p(`AppShell`,`nav`,H,M),p(`AppShell`,`iconVariant`,K,N);let Ke=G>0?{...We,"--wui-nav-item-height":`${G}px`}:We,[qe,Je]=x(()=>me&&B===void 0&&typeof document<`u`?a(he)??!1:!1),[Y,X]=x(!1),[Ye,Xe]=x(!1),[Ze,Qe]=x(!1),$e=b(null),et=b(null),tt=b(null),Z=B??qe,nt=()=>{let e=!Z;B===void 0&&Je(e),me&&s(e,he),re?.(e)},rt=l.some(e=>e.collapsible),[it,at]=x(()=>rt&&typeof document<`u`?i(J):/* @__PURE__ */ new Set),ot=e=>{let t=new Set(it);t.has(e)?t.delete(e):t.add(e),at(t),o(t,J)},Q=y(()=>te(l,pe),[l,pe]),$=V?null:ie(Q);_(()=>{let e=()=>Xe(window.scrollY>4);return e(),window.addEventListener(`scroll`,e,{passive:!0}),()=>window.removeEventListener(`scroll`,e)},[]),_(()=>{h()},[]),_(()=>{g($e.current)},[]),_(()=>{let e=$e.current;if(!e)return;let t=()=>Qe(e.scrollHeight>e.clientHeight);if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[Q]);let st=!!L;_(()=>{let e=tt.current,t=et.current;if(!st||!e||!t)return;let n=()=>t.style.setProperty(`--app-footer-h`,`${e.offsetHeight}px`);n();let r=typeof ResizeObserver>`u`?null:new ResizeObserver(n);return r?.observe(e),()=>{r?.disconnect(),t.style.removeProperty(`--app-footer-h`)}},[st]),_(()=>{if(!Y)return;let e=e=>{e.key===`Escape`&&X(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[Y]);let ct=[`app-shell`,Z?`collapsed`:``,V?`no-sidebar`:``,H===`top`?`wui-shell-top`:``,Y?`mobile-open`:``,Ue].filter(Boolean).join(` `);return/* @__PURE__ */ w(`div`,{ref:et,className:ct,"data-density":W===`compact`?`compact`:void 0,"data-wui-folded-cookie":rt?J:void 0,style:Ke,...t,...Ge,children:[/* @__PURE__ */ C(`a`,{className:`wui-skip-link`,href:`#main-content`,children:ve}),/* @__PURE__ */ w(`aside`,{className:`app-sidebar`,children:[(u||v||S||T||E)&&/* @__PURE__ */ w(`div`,{className:ee({logoLight:v,logoDark:S,markLight:T,markDark:E}),children:[R({logoLight:v,logoDark:S,markLight:T,markDark:E,brandName:D}),u]}),O&&/* @__PURE__ */ C(`div`,{className:`app-sidebar-start`,children:O}),k&&/* @__PURE__ */ C(`div`,{className:`app-sidebar-start-compact`,children:k}),/* @__PURE__ */ C(`nav`,{className:`app-sidebar-scroll`,"aria-label":fe,ref:$e,tabIndex:Ze?0:void 0,children:Q.map((e,t)=>{let n=e.items.map(e=>e.header==null?/* @__PURE__ */ C(se,{item:e,linkComponent:q,onNavigate:()=>X(!1),iconVariant:K,newLabel:Ce,togglePagesLabel:we},e.key??e.href??e.label):/* @__PURE__ */ C(`div`,{className:`wui-nav-header`,children:e.header},e.key??e.header));if(!e.collapsible)return/* @__PURE__ */ w(`div`,{className:`app-nav-group`,children:[e.label&&/* @__PURE__ */ C(`div`,{className:`app-nav-group-label`,children:e.label}),n,e.after&&/* @__PURE__ */ C(`div`,{className:`wui-nav-group-after`,children:e.after})]},e.key??e.label??`group-${t}`);let r=!it.has(e.key)||!!U(e.items),i=`wui-nav-group-${e.key}`;return/* @__PURE__ */ w(`div`,{className:`app-nav-group wui-nav-group-collapsible${r?``:` wui-nav-group-folded`}`,"data-wui-nav-group":e.key,children:[/* @__PURE__ */ w(`button`,{type:`button`,className:`app-nav-group-label wui-nav-group-toggle`,"aria-expanded":r,"aria-controls":i,onClick:()=>ot(e.key),children:[/* @__PURE__ */ C(`span`,{className:`wui-nav-group-text`,children:e.label}),/* @__PURE__ */ C(`span`,{className:`wui-nav-group-caret`,children:/* @__PURE__ */ C(d,{name:`chevron-down`,size:16})})]}),/* @__PURE__ */ w(`div`,{className:`wui-nav-group-body`,id:i,children:[n,e.after&&/* @__PURE__ */ C(`div`,{className:`wui-nav-group-after`,children:e.after})]})]},e.key??`group-${t}`)})}),P&&/* @__PURE__ */ C(`div`,{className:`app-sidebar-foot`,children:P}),!V&&/* @__PURE__ */ C(`button`,{type:`button`,className:`app-sidebar-toggle`,onClick:nt,"aria-label":Z?xe:Se,"aria-expanded":!Z,children:/* @__PURE__ */ C(d,{name:`chevrons-left`,size:20})})]}),/* @__PURE__ */ w(`div`,{className:`app-main`,children:[/* @__PURE__ */ w(`header`,{className:`app-topbar${Ye?` scrolled`:``}`,"data-tone":de===`primary`?`primary`:void 0,children:[/* @__PURE__ */ w(`div`,{className:`app-topbar-start`,children:[/* @__PURE__ */ C(`button`,{type:`button`,className:`app-topbar-menu`,onClick:()=>X(!0),"aria-label":ye,"aria-expanded":Y,children:/* @__PURE__ */ C(d,{name:`menu`,size:18})}),H===`top`&&u&&/* @__PURE__ */ C(`div`,{className:`wui-shell-top-brand`,children:u}),H===`top`&&/* @__PURE__ */ C(`div`,{className:`wui-shell-top-nav`,children:/* @__PURE__ */ C(f,{items:ae(Q),ariaLabel:fe,linkComponent:q})}),F,He&&/* @__PURE__ */ C(ue,{config:He,searchResultsLabel:Fe,noResultsText:Ie,noResultsForText:Le,resultsCountText:Re,resultCountText:ze})]}),/* @__PURE__ */ w(`div`,{className:`app-topbar-end`,children:[I,Ve&&/* @__PURE__ */ C(le,{config:Ve,unreadLabel:Oe,markAllReadLabel:ke,viewAllLabel:Ae,loadingNotificationsText:je,noUnreadText:Me,unreadNotificationsText:Ne,unreadBellLabel:Pe}),Be&&/* @__PURE__ */ C(ce,{config:Be,linkComponent:q,accountMenuLabel:Te,roleLabel:Ee,rolesLabel:De})]})]}),/* @__PURE__ */ C(`main`,{className:`app-content`,id:`main-content`,children:ne}),L&&/* @__PURE__ */ C(`footer`,{className:`app-footer`,ref:tt,children:L})]}),z&&/* @__PURE__ */ C(`div`,{className:`wui-shell-launcher`,children:z}),$&&/* @__PURE__ */ w(`nav`,{className:`wui-tabbar`,"aria-label":ge,children:[$.tabs.map(e=>/* @__PURE__ */ C(oe,{tab:e,linkComponent:q,iconVariant:K},e.key??e.href)),$.hasMore&&/* @__PURE__ */ w(`button`,{type:`button`,className:`wui-tabbar-item${$.moreActive?` active`:``}`,onClick:()=>X(!0),children:[/* @__PURE__ */ C(`span`,{className:`wui-tabbar-icon`,children:/* @__PURE__ */ C(d,{name:`more`,size:24})}),/* @__PURE__ */ C(`span`,{className:`wui-tabbar-label`,children:_e})]})]}),/* @__PURE__ */ C(`button`,{type:`button`,className:`app-scrim`,onClick:()=>X(!1),"aria-label":be,tabIndex:Y?0:-1})]})}function te(e,t){for(let t of e)t.collapsible&&H(t);let r=(e,t=!1)=>(e??[]).map(e=>Array.isArray(e.children)?{...e,children:r(e.children)}:{...e}).filter(e=>B(e)?t:(e.children?.length??0)>0||!!e.href),i=e.map(e=>({...e,items:re(r(e.items,!0))})).filter(e=>e.items.some(e=>!B(e))),a=[],o=e=>{for(let t of e)B(t)||(a.push(t),t.children&&o(t.children))};for(let e of i)o(e.items);for(let e of a)m(`AppShell items`,ne(e)),p(`AppShell`,`match`,e.match,k),p(`AppShell`,`iconVariant`,e.iconVariant,N);let s=null;if(t!=null&&!a.some(e=>e.active===!0)){let e=-1;for(let r of a){if(r.active!=null||r.children?.length&&!r.href)continue;let i=n(t,r.href,{exact:r.match===`exact`,also:r.matchAlso});if(i<0)continue;let a=r.match===`exact`&&n(t,r.href,{exact:!0})>=0?1/0:i;a>e&&(e=a,s=r)}}for(let e of a)e.active=e.active??e===s;return i}function ne(e){return Object.fromEntries(Object.entries(e).filter(([e])=>!P.has(e)))}var B=e=>e.header!=null;function re(e){return e.filter((t,n)=>{if(!B(t))return!0;let r=e.findIndex((e,t)=>t>n&&B(e));return e.slice(n+1,r<0?void 0:r).length>0})}var V=/* @__PURE__ */ new Set;function H(t){if(t.key!=null&&O.test(t.key))return;let n=t.key==null?`<AppShell> a collapsible group needs a key so its folded state can be remembered.`:`<AppShell> collapsible group key "${t.key}" must use lower-case letters, digits and hyphens.`,r=!0;try{r=process.env.NODE_ENV!==`production`}catch{r=!0}r&&!V.has(n)&&(V.add(n),e(n))}function ie(e){let t=[],n=e=>{for(let r of e)B(r)||(r.children?.length?n(r.children):t.push(r))};for(let t of e)n(t.items);let r=t.filter(e=>e.tab);if(r.length===0)return null;let i=r.length<t.length,a=i?E:D;if(r.length>a)throw Error(`<AppShell>: ${r.length} items carry tab: true, but the phone tab bar holds ${a} (${i?`4 plus More, because other items exist`:`5 when every item is a tab`}). Flag fewer items.`);return{tabs:r,hasMore:i,moreActive:t.some(e=>!e.tab&&e.active)}}function ae(e){let t=e=>({key:e.key??e.href??e.label,label:e.label,to:e.href,current:!!e.active}),n=e=>e.flatMap(e=>B(e)?[]:[...e.href?[{...t(e),icon:e.icon}]:[],...n(e.children??[])]),r=[];for(let i of e.flatMap(e=>e.items)){if(B(i))continue;let e=n(i.children??[]);if(e.length>0){let n=i.href?[{...t(i),icon:i.icon}]:[];r.push({key:t(i).key,label:i.label,links:[...n,...e]})}else i.href&&r.push(t(i))}return r}function oe({tab:e,linkComponent:t,iconVariant:n}){let r=`wui-tabbar-item${e.active?` active`:``}`,i=/* @__PURE__ */ w(S,{children:[e.icon&&/* @__PURE__ */ C(`span`,{className:`wui-tabbar-icon`,children:typeof e.icon==`string`?/* @__PURE__ */ C(d,{name:e.icon,size:24,variant:e.iconVariant??n}):e.icon}),/* @__PURE__ */ C(`span`,{className:`wui-tabbar-label`,children:e.tabLabel??e.label}),e.badge!=null&&/* @__PURE__ */ C(`span`,{className:`wui-tabbar-badge${e.badgeTone?` tone-${e.badgeTone}`:``}`,title:e.badgeTitle||void 0,children:e.badge})]}),a=e.active?`page`:void 0;return t?/* @__PURE__ */ C(t,{className:r,to:e.href,"aria-current":a,children:i}):/* @__PURE__ */ C(`a`,{className:r,href:e.href,"aria-current":a,children:i})}function U(e){for(let t of e){if(t.active)return t;let e=t.children?.length?U(t.children):void 0;if(e)return e}}function se({item:e,linkComponent:n,onNavigate:r,depth:i=0,iconVariant:a,newLabel:o,togglePagesLabel:s}){let c=i>0,l=i>1?` wui-nav-depth-${Math.min(i,6)}`:``,u=Array.isArray(e.children)&&e.children.length>0,f=u?U(e.children):void 0,p=!!f,m=f?f.key??f.href??f.label:null,[h,g]=x(p);_(()=>{m!=null&&g(!0)},[m]);let v=typeof e.label==`string`?e.label:void 0,y=!c&&e.icon&&/* @__PURE__ */ C(`span`,{className:`app-nav-icon`,children:typeof e.icon==`string`?/* @__PURE__ */ C(d,{name:e.icon,size:e.iconSize??22,variant:e.iconVariant??a}):e.icon}),b=e.badge!=null&&/* @__PURE__ */ C(`span`,{className:`app-nav-badge${e.badgeTone?` tone-${e.badgeTone}`:``}`,title:e.badgeTitle||void 0,children:e.badge}),T=L(e.newUntil)&&/* @__PURE__ */ C(`span`,{className:`wui-nav-new`,children:o}),E=/* @__PURE__ */ w(S,{children:[y,/* @__PURE__ */ C(`span`,{className:`app-nav-text`,children:e.label}),T,b,e.trailingIcon&&/* @__PURE__ */ C(`span`,{className:`app-nav-trailing`,children:typeof e.trailingIcon==`string`?/* @__PURE__ */ C(d,{name:e.trailingIcon,size:16}):e.trailingIcon})]}),D=e.active?`page`:void 0;if(u){let u=/* @__PURE__ */ C(`div`,{className:`app-nav-sub${h?` expanded`:``}`,inert:!h,"aria-hidden":!h||void 0,children:/* @__PURE__ */ C(`div`,{className:`app-nav-sub-inner`,children:e.children.map(e=>/* @__PURE__ */ C(se,{item:e,linkComponent:n,onNavigate:r,depth:i+1,iconVariant:a,newLabel:o,togglePagesLabel:s},e.key??e.href))})});if(e.href){let i=n?/* @__PURE__ */ C(n,{className:`wui-nav-split-link`,to:e.href,"aria-current":D,onClick:r,children:E}):/* @__PURE__ */ C(`a`,{className:`wui-nav-split-link`,href:e.href,"aria-current":D,onClick:r,children:E});return/* @__PURE__ */ w(S,{children:[/* @__PURE__ */ w(`div`,{className:`app-nav-item has-children wui-nav-split${c?` app-nav-subitem`:``}${p||e.active?` active`:``}${l}`,"data-label":v,children:[i,/* @__PURE__ */ C(`button`,{type:`button`,className:`app-nav-caret wui-nav-split-toggle`,"aria-expanded":h,"aria-label":t(s,{name:v??``}),onClick:()=>g(e=>!e),children:/* @__PURE__ */ C(d,{name:`chevron-right`,size:16})})]}),u]})}return/* @__PURE__ */ w(S,{children:[/* @__PURE__ */ w(`button`,{type:`button`,className:`app-nav-item${c?` app-nav-subitem`:``} has-children${p?` active`:``}${l}`,"aria-expanded":h,"data-label":v,onClick:()=>g(e=>!e),children:[y,/* @__PURE__ */ C(`span`,{className:`app-nav-text`,children:e.label}),T,b,/* @__PURE__ */ C(`span`,{className:`app-nav-caret`,children:/* @__PURE__ */ C(d,{name:`chevron-right`,size:16})})]}),u]})}let O=`app-nav-item${c?` app-nav-subitem`:``}${e.active?` active`:``}${l}`;return n?/* @__PURE__ */ C(n,{className:O,to:e.href,"aria-current":D,"data-label":v,onClick:r,children:E}):/* @__PURE__ */ C(`a`,{className:O,href:e.href,"aria-current":D,"data-label":v,onClick:r,children:E})}function W(){let[e,t]=x(!1),n=b(null);return _(()=>{if(!e)return;let r=e=>{n.current?.contains(e.target)||t(!1)},i=e=>{e.key===`Escape`&&(t(!1),n.current?.querySelector(`button`)?.focus())};return document.addEventListener(`mousedown`,r),document.addEventListener(`keydown`,i),()=>{document.removeEventListener(`mousedown`,r),document.removeEventListener(`keydown`,i)}},[e]),{open:e,setOpen:t,ref:n}}function ce({config:e,linkComponent:n,accountMenuLabel:r,roleLabel:i,rolesLabel:a}){let o=v(),{open:s,setOpen:c,ref:f}=W(),{name:m,role:h,roles:g=[],photo:_,profileHref:y,profileLabel:b=`My profile`,onLogout:x,logoutAction:T,logoutLabel:E=`Sign out`,head:D,section:O,logoutVariant:k=`item`,items:A=[]}=e;if(p(`AppShell`,`userMenu.logoutVariant`,k,[`item`,`button`]),!m)throw Error(`<AppShell> userMenu.name is required; the trigger and the avatar are named from it.`);let j=g.map(e=>(e??``).trim()).filter(Boolean),M=()=>c(!1),N=(e,t,r,i)=>n?/* @__PURE__ */ C(n,{className:`dropdown-item`,to:e,onClick:i,children:t},r):/* @__PURE__ */ C(`a`,{className:`dropdown-item`,href:e,onClick:i,children:t},r),P=/* @__PURE__ */ C(d,{name:`log-out`,size:18}),F=/* @__PURE__ */ w(S,{children:[P,E]});return/* @__PURE__ */ w(`div`,{className:`dropdown wui-usermenu`,ref:f,children:[/* @__PURE__ */ w(`button`,{type:`button`,id:o,className:`wui-usermenu-trigger`,"aria-expanded":s,"aria-label":t(r,{name:m}),onClick:()=>c(e=>!e),children:[/* @__PURE__ */ C(l,{name:m,src:_,tone:`auto`}),/* @__PURE__ */ w(`span`,{className:`wui-usermenu-text`,children:[/* @__PURE__ */ C(`span`,{className:`wui-usermenu-name`,children:m}),h&&/* @__PURE__ */ C(`span`,{className:`wui-usermenu-role`,children:h})]}),/* @__PURE__ */ C(d,{name:`chevron-down`,size:14,className:`wui-usermenu-caret`})]}),/* @__PURE__ */ w(`div`,{className:`dropdown-menu dropdown-menu-end wui-usermenu-menu${s?` show`:``}`,"aria-labelledby":o,"data-bs-popper":s?`static`:void 0,children:[/* @__PURE__ */ w(`div`,{className:`wui-usermenu-head`,children:[/* @__PURE__ */ C(l,{name:m,src:_,size:`lg`,tone:`auto`}),/* @__PURE__ */ w(`div`,{className:`wui-usermenu-who`,children:[/* @__PURE__ */ C(`div`,{className:`wui-usermenu-name`,children:m}),h&&/* @__PURE__ */ C(`div`,{className:`wui-usermenu-role`,children:h}),j.length>0&&/* @__PURE__ */ w(`div`,{className:`wui-usermenu-roles`,children:[/* @__PURE__ */ C(`span`,{className:`wui-usermenu-roles-label`,children:j.length===1?i:a}),` ${j.join(`, `)}`]}),D?/* @__PURE__ */ C(`div`,{className:`wui-usermenu-extra`,children:D}):null]})]}),O?/* @__PURE__ */ C(`div`,{className:`wui-usermenu-section`,children:O}):null,y&&N(y,/* @__PURE__ */ w(S,{children:[/* @__PURE__ */ C(d,{name:`user`,size:18}),b]}),void 0,M),A.map(e=>{if(e.divider)return/* @__PURE__ */ C(`hr`,{className:`dropdown-divider`},e.key);let t=/* @__PURE__ */ w(S,{children:[e.icon&&/* @__PURE__ */ C(d,{name:e.icon,size:18}),e.label]}),n=()=>{e.onClick?.(),M()};return e.href?N(e.href,t,e.key,n):/* @__PURE__ */ C(`button`,{type:`button`,className:`dropdown-item`,onClick:n,children:t},e.key)}),k===`button`?(T||x)&&/* @__PURE__ */ C(`div`,{className:`wui-usermenu-foot`,children:T?/* @__PURE__ */ C(`form`,{method:`post`,action:T,className:`wui-usermenu-logout`,children:/* @__PURE__ */ C(u,{type:`submit`,tone:`danger`,variant:`soft`,block:!0,leftIcon:P,children:E})}):/* @__PURE__ */ C(u,{type:`button`,tone:`danger`,variant:`soft`,block:!0,leftIcon:P,onClick:()=>{M(),x()},children:E})}):T?/* @__PURE__ */ C(`form`,{method:`post`,action:T,className:`wui-usermenu-logout`,children:/* @__PURE__ */ C(`button`,{type:`submit`,className:`dropdown-item danger`,children:F})}):x&&/* @__PURE__ */ C(`button`,{type:`button`,className:`dropdown-item danger`,onClick:()=>{M(),x()},children:F})]})]})}function le({config:e,unreadLabel:n,markAllReadLabel:r,viewAllLabel:i,loadingNotificationsText:a,noUnreadText:o,unreadNotificationsText:s,unreadBellLabel:c}){let l=v(),{open:u,setOpen:f,ref:p}=W(),{unread:m=0,items:h,loading:g=!1,onOpen:y,onMarkAllRead:T,viewAllHref:E,label:D=`Notifications`,emptyText:O=`You are all caught up.`}=e,[k,A]=x(``),j=b(m);_(()=>{j.current!==m&&(j.current=m,A(m===0?o:t(s,{count:F(m)})))},[m,o,s]);let M=null;return h?.length?M=/* @__PURE__ */ C(`div`,{className:`wui-bell-items`,children:h.map((e,t)=>{let r=`wui-bell-item${e.read?` wui-bell-item-read`:``}`,i=/* @__PURE__ */ w(S,{children:[/* @__PURE__ */ C(`span`,{className:`wui-bell-dot`,"aria-hidden":`true`}),e.icon&&/* @__PURE__ */ C(`span`,{className:`wui-bell-icon`,children:/* @__PURE__ */ C(d,{name:e.icon,size:18})}),/* @__PURE__ */ w(`span`,{className:`wui-bell-body`,children:[!e.read&&/* @__PURE__ */ w(`span`,{className:`visually-hidden`,children:[n,`: `]}),/* @__PURE__ */ C(`span`,{className:`wui-bell-item-title`,children:e.title}),e.time&&/* @__PURE__ */ C(`span`,{className:`wui-bell-when`,children:e.time})]})]});return e.href?/* @__PURE__ */ C(`a`,{className:r,href:e.href,"data-id":e.id,children:i},e.id??t):/* @__PURE__ */ C(`div`,{className:r,"data-id":e.id,children:i},e.id??t)})}):g?M=/* @__PURE__ */ C(`div`,{className:`wui-bell-state`,children:a}):h&&(M=/* @__PURE__ */ C(`div`,{className:`wui-bell-state`,children:O})),/* @__PURE__ */ w(`div`,{className:`dropdown wui-bell`,ref:p,children:[/* @__PURE__ */ w(`button`,{type:`button`,id:l,className:`topbar-icon-btn wui-bell-trigger`,"aria-expanded":u,"aria-label":m===0?D:t(c,{label:D,count:F(m)}),onClick:()=>{let e=!u;f(e),e&&y?.()},children:[/* @__PURE__ */ C(d,{name:`notification`,size:20}),/* @__PURE__ */ C(`span`,{className:`wui-bell-count`,"aria-hidden":`true`,hidden:m===0,children:F(m)})]}),/* @__PURE__ */ C(`span`,{className:`visually-hidden`,"aria-live":`polite`,children:k}),/* @__PURE__ */ w(`div`,{className:`dropdown-menu dropdown-menu-end wui-bell-menu${u?` show`:``}`,"aria-labelledby":l,"data-bs-popper":u?`static`:void 0,children:[/* @__PURE__ */ w(`div`,{className:`wui-bell-head`,children:[/* @__PURE__ */ C(`span`,{className:`wui-bell-title`,children:D}),T&&/* @__PURE__ */ C(`button`,{type:`button`,className:`wui-bell-markall`,onClick:T,children:r})]}),/* @__PURE__ */ C(`div`,{className:`wui-bell-list`,"aria-busy":g||void 0,children:M}),E&&/* @__PURE__ */ C(`a`,{className:`wui-bell-foot`,href:E,children:i})]})]})}var G=e=>!!e&&(e.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(e.tagName));function ue({config:e,searchResultsLabel:n,noResultsText:r,noResultsForText:i,resultsCountText:a,resultCountText:o}){let s=v(),{value:c=``,onChange:l,results:u=null,loading:f=!1,onSelect:p,onSubmit:m,onFocus:h,placeholder:g=`Search`}=e,[S,T]=x(!1),[E,D]=x(!1),[O,k]=x({results:null,index:-1}),A=O.results===u?O.index:-1,j=e=>k({results:u,index:e}),M=b(null),N=b(null),P=b([]),F=y(()=>(u??[]).flatMap(e=>e.hits??[]),[u]),I=u!=null&&!E,L=F.length;_(()=>{let e=e=>{e.key!==`/`||e.ctrlKey||e.metaKey||e.altKey||G(e.target)||(e.preventDefault(),T(!0),N.current?.focus())},t=e=>{M.current?.contains(e.target)||(D(!0),T(!1))};return document.addEventListener(`keydown`,e),document.addEventListener(`pointerdown`,t),()=>{document.removeEventListener(`keydown`,e),document.removeEventListener(`pointerdown`,t)}},[]);let ee=e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){if(!I||L===0)return;e.preventDefault(),j((A+(e.key===`ArrowDown`?1:-1)+L)%L)}else e.key===`Enter`?I&&A>=0&&P.current[A]?(e.preventDefault(),P.current[A].click()):m&&c.trim()!==``&&(e.preventDefault(),m(c.trim())):e.key===`Escape`&&(I?(e.preventDefault(),D(!0)):S&&(e.preventDefault(),T(!1)))},R=-1;return P.current=[],/* @__PURE__ */ w(`div`,{className:`wui-topsearch${S?` is-open`:``}${f?` is-loading`:``}`,ref:M,children:[/* @__PURE__ */ C(`button`,{type:`button`,className:`topbar-icon-btn wui-topsearch-open`,"aria-label":g,"aria-expanded":S,"aria-controls":`${s}-panel`,onClick:()=>{let e=!S;T(e),e&&N.current?.focus()},children:/* @__PURE__ */ C(d,{name:`search`,size:20})}),/* @__PURE__ */ w(`div`,{className:`wui-topsearch-panel`,id:`${s}-panel`,children:[/* @__PURE__ */ w(`div`,{className:`search-wrap`,children:[/* @__PURE__ */ C(d,{name:`search`,size:18,className:`search-icon`}),/* @__PURE__ */ C(`input`,{ref:N,type:`search`,className:`form-control input search-input`,id:`${s}-input`,placeholder:g,"aria-label":g,role:`combobox`,"aria-autocomplete":`list`,"aria-expanded":I,"aria-controls":`${s}-list`,"aria-activedescendant":I&&A>=0?`${s}-opt-${A}`:void 0,autoComplete:`off`,value:c,onChange:e=>{D(!1),l?.(e.target.value)},onKeyDown:ee,onFocus:h})]}),/* @__PURE__ */ C(`div`,{className:`wui-topsearch-results`,id:`${s}-list`,role:`listbox`,"aria-label":n,hidden:!I,children:I&&/* @__PURE__ */ w(`div`,{className:`wui-topsearch-groups`,role:`presentation`,children:[L===0&&/* @__PURE__ */ C(`div`,{className:`wui-topsearch-empty`,role:`option`,"aria-disabled":`true`,"aria-selected":`false`,children:t(i,{value:c})}),u.filter(e=>e.hits?.length).map((e,t)=>/* @__PURE__ */ w(`div`,{className:`wui-topsearch-group`,role:`group`,"aria-label":e.label??``,children:[e.label&&/* @__PURE__ */ C(`div`,{className:`wui-topsearch-group-label`,role:`presentation`,children:e.label}),e.hits.map(e=>{R+=1;let t=R;return/* @__PURE__ */ w(`a`,{className:`wui-topsearch-hit${t===A?` is-active`:``}`,role:`option`,"aria-selected":t===A,id:`${s}-opt-${t}`,href:e.href,ref:e=>{P.current[t]=e},onClick:t=>p?.(e,t),children:[e.icon&&/* @__PURE__ */ C(`span`,{className:`wui-topsearch-hit-icon`,children:/* @__PURE__ */ C(d,{name:e.icon,size:18})}),/* @__PURE__ */ w(`span`,{className:`wui-topsearch-hit-text`,children:[/* @__PURE__ */ C(`span`,{className:`wui-topsearch-hit-title`,children:e.title}),e.subtitle&&/* @__PURE__ */ C(`span`,{className:`wui-topsearch-hit-sub`,children:e.subtitle})]})]},`${e.href}-${t}`)})]},e.label??t))]})})]}),/* @__PURE__ */ C(`span`,{className:`visually-hidden`,"aria-live":`polite`,children:I?L===0?r:t(L===1?o:a,{count:L}):``})]})}export{z as default};
|
package/dist/guidance.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webority/ui-react",
|
|
3
|
-
"version": "0.143.
|
|
3
|
+
"version": "0.143.1",
|
|
4
4
|
"description": "Webority shared React component library — App* primitives on react-bootstrap + the @webority/theme design system.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"type": "module",
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
},
|
|
30
30
|
"sideEffects": false,
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@webority/markdown-core": "0.143.
|
|
33
|
-
"@webority/theme": "0.143.
|
|
34
|
-
"@webority/ui-elements": "0.143.
|
|
35
|
-
"@webority/web-core": "0.143.
|
|
32
|
+
"@webority/markdown-core": "0.143.1",
|
|
33
|
+
"@webority/theme": "0.143.1",
|
|
34
|
+
"@webority/ui-elements": "0.143.1",
|
|
35
|
+
"@webority/web-core": "0.143.1"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"@webority/analytics": "^0.35.0",
|
|
@@ -50,8 +50,8 @@
|
|
|
50
50
|
"@vitejs/plugin-react": "^6.0.1",
|
|
51
51
|
"@vitest/coverage-v8": "5.0.1",
|
|
52
52
|
"@webority/analytics": "0.35.1",
|
|
53
|
-
"@webority/canvas-kit": "0.143.
|
|
54
|
-
"@webority/tokens": "0.143.
|
|
53
|
+
"@webority/canvas-kit": "0.143.1",
|
|
54
|
+
"@webority/tokens": "0.143.1",
|
|
55
55
|
"bootstrap": "5.3.3",
|
|
56
56
|
"jsdom": "30.1.1",
|
|
57
57
|
"react": "^19.2.6",
|