@webority/ui-react 0.172.1 → 0.173.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.
@@ -2,7 +2,7 @@
2
2
  "kind": "WeborityWeb",
3
3
  "library": {
4
4
  "name": "@webority/ui-react",
5
- "version": "0.172.1"
5
+ "version": "0.173.0"
6
6
  },
7
7
  "rendererProtocolVersion": 14,
8
8
  "platform": "Web",
@@ -1,21 +1,21 @@
1
1
  {
2
2
  "name": "webority-web",
3
- "version": "0.172.1",
3
+ "version": "0.173.0",
4
4
  "platform": "Web",
5
5
  "kitModuleVersion": 2,
6
6
  "rendererProtocolVersion": 14,
7
7
  "library": {
8
8
  "name": "@webority/ui-react",
9
- "version": "0.172.1"
9
+ "version": "0.173.0"
10
10
  },
11
11
  "files": {
12
12
  "manifest.json": {
13
- "sha256": "9888f02c2f8c76cb114dcac2a454ab3c0953bde08d30eb7e6f0ad3378c21d954",
13
+ "sha256": "afc4c0cce964d64a8319fea525bb86bf6ca56168d0653733b5205873a42b39f3",
14
14
  "bytes": 1130050
15
15
  },
16
16
  "kit.js": {
17
- "sha256": "6701a55ea018b12b388c186d21b93a665e22b4eadb1a4c82b4996975011ef42e",
18
- "bytes": 10140955
17
+ "sha256": "6536a3aff304dd1fe91f5cb675b257c2c8124a8c5737f71a17ce659b28a7a2d5",
18
+ "bytes": 10141194
19
19
  },
20
20
  "kit.css": {
21
21
  "sha256": "13b14f71fb6ea024945f95cba617b4f1d49f44a65ba7c7ed05d2354805539ef6",
@@ -1 +1 @@
1
- import{linkTarget as e}from"../lib/linkTarget.js";import{TargetLink as t}from"../lib/TargetLink.js";import n from"../lib/useElementEntry.js";import r from"../lib/useWuiText.js";import{FILL_VARIANTS as i}from"../lib/vocabulary.js";import{splitMarkerProps as a}from"../lib/wuiMarker.js";import o from"./AppAvatar.js";import s from"./AppBadge.js";import c from"./AppButton.js";import l from"./AppIcon.js";import u from"./AppMarkdown.js";import d from"./assertValidValue.js";import f from"./warnUnknownProps.js";import{COMMENT_REACTIONS as p,formatDateTime as m,formatFileSize as h,formatNumber as g,initialsOf as _,mentionTextFromValue as v,parseMentionValue as y,toInstant as b}from"@webority/ui-elements/helpers";import{Fragment as x,useEffect as S,useId as C,useRef as w}from"react";import{jsx as T,jsxs as E}from"react/jsx-runtime";import{COMMENT_THREAD_TEXT as D,fillText as O}from"@webority/ui-elements/text";var k=[`stacked`,`inline`],A=[`list`,`conversation`],j=()=>import(`@webority/ui-elements/elements/comment-thread`),M=()=>import(`@webority/ui-elements/elements/mention-input`),N=e=>y(e??``).map((e,t)=>({key:`segment-${t}`,seg:e})),P=e=>e.localName===`wui-mention-input`;function F(e){let{marker:t,props:s}=a(`AppCommentThread`,e),l=r(`commentThread`,D),{comments:u=[],onPost:m,onReply:h,onEdit:g,onDelete:_,onReact:v,people:y,loadPeople:b,reactionChoices:x,allowReplies:O=!0,allowReactions:N=!0,composerPlaceholder:F,variant:L=`list`,composer:R=`stacked`,author:z,postLabel:B=l.postLabel,postVariant:V,composerRows:H,readOnly:U=!1,markdown:W=!1,linkComponent:G,label:K=l.label,internalLabel:ee=l.internalLabel,attachmentsLabel:te=l.attachmentsLabel,composerLabel:ne=l.composerLabel,noCommentsText:re=l.noCommentsText,reactionsLabel:ie=l.reactionsLabel,repliesToLabel:ae=l.repliesToLabel,editedLabel:oe=l.editedLabel,deletedText:se=l.deletedText,replyLabel:ce=l.replyLabel,editLabel:le=l.editLabel,deleteLabel:ue=l.deleteLabel,deleteConfirmText:de=l.deleteConfirmText,cancelLabel:fe=l.cancelLabel,addReactionLabel:pe=l.addReactionLabel,chooseReactionLabel:me=l.chooseReactionLabel,peopleLabel:he=l.peopleLabel,id:ge,className:_e=``,...q}=s;f(`AppCommentThread`,q),d(`AppCommentThread`,`variant`,L,A),d(`AppCommentThread`,`composer`,R,k),V!==void 0&&d(`AppCommentThread`,`postVariant`,V,i);let J=n(`wui-comment-thread`,j);n(`wui-mention-input`,M);let ve=C(),Y=ge||`comment-thread-${ve.replace(/[^a-zA-Z0-9_-]/g,``)}`,X=w(null),Z=typeof b==`function`,ye=x?.length?x:p,Q=R===`inline`,be=H??(Q?1:3),xe={reactionsLabel:ie,repliesToLabel:ae,editedLabel:oe,deletedText:se,replyLabel:ce,editLabel:le,deleteLabel:ue,deleteConfirmText:de,cancelLabel:fe,addReactionLabel:pe},$=w({onPost:m,onReply:h,onEdit:g,onDelete:_,onReact:v,loadPeople:b});return $.current={onPost:m,onReply:h,onEdit:g,onDelete:_,onReact:v,loadPeople:b},S(()=>{let e=X.current;if(e&&J)return e.submit=async e=>{let t=$.current;e.intent===`post`?await t.onPost?.(e.body):e.intent===`reply`?await t.onReply?.(e.parentId,e.body):e.intent===`edit`?await t.onEdit?.(e.commentId,e.body):e.intent===`delete`?await t.onDelete?.(e.commentId):e.intent===`react`&&await t.onReact?.(e.commentId,e.emoji)},()=>{e.submit=void 0}},[J]),S(()=>{let e=X.current;e&&J&&!Z&&(e.people=y||[])},[y,Z,J]),S(()=>{let e=X.current;if(!e||!Z)return;let t=/* @__PURE__ */ new WeakMap,n=async e=>{let n=e.target;if(!(e instanceof CustomEvent)||!(n instanceof HTMLElement)||!P(n))throw TypeError(`<wui-comment-thread> search came from something other than a mention box.`);let r=e.detail;if(typeof r!=`object`||!r||!(`query`in r)||typeof r.query!=`string`)throw TypeError(`<wui-comment-thread> search carried no query.`);let i=r.query,{loadPeople:a}=$.current;if(typeof a!=`function`)throw Error(`<AppCommentThread> is remote but has no loadPeople.`);let o=(t.get(n)??0)+1;t.set(n,o),n.loading=!0;try{let e=await a(i);t.get(n)===o&&(n.people=e||[])}catch(e){t.get(n)===o&&(n.people=[],n.searchFailed=!0,reportError(e))}finally{t.get(n)===o&&(n.loading=!1)}};return e.addEventListener(`search`,n),()=>e.removeEventListener(`search`,n)},[Z]),/* @__PURE__ */ E(`wui-comment-thread`,{ref:X,id:Y,class:[`wui-comment-thread`,L===`conversation`&&`wui-comment-thread--conversation`,_e].filter(Boolean).join(` `),controlled:``,"read-only":U?``:void 0,remote:Z?``:void 0,"reaction-choices":x?.length?x.join(` `):void 0,"no-replies":O?void 0:``,"no-reactions":N?void 0:``,"composer-placeholder":F,...t,...q,children:[/* @__PURE__ */ T(`div`,{className:`wui-comment-items`,"data-wui-items":``,children:u.length?/* @__PURE__ */ T(`ol`,{className:`wui-comment-list`,"aria-label":K,children:u.map(e=>/* @__PURE__ */ T(I,{comment:e,topLevel:!0,readOnly:U,allowReplies:O,allowReactions:N,markdown:W,linkComponent:G,internalLabel:ee,attachmentsLabel:te,text:xe},e.id))}):/* @__PURE__ */ T(`p`,{className:`wui-comment-empty`,children:re})}),!U&&N&&/* @__PURE__ */ T(`div`,{className:`wui-reaction-picker`,role:`group`,"aria-label":me,"data-wui-picker":``,popover:`auto`,children:ye.map(e=>/* @__PURE__ */ T(`button`,{type:`button`,className:`wui-reaction-choice`,"data-wui-emoji":e,children:e},e))}),!U&&/* @__PURE__ */ E(`div`,{className:Q?`wui-comment-composer wui-comment-composer-inline`:`wui-comment-composer`,"data-wui-composer":``,children:[Q&&z?/* @__PURE__ */ T(o,{name:z,size:`sm`,tone:`auto`,className:`wui-comment-composer-avatar`}):null,/* @__PURE__ */ T(`wui-mention-input`,{id:`${Y}-new`,class:`wui-mention-input`,label:ne,"people-label":he,placeholder:F??l.composerPlaceholder,rows:String(be),remote:Z?``:void 0}),/* @__PURE__ */ T(`div`,{className:`wui-comment-form-actions`,children:/* @__PURE__ */ T(c,{variant:V??(Q?`outline`:`soft`),size:`sm`,"data-wui-action":`post`,children:B})}),/* @__PURE__ */ T(`div`,{className:`wui-comment-error`,"data-wui-error":``,hidden:!0})]}),/* @__PURE__ */ T(`span`,{className:`visually-hidden`,"data-wui-live":``,"aria-live":`polite`,"aria-atomic":`true`})]})}function I({comment:n,topLevel:r=!1,readOnly:i,allowReplies:a,allowReactions:o,markdown:d,linkComponent:f,internalLabel:p,attachmentsLabel:y,text:S}){let{id:C,author:w,at:D,value:k,edited:A,mine:j,internal:M,attachments:P=[],deleted:F,canEdit:L,canDelete:R,reactions:z=[],replies:B=[]}=n,V=w?.name||``,H=b(D),U=!i&&!F&&L,W=!i&&!F&&R,G=r&&a,K=[`wui-comment`,M&&`wui-comment--internal`,j&&`wui-comment--mine`].filter(Boolean).join(` `);return/* @__PURE__ */ E(`li`,{className:K,"data-wui-comment":C,"data-value":k??``,"data-wui-deleted":F?``:void 0,children:[/* @__PURE__ */ E(`div`,{className:`wui-comment-row`,children:[/* @__PURE__ */ E(`span`,{className:`avatar avatar-sm wui-comment-avatar`,"aria-hidden":`true`,children:[/* @__PURE__ */ T(`span`,{className:`avatar-face`,children:_(V)||`?`}),w?.src&&/* @__PURE__ */ T(`img`,{className:`avatar-img`,src:w.src,alt:``,onError:e=>{e.currentTarget.hidden=!0}})]}),/* @__PURE__ */ E(`div`,{className:`wui-comment-main`,children:[/* @__PURE__ */ E(`div`,{className:`wui-comment-head`,children:[/* @__PURE__ */ T(`span`,{className:`wui-comment-author`,children:V}),/* @__PURE__ */ T(`time`,{className:`wui-comment-time`,dateTime:Number.isFinite(H)?new Date(H).toISOString():void 0,children:m(D)}),A&&!F&&/* @__PURE__ */ T(`span`,{className:`wui-comment-edited`,children:S.editedLabel}),M&&/* @__PURE__ */ T(s,{className:`wui-comment-internal-badge`,children:p})]}),F?/* @__PURE__ */ T(`div`,{className:`wui-comment-text wui-comment-text-deleted`,children:S.deletedText}):/* @__PURE__ */ T(`div`,{className:d?`wui-comment-text wui-comment-text--markdown`:`wui-comment-text`,"data-wui-text":``,children:d?/* @__PURE__ */ T(u,{value:v(k??``).text,headings:`text`}):N(k).map(({key:e,seg:t})=>`text`in t?/* @__PURE__ */ T(x,{children:t.text},e):/* @__PURE__ */ E(`span`,{className:`wui-mention`,"data-mention-id":t.id,children:[`@`,t.label]},e))}),!F&&P.length>0&&/* @__PURE__ */ T(`ul`,{className:`wui-comment-attachments`,"aria-label":y,children:P.map(n=>{let r=e(f,{to:n.to,href:n.href,routeHref:!1});return/* @__PURE__ */ E(`li`,{children:[/* @__PURE__ */ E(t,{link:r,className:`wui-comment-attachment`,...n.to?{}:{download:!0},children:[/* @__PURE__ */ T(l,{name:`paperclip`,size:14}),n.name]}),typeof n.sizeBytes==`number`&&/* @__PURE__ */ T(`span`,{className:`wui-comment-attachment-size`,children:h(n.sizeBytes)})]},n.to??n.href)})}),U&&/* @__PURE__ */ T(`div`,{className:`wui-comment-editor`,"data-wui-editor":``,hidden:!0}),o&&!F&&(z.length>0||!i)&&/* @__PURE__ */ E(`div`,{className:`wui-comment-reactions`,role:`group`,"aria-label":S.reactionsLabel,children:[z.map(e=>i?/* @__PURE__ */ E(`span`,{className:e.mine?`wui-reaction wui-reaction-mine`:`wui-reaction`,children:[/* @__PURE__ */ T(`span`,{className:`wui-reaction-emoji`,children:e.emoji}),/* @__PURE__ */ T(`span`,{className:`wui-reaction-count`,children:g(e.count,{decimals:0})})]},e.emoji):/* @__PURE__ */ E(`button`,{type:`button`,className:e.mine?`wui-reaction wui-reaction-mine`:`wui-reaction`,"data-wui-emoji":e.emoji,"aria-pressed":e.mine?`true`:`false`,children:[/* @__PURE__ */ T(`span`,{className:`wui-reaction-emoji`,children:e.emoji}),/* @__PURE__ */ T(`span`,{className:`wui-reaction-count`,children:g(e.count,{decimals:0})})]},e.emoji)),!i&&/* @__PURE__ */ T(`button`,{type:`button`,className:`wui-reaction-add`,"data-wui-action":`react-menu`,"aria-label":S.addReactionLabel,"aria-haspopup":`true`,"aria-expanded":`false`,children:/* @__PURE__ */ T(l,{name:`emoji-smile`,size:16})})]}),!i&&!F&&(G||U||W)&&/* @__PURE__ */ E(`div`,{className:`wui-comment-actions`,"data-wui-actions":``,children:[G&&/* @__PURE__ */ T(`button`,{type:`button`,className:`wui-comment-action`,"data-wui-action":`reply`,children:S.replyLabel}),U&&/* @__PURE__ */ T(`button`,{type:`button`,className:`wui-comment-action`,"data-wui-action":`edit`,children:S.editLabel}),W&&/* @__PURE__ */ T(`button`,{type:`button`,className:`wui-comment-action`,"data-wui-action":`delete`,children:S.deleteLabel})]}),W&&/* @__PURE__ */ E(`div`,{className:`wui-comment-confirm`,"data-wui-confirm":``,hidden:!0,children:[/* @__PURE__ */ T(`span`,{className:`wui-comment-confirm-text`,children:S.deleteConfirmText}),/* @__PURE__ */ T(c,{tone:`danger`,size:`sm`,"data-wui-action":`confirm-delete`,children:S.deleteLabel}),/* @__PURE__ */ T(c,{variant:`ghost`,size:`sm`,"data-wui-action":`cancel-delete`,children:S.cancelLabel})]}),!i&&/* @__PURE__ */ T(`div`,{className:`wui-comment-error`,"data-wui-error":``,hidden:!0})]})]}),r&&B.length>0&&/* @__PURE__ */ T(`ol`,{className:`wui-comment-list wui-comment-replies`,"aria-label":O(S.repliesToLabel,{name:V}),children:B.map(e=>/* @__PURE__ */ T(I,{comment:e,readOnly:i,allowReactions:o,markdown:d,linkComponent:f,internalLabel:p,attachmentsLabel:y,text:S},e.id))}),G&&!i&&!F&&/* @__PURE__ */ T(`div`,{className:`wui-comment-reply`,"data-wui-reply":``,hidden:!0})]})}export{F as default};
1
+ import{linkTarget as e}from"../lib/linkTarget.js";import{TargetLink as t}from"../lib/TargetLink.js";import n from"../lib/useElementEntry.js";import r from"../lib/useWuiText.js";import{FILL_VARIANTS as i}from"../lib/vocabulary.js";import{splitMarkerProps as a}from"../lib/wuiMarker.js";import o from"./AppAvatar.js";import s from"./AppBadge.js";import c from"./AppButton.js";import l from"./AppIcon.js";import u from"./AppMarkdown.js";import d from"./assertValidValue.js";import f from"./warnUnknownProps.js";import{COMMENT_REACTIONS as p,formatDateTime as m,formatFileSize as h,formatNumber as g,initialsOf as _,mentionTextFromValue as v,parseMentionValue as y,toInstant as b}from"@webority/ui-elements/helpers";import{Fragment as x,useEffect as S,useId as C,useRef as w}from"react";import{jsx as T,jsxs as E}from"react/jsx-runtime";import{COMMENT_THREAD_TEXT as D,fillText as O}from"@webority/ui-elements/text";var k=[`stacked`,`inline`],A=[`list`,`conversation`],j=()=>import(`@webority/ui-elements/elements/comment-thread`),M=()=>import(`@webority/ui-elements/elements/mention-input`),N=e=>y(e??``).map((e,t)=>({key:`segment-${t}`,seg:e})),P=e=>e.localName===`wui-mention-input`;function F(e){let{marker:t,props:s}=a(`AppCommentThread`,e),l=r(`commentThread`,D),{comments:u=[],onPost:m,onReply:h,onEdit:g,onDelete:_,onReact:v,people:y,loadPeople:b,reactionChoices:x,allowReplies:O=!0,allowReactions:N=!0,composerPlaceholder:F,variant:L=`list`,composer:R=`stacked`,author:z,postLabel:B=l.postLabel,postVariant:V,composerRows:H,readOnly:U=!1,markdown:W=!1,linkComponent:G,label:K=l.label,internalLabel:ee=l.internalLabel,attachmentsLabel:te=l.attachmentsLabel,composerLabel:ne=l.composerLabel,noCommentsText:re=l.noCommentsText,reactionsLabel:ie=l.reactionsLabel,repliesToLabel:ae=l.repliesToLabel,editedLabel:oe=l.editedLabel,deletedText:se=l.deletedText,replyLabel:ce=l.replyLabel,editLabel:le=l.editLabel,deleteLabel:ue=l.deleteLabel,deleteConfirmText:de=l.deleteConfirmText,cancelLabel:fe=l.cancelLabel,addReactionLabel:pe=l.addReactionLabel,chooseReactionLabel:me=l.chooseReactionLabel,peopleLabel:he=l.peopleLabel,id:ge,className:_e=``,...q}=s;f(`AppCommentThread`,q),d(`AppCommentThread`,`variant`,L,A),d(`AppCommentThread`,`composer`,R,k),V!==void 0&&d(`AppCommentThread`,`postVariant`,V,i);let J=n(`wui-comment-thread`,j);n(`wui-mention-input`,M);let ve=C(),Y=ge||`comment-thread-${ve.replace(/[^a-zA-Z0-9_-]/g,``)}`,X=w(null),Z=typeof b==`function`,ye=x?.length?x:p,Q=R===`inline`,be=H??(Q?1:3),xe={reactionsLabel:ie,repliesToLabel:ae,editedLabel:oe,deletedText:se,replyLabel:ce,editLabel:le,deleteLabel:ue,deleteConfirmText:de,cancelLabel:fe,addReactionLabel:pe},$=w({onPost:m,onReply:h,onEdit:g,onDelete:_,onReact:v,loadPeople:b});return $.current={onPost:m,onReply:h,onEdit:g,onDelete:_,onReact:v,loadPeople:b},S(()=>{let e=X.current;if(e&&J)return e.submit=async e=>{let t=$.current;e.intent===`post`?await t.onPost?.(e.body):e.intent===`reply`?await t.onReply?.(e.parentId,e.body):e.intent===`edit`?await t.onEdit?.(e.commentId,e.body):e.intent===`delete`?await t.onDelete?.(e.commentId):e.intent===`react`&&await t.onReact?.(e.commentId,e.emoji)},()=>{e.submit=void 0}},[J]),S(()=>{let e=X.current;e&&J&&!Z&&(e.people=y||[])},[y,Z,J]),S(()=>{let e=X.current;if(!e||!Z)return;let t=/* @__PURE__ */ new WeakMap,n=async e=>{let n=e.target;if(!(e instanceof CustomEvent)||!(n instanceof HTMLElement)||!P(n))throw TypeError(`<wui-comment-thread> search came from something other than a mention box.`);let r=e.detail;if(typeof r!=`object`||!r||!(`query`in r)||typeof r.query!=`string`)throw TypeError(`<wui-comment-thread> search carried no query.`);let i=r.query,{loadPeople:a}=$.current;if(typeof a!=`function`)throw Error(`<AppCommentThread> is remote but has no loadPeople.`);let o=(t.get(n)??0)+1;t.set(n,o),n.loading=!0;try{let e=await a(i);t.get(n)===o&&(n.people=e||[])}catch(e){t.get(n)===o&&(n.people=[],n.searchFailed=!0,reportError(e))}finally{t.get(n)===o&&(n.loading=!1)}};return e.addEventListener(`search`,n),()=>e.removeEventListener(`search`,n)},[Z]),/* @__PURE__ */ E(`wui-comment-thread`,{ref:X,id:Y,class:[`wui-comment-thread`,L===`conversation`&&`wui-comment-thread--conversation`,_e].filter(Boolean).join(` `),controlled:``,"read-only":U?``:void 0,remote:Z?``:void 0,"reaction-choices":x?.length?x.join(` `):void 0,"no-replies":O?void 0:``,"no-reactions":N?void 0:``,"composer-placeholder":F,...t,...q,children:[/* @__PURE__ */ T(`div`,{className:`wui-comment-items`,"data-wui-items":``,children:u.length?/* @__PURE__ */ T(`ol`,{className:`wui-comment-list`,"aria-label":K,children:u.map(e=>/* @__PURE__ */ T(I,{comment:e,topLevel:!0,readOnly:U,allowReplies:O,allowReactions:N,markdown:W,linkComponent:G,internalLabel:ee,attachmentsLabel:te,text:xe},e.id))}):/* @__PURE__ */ T(`p`,{className:`wui-comment-empty`,children:re})}),!U&&N&&/* @__PURE__ */ T(`div`,{className:`wui-reaction-picker`,role:`group`,"aria-label":me,"data-wui-picker":``,popover:`auto`,children:ye.map(e=>/* @__PURE__ */ T(`button`,{type:`button`,className:`wui-reaction-choice`,"data-wui-emoji":e,children:e},e))}),!U&&/* @__PURE__ */ E(`div`,{className:Q?`wui-comment-composer wui-comment-composer-inline`:`wui-comment-composer`,"data-wui-composer":``,children:[Q&&z?/* @__PURE__ */ T(o,{name:z,size:`sm`,tone:`auto`,className:`wui-comment-composer-avatar`}):null,/* @__PURE__ */ T(`wui-mention-input`,{id:`${Y}-new`,class:`wui-mention-input`,label:ne,"people-label":he,placeholder:F??l.composerPlaceholder,rows:String(be),remote:Z?``:void 0}),/* @__PURE__ */ T(`div`,{className:`wui-comment-form-actions`,children:/* @__PURE__ */ T(c,{variant:V??(Q?`outline`:`soft`),size:`sm`,"data-wui-action":`post`,children:B})}),/* @__PURE__ */ T(`div`,{className:`wui-comment-error`,"data-wui-error":``,hidden:!0})]}),/* @__PURE__ */ T(`span`,{className:`visually-hidden`,"data-wui-live":``,"aria-live":`polite`,"aria-atomic":`true`})]})}function I({comment:n,topLevel:r=!1,readOnly:i,allowReplies:a,allowReactions:o,markdown:d,linkComponent:f,internalLabel:p,attachmentsLabel:y,text:S}){let{id:C,author:w,at:D,value:k,edited:A,mine:j,internal:M,attachments:P=[],deleted:F,canEdit:L,canDelete:R,reactions:z=[],replies:B=[]}=n,V=w?.name||``,H=b(D),U=!i&&!F&&L,W=!i&&!F&&R,G=r&&a,K=[`wui-comment`,M&&`wui-comment--internal`,j&&`wui-comment--mine`].filter(Boolean).join(` `);return/* @__PURE__ */ E(`li`,{className:K,"data-wui-comment":C,"data-value":k??``,"data-wui-deleted":F?``:void 0,children:[/* @__PURE__ */ E(`div`,{className:`wui-comment-row`,children:[/* @__PURE__ */ E(`span`,{className:`avatar avatar-sm wui-comment-avatar`,"aria-hidden":`true`,children:[/* @__PURE__ */ T(`span`,{className:`avatar-face`,children:_(V)||`?`}),w?.src&&/* @__PURE__ */ T(`img`,{className:`avatar-img`,src:w.src,alt:``,onError:e=>{e.currentTarget.hidden=!0}})]}),/* @__PURE__ */ E(`div`,{className:`wui-comment-main`,children:[/* @__PURE__ */ E(`div`,{className:`wui-comment-head`,children:[/* @__PURE__ */ T(`span`,{className:`wui-comment-author`,children:V}),/* @__PURE__ */ T(`time`,{className:`wui-comment-time`,dateTime:Number.isFinite(H)?new Date(H).toISOString():void 0,children:m(D)}),A&&!F&&/* @__PURE__ */ T(`span`,{className:`wui-comment-edited`,children:S.editedLabel}),M&&/* @__PURE__ */ T(s,{className:`wui-comment-internal-badge`,children:p})]}),F?/* @__PURE__ */ T(`div`,{className:`wui-comment-text wui-comment-text-deleted`,children:S.deletedText}):/* @__PURE__ */ T(`div`,{className:d?`wui-comment-text wui-comment-text--markdown`:`wui-comment-text`,"data-wui-text":``,children:d?/* @__PURE__ */ T(u,{value:v(k??``).text,headings:`text`}):N(k).map(({key:e,seg:t})=>`text`in t?/* @__PURE__ */ T(x,{children:t.text},e):/* @__PURE__ */ E(`span`,{className:`wui-mention`,"data-mention-id":t.id,children:[`@`,t.label]},e))}),!F&&P.length>0&&/* @__PURE__ */ T(`ul`,{className:`wui-comment-attachments`,"aria-label":y,children:P.map(n=>{let r=e(f,{to:n.to,href:n.href,routeHref:!1});return/* @__PURE__ */ E(`li`,{children:[/* @__PURE__ */ E(t,{link:r,className:`wui-comment-attachment`,...n.to?{}:{download:!0},children:[/* @__PURE__ */ T(l,{name:`paperclip`,size:14}),n.name]}),typeof n.sizeBytes==`number`&&/* @__PURE__ */ T(`span`,{className:`wui-comment-attachment-size`,children:h(n.sizeBytes)})]},n.to??n.href)})}),U&&/* @__PURE__ */ T(`div`,{className:`wui-comment-editor`,"data-wui-editor":``,hidden:!0}),o&&!F&&(z.length>0||!i)&&/* @__PURE__ */ E(`div`,{className:`wui-comment-reactions`,role:`group`,"aria-label":S.reactionsLabel,children:[z.map(e=>i?/* @__PURE__ */ E(`span`,{className:e.mine?`wui-reaction wui-reaction-mine`:`wui-reaction`,children:[/* @__PURE__ */ T(`span`,{className:`wui-reaction-emoji`,children:e.emoji}),/* @__PURE__ */ T(`span`,{className:`wui-reaction-count`,children:g(e.count,{decimals:0})})]},e.emoji):/* @__PURE__ */ E(`button`,{type:`button`,className:e.mine?`wui-reaction wui-reaction-mine`:`wui-reaction`,"data-wui-emoji":e.emoji,"aria-pressed":e.mine?`true`:`false`,children:[/* @__PURE__ */ T(`span`,{className:`wui-reaction-emoji`,children:e.emoji}),/* @__PURE__ */ T(`span`,{className:`wui-reaction-count`,children:g(e.count,{decimals:0})})]},e.emoji)),!i&&/* @__PURE__ */ T(`button`,{type:`button`,className:`wui-reaction-add`,"data-wui-action":`react-menu`,"aria-label":S.addReactionLabel,"aria-haspopup":`true`,"aria-expanded":`false`,children:/* @__PURE__ */ T(l,{name:`emoji-smile`,size:16})})]}),!i&&!F&&(G||U||W)&&/* @__PURE__ */ E(`div`,{className:`wui-comment-actions`,"data-wui-actions":``,children:[G&&/* @__PURE__ */ T(`button`,{type:`button`,className:`wui-comment-action`,"data-wui-action":`reply`,children:S.replyLabel}),U&&/* @__PURE__ */ T(`button`,{type:`button`,className:`wui-comment-action`,"data-wui-action":`edit`,children:S.editLabel}),W&&/* @__PURE__ */ T(`button`,{type:`button`,className:`wui-comment-action`,"data-wui-action":`delete`,children:S.deleteLabel})]}),W&&/* @__PURE__ */ E(`div`,{className:`wui-comment-confirm`,"data-wui-comment-confirm":``,hidden:!0,children:[/* @__PURE__ */ T(`span`,{className:`wui-comment-confirm-text`,children:S.deleteConfirmText}),/* @__PURE__ */ T(c,{tone:`danger`,size:`sm`,"data-wui-action":`confirm-delete`,children:S.deleteLabel}),/* @__PURE__ */ T(c,{variant:`ghost`,size:`sm`,"data-wui-action":`cancel-delete`,children:S.cancelLabel})]}),!i&&/* @__PURE__ */ T(`div`,{className:`wui-comment-error`,"data-wui-error":``,hidden:!0})]})]}),r&&B.length>0&&/* @__PURE__ */ T(`ol`,{className:`wui-comment-list wui-comment-replies`,"aria-label":O(S.repliesToLabel,{name:V}),children:B.map(e=>/* @__PURE__ */ T(I,{comment:e,readOnly:i,allowReactions:o,markdown:d,linkComponent:f,internalLabel:p,attachmentsLabel:y,text:S},e.id))}),G&&!i&&!F&&/* @__PURE__ */ T(`div`,{className:`wui-comment-reply`,"data-wui-reply":``,hidden:!0})]})}export{F as default};
@@ -1 +1 @@
1
- import{devWarn as e}from"../lib/devWarn.js";import{emptyPlaceholder as t}from"../lib/emptyValue.js";import n from"../lib/useElementEntry.js";import r from"../lib/useWuiText.js";import{splitMarkerProps as i}from"../lib/wuiMarker.js";import a from"./AppButton.js";import o from"./AppEmptyState.js";import s from"./AppIcon.js";import ee from"./AppInfoTip.js";import te from"./AppRowActions.js";import c from"./AppSkeleton.js";import l from"./AppTablePagination.js";import u from"./assertValidValue.js";import d from"./warnUnknownProps.js";import{COLUMN_MAX_WIDTH as f,COLUMN_MIN_WIDTH as ne,PIN_AT_VAR as re,PIN_SIDES as ie,ROW_HEIGHTS as ae,ROW_MOVE_LIMIT as oe,ROW_SAVE_ERROR_CLASS as se,attachRowDrag as ce,attachScrollEdges as le,downloadTable as ue,groupCount as de,groupItems as fe,isImeSafeEnter as pe,measureRows as me,pinAtValue as he,pinClasses as ge,planPins as _e,playRowMoves as ve,rowOrderChanged as ye,saveOutcomeText as be,settledRows as xe,syncTargets as Se,tableCsv as Ce,tableXlsx as we,virtualRange as Te}from"@webority/ui-elements/helpers";import{Children as Ee,Fragment as De,isValidElement as Oe,useCallback as ke,useEffect as p,useLayoutEffect as Ae,useMemo as je,useRef as m,useState as h}from"react";import{Fragment as Me,jsx as g,jsxs as _}from"react/jsx-runtime";import{DATA_TABLE_TEXT as Ne,ROW_ACTIONS_TEXT as Pe,fillText as Fe,pluralText as Ie}from"@webority/ui-elements/text";import{FORCED_STATE_CLASSES as Le}from"@webority/theme/runtime";var Re=()=>import(`@webority/ui-elements/elements/data-table`),ze=[`comfortable`,`cozy`,`compact`],Be=[`hover`,`hover-menu`,`column`],Ve=`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,He=[`auto`,`fixed`],Ue=[1,2,3,4],We=e=>typeof e==`number`?`${e}px`:e;function Ge(e){let t=e.flatMap(e=>{let t=e.minWidth??e.width;return t===void 0?[]:[We(t)]});if(t.length!==0)return t.length===1?t[0]:`calc(${t.join(` + `)})`}function v(e,t){return typeof e==`object`&&e?Reflect.get(e,t):void 0}function Ke(e,t){if(e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`||Oe(e)||Array.isArray(e))return e;throw Error(`AppDataTable: the value under "${t}" is not renderable; give that column a render function.`)}function qe(e,t){return Ke(v(e,t),t)}var Je=()=>{try{return process.env.NODE_ENV!==`production`}catch{return!0}},y=/* @__PURE__ */ new Set;function b(t,n){!y.has(t)&&Je()&&(y.add(t),e(`[@webority/ui-react] <AppDataTable> ${n}`))}var Ye=100,Xe=e=>{let t=typeof e==`object`&&e&&`id`in e?e.id:void 0;return typeof t==`string`||typeof t==`number`?t:void 0},Ze=()=>{},Qe=()=>({total:0,keys:[]}),$e=[],et=(e,t,n)=>{let r=!!t?.(e),i=r?``:n?.(e)||``;return{state:r?`saving`:i?`error`:null,message:i}};function x(e){return e===`end`?`wui-cell-end`:e===`num`?`num`:e===`center`?`text-center`:``}function tt(e){return e===`center`?`44%`:e===`end`||e===`num`?`56%`:`60%`}function nt(e){return e==null||e===``?t():Array.isArray(e)?Ee.toArray(e):typeof e==`boolean`?String(e):e}function rt(e){if(!e||!(e.total>0))return!1;let t=e.pageSizes?.length?e.pageSizes:[e.pageSize];return e.total>Math.min(...t)}function S(e){n(`wui-data-table`,Re);let t=r(`dataTable`,Ne),Ee=r(`rowActions`,Pe),Oe=e=>e?Fe(t.resizeColumnText,{label:e}):t.resizeColumnLabel,{marker:We,props:Je}=i(`AppDataTable`,e),{columns:y,rows:S=$e,rowKey:it=Xe,sort:at,onSort:ot,loading:C=!1,refreshing:st=!1,skeletonRows:ct=5,empty:lt=t.empty,emptyFiltered:ut,error:dt,onRetry:ft,sourceCount:pt,rowActions:w,linkComponent:mt,rowActionsLabel:ht,pagination:T,ariaLabel:gt,className:_t=``,wrapperClassName:vt=``,selectable:E=!1,selectedIds:D,isRowSelectable:yt,onToggleRow:bt,onToggleAll:xt,onSelectRange:St,renderExpanded:Ct,singleExpand:wt=!1,density:Tt=`cozy`,densitySwitch:Et=!1,exportable:Dt=!1,exportName:Ot=`table`,onExport:kt,tableLayout:At=`auto`,striped:jt=!1,flush:Mt=!1,pad:Nt,nameLines:O,headerTone:Pt,rowDrag:k=!1,maxHeight:Ft,stickyFirstColumn:It=!1,stickyActions:Lt=!1,equalActions:Rt=!1,linkFirstColumn:zt=!1,stackOnMobile:A=!1,hiddenColumns:Bt,rowStatus:Vt,rowTone:Ht,rowActionsMode:Ut=`hover`,rowHref:j,onRowClick:Wt,activeRowKey:Gt,hoverRowKey:Kt,resizableColumns:qt=!1,viewKey:Jt,groupBy:M,groupLabel:Yt,virtual:N=!1,rowSaving:Xt,rowSaveError:P,...Zt}=Je;d(`AppDataTable`,Zt);let{style:Qt,...$t}=Zt,F=ke((e,t)=>{let n=it(e,t);if(n==null)throw Error(`AppDataTable: a row has no key. Pass rowKey, or give every row an id.`);return n},[it]),en=Bt?.length?new Set(Bt):null;y=en?y.filter(e=>!(e.hideable&&en.has(e.key))):y,u(`AppDataTable`,`density`,Tt,ze),u(`AppDataTable`,`rowActionsMode`,Ut,Be),u(`AppDataTable`,`tableLayout`,At,He),u(`AppDataTable`,`nameLines`,O,Ue);for(let e of y)u(`AppDataTable`,`column.pin`,e.pin,ie);let I=typeof j==`function`||typeof Wt==`function`,[tn,nn]=h(null),L=Et&&tn?tn:Tt,rn=[`table table-ledger`,L===`cozy`||L===`compact`?`wui-table-${L}`:``,Ut===`hover-menu`?`wui-table-actions-menu`:``,Ut===`column`?`wui-table-actions-column`:``,jt?`wui-table-striped`:``,It?`wui-table-sticky-first`:``,Lt?`wui-table-sticky-actions`:``,Rt?`wui-table-equal-actions`:``,A?`wui-table-stack`:``,zt&&I?`wui-table-link-first`:``,_t].filter(Boolean).join(` `),R=typeof Ct==`function`,[an,on]=h(()=>/* @__PURE__ */ new Set),sn=e=>on(t=>{if(t.has(e)){let n=new Set(t);return n.delete(e),n}return wt?/* @__PURE__ */ new Set([e]):new Set(t).add(e)}),cn=y.some(e=>typeof e.footer==`function`),ln=e=>!!(e.target instanceof Element&&e.target.closest(`a, button, input, select, textarea, label, [role='menu'], [role='menuitem'], .dropdown`)),un=(e,t)=>{if(ln(t)||(Wt&&Wt(e),!j))return;let n=j(e);n&&(t.ctrlKey||t.metaKey||t.button===1?window.open(n,`_blank`,`noopener`):window.location.assign(n))},z=Ft!==void 0,dn=st&&!C&&S.length>0,fn=[`table-wrap`,z?`wui-table-scroll`:``,Mt?`wui-table-flush`:``,dn?`wui-table-refreshing`:``,vt].filter(Boolean).join(` `),pn={maxHeight:z?Ft:void 0,"--wui-table-pad":Nt!=null&&!Mt?`${Nt}px`:void 0,"--wui-name-lines":N?`1`:O?.toString(),"--wui-table-header-bg":Pt??void 0},mn=Object.values(pn).some(e=>e!==void 0)||Qt!==void 0?{...pn,...Qt}:void 0,hn=Math.max(1,y.length+ +!!w+ +!!E+ +!!R),gn=y.some(e=>e.pin===`start`||e.pin===`end`),_n=gn||qt||!!M||N,B=+!!R+ +!!E,vn=gn?_e([...R?[`lead`]:[],...E?[`lead`]:[],...y.map(e=>e.pin===`start`||e.pin===`end`?e.pin:null),...w?[null]:[]]):[],V=(e,t=``)=>{let n=vn[e];return n?{className:`${t.trim()} ${ge(n)}`.trim(),style:{[re]:he(n.side,n.ordinal)}}:{className:t,style:void 0}},H=(e,t)=>vn[e]?{...t,...V(e).style}:t,yn=y.length-1+ +!!w;Jt&&!qt&&b(`view-key`,"`viewKey` remembers resized widths: add `resizableColumns`."),N&&!z&&b(`virtual-height`,"`virtual` needs `maxHeight`: without a scroll box every row renders."),N&&(R||A)&&b(`virtual-shape`,"`virtual` takes rows of one height, so it is off with `renderExpanded` or `stackOnMobile`."),N&&O!==void 0&&O!==1&&b(`virtual-name-lines`,"`nameLines` is ignored with `virtual`: a virtual table shows one line per name."),zt&&!I&&b(`link-first-column`,"`linkFirstColumn` needs rowHref or onRowClick: the row is what opens."),wt&&typeof Ct!=`function`&&b(`single-expand`,"`singleExpand` needs renderExpanded: there are no rows to expand."),!N&&S?.length>500&&b(`rows-without-virtual`,`renders more than 500 rows without virtual: add virtual with maxHeight, or page the data.`);let U=N&&z&&!R&&!A&&!C&&S?.length>0,W=(e,t)=>!yt||!!yt(e,t),bn=E&&S?S.reduce((e,t,n)=>e+ +!!W(t,n),0):0,G=E&&S?S.reduce((e,t,n)=>e+(W(t,n)&&D?.has(F(t,n))?1:0),0):0,xn=bn>0&&G===bn,Sn=G>0&&!xn,Cn=e=>{e&&(e.indeterminate=Sn)},wn=m(null),Tn=(e,t)=>{let n=wn.current;wn.current=e;let r=t&&n!==null?S.findIndex((e,t)=>F(e,t)===n):-1,i=S.findIndex((t,n)=>F(t,n)===e);if(r<0||i<0||r===i){bt?.(e);return}let a=!D?.has(e),o=Math.min(r,i),s=S.slice(o,Math.max(r,i)+1).map((e,t)=>[e,o+t]).filter(([e,t])=>W(e,t)).map(([e,t])=>F(e,t)).filter(e=>(D?.has(e)||!1)!==a);if(St)St(s,a);else for(let e of s)bt?.(e)},En=e=>{yt?(S||[]).forEach((t,n)=>{let r=F(t,n);W(t,n)&&(D?.has(r)||!1)!==e&&bt?.(r)}):xt?.(e)},[Dn,On]=h(()=>/* @__PURE__ */ new Set),kn=e=>On(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),K=je(()=>{let e=(S||[]).map((e,t)=>({row:e,i:t}));return M?fe(e,({row:e})=>String(v(e,M)??``)).flatMap(e=>[{group:e,open:!Dn.has(e.key)},...Dn.has(e.key)?[]:e.items]):e},[S,M,Dn]),An=m(null),[q,jn]=h(null),Mn=ke(e=>{An.current=e,jn(e)},[]),Nn=m(null);p(()=>{let e=q;if(!e)return;let t=e=>{let t=e.target instanceof Element?e.target.closest(`.u-name`):null;t&&!t.title&&(t.scrollWidth>t.clientWidth||t.scrollHeight>t.clientHeight)&&(t.title=(t.textContent??``).trim())},n=e=>{let t=e.target instanceof Element?e.target.closest(`tbody > tr[aria-rowindex]`)?.getAttribute(`aria-rowindex`):null;Nn.current=t?Number(t)-2:null},r=t=>{t.relatedTarget instanceof Node&&e.contains(t.relatedTarget)||(Nn.current=null)};e.addEventListener(`mouseover`,t),e.addEventListener(`focusin`,t),e.addEventListener(`focusin`,n),e.addEventListener(`focusout`,r);let i=le(e);return()=>{e.removeEventListener(`mouseover`,t),e.removeEventListener(`focusin`,t),e.removeEventListener(`focusin`,n),e.removeEventListener(`focusout`,r),i()}},[q]),p(()=>{if(!k||!q)return;let e=ce(q);return Se(document),e},[k,q]);let Pn=m(Qe);Ae(()=>{Pn.current=()=>({total:S?.length??0,keys:S?S.flatMap((e,t)=>{let n=F(e,t);return W(e,t)&&D?.has(n)?[String(n)]:[]}):[]})});let Fn=m(!1);p(()=>{if(!Fn.current&&(Fn.current=!0,G===0))return;let{total:e,keys:t}=Pn.current();An.current?.querySelector(`table`)?.dispatchEvent(new CustomEvent(`selectionchange`,{bubbles:!0,detail:{selected:G,total:e,keys:t}}))},[G]);let[In,Ln]=h({top:0,height:0}),[Rn,zn]=h(ae[L]??ae.cozy);p(()=>{let e=q;if(!U||!e)return;let t=0,n=()=>{t=0;let n=e.querySelector(`:scope > table > thead`)?.getBoundingClientRect().height||0,r={top:Math.max(0,e.scrollTop-n),height:e.clientHeight};Ln(e=>e.top===r.top&&e.height===r.height?e:r)},r=()=>{t||=requestAnimationFrame(n)};e.addEventListener(`scroll`,r,{passive:!0});let i=typeof ResizeObserver<`u`?new ResizeObserver(r):null;return i?.observe(e),n(),()=>{e.removeEventListener(`scroll`,r),i?.disconnect(),t&&cancelAnimationFrame(t)}},[U,q]);let Bn=m(null);Ae(()=>{if(!U){Bn.current=null;return}let e=`${L}:${S?.length??0}`;if(Bn.current===e)return;Bn.current=e;let t=(An.current?.querySelector(`:scope > table > tbody > tr:not(.wui-virtual-spacer, .wui-group-row)`))?.getBoundingClientRect().height;t!==void 0&&t>0&&Math.abs(t-Rn)>.5&&zn(t)});let J={start:0,end:K.length,before:0,after:0};if(U){J=Te({scrollTop:In.top,viewport:In.height||Number.parseFloat(String(Ft))||0,rowHeight:Rn,count:K.length});let e=Nn.current;e!==null&&e>=0&&e<K.length&&(e<J.start&&J.start-e<=Ye&&(J={...J,start:e,before:e*Rn}),e>=J.end&&e-J.end<Ye&&(J={...J,end:e+1,after:(K.length-e-1)*Rn}))}let Vn=m(null),Hn=m(null),Un=m(null),Wn=!N&&!C&&S?.length>0&&S.length<=oe;Ae(()=>{let e=Vn.current;if(!Wn||!e){Hn.current=null,Un.current=null;return}let t=S.map((e,t)=>F(e,t));ye(Un.current,t)&&ve(e.rows,Hn.current),Hn.current=me(e.rows),Un.current=t});let Y=typeof Xt==`function`||typeof P==`function`,Gn=m(null),Kn=m(null),X=y[0]?.key;p(()=>{if(!Y){Kn.current=null;return}let e=/* @__PURE__ */ new Map;(S||[]).forEach((t,n)=>{let r=X===void 0?void 0:v(t,X),i=typeof r==`string`||typeof r==`number`?String(r):``;e.set(F(t,n),{...et(t,Xt,P),label:i})});let t=be(xe(Kn.current,e));Kn.current=e,t&&Gn.current&&(Gn.current.textContent=t)},[S,Xt,P,F,Y,X]);let qn=ut!==void 0&&(pt===void 0||pt>0)?ut:lt,Z=!C&&dt?dt:null,Jn=e=>{if(kt){kt(e);return}let t=y.map(e=>typeof e.label==`string`?e.label:e.key),n=S.map(e=>y.map(t=>{let n=t.exportValue?t.exportValue(e):v(e,t.key);return n==null?``:String(n)}));e===`csv`?ue([Ce(t,n)],`text/csv;charset=utf-8`,`${Ot}.csv`):ue([we(t,n)],Ve,`${Ot}.xlsx`)},Yn=({group:e,open:n},r)=>{let i=v(e.items[0]?.row,M??``),a=e.items.map(e=>e.row);return/* @__PURE__ */ g(`tr`,{className:`wui-group-row`,"data-group-key":e.key,"aria-rowindex":U?r+2:void 0,children:/* @__PURE__ */ g(`th`,{className:`wui-group-cell`,scope:`rowgroup`,colSpan:hn,children:/* @__PURE__ */ _(`button`,{type:`button`,className:`wui-group-toggle`,"aria-expanded":n,onClick:()=>kn(e.key),children:[/* @__PURE__ */ g(s,{name:`chevron-down`,size:16}),/* @__PURE__ */ g(`span`,{className:`wui-group-label`,children:Yt?Yt(i,a):nt(Ke(i,M??``))}),/* @__PURE__ */ g(`span`,{className:`wui-group-count`,"aria-hidden":`true`,children:de(e.items.length)}),/* @__PURE__ */ g(`span`,{className:`visually-hidden wui-group-rows`,children:`, ${Ie(t,`groupRows`,e.items.length,{count:de(e.items.length)})}`})]})})},`group:${e.key}`)},Xn=({row:e,i:n},r)=>{let i=F(e,n),a=R&&an.has(i),o=Gt!=null&&String(Gt)===String(i),ee=Kt!=null&&String(Kt)===String(i),c=String(i).replace(/[^a-z0-9]/gi,`_`),l=V(0,`wui-expand-cell`),u=V(+!!R,`wui-select-cell`),d=Y?et(e,Xt,P):null,f=W(e,n),ne=w?.(e);if(w&&!Array.isArray(ne))throw TypeError(`AppDataTable: rowActions returns a list of actions ({ key, label, icon, onClick or href }). It returned something else: restate the buttons as a list, see node scripts/codemods/row-actions.mjs --check.`);let re=X===void 0?void 0:v(e,X),ie=typeof re==`string`||typeof re==`number`?Fe(t.moreActionsForText,{firstValue:re}):Ee.menuLabel;return/* @__PURE__ */ _(De,{children:[/* @__PURE__ */ _(`tr`,{className:[E&&f&&D?.has(i)?`is-selected`:``,I?`wui-row-link`:``,o?`wui-row-active`:``,ee?Le.hover:``].filter(Boolean).join(` `)||void 0,"aria-current":o?`true`:void 0,"aria-rowindex":U?r+2:void 0,"aria-busy":d?.state===`saving`?`true`:void 0,"data-wui-save-state":d?.state||void 0,"data-status":Vt?.(e)||void 0,"data-tone":Ht?.(e)||void 0,"data-href":j?.(e)||void 0,"data-row-key":k?String(i):void 0,tabIndex:I?0:void 0,onClick:I?t=>un(e,t):void 0,onAuxClick:I&&j?t=>t.button===1&&un(e,t):void 0,onKeyDown:I?t=>{pe(t.nativeEvent)&&t.target===t.currentTarget&&un(e,t)}:void 0,children:[R&&/* @__PURE__ */ g(`td`,{className:l.className,style:l.style,children:/* @__PURE__ */ g(`button`,{type:`button`,className:`wui-expand-toggle${a?` is-open`:``}`,"aria-expanded":a,"aria-controls":a?`${c}-expanded`:void 0,"aria-label":a?t.collapseRowLabel:t.expandRowLabel,onClick:()=>sn(i),children:/* @__PURE__ */ g(s,{name:`chevron-down`,size:16})})}),E&&/* @__PURE__ */ g(`td`,{className:u.className,style:u.style,children:/* @__PURE__ */ g(`input`,{type:`checkbox`,className:`wui-check`,checked:f&&(D?.has(i)||!1),disabled:!f,onChange:e=>Tn(i,e.nativeEvent instanceof MouseEvent&&e.nativeEvent.shiftKey),onMouseDown:e=>{e.shiftKey&&e.preventDefault()},"aria-label":t.selectRowLabel})}),y.map((t,n)=>{let r=t.rowHeader?`th`:`td`;return/* @__PURE__ */ _(r,{scope:t.rowHeader?`row`:void 0,className:V(B+n,(n===0?`wui-name-cell `:``)+(t.rowHeader?`wui-row-header `:``)+(t.nowrap?`text-nowrap `:``)+x(t.align)+(t.cellClassName?` ${t.cellClassName}`:``)).className,style:H(B+n,t.cellStyle),"data-label":A&&typeof t.label==`string`?t.label:void 0,children:[t.render?t.render(e):nt(qe(e,t.key)),n===0&&d?.state===`error`&&/* @__PURE__ */ g(`span`,{className:se,children:d.message})]},t.key)}),w&&/* @__PURE__ */ g(`td`,{children:/* @__PURE__ */ g(te,{items:ne??[],menuLabel:ie,linkComponent:mt})})]}),a&&/* @__PURE__ */ g(`tr`,{className:`wui-row-expanded`,children:/* @__PURE__ */ g(`td`,{id:`${c}-expanded`,colSpan:hn,children:Ct?.(e)})})]},i)},Zn=(e,t)=>`group`in e?Yn(e,t):Xn(e,t),Qn=(e,t)=>U?/* @__PURE__ */ g(`tr`,{className:`wui-virtual-spacer`,"aria-hidden":`true`,hidden:t===0,children:/* @__PURE__ */ g(`td`,{colSpan:hn,style:{height:t}})},e):null,Q=V(0,`wui-expand-cell`),$=V(+!!R,`wui-select-cell`),$n=()=>Array.from({length:ct},(e,t)=>`skeleton-${t}`).map(e=>/* @__PURE__ */ _(`tr`,{children:[R&&/* @__PURE__ */ g(`td`,{className:Q.className,style:Q.style}),E&&/* @__PURE__ */ g(`td`,{className:$.className,style:$.style}),y.map((e,t)=>/* @__PURE__ */ g(`td`,{className:V(B+t,(t===0?`wui-name-cell `:``)+(e.nowrap?`text-nowrap `:``)+x(e.align)).className,style:H(B+t,void 0),"data-label":A&&typeof e.label==`string`?e.label:void 0,children:/* @__PURE__ */ g(c,{width:tt(e.align),height:12,radius:6})},e.key)),w&&/* @__PURE__ */ g(`td`,{children:/* @__PURE__ */ g(`div`,{className:`u-row-actions`,children:/* @__PURE__ */ g(c,{width:`32px`,height:12,radius:6})})})]},e));return/* @__PURE__ */ _(Me,{children:[/* @__PURE__ */ _(_n?`wui-data-table`:`div`,{ref:Mn,..._n?{class:fn,resizable:qt?``:void 0,"view-key":Jt||void 0,"data-wui-row-drag":k?``:void 0,"aria-busy":dn||void 0}:{className:fn,"data-wui-row-drag":k?``:void 0,"aria-busy":dn||void 0},style:mn,tabIndex:0,...We,...$t,children:[Dt&&/* @__PURE__ */ _(`div`,{className:`wui-table-export`,children:[/* @__PURE__ */ g(a,{variant:`soft`,size:`sm`,onClick:()=>Jn(`csv`),children:t.exportCsvLabel}),/* @__PURE__ */ g(a,{variant:`soft`,size:`sm`,onClick:()=>Jn(`xlsx`),children:t.exportExcelLabel})]}),Et&&/* @__PURE__ */ _(`div`,{className:`wui-table-density`,role:`group`,"aria-label":t.densityLabel,children:[/* @__PURE__ */ g(a,{variant:`soft`,size:`sm`,"aria-pressed":L===`comfortable`,"aria-label":t.densityComfortableLabel,onClick:()=>nn(`comfortable`),children:/* @__PURE__ */ g(s,{name:`list`,size:16})}),/* @__PURE__ */ g(a,{variant:`soft`,size:`sm`,"aria-pressed":L===`compact`,"aria-label":t.densityCompactLabel,onClick:()=>nn(`compact`),children:/* @__PURE__ */ g(s,{name:`grid`,size:16})})]}),/* @__PURE__ */ _(`table`,{className:rn,"aria-label":gt,"aria-rowcount":U?K.length+1:void 0,style:At===`fixed`?{tableLayout:`fixed`,minWidth:Ge(y)}:void 0,children:[/* @__PURE__ */ g(`thead`,{children:/* @__PURE__ */ _(`tr`,{"aria-rowindex":U?1:void 0,children:[R&&/* @__PURE__ */ g(`th`,{className:Q.className,style:Q.style,children:/* @__PURE__ */ g(`span`,{className:`visually-hidden`,children:t.expandLabel})}),E&&/* @__PURE__ */ g(`th`,{className:$.className,style:$.style,children:/* @__PURE__ */ g(`input`,{ref:Cn,type:`checkbox`,className:`wui-check`,checked:xn,disabled:C,onChange:e=>En(e.target.checked),"aria-label":t.selectAllRowsLabel})}),y.map((e,t)=>{let n=e.sortable?ot:void 0,r=n!==void 0,i=at&&at.key===e.key,a=e.align===`num`||e.align===`end`,o=r&&/* @__PURE__ */ g(`span`,{className:`sort-icon${a?` wui-sort-lead`:``}`,children:/* @__PURE__ */ g(s,{name:`chevrons-up-down`,size:14})}),te=qt&&t!==yn,c=At===`fixed`&&!e.grow?e.minWidth:void 0,l=e.width||e.minWidth?{width:e.width??c,minWidth:e.minWidth}:void 0;return/* @__PURE__ */ _(`th`,{className:V(B+t,(r?`sortable `:``)+(t===0?`wui-name-cell `:``)+(e.nowrap?`text-nowrap `:``)+(e.grow?`wui-col-grow `:``)+(te?`wui-col-resizable `:``)+x(e.align)).className,style:H(B+t,l),"data-key":_n?e.key:void 0,"aria-label":te&&typeof e.label==`string`?e.label:void 0,"data-pin":e.pin===`start`||e.pin===`end`?e.pin:void 0,tabIndex:r?0:void 0,"aria-sort":i?at?.dir===`asc`?`ascending`:`descending`:r?`none`:void 0,onClick:n?t=>{t.target instanceof Element&&t.target.closest(`.infotip`)||C||n(e.key)}:void 0,onKeyDown:n?t=>{t.target===t.currentTarget&&(pe(t.nativeEvent)||t.key===` `)&&(t.preventDefault(),C||n(e.key))}:void 0,children:[a&&o,e.label,!a&&o,e.help?/* @__PURE__ */ g(ee,{label:typeof e.label==`string`?e.label:void 0,children:e.help}):null,te&&/* @__PURE__ */ g(`span`,{className:`wui-col-resize`,role:`separator`,"aria-orientation":`vertical`,"aria-valuemin":ne,"aria-valuemax":f,tabIndex:0,"aria-label":Oe(typeof e.label==`string`?e.label:e.key)})]},e.key)}),w&&(ht?/* @__PURE__ */ g(`th`,{className:`wui-cell-end`,children:ht}):/* @__PURE__ */ g(`th`,{className:`wui-cell-end`,children:/* @__PURE__ */ g(`span`,{className:`visually-hidden`,children:t.rowActionsLabel})}))]})}),/* @__PURE__ */ g(`tbody`,{ref:Vn,children:C?$n():Z?null:S?.length?/* @__PURE__ */ _(Me,{children:[Qn(`before`,J.before),K.slice(J.start,J.end).map((e,t)=>Zn(e,J.start+t)),Qn(`after`,J.after)]}):null}),cn&&!C&&!Z&&S?.length>0&&/* @__PURE__ */ g(`tfoot`,{children:/* @__PURE__ */ _(`tr`,{children:[R&&/* @__PURE__ */ g(`td`,{className:Q.className,style:Q.style}),E&&/* @__PURE__ */ g(`td`,{className:$.className,style:$.style}),y.map((e,t)=>/* @__PURE__ */ g(`td`,{className:V(B+t,(t===0?`wui-name-cell `:``)+(e.nowrap?`text-nowrap `:``)+x(e.align)).className,style:H(B+t,void 0),children:e.footer?e.footer(S):null},e.key)),w&&/* @__PURE__ */ g(`td`,{})]})})]}),!C&&(Z||!S?.length)&&/* @__PURE__ */ g(`div`,{className:`tbl-empty-block`,role:Z?`alert`:void 0,children:Z?/* @__PURE__ */ g(o,{variant:`table`,icon:`alert-circle`,description:Z.message,action:ft?/* @__PURE__ */ g(a,{variant:`soft`,size:`sm`,onClick:()=>ft(),children:t.retryLabel}):void 0,className:`wui-table-error`}):typeof qn==`string`?/* @__PURE__ */ g(`div`,{className:`tbl-empty-plain`,children:qn}):qn})]}),rt(T)&&/* @__PURE__ */ g(l,{page:T.page,totalPages:T.totalPages,total:T.total,pageSize:T.pageSize,onPageChange:C?Ze:T.setPage,onPageSizeChange:C?Ze:T.setPageSize,pageSizes:T.pageSizes,mode:T.mode,summary:T.summary}),Y&&/* @__PURE__ */ g(`div`,{ref:Gn,className:`visually-hidden`,role:`status`,"aria-live":`polite`,"data-wui-table-status":``})]})}export{S as default};
1
+ import{devWarn as e}from"../lib/devWarn.js";import{emptyPlaceholder as t}from"../lib/emptyValue.js";import n from"../lib/useElementEntry.js";import r from"../lib/useWuiText.js";import{splitMarkerProps as i}from"../lib/wuiMarker.js";import a from"./AppButton.js";import o from"./AppEmptyState.js";import s from"./AppIcon.js";import ee from"./AppInfoTip.js";import te from"./AppRowActions.js";import c from"./AppSkeleton.js";import l from"./AppTablePagination.js";import u from"./assertValidValue.js";import d from"./warnUnknownProps.js";import{COLUMN_MAX_WIDTH as f,COLUMN_MIN_WIDTH as ne,PIN_AT_VAR as p,PIN_SIDES as re,ROW_HEIGHTS as ie,ROW_MOVE_LIMIT as ae,ROW_SAVE_ERROR_CLASS as oe,attachRowDrag as se,attachScrollEdges as ce,downloadTable as le,groupCount as ue,groupItems as de,isImeSafeEnter as fe,measureRows as pe,pinAtValue as me,pinClasses as he,planPins as ge,playRowMoves as _e,rowOrderChanged as ve,saveOutcomeText as ye,settledRows as be,syncTargets as xe,tableCsv as Se,tableXlsx as Ce,virtualRange as we}from"@webority/ui-elements/helpers";import{Children as Te,Fragment as Ee,isValidElement as De,useCallback as Oe,useEffect as m,useLayoutEffect as ke,useMemo as Ae,useRef as h,useState as g}from"react";import{Fragment as je,jsx as _,jsxs as v}from"react/jsx-runtime";import{DATA_TABLE_TEXT as Me,ROW_ACTIONS_TEXT as Ne,fillText as Pe,pluralText as Fe}from"@webority/ui-elements/text";import{FORCED_STATE_CLASSES as Ie}from"@webority/theme/runtime";var Le=()=>import(`@webority/ui-elements/elements/data-table`),Re=[`comfortable`,`cozy`,`compact`],ze=[`hover`,`hover-menu`,`column`],Be=`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,Ve=[`auto`,`fixed`],He=[1,2,3,4],Ue=e=>typeof e==`number`?`${e}px`:e;function We(e){let t=e.flatMap(e=>{let t=e.minWidth??e.width;return t===void 0?[]:[Ue(t)]});if(t.length!==0)return t.length===1?t[0]:`calc(${t.join(` + `)})`}function y(e,t){return typeof e==`object`&&e?Reflect.get(e,t):void 0}function Ge(e,t){if(e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`||De(e)||Array.isArray(e))return e;throw Error(`AppDataTable: the value under "${t}" is not renderable; give that column a render function.`)}function Ke(e,t){return Ge(y(e,t),t)}var qe=()=>{try{return process.env.NODE_ENV!==`production`}catch{return!0}},b=/* @__PURE__ */ new Set;function x(t,n){!b.has(t)&&qe()&&(b.add(t),e(`[@webority/ui-react] <AppDataTable> ${n}`))}var Je=100,Ye=e=>{let t=typeof e==`object`&&e&&`id`in e?e.id:void 0;return typeof t==`string`||typeof t==`number`?t:void 0},Xe=()=>{},Ze=()=>({total:0,keys:[]}),Qe=[],$e=(e,t,n)=>{let r=!!t?.(e),i=r?``:n?.(e)||``;return{state:r?`saving`:i?`error`:null,message:i}};function S(e){return e===`end`?`wui-cell-end`:e===`num`?`num`:e===`center`?`text-center`:``}function et(e){return e===`center`?`44%`:e===`end`||e===`num`?`56%`:`60%`}function tt(e){return e==null||e===``?t():Array.isArray(e)?Te.toArray(e):typeof e==`boolean`?String(e):e}function nt(e){if(!e||!(e.total>0))return!1;let t=e.pageSizes?.length?e.pageSizes:[e.pageSize];return e.total>Math.min(...t)}function C(e){n(`wui-data-table`,Le);let t=r(`dataTable`,Me),Te=r(`rowActions`,Ne),De=e=>e?Pe(t.resizeColumnText,{label:e}):t.resizeColumnLabel,{marker:Ue,props:qe}=i(`AppDataTable`,e),{columns:b,rows:C=Qe,rowKey:rt=Ye,sort:it,onSort:at,loading:w=!1,refreshing:ot=!1,skeletonRows:st=5,empty:ct=t.empty,emptyFiltered:lt,error:ut,onRetry:dt,sourceCount:ft,rowActions:T,linkComponent:pt,rowActionsLabel:mt,pagination:E,ariaLabel:ht,className:gt=``,wrapperClassName:_t=``,selectable:D=!1,selectedIds:O,isRowSelectable:vt,onToggleRow:yt,onToggleAll:bt,onSelectRange:xt,renderExpanded:St,singleExpand:Ct=!1,density:wt=`cozy`,densitySwitch:Tt=!1,exportable:Et=!1,exportName:Dt=`table`,onExport:Ot,tableLayout:kt=`auto`,striped:At=!1,flush:jt=!1,pad:Mt,nameLines:Nt,headerTone:Pt,rowDrag:k=!1,maxHeight:Ft,stickyFirstColumn:It=!1,stickyActions:Lt=!1,equalActions:Rt=!1,linkFirstColumn:zt=!1,stackOnMobile:A=!1,hiddenColumns:Bt,rowStatus:Vt,rowTone:Ht,rowActionsMode:Ut=`hover`,rowHref:j,onRowClick:Wt,activeRowKey:Gt,hoverRowKey:Kt,resizableColumns:M=!1,viewKey:qt,groupBy:N,groupLabel:Jt,virtual:P=!1,rowSaving:F,rowSaveError:I,...Yt}=qe;d(`AppDataTable`,Yt);let{style:Xt,...Zt}=Yt,L=Oe((e,t)=>{let n=rt(e,t);if(n==null)throw Error(`AppDataTable: a row has no key. Pass rowKey, or give every row an id.`);return n},[rt]),Qt=Bt?.length?new Set(Bt):null;b=Qt?b.filter(e=>!(e.hideable&&Qt.has(e.key))):b,u(`AppDataTable`,`density`,wt,Re),u(`AppDataTable`,`rowActionsMode`,Ut,ze),u(`AppDataTable`,`tableLayout`,kt,Ve),u(`AppDataTable`,`nameLines`,Nt,He);for(let e of b)u(`AppDataTable`,`column.pin`,e.pin,re);let R=typeof j==`function`||typeof Wt==`function`,[$t,en]=g(null),z=Tt&&$t?$t:wt,tn=[`table table-ledger`,z===`cozy`||z===`compact`?`wui-table-${z}`:``,Ut===`hover-menu`?`wui-table-actions-menu`:``,Ut===`column`?`wui-table-actions-column`:``,At?`wui-table-striped`:``,It?`wui-table-sticky-first`:``,Lt?`wui-table-sticky-actions`:``,Rt?`wui-table-equal-actions`:``,A?`wui-table-stack`:``,zt&&R?`wui-table-link-first`:``,gt].filter(Boolean).join(` `),B=typeof St==`function`,[nn,rn]=g(()=>/* @__PURE__ */ new Set),an=e=>rn(t=>{if(t.has(e)){let n=new Set(t);return n.delete(e),n}return Ct?/* @__PURE__ */ new Set([e]):new Set(t).add(e)}),on=b.some(e=>typeof e.footer==`function`),sn=e=>!!(e.target instanceof Element&&e.target.closest(`a, button, input, select, textarea, label, [role='menu'], [role='menuitem'], .dropdown`)),cn=(e,t)=>{if(sn(t)||(Wt&&Wt(e),!j))return;let n=j(e);n&&(t.ctrlKey||t.metaKey||t.button===1?window.open(n,`_blank`,`noopener`):window.location.assign(n))},V=Ft!==void 0,ln=ot&&!w&&C.length>0,un=[`table-wrap`,V?`wui-table-scroll`:``,jt?`wui-table-flush`:``,ln?`wui-table-refreshing`:``,_t].filter(Boolean).join(` `),dn={maxHeight:V?Ft:void 0,"--wui-table-pad":Mt!=null&&!jt?`${Mt}px`:void 0,"--wui-name-lines":P?`1`:Nt?.toString(),"--wui-table-header-bg":Pt??void 0},fn=Object.values(dn).some(e=>e!==void 0)||Xt!==void 0?{...dn,...Xt}:void 0,pn=Math.max(1,b.length+ +!!T+ +!!D+ +!!B),mn=b.some(e=>e.pin===`start`||e.pin===`end`),hn=mn||M||!!N||P||Et||Tt,H=+!!B+ +!!D,gn=mn?ge([...B?[`lead`]:[],...D?[`lead`]:[],...b.map(e=>e.pin===`start`||e.pin===`end`?e.pin:null),...T?[null]:[]]):[],U=(e,t=``)=>{let n=gn[e];return n?{className:`${t.trim()} ${he(n)}`.trim(),style:{[p]:me(n.side,n.ordinal)}}:{className:t,style:void 0}},_n=(e,t)=>gn[e]?{...t,...U(e).style}:t,vn=b.length-1+ +!!T;qt&&!M&&x(`view-key`,"`viewKey` remembers resized widths: add `resizableColumns`."),P&&!V&&x(`virtual-height`,"`virtual` needs `maxHeight`: without a scroll box every row renders."),P&&(B||A)&&x(`virtual-shape`,"`virtual` takes rows of one height, so it is off with `renderExpanded` or `stackOnMobile`."),P&&Nt!==void 0&&Nt!==1&&x(`virtual-name-lines`,"`nameLines` is ignored with `virtual`: a virtual table shows one line per name."),zt&&!R&&x(`link-first-column`,"`linkFirstColumn` needs rowHref or onRowClick: the row is what opens."),Ct&&typeof St!=`function`&&x(`single-expand`,"`singleExpand` needs renderExpanded: there are no rows to expand."),!P&&C?.length>500&&x(`rows-without-virtual`,`renders more than 500 rows without virtual: add virtual with maxHeight, or page the data.`);let W=P&&V&&!B&&!A&&!w&&C?.length>0,G=(e,t)=>!vt||!!vt(e,t),yn=D&&C?C.reduce((e,t,n)=>e+ +!!G(t,n),0):0,K=D&&C?C.reduce((e,t,n)=>e+(G(t,n)&&O?.has(L(t,n))?1:0),0):0,bn=yn>0&&K===yn,xn=K>0&&!bn,Sn=e=>{e&&(e.indeterminate=xn)},Cn=h(null),wn=(e,t)=>{let n=Cn.current;Cn.current=e;let r=t&&n!==null?C.findIndex((e,t)=>L(e,t)===n):-1,i=C.findIndex((t,n)=>L(t,n)===e);if(r<0||i<0||r===i){yt?.(e);return}let a=!O?.has(e),o=Math.min(r,i),s=C.slice(o,Math.max(r,i)+1).map((e,t)=>[e,o+t]).filter(([e,t])=>G(e,t)).map(([e,t])=>L(e,t)).filter(e=>(O?.has(e)||!1)!==a);if(xt)xt(s,a);else for(let e of s)yt?.(e)},Tn=e=>{vt?(C||[]).forEach((t,n)=>{let r=L(t,n);G(t,n)&&(O?.has(r)||!1)!==e&&yt?.(r)}):bt?.(e)},[En,Dn]=g(()=>/* @__PURE__ */ new Set),On=e=>Dn(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),q=Ae(()=>{let e=(C||[]).map((e,t)=>({row:e,i:t}));return N?de(e,({row:e})=>String(y(e,N)??``)).flatMap(e=>[{group:e,open:!En.has(e.key)},...En.has(e.key)?[]:e.items]):e},[C,N,En]),kn=h(null),[J,An]=g(null),jn=Oe(e=>{kn.current=e,An(e)},[]),Mn=h(null);m(()=>{let e=J;if(!e)return;let t=e=>{let t=e.target instanceof Element?e.target.closest(`.u-name`):null;t&&!t.title&&(t.scrollWidth>t.clientWidth||t.scrollHeight>t.clientHeight)&&(t.title=(t.textContent??``).trim())},n=e=>{let t=e.target instanceof Element?e.target.closest(`tbody > tr[aria-rowindex]`)?.getAttribute(`aria-rowindex`):null;Mn.current=t?Number(t)-2:null},r=t=>{t.relatedTarget instanceof Node&&e.contains(t.relatedTarget)||(Mn.current=null)};e.addEventListener(`mouseover`,t),e.addEventListener(`focusin`,t),e.addEventListener(`focusin`,n),e.addEventListener(`focusout`,r);let i=ce(e);return()=>{e.removeEventListener(`mouseover`,t),e.removeEventListener(`focusin`,t),e.removeEventListener(`focusin`,n),e.removeEventListener(`focusout`,r),i()}},[J]),m(()=>{if(!k||!J)return;let e=se(J);return xe(document),e},[k,J]);let Nn=h(Ze);ke(()=>{Nn.current=()=>({total:C?.length??0,keys:C?C.flatMap((e,t)=>{let n=L(e,t);return G(e,t)&&O?.has(n)?[String(n)]:[]}):[]})});let Pn=h(!1);m(()=>{if(!Pn.current&&(Pn.current=!0,K===0))return;let{total:e,keys:t}=Nn.current();kn.current?.querySelector(`table`)?.dispatchEvent(new CustomEvent(`selectionchange`,{bubbles:!0,detail:{selected:K,total:e,keys:t}}))},[K]);let[Fn,In]=g({top:0,height:0}),[Ln,Rn]=g(ie[z]??ie.cozy);m(()=>{let e=J;if(!W||!e)return;let t=0,n=()=>{t=0;let n=e.querySelector(`:scope > table > thead`)?.getBoundingClientRect().height||0,r={top:Math.max(0,e.scrollTop-n),height:e.clientHeight};In(e=>e.top===r.top&&e.height===r.height?e:r)},r=()=>{t||=requestAnimationFrame(n)};e.addEventListener(`scroll`,r,{passive:!0});let i=typeof ResizeObserver<`u`?new ResizeObserver(r):null;return i?.observe(e),n(),()=>{e.removeEventListener(`scroll`,r),i?.disconnect(),t&&cancelAnimationFrame(t)}},[W,J]);let zn=h(null);ke(()=>{if(!W){zn.current=null;return}let e=`${z}:${C?.length??0}`;if(zn.current===e)return;zn.current=e;let t=(kn.current?.querySelector(`:scope > table > tbody > tr:not(.wui-virtual-spacer, .wui-group-row)`))?.getBoundingClientRect().height;t!==void 0&&t>0&&Math.abs(t-Ln)>.5&&Rn(t)});let Y={start:0,end:q.length,before:0,after:0};if(W){Y=we({scrollTop:Fn.top,viewport:Fn.height||Number.parseFloat(String(Ft))||0,rowHeight:Ln,count:q.length});let e=Mn.current;e!==null&&e>=0&&e<q.length&&(e<Y.start&&Y.start-e<=Je&&(Y={...Y,start:e,before:e*Ln}),e>=Y.end&&e-Y.end<Je&&(Y={...Y,end:e+1,after:(q.length-e-1)*Ln}))}let Bn=h(null),Vn=h(null),Hn=h(null),Un=!P&&!w&&C?.length>0&&C.length<=ae;ke(()=>{let e=Bn.current;if(!Un||!e){Vn.current=null,Hn.current=null;return}let t=C.map((e,t)=>L(e,t));ve(Hn.current,t)&&_e(e.rows,Vn.current),Vn.current=pe(e.rows),Hn.current=t});let Wn=typeof F==`function`||typeof I==`function`,Gn=h(null),Kn=h(null),X=b[0]?.key;m(()=>{if(!Wn){Kn.current=null;return}let e=/* @__PURE__ */ new Map;(C||[]).forEach((t,n)=>{let r=X===void 0?void 0:y(t,X),i=typeof r==`string`||typeof r==`number`?String(r):``;e.set(L(t,n),{...$e(t,F,I),label:i})});let t=ye(be(Kn.current,e));Kn.current=e,t&&Gn.current&&(Gn.current.textContent=t)},[C,F,I,L,Wn,X]);let qn=lt!==void 0&&(ft===void 0||ft>0)?lt:ct,Z=!w&&ut?ut:null,Jn=e=>{if(Ot){Ot(e);return}let t=b.map(e=>typeof e.label==`string`?e.label:e.key),n=C.map(e=>b.map(t=>{let n=t.exportValue?t.exportValue(e):y(e,t.key);return n==null?``:String(n)}));e===`csv`?le([Se(t,n)],`text/csv;charset=utf-8`,`${Dt}.csv`):le([Ce(t,n)],Be,`${Dt}.xlsx`)},Yn=({group:e,open:n},r)=>{let i=y(e.items[0]?.row,N??``),a=e.items.map(e=>e.row);return/* @__PURE__ */ _(`tr`,{className:`wui-group-row`,"data-group-key":e.key,"aria-rowindex":W?r+2:void 0,children:/* @__PURE__ */ _(`th`,{className:`wui-group-cell`,scope:`rowgroup`,colSpan:pn,children:/* @__PURE__ */ v(`button`,{type:`button`,className:`wui-group-toggle`,"aria-expanded":n,onClick:()=>On(e.key),children:[/* @__PURE__ */ _(s,{name:`chevron-down`,size:16}),/* @__PURE__ */ _(`span`,{className:`wui-group-label`,children:Jt?Jt(i,a):tt(Ge(i,N??``))}),/* @__PURE__ */ _(`span`,{className:`wui-group-count`,"aria-hidden":`true`,children:ue(e.items.length)}),/* @__PURE__ */ _(`span`,{className:`visually-hidden wui-group-rows`,children:`, ${Fe(t,`groupRows`,e.items.length,{count:ue(e.items.length)})}`})]})})},`group:${e.key}`)},Xn=({row:e,i:n},r)=>{let i=L(e,n),a=B&&nn.has(i),o=Gt!=null&&String(Gt)===String(i),ee=Kt!=null&&String(Kt)===String(i),c=String(i).replace(/[^a-z0-9]/gi,`_`),l=U(0,`wui-expand-cell`),u=U(+!!B,`wui-select-cell`),d=Wn?$e(e,F,I):null,f=G(e,n),ne=T?.(e);if(T&&!Array.isArray(ne))throw TypeError(`AppDataTable: rowActions returns a list of actions ({ key, label, icon, onClick or href }). It returned something else: restate the buttons as a list, see node scripts/codemods/row-actions.mjs --check.`);let p=X===void 0?void 0:y(e,X),re=typeof p==`string`||typeof p==`number`?Pe(t.moreActionsForText,{firstValue:p}):Te.menuLabel;return/* @__PURE__ */ v(Ee,{children:[/* @__PURE__ */ v(`tr`,{className:[D&&f&&O?.has(i)?`is-selected`:``,R?`wui-row-link`:``,o?`wui-row-active`:``,ee?Ie.hover:``].filter(Boolean).join(` `)||void 0,"aria-current":o?`true`:void 0,"aria-rowindex":W?r+2:void 0,"aria-busy":d?.state===`saving`?`true`:void 0,"data-wui-save-state":d?.state||void 0,"data-status":Vt?.(e)||void 0,"data-tone":Ht?.(e)||void 0,"data-href":j?.(e)||void 0,"data-row-key":k?String(i):void 0,tabIndex:R?0:void 0,onClick:R?t=>cn(e,t):void 0,onAuxClick:R&&j?t=>t.button===1&&cn(e,t):void 0,onKeyDown:R?t=>{fe(t.nativeEvent)&&t.target===t.currentTarget&&cn(e,t)}:void 0,children:[B&&/* @__PURE__ */ _(`td`,{className:l.className,style:l.style,children:/* @__PURE__ */ _(`button`,{type:`button`,className:`wui-expand-toggle${a?` is-open`:``}`,"aria-expanded":a,"aria-controls":a?`${c}-expanded`:void 0,"aria-label":a?t.collapseRowLabel:t.expandRowLabel,onClick:()=>an(i),children:/* @__PURE__ */ _(s,{name:`chevron-down`,size:16})})}),D&&/* @__PURE__ */ _(`td`,{className:u.className,style:u.style,children:/* @__PURE__ */ _(`input`,{type:`checkbox`,className:`wui-check`,checked:f&&(O?.has(i)||!1),disabled:!f,onChange:e=>wn(i,e.nativeEvent instanceof MouseEvent&&e.nativeEvent.shiftKey),onMouseDown:e=>{e.shiftKey&&e.preventDefault()},"aria-label":t.selectRowLabel})}),b.map((t,n)=>{let r=t.rowHeader?`th`:`td`;return/* @__PURE__ */ v(r,{scope:t.rowHeader?`row`:void 0,className:U(H+n,(n===0?`wui-name-cell `:``)+(t.rowHeader?`wui-row-header `:``)+(t.nowrap?`text-nowrap `:``)+S(t.align)+(t.cellClassName?` ${t.cellClassName}`:``)).className,style:_n(H+n,t.cellStyle),"data-label":A&&typeof t.label==`string`?t.label:void 0,children:[t.render?t.render(e):tt(Ke(e,t.key)),n===0&&d?.state===`error`&&/* @__PURE__ */ _(`span`,{className:oe,children:d.message})]},t.key)}),T&&/* @__PURE__ */ _(`td`,{children:/* @__PURE__ */ _(te,{items:ne??[],menuLabel:re,linkComponent:pt})})]}),a&&/* @__PURE__ */ _(`tr`,{className:`wui-row-expanded`,children:/* @__PURE__ */ _(`td`,{id:`${c}-expanded`,colSpan:pn,children:St?.(e)})})]},i)},Zn=(e,t)=>`group`in e?Yn(e,t):Xn(e,t),Qn=(e,t)=>W?/* @__PURE__ */ _(`tr`,{className:`wui-virtual-spacer`,"aria-hidden":`true`,hidden:t===0,children:/* @__PURE__ */ _(`td`,{colSpan:pn,style:{height:t}})},e):null,Q=U(0,`wui-expand-cell`),$=U(+!!B,`wui-select-cell`),$n=()=>Array.from({length:st},(e,t)=>`skeleton-${t}`).map(e=>/* @__PURE__ */ v(`tr`,{children:[B&&/* @__PURE__ */ _(`td`,{className:Q.className,style:Q.style}),D&&/* @__PURE__ */ _(`td`,{className:$.className,style:$.style}),b.map((e,t)=>/* @__PURE__ */ _(`td`,{className:U(H+t,(t===0?`wui-name-cell `:``)+(e.nowrap?`text-nowrap `:``)+S(e.align)).className,style:_n(H+t,void 0),"data-label":A&&typeof e.label==`string`?e.label:void 0,children:/* @__PURE__ */ _(c,{width:et(e.align),height:12,radius:6})},e.key)),T&&/* @__PURE__ */ _(`td`,{children:/* @__PURE__ */ _(`div`,{className:`u-row-actions`,children:/* @__PURE__ */ _(c,{width:`32px`,height:12,radius:6})})})]},e));return/* @__PURE__ */ v(je,{children:[/* @__PURE__ */ v(hn?`wui-data-table`:`div`,{ref:jn,...hn?{class:un,resizable:M?``:void 0,"view-key":qt||void 0,"data-wui-row-drag":k?``:void 0,"aria-busy":ln||void 0}:{className:un,"data-wui-row-drag":k?``:void 0,"aria-busy":ln||void 0},style:fn,tabIndex:0,...Ue,...Zt,children:[Et&&/* @__PURE__ */ v(`div`,{className:`wui-table-export`,children:[/* @__PURE__ */ _(a,{variant:`soft`,size:`sm`,onClick:()=>Jn(`csv`),children:t.exportCsvLabel}),/* @__PURE__ */ _(a,{variant:`soft`,size:`sm`,onClick:()=>Jn(`xlsx`),children:t.exportExcelLabel})]}),Tt&&/* @__PURE__ */ v(`div`,{className:`wui-table-density`,role:`group`,"aria-label":t.densityLabel,children:[/* @__PURE__ */ _(a,{variant:`soft`,size:`sm`,"aria-pressed":z===`comfortable`,"aria-label":t.densityComfortableLabel,onClick:()=>en(`comfortable`),children:/* @__PURE__ */ _(s,{name:`list`,size:16})}),/* @__PURE__ */ _(a,{variant:`soft`,size:`sm`,"aria-pressed":z===`compact`,"aria-label":t.densityCompactLabel,onClick:()=>en(`compact`),children:/* @__PURE__ */ _(s,{name:`grid`,size:16})})]}),/* @__PURE__ */ v(`table`,{className:tn,"aria-label":ht,"aria-rowcount":W?q.length+1:void 0,style:kt===`fixed`?{tableLayout:`fixed`,minWidth:We(b)}:void 0,children:[/* @__PURE__ */ _(`thead`,{children:/* @__PURE__ */ v(`tr`,{"aria-rowindex":W?1:void 0,children:[B&&/* @__PURE__ */ _(`th`,{className:Q.className,style:Q.style,children:/* @__PURE__ */ _(`span`,{className:`visually-hidden`,children:t.expandLabel})}),D&&/* @__PURE__ */ _(`th`,{className:$.className,style:$.style,children:/* @__PURE__ */ _(`input`,{ref:Sn,type:`checkbox`,className:`wui-check`,checked:bn,disabled:w,onChange:e=>Tn(e.target.checked),"aria-label":t.selectAllRowsLabel})}),b.map((e,t)=>{let n=e.sortable?at:void 0,r=n!==void 0,i=it&&it.key===e.key,a=e.align===`num`||e.align===`end`,o=r&&/* @__PURE__ */ _(`span`,{className:`sort-icon${a?` wui-sort-lead`:``}`,children:/* @__PURE__ */ _(s,{name:`chevrons-up-down`,size:14})}),te=M&&t!==vn,c=kt===`fixed`&&!e.grow?e.minWidth:void 0,l=e.width||e.minWidth?{width:e.width??c,minWidth:e.minWidth}:void 0;return/* @__PURE__ */ v(`th`,{className:U(H+t,(r?`sortable `:``)+(t===0?`wui-name-cell `:``)+(e.nowrap?`text-nowrap `:``)+(e.grow?`wui-col-grow `:``)+(te?`wui-col-resizable `:``)+S(e.align)).className,style:_n(H+t,l),"data-key":hn?e.key:void 0,"aria-label":te&&typeof e.label==`string`?e.label:void 0,"data-pin":e.pin===`start`||e.pin===`end`?e.pin:void 0,tabIndex:r?0:void 0,"aria-sort":i?it?.dir===`asc`?`ascending`:`descending`:r?`none`:void 0,onClick:n?t=>{t.target instanceof Element&&t.target.closest(`.infotip`)||w||n(e.key)}:void 0,onKeyDown:n?t=>{t.target===t.currentTarget&&(fe(t.nativeEvent)||t.key===` `)&&(t.preventDefault(),w||n(e.key))}:void 0,children:[a&&o,e.label,!a&&o,e.help?/* @__PURE__ */ _(ee,{label:typeof e.label==`string`?e.label:void 0,children:e.help}):null,te&&/* @__PURE__ */ _(`span`,{className:`wui-col-resize`,role:`separator`,"aria-orientation":`vertical`,"aria-valuemin":ne,"aria-valuemax":f,tabIndex:0,"aria-label":De(typeof e.label==`string`?e.label:e.key)})]},e.key)}),T&&(mt?/* @__PURE__ */ _(`th`,{className:`wui-cell-end`,children:mt}):/* @__PURE__ */ _(`th`,{className:`wui-cell-end`,children:/* @__PURE__ */ _(`span`,{className:`visually-hidden`,children:t.rowActionsLabel})}))]})}),/* @__PURE__ */ _(`tbody`,{ref:Bn,children:w?$n():Z?null:C?.length?/* @__PURE__ */ v(je,{children:[Qn(`before`,Y.before),q.slice(Y.start,Y.end).map((e,t)=>Zn(e,Y.start+t)),Qn(`after`,Y.after)]}):null}),on&&!w&&!Z&&C?.length>0&&/* @__PURE__ */ _(`tfoot`,{children:/* @__PURE__ */ v(`tr`,{children:[B&&/* @__PURE__ */ _(`td`,{className:Q.className,style:Q.style}),D&&/* @__PURE__ */ _(`td`,{className:$.className,style:$.style}),b.map((e,t)=>/* @__PURE__ */ _(`td`,{className:U(H+t,(t===0?`wui-name-cell `:``)+(e.nowrap?`text-nowrap `:``)+S(e.align)).className,style:_n(H+t,void 0),children:e.footer?e.footer(C):null},e.key)),T&&/* @__PURE__ */ _(`td`,{})]})})]}),!w&&(Z||!C?.length)&&/* @__PURE__ */ _(`div`,{className:`tbl-empty-block`,role:Z?`alert`:void 0,children:Z?/* @__PURE__ */ _(o,{variant:`table`,icon:`alert-circle`,description:Z.message,action:dt?/* @__PURE__ */ _(a,{variant:`soft`,size:`sm`,onClick:()=>dt(),children:t.retryLabel}):void 0,className:`wui-table-error`}):typeof qn==`string`?/* @__PURE__ */ _(`div`,{className:`tbl-empty-plain`,children:qn}):qn})]}),nt(E)&&/* @__PURE__ */ _(l,{page:E.page,totalPages:E.totalPages,total:E.total,pageSize:E.pageSize,onPageChange:w?Xe:E.setPage,onPageSizeChange:w?Xe:E.setPageSize,pageSizes:E.pageSizes,mode:E.mode,summary:E.summary}),Wn&&/* @__PURE__ */ _(`div`,{ref:Gn,className:`visually-hidden`,role:`status`,"aria-live":`polite`,"data-wui-table-status":``})]})}export{C as default};
@@ -1 +1 @@
1
- import{devWarn as e}from"../lib/devWarn.js";import{linkTarget as t}from"../lib/linkTarget.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{TargetLink as c}from"../lib/TargetLink.js";import l from"../lib/useElementEntry.js";import u from"../lib/useWuiText.js";import{TONES as d}from"../lib/vocabulary.js";import{splitMarkerProps as f}from"../lib/wuiMarker.js";import p from"./AppAvatar.js";import m from"./AppButton.js";import h from"./AppIcon.js";import g from"./AppNavigationMenu.js";import _ from"./assertValidValue.js";import v from"./warnUnknownProps.js";import{IST_TIME_ZONE as y,initScrollEdges as b,isImeSafeEnter as x,revealActiveNavItem as S,setPopoverOpen as C}from"@webority/ui-elements/helpers";import{useEffect as w,useId as T,useMemo as E,useRef as D,useState as O}from"react";import{Fragment as k,jsx as A,jsxs as j}from"react/jsx-runtime";import{SHELL_TEXT as M,fillText as N}from"@webority/ui-elements/text";var P=()=>import(`@webority/ui-elements/elements/overflow`),F=()=>import(`@webority/ui-elements/elements/dropdown`),I=99,L=4,R=5,z=/^[a-z0-9-]+$/,B=`wui-sidebar-footer`,V=[],H=[`prefix`,`exact`],U=[`comfortable`,`compact`],W=[`neutral`,`primary`],ee=[`default`,`brand`],te=[`side`,`top`],ne=[`linear`,`outline`,`bold`,`bulk`,`broken`,`twotone`],re=/* @__PURE__ */ new Set([`key`,`label`,`icon`,`iconVariant`,`iconSize`,`href`,`badge`,`badgeTone`,`badgeTitle`,`newUntil`,`trailingIcon`,`active`,`match`,`matchAlso`,`tab`,`tabLabel`,`children`]),G=e=>e>I?`${I}+`:String(e),K=new Intl.DateTimeFormat(`en-CA`,{timeZone:y}),ie=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:K.format(/* @__PURE__ */ new Date)<=e},ae=({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(` `)},oe=({logoLight:e,logoDark:t,markLight:n,markDark:r,brandName:i})=>{let a=i??``,o=[e&&/* @__PURE__ */ A(`img`,{className:`wui-brand-logo wui-brand-light`,src:e,alt:a},`logo-light`),t&&/* @__PURE__ */ A(`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(e=>!!e).map(([t,n,r],i)=>i===0&&!e?/* @__PURE__ */ A(`img`,{className:n,src:r,alt:a},t):/* @__PURE__ */ A(`img`,{className:n,src:r,alt:``,"aria-hidden":`true`},t));return[...o,...s].filter(Boolean)};function q(e){let{marker:t,props:n}=f(`AppShell`,e),c=u(`shell`,M),{groups:l=[],brand:d,logoLight:p,logoDark:m,markLight:y,markDark:x,brandName:T,brandHref:N,brandLabel:P,sidebarStart:F,sidebarStartCompact:I,sidebarFooter:L,sidebarFooterItems:R=V,topbarStart:z,topbarEnd:B,footer:H,launcher:re,children:G,collapsed:K,onCollapsedChange:ie,noSidebar:q=!1,nav:J=`side`,topNavDetail:Y=!1,capBadges:ce=!1,density:le=`comfortable`,itemHeight:ue,iconVariant:X=`twotone`,topbarTone:_e=`neutral`,tone:be=`default`,navLabel:Se=c.navLabel,linkComponent:Z,currentPath:Ce,rememberCollapsed:we=!1,collapsedCookie:Te=`wui-shell-collapsed`,foldedCookie:Ee=r,tabBarLabel:De=c.tabBarLabel,moreLabel:Oe=c.moreLabel,skipLabel:ke=c.skipLabel,openNavLabel:Ae=c.openNavLabel,expandNavLabel:je=c.expandNavLabel,collapseNavLabel:Me=c.collapseNavLabel,newLabel:Ne=c.newLabel,togglePagesLabel:Pe=c.togglePagesLabel,accountMenuLabel:Fe=c.accountMenuLabel,roleLabel:Ie=c.roleLabel,rolesLabel:Le=c.rolesLabel,unreadLabel:Re=c.unreadLabel,markAllReadLabel:ze=c.markAllReadLabel,viewAllLabel:Be=c.viewAllLabel,loadingNotificationsText:Ve=c.loadingNotificationsText,noUnreadText:He=c.noUnreadText,unreadNotificationsText:Ue=c.unreadNotificationsText,unreadBellLabel:We=c.unreadBellLabel,searchResultsLabel:Ge=c.searchResultsLabel,noResultsText:Ke=c.noResultsText,noResultsForText:qe=c.noResultsForText,resultsCountText:Je=c.resultsCountText,resultCountText:Ye=c.resultCountText,userMenu:Xe,notifications:Ze,search:Qe,className:$e=``,style:et,...tt}=n;if(v(`AppShell`,tt),_(`AppShell`,`density`,le,U),_(`AppShell`,`topbarTone`,_e,W),_(`AppShell`,`tone`,be,ee),_(`AppShell`,`nav`,J,te),_(`AppShell`,`iconVariant`,X,ne),P!==void 0&&!N)throw Error(`<AppShell> brandLabel names the brand link, so it needs brandHref.`);if(N){if(!P&&!T)throw Error(`<AppShell> brandHref needs brandLabel or brandName: the collapsed rail hides the logo, so the link would have no accessible name.`);if(!(d||p||m||y||x))throw Error(`<AppShell> brandHref has no brand, logo or mark to link.`)}let nt=(ue??0)>0?{...et,"--wui-nav-item-height":`${ue}px`}:et,[rt,it]=O(()=>we&&K===void 0&&typeof document<`u`?a(Te)??!1:!1),[at,Q]=O(!1),ot=D(null),[st,ct]=O(!1),[lt,ut]=O(!1),dt=D(null),ft=K??rt,pt=e=>N?/* @__PURE__ */ A(pe,{href:N,label:P||T,linkComponent:Z,onNavigate:()=>Q(!1),children:e}):e,mt=()=>{let e=!ft;K===void 0&&it(e),we&&s(e,Te),ie?.(e)},ht=l.some(e=>e.collapsible),[gt,_t]=O(()=>ht&&typeof document<`u`?i(Ee):/* @__PURE__ */ new Set),vt=e=>{let t=new Set(gt);t.has(e)?t.delete(e):t.add(e),_t(t),o(t,Ee)},yt=E(()=>se(l,R,Ce),[l,R,Ce]),$=yt.groups,bt=yt.footer,xt=q?null:de($,bt.some(e=>e.active));w(()=>{let e=()=>ct(window.scrollY>4);return e(),window.addEventListener(`scroll`,e,{passive:!0}),()=>window.removeEventListener(`scroll`,e)},[]),w(()=>{b()},[]),w(()=>{S(dt.current)},[]),w(()=>{let e=dt.current;if(!e)return;let t=()=>ut($.length>0&&e.scrollHeight>e.clientHeight);if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[$]),w(()=>{let e=ot.current;if(!e)return;let t=window.matchMedia(`(max-width: 991.98px)`),n=()=>{t.matches?e.setAttribute(`popover`,`auto`):(e.removeAttribute(`popover`),Q(!1))},r=e=>Q(`newState`in e&&e.newState===`open`);return n(),t.addEventListener(`change`,n),e.addEventListener(`toggle`,r),()=>{t.removeEventListener(`change`,n),e.removeEventListener(`toggle`,r)}},[]),w(()=>{let e=ot.current;e?.hasAttribute(`popover`)&&C(e,at)},[at]);let St=[`app-shell`,ft?`collapsed`:``,q?`no-sidebar`:``,J===`top`?`wui-shell-top`:``,at?`mobile-open`:``,$e].filter(Boolean).join(` `);return/* @__PURE__ */ j(`div`,{className:St,"data-density":le===`compact`?`compact`:void 0,"data-shell-tone":be===`brand`?`brand`:void 0,"data-wui-folded-cookie":ht?Ee:void 0,style:nt,...t,...tt,children:[/* @__PURE__ */ A(`a`,{className:`wui-skip-link`,href:`#main-content`,children:ke}),/* @__PURE__ */ j(`aside`,{className:`app-sidebar`,ref:ot,children:[(d||p||m||y||x)&&/* @__PURE__ */ A(`div`,{className:ae({logoLight:p,logoDark:m,markLight:y,markDark:x}),children:pt(/* @__PURE__ */ j(k,{children:[oe({logoLight:p,logoDark:m,markLight:y,markDark:x,brandName:T}),d]}))}),F&&/* @__PURE__ */ A(`div`,{className:`app-sidebar-start`,children:F}),I&&/* @__PURE__ */ A(`div`,{className:`app-sidebar-start-compact`,children:I}),/* @__PURE__ */ A(`nav`,{className:`app-sidebar-scroll`,"aria-label":Se,ref:dt,tabIndex:lt?0:void 0,children:$.map((e,t)=>{let n=e.items.map(e=>e.header==null?/* @__PURE__ */ A(ge,{item:e,linkComponent:Z,onNavigate:()=>Q(!1),iconVariant:X,newLabel:Ne,togglePagesLabel:Pe,capBadges:ce},e.key??e.href??e.label):/* @__PURE__ */ A(`div`,{className:`wui-nav-header`,children:e.header},e.key??e.header));if(!e.collapsible)return/* @__PURE__ */ j(`div`,{className:`app-nav-group`,children:[e.label&&/* @__PURE__ */ A(`div`,{className:`app-nav-group-label`,children:e.label}),n,e.after&&/* @__PURE__ */ A(`div`,{className:`wui-nav-group-after`,children:e.after})]},e.key??e.label??`group-${t}`);let r=!gt.has(e.key??``)||!!he(e.items),i=`wui-nav-group-${e.key}`;return/* @__PURE__ */ j(`div`,{className:`app-nav-group wui-nav-group-collapsible${r?``:` wui-nav-group-folded`}`,"data-wui-nav-group":e.key,children:[/* @__PURE__ */ j(`button`,{type:`button`,className:`app-nav-group-label wui-nav-group-toggle`,"aria-expanded":r,"aria-controls":i,onClick:()=>vt(e.key??``),children:[/* @__PURE__ */ A(`span`,{className:`wui-nav-group-text`,children:e.label}),/* @__PURE__ */ A(`span`,{className:`wui-nav-group-caret`,children:/* @__PURE__ */ A(h,{name:`chevron-down`,size:16})})]}),/* @__PURE__ */ j(`div`,{className:`wui-nav-group-body`,id:i,children:[n,e.after&&/* @__PURE__ */ A(`div`,{className:`wui-nav-group-after`,children:e.after})]})]},e.key??`group-${t}`)})}),(L||bt.length>0)&&/* @__PURE__ */ j(`div`,{className:`app-sidebar-foot`,children:[bt.length>0&&/* @__PURE__ */ A(`div`,{className:`wui-sidebar-foot-links`,children:bt.map(e=>/* @__PURE__ */ A(ge,{item:e,linkComponent:Z,onNavigate:()=>Q(!1),iconVariant:X,newLabel:Ne,togglePagesLabel:Pe,capBadges:ce},e.key??e.href??e.label))}),L]}),!q&&/* @__PURE__ */ A(`button`,{type:`button`,className:`app-sidebar-toggle`,onClick:mt,"aria-label":ft?je:Me,"aria-expanded":!ft,children:/* @__PURE__ */ A(h,{name:`chevrons-left`,size:20})})]}),/* @__PURE__ */ j(`div`,{className:`app-main`,children:[/* @__PURE__ */ j(`header`,{className:`app-topbar${st?` wui-scrolled`:``}`,"data-tone":_e===`primary`?`primary`:void 0,children:[/* @__PURE__ */ j(`div`,{className:`app-topbar-start`,children:[/* @__PURE__ */ A(`button`,{type:`button`,className:`app-topbar-menu`,onClick:()=>Q(!0),"aria-label":Ae,"aria-expanded":at,children:/* @__PURE__ */ A(h,{name:`menu`,size:18})}),J===`top`&&d&&/* @__PURE__ */ A(`div`,{className:`wui-shell-top-brand`,children:pt(d)}),J===`top`&&/* @__PURE__ */ A(`div`,{className:`wui-shell-top-nav`,children:/* @__PURE__ */ A(g,{items:fe($,Y),ariaLabel:Se,linkComponent:Z})}),z,Qe&&/* @__PURE__ */ A(xe,{config:Qe,searchResultsLabel:Ge,noResultsText:Ke,noResultsForText:qe,resultsCountText:Je,resultCountText:Ye,moreLabel:Oe})]}),/* @__PURE__ */ j(`div`,{className:`app-topbar-end`,children:[B,Ze&&/* @__PURE__ */ A(ye,{config:Ze,unreadLabel:Re,markAllReadLabel:ze,viewAllLabel:Be,loadingNotificationsText:Ve,noUnreadText:He,unreadNotificationsText:Ue,unreadBellLabel:We}),Xe&&/* @__PURE__ */ A(ve,{config:Xe,linkComponent:Z,accountMenuLabel:Fe,roleLabel:Ie,rolesLabel:Le})]})]}),/* @__PURE__ */ A(`main`,{className:`app-content`,id:`main-content`,children:G}),H&&/* @__PURE__ */ A(`footer`,{className:`app-footer`,children:H})]}),re&&/* @__PURE__ */ A(`div`,{className:`wui-shell-launcher`,children:re}),xt&&/* @__PURE__ */ j(`nav`,{className:`wui-tabbar`,"aria-label":De,children:[xt.tabs.map(e=>/* @__PURE__ */ A(me,{tab:e,linkComponent:Z,iconVariant:X,capBadges:ce},e.key??e.href)),xt.hasMore&&/* @__PURE__ */ j(`button`,{type:`button`,className:`wui-tabbar-item${xt.moreActive?` active`:``}`,onClick:()=>Q(!0),children:[/* @__PURE__ */ A(`span`,{className:`wui-tabbar-icon`,children:/* @__PURE__ */ A(h,{name:`more`,size:24})}),/* @__PURE__ */ A(`span`,{className:`wui-tabbar-label`,children:Oe})]})]})]})}function se(e,t,r){let i=t;for(let e of i){if(e.children?.length)throw Error(`<AppShell> sidebarFooterItems cannot hold children; keep footer links flat.`);if(e.tab)throw Error(`<AppShell> sidebarFooterItems cannot carry tab: true; the phone tab bar is built from groups.`);if(e.header!=null)throw Error(`<AppShell> sidebarFooterItems cannot hold a header row.`)}for(let t of e)t.collapsible&&ue(t);let a=(e,t=!1)=>(e??[]).map(e=>Array.isArray(e.children)?{...e,children:a(e.children)}:{...e}).filter(e=>Y(e)?t:(e.children?.length??0)>0||!!e.href),o=[...e,{key:B,items:t}].map(e=>({...e,items:ce(a(e.items,!0))})).filter(e=>e.items.some(e=>!Y(e))),s=[],c=e=>{for(let t of e)Y(t)||(s.push(t),t.children&&c(t.children))};for(let e of o)c(e.items);for(let e of s)v(`AppShell items`,J(e)),_(`AppShell`,`match`,e.match,H),_(`AppShell`,`iconVariant`,e.iconVariant,ne),_(`AppShell`,`badgeTone`,e.badgeTone,d);let l=null;if(r!=null&&!s.some(e=>e.active===!0)){let e=-1;for(let t of s){if(t.active!=null||t.children?.length&&!t.href)continue;let i=n(r,t.href,{exact:t.match===`exact`,also:t.matchAlso});if(i<0)continue;let a=t.match===`exact`&&n(r,t.href,{exact:!0})>=0?1/0:i;a>e&&(e=a,l=t)}}for(let e of s)e.active=e.active??e===l;return{groups:o.filter(e=>e.key!==B),footer:o.find(e=>e.key===B)?.items??[]}}function J(e){return Object.fromEntries(Object.entries(e).filter(([e])=>!re.has(e)))}var Y=e=>e.header!=null;function ce(e){return e.filter((t,n)=>{if(!Y(t))return!0;let r=e.findIndex((e,t)=>t>n&&Y(e));return e.slice(n+1,r<0?void 0:r).length>0})}var le=/* @__PURE__ */ new Set;function ue(t){if(t.key!=null&&z.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.`;typeof process<`u`&&process.env.NODE_ENV===`production`||le.has(n)||(le.add(n),e(n))}function de(e,t){let n=[],r=e=>{for(let t of e)Y(t)||(t.children?.length?r(t.children):n.push(t))};for(let t of e)r(t.items);let i=n.filter(e=>e.tab);if(i.length===0)return null;let a=i.length<n.length,o=a?L:R;if(i.length>o)throw Error(`<AppShell>: ${i.length} items carry tab: true, but the phone tab bar holds ${o} (${a?`4 plus More, because other items exist`:`5 when every item is a tab`}). Flag fewer items.`);return{tabs:i,hasMore:a,moreActive:t||n.some(e=>!e.tab&&e.active)}}function fe(e,t){let n=e=>{if(e.label===void 0)throw Error(`<AppShell> a navigation row has no label; every row but a header needs one.`);return e.label},r=e=>e.key??e.href??n(e),i=(e,i)=>({key:r(e),label:n(e),to:i,current:!!e.active,...t&&e.description?{description:e.description}:{}}),a=e=>e.flatMap(e=>Y(e)?[]:[...e.href?[{...i(e,e.href),icon:e.icon}]:[],...a(e.children??[])]),o=[];for(let s of e)for(let e of s.items){if(Y(e))continue;let c=t&&s.label?{group:s.label}:{},l=a(e.children??[]);if(l.length>0){let a=e.href?[{...i(e,e.href),icon:e.icon}]:[],s=t&&(!!e.active||!!he(e.children??[]));o.push({key:r(e),label:n(e),links:[...a,...l],...c,...t?{current:s}:{}})}else e.href&&o.push({...i(e,e.href),...c})}return o}function X(e,t){return t&&typeof e==`number`&&e>I?`${I}+`:e}function pe({href:e,label:n,linkComponent:r,onNavigate:i,children:a}){return/* @__PURE__ */ A(c,{link:t(r,{to:e}),className:`wui-brand-link`,"aria-label":n,onClick:i,children:a})}function me({tab:e,linkComponent:n,iconVariant:r,capBadges:i}){let a=`wui-tabbar-item${e.active?` active`:``}`,o=/* @__PURE__ */ j(k,{children:[e.icon&&/* @__PURE__ */ A(`span`,{className:`wui-tabbar-icon`,children:typeof e.icon==`string`?/* @__PURE__ */ A(h,{name:e.icon,size:24,variant:e.iconVariant??r}):e.icon}),/* @__PURE__ */ A(`span`,{className:`wui-tabbar-label`,children:e.tabLabel??e.label}),e.badge!=null&&/* @__PURE__ */ A(`span`,{className:`wui-tabbar-badge${e.badgeTone?` tone-${e.badgeTone}`:``}`,title:e.badgeTitle||void 0,children:X(e.badge,i)})]}),s=e.active?`page`:void 0;return/* @__PURE__ */ A(c,{link:t(n,{to:e.href}),className:a,"aria-current":s,children:o})}function he(e){for(let t of e){if(t.active)return t;let e=t.children?.length?he(t.children):void 0;if(e)return e}}function ge({item:e,linkComponent:n,onNavigate:r,depth:i=0,iconVariant:a,newLabel:o,togglePagesLabel:s,capBadges:l}){let u=i>0,d=i>1?` wui-nav-depth-${Math.min(i,6)}`:``,f=Array.isArray(e.children)&&e.children.length>0,p=f?he(e.children??[]):void 0,m=!!p,g=p?p.key??p.href??p.label:null,[_,v]=O(m);w(()=>{g!=null&&v(!0)},[g]);let y=typeof e.label==`string`?e.label:void 0,b=!u&&e.icon&&/* @__PURE__ */ A(`span`,{className:`app-nav-icon`,children:typeof e.icon==`string`?/* @__PURE__ */ A(h,{name:e.icon,size:e.iconSize??22,variant:e.iconVariant??a}):e.icon}),x=e.badge!=null&&/* @__PURE__ */ A(`span`,{className:`app-nav-badge${e.badgeTone?` tone-${e.badgeTone}`:``}`,title:e.badgeTitle||void 0,children:X(e.badge,l)}),S=ie(e.newUntil)&&/* @__PURE__ */ A(`span`,{className:`wui-nav-new`,children:o}),C=/* @__PURE__ */ j(k,{children:[b,/* @__PURE__ */ A(`span`,{className:`app-nav-text`,children:e.label}),S,x,e.trailingIcon&&/* @__PURE__ */ A(`span`,{className:`app-nav-trailing`,children:typeof e.trailingIcon==`string`?/* @__PURE__ */ A(h,{name:e.trailingIcon,size:16}):e.trailingIcon})]}),T=e.active?`page`:void 0;if(f){let f=/* @__PURE__ */ A(`div`,{className:`app-nav-sub${_?` expanded`:``}`,inert:!_,"aria-hidden":!_||void 0,children:/* @__PURE__ */ A(`div`,{className:`app-nav-sub-inner`,children:(e.children??[]).map(e=>/* @__PURE__ */ A(ge,{item:e,linkComponent:n,onNavigate:r,depth:i+1,iconVariant:a,newLabel:o,togglePagesLabel:s,capBadges:l},e.key??e.href))})});if(e.href){let i=/* @__PURE__ */ A(c,{link:t(n,{to:e.href}),className:`wui-nav-split-link`,"aria-current":T,onClick:r,children:C});return/* @__PURE__ */ j(k,{children:[/* @__PURE__ */ j(`div`,{className:`app-nav-item has-children wui-nav-split${u?` app-nav-subitem`:``}${m||e.active?` active`:``}${d}`,"data-label":y,children:[i,/* @__PURE__ */ A(`button`,{type:`button`,className:`app-nav-caret wui-nav-split-toggle`,"aria-expanded":_,"aria-label":N(s,{name:y??``}),onClick:()=>v(e=>!e),children:/* @__PURE__ */ A(h,{name:`chevron-right`,size:16})})]}),f]})}return/* @__PURE__ */ j(k,{children:[/* @__PURE__ */ j(`button`,{type:`button`,className:`app-nav-item${u?` app-nav-subitem`:``} has-children${m?` active`:``}${d}`,"aria-expanded":_,"data-label":y,onClick:()=>v(e=>!e),children:[b,/* @__PURE__ */ A(`span`,{className:`app-nav-text`,children:e.label}),S,x,/* @__PURE__ */ A(`span`,{className:`app-nav-caret`,children:/* @__PURE__ */ A(h,{name:`chevron-right`,size:16})})]}),f]})}let E=`app-nav-item${u?` app-nav-subitem`:``}${e.active?` active`:``}${d}`;return/* @__PURE__ */ A(c,{link:t(n,{to:e.href}),className:E,"aria-current":T,"data-label":y,onClick:r,children:C})}function _e(e){l(`wui-dropdown`,F);let[t,n]=O(!1),r=D(null);return w(()=>{r.current?.toggleAttribute(`open`,t)},[t]),w(()=>{let t=r.current;if(!t)return;let i=r=>{if(r.target!==t||!(`detail`in r)||!r.detail||typeof r.detail!=`object`)return;let i=`open`in r.detail&&r.detail.open===!0;n(i),i&&e?.()};return t.addEventListener(`wui-dropdown-toggle`,i),()=>t.removeEventListener(`wui-dropdown-toggle`,i)},[e]),{open:t,setOpen:n,ref:r}}function ve({config:e,linkComponent:n,accountMenuLabel:r,roleLabel:i,rolesLabel:a}){let o=u(`shell`,M),s=T(),{open:l,setOpen:d,ref:f}=_e(),{name:g,role:v,roles:y=[],noTriggerRole:b=!1,outlined:x=!1,photo:S,profileHref:C,profileLabel:w=o.profileLabel,onLogout:E,logoutAction:D,logoutLabel:O=o.logoutLabel,head:P,section:F,logoutVariant:I=`item`,items:L=[]}=e;if(_(`AppShell`,`userMenu.logoutVariant`,I,[`item`,`button`]),!g)throw Error(`<AppShell> userMenu.name is required; the trigger and the avatar are named from it.`);let R=y.map(e=>(e??``).trim()).filter(Boolean),z=()=>d(!1),B=(e,r,i,a)=>/* @__PURE__ */ A(c,{link:t(n,{to:e}),className:`dropdown-item`,onClick:a,children:r},i),V=/* @__PURE__ */ A(h,{name:`log-out`,size:18}),H=/* @__PURE__ */ j(k,{children:[V,O]});return/* @__PURE__ */ j(`wui-dropdown`,{class:`dropdown wui-usermenu`,align:`end`,ref:f,children:[/* @__PURE__ */ j(`button`,{type:`button`,id:s,className:x?`wui-usermenu-trigger wui-usermenu-trigger-outlined`:`wui-usermenu-trigger`,"data-wui-dropdown-trigger":!0,"aria-expanded":l,"aria-label":N(r,{name:g}),children:[/* @__PURE__ */ A(p,{name:g,src:S,tone:`auto`}),/* @__PURE__ */ j(`span`,{className:`wui-usermenu-text`,children:[/* @__PURE__ */ A(`span`,{className:`wui-usermenu-name`,children:g}),v&&!b&&/* @__PURE__ */ A(`span`,{className:`wui-usermenu-role`,children:v})]}),/* @__PURE__ */ A(h,{name:`chevron-down`,size:14,className:`wui-usermenu-caret`})]}),/* @__PURE__ */ j(`div`,{"data-wui-dropdown-menu":!0,popover:`auto`,className:`dropdown-menu dropdown-menu-end wui-usermenu-menu${l?` show`:``}`,"aria-labelledby":s,children:[/* @__PURE__ */ j(`div`,{className:`wui-usermenu-head`,children:[/* @__PURE__ */ A(p,{name:g,src:S,size:`lg`,tone:`auto`}),/* @__PURE__ */ j(`div`,{className:`wui-usermenu-who`,children:[/* @__PURE__ */ A(`div`,{className:`wui-usermenu-name`,children:g}),v&&/* @__PURE__ */ A(`div`,{className:`wui-usermenu-role`,children:v}),R.length>0&&/* @__PURE__ */ j(`div`,{className:`wui-usermenu-roles`,children:[/* @__PURE__ */ A(`span`,{className:`wui-usermenu-roles-label`,children:R.length===1?i:a}),` ${R.join(`, `)}`]}),P?/* @__PURE__ */ A(`div`,{className:`wui-usermenu-extra`,children:P}):null]})]}),F?/* @__PURE__ */ A(`div`,{className:`wui-usermenu-section`,children:F}):null,C&&B(C,/* @__PURE__ */ j(k,{children:[/* @__PURE__ */ A(h,{name:`user`,size:18}),w]}),void 0,z),L.map(e=>{if(e.divider)return/* @__PURE__ */ A(`hr`,{className:`dropdown-divider`},e.key);let t=/* @__PURE__ */ j(k,{children:[e.icon&&/* @__PURE__ */ A(h,{name:e.icon,size:18}),e.label]}),n=()=>{e.onClick?.(),z()};return e.href?B(e.href,t,e.key,n):/* @__PURE__ */ A(`button`,{type:`button`,className:`dropdown-item`,onClick:n,children:t},e.key)}),I===`button`?(D||E)&&/* @__PURE__ */ A(`div`,{className:`wui-usermenu-foot`,children:D?/* @__PURE__ */ A(`form`,{method:`post`,action:D,className:`wui-usermenu-logout`,children:/* @__PURE__ */ A(m,{type:`submit`,tone:`danger`,variant:`soft`,block:!0,leftIcon:V,children:O})}):/* @__PURE__ */ A(m,{type:`button`,tone:`danger`,variant:`soft`,block:!0,leftIcon:V,onClick:()=>{z(),E?.()},children:O})}):D?/* @__PURE__ */ A(`form`,{method:`post`,action:D,className:`wui-usermenu-logout`,children:/* @__PURE__ */ A(`button`,{type:`submit`,className:`dropdown-item danger`,children:H})}):E&&/* @__PURE__ */ A(`button`,{type:`button`,className:`dropdown-item danger`,onClick:()=>{z(),E()},children:H})]})]})}function ye({config:e,unreadLabel:t,markAllReadLabel:n,viewAllLabel:r,loadingNotificationsText:i,noUnreadText:a,unreadNotificationsText:o,unreadBellLabel:s}){let c=u(`shell`,M),l=T(),{open:d,ref:f}=_e(e.onOpen),{unread:p=0,items:m,loading:g=!1,onMarkAllRead:_,viewAllHref:v,label:y=c.label,emptyText:b=c.emptyText}=e,[x,S]=O(``),C=D(p);w(()=>{C.current!==p&&(C.current=p,S(p===0?a:N(o,{count:G(p)})))},[p,a,o]);let E=null;return m?.length?E=/* @__PURE__ */ A(`div`,{className:`wui-bell-items`,children:m.map((e,n)=>{let r=`wui-bell-item${e.read?` wui-bell-item-read`:``}`,i=/* @__PURE__ */ j(k,{children:[/* @__PURE__ */ A(`span`,{className:`wui-bell-dot`,"aria-hidden":`true`}),e.icon&&/* @__PURE__ */ A(`span`,{className:`wui-bell-icon`,children:/* @__PURE__ */ A(h,{name:e.icon,size:18})}),/* @__PURE__ */ j(`span`,{className:`wui-bell-body`,children:[!e.read&&/* @__PURE__ */ j(`span`,{className:`visually-hidden`,children:[t,`: `]}),/* @__PURE__ */ A(`span`,{className:`wui-bell-item-title`,children:e.title}),e.time&&/* @__PURE__ */ A(`span`,{className:`wui-bell-when`,children:e.time})]})]});return e.href?/* @__PURE__ */ A(`a`,{className:r,href:e.href,"data-id":e.id,children:i},e.id??n):/* @__PURE__ */ A(`div`,{className:r,"data-id":e.id,children:i},e.id??n)})}):g?E=/* @__PURE__ */ A(`div`,{className:`wui-bell-state`,children:i}):m&&(E=/* @__PURE__ */ A(`div`,{className:`wui-bell-state`,children:b})),/* @__PURE__ */ j(`wui-dropdown`,{class:`dropdown wui-bell`,align:`end`,ref:f,children:[/* @__PURE__ */ j(`button`,{type:`button`,id:l,className:`topbar-icon-btn wui-bell-trigger`,"data-wui-dropdown-trigger":!0,"aria-expanded":d,"aria-label":p===0?y:N(s,{label:y,count:G(p)}),children:[/* @__PURE__ */ A(h,{name:`notification`,size:20}),/* @__PURE__ */ A(`span`,{className:`wui-bell-count`,"aria-hidden":`true`,hidden:p===0,children:G(p)})]}),/* @__PURE__ */ A(`span`,{className:`visually-hidden`,"aria-live":`polite`,children:x}),/* @__PURE__ */ j(`div`,{"data-wui-dropdown-menu":!0,popover:`auto`,className:`dropdown-menu dropdown-menu-end wui-bell-menu${d?` show`:``}`,"aria-labelledby":l,children:[/* @__PURE__ */ j(`div`,{className:`wui-bell-head`,children:[/* @__PURE__ */ A(`span`,{className:`wui-bell-title`,children:y}),_&&/* @__PURE__ */ A(`button`,{type:`button`,className:`wui-bell-markall`,onClick:_,children:n})]}),/* @__PURE__ */ A(`div`,{className:`wui-bell-list`,"aria-busy":g||void 0,children:E}),v&&/* @__PURE__ */ A(`a`,{className:`wui-bell-foot`,href:v,children:r})]})]})}var be=e=>!!e&&(e.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(e.tagName));function xe({config:e,searchResultsLabel:t,noResultsText:n,noResultsForText:r,resultsCountText:i,resultCountText:a,moreLabel:o}){l(`wui-overflow`,P);let s=u(`shell`,M),c=T(),{value:d=``,onChange:f,results:p=null,loading:m=!1,onSelect:g,onSubmit:_,onFocus:v,placeholder:y=s.placeholder}=e,[b,S]=O(!1),[C,k]=O(!1),[F,I]=O({results:null,index:-1}),L=F.results===p?F.index:-1,R=e=>I({results:p,index:e}),z=D(null),B=D(null),V=D([]),H=E(()=>(p??[]).flatMap(e=>e.hits??[]),[p]),U=p!=null&&!C,W=H.length;w(()=>{let e=e=>{e.key!==`/`||e.ctrlKey||e.metaKey||e.altKey||be(e.target instanceof HTMLElement?e.target:null)||(e.preventDefault(),S(!0),B.current?.focus())},t=e=>{z.current?.contains(e.target instanceof Node?e.target:null)||(k(!0),S(!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(!U||W===0)return;e.preventDefault(),R((L+(e.key===`ArrowDown`?1:-1)+W)%W)}else x(e.nativeEvent)?U&&L>=0&&V.current[L]?(e.preventDefault(),V.current[L].click()):_&&d.trim()!==``&&(e.preventDefault(),_(d.trim())):e.key===`Escape`&&(U?(e.preventDefault(),k(!0)):b&&(e.preventDefault(),S(!1)))},te=-1;return V.current=[],/* @__PURE__ */ A(`wui-overflow`,{class:`wui-topsearch-host`,label:o,children:/* @__PURE__ */ A(`div`,{"data-wui-overflow-list":!0,className:`wui-topsearch-row`,children:/* @__PURE__ */ j(`div`,{className:`wui-topsearch${b?` is-open`:``}${m?` is-loading`:``}`,ref:z,"data-overflow-label":y,children:[/* @__PURE__ */ A(`button`,{type:`button`,className:`topbar-icon-btn wui-topsearch-open`,"aria-label":y,"aria-expanded":b,"aria-controls":`${c}-panel`,onClick:()=>{let e=!b;S(e),e&&B.current?.focus()},children:/* @__PURE__ */ A(h,{name:`search`,size:20})}),/* @__PURE__ */ j(`div`,{className:`wui-topsearch-panel`,id:`${c}-panel`,children:[/* @__PURE__ */ j(`div`,{className:`search-wrap`,children:[/* @__PURE__ */ A(h,{name:`search`,size:18,className:`search-icon`}),/* @__PURE__ */ A(`input`,{ref:B,type:`search`,className:`form-control input search-input`,id:`${c}-input`,placeholder:y,"aria-label":y,role:`combobox`,"aria-autocomplete":`list`,"aria-expanded":U,"aria-controls":`${c}-list`,"aria-activedescendant":U&&L>=0?`${c}-opt-${L}`:void 0,autoComplete:`off`,value:d,onChange:e=>{k(!1),f?.(e.target.value)},onKeyDown:ee,onFocus:v})]}),/* @__PURE__ */ A(`div`,{className:`wui-topsearch-results`,id:`${c}-list`,role:`listbox`,"aria-label":t,hidden:!U,children:U&&/* @__PURE__ */ j(`div`,{className:`wui-topsearch-groups`,role:`presentation`,children:[W===0&&/* @__PURE__ */ A(`div`,{className:`wui-topsearch-empty`,role:`option`,"aria-disabled":`true`,"aria-selected":`false`,children:N(r,{value:d})}),p.filter(e=>e.hits?.length).map((e,t)=>/* @__PURE__ */ j(`div`,{className:`wui-topsearch-group`,role:`group`,"aria-label":e.label??``,children:[e.label&&/* @__PURE__ */ A(`div`,{className:`wui-topsearch-group-label`,role:`presentation`,children:e.label}),e.hits.map(e=>{te+=1;let t=te;return/* @__PURE__ */ j(`a`,{className:`wui-topsearch-hit${t===L?` is-active`:``}`,role:`option`,"aria-selected":t===L,id:`${c}-opt-${t}`,href:e.href,ref:e=>{V.current[t]=e},onClick:t=>g?.(e,t),children:[e.icon&&/* @__PURE__ */ A(`span`,{className:`wui-topsearch-hit-icon`,children:/* @__PURE__ */ A(h,{name:e.icon,size:18})}),/* @__PURE__ */ j(`span`,{className:`wui-topsearch-hit-text`,children:[/* @__PURE__ */ A(`span`,{className:`wui-topsearch-hit-title`,children:e.title}),e.subtitle&&/* @__PURE__ */ A(`span`,{className:`wui-topsearch-hit-sub`,children:e.subtitle})]})]},`${e.href}-${t}`)})]},e.label??t))]})})]}),/* @__PURE__ */ A(`span`,{className:`visually-hidden`,"aria-live":`polite`,children:U?W===0?n:N(W===1?a:i,{count:W}):``})]})})})}export{q as default};
1
+ import{devWarn as e}from"../lib/devWarn.js";import{linkTarget as t}from"../lib/linkTarget.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{TargetLink as c}from"../lib/TargetLink.js";import l from"../lib/useElementEntry.js";import u from"../lib/useWuiText.js";import{TONES as d}from"../lib/vocabulary.js";import{splitMarkerProps as f}from"../lib/wuiMarker.js";import p from"./AppAvatar.js";import m from"./AppButton.js";import h from"./AppIcon.js";import g from"./AppNavigationMenu.js";import _ from"./assertValidValue.js";import v from"./warnUnknownProps.js";import{IST_TIME_ZONE as y,initScrollEdges as b,isImeSafeEnter as x,revealActiveNavItem as S,setPopoverOpen as C}from"@webority/ui-elements/helpers";import{useEffect as w,useId as T,useMemo as E,useRef as D,useState as O}from"react";import{Fragment as k,jsx as A,jsxs as j}from"react/jsx-runtime";import{SHELL_TEXT as M,fillText as N}from"@webority/ui-elements/text";var P=()=>import(`@webority/ui-elements/elements/overflow`),F=()=>import(`@webority/ui-elements/elements/dropdown`),I=99,L=4,R=5,z=/^[a-z0-9-]+$/,B=`wui-sidebar-footer`,V=[],H=[`prefix`,`exact`],U=[`comfortable`,`compact`],W=[`neutral`,`primary`],ee=[`default`,`brand`],te=[`side`,`top`],ne=[`linear`,`outline`,`bold`,`bulk`,`broken`,`twotone`],re=/* @__PURE__ */ new Set([`key`,`label`,`icon`,`iconVariant`,`iconSize`,`href`,`badge`,`badgeTone`,`badgeTitle`,`newUntil`,`trailingIcon`,`active`,`match`,`matchAlso`,`tab`,`tabLabel`,`children`,`header`,`description`]),G=e=>e>I?`${I}+`:String(e),K=new Intl.DateTimeFormat(`en-CA`,{timeZone:y}),ie=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:K.format(/* @__PURE__ */ new Date)<=e},ae=({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(` `)},oe=({logoLight:e,logoDark:t,markLight:n,markDark:r,brandName:i})=>{let a=i??``,o=[e&&/* @__PURE__ */ A(`img`,{className:`wui-brand-logo wui-brand-light`,src:e,alt:a},`logo-light`),t&&/* @__PURE__ */ A(`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(e=>!!e).map(([t,n,r],i)=>i===0&&!e?/* @__PURE__ */ A(`img`,{className:n,src:r,alt:a},t):/* @__PURE__ */ A(`img`,{className:n,src:r,alt:``,"aria-hidden":`true`},t));return[...o,...s].filter(Boolean)};function q(e){let{marker:t,props:n}=f(`AppShell`,e),c=u(`shell`,M),{groups:l=[],brand:d,logoLight:p,logoDark:m,markLight:y,markDark:x,brandName:T,brandHref:N,brandLabel:P,sidebarStart:F,sidebarStartCompact:I,sidebarFooter:L,sidebarFooterItems:R=V,topbarStart:z,topbarEnd:B,footer:H,launcher:re,children:G,collapsed:K,onCollapsedChange:ie,noSidebar:q=!1,nav:J=`side`,topNavDetail:Y=!1,capBadges:ce=!1,density:le=`comfortable`,itemHeight:ue,iconVariant:X=`twotone`,topbarTone:_e=`neutral`,tone:be=`default`,navLabel:Se=c.navLabel,linkComponent:Z,currentPath:Ce,rememberCollapsed:we=!1,collapsedCookie:Te=`wui-shell-collapsed`,foldedCookie:Ee=r,tabBarLabel:De=c.tabBarLabel,moreLabel:Oe=c.moreLabel,skipLabel:ke=c.skipLabel,openNavLabel:Ae=c.openNavLabel,expandNavLabel:je=c.expandNavLabel,collapseNavLabel:Me=c.collapseNavLabel,newLabel:Ne=c.newLabel,togglePagesLabel:Pe=c.togglePagesLabel,accountMenuLabel:Fe=c.accountMenuLabel,roleLabel:Ie=c.roleLabel,rolesLabel:Le=c.rolesLabel,unreadLabel:Re=c.unreadLabel,markAllReadLabel:ze=c.markAllReadLabel,viewAllLabel:Be=c.viewAllLabel,loadingNotificationsText:Ve=c.loadingNotificationsText,noUnreadText:He=c.noUnreadText,unreadNotificationsText:Ue=c.unreadNotificationsText,unreadBellLabel:We=c.unreadBellLabel,searchResultsLabel:Ge=c.searchResultsLabel,noResultsText:Ke=c.noResultsText,noResultsForText:qe=c.noResultsForText,resultsCountText:Je=c.resultsCountText,resultCountText:Ye=c.resultCountText,userMenu:Xe,notifications:Ze,search:Qe,className:$e=``,style:et,...tt}=n;if(v(`AppShell`,tt),_(`AppShell`,`density`,le,U),_(`AppShell`,`topbarTone`,_e,W),_(`AppShell`,`tone`,be,ee),_(`AppShell`,`nav`,J,te),_(`AppShell`,`iconVariant`,X,ne),P!==void 0&&!N)throw Error(`<AppShell> brandLabel names the brand link, so it needs brandHref.`);if(N){if(!P&&!T)throw Error(`<AppShell> brandHref needs brandLabel or brandName: the collapsed rail hides the logo, so the link would have no accessible name.`);if(!(d||p||m||y||x))throw Error(`<AppShell> brandHref has no brand, logo or mark to link.`)}let nt=(ue??0)>0?{...et,"--wui-nav-item-height":`${ue}px`}:et,[rt,it]=O(()=>we&&K===void 0&&typeof document<`u`?a(Te)??!1:!1),[at,Q]=O(!1),ot=D(null),[st,ct]=O(!1),[lt,ut]=O(!1),dt=D(null),ft=K??rt,pt=e=>N?/* @__PURE__ */ A(pe,{href:N,label:P||T,linkComponent:Z,onNavigate:()=>Q(!1),children:e}):e,mt=()=>{let e=!ft;K===void 0&&it(e),we&&s(e,Te),ie?.(e)},ht=l.some(e=>e.collapsible),[gt,_t]=O(()=>ht&&typeof document<`u`?i(Ee):/* @__PURE__ */ new Set),vt=e=>{let t=new Set(gt);t.has(e)?t.delete(e):t.add(e),_t(t),o(t,Ee)},yt=E(()=>se(l,R,Ce),[l,R,Ce]),$=yt.groups,bt=yt.footer,xt=q?null:de($,bt.some(e=>e.active));w(()=>{let e=()=>ct(window.scrollY>4);return e(),window.addEventListener(`scroll`,e,{passive:!0}),()=>window.removeEventListener(`scroll`,e)},[]),w(()=>{b()},[]),w(()=>{S(dt.current)},[]),w(()=>{let e=dt.current;if(!e)return;let t=()=>ut($.length>0&&e.scrollHeight>e.clientHeight);if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[$]),w(()=>{let e=ot.current;if(!e)return;let t=window.matchMedia(`(max-width: 991.98px)`),n=()=>{t.matches?e.setAttribute(`popover`,`auto`):(e.removeAttribute(`popover`),Q(!1))},r=e=>Q(`newState`in e&&e.newState===`open`);return n(),t.addEventListener(`change`,n),e.addEventListener(`toggle`,r),()=>{t.removeEventListener(`change`,n),e.removeEventListener(`toggle`,r)}},[]),w(()=>{let e=ot.current;e?.hasAttribute(`popover`)&&C(e,at)},[at]);let St=[`app-shell`,ft?`collapsed`:``,q?`no-sidebar`:``,J===`top`?`wui-shell-top`:``,at?`mobile-open`:``,$e].filter(Boolean).join(` `);return/* @__PURE__ */ j(`div`,{className:St,"data-density":le===`compact`?`compact`:void 0,"data-shell-tone":be===`brand`?`brand`:void 0,"data-wui-folded-cookie":ht?Ee:void 0,style:nt,...t,...tt,children:[/* @__PURE__ */ A(`a`,{className:`wui-skip-link`,href:`#main-content`,children:ke}),/* @__PURE__ */ j(`aside`,{className:`app-sidebar`,ref:ot,children:[(d||p||m||y||x)&&/* @__PURE__ */ A(`div`,{className:ae({logoLight:p,logoDark:m,markLight:y,markDark:x}),children:pt(/* @__PURE__ */ j(k,{children:[oe({logoLight:p,logoDark:m,markLight:y,markDark:x,brandName:T}),d]}))}),F&&/* @__PURE__ */ A(`div`,{className:`app-sidebar-start`,children:F}),I&&/* @__PURE__ */ A(`div`,{className:`app-sidebar-start-compact`,children:I}),/* @__PURE__ */ A(`nav`,{className:`app-sidebar-scroll`,"aria-label":Se,ref:dt,tabIndex:lt?0:void 0,children:$.map((e,t)=>{let n=e.items.map(e=>e.header==null?/* @__PURE__ */ A(ge,{item:e,linkComponent:Z,onNavigate:()=>Q(!1),iconVariant:X,newLabel:Ne,togglePagesLabel:Pe,capBadges:ce},e.key??e.href??e.label):/* @__PURE__ */ A(`div`,{className:`wui-nav-header`,children:e.header},e.key??e.header));if(!e.collapsible)return/* @__PURE__ */ j(`div`,{className:`app-nav-group`,children:[e.label&&/* @__PURE__ */ A(`div`,{className:`app-nav-group-label`,children:e.label}),n,e.after&&/* @__PURE__ */ A(`div`,{className:`wui-nav-group-after`,children:e.after})]},e.key??e.label??`group-${t}`);let r=!gt.has(e.key??``)||!!he(e.items),i=`wui-nav-group-${e.key}`;return/* @__PURE__ */ j(`div`,{className:`app-nav-group wui-nav-group-collapsible${r?``:` wui-nav-group-folded`}`,"data-wui-nav-group":e.key,children:[/* @__PURE__ */ j(`button`,{type:`button`,className:`app-nav-group-label wui-nav-group-toggle`,"aria-expanded":r,"aria-controls":i,onClick:()=>vt(e.key??``),children:[/* @__PURE__ */ A(`span`,{className:`wui-nav-group-text`,children:e.label}),/* @__PURE__ */ A(`span`,{className:`wui-nav-group-caret`,children:/* @__PURE__ */ A(h,{name:`chevron-down`,size:16})})]}),/* @__PURE__ */ j(`div`,{className:`wui-nav-group-body`,id:i,children:[n,e.after&&/* @__PURE__ */ A(`div`,{className:`wui-nav-group-after`,children:e.after})]})]},e.key??`group-${t}`)})}),(L||bt.length>0)&&/* @__PURE__ */ j(`div`,{className:`app-sidebar-foot`,children:[bt.length>0&&/* @__PURE__ */ A(`div`,{className:`wui-sidebar-foot-links`,children:bt.map(e=>/* @__PURE__ */ A(ge,{item:e,linkComponent:Z,onNavigate:()=>Q(!1),iconVariant:X,newLabel:Ne,togglePagesLabel:Pe,capBadges:ce},e.key??e.href??e.label))}),L]}),!q&&/* @__PURE__ */ A(`button`,{type:`button`,className:`app-sidebar-toggle`,onClick:mt,"aria-label":ft?je:Me,"aria-expanded":!ft,children:/* @__PURE__ */ A(h,{name:`chevrons-left`,size:20})})]}),/* @__PURE__ */ j(`div`,{className:`app-main`,children:[/* @__PURE__ */ j(`header`,{className:`app-topbar${st?` wui-scrolled`:``}`,"data-tone":_e===`primary`?`primary`:void 0,children:[/* @__PURE__ */ j(`div`,{className:`app-topbar-start`,children:[/* @__PURE__ */ A(`button`,{type:`button`,className:`app-topbar-menu`,onClick:()=>Q(!0),"aria-label":Ae,"aria-expanded":at,children:/* @__PURE__ */ A(h,{name:`menu`,size:18})}),J===`top`&&d&&/* @__PURE__ */ A(`div`,{className:`wui-shell-top-brand`,children:pt(d)}),J===`top`&&/* @__PURE__ */ A(`div`,{className:`wui-shell-top-nav`,children:/* @__PURE__ */ A(g,{items:fe($,Y),ariaLabel:Se,linkComponent:Z})}),z,Qe&&/* @__PURE__ */ A(xe,{config:Qe,searchResultsLabel:Ge,noResultsText:Ke,noResultsForText:qe,resultsCountText:Je,resultCountText:Ye,moreLabel:Oe})]}),/* @__PURE__ */ j(`div`,{className:`app-topbar-end`,children:[B,Ze&&/* @__PURE__ */ A(ye,{config:Ze,unreadLabel:Re,markAllReadLabel:ze,viewAllLabel:Be,loadingNotificationsText:Ve,noUnreadText:He,unreadNotificationsText:Ue,unreadBellLabel:We}),Xe&&/* @__PURE__ */ A(ve,{config:Xe,linkComponent:Z,accountMenuLabel:Fe,roleLabel:Ie,rolesLabel:Le})]})]}),/* @__PURE__ */ A(`main`,{className:`app-content`,id:`main-content`,children:G}),H&&/* @__PURE__ */ A(`footer`,{className:`app-footer`,children:H})]}),re&&/* @__PURE__ */ A(`div`,{className:`wui-shell-launcher`,children:re}),xt&&/* @__PURE__ */ j(`nav`,{className:`wui-tabbar`,"aria-label":De,children:[xt.tabs.map(e=>/* @__PURE__ */ A(me,{tab:e,linkComponent:Z,iconVariant:X,capBadges:ce},e.key??e.href)),xt.hasMore&&/* @__PURE__ */ j(`button`,{type:`button`,className:`wui-tabbar-item${xt.moreActive?` active`:``}`,onClick:()=>Q(!0),children:[/* @__PURE__ */ A(`span`,{className:`wui-tabbar-icon`,children:/* @__PURE__ */ A(h,{name:`more`,size:24})}),/* @__PURE__ */ A(`span`,{className:`wui-tabbar-label`,children:Oe})]})]})]})}function se(e,t,r){let i=t;for(let e of i){if(e.children?.length)throw Error(`<AppShell> sidebarFooterItems cannot hold children; keep footer links flat.`);if(e.tab)throw Error(`<AppShell> sidebarFooterItems cannot carry tab: true; the phone tab bar is built from groups.`);if(e.header!=null)throw Error(`<AppShell> sidebarFooterItems cannot hold a header row.`)}for(let t of e)t.collapsible&&ue(t);let a=(e,t=!1)=>(e??[]).map(e=>Array.isArray(e.children)?{...e,children:a(e.children)}:{...e}).filter(e=>Y(e)?t:(e.children?.length??0)>0||!!e.href),o=[...e,{key:B,items:t}].map(e=>({...e,items:ce(a(e.items,!0))})).filter(e=>e.items.some(e=>!Y(e))),s=[],c=e=>{for(let t of e)Y(t)||(s.push(t),t.children&&c(t.children))};for(let e of o)c(e.items);for(let e of s)v(`AppShell items`,J(e)),_(`AppShell`,`match`,e.match,H),_(`AppShell`,`iconVariant`,e.iconVariant,ne),_(`AppShell`,`badgeTone`,e.badgeTone,d);let l=null;if(r!=null&&!s.some(e=>e.active===!0)){let e=-1;for(let t of s){if(t.active!=null||t.children?.length&&!t.href)continue;let i=n(r,t.href,{exact:t.match===`exact`,also:t.matchAlso});if(i<0)continue;let a=t.match===`exact`&&n(r,t.href,{exact:!0})>=0?1/0:i;a>e&&(e=a,l=t)}}for(let e of s)e.active=e.active??e===l;return{groups:o.filter(e=>e.key!==B),footer:o.find(e=>e.key===B)?.items??[]}}function J(e){return Object.fromEntries(Object.entries(e).filter(([e])=>!re.has(e)))}var Y=e=>e.header!=null;function ce(e){return e.filter((t,n)=>{if(!Y(t))return!0;let r=e.findIndex((e,t)=>t>n&&Y(e));return e.slice(n+1,r<0?void 0:r).length>0})}var le=/* @__PURE__ */ new Set;function ue(t){if(t.key!=null&&z.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.`;typeof process<`u`&&process.env.NODE_ENV===`production`||le.has(n)||(le.add(n),e(n))}function de(e,t){let n=[],r=e=>{for(let t of e)Y(t)||(t.children?.length?r(t.children):n.push(t))};for(let t of e)r(t.items);let i=n.filter(e=>e.tab);if(i.length===0)return null;let a=i.length<n.length,o=a?L:R;if(i.length>o)throw Error(`<AppShell>: ${i.length} items carry tab: true, but the phone tab bar holds ${o} (${a?`4 plus More, because other items exist`:`5 when every item is a tab`}). Flag fewer items.`);return{tabs:i,hasMore:a,moreActive:t||n.some(e=>!e.tab&&e.active)}}function fe(e,t){let n=e=>{if(e.label===void 0)throw Error(`<AppShell> a navigation row has no label; every row but a header needs one.`);return e.label},r=e=>e.key??e.href??n(e),i=(e,i)=>({key:r(e),label:n(e),to:i,current:!!e.active,...t&&e.description?{description:e.description}:{}}),a=e=>e.flatMap(e=>Y(e)?[]:[...e.href?[{...i(e,e.href),icon:e.icon}]:[],...a(e.children??[])]),o=[];for(let s of e)for(let e of s.items){if(Y(e))continue;let c=t&&s.label?{group:s.label}:{},l=a(e.children??[]);if(l.length>0){let a=e.href?[{...i(e,e.href),icon:e.icon}]:[],s=t&&(!!e.active||!!he(e.children??[]));o.push({key:r(e),label:n(e),links:[...a,...l],...c,...t?{current:s}:{}})}else e.href&&o.push({...i(e,e.href),...c})}return o}function X(e,t){return t&&typeof e==`number`&&e>I?`${I}+`:e}function pe({href:e,label:n,linkComponent:r,onNavigate:i,children:a}){return/* @__PURE__ */ A(c,{link:t(r,{to:e}),className:`wui-brand-link`,"aria-label":n,onClick:i,children:a})}function me({tab:e,linkComponent:n,iconVariant:r,capBadges:i}){let a=`wui-tabbar-item${e.active?` active`:``}`,o=/* @__PURE__ */ j(k,{children:[e.icon&&/* @__PURE__ */ A(`span`,{className:`wui-tabbar-icon`,children:typeof e.icon==`string`?/* @__PURE__ */ A(h,{name:e.icon,size:24,variant:e.iconVariant??r}):e.icon}),/* @__PURE__ */ A(`span`,{className:`wui-tabbar-label`,children:e.tabLabel??e.label}),e.badge!=null&&/* @__PURE__ */ A(`span`,{className:`wui-tabbar-badge${e.badgeTone?` tone-${e.badgeTone}`:``}`,title:e.badgeTitle||void 0,children:X(e.badge,i)})]}),s=e.active?`page`:void 0;return/* @__PURE__ */ A(c,{link:t(n,{to:e.href}),className:a,"aria-current":s,children:o})}function he(e){for(let t of e){if(t.active)return t;let e=t.children?.length?he(t.children):void 0;if(e)return e}}function ge({item:e,linkComponent:n,onNavigate:r,depth:i=0,iconVariant:a,newLabel:o,togglePagesLabel:s,capBadges:l}){let u=i>0,d=i>1?` wui-nav-depth-${Math.min(i,6)}`:``,f=Array.isArray(e.children)&&e.children.length>0,p=f?he(e.children??[]):void 0,m=!!p,g=p?p.key??p.href??p.label:null,[_,v]=O(m);w(()=>{g!=null&&v(!0)},[g]);let y=typeof e.label==`string`?e.label:void 0,b=!u&&e.icon&&/* @__PURE__ */ A(`span`,{className:`app-nav-icon`,children:typeof e.icon==`string`?/* @__PURE__ */ A(h,{name:e.icon,size:e.iconSize??22,variant:e.iconVariant??a}):e.icon}),x=e.badge!=null&&/* @__PURE__ */ A(`span`,{className:`app-nav-badge${e.badgeTone?` tone-${e.badgeTone}`:``}`,title:e.badgeTitle||void 0,children:X(e.badge,l)}),S=ie(e.newUntil)&&/* @__PURE__ */ A(`span`,{className:`wui-nav-new`,children:o}),C=/* @__PURE__ */ j(k,{children:[b,/* @__PURE__ */ A(`span`,{className:`app-nav-text`,children:e.label}),S,x,e.trailingIcon&&/* @__PURE__ */ A(`span`,{className:`app-nav-trailing`,children:typeof e.trailingIcon==`string`?/* @__PURE__ */ A(h,{name:e.trailingIcon,size:16}):e.trailingIcon})]}),T=e.active?`page`:void 0;if(f){let f=/* @__PURE__ */ A(`div`,{className:`app-nav-sub${_?` expanded`:``}`,inert:!_,"aria-hidden":!_||void 0,children:/* @__PURE__ */ A(`div`,{className:`app-nav-sub-inner`,children:(e.children??[]).map(e=>/* @__PURE__ */ A(ge,{item:e,linkComponent:n,onNavigate:r,depth:i+1,iconVariant:a,newLabel:o,togglePagesLabel:s,capBadges:l},e.key??e.href))})});if(e.href){let i=/* @__PURE__ */ A(c,{link:t(n,{to:e.href}),className:`wui-nav-split-link`,"aria-current":T,onClick:r,children:C});return/* @__PURE__ */ j(k,{children:[/* @__PURE__ */ j(`div`,{className:`app-nav-item has-children wui-nav-split${u?` app-nav-subitem`:``}${m||e.active?` active`:``}${d}`,"data-label":y,children:[i,/* @__PURE__ */ A(`button`,{type:`button`,className:`app-nav-caret wui-nav-split-toggle`,"aria-expanded":_,"aria-label":N(s,{name:y??``}),onClick:()=>v(e=>!e),children:/* @__PURE__ */ A(h,{name:`chevron-right`,size:16})})]}),f]})}return/* @__PURE__ */ j(k,{children:[/* @__PURE__ */ j(`button`,{type:`button`,className:`app-nav-item${u?` app-nav-subitem`:``} has-children${m?` active`:``}${d}`,"aria-expanded":_,"data-label":y,onClick:()=>v(e=>!e),children:[b,/* @__PURE__ */ A(`span`,{className:`app-nav-text`,children:e.label}),S,x,/* @__PURE__ */ A(`span`,{className:`app-nav-caret`,children:/* @__PURE__ */ A(h,{name:`chevron-right`,size:16})})]}),f]})}let E=`app-nav-item${u?` app-nav-subitem`:``}${e.active?` active`:``}${d}`;return/* @__PURE__ */ A(c,{link:t(n,{to:e.href}),className:E,"aria-current":T,"data-label":y,onClick:r,children:C})}function _e(e){l(`wui-dropdown`,F);let[t,n]=O(!1),r=D(null);return w(()=>{r.current?.toggleAttribute(`open`,t)},[t]),w(()=>{let t=r.current;if(!t)return;let i=r=>{if(r.target!==t||!(`detail`in r)||!r.detail||typeof r.detail!=`object`)return;let i=`open`in r.detail&&r.detail.open===!0;n(i),i&&e?.()};return t.addEventListener(`wui-dropdown-toggle`,i),()=>t.removeEventListener(`wui-dropdown-toggle`,i)},[e]),{open:t,setOpen:n,ref:r}}function ve({config:e,linkComponent:n,accountMenuLabel:r,roleLabel:i,rolesLabel:a}){let o=u(`shell`,M),s=T(),{open:l,setOpen:d,ref:f}=_e(),{name:g,role:v,roles:y=[],noTriggerRole:b=!1,outlined:x=!1,photo:S,profileHref:C,profileLabel:w=o.profileLabel,onLogout:E,logoutAction:D,logoutLabel:O=o.logoutLabel,head:P,section:F,logoutVariant:I=`item`,items:L=[]}=e;if(_(`AppShell`,`userMenu.logoutVariant`,I,[`item`,`button`]),!g)throw Error(`<AppShell> userMenu.name is required; the trigger and the avatar are named from it.`);let R=y.map(e=>(e??``).trim()).filter(Boolean),z=()=>d(!1),B=(e,r,i,a)=>/* @__PURE__ */ A(c,{link:t(n,{to:e}),className:`dropdown-item`,onClick:a,children:r},i),V=/* @__PURE__ */ A(h,{name:`log-out`,size:18}),H=/* @__PURE__ */ j(k,{children:[V,O]});return/* @__PURE__ */ j(`wui-dropdown`,{class:`dropdown wui-usermenu`,align:`end`,ref:f,children:[/* @__PURE__ */ j(`button`,{type:`button`,id:s,className:x?`wui-usermenu-trigger wui-usermenu-trigger-outlined`:`wui-usermenu-trigger`,"data-wui-dropdown-trigger":!0,"aria-expanded":l,"aria-label":N(r,{name:g}),children:[/* @__PURE__ */ A(p,{name:g,src:S,tone:`auto`}),/* @__PURE__ */ j(`span`,{className:`wui-usermenu-text`,children:[/* @__PURE__ */ A(`span`,{className:`wui-usermenu-name`,children:g}),v&&!b&&/* @__PURE__ */ A(`span`,{className:`wui-usermenu-role`,children:v})]}),/* @__PURE__ */ A(h,{name:`chevron-down`,size:14,className:`wui-usermenu-caret`})]}),/* @__PURE__ */ j(`div`,{"data-wui-dropdown-menu":!0,popover:`auto`,className:`dropdown-menu dropdown-menu-end wui-usermenu-menu${l?` show`:``}`,"aria-labelledby":s,children:[/* @__PURE__ */ j(`div`,{className:`wui-usermenu-head`,children:[/* @__PURE__ */ A(p,{name:g,src:S,size:`lg`,tone:`auto`}),/* @__PURE__ */ j(`div`,{className:`wui-usermenu-who`,children:[/* @__PURE__ */ A(`div`,{className:`wui-usermenu-name`,children:g}),v&&/* @__PURE__ */ A(`div`,{className:`wui-usermenu-role`,children:v}),R.length>0&&/* @__PURE__ */ j(`div`,{className:`wui-usermenu-roles`,children:[/* @__PURE__ */ A(`span`,{className:`wui-usermenu-roles-label`,children:R.length===1?i:a}),` ${R.join(`, `)}`]}),P?/* @__PURE__ */ A(`div`,{className:`wui-usermenu-extra`,children:P}):null]})]}),F?/* @__PURE__ */ A(`div`,{className:`wui-usermenu-section`,children:F}):null,C&&B(C,/* @__PURE__ */ j(k,{children:[/* @__PURE__ */ A(h,{name:`user`,size:18}),w]}),void 0,z),L.map(e=>{if(e.divider)return/* @__PURE__ */ A(`hr`,{className:`dropdown-divider`},e.key);let t=/* @__PURE__ */ j(k,{children:[e.icon&&/* @__PURE__ */ A(h,{name:e.icon,size:18}),e.label]}),n=()=>{e.onClick?.(),z()};return e.href?B(e.href,t,e.key,n):/* @__PURE__ */ A(`button`,{type:`button`,className:`dropdown-item`,onClick:n,children:t},e.key)}),I===`button`?(D||E)&&/* @__PURE__ */ A(`div`,{className:`wui-usermenu-foot`,children:D?/* @__PURE__ */ A(`form`,{method:`post`,action:D,className:`wui-usermenu-logout`,children:/* @__PURE__ */ A(m,{type:`submit`,tone:`danger`,variant:`soft`,block:!0,leftIcon:V,children:O})}):/* @__PURE__ */ A(m,{type:`button`,tone:`danger`,variant:`soft`,block:!0,leftIcon:V,onClick:()=>{z(),E?.()},children:O})}):D?/* @__PURE__ */ A(`form`,{method:`post`,action:D,className:`wui-usermenu-logout`,children:/* @__PURE__ */ A(`button`,{type:`submit`,className:`dropdown-item danger`,children:H})}):E&&/* @__PURE__ */ A(`button`,{type:`button`,className:`dropdown-item danger`,onClick:()=>{z(),E()},children:H})]})]})}function ye({config:e,unreadLabel:t,markAllReadLabel:n,viewAllLabel:r,loadingNotificationsText:i,noUnreadText:a,unreadNotificationsText:o,unreadBellLabel:s}){let c=u(`shell`,M),l=T(),{open:d,ref:f}=_e(e.onOpen),{unread:p=0,items:m,loading:g=!1,onMarkAllRead:_,viewAllHref:v,label:y=c.label,emptyText:b=c.emptyText}=e,[x,S]=O(``),C=D(p);w(()=>{C.current!==p&&(C.current=p,S(p===0?a:N(o,{count:G(p)})))},[p,a,o]);let E=null;return m?.length?E=/* @__PURE__ */ A(`div`,{className:`wui-bell-items`,children:m.map((e,n)=>{let r=`wui-bell-item${e.read?` wui-bell-item-read`:``}`,i=/* @__PURE__ */ j(k,{children:[/* @__PURE__ */ A(`span`,{className:`wui-bell-dot`,"aria-hidden":`true`}),e.icon&&/* @__PURE__ */ A(`span`,{className:`wui-bell-icon`,children:/* @__PURE__ */ A(h,{name:e.icon,size:18})}),/* @__PURE__ */ j(`span`,{className:`wui-bell-body`,children:[!e.read&&/* @__PURE__ */ j(`span`,{className:`visually-hidden`,children:[t,`: `]}),/* @__PURE__ */ A(`span`,{className:`wui-bell-item-title`,children:e.title}),e.time&&/* @__PURE__ */ A(`span`,{className:`wui-bell-when`,children:e.time})]})]});return e.href?/* @__PURE__ */ A(`a`,{className:r,href:e.href,"data-id":e.id,children:i},e.id??n):/* @__PURE__ */ A(`div`,{className:r,"data-id":e.id,children:i},e.id??n)})}):g?E=/* @__PURE__ */ A(`div`,{className:`wui-bell-state`,children:i}):m&&(E=/* @__PURE__ */ A(`div`,{className:`wui-bell-state`,children:b})),/* @__PURE__ */ j(`wui-dropdown`,{class:`dropdown wui-bell`,align:`end`,ref:f,children:[/* @__PURE__ */ j(`button`,{type:`button`,id:l,className:`topbar-icon-btn wui-bell-trigger`,"data-wui-dropdown-trigger":!0,"aria-expanded":d,"aria-label":p===0?y:N(s,{label:y,count:G(p)}),children:[/* @__PURE__ */ A(h,{name:`notification`,size:20}),/* @__PURE__ */ A(`span`,{className:`wui-bell-count`,"aria-hidden":`true`,hidden:p===0,children:G(p)})]}),/* @__PURE__ */ A(`span`,{className:`visually-hidden`,"aria-live":`polite`,children:x}),/* @__PURE__ */ j(`div`,{"data-wui-dropdown-menu":!0,popover:`auto`,className:`dropdown-menu dropdown-menu-end wui-bell-menu${d?` show`:``}`,"aria-labelledby":l,children:[/* @__PURE__ */ j(`div`,{className:`wui-bell-head`,children:[/* @__PURE__ */ A(`span`,{className:`wui-bell-title`,children:y}),_&&/* @__PURE__ */ A(`button`,{type:`button`,className:`wui-bell-markall`,onClick:_,children:n})]}),/* @__PURE__ */ A(`div`,{className:`wui-bell-list`,"aria-busy":g||void 0,children:E}),v&&/* @__PURE__ */ A(`a`,{className:`wui-bell-foot`,href:v,children:r})]})]})}var be=e=>!!e&&(e.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(e.tagName));function xe({config:e,searchResultsLabel:t,noResultsText:n,noResultsForText:r,resultsCountText:i,resultCountText:a,moreLabel:o}){l(`wui-overflow`,P);let s=u(`shell`,M),c=T(),{value:d=``,onChange:f,results:p=null,loading:m=!1,onSelect:g,onSubmit:_,onFocus:v,placeholder:y=s.placeholder}=e,[b,S]=O(!1),[C,k]=O(!1),[F,I]=O({results:null,index:-1}),L=F.results===p?F.index:-1,R=e=>I({results:p,index:e}),z=D(null),B=D(null),V=D([]),H=E(()=>(p??[]).flatMap(e=>e.hits??[]),[p]),U=p!=null&&!C,W=H.length;w(()=>{let e=e=>{e.key!==`/`||e.ctrlKey||e.metaKey||e.altKey||be(e.target instanceof HTMLElement?e.target:null)||(e.preventDefault(),S(!0),B.current?.focus())},t=e=>{z.current?.contains(e.target instanceof Node?e.target:null)||(k(!0),S(!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(!U||W===0)return;e.preventDefault(),R((L+(e.key===`ArrowDown`?1:-1)+W)%W)}else x(e.nativeEvent)?U&&L>=0&&V.current[L]?(e.preventDefault(),V.current[L].click()):_&&d.trim()!==``&&(e.preventDefault(),_(d.trim())):e.key===`Escape`&&(U?(e.preventDefault(),k(!0)):b&&(e.preventDefault(),S(!1)))},te=-1;return V.current=[],/* @__PURE__ */ A(`wui-overflow`,{class:`wui-topsearch-host`,label:o,children:/* @__PURE__ */ A(`div`,{"data-wui-overflow-list":!0,className:`wui-topsearch-row`,children:/* @__PURE__ */ j(`div`,{className:`wui-topsearch${b?` is-open`:``}${m?` is-loading`:``}`,ref:z,"data-overflow-label":y,children:[/* @__PURE__ */ A(`button`,{type:`button`,className:`topbar-icon-btn wui-topsearch-open`,"aria-label":y,"aria-expanded":b,"aria-controls":`${c}-panel`,onClick:()=>{let e=!b;S(e),e&&B.current?.focus()},children:/* @__PURE__ */ A(h,{name:`search`,size:20})}),/* @__PURE__ */ j(`div`,{className:`wui-topsearch-panel`,id:`${c}-panel`,children:[/* @__PURE__ */ j(`div`,{className:`search-wrap`,children:[/* @__PURE__ */ A(h,{name:`search`,size:18,className:`search-icon`}),/* @__PURE__ */ A(`input`,{ref:B,type:`search`,className:`form-control input search-input`,id:`${c}-input`,placeholder:y,"aria-label":y,role:`combobox`,"aria-autocomplete":`list`,"aria-expanded":U,"aria-controls":`${c}-list`,"aria-activedescendant":U&&L>=0?`${c}-opt-${L}`:void 0,autoComplete:`off`,value:d,onChange:e=>{k(!1),f?.(e.target.value)},onKeyDown:ee,onFocus:v})]}),/* @__PURE__ */ A(`div`,{className:`wui-topsearch-results`,id:`${c}-list`,role:`listbox`,"aria-label":t,hidden:!U,children:U&&/* @__PURE__ */ j(`div`,{className:`wui-topsearch-groups`,role:`presentation`,children:[W===0&&/* @__PURE__ */ A(`div`,{className:`wui-topsearch-empty`,role:`option`,"aria-disabled":`true`,"aria-selected":`false`,children:N(r,{value:d})}),p.filter(e=>e.hits?.length).map((e,t)=>/* @__PURE__ */ j(`div`,{className:`wui-topsearch-group`,role:`group`,"aria-label":e.label??``,children:[e.label&&/* @__PURE__ */ A(`div`,{className:`wui-topsearch-group-label`,role:`presentation`,children:e.label}),e.hits.map(e=>{te+=1;let t=te;return/* @__PURE__ */ j(`a`,{className:`wui-topsearch-hit${t===L?` is-active`:``}`,role:`option`,"aria-selected":t===L,id:`${c}-opt-${t}`,href:e.href,ref:e=>{V.current[t]=e},onClick:t=>g?.(e,t),children:[e.icon&&/* @__PURE__ */ A(`span`,{className:`wui-topsearch-hit-icon`,children:/* @__PURE__ */ A(h,{name:e.icon,size:18})}),/* @__PURE__ */ j(`span`,{className:`wui-topsearch-hit-text`,children:[/* @__PURE__ */ A(`span`,{className:`wui-topsearch-hit-title`,children:e.title}),e.subtitle&&/* @__PURE__ */ A(`span`,{className:`wui-topsearch-hit-sub`,children:e.subtitle})]})]},`${e.href}-${t}`)})]},e.label??t))]})})]}),/* @__PURE__ */ A(`span`,{className:`visually-hidden`,"aria-live":`polite`,children:U?W===0?n:N(W===1?a:i,{count:W}):``})]})})})}export{q as default};
@@ -2,7 +2,7 @@
2
2
  "format": "webority-guidance/1",
3
3
  "package": {
4
4
  "name": "@webority/ui-react",
5
- "version": "0.172.1"
5
+ "version": "0.173.0"
6
6
  },
7
7
  "components": [
8
8
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webority/ui-react",
3
- "version": "0.172.1",
3
+ "version": "0.173.0",
4
4
  "description": "Webority shared React component library: App* primitives on react-bootstrap and the @webority/theme design system.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "type": "module",
@@ -33,10 +33,10 @@
33
33
  },
34
34
  "sideEffects": false,
35
35
  "dependencies": {
36
- "@webority/markdown-core": "0.172.1",
37
- "@webority/theme": "0.172.1",
38
- "@webority/ui-elements": "0.172.1",
39
- "@webority/web-core": "0.172.1"
36
+ "@webority/markdown-core": "0.173.0",
37
+ "@webority/theme": "0.173.0",
38
+ "@webority/ui-elements": "0.173.0",
39
+ "@webority/web-core": "0.173.0"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "@webority/analytics": "^0.40.0",
@@ -62,9 +62,9 @@
62
62
  "@vitejs/plugin-react": "^6.0.1",
63
63
  "@vitest/coverage-v8": "5.1.0",
64
64
  "@webority/analytics": "0.40.11",
65
- "@webority/canvas-kit": "0.172.1",
66
- "@webority/biome-config": "0.172.1",
67
- "@webority/tokens": "0.172.1",
65
+ "@webority/canvas-kit": "0.173.0",
66
+ "@webority/biome-config": "0.173.0",
67
+ "@webority/tokens": "0.173.0",
68
68
  "bootstrap": "5.3.9",
69
69
  "jsdom": "30.1.1",
70
70
  "react": "^19.3.1",