@kubex/zinc 1.1.150 → 1.1.151
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 +21 -2
- package/dist/vscode.html-custom-data.json +5 -0
- package/dist/web-types.json +11 -1
- package/dist/zn.d.ts +6 -0
- package/dist/zn.min.js +4 -4
- package/docs/pages/components/data-table.md +25 -3
- package/package.json +1 -1
- package/src/components/data-table/data-table.component.ts +26 -17
- package/src/components/data-table/data-table.test.ts +92 -7
|
@@ -8983,6 +8983,16 @@
|
|
|
8983
8983
|
"description": "When set, the table's non-default state (search, filter, sort, page, per-page and field values)\nis mirrored to the URL query string and restored from it on load, so the view is shareable.",
|
|
8984
8984
|
"attribute": "sharable"
|
|
8985
8985
|
},
|
|
8986
|
+
{
|
|
8987
|
+
"kind": "field",
|
|
8988
|
+
"name": "wrapSearchFields",
|
|
8989
|
+
"type": {
|
|
8990
|
+
"text": "boolean"
|
|
8991
|
+
},
|
|
8992
|
+
"default": "false",
|
|
8993
|
+
"description": "When set, extra request params (search-component field values) are nested under a\n`searchFields` object - with `q` mirroring the search text - instead of being merged at the\nroot of the request body.",
|
|
8994
|
+
"attribute": "wrap-search-fields"
|
|
8995
|
+
},
|
|
8986
8996
|
{
|
|
8987
8997
|
"kind": "field",
|
|
8988
8998
|
"name": "groupBy",
|
|
@@ -9165,7 +9175,7 @@
|
|
|
9165
9175
|
"kind": "field",
|
|
9166
9176
|
"name": "_dataTask",
|
|
9167
9177
|
"privacy": "private",
|
|
9168
|
-
"default": "new Task(this, { task: async ([dataUri, requestParams], {signal}) => { // Every request path funnels through the task, so this is the single place to mirror the // current (non-default) state to the URL when `sharable` is set. this._updateSharableUrl(); if (dataUri === undefined || this.noInitialLoad && this._initialLoad) { return {rows: [], page: 1, perPage: this.itemsPerPage, total: 0}; } if (this.groupBy) { // we want to load all the data possible so we can group and show multiple tables this.itemsPerPage = 1000; } const requestData: DataRequest = { page: this.page, perPage: this.itemsPerPage, sortColumn: this.sortColumn, sortDirection: this.sortDirection, filter: this.filter, search: this.search, }; // Inputs-slot values are context/system params (e.g. csrf token, package name) sent with // every request
|
|
9178
|
+
"default": "new Task(this, { task: async ([dataUri, requestParams], {signal}) => { // Every request path funnels through the task, so this is the single place to mirror the // current (non-default) state to the URL when `sharable` is set. this._updateSharableUrl(); if (dataUri === undefined || this.noInitialLoad && this._initialLoad) { return {rows: [], page: 1, perPage: this.itemsPerPage, total: 0}; } if (this.groupBy) { // we want to load all the data possible so we can group and show multiple tables this.itemsPerPage = 1000; } const requestData: DataRequest = { page: this.page, perPage: this.itemsPerPage, sortColumn: this.sortColumn, sortDirection: this.sortDirection, filter: this.filter, search: this.search, }; // Inputs-slot values are context/system params (e.g. csrf token, package name) sent with // every request. const inputs = this.hasSlotController.getSlots(ActionSlots.inputs.valueOf()); const params: Record<string, any> = {}; if (inputs) { inputs.forEach((input) => { const allowedInputs = ['zn-input', 'zn-select', 'zn-query-builder', 'zn-multiselect', 'zn-params-select', 'zn-datepicker', 'input', 'select', 'textarea']; if (allowedInputs.includes(input.tagName.toLowerCase())) { const value = (input as AllowedInputElement).value as string || input.getAttribute('value'); const name = (input as AllowedInputElement).name || input.getAttribute('name'); if (name) { params[name] = value; } } }); Object.assign(requestData, params); } // Add any extra request params const extraParams = requestParams && typeof requestParams === 'object' ? requestParams as Record<string, unknown> : {}; if (this.wrapSearchFields) { // Opt-in shape: field values nested under `searchFields`, with `q` mirroring the search // text, so a backend can bind them to one map. Empty values are dropped, and the key is // null when nothing is set. The root `search` key is sent either way. const searchFields: Record<string, any> = {}; for (const [key, value] of Object.entries(extraParams)) { if (value !== undefined && value !== null && value !== '') { searchFields[key] = value; } } if (this.search || Object.keys(searchFields).length > 0) { searchFields.q = this.search; } requestData.searchFields = Object.keys(searchFields).length > 0 ? searchFields : null; } else { Object.assign(requestData, extraParams); } // This is also used for Rubix, so it may not work for your application. const response = await fetch(dataUri, { method: this.method, headers: { 'x-kx-fetch-style': 'zn-data-table', }, signal, credentials: 'same-origin', body: this.method === 'POST' ? JSON.stringify(requestData) : undefined }); if (!response.ok) throw new Error(response.statusText); return response.json(); }, args: () => [this.dataUri, this.requestParams] })"
|
|
9169
9179
|
},
|
|
9170
9180
|
{
|
|
9171
9181
|
"kind": "field",
|
|
@@ -10184,6 +10194,15 @@
|
|
|
10184
10194
|
"description": "When set, the table's non-default state (search, filter, sort, page, per-page and field values)\nis mirrored to the URL query string and restored from it on load, so the view is shareable.",
|
|
10185
10195
|
"fieldName": "sharable"
|
|
10186
10196
|
},
|
|
10197
|
+
{
|
|
10198
|
+
"name": "wrap-search-fields",
|
|
10199
|
+
"type": {
|
|
10200
|
+
"text": "boolean"
|
|
10201
|
+
},
|
|
10202
|
+
"default": "false",
|
|
10203
|
+
"description": "When set, extra request params (search-component field values) are nested under a\n`searchFields` object - with `q` mirroring the search text - instead of being merged at the\nroot of the request body.",
|
|
10204
|
+
"fieldName": "wrapSearchFields"
|
|
10205
|
+
},
|
|
10187
10206
|
{
|
|
10188
10207
|
"name": "group-by",
|
|
10189
10208
|
"type": {
|
|
@@ -53493,7 +53512,7 @@
|
|
|
53493
53512
|
"package": {
|
|
53494
53513
|
"name": "@kubex/zinc",
|
|
53495
53514
|
"description": "A collection of web components for building web applications based off of @shoelace-style/Shoelace",
|
|
53496
|
-
"version": "1.1.
|
|
53515
|
+
"version": "1.1.151",
|
|
53497
53516
|
"author": "",
|
|
53498
53517
|
"license": "MIT"
|
|
53499
53518
|
}
|
|
@@ -1234,6 +1234,11 @@
|
|
|
1234
1234
|
"description": "When set, the table's non-default state (search, filter, sort, page, per-page and field values)\nis mirrored to the URL query string and restored from it on load, so the view is shareable.",
|
|
1235
1235
|
"values": []
|
|
1236
1236
|
},
|
|
1237
|
+
{
|
|
1238
|
+
"name": "wrap-search-fields",
|
|
1239
|
+
"description": "When set, extra request params (search-component field values) are nested under a\n`searchFields` object - with `q` mirroring the search text - instead of being merged at the\nroot of the request body.",
|
|
1240
|
+
"values": []
|
|
1241
|
+
},
|
|
1237
1242
|
{ "name": "group-by", "values": [] },
|
|
1238
1243
|
{ "name": "groups", "values": [] },
|
|
1239
1244
|
{ "name": "per-page-size", "values": [] }
|
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.151",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"contributions": {
|
|
7
7
|
"html": {
|
|
@@ -2766,6 +2766,11 @@
|
|
|
2766
2766
|
"description": "When set, the table's non-default state (search, filter, sort, page, per-page and field values)\nis mirrored to the URL query string and restored from it on load, so the view is shareable.",
|
|
2767
2767
|
"value": { "type": "boolean", "default": "false" }
|
|
2768
2768
|
},
|
|
2769
|
+
{
|
|
2770
|
+
"name": "wrap-search-fields",
|
|
2771
|
+
"description": "When set, extra request params (search-component field values) are nested under a\n`searchFields` object - with `q` mirroring the search text - instead of being merged at the\nroot of the request body.",
|
|
2772
|
+
"value": { "type": "boolean", "default": "false" }
|
|
2773
|
+
},
|
|
2769
2774
|
{
|
|
2770
2775
|
"name": "group-by",
|
|
2771
2776
|
"value": { "type": "string", "default": "''" }
|
|
@@ -2859,6 +2864,11 @@
|
|
|
2859
2864
|
"description": "When set, the table's non-default state (search, filter, sort, page, per-page and field values)\nis mirrored to the URL query string and restored from it on load, so the view is shareable.",
|
|
2860
2865
|
"type": "boolean"
|
|
2861
2866
|
},
|
|
2867
|
+
{
|
|
2868
|
+
"name": "wrapSearchFields",
|
|
2869
|
+
"description": "When set, extra request params (search-component field values) are nested under a\n`searchFields` object - with `q` mirroring the search text - instead of being merged at the\nroot of the request body.",
|
|
2870
|
+
"type": "boolean"
|
|
2871
|
+
},
|
|
2862
2872
|
{ "name": "groupBy", "type": "string" },
|
|
2863
2873
|
{ "name": "groups", "type": "string" },
|
|
2864
2874
|
{ "name": "itemsPerPage", "type": "number" },
|
package/dist/zn.d.ts
CHANGED
|
@@ -4192,6 +4192,12 @@ declare module "components/data-table/data-table.component" {
|
|
|
4192
4192
|
*is mirrored to the URL query string and restored from it on load, so the view is shareable.
|
|
4193
4193
|
*/
|
|
4194
4194
|
sharable: boolean;
|
|
4195
|
+
/**
|
|
4196
|
+
* When set, extra request params (search-component field values) are nested under a
|
|
4197
|
+
* `searchFields` object - with `q` mirroring the search text - instead of being merged at the
|
|
4198
|
+
* root of the request body.
|
|
4199
|
+
*/
|
|
4200
|
+
wrapSearchFields: boolean;
|
|
4195
4201
|
groupBy: string;
|
|
4196
4202
|
groups: string;
|
|
4197
4203
|
itemsPerPage: number;
|
package/dist/zn.min.js
CHANGED
|
@@ -1199,7 +1199,7 @@ import{a as Hn,b as z3,c as _r,d as c,e as V}from"./chunks/zn.UBLZO6CI.js";var e
|
|
|
1199
1199
|
<div class="table__collum--datetime" title="${N(o.title)}">
|
|
1200
1200
|
<span><strong>${i.slice(0,10)}</strong></span>
|
|
1201
1201
|
<zn-style size="s" muted>${i.slice(11)}</zn-style>
|
|
1202
|
-
</div>`})},
|
|
1202
|
+
</div>`})},me=class me extends S{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.hideColumnSelect=!1;this.hideRefresh=!1;this.standalone=!1;this.emptyStateIcon="data_alert";this.filters=[];this.method="POST";this.noInitialLoad=!1;this.sharable=!1;this.wrapSearchFields=!1;this.groupBy="";this.groups="";this.itemsPerPage=lm;this._initialLoad=!0;this._hasLoadedData=!1;this._lastLoadHadRows=!1;this._lastTableContent=u``;this._sharableInitialised=!1;this._sharableDefaults=null;this._urlManagedKeys=new Set(["search","filter","sortColumn","sortDirection","page","perPage"]);this.resizeObserver=new ut(this,{target:null,callback:()=>{this.tableContainer&&this.tableContainer.scrollIntoView({behavior:"smooth",block:"nearest"})}});this.page=O0;this._totalRows=0;this._rows=[];this._suggestionsKey="";this.numberOfRowsSelected=0;this.selectedRows=[];this.hasSlotController=new Y(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 Ul(this,{task:async([t,r],{signal:n})=>{if(this._updateSharableUrl(),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(m=>{if(["zn-input","zn-select","zn-query-builder","zn-multiselect","zn-params-select","zn-datepicker","input","select","textarea"].includes(m.tagName.toLowerCase())){let b=m.value||m.getAttribute("value"),g=m.name||m.getAttribute("name");g&&(l[g]=b)}}),Object.assign(a,l));let p=r&&typeof r=="object"?r:{};if(this.wrapSearchFields){let m={};for(let[f,b]of Object.entries(p))b!=null&&b!==""&&(m[f]=b);(this.search||Object.keys(m).length>0)&&(m.q=this.search),a.searchFields=Object.keys(m).length>0?m:null}else Object.assign(a,p);let h=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(!h.ok)throw new Error(h.statusText);return h.json()},args:()=>[this.dataUri,this.requestParams]});this.rowHasActions=!1;this._expandedRows=new Set;this._hiddenCells=new Map;this._deselectedColumns=new Set;this._filtersOpen=!1;this._columnDefaultsApplied=!1;this._formatTemplates=R4;this.requestParams={};this.filterClearListener=t=>{t.target instanceof Qd&&(this._filtersOpen=!1)};this.filterChangeListener=t=>{t.target instanceof Qd&&(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)}};this.toggleFilters=()=>{this._filtersOpen=!this._filtersOpen};this.handleColumnSelect=t=>{let r=Object.values(this.headers).find(n=>n.key===t.detail.value);r&&this.toggleColumn(r)}}refresh(){this._initialLoad=!1,this._dataTask.run().then(t=>t)}visibleHeaders(){return this.selectableHeaders().filter(t=>this.isColumnVisible(t))}selectableHeaders(){return Object.values(this.headers).filter(t=>t.hideHeader||t.hideColumn||t.secondary?!1:!Object.values(this.hiddenColumns).includes(t.key))}isColumnVisible(t){return t.required===!0||!this._deselectedColumns.has(t.key)}applyColumnDefaults(){if(this._columnDefaultsApplied)return;let t=Object.values(this.headers);if(t.length===0)return;this._columnDefaultsApplied=!0;let r=new Set(this._deselectedColumns);t.forEach(n=>{n.default===!1&&n.required!==!0&&r.add(n.key)}),this._deselectedColumns=r}toggleColumn(t){if(t.required===!0)return;let r=new Set(this._deselectedColumns);if(!r.delete(t.key)){if(this.visibleHeaders().length<=1)return;r.add(t.key)}this._deselectedColumns=r}_captureSharableDefaults(){this._sharableDefaults||(this._sharableDefaults={search:this.search||"",filter:this.filter||"",sortColumn:this.sortColumn||"",sortDirection:this.sortDirection||"",page:String(this.page),perPage:String(this.itemsPerPage)})}_readSharableState(){if(!this.sharable||this._sharableInitialised||typeof window>"u")return;this._sharableInitialised=!0;let t=new URLSearchParams(window.location.search),r=!1;if(t.has("search")&&(this.search=t.get("search"),r=!0),t.has("filter")&&(this.filter=t.get("filter"),r=!0),t.has("sortColumn")&&(this.sortColumn=t.get("sortColumn"),r=!0),t.has("sortDirection")&&(this.sortDirection=t.get("sortDirection"),r=!0),t.has("page")){let s=parseInt(t.get("page"),10);!isNaN(s)&&s>0&&(this.page=s),r=!0}if(t.has("perPage")){let s=parseInt(t.get("perPage"),10);!isNaN(s)&&s>0&&(this.itemsPerPage=s),r=!0}let n=new Set(me._sharableKnownKeys),a={};t.forEach((s,l)=>{n.has(l)||!this._hasFieldNamed(l)||(r=!0,this._urlManagedKeys.add(l),a[l]=s)}),Object.keys(a).length>0&&(this.requestParams={...this.requestParams,...a}),r&&this.noInitialLoad&&(this._initialLoad=!1)}_populateSharableFields(){if(this.search){let r=this.querySelector("zn-data-table-search");r&&(r.value=this.search)}if(this.filter){let r=this.querySelector("zn-data-table-filter");r&&(r.value=this.filter)}let t=new Set(me._sharableKnownKeys);Object.entries(this.requestParams).forEach(([r,n])=>{t.has(r)||r==="searchUri"||n===void 0||n===null||this._setSharableFieldValue(r,String(n))})}_hasFieldNamed(t){try{let r=`[name="${window.CSS&&CSS.escape?CSS.escape(t):t}"]`;return this.querySelector(r)!==null}catch{return!1}}_setSharableFieldValue(t,r){let n;try{n=`[name="${window.CSS&&CSS.escape?CSS.escape(t):t}"]`}catch{n=`[name="${t}"]`}this.querySelectorAll(n).forEach(a=>{a.value=r,a.tagName.includes("-")&&a.setAttribute("value",r)})}_updateSharableUrl(){if(!this.sharable||!window?.history)return;let t=this._sharableDefaults??{},r=new URLSearchParams(window.location.search);this._urlManagedKeys.forEach(p=>r.delete(p));let n=(p,h)=>{this._urlManagedKeys.add(p);let m=h==null?"":String(h);m===""||m===(t[p]||"")||r.set(p,m)},a=new Set(me._sharableKnownKeys);Object.entries(this.requestParams).forEach(([p,h])=>{a.has(p)||p==="searchUri"||n(p,h)}),n("search",this.search),n("filter",this.filter),n("sortColumn",this.sortColumn),n("sortDirection",this.sortDirection),n("page",this.page),n("perPage",this.itemsPerPage);let s=r.toString(),l=`${window.location.pathname}${s?`?${s}`:""}${window.location.hash}`;window.history.replaceState(window.history.state,"",l)}render(){this.applyColumnDefaults();let t=u``,r=!1;if(this.noInitialLoad&&this._initialLoad)t=u`
|
|
1203
1203
|
<slot name="empty-state"></slot>`,r=!0;else if(this.dataUri)t=this._dataTask.render({pending:()=>this._initialLoad||!this._hasLoadedData||!this._lastLoadHadRows?u`
|
|
1204
1204
|
<div>${this.loadingTable()}</div>`:u`
|
|
1205
1205
|
<div class="reduced-opacity">${this._lastTableContent}</div>`,complete:h=>(this._initialLoad=!1,this._hasLoadedData=!0,this._lastLoadHadRows=(h?.rows?.length??0)>0,r=!this._lastLoadHadRows,this._lastTableContent=u`
|
|
@@ -1598,7 +1598,7 @@ import{a as Hn,b as z3,c as _r,d as c,e as V}from"./chunks/zn.UBLZO6CI.js";var e
|
|
|
1598
1598
|
</zn-menu-item>`})}
|
|
1599
1599
|
</zn-menu>
|
|
1600
1600
|
</zn-dropdown>
|
|
1601
|
-
</td>`}};fe.styles=[z(ys),z(R0)],fe.dependencies={"zn-alert":Ru,"zn-button":Me,"zn-empty-state":im,"zn-chip":jn,"zn-hover-container":nm,"zn-dropdown":ur,"zn-menu":on,"zn-menu-item":xi,"zn-panel":om,"zn-button-group":Bl,"zn-confirm":jl,"zn-skeleton":am,"zn-style":sm,"zn-data-table-search":rm},fe._sharableKnownKeys=["search","filter","sortColumn","sortDirection","page","perPage"],c([d({attribute:"data-uri"})],fe.prototype,"dataUri",2),c([d({attribute:"data",type:Object})],fe.prototype,"data",2),c([d({attribute:"sort-column"})],fe.prototype,"sortColumn",2),c([d({attribute:"sort-direction"})],fe.prototype,"sortDirection",2),c([d({attribute:"local-sort",type:Boolean})],fe.prototype,"localSort",2),c([d({attribute:"filter"})],fe.prototype,"filter",2),c([d({attribute:"search"})],fe.prototype,"search",2),c([d({attribute:"wide-column"})],fe.prototype,"wideColumn",2),c([d({attribute:"key"})],fe.prototype,"key",2),c([d({attribute:"headers",type:Object})],fe.prototype,"headers",2),c([d({attribute:!1})],fe.prototype,"displayTemplates",2),c([d({attribute:"hide-headers",type:Object})],fe.prototype,"hiddenHeaders",2),c([d({attribute:"hide-columns",type:Object})],fe.prototype,"hiddenColumns",2),c([d({attribute:"unsortable-headers",type:Object})],fe.prototype,"unsortableHeaders",2),c([d({attribute:"unsortable",type:Boolean})],fe.prototype,"unsortable",2),c([d({attribute:"hide-pagination",type:Boolean})],fe.prototype,"hidePagination",2),c([d({attribute:"hide-column-select",type:Boolean})],fe.prototype,"hideColumnSelect",2),c([d({attribute:"hide-refresh",type:Boolean})],fe.prototype,"hideRefresh",2),c([d({type:Boolean})],fe.prototype,"standalone",2),c([d()],fe.prototype,"caption",2),c([d({attribute:"empty-state-caption"})],fe.prototype,"emptyStateCaption",2),c([d({attribute:"empty-state-icon"})],fe.prototype,"emptyStateIcon",2),c([d({attribute:"hide-checkboxes",type:Boolean})],fe.prototype,"hideCheckboxes",2),c([d()],fe.prototype,"filters",2),c([d()],fe.prototype,"method",2),c([d({attribute:"no-initial-load",type:Boolean})],fe.prototype,"noInitialLoad",2),c([d({attribute:"sharable",type:Boolean})],fe.prototype,"sharable",2),c([d({attribute:"group-by"})],fe.prototype,"groupBy",2),c([d()],fe.prototype,"groups",2),c([d({attribute:"per-page-size",type:Number})],fe.prototype,"itemsPerPage",2),c([F("#select-all-rows")],fe.prototype,"selectAllButton",2),c([I()],fe.prototype,"_deselectedColumns",2),c([I()],fe.prototype,"_filtersOpen",2);var xs=fe;var O4=xs;xs.define("zn-data-table");var N0=_`@keyframes rotate-gradient{from{--rotate:0deg}to{--rotate:360deg}}:host{text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-transform:none}*,*::before,*::after{box-sizing:border-box;border-width:0;border-style:solid;border-color:rgb(var(--zn-border-color))}[hidden]{display:none !important}.width-container,.form-container,.wide-form-container{height:100%;width:100%;margin:var(--zn-default-margin,0 auto)}.width-container{max-width:var(--zn-container)}.form-container{max-width:var(--zn-container-ph)}.wide-form-container{max-width:var(--zn-container-lg)}:host{display:block;--zn-col-basis:250px;--col-width:23%}:host([contents]){display:contents}.cols{display:flex;flex-wrap:wrap;flex-grow:1;flex-shrink:1;width:100%;container-type:inline-size;gap:var(--zn-gap);max-width:100%}.cols ::slotted(.zn-col-1){flex-basis:calc(var(--zn-col-basis) * 1);min-width:calc(var(--col-width) * 1);flex-grow:1}.cols ::slotted(.zn-col-2){flex-basis:calc(var(--zn-col-basis) * 2);min-width:calc(var(--col-width) * 2);flex-grow:2}.cols ::slotted(.zn-col-3){flex-basis:calc(var(--zn-col-basis) * 3);min-width:calc(var(--col-width) * 3);flex-grow:3}.cols ::slotted(.zn-col-4){flex-basis:calc(var(--zn-col-basis) * 4);min-width:calc(var(--col-width) * 4);flex-grow:4}.cols ::slotted(.zn-col-5){flex-basis:calc(var(--zn-col-basis) * 5);min-width:calc(var(--col-width) * 5);flex-grow:5}.cols ::slotted(.zn-col-6){flex-basis:calc(var(--zn-col-basis) * 6);min-width:calc(var(--col-width) * 6);flex-grow:6}.cols ::slotted(.zn-col-7){flex-basis:calc(var(--zn-col-basis) * 7);min-width:calc(var(--col-width) * 7);flex-grow:7}.cols ::slotted(.zn-col-8){flex-basis:calc(var(--zn-col-basis) * 8);min-width:calc(var(--col-width) * 8);flex-grow:8}.cols ::slotted(.zn-col-9){flex-basis:calc(var(--zn-col-basis) * 9);min-width:calc(var(--col-width) * 9);flex-grow:9}.cols ::slotted(.zn-col-10){flex-basis:calc(var(--zn-col-basis) * 10);min-width:calc(var(--col-width) * 10);flex-grow:10}.cols ::slotted(.zn-col-11){flex-basis:calc(var(--zn-col-basis) * 11);min-width:calc(var(--col-width) * 11);flex-grow:11}.cols ::slotted(.zn-col-12){flex-basis:calc(var(--zn-col-basis) * 12);min-width:calc(var(--col-width) * 12);flex-grow:12}.cols--mc-1{--col-width:calc(100% / 2)}.cols--mc-2{--col-width:calc(100% / 3)}.cols--mc-3{--col-width:calc(100% / 4)}.cols--mc-4{--col-width:calc(100% / 5)}.cols--mc-5{--col-width:calc(100% / 6)}.cols--mc-6{--col-width:calc(100% / 7)}.cols--mc-7{--col-width:calc(100% / 8)}.cols--mc-8{--col-width:calc(100% / 9)}.cols--mc-9{--col-width:calc(100% / 10)}.cols--mc-10{--col-width:calc(100% / 11)}.cols--mc-11{--col-width:calc(100% / 12)}.cols--mc-12{--col-width:calc(100% / 13)}.cols--layout-121 ::slotted(.zn-col-2){order:-1;min-width:100%}@container (min-width:1440px){.cols--layout-121 ::slotted(.zn-col-2){order:initial;min-width:46%}}.cols--divide ::slotted(*:not(:last-child)){position:relative}.cols--divide ::slotted(*:not(:last-child)):after{content:"";position:absolute;display:block;width:1px;top:0;height:100%;max-height:100%;right:calc(var(--zn-spacing-small) / 2 * -1);background-color:rgb(var(--zn-border-color))}.cols--no-gap{gap:0}.cols--border{overflow:hidden}.cols--border ::slotted(*){position:relative;padding-bottom:var(--zn-spacing-small)}.cols--border ::slotted(*):before{content:"";position:absolute;bottom:-1px;left:-100vw;right:-5px;z-index:1111;border-bottom:1px solid rgb(var(--zn-border-color)) !important}.cols ::slotted([stack-split]){display:flex;flex-direction:column;gap:var(--zn-gap)}.cols--pad{padding:var(--zn-spacing-2x-small)}.cols--pad-x{padding-inline:var(--zn-spacing-2x-small)}.cols--pad-y{padding-block:var(--zn-spacing-2x-small)}@container (max-width:359px){:host([stack-at=sm]) .cols ::slotted(*){--zn-stacked:1;--zn-stack-basis:100%;flex-basis:100%;min-width:100%;max-width:100%}:host([stack-at=sm]) .cols ::slotted([stack-split]){display:contents}:host([stack-at=sm]) .cols--divide ::slotted(*:not(:last-child)):after{display:none}}@container (max-width:479px){:host([stack-at=smp]) .cols ::slotted(*){--zn-stacked:1;--zn-stack-basis:100%;flex-basis:100%;min-width:100%;max-width:100%}:host([stack-at=smp]) .cols ::slotted([stack-split]){display:contents}:host([stack-at=smp]) .cols--divide ::slotted(*:not(:last-child)):after{display:none}}@container (max-width:599px){:host([stack-at=ph]) .cols ::slotted(*){--zn-stacked:1;--zn-stack-basis:100%;flex-basis:100%;min-width:100%;max-width:100%}:host([stack-at=ph]) .cols ::slotted([stack-split]){display:contents}:host([stack-at=ph]) .cols--divide ::slotted(*:not(:last-child)):after{display:none}}@container (max-width:767px){:host([stack-at=md]) .cols ::slotted(*){--zn-stacked:1;--zn-stack-basis:100%;flex-basis:100%;min-width:100%;max-width:100%}:host([stack-at=md]) .cols ::slotted([stack-split]){display:contents}:host([stack-at=md]) .cols--divide ::slotted(*:not(:last-child)):after{display:none}}@container (max-width:1099px){:host([stack-at=lg]) .cols ::slotted(*){--zn-stacked:1;--zn-stack-basis:100%;flex-basis:100%;min-width:100%;max-width:100%}:host([stack-at=lg]) .cols ::slotted([stack-split]){display:contents}:host([stack-at=lg]) .cols--divide ::slotted(*:not(:last-child)):after{display:none}}@container (max-width:1439px){:host([stack-at=hd]) .cols ::slotted(*){--zn-stacked:1;--zn-stack-basis:100%;flex-basis:100%;min-width:100%;max-width:100%}:host([stack-at=hd]) .cols ::slotted([stack-split]){display:contents}:host([stack-at=hd]) .cols--divide ::slotted(*:not(:last-child)):after{display:none}}@container (max-width:1959px){:host([stack-at="3k"]) .cols ::slotted(*){--zn-stacked:1;--zn-stack-basis:100%;flex-basis:100%;min-width:100%;max-width:100%}:host([stack-at="3k"]) .cols ::slotted([stack-split]){display:contents}:host([stack-at="3k"]) .cols--divide ::slotted(*:not(:last-child)):after{display:none}}@container (max-width:2559px){:host([stack-at="4k"]) .cols ::slotted(*){--zn-stacked:1;--zn-stack-basis:100%;flex-basis:100%;min-width:100%;max-width:100%}:host([stack-at="4k"]) .cols ::slotted([stack-split]){display:contents}:host([stack-at="4k"]) .cols--divide ::slotted(*:not(:last-child)):after{display:none}}`;var P0={first:-1,high:-1,last:1,low:1},N4="lg",Tr=class extends S{constructor(){super(...arguments);this.layout="";this.stackAt="";this.maxColumns=0;this.noGap=!1;this.border=!1;this.divide=!1;this.childObserver=new MutationObserver(()=>this.requestUpdate())}connectedCallback(){super.connectedCallback(),this.childObserver.observe(this,{childList:!0})}disconnectedCallback(){super.disconnectedCallback(),this.childObserver.disconnect()}stackOrder(t){let r=t.getAttribute("stack-order");if(r===null)return null;let n=r.trim().toLowerCase();if(n in P0)return P0[n];let a=parseInt(n,10);return isNaN(a)?null:a}applyStackOrder(t,r){let n=this.stackOrder(t);return t.style.order=n===null?"":`calc(var(--zn-stacked, 0) * ${n})`,r&&(t.style.flexBasis="var(--zn-stack-basis, auto)"),n}render(){let t=this.layout.split(/[\s,]+/).map(p=>parseInt(p)).filter(p=>!!p);t.length===0&&t.push(1,1,1,1),this.layout=t.join(","),this.maxColumns=t.reduce((p,h)=>p+h,0);let r="zn-col-",n=Array.from(this.querySelectorAll(":scope > *:not([slot])")),a=t.length,s=n.length-(n.length%a||a),l=!1;return n.forEach((p,h)=>{let m=p.className.split(" ").filter(b=>!b.startsWith(r));p.className=m.join(" ");let f=h%a;p.classList.add(r+t[f]),this.border&&h>=s?p.style.overflow="hidden":p.style.overflow="",l=this.applyStackOrder(p,!1)!==null||l,p.hasAttribute("stack-split")&&(l=!0,this.childObserver.observe(p,{childList:!0}),Array.from(p.children).forEach(b=>this.applyStackOrder(b,!0)))}),l&&!this.stackAt&&(this.stackAt=N4),u`
|
|
1601
|
+
</td>`}};me.styles=[z(ys),z(R0)],me.dependencies={"zn-alert":Ru,"zn-button":Me,"zn-empty-state":im,"zn-chip":jn,"zn-hover-container":nm,"zn-dropdown":ur,"zn-menu":on,"zn-menu-item":xi,"zn-panel":om,"zn-button-group":Bl,"zn-confirm":jl,"zn-skeleton":am,"zn-style":sm,"zn-data-table-search":rm},me._sharableKnownKeys=["search","filter","sortColumn","sortDirection","page","perPage"],c([d({attribute:"data-uri"})],me.prototype,"dataUri",2),c([d({attribute:"data",type:Object})],me.prototype,"data",2),c([d({attribute:"sort-column"})],me.prototype,"sortColumn",2),c([d({attribute:"sort-direction"})],me.prototype,"sortDirection",2),c([d({attribute:"local-sort",type:Boolean})],me.prototype,"localSort",2),c([d({attribute:"filter"})],me.prototype,"filter",2),c([d({attribute:"search"})],me.prototype,"search",2),c([d({attribute:"wide-column"})],me.prototype,"wideColumn",2),c([d({attribute:"key"})],me.prototype,"key",2),c([d({attribute:"headers",type:Object})],me.prototype,"headers",2),c([d({attribute:!1})],me.prototype,"displayTemplates",2),c([d({attribute:"hide-headers",type:Object})],me.prototype,"hiddenHeaders",2),c([d({attribute:"hide-columns",type:Object})],me.prototype,"hiddenColumns",2),c([d({attribute:"unsortable-headers",type:Object})],me.prototype,"unsortableHeaders",2),c([d({attribute:"unsortable",type:Boolean})],me.prototype,"unsortable",2),c([d({attribute:"hide-pagination",type:Boolean})],me.prototype,"hidePagination",2),c([d({attribute:"hide-column-select",type:Boolean})],me.prototype,"hideColumnSelect",2),c([d({attribute:"hide-refresh",type:Boolean})],me.prototype,"hideRefresh",2),c([d({type:Boolean})],me.prototype,"standalone",2),c([d()],me.prototype,"caption",2),c([d({attribute:"empty-state-caption"})],me.prototype,"emptyStateCaption",2),c([d({attribute:"empty-state-icon"})],me.prototype,"emptyStateIcon",2),c([d({attribute:"hide-checkboxes",type:Boolean})],me.prototype,"hideCheckboxes",2),c([d()],me.prototype,"filters",2),c([d()],me.prototype,"method",2),c([d({attribute:"no-initial-load",type:Boolean})],me.prototype,"noInitialLoad",2),c([d({attribute:"sharable",type:Boolean})],me.prototype,"sharable",2),c([d({attribute:"wrap-search-fields",type:Boolean})],me.prototype,"wrapSearchFields",2),c([d({attribute:"group-by"})],me.prototype,"groupBy",2),c([d()],me.prototype,"groups",2),c([d({attribute:"per-page-size",type:Number})],me.prototype,"itemsPerPage",2),c([F("#select-all-rows")],me.prototype,"selectAllButton",2),c([I()],me.prototype,"_deselectedColumns",2),c([I()],me.prototype,"_filtersOpen",2);var xs=me;var O4=xs;xs.define("zn-data-table");var N0=_`@keyframes rotate-gradient{from{--rotate:0deg}to{--rotate:360deg}}:host{text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-transform:none}*,*::before,*::after{box-sizing:border-box;border-width:0;border-style:solid;border-color:rgb(var(--zn-border-color))}[hidden]{display:none !important}.width-container,.form-container,.wide-form-container{height:100%;width:100%;margin:var(--zn-default-margin,0 auto)}.width-container{max-width:var(--zn-container)}.form-container{max-width:var(--zn-container-ph)}.wide-form-container{max-width:var(--zn-container-lg)}:host{display:block;--zn-col-basis:250px;--col-width:23%}:host([contents]){display:contents}.cols{display:flex;flex-wrap:wrap;flex-grow:1;flex-shrink:1;width:100%;container-type:inline-size;gap:var(--zn-gap);max-width:100%}.cols ::slotted(.zn-col-1){flex-basis:calc(var(--zn-col-basis) * 1);min-width:calc(var(--col-width) * 1);flex-grow:1}.cols ::slotted(.zn-col-2){flex-basis:calc(var(--zn-col-basis) * 2);min-width:calc(var(--col-width) * 2);flex-grow:2}.cols ::slotted(.zn-col-3){flex-basis:calc(var(--zn-col-basis) * 3);min-width:calc(var(--col-width) * 3);flex-grow:3}.cols ::slotted(.zn-col-4){flex-basis:calc(var(--zn-col-basis) * 4);min-width:calc(var(--col-width) * 4);flex-grow:4}.cols ::slotted(.zn-col-5){flex-basis:calc(var(--zn-col-basis) * 5);min-width:calc(var(--col-width) * 5);flex-grow:5}.cols ::slotted(.zn-col-6){flex-basis:calc(var(--zn-col-basis) * 6);min-width:calc(var(--col-width) * 6);flex-grow:6}.cols ::slotted(.zn-col-7){flex-basis:calc(var(--zn-col-basis) * 7);min-width:calc(var(--col-width) * 7);flex-grow:7}.cols ::slotted(.zn-col-8){flex-basis:calc(var(--zn-col-basis) * 8);min-width:calc(var(--col-width) * 8);flex-grow:8}.cols ::slotted(.zn-col-9){flex-basis:calc(var(--zn-col-basis) * 9);min-width:calc(var(--col-width) * 9);flex-grow:9}.cols ::slotted(.zn-col-10){flex-basis:calc(var(--zn-col-basis) * 10);min-width:calc(var(--col-width) * 10);flex-grow:10}.cols ::slotted(.zn-col-11){flex-basis:calc(var(--zn-col-basis) * 11);min-width:calc(var(--col-width) * 11);flex-grow:11}.cols ::slotted(.zn-col-12){flex-basis:calc(var(--zn-col-basis) * 12);min-width:calc(var(--col-width) * 12);flex-grow:12}.cols--mc-1{--col-width:calc(100% / 2)}.cols--mc-2{--col-width:calc(100% / 3)}.cols--mc-3{--col-width:calc(100% / 4)}.cols--mc-4{--col-width:calc(100% / 5)}.cols--mc-5{--col-width:calc(100% / 6)}.cols--mc-6{--col-width:calc(100% / 7)}.cols--mc-7{--col-width:calc(100% / 8)}.cols--mc-8{--col-width:calc(100% / 9)}.cols--mc-9{--col-width:calc(100% / 10)}.cols--mc-10{--col-width:calc(100% / 11)}.cols--mc-11{--col-width:calc(100% / 12)}.cols--mc-12{--col-width:calc(100% / 13)}.cols--layout-121 ::slotted(.zn-col-2){order:-1;min-width:100%}@container (min-width:1440px){.cols--layout-121 ::slotted(.zn-col-2){order:initial;min-width:46%}}.cols--divide ::slotted(*:not(:last-child)){position:relative}.cols--divide ::slotted(*:not(:last-child)):after{content:"";position:absolute;display:block;width:1px;top:0;height:100%;max-height:100%;right:calc(var(--zn-spacing-small) / 2 * -1);background-color:rgb(var(--zn-border-color))}.cols--no-gap{gap:0}.cols--border{overflow:hidden}.cols--border ::slotted(*){position:relative;padding-bottom:var(--zn-spacing-small)}.cols--border ::slotted(*):before{content:"";position:absolute;bottom:-1px;left:-100vw;right:-5px;z-index:1111;border-bottom:1px solid rgb(var(--zn-border-color)) !important}.cols ::slotted([stack-split]){display:flex;flex-direction:column;gap:var(--zn-gap)}.cols--pad{padding:var(--zn-spacing-2x-small)}.cols--pad-x{padding-inline:var(--zn-spacing-2x-small)}.cols--pad-y{padding-block:var(--zn-spacing-2x-small)}@container (max-width:359px){:host([stack-at=sm]) .cols ::slotted(*){--zn-stacked:1;--zn-stack-basis:100%;flex-basis:100%;min-width:100%;max-width:100%}:host([stack-at=sm]) .cols ::slotted([stack-split]){display:contents}:host([stack-at=sm]) .cols--divide ::slotted(*:not(:last-child)):after{display:none}}@container (max-width:479px){:host([stack-at=smp]) .cols ::slotted(*){--zn-stacked:1;--zn-stack-basis:100%;flex-basis:100%;min-width:100%;max-width:100%}:host([stack-at=smp]) .cols ::slotted([stack-split]){display:contents}:host([stack-at=smp]) .cols--divide ::slotted(*:not(:last-child)):after{display:none}}@container (max-width:599px){:host([stack-at=ph]) .cols ::slotted(*){--zn-stacked:1;--zn-stack-basis:100%;flex-basis:100%;min-width:100%;max-width:100%}:host([stack-at=ph]) .cols ::slotted([stack-split]){display:contents}:host([stack-at=ph]) .cols--divide ::slotted(*:not(:last-child)):after{display:none}}@container (max-width:767px){:host([stack-at=md]) .cols ::slotted(*){--zn-stacked:1;--zn-stack-basis:100%;flex-basis:100%;min-width:100%;max-width:100%}:host([stack-at=md]) .cols ::slotted([stack-split]){display:contents}:host([stack-at=md]) .cols--divide ::slotted(*:not(:last-child)):after{display:none}}@container (max-width:1099px){:host([stack-at=lg]) .cols ::slotted(*){--zn-stacked:1;--zn-stack-basis:100%;flex-basis:100%;min-width:100%;max-width:100%}:host([stack-at=lg]) .cols ::slotted([stack-split]){display:contents}:host([stack-at=lg]) .cols--divide ::slotted(*:not(:last-child)):after{display:none}}@container (max-width:1439px){:host([stack-at=hd]) .cols ::slotted(*){--zn-stacked:1;--zn-stack-basis:100%;flex-basis:100%;min-width:100%;max-width:100%}:host([stack-at=hd]) .cols ::slotted([stack-split]){display:contents}:host([stack-at=hd]) .cols--divide ::slotted(*:not(:last-child)):after{display:none}}@container (max-width:1959px){:host([stack-at="3k"]) .cols ::slotted(*){--zn-stacked:1;--zn-stack-basis:100%;flex-basis:100%;min-width:100%;max-width:100%}:host([stack-at="3k"]) .cols ::slotted([stack-split]){display:contents}:host([stack-at="3k"]) .cols--divide ::slotted(*:not(:last-child)):after{display:none}}@container (max-width:2559px){:host([stack-at="4k"]) .cols ::slotted(*){--zn-stacked:1;--zn-stack-basis:100%;flex-basis:100%;min-width:100%;max-width:100%}:host([stack-at="4k"]) .cols ::slotted([stack-split]){display:contents}:host([stack-at="4k"]) .cols--divide ::slotted(*:not(:last-child)):after{display:none}}`;var P0={first:-1,high:-1,last:1,low:1},N4="lg",Tr=class extends S{constructor(){super(...arguments);this.layout="";this.stackAt="";this.maxColumns=0;this.noGap=!1;this.border=!1;this.divide=!1;this.childObserver=new MutationObserver(()=>this.requestUpdate())}connectedCallback(){super.connectedCallback(),this.childObserver.observe(this,{childList:!0})}disconnectedCallback(){super.disconnectedCallback(),this.childObserver.disconnect()}stackOrder(t){let r=t.getAttribute("stack-order");if(r===null)return null;let n=r.trim().toLowerCase();if(n in P0)return P0[n];let a=parseInt(n,10);return isNaN(a)?null:a}applyStackOrder(t,r){let n=this.stackOrder(t);return t.style.order=n===null?"":`calc(var(--zn-stacked, 0) * ${n})`,r&&(t.style.flexBasis="var(--zn-stack-basis, auto)"),n}render(){let t=this.layout.split(/[\s,]+/).map(p=>parseInt(p)).filter(p=>!!p);t.length===0&&t.push(1,1,1,1),this.layout=t.join(","),this.maxColumns=t.reduce((p,h)=>p+h,0);let r="zn-col-",n=Array.from(this.querySelectorAll(":scope > *:not([slot])")),a=t.length,s=n.length-(n.length%a||a),l=!1;return n.forEach((p,h)=>{let m=p.className.split(" ").filter(b=>!b.startsWith(r));p.className=m.join(" ");let f=h%a;p.classList.add(r+t[f]),this.border&&h>=s?p.style.overflow="hidden":p.style.overflow="",l=this.applyStackOrder(p,!1)!==null||l,p.hasAttribute("stack-split")&&(l=!0,this.childObserver.observe(p,{childList:!0}),Array.from(p.children).forEach(b=>this.applyStackOrder(b,!0)))}),l&&!this.stackAt&&(this.stackAt=N4),u`
|
|
1602
1602
|
<div part="base" class="${M({cols:!0,"cols--no-gap":this.noGap,"cols--border":this.border,"cols--pad":this.pad,"cols--pad-x":this.padX,"cols--pad-y":this.padY,"cols--divide":this.divide,[`cols--layout-${this.layout.replaceAll(",","")}`]:!!this.layout,[`cols--mc-${this.maxColumns}`]:!!this.maxColumns})}">
|
|
1603
1603
|
<slot></slot>
|
|
1604
1604
|
</div>
|
|
@@ -4418,7 +4418,7 @@ endif::[]`,caretOffset:9},{key:"inline-formatting",label:"Strong",icon:"bold@lu"
|
|
|
4418
4418
|
</span>
|
|
4419
4419
|
${vq(i)}
|
|
4420
4420
|
</div>`}function yq(o){let i=o.trim();if(i.includes(`
|
|
4421
|
-
`))return null;let t=pq.exec(i);if(!t)return null;let[,r,n,a]=t;return yg(bq(r,n),[{kind:"content",lines:[a]}])}var
|
|
4421
|
+
`))return null;let t=pq.exec(i);if(!t)return null;let[,r,n,a]=t;return yg(bq(r,n),[{kind:"content",lines:[a]}])}var fe=class extends S{constructor(){super(...arguments);this.formControlController=new re(this,{assumeInteractionOn:["zn-input","zn-change"]});this.slashController=new ko(this,{menu:()=>this.mountSlashMenu(),items:()=>this.isSlashBlock()?mq.filter(t=>this.slashItemAvailable(t)):[],onSelect:t=>this.handleSlashSelect(t)});this.toolbarOverflow=new Lh(this,{groups:()=>[...this.shadowRoot?.querySelectorAll(".toolbar__group")??[]],container:()=>this.shadowRoot?.querySelector(".remarkd-editor__toolbar")});this.editingDraft="";this.includeRequest=null;this.rawEntryValue="";this.suppressValueSync=!1;this.suppressBlurCommit=!1;this.blocks=[];this.editingIndex=null;this.slashRecentKey="";this.hasSlashMenu=!1;this.imagePickerIndex=null;this.imageEdit=null;this.dropIndicator=null;this.dragIndex=null;this.editShell="";this.rawMode=!1;this.includeOptions=null;this.includeLoadFailed=!1;this.includePickerIndex=null;this.includeQuery="";this.linkPickerOpen=!1;this.linkQuery="";this.linkResults=null;this.linkSearchFailed=!1;this.linkSelection=null;this.linkSearchToken=0;this.linkRefs=new Map;this.linkRefsPending=!1;this.pendingDragHandle=null;this.dragStartX=0;this.dragStartY=0;this.dragGhost=null;this.dragPointerY=0;this.autoScrollFrame=null;this.name="";this.value="";this.defaultValue="";this.placeholder="Type something\u2026";this.attachmentUrl="";this.includeUrl="";this.linkUrl="";this.allowRaw=!1;this.required=!1;this.readonly=!1;this.disabled=!1;this.saveImageEdit=()=>{if(this.editingIndex===null||!this.imageEdit)return;let t=[...this.blocks];t[this.editingIndex]=this.serializeImageBlock(this.imageEdit),this.closeImageEdit(),this.updateBlocks(t)};this.closeImageEdit=()=>{this.editingIndex=null,this.imageEdit=null};this.deleteImageBlock=()=>{if(this.editingIndex===null)return;let t=[...this.blocks];t.splice(this.editingIndex,1),this.closeImageEdit(),this.updateBlocks(t)};this.editImageSource=()=>{if(this.editingIndex===null)return;let t=this.editingIndex;this.imageEdit=null,this.startEdit(t)};this.handleImageControlsKeydown=t=>{t.key==="Escape"?(t.preventDefault(),this.closeImageEdit()):t.key==="Enter"&&t.target.tagName==="INPUT"&&(t.preventDefault(),this.saveImageEdit())};this.handleEditBlur=()=>{this.suppressBlurCommit||this.commitEdit()};this.commitEdit=()=>{if(this.imageEdit){let a=this.editingIndex??this.blocks.length;return this.closeImageEdit(),a+1}if(this.slashController.close(),this.editingIndex===null)return this.blocks.length;let t=this.editingIndex,r=this.splitBlocks(this.editingDraft),n=[...this.blocks];return n.splice(t,1,...r),this.editingIndex=null,this.updateBlocks(n),t+r.length};this.handleDraftInput=t=>{let r=t.target;this.editingDraft=r.value,this.autosize(r);let n=this.computeEditShell(r.value);n!==this.editShell&&(this.editShell=n,this.updateComplete.then(()=>this.autosize(r))),this.emit("zn-input")};this.handleEditKeydown=t=>{let r=t.target;if(!this.slashController.open)if(t.key==="Enter"&&t.shiftKey){t.preventDefault(),this.suppressBlurCommit=!0;let n=this.commitEdit();this.insertDraftBlock(n)}else(t.key==="Escape"||t.key==="Enter"&&(t.metaKey||t.ctrlKey)||t.key==="Backspace"&&r.value==="")&&(t.preventDefault(),r.blur())};this.handleEditPaste=t=>{let r=Array.from(t.clipboardData?.files??[]).find(a=>a.type.startsWith("image/"));if(!r)return;t.preventDefault();let n=this.editingIndex??this.blocks.length;this.insertImage(r,n+1)};this.handleDragOver=t=>{this.rawMode||t.dataTransfer?.types.includes("Files")&&t.preventDefault()};this.handleDrop=t=>{if(this.rawMode)return;let r=Array.from(t.dataTransfer?.files??[]).find(n=>n.type.startsWith("image/"));r&&(t.preventDefault(),this.insertImage(r,this.blocks.length))};this.handleHandlePointerDown=t=>{t.button===0&&(t.preventDefault(),this.editingIndex!==null&&this.commitEdit(),this.pendingDragHandle=t.currentTarget,this.dragStartX=t.clientX,this.dragStartY=t.clientY,document.addEventListener("pointermove",this.handleDragPointerMove),document.addEventListener("pointerup",this.handleDragPointerUp),document.addEventListener("pointercancel",this.cancelDrag))};this.handleDragPointerMove=t=>{if(this.pendingDragHandle){if(t.buttons%2===0){this.cancelDrag();return}if(this.dragIndex===null){if(Math.abs(t.clientX-this.dragStartX)+Math.abs(t.clientY-this.dragStartY)<4)return;let n=this.pendingDragHandle.closest(".remarkd-editor__block"),a=Array.from(this.shadowRoot?.querySelectorAll(".remarkd-editor__block")??[]),s=n?a.indexOf(n):-1;if(s<0){this.cancelDrag();return}this.dragIndex=s,this.createDragGhost(s),document.body.style.cursor="grabbing"}this.dragPointerY=t.clientY,this.moveDragGhost(t.clientX,t.clientY),this.dropIndicator=this.insertionIndexFromY(t.clientY),this.autoScrollFrame??(this.autoScrollFrame=requestAnimationFrame(this.stepAutoScroll))}};this.stepAutoScroll=()=>{this.autoScrollFrame=null,!(this.dragIndex===null||!this.autoScroll())&&(this.dropIndicator=this.insertionIndexFromY(this.dragPointerY),this.autoScrollFrame=requestAnimationFrame(this.stepAutoScroll))};this.handleDragPointerUp=t=>{let r=this.dragIndex,n=r!==null?this.dropIndicator??this.insertionIndexFromY(t.clientY):null;if(this.cancelDrag(),r===null||n===null||n===r||n===r+1)return;let a=[...this.blocks],[s]=a.splice(r,1);n>r&&n--,a.splice(n,0,s),this.updateBlocks(a)};this.cancelDrag=()=>{this.pendingDragHandle=null,this.autoScrollFrame!==null&&cancelAnimationFrame(this.autoScrollFrame),this.autoScrollFrame=null,document.removeEventListener("pointermove",this.handleDragPointerMove),document.removeEventListener("pointerup",this.handleDragPointerUp),document.removeEventListener("pointercancel",this.cancelDrag),this.dragIndex=null,this.dropIndicator=null,this.dragGhost?.remove(),this.dragGhost=null,document.body.style.cursor=""};this.closeLinkPicker=()=>{this.linkPickerOpen=!1,this.linkSelection=null,this.suppressBlurCommit=!1,clearTimeout(this.linkSearchTimer),this.updateComplete.then(()=>{this.shadowRoot?.querySelector(".remarkd-editor__input")?.focus({preventScroll:!0})})};this.closeIncludePicker=()=>{this.includePickerIndex=null};this.closeImagePicker=()=>{this.imagePickerIndex=null};this.handleImagePicked=t=>{let r=t.target.files?.[0];if(!r)return;let n=this.imagePickerIndex??this.blocks.length;this.imagePickerIndex=null,this.insertImage(r,n)};this.toggleRawMode=()=>{if(this.rawMode){this.commitRaw(),this.rawMode=!1;return}this.editingIndex!==null&&this.commitEdit(),this.slashController.detach(),this.rawEntryValue=this.value,this.rawMode=!0,this.focusRaw()};this.handleRawInput=t=>{let r=t.target;r.value!==this.value&&(this.suppressValueSync=!0,this.value=r.value,this.formControlController.updateValidity(),this.emit("zn-input"))};this.commitRaw=()=>{let t=this.splitBlocks(this.value||""),r=t.join(`
|
|
4422
4422
|
|
|
4423
4423
|
`);this.blocks=t,r!==this.value&&(this.suppressValueSync=!0,this.value=r),this.value!==this.rawEntryValue&&(this.rawEntryValue=this.value,this.formControlController.updateValidity(),this.emit("zn-change"))}}get validity(){return this.validationInput?.validity}get validationMessage(){return this.validationInput?.validationMessage??""}checkValidity(){return this.validationInput?.checkValidity()??!0}getForm(){return this.formControlController.getForm()}reportValidity(){return this.validationInput?.reportValidity()??!0}setCustomValidity(t){this.validationInput?.setCustomValidity(t),this.formControlController.updateValidity()}focus(){if(this.rawMode){this.shadowRoot?.querySelector(".remarkd-editor__raw")?.focus();return}this.blocks.length?this.startEdit(0):this.insertDraftBlock(0)}blur(){let t=this.rawMode?".remarkd-editor__raw":".remarkd-editor__input";this.shadowRoot?.querySelector(t)?.blur()}firstUpdated(t){super.firstUpdated(t),this.formControlController.updateValidity(),this.hasIncludeBlock()&&this.loadIncludeOptions(),this.resolveContentLinks()}updated(t){super.updated(t),this.shadowRoot?.querySelectorAll(".remarkd-editor__rendered--parsed").forEach(r=>this.markVariables(r)),this.shadowRoot?.querySelectorAll(".remarkd-editor__rendered--parsed").forEach(r=>this.markContentLinks(r))}disconnectedCallback(){super.disconnectedCallback(),this.cancelDrag()}handleValueChange(){if(this.suppressValueSync){this.suppressValueSync=!1;return}this.blocks=this.splitBlocks(this.value||""),this.hasUpdated&&this.hasIncludeBlock()&&this.loadIncludeOptions(),this.hasUpdated&&this.resolveContentLinks()}handleIncludeUrlChange(){this.includeRequest=null,this.includeOptions=null,this.includeLoadFailed=!1,this.hasIncludeBlock()&&this.loadIncludeOptions()}handleLinkUrlChange(){this.linkRefs.clear(),this.linkRefsPending=!1,this.resolveContentLinks()}splitBlocks(t){let r=t.replace(/\r\n/g,`
|
|
4424
4424
|
`).split(`
|
|
@@ -4645,7 +4645,7 @@ endif::[]`,caretOffset:9},{key:"inline-formatting",label:"Strong",icon:"bold@lu"
|
|
|
4645
4645
|
<zn-button type="button" icon-button="small" plain icon="x@lu"
|
|
4646
4646
|
tooltip="Cancel"
|
|
4647
4647
|
@click=${this.closeImagePicker}></zn-button>
|
|
4648
|
-
</div>`}};
|
|
4648
|
+
</div>`}};fe.styles=z(W2),fe.dependencies={"zn-dropdown":ur,"zn-menu":on,"zn-menu-item":xi,"zn-slash-menu":Ca},c([F(".remarkd-editor__validation")],fe.prototype,"validationInput",2),c([F("zn-slash-menu")],fe.prototype,"slashMenuElement",2),c([I()],fe.prototype,"blocks",2),c([I()],fe.prototype,"editingIndex",2),c([d({attribute:"slash-recent-key"})],fe.prototype,"slashRecentKey",2),c([I()],fe.prototype,"hasSlashMenu",2),c([I()],fe.prototype,"imagePickerIndex",2),c([I()],fe.prototype,"imageEdit",2),c([I()],fe.prototype,"dropIndicator",2),c([I()],fe.prototype,"dragIndex",2),c([I()],fe.prototype,"editShell",2),c([I()],fe.prototype,"rawMode",2),c([I()],fe.prototype,"includeOptions",2),c([I()],fe.prototype,"includeLoadFailed",2),c([I()],fe.prototype,"includePickerIndex",2),c([I()],fe.prototype,"includeQuery",2),c([I()],fe.prototype,"linkPickerOpen",2),c([I()],fe.prototype,"linkQuery",2),c([I()],fe.prototype,"linkResults",2),c([I()],fe.prototype,"linkSearchFailed",2),c([d()],fe.prototype,"name",2),c([d()],fe.prototype,"value",2),c([Ee()],fe.prototype,"defaultValue",2),c([d()],fe.prototype,"placeholder",2),c([d({attribute:"attachment-url"})],fe.prototype,"attachmentUrl",2),c([d({attribute:"include-url"})],fe.prototype,"includeUrl",2),c([d({attribute:"link-url"})],fe.prototype,"linkUrl",2),c([d({type:Boolean,attribute:"allow-raw",reflect:!0})],fe.prototype,"allowRaw",2),c([d({type:Boolean,reflect:!0})],fe.prototype,"required",2),c([d({type:Boolean,reflect:!0})],fe.prototype,"readonly",2),c([d({type:Boolean,reflect:!0})],fe.prototype,"disabled",2),c([K("value")],fe.prototype,"handleValueChange",1),c([K("includeUrl",{waitUntilFirstUpdate:!0})],fe.prototype,"handleIncludeUrlChange",1),c([K("linkUrl",{waitUntilFirstUpdate:!0})],fe.prototype,"handleLinkUrlChange",1);var qh=fe;fe.define("zn-remarkd-editor");var ik=_`:host{display:block}.translations{padding:var(--zn-spacing-small) var(--zn-spacing-medium)}.translations__language{margin-bottom:var(--zn-spacing-medium)}.translations__body{display:block}.translations--flush,.translations--grouped{padding:0}`;var Ae=class extends S{constructor(){super(...arguments);this.formControlController=new re(this);this.hasSlotController=new Y(this,"label","help-text");this.name="";this.value='{"en":""}';this.label="";this.helpText="";this.disabled=!1;this.required=!1;this.flush=!1;this.inputType="text";this.allowRaw=!1;this.attachmentUrl="";this.includeUrl="";this.linkUrl="";this.inlineEdit=!1;this.slashItems=[];this.slashPreset="";this.slashTrigger="/";this.slashHeading="Insert";this.slashHideKeys=!1;this.slashRecentKey="";this.grouped=!1;this.languages={en:"EN"};this.values={};this.defaultValue='{"en":""}';this._activeLanguage="en";this.handleLanguageSelect=t=>{t.stopPropagation();let r=t.target.value;typeof r=="string"&&r&&r!==this._activeLanguage&&this.switchLanguage(r)};this.handleLanguageInput=t=>{t.stopPropagation()};this.switchLanguage=t=>{this._activeLanguage=t,this.requestUpdate()};this.handleValueUpdate=t=>{let r=t.target;if(this._activeLanguage){let n=r.value;n!==this.values[this._activeLanguage]&&(this.values={...this.values,[this._activeLanguage]:n},this.updateValue())}};this.handleKeyDown=t=>{if(t.key==="Enter"){if(t.target instanceof lp||t.target instanceof Jo||t.target instanceof qh)return;!(t.altKey||t.ctrlKey||t.metaKey||t.shiftKey)&&!t.defaultPrevented&&!t.isComposing&&this.formControlController.submit()}};this.handleSubmit=()=>{this.formControlController.submit()}}get validity(){return Ze}get validationMessage(){return""}checkValidity(){return!0}getForm(){return this.formControlController.getForm()}reportValidity(){return!0}setCustomValidity(){}setActiveLanguage(t){this._activeLanguage=t,this.requestUpdate()}getActiveLanguage(){return this._activeLanguage}addLanguageKey(t){let r=this.pendingValues();Object.prototype.hasOwnProperty.call(r,t)||(this.values={...r,[t]:""},this.updateValue())}getValueLanguages(){return Object.keys(this.pendingValues())}hasTranslation(t){return(this.pendingValues()[t]??"").trim()!==""}languageState(t){return this.hasTranslation(t)?{type:"success",label:"Translated"}:{type:"error",label:t==="en"?"Empty":"English"}}languageLabel(t){return this.languages[t]??t.toUpperCase()}pendingValues(){if(Object.keys(this.values).length>0)return this.values;try{return JSON.parse(this.value||"{}")}catch{return this.values}}firstUpdated(){this.hasAttribute("value")||(this.defaultValue=this.value),this.formControlController.updateValidity()}willUpdate(t){let r=t.has("value"),n=t.has("values");if(r&&n){let a=this.value==='{"en":""}',s=Object.keys(this.values).length===0;a&&!s?r=!1:!a&&s?n=!1:this.hasAttribute("values")&&!this.hasAttribute("value")?r=!1:this.hasAttribute("value")&&!this.hasAttribute("values")&&(n=!1)}if(r)try{let a=JSON.parse(this.value||"{}");JSON.stringify(a)!==JSON.stringify(this.values)&&(this.values=a)}catch{}if(n&&(this.value=JSON.stringify(this.values),!this.grouped)){let a=Object.prototype.hasOwnProperty.call(this.values,this._activeLanguage)||Object.prototype.hasOwnProperty.call(this.languages,this._activeLanguage);if(!this._activeLanguage||!a&&this._activeLanguage!=="en"){let s=Object.keys(this.values);s.length>0?this._activeLanguage=s[0]:this._activeLanguage="en"}}}updateValue(){this.value=JSON.stringify(this.values),this.emit("zn-change"),this.emit("zn-input")}renderField(t,r,n){let a=n?"rtl":"ltr";return this.inlineEdit?u`
|
|
4649
4649
|
<zn-inline-edit
|
|
4650
4650
|
input-type=${this.inputType}
|
|
4651
4651
|
textarea-rows=${N(this.textareaRows)}
|
|
@@ -926,6 +926,30 @@ The data table expects responses in the following format:
|
|
|
926
926
|
|
|
927
927
|
For POST requests, the table sends a JSON body:
|
|
928
928
|
|
|
929
|
+
```json
|
|
930
|
+
{
|
|
931
|
+
"page": 1,
|
|
932
|
+
"perPage": 10,
|
|
933
|
+
"sortColumn": "name",
|
|
934
|
+
"sortDirection": "asc",
|
|
935
|
+
"filter": "",
|
|
936
|
+
"search": "search term",
|
|
937
|
+
"status": "open"
|
|
938
|
+
}
|
|
939
|
+
```
|
|
940
|
+
|
|
941
|
+
Field values from inputs slotted into a `zn-data-table-search`, and anything set on the table's `requestParams`, are merged at the **root** of the body under their own `name`. The search text itself is sent as `search`.
|
|
942
|
+
|
|
943
|
+
Parameters from the `inputs` slot are context/system values (a CSRF token, a package name, and the like) sent with every request. They are merged at the root too.
|
|
944
|
+
|
|
945
|
+
### Wrapped search fields
|
|
946
|
+
|
|
947
|
+
Add `wrap-search-fields` to nest the search field values under a `searchFields` object instead, so a backend can bind them to a single map rather than arbitrary top-level keys:
|
|
948
|
+
|
|
949
|
+
```html
|
|
950
|
+
<zn-data-table wrap-search-fields data-uri="/data"></zn-data-table>
|
|
951
|
+
```
|
|
952
|
+
|
|
929
953
|
```json
|
|
930
954
|
{
|
|
931
955
|
"page": 1,
|
|
@@ -941,6 +965,4 @@ For POST requests, the table sends a JSON body:
|
|
|
941
965
|
}
|
|
942
966
|
```
|
|
943
967
|
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
Parameters from the `inputs` slot are context/system values (a CSRF token, a package name, and the like) sent with every request. They are merged at the **root** of the body, not inside `searchFields`.
|
|
968
|
+
`q` mirrors the `search` text, which is still sent at the root. Empty values are dropped, and `searchFields` is `null` when nothing meaningful remains — no search text and no field values — so the backend can treat that as "no search". Parameters from the `inputs` slot stay at the root either way.
|
package/package.json
CHANGED
|
@@ -151,8 +151,6 @@ interface DataRequest {
|
|
|
151
151
|
sortDirection: string;
|
|
152
152
|
filter: string;
|
|
153
153
|
search: string;
|
|
154
|
-
// Search-related fields (from the search component's `fields` slot) plus `q` (the search text),
|
|
155
|
-
// wrapped so the backend can bind them to a single map instead of arbitrary root-level keys.
|
|
156
154
|
searchFields?: Record<string, any> | null;
|
|
157
155
|
}
|
|
158
156
|
|
|
@@ -278,6 +276,13 @@ export default class ZnDataTable extends ZincElement {
|
|
|
278
276
|
*/
|
|
279
277
|
@property({attribute: 'sharable', type: Boolean}) sharable: boolean = false;
|
|
280
278
|
|
|
279
|
+
/**
|
|
280
|
+
* When set, extra request params (search-component field values) are nested under a
|
|
281
|
+
* `searchFields` object - with `q` mirroring the search text - instead of being merged at the
|
|
282
|
+
* root of the request body.
|
|
283
|
+
*/
|
|
284
|
+
@property({attribute: 'wrap-search-fields', type: Boolean}) wrapSearchFields: boolean = false;
|
|
285
|
+
|
|
281
286
|
@property({attribute: 'group-by'}) groupBy = '';
|
|
282
287
|
|
|
283
288
|
@property() groups = '';
|
|
@@ -357,7 +362,7 @@ export default class ZnDataTable extends ZincElement {
|
|
|
357
362
|
};
|
|
358
363
|
|
|
359
364
|
// Inputs-slot values are context/system params (e.g. csrf token, package name) sent with
|
|
360
|
-
// every request
|
|
365
|
+
// every request.
|
|
361
366
|
const inputs = this.hasSlotController.getSlots(ActionSlots.inputs.valueOf());
|
|
362
367
|
const params: Record<string, any> = {};
|
|
363
368
|
if (inputs) {
|
|
@@ -374,24 +379,28 @@ export default class ZnDataTable extends ZincElement {
|
|
|
374
379
|
Object.assign(requestData, params);
|
|
375
380
|
}
|
|
376
381
|
|
|
377
|
-
//
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
382
|
+
// Add any extra request params
|
|
383
|
+
const extraParams = requestParams && typeof requestParams === 'object'
|
|
384
|
+
? requestParams as Record<string, unknown>
|
|
385
|
+
: {};
|
|
386
|
+
|
|
387
|
+
if (this.wrapSearchFields) {
|
|
388
|
+
// Opt-in shape: field values nested under `searchFields`, with `q` mirroring the search
|
|
389
|
+
// text, so a backend can bind them to one map. Empty values are dropped, and the key is
|
|
390
|
+
// null when nothing is set. The root `search` key is sent either way.
|
|
391
|
+
const searchFields: Record<string, any> = {};
|
|
392
|
+
for (const [key, value] of Object.entries(extraParams)) {
|
|
385
393
|
if (value !== undefined && value !== null && value !== '') {
|
|
386
394
|
searchFields[key] = value;
|
|
387
395
|
}
|
|
388
396
|
}
|
|
397
|
+
if (this.search || Object.keys(searchFields).length > 0) {
|
|
398
|
+
searchFields.q = this.search;
|
|
399
|
+
}
|
|
400
|
+
requestData.searchFields = Object.keys(searchFields).length > 0 ? searchFields : null;
|
|
401
|
+
} else {
|
|
402
|
+
Object.assign(requestData, extraParams);
|
|
389
403
|
}
|
|
390
|
-
if (this.search || Object.keys(searchFields).length > 0) {
|
|
391
|
-
searchFields.q = this.search;
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
requestData.searchFields = Object.keys(searchFields).length > 0 ? searchFields : null;
|
|
395
404
|
|
|
396
405
|
// This is also used for Rubix, so it may not work for your application.
|
|
397
406
|
const response = await fetch(dataUri, {
|
|
@@ -623,7 +632,7 @@ export default class ZnDataTable extends ZincElement {
|
|
|
623
632
|
params.set(key, str);
|
|
624
633
|
};
|
|
625
634
|
|
|
626
|
-
// Extra field values
|
|
635
|
+
// Extra field values - their default is empty, so setParam writes them only when set.
|
|
627
636
|
const known = new Set(ZnDataTable._sharableKnownKeys);
|
|
628
637
|
Object.entries(this.requestParams).forEach(([key, value]) => {
|
|
629
638
|
if (known.has(key) || key === 'searchUri') return;
|
|
@@ -323,9 +323,9 @@ describe('<zn-data-table>', () => {
|
|
|
323
323
|
expect(link?.hasAttribute('title')).to.be.false;
|
|
324
324
|
});
|
|
325
325
|
|
|
326
|
-
// Search-component field values
|
|
327
|
-
//
|
|
328
|
-
describe('
|
|
326
|
+
// Search-component field values and any other extra request params are merged at the root of
|
|
327
|
+
// the POST body, alongside the dedicated `search` key.
|
|
328
|
+
describe('extra request params', () => {
|
|
329
329
|
const rowResponse = () => new Response(JSON.stringify({
|
|
330
330
|
rows: [{id: '1', cells: [{text: 'Row', column: 'name'}]}],
|
|
331
331
|
page: 1,
|
|
@@ -333,7 +333,7 @@ describe('<zn-data-table>', () => {
|
|
|
333
333
|
total: 1,
|
|
334
334
|
}), {status: 200, headers: {'Content-Type': 'application/json'}});
|
|
335
335
|
|
|
336
|
-
it('
|
|
336
|
+
it('sends search-component field values at the root alongside search', async () => {
|
|
337
337
|
const originalFetch = window.fetch;
|
|
338
338
|
const bodies: Record<string, unknown>[] = [];
|
|
339
339
|
window.fetch = (_url: RequestInfo | URL, options?: RequestInit) => {
|
|
@@ -355,6 +355,89 @@ describe('<zn-data-table>', () => {
|
|
|
355
355
|
|
|
356
356
|
const body = bodies[bodies.length - 1];
|
|
357
357
|
expect(body.search).to.equal('foo');
|
|
358
|
+
expect(body.status).to.equal('open');
|
|
359
|
+
expect(body.searchFields).to.be.undefined;
|
|
360
|
+
} finally {
|
|
361
|
+
window.fetch = originalFetch;
|
|
362
|
+
}
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
it('sends no extra keys when no search or field values are set', async () => {
|
|
366
|
+
const originalFetch = window.fetch;
|
|
367
|
+
const bodies: Record<string, unknown>[] = [];
|
|
368
|
+
window.fetch = (_url: RequestInfo | URL, options?: RequestInit) => {
|
|
369
|
+
if (options?.body) bodies.push(JSON.parse(options.body as string) as Record<string, unknown>);
|
|
370
|
+
return Promise.resolve(rowResponse());
|
|
371
|
+
};
|
|
372
|
+
|
|
373
|
+
try {
|
|
374
|
+
await fixture<ZnDataTable>(html`
|
|
375
|
+
<zn-data-table data-uri="/test-data" headers='{"name": {"key": "name", "label": "Name"}}'></zn-data-table>`);
|
|
376
|
+
await waitUntil(() => bodies.length > 0);
|
|
377
|
+
|
|
378
|
+
const known = ['filter', 'page', 'perPage', 'search', 'sortColumn', 'sortDirection'];
|
|
379
|
+
expect(Object.keys(bodies[bodies.length - 1]).filter(k => !known.includes(k))).to.deep.equal([]);
|
|
380
|
+
} finally {
|
|
381
|
+
window.fetch = originalFetch;
|
|
382
|
+
}
|
|
383
|
+
});
|
|
384
|
+
|
|
385
|
+
it('sends inputs-slot params at the request root', async () => {
|
|
386
|
+
const originalFetch = window.fetch;
|
|
387
|
+
const bodies: Record<string, unknown>[] = [];
|
|
388
|
+
window.fetch = (_url: RequestInfo | URL, options?: RequestInit) => {
|
|
389
|
+
if (options?.body) bodies.push(JSON.parse(options.body as string) as Record<string, unknown>);
|
|
390
|
+
return Promise.resolve(rowResponse());
|
|
391
|
+
};
|
|
392
|
+
|
|
393
|
+
try {
|
|
394
|
+
const el = await fixture<ZnDataTable>(html`
|
|
395
|
+
<zn-data-table data-uri="/test-data" headers='{"name": {"key": "name", "label": "Name"}}'>
|
|
396
|
+
<input slot="inputs" name="csrf" value="tok">
|
|
397
|
+
</zn-data-table>`);
|
|
398
|
+
await waitUntil(() => bodies.length > 0);
|
|
399
|
+
el.refresh();
|
|
400
|
+
await waitUntil(() => bodies.length > 1);
|
|
401
|
+
|
|
402
|
+
expect(bodies[bodies.length - 1].csrf).to.equal('tok');
|
|
403
|
+
} finally {
|
|
404
|
+
window.fetch = originalFetch;
|
|
405
|
+
}
|
|
406
|
+
});
|
|
407
|
+
});
|
|
408
|
+
|
|
409
|
+
// With `wrap-search-fields`, the same values are nested under `searchFields` instead, with `q`
|
|
410
|
+
// mirroring the search text.
|
|
411
|
+
describe('wrap-search-fields', () => {
|
|
412
|
+
const rowResponse = () => new Response(JSON.stringify({
|
|
413
|
+
rows: [{id: '1', cells: [{text: 'Row', column: 'name'}]}],
|
|
414
|
+
page: 1,
|
|
415
|
+
perPage: 10,
|
|
416
|
+
total: 1,
|
|
417
|
+
}), {status: 200, headers: {'Content-Type': 'application/json'}});
|
|
418
|
+
|
|
419
|
+
it('nests field values under searchFields with q mirroring the search text', async () => {
|
|
420
|
+
const originalFetch = window.fetch;
|
|
421
|
+
const bodies: Record<string, unknown>[] = [];
|
|
422
|
+
window.fetch = (_url: RequestInfo | URL, options?: RequestInit) => {
|
|
423
|
+
if (options?.body) bodies.push(JSON.parse(options.body as string) as Record<string, unknown>);
|
|
424
|
+
return Promise.resolve(rowResponse());
|
|
425
|
+
};
|
|
426
|
+
|
|
427
|
+
try {
|
|
428
|
+
const el = await fixture<ZnDataTable>(html`
|
|
429
|
+
<zn-data-table wrap-search-fields data-uri="/test-data"
|
|
430
|
+
headers='{"name": {"key": "name", "label": "Name"}}'></zn-data-table>`);
|
|
431
|
+
await waitUntil(() => bodies.length > 0);
|
|
432
|
+
|
|
433
|
+
el.search = 'foo';
|
|
434
|
+
el.requestParams = {status: 'open', empty: ''};
|
|
435
|
+
el.refresh();
|
|
436
|
+
await waitUntil(() => bodies.some(b => b.search === 'foo'));
|
|
437
|
+
|
|
438
|
+
const body = bodies[bodies.length - 1];
|
|
439
|
+
expect(body.search).to.equal('foo');
|
|
440
|
+
expect(body.status).to.be.undefined;
|
|
358
441
|
expect(body.searchFields).to.deep.equal({status: 'open', q: 'foo'});
|
|
359
442
|
} finally {
|
|
360
443
|
window.fetch = originalFetch;
|
|
@@ -371,7 +454,8 @@ describe('<zn-data-table>', () => {
|
|
|
371
454
|
|
|
372
455
|
try {
|
|
373
456
|
await fixture<ZnDataTable>(html`
|
|
374
|
-
<zn-data-table data-uri="/test-data"
|
|
457
|
+
<zn-data-table wrap-search-fields data-uri="/test-data"
|
|
458
|
+
headers='{"name": {"key": "name", "label": "Name"}}'></zn-data-table>`);
|
|
375
459
|
await waitUntil(() => bodies.length > 0);
|
|
376
460
|
|
|
377
461
|
expect(bodies[bodies.length - 1].searchFields).to.be.null;
|
|
@@ -380,7 +464,7 @@ describe('<zn-data-table>', () => {
|
|
|
380
464
|
}
|
|
381
465
|
});
|
|
382
466
|
|
|
383
|
-
it('keeps inputs-slot params at the request root
|
|
467
|
+
it('keeps inputs-slot params at the request root', async () => {
|
|
384
468
|
const originalFetch = window.fetch;
|
|
385
469
|
const bodies: Record<string, unknown>[] = [];
|
|
386
470
|
window.fetch = (_url: RequestInfo | URL, options?: RequestInit) => {
|
|
@@ -390,7 +474,8 @@ describe('<zn-data-table>', () => {
|
|
|
390
474
|
|
|
391
475
|
try {
|
|
392
476
|
const el = await fixture<ZnDataTable>(html`
|
|
393
|
-
<zn-data-table data-uri="/test-data"
|
|
477
|
+
<zn-data-table wrap-search-fields data-uri="/test-data"
|
|
478
|
+
headers='{"name": {"key": "name", "label": "Name"}}'>
|
|
394
479
|
<input slot="inputs" name="csrf" value="tok">
|
|
395
480
|
</zn-data-table>`);
|
|
396
481
|
await waitUntil(() => bodies.length > 0);
|