@deviceinsight/ng-ui-components 7.1.0 → 7.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +3902 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2798 -1939
- package/dist/index.js.map +1 -1
- package/dist/style.css +2378 -1
- package/package.json +16 -19
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,3903 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),L=require("react-toastify"),nt=require("nanoid"),p=require("react"),P=require("classnames"),A=require("@deviceinsight/ng-ui-basic-components"),ue=require("pure-color"),te=require("react-colorful"),Te=require("dayjs/plugin/timezone"),Oe=require("dayjs/plugin/utc"),J=require("react-datepicker"),T=require("lodash"),S=require("dayjs"),it=require("dayjs/plugin/localeData"),rt=require("dayjs/plugin/localizedFormat"),at=require("dayjs/plugin/customParseFormat"),z=require("i18next"),ot=require("date-fns/locale");require("dayjs/locale/en");require("dayjs/locale/en-gb");require("dayjs/locale/en-ca");require("dayjs/locale/de");require("dayjs/locale/de-at");require("dayjs/locale/de-ch");require("dayjs/locale/it");require("dayjs/locale/ja");const O=require("react-router-dom"),xe=require("@dnd-kit/core"),K=require("@dnd-kit/sortable"),lt=require("@dnd-kit/modifiers"),ve=require("@deviceinsight/ng-ui-api-client"),ct=require("react-select"),dt=require("react-dropzone"),ut=require("react-select-async-paginate"),De=require("@svgdotjs/svg.js"),ht=require("highcharts"),pt=require("highcharts-react-official"),Pe=require("@rc-component/slider"),ft=require("@rc-component/tooltip");function Le(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const s in t)if(s!=="default"){const n=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(e,s,n.get?n:{enumerable:!0,get:()=>t[s]})}}return e.default=t,Object.freeze(e)}const Z=Le(p),se=Le(ot);let G={},Ve={autoClose:!1};const gt=t=>{Ve=t},ee=(t,e)=>{t&&(G[t]?G[t]=[...G[t],e]:G[t]=[e])},mt=(t,e,s)=>{const n=L.toast.success(t,e);s&&ee(s,n)},xt=(t,e,s)=>{const n=L.toast.info(t,e);s&&ee(s,n)},vt=(t,e,s)=>{const n=L.toast.warn(t,e);s&&ee(s,n)},St=(t,e,s)=>{const n=L.toast.error(t,{...Ve,...e});s&&ee(s,n)},bt=t=>{L.toast.dismiss(t)},yt=t=>{G[t]&&(G[t].forEach(e=>L.toast.dismiss(e)),delete G[t])},jt=()=>{G={},L.toast.dismiss()},Ct=()=>i.jsx(L.ToastContainer,{position:"top-center",theme:"colored",autoClose:3e4,hideProgressBar:!0,transition:L.Slide}),Be=(t=32)=>{let e="";for(let s=0;s<t;s++){const n=Math.random()*16|0;(s===8||s===12||s===16||s===20)&&(e+="-"),e+=(s===12?4:s===16?n&3|8:n).toString(16)}return e},wt="0123456789abcdefghijklmnopqrstuvwxyz",At=nt.customAlphabet(wt,10);let C,V;function Nt(t,e){C=t,V=e}function It(t){return t.filter((e,s,n)=>n.indexOf(e)===s)}function Rt(t,e){return t.filter(s=>!e.includes(s))}function kt(t,e){return It([...t,...e])}function Et(t,e){return t.filter(s=>e.includes(s))}function ae(t){return t.children?t.children.length+t.children.reduce((s,n)=>s+ae(n),0):0}function X(t){return t.children?t.children.reduce((e,s)=>[...e,...X(s)],[]):[t]}function Mt(t){return X(t).map(e=>e.id)}function Tt({childNodeKey:t,idKey:e,displayNameKey:s,typeKey:n,lazyLoadableKey:r,nodeMetaData:a,leafMetaData:o}){const{typeValue:l,image:c,resolver:u}=o,{typeValue:d,expandedImage:h,closedImage:g,resolver:f}=a;return function m(x,y=""){return x.map(v=>{const j=v[e],w=v[s],I=v[t],N=v[r],R=f?f(v):v[n]===d,M=u?u(v):v[n]===l,b=`${y}/${w}`,k=v;if(R)return{id:j,name:w,children:m(I||[],b),lazyLoadable:N,expandedImage:h,closedImage:g,path:b,originalNode:k};if(M)return{id:j,name:w,image:c,path:b,originalNode:k};throw new Error("unknown node or leaf type provided")})}}function Ot(t,e){let s;return e.children!==void 0&&(t.children!==void 0?s=[...t.children,...e.children]:s=[...e.children]),{...t,...e,children:s||void 0}}function Fe(t,e,s){return t.children===void 0?t:t.id===e?Ot(t,s):{...t,children:t.children.map(n=>Fe(n,e,s))}}function Ge(t,e,s,n,r){if(t[s]===e)return[t[r]];if(t[n])for(let a=0;a<t[n].length;a++){const o=Ge(t[n][a],e,s,n,r);if(o)return o.unshift(t[r]),o}return null}function Dt(t,e,s,n,r){const a=Ge(t,e,s,n,r);return a?a.join("."):null}function He({isOpen:t,onOpenChange:e,className:s,style:n,value:r,placement:a,children:o}){return i.jsx(A.Popup,{handler:i.jsx("div",{className:`di color-picker-popper ${s||""}`,style:n,children:i.jsx("div",{className:"trigger",style:{...n,backgroundColor:r}})}),open:t,onOpenChange:e,placement:a,children:i.jsx("div",{className:"color-picker-box",children:i.jsx("div",{className:"content",children:o})})})}function Ye({value:t,isOpen:e,onOpenStateChange:s,direction:n,colors:r,onPick:a,pickerStyle:o,pickerClassName:l,inline:c=!0,className:u,style:d}){const[h,g]=p.useState(!1),f=i.jsx("div",{className:P("di color-picker grid-color-picker clearfix",l),style:o,children:r.map(m=>i.jsx("div",{onClick:()=>{a(m)},className:`color ${m===t?"selected":""}`,style:{background:m}},m))});return c?f:i.jsx(He,{className:u,style:d,value:t,isOpen:e??h,onOpenChange:s??g,placement:n,children:f})}const Se=(t,e,s)=>t.length?e.test(t):!s,me=class me extends Z.Component{constructor(){super(...arguments),this.handleChange=e=>{const{value:s}=e.target,{pattern:n,required:r,onChange:a}=this.props,o=Se(s,n,r);a(s,o)}}render(){const{style:e,invalidStyle:s,value:n,...r}=this.props,{pattern:a,required:o,...l}=r;return i.jsx("input",{...l,value:n,onChange:this.handleChange,style:Se(n,a,o)?e:{...e,...s},type:"text"})}};me.defaultProps={required:!1};let Q=me;function be({value:t,pattern:e,onChange:s,placeholder:n,style:r}){const[a,o]=p.useState(t);function l(c,u){o(c),u&&s(c)}return p.useEffect(()=>{o(t)},[t]),i.jsx(Q,{value:a,onChange:l,pattern:e,invalidStyle:{borderColor:"red"},placeholder:n,required:!0,style:r})}const Pt=/^#([A-Fa-f0-9]{6})$/,Lt=/^rgb\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)$/,Ue=t=>ue.parse(t).splice(0,3),Vt=t=>t&&t.length>6?ue.convert.rgb.hex(Ue(t)):"",Bt=t=>t?ue.convert.rgb.string(Ue(t)):"";function Ft({onOpenStateChange:t,onPick:e,allowTextInput:s,className:n,direction:r,inline:a=!0,isOpen:o,opacitySlider:l,pickerClassName:c,pickerStyle:u,style:d,value:h}){const[g,f]=p.useState(!1),m=Vt(h),x=Bt(h),y=h===m?te.HexColorPicker:l&&!s?te.RgbaStringColorPicker:te.RgbStringColorPicker,v=i.jsxs("div",{className:P("di gradient-color-picker",{"with-textfield":s},c),style:u,children:[i.jsx(y,{color:h,onChange:e}),s&&i.jsxs("div",{className:"inputs",children:[i.jsx(be,{value:m,onChange:e,pattern:Pt,placeholder:"#FF00FF",style:{width:60}}),i.jsx(be,{value:x,onChange:e,pattern:Lt,placeholder:"rgb(255,0,255)",style:{width:115}})]})]});return a?v:i.jsx(He,{className:n,style:d,value:h,isOpen:o??g,onOpenChange:t??f,placement:r,children:v})}const Gt=["en","en-gb","en-ca","de","de-at","de-ch","it","ja"];function ye(t){return Gt.includes(t)}S.extend(Oe);S.extend(Te);S.extend(it);S.extend(rt);S.extend(at);function Ht(t){const[e,s]=t.split("-");let n;e&&s?n=se[`${e}${s}`]??se[e]:e?n=se[e]:n=null,n&&J.registerLocale(t,n)}async function Yt(t){let e=null;const[s]=t.split("-");ye(t.toLowerCase())?e=t.toLowerCase():ye(s.toLowerCase())&&(e=s.toLowerCase()),e&&S.locale(e)}function je(t,e){return t==null||t===""?!0:typeof t=="number"?!isNaN(t):typeof t=="string"?S(t,e,!0).isValid():!1}function ne(t,e,s){return typeof t=="number"&&!Number.isNaN(t)?new Date(t):typeof t=="string"&&S(t,e,!0).isValid()?S.tz(t,e,s).toDate():null}function Ut(t,e,s){return typeof t=="number"?S.tz(t,s):typeof t=="string"&&S(t,e,!0).isValid()?S.tz(t,e,s):null}const he=p.forwardRef(({value:t,clearable:e,inline:s,readOnly:n,wrapperClassName:r,onChange:a,locale:o,timezone:l,...c},u)=>{const[d,h]=p.useState(S.localeData().longDateFormat("L")),{t:g}=V(),[f,m]=p.useState(!1),[x,y]=p.useState(!1),[v,j]=p.useState(""),w=p.useMemo(()=>T.debounce(y,30),[]);p.useEffect(()=>{const b=o??z.language;b&&(Ht(b),Yt(b).then(()=>h(S.localeData().longDateFormat("L"))))},[o]);const I=p.useCallback(b=>b==null||b==""?"":je(b,d)?typeof b=="number"?S.tz(b,l).format(d):b:g("dateInput.invalidDate",{defaultValue:"invalid date"}),[d,g,l]);p.useEffect(()=>{t==null?j(""):j(I(t))},[I,t]),p.useEffect(()=>{m(je(t,d))},[d,t]),p.useEffect(()=>{S.locale(o??z.language),h(S.localeData().longDateFormat("L"))},[o]);const N=b=>{if(j(b),b){const k=S(b,d,!0).isValid();if(k){const H=Ut(t,d,l),Y=S.tz(b,d,l??S.tz.guess());H&&(Y.set("hour",H.hour()),Y.set("minute",H.minute()),Y.set("second",H.second()),Y.set("millisecond",H.millisecond())),a(Y.valueOf(),!0)}m(k)}else a(null,!0),m(!0)},R=b=>{a(b?b.valueOf():null),j(I(b?b.getTime():null)),y(!1)},M=()=>N("");return s?i.jsx(J,{...c,onChange:R,selected:ne(t,d,l),locale:o??z.language,isClearable:e,placeholderText:d,className:P("date",{invalid:!f}),inline:!0}):n?i.jsx(J,{...c,onChange:()=>{},selected:ne(t,d,l),locale:o??z.language,customInput:i.jsx("span",{children:i.jsx("input",{type:"text",value:I(t),readOnly:!0})}),placeholderText:d,readOnly:!0}):i.jsx(A.Popup,{handler:i.jsxs("span",{className:"di date-input-wrapper",children:[i.jsx("input",{ref:u,"data-testid":"date-input",className:P("date",{invalid:!f}),onChange:b=>N(b.target.value),value:v,placeholder:d,onBlur:()=>{N(I(t)),w(!1)}}),e&&i.jsx(A.Button,{naked:!0,small:!0,onClick:M,children:i.jsx(A.Icon,{del:!0})})]}),mode:["click","focus"],className:"date-input",handlerWrapperClassName:r,open:x,onOpenChange:y,children:i.jsx("div",{className:"di date-picker-popup-wrapper",tabIndex:0,onFocus:()=>{w(!0)},children:i.jsx(J,{...c,selected:ne(t,d,l),onChange:R,locale:o??z.language,isClearable:e,placeholderText:d,className:P("date",{invalid:!f}),inline:!0})})})});class Wt extends Z.Component{constructor(){super(...arguments),this.state={editMode:!1},this.handleEdit=()=>this.setState({editMode:!0}),this.handleChangeValue=e=>this.props.onChange(e.target.value)}render(){const{editMode:e}=this.state,{value:s}=this.props;return e?i.jsx("input",{value:s,onChange:this.handleChangeValue,autoCorrect:"off",spellCheck:"false",autoComplete:"off"}):i.jsxs("span",{children:[i.jsx("span",{style:{marginRight:10},children:s}),i.jsx(A.Button,{small:!0,onClick:this.handleEdit,children:i.jsx(A.Icon,{edit:!0})})]})}}function Zt({title:t,message:e,onAccept:s,onCancel:n,inputPlaceholder:r,cancelButtonLabel:a,acceptButtonLabel:o}){const{t:l}=V(),c=p.useRef(null),[u,d]=p.useState("");return p.useEffect(()=>{c.current?.focus()}),i.jsx(A.Modal,{header:l(t.id,{defaultValue:t.defaultValue}),content:i.jsx("div",{className:"di form",children:i.jsxs("div",{className:"field",children:[i.jsx("label",{children:i.jsx(C,{i18nKey:e.id,children:e.defaultValue})}),i.jsx("input",{type:"text",style:{width:250},ref:c,placeholder:r?l(r.id,{defaultValue:r.defaultValue}):void 0,onChange:h=>d(h.target.value)})]})}),footer:i.jsxs("div",{children:[i.jsx(A.Button,{primary:!0,onClick:()=>{s(u)},disabled:!u.length,children:o?i.jsx(C,{i18nKey:o.id,children:o.defaultValue}):i.jsx(C,{i18nKey:"form.accept",children:"Accept"})}),i.jsx(A.Button,{onClick:n,children:a?i.jsx(C,{i18nKey:a.id,children:a.defaultValue}):i.jsx(C,{i18nKey:"form.cancel",children:"Cancel"})})]}),width:600})}function zt(t){return class extends Z.Component{constructor(){super(...arguments),this.state={show:!1},this.prompt=(s,n,r,a,o)=>new Promise(l=>{this.setState({show:!0,promptElement:i.jsx(Zt,{title:s,message:n,onAccept:c=>{this.setState({show:!1}),l(c)},onCancel:()=>{this.setState({show:!1})},inputPlaceholder:r,acceptButtonLabel:a,cancelButtonLabel:o},"1")})})}render(){return[p.createElement(t,{...this.props,prompt:this.prompt,key:"0"}),this.state.show?this.state.promptElement:null]}}}const Ce=t=>!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey);function qt({to:t,confirm:e,className:s,title:n,children:r,keyboardShortcut:a,...o}){const l=O.useHistory(),{t:c}=V(),u=p.useCallback(()=>{e?e().then(f=>l.push(f||t)).catch(()=>{}):l.push(t)},[e,l,t]),d=p.useCallback(f=>{a&&f.key===a&&!Ce(f)&&f.target.tagName&&!["INPUT","SELECT","TEXTAREA"].includes(f.target.tagName)&&(f.preventDefault(),u())},[a,u]);p.useEffect(()=>{if(a)return window.addEventListener("keydown",d),()=>{window.removeEventListener("keydown",d)}},[a,d]);const h=f=>{f.button===0&&!Ce(f)&&(f.preventDefault(),u())},g=l.createHref(typeof t=="string"?{pathname:t}:t);return i.jsx("a",{href:g,onClick:h,className:`di route-link ${s||""}`,title:n?c(n.id,{defaultValue:n.defaultValue}):void 0,...o,children:r})}const Qt={info:"#ffffff",success:"#cce0cc",warning:"#fed254",error:"#d66961"};function $t({type:t="info",hideable:e=!1,className:s,icon:n,message:r,children:a}){const[o,l]=p.useState(!0),{t:c}=V();function u(){if(typeof r!="string"){const{id:h,defaultValue:g,...f}=r;return c(h,{...f,defaultValue:g})}return r}const d=u();return o?i.jsxs("div",{className:`infobox ${s||""}`,children:[i.jsxs("div",{className:"infobox-header",style:{backgroundColor:Qt[t]},children:[i.jsxs("div",{className:"infobox-header-content",children:[n&&i.jsx("div",{className:"infobox-iconcontainer",children:i.jsx("img",{src:n,alt:"info-icon",style:{width:16,height:16}})}),i.jsx("div",{className:"infobox-message",children:d})]}),e&&i.jsx("button",{className:"infobox-closebutton",onClick:()=>l(!1),children:i.jsx(A.Icon,{del:!0,large:!0})})]}),a]}):null}const oe=Object.freeze({Translate:{toString(t){if(!t)return;const{x:e,y:s}=t;return"translate3d("+(e?Math.round(e):0)+"px, "+(s?Math.round(s):0)+"px, 0)"}},Scale:{toString(t){if(!t)return;const{scaleX:e,scaleY:s}=t;return"scaleX("+e+") scaleY("+s+")"}},Transform:{toString(t){if(t)return[oe.Translate.toString(t),oe.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:s,easing:n}=t;return e+" "+s+"ms "+n}}});function ie(t,e){const s=t.endsWith("/")?"":"/";return`${t}${s}${e}`}const Jt=({id:t,to:e,className:s,title:n,children:r,draggingDisabled:a})=>{const{attributes:o,listeners:l,setNodeRef:c,transform:u,transition:d}=K.useSortable({id:t,disabled:a,strategy:K.horizontalListSortingStrategy}),h={transform:u?oe.Transform.toString({...u,scaleX:1}):void 0,transition:d},{pathname:g}=O.useLocation();return g.endsWith(e.toString())?i.jsx("button",{"data-testid":"tab-button",className:P("tab-header item active",s),title:n,ref:c,style:h,type:"button",...o,...l,children:r}):i.jsx(O.Link,{"data-testid":"tab-button",to:e,title:n,className:P("tab-header item",s),ref:c,style:h,...o,...l,children:r})};function Kt({pages:t,onOrderChange:e,basePath:s,...n}){const[r,a]=p.useState(!1),{pathname:o,state:l}=O.useLocation();function c(){const d=o.split("/").reverse()[0];return t.some(h=>h.path===d)?o.substring(0,o.lastIndexOf("/")):o}function u(d){a(!1);const{active:h,over:g}=d;if(h.id!==g?.id&&e){const f=t.findIndex(x=>x.path===h.id),m=t.findIndex(x=>x.path===g?.id);e(f,m)}}return i.jsxs("div",{className:r?"draggable-area":"",children:[i.jsx(xe.DndContext,{collisionDetection:xe.closestCenter,onDragEnd:u,onDragStart:()=>a(!0),modifiers:[lt.restrictToHorizontalAxis],children:i.jsx("div",{className:"di tabs",children:i.jsx(K.SortableContext,{items:t.map(d=>({...d,id:d.path})),strategy:K.horizontalListSortingStrategy,children:t.map(({path:d,renderHeading:h,headingTitle:g,draggingDisabled:f,disabled:m})=>i.jsx(Jt,{id:d,to:ie(s||c(),d),title:g,draggingDisabled:m||f||!e||!r&&!o.endsWith(d),children:h(n)},d))})})}),i.jsxs(O.Switch,{children:[t.map(({renderBody:d,path:h})=>i.jsx(O.Route,{path:ie(s||c(),h),render:()=>d(n)},h)),i.jsx(O.Route,{children:i.jsx(O.Redirect,{to:{pathname:ie(s||c(),t[0].path),state:l}})})]})]})}const Xt="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAMZJREFUeNpi/P//PwMtARMDjcHQt4ABGgchQPwKxMWBzwKxKFlmQy14g8dwGL5MqiXIFvynEgb5VJmWFoDwImQLWNB8pQ/EjyiM1j/IHHQLPgHxB3ok00dUCKpnuCzQAmJZKjh+Jy4L3KkUOjgtcKNG/gXi3cg5GRZuGkD8jQrhfwpmNroPbIGYkwo+2IErFXlQKfx3oRd2MK99oELwfIDlL+Qgegul+ang+u0ouRnqg0ACxTWx+CIQKyGbzThaJw+4BQABBgBH38BkTQm7ZwAAAABJRU5ErkJggg==",_t="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAGpJREFUeNpi/P//PwMtARMDjcHQt4ABFAfQeAgH4jcgIRy4gyxzkSzAZzjJlmCz4D+VMMih4TBzGWHJlJGRkZrp9S3QXBGwuTSyAOR6xtF8MGrBqAUDYMFbahYV5BTXlBV2o5E8YBYABBgAxQJ9mxTaZMQAAAAASUVORK5CYII=",es="data:image/svg+xml,%3csvg%20version='1.1'%20id='Layer_1'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20x='0px'%20y='0px'%20width='24px'%20height='24px'%20viewBox='0%200%2024%2024'%20style='enable-background:new%200%200%2050%2050;'%20xml:space='preserve'%3e%3crect%20x='0'%20y='0'%20width='5'%20height='10'%20fill='%23000'%3e%3canimateTransform%20attributeType='xml'%20attributeName='transform'%20type='translate'%20values='0%200;%200%2014;%200%200'%20begin='0'%20dur='0.6s'%20repeatCount='indefinite'%20/%3e%3c/rect%3e%3crect%20x='9'%20y='0'%20width='5'%20height='10'%20fill='%23000'%3e%3canimateTransform%20attributeType='xml'%20attributeName='transform'%20type='translate'%20values='0%200;%200%2014;%200%200'%20begin='0.2s'%20dur='0.6s'%20repeatCount='indefinite'%20/%3e%3c/rect%3e%3crect%20x='19'%20y='0'%20width='5'%20height='10'%20fill='%23000'%3e%3canimateTransform%20attributeType='xml'%20attributeName='transform'%20type='translate'%20values='0%200;%200%2014;%200%200'%20begin='0.4s'%20dur='0.6s'%20repeatCount='indefinite'%20/%3e%3c/rect%3e%3c/svg%3e",ts="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyZpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMTM4IDc5LjE1OTgyNCwgMjAxNi8wOS8xNC0wMTowOTowMSAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENDIDIwMTcgKFdpbmRvd3MpIiB4bXBNTTpJbnN0YW5jZUlEPSJ4bXAuaWlkOjIwNDI3RTg2NEQxQjExRTc4OEM3RTkwQjYwNjA2OTk5IiB4bXBNTTpEb2N1bWVudElEPSJ4bXAuZGlkOjIwNDI3RTg3NEQxQjExRTc4OEM3RTkwQjYwNjA2OTk5Ij4gPHhtcE1NOkRlcml2ZWRGcm9tIHN0UmVmOmluc3RhbmNlSUQ9InhtcC5paWQ6MjA0MjdFODQ0RDFCMTFFNzg4QzdFOTBCNjA2MDY5OTkiIHN0UmVmOmRvY3VtZW50SUQ9InhtcC5kaWQ6MjA0MjdFODU0RDFCMTFFNzg4QzdFOTBCNjA2MDY5OTkiLz4gPC9yZGY6RGVzY3JpcHRpb24+IDwvcmRmOlJERj4gPC94OnhtcG1ldGE+IDw/eHBhY2tldCBlbmQ9InIiPz5FrZPxAAAA5UlEQVR42qzTvQ7BUBTA8UpEYraJWAwSNVgMHsDIZvUEngWDisTiBTyA4A3EJEiMYrBJGBBf/yO3UlVNq07y63Cbc3rvuaea9hkZ1LHAUZmrtYzmEhG0cMX9C3nXQdQpeeiSaDdSOa8wfCSbWmayjssPBSRHD/EoqzMtscEeN8SQQwVVhB361pRHDX1VYGf5whZjlJDHymEXclPaycN2e4hjYFs/eS0gJkiibVmT4z634bVxaxRQxBQzKdDw2X0Zpi7SSEiBbIBrTAUZJOOvoxz4Z7KGriZMBuuMg+p2U/XrLR4CDACHu7RW+98pzwAAAABJRU5ErkJggg==";var D=(t=>(t.ALL="all",t.SOME="some",t.NONE="none",t))(D||{});const ss=({lastChild:t})=>i.jsxs("div",{className:"skeleton",children:[i.jsx("div",{className:"skeleton-cell top"}),i.jsx("div",{className:"skeleton-cell bottom",style:{visibility:t?"hidden":"initial"}})]}),ns=({node:t,leafNode:e,expanded:s,isLoading:n,onExpand:r})=>{let a;return e?a=t.image||ts:n?a=es:s?a=t.expandedImage||Xt:a=t.closedImage||_t,i.jsx("div",{className:"icon-container",children:i.jsx("img",{src:a,alt:"node",onClick:r})})};class is extends Z.PureComponent{constructor(){super(...arguments),this.onSelect=e=>{const{onSelect:s,selectionState:n}=this.props;s(n===D.SOME?!1:e.currentTarget.checked)},this.onLabelClick=()=>{const{onSelect:e,selectionState:s}=this.props;e(s===D.SOME?!1:this.inputRef?!this.inputRef.checked:!1)}}componentDidMount(){this.updateSelectionState()}componentDidUpdate(){this.updateSelectionState()}updateSelectionState(){const{selectionState:e}=this.props;this.inputRef&&(this.inputRef.indeterminate=e===D.SOME)}render(){const{node:e,node:{name:s},leafNode:n,expanded:r,isLastChild:a,onExpand:o,selectionState:l,isLoading:c}=this.props,u=l===D.ALL;return i.jsxs("div",{className:`node-info ${u?"selected":""}`,children:[a!==void 0&&i.jsx(ss,{lastChild:a}),i.jsx(ns,{node:e,leafNode:n,expanded:r,isLoading:c,onExpand:o}),i.jsx("input",{ref:d=>{this.inputRef=d},type:"checkbox",checked:l===D.ALL,onChange:this.onSelect}),i.jsx("div",{className:"name",onClick:this.onLabelClick,children:s})]})}}class pe extends p.Component{constructor(){super(...arguments),this.state={expanded:!1,selectionState:this.getSelectionState(),isLoading:!1},this.toggleExpand=()=>{const{node:e,lazyLoadingFunction:s}=this.props;e.lazyLoadable?this.setState({isLoading:!0},()=>{s(e).then(()=>this.setState({expanded:!0,isLoading:!1}))}):this.setState({expanded:!this.state.expanded})},this.onSelect=e=>{const{node:s,selectNodes:n,deselectNodes:r,selectedNodes:a}=this.props;if(e){const o=X(s).filter(l=>!a.includes(l.id));n(o)}else{const o=X(s).filter(l=>a.includes(l.id));r(o)}}}shouldComponentUpdate(e,s){const{selectedNodes:n,treeSize:r}=e,{expanded:a,selectionState:o,isLoading:l}=s,{selectedNodes:c,node:u,treeSize:d}=this.props,{expanded:h,selectionState:g,isLoading:f}=this.state;return l!==f||r!==d?!0:this.isLeaf()?n.includes(u.id)&&!c.includes(u.id)||!n.includes(u.id)&&c.includes(u.id)||o!==g:n.length!==c.length||a!==h||o!==g}componentDidMount(){this.setState({selectionState:this.getSelectionState()})}componentDidUpdate(){this.setState({selectionState:this.getSelectionState()})}isLeaf(){const{node:e}=this.props;return e.children===void 0}getSelectionState(){const{node:e,selectedNodes:s}=this.props;if(this.isLeaf())return s.includes(e.id)?D.ALL:D.NONE;{const n=Mt(e),r=Et(n,s);return r.length===n.length&&n.length!==0?D.ALL:r.length===0?D.NONE:D.SOME}}render(){const{node:e,isLastChild:s,...n}=this.props,{expanded:r,selectionState:a,isLoading:o}=this.state;return i.jsxs("div",{className:"node",children:[i.jsx(is,{node:e,displayName:e.name,leafNode:this.isLeaf(),expanded:r,isLastChild:s,onExpand:this.toggleExpand,onSelect:this.onSelect,isLoading:o,selectionState:a}),r&&e.children&&e.children.map((l,c)=>p.createElement(pe,{...n,key:c,node:l,isLastChild:c===(e.children||[]).length-1}))]})}}class rs extends p.Component{constructor(){super(...arguments),this.state={treeData:this.props.treeData,tree:{id:"virtualRootNode",name:"",children:[],path:"/",originalNode:{}},treeSize:0,selectedNodes:this.props.selectedNodes||[]},this.convert=Tt(this.props.dataSetConfig),this.selectNodes=e=>{const{onSelect:s}=this.props,{selectedNodes:n}=this.state;this.setState({selectedNodes:kt(n,e.map(({id:r})=>r))}),s(e.map(({originalNode:r,path:a})=>({...r,$$path:a})))},this.deselectNodes=e=>{const{onDeselect:s}=this.props,{selectedNodes:n}=this.state;this.setState({selectedNodes:Rt(n,e.map(({id:r})=>r))}),s(e.map(({originalNode:r,path:a})=>({...r,$$path:a})))},this.addTreeData=(e,s)=>{const{tree:n}=this.state,r=this.convert(e,s.path),a={id:"virtualRootNode",name:"",children:(n.children||[]).map(l=>Fe(l,s.id,{lazyLoadable:!1,children:r})),path:"/",originalNode:{}},o=ae(a);this.setState({tree:a,treeSize:o})},this.lazyLoadingFunction=e=>{const{lazyLoadingFunction:s}=this.props;return s?s(e.originalNode).then(n=>{this.addTreeData(n,e)}).catch(()=>Promise.resolve()):Promise.resolve()}}componentDidMount(){const{treeData:e}=this.props,s=this.initTree(e),n=ae(s);this.setState({tree:s,treeSize:n})}componentDidUpdate(e){const{selectedNodes:s}=e,{selectedNodes:n}=this.props;n&&s&&s.length!==n.length&&this.setState({selectedNodes:n})}initTree(e){return{id:"virtualRootNode",name:"",children:this.convert(e),path:"/",originalNode:{}}}render(){const{tree:e,selectedNodes:s,treeSize:n}=this.state;return i.jsx("div",{className:"treeview",children:e.children&&e.children.map((r,a)=>i.jsx(pe,{node:r,selectedNodes:s,selectNodes:this.selectNodes,deselectNodes:this.deselectNodes,treeSize:n,lazyLoadingFunction:this.lazyLoadingFunction},a))})}}const as="data:image/svg+xml,%3csvg%20id='Layer_1'%20data-name='Layer%201'%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2016%2016'%3e%3ccircle%20cx='7.5'%20cy='3.5'%20r='1.5'/%3e%3ccircle%20cx='7.5'%20cy='7.5'%20r='1.5'/%3e%3ccircle%20cx='7.5'%20cy='11.5'%20r='1.5'/%3e%3c/svg%3e",We=Z.createContext({toggleMenu:()=>{}});function Ze({menuButton:t,children:e,direction:s,className:n,open:r,onOpenChange:a}){const[o,l]=p.useState(!1),c=()=>{l(!o)};return i.jsx("span",{children:i.jsx(A.Popup,{open:r??o,onOpenChange:a??l,handler:t,placement:s,className:n,children:i.jsx("div",{className:"di multimenu",children:i.jsx("div",{className:`drop ${s||"bottom"} ${o?"show":""}`,children:i.jsx(We.Provider,{value:{toggleMenu:c},children:e})})})})})}const os=[5,10,15,20,50];function ze({onChangePage:t,page:e,totalPages:s,onChangeSize:n,size:r}){const a=p.useRef(null),{current:o}=a,[l,c]=p.useState(`${e+1}`),[u,d]=p.useState(!1);p.useEffect(()=>{a.current=T.debounce(t,500)},[t]),p.useEffect(()=>{c(`${e+1}`)},[e]);function h(){t(0)}function g(){e>0&&t(e-1)}function f(){e<s-1&&t(e+1)}function m(){t(s-1)}function x(w){if(n){const I=parseInt(w.target.value,10);n(I),d(!1)}}function y(w){const I=w.target.value;if(I.trim()===""){c(I);return}const N=Number(w.target.value);!Number.isNaN(N)&&N>=1&&N<=s&&(o?.(N-1),c(I))}function v(){c(`${e+1}`)}const j=e>=s-1;return i.jsx("div",{className:"di pagination-holder",children:i.jsxs("div",{className:"di pagination",children:[i.jsx("span",{className:`prev ${e===0?"disabled":""}`,onClick:h,children:"«"}),i.jsx("span",{className:`prev ${e===0?"disabled":""}`,onClick:g,children:"‹"}),i.jsxs("span",{className:"info",children:[i.jsx(C,{i18nKey:"reactable.pagination.page",children:"Page"}),i.jsx("input",{value:l,onChange:y,onBlur:v}),typeof process<"u"&&process?.env?.STORYBOOK_MODE?i.jsxs(i.Fragment,{children:["of ",s]}):i.jsxs(C,{i18nKey:"reactable.pagination.ofTotal",children:[" of ",{totalPages:s}]})]}),i.jsx("span",{className:`next ${j?"disabled":""}`,onClick:f,children:"›"}),i.jsx("span",{className:`next ${j?"disabled":""}`,onClick:m,children:"»"}),n&&i.jsx("div",{className:"options",children:i.jsx(Ze,{direction:"left",open:u,onOpenChange:d,menuButton:i.jsx(A.Button,{naked:!0,title:{id:"trend.settings.buttonTitle",defaultValue:"Settings"},children:i.jsx("img",{src:as,alt:"settings icon",style:{width:16,height:16}})}),children:i.jsxs("div",{className:"di form",style:{width:200,padding:10},children:[i.jsxs("div",{className:"field",children:[i.jsx("label",{children:i.jsx(C,{i18nKey:"reactable.pagination.entriesPerPage",children:"Entries per page"})}),i.jsx("select",{onChange:x,value:r,children:os.map(w=>i.jsx("option",{value:w,children:w},w))})]}),i.jsx("p",{children:i.jsx(C,{i18nKey:"reactable.pagination.changePageWillBeStored",children:"Your changes will be stored for view."})})]})})})]})})}const ls=t=>t.filterable?.initialValue??"",cs=({columnDef:t,changeFilter:e})=>{const{t:s}=V(),[n,r]=p.useState(ls(t)),a=o=>{const l=o.target.value;r(l),e(t.name,l)};return i.jsx("input",{type:"text",placeholder:s(`${t.filterable?.placeholder??"reactable.filter.placeholder"}`,{defaultValue:"Filter..."}),onChange:a,value:n})};function ds(t,e,s){if(!t)return null;const{page:n,size:r,sort:a}=e;return{content:(s?s(t,a,Ae):Ae(t,a)).slice(n*r,(n+1)*r),totalElements:t.length,totalPages:Math.ceil(t.length/r),number:n,size:r,sort:[a]}}const us=(t,e)=>t==="text"?(s,n)=>s[e]&&s[e].toString().toLowerCase().includes(n.toLowerCase()):(s,n)=>s[e]===n;function we(t,e,s){return t?t.filter(n=>Object.keys(s).every(r=>{const a=s[r];if(a&&a.length>0){const o=hs(r,e);return o.filterable?(o.filterable.filterFn||us(o.filterable.filterType,o.name))(n,a):!1}return!0})):null}function hs(t,e){const s=e.find(n=>n.name===t);if(!s)throw Error(`column definition not found for ${t}`);return s}function Ae(t,e){return t.sort((s,n)=>{const r=typeof s=="object"&&s?.[e.property]||0,a=typeof n=="object"&&n?.[e.property]||0,o=e.direction==="ASC"?1:-1;return r===a?0:typeof r=="string"&&typeof a=="string"?r.localeCompare(a)*o:typeof r=="number"&&typeof a=="number"?(r-a)*o:r.toString().localeCompare(a.toString())*o})}function ps(t,e,s,n,r,a){return[{name:"checkbox",label:i.jsx(A.Checkbox,{value:n,onChange:s,title:{id:"components.filtertable.selectAllItems",defaultValue:"Select/deselect all items in search result"}}),sortable:!1,render:o=>i.jsx(A.Checkbox,{value:r.includes(a(o)),onChange:l=>e(l,o)}),width:"1%"},...t]}function fe(t,e){return`${t||"unnamedTable"}-${e}`}function fs(t,e){if(!e)return T.orderBy(t,"label","asc");if(t.every(s=>!s.options))return[...t].sort(e);if(t.every(s=>s.options))return t.map(n=>({...n,options:[...n.options].sort(e)}));throw new Error("Mixing groups with single options not allowed")}class qe extends p.Component{constructor(){super(...arguments),this.state={options:[],inputValue:null},this.selectRef=p.createRef(),this.portalRoot=null,this.updateOptions=()=>{const{options:e,specialOptions:s,compareOptions:n}=this.props,r=fs(e,n);s?this.setState({options:[...r,...s]}):this.setState({options:r})},this.filterOption=(e,s)=>e.label.toString().toLowerCase().startsWith(s.toLowerCase()),this.getContainerClasses=()=>{const{specialOptions:e}=this.props;return e?["select-search-container","special"]:["select-search-container"]}}componentDidMount(){if(this.updateOptions(),this.props["data-testid"]&&this.selectRef&&this.selectRef.current&&this.selectRef.current.controlRef.setAttribute("data-testid",this.props["data-testid"]),this.props.menuPortalTarget){this.portalRoot=document.createElement("div");const e=this.getContainerClasses();this.portalRoot.classList.add(...e),this.props.menuPortalTarget.appendChild(this.portalRoot)}}componentDidUpdate(e){(!T.isEqual(e.options,this.props.options)||e.freeForm!==this.props.freeForm)&&this.updateOptions()}componentWillUnmount(){this.props.menuPortalTarget&&this.portalRoot&&this.props.menuPortalTarget.removeChild(this.portalRoot)}render(){const{noResultsMessage:e,placeholder:s,value:n,onChange:r,clearable:a,loading:o,disabled:l}=this.props,{options:c}=this.state;return i.jsx(ct,{ref:this.selectRef,joinValues:!0,name:"form-field-name",className:this.getContainerClasses().join(" "),classNamePrefix:"select-search",isClearable:a,noOptionsMessage:e?()=>e:void 0,options:c,value:n||null,onChange:r,onInputChange:u=>{this.props.freeForm&&u&&this.setState({inputValue:u})},placeholder:s,filterOption:this.filterOption,isLoading:o,menuPortalTarget:this.portalRoot,isDisabled:l,onBlur:()=>{this.props.freeForm&&this.state.inputValue!==null&&(this.setState({options:this.props.options}),this.setState({inputValue:this.state.inputValue},()=>{const u={type:"item",value:this.state.inputValue,label:this.state.inputValue};this.setState(d=>({options:[u,...d.options]})),this.state.inputValue=null,r(u)}))}})}}const gs=({columnDefs:t,onFilter:e,tableName:s})=>{const{t:n}=V(),[r,a]=p.useState({}),o=p.useRef(e);p.useEffect(()=>{o.current=e},[e]),p.useEffect(()=>{a(h=>{const g={};for(const v of t)g[v.name]=h[v.name]!==void 0?h[v.name]:v.filterable?.initialValue??"";const f=Object.keys(h),m=Object.keys(g),x=m.length===f.length&&m.every(v=>f.includes(v)),y=x&&m.every(v=>g[v]===h[v]);return x&&y?h:(Object.values(g).some(v=>v)&&o.current(g),g)})},[t]);const l=(h,g)=>{const f={...r,[h]:g};a(f),e(f)},c=h=>{if(h.filterable)switch(h.filterable.filterType){case"text":return u(h);case"options":return d(h);default:throw new Error(`Filter type ${h.filterable.filterType} not supported`)}return null},u=h=>i.jsx(cs,{columnDef:h,changeFilter:l}),d=h=>{if(!h.filterable?.filterOptions)throw new Error(`No filterOptions found for column type: options on columnDef: ${h.name}`);const g=h.filterable.filterOptions;if(h.filterable.searchableOptions){const f=g.map(x=>({type:"item",label:typeof x.label=="string"?x.label:n(x.label.id,{defaultValue:x.label.defaultValue}),value:x.value})),m=r[h.name];return i.jsx(qe,{options:f,onChange:x=>{l(h.name,x?.value)},value:m?f.find(x=>x.value===m.toString()):null,clearable:!0})}else return i.jsxs("select",{onChange:f=>{l(h.name,f.target.value)},value:r[h.name],children:[i.jsx("option",{value:"",children:n("reactable.filter.all",{defaultValue:"- All -"})},""),g.map(f=>i.jsx("option",{className:fe(s,h.name),value:f.value,children:typeof f.label=="string"?f.label:n(f.label.id,{defaultValue:f.label.defaultValue})},f.value))]})};return i.jsx("tr",{className:"di filterrow form",children:t.map(h=>i.jsx("td",{style:{textAlign:h.align||"left"},children:c(h)},h.name))})},ms=t=>t==="ASC"?"DESC":"ASC";class xs extends p.Component{constructor(){super(...arguments),this.handleSort=e=>{const{paginationSettings:s,onSort:n}=this.props,r=e.name===s.sort.property?ms(s.sort.direction):e.defaultSortDirection||"ASC";n(e.name,r)},this.getClassName=e=>{const{paginationSettings:s,tableName:n}=this.props,r=fe(n,e.name);return e.sortable?e.name===s.sort.property?s.sort.direction==="ASC"?`${r} sortable sortAsc`:`${r} sortable sortDes`:`${r} sortable`:`${r}`},this.printLabel=e=>vs(e)?i.jsx(C,{i18nKey:e.id,children:e.defaultValue}):e}render(){return i.jsx("tr",{children:this.props.columnDefs.map(e=>i.jsx("th",{style:{width:e.width||"auto",textAlign:e.align||"left"},className:this.getClassName(e),onClick:()=>{e.sortable&&this.handleSort(e)},children:this.printLabel(e.label)},e.name))})}}function vs(t){return typeof t=="object"&&t!=null&&"id"in t&&t.id!==void 0}class Ss extends p.Component{constructor(){super(...arguments),this.getRowClass=()=>{const{rowDef:e,item:s}=this.props;return e&&typeof e.getRowClass=="function"?e.getRowClass(s):""},this.handleClick=()=>{const{rowDef:e,item:s}=this.props;e&&typeof e.onClick=="function"&&e.onClick(s)},this.getTooltip=()=>{const{rowDef:e,item:s}=this.props;return e&&typeof e.getTooltip=="function"?e.getTooltip(s):""},this.getRowStyle=()=>{const{rowDef:e,item:s}=this.props;if(e&&e.getRowStyle)return e.getRowStyle(s)}}render(){const{columnDefs:e,item:s,tableName:n}=this.props;return i.jsx("tr",{className:this.getRowClass(),onClick:this.handleClick,title:this.getTooltip(),style:this.getRowStyle(),children:e.map(r=>{const a=r.align||"left",o=r.onClick?"pointer":"inherit",l=r.whiteSpace||void 0,c=r.onClick?()=>r.onClick?r.onClick(s):void 0:void 0;return i.jsx("td",{style:{textAlign:a,cursor:o,whiteSpace:l},onClick:c,className:fe(n,r.name),children:r.render(s)},`${s.id}_${r.name}`)})})}}function bs({columnDefs:t,uniqueItemKey:e,paginationSettings:s,onSort:n,onFilter:r,tableName:a,pageable:o,isLoading:l,rowDef:c,clickable:u,messageWhenEmpty:d,"data-testid":h}){const g=p.useRef(null),f=p.useRef(null),[m,x]=p.useState(!1),[y,v]=p.useState(!0),[j,w]=p.useState(!1),I="uiConfigurations/nevershowscrollingadvice",N="reactable.neverShowScrollingAdvice",R=p.useRef(y);p.useEffect(()=>{R.current=y},[y]);const M=()=>{g.current&&f.current&&x(!R.current&&f.current.scrollWidth>g.current.offsetWidth)};p.useEffect(()=>{setTimeout(()=>{(async()=>{const k=localStorage.getItem(N),H=k!==null;try{const B=await ve.readAccountObject(I)===!0;v(B),R.current=B,localStorage.setItem(N,String(B)),B||M()}catch{if(H){const B=k==="true";v(B),R.current=B,B||M()}else v(!1),R.current=!1,M()}w(!0)})()},0)},[]),p.useEffect(()=>(M(),window.addEventListener("resize",M),()=>window.removeEventListener("resize",M)),[o,t]);const b=t.some(k=>k.filterable);return i.jsx(A.SpinnerContainer,{show:l,children:i.jsxs("div",{ref:g,className:"di reactable scroll-x",children:[j&&m&&!l&&i.jsx(A.Modal,{className:"scroll-horizontally-advice",content:i.jsxs("div",{children:[i.jsx(C,{i18nKey:"reactable.scrollHorizontally.advice",children:"SHIFT + mouse wheel to scroll horizontally"}),i.jsxs("div",{className:"scroll-horizontally-advice-buttons",children:[i.jsx(A.Button,{primary:!0,onClick:async()=>{await ve.writeAccountObject(I,!0),localStorage.setItem(N,"true"),v(!0),R.current=!0,x(!1)},children:i.jsx(C,{i18nKey:"reactable.scrollHorizontally.neverShowAgain",children:"Never show again"})}),i.jsx(A.Button,{onClick:()=>x(!1),children:i.jsx(C,{i18nKey:"reactable.scrollHorizontally.ok",children:"OK"})})]})]}),width:"40%"}),i.jsxs("table",{ref:f,className:P("di reactable sortable hoverable",{selectable:u}),"data-testid":h,children:[i.jsx("thead",{children:i.jsx(xs,{columnDefs:t,paginationSettings:s,onSort:n,tableName:a})}),i.jsxs("tbody",{children:[r&&b&&i.jsx(gs,{columnDefs:t,onFilter:r,tableName:a}),o?.content.length?o.content.slice(0,s.size).map(k=>i.jsx(Ss,{columnDefs:t,item:k,rowDef:c,tableName:a},e(k))):!l&&i.jsx("tr",{children:i.jsx("td",{colSpan:t.length,children:i.jsx(C,{i18nKey:d??"reactable.noEntriesFound",children:"No entries found"})})})]})]})]})})}class Qe extends p.Component{componentDidUpdate(){const{pageable:e,paginationSettings:s,onChangePage:n}=this.props;if(!e)return;const r=e.totalPages||0,a=s.page,o=r>0?Math.min(a,r-1):0;a!==o&&n(o)}render(){const{paginationSettings:e,pageable:s,onChangePage:n,onChangeSize:r}=this.props,a=r?s&&s.totalElements>0:s&&s.totalPages>1;return i.jsxs("div",{children:[i.jsx(bs,{...this.props}),s&&a&&i.jsx(ze,{page:e.page,totalPages:s.totalPages,onChangePage:n,onChangeSize:r,size:e.size})]})}}const Ne={page:0,size:15,sort:{property:"name",direction:"DESC"}};class ys extends p.Component{constructor(e){super(e),this.content=[],this.calculatePageNumber=(n,r)=>{const{forceResetPaginationOnItemsChange:a}=this.props;if(a)this.handleChangePage(0);else{const o=Math.floor((n.length-1)/r.size);o<=0?this.handleChangePage(0):o<r.page&&this.handleChangePage(o)}},this.handleChangePage=n=>{this.setState({paginationSettings:{...this.state.paginationSettings,page:n}})},this.handleSort=(n,r)=>{this.setState({paginationSettings:{...this.state.paginationSettings,sort:{property:n,direction:r}}})},this.handleFilter=n=>{const{items:r,onFilter:a,columnDefs:o,onFilteredItemsChanged:l}=this.props;this.setState({paginationSettings:{...this.state.paginationSettings,page:0},filterSettings:n},()=>{a&&a(n);const c=we(r,o,n);this.setState({filteredItems:c}),c&&l?.(c)})},this.getPageable=()=>{const{customSortFunction:n,items:r,columnDefs:a,onContentChange:o}=this.props,{filterSettings:l,paginationSettings:c}=this.state,u=we(r,a,l),d=ds(u,c,n);return d&&d.content&&!T.isEqual(d.content,this.content)&&(this.content=d.content,o&&o(this.content)),d},this.handleSelectChange=(n,r)=>{const{onSelectedItemsChange:a,selectedItems:o=[],uniqueItemKey:l}=this.props;if(a)if(n){const c=o.concat(l(r));a(c)}else a(o.filter(c=>c!==l(r)));else console.warn("ReactableWithClientSidePagination: onSelectedItemsChange property is missing")},this.handleSelectAllChange=n=>{const{onSelectedItemsChange:r,items:a,selectedItems:o=[],uniqueItemKey:l}=this.props,{filteredItems:c}=this.state,u=(c||a||[]).map(l);r?r(n?T.uniqWith([...o,...u],T.isEqual).sort():T.difference(o,u)):console.warn("ReactableWithClientSidePagination: onSelectedItemsChange property is missing")},this.areSelectedAll=()=>{const{items:n,selectedItems:r,uniqueItemKey:a}=this.props,{filteredItems:o}=this.state;return!!r&&(o||n||[]).every(c=>r.some(u=>u===a(c)))};let s=Ne;e.paginationSettings?s=e.paginationSettings:e.initialPaginationSettings?(console.warn('initialPaginationSettings is deprecated! Please use "paginationSettings" instead'),s=e.initialPaginationSettings):console.error("Missing pagination settings!"),this.state={paginationSettings:s||Ne,filterSettings:{},filteredItems:null}}componentDidUpdate(e){const{items:s}=this.props,{items:n}=e,r=this.props.paginationSettings||this.props.initialPaginationSettings,a=e.paginationSettings||e.initialPaginationSettings;s&&n&&s.length!==n.length&&this.calculatePageNumber(s,this.state.paginationSettings),r&&!T.isEqual(r,a)&&this.setState({paginationSettings:r},()=>this.handleChangePage(0))}render(){const{uniqueItemKey:e,isLoading:s,columnDefs:n,rowDef:r,tableName:a,clickable:o,selectable:l,selectedItems:c,onChangeSize:u}=this.props,d=l?ps(n,this.handleSelectChange,this.handleSelectAllChange,this.areSelectedAll(),c||[],e):n;return i.jsx(Qe,{columnDefs:d,rowDef:r,uniqueItemKey:e,paginationSettings:this.state.paginationSettings,onChangePage:this.handleChangePage,onChangeSize:u,onSort:this.handleSort,onFilter:this.handleFilter,tableName:a,pageable:this.getPageable(),isLoading:s,clickable:o,"data-testid":this.props["data-testid"]})}}const W=class W extends Z.Component{constructor(){super(...arguments),this.state={files:[]},this.handleDrop=(e,s)=>{!this.props.multiple&&e.length>1||s.length>0||setTimeout(()=>this.selectFile(e),100)},this.selectFile=e=>{const{onSelectFile:s,onChange:n}=this.props;e.forEach(a=>{a.preview=URL.createObjectURL(a)});const r=[...this.state.files,...e];this.setState({files:r}),n?.(r),s&&e.forEach(a=>{s(a)})},this.handleRemoveFile=e=>{const{files:s}=this.state;if(e){e.preview&&window.URL.revokeObjectURL(e.preview);const n=s.filter(r=>r!==e);this.setState({files:n}),this.props.onChange?.(n),this.props.onRemoveFile?.(e)}}}render(){const{files:e}=this.state,{accept:s,previewComponent:n,dropHint:r,hoverHint:a,acceptHint:o,rejectHint:l,onChange:c,onRemoveFile:u,onDownloadFile:d,onSelectFile:h,onDropRejected:g,onDropAccepted:f,maxSize:m,multiple:x,...y}=this.props,v=r||W.defaultProps.dropHint,j=a||W.defaultProps.hoverHint,w=o||W.defaultProps.acceptHint,I=l||W.defaultProps.rejectHint;return i.jsxs("div",{...y,className:P("di upload",{clickable:!e.length,hasContent:!!e.length}),children:[!!n&&e.map((N,R)=>i.jsx(n,{file:N,onRemoveFile:()=>this.handleRemoveFile(N),onDownloadFile:d?()=>d(N):void 0},R)),(x||!e.length)&&i.jsx(dt,{accept:s,multiple:x??!1,onDrop:this.handleDrop,onDropRejected:g,onDropAccepted:f,maxSize:m||1/0,children:({getRootProps:N,getInputProps:R,isDragAccept:M,isDragReject:b,isDragActive:k})=>i.jsxs("div",{className:P("drag-drop-text-container",{active:k,accept:M,reject:b}),...N(),children:[i.jsx("input",{...R()}),i.jsx("p",{className:"drag-drop-hint",children:i.jsx(C,{i18nKey:v.id,children:v.defaultValue})}),i.jsx("p",{className:"drag-drop-hover-hint",children:i.jsx(C,{i18nKey:j.id,children:j.defaultValue})}),i.jsx("p",{className:"drag-drop-accept",children:i.jsx(C,{i18nKey:w.id,children:w.defaultValue})}),i.jsx("p",{className:"drag-drop-reject",children:i.jsx(C,{i18nKey:I.id,children:I.defaultValue})})]})})]})}};W.defaultProps={dropHint:{id:"fileUpload.dropHint",defaultValue:"Drop file here, or click to browse ..."},hoverHint:{id:"fileUpload.hoverHint",defaultValue:"Drop file here, or click to browse ..."},acceptHint:{id:"fileUpload.acceptHint",defaultValue:"This file type can be uploaded"},rejectHint:{id:"fileUpload.rejectHint",defaultValue:"This file type cannot be uploaded"}};let _=W;const js=({url:t,imageSize:e,onRemoveFile:s,onDragOver:n,onDownloadFile:r})=>i.jsx("div",{className:"di upload preview-container",onDragOver:n,children:i.jsxs("div",{className:"preview",style:{backgroundImage:`url(${t})`,...e&&{backgroundSize:e}},children:[i.jsx("button",{className:"action-button",onClick:s,"data-testid":"delete-button",children:i.jsx(C,{i18nKey:"imageUpload.remove",children:"Remove"})}),r&&i.jsx("button",{className:"action-button",onClick:r,"data-testid":"download-button",children:i.jsx(C,{i18nKey:"imageUpload.download",children:"Download"})})]})});class Cs extends p.Component{constructor(){super(...arguments),this.state={dragOverPreview:!1,file:null},this.handleDragOver=()=>{this.setState({dragOverPreview:!0})}}componentDidUpdate(e){e.imageUrl!==this.props.imageUrl&&this.setState({dragOverPreview:!1})}render(){const{accept:e,imageUrl:s,imageSize:n,onSelectFile:r,onRemoveFile:a,onDownloadFile:o,...l}=this.props,{dragOverPreview:c,file:u}=this.state;return s&&!c&&u?i.jsx(js,{url:s,imageSize:n,onRemoveFile:()=>a?.(u),onDownloadFile:o?()=>o(u):void 0,onDragOver:this.handleDragOver}):i.jsx(_,{...l,onRemoveFile:d=>{this.setState({file:null}),a?.(d)},onSelectFile:d=>{this.setState({file:d}),r?.(d)},accept:e||{"image/*":[".jpeg",".jpg",".png",".webp"]}})}}const ws="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA3NpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDYuMC1jMDAyIDc5LjE2NDQ2MCwgMjAyMC8wNS8xMi0xNjowNDoxNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtcE1NOk9yaWdpbmFsRG9jdW1lbnRJRD0ieG1wLmRpZDplMjI2NGVmOC0xY2Q1LTgyNDQtOWQ5NS0yZDBjNGMxMmZkM2UiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6MDhENjczMThERTNEMTFFQUIwNjJCODBDQ0RGM0I4QkEiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6MDhENjczMTdERTNEMTFFQUIwNjJCODBDQ0RGM0I4QkEiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIDIxLjIgKFdpbmRvd3MpIj4gPHhtcE1NOkRlcml2ZWRGcm9tIHN0UmVmOmluc3RhbmNlSUQ9InhtcC5paWQ6NTcyODQ4NjktNjA0NC0xZjQ2LTg2OWMtMjBlYzMwMTA0MWE2IiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOmUyMjY0ZWY4LTFjZDUtODI0NC05ZDk1LTJkMGM0YzEyZmQzZSIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PnOjy94AAABySURBVHjapFMJDsAgCFvJ/v/lbkvYEQ4naGIiShtaASS3lSWjRwA8d4/gAutxSLJrsr3/6kKUc0uPKnDgioQS2BKUwY8HBhzFoc+/31ipAF0JkoDY7cQyiWTmzJLADZN2HIwn2dD5Ct5EzBiK1XE+BBgAvZQfJzDjL2UAAAAASUVORK5CYII=",As=({parentPageLink:t,title:e,subPagePathPrefixArray:s,subPagePathPrefix:n,subtitle:r,children:a})=>{const{push:o}=O.useHistory(),{pathname:l}=O.useLocation(),{t:c}=V(),u=()=>{n?o(l.substring(0,l.lastIndexOf(n))):s?s.forEach(h=>{l.includes(h)&&o(l.substring(0,l.lastIndexOf(h)))}):o(l.substring(0,l.lastIndexOf("/")))},d=h=>{if(typeof h=="string")return h;{const{id:g,defaultValue:f}=h;return c(g,{defaultValue:f})}};return i.jsxs("h1",{className:"di header",children:[t&&i.jsx(A.Button,{onClick:u,style:{marginRight:"15px"},children:i.jsx("img",{src:ws,alt:c("general.navigation.goBack",{defaultValue:"Go Back"})})}),i.jsx("span",{children:d(e)}),r&&i.jsx("span",{className:"search-result-count",children:d(r)}),a]})},re=(t,e)=>{try{return S.tz(e,t).format("HH:mm")}catch(s){return console.error("DateTimeInput: Error while extracting time from date",s),"00:00"}},le=p.forwardRef(({timestamp:t,timezone:e,warning:s,readOnly:n=!1,onChange:r,...a},o)=>{const[l,c]=p.useState(re(e,t)),u=l??re(e,t);p.useEffect(()=>{c(re(e,t))},[e,t]);function d(f,m){const x=S.tz(t,e),y=S.tz(f,e).set("hour",x.hour()).set("minute",x.minute()).set("second",x.second()).set("millisecond",x.millisecond());r(y.valueOf(),m)}function h(f,m){if(m){const[x,y]=f.split(":").map(Number),v=S.tz(t,e).set("hours",x).set("minutes",y);r(v.valueOf(),!0)}c(f)}function g(){l&&/^[0-9]:[0-5][0-9]$/.test(l)&&h(l.padStart(5,"0"),!0)}return i.jsxs("span",{className:`di date-time-input ${s?"with-warning":""}`,children:[i.jsx(he,{...a,ref:o,value:t,timezone:e,onChange:d,readOnly:n}),i.jsx(Q,{"data-testid":"time-input",value:u,onChange:h,pattern:/^(([01][0-9])|2[0-3]):[0-5][0-9]$/,required:!0,invalidStyle:{borderColor:"red"},placeholder:"00:00",className:"time",onBlur:g,disabled:n})]})});class Ns extends p.Component{constructor(){super(...arguments),this.state={cache:{},currentItem:null},this.selectRef=p.createRef(),this.transformBackendItemToSelectItem=e=>{const{labelKey:s,valueKey:n}=this.props;return{value:e[n],label:e[s]}},this.reloadItemFromCache=()=>{const{value:e}=this.props,{currentItem:s,cache:n}=this.state;return e&&(!s||s.value!==e)&&n[e]?(this.setState({currentItem:n[e]}),!0):!1},this.addBackendItemToCache=e=>{if(e){const s=this.transformBackendItemToSelectItem(e),n=s.value;this.setState(({cache:r})=>({cache:{...r,[n]:s}}))}},this.fetchOptions=async(e,s)=>{const{searchByQuery:n}=this.props;try{const{content:r,number:a,totalPages:o}=await n(e,s.length);return{options:r.map(this.transformBackendItemToSelectItem),hasMore:a<o-1}}catch(r){return console.error("Error fetching options:",r),{hasMore:!1,options:[]}}},this.handleChange=e=>{const{onChange:s}=this.props;if(e){const n=e.value;this.setState(({cache:r})=>({cache:{...r,[n]:e}}),()=>{s(n)})}else s(null)}}componentDidMount(){const{value:e,searchById:s}=this.props;e&&s(e).then(this.addBackendItemToCache),this.props["data-testid"]&&setTimeout(()=>{this.selectRef?.current?.controlRef&&this.selectRef.current.controlRef.setAttribute("data-testid",this.props["data-testid"])},0)}componentDidUpdate(){const{value:e,searchById:s}=this.props,{currentItem:n}=this.state;e&&(!n||n.value!==e)?this.reloadItemFromCache()||s(e).then(this.addBackendItemToCache):!e&&n&&this.setState({currentItem:null})}render(){const{clearable:e,noResultsMessage:s,disabled:n,menuPortalTarget:r}=this.props,{currentItem:a}=this.state;return i.jsx(ut.AsyncPaginate,{selectRef:this.selectRef,className:"select-search-container",classNamePrefix:"select-search",isClearable:e,noResultsText:s,value:a,onChange:this.handleChange,loadOptions:this.fetchOptions,isDisabled:n,menuPortalTarget:r,placeholder:this.props.placeholder})}}class Is extends Z.PureComponent{constructor(){super(...arguments),this.createClickHandler=e=>()=>{const{onClick:s}=this.props;s&&s(),e()}}render(){const{disabled:e,icon:s,children:n,linkTo:r}=this.props,a=this.props["data-testid"];return i.jsx(We.Consumer,{children:({toggleMenu:o})=>r?i.jsxs(O.Link,{"data-testid":a,to:r,className:`item ${e?"disabled":""}`,onClick:this.createClickHandler(o),children:[s&&i.jsx("span",{className:"item-icon",children:s}),i.jsx("span",{className:"item-text",children:n})]}):i.jsxs("div",{"data-testid":a,className:`item ${e?"disabled":""}`,onClick:this.createClickHandler(o),children:[s&&i.jsx("span",{className:"item-icon",children:s}),i.jsx("span",{className:"item-text",children:n})]})})}}const Ie=3600*1e3;function Rs({period:t,onChange:e,readOnly:s,locale:n,timezone:r}){const[a,o]=p.useState(""),l=p.useRef(void 0),c=p.useRef(null),u=new Date(t.tsStart),d=new Date(t.tsEnd);function h(m){l.current&&clearTimeout(l.current),o(m),l.current=setTimeout(()=>o(""),1e3)}function g(m,x){if(m){const y=t.tsEnd&&m>t.tsEnd,v=y?m+Ie:t.tsEnd,j={tsStart:m,tsEnd:v};T.isEqual(j,t)||e(j),!x&&c.current&&c.current.focus(),y&&h("date-to")}}function f(m){if(m){const x=t.tsStart&&m<t.tsStart,v={tsStart:x?m-Ie:t.tsStart,tsEnd:m};T.isEqual(v,t)||e(v),x&&h("date-from")}}return i.jsxs("span",{className:"inputs",children:[i.jsx("span",{"data-testid":"from-wrapper",children:i.jsx(le,{timestamp:t.tsStart,onChange:g,warning:a==="date-from",selectsStart:!0,startDate:u,endDate:d,readOnly:s,locale:n,timezone:r})})," - ",i.jsx("span",{"data-testid":"to-wrapper",children:i.jsx(le,{ref:c,timestamp:t.tsEnd,onChange:f,warning:a==="date-to",selectsEnd:!0,startDate:u,endDate:d,readOnly:s,locale:n,timezone:r})})]})}class ks extends p.Component{constructor(e){super(e),this.tdMonth=r=>{const{selectedMonth:a,selectedYear:o,displayedYear:l}=this.state;return i.jsx("td",{"data-testid":`month-${r}-button`,onClick:()=>{this.props.onChange(r,l),this.setState({selectedMonth:r,selectedYear:l})},className:P({selected:r===a&&l===o}),children:S(`${o}/${r.toString().padStart(2,"0")}/01`,"YYYY/MM/DD").format("MMM")})};const s=e.month!==null&&e.month!==void 0?e.month:S().month()+1,n=e.year!==null&&e.year!==void 0?e.year:S().year();this.state={selectedMonth:s,selectedYear:n,displayedYear:n}}render(){const{displayedYear:e}=this.state;return i.jsxs("div",{className:"di monthpicker",children:[i.jsxs("div",{className:"pager",children:[i.jsx("span",{className:"page-nav prev",onClick:()=>{this.setState({displayedYear:e-1})}}),i.jsx("span",{className:"page-nav info",children:e}),i.jsx("span",{className:"page-nav next",onClick:()=>{this.setState({displayedYear:e+1})}})]}),i.jsx("div",{className:"months",children:i.jsx("table",{style:{margin:"auto"},children:i.jsxs("tbody",{children:[i.jsxs("tr",{children:[this.tdMonth(1),this.tdMonth(2),this.tdMonth(3)]}),i.jsxs("tr",{children:[this.tdMonth(4),this.tdMonth(5),this.tdMonth(6)]}),i.jsxs("tr",{children:[this.tdMonth(7),this.tdMonth(8),this.tdMonth(9)]}),i.jsxs("tr",{children:[this.tdMonth(10),this.tdMonth(11),this.tdMonth(12)]})]})})})]})}}const Es="data:image/svg+xml,%3csvg%20id='Layer_1'%20data-name='Layer%201'%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2016%2016'%3e%3cdefs%3e%3cstyle%3e%20.cls-1%20{%20fill:%20%23fff;%20}%20%3c/style%3e%3c/defs%3e%3cg%3e%3cg%3e%3crect%20class='cls-1'%20x='3.5'%20y='7.5'%20width='2'%20height='2'/%3e%3cpath%20d='M5,8V9H4V8H5M6,7H3v3H6V7Z'/%3e%3c/g%3e%3cg%3e%3crect%20class='cls-1'%20x='8'%20y='7'%20width='1'%20height='1'/%3e%3cpolygon%20points='9%207%208%207%208%208%209%208%209%207%209%207'/%3e%3c/g%3e%3cg%3e%3crect%20class='cls-1'%20x='10'%20y='7'%20width='1'%20height='1'/%3e%3cpolygon%20points='11%207%2010%207%2010%208%2011%208%2011%207%2011%207'/%3e%3c/g%3e%3cg%3e%3crect%20class='cls-1'%20x='12'%20y='7'%20width='1'%20height='1'/%3e%3cpolygon%20points='13%207%2012%207%2012%208%2013%208%2013%207%2013%207'/%3e%3c/g%3e%3cg%3e%3crect%20class='cls-1'%20x='8'%20y='9'%20width='1'%20height='1'/%3e%3cpolygon%20points='9%209%208%209%208%2010%209%2010%209%209%209%209'/%3e%3c/g%3e%3cg%3e%3crect%20class='cls-1'%20x='8'%20y='11'%20width='1'%20height='1'/%3e%3cpolygon%20points='9%2011%208%2011%208%2012%209%2012%209%2011%209%2011'/%3e%3c/g%3e%3cg%3e%3crect%20class='cls-1'%20x='6'%20y='11'%20width='1'%20height='1'/%3e%3cpolygon%20points='7%2011%206%2011%206%2012%207%2012%207%2011%207%2011'/%3e%3c/g%3e%3cg%3e%3crect%20class='cls-1'%20x='4'%20y='11'%20width='1'%20height='1'/%3e%3cpolygon%20points='5%2011%204%2011%204%2012%205%2012%205%2011%205%2011'/%3e%3c/g%3e%3cg%3e%3crect%20class='cls-1'%20x='10.5'%20y='9.5'%20width='2'%20height='2'/%3e%3cpath%20d='M12,10v1H11V10h1m1-1H10v3h3V9Z'/%3e%3c/g%3e%3cpath%20d='M15.31,2H.69A.69.69,0,0,0,0,2.69V14.31A.69.69,0,0,0,.69,15H15.31a.69.69,0,0,0,.69-.69V2.69A.69.69,0,0,0,15.31,2ZM14,13H2V6H14Z'/%3e%3c/g%3e%3crect%20x='3'%20width='3'%20height='2'/%3e%3crect%20x='10'%20width='3'%20height='2'/%3e%3c/svg%3e",Ms="data:image/svg+xml,%3csvg%20id='Layer_1'%20data-name='Layer%201'%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2016%2016'%3e%3cpolygon%20points='7.5%2010%204%206%2011%206%207.5%2010'/%3e%3c/svg%3e";S.extend(Te);S.extend(Oe);function E(t,e){return t?S.tz(e,t):S(e)}function $e(t){return{tsStart:E(t).startOf("day").valueOf(),tsEnd:E(t).endOf("day").valueOf()}}function Je(t){return{tsStart:E(t).subtract(1,"day").startOf("day").valueOf(),tsEnd:E(t).subtract(1,"day").endOf("day").valueOf()}}function Ke(t){return{tsStart:E(t).startOf("week").valueOf(),tsEnd:E(t).endOf("week").valueOf()}}function Xe(t){return{tsStart:E(t).startOf("month").valueOf(),tsEnd:E(t).endOf("month").valueOf()}}function _e(t,e){return{tsStart:E(e,t).startOf("day").valueOf(),tsEnd:E(e,t).endOf("day").valueOf()}}function et(t,e){return{tsStart:E(e,t).startOf("month").valueOf(),tsEnd:E(e,t).endOf("month").valueOf()}}function ce(t,e){const s=E(e).subtract(t-1,"days").startOf("day").valueOf(),n=S().endOf("day").valueOf();return{tsStart:s,tsEnd:n}}const Ts=1e3*60*60*24;function Os({tsStart:t,tsEnd:e}){return Math.round((e-t+1)/Ts)}function Ds({onChange:t,onShowCustomPeriod:e,periodName:s,timezone:n}){const[r,a]=p.useState(!1),[o,l]=p.useState(!1),[c,u]=p.useState(!1),[d,h]=p.useState(Date.now());function g(j){t(j),a(!1),e&&e(!1)}function f(j){g(_e(j??Date.now(),n)),l(!1),h(j??void 0)}function m(j,w){g(et(S().year(w).month(j-1).valueOf(),n)),u(!1)}function x(){l(!o),u(!1)}function y(){u(!c),l(!1)}function v(){a(!1),e&&e(!0)}return i.jsx("div",{children:i.jsx(A.Popup,{open:r,onOpenChange:a,handler:i.jsx(A.Button,{"data-testid":"time-period-menu-button",title:{id:"trend.calendarMenu.calendar.timePeriod",defaultValue:"Time Period"},children:i.jsxs(i.Fragment,{children:[i.jsx("img",{src:Es,alt:"calendar icon",style:{width:16,height:16}})," ",!!s&&i.jsxs("span",{children:[" ",s," "]}),i.jsx("img",{src:Ms,alt:"triangle down",style:{width:16,height:16}})]})}),children:i.jsx("div",{className:"di multimenu period-picker-multimenu",children:i.jsxs("div",{className:`drop bottom ${r?"show":""}`,children:[i.jsx("div",{className:`left-box ${o?"show":""}`,children:i.jsx(he,{inline:!0,value:d,onChange:f})}),i.jsx("div",{className:`left-box ${c?"show":""}`,children:i.jsx(ks,{onChange:m})}),i.jsxs("div",{className:"right-box",children:[i.jsx("div",{className:"item","data-testid":"today-button",onClick:()=>g($e(n)),children:i.jsx("div",{className:"item-text",children:i.jsx(C,{i18nKey:"trend.calendarMenu.timePeriod.today",children:"Today"})})}),i.jsx("div",{className:"item","data-testid":"yesterday-button",onClick:()=>g(Je(n)),children:i.jsx("div",{className:"item-text",children:i.jsx(C,{i18nKey:"trend.calendarMenu.timePeriod.yesterday",children:"Yesterday"})})}),i.jsxs("div",{className:"item",children:[i.jsx("div",{"data-testid":"last-7-days-button",className:"item-text",onClick:()=>g(ce(7,n)),children:i.jsx(C,{i18nKey:"trend.calendarMenu.timePeriod.lastSevenDays",children:"Last 7 days"})}),i.jsx("div",{className:"item-more icon triangle",children:i.jsx("div",{className:"item-more-submenu",children:[2,3,5,10,14,30].map(j=>i.jsx("div",{className:"subitem",onClick:()=>g(ce(j,n)),children:j},j))})})]}),i.jsx("div",{className:"item","data-testid":"current-week-button",onClick:()=>g(Ke(n)),children:i.jsx("div",{className:"item-text",children:i.jsx(C,{i18nKey:"trend.calendarMenu.timePeriod.currentWeek",children:"Curr. Week"})})}),i.jsx("div",{className:"item","data-testid":"current-month-button",onClick:()=>g(Xe(n)),children:i.jsx("div",{className:"item-text",children:i.jsx(C,{i18nKey:"trend.calendarMenu.timePeriod.currentMonth",children:"Curr. Month"})})}),i.jsx("div",{className:"item","data-testid":"day-button",onClick:x,children:i.jsxs("div",{className:"item-text",children:[i.jsx(C,{i18nKey:"trend.calendarMenu.timePeriod.day",children:"Day"}),i.jsx("div",{className:"item-more icon dots"})]})}),i.jsx("div",{className:"item","data-testid":"month-button",onClick:y,children:i.jsxs("div",{className:"item-text",children:[i.jsx(C,{i18nKey:"trend.calendarMenu.timePeriod.month",children:"Month"}),i.jsx("div",{className:"item-more icon dots"})]})}),e!==void 0&&i.jsx("div",{className:"item","data-testid":"from-to-button",onClick:v,children:i.jsx("div",{className:"item-text",children:i.jsx(C,{i18nKey:"trend.calendarMenu.timePeriod.fromto",children:"From/to"})})})]})]})})})})}function U(t,e){return t.tsStart===e.tsStart&&t.tsEnd===e.tsEnd}function Ps(t,e){const{t:s}=V();if(U(t,$e(e)))return s("trend.calendarMenu.timePeriod.today",{defaultValue:"Today"});if(U(t,Je(e)))return s("trend.calendarMenu.timePeriod.yesterday",{defaultValue:"Yesterday"});if(U(t,Ke(e)))return s("trend.calendarMenu.timePeriod.currentWeek",{defaultValue:"Curr. Week"});if(U(t,Xe(e)))return s("trend.calendarMenu.timePeriod.currentMonth",{defaultValue:"Curr. Month"});if(U(t,_e((t.tsStart+t.tsEnd)/2,e)))return s("trend.calendarMenu.timePeriod.day",{defaultValue:"Day"});if(U(t,et((t.tsStart+t.tsEnd)/2,e)))return s("trend.calendarMenu.timePeriod.month",{defaultValue:"Month"});const n=Os(t);if(U(t,ce(n,e)))return s("trend.calendarMenu.timePeriod.lastDays",{defaultValue:`Last ${n} days`,days:n})}function Ls({period:t,onChange:e,inputsHiddenByDefault:s,menuHidden:n,readOnly:r,locale:a,defaultPeriodName:o,timezone:l,...c}){const[u,d]=p.useState(!s),h=Ps(t,l)??o;return i.jsxs("div",{className:"di period-picker","data-testid":c["data-testid"],children:[(!s||u)&&i.jsx(Rs,{period:t,onChange:e,locale:a,readOnly:r,timezone:l}),n||r||i.jsx(Ds,{periodName:h,onShowCustomPeriod:s?d:void 0,onChange:e,timezone:l})]})}const Vs=500,Re=t=>Array.from(t.querySelectorAll("[id]")).map(e=>e.getAttribute("id")).reduce((e,s)=>(s&&(e[s]=e[s]+1||1),e),{}),Bs=t=>{const e=Re(document),s=Re(t);return Object.keys(s).filter(n=>s[n]<e[n])};function Fs(t,e){const s=setTimeout(()=>{e&&e(Bs(t))},Vs);return()=>clearTimeout(s)}const tt="http://www.w3.org/2000/svg";function Gs(t,{hoverColor:e,internalLink:s,link:n},r,a){const o=Hs(t);if(!o)return;const l=`a${Be(8)}`;t.classList.add("anchor",l),e&&r?.sheet&&r.sheet.insertRule(`.di.svg-image .anchor.${l}:hover, .di.svg-image .anchor.${l}:hover * { stroke: ${e} !important; }`),o.setAttributeNS(tt,"xlink:href","#"),o.addEventListener("click",()=>s&&a?a(n):window.open(n,"_newtab"))}function Hs(t){const e=t.parentNode;if(!e)return null;const s=e.childNodes;if(!s)return null;const n=Array.from(s).findIndex(o=>o===t),r=document.createElementNS(tt,"a");r.appendChild(t);const a=s[n]||null;return a?e.insertBefore(r,a):e.appendChild(r),r}const Ys=t=>t.replace(/<svg:svg/g,"<svg").replace(/<\/svg:svg/g,"</svg"),ge=t=>{const e=new DOMParser,s=Ys(atob(t.replace("data:image/svg+xml;base64,","")));return e.parseFromString(s,"image/svg+xml")};function Us(t,e){return ge(t).querySelectorAll(`[id^="${e}"]`)}const Ws=t=>{const e=t.filter(({type:r})=>r==="positionX"||r==="positionY"),s=t.filter(({type:r})=>r!=="positionX"&&r!=="positionY"),n=e.reduce((r,a)=>a.type==="positionX"?{...r,x:a}:a.type==="positionY"?{...r,y:a}:r,{x:null,y:null});return n.x&&n.y?s.concat([{type:"positionXY",target:n.x.target,positionX:n.x.position,positionY:n.y.position}]):n.x?s.concat([n.x]):n.y?s.concat([n.y]):s},Zs=t=>{const e=t.reduce((s,n)=>({...s,[n.target]:[...s[n.target]||[],n]}),{});return Object.keys(e).reduce((s,n)=>s.concat(Ws(e[n])),[])},$=t=>Math.max(0,Math.min(100,t));function zs(t,e,s){const n=De.SVG(s),r=t.getAttribute("id")||"",a=n.findOne(`#${r}`),o=n.findOne(`#${r}-boundaries`),l=o?o.bbox():n.viewbox();e.type==="positionX"?a.x(l.x+$(e.position)*l.width/100):e.type==="positionY"?a.y(l.y+$(e.position)*l.height/100):(a.x(l.x+$(e.positionX)*l.width/100),a.y(l.y+$(e.positionY)*l.height/100))}function qs(t,e,s,n,r){const o=ge(e).querySelector("svg");return o?(t.style.height="100%",t.innerHTML="",o.style.height="100%",o.style.width="100%",o.classList.add("di","svg-image"),o.getAttribute("viewBox")||o.setAttribute("viewBox",""),o.getAttribute("preserveAspectRatio")||o.setAttribute("preserveAspectRatio","xMidYMid"),t.appendChild(o),Qs(o,s,n,r),o):null}function Qs(t,e,s,n){if(!(!e||!e.length))for(const r of Js(Zs(e))){const a=t.querySelector(`[id=${r.target}]`);a&&$s(a,r,t,s,n)}}function $s(t,e,s,n,r){switch(e.type){case"visibility":t.setAttribute("visibility",e.visible?"visible":"hidden");break;case"text":{const a=t.querySelector("tspan");a?a.textContent=e.text:t.textContent=e.text;break}case"color":{const{color:a}=e,o=l=>{l.setAttribute("fill",a),l.style.fill=a};o(t),t.querySelectorAll("g, path").forEach(o);break}case"hyperlink":Gs(t,e,n,r);break;case"eventListener":t.addEventListener(e.eventType,e.listener,e.options);break;case"classNames":t.classList.add(...e.classNames);break;case"positionX":case"positionY":case"positionXY":zs(t,e,s);break;case"rotation":{De.SVG(t).rotate(e.degrees);break}default:throw new Error("Unknown modification")}}function Js(t){return t.sort(({type:e},{type:s})=>e!==s&&s==="rotation"?-1:1)}function Ks(){const t=p.useRef(null);return p.useEffect(()=>{const e=document.createElement("style");return e.appendChild(document.createTextNode("")),document&&document.head&&document.head.appendChild(e),t.current=e,()=>{document&&document.head&&e&&document.head.removeChild(e)}},[]),t.current}function Xs({imageData:t,modifications:e,onConflict:s}){const n=p.useRef(null),r=Ks(),{push:a}=O.useHistory();return p.useEffect(()=>{const{current:o}=n;if(o&&t){const l=qs(o,t,e,r,a);if(l&&s)return Fs(l,s)}},[t,e,s,a,r]),i.jsx("div",{ref:n})}const st=t=>{try{return ge(t).querySelector("svg")}catch{return null}},_s=t=>{const e=st(t);return!!e&&!!e.style};function de(t,e,s){return`<div>${t}</div><div>${e}: <strong>${s}</strong></div>`}const F={global:{useUTC:!1},chart:{style:{fontFamily:"arial"},plotBackgroundColor:null,plotBorderWidth:0,plotShadow:!1},credits:{enabled:!1},legend:{align:"right",verticalAlign:"center",layout:"vertical"},title:{useHTML:!0},plotOptions:{pie:{dataLabels:{enabled:!1},showInLegend:!0,startAngle:-90,endAngle:270}},tooltip:{useHTML:!0,formatter(){return de("",this.point.name,this.point.y)}},xAxis:{type:"category"},yAxis:{min:0,title:{text:""}},options:{lgo:123}},ke=t=>t?{series:{cursor:"pointer",point:{events:{click:function(){t(this.index)}}}}}:{};class en extends p.Component{constructor(){super(...arguments),this.state={},this.chart=null,this.ro=null,this.handleChart=e=>{this.chart=e,this.ro=new ResizeObserver(()=>{this.chart?.reflow()}),this.ro.observe(this.chart.renderTo)}}componentDidMount(){const{type:e,title:s,items:n,tooltipTitle:r,valueFormatter:a,onClick:o}=this.props;this.setState({...F,plotOptions:{...F.plotOptions,...ke(o)},tooltip:{...F.tooltip,formatter(){const l=a||(c=>c);return de(r||"",this.point.name,l(this.point.y))}},legend:{...F.legend,enabled:e==="pie"},yAxis:{...F.yAxis,enabled:e==="column",title:{text:s||""}},series:[{type:e,innerSize:"50%",data:n.map(({label:l,value:c})=>[l,c])}]}),setTimeout(()=>{this.setState({title:{...F.title,text:e==="column"?"":s||""}})},0)}componentDidUpdate(e){const{type:s,title:n,items:r,tooltipTitle:a,valueFormatter:o,onClick:l}=this.props;n!==e.title&&this.setState({title:{...this.state.title,text:s==="column"?"":n||""},yAxis:{...this.state.yAxis,title:{text:n||""}}}),s!==e.type&&this.setState({legend:{...this.state.legend,enabled:s==="pie"},title:{text:s==="column"?"":n||""},yAxis:{...this.state.yAxis,enabled:s==="column",title:{text:s==="column"&&n||""}},series:[{type:s,innerSize:"50%",data:r.map(({label:c,value:u})=>[c,u])}]}),T.isEqual(r,e.items)||this.setState({series:[{type:s,innerSize:"50%",data:r.map(({label:c,value:u})=>[c,u])}]}),(a!==e.tooltipTitle||o!==e.valueFormatter||l!==e.onClick)&&this.setState({tooltip:{...F.tooltip,formatter(){const c=o||(u=>u);return de(a||"",this.point.name,c(this.point.y))}},plotOptions:{...F.plotOptions,...ke(l)}})}componentWillUnmount(){this.ro&&this.chart?.renderTo&&this.ro.unobserve(this.chart.renderTo),this.chart=null,this.ro=null}render(){const e=this.props.updateOptions?this.props.updateOptions(this.state):this.state;return i.jsx(pt,{highcharts:ht,options:e,containerProps:{className:this.props.className},callback:this.handleChart})}}function tn(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var q={},Ee;function sn(){if(Ee)return q;Ee=1,Object.defineProperty(q,"__esModule",{value:!0}),q.default=void 0;let t=o=>+setTimeout(o,16),e=o=>clearTimeout(o);typeof window<"u"&&"requestAnimationFrame"in window&&(t=o=>window.requestAnimationFrame(o),e=o=>window.cancelAnimationFrame(o));let s=0;const n=new Map;function r(o){n.delete(o)}const a=(o,l=1)=>{s+=1;const c=s;function u(d){if(d===0)r(c),o();else{const h=t(()=>{u(d-1)});n.set(c,h)}}return u(l),c};return a.cancel=o=>{const l=n.get(o);return r(o),e(l)},process.env.NODE_ENV!=="production"&&(a.ids=()=>n),q.default=a,q}var nn=sn();const Me=tn(nn),rn=t=>{const{value:e,children:s,visible:n,tipFormatter:r=d=>`${d}`,...a}=t,o=p.useRef(null),l=p.useRef(null);function c(){l.current&&Me.cancel(l.current)}function u(){l.current=Me(()=>{o.current?.forceAlign()})}return p.useEffect(()=>(n?u():c(),c),[e,n]),i.jsx(ft,{placement:"top",overlay:r(e),ref:o,align:{offset:[0,-10]},visible:n,...a,children:s})},an=({tipFormatter:t,tipProps:e,...s})=>{const n=(r,a)=>i.jsx(rn,{value:a.value,visible:a.dragging,tipFormatter:t,...e,children:r});return i.jsx(Pe,{...s,handleRender:n})};function on(t,e,s){const[n,r]=p.useState(null);p.useEffect(()=>{if(n){const o=n.querySelector(".rc-slider-rail");if(!o)throw new Error(".rc-slider-rail element missing");const l=o?.querySelector(".disabled-area-element"),c=o.getBoundingClientRect().width;if(l)if(t==null)l.remove();else{const u=Math.round((s-t)/(s-e)*c);l.style.width=`${u}px`}else if(t!=null){const u=Math.round((s-t)/(s-e)*c),d=document.createElement("div");d.classList.add("disabled-area-element"),d.style.width=`${u}px`,o.appendChild(d)}}},[t,n,e,s]);const a=p.useCallback(()=>{if(n&&t!=null){const o=n.querySelector(".rc-slider-rail");if(!o)throw new Error(".rc-slider-rail element missing");const l=o?.querySelector(".disabled-area-element"),c=o.getBoundingClientRect().width;if(l){const u=Math.round((s-t)/(s-e)*c);l.style.width=`${u}px`}}},[t,s,e,n]);return p.useEffect(()=>{n&&new ResizeObserver(()=>a()).observe(n)},[n,a]),r}const ln=({min:t,max:e,step:s,value:n,tooltip:r=!0,labels:a,format:o,onChange:l,onChangeComplete:c,limit:u})=>{const d=on(u,t,e),f={min:t,max:e,step:s,value:n,onChange:m=>{if(!l)return;const x=typeof m=="number"?m:m[0],y=u!=null?Math.min(x,u):x;l(y)},onChangeComplete:()=>{c&&c(n)},marks:a};return i.jsx("div",{className:"di slider",ref:d,children:r?i.jsx(an,{...f,className:"di slider with-tooltip",tipFormatter:o}):i.jsx(Pe,{...f,className:"di slider"})})};exports.Chart=en;exports.ColorPicker=Ye;exports.ContentHeader=As;exports.DateInput=he;exports.DateTimeInput=le;exports.FileUpload=_;exports.GradientColorPicker=Ft;exports.GridColorPicker=Ye;exports.ImageUpload=Cs;exports.InfoBox=$t;exports.MessageBoxContainer=Ct;exports.MultiMenu=Ze;exports.MultiMenuItem=Is;exports.Pagination=ze;exports.PeriodPicker=Ls;exports.Reactable=Qe;exports.ReactableWithClientSidePagination=ys;exports.RouteLink=qt;exports.RouteTabs=Kt;exports.SelectWithSearch=qe;exports.SelectWithSearchAsync=Ns;exports.Slider=ln;exports.SvgImage=Xs;exports.TreeView=rs;exports.UrnInput=Wt;exports.ValidatedTextInput=Q;exports.getMutableNodeList=Us;exports.getSvgElement=st;exports.getTreeNodePathById=Dt;exports.initializeTranslation=Nt;exports.messageBoxDismissAll=jt;exports.messageBoxDismissGroup=yt;exports.messageBoxDismissSingle=bt;exports.messageBoxError=St;exports.messageBoxInfo=xt;exports.messageBoxSuccess=mt;exports.messageBoxWarn=vt;exports.nanoid10=At;exports.setGlobalErrorMessageBoxOptions=gt;exports.uuidV4=Be;exports.validateSvg=_s;exports.withPrompt=zt;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
+
const reactToastify = require("react-toastify");
|
|
5
|
+
const nanoid = require("nanoid");
|
|
6
|
+
const React = require("react");
|
|
7
|
+
const cx = require("classnames");
|
|
8
|
+
const ngUiBasicComponents = require("@deviceinsight/ng-ui-basic-components");
|
|
9
|
+
const pureColor = require("pure-color");
|
|
10
|
+
const reactColorful = require("react-colorful");
|
|
11
|
+
const timezone = require("dayjs/plugin/timezone");
|
|
12
|
+
const utc = require("dayjs/plugin/utc");
|
|
13
|
+
const DatePicker = require("react-datepicker");
|
|
14
|
+
const lodash = require("lodash");
|
|
15
|
+
const dayjs = require("dayjs");
|
|
16
|
+
const localeData = require("dayjs/plugin/localeData");
|
|
17
|
+
const localizedFormat = require("dayjs/plugin/localizedFormat");
|
|
18
|
+
const customParseFormat = require("dayjs/plugin/customParseFormat");
|
|
19
|
+
const i18n = require("i18next");
|
|
20
|
+
const Locales = require("date-fns/locale");
|
|
21
|
+
require("dayjs/locale/en");
|
|
22
|
+
require("dayjs/locale/en-gb");
|
|
23
|
+
require("dayjs/locale/en-ca");
|
|
24
|
+
require("dayjs/locale/de");
|
|
25
|
+
require("dayjs/locale/de-at");
|
|
26
|
+
require("dayjs/locale/de-ch");
|
|
27
|
+
require("dayjs/locale/it");
|
|
28
|
+
require("dayjs/locale/ja");
|
|
29
|
+
const reactRouterDom = require("react-router-dom");
|
|
30
|
+
const core = require("@dnd-kit/core");
|
|
31
|
+
const sortable = require("@dnd-kit/sortable");
|
|
32
|
+
const modifiers = require("@dnd-kit/modifiers");
|
|
33
|
+
const ngUiApiClient = require("@deviceinsight/ng-ui-api-client");
|
|
34
|
+
const Select = require("react-select");
|
|
35
|
+
const Dropzone = require("react-dropzone");
|
|
36
|
+
const reactSelectAsyncPaginate = require("react-select-async-paginate");
|
|
37
|
+
const svg_js = require("@svgdotjs/svg.js");
|
|
38
|
+
const Highcharts = require("highcharts");
|
|
39
|
+
const HighchartsReact = require("highcharts-react-official");
|
|
40
|
+
const Slider$1 = require("@rc-component/slider");
|
|
41
|
+
const Tooltip = require("@rc-component/tooltip");
|
|
42
|
+
function _interopNamespaceDefault(e) {
|
|
43
|
+
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
44
|
+
if (e) {
|
|
45
|
+
for (const k in e) {
|
|
46
|
+
if (k !== "default") {
|
|
47
|
+
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
48
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
get: () => e[k]
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
n.default = e;
|
|
56
|
+
return Object.freeze(n);
|
|
57
|
+
}
|
|
58
|
+
const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
|
|
59
|
+
const Locales__namespace = /* @__PURE__ */ _interopNamespaceDefault(Locales);
|
|
60
|
+
let groupNamesToToastIds = {};
|
|
61
|
+
let globalErrorMessageBoxOptions = {
|
|
62
|
+
autoClose: false
|
|
63
|
+
};
|
|
64
|
+
const setGlobalErrorMessageBoxOptions = (options) => {
|
|
65
|
+
globalErrorMessageBoxOptions = options;
|
|
66
|
+
};
|
|
67
|
+
const storeGroupName = (groupName, toastId) => {
|
|
68
|
+
if (groupName) {
|
|
69
|
+
if (groupNamesToToastIds[groupName]) {
|
|
70
|
+
groupNamesToToastIds[groupName] = [...groupNamesToToastIds[groupName], toastId];
|
|
71
|
+
} else {
|
|
72
|
+
groupNamesToToastIds[groupName] = [toastId];
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
const messageBoxSuccess = (content, options, groupName) => {
|
|
77
|
+
const toastId = reactToastify.toast.success(content, options);
|
|
78
|
+
if (groupName) storeGroupName(groupName, toastId);
|
|
79
|
+
};
|
|
80
|
+
const messageBoxInfo = (content, options, groupName) => {
|
|
81
|
+
const toastId = reactToastify.toast.info(content, options);
|
|
82
|
+
if (groupName) storeGroupName(groupName, toastId);
|
|
83
|
+
};
|
|
84
|
+
const messageBoxWarn = (content, options, groupName) => {
|
|
85
|
+
const toastId = reactToastify.toast.warn(content, options);
|
|
86
|
+
if (groupName) storeGroupName(groupName, toastId);
|
|
87
|
+
};
|
|
88
|
+
const messageBoxError = (content, options, groupName) => {
|
|
89
|
+
const toastId = reactToastify.toast.error(content, { ...globalErrorMessageBoxOptions, ...options });
|
|
90
|
+
if (groupName) storeGroupName(groupName, toastId);
|
|
91
|
+
};
|
|
92
|
+
const messageBoxDismissSingle = (id) => {
|
|
93
|
+
reactToastify.toast.dismiss(id);
|
|
94
|
+
};
|
|
95
|
+
const messageBoxDismissGroup = (groupName) => {
|
|
96
|
+
if (groupNamesToToastIds[groupName]) {
|
|
97
|
+
groupNamesToToastIds[groupName].forEach((toastId) => reactToastify.toast.dismiss(toastId));
|
|
98
|
+
delete groupNamesToToastIds[groupName];
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
const messageBoxDismissAll = () => {
|
|
102
|
+
groupNamesToToastIds = {};
|
|
103
|
+
reactToastify.toast.dismiss();
|
|
104
|
+
};
|
|
105
|
+
const MessageBoxContainer = () => /* @__PURE__ */ jsxRuntime.jsx(reactToastify.ToastContainer, { position: "top-center", theme: "colored", autoClose: 3e4, hideProgressBar: true, transition: reactToastify.Slide });
|
|
106
|
+
const uuidV4 = (length = 32) => {
|
|
107
|
+
let uuid = "";
|
|
108
|
+
for (let i = 0; i < length; i++) {
|
|
109
|
+
const random = Math.random() * 16 | 0;
|
|
110
|
+
if (i === 8 || i === 12 || i === 16 || i === 20) {
|
|
111
|
+
uuid += "-";
|
|
112
|
+
}
|
|
113
|
+
uuid += (i === 12 ? 4 : i === 16 ? random & 3 | 8 : random).toString(16);
|
|
114
|
+
}
|
|
115
|
+
return uuid;
|
|
116
|
+
};
|
|
117
|
+
const alphabet = "0123456789abcdefghijklmnopqrstuvwxyz";
|
|
118
|
+
const nanoid10 = nanoid.customAlphabet(alphabet, 10);
|
|
119
|
+
let Trans;
|
|
120
|
+
let useTranslation;
|
|
121
|
+
function initializeTranslation(transComponent, useTranslationHook) {
|
|
122
|
+
Trans = transComponent;
|
|
123
|
+
useTranslation = useTranslationHook;
|
|
124
|
+
}
|
|
125
|
+
function removeDuplicatesFromArray(arr) {
|
|
126
|
+
return arr.filter((id, index, arr2) => arr2.indexOf(id) === index);
|
|
127
|
+
}
|
|
128
|
+
function removeNodeIds(nodeIds, nodeIdsToRemove) {
|
|
129
|
+
return nodeIds.filter((id) => !nodeIdsToRemove.includes(id));
|
|
130
|
+
}
|
|
131
|
+
function mergeNodeIdArrays(nodeIds1, nodeIds2) {
|
|
132
|
+
return removeDuplicatesFromArray([...nodeIds1, ...nodeIds2]);
|
|
133
|
+
}
|
|
134
|
+
function intersectArrays(array1, array2) {
|
|
135
|
+
return array1.filter((value) => array2.includes(value));
|
|
136
|
+
}
|
|
137
|
+
function getTreeSize(node) {
|
|
138
|
+
if (node.children) {
|
|
139
|
+
const numberOfChildren = node.children.length;
|
|
140
|
+
return numberOfChildren + node.children.reduce((l, child) => l + getTreeSize(child), 0);
|
|
141
|
+
}
|
|
142
|
+
return 0;
|
|
143
|
+
}
|
|
144
|
+
function getAllLeaves(node) {
|
|
145
|
+
if (node.children) {
|
|
146
|
+
return node.children.reduce((childNodes, child) => [...childNodes, ...getAllLeaves(child)], []);
|
|
147
|
+
}
|
|
148
|
+
return [node];
|
|
149
|
+
}
|
|
150
|
+
function getAllLeafIds(node) {
|
|
151
|
+
return getAllLeaves(node).map((node2) => node2.id);
|
|
152
|
+
}
|
|
153
|
+
function convertToTree({
|
|
154
|
+
childNodeKey,
|
|
155
|
+
idKey,
|
|
156
|
+
displayNameKey,
|
|
157
|
+
typeKey,
|
|
158
|
+
lazyLoadableKey,
|
|
159
|
+
nodeMetaData,
|
|
160
|
+
leafMetaData
|
|
161
|
+
}) {
|
|
162
|
+
const { typeValue: leafTypeValue, image, resolver: leafResolver } = leafMetaData;
|
|
163
|
+
const { typeValue: nodeTypeValue, expandedImage, closedImage, resolver: nodeResolver } = nodeMetaData;
|
|
164
|
+
return function convert(hierarchicalData, nodePath = "") {
|
|
165
|
+
return hierarchicalData.map((rootNode) => {
|
|
166
|
+
const id = rootNode[idKey];
|
|
167
|
+
const name = rootNode[displayNameKey];
|
|
168
|
+
const children = rootNode[childNodeKey];
|
|
169
|
+
const lazyLoadable = rootNode[lazyLoadableKey];
|
|
170
|
+
const isNode = nodeResolver ? nodeResolver(rootNode) : rootNode[typeKey] === nodeTypeValue;
|
|
171
|
+
const isLeaf = leafResolver ? leafResolver(rootNode) : rootNode[typeKey] === leafTypeValue;
|
|
172
|
+
const path = `${nodePath}/${name}`;
|
|
173
|
+
const originalNode = rootNode;
|
|
174
|
+
if (isNode) {
|
|
175
|
+
return {
|
|
176
|
+
id,
|
|
177
|
+
name,
|
|
178
|
+
children: convert(children || [], path),
|
|
179
|
+
lazyLoadable,
|
|
180
|
+
expandedImage,
|
|
181
|
+
closedImage,
|
|
182
|
+
path,
|
|
183
|
+
originalNode
|
|
184
|
+
};
|
|
185
|
+
} else if (isLeaf) {
|
|
186
|
+
return {
|
|
187
|
+
id,
|
|
188
|
+
name,
|
|
189
|
+
image,
|
|
190
|
+
path,
|
|
191
|
+
originalNode
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
throw new Error("unknown node or leaf type provided");
|
|
195
|
+
});
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
function patchNode(node, patch) {
|
|
199
|
+
let patchedChildren;
|
|
200
|
+
if (patch.children !== void 0) {
|
|
201
|
+
if (node.children !== void 0) {
|
|
202
|
+
patchedChildren = [...node.children, ...patch.children];
|
|
203
|
+
} else {
|
|
204
|
+
patchedChildren = [...patch.children];
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
return { ...node, ...patch, children: patchedChildren || void 0 };
|
|
208
|
+
}
|
|
209
|
+
function findNodeAndApplyPatch(node, nodeId, patch) {
|
|
210
|
+
if (node.children === void 0) {
|
|
211
|
+
return node;
|
|
212
|
+
}
|
|
213
|
+
if (node.id === nodeId) {
|
|
214
|
+
return patchNode(node, patch);
|
|
215
|
+
}
|
|
216
|
+
return { ...node, children: node.children.map((childNode) => findNodeAndApplyPatch(childNode, nodeId, patch)) };
|
|
217
|
+
}
|
|
218
|
+
function getTreeNodePathByIdArray(currentNode, idToFind, idKey, childNodeKey, displayNameKey) {
|
|
219
|
+
if (currentNode[idKey] === idToFind) {
|
|
220
|
+
return [currentNode[displayNameKey]];
|
|
221
|
+
} else if (currentNode[childNodeKey]) {
|
|
222
|
+
for (let i = 0; i < currentNode[childNodeKey].length; i++) {
|
|
223
|
+
const path = getTreeNodePathByIdArray(
|
|
224
|
+
currentNode[childNodeKey][i],
|
|
225
|
+
idToFind,
|
|
226
|
+
idKey,
|
|
227
|
+
childNodeKey,
|
|
228
|
+
displayNameKey
|
|
229
|
+
);
|
|
230
|
+
if (path) {
|
|
231
|
+
path.unshift(currentNode[displayNameKey]);
|
|
232
|
+
return path;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
return null;
|
|
237
|
+
}
|
|
238
|
+
function getTreeNodePathById(currentNode, idToFind, idKey, childNodeKey, displayNameKey) {
|
|
239
|
+
const nodePathArray = getTreeNodePathByIdArray(currentNode, idToFind, idKey, childNodeKey, displayNameKey);
|
|
240
|
+
return nodePathArray ? nodePathArray.join(".") : null;
|
|
241
|
+
}
|
|
242
|
+
function ColorPickerPopper({
|
|
243
|
+
isOpen,
|
|
244
|
+
onOpenChange,
|
|
245
|
+
className,
|
|
246
|
+
style,
|
|
247
|
+
value,
|
|
248
|
+
placement,
|
|
249
|
+
children
|
|
250
|
+
}) {
|
|
251
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
252
|
+
ngUiBasicComponents.Popup,
|
|
253
|
+
{
|
|
254
|
+
handler: /* @__PURE__ */ jsxRuntime.jsx("div", { className: `di color-picker-popper ${className || ""}`, style, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "trigger", style: { ...style, backgroundColor: value } }) }),
|
|
255
|
+
open: isOpen,
|
|
256
|
+
onOpenChange,
|
|
257
|
+
placement,
|
|
258
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "color-picker-box", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "content", children }) })
|
|
259
|
+
}
|
|
260
|
+
);
|
|
261
|
+
}
|
|
262
|
+
function GridColorPicker({
|
|
263
|
+
value,
|
|
264
|
+
isOpen,
|
|
265
|
+
onOpenStateChange,
|
|
266
|
+
direction,
|
|
267
|
+
colors: colors2,
|
|
268
|
+
onPick,
|
|
269
|
+
pickerStyle,
|
|
270
|
+
pickerClassName,
|
|
271
|
+
inline = true,
|
|
272
|
+
className,
|
|
273
|
+
style
|
|
274
|
+
}) {
|
|
275
|
+
const [open, setOpen] = React.useState(false);
|
|
276
|
+
const picker = /* @__PURE__ */ jsxRuntime.jsx("div", { className: cx("di color-picker grid-color-picker clearfix", pickerClassName), style: pickerStyle, children: colors2.map((color) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
277
|
+
"div",
|
|
278
|
+
{
|
|
279
|
+
onClick: () => {
|
|
280
|
+
onPick(color);
|
|
281
|
+
},
|
|
282
|
+
className: `color ${color === value ? "selected" : ""}`,
|
|
283
|
+
style: {
|
|
284
|
+
background: color
|
|
285
|
+
}
|
|
286
|
+
},
|
|
287
|
+
color
|
|
288
|
+
)) });
|
|
289
|
+
if (inline) {
|
|
290
|
+
return picker;
|
|
291
|
+
}
|
|
292
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
293
|
+
ColorPickerPopper,
|
|
294
|
+
{
|
|
295
|
+
className,
|
|
296
|
+
style,
|
|
297
|
+
value,
|
|
298
|
+
isOpen: isOpen ?? open,
|
|
299
|
+
onOpenChange: onOpenStateChange ?? setOpen,
|
|
300
|
+
placement: direction,
|
|
301
|
+
children: picker
|
|
302
|
+
}
|
|
303
|
+
);
|
|
304
|
+
}
|
|
305
|
+
const isValid = (value, pattern, required) => {
|
|
306
|
+
if (!value.length) {
|
|
307
|
+
return !required;
|
|
308
|
+
}
|
|
309
|
+
return pattern.test(value);
|
|
310
|
+
};
|
|
311
|
+
const _ValidatedTextInput = class _ValidatedTextInput extends React__namespace.Component {
|
|
312
|
+
constructor() {
|
|
313
|
+
super(...arguments);
|
|
314
|
+
this.handleChange = (e) => {
|
|
315
|
+
const { value } = e.target;
|
|
316
|
+
const { pattern, required, onChange } = this.props;
|
|
317
|
+
const valid = isValid(value, pattern, required);
|
|
318
|
+
onChange(value, valid);
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
render() {
|
|
322
|
+
const { style, invalidStyle, value, ...props } = this.props;
|
|
323
|
+
const { pattern, required, ...otherProps } = props;
|
|
324
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
325
|
+
"input",
|
|
326
|
+
{
|
|
327
|
+
...otherProps,
|
|
328
|
+
value,
|
|
329
|
+
onChange: this.handleChange,
|
|
330
|
+
style: isValid(value, pattern, required) ? style : { ...style, ...invalidStyle },
|
|
331
|
+
type: "text"
|
|
332
|
+
}
|
|
333
|
+
);
|
|
334
|
+
}
|
|
335
|
+
};
|
|
336
|
+
_ValidatedTextInput.defaultProps = {
|
|
337
|
+
required: false
|
|
338
|
+
};
|
|
339
|
+
let ValidatedTextInput = _ValidatedTextInput;
|
|
340
|
+
function ColorTextInput({ value, pattern, onChange, placeholder, style }) {
|
|
341
|
+
const [text, setText] = React.useState(value);
|
|
342
|
+
function handleChange(value2, valid) {
|
|
343
|
+
setText(value2);
|
|
344
|
+
if (valid) {
|
|
345
|
+
onChange(value2);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
React.useEffect(() => {
|
|
349
|
+
setText(value);
|
|
350
|
+
}, [value]);
|
|
351
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
352
|
+
ValidatedTextInput,
|
|
353
|
+
{
|
|
354
|
+
value: text,
|
|
355
|
+
onChange: handleChange,
|
|
356
|
+
pattern,
|
|
357
|
+
invalidStyle: {
|
|
358
|
+
borderColor: "red"
|
|
359
|
+
},
|
|
360
|
+
placeholder,
|
|
361
|
+
required: true,
|
|
362
|
+
style
|
|
363
|
+
}
|
|
364
|
+
);
|
|
365
|
+
}
|
|
366
|
+
const VALIDATE_HEX_COLOR_REGEX = /^#([A-Fa-f0-9]{6})$/;
|
|
367
|
+
const VALIDATE_RGB_COLOR_REGEX = /^rgb\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)$/;
|
|
368
|
+
const convertRgbaToRgb = (color) => {
|
|
369
|
+
return pureColor.parse(color).splice(0, 3);
|
|
370
|
+
};
|
|
371
|
+
const convertToHex = (color) => {
|
|
372
|
+
return color && color.length > 6 ? pureColor.convert.rgb.hex(convertRgbaToRgb(color)) : "";
|
|
373
|
+
};
|
|
374
|
+
const convertToRgb = (color) => {
|
|
375
|
+
return color ? pureColor.convert.rgb.string(convertRgbaToRgb(color)) : "";
|
|
376
|
+
};
|
|
377
|
+
function GradientColorPicker({
|
|
378
|
+
onOpenStateChange,
|
|
379
|
+
onPick,
|
|
380
|
+
allowTextInput,
|
|
381
|
+
className,
|
|
382
|
+
direction,
|
|
383
|
+
inline = true,
|
|
384
|
+
isOpen,
|
|
385
|
+
opacitySlider,
|
|
386
|
+
pickerClassName,
|
|
387
|
+
pickerStyle,
|
|
388
|
+
style,
|
|
389
|
+
value
|
|
390
|
+
}) {
|
|
391
|
+
const [open, setOpen] = React.useState(false);
|
|
392
|
+
const hexValue = convertToHex(value);
|
|
393
|
+
const rgbValue = convertToRgb(value);
|
|
394
|
+
const ColorPicker = value === hexValue ? reactColorful.HexColorPicker : opacitySlider && !allowTextInput ? reactColorful.RgbaStringColorPicker : reactColorful.RgbStringColorPicker;
|
|
395
|
+
const picker = /* @__PURE__ */ jsxRuntime.jsxs(
|
|
396
|
+
"div",
|
|
397
|
+
{
|
|
398
|
+
className: cx(
|
|
399
|
+
"di gradient-color-picker",
|
|
400
|
+
{
|
|
401
|
+
"with-textfield": allowTextInput
|
|
402
|
+
},
|
|
403
|
+
pickerClassName
|
|
404
|
+
),
|
|
405
|
+
style: pickerStyle,
|
|
406
|
+
children: [
|
|
407
|
+
/* @__PURE__ */ jsxRuntime.jsx(ColorPicker, { color: value, onChange: onPick }),
|
|
408
|
+
allowTextInput && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "inputs", children: [
|
|
409
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
410
|
+
ColorTextInput,
|
|
411
|
+
{
|
|
412
|
+
value: hexValue,
|
|
413
|
+
onChange: onPick,
|
|
414
|
+
pattern: VALIDATE_HEX_COLOR_REGEX,
|
|
415
|
+
placeholder: "#FF00FF",
|
|
416
|
+
style: { width: 60 }
|
|
417
|
+
}
|
|
418
|
+
),
|
|
419
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
420
|
+
ColorTextInput,
|
|
421
|
+
{
|
|
422
|
+
value: rgbValue,
|
|
423
|
+
onChange: onPick,
|
|
424
|
+
pattern: VALIDATE_RGB_COLOR_REGEX,
|
|
425
|
+
placeholder: "rgb(255,0,255)",
|
|
426
|
+
style: { width: 115 }
|
|
427
|
+
}
|
|
428
|
+
)
|
|
429
|
+
] })
|
|
430
|
+
]
|
|
431
|
+
}
|
|
432
|
+
);
|
|
433
|
+
if (inline) {
|
|
434
|
+
return picker;
|
|
435
|
+
}
|
|
436
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
437
|
+
ColorPickerPopper,
|
|
438
|
+
{
|
|
439
|
+
className,
|
|
440
|
+
style,
|
|
441
|
+
value,
|
|
442
|
+
isOpen: isOpen ?? open,
|
|
443
|
+
onOpenChange: onOpenStateChange ?? setOpen,
|
|
444
|
+
placement: direction,
|
|
445
|
+
children: picker
|
|
446
|
+
}
|
|
447
|
+
);
|
|
448
|
+
}
|
|
449
|
+
const supportedLocales = ["en", "en-gb", "en-ca", "de", "de-at", "de-ch", "it", "ja"];
|
|
450
|
+
function isLocaleSupported(locale) {
|
|
451
|
+
return supportedLocales.includes(locale);
|
|
452
|
+
}
|
|
453
|
+
dayjs.extend(utc);
|
|
454
|
+
dayjs.extend(timezone);
|
|
455
|
+
dayjs.extend(localeData);
|
|
456
|
+
dayjs.extend(localizedFormat);
|
|
457
|
+
dayjs.extend(customParseFormat);
|
|
458
|
+
function registerLanguage(locale) {
|
|
459
|
+
const [localeSegment1, localeSegment2] = locale.split("-");
|
|
460
|
+
let module2;
|
|
461
|
+
if (localeSegment1 && localeSegment2) {
|
|
462
|
+
module2 = Locales__namespace[`${localeSegment1}${localeSegment2}`] ?? Locales__namespace[localeSegment1];
|
|
463
|
+
} else if (localeSegment1) {
|
|
464
|
+
module2 = Locales__namespace[localeSegment1];
|
|
465
|
+
} else {
|
|
466
|
+
module2 = null;
|
|
467
|
+
}
|
|
468
|
+
if (module2) {
|
|
469
|
+
DatePicker.registerLocale(locale, module2);
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
async function changeDayjsLocale(locale) {
|
|
473
|
+
let dayjsLocale = null;
|
|
474
|
+
const [localeSegment1] = locale.split("-");
|
|
475
|
+
if (isLocaleSupported(locale.toLowerCase())) {
|
|
476
|
+
dayjsLocale = locale.toLowerCase();
|
|
477
|
+
} else if (isLocaleSupported(localeSegment1.toLowerCase())) {
|
|
478
|
+
dayjsLocale = localeSegment1.toLowerCase();
|
|
479
|
+
}
|
|
480
|
+
if (dayjsLocale) {
|
|
481
|
+
dayjs.locale(dayjsLocale);
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
function isInputValid(value, pattern) {
|
|
485
|
+
if (value == null || value === "") {
|
|
486
|
+
return true;
|
|
487
|
+
}
|
|
488
|
+
if (typeof value === "number") {
|
|
489
|
+
return !isNaN(value);
|
|
490
|
+
}
|
|
491
|
+
if (typeof value === "string") {
|
|
492
|
+
return dayjs(value, pattern, true).isValid();
|
|
493
|
+
}
|
|
494
|
+
return false;
|
|
495
|
+
}
|
|
496
|
+
function inputToDate(value, pattern, timezone2) {
|
|
497
|
+
if (typeof value === "number" && !Number.isNaN(value)) {
|
|
498
|
+
return new Date(value);
|
|
499
|
+
}
|
|
500
|
+
if (typeof value === "string" && dayjs(value, pattern, true).isValid()) {
|
|
501
|
+
return dayjs.tz(value, pattern, timezone2).toDate();
|
|
502
|
+
}
|
|
503
|
+
return null;
|
|
504
|
+
}
|
|
505
|
+
function inputToTzDate(value, pattern, timezone2) {
|
|
506
|
+
if (typeof value === "number") {
|
|
507
|
+
return dayjs.tz(value, timezone2);
|
|
508
|
+
}
|
|
509
|
+
if (typeof value === "string" && dayjs(value, pattern, true).isValid()) {
|
|
510
|
+
return dayjs.tz(value, pattern, timezone2);
|
|
511
|
+
}
|
|
512
|
+
return null;
|
|
513
|
+
}
|
|
514
|
+
const DateInput = React.forwardRef(
|
|
515
|
+
({ value, clearable, inline, readOnly, wrapperClassName, onChange, locale, timezone: timezone2, ...otherProps }, ref) => {
|
|
516
|
+
const [pattern, setPattern] = React.useState(dayjs.localeData().longDateFormat("L"));
|
|
517
|
+
const { t } = useTranslation();
|
|
518
|
+
const [valid, setValid] = React.useState(false);
|
|
519
|
+
const [popupOpen, setPopupOpen] = React.useState(false);
|
|
520
|
+
const [inputText, setInputText] = React.useState("");
|
|
521
|
+
const debouncedSetPopupActive = React.useMemo(() => lodash.debounce(setPopupOpen, 30), []);
|
|
522
|
+
React.useEffect(() => {
|
|
523
|
+
const language = locale ?? i18n.language;
|
|
524
|
+
if (language) {
|
|
525
|
+
registerLanguage(language);
|
|
526
|
+
changeDayjsLocale(language).then(() => setPattern(dayjs.localeData().longDateFormat("L")));
|
|
527
|
+
}
|
|
528
|
+
}, [locale]);
|
|
529
|
+
const formattedDate = React.useCallback(
|
|
530
|
+
(value2) => {
|
|
531
|
+
if (value2 == null || value2 == "") {
|
|
532
|
+
return "";
|
|
533
|
+
} else if (!isInputValid(value2, pattern)) {
|
|
534
|
+
return t("dateInput.invalidDate", {
|
|
535
|
+
defaultValue: "invalid date"
|
|
536
|
+
});
|
|
537
|
+
} else {
|
|
538
|
+
return typeof value2 === "number" ? dayjs.tz(value2, timezone2).format(pattern) : value2;
|
|
539
|
+
}
|
|
540
|
+
},
|
|
541
|
+
[pattern, t, timezone2]
|
|
542
|
+
);
|
|
543
|
+
React.useEffect(() => {
|
|
544
|
+
if (value == null) {
|
|
545
|
+
setInputText("");
|
|
546
|
+
} else {
|
|
547
|
+
setInputText(formattedDate(value));
|
|
548
|
+
}
|
|
549
|
+
}, [formattedDate, value]);
|
|
550
|
+
React.useEffect(() => {
|
|
551
|
+
setValid(isInputValid(value, pattern));
|
|
552
|
+
}, [pattern, value]);
|
|
553
|
+
React.useEffect(() => {
|
|
554
|
+
dayjs.locale(locale ?? i18n.language);
|
|
555
|
+
setPattern(dayjs.localeData().longDateFormat("L"));
|
|
556
|
+
}, [locale]);
|
|
557
|
+
const handleInputTextChange = (text) => {
|
|
558
|
+
setInputText(text);
|
|
559
|
+
if (text) {
|
|
560
|
+
const valid2 = dayjs(text, pattern, true).isValid();
|
|
561
|
+
if (valid2) {
|
|
562
|
+
const prevDate = inputToTzDate(value, pattern, timezone2);
|
|
563
|
+
const newDate = dayjs.tz(text, pattern, timezone2 ?? dayjs.tz.guess());
|
|
564
|
+
if (prevDate) {
|
|
565
|
+
newDate.set("hour", prevDate.hour());
|
|
566
|
+
newDate.set("minute", prevDate.minute());
|
|
567
|
+
newDate.set("second", prevDate.second());
|
|
568
|
+
newDate.set("millisecond", prevDate.millisecond());
|
|
569
|
+
}
|
|
570
|
+
onChange(newDate.valueOf(), true);
|
|
571
|
+
}
|
|
572
|
+
setValid(valid2);
|
|
573
|
+
} else {
|
|
574
|
+
onChange(null, true);
|
|
575
|
+
setValid(true);
|
|
576
|
+
}
|
|
577
|
+
};
|
|
578
|
+
const handlePickerChange = (date) => {
|
|
579
|
+
onChange(date ? date.valueOf() : null);
|
|
580
|
+
setInputText(formattedDate(date ? date.getTime() : null));
|
|
581
|
+
setPopupOpen(false);
|
|
582
|
+
};
|
|
583
|
+
const handleClear = () => handleInputTextChange("");
|
|
584
|
+
if (inline) {
|
|
585
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
586
|
+
DatePicker,
|
|
587
|
+
{
|
|
588
|
+
...otherProps,
|
|
589
|
+
onChange: handlePickerChange,
|
|
590
|
+
selected: inputToDate(value, pattern, timezone2),
|
|
591
|
+
locale: locale ?? i18n.language,
|
|
592
|
+
isClearable: clearable,
|
|
593
|
+
placeholderText: pattern,
|
|
594
|
+
className: cx("date", { invalid: !valid }),
|
|
595
|
+
inline: true
|
|
596
|
+
}
|
|
597
|
+
);
|
|
598
|
+
}
|
|
599
|
+
if (readOnly) {
|
|
600
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
601
|
+
DatePicker,
|
|
602
|
+
{
|
|
603
|
+
...otherProps,
|
|
604
|
+
onChange: () => {
|
|
605
|
+
},
|
|
606
|
+
selected: inputToDate(value, pattern, timezone2),
|
|
607
|
+
locale: locale ?? i18n.language,
|
|
608
|
+
customInput: /* @__PURE__ */ jsxRuntime.jsx("span", { children: /* @__PURE__ */ jsxRuntime.jsx("input", { type: "text", value: formattedDate(value), readOnly: true }) }),
|
|
609
|
+
placeholderText: pattern,
|
|
610
|
+
readOnly: true
|
|
611
|
+
}
|
|
612
|
+
);
|
|
613
|
+
}
|
|
614
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
615
|
+
ngUiBasicComponents.Popup,
|
|
616
|
+
{
|
|
617
|
+
handler: /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "di date-input-wrapper", children: [
|
|
618
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
619
|
+
"input",
|
|
620
|
+
{
|
|
621
|
+
ref,
|
|
622
|
+
"data-testid": "date-input",
|
|
623
|
+
className: cx("date", { invalid: !valid }),
|
|
624
|
+
onChange: (e) => handleInputTextChange(e.target.value),
|
|
625
|
+
value: inputText,
|
|
626
|
+
placeholder: pattern,
|
|
627
|
+
onBlur: () => {
|
|
628
|
+
handleInputTextChange(formattedDate(value));
|
|
629
|
+
debouncedSetPopupActive(false);
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
),
|
|
633
|
+
clearable && /* @__PURE__ */ jsxRuntime.jsx(ngUiBasicComponents.Button, { naked: true, small: true, onClick: handleClear, children: /* @__PURE__ */ jsxRuntime.jsx(ngUiBasicComponents.Icon, { del: true }) })
|
|
634
|
+
] }),
|
|
635
|
+
mode: ["click", "focus"],
|
|
636
|
+
className: "date-input",
|
|
637
|
+
handlerWrapperClassName: wrapperClassName,
|
|
638
|
+
open: popupOpen,
|
|
639
|
+
onOpenChange: setPopupOpen,
|
|
640
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
641
|
+
"div",
|
|
642
|
+
{
|
|
643
|
+
className: "di date-picker-popup-wrapper",
|
|
644
|
+
tabIndex: 0,
|
|
645
|
+
onFocus: () => {
|
|
646
|
+
debouncedSetPopupActive(true);
|
|
647
|
+
},
|
|
648
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
649
|
+
DatePicker,
|
|
650
|
+
{
|
|
651
|
+
...otherProps,
|
|
652
|
+
selected: inputToDate(value, pattern, timezone2),
|
|
653
|
+
onChange: handlePickerChange,
|
|
654
|
+
locale: locale ?? i18n.language,
|
|
655
|
+
isClearable: clearable,
|
|
656
|
+
placeholderText: pattern,
|
|
657
|
+
className: cx("date", { invalid: !valid }),
|
|
658
|
+
inline: true
|
|
659
|
+
}
|
|
660
|
+
)
|
|
661
|
+
}
|
|
662
|
+
)
|
|
663
|
+
}
|
|
664
|
+
);
|
|
665
|
+
}
|
|
666
|
+
);
|
|
667
|
+
class UrnInput extends React__namespace.Component {
|
|
668
|
+
constructor() {
|
|
669
|
+
super(...arguments);
|
|
670
|
+
this.state = {
|
|
671
|
+
editMode: false
|
|
672
|
+
};
|
|
673
|
+
this.handleEdit = () => this.setState({
|
|
674
|
+
editMode: true
|
|
675
|
+
});
|
|
676
|
+
this.handleChangeValue = (event) => this.props.onChange(event.target.value);
|
|
677
|
+
}
|
|
678
|
+
render() {
|
|
679
|
+
const { editMode } = this.state;
|
|
680
|
+
const { value } = this.props;
|
|
681
|
+
if (editMode) {
|
|
682
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
683
|
+
"input",
|
|
684
|
+
{
|
|
685
|
+
value,
|
|
686
|
+
onChange: this.handleChangeValue,
|
|
687
|
+
autoCorrect: "off",
|
|
688
|
+
spellCheck: "false",
|
|
689
|
+
autoComplete: "off"
|
|
690
|
+
}
|
|
691
|
+
);
|
|
692
|
+
} else {
|
|
693
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
|
|
694
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
695
|
+
"span",
|
|
696
|
+
{
|
|
697
|
+
style: {
|
|
698
|
+
marginRight: 10
|
|
699
|
+
},
|
|
700
|
+
children: value
|
|
701
|
+
}
|
|
702
|
+
),
|
|
703
|
+
/* @__PURE__ */ jsxRuntime.jsx(ngUiBasicComponents.Button, { small: true, onClick: this.handleEdit, children: /* @__PURE__ */ jsxRuntime.jsx(ngUiBasicComponents.Icon, { edit: true }) })
|
|
704
|
+
] });
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
function Prompt({
|
|
709
|
+
title,
|
|
710
|
+
message,
|
|
711
|
+
onAccept,
|
|
712
|
+
onCancel,
|
|
713
|
+
inputPlaceholder,
|
|
714
|
+
cancelButtonLabel,
|
|
715
|
+
acceptButtonLabel
|
|
716
|
+
}) {
|
|
717
|
+
const { t } = useTranslation();
|
|
718
|
+
const inputRef = React.useRef(null);
|
|
719
|
+
const [value, setValue] = React.useState("");
|
|
720
|
+
React.useEffect(() => {
|
|
721
|
+
inputRef.current?.focus();
|
|
722
|
+
});
|
|
723
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
724
|
+
ngUiBasicComponents.Modal,
|
|
725
|
+
{
|
|
726
|
+
header: t(title.id, {
|
|
727
|
+
defaultValue: title.defaultValue
|
|
728
|
+
}),
|
|
729
|
+
content: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "di form", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "field", children: [
|
|
730
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { children: /* @__PURE__ */ jsxRuntime.jsx(Trans, { i18nKey: message.id, children: message.defaultValue }) }),
|
|
731
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
732
|
+
"input",
|
|
733
|
+
{
|
|
734
|
+
type: "text",
|
|
735
|
+
style: {
|
|
736
|
+
width: 250
|
|
737
|
+
},
|
|
738
|
+
ref: inputRef,
|
|
739
|
+
placeholder: inputPlaceholder ? t(inputPlaceholder.id, {
|
|
740
|
+
defaultValue: inputPlaceholder.defaultValue
|
|
741
|
+
}) : void 0,
|
|
742
|
+
onChange: (event) => setValue(event.target.value)
|
|
743
|
+
}
|
|
744
|
+
)
|
|
745
|
+
] }) }),
|
|
746
|
+
footer: /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
747
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
748
|
+
ngUiBasicComponents.Button,
|
|
749
|
+
{
|
|
750
|
+
primary: true,
|
|
751
|
+
onClick: () => {
|
|
752
|
+
onAccept(value);
|
|
753
|
+
},
|
|
754
|
+
disabled: !value.length,
|
|
755
|
+
children: acceptButtonLabel ? /* @__PURE__ */ jsxRuntime.jsx(Trans, { i18nKey: acceptButtonLabel.id, children: acceptButtonLabel.defaultValue }) : /* @__PURE__ */ jsxRuntime.jsx(Trans, { i18nKey: "form.accept", children: "Accept" })
|
|
756
|
+
}
|
|
757
|
+
),
|
|
758
|
+
/* @__PURE__ */ jsxRuntime.jsx(ngUiBasicComponents.Button, { onClick: onCancel, children: cancelButtonLabel ? /* @__PURE__ */ jsxRuntime.jsx(Trans, { i18nKey: cancelButtonLabel.id, children: cancelButtonLabel.defaultValue }) : /* @__PURE__ */ jsxRuntime.jsx(Trans, { i18nKey: "form.cancel", children: "Cancel" }) })
|
|
759
|
+
] }),
|
|
760
|
+
width: 600
|
|
761
|
+
}
|
|
762
|
+
);
|
|
763
|
+
}
|
|
764
|
+
function withPrompt(WrappedComponent) {
|
|
765
|
+
return class WithPromptWrapper extends React__namespace.Component {
|
|
766
|
+
constructor() {
|
|
767
|
+
super(...arguments);
|
|
768
|
+
this.state = {
|
|
769
|
+
show: false
|
|
770
|
+
};
|
|
771
|
+
this.prompt = (title, message, inputPlaceholder, acceptButtonLabel, cancelButtonLabel) => new Promise((resolve) => {
|
|
772
|
+
this.setState({
|
|
773
|
+
show: true,
|
|
774
|
+
promptElement: /* @__PURE__ */ jsxRuntime.jsx(
|
|
775
|
+
Prompt,
|
|
776
|
+
{
|
|
777
|
+
title,
|
|
778
|
+
message,
|
|
779
|
+
onAccept: (value) => {
|
|
780
|
+
this.setState({
|
|
781
|
+
show: false
|
|
782
|
+
});
|
|
783
|
+
resolve(value);
|
|
784
|
+
},
|
|
785
|
+
onCancel: () => {
|
|
786
|
+
this.setState({
|
|
787
|
+
show: false
|
|
788
|
+
});
|
|
789
|
+
},
|
|
790
|
+
inputPlaceholder,
|
|
791
|
+
acceptButtonLabel,
|
|
792
|
+
cancelButtonLabel
|
|
793
|
+
},
|
|
794
|
+
"1"
|
|
795
|
+
)
|
|
796
|
+
});
|
|
797
|
+
});
|
|
798
|
+
}
|
|
799
|
+
render() {
|
|
800
|
+
return [
|
|
801
|
+
/* @__PURE__ */ React.createElement(WrappedComponent, { ...this.props, prompt: this.prompt, key: "0" }),
|
|
802
|
+
this.state.show ? this.state.promptElement : null
|
|
803
|
+
];
|
|
804
|
+
}
|
|
805
|
+
};
|
|
806
|
+
}
|
|
807
|
+
const isModifiedEvent = (event) => !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
|
|
808
|
+
function RouteLink({ to, confirm, className, title, children, keyboardShortcut, ...otherProps }) {
|
|
809
|
+
const history = reactRouterDom.useHistory();
|
|
810
|
+
const { t } = useTranslation();
|
|
811
|
+
const pushRoute = React.useCallback(() => {
|
|
812
|
+
if (confirm) {
|
|
813
|
+
confirm().then((location) => history.push(location || to)).catch(() => {
|
|
814
|
+
});
|
|
815
|
+
} else {
|
|
816
|
+
history.push(to);
|
|
817
|
+
}
|
|
818
|
+
}, [confirm, history, to]);
|
|
819
|
+
const handleKeyEvent = React.useCallback(
|
|
820
|
+
(event) => {
|
|
821
|
+
if (keyboardShortcut && event.key === keyboardShortcut && !isModifiedEvent(event) && // @ts-ignore EventTarget is a Node and has a tagName
|
|
822
|
+
event.target.tagName && // @ts-ignore EventTarget is a Node and has a tagName
|
|
823
|
+
!["INPUT", "SELECT", "TEXTAREA"].includes(event.target.tagName)) {
|
|
824
|
+
event.preventDefault();
|
|
825
|
+
pushRoute();
|
|
826
|
+
}
|
|
827
|
+
},
|
|
828
|
+
[keyboardShortcut, pushRoute]
|
|
829
|
+
);
|
|
830
|
+
React.useEffect(() => {
|
|
831
|
+
if (keyboardShortcut) {
|
|
832
|
+
window.addEventListener("keydown", handleKeyEvent);
|
|
833
|
+
return () => {
|
|
834
|
+
window.removeEventListener("keydown", handleKeyEvent);
|
|
835
|
+
};
|
|
836
|
+
}
|
|
837
|
+
}, [keyboardShortcut, handleKeyEvent]);
|
|
838
|
+
const handleClickEvent = (event) => {
|
|
839
|
+
if (event.button === 0 && !isModifiedEvent(event)) {
|
|
840
|
+
event.preventDefault();
|
|
841
|
+
pushRoute();
|
|
842
|
+
}
|
|
843
|
+
};
|
|
844
|
+
const href = history.createHref(typeof to === "string" ? { pathname: to } : to);
|
|
845
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
846
|
+
"a",
|
|
847
|
+
{
|
|
848
|
+
href,
|
|
849
|
+
onClick: handleClickEvent,
|
|
850
|
+
className: `di route-link ${className || ""}`,
|
|
851
|
+
title: title ? t(title.id, {
|
|
852
|
+
defaultValue: title.defaultValue
|
|
853
|
+
}) : void 0,
|
|
854
|
+
...otherProps,
|
|
855
|
+
children
|
|
856
|
+
}
|
|
857
|
+
);
|
|
858
|
+
}
|
|
859
|
+
const colors = {
|
|
860
|
+
info: "#ffffff",
|
|
861
|
+
success: "#cce0cc",
|
|
862
|
+
warning: "#fed254",
|
|
863
|
+
error: "#d66961"
|
|
864
|
+
};
|
|
865
|
+
function InfoBox({ type = "info", hideable = false, className, icon, message: inputMessage, children }) {
|
|
866
|
+
const [visible, setVisible] = React.useState(true);
|
|
867
|
+
const { t } = useTranslation();
|
|
868
|
+
function getMessage() {
|
|
869
|
+
if (typeof inputMessage !== "string") {
|
|
870
|
+
const { id, defaultValue, ...rest } = inputMessage;
|
|
871
|
+
return t(id, { ...rest, defaultValue });
|
|
872
|
+
}
|
|
873
|
+
return inputMessage;
|
|
874
|
+
}
|
|
875
|
+
const message = getMessage();
|
|
876
|
+
return visible ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `infobox ${className ? className : ""}`, children: [
|
|
877
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
878
|
+
"div",
|
|
879
|
+
{
|
|
880
|
+
className: "infobox-header",
|
|
881
|
+
style: {
|
|
882
|
+
backgroundColor: colors[type]
|
|
883
|
+
},
|
|
884
|
+
children: [
|
|
885
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "infobox-header-content", children: [
|
|
886
|
+
icon && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "infobox-iconcontainer", children: /* @__PURE__ */ jsxRuntime.jsx("img", { src: icon, alt: "info-icon", style: { width: 16, height: 16 } }) }),
|
|
887
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "infobox-message", children: message })
|
|
888
|
+
] }),
|
|
889
|
+
hideable && /* @__PURE__ */ jsxRuntime.jsx("button", { className: "infobox-closebutton", onClick: () => setVisible(false), children: /* @__PURE__ */ jsxRuntime.jsx(ngUiBasicComponents.Icon, { del: true, large: true }) })
|
|
890
|
+
]
|
|
891
|
+
}
|
|
892
|
+
),
|
|
893
|
+
children
|
|
894
|
+
] }) : null;
|
|
895
|
+
}
|
|
896
|
+
const CSS = /* @__PURE__ */ Object.freeze({
|
|
897
|
+
Translate: {
|
|
898
|
+
toString(transform) {
|
|
899
|
+
if (!transform) {
|
|
900
|
+
return;
|
|
901
|
+
}
|
|
902
|
+
const {
|
|
903
|
+
x,
|
|
904
|
+
y
|
|
905
|
+
} = transform;
|
|
906
|
+
return "translate3d(" + (x ? Math.round(x) : 0) + "px, " + (y ? Math.round(y) : 0) + "px, 0)";
|
|
907
|
+
}
|
|
908
|
+
},
|
|
909
|
+
Scale: {
|
|
910
|
+
toString(transform) {
|
|
911
|
+
if (!transform) {
|
|
912
|
+
return;
|
|
913
|
+
}
|
|
914
|
+
const {
|
|
915
|
+
scaleX,
|
|
916
|
+
scaleY
|
|
917
|
+
} = transform;
|
|
918
|
+
return "scaleX(" + scaleX + ") scaleY(" + scaleY + ")";
|
|
919
|
+
}
|
|
920
|
+
},
|
|
921
|
+
Transform: {
|
|
922
|
+
toString(transform) {
|
|
923
|
+
if (!transform) {
|
|
924
|
+
return;
|
|
925
|
+
}
|
|
926
|
+
return [CSS.Translate.toString(transform), CSS.Scale.toString(transform)].join(" ");
|
|
927
|
+
}
|
|
928
|
+
},
|
|
929
|
+
Transition: {
|
|
930
|
+
toString(_ref) {
|
|
931
|
+
let {
|
|
932
|
+
property,
|
|
933
|
+
duration,
|
|
934
|
+
easing
|
|
935
|
+
} = _ref;
|
|
936
|
+
return property + " " + duration + "ms " + easing;
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
});
|
|
940
|
+
function resolvePath(basePath, match) {
|
|
941
|
+
const divider = basePath.endsWith("/") ? "" : "/";
|
|
942
|
+
return `${basePath}${divider}${match}`;
|
|
943
|
+
}
|
|
944
|
+
const TabHeader = ({
|
|
945
|
+
id,
|
|
946
|
+
to,
|
|
947
|
+
className,
|
|
948
|
+
title,
|
|
949
|
+
children,
|
|
950
|
+
draggingDisabled
|
|
951
|
+
}) => {
|
|
952
|
+
const { attributes, listeners, setNodeRef, transform, transition } = sortable.useSortable({
|
|
953
|
+
id,
|
|
954
|
+
disabled: draggingDisabled,
|
|
955
|
+
strategy: sortable.horizontalListSortingStrategy
|
|
956
|
+
});
|
|
957
|
+
const style = {
|
|
958
|
+
transform: transform ? CSS.Transform.toString({ ...transform, scaleX: 1 }) : void 0,
|
|
959
|
+
transition
|
|
960
|
+
};
|
|
961
|
+
const { pathname } = reactRouterDom.useLocation();
|
|
962
|
+
const isActive = pathname.endsWith(to.toString());
|
|
963
|
+
if (isActive) {
|
|
964
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
965
|
+
"button",
|
|
966
|
+
{
|
|
967
|
+
"data-testid": "tab-button",
|
|
968
|
+
className: cx("tab-header item active", className),
|
|
969
|
+
title,
|
|
970
|
+
ref: setNodeRef,
|
|
971
|
+
style,
|
|
972
|
+
type: "button",
|
|
973
|
+
...attributes,
|
|
974
|
+
...listeners,
|
|
975
|
+
children
|
|
976
|
+
}
|
|
977
|
+
);
|
|
978
|
+
}
|
|
979
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
980
|
+
reactRouterDom.Link,
|
|
981
|
+
{
|
|
982
|
+
"data-testid": "tab-button",
|
|
983
|
+
to,
|
|
984
|
+
title,
|
|
985
|
+
className: cx("tab-header item", className),
|
|
986
|
+
ref: setNodeRef,
|
|
987
|
+
style,
|
|
988
|
+
...attributes,
|
|
989
|
+
...listeners,
|
|
990
|
+
children
|
|
991
|
+
}
|
|
992
|
+
);
|
|
993
|
+
};
|
|
994
|
+
function RouteTabs({ pages, onOrderChange, basePath, ...otherProps }) {
|
|
995
|
+
const [dragging, setDragging] = React.useState(false);
|
|
996
|
+
const { pathname, state } = reactRouterDom.useLocation();
|
|
997
|
+
function determineBasePath() {
|
|
998
|
+
const lastPathSegment = pathname.split("/").reverse()[0];
|
|
999
|
+
if (pages.some((page) => page.path === lastPathSegment)) {
|
|
1000
|
+
return pathname.substring(0, pathname.lastIndexOf("/"));
|
|
1001
|
+
} else {
|
|
1002
|
+
return pathname;
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
function handleDragEnd(event) {
|
|
1006
|
+
setDragging(false);
|
|
1007
|
+
const { active, over } = event;
|
|
1008
|
+
if (active.id !== over?.id && onOrderChange) {
|
|
1009
|
+
const oldIndex = pages.findIndex((page) => page.path === active.id);
|
|
1010
|
+
const newIndex = pages.findIndex((page) => page.path === over?.id);
|
|
1011
|
+
onOrderChange(oldIndex, newIndex);
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: dragging ? "draggable-area" : "", children: [
|
|
1015
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1016
|
+
core.DndContext,
|
|
1017
|
+
{
|
|
1018
|
+
collisionDetection: core.closestCenter,
|
|
1019
|
+
onDragEnd: handleDragEnd,
|
|
1020
|
+
onDragStart: () => setDragging(true),
|
|
1021
|
+
modifiers: [modifiers.restrictToHorizontalAxis],
|
|
1022
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "di tabs", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1023
|
+
sortable.SortableContext,
|
|
1024
|
+
{
|
|
1025
|
+
items: pages.map((page) => ({ ...page, id: page.path })),
|
|
1026
|
+
strategy: sortable.horizontalListSortingStrategy,
|
|
1027
|
+
children: pages.map(({ path, renderHeading, headingTitle, draggingDisabled, disabled: pageDisabled }) => {
|
|
1028
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1029
|
+
TabHeader,
|
|
1030
|
+
{
|
|
1031
|
+
id: path,
|
|
1032
|
+
to: resolvePath(basePath || determineBasePath(), path),
|
|
1033
|
+
title: headingTitle,
|
|
1034
|
+
draggingDisabled: pageDisabled || draggingDisabled || !onOrderChange || !dragging && !pathname.endsWith(path),
|
|
1035
|
+
children: renderHeading(otherProps)
|
|
1036
|
+
},
|
|
1037
|
+
path
|
|
1038
|
+
);
|
|
1039
|
+
})
|
|
1040
|
+
}
|
|
1041
|
+
) })
|
|
1042
|
+
}
|
|
1043
|
+
),
|
|
1044
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactRouterDom.Switch, { children: [
|
|
1045
|
+
pages.map(({ renderBody, path }) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1046
|
+
reactRouterDom.Route,
|
|
1047
|
+
{
|
|
1048
|
+
path: resolvePath(basePath || determineBasePath(), path),
|
|
1049
|
+
render: () => renderBody(otherProps)
|
|
1050
|
+
},
|
|
1051
|
+
path
|
|
1052
|
+
)),
|
|
1053
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Route, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1054
|
+
reactRouterDom.Redirect,
|
|
1055
|
+
{
|
|
1056
|
+
to: {
|
|
1057
|
+
pathname: resolvePath(basePath || determineBasePath(), pages[0].path),
|
|
1058
|
+
state
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
) })
|
|
1062
|
+
] })
|
|
1063
|
+
] });
|
|
1064
|
+
}
|
|
1065
|
+
const defaultIconFolderOpen = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAMZJREFUeNpi/P//PwMtARMDjcHQt4ABGgchQPwKxMWBzwKxKFlmQy14g8dwGL5MqiXIFvynEgb5VJmWFoDwImQLWNB8pQ/EjyiM1j/IHHQLPgHxB3ok00dUCKpnuCzQAmJZKjh+Jy4L3KkUOjgtcKNG/gXi3cg5GRZuGkD8jQrhfwpmNroPbIGYkwo+2IErFXlQKfx3oRd2MK99oELwfIDlL+Qgegul+ang+u0ouRnqg0ACxTWx+CIQKyGbzThaJw+4BQABBgBH38BkTQm7ZwAAAABJRU5ErkJggg==";
|
|
1066
|
+
const defaultIconFolderClosed = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAGpJREFUeNpi/P//PwMtARMDjcHQt4ABFAfQeAgH4jcgIRy4gyxzkSzAZzjJlmCz4D+VMMih4TBzGWHJlJGRkZrp9S3QXBGwuTSyAOR6xtF8MGrBqAUDYMFbahYV5BTXlBV2o5E8YBYABBgAxQJ9mxTaZMQAAAAASUVORK5CYII=";
|
|
1067
|
+
const defaultIconFolderLoading = "data:image/svg+xml,%3csvg%20version='1.1'%20id='Layer_1'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20x='0px'%20y='0px'%20width='24px'%20height='24px'%20viewBox='0%200%2024%2024'%20style='enable-background:new%200%200%2050%2050;'%20xml:space='preserve'%3e%3crect%20x='0'%20y='0'%20width='5'%20height='10'%20fill='%23000'%3e%3canimateTransform%20attributeType='xml'%20attributeName='transform'%20type='translate'%20values='0%200;%200%2014;%200%200'%20begin='0'%20dur='0.6s'%20repeatCount='indefinite'%20/%3e%3c/rect%3e%3crect%20x='9'%20y='0'%20width='5'%20height='10'%20fill='%23000'%3e%3canimateTransform%20attributeType='xml'%20attributeName='transform'%20type='translate'%20values='0%200;%200%2014;%200%200'%20begin='0.2s'%20dur='0.6s'%20repeatCount='indefinite'%20/%3e%3c/rect%3e%3crect%20x='19'%20y='0'%20width='5'%20height='10'%20fill='%23000'%3e%3canimateTransform%20attributeType='xml'%20attributeName='transform'%20type='translate'%20values='0%200;%200%2014;%200%200'%20begin='0.4s'%20dur='0.6s'%20repeatCount='indefinite'%20/%3e%3c/rect%3e%3c/svg%3e";
|
|
1068
|
+
const defaultIconLeafNode = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyZpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMTM4IDc5LjE1OTgyNCwgMjAxNi8wOS8xNC0wMTowOTowMSAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENDIDIwMTcgKFdpbmRvd3MpIiB4bXBNTTpJbnN0YW5jZUlEPSJ4bXAuaWlkOjIwNDI3RTg2NEQxQjExRTc4OEM3RTkwQjYwNjA2OTk5IiB4bXBNTTpEb2N1bWVudElEPSJ4bXAuZGlkOjIwNDI3RTg3NEQxQjExRTc4OEM3RTkwQjYwNjA2OTk5Ij4gPHhtcE1NOkRlcml2ZWRGcm9tIHN0UmVmOmluc3RhbmNlSUQ9InhtcC5paWQ6MjA0MjdFODQ0RDFCMTFFNzg4QzdFOTBCNjA2MDY5OTkiIHN0UmVmOmRvY3VtZW50SUQ9InhtcC5kaWQ6MjA0MjdFODU0RDFCMTFFNzg4QzdFOTBCNjA2MDY5OTkiLz4gPC9yZGY6RGVzY3JpcHRpb24+IDwvcmRmOlJERj4gPC94OnhtcG1ldGE+IDw/eHBhY2tldCBlbmQ9InIiPz5FrZPxAAAA5UlEQVR42qzTvQ7BUBTA8UpEYraJWAwSNVgMHsDIZvUEngWDisTiBTyA4A3EJEiMYrBJGBBf/yO3UlVNq07y63Cbc3rvuaea9hkZ1LHAUZmrtYzmEhG0cMX9C3nXQdQpeeiSaDdSOa8wfCSbWmayjssPBSRHD/EoqzMtscEeN8SQQwVVhB361pRHDX1VYGf5whZjlJDHymEXclPaycN2e4hjYFs/eS0gJkiibVmT4z634bVxaxRQxBQzKdDw2X0Zpi7SSEiBbIBrTAUZJOOvoxz4Z7KGriZMBuuMg+p2U/XrLR4CDACHu7RW+98pzwAAAABJRU5ErkJggg==";
|
|
1069
|
+
var SelectionState = /* @__PURE__ */ ((SelectionState2) => {
|
|
1070
|
+
SelectionState2["ALL"] = "all";
|
|
1071
|
+
SelectionState2["SOME"] = "some";
|
|
1072
|
+
SelectionState2["NONE"] = "none";
|
|
1073
|
+
return SelectionState2;
|
|
1074
|
+
})(SelectionState || {});
|
|
1075
|
+
const Skeleton = ({ lastChild }) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "skeleton", children: [
|
|
1076
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "skeleton-cell top" }),
|
|
1077
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1078
|
+
"div",
|
|
1079
|
+
{
|
|
1080
|
+
className: "skeleton-cell bottom",
|
|
1081
|
+
style: {
|
|
1082
|
+
visibility: lastChild ? "hidden" : "initial"
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
)
|
|
1086
|
+
] });
|
|
1087
|
+
const NodeImage = ({ node, leafNode, expanded, isLoading, onExpand }) => {
|
|
1088
|
+
let imageSrc;
|
|
1089
|
+
if (leafNode) {
|
|
1090
|
+
imageSrc = node.image || defaultIconLeafNode;
|
|
1091
|
+
} else {
|
|
1092
|
+
if (isLoading) {
|
|
1093
|
+
imageSrc = defaultIconFolderLoading;
|
|
1094
|
+
} else if (expanded) {
|
|
1095
|
+
imageSrc = node.expandedImage || defaultIconFolderOpen;
|
|
1096
|
+
} else {
|
|
1097
|
+
imageSrc = node.closedImage || defaultIconFolderClosed;
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
1100
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "icon-container", children: /* @__PURE__ */ jsxRuntime.jsx("img", { src: imageSrc, alt: "node", onClick: onExpand }) });
|
|
1101
|
+
};
|
|
1102
|
+
class NodeInfo extends React__namespace.PureComponent {
|
|
1103
|
+
constructor() {
|
|
1104
|
+
super(...arguments);
|
|
1105
|
+
this.onSelect = (event) => {
|
|
1106
|
+
const { onSelect, selectionState } = this.props;
|
|
1107
|
+
onSelect(selectionState === SelectionState.SOME ? false : event.currentTarget.checked);
|
|
1108
|
+
};
|
|
1109
|
+
this.onLabelClick = () => {
|
|
1110
|
+
const { onSelect, selectionState } = this.props;
|
|
1111
|
+
onSelect(selectionState === SelectionState.SOME ? false : this.inputRef ? !this.inputRef.checked : false);
|
|
1112
|
+
};
|
|
1113
|
+
}
|
|
1114
|
+
componentDidMount() {
|
|
1115
|
+
this.updateSelectionState();
|
|
1116
|
+
}
|
|
1117
|
+
componentDidUpdate() {
|
|
1118
|
+
this.updateSelectionState();
|
|
1119
|
+
}
|
|
1120
|
+
updateSelectionState() {
|
|
1121
|
+
const { selectionState } = this.props;
|
|
1122
|
+
if (this.inputRef) {
|
|
1123
|
+
this.inputRef.indeterminate = selectionState === SelectionState.SOME;
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1126
|
+
render() {
|
|
1127
|
+
const {
|
|
1128
|
+
node,
|
|
1129
|
+
node: { name },
|
|
1130
|
+
leafNode,
|
|
1131
|
+
expanded,
|
|
1132
|
+
isLastChild,
|
|
1133
|
+
onExpand,
|
|
1134
|
+
selectionState,
|
|
1135
|
+
isLoading
|
|
1136
|
+
} = this.props;
|
|
1137
|
+
const selected = selectionState === SelectionState.ALL;
|
|
1138
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `node-info ${selected ? "selected" : ""}`, children: [
|
|
1139
|
+
isLastChild !== void 0 && /* @__PURE__ */ jsxRuntime.jsx(Skeleton, { lastChild: isLastChild }),
|
|
1140
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1141
|
+
NodeImage,
|
|
1142
|
+
{
|
|
1143
|
+
node,
|
|
1144
|
+
leafNode,
|
|
1145
|
+
expanded,
|
|
1146
|
+
isLoading,
|
|
1147
|
+
onExpand
|
|
1148
|
+
}
|
|
1149
|
+
),
|
|
1150
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1151
|
+
"input",
|
|
1152
|
+
{
|
|
1153
|
+
ref: (ref) => {
|
|
1154
|
+
this.inputRef = ref;
|
|
1155
|
+
},
|
|
1156
|
+
type: "checkbox",
|
|
1157
|
+
checked: selectionState === SelectionState.ALL,
|
|
1158
|
+
onChange: this.onSelect
|
|
1159
|
+
}
|
|
1160
|
+
),
|
|
1161
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "name", onClick: this.onLabelClick, children: name })
|
|
1162
|
+
] });
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
class Node extends React.Component {
|
|
1166
|
+
constructor() {
|
|
1167
|
+
super(...arguments);
|
|
1168
|
+
this.state = {
|
|
1169
|
+
expanded: false,
|
|
1170
|
+
selectionState: this.getSelectionState(),
|
|
1171
|
+
isLoading: false
|
|
1172
|
+
};
|
|
1173
|
+
this.toggleExpand = () => {
|
|
1174
|
+
const { node, lazyLoadingFunction } = this.props;
|
|
1175
|
+
if (node.lazyLoadable) {
|
|
1176
|
+
this.setState(
|
|
1177
|
+
{
|
|
1178
|
+
isLoading: true
|
|
1179
|
+
},
|
|
1180
|
+
() => {
|
|
1181
|
+
lazyLoadingFunction(node).then(
|
|
1182
|
+
() => this.setState({
|
|
1183
|
+
expanded: true,
|
|
1184
|
+
isLoading: false
|
|
1185
|
+
})
|
|
1186
|
+
);
|
|
1187
|
+
}
|
|
1188
|
+
);
|
|
1189
|
+
} else {
|
|
1190
|
+
this.setState({
|
|
1191
|
+
expanded: !this.state.expanded
|
|
1192
|
+
});
|
|
1193
|
+
}
|
|
1194
|
+
};
|
|
1195
|
+
this.onSelect = (toggled) => {
|
|
1196
|
+
const { node, selectNodes, deselectNodes, selectedNodes } = this.props;
|
|
1197
|
+
if (toggled) {
|
|
1198
|
+
const childNodes = getAllLeaves(node).filter((node2) => !selectedNodes.includes(node2.id));
|
|
1199
|
+
selectNodes(childNodes);
|
|
1200
|
+
} else {
|
|
1201
|
+
const childNodes = getAllLeaves(node).filter((node2) => selectedNodes.includes(node2.id));
|
|
1202
|
+
deselectNodes(childNodes);
|
|
1203
|
+
}
|
|
1204
|
+
};
|
|
1205
|
+
}
|
|
1206
|
+
/**
|
|
1207
|
+
* Update folder nodes only if the selection changed, or expanded changed
|
|
1208
|
+
* Update leaf nodes only if the previously selected nodes include this leaf and the currently
|
|
1209
|
+
* selected nodes do not include this leaf, and vice versa.
|
|
1210
|
+
* @param {Props} prevProps
|
|
1211
|
+
* @param {State} prevState
|
|
1212
|
+
*/
|
|
1213
|
+
shouldComponentUpdate(prevProps, prevState) {
|
|
1214
|
+
const { selectedNodes: prevSelectedNodes, treeSize: prevTreeSize } = prevProps;
|
|
1215
|
+
const { expanded: prevExpanded, selectionState: prevSelectionState, isLoading: prevIsLoading } = prevState;
|
|
1216
|
+
const { selectedNodes, node, treeSize } = this.props;
|
|
1217
|
+
const { expanded, selectionState, isLoading } = this.state;
|
|
1218
|
+
if (prevIsLoading !== isLoading) return true;
|
|
1219
|
+
if (prevTreeSize !== treeSize) return true;
|
|
1220
|
+
if (this.isLeaf()) {
|
|
1221
|
+
const selectionChangedForLeaf = prevSelectedNodes.includes(node.id) && !selectedNodes.includes(node.id) || !prevSelectedNodes.includes(node.id) && selectedNodes.includes(node.id);
|
|
1222
|
+
return selectionChangedForLeaf || prevSelectionState !== selectionState;
|
|
1223
|
+
} else {
|
|
1224
|
+
return prevSelectedNodes.length !== selectedNodes.length || prevExpanded !== expanded || prevSelectionState !== selectionState;
|
|
1225
|
+
}
|
|
1226
|
+
}
|
|
1227
|
+
componentDidMount() {
|
|
1228
|
+
this.setState({
|
|
1229
|
+
selectionState: this.getSelectionState()
|
|
1230
|
+
});
|
|
1231
|
+
}
|
|
1232
|
+
componentDidUpdate() {
|
|
1233
|
+
this.setState({
|
|
1234
|
+
selectionState: this.getSelectionState()
|
|
1235
|
+
});
|
|
1236
|
+
}
|
|
1237
|
+
isLeaf() {
|
|
1238
|
+
const { node } = this.props;
|
|
1239
|
+
return node.children === void 0;
|
|
1240
|
+
}
|
|
1241
|
+
getSelectionState() {
|
|
1242
|
+
const { node, selectedNodes } = this.props;
|
|
1243
|
+
if (this.isLeaf()) {
|
|
1244
|
+
return selectedNodes.includes(node.id) ? SelectionState.ALL : SelectionState.NONE;
|
|
1245
|
+
} else {
|
|
1246
|
+
const leafIds = getAllLeafIds(node);
|
|
1247
|
+
const intersection = intersectArrays(leafIds, selectedNodes);
|
|
1248
|
+
if (intersection.length === leafIds.length && leafIds.length !== 0) {
|
|
1249
|
+
return SelectionState.ALL;
|
|
1250
|
+
} else if (intersection.length === 0) {
|
|
1251
|
+
return SelectionState.NONE;
|
|
1252
|
+
}
|
|
1253
|
+
return SelectionState.SOME;
|
|
1254
|
+
}
|
|
1255
|
+
}
|
|
1256
|
+
render() {
|
|
1257
|
+
const { node, isLastChild, ...commonNodeProps } = this.props;
|
|
1258
|
+
const { expanded, selectionState, isLoading } = this.state;
|
|
1259
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "node", children: [
|
|
1260
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1261
|
+
NodeInfo,
|
|
1262
|
+
{
|
|
1263
|
+
node,
|
|
1264
|
+
displayName: node.name,
|
|
1265
|
+
leafNode: this.isLeaf(),
|
|
1266
|
+
expanded,
|
|
1267
|
+
isLastChild,
|
|
1268
|
+
onExpand: this.toggleExpand,
|
|
1269
|
+
onSelect: this.onSelect,
|
|
1270
|
+
isLoading,
|
|
1271
|
+
selectionState
|
|
1272
|
+
}
|
|
1273
|
+
),
|
|
1274
|
+
expanded && node.children && node.children.map((childNode, i) => /* @__PURE__ */ React.createElement(
|
|
1275
|
+
Node,
|
|
1276
|
+
{
|
|
1277
|
+
...commonNodeProps,
|
|
1278
|
+
key: i,
|
|
1279
|
+
node: childNode,
|
|
1280
|
+
isLastChild: i === (node.children || []).length - 1
|
|
1281
|
+
}
|
|
1282
|
+
))
|
|
1283
|
+
] });
|
|
1284
|
+
}
|
|
1285
|
+
}
|
|
1286
|
+
class TreeView extends React.Component {
|
|
1287
|
+
constructor() {
|
|
1288
|
+
super(...arguments);
|
|
1289
|
+
this.state = {
|
|
1290
|
+
treeData: this.props.treeData,
|
|
1291
|
+
tree: {
|
|
1292
|
+
id: "virtualRootNode",
|
|
1293
|
+
name: "",
|
|
1294
|
+
children: [],
|
|
1295
|
+
path: "/",
|
|
1296
|
+
originalNode: {}
|
|
1297
|
+
},
|
|
1298
|
+
treeSize: 0,
|
|
1299
|
+
selectedNodes: this.props.selectedNodes || []
|
|
1300
|
+
};
|
|
1301
|
+
this.convert = convertToTree(this.props.dataSetConfig);
|
|
1302
|
+
this.selectNodes = (nodes) => {
|
|
1303
|
+
const { onSelect } = this.props;
|
|
1304
|
+
const { selectedNodes } = this.state;
|
|
1305
|
+
this.setState({
|
|
1306
|
+
selectedNodes: mergeNodeIdArrays(
|
|
1307
|
+
selectedNodes,
|
|
1308
|
+
nodes.map(({ id }) => id)
|
|
1309
|
+
)
|
|
1310
|
+
});
|
|
1311
|
+
onSelect(nodes.map(({ originalNode, path }) => ({ ...originalNode, $$path: path })));
|
|
1312
|
+
};
|
|
1313
|
+
this.deselectNodes = (nodes) => {
|
|
1314
|
+
const { onDeselect } = this.props;
|
|
1315
|
+
const { selectedNodes } = this.state;
|
|
1316
|
+
this.setState({
|
|
1317
|
+
selectedNodes: removeNodeIds(
|
|
1318
|
+
selectedNodes,
|
|
1319
|
+
nodes.map(({ id }) => id)
|
|
1320
|
+
)
|
|
1321
|
+
});
|
|
1322
|
+
onDeselect(nodes.map(({ originalNode, path }) => ({ ...originalNode, $$path: path })));
|
|
1323
|
+
};
|
|
1324
|
+
this.addTreeData = (dataSet, underNode) => {
|
|
1325
|
+
const { tree } = this.state;
|
|
1326
|
+
const subTree = this.convert(dataSet, underNode.path);
|
|
1327
|
+
const newTree = {
|
|
1328
|
+
id: "virtualRootNode",
|
|
1329
|
+
name: "",
|
|
1330
|
+
children: (tree.children || []).map(
|
|
1331
|
+
(rootNode) => findNodeAndApplyPatch(rootNode, underNode.id, {
|
|
1332
|
+
lazyLoadable: false,
|
|
1333
|
+
children: subTree
|
|
1334
|
+
})
|
|
1335
|
+
),
|
|
1336
|
+
path: "/",
|
|
1337
|
+
originalNode: {}
|
|
1338
|
+
};
|
|
1339
|
+
const newTreeSize = getTreeSize(newTree);
|
|
1340
|
+
this.setState({
|
|
1341
|
+
tree: newTree,
|
|
1342
|
+
treeSize: newTreeSize
|
|
1343
|
+
});
|
|
1344
|
+
};
|
|
1345
|
+
this.lazyLoadingFunction = (node) => {
|
|
1346
|
+
const { lazyLoadingFunction } = this.props;
|
|
1347
|
+
if (!lazyLoadingFunction) return Promise.resolve();
|
|
1348
|
+
return lazyLoadingFunction(node.originalNode).then((dataSet) => {
|
|
1349
|
+
this.addTreeData(dataSet, node);
|
|
1350
|
+
}).catch(() => {
|
|
1351
|
+
return Promise.resolve();
|
|
1352
|
+
});
|
|
1353
|
+
};
|
|
1354
|
+
}
|
|
1355
|
+
componentDidMount() {
|
|
1356
|
+
const { treeData } = this.props;
|
|
1357
|
+
const tree = this.initTree(treeData);
|
|
1358
|
+
const treeSize = getTreeSize(tree);
|
|
1359
|
+
this.setState({
|
|
1360
|
+
tree,
|
|
1361
|
+
treeSize
|
|
1362
|
+
});
|
|
1363
|
+
}
|
|
1364
|
+
componentDidUpdate(prevProps) {
|
|
1365
|
+
const { selectedNodes: prevNodes } = prevProps;
|
|
1366
|
+
const { selectedNodes } = this.props;
|
|
1367
|
+
if (selectedNodes && prevNodes && prevNodes.length !== selectedNodes.length) {
|
|
1368
|
+
this.setState({
|
|
1369
|
+
selectedNodes
|
|
1370
|
+
});
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
initTree(treeData) {
|
|
1374
|
+
return {
|
|
1375
|
+
id: "virtualRootNode",
|
|
1376
|
+
name: "",
|
|
1377
|
+
children: this.convert(treeData),
|
|
1378
|
+
path: "/",
|
|
1379
|
+
originalNode: {}
|
|
1380
|
+
};
|
|
1381
|
+
}
|
|
1382
|
+
render() {
|
|
1383
|
+
const { tree, selectedNodes, treeSize } = this.state;
|
|
1384
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "treeview", children: tree.children && tree.children.map((item, i) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1385
|
+
Node,
|
|
1386
|
+
{
|
|
1387
|
+
node: item,
|
|
1388
|
+
selectedNodes,
|
|
1389
|
+
selectNodes: this.selectNodes,
|
|
1390
|
+
deselectNodes: this.deselectNodes,
|
|
1391
|
+
treeSize,
|
|
1392
|
+
lazyLoadingFunction: this.lazyLoadingFunction
|
|
1393
|
+
},
|
|
1394
|
+
i
|
|
1395
|
+
)) });
|
|
1396
|
+
}
|
|
1397
|
+
}
|
|
1398
|
+
const iconSettings = "data:image/svg+xml,%3csvg%20id='Layer_1'%20data-name='Layer%201'%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2016%2016'%3e%3ccircle%20cx='7.5'%20cy='3.5'%20r='1.5'/%3e%3ccircle%20cx='7.5'%20cy='7.5'%20r='1.5'/%3e%3ccircle%20cx='7.5'%20cy='11.5'%20r='1.5'/%3e%3c/svg%3e";
|
|
1399
|
+
const MultiMenuContext = React__namespace.createContext({
|
|
1400
|
+
toggleMenu: () => {
|
|
1401
|
+
}
|
|
1402
|
+
});
|
|
1403
|
+
function MultiMenuFunctional({ menuButton, children, direction, className, open, onOpenChange }) {
|
|
1404
|
+
const [contentVisible, setContentVisible] = React.useState(false);
|
|
1405
|
+
const toggleMenu = () => {
|
|
1406
|
+
setContentVisible(!contentVisible);
|
|
1407
|
+
};
|
|
1408
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1409
|
+
ngUiBasicComponents.Popup,
|
|
1410
|
+
{
|
|
1411
|
+
open: open ?? contentVisible,
|
|
1412
|
+
onOpenChange: onOpenChange ?? setContentVisible,
|
|
1413
|
+
handler: menuButton,
|
|
1414
|
+
placement: direction,
|
|
1415
|
+
className,
|
|
1416
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "di multimenu", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: `drop ${direction ? direction : "bottom"} ${contentVisible ? "show" : ""}`, children: /* @__PURE__ */ jsxRuntime.jsx(MultiMenuContext.Provider, { value: { toggleMenu }, children }) }) })
|
|
1417
|
+
}
|
|
1418
|
+
) });
|
|
1419
|
+
}
|
|
1420
|
+
const sizeOptions = [5, 10, 15, 20, 50];
|
|
1421
|
+
function Pagination({ onChangePage, page, totalPages, onChangeSize, size }) {
|
|
1422
|
+
const changePageDebouncedRef = React.useRef(null);
|
|
1423
|
+
const { current: changePageDebounced } = changePageDebouncedRef;
|
|
1424
|
+
const [pageRaw, setPageRaw] = React.useState(`${page + 1}`);
|
|
1425
|
+
const [menuOpen, setMenuOpen] = React.useState(false);
|
|
1426
|
+
React.useEffect(() => {
|
|
1427
|
+
changePageDebouncedRef.current = lodash.debounce(onChangePage, 500);
|
|
1428
|
+
}, [onChangePage]);
|
|
1429
|
+
React.useEffect(() => {
|
|
1430
|
+
setPageRaw(`${page + 1}`);
|
|
1431
|
+
}, [page]);
|
|
1432
|
+
function goToFirstPage() {
|
|
1433
|
+
onChangePage(0);
|
|
1434
|
+
}
|
|
1435
|
+
function goToPrevPage() {
|
|
1436
|
+
if (page > 0) {
|
|
1437
|
+
onChangePage(page - 1);
|
|
1438
|
+
}
|
|
1439
|
+
}
|
|
1440
|
+
function goToNextPage() {
|
|
1441
|
+
if (page < totalPages - 1) {
|
|
1442
|
+
onChangePage(page + 1);
|
|
1443
|
+
}
|
|
1444
|
+
}
|
|
1445
|
+
function goToLastPage() {
|
|
1446
|
+
onChangePage(totalPages - 1);
|
|
1447
|
+
}
|
|
1448
|
+
function handleChangeSize(event) {
|
|
1449
|
+
if (onChangeSize) {
|
|
1450
|
+
const newSize = parseInt(event.target.value, 10);
|
|
1451
|
+
onChangeSize(newSize);
|
|
1452
|
+
setMenuOpen(false);
|
|
1453
|
+
}
|
|
1454
|
+
}
|
|
1455
|
+
function handlePageInputChange(event) {
|
|
1456
|
+
const rawValue = event.target.value;
|
|
1457
|
+
if (rawValue.trim() === "") {
|
|
1458
|
+
setPageRaw(rawValue);
|
|
1459
|
+
return;
|
|
1460
|
+
}
|
|
1461
|
+
const parsedPage = Number(event.target.value);
|
|
1462
|
+
if (!Number.isNaN(parsedPage) && parsedPage >= 1 && parsedPage <= totalPages) {
|
|
1463
|
+
changePageDebounced?.(parsedPage - 1);
|
|
1464
|
+
setPageRaw(rawValue);
|
|
1465
|
+
}
|
|
1466
|
+
}
|
|
1467
|
+
function handlePageInputBlur() {
|
|
1468
|
+
setPageRaw(`${page + 1}`);
|
|
1469
|
+
}
|
|
1470
|
+
const isLastPage = page >= totalPages - 1;
|
|
1471
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "di pagination-holder", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "di pagination", children: [
|
|
1472
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: `prev ${page === 0 ? "disabled" : ""}`, onClick: goToFirstPage, children: "«" }),
|
|
1473
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: `prev ${page === 0 ? "disabled" : ""}`, onClick: goToPrevPage, children: "‹" }),
|
|
1474
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "info", children: [
|
|
1475
|
+
/* @__PURE__ */ jsxRuntime.jsx(Trans, { i18nKey: "reactable.pagination.page", children: "Page" }),
|
|
1476
|
+
/* @__PURE__ */ jsxRuntime.jsx("input", { value: pageRaw, onChange: handlePageInputChange, onBlur: handlePageInputBlur }),
|
|
1477
|
+
typeof process !== "undefined" && process?.env?.STORYBOOK_MODE ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1478
|
+
"of ",
|
|
1479
|
+
totalPages
|
|
1480
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsxs(Trans, { i18nKey: "reactable.pagination.ofTotal", children: [
|
|
1481
|
+
" of ",
|
|
1482
|
+
{ totalPages }
|
|
1483
|
+
] })
|
|
1484
|
+
] }),
|
|
1485
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: `next ${isLastPage ? "disabled" : ""}`, onClick: goToNextPage, children: "›" }),
|
|
1486
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: `next ${isLastPage ? "disabled" : ""}`, onClick: goToLastPage, children: "»" }),
|
|
1487
|
+
onChangeSize && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "options", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1488
|
+
MultiMenuFunctional,
|
|
1489
|
+
{
|
|
1490
|
+
direction: "left",
|
|
1491
|
+
open: menuOpen,
|
|
1492
|
+
onOpenChange: setMenuOpen,
|
|
1493
|
+
menuButton: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1494
|
+
ngUiBasicComponents.Button,
|
|
1495
|
+
{
|
|
1496
|
+
naked: true,
|
|
1497
|
+
title: {
|
|
1498
|
+
id: "trend.settings.buttonTitle",
|
|
1499
|
+
defaultValue: "Settings"
|
|
1500
|
+
},
|
|
1501
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("img", { src: iconSettings, alt: "settings icon", style: { width: 16, height: 16 } })
|
|
1502
|
+
}
|
|
1503
|
+
),
|
|
1504
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1505
|
+
"div",
|
|
1506
|
+
{
|
|
1507
|
+
className: "di form",
|
|
1508
|
+
style: {
|
|
1509
|
+
width: 200,
|
|
1510
|
+
padding: 10
|
|
1511
|
+
},
|
|
1512
|
+
children: [
|
|
1513
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "field", children: [
|
|
1514
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { children: /* @__PURE__ */ jsxRuntime.jsx(Trans, { i18nKey: "reactable.pagination.entriesPerPage", children: "Entries per page" }) }),
|
|
1515
|
+
/* @__PURE__ */ jsxRuntime.jsx("select", { onChange: handleChangeSize, value: size, children: sizeOptions.map((sizeOption) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: sizeOption, children: sizeOption }, sizeOption)) })
|
|
1516
|
+
] }),
|
|
1517
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { children: /* @__PURE__ */ jsxRuntime.jsx(Trans, { i18nKey: "reactable.pagination.changePageWillBeStored", children: "Your changes will be stored for view." }) })
|
|
1518
|
+
]
|
|
1519
|
+
}
|
|
1520
|
+
)
|
|
1521
|
+
}
|
|
1522
|
+
) })
|
|
1523
|
+
] }) });
|
|
1524
|
+
}
|
|
1525
|
+
const getInitialValueFromColumnDef = (columnDef) => {
|
|
1526
|
+
return columnDef.filterable?.initialValue ?? "";
|
|
1527
|
+
};
|
|
1528
|
+
const ReactableTextFilter = ({ columnDef, changeFilter }) => {
|
|
1529
|
+
const { t } = useTranslation();
|
|
1530
|
+
const [value, setValue] = React.useState(getInitialValueFromColumnDef(columnDef));
|
|
1531
|
+
const handleChange = (event) => {
|
|
1532
|
+
const newValue = event.target.value;
|
|
1533
|
+
setValue(newValue);
|
|
1534
|
+
changeFilter(columnDef.name, newValue);
|
|
1535
|
+
};
|
|
1536
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1537
|
+
"input",
|
|
1538
|
+
{
|
|
1539
|
+
type: "text",
|
|
1540
|
+
placeholder: t(`${columnDef.filterable?.placeholder ?? "reactable.filter.placeholder"}`, {
|
|
1541
|
+
defaultValue: "Filter..."
|
|
1542
|
+
}),
|
|
1543
|
+
onChange: handleChange,
|
|
1544
|
+
value
|
|
1545
|
+
}
|
|
1546
|
+
);
|
|
1547
|
+
};
|
|
1548
|
+
function makePageable(items, paginationSettings, customSortFunction) {
|
|
1549
|
+
if (!items) {
|
|
1550
|
+
return null;
|
|
1551
|
+
}
|
|
1552
|
+
const { page, size, sort } = paginationSettings;
|
|
1553
|
+
const sortedItems = customSortFunction ? customSortFunction(items, sort, sortItems) : sortItems(items, sort);
|
|
1554
|
+
return {
|
|
1555
|
+
content: sortedItems.slice(page * size, (page + 1) * size),
|
|
1556
|
+
totalElements: items.length,
|
|
1557
|
+
totalPages: Math.ceil(items.length / size),
|
|
1558
|
+
number: page,
|
|
1559
|
+
size,
|
|
1560
|
+
sort: [sort]
|
|
1561
|
+
};
|
|
1562
|
+
}
|
|
1563
|
+
const getDefaultFilterFn = (filterType, fieldName) => {
|
|
1564
|
+
if (filterType === "text") {
|
|
1565
|
+
return (item, filterValue) => item[fieldName] && item[fieldName].toString().toLowerCase().includes(filterValue.toLowerCase());
|
|
1566
|
+
} else {
|
|
1567
|
+
return (item, filterValue) => item[fieldName] === filterValue;
|
|
1568
|
+
}
|
|
1569
|
+
};
|
|
1570
|
+
function filterItems(items, columnDefs, filterSettings) {
|
|
1571
|
+
if (items) {
|
|
1572
|
+
return items.filter((item) => {
|
|
1573
|
+
return Object.keys(filterSettings).every((columnName) => {
|
|
1574
|
+
const filterValue = filterSettings[columnName];
|
|
1575
|
+
if (filterValue && filterValue.length > 0) {
|
|
1576
|
+
const columnDef = findColumnDefByName(columnName, columnDefs);
|
|
1577
|
+
if (columnDef.filterable) {
|
|
1578
|
+
const filterFn = columnDef.filterable.filterFn || getDefaultFilterFn(columnDef.filterable.filterType, columnDef.name);
|
|
1579
|
+
return filterFn(item, filterValue);
|
|
1580
|
+
}
|
|
1581
|
+
return false;
|
|
1582
|
+
}
|
|
1583
|
+
return true;
|
|
1584
|
+
});
|
|
1585
|
+
});
|
|
1586
|
+
}
|
|
1587
|
+
return null;
|
|
1588
|
+
}
|
|
1589
|
+
function findColumnDefByName(columnName, columnDefs) {
|
|
1590
|
+
const columnDef = columnDefs.find((cd) => cd.name === columnName);
|
|
1591
|
+
if (!columnDef) {
|
|
1592
|
+
throw Error(`column definition not found for ${columnName}`);
|
|
1593
|
+
}
|
|
1594
|
+
return columnDef;
|
|
1595
|
+
}
|
|
1596
|
+
function sortItems(items, sort) {
|
|
1597
|
+
return items.sort((itemA, itemB) => {
|
|
1598
|
+
const a = typeof itemA === "object" && itemA?.[sort.property] || 0;
|
|
1599
|
+
const b = typeof itemB === "object" && itemB?.[sort.property] || 0;
|
|
1600
|
+
const reverseFactor = sort.direction === "ASC" ? 1 : -1;
|
|
1601
|
+
if (a === b) {
|
|
1602
|
+
return 0;
|
|
1603
|
+
} else if (typeof a === "string" && typeof b === "string") {
|
|
1604
|
+
return a.localeCompare(b) * reverseFactor;
|
|
1605
|
+
} else if (typeof a === "number" && typeof b === "number") {
|
|
1606
|
+
return (a - b) * reverseFactor;
|
|
1607
|
+
} else {
|
|
1608
|
+
return a.toString().localeCompare(b.toString()) * reverseFactor;
|
|
1609
|
+
}
|
|
1610
|
+
});
|
|
1611
|
+
}
|
|
1612
|
+
function extendColumnDefsWithCheckboxes(columnDefs, onSelectChange, onSelectAllChange, selectedAll, selectedItems, uniqueItemKey) {
|
|
1613
|
+
return [
|
|
1614
|
+
{
|
|
1615
|
+
name: "checkbox",
|
|
1616
|
+
label: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1617
|
+
ngUiBasicComponents.Checkbox,
|
|
1618
|
+
{
|
|
1619
|
+
value: selectedAll,
|
|
1620
|
+
onChange: onSelectAllChange,
|
|
1621
|
+
title: {
|
|
1622
|
+
id: "components.filtertable.selectAllItems",
|
|
1623
|
+
defaultValue: "Select/deselect all items in search result"
|
|
1624
|
+
}
|
|
1625
|
+
}
|
|
1626
|
+
),
|
|
1627
|
+
sortable: false,
|
|
1628
|
+
render: (item) => {
|
|
1629
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1630
|
+
ngUiBasicComponents.Checkbox,
|
|
1631
|
+
{
|
|
1632
|
+
value: selectedItems.includes(uniqueItemKey(item)),
|
|
1633
|
+
onChange: (selected) => onSelectChange(selected, item)
|
|
1634
|
+
}
|
|
1635
|
+
);
|
|
1636
|
+
},
|
|
1637
|
+
width: "1%"
|
|
1638
|
+
},
|
|
1639
|
+
...columnDefs
|
|
1640
|
+
];
|
|
1641
|
+
}
|
|
1642
|
+
function getClassName(tableName, columnName) {
|
|
1643
|
+
return `${tableName || "unnamedTable"}-${columnName}`;
|
|
1644
|
+
}
|
|
1645
|
+
function getSortedOptions(options, compareOptions) {
|
|
1646
|
+
if (!compareOptions) {
|
|
1647
|
+
return lodash.orderBy(options, "label", "asc");
|
|
1648
|
+
}
|
|
1649
|
+
if (options.every((option) => !option.options)) {
|
|
1650
|
+
const singleOptions = options;
|
|
1651
|
+
return [...singleOptions].sort(compareOptions);
|
|
1652
|
+
}
|
|
1653
|
+
if (options.every((option) => option.options)) {
|
|
1654
|
+
const groupOptions = options;
|
|
1655
|
+
return groupOptions.map((option) => ({ ...option, options: [...option.options].sort(compareOptions) }));
|
|
1656
|
+
}
|
|
1657
|
+
throw new Error("Mixing groups with single options not allowed");
|
|
1658
|
+
}
|
|
1659
|
+
class SelectWithSearch extends React.Component {
|
|
1660
|
+
constructor() {
|
|
1661
|
+
super(...arguments);
|
|
1662
|
+
this.state = {
|
|
1663
|
+
options: [],
|
|
1664
|
+
inputValue: null
|
|
1665
|
+
};
|
|
1666
|
+
this.selectRef = React.createRef();
|
|
1667
|
+
this.portalRoot = null;
|
|
1668
|
+
this.updateOptions = () => {
|
|
1669
|
+
const { options, specialOptions, compareOptions } = this.props;
|
|
1670
|
+
const sortedOptions = getSortedOptions(options, compareOptions);
|
|
1671
|
+
if (specialOptions) {
|
|
1672
|
+
this.setState({
|
|
1673
|
+
// @ts-ignore
|
|
1674
|
+
options: [...sortedOptions, ...specialOptions]
|
|
1675
|
+
});
|
|
1676
|
+
} else {
|
|
1677
|
+
this.setState({
|
|
1678
|
+
options: sortedOptions
|
|
1679
|
+
});
|
|
1680
|
+
}
|
|
1681
|
+
};
|
|
1682
|
+
this.filterOption = (option, inputValue) => {
|
|
1683
|
+
return option.label.toString().toLowerCase().startsWith(inputValue.toLowerCase());
|
|
1684
|
+
};
|
|
1685
|
+
this.getContainerClasses = () => {
|
|
1686
|
+
const { specialOptions } = this.props;
|
|
1687
|
+
if (specialOptions) {
|
|
1688
|
+
return ["select-search-container", "special"];
|
|
1689
|
+
}
|
|
1690
|
+
return ["select-search-container"];
|
|
1691
|
+
};
|
|
1692
|
+
}
|
|
1693
|
+
componentDidMount() {
|
|
1694
|
+
this.updateOptions();
|
|
1695
|
+
if (this.props["data-testid"] && this.selectRef && this.selectRef.current) {
|
|
1696
|
+
this.selectRef.current.controlRef.setAttribute("data-testid", this.props["data-testid"]);
|
|
1697
|
+
}
|
|
1698
|
+
if (this.props.menuPortalTarget) {
|
|
1699
|
+
this.portalRoot = document.createElement("div");
|
|
1700
|
+
const classes = this.getContainerClasses();
|
|
1701
|
+
this.portalRoot.classList.add(...classes);
|
|
1702
|
+
this.props.menuPortalTarget.appendChild(this.portalRoot);
|
|
1703
|
+
}
|
|
1704
|
+
}
|
|
1705
|
+
componentDidUpdate(prevProps) {
|
|
1706
|
+
if (!lodash.isEqual(prevProps.options, this.props.options) || prevProps.freeForm !== this.props.freeForm) {
|
|
1707
|
+
this.updateOptions();
|
|
1708
|
+
}
|
|
1709
|
+
}
|
|
1710
|
+
componentWillUnmount() {
|
|
1711
|
+
if (this.props.menuPortalTarget && this.portalRoot) {
|
|
1712
|
+
this.props.menuPortalTarget.removeChild(this.portalRoot);
|
|
1713
|
+
}
|
|
1714
|
+
}
|
|
1715
|
+
render() {
|
|
1716
|
+
const { noResultsMessage, placeholder, value, onChange, clearable, loading, disabled } = this.props;
|
|
1717
|
+
const { options } = this.state;
|
|
1718
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1719
|
+
Select,
|
|
1720
|
+
{
|
|
1721
|
+
ref: this.selectRef,
|
|
1722
|
+
joinValues: true,
|
|
1723
|
+
name: "form-field-name",
|
|
1724
|
+
className: this.getContainerClasses().join(" "),
|
|
1725
|
+
classNamePrefix: "select-search",
|
|
1726
|
+
isClearable: clearable,
|
|
1727
|
+
noOptionsMessage: noResultsMessage ? () => noResultsMessage : void 0,
|
|
1728
|
+
options,
|
|
1729
|
+
value: value || null,
|
|
1730
|
+
onChange,
|
|
1731
|
+
onInputChange: (newValue) => {
|
|
1732
|
+
if (this.props.freeForm && newValue) {
|
|
1733
|
+
this.setState({ inputValue: newValue });
|
|
1734
|
+
}
|
|
1735
|
+
},
|
|
1736
|
+
placeholder,
|
|
1737
|
+
filterOption: this.filterOption,
|
|
1738
|
+
isLoading: loading,
|
|
1739
|
+
menuPortalTarget: this.portalRoot,
|
|
1740
|
+
isDisabled: disabled,
|
|
1741
|
+
onBlur: () => {
|
|
1742
|
+
if (this.props.freeForm && this.state.inputValue !== null) {
|
|
1743
|
+
this.setState({ options: this.props.options });
|
|
1744
|
+
this.setState({ inputValue: this.state.inputValue }, () => {
|
|
1745
|
+
const newItem = {
|
|
1746
|
+
type: "item",
|
|
1747
|
+
value: this.state.inputValue,
|
|
1748
|
+
label: this.state.inputValue
|
|
1749
|
+
};
|
|
1750
|
+
this.setState(
|
|
1751
|
+
(prevState) => ({
|
|
1752
|
+
options: [newItem, ...prevState.options]
|
|
1753
|
+
})
|
|
1754
|
+
);
|
|
1755
|
+
this.state.inputValue = null;
|
|
1756
|
+
onChange(newItem);
|
|
1757
|
+
});
|
|
1758
|
+
}
|
|
1759
|
+
}
|
|
1760
|
+
}
|
|
1761
|
+
);
|
|
1762
|
+
}
|
|
1763
|
+
}
|
|
1764
|
+
const ReactableTableFilterRow = ({ columnDefs, onFilter, tableName }) => {
|
|
1765
|
+
const { t } = useTranslation();
|
|
1766
|
+
const [state, setState] = React.useState({});
|
|
1767
|
+
const onFilterRef = React.useRef(onFilter);
|
|
1768
|
+
React.useEffect(() => {
|
|
1769
|
+
onFilterRef.current = onFilter;
|
|
1770
|
+
}, [onFilter]);
|
|
1771
|
+
React.useEffect(() => {
|
|
1772
|
+
setState((prev) => {
|
|
1773
|
+
const merged = {};
|
|
1774
|
+
for (const cd of columnDefs) {
|
|
1775
|
+
merged[cd.name] = prev[cd.name] !== void 0 ? prev[cd.name] : cd.filterable?.initialValue ?? "";
|
|
1776
|
+
}
|
|
1777
|
+
const prevKeys = Object.keys(prev);
|
|
1778
|
+
const mergedKeys = Object.keys(merged);
|
|
1779
|
+
const sameKeys = mergedKeys.length === prevKeys.length && mergedKeys.every((k) => prevKeys.includes(k));
|
|
1780
|
+
const sameValues = sameKeys && mergedKeys.every((k) => merged[k] === prev[k]);
|
|
1781
|
+
if (sameKeys && sameValues) {
|
|
1782
|
+
return prev;
|
|
1783
|
+
}
|
|
1784
|
+
if (Object.values(merged).some((v) => v)) {
|
|
1785
|
+
onFilterRef.current(merged);
|
|
1786
|
+
}
|
|
1787
|
+
return merged;
|
|
1788
|
+
});
|
|
1789
|
+
}, [columnDefs]);
|
|
1790
|
+
const changeFilter = (columnName, value) => {
|
|
1791
|
+
const newState = { ...state, [columnName]: value };
|
|
1792
|
+
setState(newState);
|
|
1793
|
+
onFilter(newState);
|
|
1794
|
+
};
|
|
1795
|
+
const getFilterByColumnDef = (columnDef) => {
|
|
1796
|
+
if (columnDef.filterable) {
|
|
1797
|
+
switch (columnDef.filterable.filterType) {
|
|
1798
|
+
case "text":
|
|
1799
|
+
return textFilter(columnDef);
|
|
1800
|
+
case "options":
|
|
1801
|
+
return optionsFilter(columnDef);
|
|
1802
|
+
default:
|
|
1803
|
+
throw new Error(`Filter type ${columnDef.filterable.filterType} not supported`);
|
|
1804
|
+
}
|
|
1805
|
+
}
|
|
1806
|
+
return null;
|
|
1807
|
+
};
|
|
1808
|
+
const textFilter = (columnDef) => {
|
|
1809
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ReactableTextFilter, { columnDef, changeFilter });
|
|
1810
|
+
};
|
|
1811
|
+
const optionsFilter = (columnDef) => {
|
|
1812
|
+
if (!columnDef.filterable?.filterOptions) {
|
|
1813
|
+
throw new Error(`No filterOptions found for column type: options on columnDef: ${columnDef.name}`);
|
|
1814
|
+
}
|
|
1815
|
+
const filterOptions = columnDef.filterable.filterOptions;
|
|
1816
|
+
if (columnDef.filterable.searchableOptions) {
|
|
1817
|
+
const searchableOptions = filterOptions.map((option) => ({
|
|
1818
|
+
type: "item",
|
|
1819
|
+
label: typeof option.label === "string" ? option.label : t(option.label.id, { defaultValue: option.label.defaultValue }),
|
|
1820
|
+
value: option.value
|
|
1821
|
+
}));
|
|
1822
|
+
const value = state[columnDef.name];
|
|
1823
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1824
|
+
SelectWithSearch,
|
|
1825
|
+
{
|
|
1826
|
+
options: searchableOptions,
|
|
1827
|
+
onChange: (item) => {
|
|
1828
|
+
changeFilter(columnDef.name, item?.value);
|
|
1829
|
+
},
|
|
1830
|
+
value: value ? searchableOptions.find((opt) => opt.value === value.toString()) : null,
|
|
1831
|
+
clearable: true
|
|
1832
|
+
}
|
|
1833
|
+
);
|
|
1834
|
+
} else {
|
|
1835
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1836
|
+
"select",
|
|
1837
|
+
{
|
|
1838
|
+
onChange: (event) => {
|
|
1839
|
+
changeFilter(columnDef.name, event.target.value);
|
|
1840
|
+
},
|
|
1841
|
+
value: state[columnDef.name],
|
|
1842
|
+
children: [
|
|
1843
|
+
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "", children: t("reactable.filter.all", {
|
|
1844
|
+
defaultValue: "- All -"
|
|
1845
|
+
}) }, ""),
|
|
1846
|
+
filterOptions.map((option) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1847
|
+
"option",
|
|
1848
|
+
{
|
|
1849
|
+
className: getClassName(tableName, columnDef.name),
|
|
1850
|
+
value: option.value,
|
|
1851
|
+
children: typeof option.label === "string" ? option.label : t(option.label.id, { defaultValue: option.label.defaultValue })
|
|
1852
|
+
},
|
|
1853
|
+
option.value
|
|
1854
|
+
))
|
|
1855
|
+
]
|
|
1856
|
+
}
|
|
1857
|
+
);
|
|
1858
|
+
}
|
|
1859
|
+
};
|
|
1860
|
+
return /* @__PURE__ */ jsxRuntime.jsx("tr", { className: "di filterrow form", children: columnDefs.map((columnDef) => /* @__PURE__ */ jsxRuntime.jsx("td", { style: { textAlign: columnDef.align || "left" }, children: getFilterByColumnDef(columnDef) }, columnDef.name)) });
|
|
1861
|
+
};
|
|
1862
|
+
const toggleSortDirection = (direction) => direction === "ASC" ? "DESC" : "ASC";
|
|
1863
|
+
class ReactableTableHeader extends React.Component {
|
|
1864
|
+
constructor() {
|
|
1865
|
+
super(...arguments);
|
|
1866
|
+
this.handleSort = (columnDef) => {
|
|
1867
|
+
const { paginationSettings, onSort } = this.props;
|
|
1868
|
+
const direction = columnDef.name === paginationSettings.sort.property ? toggleSortDirection(paginationSettings.sort.direction) : columnDef.defaultSortDirection || "ASC";
|
|
1869
|
+
onSort(columnDef.name, direction);
|
|
1870
|
+
};
|
|
1871
|
+
this.getClassName = (columnDef) => {
|
|
1872
|
+
const { paginationSettings, tableName } = this.props;
|
|
1873
|
+
const className = getClassName(tableName, columnDef.name);
|
|
1874
|
+
if (columnDef.sortable) {
|
|
1875
|
+
if (columnDef.name === paginationSettings.sort.property) {
|
|
1876
|
+
if (paginationSettings.sort.direction === "ASC") {
|
|
1877
|
+
return `${className} sortable sortAsc`;
|
|
1878
|
+
} else {
|
|
1879
|
+
return `${className} sortable sortDes`;
|
|
1880
|
+
}
|
|
1881
|
+
} else {
|
|
1882
|
+
return `${className} sortable`;
|
|
1883
|
+
}
|
|
1884
|
+
} else {
|
|
1885
|
+
return `${className}`;
|
|
1886
|
+
}
|
|
1887
|
+
};
|
|
1888
|
+
this.printLabel = (label) => {
|
|
1889
|
+
if (isTranslationDescriptor(label)) {
|
|
1890
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Trans, { i18nKey: label.id, children: label.defaultValue });
|
|
1891
|
+
}
|
|
1892
|
+
return label;
|
|
1893
|
+
};
|
|
1894
|
+
}
|
|
1895
|
+
render() {
|
|
1896
|
+
return /* @__PURE__ */ jsxRuntime.jsx("tr", { children: this.props.columnDefs.map((columnDef) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1897
|
+
"th",
|
|
1898
|
+
{
|
|
1899
|
+
style: {
|
|
1900
|
+
width: columnDef.width || "auto",
|
|
1901
|
+
textAlign: columnDef.align || "left"
|
|
1902
|
+
},
|
|
1903
|
+
className: this.getClassName(columnDef),
|
|
1904
|
+
onClick: () => {
|
|
1905
|
+
if (columnDef.sortable) {
|
|
1906
|
+
this.handleSort(columnDef);
|
|
1907
|
+
}
|
|
1908
|
+
},
|
|
1909
|
+
children: this.printLabel(columnDef.label)
|
|
1910
|
+
},
|
|
1911
|
+
columnDef.name
|
|
1912
|
+
)) });
|
|
1913
|
+
}
|
|
1914
|
+
}
|
|
1915
|
+
function isTranslationDescriptor(label) {
|
|
1916
|
+
return typeof label === "object" && label != null && "id" in label && label.id !== void 0;
|
|
1917
|
+
}
|
|
1918
|
+
class ReactableTableRow extends React.Component {
|
|
1919
|
+
constructor() {
|
|
1920
|
+
super(...arguments);
|
|
1921
|
+
this.getRowClass = () => {
|
|
1922
|
+
const { rowDef, item } = this.props;
|
|
1923
|
+
if (rowDef && typeof rowDef.getRowClass === "function") {
|
|
1924
|
+
return rowDef.getRowClass(item);
|
|
1925
|
+
} else {
|
|
1926
|
+
return "";
|
|
1927
|
+
}
|
|
1928
|
+
};
|
|
1929
|
+
this.handleClick = () => {
|
|
1930
|
+
const { rowDef, item } = this.props;
|
|
1931
|
+
if (rowDef && typeof rowDef.onClick === "function") {
|
|
1932
|
+
rowDef.onClick(item);
|
|
1933
|
+
}
|
|
1934
|
+
};
|
|
1935
|
+
this.getTooltip = () => {
|
|
1936
|
+
const { rowDef, item } = this.props;
|
|
1937
|
+
if (rowDef && typeof rowDef.getTooltip === "function") {
|
|
1938
|
+
return rowDef.getTooltip(item);
|
|
1939
|
+
} else {
|
|
1940
|
+
return "";
|
|
1941
|
+
}
|
|
1942
|
+
};
|
|
1943
|
+
this.getRowStyle = () => {
|
|
1944
|
+
const { rowDef, item } = this.props;
|
|
1945
|
+
if (rowDef && rowDef.getRowStyle) {
|
|
1946
|
+
return rowDef.getRowStyle(item);
|
|
1947
|
+
} else {
|
|
1948
|
+
return void 0;
|
|
1949
|
+
}
|
|
1950
|
+
};
|
|
1951
|
+
}
|
|
1952
|
+
render() {
|
|
1953
|
+
const { columnDefs, item, tableName } = this.props;
|
|
1954
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1955
|
+
"tr",
|
|
1956
|
+
{
|
|
1957
|
+
className: this.getRowClass(),
|
|
1958
|
+
onClick: this.handleClick,
|
|
1959
|
+
title: this.getTooltip(),
|
|
1960
|
+
style: this.getRowStyle(),
|
|
1961
|
+
children: columnDefs.map((columnDef) => {
|
|
1962
|
+
const textAlign = columnDef.align || "left";
|
|
1963
|
+
const cursor = columnDef.onClick ? "pointer" : "inherit";
|
|
1964
|
+
const whiteSpace = columnDef.whiteSpace || void 0;
|
|
1965
|
+
const onClick = columnDef.onClick ? () => columnDef.onClick ? columnDef.onClick(item) : void 0 : void 0;
|
|
1966
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1967
|
+
"td",
|
|
1968
|
+
{
|
|
1969
|
+
style: {
|
|
1970
|
+
textAlign,
|
|
1971
|
+
cursor,
|
|
1972
|
+
// @ts-ignore
|
|
1973
|
+
whiteSpace
|
|
1974
|
+
},
|
|
1975
|
+
onClick,
|
|
1976
|
+
className: getClassName(tableName, columnDef.name),
|
|
1977
|
+
children: columnDef.render(item)
|
|
1978
|
+
},
|
|
1979
|
+
`${item.id}_${columnDef.name}`
|
|
1980
|
+
);
|
|
1981
|
+
})
|
|
1982
|
+
}
|
|
1983
|
+
);
|
|
1984
|
+
}
|
|
1985
|
+
}
|
|
1986
|
+
function ReactableTable({
|
|
1987
|
+
columnDefs,
|
|
1988
|
+
uniqueItemKey,
|
|
1989
|
+
paginationSettings,
|
|
1990
|
+
onSort,
|
|
1991
|
+
onFilter,
|
|
1992
|
+
tableName,
|
|
1993
|
+
pageable,
|
|
1994
|
+
isLoading,
|
|
1995
|
+
rowDef,
|
|
1996
|
+
clickable,
|
|
1997
|
+
messageWhenEmpty,
|
|
1998
|
+
"data-testid": testId
|
|
1999
|
+
}) {
|
|
2000
|
+
const containerRef = React.useRef(null);
|
|
2001
|
+
const tableRef = React.useRef(null);
|
|
2002
|
+
const [showScrollingAdvice, setShowScrollingAdvice] = React.useState(false);
|
|
2003
|
+
const [neverShowScrollingAdvice, setNeverShowScrollingAdvice] = React.useState(true);
|
|
2004
|
+
const [hasInitialized, setHasInitialized] = React.useState(false);
|
|
2005
|
+
const HIDE_SCROLLING_ADVICE_PATH = "uiConfigurations/nevershowscrollingadvice";
|
|
2006
|
+
const LOCALSTORAGE_KEY = "reactable.neverShowScrollingAdvice";
|
|
2007
|
+
const neverShowScrollingAdviceRef = React.useRef(neverShowScrollingAdvice);
|
|
2008
|
+
React.useEffect(() => {
|
|
2009
|
+
neverShowScrollingAdviceRef.current = neverShowScrollingAdvice;
|
|
2010
|
+
}, [neverShowScrollingAdvice]);
|
|
2011
|
+
const updateScrollingAdvice = () => {
|
|
2012
|
+
if (containerRef.current && tableRef.current) {
|
|
2013
|
+
setShowScrollingAdvice(
|
|
2014
|
+
!neverShowScrollingAdviceRef.current && tableRef.current.scrollWidth > containerRef.current.offsetWidth
|
|
2015
|
+
);
|
|
2016
|
+
}
|
|
2017
|
+
};
|
|
2018
|
+
React.useEffect(() => {
|
|
2019
|
+
setTimeout(() => {
|
|
2020
|
+
(async () => {
|
|
2021
|
+
const localValue = localStorage.getItem(LOCALSTORAGE_KEY);
|
|
2022
|
+
const hasLocalValue = localValue !== null;
|
|
2023
|
+
try {
|
|
2024
|
+
const value = await ngUiApiClient.readAccountObject(HIDE_SCROLLING_ADVICE_PATH);
|
|
2025
|
+
const neverShow = value === true;
|
|
2026
|
+
setNeverShowScrollingAdvice(neverShow);
|
|
2027
|
+
neverShowScrollingAdviceRef.current = neverShow;
|
|
2028
|
+
localStorage.setItem(LOCALSTORAGE_KEY, String(neverShow));
|
|
2029
|
+
if (!neverShow) {
|
|
2030
|
+
updateScrollingAdvice();
|
|
2031
|
+
}
|
|
2032
|
+
} catch (error) {
|
|
2033
|
+
if (hasLocalValue) {
|
|
2034
|
+
const neverShow = localValue === "true";
|
|
2035
|
+
setNeverShowScrollingAdvice(neverShow);
|
|
2036
|
+
neverShowScrollingAdviceRef.current = neverShow;
|
|
2037
|
+
if (!neverShow) {
|
|
2038
|
+
updateScrollingAdvice();
|
|
2039
|
+
}
|
|
2040
|
+
} else {
|
|
2041
|
+
setNeverShowScrollingAdvice(false);
|
|
2042
|
+
neverShowScrollingAdviceRef.current = false;
|
|
2043
|
+
updateScrollingAdvice();
|
|
2044
|
+
}
|
|
2045
|
+
}
|
|
2046
|
+
setHasInitialized(true);
|
|
2047
|
+
})();
|
|
2048
|
+
}, 0);
|
|
2049
|
+
}, []);
|
|
2050
|
+
React.useEffect(() => {
|
|
2051
|
+
updateScrollingAdvice();
|
|
2052
|
+
window.addEventListener("resize", updateScrollingAdvice);
|
|
2053
|
+
return () => window.removeEventListener("resize", updateScrollingAdvice);
|
|
2054
|
+
}, [pageable, columnDefs]);
|
|
2055
|
+
const showFilterRow = columnDefs.some((col) => col.filterable);
|
|
2056
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ngUiBasicComponents.SpinnerContainer, { show: isLoading, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: containerRef, className: "di reactable scroll-x", children: [
|
|
2057
|
+
hasInitialized && showScrollingAdvice && !isLoading && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2058
|
+
ngUiBasicComponents.Modal,
|
|
2059
|
+
{
|
|
2060
|
+
className: "scroll-horizontally-advice",
|
|
2061
|
+
content: /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2062
|
+
/* @__PURE__ */ jsxRuntime.jsx(Trans, { i18nKey: "reactable.scrollHorizontally.advice", children: "SHIFT + mouse wheel to scroll horizontally" }),
|
|
2063
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "scroll-horizontally-advice-buttons", children: [
|
|
2064
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2065
|
+
ngUiBasicComponents.Button,
|
|
2066
|
+
{
|
|
2067
|
+
primary: true,
|
|
2068
|
+
onClick: async () => {
|
|
2069
|
+
await ngUiApiClient.writeAccountObject(HIDE_SCROLLING_ADVICE_PATH, true);
|
|
2070
|
+
localStorage.setItem(LOCALSTORAGE_KEY, "true");
|
|
2071
|
+
setNeverShowScrollingAdvice(true);
|
|
2072
|
+
neverShowScrollingAdviceRef.current = true;
|
|
2073
|
+
setShowScrollingAdvice(false);
|
|
2074
|
+
},
|
|
2075
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Trans, { i18nKey: "reactable.scrollHorizontally.neverShowAgain", children: "Never show again" })
|
|
2076
|
+
}
|
|
2077
|
+
),
|
|
2078
|
+
/* @__PURE__ */ jsxRuntime.jsx(ngUiBasicComponents.Button, { onClick: () => setShowScrollingAdvice(false), children: /* @__PURE__ */ jsxRuntime.jsx(Trans, { i18nKey: "reactable.scrollHorizontally.ok", children: "OK" }) })
|
|
2079
|
+
] })
|
|
2080
|
+
] }),
|
|
2081
|
+
width: "40%"
|
|
2082
|
+
}
|
|
2083
|
+
),
|
|
2084
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
2085
|
+
"table",
|
|
2086
|
+
{
|
|
2087
|
+
ref: tableRef,
|
|
2088
|
+
className: cx("di reactable sortable hoverable", { selectable: clickable }),
|
|
2089
|
+
"data-testid": testId,
|
|
2090
|
+
children: [
|
|
2091
|
+
/* @__PURE__ */ jsxRuntime.jsx("thead", { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2092
|
+
ReactableTableHeader,
|
|
2093
|
+
{
|
|
2094
|
+
columnDefs,
|
|
2095
|
+
paginationSettings,
|
|
2096
|
+
onSort,
|
|
2097
|
+
tableName
|
|
2098
|
+
}
|
|
2099
|
+
) }),
|
|
2100
|
+
/* @__PURE__ */ jsxRuntime.jsxs("tbody", { children: [
|
|
2101
|
+
onFilter && showFilterRow && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2102
|
+
ReactableTableFilterRow,
|
|
2103
|
+
{
|
|
2104
|
+
columnDefs,
|
|
2105
|
+
onFilter,
|
|
2106
|
+
tableName
|
|
2107
|
+
}
|
|
2108
|
+
),
|
|
2109
|
+
pageable?.content.length ? pageable.content.slice(0, paginationSettings.size).map((item) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2110
|
+
ReactableTableRow,
|
|
2111
|
+
{
|
|
2112
|
+
columnDefs,
|
|
2113
|
+
item,
|
|
2114
|
+
rowDef,
|
|
2115
|
+
tableName
|
|
2116
|
+
},
|
|
2117
|
+
uniqueItemKey(item)
|
|
2118
|
+
)) : !isLoading && /* @__PURE__ */ jsxRuntime.jsx("tr", { children: /* @__PURE__ */ jsxRuntime.jsx("td", { colSpan: columnDefs.length, children: /* @__PURE__ */ jsxRuntime.jsx(Trans, { i18nKey: messageWhenEmpty ?? "reactable.noEntriesFound", children: "No entries found" }) }) })
|
|
2119
|
+
] })
|
|
2120
|
+
]
|
|
2121
|
+
}
|
|
2122
|
+
)
|
|
2123
|
+
] }) });
|
|
2124
|
+
}
|
|
2125
|
+
class Reactable extends React.Component {
|
|
2126
|
+
componentDidUpdate() {
|
|
2127
|
+
const { pageable, paginationSettings, onChangePage } = this.props;
|
|
2128
|
+
if (!pageable) {
|
|
2129
|
+
return;
|
|
2130
|
+
}
|
|
2131
|
+
const totalPages = pageable.totalPages || 0;
|
|
2132
|
+
const currentPage = paginationSettings.page;
|
|
2133
|
+
const clampedPage = totalPages > 0 ? Math.min(currentPage, totalPages - 1) : 0;
|
|
2134
|
+
if (currentPage !== clampedPage) {
|
|
2135
|
+
onChangePage(clampedPage);
|
|
2136
|
+
}
|
|
2137
|
+
}
|
|
2138
|
+
render() {
|
|
2139
|
+
const { paginationSettings, pageable, onChangePage, onChangeSize } = this.props;
|
|
2140
|
+
const showPagination = onChangeSize ? pageable && pageable.totalElements > 0 : pageable && pageable.totalPages > 1;
|
|
2141
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2142
|
+
/* @__PURE__ */ jsxRuntime.jsx(ReactableTable, { ...this.props }),
|
|
2143
|
+
pageable && showPagination && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2144
|
+
Pagination,
|
|
2145
|
+
{
|
|
2146
|
+
page: paginationSettings.page,
|
|
2147
|
+
totalPages: pageable.totalPages,
|
|
2148
|
+
onChangePage,
|
|
2149
|
+
onChangeSize,
|
|
2150
|
+
size: paginationSettings.size
|
|
2151
|
+
}
|
|
2152
|
+
)
|
|
2153
|
+
] });
|
|
2154
|
+
}
|
|
2155
|
+
}
|
|
2156
|
+
const DEFAULT_PAGINATION_SETTINGS = {
|
|
2157
|
+
page: 0,
|
|
2158
|
+
size: 15,
|
|
2159
|
+
sort: {
|
|
2160
|
+
property: "name",
|
|
2161
|
+
direction: "DESC"
|
|
2162
|
+
}
|
|
2163
|
+
};
|
|
2164
|
+
class ReactableWithClientSidePagination extends React.Component {
|
|
2165
|
+
constructor(props) {
|
|
2166
|
+
super(props);
|
|
2167
|
+
this.content = [];
|
|
2168
|
+
this.calculatePageNumber = (items, paginationSettings2) => {
|
|
2169
|
+
const { forceResetPaginationOnItemsChange } = this.props;
|
|
2170
|
+
if (!forceResetPaginationOnItemsChange) {
|
|
2171
|
+
const maxPageNumber = Math.floor((items.length - 1) / paginationSettings2.size);
|
|
2172
|
+
if (maxPageNumber <= 0) {
|
|
2173
|
+
this.handleChangePage(0);
|
|
2174
|
+
} else if (maxPageNumber < paginationSettings2.page) {
|
|
2175
|
+
this.handleChangePage(maxPageNumber);
|
|
2176
|
+
}
|
|
2177
|
+
} else {
|
|
2178
|
+
this.handleChangePage(0);
|
|
2179
|
+
}
|
|
2180
|
+
};
|
|
2181
|
+
this.handleChangePage = (page) => {
|
|
2182
|
+
this.setState({
|
|
2183
|
+
paginationSettings: { ...this.state.paginationSettings, page }
|
|
2184
|
+
});
|
|
2185
|
+
};
|
|
2186
|
+
this.handleSort = (property, direction) => {
|
|
2187
|
+
this.setState({
|
|
2188
|
+
paginationSettings: {
|
|
2189
|
+
...this.state.paginationSettings,
|
|
2190
|
+
sort: {
|
|
2191
|
+
property,
|
|
2192
|
+
direction
|
|
2193
|
+
}
|
|
2194
|
+
}
|
|
2195
|
+
});
|
|
2196
|
+
};
|
|
2197
|
+
this.handleFilter = (filterSettings) => {
|
|
2198
|
+
const { items, onFilter, columnDefs, onFilteredItemsChanged } = this.props;
|
|
2199
|
+
this.setState(
|
|
2200
|
+
{
|
|
2201
|
+
paginationSettings: { ...this.state.paginationSettings, page: 0 },
|
|
2202
|
+
filterSettings
|
|
2203
|
+
},
|
|
2204
|
+
() => {
|
|
2205
|
+
if (onFilter) {
|
|
2206
|
+
onFilter(filterSettings);
|
|
2207
|
+
}
|
|
2208
|
+
const filteredItems = filterItems(items, columnDefs, filterSettings);
|
|
2209
|
+
this.setState({
|
|
2210
|
+
filteredItems
|
|
2211
|
+
});
|
|
2212
|
+
if (filteredItems) {
|
|
2213
|
+
onFilteredItemsChanged?.(filteredItems);
|
|
2214
|
+
}
|
|
2215
|
+
}
|
|
2216
|
+
);
|
|
2217
|
+
};
|
|
2218
|
+
this.getPageable = () => {
|
|
2219
|
+
const { customSortFunction, items, columnDefs, onContentChange } = this.props;
|
|
2220
|
+
const { filterSettings, paginationSettings: paginationSettings2 } = this.state;
|
|
2221
|
+
const filteredItems = filterItems(items, columnDefs, filterSettings);
|
|
2222
|
+
const pageable = makePageable(filteredItems, paginationSettings2, customSortFunction);
|
|
2223
|
+
if (pageable && pageable.content && !lodash.isEqual(pageable.content, this.content)) {
|
|
2224
|
+
this.content = pageable.content;
|
|
2225
|
+
if (onContentChange) {
|
|
2226
|
+
onContentChange(this.content);
|
|
2227
|
+
}
|
|
2228
|
+
}
|
|
2229
|
+
return pageable;
|
|
2230
|
+
};
|
|
2231
|
+
this.handleSelectChange = (selected, item) => {
|
|
2232
|
+
const { onSelectedItemsChange, selectedItems = [], uniqueItemKey } = this.props;
|
|
2233
|
+
if (onSelectedItemsChange) {
|
|
2234
|
+
if (selected) {
|
|
2235
|
+
const newSelectedItems = selectedItems.concat(uniqueItemKey(item));
|
|
2236
|
+
onSelectedItemsChange(newSelectedItems);
|
|
2237
|
+
} else {
|
|
2238
|
+
onSelectedItemsChange(selectedItems.filter((key) => key !== uniqueItemKey(item)));
|
|
2239
|
+
}
|
|
2240
|
+
} else {
|
|
2241
|
+
console.warn("ReactableWithClientSidePagination: onSelectedItemsChange property is missing");
|
|
2242
|
+
}
|
|
2243
|
+
};
|
|
2244
|
+
this.handleSelectAllChange = (selectedAll) => {
|
|
2245
|
+
const { onSelectedItemsChange, items, selectedItems = [], uniqueItemKey } = this.props;
|
|
2246
|
+
const { filteredItems } = this.state;
|
|
2247
|
+
const visibleItems = (filteredItems || items || []).map(uniqueItemKey);
|
|
2248
|
+
if (onSelectedItemsChange) {
|
|
2249
|
+
if (selectedAll) {
|
|
2250
|
+
onSelectedItemsChange(lodash.uniqWith([...selectedItems, ...visibleItems], lodash.isEqual).sort());
|
|
2251
|
+
} else {
|
|
2252
|
+
onSelectedItemsChange(lodash.difference(selectedItems, visibleItems));
|
|
2253
|
+
}
|
|
2254
|
+
} else {
|
|
2255
|
+
console.warn("ReactableWithClientSidePagination: onSelectedItemsChange property is missing");
|
|
2256
|
+
}
|
|
2257
|
+
};
|
|
2258
|
+
this.areSelectedAll = () => {
|
|
2259
|
+
const { items, selectedItems, uniqueItemKey } = this.props;
|
|
2260
|
+
const { filteredItems } = this.state;
|
|
2261
|
+
const visibleItems = filteredItems || items || [];
|
|
2262
|
+
return !!selectedItems && visibleItems.every((item) => selectedItems.some((key) => key === uniqueItemKey(item)));
|
|
2263
|
+
};
|
|
2264
|
+
let paginationSettings = DEFAULT_PAGINATION_SETTINGS;
|
|
2265
|
+
if (props.paginationSettings) {
|
|
2266
|
+
paginationSettings = props.paginationSettings;
|
|
2267
|
+
} else if (props.initialPaginationSettings) {
|
|
2268
|
+
console.warn('initialPaginationSettings is deprecated! Please use "paginationSettings" instead');
|
|
2269
|
+
paginationSettings = props.initialPaginationSettings;
|
|
2270
|
+
} else {
|
|
2271
|
+
console.error("Missing pagination settings!");
|
|
2272
|
+
}
|
|
2273
|
+
this.state = {
|
|
2274
|
+
paginationSettings: paginationSettings || DEFAULT_PAGINATION_SETTINGS,
|
|
2275
|
+
filterSettings: {},
|
|
2276
|
+
filteredItems: null
|
|
2277
|
+
};
|
|
2278
|
+
}
|
|
2279
|
+
componentDidUpdate(prevProps) {
|
|
2280
|
+
const { items } = this.props;
|
|
2281
|
+
const { items: prevItems } = prevProps;
|
|
2282
|
+
const settings = this.props.paginationSettings || this.props.initialPaginationSettings;
|
|
2283
|
+
const prevSettings = prevProps.paginationSettings || prevProps.initialPaginationSettings;
|
|
2284
|
+
if (items && prevItems && items.length !== prevItems.length) {
|
|
2285
|
+
this.calculatePageNumber(items, this.state.paginationSettings);
|
|
2286
|
+
}
|
|
2287
|
+
if (settings && !lodash.isEqual(settings, prevSettings)) {
|
|
2288
|
+
this.setState(
|
|
2289
|
+
{
|
|
2290
|
+
paginationSettings: settings
|
|
2291
|
+
},
|
|
2292
|
+
() => this.handleChangePage(0)
|
|
2293
|
+
);
|
|
2294
|
+
}
|
|
2295
|
+
}
|
|
2296
|
+
render() {
|
|
2297
|
+
const {
|
|
2298
|
+
uniqueItemKey,
|
|
2299
|
+
isLoading,
|
|
2300
|
+
columnDefs,
|
|
2301
|
+
rowDef,
|
|
2302
|
+
tableName,
|
|
2303
|
+
clickable,
|
|
2304
|
+
selectable,
|
|
2305
|
+
selectedItems,
|
|
2306
|
+
onChangeSize
|
|
2307
|
+
} = this.props;
|
|
2308
|
+
const finalColumnDefs = selectable ? extendColumnDefsWithCheckboxes(
|
|
2309
|
+
columnDefs,
|
|
2310
|
+
this.handleSelectChange,
|
|
2311
|
+
this.handleSelectAllChange,
|
|
2312
|
+
this.areSelectedAll(),
|
|
2313
|
+
selectedItems || [],
|
|
2314
|
+
uniqueItemKey
|
|
2315
|
+
) : columnDefs;
|
|
2316
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2317
|
+
Reactable,
|
|
2318
|
+
{
|
|
2319
|
+
columnDefs: finalColumnDefs,
|
|
2320
|
+
rowDef,
|
|
2321
|
+
uniqueItemKey,
|
|
2322
|
+
paginationSettings: this.state.paginationSettings,
|
|
2323
|
+
onChangePage: this.handleChangePage,
|
|
2324
|
+
onChangeSize,
|
|
2325
|
+
onSort: this.handleSort,
|
|
2326
|
+
onFilter: this.handleFilter,
|
|
2327
|
+
tableName,
|
|
2328
|
+
pageable: this.getPageable(),
|
|
2329
|
+
isLoading,
|
|
2330
|
+
clickable,
|
|
2331
|
+
"data-testid": this.props["data-testid"]
|
|
2332
|
+
}
|
|
2333
|
+
);
|
|
2334
|
+
}
|
|
2335
|
+
}
|
|
2336
|
+
const _FileUpload = class _FileUpload extends React__namespace.Component {
|
|
2337
|
+
constructor() {
|
|
2338
|
+
super(...arguments);
|
|
2339
|
+
this.state = {
|
|
2340
|
+
files: []
|
|
2341
|
+
};
|
|
2342
|
+
this.handleDrop = (accepted, rejected) => {
|
|
2343
|
+
if (!this.props.multiple && accepted.length > 1) {
|
|
2344
|
+
return;
|
|
2345
|
+
}
|
|
2346
|
+
if (rejected.length > 0) {
|
|
2347
|
+
return;
|
|
2348
|
+
}
|
|
2349
|
+
setTimeout(() => this.selectFile(accepted), 100);
|
|
2350
|
+
};
|
|
2351
|
+
this.selectFile = (files) => {
|
|
2352
|
+
const { onSelectFile, onChange } = this.props;
|
|
2353
|
+
files.forEach((file) => {
|
|
2354
|
+
file.preview = URL.createObjectURL(file);
|
|
2355
|
+
});
|
|
2356
|
+
const newFiles = [...this.state.files, ...files];
|
|
2357
|
+
this.setState({ files: newFiles });
|
|
2358
|
+
onChange?.(newFiles);
|
|
2359
|
+
if (onSelectFile) {
|
|
2360
|
+
files.forEach((file) => {
|
|
2361
|
+
onSelectFile(file);
|
|
2362
|
+
});
|
|
2363
|
+
}
|
|
2364
|
+
};
|
|
2365
|
+
this.handleRemoveFile = (file) => {
|
|
2366
|
+
const { files } = this.state;
|
|
2367
|
+
if (file) {
|
|
2368
|
+
if (file.preview) window.URL.revokeObjectURL(file.preview);
|
|
2369
|
+
const newFiles = files.filter((f) => f !== file);
|
|
2370
|
+
this.setState({ files: newFiles });
|
|
2371
|
+
this.props.onChange?.(newFiles);
|
|
2372
|
+
this.props.onRemoveFile?.(file);
|
|
2373
|
+
}
|
|
2374
|
+
};
|
|
2375
|
+
}
|
|
2376
|
+
render() {
|
|
2377
|
+
const { files } = this.state;
|
|
2378
|
+
const {
|
|
2379
|
+
accept,
|
|
2380
|
+
previewComponent: Preview,
|
|
2381
|
+
dropHint,
|
|
2382
|
+
hoverHint,
|
|
2383
|
+
acceptHint,
|
|
2384
|
+
rejectHint,
|
|
2385
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2386
|
+
onChange,
|
|
2387
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2388
|
+
onRemoveFile,
|
|
2389
|
+
onDownloadFile,
|
|
2390
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2391
|
+
onSelectFile,
|
|
2392
|
+
onDropRejected,
|
|
2393
|
+
onDropAccepted,
|
|
2394
|
+
maxSize,
|
|
2395
|
+
multiple,
|
|
2396
|
+
...otherProps
|
|
2397
|
+
} = this.props;
|
|
2398
|
+
const dropHintOrDefault = dropHint || _FileUpload.defaultProps.dropHint;
|
|
2399
|
+
const hoverHintOrDefault = hoverHint || _FileUpload.defaultProps.hoverHint;
|
|
2400
|
+
const acceptHintOrDefault = acceptHint || _FileUpload.defaultProps.acceptHint;
|
|
2401
|
+
const rejectHintOrDefault = rejectHint || _FileUpload.defaultProps.rejectHint;
|
|
2402
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2403
|
+
"div",
|
|
2404
|
+
{
|
|
2405
|
+
...otherProps,
|
|
2406
|
+
className: cx("di upload", {
|
|
2407
|
+
clickable: !files.length,
|
|
2408
|
+
hasContent: !!files.length
|
|
2409
|
+
}),
|
|
2410
|
+
children: [
|
|
2411
|
+
!!Preview && files.map((file, i) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2412
|
+
Preview,
|
|
2413
|
+
{
|
|
2414
|
+
file,
|
|
2415
|
+
onRemoveFile: () => this.handleRemoveFile(file),
|
|
2416
|
+
onDownloadFile: onDownloadFile ? () => onDownloadFile(file) : void 0
|
|
2417
|
+
},
|
|
2418
|
+
i
|
|
2419
|
+
)),
|
|
2420
|
+
(multiple || !files.length) && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2421
|
+
Dropzone,
|
|
2422
|
+
{
|
|
2423
|
+
accept,
|
|
2424
|
+
multiple: multiple ?? false,
|
|
2425
|
+
onDrop: this.handleDrop,
|
|
2426
|
+
onDropRejected,
|
|
2427
|
+
onDropAccepted,
|
|
2428
|
+
maxSize: maxSize || Infinity,
|
|
2429
|
+
children: ({ getRootProps, getInputProps, isDragAccept, isDragReject, isDragActive }) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2430
|
+
"div",
|
|
2431
|
+
{
|
|
2432
|
+
className: cx("drag-drop-text-container", {
|
|
2433
|
+
active: isDragActive,
|
|
2434
|
+
accept: isDragAccept,
|
|
2435
|
+
reject: isDragReject
|
|
2436
|
+
}),
|
|
2437
|
+
...getRootProps(),
|
|
2438
|
+
children: [
|
|
2439
|
+
/* @__PURE__ */ jsxRuntime.jsx("input", { ...getInputProps() }),
|
|
2440
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "drag-drop-hint", children: /* @__PURE__ */ jsxRuntime.jsx(Trans, { i18nKey: dropHintOrDefault.id, children: dropHintOrDefault.defaultValue }) }),
|
|
2441
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "drag-drop-hover-hint", children: /* @__PURE__ */ jsxRuntime.jsx(Trans, { i18nKey: hoverHintOrDefault.id, children: hoverHintOrDefault.defaultValue }) }),
|
|
2442
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "drag-drop-accept", children: /* @__PURE__ */ jsxRuntime.jsx(Trans, { i18nKey: acceptHintOrDefault.id, children: acceptHintOrDefault.defaultValue }) }),
|
|
2443
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "drag-drop-reject", children: /* @__PURE__ */ jsxRuntime.jsx(Trans, { i18nKey: rejectHintOrDefault.id, children: rejectHintOrDefault.defaultValue }) })
|
|
2444
|
+
]
|
|
2445
|
+
}
|
|
2446
|
+
)
|
|
2447
|
+
}
|
|
2448
|
+
)
|
|
2449
|
+
]
|
|
2450
|
+
}
|
|
2451
|
+
);
|
|
2452
|
+
}
|
|
2453
|
+
};
|
|
2454
|
+
_FileUpload.defaultProps = {
|
|
2455
|
+
dropHint: {
|
|
2456
|
+
id: "fileUpload.dropHint",
|
|
2457
|
+
defaultValue: "Drop file here, or click to browse ..."
|
|
2458
|
+
},
|
|
2459
|
+
hoverHint: {
|
|
2460
|
+
id: "fileUpload.hoverHint",
|
|
2461
|
+
defaultValue: "Drop file here, or click to browse ..."
|
|
2462
|
+
},
|
|
2463
|
+
acceptHint: {
|
|
2464
|
+
id: "fileUpload.acceptHint",
|
|
2465
|
+
defaultValue: "This file type can be uploaded"
|
|
2466
|
+
},
|
|
2467
|
+
rejectHint: {
|
|
2468
|
+
id: "fileUpload.rejectHint",
|
|
2469
|
+
defaultValue: "This file type cannot be uploaded"
|
|
2470
|
+
}
|
|
2471
|
+
};
|
|
2472
|
+
let FileUpload = _FileUpload;
|
|
2473
|
+
const PreviewImage = ({ url, imageSize, onRemoveFile, onDragOver, onDownloadFile }) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "di upload preview-container", onDragOver, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2474
|
+
"div",
|
|
2475
|
+
{
|
|
2476
|
+
className: "preview",
|
|
2477
|
+
style: {
|
|
2478
|
+
backgroundImage: `url(${url})`,
|
|
2479
|
+
...imageSize && { backgroundSize: imageSize }
|
|
2480
|
+
},
|
|
2481
|
+
children: [
|
|
2482
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { className: "action-button", onClick: onRemoveFile, "data-testid": "delete-button", children: /* @__PURE__ */ jsxRuntime.jsx(Trans, { i18nKey: "imageUpload.remove", children: "Remove" }) }),
|
|
2483
|
+
onDownloadFile && /* @__PURE__ */ jsxRuntime.jsx("button", { className: "action-button", onClick: onDownloadFile, "data-testid": "download-button", children: /* @__PURE__ */ jsxRuntime.jsx(Trans, { i18nKey: "imageUpload.download", children: "Download" }) })
|
|
2484
|
+
]
|
|
2485
|
+
}
|
|
2486
|
+
) });
|
|
2487
|
+
class ImageUpload extends React.Component {
|
|
2488
|
+
constructor() {
|
|
2489
|
+
super(...arguments);
|
|
2490
|
+
this.state = {
|
|
2491
|
+
dragOverPreview: false,
|
|
2492
|
+
file: null
|
|
2493
|
+
};
|
|
2494
|
+
this.handleDragOver = () => {
|
|
2495
|
+
this.setState({
|
|
2496
|
+
dragOverPreview: true
|
|
2497
|
+
});
|
|
2498
|
+
};
|
|
2499
|
+
}
|
|
2500
|
+
componentDidUpdate(prevProps) {
|
|
2501
|
+
if (prevProps.imageUrl !== this.props.imageUrl) {
|
|
2502
|
+
this.setState({
|
|
2503
|
+
dragOverPreview: false
|
|
2504
|
+
});
|
|
2505
|
+
}
|
|
2506
|
+
}
|
|
2507
|
+
render() {
|
|
2508
|
+
const { accept, imageUrl, imageSize, onSelectFile, onRemoveFile, onDownloadFile, ...otherProps } = this.props;
|
|
2509
|
+
const { dragOverPreview, file } = this.state;
|
|
2510
|
+
if (imageUrl && !dragOverPreview && file) {
|
|
2511
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2512
|
+
PreviewImage,
|
|
2513
|
+
{
|
|
2514
|
+
url: imageUrl,
|
|
2515
|
+
imageSize,
|
|
2516
|
+
onRemoveFile: () => onRemoveFile?.(file),
|
|
2517
|
+
onDownloadFile: onDownloadFile ? () => onDownloadFile(file) : void 0,
|
|
2518
|
+
onDragOver: this.handleDragOver
|
|
2519
|
+
}
|
|
2520
|
+
);
|
|
2521
|
+
} else {
|
|
2522
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2523
|
+
FileUpload,
|
|
2524
|
+
{
|
|
2525
|
+
...otherProps,
|
|
2526
|
+
onRemoveFile: (file2) => {
|
|
2527
|
+
this.setState({ file: null });
|
|
2528
|
+
onRemoveFile?.(file2);
|
|
2529
|
+
},
|
|
2530
|
+
onSelectFile: (file2) => {
|
|
2531
|
+
this.setState({ file: file2 });
|
|
2532
|
+
onSelectFile?.(file2);
|
|
2533
|
+
},
|
|
2534
|
+
accept: accept || {
|
|
2535
|
+
"image/*": [".jpeg", ".jpg", ".png", ".webp"]
|
|
2536
|
+
}
|
|
2537
|
+
}
|
|
2538
|
+
);
|
|
2539
|
+
}
|
|
2540
|
+
}
|
|
2541
|
+
}
|
|
2542
|
+
const arrowBackIcon = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA3NpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDYuMC1jMDAyIDc5LjE2NDQ2MCwgMjAyMC8wNS8xMi0xNjowNDoxNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtcE1NOk9yaWdpbmFsRG9jdW1lbnRJRD0ieG1wLmRpZDplMjI2NGVmOC0xY2Q1LTgyNDQtOWQ5NS0yZDBjNGMxMmZkM2UiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6MDhENjczMThERTNEMTFFQUIwNjJCODBDQ0RGM0I4QkEiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6MDhENjczMTdERTNEMTFFQUIwNjJCODBDQ0RGM0I4QkEiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIDIxLjIgKFdpbmRvd3MpIj4gPHhtcE1NOkRlcml2ZWRGcm9tIHN0UmVmOmluc3RhbmNlSUQ9InhtcC5paWQ6NTcyODQ4NjktNjA0NC0xZjQ2LTg2OWMtMjBlYzMwMTA0MWE2IiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOmUyMjY0ZWY4LTFjZDUtODI0NC05ZDk1LTJkMGM0YzEyZmQzZSIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PnOjy94AAABySURBVHjapFMJDsAgCFvJ/v/lbkvYEQ4naGIiShtaASS3lSWjRwA8d4/gAutxSLJrsr3/6kKUc0uPKnDgioQS2BKUwY8HBhzFoc+/31ipAF0JkoDY7cQyiWTmzJLADZN2HIwn2dD5Ct5EzBiK1XE+BBgAvZQfJzDjL2UAAAAASUVORK5CYII=";
|
|
2543
|
+
const ContentHeader = ({
|
|
2544
|
+
parentPageLink,
|
|
2545
|
+
title,
|
|
2546
|
+
subPagePathPrefixArray,
|
|
2547
|
+
subPagePathPrefix,
|
|
2548
|
+
subtitle,
|
|
2549
|
+
children
|
|
2550
|
+
}) => {
|
|
2551
|
+
const { push } = reactRouterDom.useHistory();
|
|
2552
|
+
const { pathname } = reactRouterDom.useLocation();
|
|
2553
|
+
const { t } = useTranslation();
|
|
2554
|
+
const goToParentPage = () => {
|
|
2555
|
+
if (subPagePathPrefix) {
|
|
2556
|
+
push(pathname.substring(0, pathname.lastIndexOf(subPagePathPrefix)));
|
|
2557
|
+
} else if (subPagePathPrefixArray) {
|
|
2558
|
+
subPagePathPrefixArray.forEach((pathPrefix) => {
|
|
2559
|
+
if (pathname.includes(pathPrefix)) {
|
|
2560
|
+
push(pathname.substring(0, pathname.lastIndexOf(pathPrefix)));
|
|
2561
|
+
}
|
|
2562
|
+
});
|
|
2563
|
+
} else {
|
|
2564
|
+
push(pathname.substring(0, pathname.lastIndexOf("/")));
|
|
2565
|
+
}
|
|
2566
|
+
};
|
|
2567
|
+
const printStringOrMessage = (stringOrMessage) => {
|
|
2568
|
+
if (typeof stringOrMessage === "string") {
|
|
2569
|
+
return stringOrMessage;
|
|
2570
|
+
} else {
|
|
2571
|
+
const { id, defaultValue } = stringOrMessage;
|
|
2572
|
+
return t(id, {
|
|
2573
|
+
defaultValue
|
|
2574
|
+
});
|
|
2575
|
+
}
|
|
2576
|
+
};
|
|
2577
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("h1", { className: "di header", children: [
|
|
2578
|
+
parentPageLink && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2579
|
+
ngUiBasicComponents.Button,
|
|
2580
|
+
{
|
|
2581
|
+
onClick: goToParentPage,
|
|
2582
|
+
style: {
|
|
2583
|
+
marginRight: "15px"
|
|
2584
|
+
},
|
|
2585
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2586
|
+
"img",
|
|
2587
|
+
{
|
|
2588
|
+
src: arrowBackIcon,
|
|
2589
|
+
alt: t("general.navigation.goBack", {
|
|
2590
|
+
defaultValue: "Go Back"
|
|
2591
|
+
})
|
|
2592
|
+
}
|
|
2593
|
+
)
|
|
2594
|
+
}
|
|
2595
|
+
),
|
|
2596
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: printStringOrMessage(title) }),
|
|
2597
|
+
subtitle && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "search-result-count", children: printStringOrMessage(subtitle) }),
|
|
2598
|
+
children
|
|
2599
|
+
] });
|
|
2600
|
+
};
|
|
2601
|
+
const formatTime = (timezone2, date) => {
|
|
2602
|
+
try {
|
|
2603
|
+
return dayjs.tz(date, timezone2).format("HH:mm");
|
|
2604
|
+
} catch (error) {
|
|
2605
|
+
console.error("DateTimeInput: Error while extracting time from date", error);
|
|
2606
|
+
return "00:00";
|
|
2607
|
+
}
|
|
2608
|
+
};
|
|
2609
|
+
const DateTimeInput = React.forwardRef(
|
|
2610
|
+
({ timestamp, timezone: timezone2, warning, readOnly = false, onChange, ...otherProps }, ref) => {
|
|
2611
|
+
const [time, setTime] = React.useState(formatTime(timezone2, timestamp));
|
|
2612
|
+
const timeValue = time == null ? formatTime(timezone2, timestamp) : time;
|
|
2613
|
+
React.useEffect(() => {
|
|
2614
|
+
setTime(formatTime(timezone2, timestamp));
|
|
2615
|
+
}, [timezone2, timestamp]);
|
|
2616
|
+
function handleChangeDate(date, fromTextField) {
|
|
2617
|
+
const currentDate = dayjs.tz(timestamp, timezone2);
|
|
2618
|
+
const newDate = dayjs.tz(date, timezone2).set("hour", currentDate.hour()).set("minute", currentDate.minute()).set("second", currentDate.second()).set("millisecond", currentDate.millisecond());
|
|
2619
|
+
onChange(newDate.valueOf(), fromTextField);
|
|
2620
|
+
}
|
|
2621
|
+
function handleChangeTime(time2, valid) {
|
|
2622
|
+
if (valid) {
|
|
2623
|
+
const [hours, minutes] = time2.split(":").map(Number);
|
|
2624
|
+
const newDate = dayjs.tz(timestamp, timezone2).set("hours", hours).set("minutes", minutes);
|
|
2625
|
+
onChange(newDate.valueOf(), true);
|
|
2626
|
+
}
|
|
2627
|
+
setTime(time2);
|
|
2628
|
+
}
|
|
2629
|
+
function tryFixTime() {
|
|
2630
|
+
if (time && /^[0-9]:[0-5][0-9]$/.test(time)) {
|
|
2631
|
+
handleChangeTime(time.padStart(5, "0"), true);
|
|
2632
|
+
}
|
|
2633
|
+
}
|
|
2634
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: `di date-time-input ${warning ? "with-warning" : ""}`, children: [
|
|
2635
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2636
|
+
DateInput,
|
|
2637
|
+
{
|
|
2638
|
+
...otherProps,
|
|
2639
|
+
ref,
|
|
2640
|
+
value: timestamp,
|
|
2641
|
+
timezone: timezone2,
|
|
2642
|
+
onChange: handleChangeDate,
|
|
2643
|
+
readOnly
|
|
2644
|
+
}
|
|
2645
|
+
),
|
|
2646
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2647
|
+
ValidatedTextInput,
|
|
2648
|
+
{
|
|
2649
|
+
"data-testid": "time-input",
|
|
2650
|
+
value: timeValue,
|
|
2651
|
+
onChange: handleChangeTime,
|
|
2652
|
+
pattern: /^(([01][0-9])|2[0-3]):[0-5][0-9]$/,
|
|
2653
|
+
required: true,
|
|
2654
|
+
invalidStyle: {
|
|
2655
|
+
borderColor: "red"
|
|
2656
|
+
},
|
|
2657
|
+
placeholder: "00:00",
|
|
2658
|
+
className: "time",
|
|
2659
|
+
onBlur: tryFixTime,
|
|
2660
|
+
disabled: readOnly
|
|
2661
|
+
}
|
|
2662
|
+
)
|
|
2663
|
+
] });
|
|
2664
|
+
}
|
|
2665
|
+
);
|
|
2666
|
+
class SelectWithSearchAsync extends React.Component {
|
|
2667
|
+
constructor() {
|
|
2668
|
+
super(...arguments);
|
|
2669
|
+
this.state = {
|
|
2670
|
+
cache: {},
|
|
2671
|
+
currentItem: null
|
|
2672
|
+
};
|
|
2673
|
+
this.selectRef = React.createRef();
|
|
2674
|
+
this.transformBackendItemToSelectItem = (backendItem) => {
|
|
2675
|
+
const { labelKey, valueKey } = this.props;
|
|
2676
|
+
return {
|
|
2677
|
+
value: backendItem[valueKey],
|
|
2678
|
+
label: backendItem[labelKey]
|
|
2679
|
+
};
|
|
2680
|
+
};
|
|
2681
|
+
this.reloadItemFromCache = () => {
|
|
2682
|
+
const { value } = this.props;
|
|
2683
|
+
const { currentItem, cache } = this.state;
|
|
2684
|
+
if (value && (!currentItem || currentItem.value !== value) && cache[value]) {
|
|
2685
|
+
this.setState({
|
|
2686
|
+
currentItem: cache[value]
|
|
2687
|
+
});
|
|
2688
|
+
return true;
|
|
2689
|
+
}
|
|
2690
|
+
return false;
|
|
2691
|
+
};
|
|
2692
|
+
this.addBackendItemToCache = (item) => {
|
|
2693
|
+
if (item) {
|
|
2694
|
+
const selectItem = this.transformBackendItemToSelectItem(item);
|
|
2695
|
+
const id = selectItem.value;
|
|
2696
|
+
this.setState(({ cache }) => ({
|
|
2697
|
+
cache: { ...cache, [id]: selectItem }
|
|
2698
|
+
}));
|
|
2699
|
+
}
|
|
2700
|
+
};
|
|
2701
|
+
this.fetchOptions = async (input, options) => {
|
|
2702
|
+
const { searchByQuery } = this.props;
|
|
2703
|
+
try {
|
|
2704
|
+
const { content, number, totalPages } = await searchByQuery(input, options.length);
|
|
2705
|
+
return {
|
|
2706
|
+
options: content.map(this.transformBackendItemToSelectItem),
|
|
2707
|
+
hasMore: number < totalPages - 1
|
|
2708
|
+
};
|
|
2709
|
+
} catch (error) {
|
|
2710
|
+
console.error("Error fetching options:", error);
|
|
2711
|
+
return { hasMore: false, options: [] };
|
|
2712
|
+
}
|
|
2713
|
+
};
|
|
2714
|
+
this.handleChange = (item) => {
|
|
2715
|
+
const { onChange } = this.props;
|
|
2716
|
+
if (item) {
|
|
2717
|
+
const id = item.value;
|
|
2718
|
+
this.setState(
|
|
2719
|
+
({ cache }) => ({
|
|
2720
|
+
cache: { ...cache, [id]: item }
|
|
2721
|
+
}),
|
|
2722
|
+
() => {
|
|
2723
|
+
onChange(id);
|
|
2724
|
+
}
|
|
2725
|
+
);
|
|
2726
|
+
} else {
|
|
2727
|
+
onChange(null);
|
|
2728
|
+
}
|
|
2729
|
+
};
|
|
2730
|
+
}
|
|
2731
|
+
componentDidMount() {
|
|
2732
|
+
const { value, searchById } = this.props;
|
|
2733
|
+
if (value) {
|
|
2734
|
+
searchById(value).then(this.addBackendItemToCache);
|
|
2735
|
+
}
|
|
2736
|
+
if (this.props["data-testid"]) {
|
|
2737
|
+
setTimeout(() => {
|
|
2738
|
+
if (this.selectRef?.current?.controlRef) {
|
|
2739
|
+
this.selectRef.current.controlRef.setAttribute("data-testid", this.props["data-testid"]);
|
|
2740
|
+
}
|
|
2741
|
+
}, 0);
|
|
2742
|
+
}
|
|
2743
|
+
}
|
|
2744
|
+
componentDidUpdate() {
|
|
2745
|
+
const { value, searchById } = this.props;
|
|
2746
|
+
const { currentItem } = this.state;
|
|
2747
|
+
if (value && (!currentItem || currentItem.value !== value)) {
|
|
2748
|
+
const foundInCache = this.reloadItemFromCache();
|
|
2749
|
+
if (!foundInCache) {
|
|
2750
|
+
searchById(value).then(this.addBackendItemToCache);
|
|
2751
|
+
}
|
|
2752
|
+
} else if (!value && currentItem) {
|
|
2753
|
+
this.setState({
|
|
2754
|
+
currentItem: null
|
|
2755
|
+
});
|
|
2756
|
+
}
|
|
2757
|
+
}
|
|
2758
|
+
render() {
|
|
2759
|
+
const { clearable, noResultsMessage, disabled, menuPortalTarget } = this.props;
|
|
2760
|
+
const { currentItem } = this.state;
|
|
2761
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2762
|
+
reactSelectAsyncPaginate.AsyncPaginate,
|
|
2763
|
+
{
|
|
2764
|
+
selectRef: this.selectRef,
|
|
2765
|
+
className: "select-search-container",
|
|
2766
|
+
classNamePrefix: "select-search",
|
|
2767
|
+
isClearable: clearable,
|
|
2768
|
+
noResultsText: noResultsMessage,
|
|
2769
|
+
value: currentItem,
|
|
2770
|
+
onChange: this.handleChange,
|
|
2771
|
+
loadOptions: this.fetchOptions,
|
|
2772
|
+
isDisabled: disabled,
|
|
2773
|
+
menuPortalTarget,
|
|
2774
|
+
placeholder: this.props.placeholder
|
|
2775
|
+
}
|
|
2776
|
+
);
|
|
2777
|
+
}
|
|
2778
|
+
}
|
|
2779
|
+
class MultiMenuItem extends React__namespace.PureComponent {
|
|
2780
|
+
constructor() {
|
|
2781
|
+
super(...arguments);
|
|
2782
|
+
this.createClickHandler = (toggleMenu) => () => {
|
|
2783
|
+
const { onClick } = this.props;
|
|
2784
|
+
if (onClick) {
|
|
2785
|
+
onClick();
|
|
2786
|
+
}
|
|
2787
|
+
toggleMenu();
|
|
2788
|
+
};
|
|
2789
|
+
}
|
|
2790
|
+
render() {
|
|
2791
|
+
const { disabled, icon, children, linkTo } = this.props;
|
|
2792
|
+
const dataTestId = this.props["data-testid"];
|
|
2793
|
+
return /* @__PURE__ */ jsxRuntime.jsx(MultiMenuContext.Consumer, { children: ({ toggleMenu }) => linkTo ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2794
|
+
reactRouterDom.Link,
|
|
2795
|
+
{
|
|
2796
|
+
"data-testid": dataTestId,
|
|
2797
|
+
to: linkTo,
|
|
2798
|
+
className: `item ${disabled ? "disabled" : ""}`,
|
|
2799
|
+
onClick: this.createClickHandler(toggleMenu),
|
|
2800
|
+
children: [
|
|
2801
|
+
icon && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "item-icon", children: icon }),
|
|
2802
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "item-text", children })
|
|
2803
|
+
]
|
|
2804
|
+
}
|
|
2805
|
+
) : /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2806
|
+
"div",
|
|
2807
|
+
{
|
|
2808
|
+
"data-testid": dataTestId,
|
|
2809
|
+
className: `item ${disabled ? "disabled" : ""}`,
|
|
2810
|
+
onClick: this.createClickHandler(toggleMenu),
|
|
2811
|
+
children: [
|
|
2812
|
+
icon && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "item-icon", children: icon }),
|
|
2813
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "item-text", children })
|
|
2814
|
+
]
|
|
2815
|
+
}
|
|
2816
|
+
) });
|
|
2817
|
+
}
|
|
2818
|
+
}
|
|
2819
|
+
const ONE_HOUR = 60 * 60 * 1e3;
|
|
2820
|
+
function Inputs({ period, onChange, readOnly, locale, timezone: timezone2 }) {
|
|
2821
|
+
const [showWarningTarget, setShowWarningTarget] = React.useState("");
|
|
2822
|
+
const warningTimeoutRef = React.useRef(void 0);
|
|
2823
|
+
const endDateRef = React.useRef(null);
|
|
2824
|
+
const startDate = new Date(period.tsStart);
|
|
2825
|
+
const endDate = new Date(period.tsEnd);
|
|
2826
|
+
function showWarning(target) {
|
|
2827
|
+
if (warningTimeoutRef.current) {
|
|
2828
|
+
clearTimeout(warningTimeoutRef.current);
|
|
2829
|
+
}
|
|
2830
|
+
setShowWarningTarget(target);
|
|
2831
|
+
warningTimeoutRef.current = setTimeout(() => setShowWarningTarget(""), 1e3);
|
|
2832
|
+
}
|
|
2833
|
+
function handleChangeStartDate(timestamp, fromTextField) {
|
|
2834
|
+
if (timestamp) {
|
|
2835
|
+
const incorrect = period.tsEnd && timestamp > period.tsEnd;
|
|
2836
|
+
const tsEnd = incorrect ? timestamp + ONE_HOUR : period.tsEnd;
|
|
2837
|
+
const newPeriod = {
|
|
2838
|
+
tsStart: timestamp,
|
|
2839
|
+
tsEnd
|
|
2840
|
+
};
|
|
2841
|
+
if (!lodash.isEqual(newPeriod, period)) {
|
|
2842
|
+
onChange(newPeriod);
|
|
2843
|
+
}
|
|
2844
|
+
if (!fromTextField && endDateRef.current) {
|
|
2845
|
+
endDateRef.current.focus();
|
|
2846
|
+
}
|
|
2847
|
+
if (incorrect) {
|
|
2848
|
+
showWarning("date-to");
|
|
2849
|
+
}
|
|
2850
|
+
}
|
|
2851
|
+
}
|
|
2852
|
+
function handleChangeEndDate(timestamp) {
|
|
2853
|
+
if (timestamp) {
|
|
2854
|
+
const incorrect = period.tsStart && timestamp < period.tsStart;
|
|
2855
|
+
const tsStart = incorrect ? timestamp - ONE_HOUR : period.tsStart;
|
|
2856
|
+
const newPeriod = {
|
|
2857
|
+
tsStart,
|
|
2858
|
+
tsEnd: timestamp
|
|
2859
|
+
};
|
|
2860
|
+
if (!lodash.isEqual(newPeriod, period)) {
|
|
2861
|
+
onChange(newPeriod);
|
|
2862
|
+
}
|
|
2863
|
+
if (incorrect) {
|
|
2864
|
+
showWarning("date-from");
|
|
2865
|
+
}
|
|
2866
|
+
}
|
|
2867
|
+
}
|
|
2868
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "inputs", children: [
|
|
2869
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { "data-testid": "from-wrapper", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2870
|
+
DateTimeInput,
|
|
2871
|
+
{
|
|
2872
|
+
timestamp: period.tsStart,
|
|
2873
|
+
onChange: handleChangeStartDate,
|
|
2874
|
+
warning: showWarningTarget === "date-from",
|
|
2875
|
+
selectsStart: true,
|
|
2876
|
+
startDate,
|
|
2877
|
+
endDate,
|
|
2878
|
+
readOnly,
|
|
2879
|
+
locale,
|
|
2880
|
+
timezone: timezone2
|
|
2881
|
+
}
|
|
2882
|
+
) }),
|
|
2883
|
+
" - ",
|
|
2884
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { "data-testid": "to-wrapper", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2885
|
+
DateTimeInput,
|
|
2886
|
+
{
|
|
2887
|
+
ref: endDateRef,
|
|
2888
|
+
timestamp: period.tsEnd,
|
|
2889
|
+
onChange: handleChangeEndDate,
|
|
2890
|
+
warning: showWarningTarget === "date-to",
|
|
2891
|
+
selectsEnd: true,
|
|
2892
|
+
startDate,
|
|
2893
|
+
endDate,
|
|
2894
|
+
readOnly,
|
|
2895
|
+
locale,
|
|
2896
|
+
timezone: timezone2
|
|
2897
|
+
}
|
|
2898
|
+
) })
|
|
2899
|
+
] });
|
|
2900
|
+
}
|
|
2901
|
+
class MonthPicker extends React.Component {
|
|
2902
|
+
constructor(props) {
|
|
2903
|
+
super(props);
|
|
2904
|
+
this.tdMonth = (month2) => {
|
|
2905
|
+
const { selectedMonth, selectedYear, displayedYear } = this.state;
|
|
2906
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2907
|
+
"td",
|
|
2908
|
+
{
|
|
2909
|
+
"data-testid": `month-${month2}-button`,
|
|
2910
|
+
onClick: () => {
|
|
2911
|
+
this.props.onChange(month2, displayedYear);
|
|
2912
|
+
this.setState({
|
|
2913
|
+
selectedMonth: month2,
|
|
2914
|
+
selectedYear: displayedYear
|
|
2915
|
+
});
|
|
2916
|
+
},
|
|
2917
|
+
className: cx({ selected: month2 === selectedMonth && displayedYear === selectedYear }),
|
|
2918
|
+
children: dayjs(`${selectedYear}/${month2.toString().padStart(2, "0")}/01`, "YYYY/MM/DD").format("MMM")
|
|
2919
|
+
}
|
|
2920
|
+
);
|
|
2921
|
+
};
|
|
2922
|
+
const month = props.month !== null && props.month !== void 0 ? props.month : dayjs().month() + 1;
|
|
2923
|
+
const year = props.year !== null && props.year !== void 0 ? props.year : dayjs().year();
|
|
2924
|
+
this.state = {
|
|
2925
|
+
selectedMonth: month,
|
|
2926
|
+
selectedYear: year,
|
|
2927
|
+
displayedYear: year
|
|
2928
|
+
};
|
|
2929
|
+
}
|
|
2930
|
+
render() {
|
|
2931
|
+
const { displayedYear } = this.state;
|
|
2932
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "di monthpicker", children: [
|
|
2933
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pager", children: [
|
|
2934
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2935
|
+
"span",
|
|
2936
|
+
{
|
|
2937
|
+
className: "page-nav prev",
|
|
2938
|
+
onClick: () => {
|
|
2939
|
+
this.setState({
|
|
2940
|
+
displayedYear: displayedYear - 1
|
|
2941
|
+
});
|
|
2942
|
+
}
|
|
2943
|
+
}
|
|
2944
|
+
),
|
|
2945
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "page-nav info", children: displayedYear }),
|
|
2946
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2947
|
+
"span",
|
|
2948
|
+
{
|
|
2949
|
+
className: "page-nav next",
|
|
2950
|
+
onClick: () => {
|
|
2951
|
+
this.setState({
|
|
2952
|
+
displayedYear: displayedYear + 1
|
|
2953
|
+
});
|
|
2954
|
+
}
|
|
2955
|
+
}
|
|
2956
|
+
)
|
|
2957
|
+
] }),
|
|
2958
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "months", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2959
|
+
"table",
|
|
2960
|
+
{
|
|
2961
|
+
style: {
|
|
2962
|
+
margin: "auto"
|
|
2963
|
+
},
|
|
2964
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("tbody", { children: [
|
|
2965
|
+
/* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
|
|
2966
|
+
this.tdMonth(1),
|
|
2967
|
+
this.tdMonth(2),
|
|
2968
|
+
this.tdMonth(3)
|
|
2969
|
+
] }),
|
|
2970
|
+
/* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
|
|
2971
|
+
this.tdMonth(4),
|
|
2972
|
+
this.tdMonth(5),
|
|
2973
|
+
this.tdMonth(6)
|
|
2974
|
+
] }),
|
|
2975
|
+
/* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
|
|
2976
|
+
this.tdMonth(7),
|
|
2977
|
+
this.tdMonth(8),
|
|
2978
|
+
this.tdMonth(9)
|
|
2979
|
+
] }),
|
|
2980
|
+
/* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
|
|
2981
|
+
this.tdMonth(10),
|
|
2982
|
+
this.tdMonth(11),
|
|
2983
|
+
this.tdMonth(12)
|
|
2984
|
+
] })
|
|
2985
|
+
] })
|
|
2986
|
+
}
|
|
2987
|
+
) })
|
|
2988
|
+
] });
|
|
2989
|
+
}
|
|
2990
|
+
}
|
|
2991
|
+
const imgIconCalendar = "data:image/svg+xml,%3csvg%20id='Layer_1'%20data-name='Layer%201'%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2016%2016'%3e%3cdefs%3e%3cstyle%3e%20.cls-1%20{%20fill:%20%23fff;%20}%20%3c/style%3e%3c/defs%3e%3cg%3e%3cg%3e%3crect%20class='cls-1'%20x='3.5'%20y='7.5'%20width='2'%20height='2'/%3e%3cpath%20d='M5,8V9H4V8H5M6,7H3v3H6V7Z'/%3e%3c/g%3e%3cg%3e%3crect%20class='cls-1'%20x='8'%20y='7'%20width='1'%20height='1'/%3e%3cpolygon%20points='9%207%208%207%208%208%209%208%209%207%209%207'/%3e%3c/g%3e%3cg%3e%3crect%20class='cls-1'%20x='10'%20y='7'%20width='1'%20height='1'/%3e%3cpolygon%20points='11%207%2010%207%2010%208%2011%208%2011%207%2011%207'/%3e%3c/g%3e%3cg%3e%3crect%20class='cls-1'%20x='12'%20y='7'%20width='1'%20height='1'/%3e%3cpolygon%20points='13%207%2012%207%2012%208%2013%208%2013%207%2013%207'/%3e%3c/g%3e%3cg%3e%3crect%20class='cls-1'%20x='8'%20y='9'%20width='1'%20height='1'/%3e%3cpolygon%20points='9%209%208%209%208%2010%209%2010%209%209%209%209'/%3e%3c/g%3e%3cg%3e%3crect%20class='cls-1'%20x='8'%20y='11'%20width='1'%20height='1'/%3e%3cpolygon%20points='9%2011%208%2011%208%2012%209%2012%209%2011%209%2011'/%3e%3c/g%3e%3cg%3e%3crect%20class='cls-1'%20x='6'%20y='11'%20width='1'%20height='1'/%3e%3cpolygon%20points='7%2011%206%2011%206%2012%207%2012%207%2011%207%2011'/%3e%3c/g%3e%3cg%3e%3crect%20class='cls-1'%20x='4'%20y='11'%20width='1'%20height='1'/%3e%3cpolygon%20points='5%2011%204%2011%204%2012%205%2012%205%2011%205%2011'/%3e%3c/g%3e%3cg%3e%3crect%20class='cls-1'%20x='10.5'%20y='9.5'%20width='2'%20height='2'/%3e%3cpath%20d='M12,10v1H11V10h1m1-1H10v3h3V9Z'/%3e%3c/g%3e%3cpath%20d='M15.31,2H.69A.69.69,0,0,0,0,2.69V14.31A.69.69,0,0,0,.69,15H15.31a.69.69,0,0,0,.69-.69V2.69A.69.69,0,0,0,15.31,2ZM14,13H2V6H14Z'/%3e%3c/g%3e%3crect%20x='3'%20width='3'%20height='2'/%3e%3crect%20x='10'%20width='3'%20height='2'/%3e%3c/svg%3e";
|
|
2992
|
+
const imgTriangleDown = "data:image/svg+xml,%3csvg%20id='Layer_1'%20data-name='Layer%201'%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2016%2016'%3e%3cpolygon%20points='7.5%2010%204%206%2011%206%207.5%2010'/%3e%3c/svg%3e";
|
|
2993
|
+
dayjs.extend(timezone);
|
|
2994
|
+
dayjs.extend(utc);
|
|
2995
|
+
function dayjsTz(timezone2, ts) {
|
|
2996
|
+
return timezone2 ? dayjs.tz(ts, timezone2) : dayjs(ts);
|
|
2997
|
+
}
|
|
2998
|
+
function createToday(timezone2) {
|
|
2999
|
+
return {
|
|
3000
|
+
tsStart: dayjsTz(timezone2).startOf("day").valueOf(),
|
|
3001
|
+
tsEnd: dayjsTz(timezone2).endOf("day").valueOf()
|
|
3002
|
+
};
|
|
3003
|
+
}
|
|
3004
|
+
function createYesterday(timezone2) {
|
|
3005
|
+
return {
|
|
3006
|
+
tsStart: dayjsTz(timezone2).subtract(1, "day").startOf("day").valueOf(),
|
|
3007
|
+
tsEnd: dayjsTz(timezone2).subtract(1, "day").endOf("day").valueOf()
|
|
3008
|
+
};
|
|
3009
|
+
}
|
|
3010
|
+
function createCurrentWeek(timezone2) {
|
|
3011
|
+
return {
|
|
3012
|
+
tsStart: dayjsTz(timezone2).startOf("week").valueOf(),
|
|
3013
|
+
tsEnd: dayjsTz(timezone2).endOf("week").valueOf()
|
|
3014
|
+
};
|
|
3015
|
+
}
|
|
3016
|
+
function createCurrentMonth(timezone2) {
|
|
3017
|
+
return {
|
|
3018
|
+
tsStart: dayjsTz(timezone2).startOf("month").valueOf(),
|
|
3019
|
+
tsEnd: dayjsTz(timezone2).endOf("month").valueOf()
|
|
3020
|
+
};
|
|
3021
|
+
}
|
|
3022
|
+
function createWholeDay(tsMiddle, timezone2) {
|
|
3023
|
+
return {
|
|
3024
|
+
tsStart: dayjsTz(timezone2, tsMiddle).startOf("day").valueOf(),
|
|
3025
|
+
tsEnd: dayjsTz(timezone2, tsMiddle).endOf("day").valueOf()
|
|
3026
|
+
};
|
|
3027
|
+
}
|
|
3028
|
+
function createWholeMonth(tsMiddle, timezone2) {
|
|
3029
|
+
return {
|
|
3030
|
+
tsStart: dayjsTz(timezone2, tsMiddle).startOf("month").valueOf(),
|
|
3031
|
+
tsEnd: dayjsTz(timezone2, tsMiddle).endOf("month").valueOf()
|
|
3032
|
+
};
|
|
3033
|
+
}
|
|
3034
|
+
function createLastXDays(days, timezone2) {
|
|
3035
|
+
const tsStart = dayjsTz(timezone2).subtract(days - 1, "days").startOf("day").valueOf();
|
|
3036
|
+
const tsEnd = dayjs().endOf("day").valueOf();
|
|
3037
|
+
return { tsStart, tsEnd };
|
|
3038
|
+
}
|
|
3039
|
+
const DAY_TO_MILLIS = 1e3 * 60 * 60 * 24;
|
|
3040
|
+
function periodToDays({ tsStart, tsEnd }) {
|
|
3041
|
+
return Math.round((tsEnd - tsStart + 1) / DAY_TO_MILLIS);
|
|
3042
|
+
}
|
|
3043
|
+
function Menu({ onChange, onShowCustomPeriod, periodName, timezone: timezone2 }) {
|
|
3044
|
+
const [visible, setVisible] = React.useState(false);
|
|
3045
|
+
const [showDatePicker, setShowDatePicker] = React.useState(false);
|
|
3046
|
+
const [showMonthPicker, setShowMonthPicker] = React.useState(false);
|
|
3047
|
+
const [datePickerDate, setDatePickerDate] = React.useState(Date.now());
|
|
3048
|
+
function setPeriod(period) {
|
|
3049
|
+
onChange(period);
|
|
3050
|
+
setVisible(false);
|
|
3051
|
+
if (onShowCustomPeriod) {
|
|
3052
|
+
onShowCustomPeriod(false);
|
|
3053
|
+
}
|
|
3054
|
+
}
|
|
3055
|
+
function setPeriodSpecificDate(date) {
|
|
3056
|
+
setPeriod(createWholeDay(date ?? Date.now(), timezone2));
|
|
3057
|
+
setShowDatePicker(false);
|
|
3058
|
+
setDatePickerDate(date ?? void 0);
|
|
3059
|
+
}
|
|
3060
|
+
function setPeriodSpecificMonth(month, year) {
|
|
3061
|
+
setPeriod(
|
|
3062
|
+
createWholeMonth(
|
|
3063
|
+
dayjs().year(year).month(month - 1).valueOf(),
|
|
3064
|
+
timezone2
|
|
3065
|
+
)
|
|
3066
|
+
);
|
|
3067
|
+
setShowMonthPicker(false);
|
|
3068
|
+
}
|
|
3069
|
+
function toggleDatePicker() {
|
|
3070
|
+
setShowDatePicker(!showDatePicker);
|
|
3071
|
+
setShowMonthPicker(false);
|
|
3072
|
+
}
|
|
3073
|
+
function toggleMonthPicker() {
|
|
3074
|
+
setShowMonthPicker(!showMonthPicker);
|
|
3075
|
+
setShowDatePicker(false);
|
|
3076
|
+
}
|
|
3077
|
+
function handleCustomPeriodSelect() {
|
|
3078
|
+
setVisible(false);
|
|
3079
|
+
if (onShowCustomPeriod) {
|
|
3080
|
+
onShowCustomPeriod(true);
|
|
3081
|
+
}
|
|
3082
|
+
}
|
|
3083
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3084
|
+
ngUiBasicComponents.Popup,
|
|
3085
|
+
{
|
|
3086
|
+
open: visible,
|
|
3087
|
+
onOpenChange: setVisible,
|
|
3088
|
+
handler: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3089
|
+
ngUiBasicComponents.Button,
|
|
3090
|
+
{
|
|
3091
|
+
"data-testid": "time-period-menu-button",
|
|
3092
|
+
title: {
|
|
3093
|
+
id: "trend.calendarMenu.calendar.timePeriod",
|
|
3094
|
+
defaultValue: "Time Period"
|
|
3095
|
+
},
|
|
3096
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
3097
|
+
/* @__PURE__ */ jsxRuntime.jsx("img", { src: imgIconCalendar, alt: "calendar icon", style: { width: 16, height: 16 } }),
|
|
3098
|
+
" ",
|
|
3099
|
+
!!periodName && /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
|
|
3100
|
+
" ",
|
|
3101
|
+
periodName,
|
|
3102
|
+
" "
|
|
3103
|
+
] }),
|
|
3104
|
+
/* @__PURE__ */ jsxRuntime.jsx("img", { src: imgTriangleDown, alt: "triangle down", style: { width: 16, height: 16 } })
|
|
3105
|
+
] })
|
|
3106
|
+
}
|
|
3107
|
+
),
|
|
3108
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "di multimenu period-picker-multimenu", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `drop bottom ${visible ? "show" : ""}`, children: [
|
|
3109
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: `left-box ${showDatePicker ? "show" : ""}`, children: /* @__PURE__ */ jsxRuntime.jsx(DateInput, { inline: true, value: datePickerDate, onChange: setPeriodSpecificDate }) }),
|
|
3110
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: `left-box ${showMonthPicker ? "show" : ""}`, children: /* @__PURE__ */ jsxRuntime.jsx(MonthPicker, { onChange: setPeriodSpecificMonth }) }),
|
|
3111
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "right-box", children: [
|
|
3112
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3113
|
+
"div",
|
|
3114
|
+
{
|
|
3115
|
+
className: "item",
|
|
3116
|
+
"data-testid": "today-button",
|
|
3117
|
+
onClick: () => setPeriod(createToday(timezone2)),
|
|
3118
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "item-text", children: /* @__PURE__ */ jsxRuntime.jsx(Trans, { i18nKey: "trend.calendarMenu.timePeriod.today", children: "Today" }) })
|
|
3119
|
+
}
|
|
3120
|
+
),
|
|
3121
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3122
|
+
"div",
|
|
3123
|
+
{
|
|
3124
|
+
className: "item",
|
|
3125
|
+
"data-testid": "yesterday-button",
|
|
3126
|
+
onClick: () => setPeriod(createYesterday(timezone2)),
|
|
3127
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "item-text", children: /* @__PURE__ */ jsxRuntime.jsx(Trans, { i18nKey: "trend.calendarMenu.timePeriod.yesterday", children: "Yesterday" }) })
|
|
3128
|
+
}
|
|
3129
|
+
),
|
|
3130
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "item", children: [
|
|
3131
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3132
|
+
"div",
|
|
3133
|
+
{
|
|
3134
|
+
"data-testid": "last-7-days-button",
|
|
3135
|
+
className: "item-text",
|
|
3136
|
+
onClick: () => setPeriod(createLastXDays(7, timezone2)),
|
|
3137
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Trans, { i18nKey: "trend.calendarMenu.timePeriod.lastSevenDays", children: "Last 7 days" })
|
|
3138
|
+
}
|
|
3139
|
+
),
|
|
3140
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "item-more icon triangle", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "item-more-submenu", children: [2, 3, 5, 10, 14, 30].map((days) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3141
|
+
"div",
|
|
3142
|
+
{
|
|
3143
|
+
className: "subitem",
|
|
3144
|
+
onClick: () => setPeriod(createLastXDays(days, timezone2)),
|
|
3145
|
+
children: days
|
|
3146
|
+
},
|
|
3147
|
+
days
|
|
3148
|
+
)) }) })
|
|
3149
|
+
] }),
|
|
3150
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3151
|
+
"div",
|
|
3152
|
+
{
|
|
3153
|
+
className: "item",
|
|
3154
|
+
"data-testid": "current-week-button",
|
|
3155
|
+
onClick: () => setPeriod(createCurrentWeek(timezone2)),
|
|
3156
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "item-text", children: /* @__PURE__ */ jsxRuntime.jsx(Trans, { i18nKey: "trend.calendarMenu.timePeriod.currentWeek", children: "Curr. Week" }) })
|
|
3157
|
+
}
|
|
3158
|
+
),
|
|
3159
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3160
|
+
"div",
|
|
3161
|
+
{
|
|
3162
|
+
className: "item",
|
|
3163
|
+
"data-testid": "current-month-button",
|
|
3164
|
+
onClick: () => setPeriod(createCurrentMonth(timezone2)),
|
|
3165
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "item-text", children: /* @__PURE__ */ jsxRuntime.jsx(Trans, { i18nKey: "trend.calendarMenu.timePeriod.currentMonth", children: "Curr. Month" }) })
|
|
3166
|
+
}
|
|
3167
|
+
),
|
|
3168
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "item", "data-testid": "day-button", onClick: toggleDatePicker, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "item-text", children: [
|
|
3169
|
+
/* @__PURE__ */ jsxRuntime.jsx(Trans, { i18nKey: "trend.calendarMenu.timePeriod.day", children: "Day" }),
|
|
3170
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "item-more icon dots" })
|
|
3171
|
+
] }) }),
|
|
3172
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "item", "data-testid": "month-button", onClick: toggleMonthPicker, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "item-text", children: [
|
|
3173
|
+
/* @__PURE__ */ jsxRuntime.jsx(Trans, { i18nKey: "trend.calendarMenu.timePeriod.month", children: "Month" }),
|
|
3174
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "item-more icon dots" })
|
|
3175
|
+
] }) }),
|
|
3176
|
+
onShowCustomPeriod !== void 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "item", "data-testid": "from-to-button", onClick: handleCustomPeriodSelect, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "item-text", children: /* @__PURE__ */ jsxRuntime.jsx(Trans, { i18nKey: "trend.calendarMenu.timePeriod.fromto", children: "From/to" }) }) })
|
|
3177
|
+
] })
|
|
3178
|
+
] }) })
|
|
3179
|
+
}
|
|
3180
|
+
) });
|
|
3181
|
+
}
|
|
3182
|
+
function compare(period1, period2) {
|
|
3183
|
+
return period1.tsStart === period2.tsStart && period1.tsEnd === period2.tsEnd;
|
|
3184
|
+
}
|
|
3185
|
+
function usePeriodName(period, timezone2) {
|
|
3186
|
+
const { t } = useTranslation();
|
|
3187
|
+
if (compare(period, createToday(timezone2))) {
|
|
3188
|
+
return t("trend.calendarMenu.timePeriod.today", { defaultValue: "Today" });
|
|
3189
|
+
}
|
|
3190
|
+
if (compare(period, createYesterday(timezone2))) {
|
|
3191
|
+
return t("trend.calendarMenu.timePeriod.yesterday", { defaultValue: "Yesterday" });
|
|
3192
|
+
}
|
|
3193
|
+
if (compare(period, createCurrentWeek(timezone2))) {
|
|
3194
|
+
return t("trend.calendarMenu.timePeriod.currentWeek", { defaultValue: "Curr. Week" });
|
|
3195
|
+
}
|
|
3196
|
+
if (compare(period, createCurrentMonth(timezone2))) {
|
|
3197
|
+
return t("trend.calendarMenu.timePeriod.currentMonth", { defaultValue: "Curr. Month" });
|
|
3198
|
+
}
|
|
3199
|
+
if (compare(period, createWholeDay((period.tsStart + period.tsEnd) / 2, timezone2))) {
|
|
3200
|
+
return t("trend.calendarMenu.timePeriod.day", { defaultValue: "Day" });
|
|
3201
|
+
}
|
|
3202
|
+
if (compare(period, createWholeMonth((period.tsStart + period.tsEnd) / 2, timezone2))) {
|
|
3203
|
+
return t("trend.calendarMenu.timePeriod.month", { defaultValue: "Month" });
|
|
3204
|
+
}
|
|
3205
|
+
const days = periodToDays(period);
|
|
3206
|
+
if (compare(period, createLastXDays(days, timezone2))) {
|
|
3207
|
+
return t("trend.calendarMenu.timePeriod.lastDays", {
|
|
3208
|
+
defaultValue: `Last ${days} days`,
|
|
3209
|
+
days
|
|
3210
|
+
});
|
|
3211
|
+
}
|
|
3212
|
+
return void 0;
|
|
3213
|
+
}
|
|
3214
|
+
function PeriodPicker({
|
|
3215
|
+
period,
|
|
3216
|
+
onChange,
|
|
3217
|
+
inputsHiddenByDefault,
|
|
3218
|
+
menuHidden,
|
|
3219
|
+
readOnly,
|
|
3220
|
+
locale,
|
|
3221
|
+
defaultPeriodName,
|
|
3222
|
+
timezone: timezone2,
|
|
3223
|
+
...props
|
|
3224
|
+
}) {
|
|
3225
|
+
const [showInputs, setShowInputs] = React.useState(!inputsHiddenByDefault);
|
|
3226
|
+
const periodName = usePeriodName(period, timezone2) ?? defaultPeriodName;
|
|
3227
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "di period-picker", "data-testid": props["data-testid"], children: [
|
|
3228
|
+
(!inputsHiddenByDefault || showInputs) && /* @__PURE__ */ jsxRuntime.jsx(Inputs, { period, onChange, locale, readOnly, timezone: timezone2 }),
|
|
3229
|
+
menuHidden || readOnly || /* @__PURE__ */ jsxRuntime.jsx(
|
|
3230
|
+
Menu,
|
|
3231
|
+
{
|
|
3232
|
+
periodName,
|
|
3233
|
+
onShowCustomPeriod: inputsHiddenByDefault ? setShowInputs : void 0,
|
|
3234
|
+
onChange,
|
|
3235
|
+
timezone: timezone2
|
|
3236
|
+
}
|
|
3237
|
+
)
|
|
3238
|
+
] });
|
|
3239
|
+
}
|
|
3240
|
+
const CONFLICTING_IDS_DETECTION_DELAY = 500;
|
|
3241
|
+
const calculateIdCountsInElement = (element) => {
|
|
3242
|
+
return Array.from(element.querySelectorAll("[id]")).map((element2) => element2.getAttribute("id")).reduce((acc, id) => {
|
|
3243
|
+
if (id) acc[id] = acc[id] + 1 || 1;
|
|
3244
|
+
return acc;
|
|
3245
|
+
}, {});
|
|
3246
|
+
};
|
|
3247
|
+
const findAllDuplicatedIdsInSvgElement = (svgElement) => {
|
|
3248
|
+
const idCountsInDocument = calculateIdCountsInElement(document);
|
|
3249
|
+
const idCountsInSvg = calculateIdCountsInElement(svgElement);
|
|
3250
|
+
return Object.keys(idCountsInSvg).filter((key) => idCountsInSvg[key] < idCountsInDocument[key]);
|
|
3251
|
+
};
|
|
3252
|
+
function findConflicts(svgElement, onConflict) {
|
|
3253
|
+
const timeoutId = setTimeout(() => {
|
|
3254
|
+
if (onConflict) {
|
|
3255
|
+
onConflict(findAllDuplicatedIdsInSvgElement(svgElement));
|
|
3256
|
+
}
|
|
3257
|
+
}, CONFLICTING_IDS_DETECTION_DELAY);
|
|
3258
|
+
return () => clearTimeout(timeoutId);
|
|
3259
|
+
}
|
|
3260
|
+
const SVG_NS = "http://www.w3.org/2000/svg";
|
|
3261
|
+
function createHyperlinkModification(element, { hoverColor, internalLink, link }, globalStyleElement, onInternalLinkChange) {
|
|
3262
|
+
const anchor = wrapIntoAnchor(element);
|
|
3263
|
+
if (!anchor) return;
|
|
3264
|
+
const uniqueClassName = `a${uuidV4(8)}`;
|
|
3265
|
+
element.classList.add("anchor", uniqueClassName);
|
|
3266
|
+
if (hoverColor && globalStyleElement?.sheet) {
|
|
3267
|
+
globalStyleElement.sheet.insertRule(
|
|
3268
|
+
`.di.svg-image .anchor.${uniqueClassName}:hover, .di.svg-image .anchor.${uniqueClassName}:hover * { stroke: ${hoverColor} !important; }`
|
|
3269
|
+
);
|
|
3270
|
+
}
|
|
3271
|
+
anchor.setAttributeNS(SVG_NS, "xlink:href", "#");
|
|
3272
|
+
anchor.addEventListener(
|
|
3273
|
+
"click",
|
|
3274
|
+
() => internalLink && onInternalLinkChange ? onInternalLinkChange(link) : window.open(link, "_newtab")
|
|
3275
|
+
);
|
|
3276
|
+
}
|
|
3277
|
+
function wrapIntoAnchor(wrappedElement) {
|
|
3278
|
+
const parentNode = wrappedElement.parentNode;
|
|
3279
|
+
if (!parentNode) {
|
|
3280
|
+
return null;
|
|
3281
|
+
}
|
|
3282
|
+
const siblings = parentNode.childNodes;
|
|
3283
|
+
if (!siblings) {
|
|
3284
|
+
return null;
|
|
3285
|
+
}
|
|
3286
|
+
const index = Array.from(siblings).findIndex((el) => el === wrappedElement);
|
|
3287
|
+
const wrapperElement = document.createElementNS(SVG_NS, "a");
|
|
3288
|
+
wrapperElement.appendChild(wrappedElement);
|
|
3289
|
+
const siblingNode = siblings[index] || null;
|
|
3290
|
+
if (siblingNode) {
|
|
3291
|
+
parentNode.insertBefore(wrapperElement, siblingNode);
|
|
3292
|
+
} else {
|
|
3293
|
+
parentNode.appendChild(wrapperElement);
|
|
3294
|
+
}
|
|
3295
|
+
return wrapperElement;
|
|
3296
|
+
}
|
|
3297
|
+
const removeSvgNamespace = (xml) => xml.replace(/<svg:svg/g, "<svg").replace(/<\/svg:svg/g, "</svg");
|
|
3298
|
+
const parseFromString = (imageData) => {
|
|
3299
|
+
const parser = new DOMParser();
|
|
3300
|
+
const xml = removeSvgNamespace(atob(imageData.replace("data:image/svg+xml;base64,", "")));
|
|
3301
|
+
return parser.parseFromString(xml, "image/svg+xml");
|
|
3302
|
+
};
|
|
3303
|
+
function getMutableNodeList(imageData, diFieldId) {
|
|
3304
|
+
const doc = parseFromString(imageData);
|
|
3305
|
+
return doc.querySelectorAll(`[id^="${diFieldId}"]`);
|
|
3306
|
+
}
|
|
3307
|
+
const mergePositionChanges = (modifications) => {
|
|
3308
|
+
const positionModifications = modifications.filter(({ type }) => type === "positionX" || type === "positionY");
|
|
3309
|
+
const restModifications = modifications.filter(({ type }) => type !== "positionX" && type !== "positionY");
|
|
3310
|
+
const positionByAxisModifications = positionModifications.reduce(
|
|
3311
|
+
(acc, modification) => {
|
|
3312
|
+
if (modification.type === "positionX") {
|
|
3313
|
+
return { ...acc, x: modification };
|
|
3314
|
+
} else if (modification.type === "positionY") {
|
|
3315
|
+
return { ...acc, y: modification };
|
|
3316
|
+
}
|
|
3317
|
+
return acc;
|
|
3318
|
+
},
|
|
3319
|
+
{
|
|
3320
|
+
x: null,
|
|
3321
|
+
y: null
|
|
3322
|
+
}
|
|
3323
|
+
);
|
|
3324
|
+
if (positionByAxisModifications.x && positionByAxisModifications.y) {
|
|
3325
|
+
return restModifications.concat([
|
|
3326
|
+
{
|
|
3327
|
+
type: "positionXY",
|
|
3328
|
+
target: positionByAxisModifications.x.target,
|
|
3329
|
+
positionX: positionByAxisModifications.x.position,
|
|
3330
|
+
positionY: positionByAxisModifications.y.position
|
|
3331
|
+
}
|
|
3332
|
+
]);
|
|
3333
|
+
} else if (positionByAxisModifications.x) {
|
|
3334
|
+
return restModifications.concat([positionByAxisModifications.x]);
|
|
3335
|
+
} else if (positionByAxisModifications.y) {
|
|
3336
|
+
return restModifications.concat([positionByAxisModifications.y]);
|
|
3337
|
+
} else {
|
|
3338
|
+
return restModifications;
|
|
3339
|
+
}
|
|
3340
|
+
};
|
|
3341
|
+
const transformPositionModifications = (modifications) => {
|
|
3342
|
+
const modificationsByTarget = modifications.reduce(
|
|
3343
|
+
(acc, modification) => ({
|
|
3344
|
+
...acc,
|
|
3345
|
+
[modification.target]: [...acc[modification.target] || [], modification]
|
|
3346
|
+
}),
|
|
3347
|
+
{}
|
|
3348
|
+
);
|
|
3349
|
+
return Object.keys(modificationsByTarget).reduce(
|
|
3350
|
+
(acc, target) => acc.concat(mergePositionChanges(modificationsByTarget[target])),
|
|
3351
|
+
[]
|
|
3352
|
+
);
|
|
3353
|
+
};
|
|
3354
|
+
const limitPercentagePosition = (position) => Math.max(0, Math.min(100, position));
|
|
3355
|
+
function createPositionModification(element, modification, svgElement) {
|
|
3356
|
+
const svg = svg_js.SVG(svgElement);
|
|
3357
|
+
const targetId = element.getAttribute("id") || "";
|
|
3358
|
+
const targetEl = svg.findOne(`#${targetId}`);
|
|
3359
|
+
const boundariesEl = svg.findOne(`#${targetId}-boundaries`);
|
|
3360
|
+
const bbox = boundariesEl ? boundariesEl.bbox() : svg.viewbox();
|
|
3361
|
+
if (modification.type === "positionX") {
|
|
3362
|
+
targetEl.x(bbox.x + limitPercentagePosition(modification.position) * bbox.width / 100);
|
|
3363
|
+
} else if (modification.type === "positionY") {
|
|
3364
|
+
targetEl.y(bbox.y + limitPercentagePosition(modification.position) * bbox.height / 100);
|
|
3365
|
+
} else {
|
|
3366
|
+
targetEl.x(bbox.x + limitPercentagePosition(modification.positionX) * bbox.width / 100);
|
|
3367
|
+
targetEl.y(bbox.y + limitPercentagePosition(modification.positionY) * bbox.height / 100);
|
|
3368
|
+
}
|
|
3369
|
+
}
|
|
3370
|
+
function renderSvg(svgWrapper, imageData, modifications, globalStyleElement, onInternalLinkChange) {
|
|
3371
|
+
const imageDocument = parseFromString(imageData);
|
|
3372
|
+
const svgElement = imageDocument.querySelector("svg");
|
|
3373
|
+
if (svgElement) {
|
|
3374
|
+
svgWrapper.style.height = "100%";
|
|
3375
|
+
svgWrapper.innerHTML = "";
|
|
3376
|
+
svgElement.style.height = "100%";
|
|
3377
|
+
svgElement.style.width = "100%";
|
|
3378
|
+
svgElement.classList.add("di", "svg-image");
|
|
3379
|
+
if (!svgElement.getAttribute("viewBox")) {
|
|
3380
|
+
svgElement.setAttribute("viewBox", "");
|
|
3381
|
+
}
|
|
3382
|
+
if (!svgElement.getAttribute("preserveAspectRatio")) {
|
|
3383
|
+
svgElement.setAttribute("preserveAspectRatio", "xMidYMid");
|
|
3384
|
+
}
|
|
3385
|
+
svgWrapper.appendChild(svgElement);
|
|
3386
|
+
applyModifications(svgElement, modifications, globalStyleElement, onInternalLinkChange);
|
|
3387
|
+
return svgElement;
|
|
3388
|
+
}
|
|
3389
|
+
return null;
|
|
3390
|
+
}
|
|
3391
|
+
function applyModifications(svgElement, modifications, globalStyleElement, onInternalLinkChange) {
|
|
3392
|
+
if (!modifications || !modifications.length) return;
|
|
3393
|
+
for (const modification of sortModifications(transformPositionModifications(modifications))) {
|
|
3394
|
+
const element = svgElement.querySelector(`[id=${modification.target}]`);
|
|
3395
|
+
if (element) {
|
|
3396
|
+
applyModification(element, modification, svgElement, globalStyleElement, onInternalLinkChange);
|
|
3397
|
+
}
|
|
3398
|
+
}
|
|
3399
|
+
}
|
|
3400
|
+
function applyModification(element, modification, svgElement, globalStyleElement, onInternalLinkChange) {
|
|
3401
|
+
switch (modification.type) {
|
|
3402
|
+
case "visibility":
|
|
3403
|
+
element.setAttribute("visibility", modification.visible ? "visible" : "hidden");
|
|
3404
|
+
break;
|
|
3405
|
+
case "text": {
|
|
3406
|
+
const tspan = element.querySelector("tspan");
|
|
3407
|
+
if (tspan) {
|
|
3408
|
+
tspan.textContent = modification.text;
|
|
3409
|
+
} else {
|
|
3410
|
+
element.textContent = modification.text;
|
|
3411
|
+
}
|
|
3412
|
+
break;
|
|
3413
|
+
}
|
|
3414
|
+
case "color": {
|
|
3415
|
+
const { color } = modification;
|
|
3416
|
+
const changeColor = (el) => {
|
|
3417
|
+
el.setAttribute("fill", color);
|
|
3418
|
+
el.style.fill = color;
|
|
3419
|
+
};
|
|
3420
|
+
changeColor(element);
|
|
3421
|
+
element.querySelectorAll("g, path").forEach(changeColor);
|
|
3422
|
+
break;
|
|
3423
|
+
}
|
|
3424
|
+
case "hyperlink":
|
|
3425
|
+
createHyperlinkModification(element, modification, globalStyleElement, onInternalLinkChange);
|
|
3426
|
+
break;
|
|
3427
|
+
case "eventListener":
|
|
3428
|
+
element.addEventListener(modification.eventType, modification.listener, modification.options);
|
|
3429
|
+
break;
|
|
3430
|
+
case "classNames":
|
|
3431
|
+
element.classList.add(...modification.classNames);
|
|
3432
|
+
break;
|
|
3433
|
+
case "positionX":
|
|
3434
|
+
case "positionY":
|
|
3435
|
+
case "positionXY":
|
|
3436
|
+
createPositionModification(element, modification, svgElement);
|
|
3437
|
+
break;
|
|
3438
|
+
case "rotation": {
|
|
3439
|
+
svg_js.SVG(element).rotate(modification.degrees);
|
|
3440
|
+
break;
|
|
3441
|
+
}
|
|
3442
|
+
default:
|
|
3443
|
+
throw new Error("Unknown modification");
|
|
3444
|
+
}
|
|
3445
|
+
}
|
|
3446
|
+
function sortModifications(modifications) {
|
|
3447
|
+
return modifications.sort(({ type: type1 }, { type: type2 }) => type1 !== type2 && type2 === "rotation" ? -1 : 1);
|
|
3448
|
+
}
|
|
3449
|
+
function useGlobalStyleElement() {
|
|
3450
|
+
const styleElementRef = React.useRef(null);
|
|
3451
|
+
React.useEffect(() => {
|
|
3452
|
+
const styleElement = document.createElement("style");
|
|
3453
|
+
styleElement.appendChild(document.createTextNode(""));
|
|
3454
|
+
if (document && document.head) {
|
|
3455
|
+
document.head.appendChild(styleElement);
|
|
3456
|
+
}
|
|
3457
|
+
styleElementRef.current = styleElement;
|
|
3458
|
+
return () => {
|
|
3459
|
+
if (document && document.head && styleElement) {
|
|
3460
|
+
document.head.removeChild(styleElement);
|
|
3461
|
+
}
|
|
3462
|
+
};
|
|
3463
|
+
}, []);
|
|
3464
|
+
return styleElementRef.current;
|
|
3465
|
+
}
|
|
3466
|
+
function SvgImage({ imageData, modifications, onConflict }) {
|
|
3467
|
+
const svgWrapperRef = React.useRef(null);
|
|
3468
|
+
const styleElement = useGlobalStyleElement();
|
|
3469
|
+
const { push } = reactRouterDom.useHistory();
|
|
3470
|
+
React.useEffect(() => {
|
|
3471
|
+
const { current: wrapper } = svgWrapperRef;
|
|
3472
|
+
if (wrapper && imageData) {
|
|
3473
|
+
const svgElement = renderSvg(wrapper, imageData, modifications, styleElement, push);
|
|
3474
|
+
if (svgElement && onConflict) {
|
|
3475
|
+
return findConflicts(svgElement, onConflict);
|
|
3476
|
+
}
|
|
3477
|
+
}
|
|
3478
|
+
}, [imageData, modifications, onConflict, push, styleElement]);
|
|
3479
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { ref: svgWrapperRef });
|
|
3480
|
+
}
|
|
3481
|
+
const getSvgElement = (imageData) => {
|
|
3482
|
+
try {
|
|
3483
|
+
const imageDoc = parseFromString(imageData);
|
|
3484
|
+
return imageDoc.querySelector("svg");
|
|
3485
|
+
} catch (e) {
|
|
3486
|
+
return null;
|
|
3487
|
+
}
|
|
3488
|
+
};
|
|
3489
|
+
const validateSvg = (imageData) => {
|
|
3490
|
+
const svgElement = getSvgElement(imageData);
|
|
3491
|
+
return !!svgElement && !!svgElement.style;
|
|
3492
|
+
};
|
|
3493
|
+
function createTooltip(header, name, value) {
|
|
3494
|
+
return `<div>${header}</div><div>${name}: <strong>${value}</strong></div>`;
|
|
3495
|
+
}
|
|
3496
|
+
const initialOptions = {
|
|
3497
|
+
global: {
|
|
3498
|
+
useUTC: false
|
|
3499
|
+
},
|
|
3500
|
+
chart: {
|
|
3501
|
+
style: {
|
|
3502
|
+
fontFamily: "arial"
|
|
3503
|
+
},
|
|
3504
|
+
plotBackgroundColor: null,
|
|
3505
|
+
plotBorderWidth: 0,
|
|
3506
|
+
plotShadow: false
|
|
3507
|
+
},
|
|
3508
|
+
credits: {
|
|
3509
|
+
enabled: false
|
|
3510
|
+
},
|
|
3511
|
+
legend: {
|
|
3512
|
+
align: "right",
|
|
3513
|
+
verticalAlign: "center",
|
|
3514
|
+
layout: "vertical"
|
|
3515
|
+
},
|
|
3516
|
+
title: {
|
|
3517
|
+
useHTML: true
|
|
3518
|
+
},
|
|
3519
|
+
plotOptions: {
|
|
3520
|
+
pie: {
|
|
3521
|
+
dataLabels: {
|
|
3522
|
+
enabled: false
|
|
3523
|
+
},
|
|
3524
|
+
showInLegend: true,
|
|
3525
|
+
startAngle: -90,
|
|
3526
|
+
endAngle: 270
|
|
3527
|
+
}
|
|
3528
|
+
},
|
|
3529
|
+
tooltip: {
|
|
3530
|
+
useHTML: true,
|
|
3531
|
+
formatter() {
|
|
3532
|
+
return createTooltip("", this.point.name, this.point.y);
|
|
3533
|
+
}
|
|
3534
|
+
},
|
|
3535
|
+
xAxis: {
|
|
3536
|
+
type: "category"
|
|
3537
|
+
},
|
|
3538
|
+
yAxis: {
|
|
3539
|
+
min: 0,
|
|
3540
|
+
title: {
|
|
3541
|
+
text: ""
|
|
3542
|
+
}
|
|
3543
|
+
},
|
|
3544
|
+
options: {
|
|
3545
|
+
lgo: 123
|
|
3546
|
+
}
|
|
3547
|
+
};
|
|
3548
|
+
const getClickConfiguration = (onClick) => {
|
|
3549
|
+
return onClick ? {
|
|
3550
|
+
series: {
|
|
3551
|
+
cursor: "pointer",
|
|
3552
|
+
point: {
|
|
3553
|
+
events: {
|
|
3554
|
+
click: function() {
|
|
3555
|
+
onClick(this.index);
|
|
3556
|
+
}
|
|
3557
|
+
}
|
|
3558
|
+
}
|
|
3559
|
+
}
|
|
3560
|
+
} : {};
|
|
3561
|
+
};
|
|
3562
|
+
class Chart extends React.Component {
|
|
3563
|
+
constructor() {
|
|
3564
|
+
super(...arguments);
|
|
3565
|
+
this.state = {};
|
|
3566
|
+
this.chart = null;
|
|
3567
|
+
this.ro = null;
|
|
3568
|
+
this.handleChart = (chart) => {
|
|
3569
|
+
this.chart = chart;
|
|
3570
|
+
this.ro = new ResizeObserver(() => {
|
|
3571
|
+
this.chart?.reflow();
|
|
3572
|
+
});
|
|
3573
|
+
this.ro.observe(this.chart.renderTo);
|
|
3574
|
+
};
|
|
3575
|
+
}
|
|
3576
|
+
componentDidMount() {
|
|
3577
|
+
const { type, title, items, tooltipTitle, valueFormatter, onClick } = this.props;
|
|
3578
|
+
this.setState({
|
|
3579
|
+
...initialOptions,
|
|
3580
|
+
plotOptions: { ...initialOptions.plotOptions, ...getClickConfiguration(onClick) },
|
|
3581
|
+
tooltip: {
|
|
3582
|
+
...initialOptions.tooltip,
|
|
3583
|
+
formatter() {
|
|
3584
|
+
const format = valueFormatter || ((value) => value);
|
|
3585
|
+
return createTooltip(tooltipTitle || "", this.point.name, format(this.point.y));
|
|
3586
|
+
}
|
|
3587
|
+
},
|
|
3588
|
+
legend: { ...initialOptions.legend, enabled: type === "pie" },
|
|
3589
|
+
yAxis: {
|
|
3590
|
+
...initialOptions.yAxis,
|
|
3591
|
+
enabled: type === "column",
|
|
3592
|
+
title: {
|
|
3593
|
+
text: title || ""
|
|
3594
|
+
}
|
|
3595
|
+
},
|
|
3596
|
+
series: [
|
|
3597
|
+
{
|
|
3598
|
+
type,
|
|
3599
|
+
innerSize: "50%",
|
|
3600
|
+
data: items.map(({ label, value }) => [label, value])
|
|
3601
|
+
}
|
|
3602
|
+
]
|
|
3603
|
+
});
|
|
3604
|
+
setTimeout(() => {
|
|
3605
|
+
this.setState({
|
|
3606
|
+
title: { ...initialOptions.title, text: type === "column" ? "" : title || "" }
|
|
3607
|
+
});
|
|
3608
|
+
}, 0);
|
|
3609
|
+
}
|
|
3610
|
+
componentDidUpdate(prevProps) {
|
|
3611
|
+
const { type, title, items, tooltipTitle, valueFormatter, onClick } = this.props;
|
|
3612
|
+
if (title !== prevProps.title) {
|
|
3613
|
+
this.setState({
|
|
3614
|
+
title: { ...this.state.title, text: type === "column" ? "" : title || "" },
|
|
3615
|
+
yAxis: {
|
|
3616
|
+
...this.state.yAxis,
|
|
3617
|
+
title: {
|
|
3618
|
+
text: title || ""
|
|
3619
|
+
}
|
|
3620
|
+
}
|
|
3621
|
+
});
|
|
3622
|
+
}
|
|
3623
|
+
if (type !== prevProps.type) {
|
|
3624
|
+
this.setState({
|
|
3625
|
+
legend: { ...this.state.legend, enabled: type === "pie" },
|
|
3626
|
+
title: {
|
|
3627
|
+
text: type === "column" ? "" : title || ""
|
|
3628
|
+
},
|
|
3629
|
+
yAxis: {
|
|
3630
|
+
...this.state.yAxis,
|
|
3631
|
+
enabled: type === "column",
|
|
3632
|
+
title: {
|
|
3633
|
+
text: type === "column" ? title || "" : ""
|
|
3634
|
+
}
|
|
3635
|
+
},
|
|
3636
|
+
series: [
|
|
3637
|
+
{
|
|
3638
|
+
type,
|
|
3639
|
+
innerSize: "50%",
|
|
3640
|
+
data: items.map(({ label, value }) => [label, value])
|
|
3641
|
+
}
|
|
3642
|
+
]
|
|
3643
|
+
});
|
|
3644
|
+
}
|
|
3645
|
+
if (!lodash.isEqual(items, prevProps.items)) {
|
|
3646
|
+
this.setState({
|
|
3647
|
+
series: [
|
|
3648
|
+
{
|
|
3649
|
+
type,
|
|
3650
|
+
innerSize: "50%",
|
|
3651
|
+
data: items.map(({ label, value }) => [label, value])
|
|
3652
|
+
}
|
|
3653
|
+
]
|
|
3654
|
+
});
|
|
3655
|
+
}
|
|
3656
|
+
if (tooltipTitle !== prevProps.tooltipTitle || valueFormatter !== prevProps.valueFormatter || onClick !== prevProps.onClick) {
|
|
3657
|
+
this.setState({
|
|
3658
|
+
tooltip: {
|
|
3659
|
+
...initialOptions.tooltip,
|
|
3660
|
+
formatter() {
|
|
3661
|
+
const format = valueFormatter || ((value) => value);
|
|
3662
|
+
return createTooltip(tooltipTitle || "", this.point.name, format(this.point.y));
|
|
3663
|
+
}
|
|
3664
|
+
},
|
|
3665
|
+
plotOptions: { ...initialOptions.plotOptions, ...getClickConfiguration(onClick) }
|
|
3666
|
+
});
|
|
3667
|
+
}
|
|
3668
|
+
}
|
|
3669
|
+
componentWillUnmount() {
|
|
3670
|
+
if (this.ro && this.chart?.renderTo) {
|
|
3671
|
+
this.ro.unobserve(this.chart.renderTo);
|
|
3672
|
+
}
|
|
3673
|
+
this.chart = null;
|
|
3674
|
+
this.ro = null;
|
|
3675
|
+
}
|
|
3676
|
+
render() {
|
|
3677
|
+
const options = this.props.updateOptions ? this.props.updateOptions(this.state) : this.state;
|
|
3678
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3679
|
+
HighchartsReact,
|
|
3680
|
+
{
|
|
3681
|
+
highcharts: Highcharts,
|
|
3682
|
+
options,
|
|
3683
|
+
containerProps: {
|
|
3684
|
+
className: this.props.className
|
|
3685
|
+
},
|
|
3686
|
+
callback: this.handleChart
|
|
3687
|
+
}
|
|
3688
|
+
);
|
|
3689
|
+
}
|
|
3690
|
+
}
|
|
3691
|
+
function getDefaultExportFromCjs(x) {
|
|
3692
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
3693
|
+
}
|
|
3694
|
+
var raf$1 = {};
|
|
3695
|
+
var hasRequiredRaf;
|
|
3696
|
+
function requireRaf() {
|
|
3697
|
+
if (hasRequiredRaf) return raf$1;
|
|
3698
|
+
hasRequiredRaf = 1;
|
|
3699
|
+
Object.defineProperty(raf$1, "__esModule", {
|
|
3700
|
+
value: true
|
|
3701
|
+
});
|
|
3702
|
+
raf$1.default = void 0;
|
|
3703
|
+
let raf2 = (callback) => +setTimeout(callback, 16);
|
|
3704
|
+
let caf = (num) => clearTimeout(num);
|
|
3705
|
+
if (typeof window !== "undefined" && "requestAnimationFrame" in window) {
|
|
3706
|
+
raf2 = (callback) => window.requestAnimationFrame(callback);
|
|
3707
|
+
caf = (handle) => window.cancelAnimationFrame(handle);
|
|
3708
|
+
}
|
|
3709
|
+
let rafUUID = 0;
|
|
3710
|
+
const rafIds = /* @__PURE__ */ new Map();
|
|
3711
|
+
function cleanup(id) {
|
|
3712
|
+
rafIds.delete(id);
|
|
3713
|
+
}
|
|
3714
|
+
const wrapperRaf = (callback, times = 1) => {
|
|
3715
|
+
rafUUID += 1;
|
|
3716
|
+
const id = rafUUID;
|
|
3717
|
+
function callRef(leftTimes) {
|
|
3718
|
+
if (leftTimes === 0) {
|
|
3719
|
+
cleanup(id);
|
|
3720
|
+
callback();
|
|
3721
|
+
} else {
|
|
3722
|
+
const realId = raf2(() => {
|
|
3723
|
+
callRef(leftTimes - 1);
|
|
3724
|
+
});
|
|
3725
|
+
rafIds.set(id, realId);
|
|
3726
|
+
}
|
|
3727
|
+
}
|
|
3728
|
+
callRef(times);
|
|
3729
|
+
return id;
|
|
3730
|
+
};
|
|
3731
|
+
wrapperRaf.cancel = (id) => {
|
|
3732
|
+
const realId = rafIds.get(id);
|
|
3733
|
+
cleanup(id);
|
|
3734
|
+
return caf(realId);
|
|
3735
|
+
};
|
|
3736
|
+
if (process.env.NODE_ENV !== "production") {
|
|
3737
|
+
wrapperRaf.ids = () => rafIds;
|
|
3738
|
+
}
|
|
3739
|
+
raf$1.default = wrapperRaf;
|
|
3740
|
+
return raf$1;
|
|
3741
|
+
}
|
|
3742
|
+
var rafExports = requireRaf();
|
|
3743
|
+
const raf = /* @__PURE__ */ getDefaultExportFromCjs(rafExports);
|
|
3744
|
+
const HandleTooltip = (props) => {
|
|
3745
|
+
const { value, children, visible, tipFormatter = (val) => `${val}`, ...restProps } = props;
|
|
3746
|
+
const tooltipRef = React.useRef(null);
|
|
3747
|
+
const rafRef = React.useRef(null);
|
|
3748
|
+
function cancelKeepAlign() {
|
|
3749
|
+
if (rafRef.current) {
|
|
3750
|
+
raf.cancel(rafRef.current);
|
|
3751
|
+
}
|
|
3752
|
+
}
|
|
3753
|
+
function keepAlign() {
|
|
3754
|
+
rafRef.current = raf(() => {
|
|
3755
|
+
tooltipRef.current?.forceAlign();
|
|
3756
|
+
});
|
|
3757
|
+
}
|
|
3758
|
+
React.useEffect(() => {
|
|
3759
|
+
if (visible) {
|
|
3760
|
+
keepAlign();
|
|
3761
|
+
} else {
|
|
3762
|
+
cancelKeepAlign();
|
|
3763
|
+
}
|
|
3764
|
+
return cancelKeepAlign;
|
|
3765
|
+
}, [value, visible]);
|
|
3766
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3767
|
+
Tooltip,
|
|
3768
|
+
{
|
|
3769
|
+
placement: "top",
|
|
3770
|
+
overlay: tipFormatter(value),
|
|
3771
|
+
ref: tooltipRef,
|
|
3772
|
+
align: { offset: [0, -10] },
|
|
3773
|
+
visible,
|
|
3774
|
+
...restProps,
|
|
3775
|
+
children
|
|
3776
|
+
}
|
|
3777
|
+
);
|
|
3778
|
+
};
|
|
3779
|
+
const TooltipSlider = ({ tipFormatter, tipProps, ...props }) => {
|
|
3780
|
+
const tipHandleRender = (node, handleProps) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3781
|
+
HandleTooltip,
|
|
3782
|
+
{
|
|
3783
|
+
value: handleProps.value,
|
|
3784
|
+
visible: handleProps.dragging,
|
|
3785
|
+
tipFormatter,
|
|
3786
|
+
...tipProps,
|
|
3787
|
+
children: node
|
|
3788
|
+
}
|
|
3789
|
+
);
|
|
3790
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Slider$1, { ...props, handleRender: tipHandleRender });
|
|
3791
|
+
};
|
|
3792
|
+
function useLimitStyling(limit, min, max) {
|
|
3793
|
+
const [slider, setSlider] = React.useState(null);
|
|
3794
|
+
React.useEffect(() => {
|
|
3795
|
+
if (slider) {
|
|
3796
|
+
const containerEl = slider.querySelector(".rc-slider-rail");
|
|
3797
|
+
if (!containerEl) throw new Error(".rc-slider-rail element missing");
|
|
3798
|
+
const disabledAreaEl = containerEl?.querySelector(`.disabled-area-element`);
|
|
3799
|
+
const sliderWidth = containerEl.getBoundingClientRect().width;
|
|
3800
|
+
if (disabledAreaEl) {
|
|
3801
|
+
if (limit == null) {
|
|
3802
|
+
disabledAreaEl.remove();
|
|
3803
|
+
} else {
|
|
3804
|
+
const width = Math.round((max - limit) / (max - min) * sliderWidth);
|
|
3805
|
+
disabledAreaEl.style.width = `${width}px`;
|
|
3806
|
+
}
|
|
3807
|
+
} else if (limit != null) {
|
|
3808
|
+
const width = Math.round((max - limit) / (max - min) * sliderWidth);
|
|
3809
|
+
const disabledAreaEl2 = document.createElement("div");
|
|
3810
|
+
disabledAreaEl2.classList.add("disabled-area-element");
|
|
3811
|
+
disabledAreaEl2.style.width = `${width}px`;
|
|
3812
|
+
containerEl.appendChild(disabledAreaEl2);
|
|
3813
|
+
}
|
|
3814
|
+
}
|
|
3815
|
+
}, [limit, slider, min, max]);
|
|
3816
|
+
const updateLimitAreaSize = React.useCallback(() => {
|
|
3817
|
+
if (slider && limit != null) {
|
|
3818
|
+
const containerEl = slider.querySelector(".rc-slider-rail");
|
|
3819
|
+
if (!containerEl) throw new Error(".rc-slider-rail element missing");
|
|
3820
|
+
const disabledAreaEl = containerEl?.querySelector(`.disabled-area-element`);
|
|
3821
|
+
const sliderWidth = containerEl.getBoundingClientRect().width;
|
|
3822
|
+
if (disabledAreaEl) {
|
|
3823
|
+
const width = Math.round((max - limit) / (max - min) * sliderWidth);
|
|
3824
|
+
disabledAreaEl.style.width = `${width}px`;
|
|
3825
|
+
}
|
|
3826
|
+
}
|
|
3827
|
+
}, [limit, max, min, slider]);
|
|
3828
|
+
React.useEffect(() => {
|
|
3829
|
+
if (slider) {
|
|
3830
|
+
const resizeObserver = new ResizeObserver(() => updateLimitAreaSize());
|
|
3831
|
+
resizeObserver.observe(slider);
|
|
3832
|
+
}
|
|
3833
|
+
}, [slider, updateLimitAreaSize]);
|
|
3834
|
+
return setSlider;
|
|
3835
|
+
}
|
|
3836
|
+
const Slider = ({ min, max, step, value, tooltip = true, labels, format, onChange, onChangeComplete, limit }) => {
|
|
3837
|
+
const setSliderRef = useLimitStyling(limit, min, max);
|
|
3838
|
+
const handleChange = (value2) => {
|
|
3839
|
+
if (!onChange) return;
|
|
3840
|
+
const numericValue = typeof value2 === "number" ? value2 : value2[0];
|
|
3841
|
+
const allowedValue = limit != null ? Math.min(numericValue, limit) : numericValue;
|
|
3842
|
+
onChange(allowedValue);
|
|
3843
|
+
};
|
|
3844
|
+
const handleChangeComplete = () => {
|
|
3845
|
+
if (!onChangeComplete) {
|
|
3846
|
+
return;
|
|
3847
|
+
}
|
|
3848
|
+
onChangeComplete(value);
|
|
3849
|
+
};
|
|
3850
|
+
const basicProps = {
|
|
3851
|
+
min,
|
|
3852
|
+
max,
|
|
3853
|
+
step,
|
|
3854
|
+
value,
|
|
3855
|
+
onChange: handleChange,
|
|
3856
|
+
onChangeComplete: handleChangeComplete,
|
|
3857
|
+
marks: labels
|
|
3858
|
+
};
|
|
3859
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "di slider", ref: setSliderRef, children: tooltip ? /* @__PURE__ */ jsxRuntime.jsx(TooltipSlider, { ...basicProps, className: "di slider with-tooltip", tipFormatter: format }) : /* @__PURE__ */ jsxRuntime.jsx(Slider$1, { ...basicProps, className: "di slider" }) });
|
|
3860
|
+
};
|
|
3861
|
+
exports.Chart = Chart;
|
|
3862
|
+
exports.ColorPicker = GridColorPicker;
|
|
3863
|
+
exports.ContentHeader = ContentHeader;
|
|
3864
|
+
exports.DateInput = DateInput;
|
|
3865
|
+
exports.DateTimeInput = DateTimeInput;
|
|
3866
|
+
exports.FileUpload = FileUpload;
|
|
3867
|
+
exports.GradientColorPicker = GradientColorPicker;
|
|
3868
|
+
exports.GridColorPicker = GridColorPicker;
|
|
3869
|
+
exports.ImageUpload = ImageUpload;
|
|
3870
|
+
exports.InfoBox = InfoBox;
|
|
3871
|
+
exports.MessageBoxContainer = MessageBoxContainer;
|
|
3872
|
+
exports.MultiMenu = MultiMenuFunctional;
|
|
3873
|
+
exports.MultiMenuItem = MultiMenuItem;
|
|
3874
|
+
exports.Pagination = Pagination;
|
|
3875
|
+
exports.PeriodPicker = PeriodPicker;
|
|
3876
|
+
exports.Reactable = Reactable;
|
|
3877
|
+
exports.ReactableWithClientSidePagination = ReactableWithClientSidePagination;
|
|
3878
|
+
exports.RouteLink = RouteLink;
|
|
3879
|
+
exports.RouteTabs = RouteTabs;
|
|
3880
|
+
exports.SelectWithSearch = SelectWithSearch;
|
|
3881
|
+
exports.SelectWithSearchAsync = SelectWithSearchAsync;
|
|
3882
|
+
exports.Slider = Slider;
|
|
3883
|
+
exports.SvgImage = SvgImage;
|
|
3884
|
+
exports.TreeView = TreeView;
|
|
3885
|
+
exports.UrnInput = UrnInput;
|
|
3886
|
+
exports.ValidatedTextInput = ValidatedTextInput;
|
|
3887
|
+
exports.getMutableNodeList = getMutableNodeList;
|
|
3888
|
+
exports.getSvgElement = getSvgElement;
|
|
3889
|
+
exports.getTreeNodePathById = getTreeNodePathById;
|
|
3890
|
+
exports.initializeTranslation = initializeTranslation;
|
|
3891
|
+
exports.messageBoxDismissAll = messageBoxDismissAll;
|
|
3892
|
+
exports.messageBoxDismissGroup = messageBoxDismissGroup;
|
|
3893
|
+
exports.messageBoxDismissSingle = messageBoxDismissSingle;
|
|
3894
|
+
exports.messageBoxError = messageBoxError;
|
|
3895
|
+
exports.messageBoxInfo = messageBoxInfo;
|
|
3896
|
+
exports.messageBoxSuccess = messageBoxSuccess;
|
|
3897
|
+
exports.messageBoxWarn = messageBoxWarn;
|
|
3898
|
+
exports.nanoid10 = nanoid10;
|
|
3899
|
+
exports.setGlobalErrorMessageBoxOptions = setGlobalErrorMessageBoxOptions;
|
|
3900
|
+
exports.uuidV4 = uuidV4;
|
|
3901
|
+
exports.validateSvg = validateSvg;
|
|
3902
|
+
exports.withPrompt = withPrompt;
|
|
2
3903
|
//# sourceMappingURL=index.cjs.map
|