zavadil-react-common 1.2.132 → 1.2.133

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -1,2 +1,2 @@
1
- import{jsxs as e,jsx as n,Fragment as t}from"react/jsx-runtime";import{StringUtil as i,DateUtil as r,NumberUtil as a,CancellablePromise as o,EntityClientWithStub as l,BasicLocalization as c,ObjectUtil as d,UserAlertType as s,ByteUtil as u}from"zavadil-ts-common";import{useMemo as h,useCallback as m,useState as p,useRef as f,useEffect as g,createContext as v,useContext as b}from"react";import{InputGroup as y,Form as C,Button as w,Spinner as x,Dropdown as z,Pagination as N,Table as k,Stack as S,ProgressBar as O,Modal as P,Badge as I,Placeholder as E}from"react-bootstrap";import{BsXCircle as B,BsTrash as M,BsFillCaretDownFill as A,BsFillCaretUpFill as L,BsCheckCircle as G,BsCircle as j,BsCheckAll as D,BsBug as F,BsExclamationDiamond as H,BsInfo as T,BsQuestion as V,BsEye as R}from"react-icons/bs";import{FaFloppyDisk as U}from"react-icons/fa6";import{VscEyeClosed as J}from"react-icons/vsc";var K=function(){return K=Object.assign||function(e){for(var n,t=1,i=arguments.length;t<i;t++)for(var r in n=arguments[t])Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r]);return e},K.apply(this,arguments)};function Y(e,n,t){if(t||2===arguments.length)for(var i,r=0,a=n.length;r<a;r++)!i&&r in n||(i||(i=Array.prototype.slice.call(n,0,r)),i[r]=n[r]);return e.concat(i||Array.prototype.slice.call(n))}function q(t){var r=t.value,a=t.onChange,o=t.onReset,l=t.onBlur,c=t.disabled,d=t.className,s=h((function(){return i.getNonEmpty(r)}),[r]),u=h((function(){return i.isBlank(r)}),[s]),p=m((function(){o?o():a("")}),[o,a]);return e(y,K({className:d},{children:[n(C.Control,{type:"text",disabled:c,value:s,onChange:function(e){return a(e.target.value)},onBlur:l}),n(w,K({onClick:p,disabled:u},{children:n("div",K({className:"d-flex align-items-center"},{children:n(B,{})}))}))]}))}function Q(e){var t=e.value,i=e.onChange,a=e.disabled;return n(C.Control,{type:"date",disabled:a,value:r.formatDateForInput(t),onChange:function(e){i(r.parseDate(e.target.value))}})}function W(e){var t=e.value,i=e.onChange,a=e.disabled;return n(C.Control,{type:"datetime-local",disabled:a,value:r.formatDateTimeForInput(t),onChange:function(e){i(r.parseDate(e.target.value))}})}function X(t){var i=t.disabled,r=t.variant,a=t.icon,o=t.size,l=t.children,c=t.onClick;return n(w,K({disabled:!0===i,size:o,onClick:c,variant:r},{children:e("div",K({className:"d-flex align-items-center gap-2"},{children:[a,l&&n("div",{children:l})]}))}))}function Z(t){var i=t.disabled,r=t.checked,a=t.iconOn,o=t.iconOff,l=t.size,c=t.onChange;return e("div",K({className:"d-flex align-items-center gap-2 cursor-pointer",onClick:function(e){return c(!r)}},{children:[n(C.Switch,{disabled:i,size:l,type:"switch",checked:r,readOnly:!0,className:"cursor-pointer"}),r?a:o]}))}function $(e){var t=e.disabled,i=e.icon,r=e.loading,a=e.children,o=e.size;e.variant;var l=e.onClick;return n(X,K(!0===r?{disabled:!0,onClick:l,size:o,icon:n(x,{size:"sm"})}:{disabled:t,onClick:l,icon:i,size:o},{children:a}))}function _(e){var t=e.disabled,i=e.icon,r=e.loading,a=e.children,o=e.size,l=e.onClick,c=e.isChanged,d=h((function(){return i||n(U,{})}),[i]),s=h((function(){return c?n("strong",{children:a}):a}),[c,a]);return n($,K({disabled:t||!1===c,onClick:l,icon:d,loading:r,size:o},{children:s}))}function ee(e){var t=e.disabled,i=e.icon,r=e.loading,a=e.children,o=e.size,l=e.onClick,c=e.isChanged,d=h((function(){return i||n(M,{})}),[i]);return n($,K({disabled:t||!1===c,onClick:l,icon:d,loading:r,size:o,variant:"danger"},{children:a}))}function ne(t){var r=t.value,a=t.options,o=t.disabled,l=t.onChange,c=t.showEmptyOption,d=t.emptyOptionLabel;return i.isEmpty(r)&&a.length>0&&!0!==c?(l(a[0].id),e("span",{children:[r," - selecting default ",a[0].id]})):e(C.Select,K({value:r||"",onChange:function(e){return l(e.target.value)},disabled:o},{children:[!0===c&&n("option",K({value:""},{children:d||""}),""),a?a.map((function(e,t){return n("option",K({value:e.id||""},{children:e.label||""}),t)})):n("span",{children:n(x,{})})]}))}function te(e){var t=e.value,i=e.options,r=e.disabled,o=e.onChange,l=e.showEmptyOption,c=e.emptyOptionLabel,d=h((function(){return t?String(t):""}),[t]),s=h((function(){return i?i.map((function(e){return{id:e.id?String(e.id):"",label:e.label}})):[]}),[i]),u=m((function(e){return o(a.parseNumber(e))}),[o]);return n(ne,{disabled:r,value:d,options:s,onChange:u,showEmptyOption:l,emptyOptionLabel:c})}function ie(e){var t=e.id,i=e.sort,r=e.disabled,a=e.labelGetter,o=e.onChange,l=e.options,c=e.showEmptyOption,d=e.emptyOptionLabel,s=h((function(){var e=[];return l&&(e=i?l.sort((function(e,n){return e.name>n.name?1:-1})):l),e.map((function(e){return{id:e.id,label:a?a(e):e.name}}))}),[l]);return n(te,{disabled:r,value:t,options:s,onChange:o,showEmptyOption:c,emptyOptionLabel:d})}function re(e){var t=e.value,i=e.options,r=e.onChange,a=e.showEmptyOption,o=e.emptyOptionLabel,l=h((function(){return i?i.map((function(e){return{id:e,label:e}})):[]}),[i]);return n(ne,{value:t,options:l,onChange:r,showEmptyOption:a,emptyOptionLabel:o})}function ae(e){var t=e.id,i=e.label,r=e.disabled,a=e.checked,o=e.size,l=e.onChange;return n(C.Switch,{disabled:r,id:t,size:o,type:"switch",checked:a,onChange:function(e){return l(!a)},className:"cursor-pointer",label:i})}function oe(t){var i=t.selected,r=t.disabled,a=t.labelGetter,l=t.onChange,c=t.onSearch,d=p(),s=d[0],u=d[1],v=p(),b=v[0],y=v[1],C=p(),w=C[0],x=C[1],N=f(),k=m((function(e){return a?a(e):"name"in e&&"string"==typeof e.name?e.name:"[".concat(e.id,"]")}),[a]),S=h((function(){return i?"border rounded border-primary":void 0}),[i]),O=m((function(){console.log("user left control"),w&&(x(void 0),y(i?k(i):""))}),[l,w,i,k]),P=m((function(){N.current=window.setTimeout(O,100)}),[N,O]),I=m((function(){N.current&&clearTimeout(N.current)}),[N]);g((function(){return I}),[]),g((function(){y(i?k(i):""),s&&(s.cancel(),u(void 0)),x(void 0)}),[i]);var E=m((function(){l(null),y(""),s&&(s.cancel(),u(void 0)),x(void 0)}),[l,s]),B=m((function(e){y(e),s&&s.cancel();var n=new o(c(e));n.promise.then(x),u(n)}),[s,c]),M=m((function(e){console.log("user selected item"),x(void 0),l(K({},e))}),[l]);return n("div",K({onBlur:P,onFocus:I},{children:e(z,K({defaultShow:!1,show:null!==w},{children:[n(q,{disabled:r,value:b,onChange:B,onReset:E,className:S}),w&&n(z.Menu,{children:w.map((function(e){return n(z.Item,K({onClick:function(n){I(),M(e)},active:e.id===(null==i?void 0:i.id)},{children:k(e)}),e.id)}))})]}))}))}function le(e){var t=e.selected,r=e.disabled,a=e.labelGetter,o=e.onChange,l=e.entityClient,c=m((function(e){return l.loadPage({search:i.safeLowercase(e),page:0,size:10,sorting:[{name:"id"}]}).then((function(e){return e.content}))}),[a]);return n(oe,{disabled:r,selected:t,labelGetter:a,onSearch:c,onChange:o})}function ce(e){var t=e.id,i=e.disabled,r=e.labelGetter,a=e.onChange,o=e.entityClient,c=p(null),d=c[0],s=c[1];g((function(){t?d&&d.id===t?s(K({},d)):o instanceof l?o.loadSingleStub(t).then(s):o.loadSingle(t).then(s):s(null)}),[t]);var u=m((function(e){var n=e?e.id:null;n!==t&&a(n),s(e)}),[t,a]);return n(le,{disabled:i,selected:d,labelGetter:r,entityClient:o,onChange:u})}function de(e){var t=e.selected,r=e.disabled,a=e.labelGetter,o=e.onChange,l=e.lookupClient,c=h((function(){return a||function(e){return e.name}}),[a]),d=m((function(e){return l.loadPage({search:i.safeLowercase(e),page:0,size:10,sorting:[{name:"name"}]}).then((function(e){return e.content}))}),[a]);return n(oe,{disabled:r,selected:t,labelGetter:c,onSearch:d,onChange:o})}function se(e){var t=e.id,i=e.disabled,r=e.labelGetter,a=e.onChange,o=e.lookupClient,l=p(null),c=l[0],d=l[1];g((function(){t?c&&c.id===t?d(K({},c)):o.loadSingle(t).then(d):d(null)}),[t]);var s=m((function(e){var n=e?e.id:null;n!==t&&a(n),d(e)}),[t,c]);return n(de,{disabled:i,selected:c,labelGetter:r,lookupClient:o,onChange:s})}"function"==typeof SuppressedError&&SuppressedError;var ue=v(new c);function he(e){var i=e.text,r=e.tag,a=b(ue),o=h((function(){if(void 0!==r&&""!==r)return"string"==typeof r?{tags:[r]}:{tags:r}}),[r]),l=h((function(){return a.translate(i,o)}),[a,i,o]);return n(t,{children:l})}function me(e){var t=e.paging,i=e.totalItems,r=e.onPagingChanged,a=Math.ceil(i/t.size),o=function(e){t.page=e,r(d.clone(t))},l=[];if(a>1){l.push(n(N.First,{onClick:function(){return o(0)},disabled:0===t.page},"first")),l.push(n(N.Prev,{onClick:function(){return o(t.page-1)},disabled:0===t.page},"prev"));var c=Math.round(3.5),s=t.page>c?t.page-c:0,u=s+10;u>=a&&(u=a-1),s>0&&l.push(n(N.Ellipsis,{disabled:!0},"ellipsisStart"));for(var h=function(e){l.push(n(N.Item,K({active:e===t.page,onClick:function(){return o(e)}},{children:e+1}),e))},m=s;m<=u;m++)h(m);u<a-1&&l.push(n(N.Ellipsis,{disabled:!0},"ellipsisEnd")),l.push(n(N.Next,{onClick:function(){return o(t.page+1)},disabled:t.page===a-1},"next")),l.push(n(N.Last,{onClick:function(){return o(a-1)},disabled:t.page===a-1},"last"))}return n(N,K({size:"sm",className:"flex-wrap m-0"},{children:l}))}var pe=[{id:10,label:"10"},{id:100,label:"100"},{id:1e3,label:"1000"}];function fe(r){var a=r.hover,o=r.showPagingOnBottom,l=r.showPageSizeSelection,c=r.striped,s=r.bordered,u=r.header,m=r.children,p=r.paging,f=r.totalItems,g=r.onPagingChanged,v=Math.ceil(f/p.size),b=h((function(){var e=p.size;if(null===pe.find((function(n){return n.id===e}))){var n=d.clone(pe);return n.push({id:e,label:String(e)}),n}return pe}),[p]);return n("div",{children:e(k,K({hover:a,striped:c,responsive:!0,bordered:s},{children:[e("thead",{children:[n("tr",{children:n("td",K({colSpan:u.length},{children:e("div",K({className:"d-flex justify-content-between align-items-center gap-2"},{children:[e("div",{children:[n(he,{text:"Page"}),": ",p.page+1," / ",v]}),v>0&&n(me,{paging:p,totalItems:f,onPagingChanged:g}),e("div",{children:[n(he,{text:"Total items"}),": ",f]})]}))}))}),n("tr",{children:u.map((function(r,a){var o=!1===r.sort?"":i.isBlank(r.sort)?r.name:r.sort;if(i.isBlank(o)||!o)return n("th",{children:r.label},a);var l=p.sorting&&p.sorting.find((function(e){return e.name===o}));return e("th",K({className:"user-select-none text-nowrap",role:"button",onClick:function(e){return function(e,n){p.sorting||(p.sorting=[]);var t=p.sorting.find((function(e){return e.name===n})),i=t&&1===p.sorting.length;e.ctrlKey||i||(p.sorting=[],t=void 0),t?t.desc=!t.desc:p.sorting.push({name:n}),g(d.clone(p))}(e,o)}},{children:[r.label,l?l.desc?n(A,{}):n(L,{}):n(t,{})]}),a)}))})]}),n("tbody",{children:m}),f>0&&e("tfoot",{children:[o&&n("tr",{children:n("td",K({colSpan:u.length},{children:e("div",K({className:"d-flex justify-content-between align-items-center gap-2"},{children:[e("div",{children:[n(he,{text:"Page"}),": ",p.page+1," / ",v]}),v>0&&n(me,{paging:p,totalItems:f,onPagingChanged:g}),e("div",{children:[n(he,{text:"Total items"}),": ",f]})]}))}))}),l&&n("tr",{children:n("td",K({colSpan:u.length},{children:e("div",K({className:"d-flex align-items-center gap-2 justify-content-end"},{children:[e("div",K({className:"text-nowrap"},{children:[n(he,{text:"Page size"}),":"]})),n("div",{children:n(te,{value:p.size,options:b,onChange:function(e){p.size=e||10,g(K({},p))},showEmptyOption:!1})})]}))}))})]})]}))})}function ge(e){e.disabled;var t=e.checked,i=e.iconOn,r=e.iconOff,a=e.size,o=e.onChange,l=h((function(){return t?i||n(G,{size:a}):r||n(j,{size:a,className:"text-muted"})}),[t,i,r,a]);return n("div",K({className:"d-flex align-items-center cursor-pointer",onClick:function(e){e.stopPropagation(),e.preventDefault(),o(!t)}},{children:l}))}function ve(t){var i=t.showSelect,r=t.header,a=t.items,o=t.onSelect,l=t.onClick,c=t.totalItems,s=t.paging,u=t.onPagingChanged,f=p(!1),v=f[0],b=f[1],y=p(),C=y[0],w=y[1],x=m((function(e){C&&w(C.map((function(n){return{selected:e,item:n.item}}))),b(e)}),[C]),z=h((function(){var e=Y([],r,!0);return!1!==i&&e.unshift({name:"",label:n("div",K({className:"py-1"},{children:n(ge,{checked:v,onChange:function(){return x(!v)},iconOn:n(D,{})})}))}),e}),[r,v,x]);return g((function(){w(a?a.map((function(e){return{selected:v,item:e}})):void 0)}),[a]),g((function(){C&&o&&o(C.filter((function(e){return e.selected})).map((function(e){return e.item})))}),[C,o]),n(fe,K({header:z,hover:void 0!==l,paging:s,striped:!0,totalItems:c,onPagingChanged:u},{children:C&&C.map((function(t,a){return e("tr",K({className:"selectable ".concat(l?"cursor-pointer":""," ").concat(t.selected?"table-active table-primary":""),onClick:function(e){l&&l(t.item)}},{children:[!1!==i&&n("td",{children:n("div",K({className:"py-2 d-flex align-items-center"},{children:n(ge,{checked:t.selected,onChange:function(){t.selected=!t.selected,v&&!t.selected&&b(!1),w(Y([],C,!0))}})}))}),r.map((function(e,i){var r,a=e.renderer||(r=e.name,function(e){return d.getNestedValue(e,r)});return n("td",{children:a(t.item)},i)}))]}),a)}))}))}function be(e){var t=e.cols,i=e.rows,r=e.size,a=h((function(){return void 0===t?1:t}),[t]),o=h((function(){return void 0===i?20:i}),[i]);return h((function(){return void 0===r?"lg":r}),[r]),n("div",{children:n(k,K({responsive:!0},{children:n("tbody",{children:Array.from({length:o},(function(e,t){return n("tr",{children:Array.from({length:a},(function(e,t){return n("td",{children:n("div",{className:"w-100 p-1 m-1"})},t)}))},t)}))})}))})}var ye=new Map([[s.error,F],[s.warning,H],[s.info,T]]);function Ce(e){var t=e.type,i=e.size,r=e.customVariant,a=ye.get(t)||V;return n("div",K({className:"d-flex align-items-center text-".concat(void 0===r?t:r)},{children:a({size:i})}))}function we(t){var i=t.userAlert,a=t.maxDurationMs;return e(S,K({direction:"horizontal",gap:2,className:"align-items-center"},{children:[i.remainsMs&&n("div",K({style:{width:20}},{children:n(O,{min:0,max:a,now:i.remainsMs,variant:i.type})})),n("div",{children:r.formatDateForHumans(i.time)}),n(Ce,{type:i.type}),n("div",{children:i.message})]}))}function xe(i){var r=i.userAlerts,a=p(!1),o=a[0],l=a[1],c=p(r.alerts.length),d=c[0],s=c[1],u=p(Y([],r.visibleAlerts,!0)),h=u[0],f=u[1],v=p(r.getSummary()),b=v[0],y=v[1],C=m((function(){s(r.alerts.length),f(Y([],o?r.alerts:r.visibleAlerts,!0)),y(r.getSummary())}),[r,o]);return g((function(){r.addOnChangeHandler(C);var e=setInterval((function(){return r.updateVisibility()}),100);return function(){clearInterval(e),r.removeOnChangeHandler(C)}}),[r,C]),d<=0?n(t,{}):e("div",K({className:"user-alerts border rounded bg-body text-body position-fixed text-end",style:{bottom:15,right:15,zIndex:2147483647}},{children:[h.length>0&&n("div",K({className:"max-w-50 p-2 border-bottom"},{children:h.map((function(e,t){return n(we,{userAlert:e,maxDurationMs:r.maxVisibilityMs},t)}))})),n("div",K({className:"p-2"},{children:e(S,K({direction:"horizontal",gap:2,className:"justify-content-end align-items-center"},{children:[n(X,o?K({size:"sm",variant:"primary",onClick:function(){return l(!1)},icon:n(J,{})},{children:"Hide"}):K({size:"sm",variant:"primary",onClick:function(){return l(!0)},icon:n(R,{})},{children:"Show All"})),Array.from(b.entries()).map((function(t,i){return e(S,K({direction:"horizontal",gap:1,className:"px-1 border rounded align-items-center"},{children:[n(Ce,{type:t[0],customVariant:0===t[1]?"muted":void 0}),n("div",K({className:t[1]>0?"text-".concat(t[0]," fw-bold"):"text-muted"},{children:t[1]}))]}),i)})),n(X,K({size:"sm",variant:"danger",onClick:function(){return r.reset()},icon:n(M,{})},{children:"Reset"}))]}))}))]}))}var ze=function(){function e(e){this.setProps=e}return e.prototype.confirm=function(e,n,t){var i=this;this.setProps({name:e,text:n,onConfirm:function(){t(),i.setProps(void 0)},onClose:function(){return i.setProps(void 0)}})},e}(),Ne=v(new ze((function(){})));function ke(t){var i=t.name,r=t.text,a=t.onClose,o=t.onConfirm;return e(P,K({show:!0,backdrop:!0,onHide:a},{children:[n(P.Header,{children:i||"Confirm"}),n(P.Body,{children:r}),n(P.Footer,{children:e(S,K({direction:"horizontal"},{children:[n(w,K({variant:"link",onClick:a},{children:n(he,{text:"Back"})})),n(w,K({variant:"primary",onClick:o},{children:n(he,{text:"Yes"})}))]}))})]}))}function Se(t){var i=t.stats,r=i.heapSize,a=i.heapMaxSize,o=i.heapFreeSize,l=r-o;return e("div",{children:[e("div",K({className:"d-flex align-items-center gap-2"},{children:[n("pre",{children:"Java Heap"}),e("pre",{children:["[",u.formatByteSize(r)," / ",u.formatByteSize(a),"]"]})]})),e("div",K({className:"d-flex align-items-center gap-2"},{children:[n("pre",{children:"Used:"}),n(I,K({className:"bg-warning text-bg-warning"},{children:u.formatByteSize(l)})),n("pre",{children:"Free:"}),n(I,K({className:"bg-success text-white"},{children:u.formatByteSize(o)}))]})),n("div",K({className:"p-1"},{children:e(O,K({min:0,max:a},{children:[n(O,{variant:"warning",min:0,now:l,max:a}),n(O,{variant:"success",min:0,now:o,max:a})]}))}))]})}function Oe(t){var i=t.name,r=t.stats;return e("div",{children:[e("div",K({className:"d-flex align-items-center gap-2"},{children:[n("pre",{children:i}),e("pre",{children:["[",r.cachedItems,r.capacity>0&&" / ",r.capacity>0&&r.capacity,"]"]})]})),r.capacity>0&&n("div",K({className:"p-1"},{children:n(O,{now:r.cachedItems,min:0,max:r.capacity})}))]})}var Pe=new Map([["Idle","secondary"],["Processing","success"],["Loading","warn"]]);function Ie(e){var t=e.state,i=Pe.get(t)||"light";return n(I,K({className:"bg-".concat(i," text-bg-").concat(i)},{children:t}))}function Ee(t){var i=t.name,r=t.stats,a=r?r.remaining+r.processed:void 0;return e("div",{children:[e("div",K({className:"d-flex align-items-center gap-2"},{children:[n("pre",{children:i}),e("pre",{children:["[",void 0!==(null==r?void 0:r.processed)?r.processed:"?"," / ",void 0!==a?a:"?","]"]}),n(Ie,{state:r?r.state:"Unknown"})]})),n("div",K({className:"p-1"},{children:r?n(O,{variant:"primary",striped:!0,animated:!0,min:0,now:r.processed,max:a||1}):n(E,K({className:"w-100",animation:"glow"},{children:n(E,{className:"w-100"})}))}))]})}function Be(e){var t=e.children,i=e.center,r=h((function(){return!1===i?"":"d-flex align-items-center justify-content-center"}),[i]);return n("div",K({className:"w-100 h-100 position-absolute ".concat(r),style:{left:0,right:0,top:0,bottom:0}},{children:t}))}export{fe as AdvancedTable,ce as AutocompleteEntityIdSelect,le as AutocompleteEntitySelect,se as AutocompleteLookupIdSelect,de as AutocompleteLookupSelect,oe as AutocompleteSelect,Oe as CacheStatsControl,ke as ConfirmDialog,Ne as ConfirmDialogContext,ze as ConfirmDialogContextData,Q as DateInput,W as DateTimeInput,ee as DeleteButton,re as EnumSelect,X as IconButton,Z as IconSwitch,Se as JavaHeapControl,$ as LoadingButton,ue as LocalizationContext,he as Localize,ie as LookupSelect,te as NumberSelect,Ie as QueueStateControl,Ee as QueueStatsControl,_ as SaveButton,Be as Spread,ne as StringSelect,ae as Switch,me as TablePagination,be as TablePlaceholder,ve as TableWithSelect,q as TextInputWithReset,Ce as UserAlertTypeIcon,we as UserAlertWidget,xe as UserAlertsWidget};
1
+ import{jsxs as e,jsx as n,Fragment as t}from"react/jsx-runtime";import{StringUtil as i,DateUtil as r,NumberUtil as a,CancellablePromise as o,EntityClientWithStub as l,BasicLocalization as c,ObjectUtil as d,UserAlertType as s,ByteUtil as u}from"zavadil-ts-common";import{useMemo as h,useCallback as m,useState as p,useRef as f,useEffect as g,createContext as v,useContext as b}from"react";import{InputGroup as y,Form as C,Button as w,Spinner as x,Dropdown as z,Pagination as N,Table as k,Stack as S,ProgressBar as O,Modal as P,Badge as I,Placeholder as E}from"react-bootstrap";import{BsXCircle as B,BsTrash as M,BsFillCaretDownFill as A,BsFillCaretUpFill as L,BsCheckCircle as G,BsCircle as j,BsCheckAll as D,BsBug as F,BsExclamationDiamond as H,BsInfo as T,BsQuestion as V,BsEye as R}from"react-icons/bs";import{FaFloppyDisk as U}from"react-icons/fa6";import{VscEyeClosed as J}from"react-icons/vsc";var K=function(){return K=Object.assign||function(e){for(var n,t=1,i=arguments.length;t<i;t++)for(var r in n=arguments[t])Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r]);return e},K.apply(this,arguments)};function Y(e,n,t){if(t||2===arguments.length)for(var i,r=0,a=n.length;r<a;r++)!i&&r in n||(i||(i=Array.prototype.slice.call(n,0,r)),i[r]=n[r]);return e.concat(i||Array.prototype.slice.call(n))}function q(t){var r=t.value,a=t.onChange,o=t.onReset,l=t.onBlur,c=t.disabled,d=t.className,s=h((function(){return i.getNonEmpty(r)}),[r]),u=h((function(){return i.isBlank(r)}),[s]),p=m((function(){o?o():a("")}),[o,a]);return e(y,K({className:d},{children:[n(C.Control,{type:"text",disabled:c,value:s,onChange:function(e){return a(e.target.value)},onBlur:l}),n(w,K({onClick:p,disabled:u},{children:n("div",K({className:"d-flex align-items-center"},{children:n(B,{})}))}))]}))}function Q(e){var t=e.value,i=e.onChange,a=e.disabled;return n(C.Control,{type:"date",disabled:a,value:r.formatDateForInput(t),onChange:function(e){i(r.parseDate(e.target.value))}})}function W(e){var t=e.value,i=e.onChange,a=e.disabled;return n(C.Control,{type:"datetime-local",disabled:a,value:r.formatDateTimeForInput(t),onChange:function(e){i(r.parseDate(e.target.value))}})}function X(t){var i=t.disabled,r=t.variant,a=t.icon,o=t.size,l=t.children,c=t.onClick;return n(w,K({disabled:!0===i,size:o,onClick:c,variant:r},{children:e("div",K({className:"d-flex align-items-center gap-2"},{children:[a,l&&n("div",{children:l})]}))}))}function Z(t){var i=t.disabled,r=t.checked,a=t.iconOn,o=t.iconOff,l=t.size,c=t.onChange;return e("div",K({className:"d-flex align-items-center gap-2 cursor-pointer",onClick:function(e){return c(!r)}},{children:[n(C.Switch,{disabled:i,size:l,type:"switch",checked:r,readOnly:!0,className:"cursor-pointer"}),r?a:o]}))}function $(e){var t=e.disabled,i=e.icon,r=e.loading,a=e.children,o=e.size,l=e.variant,c=e.onClick;return n(X,K(!0===r?{disabled:!0,onClick:c,size:o,variant:l,icon:n(x,{size:"sm"})}:{disabled:t,onClick:c,icon:i,size:o,variant:l},{children:a}))}function _(e){var t=e.disabled,i=e.icon,r=e.loading,a=e.children,o=e.size,l=e.onClick,c=e.isChanged,d=h((function(){return i||n(U,{})}),[i]),s=h((function(){return c?n("strong",{children:a}):a}),[c,a]);return n($,K({disabled:t||!1===c,onClick:l,icon:d,loading:r,size:o},{children:s}))}function ee(e){var t=e.disabled,i=e.icon,r=e.loading,a=e.children,o=e.size,l=e.onClick,c=e.isChanged,d=h((function(){return i||n(M,{})}),[i]);return n($,K({disabled:t||!1===c,onClick:l,icon:d,loading:r,size:o,variant:"danger"},{children:a}))}function ne(t){var r=t.value,a=t.options,o=t.disabled,l=t.onChange,c=t.showEmptyOption,d=t.emptyOptionLabel;return i.isEmpty(r)&&a.length>0&&!0!==c?(l(a[0].id),e("span",{children:[r," - selecting default ",a[0].id]})):e(C.Select,K({value:r||"",onChange:function(e){return l(e.target.value)},disabled:o},{children:[!0===c&&n("option",K({value:""},{children:d||""}),""),a?a.map((function(e,t){return n("option",K({value:e.id||""},{children:e.label||""}),t)})):n("span",{children:n(x,{})})]}))}function te(e){var t=e.value,i=e.options,r=e.disabled,o=e.onChange,l=e.showEmptyOption,c=e.emptyOptionLabel,d=h((function(){return t?String(t):""}),[t]),s=h((function(){return i?i.map((function(e){return{id:e.id?String(e.id):"",label:e.label}})):[]}),[i]),u=m((function(e){return o(a.parseNumber(e))}),[o]);return n(ne,{disabled:r,value:d,options:s,onChange:u,showEmptyOption:l,emptyOptionLabel:c})}function ie(e){var t=e.id,i=e.sort,r=e.disabled,a=e.labelGetter,o=e.onChange,l=e.options,c=e.showEmptyOption,d=e.emptyOptionLabel,s=h((function(){var e=[];return l&&(e=i?l.sort((function(e,n){return e.name>n.name?1:-1})):l),e.map((function(e){return{id:e.id,label:a?a(e):e.name}}))}),[l]);return n(te,{disabled:r,value:t,options:s,onChange:o,showEmptyOption:c,emptyOptionLabel:d})}function re(e){var t=e.value,i=e.options,r=e.onChange,a=e.showEmptyOption,o=e.emptyOptionLabel,l=h((function(){return i?i.map((function(e){return{id:e,label:e}})):[]}),[i]);return n(ne,{value:t,options:l,onChange:r,showEmptyOption:a,emptyOptionLabel:o})}function ae(e){var t=e.id,i=e.label,r=e.disabled,a=e.checked,o=e.size,l=e.onChange;return n(C.Switch,{disabled:r,id:t,size:o,type:"switch",checked:a,onChange:function(e){return l(!a)},className:"cursor-pointer",label:i})}function oe(t){var i=t.selected,r=t.disabled,a=t.labelGetter,l=t.onChange,c=t.onSearch,d=p(),s=d[0],u=d[1],v=p(),b=v[0],y=v[1],C=p(),w=C[0],x=C[1],N=f(),k=m((function(e){return a?a(e):"name"in e&&"string"==typeof e.name?e.name:"[".concat(e.id,"]")}),[a]),S=h((function(){return i?"border rounded border-primary":void 0}),[i]),O=m((function(){console.log("user left control"),w&&(x(void 0),y(i?k(i):""))}),[l,w,i,k]),P=m((function(){N.current=window.setTimeout(O,100)}),[N,O]),I=m((function(){N.current&&clearTimeout(N.current)}),[N]);g((function(){return I}),[]),g((function(){y(i?k(i):""),s&&(s.cancel(),u(void 0)),x(void 0)}),[i]);var E=m((function(){l(null),y(""),s&&(s.cancel(),u(void 0)),x(void 0)}),[l,s]),B=m((function(e){y(e),s&&s.cancel();var n=new o(c(e));n.promise.then(x),u(n)}),[s,c]),M=m((function(e){console.log("user selected item"),x(void 0),l(K({},e))}),[l]);return n("div",K({onBlur:P,onFocus:I},{children:e(z,K({defaultShow:!1,show:null!==w},{children:[n(q,{disabled:r,value:b,onChange:B,onReset:E,className:S}),w&&n(z.Menu,{children:w.map((function(e){return n(z.Item,K({onClick:function(n){I(),M(e)},active:e.id===(null==i?void 0:i.id)},{children:k(e)}),e.id)}))})]}))}))}function le(e){var t=e.selected,r=e.disabled,a=e.labelGetter,o=e.onChange,l=e.entityClient,c=m((function(e){return l.loadPage({search:i.safeLowercase(e),page:0,size:10,sorting:[{name:"id"}]}).then((function(e){return e.content}))}),[a]);return n(oe,{disabled:r,selected:t,labelGetter:a,onSearch:c,onChange:o})}function ce(e){var t=e.id,i=e.disabled,r=e.labelGetter,a=e.onChange,o=e.entityClient,c=p(null),d=c[0],s=c[1];g((function(){t?d&&d.id===t?s(K({},d)):o instanceof l?o.loadSingleStub(t).then(s):o.loadSingle(t).then(s):s(null)}),[t]);var u=m((function(e){var n=e?e.id:null;n!==t&&a(n),s(e)}),[t,a]);return n(le,{disabled:i,selected:d,labelGetter:r,entityClient:o,onChange:u})}function de(e){var t=e.selected,r=e.disabled,a=e.labelGetter,o=e.onChange,l=e.lookupClient,c=h((function(){return a||function(e){return e.name}}),[a]),d=m((function(e){return l.loadPage({search:i.safeLowercase(e),page:0,size:10,sorting:[{name:"name"}]}).then((function(e){return e.content}))}),[a]);return n(oe,{disabled:r,selected:t,labelGetter:c,onSearch:d,onChange:o})}function se(e){var t=e.id,i=e.disabled,r=e.labelGetter,a=e.onChange,o=e.lookupClient,l=p(null),c=l[0],d=l[1];g((function(){t?c&&c.id===t?d(K({},c)):o.loadSingle(t).then(d):d(null)}),[t]);var s=m((function(e){var n=e?e.id:null;n!==t&&a(n),d(e)}),[t,c]);return n(de,{disabled:i,selected:c,labelGetter:r,lookupClient:o,onChange:s})}"function"==typeof SuppressedError&&SuppressedError;var ue=v(new c);function he(e){var i=e.text,r=e.tag,a=b(ue),o=h((function(){if(void 0!==r&&""!==r)return"string"==typeof r?{tags:[r]}:{tags:r}}),[r]),l=h((function(){return a.translate(i,o)}),[a,i,o]);return n(t,{children:l})}function me(e){var t=e.paging,i=e.totalItems,r=e.onPagingChanged,a=Math.ceil(i/t.size),o=function(e){t.page=e,r(d.clone(t))},l=[];if(a>1){l.push(n(N.First,{onClick:function(){return o(0)},disabled:0===t.page},"first")),l.push(n(N.Prev,{onClick:function(){return o(t.page-1)},disabled:0===t.page},"prev"));var c=Math.round(3.5),s=t.page>c?t.page-c:0,u=s+10;u>=a&&(u=a-1),s>0&&l.push(n(N.Ellipsis,{disabled:!0},"ellipsisStart"));for(var h=function(e){l.push(n(N.Item,K({active:e===t.page,onClick:function(){return o(e)}},{children:e+1}),e))},m=s;m<=u;m++)h(m);u<a-1&&l.push(n(N.Ellipsis,{disabled:!0},"ellipsisEnd")),l.push(n(N.Next,{onClick:function(){return o(t.page+1)},disabled:t.page===a-1},"next")),l.push(n(N.Last,{onClick:function(){return o(a-1)},disabled:t.page===a-1},"last"))}return n(N,K({size:"sm",className:"flex-wrap m-0"},{children:l}))}var pe=[{id:10,label:"10"},{id:100,label:"100"},{id:1e3,label:"1000"}];function fe(r){var a=r.hover,o=r.showPagingOnBottom,l=r.showPageSizeSelection,c=r.striped,s=r.bordered,u=r.header,m=r.children,p=r.paging,f=r.totalItems,g=r.onPagingChanged,v=Math.ceil(f/p.size),b=h((function(){var e=p.size;if(null===pe.find((function(n){return n.id===e}))){var n=d.clone(pe);return n.push({id:e,label:String(e)}),n}return pe}),[p]);return n("div",{children:e(k,K({hover:a,striped:c,responsive:!0,bordered:s},{children:[e("thead",{children:[n("tr",{children:n("td",K({colSpan:u.length},{children:e("div",K({className:"d-flex justify-content-between align-items-center gap-2"},{children:[e("div",{children:[n(he,{text:"Page"}),": ",p.page+1," / ",v]}),v>0&&n(me,{paging:p,totalItems:f,onPagingChanged:g}),e("div",{children:[n(he,{text:"Total items"}),": ",f]})]}))}))}),n("tr",{children:u.map((function(r,a){var o=!1===r.sort?"":i.isBlank(r.sort)?r.name:r.sort;if(i.isBlank(o)||!o)return n("th",{children:r.label},a);var l=p.sorting&&p.sorting.find((function(e){return e.name===o}));return e("th",K({className:"user-select-none text-nowrap",role:"button",onClick:function(e){return function(e,n){p.sorting||(p.sorting=[]);var t=p.sorting.find((function(e){return e.name===n})),i=t&&1===p.sorting.length;e.ctrlKey||i||(p.sorting=[],t=void 0),t?t.desc=!t.desc:p.sorting.push({name:n}),g(d.clone(p))}(e,o)}},{children:[r.label,l?l.desc?n(A,{}):n(L,{}):n(t,{})]}),a)}))})]}),n("tbody",{children:m}),f>0&&e("tfoot",{children:[o&&n("tr",{children:n("td",K({colSpan:u.length},{children:e("div",K({className:"d-flex justify-content-between align-items-center gap-2"},{children:[e("div",{children:[n(he,{text:"Page"}),": ",p.page+1," / ",v]}),v>0&&n(me,{paging:p,totalItems:f,onPagingChanged:g}),e("div",{children:[n(he,{text:"Total items"}),": ",f]})]}))}))}),l&&n("tr",{children:n("td",K({colSpan:u.length},{children:e("div",K({className:"d-flex align-items-center gap-2 justify-content-end"},{children:[e("div",K({className:"text-nowrap"},{children:[n(he,{text:"Page size"}),":"]})),n("div",{children:n(te,{value:p.size,options:b,onChange:function(e){p.size=e||10,g(K({},p))},showEmptyOption:!1})})]}))}))})]})]}))})}function ge(e){e.disabled;var t=e.checked,i=e.iconOn,r=e.iconOff,a=e.size,o=e.onChange,l=h((function(){return t?i||n(G,{size:a}):r||n(j,{size:a,className:"text-muted"})}),[t,i,r,a]);return n("div",K({className:"d-flex align-items-center cursor-pointer",onClick:function(e){e.stopPropagation(),e.preventDefault(),o(!t)}},{children:l}))}function ve(t){var i=t.showSelect,r=t.header,a=t.items,o=t.onSelect,l=t.onClick,c=t.totalItems,s=t.paging,u=t.onPagingChanged,f=p(!1),v=f[0],b=f[1],y=p(),C=y[0],w=y[1],x=m((function(e){C&&w(C.map((function(n){return{selected:e,item:n.item}}))),b(e)}),[C]),z=h((function(){var e=Y([],r,!0);return!1!==i&&e.unshift({name:"",label:n("div",K({className:"py-1"},{children:n(ge,{checked:v,onChange:function(){return x(!v)},iconOn:n(D,{})})}))}),e}),[r,v,x]);return g((function(){w(a?a.map((function(e){return{selected:v,item:e}})):void 0)}),[a]),g((function(){C&&o&&o(C.filter((function(e){return e.selected})).map((function(e){return e.item})))}),[C,o]),n(fe,K({header:z,hover:void 0!==l,paging:s,striped:!0,totalItems:c,onPagingChanged:u},{children:C&&C.map((function(t,a){return e("tr",K({className:"selectable ".concat(l?"cursor-pointer":""," ").concat(t.selected?"table-active table-primary":""),onClick:function(e){l&&l(t.item)}},{children:[!1!==i&&n("td",{children:n("div",K({className:"py-2 d-flex align-items-center"},{children:n(ge,{checked:t.selected,onChange:function(){t.selected=!t.selected,v&&!t.selected&&b(!1),w(Y([],C,!0))}})}))}),r.map((function(e,i){var r,a=e.renderer||(r=e.name,function(e){return d.getNestedValue(e,r)});return n("td",{children:a(t.item)},i)}))]}),a)}))}))}function be(e){var t=e.cols,i=e.rows,r=e.size,a=h((function(){return void 0===t?1:t}),[t]),o=h((function(){return void 0===i?20:i}),[i]);return h((function(){return void 0===r?"lg":r}),[r]),n("div",{children:n(k,K({responsive:!0},{children:n("tbody",{children:Array.from({length:o},(function(e,t){return n("tr",{children:Array.from({length:a},(function(e,t){return n("td",{children:n("div",{className:"w-100 p-1 m-1"})},t)}))},t)}))})}))})}var ye=new Map([[s.error,F],[s.warning,H],[s.info,T]]);function Ce(e){var t=e.type,i=e.size,r=e.customVariant,a=ye.get(t)||V;return n("div",K({className:"d-flex align-items-center text-".concat(void 0===r?t:r)},{children:a({size:i})}))}function we(t){var i=t.userAlert,a=t.maxDurationMs;return e(S,K({direction:"horizontal",gap:2,className:"align-items-center"},{children:[i.remainsMs&&n("div",K({style:{width:20}},{children:n(O,{min:0,max:a,now:i.remainsMs,variant:i.type})})),n("div",{children:r.formatDateForHumans(i.time)}),n(Ce,{type:i.type}),n("div",{children:i.message})]}))}function xe(i){var r=i.userAlerts,a=p(!1),o=a[0],l=a[1],c=p(r.alerts.length),d=c[0],s=c[1],u=p(Y([],r.visibleAlerts,!0)),h=u[0],f=u[1],v=p(r.getSummary()),b=v[0],y=v[1],C=m((function(){s(r.alerts.length),f(Y([],o?r.alerts:r.visibleAlerts,!0)),y(r.getSummary())}),[r,o]);return g((function(){r.addOnChangeHandler(C);var e=setInterval((function(){return r.updateVisibility()}),100);return function(){clearInterval(e),r.removeOnChangeHandler(C)}}),[r,C]),d<=0?n(t,{}):e("div",K({className:"user-alerts border rounded bg-body text-body position-fixed text-end",style:{bottom:15,right:15,zIndex:2147483647}},{children:[h.length>0&&n("div",K({className:"max-w-50 p-2 border-bottom"},{children:h.map((function(e,t){return n(we,{userAlert:e,maxDurationMs:r.maxVisibilityMs},t)}))})),n("div",K({className:"p-2"},{children:e(S,K({direction:"horizontal",gap:2,className:"justify-content-end align-items-center"},{children:[n(X,o?K({size:"sm",variant:"primary",onClick:function(){return l(!1)},icon:n(J,{})},{children:"Hide"}):K({size:"sm",variant:"primary",onClick:function(){return l(!0)},icon:n(R,{})},{children:"Show All"})),Array.from(b.entries()).map((function(t,i){return e(S,K({direction:"horizontal",gap:1,className:"px-1 border rounded align-items-center"},{children:[n(Ce,{type:t[0],customVariant:0===t[1]?"muted":void 0}),n("div",K({className:t[1]>0?"text-".concat(t[0]," fw-bold"):"text-muted"},{children:t[1]}))]}),i)})),n(X,K({size:"sm",variant:"danger",onClick:function(){return r.reset()},icon:n(M,{})},{children:"Reset"}))]}))}))]}))}var ze=function(){function e(e){this.setProps=e}return e.prototype.confirm=function(e,n,t){var i=this;this.setProps({name:e,text:n,onConfirm:function(){t(),i.setProps(void 0)},onClose:function(){return i.setProps(void 0)}})},e}(),Ne=v(new ze((function(){})));function ke(t){var i=t.name,r=t.text,a=t.onClose,o=t.onConfirm;return e(P,K({show:!0,backdrop:!0,onHide:a},{children:[n(P.Header,{children:i||"Confirm"}),n(P.Body,{children:r}),n(P.Footer,{children:e(S,K({direction:"horizontal"},{children:[n(w,K({variant:"link",onClick:a},{children:n(he,{text:"Back"})})),n(w,K({variant:"primary",onClick:o},{children:n(he,{text:"Yes"})}))]}))})]}))}function Se(t){var i=t.stats,r=i.heapSize,a=i.heapMaxSize,o=i.heapFreeSize,l=r-o;return e("div",{children:[e("div",K({className:"d-flex align-items-center gap-2"},{children:[n("pre",{children:"Java Heap"}),e("pre",{children:["[",u.formatByteSize(r)," / ",u.formatByteSize(a),"]"]})]})),e("div",K({className:"d-flex align-items-center gap-2"},{children:[n("pre",{children:"Used:"}),n(I,K({className:"bg-warning text-bg-warning"},{children:u.formatByteSize(l)})),n("pre",{children:"Free:"}),n(I,K({className:"bg-success text-white"},{children:u.formatByteSize(o)}))]})),n("div",K({className:"p-1"},{children:e(O,K({min:0,max:a},{children:[n(O,{variant:"warning",min:0,now:l,max:a}),n(O,{variant:"success",min:0,now:o,max:a})]}))}))]})}function Oe(t){var i=t.name,r=t.stats;return e("div",{children:[e("div",K({className:"d-flex align-items-center gap-2"},{children:[n("pre",{children:i}),e("pre",{children:["[",r.cachedItems,r.capacity>0&&" / ",r.capacity>0&&r.capacity,"]"]})]})),r.capacity>0&&n("div",K({className:"p-1"},{children:n(O,{now:r.cachedItems,min:0,max:r.capacity})}))]})}var Pe=new Map([["Idle","secondary"],["Processing","success"],["Loading","warn"]]);function Ie(e){var t=e.state,i=Pe.get(t)||"light";return n(I,K({className:"bg-".concat(i," text-bg-").concat(i)},{children:t}))}function Ee(t){var i=t.name,r=t.stats,a=r?r.remaining+r.processed:void 0;return e("div",{children:[e("div",K({className:"d-flex align-items-center gap-2"},{children:[n("pre",{children:i}),e("pre",{children:["[",void 0!==(null==r?void 0:r.processed)?r.processed:"?"," / ",void 0!==a?a:"?","]"]}),n(Ie,{state:r?r.state:"Unknown"})]})),n("div",K({className:"p-1"},{children:r?n(O,{variant:"primary",striped:!0,animated:!0,min:0,now:r.processed,max:a||1}):n(E,K({className:"w-100",animation:"glow"},{children:n(E,{className:"w-100"})}))}))]})}function Be(e){var t=e.children,i=e.center,r=h((function(){return!1===i?"":"d-flex align-items-center justify-content-center"}),[i]);return n("div",K({className:"w-100 h-100 position-absolute ".concat(r),style:{left:0,right:0,top:0,bottom:0}},{children:t}))}export{fe as AdvancedTable,ce as AutocompleteEntityIdSelect,le as AutocompleteEntitySelect,se as AutocompleteLookupIdSelect,de as AutocompleteLookupSelect,oe as AutocompleteSelect,Oe as CacheStatsControl,ke as ConfirmDialog,Ne as ConfirmDialogContext,ze as ConfirmDialogContextData,Q as DateInput,W as DateTimeInput,ee as DeleteButton,re as EnumSelect,X as IconButton,Z as IconSwitch,Se as JavaHeapControl,$ as LoadingButton,ue as LocalizationContext,he as Localize,ie as LookupSelect,te as NumberSelect,Ie as QueueStateControl,Ee as QueueStatsControl,_ as SaveButton,Be as Spread,ne as StringSelect,ae as Switch,me as TablePagination,be as TablePlaceholder,ve as TableWithSelect,q as TextInputWithReset,Ce as UserAlertTypeIcon,we as UserAlertWidget,xe as UserAlertsWidget};
2
2
  //# sourceMappingURL=index.esm.js.map