@kubex/zinc 1.1.66 → 1.1.67
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/custom-elements.json +7 -3
- package/dist/vscode.html-custom-data.json +1 -1
- package/dist/web-types.json +6 -2
- package/dist/zn.d.ts +1 -0
- package/dist/zn.min.js +10 -2
- package/package.json +1 -1
- package/src/components/data-table/data-table.component.ts +19 -1
- package/src/components/data-table/data-table.test.ts +46 -0
|
@@ -7860,6 +7860,10 @@
|
|
|
7860
7860
|
{
|
|
7861
7861
|
"description": "Slot for custom empty state.",
|
|
7862
7862
|
"name": "empty-state"
|
|
7863
|
+
},
|
|
7864
|
+
{
|
|
7865
|
+
"description": "Slot for a custom no-results state, shown when a search on a no-initial-load table returns no rows.",
|
|
7866
|
+
"name": "no-results"
|
|
7863
7867
|
}
|
|
7864
7868
|
],
|
|
7865
7869
|
"members": [
|
|
@@ -8213,7 +8217,7 @@
|
|
|
8213
8217
|
"kind": "field",
|
|
8214
8218
|
"name": "hasSlotController",
|
|
8215
8219
|
"privacy": "private",
|
|
8216
|
-
"default": "new HasSlotController( this, '[default]', ActionSlots.search.valueOf(), ActionSlots.delete.valueOf(), ActionSlots.modify.valueOf(), ActionSlots.create.valueOf(), ActionSlots.filter.valueOf(), ActionSlots.sort.valueOf(), ActionSlots.inputs.valueOf(), 'empty-state' )"
|
|
8220
|
+
"default": "new HasSlotController( this, '[default]', ActionSlots.search.valueOf(), ActionSlots.delete.valueOf(), ActionSlots.modify.valueOf(), ActionSlots.create.valueOf(), ActionSlots.filter.valueOf(), ActionSlots.sort.valueOf(), ActionSlots.inputs.valueOf(), 'empty-state', 'no-results' )"
|
|
8217
8221
|
},
|
|
8218
8222
|
{
|
|
8219
8223
|
"kind": "field",
|
|
@@ -8994,7 +8998,7 @@
|
|
|
8994
8998
|
"tagNameWithoutPrefix": "data-table",
|
|
8995
8999
|
"tagName": "zn-data-table",
|
|
8996
9000
|
"customElement": true,
|
|
8997
|
-
"jsDoc": "/**\n * @summary Short summary of the component's intended use.\n * @documentation https://zinc.style/components/data-table\n * @status experimental\n * @since 1.0\n *\n * @dependency zn-alert\n * @dependency zn-button\n * @dependency zn-empty-state\n * @dependency zn-chip\n * @dependency zn-hover-container\n * @dependency zn-dropdown\n * @dependency zn-menu\n * @dependency zn-menu-item\n * @dependency zn-button-group\n * @dependency zn-confirm\n * @dependency zn-skeleton\n * @dependency zn-data-table-search\n *\n * @slot - The default slot.\n * @slot search - Slot for search component.\n * @slot sort - Slot for sort component.\n * @slot filter - Slot for filter component.\n * @slot filter-top - Slot for top-level filter component.\n * @slot delete-action - Slot for delete action button.\n * @slot modify-action - Slot for modify action button.\n * @slot create-action - Slot for create action button.\n * @slot inputs - Slot for additional input controls.\n * @slot empty-state - Slot for custom empty state.\n *\n * @csspart base - The component's base wrapper.\n *\n * @cssproperty --example - An example CSS custom property.\n */",
|
|
9001
|
+
"jsDoc": "/**\n * @summary Short summary of the component's intended use.\n * @documentation https://zinc.style/components/data-table\n * @status experimental\n * @since 1.0\n *\n * @dependency zn-alert\n * @dependency zn-button\n * @dependency zn-empty-state\n * @dependency zn-chip\n * @dependency zn-hover-container\n * @dependency zn-dropdown\n * @dependency zn-menu\n * @dependency zn-menu-item\n * @dependency zn-button-group\n * @dependency zn-confirm\n * @dependency zn-skeleton\n * @dependency zn-data-table-search\n *\n * @slot - The default slot.\n * @slot search - Slot for search component.\n * @slot sort - Slot for sort component.\n * @slot filter - Slot for filter component.\n * @slot filter-top - Slot for top-level filter component.\n * @slot delete-action - Slot for delete action button.\n * @slot modify-action - Slot for modify action button.\n * @slot create-action - Slot for create action button.\n * @slot inputs - Slot for additional input controls.\n * @slot empty-state - Slot for custom empty state.\n * @slot no-results - Slot for a custom no-results state, shown when a search on a no-initial-load table returns no rows.\n *\n * @csspart base - The component's base wrapper.\n *\n * @cssproperty --example - An example CSS custom property.\n */",
|
|
8998
9002
|
"documentation": "https://zinc.style/components/data-table",
|
|
8999
9003
|
"status": "experimental",
|
|
9000
9004
|
"since": "1.0",
|
|
@@ -42310,7 +42314,7 @@
|
|
|
42310
42314
|
"package": {
|
|
42311
42315
|
"name": "@kubex/zinc",
|
|
42312
42316
|
"description": "A collection of web components for building web applications based off of @shoelace-style/Shoelace",
|
|
42313
|
-
"version": "1.1.
|
|
42317
|
+
"version": "1.1.67",
|
|
42314
42318
|
"author": "",
|
|
42315
42319
|
"license": "MIT"
|
|
42316
42320
|
}
|
|
@@ -1079,7 +1079,7 @@
|
|
|
1079
1079
|
},
|
|
1080
1080
|
{
|
|
1081
1081
|
"name": "zn-data-table",
|
|
1082
|
-
"description": "Short summary of the component's intended use.\n---\n\n\n### **Slots:**\n - _default_ - The default slot.\n- **search** - Slot for search component.\n- **sort** - Slot for sort component.\n- **filter** - Slot for filter component.\n- **filter-top** - Slot for top-level filter component.\n- **delete-action** - Slot for delete action button.\n- **modify-action** - Slot for modify action button.\n- **create-action** - Slot for create action button.\n- **inputs** - Slot for additional input controls.\n- **empty-state** - Slot for custom empty state.\n\n### **CSS Properties:**\n - **--example** - An example CSS custom property. _(default: undefined)_\n\n### **CSS Parts:**\n - **base** - The component's base wrapper.",
|
|
1082
|
+
"description": "Short summary of the component's intended use.\n---\n\n\n### **Slots:**\n - _default_ - The default slot.\n- **search** - Slot for search component.\n- **sort** - Slot for sort component.\n- **filter** - Slot for filter component.\n- **filter-top** - Slot for top-level filter component.\n- **delete-action** - Slot for delete action button.\n- **modify-action** - Slot for modify action button.\n- **create-action** - Slot for create action button.\n- **inputs** - Slot for additional input controls.\n- **empty-state** - Slot for custom empty state.\n- **no-results** - Slot for a custom no-results state, shown when a search on a no-initial-load table returns no rows.\n\n### **CSS Properties:**\n - **--example** - An example CSS custom property. _(default: undefined)_\n\n### **CSS Parts:**\n - **base** - The component's base wrapper.",
|
|
1083
1083
|
"attributes": [
|
|
1084
1084
|
{ "name": "data-uri", "values": [] },
|
|
1085
1085
|
{ "name": "data", "values": [{ "name": "Row[]" }, { "name": "Row" }] },
|
package/dist/web-types.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://raw.githubusercontent.com/JetBrains/web-types/master/schema/web-types.json",
|
|
3
3
|
"name": "@kubex/zinc",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.67",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"contributions": {
|
|
7
7
|
"html": {
|
|
@@ -2411,7 +2411,7 @@
|
|
|
2411
2411
|
},
|
|
2412
2412
|
{
|
|
2413
2413
|
"name": "zn-data-table",
|
|
2414
|
-
"description": "Short summary of the component's intended use.\n---\n\n\n### **Slots:**\n - _default_ - The default slot.\n- **search** - Slot for search component.\n- **sort** - Slot for sort component.\n- **filter** - Slot for filter component.\n- **filter-top** - Slot for top-level filter component.\n- **delete-action** - Slot for delete action button.\n- **modify-action** - Slot for modify action button.\n- **create-action** - Slot for create action button.\n- **inputs** - Slot for additional input controls.\n- **empty-state** - Slot for custom empty state.\n\n### **CSS Properties:**\n - **--example** - An example CSS custom property. _(default: undefined)_\n\n### **CSS Parts:**\n - **base** - The component's base wrapper.",
|
|
2414
|
+
"description": "Short summary of the component's intended use.\n---\n\n\n### **Slots:**\n - _default_ - The default slot.\n- **search** - Slot for search component.\n- **sort** - Slot for sort component.\n- **filter** - Slot for filter component.\n- **filter-top** - Slot for top-level filter component.\n- **delete-action** - Slot for delete action button.\n- **modify-action** - Slot for modify action button.\n- **create-action** - Slot for create action button.\n- **inputs** - Slot for additional input controls.\n- **empty-state** - Slot for custom empty state.\n- **no-results** - Slot for a custom no-results state, shown when a search on a no-initial-load table returns no rows.\n\n### **CSS Properties:**\n - **--example** - An example CSS custom property. _(default: undefined)_\n\n### **CSS Parts:**\n - **base** - The component's base wrapper.",
|
|
2415
2415
|
"doc-url": "",
|
|
2416
2416
|
"attributes": [
|
|
2417
2417
|
{ "name": "data-uri", "value": { "type": "string" } },
|
|
@@ -2523,6 +2523,10 @@
|
|
|
2523
2523
|
{
|
|
2524
2524
|
"name": "empty-state",
|
|
2525
2525
|
"description": "Slot for custom empty state."
|
|
2526
|
+
},
|
|
2527
|
+
{
|
|
2528
|
+
"name": "no-results",
|
|
2529
|
+
"description": "Slot for a custom no-results state, shown when a search on a no-initial-load table returns no rows."
|
|
2526
2530
|
}
|
|
2527
2531
|
],
|
|
2528
2532
|
"events": [],
|
package/dist/zn.d.ts
CHANGED
|
@@ -3526,6 +3526,7 @@ declare module "components/data-table/data-table.component" {
|
|
|
3526
3526
|
* @slot create-action - Slot for create action button.
|
|
3527
3527
|
* @slot inputs - Slot for additional input controls.
|
|
3528
3528
|
* @slot empty-state - Slot for custom empty state.
|
|
3529
|
+
* @slot no-results - Slot for a custom no-results state, shown when a search on a no-initial-load table returns no rows.
|
|
3529
3530
|
*
|
|
3530
3531
|
* @csspart base - The component's base wrapper.
|
|
3531
3532
|
*
|
package/dist/zn.min.js
CHANGED
|
@@ -653,7 +653,7 @@ import{a as Cn,b as i_,c as sr,d as c,e as F}from"./chunks/zn.UBLZO6CI.js";var Q
|
|
|
653
653
|
<div class="table__collum--datetime">
|
|
654
654
|
<span><strong>${o.slice(0,10)}</strong></span>
|
|
655
655
|
<zn-style size="s" muted>${o.slice(11)}</zn-style>
|
|
656
|
-
</div>`})},yt=class extends C{constructor(){super(...arguments);this.data=[];this.sortDirection="asc";this.localSort=!1;this.filter="";this.search="";this.key="id";this.headers={};this.displayTemplates={};this.hiddenHeaders="{}";this.hiddenColumns="{}";this.unsortableHeaders="{}";this.unsortable=!1;this.standalone=!1;this.emptyStateIcon="data_alert";this.filters=[];this.method="POST";this.noInitialLoad=!1;this.groupBy="";this.groups="";this.itemsPerPage=Hh;this._initialLoad=!0;this._hasLoadedData=!1;this._lastLoadHadRows=!1;this._lastTableContent=u``;this.resizeObserver=new Jt(this,{target:null,callback:()=>{this.tableContainer&&this.tableContainer.scrollIntoView({behavior:"smooth",block:"nearest"})}});this.page=Xb;this._rows=[];this.numberOfRowsSelected=0;this.selectedRows=[];this.hasSlotController=new Q(this,"[default]","search".valueOf(),"delete-action".valueOf(),"modify-action".valueOf(),"create-action".valueOf(),"filter".valueOf(),"sort".valueOf(),"inputs".valueOf(),"empty-state");this._dataTask=new al(this,{task:async([t,r],{signal:n})=>{if(t===void 0||this.noInitialLoad&&this._initialLoad)return{rows:[],page:1,perPage:this.itemsPerPage,total:0};this.groupBy&&(this.itemsPerPage=1e3);let a={page:this.page,perPage:this.itemsPerPage,sortColumn:this.sortColumn,sortDirection:this.sortDirection,filter:this.filter,search:this.search},s=this.hasSlotController.getSlots("inputs".valueOf()),l={};s&&(s.forEach(h=>{if(["zn-input","zn-select","zn-query-builder","zn-multiselect","zn-params-select","zn-datepicker","input","select","textarea"].includes(h.tagName.toLowerCase())){let f=h.value||h.getAttribute("value"),b=h.name||h.getAttribute("name");b&&(l[b]=f)}}),Object.assign(a,l)),r&&typeof r=="object"&&Object.assign(a,r);let d=await fetch(t,{method:this.method,headers:{"x-kx-fetch-style":"zn-data-table"},signal:n,credentials:"same-origin",body:this.method==="POST"?JSON.stringify(a):void 0});if(!d.ok)throw new Error(d.statusText);return d.json()},args:()=>[this.dataUri,this.requestParams]});this.rowHasActions=!1;this._expandedRows=new Set;this._hiddenCells=new Map;this._formatTemplates=Qk;this.requestParams={};this.filterChangeListener=t=>{t.target instanceof Lh&&(this.filter=t.target.value,this._dataTask.run().then(r=>r))};this.searchChangeListener=t=>{let r=t.target;if(r&&r.tagName==="ZN-DATA-TABLE-SEARCH"){if(this.search=r.value,t.detail){let{formData:n,searchUri:a}=t.detail;if(n&&typeof n=="object"&&(this.requestParams={...this.requestParams,...n}),a){let s=this.dataUri;this.dataUri=a,this._dataTask.run().then(()=>{this.dataUri=s});return}}this._dataTask.run().then(n=>n)}}}refresh(){this._initialLoad=!1,this._dataTask.run().then(t=>t)}render(){let t=u``;if(this.noInitialLoad&&this._initialLoad)t=u`
|
|
656
|
+
</div>`})},yt=class extends C{constructor(){super(...arguments);this.data=[];this.sortDirection="asc";this.localSort=!1;this.filter="";this.search="";this.key="id";this.headers={};this.displayTemplates={};this.hiddenHeaders="{}";this.hiddenColumns="{}";this.unsortableHeaders="{}";this.unsortable=!1;this.standalone=!1;this.emptyStateIcon="data_alert";this.filters=[];this.method="POST";this.noInitialLoad=!1;this.groupBy="";this.groups="";this.itemsPerPage=Hh;this._initialLoad=!0;this._hasLoadedData=!1;this._lastLoadHadRows=!1;this._lastTableContent=u``;this.resizeObserver=new Jt(this,{target:null,callback:()=>{this.tableContainer&&this.tableContainer.scrollIntoView({behavior:"smooth",block:"nearest"})}});this.page=Xb;this._rows=[];this.numberOfRowsSelected=0;this.selectedRows=[];this.hasSlotController=new Q(this,"[default]","search".valueOf(),"delete-action".valueOf(),"modify-action".valueOf(),"create-action".valueOf(),"filter".valueOf(),"sort".valueOf(),"inputs".valueOf(),"empty-state","no-results");this._dataTask=new al(this,{task:async([t,r],{signal:n})=>{if(t===void 0||this.noInitialLoad&&this._initialLoad)return{rows:[],page:1,perPage:this.itemsPerPage,total:0};this.groupBy&&(this.itemsPerPage=1e3);let a={page:this.page,perPage:this.itemsPerPage,sortColumn:this.sortColumn,sortDirection:this.sortDirection,filter:this.filter,search:this.search},s=this.hasSlotController.getSlots("inputs".valueOf()),l={};s&&(s.forEach(h=>{if(["zn-input","zn-select","zn-query-builder","zn-multiselect","zn-params-select","zn-datepicker","input","select","textarea"].includes(h.tagName.toLowerCase())){let f=h.value||h.getAttribute("value"),b=h.name||h.getAttribute("name");b&&(l[b]=f)}}),Object.assign(a,l)),r&&typeof r=="object"&&Object.assign(a,r);let d=await fetch(t,{method:this.method,headers:{"x-kx-fetch-style":"zn-data-table"},signal:n,credentials:"same-origin",body:this.method==="POST"?JSON.stringify(a):void 0});if(!d.ok)throw new Error(d.statusText);return d.json()},args:()=>[this.dataUri,this.requestParams]});this.rowHasActions=!1;this._expandedRows=new Set;this._hiddenCells=new Map;this._formatTemplates=Qk;this.requestParams={};this.filterChangeListener=t=>{t.target instanceof Lh&&(this.filter=t.target.value,this._dataTask.run().then(r=>r))};this.searchChangeListener=t=>{let r=t.target;if(r&&r.tagName==="ZN-DATA-TABLE-SEARCH"){if(this.search=r.value,t.detail){let{formData:n,searchUri:a}=t.detail;if(n&&typeof n=="object"&&(this.requestParams={...this.requestParams,...n}),a){let s=this.dataUri;this.dataUri=a,this._dataTask.run().then(()=>{this.dataUri=s});return}}this._dataTask.run().then(n=>n)}}}refresh(){this._initialLoad=!1,this._dataTask.run().then(t=>t)}render(){let t=u``;if(this.noInitialLoad&&this._initialLoad)t=u`
|
|
657
657
|
<slot name="empty-state"></slot>`;else if(this.dataUri)t=this._dataTask.render({pending:()=>this._initialLoad||!this._hasLoadedData||!this._lastLoadHadRows?u`
|
|
658
658
|
<div>${this.loadingTable()}</div>`:u`
|
|
659
659
|
<div class="reduced-opacity">${this._lastTableContent}</div>`,complete:a=>(this._initialLoad=!1,this._hasLoadedData=!0,this._lastLoadHadRows=(a?.rows?.length??0)>0,this._lastTableContent=u`
|
|
@@ -669,7 +669,15 @@ import{a as Cn,b as i_,c as sr,d as c,e as F}from"./chunks/zn.UBLZO6CI.js";var Q
|
|
|
669
669
|
${r?this.getTableHeader():u``}
|
|
670
670
|
${t}
|
|
671
671
|
</div>
|
|
672
|
-
`}connectedCallback(){super.connectedCallback(),this.addEventListener("zn-filter-change",this.filterChangeListener),this.addEventListener("zn-search-change",this.searchChangeListener)}getTemplate(t){return this.displayTemplates[t]??this._formatTemplates[t]}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("zn-filter-change",this.filterChangeListener),this.removeEventListener("zn-search-change",this.searchChangeListener)}emptyState(){return this.hasSlotController.test("
|
|
672
|
+
`}connectedCallback(){super.connectedCallback(),this.addEventListener("zn-filter-change",this.filterChangeListener),this.addEventListener("zn-search-change",this.searchChangeListener)}getTemplate(t){return this.displayTemplates[t]??this._formatTemplates[t]}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("zn-filter-change",this.filterChangeListener),this.removeEventListener("zn-search-change",this.searchChangeListener)}emptyState(){return this.noInitialLoad&&!this._initialLoad?this.hasSlotController.test("no-results")?u`
|
|
673
|
+
<div class="table--empty">
|
|
674
|
+
<slot name="no-results"></slot>
|
|
675
|
+
</div>`:u`
|
|
676
|
+
<div class="table--empty">
|
|
677
|
+
<zn-empty-state caption="No Results Found" icon="search">
|
|
678
|
+
<p>Nothing matched your search. Try adjusting your filters.</p>
|
|
679
|
+
</zn-empty-state>
|
|
680
|
+
</div>`:this.hasSlotController.test("empty-state")?u`
|
|
673
681
|
<div class="table--empty">
|
|
674
682
|
<slot name="empty-state"></slot>
|
|
675
683
|
</div>`:u`
|
package/package.json
CHANGED
|
@@ -178,6 +178,7 @@ type AllowedInputElement =
|
|
|
178
178
|
* @slot create-action - Slot for create action button.
|
|
179
179
|
* @slot inputs - Slot for additional input controls.
|
|
180
180
|
* @slot empty-state - Slot for custom empty state.
|
|
181
|
+
* @slot no-results - Slot for a custom no-results state, shown when a search on a no-initial-load table returns no rows.
|
|
181
182
|
*
|
|
182
183
|
* @csspart base - The component's base wrapper.
|
|
183
184
|
*
|
|
@@ -288,7 +289,8 @@ export default class ZnDataTable extends ZincElement {
|
|
|
288
289
|
ActionSlots.filter.valueOf(),
|
|
289
290
|
ActionSlots.sort.valueOf(),
|
|
290
291
|
ActionSlots.inputs.valueOf(),
|
|
291
|
-
'empty-state'
|
|
292
|
+
'empty-state',
|
|
293
|
+
'no-results'
|
|
292
294
|
);
|
|
293
295
|
|
|
294
296
|
private _dataTask = new Task(this, {
|
|
@@ -501,6 +503,22 @@ export default class ZnDataTable extends ZincElement {
|
|
|
501
503
|
}
|
|
502
504
|
|
|
503
505
|
emptyState() {
|
|
506
|
+
if (this.noInitialLoad && !this._initialLoad) {
|
|
507
|
+
if (this.hasSlotController.test('no-results')) {
|
|
508
|
+
return html`
|
|
509
|
+
<div class="table--empty">
|
|
510
|
+
<slot name="no-results"></slot>
|
|
511
|
+
</div>`;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
return html`
|
|
515
|
+
<div class="table--empty">
|
|
516
|
+
<zn-empty-state caption="No Results Found" icon="search">
|
|
517
|
+
<p>Nothing matched your search. Try adjusting your filters.</p>
|
|
518
|
+
</zn-empty-state>
|
|
519
|
+
</div>`;
|
|
520
|
+
}
|
|
521
|
+
|
|
504
522
|
if (this.hasSlotController.test('empty-state')) {
|
|
505
523
|
return html`
|
|
506
524
|
<div class="table--empty">
|
|
@@ -73,6 +73,52 @@ describe('<zn-data-table>', () => {
|
|
|
73
73
|
}
|
|
74
74
|
});
|
|
75
75
|
|
|
76
|
+
it('shows the empty-state slot before any load on a no-initial-load table, then a no-results state after an empty search', async () => {
|
|
77
|
+
const originalFetch = window.fetch;
|
|
78
|
+
window.fetch = () => Promise.resolve(new Response(JSON.stringify({rows: [], page: 1, perPage: 10, total: 0}),
|
|
79
|
+
{status: 200, headers: {'Content-Type': 'application/json'}}));
|
|
80
|
+
|
|
81
|
+
try {
|
|
82
|
+
const el = await fixture<ZnDataTable>(html`
|
|
83
|
+
<zn-data-table data-uri="/test-data" no-initial-load headers='{"name": {"key": "name", "label": "Name"}}'>
|
|
84
|
+
<div slot="empty-state" id="filters-prompt">No Filters Selected</div>
|
|
85
|
+
</zn-data-table>`);
|
|
86
|
+
|
|
87
|
+
expect(el.shadowRoot!.querySelector('slot[name="empty-state"]')).to.exist;
|
|
88
|
+
|
|
89
|
+
el.refresh();
|
|
90
|
+
await waitUntil(() => el.shadowRoot?.querySelector('zn-empty-state'));
|
|
91
|
+
|
|
92
|
+
expect(el.shadowRoot!.querySelector('slot[name="empty-state"]')).to.not.exist;
|
|
93
|
+
const emptyState = el.shadowRoot!.querySelector('zn-empty-state')!;
|
|
94
|
+
expect(emptyState.getAttribute('caption')).to.equal('No Results Found');
|
|
95
|
+
} finally {
|
|
96
|
+
window.fetch = originalFetch;
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it('prefers the no-results slot after an empty search on a no-initial-load table', async () => {
|
|
101
|
+
const originalFetch = window.fetch;
|
|
102
|
+
window.fetch = () => Promise.resolve(new Response(JSON.stringify({rows: [], page: 1, perPage: 10, total: 0}),
|
|
103
|
+
{status: 200, headers: {'Content-Type': 'application/json'}}));
|
|
104
|
+
|
|
105
|
+
try {
|
|
106
|
+
const el = await fixture<ZnDataTable>(html`
|
|
107
|
+
<zn-data-table data-uri="/test-data" no-initial-load headers='{"name": {"key": "name", "label": "Name"}}'>
|
|
108
|
+
<div slot="empty-state">No Filters Selected</div>
|
|
109
|
+
<div slot="no-results">No Customers Found</div>
|
|
110
|
+
</zn-data-table>`);
|
|
111
|
+
|
|
112
|
+
el.refresh();
|
|
113
|
+
await waitUntil(() => el.shadowRoot?.querySelector('slot[name="no-results"]'));
|
|
114
|
+
|
|
115
|
+
expect(el.shadowRoot!.querySelector('slot[name="no-results"]')).to.exist;
|
|
116
|
+
expect(el.shadowRoot!.querySelector('slot[name="empty-state"]')).to.not.exist;
|
|
117
|
+
} finally {
|
|
118
|
+
window.fetch = originalFetch;
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
|
|
76
122
|
it('exposes displayTemplates as an object property', async () => {
|
|
77
123
|
const el = await fixture<ZnDataTable>(html` <zn-data-table></zn-data-table> `);
|
|
78
124
|
const templates = (el as unknown as {displayTemplates: Record<string, unknown>}).displayTemplates;
|