zavadil-react-common 2.0.4 → 2.0.6

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.
@@ -16,3 +16,7 @@ export * from './AutocompleteEntitySelect';
16
16
  export * from './AutocompleteEntityIdSelect';
17
17
  export * from './AutocompleteLookupSelect';
18
18
  export * from './AutocompleteLookupIdSelect';
19
+ export * from './EntitySelect';
20
+ export * from './EntityIdSelect';
21
+ export * from './EntityWithNameSelect';
22
+ export * from './EntityWithNameIdSelect';
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import * as react_jsx_runtime from 'react/jsx-runtime';
3
- import { PagingRequest, LookupTableEntity, EntityBase, EntityClient, EntityClientWithStub, LookupClient, UserAlertType, UserAlerts, UserAlert, JavaHeapStats, CacheStats, QueueStats, Localization } from 'zavadil-ts-common';
3
+ import { PagingRequest, LookupTableEntity, EntityBase, EntityClient, EntityClientWithStub, LookupClient, EntityWithName, UserAlertType, UserAlerts, UserAlert, JavaHeapStats, CacheStats, QueueStats, Localization } from 'zavadil-ts-common';
4
4
  import * as react from 'react';
5
5
  import react__default, { ReactNode, PropsWithChildren } from 'react';
6
6
  import { PlaceholderSize } from 'react-bootstrap/usePlaceholder';
@@ -227,6 +227,52 @@ type AutocompleteLookupIdSelectProps<T extends LookupTableEntity> = {
227
227
  };
228
228
  declare function AutocompleteLookupIdSelect<T extends LookupTableEntity>({ id, disabled, labelGetter, onChange, lookupClient }: AutocompleteLookupIdSelectProps<T>): react_jsx_runtime.JSX.Element;
229
229
 
230
+ type EntitySelectProps<T extends EntityBase> = {
231
+ value?: T | null;
232
+ onChange: (e: T | null | undefined) => any;
233
+ options?: Array<T> | null;
234
+ showEmptyOption?: boolean;
235
+ disabled?: boolean;
236
+ emptyOptionLabel?: string;
237
+ sort?: boolean;
238
+ labelGetter: (item: T) => string;
239
+ };
240
+ declare function EntitySelect<T extends EntityBase>({ value, sort, disabled, labelGetter, onChange, options, showEmptyOption, emptyOptionLabel }: EntitySelectProps<T>): react_jsx_runtime.JSX.Element;
241
+
242
+ type EntityIdSelectProps<T extends EntityBase> = {
243
+ id?: number | null;
244
+ onChange: (n: number | null | undefined) => any;
245
+ options?: Array<T> | null;
246
+ showEmptyOption?: boolean;
247
+ disabled?: boolean;
248
+ emptyOptionLabel?: string;
249
+ sort?: boolean;
250
+ labelGetter: (item: T) => string;
251
+ };
252
+ declare function EntityIdSelect<T extends EntityBase>({ id, sort, disabled, labelGetter, onChange, options, showEmptyOption, emptyOptionLabel }: EntityIdSelectProps<T>): react_jsx_runtime.JSX.Element;
253
+
254
+ type EntityWithNameSelectProps<T extends EntityWithName> = {
255
+ value?: T | null;
256
+ onChange: (e: T | null | undefined) => any;
257
+ options?: Array<T> | null;
258
+ showEmptyOption?: boolean;
259
+ disabled?: boolean;
260
+ emptyOptionLabel?: string;
261
+ sort?: boolean;
262
+ };
263
+ declare function EntityWithNameSelect<T extends EntityWithName>({ value, sort, disabled, onChange, options, showEmptyOption, emptyOptionLabel }: EntityWithNameSelectProps<T>): react_jsx_runtime.JSX.Element;
264
+
265
+ type EntityWithNameIdSelectProps<T extends EntityWithName> = {
266
+ id?: number | null;
267
+ onChange: (n: number | null | undefined) => any;
268
+ options?: Array<T> | null;
269
+ showEmptyOption?: boolean;
270
+ disabled?: boolean;
271
+ emptyOptionLabel?: string;
272
+ sort?: boolean;
273
+ };
274
+ declare function EntityWithNameIdSelect<T extends EntityWithName>({ id, sort, disabled, onChange, options, showEmptyOption, emptyOptionLabel }: EntityWithNameIdSelectProps<T>): react_jsx_runtime.JSX.Element;
275
+
230
276
  type UserAlertTypeIconProps = {
231
277
  type: UserAlertType;
232
278
  size?: string | number;
@@ -297,4 +343,4 @@ type LocalizeProps = {
297
343
  };
298
344
  declare function Localize({ text, tag }: LocalizeProps): react_jsx_runtime.JSX.Element;
299
345
 
300
- export { type ActiveButtonProps, AdvancedTable, type AdvancedTableProps, AutocompleteEntityIdSelect, AutocompleteEntitySelect, type AutocompleteEntitySelectProps, type AutocompleteIdSelectProps, AutocompleteLookupIdSelect, type AutocompleteLookupIdSelectProps, AutocompleteLookupSelect, type AutocompleteLookupSelectProps, AutocompleteSelect, type AutocompleteSelectProps, type BasicDialogProps, CacheStatsControl, type CacheStatsControlProps, ConfirmDialog, ConfirmDialogContext, ConfirmDialogContextData, type ConfirmDialogProps, DateInput, type DateInputProps, DateTime, DateTimeInput, type DateTimeInputProps, type DateTimeProps, DeleteButton, type DeleteButtonProps, Duration, type DurationProps, Elapsed, type ElapsedProps, EnumSelect, type EnumSelectProps, type GenericSelectOption, type GenericSelectProps, type HeaderCol, IconButton, type IconButtonProps, IconSwitch, type IconSwitchProps, JavaHeapControl, LoadingButton, LocalizationContext, Localize, type LocalizeProps, LookupSelect, type LookupSelectProps, NumberSelect, type NumberSelectProps, QueueStateControl, type QueueStateControlProps, QueueStatsControl, type QueueStatsControlProps, type RenderFunc, type RenderResult, SaveButton, type SaveButtonProps, type SelectableHeaderCol, type SelectableItem, type SelectableTableHeader, Spread, type SpreadProps, StringSelect, type StringSelectProps, Switch, type SwitchProps, type TableHeader, TablePagination, type TablePaginationProps, TablePlaceholder, type TablePlaceholderProps, TableWithSelect, type TableWithSelectProps, TextInputWithReset, type TextInputWithResetProps, UserAlertTypeIcon, type UserAlertTypeIconProps, UserAlertWidget, type UserAlertWidgetProps, UserAlertsWidget, type UserAlertsWidgetProps, type WorkerJavaHeapControlProps };
346
+ export { type ActiveButtonProps, AdvancedTable, type AdvancedTableProps, AutocompleteEntityIdSelect, AutocompleteEntitySelect, type AutocompleteEntitySelectProps, type AutocompleteIdSelectProps, AutocompleteLookupIdSelect, type AutocompleteLookupIdSelectProps, AutocompleteLookupSelect, type AutocompleteLookupSelectProps, AutocompleteSelect, type AutocompleteSelectProps, type BasicDialogProps, CacheStatsControl, type CacheStatsControlProps, ConfirmDialog, ConfirmDialogContext, ConfirmDialogContextData, type ConfirmDialogProps, DateInput, type DateInputProps, DateTime, DateTimeInput, type DateTimeInputProps, type DateTimeProps, DeleteButton, type DeleteButtonProps, Duration, type DurationProps, Elapsed, type ElapsedProps, EntityIdSelect, type EntityIdSelectProps, EntitySelect, type EntitySelectProps, EntityWithNameIdSelect, type EntityWithNameIdSelectProps, EntityWithNameSelect, type EntityWithNameSelectProps, EnumSelect, type EnumSelectProps, type GenericSelectOption, type GenericSelectProps, type HeaderCol, IconButton, type IconButtonProps, IconSwitch, type IconSwitchProps, JavaHeapControl, LoadingButton, LocalizationContext, Localize, type LocalizeProps, LookupSelect, type LookupSelectProps, NumberSelect, type NumberSelectProps, QueueStateControl, type QueueStateControlProps, QueueStatsControl, type QueueStatsControlProps, type RenderFunc, type RenderResult, SaveButton, type SaveButtonProps, type SelectableHeaderCol, type SelectableItem, type SelectableTableHeader, Spread, type SpreadProps, StringSelect, type StringSelectProps, Switch, type SwitchProps, type TableHeader, TablePagination, type TablePaginationProps, TablePlaceholder, type TablePlaceholderProps, TableWithSelect, type TableWithSelectProps, TextInputWithReset, type TextInputWithResetProps, UserAlertTypeIcon, type UserAlertTypeIconProps, UserAlertWidget, type UserAlertWidgetProps, UserAlertsWidget, type UserAlertsWidgetProps, type WorkerJavaHeapControlProps };
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 s,UserAlertType as d,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 N,Pagination as z,Table as k,Stack as S,ProgressBar as O,Modal as P,Badge as E,Placeholder as I}from"react-bootstrap";import{BsXCircle as B,BsTrash as M,BsFillCaretDownFill as A,BsFillCaretUpFill as D,BsCheckCircle as L,BsCircle as G,BsCheckAll as F,BsBug as j,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,s=t.className,d=h((function(){return i.getNonEmpty(r)}),[r]),u=h((function(){return i.isBlank(r)}),[d]),p=m((function(){o?o():a("")}),[o,a]);return e(y,K({className:s},{children:[n(C.Control,{type:"text",disabled:c,value:d,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,s=h((function(){return i||n(U,{})}),[i]),d=h((function(){return c?n("strong",{children:a}):a}),[c,a]);return n($,K({disabled:t||!1===c,onClick:l,icon:s,loading:r,size:o},{children:d}))}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,s=h((function(){return i||n(M,{})}),[i]);return n($,K({disabled:t||!1===c,onClick:l,icon:s,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,s=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:s||""}),""),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,s=h((function(){return t?String(t):""}),[t]),d=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:s,options:d,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,s=e.emptyOptionLabel,d=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:d,onChange:o,showEmptyOption:c,emptyOptionLabel:s})}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,s=p(),d=s[0],u=s[1],v=p(),b=v[0],y=v[1],C=p(),w=C[0],x=C[1],z=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(){z.current=window.setTimeout(O,100)}),[z,O]),E=m((function(){z.current&&clearTimeout(z.current)}),[z]);g((function(){return E}),[]),g((function(){y(i?k(i):""),d&&(d.cancel(),u(void 0)),x(void 0)}),[i]);var I=m((function(){l(null),y(""),d&&(d.cancel(),u(void 0)),x(void 0)}),[l,d]),B=m((function(e){y(e),d&&d.cancel();var n=new o(c(e));n.promise.then(x),u(n)}),[d,c]),M=m((function(e){console.log("user selected item"),x(void 0),l(K({},e))}),[l]);return n("div",K({onBlur:P,onFocus:E},{children:e(N,K({defaultShow:!1,show:null!==w},{children:[n(q,{disabled:r,value:b,onChange:B,onReset:I,className:S}),w&&n(N.Menu,{children:w.map((function(e){return n(N.Item,K({onClick:function(n){E(),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),s=c[0],d=c[1];g((function(){t?s&&s.id===t?d(K({},s)):o instanceof l?o.loadSingleStub(t).then(d):o.loadSingle(t).then(d):d(null)}),[t]);var u=m((function(e){var n=e?e.id:null;n!==t&&a(n),d(e)}),[t,a]);return n(le,{disabled:i,selected:s,labelGetter:r,entityClient:o,onChange:u})}function se(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]),s=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:s,onChange:o})}function de(e){var t=e.id,i=e.disabled,r=e.labelGetter,a=e.onChange,o=e.lookupClient,l=p(null),c=l[0],s=l[1];g((function(){t?c&&c.id===t?s(K({},c)):o.loadSingle(t).then(s):s(null)}),[t]);var d=m((function(e){var n=e?e.id:null;n!==t&&a(n),s(e)}),[t,c]);return n(se,{disabled:i,selected:c,labelGetter:r,lookupClient:o,onChange:d})}"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(s.clone(t))},l=[];if(a>1){l.push(n(z.First,{onClick:function(){return o(0)},disabled:0===t.page},"first")),l.push(n(z.Prev,{onClick:function(){return o(t.page-1)},disabled:0===t.page},"prev"));var c=Math.round(3.5),d=t.page>c?t.page-c:0,u=d+10;u>=a&&(u=a-1),d>0&&l.push(n(z.Ellipsis,{disabled:!0},"ellipsisStart"));for(var h=function(e){l.push(n(z.Item,K({active:e===t.page,onClick:function(){return o(e)}},{children:e+1}),e))},m=d;m<=u;m++)h(m);u<a-1&&l.push(n(z.Ellipsis,{disabled:!0},"ellipsisEnd")),l.push(n(z.Next,{onClick:function(){return o(t.page+1)},disabled:t.page===a-1},"next")),l.push(n(z.Last,{onClick:function(){return o(a-1)},disabled:t.page===a-1},"last"))}return n(z,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,d=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=s.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:d},{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(s.clone(p))}(e,o)}},{children:[r.label,l?l.desc?n(A,{}):n(D,{}):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(L,{size:a}):r||n(G,{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,d=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]),N=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(F,{})})}))}),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:N,hover:void 0!==l,paging:d,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 s.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)}))})}))})}function ye(e){var t=e.value;return n("div",K({className:"text-nowrap"},{children:r.formatDateTimeForHumans(t)}))}function Ce(e){var i=e.ms;return s.isEmpty(i)?n(t,{}):n("div",K({className:"text-nowrap"},{children:r.formatDuration(i)}))}function we(e){var t=e.date,i=h((function(){return s.isEmpty(t)?null:Date.now()-t.getTime()}),[t]);return n(Ce,{ms:i})}var xe=new Map([[d.error,j],[d.warning,H],[d.info,T]]);function Ne(e){var t=e.type,i=e.size,r=e.customVariant,a=xe.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 ze(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(Ne,{type:i.type}),n("div",{children:i.message})]}))}function ke(i){var r=i.userAlerts,a=p(!1),o=a[0],l=a[1],c=p(r.alerts.length),s=c[0],d=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(){d(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]),s<=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(ze,{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(Ne,{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 Se=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}(),Oe=v(new Se((function(){})));function Pe(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 Ee(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(E,K({className:"bg-warning text-bg-warning"},{children:u.formatByteSize(l)})),n("pre",{children:"Free:"}),n(E,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 Ie(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 Be=new Map([["Idle","secondary"],["Processing","success"],["Loading","warn"]]);function Me(e){var t=e.state,i=Be.get(t)||"light";return n(E,K({className:"bg-".concat(i," text-bg-").concat(i)},{children:t}))}function Ae(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(Me,{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(I,K({className:"w-100",animation:"glow"},{children:n(I,{className:"w-100"})}))}))]})}function De(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,de as AutocompleteLookupIdSelect,se as AutocompleteLookupSelect,oe as AutocompleteSelect,Ie as CacheStatsControl,Pe as ConfirmDialog,Oe as ConfirmDialogContext,Se as ConfirmDialogContextData,Q as DateInput,ye as DateTime,W as DateTimeInput,ee as DeleteButton,Ce as Duration,we as Elapsed,re as EnumSelect,X as IconButton,Z as IconSwitch,Ee as JavaHeapControl,$ as LoadingButton,ue as LocalizationContext,he as Localize,ie as LookupSelect,te as NumberSelect,Me as QueueStateControl,Ae as QueueStatsControl,_ as SaveButton,De as Spread,ne as StringSelect,ae as Switch,me as TablePagination,be as TablePlaceholder,ve as TableWithSelect,q as TextInputWithReset,Ne as UserAlertTypeIcon,ze as UserAlertWidget,ke 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 s,UserAlertType as d,ByteUtil as u}from"zavadil-ts-common";import{useMemo as p,useCallback as h,useEffect as m,useState as f,useRef 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 N,Pagination as z,Table as k,Stack as O,ProgressBar as S,Modal as E,Badge as P,Placeholder as L}from"react-bootstrap";import{BsXCircle as I,BsTrash as G,BsFillCaretDownFill as B,BsFillCaretUpFill as M,BsCheckCircle as A,BsCircle as D,BsCheckAll as F,BsBug as j,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,s=t.className,d=p((function(){return i.getNonEmpty(r)}),[r]),u=p((function(){return i.isBlank(r)}),[d]),m=h((function(){o?o():a("")}),[o,a]);return e(y,K({className:s},{children:[n(C.Control,{type:"text",disabled:c,value:d,onChange:function(e){return a(e.target.value)},onBlur:l}),n(w,K({onClick:m,disabled:u},{children:n("div",K({className:"d-flex align-items-center"},{children:n(I,{})}))}))]}))}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,s=p((function(){return i||n(U,{})}),[i]),d=p((function(){return c?n("strong",{children:a}):a}),[c,a]);return n($,K({disabled:t||!1===c,onClick:l,icon:s,loading:r,size:o},{children:d}))}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,s=p((function(){return i||n(G,{})}),[i]);return n($,K({disabled:t||!1===c,onClick:l,icon:s,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,s=t.emptyOptionLabel;return m((function(){i.isEmpty(r)&&a.length>0&&!0!==c&&l(a[0].id)}),[r,a,c,l]),e(C.Select,K({value:r||"",onChange:function(e){return l(e.target.value)},disabled:o},{children:[!0===c&&n("option",K({value:""},{children:s||""}),""),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,s=p((function(){return t?String(t):""}),[t]),d=p((function(){return i?i.map((function(e){return{id:e.id?String(e.id):"",label:e.label}})):[]}),[i]),u=h((function(e){return o(a.parseNumber(e))}),[o]);return n(ne,{disabled:r,value:s,options:d,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,s=e.emptyOptionLabel,d=p((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:d,onChange:o,showEmptyOption:c,emptyOptionLabel:s})}function re(e){var t=e.value,i=e.options,r=e.onChange,a=e.showEmptyOption,o=e.emptyOptionLabel,l=p((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,s=f(),d=s[0],u=s[1],v=f(),b=v[0],y=v[1],C=f(),w=C[0],x=C[1],z=g(),k=h((function(e){return a?a(e):"name"in e&&"string"==typeof e.name?e.name:"[".concat(e.id,"]")}),[a]),O=p((function(){return i?"border rounded border-primary":void 0}),[i]),S=h((function(){console.log("user left control"),w&&(x(void 0),y(i?k(i):""))}),[l,w,i,k]),E=h((function(){z.current=window.setTimeout(S,100)}),[z,S]),P=h((function(){z.current&&clearTimeout(z.current)}),[z]);m((function(){return P}),[]),m((function(){y(i?k(i):""),d&&(d.cancel(),u(void 0)),x(void 0)}),[i]);var L=h((function(){l(null),y(""),d&&(d.cancel(),u(void 0)),x(void 0)}),[l,d]),I=h((function(e){y(e),d&&d.cancel();var n=new o(c(e));n.promise.then(x),u(n)}),[d,c]),G=h((function(e){console.log("user selected item"),x(void 0),l(K({},e))}),[l]);return n("div",K({onBlur:E,onFocus:P},{children:e(N,K({defaultShow:!1,show:null!==w},{children:[n(q,{disabled:r,value:b,onChange:I,onReset:L,className:O}),w&&n(N.Menu,{children:w.map((function(e){return n(N.Item,K({onClick:function(n){P(),G(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=h((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=f(null),s=c[0],d=c[1];m((function(){t?s&&s.id===t?d(K({},s)):o instanceof l?o.loadSingleStub(t).then(d):o.loadSingle(t).then(d):d(null)}),[t]);var u=h((function(e){var n=e?e.id:null;n!==t&&a(n),d(e)}),[t,a]);return n(le,{disabled:i,selected:s,labelGetter:r,entityClient:o,onChange:u})}function se(e){var t=e.selected,r=e.disabled,a=e.labelGetter,o=e.onChange,l=e.lookupClient,c=p((function(){return a||function(e){return e.name}}),[a]),s=h((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:s,onChange:o})}function de(e){var t=e.id,i=e.disabled,r=e.labelGetter,a=e.onChange,o=e.lookupClient,l=f(null),c=l[0],s=l[1];m((function(){t?c&&c.id===t?s(K({},c)):o.loadSingle(t).then(s):s(null)}),[t]);var d=h((function(e){var n=e?e.id:null;n!==t&&a(n),s(e)}),[t,c]);return n(se,{disabled:i,selected:c,labelGetter:r,lookupClient:o,onChange:d})}function ue(e){var t=e.id,i=e.sort,r=e.disabled,a=e.labelGetter,o=e.onChange,l=e.options,c=e.showEmptyOption,s=e.emptyOptionLabel,d=p((function(){var e=[];return l&&(e=i?l.sort((function(e,n){return a(e)>a(n)?1:-1})):l),e.map((function(e){return{id:e.id,label:a(e)}}))}),[l]);return n(te,{disabled:r,value:t,options:d,onChange:o,showEmptyOption:c,emptyOptionLabel:s})}function pe(e){var t=e.value,i=e.sort,r=e.disabled,a=e.labelGetter,o=e.onChange,l=e.options,c=e.showEmptyOption,s=e.emptyOptionLabel;return n(ue,{disabled:r,id:t?t.id:null,options:l,sort:i,onChange:function(e){o(l&&e?l.find((function(n){return n.id===e})):void 0)},labelGetter:a,showEmptyOption:c,emptyOptionLabel:s})}function he(e){var t=e.value,i=e.sort,r=e.disabled,a=e.onChange,o=e.options,l=e.showEmptyOption,c=e.emptyOptionLabel;return n(pe,{value:t,labelGetter:function(e){return e.name},disabled:r,sort:i,options:o,onChange:a,showEmptyOption:l,emptyOptionLabel:c})}function me(e){var t=e.id,i=e.sort,r=e.disabled,a=e.onChange,o=e.options,l=e.showEmptyOption,c=e.emptyOptionLabel;return n(ue,{id:t,labelGetter:function(e){return e.name},disabled:r,sort:i,options:o,onChange:a,showEmptyOption:l,emptyOptionLabel:c})}"function"==typeof SuppressedError&&SuppressedError;var fe=v(new c);function ge(e){var i=e.text,r=e.tag,a=b(fe),o=p((function(){if(void 0!==r&&""!==r)return"string"==typeof r?{tags:[r]}:{tags:r}}),[r]),l=p((function(){return a.translate(i,o)}),[a,i,o]);return n(t,{children:l})}function ve(e){var t=e.paging,i=e.totalItems,r=e.onPagingChanged,a=Math.ceil(i/t.size),o=function(e){t.page=e,r(s.clone(t))},l=[];if(a>1){l.push(n(z.First,{onClick:function(){return o(0)},disabled:0===t.page},"first")),l.push(n(z.Prev,{onClick:function(){return o(t.page-1)},disabled:0===t.page},"prev"));var c=Math.round(3.5),d=t.page>c?t.page-c:0,u=d+10;u>=a&&(u=a-1),d>0&&l.push(n(z.Ellipsis,{disabled:!0},"ellipsisStart"));for(var p=function(e){l.push(n(z.Item,K({active:e===t.page,onClick:function(){return o(e)}},{children:e+1}),e))},h=d;h<=u;h++)p(h);u<a-1&&l.push(n(z.Ellipsis,{disabled:!0},"ellipsisEnd")),l.push(n(z.Next,{onClick:function(){return o(t.page+1)},disabled:t.page===a-1},"next")),l.push(n(z.Last,{onClick:function(){return o(a-1)},disabled:t.page===a-1},"last"))}return n(z,K({size:"sm",className:"flex-wrap m-0"},{children:l}))}var be=[{id:10,label:"10"},{id:100,label:"100"},{id:1e3,label:"1000"}];function ye(r){var a=r.hover,o=r.showPagingOnBottom,l=r.showPageSizeSelection,c=r.striped,d=r.bordered,u=r.header,h=r.children,m=r.paging,f=r.totalItems,g=r.onPagingChanged,v=Math.ceil(f/m.size),b=p((function(){var e=m.size;if(null===be.find((function(n){return n.id===e}))){var n=s.clone(be);return n.push({id:e,label:String(e)}),n}return be}),[m]);return n("div",{children:e(k,K({hover:a,striped:c,responsive:!0,bordered:d},{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(ge,{text:"Page"}),": ",m.page+1," / ",v]}),v>0&&n(ve,{paging:m,totalItems:f,onPagingChanged:g}),e("div",{children:[n(ge,{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=m.sorting&&m.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){m.sorting||(m.sorting=[]);var t=m.sorting.find((function(e){return e.name===n})),i=t&&1===m.sorting.length;e.ctrlKey||i||(m.sorting=[],t=void 0),t?t.desc=!t.desc:m.sorting.push({name:n}),g(s.clone(m))}(e,o)}},{children:[r.label,l?l.desc?n(B,{}):n(M,{}):n(t,{})]}),a)}))})]}),n("tbody",{children:h}),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(ge,{text:"Page"}),": ",m.page+1," / ",v]}),v>0&&n(ve,{paging:m,totalItems:f,onPagingChanged:g}),e("div",{children:[n(ge,{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(ge,{text:"Page size"}),":"]})),n("div",{children:n(te,{value:m.size,options:b,onChange:function(e){m.size=e||10,g(K({},m))},showEmptyOption:!1})})]}))}))})]})]}))})}function Ce(e){e.disabled;var t=e.checked,i=e.iconOn,r=e.iconOff,a=e.size,o=e.onChange,l=p((function(){return t?i||n(A,{size:a}):r||n(D,{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 we(t){var i=t.showSelect,r=t.header,a=t.items,o=t.onSelect,l=t.onClick,c=t.totalItems,d=t.paging,u=t.onPagingChanged,g=f(!1),v=g[0],b=g[1],y=f(),C=y[0],w=y[1],x=h((function(e){C&&w(C.map((function(n){return{selected:e,item:n.item}}))),b(e)}),[C]),N=p((function(){var e=Y([],r,!0);return!1!==i&&e.unshift({name:"",label:n("div",K({className:"py-1"},{children:n(Ce,{checked:v,onChange:function(){return x(!v)},iconOn:n(F,{})})}))}),e}),[r,v,x]);return m((function(){w(a?a.map((function(e){return{selected:v,item:e}})):void 0)}),[a]),m((function(){C&&o&&o(C.filter((function(e){return e.selected})).map((function(e){return e.item})))}),[C,o]),n(ye,K({header:N,hover:void 0!==l,paging:d,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(Ce,{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 s.getNestedValue(e,r)});return n("td",{children:a(t.item)},i)}))]}),a)}))}))}function xe(e){var t=e.cols,i=e.rows,r=e.size,a=p((function(){return void 0===t?1:t}),[t]),o=p((function(){return void 0===i?20:i}),[i]);return p((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)}))})}))})}function Ne(e){var t=e.value;return n("div",K({className:"text-nowrap"},{children:r.formatDateTimeForHumans(t)}))}function ze(e){var i=e.ms;return s.isEmpty(i)?n(t,{}):n("div",K({className:"text-nowrap"},{children:r.formatDuration(i)}))}function ke(e){var t=e.date,i=p((function(){return s.isEmpty(t)?null:Date.now()-t.getTime()}),[t]);return n(ze,{ms:i})}var Oe=new Map([[d.error,j],[d.warning,H],[d.info,T]]);function Se(e){var t=e.type,i=e.size,r=e.customVariant,a=Oe.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 Ee(t){var i=t.userAlert,a=t.maxDurationMs;return e(O,K({direction:"horizontal",gap:2,className:"align-items-center"},{children:[i.remainsMs&&n("div",K({style:{width:20}},{children:n(S,{min:0,max:a,now:i.remainsMs,variant:i.type})})),n("div",{children:r.formatDateForHumans(i.time)}),n(Se,{type:i.type}),n("div",{children:i.message})]}))}function Pe(i){var r=i.userAlerts,a=f(!1),o=a[0],l=a[1],c=f(r.alerts.length),s=c[0],d=c[1],u=f(Y([],r.visibleAlerts,!0)),p=u[0],g=u[1],v=f(r.getSummary()),b=v[0],y=v[1],C=h((function(){d(r.alerts.length),g(Y([],o?r.alerts:r.visibleAlerts,!0)),y(r.getSummary())}),[r,o]);return m((function(){r.addOnChangeHandler(C);var e=setInterval((function(){return r.updateVisibility()}),100);return function(){clearInterval(e),r.removeOnChangeHandler(C)}}),[r,C]),s<=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:[p.length>0&&n("div",K({className:"max-w-50 p-2 border-bottom"},{children:p.map((function(e,t){return n(Ee,{userAlert:e,maxDurationMs:r.maxVisibilityMs},t)}))})),n("div",K({className:"p-2"},{children:e(O,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(O,K({direction:"horizontal",gap:1,className:"px-1 border rounded align-items-center"},{children:[n(Se,{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(G,{})},{children:"Reset"}))]}))}))]}))}var Le=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}(),Ie=v(new Le((function(){})));function Ge(t){var i=t.name,r=t.text,a=t.onClose,o=t.onConfirm;return e(E,K({show:!0,backdrop:!0,onHide:a},{children:[n(E.Header,{children:i||"Confirm"}),n(E.Body,{children:r}),n(E.Footer,{children:e(O,K({direction:"horizontal"},{children:[n(w,K({variant:"link",onClick:a},{children:n(ge,{text:"Back"})})),n(w,K({variant:"primary",onClick:o},{children:n(ge,{text:"Yes"})}))]}))})]}))}function Be(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(P,K({className:"bg-warning text-bg-warning"},{children:u.formatByteSize(l)})),n("pre",{children:"Free:"}),n(P,K({className:"bg-success text-white"},{children:u.formatByteSize(o)}))]})),n("div",K({className:"p-1"},{children:e(S,K({min:0,max:a},{children:[n(S,{variant:"warning",min:0,now:l,max:a}),n(S,{variant:"success",min:0,now:o,max:a})]}))}))]})}function Me(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(S,{now:r.cachedItems,min:0,max:r.capacity})}))]})}var Ae=new Map([["Idle","secondary"],["Processing","success"],["Loading","warn"]]);function De(e){var t=e.state,i=Ae.get(t)||"light";return n(P,K({className:"bg-".concat(i," text-bg-").concat(i)},{children:t}))}function Fe(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(De,{state:r?r.state:"Unknown"})]})),n("div",K({className:"p-1"},{children:r?n(S,{variant:"primary",striped:!0,animated:!0,min:0,now:r.processed,max:a||1}):n(L,K({className:"w-100",animation:"glow"},{children:n(L,{className:"w-100"})}))}))]})}function je(e){var t=e.children,i=e.center,r=p((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{ye as AdvancedTable,ce as AutocompleteEntityIdSelect,le as AutocompleteEntitySelect,de as AutocompleteLookupIdSelect,se as AutocompleteLookupSelect,oe as AutocompleteSelect,Me as CacheStatsControl,Ge as ConfirmDialog,Ie as ConfirmDialogContext,Le as ConfirmDialogContextData,Q as DateInput,Ne as DateTime,W as DateTimeInput,ee as DeleteButton,ze as Duration,ke as Elapsed,ue as EntityIdSelect,pe as EntitySelect,me as EntityWithNameIdSelect,he as EntityWithNameSelect,re as EnumSelect,X as IconButton,Z as IconSwitch,Be as JavaHeapControl,$ as LoadingButton,fe as LocalizationContext,ge as Localize,ie as LookupSelect,te as NumberSelect,De as QueueStateControl,Fe as QueueStatsControl,_ as SaveButton,je as Spread,ne as StringSelect,ae as Switch,ve as TablePagination,xe as TablePlaceholder,we as TableWithSelect,q as TextInputWithReset,Se as UserAlertTypeIcon,Ee as UserAlertWidget,Pe as UserAlertsWidget};
2
2
  //# sourceMappingURL=index.esm.js.map