@prioticket/design-system-web 1.7.0-beta.1 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"package": {
|
|
3
3
|
"name": "@prioticket/design-system-web",
|
|
4
|
-
"version": "1.7.0
|
|
4
|
+
"version": "1.7.0",
|
|
5
5
|
"description": "",
|
|
6
6
|
"installation": "npm install @prioticket/design-system-web"
|
|
7
7
|
},
|
|
8
|
-
"generatedAt": "2026-03-
|
|
8
|
+
"generatedAt": "2026-03-09T17:32:58.984Z",
|
|
9
9
|
"components": {
|
|
10
10
|
"pd-box": {
|
|
11
11
|
"tagName": "pd-box",
|
package/custom-elements.json
CHANGED
|
@@ -6708,6 +6708,21 @@
|
|
|
6708
6708
|
"privacy": "private",
|
|
6709
6709
|
"default": "null"
|
|
6710
6710
|
},
|
|
6711
|
+
{
|
|
6712
|
+
"kind": "field",
|
|
6713
|
+
"name": "_flipPositions",
|
|
6714
|
+
"privacy": "private",
|
|
6715
|
+
"default": "new Map<string | number, number>()"
|
|
6716
|
+
},
|
|
6717
|
+
{
|
|
6718
|
+
"kind": "field",
|
|
6719
|
+
"name": "_flipPending",
|
|
6720
|
+
"type": {
|
|
6721
|
+
"text": "boolean"
|
|
6722
|
+
},
|
|
6723
|
+
"privacy": "private",
|
|
6724
|
+
"default": "false"
|
|
6725
|
+
},
|
|
6711
6726
|
{
|
|
6712
6727
|
"kind": "field",
|
|
6713
6728
|
"name": "_displayDataCache",
|
|
@@ -6726,6 +6741,12 @@
|
|
|
6726
6741
|
"privacy": "private",
|
|
6727
6742
|
"default": "''"
|
|
6728
6743
|
},
|
|
6744
|
+
{
|
|
6745
|
+
"kind": "field",
|
|
6746
|
+
"name": "_displayToDataIndexMap",
|
|
6747
|
+
"privacy": "private",
|
|
6748
|
+
"default": "new Map<T, number>()"
|
|
6749
|
+
},
|
|
6729
6750
|
{
|
|
6730
6751
|
"kind": "field",
|
|
6731
6752
|
"name": "_reactRoots",
|
|
@@ -6772,6 +6793,38 @@
|
|
|
6772
6793
|
"description": "Processed data with sorting and pagination applied.\nResults are memoized for performance.",
|
|
6773
6794
|
"readonly": true
|
|
6774
6795
|
},
|
|
6796
|
+
{
|
|
6797
|
+
"kind": "method",
|
|
6798
|
+
"name": "_captureRowPositions",
|
|
6799
|
+
"privacy": "private",
|
|
6800
|
+
"return": {
|
|
6801
|
+
"type": {
|
|
6802
|
+
"text": "void"
|
|
6803
|
+
}
|
|
6804
|
+
},
|
|
6805
|
+
"description": "Captures the current Y position of every visible row.\nMust be called BEFORE data changes trigger a re-render."
|
|
6806
|
+
},
|
|
6807
|
+
{
|
|
6808
|
+
"kind": "method",
|
|
6809
|
+
"name": "_playFlipAnimation",
|
|
6810
|
+
"privacy": "private",
|
|
6811
|
+
"return": {
|
|
6812
|
+
"type": {
|
|
6813
|
+
"text": "void"
|
|
6814
|
+
}
|
|
6815
|
+
},
|
|
6816
|
+
"description": "After re-render, computes the delta between old and new positions\nand animates rows from their old position to the new one."
|
|
6817
|
+
},
|
|
6818
|
+
{
|
|
6819
|
+
"kind": "field",
|
|
6820
|
+
"name": "_dataRevision",
|
|
6821
|
+
"type": {
|
|
6822
|
+
"text": "number"
|
|
6823
|
+
},
|
|
6824
|
+
"privacy": "private",
|
|
6825
|
+
"default": "0",
|
|
6826
|
+
"description": "Incremented whenever data is set, ensuring the cache is always invalidated.\nThis replaces the fragile fingerprinting approach that missed adjacent swaps."
|
|
6827
|
+
},
|
|
6775
6828
|
{
|
|
6776
6829
|
"kind": "method",
|
|
6777
6830
|
"name": "_computeCacheKey",
|
|
@@ -6824,25 +6877,6 @@
|
|
|
6824
6877
|
}
|
|
6825
6878
|
]
|
|
6826
6879
|
},
|
|
6827
|
-
{
|
|
6828
|
-
"kind": "method",
|
|
6829
|
-
"name": "_getActualDataIndex",
|
|
6830
|
-
"privacy": "private",
|
|
6831
|
-
"return": {
|
|
6832
|
-
"type": {
|
|
6833
|
-
"text": "number"
|
|
6834
|
-
}
|
|
6835
|
-
},
|
|
6836
|
-
"parameters": [
|
|
6837
|
-
{
|
|
6838
|
-
"name": "row",
|
|
6839
|
-
"type": {
|
|
6840
|
-
"text": "T"
|
|
6841
|
-
}
|
|
6842
|
-
}
|
|
6843
|
-
],
|
|
6844
|
-
"description": "Finds the actual index of a row in the full data array.\nThis is critical for stable row keys when pagination is active."
|
|
6845
|
-
},
|
|
6846
6880
|
{
|
|
6847
6881
|
"kind": "method",
|
|
6848
6882
|
"name": "_isColumnSortable",
|
|
@@ -7066,7 +7100,7 @@
|
|
|
7066
7100
|
}
|
|
7067
7101
|
},
|
|
7068
7102
|
{
|
|
7069
|
-
"name": "
|
|
7103
|
+
"name": "displayIndex",
|
|
7070
7104
|
"type": {
|
|
7071
7105
|
"text": "number"
|
|
7072
7106
|
}
|
|
@@ -7090,7 +7124,7 @@
|
|
|
7090
7124
|
}
|
|
7091
7125
|
},
|
|
7092
7126
|
{
|
|
7093
|
-
"name": "
|
|
7127
|
+
"name": "displayIndex",
|
|
7094
7128
|
"type": {
|
|
7095
7129
|
"text": "number"
|
|
7096
7130
|
}
|
|
@@ -7132,7 +7166,7 @@
|
|
|
7132
7166
|
}
|
|
7133
7167
|
},
|
|
7134
7168
|
{
|
|
7135
|
-
"name": "
|
|
7169
|
+
"name": "toDisplayIndex",
|
|
7136
7170
|
"type": {
|
|
7137
7171
|
"text": "number"
|
|
7138
7172
|
}
|
|
@@ -7186,7 +7220,7 @@
|
|
|
7186
7220
|
}
|
|
7187
7221
|
},
|
|
7188
7222
|
{
|
|
7189
|
-
"name": "
|
|
7223
|
+
"name": "displayIndex",
|
|
7190
7224
|
"type": {
|
|
7191
7225
|
"text": "number"
|
|
7192
7226
|
}
|
|
@@ -7204,18 +7238,19 @@
|
|
|
7204
7238
|
},
|
|
7205
7239
|
"parameters": [
|
|
7206
7240
|
{
|
|
7207
|
-
"name": "
|
|
7241
|
+
"name": "fromDisplayIndex",
|
|
7208
7242
|
"type": {
|
|
7209
7243
|
"text": "number"
|
|
7210
7244
|
}
|
|
7211
7245
|
},
|
|
7212
7246
|
{
|
|
7213
|
-
"name": "
|
|
7247
|
+
"name": "toDisplayIndex",
|
|
7214
7248
|
"type": {
|
|
7215
7249
|
"text": "number"
|
|
7216
7250
|
}
|
|
7217
7251
|
}
|
|
7218
|
-
]
|
|
7252
|
+
],
|
|
7253
|
+
"description": "Maps display indices to this.data indices, performs the reorder\ninternally, and emits the event with the complete reordered array.\n\nWhen sorting is active the user sees a sorted view; dragging within it\nmeans \"I accept this sorted order AND want to adjust it.\" We therefore\n**materialize** the sort into the data array before applying the drag,\nso the result matches what the user visually intended."
|
|
7219
7254
|
},
|
|
7220
7255
|
{
|
|
7221
7256
|
"kind": "method",
|
|
@@ -7636,15 +7671,25 @@
|
|
|
7636
7671
|
"name": "row",
|
|
7637
7672
|
"type": {
|
|
7638
7673
|
"text": "T"
|
|
7639
|
-
}
|
|
7674
|
+
},
|
|
7675
|
+
"description": "The data item"
|
|
7640
7676
|
},
|
|
7641
7677
|
{
|
|
7642
|
-
"name": "
|
|
7678
|
+
"name": "displayIndex",
|
|
7643
7679
|
"type": {
|
|
7644
7680
|
"text": "number"
|
|
7645
|
-
}
|
|
7681
|
+
},
|
|
7682
|
+
"description": "0-based position in the visible (sorted/paginated) list — used for drag-and-drop"
|
|
7683
|
+
},
|
|
7684
|
+
{
|
|
7685
|
+
"name": "dataIndex",
|
|
7686
|
+
"type": {
|
|
7687
|
+
"text": "number"
|
|
7688
|
+
},
|
|
7689
|
+
"description": "Position in the original this.data array — used for row keys, selection, and events"
|
|
7646
7690
|
}
|
|
7647
|
-
]
|
|
7691
|
+
],
|
|
7692
|
+
"description": "Renders a single table row."
|
|
7648
7693
|
},
|
|
7649
7694
|
{
|
|
7650
7695
|
"kind": "method",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("lit"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("lit"),d=require("lit/decorators.js"),_=require("lit/directives/repeat.js"),g=require("lit/directives/class-map.js"),y=require("lit/directives/ref.js");require("./pd-icon.cjs.js");require("./pd-checkbox.cjs.js");require("./pd-text-field.cjs.js");require("./pd-icon-button.cjs.js");require("./pd-select.cjs.js");require("./pd-menu-item.cjs.js");var f=Object.defineProperty,w=Object.getOwnPropertyDescriptor,c=(p,e,t,a)=>{for(var r=a>1?void 0:a?w(e,t):e,o=p.length-1,s;o>=0;o--)(s=p[o])&&(r=(a?s(e,t,r):s(r))||r);return a&&r&&f(e,t,r),r};exports.PdTable=class extends i.LitElement{constructor(){super(...arguments),this.columns=[],this.data=[],this.rowKey=(e,t)=>{const a=e.id;return a!=null?String(a):`__idx_${t}`},this.selectable=!1,this.sortable=!1,this.pagination=!1,this.pageSize=10,this.pageIndex=0,this.totalItems=0,this.draggableRows=!1,this.draggableColumns=!1,this.loading=!1,this.clearSelectionOnDataChange=!1,this.currencyCode="EUR",this.pageSizeOptions=[5,10,25,50,100],this._sortColumn=null,this._sortDirection="asc",this._selectedRowKeys=new Set,this._draggedRowIndex=null,this._dragOverRowIndex=null,this._isDragHandleGrabbed=!1,this._draggedColumnIndex=null,this._dragOverColumnIndex=null,this._flipPositions=new Map,this._flipPending=!1,this._displayDataCache=[],this._displayDataCacheKey="",this._displayToDataIndexMap=new Map,this._reactRoots=new Map,this._dataRevision=0,this._uniqueId=Math.random().toString(36).substring(2,9)}get _isServerSidePagination(){return this.totalItems>0}get _totalCount(){return this._isServerSidePagination?this.totalItems:this.data.length}get _totalPages(){return Math.ceil(this._totalCount/this.pageSize)}get _displayData(){const e=this._computeCacheKey();if(e===this._displayDataCacheKey)return this._displayDataCache;let t=[...this.data];if(this.sortable&&this._sortColumn&&(t=this._sortData(t)),this.pagination&&!this._isServerSidePagination&&this.data.length>this.pageSize){const a=this.pageIndex*this.pageSize,r=a+this.pageSize;t=t.slice(a,r)}this._displayDataCacheKey=e,this._displayDataCache=t,this._displayToDataIndexMap=new Map;for(let a=0;a<t.length;a++)this._displayToDataIndexMap.set(t[a],this.data.indexOf(t[a]));return t}disconnectedCallback(){super.disconnectedCallback(),this._reactRoots.forEach(({unmount:e})=>e()),this._reactRoots.clear()}willUpdate(e){super.willUpdate(e),e.has("data")&&this._dataRevision++,e.has("data")&&this.clearSelectionOnDataChange&&(this._selectedRowKeys=new Set),(e.has("data")||e.has("pageSize"))&&this.pageIndex>=this._totalPages&&this._totalPages>0&&(this.pageIndex=this._totalPages-1)}updated(e){super.updated(e),this._flipPending&&(this._flipPending=!1,this._playFlipAnimation())}_captureRowPositions(){this._flipPositions.clear();const e=this.shadowRoot?.querySelector("tbody");if(!e)return;const t=e.querySelectorAll('tr[role="row"]'),a=this._displayData;t.forEach((r,o)=>{const s=a[o];if(!s)return;const l=this._displayToDataIndexMap.get(s)??this.data.indexOf(s),n=this._getRowKey(s,l);this._flipPositions.set(n,r.getBoundingClientRect().top)})}_playFlipAnimation(){const e=this.shadowRoot?.querySelector("tbody");if(!e||this._flipPositions.size===0)return;const t=e.querySelectorAll('tr[role="row"]'),a=this._displayData;t.forEach((r,o)=>{const s=a[o];if(!s)return;const l=this._displayToDataIndexMap.get(s)??this.data.indexOf(s),n=this._getRowKey(s,l),h=this._flipPositions.get(n);if(h===void 0)return;const m=r.getBoundingClientRect().top,u=h-m;Math.abs(u)<1||(r.style.transform=`translateY(${u}px)`,r.style.transition="none",requestAnimationFrame(()=>{r.style.transition="transform 200ms cubic-bezier(0.2, 0, 0, 1)",r.style.transform="";const b=()=>{r.style.transition="",r.removeEventListener("transitionend",b)};r.addEventListener("transitionend",b,{once:!0})}))}),this._flipPositions.clear()}_computeCacheKey(){return`${this._dataRevision}|${this._sortColumn}|${this._sortDirection}|${this.pageIndex}|${this.pageSize}|${this.totalItems}`}_sortData(e){const t=this._sortColumn,a=this._sortDirection;return[...e].sort((r,o)=>{const s=r[t],l=o[t];if(s==null&&l==null)return 0;if(s==null)return a==="asc"?1:-1;if(l==null)return a==="asc"?-1:1;if(typeof s=="number"&&typeof l=="number")return a==="asc"?s-l:l-s;if(s instanceof Date&&l instanceof Date)return a==="asc"?s.getTime()-l.getTime():l.getTime()-s.getTime();const n=String(s).toLowerCase(),h=String(l).toLowerCase();return n<h?a==="asc"?-1:1:n>h?a==="asc"?1:-1:0})}_getRowKey(e,t){return this.rowKey(e,t)}_isColumnSortable(e){return e.sortable!==void 0?e.sortable:this.sortable}_getColumnAlignment(e){return e.align?e.align:e.type==="number"||e.type==="currency"?"right":e.type==="boolean"?"center":"left"}_getColspan(){return this.columns.length+(this.selectable?1:0)+(this.draggableRows?1:0)}_handleSort(e){if(!this._isColumnSortable(e))return;const t=this._sortColumn===e.id&&this._sortDirection==="asc"?"desc":"asc";this._sortColumn=e.id,this._sortDirection=t,this.dispatchEvent(new CustomEvent("pd-table-sort",{detail:{columnId:e.id,direction:t},bubbles:!0,composed:!0}))}_handleHeaderKeyDown(e,t){(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),this._handleSort(t))}_handleSelectAll(e){const t=e.target,a=new Set;t.checked&&this.data.forEach((r,o)=>{a.add(this._getRowKey(r,o))}),this._selectedRowKeys=a,this._emitSelectionChange()}_handleSelectRow(e,t,a){const r=this._getRowKey(e,t),o=new Set(this._selectedRowKeys);a?o.add(r):o.delete(r),this._selectedRowKeys=o,this._emitSelectionChange()}_emitSelectionChange(){const e=this.data.filter((t,a)=>this._selectedRowKeys.has(this._getRowKey(t,a)));this.dispatchEvent(new CustomEvent("pd-table-selection-change",{detail:{selectedKeys:Array.from(this._selectedRowKeys),selectedRows:e},bubbles:!0,composed:!0}))}_handleRowClick(e,t){this.dispatchEvent(new CustomEvent("pd-table-row-click",{detail:{row:e,index:t},bubbles:!0,composed:!0}))}_handleCellChange(e,t,a,r){const o=r.target,s=e[a.id];let l=o.value;if(a.type==="number"||a.type==="currency"){const n=parseFloat(o.value);l=isNaN(n)?null:n}this.dispatchEvent(new CustomEvent("pd-table-cell-change",{detail:{row:e,rowIndex:t,columnId:a.id,value:l,previousValue:s},bubbles:!0,composed:!0}))}_onDragStart(e,t){if(!this.draggableRows||!this._isDragHandleGrabbed){e.preventDefault();return}this._draggedRowIndex=t,e.dataTransfer&&(e.dataTransfer.effectAllowed="move",e.dataTransfer.setData("text/plain",String(t))),requestAnimationFrame(()=>{(e.target.closest?.("tr")??e.target).classList.add("dragging")})}_onDragOver(e,t){!this.draggableRows||this._draggedRowIndex===null||(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect="move"),this._dragOverRowIndex!==t&&(this._dragOverRowIndex=t))}_onDragEnd(e){this._resetDragState(),(e.target.closest?.("tr")??e.target).classList.remove("dragging")}_onDrop(e,t){if(e.preventDefault(),!this.draggableRows||this._draggedRowIndex===null)return;const a=this._draggedRowIndex;a!==t&&this._emitReorder(a,t),this._resetDragState()}_resetDragState(){this._draggedRowIndex=null,this._dragOverRowIndex=null,this._isDragHandleGrabbed=!1}_handleDragHandleMouseDown(){this._isDragHandleGrabbed=!0}_handleDragHandleMouseUp(){this._isDragHandleGrabbed=!1}_handleDragHandleKeyDown(e,t){const a=this._displayData;e.key==="ArrowUp"&&t>0?(e.preventDefault(),this._emitReorder(t,t-1)):e.key==="ArrowDown"&&t<a.length-1&&(e.preventDefault(),this._emitReorder(t,t+1))}_emitReorder(e,t){const a=this._displayData,r=a[e],o=a[t];if(!r||!o)return;this._captureRowPositions(),this._flipPending=!0,this._sortColumn&&(this.data=this._sortData([...this.data])),this._sortColumn=null,this._sortDirection="asc";const s=this.data.indexOf(r),l=this.data.indexOf(o);if(s===-1||l===-1)return;const n=[...this.data],[h]=n.splice(s,1);n.splice(l,0,h),this.data=n,this.dispatchEvent(new CustomEvent("pd-table-row-reorder",{detail:{fromIndex:s,toIndex:l,item:r,data:n},bubbles:!0,composed:!0}))}_onColumnDragStart(e,t){if(!this.draggableColumns){e.preventDefault();return}this._draggedColumnIndex=t,e.dataTransfer&&(e.dataTransfer.effectAllowed="move",e.dataTransfer.setData("text/plain",`column:${t}`)),requestAnimationFrame(()=>{e.target.classList.add("column-dragging")})}_onColumnDragOver(e,t){!this.draggableColumns||this._draggedColumnIndex===null||(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect="move"),this._dragOverColumnIndex!==t&&(this._dragOverColumnIndex=t))}_onColumnDragEnd(e){this._resetColumnDragState(),e.target.classList.remove("column-dragging")}_onColumnDrop(e,t){if(e.preventDefault(),!this.draggableColumns||this._draggedColumnIndex===null)return;const a=this._draggedColumnIndex;a!==t&&this.dispatchEvent(new CustomEvent("pd-table-column-reorder",{detail:{fromIndex:a,toIndex:t,column:this.columns[a]},bubbles:!0,composed:!0})),this._resetColumnDragState()}_resetColumnDragState(){this._draggedColumnIndex=null,this._dragOverColumnIndex=null}_handleColumnHeaderKeyDown(e,t){this.draggableColumns&&(e.key==="ArrowLeft"&&t>0?(e.preventDefault(),this._emitColumnReorder(t,t-1)):e.key==="ArrowRight"&&t<this.columns.length-1&&(e.preventDefault(),this._emitColumnReorder(t,t+1)))}_emitColumnReorder(e,t){this.dispatchEvent(new CustomEvent("pd-table-column-reorder",{detail:{fromIndex:e,toIndex:t,column:this.columns[e]},bubbles:!0,composed:!0}))}_handlePageChange(e){e<0||e>=this._totalPages||(this.pageIndex=e,this.dispatchEvent(new CustomEvent("pd-table-page-change",{detail:{pageIndex:e,pageSize:this.pageSize},bubbles:!0,composed:!0})))}_handlePageSizeChange(e){const t=parseInt(e.detail.value,10);this.pageSize=t,this.pageIndex=0,this.dispatchEvent(new CustomEvent("pd-table-page-change",{detail:{pageIndex:0,pageSize:t},bubbles:!0,composed:!0}))}_renderHeader(){const e=this.data.length>0&&this._selectedRowKeys.size===this.data.length,t=this._selectedRowKeys.size>0&&this._selectedRowKeys.size<this.data.length;return i.html`
|
|
2
2
|
<thead>
|
|
3
3
|
<tr role="row">
|
|
4
4
|
${this.draggableRows?i.html`
|
|
@@ -21,20 +21,20 @@
|
|
|
21
21
|
${this.columns.map((a,r)=>this._renderHeaderCell(a,r))}
|
|
22
22
|
</tr>
|
|
23
23
|
</thead>
|
|
24
|
-
`}_renderHeaderCell(e,t){const a=this._isColumnSortable(e),r=this._getColumnAlignment(e),
|
|
24
|
+
`}_renderHeaderCell(e,t){const a=this._isColumnSortable(e),r=this._getColumnAlignment(e),o=this._sortColumn===e.id,s=this._draggedColumnIndex===t,l=this._dragOverColumnIndex===t&&!s,n=o?this._sortDirection==="asc"?"ascending":"descending":"none";return i.html`
|
|
25
25
|
<th
|
|
26
26
|
role="columnheader"
|
|
27
|
-
class=${g.classMap({sortable:a,sorted:
|
|
27
|
+
class=${g.classMap({sortable:a,sorted:o,[`align-${r}`]:!0,"column-draggable":this.draggableColumns,"column-dragging":s,"column-drag-over":l})}
|
|
28
28
|
style=${e.width?`width: ${e.width};`:""}${e.minWidth?` min-width: ${e.minWidth};`:""}
|
|
29
|
-
aria-sort=${a?
|
|
29
|
+
aria-sort=${a?n:i.nothing}
|
|
30
30
|
tabindex=${a||this.draggableColumns?"0":i.nothing}
|
|
31
31
|
draggable=${this.draggableColumns?"true":"false"}
|
|
32
32
|
@click=${()=>this._handleSort(e)}
|
|
33
|
-
@keydown=${
|
|
34
|
-
@dragstart=${
|
|
35
|
-
@dragover=${
|
|
36
|
-
@drop=${
|
|
37
|
-
@dragend=${
|
|
33
|
+
@keydown=${h=>{this._handleHeaderKeyDown(h,e),this._handleColumnHeaderKeyDown(h,t)}}
|
|
34
|
+
@dragstart=${h=>this._onColumnDragStart(h,t)}
|
|
35
|
+
@dragover=${h=>this._onColumnDragOver(h,t)}
|
|
36
|
+
@drop=${h=>this._onColumnDrop(h,t)}
|
|
37
|
+
@dragend=${h=>this._onColumnDragEnd(h)}
|
|
38
38
|
>
|
|
39
39
|
<div class=${g.classMap({"header-content":!0,[`align-${r}`]:!0})}>
|
|
40
40
|
${this.draggableColumns?i.html`
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
<span class="header-text">${e.header}</span>
|
|
49
49
|
${a?i.html`
|
|
50
50
|
<pd-icon
|
|
51
|
-
class=${g.classMap({"sort-icon":!0,"sort-icon-visible":
|
|
51
|
+
class=${g.classMap({"sort-icon":!0,"sort-icon-visible":o,"sort-icon-desc":o&&this._sortDirection==="desc"})}
|
|
52
52
|
name="arrow_upward"
|
|
53
53
|
size="small"
|
|
54
54
|
aria-hidden="true"
|
|
@@ -56,13 +56,13 @@
|
|
|
56
56
|
`:i.nothing}
|
|
57
57
|
</div>
|
|
58
58
|
</th>
|
|
59
|
-
`}_renderCell(e,t,a){if(a.cellTemplate){const
|
|
59
|
+
`}_renderCell(e,t,a){if(a.cellTemplate){const o=a.cellTemplate(e,t);if(this._isReactElement(o)){const s=`${this.rowKey(e,t)}-${a.id}`;return this._renderReactCellContent(o,s)}return o}const r=e[a.id];if(a.editable)return this._renderEditableCell(e,t,a,r);switch(a.type){case"currency":return this._formatCurrency(r,a.currencyCode);case"number":return this._formatNumber(r);case"date":return this._formatDate(r);case"boolean":return this._renderBoolean(r);default:return r!=null?String(r):""}}_renderEditableCell(e,t,a,r){const o=a.type==="number"||a.type==="currency"?"number":"text";return i.html`
|
|
60
60
|
<pd-text-field
|
|
61
|
-
type=${
|
|
61
|
+
type=${o}
|
|
62
62
|
.value=${r!=null?String(r):""}
|
|
63
63
|
aria-label="${a.header}"
|
|
64
|
-
@change=${
|
|
65
|
-
@click=${
|
|
64
|
+
@change=${s=>this._handleCellChange(e,t,a,s)}
|
|
65
|
+
@click=${s=>s.stopPropagation()}
|
|
66
66
|
style="width: 100%;"
|
|
67
67
|
></pd-text-field>
|
|
68
68
|
`}_formatCurrency(e,t){const a=Number(e);if(e==null||isNaN(a))return String(e??"");const r=t||this.currencyCode;try{return a.toLocaleString(this.locale,{style:"currency",currency:r})}catch{return a.toLocaleString(this.locale)}}_formatNumber(e){const t=Number(e);return e==null||isNaN(t)?String(e??""):t.toLocaleString(this.locale)}_formatDate(e){if(e==null)return"";const t=e instanceof Date?e:new Date(String(e));return isNaN(t.getTime())?String(e):t.toLocaleDateString(this.locale)}_renderBoolean(e){const t=!!e;return i.html`
|
|
@@ -72,17 +72,17 @@
|
|
|
72
72
|
aria-label=${t?"Yes":"No"}
|
|
73
73
|
class=${g.classMap({"boolean-true":t,"boolean-false":!t})}
|
|
74
74
|
></pd-icon>
|
|
75
|
-
`}_isReactElement(e){return typeof e=="object"&&e!==null&&"$$typeof"in e}_renderReactCellContent(e,t){return i.html`<span style="display:contents" ${
|
|
75
|
+
`}_isReactElement(e){return typeof e=="object"&&e!==null&&"$$typeof"in e}_renderReactCellContent(e,t){return i.html`<span style="display:contents" ${y.ref(a=>{if(!a){this._reactRoots.get(t)?.unmount(),this._reactRoots.delete(t);return}const r=this._reactRoots.get(t);if(r){r.render(e);return}Promise.resolve().then(()=>require("../client-CjTRT4wy.cjs")).then(o=>o.client).then(({createRoot:o})=>{if(this._reactRoots.has(t))this._reactRoots.get(t).render(e);else{const s=o(a);s.render(e),this._reactRoots.set(t,{render:l=>s.render(l),unmount:()=>s.unmount()})}})})}></span>`}_renderRow(e,t,a){const r=this._getRowKey(e,a),o=this._selectedRowKeys.has(r),s=this._draggedRowIndex===t,l=this._dragOverRowIndex===t&&!s;return i.html`
|
|
76
76
|
<tr
|
|
77
77
|
role="row"
|
|
78
|
-
class=${g.classMap({selected:
|
|
79
|
-
aria-selected=${this.selectable?String(
|
|
78
|
+
class=${g.classMap({selected:o,draggable:this.draggableRows,dragging:s,"drag-over":l})}
|
|
79
|
+
aria-selected=${this.selectable?String(o):i.nothing}
|
|
80
80
|
draggable=${this.draggableRows?"true":"false"}
|
|
81
|
-
@dragstart=${
|
|
82
|
-
@dragover=${
|
|
83
|
-
@drop=${
|
|
84
|
-
@dragend=${
|
|
85
|
-
@click=${()=>this._handleRowClick(e,
|
|
81
|
+
@dragstart=${n=>this._onDragStart(n,t)}
|
|
82
|
+
@dragover=${n=>this._onDragOver(n,t)}
|
|
83
|
+
@drop=${n=>this._onDrop(n,t)}
|
|
84
|
+
@dragend=${n=>this._onDragEnd(n)}
|
|
85
|
+
@click=${()=>this._handleRowClick(e,a)}
|
|
86
86
|
>
|
|
87
87
|
${this.draggableRows?i.html`
|
|
88
88
|
<td class="drag-handle-cell" role="cell">
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
aria-label="Drag to reorder row. Use arrow keys to move up or down."
|
|
96
96
|
@mousedown=${this._handleDragHandleMouseDown}
|
|
97
97
|
@mouseup=${this._handleDragHandleMouseUp}
|
|
98
|
-
@keydown=${
|
|
98
|
+
@keydown=${n=>this._handleDragHandleKeyDown(n,t)}
|
|
99
99
|
></pd-icon>
|
|
100
100
|
</td>
|
|
101
101
|
`:i.nothing}
|
|
@@ -104,19 +104,19 @@
|
|
|
104
104
|
<td class="checkbox-cell" role="cell">
|
|
105
105
|
<pd-checkbox
|
|
106
106
|
aria-label="Select row"
|
|
107
|
-
?checked=${
|
|
108
|
-
@change=${
|
|
109
|
-
@click=${
|
|
107
|
+
?checked=${o}
|
|
108
|
+
@change=${n=>{const h=n.target;this._handleSelectRow(e,a,h.checked)}}
|
|
109
|
+
@click=${n=>n.stopPropagation()}
|
|
110
110
|
></pd-checkbox>
|
|
111
111
|
</td>
|
|
112
112
|
`:i.nothing}
|
|
113
113
|
|
|
114
|
-
${this.columns.map(
|
|
114
|
+
${this.columns.map(n=>i.html`
|
|
115
115
|
<td
|
|
116
116
|
role="cell"
|
|
117
|
-
class=${g.classMap({[`align-${this._getColumnAlignment(
|
|
117
|
+
class=${g.classMap({[`align-${this._getColumnAlignment(n)}`]:!0,editable:!!n.editable})}
|
|
118
118
|
>
|
|
119
|
-
${this._renderCell(e,
|
|
119
|
+
${this._renderCell(e,a,n)}
|
|
120
120
|
</td>
|
|
121
121
|
`)}
|
|
122
122
|
</tr>
|
|
@@ -141,7 +141,7 @@
|
|
|
141
141
|
</slot>
|
|
142
142
|
</td>
|
|
143
143
|
</tr>
|
|
144
|
-
`}_renderPagination(){if(!this.pagination)return i.nothing;const e=this._totalCount,t=e===0?0:this.pageIndex*this.pageSize+1,a=Math.min((this.pageIndex+1)*this.pageSize,e),r=this.pageIndex===0,
|
|
144
|
+
`}_renderPagination(){if(!this.pagination)return i.nothing;const e=this._totalCount,t=e===0?0:this.pageIndex*this.pageSize+1,a=Math.min((this.pageIndex+1)*this.pageSize,e),r=this.pageIndex===0,o=this.pageIndex>=this._totalPages-1||e===0;return i.html`
|
|
145
145
|
<nav class="pagination">
|
|
146
146
|
<div class="items-per-page">
|
|
147
147
|
<label id="page-size-label-${this._uniqueId}">Items per page:</label>
|
|
@@ -150,7 +150,7 @@
|
|
|
150
150
|
variant="filled"
|
|
151
151
|
aria-labelledby="page-size-label-${this._uniqueId}"
|
|
152
152
|
.value=${this.pageSize.toString()}
|
|
153
|
-
.options=${this.pageSizeOptions.map(
|
|
153
|
+
.options=${this.pageSizeOptions.map(s=>({value:String(s),label:String(s)}))}
|
|
154
154
|
@change=${this._handlePageSizeChange}
|
|
155
155
|
></pd-select>
|
|
156
156
|
</div>
|
|
@@ -177,13 +177,13 @@
|
|
|
177
177
|
<pd-icon-button
|
|
178
178
|
icon="chevron_right"
|
|
179
179
|
aria-label="Next page"
|
|
180
|
-
?disabled=${
|
|
180
|
+
?disabled=${o}
|
|
181
181
|
@click=${()=>this._handlePageChange(this.pageIndex+1)}
|
|
182
182
|
></pd-icon-button>
|
|
183
183
|
<pd-icon-button
|
|
184
184
|
icon="last_page"
|
|
185
185
|
aria-label="Last page"
|
|
186
|
-
?disabled=${
|
|
186
|
+
?disabled=${o}
|
|
187
187
|
@click=${()=>this._handlePageChange(this._totalPages-1)}
|
|
188
188
|
></pd-icon-button>
|
|
189
189
|
</div>
|
|
@@ -201,7 +201,7 @@
|
|
|
201
201
|
<tbody>
|
|
202
202
|
${this.loading?this._renderLoadingState():i.nothing}
|
|
203
203
|
${t?this._renderEmptyState():i.nothing}
|
|
204
|
-
${this.loading?i.nothing:
|
|
204
|
+
${this.loading?i.nothing:_.repeat(e,a=>{const r=this._displayToDataIndexMap.get(a)??this.data.indexOf(a);return this._getRowKey(a,r)},(a,r)=>{const o=this._displayToDataIndexMap.get(a)??this.data.indexOf(a);return this._renderRow(a,r,o)})}
|
|
205
205
|
</tbody>
|
|
206
206
|
</table>
|
|
207
207
|
</div>
|
|
@@ -367,7 +367,8 @@
|
|
|
367
367
|
}
|
|
368
368
|
|
|
369
369
|
tr.dragging {
|
|
370
|
-
opacity: 0.
|
|
370
|
+
opacity: 0.4;
|
|
371
|
+
z-index: 1;
|
|
371
372
|
}
|
|
372
373
|
|
|
373
374
|
tr.dragging td {
|
|
@@ -378,6 +379,11 @@
|
|
|
378
379
|
box-shadow: inset 0 2px 0 0 var(--md-sys-color-primary);
|
|
379
380
|
}
|
|
380
381
|
|
|
382
|
+
/* Rows use will-change during FLIP animation for GPU acceleration */
|
|
383
|
+
tr[role="row"] {
|
|
384
|
+
will-change: auto;
|
|
385
|
+
}
|
|
386
|
+
|
|
381
387
|
/* Column Drag States */
|
|
382
388
|
th.column-draggable {
|
|
383
389
|
cursor: grab;
|
|
@@ -554,4 +560,4 @@
|
|
|
554
560
|
justify-content: space-between;
|
|
555
561
|
}
|
|
556
562
|
}
|
|
557
|
-
`;
|
|
563
|
+
`;c([d.property({type:Array})],exports.PdTable.prototype,"columns",2);c([d.property({type:Array})],exports.PdTable.prototype,"data",2);c([d.property({attribute:!1})],exports.PdTable.prototype,"rowKey",2);c([d.property({type:Boolean})],exports.PdTable.prototype,"selectable",2);c([d.property({type:Boolean})],exports.PdTable.prototype,"sortable",2);c([d.property({type:Boolean})],exports.PdTable.prototype,"pagination",2);c([d.property({type:Number})],exports.PdTable.prototype,"pageSize",2);c([d.property({type:Number})],exports.PdTable.prototype,"pageIndex",2);c([d.property({type:Number})],exports.PdTable.prototype,"totalItems",2);c([d.property({type:Boolean,attribute:"draggable-rows"})],exports.PdTable.prototype,"draggableRows",2);c([d.property({type:Boolean,attribute:"draggable-columns"})],exports.PdTable.prototype,"draggableColumns",2);c([d.property({type:Boolean})],exports.PdTable.prototype,"loading",2);c([d.property({type:Boolean,attribute:"clear-selection-on-data-change"})],exports.PdTable.prototype,"clearSelectionOnDataChange",2);c([d.property({type:String,attribute:"currency-code"})],exports.PdTable.prototype,"currencyCode",2);c([d.property({type:String})],exports.PdTable.prototype,"locale",2);c([d.property({type:Array,attribute:"page-size-options"})],exports.PdTable.prototype,"pageSizeOptions",2);c([d.state()],exports.PdTable.prototype,"_sortColumn",2);c([d.state()],exports.PdTable.prototype,"_sortDirection",2);c([d.state()],exports.PdTable.prototype,"_selectedRowKeys",2);c([d.state()],exports.PdTable.prototype,"_draggedRowIndex",2);c([d.state()],exports.PdTable.prototype,"_dragOverRowIndex",2);c([d.state()],exports.PdTable.prototype,"_isDragHandleGrabbed",2);c([d.state()],exports.PdTable.prototype,"_draggedColumnIndex",2);c([d.state()],exports.PdTable.prototype,"_dragOverColumnIndex",2);exports.PdTable=c([d.customElement("pd-table")],exports.PdTable);
|