@webority/ui-react 0.165.0 → 0.167.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/dist/canvas-kit/kit.js +217 -215
  2. package/dist/canvas-kit/manifest.json +247 -28
  3. package/dist/canvas-kit/release.json +6 -6
  4. package/dist/components/AppAsyncBlock.js +1 -1
  5. package/dist/components/AppAvatar.js +1 -1
  6. package/dist/components/AppAvatarGroup.js +1 -1
  7. package/dist/components/AppBanner.js +1 -1
  8. package/dist/components/AppBreadcrumbs.js +1 -1
  9. package/dist/components/AppButton.js +1 -1
  10. package/dist/components/AppCalendar.js +1 -1
  11. package/dist/components/AppCard.js +1 -1
  12. package/dist/components/AppCarousel.js +1 -1
  13. package/dist/components/AppCell.js +1 -1
  14. package/dist/components/AppChart.js +1 -1
  15. package/dist/components/AppChartCard.js +1 -1
  16. package/dist/components/AppCheckbox.js +1 -1
  17. package/dist/components/AppChip.js +1 -1
  18. package/dist/components/AppChipGroup.js +1 -1
  19. package/dist/components/AppChoiceCard.js +1 -1
  20. package/dist/components/AppChoiceChip.js +1 -1
  21. package/dist/components/AppColorField.js +1 -1
  22. package/dist/components/AppColumnMenu.js +1 -1
  23. package/dist/components/AppCommandPalette.js +1 -1
  24. package/dist/components/AppCommentThread.js +1 -1
  25. package/dist/components/AppCompareTable.js +1 -1
  26. package/dist/components/AppConfirmDialog.js +1 -1
  27. package/dist/components/AppConfirmProvider.js +1 -1
  28. package/dist/components/AppContextMenu.js +1 -1
  29. package/dist/components/AppCopyButton.js +1 -1
  30. package/dist/components/AppDataTable.js +1 -1
  31. package/dist/components/AppDatePicker.js +1 -1
  32. package/dist/components/AppDateRangePicker.js +1 -1
  33. package/dist/components/AppDescriptions.js +1 -1
  34. package/dist/components/AppDrawer.js +1 -1
  35. package/dist/components/AppDropZone.js +1 -1
  36. package/dist/components/AppDropdown.js +1 -1
  37. package/dist/components/AppDueDate.js +1 -1
  38. package/dist/components/AppEntryGrid.js +1 -1
  39. package/dist/components/AppErrorBoundary.js +1 -1
  40. package/dist/components/AppErrorSummary.js +1 -1
  41. package/dist/components/AppFileAttachment.js +1 -1
  42. package/dist/components/AppFilePicker.js +1 -1
  43. package/dist/components/AppFilterBar.js +1 -1
  44. package/dist/components/AppFloatingDock.js +1 -1
  45. package/dist/components/AppForm.js +1 -1
  46. package/dist/components/AppFormulaSteps.js +1 -1
  47. package/dist/components/AppHoverCard.js +1 -1
  48. package/dist/components/AppImagePicker.js +1 -1
  49. package/dist/components/AppInfoTip.js +1 -1
  50. package/dist/components/AppInlineEdit.js +1 -1
  51. package/dist/components/AppInput.js +1 -1
  52. package/dist/components/AppInputGroup.js +1 -1
  53. package/dist/components/AppKanban.js +1 -1
  54. package/dist/components/AppMentionInput.js +1 -1
  55. package/dist/components/AppModal.js +1 -1
  56. package/dist/components/AppNavigationMenu.js +1 -1
  57. package/dist/components/AppNotificationCenter.js +1 -1
  58. package/dist/components/AppNumberInput.js +1 -1
  59. package/dist/components/AppOnboardingChecklist.js +1 -1
  60. package/dist/components/AppOrgTree.js +1 -1
  61. package/dist/components/AppOtpInput.js +1 -1
  62. package/dist/components/AppPageHeader.js +1 -1
  63. package/dist/components/AppPhoneNumberInput.js +1 -1
  64. package/dist/components/AppPricingCard.js +1 -1
  65. package/dist/components/AppQrCode.js +1 -1
  66. package/dist/components/AppRadio.js +1 -1
  67. package/dist/components/AppRadioGroup.js +1 -1
  68. package/dist/components/AppRating.js +1 -1
  69. package/dist/components/AppRecordPager.js +1 -1
  70. package/dist/components/AppRelativeTime.js +1 -1
  71. package/dist/components/AppRepeater.js +1 -1
  72. package/dist/components/AppRichText.js +1 -1
  73. package/dist/components/AppRouteError.js +1 -1
  74. package/dist/components/AppRowActions.js +1 -1
  75. package/dist/components/AppScoreScale.js +1 -1
  76. package/dist/components/AppSearch.js +1 -1
  77. package/dist/components/AppSectionLeadCapture.js +1 -1
  78. package/dist/components/AppSegmented.js +1 -1
  79. package/dist/components/AppSelect.js +1 -1
  80. package/dist/components/AppShell.js +1 -1
  81. package/dist/components/AppShortcutLegend.js +1 -1
  82. package/dist/components/AppShowMore.js +1 -1
  83. package/dist/components/AppSlider.js +1 -1
  84. package/dist/components/AppSortableList.js +1 -1
  85. package/dist/components/AppSparkline.js +1 -1
  86. package/dist/components/AppSpinner.js +1 -1
  87. package/dist/components/AppSplash.js +1 -1
  88. package/dist/components/AppSplitButton.js +1 -1
  89. package/dist/components/AppSplitView.js +1 -1
  90. package/dist/components/AppStatusBadge.js +1 -1
  91. package/dist/components/AppStepper.js +1 -1
  92. package/dist/components/AppSwitch.js +1 -1
  93. package/dist/components/AppTablePagination.js +1 -1
  94. package/dist/components/AppTableToolbar.js +1 -1
  95. package/dist/components/AppTabs.js +1 -1
  96. package/dist/components/AppTextarea.js +1 -1
  97. package/dist/components/AppThemeToggle.js +1 -1
  98. package/dist/components/AppTimePicker.js +1 -1
  99. package/dist/components/AppTimeline.js +1 -1
  100. package/dist/components/AppToast.js +1 -1
  101. package/dist/components/AppUpdateBar.js +1 -1
  102. package/dist/components/AppWhatsNew.js +1 -1
  103. package/dist/components/AppWizard.js +1 -1
  104. package/dist/components/AppWorkspaceSwitcher.js +1 -1
  105. package/dist/components/toast.js +1 -1
  106. package/dist/guidance.json +10 -5
  107. package/dist/lib/FileItemRow.js +1 -1
  108. package/dist/lib/emptyValue.js +1 -1
  109. package/dist/lib/fieldState.js +1 -1
  110. package/dist/lib/useWuiText.js +1 -0
  111. package/dist/types/components/AppColorField.d.ts +3 -3
  112. package/dist/types/components/AppDatePicker.d.ts +2 -1
  113. package/dist/types/components/AppDateRangePicker.d.ts +1 -1
  114. package/dist/types/components/AppDropdown.d.ts +6 -0
  115. package/dist/types/components/AppEntryGrid.d.ts +43 -1
  116. package/dist/types/components/AppFormulaSteps.d.ts +3 -3
  117. package/dist/types/components/AppInput.d.ts +4 -4
  118. package/dist/types/components/AppInputGroup.d.ts +1 -1
  119. package/dist/types/components/AppMentionInput.d.ts +2 -2
  120. package/dist/types/components/AppNumberInput.d.ts +9 -3
  121. package/dist/types/components/AppPhoneNumberInput.d.ts +1 -1
  122. package/dist/types/components/AppRowActions.d.ts +6 -0
  123. package/dist/types/components/AppSearch.d.ts +1 -1
  124. package/dist/types/components/AppSelect.d.ts +3 -2
  125. package/dist/types/components/AppTextarea.d.ts +2 -2
  126. package/dist/types/components/AppTimePicker.d.ts +1 -1
  127. package/dist/types/index.d.ts +2 -1
  128. package/dist/types/lib/emptyValue.d.ts +2 -2
  129. package/dist/types/lib/fieldState.d.ts +1 -0
  130. package/dist/types/lib/useWuiText.d.ts +3 -0
  131. package/dist/ui-react.js +1 -1
  132. package/package.json +9 -9
  133. package/dist/lib/unsavedText.js +0 -1
  134. package/dist/types/lib/unsavedText.d.ts +0 -5
@@ -1 +1 @@
1
- import{devWarn as e}from"../lib/devWarn.js";import t from"../lib/useElementEntry.js";import{splitMarkerProps as n}from"../lib/wuiMarker.js";import r from"./AppIcon.js";import i from"./AppInfoTip.js";import a from"./AppRowActions.js";import o from"./AppSkeleton.js";import s from"./AppTablePagination.js";import c from"./assertValidValue.js";import l from"./warnUnknownProps.js";import{COLUMN_MAX_WIDTH as ee,COLUMN_MIN_WIDTH as te,DATA_TABLE_TEXT as u,PIN_AT_VAR as d,PIN_SIDES as ne,ROW_HEIGHTS as f,ROW_MOVE_LIMIT as re,ROW_SAVE_ERROR_CLASS as ie,attachRowDrag as ae,attachScrollEdges as oe,groupCount as se,groupItems as ce,isImeSafeEnter as le,measureRows as ue,pinAtValue as de,pinClasses as fe,planPins as pe,playRowMoves as me,rowOrderChanged as he,saveOutcomeText as ge,settledRows as _e,syncTargets as ve,virtualRange as ye}from"@webority/ui-elements/helpers";import{Children as be,Fragment as xe,isValidElement as Se,useCallback as Ce,useEffect as p,useLayoutEffect as we,useMemo as Te,useRef as m,useState as h}from"react";import{Fragment as Ee,jsx as g,jsxs as _}from"react/jsx-runtime";import{FORCED_STATE_CLASSES as De}from"@webority/theme/runtime";var Oe=()=>import(`@webority/ui-elements/elements/data-table`),ke=[`comfortable`,`cozy`,`compact`],Ae=[`auto`,`fixed`],je=[1,2,3,4];function v(e,t){return typeof e==`object`&&e?Reflect.get(e,t):void 0}function Me(e,t){if(e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`||Se(e)||Array.isArray(e))return e;throw Error(`AppDataTable: the value under "${t}" is not renderable; give that column a render function.`)}function Ne(e,t){return Me(v(e,t),t)}var y=()=>{try{return process.env.NODE_ENV!==`production`}catch{return!0}},b=/* @__PURE__ */ new Set;function x(t,n){!b.has(t)&&y()&&(b.add(t),e(`[@webority/ui-react] <AppDataTable> ${n}`))}var Pe=100,Fe=e=>{let t=typeof e==`object`&&e&&`id`in e?e.id:void 0;return typeof t==`string`||typeof t==`number`?t:void 0},Ie=()=>{},Le=()=>({total:0,keys:[]}),Re=[],ze=(e,t,n)=>{let r=!!t?.(e),i=r?``:n?.(e)||``;return{state:r?`saving`:i?`error`:null,message:i}};function Be(e){return e===`end`?`wui-cell-end`:e===`num`?`num`:e===`center`?`text-center`:``}function Ve(e){return e===`center`?`44%`:e===`end`||e===`num`?`56%`:`60%`}function He(e){return e==null||e===``?`-`:Array.isArray(e)?be.toArray(e):typeof e==`boolean`?String(e):e}function Ue(e){if(!e||!(e.total>0))return!1;let t=e.pageSizes?.length?e.pageSizes:[e.pageSize];return e.total>Math.min(...t)}function We(e){t(`wui-data-table`,Oe);let{marker:be,props:Se}=n(`AppDataTable`,e),{columns:y,rows:b=Re,rowKey:We=Fe,sort:Ge,onSort:Ke,loading:S=!1,refreshing:qe=!1,skeletonRows:Je=5,empty:Ye=`No records found.`,emptyFiltered:Xe,sourceCount:Ze,rowActions:C,linkComponent:Qe,rowActionsLabel:$e,pagination:w,ariaLabel:et,className:tt=``,wrapperClassName:nt=``,selectable:T=!1,selectedIds:E,isRowSelectable:rt,onToggleRow:it,onToggleAll:at,onSelectRange:ot,renderExpanded:st,singleExpand:ct=!1,density:D=`comfortable`,tableLayout:lt=`auto`,striped:ut=!1,flush:dt=!1,pad:ft,nameLines:O,headerTone:pt,rowDrag:k=!1,maxHeight:mt,stickyFirstColumn:ht=!1,stickyActions:gt=!1,equalActions:_t=!1,linkFirstColumn:vt=!1,stackOnMobile:A=!1,hiddenColumns:yt,rowStatus:bt,rowHref:j,onRowClick:xt,activeRowKey:St,hoverRowKey:Ct,resizableColumns:M=!1,viewKey:wt,groupBy:N,groupLabel:Tt,virtual:P=!1,rowSaving:F,rowSaveError:I,...Et}=Se;l(`AppDataTable`,Et);let{style:Dt,...Ot}=Et,L=Ce((e,t)=>{let n=We(e,t);if(n==null)throw Error(`AppDataTable: a row has no key. Pass rowKey, or give every row an id.`);return n},[We]),kt=yt?.length?new Set(yt):null;y=kt?y.filter(e=>!(e.hideable&&kt.has(e.key))):y,c(`AppDataTable`,`density`,D,ke),c(`AppDataTable`,`tableLayout`,lt,Ae),c(`AppDataTable`,`nameLines`,O,je);for(let e of y)c(`AppDataTable`,`column.pin`,e.pin,ne);let R=typeof j==`function`||typeof xt==`function`,At=[`table table-ledger`,D===`cozy`||D===`compact`?`wui-table-${D}`:``,ut?`wui-table-striped`:``,ht?`wui-table-sticky-first`:``,gt?`wui-table-sticky-actions`:``,_t?`wui-table-equal-actions`:``,A?`wui-table-stack`:``,vt&&R?`wui-table-link-first`:``,tt].filter(Boolean).join(` `),z=typeof st==`function`,[jt,Mt]=h(()=>/* @__PURE__ */ new Set),Nt=e=>Mt(t=>{if(t.has(e)){let n=new Set(t);return n.delete(e),n}return ct?/* @__PURE__ */ new Set([e]):new Set(t).add(e)}),Pt=y.some(e=>typeof e.footer==`function`),Ft=e=>!!(e.target instanceof Element&&e.target.closest(`a, button, input, select, textarea, label, [role='menu'], [role='menuitem'], .dropdown`)),It=(e,t)=>{if(Ft(t)||(xt&&xt(e),!j))return;let n=j(e);n&&(t.ctrlKey||t.metaKey||t.button===1?window.open(n,`_blank`,`noopener`):window.location.assign(n))},Lt=mt!==void 0,Rt=qe&&!S&&b.length>0,zt=[`table-wrap`,Lt?`wui-table-scroll`:``,dt?`wui-table-flush`:``,Rt?`wui-table-refreshing`:``,nt].filter(Boolean).join(` `),Bt={maxHeight:Lt?mt:void 0,"--wui-table-pad":ft!=null&&!dt?`${ft}px`:void 0,"--wui-name-lines":P?`1`:O?.toString(),"--wui-table-header-bg":pt??void 0},Vt=Object.values(Bt).some(e=>e!==void 0)||Dt!==void 0?{...Bt,...Dt}:void 0,Ht=Math.max(1,y.length+ +!!C+ +!!T+ +!!z),Ut=y.some(e=>e.pin===`start`||e.pin===`end`),Wt=Ut||M||!!N||P,B=+!!z+ +!!T,Gt=Ut?pe([...z?[`lead`]:[],...T?[`lead`]:[],...y.map(e=>e.pin===`start`||e.pin===`end`?e.pin:null),...C?[null]:[]]):[],V=(e,t=``)=>{let n=Gt[e];return n?{className:`${t.trim()} ${fe(n)}`.trim(),style:{[d]:de(n.side,n.ordinal)}}:{className:t,style:void 0}},H=(e,t)=>Gt[e]?{...t,...V(e).style}:t,Kt=y.length-1+ +!!C;wt&&!M&&x(`view-key`,"`viewKey` remembers resized widths: add `resizableColumns`."),P&&!Lt&&x(`virtual-height`,"`virtual` needs `maxHeight`: without a scroll box every row renders."),P&&(z||A)&&x(`virtual-shape`,"`virtual` takes rows of one height, so it is off with `renderExpanded` or `stackOnMobile`."),P&&O!==void 0&&O!==1&&x(`virtual-name-lines`,"`nameLines` is ignored with `virtual`: a virtual table shows one line per name."),vt&&!R&&x(`link-first-column`,"`linkFirstColumn` needs rowHref or onRowClick: the row is what opens."),ct&&typeof st!=`function`&&x(`single-expand`,"`singleExpand` needs renderExpanded: there are no rows to expand."),!P&&b?.length>500&&x(`rows-without-virtual`,`renders more than 500 rows without virtual: add virtual with maxHeight, or page the data.`);let U=P&&Lt&&!z&&!A&&!S&&b?.length>0,W=(e,t)=>!rt||!!rt(e,t),qt=T&&b?b.reduce((e,t,n)=>e+ +!!W(t,n),0):0,G=T&&b?b.reduce((e,t,n)=>e+(W(t,n)&&E?.has(L(t,n))?1:0),0):0,Jt=qt>0&&G===qt,Yt=G>0&&!Jt,Xt=e=>{e&&(e.indeterminate=Yt)},Zt=m(null),Qt=(e,t)=>{let n=Zt.current;Zt.current=e;let r=t&&n!==null?b.findIndex((e,t)=>L(e,t)===n):-1,i=b.findIndex((t,n)=>L(t,n)===e);if(r<0||i<0||r===i){it?.(e);return}let a=!E?.has(e),o=Math.min(r,i),s=b.slice(o,Math.max(r,i)+1).map((e,t)=>[e,o+t]).filter(([e,t])=>W(e,t)).map(([e,t])=>L(e,t)).filter(e=>(E?.has(e)||!1)!==a);if(ot)ot(s,a);else for(let e of s)it?.(e)},$t=e=>{rt?(b||[]).forEach((t,n)=>{let r=L(t,n);W(t,n)&&(E?.has(r)||!1)!==e&&it?.(r)}):at?.(e)},[en,tn]=h(()=>/* @__PURE__ */ new Set),nn=e=>tn(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),K=Te(()=>{let e=(b||[]).map((e,t)=>({row:e,i:t}));return N?ce(e,({row:e})=>String(v(e,N)??``)).flatMap(e=>[{group:e,open:!en.has(e.key)},...en.has(e.key)?[]:e.items]):e},[b,N,en]),rn=m(null),[q,an]=h(null),on=Ce(e=>{rn.current=e,an(e)},[]),sn=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;sn.current=t?Number(t)-2:null},r=t=>{t.relatedTarget instanceof Node&&e.contains(t.relatedTarget)||(sn.current=null)};e.addEventListener(`mouseover`,t),e.addEventListener(`focusin`,t),e.addEventListener(`focusin`,n),e.addEventListener(`focusout`,r);let i=oe(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=ae(q);return ve(document),e},[k,q]);let cn=m(Le);we(()=>{cn.current=()=>({total:b?.length??0,keys:b?b.flatMap((e,t)=>{let n=L(e,t);return W(e,t)&&E?.has(n)?[String(n)]:[]}):[]})});let ln=m(!1);p(()=>{if(!ln.current&&(ln.current=!0,G===0))return;let{total:e,keys:t}=cn.current();rn.current?.querySelector(`table`)?.dispatchEvent(new CustomEvent(`selectionchange`,{bubbles:!0,detail:{selected:G,total:e,keys:t}}))},[G]);let[un,dn]=h({top:0,height:0}),[J,fn]=h(f[D]??f.comfortable);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};dn(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 pn=m(null);we(()=>{if(!U){pn.current=null;return}let e=`${D}:${b?.length??0}`;if(pn.current===e)return;pn.current=e;let t=(rn.current?.querySelector(`:scope > table > tbody > tr:not(.wui-virtual-spacer, .wui-group-row)`))?.getBoundingClientRect().height;t!==void 0&&t>0&&Math.abs(t-J)>.5&&fn(t)});let Y={start:0,end:K.length,before:0,after:0};if(U){Y=ye({scrollTop:un.top,viewport:un.height||Number.parseFloat(String(mt))||0,rowHeight:J,count:K.length});let e=sn.current;e!==null&&e>=0&&e<K.length&&(e<Y.start&&Y.start-e<=Pe&&(Y={...Y,start:e,before:e*J}),e>=Y.end&&e-Y.end<Pe&&(Y={...Y,end:e+1,after:(K.length-e-1)*J}))}let mn=m(null),hn=m(null),gn=m(null),_n=!P&&!S&&b?.length>0&&b.length<=re;we(()=>{let e=mn.current;if(!_n||!e){hn.current=null,gn.current=null;return}let t=b.map((e,t)=>L(e,t));he(gn.current,t)&&me(e.rows,hn.current),hn.current=ue(e.rows),gn.current=t});let X=typeof F==`function`||typeof I==`function`,vn=m(null),yn=m(null),Z=y[0]?.key;p(()=>{if(!X){yn.current=null;return}let e=/* @__PURE__ */ new Map;(b||[]).forEach((t,n)=>{let r=Z===void 0?void 0:v(t,Z),i=typeof r==`string`||typeof r==`number`?String(r):``;e.set(L(t,n),{...ze(t,F,I),label:i})});let t=ge(_e(yn.current,e));yn.current=e,t&&vn.current&&(vn.current.textContent=t)},[b,F,I,L,X,Z]);let bn=Xe!==void 0&&(Ze===void 0||Ze>0)?Xe:Ye,xn=({group:e,open:t},n)=>{let i=v(e.items[0]?.row,N??``),a=e.items.map(e=>e.row);return/* @__PURE__ */ g(`tr`,{className:`wui-group-row`,"data-group-key":e.key,"aria-rowindex":U?n+2:void 0,children:/* @__PURE__ */ g(`th`,{className:`wui-group-cell`,scope:`rowgroup`,colSpan:Ht,children:/* @__PURE__ */ _(`button`,{type:`button`,className:`wui-group-toggle`,"aria-expanded":t,onClick:()=>nn(e.key),children:[/* @__PURE__ */ g(r,{name:`chevron-down`,size:16}),/* @__PURE__ */ g(`span`,{className:`wui-group-label`,children:Tt?Tt(i,a):He(Me(i,N??``))}),/* @__PURE__ */ g(`span`,{className:`wui-group-count`,"aria-hidden":`true`,children:se(e.items.length)}),/* @__PURE__ */ g(`span`,{className:`visually-hidden wui-group-rows`,children:`, ${u.rows(e.items.length)}`})]})})},`group:${e.key}`)},Sn=({row:e,i:t},n)=>{let i=L(e,t),o=z&&jt.has(i),s=St!=null&&String(St)===String(i),c=Ct!=null&&String(Ct)===String(i),l=String(i).replace(/[^a-z0-9]/gi,`_`),ee=V(0,`wui-expand-cell`),te=V(+!!z,`wui-select-cell`),u=X?ze(e,F,I):null,d=W(e,t),ne=C?.(e);if(C&&!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 f=Z===void 0?void 0:v(e,Z),re=typeof f==`string`||typeof f==`number`?`More actions for ${f}`:`More actions`;return/* @__PURE__ */ _(xe,{children:[/* @__PURE__ */ _(`tr`,{className:[T&&d&&E?.has(i)?`is-selected`:``,R?`wui-row-link`:``,s?`wui-row-active`:``,c?De.hover:``].filter(Boolean).join(` `)||void 0,"aria-current":s?`true`:void 0,"aria-rowindex":U?n+2:void 0,"aria-busy":u?.state===`saving`?`true`:void 0,"data-wui-save-state":u?.state||void 0,"data-status":bt?.(e)||void 0,"data-href":j?.(e)||void 0,"data-row-key":k?String(i):void 0,tabIndex:R?0:void 0,onClick:R?t=>It(e,t):void 0,onAuxClick:R&&j?t=>t.button===1&&It(e,t):void 0,onKeyDown:R?t=>{le(t.nativeEvent)&&t.target===t.currentTarget&&It(e,t)}:void 0,children:[z&&/* @__PURE__ */ g(`td`,{className:ee.className,style:ee.style,children:/* @__PURE__ */ g(`button`,{type:`button`,className:`wui-expand-toggle${o?` is-open`:``}`,"aria-expanded":o,"aria-controls":o?`${l}-expanded`:void 0,"aria-label":o?`Collapse row`:`Expand row`,onClick:()=>Nt(i),children:/* @__PURE__ */ g(r,{name:`chevron-down`,size:16})})}),T&&/* @__PURE__ */ g(`td`,{className:te.className,style:te.style,children:/* @__PURE__ */ g(`input`,{type:`checkbox`,className:`wui-check`,checked:d&&(E?.has(i)||!1),disabled:!d,onChange:e=>Qt(i,e.nativeEvent instanceof MouseEvent&&e.nativeEvent.shiftKey),onMouseDown:e=>{e.shiftKey&&e.preventDefault()},"aria-label":`Select row`})}),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 `:``)+Be(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):He(Ne(e,t.key)),n===0&&u?.state===`error`&&/* @__PURE__ */ g(`span`,{className:ie,children:u.message})]},t.key)}),C&&/* @__PURE__ */ g(`td`,{children:/* @__PURE__ */ g(a,{items:ne??[],menuLabel:re,linkComponent:Qe})})]}),o&&/* @__PURE__ */ g(`tr`,{className:`wui-row-expanded`,children:/* @__PURE__ */ g(`td`,{id:`${l}-expanded`,colSpan:Ht,children:st?.(e)})})]},i)},Cn=(e,t)=>`group`in e?xn(e,t):Sn(e,t),wn=(e,t)=>U?/* @__PURE__ */ g(`tr`,{className:`wui-virtual-spacer`,"aria-hidden":`true`,hidden:t===0,children:/* @__PURE__ */ g(`td`,{colSpan:Ht,style:{height:t}})},e):null,Q=V(0,`wui-expand-cell`),$=V(+!!z,`wui-select-cell`),Tn=()=>Array.from({length:Je},(e,t)=>`skeleton-${t}`).map(e=>/* @__PURE__ */ _(`tr`,{children:[z&&/* @__PURE__ */ g(`td`,{className:Q.className,style:Q.style}),T&&/* @__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 `:``)+Be(e.align)).className,style:H(B+t,void 0),"data-label":A&&typeof e.label==`string`?e.label:void 0,children:/* @__PURE__ */ g(o,{width:Ve(e.align),height:12,radius:6})},e.key)),C&&/* @__PURE__ */ g(`td`,{children:/* @__PURE__ */ g(`div`,{className:`u-row-actions`,children:/* @__PURE__ */ g(o,{width:`32px`,height:12,radius:6})})})]},e));return/* @__PURE__ */ _(Ee,{children:[/* @__PURE__ */ _(Wt?`wui-data-table`:`div`,{ref:on,...Wt?{class:zt,resizable:M?``:void 0,"view-key":wt||void 0,"data-wui-row-drag":k?``:void 0,"aria-busy":Rt||void 0}:{className:zt,"data-wui-row-drag":k?``:void 0,"aria-busy":Rt||void 0},style:Vt,tabIndex:0,...be,...Ot,children:[/* @__PURE__ */ _(`table`,{className:At,"aria-label":et,"aria-rowcount":U?K.length+1:void 0,style:lt===`fixed`?{tableLayout:`fixed`}:void 0,children:[/* @__PURE__ */ g(`thead`,{children:/* @__PURE__ */ _(`tr`,{"aria-rowindex":U?1:void 0,children:[z&&/* @__PURE__ */ g(`th`,{className:Q.className,style:Q.style,children:/* @__PURE__ */ g(`span`,{className:`visually-hidden`,children:`Expand`})}),T&&/* @__PURE__ */ g(`th`,{className:$.className,style:$.style,children:/* @__PURE__ */ g(`input`,{ref:Xt,type:`checkbox`,className:`wui-check`,checked:Jt,disabled:S,onChange:e=>$t(e.target.checked),"aria-label":`Select all rows`})}),y.map((e,t)=>{let n=e.sortable?Ke:void 0,a=n!==void 0,o=Ge&&Ge.key===e.key,s=e.align===`num`||e.align===`end`,c=a&&/* @__PURE__ */ g(`span`,{className:`sort-icon${s?` wui-sort-lead`:``}`,children:/* @__PURE__ */ g(r,{name:`chevrons-up-down`,size:14})}),l=M&&t!==Kt,d=e.width||e.minWidth?{width:e.width,minWidth:e.minWidth}:void 0;return/* @__PURE__ */ _(`th`,{className:V(B+t,(a?`sortable `:``)+(t===0?`wui-name-cell `:``)+(e.nowrap?`text-nowrap `:``)+(e.grow?`wui-col-grow `:``)+(l?`wui-col-resizable `:``)+Be(e.align)).className,style:H(B+t,d),"data-key":Wt?e.key:void 0,"aria-label":l&&typeof e.label==`string`?e.label:void 0,"data-pin":e.pin===`start`||e.pin===`end`?e.pin:void 0,tabIndex:a?0:void 0,"aria-sort":o?Ge?.dir===`asc`?`ascending`:`descending`:a?`none`:void 0,onClick:n?t=>{t.target instanceof Element&&t.target.closest(`.infotip`)||S||n(e.key)}:void 0,onKeyDown:n?t=>{t.target===t.currentTarget&&(le(t.nativeEvent)||t.key===` `)&&(t.preventDefault(),S||n(e.key))}:void 0,children:[s&&c,e.label,!s&&c,e.help?/* @__PURE__ */ g(i,{label:typeof e.label==`string`?e.label:void 0,children:e.help}):null,l&&/* @__PURE__ */ g(`span`,{className:`wui-col-resize`,role:`separator`,"aria-orientation":`vertical`,"aria-valuemin":te,"aria-valuemax":ee,tabIndex:0,"aria-label":u.resize(typeof e.label==`string`?e.label:e.key)})]},e.key)}),C&&($e?/* @__PURE__ */ g(`th`,{className:`wui-cell-end`,children:$e}):/* @__PURE__ */ g(`th`,{className:`wui-cell-end`,children:/* @__PURE__ */ g(`span`,{className:`visually-hidden`,children:`Actions`})}))]})}),/* @__PURE__ */ g(`tbody`,{ref:mn,children:S?Tn():b?.length?/* @__PURE__ */ _(Ee,{children:[wn(`before`,Y.before),K.slice(Y.start,Y.end).map((e,t)=>Cn(e,Y.start+t)),wn(`after`,Y.after)]}):null}),Pt&&!S&&b?.length>0&&/* @__PURE__ */ g(`tfoot`,{children:/* @__PURE__ */ _(`tr`,{children:[z&&/* @__PURE__ */ g(`td`,{className:Q.className,style:Q.style}),T&&/* @__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 `:``)+Be(e.align)).className,style:H(B+t,void 0),children:e.footer?e.footer(b):null},e.key)),C&&/* @__PURE__ */ g(`td`,{})]})})]}),!S&&!b?.length&&/* @__PURE__ */ g(`div`,{className:`tbl-empty-block`,children:typeof bn==`string`?/* @__PURE__ */ g(`div`,{className:`tbl-empty-plain`,children:bn}):bn})]}),Ue(w)&&/* @__PURE__ */ g(s,{page:w.page,totalPages:w.totalPages,total:w.total,pageSize:w.pageSize,onPageChange:S?Ie:w.setPage,onPageSizeChange:S?Ie:w.setPageSize,pageSizes:w.pageSizes,mode:w.mode,summary:w.summary}),X&&/* @__PURE__ */ g(`div`,{ref:vn,className:`visually-hidden`,role:`status`,"aria-live":`polite`,"data-wui-table-status":``})]})}export{We 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"./AppIcon.js";import o from"./AppInfoTip.js";import s from"./AppRowActions.js";import c from"./AppSkeleton.js";import l from"./AppTablePagination.js";import u from"./assertValidValue.js";import ee from"./warnUnknownProps.js";import{COLUMN_MAX_WIDTH as te,COLUMN_MIN_WIDTH as d,PIN_AT_VAR as f,PIN_SIDES as ne,ROW_HEIGHTS as p,ROW_MOVE_LIMIT as re,ROW_SAVE_ERROR_CLASS as ie,attachRowDrag as ae,attachScrollEdges as oe,groupCount as se,groupItems as ce,isImeSafeEnter as le,measureRows as ue,pinAtValue as de,pinClasses as fe,planPins as pe,playRowMoves as me,rowOrderChanged as he,saveOutcomeText as ge,settledRows as _e,syncTargets as ve,virtualRange as ye}from"@webority/ui-elements/helpers";import{Children as be,Fragment as xe,isValidElement as Se,useCallback as Ce,useEffect as m,useLayoutEffect as we,useMemo as Te,useRef as h,useState as g}from"react";import{Fragment as Ee,jsx as _,jsxs as v}from"react/jsx-runtime";import{DATA_TABLE_TEXT as De,ROW_ACTIONS_TEXT as Oe,fillText as ke,pluralText as Ae}from"@webority/ui-elements/text";import{FORCED_STATE_CLASSES as je}from"@webority/theme/runtime";var Me=()=>import(`@webority/ui-elements/elements/data-table`),Ne=[`comfortable`,`cozy`,`compact`],Pe=[`auto`,`fixed`],Fe=[1,2,3,4];function y(e,t){return typeof e==`object`&&e?Reflect.get(e,t):void 0}function Ie(e,t){if(e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`||Se(e)||Array.isArray(e))return e;throw Error(`AppDataTable: the value under "${t}" is not renderable; give that column a render function.`)}function Le(e,t){return Ie(y(e,t),t)}var Re=()=>{try{return process.env.NODE_ENV!==`production`}catch{return!0}},ze=/* @__PURE__ */ new Set;function b(t,n){!ze.has(t)&&Re()&&(ze.add(t),e(`[@webority/ui-react] <AppDataTable> ${n}`))}var Be=100,Ve=e=>{let t=typeof e==`object`&&e&&`id`in e?e.id:void 0;return typeof t==`string`||typeof t==`number`?t:void 0},He=()=>{},Ue=()=>({total:0,keys:[]}),We=[],Ge=(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 Ke(e){return e===`center`?`44%`:e===`end`||e===`num`?`56%`:`60%`}function qe(e){return e==null||e===``?t():Array.isArray(e)?be.toArray(e):typeof e==`boolean`?String(e):e}function Je(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`,Me);let t=r(`dataTable`,De),be=r(`rowActions`,Oe),Se=e=>e?ke(t.resizeColumnText,{label:e}):t.resizeColumnLabel,{marker:Re,props:ze}=i(`AppDataTable`,e),{columns:S,rows:C=We,rowKey:Ye=Ve,sort:Xe,onSort:Ze,loading:w=!1,refreshing:Qe=!1,skeletonRows:$e=5,empty:et=t.empty,emptyFiltered:tt,sourceCount:nt,rowActions:T,linkComponent:rt,rowActionsLabel:it,pagination:E,ariaLabel:at,className:ot=``,wrapperClassName:st=``,selectable:D=!1,selectedIds:O,isRowSelectable:ct,onToggleRow:lt,onToggleAll:ut,onSelectRange:dt,renderExpanded:ft,singleExpand:pt=!1,density:k=`comfortable`,tableLayout:mt=`auto`,striped:ht=!1,flush:gt=!1,pad:_t,nameLines:A,headerTone:vt,rowDrag:j=!1,maxHeight:yt,stickyFirstColumn:bt=!1,stickyActions:xt=!1,equalActions:St=!1,linkFirstColumn:Ct=!1,stackOnMobile:M=!1,hiddenColumns:wt,rowStatus:Tt,rowHref:N,onRowClick:Et,activeRowKey:Dt,hoverRowKey:Ot,resizableColumns:P=!1,viewKey:kt,groupBy:F,groupLabel:At,virtual:I=!1,rowSaving:L,rowSaveError:R,...jt}=ze;ee(`AppDataTable`,jt);let{style:Mt,...Nt}=jt,z=Ce((e,t)=>{let n=Ye(e,t);if(n==null)throw Error(`AppDataTable: a row has no key. Pass rowKey, or give every row an id.`);return n},[Ye]),Pt=wt?.length?new Set(wt):null;S=Pt?S.filter(e=>!(e.hideable&&Pt.has(e.key))):S,u(`AppDataTable`,`density`,k,Ne),u(`AppDataTable`,`tableLayout`,mt,Pe),u(`AppDataTable`,`nameLines`,A,Fe);for(let e of S)u(`AppDataTable`,`column.pin`,e.pin,ne);let B=typeof N==`function`||typeof Et==`function`,Ft=[`table table-ledger`,k===`cozy`||k===`compact`?`wui-table-${k}`:``,ht?`wui-table-striped`:``,bt?`wui-table-sticky-first`:``,xt?`wui-table-sticky-actions`:``,St?`wui-table-equal-actions`:``,M?`wui-table-stack`:``,Ct&&B?`wui-table-link-first`:``,ot].filter(Boolean).join(` `),V=typeof ft==`function`,[It,Lt]=g(()=>/* @__PURE__ */ new Set),Rt=e=>Lt(t=>{if(t.has(e)){let n=new Set(t);return n.delete(e),n}return pt?/* @__PURE__ */ new Set([e]):new Set(t).add(e)}),zt=S.some(e=>typeof e.footer==`function`),Bt=e=>!!(e.target instanceof Element&&e.target.closest(`a, button, input, select, textarea, label, [role='menu'], [role='menuitem'], .dropdown`)),Vt=(e,t)=>{if(Bt(t)||(Et&&Et(e),!N))return;let n=N(e);n&&(t.ctrlKey||t.metaKey||t.button===1?window.open(n,`_blank`,`noopener`):window.location.assign(n))},H=yt!==void 0,Ht=Qe&&!w&&C.length>0,Ut=[`table-wrap`,H?`wui-table-scroll`:``,gt?`wui-table-flush`:``,Ht?`wui-table-refreshing`:``,st].filter(Boolean).join(` `),Wt={maxHeight:H?yt:void 0,"--wui-table-pad":_t!=null&&!gt?`${_t}px`:void 0,"--wui-name-lines":I?`1`:A?.toString(),"--wui-table-header-bg":vt??void 0},Gt=Object.values(Wt).some(e=>e!==void 0)||Mt!==void 0?{...Wt,...Mt}:void 0,Kt=Math.max(1,S.length+ +!!T+ +!!D+ +!!V),qt=S.some(e=>e.pin===`start`||e.pin===`end`),Jt=qt||P||!!F||I,U=+!!V+ +!!D,Yt=qt?pe([...V?[`lead`]:[],...D?[`lead`]:[],...S.map(e=>e.pin===`start`||e.pin===`end`?e.pin:null),...T?[null]:[]]):[],W=(e,t=``)=>{let n=Yt[e];return n?{className:`${t.trim()} ${fe(n)}`.trim(),style:{[f]:de(n.side,n.ordinal)}}:{className:t,style:void 0}},Xt=(e,t)=>Yt[e]?{...t,...W(e).style}:t,Zt=S.length-1+ +!!T;kt&&!P&&b(`view-key`,"`viewKey` remembers resized widths: add `resizableColumns`."),I&&!H&&b(`virtual-height`,"`virtual` needs `maxHeight`: without a scroll box every row renders."),I&&(V||M)&&b(`virtual-shape`,"`virtual` takes rows of one height, so it is off with `renderExpanded` or `stackOnMobile`."),I&&A!==void 0&&A!==1&&b(`virtual-name-lines`,"`nameLines` is ignored with `virtual`: a virtual table shows one line per name."),Ct&&!B&&b(`link-first-column`,"`linkFirstColumn` needs rowHref or onRowClick: the row is what opens."),pt&&typeof ft!=`function`&&b(`single-expand`,"`singleExpand` needs renderExpanded: there are no rows to expand."),!I&&C?.length>500&&b(`rows-without-virtual`,`renders more than 500 rows without virtual: add virtual with maxHeight, or page the data.`);let G=I&&H&&!V&&!M&&!w&&C?.length>0,K=(e,t)=>!ct||!!ct(e,t),Qt=D&&C?C.reduce((e,t,n)=>e+ +!!K(t,n),0):0,q=D&&C?C.reduce((e,t,n)=>e+(K(t,n)&&O?.has(z(t,n))?1:0),0):0,$t=Qt>0&&q===Qt,en=q>0&&!$t,tn=e=>{e&&(e.indeterminate=en)},nn=h(null),rn=(e,t)=>{let n=nn.current;nn.current=e;let r=t&&n!==null?C.findIndex((e,t)=>z(e,t)===n):-1,i=C.findIndex((t,n)=>z(t,n)===e);if(r<0||i<0||r===i){lt?.(e);return}let a=!O?.has(e),o=Math.min(r,i),s=C.slice(o,Math.max(r,i)+1).map((e,t)=>[e,o+t]).filter(([e,t])=>K(e,t)).map(([e,t])=>z(e,t)).filter(e=>(O?.has(e)||!1)!==a);if(dt)dt(s,a);else for(let e of s)lt?.(e)},an=e=>{ct?(C||[]).forEach((t,n)=>{let r=z(t,n);K(t,n)&&(O?.has(r)||!1)!==e&&lt?.(r)}):ut?.(e)},[on,sn]=g(()=>/* @__PURE__ */ new Set),cn=e=>sn(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),J=Te(()=>{let e=(C||[]).map((e,t)=>({row:e,i:t}));return F?ce(e,({row:e})=>String(y(e,F)??``)).flatMap(e=>[{group:e,open:!on.has(e.key)},...on.has(e.key)?[]:e.items]):e},[C,F,on]),ln=h(null),[Y,un]=g(null),dn=Ce(e=>{ln.current=e,un(e)},[]),fn=h(null);m(()=>{let e=Y;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;fn.current=t?Number(t)-2:null},r=t=>{t.relatedTarget instanceof Node&&e.contains(t.relatedTarget)||(fn.current=null)};e.addEventListener(`mouseover`,t),e.addEventListener(`focusin`,t),e.addEventListener(`focusin`,n),e.addEventListener(`focusout`,r);let i=oe(e);return()=>{e.removeEventListener(`mouseover`,t),e.removeEventListener(`focusin`,t),e.removeEventListener(`focusin`,n),e.removeEventListener(`focusout`,r),i()}},[Y]),m(()=>{if(!j||!Y)return;let e=ae(Y);return ve(document),e},[j,Y]);let pn=h(Ue);we(()=>{pn.current=()=>({total:C?.length??0,keys:C?C.flatMap((e,t)=>{let n=z(e,t);return K(e,t)&&O?.has(n)?[String(n)]:[]}):[]})});let mn=h(!1);m(()=>{if(!mn.current&&(mn.current=!0,q===0))return;let{total:e,keys:t}=pn.current();ln.current?.querySelector(`table`)?.dispatchEvent(new CustomEvent(`selectionchange`,{bubbles:!0,detail:{selected:q,total:e,keys:t}}))},[q]);let[hn,gn]=g({top:0,height:0}),[_n,vn]=g(p[k]??p.comfortable);m(()=>{let e=Y;if(!G||!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};gn(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)}},[G,Y]);let yn=h(null);we(()=>{if(!G){yn.current=null;return}let e=`${k}:${C?.length??0}`;if(yn.current===e)return;yn.current=e;let t=(ln.current?.querySelector(`:scope > table > tbody > tr:not(.wui-virtual-spacer, .wui-group-row)`))?.getBoundingClientRect().height;t!==void 0&&t>0&&Math.abs(t-_n)>.5&&vn(t)});let X={start:0,end:J.length,before:0,after:0};if(G){X=ye({scrollTop:hn.top,viewport:hn.height||Number.parseFloat(String(yt))||0,rowHeight:_n,count:J.length});let e=fn.current;e!==null&&e>=0&&e<J.length&&(e<X.start&&X.start-e<=Be&&(X={...X,start:e,before:e*_n}),e>=X.end&&e-X.end<Be&&(X={...X,end:e+1,after:(J.length-e-1)*_n}))}let bn=h(null),xn=h(null),Sn=h(null),Cn=!I&&!w&&C?.length>0&&C.length<=re;we(()=>{let e=bn.current;if(!Cn||!e){xn.current=null,Sn.current=null;return}let t=C.map((e,t)=>z(e,t));he(Sn.current,t)&&me(e.rows,xn.current),xn.current=ue(e.rows),Sn.current=t});let wn=typeof L==`function`||typeof R==`function`,Tn=h(null),En=h(null),Z=S[0]?.key;m(()=>{if(!wn){En.current=null;return}let e=/* @__PURE__ */ new Map;(C||[]).forEach((t,n)=>{let r=Z===void 0?void 0:y(t,Z),i=typeof r==`string`||typeof r==`number`?String(r):``;e.set(z(t,n),{...Ge(t,L,R),label:i})});let t=ge(_e(En.current,e));En.current=e,t&&Tn.current&&(Tn.current.textContent=t)},[C,L,R,z,wn,Z]);let Dn=tt!==void 0&&(nt===void 0||nt>0)?tt:et,On=({group:e,open:n},r)=>{let i=y(e.items[0]?.row,F??``),o=e.items.map(e=>e.row);return/* @__PURE__ */ _(`tr`,{className:`wui-group-row`,"data-group-key":e.key,"aria-rowindex":G?r+2:void 0,children:/* @__PURE__ */ _(`th`,{className:`wui-group-cell`,scope:`rowgroup`,colSpan:Kt,children:/* @__PURE__ */ v(`button`,{type:`button`,className:`wui-group-toggle`,"aria-expanded":n,onClick:()=>cn(e.key),children:[/* @__PURE__ */ _(a,{name:`chevron-down`,size:16}),/* @__PURE__ */ _(`span`,{className:`wui-group-label`,children:At?At(i,o):qe(Ie(i,F??``))}),/* @__PURE__ */ _(`span`,{className:`wui-group-count`,"aria-hidden":`true`,children:se(e.items.length)}),/* @__PURE__ */ _(`span`,{className:`visually-hidden wui-group-rows`,children:`, ${Ae(t,`groupRows`,e.items.length,{count:se(e.items.length)})}`})]})})},`group:${e.key}`)},kn=({row:e,i:n},r)=>{let i=z(e,n),o=V&&It.has(i),c=Dt!=null&&String(Dt)===String(i),l=Ot!=null&&String(Ot)===String(i),u=String(i).replace(/[^a-z0-9]/gi,`_`),ee=W(0,`wui-expand-cell`),te=W(+!!V,`wui-select-cell`),d=wn?Ge(e,L,R):null,f=K(e,n),ne=T?.(e);if(T&&!Array.isArray(ne))throw TypeError(`AppDataTable: rowActions returns a list of actions ({ key, label, icon, onClick or href }). It returned something else: restate the buttons as a list, see node scripts/codemods/row-actions.mjs --check.`);let p=Z===void 0?void 0:y(e,Z),re=typeof p==`string`||typeof p==`number`?ke(t.moreActionsForText,{firstValue:p}):be.menuLabel;return/* @__PURE__ */ v(xe,{children:[/* @__PURE__ */ v(`tr`,{className:[D&&f&&O?.has(i)?`is-selected`:``,B?`wui-row-link`:``,c?`wui-row-active`:``,l?je.hover:``].filter(Boolean).join(` `)||void 0,"aria-current":c?`true`:void 0,"aria-rowindex":G?r+2:void 0,"aria-busy":d?.state===`saving`?`true`:void 0,"data-wui-save-state":d?.state||void 0,"data-status":Tt?.(e)||void 0,"data-href":N?.(e)||void 0,"data-row-key":j?String(i):void 0,tabIndex:B?0:void 0,onClick:B?t=>Vt(e,t):void 0,onAuxClick:B&&N?t=>t.button===1&&Vt(e,t):void 0,onKeyDown:B?t=>{le(t.nativeEvent)&&t.target===t.currentTarget&&Vt(e,t)}:void 0,children:[V&&/* @__PURE__ */ _(`td`,{className:ee.className,style:ee.style,children:/* @__PURE__ */ _(`button`,{type:`button`,className:`wui-expand-toggle${o?` is-open`:``}`,"aria-expanded":o,"aria-controls":o?`${u}-expanded`:void 0,"aria-label":o?t.collapseRowLabel:t.expandRowLabel,onClick:()=>Rt(i),children:/* @__PURE__ */ _(a,{name:`chevron-down`,size:16})})}),D&&/* @__PURE__ */ _(`td`,{className:te.className,style:te.style,children:/* @__PURE__ */ _(`input`,{type:`checkbox`,className:`wui-check`,checked:f&&(O?.has(i)||!1),disabled:!f,onChange:e=>rn(i,e.nativeEvent instanceof MouseEvent&&e.nativeEvent.shiftKey),onMouseDown:e=>{e.shiftKey&&e.preventDefault()},"aria-label":t.selectRowLabel})}),S.map((t,n)=>{let r=t.rowHeader?`th`:`td`;return/* @__PURE__ */ v(r,{scope:t.rowHeader?`row`:void 0,className:W(U+n,(n===0?`wui-name-cell `:``)+(t.rowHeader?`wui-row-header `:``)+(t.nowrap?`text-nowrap `:``)+x(t.align)+(t.cellClassName?` ${t.cellClassName}`:``)).className,style:Xt(U+n,t.cellStyle),"data-label":M&&typeof t.label==`string`?t.label:void 0,children:[t.render?t.render(e):qe(Le(e,t.key)),n===0&&d?.state===`error`&&/* @__PURE__ */ _(`span`,{className:ie,children:d.message})]},t.key)}),T&&/* @__PURE__ */ _(`td`,{children:/* @__PURE__ */ _(s,{items:ne??[],menuLabel:re,linkComponent:rt})})]}),o&&/* @__PURE__ */ _(`tr`,{className:`wui-row-expanded`,children:/* @__PURE__ */ _(`td`,{id:`${u}-expanded`,colSpan:Kt,children:ft?.(e)})})]},i)},An=(e,t)=>`group`in e?On(e,t):kn(e,t),jn=(e,t)=>G?/* @__PURE__ */ _(`tr`,{className:`wui-virtual-spacer`,"aria-hidden":`true`,hidden:t===0,children:/* @__PURE__ */ _(`td`,{colSpan:Kt,style:{height:t}})},e):null,Q=W(0,`wui-expand-cell`),$=W(+!!V,`wui-select-cell`),Mn=()=>Array.from({length:$e},(e,t)=>`skeleton-${t}`).map(e=>/* @__PURE__ */ v(`tr`,{children:[V&&/* @__PURE__ */ _(`td`,{className:Q.className,style:Q.style}),D&&/* @__PURE__ */ _(`td`,{className:$.className,style:$.style}),S.map((e,t)=>/* @__PURE__ */ _(`td`,{className:W(U+t,(t===0?`wui-name-cell `:``)+(e.nowrap?`text-nowrap `:``)+x(e.align)).className,style:Xt(U+t,void 0),"data-label":M&&typeof e.label==`string`?e.label:void 0,children:/* @__PURE__ */ _(c,{width:Ke(e.align),height:12,radius:6})},e.key)),T&&/* @__PURE__ */ _(`td`,{children:/* @__PURE__ */ _(`div`,{className:`u-row-actions`,children:/* @__PURE__ */ _(c,{width:`32px`,height:12,radius:6})})})]},e));return/* @__PURE__ */ v(Ee,{children:[/* @__PURE__ */ v(Jt?`wui-data-table`:`div`,{ref:dn,...Jt?{class:Ut,resizable:P?``:void 0,"view-key":kt||void 0,"data-wui-row-drag":j?``:void 0,"aria-busy":Ht||void 0}:{className:Ut,"data-wui-row-drag":j?``:void 0,"aria-busy":Ht||void 0},style:Gt,tabIndex:0,...Re,...Nt,children:[/* @__PURE__ */ v(`table`,{className:Ft,"aria-label":at,"aria-rowcount":G?J.length+1:void 0,style:mt===`fixed`?{tableLayout:`fixed`}:void 0,children:[/* @__PURE__ */ _(`thead`,{children:/* @__PURE__ */ v(`tr`,{"aria-rowindex":G?1:void 0,children:[V&&/* @__PURE__ */ _(`th`,{className:Q.className,style:Q.style,children:/* @__PURE__ */ _(`span`,{className:`visually-hidden`,children:t.expandLabel})}),D&&/* @__PURE__ */ _(`th`,{className:$.className,style:$.style,children:/* @__PURE__ */ _(`input`,{ref:tn,type:`checkbox`,className:`wui-check`,checked:$t,disabled:w,onChange:e=>an(e.target.checked),"aria-label":t.selectAllRowsLabel})}),S.map((e,t)=>{let n=e.sortable?Ze:void 0,r=n!==void 0,i=Xe&&Xe.key===e.key,s=e.align===`num`||e.align===`end`,c=r&&/* @__PURE__ */ _(`span`,{className:`sort-icon${s?` wui-sort-lead`:``}`,children:/* @__PURE__ */ _(a,{name:`chevrons-up-down`,size:14})}),l=P&&t!==Zt,u=e.width||e.minWidth?{width:e.width,minWidth:e.minWidth}:void 0;return/* @__PURE__ */ v(`th`,{className:W(U+t,(r?`sortable `:``)+(t===0?`wui-name-cell `:``)+(e.nowrap?`text-nowrap `:``)+(e.grow?`wui-col-grow `:``)+(l?`wui-col-resizable `:``)+x(e.align)).className,style:Xt(U+t,u),"data-key":Jt?e.key:void 0,"aria-label":l&&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?Xe?.dir===`asc`?`ascending`:`descending`:r?`none`:void 0,onClick:n?t=>{t.target instanceof Element&&t.target.closest(`.infotip`)||w||n(e.key)}:void 0,onKeyDown:n?t=>{t.target===t.currentTarget&&(le(t.nativeEvent)||t.key===` `)&&(t.preventDefault(),w||n(e.key))}:void 0,children:[s&&c,e.label,!s&&c,e.help?/* @__PURE__ */ _(o,{label:typeof e.label==`string`?e.label:void 0,children:e.help}):null,l&&/* @__PURE__ */ _(`span`,{className:`wui-col-resize`,role:`separator`,"aria-orientation":`vertical`,"aria-valuemin":d,"aria-valuemax":te,tabIndex:0,"aria-label":Se(typeof e.label==`string`?e.label:e.key)})]},e.key)}),T&&(it?/* @__PURE__ */ _(`th`,{className:`wui-cell-end`,children:it}):/* @__PURE__ */ _(`th`,{className:`wui-cell-end`,children:/* @__PURE__ */ _(`span`,{className:`visually-hidden`,children:t.rowActionsLabel})}))]})}),/* @__PURE__ */ _(`tbody`,{ref:bn,children:w?Mn():C?.length?/* @__PURE__ */ v(Ee,{children:[jn(`before`,X.before),J.slice(X.start,X.end).map((e,t)=>An(e,X.start+t)),jn(`after`,X.after)]}):null}),zt&&!w&&C?.length>0&&/* @__PURE__ */ _(`tfoot`,{children:/* @__PURE__ */ v(`tr`,{children:[V&&/* @__PURE__ */ _(`td`,{className:Q.className,style:Q.style}),D&&/* @__PURE__ */ _(`td`,{className:$.className,style:$.style}),S.map((e,t)=>/* @__PURE__ */ _(`td`,{className:W(U+t,(t===0?`wui-name-cell `:``)+(e.nowrap?`text-nowrap `:``)+x(e.align)).className,style:Xt(U+t,void 0),children:e.footer?e.footer(C):null},e.key)),T&&/* @__PURE__ */ _(`td`,{})]})})]}),!w&&!C?.length&&/* @__PURE__ */ _(`div`,{className:`tbl-empty-block`,children:typeof Dn==`string`?/* @__PURE__ */ _(`div`,{className:`tbl-empty-plain`,children:Dn}):Dn})]}),Je(E)&&/* @__PURE__ */ _(l,{page:E.page,totalPages:E.totalPages,total:E.total,pageSize:E.pageSize,onPageChange:w?He:E.setPage,onPageSizeChange:w?He:E.setPageSize,pageSizes:E.pageSizes,mode:E.mode,summary:E.summary}),wn&&/* @__PURE__ */ _(`div`,{ref:Tn,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 n}from"../lib/formFields.js";import r from"../lib/useElementEntry.js";import{splitMarkerProps as i}from"../lib/wuiMarker.js";import a from"./AppInfoTip.js";import o from"./AppRequiredMark.js";import s from"./assertValidValue.js";import ee 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";var h=[`sm`,`md`,`lg`],g=()=>import(`@webority/ui-elements/elements/datepicker`),_=d(function(d,_){let v=r(`wui-datepicker`,g),{marker:y,props:b}=i(`AppDatePicker`,d),{value:x,onChange:te,label:S,required:C=!1,optional:w=!1,optionalLabel:T=`(optional)`,helperText:E,error:D,name:O,min:k,max:A,placeholder:j=`Choose a date`,disabled:M,readOnly:N=!1,loading:P=!1,defaultValue:F,help:I,helpLabel:ne=`More information`,size:L,firstDay:R,displayFormat:z,id:B,ariaLabel:V,className:H=``,fieldClassName:U=``,...W}=b,G=n(O),K=D??G;l(`AppDatePicker`,W),s(`AppDatePicker`,`size`,L,h),typeof z==`string`&&z!==``&&/DD|YYYY|YY/.test(z)&&e(`[@webority/ui-react] <AppDatePicker> displayFormat "${z}" uses uppercase day or year tokens, which print as written; the tokens are yyyy, MMMM, MMM, MM, dd and d.`);let q=f(),J=B||q,{setRef:Y}=c({ready:v,ref:_,value:x??(F===void 0?``:void 0),defaultValue:F,onChange:te}),X=!S&&!K&&!E,Z=K?`${J}-error`:void 0,Q=E?`${J}-hint`:void 0,re=Z||Q,$=/* @__PURE__ */ p(`wui-datepicker`,{ref:Y,id:J,name:O,value:(x??F)||void 0,min:k,max:A,placeholder:j,size:L||void 0,"first-day":R==null?void 0:String(R),"display-format":z||void 0,"aria-label":V||ee(S)||void 0,"aria-describedby":re,"aria-invalid":K?`true`:void 0,disabled:M?``:void 0,readonly:N?``:void 0,loading:P?``:void 0,required:C?``:void 0,className:H||void 0,...W});return X?u($,y):/* @__PURE__ */ m(`div`,{...y,className:`field${U?` ${U}`:``}`,children:[S&&/* @__PURE__ */ m(`label`,{className:`label`,htmlFor:J,children:[S,w&&!C&&/* @__PURE__ */ p(`span`,{className:`label-optional`,children:` ${T}`}),C&&/* @__PURE__ */ p(o,{}),I&&/* @__PURE__ */ p(a,{label:ne,children:I})]}),$,/* @__PURE__ */ p(t,{error:K,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 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 +1 @@
1
- import e from"../lib/FieldMessage.js";import{useFieldError as t}from"../lib/formFields.js";import n from"../lib/useElementEntry.js";import{splitMarkerProps as ee}from"../lib/wuiMarker.js";import te from"./AppInfoTip.js";import ne from"./AppRequiredMark.js";import r from"./assertValidValue.js";import i from"./textOf.js";import a from"./useWuiControl.js";import o from"./warnUnknownProps.js";import{cloneElement as s,forwardRef as c,useEffect as l,useId as re,useRef as ie}from"react";import{jsx as u,jsxs as d}from"react/jsx-runtime";var ae=[`sm`,`md`,`lg`],oe=()=>import(`@webority/ui-elements/elements/date-range`),se=e=>{if(e?.length)return e.every(e=>typeof e==`string`)?e.join(`,`):JSON.stringify(e)},f=c(function(c,f){let p=n(`wui-date-range`,oe),{marker:m,props:h}=ee(`AppDateRangePicker`,c),{start:g,end:_,defaultStart:v,defaultEnd:y,onChange:b,open:x,onOpenChange:S,label:C,help:w,helpLabel:ce=`More information`,required:T=!1,optional:E=!1,optionalLabel:D=`(optional)`,helperText:O,error:k,startName:A,endName:j,min:M,max:N,placeholder:P=`Start to End`,disabled:F,readOnly:I=!1,loading:L=!1,size:R,firstDay:z,timeZone:B,financialYearStart:V,presets:le,id:H,ariaLabel:U,className:W=``,fieldClassName:G=``,...K}=h,ue=t(A),de=t(j),q=k??ue??de;o(`AppDateRangePicker`,K),r(`AppDateRangePicker`,`size`,R,ae);let fe=re(),J=H||fe,{setRef:pe,innerRef:Y}=a({ready:p,ref:e=>{typeof f==`function`?f(e):f&&(f.current=e)},onChange:b}),X=ie(!1);l(()=>{if(!p)return;let e=Y.current;if(!e)return;let t=g===void 0?!X.current&&v!==void 0?v:e.value.start:g,n=_===void 0?!X.current&&y!==void 0?y:e.value.end:_;(e.value.start!==t||e.value.end!==n)&&(e.value={start:t,end:n}),X.current=!0},[p,g,_,v,y,Y]),l(()=>{if(!p||x===void 0)return;let e=Y.current;e&&e.open!==x&&(e.open=x)},[p,x,Y]),l(()=>{let e=Y.current;if(!p||!e||!S)return;let t=t=>{t instanceof CustomEvent&&t.target===e&&S(!!t.detail?.open)};return e.addEventListener(`wui-date-range:openchange`,t),()=>e.removeEventListener(`wui-date-range:openchange`,t)},[p,S,Y]);let me=!C&&!q&&!O,Z=q?`${J}-error`:void 0,Q=O?`${J}-hint`:void 0,he=Z||Q,$=/* @__PURE__ */ u(`wui-date-range`,{ref:pe,id:J,"start-name":A,"end-name":j,min:M,max:N,placeholder:P,size:R||void 0,"first-day":z==null?void 0:String(z),"time-zone":B||void 0,"financial-year-start":V==null?void 0:String(V),presets:se(le),"aria-label":U||i(C)||void 0,"aria-describedby":he,"aria-invalid":q?`true`:void 0,disabled:F?``:void 0,readonly:I?``:void 0,loading:L?``:void 0,required:T?``:void 0,className:W||void 0,...K});return me?s($,m):/* @__PURE__ */ d(`div`,{...m,className:`field${G?` ${G}`:``}`,children:[C&&/* @__PURE__ */ d(`label`,{className:`label`,htmlFor:J,children:[C,E&&!T&&/* @__PURE__ */ u(`span`,{className:`label-optional`,children:` ${D}`}),T&&/* @__PURE__ */ u(ne,{}),w&&/* @__PURE__ */ u(te,{label:ce,children:w})]}),$,/* @__PURE__ */ u(e,{error:q,hint:O,errorId:Z,hintId:Q})]})});export{f as default};
1
+ import e from"../lib/FieldMessage.js";import{useFieldError as t}from"../lib/formFields.js";import n from"../lib/useElementEntry.js";import ee from"../lib/useWuiText.js";import{splitMarkerProps as r}from"../lib/wuiMarker.js";import i from"./AppInfoTip.js";import a from"./AppRequiredMark.js";import te 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,useEffect as d,useId as ne,useRef as f}from"react";import{jsx as p,jsxs as m}from"react/jsx-runtime";import{DATE_RANGE_PICKER_TEXT as re}from"@webority/ui-elements/text";var ie=[`sm`,`md`,`lg`,`xl`],ae=()=>import(`@webority/ui-elements/elements/date-range`),oe=e=>{if(e?.length)return e.every(e=>typeof e==`string`)?e.join(`,`):JSON.stringify(e)},h=u(function(u,h){let g=n(`wui-date-range`,ae),_=ee(`dateRangePicker`,re),{marker:v,props:se}=r(`AppDateRangePicker`,u),{start:y,end:b,defaultStart:x,defaultEnd:S,onChange:C,open:w,onOpenChange:T,label:E,help:D,helpLabel:ce=_.helpLabel,required:O=!1,optional:k=!1,optionalLabel:A=_.optionalLabel,helperText:j,error:M,startName:N,endName:P,min:F,max:I,placeholder:L=_.placeholder,disabled:R,readOnly:z=!1,loading:B=!1,size:V,firstDay:H,timeZone:le,financialYearStart:U,presets:W,id:ue,ariaLabel:de,className:fe=``,fieldClassName:G=``,...K}=se,pe=t(N),me=t(P),q=M??pe??me;c(`AppDateRangePicker`,K),te(`AppDateRangePicker`,`size`,V,ie);let he=ne(),J=ue||he,{setRef:ge,innerRef:Y}=s({ready:g,ref:e=>{typeof h==`function`?h(e):h&&(h.current=e)},onChange:C}),X=f(!1);d(()=>{if(!g)return;let e=Y.current;if(!e)return;let t=y===void 0?!X.current&&x!==void 0?x:e.value.start:y,n=b===void 0?!X.current&&S!==void 0?S:e.value.end:b;(e.value.start!==t||e.value.end!==n)&&(e.value={start:t,end:n}),X.current=!0},[g,y,b,x,S,Y]),d(()=>{if(!g||w===void 0)return;let e=Y.current;e&&e.open!==w&&(e.open=w)},[g,w,Y]),d(()=>{let e=Y.current;if(!g||!e||!T)return;let t=t=>{t instanceof CustomEvent&&t.target===e&&T(!!t.detail?.open)};return e.addEventListener(`wui-date-range:openchange`,t),()=>e.removeEventListener(`wui-date-range:openchange`,t)},[g,T,Y]);let _e=!E&&!q&&!j,Z=q?`${J}-error`:void 0,Q=j?`${J}-hint`:void 0,ve=Z||Q,$=/* @__PURE__ */ p(`wui-date-range`,{ref:ge,id:J,"start-name":N,"end-name":P,min:F,max:I,placeholder:L,size:V||void 0,"first-day":H==null?void 0:String(H),"time-zone":le||void 0,"financial-year-start":U==null?void 0:String(U),presets:oe(W),"aria-label":de||o(E)||void 0,"aria-describedby":ve,"aria-invalid":q?`true`:void 0,disabled:R?``:void 0,readonly:z?``:void 0,loading:B?``:void 0,required:O?``:void 0,className:fe||void 0,...K});return _e?l($,v):/* @__PURE__ */ m(`div`,{...v,className:`field${G?` ${G}`:``}`,children:[E&&/* @__PURE__ */ m(`label`,{className:`label`,htmlFor:J,children:[E,k&&!O&&/* @__PURE__ */ p(`span`,{className:`label-optional`,children:` ${A}`}),O&&/* @__PURE__ */ p(a,{}),D&&/* @__PURE__ */ p(i,{label:ce,children:D})]}),$,/* @__PURE__ */ p(e,{error:q,hint:j,errorId:Z,hintId:Q})]})});export{h as default};
@@ -1 +1 @@
1
- import{isEmpty as e}from"../lib/emptyValue.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"./assertValidValue.js";import a from"./renderIconProp.js";import o from"./warnUnknownProps.js";import{jsx as s,jsxs as c}from"react/jsx-runtime";var l=[`sm`,`md`],u=[`grid`,`summary`,`list`],d=[1,2,3,4];function f(e,t){if(typeof e==`string`)return`${e}-${t}`;throw Error("<AppDescriptions> an item whose label is not text needs a `key`.")}function p(p){let{marker:m,props:h}=r(`AppDescriptions`,p),{items:g=[],columns:_=2,size:v=`md`,bordered:y=!1,layout:b=`grid`,title:x,linkComponent:S,className:C=``,...w}=h;o(`AppDescriptions`,w),i(`AppDescriptions`,`columns`,_,d),i(`AppDescriptions`,`size`,v,l),i(`AppDescriptions`,`layout`,b,u);let T=[`descs`,`descs-col-${_}`,v&&v!==`md`?`descs-${v}`:``,y?`descs-bordered`:``,b===`summary`?`wui-descs-summary`:``,b===`list`?`wui-descs-list`:``,_===4?`wui-descs-col-4`:``,C].filter(Boolean).join(` `)||void 0;return/* @__PURE__ */ c(`div`,{className:T,...m,...w,children:[x&&/* @__PURE__ */ s(`div`,{className:`descs-title`,children:x}),/* @__PURE__ */ s(`dl`,{className:`descs-list`,children:g.map((r,i)=>{let o=e(r.value),l=Math.min(12,Math.max(1,r.span??1)),u=r.key??f(r.label,i),d=o?`-`:r.value,p=t(S,{href:r.href}),m=Object.fromEntries(Object.entries(r).filter(([e])=>e.startsWith(`data-`)));return/* @__PURE__ */ c(`div`,{className:`descs-item${r.emphasis?` wui-descs-emphasis`:``} wui-descs-span-${l}`,id:r.id,tabIndex:r.tabIndex,...m,children:[r.icon&&/* @__PURE__ */ s(`span`,{className:`wui-descs-icon`,children:a(r.icon,{size:16})}),/* @__PURE__ */ s(`dt`,{className:`descs-label`,children:r.label}),/* @__PURE__ */ s(`dd`,{className:`descs-value${o?` is-empty`:``}${r.multiline&&!o?` wui-pre-line`:``}`,children:r.href?/* @__PURE__ */ s(n,{link:p,className:`wui-descs-link`,children:d}):d})]},u)})})]})}export{p 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];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 +1 @@
1
- import e from"../lib/DiscardPrompt.js";import t from"../lib/useElementEntry.js";import{splitMarkerProps as n}from"../lib/wuiMarker.js";import r from"./AppIcon.js";import i from"./assertValidValue.js";import a from"./warnUnknownProps.js";import{useEffect as o,useId as s,useRef as c,useState as l}from"react";import{jsx as u,jsxs as d}from"react/jsx-runtime";var f=[`end`,`start`],p=[`sm`,`md`,`lg`,`xl`],m=[50,90],h=()=>import(`@webority/ui-elements/elements/drawer`),g=e=>Array.isArray(e)&&e.length>0&&e.every(e=>Number.isFinite(e)&&e>=10&&e<=100);function _(_){t(`wui-drawer`,h);let{marker:ee,props:te}=n(`AppDrawer`,_),{open:v=!1,onClose:y,title:b,titleIcon:x,header:S,subtitle:C,ariaLabel:w,side:T=`end`,size:E=`md`,width:D,maxWidth:O,snapPoints:k=m,defaultSnap:A=0,sheet:j=!0,onSnapChange:M,onOpened:N,onClosed:ne,dismissible:P=!0,closeLabel:F=`Close`,sheetHeightLabel:I=`Sheet height`,staticBackdrop:L=!0,confirmDiscard:R,dirty:z=!1,headerClassName:B=``,bodyClassName:V=``,footer:H,className:U=``,style:W,children:G,...K}=te;a(`AppDrawer`,K),i(`AppDrawer`,`side`,T,f),i(`AppDrawer`,`size`,E,p),i(`AppDrawer`,`snapPoints`,g(k)?void 0:JSON.stringify(k),[`an array of numbers from 10 to 100`]);let q=s(),J=b!=null&&b!==!1&&b!==``,Y=c(null),X=c({dirty:!1}),Z=c(null),[Q,$]=l(!1);X.current={onClose:y,onSnapChange:M,onOpened:N,onClosed:ne,confirmDiscard:R,dirty:z},o(()=>{v||$(!1)},[v]),o(()=>{Q&&Z.current?.focus()},[Q]),o(()=>{let e=Y.current;if(!e)return;let t=t=>{t.target===e&&(t.preventDefault(),X.current.confirmDiscard&&X.current.dirty?$(!0):X.current.onClose?.())},n=t=>{if(t.target===e){if(!(t instanceof CustomEvent))throw TypeError(`<wui-drawer> snap arrived without its index and percent.`);X.current.onSnapChange?.(t.detail.index,t.detail.percent)}},r=t=>{t.target===e&&X.current.onOpened?.()},i=t=>{t.target===e&&X.current.onClosed?.()};return e.addEventListener(`wui-drawer-close`,t),e.addEventListener(`wui-drawer-snap`,n),e.addEventListener(`wui-drawer-opened`,r),e.addEventListener(`wui-drawer-closed`,i),()=>{e.removeEventListener(`wui-drawer-close`,t),e.removeEventListener(`wui-drawer-snap`,n),e.removeEventListener(`wui-drawer-opened`,r),e.removeEventListener(`wui-drawer-closed`,i)}},[]);let re=()=>{$(!1),Y.current?.dispatchEvent(new CustomEvent(`wui:drawer:discard`,{bubbles:!0})),X.current.onClose?.()},ie=g(k)?k:m,ae={...D&&{"--wui-drawer-width":D},...O&&{"--wui-drawer-max-width":O},...W};return/* @__PURE__ */ u(`wui-drawer`,{ref:Y,...ee,...K,class:[`wui-drawer`,U].filter(Boolean).join(` `),side:T,size:E,"snap-points":ie.join(`,`),"default-snap":String(A),static:L?``:void 0,"no-sheet":j?void 0:``,"no-dismiss":P?void 0:``,"confirm-discard":R||void 0,open:v?``:void 0,style:ae,children:/* @__PURE__ */ d(`dialog`,{className:`wui-drawer-panel`,"aria-label":w||void 0,"aria-labelledby":!w&&J&&S===void 0?q:void 0,children:[j&&/* @__PURE__ */ u(`div`,{className:`wui-drawer-grip`,"data-wui-drawer-grip":``,children:/* @__PURE__ */ u(`div`,{className:`wui-drawer-handle`,role:`slider`,tabIndex:0,"aria-orientation":`vertical`,"aria-label":I})}),S===void 0?/* @__PURE__ */ d(`div`,{className:[`wui-drawer-header`,B].filter(Boolean).join(` `),"data-wui-drawer-grip":j?``:void 0,children:[/* @__PURE__ */ d(`div`,{className:`wui-drawer-headtext`,children:[J&&/* @__PURE__ */ d(`div`,{className:`wui-drawer-title`,id:q,children:[x&&/* @__PURE__ */ u(`span`,{className:`wui-drawer-title-ic`,children:/* @__PURE__ */ u(r,{name:x,size:18})}),b]}),C&&/* @__PURE__ */ u(`div`,{className:`wui-drawer-subtitle`,children:C})]}),P&&/* @__PURE__ */ u(`button`,{type:`button`,className:`wui-drawer-close`,"data-wui-dismiss":``,"aria-label":F,children:/* @__PURE__ */ u(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:/* @__PURE__ */ u(`path`,{d:`M18 6 6 18M6 6l12 12`})})})]}):S,/* @__PURE__ */ u(`div`,{className:[`wui-drawer-body`,V].filter(Boolean).join(` `),children:G}),(H||Q)&&/* @__PURE__ */ d(`div`,{className:Q?`wui-drawer-footer wui-drawer-discarding`:`wui-drawer-footer`,children:[Q&&/* @__PURE__ */ u(e,{text:R,confirmRef:Z,onDiscard:re,onKeep:()=>$(!1)}),H]})]})})}export{_ as default};
1
+ import e from"../lib/DiscardPrompt.js";import t from"../lib/useElementEntry.js";import n from"../lib/useWuiText.js";import{splitMarkerProps as r}from"../lib/wuiMarker.js";import i from"./AppIcon.js";import a from"./assertValidValue.js";import o from"./warnUnknownProps.js";import{useEffect as s,useId as c,useRef as l,useState as u}from"react";import{jsx as d,jsxs as f}from"react/jsx-runtime";import{DRAWER_TEXT as p}from"@webority/ui-elements/text";var ee=[`end`,`start`],te=[`sm`,`md`,`lg`,`xl`],m=[50,90],ne=()=>import(`@webority/ui-elements/elements/drawer`),h=e=>Array.isArray(e)&&e.length>0&&e.every(e=>Number.isFinite(e)&&e>=10&&e<=100);function g(g){t(`wui-drawer`,ne);let _=n(`drawer`,p),{marker:v,props:y}=r(`AppDrawer`,g),{open:b=!1,onClose:x,title:S,titleIcon:C,header:w,subtitle:T,ariaLabel:E,side:D=`end`,size:O=`md`,width:k,maxWidth:A,snapPoints:j=m,defaultSnap:re=0,sheet:M=!0,onSnapChange:ie,onOpened:ae,onClosed:N,dismissible:P=!0,closeLabel:F=_.closeLabel,sheetHeightLabel:I=_.sheetHeightLabel,staticBackdrop:L=!0,confirmDiscard:R,dirty:z=!1,headerClassName:B=``,bodyClassName:V=``,footer:H,className:U=``,style:W,children:G,...K}=y;o(`AppDrawer`,K),a(`AppDrawer`,`side`,D,ee),a(`AppDrawer`,`size`,O,te),a(`AppDrawer`,`snapPoints`,h(j)?void 0:JSON.stringify(j),[`an array of numbers from 10 to 100`]);let q=c(),J=S!=null&&S!==!1&&S!==``,Y=l(null),X=l({dirty:!1}),Z=l(null),[Q,$]=u(!1);X.current={onClose:x,onSnapChange:ie,onOpened:ae,onClosed:N,confirmDiscard:R,dirty:z},s(()=>{b||$(!1)},[b]),s(()=>{Q&&Z.current?.focus()},[Q]),s(()=>{let e=Y.current;if(!e)return;let t=t=>{t.target===e&&(t.preventDefault(),X.current.confirmDiscard&&X.current.dirty?$(!0):X.current.onClose?.())},n=t=>{if(t.target===e){if(!(t instanceof CustomEvent))throw TypeError(`<wui-drawer> snap arrived without its index and percent.`);X.current.onSnapChange?.(t.detail.index,t.detail.percent)}},r=t=>{t.target===e&&X.current.onOpened?.()},i=t=>{t.target===e&&X.current.onClosed?.()};return e.addEventListener(`wui-drawer-close`,t),e.addEventListener(`wui-drawer-snap`,n),e.addEventListener(`wui-drawer-opened`,r),e.addEventListener(`wui-drawer-closed`,i),()=>{e.removeEventListener(`wui-drawer-close`,t),e.removeEventListener(`wui-drawer-snap`,n),e.removeEventListener(`wui-drawer-opened`,r),e.removeEventListener(`wui-drawer-closed`,i)}},[]);let oe=()=>{$(!1),Y.current?.dispatchEvent(new CustomEvent(`wui:drawer:discard`,{bubbles:!0})),X.current.onClose?.()},se=h(j)?j:m,ce={...k&&{"--wui-drawer-width":k},...A&&{"--wui-drawer-max-width":A},...W};return/* @__PURE__ */ d(`wui-drawer`,{ref:Y,...v,...K,class:[`wui-drawer`,U].filter(Boolean).join(` `),side:D,size:O,"snap-points":se.join(`,`),"default-snap":String(re),static:L?``:void 0,"no-sheet":M?void 0:``,"no-dismiss":P?void 0:``,"confirm-discard":R||void 0,open:b?``:void 0,style:ce,children:/* @__PURE__ */ f(`dialog`,{className:`wui-drawer-panel`,"aria-label":E||void 0,"aria-labelledby":!E&&J&&w===void 0?q:void 0,children:[M&&/* @__PURE__ */ d(`div`,{className:`wui-drawer-grip`,"data-wui-drawer-grip":``,children:/* @__PURE__ */ d(`div`,{className:`wui-drawer-handle`,role:`slider`,tabIndex:0,"aria-orientation":`vertical`,"aria-label":I})}),w===void 0?/* @__PURE__ */ f(`div`,{className:[`wui-drawer-header`,B].filter(Boolean).join(` `),"data-wui-drawer-grip":M?``:void 0,children:[/* @__PURE__ */ f(`div`,{className:`wui-drawer-headtext`,children:[J&&/* @__PURE__ */ f(`div`,{className:`wui-drawer-title`,id:q,children:[C&&/* @__PURE__ */ d(`span`,{className:`wui-drawer-title-ic`,children:/* @__PURE__ */ d(i,{name:C,size:18})}),S]}),T&&/* @__PURE__ */ d(`div`,{className:`wui-drawer-subtitle`,children:T})]}),P&&/* @__PURE__ */ d(`button`,{type:`button`,className:`wui-drawer-close`,"data-wui-dismiss":``,"aria-label":F,children:/* @__PURE__ */ d(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:/* @__PURE__ */ d(`path`,{d:`M18 6 6 18M6 6l12 12`})})})]}):w,/* @__PURE__ */ d(`div`,{className:[`wui-drawer-body`,V].filter(Boolean).join(` `),children:G}),(H||Q)&&/* @__PURE__ */ f(`div`,{className:Q?`wui-drawer-footer wui-drawer-discarding`:`wui-drawer-footer`,children:[Q&&/* @__PURE__ */ d(e,{text:R,confirmRef:Z,onDiscard:oe,onKeep:()=>$(!1)}),H]})]})})}export{g as default};
@@ -1 +1 @@
1
- import e from"../lib/FieldMessage.js";import t from"../lib/fillLabel.js";import{useFieldError as n}from"../lib/formFields.js";import r from"../lib/useFileDrop.js";import{splitMarkerProps as i}from"../lib/wuiMarker.js";import a from"./AppIcon.js";import o from"./warnUnknownProps.js";import{DEFAULT_MAX_SIZE_MB as s,acceptDroppedFiles as c,acceptLabel as l}from"@webority/ui-elements/helpers";import{useId as u,useState as d}from"react";import{jsx as f,jsxs as p}from"react/jsx-runtime";function m(m){let{marker:h,props:g}=i(`AppDropZone`,m),{label:_,name:v,id:y,onChange:b,multiple:x=!1,accept:S=``,maxSizeMb:C=s,error:w,helperText:T,disabled:E=!1,className:D=``,fieldClassName:O=``,style:k,browseLabel:A=`Click to upload`,dropLabel:j=`or drag & drop`,anyTypeText:M=`Any file type`,maxSizeText:N=`up to {size} MB`,...P}=g;o(`AppDropZone`,P);let F=n(v),I=w??F,[L,R]=d(``),z=u(),B=y||z,V=I||L,H=V?`${B}-error`:void 0,U=T&&!V?`${B}-hint`:void 0,W=H||U,G=S?l(S):M,K={accept:S,maxSizeMb:C,multiple:x},q=e=>{R(``);let[t]=e;m.multiple?m.onChange(e):t&&m.onChange(t)},J=e=>R(e.message),{dragOver:Y,dropProps:X}=r({...K,disabled:E,onFiles:q,onReject:J}),Z=e=>{let{files:t,rejections:n}=c(e,K);if(!t.length&&!n.length)return;t.length&&q(t);let[r]=n;r&&J(r)};return/* @__PURE__ */ p(`div`,{...h,className:`field${O?` ${O}`:``}`,children:[_?/* @__PURE__ */ f(`label`,{className:`label`,htmlFor:B,children:_}):null,/* @__PURE__ */ p(`div`,{className:`file-input file-input-tall${Y?` dragging`:``}${V?` error`:``}${D?` ${D}`:``}`,style:k,"aria-disabled":E||void 0,...X,children:[/* @__PURE__ */ p(`label`,{htmlFor:B,className:`file-input-zone-label`,children:[/* @__PURE__ */ f(`span`,{className:`file-input-icon`,children:/* @__PURE__ */ f(a,{name:`upload`,size:24})}),/* @__PURE__ */ p(`span`,{className:`file-input-title`,children:[/* @__PURE__ */ f(`span`,{className:`browse`,children:A}),` ${j}`]}),/* @__PURE__ */ f(`span`,{className:`file-input-text`,children:C>0?`${G}, ${t(N,{size:C})}`:G})]}),/* @__PURE__ */ f(`input`,{id:B,type:`file`,"aria-describedby":W,name:v,accept:S,multiple:x||void 0,disabled:E||void 0,className:`visually-hidden`,onClick:e=>{e.currentTarget.value=``},onChange:e=>Z(e.target.files),...P})]}),/* @__PURE__ */ f(e,{error:V,hint:T,errorId:H,hintId:U})]})}export{m as default};
1
+ import e from"../lib/FieldMessage.js";import{useFieldError as t}from"../lib/formFields.js";import n from"../lib/useFileDrop.js";import r from"../lib/useWuiText.js";import{splitMarkerProps as i}from"../lib/wuiMarker.js";import a from"./AppIcon.js";import o from"./warnUnknownProps.js";import{DEFAULT_MAX_SIZE_MB as s,acceptDroppedFiles as c,acceptLabel as l}from"@webority/ui-elements/helpers";import{useId as u,useState as d}from"react";import{jsx as f,jsxs as p}from"react/jsx-runtime";import{DROP_ZONE_TEXT as m,fillText as h}from"@webority/ui-elements/text";function g(g){let{marker:_,props:v}=i(`AppDropZone`,g),y=r(`dropZone`,m),{label:b,name:x,id:S,onChange:ee,multiple:C=!1,accept:w=``,maxSizeMb:T=s,error:E,helperText:D,disabled:O=!1,className:k=``,fieldClassName:A=``,style:j,browseLabel:M=y.browseLabel,dropLabel:N=y.dropLabel,anyTypeText:P=y.anyTypeText,maxSizeText:F=y.maxSizeText,...I}=v;o(`AppDropZone`,I);let L=t(x),R=E??L,[z,B]=d(``),V=u(),H=S||V,U=R||z,W=U?`${H}-error`:void 0,G=D&&!U?`${H}-hint`:void 0,K=W||G,q=w?l(w):P,J={accept:w,maxSizeMb:T,multiple:C},Y=e=>{B(``);let[t]=e;g.multiple?g.onChange(e):t&&g.onChange(t)},X=e=>B(e.message),{dragOver:Z,dropProps:Q}=n({...J,disabled:O,onFiles:Y,onReject:X}),$=e=>{let{files:t,rejections:n}=c(e,J);if(!t.length&&!n.length)return;t.length&&Y(t);let[r]=n;r&&X(r)};return/* @__PURE__ */ p(`div`,{..._,className:`field${A?` ${A}`:``}`,children:[b?/* @__PURE__ */ f(`label`,{className:`label`,htmlFor:H,children:b}):null,/* @__PURE__ */ p(`div`,{className:`file-input file-input-tall${Z?` dragging`:``}${U?` error`:``}${k?` ${k}`:``}`,style:j,"aria-disabled":O||void 0,...Q,children:[/* @__PURE__ */ p(`label`,{htmlFor:H,className:`file-input-zone-label`,children:[/* @__PURE__ */ f(`span`,{className:`file-input-icon`,children:/* @__PURE__ */ f(a,{name:`upload`,size:24})}),/* @__PURE__ */ p(`span`,{className:`file-input-title`,children:[/* @__PURE__ */ f(`span`,{className:`browse`,children:M}),` ${N}`]}),/* @__PURE__ */ f(`span`,{className:`file-input-text`,children:T>0?`${q}, ${h(F,{size:T})}`:q})]}),/* @__PURE__ */ f(`input`,{id:H,type:`file`,"aria-describedby":K,name:x,accept:w,multiple:C||void 0,disabled:O||void 0,className:`visually-hidden`,onClick:e=>{e.currentTarget.value=``},onChange:e=>$(e.target.files),...I})]}),/* @__PURE__ */ f(e,{error:U,hint:D,errorId:W,hintId:G})]})}export{g as default};
@@ -1 +1 @@
1
- import{devWarn as e}from"../lib/devWarn.js";import{linkTarget as t}from"../lib/linkTarget.js";import{shortcutAria as n,shortcutChip as ee}from"../lib/shortcutChip.js";import{TargetLink as r}from"../lib/TargetLink.js";import i from"../lib/useElementEntry.js";import{TONES as a}from"../lib/vocabulary.js";import{splitMarkerProps as o}from"../lib/wuiMarker.js";import s from"./AppIcon.js";import c from"./assertValidValue.js";import l from"./renderIconProp.js";import te from"./warnUnknownProps.js";import ne from"./withTooltip.js";import{Fragment as re,useEffect as u,useId as d,useRef as f,useState as p}from"react";import{Fragment as m,jsx as h,jsxs as g}from"react/jsx-runtime";var _=[`sm`,`md`,`lg`,`xl`],v=[`neutral`],y=[`sm`,`md`,`lg`,`fit`],ie=()=>import(`@webority/ui-elements/elements/dropdown`),b=e=>e.description?/* @__PURE__ */ g(`span`,{className:`wui-dropdown-item-body`,children:[/* @__PURE__ */ h(`span`,{className:`wui-dropdown-item-label`,children:e.label}),/* @__PURE__ */ h(`span`,{className:`wui-dropdown-item-desc`,children:e.description})]}):e.label,x=!1;function S(){let t=!0;try{t=process.env.NODE_ENV!==`production`}catch{t=!0}t&&!x&&(x=!0,e("[@webority/ui-react] <AppDropdown> icon-only toggle has no accessible name — pass `label` or `ariaLabel`."))}function C(x){i(`wui-dropdown`,ie);let{marker:C,props:ae}=o(`AppDropdown`,x),{icon:oe,iconSize:se,toggleClassName:ce,toggleVariant:w,menuWidth:T,label:E,ariaLabel:D,align:O=`end`,items:k=[],menuClassName:A=``,linkComponent:j,children:M,trigger:N,open:P,onOpenChange:le,searchable:F,searchPlaceholder:I,noMatchText:L,...R}=ae;if(te(`AppDropdown`,R),F&&M!=null)throw Error(`<AppDropdown> searchable filters items, so it takes items and no children.`);if(!F&&(I!==void 0||L!==void 0))throw Error(`<AppDropdown> searchPlaceholder and noMatchText need searchable.`);for(let e of k)if(c(`AppDropdown`,`items[].hiddenFrom`,e.hiddenFrom,_),c(`AppDropdown`,`items[].tone`,e.tone,a),F&&e.label!=null&&typeof e.label!=`string`)throw RangeError(`<AppDropdown> searchable filters rows by their text, so every item label must be a string.`);N||D||E||S(),c(`AppDropdown`,`toggleVariant`,w,v),c(`AppDropdown`,`menuWidth`,T,y),w&&!N&&e(`AppDropdown: toggleVariant needs a trigger; the icon toggle ignores it.`);let z=(ce??(N?`wui-dropdown-trigger`:`topbar-icon-btn`))+(N&&w===`neutral`?` wui-dropdown-trigger-neutral`:``),B=[`dropdown-menu`,O===`end`?`dropdown-menu-end`:``,T&&y.includes(T)?`wui-dropdown-menu-${T}`:``,F?`wui-dropdown-menu-searchable`:``,A].filter(Boolean).join(` `),[V,H]=p(``),U=f(null),W=I??`Search`,G=L??`No matches.`,K=V.trim().toLowerCase(),q=K?k.filter(e=>!e.divider&&e.header==null&&(typeof e.label==`string`?e.label:``).toLowerCase().includes(K)):k,J=oe??(N?void 0:`more-horizontal`),Y=d(),X=P!==void 0,[ue,de]=p(!1),Z=X?!!P:ue,Q=f(null);Q.current=(e,t)=>{X||de(e),le?.(e,t)};let $=f(null);return u(()=>{let e=$.current;if(!e)return;let t=t=>{if(t.target===e){if(!(t instanceof CustomEvent))throw TypeError(`<wui-dropdown> toggle arrived without its detail.`);t.preventDefault(),Q.current?.(t.detail.open,{source:t.detail.source})}};return e.addEventListener(`wui-dropdown-toggle`,t),()=>e.removeEventListener(`wui-dropdown-toggle`,t)},[]),u(()=>{F&&Z&&U.current?.focus(),Z||H(``)},[Z,F]),u(()=>{let e=U.current;if(!F||!e)return;let t=t=>{if(t.key===`ArrowDown`||t.key===`ArrowUp`){t.preventDefault(),t.stopPropagation();let n=Array.from(e.closest(`.dropdown-menu`)?.querySelectorAll(`.dropdown-item`)??[]);(t.key===`ArrowDown`?n[0]:n[n.length-1])?.focus()}else t.key!==`Tab`&&t.key!==`Escape`&&t.stopPropagation()};return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)},[F]),/* @__PURE__ */ g(`wui-dropdown`,{...C,...R,ref:$,class:[`dropdown`,R.className].filter(Boolean).join(` `),align:O,open:Z?``:void 0,children:[/* @__PURE__ */ h(`button`,{type:`button`,id:Y,"data-wui-dropdown-trigger":!0,"aria-expanded":Z?`true`:`false`,className:z,title:E,"aria-label":D??(N?void 0:E),children:N??(J===void 0?null:/* @__PURE__ */ h(s,{name:J,size:se??20}))}),/* @__PURE__ */ g(`div`,{className:B,"aria-labelledby":Y,"data-wui-dropdown-menu":!0,popover:`auto`,children:[F?/* @__PURE__ */ g(`div`,{className:`wui-dropdown-search`,children:[/* @__PURE__ */ h(s,{name:`search`,size:14}),/* @__PURE__ */ h(`input`,{ref:U,type:`search`,className:`wui-dropdown-search-input`,autoComplete:`off`,placeholder:W,"aria-label":W,value:V,onChange:e=>H(e.target.value)})]}):null,M??q.map(e=>{if(e.to&&e.href)throw RangeError(`AppDropdown: an item takes to or href, not both.`);if(e.header!=null)return/* @__PURE__ */ h(`div`,{className:`dropdown-header`,children:e.header},e.key);if(e.divider)return/* @__PURE__ */ h(`hr`,{className:`dropdown-divider`},e.key);if(e.disabled)return/* @__PURE__ */ h(re,{children:ne(/* @__PURE__ */ g(`button`,{type:`button`,className:[`dropdown-item`,e.tone===`danger`&&`danger`,`wui-dropdown-item-disabled`,e.hiddenFrom&&_.includes(e.hiddenFrom)&&`wui-hidden-from-${e.hiddenFrom}`].filter(Boolean).join(` `),"aria-disabled":`true`,children:[e.image?/* @__PURE__ */ h(`img`,{src:e.image,alt:``}):l(e.icon,{size:16}),b(e),e.disabledReason&&/* @__PURE__ */ g(`span`,{className:`visually-hidden wui-dropdown-item-reason`,children:[`: `,e.disabledReason]})]}),e.disabledReason,`auto`)},e.key);let i=[`dropdown-item`,e.tone===`danger`&&`danger`,e.hiddenFrom&&_.includes(e.hiddenFrom)&&`wui-hidden-from-${e.hiddenFrom}`].filter(Boolean).join(` `)||void 0,a=/* @__PURE__ */ g(m,{children:[e.image?/* @__PURE__ */ h(`img`,{src:e.image,alt:``}):l(e.icon,{size:16}),b(e),ee(e.shortcut)]}),o={className:i,onClick:e.onClick,"aria-keyshortcuts":n(e.shortcut)};return e.to?/* @__PURE__ */ h(r,{link:t(j,{to:e.to}),...o,children:a},e.key):e.href?/* @__PURE__ */ h(r,{link:t(j,{href:e.href,external:!0}),...o,children:a},e.key):/* @__PURE__ */ h(`button`,{type:`button`,...o,children:a},e.key)}),F&&K&&q.length===0?/* @__PURE__ */ h(`div`,{className:`wui-dropdown-empty`,role:`status`,children:G}):null]})]})}export{C as default};
1
+ import{devWarn as e}from"../lib/devWarn.js";import{linkTarget as t}from"../lib/linkTarget.js";import{shortcutAria as n,shortcutChip as ee}from"../lib/shortcutChip.js";import{TargetLink as r}from"../lib/TargetLink.js";import i from"../lib/useElementEntry.js";import a from"../lib/useWuiText.js";import{TONES as o}from"../lib/vocabulary.js";import{splitMarkerProps as te}from"../lib/wuiMarker.js";import s from"./AppIcon.js";import c from"./assertValidValue.js";import l from"./renderIconProp.js";import ne from"./warnUnknownProps.js";import re from"./withTooltip.js";import{Fragment as ie,useEffect as u,useId as ae,useRef as d,useState as f}from"react";import{Fragment as oe,jsx as p,jsxs as m}from"react/jsx-runtime";import{DROPDOWN_TEXT as h}from"@webority/ui-elements/text";var g=[`sm`,`md`,`lg`,`xl`],se=[`neutral`],_=[`sm`,`md`,`lg`,`fit`],ce=[`_blank`,`_self`],le=/^data-[a-z0-9]+(?:-[a-z0-9]+)*$/,ue=()=>import(`@webority/ui-elements/elements/dropdown`),v=e=>e.description?/* @__PURE__ */ m(`span`,{className:`wui-dropdown-item-body`,children:[/* @__PURE__ */ p(`span`,{className:`wui-dropdown-item-label`,children:e.label}),/* @__PURE__ */ p(`span`,{className:`wui-dropdown-item-desc`,children:e.description})]}):e.label,y=!1;function de(){let t=!0;try{t=process.env.NODE_ENV!==`production`}catch{t=!0}t&&!y&&(y=!0,e("[@webority/ui-react] <AppDropdown> icon-only toggle has no accessible name — pass `label` or `ariaLabel`."))}function b(y){i(`wui-dropdown`,ue);let b=a(`dropdown`,h),{marker:x,props:S}=te(`AppDropdown`,y),{icon:C,iconSize:w,toggleClassName:T,toggleVariant:E,menuWidth:D,label:O,ariaLabel:k,align:A=`end`,items:j=[],menuClassName:M=``,linkComponent:N,children:P,trigger:F,open:I,onOpenChange:L,searchable:R,searchPlaceholder:z,noMatchText:B,...V}=S;if(ne(`AppDropdown`,V),R&&P!=null)throw Error(`<AppDropdown> searchable filters items, so it takes items and no children.`);if(!R&&(z!==void 0||B!==void 0))throw Error(`<AppDropdown> searchPlaceholder and noMatchText need searchable.`);for(let e of j){if(c(`AppDropdown`,`items[].hiddenFrom`,e.hiddenFrom,g),c(`AppDropdown`,`items[].tone`,e.tone,o),c(`AppDropdown`,`items[].target`,e.target,ce),(e.target||e.rel)&&!e.href&&!e.to)throw RangeError(`<AppDropdown> item "${e.key}" takes target and rel only with href or to.`);for(let t of Object.keys(e.data??{}))if(!le.test(t))throw RangeError(`<AppDropdown> item "${e.key}" has a data key "${t}" that is not data-<name> in lowercase.`);if(R&&e.label!=null&&typeof e.label!=`string`)throw RangeError(`<AppDropdown> searchable filters rows by their text, so every item label must be a string.`)}F||k||O||de(),c(`AppDropdown`,`toggleVariant`,E,se),c(`AppDropdown`,`menuWidth`,D,_),E&&!F&&e(`AppDropdown: toggleVariant needs a trigger; the icon toggle ignores it.`);let fe=(T??(F?`wui-dropdown-trigger`:`topbar-icon-btn`))+(F&&E===`neutral`?` wui-dropdown-trigger-neutral`:``),pe=[`dropdown-menu`,A===`end`?`dropdown-menu-end`:``,D&&_.includes(D)?`wui-dropdown-menu-${D}`:``,R?`wui-dropdown-menu-searchable`:``,M].filter(Boolean).join(` `),[H,U]=f(``),W=d(null),G=z??b.searchPlaceholder,me=B??b.noMatchText,K=H.trim().toLowerCase(),q=K?j.filter(e=>!e.divider&&e.header==null&&(typeof e.label==`string`?e.label:``).toLowerCase().includes(K)):j,J=C??(F?void 0:`more-horizontal`),Y=ae(),X=I!==void 0,[he,ge]=f(!1),Z=X?!!I:he,Q=d(null);Q.current=(e,t)=>{X||ge(e),L?.(e,t)};let $=d(null);return u(()=>{let e=$.current;if(!e)return;let t=t=>{if(t.target===e){if(!(t instanceof CustomEvent))throw TypeError(`<wui-dropdown> toggle arrived without its detail.`);t.preventDefault(),Q.current?.(t.detail.open,{source:t.detail.source})}};return e.addEventListener(`wui-dropdown-toggle`,t),()=>e.removeEventListener(`wui-dropdown-toggle`,t)},[]),u(()=>{R&&Z&&W.current?.focus(),Z||U(``)},[Z,R]),u(()=>{let e=W.current;if(!R||!e)return;let t=t=>{if(t.key===`ArrowDown`||t.key===`ArrowUp`){t.preventDefault(),t.stopPropagation();let n=Array.from(e.closest(`.dropdown-menu`)?.querySelectorAll(`.dropdown-item`)??[]);(t.key===`ArrowDown`?n[0]:n[n.length-1])?.focus()}else t.key!==`Tab`&&t.key!==`Escape`&&t.stopPropagation()};return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)},[R]),/* @__PURE__ */ m(`wui-dropdown`,{...x,...V,ref:$,class:[`dropdown`,V.className].filter(Boolean).join(` `),align:A,open:Z?``:void 0,children:[/* @__PURE__ */ p(`button`,{type:`button`,id:Y,"data-wui-dropdown-trigger":!0,"aria-expanded":Z?`true`:`false`,className:fe,title:O,"aria-label":k??(F?void 0:O),children:F??(J===void 0?null:/* @__PURE__ */ p(s,{name:J,size:w??20}))}),/* @__PURE__ */ m(`div`,{className:pe,"aria-labelledby":Y,"data-wui-dropdown-menu":!0,popover:`auto`,children:[R?/* @__PURE__ */ m(`div`,{className:`wui-dropdown-search`,children:[/* @__PURE__ */ p(s,{name:`search`,size:14}),/* @__PURE__ */ p(`input`,{ref:W,type:`search`,className:`wui-dropdown-search-input`,autoComplete:`off`,placeholder:G,"aria-label":G,value:H,onChange:e=>U(e.target.value)})]}):null,P??q.map(e=>{if(e.to&&e.href)throw RangeError(`AppDropdown: an item takes to or href, not both.`);if(e.header!=null)return/* @__PURE__ */ p(`div`,{className:`dropdown-header`,children:e.header},e.key);if(e.divider)return/* @__PURE__ */ p(`hr`,{className:`dropdown-divider`},e.key);if(e.disabled)return/* @__PURE__ */ p(ie,{children:re(/* @__PURE__ */ m(`button`,{type:`button`,className:[`dropdown-item`,e.tone===`danger`&&`danger`,`wui-dropdown-item-disabled`,e.hiddenFrom&&g.includes(e.hiddenFrom)&&`wui-hidden-from-${e.hiddenFrom}`].filter(Boolean).join(` `),"aria-disabled":`true`,...e.data,children:[e.image?/* @__PURE__ */ p(`img`,{src:e.image,alt:``}):l(e.icon,{size:16}),v(e),e.disabledReason&&/* @__PURE__ */ m(`span`,{className:`visually-hidden wui-dropdown-item-reason`,children:[`: `,e.disabledReason]})]}),e.disabledReason,`auto`)},e.key);let i=[`dropdown-item`,e.tone===`danger`&&`danger`,e.hiddenFrom&&g.includes(e.hiddenFrom)&&`wui-hidden-from-${e.hiddenFrom}`].filter(Boolean).join(` `)||void 0,a=/* @__PURE__ */ m(oe,{children:[e.image?/* @__PURE__ */ p(`img`,{src:e.image,alt:``}):l(e.icon,{size:16}),v(e),ee(e.shortcut)]}),o={className:i,onClick:e.onClick,"aria-keyshortcuts":n(e.shortcut),...e.data};return e.to?/* @__PURE__ */ p(r,{link:t(N,{to:e.to}),target:e.target,rel:e.rel,...o,children:a},e.key):e.href?/* @__PURE__ */ p(r,{link:t(N,{href:e.href,external:!0}),target:e.target,rel:e.rel,...o,children:a},e.key):/* @__PURE__ */ p(`button`,{type:`button`,...o,children:a},e.key)}),R&&K&&q.length===0?/* @__PURE__ */ p(`div`,{className:`wui-dropdown-empty`,role:`status`,children:me}):null]})]})}export{b as default};
@@ -1 +1 @@
1
- import e from"../lib/fillLabel.js";import{splitMarkerProps as t}from"../lib/wuiMarker.js";import n from"./AppIcon.js";import r from"./assertValidValue.js";import i from"./warnUnknownProps.js";import{formatDate as a,toInstant as o}from"@webority/ui-elements/helpers";import{jsx as s,jsxs as c}from"react/jsx-runtime";var l=864e5,u=198e5,d=14,f=[`days`,`due`],p=e=>Math.floor((e+u)/l),m=(...e)=>e.filter(Boolean).join(` `),h=(t,n,r)=>n===0?r.dueTodayLabel:t===`due`?n===1?r.dueTomorrowLabel:e(r.dueInLabel,{days:n}):n===1?r.oneDayLeftLabel:e(r.daysLeftLabel,{days:n});function g(u){let{marker:g,props:_}=t(`AppDueDate`,u),{date:v,soonDays:y,soonWording:b=`days`,icon:x=!1,overdue:S=!1,overdueLabel:C,notSetLabel:w=`Not set`,dueTodayLabel:T=`Due today`,dueTomorrowLabel:E=`Due tomorrow`,dueInLabel:D=`Due in {days} days`,daysLeftLabel:O=`{days} days left`,oneDayLeftLabel:k=`1 day left`,overdueSinceLabel:A=`Overdue since {date}`,className:j=``,...M}=_;i(`AppDueDate`,M),r(`AppDueDate`,`soonWording`,b,f);let N=o(v);if(!Number.isFinite(N))return/* @__PURE__ */ s(`wui-due-date`,{class:m(`wui-due-date`,`wui-due-date-empty`,j),...g,...M,children:/* @__PURE__ */ s(`time`,{children:w})});let P=p(N),F=(/* @__PURE__ */ new Date(P*l)).toISOString().slice(0,10),I=P-p(Date.now()),L=x?/* @__PURE__ */ s(n,{name:`calendar`,size:d}):null;if(S){let t=a(N);return/* @__PURE__ */ c(`wui-due-date`,{class:m(`wui-due-date`,`wui-due-date-danger`,j),title:e(A,{date:t}),...g,...M,children:[/* @__PURE__ */ s(n,{name:`danger`,size:d}),L,/* @__PURE__ */ s(`time`,{dateTime:F,children:C||t})]})}return y!==void 0&&Number.isFinite(y)&&I>=0&&I<=y?/* @__PURE__ */ c(`wui-due-date`,{class:m(`wui-due-date`,`wui-due-date-warning`,j),...g,...M,children:[L,/* @__PURE__ */ s(`time`,{dateTime:F,children:h(b,I,{dueTodayLabel:T,dueTomorrowLabel:E,dueInLabel:D,daysLeftLabel:O,oneDayLeftLabel:k})})]}):/* @__PURE__ */ c(`wui-due-date`,{class:m(`wui-due-date`,j),...g,...M,children:[L,/* @__PURE__ */ s(`time`,{dateTime:F,children:a(N)})]})}export{g as default};
1
+ import e from"../lib/useWuiText.js";import{splitMarkerProps as t}from"../lib/wuiMarker.js";import n from"./AppIcon.js";import r from"./assertValidValue.js";import i from"./warnUnknownProps.js";import{formatDate as a,toInstant as o}from"@webority/ui-elements/helpers";import{jsx as s,jsxs as c}from"react/jsx-runtime";import{DUE_DATE_TEXT as l,fillText as u}from"@webority/ui-elements/text";var d=864e5,f=198e5,p=14,m=[`days`,`due`],h=e=>Math.floor((e+f)/d),g=(...e)=>e.filter(Boolean).join(` `),_=(e,t,n)=>t===0?n.dueTodayLabel:e===`due`?t===1?n.dueTomorrowLabel:u(n.dueInLabel,{days:t}):t===1?n.oneDayLeftLabel:u(n.daysLeftLabel,{days:t});function v(f){let{marker:v,props:y}=t(`AppDueDate`,f),b=e(`dueDate`,l),{date:x,soonDays:S,soonWording:C=`days`,icon:w=!1,overdue:T=!1,overdueLabel:E,notSetLabel:D=b.notSetLabel,dueTodayLabel:O=b.dueTodayLabel,dueTomorrowLabel:k=b.dueTomorrowLabel,dueInLabel:A=b.dueInLabel,daysLeftLabel:j=b.daysLeftLabel,oneDayLeftLabel:M=b.oneDayLeftLabel,overdueSinceLabel:N=b.overdueSinceLabel,className:P=``,...F}=y;i(`AppDueDate`,F),r(`AppDueDate`,`soonWording`,C,m);let I=o(x);if(!Number.isFinite(I))return/* @__PURE__ */ s(`wui-due-date`,{class:g(`wui-due-date`,`wui-due-date-empty`,P),...v,...F,children:/* @__PURE__ */ s(`time`,{children:D})});let L=h(I),R=(/* @__PURE__ */ new Date(L*d)).toISOString().slice(0,10),z=L-h(Date.now()),B=w?/* @__PURE__ */ s(n,{name:`calendar`,size:p}):null;if(T){let e=a(I);return/* @__PURE__ */ c(`wui-due-date`,{class:g(`wui-due-date`,`wui-due-date-danger`,P),title:u(N,{date:e}),...v,...F,children:[/* @__PURE__ */ s(n,{name:`danger`,size:p}),B,/* @__PURE__ */ s(`time`,{dateTime:R,children:E||e})]})}return S!==void 0&&Number.isFinite(S)&&z>=0&&z<=S?/* @__PURE__ */ c(`wui-due-date`,{class:g(`wui-due-date`,`wui-due-date-warning`,P),...v,...F,children:[B,/* @__PURE__ */ s(`time`,{dateTime:R,children:_(C,z,{dueTodayLabel:O,dueTomorrowLabel:k,dueInLabel:A,daysLeftLabel:j,oneDayLeftLabel:M})})]}):/* @__PURE__ */ c(`wui-due-date`,{class:g(`wui-due-date`,P),...v,...F,children:[B,/* @__PURE__ */ s(`time`,{dateTime:R,children:a(I)})]})}export{v as default};
@@ -1 +1 @@
1
- import e from"../lib/useElementEntry.js";import{splitMarkerProps as t}from"../lib/wuiMarker.js";import n from"./AppIcon.js";import r from"./AppInfoTip.js";import i from"./AppKbd.js";import a from"./AppSpinner.js";import o from"./assertValidValue.js";import s from"./warnUnknownProps.js";import{Fragment as c,useEffect as l,useRef as u}from"react";import{Fragment as d,jsx as f,jsxs as p}from"react/jsx-runtime";var m=[`text`,`number`],h=[`clean`,`dirty`,`saving`,`saved`,`failed`],g=()=>import(`@webority/ui-elements/elements/entry-grid`);function _(_){e(`wui-entry-grid`,g);let{marker:v,props:y}=t(`AppEntryGrid`,_),{columns:b,rows:x,rowKey:S,activeRowKey:C,onActiveRowChange:w,renderCell:T,rowState:E,rowError:D,onCommitRow:O,onDiscardRow:k,onAddRow:A,renderRowDetail:j,hint:M=!0,label:N=`Entry lines`,addLabel:P=`Add line`,emptyLabel:F=`No lines yet`,statusLabel:I=`Status`,dirtyLabel:L=`Changed`,savingLabel:R=`Saving`,savedLabel:z=`Saved`,failedLabel:B=`Not saved`,commitNextLabel:V=`Save and go to the next line`,commitStayLabel:H=`Save`,discardLabel:U=`Discard changes`,moveLabel:W=`Move between lines`,className:G=``,...K}=y;s(`AppEntryGrid`,K);for(let e of b)o(`AppEntryGrid`,`columns[].kind`,e.kind,m);let q=x.map(e=>{let t=E?E(e):`clean`;return o(`AppEntryGrid`,`rowState()`,t,h),t}),J=u(null),Y=u({rows:x,rowKey:S,onCommitRow:O,onDiscardRow:k,onActiveRowChange:w,onAddRow:A});Y.current={rows:x,rowKey:S,onCommitRow:O,onDiscardRow:k,onActiveRowChange:w,onAddRow:A},l(()=>{let e=J.current;if(!e)return;let t=e=>{let t=e instanceof CustomEvent?e.detail?.rowKey:void 0,{rows:n,rowKey:r}=Y.current;return typeof t==`string`?n.find(e=>r(e)===t):void 0},n=e=>{let n=t(e),r=e instanceof CustomEvent?e.detail?.move:void 0;n!==void 0&&(r===`next`||r===`stay`)&&Y.current.onCommitRow?.(n,r)},r=e=>{let n=t(e);n!==void 0&&Y.current.onDiscardRow?.(n)},i=e=>{let n=t(e);n!==void 0&&Y.current.onActiveRowChange?.(Y.current.rowKey(n))},a=()=>Y.current.onAddRow?.();return e.addEventListener(`wui-entry-grid:commit`,n),e.addEventListener(`wui-entry-grid:discard`,r),e.addEventListener(`wui-entry-grid:active`,i),e.addEventListener(`wui-entry-grid:add`,a),()=>{e.removeEventListener(`wui-entry-grid:commit`,n),e.removeEventListener(`wui-entry-grid:discard`,r),e.removeEventListener(`wui-entry-grid:active`,i),e.removeEventListener(`wui-entry-grid:add`,a)}},[]);let X=e=>e===`dirty`?/* @__PURE__ */ f(`span`,{className:`wui-entry-grid-dot`,role:`img`,"aria-label":L}):e===`saving`?/* @__PURE__ */ f(a,{size:`sm`,label:R}):e===`saved`?/* @__PURE__ */ p(d,{children:[/* @__PURE__ */ f(n,{name:`tick-circle`,size:16}),/* @__PURE__ */ f(`span`,{className:`visually-hidden`,children:z})]}):e===`failed`?/* @__PURE__ */ p(d,{children:[/* @__PURE__ */ f(n,{name:`danger`,size:16}),/* @__PURE__ */ f(`span`,{className:`visually-hidden`,children:B})]}):null,Z=b.some(e=>e.footer),Q=b.length+1,$=e=>e.kind===`number`?`text-end`:void 0;return/* @__PURE__ */ p(`wui-entry-grid`,{ref:J,class:[`wui-entry-grid`,G].filter(Boolean).join(` `),"active-row":C??``,...v,...K,children:[/* @__PURE__ */ f(`div`,{className:`table-responsive wui-entry-grid-scroll`,children:/* @__PURE__ */ p(`table`,{className:`table wui-entry-grid-table`,"aria-label":N,children:[/* @__PURE__ */ f(`thead`,{children:/* @__PURE__ */ p(`tr`,{children:[/* @__PURE__ */ f(`th`,{scope:`col`,className:`wui-entry-grid-status`,children:/* @__PURE__ */ f(`span`,{className:`visually-hidden`,children:I})}),b.map(e=>/* @__PURE__ */ p(`th`,{scope:`col`,className:$(e),style:e.width===void 0?void 0:{width:e.width},children:[e.label,e.help?/* @__PURE__ */ f(r,{label:typeof e.label==`string`?e.label:void 0,children:e.help}):null]},e.key))]})}),/* @__PURE__ */ p(`tbody`,{children:[x.map((e,t)=>{let n=S(e),r=q[t]??`clean`,i=n===C,a=r===`failed`&&D!==void 0,o=i&&j!==void 0,s=[`wui-entry-grid-row`,i&&`is-active`,r!==`clean`&&`wui-entry-grid-row-${r}`].filter(Boolean).join(` `);return/* @__PURE__ */ p(c,{children:[/* @__PURE__ */ p(`tr`,{className:s,"data-row-key":n,"aria-current":i?`true`:void 0,children:[/* @__PURE__ */ f(`td`,{className:`wui-entry-grid-status`,children:X(r)}),b.map(t=>/* @__PURE__ */ f(`td`,{className:$(t),"data-kind":t.kind??`text`,children:T(e,t,i)},t.key))]}),a||o?/* @__PURE__ */ f(`tr`,{className:`wui-entry-grid-detail`,children:/* @__PURE__ */ p(`td`,{colSpan:Q,children:[a?/* @__PURE__ */ f(`div`,{className:`wui-entry-grid-error`,role:`alert`,children:D(e)}):null,o?j(e):null]})}):null]},n)}),x.length===0?/* @__PURE__ */ f(`tr`,{className:`wui-entry-grid-empty`,children:/* @__PURE__ */ f(`td`,{colSpan:Q,children:F})}):null]}),Z?/* @__PURE__ */ f(`tfoot`,{className:`wui-entry-grid-footer`,children:/* @__PURE__ */ p(`tr`,{children:[/* @__PURE__ */ f(`td`,{}),b.map(e=>/* @__PURE__ */ f(`td`,{className:$(e),children:e.footer?.(x)},e.key))]})}):null]})}),/* @__PURE__ */ p(`div`,{className:`wui-entry-grid-bar`,children:[A?/* @__PURE__ */ f(`button`,{type:`button`,className:`btn btn-sm btn-outline-primary wui-entry-grid-add`,children:P}):null,M?/* @__PURE__ */ p(`ul`,{className:`wui-entry-grid-hint`,children:[/* @__PURE__ */ p(`li`,{children:[/* @__PURE__ */ f(i,{children:`Enter`}),` ${V}`]}),/* @__PURE__ */ p(`li`,{children:[/* @__PURE__ */ f(i,{children:`Ctrl`}),`+`,/* @__PURE__ */ f(i,{children:`S`}),` ${H}`]}),/* @__PURE__ */ p(`li`,{children:[/* @__PURE__ */ f(i,{children:`Esc`}),` ${U}`]}),/* @__PURE__ */ p(`li`,{children:[/* @__PURE__ */ f(i,{children:`Ctrl`}),`+`,/* @__PURE__ */ f(i,{children:`↑`}),`/`,/* @__PURE__ */ f(i,{children:`↓`}),` ${W}`]})]}):null]})]})}export{_ as default};
1
+ import e from"../lib/useElementEntry.js";import t from"../lib/useWuiText.js";import{splitMarkerProps as n}from"../lib/wuiMarker.js";import r from"./AppIcon.js";import i from"./AppInfoTip.js";import a from"./AppKbd.js";import o from"./AppSkeleton.js";import s from"./AppSpinner.js";import c from"./AppTablePagination.js";import l from"./assertValidValue.js";import ee from"./warnUnknownProps.js";import{Fragment as u,useEffect as te,useRef as d}from"react";import{Fragment as f,jsx as p,jsxs as m}from"react/jsx-runtime";import{ENTRY_GRID_TEXT as h,KBD_TEXT as g}from"@webority/ui-elements/text";var _=[`text`,`number`],ne=[`start`],re=3,ie=[`clean`,`dirty`,`saving`,`saved`,`failed`],ae=e=>Array.isArray(e)&&e.every(e=>Array.isArray(e)&&e.every(e=>typeof e==`string`)),oe=()=>import(`@webority/ui-elements/elements/entry-grid`);function v(v){e(`wui-entry-grid`,oe);let y=t(`entryGrid`,h),b=t(`kbd`,g),{marker:se,props:x}=n(`AppEntryGrid`,v),{columns:S,rows:C,rowKey:w,activeRowKey:T,onActiveRowChange:E,renderCell:ce,rowState:D,rowError:O,onCommitRow:k,onDiscardRow:A,onAddRow:j,sort:M,onSort:N,onPasteRows:P,onRemoveRow:F,loading:I=!1,skeletonRows:L=re,emptyContent:R,rowProps:z,pagination:B,renderRowDetail:V,hint:H=!0,label:U=y.label,addLabel:W=y.addLabel,emptyLabel:G=y.emptyLabel,statusLabel:K=y.statusLabel,dirtyLabel:le=y.dirtyLabel,savingLabel:ue=y.savingLabel,savedLabel:de=y.savedLabel,failedLabel:fe=y.failedLabel,commitNextLabel:pe=y.commitNextLabel,commitStayLabel:me=y.commitStayLabel,discardLabel:he=y.discardLabel,moveLabel:ge=y.moveLabel,removeLineLabel:_e=y.removeLineLabel,className:ve=``,...q}=x;if(ee(`AppEntryGrid`,q),S.forEach((e,t)=>{if(l(`AppEntryGrid`,`columns[].kind`,e.kind,_),l(`AppEntryGrid`,`columns[].pin`,e.pin,ne),e.pin!==void 0&&t!==0)throw Error(`AppEntryGrid: only the first column can be pinned, but "${e.key}" has pin.`);if(e.sortable&&N===void 0)throw Error(`AppEntryGrid: column "${e.key}" is sortable, so the grid needs onSort.`)}),!Number.isInteger(L)||L<1)throw Error(`AppEntryGrid: skeletonRows must be a whole number of 1 or more, not ${L}.`);if(R!==void 0&&x.emptyLabel!==void 0)throw Error(`AppEntryGrid: give emptyLabel or emptyContent, not both.`);let ye=C.map(e=>{let t=D?D(e):`clean`;return l(`AppEntryGrid`,`rowState()`,t,ie),t}),J=d(null),Y=d({rows:C,rowKey:w,onCommitRow:k,onDiscardRow:A,onActiveRowChange:E,onAddRow:j,onSort:N,onPasteRows:P,onRemoveRow:F});Y.current={rows:C,rowKey:w,onCommitRow:k,onDiscardRow:A,onActiveRowChange:E,onAddRow:j,onSort:N,onPasteRows:P,onRemoveRow:F},te(()=>{let e=J.current;if(!e)return;let t=e=>{let t=e instanceof CustomEvent?e.detail?.rowKey:void 0,{rows:n,rowKey:r}=Y.current;return typeof t==`string`?n.find(e=>r(e)===t):void 0},n=e=>{let n=t(e),r=e instanceof CustomEvent?e.detail?.move:void 0;n!==void 0&&(r===`next`||r===`stay`)&&Y.current.onCommitRow?.(n,r)},r=e=>{let n=t(e);n!==void 0&&Y.current.onDiscardRow?.(n)},i=e=>{let n=t(e);n!==void 0&&Y.current.onActiveRowChange?.(Y.current.rowKey(n))},a=()=>Y.current.onAddRow?.(),o=e=>{let t=e instanceof CustomEvent?e.detail?.columnKey:void 0;typeof t==`string`&&Y.current.onSort?.(t)},s=e=>{let n=e instanceof CustomEvent?e.detail:void 0,r=t(e);r!==void 0&&typeof n?.columnKey==`string`&&ae(n.rows)&&Y.current.onPasteRows?.({rowKey:Y.current.rowKey(r),columnKey:n.columnKey,rows:n.rows})},c=e=>{let n=t(e);n!==void 0&&Y.current.onRemoveRow?.(Y.current.rowKey(n))};return e.addEventListener(`wui-entry-grid:commit`,n),e.addEventListener(`wui-entry-grid:discard`,r),e.addEventListener(`wui-entry-grid:active`,i),e.addEventListener(`wui-entry-grid:add`,a),e.addEventListener(`wui-entry-grid:sort`,o),e.addEventListener(`wui-entry-grid:paste`,s),e.addEventListener(`wui-entry-grid:remove`,c),()=>{e.removeEventListener(`wui-entry-grid:commit`,n),e.removeEventListener(`wui-entry-grid:discard`,r),e.removeEventListener(`wui-entry-grid:active`,i),e.removeEventListener(`wui-entry-grid:add`,a),e.removeEventListener(`wui-entry-grid:sort`,o),e.removeEventListener(`wui-entry-grid:paste`,s),e.removeEventListener(`wui-entry-grid:remove`,c)}},[]);let be=e=>e===`dirty`?/* @__PURE__ */ p(`span`,{className:`wui-entry-grid-dot`,role:`img`,"aria-label":le}):e===`saving`?/* @__PURE__ */ p(s,{size:`sm`,label:ue}):e===`saved`?/* @__PURE__ */ m(f,{children:[/* @__PURE__ */ p(r,{name:`tick-circle`,size:16}),/* @__PURE__ */ p(`span`,{className:`visually-hidden`,children:de})]}):e===`failed`?/* @__PURE__ */ m(f,{children:[/* @__PURE__ */ p(r,{name:`danger`,size:16}),/* @__PURE__ */ p(`span`,{className:`visually-hidden`,children:fe})]}):null,xe=S.some(e=>e.footer),X=S.length+1,Z=e=>e.kind===`number`?`text-end`:void 0,Se=e=>[e.sortable&&`sortable`,e.kind===`number`&&`text-end`].filter(Boolean).join(` `)||void 0,Q=S.some(e=>e.group!==void 0),$=[];for(let e of S){let t=$[$.length-1];e.group!==void 0&&t?.group===e.group?t.span+=1:$.push({key:e.key,group:e.group,span:1})}let Ce=e=>{if(e.sortable)return M?.key===e.key?M.dir===`asc`?`ascending`:`descending`:`none`},we=e=>{let t=z?.(e)??{};for(let e of Object.keys(t))if(!e.startsWith(`data-`)||e===`data-row-key`)throw Error(`AppEntryGrid: rowProps can only return data-* attributes other than data-row-key, not "${e}".`);return t};return/* @__PURE__ */ m(`wui-entry-grid`,{ref:J,class:[`wui-entry-grid`,ve].filter(Boolean).join(` `),"active-row":T??``,removable:F?``:void 0,...se,...q,children:[/* @__PURE__ */ p(`div`,{className:`table-responsive wui-entry-grid-scroll`,children:/* @__PURE__ */ m(`table`,{className:`table wui-entry-grid-table`,"aria-label":U,children:[/* @__PURE__ */ m(`thead`,{children:[Q?/* @__PURE__ */ m(`tr`,{children:[/* @__PURE__ */ p(`th`,{scope:`col`,className:`wui-entry-grid-status`,rowSpan:2,children:/* @__PURE__ */ p(`span`,{className:`visually-hidden`,children:K})}),$.map(e=>/* @__PURE__ */ p(`th`,{className:`wui-entry-grid-group`,scope:e.span>1?`colgroup`:`col`,colSpan:e.span>1?e.span:void 0,"data-pin":e.span===1?S.find(t=>t.key===e.key)?.pin:void 0,children:e.group},e.key))]}):null,/* @__PURE__ */ m(`tr`,{children:[Q?null:/* @__PURE__ */ p(`th`,{scope:`col`,className:`wui-entry-grid-status`,children:/* @__PURE__ */ p(`span`,{className:`visually-hidden`,children:K})}),S.map(e=>{let t=e.sortable?/* @__PURE__ */ p(`span`,{className:`sort-icon${e.kind===`number`?` wui-sort-lead`:``}`,children:/* @__PURE__ */ p(r,{name:`chevrons-up-down`,size:14})}):null;return/* @__PURE__ */ m(`th`,{scope:`col`,className:Se(e),style:e.width===void 0?void 0:{width:e.width},"data-column-key":e.key,"data-pin":e.pin,"data-sortable":e.sortable?`true`:void 0,tabIndex:e.sortable?0:void 0,"aria-sort":Ce(e),children:[e.kind===`number`?t:null,e.label,e.kind===`number`?null:t,e.help?/* @__PURE__ */ p(i,{label:typeof e.label==`string`?e.label:void 0,children:e.help}):null]},e.key)})]})]}),/* @__PURE__ */ m(`tbody`,{children:[I?Array.from({length:L},(e,t)=>`skeleton-${t}`).map(e=>/* @__PURE__ */ m(`tr`,{children:[/* @__PURE__ */ p(`td`,{className:`wui-entry-grid-status`}),S.map(e=>/* @__PURE__ */ p(`td`,{className:Z(e),"data-column-key":e.key,"data-pin":e.pin,children:/* @__PURE__ */ p(o,{width:e.kind===`number`?`56%`:`60%`,height:12,radius:6})},e.key))]},e)):C.map((e,t)=>{let n=w(e),r=ye[t]??`clean`,i=n===T,a=r===`failed`&&O!==void 0,o=i&&V!==void 0,s=[`wui-entry-grid-row`,i&&`is-active`,r!==`clean`&&`wui-entry-grid-row-${r}`].filter(Boolean).join(` `);return/* @__PURE__ */ m(u,{children:[/* @__PURE__ */ m(`tr`,{...we(e),className:s,"data-row-key":n,"aria-current":i?`true`:void 0,children:[/* @__PURE__ */ p(`td`,{className:`wui-entry-grid-status`,children:be(r)}),S.map(t=>/* @__PURE__ */ p(`td`,{className:Z(t),"data-kind":t.kind??`text`,"data-column-key":t.key,"data-pin":t.pin,children:ce(e,t,i)},t.key))]}),a||o?/* @__PURE__ */ p(`tr`,{className:`wui-entry-grid-detail`,children:/* @__PURE__ */ m(`td`,{colSpan:X,children:[a?/* @__PURE__ */ p(`div`,{className:`wui-entry-grid-error`,role:`alert`,children:O(e)}):null,o?V(e):null]})}):null]},n)}),!I&&C.length===0?/* @__PURE__ */ p(`tr`,{className:`wui-entry-grid-empty`,children:/* @__PURE__ */ p(`td`,{colSpan:X,children:R===void 0?G:R})}):null]}),xe?/* @__PURE__ */ p(`tfoot`,{className:`wui-entry-grid-footer`,children:/* @__PURE__ */ m(`tr`,{children:[/* @__PURE__ */ p(`td`,{}),S.map(e=>/* @__PURE__ */ p(`td`,{className:Z(e),children:e.footer?.(C)},e.key))]})}):null]})}),B?/* @__PURE__ */ p(c,{page:B.page,totalPages:B.totalPages,total:B.total,pageSize:B.pageSize,onPageChange:I?void 0:B.setPage,onPageSizeChange:I?void 0:B.setPageSize,pageSizes:B.pageSizes,mode:B.mode,summary:B.summary}):null,/* @__PURE__ */ m(`div`,{className:`wui-entry-grid-bar`,children:[j?/* @__PURE__ */ p(`button`,{type:`button`,className:`btn btn-sm btn-outline-primary wui-entry-grid-add`,children:W}):null,H?/* @__PURE__ */ m(`ul`,{className:`wui-entry-grid-hint`,children:[k?/* @__PURE__ */ m(f,{children:[/* @__PURE__ */ m(`li`,{children:[/* @__PURE__ */ p(a,{children:b.enterLabel}),` ${pe}`]}),/* @__PURE__ */ m(`li`,{children:[/* @__PURE__ */ p(a,{children:b.ctrlLabel}),`+`,/* @__PURE__ */ p(a,{children:`S`}),` ${me}`]})]}):null,/* @__PURE__ */ m(`li`,{children:[/* @__PURE__ */ p(a,{children:b.escLabel}),` ${he}`]}),/* @__PURE__ */ m(`li`,{children:[/* @__PURE__ */ p(a,{children:b.ctrlLabel}),`+`,/* @__PURE__ */ p(a,{children:`↑`}),`/`,/* @__PURE__ */ p(a,{children:`↓`}),` ${ge}`]}),F?/* @__PURE__ */ m(`li`,{children:[/* @__PURE__ */ p(a,{children:b.ctrlLabel}),`+`,/* @__PURE__ */ p(a,{children:`Delete`}),` ${_e}`]}):null]}):null]})]})}export{v as default};
@@ -1 +1 @@
1
- import e from"./AppButton.js";import t from"./AppRouteError.js";import n from"./warnUnknownProps.js";import{Component as r}from"react";import{jsx as i}from"react/jsx-runtime";var a=()=>window.location.reload(),o=(e=[],t=[])=>e.length===t.length&&e.every((e,n)=>Object.is(e,t[n])),s=class extends r{state={error:null,hasError:!1};static getDerivedStateFromError(e){return{error:e,hasError:!0}}componentDidCatch(e,t){this.props.onError?.(e,t)}componentDidUpdate(e){this.state.hasError&&!o(e.resetKeys,this.props.resetKeys)&&this.reset()}reset=()=>{this.props.onReset?.(),this.setState({error:null,hasError:!1})};render(){let{children:r,fallback:o,homeHref:s=`/`,brand:c,onError:l,onReset:u,resetKeys:d,...f}=this.props;return n(`AppErrorBoundary`,f),this.state.hasError?typeof o==`function`?o({error:this.state.error,reset:this.reset}):o===void 0?/* @__PURE__ */ i(t,{kind:`error`,fullPage:!1,homeHref:s,brand:c,onRetry:this.reset,children:/* @__PURE__ */ i(e,{variant:`ghost`,leftIcon:`refresh-cw`,onClick:a,children:`Reload the page`})}):o:r}};function c({children:e,fallback:t,onError:n,resetKeys:r,onReset:a,homeHref:o,brand:c}){return/* @__PURE__ */ i(s,{fallback:t,onError:n,resetKeys:r,onReset:a,homeHref:o,brand:c,children:e})}export{c as default};
1
+ import e from"../lib/useWuiText.js";import t from"./AppButton.js";import n from"./AppRouteError.js";import r from"./warnUnknownProps.js";import{Component as i}from"react";import{jsx as a}from"react/jsx-runtime";import{ERROR_BOUNDARY_TEXT as o}from"@webority/ui-elements/text";var s=()=>window.location.reload(),c=(e=[],t=[])=>e.length===t.length&&e.every((e,n)=>Object.is(e,t[n])),l=class extends i{state={error:null,hasError:!1};static getDerivedStateFromError(e){return{error:e,hasError:!0}}componentDidCatch(e,t){this.props.onError?.(e,t)}componentDidUpdate(e){this.state.hasError&&!c(e.resetKeys,this.props.resetKeys)&&this.reset()}reset=()=>{this.props.onReset?.(),this.setState({error:null,hasError:!1})};render(){let{children:e,fallback:i,homeHref:o=`/`,brand:c,reloadLabel:l,onError:u,onReset:d,resetKeys:f,...p}=this.props;return r(`AppErrorBoundary`,p),this.state.hasError?typeof i==`function`?i({error:this.state.error,reset:this.reset}):i===void 0?/* @__PURE__ */ a(n,{kind:`error`,fullPage:!1,homeHref:o,brand:c,onRetry:this.reset,children:/* @__PURE__ */ a(t,{variant:`ghost`,leftIcon:`refresh-cw`,onClick:s,children:l})}):i:e}};function u({children:t,fallback:n,onError:r,resetKeys:i,onReset:s,homeHref:c,brand:u}){let d=e(`errorBoundary`,o);return/* @__PURE__ */ a(l,{fallback:n,onError:r,resetKeys:i,onReset:s,homeHref:c,brand:u,reloadLabel:d.reloadPageLabel,children:t})}export{u as default};
@@ -1 +1 @@
1
- import e from"../lib/focusField.js";import{splitMarkerProps as t}from"../lib/wuiMarker.js";import n from"./warnUnknownProps.js";import{useEffect as r,useId as i,useRef as a}from"react";import{jsx as o,jsxs as s}from"react/jsx-runtime";function c(c){let{marker:l,props:u}=t(`AppErrorSummary`,c),{errors:d=[],title:f,autoFocus:p=!0,id:m,className:h=``,...g}=u;n(`AppErrorSummary`,g);let _=i(),v=m||_,y=a(null),b=a(0),x=d.length;return r(()=>{p&&x>0&&b.current===0&&y.current?.focus(),b.current=x},[x,p]),x?/* @__PURE__ */ s(`div`,{ref:y,className:[`alert alert-danger wui-error-summary`,h].filter(Boolean).join(` `),role:`alert`,tabIndex:-1,"aria-labelledby":`${v}-title`,id:v,"data-autofocus":p?``:void 0,...l,...g,children:[/* @__PURE__ */ o(`h2`,{className:`wui-error-summary-title`,id:`${v}-title`,children:f??`Fix ${x} field${x>1?`s`:``} to continue`}),/* @__PURE__ */ o(`ul`,{className:`wui-error-summary-list`,children:d.map(t=>/* @__PURE__ */ o(`li`,{children:/* @__PURE__ */ o(`a`,{href:`#${t.field}`,onClick:n=>{n.preventDefault(),e(t.field)},children:t.message})},`${t.field}:${t.message}`))})]}):null}export{c as default};
1
+ import e from"../lib/focusField.js";import t from"../lib/useWuiText.js";import{splitMarkerProps as n}from"../lib/wuiMarker.js";import r from"./warnUnknownProps.js";import{useEffect as i,useId as a,useRef as o}from"react";import{jsx as s,jsxs as c}from"react/jsx-runtime";import{ERROR_SUMMARY_TEXT as l,pluralText as u}from"@webority/ui-elements/text";function d(d){let{marker:f,props:p}=n(`AppErrorSummary`,d),m=t(`errorSummary`,l),{errors:h=[],title:g,autoFocus:_=!0,id:v,className:y=``,...b}=p;r(`AppErrorSummary`,b);let x=a(),S=v||x,C=o(null),w=o(0),T=h.length;return i(()=>{_&&T>0&&w.current===0&&C.current?.focus(),w.current=T},[T,_]),T?/* @__PURE__ */ c(`div`,{ref:C,className:[`alert alert-danger wui-error-summary`,y].filter(Boolean).join(` `),role:`alert`,tabIndex:-1,"aria-labelledby":`${S}-title`,id:S,"data-autofocus":_?``:void 0,...f,...b,children:[/* @__PURE__ */ s(`h2`,{className:`wui-error-summary-title`,id:`${S}-title`,children:g??u(m,`title`,T)}),/* @__PURE__ */ s(`ul`,{className:`wui-error-summary-list`,children:h.map(t=>/* @__PURE__ */ s(`li`,{children:/* @__PURE__ */ s(`a`,{href:`#${t.field}`,onClick:n=>{n.preventDefault(),e(t.field)},children:t.message})},`${t.field}:${t.message}`))})]}):null}export{d as default};
@@ -1 +1 @@
1
- import e from"../lib/FieldMessage.js";import t from"../lib/FileItemRow.js";import{keyOf as n,linkOf as r,nameOf as i,sizeLabelOf as a,uploadErrorOf as o,uploadProgressOf as s,useItemUrl as c}from"../lib/fileItem.js";import l from"../lib/fillLabel.js";import{useFieldError as u}from"../lib/formFields.js";import{linkTarget as d}from"../lib/linkTarget.js";import{TargetLink as f}from"../lib/TargetLink.js";import p from"../lib/useFileDrop.js";import{splitMarkerProps as m}from"../lib/wuiMarker.js";import h from"./AppIcon.js";import g from"./AppProgress.js";import _ from"./warnUnknownProps.js";import{DEFAULT_IMAGE_ACCEPT as v,DEFAULT_MAX_SIZE_MB as y,acceptDroppedFiles as b,acceptLabel as x,isImageFile as S,isImageOnlyAccept as C}from"@webority/ui-elements/helpers";import{useId as w,useState as T}from"react";import{jsx as E,jsxs as D}from"react/jsx-runtime";function O(i){let{marker:a,props:o}=m(`AppFileAttachment`,i),{label:s=`Attachment`,value:c,name:l,onChange:d,multiple:f=!1,accept:g=v,maxSizeMb:x=y,optional:O=!1,validate:A=!0,error:j,id:M,linkComponent:N,browseLabel:ne=`Browse`,removeLabel:re=`Remove attachment`,uploadingLabel:ie=`Uploading {name}`,maxSizeText:ae=`Up to {size} MB`,typesAndMaxSizeText:oe=`{types}, up to {size} MB`,removeFileLabel:se=`Remove {name}`,optionalLabel:ce=`(optional)`,dropTitle:le,...P}=o,F=u(l),I=j??F;if(_(`AppFileAttachment`,P),!f&&Array.isArray(c))throw TypeError(`[@webority/ui-react] <AppFileAttachment> received a list of files as value without multiple. Pass one file (or null), or set multiple to take a list.`);let L=w(),R=M||L,[z,B]=T(``),V=Array.isArray(c)?c:c?[c]:[],H=C(g),U=e=>e instanceof File?S(e):H||S(te(e)),W=V[0],G=!f&&W!==void 0&&U(W)&&(W instanceof File||r(W)!==null)?W:void 0,K=ee(g,x,ae,oe),q=A?{accept:g,maxSizeMb:x,multiple:f}:{accept:``,maxSizeMb:0,multiple:f},J=e=>{i.multiple||i.onChange(e)},Y=e=>{i.multiple&&i.onChange(e)};function X(e){if(B(``),f){let t=Array.isArray(c)?c:c?[c]:[],r=new Set(t.map(n)),i=t.concat(e.filter(e=>!r.has(n(e))));Y(i)}else J(e[0]??null)}function ue(e){if(!e.length)return;let{files:t,rejections:n}=b(e,q);t.length&&X(t),B(n[0]?.message??``)}let{dragOver:de,dropProps:fe}=p({...q,disabled:P.disabled,onFiles:X,onReject:e=>B(e.message)});function pe(e){let t=Array.from(e.target.files||[]);e.target.value=``,ue(t)}function Z(e){B(``),f?Y(V.filter((t,n)=>n!==e)):J(null)}let Q=I||z,me=Q?`${R}-error`:void 0,he=f||V.length===0,$=H?`image`:`file`,ge=le??(f?`Add ${$}s`:`Add ${H?`an`:`a`} ${$}`);return/* @__PURE__ */ D(`div`,{...a,className:`field`,children:[/* @__PURE__ */ D(`label`,{className:`label`,htmlFor:R,children:[s,O&&/* @__PURE__ */ E(`span`,{className:`label-optional`,children:` ${ce}`})]}),/* @__PURE__ */ D(`label`,{className:`attach-drop${de?` dragging`:``}`,htmlFor:R,style:he?void 0:{display:`none`},...fe,children:[/* @__PURE__ */ E(`span`,{className:`attach-drop-icon`,children:/* @__PURE__ */ E(h,{name:H?`image`:`file-text`,size:18})}),/* @__PURE__ */ D(`span`,{className:`attach-drop-copy`,children:[/* @__PURE__ */ E(`span`,{className:`attach-drop-title`,children:ge}),K&&/* @__PURE__ */ E(`span`,{className:`attach-drop-hint`,children:K})]}),/* @__PURE__ */ E(`span`,{className:`attach-drop-cta`,children:ne})]}),/* @__PURE__ */ E(`input`,{id:R,type:`file`,className:`visually-hidden`,name:l,accept:g||void 0,multiple:f||void 0,"aria-describedby":me,onChange:pe,...P}),G?/* @__PURE__ */ E(k,{item:G,isImage:!0,linkComponent:N,onRemove:()=>Z(0),removeLabel:re,uploadingLabel:ie}):V.length>0&&/* @__PURE__ */ E(`div`,{className:`attach-list`,children:V.map((e,r)=>/* @__PURE__ */ E(t,{item:e,isImage:U(e),linkComponent:N,onRemove:()=>Z(r),removeFileLabel:se},n(e)))}),/* @__PURE__ */ E(e,{error:Q,errorId:`${R}-error`})]})}function ee(e,t,n,r){let i=e?.trim()?x(e):``,a=t>0;return i&&a?l(r,{types:i,size:t}):a?l(n,{size:t}):i}function te({name:e,url:t}){return{...e===void 0?null:{name:e},...t===void 0?null:{url:t}}}function k({item:e,isImage:t,linkComponent:n,onRemove:u,removeLabel:p,uploadingLabel:m}){let _=c(e,t),v=i(e),y=a(e),b=s(e),x=o(e),S=r(e),C=e instanceof File?void 0:e.to,w=d(n,{to:C,href:S??void 0,routeHref:!1});return/* @__PURE__ */ D(`div`,{className:x?`attach-preview wui-attach-failed`:`attach-preview`,children:[/* @__PURE__ */ D(`div`,{className:`attach-figure`,children:[/* @__PURE__ */ E(`img`,{src:_??void 0,alt:v}),/* @__PURE__ */ E(`button`,{type:`button`,className:`attach-remove`,"aria-label":p,onClick:u,children:/* @__PURE__ */ E(h,{name:`x`,size:18})})]}),/* @__PURE__ */ D(`div`,{className:`attach-meta`,children:[/* @__PURE__ */ E(`div`,{className:`attach-name`,children:S||C?/* @__PURE__ */ E(f,{link:w,children:v}):v}),y&&/* @__PURE__ */ E(`div`,{className:`attach-size`,children:y})]}),b!==null&&/* @__PURE__ */ E(g,{value:b,size:`sm`,label:l(m,{name:v}),className:`wui-attach-progress`}),x&&/* @__PURE__ */ E(`div`,{className:`wui-attach-error`,children:x})]})}export{O as default};
1
+ import e from"../lib/FieldMessage.js";import t from"../lib/FileItemRow.js";import{keyOf as n,linkOf as r,nameOf as i,sizeLabelOf as a,uploadErrorOf as o,uploadProgressOf as s,useItemUrl as c}from"../lib/fileItem.js";import{useFieldError as l}from"../lib/formFields.js";import{linkTarget as u}from"../lib/linkTarget.js";import{TargetLink as d}from"../lib/TargetLink.js";import f from"../lib/useFileDrop.js";import p from"../lib/useWuiText.js";import{splitMarkerProps as m}from"../lib/wuiMarker.js";import h from"./AppIcon.js";import g from"./AppProgress.js";import _ from"./warnUnknownProps.js";import{DEFAULT_IMAGE_ACCEPT as v,DEFAULT_MAX_SIZE_MB as y,acceptDroppedFiles as b,acceptLabel as x,isImageFile as S,isImageOnlyAccept as C}from"@webority/ui-elements/helpers";import{useId as ee,useState as te}from"react";import{jsx as w,jsxs as T}from"react/jsx-runtime";import{FILE_ATTACHMENT_TEXT as ne,fillText as E,pluralText as D}from"@webority/ui-elements/text";function O(i){let{marker:a,props:o}=m(`AppFileAttachment`,i),s=p(`fileAttachment`,ne),{label:c=s.label,value:u,name:d,onChange:g,multiple:x=!1,accept:E=v,maxSizeMb:O=y,optional:ie=!1,validate:ae=!0,error:oe,id:se,linkComponent:j,browseLabel:ce=s.browseLabel,removeLabel:le=s.removeLabel,uploadingLabel:ue=s.uploadingLabel,maxSizeText:de=s.maxSizeText,typesAndMaxSizeText:fe=s.typesAndMaxSizeText,removeFileLabel:pe=s.removeFileLabel,optionalLabel:M=s.optionalLabel,dropTitle:N,...P}=o,F=l(d),I=oe??F;if(_(`AppFileAttachment`,P),!x&&Array.isArray(u))throw TypeError(`[@webority/ui-react] <AppFileAttachment> received a list of files as value without multiple. Pass one file (or null), or set multiple to take a list.`);let L=ee(),R=se||L,[z,B]=te(``),V=Array.isArray(u)?u:u?[u]:[],H=C(E),U=e=>e instanceof File?S(e):H||S(A(e)),W=V[0],G=!x&&W!==void 0&&U(W)&&(W instanceof File||r(W)!==null)?W:void 0,K=k(E,O,de,fe),q=ae?{accept:E,maxSizeMb:O,multiple:x}:{accept:``,maxSizeMb:0,multiple:x},J=e=>{i.multiple||i.onChange(e)},Y=e=>{i.multiple&&i.onChange(e)};function X(e){if(B(``),x){let t=Array.isArray(u)?u:u?[u]:[],r=new Set(t.map(n)),i=t.concat(e.filter(e=>!r.has(n(e))));Y(i)}else J(e[0]??null)}function me(e){if(!e.length)return;let{files:t,rejections:n}=b(e,q);t.length&&X(t),B(n[0]?.message??``)}let{dragOver:he,dropProps:ge}=f({...q,disabled:P.disabled,onFiles:X,onReject:e=>B(e.message)});function Z(e){let t=Array.from(e.target.files||[]);e.target.value=``,me(t)}function Q(e){B(``),x?Y(V.filter((t,n)=>n!==e)):J(null)}let $=I||z,_e=$?`${R}-error`:void 0,ve=x||V.length===0,ye=N??(H?D(s,`dropImageTitle`,x?2:1):D(s,`dropFileTitle`,x?2:1));return/* @__PURE__ */ T(`div`,{...a,className:`field`,children:[/* @__PURE__ */ T(`label`,{className:`label`,htmlFor:R,children:[c,ie&&/* @__PURE__ */ w(`span`,{className:`label-optional`,children:` ${M}`})]}),/* @__PURE__ */ T(`label`,{className:`attach-drop${he?` dragging`:``}`,htmlFor:R,style:ve?void 0:{display:`none`},...ge,children:[/* @__PURE__ */ w(`span`,{className:`attach-drop-icon`,children:/* @__PURE__ */ w(h,{name:H?`image`:`file-text`,size:18})}),/* @__PURE__ */ T(`span`,{className:`attach-drop-copy`,children:[/* @__PURE__ */ w(`span`,{className:`attach-drop-title`,children:ye}),K&&/* @__PURE__ */ w(`span`,{className:`attach-drop-hint`,children:K})]}),/* @__PURE__ */ w(`span`,{className:`attach-drop-cta`,children:ce})]}),/* @__PURE__ */ w(`input`,{id:R,type:`file`,className:`visually-hidden`,name:d,accept:E||void 0,multiple:x||void 0,"aria-describedby":_e,onChange:Z,...P}),G?/* @__PURE__ */ w(re,{item:G,isImage:!0,linkComponent:j,onRemove:()=>Q(0),removeLabel:le,uploadingLabel:ue}):V.length>0&&/* @__PURE__ */ w(`div`,{className:`attach-list`,children:V.map((e,r)=>/* @__PURE__ */ w(t,{item:e,isImage:U(e),linkComponent:j,onRemove:()=>Q(r),removeFileLabel:pe},n(e)))}),/* @__PURE__ */ w(e,{error:$,errorId:`${R}-error`})]})}function k(e,t,n,r){let i=e?.trim()?x(e):``,a=t>0;return i&&a?E(r,{types:i,size:t}):a?E(n,{size:t}):i}function A({name:e,url:t}){return{...e===void 0?null:{name:e},...t===void 0?null:{url:t}}}function re({item:e,isImage:t,linkComponent:n,onRemove:l,removeLabel:f,uploadingLabel:p}){let m=c(e,t),_=i(e),v=a(e),y=s(e),b=o(e),x=r(e),S=e instanceof File?void 0:e.to,C=u(n,{to:S,href:x??void 0,routeHref:!1});return/* @__PURE__ */ T(`div`,{className:b?`attach-preview wui-attach-failed`:`attach-preview`,children:[/* @__PURE__ */ T(`div`,{className:`attach-figure`,children:[/* @__PURE__ */ w(`img`,{src:m??void 0,alt:_}),/* @__PURE__ */ w(`button`,{type:`button`,className:`attach-remove`,"aria-label":f,onClick:l,children:/* @__PURE__ */ w(h,{name:`x`,size:18})})]}),/* @__PURE__ */ T(`div`,{className:`attach-meta`,children:[/* @__PURE__ */ w(`div`,{className:`attach-name`,children:x||S?/* @__PURE__ */ w(d,{link:C,children:_}):_}),v&&/* @__PURE__ */ w(`div`,{className:`attach-size`,children:v})]}),y!==null&&/* @__PURE__ */ w(g,{value:y,size:`sm`,label:E(p,{name:_??``}),className:`wui-attach-progress`}),b&&/* @__PURE__ */ w(`div`,{className:`wui-attach-error`,children:b})]})}export{O as default};
@@ -1 +1 @@
1
- import{devWarn as e}from"../lib/devWarn.js";import t from"../lib/FieldMessage.js";import n from"../lib/FileItemRow.js";import{FIELD_SIZES as r}from"../lib/fieldState.js";import{keyOf as i}from"../lib/fileItem.js";import a from"../lib/fillLabel.js";import{useFieldError as o}from"../lib/formFields.js";import ee from"../lib/useFileDrop.js";import{splitMarkerProps as te}from"../lib/wuiMarker.js";import s from"./AppIcon.js";import ne from"./AppInfoTip.js";import re from"./AppRequiredMark.js";import ie from"./AppSpinner.js";import ae from"./assertValidValue.js";import oe from"./warnUnknownProps.js";import se from"./withTooltip.js";import{DEFAULT_MAX_SIZE_MB as ce,acceptDroppedFiles as le,acceptLabel as c,isImageFile as l,isImageOnlyAccept as ue,isPdfFile as de}from"@webority/ui-elements/helpers";import{useEffect as u,useId as fe,useRef as pe,useState as d}from"react";import{jsx as f,jsxs as p}from"react/jsx-runtime";var me=[`dropzone`,`button`],he={sm:` input-sm`,md:``,lg:` input-lg`},ge={md:``,lg:` btn-lg`};function m(e){return e instanceof File?e:{url:e.url,...e.name===void 0?null:{name:e.name}}}function h(h){let{marker:_e,props:ve}=te(`AppFilePicker`,h),{label:g,value:_,name:v,id:ye,onChange:be,multiple:y=!1,variant:b=`dropzone`,buttonLabel:xe=`Add file`,browseLabel:Se=`Click to upload`,dropLabel:Ce=`or drag & drop`,maxSizeText:we=`up to {size} MB`,optionalLabel:Te=`(optional)`,changeImageLabel:Ee=`Change image`,changeFileLabel:De=`Change file`,maxFilesText:Oe=`Up to {count} files.`,removeFileLabel:ke=`Remove {name}`,maxFiles:x,accept:S=`.jpg,.jpeg,.png`,maxSizeMb:C=ce,required:w,optional:Ae=!1,error:je,helperText:T,help:E,helpLabel:Me=`More information`,loading:D=!1,readOnly:O=!1,size:k,disabled:A=!1,className:j=``,fieldClassName:M=``,style:N,...P}=ve,Ne=o(v),Pe=je??Ne;if(oe(`AppFilePicker`,P),ae(`AppFilePicker`,`variant`,b,me),ae(`AppFilePicker`,`size`,k,r),!y&&Array.isArray(_))throw TypeError(`[@webority/ui-react] <AppFilePicker> received a list of files as value without multiple. Pass one file (or null), or set multiple to take a list.`);let F=k===void 0?``:he[k]??``,I=O?{"aria-readonly":`true`,"data-wui-readonly":``}:null,[Fe,L]=d(null),[Ie,R]=d(null),[Le,z]=d(``),B=pe(null),Re=fe(),V=ye||Re,H=A||D;u(()=>{if(!y&&_ instanceof File&&l(_)){let e=URL.createObjectURL(_);return L(e),()=>URL.revokeObjectURL(e)}L(null)},[_,y]);let U=y||Array.isArray(_)?void 0:_,W=U&&!l(m(U))&&de(m(U))?U instanceof File?U:U.url:null;u(()=>{if(!W){R(null);return}let t=!0,n=null;return import(`@webority/ui-elements/file-viewer`).then(e=>e.renderPdfFirstPage(typeof W==`string`?{url:W}:W)).then(e=>{t&&(n=URL.createObjectURL(e),R(n))}).catch(t=>e(`[AppFilePicker] the PDF preview failed:`,t?.message)),()=>{t=!1,R(null),n&&URL.revokeObjectURL(n)}},[W]);let G=y?Array.isArray(_)?_:_?[_]:[]:[],K=Pe||Le,q=K?`${V}-error`:void 0,J=T&&!K?`${V}-hint`:void 0,ze=q||J,Be=ue(S),Ve=b===`button`,He=`btn btn-outline-primary${(k===`md`||k===`lg`?ge[k]:void 0)??` btn-sm`}`,Ue=!y&&!!_,Y=!!U&&(U instanceof File?l(U):Be||l(m(U))),We=U?.name,Ge=U instanceof File?void 0:U?.url,Ke=Y?Ge||Fe:Ie,X=Y?`image`:`file`,qe=g?`Change ${g}`:`Change ${X}`,Je=g?`Remove ${g}`:`Remove ${X}`,Ye=g?`${g} preview`:`Selected ${X} preview`,Xe={accept:S,maxSizeMb:C,multiple:y},Z=e=>{h.multiple||h.onChange(e)},Ze=e=>{h.multiple&&h.onChange(e)},Qe=e=>{if(z(``),!y){Z(e[0]??null);return}let t=Array.isArray(_)?_:_?[_]:[],n=new Set(t.map(i)),r=[];for(let t of e)n.has(i(t))||(n.add(i(t)),r.push(t));let o=t.concat(r);x&&o.length>x&&(o=o.slice(0,x),z(a(Oe,{count:x}))),Ze(o)},$e=e=>z(e.message),{dragOver:et,dropProps:tt}=ee({...Xe,disabled:H||O,onFiles:Qe,onReject:$e}),nt=e=>{if(O)return;let{files:t,rejections:n}=le(e,Xe);t.length&&Qe(t);let[r]=n;r&&$e(r)},rt=e=>nt(e.target.files),it=e=>{O||(z(``),Ze(G.filter((t,n)=>n!==e)))},at=()=>{O||B.current?.click()},Q=D?/* @__PURE__ */ f(`span`,{className:`wui-file-busy`,children:/* @__PURE__ */ f(ie,{size:`sm`})}):null,$=/* @__PURE__ */ f(`input`,{id:V,name:v,ref:B,type:`file`,"aria-describedby":ze,accept:S,multiple:y||void 0,disabled:H||void 0,className:`visually-hidden`,onClick:e=>{O?e.preventDefault():e.currentTarget.value=``},onChange:rt,...P});return/* @__PURE__ */ p(`div`,{..._e,className:`field${M?` ${M}`:``}`,children:[g?/* @__PURE__ */ p(`label`,{className:`label`,htmlFor:V,children:[g,Ae&&!w&&/* @__PURE__ */ f(`span`,{className:`label-optional`,children:` ${Te}`}),w&&/* @__PURE__ */ f(re,{}),E&&/* @__PURE__ */ f(ne,{label:Me,children:E})]}):null,Ve?/* @__PURE__ */ p(`div`,{className:`file-input wui-file-input-button-field${F}${K?` error`:``}${j?` ${j}`:``}`,style:N,"aria-busy":D||void 0,...I,children:[/* @__PURE__ */ p(`label`,{htmlFor:V,className:He,children:[/* @__PURE__ */ f(s,{name:`paperclip`,size:16}),xe]}),$,Q]}):Ue?/* @__PURE__ */ p(`div`,{className:`file-preview${F}${K?` error`:``}${j?` ${j}`:``}`,style:N,"aria-busy":D||void 0,...I,children:[/* @__PURE__ */ p(`button`,{type:`button`,className:`file-preview-open`,"aria-label":qe,onClick:at,disabled:H||O,children:[Ke?/* @__PURE__ */ f(`img`,{src:Ke,alt:Ye,className:`file-preview-img`}):/* @__PURE__ */ p(`span`,{className:`file-preview-file`,children:[/* @__PURE__ */ f(s,{name:`file-text`,size:28}),/* @__PURE__ */ f(`span`,{className:`file-preview-file-name`,children:We})]}),/* @__PURE__ */ f(`span`,{className:`file-preview-overlay`,children:/* @__PURE__ */ p(`span`,{className:`file-preview-cta`,children:[/* @__PURE__ */ f(s,{name:Y?`image`:`file-text`,size:16}),` `,Y?Ee:De]})})]}),se(/* @__PURE__ */ f(`button`,{type:`button`,className:`file-preview-remove`,"aria-label":Je,onClick:()=>Z(null),disabled:H||O,children:/* @__PURE__ */ f(s,{name:`x`,size:16})}),Je),$,Q]}):/* @__PURE__ */ p(`div`,{className:`file-input file-input-tall${F}${et?` dragging`:``}${K?` error`:``}${y&&G.length>0?` has-files`:``}${j?` ${j}`:``}`,style:N,"aria-busy":D||void 0,"aria-disabled":A||void 0,...I,...tt,children:[/* @__PURE__ */ p(`label`,{htmlFor:V,className:`file-input-zone-label`,children:[/* @__PURE__ */ f(`span`,{className:`file-input-icon`,children:/* @__PURE__ */ f(s,{name:`upload`,size:24})}),/* @__PURE__ */ p(`span`,{className:`file-input-title`,children:[/* @__PURE__ */ f(`span`,{className:`browse`,children:Se}),` ${Ce}`]}),/* @__PURE__ */ f(`span`,{className:`file-input-text`,children:C>0?`${c(S)}, ${a(we,{size:C})}`:c(S)})]}),$,Q,y&&G.length>0&&/* @__PURE__ */ f(`div`,{className:`attach-list`,children:G.map((e,t)=>/* @__PURE__ */ f(n,{item:e,isImage:e instanceof File?l(e):Be||l(m(e)),noun:`file`,removeFileLabel:ke,readOnly:O,onRemove:()=>it(t)},i(e)))})]}),/* @__PURE__ */ f(t,{error:K,hint:T,errorId:q,hintId:J})]})}export{h as default};
1
+ import{devWarn as e}from"../lib/devWarn.js";import t from"../lib/FieldMessage.js";import n from"../lib/FileItemRow.js";import{BOX_SIZES as r}from"../lib/fieldState.js";import{keyOf as i}from"../lib/fileItem.js";import{useFieldError as a}from"../lib/formFields.js";import ee from"../lib/useFileDrop.js";import te from"../lib/useWuiText.js";import{splitMarkerProps as ne}from"../lib/wuiMarker.js";import o from"./AppIcon.js";import re from"./AppInfoTip.js";import ie from"./AppRequiredMark.js";import ae from"./AppSpinner.js";import s from"./assertValidValue.js";import oe from"./warnUnknownProps.js";import se from"./withTooltip.js";import{DEFAULT_MAX_SIZE_MB as ce,acceptDroppedFiles as le,acceptLabel as c,isImageFile as l,isImageOnlyAccept as ue,isPdfFile as de}from"@webority/ui-elements/helpers";import{useEffect as u,useId as fe,useRef as pe,useState as d}from"react";import{jsx as f,jsxs as p}from"react/jsx-runtime";import{FILE_PICKER_TEXT as me,fillText as m}from"@webority/ui-elements/text";var he=[`dropzone`,`button`],ge={sm:` wui-input-sm`,md:``,lg:` wui-input-lg`},_e={md:``,lg:` btn-lg`};function h(e){return e instanceof File?e:{url:e.url,...e.name===void 0?null:{name:e.name}}}function g(g){let{marker:ve,props:ye}=ne(`AppFilePicker`,g),_=te(`filePicker`,me),{label:v,value:y,name:b,id:be,onChange:xe,multiple:x=!1,variant:S=`dropzone`,buttonLabel:Se=_.buttonLabel,browseLabel:Ce=_.browseLabel,dropLabel:we=_.dropLabel,maxSizeText:Te=_.maxSizeText,optionalLabel:Ee=_.optionalLabel,changeImageLabel:De=_.changeImageLabel,changeFileLabel:Oe=_.changeFileLabel,maxFilesText:ke=_.maxFilesText,removeFileLabel:Ae=_.removeFileLabel,maxFiles:C,accept:w=`.jpg,.jpeg,.png`,maxSizeMb:T=ce,required:E,optional:je=!1,error:Me,helperText:D,help:O,helpLabel:Ne=_.helpLabel,loading:k=!1,readOnly:A=!1,size:j,disabled:M=!1,className:N=``,fieldClassName:P=``,style:F,...I}=ye,Pe=a(b),Fe=Me??Pe;if(oe(`AppFilePicker`,I),s(`AppFilePicker`,`variant`,S,he),s(`AppFilePicker`,`size`,j,r),!x&&Array.isArray(y))throw TypeError(`[@webority/ui-react] <AppFilePicker> received a list of files as value without multiple. Pass one file (or null), or set multiple to take a list.`);let L=j===void 0?``:ge[j]??``,R=A?{"aria-readonly":`true`,"data-wui-readonly":``}:null,[Ie,z]=d(null),[Le,B]=d(null),[Re,V]=d(``),H=pe(null),ze=fe(),U=be||ze,W=M||k;u(()=>{if(!x&&y instanceof File&&l(y)){let e=URL.createObjectURL(y);return z(e),()=>URL.revokeObjectURL(e)}z(null)},[y,x]);let G=x||Array.isArray(y)?void 0:y,K=G&&!l(h(G))&&de(h(G))?G instanceof File?G:G.url:null;u(()=>{if(!K){B(null);return}let t=!0,n=null;return import(`@webority/ui-elements/file-viewer`).then(e=>e.renderPdfFirstPage(typeof K==`string`?{url:K}:K)).then(e=>{t&&(n=URL.createObjectURL(e),B(n))}).catch(t=>e(`[AppFilePicker] the PDF preview failed:`,t?.message)),()=>{t=!1,B(null),n&&URL.revokeObjectURL(n)}},[K]);let q=x?Array.isArray(y)?y:y?[y]:[]:[],J=Fe||Re,Y=J?`${U}-error`:void 0,Be=D&&!J?`${U}-hint`:void 0,Ve=Y||Be,He=ue(w),Ue=S===`button`,We=`btn btn-outline-primary${(j===`md`||j===`lg`?_e[j]:void 0)??` btn-sm`}`,Ge=!x&&!!y,X=!!G&&(G instanceof File?l(G):He||l(h(G))),Ke=G?.name,qe=G instanceof File?void 0:G?.url,Je=X?qe||Ie:Le,Z=X?_.imageLabel:_.fileLabel,Ye=m(_.changeNamedText,{label:v||Z}),Xe=m(_.removeNamedText,{label:v||Z}),Ze=v?m(_.previewAltText,{label:v}):m(_.selectedPreviewText,{noun:Z}),Qe={accept:w,maxSizeMb:T,multiple:x},$e=e=>{g.multiple||g.onChange(e)},et=e=>{g.multiple&&g.onChange(e)},tt=e=>{if(V(``),!x){$e(e[0]??null);return}let t=Array.isArray(y)?y:y?[y]:[],n=new Set(t.map(i)),r=[];for(let t of e)n.has(i(t))||(n.add(i(t)),r.push(t));let a=t.concat(r);C&&a.length>C&&(a=a.slice(0,C),V(m(ke,{count:C}))),et(a)},nt=e=>V(e.message),{dragOver:rt,dropProps:it}=ee({...Qe,disabled:W||A,onFiles:tt,onReject:nt}),at=e=>{if(A)return;let{files:t,rejections:n}=le(e,Qe);t.length&&tt(t);let[r]=n;r&&nt(r)},ot=e=>at(e.target.files),st=e=>{A||(V(``),et(q.filter((t,n)=>n!==e)))},ct=()=>{A||H.current?.click()},Q=k?/* @__PURE__ */ f(`span`,{className:`wui-file-busy`,children:/* @__PURE__ */ f(ae,{size:`sm`})}):null,$=/* @__PURE__ */ f(`input`,{id:U,name:b,ref:H,type:`file`,"aria-describedby":Ve,accept:w,multiple:x||void 0,disabled:W||void 0,className:`visually-hidden`,onClick:e=>{A?e.preventDefault():e.currentTarget.value=``},onChange:ot,...I});return/* @__PURE__ */ p(`div`,{...ve,className:`field${P?` ${P}`:``}`,children:[v?/* @__PURE__ */ p(`label`,{className:`label`,htmlFor:U,children:[v,je&&!E&&/* @__PURE__ */ f(`span`,{className:`label-optional`,children:` ${Ee}`}),E&&/* @__PURE__ */ f(ie,{}),O&&/* @__PURE__ */ f(re,{label:Ne,children:O})]}):null,Ue?/* @__PURE__ */ p(`div`,{className:`file-input wui-file-input-button-field${L}${J?` error`:``}${N?` ${N}`:``}`,style:F,"aria-busy":k||void 0,...R,children:[/* @__PURE__ */ p(`label`,{htmlFor:U,className:We,children:[/* @__PURE__ */ f(o,{name:`paperclip`,size:16}),Se]}),$,Q]}):Ge?/* @__PURE__ */ p(`div`,{className:`file-preview${L}${J?` error`:``}${N?` ${N}`:``}`,style:F,"aria-busy":k||void 0,...R,children:[/* @__PURE__ */ p(`button`,{type:`button`,className:`file-preview-open`,"aria-label":Ye,onClick:ct,disabled:W||A,children:[Je?/* @__PURE__ */ f(`img`,{src:Je,alt:Ze,className:`file-preview-img`}):/* @__PURE__ */ p(`span`,{className:`file-preview-file`,children:[/* @__PURE__ */ f(o,{name:`file-text`,size:28}),/* @__PURE__ */ f(`span`,{className:`file-preview-file-name`,children:Ke})]}),/* @__PURE__ */ f(`span`,{className:`file-preview-overlay`,children:/* @__PURE__ */ p(`span`,{className:`file-preview-cta`,children:[/* @__PURE__ */ f(o,{name:X?`image`:`file-text`,size:16}),` `,X?De:Oe]})})]}),se(/* @__PURE__ */ f(`button`,{type:`button`,className:`file-preview-remove`,"aria-label":Xe,onClick:()=>$e(null),disabled:W||A,children:/* @__PURE__ */ f(o,{name:`x`,size:16})}),Xe),$,Q]}):/* @__PURE__ */ p(`div`,{className:`file-input file-input-tall${L}${rt?` dragging`:``}${J?` error`:``}${x&&q.length>0?` has-files`:``}${N?` ${N}`:``}`,style:F,"aria-busy":k||void 0,"aria-disabled":M||void 0,...R,...it,children:[/* @__PURE__ */ p(`label`,{htmlFor:U,className:`file-input-zone-label`,children:[/* @__PURE__ */ f(`span`,{className:`file-input-icon`,children:/* @__PURE__ */ f(o,{name:`upload`,size:24})}),/* @__PURE__ */ p(`span`,{className:`file-input-title`,children:[/* @__PURE__ */ f(`span`,{className:`browse`,children:Ce}),` ${we}`]}),/* @__PURE__ */ f(`span`,{className:`file-input-text`,children:T>0?`${c(w)}, ${m(Te,{size:T})}`:c(w)})]}),$,Q,x&&q.length>0&&/* @__PURE__ */ f(`div`,{className:`attach-list`,children:q.map((e,t)=>/* @__PURE__ */ f(n,{item:e,isImage:e instanceof File?l(e):He||l(h(e)),noun:_.fileLabel,removeFileLabel:Ae,readOnly:A,onRemove:()=>st(t)},i(e)))})]}),/* @__PURE__ */ f(t,{error:J,hint:D,errorId:Y,hintId:Be})]})}export{g as default};
@@ -1 +1 @@
1
- import{emptyFacetValue as e,isFacetActive as t}from"../web-core/dist/query/listQuery.js";import{devWarn as n}from"../lib/devWarn.js";import r from"../lib/fillLabel.js";import i from"../lib/useElementEntry.js";import{splitMarkerProps as a}from"../lib/wuiMarker.js";import o from"./AppButton.js";import ee from"./AppChip.js";import s from"./AppDateRangePicker.js";import te from"./AppIcon.js";import c from"./AppSearch.js";import l from"./AppSegmented.js";import u from"./AppSelect.js";import ne from"./AppSwitch.js";import d from"./assertValidValue.js";import re from"./warnUnknownProps.js";import{isImeSafeEnter as ie}from"@webority/ui-elements/helpers";import{Fragment as ae,useEffect as f,useId as oe,useRef as p,useState as se,useSyncExternalStore as ce}from"react";import{Fragment as le,jsx as m,jsxs as h}from"react/jsx-runtime";var g=`(max-width: 575.98px)`,ue=3,_=2,de=e=>{let t=window.matchMedia?.(g);return t?.addEventListener(`change`,e),()=>t?.removeEventListener(`change`,e)},fe=()=>window.matchMedia?.(g).matches??!1,pe=[`enum`,`multiEnum`,`dateRange`,`text`],me=[`sm`,`md`],he=()=>import(`@webority/ui-elements/elements/filter-popover`),v=4,ge=e=>(e.type===`enum`||e.type===`multiEnum`)&&!e.options?.length,y=(e,t)=>e.options?.find(e=>e.value===t)?.label??t,_e=(e,t)=>JSON.stringify(e)===JSON.stringify(t),b=(e,t,n)=>/* @__PURE__ */ RangeError(`[@webority/ui-react] <AppFilterBar> facet "${e.key}" needs ${t}, received ${JSON.stringify(n)}.`),x=(e,t)=>{if(t==null)return``;if(typeof t==`string`)return t;throw b(e,`a string value`,t)},S=(e,t)=>{if(t==null)return[];if(Array.isArray(t)&&t.every(e=>typeof e==`string`))return t;throw b(e,`an array of strings`,t)},C=(e,t)=>{if(t==null)return{from:``,to:``};if(typeof t==`object`&&!Array.isArray(t)&&!(t instanceof Date)){let{from:e,to:n}=t;if((e===void 0||typeof e==`string`)&&(n===void 0||typeof n==`string`))return{from:e,to:n}}throw b(e,`a { from, to } date range`,t)};function ve(n,i,a){if(n.required||!t(n,i))return[];if(n.type===`enum`)return[{id:n.key,text:y(n,x(n,i)),clear:()=>e(n)}];if(n.type===`multiEnum`){let e=S(n,i);return e.map(t=>({id:`${n.key}:${t}`,text:y(n,t),clear:()=>e.filter(e=>e!==t)}))}if(n.type===`dateRange`){let t=C(n,i),o=t.from&&t.to?r(a.range,{from:t.from,to:t.to}):t.from?r(a.from,{date:t.from}):r(a.until,{date:t.to});return[{id:n.key,text:o,clear:()=>e(n)}]}return[]}var w=/* @__PURE__ */ new Set;function ye(e){let t=!0;try{t=process.env.NODE_ENV!==`production`}catch{t=!0}t&&!w.has(e)&&(w.add(e),n(`[@webority/ui-react] <AppFilterBar> facet "${e}" sets allLabel, which only an enum facet uses.`))}var T=/* @__PURE__ */ new Set;function be(e){let t=!0;try{t=process.env.NODE_ENV!==`production`}catch{t=!0}t&&!T.has(e)&&(T.add(e),n(`[@webority/ui-react] <AppFilterBar> facet "${e}" sets required, which only an enum facet uses.`))}var E=/* @__PURE__ */ new Set;function xe(e){let t=!0;try{t=process.env.NODE_ENV!==`production`}catch{t=!0}t&&!E.has(e)&&(E.add(e),n(`[@webority/ui-react] <AppFilterBar> facet "${e}" sets allLabel and required; a required facet has no All segment.`))}var D=/* @__PURE__ */ new Set;function Se(e){let t=!0;try{t=process.env.NODE_ENV!==`production`}catch{t=!0}t&&!D.has(e)&&(D.add(e),n(`[@webority/ui-react] <AppFilterBar> facet "${e}" sets presets, which only a dateRange facet uses.`))}var O=/* @__PURE__ */ new Set;function Ce(e){let t=!0;try{t=process.env.NODE_ENV!==`production`}catch{t=!0}t&&!O.has(e)&&(O.add(e),n(`[@webority/ui-react] <AppFilterBar> facet "${e}" sets count or icon on an option, which only an enum facet drawn as segments shows.`))}var we=e=>{let t=e.options?.length??0;return e.type===`enum`&&(e.required?t<=v:t<v)};function k(n){i(`wui-filter-popover`,he);let{marker:s,props:c}=a(`AppFilterBar`,n),{facets:l,value:u,onChange:g,onChangeMany:v,inline:y=ue,facetLabels:b=!1,floating:x=!1,apply:S=!1,size:C=`sm`,className:w=``,clearAllLabel:T=`Clear all`,filtersLabel:E=`Filters`,filtersActiveLabel:D=`Filters, {count} active`,keepOpenLabel:O=`Keep open`,appliesAtOnceText:k=`Changes apply at once.`,applyLabel:Te=`Apply`,anyLabel:j=`Any`,removeChipLabel:Ee=`Remove {facet} filter {value}`,dateFromText:De=`From {date}`,dateUntilText:Oe=`Until {date}`,dateRangeText:ke=`{from} to {to}`,...M}=c;re(`AppFilterBar`,M),d(`AppFilterBar`,`size`,C,me);let N=C===`md`,Ae={range:ke,from:De,until:Oe},P=ce(de,fe,()=>!1),F=p(null),I=p(null),je=e=>{let t=F.current,n=I.current;t&&n&&(e.preventDefault(),t.open=!t.open,n.classList.remove(`wui-filter-more-panel-end`),t.open&&n.getBoundingClientRect().right>window.innerWidth-8&&n.classList.add(`wui-filter-more-panel-end`))},L=oe(),[R,z]=se({}),B=p(u);for(let e of l)d(`AppFilterBar`,`facets[].type`,e.type,pe);for(let e of l)e.allLabel!=null&&e.type!==`enum`&&ye(e.key),e.required&&e.type!==`enum`&&be(e.key),e.required&&e.allLabel!=null&&xe(e.key),e.presets!=null&&e.type!==`dateRange`&&Se(e.key),e.options?.some(e=>e.count!=null||e.icon!=null)&&!we(e)&&Ce(e.key);let V=l.filter(e=>!ge(e)),H=V.flatMap(e=>ve(e,u[e.key],Ae).map(t=>({...t,facet:e}))),U=V.filter(e=>!e.required&&t(e,u[e.key])),W=x||P?0:Math.max(0,y),G=V.slice(W),Me=G.filter(e=>U.includes(e)).length,K=!x&&G.length>0;f(()=>{if(!K)return;let e=e=>{let t=F.current;t?.open&&(e.type===`keydown`?e instanceof KeyboardEvent&&e.key===`Escape`:!e.composedPath().includes(t))&&(t.open=!1)};return document.addEventListener(`click`,e),document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`click`,e),document.removeEventListener(`keydown`,e)}},[K]),f(()=>{let e=B.current;B.current=u,z(t=>{let n=Object.entries(t).filter(([t])=>_e(e[t],u[t]));return n.length===Object.keys(t).length?t:Object.fromEntries(n)})},[u]);let q=e=>S&&!x&&(e.type===`text`||e.type===`dateRange`),J=e=>q(e)&&Object.hasOwn(R,e.key)?R[e.key]:u[e.key],Y=e=>t=>q(e)?z(n=>({...n,[e.key]:t})):g(e.key,t),X=e=>{let t=Object.entries(e);if(t.length!==0){if(v)v(e);else for(let[e,n]of t)g(e,n)}},Z=()=>{X(R),z({})},Ne=e=>{ie(e.nativeEvent)&&Z()},Pe=e=>{e.preventDefault(),Z()},Q=(e,t)=>e.type===`text`&&q(e)?/* @__PURE__ */ m(`span`,{onKeyDownCapture:Ne,children:t}):t,Fe=(e,t)=>b?/* @__PURE__ */ h(`div`,{className:`wui-filter-popover-field wui-filter-facet`,children:[/* @__PURE__ */ m(`span`,{className:`label`,"aria-hidden":`true`,children:e.label}),t]},e.key):t,Ie=e=>Fe(e,/* @__PURE__ */ m(ae,{children:Q(e,/* @__PURE__ */ m(A,{facet:e,value:J(e),onChange:Y(e),medium:N,anyLabel:j}))},e.key)),$=e=>/* @__PURE__ */ h(`div`,{className:`wui-filter-popover-field`,children:[/* @__PURE__ */ m(`span`,{className:`label`,"aria-hidden":`true`,children:e.label}),Q(e,/* @__PURE__ */ m(A,{facet:e,value:J(e),onChange:Y(e),floating:!0,medium:N,anyLabel:j}))]},e.key),Le=(e,t)=>t>0&&/* @__PURE__ */ m(`span`,{className:e,children:` (${t})`}),Re=e=>/* @__PURE__ */ m(ee,{size:`sm`,label:`${e.facet.label}: ${e.text}`,removeLabel:r(Ee,{facet:e.facet.label,value:e.text}),onRemove:()=>g(e.facet.key,e.clear()),className:!x&&V.indexOf(e.facet)<W?`wui-filter-chip-inline`:void 0},e.id),ze=/* @__PURE__ */ m(o,{variant:`ghost`,size:N?void 0:`sm`,onClick:()=>{X(Object.fromEntries(U.map(t=>[t.key,e(t)]))),z({})},children:T});if(x){let e=H.slice(_),t=U.length;return/* @__PURE__ */ h(`div`,{className:`wui-filter-bar d-flex flex-wrap align-items-center gap-2${w?` ${w}`:``}`,...s,...M,children:[/* @__PURE__ */ h(`wui-filter-popover`,{class:`wui-filter-popover`,children:[/* @__PURE__ */ h(o,{variant:t>0?`outline`:`ghost`,size:N?void 0:`sm`,leftIcon:`filter`,className:`wui-filter-popover-trigger`,"aria-expanded":`false`,"aria-controls":L,"aria-label":t>0?r(D,{count:t}):void 0,children:[E,t>0&&/* @__PURE__ */ m(`span`,{className:`badge rounded-pill text-bg-primary ms-1`,children:t})]}),/* @__PURE__ */ h(`div`,{id:L,className:`wui-filter-popover-panel`,popover:`auto`,role:`dialog`,"aria-label":E,children:[/* @__PURE__ */ h(`div`,{className:`wui-filter-popover-head`,children:[/* @__PURE__ */ m(`span`,{className:`wui-filter-popover-title`,children:E}),/* @__PURE__ */ m(ne,{label:O,id:`${L}-pin`})]}),/* @__PURE__ */ m(`div`,{className:`wui-filter-popover-grid`,children:V.map($)}),/* @__PURE__ */ h(`div`,{className:`wui-filter-popover-foot`,children:[/* @__PURE__ */ m(`span`,{className:`wui-filter-popover-note`,children:k}),t>0&&ze]})]})]}),H.slice(0,_).map(Re),e.length>0&&/* @__PURE__ */ h(`span`,{className:`chip chip-sm wui-filter-popover-more`,title:e.map(e=>`${e.facet.label}: ${e.text}`).join(`, `),children:[`+`,e.length]})]})}let Be=`wui-filter-bar d-flex flex-wrap align-items-center gap-2${P&&K?` wui-filter-bar--folded`:``}`,Ve=e=>`${e}${w?` ${w}`:``}`,He=/* @__PURE__ */ h(le,{children:[V.slice(0,W).map(Ie),K&&/* @__PURE__ */ h(`details`,{ref:F,className:`wui-filter-more`,children:[/* @__PURE__ */ h(`summary`,{className:`btn btn-outline-primary${N?``:` btn-sm`} wui-filter-more-trigger`,onClick:je,children:[/* @__PURE__ */ m(te,{name:`filter`,size:14,className:`me-2`}),E,Le(`wui-filter-count-desktop`,Me),Le(`wui-filter-count-phone`,U.length)]}),/* @__PURE__ */ h(`div`,{ref:I,className:`wui-filter-more-panel`,children:[/* @__PURE__ */ m(`div`,{className:`wui-filter-more-head`,children:E}),G.map($)]})]}),H.map(Re),U.length>0&&ze]});return!S||!V.some(e=>e.type===`text`||e.type===`dateRange`)?/* @__PURE__ */ m(`div`,{className:Ve(Be),...s,...M,children:He}):/* @__PURE__ */ h(`div`,{className:Ve(`wui-filter-form d-flex flex-wrap align-items-center gap-2`),...s,...M,children:[/* @__PURE__ */ m(`div`,{className:Be,children:He}),/* @__PURE__ */ m(o,{type:`submit`,size:N?void 0:`sm`,onClick:Pe,children:Te})]})}function A({facet:e,value:t,onChange:n,floating:r=!1,medium:i=!1,anyLabel:a}){if(e.type===`enum`){let o=e.options??[];return(e.required?o.length<=v:o.length<v)?/* @__PURE__ */ m(l,{label:e.label,name:e.key,size:i?`md`:`sm`,value:x(e,t),onChange:n,options:e.required?o:[{value:``,label:e.allLabel||`All`},...o]}):/* @__PURE__ */ m(u,{"aria-label":e.label,name:e.key,placeholder:r?a:e.label,clearable:!e.required,size:i?void 0:`sm`,value:x(e,t),onChange:n,options:o})}return e.type===`multiEnum`?/* @__PURE__ */ m(u,{mode:`multiple`,"aria-label":e.label,name:e.key,placeholder:r?a:e.label,size:i?void 0:`sm`,collapseChips:!0,value:S(e,t),onChange:n,options:e.options??[]}):e.type===`dateRange`?/* @__PURE__ */ m(s,{ariaLabel:e.label,startName:`${e.key}From`,endName:`${e.key}To`,placeholder:r?a:e.label,size:i?void 0:`sm`,presets:e.presets,start:C(e,t).from,end:C(e,t).to,onChange:e=>n({from:e.start??``,to:e.end??``})}):/* @__PURE__ */ m(c,{ariaLabel:e.label,name:e.key,placeholder:e.label,size:i?void 0:`sm`,value:x(e,t),onChange:n})}export{k as default};
1
+ import{emptyFacetValue as e,isFacetActive as t}from"../web-core/dist/query/listQuery.js";import{devWarn as n}from"../lib/devWarn.js";import r from"../lib/useElementEntry.js";import i from"../lib/useWuiText.js";import{splitMarkerProps as a}from"../lib/wuiMarker.js";import o from"./AppButton.js";import s from"./AppChip.js";import c from"./AppDateRangePicker.js";import ee from"./AppIcon.js";import l from"./AppSearch.js";import te from"./AppSegmented.js";import u from"./AppSelect.js";import ne from"./AppSwitch.js";import d from"./assertValidValue.js";import re from"./warnUnknownProps.js";import{isImeSafeEnter as ie}from"@webority/ui-elements/helpers";import{Fragment as ae,useEffect as f,useId as oe,useRef as p,useState as se,useSyncExternalStore as ce}from"react";import{Fragment as le,jsx as m,jsxs as h}from"react/jsx-runtime";import{FILTER_BAR_TEXT as g,fillText as _}from"@webority/ui-elements/text";var v=`(max-width: 575.98px)`,ue=3,y=2,de=e=>{let t=window.matchMedia?.(v);return t?.addEventListener(`change`,e),()=>t?.removeEventListener(`change`,e)},fe=()=>window.matchMedia?.(v).matches??!1,pe=[`enum`,`multiEnum`,`dateRange`,`text`],me=[`sm`,`md`],he=()=>import(`@webority/ui-elements/elements/filter-popover`),b=4,ge=e=>(e.type===`enum`||e.type===`multiEnum`)&&!e.options?.length,x=(e,t)=>e.options?.find(e=>e.value===t)?.label??t,_e=(e,t)=>JSON.stringify(e)===JSON.stringify(t),S=(e,t,n)=>/* @__PURE__ */ RangeError(`[@webority/ui-react] <AppFilterBar> facet "${e.key}" needs ${t}, received ${JSON.stringify(n)}.`),C=(e,t)=>{if(t==null)return``;if(typeof t==`string`)return t;throw S(e,`a string value`,t)},w=(e,t)=>{if(t==null)return[];if(Array.isArray(t)&&t.every(e=>typeof e==`string`))return t;throw S(e,`an array of strings`,t)},T=(e,t)=>{if(t==null)return{from:``,to:``};if(typeof t==`object`&&!Array.isArray(t)&&!(t instanceof Date)){let{from:e,to:n}=t;if((e===void 0||typeof e==`string`)&&(n===void 0||typeof n==`string`))return{from:e,to:n}}throw S(e,`a { from, to } date range`,t)};function ve(n,r,i){if(n.required||!t(n,r))return[];if(n.type===`enum`)return[{id:n.key,text:x(n,C(n,r)),clear:()=>e(n)}];if(n.type===`multiEnum`){let e=w(n,r);return e.map(t=>({id:`${n.key}:${t}`,text:x(n,t),clear:()=>e.filter(e=>e!==t)}))}if(n.type===`dateRange`){let t=T(n,r),a=t.from&&t.to?_(i.range,{from:t.from,to:t.to}):t.from?_(i.from,{date:t.from}):_(i.until,{date:t.to??``});return[{id:n.key,text:a,clear:()=>e(n)}]}return[]}var E=/* @__PURE__ */ new Set;function ye(e){let t=!0;try{t=process.env.NODE_ENV!==`production`}catch{t=!0}t&&!E.has(e)&&(E.add(e),n(`[@webority/ui-react] <AppFilterBar> facet "${e}" sets allLabel, which only an enum facet uses.`))}var D=/* @__PURE__ */ new Set;function be(e){let t=!0;try{t=process.env.NODE_ENV!==`production`}catch{t=!0}t&&!D.has(e)&&(D.add(e),n(`[@webority/ui-react] <AppFilterBar> facet "${e}" sets required, which only an enum facet uses.`))}var O=/* @__PURE__ */ new Set;function xe(e){let t=!0;try{t=process.env.NODE_ENV!==`production`}catch{t=!0}t&&!O.has(e)&&(O.add(e),n(`[@webority/ui-react] <AppFilterBar> facet "${e}" sets allLabel and required; a required facet has no All segment.`))}var k=/* @__PURE__ */ new Set;function Se(e){let t=!0;try{t=process.env.NODE_ENV!==`production`}catch{t=!0}t&&!k.has(e)&&(k.add(e),n(`[@webority/ui-react] <AppFilterBar> facet "${e}" sets presets, which only a dateRange facet uses.`))}var A=/* @__PURE__ */ new Set;function Ce(e){let t=!0;try{t=process.env.NODE_ENV!==`production`}catch{t=!0}t&&!A.has(e)&&(A.add(e),n(`[@webority/ui-react] <AppFilterBar> facet "${e}" sets count or icon on an option, which only an enum facet drawn as segments shows.`))}var we=e=>{let t=e.options?.length??0;return e.type===`enum`&&(e.required?t<=b:t<b)};function j(n){r(`wui-filter-popover`,he);let c=i(`filterBar`,g),{marker:l,props:te}=a(`AppFilterBar`,n),{facets:u,value:v,onChange:b,onChangeMany:x,inline:S=ue,facetLabels:C=!1,floating:w=!1,apply:T=!1,size:E=`sm`,className:D=``,clearAllLabel:O=c.clearAllLabel,filtersLabel:k=c.filtersLabel,filtersActiveLabel:A=c.filtersActiveLabel,keepOpenLabel:j=c.keepOpenLabel,appliesAtOnceText:Te=c.appliesAtOnceText,applyLabel:Ee=c.applyLabel,anyLabel:N=c.anyLabel,removeChipLabel:De=c.removeChipLabel,dateFromText:Oe=c.dateFromText,dateUntilText:ke=c.dateUntilText,dateRangeText:Ae=c.dateRangeText,...P}=te;re(`AppFilterBar`,P),d(`AppFilterBar`,`size`,E,me);let F=E===`md`,je={range:Ae,from:Oe,until:ke},I=ce(de,fe,()=>!1),L=p(null),R=p(null),Me=e=>{let t=L.current,n=R.current;t&&n&&(e.preventDefault(),t.open=!t.open,n.classList.remove(`wui-filter-more-panel-end`),t.open&&n.getBoundingClientRect().right>window.innerWidth-8&&n.classList.add(`wui-filter-more-panel-end`))},z=oe(),[B,V]=se({}),H=p(v);for(let e of u)d(`AppFilterBar`,`facets[].type`,e.type,pe);for(let e of u)e.allLabel!=null&&e.type!==`enum`&&ye(e.key),e.required&&e.type!==`enum`&&be(e.key),e.required&&e.allLabel!=null&&xe(e.key),e.presets!=null&&e.type!==`dateRange`&&Se(e.key),e.options?.some(e=>e.count!=null||e.icon!=null)&&!we(e)&&Ce(e.key);let U=u.filter(e=>!ge(e)),W=U.flatMap(e=>ve(e,v[e.key],je).map(t=>({...t,facet:e}))),G=U.filter(e=>!e.required&&t(e,v[e.key])),K=w||I?0:Math.max(0,S),q=U.slice(K),Ne=q.filter(e=>G.includes(e)).length,J=!w&&q.length>0;f(()=>{if(!J)return;let e=e=>{let t=L.current;t?.open&&(e.type===`keydown`?e instanceof KeyboardEvent&&e.key===`Escape`:!e.composedPath().includes(t))&&(t.open=!1)};return document.addEventListener(`click`,e),document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`click`,e),document.removeEventListener(`keydown`,e)}},[J]),f(()=>{let e=H.current;H.current=v,V(t=>{let n=Object.entries(t).filter(([t])=>_e(e[t],v[t]));return n.length===Object.keys(t).length?t:Object.fromEntries(n)})},[v]);let Y=e=>T&&!w&&(e.type===`text`||e.type===`dateRange`),X=e=>Y(e)&&Object.hasOwn(B,e.key)?B[e.key]:v[e.key],Z=e=>t=>Y(e)?V(n=>({...n,[e.key]:t})):b(e.key,t),Q=e=>{let t=Object.entries(e);if(t.length!==0){if(x)x(e);else for(let[e,n]of t)b(e,n)}},$=()=>{Q(B),V({})},Pe=e=>{ie(e.nativeEvent)&&$()},Fe=e=>{e.preventDefault(),$()},Ie=(e,t)=>e.type===`text`&&Y(e)?/* @__PURE__ */ m(`span`,{onKeyDownCapture:Pe,children:t}):t,Le=(e,t)=>C?/* @__PURE__ */ h(`div`,{className:`wui-filter-popover-field wui-filter-facet`,children:[/* @__PURE__ */ m(`span`,{className:`label`,"aria-hidden":`true`,children:e.label}),t]},e.key):t,Re=e=>Le(e,/* @__PURE__ */ m(ae,{children:Ie(e,/* @__PURE__ */ m(M,{facet:e,value:X(e),onChange:Z(e),medium:F,anyLabel:N}))},e.key)),ze=e=>/* @__PURE__ */ h(`div`,{className:`wui-filter-popover-field`,children:[/* @__PURE__ */ m(`span`,{className:`label`,"aria-hidden":`true`,children:e.label}),Ie(e,/* @__PURE__ */ m(M,{facet:e,value:X(e),onChange:Z(e),floating:!0,medium:F,anyLabel:N}))]},e.key),Be=(e,t)=>t>0&&/* @__PURE__ */ m(`span`,{className:e,children:` (${t})`}),Ve=e=>/* @__PURE__ */ m(s,{size:`sm`,label:`${e.facet.label}: ${e.text}`,removeLabel:_(De,{facet:e.facet.label,value:e.text}),onRemove:()=>b(e.facet.key,e.clear()),className:!w&&U.indexOf(e.facet)<K?`wui-filter-chip-inline`:void 0},e.id),He=/* @__PURE__ */ m(o,{variant:`ghost`,size:F?void 0:`sm`,onClick:()=>{Q(Object.fromEntries(G.map(t=>[t.key,e(t)]))),V({})},children:O});if(w){let e=W.slice(y),t=G.length;return/* @__PURE__ */ h(`div`,{className:`wui-filter-bar d-flex flex-wrap align-items-center gap-2${D?` ${D}`:``}`,...l,...P,children:[/* @__PURE__ */ h(`wui-filter-popover`,{class:`wui-filter-popover`,children:[/* @__PURE__ */ h(o,{variant:t>0?`outline`:`ghost`,size:F?void 0:`sm`,leftIcon:`filter`,className:`wui-filter-popover-trigger`,"aria-expanded":`false`,"aria-controls":z,"aria-label":t>0?_(A,{count:t}):void 0,children:[k,t>0&&/* @__PURE__ */ m(`span`,{className:`badge rounded-pill text-bg-primary ms-1`,children:t})]}),/* @__PURE__ */ h(`div`,{id:z,className:`wui-filter-popover-panel`,popover:`auto`,role:`dialog`,"aria-label":k,children:[/* @__PURE__ */ h(`div`,{className:`wui-filter-popover-head`,children:[/* @__PURE__ */ m(`span`,{className:`wui-filter-popover-title`,children:k}),/* @__PURE__ */ m(ne,{label:j,id:`${z}-pin`})]}),/* @__PURE__ */ m(`div`,{className:`wui-filter-popover-grid`,children:U.map(ze)}),/* @__PURE__ */ h(`div`,{className:`wui-filter-popover-foot`,children:[/* @__PURE__ */ m(`span`,{className:`wui-filter-popover-note`,children:Te}),t>0&&He]})]})]}),W.slice(0,y).map(Ve),e.length>0&&/* @__PURE__ */ h(`span`,{className:`chip chip-sm wui-filter-popover-more`,title:e.map(e=>`${e.facet.label}: ${e.text}`).join(`, `),children:[`+`,e.length]})]})}let Ue=`wui-filter-bar d-flex flex-wrap align-items-center gap-2${I&&J?` wui-filter-bar--folded`:``}`,We=e=>`${e}${D?` ${D}`:``}`,Ge=/* @__PURE__ */ h(le,{children:[U.slice(0,K).map(Re),J&&/* @__PURE__ */ h(`details`,{ref:L,className:`wui-filter-more`,children:[/* @__PURE__ */ h(`summary`,{className:`btn btn-outline-primary${F?``:` btn-sm`} wui-filter-more-trigger`,onClick:Me,children:[/* @__PURE__ */ m(ee,{name:`filter`,size:14,className:`me-2`}),k,Be(`wui-filter-count-desktop`,Ne),Be(`wui-filter-count-phone`,G.length)]}),/* @__PURE__ */ h(`div`,{ref:R,className:`wui-filter-more-panel`,children:[/* @__PURE__ */ m(`div`,{className:`wui-filter-more-head`,children:k}),q.map(ze)]})]}),W.map(Ve),G.length>0&&He]});return!T||!U.some(e=>e.type===`text`||e.type===`dateRange`)?/* @__PURE__ */ m(`div`,{className:We(Ue),...l,...P,children:Ge}):/* @__PURE__ */ h(`div`,{className:We(`wui-filter-form d-flex flex-wrap align-items-center gap-2`),...l,...P,children:[/* @__PURE__ */ m(`div`,{className:Ue,children:Ge}),/* @__PURE__ */ m(o,{type:`submit`,size:F?void 0:`sm`,onClick:Fe,children:Ee})]})}function M({facet:e,value:t,onChange:n,floating:r=!1,medium:a=!1,anyLabel:o}){let s=i(`filterBar`,g);if(e.type===`enum`){let i=e.options??[];return(e.required?i.length<=b:i.length<b)?/* @__PURE__ */ m(te,{label:e.label,name:e.key,size:a?`md`:`sm`,value:C(e,t),onChange:n,options:e.required?i:[{value:``,label:e.allLabel||s.allLabel},...i]}):/* @__PURE__ */ m(u,{"aria-label":e.label,name:e.key,placeholder:r?o:e.label,clearable:!e.required,size:a?void 0:`sm`,value:C(e,t),onChange:n,options:i})}return e.type===`multiEnum`?/* @__PURE__ */ m(u,{mode:`multiple`,"aria-label":e.label,name:e.key,placeholder:r?o:e.label,size:a?void 0:`sm`,collapseChips:!0,value:w(e,t),onChange:n,options:e.options??[]}):e.type===`dateRange`?/* @__PURE__ */ m(c,{ariaLabel:e.label,startName:`${e.key}From`,endName:`${e.key}To`,placeholder:r?o:e.label,size:a?void 0:`sm`,presets:e.presets,start:T(e,t).from,end:T(e,t).to,onChange:e=>n({from:e.start??``,to:e.end??``})}):/* @__PURE__ */ m(l,{ariaLabel:e.label,name:e.key,placeholder:e.label,size:a?void 0:`sm`,value:C(e,t),onChange:n})}export{j 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{splitMarkerProps as r}from"../lib/wuiMarker.js";import i from"./renderIconProp.js";import a from"./warnUnknownProps.js";import{Fragment as o,jsx as s,jsxs as c}from"react/jsx-runtime";var l=()=>import(`@webority/ui-elements/elements/dock`);function u(u){n(`wui-dock`,l);let{marker:d,props:f}=r(`AppFloatingDock`,u),{items:p=[],linkComponent:m,ariaLabel:h=`Quick navigation`,magnify:g=!0,maxScale:_,radius:v,className:y=``,...b}=f;return a(`AppFloatingDock`,b),/* @__PURE__ */ s(`wui-dock`,{role:`navigation`,"aria-label":h,static:g?void 0:``,"max-scale":_??void 0,radius:v??void 0,class:y||void 0,...d,...b,children:p.map((n,r)=>{let a=n.key??`${n.title}-${r}`,l=/* @__PURE__ */ c(o,{children:[/* @__PURE__ */ s(`span`,{className:`dock-item-tip`,"aria-hidden":`true`,children:n.title}),/* @__PURE__ */ s(`span`,{className:`dock-item-icon`,children:i(n.icon,{size:18})})]});if(n.to&&m){let r=e(m,{to:n.to});return/* @__PURE__ */ s(t,{link:r,className:`dock-item`,"aria-label":n.title,children:l},a)}let u=n.href??n.to;return u?/* @__PURE__ */ s(`a`,{className:`dock-item`,href:u,"aria-label":n.title,children:l},a):/* @__PURE__ */ s(`button`,{type:`button`,className:`dock-item`,onClick:n.onClick,"aria-label":n.title,children:l},a)})})}export{u 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,jsx as c,jsxs as l}from"react/jsx-runtime";import{FLOATING_DOCK_TEXT as u}from"@webority/ui-elements/text";var d=()=>import(`@webority/ui-elements/elements/dock`);function f(f){n(`wui-dock`,d);let{marker:p,props:m}=i(`AppFloatingDock`,f),h=r(`floatingDock`,u),{items:g=[],linkComponent:_,ariaLabel:v=h.ariaLabel,magnify:y=!0,maxScale:b,radius:x,className:S=``,...C}=m;return o(`AppFloatingDock`,C),/* @__PURE__ */ c(`wui-dock`,{role:`navigation`,"aria-label":v,static:y?void 0:``,"max-scale":b??void 0,radius:x??void 0,class:S||void 0,...p,...C,children:g.map((n,r)=>{let i=n.key??`${n.title}-${r}`,o=/* @__PURE__ */ l(s,{children:[/* @__PURE__ */ c(`span`,{className:`dock-item-tip`,"aria-hidden":`true`,children:n.title}),/* @__PURE__ */ c(`span`,{className:`dock-item-icon`,children:a(n.icon,{size:18})})]});if(n.to&&_){let r=e(_,{to:n.to});return/* @__PURE__ */ c(t,{link:r,className:`dock-item`,"aria-label":n.title,children:o},i)}let u=n.href??n.to;return u?/* @__PURE__ */ c(`a`,{className:`dock-item`,href:u,"aria-label":n.title,children:o},i):/* @__PURE__ */ c(`button`,{type:`button`,className:`dock-item`,onClick:n.onClick,"aria-label":n.title,children:o},i)})})}export{f 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{UNSAVED_TEXT as i}from"../lib/unsavedText.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";var v=l(null);function y(){let e=d(v);if(e===null)throw Error(`useFormSubmit must be called inside an AppForm`);return e}var b=/* @__PURE__ */ new Set,x=/* @__PURE__ */ new Map;function S(l){let{marker:d,props:y}=a(`AppForm`,l),{onSubmit:S,onChange:C,className:w,children:T,noValidate:E,action:D,method:O,encType:k,acceptCharset:A,fieldErrors:j,formErrors:M,unsavedChanges:N,unsavedChangesMessage:ee,...P}=y;c(`AppForm`,P);let[F,I]=h(!1),[L,R]=h(e),z=m(!1),[B,V]=h(null),H=p(()=>new Map(Object.entries(j??{}).map(([e,t])=>[r(e),t])),[j]),U=JSON.stringify([...H].sort(([e],[t])=>e<t?-1:+(e>t))),[W,G]=h({key:U,names:b}),K=W.key===U?W.names:b,q=u(e=>{C?.(e);let t=e.target;if(!(t instanceof HTMLElement)||!(`name`in t)||typeof t.name!=`string`||t.name===``)return;let n=r(t.name);H.has(n)&&G(e=>{let t=e.key===U?e.names:b;return t.has(n)?e:{key:U,names:/* @__PURE__ */ new Set([...t,n])}})},[C,H,U]),[J,Y]=h(x),X=u(e=>(Y(t=>new Map(t).set(e,(t.get(e)??0)+1)),()=>{Y(t=>{let n=new Map(t),r=(t.get(e)??0)-1;return r>0?n.set(e,r):n.delete(e),n})}),[]),Z=u(e=>K.has(e)?void 0:H.get(e),[K,H]),Q=p(()=>({errorOf:Z,claim:X}),[Z,X]),$=[.../* @__PURE__ */ new Set([...M??[],...[...H].filter(([e])=>!J.has(e)).map(([,e])=>e)])],te=u(async t=>{if(t.preventDefault(),z.current)return;z.current=!0,I(!0);let n=t.currentTarget;try{await S(t,{idempotencyKey:L})?R(e()):V({form:n})}finally{z.current=!1,I(!1)}},[S,L]);f(()=>{if(B===null)return;let{form:e}=B;if(V(null),e.querySelector(`.wui-error-summary`)!==null)return;let n=[...e.querySelectorAll(`[name]`)].map(e=>e.getAttribute(`name`)).find(e=>e!==null&&H.has(r(e)));n!==void 0&&t(n)},[B,H]);let ne=p(()=>({submitting:F,idempotencyKey:L}),[F,L]);return/* @__PURE__ */ g(n.Provider,{value:Q,children:/* @__PURE__ */ _(v.Provider,{value:ne,children:[/* @__PURE__ */ _(`form`,{...d,...P,noValidate:E,action:D,method:O,encType:k,acceptCharset:A,className:w,onChange:q,onSubmit:te,"aria-busy":F||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,T]}),N?.blocked?/* @__PURE__ */ g(o,{open:!0,title:i.title,description:ee??i.message,confirmLabel:i.leaveLabel,onConfirm:N.discard,onClose:N.keep}):null]})})}export{v as FormSubmitContext,S as default,y 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{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 +1 @@
1
- import{splitMarkerProps as e}from"../lib/wuiMarker.js";import t from"./assertValidValue.js";import n from"./warnUnknownProps.js";import{jsx as r,jsxs as i}from"react/jsx-runtime";var a=[`plus`,`minus`,`times`,`divide`,`equal`],o={plus:`+`,minus:`−`,times:`×`,divide:`÷`,equal:`=`};function s(s){let{marker:c,props:l}=e(`AppFormulaSteps`,s),{steps:u=[],label:d=`Calculation`,plusLabel:f=`plus`,minusLabel:p=`minus`,timesLabel:m=`times`,divideLabel:h=`divided by`,equalLabel:g=`equals`,className:_=``,...v}=l;n(`AppFormulaSteps`,v);for(let e of u)t(`AppFormulaSteps`,`steps[].sign`,e.sign,a);let y={plus:f,minus:p,times:m,divide:h,equal:g},b=[`wui-formula-steps`,_].filter(Boolean).join(` `);return/* @__PURE__ */ r(`ol`,{className:b,"aria-label":d,...c,...v,children:u.map((e,t)=>/* @__PURE__ */ i(`li`,{className:e.sign===`equal`?`wui-formula-step wui-formula-step-total`:`wui-formula-step`,children:[/* @__PURE__ */ r(`span`,{className:`wui-formula-sign`,"aria-hidden":`true`,children:e.sign?o[e.sign]:null}),e.sign?/* @__PURE__ */ r(`span`,{className:`visually-hidden`,children:`${y[e.sign]} `}):null,/* @__PURE__ */ r(`span`,{className:`wui-formula-label`,children:e.label}),e.working?/* @__PURE__ */ r(`span`,{className:`wui-formula-working`,children:e.working}):null,/* @__PURE__ */ r(`span`,{className:`wui-formula-result`,children:e.result}),e.note?/* @__PURE__ */ r(`span`,{className:`wui-formula-note`,children:e.note}):null]},e.key??`${e.label}-${t}`))})}export{s as default};
1
+ import e from"../lib/useWuiText.js";import{splitMarkerProps as t}from"../lib/wuiMarker.js";import n from"./assertValidValue.js";import r from"./warnUnknownProps.js";import{jsx as i,jsxs as a}from"react/jsx-runtime";import{FORMULA_STEPS_TEXT as o}from"@webority/ui-elements/text";var s=[`plus`,`minus`,`times`,`divide`,`equal`],c={plus:`+`,minus:`−`,times:`×`,divide:`÷`,equal:`=`};function l(l){let u=e(`formulaSteps`,o),{marker:d,props:f}=t(`AppFormulaSteps`,l),{steps:p=[],label:m=u.label,plusLabel:h=u.plusLabel,minusLabel:g=u.minusLabel,timesLabel:_=u.timesLabel,divideLabel:v=u.divideLabel,equalLabel:y=u.equalLabel,className:b=``,...x}=f;r(`AppFormulaSteps`,x);for(let e of p)n(`AppFormulaSteps`,`steps[].sign`,e.sign,s);let S={plus:h,minus:g,times:_,divide:v,equal:y},C=[`wui-formula-steps`,b].filter(Boolean).join(` `);return/* @__PURE__ */ i(`ol`,{className:C,"aria-label":m,...d,...x,children:p.map((e,t)=>/* @__PURE__ */ a(`li`,{className:e.sign===`equal`?`wui-formula-step wui-formula-step-total`:`wui-formula-step`,children:[/* @__PURE__ */ i(`span`,{className:`wui-formula-sign`,"aria-hidden":`true`,children:e.sign?c[e.sign]:null}),e.sign?/* @__PURE__ */ i(`span`,{className:`visually-hidden`,children:`${S[e.sign]} `}):null,/* @__PURE__ */ i(`span`,{className:`wui-formula-label`,children:e.label}),e.working?/* @__PURE__ */ i(`span`,{className:`wui-formula-working`,children:e.working}):null,/* @__PURE__ */ i(`span`,{className:`wui-formula-result`,children:e.result}),e.note?/* @__PURE__ */ i(`span`,{className:`wui-formula-note`,children:e.note}):null]},e.key??`${e.label}-${t}`))})}export{l as default};