@webority/ui-react 0.169.1 → 0.170.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.
- package/dist/canvas-kit/kit.js +138 -135
- package/dist/canvas-kit/manifest.json +541 -15
- package/dist/canvas-kit/release.json +6 -6
- package/dist/components/AppDataTable.js +1 -1
- package/dist/components/AppFilterBar.js +1 -1
- package/dist/components/AppMonthPicker.js +1 -0
- package/dist/components/AppSelect.js +1 -1
- package/dist/components/AppSplitView.js +1 -1
- package/dist/components/AppYearPicker.js +1 -0
- package/dist/guidance.json +181 -1
- package/dist/types/components/AppDataTable.d.ts +2 -2
- package/dist/types/components/AppFilterBar.d.ts +2 -0
- package/dist/types/components/AppMonthPicker.d.ts +92 -0
- package/dist/types/components/AppSelect.d.ts +2 -0
- package/dist/types/components/AppYearPicker.d.ts +92 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/ui-react.js +1 -1
- package/package.json +8 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
import{devWarn as e}from"../lib/devWarn.js";import{emptyPlaceholder as t}from"../lib/emptyValue.js";import n from"../lib/useElementEntry.js";import r from"../lib/useWuiText.js";import{splitMarkerProps as i}from"../lib/wuiMarker.js";import a from"./AppButton.js";import o from"./AppEmptyState.js";import s from"./AppIcon.js";import ee from"./AppInfoTip.js";import te from"./AppRowActions.js";import c from"./AppSkeleton.js";import l from"./AppTablePagination.js";import u from"./assertValidValue.js";import d from"./warnUnknownProps.js";import{COLUMN_MAX_WIDTH as f,COLUMN_MIN_WIDTH as ne,PIN_AT_VAR as re,PIN_SIDES as ie,ROW_HEIGHTS as ae,ROW_MOVE_LIMIT as oe,ROW_SAVE_ERROR_CLASS as se,attachRowDrag as ce,attachScrollEdges as le,groupCount as ue,groupItems as de,isImeSafeEnter as fe,measureRows as pe,pinAtValue as me,pinClasses as he,planPins as ge,playRowMoves as _e,rowOrderChanged as ve,saveOutcomeText as ye,settledRows as be,syncTargets as xe,virtualRange as Se}from"@webority/ui-elements/helpers";import{Children as Ce,Fragment as we,isValidElement as Te,useCallback as Ee,useEffect as p,useLayoutEffect as De,useMemo as Oe,useRef as m,useState as h}from"react";import{Fragment as ke,jsx as g,jsxs as _}from"react/jsx-runtime";import{DATA_TABLE_TEXT as Ae,ROW_ACTIONS_TEXT as je,fillText as Me,pluralText as Ne}from"@webority/ui-elements/text";import{FORCED_STATE_CLASSES as Pe}from"@webority/theme/runtime";var Fe=()=>import(`@webority/ui-elements/elements/data-table`),Ie=[`comfortable`,`cozy`,`compact`],Le=[`auto`,`fixed`],Re=[1,2,3,4],ze=e=>typeof e==`number`?`${e}px`:e;function Be(e){let t=e.flatMap(e=>{let t=e.minWidth??e.width;return t===void 0?[]:[ze(t)]});if(t.length!==0)return t.length===1?t[0]:`calc(${t.join(` + `)})`}function v(e,t){return typeof e==`object`&&e?Reflect.get(e,t):void 0}function Ve(e,t){if(e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`||Te(e)||Array.isArray(e))return e;throw Error(`AppDataTable: the value under "${t}" is not renderable; give that column a render function.`)}function He(e,t){return Ve(v(e,t),t)}var Ue=()=>{try{return process.env.NODE_ENV!==`production`}catch{return!0}},y=/* @__PURE__ */ new Set;function b(t,n){!y.has(t)&&Ue()&&(y.add(t),e(`[@webority/ui-react] <AppDataTable> ${n}`))}var We=100,Ge=e=>{let t=typeof e==`object`&&e&&`id`in e?e.id:void 0;return typeof t==`string`||typeof t==`number`?t:void 0},Ke=()=>{},qe=()=>({total:0,keys:[]}),Je=[],Ye=(e,t,n)=>{let r=!!t?.(e),i=r?``:n?.(e)||``;return{state:r?`saving`:i?`error`:null,message:i}};function x(e){return e===`end`?`wui-cell-end`:e===`num`?`num`:e===`center`?`text-center`:``}function Xe(e){return e===`center`?`44%`:e===`end`||e===`num`?`56%`:`60%`}function Ze(e){return e==null||e===``?t():Array.isArray(e)?Ce.toArray(e):typeof e==`boolean`?String(e):e}function Qe(e){if(!e||!(e.total>0))return!1;let t=e.pageSizes?.length?e.pageSizes:[e.pageSize];return e.total>Math.min(...t)}function S(e){n(`wui-data-table`,Fe);let t=r(`dataTable`,Ae),Ce=r(`rowActions`,je),Te=e=>e?Me(t.resizeColumnText,{label:e}):t.resizeColumnLabel,{marker:ze,props:Ue}=i(`AppDataTable`,e),{columns:y,rows:S=Je,rowKey:$e=Ge,sort:et,onSort:tt,loading:C=!1,refreshing:nt=!1,skeletonRows:rt=5,empty:it=t.empty,emptyFiltered:at,error:ot,onRetry:st,sourceCount:ct,rowActions:w,linkComponent:lt,rowActionsLabel:ut,pagination:T,ariaLabel:dt,className:ft=``,wrapperClassName:pt=``,selectable:E=!1,selectedIds:D,isRowSelectable:mt,onToggleRow:ht,onToggleAll:gt,onSelectRange:_t,renderExpanded:vt,singleExpand:yt=!1,density:O=`comfortable`,tableLayout:bt=`auto`,striped:xt=!1,flush:St=!1,pad:Ct,nameLines:k,headerTone:wt,rowDrag:A=!1,maxHeight:Tt,stickyFirstColumn:Et=!1,stickyActions:Dt=!1,equalActions:Ot=!1,linkFirstColumn:kt=!1,stackOnMobile:j=!1,hiddenColumns:At,rowStatus:jt,rowHref:M,onRowClick:Mt,activeRowKey:Nt,hoverRowKey:Pt,resizableColumns:N=!1,viewKey:Ft,groupBy:P,groupLabel:It,virtual:F=!1,rowSaving:I,rowSaveError:L,...Lt}=Ue;d(`AppDataTable`,Lt);let{style:Rt,...zt}=Lt,R=Ee((e,t)=>{let n=$e(e,t);if(n==null)throw Error(`AppDataTable: a row has no key. Pass rowKey, or give every row an id.`);return n},[$e]),Bt=At?.length?new Set(At):null;y=Bt?y.filter(e=>!(e.hideable&&Bt.has(e.key))):y,u(`AppDataTable`,`density`,O,Ie),u(`AppDataTable`,`tableLayout`,bt,Le),u(`AppDataTable`,`nameLines`,k,Re);for(let e of y)u(`AppDataTable`,`column.pin`,e.pin,ie);let z=typeof M==`function`||typeof Mt==`function`,Vt=[`table table-ledger`,O===`cozy`||O===`compact`?`wui-table-${O}`:``,xt?`wui-table-striped`:``,Et?`wui-table-sticky-first`:``,Dt?`wui-table-sticky-actions`:``,Ot?`wui-table-equal-actions`:``,j?`wui-table-stack`:``,kt&&z?`wui-table-link-first`:``,ft].filter(Boolean).join(` `),B=typeof vt==`function`,[Ht,Ut]=h(()=>/* @__PURE__ */ new Set),Wt=e=>Ut(t=>{if(t.has(e)){let n=new Set(t);return n.delete(e),n}return yt?/* @__PURE__ */ new Set([e]):new Set(t).add(e)}),Gt=y.some(e=>typeof e.footer==`function`),Kt=e=>!!(e.target instanceof Element&&e.target.closest(`a, button, input, select, textarea, label, [role='menu'], [role='menuitem'], .dropdown`)),qt=(e,t)=>{if(Kt(t)||(Mt&&Mt(e),!M))return;let n=M(e);n&&(t.ctrlKey||t.metaKey||t.button===1?window.open(n,`_blank`,`noopener`):window.location.assign(n))},V=Tt!==void 0,Jt=nt&&!C&&S.length>0,Yt=[`table-wrap`,V?`wui-table-scroll`:``,St?`wui-table-flush`:``,Jt?`wui-table-refreshing`:``,pt].filter(Boolean).join(` `),Xt={maxHeight:V?Tt:void 0,"--wui-table-pad":Ct!=null&&!St?`${Ct}px`:void 0,"--wui-name-lines":F?`1`:k?.toString(),"--wui-table-header-bg":wt??void 0},Zt=Object.values(Xt).some(e=>e!==void 0)||Rt!==void 0?{...Xt,...Rt}:void 0,Qt=Math.max(1,y.length+ +!!w+ +!!E+ +!!B),$t=y.some(e=>e.pin===`start`||e.pin===`end`),en=$t||N||!!P||F,H=+!!B+ +!!E,tn=$t?ge([...B?[`lead`]:[],...E?[`lead`]:[],...y.map(e=>e.pin===`start`||e.pin===`end`?e.pin:null),...w?[null]:[]]):[],U=(e,t=``)=>{let n=tn[e];return n?{className:`${t.trim()} ${he(n)}`.trim(),style:{[re]:me(n.side,n.ordinal)}}:{className:t,style:void 0}},nn=(e,t)=>tn[e]?{...t,...U(e).style}:t,rn=y.length-1+ +!!w;Ft&&!N&&b(`view-key`,"`viewKey` remembers resized widths: add `resizableColumns`."),F&&!V&&b(`virtual-height`,"`virtual` needs `maxHeight`: without a scroll box every row renders."),F&&(B||j)&&b(`virtual-shape`,"`virtual` takes rows of one height, so it is off with `renderExpanded` or `stackOnMobile`."),F&&k!==void 0&&k!==1&&b(`virtual-name-lines`,"`nameLines` is ignored with `virtual`: a virtual table shows one line per name."),kt&&!z&&b(`link-first-column`,"`linkFirstColumn` needs rowHref or onRowClick: the row is what opens."),yt&&typeof vt!=`function`&&b(`single-expand`,"`singleExpand` needs renderExpanded: there are no rows to expand."),!F&&S?.length>500&&b(`rows-without-virtual`,`renders more than 500 rows without virtual: add virtual with maxHeight, or page the data.`);let W=F&&V&&!B&&!j&&!C&&S?.length>0,G=(e,t)=>!mt||!!mt(e,t),an=E&&S?S.reduce((e,t,n)=>e+ +!!G(t,n),0):0,K=E&&S?S.reduce((e,t,n)=>e+(G(t,n)&&D?.has(R(t,n))?1:0),0):0,on=an>0&&K===an,sn=K>0&&!on,cn=e=>{e&&(e.indeterminate=sn)},ln=m(null),un=(e,t)=>{let n=ln.current;ln.current=e;let r=t&&n!==null?S.findIndex((e,t)=>R(e,t)===n):-1,i=S.findIndex((t,n)=>R(t,n)===e);if(r<0||i<0||r===i){ht?.(e);return}let a=!D?.has(e),o=Math.min(r,i),s=S.slice(o,Math.max(r,i)+1).map((e,t)=>[e,o+t]).filter(([e,t])=>G(e,t)).map(([e,t])=>R(e,t)).filter(e=>(D?.has(e)||!1)!==a);if(_t)_t(s,a);else for(let e of s)ht?.(e)},dn=e=>{mt?(S||[]).forEach((t,n)=>{let r=R(t,n);G(t,n)&&(D?.has(r)||!1)!==e&&ht?.(r)}):gt?.(e)},[fn,pn]=h(()=>/* @__PURE__ */ new Set),mn=e=>pn(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),q=Oe(()=>{let e=(S||[]).map((e,t)=>({row:e,i:t}));return P?de(e,({row:e})=>String(v(e,P)??``)).flatMap(e=>[{group:e,open:!fn.has(e.key)},...fn.has(e.key)?[]:e.items]):e},[S,P,fn]),hn=m(null),[J,gn]=h(null),_n=Ee(e=>{hn.current=e,gn(e)},[]),vn=m(null);p(()=>{let e=J;if(!e)return;let t=e=>{let t=e.target instanceof Element?e.target.closest(`.u-name`):null;t&&!t.title&&(t.scrollWidth>t.clientWidth||t.scrollHeight>t.clientHeight)&&(t.title=(t.textContent??``).trim())},n=e=>{let t=e.target instanceof Element?e.target.closest(`tbody > tr[aria-rowindex]`)?.getAttribute(`aria-rowindex`):null;vn.current=t?Number(t)-2:null},r=t=>{t.relatedTarget instanceof Node&&e.contains(t.relatedTarget)||(vn.current=null)};e.addEventListener(`mouseover`,t),e.addEventListener(`focusin`,t),e.addEventListener(`focusin`,n),e.addEventListener(`focusout`,r);let i=le(e);return()=>{e.removeEventListener(`mouseover`,t),e.removeEventListener(`focusin`,t),e.removeEventListener(`focusin`,n),e.removeEventListener(`focusout`,r),i()}},[J]),p(()=>{if(!A||!J)return;let e=ce(J);return xe(document),e},[A,J]);let yn=m(qe);De(()=>{yn.current=()=>({total:S?.length??0,keys:S?S.flatMap((e,t)=>{let n=R(e,t);return G(e,t)&&D?.has(n)?[String(n)]:[]}):[]})});let bn=m(!1);p(()=>{if(!bn.current&&(bn.current=!0,K===0))return;let{total:e,keys:t}=yn.current();hn.current?.querySelector(`table`)?.dispatchEvent(new CustomEvent(`selectionchange`,{bubbles:!0,detail:{selected:K,total:e,keys:t}}))},[K]);let[xn,Sn]=h({top:0,height:0}),[Cn,wn]=h(ae[O]??ae.comfortable);p(()=>{let e=J;if(!W||!e)return;let t=0,n=()=>{t=0;let n=e.querySelector(`:scope > table > thead`)?.getBoundingClientRect().height||0,r={top:Math.max(0,e.scrollTop-n),height:e.clientHeight};Sn(e=>e.top===r.top&&e.height===r.height?e:r)},r=()=>{t||=requestAnimationFrame(n)};e.addEventListener(`scroll`,r,{passive:!0});let i=typeof ResizeObserver<`u`?new ResizeObserver(r):null;return i?.observe(e),n(),()=>{e.removeEventListener(`scroll`,r),i?.disconnect(),t&&cancelAnimationFrame(t)}},[W,J]);let Tn=m(null);De(()=>{if(!W){Tn.current=null;return}let e=`${O}:${S?.length??0}`;if(Tn.current===e)return;Tn.current=e;let t=(hn.current?.querySelector(`:scope > table > tbody > tr:not(.wui-virtual-spacer, .wui-group-row)`))?.getBoundingClientRect().height;t!==void 0&&t>0&&Math.abs(t-Cn)>.5&&wn(t)});let Y={start:0,end:q.length,before:0,after:0};if(W){Y=Se({scrollTop:xn.top,viewport:xn.height||Number.parseFloat(String(Tt))||0,rowHeight:Cn,count:q.length});let e=vn.current;e!==null&&e>=0&&e<q.length&&(e<Y.start&&Y.start-e<=We&&(Y={...Y,start:e,before:e*Cn}),e>=Y.end&&e-Y.end<We&&(Y={...Y,end:e+1,after:(q.length-e-1)*Cn}))}let En=m(null),Dn=m(null),On=m(null),kn=!F&&!C&&S?.length>0&&S.length<=oe;De(()=>{let e=En.current;if(!kn||!e){Dn.current=null,On.current=null;return}let t=S.map((e,t)=>R(e,t));ve(On.current,t)&&_e(e.rows,Dn.current),Dn.current=pe(e.rows),On.current=t});let An=typeof I==`function`||typeof L==`function`,jn=m(null),Mn=m(null),X=y[0]?.key;p(()=>{if(!An){Mn.current=null;return}let e=/* @__PURE__ */ new Map;(S||[]).forEach((t,n)=>{let r=X===void 0?void 0:v(t,X),i=typeof r==`string`||typeof r==`number`?String(r):``;e.set(R(t,n),{...Ye(t,I,L),label:i})});let t=ye(be(Mn.current,e));Mn.current=e,t&&jn.current&&(jn.current.textContent=t)},[S,I,L,R,An,X]);let Nn=at!==void 0&&(ct===void 0||ct>0)?at:it,Z=!C&&ot?ot:null,Pn=({group:e,open:n},r)=>{let i=v(e.items[0]?.row,P??``),a=e.items.map(e=>e.row);return/* @__PURE__ */ g(`tr`,{className:`wui-group-row`,"data-group-key":e.key,"aria-rowindex":W?r+2:void 0,children:/* @__PURE__ */ g(`th`,{className:`wui-group-cell`,scope:`rowgroup`,colSpan:Qt,children:/* @__PURE__ */ _(`button`,{type:`button`,className:`wui-group-toggle`,"aria-expanded":n,onClick:()=>mn(e.key),children:[/* @__PURE__ */ g(s,{name:`chevron-down`,size:16}),/* @__PURE__ */ g(`span`,{className:`wui-group-label`,children:It?It(i,a):Ze(Ve(i,P??``))}),/* @__PURE__ */ g(`span`,{className:`wui-group-count`,"aria-hidden":`true`,children:ue(e.items.length)}),/* @__PURE__ */ g(`span`,{className:`visually-hidden wui-group-rows`,children:`, ${Ne(t,`groupRows`,e.items.length,{count:ue(e.items.length)})}`})]})})},`group:${e.key}`)},Fn=({row:e,i:n},r)=>{let i=R(e,n),a=B&&Ht.has(i),o=Nt!=null&&String(Nt)===String(i),ee=Pt!=null&&String(Pt)===String(i),c=String(i).replace(/[^a-z0-9]/gi,`_`),l=U(0,`wui-expand-cell`),u=U(+!!B,`wui-select-cell`),d=An?Ye(e,I,L):null,f=G(e,n),ne=w?.(e);if(w&&!Array.isArray(ne))throw TypeError(`AppDataTable: rowActions returns a list of actions ({ key, label, icon, onClick or href }). It returned something else: restate the buttons as a list, see node scripts/codemods/row-actions.mjs --check.`);let re=X===void 0?void 0:v(e,X),ie=typeof re==`string`||typeof re==`number`?Me(t.moreActionsForText,{firstValue:re}):Ce.menuLabel;return/* @__PURE__ */ _(we,{children:[/* @__PURE__ */ _(`tr`,{className:[E&&f&&D?.has(i)?`is-selected`:``,z?`wui-row-link`:``,o?`wui-row-active`:``,ee?Pe.hover:``].filter(Boolean).join(` `)||void 0,"aria-current":o?`true`:void 0,"aria-rowindex":W?r+2:void 0,"aria-busy":d?.state===`saving`?`true`:void 0,"data-wui-save-state":d?.state||void 0,"data-status":jt?.(e)||void 0,"data-href":M?.(e)||void 0,"data-row-key":A?String(i):void 0,tabIndex:z?0:void 0,onClick:z?t=>qt(e,t):void 0,onAuxClick:z&&M?t=>t.button===1&&qt(e,t):void 0,onKeyDown:z?t=>{fe(t.nativeEvent)&&t.target===t.currentTarget&&qt(e,t)}:void 0,children:[B&&/* @__PURE__ */ g(`td`,{className:l.className,style:l.style,children:/* @__PURE__ */ g(`button`,{type:`button`,className:`wui-expand-toggle${a?` is-open`:``}`,"aria-expanded":a,"aria-controls":a?`${c}-expanded`:void 0,"aria-label":a?t.collapseRowLabel:t.expandRowLabel,onClick:()=>Wt(i),children:/* @__PURE__ */ g(s,{name:`chevron-down`,size:16})})}),E&&/* @__PURE__ */ g(`td`,{className:u.className,style:u.style,children:/* @__PURE__ */ g(`input`,{type:`checkbox`,className:`wui-check`,checked:f&&(D?.has(i)||!1),disabled:!f,onChange:e=>un(i,e.nativeEvent instanceof MouseEvent&&e.nativeEvent.shiftKey),onMouseDown:e=>{e.shiftKey&&e.preventDefault()},"aria-label":t.selectRowLabel})}),y.map((t,n)=>{let r=t.rowHeader?`th`:`td`;return/* @__PURE__ */ _(r,{scope:t.rowHeader?`row`:void 0,className:U(H+n,(n===0?`wui-name-cell `:``)+(t.rowHeader?`wui-row-header `:``)+(t.nowrap?`text-nowrap `:``)+x(t.align)+(t.cellClassName?` ${t.cellClassName}`:``)).className,style:nn(H+n,t.cellStyle),"data-label":j&&typeof t.label==`string`?t.label:void 0,children:[t.render?t.render(e):Ze(He(e,t.key)),n===0&&d?.state===`error`&&/* @__PURE__ */ g(`span`,{className:se,children:d.message})]},t.key)}),w&&/* @__PURE__ */ g(`td`,{children:/* @__PURE__ */ g(te,{items:ne??[],menuLabel:ie,linkComponent:lt})})]}),a&&/* @__PURE__ */ g(`tr`,{className:`wui-row-expanded`,children:/* @__PURE__ */ g(`td`,{id:`${c}-expanded`,colSpan:Qt,children:vt?.(e)})})]},i)},In=(e,t)=>`group`in e?Pn(e,t):Fn(e,t),Ln=(e,t)=>W?/* @__PURE__ */ g(`tr`,{className:`wui-virtual-spacer`,"aria-hidden":`true`,hidden:t===0,children:/* @__PURE__ */ g(`td`,{colSpan:Qt,style:{height:t}})},e):null,Q=U(0,`wui-expand-cell`),$=U(+!!B,`wui-select-cell`),Rn=()=>Array.from({length:rt},(e,t)=>`skeleton-${t}`).map(e=>/* @__PURE__ */ _(`tr`,{children:[B&&/* @__PURE__ */ g(`td`,{className:Q.className,style:Q.style}),E&&/* @__PURE__ */ g(`td`,{className:$.className,style:$.style}),y.map((e,t)=>/* @__PURE__ */ g(`td`,{className:U(H+t,(t===0?`wui-name-cell `:``)+(e.nowrap?`text-nowrap `:``)+x(e.align)).className,style:nn(H+t,void 0),"data-label":j&&typeof e.label==`string`?e.label:void 0,children:/* @__PURE__ */ g(c,{width:Xe(e.align),height:12,radius:6})},e.key)),w&&/* @__PURE__ */ g(`td`,{children:/* @__PURE__ */ g(`div`,{className:`u-row-actions`,children:/* @__PURE__ */ g(c,{width:`32px`,height:12,radius:6})})})]},e));return/* @__PURE__ */ _(ke,{children:[/* @__PURE__ */ _(en?`wui-data-table`:`div`,{ref:_n,...en?{class:Yt,resizable:N?``:void 0,"view-key":Ft||void 0,"data-wui-row-drag":A?``:void 0,"aria-busy":Jt||void 0}:{className:Yt,"data-wui-row-drag":A?``:void 0,"aria-busy":Jt||void 0},style:Zt,tabIndex:0,...ze,...zt,children:[/* @__PURE__ */ _(`table`,{className:Vt,"aria-label":dt,"aria-rowcount":W?q.length+1:void 0,style:bt===`fixed`?{tableLayout:`fixed`,minWidth:Be(y)}:void 0,children:[/* @__PURE__ */ g(`thead`,{children:/* @__PURE__ */ _(`tr`,{"aria-rowindex":W?1:void 0,children:[B&&/* @__PURE__ */ g(`th`,{className:Q.className,style:Q.style,children:/* @__PURE__ */ g(`span`,{className:`visually-hidden`,children:t.expandLabel})}),E&&/* @__PURE__ */ g(`th`,{className:$.className,style:$.style,children:/* @__PURE__ */ g(`input`,{ref:cn,type:`checkbox`,className:`wui-check`,checked:on,disabled:C,onChange:e=>dn(e.target.checked),"aria-label":t.selectAllRowsLabel})}),y.map((e,t)=>{let n=e.sortable?tt:void 0,r=n!==void 0,i=et&&et.key===e.key,a=e.align===`num`||e.align===`end`,o=r&&/* @__PURE__ */ g(`span`,{className:`sort-icon${a?` wui-sort-lead`:``}`,children:/* @__PURE__ */ g(s,{name:`chevrons-up-down`,size:14})}),te=N&&t!==rn,c=bt===`fixed`&&!e.grow?e.minWidth:void 0,l=e.width||e.minWidth?{width:e.width??c,minWidth:e.minWidth}:void 0;return/* @__PURE__ */ _(`th`,{className:U(H+t,(r?`sortable `:``)+(t===0?`wui-name-cell `:``)+(e.nowrap?`text-nowrap `:``)+(e.grow?`wui-col-grow `:``)+(te?`wui-col-resizable `:``)+x(e.align)).className,style:nn(H+t,l),"data-key":en?e.key:void 0,"aria-label":te&&typeof e.label==`string`?e.label:void 0,"data-pin":e.pin===`start`||e.pin===`end`?e.pin:void 0,tabIndex:r?0:void 0,"aria-sort":i?et?.dir===`asc`?`ascending`:`descending`:r?`none`:void 0,onClick:n?t=>{t.target instanceof Element&&t.target.closest(`.infotip`)||C||n(e.key)}:void 0,onKeyDown:n?t=>{t.target===t.currentTarget&&(fe(t.nativeEvent)||t.key===` `)&&(t.preventDefault(),C||n(e.key))}:void 0,children:[a&&o,e.label,!a&&o,e.help?/* @__PURE__ */ g(ee,{label:typeof e.label==`string`?e.label:void 0,children:e.help}):null,te&&/* @__PURE__ */ g(`span`,{className:`wui-col-resize`,role:`separator`,"aria-orientation":`vertical`,"aria-valuemin":ne,"aria-valuemax":f,tabIndex:0,"aria-label":Te(typeof e.label==`string`?e.label:e.key)})]},e.key)}),w&&(ut?/* @__PURE__ */ g(`th`,{className:`wui-cell-end`,children:ut}):/* @__PURE__ */ g(`th`,{className:`wui-cell-end`,children:/* @__PURE__ */ g(`span`,{className:`visually-hidden`,children:t.rowActionsLabel})}))]})}),/* @__PURE__ */ g(`tbody`,{ref:En,children:C?Rn():Z?null:S?.length?/* @__PURE__ */ _(ke,{children:[Ln(`before`,Y.before),q.slice(Y.start,Y.end).map((e,t)=>In(e,Y.start+t)),Ln(`after`,Y.after)]}):null}),Gt&&!C&&!Z&&S?.length>0&&/* @__PURE__ */ g(`tfoot`,{children:/* @__PURE__ */ _(`tr`,{children:[B&&/* @__PURE__ */ g(`td`,{className:Q.className,style:Q.style}),E&&/* @__PURE__ */ g(`td`,{className:$.className,style:$.style}),y.map((e,t)=>/* @__PURE__ */ g(`td`,{className:U(H+t,(t===0?`wui-name-cell `:``)+(e.nowrap?`text-nowrap `:``)+x(e.align)).className,style:nn(H+t,void 0),children:e.footer?e.footer(S):null},e.key)),w&&/* @__PURE__ */ g(`td`,{})]})})]}),!C&&(Z||!S?.length)&&/* @__PURE__ */ g(`div`,{className:`tbl-empty-block`,role:Z?`alert`:void 0,children:Z?/* @__PURE__ */ g(o,{variant:`table`,icon:`alert-circle`,description:Z.message,action:st?/* @__PURE__ */ g(a,{variant:`soft`,size:`sm`,onClick:()=>st(),children:t.retryLabel}):void 0,className:`wui-table-error`}):typeof Nn==`string`?/* @__PURE__ */ g(`div`,{className:`tbl-empty-plain`,children:Nn}):Nn})]}),Qe(T)&&/* @__PURE__ */ g(l,{page:T.page,totalPages:T.totalPages,total:T.total,pageSize:T.pageSize,onPageChange:C?Ke:T.setPage,onPageSizeChange:C?Ke:T.setPageSize,pageSizes:T.pageSizes,mode:T.mode,summary:T.summary}),An&&/* @__PURE__ */ g(`div`,{ref:jn,className:`visually-hidden`,role:`status`,"aria-live":`polite`,"data-wui-table-status":``})]})}export{S as default};
|
|
1
|
+
import{devWarn as e}from"../lib/devWarn.js";import{emptyPlaceholder as t}from"../lib/emptyValue.js";import n from"../lib/useElementEntry.js";import r from"../lib/useWuiText.js";import{splitMarkerProps as i}from"../lib/wuiMarker.js";import a from"./AppButton.js";import o from"./AppEmptyState.js";import s from"./AppIcon.js";import ee from"./AppInfoTip.js";import te from"./AppRowActions.js";import c from"./AppSkeleton.js";import l from"./AppTablePagination.js";import u from"./assertValidValue.js";import d from"./warnUnknownProps.js";import{COLUMN_MAX_WIDTH as f,COLUMN_MIN_WIDTH as ne,PIN_AT_VAR as re,PIN_SIDES as ie,ROW_HEIGHTS as ae,ROW_MOVE_LIMIT as oe,ROW_SAVE_ERROR_CLASS as se,attachRowDrag as ce,attachScrollEdges as le,groupCount as ue,groupItems as de,isImeSafeEnter as fe,measureRows as pe,pinAtValue as me,pinClasses as he,planPins as ge,playRowMoves as _e,rowOrderChanged as ve,saveOutcomeText as ye,settledRows as be,syncTargets as xe,virtualRange as Se}from"@webority/ui-elements/helpers";import{Children as Ce,Fragment as we,isValidElement as Te,useCallback as Ee,useEffect as p,useLayoutEffect as De,useMemo as Oe,useRef as m,useState as h}from"react";import{Fragment as ke,jsx as g,jsxs as _}from"react/jsx-runtime";import{DATA_TABLE_TEXT as Ae,ROW_ACTIONS_TEXT as je,fillText as Me,pluralText as Ne}from"@webority/ui-elements/text";import{FORCED_STATE_CLASSES as Pe}from"@webority/theme/runtime";var Fe=()=>import(`@webority/ui-elements/elements/data-table`),Ie=[`comfortable`,`cozy`,`compact`],Le=[`auto`,`fixed`],Re=[1,2,3,4],ze=e=>typeof e==`number`?`${e}px`:e;function Be(e){let t=e.flatMap(e=>{let t=e.minWidth??e.width;return t===void 0?[]:[ze(t)]});if(t.length!==0)return t.length===1?t[0]:`calc(${t.join(` + `)})`}function v(e,t){return typeof e==`object`&&e?Reflect.get(e,t):void 0}function Ve(e,t){if(e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`||Te(e)||Array.isArray(e))return e;throw Error(`AppDataTable: the value under "${t}" is not renderable; give that column a render function.`)}function He(e,t){return Ve(v(e,t),t)}var Ue=()=>{try{return process.env.NODE_ENV!==`production`}catch{return!0}},y=/* @__PURE__ */ new Set;function b(t,n){!y.has(t)&&Ue()&&(y.add(t),e(`[@webority/ui-react] <AppDataTable> ${n}`))}var We=100,Ge=e=>{let t=typeof e==`object`&&e&&`id`in e?e.id:void 0;return typeof t==`string`||typeof t==`number`?t:void 0},Ke=()=>{},qe=()=>({total:0,keys:[]}),Je=[],Ye=(e,t,n)=>{let r=!!t?.(e),i=r?``:n?.(e)||``;return{state:r?`saving`:i?`error`:null,message:i}};function x(e){return e===`end`?`wui-cell-end`:e===`num`?`num`:e===`center`?`text-center`:``}function Xe(e){return e===`center`?`44%`:e===`end`||e===`num`?`56%`:`60%`}function Ze(e){return e==null||e===``?t():Array.isArray(e)?Ce.toArray(e):typeof e==`boolean`?String(e):e}function Qe(e){if(!e||!(e.total>0))return!1;let t=e.pageSizes?.length?e.pageSizes:[e.pageSize];return e.total>Math.min(...t)}function S(e){n(`wui-data-table`,Fe);let t=r(`dataTable`,Ae),Ce=r(`rowActions`,je),Te=e=>e?Me(t.resizeColumnText,{label:e}):t.resizeColumnLabel,{marker:ze,props:Ue}=i(`AppDataTable`,e),{columns:y,rows:S=Je,rowKey:$e=Ge,sort:et,onSort:tt,loading:C=!1,refreshing:nt=!1,skeletonRows:rt=5,empty:it=t.empty,emptyFiltered:at,error:ot,onRetry:st,sourceCount:ct,rowActions:w,linkComponent:lt,rowActionsLabel:ut,pagination:T,ariaLabel:dt,className:ft=``,wrapperClassName:pt=``,selectable:E=!1,selectedIds:D,isRowSelectable:mt,onToggleRow:ht,onToggleAll:gt,onSelectRange:_t,renderExpanded:vt,singleExpand:yt=!1,density:O=`cozy`,tableLayout:bt=`auto`,striped:xt=!1,flush:St=!1,pad:Ct,nameLines:k,headerTone:wt,rowDrag:A=!1,maxHeight:Tt,stickyFirstColumn:Et=!1,stickyActions:Dt=!1,equalActions:Ot=!1,linkFirstColumn:kt=!1,stackOnMobile:j=!1,hiddenColumns:At,rowStatus:jt,rowHref:M,onRowClick:Mt,activeRowKey:Nt,hoverRowKey:Pt,resizableColumns:N=!1,viewKey:Ft,groupBy:P,groupLabel:It,virtual:F=!1,rowSaving:I,rowSaveError:L,...Lt}=Ue;d(`AppDataTable`,Lt);let{style:Rt,...zt}=Lt,R=Ee((e,t)=>{let n=$e(e,t);if(n==null)throw Error(`AppDataTable: a row has no key. Pass rowKey, or give every row an id.`);return n},[$e]),Bt=At?.length?new Set(At):null;y=Bt?y.filter(e=>!(e.hideable&&Bt.has(e.key))):y,u(`AppDataTable`,`density`,O,Ie),u(`AppDataTable`,`tableLayout`,bt,Le),u(`AppDataTable`,`nameLines`,k,Re);for(let e of y)u(`AppDataTable`,`column.pin`,e.pin,ie);let z=typeof M==`function`||typeof Mt==`function`,Vt=[`table table-ledger`,O===`cozy`||O===`compact`?`wui-table-${O}`:``,xt?`wui-table-striped`:``,Et?`wui-table-sticky-first`:``,Dt?`wui-table-sticky-actions`:``,Ot?`wui-table-equal-actions`:``,j?`wui-table-stack`:``,kt&&z?`wui-table-link-first`:``,ft].filter(Boolean).join(` `),B=typeof vt==`function`,[Ht,Ut]=h(()=>/* @__PURE__ */ new Set),Wt=e=>Ut(t=>{if(t.has(e)){let n=new Set(t);return n.delete(e),n}return yt?/* @__PURE__ */ new Set([e]):new Set(t).add(e)}),Gt=y.some(e=>typeof e.footer==`function`),Kt=e=>!!(e.target instanceof Element&&e.target.closest(`a, button, input, select, textarea, label, [role='menu'], [role='menuitem'], .dropdown`)),qt=(e,t)=>{if(Kt(t)||(Mt&&Mt(e),!M))return;let n=M(e);n&&(t.ctrlKey||t.metaKey||t.button===1?window.open(n,`_blank`,`noopener`):window.location.assign(n))},V=Tt!==void 0,Jt=nt&&!C&&S.length>0,Yt=[`table-wrap`,V?`wui-table-scroll`:``,St?`wui-table-flush`:``,Jt?`wui-table-refreshing`:``,pt].filter(Boolean).join(` `),Xt={maxHeight:V?Tt:void 0,"--wui-table-pad":Ct!=null&&!St?`${Ct}px`:void 0,"--wui-name-lines":F?`1`:k?.toString(),"--wui-table-header-bg":wt??void 0},Zt=Object.values(Xt).some(e=>e!==void 0)||Rt!==void 0?{...Xt,...Rt}:void 0,Qt=Math.max(1,y.length+ +!!w+ +!!E+ +!!B),$t=y.some(e=>e.pin===`start`||e.pin===`end`),en=$t||N||!!P||F,H=+!!B+ +!!E,tn=$t?ge([...B?[`lead`]:[],...E?[`lead`]:[],...y.map(e=>e.pin===`start`||e.pin===`end`?e.pin:null),...w?[null]:[]]):[],U=(e,t=``)=>{let n=tn[e];return n?{className:`${t.trim()} ${he(n)}`.trim(),style:{[re]:me(n.side,n.ordinal)}}:{className:t,style:void 0}},nn=(e,t)=>tn[e]?{...t,...U(e).style}:t,rn=y.length-1+ +!!w;Ft&&!N&&b(`view-key`,"`viewKey` remembers resized widths: add `resizableColumns`."),F&&!V&&b(`virtual-height`,"`virtual` needs `maxHeight`: without a scroll box every row renders."),F&&(B||j)&&b(`virtual-shape`,"`virtual` takes rows of one height, so it is off with `renderExpanded` or `stackOnMobile`."),F&&k!==void 0&&k!==1&&b(`virtual-name-lines`,"`nameLines` is ignored with `virtual`: a virtual table shows one line per name."),kt&&!z&&b(`link-first-column`,"`linkFirstColumn` needs rowHref or onRowClick: the row is what opens."),yt&&typeof vt!=`function`&&b(`single-expand`,"`singleExpand` needs renderExpanded: there are no rows to expand."),!F&&S?.length>500&&b(`rows-without-virtual`,`renders more than 500 rows without virtual: add virtual with maxHeight, or page the data.`);let W=F&&V&&!B&&!j&&!C&&S?.length>0,G=(e,t)=>!mt||!!mt(e,t),an=E&&S?S.reduce((e,t,n)=>e+ +!!G(t,n),0):0,K=E&&S?S.reduce((e,t,n)=>e+(G(t,n)&&D?.has(R(t,n))?1:0),0):0,on=an>0&&K===an,sn=K>0&&!on,cn=e=>{e&&(e.indeterminate=sn)},ln=m(null),un=(e,t)=>{let n=ln.current;ln.current=e;let r=t&&n!==null?S.findIndex((e,t)=>R(e,t)===n):-1,i=S.findIndex((t,n)=>R(t,n)===e);if(r<0||i<0||r===i){ht?.(e);return}let a=!D?.has(e),o=Math.min(r,i),s=S.slice(o,Math.max(r,i)+1).map((e,t)=>[e,o+t]).filter(([e,t])=>G(e,t)).map(([e,t])=>R(e,t)).filter(e=>(D?.has(e)||!1)!==a);if(_t)_t(s,a);else for(let e of s)ht?.(e)},dn=e=>{mt?(S||[]).forEach((t,n)=>{let r=R(t,n);G(t,n)&&(D?.has(r)||!1)!==e&&ht?.(r)}):gt?.(e)},[fn,pn]=h(()=>/* @__PURE__ */ new Set),mn=e=>pn(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),q=Oe(()=>{let e=(S||[]).map((e,t)=>({row:e,i:t}));return P?de(e,({row:e})=>String(v(e,P)??``)).flatMap(e=>[{group:e,open:!fn.has(e.key)},...fn.has(e.key)?[]:e.items]):e},[S,P,fn]),hn=m(null),[J,gn]=h(null),_n=Ee(e=>{hn.current=e,gn(e)},[]),vn=m(null);p(()=>{let e=J;if(!e)return;let t=e=>{let t=e.target instanceof Element?e.target.closest(`.u-name`):null;t&&!t.title&&(t.scrollWidth>t.clientWidth||t.scrollHeight>t.clientHeight)&&(t.title=(t.textContent??``).trim())},n=e=>{let t=e.target instanceof Element?e.target.closest(`tbody > tr[aria-rowindex]`)?.getAttribute(`aria-rowindex`):null;vn.current=t?Number(t)-2:null},r=t=>{t.relatedTarget instanceof Node&&e.contains(t.relatedTarget)||(vn.current=null)};e.addEventListener(`mouseover`,t),e.addEventListener(`focusin`,t),e.addEventListener(`focusin`,n),e.addEventListener(`focusout`,r);let i=le(e);return()=>{e.removeEventListener(`mouseover`,t),e.removeEventListener(`focusin`,t),e.removeEventListener(`focusin`,n),e.removeEventListener(`focusout`,r),i()}},[J]),p(()=>{if(!A||!J)return;let e=ce(J);return xe(document),e},[A,J]);let yn=m(qe);De(()=>{yn.current=()=>({total:S?.length??0,keys:S?S.flatMap((e,t)=>{let n=R(e,t);return G(e,t)&&D?.has(n)?[String(n)]:[]}):[]})});let bn=m(!1);p(()=>{if(!bn.current&&(bn.current=!0,K===0))return;let{total:e,keys:t}=yn.current();hn.current?.querySelector(`table`)?.dispatchEvent(new CustomEvent(`selectionchange`,{bubbles:!0,detail:{selected:K,total:e,keys:t}}))},[K]);let[xn,Sn]=h({top:0,height:0}),[Cn,wn]=h(ae[O]??ae.cozy);p(()=>{let e=J;if(!W||!e)return;let t=0,n=()=>{t=0;let n=e.querySelector(`:scope > table > thead`)?.getBoundingClientRect().height||0,r={top:Math.max(0,e.scrollTop-n),height:e.clientHeight};Sn(e=>e.top===r.top&&e.height===r.height?e:r)},r=()=>{t||=requestAnimationFrame(n)};e.addEventListener(`scroll`,r,{passive:!0});let i=typeof ResizeObserver<`u`?new ResizeObserver(r):null;return i?.observe(e),n(),()=>{e.removeEventListener(`scroll`,r),i?.disconnect(),t&&cancelAnimationFrame(t)}},[W,J]);let Tn=m(null);De(()=>{if(!W){Tn.current=null;return}let e=`${O}:${S?.length??0}`;if(Tn.current===e)return;Tn.current=e;let t=(hn.current?.querySelector(`:scope > table > tbody > tr:not(.wui-virtual-spacer, .wui-group-row)`))?.getBoundingClientRect().height;t!==void 0&&t>0&&Math.abs(t-Cn)>.5&&wn(t)});let Y={start:0,end:q.length,before:0,after:0};if(W){Y=Se({scrollTop:xn.top,viewport:xn.height||Number.parseFloat(String(Tt))||0,rowHeight:Cn,count:q.length});let e=vn.current;e!==null&&e>=0&&e<q.length&&(e<Y.start&&Y.start-e<=We&&(Y={...Y,start:e,before:e*Cn}),e>=Y.end&&e-Y.end<We&&(Y={...Y,end:e+1,after:(q.length-e-1)*Cn}))}let En=m(null),Dn=m(null),On=m(null),kn=!F&&!C&&S?.length>0&&S.length<=oe;De(()=>{let e=En.current;if(!kn||!e){Dn.current=null,On.current=null;return}let t=S.map((e,t)=>R(e,t));ve(On.current,t)&&_e(e.rows,Dn.current),Dn.current=pe(e.rows),On.current=t});let An=typeof I==`function`||typeof L==`function`,jn=m(null),Mn=m(null),X=y[0]?.key;p(()=>{if(!An){Mn.current=null;return}let e=/* @__PURE__ */ new Map;(S||[]).forEach((t,n)=>{let r=X===void 0?void 0:v(t,X),i=typeof r==`string`||typeof r==`number`?String(r):``;e.set(R(t,n),{...Ye(t,I,L),label:i})});let t=ye(be(Mn.current,e));Mn.current=e,t&&jn.current&&(jn.current.textContent=t)},[S,I,L,R,An,X]);let Nn=at!==void 0&&(ct===void 0||ct>0)?at:it,Z=!C&&ot?ot:null,Pn=({group:e,open:n},r)=>{let i=v(e.items[0]?.row,P??``),a=e.items.map(e=>e.row);return/* @__PURE__ */ g(`tr`,{className:`wui-group-row`,"data-group-key":e.key,"aria-rowindex":W?r+2:void 0,children:/* @__PURE__ */ g(`th`,{className:`wui-group-cell`,scope:`rowgroup`,colSpan:Qt,children:/* @__PURE__ */ _(`button`,{type:`button`,className:`wui-group-toggle`,"aria-expanded":n,onClick:()=>mn(e.key),children:[/* @__PURE__ */ g(s,{name:`chevron-down`,size:16}),/* @__PURE__ */ g(`span`,{className:`wui-group-label`,children:It?It(i,a):Ze(Ve(i,P??``))}),/* @__PURE__ */ g(`span`,{className:`wui-group-count`,"aria-hidden":`true`,children:ue(e.items.length)}),/* @__PURE__ */ g(`span`,{className:`visually-hidden wui-group-rows`,children:`, ${Ne(t,`groupRows`,e.items.length,{count:ue(e.items.length)})}`})]})})},`group:${e.key}`)},Fn=({row:e,i:n},r)=>{let i=R(e,n),a=B&&Ht.has(i),o=Nt!=null&&String(Nt)===String(i),ee=Pt!=null&&String(Pt)===String(i),c=String(i).replace(/[^a-z0-9]/gi,`_`),l=U(0,`wui-expand-cell`),u=U(+!!B,`wui-select-cell`),d=An?Ye(e,I,L):null,f=G(e,n),ne=w?.(e);if(w&&!Array.isArray(ne))throw TypeError(`AppDataTable: rowActions returns a list of actions ({ key, label, icon, onClick or href }). It returned something else: restate the buttons as a list, see node scripts/codemods/row-actions.mjs --check.`);let re=X===void 0?void 0:v(e,X),ie=typeof re==`string`||typeof re==`number`?Me(t.moreActionsForText,{firstValue:re}):Ce.menuLabel;return/* @__PURE__ */ _(we,{children:[/* @__PURE__ */ _(`tr`,{className:[E&&f&&D?.has(i)?`is-selected`:``,z?`wui-row-link`:``,o?`wui-row-active`:``,ee?Pe.hover:``].filter(Boolean).join(` `)||void 0,"aria-current":o?`true`:void 0,"aria-rowindex":W?r+2:void 0,"aria-busy":d?.state===`saving`?`true`:void 0,"data-wui-save-state":d?.state||void 0,"data-status":jt?.(e)||void 0,"data-href":M?.(e)||void 0,"data-row-key":A?String(i):void 0,tabIndex:z?0:void 0,onClick:z?t=>qt(e,t):void 0,onAuxClick:z&&M?t=>t.button===1&&qt(e,t):void 0,onKeyDown:z?t=>{fe(t.nativeEvent)&&t.target===t.currentTarget&&qt(e,t)}:void 0,children:[B&&/* @__PURE__ */ g(`td`,{className:l.className,style:l.style,children:/* @__PURE__ */ g(`button`,{type:`button`,className:`wui-expand-toggle${a?` is-open`:``}`,"aria-expanded":a,"aria-controls":a?`${c}-expanded`:void 0,"aria-label":a?t.collapseRowLabel:t.expandRowLabel,onClick:()=>Wt(i),children:/* @__PURE__ */ g(s,{name:`chevron-down`,size:16})})}),E&&/* @__PURE__ */ g(`td`,{className:u.className,style:u.style,children:/* @__PURE__ */ g(`input`,{type:`checkbox`,className:`wui-check`,checked:f&&(D?.has(i)||!1),disabled:!f,onChange:e=>un(i,e.nativeEvent instanceof MouseEvent&&e.nativeEvent.shiftKey),onMouseDown:e=>{e.shiftKey&&e.preventDefault()},"aria-label":t.selectRowLabel})}),y.map((t,n)=>{let r=t.rowHeader?`th`:`td`;return/* @__PURE__ */ _(r,{scope:t.rowHeader?`row`:void 0,className:U(H+n,(n===0?`wui-name-cell `:``)+(t.rowHeader?`wui-row-header `:``)+(t.nowrap?`text-nowrap `:``)+x(t.align)+(t.cellClassName?` ${t.cellClassName}`:``)).className,style:nn(H+n,t.cellStyle),"data-label":j&&typeof t.label==`string`?t.label:void 0,children:[t.render?t.render(e):Ze(He(e,t.key)),n===0&&d?.state===`error`&&/* @__PURE__ */ g(`span`,{className:se,children:d.message})]},t.key)}),w&&/* @__PURE__ */ g(`td`,{children:/* @__PURE__ */ g(te,{items:ne??[],menuLabel:ie,linkComponent:lt})})]}),a&&/* @__PURE__ */ g(`tr`,{className:`wui-row-expanded`,children:/* @__PURE__ */ g(`td`,{id:`${c}-expanded`,colSpan:Qt,children:vt?.(e)})})]},i)},In=(e,t)=>`group`in e?Pn(e,t):Fn(e,t),Ln=(e,t)=>W?/* @__PURE__ */ g(`tr`,{className:`wui-virtual-spacer`,"aria-hidden":`true`,hidden:t===0,children:/* @__PURE__ */ g(`td`,{colSpan:Qt,style:{height:t}})},e):null,Q=U(0,`wui-expand-cell`),$=U(+!!B,`wui-select-cell`),Rn=()=>Array.from({length:rt},(e,t)=>`skeleton-${t}`).map(e=>/* @__PURE__ */ _(`tr`,{children:[B&&/* @__PURE__ */ g(`td`,{className:Q.className,style:Q.style}),E&&/* @__PURE__ */ g(`td`,{className:$.className,style:$.style}),y.map((e,t)=>/* @__PURE__ */ g(`td`,{className:U(H+t,(t===0?`wui-name-cell `:``)+(e.nowrap?`text-nowrap `:``)+x(e.align)).className,style:nn(H+t,void 0),"data-label":j&&typeof e.label==`string`?e.label:void 0,children:/* @__PURE__ */ g(c,{width:Xe(e.align),height:12,radius:6})},e.key)),w&&/* @__PURE__ */ g(`td`,{children:/* @__PURE__ */ g(`div`,{className:`u-row-actions`,children:/* @__PURE__ */ g(c,{width:`32px`,height:12,radius:6})})})]},e));return/* @__PURE__ */ _(ke,{children:[/* @__PURE__ */ _(en?`wui-data-table`:`div`,{ref:_n,...en?{class:Yt,resizable:N?``:void 0,"view-key":Ft||void 0,"data-wui-row-drag":A?``:void 0,"aria-busy":Jt||void 0}:{className:Yt,"data-wui-row-drag":A?``:void 0,"aria-busy":Jt||void 0},style:Zt,tabIndex:0,...ze,...zt,children:[/* @__PURE__ */ _(`table`,{className:Vt,"aria-label":dt,"aria-rowcount":W?q.length+1:void 0,style:bt===`fixed`?{tableLayout:`fixed`,minWidth:Be(y)}:void 0,children:[/* @__PURE__ */ g(`thead`,{children:/* @__PURE__ */ _(`tr`,{"aria-rowindex":W?1:void 0,children:[B&&/* @__PURE__ */ g(`th`,{className:Q.className,style:Q.style,children:/* @__PURE__ */ g(`span`,{className:`visually-hidden`,children:t.expandLabel})}),E&&/* @__PURE__ */ g(`th`,{className:$.className,style:$.style,children:/* @__PURE__ */ g(`input`,{ref:cn,type:`checkbox`,className:`wui-check`,checked:on,disabled:C,onChange:e=>dn(e.target.checked),"aria-label":t.selectAllRowsLabel})}),y.map((e,t)=>{let n=e.sortable?tt:void 0,r=n!==void 0,i=et&&et.key===e.key,a=e.align===`num`||e.align===`end`,o=r&&/* @__PURE__ */ g(`span`,{className:`sort-icon${a?` wui-sort-lead`:``}`,children:/* @__PURE__ */ g(s,{name:`chevrons-up-down`,size:14})}),te=N&&t!==rn,c=bt===`fixed`&&!e.grow?e.minWidth:void 0,l=e.width||e.minWidth?{width:e.width??c,minWidth:e.minWidth}:void 0;return/* @__PURE__ */ _(`th`,{className:U(H+t,(r?`sortable `:``)+(t===0?`wui-name-cell `:``)+(e.nowrap?`text-nowrap `:``)+(e.grow?`wui-col-grow `:``)+(te?`wui-col-resizable `:``)+x(e.align)).className,style:nn(H+t,l),"data-key":en?e.key:void 0,"aria-label":te&&typeof e.label==`string`?e.label:void 0,"data-pin":e.pin===`start`||e.pin===`end`?e.pin:void 0,tabIndex:r?0:void 0,"aria-sort":i?et?.dir===`asc`?`ascending`:`descending`:r?`none`:void 0,onClick:n?t=>{t.target instanceof Element&&t.target.closest(`.infotip`)||C||n(e.key)}:void 0,onKeyDown:n?t=>{t.target===t.currentTarget&&(fe(t.nativeEvent)||t.key===` `)&&(t.preventDefault(),C||n(e.key))}:void 0,children:[a&&o,e.label,!a&&o,e.help?/* @__PURE__ */ g(ee,{label:typeof e.label==`string`?e.label:void 0,children:e.help}):null,te&&/* @__PURE__ */ g(`span`,{className:`wui-col-resize`,role:`separator`,"aria-orientation":`vertical`,"aria-valuemin":ne,"aria-valuemax":f,tabIndex:0,"aria-label":Te(typeof e.label==`string`?e.label:e.key)})]},e.key)}),w&&(ut?/* @__PURE__ */ g(`th`,{className:`wui-cell-end`,children:ut}):/* @__PURE__ */ g(`th`,{className:`wui-cell-end`,children:/* @__PURE__ */ g(`span`,{className:`visually-hidden`,children:t.rowActionsLabel})}))]})}),/* @__PURE__ */ g(`tbody`,{ref:En,children:C?Rn():Z?null:S?.length?/* @__PURE__ */ _(ke,{children:[Ln(`before`,Y.before),q.slice(Y.start,Y.end).map((e,t)=>In(e,Y.start+t)),Ln(`after`,Y.after)]}):null}),Gt&&!C&&!Z&&S?.length>0&&/* @__PURE__ */ g(`tfoot`,{children:/* @__PURE__ */ _(`tr`,{children:[B&&/* @__PURE__ */ g(`td`,{className:Q.className,style:Q.style}),E&&/* @__PURE__ */ g(`td`,{className:$.className,style:$.style}),y.map((e,t)=>/* @__PURE__ */ g(`td`,{className:U(H+t,(t===0?`wui-name-cell `:``)+(e.nowrap?`text-nowrap `:``)+x(e.align)).className,style:nn(H+t,void 0),children:e.footer?e.footer(S):null},e.key)),w&&/* @__PURE__ */ g(`td`,{})]})})]}),!C&&(Z||!S?.length)&&/* @__PURE__ */ g(`div`,{className:`tbl-empty-block`,role:Z?`alert`:void 0,children:Z?/* @__PURE__ */ g(o,{variant:`table`,icon:`alert-circle`,description:Z.message,action:st?/* @__PURE__ */ g(a,{variant:`soft`,size:`sm`,onClick:()=>st(),children:t.retryLabel}):void 0,className:`wui-table-error`}):typeof Nn==`string`?/* @__PURE__ */ g(`div`,{className:`tbl-empty-plain`,children:Nn}):Nn})]}),Qe(T)&&/* @__PURE__ */ g(l,{page:T.page,totalPages:T.totalPages,total:T.total,pageSize:T.pageSize,onPageChange:C?Ke:T.setPage,onPageSizeChange:C?Ke:T.setPageSize,pageSizes:T.pageSizes,mode:T.mode,summary:T.summary}),An&&/* @__PURE__ */ g(`div`,{ref:jn,className:`visually-hidden`,role:`status`,"aria-live":`polite`,"data-wui-table-status":``})]})}export{S as default};
|
|
@@ -1 +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/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
|
+
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 u from"./AppSegmented.js";import d from"./AppSelect.js";import te from"./AppSwitch.js";import f from"./assertValidValue.js";import ne from"./warnUnknownProps.js";import{isImeSafeEnter as re}from"@webority/ui-elements/helpers";import{Fragment as ie,useEffect as p,useId as ae,useRef as m,useState as oe,useSyncExternalStore as se}from"react";import{Fragment as ce,jsx as h,jsxs as g}from"react/jsx-runtime";import{FILTER_BAR_TEXT as _,fillText as v}from"@webority/ui-elements/text";var y=`(max-width: 575.98px)`,le=3,b=2,ue=e=>{let t=window.matchMedia?.(y);return t?.addEventListener(`change`,e),()=>t?.removeEventListener(`change`,e)},de=()=>window.matchMedia?.(y).matches??!1,fe=[`enum`,`multiEnum`,`dateRange`,`text`],pe=[`sm`,`md`],me=()=>import(`@webority/ui-elements/elements/filter-popover`),x=4,he=e=>(e.type===`enum`||e.type===`multiEnum`)&&!e.source&&!e.options?.length,S=(e,t)=>e.options?.find(e=>e.value===t)?.label??t,ge=(e,t)=>JSON.stringify(e)===JSON.stringify(t),C=(e,t,n)=>/* @__PURE__ */ RangeError(`[@webority/ui-react] <AppFilterBar> facet "${e.key}" needs ${t}, received ${JSON.stringify(n)}.`),_e=e=>/* @__PURE__ */ RangeError(`[@webority/ui-react] <AppFilterBar> facet "${e.key}" sets source, which only an enum or multiEnum facet uses. Remove source, or make the facet type enum or multiEnum.`),w=(e,t)=>{if(t==null)return``;if(typeof t==`string`)return t;throw C(e,`a string value`,t)},T=(e,t)=>{if(t==null)return[];if(Array.isArray(t)&&t.every(e=>typeof e==`string`))return t;throw C(e,`an array of strings`,t)},E=(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 C(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:S(n,w(n,r)),clear:()=>e(n)}];if(n.type===`multiEnum`){let e=T(n,r);return e.map(t=>({id:`${n.key}:${t}`,text:S(n,t),clear:()=>e.filter(e=>e!==t)}))}if(n.type===`dateRange`){let t=E(n,r),a=t.from&&t.to?v(i.range,{from:t.from,to:t.to}):t.from?v(i.from,{date:t.from}):v(i.until,{date:t.to??``});return[{id:n.key,text:a,clear:()=>e(n)}]}return[]}var D=/* @__PURE__ */ new Set;function ye(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 allLabel, which only an enum facet uses.`))}var O=/* @__PURE__ */ new Set;function be(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 required, which only an enum facet uses.`))}var k=/* @__PURE__ */ new Set;function xe(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 allLabel and required; a required facet has no All segment.`))}var A=/* @__PURE__ */ new Set;function Se(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 presets, which only a dateRange facet uses.`))}var j=/* @__PURE__ */ new Set;function Ce(e){let t=!0;try{t=process.env.NODE_ENV!==`production`}catch{t=!0}t&&!j.has(e)&&(j.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.source&&(e.required?t<=x:t<x)};function M(n){r(`wui-filter-popover`,me);let c=i(`filterBar`,_),{marker:l,props:u}=a(`AppFilterBar`,n),{facets:d,value:y,onChange:x,onChangeMany:S,inline:C=le,facetLabels:w=!1,floating:T=!1,apply:E=!1,size:D=`sm`,className:O=``,clearAllLabel:k=c.clearAllLabel,filtersLabel:A=c.filtersLabel,filtersActiveLabel:j=c.filtersActiveLabel,keepOpenLabel:M=c.keepOpenLabel,appliesAtOnceText:Te=c.appliesAtOnceText,applyLabel:Ee=c.applyLabel,anyLabel:P=c.anyLabel,removeChipLabel:De=c.removeChipLabel,dateFromText:Oe=c.dateFromText,dateUntilText:ke=c.dateUntilText,dateRangeText:Ae=c.dateRangeText,...F}=u;ne(`AppFilterBar`,F),f(`AppFilterBar`,`size`,D,pe);let I=D===`md`,je={range:Ae,from:Oe,until:ke},L=se(ue,de,()=>!1),R=m(null),z=m(null),Me=e=>{let t=R.current,n=z.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`))},B=ae(),[V,H]=oe({}),U=m(y);for(let e of d)f(`AppFilterBar`,`facets[].type`,e.type,fe);for(let e of d){if(e.source&&e.type!==`enum`&&e.type!==`multiEnum`)throw _e(e);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 W=d.filter(e=>!he(e)),G=W.flatMap(e=>ve(e,y[e.key],je).map(t=>({...t,facet:e}))),K=W.filter(e=>!e.required&&t(e,y[e.key])),q=T||L?0:Math.max(0,C),J=W.slice(q),Ne=J.filter(e=>K.includes(e)).length,Y=!T&&J.length>0;p(()=>{if(!Y)return;let e=e=>{let t=R.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)}},[Y]),p(()=>{let e=U.current;U.current=y,H(t=>{let n=Object.entries(t).filter(([t])=>ge(e[t],y[t]));return n.length===Object.keys(t).length?t:Object.fromEntries(n)})},[y]);let X=e=>E&&!T&&(e.type===`text`||e.type===`dateRange`),Z=e=>X(e)&&Object.hasOwn(V,e.key)?V[e.key]:y[e.key],Q=e=>t=>X(e)?H(n=>({...n,[e.key]:t})):x(e.key,t),Pe=e=>{let t=Object.entries(e);if(t.length!==0){if(S)S(e);else for(let[e,n]of t)x(e,n)}},Fe=()=>{Pe(V),H({})},Ie=e=>{re(e.nativeEvent)&&Fe()},Le=e=>{e.preventDefault(),Fe()},Re=(e,t)=>e.type===`text`&&X(e)?/* @__PURE__ */ h(`span`,{onKeyDownCapture:Ie,children:t}):t,ze=(e,t)=>w?/* @__PURE__ */ g(`div`,{className:`wui-filter-popover-field wui-filter-facet`,children:[/* @__PURE__ */ h(`span`,{className:`label`,"aria-hidden":`true`,children:e.label}),t]},e.key):t,Be=e=>ze(e,/* @__PURE__ */ h(ie,{children:Re(e,/* @__PURE__ */ h(N,{facet:e,value:Z(e),onChange:Q(e),medium:I,anyLabel:P}))},e.key)),$=e=>/* @__PURE__ */ g(`div`,{className:`wui-filter-popover-field`,children:[/* @__PURE__ */ h(`span`,{className:`label`,"aria-hidden":`true`,children:e.label}),Re(e,/* @__PURE__ */ h(N,{facet:e,value:Z(e),onChange:Q(e),floating:!0,medium:I,anyLabel:P}))]},e.key),Ve=(e,t)=>t>0&&/* @__PURE__ */ h(`span`,{className:e,children:` (${t})`}),He=e=>/* @__PURE__ */ h(s,{size:`sm`,label:`${e.facet.label}: ${e.text}`,removeLabel:v(De,{facet:e.facet.label,value:e.text}),onRemove:()=>x(e.facet.key,e.clear()),className:!T&&W.indexOf(e.facet)<q?`wui-filter-chip-inline`:void 0},e.id),Ue=/* @__PURE__ */ h(o,{variant:`ghost`,size:I?void 0:`sm`,onClick:()=>{Pe(Object.fromEntries(K.map(t=>[t.key,e(t)]))),H({})},children:k});if(T){let e=G.slice(b),t=K.length;return/* @__PURE__ */ g(`div`,{className:`wui-filter-bar d-flex flex-wrap align-items-center gap-2${O?` ${O}`:``}`,...l,...F,children:[/* @__PURE__ */ g(`wui-filter-popover`,{class:`wui-filter-popover`,children:[/* @__PURE__ */ g(o,{variant:t>0?`outline`:`ghost`,size:I?void 0:`sm`,leftIcon:`filter`,className:`wui-filter-popover-trigger`,"aria-expanded":`false`,"aria-controls":B,"aria-label":t>0?v(j,{count:t}):void 0,children:[A,t>0&&/* @__PURE__ */ h(`span`,{className:`badge rounded-pill text-bg-primary ms-1`,children:t})]}),/* @__PURE__ */ g(`div`,{id:B,className:`wui-filter-popover-panel`,popover:`auto`,role:`dialog`,"aria-label":A,children:[/* @__PURE__ */ g(`div`,{className:`wui-filter-popover-head`,children:[/* @__PURE__ */ h(`span`,{className:`wui-filter-popover-title`,children:A}),/* @__PURE__ */ h(te,{label:M,id:`${B}-pin`})]}),/* @__PURE__ */ h(`div`,{className:`wui-filter-popover-grid`,children:W.map($)}),/* @__PURE__ */ g(`div`,{className:`wui-filter-popover-foot`,children:[/* @__PURE__ */ h(`span`,{className:`wui-filter-popover-note`,children:Te}),t>0&&Ue]})]})]}),G.slice(0,b).map(He),e.length>0&&/* @__PURE__ */ g(`span`,{className:`chip chip-sm wui-filter-popover-more`,title:e.map(e=>`${e.facet.label}: ${e.text}`).join(`, `),children:[`+`,e.length]})]})}let We=`wui-filter-bar d-flex flex-wrap align-items-center gap-2${L&&Y?` wui-filter-bar--folded`:``}`,Ge=e=>`${e}${O?` ${O}`:``}`,Ke=/* @__PURE__ */ g(ce,{children:[W.slice(0,q).map(Be),Y&&/* @__PURE__ */ g(`details`,{ref:R,className:`wui-filter-more`,children:[/* @__PURE__ */ g(`summary`,{className:`btn btn-outline-primary${I?``:` btn-sm`} wui-filter-more-trigger`,onClick:Me,children:[/* @__PURE__ */ h(ee,{name:`filter`,size:14,className:`me-2`}),A,Ve(`wui-filter-count-desktop`,Ne),Ve(`wui-filter-count-phone`,K.length)]}),/* @__PURE__ */ g(`div`,{ref:z,className:`wui-filter-more-panel`,children:[/* @__PURE__ */ h(`div`,{className:`wui-filter-more-head`,children:A}),J.map($)]})]}),G.map(He),K.length>0&&Ue]});return!E||!W.some(e=>e.type===`text`||e.type===`dateRange`)?/* @__PURE__ */ h(`div`,{className:Ge(We),...l,...F,children:Ke}):/* @__PURE__ */ g(`div`,{className:Ge(`wui-filter-form d-flex flex-wrap align-items-center gap-2`),...l,...F,children:[/* @__PURE__ */ h(`div`,{className:We,children:Ke}),/* @__PURE__ */ h(o,{type:`submit`,size:I?void 0:`sm`,onClick:Le,children:Ee})]})}function N({facet:e,value:t,onChange:n,floating:r=!1,medium:a=!1,anyLabel:o}){let s=i(`filterBar`,_);if(e.type===`enum`){let i=e.options??[];return!e.source&&(e.required?i.length<=x:i.length<x)?/* @__PURE__ */ h(u,{label:e.label,name:e.key,size:a?`md`:`sm`,value:w(e,t),onChange:n,options:e.required?i:[{value:``,label:e.allLabel||s.allLabel},...i]}):/* @__PURE__ */ h(d,{mode:e.source?`search`:void 0,"aria-label":e.label,name:e.key,placeholder:r?o:e.label,clearable:!e.required,size:a?void 0:`sm`,value:w(e,t),onChange:n,options:i,source:e.source})}return e.type===`multiEnum`?/* @__PURE__ */ h(d,{mode:`multiple`,"aria-label":e.label,name:e.key,placeholder:r?o:e.label,size:a?void 0:`sm`,collapseChips:!0,value:T(e,t),onChange:n,options:e.options??[],source:e.source}):e.type===`dateRange`?/* @__PURE__ */ h(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:E(e,t).from,end:E(e,t).to,onChange:e=>n({from:e.start??``,to:e.end??``})}):/* @__PURE__ */ h(l,{ariaLabel:e.label,name:e.key,placeholder:e.label,size:a?void 0:`sm`,value:w(e,t),onChange:n})}export{M as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{devWarn as e}from"../lib/devWarn.js";import t from"../lib/FieldMessage.js";import{useFieldError as ee}from"../lib/formFields.js";import te from"../lib/useElementEntry.js";import n from"../lib/useWuiText.js";import{splitMarkerProps as r}from"../lib/wuiMarker.js";import i from"./AppInfoTip.js";import a from"./AppRequiredMark.js";import o from"./assertValidValue.js";import s from"./textOf.js";import c from"./useWuiControl.js";import l from"./warnUnknownProps.js";import{cloneElement as u,forwardRef as d,useId as f}from"react";import{jsx as p,jsxs as m}from"react/jsx-runtime";import{DATE_PICKER_TEXT as h}from"@webority/ui-elements/text";var g=[`sm`,`md`,`lg`,`xl`],_=()=>import(`@webority/ui-elements/elements/datepicker`),v=d(function(d,v){let ne=te(`wui-datepicker`,_),y=n(`datePicker`,h),{marker:b,props:x}=r(`AppMonthPicker`,d),{value:S,onChange:C,label:w,required:T=!1,optional:E=!1,optionalLabel:D=y.optionalLabel,helperText:O,error:k,name:A,min:j,max:M,placeholder:N=y.monthPlaceholder,disabled:P,readOnly:F=!1,loading:re=!1,defaultValue:I,help:L,helpLabel:R=y.helpLabel,size:z,displayFormat:B,id:V,ariaLabel:H,"aria-invalid":U,className:W=``,fieldClassName:G=``,...K}=x,q=ee(A),J=k??q;l(`AppMonthPicker`,K),o(`AppMonthPicker`,`size`,z,g),typeof B==`string`&&B!==``&&/DD|YYYY|YY/.test(B)&&e(`[@webority/ui-react] <AppMonthPicker> displayFormat "${B}" uses uppercase year or day tokens, which print as written; the month tokens are yyyy, MMMM, MMM and MM.`);let Y=f(),X=V||Y,{setRef:ie}=c({ready:ne,ref:v,value:S??(I===void 0?``:void 0),defaultValue:I,onChange:C}),ae=!w&&!J&&!O,Z=J?`${X}-error`:void 0,Q=O?`${X}-hint`:void 0,oe=Z||Q,$=/* @__PURE__ */ p(`wui-datepicker`,{ref:ie,id:X,name:A,value:(S??I)||void 0,min:j,max:M,placeholder:N,size:z||void 0,"display-format":B||void 0,"aria-label":H||s(w)||void 0,"aria-describedby":oe,"aria-invalid":U??(J?`true`:void 0),disabled:P?``:void 0,readonly:F?``:void 0,loading:re?``:void 0,required:T?``:void 0,className:W||void 0,...K,mode:`month`});return ae?u($,b):/* @__PURE__ */ m(`div`,{...b,className:`field${G?` ${G}`:``}`,children:[w&&/* @__PURE__ */ m(`label`,{className:`label`,htmlFor:X,children:[w,E&&!T&&/* @__PURE__ */ p(`span`,{className:`label-optional`,children:` ${D}`}),T&&/* @__PURE__ */ p(a,{}),L&&/* @__PURE__ */ p(i,{label:R,children:L})]}),$,/* @__PURE__ */ p(t,{error:J,hint:O,errorId:Z,hintId:Q})]})});export{v as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{devWarn as e}from"../lib/devWarn.js";import t from"../lib/FieldMessage.js";import{FIELD_SIZES as n}from"../lib/fieldState.js";import{loadFlagStyles as r}from"../lib/flagStyles.js";import{useFieldError as ee}from"../lib/formFields.js";import te from"../lib/useElementEntry.js";import ne from"../lib/useWuiText.js";import{splitMarkerProps as re}from"../lib/wuiMarker.js";import ie from"./AppInfoTip.js";import
|
|
1
|
+
import{devWarn as e}from"../lib/devWarn.js";import t from"../lib/FieldMessage.js";import{FIELD_SIZES as n}from"../lib/fieldState.js";import{loadFlagStyles as r}from"../lib/flagStyles.js";import{useFieldError as ee}from"../lib/formFields.js";import te from"../lib/useElementEntry.js";import ne from"../lib/useWuiText.js";import{splitMarkerProps as re}from"../lib/wuiMarker.js";import ie from"./AppInfoTip.js";import ae from"./AppRequiredMark.js";import i from"./assertValidValue.js";import a from"./textOf.js";import oe from"./useNodeLabels.js";import se,{optionsEqual as ce}from"./useWuiControl.js";import le from"./warnUnknownProps.js";import{forwardRef as o,useEffect as ue,useId as de,useLayoutEffect as s,useMemo as fe,useRef as c}from"react";import{Fragment as pe,jsx as l,jsxs as u}from"react/jsx-runtime";import{SELECT_TEXT as me,fillText as he}from"@webority/ui-elements/text";var ge=[`single`,`multiple`,`search`,`tag`,`country`],_e=[`comfortable`,`compact`],ve=[`off`,`border`,`above`],ye=[],d=[],be=()=>import(`@webority/ui-elements/elements/select`),xe=e=>e===`multiple`||e===`tag`,f=e=>e!=null&&e!==``,p=e=>{throw Error(`<AppSelect> controlOnly draws no field, so it takes no ${e}; draw the label or message on the page.`)},Se=(e,t)=>{let n=t??``;String(e.value??``)!==String(n)&&(e.value=n)},Ce=(e,t)=>{let n=Array.isArray(t)?t:d,r=Array.isArray(e.value)?e.value:d;n.length===r.length&&n.every((e,t)=>e===r[t])||(e.value=n)},we=(e,t)=>({...e,label:t}),Te=e=>Array.isArray(e)?e.join(`,`):e,m=o(function(o,m){let h=te(`wui-select`,be),{marker:g,props:Ee}=re(`AppSelect`,o),_=ne(`select`,me),{mode:v=`single`,density:y=`comfortable`,size:b,value:De,defaultValue:Oe,onChange:ke,options:x=ye,loadOptions:S,remote:C=!1,onSearch:Ae,source:w,validate:T,placeholder:je,searchPlaceholder:Me,emptyText:Ne,searchable:E,clearable:Pe=!1,openOnHover:Fe=!1,icon:Ie,valuePrefix:D,prefix:O,suffix:k,floatingLabel:A=`off`,disabled:Le,readOnly:Re=!1,loading:ze=!1,open:Be,label:j,required:M=!1,optional:Ve=!1,optionalLabel:He=_.optionalLabel,error:Ue,helperText:N,help:P,helpLabel:We=_.helpLabel,id:Ge,name:F,minChars:I,debounce:L,allowCustom:Ke=!1,addLabel:qe,searchingText:Je,hintText:Ye,valueLabel:Xe,valueAvatar:Ze,valueInitials:Qe,maxTags:R,allowDuplicates:$e=!1,separators:et,pattern:tt,invalidMessage:nt,createLabel:rt,collapseChips:it=!1,selectedText:at,clearAllLabel:ot,countries:st,suggested:ct,suggestedLabel:lt,allCountriesLabel:ut,recentsKey:dt,recentsLimit:z,recentsLabel:ft,className:pt=``,fieldClassName:B=``,controlOnly:V=!1,"aria-label":mt,"aria-labelledby":ht,"aria-describedby":gt,"aria-invalid":_t,...H}=Ee,vt=ee(F),U=Ue??vt;le(`AppSelect`,H),i(`AppSelect`,`mode`,v,ge),i(`AppSelect`,`density`,y,_e),i(`AppSelect`,`size`,b,n);let W=xe(v);if(i(`AppSelect`,`floatingLabel`,A,W?[`off`]:ve),w&&(C||S))throw Error(`<AppSelect> source answers each query from the server, so it takes no remote or loadOptions; drop one of them.`);let G=c(!1);W&&(O!=null||k!=null)&&!G.current&&(G.current=!0,e(`AppSelect: prefix and suffix are not drawn in mode="${v}"; they are ignored.`));let yt=de(),K=c(!1);ue(()=>{v===`country`&&r()},[v]);let{setRef:bt,innerRef:q}=se({ready:h,ref:m,value:De??(Oe===void 0?W?d:``:void 0),defaultValue:Oe,writeValue:W?Ce:Se,on:{change:e=>{let t=e.currentTarget.value,n={isCustom:!!e.detail?.isCustom};switch(o.mode){case`multiple`:Array.isArray(t)&&o.onChange?.(t);break;case`tag`:Array.isArray(t)&&o.onChange?.(t,n);break;case`search`:typeof t==`string`&&o.onChange?.(t,n);break;default:typeof t==`string`&&o.onChange?.(t)}},search:e=>{C&&typeof S!=`function`&&Ae?.(e.detail.query,{seq:e.detail.seq})}}}),xt=fe(()=>typeof S==`function`?(e,t)=>new Promise(n=>n(S(e,t))).then(e=>(K.current=!0,e),e=>{throw K.current=!0,e}):null,[S]),{portal:St,toElementOptions:J}=oe(x),Y=c({el:null,options:null,map:null});s(()=>{let e=q.current;if(!e||!h||Y.current.el===e&&Y.current.options===x&&Y.current.map===J||(Y.current={el:e,options:x,map:J},S&&K.current))return;let t=J(x,we);ce(t,e.options)||(e.options=t)}),s(()=>{let e=q.current;if(!e||!h)return;e.loadOptions!==xt&&(e.loadOptions=xt);let t=typeof T==`function`?T:null;e.validate!==t&&(e.validate=t)}),s(()=>{q.current?.toggleAttribute(`loading`,!!ze)});let X=Ge||yt,Z=!W&&A!==`off`&&j,Ct=U&&X?`${X}-error`:void 0,wt=N&&X?`${X}-hint`:void 0,Tt=Ct||wt||gt;ue(()=>{let e=q.current;e&&(D==null||D===``?e.removeAttribute(`prefix`):e.setAttribute(`prefix`,D))},[D,q]);let Et=!W&&!Z&&(O!=null||k!=null),Dt=v===`multiple`||v===`tag`||v===`country`;if(V&&(f(j)&&p(`label`),f(U)&&p(`error`),f(N)&&p(`helperText`),f(B)&&p(`fieldClassName`),Dt))throw Error(`<AppSelect> controlOnly draws no field, so it takes no mode="${v}"; that mode always draws its field.`);let Q=V||!Dt&&!j&&!U&&!N&&!B,Ot=a(j).trim(),kt=Ot&&(v===`single`||v===`multiple`||v===`search`)?he(_.defaultSearchPlaceholder,{labelText:Ot}):void 0,At=/* @__PURE__ */ l(`wui-select`,{"aria-label":mt||a(j)||void 0,"aria-labelledby":ht||void 0,"aria-describedby":Tt||void 0,"aria-invalid":_t??(U?`true`:void 0),ref:bt,id:X,name:F,mode:v,density:y===`compact`?`compact`:void 0,placeholder:Z?` `:je||void 0,"search-placeholder":Me||kt,"empty-text":Ne||void 0,searchable:E===void 0?void 0:E?`true`:`false`,clearable:Pe?``:void 0,"open-on-hover":Fe?``:void 0,size:b!==`md`&&n.includes(b??``)?b:void 0,icon:Ie||void 0,disabled:Le?``:void 0,readonly:Re?``:void 0,open:Be?``:void 0,required:M?``:void 0,"min-chars":I==null?void 0:String(I),debounce:L==null?void 0:String(L),remote:C?``:void 0,source:w||void 0,"allow-custom":Ke?``:void 0,"add-label":qe||void 0,"searching-text":Je||void 0,"hint-text":Ye||void 0,"value-label":Xe||void 0,"value-avatar":Ze||void 0,"value-initials":Qe||void 0,"max-tags":R==null?void 0:String(R),"allow-duplicates":$e?``:void 0,separators:et||void 0,pattern:tt||void 0,"invalid-message":nt||void 0,"create-label":rt||void 0,"collapse-chips":it?``:void 0,"selected-text":at||void 0,"clear-all-label":ot||void 0,countries:Te(st)||void 0,suggested:Te(ct)||void 0,"suggested-label":lt||void 0,"all-countries-label":ut||void 0,"recents-key":dt||void 0,"recents-limit":z==null?void 0:String(z),"recents-label":ft||void 0,className:pt||void 0,...Q&&!Et?g:null,...H}),$=/* @__PURE__ */ u(pe,{children:[At,St]}),jt=Et?/* @__PURE__ */ u(`div`,{...Q?g:null,className:`input-affixed`,children:[O!=null&&/* @__PURE__ */ l(`span`,{className:`affix affix-pre`,children:O}),$,k!=null&&/* @__PURE__ */ l(`span`,{className:`affix affix-suf`,children:k})]}):$;if(Q)return jt;let Mt=[`field`,B].filter(Boolean).join(` `);return/* @__PURE__ */ u(`div`,{...g,className:Mt,children:[j&&!Z&&/* @__PURE__ */ u(`label`,{className:`label`,htmlFor:X,children:[j,Ve&&!M&&/* @__PURE__ */ l(`span`,{className:`label-optional`,children:` ${He}`}),M&&/* @__PURE__ */ l(ae,{}),P&&/* @__PURE__ */ l(ie,{label:We,children:P})]}),Z?/* @__PURE__ */ u(`div`,{className:A===`above`?`field-float wui-float-above`:`field-float`,children:[$,/* @__PURE__ */ u(`label`,{className:`float-label`,htmlFor:X,children:[j,Ve&&!M&&/* @__PURE__ */ l(`span`,{className:`label-optional`,children:` ${He}`}),M&&/* @__PURE__ */ l(ae,{})]})]}):jt,/* @__PURE__ */ l(t,{error:U,hint:N,errorId:Ct,hintId:wt})]})});export{m as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{linkTarget as e}from"../lib/linkTarget.js";import{TargetLink as t}from"../lib/TargetLink.js";import n from"../lib/useWuiText.js";import{splitMarkerProps as r}from"../lib/wuiMarker.js";import i from"./AppRecordPager.js";import a from"./AppShortcutLegend.js";import o from"./assertValidValue.js";import s from"./warnUnknownProps.js";import{listKeys as c,selectKey as l,shortcutKey as ee}from"@webority/ui-elements/helpers";import{useEffect as te,useMemo as u,useRef as d}from"react";import{Fragment as ne,jsx as f,jsxs as p}from"react/jsx-runtime";import{KBD_TEXT as m,SPLIT_VIEW_TEXT as re,fillText as h}from"@webority/ui-elements/text";var g={sm:576,md:768,lg:992,xl:1200,xxl:1400},ie=Object.keys(g),_=[3,4,5,6,7,8],ae=Array.from({length:6},(e,t)=>`skeleton-placeholder-${t}`),v=`.wui-split-items > .wui-split-item > .wui-split-link`,y=(e,t)=>e!=null&&String(e)===String(t),oe=e=>{let t=window.matchMedia?.(`(min-width: ${g[e]}px)`);return!t||t.matches},se=(e,t)=>typeof e==`string`||typeof e==`number`?String(e):t;function b(b){let{marker:ce,props:le}=r(`AppSplitView`,b),x=n(`splitView`,re),S=n(`kbd`,m),{items:C=[],currentKey:w,onSelect:T,selectable:E=!1,selectedKeys:D,onToggle:ue,onToggleAll:de,bulkActions:fe,header:O,chips:k,pane:pe,paneHeader:A,pager:me=!0,shortcuts:j,shortcutsEnabled:M=!0,empty:N=x.empty,loading:P=!1,listWidth:F=5,stackBelow:I=`xl`,linkComponent:L,loadingLabel:R=x.loadingLabel,itemsLabel:z=x.itemsLabel,selectItemLabel:he=x.selectItemLabel,selectAllLabel:B=x.selectAllLabel,readingPaneLabel:ge=x.readingPaneLabel,previousItemLabel:_e=x.previousItemLabel,nextItemLabel:ve=x.nextItemLabel,openLabel:ye=x.openLabel,moveLabel:be=x.moveLabel,selectedLabel:xe=x.selectedLabel,untitledItemLabel:Se=x.untitledItemLabel,className:Ce=``,...V}=le,H=u(()=>new Set(D),[D]);s(`AppSplitView`,V),o(`AppSplitView`,`stackBelow`,I,ie),o(`AppSplitView`,`listWidth`,F,_);let U=g[I]?I:`xl`,we=_.includes(F)?F:5,W=d(null),Te=w!=null,G=E?H?.size??0:0,K=G>0,q=E&&C.length>0&&C.every(e=>H?.has(e.key)),Ee=E&&!q&&C.some(e=>H?.has(e.key)),De=e=>{e&&(e.indeterminate=Ee)},J=d(
|
|
1
|
+
import{linkTarget as e}from"../lib/linkTarget.js";import{TargetLink as t}from"../lib/TargetLink.js";import n from"../lib/useWuiText.js";import{splitMarkerProps as r}from"../lib/wuiMarker.js";import i from"./AppRecordPager.js";import a from"./AppShortcutLegend.js";import o from"./assertValidValue.js";import s from"./warnUnknownProps.js";import{listKeys as c,selectKey as l,shortcutKey as ee}from"@webority/ui-elements/helpers";import{useEffect as te,useMemo as u,useRef as d}from"react";import{Fragment as ne,jsx as f,jsxs as p}from"react/jsx-runtime";import{KBD_TEXT as m,SPLIT_VIEW_TEXT as re,fillText as h}from"@webority/ui-elements/text";var g={sm:576,md:768,lg:992,xl:1200,xxl:1400},ie=Object.keys(g),_=[3,4,5,6,7,8],ae=Array.from({length:6},(e,t)=>`skeleton-placeholder-${t}`),v=`.wui-split-items > .wui-split-item > .wui-split-link`,y=(e,t)=>e!=null&&String(e)===String(t),oe=e=>{let t=window.matchMedia?.(`(min-width: ${g[e]}px)`);return!t||t.matches},se=(e,t)=>typeof e==`string`||typeof e==`number`?String(e):t;function b(b){let{marker:ce,props:le}=r(`AppSplitView`,b),x=n(`splitView`,re),S=n(`kbd`,m),{items:C=[],currentKey:w,onSelect:T,selectable:E=!1,selectedKeys:D,onToggle:ue,onToggleAll:de,bulkActions:fe,header:O,chips:k,pane:pe,paneHeader:A,pager:me=!0,shortcuts:j,shortcutsEnabled:M=!0,empty:N=x.empty,loading:P=!1,listWidth:F=5,stackBelow:I=`xl`,linkComponent:L,loadingLabel:R=x.loadingLabel,itemsLabel:z=x.itemsLabel,selectItemLabel:he=x.selectItemLabel,selectAllLabel:B=x.selectAllLabel,readingPaneLabel:ge=x.readingPaneLabel,previousItemLabel:_e=x.previousItemLabel,nextItemLabel:ve=x.nextItemLabel,openLabel:ye=x.openLabel,moveLabel:be=x.moveLabel,selectedLabel:xe=x.selectedLabel,untitledItemLabel:Se=x.untitledItemLabel,className:Ce=``,...V}=le,H=u(()=>new Set(D),[D]);s(`AppSplitView`,V),o(`AppSplitView`,`stackBelow`,I,ie),o(`AppSplitView`,`listWidth`,F,_);let U=g[I]?I:`xl`,we=_.includes(F)?F:5,W=d(null),Te=w!=null,G=E?H?.size??0:0,K=G>0,q=E&&C.length>0&&C.every(e=>H?.has(e.key)),Ee=E&&!q&&C.some(e=>H?.has(e.key)),De=e=>{e&&(e.indeterminate=Ee)},J=d(w);te(()=>{J.current!==w&&(J.current=w,w!=null&&W.current?.querySelector(`.wui-split-link[aria-current="true"]`)?.scrollIntoView?.({block:`nearest`}))},[w]);let Y=(e,t)=>{t.button>0||t.ctrlKey||t.metaKey||t.shiftKey||t.altKey||T&&(!e.href||oe(U))&&(t.preventDefault(),T(e.key))},X=e=>{let t=[...W.current?.querySelectorAll(v)??[]];t[t.findIndex(e=>e.getAttribute(`aria-current`)===`true`)+e]?.click()},Oe=[`wui-split-view`,Te?`wui-split-reading`:``,Ce].filter(Boolean).join(` `),ke=E?[...c(),l()]:c(),Ae=/* @__PURE__ */ new Set([`J`,`K`,`Enter`,`?`,...E?[`X`]:[]]),je=[...ke,...(j??[]).filter(e=>!Ae.has(ee(e.key))).map(e=>({key:e.key,label:e.label,onPress:()=>e.onPress?.(w)}))],Z=C.findIndex(e=>y(w,e.key)),Q=me&&!P&&C.length>0?/* @__PURE__ */ f(i,{"data-split-pager":``,index:Z>=0?Z+1:void 0,total:C.length,onPrev:()=>X(-1),onNext:()=>X(1),prevLabel:_e,nextLabel:ve}):null,Me=n=>{let r=y(w,n.key),i=E&&!!H?.has(n.key),a=n.badge!==void 0&&n.badge!==null&&n.badge!==``,o=e(L,{href:n.href}),s=/* @__PURE__ */ p(ne,{children:[/* @__PURE__ */ p(`span`,{className:`wui-split-item-main`,children:[/* @__PURE__ */ f(`span`,{className:`wui-split-item-title`,children:n.title}),n.meta!==void 0&&n.meta!==null&&/* @__PURE__ */ f(`span`,{className:`wui-split-item-meta`,children:n.meta})]}),(n.trailing||a)&&/* @__PURE__ */ p(`span`,{className:`wui-split-item-end`,children:[n.trailing,a&&/* @__PURE__ */ f(`span`,{className:`wui-split-badge`,children:n.badge})]})]});return/* @__PURE__ */ p(`li`,{className:[`wui-split-item`,r?`is-active`:``,i?`is-selected`:``].filter(Boolean).join(` `),"data-key":n.key,children:[E&&/* @__PURE__ */ f(`input`,{type:`checkbox`,className:`wui-check wui-split-check`,checked:i,onChange:()=>ue?.(n.key),"aria-label":h(he,{title:se(n.title,Se)})}),n.href?/* @__PURE__ */ f(t,{link:o,className:`wui-split-link`,"aria-current":r?`true`:void 0,onClick:e=>Y(n,e),children:s}):/* @__PURE__ */ f(`button`,{type:`button`,className:`wui-split-link`,"aria-current":r?`true`:void 0,onClick:e=>Y(n,e),children:s})]},n.key)},$;return $=P?/* @__PURE__ */ p(`div`,{className:`wui-split-items`,"aria-busy":`true`,tabIndex:0,children:[/* @__PURE__ */ f(`span`,{className:`visually-hidden`,children:R}),ae.map(e=>/* @__PURE__ */ p(`div`,{className:`wui-split-skeleton`,"aria-hidden":`true`,children:[/* @__PURE__ */ f(`span`,{className:`skeleton wui-split-skeleton-title`}),/* @__PURE__ */ f(`span`,{className:`skeleton wui-split-skeleton-meta`})]},e))]}):C.length?/* @__PURE__ */ f(`ul`,{className:`wui-split-items`,"aria-label":z,children:C.map(Me)}):/* @__PURE__ */ f(`div`,{className:`wui-split-empty`,children:N}),/* @__PURE__ */ p(`div`,{ref:W,className:Oe,"data-stack-below":U,"data-list-width":we,"data-shortcut-scope":M?``:void 0,...ce,...V,children:[/* @__PURE__ */ p(`div`,{className:`wui-split-list`,children:[(O||E)&&/* @__PURE__ */ p(`div`,{className:`wui-split-head`,children:[E&&/* @__PURE__ */ f(`input`,{ref:De,type:`checkbox`,className:`wui-check wui-split-all`,checked:q,onChange:e=>de?.(e.target.checked),"aria-label":B}),/* @__PURE__ */ f(`div`,{className:`wui-split-head-main`,hidden:K,children:O}),E&&/* @__PURE__ */ p(`div`,{className:`wui-split-head-bulk`,hidden:!K,children:[/* @__PURE__ */ f(`span`,{className:`wui-split-count`,"aria-live":`polite`,children:h(xe,{count:G})}),fe]})]}),k&&/* @__PURE__ */ f(`div`,{className:`wui-split-chips`,children:k}),$,M&&/* @__PURE__ */ p(`div`,{className:`wui-split-legend`,children:[/* @__PURE__ */ p(`span`,{children:[/* @__PURE__ */ f(`kbd`,{className:`wui-kbd`,children:`J`}),` `,/* @__PURE__ */ f(`kbd`,{className:`wui-kbd`,children:`K`}),` ${be}`]}),/* @__PURE__ */ p(`span`,{children:[/* @__PURE__ */ f(`kbd`,{className:`wui-kbd`,children:S.enterLabel}),` ${ye}`]}),/* @__PURE__ */ f(a,{items:v,shortcuts:je})]})]}),/* @__PURE__ */ p(`div`,{className:`wui-split-pane`,children:[(A||Q)&&/* @__PURE__ */ p(`div`,{className:`wui-split-pane-head`,children:[A,Q]}),/* @__PURE__ */ f(`section`,{className:`wui-split-pane-body`,"aria-label":ge,tabIndex:0,children:pe})]})]})}export{b as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{devWarn as e}from"../lib/devWarn.js";import t from"../lib/FieldMessage.js";import{useFieldError as ee}from"../lib/formFields.js";import te from"../lib/useElementEntry.js";import n from"../lib/useWuiText.js";import{splitMarkerProps as r}from"../lib/wuiMarker.js";import i from"./AppInfoTip.js";import a from"./AppRequiredMark.js";import o from"./assertValidValue.js";import s from"./textOf.js";import c from"./useWuiControl.js";import l from"./warnUnknownProps.js";import{cloneElement as u,forwardRef as d,useId as f}from"react";import{jsx as p,jsxs as m}from"react/jsx-runtime";import{DATE_PICKER_TEXT as h}from"@webority/ui-elements/text";var g=[`sm`,`md`,`lg`,`xl`],_=()=>import(`@webority/ui-elements/elements/datepicker`),v=d(function(d,v){let ne=te(`wui-datepicker`,_),y=n(`datePicker`,h),{marker:b,props:x}=r(`AppYearPicker`,d),{value:S,onChange:C,label:w,required:T=!1,optional:E=!1,optionalLabel:D=y.optionalLabel,helperText:O,error:k,name:A,min:j,max:M,placeholder:N=y.yearPlaceholder,disabled:P,readOnly:F=!1,loading:re=!1,defaultValue:I,help:L,helpLabel:R=y.helpLabel,size:z,displayFormat:B,id:V,ariaLabel:H,"aria-invalid":U,className:W=``,fieldClassName:G=``,...K}=x,q=ee(A),J=k??q;l(`AppYearPicker`,K),o(`AppYearPicker`,`size`,z,g),typeof B==`string`&&B!==``&&/DD|YYYY|YY/.test(B)&&e(`[@webority/ui-react] <AppYearPicker> displayFormat "${B}" uses uppercase year or day tokens, which print as written; the year token is yyyy.`);let Y=f(),X=V||Y,{setRef:ie}=c({ready:ne,ref:v,value:S??(I===void 0?``:void 0),defaultValue:I,onChange:C}),ae=!w&&!J&&!O,Z=J?`${X}-error`:void 0,Q=O?`${X}-hint`:void 0,oe=Z||Q,$=/* @__PURE__ */ p(`wui-datepicker`,{ref:ie,id:X,name:A,value:(S??I)||void 0,min:j,max:M,placeholder:N,size:z||void 0,"display-format":B||void 0,"aria-label":H||s(w)||void 0,"aria-describedby":oe,"aria-invalid":U??(J?`true`:void 0),disabled:P?``:void 0,readonly:F?``:void 0,loading:re?``:void 0,required:T?``:void 0,className:W||void 0,...K,mode:`year`});return ae?u($,b):/* @__PURE__ */ m(`div`,{...b,className:`field${G?` ${G}`:``}`,children:[w&&/* @__PURE__ */ m(`label`,{className:`label`,htmlFor:X,children:[w,E&&!T&&/* @__PURE__ */ p(`span`,{className:`label-optional`,children:` ${D}`}),T&&/* @__PURE__ */ p(a,{}),L&&/* @__PURE__ */ p(i,{label:R,children:L})]}),$,/* @__PURE__ */ p(t,{error:J,hint:O,errorId:Z,hintId:Q})]})});export{v as default};
|
package/dist/guidance.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"format": "webority-guidance/1",
|
|
3
3
|
"package": {
|
|
4
4
|
"name": "@webority/ui-react",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.170.0"
|
|
6
6
|
},
|
|
7
7
|
"components": [
|
|
8
8
|
{
|
|
@@ -5336,6 +5336,96 @@
|
|
|
5336
5336
|
]
|
|
5337
5337
|
}
|
|
5338
5338
|
},
|
|
5339
|
+
{
|
|
5340
|
+
"name": "AppMonthPicker",
|
|
5341
|
+
"usage": {
|
|
5342
|
+
"when": [
|
|
5343
|
+
"Capturing a single calendar month: billing month, reporting period, expiry month.",
|
|
5344
|
+
"You need one consistent month picker across every browser and both surfaces.",
|
|
5345
|
+
"Restricting selection to a valid window with min / max."
|
|
5346
|
+
],
|
|
5347
|
+
"whenNot": [
|
|
5348
|
+
{
|
|
5349
|
+
"text": "You need a full calendar date.",
|
|
5350
|
+
"instead": "AppDatePicker"
|
|
5351
|
+
},
|
|
5352
|
+
{
|
|
5353
|
+
"text": "You are capturing a start-and-end range of months or dates.",
|
|
5354
|
+
"instead": "AppDateRangePicker"
|
|
5355
|
+
},
|
|
5356
|
+
{
|
|
5357
|
+
"text": "The value is free text, not a month.",
|
|
5358
|
+
"instead": "AppInput"
|
|
5359
|
+
},
|
|
5360
|
+
{
|
|
5361
|
+
"text": "You are picking from a fixed list of labels.",
|
|
5362
|
+
"instead": "AppSelect"
|
|
5363
|
+
}
|
|
5364
|
+
],
|
|
5365
|
+
"do": [
|
|
5366
|
+
{
|
|
5367
|
+
"title": "Give the month a visible label",
|
|
5368
|
+
"note": "A visible label above the field. The user knows what the month is for before opening it.",
|
|
5369
|
+
"example": [
|
|
5370
|
+
{
|
|
5371
|
+
"component": "AppMonthPicker",
|
|
5372
|
+
"props": {
|
|
5373
|
+
"id": "bp-good-month",
|
|
5374
|
+
"label": "Billing month",
|
|
5375
|
+
"value": "2026-07"
|
|
5376
|
+
}
|
|
5377
|
+
}
|
|
5378
|
+
]
|
|
5379
|
+
},
|
|
5380
|
+
{
|
|
5381
|
+
"title": "Set min and max bounds",
|
|
5382
|
+
"note": "min / max stop invalid months at the source, so the user can only pick a real one.",
|
|
5383
|
+
"example": [
|
|
5384
|
+
{
|
|
5385
|
+
"component": "AppMonthPicker",
|
|
5386
|
+
"props": {
|
|
5387
|
+
"value": "2026-07",
|
|
5388
|
+
"min": "2026-01",
|
|
5389
|
+
"max": "2026-12"
|
|
5390
|
+
}
|
|
5391
|
+
}
|
|
5392
|
+
]
|
|
5393
|
+
}
|
|
5394
|
+
],
|
|
5395
|
+
"dont": [
|
|
5396
|
+
{
|
|
5397
|
+
"title": "Give the month a visible label",
|
|
5398
|
+
"note": "Only a placeholder as the label, which vanishes the moment a month is picked.",
|
|
5399
|
+
"example": [
|
|
5400
|
+
{
|
|
5401
|
+
"component": "AppMonthPicker",
|
|
5402
|
+
"props": {
|
|
5403
|
+
"value": "",
|
|
5404
|
+
"placeholder": "Month"
|
|
5405
|
+
}
|
|
5406
|
+
}
|
|
5407
|
+
]
|
|
5408
|
+
},
|
|
5409
|
+
{
|
|
5410
|
+
"title": "Set min and max bounds",
|
|
5411
|
+
"note": "No bounds, then reject the month after submit. Constrain up front instead.",
|
|
5412
|
+
"example": [
|
|
5413
|
+
{
|
|
5414
|
+
"component": "AppMonthPicker",
|
|
5415
|
+
"props": {
|
|
5416
|
+
"value": "2030-01"
|
|
5417
|
+
}
|
|
5418
|
+
}
|
|
5419
|
+
]
|
|
5420
|
+
}
|
|
5421
|
+
],
|
|
5422
|
+
"a11y": [
|
|
5423
|
+
"The field label names the control through aria-label when it is a string, and ariaLabel overrides it.",
|
|
5424
|
+
"Helper text or error text is linked to the control with aria-describedby, and an error sets aria-invalid. A caller's aria-invalid takes its place.",
|
|
5425
|
+
"Required and disabled are set as native attributes on the control."
|
|
5426
|
+
]
|
|
5427
|
+
}
|
|
5428
|
+
},
|
|
5339
5429
|
{
|
|
5340
5430
|
"name": "AppNavList",
|
|
5341
5431
|
"usage": {
|
|
@@ -9995,6 +10085,96 @@
|
|
|
9995
10085
|
"Logos carry an empty alt, so each workspace name is read once."
|
|
9996
10086
|
]
|
|
9997
10087
|
}
|
|
10088
|
+
},
|
|
10089
|
+
{
|
|
10090
|
+
"name": "AppYearPicker",
|
|
10091
|
+
"usage": {
|
|
10092
|
+
"when": [
|
|
10093
|
+
"Capturing a single calendar year: financial year, reporting year, graduation year.",
|
|
10094
|
+
"You need one consistent year picker across every browser and both surfaces.",
|
|
10095
|
+
"Restricting selection to a valid window with min / max."
|
|
10096
|
+
],
|
|
10097
|
+
"whenNot": [
|
|
10098
|
+
{
|
|
10099
|
+
"text": "You need a month or a full calendar date.",
|
|
10100
|
+
"instead": "AppMonthPicker"
|
|
10101
|
+
},
|
|
10102
|
+
{
|
|
10103
|
+
"text": "You are capturing a start-and-end range of dates.",
|
|
10104
|
+
"instead": "AppDateRangePicker"
|
|
10105
|
+
},
|
|
10106
|
+
{
|
|
10107
|
+
"text": "The value is free text, not a year.",
|
|
10108
|
+
"instead": "AppInput"
|
|
10109
|
+
},
|
|
10110
|
+
{
|
|
10111
|
+
"text": "You are picking from a fixed list of labels.",
|
|
10112
|
+
"instead": "AppSelect"
|
|
10113
|
+
}
|
|
10114
|
+
],
|
|
10115
|
+
"do": [
|
|
10116
|
+
{
|
|
10117
|
+
"title": "Give the year a visible label",
|
|
10118
|
+
"note": "A visible label above the field. The user knows what the year is for before opening it.",
|
|
10119
|
+
"example": [
|
|
10120
|
+
{
|
|
10121
|
+
"component": "AppYearPicker",
|
|
10122
|
+
"props": {
|
|
10123
|
+
"id": "yp-good-year",
|
|
10124
|
+
"label": "Financial year",
|
|
10125
|
+
"value": "2026"
|
|
10126
|
+
}
|
|
10127
|
+
}
|
|
10128
|
+
]
|
|
10129
|
+
},
|
|
10130
|
+
{
|
|
10131
|
+
"title": "Set min and max bounds",
|
|
10132
|
+
"note": "min / max stop invalid years at the source, so the user can only pick a real one.",
|
|
10133
|
+
"example": [
|
|
10134
|
+
{
|
|
10135
|
+
"component": "AppYearPicker",
|
|
10136
|
+
"props": {
|
|
10137
|
+
"value": "2026",
|
|
10138
|
+
"min": "2024",
|
|
10139
|
+
"max": "2030"
|
|
10140
|
+
}
|
|
10141
|
+
}
|
|
10142
|
+
]
|
|
10143
|
+
}
|
|
10144
|
+
],
|
|
10145
|
+
"dont": [
|
|
10146
|
+
{
|
|
10147
|
+
"title": "Give the year a visible label",
|
|
10148
|
+
"note": "Only a placeholder as the label, which vanishes the moment a year is picked.",
|
|
10149
|
+
"example": [
|
|
10150
|
+
{
|
|
10151
|
+
"component": "AppYearPicker",
|
|
10152
|
+
"props": {
|
|
10153
|
+
"value": "",
|
|
10154
|
+
"placeholder": "Year"
|
|
10155
|
+
}
|
|
10156
|
+
}
|
|
10157
|
+
]
|
|
10158
|
+
},
|
|
10159
|
+
{
|
|
10160
|
+
"title": "Set min and max bounds",
|
|
10161
|
+
"note": "No bounds, then reject the year after submit. Constrain up front instead.",
|
|
10162
|
+
"example": [
|
|
10163
|
+
{
|
|
10164
|
+
"component": "AppYearPicker",
|
|
10165
|
+
"props": {
|
|
10166
|
+
"value": "2990"
|
|
10167
|
+
}
|
|
10168
|
+
}
|
|
10169
|
+
]
|
|
10170
|
+
}
|
|
10171
|
+
],
|
|
10172
|
+
"a11y": [
|
|
10173
|
+
"The field label names the control through aria-label when it is a string, and ariaLabel overrides it.",
|
|
10174
|
+
"Helper text or error text is linked to the control with aria-describedby, and an error sets aria-invalid. A caller's aria-invalid takes its place.",
|
|
10175
|
+
"Required and disabled are set as native attributes on the control."
|
|
10176
|
+
]
|
|
10177
|
+
}
|
|
9998
10178
|
}
|
|
9999
10179
|
]
|
|
10000
10180
|
}
|
|
@@ -109,8 +109,8 @@ export interface AppDataTableProps<Row> extends Omit<ComponentPropsWithoutRef<"d
|
|
|
109
109
|
wrapperClassName?: string | undefined;
|
|
110
110
|
style?: CSSProperties | undefined;
|
|
111
111
|
/**
|
|
112
|
-
* Row height:
|
|
113
|
-
* @default "
|
|
112
|
+
* Row height: cozy 48 px (the default), comfortable 72 px for reading-heavy pages, compact 40 px. Compact is one line per row and hides the identity subline.
|
|
113
|
+
* @default "cozy"
|
|
114
114
|
*/
|
|
115
115
|
density?: AppDataTableDensity | undefined;
|
|
116
116
|
/**
|
|
@@ -17,6 +17,8 @@ export interface AppFilterFacet {
|
|
|
17
17
|
label: string;
|
|
18
18
|
type: "enum" | "multiEnum" | "dateRange" | "text";
|
|
19
19
|
options?: AppFilterOption[] | undefined;
|
|
20
|
+
/** Enum and multiEnum facets: search the server for options (GET source?q=query). `options` then holds only the records of the current value, so a chosen option shows its label. */
|
|
21
|
+
source?: string | undefined;
|
|
20
22
|
allLabel?: string | undefined;
|
|
21
23
|
required?: boolean | undefined;
|
|
22
24
|
presets?: AppDateRangePickerProps["presets"] | undefined;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import type React from "react";
|
|
2
|
+
export interface AppMonthPickerProps extends Omit<React.HTMLAttributes<HTMLElement>, "defaultValue" | "onChange" | "placeholder"> {
|
|
3
|
+
/** The chosen month as YYYY-MM. */
|
|
4
|
+
value?: string | undefined;
|
|
5
|
+
/** Receives the chosen month as `YYYY-MM`, or `""` when it is cleared. */
|
|
6
|
+
onChange?: ((value: string) => void) | undefined;
|
|
7
|
+
/** The field label, shown above the control and used as its accessible name. */
|
|
8
|
+
label?: React.ReactNode | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* Marks the field required, with the required mark on the label.
|
|
11
|
+
* @default false
|
|
12
|
+
*/
|
|
13
|
+
required?: boolean | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* Ends the label with (optional) when the field is not required. Required wins when both are set.
|
|
16
|
+
* @default false
|
|
17
|
+
*/
|
|
18
|
+
optional?: boolean | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* Replaces the built-in English text, for other languages.
|
|
21
|
+
* @default "(optional)"
|
|
22
|
+
*/
|
|
23
|
+
optionalLabel?: string | undefined;
|
|
24
|
+
/** Helper text shown under the control. */
|
|
25
|
+
helperText?: string | undefined;
|
|
26
|
+
/** An error message shown under the control. */
|
|
27
|
+
error?: string | undefined;
|
|
28
|
+
/** The form field name the YYYY-MM month posts under. */
|
|
29
|
+
name?: string | undefined;
|
|
30
|
+
/** The earliest selectable month, as YYYY-MM. */
|
|
31
|
+
min?: string | undefined;
|
|
32
|
+
/** The latest selectable month, as YYYY-MM. */
|
|
33
|
+
max?: string | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Text shown in the field while no month is chosen.
|
|
36
|
+
* @default "Choose a month"
|
|
37
|
+
*/
|
|
38
|
+
placeholder?: string | undefined;
|
|
39
|
+
/** Disables the control. */
|
|
40
|
+
disabled?: boolean | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Shows the value but blocks editing. The value still posts.
|
|
43
|
+
* @default false
|
|
44
|
+
*/
|
|
45
|
+
readOnly?: boolean | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* Shows a busy state and blocks input while data loads.
|
|
48
|
+
* @default false
|
|
49
|
+
*/
|
|
50
|
+
loading?: boolean | undefined;
|
|
51
|
+
/** The starting month of an uncontrolled field, as YYYY-MM. */
|
|
52
|
+
defaultValue?: string | undefined;
|
|
53
|
+
/** The content of the info-tip beside the label, opened by a button. */
|
|
54
|
+
help?: React.ReactNode | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* The accessible name of the info-tip button.
|
|
57
|
+
* @default "More information"
|
|
58
|
+
*/
|
|
59
|
+
helpLabel?: string | undefined;
|
|
60
|
+
/** Control height tier, matching AppInput. */
|
|
61
|
+
size?: "sm" | "md" | "lg" | "xl" | undefined;
|
|
62
|
+
/**
|
|
63
|
+
* How the chosen month reads in the field, from the tokens yyyy, MMMM, MMM and MM (for example MM/yyyy). The onChange value stays YYYY-MM.
|
|
64
|
+
* @default "MMM yyyy"
|
|
65
|
+
*/
|
|
66
|
+
displayFormat?: string | undefined;
|
|
67
|
+
/** The id of the control; a unique one is made when left out. */
|
|
68
|
+
id?: string | undefined;
|
|
69
|
+
/** Accessible name when there is no visible label. */
|
|
70
|
+
ariaLabel?: string | undefined;
|
|
71
|
+
"aria-invalid"?: boolean | "true" | "false" | undefined;
|
|
72
|
+
/**
|
|
73
|
+
* Classes for the wui-datepicker control itself.
|
|
74
|
+
* @default ""
|
|
75
|
+
*/
|
|
76
|
+
className?: string | undefined;
|
|
77
|
+
/**
|
|
78
|
+
* Classes for the field wrapper that holds the label, helper text and error.
|
|
79
|
+
* @default ""
|
|
80
|
+
*/
|
|
81
|
+
fieldClassName?: string | undefined;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Thin React wrapper over the shared `<wui-datepicker mode="month">` element: a month-only
|
|
85
|
+
* picker that never shows a day view. Values are `YYYY-MM` strings.
|
|
86
|
+
*
|
|
87
|
+
* Wraps it in the standard `.field` shell: label, required mark, hint and
|
|
88
|
+
* error, the same as `<app-month-picker>` and every other field primitive.
|
|
89
|
+
* The shell is omitted entirely when there is nothing to render around the control.
|
|
90
|
+
*/
|
|
91
|
+
declare const AppMonthPicker: React.ForwardRefExoticComponent<AppMonthPickerProps & React.RefAttributes<HTMLElement>>;
|
|
92
|
+
export default AppMonthPicker;
|
|
@@ -55,6 +55,8 @@ interface AppSelectBaseProps {
|
|
|
55
55
|
onSearch?: ((query: string, meta: {
|
|
56
56
|
seq: number;
|
|
57
57
|
}) => void) | undefined;
|
|
58
|
+
/** Search, multiple and tag modes: the endpoint the select calls as GET source?q=query, answering a JSON array of option records. Leave it off with remote or loadOptions. */
|
|
59
|
+
source?: string | undefined;
|
|
58
60
|
/** Tag mode. `true` accepts the entry; a string refuses it with that message. */
|
|
59
61
|
validate?: ((value: string) => true | string) | undefined;
|
|
60
62
|
/** The text in the empty field. Left unset, the element's default for the mode applies: Select… in single, search and multiple, Add… in tag, Select country in country. */
|