@mmlogic/components 0.5.9 → 0.5.11
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/cjs/mrd-boolean-field_25.cjs.entry.js +87 -28
- package/dist/collection/components/table/mrd-table/mrd-table.js +87 -28
- package/dist/components/mrd-table2.js +1 -1
- package/dist/esm/mrd-boolean-field_25.entry.js +87 -28
- package/dist/mosterdcomponents/cell-renderer-B8u5BCK-.js.map +1 -0
- package/dist/mosterdcomponents/client-layout-Bc42CfJB.js.map +1 -0
- package/dist/mosterdcomponents/document-attachments-BufPmMRv.js.map +1 -0
- package/dist/mosterdcomponents/field-helpers-CUJsHr1V.js.map +1 -0
- package/dist/mosterdcomponents/file-upload-common-DdTDuxEU.js.map +1 -0
- package/dist/mosterdcomponents/format-gcecItcD.js.map +1 -0
- package/dist/mosterdcomponents/i18n-Ba7_jO9I.js.map +1 -0
- package/dist/mosterdcomponents/index-1ayBojyN.js.map +1 -0
- package/dist/mosterdcomponents/index-DhffneUF.js.map +1 -0
- package/dist/mosterdcomponents/index.esm.js.map +1 -0
- package/dist/mosterdcomponents/mosterdcomponents.esm.js +1 -1
- package/dist/mosterdcomponents/mosterdcomponents.esm.js.map +1 -0
- package/dist/mosterdcomponents/{p-986a68d6.entry.js → p-eee4be8b.entry.js} +2 -2
- package/dist/mosterdcomponents/purify.es-_duHfPgC.js.map +1 -0
- package/dist/mosterdcomponents/query-params-BZbQoeYF.js.map +1 -0
- package/dist/mosterdcomponents/quill-C9pgw_k-.js.map +1 -0
- package/dist/mosterdcomponents/validation-CjjTt66G.js.map +1 -0
- package/dist/types/components/table/mrd-table/mrd-table.d.ts +26 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{h as t,proxyCustomElement as r,HTMLElement as e,createEvent as l,writeTask as i,Host as a,transformTag as o}from"@stencil/core/internal/client";import{t as s}from"./i18n.js";import{a as d,b as n}from"./query-params.js";import{C as c}from"./cell-renderer.js";import{f as m,d as h,c as b}from"./format.js";const u=new Set(["TEXT","TEXTBLOCK","EMAIL","HYPERLINK"]),p=new Set(["INTEGER","DECIMAL","PERCENTAGE","CURRENCY"]),_=new Set(["DATE","DATETIME","TIME"]),v=new Set(["FILE","IMAGE"]),f=new Set(["LONGTEXT","JSON","FILE","IMAGE"]);function g(t,r){var e,l,i;const a=new URLSearchParams(t);a.delete("page"),a.delete("sort");const o=function(t){var r;const e={sum:[],avg:[],count:[]};for(const l of t){if("FIELD"!==l.type||!l.aggregate)continue;const t=l.aggregate.toLowerCase();t in e&&e[t].push(null!==(r=l.name)&&void 0!==r?r:"")}const l={};return e.sum.length&&(l.sum=e.sum),e.avg.length&&(l.avg=e.avg),e.count.length&&(l.count=e.count),Object.keys(l).length>0?l:null}(r);return(null===(e=null==o?void 0:o.sum)||void 0===e?void 0:e.length)&&a.set("sum",o.sum.join(",")),(null===(l=null==o?void 0:o.avg)||void 0===l?void 0:l.length)&&a.set("avg",o.avg.join(",")),(null===(i=null==o?void 0:o.count)||void 0===i?void 0:i.length)&&a.set("count",o.count.join(",")),a.toString()}function w(t){if(!t)return t;const[r,e,l]=t.split("-").map(Number);return new Date(r,e-1,l).toISOString().replace(/\.\d{3}Z$/,"Z")}function y(t){if(!t)return t;const[r,e,l]=t.split("-").map(Number);return new Date(r,e-1,l+1).toISOString().replace(/\.\d{3}Z$/,"Z")}const x=()=>t("span",{class:"mrd-table__filter-icon","aria-hidden":"true"},t("svg",{viewBox:"0 0 24 24",width:"14",height:"14",fill:"currentColor"},t("path",{d:"M10 18h4v-2h-4v2zM3 6v2h18V6H3zm3 7h12v-2H6v2z"}))),k=({col:r,row:e,locale:l,onDownload:i,onOpenTextblock:a,onOpenJson:o})=>{var d,n,m;const h=null!==(d=r.dataType)&&void 0!==d?d:"",b="FIELD"===r.type&&p.has(h);if("FIELD"===r.type&&("FILE"===h||"IMAGE"===h)){const a=null!==(n=r.name)&&void 0!==n?n:"",o=null==e?void 0:e[a],d=null==o?void 0:o.href,c=null==o?void 0:o.fileName;return t("td",{class:"mrd-table__cell"},d&&c?t("button",{class:"mrd-table__file-btn",title:c,onClick:t=>{t.stopPropagation(),i({href:d,fileName:c})}},t("svg",{class:"mrd-table__file-icon",viewBox:"0 0 24 24","aria-hidden":"true"},t("path",{fill:"currentColor",d:"M14 2H6c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V8l-6-6zm-1 7V3.5L18.5 9H13zm-3 8l-3-3 1.41-1.41L10 14.17l4.59-4.58L16 11l-6 6z"})),s("download",l)):"")}if("JSON"===h){const i=null!==(m=r.name)&&void 0!==m?m:"",a=i?null==e?void 0:e[i]:void 0;if(null==a||""===a)return t("td",{class:"mrd-table__cell"});const d=c.formatJson(a,!0),n=c.formatJson(a,!1);return t("td",{class:"mrd-table__cell"},t("span",{class:"mrd-table__json-preview",innerHTML:d}),t("button",{class:"mrd-table__textblock-btn",onClick:t=>{t.stopPropagation(),o(n)},"aria-label":s("textblock_show_more",l)},"⋯"))}if("TEXTBLOCK"===h){const i=c.render(r,e,l);if(i.length<=200)return t("td",{class:"mrd-table__cell"},i);const o=i.slice(0,200)+"…";return t("td",{class:"mrd-table__cell"},o,t("button",{class:"mrd-table__textblock-btn",onClick:t=>{t.stopPropagation(),a(i)},"aria-label":s("textblock_show_more",l)},"⋯"))}const u=c.render(r,e,l);return t("td",{class:"mrd-table__cell"+(b?" mrd-table__cell--numeric":""),title:u||void 0},u)},E=({columns:r,aggregations:e,locale:l})=>e&&r.some((t=>"FIELD"===t.type&&t.aggregate))?t("tfoot",null,t("tr",{class:"mrd-table__totals-row"},r.map((r=>{var i;const a=function(t,r,e){var l,i;if("FIELD"!==t.type||!t.aggregate||!r)return"";const a=null===(l=r[t.aggregate.toLowerCase()])||void 0===l?void 0:l[null!==(i=t.name)&&void 0!==i?i:""];if(null==a)return"";const o=t.dataType;return"INTEGER"===o?m(a,e,{maximumFractionDigits:0}):"PERCENTAGE"===o?h(a,e):"CURRENCY"===o&&t.currencyCode?b(a,t.currencyCode,e):m(a,e)}(r,e,l),o="FIELD"===r.type&&p.has(null!==(i=r.dataType)&&void 0!==i?i:"");return t("td",{class:"mrd-table__totals-cell"+(o?" mrd-table__totals-cell--numeric":"")},a)})))):null,C=({text:r,locale:e,onClose:l})=>null===r?null:t("div",{class:"mrd-table__modal-backdrop",onClick:l,role:"dialog","aria-modal":"true"},t("div",{class:"mrd-table__modal",onClick:t=>t.stopPropagation()},t("button",{class:"mrd-table__modal-close",onClick:l,"aria-label":s("close",e)},"✕"),t("p",{class:"mrd-table__modal-text"},r))),z=({html:r,locale:e,onClose:l})=>null===r?null:t("div",{class:"mrd-table__modal-backdrop",onClick:l,role:"dialog","aria-modal":"true"},t("div",{class:"mrd-table__modal",onClick:t=>t.stopPropagation()},t("button",{class:"mrd-table__modal-close",onClick:l,"aria-label":s("close",e)},"✕"),t("pre",{class:"mrd-table__modal-json",innerHTML:r}))),O=({locale:r,filterCount:e,actions:l,views:i,activeViewIdx:a,viewPopoverOpen:o,createPickerOpen:d,createTypes:n,cb:c})=>{var m;const h=l.length>0,b=i.length>1;return t("div",{class:"mrd-table__toolbar"},t("div",{class:"mrd-table__toolbar-left"},e>0&&t("button",{class:"mrd-table__action mrd-table__action--secondary mrd-table__filter-clear",onClick:c.onClearAllFilters},t("svg",{class:"mrd-table__action-icon",viewBox:"0 0 24 24","aria-hidden":"true"},t("path",{fill:"currentColor",d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"})),t("span",{class:"mrd-table__filter-clear-label"},s("table_filter_clear_all",r)," (",e,")"))),b&&t("div",{class:"mrd-table__toolbar-center"},t("div",{class:"mrd-table__view-switcher"},t("button",{class:"mrd-table__view-arrow","aria-label":"Previous view",onClick:()=>c.onViewSwitch((a-1+i.length)%i.length)},"◀"),t("div",{class:"mrd-table__view-title-wrap"},t("button",{class:"mrd-table__view-title",onClick:t=>c.onToggleViewPopover(t)},null===(m=i[a])||void 0===m?void 0:m.label),o&&t("div",{class:"mrd-table__view-popover",onClick:t=>t.stopPropagation()},i.map(((r,e)=>t("button",{key:String(e),class:"mrd-table__view-popover-item"+(e===a?" mrd-table__view-popover-item--active":""),onClick:()=>{e!==a&&c.onViewSwitch(e),c.onCloseViewPopover()}},r.label))))),t("button",{class:"mrd-table__view-arrow","aria-label":"Next view",onClick:()=>c.onViewSwitch((a+1)%i.length)},"▶"))),h&&t("div",{class:"mrd-table__toolbar-right"},l.map((r=>{var e,l;const i="create"===r.action?n:null;return(null==i?void 0:i.length)?t("div",{class:"mrd-table__create-picker-wrap",key:`action-${r.action}`},t("button",{class:`mrd-table__action mrd-table__action--${null!==(e=r.variant)&&void 0!==e?e:"secondary"}`,onClick:c.onToggleCreatePicker},r.icon?t("svg",{class:"mrd-table__action-icon","aria-hidden":"true"},t("use",{href:r.icon})):r.label,t("span",{class:"mrd-table__action-tooltip"},r.label)),d&&t("div",{class:"mrd-table__create-picker"},i.map((r=>t("button",{key:r.type,class:"mrd-table__create-picker-item",onClick:()=>c.onCreate(r.type)},r.label))))):t("button",{key:`action-${r.action}`,class:`mrd-table__action mrd-table__action--${null!==(l=r.variant)&&void 0!==l?l:"secondary"}`,disabled:r.disabled,onClick:()=>c.onAction(r.action)},r.icon?t("svg",{class:"mrd-table__action-icon","aria-hidden":"true"},t("use",{href:r.icon})):r.label,t("span",{class:"mrd-table__action-tooltip"},r.label))}))))},S=({col:r,dataType:e,openFilterCol:l,pendingFilter:i,locale:a,cb:o})=>{var d,n,c,m,h,b;const f=i;if(v.has(e))return t("p",{class:"mrd-table__filter-no-support"},s("filter_no_support",a));if("BOOLEAN"===e){const r=f.operator,e="isEmpty"===r||"isNotEmpty"===r;return t("div",{class:"mrd-table__filter-radio-group"},[{labelKey:"filter_all",value:null},{labelKey:"yes",value:!0},{labelKey:"no",value:!1}].map((r=>t("label",{class:"mrd-table__filter-radio-label"},t("input",{type:"radio",name:`bf-${l}`,checked:!e&&f.value===r.value,onChange:()=>o.onReplacePending(Object.assign(Object.assign({},f),{operator:void 0,value:r.value}))}),s(r.labelKey,a)))),t("label",{class:"mrd-table__filter-radio-label"},t("input",{type:"radio",name:`bf-${l}`,checked:"isEmpty"===r,onChange:()=>o.onReplacePending(Object.assign(Object.assign({},f),{operator:"isEmpty",value:void 0}))}),s("filter_is_empty",a)),t("label",{class:"mrd-table__filter-radio-label"},t("input",{type:"radio",name:`bf-${l}`,checked:"isNotEmpty"===r,onChange:()=>o.onReplacePending(Object.assign(Object.assign({},f),{operator:"isNotEmpty",value:void 0}))}),s("filter_is_not_empty",a)))}if("LIST"===e){const e=null!==(d=r.listItems)&&void 0!==d?d:[],l=null!==(n=f.values)&&void 0!==n?n:[];return t("div",{class:"mrd-table__filter-list"},t("div",{class:"mrd-table__filter-list-controls"},t("button",{class:"mrd-table__filter-list-btn",onClick:()=>o.onReplacePending(Object.assign(Object.assign({},f),{values:e.map((t=>t.key))}))},s("filter_select_all",a)),t("button",{class:"mrd-table__filter-list-btn",onClick:()=>o.onReplacePending(Object.assign(Object.assign({},f),{values:[]}))},s("filter_select_none",a))),e.map((r=>t("label",{class:"mrd-table__filter-checkbox-label"},t("input",{type:"checkbox",checked:l.includes(r.key),onChange:t=>o.onToggleValue(r.key,t.target.checked)}),r.label))))}if(u.has(e)||"RELATION"===e){const r=null!==(c=f.operator)&&void 0!==c?c:"startsWith",e="isEmpty"===r||"isNotEmpty"===r;return t("div",{class:"mrd-table__filter-editor"},t("select",{class:"mrd-table__filter-select",onChange:t=>o.onSetPending("operator",t.target.value)},[{val:"startsWith",labelKey:"filter_starts_with"},{val:"equals",labelKey:"filter_equals"},{val:"isEmpty",labelKey:"filter_is_empty"},{val:"isNotEmpty",labelKey:"filter_is_not_empty"}].map((e=>t("option",{value:e.val,selected:r===e.val},s(e.labelKey,a))))),!e&&t("input",{type:"text",class:"mrd-table__filter-input",value:String(null!==(m=f.value)&&void 0!==m?m:""),placeholder:s("filter_search_value",a),onInput:t=>o.onSetPending("value",t.target.value)}))}if(p.has(e)){const r=f.operator,e="isEmpty"===r||"isNotEmpty"===r,i=!e&&(void 0!==f.from||void 0!==f.to);return t("div",{class:"mrd-table__filter-editor"},t("select",{class:"mrd-table__filter-select",onChange:t=>{const r=t.target.value;o.onReplacePending(Object.assign(Object.assign({},f),"isEmpty"===r||"isNotEmpty"===r?{operator:r,value:void 0,from:void 0,to:void 0}:{operator:void 0}))}},t("option",{value:"",selected:!e},s("filter_has_value",a)),t("option",{value:"isEmpty",selected:"isEmpty"===r},s("filter_is_empty",a)),t("option",{value:"isNotEmpty",selected:"isNotEmpty"===r},s("filter_is_not_empty",a))),!e&&t("div",{class:"mrd-table__filter-editor"},t("div",{class:"mrd-table__filter-radio-group mrd-table__filter-radio-group--inline"},t("label",{class:"mrd-table__filter-radio-label"},t("input",{type:"radio",name:`nm-${l}`,checked:!i,onChange:()=>o.onReplacePending(Object.assign(Object.assign({},f),{from:void 0,to:void 0}))}),s("filter_exact",a)),t("label",{class:"mrd-table__filter-radio-label"},t("input",{type:"radio",name:`nm-${l}`,checked:i,onChange:()=>o.onReplacePending(Object.assign(Object.assign({},f),{value:void 0,from:null,to:null}))}),s("filter_range",a))),i?t("div",{class:"mrd-table__filter-range"},t("input",{type:"number",class:"mrd-table__filter-input",placeholder:s("filter_from",a),value:null!=f.from?String(f.from):"",onInput:t=>o.onSetPending("from",t.target.value)}),t("span",{class:"mrd-table__filter-range-sep"},"–"),t("input",{type:"number",class:"mrd-table__filter-input",placeholder:s("filter_to",a),value:null!=f.to?String(f.to):"",onInput:t=>o.onSetPending("to",t.target.value)})):t("input",{type:"number",class:"mrd-table__filter-input",value:null!=f.value?String(f.value):"",onInput:t=>o.onSetPending("value",t.target.value)})))}if("DATETIME"===e){const r=f.operator,e="isEmpty"===r||"isNotEmpty"===r,i=!e&&(void 0!==f.from||void 0!==f.to);return t("div",{class:"mrd-table__filter-editor"},t("select",{class:"mrd-table__filter-select",onChange:t=>{const r=t.target.value;o.onReplacePending(Object.assign(Object.assign({},f),"isEmpty"===r||"isNotEmpty"===r?{operator:r,value:void 0,from:void 0,to:void 0}:{operator:void 0}))}},t("option",{value:"",selected:!e},s("filter_has_value",a)),t("option",{value:"isEmpty",selected:"isEmpty"===r},s("filter_is_empty",a)),t("option",{value:"isNotEmpty",selected:"isNotEmpty"===r},s("filter_is_not_empty",a))),!e&&t("div",{class:"mrd-table__filter-editor"},t("div",{class:"mrd-table__filter-radio-group mrd-table__filter-radio-group--inline"},t("label",{class:"mrd-table__filter-radio-label"},t("input",{type:"radio",name:`dt-${l}`,checked:!i,onChange:()=>o.onReplacePending(Object.assign(Object.assign({},f),{from:void 0,to:void 0}))}),s("filter_exact",a)),t("label",{class:"mrd-table__filter-radio-label"},t("input",{type:"radio",name:`dt-${l}`,checked:i,onChange:()=>o.onReplacePending(Object.assign(Object.assign({},f),{value:void 0,from:null,to:null}))}),s("filter_range",a))),i?t("div",{class:"mrd-table__filter-range mrd-table__filter-range--stacked"},t("label",{class:"mrd-table__filter-range-label"},s("filter_from",a)),t("input",{type:"date",class:"mrd-table__filter-input",value:null!=f.from?String(f.from):"",onInput:t=>o.onSetPending("from",t.target.value)}),t("label",{class:"mrd-table__filter-range-label"},s("filter_to",a)),t("input",{type:"date",class:"mrd-table__filter-input",value:null!=f.to?String(f.to):"",onInput:t=>o.onSetPending("to",t.target.value)})):t("input",{type:"date",class:"mrd-table__filter-input",value:String(null!==(h=f.value)&&void 0!==h?h:""),onInput:t=>o.onSetPending("value",t.target.value)})))}if(_.has(e)){const r="DATE"===e?"date":"time",i=f.operator,d="isEmpty"===i||"isNotEmpty"===i,n=!d&&(void 0!==f.from||void 0!==f.to);return t("div",{class:"mrd-table__filter-editor"},t("select",{class:"mrd-table__filter-select",onChange:t=>{const r=t.target.value;o.onReplacePending(Object.assign(Object.assign({},f),"isEmpty"===r||"isNotEmpty"===r?{operator:r,value:void 0,from:void 0,to:void 0}:{operator:void 0}))}},t("option",{value:"",selected:!d},s("filter_has_value",a)),t("option",{value:"isEmpty",selected:"isEmpty"===i},s("filter_is_empty",a)),t("option",{value:"isNotEmpty",selected:"isNotEmpty"===i},s("filter_is_not_empty",a))),!d&&t("div",{class:"mrd-table__filter-editor"},t("div",{class:"mrd-table__filter-radio-group mrd-table__filter-radio-group--inline"},t("label",{class:"mrd-table__filter-radio-label"},t("input",{type:"radio",name:`dt-${l}`,checked:!n,onChange:()=>o.onReplacePending(Object.assign(Object.assign({},f),{from:void 0,to:void 0}))}),s("filter_exact",a)),t("label",{class:"mrd-table__filter-radio-label"},t("input",{type:"radio",name:`dt-${l}`,checked:n,onChange:()=>o.onReplacePending(Object.assign(Object.assign({},f),{value:void 0,from:null,to:null}))}),s("filter_range",a))),n?t("div",{class:"mrd-table__filter-range"},t("input",{type:r,class:"mrd-table__filter-input",placeholder:s("filter_from",a),value:null!=f.from?String(f.from):"",onInput:t=>o.onSetPending("from",t.target.value)}),t("input",{type:r,class:"mrd-table__filter-input",placeholder:s("filter_to",a),value:null!=f.to?String(f.to):"",onInput:t=>o.onSetPending("to",t.target.value)})):t("input",{type:r,class:"mrd-table__filter-input",value:String(null!==(b=f.value)&&void 0!==b?b:""),onInput:t=>o.onSetPending("value",t.target.value)})))}return null},T=r=>{var e;const{col:l,openFilterCol:i,popupPos:a,sortField:o,sortDir:d,locale:n,cb:c}=r,m=null!==(e=l.label)&&void 0!==e?e:i,h=o===i;return t("div",{class:"mrd-table__filter-popup",style:{top:`${a.top}px`,left:`${a.left}px`},onClick:t=>t.stopPropagation()},t("div",{class:"mrd-table__filter-popup-header"},t("span",{class:"mrd-table__filter-popup-title"},m),t("button",{class:"mrd-table__filter-close",onClick:c.onClose},"✕")),t("div",{class:"mrd-table__filter-section"},t("div",{class:"mrd-table__filter-section-label"},s("filter_sorting",n)),t("div",{class:"mrd-table__filter-sort-buttons"},t("button",{class:"mrd-table__filter-sort-btn"+(h&&"asc"===d?" mrd-table__filter-sort-btn--active":""),onClick:()=>c.onApplySort("asc")},"▲ ",s("filter_ascending",n)),t("button",{class:"mrd-table__filter-sort-btn"+(h&&"desc"===d?" mrd-table__filter-sort-btn--active":""),onClick:()=>c.onApplySort("desc")},"▼ ",s("filter_descending",n)))),t("div",{class:"mrd-table__filter-divider"}),t("div",{class:"mrd-table__filter-section"},t("div",{class:"mrd-table__filter-section-label"},s("filter_section",n)),t(S,Object.assign({},r))),t("div",{class:"mrd-table__filter-popup-footer"},t("button",{class:"mrd-table__filter-btn mrd-table__filter-btn--clear",onClick:c.onClear},s("filter_clear",n)),t("button",{class:"mrd-table__filter-btn mrd-table__filter-btn--apply",onClick:c.onApply},s("filter_apply",n))))};function M(t,r){return Math.ceil(t/r)}function j(t,r,e){return{firstPage:Math.floor(t/e),lastPage:Math.floor(r/e)}}const P=r(class extends e{constructor(t){super(),!1!==t&&this.__registerHost(),this.mrdLoadPage=l(this,"mrdLoadPage",7),this.mrdPageError=l(this,"mrdPageError",7),this.mrdRowClick=l(this,"mrdRowClick",7),this.mrdAction=l(this,"mrdAction",7),this.mrdDownload=l(this,"mrdDownload",7),this.mrdLoadAggregations=l(this,"mrdLoadAggregations",7),this.pendingPages=new Set,this.debounceTimer=null,this.requestedAt=new Map,this.retryAttempts=new Map,this.staleCheckTimer=null,this.outsideClickHandler=null,this.keydownHandler=null,this.createPickerClickHandler=null,this.viewPopoverClickHandler=null,this.colWidthMeasureScheduled=!1,this.resizeOrigin=null,this.colWidthsUserSet=!1,this.paginationActivated=!1,this.item=null,this.parentId="",this.rows=[],this.locale=navigator.language,this.totalElements=0,this.pageSize=20,this.rowHeight=36,this.tableHeight=500,this.requestTimeoutMs=15e3,this.activeViewIdx=0,this.loadedPages=new Map,this.requestedPages=new Set,this.failedPages=new Set,this.renderStart=0,this.renderEnd=0,this.colWidths=[],this.resizingCol=null,this.sortField="",this.sortDir="asc",this.activeFilters=new Map,this.openFilterCol=null,this.pendingFilter=null,this.popupPos={top:0,left:0},this.createPickerOpen=!1,this.viewPopoverOpen=!1,this.scrollTop=0,this.textblockModal=null,this.jsonModal=null,this.aggregations=null,this.aggregationsTotal=null,this.aggregationsPending=!1,this.minKnownTotal=0,this.handleScroll=t=>{const r=t.currentTarget,{renderStart:e,renderEnd:l}=function(t,r,e,l){const i=Math.floor(t/r),a=i+M(e,r)+10;return{renderStart:Math.max(0,i-10),renderEnd:l>0?Math.min(l-1,a):a}}(r.scrollTop,this.rowHeight,this.tableHeight,this.baseTotal);this.scrollTop=r.scrollTop,this.renderStart=e,this.renderEnd=l,this.requestPagesForWindow(this.renderStart,this.renderEnd)}}totalElementsChanged(t){t>0&&(this.renderEnd=Math.min(this.renderEnd,t-1))}itemChanged(t){var r,e;this.activeViewIdx=0,this.applyDefaultSort(null!==(e=null===(r=null==t?void 0:t.view)||void 0===r?void 0:r.defaultSort)&&void 0!==e?e:""),this.colWidths=[],this.colWidthMeasureScheduled=!1,this.colWidthsUserSet=!1}componentWillLoad(){var t,r,e;this.applyDefaultSort(null!==(e=null===(r=null===(t=this.item)||void 0===t?void 0:t.view)||void 0===r?void 0:r.defaultSort)&&void 0!==e?e:"")}componentDidLoad(){this.staleCheckTimer=setInterval((()=>this.checkStalePages()),2e3)}applyDefaultSort(t){const{field:r,dir:e}=function(t){var r;if(!t)return{field:"",dir:"asc"};const e=t.split(",");return{field:e[0].trim(),dir:"desc"===(null===(r=e[1])||void 0===r?void 0:r.trim())?"desc":"asc"}}(t);this.sortField=r,this.sortDir=e}async init(){null!==this.debounceTimer&&(clearTimeout(this.debounceTimer),this.debounceTimer=null),this.pendingPages.clear(),this.loadedPages=new Map,this.requestedPages=new Set,this.failedPages=new Set,this.requestedAt.clear(),this.retryAttempts.clear(),this.colWidths=[],this.colWidthMeasureScheduled=!1,this.colWidthsUserSet=!1,this.scrollTop=0,this.renderStart=0,this.renderEnd=this.visibleCount()-1;const t=this.el.querySelector(".mrd-table__scroll");t&&(t.scrollTop=0),this.aggregations=null,this.aggregationsTotal=null,this.aggregationsPending=!0,this.minKnownTotal=0,this.paginationActivated=!0,this.emitLoadPage(0),this.requestedPages=new Set([0])}async setPage(t,r,e){this.paginationActivated=!0;const l=void 0!==e?!e:r.length<this.pageSize;l?(this.renderEnd=Math.min(this.renderEnd,t*this.pageSize+r.length-1),this.minKnownTotal=t*this.pageSize+r.length):this.minKnownTotal=Math.max(this.minKnownTotal,(t+1)*this.pageSize+1);const i=new Map(this.loadedPages);if(i.set(t,r),this.loadedPages=i,this.renderEnd<this.renderStart&&(this.renderEnd=Math.min(this.renderStart+this.visibleCount()-1,this.minKnownTotal-1)),this.requestedAt.delete(t),this.retryAttempts.delete(t),this.failedPages.has(t)){const r=new Set(this.failedPages);r.delete(t),this.failedPages=r}if(0===t&&this.aggregationsPending){this.aggregationsPending=!1;const t=this.columns.some((t=>"FIELD"===t.type&&t.aggregate));l&&!t||this.emitLoadAggregations()}}async setAggregations(t){null!=t.total&&(this.aggregationsTotal=t.total),this.aggregations=t}disconnectedCallback(){null!==this.staleCheckTimer&&(clearInterval(this.staleCheckTimer),this.staleCheckTimer=null),this.outsideClickHandler&&(document.removeEventListener("click",this.outsideClickHandler),this.outsideClickHandler=null),this.createPickerClickHandler&&(document.removeEventListener("click",this.createPickerClickHandler),this.createPickerClickHandler=null),this.keydownHandler&&(document.removeEventListener("keydown",this.keydownHandler),this.keydownHandler=null),this.viewPopoverClickHandler&&(document.removeEventListener("click",this.viewPopoverClickHandler),this.viewPopoverClickHandler=null)}componentDidRender(){0===this.colWidths.length&&!this.colWidthMeasureScheduled&&this.loadedPages.size>0&&(this.colWidthMeasureScheduled=!0,i((()=>{if(this.colWidthMeasureScheduled=!1,0!==this.colWidths.length)return;const t=this.measureColWidths();t&&(this.colWidths=t)})))}measureColWidths(){const t=this.el.querySelectorAll(".mrd-table__header");return 0===t.length||t.length!==this.columns.length?null:Array.from(t).map((t=>Math.round(t.getBoundingClientRect().width)))}syncColWidths(){const t=this.measureColWidths();return t?(this.colWidths=t,!0):this.colWidths.length===this.columns.length}setColWidth(t,r){const e=[...this.colWidths];e[t]=Math.max(48,Math.round(r)),this.colWidths=e,this.colWidthsUserSet=!0}handleResizeStart(t,r){var e,l;t.preventDefault(),t.stopPropagation(),this.syncColWidths()&&(this.resizeOrigin={idx:r,startX:t.clientX,startWidth:this.colWidths[r]},this.resizingCol=r,null===(l=(e=t.currentTarget).setPointerCapture)||void 0===l||l.call(e,t.pointerId))}handleResizeMove(t){if(!this.resizeOrigin)return;const{idx:r,startX:e,startWidth:l}=this.resizeOrigin;this.setColWidth(r,l+(t.clientX-e))}handleResizeEnd(t){var r,e;this.resizeOrigin&&(this.resizeOrigin=null,this.resizingCol=null,null===(e=(r=t.currentTarget).releasePointerCapture)||void 0===e||e.call(r,t.pointerId))}handleResizeAutoFit(t,r){if(t.preventDefault(),t.stopPropagation(),!this.syncColWidths())return;const e=this.el.querySelectorAll(`.mrd-table__header:nth-child(${r+1}), .mrd-table__cell:nth-child(${r+1})`);let l=0;e.forEach((t=>{const r=getComputedStyle(t),e=parseFloat(r.paddingLeft||"0")+parseFloat(r.paddingRight||"0");l=Math.max(l,t.scrollWidth+e)})),l>0&&this.setColWidth(r,Math.min(l,600))}lockedTableStyle(){if(0===this.colWidths.length)return;const t=this.colWidths.reduce(((t,r)=>t+(r||0)),0);return Object.assign({tableLayout:"fixed",width:`${t}px`},this.colWidthsUserSet?{}:{minWidth:"100%"})}renderColResizer(r){return t("span",{class:"mrd-table__col-resizer"+(this.resizingCol===r?" mrd-table__col-resizer--active":""),role:"separator","aria-orientation":"vertical",title:s("column_resize",this.locale),"on-pointerdown":t=>this.handleResizeStart(t,r),"on-pointermove":t=>this.handleResizeMove(t),"on-pointerup":t=>this.handleResizeEnd(t),"on-pointercancel":t=>this.handleResizeEnd(t),"on-dblclick":t=>this.handleResizeAutoFit(t,r),onClick:t=>t.stopPropagation()})}visibleCount(){return M(this.tableHeight,this.rowHeight)}sortParam(){return(t=this.sortField)?"desc"===this.sortDir?`${t},desc`:t:"";var t}get allViews(){var t,r,e,l,i,a,o;if(!this.item)return[];const s=this.item;return[{label:null!==(i=null!==(l=null!==(e=null!==(t=s.label)&&void 0!==t?t:null===(r=s.view)||void 0===r?void 0:r.pluralLabel)&&void 0!==e?e:s.dataClass)&&void 0!==l?l:s.relatedClass)&&void 0!==i?i:"",dataClass:null!==(a=s.dataClass)&&void 0!==a?a:s.relatedClass,fromClass:s.fromClass,filterClass:s.filterClass,view:s.view},...(null!==(o=s.alternativeViews)&&void 0!==o?o:[]).map((t=>{var r,e,l,i;return{label:null!==(i=null!==(l=null!==(r=t.label)&&void 0!==r?r:null===(e=t.view)||void 0===e?void 0:e.pluralLabel)&&void 0!==l?l:t.dataClass)&&void 0!==i?i:"",dataClass:t.dataClass,fromClass:t.fromClass,filterClass:t.filterClass,view:t.view}}))]}buildExcelPath(){var t;const r=this.allViews[this.activeViewIdx];return r?"/excel"+n({isRelatedView:"RELATED_VIEW"===(null===(t=this.item)||void 0===t?void 0:t.type),fromClass:r.fromClass,parentId:this.parentId,dataClass:r.dataClass}):""}buildActionDetail(t,r){var e,l,i;if("export"===t)return{action:t,path:this.buildExcelPath(),qs:this.buildQueryParams(0)};if("create"===t){const a=this.allViews[this.activeViewIdx],o="RELATED_VIEW"===(null===(e=this.item)||void 0===e?void 0:e.type)?`/${null!==(l=null==a?void 0:a.fromClass)&&void 0!==l?l:""}/${this.parentId}`:null;return Object.assign({action:t,dataClass:null!==(i=null==a?void 0:a.dataClass)&&void 0!==i?i:"",parentPath:o},r?{basicType:r}:{})}return{action:t}}buildDataPath(){var t;const r=this.allViews[this.activeViewIdx];return r?n({isRelatedView:"RELATED_VIEW"===(null===(t=this.item)||void 0===t?void 0:t.type),fromClass:r.fromClass,parentId:this.parentId,dataClass:r.dataClass}):""}buildQueryParams(t){var r;const e=this.allViews[this.activeViewIdx];return function(t){var r,e;const l=new URLSearchParams;t.page>0&&l.set("page",String(t.page)),t.sort&&l.set("sort",t.sort),t.filterClass&&l.set("type",t.filterClass),d(l,t.viewFilters);for(const i of t.activeFilters)"isEmpty"!==i.operator?"isNotEmpty"!==i.operator?"startsWith"!==i.operator?(null===(e=i.values)||void 0===e?void 0:e.length)?l.set(i.field,i.values.join(",")):(null!=i.value&&l.set(i.field,String(i.value)),null!=i.from&&l.set(i.field+"_from",String(i.from)),null!=i.to&&l.set(i.field+"_to",String(i.to))):l.set(i.field+"_startswith",String(null!==(r=i.value)&&void 0!==r?r:"")):l.set(i.field+"_notempty","true"):l.set(i.field,"");return l.toString()}({page:t,sort:this.sortParam(),filterClass:null==e?void 0:e.filterClass,viewFilters:null===(r=null==e?void 0:e.view)||void 0===r?void 0:r.filter,activeFilters:this.activeFilters.values()})}get isPaginated(){return this.totalElements>0||this.paginationActivated}get columns(){var t,r,e;return null!==(e=null===(r=null===(t=this.allViews[this.activeViewIdx])||void 0===t?void 0:t.view)||void 0===r?void 0:r.values)&&void 0!==e?e:[]}get tableActions(){var t,r;const e=null!==(r=null===(t=this.item)||void 0===t?void 0:t.actions)&&void 0!==r?r:[];return(null!=e?e:[]).reduce(((t,r)=>("NEW"===r&&t.push({action:"create",label:s("table_new_record",this.locale),icon:"assets/sprites.svg#icon-plus",variant:"primary"}),"EXPORT"===r&&t.push({action:"export",label:s("table_export_excel",this.locale),icon:"assets/sprites.svg#icon-file-excel"}),t)),[])}toggleCreatePicker(){this.createPickerOpen?this.closeCreatePicker():(this.createPickerOpen=!0,this.createPickerClickHandler&&document.removeEventListener("click",this.createPickerClickHandler),this.createPickerClickHandler=t=>{const r=this.el.querySelector(".mrd-table__create-picker-wrap");r&&!r.contains(t.target)&&this.closeCreatePicker()},document.addEventListener("click",this.createPickerClickHandler))}closeCreatePicker(){this.createPickerOpen=!1,this.createPickerClickHandler&&(document.removeEventListener("click",this.createPickerClickHandler),this.createPickerClickHandler=null)}colName(t){var r;return null!==(r=t.name)&&void 0!==r?r:""}colDataType(t){var r;return"RELATION"===t.type?"RELATION":null!==(r=t.dataType)&&void 0!==r?r:"TEXT"}isTotalKnown(){return null!=this.aggregationsTotal||function(t,r){for(const e of t.values())if(e.length<r)return!0;return!1}(this.loadedPages,this.pageSize)}get baseTotal(){return null!=this.aggregationsTotal?this.aggregationsTotal:this.totalElements>0?this.totalElements:this.minKnownTotal}emitLoadAggregations(){const t=this.buildQueryParams(0);this.mrdLoadAggregations.emit({path:this.buildDataPath(),qs:t,aggQs:g(t,this.columns)})}resetPages(){null!==this.debounceTimer&&(clearTimeout(this.debounceTimer),this.debounceTimer=null),this.pendingPages.clear(),this.loadedPages=new Map,this.requestedPages=new Set,this.failedPages=new Set,this.requestedAt.clear(),this.retryAttempts.clear(),this.colWidthsUserSet||(this.colWidths=[],this.colWidthMeasureScheduled=!1),this.scrollTop=0,this.renderStart=0,this.minKnownTotal=0,this.renderEnd=this.visibleCount()-1;const t=this.el.querySelector(".mrd-table__scroll");t&&(t.scrollTop=0)}applySort(t,r){this.sortField=this.colName(t),this.sortDir=r,this.resetPages(),this.emitPagesForWindow(this.renderStart,this.renderEnd)}emitLoadPage(t){this.mrdLoadPage.emit({page:t,sort:this.sortParam(),path:this.buildDataPath(),qs:this.buildQueryParams(t)}),this.requestedAt.set(t,Date.now())}emitPagesForWindow(t,r){const{firstPage:e,lastPage:l}=j(t,r,this.pageSize),i=new Set(this.requestedPages);let a=!1;for(let t=e;t<=l;t++)this.loadedPages.has(t)||i.has(t)||(i.add(t),this.emitLoadPage(t),a=!0);a&&(this.requestedPages=i)}getRow(t){return function(t,r,e){var l;const i=t.get(Math.floor(r/e));return null!==(l=null==i?void 0:i[r%e])&&void 0!==l?l:null}(this.loadedPages,t,this.pageSize)}requestPagesForWindow(t,r){const{firstPage:e,lastPage:l}=j(t,r,this.pageSize);let i=!1;for(let t=e;t<=l;t++)this.loadedPages.has(t)||this.requestedPages.has(t)||this.pendingPages.has(t)||(this.pendingPages.add(t),i=!0);i&&(null!==this.debounceTimer&&clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout((()=>this.flushPendingPages()),150))}flushPendingPages(){if(this.debounceTimer=null,0===this.pendingPages.size)return;const t=new Set(this.requestedPages);let r=!1;for(const e of this.pendingPages){if(this.loadedPages.has(e)||t.has(e))continue;const l=e*this.pageSize;l+this.pageSize-1<this.renderStart||l>this.renderEnd||(t.add(e),this.emitLoadPage(e),r=!0)}this.pendingPages.clear(),r&&(this.requestedPages=t)}checkStalePages(){var t;if(0===this.requestedAt.size)return;const r=function(t,r,e){const l=[];for(const[i,a]of t)r-a>=e&&l.push(i);return l}(this.requestedAt,Date.now(),this.requestTimeoutMs).filter((t=>!this.loadedPages.has(t)));if(0===r.length)return;let e=null;for(const l of r){const r=null!==(t=this.retryAttempts.get(l))&&void 0!==t?t:0;r<3?(this.retryAttempts.set(l,r+1),this.emitLoadPage(l)):(this.requestedAt.delete(l),this.retryAttempts.delete(l),e||(e=new Set(this.failedPages)),e.add(l),this.mrdPageError.emit({page:l}))}e&&(this.failedPages=e)}retryPage(t){const r=new Set(this.failedPages);r.delete(t),this.failedPages=r,this.retryAttempts.delete(t),this.emitLoadPage(t);const e=new Set(this.requestedPages);e.add(t),this.requestedPages=e}handleFilterOpen(t,r){r.stopPropagation();const e=r.currentTarget.getBoundingClientRect();let l=e.left;l+280>window.innerWidth-8&&(l=e.right-280),this.popupPos={top:e.bottom+4,left:Math.max(8,l)};const i=this.colName(t),a=this.colDataType(t),o=this.activeFilters.get(i),s=u.has(a)||"RELATION"===a?"startsWith":void 0;this.pendingFilter="DATETIME"===a&&o&&"isEmpty"!==o.operator&&"isNotEmpty"!==o.operator?function(t){const r=Object.assign({},t);return"string"==typeof r.from&&r.from&&(r.from=function(t){if(!t)return t;const r=new Date(t);return isNaN(r.getTime())?t:`${r.getFullYear()}-${String(r.getMonth()+1).padStart(2,"0")}-${String(r.getDate()).padStart(2,"0")}`}(r.from)),"string"==typeof r.to&&r.to&&(r.to=function(t){if(!t)return t;const r=new Date(t);return isNaN(r.getTime())?t:(r.setDate(r.getDate()-1),`${r.getFullYear()}-${String(r.getMonth()+1).padStart(2,"0")}-${String(r.getDate()).padStart(2,"0")}`)}(r.to)),r.from&&r.to&&r.from===r.to?Object.assign(Object.assign({},r),{value:r.from,from:void 0,to:void 0}):r}(o):o?Object.assign({},o):{field:i,dataType:a,operator:s},this.openFilterCol=i,this.outsideClickHandler&&document.removeEventListener("click",this.outsideClickHandler),this.outsideClickHandler=t=>{const r=this.el.querySelector(".mrd-table__filter-popup");r&&!r.contains(t.target)&&this.closeFilterPopup()},document.addEventListener("click",this.outsideClickHandler)}closeFilterPopup(){this.openFilterCol=null,this.pendingFilter=null,this.outsideClickHandler&&(document.removeEventListener("click",this.outsideClickHandler),this.outsideClickHandler=null)}openTextblockModal(t){this.textblockModal=t,this.keydownHandler&&document.removeEventListener("keydown",this.keydownHandler),this.keydownHandler=t=>{"Escape"===t.key&&this.closeTextblockModal()},document.addEventListener("keydown",this.keydownHandler)}closeTextblockModal(){this.textblockModal=null,this.keydownHandler&&(document.removeEventListener("keydown",this.keydownHandler),this.keydownHandler=null)}openJsonModal(t){this.jsonModal=t,this.keydownHandler&&document.removeEventListener("keydown",this.keydownHandler),this.keydownHandler=t=>{"Escape"===t.key&&this.closeJsonModal()},document.addEventListener("keydown",this.keydownHandler)}closeJsonModal(){this.jsonModal=null,this.keydownHandler&&(document.removeEventListener("keydown",this.keydownHandler),this.keydownHandler=null)}setPending(t,r){this.pendingFilter=Object.assign(Object.assign({},this.pendingFilter),{[t]:r})}togglePendingValue(t,r){var e,l;const i=null!==(l=null===(e=this.pendingFilter)||void 0===e?void 0:e.values)&&void 0!==l?l:[];this.pendingFilter=Object.assign(Object.assign({},this.pendingFilter),{values:r?[...i,t]:i.filter((r=>r!==t))})}applyFilter(){const t=this.pendingFilter;if(!(null==t?void 0:t.field))return void this.closeFilterPopup();const r=function(t){const r=Object.assign({},t);return"DATETIME"===t.dataType&&"isEmpty"!==t.operator&&"isNotEmpty"!==t.operator&&("string"==typeof r.value&&r.value?(r.from=w(r.value),r.to=y(r.value),r.value=void 0):("string"==typeof r.from&&r.from&&(r.from=w(r.from)),"string"==typeof r.to&&r.to&&(r.to=y(r.to)))),r}(t),e=new Map(this.activeFilters);!function(t){return"isEmpty"===t.operator||"isNotEmpty"===t.operator||void 0!==t.values&&t.values.length>0||null!=t.value&&""!==t.value||"boolean"==typeof t.value||null!=t.from&&""!==t.from||null!=t.to&&""!==t.to}(r)?e.delete(r.field):e.set(r.field,r),this.activeFilters=e,this.closeFilterPopup(),this.aggregations=null,this.aggregationsTotal=null,this.aggregationsPending=!0,this.isPaginated&&(this.resetPages(),this.emitPagesForWindow(this.renderStart,this.renderEnd))}clearFilter(){const t=this.openFilterCol,r=new Map(this.activeFilters);t&&r.delete(t),this.activeFilters=r,this.closeFilterPopup(),this.aggregations=null,this.aggregationsTotal=null,this.aggregationsPending=!0,this.isPaginated&&(this.resetPages(),this.emitPagesForWindow(this.renderStart,this.renderEnd))}clearAllFilters(){this.activeFilters=new Map,this.aggregations=null,this.aggregationsTotal=null,this.aggregationsPending=!0,this.isPaginated&&(this.resetPages(),this.emitPagesForWindow(this.renderStart,this.renderEnd))}handleViewSwitch(t){var r,e;const l=this.allViews[t];(null==l?void 0:l.view)&&(this.activeViewIdx=t,this.applyDefaultSort(null!==(e=null===(r=l.view)||void 0===r?void 0:r.defaultSort)&&void 0!==e?e:""),this.activeFilters=new Map,this.init())}toggleViewPopover(t){t.stopPropagation(),this.viewPopoverOpen?this.closeViewPopover():(this.viewPopoverOpen=!0,this.viewPopoverClickHandler=()=>this.closeViewPopover(),document.addEventListener("click",this.viewPopoverClickHandler))}closeViewPopover(){this.viewPopoverOpen=!1,this.viewPopoverClickHandler&&(document.removeEventListener("click",this.viewPopoverClickHandler),this.viewPopoverClickHandler=null)}renderToolbar(){var r;return t(O,{locale:this.locale,filterCount:this.activeFilters.size,actions:this.tableActions,views:this.allViews,activeViewIdx:this.activeViewIdx,viewPopoverOpen:this.viewPopoverOpen,createPickerOpen:this.createPickerOpen,createTypes:null===(r=this.item)||void 0===r?void 0:r.createTypes,cb:{onClearAllFilters:()=>this.clearAllFilters(),onViewSwitch:t=>this.handleViewSwitch(t),onToggleViewPopover:t=>this.toggleViewPopover(t),onCloseViewPopover:()=>this.closeViewPopover(),onToggleCreatePicker:()=>this.toggleCreatePicker(),onCreate:t=>{this.mrdAction.emit(this.buildActionDetail("create",t)),this.closeCreatePicker()},onAction:t=>this.mrdAction.emit(this.buildActionDetail(t))}})}renderFilterPopup(){if(!this.openFilterCol||!this.pendingFilter)return null;const r=this.columns.find((t=>this.colName(t)===this.openFilterCol));return r?t(T,{col:r,dataType:this.colDataType(r),openFilterCol:this.openFilterCol,pendingFilter:this.pendingFilter,popupPos:this.popupPos,sortField:this.sortField,sortDir:this.sortDir,locale:this.locale,cb:{onSetPending:(t,r)=>this.setPending(t,r),onReplacePending:t=>this.pendingFilter=t,onToggleValue:(t,r)=>this.togglePendingValue(t,r),onApplySort:t=>this.applySort(r,t),onApply:()=>this.applyFilter(),onClear:()=>this.clearFilter(),onClose:()=>this.closeFilterPopup()}}):null}renderFooter(r,e,l=!0){if(!this.isPaginated){const e=null!=r?r:0;return 0===e?null:t("div",{class:"mrd-table__footer"},e," ",s("table_of",this.locale)," ",e)}if(!this.loadedPages.has(0))return null;const i=null!=e?e:this.baseTotal,a=Math.min(Math.floor(this.scrollTop/this.rowHeight)+1,i),o=Math.min(Math.ceil((this.scrollTop+this.tableHeight)/this.rowHeight),i),d=l?String(i):"…";return t("div",{class:"mrd-table__footer"},a,"–",o," ",s("table_of",this.locale)," ",d)}renderCell(r,e){return t(k,{col:r,row:e,locale:this.locale,onDownload:t=>this.mrdDownload.emit(t),onOpenTextblock:t=>this.openTextblockModal(t),onOpenJson:t=>this.openJsonModal(t)})}renderTotalsRow(){return t(E,{columns:this.columns,aggregations:this.aggregations,locale:this.locale})}render(){var r,e,l;if(!(null===(r=this.columns)||void 0===r?void 0:r.length))return null;if(!this.isPaginated)return t(a,{class:{"mrd-table--resizing":null!==this.resizingCol}},this.renderToolbar(),t("div",{class:"mrd-table"},t("table",{class:"mrd-table__table",style:this.lockedTableStyle()},t("thead",null,t("tr",null,this.columns.map(((r,e)=>{var l;const i=this.colName(r),a=this.activeFilters.has(i),o=!f.has(this.colDataType(r)),s=["mrd-table__header",a?"mrd-table__header--filtered":"",o?"mrd-table__header--sortable":""].filter(Boolean).join(" ");return t("th",{class:s,style:this.colWidths[e]?{width:`${this.colWidths[e]}px`}:void 0,onClick:o?t=>this.handleFilterOpen(r,t):void 0},t("span",{class:"mrd-table__header-label"},null!==(l=r.label)&&void 0!==l?l:""),a&&t(x,null),this.renderColResizer(e))})))),t("tbody",null,null===(e=this.rows)||void 0===e?void 0:e.map(((r,e)=>t("tr",{class:"mrd-table__row mrd-table__row--clickable",style:{background:e%2==0?"":"var(--mrd-color-neutral-100)"},onClick:()=>this.mrdRowClick.emit({row:r})},this.columns.map((t=>this.renderCell(t,r))))))),this.renderTotalsRow()),(!this.rows||0===this.rows.length)&&t("p",{class:"mrd-table__empty"},s("no_results",this.locale))),this.renderFooter(null===(l=this.rows)||void 0===l?void 0:l.length),this.renderFilterPopup(),this.renderTextblockModal(),this.renderJsonModal());const i=function(t,r,e){let l=e;for(const[e,i]of t)i.length<r&&(l=Math.min(l,e*r+i.length));return l}(this.loadedPages,this.pageSize,this.baseTotal),o=Math.min(this.renderEnd,i-1),d=this.columns.length,n=this.renderStart*this.rowHeight,c=Math.max(0,(i-1-o)*this.rowHeight),m=this.lockedTableStyle(),h=[];for(let r=this.renderStart;r<=o;r++){const e=this.getRow(r);if(null===e){const e=Math.floor(r/this.pageSize);this.failedPages.has(e)?h.push(t("tr",{class:"mrd-table__row mrd-table__row--failed"},t("td",{class:"mrd-table__cell--failed",colSpan:d},t("button",{type:"button",class:"mrd-table__retry-button",onClick:()=>this.retryPage(e)},s("load_failed_retry",this.locale))))):h.push(t("tr",{class:"mrd-table__row mrd-table__row--loading"},t("td",{class:"mrd-table__cell--placeholder",colSpan:d},t("span",{class:"mrd-table__placeholder-bar"}))))}else h.push(t("tr",{class:"mrd-table__row mrd-table__row--clickable",style:{background:r%2==0?"":"var(--mrd-color-neutral-100)"},onClick:()=>this.mrdRowClick.emit({row:e,listContext:{index:r,sort:this.sortParam(),path:this.buildDataPath(),qs:this.buildQueryParams(0)}})},this.columns.map((t=>this.renderCell(t,e)))))}return t(a,{class:{"mrd-table--resizing":null!==this.resizingCol}},this.renderToolbar(),t("div",{class:"mrd-table__scroll",style:{height:`${this.tableHeight}px`},onScroll:this.handleScroll},t("table",{class:"mrd-table__table",style:m},t("thead",null,t("tr",null,this.columns.map(((r,e)=>{var l;const i=this.colName(r),a=this.sortField===i,o=this.activeFilters.has(i),s=!f.has(this.colDataType(r)),d=["mrd-table__header",s?"mrd-table__header--sortable":"",a?`mrd-table__header--sorted-${this.sortDir}`:"",o?"mrd-table__header--filtered":""].filter(Boolean).join(" ");return t("th",{class:d,style:this.colWidths[e]?{width:`${this.colWidths[e]}px`}:void 0,onClick:s?t=>this.handleFilterOpen(r,t):void 0},t("span",{class:"mrd-table__header-label"},null!==(l=r.label)&&void 0!==l?l:""),s&&a&&t("span",{class:"mrd-table__sort-icon","aria-hidden":"true"},"asc"===this.sortDir?"▲":"▼"),s&&!a&&t("span",{class:"mrd-table__sort-icon","aria-hidden":"true"},"⇅"),s&&o&&t(x,null),this.renderColResizer(e))})))),t("tbody",null,n>0&&t("tr",{class:"mrd-table__spacer",style:{height:`${n}px`}},t("td",{colSpan:d})),h,c>0&&t("tr",{class:"mrd-table__spacer",style:{height:`${c}px`}},t("td",{colSpan:d}))),this.renderTotalsRow())),0===i&&this.loadedPages.has(0)&&t("p",{class:"mrd-table__empty"},s("no_results",this.locale)),i>0&&this.renderFooter(void 0,i,this.isTotalKnown()),this.renderFilterPopup(),this.renderTextblockModal(),this.renderJsonModal())}renderTextblockModal(){return t(C,{text:this.textblockModal,locale:this.locale,onClose:()=>this.closeTextblockModal()})}renderJsonModal(){return t(z,{html:this.jsonModal,locale:this.locale,onClose:()=>this.closeJsonModal()})}get el(){return this}static get watchers(){return{totalElements:[{totalElementsChanged:0}],item:[{itemChanged:0}]}}static get style(){return'.sc-mrd-table-h{display:block;width:100%}.mrd-table.sc-mrd-table{overflow-x:auto}.mrd-table__scroll.sc-mrd-table{overflow-y:auto;overflow-x:auto;border:1px solid var(--mrd-border-color);border-radius:var(--mrd-border-radius);overflow-anchor:none}.mrd-table__table.sc-mrd-table{width:auto;min-width:100%;border-collapse:collapse;font-size:var(--mrd-font-size-sm);color:var(--mrd-color-neutral-900)}.mrd-table__scroll.sc-mrd-table .mrd-table__table.sc-mrd-table{min-width:max-content}.mrd-table__header.sc-mrd-table{position:sticky;top:0;z-index:1;background:var(--mrd-color-white);text-align:left;padding:var(--mrd-space-2) var(--mrd-space-4);border-bottom:2px solid var(--mrd-border-color);color:var(--mrd-color-neutral-600);font-weight:var(--mrd-font-weight-medium);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-size:var(--mrd-font-size-xs);text-transform:uppercase;letter-spacing:0.04em}.mrd-table__header--sortable.sc-mrd-table{cursor:pointer;user-select:none}.mrd-table__header--sortable.sc-mrd-table:hover{background:var(--mrd-color-neutral-50);color:var(--mrd-color-neutral-800)}.mrd-table__header--sorted-asc.sc-mrd-table,.mrd-table__header--sorted-desc.sc-mrd-table{color:var(--mrd-color-primary);border-bottom-color:var(--mrd-color-primary)}.mrd-table__header--filtered.sc-mrd-table{color:var(--mrd-color-primary);border-bottom-color:var(--mrd-color-primary)}.mrd-table__header-label.sc-mrd-table{margin-right:var(--mrd-space-1)}.mrd-table__col-resizer.sc-mrd-table{position:absolute;top:0;right:0;width:9px;height:100%;cursor:col-resize;touch-action:none;user-select:none}.mrd-table__col-resizer.sc-mrd-table::after{content:"";position:absolute;top:25%;right:4px;width:1px;height:50%;background:var(--mrd-border-color)}.mrd-table__col-resizer.sc-mrd-table:hover::after{width:2px;right:3px;background:var(--mrd-color-primary)}.mrd-table__col-resizer--active.sc-mrd-table::after{width:2px;right:3px;height:100%;top:0;background:var(--mrd-color-primary)}.mrd-table--resizing.sc-mrd-table{cursor:col-resize;user-select:none}.mrd-table__sort-icon.sc-mrd-table{font-size:0.85rem;opacity:0.4;vertical-align:middle}.mrd-table__header--sorted-asc.sc-mrd-table .mrd-table__sort-icon.sc-mrd-table,.mrd-table__header--sorted-desc.sc-mrd-table .mrd-table__sort-icon.sc-mrd-table{opacity:1;color:var(--mrd-color-primary)}.mrd-table__filter-icon.sc-mrd-table{display:inline-flex;align-items:center;vertical-align:middle;margin-left:var(--mrd-space-1);color:var(--mrd-color-primary)}.mrd-table__row.sc-mrd-table{border-bottom:1px solid var(--mrd-border-color)}.mrd-table__row.sc-mrd-table:hover{background:var(--mrd-color-neutral-200) !important}.mrd-table__row--clickable.sc-mrd-table{cursor:pointer}.mrd-table__row--loading.sc-mrd-table{background:transparent}.mrd-table__row--failed.sc-mrd-table{background:transparent}.mrd-table__spacer.sc-mrd-table{border:none}.mrd-table__spacer.sc-mrd-table td.sc-mrd-table{padding:0;border:none}.mrd-table__cell.sc-mrd-table{padding:var(--mrd-space-2) var(--mrd-space-4);vertical-align:top;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.mrd-table__cell--numeric.sc-mrd-table{text-align:right;font-variant-numeric:tabular-nums}.mrd-table__cell--placeholder.sc-mrd-table{padding:var(--mrd-space-2) var(--mrd-space-4);border-bottom:1px solid var(--mrd-border-color)}.mrd-table__cell--failed.sc-mrd-table{padding:var(--mrd-space-2) var(--mrd-space-4);border-bottom:1px solid var(--mrd-border-color)}.mrd-table__placeholder-bar.sc-mrd-table{display:block;height:0.75rem;width:55%;border-radius:var(--mrd-border-radius-sm);background:linear-gradient(90deg, var(--mrd-color-neutral-200) 25%, var(--mrd-color-neutral-100) 50%, var(--mrd-color-neutral-200) 75%);background-size:200% 100%;animation:mrd-shimmer 1.4s ease infinite}.mrd-table__retry-button.sc-mrd-table{border:none;background:none;padding:0;color:var(--mrd-color-danger);font-size:inherit;cursor:pointer;text-decoration:underline}.mrd-table__toolbar.sc-mrd-table{display:flex;align-items:center;justify-content:space-between;padding-bottom:var(--mrd-space-2)}.mrd-table__toolbar-left.sc-mrd-table,.mrd-table__toolbar-right.sc-mrd-table{display:flex;gap:var(--mrd-space-2);align-items:center}.mrd-table__toolbar-center.sc-mrd-table{flex:1;display:flex;justify-content:center;align-items:center;gap:var(--mrd-space-1)}.mrd-table__view-switcher.sc-mrd-table{display:flex;align-items:center;gap:var(--mrd-space-1)}.mrd-table__view-arrow.sc-mrd-table{background:none;border:none;cursor:pointer;padding:0 var(--mrd-space-1);color:var(--mrd-color-neutral-500);font-size:var(--mrd-font-size-xs);line-height:1}.mrd-table__view-arrow.sc-mrd-table:hover{color:var(--mrd-color-neutral-800)}.mrd-table__view-title-wrap.sc-mrd-table{position:relative}.mrd-table__view-title.sc-mrd-table{font-size:var(--mrd-font-size-sm);font-weight:600;color:var(--mrd-color-neutral-800);font-family:var(--mrd-font-family);background:none;border:none;outline:none;cursor:pointer;padding:0 var(--mrd-space-1);max-width:220px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.mrd-table__view-title.sc-mrd-table:hover{color:var(--mrd-color-primary)}.mrd-table__view-popover.sc-mrd-table{position:absolute;top:calc(100% + var(--mrd-space-1));left:50%;transform:translateX(-50%);background:var(--mrd-color-white);border:1px solid var(--mrd-color-neutral-200);border-radius:var(--mrd-radius-md);box-shadow:var(--mrd-shadow-md);z-index:100;min-width:160px;padding:var(--mrd-space-1) 0}.mrd-table__view-popover-item.sc-mrd-table{display:block;width:100%;text-align:left;background:none;border:none;cursor:pointer;padding:var(--mrd-space-2) var(--mrd-space-3);font-size:var(--mrd-font-size-sm);font-family:var(--mrd-font-family);color:var(--mrd-color-neutral-700);white-space:nowrap}.mrd-table__view-popover-item.sc-mrd-table:hover{background:var(--mrd-color-neutral-50)}.mrd-table__view-popover-item--active.sc-mrd-table{font-weight:600;color:var(--mrd-color-primary)}.mrd-table__action.sc-mrd-table{position:relative;display:inline-flex;align-items:center;justify-content:center;width:2rem;height:2rem;padding:0;background:transparent;border:1px solid transparent;border-radius:var(--mrd-border-radius);cursor:pointer;color:var(--mrd-color-neutral-400);transition:background-color 0.15s, border-color 0.15s, color 0.15s}.mrd-table__action.sc-mrd-table:hover{background-color:var(--mrd-color-neutral-100);border-color:var(--mrd-color-neutral-300);color:var(--mrd-color-neutral-700)}.mrd-table__action.sc-mrd-table:hover .mrd-table__action-tooltip.sc-mrd-table{display:block}.mrd-table__action.sc-mrd-table:disabled{opacity:0.4;cursor:not-allowed}.mrd-table__action--primary.sc-mrd-table{color:var(--mrd-color-neutral-500)}.mrd-table__action--primary.sc-mrd-table:hover{background:var(--mrd-color-primary);border-color:var(--mrd-color-primary);color:var(--mrd-color-white)}.mrd-table__action--danger.sc-mrd-table{color:var(--mrd-color-error)}.mrd-table__action--danger.sc-mrd-table:hover{background-color:var(--mrd-color-error-light, #fef2f2);border-color:var(--mrd-color-error)}.mrd-table__action-icon.sc-mrd-table{width:1.25rem;height:1.25rem;pointer-events:none;fill:currentColor}.mrd-table__action-tooltip.sc-mrd-table{display:none;position:absolute;bottom:calc(100% + 6px);right:0;padding:var(--mrd-space-1) var(--mrd-space-2);font-size:var(--mrd-font-size-xs);white-space:nowrap;background:var(--mrd-color-tooltip, #fffce1);color:var(--mrd-color-neutral-900);border:1px solid var(--mrd-border-color);border-radius:var(--mrd-border-radius-sm, var(--mrd-border-radius));pointer-events:none;z-index:10}.mrd-table__create-picker-wrap.sc-mrd-table{position:relative}.mrd-table__create-picker.sc-mrd-table{position:absolute;right:0;top:calc(100% + 4px);background:var(--mrd-color-white, #fff);border:1px solid var(--mrd-border-color);border-radius:var(--mrd-border-radius);box-shadow:var(--mrd-shadow-md, 0 4px 12px rgba(0, 0, 0, 0.12));z-index:10;min-width:10rem;padding:var(--mrd-space-1) 0}.mrd-table__create-picker-item.sc-mrd-table{display:block;width:100%;text-align:left;padding:var(--mrd-space-2) var(--mrd-space-3);background:none;border:none;cursor:pointer;font-size:var(--mrd-font-size-sm);font-family:var(--mrd-font-family);color:var(--mrd-color-neutral-800)}.mrd-table__create-picker-item.sc-mrd-table:hover{background:var(--mrd-color-neutral-50);color:var(--mrd-color-neutral-900)}.mrd-table__filter-clear.sc-mrd-table{width:auto;gap:var(--mrd-space-1);padding:0 var(--mrd-space-2);color:var(--mrd-color-primary);border-color:var(--mrd-color-primary)}.mrd-table__filter-clear.sc-mrd-table:hover{color:var(--mrd-color-primary);border-color:var(--mrd-color-primary)}.mrd-table__filter-clear-label.sc-mrd-table{font-size:var(--mrd-font-size-sm);white-space:nowrap}.mrd-table__filter-popup.sc-mrd-table{position:fixed;width:280px;background:var(--mrd-color-white);border:1px solid var(--mrd-border-color);border-radius:var(--mrd-border-radius);box-shadow:var(--mrd-shadow-md, 0 4px 12px rgba(0, 0, 0, 0.12));z-index:var(--mrd-z-dropdown, 200);font-size:var(--mrd-font-size-sm)}.mrd-table__filter-popup-header.sc-mrd-table{display:flex;align-items:center;justify-content:space-between;padding:var(--mrd-space-2) var(--mrd-space-3);border-bottom:1px solid var(--mrd-border-color)}.mrd-table__filter-popup-title.sc-mrd-table{font-weight:var(--mrd-font-weight-medium);color:var(--mrd-color-neutral-800);font-size:var(--mrd-font-size-sm)}.mrd-table__filter-close.sc-mrd-table{background:transparent;border:none;cursor:pointer;color:var(--mrd-color-neutral-500);font-size:0.9rem;padding:2px 4px;border-radius:3px;line-height:1}.mrd-table__filter-close.sc-mrd-table:hover{background:var(--mrd-color-neutral-100);color:var(--mrd-color-neutral-800)}.mrd-table__filter-section.sc-mrd-table{padding:var(--mrd-space-2) var(--mrd-space-3)}.mrd-table__filter-section-label.sc-mrd-table{font-size:var(--mrd-font-size-xs);font-weight:var(--mrd-font-weight-medium);text-transform:uppercase;letter-spacing:0.04em;color:var(--mrd-color-neutral-500);margin-bottom:var(--mrd-space-2)}.mrd-table__filter-sort-buttons.sc-mrd-table{display:flex;gap:var(--mrd-space-2)}.mrd-table__filter-sort-btn.sc-mrd-table{flex:1;padding:var(--mrd-space-1) var(--mrd-space-2);background:transparent;border:1px solid var(--mrd-border-color);border-radius:var(--mrd-border-radius);cursor:pointer;font-size:var(--mrd-font-size-xs);color:var(--mrd-color-neutral-700)}.mrd-table__filter-sort-btn.sc-mrd-table:hover{background:var(--mrd-color-neutral-100)}.mrd-table__filter-sort-btn--active.sc-mrd-table{background:var(--mrd-color-primary);border-color:var(--mrd-color-primary);color:var(--mrd-color-white)}.mrd-table__filter-divider.sc-mrd-table{height:1px;background:var(--mrd-border-color);margin:0}.mrd-table__filter-editor.sc-mrd-table{display:flex;flex-direction:column;gap:var(--mrd-space-2)}.mrd-table__filter-select.sc-mrd-table,.mrd-table__filter-input.sc-mrd-table{width:100%;padding:var(--mrd-space-1) var(--mrd-space-2);border:1px solid var(--mrd-border-color);border-radius:var(--mrd-border-radius);font-size:var(--mrd-font-size-sm);color:var(--mrd-color-neutral-900);background:var(--mrd-color-white);box-sizing:border-box}.mrd-table__filter-select.sc-mrd-table:focus,.mrd-table__filter-input.sc-mrd-table:focus{outline:none;border-color:var(--mrd-color-primary);box-shadow:0 0 0 2px rgba(0, 0, 0, 0.06)}.mrd-table__filter-range.sc-mrd-table{display:flex;align-items:center;gap:var(--mrd-space-1)}.mrd-table__filter-range.sc-mrd-table .mrd-table__filter-input.sc-mrd-table{flex:1;min-width:0}.mrd-table__filter-range--stacked.sc-mrd-table{flex-direction:column;align-items:stretch;gap:var(--mrd-space-2)}.mrd-table__filter-range-sep.sc-mrd-table{color:var(--mrd-color-neutral-400);flex-shrink:0}.mrd-table__filter-range-label.sc-mrd-table{font-size:var(--mrd-font-size-xs);color:var(--mrd-color-neutral-500);margin-bottom:2px}.mrd-table__filter-radio-group.sc-mrd-table{display:flex;flex-direction:column;gap:var(--mrd-space-1)}.mrd-table__filter-radio-group--inline.sc-mrd-table{flex-direction:row;gap:var(--mrd-space-3)}.mrd-table__filter-radio-label.sc-mrd-table{display:flex;align-items:center;gap:var(--mrd-space-1);cursor:pointer;font-size:var(--mrd-font-size-sm);color:var(--mrd-color-neutral-800)}.mrd-table__filter-list.sc-mrd-table{display:flex;flex-direction:column;gap:var(--mrd-space-1);max-height:180px;overflow-y:auto}.mrd-table__filter-list-controls.sc-mrd-table{display:flex;gap:var(--mrd-space-2);margin-bottom:var(--mrd-space-1)}.mrd-table__filter-list-btn.sc-mrd-table{font-size:var(--mrd-font-size-xs);color:var(--mrd-color-primary);background:transparent;border:none;cursor:pointer;padding:0;text-decoration:underline}.mrd-table__filter-checkbox-label.sc-mrd-table{display:flex;align-items:center;gap:var(--mrd-space-1);cursor:pointer;font-size:var(--mrd-font-size-sm);color:var(--mrd-color-neutral-800)}.mrd-table__filter-no-support.sc-mrd-table{font-size:var(--mrd-font-size-sm);color:var(--mrd-color-neutral-500);margin:0;font-style:italic}.mrd-table__filter-popup-footer.sc-mrd-table{display:flex;justify-content:flex-end;gap:var(--mrd-space-2);padding:var(--mrd-space-2) var(--mrd-space-3);border-top:1px solid var(--mrd-border-color)}.mrd-table__filter-btn.sc-mrd-table{padding:var(--mrd-space-1) var(--mrd-space-3);border-radius:var(--mrd-border-radius);border:1px solid var(--mrd-border-color);font-size:var(--mrd-font-size-sm);cursor:pointer}.mrd-table__filter-btn--clear.sc-mrd-table{background:transparent;color:var(--mrd-color-neutral-600)}.mrd-table__filter-btn--clear.sc-mrd-table:hover{background:var(--mrd-color-neutral-100)}.mrd-table__filter-btn--apply.sc-mrd-table{background:var(--mrd-color-primary);border-color:var(--mrd-color-primary);color:var(--mrd-color-white)}.mrd-table__filter-btn--apply.sc-mrd-table:hover{background:var(--mrd-color-primary-dark, var(--mrd-color-primary));border-color:var(--mrd-color-primary-dark, var(--mrd-color-primary))}.mrd-table__totals-row.sc-mrd-table{border-top:2px solid var(--mrd-border-color)}.mrd-table__totals-cell.sc-mrd-table{position:sticky;bottom:0;z-index:2;padding:var(--mrd-space-2) var(--mrd-space-4);background:var(--mrd-color-white);font-weight:var(--mrd-font-weight-medium);font-variant-numeric:tabular-nums;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;border-top:2px solid var(--mrd-border-color)}.mrd-table__totals-cell--numeric.sc-mrd-table{text-align:right}.mrd-table__footer.sc-mrd-table{padding:var(--mrd-space-1) var(--mrd-space-2);font-size:var(--mrd-font-size-xs);color:var(--mrd-color-neutral-500);text-align:right}.mrd-table__empty.sc-mrd-table{padding:var(--mrd-space-4) var(--mrd-space-3);color:var(--mrd-color-neutral-500);font-size:var(--mrd-font-size-sm);text-align:center;margin:0}.mrd-table__file-btn.sc-mrd-table{display:inline-flex;align-items:center;gap:var(--mrd-space-1);background:none;border:none;padding:0;cursor:pointer;color:var(--mrd-color-primary);font-size:var(--mrd-font-size-sm);font-family:inherit;max-width:100%;overflow:hidden}.mrd-table__file-btn.sc-mrd-table:hover{text-decoration:underline;color:var(--mrd-color-primary-dark)}.mrd-table__file-icon.sc-mrd-table{flex-shrink:0;width:1rem;height:1rem}.mrd-table__textblock-btn.sc-mrd-table{display:inline;background:none;border:none;padding:0 0 0 var(--mrd-space-1);cursor:pointer;color:var(--mrd-color-primary);font-size:var(--mrd-font-size-sm);font-family:inherit;line-height:inherit;vertical-align:middle}.mrd-table__textblock-btn.sc-mrd-table:hover{color:var(--mrd-color-primary-dark)}.mrd-table__modal-backdrop.sc-mrd-table{position:fixed;inset:0;background:rgba(0, 0, 0, 0.4);z-index:var(--mrd-z-modal, 300);display:flex;align-items:center;justify-content:center}.mrd-table__modal.sc-mrd-table{background:#fff;border-radius:var(--mrd-radius-md, 0.5rem);padding:var(--mrd-space-6);max-width:min(600px, 90vw);max-height:70vh;overflow-y:auto;position:relative;box-shadow:var(--mrd-shadow-lg)}.mrd-table__modal-close.sc-mrd-table{position:absolute;top:var(--mrd-space-3);right:var(--mrd-space-3);background:none;border:none;cursor:pointer;font-size:1.25rem;line-height:1;color:var(--mrd-color-text-muted, #6b7280);padding:0}.mrd-table__modal-close.sc-mrd-table:hover{color:var(--mrd-color-text, #111827)}.mrd-table__modal-text.sc-mrd-table{margin:0;padding-right:var(--mrd-space-6);white-space:pre-wrap;word-break:break-word;font-size:var(--mrd-font-size-sm);line-height:1.6}.mrd-table__json-preview.sc-mrd-table{font-family:var(--mrd-font-family-mono);font-size:var(--mrd-font-size-xs);overflow:hidden;white-space:nowrap;text-overflow:ellipsis;display:inline-block;max-width:calc(100% - 1.5rem);vertical-align:middle}.mrd-table__modal-json.sc-mrd-table{margin:0;padding-right:var(--mrd-space-6);font-family:var(--mrd-font-family-mono);font-size:var(--mrd-font-size-xs);white-space:pre-wrap;word-break:break-word;line-height:1.6;background:none;border:none}@keyframes mrd-shimmer{0%{background-position:200% 0}100%{background-position:-200% 0}}'}},[2,"mrd-table",{item:[16],parentId:[1,"parent-id"],rows:[16],locale:[1],totalElements:[2,"total-elements"],pageSize:[2,"page-size"],rowHeight:[2,"row-height"],tableHeight:[2,"table-height"],requestTimeoutMs:[2,"request-timeout-ms"],activeViewIdx:[32],loadedPages:[32],requestedPages:[32],failedPages:[32],renderStart:[32],renderEnd:[32],colWidths:[32],resizingCol:[32],sortField:[32],sortDir:[32],activeFilters:[32],openFilterCol:[32],pendingFilter:[32],popupPos:[32],createPickerOpen:[32],viewPopoverOpen:[32],scrollTop:[32],textblockModal:[32],jsonModal:[32],aggregations:[32],aggregationsTotal:[32],minKnownTotal:[32],init:[64],setPage:[64],setAggregations:[64]},void 0,{totalElements:[{totalElementsChanged:0}],item:[{itemChanged:0}]}]);function I(){"undefined"!=typeof customElements&&["mrd-table"].forEach((t=>{"mrd-table"===t&&(customElements.get(o(t))||customElements.define(o(t),P))}))}export{P as M,I as d}
|
|
1
|
+
import{h as t,proxyCustomElement as r,HTMLElement as e,createEvent as l,writeTask as i,Host as a,transformTag as o}from"@stencil/core/internal/client";import{t as s}from"./i18n.js";import{a as d,b as n}from"./query-params.js";import{C as c}from"./cell-renderer.js";import{f as m,d as h,c as b}from"./format.js";const u=new Set(["TEXT","TEXTBLOCK","EMAIL","HYPERLINK"]),p=new Set(["INTEGER","DECIMAL","PERCENTAGE","CURRENCY"]),_=new Set(["DATE","DATETIME","TIME"]),v=new Set(["FILE","IMAGE"]),f=new Set(["LONGTEXT","JSON","FILE","IMAGE"]);function g(t,r){var e,l,i;const a=new URLSearchParams(t);a.delete("page"),a.delete("sort");const o=function(t){var r;const e={sum:[],avg:[],count:[]};for(const l of t){if("FIELD"!==l.type||!l.aggregate)continue;const t=l.aggregate.toLowerCase();t in e&&e[t].push(null!==(r=l.name)&&void 0!==r?r:"")}const l={};return e.sum.length&&(l.sum=e.sum),e.avg.length&&(l.avg=e.avg),e.count.length&&(l.count=e.count),Object.keys(l).length>0?l:null}(r);return(null===(e=null==o?void 0:o.sum)||void 0===e?void 0:e.length)&&a.set("sum",o.sum.join(",")),(null===(l=null==o?void 0:o.avg)||void 0===l?void 0:l.length)&&a.set("avg",o.avg.join(",")),(null===(i=null==o?void 0:o.count)||void 0===i?void 0:i.length)&&a.set("count",o.count.join(",")),a.toString()}function w(t){if(!t)return t;const[r,e,l]=t.split("-").map(Number);return new Date(r,e-1,l).toISOString().replace(/\.\d{3}Z$/,"Z")}function y(t){if(!t)return t;const[r,e,l]=t.split("-").map(Number);return new Date(r,e-1,l+1).toISOString().replace(/\.\d{3}Z$/,"Z")}const x=()=>t("span",{class:"mrd-table__filter-icon","aria-hidden":"true"},t("svg",{viewBox:"0 0 24 24",width:"14",height:"14",fill:"currentColor"},t("path",{d:"M10 18h4v-2h-4v2zM3 6v2h18V6H3zm3 7h12v-2H6v2z"}))),k=({col:r,row:e,locale:l,onDownload:i,onOpenTextblock:a,onOpenJson:o})=>{var d,n,m;const h=null!==(d=r.dataType)&&void 0!==d?d:"",b="FIELD"===r.type&&p.has(h);if("FIELD"===r.type&&("FILE"===h||"IMAGE"===h)){const a=null!==(n=r.name)&&void 0!==n?n:"",o=null==e?void 0:e[a],d=null==o?void 0:o.href,c=null==o?void 0:o.fileName;return t("td",{class:"mrd-table__cell"},d&&c?t("button",{class:"mrd-table__file-btn",title:c,onClick:t=>{t.stopPropagation(),i({href:d,fileName:c})}},t("svg",{class:"mrd-table__file-icon",viewBox:"0 0 24 24","aria-hidden":"true"},t("path",{fill:"currentColor",d:"M14 2H6c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V8l-6-6zm-1 7V3.5L18.5 9H13zm-3 8l-3-3 1.41-1.41L10 14.17l4.59-4.58L16 11l-6 6z"})),s("download",l)):"")}if("JSON"===h){const i=null!==(m=r.name)&&void 0!==m?m:"",a=i?null==e?void 0:e[i]:void 0;if(null==a||""===a)return t("td",{class:"mrd-table__cell"});const d=c.formatJson(a,!0),n=c.formatJson(a,!1);return t("td",{class:"mrd-table__cell"},t("span",{class:"mrd-table__json-preview",innerHTML:d}),t("button",{class:"mrd-table__textblock-btn",onClick:t=>{t.stopPropagation(),o(n)},"aria-label":s("textblock_show_more",l)},"⋯"))}if("TEXTBLOCK"===h){const i=c.render(r,e,l);if(i.length<=200)return t("td",{class:"mrd-table__cell"},i);const o=i.slice(0,200)+"…";return t("td",{class:"mrd-table__cell"},o,t("button",{class:"mrd-table__textblock-btn",onClick:t=>{t.stopPropagation(),a(i)},"aria-label":s("textblock_show_more",l)},"⋯"))}const u=c.render(r,e,l);return t("td",{class:"mrd-table__cell"+(b?" mrd-table__cell--numeric":""),title:u||void 0},u)},E=({columns:r,aggregations:e,locale:l})=>e&&r.some((t=>"FIELD"===t.type&&t.aggregate))?t("tfoot",null,t("tr",{class:"mrd-table__totals-row"},r.map((r=>{var i;const a=function(t,r,e){var l,i;if("FIELD"!==t.type||!t.aggregate||!r)return"";const a=null===(l=r[t.aggregate.toLowerCase()])||void 0===l?void 0:l[null!==(i=t.name)&&void 0!==i?i:""];if(null==a)return"";const o=t.dataType;return"INTEGER"===o?m(a,e,{maximumFractionDigits:0}):"PERCENTAGE"===o?h(a,e):"CURRENCY"===o&&t.currencyCode?b(a,t.currencyCode,e):m(a,e)}(r,e,l),o="FIELD"===r.type&&p.has(null!==(i=r.dataType)&&void 0!==i?i:"");return t("td",{class:"mrd-table__totals-cell"+(o?" mrd-table__totals-cell--numeric":"")},a)})))):null,C=({text:r,locale:e,onClose:l})=>null===r?null:t("div",{class:"mrd-table__modal-backdrop",onClick:l,role:"dialog","aria-modal":"true"},t("div",{class:"mrd-table__modal",onClick:t=>t.stopPropagation()},t("button",{class:"mrd-table__modal-close",onClick:l,"aria-label":s("close",e)},"✕"),t("p",{class:"mrd-table__modal-text"},r))),z=({html:r,locale:e,onClose:l})=>null===r?null:t("div",{class:"mrd-table__modal-backdrop",onClick:l,role:"dialog","aria-modal":"true"},t("div",{class:"mrd-table__modal",onClick:t=>t.stopPropagation()},t("button",{class:"mrd-table__modal-close",onClick:l,"aria-label":s("close",e)},"✕"),t("pre",{class:"mrd-table__modal-json",innerHTML:r}))),M=({locale:r,filterCount:e,actions:l,views:i,activeViewIdx:a,viewPopoverOpen:o,createPickerOpen:d,createTypes:n,cb:c})=>{var m;const h=l.length>0,b=i.length>1;return t("div",{class:"mrd-table__toolbar"},t("div",{class:"mrd-table__toolbar-left"},e>0&&t("button",{class:"mrd-table__action mrd-table__action--secondary mrd-table__filter-clear",onClick:c.onClearAllFilters},t("svg",{class:"mrd-table__action-icon",viewBox:"0 0 24 24","aria-hidden":"true"},t("path",{fill:"currentColor",d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"})),t("span",{class:"mrd-table__filter-clear-label"},s("table_filter_clear_all",r)," (",e,")"))),b&&t("div",{class:"mrd-table__toolbar-center"},t("div",{class:"mrd-table__view-switcher"},t("button",{class:"mrd-table__view-arrow","aria-label":"Previous view",onClick:()=>c.onViewSwitch((a-1+i.length)%i.length)},"◀"),t("div",{class:"mrd-table__view-title-wrap"},t("button",{class:"mrd-table__view-title",onClick:t=>c.onToggleViewPopover(t)},null===(m=i[a])||void 0===m?void 0:m.label),o&&t("div",{class:"mrd-table__view-popover",onClick:t=>t.stopPropagation()},i.map(((r,e)=>t("button",{key:String(e),class:"mrd-table__view-popover-item"+(e===a?" mrd-table__view-popover-item--active":""),onClick:()=>{e!==a&&c.onViewSwitch(e),c.onCloseViewPopover()}},r.label))))),t("button",{class:"mrd-table__view-arrow","aria-label":"Next view",onClick:()=>c.onViewSwitch((a+1)%i.length)},"▶"))),h&&t("div",{class:"mrd-table__toolbar-right"},l.map((r=>{var e,l;const i="create"===r.action?n:null;return(null==i?void 0:i.length)?t("div",{class:"mrd-table__create-picker-wrap",key:`action-${r.action}`},t("button",{class:`mrd-table__action mrd-table__action--${null!==(e=r.variant)&&void 0!==e?e:"secondary"}`,onClick:c.onToggleCreatePicker},r.icon?t("svg",{class:"mrd-table__action-icon","aria-hidden":"true"},t("use",{href:r.icon})):r.label,t("span",{class:"mrd-table__action-tooltip"},r.label)),d&&t("div",{class:"mrd-table__create-picker"},i.map((r=>t("button",{key:r.type,class:"mrd-table__create-picker-item",onClick:()=>c.onCreate(r.type)},r.label))))):t("button",{key:`action-${r.action}`,class:`mrd-table__action mrd-table__action--${null!==(l=r.variant)&&void 0!==l?l:"secondary"}`,disabled:r.disabled,onClick:()=>c.onAction(r.action)},r.icon?t("svg",{class:"mrd-table__action-icon","aria-hidden":"true"},t("use",{href:r.icon})):r.label,t("span",{class:"mrd-table__action-tooltip"},r.label))}))))},O=({col:r,dataType:e,openFilterCol:l,pendingFilter:i,locale:a,cb:o})=>{var d,n,c,m,h,b;const f=i;if(v.has(e))return t("p",{class:"mrd-table__filter-no-support"},s("filter_no_support",a));if("BOOLEAN"===e){const r=f.operator,e="isEmpty"===r||"isNotEmpty"===r;return t("div",{class:"mrd-table__filter-radio-group"},[{labelKey:"filter_all",value:null},{labelKey:"yes",value:!0},{labelKey:"no",value:!1}].map((r=>t("label",{class:"mrd-table__filter-radio-label"},t("input",{type:"radio",name:`bf-${l}`,checked:!e&&f.value===r.value,onChange:()=>o.onReplacePending(Object.assign(Object.assign({},f),{operator:void 0,value:r.value}))}),s(r.labelKey,a)))),t("label",{class:"mrd-table__filter-radio-label"},t("input",{type:"radio",name:`bf-${l}`,checked:"isEmpty"===r,onChange:()=>o.onReplacePending(Object.assign(Object.assign({},f),{operator:"isEmpty",value:void 0}))}),s("filter_is_empty",a)),t("label",{class:"mrd-table__filter-radio-label"},t("input",{type:"radio",name:`bf-${l}`,checked:"isNotEmpty"===r,onChange:()=>o.onReplacePending(Object.assign(Object.assign({},f),{operator:"isNotEmpty",value:void 0}))}),s("filter_is_not_empty",a)))}if("LIST"===e){const e=null!==(d=r.listItems)&&void 0!==d?d:[],l=null!==(n=f.values)&&void 0!==n?n:[];return t("div",{class:"mrd-table__filter-list"},t("div",{class:"mrd-table__filter-list-controls"},t("button",{class:"mrd-table__filter-list-btn",onClick:()=>o.onReplacePending(Object.assign(Object.assign({},f),{values:e.map((t=>t.key))}))},s("filter_select_all",a)),t("button",{class:"mrd-table__filter-list-btn",onClick:()=>o.onReplacePending(Object.assign(Object.assign({},f),{values:[]}))},s("filter_select_none",a))),e.map((r=>t("label",{class:"mrd-table__filter-checkbox-label"},t("input",{type:"checkbox",checked:l.includes(r.key),onChange:t=>o.onToggleValue(r.key,t.target.checked)}),r.label))))}if(u.has(e)||"RELATION"===e){const r=null!==(c=f.operator)&&void 0!==c?c:"startsWith",e="isEmpty"===r||"isNotEmpty"===r;return t("div",{class:"mrd-table__filter-editor"},t("select",{class:"mrd-table__filter-select",onChange:t=>o.onSetPending("operator",t.target.value)},[{val:"startsWith",labelKey:"filter_starts_with"},{val:"equals",labelKey:"filter_equals"},{val:"isEmpty",labelKey:"filter_is_empty"},{val:"isNotEmpty",labelKey:"filter_is_not_empty"}].map((e=>t("option",{value:e.val,selected:r===e.val},s(e.labelKey,a))))),!e&&t("input",{type:"text",class:"mrd-table__filter-input",value:String(null!==(m=f.value)&&void 0!==m?m:""),placeholder:s("filter_search_value",a),onInput:t=>o.onSetPending("value",t.target.value)}))}if(p.has(e)){const r=f.operator,e="isEmpty"===r||"isNotEmpty"===r,i=!e&&(void 0!==f.from||void 0!==f.to);return t("div",{class:"mrd-table__filter-editor"},t("select",{class:"mrd-table__filter-select",onChange:t=>{const r=t.target.value;o.onReplacePending(Object.assign(Object.assign({},f),"isEmpty"===r||"isNotEmpty"===r?{operator:r,value:void 0,from:void 0,to:void 0}:{operator:void 0}))}},t("option",{value:"",selected:!e},s("filter_has_value",a)),t("option",{value:"isEmpty",selected:"isEmpty"===r},s("filter_is_empty",a)),t("option",{value:"isNotEmpty",selected:"isNotEmpty"===r},s("filter_is_not_empty",a))),!e&&t("div",{class:"mrd-table__filter-editor"},t("div",{class:"mrd-table__filter-radio-group mrd-table__filter-radio-group--inline"},t("label",{class:"mrd-table__filter-radio-label"},t("input",{type:"radio",name:`nm-${l}`,checked:!i,onChange:()=>o.onReplacePending(Object.assign(Object.assign({},f),{from:void 0,to:void 0}))}),s("filter_exact",a)),t("label",{class:"mrd-table__filter-radio-label"},t("input",{type:"radio",name:`nm-${l}`,checked:i,onChange:()=>o.onReplacePending(Object.assign(Object.assign({},f),{value:void 0,from:null,to:null}))}),s("filter_range",a))),i?t("div",{class:"mrd-table__filter-range"},t("input",{type:"number",class:"mrd-table__filter-input",placeholder:s("filter_from",a),value:null!=f.from?String(f.from):"",onInput:t=>o.onSetPending("from",t.target.value)}),t("span",{class:"mrd-table__filter-range-sep"},"–"),t("input",{type:"number",class:"mrd-table__filter-input",placeholder:s("filter_to",a),value:null!=f.to?String(f.to):"",onInput:t=>o.onSetPending("to",t.target.value)})):t("input",{type:"number",class:"mrd-table__filter-input",value:null!=f.value?String(f.value):"",onInput:t=>o.onSetPending("value",t.target.value)})))}if("DATETIME"===e){const r=f.operator,e="isEmpty"===r||"isNotEmpty"===r,i=!e&&(void 0!==f.from||void 0!==f.to);return t("div",{class:"mrd-table__filter-editor"},t("select",{class:"mrd-table__filter-select",onChange:t=>{const r=t.target.value;o.onReplacePending(Object.assign(Object.assign({},f),"isEmpty"===r||"isNotEmpty"===r?{operator:r,value:void 0,from:void 0,to:void 0}:{operator:void 0}))}},t("option",{value:"",selected:!e},s("filter_has_value",a)),t("option",{value:"isEmpty",selected:"isEmpty"===r},s("filter_is_empty",a)),t("option",{value:"isNotEmpty",selected:"isNotEmpty"===r},s("filter_is_not_empty",a))),!e&&t("div",{class:"mrd-table__filter-editor"},t("div",{class:"mrd-table__filter-radio-group mrd-table__filter-radio-group--inline"},t("label",{class:"mrd-table__filter-radio-label"},t("input",{type:"radio",name:`dt-${l}`,checked:!i,onChange:()=>o.onReplacePending(Object.assign(Object.assign({},f),{from:void 0,to:void 0}))}),s("filter_exact",a)),t("label",{class:"mrd-table__filter-radio-label"},t("input",{type:"radio",name:`dt-${l}`,checked:i,onChange:()=>o.onReplacePending(Object.assign(Object.assign({},f),{value:void 0,from:null,to:null}))}),s("filter_range",a))),i?t("div",{class:"mrd-table__filter-range mrd-table__filter-range--stacked"},t("label",{class:"mrd-table__filter-range-label"},s("filter_from",a)),t("input",{type:"date",class:"mrd-table__filter-input",value:null!=f.from?String(f.from):"",onInput:t=>o.onSetPending("from",t.target.value)}),t("label",{class:"mrd-table__filter-range-label"},s("filter_to",a)),t("input",{type:"date",class:"mrd-table__filter-input",value:null!=f.to?String(f.to):"",onInput:t=>o.onSetPending("to",t.target.value)})):t("input",{type:"date",class:"mrd-table__filter-input",value:String(null!==(h=f.value)&&void 0!==h?h:""),onInput:t=>o.onSetPending("value",t.target.value)})))}if(_.has(e)){const r="DATE"===e?"date":"time",i=f.operator,d="isEmpty"===i||"isNotEmpty"===i,n=!d&&(void 0!==f.from||void 0!==f.to);return t("div",{class:"mrd-table__filter-editor"},t("select",{class:"mrd-table__filter-select",onChange:t=>{const r=t.target.value;o.onReplacePending(Object.assign(Object.assign({},f),"isEmpty"===r||"isNotEmpty"===r?{operator:r,value:void 0,from:void 0,to:void 0}:{operator:void 0}))}},t("option",{value:"",selected:!d},s("filter_has_value",a)),t("option",{value:"isEmpty",selected:"isEmpty"===i},s("filter_is_empty",a)),t("option",{value:"isNotEmpty",selected:"isNotEmpty"===i},s("filter_is_not_empty",a))),!d&&t("div",{class:"mrd-table__filter-editor"},t("div",{class:"mrd-table__filter-radio-group mrd-table__filter-radio-group--inline"},t("label",{class:"mrd-table__filter-radio-label"},t("input",{type:"radio",name:`dt-${l}`,checked:!n,onChange:()=>o.onReplacePending(Object.assign(Object.assign({},f),{from:void 0,to:void 0}))}),s("filter_exact",a)),t("label",{class:"mrd-table__filter-radio-label"},t("input",{type:"radio",name:`dt-${l}`,checked:n,onChange:()=>o.onReplacePending(Object.assign(Object.assign({},f),{value:void 0,from:null,to:null}))}),s("filter_range",a))),n?t("div",{class:"mrd-table__filter-range"},t("input",{type:r,class:"mrd-table__filter-input",placeholder:s("filter_from",a),value:null!=f.from?String(f.from):"",onInput:t=>o.onSetPending("from",t.target.value)}),t("input",{type:r,class:"mrd-table__filter-input",placeholder:s("filter_to",a),value:null!=f.to?String(f.to):"",onInput:t=>o.onSetPending("to",t.target.value)})):t("input",{type:r,class:"mrd-table__filter-input",value:String(null!==(b=f.value)&&void 0!==b?b:""),onInput:t=>o.onSetPending("value",t.target.value)})))}return null},S=r=>{var e;const{col:l,openFilterCol:i,popupPos:a,sortField:o,sortDir:d,locale:n,cb:c}=r,m=null!==(e=l.label)&&void 0!==e?e:i,h=o===i;return t("div",{class:"mrd-table__filter-popup",style:{top:`${a.top}px`,left:`${a.left}px`},onClick:t=>t.stopPropagation()},t("div",{class:"mrd-table__filter-popup-header"},t("span",{class:"mrd-table__filter-popup-title"},m),t("button",{class:"mrd-table__filter-close",onClick:c.onClose},"✕")),t("div",{class:"mrd-table__filter-section"},t("div",{class:"mrd-table__filter-section-label"},s("filter_sorting",n)),t("div",{class:"mrd-table__filter-sort-buttons"},t("button",{class:"mrd-table__filter-sort-btn"+(h&&"asc"===d?" mrd-table__filter-sort-btn--active":""),onClick:()=>c.onApplySort("asc")},"▲ ",s("filter_ascending",n)),t("button",{class:"mrd-table__filter-sort-btn"+(h&&"desc"===d?" mrd-table__filter-sort-btn--active":""),onClick:()=>c.onApplySort("desc")},"▼ ",s("filter_descending",n)))),t("div",{class:"mrd-table__filter-divider"}),t("div",{class:"mrd-table__filter-section"},t("div",{class:"mrd-table__filter-section-label"},s("filter_section",n)),t(O,Object.assign({},r))),t("div",{class:"mrd-table__filter-popup-footer"},t("button",{class:"mrd-table__filter-btn mrd-table__filter-btn--clear",onClick:c.onClear},s("filter_clear",n)),t("button",{class:"mrd-table__filter-btn mrd-table__filter-btn--apply",onClick:c.onApply},s("filter_apply",n))))};function T(t,r){return Math.ceil(t/r)}function j(t,r,e){return{firstPage:Math.floor(t/e),lastPage:Math.floor(r/e)}}const P=r(class extends e{constructor(t){super(),!1!==t&&this.__registerHost(),this.mrdLoadPage=l(this,"mrdLoadPage",7),this.mrdPageError=l(this,"mrdPageError",7),this.mrdRowClick=l(this,"mrdRowClick",7),this.mrdAction=l(this,"mrdAction",7),this.mrdDownload=l(this,"mrdDownload",7),this.mrdLoadAggregations=l(this,"mrdLoadAggregations",7),this.pendingPages=new Set,this.debounceTimer=null,this.requestedAt=new Map,this.retryAttempts=new Map,this.staleCheckTimer=null,this.outsideClickHandler=null,this.keydownHandler=null,this.createPickerClickHandler=null,this.viewPopoverClickHandler=null,this.resizeObserver=null,this.colWidthMeasureScheduled=!1,this.resizeOrigin=null,this.colWidthsUserSet=!1,this.paginationActivated=!1,this.item=null,this.parentId="",this.rows=[],this.locale=navigator.language,this.totalElements=0,this.pageSize=20,this.rowHeight=36,this.tableHeight=500,this.requestTimeoutMs=15e3,this.activeViewIdx=0,this.loadedPages=new Map,this.requestedPages=new Set,this.failedPages=new Set,this.renderStart=0,this.renderEnd=0,this.colWidths=[],this.resizingCol=null,this.sortField="",this.sortDir="asc",this.activeFilters=new Map,this.openFilterCol=null,this.pendingFilter=null,this.popupPos={top:0,left:0},this.createPickerOpen=!1,this.viewPopoverOpen=!1,this.scrollTop=0,this.textblockModal=null,this.jsonModal=null,this.aggregations=null,this.aggregationsTotal=null,this.aggregationsPending=!1,this.minKnownTotal=0,this.handleScroll=t=>{const r=t.currentTarget,{renderStart:e,renderEnd:l}=function(t,r,e,l){const i=Math.floor(t/r),a=i+T(e,r)+10;return{renderStart:Math.max(0,i-10),renderEnd:l>0?Math.min(l-1,a):a}}(r.scrollTop,this.rowHeight,this.tableHeight,this.baseTotal);this.scrollTop=r.scrollTop,this.renderStart=e,this.renderEnd=l,this.requestPagesForWindow(this.renderStart,this.renderEnd)}}totalElementsChanged(t){t>0&&(this.renderEnd=Math.min(this.renderEnd,t-1))}itemChanged(t){var r,e;this.activeViewIdx=0,this.applyDefaultSort(null!==(e=null===(r=null==t?void 0:t.view)||void 0===r?void 0:r.defaultSort)&&void 0!==e?e:""),this.colWidths=[],this.colWidthMeasureScheduled=!1,this.colWidthsUserSet=!1}componentWillLoad(){var t,r,e;this.applyDefaultSort(null!==(e=null===(r=null===(t=this.item)||void 0===t?void 0:t.view)||void 0===r?void 0:r.defaultSort)&&void 0!==e?e:"")}componentDidLoad(){this.staleCheckTimer=setInterval((()=>this.checkStalePages()),2e3),"undefined"!=typeof ResizeObserver&&(this.resizeObserver=new ResizeObserver((()=>this.freezeColWidths())),this.resizeObserver.observe(this.el))}applyDefaultSort(t){const{field:r,dir:e}=function(t){var r;if(!t)return{field:"",dir:"asc"};const e=t.split(",");return{field:e[0].trim(),dir:"desc"===(null===(r=e[1])||void 0===r?void 0:r.trim())?"desc":"asc"}}(t);this.sortField=r,this.sortDir=e}async init(){null!==this.debounceTimer&&(clearTimeout(this.debounceTimer),this.debounceTimer=null),this.pendingPages.clear(),this.loadedPages=new Map,this.requestedPages=new Set,this.failedPages=new Set,this.requestedAt.clear(),this.retryAttempts.clear(),this.colWidths=[],this.colWidthMeasureScheduled=!1,this.colWidthsUserSet=!1,this.scrollTop=0,this.renderStart=0,this.renderEnd=this.visibleCount()-1;const t=this.el.querySelector(".mrd-table__scroll");t&&(t.scrollTop=0),this.aggregations=null,this.aggregationsTotal=null,this.aggregationsPending=!0,this.minKnownTotal=0,this.paginationActivated=!0,this.emitLoadPage(0),this.requestedPages=new Set([0])}async setPage(t,r,e){this.paginationActivated=!0;const l=void 0!==e?!e:r.length<this.pageSize;l?(this.renderEnd=Math.min(this.renderEnd,t*this.pageSize+r.length-1),this.minKnownTotal=t*this.pageSize+r.length):this.minKnownTotal=Math.max(this.minKnownTotal,(t+1)*this.pageSize+1);const i=new Map(this.loadedPages);if(i.set(t,r),this.loadedPages=i,this.renderEnd<this.renderStart&&(this.renderEnd=Math.min(this.renderStart+this.visibleCount()-1,this.minKnownTotal-1)),this.requestedAt.delete(t),this.retryAttempts.delete(t),this.failedPages.has(t)){const r=new Set(this.failedPages);r.delete(t),this.failedPages=r}if(0===t&&this.aggregationsPending){this.aggregationsPending=!1;const t=this.columns.some((t=>"FIELD"===t.type&&t.aggregate));l&&!t||this.emitLoadAggregations()}}async setAggregations(t){null!=t.total&&(this.aggregationsTotal=t.total),this.aggregations=t}disconnectedCallback(){this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),null!==this.staleCheckTimer&&(clearInterval(this.staleCheckTimer),this.staleCheckTimer=null),this.outsideClickHandler&&(document.removeEventListener("click",this.outsideClickHandler),this.outsideClickHandler=null),this.createPickerClickHandler&&(document.removeEventListener("click",this.createPickerClickHandler),this.createPickerClickHandler=null),this.keydownHandler&&(document.removeEventListener("keydown",this.keydownHandler),this.keydownHandler=null),this.viewPopoverClickHandler&&(document.removeEventListener("click",this.viewPopoverClickHandler),this.viewPopoverClickHandler=null)}componentDidRender(){this.freezeColWidths()}freezeColWidths(){0!==this.colWidths.length||this.colWidthMeasureScheduled||0===this.loadedPages.size||(this.colWidthMeasureScheduled=!0,i((()=>{var t;if(this.colWidthMeasureScheduled=!1,0!==this.colWidths.length)return;const r=null!==(t=this.measureContentWidths())&&void 0!==t?t:this.measureColWidths();r&&r.some((t=>t>0))&&(this.colWidths=r)})))}measureColWidths(){const t=this.el.querySelectorAll(".mrd-table__header");return 0===t.length||t.length!==this.columns.length?null:Array.from(t).map((t=>Math.round(t.getBoundingClientRect().width)))}neededWidth(t){const r=t=>"number"==typeof t&&Number.isFinite(t)?t:0,e=r(t.clientWidth),l=r(t.scrollWidth),i=r(parseFloat(getComputedStyle(t).paddingRight||"0")),a=Math.max(0,r(t.offsetWidth)-e);return Math.ceil((l>e?l+i:e)+a)}measureContentWidths(){const t=this.el.querySelectorAll(".mrd-table__header");if(0===t.length||t.length!==this.columns.length)return null;const r=Array.from(t).map(((t,r)=>{let e=this.neededWidth(t);return this.el.querySelectorAll(`.mrd-table__cell:nth-child(${r+1})`).forEach((t=>{e=Math.max(e,this.neededWidth(t))})),e}));return r.every((t=>t<=0))?null:r.map((t=>Math.min(Math.max(t,48),600)))}syncColWidths(){const t=this.measureColWidths();return t?(this.colWidths=t,!0):this.colWidths.length===this.columns.length}setColWidth(t,r){const e=[...this.colWidths];e[t]=Math.max(48,Math.round(r)),this.colWidths=e,this.colWidthsUserSet=!0}handleResizeStart(t,r){var e,l;t.preventDefault(),t.stopPropagation(),this.syncColWidths()&&(this.resizeOrigin={idx:r,startX:t.clientX,startWidth:this.colWidths[r]},this.resizingCol=r,null===(l=(e=t.currentTarget).setPointerCapture)||void 0===l||l.call(e,t.pointerId))}handleResizeMove(t){if(!this.resizeOrigin)return;const{idx:r,startX:e,startWidth:l}=this.resizeOrigin;this.setColWidth(r,l+(t.clientX-e))}handleResizeEnd(t){var r,e;this.resizeOrigin&&(this.resizeOrigin=null,this.resizingCol=null,null===(e=(r=t.currentTarget).releasePointerCapture)||void 0===e||e.call(r,t.pointerId))}handleResizeAutoFit(t,r){if(t.preventDefault(),t.stopPropagation(),!this.syncColWidths())return;const e=this.el.querySelectorAll(`.mrd-table__header:nth-child(${r+1}), .mrd-table__cell:nth-child(${r+1})`);let l=0;e.forEach((t=>{l=Math.max(l,this.neededWidth(t))})),l>0&&this.setColWidth(r,Math.min(l,600))}lockedTableStyle(){if(0===this.colWidths.length)return;const t=this.colWidths.reduce(((t,r)=>t+(r||0)),0);return Object.assign({tableLayout:"fixed",width:`${t}px`},this.colWidthsUserSet?{}:{minWidth:"100%"})}renderColResizer(r){return t("span",{class:"mrd-table__col-resizer"+(this.resizingCol===r?" mrd-table__col-resizer--active":""),role:"separator","aria-orientation":"vertical",title:s("column_resize",this.locale),"on-pointerdown":t=>this.handleResizeStart(t,r),"on-pointermove":t=>this.handleResizeMove(t),"on-pointerup":t=>this.handleResizeEnd(t),"on-pointercancel":t=>this.handleResizeEnd(t),"on-dblclick":t=>this.handleResizeAutoFit(t,r),onClick:t=>t.stopPropagation()})}visibleCount(){return T(this.tableHeight,this.rowHeight)}sortParam(){return(t=this.sortField)?"desc"===this.sortDir?`${t},desc`:t:"";var t}get allViews(){var t,r,e,l,i,a,o;if(!this.item)return[];const s=this.item;return[{label:null!==(i=null!==(l=null!==(e=null!==(t=s.label)&&void 0!==t?t:null===(r=s.view)||void 0===r?void 0:r.pluralLabel)&&void 0!==e?e:s.dataClass)&&void 0!==l?l:s.relatedClass)&&void 0!==i?i:"",dataClass:null!==(a=s.dataClass)&&void 0!==a?a:s.relatedClass,fromClass:s.fromClass,filterClass:s.filterClass,view:s.view},...(null!==(o=s.alternativeViews)&&void 0!==o?o:[]).map((t=>{var r,e,l,i;return{label:null!==(i=null!==(l=null!==(r=t.label)&&void 0!==r?r:null===(e=t.view)||void 0===e?void 0:e.pluralLabel)&&void 0!==l?l:t.dataClass)&&void 0!==i?i:"",dataClass:t.dataClass,fromClass:t.fromClass,filterClass:t.filterClass,view:t.view}}))]}buildExcelPath(){var t;const r=this.allViews[this.activeViewIdx];return r?"/excel"+n({isRelatedView:"RELATED_VIEW"===(null===(t=this.item)||void 0===t?void 0:t.type),fromClass:r.fromClass,parentId:this.parentId,dataClass:r.dataClass}):""}buildActionDetail(t,r){var e,l,i;if("export"===t)return{action:t,path:this.buildExcelPath(),qs:this.buildQueryParams(0)};if("create"===t){const a=this.allViews[this.activeViewIdx],o="RELATED_VIEW"===(null===(e=this.item)||void 0===e?void 0:e.type)?`/${null!==(l=null==a?void 0:a.fromClass)&&void 0!==l?l:""}/${this.parentId}`:null;return Object.assign({action:t,dataClass:null!==(i=null==a?void 0:a.dataClass)&&void 0!==i?i:"",parentPath:o},r?{basicType:r}:{})}return{action:t}}buildDataPath(){var t;const r=this.allViews[this.activeViewIdx];return r?n({isRelatedView:"RELATED_VIEW"===(null===(t=this.item)||void 0===t?void 0:t.type),fromClass:r.fromClass,parentId:this.parentId,dataClass:r.dataClass}):""}buildQueryParams(t){var r;const e=this.allViews[this.activeViewIdx];return function(t){var r,e;const l=new URLSearchParams;t.page>0&&l.set("page",String(t.page)),t.sort&&l.set("sort",t.sort),t.filterClass&&l.set("type",t.filterClass),d(l,t.viewFilters);for(const i of t.activeFilters)"isEmpty"!==i.operator?"isNotEmpty"!==i.operator?"startsWith"!==i.operator?(null===(e=i.values)||void 0===e?void 0:e.length)?l.set(i.field,i.values.join(",")):(null!=i.value&&l.set(i.field,String(i.value)),null!=i.from&&l.set(i.field+"_from",String(i.from)),null!=i.to&&l.set(i.field+"_to",String(i.to))):l.set(i.field+"_startswith",String(null!==(r=i.value)&&void 0!==r?r:"")):l.set(i.field+"_notempty","true"):l.set(i.field,"");return l.toString()}({page:t,sort:this.sortParam(),filterClass:null==e?void 0:e.filterClass,viewFilters:null===(r=null==e?void 0:e.view)||void 0===r?void 0:r.filter,activeFilters:this.activeFilters.values()})}get isPaginated(){return this.totalElements>0||this.paginationActivated}get columns(){var t,r,e;return null!==(e=null===(r=null===(t=this.allViews[this.activeViewIdx])||void 0===t?void 0:t.view)||void 0===r?void 0:r.values)&&void 0!==e?e:[]}get tableActions(){var t,r;const e=null!==(r=null===(t=this.item)||void 0===t?void 0:t.actions)&&void 0!==r?r:[];return(null!=e?e:[]).reduce(((t,r)=>("NEW"===r&&t.push({action:"create",label:s("table_new_record",this.locale),icon:"assets/sprites.svg#icon-plus",variant:"primary"}),"EXPORT"===r&&t.push({action:"export",label:s("table_export_excel",this.locale),icon:"assets/sprites.svg#icon-file-excel"}),t)),[])}toggleCreatePicker(){this.createPickerOpen?this.closeCreatePicker():(this.createPickerOpen=!0,this.createPickerClickHandler&&document.removeEventListener("click",this.createPickerClickHandler),this.createPickerClickHandler=t=>{const r=this.el.querySelector(".mrd-table__create-picker-wrap");r&&!r.contains(t.target)&&this.closeCreatePicker()},document.addEventListener("click",this.createPickerClickHandler))}closeCreatePicker(){this.createPickerOpen=!1,this.createPickerClickHandler&&(document.removeEventListener("click",this.createPickerClickHandler),this.createPickerClickHandler=null)}colName(t){var r;return null!==(r=t.name)&&void 0!==r?r:""}colDataType(t){var r;return"RELATION"===t.type?"RELATION":null!==(r=t.dataType)&&void 0!==r?r:"TEXT"}isTotalKnown(){return null!=this.aggregationsTotal||function(t,r){for(const e of t.values())if(e.length<r)return!0;return!1}(this.loadedPages,this.pageSize)}get baseTotal(){return null!=this.aggregationsTotal?this.aggregationsTotal:this.totalElements>0?this.totalElements:this.minKnownTotal}emitLoadAggregations(){const t=this.buildQueryParams(0);this.mrdLoadAggregations.emit({path:this.buildDataPath(),qs:t,aggQs:g(t,this.columns)})}resetPages(){null!==this.debounceTimer&&(clearTimeout(this.debounceTimer),this.debounceTimer=null),this.pendingPages.clear(),this.loadedPages=new Map,this.requestedPages=new Set,this.failedPages=new Set,this.requestedAt.clear(),this.retryAttempts.clear(),this.colWidthsUserSet||(this.colWidths=[],this.colWidthMeasureScheduled=!1),this.scrollTop=0,this.renderStart=0,this.minKnownTotal=0,this.renderEnd=this.visibleCount()-1;const t=this.el.querySelector(".mrd-table__scroll");t&&(t.scrollTop=0)}applySort(t,r){this.sortField=this.colName(t),this.sortDir=r,this.resetPages(),this.emitPagesForWindow(this.renderStart,this.renderEnd)}emitLoadPage(t){this.mrdLoadPage.emit({page:t,sort:this.sortParam(),path:this.buildDataPath(),qs:this.buildQueryParams(t)}),this.requestedAt.set(t,Date.now())}emitPagesForWindow(t,r){const{firstPage:e,lastPage:l}=j(t,r,this.pageSize),i=new Set(this.requestedPages);let a=!1;for(let t=e;t<=l;t++)this.loadedPages.has(t)||i.has(t)||(i.add(t),this.emitLoadPage(t),a=!0);a&&(this.requestedPages=i)}getRow(t){return function(t,r,e){var l;const i=t.get(Math.floor(r/e));return null!==(l=null==i?void 0:i[r%e])&&void 0!==l?l:null}(this.loadedPages,t,this.pageSize)}requestPagesForWindow(t,r){const{firstPage:e,lastPage:l}=j(t,r,this.pageSize);let i=!1;for(let t=e;t<=l;t++)this.loadedPages.has(t)||this.requestedPages.has(t)||this.pendingPages.has(t)||(this.pendingPages.add(t),i=!0);i&&(null!==this.debounceTimer&&clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout((()=>this.flushPendingPages()),150))}flushPendingPages(){if(this.debounceTimer=null,0===this.pendingPages.size)return;const t=new Set(this.requestedPages);let r=!1;for(const e of this.pendingPages){if(this.loadedPages.has(e)||t.has(e))continue;const l=e*this.pageSize;l+this.pageSize-1<this.renderStart||l>this.renderEnd||(t.add(e),this.emitLoadPage(e),r=!0)}this.pendingPages.clear(),r&&(this.requestedPages=t)}checkStalePages(){var t;if(0===this.requestedAt.size)return;const r=function(t,r,e){const l=[];for(const[i,a]of t)r-a>=e&&l.push(i);return l}(this.requestedAt,Date.now(),this.requestTimeoutMs).filter((t=>!this.loadedPages.has(t)));if(0===r.length)return;let e=null;for(const l of r){const r=null!==(t=this.retryAttempts.get(l))&&void 0!==t?t:0;r<3?(this.retryAttempts.set(l,r+1),this.emitLoadPage(l)):(this.requestedAt.delete(l),this.retryAttempts.delete(l),e||(e=new Set(this.failedPages)),e.add(l),this.mrdPageError.emit({page:l}))}e&&(this.failedPages=e)}retryPage(t){const r=new Set(this.failedPages);r.delete(t),this.failedPages=r,this.retryAttempts.delete(t),this.emitLoadPage(t);const e=new Set(this.requestedPages);e.add(t),this.requestedPages=e}handleFilterOpen(t,r){r.stopPropagation();const e=r.currentTarget.getBoundingClientRect();let l=e.left;l+280>window.innerWidth-8&&(l=e.right-280),this.popupPos={top:e.bottom+4,left:Math.max(8,l)};const i=this.colName(t),a=this.colDataType(t),o=this.activeFilters.get(i),s=u.has(a)||"RELATION"===a?"startsWith":void 0;this.pendingFilter="DATETIME"===a&&o&&"isEmpty"!==o.operator&&"isNotEmpty"!==o.operator?function(t){const r=Object.assign({},t);return"string"==typeof r.from&&r.from&&(r.from=function(t){if(!t)return t;const r=new Date(t);return isNaN(r.getTime())?t:`${r.getFullYear()}-${String(r.getMonth()+1).padStart(2,"0")}-${String(r.getDate()).padStart(2,"0")}`}(r.from)),"string"==typeof r.to&&r.to&&(r.to=function(t){if(!t)return t;const r=new Date(t);return isNaN(r.getTime())?t:(r.setDate(r.getDate()-1),`${r.getFullYear()}-${String(r.getMonth()+1).padStart(2,"0")}-${String(r.getDate()).padStart(2,"0")}`)}(r.to)),r.from&&r.to&&r.from===r.to?Object.assign(Object.assign({},r),{value:r.from,from:void 0,to:void 0}):r}(o):o?Object.assign({},o):{field:i,dataType:a,operator:s},this.openFilterCol=i,this.outsideClickHandler&&document.removeEventListener("click",this.outsideClickHandler),this.outsideClickHandler=t=>{const r=this.el.querySelector(".mrd-table__filter-popup");r&&!r.contains(t.target)&&this.closeFilterPopup()},document.addEventListener("click",this.outsideClickHandler)}closeFilterPopup(){this.openFilterCol=null,this.pendingFilter=null,this.outsideClickHandler&&(document.removeEventListener("click",this.outsideClickHandler),this.outsideClickHandler=null)}openTextblockModal(t){this.textblockModal=t,this.keydownHandler&&document.removeEventListener("keydown",this.keydownHandler),this.keydownHandler=t=>{"Escape"===t.key&&this.closeTextblockModal()},document.addEventListener("keydown",this.keydownHandler)}closeTextblockModal(){this.textblockModal=null,this.keydownHandler&&(document.removeEventListener("keydown",this.keydownHandler),this.keydownHandler=null)}openJsonModal(t){this.jsonModal=t,this.keydownHandler&&document.removeEventListener("keydown",this.keydownHandler),this.keydownHandler=t=>{"Escape"===t.key&&this.closeJsonModal()},document.addEventListener("keydown",this.keydownHandler)}closeJsonModal(){this.jsonModal=null,this.keydownHandler&&(document.removeEventListener("keydown",this.keydownHandler),this.keydownHandler=null)}setPending(t,r){this.pendingFilter=Object.assign(Object.assign({},this.pendingFilter),{[t]:r})}togglePendingValue(t,r){var e,l;const i=null!==(l=null===(e=this.pendingFilter)||void 0===e?void 0:e.values)&&void 0!==l?l:[];this.pendingFilter=Object.assign(Object.assign({},this.pendingFilter),{values:r?[...i,t]:i.filter((r=>r!==t))})}applyFilter(){const t=this.pendingFilter;if(!(null==t?void 0:t.field))return void this.closeFilterPopup();const r=function(t){const r=Object.assign({},t);return"DATETIME"===t.dataType&&"isEmpty"!==t.operator&&"isNotEmpty"!==t.operator&&("string"==typeof r.value&&r.value?(r.from=w(r.value),r.to=y(r.value),r.value=void 0):("string"==typeof r.from&&r.from&&(r.from=w(r.from)),"string"==typeof r.to&&r.to&&(r.to=y(r.to)))),r}(t),e=new Map(this.activeFilters);!function(t){return"isEmpty"===t.operator||"isNotEmpty"===t.operator||void 0!==t.values&&t.values.length>0||null!=t.value&&""!==t.value||"boolean"==typeof t.value||null!=t.from&&""!==t.from||null!=t.to&&""!==t.to}(r)?e.delete(r.field):e.set(r.field,r),this.activeFilters=e,this.closeFilterPopup(),this.aggregations=null,this.aggregationsTotal=null,this.aggregationsPending=!0,this.isPaginated&&(this.resetPages(),this.emitPagesForWindow(this.renderStart,this.renderEnd))}clearFilter(){const t=this.openFilterCol,r=new Map(this.activeFilters);t&&r.delete(t),this.activeFilters=r,this.closeFilterPopup(),this.aggregations=null,this.aggregationsTotal=null,this.aggregationsPending=!0,this.isPaginated&&(this.resetPages(),this.emitPagesForWindow(this.renderStart,this.renderEnd))}clearAllFilters(){this.activeFilters=new Map,this.aggregations=null,this.aggregationsTotal=null,this.aggregationsPending=!0,this.isPaginated&&(this.resetPages(),this.emitPagesForWindow(this.renderStart,this.renderEnd))}handleViewSwitch(t){var r,e;const l=this.allViews[t];(null==l?void 0:l.view)&&(this.activeViewIdx=t,this.applyDefaultSort(null!==(e=null===(r=l.view)||void 0===r?void 0:r.defaultSort)&&void 0!==e?e:""),this.activeFilters=new Map,this.init())}toggleViewPopover(t){t.stopPropagation(),this.viewPopoverOpen?this.closeViewPopover():(this.viewPopoverOpen=!0,this.viewPopoverClickHandler=()=>this.closeViewPopover(),document.addEventListener("click",this.viewPopoverClickHandler))}closeViewPopover(){this.viewPopoverOpen=!1,this.viewPopoverClickHandler&&(document.removeEventListener("click",this.viewPopoverClickHandler),this.viewPopoverClickHandler=null)}renderToolbar(){var r;return t(M,{locale:this.locale,filterCount:this.activeFilters.size,actions:this.tableActions,views:this.allViews,activeViewIdx:this.activeViewIdx,viewPopoverOpen:this.viewPopoverOpen,createPickerOpen:this.createPickerOpen,createTypes:null===(r=this.item)||void 0===r?void 0:r.createTypes,cb:{onClearAllFilters:()=>this.clearAllFilters(),onViewSwitch:t=>this.handleViewSwitch(t),onToggleViewPopover:t=>this.toggleViewPopover(t),onCloseViewPopover:()=>this.closeViewPopover(),onToggleCreatePicker:()=>this.toggleCreatePicker(),onCreate:t=>{this.mrdAction.emit(this.buildActionDetail("create",t)),this.closeCreatePicker()},onAction:t=>this.mrdAction.emit(this.buildActionDetail(t))}})}renderFilterPopup(){if(!this.openFilterCol||!this.pendingFilter)return null;const r=this.columns.find((t=>this.colName(t)===this.openFilterCol));return r?t(S,{col:r,dataType:this.colDataType(r),openFilterCol:this.openFilterCol,pendingFilter:this.pendingFilter,popupPos:this.popupPos,sortField:this.sortField,sortDir:this.sortDir,locale:this.locale,cb:{onSetPending:(t,r)=>this.setPending(t,r),onReplacePending:t=>this.pendingFilter=t,onToggleValue:(t,r)=>this.togglePendingValue(t,r),onApplySort:t=>this.applySort(r,t),onApply:()=>this.applyFilter(),onClear:()=>this.clearFilter(),onClose:()=>this.closeFilterPopup()}}):null}renderFooter(r,e,l=!0){if(!this.isPaginated){const e=null!=r?r:0;return 0===e?null:t("div",{class:"mrd-table__footer"},e," ",s("table_of",this.locale)," ",e)}if(!this.loadedPages.has(0))return null;const i=null!=e?e:this.baseTotal,a=Math.min(Math.floor(this.scrollTop/this.rowHeight)+1,i),o=Math.min(Math.ceil((this.scrollTop+this.tableHeight)/this.rowHeight),i),d=l?String(i):"…";return t("div",{class:"mrd-table__footer"},a,"–",o," ",s("table_of",this.locale)," ",d)}renderCell(r,e){return t(k,{col:r,row:e,locale:this.locale,onDownload:t=>this.mrdDownload.emit(t),onOpenTextblock:t=>this.openTextblockModal(t),onOpenJson:t=>this.openJsonModal(t)})}renderTotalsRow(){return t(E,{columns:this.columns,aggregations:this.aggregations,locale:this.locale})}render(){var r,e,l;if(!(null===(r=this.columns)||void 0===r?void 0:r.length))return null;if(!this.isPaginated)return t(a,{class:{"mrd-table--resizing":null!==this.resizingCol}},this.renderToolbar(),t("div",{class:"mrd-table"},t("table",{class:"mrd-table__table",style:this.lockedTableStyle()},t("thead",null,t("tr",null,this.columns.map(((r,e)=>{var l;const i=this.colName(r),a=this.activeFilters.has(i),o=!f.has(this.colDataType(r)),s=["mrd-table__header",a?"mrd-table__header--filtered":"",o?"mrd-table__header--sortable":""].filter(Boolean).join(" ");return t("th",{class:s,style:this.colWidths[e]?{width:`${this.colWidths[e]}px`}:void 0,onClick:o?t=>this.handleFilterOpen(r,t):void 0},t("span",{class:"mrd-table__header-label"},null!==(l=r.label)&&void 0!==l?l:""),a&&t(x,null),this.renderColResizer(e))})))),t("tbody",null,null===(e=this.rows)||void 0===e?void 0:e.map(((r,e)=>t("tr",{class:"mrd-table__row mrd-table__row--clickable",style:{background:e%2==0?"":"var(--mrd-color-neutral-100)"},onClick:()=>this.mrdRowClick.emit({row:r})},this.columns.map((t=>this.renderCell(t,r))))))),this.renderTotalsRow()),(!this.rows||0===this.rows.length)&&t("p",{class:"mrd-table__empty"},s("no_results",this.locale))),this.renderFooter(null===(l=this.rows)||void 0===l?void 0:l.length),this.renderFilterPopup(),this.renderTextblockModal(),this.renderJsonModal());const i=function(t,r,e){let l=e;for(const[e,i]of t)i.length<r&&(l=Math.min(l,e*r+i.length));return l}(this.loadedPages,this.pageSize,this.baseTotal),o=Math.min(this.renderEnd,i-1),d=this.columns.length,n=this.renderStart*this.rowHeight,c=Math.max(0,(i-1-o)*this.rowHeight),m=this.lockedTableStyle(),h=[];for(let r=this.renderStart;r<=o;r++){const e=this.getRow(r);if(null===e){const e=Math.floor(r/this.pageSize);this.failedPages.has(e)?h.push(t("tr",{class:"mrd-table__row mrd-table__row--failed"},t("td",{class:"mrd-table__cell--failed",colSpan:d},t("button",{type:"button",class:"mrd-table__retry-button",onClick:()=>this.retryPage(e)},s("load_failed_retry",this.locale))))):h.push(t("tr",{class:"mrd-table__row mrd-table__row--loading"},t("td",{class:"mrd-table__cell--placeholder",colSpan:d},t("span",{class:"mrd-table__placeholder-bar"}))))}else h.push(t("tr",{class:"mrd-table__row mrd-table__row--clickable",style:{background:r%2==0?"":"var(--mrd-color-neutral-100)"},onClick:()=>this.mrdRowClick.emit({row:e,listContext:{index:r,sort:this.sortParam(),path:this.buildDataPath(),qs:this.buildQueryParams(0)}})},this.columns.map((t=>this.renderCell(t,e)))))}return t(a,{class:{"mrd-table--resizing":null!==this.resizingCol}},this.renderToolbar(),t("div",{class:"mrd-table__scroll",style:{height:`${this.tableHeight}px`},onScroll:this.handleScroll},t("table",{class:"mrd-table__table",style:m},t("thead",null,t("tr",null,this.columns.map(((r,e)=>{var l;const i=this.colName(r),a=this.sortField===i,o=this.activeFilters.has(i),s=!f.has(this.colDataType(r)),d=["mrd-table__header",s?"mrd-table__header--sortable":"",a?`mrd-table__header--sorted-${this.sortDir}`:"",o?"mrd-table__header--filtered":""].filter(Boolean).join(" ");return t("th",{class:d,style:this.colWidths[e]?{width:`${this.colWidths[e]}px`}:void 0,onClick:s?t=>this.handleFilterOpen(r,t):void 0},t("span",{class:"mrd-table__header-label"},null!==(l=r.label)&&void 0!==l?l:""),s&&a&&t("span",{class:"mrd-table__sort-icon","aria-hidden":"true"},"asc"===this.sortDir?"▲":"▼"),s&&!a&&t("span",{class:"mrd-table__sort-icon","aria-hidden":"true"},"⇅"),s&&o&&t(x,null),this.renderColResizer(e))})))),t("tbody",null,n>0&&t("tr",{class:"mrd-table__spacer",style:{height:`${n}px`}},t("td",{colSpan:d})),h,c>0&&t("tr",{class:"mrd-table__spacer",style:{height:`${c}px`}},t("td",{colSpan:d}))),this.renderTotalsRow())),0===i&&this.loadedPages.has(0)&&t("p",{class:"mrd-table__empty"},s("no_results",this.locale)),i>0&&this.renderFooter(void 0,i,this.isTotalKnown()),this.renderFilterPopup(),this.renderTextblockModal(),this.renderJsonModal())}renderTextblockModal(){return t(C,{text:this.textblockModal,locale:this.locale,onClose:()=>this.closeTextblockModal()})}renderJsonModal(){return t(z,{html:this.jsonModal,locale:this.locale,onClose:()=>this.closeJsonModal()})}get el(){return this}static get watchers(){return{totalElements:[{totalElementsChanged:0}],item:[{itemChanged:0}]}}static get style(){return'.sc-mrd-table-h{display:block;width:100%}.mrd-table.sc-mrd-table{overflow-x:auto}.mrd-table__scroll.sc-mrd-table{overflow-y:auto;overflow-x:auto;border:1px solid var(--mrd-border-color);border-radius:var(--mrd-border-radius);overflow-anchor:none}.mrd-table__table.sc-mrd-table{width:auto;min-width:100%;border-collapse:collapse;font-size:var(--mrd-font-size-sm);color:var(--mrd-color-neutral-900)}.mrd-table__scroll.sc-mrd-table .mrd-table__table.sc-mrd-table{min-width:max-content}.mrd-table__header.sc-mrd-table{position:sticky;top:0;z-index:1;background:var(--mrd-color-white);text-align:left;padding:var(--mrd-space-2) var(--mrd-space-4);border-bottom:2px solid var(--mrd-border-color);color:var(--mrd-color-neutral-600);font-weight:var(--mrd-font-weight-medium);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-size:var(--mrd-font-size-xs);text-transform:uppercase;letter-spacing:0.04em}.mrd-table__header--sortable.sc-mrd-table{cursor:pointer;user-select:none}.mrd-table__header--sortable.sc-mrd-table:hover{background:var(--mrd-color-neutral-50);color:var(--mrd-color-neutral-800)}.mrd-table__header--sorted-asc.sc-mrd-table,.mrd-table__header--sorted-desc.sc-mrd-table{color:var(--mrd-color-primary);border-bottom-color:var(--mrd-color-primary)}.mrd-table__header--filtered.sc-mrd-table{color:var(--mrd-color-primary);border-bottom-color:var(--mrd-color-primary)}.mrd-table__header-label.sc-mrd-table{margin-right:var(--mrd-space-1)}.mrd-table__col-resizer.sc-mrd-table{position:absolute;top:0;right:0;width:9px;height:100%;cursor:col-resize;touch-action:none;user-select:none}.mrd-table__col-resizer.sc-mrd-table::after{content:"";position:absolute;top:25%;right:4px;width:1px;height:50%;background:var(--mrd-border-color)}.mrd-table__col-resizer.sc-mrd-table:hover::after{width:2px;right:3px;background:var(--mrd-color-primary)}.mrd-table__col-resizer--active.sc-mrd-table::after{width:2px;right:3px;height:100%;top:0;background:var(--mrd-color-primary)}.mrd-table--resizing.sc-mrd-table{cursor:col-resize;user-select:none}.mrd-table__sort-icon.sc-mrd-table{font-size:0.85rem;opacity:0.4;vertical-align:middle}.mrd-table__header--sorted-asc.sc-mrd-table .mrd-table__sort-icon.sc-mrd-table,.mrd-table__header--sorted-desc.sc-mrd-table .mrd-table__sort-icon.sc-mrd-table{opacity:1;color:var(--mrd-color-primary)}.mrd-table__filter-icon.sc-mrd-table{display:inline-flex;align-items:center;vertical-align:middle;margin-left:var(--mrd-space-1);color:var(--mrd-color-primary)}.mrd-table__row.sc-mrd-table{border-bottom:1px solid var(--mrd-border-color)}.mrd-table__row.sc-mrd-table:hover{background:var(--mrd-color-neutral-200) !important}.mrd-table__row--clickable.sc-mrd-table{cursor:pointer}.mrd-table__row--loading.sc-mrd-table{background:transparent}.mrd-table__row--failed.sc-mrd-table{background:transparent}.mrd-table__spacer.sc-mrd-table{border:none}.mrd-table__spacer.sc-mrd-table td.sc-mrd-table{padding:0;border:none}.mrd-table__cell.sc-mrd-table{padding:var(--mrd-space-2) var(--mrd-space-4);vertical-align:top;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.mrd-table__cell--numeric.sc-mrd-table{text-align:right;font-variant-numeric:tabular-nums}.mrd-table__cell--placeholder.sc-mrd-table{padding:var(--mrd-space-2) var(--mrd-space-4);border-bottom:1px solid var(--mrd-border-color)}.mrd-table__cell--failed.sc-mrd-table{padding:var(--mrd-space-2) var(--mrd-space-4);border-bottom:1px solid var(--mrd-border-color)}.mrd-table__placeholder-bar.sc-mrd-table{display:block;height:0.75rem;width:55%;border-radius:var(--mrd-border-radius-sm);background:linear-gradient(90deg, var(--mrd-color-neutral-200) 25%, var(--mrd-color-neutral-100) 50%, var(--mrd-color-neutral-200) 75%);background-size:200% 100%;animation:mrd-shimmer 1.4s ease infinite}.mrd-table__retry-button.sc-mrd-table{border:none;background:none;padding:0;color:var(--mrd-color-danger);font-size:inherit;cursor:pointer;text-decoration:underline}.mrd-table__toolbar.sc-mrd-table{display:flex;align-items:center;justify-content:space-between;padding-bottom:var(--mrd-space-2)}.mrd-table__toolbar-left.sc-mrd-table,.mrd-table__toolbar-right.sc-mrd-table{display:flex;gap:var(--mrd-space-2);align-items:center}.mrd-table__toolbar-center.sc-mrd-table{flex:1;display:flex;justify-content:center;align-items:center;gap:var(--mrd-space-1)}.mrd-table__view-switcher.sc-mrd-table{display:flex;align-items:center;gap:var(--mrd-space-1)}.mrd-table__view-arrow.sc-mrd-table{background:none;border:none;cursor:pointer;padding:0 var(--mrd-space-1);color:var(--mrd-color-neutral-500);font-size:var(--mrd-font-size-xs);line-height:1}.mrd-table__view-arrow.sc-mrd-table:hover{color:var(--mrd-color-neutral-800)}.mrd-table__view-title-wrap.sc-mrd-table{position:relative}.mrd-table__view-title.sc-mrd-table{font-size:var(--mrd-font-size-sm);font-weight:600;color:var(--mrd-color-neutral-800);font-family:var(--mrd-font-family);background:none;border:none;outline:none;cursor:pointer;padding:0 var(--mrd-space-1);max-width:220px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.mrd-table__view-title.sc-mrd-table:hover{color:var(--mrd-color-primary)}.mrd-table__view-popover.sc-mrd-table{position:absolute;top:calc(100% + var(--mrd-space-1));left:50%;transform:translateX(-50%);background:var(--mrd-color-white);border:1px solid var(--mrd-color-neutral-200);border-radius:var(--mrd-radius-md);box-shadow:var(--mrd-shadow-md);z-index:100;min-width:160px;padding:var(--mrd-space-1) 0}.mrd-table__view-popover-item.sc-mrd-table{display:block;width:100%;text-align:left;background:none;border:none;cursor:pointer;padding:var(--mrd-space-2) var(--mrd-space-3);font-size:var(--mrd-font-size-sm);font-family:var(--mrd-font-family);color:var(--mrd-color-neutral-700);white-space:nowrap}.mrd-table__view-popover-item.sc-mrd-table:hover{background:var(--mrd-color-neutral-50)}.mrd-table__view-popover-item--active.sc-mrd-table{font-weight:600;color:var(--mrd-color-primary)}.mrd-table__action.sc-mrd-table{position:relative;display:inline-flex;align-items:center;justify-content:center;width:2rem;height:2rem;padding:0;background:transparent;border:1px solid transparent;border-radius:var(--mrd-border-radius);cursor:pointer;color:var(--mrd-color-neutral-400);transition:background-color 0.15s, border-color 0.15s, color 0.15s}.mrd-table__action.sc-mrd-table:hover{background-color:var(--mrd-color-neutral-100);border-color:var(--mrd-color-neutral-300);color:var(--mrd-color-neutral-700)}.mrd-table__action.sc-mrd-table:hover .mrd-table__action-tooltip.sc-mrd-table{display:block}.mrd-table__action.sc-mrd-table:disabled{opacity:0.4;cursor:not-allowed}.mrd-table__action--primary.sc-mrd-table{color:var(--mrd-color-neutral-500)}.mrd-table__action--primary.sc-mrd-table:hover{background:var(--mrd-color-primary);border-color:var(--mrd-color-primary);color:var(--mrd-color-white)}.mrd-table__action--danger.sc-mrd-table{color:var(--mrd-color-error)}.mrd-table__action--danger.sc-mrd-table:hover{background-color:var(--mrd-color-error-light, #fef2f2);border-color:var(--mrd-color-error)}.mrd-table__action-icon.sc-mrd-table{width:1.25rem;height:1.25rem;pointer-events:none;fill:currentColor}.mrd-table__action-tooltip.sc-mrd-table{display:none;position:absolute;bottom:calc(100% + 6px);right:0;padding:var(--mrd-space-1) var(--mrd-space-2);font-size:var(--mrd-font-size-xs);white-space:nowrap;background:var(--mrd-color-tooltip, #fffce1);color:var(--mrd-color-neutral-900);border:1px solid var(--mrd-border-color);border-radius:var(--mrd-border-radius-sm, var(--mrd-border-radius));pointer-events:none;z-index:10}.mrd-table__create-picker-wrap.sc-mrd-table{position:relative}.mrd-table__create-picker.sc-mrd-table{position:absolute;right:0;top:calc(100% + 4px);background:var(--mrd-color-white, #fff);border:1px solid var(--mrd-border-color);border-radius:var(--mrd-border-radius);box-shadow:var(--mrd-shadow-md, 0 4px 12px rgba(0, 0, 0, 0.12));z-index:10;min-width:10rem;padding:var(--mrd-space-1) 0}.mrd-table__create-picker-item.sc-mrd-table{display:block;width:100%;text-align:left;padding:var(--mrd-space-2) var(--mrd-space-3);background:none;border:none;cursor:pointer;font-size:var(--mrd-font-size-sm);font-family:var(--mrd-font-family);color:var(--mrd-color-neutral-800)}.mrd-table__create-picker-item.sc-mrd-table:hover{background:var(--mrd-color-neutral-50);color:var(--mrd-color-neutral-900)}.mrd-table__filter-clear.sc-mrd-table{width:auto;gap:var(--mrd-space-1);padding:0 var(--mrd-space-2);color:var(--mrd-color-primary);border-color:var(--mrd-color-primary)}.mrd-table__filter-clear.sc-mrd-table:hover{color:var(--mrd-color-primary);border-color:var(--mrd-color-primary)}.mrd-table__filter-clear-label.sc-mrd-table{font-size:var(--mrd-font-size-sm);white-space:nowrap}.mrd-table__filter-popup.sc-mrd-table{position:fixed;width:280px;background:var(--mrd-color-white);border:1px solid var(--mrd-border-color);border-radius:var(--mrd-border-radius);box-shadow:var(--mrd-shadow-md, 0 4px 12px rgba(0, 0, 0, 0.12));z-index:var(--mrd-z-dropdown, 200);font-size:var(--mrd-font-size-sm)}.mrd-table__filter-popup-header.sc-mrd-table{display:flex;align-items:center;justify-content:space-between;padding:var(--mrd-space-2) var(--mrd-space-3);border-bottom:1px solid var(--mrd-border-color)}.mrd-table__filter-popup-title.sc-mrd-table{font-weight:var(--mrd-font-weight-medium);color:var(--mrd-color-neutral-800);font-size:var(--mrd-font-size-sm)}.mrd-table__filter-close.sc-mrd-table{background:transparent;border:none;cursor:pointer;color:var(--mrd-color-neutral-500);font-size:0.9rem;padding:2px 4px;border-radius:3px;line-height:1}.mrd-table__filter-close.sc-mrd-table:hover{background:var(--mrd-color-neutral-100);color:var(--mrd-color-neutral-800)}.mrd-table__filter-section.sc-mrd-table{padding:var(--mrd-space-2) var(--mrd-space-3)}.mrd-table__filter-section-label.sc-mrd-table{font-size:var(--mrd-font-size-xs);font-weight:var(--mrd-font-weight-medium);text-transform:uppercase;letter-spacing:0.04em;color:var(--mrd-color-neutral-500);margin-bottom:var(--mrd-space-2)}.mrd-table__filter-sort-buttons.sc-mrd-table{display:flex;gap:var(--mrd-space-2)}.mrd-table__filter-sort-btn.sc-mrd-table{flex:1;padding:var(--mrd-space-1) var(--mrd-space-2);background:transparent;border:1px solid var(--mrd-border-color);border-radius:var(--mrd-border-radius);cursor:pointer;font-size:var(--mrd-font-size-xs);color:var(--mrd-color-neutral-700)}.mrd-table__filter-sort-btn.sc-mrd-table:hover{background:var(--mrd-color-neutral-100)}.mrd-table__filter-sort-btn--active.sc-mrd-table{background:var(--mrd-color-primary);border-color:var(--mrd-color-primary);color:var(--mrd-color-white)}.mrd-table__filter-divider.sc-mrd-table{height:1px;background:var(--mrd-border-color);margin:0}.mrd-table__filter-editor.sc-mrd-table{display:flex;flex-direction:column;gap:var(--mrd-space-2)}.mrd-table__filter-select.sc-mrd-table,.mrd-table__filter-input.sc-mrd-table{width:100%;padding:var(--mrd-space-1) var(--mrd-space-2);border:1px solid var(--mrd-border-color);border-radius:var(--mrd-border-radius);font-size:var(--mrd-font-size-sm);color:var(--mrd-color-neutral-900);background:var(--mrd-color-white);box-sizing:border-box}.mrd-table__filter-select.sc-mrd-table:focus,.mrd-table__filter-input.sc-mrd-table:focus{outline:none;border-color:var(--mrd-color-primary);box-shadow:0 0 0 2px rgba(0, 0, 0, 0.06)}.mrd-table__filter-range.sc-mrd-table{display:flex;align-items:center;gap:var(--mrd-space-1)}.mrd-table__filter-range.sc-mrd-table .mrd-table__filter-input.sc-mrd-table{flex:1;min-width:0}.mrd-table__filter-range--stacked.sc-mrd-table{flex-direction:column;align-items:stretch;gap:var(--mrd-space-2)}.mrd-table__filter-range-sep.sc-mrd-table{color:var(--mrd-color-neutral-400);flex-shrink:0}.mrd-table__filter-range-label.sc-mrd-table{font-size:var(--mrd-font-size-xs);color:var(--mrd-color-neutral-500);margin-bottom:2px}.mrd-table__filter-radio-group.sc-mrd-table{display:flex;flex-direction:column;gap:var(--mrd-space-1)}.mrd-table__filter-radio-group--inline.sc-mrd-table{flex-direction:row;gap:var(--mrd-space-3)}.mrd-table__filter-radio-label.sc-mrd-table{display:flex;align-items:center;gap:var(--mrd-space-1);cursor:pointer;font-size:var(--mrd-font-size-sm);color:var(--mrd-color-neutral-800)}.mrd-table__filter-list.sc-mrd-table{display:flex;flex-direction:column;gap:var(--mrd-space-1);max-height:180px;overflow-y:auto}.mrd-table__filter-list-controls.sc-mrd-table{display:flex;gap:var(--mrd-space-2);margin-bottom:var(--mrd-space-1)}.mrd-table__filter-list-btn.sc-mrd-table{font-size:var(--mrd-font-size-xs);color:var(--mrd-color-primary);background:transparent;border:none;cursor:pointer;padding:0;text-decoration:underline}.mrd-table__filter-checkbox-label.sc-mrd-table{display:flex;align-items:center;gap:var(--mrd-space-1);cursor:pointer;font-size:var(--mrd-font-size-sm);color:var(--mrd-color-neutral-800)}.mrd-table__filter-no-support.sc-mrd-table{font-size:var(--mrd-font-size-sm);color:var(--mrd-color-neutral-500);margin:0;font-style:italic}.mrd-table__filter-popup-footer.sc-mrd-table{display:flex;justify-content:flex-end;gap:var(--mrd-space-2);padding:var(--mrd-space-2) var(--mrd-space-3);border-top:1px solid var(--mrd-border-color)}.mrd-table__filter-btn.sc-mrd-table{padding:var(--mrd-space-1) var(--mrd-space-3);border-radius:var(--mrd-border-radius);border:1px solid var(--mrd-border-color);font-size:var(--mrd-font-size-sm);cursor:pointer}.mrd-table__filter-btn--clear.sc-mrd-table{background:transparent;color:var(--mrd-color-neutral-600)}.mrd-table__filter-btn--clear.sc-mrd-table:hover{background:var(--mrd-color-neutral-100)}.mrd-table__filter-btn--apply.sc-mrd-table{background:var(--mrd-color-primary);border-color:var(--mrd-color-primary);color:var(--mrd-color-white)}.mrd-table__filter-btn--apply.sc-mrd-table:hover{background:var(--mrd-color-primary-dark, var(--mrd-color-primary));border-color:var(--mrd-color-primary-dark, var(--mrd-color-primary))}.mrd-table__totals-row.sc-mrd-table{border-top:2px solid var(--mrd-border-color)}.mrd-table__totals-cell.sc-mrd-table{position:sticky;bottom:0;z-index:2;padding:var(--mrd-space-2) var(--mrd-space-4);background:var(--mrd-color-white);font-weight:var(--mrd-font-weight-medium);font-variant-numeric:tabular-nums;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;border-top:2px solid var(--mrd-border-color)}.mrd-table__totals-cell--numeric.sc-mrd-table{text-align:right}.mrd-table__footer.sc-mrd-table{padding:var(--mrd-space-1) var(--mrd-space-2);font-size:var(--mrd-font-size-xs);color:var(--mrd-color-neutral-500);text-align:right}.mrd-table__empty.sc-mrd-table{padding:var(--mrd-space-4) var(--mrd-space-3);color:var(--mrd-color-neutral-500);font-size:var(--mrd-font-size-sm);text-align:center;margin:0}.mrd-table__file-btn.sc-mrd-table{display:inline-flex;align-items:center;gap:var(--mrd-space-1);background:none;border:none;padding:0;cursor:pointer;color:var(--mrd-color-primary);font-size:var(--mrd-font-size-sm);font-family:inherit;max-width:100%;overflow:hidden}.mrd-table__file-btn.sc-mrd-table:hover{text-decoration:underline;color:var(--mrd-color-primary-dark)}.mrd-table__file-icon.sc-mrd-table{flex-shrink:0;width:1rem;height:1rem}.mrd-table__textblock-btn.sc-mrd-table{display:inline;background:none;border:none;padding:0 0 0 var(--mrd-space-1);cursor:pointer;color:var(--mrd-color-primary);font-size:var(--mrd-font-size-sm);font-family:inherit;line-height:inherit;vertical-align:middle}.mrd-table__textblock-btn.sc-mrd-table:hover{color:var(--mrd-color-primary-dark)}.mrd-table__modal-backdrop.sc-mrd-table{position:fixed;inset:0;background:rgba(0, 0, 0, 0.4);z-index:var(--mrd-z-modal, 300);display:flex;align-items:center;justify-content:center}.mrd-table__modal.sc-mrd-table{background:#fff;border-radius:var(--mrd-radius-md, 0.5rem);padding:var(--mrd-space-6);max-width:min(600px, 90vw);max-height:70vh;overflow-y:auto;position:relative;box-shadow:var(--mrd-shadow-lg)}.mrd-table__modal-close.sc-mrd-table{position:absolute;top:var(--mrd-space-3);right:var(--mrd-space-3);background:none;border:none;cursor:pointer;font-size:1.25rem;line-height:1;color:var(--mrd-color-text-muted, #6b7280);padding:0}.mrd-table__modal-close.sc-mrd-table:hover{color:var(--mrd-color-text, #111827)}.mrd-table__modal-text.sc-mrd-table{margin:0;padding-right:var(--mrd-space-6);white-space:pre-wrap;word-break:break-word;font-size:var(--mrd-font-size-sm);line-height:1.6}.mrd-table__json-preview.sc-mrd-table{font-family:var(--mrd-font-family-mono);font-size:var(--mrd-font-size-xs);overflow:hidden;white-space:nowrap;text-overflow:ellipsis;display:inline-block;max-width:calc(100% - 1.5rem);vertical-align:middle}.mrd-table__modal-json.sc-mrd-table{margin:0;padding-right:var(--mrd-space-6);font-family:var(--mrd-font-family-mono);font-size:var(--mrd-font-size-xs);white-space:pre-wrap;word-break:break-word;line-height:1.6;background:none;border:none}@keyframes mrd-shimmer{0%{background-position:200% 0}100%{background-position:-200% 0}}'}},[2,"mrd-table",{item:[16],parentId:[1,"parent-id"],rows:[16],locale:[1],totalElements:[2,"total-elements"],pageSize:[2,"page-size"],rowHeight:[2,"row-height"],tableHeight:[2,"table-height"],requestTimeoutMs:[2,"request-timeout-ms"],activeViewIdx:[32],loadedPages:[32],requestedPages:[32],failedPages:[32],renderStart:[32],renderEnd:[32],colWidths:[32],resizingCol:[32],sortField:[32],sortDir:[32],activeFilters:[32],openFilterCol:[32],pendingFilter:[32],popupPos:[32],createPickerOpen:[32],viewPopoverOpen:[32],scrollTop:[32],textblockModal:[32],jsonModal:[32],aggregations:[32],aggregationsTotal:[32],minKnownTotal:[32],init:[64],setPage:[64],setAggregations:[64]},void 0,{totalElements:[{totalElementsChanged:0}],item:[{itemChanged:0}]}]);function I(){"undefined"!=typeof customElements&&["mrd-table"].forEach((t=>{"mrd-table"===t&&(customElements.get(o(t))||customElements.define(o(t),P))}))}export{P as M,I as d}
|
|
@@ -6639,6 +6639,8 @@ const MrdTable = class {
|
|
|
6639
6639
|
this.keydownHandler = null;
|
|
6640
6640
|
this.createPickerClickHandler = null;
|
|
6641
6641
|
this.viewPopoverClickHandler = null;
|
|
6642
|
+
/** Watches the host for gaining a box (e.g. its tab pane being shown) — see componentDidLoad. */
|
|
6643
|
+
this.resizeObserver = null;
|
|
6642
6644
|
/** Guards against scheduling more than one column-width measurement per freeze. */
|
|
6643
6645
|
this.colWidthMeasureScheduled = false;
|
|
6644
6646
|
/** Drag origin of the running column resize (null = no drag in progress). */
|
|
@@ -6743,6 +6745,14 @@ const MrdTable = class {
|
|
|
6743
6745
|
}
|
|
6744
6746
|
componentDidLoad() {
|
|
6745
6747
|
this.staleCheckTimer = setInterval(() => this.checkStalePages(), STALE_CHECK_INTERVAL_MS);
|
|
6748
|
+
// A table inside a hidden tab pane renders and loads page 0 without ever having a box, so
|
|
6749
|
+
// the width freeze cannot measure anything. ResizeObserver fires the moment the pane is
|
|
6750
|
+
// shown (the host gains a box) — that is when the freeze gets its chance. componentDidRender
|
|
6751
|
+
// is no help there: showing a sibling tab does not re-render this component.
|
|
6752
|
+
if (typeof ResizeObserver !== 'undefined') {
|
|
6753
|
+
this.resizeObserver = new ResizeObserver(() => this.freezeColWidths());
|
|
6754
|
+
this.resizeObserver.observe(this.el);
|
|
6755
|
+
}
|
|
6746
6756
|
}
|
|
6747
6757
|
// ── Helpers ────────────────────────────────────────────────────────────────
|
|
6748
6758
|
applyDefaultSort(defaultSort) {
|
|
@@ -6846,6 +6856,10 @@ const MrdTable = class {
|
|
|
6846
6856
|
}
|
|
6847
6857
|
// ── Lifecycle ──────────────────────────────────────────────────────────────
|
|
6848
6858
|
disconnectedCallback() {
|
|
6859
|
+
if (this.resizeObserver) {
|
|
6860
|
+
this.resizeObserver.disconnect();
|
|
6861
|
+
this.resizeObserver = null;
|
|
6862
|
+
}
|
|
6849
6863
|
if (this.staleCheckTimer !== null) {
|
|
6850
6864
|
clearInterval(this.staleCheckTimer);
|
|
6851
6865
|
this.staleCheckTimer = null;
|
|
@@ -6868,28 +6882,35 @@ const MrdTable = class {
|
|
|
6868
6882
|
}
|
|
6869
6883
|
}
|
|
6870
6884
|
componentDidRender() {
|
|
6871
|
-
|
|
6872
|
-
|
|
6873
|
-
|
|
6874
|
-
|
|
6875
|
-
|
|
6876
|
-
|
|
6877
|
-
|
|
6878
|
-
|
|
6879
|
-
|
|
6880
|
-
|
|
6881
|
-
|
|
6882
|
-
|
|
6883
|
-
|
|
6884
|
-
|
|
6885
|
-
|
|
6886
|
-
|
|
6887
|
-
|
|
6888
|
-
|
|
6889
|
-
|
|
6890
|
-
|
|
6891
|
-
|
|
6892
|
-
|
|
6885
|
+
this.freezeColWidths();
|
|
6886
|
+
}
|
|
6887
|
+
/** Freeze the column widths once the first data page has rendered.
|
|
6888
|
+
*
|
|
6889
|
+
* The measurement reads layout and writes the colWidths @State, which would trigger a
|
|
6890
|
+
* re-render *during* the render cycle if done synchronously from componentDidRender. It is
|
|
6891
|
+
* deferred to a writeTask so the state mutation happens outside the render pass (avoids the
|
|
6892
|
+
* Stencil "state/prop changed during rendering" warning and potential loops).
|
|
6893
|
+
*
|
|
6894
|
+
* NB: the freeze must not depend on the totalElements prop — hosts may omit it and rely on
|
|
6895
|
+
* minKnownTotal, in which case the widths would never be locked and every incoming page
|
|
6896
|
+
* would re-flow all columns. */
|
|
6897
|
+
freezeColWidths() {
|
|
6898
|
+
if (this.colWidths.length !== 0 || this.colWidthMeasureScheduled || this.loadedPages.size === 0)
|
|
6899
|
+
return;
|
|
6900
|
+
this.colWidthMeasureScheduled = true;
|
|
6901
|
+
writeTask(() => {
|
|
6902
|
+
var _a;
|
|
6903
|
+
this.colWidthMeasureScheduled = false;
|
|
6904
|
+
// Re-check: state may have changed (e.g. a reset) between scheduling and running.
|
|
6905
|
+
if (this.colWidths.length !== 0)
|
|
6906
|
+
return;
|
|
6907
|
+
const measured = (_a = this.measureContentWidths()) !== null && _a !== void 0 ? _a : this.measureColWidths();
|
|
6908
|
+
// A table inside a hidden tab pane (a tab page that is loaded but not shown) has no
|
|
6909
|
+
// layout at all, so every measurement comes back 0. Locking those would pin every
|
|
6910
|
+
// column at MIN_COL_WIDTH for good; wait for the ResizeObserver to report a real box.
|
|
6911
|
+
if (measured && measured.some(w => w > 0))
|
|
6912
|
+
this.colWidths = measured;
|
|
6913
|
+
});
|
|
6893
6914
|
}
|
|
6894
6915
|
// ── Column resizing (drag the header border, Excel-style) ──────────────────
|
|
6895
6916
|
/** Current rendered header widths, or null when they can't be trusted (header not laid out yet). */
|
|
@@ -6899,6 +6920,49 @@ const MrdTable = class {
|
|
|
6899
6920
|
return null;
|
|
6900
6921
|
return Array.from(ths).map(th => Math.round(th.getBoundingClientRect().width));
|
|
6901
6922
|
}
|
|
6923
|
+
/** Width one cell needs to show its content in full, borders included.
|
|
6924
|
+
* Read from scrollWidth rather than the laid-out box: cells clip with `overflow: hidden`,
|
|
6925
|
+
* so a squeezed cell reports the width it *was given*, not the width it needs. */
|
|
6926
|
+
neededWidth(cell) {
|
|
6927
|
+
// The layout metrics are absent in the mock DOM the specs run on; treat them as 0
|
|
6928
|
+
// rather than letting a NaN poison the Math.max chain the callers build.
|
|
6929
|
+
const px = (v) => (typeof v === 'number' && Number.isFinite(v) ? v : 0);
|
|
6930
|
+
const clientWidth = px(cell.clientWidth);
|
|
6931
|
+
const scrollWidth = px(cell.scrollWidth);
|
|
6932
|
+
const paddingRight = px(parseFloat(getComputedStyle(cell).paddingRight || '0'));
|
|
6933
|
+
const borders = Math.max(0, px(cell.offsetWidth) - clientWidth);
|
|
6934
|
+
// scrollWidth drops the right padding once the content overflows the clipped box;
|
|
6935
|
+
// when it fits, clientWidth is already the full padded box.
|
|
6936
|
+
const content = scrollWidth > clientWidth ? scrollWidth + paddingRight : clientWidth;
|
|
6937
|
+
return Math.ceil(content + borders);
|
|
6938
|
+
}
|
|
6939
|
+
/** Width each column needs for its header and its rendered page-0 cells — what the columns
|
|
6940
|
+
* are locked to, so they never end up narrower than their content.
|
|
6941
|
+
*
|
|
6942
|
+
* Deliberately not the laid-out widths: with many columns the browser squeezes them to fit
|
|
6943
|
+
* the container instead of overflowing (the cells clip, so they no longer resist), which
|
|
6944
|
+
* cost the horizontal scrollbar. Locking the needed widths makes the summed table width
|
|
6945
|
+
* exceed the container again, and `.mrd-table__scroll` scrolls. Capped per column at
|
|
6946
|
+
* MAX_AUTOFIT_WIDTH so one outlier value can't blow up the layout — same cap as auto-fit. */
|
|
6947
|
+
measureContentWidths() {
|
|
6948
|
+
const ths = this.el.querySelectorAll('.mrd-table__header');
|
|
6949
|
+
if (ths.length === 0 || ths.length !== this.columns.length)
|
|
6950
|
+
return null;
|
|
6951
|
+
const needed = Array.from(ths).map((th, idx) => {
|
|
6952
|
+
let widest = this.neededWidth(th);
|
|
6953
|
+
// .mrd-table__cell only matches real data cells — the shimmer/retry rows render a single
|
|
6954
|
+
// colSpan cell (without that class) which would measure as the full table width.
|
|
6955
|
+
this.el
|
|
6956
|
+
.querySelectorAll(`.mrd-table__cell:nth-child(${idx + 1})`)
|
|
6957
|
+
.forEach(cell => { widest = Math.max(widest, this.neededWidth(cell)); });
|
|
6958
|
+
return widest;
|
|
6959
|
+
});
|
|
6960
|
+
// Nothing has a box: the table is in a hidden tab pane. Report "cannot measure" rather
|
|
6961
|
+
// than clamping a row of zeroes up to MIN_COL_WIDTH, which would look like a real result.
|
|
6962
|
+
if (needed.every(w => w <= 0))
|
|
6963
|
+
return null;
|
|
6964
|
+
return needed.map(w => Math.min(Math.max(w, MIN_COL_WIDTH), MAX_AUTOFIT_WIDTH));
|
|
6965
|
+
}
|
|
6902
6966
|
/** Re-reads the rendered header widths into colWidths so a drag starts from what is
|
|
6903
6967
|
* actually on screen — and locks the columns if they weren't locked yet.
|
|
6904
6968
|
*
|
|
@@ -6959,12 +7023,7 @@ const MrdTable = class {
|
|
|
6959
7023
|
// colSpan cell (without that class) which would otherwise measure as the full table width.
|
|
6960
7024
|
const cells = this.el.querySelectorAll(`.mrd-table__header:nth-child(${idx + 1}), .mrd-table__cell:nth-child(${idx + 1})`);
|
|
6961
7025
|
let widest = 0;
|
|
6962
|
-
cells.forEach(cell => {
|
|
6963
|
-
// scrollWidth is the untruncated content width; cells clip with overflow: hidden.
|
|
6964
|
-
const style = getComputedStyle(cell);
|
|
6965
|
-
const padding = parseFloat(style.paddingLeft || '0') + parseFloat(style.paddingRight || '0');
|
|
6966
|
-
widest = Math.max(widest, cell.scrollWidth + padding);
|
|
6967
|
-
});
|
|
7026
|
+
cells.forEach(cell => { widest = Math.max(widest, this.neededWidth(cell)); });
|
|
6968
7027
|
if (widest > 0)
|
|
6969
7028
|
this.setColWidth(idx, Math.min(widest, MAX_AUTOFIT_WIDTH));
|
|
6970
7029
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cell-renderer-B8u5BCK-.js","sources":["src/utils/cell-renderer.ts"],"sourcesContent":["import { formatNumber, formatPercentage, formatCurrency, formatDate, formatDateTime, formatTime } from './format';\nimport { ClientLayoutItem, ClientLayoutItemType } from '../types/client-layout';\n\n/** TableColumn is an alias for ClientLayoutItem — used for table column definitions. */\nexport type TableColumn = ClientLayoutItem;\n\n/** One entry in the alternativeViews array for mrd-table. */\nexport interface AlternativeView {\n /** Named view identifier, emitted in mrdSwitchView. */\n name: string;\n /** Display text; falls back to name when absent. */\n label?: string;\n /** Optional class override (TypeFQN); emitted in mrdSwitchView. */\n class?: string;\n}\n\n/** Defines a toolbar action button for mrd-table. */\nexport interface TableAction {\n /** Machine-readable identifier, e.g. 'create' | 'export'. Emitted in mrdAction event. */\n action: string;\n /** Tooltip text (and label fallback when no icon is provided). */\n label: string;\n /** SVG sprite href, e.g. \"assets/sprites.svg#icon-plus\". Optional. */\n icon?: string;\n /** Button style variant. Defaults to 'secondary'. */\n variant?: 'primary' | 'secondary' | 'danger';\n disabled?: boolean;\n basicType?: string;\n}\n\n/** Represents an active filter on a single column. */\nexport interface ColumnFilter {\n field: string;\n dataType: string;\n /** Text operator — only relevant for text-like data types. */\n operator?: 'contains' | 'startsWith' | 'equals' | 'isEmpty' | 'isNotEmpty';\n /** Single value (boolean, exact text/number/date). */\n value?: string | number | boolean | null;\n /** Range start (≥) — future API support. */\n from?: string | number | null;\n /** Range end (≤) — future API support. */\n to?: string | number | null;\n /** LIST: keys of selected items to include. */\n values?: string[];\n}\n\nexport class CellRenderer {\n static render(column: TableColumn, row: Record<string, any>, locale: string): string {\n if (column.type === ClientLayoutItemType.RELATION) {\n const name = column.name ?? '';\n const link = row?._links?.[name];\n if (!link) return '';\n if (Array.isArray(link)) return link.map((l: any) => l.name ?? '').filter(Boolean).join(', ');\n return link.name ?? '';\n }\n\n if (column.type !== ClientLayoutItemType.FIELD) return '';\n\n const name = column.name ?? '';\n const dataType = column.dataType;\n const listItems = column.listItems;\n let raw = row?.[name];\n // History-enabled fields are stored as { current, history: [...] } — render\n // the current value, same as mrd-layout-section's field rendering.\n if (column.historyEnabled && raw != null && typeof raw === 'object' && !Array.isArray(raw) && 'current' in raw) {\n raw = (raw as any).current;\n }\n if (raw == null || raw === '') return '';\n\n const values = Array.isArray(raw) ? raw : [raw];\n return values\n .map(v => CellRenderer.renderValue(dataType ?? 'TEXT', v, listItems ?? [], locale))\n .filter(s => s !== '')\n .join(', ');\n }\n\n static renderValue(\n dataType: string,\n value: any,\n listItems: Array<{ key: string; label: string }>,\n locale: string,\n ): string {\n switch (dataType) {\n case 'INTEGER':\n return formatNumber(Number(value), locale, { maximumFractionDigits: 0 });\n case 'DECIMAL':\n return formatNumber(Number(value), locale);\n case 'PERCENTAGE':\n return formatPercentage(Number(value), locale);\n case 'CURRENCY': {\n const { amount, currency } = typeof value === 'object' && value !== null\n ? value\n : { amount: value, currency: '' };\n return currency\n ? formatCurrency(Number(amount), currency, locale)\n : formatNumber(Number(amount), locale);\n }\n case 'DATE':\n return formatDate(value, locale);\n case 'DATETIME':\n return formatDateTime(value, locale);\n case 'TIME':\n return formatTime(value, locale);\n case 'BOOLEAN':\n return value ? '✓' : '';\n case 'FILE':\n case 'IMAGE':\n return typeof value === 'object' && value !== null ? (value.fileName ?? '') : '';\n case 'LIST': {\n const item = listItems.find(li => li.key === String(value));\n return item?.label ?? String(value);\n }\n case 'TEXTBLOCK': {\n const stripped = String(value).replace(/<[^>]*>/g, '');\n const txt = document.createElement('textarea');\n txt.innerHTML = stripped;\n return txt.value.trim();\n }\n case 'LONGTEXT':\n return String(value).replace(/[\\r\\n]+/g, ' ').trim();\n case 'JSON': {\n const str = typeof value === 'object' ? JSON.stringify(value) : String(value);\n return str.replace(/[\\r\\n]+/g, ' ').trim();\n }\n case 'SECRET':\n return value ? '••••••••' : '';\n default:\n return String(value);\n }\n }\n\n /**\n * Returns syntax-highlighted JSON as an HTML string with inline styles.\n * compact=true → single line (no indentation); compact=false → pretty-printed.\n */\n static formatJson(value: any, compact = false): string {\n try {\n const parsed = typeof value === 'string' ? JSON.parse(value) : value;\n const json = compact ? JSON.stringify(parsed) : JSON.stringify(parsed, null, 2);\n return json.replace(\n /(\"(\\\\u[a-zA-Z0-9]{4}|\\\\[^u]|[^\\\\\"])*\"(\\s*:)?|\\b(true|false|null)\\b|-?\\d+(?:\\.\\d*)?(?:[eE][+\\-]?\\d+)?)/g,\n match => {\n let style = 'color:#2aa198';\n if (/^\"/.test(match)) {\n style = /:$/.test(match) ? 'color:#881391' : 'color:#268bd2';\n } else if (/true|false/.test(match)) {\n style = 'color:#b58900';\n } else if (/null/.test(match)) {\n style = 'color:#dc322f';\n }\n return `<span style=\"${style}\">${match}</span>`;\n },\n );\n } catch {\n return String(value);\n }\n }\n}\n"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-layout-Bc42CfJB.js","sources":["src/types/client-layout.ts"],"sourcesContent":["// ─── Layout type ──────────────────────────────────────────────────────────────\n\nexport enum ClientLayoutType {\n OBJECT_FORM_DASHBOARD = 'OBJECT_FORM_DASHBOARD',\n CLASS_DASHBOARD = 'CLASS_DASHBOARD',\n GENERAL_DASHBOARD = 'GENERAL_DASHBOARD',\n NAVIGATION_PANE = 'NAVIGATION_PANE',\n}\n\n// ─── Item types ───────────────────────────────────────────────────────────────\n\nexport enum ClientLayoutItemType {\n // Form / data input\n FIELD = 'FIELD',\n RELATION = 'RELATION',\n // Layout structure\n SECTION = 'SECTION',\n GROUP = 'GROUP',\n // Read-only / display\n HEADER = 'HEADER',\n TEXT = 'TEXT',\n // Navigation / actions\n NAVIGATE = 'NAVIGATE',\n ACTION = 'ACTION',\n SEARCH = 'SEARCH',\n // Dashboard views\n VIEW = 'VIEW',\n RELATED_VIEW = 'RELATED_VIEW',\n RELATED_OBJECT = 'RELATED_OBJECT',\n}\n\n// ─── Field data types ─────────────────────────────────────────────────────────\n\nexport enum ClientLayoutItemFieldDataType {\n TEXT = 'TEXT',\n TEXTBLOCK = 'TEXTBLOCK',\n INTEGER = 'INTEGER',\n DECIMAL = 'DECIMAL',\n PERCENTAGE = 'PERCENTAGE',\n CURRENCY = 'CURRENCY',\n BOOLEAN = 'BOOLEAN',\n DATE = 'DATE',\n DATETIME = 'DATETIME',\n TIME = 'TIME',\n EMAIL = 'EMAIL',\n HYPERLINK = 'HYPERLINK',\n LIST = 'LIST',\n FILE = 'FILE',\n IMAGE = 'IMAGE',\n LONGTEXT = 'LONGTEXT',\n JSON = 'JSON',\n SECRET = 'SECRET',\n}\n\n// ─── Relation display / edit behaviour ───────────────────────────────────────\n\nexport enum ClientLayoutItemRelationDisplayType {\n SEARCH = 'SEARCH',\n DROPDOWN = 'DROPDOWN',\n CHECKBOX = 'CHECKBOX',\n}\n\nexport enum ClientLayoutItemRelationEditBehavior {\n SEARCH = 'SEARCH',\n DROPDOWN = 'DROPDOWN',\n CHECKBOX = 'CHECKBOX',\n}\n\n// ─── VIEW / RELATED_VIEW navigate behaviour ──────────────────────────────────\n\n/** How navigating from a row/document in this VIEW or RELATED_VIEW should open\n * its target: a full page navigation, or an overlay on top of the current page. */\nexport enum ClientLayoutNavigateBehaviour {\n PAGE = 'PAGE',\n OVERLAY_PAGE = 'OVERLAY_PAGE',\n}\n\n// ─── Data object link types (API _links shape) ───────────────────────────────\n\n/** A single sub-link within a multi-value relation link. */\nexport interface DataObjectSubLink {\n href: string;\n name: string;\n}\n\n/** Link object as returned by the API on a data object's `_links` map. */\nexport interface DataObjectLink {\n href: string;\n name?: string;\n values?: DataObjectSubLink[];\n}\n\n// ─── Shared value types ───────────────────────────────────────────────────────\n\n/** A selectable list item as returned by the API. */\nexport interface ClientListValue {\n /** Raw key stored in the database (API uses `key`, older code used `value`). */\n key: string;\n label: string;\n color?: string | null;\n backgroundColor?: string | null;\n}\n\nexport interface CurrencyValue {\n amount: number | null;\n currency: string;\n decimals?: number;\n}\n\nexport interface HyperlinkValue {\n href: string;\n name?: string;\n}\n\nexport interface RelationSearchResult {\n id: string;\n label: string;\n description?: string;\n}\n\n/** A single file belonging to a `commons.document`-archetype record. The host\n * resolves `href` to a signed URL and decides how (or whether) to render it\n * inline — the component only ever hands over the reference. */\nexport interface DocumentAttachment {\n href: string;\n fileName: string;\n mimeType?: string;\n}\n\n// ─── Archetypes (semantic type contracts) ────────────────────────────────────\n\n/**\n * A resolved archetype binding as published on a dashboard.\n * `archetype` is the platform-defined id (e.g. `commons.document`); `slots` maps\n * each slot name to the concrete field/relation name on this type. The client\n * keys on the archetype id and reads values from the data endpoint via the map;\n * the slot kind (value vs relation) is known from the archetype id itself and is\n * not published.\n */\nexport interface ClientArchetype {\n archetype: string;\n slots: Record<string, string>;\n}\n\n/** Well-known archetype ids the client renders specially. */\nexport const ARCHETYPE_DOCUMENT = 'commons.document';\nexport const ARCHETYPE_INVOICE = 'commons.invoice';\nexport const ARCHETYPE_EMAIL = 'commons.email';\n/** Bound by a `commons.invoice`'s `lines` relation target class. Used to find the\n * RELATED_VIEW item for the line items generically, by archetype id rather than\n * by name/class string. */\nexport const ARCHETYPE_INVOICE_LINE = 'commons.invoiceLine';\n\n/**\n * Find a binding for `archetypeId` in a published `archetypes` list.\n * Returns `undefined` when the archetype is absent — callers fall back to the\n * generic table/field rendering.\n */\nexport function resolveArchetype(\n archetypes: ClientArchetype[] | null | undefined,\n archetypeId: string,\n): ClientArchetype | undefined {\n return (archetypes ?? []).find(a => a.archetype === archetypeId);\n}\n\n// ─── Item definitions ─────────────────────────────────────────────────────────\n\nexport interface ClientLayoutItemField {\n name: string;\n label: string;\n dataType: ClientLayoutItemFieldDataType;\n required: boolean;\n disabled?: boolean;\n multiple?: boolean;\n header?: boolean;\n defaultValue?: string | null;\n listItems?: ClientListValue[] | null;\n // UI hints — optional, not sent by API\n placeholder?: string;\n accept?: string;\n maxSize?: number;\n decimalPrecision?: number;\n currencyCode?: string;\n /** Aggregate function to render in the table totals row. */\n aggregate?: 'sum' | 'avg' | 'count' | null;\n historyEnabled?: boolean;\n /** Render the item on an OBJECT_DASHBOARD even when it has no value. */\n showEmpty?: boolean;\n}\n\n/** Response shape from the /aggregations endpoint. */\nexport interface AggregationResult {\n total?: number;\n count?: Record<string, number>;\n sum?: Record<string, number>;\n avg?: Record<string, number>;\n}\n\nexport interface ClientLayoutItemRelation {\n name: string;\n label: string;\n relatedClass: string;\n mostSignificantClass?: string;\n displayType?: ClientLayoutItemRelationDisplayType;\n editBehavior?: ClientLayoutItemRelationEditBehavior | null;\n commonRelation?: string;\n required: boolean;\n disabled?: boolean;\n multiple?: boolean;\n defaultValue?: string | null;\n dropdownValues?: ClientListValue[];\n /** Render the item on an OBJECT_DASHBOARD even when it has no value. */\n showEmpty?: boolean;\n}\n\nexport interface ClientLayoutItemNavigate {\n dataClass: string;\n icon?: string | null;\n navigationType?: string | null;\n}\n\nexport interface ClientLayoutItemRelatedView {\n name: string;\n fromClass?: string | null;\n relatedClass: string;\n filterClass?: string | null;\n showTitle: boolean;\n}\n\nexport interface ClientLayoutItemRelatedObject {\n name: string;\n relatedClass: string;\n}\n\nexport interface ClientLayoutItemSearch {\n dataClass: string;\n showTitle: boolean;\n}\n\n// ─── Generic item ─────────────────────────────────────────────────────────────\n\nexport interface ClientCreateType {\n type: string;\n label: string;\n}\n\n/**\n * A single item in a ClientLayout. The `type` discriminator determines which\n * optional fields are present. Components should only act on types they\n * understand and ignore others.\n */\nexport interface ClientLayoutItem {\n type: ClientLayoutItemType;\n label?: string;\n\n // FIELD\n field?: ClientLayoutItemField;\n\n // RELATION\n relation?: ClientLayoutItemRelation;\n\n // SECTION / GROUP — nested items\n items?: ClientLayoutItem[];\n\n // NAVIGATE\n navigate?: ClientLayoutItemNavigate;\n\n // VIEW — embedded view config (new flat format)\n view?: ClientViewMetadata;\n\n // RELATED_VIEW\n relatedView?: ClientLayoutItemRelatedView;\n\n // RELATED_OBJECT\n relatedObject?: ClientLayoutItemRelatedObject;\n\n // SEARCH\n search?: ClientLayoutItemSearch;\n\n /**\n * Archetype bindings for this item. The API publishes them on the item itself\n * (sibling of `view`), for two cases:\n * - object dashboard top-level: the type of the object itself → mrd-layout-section\n * renders a recognisable single-document view instead of generic fields;\n * - a VIEW / RELATED_VIEW item: → mrd-layout-section offers the document\n * collection view (folder tree) alongside the generic table.\n */\n archetypes?: ClientArchetype[];\n\n // ─── Flat API fields ──────────────────────────────────────────────────────\n // Shared / ACTION / VIEW\n name?: string;\n showTitle?: boolean;\n /** Embedded alternative view configs (new flat format). */\n alternativeViews?: Array<{ label?: string; dataClass?: string; fromClass?: string | null; filterClass?: string | null; view?: ClientViewMetadata }>;\n /** Toolbar buttons for embedded views. null/omitted = [\"NEW\",\"EXPORT\"]; [] = none. */\n actions?: string[] | null;\n /** Concrete subtypes available for create. When set, the NEW button expands into one button per entry. */\n createTypes?: ClientCreateType[] | null;\n\n // FIELD (flat)\n dataType?: ClientLayoutItemFieldDataType;\n required?: boolean;\n disabled?: boolean;\n multiple?: boolean;\n header?: boolean;\n defaultValue?: string | null;\n listItems?: ClientListValue[] | null;\n aggregate?: 'sum' | 'avg' | 'count' | null;\n placeholder?: string;\n accept?: string;\n maxSize?: number;\n decimalPrecision?: number;\n currencyCode?: string;\n historyEnabled?: boolean;\n /** FIELD / RELATION — render the item on an OBJECT_DASHBOARD even when it has\n * no value, instead of hiding it (the default). */\n showEmpty?: boolean;\n\n // RELATION (flat)\n relatedClass?: string;\n mostSignificantClass?: string;\n displayType?: ClientLayoutItemRelationDisplayType;\n editBehavior?: ClientLayoutItemRelationEditBehavior | null;\n commonRelation?: string;\n dropdownValues?: ClientListValue[];\n\n // VIEW / NAVIGATE / SEARCH (flat) — API sends 'dataClass' (renamed from reserved 'class')\n dataClass?: string;\n\n // RELATED_VIEW (flat)\n fromClass?: string | null;\n filterClass?: string | null;\n /** Name of the relation on the related object that points back to the\n * `fromClass` parent (e.g. a document's `dossier` relation). When it equals\n * the `commons.document` archetype's `container` slot, the view is a single\n * container context (see mrd-document-list seeding). */\n inverseRelation?: string | null;\n /** How navigating out of this VIEW/RELATED_VIEW opens its target. Defaults to\n * `PAGE` (full navigation) when absent. mrd-layout-section reads this off the\n * item and includes it in the mrdNavigate event detail it relays upward. */\n navigateBehaviour?: ClientLayoutNavigateBehaviour;\n\n // NAVIGATE (flat)\n icon?: string | null;\n navigationType?: string | null;\n\n // ACTION (flat)\n actionType?: string;\n}\n\n// ─── Layout ───────────────────────────────────────────────────────────────────\n\nexport interface ClientLayout {\n type?: ClientLayoutType;\n label?: string;\n /** Used as the form title (mrd-form). */\n title?: string;\n tabPage?: boolean;\n items: ClientLayoutItem[];\n}\n\n// ─── ViewMetadata (from DashboardMetadata.views) ─────────────────────────────\n\nexport interface ViewFilter {\n name: string;\n value?: string | null;\n operator?: 'EQUALS' | 'FROM' | 'TO' | 'STARTS_WITH' | 'NOT_EMPTY' | 'EMPTY' | null;\n}\n\nexport interface ClientViewMetadata {\n name: string | null;\n defaultView: boolean;\n defaultSort?: string | null;\n /** Column definitions — each item is a FIELD or RELATION item. */\n values: ClientLayoutItem[];\n /** Static query-param filters baked into the view definition. */\n filter?: ViewFilter[] | null;\n type?: string;\n referenceType?: string | null;\n filterType?: string | null;\n singularLabel?: string;\n pluralLabel?: string;\n /**\n * Archetype bindings published on this VIEW / RELATED_VIEW item. When it\n * contains `commons.document`, mrd-layout-section offers the document\n * collection view (folder tree) alongside the generic table.\n */\n archetypes?: ClientArchetype[];\n}\n\n// ─── DashboardMetadata ────────────────────────────────────────────────────────\n\nexport interface ClientDashboardMetadata {\n layouts: ClientLayout[];\n /** Top-level archetypes on an object dashboard (the object's own type). Drives the\n * single-document view; passed to the main layout's mrd-layout-section. */\n archetypes?: ClientArchetype[];\n /** Legacy: view metadata map keyed by generated name. Absent in new flat format. */\n views?: Record<string, ClientViewMetadata>;\n layoutType: ClientLayoutType;\n _links?: Record<string, { href: string }>;\n}\n"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document-attachments-BufPmMRv.js","sources":["src/utils/document-attachments.ts"],"sourcesContent":["import { ClientArchetype, DocumentAttachment } from '../types/client-layout';\n\n/**\n * Extract an archetype's file slot from a data record as a `DocumentAttachment[]` —\n * empty when the slot is unmapped or has no value. `slot` defaults to `'file'` (the\n * commons.document single-file slot); pass `'attachments'` for the multi-file slots\n * on commons.email / commons.invoice. A single-object slot value yields a one-entry\n * array, an array-valued slot yields one entry per item.\n * Shared by mrd-document-view / mrd-invoice-view / mrd-email-view (on load/data-change)\n * and mrd-document-container (row-click prefetch on mrdNavigate), so all report the\n * exact same shape.\n */\nexport function attachmentsFromRecord(\n archetype: ClientArchetype | null | undefined,\n record: Record<string, unknown> | null | undefined,\n slot: string = 'file',\n): DocumentAttachment[] {\n const field = archetype?.slots?.[slot];\n if (!field) return [];\n const raw = (record as any)?.[field];\n if (!raw) return [];\n const items = Array.isArray(raw) ? raw : [raw];\n return items.filter(Boolean).map(item => ({\n href: item.href,\n fileName: item.fileName ?? String(item),\n mimeType: item.mimeType ?? item.contentType ?? undefined,\n }));\n}\n\n/** Dedup key for the componentDidLoad/@Watch('data') \"emit mrdAttachments only on\n * change\" guard shared by mrd-document-view / mrd-invoice-view / mrd-email-view. */\nexport function attachmentsKey(attachments: DocumentAttachment[]): string {\n return attachments.map(a => a.href).join('|');\n}\n"],"names":[],"mappings":"AAEA;;;;;;;;;AASG;AACG,SAAU,qBAAqB,CACnC,SAA6C,EAC7C,MAAkD,EAClD,OAAe,MAAM,EAAA;;IAErB,MAAM,KAAK,GAAG,CAAA,EAAA,GAAA,SAAS,KAAA,IAAA,IAAT,SAAS,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAT,SAAS,CAAE,KAAK,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAG,IAAI,CAAC;AACtC,IAAA,IAAI,CAAC,KAAK;AAAE,QAAA,OAAO,EAAE;IACrB,MAAM,GAAG,GAAI,MAAc,KAAA,IAAA,IAAd,MAAM,uBAAN,MAAM,CAAW,KAAK,CAAC;AACpC,IAAA,IAAI,CAAC,GAAG;AAAE,QAAA,OAAO,EAAE;AACnB,IAAA,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC;IAC9C,OAAO,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,IAAI,IAAG;;AAAC,QAAA,QAAC;YACxC,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,QAAQ,EAAE,MAAA,IAAI,CAAC,QAAQ,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAI,MAAM,CAAC,IAAI,CAAC;AACvC,YAAA,QAAQ,EAAE,CAAA,EAAA,GAAA,CAAA,EAAA,GAAA,IAAI,CAAC,QAAQ,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAI,IAAI,CAAC,WAAW,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAI,SAAS;AACzD,SAAA;AAAC,KAAA,CAAC;AACL;AAEA;AACqF;AAC/E,SAAU,cAAc,CAAC,WAAiC,EAAA;AAC9D,IAAA,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;AAC/C;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field-helpers-CUJsHr1V.js","sources":["src/components/fields/field-helpers.tsx"],"sourcesContent":["import { FunctionalComponent, h } from '@stencil/core';\nimport { t } from '../../utils/i18n';\nimport { validateRequired } from '../../utils/validation';\n\n/**\n * Shared building blocks for the leaf field components.\n * `base` is the BEM block name, e.g. 'mrd-text-field'.\n */\n\nexport const FieldLabel: FunctionalComponent<{ base: string; label: string; required: boolean }> = ({ base, label, required }) =>\n label ? <label class={`${base}__label${required ? ` ${base}__label--required` : ''}`}>{label}</label> : null;\n\nexport const FieldError: FunctionalComponent<{ base: string; error: string }> = ({ base, error }) =>\n error ? <span class={`${base}__error`}>{error}</span> : null;\n\n/** Class string for the form control, with the --error modifier when applicable. */\nexport function controlClass(base: string, hasError: boolean, element: string = 'input'): string {\n return `${base}__${element}${hasError ? ` ${base}__${element}--error` : ''}`;\n}\n\n/** Returns the localised required-error, or '' when the value passes. */\nexport function requiredError(value: unknown, required: boolean, locale: string): string {\n return required && !validateRequired(value) ? t('required', locale) : '';\n}\n"],"names":[],"mappings":";;;;AAIA;;;AAGG;MAEU,UAAU,GAA4E,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,KAC3H,KAAK,GAAG,aAAO,KAAK,EAAE,CAAA,EAAG,IAAI,CAAA,OAAA,EAAU,QAAQ,GAAG,CAAA,CAAA,EAAI,IAAI,CAAA,iBAAA,CAAmB,GAAG,EAAE,CAAA,CAAE,IAAG,KAAK,CAAS,GAAG;AAEnG,MAAM,UAAU,GAAyD,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAC9F,KAAK,GAAG,CAAA,CAAA,MAAA,EAAA,EAAM,KAAK,EAAE,GAAG,IAAI,CAAA,OAAA,CAAS,EAAA,EAAG,KAAK,CAAQ,GAAG;AAE1D;AACM,SAAU,YAAY,CAAC,IAAY,EAAE,QAAiB,EAAE,UAAkB,OAAO,EAAA;AACrF,IAAA,OAAO,GAAG,IAAI,CAAA,EAAA,EAAK,OAAO,CAAA,EAAG,QAAQ,GAAG,IAAI,IAAI,CAAA,EAAA,EAAK,OAAO,CAAA,OAAA,CAAS,GAAG,EAAE,EAAE;AAC9E;AAEA;SACgB,aAAa,CAAC,KAAc,EAAE,QAAiB,EAAE,MAAc,EAAA;IAC7E,OAAO,QAAQ,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,MAAM,CAAC,GAAG,EAAE;AAC1E;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-upload-common-DdTDuxEU.js","sources":["src/components/fields/file-upload-common.ts"],"sourcesContent":["import { t } from '../../utils/i18n';\n\n/**\n * Shared upload behaviour for mrd-file-field and mrd-image-field:\n * file validation, drop-zone class building and drag-drop wiring.\n */\n\n/** A resolved file/image value, matching the shape the API returns for an already-persisted\n * file (mrd-table cell renderer, mrd-document-view, mrd-layout-section all read `.href` /\n * `.fileName` the same way) — also what a freshly-completed upload resolves to (host builds\n * `{ href: uri, fileName: file.name }` client-side). May carry extra metadata (`contentType`,\n * `size`, …) that this library ignores. */\nexport interface UploadedFileRef {\n href: string;\n fileName: string;\n [key: string]: unknown;\n}\n\n/** A single field entry: a pending `File` (upload in progress), a resolved `UploadedFileRef`,\n * or a bare href string (legacy shape — still supported so older hosts keep working unchanged). */\nexport type FileEntry = File | UploadedFileRef | string;\n\n/** True while the entry is still a local `File` awaiting upload resolution. */\nexport function isPending(entry: FileEntry): boolean {\n return entry instanceof File;\n}\n\n/** Display name for an entry: the `File`'s own name, the resolved `fileName`, or — for the\n * legacy bare-href shape — a best-effort basename of the URI. */\nexport function entryLabel(entry: FileEntry): string {\n if (entry instanceof File) return entry.name;\n if (typeof entry !== 'string') return entry.fileName || entry.href;\n const base = entry.split('/').pop() ?? entry;\n try {\n return decodeURIComponent(base);\n } catch {\n return base;\n }\n}\n\n/** Validates a selected/dropped file; returns a localised error message or '' when accepted. */\nexport function validateUploadFile(file: File, maxSize: number, locale: string, requireImage = false): string {\n if (maxSize > 0 && file.size > maxSize) return t('file_too_large', locale);\n if (requireImage && !file.type.startsWith('image/')) return t('invalid_image', locale);\n return '';\n}\n\n/** BEM class string for the drop zone, e.g. base 'mrd-file-field' → 'mrd-file-field__zone …'. */\nexport function uploadZoneClass(base: string, opts: { dragging: boolean; error: boolean; disabled: boolean }): string {\n return [\n `${base}__zone`,\n opts.dragging ? `${base}__zone--dragging` : '',\n opts.error ? `${base}__zone--error` : '',\n opts.disabled ? `${base}__zone--disabled` : '',\n ].filter(Boolean).join(' ');\n}\n\n/** Drag-drop handlers for the drop zone; the component owns the dragging state and file handling. */\nexport function makeDragHandlers(setDragging: (dragging: boolean) => void, onFiles: (files: File[]) => void) {\n return {\n onDragOver: (e: DragEvent) => {\n e.preventDefault();\n setDragging(true);\n },\n onDragLeave: () => setDragging(false),\n onDrop: (e: DragEvent) => {\n e.preventDefault();\n setDragging(false);\n onFiles(Array.from(e.dataTransfer?.files ?? []));\n },\n };\n}\n"],"names":[],"mappings":";;AAsBA;AACM,SAAU,SAAS,CAAC,KAAgB,EAAA;IACxC,OAAO,KAAK,YAAY,IAAI;AAC9B;AAEA;AACkE;AAC5D,SAAU,UAAU,CAAC,KAAgB,EAAA;;IACzC,IAAI,KAAK,YAAY,IAAI;QAAE,OAAO,KAAK,CAAC,IAAI;IAC5C,IAAI,OAAO,KAAK,KAAK,QAAQ;AAAE,QAAA,OAAO,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,IAAI;AAClE,IAAA,MAAM,IAAI,GAAG,CAAA,EAAA,GAAA,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAI,KAAK;AAC5C,IAAA,IAAI;AACF,QAAA,OAAO,kBAAkB,CAAC,IAAI,CAAC;;IAC/B,OAAA,EAAA,EAAM;AACN,QAAA,OAAO,IAAI;;AAEf;AAEA;AACM,SAAU,kBAAkB,CAAC,IAAU,EAAE,OAAe,EAAE,MAAc,EAAE,YAAY,GAAG,KAAK,EAAA;IAClG,IAAI,OAAO,GAAG,CAAC,IAAI,IAAI,CAAC,IAAI,GAAG,OAAO;AAAE,QAAA,OAAO,CAAC,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAC1E,IAAI,YAAY,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC;AAAE,QAAA,OAAO,CAAC,CAAC,eAAe,EAAE,MAAM,CAAC;AACtF,IAAA,OAAO,EAAE;AACX;AAEA;AACM,SAAU,eAAe,CAAC,IAAY,EAAE,IAA8D,EAAA;IAC1G,OAAO;AACL,QAAA,CAAA,EAAG,IAAI,CAAA,MAAA,CAAQ;QACf,IAAI,CAAC,QAAQ,GAAG,CAAA,EAAG,IAAI,CAAA,gBAAA,CAAkB,GAAG,EAAE;QAC9C,IAAI,CAAC,KAAK,GAAG,CAAA,EAAG,IAAI,CAAA,aAAA,CAAe,GAAG,EAAE;QACxC,IAAI,CAAC,QAAQ,GAAG,CAAA,EAAG,IAAI,CAAA,gBAAA,CAAkB,GAAG,EAAE;KAC/C,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;AAC7B;AAEA;AACM,SAAU,gBAAgB,CAAC,WAAwC,EAAE,OAAgC,EAAA;IACzG,OAAO;AACL,QAAA,UAAU,EAAE,CAAC,CAAY,KAAI;YAC3B,CAAC,CAAC,cAAc,EAAE;YAClB,WAAW,CAAC,IAAI,CAAC;SAClB;AACD,QAAA,WAAW,EAAE,MAAM,WAAW,CAAC,KAAK,CAAC;AACrC,QAAA,MAAM,EAAE,CAAC,CAAY,KAAI;;YACvB,CAAC,CAAC,cAAc,EAAE;YAClB,WAAW,CAAC,KAAK,CAAC;YAClB,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,MAAA,CAAA,EAAA,GAAA,CAAC,CAAC,YAAY,0CAAE,KAAK,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAI,EAAE,CAAC,CAAC;SACjD;KACF;AACH;;;;"}
|