@webority/ui-react 0.83.0 → 0.83.2

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.
@@ -1 +1 @@
1
- import e from"./warnUnknownProps.js";import t from"./AppIcon.js";import n from"../lib/FieldMessage.js";import{keyOf as r,nameOf as i,sizeLabelOf as a,useItemUrl as o}from"../lib/fileItem.js";import s from"../lib/FileItemRow.js";import{DEFAULT_IMAGE_ACCEPT as c,DEFAULT_MAX_SIZE_MB as l,acceptLabel as u,isImageFile as d,isImageOnlyAccept as f,validateFile as p}from"@webority/ui-elements/helpers";import{useId as m,useState as h}from"react";import{Fragment as g,jsx as _,jsxs as v}from"react/jsx-runtime";function y({label:i=`Attachment`,value:a,name:o,onChange:u,multiple:y=!1,accept:S=c,maxSizeMb:C=l,optional:w=!1,validate:T=!0,error:E,id:D,...O}){e(`AppFileAttachment`,O);let k=m(),A=D||k,[j,M]=h(``),[N,P]=h(!1),F=y&&Array.isArray(a)?a:a?[a]:[],I=f(S),L=e=>e instanceof File?d(e):I||d(e),R=!y&&F.length===1&&L(F[0]),z=b(S,C);function B(e){if(!e.length)return;let t=[],n=``;for(let r of e){let e=T?p(r,{accept:S,maxSizeMb:C}):null;if(e){n||=e;continue}t.push(r)}if(M(n),t.length)if(y){let e=Array.isArray(a)?a:a?[a]:[],n=new Set(e.map(r));u(e.concat(t.filter(e=>!n.has(r(e)))))}else u(t[0])}function V(e){let t=Array.from(e.target.files||[]);e.target.value=``,B(t)}function H(e){M(``),u(y?F.filter((t,n)=>n!==e):null)}let U=E||j,W=U?`${A}-error`:void 0,G=y||F.length===0,K=I?`image`:`file`,q=y?`Add ${K}s`:`Add ${I?`an`:`a`} ${K}`;return v(`div`,{className:`field`,children:[v(`label`,{className:`label`,htmlFor:A,children:[i,w&&_(`span`,{className:`label-optional`,children:` (optional)`})]}),G&&v(g,{children:[v(`label`,{className:`attach-drop${N?` dragging`:``}`,htmlFor:A,onDragEnter:e=>{e.preventDefault(),O.disabled||P(!0)},onDragOver:e=>{e.preventDefault(),O.disabled||P(!0)},onDragLeave:e=>{e.preventDefault(),P(!1)},onDrop:e=>{e.preventDefault(),P(!1),!O.disabled&&B(Array.from(e.dataTransfer?.files||[]))},children:[_(`span`,{className:`attach-drop-icon`,children:_(t,{name:I?`image`:`file-text`,size:18})}),v(`span`,{className:`attach-drop-copy`,children:[_(`span`,{className:`attach-drop-title`,children:q}),z&&_(`span`,{className:`attach-drop-hint`,children:z})]}),_(`span`,{className:`attach-drop-cta`,children:`Browse`})]}),_(`input`,{id:A,type:`file`,className:`visually-hidden`,name:o,accept:S||void 0,multiple:y||void 0,"aria-describedby":W,onChange:V,...O})]}),R?_(x,{item:F[0],isImage:!0,onRemove:()=>H(0)}):F.length>0&&_(`div`,{className:`attach-list`,children:F.map((e,t)=>_(s,{item:e,isImage:L(e),onRemove:()=>H(t)},r(e)))}),_(n,{error:U,errorId:`${A}-error`})]})}function b(e,t){let n=e?.trim()?u(e):``,r=t>0?`up to ${t} MB`:``;return n&&r?`${n}, ${r}`:r?`Up to ${t} MB`:n}function x({item:e,isImage:n,onRemove:r}){let s=o(e,n),c=i(e),l=a(e);return v(`div`,{className:`attach-preview`,children:[v(`div`,{className:`attach-figure`,children:[_(`img`,{src:s,alt:c}),_(`button`,{type:`button`,className:`attach-remove`,"aria-label":`Remove attachment`,onClick:r,children:_(t,{name:`x`,size:18})})]}),v(`div`,{className:`attach-meta`,children:[_(`div`,{className:`attach-name`,children:c}),l&&_(`div`,{className:`attach-size`,children:l})]})]})}export{y as default};
1
+ import e from"./warnUnknownProps.js";import t from"./AppIcon.js";import n from"../lib/FieldMessage.js";import r from"./AppProgress.js";import{keyOf as i,linkOf as a,nameOf as o,sizeLabelOf as s,uploadErrorOf as c,uploadProgressOf as l,useItemUrl as u}from"../lib/fileItem.js";import d from"../lib/FileItemRow.js";import{DEFAULT_IMAGE_ACCEPT as f,DEFAULT_MAX_SIZE_MB as p,acceptLabel as m,isImageFile as h,isImageOnlyAccept as g,validateFile as _}from"@webority/ui-elements/helpers";import{useId as v,useState as y}from"react";import{Fragment as b,jsx as x,jsxs as S}from"react/jsx-runtime";function C({label:r=`Attachment`,value:o,name:s,onChange:c,multiple:l=!1,accept:u=f,maxSizeMb:m=p,optional:C=!1,validate:E=!0,error:D,id:O,...k}){e(`AppFileAttachment`,k);let A=v(),j=O||A,[M,N]=y(``),[P,F]=y(!1),I=l&&Array.isArray(o)?o:o?[o]:[],L=g(u),R=e=>e instanceof File?h(e):L||h(e),z=!l&&I.length===1&&R(I[0])&&(I[0]instanceof File||a(I[0])!==null),B=w(u,m);function V(e){if(!e.length)return;let t=[],n=``;for(let r of e){let e=E?_(r,{accept:u,maxSizeMb:m}):null;if(e){n||=e;continue}t.push(r)}if(N(n),t.length)if(l){let e=Array.isArray(o)?o:o?[o]:[],n=new Set(e.map(i));c(e.concat(t.filter(e=>!n.has(i(e)))))}else c(t[0])}function H(e){let t=Array.from(e.target.files||[]);e.target.value=``,V(t)}function U(e){N(``),c(l?I.filter((t,n)=>n!==e):null)}let W=D||M,G=W?`${j}-error`:void 0,K=l||I.length===0,q=L?`image`:`file`,J=l?`Add ${q}s`:`Add ${L?`an`:`a`} ${q}`;return S(`div`,{className:`field`,children:[S(`label`,{className:`label`,htmlFor:j,children:[r,C&&x(`span`,{className:`label-optional`,children:` (optional)`})]}),K&&S(b,{children:[S(`label`,{className:`attach-drop${P?` dragging`:``}`,htmlFor:j,onDragEnter:e=>{e.preventDefault(),k.disabled||F(!0)},onDragOver:e=>{e.preventDefault(),k.disabled||F(!0)},onDragLeave:e=>{e.preventDefault(),F(!1)},onDrop:e=>{e.preventDefault(),F(!1),!k.disabled&&V(Array.from(e.dataTransfer?.files||[]))},children:[x(`span`,{className:`attach-drop-icon`,children:x(t,{name:L?`image`:`file-text`,size:18})}),S(`span`,{className:`attach-drop-copy`,children:[x(`span`,{className:`attach-drop-title`,children:J}),B&&x(`span`,{className:`attach-drop-hint`,children:B})]}),x(`span`,{className:`attach-drop-cta`,children:`Browse`})]}),x(`input`,{id:j,type:`file`,className:`visually-hidden`,name:s,accept:u||void 0,multiple:l||void 0,"aria-describedby":G,onChange:H,...k})]}),z?x(T,{item:I[0],isImage:!0,onRemove:()=>U(0)}):I.length>0&&x(`div`,{className:`attach-list`,children:I.map((e,t)=>x(d,{item:e,isImage:R(e),onRemove:()=>U(t)},i(e)))}),x(n,{error:W,errorId:`${j}-error`})]})}function w(e,t){let n=e?.trim()?m(e):``,r=t>0?`up to ${t} MB`:``;return n&&r?`${n}, ${r}`:r?`Up to ${t} MB`:n}function T({item:e,isImage:n,onRemove:i}){let d=u(e,n),f=o(e),p=s(e),m=l(e),h=c(e),g=a(e);return S(`div`,{className:h?`attach-preview wui-attach-failed`:`attach-preview`,children:[S(`div`,{className:`attach-figure`,children:[x(`img`,{src:d,alt:f}),x(`button`,{type:`button`,className:`attach-remove`,"aria-label":`Remove attachment`,onClick:i,children:x(t,{name:`x`,size:18})})]}),S(`div`,{className:`attach-meta`,children:[x(`div`,{className:`attach-name`,children:g?x(`a`,{href:g,children:f}):f}),p&&x(`div`,{className:`attach-size`,children:p})]}),m!==null&&x(r,{value:m,size:`sm`,label:`Uploading ${f}`,className:`wui-attach-progress`}),h&&x(`div`,{className:`wui-attach-error`,children:h})]})}export{C as default};
@@ -1 +1 @@
1
- import{devWarn as e}from"../lib/devWarn.js";import t from"./warnInvalidValue.js";import n from"./warnUnknownProps.js";import r from"./AppIcon.js";import i from"./AppButton.js";import a from"./AppSegmented.js";import o from"./AppChip.js";import s from"./AppDateRangePicker.js";import{emptyFacetValue as c,isFacetActive as l}from"../lib/listQuery.js";import u from"./AppMultiSelect.js";import d from"./AppSearch.js";import f from"./AppSelect.js";import p from"./AppSwitch.js";import{useEffect as m,useId as h,useRef as g,useSyncExternalStore as _}from"react";import{jsx as v,jsxs as y}from"react/jsx-runtime";import"@webority/ui-elements/elements/filter-popover";var b=`(max-width: 575.98px)`,x=3,S=2,C=e=>{let t=window.matchMedia?.(b);return t?.addEventListener(`change`,e),()=>t?.removeEventListener(`change`,e)},w=()=>window.matchMedia?.(b).matches??!1,T=[`enum`,`multiEnum`,`dateRange`,`text`],E=4,D=e=>(e.type===`enum`||e.type===`multiEnum`)&&!e.options?.length,O=(e,t)=>e.options?.find(e=>e.value===t)?.label??t;function k(e,t){if(!l(e,t))return[];if(e.type===`enum`)return[{id:e.key,text:O(e,t),clear:()=>c(e)}];if(e.type===`multiEnum`)return t.map(n=>({id:`${e.key}:${n}`,text:O(e,n),clear:()=>t.filter(e=>e!==n)}));if(e.type===`dateRange`){let n=t.from&&t.to?`${t.from} to ${t.to}`:t.from?`From ${t.from}`:`Until ${t.to}`;return[{id:e.key,text:n,clear:()=>c(e)}]}return[]}var A=new Set;function j(t){let n=!0;try{n=process.env.NODE_ENV!==`production`}catch{n=!0}!n||A.has(t)||(A.add(t),e(`[@webority/ui-react] <AppFilterBar> facet "${t}" sets allLabel, which only an enum facet uses.`))}var M=new Set;function N(t){let n=!0;try{n=process.env.NODE_ENV!==`production`}catch{n=!0}!n||M.has(t)||(M.add(t),e(`[@webority/ui-react] <AppFilterBar> facet "${t}" sets presets, which only a dateRange facet uses.`))}function P({facets:e,value:a,onChange:s,inline:u=x,floating:d=!1,className:f=``,...b}){n(`AppFilterBar`,b);let E=_(C,w,()=>!1),O=g(null),A=h();for(let n of e)t(`AppFilterBar`,`facets[].type`,n.type,T);for(let t of e)t.allLabel!=null&&t.type!==`enum`&&j(t.key),t.presets!=null&&t.type!==`dateRange`&&N(t.key);let M=e.filter(e=>!D(e)),P=M.flatMap(e=>k(e,a[e.key]).map(t=>({...t,facet:e}))),I=M.filter(e=>l(e,a[e.key])),L=d||E?0:Math.max(0,u),R=M.slice(L),z=R.filter(e=>I.includes(e)).length,B=!d&&R.length>0;m(()=>{if(!B)return;let e=e=>{let t=O.current;t?.open&&(e.type===`keydown`?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)}},[B]);let V=e=>v(F,{facet:e,value:a[e.key],onChange:t=>s(e.key,t)},e.key),H=e=>y(`div`,{className:`wui-filter-popover-field`,children:[v(`span`,{className:`label`,"aria-hidden":`true`,children:e.label}),v(F,{facet:e,value:a[e.key],onChange:t=>s(e.key,t),floating:!0})]},e.key),U=(e,t)=>t>0&&v(`span`,{className:e,children:` (${t})`}),W=e=>v(o,{size:`sm`,label:`${e.facet.label}: ${e.text}`,removeLabel:`Remove ${e.facet.label} filter ${e.text}`,onRemove:()=>s(e.facet.key,e.clear()),className:!d&&M.indexOf(e.facet)<L?`wui-filter-chip-inline`:void 0},e.id),G=v(i,{variant:`ghost`,size:`sm`,onClick:()=>{for(let e of I)s(e.key,c(e))},children:`Clear all`});if(d){let e=P.slice(S),t=I.length;return y(`div`,{className:`wui-filter-bar d-flex flex-wrap align-items-center gap-2${f?` ${f}`:``}`,...b,children:[y(`wui-filter-popover`,{class:`wui-filter-popover`,children:[y(`button`,{type:`button`,className:`btn ${t>0?`btn-outline-primary`:`btn-ghost`} btn-sm wui-filter-popover-trigger`,"aria-expanded":`false`,"aria-controls":A,"aria-label":t>0?`Filters, ${t} active`:void 0,children:[v(r,{name:`filter`,size:14,className:`me-2`}),`Filters`,t>0&&v(`span`,{className:`badge rounded-pill text-bg-primary ms-1`,children:t})]}),y(`div`,{id:A,className:`wui-filter-popover-panel`,role:`dialog`,"aria-label":`Filters`,hidden:!0,children:[y(`div`,{className:`wui-filter-popover-head`,children:[v(`span`,{className:`wui-filter-popover-title`,children:`Filters`}),v(p,{label:`Keep open`,id:`${A}-pin`})]}),v(`div`,{className:`wui-filter-popover-grid`,children:M.map(H)}),y(`div`,{className:`wui-filter-popover-foot`,children:[v(`span`,{className:`wui-filter-popover-note`,children:`Changes apply at once.`}),t>0&&G]})]})]}),P.slice(0,S).map(W),e.length>0&&y(`span`,{className:`chip chip-sm wui-filter-popover-more`,title:e.map(e=>`${e.facet.label}: ${e.text}`).join(`, `),children:[`+`,e.length]})]})}return y(`div`,{className:`wui-filter-bar d-flex flex-wrap align-items-center gap-2${E&&B?` wui-filter-bar--folded`:``}${f?` ${f}`:``}`,...b,children:[M.slice(0,L).map(V),B&&y(`details`,{ref:O,className:`wui-filter-more`,children:[y(`summary`,{className:`btn btn-outline-primary btn-sm wui-filter-more-trigger`,children:[v(r,{name:`filter`,size:14,className:`me-2`}),`Filters`,U(`wui-filter-count-desktop`,z),U(`wui-filter-count-phone`,I.length)]}),y(`div`,{className:`wui-filter-more-panel`,children:[v(`div`,{className:`wui-filter-more-head`,children:`Filters`}),R.map(H)]})]}),P.map(W),I.length>0&&G]})}function F({facet:e,value:t,onChange:n,floating:r=!1}){if(e.type===`enum`){let i=e.options??[];return i.length<E?v(a,{label:e.label,name:e.key,size:`sm`,value:t??``,onChange:n,options:[{value:``,label:e.allLabel||`All`},...i]}):v(f,{"aria-label":e.label,name:e.key,placeholder:r?`Any`:e.label,size:`sm`,clearable:!0,value:t??``,onChange:n,options:i})}return e.type===`multiEnum`?v(u,{"aria-label":e.label,name:e.key,placeholder:r?`Any`:e.label,size:`sm`,collapseChips:!0,values:t??[],onChange:n,options:e.options??[]}):e.type===`dateRange`?v(s,{ariaLabel:e.label,startName:`${e.key}From`,endName:`${e.key}To`,placeholder:r?`Any`:e.label,size:`sm`,presets:e.presets,start:t?.from??``,end:t?.to??``,onChange:e=>n({from:e.start??``,to:e.end??``})}):v(d,{ariaLabel:e.label,name:e.key,placeholder:e.label,size:`sm`,value:t??``,onChange:n})}export{P as default};
1
+ import{devWarn as e}from"../lib/devWarn.js";import t from"./warnInvalidValue.js";import n from"./warnUnknownProps.js";import r from"./AppIcon.js";import i from"./AppButton.js";import a from"./AppSegmented.js";import ee from"./AppChip.js";import o from"./AppDateRangePicker.js";import{emptyFacetValue as s,isFacetActive as c}from"../lib/listQuery.js";import l from"./AppMultiSelect.js";import u from"./AppSearch.js";import d from"./AppSelect.js";import f from"./AppSwitch.js";import{Fragment as te,useEffect as p,useId as m,useRef as h,useState as ne,useSyncExternalStore as re}from"react";import{Fragment as g,jsx as _,jsxs as v}from"react/jsx-runtime";import"@webority/ui-elements/elements/filter-popover";var y=`(max-width: 575.98px)`,b=3,x=2,ie=e=>{let t=window.matchMedia?.(y);return t?.addEventListener(`change`,e),()=>t?.removeEventListener(`change`,e)},ae=()=>window.matchMedia?.(y).matches??!1,S=[`enum`,`multiEnum`,`dateRange`,`text`],C=4,w=e=>(e.type===`enum`||e.type===`multiEnum`)&&!e.options?.length,T=(e,t)=>e.options?.find(e=>e.value===t)?.label??t,oe=(e,t)=>JSON.stringify(e)===JSON.stringify(t);function se(e,t){if(!c(e,t))return[];if(e.type===`enum`)return[{id:e.key,text:T(e,t),clear:()=>s(e)}];if(e.type===`multiEnum`)return t.map(n=>({id:`${e.key}:${n}`,text:T(e,n),clear:()=>t.filter(e=>e!==n)}));if(e.type===`dateRange`){let n=t.from&&t.to?`${t.from} to ${t.to}`:t.from?`From ${t.from}`:`Until ${t.to}`;return[{id:e.key,text:n,clear:()=>s(e)}]}return[]}var E=new Set;function D(t){let n=!0;try{n=process.env.NODE_ENV!==`production`}catch{n=!0}!n||E.has(t)||(E.add(t),e(`[@webority/ui-react] <AppFilterBar> facet "${t}" sets allLabel, which only an enum facet uses.`))}var O=new Set;function k(t){let n=!0;try{n=process.env.NODE_ENV!==`production`}catch{n=!0}!n||O.has(t)||(O.add(t),e(`[@webority/ui-react] <AppFilterBar> facet "${t}" sets presets, which only a dateRange facet uses.`))}function A({facets:e,value:a,onChange:o,inline:l=b,floating:u=!1,apply:d=!1,className:y=``,...C}){n(`AppFilterBar`,C);let T=re(ie,ae,()=>!1),E=h(null),O=m(),[A,M]=ne({}),N=h(a);for(let n of e)t(`AppFilterBar`,`facets[].type`,n.type,S);for(let t of e)t.allLabel!=null&&t.type!==`enum`&&D(t.key),t.presets!=null&&t.type!==`dateRange`&&k(t.key);let P=e.filter(e=>!w(e)),F=P.flatMap(e=>se(e,a[e.key]).map(t=>({...t,facet:e}))),I=P.filter(e=>c(e,a[e.key])),L=u||T?0:Math.max(0,l),R=P.slice(L),z=R.filter(e=>I.includes(e)).length,B=!u&&R.length>0;p(()=>{if(!B)return;let e=e=>{let t=E.current;t?.open&&(e.type===`keydown`?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)}},[B]),p(()=>{let e=N.current;N.current=a,M(t=>{let n=Object.entries(t).filter(([t])=>oe(e[t],a[t]));return n.length===Object.keys(t).length?t:Object.fromEntries(n)})},[a]);let V=e=>d&&!u&&(e.type===`text`||e.type===`dateRange`),H=e=>V(e)&&Object.hasOwn(A,e.key)?A[e.key]:a[e.key],U=e=>t=>V(e)?M(n=>({...n,[e.key]:t})):o(e.key,t),W=()=>{for(let[e,t]of Object.entries(A))o(e,t);M({})},G=e=>{e.key===`Enter`&&W()},ce=e=>{e.preventDefault(),W()},K=(e,t)=>e.type===`text`&&V(e)?_(`span`,{onKeyDownCapture:G,children:t}):t,le=e=>_(te,{children:K(e,_(j,{facet:e,value:H(e),onChange:U(e)}))},e.key),q=e=>v(`div`,{className:`wui-filter-popover-field`,children:[_(`span`,{className:`label`,"aria-hidden":`true`,children:e.label}),K(e,_(j,{facet:e,value:H(e),onChange:U(e),floating:!0}))]},e.key),J=(e,t)=>t>0&&_(`span`,{className:e,children:` (${t})`}),Y=e=>_(ee,{size:`sm`,label:`${e.facet.label}: ${e.text}`,removeLabel:`Remove ${e.facet.label} filter ${e.text}`,onRemove:()=>o(e.facet.key,e.clear()),className:!u&&P.indexOf(e.facet)<L?`wui-filter-chip-inline`:void 0},e.id),X=_(i,{variant:`ghost`,size:`sm`,onClick:()=>{for(let e of I)o(e.key,s(e));M({})},children:`Clear all`});if(u){let e=F.slice(x),t=I.length;return v(`div`,{className:`wui-filter-bar d-flex flex-wrap align-items-center gap-2${y?` ${y}`:``}`,...C,children:[v(`wui-filter-popover`,{class:`wui-filter-popover`,children:[v(`button`,{type:`button`,className:`btn ${t>0?`btn-outline-primary`:`btn-ghost`} btn-sm wui-filter-popover-trigger`,"aria-expanded":`false`,"aria-controls":O,"aria-label":t>0?`Filters, ${t} active`:void 0,children:[_(r,{name:`filter`,size:14,className:`me-2`}),`Filters`,t>0&&_(`span`,{className:`badge rounded-pill text-bg-primary ms-1`,children:t})]}),v(`div`,{id:O,className:`wui-filter-popover-panel`,role:`dialog`,"aria-label":`Filters`,hidden:!0,children:[v(`div`,{className:`wui-filter-popover-head`,children:[_(`span`,{className:`wui-filter-popover-title`,children:`Filters`}),_(f,{label:`Keep open`,id:`${O}-pin`})]}),_(`div`,{className:`wui-filter-popover-grid`,children:P.map(q)}),v(`div`,{className:`wui-filter-popover-foot`,children:[_(`span`,{className:`wui-filter-popover-note`,children:`Changes apply at once.`}),t>0&&X]})]})]}),F.slice(0,x).map(Y),e.length>0&&v(`span`,{className:`chip chip-sm wui-filter-popover-more`,title:e.map(e=>`${e.facet.label}: ${e.text}`).join(`, `),children:[`+`,e.length]})]})}let Z=`wui-filter-bar d-flex flex-wrap align-items-center gap-2${T&&B?` wui-filter-bar--folded`:``}`,Q=e=>`${e}${y?` ${y}`:``}`,$=v(g,{children:[P.slice(0,L).map(le),B&&v(`details`,{ref:E,className:`wui-filter-more`,children:[v(`summary`,{className:`btn btn-outline-primary btn-sm wui-filter-more-trigger`,children:[_(r,{name:`filter`,size:14,className:`me-2`}),`Filters`,J(`wui-filter-count-desktop`,z),J(`wui-filter-count-phone`,I.length)]}),v(`div`,{className:`wui-filter-more-panel`,children:[_(`div`,{className:`wui-filter-more-head`,children:`Filters`}),R.map(q)]})]}),F.map(Y),I.length>0&&X]});return!d||!P.some(e=>e.type===`text`||e.type===`dateRange`)?_(`div`,{className:Q(Z),...C,children:$}):v(`div`,{className:Q(`wui-filter-form d-flex flex-wrap align-items-center gap-2`),...C,children:[_(`div`,{className:Z,children:$}),_(i,{type:`submit`,size:`sm`,onClick:ce,children:`Apply`})]})}function j({facet:e,value:t,onChange:n,floating:r=!1}){if(e.type===`enum`){let i=e.options??[];return i.length<C?_(a,{label:e.label,name:e.key,size:`sm`,value:t??``,onChange:n,options:[{value:``,label:e.allLabel||`All`},...i]}):_(d,{"aria-label":e.label,name:e.key,placeholder:r?`Any`:e.label,size:`sm`,clearable:!0,value:t??``,onChange:n,options:i})}return e.type===`multiEnum`?_(l,{"aria-label":e.label,name:e.key,placeholder:r?`Any`:e.label,size:`sm`,collapseChips:!0,values:t??[],onChange:n,options:e.options??[]}):e.type===`dateRange`?_(o,{ariaLabel:e.label,startName:`${e.key}From`,endName:`${e.key}To`,placeholder:r?`Any`:e.label,size:`sm`,presets:e.presets,start:t?.from??``,end:t?.to??``,onChange:e=>n({from:e.start??``,to:e.end??``})}):_(u,{ariaLabel:e.label,name:e.key,placeholder:e.label,size:`sm`,value:t??``,onChange:n})}export{A as default};
@@ -1 +1 @@
1
- import e from"../components/AppIcon.js";import t from"../components/AppProgress.js";import{nameOf as n,sizeLabelOf as r,useItemUrl as i}from"./fileItem.js";import{jsx as a,jsxs as o}from"react/jsx-runtime";function s({item:s,isImage:c,onRemove:l,noun:u=`attachment`}){let d=i(s,c),f=n(s),p=r(s),m=s?.progress,h=typeof m==`number`&&m>=0&&m<=99,g=typeof s?.error==`string`&&s.error.length>0,_=typeof s?.url==`string`&&s.url.length>0?s.url:null;return o(`div`,{className:g?`attach-item wui-attach-failed`:`attach-item`,children:[a(`span`,{className:`attach-item-media`,children:d?a(`img`,{src:d,alt:f}):a(e,{name:`file-text`,size:18})}),o(`span`,{className:`attach-item-info`,children:[a(`span`,{className:`attach-name`,children:_?a(`a`,{href:_,children:f}):f}),p&&a(`span`,{className:`attach-size`,children:p}),h&&a(t,{value:m,size:`sm`,label:`Uploading ${f}`,className:`wui-attach-progress`}),g&&a(`div`,{className:`wui-attach-error`,children:s?.error})]}),a(`button`,{type:`button`,className:`attach-item-remove`,"aria-label":`Remove ${f||u}`,onClick:l,children:a(e,{name:`x`,size:16})})]})}export{s as default};
1
+ import e from"../components/AppIcon.js";import t from"../components/AppProgress.js";import{linkOf as n,nameOf as r,sizeLabelOf as i,uploadErrorOf as a,uploadProgressOf as o,useItemUrl as s}from"./fileItem.js";import{jsx as c,jsxs as l}from"react/jsx-runtime";function u({item:u,isImage:d,onRemove:f,noun:p=`attachment`}){let m=s(u,d),h=r(u),g=i(u),_=o(u),v=a(u),y=n(u);return l(`div`,{className:v?`attach-item wui-attach-failed`:`attach-item`,children:[c(`span`,{className:`attach-item-media`,children:m?c(`img`,{src:m,alt:h}):c(e,{name:`file-text`,size:18})}),l(`span`,{className:`attach-item-info`,children:[c(`span`,{className:`attach-name`,children:y?c(`a`,{href:y,children:h}):h}),g&&c(`span`,{className:`attach-size`,children:g}),_!==null&&c(t,{value:_,size:`sm`,label:`Uploading ${h}`,className:`wui-attach-progress`}),v&&c(`div`,{className:`wui-attach-error`,children:v})]}),c(`button`,{type:`button`,className:`attach-item-remove`,"aria-label":`Remove ${h||p}`,onClick:f,children:c(e,{name:`x`,size:16})})]})}export{u as default};
@@ -1 +1 @@
1
- import{useEffect as e,useState as t}from"react";function n(e){return e instanceof File?`${e.name}:${e.size}`:e?.url||e?.name||`item`}function r(e){return e instanceof File?e.name:e?.name}var i=[`KB`,`MB`,`GB`];function a(e){if(e<1024)return`${e} B`;let t=e/1024,n=0;for(;t>=1024&&n<i.length-1;)t/=1024,n+=1;return`${new Intl.NumberFormat(void 0,{minimumFractionDigits:1,maximumFractionDigits:1}).format(t)} ${i[n]}`}function o(e){if(e instanceof File)return a(e.size);let t=e?.sizeBytes;return Number.isFinite(t)&&t>=0?a(t):null}function s(n,r){let[i,a]=t(null);return e(()=>{if(!r){a(null);return}if(n instanceof File){let e=URL.createObjectURL(n);return a(e),()=>URL.revokeObjectURL(e)}a(n?.url||null)},[n,r]),i}export{n as keyOf,r as nameOf,o as sizeLabelOf,s as useItemUrl};
1
+ import{formatFileSize as e}from"@webority/ui-elements/helpers";import{useEffect as t,useState as n}from"react";function r(e){return e instanceof File?`${e.name}:${e.size}`:e?.url||e?.name||`item`}function i(e){return e instanceof File?e.name:e?.name}function a(t){if(t instanceof File)return e(t.size);let n=t?.sizeBytes;return Number.isFinite(n)&&n>=0?e(n):null}function o(e){return typeof e?.url==`string`&&e.url.length>0?e.url:null}function s(e){let t=e?.progress;return typeof t==`number`&&t>=0&&t<=99?t:null}function c(e){return typeof e?.error==`string`&&e.error.length>0?e.error:null}function l(e,r){let[i,a]=n(null);return t(()=>{if(!r){a(null);return}if(e instanceof File){let t=URL.createObjectURL(e);return a(t),()=>URL.revokeObjectURL(t)}a(e?.url||null)},[e,r]),i}export{r as keyOf,o as linkOf,i as nameOf,a as sizeLabelOf,c as uploadErrorOf,s as uploadProgressOf,l as useItemUrl};
@@ -18,6 +18,8 @@ import "@webority/ui-elements/elements/filter-popover";
18
18
  * into that one button and the panel becomes a sheet from the bottom edge. The button and Clear all
19
19
  * never wrap.
20
20
  *
21
+ * With `apply`, a search box or date range waits for Apply, or Enter in a search box, before it calls `onChange`; other choices still apply as they change.
22
+ *
21
23
  * @param {object} props
22
24
  * @param {{ key: string, label: string, type: 'enum'|'multiEnum'|'dateRange'|'text',
23
25
  * options?: { value: string, label: string }[], allLabel?: string, presets?: string[] }[]} props.facets `options` fills an `enum` or `multiEnum`;
@@ -29,9 +31,10 @@ import "@webority/ui-elements/elements/filter-popover";
29
31
  * Called with the facet key and its new value. Clear all calls it once per active facet, with the empty value.
30
32
  * @param {number} [props.inline=3] How many facets stay in the row; the rest fold into the Filters button.
31
33
  * @param {boolean} [props.floating=false] A floating panel: hover, click or F opens the facets in a non-modal panel under the Filters button, with a chip summary in the row.
34
+ * @param {boolean} [props.apply=false] Hold search and date range edits until Apply (or Enter in a search box), as the Razor app-filter-bar does; other choices still apply when they change. Apply shows only when a text or dateRange facet is present, and never with floating.
32
35
  * @param {string} [props.className]
33
36
  */
34
- export default function AppFilterBar({ facets: allFacets, value, onChange, inline, floating, className, ...rest }: {
37
+ export default function AppFilterBar({ facets: allFacets, value, onChange, inline, floating, apply, className, ...rest }: {
35
38
  facets: {
36
39
  key: string;
37
40
  label: string;
@@ -53,5 +56,6 @@ export default function AppFilterBar({ facets: allFacets, value, onChange, inlin
53
56
  }) => void;
54
57
  inline?: number;
55
58
  floating?: boolean;
59
+ apply?: boolean;
56
60
  className?: string;
57
61
  }): import("react").JSX.Element;
@@ -11,6 +11,12 @@ export declare function nameOf(item: any): any;
11
11
  * `sizeBytes` of 0 or more. Null when the size is unknown.
12
12
  */
13
13
  export declare function sizeLabelOf(item: any): string;
14
+ /** The link a stored file opens; a freshly picked File has none. */
15
+ export declare function linkOf(item: any): any;
16
+ /** Upload progress while it is under 100, else null: a finished upload draws no bar. */
17
+ export declare function uploadProgressOf(item: any): number;
18
+ /** Why the upload failed, or null. */
19
+ export declare function uploadErrorOf(item: any): any;
14
20
  /**
15
21
  * A freshly-picked File has no URL of its own; mint one (for images) and revoke it on
16
22
  * change/unmount. An existing attachment already carries `url`. Non-images get no URL — the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webority/ui-react",
3
- "version": "0.83.0",
3
+ "version": "0.83.2",
4
4
  "description": "Webority shared React component library — App* primitives on react-bootstrap + the @webority/theme design system.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "type": "module",
@@ -27,8 +27,8 @@
27
27
  },
28
28
  "sideEffects": false,
29
29
  "dependencies": {
30
- "@webority/ui-elements": "0.83.0",
31
- "@webority/theme": "0.83.0"
30
+ "@webority/theme": "0.83.2",
31
+ "@webority/ui-elements": "0.83.2"
32
32
  },
33
33
  "peerDependencies": {
34
34
  "@webority/analytics": "^0.25.0",