@webority/ui-react 0.171.3 → 0.172.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist/canvas-kit/kit.js +143 -365
  2. package/dist/canvas-kit/manifest.json +332 -3
  3. package/dist/canvas-kit/release.json +6 -6
  4. package/dist/components/AppChart.js +1 -1
  5. package/dist/components/AppCommentThread.js +1 -1
  6. package/dist/components/AppConfirmDialog.js +1 -1
  7. package/dist/components/AppDataTable.js +1 -1
  8. package/dist/components/AppDatePicker.js +1 -1
  9. package/dist/components/AppDateTimePicker.js +1 -0
  10. package/dist/components/AppDescriptions.js +1 -1
  11. package/dist/components/AppFileTiles.js +1 -1
  12. package/dist/components/AppForm.js +1 -1
  13. package/dist/components/AppInput.js +1 -1
  14. package/dist/components/AppKpiTile.js +1 -1
  15. package/dist/components/AppMonthPicker.js +1 -1
  16. package/dist/components/AppNavigationMenu.js +1 -1
  17. package/dist/components/AppSelect.js +1 -1
  18. package/dist/components/AppShell.js +1 -1
  19. package/dist/components/AppTablePagination.js +1 -1
  20. package/dist/components/AppTabs.js +1 -1
  21. package/dist/components/AppTransferList.js +1 -1
  22. package/dist/components/useNodeLabels.js +1 -1
  23. package/dist/guidance.json +29 -2
  24. package/dist/hookForm/index.js +1 -1
  25. package/dist/types/components/AppChart.d.ts +9 -1
  26. package/dist/types/components/AppCommentThread.d.ts +2 -0
  27. package/dist/types/components/AppConfirmDialog.d.ts +9 -2
  28. package/dist/types/components/AppDataTable.d.ts +31 -0
  29. package/dist/types/components/AppDatePicker.d.ts +5 -0
  30. package/dist/types/components/AppDateTimePicker.d.ts +75 -0
  31. package/dist/types/components/AppDescriptions.d.ts +5 -0
  32. package/dist/types/components/AppForm.d.ts +5 -3
  33. package/dist/types/components/AppInput.d.ts +5 -0
  34. package/dist/types/components/AppKpiTile.d.ts +7 -0
  35. package/dist/types/components/AppMonthPicker.d.ts +5 -0
  36. package/dist/types/components/AppNavigationMenu.d.ts +2 -0
  37. package/dist/types/components/AppSelect.d.ts +10 -0
  38. package/dist/types/components/AppShell.d.ts +13 -1
  39. package/dist/types/components/AppTablePagination.d.ts +2 -0
  40. package/dist/types/index.d.ts +2 -1
  41. package/dist/ui-react.js +1 -1
  42. package/package.json +8 -8
@@ -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,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,virtualRange as Se}from"@webority/ui-elements/helpers";import{Children as Ce,Fragment as we,isValidElement as Te,useCallback as Ee,useEffect as p,useLayoutEffect as De,useMemo as Oe,useRef as m,useState as h}from"react";import{Fragment as ke,jsx as g,jsxs as _}from"react/jsx-runtime";import{DATA_TABLE_TEXT as Ae,ROW_ACTIONS_TEXT as je,fillText as Me,pluralText as Ne}from"@webority/ui-elements/text";import{FORCED_STATE_CLASSES as Pe}from"@webority/theme/runtime";var Fe=()=>import(`@webority/ui-elements/elements/data-table`),Ie=[`comfortable`,`cozy`,`compact`],Le=[`auto`,`fixed`],Re=[1,2,3,4],ze=e=>typeof e==`number`?`${e}px`:e;function Be(e){let t=e.flatMap(e=>{let t=e.minWidth??e.width;return t===void 0?[]:[ze(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 Ve(e,t){if(e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`||Te(e)||Array.isArray(e))return e;throw Error(`AppDataTable: the value under "${t}" is not renderable; give that column a render function.`)}function He(e,t){return Ve(v(e,t),t)}var Ue=()=>{try{return process.env.NODE_ENV!==`production`}catch{return!0}},y=/* @__PURE__ */ new Set;function b(t,n){!y.has(t)&&Ue()&&(y.add(t),e(`[@webority/ui-react] <AppDataTable> ${n}`))}var We=100,Ge=e=>{let t=typeof e==`object`&&e&&`id`in e?e.id:void 0;return typeof t==`string`||typeof t==`number`?t:void 0},Ke=()=>{},qe=()=>({total:0,keys:[]}),Je=[],Ye=(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 Xe(e){return e===`center`?`44%`:e===`end`||e===`num`?`56%`:`60%`}function Ze(e){return e==null||e===``?t():Array.isArray(e)?Ce.toArray(e):typeof e==`boolean`?String(e):e}function Qe(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`,Fe);let t=r(`dataTable`,Ae),Ce=r(`rowActions`,je),Te=e=>e?Me(t.resizeColumnText,{label:e}):t.resizeColumnLabel,{marker:ze,props:Ue}=i(`AppDataTable`,e),{columns:y,rows:S=Je,rowKey:$e=Ge,sort:et,onSort:tt,loading:C=!1,refreshing:nt=!1,skeletonRows:rt=5,empty:it=t.empty,emptyFiltered:at,error:ot,onRetry:st,sourceCount:ct,rowActions:w,linkComponent:lt,rowActionsLabel:ut,pagination:T,ariaLabel:dt,className:ft=``,wrapperClassName:pt=``,selectable:E=!1,selectedIds:D,isRowSelectable:mt,onToggleRow:ht,onToggleAll:gt,onSelectRange:_t,renderExpanded:vt,singleExpand:yt=!1,density:O=`cozy`,tableLayout:bt=`auto`,striped:xt=!1,flush:St=!1,pad:Ct,nameLines:k,headerTone:wt,rowDrag:A=!1,maxHeight:Tt,stickyFirstColumn:Et=!1,stickyActions:Dt=!1,equalActions:Ot=!1,linkFirstColumn:kt=!1,stackOnMobile:j=!1,hiddenColumns:At,rowStatus:jt,rowHref:M,onRowClick:Mt,activeRowKey:Nt,hoverRowKey:Pt,resizableColumns:N=!1,viewKey:Ft,groupBy:P,groupLabel:It,virtual:F=!1,rowSaving:I,rowSaveError:L,...Lt}=Ue;d(`AppDataTable`,Lt);let{style:Rt,...zt}=Lt,R=Ee((e,t)=>{let n=$e(e,t);if(n==null)throw Error(`AppDataTable: a row has no key. Pass rowKey, or give every row an id.`);return n},[$e]),Bt=At?.length?new Set(At):null;y=Bt?y.filter(e=>!(e.hideable&&Bt.has(e.key))):y,u(`AppDataTable`,`density`,O,Ie),u(`AppDataTable`,`tableLayout`,bt,Le),u(`AppDataTable`,`nameLines`,k,Re);for(let e of y)u(`AppDataTable`,`column.pin`,e.pin,ie);let z=typeof M==`function`||typeof Mt==`function`,Vt=[`table table-ledger`,O===`cozy`||O===`compact`?`wui-table-${O}`:``,xt?`wui-table-striped`:``,Et?`wui-table-sticky-first`:``,Dt?`wui-table-sticky-actions`:``,Ot?`wui-table-equal-actions`:``,j?`wui-table-stack`:``,kt&&z?`wui-table-link-first`:``,ft].filter(Boolean).join(` `),B=typeof vt==`function`,[Ht,Ut]=h(()=>/* @__PURE__ */ new Set),Wt=e=>Ut(t=>{if(t.has(e)){let n=new Set(t);return n.delete(e),n}return yt?/* @__PURE__ */ new Set([e]):new Set(t).add(e)}),Gt=y.some(e=>typeof e.footer==`function`),Kt=e=>!!(e.target instanceof Element&&e.target.closest(`a, button, input, select, textarea, label, [role='menu'], [role='menuitem'], .dropdown`)),qt=(e,t)=>{if(Kt(t)||(Mt&&Mt(e),!M))return;let n=M(e);n&&(t.ctrlKey||t.metaKey||t.button===1?window.open(n,`_blank`,`noopener`):window.location.assign(n))},V=Tt!==void 0,Jt=nt&&!C&&S.length>0,Yt=[`table-wrap`,V?`wui-table-scroll`:``,St?`wui-table-flush`:``,Jt?`wui-table-refreshing`:``,pt].filter(Boolean).join(` `),Xt={maxHeight:V?Tt:void 0,"--wui-table-pad":Ct!=null&&!St?`${Ct}px`:void 0,"--wui-name-lines":F?`1`:k?.toString(),"--wui-table-header-bg":wt??void 0},Zt=Object.values(Xt).some(e=>e!==void 0)||Rt!==void 0?{...Xt,...Rt}:void 0,Qt=Math.max(1,y.length+ +!!w+ +!!E+ +!!B),$t=y.some(e=>e.pin===`start`||e.pin===`end`),en=$t||N||!!P||F,H=+!!B+ +!!E,tn=$t?ge([...B?[`lead`]:[],...E?[`lead`]:[],...y.map(e=>e.pin===`start`||e.pin===`end`?e.pin:null),...w?[null]:[]]):[],U=(e,t=``)=>{let n=tn[e];return n?{className:`${t.trim()} ${he(n)}`.trim(),style:{[re]:me(n.side,n.ordinal)}}:{className:t,style:void 0}},nn=(e,t)=>tn[e]?{...t,...U(e).style}:t,rn=y.length-1+ +!!w;Ft&&!N&&b(`view-key`,"`viewKey` remembers resized widths: add `resizableColumns`."),F&&!V&&b(`virtual-height`,"`virtual` needs `maxHeight`: without a scroll box every row renders."),F&&(B||j)&&b(`virtual-shape`,"`virtual` takes rows of one height, so it is off with `renderExpanded` or `stackOnMobile`."),F&&k!==void 0&&k!==1&&b(`virtual-name-lines`,"`nameLines` is ignored with `virtual`: a virtual table shows one line per name."),kt&&!z&&b(`link-first-column`,"`linkFirstColumn` needs rowHref or onRowClick: the row is what opens."),yt&&typeof vt!=`function`&&b(`single-expand`,"`singleExpand` needs renderExpanded: there are no rows to expand."),!F&&S?.length>500&&b(`rows-without-virtual`,`renders more than 500 rows without virtual: add virtual with maxHeight, or page the data.`);let W=F&&V&&!B&&!j&&!C&&S?.length>0,G=(e,t)=>!mt||!!mt(e,t),an=E&&S?S.reduce((e,t,n)=>e+ +!!G(t,n),0):0,K=E&&S?S.reduce((e,t,n)=>e+(G(t,n)&&D?.has(R(t,n))?1:0),0):0,on=an>0&&K===an,sn=K>0&&!on,cn=e=>{e&&(e.indeterminate=sn)},ln=m(null),un=(e,t)=>{let n=ln.current;ln.current=e;let r=t&&n!==null?S.findIndex((e,t)=>R(e,t)===n):-1,i=S.findIndex((t,n)=>R(t,n)===e);if(r<0||i<0||r===i){ht?.(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])=>G(e,t)).map(([e,t])=>R(e,t)).filter(e=>(D?.has(e)||!1)!==a);if(_t)_t(s,a);else for(let e of s)ht?.(e)},dn=e=>{mt?(S||[]).forEach((t,n)=>{let r=R(t,n);G(t,n)&&(D?.has(r)||!1)!==e&&ht?.(r)}):gt?.(e)},[fn,pn]=h(()=>/* @__PURE__ */ new Set),mn=e=>pn(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),q=Oe(()=>{let e=(S||[]).map((e,t)=>({row:e,i:t}));return P?de(e,({row:e})=>String(v(e,P)??``)).flatMap(e=>[{group:e,open:!fn.has(e.key)},...fn.has(e.key)?[]:e.items]):e},[S,P,fn]),hn=m(null),[J,gn]=h(null),_n=Ee(e=>{hn.current=e,gn(e)},[]),vn=m(null);p(()=>{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;vn.current=t?Number(t)-2:null},r=t=>{t.relatedTarget instanceof Node&&e.contains(t.relatedTarget)||(vn.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()}},[J]),p(()=>{if(!A||!J)return;let e=ce(J);return xe(document),e},[A,J]);let yn=m(qe);De(()=>{yn.current=()=>({total:S?.length??0,keys:S?S.flatMap((e,t)=>{let n=R(e,t);return G(e,t)&&D?.has(n)?[String(n)]:[]}):[]})});let bn=m(!1);p(()=>{if(!bn.current&&(bn.current=!0,K===0))return;let{total:e,keys:t}=yn.current();hn.current?.querySelector(`table`)?.dispatchEvent(new CustomEvent(`selectionchange`,{bubbles:!0,detail:{selected:K,total:e,keys:t}}))},[K]);let[xn,Sn]=h({top:0,height:0}),[Cn,wn]=h(ae[O]??ae.cozy);p(()=>{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};Sn(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 Tn=m(null);De(()=>{if(!W){Tn.current=null;return}let e=`${O}:${S?.length??0}`;if(Tn.current===e)return;Tn.current=e;let t=(hn.current?.querySelector(`:scope > table > tbody > tr:not(.wui-virtual-spacer, .wui-group-row)`))?.getBoundingClientRect().height;t!==void 0&&t>0&&Math.abs(t-Cn)>.5&&wn(t)});let Y={start:0,end:q.length,before:0,after:0};if(W){Y=Se({scrollTop:xn.top,viewport:xn.height||Number.parseFloat(String(Tt))||0,rowHeight:Cn,count:q.length});let e=vn.current;e!==null&&e>=0&&e<q.length&&(e<Y.start&&Y.start-e<=We&&(Y={...Y,start:e,before:e*Cn}),e>=Y.end&&e-Y.end<We&&(Y={...Y,end:e+1,after:(q.length-e-1)*Cn}))}let En=m(null),Dn=m(null),On=m(null),kn=!F&&!C&&S?.length>0&&S.length<=oe;De(()=>{let e=En.current;if(!kn||!e){Dn.current=null,On.current=null;return}let t=S.map((e,t)=>R(e,t));ve(On.current,t)&&_e(e.rows,Dn.current),Dn.current=pe(e.rows),On.current=t});let An=typeof I==`function`||typeof L==`function`,jn=m(null),Mn=m(null),X=y[0]?.key;p(()=>{if(!An){Mn.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(R(t,n),{...Ye(t,I,L),label:i})});let t=ye(be(Mn.current,e));Mn.current=e,t&&jn.current&&(jn.current.textContent=t)},[S,I,L,R,An,X]);let Nn=at!==void 0&&(ct===void 0||ct>0)?at:it,Z=!C&&ot?ot:null,Pn=({group:e,open:n},r)=>{let i=v(e.items[0]?.row,P??``),a=e.items.map(e=>e.row);return/* @__PURE__ */ g(`tr`,{className:`wui-group-row`,"data-group-key":e.key,"aria-rowindex":W?r+2:void 0,children:/* @__PURE__ */ g(`th`,{className:`wui-group-cell`,scope:`rowgroup`,colSpan:Qt,children:/* @__PURE__ */ _(`button`,{type:`button`,className:`wui-group-toggle`,"aria-expanded":n,onClick:()=>mn(e.key),children:[/* @__PURE__ */ g(s,{name:`chevron-down`,size:16}),/* @__PURE__ */ g(`span`,{className:`wui-group-label`,children:It?It(i,a):Ze(Ve(i,P??``))}),/* @__PURE__ */ g(`span`,{className:`wui-group-count`,"aria-hidden":`true`,children:ue(e.items.length)}),/* @__PURE__ */ g(`span`,{className:`visually-hidden wui-group-rows`,children:`, ${Ne(t,`groupRows`,e.items.length,{count:ue(e.items.length)})}`})]})})},`group:${e.key}`)},Fn=({row:e,i:n},r)=>{let i=R(e,n),a=B&&Ht.has(i),o=Nt!=null&&String(Nt)===String(i),ee=Pt!=null&&String(Pt)===String(i),c=String(i).replace(/[^a-z0-9]/gi,`_`),l=U(0,`wui-expand-cell`),u=U(+!!B,`wui-select-cell`),d=An?Ye(e,I,L):null,f=G(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`?Me(t.moreActionsForText,{firstValue:re}):Ce.menuLabel;return/* @__PURE__ */ _(we,{children:[/* @__PURE__ */ _(`tr`,{className:[E&&f&&D?.has(i)?`is-selected`:``,z?`wui-row-link`:``,o?`wui-row-active`:``,ee?Pe.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":jt?.(e)||void 0,"data-href":M?.(e)||void 0,"data-row-key":A?String(i):void 0,tabIndex:z?0:void 0,onClick:z?t=>qt(e,t):void 0,onAuxClick:z&&M?t=>t.button===1&&qt(e,t):void 0,onKeyDown:z?t=>{fe(t.nativeEvent)&&t.target===t.currentTarget&&qt(e,t)}:void 0,children:[B&&/* @__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:()=>Wt(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=>un(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:U(H+n,(n===0?`wui-name-cell `:``)+(t.rowHeader?`wui-row-header `:``)+(t.nowrap?`text-nowrap `:``)+x(t.align)+(t.cellClassName?` ${t.cellClassName}`:``)).className,style:nn(H+n,t.cellStyle),"data-label":j&&typeof t.label==`string`?t.label:void 0,children:[t.render?t.render(e):Ze(He(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:lt})})]}),a&&/* @__PURE__ */ g(`tr`,{className:`wui-row-expanded`,children:/* @__PURE__ */ g(`td`,{id:`${c}-expanded`,colSpan:Qt,children:vt?.(e)})})]},i)},In=(e,t)=>`group`in e?Pn(e,t):Fn(e,t),Ln=(e,t)=>W?/* @__PURE__ */ g(`tr`,{className:`wui-virtual-spacer`,"aria-hidden":`true`,hidden:t===0,children:/* @__PURE__ */ g(`td`,{colSpan:Qt,style:{height:t}})},e):null,Q=U(0,`wui-expand-cell`),$=U(+!!B,`wui-select-cell`),Rn=()=>Array.from({length:rt},(e,t)=>`skeleton-${t}`).map(e=>/* @__PURE__ */ _(`tr`,{children:[B&&/* @__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:U(H+t,(t===0?`wui-name-cell `:``)+(e.nowrap?`text-nowrap `:``)+x(e.align)).className,style:nn(H+t,void 0),"data-label":j&&typeof e.label==`string`?e.label:void 0,children:/* @__PURE__ */ g(c,{width:Xe(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__ */ _(ke,{children:[/* @__PURE__ */ _(en?`wui-data-table`:`div`,{ref:_n,...en?{class:Yt,resizable:N?``:void 0,"view-key":Ft||void 0,"data-wui-row-drag":A?``:void 0,"aria-busy":Jt||void 0}:{className:Yt,"data-wui-row-drag":A?``:void 0,"aria-busy":Jt||void 0},style:Zt,tabIndex:0,...ze,...zt,children:[/* @__PURE__ */ _(`table`,{className:Vt,"aria-label":dt,"aria-rowcount":W?q.length+1:void 0,style:bt===`fixed`?{tableLayout:`fixed`,minWidth:Be(y)}:void 0,children:[/* @__PURE__ */ g(`thead`,{children:/* @__PURE__ */ _(`tr`,{"aria-rowindex":W?1:void 0,children:[B&&/* @__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:on,disabled:C,onChange:e=>dn(e.target.checked),"aria-label":t.selectAllRowsLabel})}),y.map((e,t)=>{let n=e.sortable?tt:void 0,r=n!==void 0,i=et&&et.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=N&&t!==rn,c=bt===`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:U(H+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:nn(H+t,l),"data-key":en?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?et?.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&&(fe(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":Te(typeof e.label==`string`?e.label:e.key)})]},e.key)}),w&&(ut?/* @__PURE__ */ g(`th`,{className:`wui-cell-end`,children:ut}):/* @__PURE__ */ g(`th`,{className:`wui-cell-end`,children:/* @__PURE__ */ g(`span`,{className:`visually-hidden`,children:t.rowActionsLabel})}))]})}),/* @__PURE__ */ g(`tbody`,{ref:En,children:C?Rn():Z?null:S?.length?/* @__PURE__ */ _(ke,{children:[Ln(`before`,Y.before),q.slice(Y.start,Y.end).map((e,t)=>In(e,Y.start+t)),Ln(`after`,Y.after)]}):null}),Gt&&!C&&!Z&&S?.length>0&&/* @__PURE__ */ g(`tfoot`,{children:/* @__PURE__ */ _(`tr`,{children:[B&&/* @__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:U(H+t,(t===0?`wui-name-cell `:``)+(e.nowrap?`text-nowrap `:``)+x(e.align)).className,style:nn(H+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:st?/* @__PURE__ */ g(a,{variant:`soft`,size:`sm`,onClick:()=>st(),children:t.retryLabel}):void 0,className:`wui-table-error`}):typeof Nn==`string`?/* @__PURE__ */ g(`div`,{className:`tbl-empty-plain`,children:Nn}):Nn})]}),Qe(T)&&/* @__PURE__ */ g(l,{page:T.page,totalPages:T.totalPages,total:T.total,pageSize:T.pageSize,onPageChange:C?Ke:T.setPage,onPageSizeChange:C?Ke:T.setPageSize,pageSizes:T.pageSizes,mode:T.mode,summary:T.summary}),An&&/* @__PURE__ */ g(`div`,{ref:jn,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 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 +1 @@
1
- import{devWarn as e}from"../lib/devWarn.js";import t from"../lib/FieldMessage.js";import{useFieldError as ee}from"../lib/formFields.js";import n from"../lib/useElementEntry.js";import r from"../lib/useWuiText.js";import{splitMarkerProps as i}from"../lib/wuiMarker.js";import te from"./AppInfoTip.js";import ne from"./AppRequiredMark.js";import a from"./assertValidValue.js";import o from"./textOf.js";import s from"./useWuiControl.js";import c from"./warnUnknownProps.js";import{cloneElement as l,forwardRef as u,useId as d}from"react";import{jsx as f,jsxs as p}from"react/jsx-runtime";import{DATE_PICKER_TEXT as m}from"@webority/ui-elements/text";var h=[`sm`,`md`,`lg`,`xl`],g=()=>import(`@webority/ui-elements/elements/datepicker`),_=u(function(u,_){let re=n(`wui-datepicker`,g),v=r(`datePicker`,m),{marker:y,props:ie}=i(`AppDatePicker`,u),{value:b,onChange:x,label:S,required:C=!1,optional:w=!1,optionalLabel:T=v.optionalLabel,helperText:E,error:D,name:O,min:k,max:A,placeholder:j=v.placeholder,disabled:M,readOnly:N=!1,loading:P=!1,defaultValue:F,help:I,helpLabel:L=v.helpLabel,size:R,firstDay:z,displayFormat:B,id:V,ariaLabel:H,"aria-invalid":U,className:W=``,fieldClassName:G=``,...K}=ie,q=ee(O),J=D??q;c(`AppDatePicker`,K),a(`AppDatePicker`,`size`,R,h),typeof B==`string`&&B!==``&&/DD|YYYY|YY/.test(B)&&e(`[@webority/ui-react] <AppDatePicker> displayFormat "${B}" uses uppercase day or year tokens, which print as written; the tokens are yyyy, MMMM, MMM, MM, dd and d.`);let Y=d(),X=V||Y,{setRef:ae}=s({ready:re,ref:_,value:b??(F===void 0?``:void 0),defaultValue:F,onChange:x}),oe=!S&&!J&&!E,Z=J?`${X}-error`:void 0,Q=E?`${X}-hint`:void 0,se=Z||Q,$=/* @__PURE__ */ f(`wui-datepicker`,{ref:ae,id:X,name:O,value:(b??F)||void 0,min:k,max:A,placeholder:j,size:R||void 0,"first-day":z==null?void 0:String(z),"display-format":B||void 0,"aria-label":H||o(S)||void 0,"aria-describedby":se,"aria-invalid":U??(J?`true`:void 0),disabled:M?``:void 0,readonly:N?``:void 0,loading:P?``:void 0,required:C?``:void 0,className:W||void 0,...K});return oe?l($,y):/* @__PURE__ */ p(`div`,{...y,className:`field${G?` ${G}`:``}`,children:[S&&/* @__PURE__ */ p(`label`,{className:`label`,htmlFor:X,children:[S,w&&!C&&/* @__PURE__ */ f(`span`,{className:`label-optional`,children:` ${T}`}),C&&/* @__PURE__ */ f(ne,{}),I&&/* @__PURE__ */ f(te,{label:L,children:I})]}),$,/* @__PURE__ */ f(t,{error:J,hint:E,errorId:Z,hintId:Q})]})});export{_ as default};
1
+ import{devWarn as e}from"../lib/devWarn.js";import t from"../lib/FieldMessage.js";import{useFieldError as n}from"../lib/formFields.js";import ee from"../lib/useElementEntry.js";import r from"../lib/useWuiText.js";import{splitMarkerProps as i}from"../lib/wuiMarker.js";import te from"./AppInfoTip.js";import ne from"./AppRequiredMark.js";import a from"./assertValidValue.js";import o from"./textOf.js";import s from"./useWuiControl.js";import c from"./warnUnknownProps.js";import{cloneElement as l,forwardRef as u,useId as d}from"react";import{jsx as f,jsxs as p}from"react/jsx-runtime";import{DATE_PICKER_TEXT as m}from"@webority/ui-elements/text";var h=[`sm`,`md`,`lg`,`xl`],g=()=>import(`@webority/ui-elements/elements/datepicker`),_=u(function(u,_){let re=ee(`wui-datepicker`,g),v=r(`datePicker`,m),{marker:y,props:ie}=i(`AppDatePicker`,u),{value:b,onChange:x,label:S,required:C=!1,optional:w=!1,optionalLabel:T=v.optionalLabel,helperText:E,error:D,valid:O=!1,name:k,min:A,max:j,placeholder:M=v.placeholder,disabled:N,readOnly:P=!1,loading:F=!1,defaultValue:I,help:L,helpLabel:R=v.helpLabel,size:z,firstDay:B,displayFormat:V,id:H,ariaLabel:U,"aria-invalid":W,className:G=``,fieldClassName:K=``,...q}=ie,J=n(k),Y=D??J;c(`AppDatePicker`,q),a(`AppDatePicker`,`size`,z,h),typeof V==`string`&&V!==``&&/DD|YYYY|YY/.test(V)&&e(`[@webority/ui-react] <AppDatePicker> displayFormat "${V}" uses uppercase day or year tokens, which print as written; the tokens are yyyy, MMMM, MMM, MM, dd and d.`);let ae=d(),X=H||ae,{setRef:oe}=s({ready:re,ref:_,value:b??(I===void 0?``:void 0),defaultValue:I,onChange:x}),se=!S&&!Y&&!E,Z=Y?`${X}-error`:void 0,Q=E?`${X}-hint`:void 0,ce=Z||Q,le=[G,O&&!Y?`wui-valid`:``].filter(Boolean).join(` `),$=/* @__PURE__ */ f(`wui-datepicker`,{ref:oe,id:X,name:k,value:(b??I)||void 0,min:A,max:j,placeholder:M,size:z||void 0,"first-day":B==null?void 0:String(B),"display-format":V||void 0,"aria-label":U||o(S)||void 0,"aria-describedby":ce,"aria-invalid":W??(Y?`true`:void 0),disabled:N?``:void 0,readonly:P?``:void 0,loading:F?``:void 0,required:C?``:void 0,className:le||void 0,...q});return se?l($,y):/* @__PURE__ */ p(`div`,{...y,className:`field${K?` ${K}`:``}`,children:[S&&/* @__PURE__ */ p(`label`,{className:`label`,htmlFor:X,children:[S,w&&!C&&/* @__PURE__ */ f(`span`,{className:`label-optional`,children:` ${T}`}),C&&/* @__PURE__ */ f(ne,{}),L&&/* @__PURE__ */ f(te,{label:R,children:L})]}),$,/* @__PURE__ */ f(t,{error:Y,hint:E,errorId:Z,hintId:Q})]})});export{_ as default};
@@ -0,0 +1 @@
1
+ import e from"../lib/FieldMessage.js";import{useFieldError as t}from"../lib/formFields.js";import n from"../lib/useElementEntry.js";import r from"../lib/useWuiText.js";import{splitMarkerProps as i}from"../lib/wuiMarker.js";import a from"./AppInfoTip.js";import o from"./AppRequiredMark.js";import s from"./textOf.js";import c from"./useWuiControl.js";import l from"./warnUnknownProps.js";import{timeZoneLabel as u}from"@webority/ui-elements/helpers";import{forwardRef as d,useId as f}from"react";import{jsx as p,jsxs as m}from"react/jsx-runtime";import{DATE_PICKER_TEXT as h,TIME_PICKER_TEXT as g,fillText as _}from"@webority/ui-elements/text";var v=`Asia/Kolkata`,y=async()=>(await Promise.all([import(`@webority/ui-elements/elements/datepicker`),import(`@webority/ui-elements/elements/timepicker`)]),import(`@webority/ui-elements/elements/date-time`));function b(e,t){if(t!==void 0&&t!==``&&Number.isNaN(Date.parse(t)))throw Error(`<AppDateTimePicker> ${e} "${t}" is not an ISO UTC date-time.`)}var x=d(function(d,x){let S=n(`wui-date-time`,y),C=r(`datePicker`,h),w=r(`timePicker`,g),{marker:T,props:E}=i(`AppDateTimePicker`,d),{value:D,defaultValue:O,onChange:k,label:A,required:j=!1,optional:M=!1,optionalLabel:N=C.optionalLabel,helperText:P,error:F,name:I,min:L,max:R,disabled:z,readOnly:B=!1,help:V,helpLabel:H=C.helpLabel,zone:U=v,id:W,className:G=``,fieldClassName:K=``,...q}=E,J=t(I),Y=F??J;l(`AppDateTimePicker`,q),b(`value`,D),b(`defaultValue`,O),b(`min`,L),b(`max`,R);let X=f(),Z=W||X,Q=Y?`${Z}-error`:void 0,$=`${Z}-hint`,ee=P??_(C.zoneNote,{zone:u(U)}),{setRef:te}=c({ready:S,ref:x,value:D??(O===void 0?``:void 0),defaultValue:O,onChange:k});return/* @__PURE__ */ m(`div`,{...T,className:`field${K?` ${K}`:``}`,children:[A&&/* @__PURE__ */ m(`label`,{className:`label`,htmlFor:`${Z}-date`,children:[A,M&&!j&&/* @__PURE__ */ p(`span`,{className:`label-optional`,children:` ${N}`}),j&&/* @__PURE__ */ p(o,{}),V&&/* @__PURE__ */ p(a,{label:H,children:V})]}),/* @__PURE__ */ p(`wui-date-time`,{ref:te,id:Z,name:I,value:(D??O)||void 0,min:L,max:R,zone:U,"date-placeholder":C.placeholder,"time-placeholder":w.placeholder,"time-label":C.dateTimeLabel,"aria-label":s(A)||void 0,"aria-describedby":Q||$,"aria-invalid":Y?`true`:void 0,disabled:z?``:void 0,readonly:B?``:void 0,required:j?``:void 0,className:G||void 0,...q}),/* @__PURE__ */ p(e,{error:Y,hint:ee,errorId:Q,hintId:$})]})});export{x as default};
@@ -1 +1 @@
1
- import{emptyPlaceholder as e,isEmpty as t}from"../lib/emptyValue.js";import{linkTarget as n}from"../lib/linkTarget.js";import{TargetLink as r}from"../lib/TargetLink.js";import{splitMarkerProps as i}from"../lib/wuiMarker.js";import a from"./assertValidValue.js";import o from"./renderIconProp.js";import s from"./warnUnknownProps.js";import{jsx as c,jsxs as l}from"react/jsx-runtime";var u=[`sm`,`md`],d=[`grid`,`summary`,`list`],f=[1,2,3,4];function p(e,t){if(typeof e==`string`)return`${e}-${t}`;throw Error("<AppDescriptions> an item whose label is not text needs a `key`.")}function m(m){let{marker:h,props:g}=i(`AppDescriptions`,m),{items:_=[],columns:v=2,size:y=`md`,bordered:b=!1,layout:x=`grid`,title:S,linkComponent:C,className:w=``,...T}=g;s(`AppDescriptions`,T),a(`AppDescriptions`,`columns`,v,f),a(`AppDescriptions`,`size`,y,u),a(`AppDescriptions`,`layout`,x,d);let E=[`descs`,`descs-col-${v}`,y&&y!==`md`?`descs-${y}`:``,b?`descs-bordered`:``,x===`summary`?`wui-descs-summary`:``,x===`list`?`wui-descs-list`:``,v===4?`wui-descs-col-4`:``,w].filter(Boolean).join(` `)||void 0;return/* @__PURE__ */ l(`div`,{className:E,...h,...T,children:[S&&/* @__PURE__ */ c(`div`,{className:`descs-title`,children:S}),/* @__PURE__ */ c(`dl`,{className:`descs-list`,children:_.map((i,a)=>{let s=t(i.value),u=Math.min(12,Math.max(1,i.span??1)),d=i.key??p(i.label,a),f=s?e():i.value,m=n(C,{href:i.href}),h=Object.fromEntries(Object.entries(i).filter(([e])=>e.startsWith(`data-`)));return/* @__PURE__ */ l(`div`,{className:`descs-item${i.emphasis?` wui-descs-emphasis`:``} wui-descs-span-${u}`,id:i.id,tabIndex:i.tabIndex,...h,children:[i.icon&&/* @__PURE__ */ c(`span`,{className:`wui-descs-icon`,children:o(i.icon,{size:16})}),/* @__PURE__ */ c(`dt`,{className:`descs-label`,children:i.label}),/* @__PURE__ */ c(`dd`,{className:`descs-value${s?` is-empty`:``}${i.multiline&&!s?` wui-pre-line`:``}`,children:i.href?/* @__PURE__ */ c(r,{link:m,className:`wui-descs-link`,children:f}):f})]},d)})})]})}export{m as default};
1
+ import{emptyPlaceholder as e,isEmpty as t}from"../lib/emptyValue.js";import{linkTarget as n}from"../lib/linkTarget.js";import{TargetLink as r}from"../lib/TargetLink.js";import{splitMarkerProps as i}from"../lib/wuiMarker.js";import a from"./assertValidValue.js";import o from"./renderIconProp.js";import s from"./warnUnknownProps.js";import{jsx as c,jsxs as l}from"react/jsx-runtime";var u=[`sm`,`md`],d=[`grid`,`summary`,`list`],f=[1,2,3,4],p=[`top`,`start`];function m(e,t){if(typeof e==`string`)return`${e}-${t}`;throw Error("<AppDescriptions> an item whose label is not text needs a `key`.")}function h(h){let{marker:g,props:_}=i(`AppDescriptions`,h),{items:v=[],columns:y=2,size:b=`md`,bordered:x=!1,layout:S=`grid`,labels:C=`top`,title:w,linkComponent:T,className:E=``,...D}=_;s(`AppDescriptions`,D),a(`AppDescriptions`,`columns`,y,f),a(`AppDescriptions`,`size`,b,u),a(`AppDescriptions`,`layout`,S,d),a(`AppDescriptions`,`labels`,C,p);let O=[`descs`,`descs-col-${y}`,b&&b!==`md`?`descs-${b}`:``,x?`descs-bordered`:``,S===`summary`?`wui-descs-summary`:``,S===`list`?`wui-descs-list`:``,C===`start`&&S===`grid`?`wui-descs-labels-start`:``,y===4?`wui-descs-col-4`:``,E].filter(Boolean).join(` `)||void 0;return/* @__PURE__ */ l(`div`,{className:O,...g,...D,children:[w&&/* @__PURE__ */ c(`div`,{className:`descs-title`,children:w}),/* @__PURE__ */ c(`dl`,{className:`descs-list`,children:v.map((i,a)=>{let s=t(i.value),u=Math.min(12,Math.max(1,i.span??1)),d=i.key??m(i.label,a),f=s?e():i.value,p=n(T,{href:i.href}),h=Object.fromEntries(Object.entries(i).filter(([e])=>e.startsWith(`data-`)));return/* @__PURE__ */ l(`div`,{className:`descs-item${i.emphasis?` wui-descs-emphasis`:``} wui-descs-span-${u}`,id:i.id,tabIndex:i.tabIndex,...h,children:[i.icon&&/* @__PURE__ */ c(`span`,{className:`wui-descs-icon`,children:o(i.icon,{size:16})}),/* @__PURE__ */ c(`dt`,{className:`descs-label`,children:i.label}),/* @__PURE__ */ c(`dd`,{className:`descs-value${s?` is-empty`:``}${i.multiline&&!s?` wui-pre-line`:``}`,children:i.href?/* @__PURE__ */ c(r,{link:p,className:`wui-descs-link`,children:f}):f})]},d)})})]})}export{h as default};
@@ -1 +1 @@
1
- import{sizeLabelOf as e}from"../lib/fileItem.js";import{linkTarget as t}from"../lib/linkTarget.js";import{TargetLink as n}from"../lib/TargetLink.js";import{splitMarkerProps as r}from"../lib/wuiMarker.js";import i from"./warnUnknownProps.js";import{Fragment as a,jsx as o,jsxs as s}from"react/jsx-runtime";function c(e){let t=e.lastIndexOf(`.`),n=t>0?e.slice(t+1):``;return n.length>0?n.slice(0,4).toUpperCase():`FILE`}function l(t){let n=e({sizeBytes:t.sizeBytes});return n&&t.meta?/* @__PURE__ */ s(a,{children:[n,` · `,t.meta]}):n||t.meta||null}function u(e){let{marker:u,props:d}=r(`AppFileTiles`,e),{label:f,files:p=[],linkComponent:m,className:h=``,...g}=d;if(i(`AppFileTiles`,g),p.some(e=>!e.name))throw Error(`<AppFileTiles> each file needs a name.`);let _=[`wui-file-tiles`,h].filter(Boolean).join(` `);return/* @__PURE__ */ o(`ul`,{className:_,"aria-label":f,...u,...g,children:p.map(e=>{let r=t(m,{to:e.to,href:e.href,routeHref:!1}),i=l(e),u=/* @__PURE__ */ s(a,{children:[/* @__PURE__ */ o(`span`,{className:`wui-file-tile-ext`,"aria-hidden":`true`,children:c(e.name)}),/* @__PURE__ */ s(`span`,{className:`wui-file-tile-text`,children:[/* @__PURE__ */ o(`span`,{className:`wui-file-tile-name`,children:e.name}),i?/* @__PURE__ */ o(`span`,{className:`wui-file-tile-meta`,children:i}):null]})]});return/* @__PURE__ */ o(`li`,{children:e.href||e.to?/* @__PURE__ */ o(n,{link:r,className:`wui-file-tile`,children:u}):/* @__PURE__ */ o(`div`,{className:`wui-file-tile`,children:u})},e.key)})})}export{u as default};
1
+ import{sizeLabelOf as e}from"../lib/fileItem.js";import{linkTarget as t}from"../lib/linkTarget.js";import{TargetLink as n}from"../lib/TargetLink.js";import{splitMarkerProps as r}from"../lib/wuiMarker.js";import i from"./warnUnknownProps.js";import{Fragment as a,jsx as o,jsxs as s}from"react/jsx-runtime";function c(e){let t=e.lastIndexOf(`.`),n=t>0?e.slice(t+1):``;return n.length>0?n.slice(0,4).toUpperCase():`FILE`}function l(t){let n=e({sizeBytes:t.sizeBytes});return n&&t.meta?/* @__PURE__ */ s(a,{children:[n,` · `,t.meta]}):n||t.meta||null}function u(e){let{marker:u,props:d}=r(`AppFileTiles`,e),{label:f,files:p=[],linkComponent:m,className:h=``,...g}=d;if(i(`AppFileTiles`,g),p.some(e=>!e.name))throw Error(`<AppFileTiles> each file needs a name.`);let _=[`wui-file-tiles`,h].filter(Boolean).join(` `);return/* @__PURE__ */ o(`ul`,{className:_,"aria-label":f,...u,...g,children:p.map(e=>{let r=t(m,{to:e.to,href:e.href,routeHref:!1}),i=l(e),u=!!i,d=/* @__PURE__ */ s(a,{children:[/* @__PURE__ */ o(`span`,{className:`wui-file-tile-ext`,"aria-hidden":`true`,children:c(e.name)}),/* @__PURE__ */ s(`span`,{className:`wui-file-tile-text`,children:[/* @__PURE__ */ o(`span`,{className:`wui-file-tile-name`,children:e.name}),u?/* @__PURE__ */ o(`span`,{className:`wui-file-tile-meta`,children:i}):null]})]});return/* @__PURE__ */ o(`li`,{children:e.href||e.to?/* @__PURE__ */ o(n,{link:r,className:`wui-file-tile`,children:d}):/* @__PURE__ */ o(`div`,{className:`wui-file-tile`,children:d})},e.key)})})}export{u as default};
@@ -1 +1 @@
1
- import{newIdempotencyKey as e}from"../web-core/dist/api/idempotencyKey.js";import t from"../lib/focusField.js";import{FormFieldsContext as n,toFieldName as r}from"../lib/formFields.js";import i from"../lib/useWuiText.js";import{splitMarkerProps as a}from"../lib/wuiMarker.js";import o from"./AppConfirmDialog.js";import s from"./AppIcon.js";import c from"./warnUnknownProps.js";import{createContext as l,useCallback as u,useContext as d,useEffect as f,useMemo as p,useRef as m,useState as h}from"react";import{jsx as g,jsxs as _}from"react/jsx-runtime";import{UNSAVED_CHANGES_TEXT as v}from"@webority/ui-elements/text";var y=l(null);function b(){let e=d(y);if(e===null)throw Error(`useFormSubmit must be called inside an AppForm`);return e}var x=/* @__PURE__ */ new Set,S=/* @__PURE__ */ new Map;function C(l){let{marker:d,props:b}=a(`AppForm`,l),C=i(`unsavedChanges`,v),{onSubmit:w,onChange:T,className:ee,children:E,noValidate:D,action:O,method:k,encType:A,acceptCharset:j,fieldErrors:M,formErrors:te,unsavedChanges:N,unsavedChangesMessage:P,...F}=b;c(`AppForm`,F);let[I,L]=h(!1),[R,z]=h(e),B=m(!1),[V,H]=h(null),U=p(()=>new Map(Object.entries(M??{}).map(([e,t])=>[r(e),t])),[M]),W=JSON.stringify([...U].sort(([e],[t])=>e<t?-1:+(e>t))),[G,K]=h({key:W,names:x}),q=G.key===W?G.names:x,J=u(e=>{T?.(e);let t=e.target;if(!(t instanceof HTMLElement)||!(`name`in t)||typeof t.name!=`string`||t.name===``)return;let n=r(t.name);U.has(n)&&K(e=>{let t=e.key===W?e.names:x;return t.has(n)?e:{key:W,names:/* @__PURE__ */ new Set([...t,n])}})},[T,U,W]),[Y,X]=h(S),Z=u(e=>(X(t=>new Map(t).set(e,(t.get(e)??0)+1)),()=>{X(t=>{let n=new Map(t),r=(t.get(e)??0)-1;return r>0?n.set(e,r):n.delete(e),n})}),[]),Q=u(e=>q.has(e)?void 0:U.get(e),[q,U]),ne=p(()=>({errorOf:Q,claim:Z}),[Q,Z]),$=[.../* @__PURE__ */ new Set([...te??[],...[...U].filter(([e])=>!Y.has(e)).map(([,e])=>e)])],re=u(async t=>{if(t.preventDefault(),B.current)return;B.current=!0,L(!0);let n=t.currentTarget;try{await w(t,{idempotencyKey:R})?z(e()):H({form:n})}finally{B.current=!1,L(!1)}},[w,R]);f(()=>{if(V===null)return;let{form:e}=V;if(H(null),e.querySelector(`.wui-error-summary`)!==null)return;let n=[...e.querySelectorAll(`[name]`)].map(e=>e.getAttribute(`name`)).find(e=>e!==null&&U.has(r(e)));n!==void 0&&t(n)},[V,U]);let ie=p(()=>({submitting:I,idempotencyKey:R}),[I,R]);return/* @__PURE__ */ g(n.Provider,{value:ne,children:/* @__PURE__ */ _(y.Provider,{value:ie,children:[/* @__PURE__ */ _(`form`,{...d,...F,noValidate:D,action:O,method:k,encType:A,acceptCharset:j,className:ee,onChange:J,onSubmit:re,"aria-busy":I||void 0,children:[$.length>0?/* @__PURE__ */ _(`div`,{role:`alert`,className:`alert alert-danger alert-has-icon`,"data-wui-form-errors":``,children:[/* @__PURE__ */ g(`span`,{className:`alert-icon`,children:/* @__PURE__ */ g(s,{name:`x`,size:11})}),/* @__PURE__ */ g(`div`,{className:`alert-content`,children:$.length===1?$[0]:$.map(e=>/* @__PURE__ */ g(`div`,{children:e},e))})]}):null,E]}),N?.blocked?/* @__PURE__ */ g(o,{open:!0,title:C.title,description:P??C.message,confirmLabel:C.leaveLabel,onConfirm:N.discard,onClose:N.keep}):null]})})}export{y as FormSubmitContext,C as default,b as useFormSubmit};
1
+ import{newIdempotencyKey as e}from"../web-core/dist/api/idempotencyKey.js";import t from"../lib/focusField.js";import{FormFieldsContext as n,toFieldName as r}from"../lib/formFields.js";import i from"../lib/useWuiText.js";import{splitMarkerProps as a}from"../lib/wuiMarker.js";import o from"./AppConfirmDialog.js";import s from"./AppIcon.js";import c from"./warnUnknownProps.js";import{createContext as l,useCallback as u,useContext as d,useEffect as f,useMemo as p,useRef as m,useState as h}from"react";import{jsx as g,jsxs as _}from"react/jsx-runtime";import{UNSAVED_CHANGES_TEXT as v}from"@webority/ui-elements/text";var y=l(null);function b(){let e=d(y);if(e===null)throw Error(`useFormSubmit must be called inside an AppForm`);return e}var x=/* @__PURE__ */ new Set,S=/* @__PURE__ */ new Map;function C(l){let{marker:d,props:b}=a(`AppForm`,l),C=i(`unsavedChanges`,v),{onSubmit:w,onChange:T,className:ee,children:E,noValidate:D,action:O,method:k,encType:A,acceptCharset:j,fieldErrors:M,formErrors:te,unsavedChanges:N,unsavedChangesMessage:P,...F}=b;c(`AppForm`,F);let[I,L]=h(!1),[R,z]=h(e),B=m(!1),[V,H]=h(null),U=p(()=>new Map(Object.entries(M??{}).map(([e,t])=>[r(e),t])),[M]),W=JSON.stringify([...U].sort(([e],[t])=>e<t?-1:+(e>t))),[G,K]=h({key:W,names:x}),q=G.key===W?G.names:x,J=u(e=>{T?.(e);let t=e.target;if(!(t instanceof HTMLElement)||!(`name`in t)||typeof t.name!=`string`||t.name===``)return;let n=r(t.name);U.has(n)&&K(e=>{let t=e.key===W?e.names:x;return t.has(n)?e:{key:W,names:/* @__PURE__ */ new Set([...t,n])}})},[T,U,W]),[Y,X]=h(S),Z=u(e=>(X(t=>new Map(t).set(e,(t.get(e)??0)+1)),()=>{X(t=>{let n=new Map(t),r=(t.get(e)??0)-1;return r>0?n.set(e,r):n.delete(e),n})}),[]),Q=u(e=>q.has(e)?void 0:U.get(e),[q,U]),ne=p(()=>({errorOf:Q,claim:Z}),[Q,Z]),$=[.../* @__PURE__ */ new Set([...te??[],...[...U].filter(([e])=>!Y.has(e)).map(([,e])=>e)])],re=u(async t=>{if(t.preventDefault(),B.current)return;B.current=!0,L(!0);let n=t.currentTarget;try{let r=await w(t,{idempotencyKey:R});r!==!1&&z(e()),r!==!0&&H({form:n})}finally{B.current=!1,L(!1)}},[w,R]);f(()=>{if(V===null)return;let{form:e}=V;if(H(null),e.querySelector(`.wui-error-summary`)!==null)return;let n=[...e.querySelectorAll(`[name]`)].map(e=>e.getAttribute(`name`)).find(e=>e!==null&&U.has(r(e)));n!==void 0&&t(n)},[V,U]);let ie=p(()=>({submitting:I,idempotencyKey:R}),[I,R]);return/* @__PURE__ */ g(n.Provider,{value:ne,children:/* @__PURE__ */ _(y.Provider,{value:ie,children:[/* @__PURE__ */ _(`form`,{...d,...F,noValidate:D,action:O,method:k,encType:A,acceptCharset:j,className:ee,onChange:J,onSubmit:re,"aria-busy":I||void 0,children:[$.length>0?/* @__PURE__ */ _(`div`,{role:`alert`,className:`alert alert-danger alert-has-icon`,"data-wui-form-errors":``,children:[/* @__PURE__ */ g(`span`,{className:`alert-icon`,children:/* @__PURE__ */ g(s,{name:`x`,size:11})}),/* @__PURE__ */ g(`div`,{className:`alert-content`,children:$.length===1?$[0]:$.map(e=>/* @__PURE__ */ g(`div`,{children:e},e))})]}):null,E]}),N?.blocked?/* @__PURE__ */ g(o,{open:!0,title:C.title,description:P??C.message,confirmLabel:C.leaveLabel,onConfirm:N.discard,onClose:N.keep}):null]})})}export{y as FormSubmitContext,C as default,b as useFormSubmit};
@@ -1 +1 @@
1
- import{devWarn as e}from"../lib/devWarn.js";import t from"../lib/FieldMessage.js";import{FIELD_BUSY_CLASS as n,blockWhenReadOnly as ee}from"../lib/fieldState.js";import{useFieldError as te}from"../lib/formFields.js";import ne from"../lib/useWuiText.js";import{splitMarkerProps as re}from"../lib/wuiMarker.js";import r from"./AppIcon.js";import ie from"./AppInfoTip.js";import ae from"./AppPopover.js";import i from"./AppRequiredMark.js";import a from"./assertValidValue.js";import oe from"./warnUnknownProps.js";import{MASK_INPUT_TYPES as se,MASK_NAMES as ce,attachInputMask as le,evaluatePassword as ue,formatMasked as de,isMaskPattern as fe,postedMasked as pe}from"@webority/ui-elements/helpers";import{cloneElement as me,forwardRef as he,useEffect as o,useId as ge,useRef as _e,useState as s}from"react";import{jsx as c,jsxs as l}from"react/jsx-runtime";import{INPUT_TEXT as ve}from"@webority/ui-elements/text";import{Form as u}from"react-bootstrap";var ye=[`sm`,`md`,`lg`,`xl`],be=[`bare`,`underline`],xe=[`off`,`border`,`above`],Se=[`off`,`shown`];function d(e,t){if(t!=null&&t!==``&&t!==!1)throw Error(`<AppInput> controlOnly draws no field, so it takes no ${e}; draw the label or message on the page.`)}function Ce(e){return e==null||{...`minLength`in e&&{minLength:e.minLength??0},...`uppercase`in e&&{uppercase:e.uppercase??!1},...`lowercase`in e&&{lowercase:e.lowercase??!1},...`digit`in e&&{digit:e.digit??!1},...`special`in e&&{special:e.special??!1},...`uniqueChars`in e&&{uniqueChars:e.uniqueChars??0},...`customRules`in e&&{customRules:e.customRules??[]}}}var f=he(function(he,f){let{marker:we,props:Te}=re(`AppInput`,he),p=ne(`input`,ve),{label:m,required:h=!1,optional:g=!1,error:Ee,helperText:_,help:v,helpLabel:De=p.helpLabel,type:y=`text`,size:b=`md`,leftIcon:x,rightIcon:S,onRightIconClick:Oe,rightIconLabel:ke,unit:C,id:Ae,name:je,className:Me=``,fieldClassName:w=``,disabled:Ne=!1,readOnly:T=!1,loading:E=!1,clearable:D=!1,clearLabel:Pe=p.clearLabel,optionalLabel:Fe=p.optionalLabel,requirementsTitle:Ie=p.requirementsTitle,showPasswordLabel:Le=p.showPasswordLabel,hidePasswordLabel:Re=p.hidePasswordLabel,showCount:O=!1,maxLength:k,monospace:ze=!1,prefix:A,suffix:j,action:Be,floatingLabel:M=`off`,variant:N,passwordRequirements:P=`off`,passwordPolicy:Ve,requirementsPlacement:F=`auto`,mask:I,postFormatted:L=!1,onMaskChange:He,controlOnly:Ue=!1,value:R,...z}=Te,We=te(je);oe(`AppInput`,z);let{onChange:Ge,onBlur:Ke,onClick:qe,onInput:B,...Je}=z;a(`AppInput`,`size`,b,ye),a(`AppInput`,`variant`,N,be),a(`AppInput`,`floatingLabel`,M,xe),a(`AppInput`,`passwordRequirements`,P,Se),Ue&&(d(`label`,m),d(`error`,Ee),d(`helperText`,_),d(`fieldClassName`,w),d(`showCount`,O),d(`help`,v),d(`optional`,g),d(`floatingLabel`,M===`off`?void 0:M),d(`passwordRequirements`,P===`shown`?P:void 0)),o(()=>{g&&h&&typeof process<`u`&&process.env.NODE_ENV!==`production`&&e(`AppInput: optional and required together; optional ignored`)},[g,h]),I!=null&&!fe(I)&&a(`AppInput`,`mask`,I,ce),I!=null&&a(`AppInput`,`type`,y,se);let[V,Ye]=s(!1),[Xe,Ze]=s(``),H=Ee||Xe||We,Qe=ge(),U=Ae||Qe,W=y===`password`,$e=W&&V?`text`:y,G=_e(null),et=e=>{G.current=e,typeof f==`function`?f(e):f&&(f.current=e)},K=String(R??z.defaultValue??``),[tt,q]=s(()=>!!K),[nt,rt]=s(()=>K.length),it=D&&!Ne&&!T&&!E,J=D||O,Y=W&&P===`shown`,[at,ot]=s(K);o(()=>{Y&&R!==void 0&&ot(String(R??``))},[R,Y]),o(()=>{if(!J||R===void 0)return;let e=String(R??``);q(!!e),rt(e.length)},[R,J]);let st=e=>{let t=e.currentTarget;q(!!t.value),rt(t.value.length),B?.(e)},ct=e=>{Y&&ot(e.currentTarget.value),J?st(e):B?.(e)},lt=I?{...R!==void 0&&{value:de(I,R)},...z.defaultValue!==void 0&&{defaultValue:de(I,z.defaultValue)}}:null,ut=_e(He);ut.current=He,o(()=>{let e=G.current;if(!I||!e)return;let t,n=le(e,{mask:I,postFormatted:L,onChange:(e,t)=>ut.current?.(e,t),onInvalidChange:e=>{clearTimeout(t),t=setTimeout(()=>Ze(e),0)}});return()=>{n(),clearTimeout(t),Ze(``)}},[I,L]);let dt=e=>I&&!L&&e?t=>{let n=t.currentTarget,ee=new Proxy(n,{get:(e,t)=>{if(t===`value`)return pe(I,e.value);let n=Reflect.get(e,t,e);return typeof n==`function`?n.bind(e):n}});e(Object.create(t,{target:{value:ee}}))}:e,ft=it?/* @__PURE__ */ c(`button`,{type:`button`,className:`input-clear`,onClick:()=>{let e=G.current;if(!e)return;let t=Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,`value`)?.set;t?t.call(e,``):e.value=``,e.dispatchEvent(new Event(`input`,{bubbles:!0})),q(!1),e.focus()},"aria-label":Pe,tabIndex:-1,hidden:!tt,children:/* @__PURE__ */ c(r,{name:`x`,size:16})}):null,pt=H&&U?`${U}-error`:void 0,mt=_&&U?`${U}-hint`:void 0,X=Y&&F===`inline`,ht=X&&U?`${U}-requirements`:void 0,gt=pt||(X?ht:mt),_t=[`input`,b===`sm`?`wui-input-sm`:``,b===`lg`?`wui-input-lg`:``,b===`xl`?`wui-input-xl`:``,H?`error`:``,W?`pw`:``,C?`num-input`:``,!(M!==`off`&&m||A||j||C||W||S)&&D&&it?`has-clear`:``,N===`underline`?`wui-input-underline`:N?`input-${N}`:``,ze?`wui-mono`:``,E?n:``,Me].filter(Boolean).join(` `),vt=ee(T||E),yt=vt?e=>{vt(e),qe?.(e)}:qe,bt=dt(Ge),xt=dt(Ke),St=J||Y?ct:B,Z=/* @__PURE__ */ c(u.Control,{id:U,name:je,type:$e,className:_t,disabled:Ne,readOnly:T||E,"aria-busy":E||void 0,required:h,"aria-invalid":H?`true`:`false`,"aria-describedby":gt,maxLength:k,...R===void 0?null:{value:R},...Je,...yt?{onClick:yt}:null,...bt?{onChange:bt}:null,...xt?{onBlur:xt}:null,...lt,placeholder:M===`off`?z.placeholder:` `,ref:et,...St?{onInput:St}:null}),Q=Ve??!0,Ct=Q&&typeof Q==`object`&&Q.title||Ie,wt=Y?ue(at,Ce(Ve)):null,Tt=Y?/* @__PURE__ */ c(`ul`,{className:`pw-criteria`,"aria-live":`polite`,id:ht,"aria-label":X?Ct:void 0,children:wt?.map(e=>/* @__PURE__ */ l(`li`,{className:`pw-rule ${e.met?`met`:`unmet`}`,children:[/* @__PURE__ */ c(`span`,{className:`pw-mark`,"aria-hidden":`true`}),/* @__PURE__ */ c(`span`,{className:`pw-rule-text`,children:e.label}),/* @__PURE__ */ c(`span`,{className:`visually-hidden`,children:e.met?p.requirementMetLabel:p.requirementNotMetLabel})]},e.key))}):null,$;if(M!==`off`&&m&&!W)$=/* @__PURE__ */ l(`div`,{className:M===`above`?`field-float wui-float-above`:`field-float`,children:[Z,/* @__PURE__ */ l(`label`,{className:`float-label`,htmlFor:U,children:[m,h&&/* @__PURE__ */ c(i,{})]})]});else if(Be)$=/* @__PURE__ */ l(`div`,{className:`input-action-row`,children:[/* @__PURE__ */ l(`div`,{className:x?`input-icon`:`input-wrap`,children:[x&&/* @__PURE__ */ c(`span`,{className:`ic`,children:/* @__PURE__ */ c(r,{name:x,size:16})}),Z]}),/* @__PURE__ */ c(`div`,{className:`input-action`,children:Be})]});else if(A||j)$=/* @__PURE__ */ l(`div`,{className:`input-affixed`,children:[A!=null&&/* @__PURE__ */ c(`span`,{className:`affix affix-pre`,children:A}),Z,j!=null&&/* @__PURE__ */ c(`span`,{className:`affix affix-suf`,children:j})]});else if(C)$=/* @__PURE__ */ l(`div`,{className:`input-with-unit`,children:[Z,/* @__PURE__ */ c(`span`,{className:`unit`,children:C})]});else if(W){let e=/* @__PURE__ */ l(`button`,{type:`button`,className:`pw-toggle${V?` pw-revealed`:``}`,onClick:()=>Ye(e=>!e),"aria-label":V?Re:Le,tabIndex:-1,children:[/* @__PURE__ */ c(r,{name:`eye`,size:18,className:`pw-eye`}),/* @__PURE__ */ c(r,{name:`eye-off`,size:18,className:`pw-eye-off`})]}),t=M!==`off`&&m?/* @__PURE__ */ c(`div`,{className:M===`above`?`field-float wui-float-above`:`field-float`,children:/* @__PURE__ */ l(`div`,{className:`input-wrap`,children:[Z,e,/* @__PURE__ */ l(`label`,{className:`float-label`,htmlFor:U,children:[m,h&&/* @__PURE__ */ c(i,{})]})]})}):/* @__PURE__ */ l(`div`,{className:x?`input-icon`:`input-wrap`,children:[x&&/* @__PURE__ */ c(`span`,{className:`ic`,children:/* @__PURE__ */ c(r,{name:x,size:16})}),Z,e]});$=Y&&!X&&F!==`inline`?/* @__PURE__ */ c(ae,{trigger:t,triggerType:`focus`,placement:F,title:Ct,className:`pw-popover`,children:Tt}):t}else $=S?/* @__PURE__ */ l(`div`,{className:`input-wrap`,children:[Z,/* @__PURE__ */ c(`button`,{type:`button`,className:`pw-toggle`,onClick:Oe,disabled:!Oe,tabIndex:-1,"aria-label":ke||S,children:/* @__PURE__ */ c(r,{name:S,size:18})})]}):D?/* @__PURE__ */ l(`div`,{className:x?`input-icon`:`input-wrap`,children:[x&&/* @__PURE__ */ c(`span`,{className:`ic`,children:/* @__PURE__ */ c(r,{name:x,size:16})}),Z,ft]}):x?/* @__PURE__ */ l(`div`,{className:`input-icon`,children:[/* @__PURE__ */ c(`span`,{className:`ic`,children:/* @__PURE__ */ c(r,{name:x,size:16})}),Z]}):Z;return Ue?me($,we):/* @__PURE__ */ l(u.Group,{...we,className:`field${w?` ${w}`:``}`,children:[m&&M===`off`&&/* @__PURE__ */ l(u.Label,{className:`label`,htmlFor:U,children:[m,g&&!h&&/* @__PURE__ */ c(`span`,{className:`label-optional`,children:` ${Fe}`}),h&&/* @__PURE__ */ c(i,{}),v&&/* @__PURE__ */ c(ie,{label:De,children:v})]}),$,X&&/* @__PURE__ */ c(`div`,{className:`wui-pw-inline`,children:Tt}),/* @__PURE__ */ c(t,{error:H,hint:X?null:_,errorId:pt,hintId:mt}),O&&/* @__PURE__ */ l(`div`,{className:`field-count${k&&nt>=k?` at-limit`:``}`,children:[nt,k?` / ${k}`:``]})]})});export{f as default};
1
+ import{devWarn as e}from"../lib/devWarn.js";import t from"../lib/FieldMessage.js";import{FIELD_BUSY_CLASS as n,blockWhenReadOnly as ee}from"../lib/fieldState.js";import{useFieldError as te}from"../lib/formFields.js";import ne from"../lib/useWuiText.js";import{splitMarkerProps as re}from"../lib/wuiMarker.js";import r from"./AppIcon.js";import ie from"./AppInfoTip.js";import ae from"./AppPopover.js";import i from"./AppRequiredMark.js";import a from"./assertValidValue.js";import oe from"./warnUnknownProps.js";import{MASK_INPUT_TYPES as se,MASK_NAMES as ce,attachInputMask as le,evaluatePassword as ue,formatMasked as de,isMaskPattern as fe,postedMasked as pe}from"@webority/ui-elements/helpers";import{cloneElement as me,forwardRef as he,useEffect as o,useId as ge,useRef as _e,useState as s}from"react";import{jsx as c,jsxs as l}from"react/jsx-runtime";import{INPUT_TEXT as ve}from"@webority/ui-elements/text";import{Form as u}from"react-bootstrap";var ye=[`sm`,`md`,`lg`,`xl`],be=[`bare`,`underline`],xe=[`off`,`border`,`above`],Se=[`off`,`shown`];function d(e,t){if(t!=null&&t!==``&&t!==!1)throw Error(`<AppInput> controlOnly draws no field, so it takes no ${e}; draw the label or message on the page.`)}function Ce(e){return e==null||{...`minLength`in e&&{minLength:e.minLength??0},...`uppercase`in e&&{uppercase:e.uppercase??!1},...`lowercase`in e&&{lowercase:e.lowercase??!1},...`digit`in e&&{digit:e.digit??!1},...`special`in e&&{special:e.special??!1},...`uniqueChars`in e&&{uniqueChars:e.uniqueChars??0},...`customRules`in e&&{customRules:e.customRules??[]}}}var f=he(function(he,f){let{marker:we,props:Te}=re(`AppInput`,he),p=ne(`input`,ve),{label:m,required:h=!1,optional:g=!1,error:Ee,valid:De=!1,helperText:_,help:v,helpLabel:Oe=p.helpLabel,type:y=`text`,size:b=`md`,leftIcon:x,rightIcon:S,onRightIconClick:ke,rightIconLabel:Ae,unit:C,id:je,name:Me,className:Ne=``,fieldClassName:w=``,disabled:Pe=!1,readOnly:T=!1,loading:E=!1,clearable:D=!1,clearLabel:Fe=p.clearLabel,optionalLabel:Ie=p.optionalLabel,requirementsTitle:Le=p.requirementsTitle,showPasswordLabel:Re=p.showPasswordLabel,hidePasswordLabel:ze=p.hidePasswordLabel,showCount:O=!1,maxLength:k,monospace:Be=!1,prefix:A,suffix:j,action:Ve,floatingLabel:M=`off`,variant:N,passwordRequirements:P=`off`,passwordPolicy:He,requirementsPlacement:F=`auto`,mask:I,postFormatted:L=!1,onMaskChange:Ue,controlOnly:We=!1,value:R,...z}=Te,Ge=te(Me);oe(`AppInput`,z);let{onChange:Ke,onBlur:qe,onClick:Je,onInput:B,...Ye}=z;a(`AppInput`,`size`,b,ye),a(`AppInput`,`variant`,N,be),a(`AppInput`,`floatingLabel`,M,xe),a(`AppInput`,`passwordRequirements`,P,Se),We&&(d(`label`,m),d(`error`,Ee),d(`helperText`,_),d(`fieldClassName`,w),d(`showCount`,O),d(`help`,v),d(`optional`,g),d(`floatingLabel`,M===`off`?void 0:M),d(`passwordRequirements`,P===`shown`?P:void 0)),o(()=>{g&&h&&typeof process<`u`&&process.env.NODE_ENV!==`production`&&e(`AppInput: optional and required together; optional ignored`)},[g,h]),I!=null&&!fe(I)&&a(`AppInput`,`mask`,I,ce),I!=null&&a(`AppInput`,`type`,y,se);let[V,Xe]=s(!1),[Ze,Qe]=s(``),H=Ee||Ze||Ge,$e=ge(),U=je||$e,W=y===`password`,et=W&&V?`text`:y,G=_e(null),tt=e=>{G.current=e,typeof f==`function`?f(e):f&&(f.current=e)},K=String(R??z.defaultValue??``),[nt,q]=s(()=>!!K),[rt,it]=s(()=>K.length),at=D&&!Pe&&!T&&!E,J=D||O,Y=W&&P===`shown`,[ot,st]=s(K);o(()=>{Y&&R!==void 0&&st(String(R??``))},[R,Y]),o(()=>{if(!J||R===void 0)return;let e=String(R??``);q(!!e),it(e.length)},[R,J]);let ct=e=>{let t=e.currentTarget;q(!!t.value),it(t.value.length),B?.(e)},lt=e=>{Y&&st(e.currentTarget.value),J?ct(e):B?.(e)},ut=I?{...R!==void 0&&{value:de(I,R)},...z.defaultValue!==void 0&&{defaultValue:de(I,z.defaultValue)}}:null,dt=_e(Ue);dt.current=Ue,o(()=>{let e=G.current;if(!I||!e)return;let t,n=le(e,{mask:I,postFormatted:L,onChange:(e,t)=>dt.current?.(e,t),onInvalidChange:e=>{clearTimeout(t),t=setTimeout(()=>Qe(e),0)}});return()=>{n(),clearTimeout(t),Qe(``)}},[I,L]);let ft=e=>I&&!L&&e?t=>{let n=t.currentTarget,ee=new Proxy(n,{get:(e,t)=>{if(t===`value`)return pe(I,e.value);let n=Reflect.get(e,t,e);return typeof n==`function`?n.bind(e):n}});e(Object.create(t,{target:{value:ee}}))}:e,pt=at?/* @__PURE__ */ c(`button`,{type:`button`,className:`input-clear`,onClick:()=>{let e=G.current;if(!e)return;let t=Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,`value`)?.set;t?t.call(e,``):e.value=``,e.dispatchEvent(new Event(`input`,{bubbles:!0})),q(!1),e.focus()},"aria-label":Fe,tabIndex:-1,hidden:!nt,children:/* @__PURE__ */ c(r,{name:`x`,size:16})}):null,mt=H&&U?`${U}-error`:void 0,ht=_&&U?`${U}-hint`:void 0,X=Y&&F===`inline`,gt=X&&U?`${U}-requirements`:void 0,_t=mt||(X?gt:ht),vt=[`input`,b===`sm`?`wui-input-sm`:``,b===`lg`?`wui-input-lg`:``,b===`xl`?`wui-input-xl`:``,H?`error`:``,De&&!H?`wui-valid`:``,W?`pw`:``,C?`num-input`:``,!(M!==`off`&&m||A||j||C||W||S)&&D&&at?`has-clear`:``,N===`underline`?`wui-input-underline`:N?`input-${N}`:``,Be?`wui-mono`:``,E?n:``,Ne].filter(Boolean).join(` `),yt=ee(T||E),bt=yt?e=>{yt(e),Je?.(e)}:Je,xt=ft(Ke),St=ft(qe),Ct=J||Y?lt:B,Z=/* @__PURE__ */ c(u.Control,{id:U,name:Me,type:et,className:vt,disabled:Pe,readOnly:T||E,"aria-busy":E||void 0,required:h,"aria-invalid":H?`true`:`false`,"aria-describedby":_t,maxLength:k,...R===void 0?null:{value:R},...Ye,...bt?{onClick:bt}:null,...xt?{onChange:xt}:null,...St?{onBlur:St}:null,...ut,placeholder:M===`off`?z.placeholder:` `,ref:tt,...Ct?{onInput:Ct}:null}),Q=He??!0,wt=Q&&typeof Q==`object`&&Q.title||Le,Tt=Y?ue(ot,Ce(He)):null,Et=Y?/* @__PURE__ */ c(`ul`,{className:`pw-criteria`,"aria-live":`polite`,id:gt,"aria-label":X?wt:void 0,children:Tt?.map(e=>/* @__PURE__ */ l(`li`,{className:`pw-rule ${e.met?`met`:`unmet`}`,children:[/* @__PURE__ */ c(`span`,{className:`pw-mark`,"aria-hidden":`true`}),/* @__PURE__ */ c(`span`,{className:`pw-rule-text`,children:e.label}),/* @__PURE__ */ c(`span`,{className:`visually-hidden`,children:e.met?p.requirementMetLabel:p.requirementNotMetLabel})]},e.key))}):null,$;if(M!==`off`&&m&&!W)$=/* @__PURE__ */ l(`div`,{className:M===`above`?`field-float wui-float-above`:`field-float`,children:[Z,/* @__PURE__ */ l(`label`,{className:`float-label`,htmlFor:U,children:[m,h&&/* @__PURE__ */ c(i,{})]})]});else if(Ve)$=/* @__PURE__ */ l(`div`,{className:`input-action-row`,children:[/* @__PURE__ */ l(`div`,{className:x?`input-icon`:`input-wrap`,children:[x&&/* @__PURE__ */ c(`span`,{className:`ic`,children:/* @__PURE__ */ c(r,{name:x,size:16})}),Z]}),/* @__PURE__ */ c(`div`,{className:`input-action`,children:Ve})]});else if(A||j)$=/* @__PURE__ */ l(`div`,{className:`input-affixed`,children:[A!=null&&/* @__PURE__ */ c(`span`,{className:`affix affix-pre`,children:A}),Z,j!=null&&/* @__PURE__ */ c(`span`,{className:`affix affix-suf`,children:j})]});else if(C)$=/* @__PURE__ */ l(`div`,{className:`input-with-unit`,children:[Z,/* @__PURE__ */ c(`span`,{className:`unit`,children:C})]});else if(W){let e=/* @__PURE__ */ l(`button`,{type:`button`,className:`pw-toggle${V?` pw-revealed`:``}`,onClick:()=>Xe(e=>!e),"aria-label":V?ze:Re,tabIndex:-1,children:[/* @__PURE__ */ c(r,{name:`eye`,size:18,className:`pw-eye`}),/* @__PURE__ */ c(r,{name:`eye-off`,size:18,className:`pw-eye-off`})]}),t=M!==`off`&&m?/* @__PURE__ */ c(`div`,{className:M===`above`?`field-float wui-float-above`:`field-float`,children:/* @__PURE__ */ l(`div`,{className:`input-wrap`,children:[Z,e,/* @__PURE__ */ l(`label`,{className:`float-label`,htmlFor:U,children:[m,h&&/* @__PURE__ */ c(i,{})]})]})}):/* @__PURE__ */ l(`div`,{className:x?`input-icon`:`input-wrap`,children:[x&&/* @__PURE__ */ c(`span`,{className:`ic`,children:/* @__PURE__ */ c(r,{name:x,size:16})}),Z,e]});$=Y&&!X&&F!==`inline`?/* @__PURE__ */ c(ae,{trigger:t,triggerType:`focus`,placement:F,title:wt,className:`pw-popover`,children:Et}):t}else $=S?/* @__PURE__ */ l(`div`,{className:`input-wrap`,children:[Z,/* @__PURE__ */ c(`button`,{type:`button`,className:`pw-toggle`,onClick:ke,disabled:!ke,tabIndex:-1,"aria-label":Ae||S,children:/* @__PURE__ */ c(r,{name:S,size:18})})]}):D?/* @__PURE__ */ l(`div`,{className:x?`input-icon`:`input-wrap`,children:[x&&/* @__PURE__ */ c(`span`,{className:`ic`,children:/* @__PURE__ */ c(r,{name:x,size:16})}),Z,pt]}):x?/* @__PURE__ */ l(`div`,{className:`input-icon`,children:[/* @__PURE__ */ c(`span`,{className:`ic`,children:/* @__PURE__ */ c(r,{name:x,size:16})}),Z]}):Z;return We?me($,we):/* @__PURE__ */ l(u.Group,{...we,className:`field${w?` ${w}`:``}`,children:[m&&M===`off`&&/* @__PURE__ */ l(u.Label,{className:`label`,htmlFor:U,children:[m,g&&!h&&/* @__PURE__ */ c(`span`,{className:`label-optional`,children:` ${Ie}`}),h&&/* @__PURE__ */ c(i,{}),v&&/* @__PURE__ */ c(ie,{label:Oe,children:v})]}),$,X&&/* @__PURE__ */ c(`div`,{className:`wui-pw-inline`,children:Et}),/* @__PURE__ */ c(t,{error:H,hint:X?null:_,errorId:mt,hintId:ht}),O&&/* @__PURE__ */ l(`div`,{className:`field-count${k&&rt>=k?` at-limit`:``}`,children:[rt,k?` / ${k}`:``]})]})});export{f as default};
@@ -1 +1 @@
1
- import{linkTarget as e}from"../lib/linkTarget.js";import{TargetLink as t}from"../lib/TargetLink.js";import{TONES as n}from"../lib/vocabulary.js";import{splitMarkerProps as r}from"../lib/wuiMarker.js";import i from"./AppIcon.js";import a from"./AppSparkline.js";import o from"./assertValidValue.js";import s from"./renderIconProp.js";import c from"./textOf.js";import l from"./warnUnknownProps.js";import{Fragment as u,jsx as d,jsxs as f}from"react/jsx-runtime";var p=[`plain`,`filled`,`accent`,`spotlight`],m=[`sm`,`md`,`lg`],h=n,g=[`linear`,`outline`,`bold`,`bulk`,`broken`,`twotone`],_=[`up`,`down`,`flat`],ee=n.filter(e=>[`success`,`danger`,`neutral`].includes(e)),v={success:` wui-kpi-delta--success`,danger:` wui-kpi-delta--danger`,neutral:` wui-kpi-delta--neutral`};function y(e){let t=c(e).trim();return t.startsWith(`+`)?`up`:t.startsWith(`-`)||t.startsWith(`−`)?`down`:`flat`}function b(n){let{marker:c,props:b}=r(`AppKpiTile`,n),{label:x,value:S,caption:C,icon:w,iconTone:T,iconVariant:E=`twotone`,delta:D,deltaDirection:O,deltaTone:k,sparkline:A,variant:j=`plain`,size:M=`md`,valueSize:N,inline:P=!1,attention:F=!1,href:I,linkComponent:L,className:R=``,style:z,iconClassName:B=``,labelClassName:V=``,valueClassName:H=``,captionClassName:U=``,deltaClassName:W=``,sparklineClassName:G=``,...K}=b;l(`AppKpiTile`,K),o(`AppKpiTile`,`variant`,j,p),o(`AppKpiTile`,`size`,M,m),o(`AppKpiTile`,`iconTone`,T,h),o(`AppKpiTile`,`iconVariant`,E,g),o(`AppKpiTile`,`deltaDirection`,O,_),o(`AppKpiTile`,`deltaTone`,k,ee);let q=`kpi${P?` kpi-inline`:``}${j===`filled`?` kpi-filled`:j===`accent`?` kpi-accent`:j===`spotlight`?` kpi-spotlight`:``}${M===`lg`?` kpi-lg`:M===`sm`?` kpi-sm`:``}${F?` kpi-attention`:``}${R?` ${R}`:``}`,J=typeof N==`number`&&N>0?{...z,"--wui-kpi-value-size":`${N}px`}:z,Y=O??y(D),X=Y===`up`?`arrow-up`:Y===`down`?`arrow-down`:null,Z=k!==void 0&&Object.hasOwn(v,k)?v[k]:``,Q=I==null?null:e(L,{href:I}),$=/* @__PURE__ */ f(u,{children:[w&&/* @__PURE__ */ d(`span`,{className:`kpi-icon${T?` kpi-icon-${T}`:``}${B?` ${B}`:``}`,children:s(w,{size:20,variant:E})}),/* @__PURE__ */ d(`div`,{className:`kpi-label${V?` ${V}`:``}`,children:x}),/* @__PURE__ */ d(`div`,{className:`kpi-value${H?` ${H}`:``}`,children:S}),C&&/* @__PURE__ */ d(`div`,{className:`kpi-caption${U?` ${U}`:``}`,children:C}),D&&/* @__PURE__ */ f(`div`,{className:`kpi-delta${Y===`flat`?``:` ${Y}`}${Z}${W?` ${W}`:``}`,children:[X&&/* @__PURE__ */ d(i,{name:X,size:13}),D]}),A&&A.length>0&&/* @__PURE__ */ d(a,{data:A,className:`kpi-sparkline${G?` ${G}`:``}`})]});return Q===null?/* @__PURE__ */ d(`div`,{className:q,style:J,...c,...K,children:$}):/* @__PURE__ */ d(t,{link:Q,className:q,style:J,...c,...K,children:$})}export{b as default};
1
+ import{linkTarget as e}from"../lib/linkTarget.js";import{TargetLink as t}from"../lib/TargetLink.js";import{TONES as n}from"../lib/vocabulary.js";import{splitMarkerProps as r}from"../lib/wuiMarker.js";import i from"./AppIcon.js";import a from"./AppSparkline.js";import o from"./assertValidValue.js";import s from"./renderIconProp.js";import c from"./textOf.js";import l from"./warnUnknownProps.js";import{Fragment as u,jsx as d,jsxs as f}from"react/jsx-runtime";var ee=[`plain`,`filled`,`accent`,`spotlight`],p=[`sm`,`md`,`lg`],m=n,h=[`linear`,`outline`,`bold`,`bulk`,`broken`,`twotone`],te=[`up`,`down`,`flat`],g=[1,2,3,4,5,6,7,8],_=n.filter(e=>[`success`,`danger`,`neutral`].includes(e)),v={success:` wui-kpi-delta--success`,danger:` wui-kpi-delta--danger`,neutral:` wui-kpi-delta--neutral`};function y(e){let t=c(e).trim();return t.startsWith(`+`)?`up`:t.startsWith(`-`)||t.startsWith(`−`)?`down`:`flat`}function b(n){let{marker:c,props:b}=r(`AppKpiTile`,n),{label:x,value:S,caption:C,icon:w,iconTone:T,iconVariant:E=`twotone`,delta:D,deltaDirection:O,deltaTone:k,sparkline:A,variant:j=`plain`,size:M=`md`,valueSize:N,inline:ne=!1,stacked:P=!1,iconSlot:F,attention:I=!1,href:L,linkComponent:R,className:z=``,style:B,iconClassName:V=``,labelClassName:H=``,valueClassName:U=``,captionClassName:W=``,deltaClassName:G=``,sparklineClassName:K=``,...q}=b;l(`AppKpiTile`,q),o(`AppKpiTile`,`variant`,j,ee),o(`AppKpiTile`,`size`,M,p),o(`AppKpiTile`,`iconTone`,T,m),o(`AppKpiTile`,`iconVariant`,E,h),o(`AppKpiTile`,`deltaDirection`,O,te),o(`AppKpiTile`,`deltaTone`,k,_),o(`AppKpiTile`,`iconSlot`,F,g);let J=`kpi${ne?` kpi-inline`:P||j===`spotlight`?``:` wui-kpi-picked`}${j===`filled`?` kpi-filled`:j===`accent`?` kpi-accent`:j===`spotlight`?` kpi-spotlight`:``}${M===`lg`?` kpi-lg`:M===`sm`?` kpi-sm`:``}${I?` kpi-attention`:``}${z?` ${z}`:``}`,Y=typeof N==`number`&&N>0?{...B,"--wui-kpi-value-size":`${N}px`}:B,X=O??y(D),Z=X===`up`?`arrow-up`:X===`down`?`arrow-down`:null,re=k!==void 0&&Object.hasOwn(v,k)?v[k]:``,Q=L==null?null:e(R,{href:L}),ie=F==null?``:` wui-kpi-icon-chart-${F}`,$=/* @__PURE__ */ f(u,{children:[w&&/* @__PURE__ */ d(`span`,{className:`kpi-icon${ie}${T?` kpi-icon-${T}`:``}${V?` ${V}`:``}`,children:s(w,{size:20,variant:E})}),/* @__PURE__ */ d(`div`,{className:`kpi-label${H?` ${H}`:``}`,children:x}),/* @__PURE__ */ d(`div`,{className:`kpi-value${U?` ${U}`:``}`,children:S}),C&&/* @__PURE__ */ d(`div`,{className:`kpi-caption${W?` ${W}`:``}`,children:C}),D&&/* @__PURE__ */ f(`div`,{className:`kpi-delta${X===`flat`?``:` ${X}`}${re}${G?` ${G}`:``}`,children:[Z&&/* @__PURE__ */ d(i,{name:Z,size:13}),D]}),A&&A.length>0&&/* @__PURE__ */ d(a,{data:A,className:`kpi-sparkline${K?` ${K}`:``}`})]});return Q===null?/* @__PURE__ */ d(`div`,{className:J,style:Y,...c,...q,children:$}):/* @__PURE__ */ d(t,{link:Q,className:J,style:Y,...c,...q,children:$})}export{b as default};
@@ -1 +1 @@
1
- import{devWarn as e}from"../lib/devWarn.js";import t from"../lib/FieldMessage.js";import{useFieldError as ee}from"../lib/formFields.js";import te from"../lib/useElementEntry.js";import n from"../lib/useWuiText.js";import{splitMarkerProps as r}from"../lib/wuiMarker.js";import i from"./AppInfoTip.js";import a from"./AppRequiredMark.js";import o from"./assertValidValue.js";import s from"./textOf.js";import c from"./useWuiControl.js";import l from"./warnUnknownProps.js";import{cloneElement as u,forwardRef as d,useId as f}from"react";import{jsx as p,jsxs as m}from"react/jsx-runtime";import{DATE_PICKER_TEXT as h}from"@webority/ui-elements/text";var g=[`sm`,`md`,`lg`,`xl`],_=()=>import(`@webority/ui-elements/elements/datepicker`),v=d(function(d,v){let ne=te(`wui-datepicker`,_),y=n(`datePicker`,h),{marker:b,props:x}=r(`AppMonthPicker`,d),{value:S,onChange:C,label:w,required:T=!1,optional:E=!1,optionalLabel:D=y.optionalLabel,helperText:O,error:k,name:A,min:j,max:M,placeholder:N=y.monthPlaceholder,disabled:P,readOnly:F=!1,loading:re=!1,defaultValue:I,help:L,helpLabel:R=y.helpLabel,size:z,displayFormat:B,id:V,ariaLabel:H,"aria-invalid":U,className:W=``,fieldClassName:G=``,...K}=x,q=ee(A),J=k??q;l(`AppMonthPicker`,K),o(`AppMonthPicker`,`size`,z,g),typeof B==`string`&&B!==``&&/DD|YYYY|YY/.test(B)&&e(`[@webority/ui-react] <AppMonthPicker> displayFormat "${B}" uses uppercase year or day tokens, which print as written; the month tokens are yyyy, MMMM, MMM and MM.`);let Y=f(),X=V||Y,{setRef:ie}=c({ready:ne,ref:v,value:S??(I===void 0?``:void 0),defaultValue:I,onChange:C}),ae=!w&&!J&&!O,Z=J?`${X}-error`:void 0,Q=O?`${X}-hint`:void 0,oe=Z||Q,$=/* @__PURE__ */ p(`wui-datepicker`,{ref:ie,id:X,name:A,value:(S??I)||void 0,min:j,max:M,placeholder:N,size:z||void 0,"display-format":B||void 0,"aria-label":H||s(w)||void 0,"aria-describedby":oe,"aria-invalid":U??(J?`true`:void 0),disabled:P?``:void 0,readonly:F?``:void 0,loading:re?``:void 0,required:T?``:void 0,className:W||void 0,...K,mode:`month`});return ae?u($,b):/* @__PURE__ */ m(`div`,{...b,className:`field${G?` ${G}`:``}`,children:[w&&/* @__PURE__ */ m(`label`,{className:`label`,htmlFor:X,children:[w,E&&!T&&/* @__PURE__ */ p(`span`,{className:`label-optional`,children:` ${D}`}),T&&/* @__PURE__ */ p(a,{}),L&&/* @__PURE__ */ p(i,{label:R,children:L})]}),$,/* @__PURE__ */ p(t,{error:J,hint:O,errorId:Z,hintId:Q})]})});export{v as default};
1
+ import{devWarn as e}from"../lib/devWarn.js";import t from"../lib/FieldMessage.js";import{useFieldError as n}from"../lib/formFields.js";import r from"../lib/useElementEntry.js";import i from"../lib/useWuiText.js";import{splitMarkerProps as ee}from"../lib/wuiMarker.js";import te from"./AppInfoTip.js";import ne from"./AppRequiredMark.js";import a from"./assertValidValue.js";import o from"./textOf.js";import s from"./useWuiControl.js";import c from"./warnUnknownProps.js";import{cloneElement as l,forwardRef as u,useId as d}from"react";import{jsx as f,jsxs as p}from"react/jsx-runtime";import{DATE_PICKER_TEXT as m}from"@webority/ui-elements/text";var h=[`sm`,`md`,`lg`,`xl`],g=()=>import(`@webority/ui-elements/elements/datepicker`),_=u(function(u,_){let re=r(`wui-datepicker`,g),v=i(`datePicker`,m),{marker:y,props:b}=ee(`AppMonthPicker`,u),{value:x,onChange:S,label:C,required:w=!1,optional:T=!1,optionalLabel:E=v.optionalLabel,helperText:D,error:O,name:k,min:A,max:j,placeholder:M=v.monthPlaceholder,disabled:N,readOnly:P=!1,loading:ie=!1,defaultValue:F,help:I,helpLabel:L=v.helpLabel,valueAsDate:R=!1,size:z,displayFormat:B,id:V,ariaLabel:H,"aria-invalid":U,className:W=``,fieldClassName:G=``,...K}=b,q=n(k),J=O??q;c(`AppMonthPicker`,K),a(`AppMonthPicker`,`size`,z,h),typeof B==`string`&&B!==``&&/DD|YYYY|YY/.test(B)&&e(`[@webority/ui-react] <AppMonthPicker> displayFormat "${B}" uses uppercase year or day tokens, which print as written; the month tokens are yyyy, MMMM, MMM and MM.`);let Y=d(),X=V||Y,{setRef:ae}=s({ready:re,ref:_,value:x??(F===void 0?``:void 0),defaultValue:F,onChange:S}),oe=!C&&!J&&!D,Z=J?`${X}-error`:void 0,Q=D?`${X}-hint`:void 0,se=Z||Q,$=/* @__PURE__ */ f(`wui-datepicker`,{ref:ae,id:X,name:k,value:(x??F)||void 0,min:A,max:j,placeholder:M,size:z||void 0,"display-format":B||void 0,"aria-label":H||o(C)||void 0,"aria-describedby":se,"aria-invalid":U??(J?`true`:void 0),disabled:N?``:void 0,readonly:P?``:void 0,loading:ie?``:void 0,required:w?``:void 0,className:W||void 0,"value-as-date":R?``:void 0,...K,mode:`month`});return oe?l($,y):/* @__PURE__ */ p(`div`,{...y,className:`field${G?` ${G}`:``}`,children:[C&&/* @__PURE__ */ p(`label`,{className:`label`,htmlFor:X,children:[C,T&&!w&&/* @__PURE__ */ f(`span`,{className:`label-optional`,children:` ${E}`}),w&&/* @__PURE__ */ f(ne,{}),I&&/* @__PURE__ */ f(te,{label:L,children:I})]}),$,/* @__PURE__ */ f(t,{error:J,hint:D,errorId:Z,hintId:Q})]})});export{_ as default};
@@ -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{splitMarkerProps as i}from"../lib/wuiMarker.js";import a from"./renderIconProp.js";import o from"./warnUnknownProps.js";import{useId as s}from"react";import{jsx as c,jsxs as l}from"react/jsx-runtime";import{NAVIGATION_MENU_TEXT as u}from"@webority/ui-elements/text";var d=()=>import(`@webority/ui-elements/elements/navigation-menu`);function f(f){n(`wui-navigation-menu`,d);let p=r(`navigationMenu`,u),{marker:m,props:h}=i(`AppNavigationMenu`,f),{items:g=[],ariaLabel:_=p.ariaLabel,linkComponent:v,className:y=``,...b}=h;o(`AppNavigationMenu`,b);let x=s();return/* @__PURE__ */ c(`wui-navigation-menu`,{class:[`wui-nav-menu`,y].filter(Boolean).join(` `),...m,...b,children:/* @__PURE__ */ c(`nav`,{"aria-label":_,children:/* @__PURE__ */ c(`ul`,{className:`wui-nav-menu-list`,children:g.map(n=>{if(!n.links?.length)return/* @__PURE__ */ c(`li`,{className:`wui-nav-menu-item`,children:/* @__PURE__ */ c(t,{link:e(v,{href:n.to}),className:`wui-nav-menu-toplink`,"aria-current":n.current?`page`:void 0,children:n.label})},n.key);let r=`${x}-${n.key}`;return/* @__PURE__ */ l(`li`,{className:`wui-nav-menu-item`,children:[/* @__PURE__ */ l(`button`,{type:`button`,className:`wui-nav-menu-trigger`,"aria-expanded":`false`,"aria-controls":r,"data-key":n.key,children:[n.label,a(`chevron-down`,{size:14,className:`wui-nav-menu-chevron`})]}),/* @__PURE__ */ c(`div`,{className:`wui-nav-menu-panel`,id:r,children:/* @__PURE__ */ c(`ul`,{className:`wui-nav-menu-links`,children:n.links.map(n=>/* @__PURE__ */ c(`li`,{children:/* @__PURE__ */ l(t,{link:e(v,{href:n.to}),className:`wui-nav-menu-link`,"aria-current":n.current?`page`:void 0,children:[a(n.icon,{size:18}),/* @__PURE__ */ l(`span`,{className:`wui-nav-menu-link-text`,children:[/* @__PURE__ */ c(`span`,{className:`wui-nav-menu-link-label`,children:n.label}),n.description?/* @__PURE__ */ c(`span`,{className:`wui-nav-menu-link-desc`,children:n.description}):null]})]})},n.key))})})]},n.key)})})})})}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{splitMarkerProps as i}from"../lib/wuiMarker.js";import a from"./renderIconProp.js";import o from"./warnUnknownProps.js";import{Fragment as s,useId as c}from"react";import{jsx as l,jsxs as u}from"react/jsx-runtime";import{NAVIGATION_MENU_TEXT as d}from"@webority/ui-elements/text";var f=()=>import(`@webority/ui-elements/elements/navigation-menu`);function p(p){n(`wui-navigation-menu`,f);let m=r(`navigationMenu`,d),{marker:h,props:g}=i(`AppNavigationMenu`,p),{items:_=[],ariaLabel:v=m.ariaLabel,linkComponent:y,className:b=``,...x}=g;o(`AppNavigationMenu`,x);let S=c();return/* @__PURE__ */ l(`wui-navigation-menu`,{class:[`wui-nav-menu`,b].filter(Boolean).join(` `),...h,...x,children:/* @__PURE__ */ l(`nav`,{"aria-label":v,children:/* @__PURE__ */ l(`ul`,{className:`wui-nav-menu-list`,children:_.map((n,r)=>{let i=n.group&&n.group!==_[r-1]?.group?/* @__PURE__ */ l(`li`,{className:`wui-nav-menu-group`,role:`presentation`,children:n.group},`${n.key}-group`):null;if(!n.links?.length)return/* @__PURE__ */ u(s,{children:[i,/* @__PURE__ */ l(`li`,{className:`wui-nav-menu-item`,children:/* @__PURE__ */ l(t,{link:e(y,{href:n.to}),className:`wui-nav-menu-toplink`,"aria-current":n.current?`page`:void 0,children:n.label})})]},n.key);let o=`${S}-${n.key}`;return/* @__PURE__ */ u(s,{children:[i,/* @__PURE__ */ u(`li`,{className:`wui-nav-menu-item`,children:[/* @__PURE__ */ u(`button`,{type:`button`,className:n.current?`wui-nav-menu-trigger is-current`:`wui-nav-menu-trigger`,"aria-expanded":`false`,"aria-controls":o,"data-key":n.key,children:[n.label,a(`chevron-down`,{size:14,className:`wui-nav-menu-chevron`})]}),/* @__PURE__ */ l(`div`,{className:`wui-nav-menu-panel`,id:o,children:/* @__PURE__ */ l(`ul`,{className:`wui-nav-menu-links`,children:n.links.map(n=>/* @__PURE__ */ l(`li`,{children:/* @__PURE__ */ u(t,{link:e(y,{href:n.to}),className:`wui-nav-menu-link`,"aria-current":n.current?`page`:void 0,children:[a(n.icon,{size:18}),/* @__PURE__ */ u(`span`,{className:`wui-nav-menu-link-text`,children:[/* @__PURE__ */ l(`span`,{className:`wui-nav-menu-link-label`,children:n.label}),n.description?/* @__PURE__ */ l(`span`,{className:`wui-nav-menu-link-desc`,children:n.description}):null]})]})},n.key))})})]})]},n.key)})})})})}export{p as default};
@@ -1 +1 @@
1
- import{devWarn as e}from"../lib/devWarn.js";import t from"../lib/FieldMessage.js";import{FIELD_SIZES as n}from"../lib/fieldState.js";import{loadFlagStyles as r}from"../lib/flagStyles.js";import{useFieldError as ee}from"../lib/formFields.js";import te from"../lib/useElementEntry.js";import ne from"../lib/useWuiText.js";import{splitMarkerProps as re}from"../lib/wuiMarker.js";import ie from"./AppInfoTip.js";import ae from"./AppRequiredMark.js";import i from"./assertValidValue.js";import a from"./textOf.js";import oe from"./useNodeLabels.js";import se,{optionsEqual as ce}from"./useWuiControl.js";import le from"./warnUnknownProps.js";import{forwardRef as o,useEffect as ue,useId as de,useLayoutEffect as s,useMemo as fe,useRef as c}from"react";import{Fragment as pe,jsx as l,jsxs as u}from"react/jsx-runtime";import{SELECT_TEXT as me,fillText as he}from"@webority/ui-elements/text";var ge=[`single`,`multiple`,`search`,`tag`,`country`],_e=[`comfortable`,`compact`],ve=[`off`,`border`,`above`],ye=[],d=[],be=()=>import(`@webority/ui-elements/elements/select`),xe=e=>e===`multiple`||e===`tag`,f=e=>e!=null&&e!==``,p=e=>{throw Error(`<AppSelect> controlOnly draws no field, so it takes no ${e}; draw the label or message on the page.`)},Se=(e,t)=>{let n=t??``;String(e.value??``)!==String(n)&&(e.value=n)},Ce=(e,t)=>{let n=Array.isArray(t)?t:d,r=Array.isArray(e.value)?e.value:d;n.length===r.length&&n.every((e,t)=>e===r[t])||(e.value=n)},we=(e,t)=>({...e,label:t}),Te=e=>Array.isArray(e)?e.join(`,`):e,m=o(function(o,m){let h=te(`wui-select`,be),{marker:g,props:Ee}=re(`AppSelect`,o),_=ne(`select`,me),{mode:v=`single`,density:y=`comfortable`,size:b,value:De,defaultValue:Oe,onChange:ke,options:x=ye,loadOptions:S,remote:C=!1,onSearch:Ae,source:w,validate:T,placeholder:je,searchPlaceholder:Me,emptyText:Ne,searchable:E,clearable:Pe=!1,openOnHover:Fe=!1,icon:Ie,valuePrefix:D,prefix:O,suffix:k,floatingLabel:A=`off`,disabled:Le,readOnly:Re=!1,loading:ze=!1,open:Be,label:j,required:M=!1,optional:Ve=!1,optionalLabel:He=_.optionalLabel,error:Ue,helperText:N,help:P,helpLabel:We=_.helpLabel,id:Ge,name:F,minChars:I,debounce:L,allowCustom:Ke=!1,addLabel:qe,searchingText:Je,hintText:Ye,valueLabel:Xe,valueAvatar:Ze,valueInitials:Qe,maxTags:R,allowDuplicates:$e=!1,separators:et,pattern:tt,invalidMessage:nt,createLabel:rt,collapseChips:it=!1,selectedText:at,clearAllLabel:ot,countries:st,suggested:ct,suggestedLabel:lt,allCountriesLabel:ut,recentsKey:dt,recentsLimit:z,recentsLabel:ft,className:pt=``,fieldClassName:B=``,controlOnly:V=!1,"aria-label":mt,"aria-labelledby":ht,"aria-describedby":gt,"aria-invalid":_t,...H}=Ee,vt=ee(F),U=Ue??vt;le(`AppSelect`,H),i(`AppSelect`,`mode`,v,ge),i(`AppSelect`,`density`,y,_e),i(`AppSelect`,`size`,b,n);let W=xe(v);if(i(`AppSelect`,`floatingLabel`,A,W?[`off`]:ve),w&&(C||S))throw Error(`<AppSelect> source answers each query from the server, so it takes no remote or loadOptions; drop one of them.`);let G=c(!1);W&&(O!=null||k!=null)&&!G.current&&(G.current=!0,e(`AppSelect: prefix and suffix are not drawn in mode="${v}"; they are ignored.`));let yt=de(),K=c(!1);ue(()=>{v===`country`&&r()},[v]);let{setRef:bt,innerRef:q}=se({ready:h,ref:m,value:De??(Oe===void 0?W?d:``:void 0),defaultValue:Oe,writeValue:W?Ce:Se,on:{change:e=>{let t=e.currentTarget.value,n={isCustom:!!e.detail?.isCustom};switch(o.mode){case`multiple`:Array.isArray(t)&&o.onChange?.(t);break;case`tag`:Array.isArray(t)&&o.onChange?.(t,n);break;case`search`:typeof t==`string`&&o.onChange?.(t,n);break;default:typeof t==`string`&&o.onChange?.(t)}},search:e=>{C&&typeof S!=`function`&&Ae?.(e.detail.query,{seq:e.detail.seq})}}}),xt=fe(()=>typeof S==`function`?(e,t)=>new Promise(n=>n(S(e,t))).then(e=>(K.current=!0,e),e=>{throw K.current=!0,e}):null,[S]),{portal:St,toElementOptions:J}=oe(x),Y=c({el:null,options:null,map:null});s(()=>{let e=q.current;if(!e||!h||Y.current.el===e&&Y.current.options===x&&Y.current.map===J||(Y.current={el:e,options:x,map:J},S&&K.current))return;let t=J(x,we);ce(t,e.options)||(e.options=t)}),s(()=>{let e=q.current;if(!e||!h)return;e.loadOptions!==xt&&(e.loadOptions=xt);let t=typeof T==`function`?T:null;e.validate!==t&&(e.validate=t)}),s(()=>{q.current?.toggleAttribute(`loading`,!!ze)});let X=Ge||yt,Z=!W&&A!==`off`&&j,Ct=U&&X?`${X}-error`:void 0,wt=N&&X?`${X}-hint`:void 0,Tt=Ct||wt||gt;ue(()=>{let e=q.current;e&&(D==null||D===``?e.removeAttribute(`prefix`):e.setAttribute(`prefix`,D))},[D,q]);let Et=!W&&!Z&&(O!=null||k!=null),Dt=v===`multiple`||v===`tag`||v===`country`;if(V&&(f(j)&&p(`label`),f(U)&&p(`error`),f(N)&&p(`helperText`),f(B)&&p(`fieldClassName`),Dt))throw Error(`<AppSelect> controlOnly draws no field, so it takes no mode="${v}"; that mode always draws its field.`);let Q=V||!Dt&&!j&&!U&&!N&&!B,Ot=a(j).trim(),kt=Ot&&(v===`single`||v===`multiple`||v===`search`)?he(_.defaultSearchPlaceholder,{labelText:Ot}):void 0,At=/* @__PURE__ */ l(`wui-select`,{"aria-label":mt||a(j)||void 0,"aria-labelledby":ht||void 0,"aria-describedby":Tt||void 0,"aria-invalid":_t??(U?`true`:void 0),ref:bt,id:X,name:F,mode:v,density:y===`compact`?`compact`:void 0,placeholder:Z?` `:je||void 0,"search-placeholder":Me||kt,"empty-text":Ne||void 0,searchable:E===void 0?void 0:E?`true`:`false`,clearable:Pe?``:void 0,"open-on-hover":Fe?``:void 0,size:b!==`md`&&n.includes(b??``)?b:void 0,icon:Ie||void 0,disabled:Le?``:void 0,readonly:Re?``:void 0,open:Be?``:void 0,required:M?``:void 0,"min-chars":I==null?void 0:String(I),debounce:L==null?void 0:String(L),remote:C?``:void 0,source:w||void 0,"allow-custom":Ke?``:void 0,"add-label":qe||void 0,"searching-text":Je||void 0,"hint-text":Ye||void 0,"value-label":Xe||void 0,"value-avatar":Ze||void 0,"value-initials":Qe||void 0,"max-tags":R==null?void 0:String(R),"allow-duplicates":$e?``:void 0,separators:et||void 0,pattern:tt||void 0,"invalid-message":nt||void 0,"create-label":rt||void 0,"collapse-chips":it?``:void 0,"selected-text":at||void 0,"clear-all-label":ot||void 0,countries:Te(st)||void 0,suggested:Te(ct)||void 0,"suggested-label":lt||void 0,"all-countries-label":ut||void 0,"recents-key":dt||void 0,"recents-limit":z==null?void 0:String(z),"recents-label":ft||void 0,className:pt||void 0,...Q&&!Et?g:null,...H}),$=/* @__PURE__ */ u(pe,{children:[At,St]}),jt=Et?/* @__PURE__ */ u(`div`,{...Q?g:null,className:`input-affixed`,children:[O!=null&&/* @__PURE__ */ l(`span`,{className:`affix affix-pre`,children:O}),$,k!=null&&/* @__PURE__ */ l(`span`,{className:`affix affix-suf`,children:k})]}):$;if(Q)return jt;let Mt=[`field`,B].filter(Boolean).join(` `);return/* @__PURE__ */ u(`div`,{...g,className:Mt,children:[j&&!Z&&/* @__PURE__ */ u(`label`,{className:`label`,htmlFor:X,children:[j,Ve&&!M&&/* @__PURE__ */ l(`span`,{className:`label-optional`,children:` ${He}`}),M&&/* @__PURE__ */ l(ae,{}),P&&/* @__PURE__ */ l(ie,{label:We,children:P})]}),Z?/* @__PURE__ */ u(`div`,{className:A===`above`?`field-float wui-float-above`:`field-float`,children:[$,/* @__PURE__ */ u(`label`,{className:`float-label`,htmlFor:X,children:[j,Ve&&!M&&/* @__PURE__ */ l(`span`,{className:`label-optional`,children:` ${He}`}),M&&/* @__PURE__ */ l(ae,{})]})]}):jt,/* @__PURE__ */ l(t,{error:U,hint:N,errorId:Ct,hintId:wt})]})});export{m as default};
1
+ import{devWarn as e}from"../lib/devWarn.js";import t from"../lib/FieldMessage.js";import{FIELD_SIZES as n}from"../lib/fieldState.js";import{loadFlagStyles as r}from"../lib/flagStyles.js";import{useFieldError as ee}from"../lib/formFields.js";import te from"../lib/useElementEntry.js";import ne from"../lib/useWuiText.js";import{splitMarkerProps as re}from"../lib/wuiMarker.js";import ie from"./AppInfoTip.js";import i from"./AppRequiredMark.js";import a from"./assertValidValue.js";import ae from"./textOf.js";import oe from"./useNodeLabels.js";import se,{optionsEqual as ce}from"./useWuiControl.js";import le from"./warnUnknownProps.js";import{forwardRef as o,useEffect as s,useId as ue,useLayoutEffect as c,useMemo as de,useRef as l}from"react";import{Fragment as fe,jsx as u,jsxs as d}from"react/jsx-runtime";import{SELECT_TEXT as pe,fillText as me}from"@webority/ui-elements/text";var he=[`single`,`multiple`,`search`,`tag`,`country`],ge=[`comfortable`,`compact`],_e=[`off`,`border`,`above`],ve=[],f=[],ye=()=>import(`@webority/ui-elements/elements/select`),be=e=>e===`multiple`||e===`tag`,p=e=>e!=null&&e!==``,m=e=>{throw Error(`<AppSelect> controlOnly draws no field, so it takes no ${e}; draw the label or message on the page.`)},xe=(e,t)=>{let n=t??``;String(e.value??``)!==String(n)&&(e.value=n)},Se=(e,t)=>{let n=Array.isArray(t)?t:f,r=Array.isArray(e.value)?e.value:f;n.length===r.length&&n.every((e,t)=>e===r[t])||(e.value=n)},Ce=(e,t)=>({...e,label:t}),h=e=>Array.isArray(e)?e.join(`,`):e,g=o(function(o,g){let _=te(`wui-select`,ye),{marker:v,props:we}=re(`AppSelect`,o),y=ne(`select`,pe),{mode:b=`single`,density:x=`comfortable`,size:S,value:Te,defaultValue:Ee,onChange:De,options:C=ve,loadOptions:w,remote:T=!1,onSearch:Oe,source:E,validate:ke,placeholder:Ae,searchPlaceholder:je,emptyText:Me,searchable:D,clearable:Ne=!1,openOnHover:Pe=!1,lazyOptions:Fe=!1,icon:Ie,valuePrefix:O,prefix:k,suffix:A,floatingLabel:j=`off`,disabled:Le,readOnly:Re=!1,loading:ze=!1,open:Be,label:M,required:N=!1,optional:Ve=!1,optionalLabel:He=y.optionalLabel,error:Ue,valid:We=!1,helperText:P,help:Ge,helpLabel:Ke=y.helpLabel,id:qe,name:F,minChars:I,debounce:L,allowCustom:Je=!1,addLabel:Ye,searchingText:Xe,hintText:Ze,valueLabel:Qe,valueAvatar:$e,valueInitials:et,maxTags:R,allowDuplicates:tt=!1,separators:nt,pattern:rt,invalidMessage:it,createLabel:at,collapseChips:ot=!1,selectedText:st,clearAllLabel:ct,countries:lt,suggested:ut,suggestedLabel:dt,allCountriesLabel:ft,recentsKey:pt,recentsLimit:z,recentsLabel:mt,className:ht=``,fieldClassName:B=``,controlOnly:V=!1,"aria-label":gt,"aria-labelledby":_t,"aria-describedby":vt,"aria-invalid":yt,...H}=we,bt=ee(F),U=Ue??bt;le(`AppSelect`,H),a(`AppSelect`,`mode`,b,he),a(`AppSelect`,`density`,x,ge),a(`AppSelect`,`size`,S,n);let W=be(b);if(a(`AppSelect`,`floatingLabel`,j,W?[`off`]:_e),E&&(T||w))throw Error(`<AppSelect> source answers each query from the server, so it takes no remote or loadOptions; drop one of them.`);let G=l(!1);W&&(k!=null||A!=null)&&!G.current&&(G.current=!0,e(`AppSelect: prefix and suffix are not drawn in mode="${b}"; they are ignored.`));let xt=ue(),K=l(!1);s(()=>{b===`country`&&r()},[b]);let{setRef:St,innerRef:q}=se({ready:_,ref:g,value:Te??(Ee===void 0?W?f:``:void 0),defaultValue:Ee,writeValue:W?Se:xe,on:{change:e=>{let t=e.currentTarget.value,n={isCustom:!!e.detail?.isCustom};switch(o.mode){case`multiple`:Array.isArray(t)&&o.onChange?.(t);break;case`tag`:Array.isArray(t)&&o.onChange?.(t,n);break;case`search`:typeof t==`string`&&o.onChange?.(t,n);break;default:typeof t==`string`&&o.onChange?.(t)}},search:e=>{T&&typeof w!=`function`&&Oe?.(e.detail.query,{seq:e.detail.seq})}}}),Ct=de(()=>typeof w==`function`?(e,t)=>new Promise(n=>n(w(e,t))).then(e=>(K.current=!0,e),e=>{throw K.current=!0,e}):null,[w]),{portal:wt,toElementOptions:J}=oe(C),Y=l({el:null,options:null,map:null});c(()=>{let e=q.current;if(!e||!_||Y.current.el===e&&Y.current.options===C&&Y.current.map===J||(Y.current={el:e,options:C,map:J},w&&K.current))return;let t=J(C,Ce);ce(t,e.options)||(e.options=t)}),c(()=>{let e=q.current;if(!e||!_)return;e.loadOptions!==Ct&&(e.loadOptions=Ct);let t=typeof ke==`function`?ke:null;e.validate!==t&&(e.validate=t)}),c(()=>{q.current?.toggleAttribute(`loading`,!!ze)});let X=qe||xt,Z=!W&&j!==`off`&&M,Tt=U&&X?`${X}-error`:void 0,Et=P&&X?`${X}-hint`:void 0,Dt=Tt||Et||vt;s(()=>{let e=q.current;e&&(O==null||O===``?e.removeAttribute(`prefix`):e.setAttribute(`prefix`,O))},[O,q]);let Ot=!W&&!Z&&(k!=null||A!=null),kt=b===`multiple`||b===`tag`||b===`country`;if(V&&(p(M)&&m(`label`),p(U)&&m(`error`),p(P)&&m(`helperText`),p(B)&&m(`fieldClassName`),kt))throw Error(`<AppSelect> controlOnly draws no field, so it takes no mode="${b}"; that mode always draws its field.`);let Q=V||!kt&&!M&&!U&&!P&&!B,At=ae(M).trim(),jt=At&&(b===`single`||b===`multiple`||b===`search`)?me(y.defaultSearchPlaceholder,{labelText:At}):void 0,Mt=[ht,We&&!U?`wui-valid`:``].filter(Boolean).join(` `),Nt=/* @__PURE__ */ u(`wui-select`,{"aria-label":gt||ae(M)||void 0,"aria-labelledby":_t||void 0,"aria-describedby":Dt||void 0,"aria-invalid":yt??(U?`true`:void 0),ref:St,id:X,name:F,mode:b,density:x===`compact`?`compact`:void 0,placeholder:Z?` `:Ae||void 0,"search-placeholder":je||jt,"empty-text":Me||void 0,searchable:D===void 0?void 0:D?`true`:`false`,clearable:Ne?``:void 0,"open-on-hover":Pe?``:void 0,"lazy-options":Fe?``:void 0,size:S!==`md`&&n.includes(S??``)?S:void 0,icon:Ie||void 0,disabled:Le?``:void 0,readonly:Re?``:void 0,open:Be?``:void 0,required:N?``:void 0,"min-chars":I==null?void 0:String(I),debounce:L==null?void 0:String(L),remote:T?``:void 0,source:E||void 0,"allow-custom":Je?``:void 0,"add-label":Ye||void 0,"searching-text":Xe||void 0,"hint-text":Ze||void 0,"value-label":Qe||void 0,"value-avatar":$e||void 0,"value-initials":et||void 0,"max-tags":R==null?void 0:String(R),"allow-duplicates":tt?``:void 0,separators:nt||void 0,pattern:rt||void 0,"invalid-message":it||void 0,"create-label":at||void 0,"collapse-chips":ot?``:void 0,"selected-text":st||void 0,"clear-all-label":ct||void 0,countries:h(lt)||void 0,suggested:h(ut)||void 0,"suggested-label":dt||void 0,"all-countries-label":ft||void 0,"recents-key":pt||void 0,"recents-limit":z==null?void 0:String(z),"recents-label":mt||void 0,className:Mt||void 0,...Q&&!Ot?v:null,...H}),$=/* @__PURE__ */ d(fe,{children:[Nt,wt]}),Pt=Ot?/* @__PURE__ */ d(`div`,{...Q?v:null,className:`input-affixed`,children:[k!=null&&/* @__PURE__ */ u(`span`,{className:`affix affix-pre`,children:k}),$,A!=null&&/* @__PURE__ */ u(`span`,{className:`affix affix-suf`,children:A})]}):$;if(Q)return Pt;let Ft=[`field`,B].filter(Boolean).join(` `);return/* @__PURE__ */ d(`div`,{...v,className:Ft,children:[M&&!Z&&/* @__PURE__ */ d(`label`,{className:`label`,htmlFor:X,children:[M,Ve&&!N&&/* @__PURE__ */ u(`span`,{className:`label-optional`,children:` ${He}`}),N&&/* @__PURE__ */ u(i,{}),Ge&&/* @__PURE__ */ u(ie,{label:Ke,children:Ge})]}),Z?/* @__PURE__ */ d(`div`,{className:j===`above`?`field-float wui-float-above`:`field-float`,children:[$,/* @__PURE__ */ d(`label`,{className:`float-label`,htmlFor:X,children:[M,Ve&&!N&&/* @__PURE__ */ u(`span`,{className:`label-optional`,children:` ${He}`}),N&&/* @__PURE__ */ u(i,{})]})]}):Pt,/* @__PURE__ */ u(t,{error:U,hint:P,errorId:Tt,hintId:Et})]})});export{g 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 ee,fillText as M}from"@webority/ui-elements/text";var N=()=>import(`@webority/ui-elements/elements/overflow`),P=()=>import(`@webority/ui-elements/elements/dropdown`),F=99,I=4,L=5,R=/^[a-z0-9-]+$/,z=`wui-sidebar-footer`,B=[],V=[`prefix`,`exact`],H=[`comfortable`,`compact`],U=[`neutral`,`primary`],te=[`default`,`brand`],ne=[`side`,`top`],re=[`linear`,`outline`,`bold`,`bulk`,`broken`,`twotone`],ie=/* @__PURE__ */ new Set([`key`,`label`,`icon`,`iconVariant`,`iconSize`,`href`,`badge`,`badgeTone`,`badgeTitle`,`newUntil`,`trailingIcon`,`active`,`match`,`matchAlso`,`tab`,`tabLabel`,`children`]),W=e=>e>F?`${F}+`:String(e),G=new Intl.DateTimeFormat(`en-CA`,{timeZone:y}),ae=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:G.format(/* @__PURE__ */ new Date)<=e},oe=({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(` `)},se=({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 K(e){let{marker:t,props:n}=f(`AppShell`,e),c=u(`shell`,ee),{groups:l=[],brand:d,logoLight:p,logoDark:m,markLight:y,markDark:x,brandName:T,brandHref:M,brandLabel:N,sidebarStart:P,sidebarStartCompact:F,sidebarFooter:I,sidebarFooterItems:L=B,topbarStart:R,topbarEnd:z,footer:V,launcher:ie,children:W,collapsed:G,onCollapsedChange:ae,noSidebar:K=!1,nav:q=`side`,density:J=`comfortable`,itemHeight:le,iconVariant:Y=`twotone`,topbarTone:ue=`neutral`,tone:X=`default`,navLabel:ye=c.navLabel,linkComponent:Z,currentPath:xe,rememberCollapsed:Se=!1,collapsedCookie:Ce=`wui-shell-collapsed`,foldedCookie:we=r,tabBarLabel:Te=c.tabBarLabel,moreLabel:Ee=c.moreLabel,skipLabel:De=c.skipLabel,openNavLabel:Oe=c.openNavLabel,expandNavLabel:ke=c.expandNavLabel,collapseNavLabel:Ae=c.collapseNavLabel,newLabel:je=c.newLabel,togglePagesLabel:Me=c.togglePagesLabel,accountMenuLabel:Ne=c.accountMenuLabel,roleLabel:Pe=c.roleLabel,rolesLabel:Fe=c.rolesLabel,unreadLabel:Ie=c.unreadLabel,markAllReadLabel:Le=c.markAllReadLabel,viewAllLabel:Re=c.viewAllLabel,loadingNotificationsText:ze=c.loadingNotificationsText,noUnreadText:Be=c.noUnreadText,unreadNotificationsText:Ve=c.unreadNotificationsText,unreadBellLabel:He=c.unreadBellLabel,searchResultsLabel:Ue=c.searchResultsLabel,noResultsText:We=c.noResultsText,noResultsForText:Ge=c.noResultsForText,resultsCountText:Ke=c.resultsCountText,resultCountText:qe=c.resultCountText,userMenu:Je,notifications:Ye,search:Xe,className:Ze=``,style:Qe,...$e}=n;if(v(`AppShell`,$e),_(`AppShell`,`density`,J,H),_(`AppShell`,`topbarTone`,ue,U),_(`AppShell`,`tone`,X,te),_(`AppShell`,`nav`,q,ne),_(`AppShell`,`iconVariant`,Y,re),N!==void 0&&!M)throw Error(`<AppShell> brandLabel names the brand link, so it needs brandHref.`);if(M){if(!N&&!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 et=(le??0)>0?{...Qe,"--wui-nav-item-height":`${le}px`}:Qe,[tt,nt]=O(()=>Se&&G===void 0&&typeof document<`u`?a(Ce)??!1:!1),[rt,Q]=O(!1),it=D(null),[at,ot]=O(!1),[st,ct]=O(!1),lt=D(null),ut=G??tt,dt=e=>M?/* @__PURE__ */ A(pe,{href:M,label:N||T,linkComponent:Z,onNavigate:()=>Q(!1),children:e}):e,ft=()=>{let e=!ut;G===void 0&&nt(e),Se&&s(e,Ce),ae?.(e)},pt=l.some(e=>e.collapsible),[mt,ht]=O(()=>pt&&typeof document<`u`?i(we):/* @__PURE__ */ new Set),gt=e=>{let t=new Set(mt);t.has(e)?t.delete(e):t.add(e),ht(t),o(t,we)},_t=E(()=>ce(l,L,xe),[l,L,xe]),$=_t.groups,vt=_t.footer,yt=K?null:de($,vt.some(e=>e.active));w(()=>{let e=()=>ot(window.scrollY>4);return e(),window.addEventListener(`scroll`,e,{passive:!0}),()=>window.removeEventListener(`scroll`,e)},[]),w(()=>{b()},[]),w(()=>{S(lt.current)},[]),w(()=>{let e=lt.current;if(!e)return;let t=()=>ct($.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=it.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=it.current;e?.hasAttribute(`popover`)&&C(e,rt)},[rt]);let bt=[`app-shell`,ut?`collapsed`:``,K?`no-sidebar`:``,q===`top`?`wui-shell-top`:``,rt?`mobile-open`:``,Ze].filter(Boolean).join(` `);return/* @__PURE__ */ j(`div`,{className:bt,"data-density":J===`compact`?`compact`:void 0,"data-shell-tone":X===`brand`?`brand`:void 0,"data-wui-folded-cookie":pt?we:void 0,style:et,...t,...$e,children:[/* @__PURE__ */ A(`a`,{className:`wui-skip-link`,href:`#main-content`,children:De}),/* @__PURE__ */ j(`aside`,{className:`app-sidebar`,ref:it,children:[(d||p||m||y||x)&&/* @__PURE__ */ A(`div`,{className:oe({logoLight:p,logoDark:m,markLight:y,markDark:x}),children:dt(/* @__PURE__ */ j(k,{children:[se({logoLight:p,logoDark:m,markLight:y,markDark:x,brandName:T}),d]}))}),P&&/* @__PURE__ */ A(`div`,{className:`app-sidebar-start`,children:P}),F&&/* @__PURE__ */ A(`div`,{className:`app-sidebar-start-compact`,children:F}),/* @__PURE__ */ A(`nav`,{className:`app-sidebar-scroll`,"aria-label":ye,ref:lt,tabIndex:st?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:Y,newLabel:je,togglePagesLabel:Me},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=!mt.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:()=>gt(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}`)})}),(I||vt.length>0)&&/* @__PURE__ */ j(`div`,{className:`app-sidebar-foot`,children:[vt.length>0&&/* @__PURE__ */ A(`div`,{className:`wui-sidebar-foot-links`,children:vt.map(e=>/* @__PURE__ */ A(ge,{item:e,linkComponent:Z,onNavigate:()=>Q(!1),iconVariant:Y,newLabel:je,togglePagesLabel:Me},e.key??e.href??e.label))}),I]}),!K&&/* @__PURE__ */ A(`button`,{type:`button`,className:`app-sidebar-toggle`,onClick:ft,"aria-label":ut?ke:Ae,"aria-expanded":!ut,children:/* @__PURE__ */ A(h,{name:`chevrons-left`,size:20})})]}),/* @__PURE__ */ j(`div`,{className:`app-main`,children:[/* @__PURE__ */ j(`header`,{className:`app-topbar${at?` wui-scrolled`:``}`,"data-tone":ue===`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":Oe,"aria-expanded":rt,children:/* @__PURE__ */ A(h,{name:`menu`,size:18})}),q===`top`&&d&&/* @__PURE__ */ A(`div`,{className:`wui-shell-top-brand`,children:dt(d)}),q===`top`&&/* @__PURE__ */ A(`div`,{className:`wui-shell-top-nav`,children:/* @__PURE__ */ A(g,{items:fe($),ariaLabel:ye,linkComponent:Z})}),R,Xe&&/* @__PURE__ */ A(be,{config:Xe,searchResultsLabel:Ue,noResultsText:We,noResultsForText:Ge,resultsCountText:Ke,resultCountText:qe,moreLabel:Ee})]}),/* @__PURE__ */ j(`div`,{className:`app-topbar-end`,children:[z,Ye&&/* @__PURE__ */ A(ve,{config:Ye,unreadLabel:Ie,markAllReadLabel:Le,viewAllLabel:Re,loadingNotificationsText:ze,noUnreadText:Be,unreadNotificationsText:Ve,unreadBellLabel:He}),Je&&/* @__PURE__ */ A(_e,{config:Je,linkComponent:Z,accountMenuLabel:Ne,roleLabel:Pe,rolesLabel:Fe})]})]}),/* @__PURE__ */ A(`main`,{className:`app-content`,id:`main-content`,children:W}),V&&/* @__PURE__ */ A(`footer`,{className:`app-footer`,children:V})]}),ie&&/* @__PURE__ */ A(`div`,{className:`wui-shell-launcher`,children:ie}),yt&&/* @__PURE__ */ j(`nav`,{className:`wui-tabbar`,"aria-label":Te,children:[yt.tabs.map(e=>/* @__PURE__ */ A(me,{tab:e,linkComponent:Z,iconVariant:Y},e.key??e.href)),yt.hasMore&&/* @__PURE__ */ j(`button`,{type:`button`,className:`wui-tabbar-item${yt.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:Ee})]})]})]})}function ce(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=>J(e)?t:(e.children?.length??0)>0||!!e.href),o=[...e,{key:z,items:t}].map(e=>({...e,items:le(a(e.items,!0))})).filter(e=>e.items.some(e=>!J(e))),s=[],c=e=>{for(let t of e)J(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`,q(e)),_(`AppShell`,`match`,e.match,V),_(`AppShell`,`iconVariant`,e.iconVariant,re),_(`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!==z),footer:o.find(e=>e.key===z)?.items??[]}}function q(e){return Object.fromEntries(Object.entries(e).filter(([e])=>!ie.has(e)))}var J=e=>e.header!=null;function le(e){return e.filter((t,n)=>{if(!J(t))return!0;let r=e.findIndex((e,t)=>t>n&&J(e));return e.slice(n+1,r<0?void 0:r).length>0})}var Y=/* @__PURE__ */ new Set;function ue(t){if(t.key!=null&&R.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`||Y.has(n)||(Y.add(n),e(n))}function de(e,t){let n=[],r=e=>{for(let t of e)J(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?I:L;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){let t=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},n=e=>e.key??e.href??t(e),r=(e,r)=>({key:n(e),label:t(e),to:r,current:!!e.active}),i=e=>e.flatMap(e=>J(e)?[]:[...e.href?[{...r(e,e.href),icon:e.icon}]:[],...i(e.children??[])]),a=[];for(let o of e.flatMap(e=>e.items)){if(J(o))continue;let e=i(o.children??[]);if(e.length>0){let i=o.href?[{...r(o,o.href),icon:o.icon}]:[];a.push({key:n(o),label:t(o),links:[...i,...e]})}else o.href&&a.push(r(o,o.href))}return a}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}){let i=`wui-tabbar-item${e.active?` active`:``}`,a=/* @__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:e.badge})]}),o=e.active?`page`:void 0;return/* @__PURE__ */ A(c,{link:t(n,{to:e.href}),className:i,"aria-current":o,children:a})}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}){let l=i>0,u=i>1?` wui-nav-depth-${Math.min(i,6)}`:``,d=Array.isArray(e.children)&&e.children.length>0,f=d?he(e.children??[]):void 0,p=!!f,m=f?f.key??f.href??f.label:null,[g,_]=O(p);w(()=>{m!=null&&_(!0)},[m]);let v=typeof e.label==`string`?e.label:void 0,y=!l&&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}),b=e.badge!=null&&/* @__PURE__ */ A(`span`,{className:`app-nav-badge${e.badgeTone?` tone-${e.badgeTone}`:``}`,title:e.badgeTitle||void 0,children:e.badge}),x=ae(e.newUntil)&&/* @__PURE__ */ A(`span`,{className:`wui-nav-new`,children:o}),S=/* @__PURE__ */ j(k,{children:[y,/* @__PURE__ */ A(`span`,{className:`app-nav-text`,children:e.label}),x,b,e.trailingIcon&&/* @__PURE__ */ A(`span`,{className:`app-nav-trailing`,children:typeof e.trailingIcon==`string`?/* @__PURE__ */ A(h,{name:e.trailingIcon,size:16}):e.trailingIcon})]}),C=e.active?`page`:void 0;if(d){let d=/* @__PURE__ */ A(`div`,{className:`app-nav-sub${g?` expanded`:``}`,inert:!g,"aria-hidden":!g||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},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":C,onClick:r,children:S});return/* @__PURE__ */ j(k,{children:[/* @__PURE__ */ j(`div`,{className:`app-nav-item has-children wui-nav-split${l?` app-nav-subitem`:``}${p||e.active?` active`:``}${u}`,"data-label":v,children:[i,/* @__PURE__ */ A(`button`,{type:`button`,className:`app-nav-caret wui-nav-split-toggle`,"aria-expanded":g,"aria-label":M(s,{name:v??``}),onClick:()=>_(e=>!e),children:/* @__PURE__ */ A(h,{name:`chevron-right`,size:16})})]}),d]})}return/* @__PURE__ */ j(k,{children:[/* @__PURE__ */ j(`button`,{type:`button`,className:`app-nav-item${l?` app-nav-subitem`:``} has-children${p?` active`:``}${u}`,"aria-expanded":g,"data-label":v,onClick:()=>_(e=>!e),children:[y,/* @__PURE__ */ A(`span`,{className:`app-nav-text`,children:e.label}),x,b,/* @__PURE__ */ A(`span`,{className:`app-nav-caret`,children:/* @__PURE__ */ A(h,{name:`chevron-right`,size:16})})]}),d]})}let T=`app-nav-item${l?` app-nav-subitem`:``}${e.active?` active`:``}${u}`;return/* @__PURE__ */ A(c,{link:t(n,{to:e.href}),className:T,"aria-current":C,"data-label":v,onClick:r,children:S})}function X(e){l(`wui-dropdown`,P);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 _e({config:e,linkComponent:n,accountMenuLabel:r,roleLabel:i,rolesLabel:a}){let o=u(`shell`,ee),s=T(),{open:l,setOpen:d,ref:f}=X(),{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:N,section:P,logoutVariant:F=`item`,items:I=[]}=e;if(_(`AppShell`,`userMenu.logoutVariant`,F,[`item`,`button`]),!g)throw Error(`<AppShell> userMenu.name is required; the trigger and the avatar are named from it.`);let L=y.map(e=>(e??``).trim()).filter(Boolean),R=()=>d(!1),z=(e,r,i,a)=>/* @__PURE__ */ A(c,{link:t(n,{to:e}),className:`dropdown-item`,onClick:a,children:r},i),B=/* @__PURE__ */ A(h,{name:`log-out`,size:18}),V=/* @__PURE__ */ j(k,{children:[B,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":M(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}),L.length>0&&/* @__PURE__ */ j(`div`,{className:`wui-usermenu-roles`,children:[/* @__PURE__ */ A(`span`,{className:`wui-usermenu-roles-label`,children:L.length===1?i:a}),` ${L.join(`, `)}`]}),N?/* @__PURE__ */ A(`div`,{className:`wui-usermenu-extra`,children:N}):null]})]}),P?/* @__PURE__ */ A(`div`,{className:`wui-usermenu-section`,children:P}):null,C&&z(C,/* @__PURE__ */ j(k,{children:[/* @__PURE__ */ A(h,{name:`user`,size:18}),w]}),void 0,R),I.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?.(),R()};return e.href?z(e.href,t,e.key,n):/* @__PURE__ */ A(`button`,{type:`button`,className:`dropdown-item`,onClick:n,children:t},e.key)}),F===`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:B,children:O})}):/* @__PURE__ */ A(m,{type:`button`,tone:`danger`,variant:`soft`,block:!0,leftIcon:B,onClick:()=>{R(),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:V})}):E&&/* @__PURE__ */ A(`button`,{type:`button`,className:`dropdown-item danger`,onClick:()=>{R(),E()},children:V})]})]})}function ve({config:e,unreadLabel:t,markAllReadLabel:n,viewAllLabel:r,loadingNotificationsText:i,noUnreadText:a,unreadNotificationsText:o,unreadBellLabel:s}){let c=u(`shell`,ee),l=T(),{open:d,ref:f}=X(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:M(o,{count:W(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:M(s,{label:y,count:W(p)}),children:[/* @__PURE__ */ A(h,{name:`notification`,size:20}),/* @__PURE__ */ A(`span`,{className:`wui-bell-count`,"aria-hidden":`true`,hidden:p===0,children:W(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 ye=e=>!!e&&(e.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(e.tagName));function be({config:e,searchResultsLabel:t,noResultsText:n,noResultsForText:r,resultsCountText:i,resultCountText:a,moreLabel:o}){l(`wui-overflow`,N);let s=u(`shell`,ee),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),[P,F]=O({results:null,index:-1}),I=P.results===p?P.index:-1,L=e=>F({results:p,index:e}),R=D(null),z=D(null),B=D([]),V=E(()=>(p??[]).flatMap(e=>e.hits??[]),[p]),H=p!=null&&!C,U=V.length;w(()=>{let e=e=>{e.key!==`/`||e.ctrlKey||e.metaKey||e.altKey||ye(e.target instanceof HTMLElement?e.target:null)||(e.preventDefault(),S(!0),z.current?.focus())},t=e=>{R.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 te=e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){if(!H||U===0)return;e.preventDefault(),L((I+(e.key===`ArrowDown`?1:-1)+U)%U)}else x(e.nativeEvent)?H&&I>=0&&B.current[I]?(e.preventDefault(),B.current[I].click()):_&&d.trim()!==``&&(e.preventDefault(),_(d.trim())):e.key===`Escape`&&(H?(e.preventDefault(),k(!0)):b&&(e.preventDefault(),S(!1)))},ne=-1;return B.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:R,"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&&z.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:z,type:`search`,className:`form-control input search-input`,id:`${c}-input`,placeholder:y,"aria-label":y,role:`combobox`,"aria-autocomplete":`list`,"aria-expanded":H,"aria-controls":`${c}-list`,"aria-activedescendant":H&&I>=0?`${c}-opt-${I}`:void 0,autoComplete:`off`,value:d,onChange:e=>{k(!1),f?.(e.target.value)},onKeyDown:te,onFocus:v})]}),/* @__PURE__ */ A(`div`,{className:`wui-topsearch-results`,id:`${c}-list`,role:`listbox`,"aria-label":t,hidden:!H,children:H&&/* @__PURE__ */ j(`div`,{className:`wui-topsearch-groups`,role:`presentation`,children:[U===0&&/* @__PURE__ */ A(`div`,{className:`wui-topsearch-empty`,role:`option`,"aria-disabled":`true`,"aria-selected":`false`,children:M(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=>{ne+=1;let t=ne;return/* @__PURE__ */ j(`a`,{className:`wui-topsearch-hit${t===I?` is-active`:``}`,role:`option`,"aria-selected":t===I,id:`${c}-opt-${t}`,href:e.href,ref:e=>{B.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:H?U===0?n:M(U===1?a:i,{count:U}):``})]})})})}export{K 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`]),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 +1 @@
1
- import{pageWindow as e}from"../lib/pageWindow.js";import t from"../lib/useWuiText.js";import{splitMarkerProps as n}from"../lib/wuiMarker.js";import r from"./AppIcon.js";import i from"./AppSelect.js";import a from"./assertValidValue.js";import o from"./warnUnknownProps.js";import{jsx as s,jsxs as c}from"react/jsx-runtime";import{TABLE_PAGINATION_TEXT as l,fillText as u}from"@webority/ui-elements/text";var d=[`numbered`,`prev-next`],f=[`sm`,`md`],p=[`footer`,`standalone`],m=[5,10,25,50];function h(e,t,n,r){let i=Math.min((t-1)*n+1,r),a=Math.min(t*n,r);return u(e,{first:i,last:a,total:r})}function g(g){let{marker:_,props:v}=n(`AppTablePagination`,g),y=t(`tablePagination`,l),{page:b,totalPages:x,total:S,pageSize:C,onPageChange:w,onPageSizeChange:T,pageSizes:E=m,mode:D=`numbered`,showPageSize:O=!0,siblings:k=2,summary:A=!1,size:j=`md`,variant:M=`footer`,ariaLabel:N=y.ariaLabel,rowsPerPageLabel:P=y.rowsPerPageLabel,pageSizeLabel:F=y.pageSizeLabel,previousLabel:I=y.previousLabel,nextLabel:L=y.nextLabel,pageLabel:R=y.pageLabel,rangeText:z=y.rangeText,className:B=``,...V}=v;o(`AppTablePagination`,V),a(`AppTablePagination`,`mode`,D,d),a(`AppTablePagination`,`size`,j,f),a(`AppTablePagination`,`variant`,M,p);let H=Number(C)||0,U=Number(S)||0,W=x===void 0?U<=0:x<=0,G=Math.max(1,x??Math.ceil(U/(H>0?H:10))),K=Math.min(Math.max(1,Number(b)||1),G),q=H>0&&!!T&&O!==!1,J=A===!0&&U>0&&H>0;if(W||G<=1&&!q)return null;let Y=H>0&&!E.includes(H)?[...E,H].sort((e,t)=>e-t):E,X=D===`numbered`,Z=X?e(K,G,{siblingCount:k}):null,Q=[`table-pagination`,M===`standalone`&&`wui-table-pagination-standalone`,j===`sm`&&`wui-table-pagination-sm`,B].filter(Boolean).join(` `);return/* @__PURE__ */ c(`nav`,{className:Q,"aria-label":N,..._,...V,children:[J&&/* @__PURE__ */ s(`span`,{className:`wui-pager-summary`,children:h(y.summaryText,K,H,U)}),q&&/* @__PURE__ */ s(`span`,{className:`tpg-rows`,children:/* @__PURE__ */ s(i,{density:`compact`,size:`sm`,"aria-label":P,value:String(H),onChange:e=>T?.(Number(e)),options:Y.map(e=>({value:String(e),label:u(F,{count:e})}))})}),!X&&/* @__PURE__ */ s(`span`,{className:`tpg-range`,children:u(z,{page:K,pages:G})}),/* @__PURE__ */ c(`div`,{className:`tpg-nav`,children:[/* @__PURE__ */ s(`button`,{type:`button`,className:`tpg-arrow`,onClick:()=>w?.(Math.max(1,K-1)),disabled:K<=1,"aria-label":I,children:/* @__PURE__ */ s(r,{name:`arrow-left`,size:18})}),Z?.map(e=>typeof e==`number`?/* @__PURE__ */ s(`button`,{type:`button`,className:`tpg-page${e===K?` is-active`:``}`,onClick:()=>w?.(e),"aria-current":e===K?`page`:void 0,"aria-label":u(R,{page:e}),children:e},e):/* @__PURE__ */ s(`span`,{className:`tpg-ellipsis`,"aria-hidden":`true`,children:`…`},e)),/* @__PURE__ */ s(`button`,{type:`button`,className:`tpg-arrow`,onClick:()=>w?.(Math.min(G,K+1)),disabled:K>=G,"aria-label":L,children:/* @__PURE__ */ s(r,{name:`arrow-right`,size:18})})]})]})}export{g as default};
1
+ import{pageWindow as e}from"../lib/pageWindow.js";import t from"../lib/useWuiText.js";import{splitMarkerProps as n}from"../lib/wuiMarker.js";import r from"./AppIcon.js";import i from"./AppSelect.js";import a from"./assertValidValue.js";import o from"./warnUnknownProps.js";import{jsx as s,jsxs as c}from"react/jsx-runtime";import{TABLE_PAGINATION_TEXT as l,fillText as u}from"@webority/ui-elements/text";var d=[`numbered`,`prev-next`],f=[`sm`,`md`],p=[`footer`,`standalone`],m=[5,10,25,50];function h(e,t,n,r){let i=Math.min((t-1)*n+1,r),a=Math.min(t*n,r);return u(e,{first:i,last:a,total:r})}function g(g){let{marker:_,props:v}=n(`AppTablePagination`,g),y=t(`tablePagination`,l),{page:b,totalPages:x,total:S,hasNext:C,pageSize:w,onPageChange:T,onPageSizeChange:E,pageSizes:D=m,mode:O=`numbered`,showPageSize:k=!0,siblings:A=2,summary:j=!1,size:M=`md`,variant:N=`footer`,ariaLabel:P=y.ariaLabel,rowsPerPageLabel:F=y.rowsPerPageLabel,pageSizeLabel:I=y.pageSizeLabel,previousLabel:L=y.previousLabel,nextLabel:R=y.nextLabel,pageLabel:z=y.pageLabel,rangeText:B=y.rangeText,className:V=``,...H}=v;o(`AppTablePagination`,H),a(`AppTablePagination`,`mode`,O,d),a(`AppTablePagination`,`size`,M,f),a(`AppTablePagination`,`variant`,N,p);let U=Number(w)||0,W=Number(S)||0;if(C!==void 0&&(x!==void 0||W>0))throw Error(`AppTablePagination hasNext is for an unknown total: leave total and totalPages unset.`);let G=C!==void 0,K=!G&&(x===void 0?W<=0:x<=0),q=Math.max(1,x??Math.ceil(W/(U>0?U:10))),J=G?Math.max(1,Number(b)||1):Math.min(Math.max(1,Number(b)||1),q),Y=U>0&&!!E&&k!==!1,X=j===!0&&W>0&&U>0;if(K||!G&&q<=1&&!Y)return null;let Z=U>0&&!D.includes(U)?[...D,U].sort((e,t)=>e-t):D,Q=!G&&O===`numbered`,$=Q?e(J,q,{siblingCount:A}):null,ee=[`table-pagination`,N===`standalone`&&`wui-table-pagination-standalone`,M===`sm`&&`wui-table-pagination-sm`,V].filter(Boolean).join(` `);return/* @__PURE__ */ c(`nav`,{className:ee,"aria-label":P,..._,...H,children:[X&&/* @__PURE__ */ s(`span`,{className:`wui-pager-summary`,children:h(y.summaryText,J,U,W)}),Y&&/* @__PURE__ */ s(`span`,{className:`tpg-rows`,children:/* @__PURE__ */ s(i,{density:`compact`,size:`sm`,"aria-label":F,value:String(U),onChange:e=>E?.(Number(e)),options:Z.map(e=>({value:String(e),label:u(I,{count:e})}))})}),!Q&&!G&&/* @__PURE__ */ s(`span`,{className:`tpg-range`,children:u(B,{page:J,pages:q})}),/* @__PURE__ */ c(`div`,{className:`tpg-nav`,children:[/* @__PURE__ */ s(`button`,{type:`button`,className:`tpg-arrow`,onClick:()=>T?.(Math.max(1,J-1)),disabled:J<=1,"aria-label":L,children:/* @__PURE__ */ s(r,{name:`arrow-left`,size:18})}),$?.map(e=>typeof e==`number`?/* @__PURE__ */ s(`button`,{type:`button`,className:`tpg-page${e===J?` is-active`:``}`,onClick:()=>T?.(e),"aria-current":e===J?`page`:void 0,"aria-label":u(z,{page:e}),children:e},e):/* @__PURE__ */ s(`span`,{className:`tpg-ellipsis`,"aria-hidden":`true`,children:`…`},e)),/* @__PURE__ */ s(`button`,{type:`button`,className:`tpg-arrow`,onClick:()=>T?.(G?J+1:Math.min(q,J+1)),disabled:G?!C:J>=q,"aria-label":R,children:/* @__PURE__ */ s(r,{name:`arrow-right`,size:18})})]})]})}export{g as default};
@@ -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{TONES as i}from"../lib/vocabulary.js";import{splitMarkerProps as a}from"../lib/wuiMarker.js";import o from"./AppIcon.js";import s from"./AppTooltip.js";import c from"./assertValidValue.js";import l from"./renderIconProp.js";import u from"./warnUnknownProps.js";import{formatNumber as ee}from"@webority/ui-elements/helpers";import{cloneElement as te,useCallback as d,useEffect as f,useLayoutEffect as p,useRef as m,useState as h}from"react";import{Fragment as ne,jsx as g,jsxs as _}from"react/jsx-runtime";import{TABS_TEXT as re}from"@webority/ui-elements/text";var v=[`underline`,`pills`],y=[`horizontal`,`vertical`],ie=[`sm`,`md`,`lg`],ae=[`automatic`,`manual`],oe=[`scroll`,`menu`],se=i.filter(e=>e!==`primary`&&e!==`neutral`),ce=()=>import(`@webority/ui-elements/elements/overflow`),b=1,le=28,x=.7;function S(i){let{marker:S,props:C}=a(`AppTabs`,i),w=r(`tabs`,re),{tabs:T,value:E,onChange:D,linkComponent:O,variant:k=`underline`,orientation:A=`horizontal`,size:j=`md`,fitted:ue=!1,overflow:M=`scroll`,moreLabel:de=w.moreLabel,maxVisible:fe,activation:N=`automatic`,ariaLabel:P,className:F=``,style:I,...L}=C;n(`wui-overflow`,ce),u(`AppTabs`,L),c(`AppTabs`,`variant`,k,v),c(`AppTabs`,`orientation`,A,y),c(`AppTabs`,`size`,j,ie),c(`AppTabs`,`activation`,N,ae),c(`AppTabs`,`overflow`,M,oe);for(let e of T)c(`AppTabs`,`tabs[].tone`,e.tone,se);let R=m(null),z=m(null),B=A===`vertical`,V=(M===`menu`||fe!=null)&&!B,[H,U]=h(E);f(()=>{U(E)},[E]);let pe=T.find(e=>!e.disabled)?.key,me=T.some(e=>e.key===H&&!e.disabled)?H:void 0,he=T.some(e=>e.key===E&&!e.disabled)?E:void 0,ge=me??he??pe,_e=e=>{R.current?.querySelector(`[data-key="${CSS.escape(String(e))}"]`)?.focus()},W=d(()=>{let e=R.current,t=z.current;if(!e||!t||B||V)return;let n=e.scrollWidth-e.clientWidth;t.classList.toggle(`is-overflow-start`,e.scrollLeft>b),t.classList.toggle(`is-overflow-end`,n>b&&e.scrollLeft<n-b)},[B,V]),G=d(()=>{let e=R.current;if(!e)return;let t=e.querySelector(`.app-tab.active`);t?(B?(e.style.setProperty(`--wui-tab-y`,`${t.offsetTop}px`),e.style.setProperty(`--wui-tab-h`,`${t.offsetHeight}px`)):(e.style.setProperty(`--wui-tab-x`,`${t.offsetLeft}px`),e.style.setProperty(`--wui-tab-w`,`${t.offsetWidth}px`)),e.toggleAttribute(`data-active-danger`,!!T.find(e=>e.key===E)?.danger)):e.style.setProperty(B?`--wui-tab-h`:`--wui-tab-w`,`0px`),e.setAttribute(`data-wui-tabs`,``),W()},[B,T,E,W]),K=e=>!V||!R.current?.querySelector(`[data-key="${CSS.escape(String(e))}"][data-wui-overflow-hidden]`),q=d(e=>{let t=R.current;if(!t||B)return;let n=t.querySelector(`.app-tab[data-key="${CSS.escape(e)}"]`);if(!n)return;let r=le,i=n.offsetLeft,a=i+n.offsetWidth;i-r<t.scrollLeft?t.scrollLeft=Math.max(0,i-r):a+r>t.scrollLeft+t.clientWidth&&(t.scrollLeft=a+r-t.clientWidth)},[B]);p(()=>{G()},[G]),p(()=>{q(E)},[E,q]);let J=m(G);f(()=>{J.current=G},[G]),f(()=>{if(!document.fonts)return;let e=!0;return document.fonts.ready.then(()=>{e&&J.current()}),()=>{e=!1}},[]);let Y=m(null),X=d(e=>{if(typeof ResizeObserver>`u`)return;let t=Y.current??{ro:new ResizeObserver(()=>J.current()),count:0};return Y.current=t,t.ro.observe(e),t.count+=1,()=>{t.ro.unobserve(e),--t.count,t.count===0&&(t.ro.disconnect(),Y.current===t&&(Y.current=null))}},[]),ve=d(e=>{R.current=e;let t=e?X(e):void 0;return()=>{R.current=null,t?.()}},[X]),Z=d(e=>{z.current=e;let t=e?X(e):void 0;return()=>{z.current=null,t?.()}},[X]);f(()=>{let e=z.current;if(!V||!e)return;let t=()=>J.current();return e.addEventListener(`wui-overflow-change`,t),()=>e.removeEventListener(`wui-overflow-change`,t)},[V]);function ye(e){let t=e.target instanceof HTMLElement?e.target.dataset.key:void 0;if(t==null)return;let n=T.findIndex(e=>e.key===t);if(n<0)return;let r=T.length,i=(e,t)=>{for(let n=1;n<=r;n++){let i=T[((e+t*n)%r+r)%r];if(i&&!i.disabled&&K(i.key))return i}return null},a=B?`ArrowDown`:`ArrowRight`,o=B?`ArrowUp`:`ArrowLeft`,s=null;if(e.key===a?s=i(n,1):e.key===o?s=i(n,-1):e.key===`Home`?s=T.find(e=>!e.disabled&&K(e.key))??null:e.key===`End`&&(s=[...T].reverse().find(e=>!e.disabled&&K(e.key))??null),!s)return;e.preventDefault(),U(s.key),_e(s.key);let c=s.href!=null||s.to!=null;N===`automatic`&&!c&&D?.(s.key)}let Q=e=>{let t=R.current;t&&t.scrollBy({left:e*t.clientWidth*x})},be=[`app-tabs`,k===`pills`?`app-tabs-pills`:``,B?`app-tabs-vertical`:``,j===`sm`?`app-tabs-sm`:``,j===`lg`?`app-tabs-lg`:``,ue?`app-tabs-fitted`:``,F].filter(Boolean).join(` `),$=/* @__PURE__ */ _(`div`,{ref:ve,role:`tablist`,"aria-orientation":B?`vertical`:void 0,"aria-label":P,className:be,style:I,"data-wui-overflow-list":V?``:void 0,...L,onKeyDown:ye,onScroll:W,children:[T.map(n=>{let r=n.key===E,i=n.href!=null||n.to!=null,a={role:`tab`,"data-key":n.key,"aria-selected":r,tabIndex:n.key===ge?0:-1,className:`app-tab${r?` active`:``}${n.danger?` danger`:``}${i&&n.disabled?` disabled`:``}`},o=/* @__PURE__ */ _(ne,{children:[n.image?/* @__PURE__ */ g(`img`,{className:`app-tab-img`,src:n.image,alt:n.imageAlt??``}):l(n.icon,{size:16,className:`app-tab-icon`}),/* @__PURE__ */ g(`span`,{className:`wui-tab-label`,children:n.label}),(n.countLabel||n.count!=null)&&/* @__PURE__ */ g(`span`,{className:`app-tab-count${n.tone?` ${n.tone}`:``}`,children:n.countLabel||ee(n.count,{decimals:0})})]}),c;if(i){let r=n.disabled||n.to==null||O==null||O===`a`?e(void 0,{href:n.disabled?void 0:n.href??n.to}):e(O,{to:n.to}),i=n.rel??(n.target===`_blank`?`noopener noreferrer`:void 0),s=n.disabled?{"aria-disabled":!0}:{target:n.target,rel:i},l=e=>{n.disabled?e.preventDefault():e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(U(n.key),D?.(n.key))};c=/* @__PURE__ */ g(t,{link:r,...a,...s,onClick:l,children:o},n.key)}else c=/* @__PURE__ */ g(`button`,{type:`button`,...a,disabled:n.disabled,onClick:()=>{n.disabled||(U(n.key),D?.(n.key))},children:o},n.key);return n.tooltip?/* @__PURE__ */ g(s,{content:n.tooltip,children:c},n.key):c}),/* @__PURE__ */ g(`span`,{className:`app-tab-indicator`,"aria-hidden":`true`,"data-wui-overflow-skip":``})]});return B?te($,S):V?/* @__PURE__ */ g(`wui-overflow`,{...S,ref:Z,class:`app-tabs-wrap`,label:de,children:$}):/* @__PURE__ */ _(`div`,{...S,ref:Z,className:`app-tabs-wrap`,children:[/* @__PURE__ */ g(`button`,{type:`button`,className:`app-tabs-scroll-btn prev`,"aria-label":w.scrollTabsBackwardLabel,tabIndex:-1,onClick:()=>Q(-1),children:/* @__PURE__ */ g(o,{name:`chevron-left`,size:16})}),$,/* @__PURE__ */ g(`button`,{type:`button`,className:`app-tabs-scroll-btn next`,"aria-label":w.scrollTabsForwardLabel,tabIndex:-1,onClick:()=>Q(1),children:/* @__PURE__ */ g(o,{name:`chevron-right`,size:16})})]})}export{S 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{TONES as i}from"../lib/vocabulary.js";import{splitMarkerProps as a}from"../lib/wuiMarker.js";import o from"./AppIcon.js";import s from"./AppTooltip.js";import c from"./assertValidValue.js";import l from"./renderIconProp.js";import ee from"./warnUnknownProps.js";import{formatNumber as te}from"@webority/ui-elements/helpers";import{cloneElement as u,useCallback as d,useEffect as f,useLayoutEffect as p,useRef as m,useState as ne}from"react";import{Fragment as h,jsx as g,jsxs as _}from"react/jsx-runtime";import{TABS_TEXT as re}from"@webority/ui-elements/text";var v=[`underline`,`pills`],ie=[`horizontal`,`vertical`],ae=[`sm`,`md`,`lg`],oe=[`automatic`,`manual`],se=[`scroll`,`menu`],ce=i.filter(e=>e!==`primary`&&e!==`neutral`),le=()=>import(`@webority/ui-elements/elements/overflow`),y=1,ue=28,b=.7;function x(i){let{marker:x,props:S}=a(`AppTabs`,i),C=r(`tabs`,re),{tabs:w,value:T,onChange:E,linkComponent:D,variant:O=`underline`,orientation:k=`horizontal`,size:A=`md`,fitted:de=!1,overflow:j=`scroll`,moreLabel:fe=C.moreLabel,maxVisible:M,activation:N=`automatic`,ariaLabel:P,className:F=``,style:I,...L}=S;n(`wui-overflow`,le),ee(`AppTabs`,L),c(`AppTabs`,`variant`,O,v),c(`AppTabs`,`orientation`,k,ie),c(`AppTabs`,`size`,A,ae),c(`AppTabs`,`activation`,N,oe),c(`AppTabs`,`overflow`,j,se);for(let e of w)c(`AppTabs`,`tabs[].tone`,e.tone,ce);let R=m(null),z=m(null),B=k===`vertical`,V=(j===`menu`||M!=null)&&!B,[H,U]=ne(T);f(()=>{U(T)},[T]);let pe=w.find(e=>!e.disabled)?.key,me=w.some(e=>e.key===H&&!e.disabled)?H:void 0,he=w.some(e=>e.key===T&&!e.disabled)?T:void 0,ge=me??he??pe,_e=e=>{R.current?.querySelector(`[data-key="${CSS.escape(String(e))}"]`)?.focus()},W=d(()=>{let e=R.current,t=z.current;if(!e||!t||B||V)return;let n=e.scrollWidth-e.clientWidth;t.classList.toggle(`is-overflow-start`,e.scrollLeft>y),t.classList.toggle(`is-overflow-end`,n>y&&e.scrollLeft<n-y)},[B,V]),G=d(()=>{let e=R.current;if(!e)return;let t=e.querySelector(`.app-tab.active`);t?(B?(e.style.setProperty(`--wui-tab-y`,`${t.offsetTop}px`),e.style.setProperty(`--wui-tab-h`,`${t.offsetHeight}px`)):(e.style.setProperty(`--wui-tab-x`,`${t.offsetLeft}px`),e.style.setProperty(`--wui-tab-w`,`${t.offsetWidth}px`)),e.toggleAttribute(`data-active-danger`,!!w.find(e=>e.key===T)?.danger)):e.style.setProperty(B?`--wui-tab-h`:`--wui-tab-w`,`0px`),e.setAttribute(`data-wui-tabs`,``),W()},[B,w,T,W]),K=e=>!V||!R.current?.querySelector(`[data-key="${CSS.escape(String(e))}"][data-wui-overflow-hidden]`),q=d(e=>{let t=R.current;if(!t||B)return;let n=t.querySelector(`.app-tab[data-key="${CSS.escape(e)}"]`);if(!n)return;let r=ue,i=n.offsetLeft,a=i+n.offsetWidth;i-r<t.scrollLeft?t.scrollLeft=Math.max(0,i-r):a+r>t.scrollLeft+t.clientWidth&&(t.scrollLeft=a+r-t.clientWidth)},[B]);p(()=>{G()},[G]),p(()=>{q(T)},[T,q]);let J=m(G);f(()=>{J.current=G},[G]),f(()=>{if(!document.fonts)return;let e=!0;return document.fonts.ready.then(()=>{e&&J.current()}),()=>{e=!1}},[]);let Y=m(null),X=d(e=>{if(typeof ResizeObserver>`u`)return;let t=Y.current??{ro:new ResizeObserver(()=>J.current()),count:0};return Y.current=t,t.ro.observe(e),t.count+=1,()=>{t.ro.unobserve(e),--t.count,t.count===0&&(t.ro.disconnect(),Y.current===t&&(Y.current=null))}},[]),ve=d(e=>{R.current=e;let t=e?X(e):void 0;return()=>{R.current=null,t?.()}},[X]),Z=d(e=>{z.current=e;let t=e?X(e):void 0;return()=>{z.current=null,t?.()}},[X]);f(()=>{let e=z.current;if(!V||!e)return;let t=()=>J.current();return e.addEventListener(`wui-overflow-change`,t),()=>e.removeEventListener(`wui-overflow-change`,t)},[V]);function ye(e){let t=e.target instanceof HTMLElement?e.target.dataset.key:void 0;if(t==null)return;let n=w.findIndex(e=>e.key===t);if(n<0)return;let r=w.length,i=(e,t)=>{for(let n=1;n<=r;n++){let i=w[((e+t*n)%r+r)%r];if(i&&!i.disabled&&K(i.key))return i}return null},a=getComputedStyle(e.currentTarget).direction===`rtl`,o=B?`ArrowDown`:a?`ArrowLeft`:`ArrowRight`,s=B?`ArrowUp`:a?`ArrowRight`:`ArrowLeft`,c=null;if(e.key===o?c=i(n,1):e.key===s?c=i(n,-1):e.key===`Home`?c=w.find(e=>!e.disabled&&K(e.key))??null:e.key===`End`&&(c=[...w].reverse().find(e=>!e.disabled&&K(e.key))??null),!c)return;e.preventDefault(),U(c.key),_e(c.key);let l=c.href!=null||c.to!=null;N===`automatic`&&!l&&E?.(c.key)}let Q=e=>{let t=R.current;t&&t.scrollBy({left:e*t.clientWidth*b})},be=[`app-tabs`,O===`pills`?`app-tabs-pills`:``,B?`app-tabs-vertical`:``,A===`sm`?`app-tabs-sm`:``,A===`lg`?`app-tabs-lg`:``,de?`app-tabs-fitted`:``,F].filter(Boolean).join(` `),$=/* @__PURE__ */ _(`div`,{ref:ve,role:`tablist`,"aria-orientation":B?`vertical`:void 0,"aria-label":P,className:be,style:I,"data-wui-overflow-list":V?``:void 0,...L,onKeyDown:ye,onScroll:W,children:[w.map(n=>{let r=n.key===T,i=n.href!=null||n.to!=null,a={role:`tab`,"data-key":n.key,"aria-selected":r,tabIndex:n.key===ge?0:-1,className:`app-tab${r?` active`:``}${n.danger?` danger`:``}${i&&n.disabled?` disabled`:``}`},o=/* @__PURE__ */ _(h,{children:[n.image?/* @__PURE__ */ g(`img`,{className:`app-tab-img`,src:n.image,alt:n.imageAlt??``}):l(n.icon,{size:16,className:`app-tab-icon`}),/* @__PURE__ */ g(`span`,{className:`wui-tab-label`,children:n.label}),(n.countLabel||n.count!=null)&&/* @__PURE__ */ g(`span`,{className:`app-tab-count${n.tone?` ${n.tone}`:``}`,children:n.countLabel||te(n.count,{decimals:0})})]}),c;if(i){let r=n.disabled||n.to==null||D==null||D===`a`?e(void 0,{href:n.disabled?void 0:n.href??n.to}):e(D,{to:n.to}),i=n.rel??(n.target===`_blank`?`noopener noreferrer`:void 0),s=n.disabled?{"aria-disabled":!0}:{target:n.target,rel:i},l=e=>{n.disabled?e.preventDefault():e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(U(n.key),E?.(n.key))};c=/* @__PURE__ */ g(t,{link:r,...a,...s,onClick:l,children:o},n.key)}else c=/* @__PURE__ */ g(`button`,{type:`button`,...a,disabled:n.disabled,onClick:()=>{n.disabled||(U(n.key),E?.(n.key))},children:o},n.key);return n.tooltip?/* @__PURE__ */ g(s,{content:n.tooltip,children:c},n.key):c}),/* @__PURE__ */ g(`span`,{className:`app-tab-indicator`,"aria-hidden":`true`,"data-wui-overflow-skip":``})]});return B?u($,x):V?/* @__PURE__ */ g(`wui-overflow`,{...x,ref:Z,class:`app-tabs-wrap`,label:fe,children:$}):/* @__PURE__ */ _(`div`,{...x,ref:Z,className:`app-tabs-wrap`,children:[/* @__PURE__ */ g(`button`,{type:`button`,className:`app-tabs-scroll-btn prev`,"aria-label":C.scrollTabsBackwardLabel,tabIndex:-1,onClick:()=>Q(-1),children:/* @__PURE__ */ g(o,{name:`chevron-left`,size:16})}),$,/* @__PURE__ */ g(`button`,{type:`button`,className:`app-tabs-scroll-btn next`,"aria-label":C.scrollTabsForwardLabel,tabIndex:-1,onClick:()=>Q(1),children:/* @__PURE__ */ g(o,{name:`chevron-right`,size:16})})]})}export{x as default};