@webority/ui-react 0.109.7 → 0.109.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,7 +2,7 @@
2
2
  "kind": "WeborityWeb",
3
3
  "library": {
4
4
  "name": "@webority/ui-react",
5
- "version": "0.109.7"
5
+ "version": "0.109.9"
6
6
  },
7
7
  "rendererProtocolVersion": 12,
8
8
  "platform": "Web",
@@ -9106,6 +9106,12 @@
9106
9106
  "required": false,
9107
9107
  "description": "Quick ranges for a dateRange facet: today, yesterday, last7Days, last30Days, thisMonth, lastMonth, thisFinancialYear."
9108
9108
  },
9109
+ {
9110
+ "name": "required",
9111
+ "type": "boolean",
9112
+ "required": false,
9113
+ "description": "An enum that always holds one of its options: no All segment, its select cannot be cleared, and it draws no chip and is left out of Clear all and the Filters count."
9114
+ },
9109
9115
  {
9110
9116
  "name": "type",
9111
9117
  "type": "enum",
@@ -1,21 +1,21 @@
1
1
  {
2
2
  "name": "webority-web",
3
- "version": "0.109.7",
3
+ "version": "0.109.9",
4
4
  "platform": "Web",
5
5
  "kitModuleVersion": 2,
6
6
  "rendererProtocolVersion": 12,
7
7
  "library": {
8
8
  "name": "@webority/ui-react",
9
- "version": "0.109.7"
9
+ "version": "0.109.9"
10
10
  },
11
11
  "files": {
12
12
  "manifest.json": {
13
- "sha256": "a8e8c5e0c031dfabb0c812920d341eb752085768d7c53fbdcbd91d315268c662",
14
- "bytes": 856329
13
+ "sha256": "779becc0775536c9465ab3ed4ad04d99bfdf69250e9ab0e834f8b7c5d6ae0447",
14
+ "bytes": 856654
15
15
  },
16
16
  "kit.js": {
17
- "sha256": "5e5c156fd6587fea5628d3ea40f364a4955f3009876d0efdaf8ffbd79b61f652",
18
- "bytes": 10897341
17
+ "sha256": "c3641da2f695b6b7622da9ab34b8b212520c35b505f689d8afcfb347bd9aaa6c",
18
+ "bytes": 10900270
19
19
  },
20
20
  "kit.css": {
21
21
  "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
@@ -1 +1 @@
1
- import{splitMarkerProps as e}from"../lib/wuiMarker.js";import t from"./warnInvalidValue.js";import n from"./warnUnknownProps.js";import r from"./AppIcon.js";import{initialsOf as i}from"../lib/initials.js";import a from"./AppAvatar.js";import{parseMentionValue as o}from"@webority/ui-elements/elements/mention-input";import{formatDate as s,formatFileSize as c,formatNumber as l,toInstant as u}from"@webority/ui-elements/helpers";import{Fragment as d,useEffect as f,useId as p,useRef as m}from"react";import{jsx as h,jsxs as g}from"react/jsx-runtime";import{COMMENT_REACTIONS as _,COMMENT_TEXT as v}from"@webority/ui-elements/elements/comment-thread";var y=[`stacked`,`inline`],b=[`list`,`conversation`];function x(r){let{marker:i,props:o}=e(`AppCommentThread`,r),{comments:s=[],onPost:c,onReply:l,onEdit:u,onDelete:d,onReact:x,people:C,loadPeople:w,reactionChoices:T,allowReplies:E=!0,allowReactions:D=!0,composerPlaceholder:O,variant:k=`list`,composer:A=`stacked`,author:j,postLabel:M=v.post,composerRows:N,readOnly:P=!1,label:F=v.listName,id:I,className:L=``,...R}=o;n(`AppCommentThread`,R),t(`AppCommentThread`,`variant`,k,b),t(`AppCommentThread`,`composer`,A,y);let z=p(),B=I||`comment-thread-${z.replace(/[^a-zA-Z0-9_-]/g,``)}`,V=m(null),H=typeof w==`function`,U=T?.length?T:_,W=A===`inline`,G=N??(W?1:3),K=m(null);return K.current={onPost:c,onReply:l,onEdit:u,onDelete:d,onReact:x,loadPeople:w},f(()=>{let e=V.current;if(e)return e.submit=async({intent:e,commentId:t,parentId:n,body:r,emoji:i})=>{let a=K.current;e===`post`?await a.onPost?.(r):e===`reply`?await a.onReply?.(n,r):e===`edit`?await a.onEdit?.(t,r):e===`delete`?await a.onDelete?.(t):e===`react`&&await a.onReact?.(t,i)},()=>{e.submit=void 0}},[]),f(()=>{let e=V.current;!e||H||(e.people=C||[])},[C,H]),f(()=>{let e=V.current;if(!e||!H)return;let t=new WeakMap,n=async e=>{let n=e.target,r=(t.get(n)??0)+1;t.set(n,r),n.loading=!0;try{let i=await K.current.loadPeople(e.detail.query);t.get(n)===r&&(n.people=i||[])}catch{t.get(n)===r&&(n.people=[])}finally{t.get(n)===r&&(n.loading=!1)}};return e.addEventListener(`search`,n),()=>e.removeEventListener(`search`,n)},[H]),g(`wui-comment-thread`,{ref:V,id:B,class:[`wui-comment-thread`,k===`conversation`&&`wui-comment-thread--conversation`,L].filter(Boolean).join(` `),controlled:``,"read-only":P?``:void 0,remote:H?``:void 0,"reaction-choices":T?.length?T.join(` `):void 0,"no-replies":E?void 0:``,"no-reactions":D?void 0:``,"composer-placeholder":O,...i,...R,children:[h(`div`,{className:`wui-comment-items`,"data-wui-items":``,children:s.length?h(`ol`,{className:`wui-comment-list`,"aria-label":F,children:s.map(e=>h(S,{comment:e,topLevel:!0,readOnly:P,allowReplies:E,allowReactions:D},e.id))}):h(`p`,{className:`wui-comment-empty`,children:v.empty})}),!P&&D&&h(`div`,{className:`wui-reaction-picker`,role:`group`,"aria-label":v.pickerName,"data-wui-picker":``,hidden:!0,children:U.map(e=>h(`button`,{type:`button`,className:`wui-reaction-choice`,"data-wui-emoji":e,children:e},e))}),!P&&g(`div`,{className:W?`wui-comment-composer wui-comment-composer-inline`:`wui-comment-composer`,"data-wui-composer":``,children:[W&&j?h(a,{name:j,size:`sm`,tone:`auto`,className:`wui-comment-composer-avatar`}):null,h(`wui-mention-input`,{id:`${B}-new`,class:`wui-mention-input`,label:v.composerLabel,placeholder:O??v.composerPlaceholder,rows:String(G),remote:H?``:void 0}),h(`div`,{className:`wui-comment-form-actions`,children:h(`button`,{type:`button`,className:W?`btn btn-outline-primary btn-sm`:`btn btn-primary btn-sm`,"data-wui-action":`post`,children:M})}),h(`div`,{className:`wui-comment-error`,"data-wui-error":``,hidden:!0})]}),h(`span`,{className:`visually-hidden`,"data-wui-live":``,"aria-live":`polite`,"aria-atomic":`true`})]})}function S({comment:e,topLevel:t=!1,readOnly:n,allowReplies:a,allowReactions:f}){let{id:p,author:m,at:_,value:y,edited:b,mine:x,internal:C,attachments:w=[],deleted:T,canEdit:E,canDelete:D,reactions:O=[],replies:k=[]}=e,A=m?.name||``,j=u(_),M=!n&&!T&&E,N=!n&&!T&&D,P=t&&a;return g(`li`,{className:[`wui-comment`,C&&`wui-comment--internal`,x&&`wui-comment--mine`].filter(Boolean).join(` `),"data-wui-comment":p,"data-value":y??``,"data-wui-deleted":T?``:void 0,children:[g(`div`,{className:`wui-comment-row`,children:[g(`span`,{className:`avatar avatar-sm wui-comment-avatar`,"aria-hidden":`true`,children:[h(`span`,{className:`avatar-face`,children:i(A)||`?`}),m?.src&&h(`img`,{className:`avatar-img`,src:m.src,alt:``,onError:e=>{e.currentTarget.hidden=!0}})]}),g(`div`,{className:`wui-comment-main`,children:[g(`div`,{className:`wui-comment-head`,children:[h(`span`,{className:`wui-comment-author`,children:A}),h(`time`,{className:`wui-comment-time`,dateTime:Number.isFinite(j)?new Date(j).toISOString():void 0,children:s(_,{pattern:`datetime`})}),b&&!T&&h(`span`,{className:`wui-comment-edited`,children:v.edited}),C&&h(`span`,{className:`badge wui-comment-internal-badge`,children:`Internal note`})]}),T?h(`div`,{className:`wui-comment-text wui-comment-text-deleted`,children:v.deleted}):h(`div`,{className:`wui-comment-text`,"data-wui-text":``,children:o(y).map((e,t)=>`text`in e?h(d,{children:e.text},t):g(`span`,{className:`wui-mention`,"data-mention-id":e.id,children:[`@`,e.label]},t))}),!T&&w.length>0&&h(`ul`,{className:`wui-comment-attachments`,"aria-label":`Attachments`,children:w.map(e=>g(`li`,{children:[g(`a`,{className:`wui-comment-attachment`,href:e.href,download:!0,children:[h(r,{name:`paperclip`,size:14}),e.name]}),typeof e.sizeBytes==`number`&&h(`span`,{className:`wui-comment-attachment-size`,children:c(e.sizeBytes)})]},e.href))}),M&&h(`div`,{className:`wui-comment-editor`,"data-wui-editor":``,hidden:!0}),f&&!T&&(O.length>0||!n)&&g(`div`,{className:`wui-comment-reactions`,role:`group`,"aria-label":v.reactions,children:[O.map(e=>n?g(`span`,{className:e.mine?`wui-reaction wui-reaction-mine`:`wui-reaction`,children:[h(`span`,{className:`wui-reaction-emoji`,children:e.emoji}),h(`span`,{className:`wui-reaction-count`,children:l(e.count,{decimals:0})})]},e.emoji):g(`button`,{type:`button`,className:e.mine?`wui-reaction wui-reaction-mine`:`wui-reaction`,"data-wui-emoji":e.emoji,"aria-pressed":e.mine?`true`:`false`,children:[h(`span`,{className:`wui-reaction-emoji`,children:e.emoji}),h(`span`,{className:`wui-reaction-count`,children:l(e.count,{decimals:0})})]},e.emoji)),!n&&h(`button`,{type:`button`,className:`wui-reaction-add`,"data-wui-action":`react-menu`,"aria-label":v.addReaction,"aria-haspopup":`true`,"aria-expanded":`false`,children:h(r,{name:`emoji-smile`,size:16})})]}),!n&&!T&&(P||M||N)&&g(`div`,{className:`wui-comment-actions`,"data-wui-actions":``,children:[P&&h(`button`,{type:`button`,className:`wui-comment-action`,"data-wui-action":`reply`,children:v.reply}),M&&h(`button`,{type:`button`,className:`wui-comment-action`,"data-wui-action":`edit`,children:v.edit}),N&&h(`button`,{type:`button`,className:`wui-comment-action`,"data-wui-action":`delete`,children:v.delete})]}),N&&g(`div`,{className:`wui-comment-confirm`,"data-wui-confirm":``,hidden:!0,children:[h(`span`,{className:`wui-comment-confirm-text`,children:v.confirmDelete}),h(`button`,{type:`button`,className:`btn btn-danger btn-sm`,"data-wui-action":`confirm-delete`,children:v.delete}),h(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,"data-wui-action":`cancel-delete`,children:v.cancel})]}),!n&&h(`div`,{className:`wui-comment-error`,"data-wui-error":``,hidden:!0})]})]}),t&&k.length>0&&h(`ol`,{className:`wui-comment-list wui-comment-replies`,"aria-label":v.repliesName(A),children:k.map(e=>h(S,{comment:e,readOnly:n,allowReactions:f},e.id))}),P&&!n&&!T&&h(`div`,{className:`wui-comment-reply`,"data-wui-reply":``,hidden:!0})]})}export{x as default};
1
+ import{splitMarkerProps as e}from"../lib/wuiMarker.js";import t from"./warnInvalidValue.js";import n from"./warnUnknownProps.js";import r from"./AppIcon.js";import i from"./AppButton.js";import{initialsOf as a}from"../lib/initials.js";import o from"./AppAvatar.js";import s from"./AppBadge.js";import{parseMentionValue as c}from"@webority/ui-elements/elements/mention-input";import{formatDate as l,formatFileSize as u,formatNumber as d,toInstant as f}from"@webority/ui-elements/helpers";import{Fragment as p,useEffect as m,useId as h,useRef as g}from"react";import{jsx as _,jsxs as v}from"react/jsx-runtime";import{COMMENT_REACTIONS as y,COMMENT_TEXT as b}from"@webority/ui-elements/elements/comment-thread";var x=[`stacked`,`inline`],S=[`list`,`conversation`];function C(r){let{marker:a,props:s}=e(`AppCommentThread`,r),{comments:c=[],onPost:l,onReply:u,onEdit:d,onDelete:f,onReact:p,people:C,loadPeople:T,reactionChoices:E,allowReplies:D=!0,allowReactions:O=!0,composerPlaceholder:k,variant:A=`list`,composer:j=`stacked`,author:M,postLabel:N=b.post,composerRows:P,readOnly:F=!1,label:I=b.listName,id:L,className:R=``,...z}=s;n(`AppCommentThread`,z),t(`AppCommentThread`,`variant`,A,S),t(`AppCommentThread`,`composer`,j,x);let B=h(),V=L||`comment-thread-${B.replace(/[^a-zA-Z0-9_-]/g,``)}`,H=g(null),U=typeof T==`function`,W=E?.length?E:y,G=j===`inline`,K=P??(G?1:3),q=g(null);return q.current={onPost:l,onReply:u,onEdit:d,onDelete:f,onReact:p,loadPeople:T},m(()=>{let e=H.current;if(e)return e.submit=async({intent:e,commentId:t,parentId:n,body:r,emoji:i})=>{let a=q.current;e===`post`?await a.onPost?.(r):e===`reply`?await a.onReply?.(n,r):e===`edit`?await a.onEdit?.(t,r):e===`delete`?await a.onDelete?.(t):e===`react`&&await a.onReact?.(t,i)},()=>{e.submit=void 0}},[]),m(()=>{let e=H.current;!e||U||(e.people=C||[])},[C,U]),m(()=>{let e=H.current;if(!e||!U)return;let t=new WeakMap,n=async e=>{let n=e.target,r=(t.get(n)??0)+1;t.set(n,r),n.loading=!0;try{let i=await q.current.loadPeople(e.detail.query);t.get(n)===r&&(n.people=i||[])}catch{t.get(n)===r&&(n.people=[])}finally{t.get(n)===r&&(n.loading=!1)}};return e.addEventListener(`search`,n),()=>e.removeEventListener(`search`,n)},[U]),v(`wui-comment-thread`,{ref:H,id:V,class:[`wui-comment-thread`,A===`conversation`&&`wui-comment-thread--conversation`,R].filter(Boolean).join(` `),controlled:``,"read-only":F?``:void 0,remote:U?``:void 0,"reaction-choices":E?.length?E.join(` `):void 0,"no-replies":D?void 0:``,"no-reactions":O?void 0:``,"composer-placeholder":k,...a,...z,children:[_(`div`,{className:`wui-comment-items`,"data-wui-items":``,children:c.length?_(`ol`,{className:`wui-comment-list`,"aria-label":I,children:c.map(e=>_(w,{comment:e,topLevel:!0,readOnly:F,allowReplies:D,allowReactions:O},e.id))}):_(`p`,{className:`wui-comment-empty`,children:b.empty})}),!F&&O&&_(`div`,{className:`wui-reaction-picker`,role:`group`,"aria-label":b.pickerName,"data-wui-picker":``,hidden:!0,children:W.map(e=>_(`button`,{type:`button`,className:`wui-reaction-choice`,"data-wui-emoji":e,children:e},e))}),!F&&v(`div`,{className:G?`wui-comment-composer wui-comment-composer-inline`:`wui-comment-composer`,"data-wui-composer":``,children:[G&&M?_(o,{name:M,size:`sm`,tone:`auto`,className:`wui-comment-composer-avatar`}):null,_(`wui-mention-input`,{id:`${V}-new`,class:`wui-mention-input`,label:b.composerLabel,placeholder:k??b.composerPlaceholder,rows:String(K),remote:U?``:void 0}),_(`div`,{className:`wui-comment-form-actions`,children:_(i,{variant:G?`outline`:`primary`,size:`sm`,"data-wui-action":`post`,children:N})}),_(`div`,{className:`wui-comment-error`,"data-wui-error":``,hidden:!0})]}),_(`span`,{className:`visually-hidden`,"data-wui-live":``,"aria-live":`polite`,"aria-atomic":`true`})]})}function w({comment:e,topLevel:t=!1,readOnly:n,allowReplies:o,allowReactions:m}){let{id:h,author:g,at:y,value:x,edited:S,mine:C,internal:T,attachments:E=[],deleted:D,canEdit:O,canDelete:k,reactions:A=[],replies:j=[]}=e,M=g?.name||``,N=f(y),P=!n&&!D&&O,F=!n&&!D&&k,I=t&&o;return v(`li`,{className:[`wui-comment`,T&&`wui-comment--internal`,C&&`wui-comment--mine`].filter(Boolean).join(` `),"data-wui-comment":h,"data-value":x??``,"data-wui-deleted":D?``:void 0,children:[v(`div`,{className:`wui-comment-row`,children:[v(`span`,{className:`avatar avatar-sm wui-comment-avatar`,"aria-hidden":`true`,children:[_(`span`,{className:`avatar-face`,children:a(M)||`?`}),g?.src&&_(`img`,{className:`avatar-img`,src:g.src,alt:``,onError:e=>{e.currentTarget.hidden=!0}})]}),v(`div`,{className:`wui-comment-main`,children:[v(`div`,{className:`wui-comment-head`,children:[_(`span`,{className:`wui-comment-author`,children:M}),_(`time`,{className:`wui-comment-time`,dateTime:Number.isFinite(N)?new Date(N).toISOString():void 0,children:l(y,{pattern:`datetime`})}),S&&!D&&_(`span`,{className:`wui-comment-edited`,children:b.edited}),T&&_(s,{className:`wui-comment-internal-badge`,children:`Internal note`})]}),D?_(`div`,{className:`wui-comment-text wui-comment-text-deleted`,children:b.deleted}):_(`div`,{className:`wui-comment-text`,"data-wui-text":``,children:c(x).map((e,t)=>`text`in e?_(p,{children:e.text},t):v(`span`,{className:`wui-mention`,"data-mention-id":e.id,children:[`@`,e.label]},t))}),!D&&E.length>0&&_(`ul`,{className:`wui-comment-attachments`,"aria-label":`Attachments`,children:E.map(e=>v(`li`,{children:[v(`a`,{className:`wui-comment-attachment`,href:e.href,download:!0,children:[_(r,{name:`paperclip`,size:14}),e.name]}),typeof e.sizeBytes==`number`&&_(`span`,{className:`wui-comment-attachment-size`,children:u(e.sizeBytes)})]},e.href))}),P&&_(`div`,{className:`wui-comment-editor`,"data-wui-editor":``,hidden:!0}),m&&!D&&(A.length>0||!n)&&v(`div`,{className:`wui-comment-reactions`,role:`group`,"aria-label":b.reactions,children:[A.map(e=>n?v(`span`,{className:e.mine?`wui-reaction wui-reaction-mine`:`wui-reaction`,children:[_(`span`,{className:`wui-reaction-emoji`,children:e.emoji}),_(`span`,{className:`wui-reaction-count`,children:d(e.count,{decimals:0})})]},e.emoji):v(`button`,{type:`button`,className:e.mine?`wui-reaction wui-reaction-mine`:`wui-reaction`,"data-wui-emoji":e.emoji,"aria-pressed":e.mine?`true`:`false`,children:[_(`span`,{className:`wui-reaction-emoji`,children:e.emoji}),_(`span`,{className:`wui-reaction-count`,children:d(e.count,{decimals:0})})]},e.emoji)),!n&&_(`button`,{type:`button`,className:`wui-reaction-add`,"data-wui-action":`react-menu`,"aria-label":b.addReaction,"aria-haspopup":`true`,"aria-expanded":`false`,children:_(r,{name:`emoji-smile`,size:16})})]}),!n&&!D&&(I||P||F)&&v(`div`,{className:`wui-comment-actions`,"data-wui-actions":``,children:[I&&_(`button`,{type:`button`,className:`wui-comment-action`,"data-wui-action":`reply`,children:b.reply}),P&&_(`button`,{type:`button`,className:`wui-comment-action`,"data-wui-action":`edit`,children:b.edit}),F&&_(`button`,{type:`button`,className:`wui-comment-action`,"data-wui-action":`delete`,children:b.delete})]}),F&&v(`div`,{className:`wui-comment-confirm`,"data-wui-confirm":``,hidden:!0,children:[_(`span`,{className:`wui-comment-confirm-text`,children:b.confirmDelete}),_(i,{variant:`danger`,size:`sm`,"data-wui-action":`confirm-delete`,children:b.delete}),_(i,{variant:`ghost`,size:`sm`,"data-wui-action":`cancel-delete`,children:b.cancel})]}),!n&&_(`div`,{className:`wui-comment-error`,"data-wui-error":``,hidden:!0})]})]}),t&&j.length>0&&_(`ol`,{className:`wui-comment-list wui-comment-replies`,"aria-label":b.repliesName(M),children:j.map(e=>_(w,{comment:e,readOnly:n,allowReactions:m},e.id))}),I&&!n&&!D&&_(`div`,{className:`wui-comment-reply`,"data-wui-reply":``,hidden:!0})]})}export{C as default};
@@ -1 +1 @@
1
- import{splitMarkerProps as e}from"../lib/wuiMarker.js";import{devWarn as t}from"../lib/devWarn.js";import n from"./warnInvalidValue.js";import r from"./warnUnknownProps.js";import i from"./withTooltip.js";import a from"./AppIcon.js";import ee from"../lib/FieldMessage.js";import te from"./AppRequiredMark.js";import ne from"../lib/useFileDrop.js";import{keyOf as o}from"../lib/fileItem.js";import re from"../lib/FileItemRow.js";import{DEFAULT_MAX_SIZE_MB as ie,acceptDroppedFiles as ae,acceptLabel as s,isImageFile as c,isImageOnlyAccept as oe,isPdfFile as se}from"@webority/ui-elements/helpers";import{useEffect as l,useId as ce,useRef as le,useState as u}from"react";import{jsx as d,jsxs as f}from"react/jsx-runtime";var p=[`dropzone`,`button`];function m(m){let{marker:ue,props:h}=e(`AppFilePicker`,m),{label:g,value:_,name:de,id:fe,onPick:v,multiple:y=!1,variant:b=`dropzone`,buttonLabel:pe=`Add file`,maxFiles:x,accept:S=`.jpg,.jpeg,.png`,maxSizeMb:C=ie,required:w,error:me,hint:T,loading:E=!1,className:D=``,fieldClassName:O=``,style:k,...A}=h;r(`AppFilePicker`,A),n(`AppFilePicker`,`variant`,b,p);let[he,j]=u(null),[ge,M]=u(null),[N,P]=u(``),F=le(null),I=ce(),L=fe||I;l(()=>{if(!y&&_ instanceof File&&c(_)){let e=URL.createObjectURL(_);return j(e),()=>URL.revokeObjectURL(e)}j(null)},[_,y]);let R=!y&&_&&!c(_)&&se(_)?_ instanceof File?_:_.url:null;l(()=>{if(!R){M(null);return}let e=!0,n=null;return import(`@webority/ui-elements/file-viewer`).then(e=>e.renderPdfFirstPage(typeof R==`string`?{url:R}:R)).then(t=>{e&&(n=URL.createObjectURL(t),M(n))}).catch(e=>t(`[AppFilePicker] the PDF preview failed:`,e?.message)),()=>{e=!1,M(null),n&&URL.revokeObjectURL(n)}},[R]);let z=y?Array.isArray(_)?_:_?[_]:[]:[],B=me||N,V=B?`${L}-error`:void 0,H=T&&!B?`${L}-hint`:void 0,_e=V||H,U=oe(S),ve=b===`button`,W=!y&&!!_,G=W&&(_ instanceof File?c(_):U||c(_)),ye=_?.name,K=G?_?.url||he:ge,q=G?`image`:`file`,be=g?`Change ${g}`:`Change ${q}`,J=g?`Remove ${g}`:`Remove ${q}`,xe=g?`${g} preview`:`Selected ${q} preview`,Y={accept:S,maxSizeMb:C,multiple:y},X=e=>{if(P(``),!y){v(e[0]);return}let t=Array.isArray(_)?_:_?[_]:[],n=new Set(t.map(o)),r=[];for(let t of e)n.has(o(t))||(n.add(o(t)),r.push(t));let i=t.concat(r);x&&i.length>x&&(i=i.slice(0,x),P(`Up to ${x} files.`)),v(i)},Z=e=>P(e.message),{dragOver:Se,dropProps:Ce}=ne({...Y,disabled:E,onFiles:X,onReject:Z}),we=e=>{let{files:t,rejections:n}=ae(e,Y);t.length&&X(t),n.length&&Z(n[0])},Te=e=>we(e.target.files),Ee=e=>{P(``),v(z.filter((t,n)=>n!==e))},De=()=>F.current?.click(),Q=E?d(`span`,{className:`wui-file-busy`,children:d(`span`,{className:`spinner-border spinner-border-sm`,role:`status`,"aria-label":`Loading`})}):null,$=d(`input`,{id:L,name:de,ref:F,type:`file`,"aria-describedby":_e,accept:S,multiple:y||void 0,disabled:E||void 0,className:`visually-hidden`,onClick:e=>{e.currentTarget.value=``},onChange:Te,...A});return f(`div`,{...ue,className:`field${O?` ${O}`:``}`,children:[f(`label`,{className:`label`,htmlFor:L,children:[g,w&&d(te,{})]}),ve?f(`div`,{className:`file-input wui-file-input-button-field${B?` error`:``}${D?` ${D}`:``}`,style:k,"aria-busy":E||void 0,children:[f(`label`,{htmlFor:L,className:`btn btn-outline-primary btn-sm`,children:[d(a,{name:`paperclip`,size:16}),pe]}),$,Q]}):W?f(`div`,{className:`file-preview${B?` error`:``}${D?` ${D}`:``}`,style:k,"aria-busy":E||void 0,children:[f(`button`,{type:`button`,className:`file-preview-open`,"aria-label":be,onClick:De,disabled:E,children:[K?d(`img`,{src:K,alt:xe,className:`file-preview-img`}):f(`span`,{className:`file-preview-file`,children:[d(a,{name:`file-text`,size:28}),d(`span`,{className:`file-preview-file-name`,children:ye})]}),d(`span`,{className:`file-preview-overlay`,children:f(`span`,{className:`file-preview-cta`,children:[d(a,{name:G?`image`:`file-text`,size:16}),` `,G?`Change image`:`Change file`]})})]}),i(d(`button`,{type:`button`,className:`file-preview-remove`,"aria-label":J,onClick:()=>v(null),disabled:E,children:d(a,{name:`x`,size:16})}),J),$,Q]}):f(`div`,{className:`file-input file-input-tall${Se?` dragging`:``}${B?` error`:``}${y&&z.length>0?` has-files`:``}${D?` ${D}`:``}`,style:k,"aria-busy":E||void 0,...Ce,children:[f(`label`,{htmlFor:L,className:`file-input-zone-label`,children:[d(`span`,{className:`file-input-icon`,children:d(a,{name:`upload`,size:24})}),f(`span`,{className:`file-input-title`,children:[d(`span`,{className:`browse`,children:`Click to upload`}),` or drag & drop`]}),d(`span`,{className:`file-input-text`,children:C>0?`${s(S)}, up to ${C} MB`:s(S)})]}),$,Q,y&&z.length>0&&d(`div`,{className:`attach-list`,children:z.map((e,t)=>d(re,{item:e,isImage:e instanceof File?c(e):U||c(e),noun:`file`,onRemove:()=>Ee(t)},o(e)))})]}),d(ee,{error:B,hint:T,errorId:V,hintId:H})]})}export{m as default};
1
+ import{splitMarkerProps as e}from"../lib/wuiMarker.js";import{devWarn as t}from"../lib/devWarn.js";import n from"./warnInvalidValue.js";import r from"./warnUnknownProps.js";import i from"./withTooltip.js";import a from"./AppIcon.js";import ee from"../lib/FieldMessage.js";import te from"./AppRequiredMark.js";import ne from"./AppSpinner.js";import o from"../lib/useFileDrop.js";import{keyOf as s}from"../lib/fileItem.js";import re from"../lib/FileItemRow.js";import{DEFAULT_MAX_SIZE_MB as ie,acceptDroppedFiles as ae,acceptLabel as c,isImageFile as l,isImageOnlyAccept as oe,isPdfFile as se}from"@webority/ui-elements/helpers";import{useEffect as u,useId as ce,useRef as le,useState as d}from"react";import{jsx as f,jsxs as p}from"react/jsx-runtime";var m=[`dropzone`,`button`];function h(h){let{marker:ue,props:de}=e(`AppFilePicker`,h),{label:g,value:_,name:fe,id:pe,onPick:v,multiple:y=!1,variant:b=`dropzone`,buttonLabel:me=`Add file`,maxFiles:x,accept:S=`.jpg,.jpeg,.png`,maxSizeMb:C=ie,required:he,error:w,hint:T,loading:E=!1,className:D=``,fieldClassName:O=``,style:k,...A}=de;r(`AppFilePicker`,A),n(`AppFilePicker`,`variant`,b,m);let[ge,j]=d(null),[_e,M]=d(null),[N,P]=d(``),F=le(null),I=ce(),L=pe||I;u(()=>{if(!y&&_ instanceof File&&l(_)){let e=URL.createObjectURL(_);return j(e),()=>URL.revokeObjectURL(e)}j(null)},[_,y]);let R=!y&&_&&!l(_)&&se(_)?_ instanceof File?_:_.url:null;u(()=>{if(!R){M(null);return}let e=!0,n=null;return import(`@webority/ui-elements/file-viewer`).then(e=>e.renderPdfFirstPage(typeof R==`string`?{url:R}:R)).then(t=>{e&&(n=URL.createObjectURL(t),M(n))}).catch(e=>t(`[AppFilePicker] the PDF preview failed:`,e?.message)),()=>{e=!1,M(null),n&&URL.revokeObjectURL(n)}},[R]);let z=y?Array.isArray(_)?_:_?[_]:[]:[],B=w||N,V=B?`${L}-error`:void 0,H=T&&!B?`${L}-hint`:void 0,ve=V||H,U=oe(S),ye=b===`button`,W=!y&&!!_,G=W&&(_ instanceof File?l(_):U||l(_)),be=_?.name,K=G?_?.url||ge:_e,q=G?`image`:`file`,xe=g?`Change ${g}`:`Change ${q}`,J=g?`Remove ${g}`:`Remove ${q}`,Se=g?`${g} preview`:`Selected ${q} preview`,Y={accept:S,maxSizeMb:C,multiple:y},X=e=>{if(P(``),!y){v(e[0]);return}let t=Array.isArray(_)?_:_?[_]:[],n=new Set(t.map(s)),r=[];for(let t of e)n.has(s(t))||(n.add(s(t)),r.push(t));let i=t.concat(r);x&&i.length>x&&(i=i.slice(0,x),P(`Up to ${x} files.`)),v(i)},Z=e=>P(e.message),{dragOver:Ce,dropProps:we}=o({...Y,disabled:E,onFiles:X,onReject:Z}),Te=e=>{let{files:t,rejections:n}=ae(e,Y);t.length&&X(t),n.length&&Z(n[0])},Ee=e=>Te(e.target.files),De=e=>{P(``),v(z.filter((t,n)=>n!==e))},Oe=()=>F.current?.click(),Q=E?f(`span`,{className:`wui-file-busy`,children:f(ne,{size:`sm`})}):null,$=f(`input`,{id:L,name:fe,ref:F,type:`file`,"aria-describedby":ve,accept:S,multiple:y||void 0,disabled:E||void 0,className:`visually-hidden`,onClick:e=>{e.currentTarget.value=``},onChange:Ee,...A});return p(`div`,{...ue,className:`field${O?` ${O}`:``}`,children:[p(`label`,{className:`label`,htmlFor:L,children:[g,he&&f(te,{})]}),ye?p(`div`,{className:`file-input wui-file-input-button-field${B?` error`:``}${D?` ${D}`:``}`,style:k,"aria-busy":E||void 0,children:[p(`label`,{htmlFor:L,className:`btn btn-outline-primary btn-sm`,children:[f(a,{name:`paperclip`,size:16}),me]}),$,Q]}):W?p(`div`,{className:`file-preview${B?` error`:``}${D?` ${D}`:``}`,style:k,"aria-busy":E||void 0,children:[p(`button`,{type:`button`,className:`file-preview-open`,"aria-label":xe,onClick:Oe,disabled:E,children:[K?f(`img`,{src:K,alt:Se,className:`file-preview-img`}):p(`span`,{className:`file-preview-file`,children:[f(a,{name:`file-text`,size:28}),f(`span`,{className:`file-preview-file-name`,children:be})]}),f(`span`,{className:`file-preview-overlay`,children:p(`span`,{className:`file-preview-cta`,children:[f(a,{name:G?`image`:`file-text`,size:16}),` `,G?`Change image`:`Change file`]})})]}),i(f(`button`,{type:`button`,className:`file-preview-remove`,"aria-label":J,onClick:()=>v(null),disabled:E,children:f(a,{name:`x`,size:16})}),J),$,Q]}):p(`div`,{className:`file-input file-input-tall${Ce?` dragging`:``}${B?` error`:``}${y&&z.length>0?` has-files`:``}${D?` ${D}`:``}`,style:k,"aria-busy":E||void 0,...we,children:[p(`label`,{htmlFor:L,className:`file-input-zone-label`,children:[f(`span`,{className:`file-input-icon`,children:f(a,{name:`upload`,size:24})}),p(`span`,{className:`file-input-title`,children:[f(`span`,{className:`browse`,children:`Click to upload`}),` or drag & drop`]}),f(`span`,{className:`file-input-text`,children:C>0?`${c(S)}, up to ${C} MB`:c(S)})]}),$,Q,y&&z.length>0&&f(`div`,{className:`attach-list`,children:z.map((e,t)=>f(re,{item:e,isImage:e instanceof File?l(e):U||l(e),noun:`file`,onRemove:()=>De(t)},s(e)))})]}),f(ee,{error:B,hint:T,errorId:V,hintId:H})]})}export{h as default};
@@ -1 +1 @@
1
- import{splitMarkerProps as e}from"../lib/wuiMarker.js";import{devWarn as t}from"../lib/devWarn.js";import n from"./warnInvalidValue.js";import r from"./warnUnknownProps.js";import i from"./AppIcon.js";import a from"./AppButton.js";import o from"./AppSegmented.js";import ee from"./AppChip.js";import s from"./AppSelect.js";import c from"./AppDateRangePicker.js";import{emptyFacetValue as l,isFacetActive as u}from"../lib/listQuery.js";import d from"./AppMultiSelect.js";import f from"./AppSearch.js";import te from"./AppSwitch.js";import{Fragment as ne,useEffect as p,useId as re,useRef as m,useState as h,useSyncExternalStore as ie}from"react";import{Fragment as ae,jsx as g,jsxs as _}from"react/jsx-runtime";import"@webority/ui-elements/elements/filter-popover";var v=`(max-width: 575.98px)`,oe=3,y=2,b=e=>{let t=window.matchMedia?.(v);return t?.addEventListener(`change`,e),()=>t?.removeEventListener(`change`,e)},x=()=>window.matchMedia?.(v).matches??!1,S=[`enum`,`multiEnum`,`dateRange`,`text`],C=4,se=e=>(e.type===`enum`||e.type===`multiEnum`)&&!e.options?.length,w=(e,t)=>e.options?.find(e=>e.value===t)?.label??t,ce=(e,t)=>JSON.stringify(e)===JSON.stringify(t);function le(e,t){if(!u(e,t))return[];if(e.type===`enum`)return[{id:e.key,text:w(e,t),clear:()=>l(e)}];if(e.type===`multiEnum`)return t.map(n=>({id:`${e.key}:${n}`,text:w(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:()=>l(e)}]}return[]}var T=new Set;function ue(e){let n=!0;try{n=process.env.NODE_ENV!==`production`}catch{n=!0}!n||T.has(e)||(T.add(e),t(`[@webority/ui-react] <AppFilterBar> facet "${e}" sets allLabel, which only an enum facet uses.`))}var E=new Set;function de(e){let n=!0;try{n=process.env.NODE_ENV!==`production`}catch{n=!0}!n||E.has(e)||(E.add(e),t(`[@webority/ui-react] <AppFilterBar> facet "${e}" sets presets, which only a dateRange facet uses.`))}function D(t){let{marker:o,props:s}=e(`AppFilterBar`,t),{facets:c,value:d,onChange:f,inline:v=oe,floating:C=!1,apply:w=!1,className:T=``,...E}=s;r(`AppFilterBar`,E);let D=ie(b,x,()=>!1),k=m(null),A=re(),[j,M]=h({}),N=m(d);for(let e of c)n(`AppFilterBar`,`facets[].type`,e.type,S);for(let e of c)e.allLabel!=null&&e.type!==`enum`&&ue(e.key),e.presets!=null&&e.type!==`dateRange`&&de(e.key);let P=c.filter(e=>!se(e)),F=P.flatMap(e=>le(e,d[e.key]).map(t=>({...t,facet:e}))),I=P.filter(e=>u(e,d[e.key])),L=C||D?0:Math.max(0,v),R=P.slice(L),z=R.filter(e=>I.includes(e)).length,B=!C&&R.length>0;p(()=>{if(!B)return;let e=e=>{let t=k.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=d,M(t=>{let n=Object.entries(t).filter(([t])=>ce(e[t],d[t]));return n.length===Object.keys(t).length?t:Object.fromEntries(n)})},[d]);let V=e=>w&&!C&&(e.type===`text`||e.type===`dateRange`),H=e=>V(e)&&Object.hasOwn(j,e.key)?j[e.key]:d[e.key],U=e=>t=>V(e)?M(n=>({...n,[e.key]:t})):f(e.key,t),W=()=>{for(let[e,t]of Object.entries(j))f(e,t);M({})},G=e=>{e.key===`Enter`&&W()},fe=e=>{e.preventDefault(),W()},K=(e,t)=>e.type===`text`&&V(e)?g(`span`,{onKeyDownCapture:G,children:t}):t,pe=e=>g(ne,{children:K(e,g(O,{facet:e,value:H(e),onChange:U(e)}))},e.key),q=e=>_(`div`,{className:`wui-filter-popover-field`,children:[g(`span`,{className:`label`,"aria-hidden":`true`,children:e.label}),K(e,g(O,{facet:e,value:H(e),onChange:U(e),floating:!0}))]},e.key),J=(e,t)=>t>0&&g(`span`,{className:e,children:` (${t})`}),Y=e=>g(ee,{size:`sm`,label:`${e.facet.label}: ${e.text}`,removeLabel:`Remove ${e.facet.label} filter ${e.text}`,onRemove:()=>f(e.facet.key,e.clear()),className:!C&&P.indexOf(e.facet)<L?`wui-filter-chip-inline`:void 0},e.id),X=g(a,{variant:`ghost`,size:`sm`,onClick:()=>{for(let e of I)f(e.key,l(e));M({})},children:`Clear all`});if(C){let e=F.slice(y),t=I.length;return _(`div`,{className:`wui-filter-bar d-flex flex-wrap align-items-center gap-2${T?` ${T}`:``}`,...o,...E,children:[_(`wui-filter-popover`,{class:`wui-filter-popover`,children:[_(`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:[g(i,{name:`filter`,size:14,className:`me-2`}),`Filters`,t>0&&g(`span`,{className:`badge rounded-pill text-bg-primary ms-1`,children:t})]}),_(`div`,{id:A,className:`wui-filter-popover-panel`,role:`dialog`,"aria-label":`Filters`,hidden:!0,children:[_(`div`,{className:`wui-filter-popover-head`,children:[g(`span`,{className:`wui-filter-popover-title`,children:`Filters`}),g(te,{label:`Keep open`,id:`${A}-pin`})]}),g(`div`,{className:`wui-filter-popover-grid`,children:P.map(q)}),_(`div`,{className:`wui-filter-popover-foot`,children:[g(`span`,{className:`wui-filter-popover-note`,children:`Changes apply at once.`}),t>0&&X]})]})]}),F.slice(0,y).map(Y),e.length>0&&_(`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${D&&B?` wui-filter-bar--folded`:``}`,Q=e=>`${e}${T?` ${T}`:``}`,$=_(ae,{children:[P.slice(0,L).map(pe),B&&_(`details`,{ref:k,className:`wui-filter-more`,children:[_(`summary`,{className:`btn btn-outline-primary btn-sm wui-filter-more-trigger`,children:[g(i,{name:`filter`,size:14,className:`me-2`}),`Filters`,J(`wui-filter-count-desktop`,z),J(`wui-filter-count-phone`,I.length)]}),_(`div`,{className:`wui-filter-more-panel`,children:[g(`div`,{className:`wui-filter-more-head`,children:`Filters`}),R.map(q)]})]}),F.map(Y),I.length>0&&X]});return!w||!P.some(e=>e.type===`text`||e.type===`dateRange`)?g(`div`,{className:Q(Z),...o,...E,children:$}):_(`div`,{className:Q(`wui-filter-form d-flex flex-wrap align-items-center gap-2`),...o,...E,children:[g(`div`,{className:Z,children:$}),g(a,{type:`submit`,size:`sm`,onClick:fe,children:`Apply`})]})}function O({facet:e,value:t,onChange:n,floating:r=!1}){if(e.type===`enum`){let i=e.options??[];return i.length<C?g(o,{label:e.label,name:e.key,size:`sm`,value:t??``,onChange:n,options:[{value:``,label:e.allLabel||`All`},...i]}):g(s,{"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`?g(d,{"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`?g(c,{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??``})}):g(f,{ariaLabel:e.label,name:e.key,placeholder:e.label,size:`sm`,value:t??``,onChange:n})}export{D as default};
1
+ import{splitMarkerProps as e}from"../lib/wuiMarker.js";import{devWarn as t}from"../lib/devWarn.js";import n from"./warnInvalidValue.js";import r from"./warnUnknownProps.js";import i from"./AppIcon.js";import a from"./AppButton.js";import o from"./AppSegmented.js";import s from"./AppChip.js";import c from"./AppSelect.js";import l from"./AppDateRangePicker.js";import{emptyFacetValue as u,isFacetActive as d}from"../lib/listQuery.js";import f from"./AppMultiSelect.js";import p from"./AppSearch.js";import ee from"./AppSwitch.js";import{Fragment as m,useEffect as h,useId as te,useRef as g,useState as ne,useSyncExternalStore as re}from"react";import{Fragment as ie,jsx as _,jsxs as v}from"react/jsx-runtime";import"@webority/ui-elements/elements/filter-popover";var y=`(max-width: 575.98px)`,ae=3,b=2,oe=e=>{let t=window.matchMedia?.(y);return t?.addEventListener(`change`,e),()=>t?.removeEventListener(`change`,e)},se=()=>window.matchMedia?.(y).matches??!1,ce=[`enum`,`multiEnum`,`dateRange`,`text`],x=4,le=e=>(e.type===`enum`||e.type===`multiEnum`)&&!e.options?.length,S=(e,t)=>e.options?.find(e=>e.value===t)?.label??t,ue=(e,t)=>JSON.stringify(e)===JSON.stringify(t);function C(e,t){if(e.required||!d(e,t))return[];if(e.type===`enum`)return[{id:e.key,text:S(e,t),clear:()=>u(e)}];if(e.type===`multiEnum`)return t.map(n=>({id:`${e.key}:${n}`,text:S(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:()=>u(e)}]}return[]}var w=new Set;function T(e){let n=!0;try{n=process.env.NODE_ENV!==`production`}catch{n=!0}!n||w.has(e)||(w.add(e),t(`[@webority/ui-react] <AppFilterBar> facet "${e}" sets allLabel, which only an enum facet uses.`))}var E=new Set;function de(e){let n=!0;try{n=process.env.NODE_ENV!==`production`}catch{n=!0}!n||E.has(e)||(E.add(e),t(`[@webority/ui-react] <AppFilterBar> facet "${e}" sets required, which only an enum facet uses.`))}var D=new Set;function fe(e){let n=!0;try{n=process.env.NODE_ENV!==`production`}catch{n=!0}!n||D.has(e)||(D.add(e),t(`[@webority/ui-react] <AppFilterBar> facet "${e}" sets allLabel and required; a required facet has no All segment.`))}var O=new Set;function k(e){let n=!0;try{n=process.env.NODE_ENV!==`production`}catch{n=!0}!n||O.has(e)||(O.add(e),t(`[@webority/ui-react] <AppFilterBar> facet "${e}" sets presets, which only a dateRange facet uses.`))}function A(t){let{marker:o,props:c}=e(`AppFilterBar`,t),{facets:l,value:f,onChange:p,inline:y=ae,floating:x=!1,apply:S=!1,className:w=``,...E}=c;r(`AppFilterBar`,E);let D=re(oe,se,()=>!1),O=g(null),A=te(),[M,N]=ne({}),P=g(f);for(let e of l)n(`AppFilterBar`,`facets[].type`,e.type,ce);for(let e of l)e.allLabel!=null&&e.type!==`enum`&&T(e.key),e.required&&e.type!==`enum`&&de(e.key),e.required&&e.allLabel!=null&&fe(e.key),e.presets!=null&&e.type!==`dateRange`&&k(e.key);let F=l.filter(e=>!le(e)),I=F.flatMap(e=>C(e,f[e.key]).map(t=>({...t,facet:e}))),L=F.filter(e=>!e.required&&d(e,f[e.key])),R=x||D?0:Math.max(0,y),z=F.slice(R),B=z.filter(e=>L.includes(e)).length,V=!x&&z.length>0;h(()=>{if(!V)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)}},[V]),h(()=>{let e=P.current;P.current=f,N(t=>{let n=Object.entries(t).filter(([t])=>ue(e[t],f[t]));return n.length===Object.keys(t).length?t:Object.fromEntries(n)})},[f]);let H=e=>S&&!x&&(e.type===`text`||e.type===`dateRange`),U=e=>H(e)&&Object.hasOwn(M,e.key)?M[e.key]:f[e.key],W=e=>t=>H(e)?N(n=>({...n,[e.key]:t})):p(e.key,t),G=()=>{for(let[e,t]of Object.entries(M))p(e,t);N({})},pe=e=>{e.key===`Enter`&&G()},me=e=>{e.preventDefault(),G()},K=(e,t)=>e.type===`text`&&H(e)?_(`span`,{onKeyDownCapture:pe,children:t}):t,he=e=>_(m,{children:K(e,_(j,{facet:e,value:U(e),onChange:W(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:U(e),onChange:W(e),floating:!0}))]},e.key),J=(e,t)=>t>0&&_(`span`,{className:e,children:` (${t})`}),Y=e=>_(s,{size:`sm`,label:`${e.facet.label}: ${e.text}`,removeLabel:`Remove ${e.facet.label} filter ${e.text}`,onRemove:()=>p(e.facet.key,e.clear()),className:!x&&F.indexOf(e.facet)<R?`wui-filter-chip-inline`:void 0},e.id),X=_(a,{variant:`ghost`,size:`sm`,onClick:()=>{for(let e of L)p(e.key,u(e));N({})},children:`Clear all`});if(x){let e=I.slice(b),t=L.length;return v(`div`,{className:`wui-filter-bar d-flex flex-wrap align-items-center gap-2${w?` ${w}`:``}`,...o,...E,children:[v(`wui-filter-popover`,{class:`wui-filter-popover`,children:[v(a,{variant:t>0?`outline`:`ghost`,size:`sm`,leftIcon:`filter`,className:`wui-filter-popover-trigger`,"aria-expanded":`false`,"aria-controls":A,"aria-label":t>0?`Filters, ${t} active`:void 0,children:[`Filters`,t>0&&_(`span`,{className:`badge rounded-pill text-bg-primary ms-1`,children:t})]}),v(`div`,{id:A,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`}),_(ee,{label:`Keep open`,id:`${A}-pin`})]}),_(`div`,{className:`wui-filter-popover-grid`,children:F.map(q)}),v(`div`,{className:`wui-filter-popover-foot`,children:[_(`span`,{className:`wui-filter-popover-note`,children:`Changes apply at once.`}),t>0&&X]})]})]}),I.slice(0,b).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${D&&V?` wui-filter-bar--folded`:``}`,Q=e=>`${e}${w?` ${w}`:``}`,$=v(ie,{children:[F.slice(0,R).map(he),V&&v(`details`,{ref:O,className:`wui-filter-more`,children:[v(`summary`,{className:`btn btn-outline-primary btn-sm wui-filter-more-trigger`,children:[_(i,{name:`filter`,size:14,className:`me-2`}),`Filters`,J(`wui-filter-count-desktop`,B),J(`wui-filter-count-phone`,L.length)]}),v(`div`,{className:`wui-filter-more-panel`,children:[_(`div`,{className:`wui-filter-more-head`,children:`Filters`}),z.map(q)]})]}),I.map(Y),L.length>0&&X]});return!S||!F.some(e=>e.type===`text`||e.type===`dateRange`)?_(`div`,{className:Q(Z),...o,...E,children:$}):v(`div`,{className:Q(`wui-filter-form d-flex flex-wrap align-items-center gap-2`),...o,...E,children:[_(`div`,{className:Z,children:$}),_(a,{type:`submit`,size:`sm`,onClick:me,children:`Apply`})]})}function j({facet:e,value:t,onChange:n,floating:r=!1}){if(e.type===`enum`){let i=e.options??[];return(e.required?i.length<=x:i.length<x)?_(o,{label:e.label,name:e.key,size:`sm`,value:t??``,onChange:n,options:e.required?i:[{value:``,label:e.allLabel||`All`},...i]}):_(c,{"aria-label":e.label,name:e.key,placeholder:r?`Any`:e.label,clearable:!e.required,size:`sm`,value:t??``,onChange:n,options:i})}return e.type===`multiEnum`?_(f,{"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`?_(l,{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??``})}):_(p,{ariaLabel:e.label,name:e.key,placeholder:e.label,size:`sm`,value:t??``,onChange:n})}export{A as default};
@@ -1 +1 @@
1
- import{splitMarkerProps as e}from"../lib/wuiMarker.js";import t from"./warnInvalidValue.js";import n from"./warnUnknownProps.js";import ee from"./withTooltip.js";import r from"./AppIcon.js";import te from"./AppAlert.js";import ne from"./AppButton.js";import re from"../lib/FieldMessage.js";import ie from"./AppRequiredMark.js";import ae from"./AppModal.js";import oe from"../lib/useFileDrop.js";import{AVATAR_ACCEPT as se,AVATAR_MAX_SIZE_MB as i,AVATAR_OUTPUT_SIZE as ce,AVATAR_OUTPUT_TYPE as a,AVATAR_PREVIEW_SIZES as le,AVATAR_TEXT as o,DEFAULT_IMAGE_ACCEPT as s,DEFAULT_MAX_SIZE_MB as c,avatarUnreadableMessage as l,validateFile as ue}from"@webority/ui-elements/helpers";import{useCallback as de,useEffect as fe,useId as pe,useRef as me,useState as u}from"react";import{Fragment as he,jsx as d,jsxs as f}from"react/jsx-runtime";import"@webority/ui-elements/elements/image-crop";var ge=[`logo`,`avatar`],_e=[`overlay`,`buttons`],ve=[`stacked`,`inline`,`profile`],ye=[`initials`,`avatar`],be=[`circle`,`rounded`,`square`],xe=[`keep`,`image/webp`],Se=le.join(` `),Ce={logo:{controls:`overlay`,accept:s,maxSizeMb:c,crop:void 0,rotatable:!1,previews:!1,camera:!1,outputSize:void 0,outputType:`keep`,variant:`initials`,sizes:{sm:72,md:120,lg:160}},avatar:{controls:`buttons`,accept:se,maxSizeMb:i,crop:1,rotatable:!0,previews:!0,camera:!0,outputSize:ce,outputType:a,variant:`avatar`,sizes:{sm:64,md:96,lg:128}}},p=`That image could not be cropped. Choose another one.`,we=`That image could not be opened. Choose another one.`,Te={dialogSize:`lg`,dialogTitle:`Crop photo`,dialogSubtitle:`Drag the frame and zoom to choose what to keep.`,save:`Apply`,cancel:`Cancel`,cropFailed:p,unreadable:()=>we},Ee={dialogSize:void 0,dialogTitle:o.dialogTitle,dialogSubtitle:o.dialogSubtitle,save:o.save,cancel:o.cancel,cropFailed:o.cropFailed,unreadable:l};function m(se){let{marker:i,props:ce}=e(`AppImagePicker`,se),{kind:a=`logo`,controls:le,value:s,fallback:c,variant:l,name:p,onPick:we,onRemove:m,removeName:h,loading:g=!1,disabled:De=!1,accept:Oe,maxSizeMb:ke,shape:_=`circle`,size:v=`md`,crop:Ae,rotatable:je,previews:Me,camera:Ne,outputSize:Pe,outputType:Fe,layout:y=`stacked`,title:Ie,subtitle:Le,overlayIcon:Re=`image`,overlayLabel:ze=`Update photo`,removeLabel:b=`Remove photo`,ariaLabel:Be,label:Ve,hint:x,error:He,required:Ue=!1,className:S=``,fieldClassName:We=``,style:C,...w}=ce;n(`AppImagePicker`,w),t(`AppImagePicker`,`kind`,a,ge),t(`AppImagePicker`,`controls`,le,_e),t(`AppImagePicker`,`variant`,l,ye),t(`AppImagePicker`,`layout`,y,ve),t(`AppImagePicker`,`shape`,_,be),t(`AppImagePicker`,`outputType`,Fe,xe);let T=Ce[a]??Ce.logo,E=a===`avatar`?Ee:Te,D=T.sizes;t(`AppImagePicker`,`size`,typeof v==`string`?v:null,Object.keys(D));let Ge=(le??T.controls)===`overlay`,Ke=l??T.variant,O=Oe??T.accept,k=ke??T.maxSizeMb,A=Pe??T.outputSize,qe=Fe??T.outputType,Je=je??T.rotatable,Ye=Me??T.previews,Xe=Ne??T.camera,j=Ae??T.crop,M=j===`free`?null:typeof j==`number`&&Number.isFinite(j)&&j>0?j:void 0;j!=null&&M===void 0&&t(`AppImagePicker`,`crop`,String(j),[`free`,`a positive number`]);let Ze=M!==void 0&&A===void 0,N=me(null),Qe=me(null),P=me(null),F=pe(),[I,L]=u(null),[$e,R]=u(!1),[et,z]=u(!1),[tt,B]=u(``),[V,H]=u(null),[U,nt]=u(!1),[W,G]=u(`loading`),[rt,K]=u(``),it=de(e=>{if(P.current=e,!e)return;let t=()=>{G(`ready`),e.querySelector(`.wui-crop-stage`)?.focus()},n=()=>G(`error`);return e.addEventListener(`load`,t),e.addEventListener(`error`,n),()=>{e.removeEventListener(`load`,t),e.removeEventListener(`error`,n),P.current=null}},[]);fe(()=>()=>V&&URL.revokeObjectURL(V.url),[V]),fe(()=>()=>I&&URL.revokeObjectURL(I),[I]);let[at,ot]=u(s);s!==at&&(ot(s),L(null),R(!1),z(!1));let q=g||De,J=$e?null:I||(s&&!et?s:null),st=!!J,Y=He||tt,X=x&&!Y?`${F}-hint`:void 0,Z=Y?`${F}-error`:void 0,ct=Z||X,lt=!q&&st&&(!!I||!!m||!!h),ut=st?o.change:o.choose,dt=typeof v==`number`?v:D[v]??D.md,ft=()=>{q||N.current?.click()},pt=()=>{q||Qe.current?.click()},mt=e=>{if(p&&N.current&&typeof DataTransfer==`function`){let t=new DataTransfer;t.items.add(e),N.current.files=t.files}R(!1),z(!1),L(URL.createObjectURL(e)),we(e)},ht=e=>{let t=M!==void 0&&e.type!==`image/svg+xml`,n=ue(e,{accept:O,maxSizeMb:t&&Ze?0:k});if(n){B(n);return}if(B(``),t){G(`loading`),K(``),H({file:e,url:URL.createObjectURL(e)});return}mt(e)},{dragOver:gt,dropProps:_t}=oe({accept:O,maxSizeMb:Ze?0:k,disabled:q,onFiles:e=>ht(e[0]),onReject:({message:e})=>B(e)}),vt=e=>{let t=qe===`keep`?e.type:qe;return A===void 0?{name:e.name,type:t,maxBytes:k>0?k*1024*1024:0}:{name:e.name||`photo`,type:t,size:A}},yt=async()=>{let{file:e}=V;nt(!0),K(``);let t=null;try{t=await P.current?.toFile(vt(e))}catch{t=null}if(nt(!1),!t){K(E.cropFailed);return}if(H(null),Ze){let e=ue(t,{accept:O,maxSizeMb:k});e?B(e):mt(t);return}mt(t)},bt=()=>{U||H(null)},xt=e=>{let t=e.target.files?.[0];e.target.value=``,t&&ht(t)},St=()=>{L(null),R(!0),B(``),N.current&&(N.current.value=``),m?.()},Q=M!==void 0&&f(ae,{open:!!V,title:E.dialogTitle,subtitle:E.dialogSubtitle,size:E.dialogSize,staticBackdrop:!0,dismissible:!U,onClose:bt,footer:f(he,{children:[d(ne,{type:`button`,variant:`secondary`,disabled:U,onClick:bt,children:E.cancel}),d(ne,{type:`button`,variant:`primary`,loading:U,disabled:W!==`ready`,onClick:yt,children:E.save})]}),children:[W===`error`&&V&&d(te,{variant:`danger`,children:E.unreadable(V.file)}),rt&&d(te,{variant:`danger`,children:rt}),V&&W!==`error`&&d(`wui-image-crop`,{ref:it,src:V.url,aspect:M??`free`,round:M===1&&_===`circle`,rotatable:Je,previews:Ye?Se:void 0})]}),Ct=h&&d(`input`,{type:`hidden`,name:h,value:`true`,disabled:!$e}),$=Ve&&f(`label`,{className:`label`,htmlFor:F,children:[Ve,Ue&&d(ie,{})]}),wt=d(`input`,{id:F,ref:N,type:`file`,name:p,hidden:!0,accept:O,disabled:q,onChange:xt});if(!Ge){let e=dt,t=Xe&&f(`button`,{type:`button`,className:`btn btn-secondary btn-sm wui-image-picker-buttons-camera`,disabled:q,onClick:pt,children:[d(r,{name:`camera`,size:16}),o.camera]});return f(`div`,{...i,className:`field wui-image-picker-field${We?` ${We}`:``}`,children:[$,f(`div`,{className:`wui-image-picker-buttons${gt?` is-dragging`:``}${S?` ${S}`:``}`,style:{"--wui-avatar-size":`${e}px`,...C},..._t,children:[f(`button`,{type:`button`,className:`wui-image-picker-buttons-face`,tabIndex:-1,"aria-label":Be??ut,"aria-describedby":ct,"aria-busy":g||void 0,disabled:q,onClick:ft,...w,children:[J?d(`img`,{className:`wui-image-picker-buttons-img`,src:J,alt:``,onError:()=>z(!0)}):d(`span`,{className:`wui-image-picker-buttons-placeholder`,"aria-hidden":`true`,children:c||d(r,{name:`user`,size:Math.round(e*.5)})}),d(`span`,{className:`wui-image-picker-buttons-badge`,"aria-hidden":`true`,children:g?d(r,{name:`refresh-cw`,size:14,className:`wui-spin`}):d(r,{name:`camera`,size:14})})]}),f(`div`,{className:`wui-image-picker-buttons-actions`,children:[d(`button`,{type:`button`,className:`btn btn-secondary btn-sm`,disabled:q,"aria-describedby":ct,onClick:ft,children:ut}),t,d(`button`,{type:`button`,className:`btn btn-secondary-danger btn-sm`,"data-wui-image-picker-remove":!0,hidden:!lt,onClick:St,children:b})]}),wt,Xe&&d(`input`,{ref:Qe,type:`file`,hidden:!0,accept:`image/*`,capture:`user`,disabled:q,onChange:xt}),Ct]}),d(re,{error:Y,hint:x,errorId:Z,hintId:X}),Q]})}let Tt=dt,Et=Math.max(14,Math.round(Tt*.18)),Dt=Math.round(Tt*.5),Ot=`wui-image-picker${Ke===`avatar`?` wui-image-picker-avatar`:``}${_===`rounded`?` wui-image-picker-rounded`:_===`square`?` wui-image-picker-square`:``}${gt?` is-dragging`:``}`,kt=y===`inline`,At=y===`profile`,jt=[`field`,`wui-image-picker-field`,kt&&`wui-image-picker-field-inline`,At&&`wui-image-picker-field-profile`,S,We].filter(Boolean).join(` `),Mt=f(`div`,{className:`wui-image-picker-shell`,style:{"--wui-logo-size":`${Tt}px`},children:[d(`button`,{type:`button`,className:Ot,onClick:ft,disabled:q,"aria-busy":g||void 0,"aria-label":Be??`Upload photo`,"aria-describedby":Z||X,..._t,...w,children:f(`span`,{className:`wui-image-picker-ring`,"data-overlay-label":ze,children:[J?d(`img`,{className:`wui-image-picker-img`,src:J,alt:``,onError:()=>z(!0)}):d(`span`,{className:`wui-image-picker-logo`,children:c||Ke===`avatar`&&d(r,{name:`user`,size:Dt})}),g?d(`span`,{className:`wui-image-picker-overlay is-loading`,"aria-hidden":`true`,children:d(r,{name:`refresh-cw`,size:Et,className:`wui-spin`})}):!De&&f(`span`,{className:`wui-image-picker-overlay`,children:[d(r,{name:Re,size:Et}),d(`span`,{children:ze})]})]})}),ee(d(`button`,{type:`button`,className:`wui-image-picker-remove`,hidden:!lt,"aria-label":b,"data-wui-image-picker-remove":!0,onClick:St,children:d(r,{name:`x`,size:14})}),lt?b:null),wt,Ct]}),Nt=x&&!Y?d(`div`,{className:`wui-image-picker-hint`,id:X,children:x}):null,Pt=Y?d(re,{error:Y,errorId:Z}):null,Ft=f(`div`,{className:`wui-image-picker-meta`,children:[Ie&&d(`div`,{className:`wui-image-picker-title`,children:Ie}),Le&&d(`div`,{className:`wui-image-picker-subtitle`,children:Le}),Nt,Pt]});return kt?f(`div`,{...i,className:jt,style:C,children:[$,f(`div`,{className:`wui-image-picker-row`,children:[Mt,Ft]}),Q]}):At?f(`div`,{...i,className:jt,style:C,children:[$,Mt,Ft,Q]}):f(`div`,{...i,className:jt,style:C,children:[$,Mt,Nt,Pt,Q]})}export{m as default};
1
+ import{splitMarkerProps as e}from"../lib/wuiMarker.js";import t from"./warnInvalidValue.js";import n from"./warnUnknownProps.js";import ee from"./withTooltip.js";import r from"./AppIcon.js";import te from"./AppAlert.js";import i from"./AppButton.js";import ne from"../lib/FieldMessage.js";import re from"./AppRequiredMark.js";import ie from"./AppModal.js";import ae from"../lib/useFileDrop.js";import{AVATAR_ACCEPT as oe,AVATAR_MAX_SIZE_MB as a,AVATAR_OUTPUT_SIZE as se,AVATAR_OUTPUT_TYPE as o,AVATAR_PREVIEW_SIZES as ce,AVATAR_TEXT as s,DEFAULT_IMAGE_ACCEPT as c,DEFAULT_MAX_SIZE_MB as l,avatarUnreadableMessage as u,validateFile as le}from"@webority/ui-elements/helpers";import{useCallback as ue,useEffect as de,useId as fe,useRef as d,useState as f}from"react";import{Fragment as pe,jsx as p,jsxs as m}from"react/jsx-runtime";import"@webority/ui-elements/elements/image-crop";var me=[`logo`,`avatar`],he=[`overlay`,`buttons`],ge=[`stacked`,`inline`,`profile`],_e=[`initials`,`avatar`],ve=[`circle`,`rounded`,`square`],ye=[`keep`,`image/webp`],be=ce.join(` `),xe={logo:{controls:`overlay`,accept:c,maxSizeMb:l,crop:void 0,rotatable:!1,previews:!1,camera:!1,outputSize:void 0,outputType:`keep`,variant:`initials`,sizes:{sm:72,md:120,lg:160}},avatar:{controls:`buttons`,accept:oe,maxSizeMb:a,crop:1,rotatable:!0,previews:!0,camera:!0,outputSize:se,outputType:o,variant:`avatar`,sizes:{sm:64,md:96,lg:128}}},Se=`That image could not be cropped. Choose another one.`,Ce=`That image could not be opened. Choose another one.`,we={dialogSize:`lg`,dialogTitle:`Crop photo`,dialogSubtitle:`Drag the frame and zoom to choose what to keep.`,save:`Apply`,cancel:`Cancel`,cropFailed:Se,unreadable:()=>Ce},Te={dialogSize:void 0,dialogTitle:s.dialogTitle,dialogSubtitle:s.dialogSubtitle,save:s.save,cancel:s.cancel,cropFailed:s.cropFailed,unreadable:u};function Ee(oe){let{marker:a,props:se}=e(`AppImagePicker`,oe),{kind:o=`logo`,controls:ce,value:c,fallback:l,variant:u,name:Se,onPick:Ce,onRemove:Ee,removeName:h,loading:g=!1,disabled:De=!1,accept:Oe,maxSizeMb:ke,shape:_=`circle`,size:v=`md`,crop:Ae,rotatable:je,previews:Me,camera:Ne,outputSize:Pe,outputType:Fe,layout:y=`stacked`,title:Ie,subtitle:Le,overlayIcon:Re=`image`,overlayLabel:ze=`Update photo`,removeLabel:b=`Remove photo`,ariaLabel:Be,label:Ve,hint:x,error:He,required:Ue=!1,className:We=``,fieldClassName:S=``,style:C,...w}=se;n(`AppImagePicker`,w),t(`AppImagePicker`,`kind`,o,me),t(`AppImagePicker`,`controls`,ce,he),t(`AppImagePicker`,`variant`,u,_e),t(`AppImagePicker`,`layout`,y,ge),t(`AppImagePicker`,`shape`,_,ve),t(`AppImagePicker`,`outputType`,Fe,ye);let T=xe[o]??xe.logo,E=o===`avatar`?Te:we,D=T.sizes;t(`AppImagePicker`,`size`,typeof v==`string`?v:null,Object.keys(D));let Ge=(ce??T.controls)===`overlay`,Ke=u??T.variant,O=Oe??T.accept,k=ke??T.maxSizeMb,A=Pe??T.outputSize,qe=Fe??T.outputType,Je=je??T.rotatable,Ye=Me??T.previews,Xe=Ne??T.camera,j=Ae??T.crop,M=j===`free`?null:typeof j==`number`&&Number.isFinite(j)&&j>0?j:void 0;j!=null&&M===void 0&&t(`AppImagePicker`,`crop`,String(j),[`free`,`a positive number`]);let Ze=M!==void 0&&A===void 0,N=d(null),Qe=d(null),P=d(null),F=fe(),[I,L]=f(null),[$e,R]=f(!1),[et,z]=f(!1),[tt,B]=f(``),[V,H]=f(null),[U,nt]=f(!1),[W,G]=f(`loading`),[rt,K]=f(``),it=ue(e=>{if(P.current=e,!e)return;let t=()=>{G(`ready`),e.querySelector(`.wui-crop-stage`)?.focus()},n=()=>G(`error`);return e.addEventListener(`load`,t),e.addEventListener(`error`,n),()=>{e.removeEventListener(`load`,t),e.removeEventListener(`error`,n),P.current=null}},[]);de(()=>()=>V&&URL.revokeObjectURL(V.url),[V]),de(()=>()=>I&&URL.revokeObjectURL(I),[I]);let[at,ot]=f(c);c!==at&&(ot(c),L(null),R(!1),z(!1));let q=g||De,J=$e?null:I||(c&&!et?c:null),st=!!J,Y=He||tt,X=x&&!Y?`${F}-hint`:void 0,Z=Y?`${F}-error`:void 0,ct=Z||X,lt=!q&&st&&(!!I||!!Ee||!!h),ut=st?s.change:s.choose,dt=typeof v==`number`?v:D[v]??D.md,ft=()=>{q||N.current?.click()},pt=()=>{q||Qe.current?.click()},mt=e=>{if(Se&&N.current&&typeof DataTransfer==`function`){let t=new DataTransfer;t.items.add(e),N.current.files=t.files}R(!1),z(!1),L(URL.createObjectURL(e)),Ce(e)},ht=e=>{let t=M!==void 0&&e.type!==`image/svg+xml`,n=le(e,{accept:O,maxSizeMb:t&&Ze?0:k});if(n){B(n);return}if(B(``),t){G(`loading`),K(``),H({file:e,url:URL.createObjectURL(e)});return}mt(e)},{dragOver:gt,dropProps:_t}=ae({accept:O,maxSizeMb:Ze?0:k,disabled:q,onFiles:e=>ht(e[0]),onReject:({message:e})=>B(e)}),vt=e=>{let t=qe===`keep`?e.type:qe;return A===void 0?{name:e.name,type:t,maxBytes:k>0?k*1024*1024:0}:{name:e.name||`photo`,type:t,size:A}},yt=async()=>{let{file:e}=V;nt(!0),K(``);let t=null;try{t=await P.current?.toFile(vt(e))}catch{t=null}if(nt(!1),!t){K(E.cropFailed);return}if(H(null),Ze){let e=le(t,{accept:O,maxSizeMb:k});e?B(e):mt(t);return}mt(t)},bt=()=>{U||H(null)},xt=e=>{let t=e.target.files?.[0];e.target.value=``,t&&ht(t)},St=()=>{L(null),R(!0),B(``),N.current&&(N.current.value=``),Ee?.()},Q=M!==void 0&&m(ie,{open:!!V,title:E.dialogTitle,subtitle:E.dialogSubtitle,size:E.dialogSize,staticBackdrop:!0,dismissible:!U,onClose:bt,footer:m(pe,{children:[p(i,{type:`button`,variant:`secondary`,disabled:U,onClick:bt,children:E.cancel}),p(i,{type:`button`,variant:`primary`,loading:U,disabled:W!==`ready`,onClick:yt,children:E.save})]}),children:[W===`error`&&V&&p(te,{variant:`danger`,children:E.unreadable(V.file)}),rt&&p(te,{variant:`danger`,children:rt}),V&&W!==`error`&&p(`wui-image-crop`,{ref:it,src:V.url,aspect:M??`free`,round:M===1&&_===`circle`,rotatable:Je,previews:Ye?be:void 0})]}),Ct=h&&p(`input`,{type:`hidden`,name:h,value:`true`,disabled:!$e}),$=Ve&&m(`label`,{className:`label`,htmlFor:F,children:[Ve,Ue&&p(re,{})]}),wt=p(`input`,{id:F,ref:N,type:`file`,name:Se,hidden:!0,accept:O,disabled:q,onChange:xt});if(!Ge){let e=dt,t=Xe&&m(`button`,{type:`button`,className:`btn btn-secondary btn-sm wui-image-picker-buttons-camera`,disabled:q,onClick:pt,children:[p(r,{name:`camera`,size:16}),s.camera]});return m(`div`,{...a,className:`field wui-image-picker-field${S?` ${S}`:``}`,children:[$,m(`div`,{className:`wui-image-picker-buttons${gt?` is-dragging`:``}${We?` ${We}`:``}`,style:{"--wui-avatar-size":`${e}px`,...C},..._t,children:[m(`button`,{type:`button`,className:`wui-image-picker-buttons-face`,tabIndex:-1,"aria-label":Be??ut,"aria-describedby":ct,"aria-busy":g||void 0,disabled:q,onClick:ft,...w,children:[J?p(`img`,{className:`wui-image-picker-buttons-img`,src:J,alt:``,onError:()=>z(!0)}):p(`span`,{className:`wui-image-picker-buttons-placeholder`,"aria-hidden":`true`,children:l||p(r,{name:`user`,size:Math.round(e*.5)})}),p(`span`,{className:`wui-image-picker-buttons-badge`,"aria-hidden":`true`,children:g?p(r,{name:`refresh-cw`,size:14,className:`wui-spin`}):p(r,{name:`camera`,size:14})})]}),m(`div`,{className:`wui-image-picker-buttons-actions`,children:[p(i,{variant:`secondary`,size:`sm`,disabled:q,"aria-describedby":ct,onClick:ft,children:ut}),t,p(i,{variant:`secondary-danger`,size:`sm`,"data-wui-image-picker-remove":!0,hidden:!lt,onClick:St,children:b})]}),wt,Xe&&p(`input`,{ref:Qe,type:`file`,hidden:!0,accept:`image/*`,capture:`user`,disabled:q,onChange:xt}),Ct]}),p(ne,{error:Y,hint:x,errorId:Z,hintId:X}),Q]})}let Tt=dt,Et=Math.max(14,Math.round(Tt*.18)),Dt=Math.round(Tt*.5),Ot=`wui-image-picker${Ke===`avatar`?` wui-image-picker-avatar`:``}${_===`rounded`?` wui-image-picker-rounded`:_===`square`?` wui-image-picker-square`:``}${gt?` is-dragging`:``}`,kt=y===`inline`,At=y===`profile`,jt=[`field`,`wui-image-picker-field`,kt&&`wui-image-picker-field-inline`,At&&`wui-image-picker-field-profile`,We,S].filter(Boolean).join(` `),Mt=m(`div`,{className:`wui-image-picker-shell`,style:{"--wui-logo-size":`${Tt}px`},children:[p(`button`,{type:`button`,className:Ot,onClick:ft,disabled:q,"aria-busy":g||void 0,"aria-label":Be??`Upload photo`,"aria-describedby":Z||X,..._t,...w,children:m(`span`,{className:`wui-image-picker-ring`,"data-overlay-label":ze,children:[J?p(`img`,{className:`wui-image-picker-img`,src:J,alt:``,onError:()=>z(!0)}):p(`span`,{className:`wui-image-picker-logo`,children:l||Ke===`avatar`&&p(r,{name:`user`,size:Dt})}),g?p(`span`,{className:`wui-image-picker-overlay is-loading`,"aria-hidden":`true`,children:p(r,{name:`refresh-cw`,size:Et,className:`wui-spin`})}):!De&&m(`span`,{className:`wui-image-picker-overlay`,children:[p(r,{name:Re,size:Et}),p(`span`,{children:ze})]})]})}),ee(p(`button`,{type:`button`,className:`wui-image-picker-remove`,hidden:!lt,"aria-label":b,"data-wui-image-picker-remove":!0,onClick:St,children:p(r,{name:`x`,size:14})}),lt?b:null),wt,Ct]}),Nt=x&&!Y?p(`div`,{className:`wui-image-picker-hint`,id:X,children:x}):null,Pt=Y?p(ne,{error:Y,errorId:Z}):null,Ft=m(`div`,{className:`wui-image-picker-meta`,children:[Ie&&p(`div`,{className:`wui-image-picker-title`,children:Ie}),Le&&p(`div`,{className:`wui-image-picker-subtitle`,children:Le}),Nt,Pt]});return kt?m(`div`,{...a,className:jt,style:C,children:[$,m(`div`,{className:`wui-image-picker-row`,children:[Mt,Ft]}),Q]}):At?m(`div`,{...a,className:jt,style:C,children:[$,Mt,Ft,Q]}):m(`div`,{...a,className:jt,style:C,children:[$,Mt,Nt,Pt,Q]})}export{Ee as default};
@@ -1 +1 @@
1
- import{splitMarkerProps as e}from"../lib/wuiMarker.js";import t from"./warnUnknownProps.js";import{formatNumber as n}from"@webority/ui-elements/helpers";import{jsx as r,jsxs as i}from"react/jsx-runtime";function a(a){let{marker:o,props:s}=e(`AppTableToolbar`,a),{filters:c,actions:l,selectedCount:u=0,bulkActions:d,onClearSelection:f,totalCount:p,pageCount:m,onSelectAllMatching:h,allMatchingSelected:g=!1,className:_=``,...v}=s;t(`AppTableToolbar`,v);let y=u>0,b=typeof h==`function`&&typeof p==`number`,x=b&&g,S=e=>n(e,{decimals:0}),C=b&&!x&&y&&u>=(m??1)&&p>(m??u);return i(`div`,{className:`wui-table-toolbar${_?` ${_}`:``}`,...o,...v,children:[i(`div`,{className:`wui-table-toolbar-main`,hidden:y,children:[r(`div`,{className:`wui-table-toolbar-filters`,children:c}),r(`div`,{className:`wui-table-toolbar-actions`,children:l})]}),i(`div`,{className:`wui-table-toolbar-bulk`,hidden:!y,children:[i(`span`,{className:`wui-table-toolbar-count`,"aria-live":`polite`,children:[x?`All ${S(p)}`:S(u),` selected`]}),b&&i(`button`,{type:`button`,className:`btn btn-link btn-sm wui-table-toolbar-all`,hidden:!C,onClick:h,children:[`Select all `,S(p),` matching`]}),d,f&&r(`button`,{type:`button`,className:`btn btn-ghost btn-sm wui-table-toolbar-clear`,onClick:f,children:x?`Clear selection`:`Clear`})]})]})}export{a as default};
1
+ import{splitMarkerProps as e}from"../lib/wuiMarker.js";import t from"./warnUnknownProps.js";import n from"./AppButton.js";import{formatNumber as r}from"@webority/ui-elements/helpers";import{jsx as i,jsxs as a}from"react/jsx-runtime";function o(o){let{marker:s,props:c}=e(`AppTableToolbar`,o),{filters:l,actions:u,selectedCount:d=0,bulkActions:f,onClearSelection:p,totalCount:m,pageCount:h,onSelectAllMatching:g,allMatchingSelected:_=!1,className:v=``,...y}=c;t(`AppTableToolbar`,y);let b=d>0,x=typeof g==`function`&&typeof m==`number`,S=x&&_,C=e=>r(e,{decimals:0}),w=x&&!S&&b&&d>=(h??1)&&m>(h??d);return a(`div`,{className:`wui-table-toolbar${v?` ${v}`:``}`,...s,...y,children:[a(`div`,{className:`wui-table-toolbar-main`,hidden:b,children:[i(`div`,{className:`wui-table-toolbar-filters`,children:l}),i(`div`,{className:`wui-table-toolbar-actions`,children:u})]}),a(`div`,{className:`wui-table-toolbar-bulk`,hidden:!b,children:[a(`span`,{className:`wui-table-toolbar-count`,"aria-live":`polite`,children:[S?`All ${C(m)}`:C(d),` selected`]}),x&&a(`button`,{type:`button`,className:`btn btn-link btn-sm wui-table-toolbar-all`,hidden:!w,onClick:g,children:[`Select all `,C(m),` matching`]}),f,p&&i(n,{variant:`ghost`,size:`sm`,className:`wui-table-toolbar-clear`,onClick:p,children:S?`Clear selection`:`Clear`})]})]})}export{o as default};
@@ -2,7 +2,7 @@
2
2
  "format": "webority-guidance/1",
3
3
  "package": {
4
4
  "name": "@webority/ui-react",
5
- "version": "0.109.7"
5
+ "version": "0.109.9"
6
6
  },
7
7
  "components": [
8
8
  {
@@ -1 +1 @@
1
- import{jsx as e,jsxs as t}from"react/jsx-runtime";function n({text:n,confirmRef:r,onDiscard:i,onKeep:a}){return t(`div`,{className:`wui-drawer-discard`,role:`alert`,children:[e(`span`,{className:`wui-drawer-discard-text`,children:n}),e(`button`,{type:`button`,className:`btn btn-danger btn-sm`,"data-wui-discard-confirm":``,ref:r,onClick:i,children:`Discard`}),e(`button`,{type:`button`,className:`btn btn-secondary btn-sm`,"data-wui-discard-keep":``,onClick:a,children:`Keep editing`})]})}export{n as default};
1
+ import e from"../components/AppButton.js";import{jsx as t,jsxs as n}from"react/jsx-runtime";function r({text:r,confirmRef:i,onDiscard:a,onKeep:o}){return n(`div`,{className:`wui-drawer-discard`,role:`alert`,children:[t(`span`,{className:`wui-drawer-discard-text`,children:r}),t(e,{variant:`danger`,size:`sm`,"data-wui-discard-confirm":``,ref:i,onClick:a,children:`Discard`}),t(e,{variant:`secondary`,size:`sm`,"data-wui-discard-keep":``,onClick:o,children:`Keep editing`})]})}export{r as default};
@@ -7,7 +7,7 @@ import "@webority/ui-elements/elements/filter-popover";
7
7
  * `value` is an object keyed by facet key. A facet's value is a string for `enum` and `text`, an array
8
8
  * of strings for `multiEnum`, and `{ from, to }` (yyyy-MM-dd strings) for `dateRange`; the empty value
9
9
  * is "", [] and `{ from: "", to: "" }`. An `enum` shows as segments (with an "All" segment, renamed by `allLabel`) up to three
10
- * options and as a clearable select beyond that. A `text` facet has no chip: its box shows the text
10
+ * options and as a clearable select beyond that. A `required` enum always holds one of its options: it has no All segment or empty choice, its select cannot be cleared, and it draws no chip and is left out of Clear all and the Filters count. A `text` facet has no chip: its box shows the text
11
11
  * and clears itself. The controls, chips and Clear all share one row, the search box wider and
12
12
  * selects and date ranges narrow; it wraps only when full, and each facet takes its own line on a phone.
13
13
  *
@@ -22,7 +22,7 @@ import "@webority/ui-elements/elements/filter-popover";
22
22
  *
23
23
  * @param {object} props
24
24
  * @param {{ key: string, label: string, type: 'enum'|'multiEnum'|'dateRange'|'text',
25
- * options?: { value: string, label: string }[], allLabel?: string, presets?: string[] }[]} props.facets
25
+ * options?: { value: string, label: string }[], allLabel?: string, required?: boolean, presets?: string[] }[]} props.facets
26
26
  * @param {Record<string, string|string[]|{ from: string, to: string }>} props.value
27
27
  * @param {(key: string, value: string|string[]|{ from: string, to: string }) => void} props.onChange
28
28
  * Called with the facet key and its new value. Clear all calls it once per active facet, with the empty value.
@@ -42,6 +42,7 @@ export default function AppFilterBar(props: {
42
42
  label: string;
43
43
  }[];
44
44
  allLabel?: string;
45
+ required?: boolean;
45
46
  presets?: string[];
46
47
  }[];
47
48
  /** The current filters, keyed by facet key: a string, a list of strings, or a { from, to } date range. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webority/ui-react",
3
- "version": "0.109.7",
3
+ "version": "0.109.9",
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",
@@ -29,8 +29,8 @@
29
29
  },
30
30
  "sideEffects": false,
31
31
  "dependencies": {
32
- "@webority/theme": "0.109.7",
33
- "@webority/ui-elements": "0.109.7"
32
+ "@webority/theme": "0.109.9",
33
+ "@webority/ui-elements": "0.109.9"
34
34
  },
35
35
  "peerDependencies": {
36
36
  "@webority/analytics": "^0.28.0",
@@ -56,8 +56,8 @@
56
56
  "typescript": "^7.0.2",
57
57
  "vite": "^8.0.12",
58
58
  "vitest": "5.0.1",
59
- "@webority/canvas-kit": "0.109.7",
60
- "@webority/tokens": "0.109.7"
59
+ "@webority/canvas-kit": "0.109.9",
60
+ "@webority/tokens": "0.109.9"
61
61
  },
62
62
  "scripts": {
63
63
  "build": "vite build && tsc -p tsconfig.json && node ../../scripts/inject-meta-docs.mjs && node ../canvas-kit/dist/cli.js build --config canvas-kit.json --out dist/canvas-kit && node ../canvas-kit/dist/cli.js guidance --config canvas-kit.json --out dist/guidance.json && node ../../scripts/sync-rcl-assets.mjs analytics",