@svgrid/enterprise 3.1.8 → 3.1.9
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/README.md +1 -0
- package/dist/SvAlertRuleEditor.svelte +16 -5
- package/dist/SvGridAlerts.svelte +8 -0
- package/dist/SvGridAlerts.svelte.d.ts +4 -0
- package/dist/SvGridBoard.svelte +69 -10
- package/dist/SvGridBulkEditDrawer.svelte +13 -5
- package/dist/SvGridGallery.svelte +286 -0
- package/dist/SvGridGallery.svelte.d.ts +30 -0
- package/dist/SvGridScheduler.svelte +33 -11
- package/dist/SvGridSelectionBar.svelte +47 -0
- package/dist/advanced-filter/expr-columns-from-grid.d.ts +1 -0
- package/dist/advanced-filter/expr-columns-from-grid.js +11 -7
- package/dist/advanced-filter-enable.d.ts +6 -0
- package/dist/advanced-filter-enable.js +8 -0
- package/dist/alerts/alert-engine.d.ts +7 -0
- package/dist/alerts/alert-engine.js +5 -2
- package/dist/alerts/condition-editor.d.ts +26 -0
- package/dist/alerts/condition-editor.js +17 -0
- package/dist/base/index.d.ts +20 -0
- package/dist/base/index.js +20 -0
- package/dist/bulk-edit.d.ts +11 -0
- package/dist/bulk-edit.js +18 -1
- package/dist/cdn/svgrid-enterprise.svelte-external.js +11197 -10639
- package/dist/designer/assets/GridFooter-Cu8_yBlQ.js +2 -0
- package/dist/designer/assets/GridMenus-BUjkkAU2.js +6 -0
- package/dist/designer/assets/PinSplitter-BgTpgh1d.css +1 -0
- package/dist/designer/assets/PinSplitter-C5AwA1xV.js +1 -0
- package/dist/designer/assets/SvGrid.helpers-CIrmIo9U.js +1 -0
- package/dist/designer/assets/SvGridCellEditor-CJxThKL_.js +4 -0
- package/dist/designer/assets/SvListBox-CS7oUAiX.js +2 -0
- package/dist/designer/assets/conditional-formatting-MDWbF8_Y.js +1 -0
- package/dist/designer/assets/grid-extension.svelte-BZ7AqyJI.js +1 -0
- package/dist/designer/assets/{index-Obk8sI77.js → index-BPU2KNc5.js} +307 -307
- package/dist/designer/assets/index-BmvG99kR.css +1 -0
- package/dist/designer/assets/sparkline-C-NcnB2i.js +1 -0
- package/dist/designer/assets/src-C_U1NKOY.js +58 -0
- package/dist/designer/assets/sv-grid-scrollbar-B9N6Wuj0.js +109 -0
- package/dist/designer/assets/validate-H5u2HEQh.js +1 -0
- package/dist/designer/index.html +11 -7
- package/dist/expressions/compile.js +10 -0
- package/dist/expressions/evaluate.js +18 -0
- package/dist/expressions/expression-types.d.ts +10 -0
- package/dist/expressions/kinds.d.ts +28 -0
- package/dist/expressions/kinds.js +19 -0
- package/dist/expressions/parse.js +9 -1
- package/dist/fields/AttachmentCell.svelte +242 -0
- package/dist/fields/AttachmentCell.svelte.d.ts +5 -0
- package/dist/fields/AttachmentDialog.svelte +357 -0
- package/dist/fields/AttachmentDialog.svelte.d.ts +13 -0
- package/dist/fields/AttachmentEditor.svelte +41 -0
- package/dist/fields/AttachmentEditor.svelte.d.ts +11 -0
- package/dist/fields/AttachmentPreview.svelte +72 -0
- package/dist/fields/AttachmentPreview.svelte.d.ts +8 -0
- package/dist/fields/BarcodeCell.svelte +20 -0
- package/dist/fields/BarcodeCell.svelte.d.ts +5 -0
- package/dist/fields/BaseAutomations.svelte +558 -0
- package/dist/fields/BaseAutomations.svelte.d.ts +18 -0
- package/dist/fields/BaseChartView.svelte +47 -0
- package/dist/fields/BaseChartView.svelte.d.ts +8 -0
- package/dist/fields/BaseTableView.svelte +185 -0
- package/dist/fields/BaseTableView.svelte.d.ts +37 -0
- package/dist/fields/BaseTabs.svelte +308 -0
- package/dist/fields/BaseTabs.svelte.d.ts +21 -0
- package/dist/fields/ButtonCell.svelte +47 -0
- package/dist/fields/ButtonCell.svelte.d.ts +20 -0
- package/dist/fields/CheckboxCell.svelte +46 -0
- package/dist/fields/CheckboxCell.svelte.d.ts +14 -0
- package/dist/fields/DeleteFieldConfirm.svelte +80 -0
- package/dist/fields/DeleteFieldConfirm.svelte.d.ts +8 -0
- package/dist/fields/DeleteRecordConfirm.svelte +48 -0
- package/dist/fields/DeleteRecordConfirm.svelte.d.ts +9 -0
- package/dist/fields/FieldCell.svelte +80 -0
- package/dist/fields/FieldCell.svelte.d.ts +9 -0
- package/dist/fields/FieldEditor.svelte +321 -0
- package/dist/fields/FieldEditor.svelte.d.ts +10 -0
- package/dist/fields/FieldInput.svelte +188 -0
- package/dist/fields/FieldInput.svelte.d.ts +29 -0
- package/dist/fields/FieldsHeaderEnd.svelte +146 -0
- package/dist/fields/FieldsHeaderEnd.svelte.d.ts +6 -0
- package/dist/fields/FootRowAdder.svelte +8 -0
- package/dist/fields/FootRowAdder.svelte.d.ts +6 -0
- package/dist/fields/GroupHeader.svelte +127 -0
- package/dist/fields/GroupHeader.svelte.d.ts +24 -0
- package/dist/fields/LinkCell.svelte +46 -0
- package/dist/fields/LinkCell.svelte.d.ts +9 -0
- package/dist/fields/LinkPickerEditor.svelte +172 -0
- package/dist/fields/LinkPickerEditor.svelte.d.ts +9 -0
- package/dist/fields/LinkPreview.svelte +60 -0
- package/dist/fields/LinkPreview.svelte.d.ts +7 -0
- package/dist/fields/LinkedRecordView.svelte +94 -0
- package/dist/fields/LinkedRecordView.svelte.d.ts +9 -0
- package/dist/fields/LinkedRecordsCell.svelte +59 -0
- package/dist/fields/LinkedRecordsCell.svelte.d.ts +11 -0
- package/dist/fields/LongTextEditor.svelte +157 -0
- package/dist/fields/LongTextEditor.svelte.d.ts +11 -0
- package/dist/fields/NumberEditor.svelte +309 -0
- package/dist/fields/NumberEditor.svelte.d.ts +12 -0
- package/dist/fields/OptionsEditor.svelte +117 -0
- package/dist/fields/OptionsEditor.svelte.d.ts +11 -0
- package/dist/fields/PercentCell.svelte +21 -0
- package/dist/fields/PercentCell.svelte.d.ts +8 -0
- package/dist/fields/PropertyInput.svelte +204 -0
- package/dist/fields/PropertyInput.svelte.d.ts +11 -0
- package/dist/fields/RatingCell.svelte +75 -0
- package/dist/fields/RatingCell.svelte.d.ts +16 -0
- package/dist/fields/RatingEditor.svelte +82 -0
- package/dist/fields/RatingEditor.svelte.d.ts +9 -0
- package/dist/fields/RecordView.svelte +310 -0
- package/dist/fields/RecordView.svelte.d.ts +11 -0
- package/dist/fields/RichTextCell.svelte +30 -0
- package/dist/fields/RichTextCell.svelte.d.ts +5 -0
- package/dist/fields/RowAdder.svelte +93 -0
- package/dist/fields/RowAdder.svelte.d.ts +7 -0
- package/dist/fields/RowHeader.svelte +99 -0
- package/dist/fields/RowHeader.svelte.d.ts +11 -0
- package/dist/fields/SelectCell.svelte +35 -0
- package/dist/fields/SelectCell.svelte.d.ts +15 -0
- package/dist/fields/SelectEditor.svelte +350 -0
- package/dist/fields/SelectEditor.svelte.d.ts +17 -0
- package/dist/fields/SummaryCell.svelte +160 -0
- package/dist/fields/SummaryCell.svelte.d.ts +11 -0
- package/dist/fields/SvBase.svelte +545 -0
- package/dist/fields/SvBase.svelte.d.ts +30 -0
- package/dist/fields/SvBaseForm.svelte +295 -0
- package/dist/fields/SvBaseForm.svelte.d.ts +22 -0
- package/dist/fields/SvBaseViewBar.svelte +644 -0
- package/dist/fields/SvBaseViewBar.svelte.d.ts +26 -0
- package/dist/fields/UserCell.svelte +39 -0
- package/dist/fields/UserCell.svelte.d.ts +9 -0
- package/dist/fields/UserFace.svelte +30 -0
- package/dist/fields/UserFace.svelte.d.ts +12 -0
- package/dist/fields/activity.svelte.d.ts +50 -0
- package/dist/fields/activity.svelte.js +110 -0
- package/dist/fields/attachments.d.ts +95 -0
- package/dist/fields/attachments.js +145 -0
- package/dist/fields/automation-outbound.d.ts +46 -0
- package/dist/fields/automation-outbound.js +61 -0
- package/dist/fields/automation-server.d.ts +53 -0
- package/dist/fields/automation-server.js +333 -0
- package/dist/fields/automations.svelte.d.ts +208 -0
- package/dist/fields/automations.svelte.js +437 -0
- package/dist/fields/bar-request.svelte.d.ts +16 -0
- package/dist/fields/bar-request.svelte.js +15 -0
- package/dist/fields/base-alerts.d.ts +24 -0
- package/dist/fields/base-alerts.js +64 -0
- package/dist/fields/base-connect.d.ts +82 -0
- package/dist/fields/base-connect.js +271 -0
- package/dist/fields/base-schema.d.ts +104 -0
- package/dist/fields/base-schema.js +266 -0
- package/dist/fields/base-sql.d.ts +62 -0
- package/dist/fields/base-sql.js +251 -0
- package/dist/fields/base-sync.d.ts +142 -0
- package/dist/fields/base-sync.js +499 -0
- package/dist/fields/base-tables.d.ts +89 -0
- package/dist/fields/base-tables.js +349 -0
- package/dist/fields/builtin-types.d.ts +13 -0
- package/dist/fields/builtin-types.js +773 -0
- package/dist/fields/button.d.ts +2 -0
- package/dist/fields/button.js +17 -0
- package/dist/fields/chart-view.d.ts +35 -0
- package/dist/fields/chart-view.js +154 -0
- package/dist/fields/column-order.d.ts +6 -0
- package/dist/fields/column-order.js +12 -0
- package/dist/fields/convert.d.ts +16 -0
- package/dist/fields/convert.js +176 -0
- package/dist/fields/copy-text.d.ts +13 -0
- package/dist/fields/copy-text.js +45 -0
- package/dist/fields/editor-request.svelte.d.ts +71 -0
- package/dist/fields/editor-request.svelte.js +52 -0
- package/dist/fields/field-ops.d.ts +72 -0
- package/dist/fields/field-ops.js +334 -0
- package/dist/fields/filter-model.d.ts +84 -0
- package/dist/fields/filter-model.js +446 -0
- package/dist/fields/format.d.ts +109 -0
- package/dist/fields/format.js +288 -0
- package/dist/fields/formula.d.ts +50 -0
- package/dist/fields/formula.js +530 -0
- package/dist/fields/grid-access.d.ts +60 -0
- package/dist/fields/grid-access.js +120 -0
- package/dist/fields/index.d.ts +34 -0
- package/dist/fields/index.js +312 -0
- package/dist/fields/linked-fields.d.ts +8 -0
- package/dist/fields/linked-fields.js +40 -0
- package/dist/fields/links.d.ts +10 -0
- package/dist/fields/links.js +46 -0
- package/dist/fields/name-list.d.ts +16 -0
- package/dist/fields/name-list.js +49 -0
- package/dist/fields/palette.d.ts +47 -0
- package/dist/fields/palette.js +69 -0
- package/dist/fields/record-delete.svelte.d.ts +12 -0
- package/dist/fields/record-delete.svelte.js +5 -0
- package/dist/fields/record-menu.d.ts +9 -0
- package/dist/fields/record-menu.js +78 -0
- package/dist/fields/registry.svelte.d.ts +176 -0
- package/dist/fields/registry.svelte.js +51 -0
- package/dist/fields/rich-text.d.ts +23 -0
- package/dist/fields/rich-text.js +48 -0
- package/dist/fields/row-color-choice.svelte.d.ts +31 -0
- package/dist/fields/row-color-choice.svelte.js +25 -0
- package/dist/fields/row-colors.d.ts +36 -0
- package/dist/fields/row-colors.js +90 -0
- package/dist/fields/row-height.d.ts +28 -0
- package/dist/fields/row-height.js +50 -0
- package/dist/fields/sources.svelte.d.ts +80 -0
- package/dist/fields/sources.svelte.js +131 -0
- package/dist/fields/summaries.d.ts +18 -0
- package/dist/fields/summaries.js +138 -0
- package/dist/fields/view-model.d.ts +129 -0
- package/dist/fields/view-model.js +492 -0
- package/dist/fields/viewbar/ChartPanel.svelte +61 -0
- package/dist/fields/viewbar/ChartPanel.svelte.d.ts +9 -0
- package/dist/fields/viewbar/ColorPanel.svelte +112 -0
- package/dist/fields/viewbar/ColorPanel.svelte.d.ts +9 -0
- package/dist/fields/viewbar/ConditionValue.svelte +153 -0
- package/dist/fields/viewbar/ConditionValue.svelte.d.ts +15 -0
- package/dist/fields/viewbar/FieldIcon.svelte +18 -0
- package/dist/fields/viewbar/FieldIcon.svelte.d.ts +9 -0
- package/dist/fields/viewbar/FilterPanel.svelte +192 -0
- package/dist/fields/viewbar/FilterPanel.svelte.d.ts +13 -0
- package/dist/fields/viewbar/GanttPanel.svelte +60 -0
- package/dist/fields/viewbar/GanttPanel.svelte.d.ts +10 -0
- package/dist/fields/viewbar/HideFieldsPanel.svelte +104 -0
- package/dist/fields/viewbar/HideFieldsPanel.svelte.d.ts +7 -0
- package/dist/fields/viewbar/SortPanel.svelte +85 -0
- package/dist/fields/viewbar/SortPanel.svelte.d.ts +8 -0
- package/dist/fields/viewbar/ViewsMenu.svelte +250 -0
- package/dist/fields/viewbar/ViewsMenu.svelte.d.ts +15 -0
- package/dist/fields/viewbar/panel-focus.d.ts +3 -0
- package/dist/fields/viewbar/panel-focus.js +22 -0
- package/dist/fields/viewbar/sort-state.d.ts +20 -0
- package/dist/fields/viewbar/sort-state.js +24 -0
- package/dist/gallery.d.ts +7 -0
- package/dist/gallery.js +36 -0
- package/dist/gantt/SvGridGantt.svelte +88 -16
- package/dist/gantt/gantt-config.d.ts +28 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +6 -0
- package/dist/install.js +3 -0
- package/dist/license-core.d.ts +3 -3
- package/dist/license.js +1 -0
- package/dist/node/studio.js +105 -4
- package/dist/scheduler-config.d.ts +11 -0
- package/dist/sources/introspect-supabase.js +4 -1
- package/dist/sources/rest.js +6 -2
- package/dist/studio/ui-components.generated.js +93 -1
- package/dist/upgrade-prompt.d.ts +1 -1
- package/dist/version.d.ts +2 -2
- package/dist/version.js +2 -2
- package/dist/wc/GridFooter-f5K0aLe_.js +145 -0
- package/dist/wc/GridMenus-FtSN_8t9.js +1369 -0
- package/dist/wc/PinSplitter-D-qtDhSM.js +132 -0
- package/dist/wc/{SvGrid.helpers-zBkDTryR.js → SvGrid.helpers-B2GEKrxS.js} +84 -36
- package/dist/wc/{SvGridCellEditor-CzUKEbkI.js → SvGridCellEditor-B_cLJrsp.js} +20 -9
- package/dist/wc/conditional-formatting-BXis_oP1.js +189 -0
- package/dist/wc/grid-extension.svelte-Bufq4B4C.js +20 -0
- package/dist/wc/sv-sheet-element.js +7556 -7617
- package/dist/wc/svelte-virtualizer.svelte-ehwOupl-.js +360 -0
- package/dist/wc/{validate-43C03DLP.js → validate-BaMO8UPE.js} +1 -1
- package/package.json +14 -3
- package/dist/designer/assets/GridMenus-CvcASlKv.js +0 -8
- package/dist/designer/assets/SvGrid.helpers-DE5mmORW.js +0 -1
- package/dist/designer/assets/SvGridCellEditor-C7NWcnNC.js +0 -4
- package/dist/designer/assets/SvListBox-BlmmzYcU.js +0 -110
- package/dist/designer/assets/index-KmSEY7Lb.css +0 -1
- package/dist/designer/assets/src-DqHCqori.js +0 -58
- package/dist/designer/assets/validate-B71dE1Cs.js +0 -1
- package/dist/wc/GridMenus-fWbBUiRH.js +0 -1088
- package/dist/wc/svelte-virtualizer.svelte-Dntdh8Ms.js +0 -581
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";var t=e({buildSparkline:()=>i,toSparklineValues:()=>r}),n={width:88,height:22,color:`var(--sg-accent, #2563eb)`,negativeColor:`#ef4444`,lineWidth:1.5};function r(e){return Array.isArray(e)?e.map(e=>Number(e)).filter(e=>Number.isFinite(e)):typeof e==`string`&&e.trim()?e.split(/[,\s]+/).map(e=>Number(e)).filter(e=>Number.isFinite(e)):[]}function i(e,t={}){if(!e.length)return null;let r=t.width??n.width,i=t.height??n.height,o=t.type??`line`,s=t.color??n.color,c=t.negativeColor??n.negativeColor,l=t.lineWidth??n.lineWidth,u=Math.ceil(l)+1,d=Math.max(1,r-u*2),f=Math.max(1,i-u*2),p={width:r,height:i,type:o,color:s,negativeColor:c,lineWidth:l};if(o===`winloss`){let t=e.length,n=t>1?Math.min(2,d/t/3):0,r=d/t,a=Math.max(1,r-n),o=i/2,s=f/2,c=[];return e.forEach((e,t)=>{let n=u+t*r+(r-a)/2;e>0?c.push({x:n,y:o-s,w:a,h:s,negative:!1}):e<0&&c.push({x:n,y:o,w:a,h:s,negative:!0})}),{...p,linePath:``,areaPath:``,bars:c,lastPoint:null}}let m=t.min??Math.min(...e),h=t.max??Math.max(...e),g=h-m||1;if(o===`bar`){let t=e.length,n=t>1?Math.min(2,d/t/3):0,r=d/t,i=Math.max(1,r-n),a=m<0&&h>0?0:m,o=u+f-(a-m)/g*f,s=e.map((e,t)=>{let n=u+t*r+(r-i)/2,s=u+f-(e-m)/g*f,c=Math.min(s,o),l=Math.max(1,Math.abs(s-o));return{x:n,y:c,w:i,h:l,negative:e<a}});return{...p,linePath:``,areaPath:``,bars:s,lastPoint:null}}let _=e.length,v=_>1?d/(_-1):0,y=e.map((e,t)=>({x:_===1?u+d/2:u+t*v,y:u+f-(e-m)/g*f})),b=_===1?`M${a(y[0].x-1)},${a(y[0].y)} L${a(y[0].x+1)},${a(y[0].y)}`:y.map((e,t)=>`${t===0?`M`:`L`}${a(e.x)},${a(e.y)}`).join(` `),x=y[0],S=y[y.length-1],C=u+f,w=o===`area`?`${b} L${a(S.x)},${a(C)} L${a(x.x)},${a(C)} Z`:``;return{...p,linePath:b,areaPath:w,bars:[],lastPoint:t.lastPoint===!1?null:{x:S.x,y:S.y}}}function a(e){return Math.round(e*100)/100}export{t as n,i as t};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./jszip.min-CX2fPs3O.js","./rolldown-runtime-Dd_uD5pT.js","./pdfmake-BpIYFHoG.js","./vfs_fonts-BV-Ul9v2.js","./src-CITpcm6b.js","./chart-export-B6bkQ3X8.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{i as e,n as t}from"./rolldown-runtime-Dd_uD5pT.js";import{i as n,r,t as i}from"./conditional-formatting-MDWbF8_Y.js";import{a,c as o,d as s,i as c,l,n as u,o as d,s as f,t as p,u as m}from"./export-format-DGscOjS9.js";import{t as h}from"./preload-helper-HclGiUj8.js";var g=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),_=(e,t)=>e>>>t|e<<32-t;function v(e){let t=new TextEncoder().encode(e),n=t.length*8,r=Math.ceil((t.length+9)/64)*64,i=new Uint8Array(r);i.set(t),i[t.length]=128;let a=new DataView(i.buffer);a.setUint32(r-8,Math.floor(n/4294967296)),a.setUint32(r-4,n>>>0);let o=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),s=new Uint32Array(64);for(let e=0;e<r;e+=64){for(let t=0;t<16;t++)s[t]=a.getUint32(e+t*4);for(let e=16;e<64;e++){let t=_(s[e-15],7)^_(s[e-15],18)^s[e-15]>>>3,n=_(s[e-2],17)^_(s[e-2],19)^s[e-2]>>>10;s[e]=s[e-16]+t+s[e-7]+n>>>0}let t=o[0],n=o[1],r=o[2],i=o[3],c=o[4],l=o[5],u=o[6],d=o[7];for(let e=0;e<64;e++){let a=_(c,6)^_(c,11)^_(c,25),o=c&l^~c&u,f=d+a+o+g[e]+s[e]>>>0,p=(_(t,2)^_(t,13)^_(t,22))+(t&n^t&r^n&r)>>>0;d=u,u=l,l=c,c=i+f>>>0,i=r,r=n,n=t,t=f+p>>>0}o[0]=o[0]+t>>>0,o[1]=o[1]+n>>>0,o[2]=o[2]+r>>>0,o[3]=o[3]+i>>>0,o[4]=o[4]+c>>>0,o[5]=o[5]+l>>>0,o[6]=o[6]+u>>>0,o[7]=o[7]+d>>>0}let c=``;for(let e of o)c+=e.toString(16).padStart(8,`0`);return c}function y(e,t){return e===`suite`||t===`grid`}function b(e,t=new Date){return e==null||e.trim()===``?{status:`unset`,valid:!1,edition:`suite`}:v(e.trim().toLowerCase())===`dabe98638cdc5760637bb2a741e65680a6ff0fb590d8b1018c9597650486cb10`?{status:`licensed`,valid:!0,edition:`suite`}:{status:`invalid`,valid:!1,edition:`suite`}}var x=new Set([`svgrid.com`,`www.svgrid.com`]);function S(){let e=globalThis.location?.hostname;return typeof e==`string`&&x.has(e.toLowerCase())}var C=`data-svgrid-enterprise-watermark`,w=`data-svgrid-enterprise-nudged`,ee=`https://svgrid.com/pricing/?utm_source=svgrid-enterprise&utm_medium=watermark`,te=`www.svgrid.com`,ne=5e3,T=700,E=!1,D=null;function O(){S()||(ie(),!(typeof document>`u`||typeof window>`u`)&&(queueMicrotask(()=>j()),D||(D=new MutationObserver(A),D.observe(document.body,{childList:!0,subtree:!0}))))}var k=!1;function A(e){for(let t of e){let e=t.target;if(!(e.nodeType===1&&e.closest?.(`.sv-grid-root[${w}]`))){re();return}}}function re(){if(k)return;k=!0;let e=()=>{k=!1,j()};typeof requestAnimationFrame==`function`?requestAnimationFrame(e):setTimeout(e,16)}function ie(){E||(E=!0,!(typeof console>`u`)&&console.log(`%c @svgrid/enterprise %c User is using a Commercial version which requires a license.
|
|
3
|
+
Contact sales@jqwidgets.com for details or visit the license page: https://svgrid.com/pricing/?utm_source=svgrid-enterprise&utm_medium=console`,`background:#4f46e5;color:#fff;padding:2px 6px;border-radius:3px;font-weight:600`,`color:inherit`))}function j(){if(typeof document>`u`)return;let e=document.querySelectorAll(`.sv-grid-root, [role="grid"]`);if(e.length===0){ae();return}document.querySelectorAll(`[${C}="fixed"]`).forEach(e=>e.remove());let t=new Set;e.forEach(e=>{let n=M(e);n&&t.add(n)}),t.forEach(N)}function M(e){let t=e.closest(`.sv-grid-root`);if(t)return t;let n=e;for(;n&&/^(TABLE|THEAD|TBODY|TFOOT|TR|COLGROUP)$/.test(n.tagName);)n=n.parentElement;return n}function N(e){if(e.hasAttribute(w))return;e.setAttribute(w,`1`),getComputedStyle(e).position===`static`&&(e.style.position=`relative`);let t=oe(`grid`);ce(t,!1),e.appendChild(t),se(t)}function ae(){if(typeof document>`u`||document.querySelector(`[${C}="fixed"]`))return;let e=oe(`fixed`);ce(e,!0),document.body.appendChild(e),se(e)}function oe(e){let t=document.createElement(`a`);return t.setAttribute(C,e),t.href=ee,t.target=`_blank`,t.rel=`noopener noreferrer`,t.textContent=te,t.title=`Unlicensed @svgrid/enterprise. Contact sales@jqwidgets.com or visit www.svgrid.com.`,t}function se(e){if(typeof window>`u`){e.remove();return}window.setTimeout(()=>{if(typeof window>`u`){e.remove();return}e.style.opacity=`0`,window.setTimeout(()=>e.remove(),T)},ne)}function ce(e,t){Object.assign(e.style,{position:t?`fixed`:`absolute`,bottom:t?`12px`:`6px`,right:t?`12px`:`8px`,zIndex:`2147483647`,background:`rgba(15,23,42,0.85)`,color:`#fff`,padding:t?`6px 10px`:`4px 8px`,borderRadius:t?`4px`:`3px`,fontFamily:`-apple-system, "Segoe UI", Roboto, sans-serif`,fontSize:t?`11px`:`10px`,lineHeight:`1.2`,textDecoration:`none`,boxShadow:t?`0 2px 12px rgba(0,0,0,0.35)`:`0 1px 4px rgba(0,0,0,0.3)`,border:`1px solid rgba(255,255,255,0.18)`,pointerEvents:`auto`,letterSpacing:`0.02em`,opacity:`1`,transition:`opacity ${T}ms ease`})}var le=`data-svgrid-enterprise-upgrade`,ue=`https://svgrid.com/pricing?ref=in-app&utm_source=svgrid-enterprise&utm_medium=upgrade-prompt`,de=`https://svgrid.com/docs/enterprise/evaluation/?utm_source=svgrid-enterprise&utm_medium=upgrade-prompt`,fe=!1;function P(e,t){if(fe||typeof document>`u`||typeof window>`u`||S()||document.querySelector(`[${le}]`))return;fe=!0;let n=pe(e,t?.expired===!0);document.body.appendChild(n),requestAnimationFrame(()=>{n.style.opacity=`1`,n.style.transform=`translateY(0)`})}function F(e){e.style.opacity=`0`,e.style.transform=`translateY(8px)`,window.setTimeout(()=>e.remove(),220)}function pe(e,t=!1){let n=document.createElement(`div`);n.setAttribute(le,`1`),n.setAttribute(`role`,`dialog`),n.setAttribute(`aria-label`,t?`Your evaluation has ended`:`SvGrid Enterprise`),Object.assign(n.style,{position:`fixed`,bottom:`16px`,right:`16px`,zIndex:`2147483646`,width:`320px`,maxWidth:`calc(100vw - 32px)`,boxSizing:`border-box`,padding:`16px 16px 14px`,background:`#0f172a`,color:`#e2e8f0`,borderRadius:`12px`,border:`1px solid rgba(99,102,241,0.4)`,boxShadow:`0 12px 40px rgba(0,0,0,0.45)`,fontFamily:`-apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif`,fontSize:`13px`,lineHeight:`1.45`,opacity:`0`,transform:`translateY(8px)`,transition:`opacity 220ms ease, transform 220ms ease`});let r=e?`<strong style="color:#fff">${me(e?String(e):`This`)}</strong> is part of SvGrid Enterprise.`:`You just used a <strong style="color:#fff">SvGrid Enterprise</strong> feature.`,i=t?`EVALUATION ENDED`:`ENTERPRISE`,a=t?`Your evaluation has ended`:`SvGrid Enterprise`,o=t?`${r} Everything still works, but this notice stays until a
|
|
4
|
+
license key is set.`:`${r} It keeps working as it is, here and in production. A
|
|
5
|
+
license key removes the watermark and this notice.`;return n.innerHTML=`
|
|
6
|
+
<button type="button" data-act="x" aria-label="Dismiss"
|
|
7
|
+
style="position:absolute;top:8px;right:8px;width:24px;height:24px;display:flex;
|
|
8
|
+
align-items:center;justify-content:center;background:transparent;border:0;
|
|
9
|
+
color:#94a3b8;font-size:18px;line-height:1;cursor:pointer;border-radius:6px;">×</button>
|
|
10
|
+
<div style="display:flex;align-items:center;gap:8px;margin-bottom:8px;">
|
|
11
|
+
<span style="display:inline-block;background:${t?`#b45309`:`#4f46e5`};color:#fff;font-size:10px;
|
|
12
|
+
font-weight:700;letter-spacing:0.06em;padding:2px 7px;border-radius:999px;">${i}</span>
|
|
13
|
+
<span style="font-weight:700;color:#fff;">${a}</span>
|
|
14
|
+
</div>
|
|
15
|
+
<p style="margin:0 0 12px;color:#cbd5e1;">
|
|
16
|
+
${o}
|
|
17
|
+
</p>
|
|
18
|
+
<div style="display:flex;gap:8px;align-items:center;">
|
|
19
|
+
<a data-act="plans" href="${ue}" target="_blank" rel="noopener noreferrer"
|
|
20
|
+
style="flex:1;text-align:center;background:#6366f1;color:#fff;font-weight:600;
|
|
21
|
+
text-decoration:none;padding:8px 12px;border-radius:8px;">${t?`Buy a license`:`See plans`}</a>
|
|
22
|
+
<a data-act="evaluation" href="${de}" target="_blank" rel="noopener noreferrer"
|
|
23
|
+
style="color:#a5b4fc;text-decoration:none;padding:8px 6px;font-weight:600;">How evaluation works</a>
|
|
24
|
+
</div>
|
|
25
|
+
<p style="margin:10px 0 0;font-size:11px;color:#64748b;">
|
|
26
|
+
Already licensed? Call <code style="color:#94a3b8;">setLicenseKey()</code> at startup to hide this.
|
|
27
|
+
</p>
|
|
28
|
+
`,n.querySelector(`[data-act="x"]`)?.addEventListener(`click`,()=>F(n)),n.querySelector(`[data-act="plans"]`)?.addEventListener(`click`,()=>F(n)),n.querySelector(`[data-act="evaluation"]`)?.addEventListener(`click`,()=>F(n)),n}function me(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}var I=null,he=!1,ge=!1,_e=new Set;function L(e){if(ge)return;ge=!0;let t=e.expiresAt?` on ${e.expiresAt.toISOString().slice(0,10)}`:``;console.info(`@svgrid/enterprise: your evaluation license expired${t}. Everything still works, but the watermark and upgrade notice stay until a license key is set. Contact sales@jqwidgets.com or see https://svgrid.com/pricing/?utm_source=svgrid-enterprise&utm_medium=console`)}function ve(e){return e.status===`dev`||e.status===`eval`}var ye=!1;function R(e){ye||e.status!==`invalid`&&e.status!==`revoked`||S()||(ye=!0,console.warn(`@svgrid/enterprise: the license key passed to setLicenseKey() is not valid, so the watermark stays. Copy the key from your order email, or contact sales@jqwidgets.com.`))}function be(){return b(I).valid}function xe(e){let t=b(I),n=ve(t)&&t.expired===!0;t.valid&&!n||(R(t),O(),n&&L(t),P(e,{expired:n}))}var Se={grid:`the enterprise grid`,spreadsheet:`the spreadsheet`,base:`SvGrid Base`,studio:`the Studio`};function Ce(e){_e.has(e)||(_e.add(e),console.info(`@svgrid/enterprise: your Grid license does not cover ${Se[e]}. Everything still works, but the watermark and upgrade notice stay until the license is upgraded to Suite. Contact sales@jqwidgets.com or see https://svgrid.com/pricing/?utm_source=svgrid-enterprise&utm_medium=console`))}function we(e,t){let n=b(I),r=n.valid&&y(n.edition,e),i=ve(n)&&n.expired===!0;if(r&&!i)return;R(n);let a=n.valid&&!i&&!r;O(),a?Ce(e):i&&L(n),P(t,{expired:i})}function Te(e){let t=b(I);switch(t.status){case`unset`:O(),P(e);return;case`invalid`:case`revoked`:R(t),O(),P(e);return;case`dev`:case`eval`:if(t.expired){O(),L(t),P(e,{expired:!0});return}he||=(console.info(`@svgrid/enterprise: using a development / evaluation license. Not for production use.`),!0);return;case`licensed`:return}}var Ee=!1;function De(){if(Ee)return;if(typeof window>`u`)throw Error(`@svgrid/enterprise: installSmartShim() requires a browser environment`);let e=window.Smart??{Utilities:{}};e.Utilities=e.Utilities??{},typeof e.Utilities.Assign!=`function`&&(e.Utilities.Assign=(t,n)=>{e.Utilities[t]=n}),(!e.Utilities.Core||typeof e.Utilities.Core.toDash!=`function`)&&(e.Utilities.Core={toDash:e=>e.replace(/[A-Z]/g,e=>`-`+e.toLowerCase())}),window.Smart=e,Ee=!0}var Oe=/[\x00-\x08\x0B\x0C\x0E-\x1F]/g;function z(e){return e.replace(Oe,``).replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}function ke(e){let t=(e,t=2)=>String(e).padStart(t,`0`);return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}T${t(e.getHours())}:${t(e.getMinutes())}:${t(e.getSeconds())}.000`}async function Ae(e,t,n,r={}){let i=Math.max(1,r.chunkRows??5e3),a=n.length,o=r.rawValues===!0,l=r.cellVisual,u=r.precisionSafe===!0,d=new Map,f=[`<Style ss:ID="sHeader"><Font ss:Bold="1"/><Interior ss:Color="#F2F2F2" ss:Pattern="Solid"/></Style>`],p=e=>e===`right`?`Right`:e===`center`?`Center`:`Left`,h=e=>{let t=e.align&&e.align!==`left`;if(!e.numFmt&&!e.fill&&!e.color&&!e.bold&&!t)return;let n=`${e.numFmt??``}|${e.fill??``}|${e.color??``}|${e.bold?`b`:``}|${e.align??``}`,r=d.get(n);if(r)return r;let i=`s${d.size+1}`,a=[];return t&&a.push(`<Alignment ss:Horizontal="${p(e.align)}"/>`),(e.color||e.bold)&&a.push(`<Font${e.color?` ss:Color="${e.color}"`:``}${e.bold?` ss:Bold="1"`:``}/>`),e.fill&&a.push(`<Interior ss:Color="${e.fill}" ss:Pattern="Solid"/>`),e.numFmt&&a.push(`<NumberFormat ss:Format="${z(e.numFmt)}"/>`),f.push(`<Style ss:ID="${i}">${a.join(``)}</Style>`),d.set(n,i),i};function g(e,t,n,r){let i=e.link?.(t)||void 0,a=l?.(n,r),d=t=>h({numFmt:t,fill:a?.fill,color:a?.color,bold:a?.bold,align:e.align});if(e.exportValue){let n=e.exportValue(t),r=n==null?``:String(n);return{type:`String`,value:a?.icon?`${a.icon} ${r}`:r,styleId:d(),href:i}}let f=t[e.field];if(a?.icon){let t=o?String(f??``):c(f,e.format);return{type:`String`,value:`${a.icon} ${t}`,styleId:d(),href:i}}let p=e=>u&&Math.abs(e)>=0x38d7ea4c68000;if(o){let e=f==null?``:String(f);return typeof f==`number`&&Number.isFinite(f)&&!p(f)?{type:`Number`,value:e,styleId:d(),href:i}:{type:`String`,value:e,styleId:d(),href:i}}let g=s(f,e.format);if(g.ok){let t=m(e.format);return g.value instanceof Date?{type:`DateTime`,value:ke(g.value),styleId:d(t),href:i}:p(g.value)?{type:`String`,value:String(g.value),styleId:d(),href:i}:{type:`Number`,value:String(g.value),styleId:d(t),href:i}}return{type:`String`,value:c(f,e.format),styleId:d(),href:i}}let _=e=>`<Cell${e.styleId?` ss:StyleID="${e.styleId}"`:``}${e.href?` ss:HRef="${z(e.href)}"`:``}><Data ss:Type="${e.type}">${z(e.value)}</Data></Cell>`,v=r.widths?r.widths.map(e=>`<Column ss:Width="${Math.round(e*.75)}"/>`).join(``):``,y=Math.max(0,Math.floor(r.freezeColumns??0)),b=r.freezeHeader||y>0?`<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel"><FreezePanes/><FrozenNoSplit/>`+(r.freezeHeader?`<SplitHorizontal>1</SplitHorizontal><TopRowBottomPane>1</TopRowBottomPane>`:``)+(y>0?`<SplitVertical>${y}</SplitVertical><LeftColumnRightPane>${y}</LeftColumnRightPane>`:``)+`<ActivePane>2</ActivePane></WorksheetOptions>`:``,x=[`<Row>${t.map(e=>`<Cell ss:StyleID="sHeader"><Data ss:Type="String">${z(e.header??e.field)}</Data></Cell>`).join(``)}</Row>`];for(let e=0;e<a;e++){if(r.signal?.aborted)throw new DOMException(`Export aborted`,`AbortError`);let o=n[e],s=t.map((t,n)=>_(g(t,o,e,n))).join(``);x.push(`<Row>${s}</Row>`),e>0&&e%i===0&&(r.onProgress?.({phase:`serialize`,ratio:e/a,row:e,total:a}),await new Promise(e=>setTimeout(e,0)))}return r.onProgress?.({phase:`serialize`,ratio:1,row:a,total:a}),`<?xml version="1.0"?>
|
|
29
|
+
<?mso-application progid="Excel.Sheet"?>
|
|
30
|
+
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:html="http://www.w3.org/TR/REC-html40"><Styles>${f.join(``)}</Styles><Worksheet ss:Name="${z(e.slice(0,31)||`Sheet1`)}"><Table>${v}${x.join(``)}</Table>`+b+`</Worksheet></Workbook>`}var je={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`},Me=/[\x00-\x08\x0B\x0C\x0E-\x1F]/g;function B(e){return e.replace(Me,``).replace(/[&<>"']/g,e=>je[e])}function V(e){let t=e,n=``;do n=String.fromCharCode(65+t%26)+n,t=Math.floor(t/26)-1;while(t>=0);return n}function H(e){if(!e)return null;let t=/^#?([0-9a-f]{6})$/i.exec(e.trim());return t?`FF`+t[1].toUpperCase():null}function Ne(e){return(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds())-Date.UTC(1899,11,30))/864e5}function Pe(e){if(e instanceof Date)return e;let t=String(e).trim(),n=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t);return n?new Date(Number(n[1]),Number(n[2])-1,Number(n[3])):new Date(t)}var Fe=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
31
|
+
<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"/><Override PartName="/xl/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"/></Types>`,Ie=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
32
|
+
<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>`;function Le(e){return e.replace(/[\\/?*[\]:]/g,` `).trim().slice(0,31)||`Sheet1`}function Re(e){return`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
33
|
+
<workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"><sheets><sheet name="${B(Le(e))}" sheetId="1" r:id="rId1"/></sheets></workbook>`}var ze=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
34
|
+
<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"/><Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/></Relationships>`;function Be(e,t){let n=new Map,r=164,i=e=>{if(!e)return 0;let t=n.get(e);if(t!=null)return t;let i=r++;return n.set(e,i),i},a=[`<font><sz val="11"/><name val="Calibri"/></font>`,`<font><b/><sz val="11"/><name val="Calibri"/></font>`],o=new Map,s=(e,t)=>{let n=H(t);if(!e&&!n)return 0;let r=`${e?`b`:``}|${n??``}`,i=o.get(r);if(i!=null)return i;let s=a.length;return a.push(`<font>${e?`<b/>`:``}<sz val="11"/><name val="Calibri"/>${n?`<color rgb="${n}"/>`:``}</font>`),o.set(r,s),s},c=[`<fill><patternFill patternType="none"/></fill>`,`<fill><patternFill patternType="gray125"/></fill>`],l=new Map,u=e=>{let t=H(e);if(!t)return 0;let n=l.get(t);if(n!=null)return n;let r=c.length;return c.push(`<fill><patternFill patternType="solid"><fgColor rgb="${t}"/><bgColor indexed="64"/></patternFill></fill>`),l.set(t,r),r},d=[`<xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0"/>`,`<xf numFmtId="0" fontId="1" fillId="0" borderId="0" xfId="0" applyFont="1"/>`],f=new Map,p=(e,t,n,r)=>{let i=`${e}|${t}|${n}|${r??``}`,a=f.get(i);if(a!=null)return a;let o=d.length,s=r&&r!==`left`?`<alignment horizontal="${r}"/>`:``;return d.push(`<xf numFmtId="${e}" fontId="${t}" fillId="${n}" borderId="0" xfId="0"${e?` applyNumberFormat="1"`:``}${t?` applyFont="1"`:``}${n?` applyFill="1"`:``}${s?` applyAlignment="1"`:``}>${s}</xf>`),f.set(i,o),o},m=e=>{let t=i(e.numFmt),n=s(e.bold===!0,e.color),r=u(e.fill);return t===0&&n===0&&r===0&&(!e.align||e.align===`left`)?0:p(t,n,r,e.align)};for(let e of t)for(let t of e)m(t);return{styleIndexOf:m,build:()=>`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
35
|
+
<styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">`+(n.size>0?`<numFmts count="${n.size}">${[...n.entries()].map(([e,t])=>`<numFmt numFmtId="${t}" formatCode="${B(e)}"/>`).join(``)}</numFmts>`:``)+`<fonts count="${a.length}">${a.join(``)}</fonts><fills count="${c.length}">${c.join(``)}</fills><borders count="1"><border><left/><right/><top/><bottom/><diagonal/></border></borders><cellStyleXfs count="1"><xf numFmtId="0" fontId="0" fillId="0" borderId="0"/></cellStyleXfs><cellXfs count="${d.length}">${d.join(``)}</cellXfs><cellStyles count="1"><cellStyle name="Normal" xfId="0" builtinId="0"/></cellStyles></styleSheet>`}}function Ve(e){let{header:t,rows:n}=e,r=Be(t,n),i=[],a=[`<row r="1">${t.map((e,t)=>`<c r="${V(t)}1" s="1" t="inlineStr"><is><t xml:space="preserve">${B(e)}</t></is></c>`).join(``)}</row>`];for(let e=0;e<n.length;e++){let t=e+2,o=n[e],s=[];for(let e=0;e<o.length;e++){let n=o[e],a=`${V(e)}${t}`,c=r.styleIndexOf(n),l=c?` s="${c}"`:``;if(n.link&&i.push({ref:a,url:n.link,id:`rId${i.length+1}`}),n.value==null||n.value===``)s.push(`<c r="${a}"${l}/>`);else if(n.t===`n`)s.push(`<c r="${a}"${l}><v>${Number(n.value)}</v></c>`);else if(n.t===`d`){let e=Pe(n.value);s.push(`<c r="${a}"${l}><v>${Ne(e)}</v></c>`)}else n.t===`b`?s.push(`<c r="${a}"${l} t="b"><v>${+!!n.value}</v></c>`):s.push(`<c r="${a}"${l} t="inlineStr"><is><t xml:space="preserve">${B(String(n.value))}</t></is></c>`)}a.push(`<row r="${t}">${s.join(``)}</row>`)}let o=e.widths?`<cols>${e.widths.map((e,t)=>`<col min="${t+1}" max="${t+1}" width="${Math.max(4,Math.round(e/7*100)/100)}" customWidth="1"/>`).join(``)}</cols>`:``,s=Math.max(0,Math.floor(e.freezeColumns??0)),c=+!!e.freezeHeader,l=`<sheetView workbookViewId="0"/>`;if(c>0||s>0){let e=`${V(s)}${c+1}`,t=s>0&&c>0?`bottomRight`:s>0?`topRight`:`bottomLeft`;l=`<sheetView workbookViewId="0"><pane${s>0?` xSplit="${s}"`:``}${c>0?` ySplit="${c}"`:``} topLeftCell="${e}" activePane="${t}" state="frozen"/><selection pane="${t}" activeCell="${e}" sqref="${e}"/></sheetView>`}let u=n.length>0?(e.condFormats??[]).map((e,t)=>{let r=V(e.colIdx),i=`${r}2:${r}${n.length+1}`;if(e.kind===`dataBar`){let n=H(e.color)??`FF638EC6`;return`<conditionalFormatting sqref="${i}"><cfRule type="dataBar" priority="${t+1}"><dataBar><cfvo type="min"/><cfvo type="max"/><color rgb="${n}"/></dataBar></cfRule></conditionalFormatting>`}let a=e.colors.map(e=>H(e)??`FFFFFFFF`),o=a.length>=3?`<cfvo type="min"/><cfvo type="percentile" val="50"/><cfvo type="max"/>`:`<cfvo type="min"/><cfvo type="max"/>`,s=a.map(e=>`<color rgb="${e}"/>`).join(``);return`<conditionalFormatting sqref="${i}"><cfRule type="colorScale" priority="${t+1}"><colorScale>${o}${s}</colorScale></cfRule></conditionalFormatting>`}).join(``):``,d=i.length?`<hyperlinks>${i.map(e=>`<hyperlink ref="${e.ref}" r:id="${e.id}"/>`).join(``)}</hyperlinks>`:``,f=``,p=``,m=``;if(e.table&&t.length>0){let o=e.table,s=new Set,c=t.map((e,t)=>{let n=(e??``).trim()||`Column${t+1}`,r=n,i=1;for(;s.has(r.toLowerCase());)r=`${n}${++i}`;return s.add(r.toLowerCase()),r}),l=V(t.length-1),u=n.length+1,d=u+1,h=o.totalsRow&&n.length>0,g=o.totalsFns.findIndex(e=>!e);if(h){let e=t.map((e,t)=>{let i=`${V(t)}${d}`,a=o.totalsFns[t];if(a){let e=0;for(let r of n){let n=r[t];n?.t===`n`&&typeof n.value==`number`&&(e+=n.value)}let s=n.find(e=>e[t]?.t===`n`)?.[t]?.numFmt,l=r.styleIndexOf({t:`n`,value:e,numFmt:s,bold:!0}),u=a===`average`?101:a===`count`?103:109,d=a===`count`?n.length:e;return`<c r="${i}"${l?` s="${l}"`:``}><f>SUBTOTAL(${u},${o.name}[${B(c[t])}])</f><v>${d}</v></c>`}if(t===g){let e=r.styleIndexOf({t:`s`,value:`Total`,bold:!0});return`<c r="${i}"${e?` s="${e}"`:``} t="inlineStr"><is><t>Total</t></is></c>`}return`<c r="${i}"/>`});a.push(`<row r="${d}">${e.join(``)}</row>`)}let _=c.map((e,t)=>{let n=h?o.totalsFns[t]:void 0,r=h?n?` totalsRowFunction="${n}"`:t===g?` totalsRowLabel="Total"`:``:``;return`<tableColumn id="${t+1}" name="${B(e)}"${r}/>`}).join(``);f=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
36
|
+
<table xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" id="1" name="${B(o.name)}" displayName="${B(o.name)}" ref="A1:${l}${h?d:u}"${h?` totalsRowCount="1"`:` totalsRowShown="0"`}><autoFilter ref="A1:${l}${u}"/><tableColumns count="${t.length}">${_}</tableColumns><tableStyleInfo name="${B(o.style??`TableStyleMedium2`)}" showFirstColumn="0" showLastColumn="0" showRowStripes="1" showColumnStripes="0"/></table>`,m=`rId${i.length+1}`,p=`<tableParts count="1"><tablePart r:id="${m}"/></tableParts>`}let h=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
37
|
+
<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"><sheetViews>${l}</sheetViews><sheetFormatPr defaultRowHeight="15"/>`+o+`<sheetData>${a.join(``)}</sheetData>`+u+d+p+`</worksheet>`,g={"[Content_Types].xml":f?Fe.replace(`</Types>`,`<Override PartName="/xl/tables/table1.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml"/></Types>`):Fe,"_rels/.rels":Ie,"xl/workbook.xml":Re(e.sheetName),"xl/_rels/workbook.xml.rels":ze,"xl/styles.xml":r.build(),"xl/worksheets/sheet1.xml":h};if(f&&(g[`xl/tables/table1.xml`]=f),i.length||m){let e=i.map(e=>`<Relationship Id="${e.id}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink" Target="${B(e.url)}" TargetMode="External"/>`);m&&e.push(`<Relationship Id="${m}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/table" Target="../tables/table1.xml"/>`),g[`xl/worksheets/_rels/sheet1.xml.rels`]=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
38
|
+
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">`+e.join(``)+`</Relationships>`}return g}async function He(e,t){let n=new t;for(let[t,r]of Object.entries(e))n.file(t,r);return n.generateAsync({type:`blob`,mimeType:`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`})}function Ue(e){let t=e=>!!e&&typeof e==`object`&&Object.keys(e).some(e=>/\.(ttf|otf)$/i.test(e))&&Object.values(e).every(e=>typeof e==`string`),n=new Set,r=e=>{if(!e||typeof e!=`object`||n.has(e))return null;if(n.add(e),t(e))return e;let i=e;return r(i.pdfMake?.vfs)??r(i.vfs)??r(i.default)};return r(e)}function We(e,t){let n=Ue(t);return n?(typeof e.addVirtualFileSystem==`function`&&e.addVirtualFileSystem(n),e.vfs=n,!0):!1}function Ge(e){if(!e)return null;let t=e.trim(),n=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(t);if(n){let e=n[1];return`#`+(e.length===3?e.split(``).map(e=>e+e).join(``):e).toLowerCase()}let r=/^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)(?:[\s,/]+([\d.]+%?))?\s*\)$/i.exec(t);if(!r||!((r[4]===void 0?1:r[4].endsWith(`%`)?Number(r[4].slice(0,-1))/100:Number(r[4]))>.05))return null;let i=e=>Math.max(0,Math.min(255,Math.round(Number(e)))).toString(16).padStart(2,`0`);return`#`+i(r[1])+i(r[2])+i(r[3])}function Ke(e){let t=parseInt(e.slice(1),16),n=e=>{let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4};return .2126*n(t>>16&255)+.7152*n(t>>8&255)+.0722*n(t&255)}function qe(e){if(!e||typeof getComputedStyle!=`function`)return{};let t=t=>e.querySelector(t),n=(e,t)=>e?Ge(getComputedStyle(e).getPropertyValue(t)):null,r=e=>{for(let t=e;t;t=t.parentElement){let e=n(t,`background-color`);if(e)return e}return null},i=`:not([class*="row-number"]):not([class*="selection"])`,a=t(`.sv-grid-head .sv-grid-column${i}`)??t(`.sv-grid-header-cell`)??t(`thead th`),o=t(`.sv-grid-body .sv-grid-row:not(.sv-grid-row-alt):not(.sv-grid-header-row) .sv-grid-cell${i}`)??t(`tbody td`),s=t(`.sv-grid-body .sv-grid-row-alt .sv-grid-cell${i}`),c=t(`.sv-grid-group-row .sv-grid-cell`),l={},u=r(a),d=n(a,`color`);u&&(l.headerColor=u),d&&(l.headerTextColor=d);let f=r(o?o.parentElement:t(`.sv-grid-container`)??e),p=n(o,`color`);if(f&&Ke(f)<.4||p&&Ke(p)>.5)return l;p&&(l.textColor=p);let m=n(o,`border-bottom-color`)??n(a,`border-bottom-color`);m&&(l.borderColor=m);let h=n(s,`background-color`);h&&h!==f&&(l.zebraColor=h);let g=n(c,`background-color`),_=n(c,`color`);return g&&g!==f&&(l.groupColor=g),_&&(l.groupTextColor=_),l}var Je={A4:[595.28,841.89],A3:[841.89,1190.55],A5:[419.53,595.28],LETTER:[612,792],LEGAL:[612,1008]};async function Ye(e,t){if(!e?.length)return[];let n=[];for(let r of e){if(`image`in r){n.push(r);continue}let e=await t(r.element),i=await new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(String(r.result)),r.onerror=()=>n(r.error??Error(`could not read the chart image`)),r.readAsDataURL(e)});n.push({image:i,title:r.title,caption:r.caption,width:r.width})}return n}function Xe(e){let{columns:t}=e,n=e.opts??{},r=e.styles??{},i=e.theme??{},a=e.now??new Date(0),o=n.fontSize??8,s=n.headerColor??r.headerRow?.backgroundColor??i.headerColor??`#334155`,c=n.headerTextColor??r.headerRow?.color??i.headerTextColor??`#ffffff`,l=n.zebra??!0,u=n.zebraColor??r.rowAlternate?.backgroundColor??i.zebraColor??`#f1f5f9`,d=n.groupColor??i.groupColor??`#e2e8f0`,f=n.groupTextColor??i.groupTextColor??`#0f172a`,p=n.subtotalColor??i.subtotalColor??`#f8fafc`,m=n.textColor??r.rows?.color??i.textColor,h=n.borderColor??i.borderColor??`#e2e8f0`,g=n.repeatHeader??!0,_=e=>e===`bold`||typeof e==`number`&&e>=600,v=e=>{if(e===void 0)return;let t=typeof e==`number`?e:parseFloat(e);return Number.isFinite(t)&&t>0?t:void 0},y=(e,t)=>{if(!t)return;t.backgroundColor&&(e.fillColor=t.backgroundColor),t.color&&(e.color=t.color),_(t.fontWeight)?e.bold=!0:t.fontWeight===`normal`&&(e.bold=!1),t.fontStyle===`italic`&&(e.italics=!0);let n=v(t.fontSize);n&&(e.fontSize=n),t.textAlign&&(e.alignment=t.textAlign)},b=new Map;for(let[e,t]of Object.entries(r.cells??{})){let n=/^([A-Z]+)(\d+)$/i.exec(e.trim());if(!n)continue;let r=0;for(let e of n[1].toUpperCase())r=r*26+(e.charCodeAt(0)-64);b.set(`${Number(n[2])-1}:${r-1}`,t)}let x=n.pageOrientation??(t.length>(n.autoLandscapeThreshold??8)?`landscape`:`portrait`),S=Array.isArray(n.columnWidths)?n.columnWidths:t.map(()=>n.columnWidths===`auto`?`auto`:`*`),C=t.map((e,t)=>{let n={text:e.header,bold:!0,alignment:e.align??`left`,color:c,fillColor:s};return y(n,r.headerRow?{...r.headerRow,backgroundColor:void 0,color:void 0}:void 0),y(n,b.get(`0:${t}`)),n}),w=e.body??(e.rows??[]).map(e=>({kind:`data`,cells:e})),ee=e.dataCellStyle,te=e.dataCellLink,ne=0,T=new Set,E=[C];if(w.forEach((e,n)=>{let i=n+1;if(e.kind===`group`){let n={text:e.label,bold:!0,color:f,fillColor:d,colSpan:t.length,margin:[(e.level??0)*12,2,0,2]},r=Array.from({length:Math.max(0,t.length-1)},()=>({text:``}));E.push([n,...r])}else if(e.kind===`subtotal`)E.push(t.map((t,n)=>({text:e.cells[n]??``,bold:!0,alignment:t.align??`left`,fillColor:p})));else{T.add(i);let n=ne++;E.push(t.map((t,i)=>{let a={text:e.cells[i]??``,alignment:t.align??`left`};m&&(a.color=m),y(a,r.rows?{...r.rows,backgroundColor:void 0}:void 0),l&&n%2==1&&r.rowAlternate?.color&&(a.color=r.rowAlternate.color),y(a,b.get(`${n+1}:${i}`));let o=ee?.(n,i);o&&(o.fill&&(a.fillColor=o.fill),o.color&&(a.color=o.color),o.bold&&(a.bold=!0));let s=te?.(n,i);return s&&(a.link=s,a.decoration=`underline`,o?.color||(a.color=`#2563eb`)),a}))}}),e.merges?.length&&!e.body){let n=[...T].sort((e,t)=>e-t);for(let r of e.merges){let e=Math.max(1,Math.floor(r.rowSpan??1)),i=Math.max(1,Math.floor(r.colSpan??1));if(e===1&&i===1)continue;let a=n[r.row];if(a===void 0||r.col<0||r.col>=t.length)continue;let o=E[a]?.[r.col];if(o){e>1&&(o.rowSpan=Math.min(e,E.length-a)),i>1&&(o.colSpan=Math.min(i,t.length-r.col));for(let e=0;e<(o.rowSpan??1);e+=1)for(let t=0;t<(o.colSpan??1);t+=1){if(e===0&&t===0)continue;let n=E[a+e]?.[r.col+t];n&&(n.text=``)}}}}let D={table:{headerRows:+!!g,dontBreakRows:!0,widths:S,body:E},layout:{fillColor:e=>l&&e>0&&e%2==0&&T.has(e)?u:null,hLineWidth:()=>.5,vLineWidth:()=>.5,hLineColor:()=>h,vLineColor:()=>h,paddingTop:()=>3,paddingBottom:()=>3,paddingLeft:()=>5,paddingRight:()=>5}},O=(e,t)=>(e??[]).map(e=>{if(`image`in e)return{image:e.image,...e.width?{width:e.width}:{},...e.height?{height:e.height}:{},margin:t};if(`text`in e){let n={text:e.text};return y(n,e.style),{...n,margin:t}}return{columns:[{text:e.left??``,alignment:`left`},{text:e.center??``,alignment:`center`},{text:e.right??``,alignment:`right`}],margin:t}}),k=[];if(k.push(...O(e.headerLines,[0,0,0,4])),n.logo&&k.push({image:n.logo,width:n.logoWidth??90,margin:[0,0,0,8]}),n.title&&k.push({text:n.title,fontSize:o+8,bold:!0,margin:[0,0,0,2]}),n.subtitle&&k.push({text:n.subtitle,fontSize:o+1,color:`#64748b`,margin:[0,0,0,8]}),n.kpis?.length){let e=n.kpiColor??`#f8fafc`;k.push({table:{widths:n.kpis.map(()=>`*`),body:[n.kpis.map(t=>({fillColor:e,margin:[8,6,8,6],stack:[{text:t.label,fontSize:o,color:`#64748b`},{text:t.value,fontSize:o+10,bold:!0,margin:[0,2,0,0]},...t.delta?[{text:t.delta,fontSize:o,color:t.color??`#64748b`,margin:[0,2,0,0]}]:[]]}))]},layout:{hLineWidth:()=>0,vLineWidth:()=>4,vLineColor:()=>`#ffffff`,paddingLeft:()=>0,paddingRight:()=>0,paddingTop:()=>0,paddingBottom:()=>0},margin:[0,0,0,10]})}let A=n.margins??[28,34,28,34],[re,ie]=Je[n.pageSize??`A4`],j=(x===`landscape`?ie:re)-A[0]-A[2],M=(e.charts??(n.charts??[]).filter(e=>`image`in e)).map(e=>({stack:[...e.title?[{text:e.title,fontSize:o+3,bold:!0,margin:[0,0,0,4]}]:[],{image:e.image,width:Math.min(e.width??j,j)},...e.caption?[{text:e.caption,fontSize:o,color:`#64748b`,margin:[0,3,0,0]}]:[]],margin:[0,0,0,12],unbreakable:!0}));n.chartsPosition!==`below`&&k.push(...M),k.push(D),n.chartsPosition===`below`&&(M.length&&k.push({text:``,margin:[0,0,0,12]}),k.push(...M)),k.push(...O(e.footerLines,[0,4,0,0]));let N={pageSize:n.pageSize??`A4`,pageOrientation:x,pageMargins:n.margins??[28,34,28,34],defaultStyle:{fontSize:o},content:k};if(n.showPageNumbers??!0){let e=a.toISOString().slice(0,10);N.footer=(t,n)=>({margin:[28,6,28,0],columns:[{text:e,alignment:`left`,fontSize:7,color:`#94a3b8`},{text:`Page ${t} of ${n}`,alignment:`right`,fontSize:7,color:`#94a3b8`}]})}return N}function Ze(e,t){let n=/^#?([0-9a-f]{6})$/i.exec(e.trim());if(!n)return e;let r=parseInt(n[1],16);return`#`+[r>>16&255,r>>8&255,r&255].map(e=>Math.round(e+(255-e)*t).toString(16).padStart(2,`0`)).join(``)}function Qe(e){let t={};return e.background&&(t.fill=e.background),!t.fill&&e.dataBar&&(t.fill=Ze(e.dataBar.color,.72)),e.color&&e.color!==`transparent`&&(t.color=e.color),(e.fontWeight===`bold`||typeof e.fontWeight==`number`&&e.fontWeight>=600)&&(t.bold=!0),e.icon&&(t.icon=e.icon),Object.keys(t).length>0?t:void 0}function U(e,t,a){if(!a||a.length===0)return()=>void 0;let o=new Map;if(r(a))for(let n of e)o.set(n.field,i(t.map(e=>e[n.field])));return(r,i)=>{let s=e[i],c=t[r];if(!s||!c)return;let l=c[s.field];return Qe(n(l,c,s.field,a,o.get(s.field)??null))}}var $e=[`csv`,`tsv`,`html`,`json`,`xml`,`md`],et=null;async function tt(){if(typeof window>`u`)throw Error(`@svgrid/enterprise: export requires a browser environment`);return et||=(async()=>{De(),await h(()=>import(`./smart.export-CDCwbFH4.js`),[],import.meta.url);let e=window.Smart?.Utilities?.DataExporter;if(!e)throw Error(`@svgrid/enterprise: failed to load Smart.Utilities.DataExporter`);return e})(),et}async function W(t){let n=globalThis;if(t===`xlsx`&&n.JSZip==null){let t;try{t=await h(()=>import(`./jszip.min-CX2fPs3O.js`).then(t=>e(t.default,1)),__vite__mapDeps([0,1]),import.meta.url)}catch{throw Error(`@svgrid/enterprise: xlsx export requires the "jszip" peer dependency. Install it with: pnpm add jszip`)}n.JSZip=t.default??t}if(t===`pdf`&&n.pdfMake==null){let t,r;try{t=await h(()=>import(`./pdfmake-BpIYFHoG.js`).then(t=>e(t.default,1)),__vite__mapDeps([2,1]),import.meta.url),r=await h(()=>import(`./vfs_fonts-BV-Ul9v2.js`).then(t=>e(t.default,1)),__vite__mapDeps([3,1]),import.meta.url)}catch{throw Error(`@svgrid/enterprise: pdf export requires the "pdfmake" peer dependency. Install it with: pnpm add pdfmake`)}let i=t.default??t;if(!We(i,r))throw Error(`@svgrid/enterprise: "pdfmake/build/vfs_fonts" did not contain a font map; the installed pdfmake is not one this export knows.`);n.pdfMake=i}}function G(e,t){if(Array.isArray(t))return t;switch(t){case`selected`:return e.getSelectedRows();case`all`:return e.getData();case`displayed`:case void 0:default:return e.getDisplayedRows()}}function K(e,t,n){if(t.columns&&t.columns.length>0)return t.columns;let r=e.getColumns().filter(e=>e.visible&&e.field);return r.length>0?r.map(e=>({field:e.field,header:e.header,format:e.format,align:e.align})):n.length>0?Object.keys(n[0]).filter(e=>!e.startsWith(`_`)).map(e=>({field:e})):[]}function q(e,t,n){if(e.exportValue)return e.exportValue(t)??``;let r=t[e.field];return n?r:c(r,e.format)}async function J(e,t,n){let r=n.rawValues===!0,i={};for(let e of t)i[e.field]=e.header??e.field;let a=[i],o=e.length;for(let i=0;i<o;i++){if(n.signal?.aborted)throw new DOMException(`Export aborted`,`AbortError`);let s=e[i],c={};for(let e of t)c[e.field]=q(e,s,r);a.push(c),i>0&&i%5e3==0&&(n.onProgress?.({phase:`project`,ratio:i/o,row:i,total:o}),await new Promise(e=>setTimeout(e,0)))}return n.onProgress?.({phase:`project`,ratio:1,row:o,total:o}),a}function nt(e){if(!e)return;let t={};e.headerRow&&(t.header={...e.headerRow});let n=e.rows?{...e.rows}:{};return e.rowAlternate&&(n.alternationCount=2,n.alternationStart=0,e.rowAlternate.backgroundColor&&(n.alternationIndex1BackgroundColor=e.rowAlternate.backgroundColor),e.rowAlternate.color&&(n.alternationIndex1Color=e.rowAlternate.color)),Object.keys(n).length>0&&(t.rows=n),e.cells&&(t.cells=e.cells),t}var rt=0,it=new Map;function at(e){let t=it.get(e);if(t)return t;let n=`img${++rt}`;return it.set(e,n),n}function ot(e,t=64,n=64){let r=/^data:image\/([a-zA-Z0-9+]+);/i.exec(e)?.[1]?.toLowerCase()??`png`,i=r===`jpg`?`jpeg`:r===`svg+xml`?`svg`:r;return{id:at(e),base64:e,imageType:i,width:t,height:n}}function st(e,t){if(!e||e.length===0||t.length===0)return;let n=t[0],r=[];for(let i of e){let e={},a;if(`image`in i)e[n]=i.image,a={mergeAcross:!0,textAlign:`left`};else if(`text`in i)e[n]=i.text,a={mergeAcross:!0,...i.style??{}};else{let r=t[Math.floor(t.length/2)],o=t[t.length-1];i.left!==void 0&&(e[n]=i.left),i.center!==void 0&&(e[r]=i.center),i.right!==void 0&&(e[o]=i.right),a={textAlign:`left`}}r.push({cells:e,style:a})}return r}function ct(e,t){let n=e&&e.length>0?new Set(e):null;return(e,r,i)=>typeof i!=`string`||!/^data:image\//i.test(i)?null:n&&!n.has(r)?{image:ot(i,96,96),value:``}:{image:ot(i,t.width,t.height),value:``}}function lt(e){let t={exportHeader:!0,pageOrientation:e.pageOrientation??`portrait`};e.freezeHeader!==!1&&(t.freezeHeader=!0),e.freezeColumns&&e.freezeColumns>0&&(t.freezeColumnsCount=Math.floor(e.freezeColumns));let n=nt(e.styles);if(n&&(t.style=n),e.hierarchical&&(t.hierarchical=!0),e.merges?.length&&!e.groupBy?.length&&!e.hierarchical){let n=e.merges.map(e=>({cell:[e.row,e.col],rowspan:Math.max(1,Math.floor(e.rowSpan??1)),colspan:Math.max(1,Math.floor(e.colSpan??1))})).filter(e=>e.rowspan>1||e.colspan>1);n.length&&(t.mergedCells=n)}return t}function ut(e,t,n){let r=st(t.header,n),i=st(t.footer,n);r&&(e.headerContent=r),i&&(e.footerContent=i);let a=(t.header?.some(e=>`image`in e)??!1)||(t.footer?.some(e=>`image`in e)??!1);if(t.imageFields?.length||a){let n=t.imageSize??{width:32,height:32};e.addImageToCell=ct(t.imageFields,n)}return e}function Y(e,t){return e.toLowerCase().endsWith(`.`+t)?e:`${e}.${t}`}function dt(e,t,n,r,i){return i!==!1&&p(e,t),{blob:e,filename:t,mime:n,rowCount:r,byteSize:e.size}}function ft(e,t,n,r,i){i!==!1&&u(e,t,n);let a=new Blob([e],{type:n});return{blob:a,filename:t,mime:n,rowCount:r,byteSize:a.size}}function X(e,t,n){let r=Math.min(t.length,200);return e.map(e=>{if(typeof e.width==`number`)return e.width;let i=String(e.header??e.field).length;for(let a=0;a<r;a++){let r=q(e,t[a],n),o=r==null?0:String(r).length;o>i&&(i=o)}return Math.max(48,Math.min(400,i*7+14))})}function pt(e,t,n){if(typeof t.freezeColumns==`number`)return t.freezeColumns;let r=e.getColumnPinning().left;if(!r||r.length===0)return;let i=new Set(r),a=0;for(let e of n)if(i.has(e.field))a++;else break;return a>0?a:void 0}function mt(e){let t=e,n=``;do n=String.fromCharCode(65+t%26)+n,t=Math.floor(t/26)-1;while(t>=0);return n}function Z(e,t){if(e.some(e=>e.link))return(n,r)=>{let i=e[r],a=t[n];if(!(!i?.link||!a))return i.link(a)||void 0}}function ht(e){let t={};for(let n of e)n.align&&(t[n.field]=n.align);return t}async function gt(e,t,n,r,i,s){let c=n.map(e=>e.field),u={onProgress:r.onProgress,signal:r.signal};switch(e){case`html`:return{text:await d(t,c,{...u,title:(r.filename??`grid`).trim()||`grid`,align:ht(n),cellStyle:i,cellLink:s}),mime:`text/html;charset=utf-8`,ext:`html`};case`json`:return{text:await f(t,c,u),mime:`application/json;charset=utf-8`,ext:`json`};case`xml`:return{text:await l(t,c,u),mime:`application/xml;charset=utf-8`,ext:`xml`};case`md`:return{text:await o(t,c,{...u,align:ht(n)}),mime:`text/markdown;charset=utf-8`,ext:`md`};case`tsv`:return{text:await a(t,c,{...u,csv:{...r.csv,delimiter:` `}}),mime:`text/tab-separated-values;charset=utf-8`,ext:`tsv`};default:{let e=r.csv?.delimiter??`,`;return{text:await a(t,c,{...u,csv:{...r.csv,delimiter:e}}),mime:`text/csv;charset=utf-8`,ext:`csv`}}}}async function _t(e,t){if(t.sheets&&t.sheets.length>0)throw Error(`@svgrid/enterprise: multi-sheet export requires format 'xlsx', got '${t.format}'`);let n=G(e,t.rows);if(n.length===0)throw Error(`@svgrid/enterprise: nothing to export - the grid has no rows`);let r=K(e,t,n),i=await J(n,r,t.format===`json`?{...t,rawValues:t.rawValues??!0}:t),a=(t.filename??`grid`).trim()||`grid`,o=t.format===`html`?U(r,n,t.conditionalFormats):void 0,s=t.format===`html`?Z(r,n):void 0,{text:c,mime:l,ext:u}=await gt(t.format,i,r,t,o,s);return ft(c,Y(a,u),l,n.length,t.download)}async function vt(e,t){if(t.sheets&&t.sheets.length>0)throw Error(`@svgrid/enterprise: multi-sheet export requires format 'xlsx'. Use 'xls' for a single legacy sheet.`);let n=G(e,t.rows);if(n.length===0)throw Error(`@svgrid/enterprise: nothing to export - the grid has no rows`);let r=K(e,t,n),i=(t.filename??`grid`).trim()||`grid`,a=U(r,n,t.conditionalFormats);return ft(await Ae(i,r,n,{rawValues:t.rawValues,onProgress:t.onProgress,signal:t.signal,freezeHeader:t.freezeHeader!==!1,freezeColumns:pt(e,t,r),widths:t.autoFitColumns===!1?void 0:X(r,n,t.rawValues===!0),cellVisual:t.conditionalFormats?.length?a:void 0,precisionSafe:t.precisionSafe}),Y(i,`xls`),`application/vnd.ms-excel;charset=utf-8`,n.length,t.download)}function Q(e){return e.format?.type===`number`||e.format?.type===`currency`}function yt(e,t,n){let r=[],i=t=>e.find(e=>e.field===t)?.header??t,a=e.findIndex(e=>!Q(e)),o=(t,s)=>{if(s>=n.length){for(let n of t)r.push({kind:`data`,cells:e.map(e=>String(q(e,n,!1)??``))});return}let l=n[s],u=new Map;for(let e of t){let t=String(e[l]??``),n=u.get(t);n?n.push(e):u.set(t,[e])}for(let[t,n]of u)if(r.push({kind:`group`,label:`${i(l)}: ${t} (${n.length})`,level:s}),o(n,s+1),e.some(Q)){let i=e.map(e=>{if(!Q(e))return``;let t=n.reduce((t,n)=>t+(Number(n[e.field])||0),0);return c(t,e.format)});a>=0&&(i[a]=`Subtotal (${t})`),r.push({kind:`subtotal`,cells:i})}};return o(t,0),r}async function bt(e,t){await W(`pdf`);let n=globalThis.pdfMake;if(!n)throw Error(`@svgrid/enterprise: pdf export requires the "pdfmake" peer dependency.`);let r=G(e,t.rows);if(r.length===0)throw Error(`@svgrid/enterprise: nothing to export - the grid has no rows`);let i=K(e,t,r),a=i.map(e=>e.field),o=i.map(e=>({header:e.header??e.field,align:e.align})),s=t.autoGroup!==!1&&!t.groupBy?.length&&!t.hierarchical?(e.getState().grouping??[]).filter(e=>!!e).map(e=>String(e)):[],c=t.groupBy?.length?t.groupBy:s.length>0?s:void 0;if(t.signal?.aborted)throw new DOMException(`Export aborted`,`AbortError`);t.onProgress?.({phase:`write`,ratio:0,total:r.length});let l={...t.pdf,pageOrientation:t.pdf?.pageOrientation??t.pageOrientation},u=l.matchTheme===!1?{}:qe(e.getElement?.()??null),d={headerLines:t.header,footerLines:t.footer},f=await Ye(l.charts,async e=>{let{chartToPngBlob:t}=await h(async()=>{let{chartToPngBlob:e}=await import(`./src-CITpcm6b.js`).then(e=>e.t);return{chartToPngBlob:e}},__vite__mapDeps([4,1,5]),import.meta.url);return t(e,{scale:2})}),p=new Date,m;if(c?.length)m=Xe({columns:o,body:yt(i,r,c),opts:l,styles:t.styles,theme:u,...d,charts:f,now:p});else{let e=(await J(r,i,t)).slice(1).map(e=>a.map(t=>String(e[t]??``))),n=U(i,r,t.conditionalFormats);for(let t=0;t<e.length;t++)for(let r=0;r<i.length;r++){let i=n(t,r)?.icon;i&&(e[t][r]=`${i} ${e[t][r]??``}`)}m=Xe({columns:o,rows:e,dataCellStyle:(e,t)=>{let r=n(e,t);return r?{fill:r.fill,color:r.color,bold:r.bold}:void 0},dataCellLink:Z(i,r),opts:l,styles:t.styles,theme:u,...d,merges:t.merges,charts:f,now:p})}let g=(t.filename??`grid`).trim()||`grid`,_=await new Promise(e=>n.createPdf(m).getBlob(e));return t.onProgress?.({phase:`write`,ratio:1,total:r.length}),dt(_,Y(g,`pdf`),`application/pdf`,r.length,t.download)}async function xt(e,t,n,r,i,a){let o=e.map(e=>e.header??e.field),l=a?.precisionSafe===!0,u=(e,t,n)=>l&&Math.abs(e)>=0x38d7ea4c68000?{t:`s`,value:String(e),...t}:{t:`n`,value:e,numFmt:n,...t},d=(t,a,o)=>{let l=e[o],d=r(a,o),f={align:l.align,fill:d?.fill,color:d?.color,bold:d?.bold,link:i?.(a,o)};if(l.exportValue){let e=l.exportValue(t);return typeof e==`number`&&Number.isFinite(e)?u(e,f,m(l.format)):e instanceof Date?{t:`d`,value:e,numFmt:m(l.format)??`yyyy-mm-dd`,...f}:{t:`s`,value:e==null?``:String(e),...f}}let p=t[l.field];if(d?.icon){let e=n?String(p??``):c(p,l.format);return{t:`s`,value:`${d.icon} ${e}`,...f}}if(n)return typeof p==`number`&&Number.isFinite(p)?u(p,f):{t:`s`,value:p==null?``:String(p),...f};let h=s(p,l.format);return h.ok?h.value instanceof Date?{t:`d`,value:h.value,numFmt:m(l.format)??`yyyy-mm-dd`,...f}:u(h.value,f,m(l.format)):{t:`s`,value:c(p,l.format),...f}},f=[],p=t.length;for(let n=0;n<p;n++){if(a?.signal?.aborted)throw new DOMException(`Export aborted`,`AbortError`);let r=t[n];f.push(e.map((e,t)=>d(r,n,t))),n>0&&n%2e3==0&&(a?.onProgress?.({phase:`project`,ratio:n/p,row:n,total:p}),await new Promise(e=>setTimeout(e,0)))}return{header:o,cells:f}}async function St(e,t){await W(`xlsx`);let n=globalThis.JSZip;if(!n)throw Error(`@svgrid/enterprise: xlsx export requires the "jszip" peer dependency.`);let r=G(e,t.rows);if(r.length===0)throw Error(`@svgrid/enterprise: nothing to export - the grid has no rows`);let i=K(e,t,r),a=t.rawValues===!0,o=t.conditionalFormats??[],s=U(i,r,o.filter(e=>e.type===`rule`||e.type===`iconSet`)),c=Z(i,r),l=[];for(let e of o){if(e.type!==`colorScale`&&e.type!==`dataBar`)continue;let t=e.columns&&e.columns.length>0?i.map((t,n)=>e.columns.includes(t.field)?n:-1).filter(e=>e>=0):i.map((e,t)=>t);for(let n of t)if(e.type===`dataBar`)l.push({kind:`dataBar`,colIdx:n,color:e.color});else{let t=e.min??`#ffffff`,r=e.max??`#000000`;l.push({kind:`colorScale`,colIdx:n,colors:e.mid?[t,e.mid,r]:[t,r]})}}if(t.signal?.aborted)throw new DOMException(`Export aborted`,`AbortError`);t.onProgress?.({phase:`write`,ratio:0,total:r.length});let{header:u,cells:d}=await xt(i,r,a,s,c,{onProgress:t.onProgress,signal:t.signal,precisionSafe:t.precisionSafe}),f=t.autoFitColumns===!1?void 0:X(i,r,a),p=(t.filename??`grid`).trim()||`grid`,m;t.excelTable&&(m={name:`Table1`,totalsRow:typeof t.excelTable==`object`&&t.excelTable.totalsRow===!0,style:typeof t.excelTable==`object`?t.excelTable.style:void 0,totalsFns:i.map(e=>Q(e)?`sum`:void 0)});let h=await He(Ve({sheetName:p,header:u,rows:d,widths:f,freezeHeader:t.freezeHeader!==!1,freezeColumns:pt(e,t,i),condFormats:l,table:m}),n);return t.onProgress?.({phase:`write`,ratio:1,total:r.length}),dt(h,Y(p,`xlsx`),`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,r.length,t.download)}async function Ct(e,t){if(Te(`Export`),$e.includes(t.format))return _t(e,t);if(t.format===`xls`)return vt(e,t);if(t.format===`pdf`)return bt(e,t);if(t.format===`xlsx`){let n=t.autoGroup===!1?[]:(e.getState().grouping??[]).filter(e=>!!e),r=(t.groupBy?.length??0)>0||n.length>0,i=!!t.styles&&!t.conditionalFormats?.length;if(!t.sheets?.length&&!r&&!t.hierarchical&&!t.merges?.length&&!t.header?.length&&!t.footer?.length&&!t.imageFields?.length&&!i)return St(e,t)}await W(t.format);let n=await tt();if(t.sheets&&t.sheets.length>0){if(t.format!==`xlsx`)throw Error(`@svgrid/enterprise: multi-sheet export requires format 'xlsx', got '${t.format}'`);let r=t.rawValues===!0,i=t.sheets.map(n=>{let i=K(e,{columns:n.columns??t.columns},n.rows),a=n.rows.map(e=>{let t={};for(let n of i)t[n.field]=q(n,e,r);return t}),o=t.autoFitColumns===!1?null:X(i,n.rows,r);return{label:n.label,dataSource:a,columns:i.map((e,t)=>o?{dataField:e.field,label:e.header??e.field,width:o[t]}:{dataField:e.field,label:e.header??e.field}),dataFields:i.map(e=>e.field),style:nt(n.styles??t.styles)}}),a=(t.filename??`grid`).trim()||`grid`,o=lt(t),s=i[0],c=new n(o);c.spreadsheets=i,ut(c,t,s.dataFields);let l={};for(let e of s.columns)l[e.dataField]=e.label;let u=[l,...s.dataSource];if(t.download===!1)throw Error(`@svgrid/enterprise: download:false is not supported for multi-sheet xlsx.`);c.exportData(u,t.format,a);return}let r=G(e,t.rows);if(r.length===0)throw Error(`@svgrid/enterprise: nothing to export - the grid has no rows`);let i=K(e,t,r),a=await J(r,i,t),o=(t.filename??`grid`).trim()||`grid`,s=i.map(e=>e.field),c=t.autoGroup!==!1&&!t.groupBy?.length&&!t.hierarchical?(e.getState().grouping??[]).filter(e=>!!e).map(e=>String(e)):[],l=t.groupBy?.length?t.groupBy:c.length>0?c:void 0,u=!t.hierarchical&&l?.length?l:void 0,d=lt(t);if(t.conditionalFormats?.length){let e=U(i,r,t.conditionalFormats),n={};for(let t=0;t<r.length;t++)for(let r=0;r<i.length;r++){let o=e(t,r);if(!o)continue;let s={};if(o.fill&&(s.backgroundColor=o.fill),o.color&&(s.color=o.color),o.bold&&(s.fontWeight=`bold`),Object.keys(s).length&&(n[mt(r)+(t+2)]=s),o.icon){let e=a[t+1],n=i[r].field;e&&(e[n]=`${o.icon} ${e[n]??``}`)}}if(Object.keys(n).length){let e=d.style??{};d.style={...e,cells:{...e.cells??{},...n}}}}if(t.download===!1)throw Error(`@svgrid/enterprise: download:false is not supported for this xlsx export (grouped / merges / header / footer / images). Use a plain xlsx, xls, pdf, or a text format.`);if(t.signal?.aborted)throw new DOMException(`Export aborted`,`AbortError`);t.onProgress?.({phase:`write`,ratio:0,total:a.length-1});let f=new n(d,u);ut(f,t,s),f.exportData(a,t.format,o),t.onProgress?.({phase:`write`,ratio:1,total:a.length-1})}var wt={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`};function $(e){return(e==null?``:String(e)).replace(/[&<>"']/g,e=>wt[e])}function Tt(e){let{columns:t,rows:n}=e,r=e.cellStyle,i=e.cellLink,a=e.opts??{},o=a.orientation??`portrait`,s=a.pageSize?`${a.pageSize} ${o}`:o,c=a.margin??`14mm`,l=a.zebra??!0,u=a.zebraColor??`#f6f8fa`,d=a.headerColor??`#f1f5f9`,f=a.headerTextColor??`#0f172a`,p=a.fontSize??9,m=e=>e&&e!==`left`?` style="text-align:${e}"`:``,h=`<thead><tr>`+t.map(e=>`<th${m(e.align)}>${$(e.header)}</th>`).join(``)+`</tr></thead>`,g=(e,t,n,a)=>{let o=[];e.align&&e.align!==`left`&&o.push(`text-align:${e.align}`);let s=r?.(n,a);s?.fill&&o.push(`background:${s.fill}`),s?.color&&o.push(`color:${s.color}`),s?.bold&&o.push(`font-weight:700`);let c=o.length?` style="${o.join(`;`)}"`:``,l=s?.icon?`${$(s.icon)} ${$(t)}`:$(t),u=i?.(n,a);return u&&(l=`<a href="${$(u)}">${l}</a>`),`<td${c}>${l}</td>`},_=`<tbody>`+n.map((e,n)=>`<tr>`+t.map((t,r)=>g(t,e[r]??``,n,r)).join(``)+`</tr>`).join(``)+`</tbody>`,v=[];return a.logo&&v.push(`<img class="logo" src="${$(a.logo)}" alt="" />`),a.title&&v.push(`<h1>${$(a.title)}</h1>`),a.subtitle&&v.push(`<p class="subtitle">${$(a.subtitle)}</p>`),`<!DOCTYPE html>
|
|
39
|
+
<html><head><meta charset="utf-8"><title>${$(a.title??`Grid`)}</title>
|
|
40
|
+
<style>
|
|
41
|
+
@page { size: ${s}; margin: ${c}; }
|
|
42
|
+
@media print { body { -webkit-print-color-adjust: exact; print-color-adjust: exact; } }
|
|
43
|
+
body { font-family: -apple-system, "Segoe UI", Roboto, sans-serif; color: #111; margin: 0; }
|
|
44
|
+
.logo { max-height: ${a.logoWidth?``:`48px`}; width: ${a.logoWidth?`${a.logoWidth}px`:`auto`}; display: block; margin-bottom: 8px; }
|
|
45
|
+
h1 { font-size: 16pt; margin: 0 0 2px 0; }
|
|
46
|
+
.subtitle { font-size: 10pt; color: #64748b; margin: 0 0 10px 0; }
|
|
47
|
+
table { border-collapse: collapse; width: 100%; font-size: ${p}pt; }
|
|
48
|
+
thead { display: table-header-group; }
|
|
49
|
+
tr { break-inside: avoid; }
|
|
50
|
+
th, td { border: 1px solid #cbd5e1; padding: 4px 7px; text-align: left; }
|
|
51
|
+
th { background: ${d}; color: ${f}; font-weight: 700; }
|
|
52
|
+
${l?`tbody tr:nth-child(even) { background: ${u}; }`:``}
|
|
53
|
+
</style></head>
|
|
54
|
+
<body>
|
|
55
|
+
${v.join(`
|
|
56
|
+
`)}
|
|
57
|
+
<table>${h}${_}</table>
|
|
58
|
+
</body></html>`}async function Et(e,t){if(Te(`Print`),typeof window>`u`)throw Error(`@svgrid/enterprise: print requires a browser environment`);let n=G(e,t?.rows);if(n.length===0)throw Error(`@svgrid/enterprise: nothing to print - the grid has no rows`);let r=K(e,{columns:t?.columns},n),i=r.map(e=>e.field),a=(await J(n,r,{rawValues:t?.rawValues})).slice(1).map(e=>i.map(t=>String(e[t]??``))),o=r.map(e=>({header:e.header??e.field,align:e.align})),s={title:t?.title??`Grid`,subtitle:t?.subtitle,logo:t?.logo,orientation:t?.orientation??`portrait`,pageSize:t?.pageSize,margin:t?.margin,zebra:t?.zebra,headerColor:t?.headerColor},c=U(r,n,t?.conditionalFormats),l=Tt({columns:o,rows:a,cellStyle:(e,t)=>c(e,t),cellLink:Z(r,n),opts:s}),u=window.open(``,`_blank`,`width=900,height=700`);if(!u)throw Error(`@svgrid/enterprise: print() could not open a window - the browser blocked the popup`);u.document.open(),u.document.write(l),u.document.close(),u.focus(),u.addEventListener(`load`,()=>{setTimeout(()=>u.print(),50)}),setTimeout(()=>{try{u.print()}catch{}},300)}var Dt=t({ALL_VALUES:()=>ALL_VALUES,DATA_BAR_COLOR:()=>DATA_BAR_COLOR,DATA_BAR_NEGATIVE_COLOR:()=>DATA_BAR_NEGATIVE_COLOR,DEFAULT_ALERT_MESSAGE:()=>DEFAULT_ALERT_MESSAGE,DEFAULT_TABLE_STYLE:()=>DEFAULT_TABLE_STYLE,GRAND_TOTAL_ROW_ID:()=>GRAND_TOTAL_ROW_ID,GROUP_TOTAL_ROW_ID_PREFIX:()=>GROUP_TOTAL_ROW_ID_PREFIX,NO_TABLE_STYLE:()=>NO_TABLE_STYLE,PROTECTED_MESSAGE:()=>PROTECTED_MESSAGE,countReducer:()=>countReducer,exportGrid:()=>Ct,printGrid:()=>Et});export{O as a,we as i,be as n,xe as r,Dt as t};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
var e=16,t=`http://www.w3.org/2000/svg`;function n(){let e=document.createElementNS(t,`svg`);e.setAttribute(`viewBox`,`0 0 24 24`),e.setAttribute(`fill`,`none`),e.setAttribute(`stroke`,`currentColor`),e.setAttribute(`stroke-width`,`3`),e.setAttribute(`stroke-linecap`,`round`),e.setAttribute(`stroke-linejoin`,`round`);let n=document.createElementNS(t,`path`);return n.setAttribute(`d`,`M6 9l6 6 6-6`),e.appendChild(n),e}var r=`
|
|
2
|
+
:host {
|
|
3
|
+
display: flex;
|
|
4
|
+
user-select: none;
|
|
5
|
+
background: var(--sg-scrollbar-bg, #eef2f8);
|
|
6
|
+
/* The 1px separator is drawn on the INNER edge only (the edge facing
|
|
7
|
+
the grid body) via the orientation rules below. A full inset box
|
|
8
|
+
here doubled up with the grid's own frame border on the outer edge,
|
|
9
|
+
reading as a 2px border - most visible in dense-gridline themes
|
|
10
|
+
like Excel, which should show a single 1px line. */
|
|
11
|
+
/* Start hidden + non-interactive - viewport/content sizes are 0 until
|
|
12
|
+
after the first layout pass, so without this default the scrollbar
|
|
13
|
+
paints visible for one frame and then JS hides it on mount. That
|
|
14
|
+
flicker is what shows up as a "flashing horizontal scrollbar"
|
|
15
|
+
every time a demo first renders. updateGeometry() switches us to
|
|
16
|
+
opacity 1 the moment the grid genuinely has overflow. */
|
|
17
|
+
opacity: 0;
|
|
18
|
+
pointer-events: none;
|
|
19
|
+
transition: opacity 120ms ease;
|
|
20
|
+
}
|
|
21
|
+
:host([orientation="vertical"]) {
|
|
22
|
+
flex-direction: column;
|
|
23
|
+
width: ${e}px;
|
|
24
|
+
/* LTR: vertical scrollbar sits at the right, inner edge is the left. */
|
|
25
|
+
box-shadow: inset 1px 0 0 0 var(--sg-scrollbar-border, rgba(15, 23, 42, 0.04));
|
|
26
|
+
}
|
|
27
|
+
:host([orientation="vertical"]:dir(rtl)) {
|
|
28
|
+
/* RTL flips the scrollbar to the left, so the inner edge is the right. */
|
|
29
|
+
box-shadow: inset -1px 0 0 0 var(--sg-scrollbar-border, rgba(15, 23, 42, 0.04));
|
|
30
|
+
}
|
|
31
|
+
:host([orientation="horizontal"]) {
|
|
32
|
+
flex-direction: row;
|
|
33
|
+
height: ${e}px;
|
|
34
|
+
/* Horizontal scrollbar sits at the bottom, inner edge is the top. */
|
|
35
|
+
box-shadow: inset 0 1px 0 0 var(--sg-scrollbar-border, rgba(15, 23, 42, 0.04));
|
|
36
|
+
}
|
|
37
|
+
.arrow {
|
|
38
|
+
flex: none;
|
|
39
|
+
display: flex;
|
|
40
|
+
align-items: center;
|
|
41
|
+
justify-content: center;
|
|
42
|
+
width: ${e}px;
|
|
43
|
+
height: ${e}px;
|
|
44
|
+
margin: 0;
|
|
45
|
+
padding: 0;
|
|
46
|
+
border: 0;
|
|
47
|
+
border-radius: 3px;
|
|
48
|
+
background: transparent;
|
|
49
|
+
color: var(--sg-scrollbar-arrow, #64748b);
|
|
50
|
+
cursor: pointer;
|
|
51
|
+
transition: background-color 100ms ease, color 100ms ease;
|
|
52
|
+
}
|
|
53
|
+
.arrow:hover {
|
|
54
|
+
background: var(--sg-scrollbar-arrow-hover-bg, #dde4ee);
|
|
55
|
+
color: var(--sg-scrollbar-arrow-hover, #1f2937);
|
|
56
|
+
}
|
|
57
|
+
.arrow:active {
|
|
58
|
+
background: var(--sg-scrollbar-arrow-active-bg, #c7d1df);
|
|
59
|
+
color: var(--sg-scrollbar-arrow-active, #0f172a);
|
|
60
|
+
}
|
|
61
|
+
.arrow:disabled {
|
|
62
|
+
color: var(--sg-scrollbar-arrow-disabled, #cbd5e1);
|
|
63
|
+
cursor: default;
|
|
64
|
+
}
|
|
65
|
+
.arrow:disabled:hover {
|
|
66
|
+
background: transparent;
|
|
67
|
+
}
|
|
68
|
+
.arrow svg {
|
|
69
|
+
width: 10px;
|
|
70
|
+
height: 10px;
|
|
71
|
+
display: block;
|
|
72
|
+
}
|
|
73
|
+
:host([orientation="vertical"]) .arrow-start svg {
|
|
74
|
+
transform: rotate(180deg);
|
|
75
|
+
}
|
|
76
|
+
:host([orientation="horizontal"]) .arrow-start svg {
|
|
77
|
+
transform: rotate(90deg);
|
|
78
|
+
}
|
|
79
|
+
:host([orientation="horizontal"]) .arrow-end svg {
|
|
80
|
+
transform: rotate(-90deg);
|
|
81
|
+
}
|
|
82
|
+
.track {
|
|
83
|
+
position: relative;
|
|
84
|
+
flex: 1 1 0;
|
|
85
|
+
min-width: 0;
|
|
86
|
+
min-height: 0;
|
|
87
|
+
}
|
|
88
|
+
.thumb {
|
|
89
|
+
position: absolute;
|
|
90
|
+
border-radius: var(--sg-scrollbar-thumb-radius, 6px);
|
|
91
|
+
background: var(--sg-scrollbar-thumb, #b1bccd);
|
|
92
|
+
cursor: pointer;
|
|
93
|
+
transition: background-color 100ms ease;
|
|
94
|
+
}
|
|
95
|
+
.thumb:hover {
|
|
96
|
+
background: var(--sg-scrollbar-thumb-hover, #8693a7);
|
|
97
|
+
}
|
|
98
|
+
.thumb:active {
|
|
99
|
+
background: var(--sg-scrollbar-thumb-active, #64748b);
|
|
100
|
+
}
|
|
101
|
+
:host([orientation="vertical"]) .thumb {
|
|
102
|
+
left: 3px;
|
|
103
|
+
right: 3px;
|
|
104
|
+
}
|
|
105
|
+
:host([orientation="horizontal"]) .thumb {
|
|
106
|
+
top: 3px;
|
|
107
|
+
bottom: 3px;
|
|
108
|
+
}
|
|
109
|
+
`,i=typeof HTMLElement<`u`?HTMLElement:class{},a=class extends i{constructor(...e){super(...e),this.dragging=!1,this.dragStart=0,this.valueStart=0,this.holdTimer=null,this.resizeObserver=null,this.resizeFrame=0,this.onArrowStartPointerDown=e=>{e.preventDefault(),this.startHold(-1)},this.onArrowEndPointerDown=e=>{e.preventDefault(),this.startHold(1)},this.stopHold=()=>{this.holdTimer!==null&&(clearTimeout(this.holdTimer),clearInterval(this.holdTimer),this.holdTimer=null)},this.onThumbPointerDown=e=>{e.preventDefault(),this.dragging=!0,this.dragStart=this.orientation===`vertical`?e.clientY:e.clientX,this.valueStart=this.value,document.addEventListener(`pointermove`,this.onPointerMove),document.addEventListener(`pointerup`,this.onPointerUp)},this.onTrackPointerDown=e=>{if(e.target===this.thumb)return;let t=this.track.getBoundingClientRect(),n=this.orientation===`vertical`?e.clientY-t.top:e.clientX-t.left,r=this.orientation===`vertical`?t.height:t.width,i=this.computeThumbSize(r),a=Math.max(r-i,1),o=Math.min(Math.max(n-i/2,0),a);this.emitScroll(o/a*this.maxValue)},this.onPointerMove=e=>{if(!this.dragging)return;let t=(this.orientation===`vertical`?e.clientY:e.clientX)-this.dragStart,n=this.track.getBoundingClientRect(),r=this.orientation===`vertical`?n.height:n.width,i=this.computeThumbSize(r),a=Math.max(r-i,1);this.emitScroll(this.valueStart+t/a*this.maxValue)},this.onPointerUp=()=>{this.dragging=!1,document.removeEventListener(`pointermove`,this.onPointerMove),document.removeEventListener(`pointerup`,this.onPointerUp)}}static get observedAttributes(){return[`orientation`,`viewport-size`,`content-size`,`value`,`step`]}connectedCallback(){if(this.shadowRoot)return;let e=this.attachShadow({mode:`open`}),t=document.createElement(`style`);t.textContent=r,this.startArrow=this.createArrow(`start`),this.endArrow=this.createArrow(`end`),this.track=document.createElement(`div`),this.track.className=`track`,this.thumb=document.createElement(`div`),this.thumb.className=`thumb`,this.track.appendChild(this.thumb),e.append(t,this.startArrow,this.track,this.endArrow),this.thumb.addEventListener(`pointerdown`,this.onThumbPointerDown),this.track.addEventListener(`pointerdown`,this.onTrackPointerDown),this.startArrow.addEventListener(`pointerdown`,this.onArrowStartPointerDown),this.endArrow.addEventListener(`pointerdown`,this.onArrowEndPointerDown);for(let e of[this.startArrow,this.endArrow])e.addEventListener(`pointerup`,this.stopHold),e.addEventListener(`pointerleave`,this.stopHold),e.addEventListener(`pointercancel`,this.stopHold);this.resizeObserver=new ResizeObserver(()=>{this.resizeFrame||=requestAnimationFrame(()=>{this.resizeFrame=0,this.render()})}),this.resizeObserver.observe(this),this.render()}disconnectedCallback(){this.stopHold(),this.resizeFrame&&cancelAnimationFrame(this.resizeFrame),this.resizeFrame=0,this.resizeObserver?.disconnect(),this.resizeObserver=null,document.removeEventListener(`pointermove`,this.onPointerMove),document.removeEventListener(`pointerup`,this.onPointerUp)}attributeChangedCallback(){this.render()}get orientation(){return this.getAttribute(`orientation`)===`horizontal`?`horizontal`:`vertical`}get viewportSize(){return Number(this.getAttribute(`viewport-size`)||`0`)}get contentSize(){return Number(this.getAttribute(`content-size`)||`0`)}get value(){return Number(this.getAttribute(`value`)||`0`)}get step(){let e=Number(this.getAttribute(`step`)||`40`);return e>0?e:40}get maxValue(){return Math.max(this.contentSize-this.viewportSize,0)}getTrackLength(){let e=this.track.getBoundingClientRect(),t=this.orientation===`vertical`?e.height:e.width;return t>0?t:Math.max(this.viewportSize-32,1)}computeThumbSize(e){if(this.contentSize<=0||this.viewportSize<=0||e<=0)return 0;let t=Math.min(this.viewportSize/this.contentSize,1);return Math.max(20,t*e)}createArrow(e){let t=document.createElement(`button`);return t.type=`button`,t.className=`arrow arrow-${e}`,t.setAttribute(`aria-label`,e===`start`?`Scroll back`:`Scroll forward`),t.appendChild(n()),t}startHold(e){this.stopHold();let t=()=>this.emitScroll(this.value+e*this.step);t(),this.holdTimer=setTimeout(()=>{this.holdTimer=setInterval(t,50)},280)}emitScroll(e){let t=Math.min(Math.max(e,0),this.maxValue);this.dispatchEvent(new CustomEvent(`scroll-change`,{detail:{value:t},bubbles:!0,composed:!0}))}render(){if(!this.shadowRoot)return;let e=this.viewportSize,t=this.contentSize<=e||e<=0;this.style.opacity=t?`0`:`1`,this.style.pointerEvents=t?`none`:`auto`;let n=this.getTrackLength(),r=this.computeThumbSize(n),i=this.maxValue,a=(i>0?this.value/i:0)*Math.max(n-r,0);this.orientation===`vertical`?(this.thumb.style.height=`${r}px`,this.thumb.style.transform=`translateY(${a}px)`):(this.thumb.style.width=`${r}px`,this.thumb.style.transform=`translateX(${a}px)`),this.startArrow.disabled=t||this.value<=0,this.endArrow.disabled=t||this.value>=i}};typeof window<`u`&&!customElements.get(`sv-grid-scrollbar`)&&customElements.define(`sv-grid-scrollbar`,a);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./server-block-cache-CXJKkJpy.js";var t=10,n=1e3,r=`https://svgrid.com/docs/getting-started/3-data-and-columns/`;function i(e,t=[]){for(let n of e)n.columns?.length?i(n.columns,t):t.push(n);return t}function a(a){let s=[],c=i(a.columns??[]),l=[],u=a.data??[],d=Math.min(u.length,n);for(let n=0;n<d&&l.length<t;n+=1){let t=u[n];e(t)||l.push(t)}if(l.length&&!a.serverGroup){let e=new Set;for(let t of l)if(t&&typeof t==`object`)for(let n of Object.keys(t))e.add(n);for(let t of c){let n=t.field;if(!n||t.fieldFn||t.fieldType||e.has(n))continue;let i=o(n,[...e]);s.push(`[svgrid] Column field "${n}" does not exist on your row data, so that column renders empty.${i?` Did you mean "${i}"?`:``} Available keys: ${[...e].slice(0,12).join(`, `)}. See ${r}`)}}let f=new Map;for(let e of c){let t=e.id??e.field;t&&f.set(t,(f.get(t)??0)+1)}for(let[e,t]of f)t>1&&s.push(`[svgrid] ${t} columns share the id "${e}". Column state (sorting, filtering, pinning, width) is keyed by id, so they will act as one. Give each an explicit \`id\`. See ${r}`);let p=a.pageable===void 0&&a.showPagination===void 0;a.pageSize!==void 0&&p&&s.push("[svgrid] `pageSize` is set but pagination was never turned on, so it has no effect and every row renders. Add `pageable` to switch the pager on."),!(a.sortable===!0||a.features?.rowSortingFeature)&&c.some(e=>e.sortable===!0)&&s.push("[svgrid] A column sets `sortable: true`, but sorting is not enabled on the grid, so its header does nothing. Add `sortable` to <SvGrid> (it registers the sorting feature for you).");let m=new Set;for(let e of c){let t=e.id??e.field;t&&m.add(t)}for(let e of a.groupBy??[]){if(m.has(e))continue;let t=o(e,[...m]);s.push(`[svgrid] \`groupBy\` refers to column "${e}", which does not exist, so that grouping level is ignored.${t?` Did you mean "${t}"?`:``} Column ids: ${[...m].slice(0,12).join(`, `)}`)}let h=a.treeData?.column;if(h&&!m.has(h)&&s.push(`[svgrid] \`treeData.column\` refers to column "${h}", which does not exist, so the expander falls back to the first visible column.`),l.length&&a.treeData){let e=new Set;for(let t of l)if(t&&typeof t==`object`)for(let n of Object.keys(t))e.add(n);let t=a.treeData.parentField;if(t&&!e.has(t)){let n=o(t,[...e]);s.push(`[svgrid] \`treeData.parentField\` is "${t}", which is not on your row data, so every row becomes a root and no hierarchy appears.${n?` Did you mean "${n}"?`:``}`)}let n=a.treeData.idField;n&&!e.has(n)&&s.push(`[svgrid] \`treeData.idField\` is "${n}", which is not on your row data, so parent lookups cannot match and the tree stays flat.`)}return a.gantt&&a.treeData&&s.push("[svgrid] `gantt` and `treeData` are both set. The Gantt builds its own work-breakdown tree from `gantt.parentField` and needs every descendant row, but `treeData` hides collapsed children from the view, so summary bars will under-report. Remove `treeData` and set `gantt.parentField` instead."),a.externalPagination===!0&&a.rowCount===void 0&&s.push("[svgrid] `externalPagination` is on but `rowCount` is not set, so the pager cannot know how many pages exist. Pass the server total as `rowCount`."),a.externalSort===!0&&!a.onSortingChange&&s.push("[svgrid] `externalSort` is on but there is no `onSortingChange` handler, so clicking a header changes nothing - the grid stopped sorting and nobody is listening. Add `onSortingChange` and re-fetch in your handler."),a.externalFilter===!0&&!a.onFiltersChange&&s.push("[svgrid] `externalFilter` is on but there is no `onFiltersChange` handler, so filtering the grid changes nothing. Add `onFiltersChange` and re-fetch in your handler."),s}function o(e,t){let n,r=1/0;for(let i of t){let t=s(e.toLowerCase(),i.toLowerCase());t<r&&(r=t,n=i)}let i=Math.min(3,Math.floor(e.length/3)+1);return r<=i?n:void 0}function s(e,t){if(e===t)return 0;let n=Array(t.length+1);for(let e=0;e<=t.length;e++)n[e]=e;for(let r=1;r<=e.length;r++){let i=n[0];n[0]=r;for(let a=1;a<=t.length;a++){let o=Math.min(n[a]+1,n[a-1]+1,i+(e[r-1]===t[a-1]?0:1));i=n[a],n[a]=o}}return n[t.length]}export{a as validateGridConfig};
|
package/dist/designer/index.html
CHANGED
|
@@ -4,19 +4,19 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>SvGrid Studio - Designer</title>
|
|
7
|
-
<script type="module" crossorigin src="./assets/index-
|
|
7
|
+
<script type="module" crossorigin src="./assets/index-BPU2KNc5.js"></script>
|
|
8
8
|
<link rel="modulepreload" crossorigin href="./assets/rolldown-runtime-Dd_uD5pT.js">
|
|
9
9
|
<link rel="modulepreload" crossorigin href="./assets/disclose-version-CIm4S9xS.js">
|
|
10
10
|
<link rel="modulepreload" crossorigin href="./assets/cell-formatting-BWrW_O0n.js">
|
|
11
|
-
<link rel="modulepreload" crossorigin href="./assets/
|
|
12
|
-
<link rel="modulepreload" crossorigin href="./assets/
|
|
13
|
-
<link rel="modulepreload" crossorigin href="./assets/src-DqHCqori.js">
|
|
11
|
+
<link rel="modulepreload" crossorigin href="./assets/SvGrid.helpers-CIrmIo9U.js">
|
|
12
|
+
<link rel="modulepreload" crossorigin href="./assets/sv-grid-scrollbar-B9N6Wuj0.js">
|
|
14
13
|
<link rel="modulepreload" crossorigin href="./assets/editor-contract-Bpoa7A5g.js">
|
|
15
14
|
<link rel="modulepreload" crossorigin href="./assets/date-format-B8JbEtIG.js">
|
|
16
15
|
<link rel="modulepreload" crossorigin href="./assets/list-option-BP_dWS66.js">
|
|
17
|
-
<link rel="modulepreload" crossorigin href="./assets/SvListBox-
|
|
18
|
-
<link rel="modulepreload" crossorigin href="./assets/
|
|
16
|
+
<link rel="modulepreload" crossorigin href="./assets/SvListBox-CS7oUAiX.js">
|
|
17
|
+
<link rel="modulepreload" crossorigin href="./assets/grid-extension.svelte-BZ7AqyJI.js">
|
|
19
18
|
<link rel="modulepreload" crossorigin href="./assets/editor-registry-BjP16H0v.js">
|
|
19
|
+
<link rel="modulepreload" crossorigin href="./assets/preload-helper-HclGiUj8.js">
|
|
20
20
|
<link rel="modulepreload" crossorigin href="./assets/popover-CUkLsvRX.js">
|
|
21
21
|
<link rel="modulepreload" crossorigin href="./assets/SvGridDropdown-Cjz0H-fI.js">
|
|
22
22
|
<link rel="modulepreload" crossorigin href="./assets/dismissable-ChWRPkoa.js">
|
|
@@ -31,7 +31,11 @@
|
|
|
31
31
|
<link rel="modulepreload" crossorigin href="./assets/SvGridChart-Fg43Yi0M.js">
|
|
32
32
|
<link rel="modulepreload" crossorigin href="./assets/chart-panel-messages-4cF2vw7L.js">
|
|
33
33
|
<link rel="modulepreload" crossorigin href="./assets/SvGridChartPanel-BsiXRAnx.js">
|
|
34
|
+
<link rel="modulepreload" crossorigin href="./assets/sparkline-C-NcnB2i.js">
|
|
34
35
|
<link rel="modulepreload" crossorigin href="./assets/server-block-cache-CXJKkJpy.js">
|
|
36
|
+
<link rel="modulepreload" crossorigin href="./assets/conditional-formatting-MDWbF8_Y.js">
|
|
37
|
+
<link rel="modulepreload" crossorigin href="./assets/export-format-DGscOjS9.js">
|
|
38
|
+
<link rel="modulepreload" crossorigin href="./assets/src-C_U1NKOY.js">
|
|
35
39
|
<link rel="stylesheet" crossorigin href="./assets/date-format-DKS-z0xS.css">
|
|
36
40
|
<link rel="stylesheet" crossorigin href="./assets/SvListBox-BXfyqy4a.css">
|
|
37
41
|
<link rel="stylesheet" crossorigin href="./assets/SvGridDropdown-CcidB3rm.css">
|
|
@@ -41,7 +45,7 @@
|
|
|
41
45
|
<link rel="stylesheet" crossorigin href="./assets/SvMenuList-DJ47ba1h.css">
|
|
42
46
|
<link rel="stylesheet" crossorigin href="./assets/SvGridChart-BgLuPO7I.css">
|
|
43
47
|
<link rel="stylesheet" crossorigin href="./assets/SvGridChartPanel-4Pc8y5yO.css">
|
|
44
|
-
<link rel="stylesheet" crossorigin href="./assets/index-
|
|
48
|
+
<link rel="stylesheet" crossorigin href="./assets/index-BmvG99kR.css">
|
|
45
49
|
</head>
|
|
46
50
|
<body>
|
|
47
51
|
<div id="app"></div>
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
* constants.
|
|
22
22
|
*/
|
|
23
23
|
import { compileExcelFilter } from '@svgrid/grid/filtering';
|
|
24
|
+
import { getPredicateKind } from './kinds.js';
|
|
24
25
|
const num = (v) => typeof v === 'number' ? v : v == null || v === '' ? NaN : Number(v);
|
|
25
26
|
const BUILTINS = {
|
|
26
27
|
ABS: (a) => Math.abs(num(a[0])),
|
|
@@ -247,6 +248,15 @@ function compileInternal(expr, opts, aggs) {
|
|
|
247
248
|
const inner = compileInternal(expr.expr, opts, aggs);
|
|
248
249
|
return (row) => !inner(row);
|
|
249
250
|
}
|
|
251
|
+
case 'ext': {
|
|
252
|
+
// Another module's condition, compiled once by that module. A type no
|
|
253
|
+
// module registered matches nothing, like an unknown node kind below.
|
|
254
|
+
const kind = getPredicateKind(expr.type);
|
|
255
|
+
if (!kind)
|
|
256
|
+
return () => false;
|
|
257
|
+
const test = kind.compile(expr.payload, { getValue: opts.getValue, locale: opts.locale });
|
|
258
|
+
return test ?? (() => true);
|
|
259
|
+
}
|
|
250
260
|
case 'cmp': {
|
|
251
261
|
// The needle-side work happens once, here.
|
|
252
262
|
const test = compileExcelFilter({
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* exactly; scalar maths and change detection are handled here.
|
|
5
5
|
*/
|
|
6
6
|
import { applyExcelFilter } from '@svgrid/grid/filtering';
|
|
7
|
+
import { getPredicateKind } from './kinds.js';
|
|
7
8
|
function readValue(ctx, row, columnId) {
|
|
8
9
|
if (ctx.getValue)
|
|
9
10
|
return ctx.getValue(row, columnId);
|
|
@@ -170,8 +171,25 @@ export function evaluatePredicate(expr, ctx) {
|
|
|
170
171
|
return applyExcelFilter(readValue(ctx, ctx.row, expr.column), { id: expr.column, operator: expr.op, value: expr.value, valueTo: expr.valueTo }, { locale: ctx.locale });
|
|
171
172
|
case 'scalarCmp':
|
|
172
173
|
return compareScalar(evaluateScalar(expr.left, ctx), expr.op, evaluateScalar(expr.right, ctx));
|
|
174
|
+
case 'ext':
|
|
175
|
+
return extTest(expr, ctx)(ctx.row);
|
|
173
176
|
}
|
|
174
177
|
}
|
|
178
|
+
// An `ext` node compiled once per node and value reader: the walk above runs
|
|
179
|
+
// per row, the module's compile should not.
|
|
180
|
+
const extCache = new WeakMap();
|
|
181
|
+
function extTest(expr, ctx) {
|
|
182
|
+
const hit = extCache.get(expr);
|
|
183
|
+
if (hit && hit.getValue === ctx.getValue)
|
|
184
|
+
return hit.test;
|
|
185
|
+
const kind = getPredicateKind(expr.type);
|
|
186
|
+
const getValue = ctx.getValue ?? ((row, id) => row?.[id]);
|
|
187
|
+
const compiled = kind ? kind.compile(expr.payload, { getValue, locale: ctx.locale }) : null;
|
|
188
|
+
// Unknown kind: matches nothing. An empty condition: matches everything.
|
|
189
|
+
const test = !kind ? () => false : (compiled ?? (() => true));
|
|
190
|
+
extCache.set(expr, { getValue: ctx.getValue, test: test });
|
|
191
|
+
return test;
|
|
192
|
+
}
|
|
175
193
|
/**
|
|
176
194
|
* Evaluate a change expression - true when the value moved between `ctx.prev`
|
|
177
195
|
* and `ctx.row` in the way the expression describes. Returns false when there
|
|
@@ -77,6 +77,16 @@ export type PredicateExpr = {
|
|
|
77
77
|
} | {
|
|
78
78
|
kind: 'const';
|
|
79
79
|
value: boolean;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* A condition another module evaluates (`registerPredicateKind`): SvGrid
|
|
83
|
+
* Base's field conditions are `{ kind: 'ext', type: 'fieldFilter', payload }`.
|
|
84
|
+
* An unregistered type compiles to nothing, so a rule never fires on it.
|
|
85
|
+
*/
|
|
86
|
+
| {
|
|
87
|
+
kind: 'ext';
|
|
88
|
+
type: string;
|
|
89
|
+
payload: unknown;
|
|
80
90
|
};
|
|
81
91
|
/**
|
|
82
92
|
* A change (observable) expression - true when a value moves between the
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Condition kinds from other modules: the `ext` node of a predicate.
|
|
3
|
+
*
|
|
4
|
+
* The expression language compares cell values with the grid filter's
|
|
5
|
+
* operators. A module whose fields mean more than their raw values (SvGrid
|
|
6
|
+
* Base: a select's option, a person, a linked record shown by name, "within
|
|
7
|
+
* the past week") registers its own condition kind here, and an `ext` node
|
|
8
|
+
* names it: `{ kind: 'ext', type: 'fieldFilter', payload }`. Alerts, the
|
|
9
|
+
* advanced filter and anything else that compiles predicates then evaluate
|
|
10
|
+
* it with that module's own semantics, with no second language for users.
|
|
11
|
+
*/
|
|
12
|
+
/** What a registered kind needs to evaluate its payload. */
|
|
13
|
+
export type PredicateKindContext<TRow> = {
|
|
14
|
+
/** A row's value for a column (computed fields included). */
|
|
15
|
+
getValue: (row: TRow, columnId: string) => unknown;
|
|
16
|
+
locale?: string | ReadonlyArray<string>;
|
|
17
|
+
};
|
|
18
|
+
export type PredicateKind = {
|
|
19
|
+
/** The payload as a row test, or null when it cannot test anything (an empty condition). */
|
|
20
|
+
compile: <TRow>(payload: unknown, ctx: PredicateKindContext<TRow>) => ((row: TRow) => boolean) | null;
|
|
21
|
+
/** Short words for the condition, where it is shown as text ("Status is Done"). */
|
|
22
|
+
describe?: (payload: unknown, columnName: (columnId: string) => string) => string;
|
|
23
|
+
/** The columns the payload reads: alerts pick the column a message names from these. */
|
|
24
|
+
columns?: (payload: unknown) => string[];
|
|
25
|
+
};
|
|
26
|
+
/** Teach the expression language a condition kind (one per type; a second call replaces it). */
|
|
27
|
+
export declare function registerPredicateKind(type: string, kind: PredicateKind): void;
|
|
28
|
+
export declare function getPredicateKind(type: string): PredicateKind | undefined;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Condition kinds from other modules: the `ext` node of a predicate.
|
|
3
|
+
*
|
|
4
|
+
* The expression language compares cell values with the grid filter's
|
|
5
|
+
* operators. A module whose fields mean more than their raw values (SvGrid
|
|
6
|
+
* Base: a select's option, a person, a linked record shown by name, "within
|
|
7
|
+
* the past week") registers its own condition kind here, and an `ext` node
|
|
8
|
+
* names it: `{ kind: 'ext', type: 'fieldFilter', payload }`. Alerts, the
|
|
9
|
+
* advanced filter and anything else that compiles predicates then evaluate
|
|
10
|
+
* it with that module's own semantics, with no second language for users.
|
|
11
|
+
*/
|
|
12
|
+
const kinds = new Map();
|
|
13
|
+
/** Teach the expression language a condition kind (one per type; a second call replaces it). */
|
|
14
|
+
export function registerPredicateKind(type, kind) {
|
|
15
|
+
kinds.set(type, kind);
|
|
16
|
+
}
|
|
17
|
+
export function getPredicateKind(type) {
|
|
18
|
+
return kinds.get(type);
|
|
19
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { columnRefText, resolveColumnRef, } from './expression-columns.js';
|
|
1
|
+
import { columnLabel, columnRefText, resolveColumnRef, } from './expression-columns.js';
|
|
2
2
|
import { isBuiltinFunction } from './evaluate.js';
|
|
3
|
+
import { getPredicateKind } from './kinds.js';
|
|
3
4
|
const KEYWORDS = new Set([
|
|
4
5
|
'AND', 'OR', 'NOT', 'TRUE', 'FALSE', 'NULL',
|
|
5
6
|
'CONTAINS', 'STARTSWITH', 'ENDSWITH', 'MATCHES',
|
|
@@ -418,6 +419,9 @@ export function stringifyPredicate(expr, columns = []) {
|
|
|
418
419
|
return expr.parts.map((p) => wrapPred(p, columns)).join(' OR ');
|
|
419
420
|
case 'scalarCmp':
|
|
420
421
|
return `${stringifyScalar(expr.left, columns)} ${expr.op} ${stringifyScalar(expr.right, columns)}`;
|
|
422
|
+
// Another module's condition reads as its own words; it is edited there, not as text.
|
|
423
|
+
case 'ext':
|
|
424
|
+
return getPredicateKind(expr.type)?.describe?.(expr.payload, (id) => columnLabel(columns, id)) ?? `[${expr.type}]`;
|
|
421
425
|
case 'cmp': {
|
|
422
426
|
const col = columnRefText(columns, expr.column);
|
|
423
427
|
if (expr.op === 'isBlank')
|
|
@@ -468,6 +472,10 @@ function walkPredicate(expr, out) {
|
|
|
468
472
|
walkScalar(expr.left, out);
|
|
469
473
|
walkScalar(expr.right, out);
|
|
470
474
|
return;
|
|
475
|
+
case 'ext':
|
|
476
|
+
for (const c of getPredicateKind(expr.type)?.columns?.(expr.payload) ?? [])
|
|
477
|
+
out.add(c);
|
|
478
|
+
return;
|
|
471
479
|
case 'const':
|
|
472
480
|
return;
|
|
473
481
|
}
|