@govtechsg/sgds-web-component 3.29.1-rc.1 → 3.29.1-rc.3
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/components/Badge/badge.js +1 -1
- package/components/Badge/badge.js.map +1 -1
- package/components/Badge/index.umd.min.js +3 -3
- package/components/Badge/index.umd.min.js.map +1 -1
- package/components/Badge/sgds-badge.d.ts +1 -0
- package/components/Badge/sgds-badge.js +7 -2
- package/components/Badge/sgds-badge.js.map +1 -1
- package/components/ComboBox/index.umd.min.js +3 -3
- package/components/ComboBox/index.umd.min.js.map +1 -1
- package/components/DataTable/index.umd.min.js +1 -1
- package/components/DataTable/index.umd.min.js.map +1 -1
- package/components/DataTable/sgds-data-table.js +2 -15
- package/components/DataTable/sgds-data-table.js.map +1 -1
- package/components/Modal/index.umd.min.js +2 -2
- package/components/Modal/index.umd.min.js.map +1 -1
- package/components/Modal/sgds-modal.js +2 -2
- package/components/Modal/sgds-modal.js.map +1 -1
- package/components/index.umd.min.js +6 -6
- package/components/index.umd.min.js.map +1 -1
- package/custom-elements.json +8 -1
- package/index.umd.min.js +6 -6
- package/index.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/react/components/Badge/badge.cjs.js +1 -1
- package/react/components/Badge/badge.cjs.js.map +1 -1
- package/react/components/Badge/badge.js +1 -1
- package/react/components/Badge/badge.js.map +1 -1
- package/react/components/Badge/sgds-badge.cjs.js +7 -2
- package/react/components/Badge/sgds-badge.cjs.js.map +1 -1
- package/react/components/Badge/sgds-badge.js +7 -2
- package/react/components/Badge/sgds-badge.js.map +1 -1
- package/react/components/DataTable/sgds-data-table.cjs.js +2 -15
- package/react/components/DataTable/sgds-data-table.cjs.js.map +1 -1
- package/react/components/DataTable/sgds-data-table.js +2 -15
- package/react/components/DataTable/sgds-data-table.js.map +1 -1
- package/react/components/Modal/sgds-modal.cjs.js +2 -2
- package/react/components/Modal/sgds-modal.cjs.js.map +1 -1
- package/react/components/Modal/sgds-modal.js +2 -2
- package/react/components/Modal/sgds-modal.js.map +1 -1
package/custom-elements.json
CHANGED
|
@@ -2047,6 +2047,13 @@
|
|
|
2047
2047
|
],
|
|
2048
2048
|
"type": {}
|
|
2049
2049
|
},
|
|
2050
|
+
{
|
|
2051
|
+
"kind": "field",
|
|
2052
|
+
"name": "_closeButtonTone",
|
|
2053
|
+
"privacy": "private",
|
|
2054
|
+
"readonly": true,
|
|
2055
|
+
"type": {}
|
|
2056
|
+
},
|
|
2050
2057
|
{
|
|
2051
2058
|
"kind": "method",
|
|
2052
2059
|
"name": "_renderBadge",
|
|
@@ -31985,7 +31992,7 @@
|
|
|
31985
31992
|
"package": {
|
|
31986
31993
|
"name": "@govtechsg/sgds-web-component",
|
|
31987
31994
|
"description": "",
|
|
31988
|
-
"version": "3.29.1-rc.
|
|
31995
|
+
"version": "3.29.1-rc.3",
|
|
31989
31996
|
"author": "GovTechSG",
|
|
31990
31997
|
"license": "MIT"
|
|
31991
31998
|
}
|
package/index.umd.min.js
CHANGED
|
@@ -2419,7 +2419,7 @@ let Tt=Symbol.for(``),Et=e=>{if(e?.r===Tt)return e?._$litStatic$},Dt=(e,...t)=>(
|
|
|
2419
2419
|
<a class="alert-link" href=${D(em(this.href))} target=${D(this.target)} tabindex="0"
|
|
2420
2420
|
><slot></slot
|
|
2421
2421
|
></a>
|
|
2422
|
-
`}};w([b({type:String,reflect:!0})],rm.prototype,`href`,void 0),w([b()],rm.prototype,`target`,void 0),P(`sgds-alert`,$p),P(`sgds-alert-link`,rm),y();var im=l`:host{cursor:default;display:inline-flex;max-width:100%}:host([variant=accent]) .badge{background-color:var(--sgds-accent-surface-default)}:host([variant=success]) .badge{background-color:var(--sgds-success-surface-default)}:host([variant=danger]) .badge{background-color:var(--sgds-danger-surface-default)}:host([variant=warning]) .badge{background-color:var(--sgds-warning-surface-default);color:var(--sgds-color-fixed-dark)}:host([variant=cyan]) .badge{background-color:var(--sgds-cyan-surface-default)}:host([variant=purple]) .badge{background-color:var(--sgds-purple-surface-default)}:host([variant=neutral]) .badge{background-color:var(--sgds-neutral-surface-default)}:host([variant=white]) .badge{background-color:var(--sgds-surface-fixed-light);color:var(--sgds-color-fixed-dark)}:host([variant=accent][outlined]) .badge{background-color:var(--sgds-accent-surface-muted);border:var(--sgds-border-width-1) solid var(--sgds-accent-border-color-muted);color:var(--sgds-accent-color-
|
|
2422
|
+
`}};w([b({type:String,reflect:!0})],rm.prototype,`href`,void 0),w([b()],rm.prototype,`target`,void 0),P(`sgds-alert`,$p),P(`sgds-alert-link`,rm),y();var im=l`:host{cursor:default;display:inline-flex;max-width:100%}:host([variant=accent]) .badge{background-color:var(--sgds-accent-surface-default)}:host([variant=success]) .badge{background-color:var(--sgds-success-surface-default)}:host([variant=danger]) .badge{background-color:var(--sgds-danger-surface-default)}:host([variant=warning]) .badge{background-color:var(--sgds-warning-surface-default);color:var(--sgds-color-fixed-dark)}:host([variant=cyan]) .badge{background-color:var(--sgds-cyan-surface-default)}:host([variant=purple]) .badge{background-color:var(--sgds-purple-surface-default)}:host([variant=neutral]) .badge{background-color:var(--sgds-neutral-surface-default)}:host([variant=white]) .badge{background-color:var(--sgds-surface-fixed-light);color:var(--sgds-color-fixed-dark)}:host([variant=accent][outlined]) .badge{background-color:var(--sgds-accent-surface-muted);border:var(--sgds-border-width-1) solid var(--sgds-accent-border-color-muted);color:var(--sgds-accent-color-default)}:host([variant=success][outlined]) .badge{background-color:var(--sgds-success-surface-muted);border:var(--sgds-border-width-1) solid var(--sgds-success-border-color-muted);color:var(--sgds-success-color-default)}:host([variant=danger][outlined]) .badge{background-color:var(--sgds-danger-surface-muted);border:var(--sgds-border-width-1) solid var(--sgds-danger-border-color-muted);color:var(--sgds-danger-color-default)}:host([variant=warning][outlined]) .badge{background-color:var(--sgds-warning-surface-muted);border:var(--sgds-border-width-1) solid var(--sgds-warning-border-color-muted);color:var(--sgds-warning-color-default)}:host([variant=cyan][outlined]) .badge{background-color:var(--sgds-cyan-surface-muted);border:var(--sgds-border-width-1) solid var(--sgds-cyan-border-color-muted);color:var(--sgds-cyan-color-default)}:host([variant=purple][outlined]) .badge{background-color:var(--sgds-purple-surface-muted);border:var(--sgds-border-width-1) solid var(--sgds-purple-border-color-muted);color:var(--sgds-purple-color-default)}:host([variant=neutral][outlined]) .badge{background-color:var(--sgds-neutral-surface-muted);border:var(--sgds-border-width-1) solid var(--sgds-neutral-border-color-muted);color:var(--sgds-color-subtle)}:host([variant=white][outlined]) .badge{background-color:var(--sgds-surface-fixed-light);border:var(--sgds-border-width-1) solid var(--sgds-border-color-translucent);color:var(--sgds-color-fixed-dark)}sgds-tooltip{display:block;max-width:100%}.badge{align-items:center;background-color:var(--sgds-primary-surface-default);border:var(--sgds-border-width-1) solid var(--sgds-border-color-transparent);border-radius:var(--sgds-border-radius-sm);color:var(--sgds-color-fixed-light);display:inline-flex;font-size:var(--sgds-font-size-label-xs);height:var(--sgds-dimension-24,24px);justify-content:center;line-height:var(--sgds-line-height-3-xs);max-width:var(--sgds-dimension-192,192px);min-width:var(--sgds-dimension-24);padding:var(--sgds-padding-none) var(--sgds-padding-xs)}.badge.outlined{background-color:var(--sgds-primary-surface-muted);border:var(--sgds-border-width-1) solid var(--sgds-primary-border-color-muted);color:var(--sgds-primary-color-default)}.badge.full-width{max-width:100%}.badge-label{overflow:hidden;padding:var(--sgds-padding-none) var(--sgds-padding-3-xs);text-overflow:ellipsis;white-space:nowrap}.badge-dismissible{padding-right:0}.badge-dimissible sgds-close-button{--sgds-close-btn-border-radius:var(--sgds-border-radius-sm)}slot::slotted(*){color:inherit!important;font-size:inherit!important;font-weight:inherit!important;line-height:inherit!important;margin:inherit!important}`;Ze();
|
|
2423
2423
|
/**
|
|
2424
2424
|
* @license
|
|
2425
2425
|
* Copyright 2020 Google LLC
|
|
@@ -2440,7 +2440,7 @@ let n=e._$AN;if(n===void 0)return!1;for(let e of n)e._$AO?.(t,!1),hm(e,t);return
|
|
|
2440
2440
|
<slot @slotchange=${()=>this._handleSlotChange()}></slot>
|
|
2441
2441
|
${this.open?_`<div ${Tm(this._tooltipBubble)} class="tooltip" role="tooltip">${this.content}</div>`:null}
|
|
2442
2442
|
</div>
|
|
2443
|
-
`}};w([b({type:String})],Tg.prototype,`content`,void 0),w([b({type:String})],Tg.prototype,`placement`,void 0),w([b({type:String})],Tg.prototype,`trigger`,void 0),w([x()],Tg.prototype,`open`,void 0),w([C()],Tg.prototype,`_tooltipTargetElements`,void 0);var Eg=class{constructor(e,...t){this.slotNames=[],(this.host=e).addController(this),this.slotNames=t,this.handleSlotChange=this.handleSlotChange.bind(this)}hasDefaultSlot(){return[...this.host.childNodes].some(e=>{if(e.nodeType===e.TEXT_NODE&&e.textContent?.trim()!==``)return!0;if(e.nodeType===e.ELEMENT_NODE){let t=e;if(t.tagName.toLowerCase()===`sl-visually-hidden`)return!1;if(!t.hasAttribute(`slot`))return!0}return!1})}hasNamedSlot(e){return this.host.querySelector(`:scope > [slot="${e}"]`)!==null}test(e){return e===`[default]`?this.hasDefaultSlot():this.hasNamedSlot(e)}hostConnected(){this.host.shadowRoot?.addEventListener(`slotchange`,this.handleSlotChange)}hostDisconnected(){this.host.shadowRoot?.removeEventListener(`slotchange`,this.handleSlotChange)}handleSlotChange(e){let t=e.target;(this.slotNames.includes(`[default]`)&&!t.name||t.name&&this.slotNames.includes(t.name))&&this.host.requestUpdate()}};function Dg(e){if(!e)return``;let t=e.assignedNodes({flatten:!0}),n=``;return[...t].forEach(e=>{e.nodeType===Node.TEXT_NODE&&(n+=e.textContent.trim())}),n}y();var Og=class extends T{constructor(...e){super(...e),this.show=!1,this.variant=`primary`,this.outlined=!1,this.dismissible=!1,this.fullWidth=!1,this.truncated=!1,this.text=``}static{this.styles=[...T.styles,im]}static{this.dependencies={"sgds-close-button":At,"sgds-tooltip":Tg}}close(){this.show=!1}_handleShowChange(){if(this.show){if(this.emit(`sgds-show`,{cancelable:!0}).defaultPrevented){this.show=!1;return}this.emit(`sgds-after-show`)}else{if(this.emit(`sgds-hide`,{cancelable:!0}).defaultPrevented){this.show=!0;return}this.emit(`sgds-after-hide`)}}_handleTruncation(){let e=this.shadowRoot?.querySelector(`.badge-label`);e&&(this.truncated=e.scrollWidth>e.clientWidth)}_handleLabelSlotChange(e){this.text=Dg(e.target)}
|
|
2443
|
+
`}};w([b({type:String})],Tg.prototype,`content`,void 0),w([b({type:String})],Tg.prototype,`placement`,void 0),w([b({type:String})],Tg.prototype,`trigger`,void 0),w([x()],Tg.prototype,`open`,void 0),w([C()],Tg.prototype,`_tooltipTargetElements`,void 0);var Eg=class{constructor(e,...t){this.slotNames=[],(this.host=e).addController(this),this.slotNames=t,this.handleSlotChange=this.handleSlotChange.bind(this)}hasDefaultSlot(){return[...this.host.childNodes].some(e=>{if(e.nodeType===e.TEXT_NODE&&e.textContent?.trim()!==``)return!0;if(e.nodeType===e.ELEMENT_NODE){let t=e;if(t.tagName.toLowerCase()===`sl-visually-hidden`)return!1;if(!t.hasAttribute(`slot`))return!0}return!1})}hasNamedSlot(e){return this.host.querySelector(`:scope > [slot="${e}"]`)!==null}test(e){return e===`[default]`?this.hasDefaultSlot():this.hasNamedSlot(e)}hostConnected(){this.host.shadowRoot?.addEventListener(`slotchange`,this.handleSlotChange)}hostDisconnected(){this.host.shadowRoot?.removeEventListener(`slotchange`,this.handleSlotChange)}handleSlotChange(e){let t=e.target;(this.slotNames.includes(`[default]`)&&!t.name||t.name&&this.slotNames.includes(t.name))&&this.host.requestUpdate()}};function Dg(e){if(!e)return``;let t=e.assignedNodes({flatten:!0}),n=``;return[...t].forEach(e=>{e.nodeType===Node.TEXT_NODE&&(n+=e.textContent.trim())}),n}y();var Og=class extends T{constructor(...e){super(...e),this.show=!1,this.variant=`primary`,this.outlined=!1,this.dismissible=!1,this.fullWidth=!1,this.truncated=!1,this.text=``}static{this.styles=[...T.styles,im]}static{this.dependencies={"sgds-close-button":At,"sgds-tooltip":Tg}}close(){this.show=!1}_handleShowChange(){if(this.show){if(this.emit(`sgds-show`,{cancelable:!0}).defaultPrevented){this.show=!1;return}this.emit(`sgds-after-show`)}else{if(this.emit(`sgds-hide`,{cancelable:!0}).defaultPrevented){this.show=!0;return}this.emit(`sgds-after-hide`)}}_handleTruncation(){let e=this.shadowRoot?.querySelector(`.badge-label`);e&&(this.truncated=e.scrollWidth>e.clientWidth)}_handleLabelSlotChange(e){this.text=Dg(e.target)}get _closeButtonTone(){return this.variant===`white`?`fixed-dark`:this.outlined?`default`:this.variant===`warning`?`fixed-dark`:`fixed-light`}_renderBadge(){return _`<div
|
|
2444
2444
|
class="
|
|
2445
2445
|
${E({"badge-dismissible":this.dismissible,badge:!0,outlined:this.outlined,"full-width":this.fullWidth})}"
|
|
2446
2446
|
aria-hidden=${this.show?`false`:`true`}
|
|
@@ -2455,7 +2455,7 @@ let n=e._$AN;if(n===void 0)return!1;for(let e of n)e._$AO?.(t,!1),hm(e,t);return
|
|
|
2455
2455
|
size="sm"
|
|
2456
2456
|
aria-label="close the badge"
|
|
2457
2457
|
@click=${this.close}
|
|
2458
|
-
tone=${
|
|
2458
|
+
tone=${this._closeButtonTone}
|
|
2459
2459
|
></sgds-close-button>`:v}
|
|
2460
2460
|
</div>`}render(){return this.dismissible&&this.show||!this.dismissible?this.truncated?_`<sgds-tooltip content=${this.text} @sgds-hide=${e=>e.stopPropagation()}
|
|
2461
2461
|
>${this._renderBadge()}</sgds-tooltip
|
|
@@ -3592,9 +3592,9 @@ super(`context-provider`,{bubbles:!0,composed:!0}),this.context=e,this.contextTa
|
|
|
3592
3592
|
<slot name="description"></slot>
|
|
3593
3593
|
</div>
|
|
3594
3594
|
</div>
|
|
3595
|
-
<
|
|
3595
|
+
<section class="modal-body" tabindex="0" aria-label="Modal body content">
|
|
3596
3596
|
<slot></slot>
|
|
3597
|
-
</
|
|
3597
|
+
</section>
|
|
3598
3598
|
</div class="modal-content">
|
|
3599
3599
|
<div class="modal-footer">
|
|
3600
3600
|
<slot name="footer"></slot>
|
|
@@ -4550,7 +4550,7 @@ super(`context-provider`,{bubbles:!0,composed:!0}),this.context=e,this.contextTa
|
|
|
4550
4550
|
:host {
|
|
4551
4551
|
display: block;
|
|
4552
4552
|
}
|
|
4553
|
-
`]}static{this.dependencies={"sgds-pagination":Zv,"sgds-data-table-cell":Sb,"sgds-data-table-head":Cb,"sgds-skeleton":py}}connectedCallback(){super.connectedCallback()}_isRowChecked(e){return e.checked||e.checkbox?.checked===!0}_updateHeaderCheckbox(){let e=this.tableRows.filter(e=>this._isRowChecked(e)).length,t=e===this.tableRows.length&&e>0;this.headerRows.forEach(n=>{n.checked=t,n.checkbox&&(n.checkbox.checked=t,n.checkbox.indeterminate=e>0&&!t)})}async _syncHeaderCheckboxAfterRender(){if(!this.multiSelect||this.headerRows.length===0)return;let e=[...this.headerRows,...this.tableRows];await Promise.all(e.map(e=>e.updateComplete)),this._updateHeaderCheckbox()}_emitRowSelect(){let e=this.tableRows.filter(e=>this._isRowChecked(e)).map(e=>this._getRowData(e));this.emit(`sgds-row-select`,{detail:{selected:e}})}_attachRowListener(e){let t=this._rowHandlers.get(e);t&&e.removeEventListener(`i-sgds-change`,t);let n=t=>{let{checked:n}=t.detail;this.headerRows.includes(e)?this.tableRows.forEach(e=>{e.checked=n,e.checkbox&&(e.checkbox.checked=n)}):(e.checked=n,this._updateHeaderCheckbox()),this._emitRowSelect()};this._rowHandlers.set(e,n),e.addEventListener(`i-sgds-change`,n)}_configureRows(){let e=this.tableRows.some(e=>e.expand),t=this.tableRows.length>0;this.headerRows.forEach(n=>{n.showCheckbox=this.multiSelect,n.showExpandPlaceholder=e,n.hasDataRows=t,this.multiSelect&&this._attachRowListener(n)}),this.tableRows.forEach(t=>{t.showCheckbox=this.multiSelect,t.showExpandPlaceholder=!t.expand&&e,this.multiSelect&&this._attachRowListener(t)}),this.multiSelect&&this._syncHeaderCheckboxAfterRender(),this._applyColumnAlignment()}_applyColumnAlignment(){let e=this._headerCells.reduce((e,t)=>{let n=Number(t.colSpan)>0?Number(t.colSpan):1,r=t.textAlign??`left`;for(let t=0;t<n;t++)e.push(r);return e},[]);this.headerRows.forEach(t=>{t.columnAlignments=[...e]}),this.tableRows.forEach(t=>{t.columnAlignments=[...e]})}_extractCellText(e,t){return e.getCellText(t)||(Array.from(e.children).filter(e=>e.tagName.toLowerCase()===`sgds-data-table-cell`)[t]?.textContent||``).trim()}_getRowData(e){let t={};return this._headerCells.forEach((n,r)=>{let i=n.sortKey||(n.textContent??``).trim()||`col-${r}`;t[i]=this._extractCellText(e,r)}),t}_toComparableValue(e,t,n){return this._extractCellText(e,n)}_compareValues(e,t,n){if(e===t)return 0;let r=Number(e),i=Number(t);if(Number.isFinite(r)&&Number.isFinite(i))return n===`ascending`?r-i:i-r;let a=String(e).localeCompare(String(t),void 0,{numeric:!0,sensitivity:`base`});return n===`ascending`?a:-a}_resetOtherHeaderSortStates(e){this._headerCells.forEach(t=>{t!==e&&t.sorting&&(t.sortDirection=`none`)})}_getRowsInInitialPositionOrder(e){return[...e].sort((e,t)=>{let n=this._initialRowPositions.get(e),r=this._initialRowPositions.get(t);return n===void 0&&r===void 0?0:n===void 0?1:r===void 0?-1:n-r})}_captureInitialRowPositions(e){this._hasCapturedInitialRowPositions||=(e.forEach((e,t)=>{this._initialRowPositions.set(e,t)}),!0)}_handleSort(e){let t=e.composedPath().find(e=>e instanceof Cb);if(!t||!t.sorting)return;let{key:n,direction:r}=e.detail,i=t?this._headerCells.indexOf(t):-1;if(this._resetOtherHeaderSortStates(t),this.serverSort){e.stopPropagation(),this.emit(`sgds-sort`,{detail:{key:n,direction:r}});return}if(!(i<0)){if(r===`none`){this.tableRows=this._getRowsInInitialPositionOrder(this.tableRows),this.
|
|
4553
|
+
`]}static{this.dependencies={"sgds-pagination":Zv,"sgds-data-table-cell":Sb,"sgds-data-table-head":Cb,"sgds-skeleton":py}}connectedCallback(){super.connectedCallback()}_isRowChecked(e){return e.checked||e.checkbox?.checked===!0}_updateHeaderCheckbox(){let e=this.tableRows.filter(e=>this._isRowChecked(e)).length,t=e===this.tableRows.length&&e>0;this.headerRows.forEach(n=>{n.checked=t,n.checkbox&&(n.checkbox.checked=t,n.checkbox.indeterminate=e>0&&!t)})}async _syncHeaderCheckboxAfterRender(){if(!this.multiSelect||this.headerRows.length===0)return;let e=[...this.headerRows,...this.tableRows];await Promise.all(e.map(e=>e.updateComplete)),this._updateHeaderCheckbox()}_emitRowSelect(){let e=this.tableRows.filter(e=>this._isRowChecked(e)).map(e=>this._getRowData(e));this.emit(`sgds-row-select`,{detail:{selected:e}})}_attachRowListener(e){let t=this._rowHandlers.get(e);t&&e.removeEventListener(`i-sgds-change`,t);let n=t=>{let{checked:n}=t.detail;this.headerRows.includes(e)?this.tableRows.forEach(e=>{e.checked=n,e.checkbox&&(e.checkbox.checked=n)}):(e.checked=n,this._updateHeaderCheckbox()),this._emitRowSelect()};this._rowHandlers.set(e,n),e.addEventListener(`i-sgds-change`,n)}_configureRows(){let e=this.tableRows.some(e=>e.expand),t=this.tableRows.length>0;this.headerRows.forEach(n=>{n.showCheckbox=this.multiSelect,n.showExpandPlaceholder=e,n.hasDataRows=t,this.multiSelect&&this._attachRowListener(n)}),this.tableRows.forEach(t=>{t.showCheckbox=this.multiSelect,t.showExpandPlaceholder=!t.expand&&e,this.multiSelect&&this._attachRowListener(t)}),this.multiSelect&&this._syncHeaderCheckboxAfterRender(),this._applyColumnAlignment()}_applyColumnAlignment(){let e=this._headerCells.reduce((e,t)=>{let n=Number(t.colSpan)>0?Number(t.colSpan):1,r=t.textAlign??`left`;for(let t=0;t<n;t++)e.push(r);return e},[]);this.headerRows.forEach(t=>{t.columnAlignments=[...e]}),this.tableRows.forEach(t=>{t.columnAlignments=[...e]})}_extractCellText(e,t){return e.getCellText(t)||(Array.from(e.children).filter(e=>e.tagName.toLowerCase()===`sgds-data-table-cell`)[t]?.textContent||``).trim()}_getRowData(e){let t={};return this._headerCells.forEach((n,r)=>{let i=n.sortKey||(n.textContent??``).trim()||`col-${r}`;t[i]=this._extractCellText(e,r)}),t}_toComparableValue(e,t,n){return this._extractCellText(e,n)}_compareValues(e,t,n){if(e===t)return 0;let r=Number(e),i=Number(t);if(Number.isFinite(r)&&Number.isFinite(i))return n===`ascending`?r-i:i-r;let a=String(e).localeCompare(String(t),void 0,{numeric:!0,sensitivity:`base`});return n===`ascending`?a:-a}_resetOtherHeaderSortStates(e){this._headerCells.forEach(t=>{t!==e&&t.sorting&&(t.sortDirection=`none`)})}_getRowsInInitialPositionOrder(e){return[...e].sort((e,t)=>{let n=this._initialRowPositions.get(e),r=this._initialRowPositions.get(t);return n===void 0&&r===void 0?0:n===void 0?1:r===void 0?-1:n-r})}_captureInitialRowPositions(e){this._hasCapturedInitialRowPositions||=(e.forEach((e,t)=>{this._initialRowPositions.set(e,t)}),!0)}_handleSort(e){let t=e.composedPath().find(e=>e instanceof Cb);if(!t||!t.sorting)return;let{key:n,direction:r}=e.detail,i=t?this._headerCells.indexOf(t):-1;if(this._resetOtherHeaderSortStates(t),this.serverSort){e.stopPropagation(),this.emit(`sgds-sort`,{detail:{key:n,direction:r}});return}if(!(i<0)){if(r===`none`){this.tableRows=this._getRowsInInitialPositionOrder(this.tableRows),this.mode===`client`&&(this.currentPage=1),this._syncDomRowOrder(),this._updateVisibleRows();return}this.tableRows=[...this.tableRows].sort((e,t)=>{let a=this._toComparableValue(e,n,i),o=this._toComparableValue(t,n,i);return this._compareValues(a,o,r)}),this.mode===`client`&&(this.currentPage=1),this._syncDomRowOrder(),this._updateVisibleRows()}}_syncDomRowOrder(){let e=this.tableRows[0]?.parentElement;e&&this.tableRows.forEach(t=>e.appendChild(t))}_handleSlotChange(e){let t=e.target.assignedElements({flatten:!0}).filter(e=>e instanceof wb),n=e=>Array.from(e.children).filter(e=>{let t=e.tagName.toLowerCase();return t!==`sgds-data-table-cell`&&t!==`sgds-data-table-head`?!1:e.getAttribute(`slot`)!==`content`});this.headerRows=t.filter(e=>n(e).some(e=>e.tagName.toLowerCase()===`sgds-data-table-head`)),this.tableRows=t.filter(e=>{let t=n(e);return t.length>0&&t.every(e=>e.tagName.toLowerCase()===`sgds-data-table-cell`)}),this._headerCells=this.headerRows.reduce((e,t)=>{let n=Array.from(t.children).filter(e=>e instanceof Cb);return e.push(...n),e},[]),this._captureInitialRowPositions(this.tableRows),this._headerCells.forEach(e=>{e.sorting&&!e.sortDirection&&(e.sortDirection=`none`)}),this._configureRows(),this._updateVisibleRows()}_updateVisibleRows(){if(this.loading){this.tableRows.forEach(e=>e.style.display=`none`);return}if(this.mode===`server`){this.tableRows.forEach(e=>e.style.display=``);return}let e=this.dataLength||this.tableRows.length,t=Math.max(1,Math.ceil(e/this.itemsPerPage));if(this.currentPage>t){this.currentPage=t;return}let n=(this.currentPage-1)*this.itemsPerPage,r=new Set(this.tableRows.slice(n,n+this.itemsPerPage));this.tableRows.forEach(e=>e.style.display=r.has(e)?``:`none`)}_getSkeletonColumnCount(){let e=this._headerCells.reduce((e,t)=>e+(Number(t.colSpan)>0?Number(t.colSpan):1),0),t=this.tableRows[0],n=t?Array.from(t.children).filter(e=>e instanceof Sb).length:0,r=this.tableRows.some(e=>e.expand);return{dataColumns:e||n||1,hasExpand:r,hasCheckbox:this.multiSelect}}_renderLoadingSkeleton(){let{dataColumns:e,hasExpand:t,hasCheckbox:n}=this._getSkeletonColumnCount(),r=Math.max(1,this.itemsPerPage||1);return Array.from({length:r},()=>_`<div class="skeleton-row" role="presentation">
|
|
4554
4554
|
${t?_`<div class="skeleton-cell control-cell">
|
|
4555
4555
|
<sgds-skeleton .height=${`20px`} .width=${`20px`} .borderRadius=${`4px`}></sgds-skeleton>
|
|
4556
4556
|
</div>`:v}
|