zavadil-react-common 2.1.7 → 2.1.8
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/component/forms/FormGroup.d.ts +5 -0
- package/dist/component/forms/Switch.d.ts +3 -3
- package/dist/component/forms/index.d.ts +23 -22
- package/dist/index.d.ts +8 -4
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/component/forms/FormGroup.tsx +18 -0
- package/src/component/forms/Switch.tsx +35 -26
- package/src/component/forms/index.ts +23 -22
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
2
|
export type SwitchProps = {
|
|
3
3
|
id?: string;
|
|
4
4
|
disabled?: boolean;
|
|
5
5
|
checked: boolean;
|
|
6
6
|
onChange: (checked: boolean) => any;
|
|
7
7
|
size?: number;
|
|
8
|
-
label?: string |
|
|
8
|
+
label?: string | ReactNode;
|
|
9
9
|
};
|
|
10
|
-
export declare function Switch({ id, label, disabled, checked, size, onChange }: SwitchProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export declare function Switch({ id, label, disabled, checked, size, onChange, }: SwitchProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
8
|
-
export * from
|
|
9
|
-
export * from
|
|
10
|
-
export * from
|
|
11
|
-
export * from
|
|
12
|
-
export * from
|
|
13
|
-
export * from
|
|
14
|
-
export * from
|
|
15
|
-
export * from
|
|
16
|
-
export * from
|
|
17
|
-
export * from
|
|
18
|
-
export * from
|
|
19
|
-
export * from
|
|
20
|
-
export * from
|
|
21
|
-
export * from
|
|
22
|
-
export * from
|
|
1
|
+
export * from "./FormGroup";
|
|
2
|
+
export * from "./TextInputWithReset";
|
|
3
|
+
export * from "./DateInput";
|
|
4
|
+
export * from "./DateTimeInput";
|
|
5
|
+
export * from "./IconButton";
|
|
6
|
+
export * from "./IconSwitch";
|
|
7
|
+
export * from "./LoadingButton";
|
|
8
|
+
export * from "./SaveButton";
|
|
9
|
+
export * from "./DeleteButton";
|
|
10
|
+
export * from "./LookupSelect";
|
|
11
|
+
export * from "./NumberSelect";
|
|
12
|
+
export * from "./StringSelect";
|
|
13
|
+
export * from "./EnumSelect";
|
|
14
|
+
export * from "./Switch";
|
|
15
|
+
export * from "./AutocompleteSelect";
|
|
16
|
+
export * from "./AutocompleteEntitySelect";
|
|
17
|
+
export * from "./AutocompleteEntityIdSelect";
|
|
18
|
+
export * from "./AutocompleteLookupSelect";
|
|
19
|
+
export * from "./AutocompleteLookupIdSelect";
|
|
20
|
+
export * from "./EntitySelect";
|
|
21
|
+
export * from "./EntityIdSelect";
|
|
22
|
+
export * from "./EntityWithNameSelect";
|
|
23
|
+
export * from "./EntityWithNameIdSelect";
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
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
|
-
import
|
|
5
|
+
import { ReactNode, PropsWithChildren } from 'react';
|
|
6
6
|
import { PlaceholderSize } from 'react-bootstrap/usePlaceholder';
|
|
7
7
|
import { ButtonVariant } from 'react-bootstrap/types';
|
|
8
8
|
|
|
@@ -75,6 +75,10 @@ type ElapsedProps = {
|
|
|
75
75
|
};
|
|
76
76
|
declare function Elapsed({ date }: ElapsedProps): react_jsx_runtime.JSX.Element;
|
|
77
77
|
|
|
78
|
+
type FormGroupProps = PropsWithChildren & {
|
|
79
|
+
label: string;
|
|
80
|
+
};
|
|
81
|
+
|
|
78
82
|
type TextInputWithResetProps = {
|
|
79
83
|
value?: string | null;
|
|
80
84
|
onChange: (s: string) => any;
|
|
@@ -178,9 +182,9 @@ type SwitchProps = {
|
|
|
178
182
|
checked: boolean;
|
|
179
183
|
onChange: (checked: boolean) => any;
|
|
180
184
|
size?: number;
|
|
181
|
-
label?: string |
|
|
185
|
+
label?: string | ReactNode;
|
|
182
186
|
};
|
|
183
|
-
declare function Switch({ id, label, disabled, checked, size, onChange }: SwitchProps): react_jsx_runtime.JSX.Element;
|
|
187
|
+
declare function Switch({ id, label, disabled, checked, size, onChange, }: SwitchProps): react_jsx_runtime.JSX.Element;
|
|
184
188
|
|
|
185
189
|
type AutocompleteSelectProps<T extends EntityBase> = {
|
|
186
190
|
selected?: T | null;
|
|
@@ -343,4 +347,4 @@ type LocalizeProps = {
|
|
|
343
347
|
};
|
|
344
348
|
declare function Localize({ text, tag }: LocalizeProps): react_jsx_runtime.JSX.Element;
|
|
345
349
|
|
|
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 };
|
|
350
|
+
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 FormGroupProps, 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 a,NumberUtil as l,CancellablePromise as o,EntityClientWithStub as r,BasicLocalization as s,ObjectUtil as d,UserAlertType as c,ByteUtil as h}from"zavadil-ts-common";import{useMemo as m,useCallback as p,useEffect as u,useState as g,useRef as b,createContext as v,useContext as f}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 D,BsCircle as A,BsCheckAll as F,BsBug as H,BsExclamationDiamond as $,BsInfo as T,BsQuestion as j,BsEye as V}from"react-icons/bs";import{FaFloppyDisk as R}from"react-icons/fa6";import{VscEyeClosed as U}from"react-icons/vsc";function J({value:t,onChange:a,onReset:l,onBlur:o,disabled:r,className:s}){const d=m((()=>i.getNonEmpty(t)),[t]),c=m((()=>i.isBlank(t)),[d]),h=p((()=>{l?l():a("")}),[l,a]);return e(y,{className:s,children:[n(C.Control,{type:"text",disabled:r,value:d,onChange:e=>a(e.target.value),onBlur:o}),n(w,{onClick:h,disabled:c,children:n("div",{className:"d-flex align-items-center",children:n(I,{})})})]})}function K({value:e,onChange:t,disabled:i}){return n(C.Control,{type:"date",disabled:i,value:a.formatDateForInput(e),onChange:e=>{t(a.parseDate(e.target.value))}})}function Y({value:e,onChange:t,disabled:i}){return n(C.Control,{type:"datetime-local",disabled:i,value:a.formatDateTimeForInput(e),onChange:e=>{t(a.parseDate(e.target.value))}})}function q({disabled:t,variant:i,icon:a,size:l,children:o,onClick:r}){return n(w,{disabled:!0===t,size:l,onClick:r,variant:i,children:e("div",{className:"d-flex align-items-center gap-2",children:[a,o&&n("div",{children:o})]})})}function Q({disabled:t,checked:i,iconOn:a,iconOff:l,size:o,onChange:r}){return e("div",{className:"d-flex align-items-center gap-2 cursor-pointer",onClick:e=>r(!i),children:[n(C.Switch,{disabled:t,size:o,type:"switch",checked:i,readOnly:!0,className:"cursor-pointer"}),i?a:l]})}function W({disabled:e,icon:t,loading:i,children:a,size:l,variant:o,onClick:r}){return n(q,!0===i?{disabled:!0,onClick:r,size:l,variant:o,icon:n(x,{size:"sm"}),children:a}:{disabled:e,onClick:r,icon:t,size:l,variant:o,children:a})}function X({disabled:e,icon:t,loading:i,children:a,size:l,onClick:o,isChanged:r}){const s=m((()=>t||n(R,{})),[t]),d=m((()=>r?n("strong",{children:a}):a),[r,a]);return n(W,{disabled:e||!1===r,onClick:o,icon:s,loading:i,size:l,children:d})}function Z({disabled:e,icon:t,loading:i,children:a,size:l,onClick:o,isChanged:r}){const s=m((()=>t||n(G,{})),[t]);return n(W,{disabled:e||!1===r,onClick:o,icon:s,loading:i,size:l,variant:"danger",children:a})}function _({value:t,options:a,disabled:l,onChange:o,showEmptyOption:r,emptyOptionLabel:s}){return u((()=>{i.isBlank(t)&&a.length>0&&!0!==r&&o(a[0].id)}),[t,a,r,o]),e(C.Select,{value:t||"",onChange:e=>o(e.target.value),disabled:l,children:[!0===r&&n("option",{value:"",children:s||""},""),a?a.map(((e,t)=>n("option",{value:e.id||"",children:e.label||""},t))):n("span",{children:n(x,{})})]})}function ee({value:e,options:t,disabled:i,onChange:a,showEmptyOption:o,emptyOptionLabel:r}){const s=m((()=>e?String(e):""),[e]),d=m((()=>t?t.map((e=>({id:e.id?String(e.id):"",label:e.label}))):[]),[t]),c=p((e=>a(l.parseNumber(e))),[a]);return n(_,{disabled:i,value:s,options:d,onChange:c,showEmptyOption:o,emptyOptionLabel:r})}function ne({id:e,sort:t,disabled:i,labelGetter:a,onChange:l,options:o,showEmptyOption:r,emptyOptionLabel:s}){const d=m((()=>{let e=[];return o&&(e=t?o.sort(((e,n)=>e.name>n.name?1:-1)):o),e.map((e=>({id:e.id,label:a?a(e):e.name})))}),[o]);return n(ee,{disabled:i,value:e,options:d,onChange:l,showEmptyOption:r,emptyOptionLabel:s})}function te({value:e,options:t,onChange:i,showEmptyOption:a,emptyOptionLabel:l}){const o=m((()=>t?t.map((e=>({id:e,label:e}))):[]),[t]);return n(_,{value:e,options:o,onChange:i,showEmptyOption:a,emptyOptionLabel:l})}function ie({id:e,label:t,disabled:i,checked:a,size:l,onChange:o}){return n(C.Switch,{disabled:i,id:e,size:l,type:"switch",checked:a,onChange:e=>o(!a),className:"cursor-pointer",label:t})}function ae({selected:t,disabled:i,labelGetter:a,onChange:l,onSearch:r}){const[s,d]=g(),[c,h]=g(),[v,f]=g(),y=b(),C=p((e=>a?a(e):"name"in e&&"string"==typeof e.name?e.name:`[${e.id}]`),[a]),w=m((()=>t?"border rounded border-primary":void 0),[t]),x=p((()=>{console.log("user left control"),v&&(f(void 0),h(t?C(t):""))}),[l,v,t,C]),z=p((()=>{y.current=window.setTimeout(x,100)}),[y,x]),k=p((()=>{y.current&&clearTimeout(y.current)}),[y]);u((()=>k),[]),u((()=>{h(t?C(t):""),s&&(s.cancel(),d(void 0)),f(void 0)}),[t]);const O=p((()=>{l(null),h(""),s&&(s.cancel(),d(void 0)),f(void 0)}),[l,s]),S=p((e=>{h(e),s&&s.cancel();const n=new o(r(e));n.promise.then(f),d(n)}),[s,r]),E=p((e=>{console.log("user selected item"),f(void 0),l({...e})}),[l]);return n("div",{onBlur:z,onFocus:k,children:e(N,{defaultShow:!1,show:null!==v,children:[n(J,{disabled:i,value:c,onChange:S,onReset:O,className:w}),v&&n(N.Menu,{children:v.map((e=>n(N.Item,{onClick:n=>{k(),E(e)},active:e.id===t?.id,children:C(e)},e.id)))})]})})}function le({selected:e,disabled:t,labelGetter:a,onChange:l,entityClient:o}){const r=p((e=>o.loadPage({search:i.safeLowercase(e),page:0,size:10,sorting:[{name:"id"}]}).then((e=>e.content))),[a]);return n(ae,{disabled:t,selected:e,labelGetter:a,onSearch:r,onChange:l})}function oe({id:e,disabled:t,labelGetter:i,onChange:a,entityClient:l}){const[o,s]=g(null);u((()=>{e?o&&o.id===e?s({...o}):l instanceof r?l.loadSingleStub(e).then(s):l.loadSingle(e).then(s):s(null)}),[e]);const d=p((n=>{const t=n?n.id:null;t!==e&&a(t),s(n)}),[e,a]);return n(le,{disabled:t,selected:o,labelGetter:i,entityClient:l,onChange:d})}function re({selected:e,disabled:t,labelGetter:a,onChange:l,lookupClient:o}){const r=m((()=>a||(e=>e.name)),[a]),s=p((e=>o.loadPage({search:i.safeLowercase(e),page:0,size:10,sorting:[{name:"name"}]}).then((e=>e.content))),[a]);return n(ae,{disabled:t,selected:e,labelGetter:r,onSearch:s,onChange:l})}function se({id:e,disabled:t,labelGetter:i,onChange:a,lookupClient:l}){const[o,r]=g(null);u((()=>{e?o&&o.id===e?r({...o}):l.loadSingle(e).then(r):r(null)}),[e]);const s=p((n=>{const t=n?n.id:null;t!==e&&a(t),r(n)}),[e,o]);return n(re,{disabled:t,selected:o,labelGetter:i,lookupClient:l,onChange:s})}function de({id:e,sort:t,disabled:i,labelGetter:a,onChange:l,options:o,showEmptyOption:r,emptyOptionLabel:s}){const d=m((()=>{let e=[];return o&&(e=t?o.sort(((e,n)=>a(e)>a(n)?1:-1)):o),e.map((e=>({id:e.id,label:a(e)})))}),[o]);return n(ee,{disabled:i,value:e,options:d,onChange:l,showEmptyOption:r,emptyOptionLabel:s})}function ce({value:e,sort:t,disabled:i,labelGetter:a,onChange:l,options:o,showEmptyOption:r,emptyOptionLabel:s}){return n(de,{disabled:i,id:e?e.id:null,options:o,sort:t,onChange:e=>{l(o&&e?o.find((n=>n.id===e)):void 0)},labelGetter:a,showEmptyOption:r,emptyOptionLabel:s})}function he({value:e,sort:t,disabled:i,onChange:a,options:l,showEmptyOption:o,emptyOptionLabel:r}){return n(ce,{value:e,labelGetter:e=>e.name,disabled:i,sort:t,options:l,onChange:a,showEmptyOption:o,emptyOptionLabel:r})}function me({id:e,sort:t,disabled:i,onChange:a,options:l,showEmptyOption:o,emptyOptionLabel:r}){return n(de,{id:e,labelGetter:e=>e.name,disabled:i,sort:t,options:l,onChange:a,showEmptyOption:o,emptyOptionLabel:r})}const pe=v(new s);function ue({text:e,tag:i}){const a=f(pe),l=m((()=>{if(void 0!==i&&""!==i)return"string"==typeof i?{tags:[i]}:{tags:i}}),[i]),o=m((()=>a.translate(e,l)),[a,e,l]);return n(t,{children:o})}function ge({paging:e,totalItems:t,onPagingChanged:i}){const a=Math.ceil(t/e.size),l=n=>{e.page=n,i(d.clone(e))},o=[];if(a>1){o.push(n(z.First,{onClick:()=>l(0),disabled:0===e.page},"first")),o.push(n(z.Prev,{onClick:()=>l(e.page-1),disabled:0===e.page},"prev"));const t=Math.round(3.5);let i=e.page>t?e.page-t:0,r=i+10;r>=a&&(r=a-1),i>0&&o.push(n(z.Ellipsis,{disabled:!0},"ellipsisStart"));for(let t=i;t<=r;t++)o.push(n(z.Item,{active:t===e.page,onClick:()=>l(t),children:t+1},t));r<a-1&&o.push(n(z.Ellipsis,{disabled:!0},"ellipsisEnd")),o.push(n(z.Next,{onClick:()=>l(e.page+1),disabled:e.page===a-1},"next")),o.push(n(z.Last,{onClick:()=>l(a-1),disabled:e.page===a-1},"last"))}return n(z,{size:"sm",className:"flex-wrap m-0",children:o})}const be=[{id:10,label:"10"},{id:100,label:"100"},{id:1e3,label:"1000"}];function ve({hover:a,showPagingOnBottom:l,showPageSizeSelection:o,striped:r,bordered:s,header:c,children:h,paging:p,totalItems:u,onPagingChanged:g}){const b=Math.ceil(u/p.size),v=m((()=>{const e=p.size;if(null===be.find((n=>n.id===e))){const n=d.clone(be);return n.push({id:e,label:String(e)}),n}return be}),[p]);return n("div",{children:e(k,{hover:a,striped:r,responsive:!0,bordered:s,children:[e("thead",{children:[n("tr",{children:n("td",{colSpan:c.length,children:e("div",{className:"d-flex justify-content-between align-items-center gap-2",children:[e("div",{children:[n(ue,{text:"Page"}),": ",p.page+1," / ",b]}),b>0&&n(ge,{paging:p,totalItems:u,onPagingChanged:g}),e("div",{children:[n(ue,{text:"Total items"}),": ",u]})]})})}),n("tr",{children:c.map(((a,l)=>{const o=!1===a.sort?"":i.isBlank(a.sort)?a.name:a.sort;if(i.isBlank(o)||!o)return n("th",{children:a.label},l);const r=p.sorting&&p.sorting.find((e=>e.name===o));return e("th",{className:"user-select-none text-nowrap",role:"button",onClick:e=>((e,n)=>{p.sorting||(p.sorting=[]);let t=p.sorting.find((e=>e.name===n));const 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:[a.label,r?r.desc?n(B,{}):n(M,{}):n(t,{})]},l)}))})]}),n("tbody",{children:h}),u>0&&e("tfoot",{children:[l&&n("tr",{children:n("td",{colSpan:c.length,children:e("div",{className:"d-flex justify-content-between align-items-center gap-2",children:[e("div",{children:[n(ue,{text:"Page"}),": ",p.page+1," / ",b]}),b>0&&n(ge,{paging:p,totalItems:u,onPagingChanged:g}),e("div",{children:[n(ue,{text:"Total items"}),": ",u]})]})})}),o&&n("tr",{children:n("td",{colSpan:c.length,children:e("div",{className:"d-flex align-items-center gap-2 justify-content-end",children:[e("div",{className:"text-nowrap",children:[n(ue,{text:"Page size"}),":"]}),n("div",{children:n(ee,{value:p.size,options:v,onChange:e=>{p.size=e||10,g({...p})},showEmptyOption:!1})})]})})})]})]})})}function fe({disabled:e,checked:t,iconOn:i,iconOff:a,size:l,onChange:o}){const r=m((()=>t?i||n(D,{size:l}):a||n(A,{size:l,className:"text-muted"})),[t,i,a,l]);return n("div",{className:"d-flex align-items-center cursor-pointer",onClick:e=>{e.stopPropagation(),e.preventDefault(),o(!t)},children:r})}function ye({showSelect:t,header:i,items:a,onSelect:l,onClick:o,totalItems:r,paging:s,onPagingChanged:c}){const[h,b]=g(!1),[v,f]=g(),y=p((e=>{v&&f(v.map((n=>({selected:e,item:n.item})))),b(e)}),[v]),C=m((()=>{const e=[...i];return!1!==t&&e.unshift({name:"",label:n("div",{className:"py-1",children:n(fe,{checked:h,onChange:()=>y(!h),iconOn:n(F,{})})})}),e}),[i,h,y]);return u((()=>{f(a?a.map((e=>({selected:h,item:e}))):void 0)}),[a]),u((()=>{v&&l&&l(v.filter((e=>e.selected)).map((e=>e.item)))}),[v,l]),n(ve,{header:C,hover:void 0!==o,paging:s,striped:!0,totalItems:r,onPagingChanged:c,children:v&&v.map(((a,l)=>e("tr",{className:`selectable ${o?"cursor-pointer":""} ${a.selected?"table-active table-primary":""}`,onClick:e=>{o&&o(a.item)},children:[!1!==t&&n("td",{children:n("div",{className:"py-2 d-flex align-items-center",children:n(fe,{checked:a.selected,onChange:()=>{a.selected=!a.selected,h&&!a.selected&&b(!1),f([...v])}})})}),i.map(((e,t)=>{const i=e.renderer||(l=e.name,e=>d.getNestedValue(e,l));var l;return n("td",{children:i(a.item)},t)}))]},l)))})}function Ce({cols:e,rows:t,size:i}){const a=m((()=>void 0===e?1:e),[e]),l=m((()=>void 0===t?20:t),[t]);return m((()=>void 0===i?"lg":i),[i]),n("div",{children:n(k,{responsive:!0,children:n("tbody",{children:Array.from({length:l},((e,t)=>n("tr",{children:Array.from({length:a},((e,t)=>n("td",{children:n("div",{className:"w-100 p-1 m-1"})},t)))},t)))})})})}function we({value:e}){return n("div",{className:"text-nowrap",children:a.formatDateTimeForHumans(e)})}function xe({ms:e}){return d.isEmpty(e)?n(t,{}):n("div",{className:"text-nowrap",children:a.formatDuration(e)})}function Ne({date:e}){const t=m((()=>d.isEmpty(e)?null:Date.now()-e.getTime()),[e]);return n(xe,{ms:t})}const ze=new Map([[c.error,H],[c.warning,$],[c.info,T]]);function ke({type:e,size:t,customVariant:i}){const a=ze.get(e)||j;return n("div",{className:`d-flex align-items-center text-${void 0===i?e:i}`,children:a({size:t})})}function Oe({userAlert:t,maxDurationMs:i}){return e(O,{direction:"horizontal",gap:2,className:"align-items-center",children:[t.remainsMs&&n("div",{style:{width:20},children:n(S,{min:0,max:i,now:t.remainsMs,variant:t.type})}),n("div",{children:a.formatDateForHumans(t.time)}),n(ke,{type:t.type}),n("div",{children:t.message})]})}function Se({userAlerts:i}){const[a,l]=g(!1),[o,r]=g(i.alerts.length),[s,d]=g([...i.visibleAlerts]),[c,h]=g(i.getSummary()),m=p((()=>{r(i.alerts.length),d(a?[...i.alerts]:[...i.visibleAlerts]),h(i.getSummary())}),[i,a]);return u((()=>{i.addOnChangeHandler(m);const e=setInterval((()=>i.updateVisibility()),100);return()=>{clearInterval(e),i.removeOnChangeHandler(m)}}),[i,m]),o<=0?n(t,{}):e("div",{className:"user-alerts border rounded bg-body text-body position-fixed text-end",style:{bottom:15,right:15,zIndex:2147483647},children:[s.length>0&&n("div",{className:"max-w-50 p-2 border-bottom",children:s.map(((e,t)=>n(Oe,{userAlert:e,maxDurationMs:i.maxVisibilityMs},t)))}),n("div",{className:"p-2",children:e(O,{direction:"horizontal",gap:2,className:"justify-content-end align-items-center",children:[n(q,a?{size:"sm",variant:"primary",onClick:()=>l(!1),icon:n(U,{}),children:"Hide"}:{size:"sm",variant:"primary",onClick:()=>l(!0),icon:n(V,{}),children:"Show All"}),Array.from(c.entries()).map(((t,i)=>e(O,{direction:"horizontal",gap:1,className:"px-1 border rounded align-items-center",children:[n(ke,{type:t[0],customVariant:0===t[1]?"muted":void 0}),n("div",{className:t[1]>0?`text-${t[0]} fw-bold`:"text-muted",children:t[1]})]},i))),n(q,{size:"sm",variant:"danger",onClick:()=>i.reset(),icon:n(G,{}),children:"Reset"})]})})]})}class Ee{constructor(e){this.setProps=e}confirm(e,n,t){this.setProps({name:e,text:n,onConfirm:()=>{t(),this.setProps(void 0)},onClose:()=>this.setProps(void 0)})}}const Pe=v(new Ee((()=>{})));function Le({name:t,text:i,onClose:a,onConfirm:l}){return e(E,{show:!0,backdrop:!0,onHide:a,children:[n(E.Header,{children:t||"Confirm"}),n(E.Body,{children:i}),n(E.Footer,{children:e(O,{direction:"horizontal",children:[n(w,{variant:"link",onClick:a,children:n(ue,{text:"Back"})}),n(w,{variant:"primary",onClick:l,children:n(ue,{text:"Yes"})})]})})]})}function Ie({stats:t}){const i=t.heapSize,a=t.heapMaxSize,l=t.heapFreeSize,o=i-l;return e("div",{children:[e("div",{className:"d-flex align-items-center gap-2",children:[n("pre",{children:"Java Heap"}),e("pre",{children:["[",h.formatByteSize(i)," / ",h.formatByteSize(a),"]"]})]}),e("div",{className:"d-flex align-items-center gap-2",children:[n("pre",{children:"Used:"}),n(P,{className:"bg-warning text-bg-warning",children:h.formatByteSize(o)}),n("pre",{children:"Free:"}),n(P,{className:"bg-success text-white",children:h.formatByteSize(l)})]}),n("div",{className:"p-1",children:e(S,{min:0,max:a,children:[n(S,{variant:"warning",min:0,now:o,max:a}),n(S,{variant:"success",min:0,now:l,max:a})]})})]})}function Ge({name:t,stats:i}){return e("div",{children:[e("div",{className:"d-flex align-items-center gap-2",children:[n("pre",{children:t}),e("pre",{children:["[",i.cachedItems,i.capacity>0&&" / ",i.capacity>0&&i.capacity,"]"]})]}),i.capacity>0&&n("div",{className:"p-1",children:n(S,{now:i.cachedItems,min:0,max:i.capacity})})]})}const Be=new Map([["Idle","secondary"],["Processing","success"],["Loading","warn"]]);function Me({state:e}){const t=Be.get(e)||"light";return n(P,{className:`bg-${t} text-bg-${t}`,children:e})}function De({name:t,stats:i}){const a=i?i.remaining+i.processed:void 0;return e("div",{children:[e("div",{className:"d-flex align-items-center gap-2",children:[n("pre",{children:t}),e("pre",{children:["[",void 0!==i?.processed?i.processed:"?"," / ",void 0!==a?a:"?","]"]}),n(Me,{state:i?i.state:"Unknown"})]}),n("div",{className:"p-1",children:i?n(S,{variant:"primary",striped:!0,animated:!0,min:0,now:i.processed,max:a||1}):n(L,{className:"w-100",animation:"glow",children:n(L,{className:"w-100"})})})]})}function Ae({children:e,center:t}){const i=m((()=>!1===t?"":"d-flex align-items-center justify-content-center"),[t]);return n("div",{className:`w-100 h-100 position-absolute ${i}`,style:{left:0,right:0,top:0,bottom:0},children:e})}export{ve as AdvancedTable,oe as AutocompleteEntityIdSelect,le as AutocompleteEntitySelect,se as AutocompleteLookupIdSelect,re as AutocompleteLookupSelect,ae as AutocompleteSelect,Ge as CacheStatsControl,Le as ConfirmDialog,Pe as ConfirmDialogContext,Ee as ConfirmDialogContextData,K as DateInput,we as DateTime,Y as DateTimeInput,Z as DeleteButton,xe as Duration,Ne as Elapsed,de as EntityIdSelect,ce as EntitySelect,me as EntityWithNameIdSelect,he as EntityWithNameSelect,te as EnumSelect,q as IconButton,Q as IconSwitch,Ie as JavaHeapControl,W as LoadingButton,pe as LocalizationContext,ue as Localize,ne as LookupSelect,ee as NumberSelect,Me as QueueStateControl,De as QueueStatsControl,X as SaveButton,Ae as Spread,_ as StringSelect,ie as Switch,ge as TablePagination,Ce as TablePlaceholder,ye as TableWithSelect,J as TextInputWithReset,ke as UserAlertTypeIcon,Oe as UserAlertWidget,Se as UserAlertsWidget};
|
|
1
|
+
import{jsx as e,Fragment as n,jsxs as t}from"react/jsx-runtime";import{BasicLocalization as i,StringUtil as a,DateUtil as l,NumberUtil as o,CancellablePromise as r,EntityClientWithStub as s,ObjectUtil as d,UserAlertType as c,ByteUtil as h}from"zavadil-ts-common";import{createContext as m,useContext as p,useMemo as u,useCallback as g,useEffect as b,useState as v,useRef as f}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 D,BsCircle as A,BsCheckAll as F,BsBug as H,BsExclamationDiamond as $,BsInfo as T,BsQuestion as j,BsEye as V}from"react-icons/bs";import{FaFloppyDisk as R}from"react-icons/fa6";import{VscEyeClosed as U}from"react-icons/vsc";const J=m(new i);function K({text:t,tag:i}){const a=p(J),l=u((()=>{if(void 0!==i&&""!==i)return"string"==typeof i?{tags:[i]}:{tags:i}}),[i]),o=u((()=>a.translate(t,l)),[a,t,l]);return e(n,{children:o})}function Y({value:n,onChange:i,onReset:l,onBlur:o,disabled:r,className:s}){const d=u((()=>a.getNonEmpty(n)),[n]),c=u((()=>a.isBlank(n)),[d]),h=g((()=>{l?l():i("")}),[l,i]);return t(y,{className:s,children:[e(C.Control,{type:"text",disabled:r,value:d,onChange:e=>i(e.target.value),onBlur:o}),e(w,{onClick:h,disabled:c,children:e("div",{className:"d-flex align-items-center",children:e(I,{})})})]})}function q({value:n,onChange:t,disabled:i}){return e(C.Control,{type:"date",disabled:i,value:l.formatDateForInput(n),onChange:e=>{t(l.parseDate(e.target.value))}})}function Q({value:n,onChange:t,disabled:i}){return e(C.Control,{type:"datetime-local",disabled:i,value:l.formatDateTimeForInput(n),onChange:e=>{t(l.parseDate(e.target.value))}})}function W({disabled:n,variant:i,icon:a,size:l,children:o,onClick:r}){return e(w,{disabled:!0===n,size:l,onClick:r,variant:i,children:t("div",{className:"d-flex align-items-center gap-2",children:[a,o&&e("div",{children:o})]})})}function X({disabled:n,checked:i,iconOn:a,iconOff:l,size:o,onChange:r}){return t("div",{className:"d-flex align-items-center gap-2 cursor-pointer",onClick:e=>r(!i),children:[e(C.Switch,{disabled:n,size:o,type:"switch",checked:i,readOnly:!0,className:"cursor-pointer"}),i?a:l]})}function Z({disabled:n,icon:t,loading:i,children:a,size:l,variant:o,onClick:r}){return e(W,!0===i?{disabled:!0,onClick:r,size:l,variant:o,icon:e(x,{size:"sm"}),children:a}:{disabled:n,onClick:r,icon:t,size:l,variant:o,children:a})}function _({disabled:n,icon:t,loading:i,children:a,size:l,onClick:o,isChanged:r}){const s=u((()=>t||e(R,{})),[t]),d=u((()=>r?e("strong",{children:a}):a),[r,a]);return e(Z,{disabled:n||!1===r,onClick:o,icon:s,loading:i,size:l,children:d})}function ee({disabled:n,icon:t,loading:i,children:a,size:l,onClick:o,isChanged:r}){const s=u((()=>t||e(G,{})),[t]);return e(Z,{disabled:n||!1===r,onClick:o,icon:s,loading:i,size:l,variant:"danger",children:a})}function ne({value:n,options:i,disabled:l,onChange:o,showEmptyOption:r,emptyOptionLabel:s}){return b((()=>{a.isBlank(n)&&i.length>0&&!0!==r&&o(i[0].id)}),[n,i,r,o]),t(C.Select,{value:n||"",onChange:e=>o(e.target.value),disabled:l,children:[!0===r&&e("option",{value:"",children:s||""},""),i?i.map(((n,t)=>e("option",{value:n.id||"",children:n.label||""},t))):e("span",{children:e(x,{})})]})}function te({value:n,options:t,disabled:i,onChange:a,showEmptyOption:l,emptyOptionLabel:r}){const s=u((()=>n?String(n):""),[n]),d=u((()=>t?t.map((e=>({id:e.id?String(e.id):"",label:e.label}))):[]),[t]),c=g((e=>a(o.parseNumber(e))),[a]);return e(ne,{disabled:i,value:s,options:d,onChange:c,showEmptyOption:l,emptyOptionLabel:r})}function ie({id:n,sort:t,disabled:i,labelGetter:a,onChange:l,options:o,showEmptyOption:r,emptyOptionLabel:s}){const d=u((()=>{let e=[];return o&&(e=t?o.sort(((e,n)=>e.name>n.name?1:-1)):o),e.map((e=>({id:e.id,label:a?a(e):e.name})))}),[o]);return e(te,{disabled:i,value:n,options:d,onChange:l,showEmptyOption:r,emptyOptionLabel:s})}function ae({value:n,options:t,onChange:i,showEmptyOption:a,emptyOptionLabel:l}){const o=u((()=>t?t.map((e=>({id:e,label:e}))):[]),[t]);return e(ne,{value:n,options:o,onChange:i,showEmptyOption:a,emptyOptionLabel:l})}function le({id:n,label:t,disabled:i,checked:l,size:o,onChange:r}){const s=u((()=>n||a.randomString()),[n]);return e(C.Switch,{disabled:i,id:s,size:o,type:"switch",checked:l,onChange:e=>r(!l),className:"cursor-pointer",label:t})}function oe({selected:n,disabled:i,labelGetter:a,onChange:l,onSearch:o}){const[s,d]=v(),[c,h]=v(),[m,p]=v(),y=f(),C=g((e=>a?a(e):"name"in e&&"string"==typeof e.name?e.name:`[${e.id}]`),[a]),w=u((()=>n?"border rounded border-primary":void 0),[n]),x=g((()=>{console.log("user left control"),m&&(p(void 0),h(n?C(n):""))}),[l,m,n,C]),z=g((()=>{y.current=window.setTimeout(x,100)}),[y,x]),k=g((()=>{y.current&&clearTimeout(y.current)}),[y]);b((()=>k),[]),b((()=>{h(n?C(n):""),s&&(s.cancel(),d(void 0)),p(void 0)}),[n]);const O=g((()=>{l(null),h(""),s&&(s.cancel(),d(void 0)),p(void 0)}),[l,s]),S=g((e=>{h(e),s&&s.cancel();const n=new r(o(e));n.promise.then(p),d(n)}),[s,o]),E=g((e=>{console.log("user selected item"),p(void 0),l({...e})}),[l]);return e("div",{onBlur:z,onFocus:k,children:t(N,{defaultShow:!1,show:null!==m,children:[e(Y,{disabled:i,value:c,onChange:S,onReset:O,className:w}),m&&e(N.Menu,{children:m.map((t=>e(N.Item,{onClick:e=>{k(),E(t)},active:t.id===n?.id,children:C(t)},t.id)))})]})})}function re({selected:n,disabled:t,labelGetter:i,onChange:l,entityClient:o}){const r=g((e=>o.loadPage({search:a.safeLowercase(e),page:0,size:10,sorting:[{name:"id"}]}).then((e=>e.content))),[i]);return e(oe,{disabled:t,selected:n,labelGetter:i,onSearch:r,onChange:l})}function se({id:n,disabled:t,labelGetter:i,onChange:a,entityClient:l}){const[o,r]=v(null);b((()=>{n?o&&o.id===n?r({...o}):l instanceof s?l.loadSingleStub(n).then(r):l.loadSingle(n).then(r):r(null)}),[n]);const d=g((e=>{const t=e?e.id:null;t!==n&&a(t),r(e)}),[n,a]);return e(re,{disabled:t,selected:o,labelGetter:i,entityClient:l,onChange:d})}function de({selected:n,disabled:t,labelGetter:i,onChange:l,lookupClient:o}){const r=u((()=>i||(e=>e.name)),[i]),s=g((e=>o.loadPage({search:a.safeLowercase(e),page:0,size:10,sorting:[{name:"name"}]}).then((e=>e.content))),[i]);return e(oe,{disabled:t,selected:n,labelGetter:r,onSearch:s,onChange:l})}function ce({id:n,disabled:t,labelGetter:i,onChange:a,lookupClient:l}){const[o,r]=v(null);b((()=>{n?o&&o.id===n?r({...o}):l.loadSingle(n).then(r):r(null)}),[n]);const s=g((e=>{const t=e?e.id:null;t!==n&&a(t),r(e)}),[n,o]);return e(de,{disabled:t,selected:o,labelGetter:i,lookupClient:l,onChange:s})}function he({id:n,sort:t,disabled:i,labelGetter:a,onChange:l,options:o,showEmptyOption:r,emptyOptionLabel:s}){const d=u((()=>{let e=[];return o&&(e=t?o.sort(((e,n)=>a(e)>a(n)?1:-1)):o),e.map((e=>({id:e.id,label:a(e)})))}),[o]);return e(te,{disabled:i,value:n,options:d,onChange:l,showEmptyOption:r,emptyOptionLabel:s})}function me({value:n,sort:t,disabled:i,labelGetter:a,onChange:l,options:o,showEmptyOption:r,emptyOptionLabel:s}){return e(he,{disabled:i,id:n?n.id:null,options:o,sort:t,onChange:e=>{l(o&&e?o.find((n=>n.id===e)):void 0)},labelGetter:a,showEmptyOption:r,emptyOptionLabel:s})}function pe({value:n,sort:t,disabled:i,onChange:a,options:l,showEmptyOption:o,emptyOptionLabel:r}){return e(me,{value:n,labelGetter:e=>e.name,disabled:i,sort:t,options:l,onChange:a,showEmptyOption:o,emptyOptionLabel:r})}function ue({id:n,sort:t,disabled:i,onChange:a,options:l,showEmptyOption:o,emptyOptionLabel:r}){return e(he,{id:n,labelGetter:e=>e.name,disabled:i,sort:t,options:l,onChange:a,showEmptyOption:o,emptyOptionLabel:r})}function ge({paging:n,totalItems:t,onPagingChanged:i}){const a=Math.ceil(t/n.size),l=e=>{n.page=e,i(d.clone(n))},o=[];if(a>1){o.push(e(z.First,{onClick:()=>l(0),disabled:0===n.page},"first")),o.push(e(z.Prev,{onClick:()=>l(n.page-1),disabled:0===n.page},"prev"));const t=Math.round(3.5);let i=n.page>t?n.page-t:0,r=i+10;r>=a&&(r=a-1),i>0&&o.push(e(z.Ellipsis,{disabled:!0},"ellipsisStart"));for(let t=i;t<=r;t++)o.push(e(z.Item,{active:t===n.page,onClick:()=>l(t),children:t+1},t));r<a-1&&o.push(e(z.Ellipsis,{disabled:!0},"ellipsisEnd")),o.push(e(z.Next,{onClick:()=>l(n.page+1),disabled:n.page===a-1},"next")),o.push(e(z.Last,{onClick:()=>l(a-1),disabled:n.page===a-1},"last"))}return e(z,{size:"sm",className:"flex-wrap m-0",children:o})}const be=[{id:10,label:"10"},{id:100,label:"100"},{id:1e3,label:"1000"}];function ve({hover:i,showPagingOnBottom:l,showPageSizeSelection:o,striped:r,bordered:s,header:c,children:h,paging:m,totalItems:p,onPagingChanged:g}){const b=Math.ceil(p/m.size),v=u((()=>{const e=m.size;if(null===be.find((n=>n.id===e))){const n=d.clone(be);return n.push({id:e,label:String(e)}),n}return be}),[m]);return e("div",{children:t(k,{hover:i,striped:r,responsive:!0,bordered:s,children:[t("thead",{children:[e("tr",{children:e("td",{colSpan:c.length,children:t("div",{className:"d-flex justify-content-between align-items-center gap-2",children:[t("div",{children:[e(K,{text:"Page"}),": ",m.page+1," / ",b]}),b>0&&e(ge,{paging:m,totalItems:p,onPagingChanged:g}),t("div",{children:[e(K,{text:"Total items"}),": ",p]})]})})}),e("tr",{children:c.map(((i,l)=>{const o=!1===i.sort?"":a.isBlank(i.sort)?i.name:i.sort;if(a.isBlank(o)||!o)return e("th",{children:i.label},l);const r=m.sorting&&m.sorting.find((e=>e.name===o));return t("th",{className:"user-select-none text-nowrap",role:"button",onClick:e=>((e,n)=>{m.sorting||(m.sorting=[]);let t=m.sorting.find((e=>e.name===n));const 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(d.clone(m))})(e,o),children:[i.label,r?r.desc?e(B,{}):e(M,{}):e(n,{})]},l)}))})]}),e("tbody",{children:h}),p>0&&t("tfoot",{children:[l&&e("tr",{children:e("td",{colSpan:c.length,children:t("div",{className:"d-flex justify-content-between align-items-center gap-2",children:[t("div",{children:[e(K,{text:"Page"}),": ",m.page+1," / ",b]}),b>0&&e(ge,{paging:m,totalItems:p,onPagingChanged:g}),t("div",{children:[e(K,{text:"Total items"}),": ",p]})]})})}),o&&e("tr",{children:e("td",{colSpan:c.length,children:t("div",{className:"d-flex align-items-center gap-2 justify-content-end",children:[t("div",{className:"text-nowrap",children:[e(K,{text:"Page size"}),":"]}),e("div",{children:e(te,{value:m.size,options:v,onChange:e=>{m.size=e||10,g({...m})},showEmptyOption:!1})})]})})})]})]})})}function fe({disabled:n,checked:t,iconOn:i,iconOff:a,size:l,onChange:o}){const r=u((()=>t?i||e(D,{size:l}):a||e(A,{size:l,className:"text-muted"})),[t,i,a,l]);return e("div",{className:"d-flex align-items-center cursor-pointer",onClick:e=>{e.stopPropagation(),e.preventDefault(),o(!t)},children:r})}function ye({showSelect:n,header:i,items:a,onSelect:l,onClick:o,totalItems:r,paging:s,onPagingChanged:c}){const[h,m]=v(!1),[p,f]=v(),y=g((e=>{p&&f(p.map((n=>({selected:e,item:n.item})))),m(e)}),[p]),C=u((()=>{const t=[...i];return!1!==n&&t.unshift({name:"",label:e("div",{className:"py-1",children:e(fe,{checked:h,onChange:()=>y(!h),iconOn:e(F,{})})})}),t}),[i,h,y]);return b((()=>{f(a?a.map((e=>({selected:h,item:e}))):void 0)}),[a]),b((()=>{p&&l&&l(p.filter((e=>e.selected)).map((e=>e.item)))}),[p,l]),e(ve,{header:C,hover:void 0!==o,paging:s,striped:!0,totalItems:r,onPagingChanged:c,children:p&&p.map(((a,l)=>t("tr",{className:`selectable ${o?"cursor-pointer":""} ${a.selected?"table-active table-primary":""}`,onClick:e=>{o&&o(a.item)},children:[!1!==n&&e("td",{children:e("div",{className:"py-2 d-flex align-items-center",children:e(fe,{checked:a.selected,onChange:()=>{a.selected=!a.selected,h&&!a.selected&&m(!1),f([...p])}})})}),i.map(((n,t)=>{const i=n.renderer||(l=n.name,e=>d.getNestedValue(e,l));var l;return e("td",{children:i(a.item)},t)}))]},l)))})}function Ce({cols:n,rows:t,size:i}){const a=u((()=>void 0===n?1:n),[n]),l=u((()=>void 0===t?20:t),[t]);return u((()=>void 0===i?"lg":i),[i]),e("div",{children:e(k,{responsive:!0,children:e("tbody",{children:Array.from({length:l},((n,t)=>e("tr",{children:Array.from({length:a},((n,t)=>e("td",{children:e("div",{className:"w-100 p-1 m-1"})},t)))},t)))})})})}function we({value:n}){return e("div",{className:"text-nowrap",children:l.formatDateTimeForHumans(n)})}function xe({ms:t}){return d.isEmpty(t)?e(n,{}):e("div",{className:"text-nowrap",children:l.formatDuration(t)})}function Ne({date:n}){const t=u((()=>d.isEmpty(n)?null:Date.now()-n.getTime()),[n]);return e(xe,{ms:t})}const ze=new Map([[c.error,H],[c.warning,$],[c.info,T]]);function ke({type:n,size:t,customVariant:i}){const a=ze.get(n)||j;return e("div",{className:`d-flex align-items-center text-${void 0===i?n:i}`,children:a({size:t})})}function Oe({userAlert:n,maxDurationMs:i}){return t(O,{direction:"horizontal",gap:2,className:"align-items-center",children:[n.remainsMs&&e("div",{style:{width:20},children:e(S,{min:0,max:i,now:n.remainsMs,variant:n.type})}),e("div",{children:l.formatDateForHumans(n.time)}),e(ke,{type:n.type}),e("div",{children:n.message})]})}function Se({userAlerts:i}){const[a,l]=v(!1),[o,r]=v(i.alerts.length),[s,d]=v([...i.visibleAlerts]),[c,h]=v(i.getSummary()),m=g((()=>{r(i.alerts.length),d(a?[...i.alerts]:[...i.visibleAlerts]),h(i.getSummary())}),[i,a]);return b((()=>{i.addOnChangeHandler(m);const e=setInterval((()=>i.updateVisibility()),100);return()=>{clearInterval(e),i.removeOnChangeHandler(m)}}),[i,m]),o<=0?e(n,{}):t("div",{className:"user-alerts border rounded bg-body text-body position-fixed text-end",style:{bottom:15,right:15,zIndex:2147483647},children:[s.length>0&&e("div",{className:"max-w-50 p-2 border-bottom",children:s.map(((n,t)=>e(Oe,{userAlert:n,maxDurationMs:i.maxVisibilityMs},t)))}),e("div",{className:"p-2",children:t(O,{direction:"horizontal",gap:2,className:"justify-content-end align-items-center",children:[e(W,a?{size:"sm",variant:"primary",onClick:()=>l(!1),icon:e(U,{}),children:"Hide"}:{size:"sm",variant:"primary",onClick:()=>l(!0),icon:e(V,{}),children:"Show All"}),Array.from(c.entries()).map(((n,i)=>t(O,{direction:"horizontal",gap:1,className:"px-1 border rounded align-items-center",children:[e(ke,{type:n[0],customVariant:0===n[1]?"muted":void 0}),e("div",{className:n[1]>0?`text-${n[0]} fw-bold`:"text-muted",children:n[1]})]},i))),e(W,{size:"sm",variant:"danger",onClick:()=>i.reset(),icon:e(G,{}),children:"Reset"})]})})]})}class Ee{constructor(e){this.setProps=e}confirm(e,n,t){this.setProps({name:e,text:n,onConfirm:()=>{t(),this.setProps(void 0)},onClose:()=>this.setProps(void 0)})}}const Pe=m(new Ee((()=>{})));function Le({name:n,text:i,onClose:a,onConfirm:l}){return t(E,{show:!0,backdrop:!0,onHide:a,children:[e(E.Header,{children:n||"Confirm"}),e(E.Body,{children:i}),e(E.Footer,{children:t(O,{direction:"horizontal",children:[e(w,{variant:"link",onClick:a,children:e(K,{text:"Back"})}),e(w,{variant:"primary",onClick:l,children:e(K,{text:"Yes"})})]})})]})}function Ie({stats:n}){const i=n.heapSize,a=n.heapMaxSize,l=n.heapFreeSize,o=i-l;return t("div",{children:[t("div",{className:"d-flex align-items-center gap-2",children:[e("pre",{children:"Java Heap"}),t("pre",{children:["[",h.formatByteSize(i)," / ",h.formatByteSize(a),"]"]})]}),t("div",{className:"d-flex align-items-center gap-2",children:[e("pre",{children:"Used:"}),e(P,{className:"bg-warning text-bg-warning",children:h.formatByteSize(o)}),e("pre",{children:"Free:"}),e(P,{className:"bg-success text-white",children:h.formatByteSize(l)})]}),e("div",{className:"p-1",children:t(S,{min:0,max:a,children:[e(S,{variant:"warning",min:0,now:o,max:a}),e(S,{variant:"success",min:0,now:l,max:a})]})})]})}function Ge({name:n,stats:i}){return t("div",{children:[t("div",{className:"d-flex align-items-center gap-2",children:[e("pre",{children:n}),t("pre",{children:["[",i.cachedItems,i.capacity>0&&" / ",i.capacity>0&&i.capacity,"]"]})]}),i.capacity>0&&e("div",{className:"p-1",children:e(S,{now:i.cachedItems,min:0,max:i.capacity})})]})}const Be=new Map([["Idle","secondary"],["Processing","success"],["Loading","warn"]]);function Me({state:n}){const t=Be.get(n)||"light";return e(P,{className:`bg-${t} text-bg-${t}`,children:n})}function De({name:n,stats:i}){const a=i?i.remaining+i.processed:void 0;return t("div",{children:[t("div",{className:"d-flex align-items-center gap-2",children:[e("pre",{children:n}),t("pre",{children:["[",void 0!==i?.processed?i.processed:"?"," / ",void 0!==a?a:"?","]"]}),e(Me,{state:i?i.state:"Unknown"})]}),e("div",{className:"p-1",children:i?e(S,{variant:"primary",striped:!0,animated:!0,min:0,now:i.processed,max:a||1}):e(L,{className:"w-100",animation:"glow",children:e(L,{className:"w-100"})})})]})}function Ae({children:n,center:t}){const i=u((()=>!1===t?"":"d-flex align-items-center justify-content-center"),[t]);return e("div",{className:`w-100 h-100 position-absolute ${i}`,style:{left:0,right:0,top:0,bottom:0},children:n})}export{ve as AdvancedTable,se as AutocompleteEntityIdSelect,re as AutocompleteEntitySelect,ce as AutocompleteLookupIdSelect,de as AutocompleteLookupSelect,oe as AutocompleteSelect,Ge as CacheStatsControl,Le as ConfirmDialog,Pe as ConfirmDialogContext,Ee as ConfirmDialogContextData,q as DateInput,we as DateTime,Q as DateTimeInput,ee as DeleteButton,xe as Duration,Ne as Elapsed,he as EntityIdSelect,me as EntitySelect,ue as EntityWithNameIdSelect,pe as EntityWithNameSelect,ae as EnumSelect,W as IconButton,X as IconSwitch,Ie as JavaHeapControl,Z as LoadingButton,J as LocalizationContext,K as Localize,ie as LookupSelect,te as NumberSelect,Me as QueueStateControl,De as QueueStatsControl,_ as SaveButton,Ae as Spread,ne as StringSelect,le as Switch,ge as TablePagination,Ce as TablePlaceholder,ye as TableWithSelect,Y as TextInputWithReset,ke as UserAlertTypeIcon,Oe as UserAlertWidget,Se as UserAlertsWidget};
|
|
2
2
|
//# sourceMappingURL=index.esm.js.map
|