@verifiedinc-public/shared-ui-elements 12.22.0 → 12.22.1

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.
@@ -35,7 +35,7 @@ export interface DataTableExportSection {
35
35
  export type DataTableExportRowDetails<TData extends DataTableData> = (row: TData) => DataTableExportSection[];
36
36
  /**
37
37
  * Snapshot of the displayed table used by every export format: the
38
- * filtered + sorted rows across every page and the visible accessor
38
+ * filtered + sorted rows on the current page and the visible accessor
39
39
  * columns in display order.
40
40
  */
41
41
  export interface DataTableExportModel {
@@ -83,11 +83,10 @@ export interface DataTableExportModelOptions<TData extends DataTableData> {
83
83
  toRecord?: (row: TData) => unknown;
84
84
  }
85
85
  /**
86
- * Builds the export snapshot from the table instance. Rows come from the
87
- * pre-pagination row model, so they reflect the active filters, quick
88
- * search and sort order across every page (with manual pagination only
89
- * the loaded page is available), unless `rows` supplies them. Display-only
90
- * columns (no accessor, e.g. expand chevrons) are skipped.
86
+ * Builds the export snapshot from the table instance. Rows are the ones
87
+ * on screen — the current page with the active filters, quick search and
88
+ * sort order — unless `rows` supplies them. Display-only columns (no
89
+ * accessor, e.g. expand chevrons) are skipped.
91
90
  */
92
91
  export declare function getDataTableExportModel<TData extends DataTableData>(table: Table<TData>, additionalColumns?: ReadonlyArray<DataTableExportColumn<TData>>, { rows: exportRows, rowDetails, toRecord, }?: DataTableExportModelOptions<TData>): DataTableExportModel;
93
92
  /** Downloads the export snapshot as `<filename>.csv`. */
@@ -1,4 +1,4 @@
1
- "use strict";import{getColumnLabel as U}from"./DataTable.utils.mjs";const y=5;async function v(e,t){const o=await e({pageIndex:0,pageSize:t}),n=Math.ceil(o.rowCount/t),s=[...o.rows];for(let p=1;p<n;p+=y){const a=Array.from({length:Math.min(y,n-p)},(d,l)=>p+l),u=await Promise.all(a.map(async d=>await e({pageIndex:d,pageSize:t})));for(const d of u)s.push(...d.rows)}return s}function x(e){return e==null?"":typeof e=="number"||typeof e=="boolean"?e:e instanceof Date?e.toLocaleString():typeof e=="object"?JSON.stringify(e):String(e)}function k(e,t=[],{rows:o,rowDetails:n,toRecord:s}={}){const p=e.getVisibleLeafColumns().filter(r=>r.accessorFn!==void 0),a=t.filter(r=>r.position==="start"),u=t.filter(r=>r.position!=="start"),d=p.map(r=>{var c;const f=(c=r.parent)==null?void 0:c.columnDef.header;return typeof f=="string"?f:""}),l=d.some(r=>r!=="")?a.map(()=>"").concat(d.map((r,c)=>c>0&&d[c-1]===r?"":r),u.map(()=>"")):void 0,i=o??e.getPrePaginationRowModel().rows.map(r=>r.original);return{groupHeader:l,rowDetails:n?i.map(r=>n(r)):void 0,records:i.map(r=>s?s(r):r),header:[...a.map(r=>r.header),...p.map(r=>U(r)),...u.map(r=>r.header)],rows:i.map((r,c)=>[...a.map(f=>x(f.value(r))),...p.map(f=>{var m;return x((m=f.accessorFn)==null?void 0:m.call(f,r,c))}),...u.map(f=>x(f.value(r)))])}}function w(e,t){const o=URL.createObjectURL(e),n=document.createElement("a");n.href=o,n.download=t,n.click(),URL.revokeObjectURL(o)}const $=/^[=+\-@\t\r]/;function D(e){let t=String(e);return typeof e=="string"&&t.length>1&&$.test(t)&&(t=`'${t}`),/[",\n\r]/.test(t)?`"${t.replace(/"/g,'""')}"`:t}function T(e){return e.rows.length>0?e.rows:e.emptyMessage?[[e.emptyMessage]]:[]}function _(e){return e.lines??e.rows.map(t=>t.map(String).filter(Boolean).join(" "))}function S(e){const t=[],o=new Set;for(const n of e.rowDetails??[])for(const s of n)t.includes(s.title)||t.push(s.title),s.rows.length>0&&o.add(s.title);return t.filter(n=>o.has(n))}function b(e){const t=S(e),o=e.rows.map((s,p)=>{var a;const u=((a=e.rowDetails)==null?void 0:a[p])??[];return[...s,...t.map(d=>{const l=u.find(i=>i.title===d);return l?_(l).join(`
1
+ "use strict";import{getColumnLabel as U}from"./DataTable.utils.mjs";const y=5;async function v(e,t){const o=await e({pageIndex:0,pageSize:t}),n=Math.ceil(o.rowCount/t),s=[...o.rows];for(let p=1;p<n;p+=y){const a=Array.from({length:Math.min(y,n-p)},(d,l)=>p+l),u=await Promise.all(a.map(async d=>await e({pageIndex:d,pageSize:t})));for(const d of u)s.push(...d.rows)}return s}function x(e){return e==null?"":typeof e=="number"||typeof e=="boolean"?e:e instanceof Date?e.toLocaleString():typeof e=="object"?JSON.stringify(e):String(e)}function k(e,t=[],{rows:o,rowDetails:n,toRecord:s}={}){const p=e.getVisibleLeafColumns().filter(r=>r.accessorFn!==void 0),a=t.filter(r=>r.position==="start"),u=t.filter(r=>r.position!=="start"),d=p.map(r=>{var c;const f=(c=r.parent)==null?void 0:c.columnDef.header;return typeof f=="string"?f:""}),l=d.some(r=>r!=="")?a.map(()=>"").concat(d.map((r,c)=>c>0&&d[c-1]===r?"":r),u.map(()=>"")):void 0,i=o??e.getRowModel().rows.map(r=>r.original);return{groupHeader:l,rowDetails:n?i.map(r=>n(r)):void 0,records:i.map(r=>s?s(r):r),header:[...a.map(r=>r.header),...p.map(r=>U(r)),...u.map(r=>r.header)],rows:i.map((r,c)=>[...a.map(f=>x(f.value(r))),...p.map(f=>{var m;return x((m=f.accessorFn)==null?void 0:m.call(f,r,c))}),...u.map(f=>x(f.value(r)))])}}function w(e,t){const o=URL.createObjectURL(e),n=document.createElement("a");n.href=o,n.download=t,n.click(),URL.revokeObjectURL(o)}const $=/^[=+\-@\t\r]/;function D(e){let t=String(e);return typeof e=="string"&&t.length>1&&$.test(t)&&(t=`'${t}`),/[",\n\r]/.test(t)?`"${t.replace(/"/g,'""')}"`:t}function T(e){return e.rows.length>0?e.rows:e.emptyMessage?[[e.emptyMessage]]:[]}function _(e){return e.lines??e.rows.map(t=>t.map(String).filter(Boolean).join(" "))}function S(e){const t=[],o=new Set;for(const n of e.rowDetails??[])for(const s of n)t.includes(s.title)||t.push(s.title),s.rows.length>0&&o.add(s.title);return t.filter(n=>o.has(n))}function b(e){const t=S(e),o=e.rows.map((s,p)=>{var a;const u=((a=e.rowDetails)==null?void 0:a[p])??[];return[...s,...t.map(d=>{const l=u.find(i=>i.title===d);return l?_(l).join(`
2
2
  `):""})]}),n=e.groupHeader?[...e.groupHeader,...t.map(()=>"")]:void 0;return[...n?[n]:[],[...e.header,...t],...o]}function j(e,t){const o=b(e).map(s=>s.map(D).join(",")),n=new Blob(["\uFEFF",o.join(`
3
3
  `)],{type:"text/csv;charset=utf-8;"});w(n,`${t}.csv`)}function A(e,t){const o=new Blob([JSON.stringify(e.records??[],null,2)],{type:"application/json;charset=utf-8;"});w(o,`${t}.json`)}function g(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}function R(e){let t="",o=e+1;for(;o>0;)t=String.fromCharCode(65+(o-1)%26)+t,o=Math.floor((o-1)/26);return t}function C(e){return`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><sheetData>${b(e).map((t,o)=>{const n=t.map((s,p)=>{const a=`${R(p)}${o+1}`;return typeof s=="number"&&Number.isFinite(s)?`<c r="${a}"><v>${s}</v></c>`:typeof s=="boolean"?`<c r="${a}" t="b"><v>${s?1:0}</v></c>`:`<c r="${a}" t="inlineStr"><is><t xml:space="preserve">${g(String(s))}</t></is></c>`}).join("");return`<row r="${o+1}">${n}</row>`}).join("")}</sheetData></worksheet>`}const F=[{name:"[Content_Types].xml",content:'<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/><Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/><Override PartName="/xl/worksheets/sheet1.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/></Types>'},{name:"_rels/.rels",content:'<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/></Relationships>'},{name:"xl/workbook.xml",content:'<?xml version="1.0" encoding="UTF-8" standalone="yes"?><workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"><sheets><sheet name="Data" sheetId="1" r:id="rId1"/></sheets></workbook>'},{name:"xl/_rels/workbook.xml.rels",content:'<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet1.xml"/></Relationships>'}],E=(()=>{const e=new Uint32Array(256);for(let t=0;t<256;t++){let o=t;for(let n=0;n<8;n++)o=o&1?3988292384^o>>>1:o>>>1;e[t]=o>>>0}return e})();function I(e){let t=4294967295;for(let o=0;o<e.length;o++)t=E[(t^e[o])&255]^t>>>8;return(t^4294967295)>>>0}function L(e){const t=new TextEncoder,o=[],n=[];let s=0;for(const i of e){const r=t.encode(i.name),c=t.encode(i.content),f=I(c),m=new DataView(new ArrayBuffer(30));m.setUint32(0,67324752,!0),m.setUint16(4,20,!0),m.setUint16(6,2048,!0),m.setUint16(8,0,!0),m.setUint16(10,0,!0),m.setUint16(12,33,!0),m.setUint32(14,f,!0),m.setUint32(18,c.length,!0),m.setUint32(22,c.length,!0),m.setUint16(26,r.length,!0),m.setUint16(28,0,!0),o.push(new Uint8Array(m.buffer),r,c);const h=new DataView(new ArrayBuffer(46));h.setUint32(0,33639248,!0),h.setUint16(4,20,!0),h.setUint16(6,20,!0),h.setUint16(8,2048,!0),h.setUint16(10,0,!0),h.setUint16(12,0,!0),h.setUint16(14,33,!0),h.setUint32(16,f,!0),h.setUint32(20,c.length,!0),h.setUint32(24,c.length,!0),h.setUint16(28,r.length,!0),h.setUint32(42,s,!0),n.push(new Uint8Array(h.buffer),r),s+=30+r.length+c.length}const p=n.reduce((i,r)=>i+r.length,0),a=new DataView(new ArrayBuffer(22));a.setUint32(0,101010256,!0),a.setUint16(8,e.length,!0),a.setUint16(10,e.length,!0),a.setUint32(12,p,!0),a.setUint32(16,s,!0);const u=new Uint8Array(a.buffer),d=new Uint8Array(s+p+u.length);let l=0;for(const i of[...o,...n,u])d.set(i,l),l+=i.length;return d.buffer}function M(e,t){const o=L([...F,{name:"xl/worksheets/sheet1.xml",content:C(e)}]);w(new Blob([o],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}),`${t}.xlsx`)}function B(){if(typeof document>"u")return;const e=window;if(e.__nonce__)return e.__nonce__;if(e.__webpack_nonce__)return e.__webpack_nonce__;const t=document.querySelector('meta[name="csp-nonce"], meta[property="csp-nonce"]');if(t!=null&&t.content)return t.content;const o=document.querySelectorAll("style[nonce], link[nonce], script[nonce]");for(const n of o){const s=n.nonce??n.getAttribute("nonce");if(s)return s}}function H(e,t,o){const n=(l,i)=>`<tr>${l.map(r=>`<${i}${typeof r=="number"?' class="num" align="right"':""}>${g(String(r))}</${i}>`).join("")}</tr>`,s=[...e.groupHeader?[n(e.groupHeader,"th")]:[],n(e.header,"th")].join(""),p=(l,i)=>{const r=T(l);if(r.length===0)return"";const c=l.header&&l.rows.length>0?`<thead>${n(l.header,"th")}</thead>`:"";return`<tr class="detail"><td colspan="${i}"><div class="section"><p class="section-title"><b>${g(l.title)}</b></p><table class="nested" cellpadding="4" cellspacing="0">${c}<tbody>${r.map(f=>n(f,"td")).join("")}</tbody></table></div></td></tr>`},a=e.header.length,u=e.rows.map((l,i)=>{var r;return n(l,"td")+(((r=e.rowDetails)==null?void 0:r[i])??[]).map(c=>p(c,a)).join("")}).join(""),d=o?` nonce="${g(o)}"`:"";return`<!doctype html><html><head><meta charset="utf-8"><title>${g(t)}</title><style${d}>
4
4
  body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; margin: 16px; }
@@ -467,11 +467,11 @@ export interface DataTableProps<TData extends DataTableData> {
467
467
  /**
468
468
  * Adds an Export button to the toolbar (requires `showToolbar`) with
469
469
  * Print, Download as CSV and Download as Excel actions. Exports always
470
- * reflect the displayed table: the filtered + sorted rows across every
470
+ * reflect the displayed table: the filtered + sorted rows on the current
471
471
  * page and the visible accessor columns in display order (display-only
472
472
  * columns are skipped). With grouped columns the export starts with a
473
- * group header row, like the rendered header. With `manualPagination`
474
- * only the loaded page is exported, unless `fetchExportPage` is given.
473
+ * group header row, like the rendered header. `fetchExportPage` adds
474
+ * "Export all rows" to export every page.
475
475
  */
476
476
  enableExport?: boolean;
477
477
  /**
@@ -22,10 +22,9 @@ interface DataTableExportMenuProps<TData extends DataTableData> {
22
22
  /**
23
23
  * Toolbar Export button opening a menu with Print / Download as CSV / Download as Excel, like
24
24
  * the MUI DataGrid toolbar, plus Download as JSON where the table asks for it. Every action
25
- * exports the displayed table: the filtered + sorted rows across every page. Print and the sheet
26
- * formats write the visible accessor columns in display order; JSON writes the rows themselves.
27
- * With `fetchExportPage`, the "Export all rows" checkbox exports every page instead of the loaded
28
- * one.
25
+ * exports the displayed table: the filtered + sorted rows on the current page. Print and the
26
+ * sheet formats write the visible accessor columns in display order; JSON writes the rows
27
+ * themselves. With `fetchExportPage`, the "Export all rows" checkbox exports every page instead.
29
28
  */
30
29
  export declare function DataTableExportMenu<TData extends DataTableData>({ table, filename, icons, additionalExportColumns, exportRowDetails, exportRecord, enableJsonExport, cspNonce, fetchExportPage, exportPageSize, }: Readonly<DataTableExportMenuProps<TData>>): import("react").JSX.Element;
31
30
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verifiedinc-public/shared-ui-elements",
3
- "version": "12.22.0",
3
+ "version": "12.22.1",
4
4
  "description": "A set of UI components, utilities that is shareable with the core apps.",
5
5
  "private": false,
6
6
  "sideEffects": false,