@8sheets/data-grid 1.0.2 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. package/README.md +1 -1
  2. package/api/serialize.js +1 -1
  3. package/api/theme-core.js +2 -0
  4. package/calc/adjust.js +1 -1
  5. package/calc/compile.js +1 -1
  6. package/calc/engine.js +1 -1
  7. package/calc/functions/array.js +1 -1
  8. package/calc/functions/database.js +1 -1
  9. package/calc/functions/date.js +1 -1
  10. package/calc/functions/financial.js +1 -1
  11. package/calc/functions/helpers.js +1 -1
  12. package/calc/functions/info.js +1 -1
  13. package/calc/functions/logical.js +1 -1
  14. package/calc/functions/lookup.js +1 -1
  15. package/calc/functions/math.js +1 -1
  16. package/calc/functions/stat.js +1 -1
  17. package/calc/functions/text.js +1 -1
  18. package/calc/parser.js +3 -3
  19. package/calc/values.js +1 -1
  20. package/calcx/async.js +1 -1
  21. package/calcx/culture/custom.js +1 -0
  22. package/calcx/culture/format-locale.js +1 -1
  23. package/calcx/culture/separators.js +1 -0
  24. package/calcx/functions/dynamic.js +1 -1
  25. package/calcx/functions/ets.js +1 -1
  26. package/calcx/functions/misc.js +1 -1
  27. package/calcx/lang/convert.js +1 -0
  28. package/cells/axis-ops.js +1 -1
  29. package/cells/block.js +1 -0
  30. package/cells/book-css.js +2 -2
  31. package/cells/cell-defaults.js +1 -1
  32. package/cells/cf-engine.js +1 -1
  33. package/cells/consolidate-links.js +1 -1
  34. package/cells/find-engine.js +2 -2
  35. package/cells/format-panes.js +3 -3
  36. package/cells/format-tabs.js +2 -2
  37. package/cells/outline-column.js +1 -1
  38. package/cells/panes.js +1 -1
  39. package/cells/rich-runs.js +2 -2
  40. package/cells/rich-values.js +1 -1
  41. package/cells/selection-modes.js +1 -1
  42. package/cells/shift-check.js +1 -0
  43. package/cells/table-rows.js +1 -0
  44. package/cells/text-layout.js +9 -8
  45. package/cells/ui-kit.js +15 -0
  46. package/cells/view-options.js +1 -1
  47. package/celltypes/cell-types.js +2 -2
  48. package/celltypes/diagonal.js +1 -1
  49. package/celltypes/dropdowns.js +3 -2
  50. package/celltypes/file-cell.js +2 -2
  51. package/celltypes/range-template.js +2 -2
  52. package/core/autofill.js +1 -1
  53. package/core/axis-styles.js +1 -0
  54. package/core/axis.js +1 -1
  55. package/core/cell-type-rules.js +1 -0
  56. package/core/changes.js +1 -1
  57. package/core/cond-format.js +1 -1
  58. package/core/culture.js +1 -0
  59. package/core/formula-refs.js +1 -1
  60. package/core/input.js +1 -1
  61. package/core/merge.js +1 -0
  62. package/core/numfmt.js +1 -1
  63. package/core/region-input.js +1 -0
  64. package/core/row-fit.js +1 -0
  65. package/core/sheet.js +1 -1
  66. package/core/sparse.js +1 -1
  67. package/core/structure.js +1 -0
  68. package/core/styles.js +1 -1
  69. package/core/tables.js +2 -2
  70. package/core/validation-ranges.js +1 -0
  71. package/core/whatif.js +1 -1
  72. package/core/workbook.js +1 -1
  73. package/datasheets/data-core.js +1 -1
  74. package/datasheets/gantt-paint.js +1 -1
  75. package/datasheets/manager.js +1 -1
  76. package/datasheets/path-binding.js +2 -2
  77. package/datasheets/rules.js +1 -1
  78. package/datasheets/view.js +2 -2
  79. package/i18n/dom.js +1 -1
  80. package/i18n/en/cells.js +1 -1
  81. package/i18n/en/format.js +1 -1
  82. package/i18n/en/misc.js +1 -1
  83. package/i18n/en/shell.js +2 -2
  84. package/i18n/pl/cells.js +1 -1
  85. package/i18n/pl/format.js +1 -1
  86. package/i18n/pl/misc.js +1 -1
  87. package/i18n/pl/shell.js +2 -2
  88. package/io/client.js +1 -1
  89. package/io/csv.js +8 -8
  90. package/io/plan.js +1 -1
  91. package/io/text-split.js +3 -3
  92. package/io/xlsx-read.js +1 -1
  93. package/io/xlsx-write.js +1 -1
  94. package/io/xml-scan.js +2 -1
  95. package/io/zip-reader.js +1 -1
  96. package/objects/chart-model.js +1 -1
  97. package/package.json +1 -1
  98. package/pivot/engine.js +1 -1
  99. package/pivot/xml.js +2 -2
  100. package/print/paginate.js +1 -1
  101. package/print/render-page.js +3 -3
  102. package/slicers/format.js +2 -2
  103. package/slicers/structured.js +1 -1
  104. package/table-view/api.js +1 -1
  105. package/table-view/cell-editor.js +2 -1
  106. package/table-view/chart.js +1 -0
  107. package/table-view/column-drag.js +1 -1
  108. package/table-view/context-menu.js +1 -0
  109. package/table-view/editors.js +1 -0
  110. package/table-view/events.js +1 -1
  111. package/table-view/files.js +1 -1
  112. package/table-view/fill-handle.js +1 -0
  113. package/table-view/filter-builder.js +1 -0
  114. package/table-view/find.js +1 -0
  115. package/table-view/grid-keys.js +2 -2
  116. package/table-view/labels-de.js +1 -0
  117. package/table-view/labels-es.js +1 -0
  118. package/table-view/labels-fr.js +1 -0
  119. package/table-view/labels-ja.js +1 -0
  120. package/table-view/labels.js +1 -1
  121. package/table-view/model.js +1 -1
  122. package/table-view/mount.js +1 -1
  123. package/table-view/panel.js +1 -1
  124. package/table-view/pivot-spec.js +1 -0
  125. package/table-view/pivot.js +1 -1
  126. package/table-view/public.d.ts +277 -28
  127. package/table-view/reader.worker.js +1 -1
  128. package/table-view/remote.js +1 -1
  129. package/table-view/row-drag.js +1 -0
  130. package/table-view/sparkline.js +1 -0
  131. package/table-view/state-check.js +1 -0
  132. package/table-view/table-css.js +380 -0
  133. package/table-view/version.js +1 -1
  134. package/ui/dialogs.js +3 -3
  135. package/ui/menu-base.js +1 -1
  136. package/ui/protection-ui.js +1 -1
package/table-view/api.js CHANGED
@@ -1 +1 @@
1
- import{colIndex as D,rangeRef as O}from"../core/address.js";import{parseTsv as I}from"../core/tsv.js";import{canEdit as S}from"./cell-editor.js";import{defaultState as R,displayOrder as L,groupPath as j,sortWith as F,toggleCollapsed as N}from"./events.js";import{parseQuickFilter as $}from"./quick-filter.js";const T=["sum","average","min","max","count","distinct"],C=["sum","average","min","max","count"],k=["sum","average","min","max","count"],V=new Set(["hidden","pinned","width","format","total","rules"]),A={data:"setData()",fields:"setData() or setDataSource()",file:"openFile()",dataSource:"setDataSource()",editable:"enableEditing()",transferColumns:"setData()"},P=new Set(["chrome","language","title","scrolling","rowSelection","renderers","detailRenderer","allowEdit","sharing","storageKey"]),p=100,w=l=>typeof l=="string"||typeof l=="number"&&Number.isFinite(l),h=l=>l!==null&&typeof l=="object"&&!Array.isArray(l);class z{#s;constructor(e){this.#s=e}#t(){if(this.#s.closed)throw new Error("The grid was destroyed.");return this.#s}#e(){const e=this.#t();if(!e.result||!e.fields)throw new Error("No table loaded.");return e}#r(e){const r=this.#e().fields.find(s=>s.name===e);if(!r)throw new Error(`Unknown field "${e}".`);return r}#o(){const e=this.#e();return L(e.state,e.fields.map(t=>t.name))}async#l(e){const t=this.#e();if(!w(e))throw new TypeError("A record ID is a number or a string.");if(!t.remote)return t.client.call("rowOf",{id:e});for(const[r,s]of t.rows?.blocks??[]){const o=s.findIndex(a=>a.id===e);if(o>=0)return r*t.rows.blockSize+o}throw new Error("This record is not loaded. A remote source scrolls to loaded records only; use scrollToRow().")}#c(e){const t=this.#s,r=t.rows?.meta?.columns??[];for(const s of t.rows?.blocks?.values()??[]){const o=s.find(a=>a.id===e&&a.group===void 0);if(o)return m(o,r)}return null}#a(e){if(!h(e)||typeof e.op!="string")throw new TypeError("A filter is { field, op, value?, value2?, values? }.");if(this.#r(e.field),(e.op==="in"||e.op==="notIn")&&!Array.isArray(e.values))throw new TypeError(`An "${e.op}" filter lists its values.`);return structuredClone(e)}#n(e,t,r=()=>{}){if(!Array.isArray(e))throw new TypeError(`${t} is a list.`);return e.map(s=>{if(!h(s))throw new TypeError(`Each item of ${t} is an object with a field.`);return this.#r(s.field),r(s),structuredClone(s)})}on(e,t){return this.#t().events.on(e,t)}off(e,t){this.#s.events.off(e,t)}destroy(){this.#s.destroy()}async openFile(e,{delimiter:t,textColumns:r,chooseSource:s=!0}={}){const o=this.#t();if(!(e instanceof Blob))throw new TypeError("openFile takes a File.");const a={};t&&(a.delimiter=t),r&&(a.textColumns=r.map(n=>typeof n=="number"?n:D(String(n).toUpperCase()))),await o.openFile(e,a,s)}async setData(e,{fields:t,title:r,editable:s,storageKey:o}={}){const a=this.#t();if(e==null||typeof e!="object")throw new TypeError("setData takes records: objects, arrays or columns.");for(const[n,i]of Object.entries({fields:t,title:r,editable:s,storageKey:o}))i!==void 0&&(a.options[n]=i);delete a.options.dataSource,await a.openData(e)}async setDataSource(e,{fields:t,title:r,editable:s,storageKey:o}={}){const a=this.#t();if(typeof e?.query!="function")throw new TypeError("A data source has a query method.");for(const[n,i]of Object.entries({fields:t,title:r,editable:s,storageKey:o}))i!==void 0&&(a.options[n]=i);if(!a.options.fields?.length)throw new Error("A remote source needs fields.");a.options.dataSource=e,await a.openRemote()}getSources(){return(this.#t().sources??[]).map((e,t)=>({index:t,name:e.name,range:O(e.range),whole:!!e.whole,header:e.headerRows!==0}))}async setSource(e,{range:t,header:r=!0}={}){const s=this.#t();if(!s.sources?.length)throw new Error("Sources belong to an open file.");await s.applySource(e,t,r)}getSource(){const e=this.#t(),t=e.sourceKind(),r={kind:t,title:t==="none"?"":e.title.textContent,editable:!!e.editable,dirty:!!e.dirty};return e.file&&(r.fileName=e.file.name),t==="file"&&Object.assign(r,{index:e.sourceIndex,range:e.sourceRange,header:e.sourceHeader}),r}async refresh({purge:e=!1}={}){const t=this.#e();t.rows&&(e?t.rows.reset():t.rows.invalidate()),await t.refresh()}getState(){return this.#e().getState()}async setState(e){const t=this.#e();if(!h(e))throw new TypeError("setState takes a state object; getState() returns one.");await t.setState({...R(t.fields),...structuredClone(e)})}async updateState(e){const t=this.#e();if(!h(e))throw new TypeError("updateState takes some keys of a state.");await t.update(structuredClone(e))}async resetState(){const e=this.#e();e.quickText?.clear(),await e.setState(R(e.fields))}async setSearch(e){const t=this.#e();clearTimeout(t.searchTimer),await t.update({search:String(e??"")})}async setFilters(e){const t=this.#e();if(!Array.isArray(e))throw new TypeError("setFilters takes a list of filters.");const r=e.map(s=>this.#a(s));t.quickText?.clear(),await t.update({filters:r,collapsed:[]})}async addFilter(e){const t=this.#e();await t.update({filters:[...t.state.filters,this.#a(e)],collapsed:[]})}async clearFilters(e){const t=this.#e();e!=null&&this.#r(e),e==null?t.quickText?.clear():t.quickText?.delete(e),await t.update({filters:e==null?[]:t.state.filters.filter(r=>r.field!==e),collapsed:[]})}async setQuickFilter(e,t){const r=this.#e(),s=this.#r(e),o=$(e,t,s.type),a=r.state.filters.filter(n=>!(n.quick&&n.field===e));o&&a.push(o),r.quickText?.delete(e),await r.update({filters:a,collapsed:[]})}async getDistinctValues(e,{limit:t=500}={}){const r=this.#e();if(this.#r(e),r.remote)throw new Error("A remote source lists its values itself.");if(!Number.isInteger(t)||t<1)throw new RangeError("limit is a positive whole number.");const{values:s}=await r.client.call("distinct",{field:e});return s.slice(0,t).map(({value:o,text:a,count:n})=>({value:o,text:a,count:n}))}async setSort(e){await this.#e().update({sort:this.#n(e,"sort").map(({field:r,desc:s})=>({field:r,desc:s===!0}))})}async sortBy(e,{desc:t=!1,add:r=!1}={}){const s=this.#e();this.#r(e),await s.update({sort:F(s.state.sort,e,t,r)})}async clearSort(e){const t=this.#e();e!=null&&this.#r(e),await t.update({sort:e==null?[]:t.state.sort.filter(r=>r.field!==e)})}async setGroups(e){const t=this.#e(),r=this.#n(e,"groups").map(({field:s,desc:o})=>o===!0?{field:s,desc:o}:{field:s});await t.update({groups:r,collapsed:[]})}async groupBy(e,{desc:t}={}){const r=this.#e();this.#r(e);const s=t===!0?{field:e,desc:t}:{field:e};await r.update({groups:[...r.state.groups.filter(o=>o.field!==e),s],collapsed:[]})}async clearGroups(e){const t=this.#e();e!=null&&this.#r(e),await t.update({groups:e==null?[]:t.state.groups.filter(r=>r.field!==e),collapsed:[]})}async#i(e,t){const r=this.#e();if(!r.state.groups.length)throw new Error("The records are not grouped.");const s=j(e);await r.applyLayout({collapsed:N(r.state.collapsed,s,t,r.state.collapseLevel)})}expandGroup(e){return this.#i(e,!1)}collapseGroup(e){return this.#i(e,!0)}async expandAll(){await this.#e().applyLayout({collapsed:[],collapseLevel:void 0})}async collapseAll(){await this.#e().applyLayout({collapsed:[],collapseLevel:0})}async setSummary(e){const t=this.#e();if(e!=null&&(this.#r(e.field),!T.includes(e.agg)))throw new Error(`A summary is one of ${T.join(", ")}.`);await t.applyLayout({total:e?{field:e.field,agg:e.agg}:null})}async setTotalsRow(e){await this.#e().toggleTotals(e!==!1)}async setFilterRow(e){await this.#e().toggleFilterRow(e!==!1)}getFields(){return(this.#t().fields??[]).map(e=>({...e}))}getColumn(e){const t=this.#e().state.columns.find(r=>r.field===e);return t?structuredClone(t):null}async setColumns(e){const t=this.#e(),r=this.#n(e,"columns",s=>x(s));if(new Set(r.map(s=>s.field)).size!==r.length)throw new Error("Each field appears once in columns.");await t.applyLayout({columns:r})}async setColumn(e,t){const r=this.#e();if(this.#r(e),!h(t))throw new TypeError("setColumn takes some keys of a column: hidden, pinned, width, format, total, rules.");for(const n of Object.keys(t))if(!V.has(n))throw new Error(`Unknown column setting "${n}".`);x(t);const s=Object.keys(t),o=r.state.columns.some(n=>n.field===e),a=(o?r.state.columns:[...r.state.columns,{field:e}]).map(n=>{if(n.field!==e)return n;const i={...n,...structuredClone(t)};for(const u of s)t[u]==null&&u!=="total"&&delete i[u];return i});if(o&&s.length===1&&s[0]==="width")return r.setColumnWidth(e,t.width??void 0);await r.applyLayout({columns:a})}async moveColumn(e,t){const r=this.#e();this.#r(e),t!=null&&this.#r(t),await r.moveColumn(e,t??null)}async autosizeColumn(e){const t=this.#e();if(this.#r(e),!this.#o().includes(e))throw new Error(`Show column "${e}" first.`);return await t.showColumn(e,this.#o()),t.autosizeColumn(e)??null}async addCalculatedField(e,t){await this.#e().addCalculatedField(e,t,"api")}getSavedViews(){return[...this.#e().readViews()].map(([e,t])=>({name:e,state:t}))}saveView(e,t){const r=this.#e();if(e=String(e??"").trim(),!e)throw new Error("A saved view needs a name.");const s=r.readViews();s.set(e,t?structuredClone(t):r.getState()),r.writeViews(s)}async restoreView(e){const t=this.#e(),r=t.readViews().get(e);if(!r)throw new Error(`No saved view "${e}".`);await t.setState(r)}deleteView(e){const t=this.#e(),r=t.readViews(),s=r.delete(e);return s&&t.writeViews(r),s}async openPivot({rowField:e,columnField:t,valueField:r,agg:s="sum"}={}){const o=this.#e();if(this.#r(e),this.#r(r),t&&this.#r(t),!k.includes(s))throw new Error(`A pivot value is one of ${k.join(", ")}.`);await o.openPivot({rowField:e,columnField:t||"",valueField:r,agg:s})}async closePivot(){await this.#e().closePivot()}async getChartData(e){const t=this.#e();if(!t.base)throw new Error("Chart data belongs to a pivot. Call openPivot() first.");return this.#r(e),t.client.call("chart",{field:e})}getPage(){const e=this.#e(),t=e.result;return e.continuous?{mode:"continuous",index:0,count:1,size:null}:{mode:"pages",index:Math.floor(t.offset/e.limit),count:t.exact===!1?null:Math.max(1,Math.ceil(t.count/e.limit)),size:e.limit}}async setPage(e){const t=this.#e();if(t.continuous)throw new Error('Paging is off. Call setScrolling("pages") first, or scrollToRow().');if(!Number.isInteger(e)||e<0)throw new RangeError("A page index is a whole number from 0.");const r=t.result;if(r.exact!==!1&&e*t.limit>=Math.max(1,r.count))throw new RangeError(`Page ${e} is past the last page.`);t.offset=e*t.limit,t.content.scrollTop=0,await t.refresh(!1)}async setScrolling(e){await this.#t().setScrolling(e)}getViewport(){return this.#e().viewport()}async scrollToRow(e){const t=this.#e();if(!Number.isInteger(e)||e<0)throw new RangeError("A row index is a whole number from 0.");if(t.result.exact!==!1&&e>=t.result.count)throw new RangeError(`Row ${e} is past the last row.`);await t.showRow(e)}async scrollToRecord(e){const t=this.#e(),r=await this.#l(e);return r<0?!1:(await t.showRow(r),!0)}async scrollToColumn(e){const t=this.#e();this.#r(e);const r=this.#o();if(!r.includes(e))throw new Error(`Column "${e}" is hidden.`);await t.showColumn(e,r)}async focusCell(e,t){const r=this.#e();if(this.#r(t),!await this.scrollToRecord(e))return!1;await this.scrollToColumn(t);const s=r.grid?.positionOf(e,t);return s?(r.grid.focusAt(s.row,s.col),!0):!1}getFocusedCell(){return this.#t().grid?.focused()??null}getRange(){const e=this.#t(),{range:t,grid:r}=e;if(!t||!r||!e.result)return null;const s=r.positionOf(t.anchor.id,t.anchor.field),o=r.positionOf(t.focus.id,t.focus.field);if(!s||!o)return null;const[a,n]=[Math.min(s.row,o.row),Math.max(s.row,o.row)],[i,u]=[Math.min(s.col,o.col),Math.max(s.col,o.col)],d=r.records.slice(a,n+1);return{anchor:{...t.anchor},focus:{...t.focus},ids:d.map(c=>c.id),fields:e.result.columns.slice(i,u+1),values:d.map(c=>c.values.slice(i,u+1))}}async setRange({anchor:e,focus:t=e}={}){const r=this.#e();for(const n of[e,t]){if(!h(n)||!w(n.id))throw new TypeError("A range is { anchor: { id, field }, focus: { id, field } }.");this.#r(n.field)}const s=n=>{const i=r.grid?.positionOf(n.id,n.field);return i&&r.grid.cells[i.row][i.col]?i:null};if(!s(e)){if(!await this.scrollToRecord(e.id))throw new Error("The range starts at a record that is not in the view.");await this.scrollToColumn(e.field)}const o=s(e),a=r.grid?.positionOf(t.id,t.field);if(!o||!a)throw new Error("A range covers drawn records only. Choose records near each other, or scroll first.");r.grid.select(o,a,!1)}async copyRange(){const e=this.#e();if(!this.getRange())throw new Error("Select cells first.");const t=e.grid.copyText();return await navigator.clipboard.writeText(t),t}getSelection(){return this.#t().getSelection()}async setSelection(e){await this.#e().setSelection(e)}async selectRecords(e,t=!0){const r=this.#e();if(!r.selection)throw new Error("Row selection is off for this table.");if(!Array.isArray(e)||!e.every(w))throw new TypeError("selectRecords takes a list of record IDs.");for(const s of e)r.selection.toggle(s,t!==!1);await r.recountSelection(!0)}async selectAll(){await this.#e().selectAll()}async clearSelection(){await this.#e().clearSelection()}getSelectedIds(){return this.#e().getSelectedIds()}async openRecordDetails(e){const t=this.#e(),r=t.result.rows.find(s=>s.id===e&&s.group===void 0&&!s.loading);if(r)return t.details(r);if(!t.remote)return await t.client.call("record",{id:e}),t.details({id:e},await t.client.call("detail",{id:e}));if(t.remote.detail)return t.details({id:e},await t.remote.detail({id:e,state:t.getState(),signal:new AbortController().signal}));throw new Error("This record is not loaded, and the source has no detail method.")}async openDialog(e,{field:t}={}){const r=this.#t(),s=()=>{if(r.remote)throw new Error("This dialog needs local records.")},o=()=>{if(s(),!r.editable)throw new Error("This view is read-only.")};if(e==="source"){if(!r.sources?.length||r.base)throw new Error("Sources belong to an open file.");return r.chooseSource()}switch(this.#e(),e){case"filter":return t!=null&&this.#r(t),r.filterDialog(t);case"sort":return r.orderDialog(!1);case"group":return r.orderDialog(!0);case"summary":return r.summaryDialog();case"columns":return r.columnsDialog();case"views":return r.readViews(),r.viewsDialog();case"pivot":if(s(),r.base)throw new Error("Go back to the records first.");return r.pivotDialog();case"chart":if(!r.base)throw new Error("A chart belongs to a pivot. Call openPivot() first.");return r.chartDialog();case"export":if(r.remote&&!r.remote.exportResults)throw new Error("This source cannot export.");return r.exportDialog();case"share":if(r.remote&&!r.remote.exportResults)throw new Error("This source cannot export.");if(!r.options.sharing&&!navigator.canShare)throw new Error("Sharing needs a sharing option.");return r.shareDialog();case"calculatedField":return o(),r.formulaDialog();case"addRecord":return o(),r.addRecordDialog();case"conditionalFormatting":return this.#r(t),r.formatDialog(t);default:throw new Error(`Unknown dialog "${e}".`)}}closeDialog(){const e=this.#t();e.root.querySelector(".tv-menu")?.dispatchEvent(new Event("tv-close"));const t=[...e.root.querySelectorAll("dialog[open]")];for(const r of t)r.close();return t.length>0}async expandRecord(e){const t=this.#e();if(!t.options.detailRenderer)throw new Error("Expanding a record needs the detailRenderer option.");if(t.expanded?.id===e)return!0;if(!await this.scrollToRecord(e))return!1;const r=t.result,s=r.rows.findIndex(o=>o.id===e&&o.group===void 0&&!o.loading);return s<0?!1:(t.toggleDetail(r.rows[s],r.offset+s),!0)}collapseRecord(){const e=this.#t();return e.expanded?(e.expanded=null,e.renderRows(),!0):!1}getExpandedRecord(){return this.#t().expanded?.id??null}isEditable(){return!!this.#t().editable}async enableEditing(){await this.#e().enableEditing()}setCellValue(e,t,r){return this.updateRecords([{id:e,values:{[t]:r}}])}async updateRecords(e){const t=this.#e();if(!Array.isArray(e))throw new TypeError("updateRecords takes a list of { id, values }.");const r=[];for(const s of e){if(!h(s)||!w(s.id)||!h(s.values))throw new TypeError("Each update is { id, values: { field: value } }.");for(const[o,a]of Object.entries(s.values)){if(this.#r(o),t.remote&&t.editable&&!S(t,o))throw new Error("This field is read-only.");r.push({id:s.id,field:o,value:a})}}return r.length?t.change("edit",{cells:r},"api"):!1}async addRecords(e){const t=this.#e();if(!Array.isArray(e)||!e.every(h))throw new TypeError("addRecords takes a list of records: { field: value } objects.");for(const s of e)for(const o of Object.keys(s))this.#r(o);if(!e.length)return[];const r=await t.change("add",{records:structuredClone(e)},"api");return r===!1?null:r}async removeRecords(e){const t=this.#e();if(!Array.isArray(e)||!e.every(w))throw new TypeError("removeRecords takes a list of record IDs.");return e.length?t.change("remove",{ids:[...new Set(e)]},"api"):!1}async paste(e,{id:t,field:r,repeat:s=1}={}){const o=this.#e(),a=typeof e=="string"?I(e):Array.isArray(e)&&e.every(Array.isArray)?e.map(n=>n.map(i=>i==null?"":String(i))):null;if(!a?.length)throw new TypeError("paste takes tab-separated text or a list of rows.");if(t===void 0||r===void 0){const n=this.getRange();if(!n)throw new Error("Choose where to paste: pass { id, field }, or select a cell.");t=n.ids[0],r=n.fields[0]}if(this.#r(r),!Number.isSafeInteger(s)||s<1)throw new RangeError("repeat is a whole number from 1.");return o.change("paste",{id:t,field:r,lines:a,repeat:s},"api")}async fillDown(){const e=this.#e();if(e.remote)throw new Error("Fill down works on local records.");const t=this.getRange();if(!t||t.ids.length<2)throw new Error("Select cells across two or more records first.");return e.grid.fillDown("api")}async undo(){return this.canUndo()?this.#s.change("undo",{},"api"):!1}async redo(){return this.canRedo()?this.#s.change("redo",{},"api"):!1}canUndo(){const e=this.#t();return!e.remote&&!!e.result?.canUndo}canRedo(){const e=this.#t();return!e.remote&&!!e.result?.canRedo}async startEdit(e,t,{text:r}={}){const s=this.#e();if(this.#r(t),!S(s,t))throw new Error(s.editable?"This field is read-only.":"This view is read-only.");if(!await this.focusCell(e,t))return!1;const o=s.grid.positionOf(e,t);return!!o&&s.grid.edit(o,r==null?void 0:String(r))}async stopEdit({cancel:e=!1}={}){const t=this.#t().editor;return t?e?(t.cancel(),!0):t.commit():!1}getEditingCell(){const e=this.#t().editor;return e?{id:e.id,field:e.field}:null}exportResults(e,t){return this.#t().exportResults(e,t)}async download(e,t){await this.#t().downloadResults(e,t)}createShareLink(){return this.#e().createShare()}revokeShareLink(){return this.#t().revokeShare()}isLoading(){return!!this.#t().load}cancelLoad(){return this.#t().cancelLoad()}setChrome(e){this.#t().setChrome(e)}getChrome(){return structuredClone(this.#t().chrome)}setLanguage(e){this.#t().setLanguage(e)}getLanguage(){return this.#t().language}async setOptions(e){const t=this.#t();if(!h(e))throw new TypeError("setOptions takes some options.");for(const s of Object.keys(e)){if(A[s])throw new Error(`The ${s} option can't change after mount. Use ${A[s]}.`);if(!P.has(s)&&!/^on[A-Z]/.test(s))throw new Error(`Unknown option "${s}".`);if(/^on[A-Z]/.test(s)&&e[s]!=null&&typeof e[s]!="function")throw new TypeError(`${s} is a function.`)}let r=!1;for(const[s,o]of Object.entries(e))switch(s){case"chrome":t.setChrome(o??"auto");break;case"language":t.setLanguage(o);break;case"scrolling":await t.setScrolling(o??"continuous");break;case"rowSelection":t.setRowSelection(o??null);break;case"title":t.options.title=o,t.result&&!t.file&&!t.base&&(t.title.textContent=o||t.t("Table"));break;case"storageKey":t.options.storageKey=o,t.result&&!t.file&&!t.base&&(t.storageKey=o?"8sheets.table.v1|"+JSON.stringify([o,t.title.textContent,t.fields.map(a=>a.name)]):null),t.renderTools();break;case"detailRenderer":t.options.detailRenderer=o??void 0,t.expanded=null,r=!0;break;case"renderers":t.options.renderers=o??void 0,r=!0;break;default:o==null?delete t.options[s]:t.options[s]=o,(s==="allowEdit"||s==="sharing")&&t.renderHeader()}r&&t.result&&t.renderRows()}async getRecords({offset:e=0,limit:t=100}={}){const r=this.#e();if(!Number.isSafeInteger(e)||e<0)throw new RangeError("offset is a whole number from 0.");if(!Number.isSafeInteger(t)||t<1||t>1e4)throw new RangeError("limit is a whole number from 1 to 10000.");if(!r.remote)return r.client.call("rows",{offset:e,limit:t});if(r.state.groups.length)throw new Error("A grouped remote result mixes group rows with records. Ungroup it, or query your server.");const s=r.getState(),o=new AbortController().signal,a=[];let n=null;for(let i=Math.floor(e/p)*p;i<e+t;i+=p){const u=[];let d=0;for(;;){const f=await r.remote.query({state:s,offset:i,limit:p,columnOffset:d,columnLimit:r.columnLimit,signal:o});if(u.push(f),d+=r.columnLimit,!Number.isSafeInteger(f.columnCount)||d>=f.columnCount)break}const c=u[0];if(Number.isSafeInteger(c.matches)?n=c.matches:Number.isSafeInteger(c.count)&&(n=c.count),c.rows.forEach((f,y)=>{const E=i+y;if(E<e||E>=e+t||f.group!==void 0)return;const g=m(f,c.columns);for(const b of u.slice(1)){const v=m(b.rows[y]??{values:[]},b.columns);Object.assign(g.values,v.values),Object.assign(g.raw,v.raw)}a.push(g)}),c.rows.length<p||c.offset!==i)break}return{total:n,records:a}}async getRecord(e){const t=this.#e();if(!w(e))throw new TypeError("A record ID is a number or a string.");if(!t.remote)return t.client.call("record",{id:e});const r=this.#c(e);if(r)return r;if(!t.remote.detail)throw new Error("This record is not loaded, and the source has no detail method.");const s=await t.remote.detail({id:e,state:t.getState(),signal:new AbortController().signal});return{id:e,values:Object.fromEntries(s.map(o=>[o.field,o.value])),raw:{}}}async getCell(e,t){this.#r(t);const r=await this.getRecord(e);if(!Object.hasOwn(r.values,t))throw new Error(`Field "${t}" is not available for this record.`);return{value:r.raw[t]??null,text:r.values[t]}}getCounts(){const e=this.#e().result;return{matches:Number.isSafeInteger(e.matches)?e.matches:null,sourceCount:Number.isSafeInteger(e.sourceCount)?e.sourceCount:null,count:e.count,exact:e.exact!==!1}}getTotals(){const e=this.#e(),t=e.state.total;return{summary:t?{field:t.field,agg:t.agg,text:e.result.summary??""}:null,totals:{...e.result.totals??{}}}}}function m(l,e){const t={},r={};return e.forEach((s,o)=>{t[s]=l.values?.[o]??"",r[s]=l.raw?.[o]??null}),{id:l.id,values:t,raw:r}}function x(l){if(l.width!=null&&(!Number.isFinite(l.width)||l.width<48||l.width>800))throw new RangeError("A column width is 48 to 800 pixels.");if(l.total!=null&&!C.includes(l.total))throw new Error(`A column total is one of ${C.join(", ")}.`);if(l.rules!=null&&!Array.isArray(l.rules))throw new TypeError("Column rules are a list.");if(l.format!=null&&typeof l.format!="string")throw new TypeError('A column format is a number format text, such as "#,##0.00".')}export{z as DataGridApi};
1
+ import{colIndex as I,rangeRef as L}from"../core/address.js";import{parseTsv as N}from"../core/tsv.js";import{canEdit as S}from"./cell-editor.js";import{defaultState as A,displayOrder as j,groupPath as P,sortWith as $,toggleCollapsed as M}from"./events.js";import{parseQuickFilter as V}from"./quick-filter.js";import{PIVOT_SHOW_AS as T}from"./pivot-spec.js";import{stateProblems as q,stateSchema as G}from"./state-check.js";import{SPARKLINE_TYPES as k}from"./sparkline.js";import{loadLanguage as R}from"./labels.js";const C=["sum","average","min","max","count","distinct"],D=["sum","average","min","max","count"],x=["sum","average","min","max","count"],U=new Set(["hidden","pinned","width","format","total","rules","caption","sparkline"]),O={data:"setData()",fields:"setData() or setDataSource()",file:"openFile()",dataSource:"setDataSource()",editable:"enableEditing()",transferColumns:"setData()"},_=new Set(["chrome","language","title","scrolling","rowSelection","renderers","detailRenderer","allowEdit","sharing","storageKey","density","columnGroups","contextMenu","rowNumbers","rowDrag","rowDrop","detailMode","flashChanges","assistant"]),p=100,d=l=>typeof l=="string"||typeof l=="number"&&Number.isFinite(l),c=l=>l!==null&&typeof l=="object"&&!Array.isArray(l);class X{#s;constructor(e){this.#s=e}#t(){if(this.#s.closed)throw new Error("The grid was destroyed.");return this.#s}#e(){const e=this.#t();if(!e.result||!e.fields)throw new Error("No table loaded.");return e}#r(e){const r=this.#e().fields.find(s=>s.name===e);if(!r)throw new Error(`Unknown field "${e}".`);return r}#o(){const e=this.#e();return j(e.state,e.fields.map(t=>t.name))}async#u(e){const t=this.#e();if(!d(e))throw new TypeError("A record ID is a number or a string.");if(!t.remote)return t.client.call("rowOf",{id:e});for(const[r,s]of t.rows?.blocks??[]){const o=s.findIndex(n=>n.id===e);if(o>=0)return r*t.rows.blockSize+o}throw new Error("This record is not loaded. A remote source scrolls to loaded records only; use scrollToRow().")}#d(e){const t=this.#s,r=t.rows?.meta?.columns??[];for(const s of t.rows?.blocks?.values()??[]){const o=s.find(n=>n.id===e&&n.group===void 0);if(o)return y(o,r)}return null}#n(e,t=0){if(c(e)&&(Array.isArray(e.any)||Array.isArray(e.all))){if(t>3)throw new Error("Filter groups nest at most four deep.");const r=(e.any??e.all).map(s=>this.#n(s,t+1));return e.any?{any:r}:{all:r}}if(!c(e)||typeof e.op!="string")throw new TypeError("A filter is { field, op, value?, value2?, values? }, or { any: [...] } or { all: [...] }.");if(this.#r(e.field),(e.op==="in"||e.op==="notIn")&&!Array.isArray(e.values))throw new TypeError(`An "${e.op}" filter lists its values.`);return structuredClone(e)}#a(e,t,r=()=>{}){if(!Array.isArray(e))throw new TypeError(`${t} is a list.`);return e.map(s=>{if(!c(s))throw new TypeError(`Each item of ${t} is an object with a field.`);return this.#r(s.field),r(s),structuredClone(s)})}on(e,t){return this.#t().events.on(e,t)}off(e,t){this.#s.events.off(e,t)}destroy(){this.#s.destroy()}async openFile(e,{delimiter:t,textColumns:r,chooseSource:s=!0}={}){const o=this.#t();if(!(e instanceof Blob))throw new TypeError("openFile takes a File.");const n={};t&&(n.delimiter=t),r&&(n.textColumns=r.map(a=>typeof a=="number"?a:I(String(a).toUpperCase()))),await o.openFile(e,n,s)}async setData(e,{fields:t,title:r,editable:s,storageKey:o}={}){const n=this.#t();if(e==null||typeof e!="object")throw new TypeError("setData takes records: objects, arrays or columns.");for(const[a,i]of Object.entries({fields:t,title:r,editable:s,storageKey:o}))i!==void 0&&(n.options[a]=i);delete n.options.dataSource,await n.openData(e)}async setDataSource(e,{fields:t,title:r,editable:s,storageKey:o}={}){const n=this.#t();if(typeof e?.query!="function")throw new TypeError("A data source has a query method.");for(const[a,i]of Object.entries({fields:t,title:r,editable:s,storageKey:o}))i!==void 0&&(n.options[a]=i);if(!n.options.fields?.length)throw new Error("A remote source needs fields.");n.options.dataSource=e,await n.openRemote()}getSources(){return(this.#t().sources??[]).map((e,t)=>({index:t,name:e.name,range:L(e.range),whole:!!e.whole,header:e.headerRows!==0}))}async setSource(e,{range:t,header:r=!0}={}){const s=this.#t();if(!s.sources?.length)throw new Error("Sources belong to an open file.");await s.applySource(e,t,r)}getSource(){const e=this.#t(),t=e.sourceKind(),r={kind:t,title:t==="none"?"":e.title.textContent,editable:!!e.editable,dirty:!!e.dirty};return e.file&&(r.fileName=e.file.name),t==="file"&&Object.assign(r,{index:e.sourceIndex,range:e.sourceRange,header:e.sourceHeader}),r}async refresh({purge:e=!1}={}){const t=this.#e();t.rows&&(e?t.rows.reset():t.rows.invalidate()),await t.refresh()}getState(){return this.#e().getState()}async setState(e){const t=this.#e();if(!c(e))throw new TypeError("setState takes a state object; getState() returns one.");await t.setState({...A(t.fields),...structuredClone(e)})}async updateState(e){const t=this.#e();if(!c(e))throw new TypeError("updateState takes some keys of a state.");await t.update(structuredClone(e))}async resetState(){const e=this.#e();e.quickText?.clear(),await e.setState(A(e.fields))}async setSearch(e){const t=this.#e();clearTimeout(t.searchTimer),await t.update({search:String(e??"")})}async setFilters(e){const t=this.#e();if(!Array.isArray(e))throw new TypeError("setFilters takes a list of filters.");const r=e.map(s=>this.#n(s));t.quickText?.clear(),await t.update({filters:r,collapsed:[]})}async addFilter(e){const t=this.#e();await t.update({filters:[...t.state.filters,this.#n(e)],collapsed:[]})}async clearFilters(e){const t=this.#e();e!=null&&this.#r(e),e==null?t.quickText?.clear():t.quickText?.delete(e),await t.update({filters:e==null?[]:t.state.filters.filter(r=>r.field!==e),collapsed:[]})}async setQuickFilter(e,t){const r=this.#e(),s=this.#r(e),o=V(e,t,s.type),n=r.state.filters.filter(a=>!(a.quick&&a.field===e));o&&n.push(o),r.quickText?.delete(e),await r.update({filters:n,collapsed:[]})}async getDistinctValues(e,{limit:t=500}={}){const r=this.#e();if(this.#r(e),r.remote)throw new Error("A remote source lists its values itself.");if(!Number.isInteger(t)||t<1)throw new RangeError("limit is a positive whole number.");const{values:s}=await r.client.call("distinct",{field:e});return s.slice(0,t).map(({value:o,text:n,count:a})=>({value:o,text:n,count:a}))}async setSort(e){await this.#e().update({sort:this.#a(e,"sort").map(({field:r,desc:s})=>({field:r,desc:s===!0}))})}async sortBy(e,{desc:t=!1,add:r=!1}={}){const s=this.#e();this.#r(e),await s.update({sort:$(s.state.sort,e,t,r)})}async clearSort(e){const t=this.#e();e!=null&&this.#r(e),await t.update({sort:e==null?[]:t.state.sort.filter(r=>r.field!==e)})}async setGroups(e){const t=this.#e(),r=this.#a(e,"groups").map(({field:s,desc:o})=>o===!0?{field:s,desc:o}:{field:s});await t.update({groups:r,collapsed:[]})}async groupBy(e,{desc:t}={}){const r=this.#e();this.#r(e);const s=t===!0?{field:e,desc:t}:{field:e};await r.update({groups:[...r.state.groups.filter(o=>o.field!==e),s],collapsed:[]})}async clearGroups(e){const t=this.#e();e!=null&&this.#r(e),await t.update({groups:e==null?[]:t.state.groups.filter(r=>r.field!==e),collapsed:[]})}async#i(e,t){const r=this.#e();if(!r.state.groups.length)throw new Error("The records are not grouped.");const s=P(e);await r.applyLayout({collapsed:M(r.state.collapsed,s,t,r.state.collapseLevel)})}expandGroup(e){return this.#i(e,!1)}collapseGroup(e){return this.#i(e,!0)}async expandAll(){const e=this.#e();if(e.state.tree)return e.setTreeCollapsed(!1);await e.applyLayout({collapsed:[],collapseLevel:void 0})}async collapseAll(){const e=this.#e();if(e.state.tree)return e.setTreeCollapsed(!0);await e.applyLayout({collapsed:[],collapseLevel:0})}async setTree(e){const t=this.#e();if(e!=null){if(!c(e))throw new TypeError("A tree is { parent, key } or { level }.");e.level!=null?this.#r(e.level):(this.#r(e.parent),e.key!=null&&this.#r(e.key));for(const r of e.rollups??[])this.#r(r.field)}await t.setTree(e?structuredClone(e):null)}async#l(e,t){const r=this.#e();if(!r.state.tree)throw new Error("The records are not shown as a tree.");if(!d(e))throw new TypeError("A record ID is a number or a string.");const s=new Set(r.state.treeCollapsed??[]);t?s.add(e):s.delete(e),await r.applyLayout({treeCollapsed:[...s]})}expandTreeNode(e){return this.#l(e,!1)}collapseTreeNode(e){return this.#l(e,!0)}getPinnedRows(){const e=this.#e().state.pinnedRows??{};return{top:[...e.top??[]],bottom:[...e.bottom??[]]}}async pinRows(e,t="top"){if(!Array.isArray(e)||!e.every(d))throw new TypeError("pinRows takes a list of record IDs.");await this.#e().pinRecords([...new Set(e)],t)}async unpinRows(e){const t=this.#e(),r=e??[...t.state.pinnedRows?.top??[],...t.state.pinnedRows?.bottom??[]];if(!Array.isArray(r)||!r.every(d))throw new TypeError("unpinRows takes a list of record IDs.");await t.pinRecords(r,null)}async moveRecords(e,t=null){const r=this.#e();if(!Array.isArray(e)||!e.length||!e.every(d))throw new TypeError("moveRecords takes a list of record IDs.");if(t!=null&&!d(t))throw new TypeError("before is a record ID or null.");return r.moveRecords([...new Set(e)],t,"api")}async applyTransaction(e){const t=this.#e();if(!c(e))throw new TypeError("A transaction is { add, update, remove }.");const{add:r=[],update:s=[],remove:o=[]}=e;if(!Array.isArray(r)||!r.every(c))throw new TypeError("add is a list of records.");if(!Array.isArray(s)||!s.every(n=>c(n)&&d(n.id)&&c(n.values)))throw new TypeError("update is a list of { id, values }.");if(!Array.isArray(o)||!o.every(d))throw new TypeError("remove is a list of record IDs.");for(const n of r)for(const a of Object.keys(n))this.#r(a);for(const n of s)for(const a of Object.keys(n.values))this.#r(a);return t.applyTransaction(structuredClone({add:r,update:s,remove:o}))}applyTransactionAsync(e){const t=this.#e();if(!c(e))throw new TypeError("A transaction is { add, update, remove }.");const r=this.#c??={add:[],update:[],remove:[],waiting:[]};return r.add.push(...e.add??[]),r.update.push(...e.update??[]),r.remove.push(...e.remove??[]),r.timer||(r.timer=setTimeout(()=>{const{add:s,update:o,remove:n,waiting:a}=r;if(this.#c=null,t.closed)return a.forEach(([,i])=>i(new Error("The grid was destroyed.")));this.applyTransaction({add:s,update:o,remove:n}).then(i=>a.forEach(([u])=>u(i)),i=>a.forEach(([,u])=>u(i)))},50)),new Promise((s,o)=>r.waiting.push([s,o]))}#c=null;flashCells(e){const t=this.#e();if(!Array.isArray(e)||!e.every(r=>c(r)&&d(r.id)))throw new TypeError("flashCells takes a list of { id, field }.");for(const r of e)this.#r(r.field);t.flashCells(e)}async setSummary(e){const t=this.#e();if(e!=null&&(this.#r(e.field),!C.includes(e.agg)))throw new Error(`A summary is one of ${C.join(", ")}.`);await t.applyLayout({total:e?{field:e.field,agg:e.agg}:null})}async setTotalsRow(e){await this.#e().toggleTotals(e!==!1)}async setFilterRow(e){await this.#e().toggleFilterRow(e!==!1)}getFields(){return(this.#t().fields??[]).map(e=>({...e}))}getColumn(e){const t=this.#e().state.columns.find(r=>r.field===e);return t?structuredClone(t):null}async setColumns(e){const t=this.#e(),r=this.#a(e,"columns",s=>F(s));if(new Set(r.map(s=>s.field)).size!==r.length)throw new Error("Each field appears once in columns.");await t.applyLayout({columns:r})}async setColumn(e,t){const r=this.#e();if(this.#r(e),!c(t))throw new TypeError("setColumn takes some keys of a column: hidden, pinned, width, format, total, rules, caption, sparkline.");for(const a of Object.keys(t))if(!U.has(a))throw new Error(`Unknown column setting "${a}".`);F(t);const s=Object.keys(t),o=r.state.columns.some(a=>a.field===e),n=(o?r.state.columns:[...r.state.columns,{field:e}]).map(a=>{if(a.field!==e)return a;const i={...a,...structuredClone(t)};for(const u of s)t[u]==null&&u!=="total"&&delete i[u];return i});if(o&&s.length===1&&s[0]==="width")return r.setColumnWidth(e,t.width??void 0);await r.applyLayout({columns:n})}async moveColumn(e,t){const r=this.#e();this.#r(e),t!=null&&this.#r(t),await r.moveColumn(e,t??null)}async autosizeColumn(e){const t=this.#e();if(this.#r(e),!this.#o().includes(e))throw new Error(`Show column "${e}" first.`);return await t.showColumn(e,this.#o()),t.autosizeColumn(e)??null}async addCalculatedField(e,t){await this.#e().addCalculatedField(e,t,"api")}getSavedViews(){return[...this.#e().readViews()].map(([e,t])=>({name:e,state:t}))}saveView(e,t){const r=this.#e();if(e=String(e??"").trim(),!e)throw new Error("A saved view needs a name.");const s=r.readViews();s.set(e,t?structuredClone(t):r.getState()),r.writeViews(s)}async restoreView(e){const t=this.#e(),r=t.readViews().get(e);if(!r)throw new Error(`No saved view "${e}".`);await t.setState(r)}deleteView(e){const t=this.#e(),r=t.readViews(),s=r.delete(e);return s&&t.writeViews(r),s}async openPivot(e={}){const t=this.#e();if(!c(e))throw new TypeError("openPivot takes { rows, columns, values } or { rowField, columnField, valueField, agg }.");const r=e.rows??[e.rowField].filter(Boolean),s=e.columns??[e.columnField].filter(Boolean),o=e.values??(e.valueField?[{field:e.valueField,agg:e.agg??"sum"}]:[]);if(!Array.isArray(r)||!r.length)throw new Error("A pivot needs a row field.");if(!Array.isArray(o)||!o.length)throw new Error("A pivot needs a value.");for(const n of[...r,...s])this.#r(n);for(const n of o){if(this.#r(n?.field),!x.includes(n.agg??"sum"))throw new Error(`A pivot value is one of ${x.join(", ")}.`);if(n.showAs!=null&&!T.includes(n.showAs))throw new Error(`Show values as is one of ${T.join(", ")}.`)}await t.openPivot({rows:[...r],columns:[...s],values:o.map(({field:n,agg:a="sum",showAs:i="normal"})=>({field:n,agg:a,showAs:i}))})}async closePivot(){await this.#e().closePivot()}async getChartData(e){const t=this.#e();if(!t.base)throw new Error("Chart data belongs to a pivot. Call openPivot() first.");return this.#r(e),t.client.call("chart",{field:e})}getPage(){const e=this.#e(),t=e.result;return e.continuous?{mode:"continuous",index:0,count:1,size:null}:{mode:"pages",index:Math.floor(t.offset/e.limit),count:t.exact===!1?null:Math.max(1,Math.ceil(t.count/e.limit)),size:e.limit}}async setPage(e){const t=this.#e();if(t.continuous)throw new Error('Paging is off. Call setScrolling("pages") first, or scrollToRow().');if(!Number.isInteger(e)||e<0)throw new RangeError("A page index is a whole number from 0.");const r=t.result;if(r.exact!==!1&&e*t.limit>=Math.max(1,r.count))throw new RangeError(`Page ${e} is past the last page.`);t.offset=e*t.limit,t.content.scrollTop=0,await t.refresh(!1)}async setScrolling(e){await this.#t().setScrolling(e)}getViewport(){return this.#e().viewport()}async scrollToRow(e){const t=this.#e();if(!Number.isInteger(e)||e<0)throw new RangeError("A row index is a whole number from 0.");if(t.result.exact!==!1&&e>=t.result.count)throw new RangeError(`Row ${e} is past the last row.`);await t.showRow(e)}async scrollToRecord(e){const t=this.#e(),r=await this.#u(e);return r<0?!1:(await t.showRow(r),!0)}async scrollToColumn(e){const t=this.#e();this.#r(e);const r=this.#o();if(!r.includes(e))throw new Error(`Column "${e}" is hidden.`);await t.showColumn(e,r)}async focusCell(e,t){const r=this.#e();if(this.#r(t),!await this.scrollToRecord(e))return!1;await this.scrollToColumn(t);const s=r.grid?.positionOf(e,t);return s?(r.grid.focusAt(s.row,s.col),!0):!1}getFocusedCell(){return this.#t().grid?.focused()??null}getRange(){const e=this.#t(),{range:t,grid:r}=e;if(!t||!r||!e.result)return null;const s=r.positionOf(t.anchor.id,t.anchor.field),o=r.positionOf(t.focus.id,t.focus.field);if(!s||!o)return null;const[n,a]=[Math.min(s.row,o.row),Math.max(s.row,o.row)],[i,u]=[Math.min(s.col,o.col),Math.max(s.col,o.col)],f=r.records.slice(n,a+1);return{anchor:{...t.anchor},focus:{...t.focus},ids:f.map(h=>h.id),fields:e.result.columns.slice(i,u+1),values:f.map(h=>h.values.slice(i,u+1))}}async setRange({anchor:e,focus:t=e}={}){const r=this.#e();for(const a of[e,t]){if(!c(a)||!d(a.id))throw new TypeError("A range is { anchor: { id, field }, focus: { id, field } }.");this.#r(a.field)}const s=a=>{const i=r.grid?.positionOf(a.id,a.field);return i&&r.grid.cells[i.row][i.col]?i:null};if(!s(e)){if(!await this.scrollToRecord(e.id))throw new Error("The range starts at a record that is not in the view.");await this.scrollToColumn(e.field)}const o=s(e),n=r.grid?.positionOf(t.id,t.field);if(!o||!n)throw new Error("A range covers drawn records only. Choose records near each other, or scroll first.");r.grid.select(o,n,!1)}async copyRange({headers:e=!1}={}){const t=this.#e();if(!this.getRange())throw new Error("Select cells first.");return t.copyCells(e===!0)}async chartRange(){this.#e().chartRange()}async openFind(e){await this.#e().openFind(e==null?void 0:String(e))}closeFind(){this.#t().closeFind()}async findNext(e,{back:t=!1}={}){const r=this.#e();if(r.remote)throw new Error("Find needs local records; search the server source instead.");return e!=null&&e!==r.finder?.text&&(r.findBar&&(r.findBar.input.value=String(e)),await r.setFindText(String(e))),r.findNext(t===!0)}async openContextMenu(e,t){const r=this.#e();if(this.#r(t),!await this.focusCell(e,t))return!1;const s=r.grid.positionOf(e,t),{openContextMenu:o}=await import("./context-menu.js");return o(r,r.grid.cells[s.row][s.col],null)}getSelection(){return this.#t().getSelection()}async setSelection(e){await this.#e().setSelection(e)}async selectRecords(e,t=!0){const r=this.#e();if(!r.selection)throw new Error("Row selection is off for this table.");if(!Array.isArray(e)||!e.every(d))throw new TypeError("selectRecords takes a list of record IDs.");for(const s of e)r.selection.toggle(s,t!==!1);await r.recountSelection(!0)}async selectAll(){await this.#e().selectAll()}async clearSelection(){await this.#e().clearSelection()}getSelectedIds(){return this.#e().getSelectedIds()}async openRecordDetails(e){const t=this.#e(),r=t.result.rows.find(s=>s.id===e&&s.group===void 0&&!s.loading);if(r)return t.details(r);if(!t.remote)return await t.client.call("record",{id:e}),t.details({id:e},await t.client.call("detail",{id:e}));if(t.remote.detail)return t.details({id:e},await t.remote.detail({id:e,state:t.getState(),signal:new AbortController().signal}));throw new Error("This record is not loaded, and the source has no detail method.")}async openDialog(e,{field:t}={}){const r=this.#t(),s=()=>{if(r.remote)throw new Error("This dialog needs local records.")},o=()=>{if(s(),!r.editable)throw new Error("This view is read-only.")};if(e==="source"){if(!r.sources?.length||r.base)throw new Error("Sources belong to an open file.");return r.chooseSource()}switch(this.#e(),e){case"filter":return t!=null&&this.#r(t),r.filterDialog(t);case"sort":return r.orderDialog(!1);case"group":return r.orderDialog(!0);case"summary":return r.summaryDialog();case"columns":return r.columnsDialog();case"views":return r.readViews(),r.viewsDialog();case"pivot":if(s(),r.base)throw new Error("Go back to the records first.");return r.pivotDialog();case"chart":if(!r.base)throw new Error("A chart belongs to a pivot. Call openPivot() first.");return r.chartDialog();case"export":if(r.remote&&!r.remote.exportResults)throw new Error("This source cannot export.");return r.exportDialog();case"share":if(r.remote&&!r.remote.exportResults)throw new Error("This source cannot export.");if(!r.options.sharing&&!navigator.canShare)throw new Error("Sharing needs a sharing option.");return r.shareDialog();case"calculatedField":return o(),r.formulaDialog();case"addRecord":return o(),r.addRecordDialog();case"conditionalFormatting":return this.#r(t),r.formatDialog(t);case"sparkline":return this.#r(t),r.sparklineDialog(t);case"tree":return r.treeDialog();case"find":return s(),r.openFind();case"assistant":if(typeof r.options.assistant!="function")throw new Error("Asking needs the assistant option.");return r.assistantDialog();default:throw new Error(`Unknown dialog "${e}".`)}}closeDialog(){const e=this.#t();e.root.querySelector(".tv-menu")?.dispatchEvent(new Event("tv-close"));const t=[...e.root.querySelectorAll("dialog[open]")];for(const r of t)r.close();return t.length>0}async expandRecord(e){const t=this.#e();if(!t.options.detailRenderer)throw new Error("Expanding a record needs the detailRenderer option.");if(t.expanded?.id===e)return!0;if(!await this.scrollToRecord(e))return!1;const r=t.result,s=r.rows.findIndex(o=>o.id===e&&o.group===void 0&&!o.loading);return s<0?!1:(t.toggleDetail(r.rows[s],r.offset+s),!0)}collapseRecord(e){const t=this.#t();return!t.opened.size||e!==void 0&&!t.opened.has(e)?!1:(e===void 0?t.opened.clear():t.opened.delete(e),t.renderRows(),!0)}getExpandedRecord(){return this.#t().expanded?.id??null}getExpandedRecords(){return[...this.#t().opened.keys()]}isEditable(){return!!this.#t().editable}async enableEditing(){await this.#e().enableEditing()}setCellValue(e,t,r){return this.updateRecords([{id:e,values:{[t]:r}}])}async updateRecords(e){const t=this.#e();if(!Array.isArray(e))throw new TypeError("updateRecords takes a list of { id, values }.");const r=[];for(const s of e){if(!c(s)||!d(s.id)||!c(s.values))throw new TypeError("Each update is { id, values: { field: value } }.");for(const[o,n]of Object.entries(s.values)){if(this.#r(o),t.remote&&t.editable&&!S(t,o))throw new Error("This field is read-only.");r.push({id:s.id,field:o,value:n})}}return r.length?t.change("edit",{cells:r},"api"):!1}async addRecords(e){const t=this.#e();if(!Array.isArray(e)||!e.every(c))throw new TypeError("addRecords takes a list of records: { field: value } objects.");for(const s of e)for(const o of Object.keys(s))this.#r(o);if(!e.length)return[];const r=await t.change("add",{records:structuredClone(e)},"api");return r===!1?null:r}async removeRecords(e){const t=this.#e();if(!Array.isArray(e)||!e.every(d))throw new TypeError("removeRecords takes a list of record IDs.");return e.length?t.change("remove",{ids:[...new Set(e)]},"api"):!1}async paste(e,{id:t,field:r,repeat:s=1}={}){const o=this.#e(),n=typeof e=="string"?N(e):Array.isArray(e)&&e.every(Array.isArray)?e.map(a=>a.map(i=>i==null?"":String(i))):null;if(!n?.length)throw new TypeError("paste takes tab-separated text or a list of rows.");if(t===void 0||r===void 0){const a=this.getRange();if(!a)throw new Error("Choose where to paste: pass { id, field }, or select a cell.");t=a.ids[0],r=a.fields[0]}if(this.#r(r),!Number.isSafeInteger(s)||s<1)throw new RangeError("repeat is a whole number from 1.");return o.change("paste",{id:t,field:r,lines:n,repeat:s},"api")}async fillDown(){const e=this.#e();if(e.remote)throw new Error("Fill down works on local records.");const t=this.getRange();if(!t||t.ids.length<2)throw new Error("Select cells across two or more records first.");return e.grid.fillDown("api")}async undo(){return this.canUndo()?this.#s.change("undo",{},"api"):!1}async redo(){return this.canRedo()?this.#s.change("redo",{},"api"):!1}canUndo(){const e=this.#t();return!e.remote&&!!e.result?.canUndo}canRedo(){const e=this.#t();return!e.remote&&!!e.result?.canRedo}async startEdit(e,t,{text:r}={}){const s=this.#e();if(this.#r(t),!S(s,t))throw new Error(s.editable?"This field is read-only.":"This view is read-only.");if(!await this.focusCell(e,t))return!1;const o=s.grid.positionOf(e,t);return!!o&&s.grid.edit(o,r==null?void 0:String(r))}async stopEdit({cancel:e=!1}={}){const t=this.#t().editor;return t?e?(t.cancel(),!0):t.commit():!1}getEditingCell(){const e=this.#t().editor;return e?{id:e.id,field:e.field}:null}exportResults(e,t){return this.#t().exportResults(e,t)}async download(e,t){await this.#t().downloadResults(e,t)}createShareLink(){return this.#e().createShare()}revokeShareLink(){return this.#t().revokeShare()}isLoading(){return!!this.#t().load}cancelLoad(){return this.#t().cancelLoad()}setChrome(e){this.#t().setChrome(e)}async setDensity(e){const t=this.#t();t.options.density=e,await t.setDensity(e)}getDensity(){return this.#t().density}askAssistant(e){return this.#e().askAssistant(e)}getStateSchema(){return G(this.#e().fields.map(e=>e.name))}validateState(e){return q(e,this.#e().fields.map(t=>t.name))}getChrome(){return structuredClone(this.#t().chrome)}async setLanguage(e){const t=this.#t();await R(e||t.language),t.setLanguage(e)}getLanguage(){return this.#t().language}async setOptions(e){const t=this.#t();if(!c(e))throw new TypeError("setOptions takes some options.");for(const s of Object.keys(e)){if(O[s])throw new Error(`The ${s} option can't change after mount. Use ${O[s]}.`);if(!_.has(s)&&!/^on[A-Z]/.test(s))throw new Error(`Unknown option "${s}".`);if(/^on[A-Z]/.test(s)&&e[s]!=null&&typeof e[s]!="function")throw new TypeError(`${s} is a function.`)}let r=!1;for(const[s,o]of Object.entries(e))switch(s){case"chrome":t.setChrome(o??"auto");break;case"language":await R(o||t.language),t.setLanguage(o);break;case"scrolling":await t.setScrolling(o??"continuous");break;case"rowSelection":t.setRowSelection(o??null);break;case"title":t.options.title=o,t.result&&!t.file&&!t.base&&(t.title.textContent=o||t.t("Table"));break;case"storageKey":t.options.storageKey=o,t.result&&!t.file&&!t.base&&(t.storageKey=o?"8sheets.table.v1|"+JSON.stringify([o,t.title.textContent,t.fields.map(n=>n.name)]):null),t.renderTools();break;case"detailRenderer":t.options.detailRenderer=o??void 0,t.expanded=null,r=!0;break;case"renderers":t.options.renderers=o??void 0,r=!0;break;case"density":t.options.density=o??"normal",await t.setDensity(o??"normal");break;case"detailMode":if(o!=null&&o!=="single"&&o!=="multiple")throw new Error('detailMode is "single" or "multiple".');t.options.detailMode=o??void 0,o!=="multiple"&&t.opened.size>1&&(t.expanded=t.expanded),r=!0;break;case"columnGroups":case"rowNumbers":case"rowDrag":case"contextMenu":case"flashChanges":o==null?delete t.options[s]:t.options[s]=o,t.measured=null,r=!0;break;case"assistant":if(o!=null&&typeof o!="function")throw new TypeError("assistant is a function.");o==null?delete t.options.assistant:t.options.assistant=o,t.renderTools();break;default:o==null?delete t.options[s]:t.options[s]=o,(s==="allowEdit"||s==="sharing")&&t.renderHeader()}r&&t.result&&t.renderRows()}async getRecords({offset:e=0,limit:t=100}={}){const r=this.#e();if(!Number.isSafeInteger(e)||e<0)throw new RangeError("offset is a whole number from 0.");if(!Number.isSafeInteger(t)||t<1||t>1e4)throw new RangeError("limit is a whole number from 1 to 10000.");if(!r.remote)return r.client.call("rows",{offset:e,limit:t});if(r.state.groups.length)throw new Error("A grouped remote result mixes group rows with records. Ungroup it, or query your server.");const s=r.getState(),o=new AbortController().signal,n=[];let a=null;for(let i=Math.floor(e/p)*p;i<e+t;i+=p){const u=[];let f=0;for(;;){const w=await r.remote.query({state:s,offset:i,limit:p,columnOffset:f,columnLimit:r.columnLimit,signal:o});if(u.push(w),f+=r.columnLimit,!Number.isSafeInteger(w.columnCount)||f>=w.columnCount)break}const h=u[0];if(Number.isSafeInteger(h.matches)?a=h.matches:Number.isSafeInteger(h.count)&&(a=h.count),h.rows.forEach((w,m)=>{const E=i+m;if(E<e||E>=e+t||w.group!==void 0)return;const g=y(w,h.columns);for(const v of u.slice(1)){const b=y(v.rows[m]??{values:[]},v.columns);Object.assign(g.values,b.values),Object.assign(g.raw,b.raw)}n.push(g)}),h.rows.length<p||h.offset!==i)break}return{total:a,records:n}}async getRecord(e){const t=this.#e();if(!d(e))throw new TypeError("A record ID is a number or a string.");if(!t.remote)return t.client.call("record",{id:e});const r=this.#d(e);if(r)return r;if(!t.remote.detail)throw new Error("This record is not loaded, and the source has no detail method.");const s=await t.remote.detail({id:e,state:t.getState(),signal:new AbortController().signal});return{id:e,values:Object.fromEntries(s.map(o=>[o.field,o.value])),raw:{}}}async getCell(e,t){this.#r(t);const r=await this.getRecord(e);if(!Object.hasOwn(r.values,t))throw new Error(`Field "${t}" is not available for this record.`);return{value:r.raw[t]??null,text:r.values[t]}}getCounts(){const e=this.#e().result;return{matches:Number.isSafeInteger(e.matches)?e.matches:null,sourceCount:Number.isSafeInteger(e.sourceCount)?e.sourceCount:null,count:e.count,exact:e.exact!==!1}}getTotals(){const e=this.#e(),t=e.state.total;return{summary:t?{field:t.field,agg:t.agg,text:e.result.summary??""}:null,totals:{...e.result.totals??{}}}}}function y(l,e){const t={},r={};return e.forEach((s,o)=>{t[s]=l.values?.[o]??"",r[s]=l.raw?.[o]??null}),{id:l.id,values:t,raw:r}}function F(l){if(l.caption!=null&&typeof l.caption!="string")throw new TypeError("A column caption is text.");if(l.sparkline!=null){if(!c(l.sparkline)||!k.includes(l.sparkline.type??"line"))throw new Error(`A sparkline is { type: ${k.join(" | ")}, fields? }.`);if(l.sparkline.fields!=null&&!Array.isArray(l.sparkline.fields))throw new TypeError("A sparkline lists its fields.")}if(l.width!=null&&(!Number.isFinite(l.width)||l.width<48||l.width>800))throw new RangeError("A column width is 48 to 800 pixels.");if(l.total!=null&&!D.includes(l.total))throw new Error(`A column total is one of ${D.join(", ")}.`);if(l.rules!=null&&!Array.isArray(l.rules))throw new TypeError("Column rules are a list.");if(l.format!=null&&typeof l.format!="string")throw new TypeError('A column format is a number format text, such as "#,##0.00".')}export{X as DataGridApi};
@@ -1 +1,2 @@
1
- import{el as y}from"./panel.js";import{cancellable as g}from"./events.js";function x(t,i){const o=t.fieldIndex?.get(i);return!!(t.editable&&(t.remote?o?.editable===!0:o?.editable))}function k(t,i,o,a,m,c){const r=t.result.columns[a];if(!x(t,r)||i.querySelector(".tv-cell-editor"))return!1;const u=o.raw?.[a],p=t.fieldIndex.get(r)?.type==="number"&&typeof u=="number"&&Number.isFinite(u)?String(u):o.values[a]??"";if(!t.emit("editStart",g({id:o.id,field:r,value:u??null,text:p})))return!1;t.editor?.cancel();const n=y("input",null,{className:"tv-cell-editor",value:m??p,spellcheck:!1,size:4});n.setAttribute("aria-label",(t.fieldIndex.get(r)?.caption||r)+" · "+t.t("Edit"));const v=[...i.childNodes];i.classList.add("tv-editing"),i.replaceChildren(n),n.focus(),m==null&&n.select();let s=!1;const b=t.editor={id:o.id,field:r,get busy(){return s},commit:()=>f(null),cancel:()=>{t.status.textContent="",d(!0)}},d=(e,l)=>{t.editor===b&&(t.editor=null,i.classList.remove("tv-editing"),i.isConnected&&i.replaceChildren(...v),t.emit("editEnd",{id:o.id,field:r,cancelled:e,value:e?u??null:l}))},f=async e=>{if(s)return!0;if(n.value===p)return d(!1,u??null),c?.focus(e),!0;s=!0;try{t.focusAfter={id:o.id,col:a,step:e};const l=n.value;return await t.change("edit",{revision:t.result.revision,cells:[{id:o.id,field:r,value:l}]})===!1?(t.focusAfter=null,s=!1,d(!0),c?.focus({row:0,col:0}),!1):(t.status.textContent="",d(!1,l),!0)}catch(l){return t.focusAfter=null,s=!1,n.setAttribute("aria-invalid","true"),t.status.textContent=t.t(l.message),t.emit("error",l),n.focus(),!1}};n.addEventListener("keydown",e=>{e.stopPropagation(),e.key==="Escape"?(e.preventDefault(),t.status.textContent="",d(!0),c?.focus({row:0,col:0})):e.key==="Enter"?(e.preventDefault(),f({row:e.shiftKey?-1:1,col:0})):e.key==="Tab"&&(e.preventDefault(),f({row:0,col:e.shiftKey?-1:1}))}),n.addEventListener("blur",()=>{!s&&i.contains(n)&&!t.closed&&setTimeout(()=>!s&&i.contains(n)&&f(null),0)});for(const e of["copy","cut","paste","pointerdown","dblclick"])n.addEventListener(e,l=>l.stopPropagation());return!0}export{x as canEdit,k as startCellEdit};
1
+ import{el as A}from"./panel.js";import{cancellable as C}from"./events.js";import{checkChoice as M,createEditor as T,editorKind as N}from"./editors.js";function L(t,i){const l=t.fieldIndex?.get(i);return!!(t.editable&&(t.remote?l?.editable===!0:l?.editable))}function D(t,i,l,s){return t.change("edit",{revision:t.result.revision,cells:[{id:i.id,field:l,value:s}]})}function O(t,i,l){const s=t.result.columns[l];if(!L(t,s))return!1;const u=i.raw?.[l],p=u===!0||/^(true|yes|1)$/i.test(String(i.values[l]??""));return t.emit("editStart",C({id:i.id,field:s,value:u??null,text:i.values[l]??""}))?(t.focusAfter={id:i.id,col:l,step:{row:0,col:0}},t.perform(async()=>{const a=await D(t,i,s,!p);t.emit("editEnd",{id:i.id,field:s,cancelled:a===!1,value:a===!1?u??null:!p})}),!0):!1}function I(t,i,l,s,u,p){const a=t.result.columns[s];if(!L(t,a)||i.classList.contains("tv-editing")||i.classList.contains("tv-editing-list"))return!1;const x=t.fieldIndex.get(a),m=N(x);if(m==="checkbox")return u==null||u===" "?O(t,l,s):!1;const h=l.raw?.[s],S=l.values[s]??"",c=T(x,{raw:h,text:S,seed:u,t:t.t,inline:!0}),b=c.read();if(!t.emit("editStart",C({id:l.id,field:a,value:h??null,text:String(b)})))return!1;t.editor?.cancel();const w=(x?.caption||a)+" · "+t.t("Edit");c.focus.setAttribute("aria-label",w);const K=[...i.childNodes];i.classList.add(m==="multiselect"?"tv-editing-list":"tv-editing");let o=null;if(m==="multiselect"){o=A("div",null,{className:"tv-cell-popup"}),o.setAttribute("role","dialog"),o.setAttribute("aria-label",w);const e=A("button",t.t("OK"),{type:"button",className:"tv-primary"});e.addEventListener("click",()=>g({row:1,col:0})),o.append(c.node,e),t.root.append(o);const n=t.root.getBoundingClientRect(),r=i.getBoundingClientRect();o.style.left=Math.max(8,Math.min(r.left-n.left,n.width-o.offsetWidth-8))+"px";const y=r.bottom-n.top+2;o.style.top=(y+o.offsetHeight<=n.height-8?y:Math.max(8,r.top-n.top-o.offsetHeight-2))+"px"}else i.replaceChildren(c.node);const d=c.focus;d.focus(),u==null&&d.select&&m!=="date"&&d.select();let f=!1;const E=t.editor={id:l.id,field:a,get busy(){return f},commit:()=>g(null),cancel:()=>{t.status.textContent="",v(!0)}},v=(e,n)=>{t.editor===E&&(t.editor=null,i.classList.remove("tv-editing","tv-editing-list"),o?.remove(),i.isConnected&&!o&&i.replaceChildren(...K),t.emit("editEnd",{id:l.id,field:a,cancelled:e,value:e?h??null:n}))},k=e=>(t.focusAfter=null,f=!1,d.setAttribute("aria-invalid","true"),t.status.textContent=t.t(e.message),t.emit("error",e),d.focus(),!1),g=async e=>{if(f)return!0;const n=c.read();if(n===b)return v(!1,h??null),p?.focus(e),!0;const r=M(x,m,n);if(r)return k(new Error(r));f=!0;try{return t.focusAfter={id:l.id,col:s,step:e},await D(t,l,a,n)===!1?(t.focusAfter=null,f=!1,v(!0),p?.focus({row:0,col:0}),!1):(t.status.textContent="",v(!1,n),!0)}catch(y){return k(y)}};(o??d).addEventListener("keydown",e=>{if(e.stopPropagation(),e.key==="Escape")e.preventDefault(),t.status.textContent="",v(!0),p?.focus({row:0,col:0});else if(e.key==="Enter"&&e.altKey&&m==="textarea"){e.preventDefault();const n=d.selectionStart;d.setRangeText(`
2
+ `,n,d.selectionEnd,"end")}else if(e.key==="Enter")e.preventDefault(),g({row:e.shiftKey?-1:1,col:0});else if(e.key==="Tab"){if(o){const n=[...o.querySelectorAll("input, button")],r=n.indexOf(document.activeElement);if(e.shiftKey?r>0:r<n.length-1)return}e.preventDefault(),g({row:0,col:e.shiftKey?-1:1})}else if(o&&(e.key==="ArrowDown"||e.key==="ArrowUp")){e.preventDefault();const n=[...o.querySelectorAll("input")],r=n.indexOf(document.activeElement);n[Math.max(0,Math.min(n.length-1,r+(e.key==="ArrowDown"?1:-1)))]?.focus()}}),(o??d).addEventListener("focusout",e=>{o?.contains(e.relatedTarget)||i.contains(e.relatedTarget)||!f&&!t.closed&&setTimeout(()=>!f&&t.editor===E&&!o?.contains(document.activeElement)&&g(null),0)});for(const e of["copy","cut","paste","pointerdown","dblclick","contextmenu"])(o??c.node).addEventListener(e,n=>n.stopPropagation());return!0}export{L as canEdit,I as startCellEdit,D as storeValue,O as toggleCell};
@@ -0,0 +1 @@
1
+ const N=["column","bar","line","pie"],w="http://www.w3.org/2000/svg",I=640,j=340,a={top:16,right:16,bottom:56,left:64};function k(o,n){const e=o.findIndex(t=>!t.numeric),l=o.map((t,r)=>({c:t,i:r})).filter(({c:t})=>t.numeric).map(({c:t,i:r})=>({name:t.caption,values:n.map(u=>Number.isFinite(u.raw[r])?u.raw[r]:0)}));return l.length?{categories:n.map((t,r)=>e>=0?String(t.values[e]??""):String(r+1)),series:l}:null}function A(o,n=5){if(!(o>0))return 1;const e=o/n,l=10**Math.floor(Math.log10(e)),s=e/l;return(s<=1?1:s<=2?2:s<=5?5:10)*l}function P(o){let n=0,e=0;for(const s of o)for(const t of s.values)t<n&&(n=t),t>e&&(e=t);n===e&&(e=n+1);const l=A(e-n);return{min:Math.floor(n/l)*l,max:Math.ceil(e/l)*l,step:l}}const h=(o,n={},e)=>{const l=document.createElementNS(w,o);for(const[s,t]of Object.entries(n))l.setAttribute(s,typeof t=="number"?(Math.round(t*10)/10).toString():t);return e!=null&&(l.textContent=e),l},S=(o,n=14)=>o.length>n?o.slice(0,n-1)+"…":o;function z({type:o="column",categories:n,series:e,title:l="",format:s=String}){const t=h("svg",{viewBox:"0 0 640 340",class:"tv-qchart",role:"img"});if(t.setAttribute("aria-label",l||e.map(i=>i.name).join(", ")),o==="pie")return H(t,n,e[0],s);const r=P(e),u=640-a.left-a.right,c=340-a.top-a.bottom,m=o==="bar",x=i=>(i-r.min)/(r.max-r.min)*(m?u:c);for(let i=r.min;i<=r.max+r.step/2;i+=r.step){const p=x(i);m?(t.append(h("line",{x1:a.left+p,x2:a.left+p,y1:a.top,y2:a.top+c,class:"tv-qchart-grid"})),t.append(h("text",{x:a.left+p,y:a.top+c+16,"text-anchor":"middle",class:"tv-qchart-label"},s(i)))):(t.append(h("line",{x1:a.left,x2:a.left+u,y1:a.top+c-p,y2:a.top+c-p,class:"tv-qchart-grid"})),t.append(h("text",{x:a.left-6,y:a.top+c-p+4,"text-anchor":"end",class:"tv-qchart-label"},s(i))))}const d=n.length,$=(m?c:u)/Math.max(1,d),g=x(0);if(n.forEach((i,p)=>{const y=$*(p+.5),v=h("text",m?{x:a.left-6,y:a.top+y+4,"text-anchor":"end",class:"tv-qchart-label"}:{x:a.left+y,y:a.top+c+16,"text-anchor":"middle",class:"tv-qchart-label"},S(i));(d<=24||p%Math.ceil(d/24)===0)&&t.append(v)}),o==="line")e.forEach((i,p)=>{const y=i.values.map((v,f)=>[a.left+$*(f+.5),a.top+c-x(v)]);t.append(h("path",{d:y.map(([v,f],M)=>(M?"L":"M")+v.toFixed(1)+" "+f.toFixed(1)).join(""),class:`tv-qchart-line tv-qchart-s${p%6}`})),y.forEach(([v,f],M)=>{const q=h("circle",{cx:v,cy:f,r:3,class:`tv-qchart-dot tv-qchart-s${p%6}`});q.append(h("title",{},`${n[M]} · ${i.name}: ${s(i.values[M])}`)),t.append(q)})});else{const i=$*.78,p=i/e.length;e.forEach((y,v)=>{y.values.forEach((f,M)=>{const q=$*M+($-i)/2+p*v,E=Math.abs(x(f)-g),b=m?h("rect",{x:a.left+Math.min(g,x(f)),y:a.top+q,width:Math.max(E,f?1:0),height:Math.max(1,p-1)}):h("rect",{x:a.left+q,y:a.top+c-Math.max(g,x(f)),width:Math.max(1,p-1),height:Math.max(E,f?1:0)});b.setAttribute("class",`tv-qchart-bar tv-qchart-s${v%6}`),b.append(h("title",{},`${n[M]} · ${y.name}: ${s(f)}`)),t.append(b)})})}return t.append(h("line",m?{x1:a.left+g,x2:a.left+g,y1:a.top,y2:a.top+c,class:"tv-qchart-axis"}:{x1:a.left,x2:a.left+u,y1:a.top+c-g,y2:a.top+c-g,class:"tv-qchart-axis"})),e.length>1&&F(t,e.map(i=>i.name)),t}function F(o,n){let e=a.left;n.forEach((l,s)=>{o.append(h("rect",{x:e,y:322,width:10,height:10,class:`tv-qchart-bar tv-qchart-s${s%6}`})),o.append(h("text",{x:e+14,y:331,class:"tv-qchart-label"},S(l,18))),e+=24+Math.min(18,l.length)*7})}function H(o,n,e,l){const s=e.values.map(x=>Math.max(0,x)),t=s.reduce((x,d)=>x+d,0)||1,r=170,u=340/2,c=130;let m=-Math.PI/2;return s.forEach((x,d)=>{const $=x/t*Math.PI*2;if(!$)return;const g=r+c*Math.cos(m),i=u+c*Math.sin(m),p=r+c*Math.cos(m+$),y=u+c*Math.sin(m+$),v=$>=Math.PI*2-1e-9?`M${r-c} ${u}a${c} ${c} 0 1 0 ${2*c} 0a${c} ${c} 0 1 0 ${-2*c} 0`:`M${r} ${u}L${g.toFixed(1)} ${i.toFixed(1)}A${c} ${c} 0 ${$>Math.PI?1:0} 1 ${p.toFixed(1)} ${y.toFixed(1)}Z`,f=h("path",{d:v,class:`tv-qchart-slice tv-qchart-s${d%6}`});f.append(h("title",{},`${n[d]}: ${l(e.values[d])} (${Math.round(x/t*100)}%)`)),o.append(f),m+=$}),n.slice(0,12).forEach((x,d)=>{o.append(h("rect",{x:330,y:40+d*22,width:12,height:12,class:`tv-qchart-slice tv-qchart-s${d%6}`})),o.append(h("text",{x:348,y:50+d*22,class:"tv-qchart-label"},`${S(x,22)} · ${Math.round(s[d]/t*100)}%`))}),o}function C(o){const n=o.cloneNode(!0);n.setAttribute("xmlns",w);const e=getComputedStyle(o),l=e.getPropertyValue("--tv-ink")||"#242424",s=[...Array(6).keys()].map(r=>`.tv-qchart-s${r}{fill:${e.getPropertyValue(`--tv-chart-${r}`).trim()};stroke:${e.getPropertyValue(`--tv-chart-${r}`).trim()}}`).join(""),t=document.createElementNS(w,"style");return t.textContent=`.tv-qchart-label{font:14px system-ui,sans-serif;fill:${l}}.tv-qchart-grid{stroke:#8884;}.tv-qchart-axis{stroke:#888}.tv-qchart-line{fill:none!important;stroke-width:2}${s}`,n.prepend(t),new Blob([new XMLSerializer().serializeToString(n)],{type:"image/svg+xml"})}export{N as CHART_TYPES,z as chartNode,A as niceStep,k as rangeSeries,C as svgFile,P as valueAxis};
@@ -1 +1 @@
1
- import{el as g}from"./panel.js";const w=48,C=800,v=t=>Math.round(Math.max(w,Math.min(C,t)));function L(t,n){const i=n?n+"px":"";t.style.width=t.style.minWidth=t.style.maxWidth=i}function u(t,n){return[...t.content.querySelectorAll("thead tr:first-child th[data-field]")].find(i=>i.dataset.field===n)}function f(t,n){const i=u(t,n);if(!i)return[];const e=i.cellIndex,o=[i];for(const l of i.closest("table").rows){if(l===i.parentElement||l.cells.length<=e)continue;const r=l.cells[e];r.colSpan===1&&o.push(r)}return o}function M(t,n){const i=f(t,n);if(!i.length)return null;const e=document.createRange();let o=0;for(const l of i){const r=getComputedStyle(l),c=parseFloat(r.paddingLeft)+parseFloat(r.paddingRight)+2;let s=0;if(l.tagName==="TH")for(const d of l.children)s+=d.classList.contains("tv-resize")?0:d.offsetWidth+2;else e.selectNodeContents(l),s=e.getBoundingClientRect().width;o=Math.max(o,Math.ceil(s+c))}return v(o)}function W(t,n){const i=t.rtl??=getComputedStyle(t.root).direction==="rtl";n.tHead?.addEventListener("pointerdown",e=>{if(e.button!==0)return;const o=e.target.closest(".tv-resize");if(o)return b(t,o.closest("th").dataset.field,e,i);const l=e.target.closest(".tv-sort");l&&e.pointerType!=="touch"&&E(t,l.closest("th").dataset.field,e)}),n.tHead?.addEventListener("dblclick",e=>{const o=e.target.closest(".tv-resize");o&&(e.preventDefault(),t.perform(()=>t.autosizeColumn(o.closest("th").dataset.field)))})}function x(t,n){const i=o=>t(o),e=o=>{document.removeEventListener("pointermove",i),document.removeEventListener("pointerup",e),document.removeEventListener("pointercancel",e),n(o,o.type==="pointercancel")};document.addEventListener("pointermove",i),document.addEventListener("pointerup",e),document.addEventListener("pointercancel",e)}function y(){const t=n=>{n.stopPropagation(),n.preventDefault()};window.addEventListener("click",t,{capture:!0,once:!0}),setTimeout(()=>window.removeEventListener("click",t,{capture:!0}),0)}function b(t,n,i,e){const o=u(t,n);if(!o)return;i.preventDefault();const l=o.getBoundingClientRect().width;let r=l;t.root.classList.add("tv-resizing"),x(c=>{r=v(l+(e?i.clientX-c.clientX:c.clientX-i.clientX)),t.liveWidths.set(n,r);for(const p of f(t,n))L(p,r);const s=u(t,n),d=s?.closest("table"),a=d?.querySelector("colgroup")?.children[s.cellIndex];a&&(d.style.width=parseFloat(d.style.width)+r-parseFloat(a.style.width)+"px",a.style.width=r+"px"),t.positionPinned?.()},(c,s)=>{if(t.root.classList.remove("tv-resizing"),t.liveWidths.delete(n),r!==l){if(s)return t.renderRows();y(),t.setColumnWidth(n,r)}})}function E(t,n,i){let e=null,o=null,l=null;const r=()=>t.root.getBoundingClientRect();x(c=>{if(!e){if(Math.abs(c.clientX-i.clientX)<6)return;const h=u(t,n);if(!h)return;e=g("div",h.querySelector(".tv-sort")?.textContent??n,{className:"tv-drag-ghost"}),o=g("div",null,{className:"tv-drop-marker"}),e.setAttribute("aria-hidden","true"),o.setAttribute("aria-hidden","true"),t.root.append(e,o),t.root.classList.add("tv-moving")}const s=r();e.style.left=c.clientX-s.left+8+"px",e.style.top=c.clientY-s.top+8+"px";const d=[...t.content.querySelectorAll("thead tr:first-child th[data-field]")];l=null;let a=d.length?d.at(-1).getBoundingClientRect().right:0;for(const h of d){const m=h.getBoundingClientRect();if(c.clientX<m.left+m.width/2){l=h.dataset.field,a=m.left;break}}const p=d[0]?.closest("thead").getBoundingClientRect();o.style.left=a-s.left-1+"px",o.style.top=(p?.top??0)-s.top+"px",o.style.height=Math.min(t.content.getBoundingClientRect().bottom,(p?.bottom??0)+400)-(p?.top??0)+"px"},(c,s)=>{e&&(e.remove(),o.remove(),t.root.classList.remove("tv-moving"),y(),!s&&l!==n&&t.perform(()=>t.moveColumn(n,l)))})}export{C as MAX_WIDTH,w as MIN_WIDTH,W as enableColumnDrag,M as fitWidth,L as sizeCell};
1
+ import{el as v}from"./panel.js";const L=48,b=800,w=t=>Math.round(Math.max(L,Math.min(b,t)));function R(t,n){const i=n?n+"px":"";t.style.width=t.style.minWidth=t.style.maxWidth=i}function u(t,n){return[...t.content.querySelectorAll("thead tr.tv-heading-row th[data-field]")].find(i=>i.dataset.field===n)}function y(t,n){const i=u(t,n);if(!i)return[];const e=i.cellIndex,o=[i];for(const l of i.closest("table").rows){if(l===i.parentElement||l.classList.contains("tv-band-row")||l.cells.length<=e)continue;const r=l.cells[e];r.colSpan===1&&o.push(r)}return o}function M(t,n){const i=y(t,n);if(!i.length)return null;const e=document.createRange();let o=0;for(const l of i){const r=getComputedStyle(l),c=parseFloat(r.paddingLeft)+parseFloat(r.paddingRight)+2;let a=0;if(l.tagName==="TH")for(const s of l.children)a+=s.classList.contains("tv-resize")?0:s.offsetWidth+2;else e.selectNodeContents(l),a=e.getBoundingClientRect().width;o=Math.max(o,Math.ceil(a+c))}return w(o)}function W(t,n){const i=t.rtl??=getComputedStyle(t.root).direction==="rtl";n.tHead?.addEventListener("pointerdown",e=>{if(e.button!==0)return;const o=e.target.closest(".tv-resize");if(o)return z(t,o.closest("th").dataset.field,e,i);const l=e.target.closest(".tv-sort");l&&e.pointerType!=="touch"&&E(t,l.closest("th").dataset.field,e)}),n.tHead?.addEventListener("dblclick",e=>{const o=e.target.closest(".tv-resize");o&&(e.preventDefault(),t.perform(()=>t.autosizeColumn(o.closest("th").dataset.field)))})}function x(t,n){const i=o=>t(o),e=o=>{document.removeEventListener("pointermove",i),document.removeEventListener("pointerup",e),document.removeEventListener("pointercancel",e),n(o,o.type==="pointercancel")};document.addEventListener("pointermove",i),document.addEventListener("pointerup",e),document.addEventListener("pointercancel",e)}function C(){const t=n=>{n.stopPropagation(),n.preventDefault()};window.addEventListener("click",t,{capture:!0,once:!0}),setTimeout(()=>window.removeEventListener("click",t,{capture:!0}),0)}function z(t,n,i,e){const o=u(t,n);if(!o)return;i.preventDefault();const l=o.getBoundingClientRect().width;let r=l;t.root.classList.add("tv-resizing"),x(c=>{r=w(l+(e?i.clientX-c.clientX:c.clientX-i.clientX)),t.liveWidths.set(n,r);for(const h of y(t,n))R(h,r);const a=u(t,n),s=a?.closest("table"),d=s?.querySelector("colgroup")?.children[a.cellIndex];d&&(s.style.width=parseFloat(s.style.width)+r-parseFloat(d.style.width)+"px",d.style.width=r+"px"),t.positionPinned?.()},(c,a)=>{if(t.root.classList.remove("tv-resizing"),t.liveWidths.delete(n),r!==l){if(a)return t.renderRows();C(),t.setColumnWidth(n,r)}})}function E(t,n,i){let e=null,o=null,l=null,r=null,c=!1;const a=()=>t.root.getBoundingClientRect();x(s=>{if(!e){if(Math.abs(s.clientX-i.clientX)<6)return;const p=u(t,n);if(!p)return;e=v("div",p.querySelector(".tv-sort")?.textContent??n,{className:"tv-drag-ghost"}),o=v("div",null,{className:"tv-drop-marker"}),e.setAttribute("aria-hidden","true"),o.setAttribute("aria-hidden","true"),t.root.append(e,o),t.root.classList.add("tv-moving"),!t.state.tree&&!t.base&&(r=v("div",t.t("Drop here to group by this column"),{className:"tv-group-zone"}),r.setAttribute("aria-hidden","true"),t.chips.prepend(r))}const d=a();if(e.style.left=s.clientX-d.left+8+"px",e.style.top=s.clientY-d.top+8+"px",r){const p=r.getBoundingClientRect();if(c=s.clientX>=p.left&&s.clientX<=p.right&&s.clientY>=p.top-6&&s.clientY<=p.bottom+6,r.classList.toggle("tv-over",c),o.hidden=c,c)return}const h=[...t.content.querySelectorAll("thead tr.tv-heading-row th[data-field]")];l=null;let f=h.length?h.at(-1).getBoundingClientRect().right:0;for(const p of h){const m=p.getBoundingClientRect();if(s.clientX<m.left+m.width/2){l=p.dataset.field,f=m.left;break}}const g=h[0]?.closest("thead").getBoundingClientRect();o.style.left=f-d.left-1+"px",o.style.top=(g?.top??0)-d.top+"px",o.style.height=Math.min(t.content.getBoundingClientRect().bottom,(g?.bottom??0)+400)-(g?.top??0)+"px"},(s,d)=>{e&&(e.remove(),o.remove(),r?.remove(),t.root.classList.remove("tv-moving"),C(),!d&&c?t.perform(()=>t.groupField(n)):!d&&l!==n&&t.perform(()=>t.moveColumn(n,l)))})}export{b as MAX_WIDTH,L as MIN_WIDTH,W as enableColumnDrag,M as fitWidth,R as sizeCell};
@@ -0,0 +1 @@
1
+ import{menu as D,el as F}from"./panel.js";import{canEdit as M}from"./cell-editor.js";import{cellPosition as k}from"./grid-keys.js";const P=()=>/Mac|iPhone|iPad/.test(globalThis.navigator?.platform??""),f=t=>(P()?"⌘":"Ctrl+")+t;function S(t,i){const o=t.t,{record:e,col:n,index:g}=i,d=t.result.columns[n],u=t.columnCaption(d),s=e.raw?.[n],p=e.values[n]??"",c=t.grid?.rectangle(),w=c&&(c.bottom>c.top||c.right>c.left),m=c?c.bottom-c.top+1:1,h=!t.remote,R=M(t,d),r=p.length>24?p.slice(0,23)+"…":p,x=typeof s=="number"||typeof s=="boolean"?s:p,a=p==="",y=t.state.sort.find(v=>v.field===d),l=[{id:"copy",label:o(w?"Copy cells":"Copy"),icon:"copy",shortcut:f("C"),action:()=>t.copyCells(!1)},{id:"copyWithHeaders",label:o("Copy with headings"),icon:"copy",action:()=>t.copyCells(!0)}];t.editable&&(l.push({id:"paste",label:o("Paste"),icon:"paste",shortcut:f("V"),disabled:!R,action:()=>t.pasteFromClipboard(e.id,d)}),h&&l.push({id:"fillDown",label:o("Fill down"),icon:"fill",shortcut:f("D"),disabled:m<2,action:()=>t.grid.fillDown()})),l.push({separator:!0},{id:"filterByValue",label:a?o("Show only blanks"):o("Show only")+" “"+r+"”",icon:"filter",action:()=>t.filterByValue(d,x,!0,a)},{id:"excludeValue",label:a?o("Hide blanks"):o("Hide")+" “"+r+"”",icon:"filter-out",action:()=>t.filterByValue(d,x,!1,a)},{id:"sortAscending",label:o("Sort ascending")+" · "+u,icon:"up",checked:!!y&&!y.desc,action:()=>t.sortField(d,!1)},{id:"sortDescending",label:o("Sort descending")+" · "+u,icon:"down",checked:!!y?.desc,action:()=>t.sortField(d,!0)}),t.state.tree||l.push({id:"groupBy",label:o("Group by")+" · "+u,icon:"group",action:()=>t.groupField(d)}),l.push({separator:!0}),w&&l.push({id:"chart",label:o("Chart the selected cells")+"…",icon:"chart",action:()=>t.chartRange()}),h&&l.push({id:"find",label:o("Find")+"…",icon:"search",shortcut:f("F"),action:()=>t.openFind(a?"":p)}),t.canPinRows()&&(t.pinnedSide(e.id)?l.push({id:"unpinRow",label:o("Unpin row"),icon:"pin",action:()=>t.pinRecords([e.id],null)}):l.push({id:"pinRowTop",label:o("Pin row to top"),icon:"pin-top",action:()=>t.pinRecords([e.id],"top")},{id:"pinRowBottom",label:o("Pin row to bottom"),icon:"pin-bottom",action:()=>t.pinRecords([e.id],"bottom")}));const C=t.state;return t.options.rowDrag&&!C.sort.length&&!C.groups.length&&!C.tree&&!t.pinnedSide(e.id)&&l.push({id:"moveUp",label:o("Move up"),icon:"up",shortcut:"Alt+↑",action:()=>t.moveRecordBy(e.id,-1)},{id:"moveDown",label:o("Move down"),icon:"down",shortcut:"Alt+↓",action:()=>t.moveRecordBy(e.id,1)}),l.push({separator:!0}),t.options.detailRenderer&&l.push({id:"expand",label:o(t.isExpanded(e.id)?"Collapse details":"Expand details"),icon:"chevron",action:()=>t.toggleDetail(e,g)}),l.push({id:"details",label:o("Record details"),icon:"details",action:()=>t.details(e)}),t.editable&&h&&l.push({id:"removeRecord",label:o(m>1?"Remove records":"Remove record"),icon:"remove",action:()=>t.change("remove",{ids:m>1?t.grid.records.slice(c.top,c.bottom+1).map(v=>v.id):[e.id]})}),(!t.remote||t.remote.exportResults)&&l.push({id:"export",label:o("Export")+"…",icon:"export",action:()=>t.exportDialog()}),l}function A(t){const i=[];for(const o of t)o&&(o.separator&&(!i.length||i.at(-1).separator)||i.push(o));for(;i.at(-1)?.separator;)i.pop();return i}function B(t,i,o){const e=t.options.contextMenu;if(e===!1||!t.grid)return!1;const n=k(i),g=n&&t.grid.records[n.row];if(!g)return!1;const b=t.grid.rectangle();(n.row<b.top||n.row>b.bottom||n.col<b.left||n.col>b.right)&&t.grid.focusAt(n.row,n.col);const d=t.result,u={record:g,col:n.col,index:d.offset+d.rows.indexOf(g)};let s=S(t,u);if(typeof e=="function"){const r=t.api.getRange(),x={id:g.id,field:d.columns[n.col],value:g.raw?.[n.col]??null,text:g.values[n.col]??"",range:r};try{const a=e(s.map(y=>({...y})),x);Array.isArray(a)&&(s=a)}catch(a){console.error(a)}}if(s=A(s),!s.length)return!1;const p=t.root.getBoundingClientRect(),c=i.getBoundingClientRect(),w=o?o.x:c.left+Math.min(c.width,24),m=o?o.y:c.bottom,h=F("span",null,{className:"tv-menu-point"});h.style.left=w-p.left+"px",h.style.top=m-p.top+"px",t.root.append(h);const R=i.isConnected?i:null;return D(t.root,h,s.map(r=>r.separator?null:[String(r.label??""),()=>t.perform(()=>r.action?.()),{icon:r.icon,checked:r.checked,disabled:!!r.disabled,shortcut:r.shortcut}]),{onClose:()=>h.remove(),focusBack:R??void 0}),!0}function L(t,i){i.addEventListener("contextmenu",o=>{if(t.options.contextMenu===!1)return;const e=o.target.closest?.("td");if(!e||!k(e)||o.target.closest("input, textarea, select, .tv-detail"))return;o.preventDefault();const n=o.button===0&&o.clientX===0&&o.clientY===0;B(t,e,n?null:{x:o.clientX,y:o.clientY})}),i.addEventListener("keydown",o=>{!(o.key==="F10"&&o.shiftKey)||!k(o.target)||(o.preventDefault(),B(t,o.target.closest("td"),null))})}export{S as contextItems,L as enableContextMenu,B as openContextMenu};
@@ -0,0 +1 @@
1
+ import{el as s}from"./panel.js";import{serialToParts as k,partsToSerial as y}from"../core/numfmt.js";const S=["text","number","date","checkbox","select","multiselect","textarea"];function g(e){return S.includes(e?.editor)?e.editor:Array.isArray(e?.options)&&e.options.length?"select":e?.type==="boolean"?"checkbox":e?.type==="date"?"date":e?.type==="number"?"number":"text"}const d=(e,t=2)=>String(e).padStart(t,"0");function N(e){if(typeof e!="number"||!Number.isFinite(e))return"";const t=k(Math.floor(e));return t?`${d(t.year,4)}-${d(t.month)}-${d(t.day)}`:""}function $(e){const t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(String(e??""));return t?y(Number(t[1]),Number(t[2]),Number(t[3])):null}function h(e){return String(e??"").split(/\s*[,;]\s*/).map(t=>t.trim()).filter(Boolean)}function L(e,t,a){const l=e?.options;if(!Array.isArray(l)||!l.length||a==null||a==="")return null;const m=new Set(l.map(o=>String(o).toLowerCase()));return(t==="multiselect"?h(a):[String(a)]).every(o=>m.has(o.toLowerCase()))?null:"Choose a value from the list."}let A=0;function T(e,{raw:t,text:a,seed:l,t:m,inline:p=!1}){const o=g(e),v=e?.caption||e?.name||"";if(o==="checkbox"){const n=s("input",null,{type:"checkbox",checked:t===!0||/^(true|yes|1)$/i.test(String(a??""))});return n.className="tv-check-editor",{kind:o,node:n,focus:n,read:()=>n.checked}}if(o==="multiselect"){const n=new Set(h(a).map(c=>c.toLowerCase())),r=s("div",null,{className:"tv-choices"});r.setAttribute("role","group"),r.setAttribute("aria-label",v);const u=[];for(const c of e.options??[]){const f=s("input",null,{type:"checkbox",checked:n.has(String(c).toLowerCase())}),b=s("label",null,{className:"tv-check"});b.append(f,s("span",String(c))),r.append(b),u.push([f,String(c)])}return u.length||r.append(s("p",m("No values"),{className:"tv-muted"})),{kind:o,node:r,focus:u[0]?.[0]??r,read:()=>u.filter(([c])=>c.checked).map(([,c])=>c).join(", ")}}if(o==="textarea"){const n=s("textarea",null,{value:l??a??"",rows:p?1:4,spellcheck:!0});return p&&(n.className="tv-cell-editor tv-cell-area"),{kind:o,node:n,focus:n,read:()=>n.value}}if(o==="date"&&l==null){const n=s("input",null,{type:"date",value:N(t)});p&&(n.className="tv-cell-editor");const r=n.value;return{kind:o,node:n,focus:n,read:()=>n.value===r&&!r?a??"":n.value}}const x=o==="number"&&typeof t=="number"&&Number.isFinite(t),i=s("input",null,{value:l??(x?String(t):a??""),spellcheck:!1,autocomplete:"off"});if(p&&(i.className="tv-cell-editor",i.size=4),o==="number"&&(i.inputMode="decimal"),o==="select"){const n="tv-list-"+ ++A,r=s("datalist",null,{id:n});for(const c of e.options??[])r.append(s("option",null,{value:String(c)}));i.setAttribute("list",n);const u=s("span",null,{className:"tv-select-editor"});return u.append(i,r),{kind:o,node:u,focus:i,read:()=>i.value}}return{kind:o,node:i,focus:i,read:()=>i.value}}export{S as EDITORS,L as checkChoice,T as createEditor,g as editorKind,N as isoDate,$ as serialOf,h as splitChoices};
@@ -1 +1 @@
1
- const d=["stateChange","change","selectionChange","rangeChange","cellClick","cellDoubleClick","rowClick","rowDoubleClick","editStart","editEnd","beforeEdit","beforeAdd","beforeRemove","beforePaste","sourceLoad","viewportChange","loadStart","loadProgress","loadEnd","error"],p=new Set(d),c=t=>"on"+t[0].toUpperCase()+t.slice(1);function g(t=()=>({})){const e=new Map,o=(n,r)=>{if(!p.has(n))throw new Error(`Unknown grid event "${n}".`);if(typeof r!="function")throw new TypeError("An event handler must be a function.")};return{on(n,r){return o(n,r),e.has(n)||e.set(n,new Set),e.get(n).add(r),()=>this.off(n,r)},off(n,r){e.get(n)?.delete(r)},has(n){return typeof t()?.[c(n)]=="function"||(e.get(n)?.size??0)>0},emit(n,r){const l=[t()?.[c(n)],...e.get(n)??[]];for(const s of l){if(typeof s!="function")continue;let i;try{i=s(r)}catch(a){console.error(a);continue}i===!1&&r?.preventDefault&&r.preventDefault()}return!r?.defaultPrevented},clear(){e.clear()}}}function h(t){let e=!1;return Object.defineProperties(t,{defaultPrevented:{get:()=>e},preventDefault:{value:()=>void(e=!0)}})}const w=t=>({columns:t.map(e=>({field:e.name})),search:"",sort:[],filters:[],groups:[],collapsed:[],total:null}),f=["columns","search","filters","sort","groups","collapsed","collapseLevel","total","totalsRow","filterRow"];function m(t){const e={};for(const o of f)e[o]=JSON.stringify(t?.[o]??null);return e}function b(t,e){return f.filter(o=>t?.[o]!==e[o])}function x(t){if(typeof t=="string")return t;if(!Array.isArray(t)||!t.length)throw new TypeError('A group is named by its values, e.g. ["East"].');return t.map(e=>e==null||e===""?"":String(e).toLowerCase()).join("")}const u=t=>t.split("").length-1;function S(t,e,o,n){const r=Number.isInteger(n)&&u(e)>=n,l=new Set(t??[]);return o===r?l.delete(e):l.add(e),[...l]}function C(t,e){const o=Number.isInteger(t.collapseLevel)&&u(e)>=t.collapseLevel;return(t.collapsed??[]).includes(e)!==o}function E(t,e){const o=new Set(e),n=(t.columns??[]).filter(r=>!r.hidden&&o.has(r.field));return[...n.filter(r=>r.pinned),...n.filter(r=>!r.pinned)].map(r=>r.field)}function v(t,e,o,n){const r={field:e,desc:o===!0};return n?t.some(l=>l.field===e)?t.map(l=>l.field===e?r:l):[...t,r]:[r]}export{d as GRID_EVENTS,f as STATE_KEYS,h as cancellable,b as changedKeys,g as createEmitter,w as defaultState,E as displayOrder,x as groupPath,C as isCollapsed,c as optionName,u as pathLevel,v as sortWith,m as stateSnapshot,S as toggleCollapsed};
1
+ const d=["stateChange","change","selectionChange","rangeChange","cellClick","cellDoubleClick","rowClick","rowDoubleClick","editStart","editEnd","beforeEdit","beforeAdd","beforeRemove","beforePaste","sourceLoad","viewportChange","loadStart","loadProgress","loadEnd","rowMove","rowDrop","error"],p=new Set(d),c=t=>"on"+t[0].toUpperCase()+t.slice(1);function g(t=()=>({})){const e=new Map,o=(n,r)=>{if(!p.has(n))throw new Error(`Unknown grid event "${n}".`);if(typeof r!="function")throw new TypeError("An event handler must be a function.")};return{on(n,r){return o(n,r),e.has(n)||e.set(n,new Set),e.get(n).add(r),()=>this.off(n,r)},off(n,r){e.get(n)?.delete(r)},has(n){return typeof t()?.[c(n)]=="function"||(e.get(n)?.size??0)>0},emit(n,r){const l=[t()?.[c(n)],...e.get(n)??[]];for(const s of l){if(typeof s!="function")continue;let i;try{i=s(r)}catch(a){console.error(a);continue}i===!1&&r?.preventDefault&&r.preventDefault()}return!r?.defaultPrevented},clear(){e.clear()}}}function h(t){let e=!1;return Object.defineProperties(t,{defaultPrevented:{get:()=>e},preventDefault:{value:()=>void(e=!0)}})}const w=t=>({columns:t.map(e=>({field:e.name})),search:"",sort:[],filters:[],groups:[],collapsed:[],total:null}),f=["columns","search","filters","sort","groups","collapsed","collapseLevel","total","totalsRow","filterRow","tree","treeCollapsed","pinnedRows"];function m(t){const e={};for(const o of f)e[o]=JSON.stringify(t?.[o]??null);return e}function b(t,e){return f.filter(o=>t?.[o]!==e[o])}function x(t){if(typeof t=="string")return t;if(!Array.isArray(t)||!t.length)throw new TypeError('A group is named by its values, e.g. ["East"].');return t.map(e=>e==null||e===""?"":String(e).toLowerCase()).join("")}const u=t=>t.split("").length-1;function C(t,e,o,n){const r=Number.isInteger(n)&&u(e)>=n,l=new Set(t??[]);return o===r?l.delete(e):l.add(e),[...l]}function S(t,e){const o=Number.isInteger(t.collapseLevel)&&u(e)>=t.collapseLevel;return(t.collapsed??[]).includes(e)!==o}function E(t,e){const o=new Set(e),n=(t.columns??[]).filter(r=>!r.hidden&&o.has(r.field));return[...n.filter(r=>r.pinned),...n.filter(r=>!r.pinned)].map(r=>r.field)}function v(t,e,o,n){const r={field:e,desc:o===!0};return n?t.some(l=>l.field===e)?t.map(l=>l.field===e?r:l):[...t,r]:[r]}export{d as GRID_EVENTS,f as STATE_KEYS,h as cancellable,b as changedKeys,g as createEmitter,w as defaultState,E as displayOrder,x as groupPath,S as isCollapsed,c as optionName,u as pathLevel,v as sortWith,m as stateSnapshot,C as toggleCollapsed};
@@ -1 +1 @@
1
- import{Workbook as g}from"../core/workbook.js";import{BOOL as C,ERR as k,NUM as v,STR as b}from"../core/sheet.js";import{Engine as R}from"../calc/engine.js";import{readCsv as S,CsvWriter as B}from"../io/csv.js";import{buildBlock as T,newBlockBuffers as N}from"../io/export-blocks.js";import{buildPlan as O}from"../io/plan.js";import{writeXlsx as $}from"../io/xlsx-write.js";import{MAX_ROWS as z,MAX_COLS as I,colIndex as x}from"../core/address.js";import{display as P}from"./model.js";async function J(u,h={},i){if(/\.(?:csv|tsv|txt)$/i.test(u.name)){const e=new g;let n=0;const l={size:u.size,slice:(...a)=>u.slice(...a),stream:()=>u.stream().pipeThrough(new TransformStream({transform(a,d){n+=a.byteLength,d.enqueue(a)}}))};return await S(l,{onProgress:a=>i?.({records:Math.max(0,a-1),loaded:n,total:u.size}),delimiter:h.delimiter||(/\.tsv$/i.test(u.name)?" ":void 0),textColumns:new Set(h.textColumns),preserveIdentifiers:!0,addString:a=>e.strings.add(a),styleFor:a=>e.styles.derive(0,{numFmt:a}),onBatch:a=>e.sheet.applyBatch(a)}),{book:e,tables:[]}}const{IoClient:o}=await import("../io/client.js"),m=new o;try{const e=i?await X(u):null,n=await m.open(u,{onProgress:({cells:s})=>i?.({records:e?.columns?Math.floor(s/e.columns):null,loaded:s,total:e?.cells??null})}),{tables:l=[],names:a=[],fullCalcOnLoad:d,manualCalc:t}=m.meta;n.engine=new R(n),n.engine.manual=t,n.engine.setNames(a),n.engine.setTables(l.map(s=>({...s,sheet:n.sheets[s.sheetIndex]}))),n.engine.buildGraph({fullCalc:d}),t||await n.engine.whenIdle();const{openZip:r}=await import("../io/zip-reader.js"),c=await r(await m.packageOf(u));if([...c.entries.keys()].some(s=>s.startsWith("customXml/"))){const{DataSheets:s}=await import("../datasheets/manager.js"),p=new s(n);if(await p.load(c))for(const f of p.manager.tables.values())f.autoSync=!1,f.remote=null}return{book:n,tables:l}}finally{m.close()}}async function X(u){try{const{openZip:h}=await import("../io/zip-reader.js"),i=await h(u);let o=0,m=0,e=0;for(const n of i.entries.keys()){if(!/^xl\/worksheets\/[^/]+\.xml$/.test(n))continue;const l=(await i.stream(n)).pipeThrough(new TextDecoderStream).getReader();let a="";for(;a.length<4096&&!/<(?:\w+:)?sheetData/.test(a);){const{done:c,value:s}=await l.read();if(c)break;a+=s}l.cancel().catch(()=>{});const d=a.match(/<(?:\w+:)?dimension\s+ref="\$?([A-Z]+)\$?(\d+)(?::\$?([A-Z]+)\$?(\d+))?"/);if(!d)return null;const t=d[3]?x(d[3])-x(d[1])+1:1,r=d[4]?Number(d[4])-Number(d[2])+1:1;o+=t*r,t*r>e&&(e=t*r,m=t)}return o>1?{cells:o,columns:m}:null}catch{return null}}function q({book:u,tables:h}){const i=[];return u.sheets.forEach((o,m)=>{if(!(o.hidden||o.isChartSheet)){if(o.kindName==="table"){const e=o.view.spec,n=o.table.byName,l=t=>t.filter(r=>n.has(r.field)),a=l(e.columns).map(({field:t,caption:r,hidden:c,pinned:s,format:p})=>({field:t,caption:r,hidden:c,pinned:s,format:p})),d=a.some(t=>!t.hidden)?{columns:a,search:e.search,sort:l(e.sort),filters:l(e.filters),groups:l(e.groups).map(({field:t})=>({field:t})),total:l(e.totals)[0]??null,collapsed:[...o.view.collapsedPaths]}:null;i.push({name:o.name,sheet:m,native:!0,initialState:d,range:{r0:0,c0:0,r1:o.maxRow,c1:o.maxCol}});return}for(const e of h.filter(n=>n.sheetIndex===m))i.push({name:e.name,sheet:m,headers:e.columns,headerRows:e.headerRows,range:{r0:e.r0,c0:e.c0,r1:e.r1-e.totalsRows,c1:e.c1}});o.maxCol>=0&&o.maxRow>=0&&i.push({name:o.name,sheet:m,whole:!0,range:{r0:0,c0:0,r1:o.maxRow,c1:o.maxCol}})}}),i.sort((o,m)=>+!!o.whole-+!!m.whole)}async function G(u,h){const{view:i}=u;i.refresh();const o=i.columns,m=[],e={write:t=>{m.push(new Blob([t]))}};if(h==="csv"){const t=new B(e,",",{bom:!0});await t.batch(o.map((c,s)=>[0,s,c.caption]));let r=[];for(let c=0;c<i.filteredCount;c++)for(let s=0;s<o.length;s++){const p=o[s];r.push([c+1,s,P(p.col.get(i.perm[c]),p.format)]),r.length===2048&&(await t.batch(r),r=[])}return await t.batch(r),await t.finish(i.filteredCount),new Blob(m,{type:"text/csv;charset=utf-8"})}if(!["xlsx","pdf"].includes(h)||i.filteredCount>=z||o.length>I)throw new Error("The result exceeds the XLSX row limit or the format is unsupported.");const n=new g,l=n.sheet;if(l.name="Results",o.forEach((t,r)=>{l.setCell(0,r,b,n.strings.add(t.caption));const c=n.styles.derive(0,{numFmt:t.format});for(let s=0;s<i.filteredCount;s++){const p=i.perm[s],f=t.col.kind(p);if(!f)continue;const w=t.col.get(p),y=f===b?n.strings.add(w):f===C?Number(w):f===k?w.index:w;l.setCell(s+1,r,f,y),c&&f===v&&l.setStyle(s+1,r,c)}}),h==="pdf"){const{createPrintJob:t}=await import("../print/paginate.js"),{writeJobPdf:r}=await import("../print/render-page.js"),c=(await import("../print/page-setup.js")).getPageSetup(l);return c.fitToPage=!0,c.fitToWidth=1,c.fitToHeight=0,await r(t(n,{sheets:[0]}),e,{title:"Results"}),new Blob(m,{type:"application/pdf"})}const a=O(n,{strings:0,styles:0,sheets:0}),d=N();return await $(e,a,{block:(t,r)=>T(l,n.strings,r,d)}),new Blob(m,{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"})}export{G as exportResults,J as openFile,q as sourcesOf};
1
+ import{Workbook as k}from"../core/workbook.js";import{BOOL as T,ERR as O,NUM as D,STR as F}from"../core/sheet.js";import{Engine as W}from"../calc/engine.js";import{readCsv as _,CsvWriter as Z}from"../io/csv.js";import{buildBlock as H,newBlockBuffers as U}from"../io/export-blocks.js";import{buildPlan as G}from"../io/plan.js";import{writeXlsx as J}from"../io/xlsx-write.js";import{MAX_ROWS as A,MAX_COLS as I,colIndex as q,colName as V}from"../core/address.js";import{changeOutline as K}from"../core/whatif.js";import{display as Q}from"./model.js";async function me(a,w={},p){if(/\.(?:csv|tsv|txt)$/i.test(a.name)){const e=new k;let s=0;const u={size:a.size,slice:(...n)=>a.slice(...n),stream:()=>a.stream().pipeThrough(new TransformStream({transform(n,t){s+=n.byteLength,t.enqueue(n)}}))};return await _(u,{onProgress:n=>p?.({records:Math.max(0,n-1),loaded:s,total:a.size}),delimiter:w.delimiter||(/\.tsv$/i.test(a.name)?" ":void 0),textColumns:new Set(w.textColumns),preserveIdentifiers:!0,addString:n=>e.strings.add(n),styleFor:n=>e.styles.derive(0,{numFmt:n}),onBatch:n=>e.sheet.applyBatch(n)}),{book:e,tables:[]}}const{IoClient:o}=await import("../io/client.js"),f=new o;try{const e=p?await Y(a):null,s=await f.open(a,{onProgress:({cells:r})=>p?.({records:e?.columns?Math.floor(r/e.columns):null,loaded:r,total:e?.cells??null})}),{tables:u=[],names:n=[],fullCalcOnLoad:t,manualCalc:c}=f.meta;s.engine=new W(s),s.engine.manual=c,s.engine.setNames(n),s.engine.setTables(u.map(r=>({...r,sheet:s.sheets[r.sheetIndex]}))),s.engine.buildGraph({fullCalc:t}),c||await s.engine.whenIdle();const{openZip:m}=await import("../io/zip-reader.js"),h=await m(await f.packageOf(a));if([...h.entries.keys()].some(r=>r.startsWith("customXml/"))){const{DataSheets:r}=await import("../datasheets/manager.js"),y=new r(s);if(await y.load(h))for(const x of y.manager.tables.values())x.autoSync=!1,x.remote=null}return{book:s,tables:u}}finally{f.close()}}async function Y(a){try{const{openZip:w}=await import("../io/zip-reader.js"),p=await w(a);let o=0,f=0,e=0;for(const s of p.entries.keys()){if(!/^xl\/worksheets\/[^/]+\.xml$/.test(s))continue;const u=(await p.stream(s)).pipeThrough(new TextDecoderStream).getReader();let n="";for(;n.length<4096&&!/<(?:\w+:)?sheetData/.test(n);){const{done:h,value:r}=await u.read();if(h)break;n+=r}u.cancel().catch(()=>{});const t=n.match(/<(?:\w+:)?dimension\s+ref="\$?([A-Z]+)\$?(\d+)(?::\$?([A-Z]+)\$?(\d+))?"/);if(!t)return null;const c=t[3]?q(t[3])-q(t[1])+1:1,m=t[4]?Number(t[4])-Number(t[2])+1:1;o+=c*m,c*m>e&&(e=c*m,f=c)}return o>1?{cells:o,columns:f}:null}catch{return null}}function pe({book:a,tables:w}){const p=[];return a.sheets.forEach((o,f)=>{if(!(o.hidden||o.isChartSheet)){if(o.kindName==="table"){const e=o.view.spec,s=o.table.byName,u=c=>c.filter(m=>s.has(m.field)),n=u(e.columns).map(({field:c,caption:m,hidden:h,pinned:r,format:y})=>({field:c,caption:m,hidden:h,pinned:r,format:y})),t=n.some(c=>!c.hidden)?{columns:n,search:e.search,sort:u(e.sort),filters:u(e.filters),groups:u(e.groups).map(({field:c})=>({field:c})),total:u(e.totals)[0]??null,collapsed:[...o.view.collapsedPaths]}:null;p.push({name:o.name,sheet:f,native:!0,initialState:t,range:{r0:0,c0:0,r1:o.maxRow,c1:o.maxCol}});return}for(const e of w.filter(s=>s.sheetIndex===f))p.push({name:e.name,sheet:f,headers:e.columns,headerRows:e.headerRows,range:{r0:e.r0,c0:e.c0,r1:e.r1-e.totalsRows,c1:e.c1}});o.maxCol>=0&&o.maxRow>=0&&p.push({name:o.name,sheet:f,whole:!0,range:{r0:0,c0:0,r1:o.maxRow,c1:o.maxCol}})}}),p.sort((o,f)=>+!!o.whole-+!!f.whole)}async function he(a,w,{layout:p=null}={}){const{view:o}=a;if(o.refresh(),p&&w!=="csv")return oe(a,w,p);const f=o.columns,e=[],s={write:t=>{e.push(new Blob([t]))}};if(w==="csv"){const t=new Z(s,",",{bom:!0});await t.batch(f.map((m,h)=>[0,h,m.caption]));let c=[];for(let m=0;m<o.filteredCount;m++)for(let h=0;h<f.length;h++){const r=f[h];c.push([m+1,h,Q(r.col.get(o.perm[m]),r.format)]),c.length===2048&&(await t.batch(c),c=[])}return await t.batch(c),await t.finish(o.filteredCount),new Blob(e,{type:"text/csv;charset=utf-8"})}if(!["xlsx","pdf"].includes(w)||o.filteredCount>=A||f.length>I)throw new Error("The result exceeds the XLSX row limit or the format is unsupported.");const u=new k,n=u.sheet;return n.name="Results",f.forEach((t,c)=>{n.setCell(0,c,F,u.strings.add(t.caption));const m=u.styles.derive(0,{numFmt:t.format});for(let h=0;h<o.filteredCount;h++){const r=o.perm[h],y=t.col.kind(r);if(!y)continue;const x=t.col.get(r),S=y===F?u.strings.add(x):y===T?Number(x):y===O?x.index:x;n.setCell(h+1,c,y,S),m&&y===D&&n.setStyle(h+1,c,m)}}),L(u,n,w)}async function L(a,w,p){const o=[],f={write:u=>{o.push(new Blob([u]))}};if(p==="pdf"){const{createPrintJob:u}=await import("../print/paginate.js"),{writeJobPdf:n}=await import("../print/render-page.js"),t=(await import("../print/page-setup.js")).getPageSetup(w);return t.fitToPage=!0,t.fitToWidth=1,t.fitToHeight=0,await n(u(a,{sheets:[0]}),f,{title:"Results"}),new Blob(o,{type:"application/pdf"})}const e=G(a,{strings:0,styles:0,sheets:0}),s=U();return await J(f,e,{block:(u,n)=>H(w,a.strings,n,s)}),new Blob(o,{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"})}const z={bold:!0,fill:"#F2F2F2"},j={bold:!0,fill:"#F7F7F7"},P={good:{fill:"#D9F2E1",color:"#14532D"},bad:{fill:"#FDE0DD",color:"#8A1C12"},warn:{fill:"#FCEFC9",color:"#6B4A00"},info:{fill:"#DDE9FB",color:"#163D7A"},strong:{bold:!0}},ee={gt:"greaterThan",gte:"greaterThanOrEqual",lt:"lessThan",lte:"lessThanOrEqual",equal:"equal",notEqual:"notEqual",between:"between"},X=a=>typeof a=="number"||/^-?\d+(\.\d+)?$/.test(String(a))?String(a):`"${String(a).replace(/"/g,'""')}"`;function te(a,w,p,o,f){const e=[];for(const s of w??[]){const u={priority:f++};if(s.type==="bar")e.push({...u,type:"dataBar",formulas:[],dataBar:{cfvo:[{type:"min"},{type:"max"}],color:{rgb:"FF638EC6"},showValue:!0}});else if(s.type==="scale")e.push({...u,type:"colorScale",formulas:[],colorScale:{cfvo:[{type:"min"},{type:"percentile",val:"50"},{type:"max"}],colors:[{rgb:"FFF8696B"},{rgb:"FFFFEB84"},{rgb:"FF63BE7B"}]}});else if(s.type==="value"){const n=s.color||s.background?{...s.background&&{fill:s.background},...s.color&&{color:s.color}}:P[s.style]??P.info;a.dxfs??=[],a.dxfs.push(n);const t=a.dxfs.length-1;if(s.op==="contains"){const c=X(String(s.value));e.push({...u,dxfId:t,type:"containsText",operator:"containsText",text:String(s.value),formulas:[`NOT(ISERROR(SEARCH(${c},${o})))`]})}else e.push({...u,dxfId:t,type:"cellIs",operator:ee[s.op]??"equal",formulas:[s.value,s.op==="between"?s.value2:void 0].filter(c=>c!==void 0).map(X)})}}return e.length?{sqref:p,rules:e}:null}async function oe(a,w,p){const{view:o,table:f}=a,e=o.columns,s=new Map(p.bands??[]),u=new Map(p.widths??[]),n=new k,t=n.sheet;t.name="Results";const c=n.styles.derive(0,z),m=n.styles.derive(0,j),h=e.map(d=>n.styles.derive(0,{numFmt:d.format}));let r=0;if([...s.values()].some(Boolean)){let d=0;for(let i=0;i<=e.length;i++){const l=i<e.length?s.get(e[i].field)??"":null,b=s.get(e[d]?.field)??"";if(!(i<e.length&&l===b)){b&&(t.setCell(r,d,F,n.strings.add(b)),i-1>d&&t.addMerge({r0:r,c0:d,r1:r,c1:i-1}));for(let g=d;g<i;g++)t.setStyle(r,g,n.styles.derive(0,{...z,hAlign:"center"}));d=i}}r++}e.forEach((d,i)=>{t.setCell(r,i,F,n.strings.add(d.caption)),t.setStyle(r,i,c)});const y=++r;if(o.count+y+1>=A||e.length>I)throw new Error("The result exceeds the XLSX row limit or the format is unsupported.");const x=(d,i,l,b)=>{if(l==null||l==="")return;const g=typeof l=="number"?D:typeof l=="boolean"?T:typeof l=="string"?F:l?.index!=null?O:F,v=g===F?n.strings.add(String(l?.code??l)):g===T?Number(l):g===O?l.index:l;t.setCell(d,i,g,v),b&&t.setStyle(d,i,b)},S=a.total?.field,E=e.findIndex(d=>d.field===S),R=[],C=r;for(let d=0;d<o.count;d++,r++){const i=o.rowInfo(d);if(i.kind==="record"){a.rowValues(e,i.record).forEach((b,g)=>x(r,g,b,typeof b=="number"?h[g]:0)),R.push(o.spec.hierarchy?i.level:o.spec.groups.length);continue}x(r,0,o.groupCaption(i.node),m);for(let l=1;l<e.length;l++)t.setStyle(r,l,m);if(E>=0&&i.kind==="group"){const l=o.summaryFor(i.node,S);x(r,E,Number.isFinite(l)?l:null,n.styles.derive(m,{numFmt:e[E].format}))}R.push(i.level)}let $=0;R.forEach((d,i)=>{const l=Math.min(7,d);l&&K(t,"row",C+i,C+i,l),$=Math.max($,l)});const N=r-1;if(p.totals){const{aggregate:d}=await import("../datasheets/view.js"),i=new Map((a.layout??[]).map(l=>[l.field,l.total]));e.forEach((l,b)=>{const g=i.get(l.field),v=g?d(l.col,g,o.perm,0,o.filteredCount):null;t.setStyle(r,b,c),b===0&&!g&&x(r,0,"Total",c),Number.isFinite(v)&&x(r,b,v,n.styles.derive(c,{numFmt:g==="count"?"#,##0":l.format}))}),r++}e.forEach((d,i)=>{const l=u.get(d.field);Number.isFinite(l)&&t.cols.setSize(i,Math.round(l))}),t.colsChanged=!0,t.frozenRows=y,t.viewChanged=!0;const B=[];let M=1;if(N>=C){const d=new Map((a.layout??[]).map(i=>[i.field,i.rules]));e.forEach((i,l)=>{const b=V(l),g=te(n,d.get(i.field),`${b}${C+1}:${b}${N+1}`,`${b}${C+1}`,M);g&&(B.push(g),M+=g.rules.length)})}return B.length&&(t.cf=B,t.cfChanged=!0),L(n,t,w)}export{he as exportResults,me as openFile,pe as sourcesOf};
@@ -0,0 +1 @@
1
+ import{el as P}from"./panel.js";import{canEdit as L}from"./cell-editor.js";import{cellPosition as M}from"./grid-keys.js";import{makeFillPlan as N}from"../core/autofill.js";import{EMPTY as k,NUM as y,STR as S}from"../core/sheet.js";function D(e,s,t){return typeof e=="number"&&Number.isFinite(e)?{kind:y,value:e,text:s,format:t}:e==null&&!s?{kind:k,value:0,text:"",format:t}:{kind:S,value:0,text:typeof e=="string"?e:s,format:t}}function F(e,s){const t=N(e),n=e.length,d=[];for(let o=0;o<s;o++){const l=o%n,i=t.at(l,Math.floor(o/n));i==null?d.push(e[l].kind===y?e[l].value:e[l].kind===k?null:e[l].text):d.push(i.text!==void 0?i.text:i.value)}return d}function H(e,s){if(e.content.querySelector(".tv-fill-handle")?.remove(),!s||!e.editable||e.remote)return;const{top:t,bottom:n,left:d,right:o}=s.rectangle(),l=s.cells[n]?.[o];if(!l||!e.result.columns.slice(d,o+1).every(f=>L(e,f)))return;const i=P("span",null,{className:"tv-fill-handle"});i.setAttribute("aria-hidden","true"),i.title=e.t("Drag to fill"),l.classList.add("tv-has-handle"),l.append(i),i.addEventListener("pointerdown",f=>{f.button===0&&(f.preventDefault(),f.stopPropagation(),I(e,s,{top:t,bottom:n,left:d,right:o}))})}function I(e,s,t){let n=null;const d=new Set,o=()=>{for(const f of d)f.classList.remove("tv-fill-preview");d.clear()},l=f=>{const r=M(document.elementFromPoint(f.clientX,f.clientY));if(o(),n=null,!r)return;const p=r.row-t.bottom,c=t.top-r.row,m=r.col-t.right,u=t.left-r.col,a=Math.max(p,c,m,u);if(a<=0)return;n=a===p?{dir:"down",to:r.row}:a===c?{dir:"up",to:r.row}:a===m?{dir:"right",to:r.col}:{dir:"left",to:r.col};const h=n.dir==="down"?[t.bottom+1,r.row]:n.dir==="up"?[r.row,t.top-1]:[t.top,t.bottom],E=n.dir==="right"?[t.right+1,r.col]:n.dir==="left"?[r.col,t.left-1]:[t.left,t.right];for(let v=h[0];v<=h[1];v++)for(let g=E[0];g<=E[1];g++){const w=s.cells[v]?.[g];w&&(w.classList.add("tv-fill-preview"),d.add(w))}},i=f=>{document.removeEventListener("pointermove",l),document.removeEventListener("pointerup",i),document.removeEventListener("pointercancel",i),o(),!(f.type==="pointercancel"||!n)&&e.perform(()=>T(e,s,t,n))};document.addEventListener("pointermove",l),document.addEventListener("pointerup",i),document.addEventListener("pointercancel",i)}function T(e,s,t,{dir:n,to:d}){const o=e.result.columns,l=s.records,i=p=>e.columnIndex?.get(o[p])?.format??e.fieldIndex?.get(o[p])?.format??"General",f=(p,c)=>D(l[p].raw?.[c],l[p].values[c],i(c)),r=[];if(n==="down"||n==="up"){const p=n==="down"?d-t.bottom:t.top-d;for(let c=t.left;c<=t.right;c++){const m=[];for(let u=t.top;u<=t.bottom;u++)m.push(f(u,c));n==="up"&&m.reverse(),F(m,p).forEach((u,a)=>{const h=n==="down"?t.bottom+1+a:t.top-1-a;l[h]&&r.push({id:l[h].id,field:o[c],value:u})})}}else{const p=n==="right"?d-t.right:t.left-d;for(let c=t.top;c<=t.bottom;c++){const m=[];for(let u=t.left;u<=t.right;u++)m.push(f(c,u));n==="left"&&m.reverse(),F(m,p).forEach((u,a)=>{const h=n==="right"?t.right+1+a:t.left-1-a;o[h]&&L(e,o[h])&&r.push({id:l[c].id,field:o[h],value:u})})}}return r.length?e.change("edit",{cells:r}):!1}export{F as fillValues,H as placeFillHandle};
@@ -0,0 +1 @@
1
+ import{button as S,el as m,iconButton as C,labeled as O,modal as M,select as T}from"./panel.js";const W={contains:"Contains",notContains:"Does not contain",equal:"Equals",notEqual:"Not equal",beginsWith:"Starts with",endsWith:"Ends with",gt:"Greater than",gte:"Greater than or equal",lt:"Less than",lte:"Less than or equal",between:"Between",notBetween:"Not between",blank:"Is blank",notBlank:"Is not blank",top:"Top",bottom:"Bottom",aboveAverage:"Above average",belowAverage:"Below average",today:"Today",yesterday:"Yesterday",tomorrow:"Tomorrow",thisWeek:"This week",thisMonth:"This month",lastMonth:"Last month",thisYear:"This year",lastYear:"Last year"},R=["contains","notContains","equal","notEqual","beginsWith","endsWith","blank","notBlank"],V=["equal","notEqual","gt","gte","lt","lte","between","notBetween","top","bottom","aboveAverage","belowAverage","blank","notBlank"],G=["equal","notEqual","gt","gte","lt","lte","between","notBetween","today","yesterday","tomorrow","thisWeek","thisMonth","lastMonth","thisYear","lastYear","blank","notBlank"],q=new Set(["blank","notBlank","aboveAverage","belowAverage","today","yesterday","tomorrow","thisWeek","thisMonth","lastMonth","thisYear","lastYear"]),Y=new Set(["between","notBetween"]);function I(e){return e==="number"?V:e==="date"?G:R}function U(e,s){const n=t=>{if(t.items){const p=t.items.map(n).filter(Boolean);return p.length?p.length===1?p[0]:{[t.join==="any"?"any":"all"]:p}:null}if(!t.field||!t.op||!q.has(t.op)&&String(t.value??"").trim()==="")return null;const u={field:t.field,op:t.op};return q.has(t.op)||(u.value=t.value),Y.has(t.op)&&(u.value2=t.value2),u},a=s.map(n).filter(Boolean);return e==="any"&&a.length>1?[{any:a}]:a}function j(e){return Array.isArray(e?.any)||Array.isArray(e?.all)?(e.any??e.all).every(j):!!e?.field&&Object.hasOwn(W,e.op)&&!e.percent&&e.formula==null&&!e.fn}function D(e){const s=e.filter(t=>!t.quick&&j(t)),n=e.filter(t=>!t.quick&&!j(t)),a=t=>Array.isArray(t.any)||Array.isArray(t.all)?{join:t.any?"any":"all",items:(t.any??t.all).map(a)}:{...t};return s.length===1&&Array.isArray(s[0].any)?{join:"any",items:s[0].any.map(a),kept:n}:{join:"all",items:s.map(a),kept:n}}function z(e,s){const n=e.t,a=e.fields,t=p=>a.find(b=>b.name===p)?.type,u=D(e.state.filters);u.items.length||u.items.push({field:s??a[0]?.name,op:t(s??a[0]?.name)==="number"?"gt":"contains",value:""}),M(e.root,n("Filter"),n,(p,b)=>{const g=o=>T([["all",n("Match all conditions")],["any",n("Match any condition")]],o),w=g(u.join);w.setAttribute("aria-label",n("Join"));const A=m("div",null,{className:"tv-filter-list"}),l=(o,d,B)=>{const y=m("div",null,{className:"tv-filter-line"}),f=T(a.map(k=>[k.name,e.columnCaption(k.name)]),d.field),r=m("select"),h=m("input",null,{value:d.value??""}),v=m("input",null,{value:d.value2??""});f.setAttribute("aria-label",n("Field")),r.setAttribute("aria-label",n("Condition")),h.setAttribute("aria-label",n("Value")),v.setAttribute("aria-label",n("Second value"));const L=()=>{const k=I(t(f.value));r.replaceChildren(...k.map(N=>new Option(n(W[N]),N))),r.value=k.includes(d.op)?d.op:k[0]},x=()=>{d.field=f.value,d.op=r.value,h.hidden=q.has(r.value),v.hidden=!Y.has(r.value),h.inputMode=v.inputMode=t(f.value)==="number"||r.value==="top"||r.value==="bottom"?"decimal":"text",h.placeholder=r.value==="top"||r.value==="bottom"?n("Number of records"):""};L(),x(),f.onchange=()=>{L(),x()},r.onchange=x,h.oninput=()=>d.value=h.value,v.oninput=()=>d.value2=v.value;const P=C("close",n("Remove condition"),()=>{o.splice(o.indexOf(d),1),y.remove()});y.append(f,r,h,v,P),B.append(y)},i=o=>{const d=m("fieldset",null,{className:"tv-filter-group"}),B=m("legend"),y=g(o.join);y.setAttribute("aria-label",n("Join")),y.onchange=()=>o.join=y.value;const f=C("close",n("Remove group"),()=>{c.items.splice(c.items.indexOf(o),1),d.remove()});B.append(y,f);const r=m("div",null,{className:"tv-filter-list"});for(const v of o.items)l(o.items,v,r);const h=S(n("Add condition"),()=>{const v={field:a[0]?.name,op:"",value:""};o.items.push(v),l(o.items,v,r)});h.classList.add("tv-link"),d.append(B,r,h),A.append(d)},c={join:u.join,items:u.items};for(const o of c.items)o.items?i(o):l(c.items,o,A);w.onchange=()=>c.join=w.value;const _=S(n("Add condition"),()=>{const o={field:a[0]?.name,op:"",value:""};c.items.push(o),l(c.items,o,A)}),F=S(n("Add group"),()=>{const o={join:"any",items:[{field:a[0]?.name,op:"",value:""}]};c.items.push(o),i(o)}),E=m("div",null,{className:"tv-filter-tools"});E.append(_,F),p.append(O(n("Show records that"),w),A,E),u.kept.length&&p.append(m("p",n("Also kept")+": "+u.kept.map(o=>e.describeFilter(o)).join("; "),{className:"tv-muted"})),e.remote||e.action(p,"Pick values",()=>J(e,A.querySelector(".tv-filter-line select")?.value??s??a[0]?.name),"tv-link"),b("Clear filters",()=>e.update({filters:e.state.filters.filter(o=>o.quick),collapsed:[]}),"danger"),b("Apply",()=>e.update({filters:[...e.state.filters.filter(o=>o.quick),...u.kept,...U(c.join,c.items)],collapsed:[]}),"primary")})}async function J(e,s){const n=e.t,{values:a}=await e.client.call("distinct",{field:s});M(e.root,n("Pick values")+" · "+e.columnCaption(s),n,(t,u)=>{const p=[],b=m("input",null,{type:"search",placeholder:n("Search")});b.setAttribute("aria-label",n("Search"));const g=m("div",null,{className:"tv-values"}),w=e.state.filters.find(l=>l.field===s&&l.op==="in"),A=new Set((w?.values??[]).map(String));for(const l of a){const i=m("input",null,{type:"checkbox",checked:A.has(String(l.value))}),c=O(l.text+" ("+l.count+")",i);c.dataset.text=l.text.toLowerCase(),p.push([i,l.value]),g.append(c)}b.oninput=()=>{const l=b.value.toLowerCase();for(const i of g.children)i.hidden=!!l&&!i.dataset.text?.includes(l)},p.length?t.append(b):g.textContent=n("No values"),t.append(g),u("Apply",async()=>{const l=p.filter(([i])=>i.checked).map(([,i])=>i);await e.update({filters:[...e.state.filters.filter(i=>!(i.field===s&&i.op==="in")),...l.length?[{field:s,op:"in",values:l}]:[]],collapsed:[]});for(const i of e.root.querySelectorAll("dialog[open]"))i.close()})})}export{W as FILTER_LABELS,U as buildFilters,j as canBuild,D as editableFilters,z as filterBuilder,I as opsFor,J as pickValues};
@@ -0,0 +1 @@
1
+ import{display as g}from"./model.js";const x=250;function h(n){return n.view.columns}function v(n,s,u,f,r){const c=n.rowValues([s[f]],u);return g(c[0],s[f].format).toLowerCase().includes(r)}function L(n,{text:s,row:u=-1,col:f=-1,back:r=!1}){const c=String(s??"").toLowerCase(),l=n.view;l.refresh();const m=h(n);if(!c||!m.length||!l.count)return null;const a=l.count,t=m.length,e=a*t;let o=u<0?r?0:-1:u*t+Math.max(0,f);for(let i=0;i<e;i++){o=r?(o-1+e)%e:(o+1)%e;const d=Math.floor(o/t),p=o%t,w=l.recordAt(d);if(w<0){o=r?d*t:d*t+t-1,i+=t-1;continue}if(v(n,m,w,p,c))return{row:d,field:m[p].field,id:w}}return null}function M(n,{text:s,row:u=-1,field:f=null}){const r=String(s??"").toLowerCase(),c=n.view;c.refresh();const l=h(n);if(!r)return{count:0,index:-1,complete:!0};const m=performance.now();let a=0,t=-1;for(let e=0;e<c.count;e++){const o=c.recordAt(e);if(!(o<0)){for(let i=0;i<l.length;i++)v(n,l,o,i,r)&&(e===u&&l[i].field===f&&(t=a),a++);if((e&1023)===1023&&performance.now()-m>x)return{count:a,index:t,complete:!1}}}return{count:a,index:t,complete:!0}}export{M as countCells,L as findCells};
@@ -1,2 +1,2 @@
1
- import{parseTsv as V,quoteTsv as W}from"../core/tsv.js";import{formatNumber as X}from"../core/numfmt.js";import{canEdit as Y,startCellEdit as Z}from"./cell-editor.js";import{cancellable as B}from"./events.js";const H=(o,s)=>o.row===s.row&&o.col===s.col;function U(o){const s=o?.closest?.("td"),r=s?.parentElement?.dataset.recordIndex;if(r==null)return null;const d=s.closest("table")?.columnAt?.[s.cellIndex];return d==null||d<0?null:{row:Number(r),col:d}}function et(o,s,r){if(!r.length||!r[0].length)return;let d={row:0,col:0},l=d;const L=new Set,J=t=>({row:Math.max(0,Math.min(r.length-1,t.row)),col:Math.max(0,Math.min(r[0].length-1,t.col))});function D(){return{top:Math.min(d.row,l.row),bottom:Math.max(d.row,l.row),left:Math.min(d.col,l.col),right:Math.max(d.col,l.col)}}function g(t,e,n,a=!1){if(n&&!e&&o.virtual&&(t.row<0||t.row>=r.length)&&i.length){const c=t.row<0?0:r.length-1,f=t.row-c,x=o.focusAfter;if(x?.view!=null)x.view+=f;else{const y=o.result;o.focusAfter={view:y.offset+y.rows.indexOf(i[c])+f,col:l.col}}o.content.scrollTop+=f*o.stride;return}const u=J(t);if(!r[u.row][u.col]&&!(e&&!n)){if(!n||!o.revealColumn)return;o.focusAfter={id:i[u.row].id,col:u.col,step:{row:0,col:0}},o.revealColumn(u.col);return}l=u,e||(d=l);for(const c of L)c.classList.remove("tv-selected");L.clear();const{top:m,bottom:E,left:v,right:h}=D();let w=0,C=0,I=-1;for(let c=m;c<=E;c++)for(let f=v;f<=h;f++){const x=r[c][f],y=i[c].raw?.[f];Number.isFinite(y)&&(w++,C+=y,I<0&&(I=f)),x&&(L.add(x),x.classList.add("tv-selected"))}const j=(E-m+1)*(h-v+1),F=o.result.columns;o.setRange({anchor:{id:i[d.row].id,field:F[d.col]},focus:{id:i[l.row].id,field:F[l.col]}});const{t:K}=o,G=o.result.columns[I],M=o.columnIndex?.get(G)?.format??o.fieldIndex?.get(G)?.format,q=c=>X(M&&M!=="General"?M:Number.isInteger(c)?"#,##0":"#,##0.########",c);let z=K("Selected cells")+" "+j;if(w&&(z+=" · "+K("Sum")+" "+q(C)+" · "+K("Average")+" "+q(C/w)),o.selectionSummary.textContent=j>1?z:"",n){const c=r[l.row][l.col];b!==c&&b?.removeAttribute("tabindex"),b=c,c.tabIndex=0,c.focus({preventScroll:a})}}let b=null;const A=r[0].findIndex(Boolean);if(A<0)return;d=l={row:0,col:A},b=r[0][A],b.tabIndex=0;const i=o.result.rows.filter(t=>t.group===void 0&&!t.loading),p=U;s.addEventListener("pointerdown",t=>{const e=p(t.target);e&&t.button===0&&g(e,t.shiftKey,!0)});function N(){const{top:t,bottom:e,left:n,right:a}=D(),u=[];for(let m=t;m<=e;m++)u.push(i[m].values.slice(n,a+1).map(W).join(" "));return u.join(`\r
2
- `)}function S(t="user"){const{top:e,bottom:n,left:a,right:u}=D(),m=o.result.columns,E=i[e],v=[];for(let h=e+1;h<=n;h++)for(let w=a;w<=u;w++)v.push({id:i[h].id,field:m[w],value:E.raw[w]});return v.length?o.change("edit",{cells:v},t):Promise.resolve(!1)}function Q(t,e){const n=i.findIndex(u=>u.id===t),a=o.result.columns.indexOf(e);return n<0||a<0?null:{row:n,col:a}}const O={focus:t=>t&&g({row:l.row+t.row,col:l.col+t.col},!1,!0),focusAt:(t,e,n)=>g({row:t,col:e},!1,!0,n),select(t,e,n){g(t,!1,!1),(n||!H(t,e))&&g(e,!0,n,!0)},rectangle:D,focused(){const t=U(document.activeElement);return t&&i[t.row]?{id:i[t.row].id,field:o.result.columns[t.col]}:null},copyText:N,fillDown:S,positionOf:Q,edit:(t,e)=>k(t,e),records:i,cells:r},k=(t,e)=>!!r[t.row][t.col]&&Z(o,r[t.row][t.col],i[t.row],t.col,e,O),P=t=>t.closest?.("button, input, select, textarea, a, .tv-detail"),T=t=>{const e=t.closest?.("tr")?.dataset.recordIndex;return e==null?null:i[Number(e)]},R=(t,e,n)=>({id:t.id,field:o.result.columns[e.col],text:t.values[e.col]??"",value:t.raw?.[e.col]??null,event:n});return s.addEventListener("click",t=>{const e=P(t.target)?null:T(t.target);if(!e)return;const n=p(t.target);n&&o.emit("cellClick",R(e,n,t)),o.emit("rowClick",{id:e.id,field:n?o.result.columns[n.col]:null,event:t})}),s.addEventListener("dblclick",t=>{const e=P(t.target)?null:T(t.target);if(!e)return;const n=p(t.target);let a=!0;if(n&&(a=o.emit("cellDoubleClick",B(R(e,n,t)))),a=o.emit("rowDoubleClick",B({id:e.id,field:n?o.result.columns[n.col]:null,event:t}))&&a,!a){t.stopPropagation(),t.preventDefault();return}n&&Y(o,o.result.columns[n.col])&&k(n)&&t.stopPropagation()},!0),s.addEventListener("pointerover",t=>{const e=p(t.target);e&&t.buttons===1&&!H(e,l)&&g(e,!0,!1)}),s.addEventListener("copy",t=>{p(t.target)&&(t.clipboardData.setData("text/plain",N()),t.preventDefault())}),s.addEventListener("paste",t=>{if(!o.editable||!p(t.target))return;t.preventDefault();const e=V(t.clipboardData.getData("text/plain"));o.perform(()=>o.change("paste",{id:i[l.row].id,field:o.result.columns[l.col],lines:e,repeat:1}))}),s.addEventListener("keydown",t=>{if(!p(t.target))return;const e=t.ctrlKey||t.metaKey;if(e&&o.editable&&!o.remote&&["z","y","d"].includes(t.key.toLowerCase())){t.preventDefault(),t.key.toLowerCase()==="d"?o.perform(()=>S()):o.perform(()=>o.change(t.shiftKey||t.key.toLowerCase()==="y"?"redo":"undo"));return}const n={...l};switch(t.key){case"ArrowLeft":n.col--;break;case"ArrowRight":n.col++;break;case"ArrowUp":n.row--;break;case"ArrowDown":n.row++;break;case"Home":n.col=0,e&&(n.row=0);break;case"End":n.col=r[0].length-1,e&&(n.row=r.length-1);break;case" ":if(!o.selection||e)return;t.preventDefault(),o.toggleRecord(i[n.row]);return;case"Enter":case"F2":if(t.preventDefault(),!t.shiftKey&&k(n))return;o.perform(()=>o.details(i[n.row]));return;default:t.key.length===1&&!e&&!t.altKey&&k(n,t.key)&&t.preventDefault();return}t.preventDefault(),g(n,t.shiftKey,!0)}),O}export{U as cellPosition,et as enableGridKeys};
1
+ import{parseTsv as W,quoteTsv as H}from"../core/tsv.js";import{formatNumber as X}from"../core/numfmt.js";import{canEdit as Y,startCellEdit as Z}from"./cell-editor.js";import{editorKind as _}from"./editors.js";import{placeFillHandle as $}from"./fill-handle.js";import{cancellable as q}from"./events.js";const z=(o,d)=>o.row===d.row&&o.col===d.col;function J(o){const d=o?.closest?.("td"),l=d?.parentElement?.dataset.recordIndex;if(l==null)return null;const u=d.closest("table")?.columnAt?.[d.cellIndex];return u==null||u<0?null:{row:Number(l),col:u}}function it(o,d,l){if(!l.length||!l[0].length)return;let u={row:0,col:0},r=u;const E=new Set,Q=t=>({row:Math.max(0,Math.min(l.length-1,t.row)),col:Math.max(0,Math.min(l[0].length-1,t.col))});function A(){return{top:Math.min(u.row,r.row),bottom:Math.max(u.row,r.row),left:Math.min(u.col,r.col),right:Math.max(u.col,r.col)}}function g(t,e,n,c=!1){if(n&&!e&&o.virtual&&(t.row<0||t.row>=l.length)&&i.length){const s=t.row<0?0:l.length-1,f=t.row-s,b=o.focusAfter;if(b?.view!=null)b.view+=f;else{const k=o.result;o.focusAfter={view:k.offset+k.rows.indexOf(i[s])+f,col:r.col}}o.content.scrollTop+=f*o.stride;return}const a=Q(t);if(!l[a.row][a.col]&&!(e&&!n)){if(!n||!o.revealColumn)return;o.focusAfter={id:i[a.row].id,col:a.col,step:{row:0,col:0}},o.revealColumn(a.col);return}r=a,e||(u=r);for(const s of E)s.classList.remove("tv-selected");E.clear();const{top:w,bottom:m,left:h,right:x}=A();let p=0,I=0,K=-1;for(let s=w;s<=m;s++)for(let f=h;f<=x;f++){const b=l[s][f],k=i[s].raw?.[f];Number.isFinite(k)&&(p++,I+=k,K<0&&(K=f)),b&&(E.add(b),b.classList.add("tv-selected"))}const j=(m-w+1)*(x-h+1),F=o.result.columns;o.setRange({anchor:{id:i[u.row].id,field:F[u.col]},focus:{id:i[r.row].id,field:F[r.col]}});const{t:M}=o,U=o.result.columns[K],N=o.columnIndex?.get(U)?.format??o.fieldIndex?.get(U)?.format,B=s=>X(N&&N!=="General"?N:Number.isInteger(s)?"#,##0":"#,##0.########",s);let G=M("Selected cells")+" "+j;if(p&&(G+=" · "+M("Sum")+" "+B(I)+" · "+M("Average")+" "+B(I/p)),o.selectionSummary.textContent=j>1?G:"",$(o,C),n){const s=l[r.row][r.col];y!==s&&y?.removeAttribute("tabindex"),y=s,s.tabIndex=0,s.focus({preventScroll:c})}}let y=null;const L=l[0].findIndex(Boolean);if(L<0)return;u=r={row:0,col:L},y=l[0][L],y.tabIndex=0;const i=o.result.rows.filter(t=>t.group===void 0&&!t.loading),v=J;d.addEventListener("pointerdown",t=>{const e=v(t.target);e&&t.button===0&&g(e,t.shiftKey,!0)});function S(t=!1){const{top:e,bottom:n,left:c,right:a}=A(),w=[];t&&w.push(o.result.columns.slice(c,a+1).map(m=>H(o.columnCaption(m))).join(" "));for(let m=e;m<=n;m++)w.push(i[m].values.slice(c,a+1).map(H).join(" "));return w.join(`\r
2
+ `)}function O(t="user"){const{top:e,bottom:n,left:c,right:a}=A(),w=o.result.columns,m=i[e],h=[];for(let x=e+1;x<=n;x++)for(let p=c;p<=a;p++)h.push({id:i[x].id,field:w[p],value:m.raw[p]});return h.length?o.change("edit",{cells:h},t):Promise.resolve(!1)}function V(t,e){const n=i.findIndex(a=>a.id===t),c=o.result.columns.indexOf(e);return n<0||c<0?null:{row:n,col:c}}const C={focus:t=>t&&g({row:r.row+t.row,col:r.col+t.col},!1,!0),focusAt:(t,e,n)=>g({row:t,col:e},!1,!0,n),select(t,e,n){g(t,!1,!1),(n||!z(t,e))&&g(e,!0,n,!0)},rectangle:A,focused(){const t=J(document.activeElement);return t&&i[t.row]?{id:i[t.row].id,field:o.result.columns[t.col]}:null},copyText:S,fillDown:O,positionOf:V,edit:(t,e)=>D(t,e),records:i,cells:l},D=(t,e)=>!!l[t.row][t.col]&&Z(o,l[t.row][t.col],i[t.row],t.col,e,C),P=t=>t.closest?.("button, input, select, textarea, a, .tv-detail"),R=t=>{const e=t.closest?.("tr")?.dataset.recordIndex;return e==null?null:i[Number(e)]},T=(t,e,n)=>({id:t.id,field:o.result.columns[e.col],text:t.values[e.col]??"",value:t.raw?.[e.col]??null,event:n});return d.addEventListener("click",t=>{const e=P(t.target)?null:R(t.target);if(!e)return;const n=v(t.target);n&&o.emit("cellClick",T(e,n,t)),o.emit("rowClick",{id:e.id,field:n?o.result.columns[n.col]:null,event:t})}),d.addEventListener("dblclick",t=>{const e=P(t.target)?null:R(t.target);if(!e)return;const n=v(t.target);let c=!0;if(n&&(c=o.emit("cellDoubleClick",q(T(e,n,t)))),c=o.emit("rowDoubleClick",q({id:e.id,field:n?o.result.columns[n.col]:null,event:t}))&&c,!c){t.stopPropagation(),t.preventDefault();return}n&&Y(o,o.result.columns[n.col])&&D(n)&&t.stopPropagation()},!0),d.addEventListener("pointerover",t=>{const e=v(t.target);e&&t.buttons===1&&!z(e,r)&&g(e,!0,!1)}),d.addEventListener("copy",t=>{v(t.target)&&(t.clipboardData.setData("text/plain",S()),t.preventDefault())}),d.addEventListener("paste",t=>{if(!o.editable||!v(t.target))return;t.preventDefault();const e=W(t.clipboardData.getData("text/plain"));o.perform(()=>o.change("paste",{id:i[r.row].id,field:o.result.columns[r.col],lines:e,repeat:1}))}),d.addEventListener("keydown",t=>{if(!v(t.target))return;const e=t.ctrlKey||t.metaKey;if(e&&o.editable&&!o.remote&&["z","y","d"].includes(t.key.toLowerCase())){t.preventDefault(),t.key.toLowerCase()==="d"?o.perform(()=>O()):o.perform(()=>o.change(t.shiftKey||t.key.toLowerCase()==="y"?"redo":"undo"));return}if(t.altKey&&!e&&(t.key==="ArrowUp"||t.key==="ArrowDown")&&o.options.rowDrag){t.preventDefault();const c=i[r.row];o.focusAfter={id:c.id,col:r.col,step:{row:0,col:0}},o.perform(()=>o.moveRecordBy(c.id,t.key==="ArrowUp"?-1:1));return}const n={...r};switch(t.key){case"ArrowLeft":n.col--;break;case"ArrowRight":n.col++;break;case"ArrowUp":n.row--;break;case"ArrowDown":n.row++;break;case"Home":n.col=0,e&&(n.row=0);break;case"End":n.col=l[0].length-1,e&&(n.row=l.length-1);break;case" ":if(!e&&_(o.fieldIndex?.get(o.result.columns[n.col]))==="checkbox"&&D(n," ")){t.preventDefault();return}if(!o.selection||e)return;t.preventDefault(),o.toggleRecord(i[n.row]);return;case"Enter":case"F2":if(t.preventDefault(),!t.shiftKey&&D(n))return;o.perform(()=>o.details(i[n.row]));return;default:t.key.length===1&&!e&&!t.altKey&&D(n,t.key)&&t.preventDefault();return}t.preventDefault(),g(n,t.shiftKey,!0)}),C}export{J as cellPosition,it as enableGridKeys};
@@ -0,0 +1 @@
1
+ var e={"Autosize column":"Spaltenbreite anpassen","Drag to resize, double-click to fit":"Zum Ändern der Breite ziehen, zum Anpassen doppelklicken",Dismiss:"Hinweis schließen","Filter row":"Filterzeile","Clear column filters":"Spaltenfilter löschen","Greater than or equal":"Größer oder gleich","Less than or equal":"Kleiner oder gleich","Open a row with its arrow to see the order lines. One order opens at a time and scrolls with the records.":"Öffnen Sie eine Zeile mit ihrem Pfeil, um die Bestellpositionen zu sehen. Es ist jeweils eine Bestellung geöffnet, die mit den Datensätzen mitscrollt.","Tick rows, or the header box for every match. Drag across cells and press Ctrl+C to copy them. Export offers the selected rows.":"Aktivieren Sie Zeilen oder das Kästchen in der Kopfzeile für alle Treffer. Ziehen Sie über Zellen und drücken Sie Ctrl+C, um sie zu kopieren. Beim Exportieren werden die ausgewählten Zeilen angeboten.",Quantity:"Menge",Price:"Preis",Amount:"Betrag",Total:"Gesamt","Order lines":"Bestellpositionen","Order no.":"Bestell-Nr.",Product:"Produkt","Expand details":"Details erweitern","Collapse details":"Details reduzieren","Conditional formatting":"Bedingte Formatierung","Data bar":"Datenbalken","Colour scale":"Farbskala","Green fill":"Grüne Füllung","Red fill":"Rote Füllung","Amber fill":"Gelbe Füllung","Blue fill":"Blaue Füllung","Bold text":"Fetter Text",Custom:"Benutzerdefiniert","No rules":"Keine Regeln",Style:"Stil",Rule:"Regel","Add rule":"Regel hinzufügen","Clear rules":"Regeln löschen","Drag a header edge to resize it and double-click to fit, drag a header to move it. Bars, colour scales and the totals row cover every matching record.":"Ziehen Sie den Rand einer Spaltenüberschrift, um die Breite zu ändern, doppelklicken Sie, um sie anzupassen, und ziehen Sie eine Überschrift, um die Spalte zu verschieben. Balken, Farbskalen und die Summenzeile umfassen alle passenden Datensätze.",Totals:"Summen","No total":"Keine Summe","Select all matching records":"Alle passenden Datensätze auswählen","Select record":"Datensatz auswählen",selected:"ausgewählt","All matching selected":"Alle Treffer ausgewählt","All matching selected except":"Alle Treffer ausgewählt außer","Clear selection":"Auswahl aufheben","All matching records":"Alle passenden Datensätze","Selected records":"Ausgewählte Datensätze",Records:"Datensätze","Select records to export first.":"Wählen Sie zuerst die zu exportierenden Datensätze aus.","This source cannot export selected records.":"Diese Quelle kann ausgewählte Datensätze nicht exportieren.","Row selection is off for this table.":"Die Zeilenauswahl ist für diese Tabelle deaktiviert.","Wait for the records to load.":"Warten Sie, bis die Datensätze geladen sind.","Search “East”, open a column menu to sort, filter, group or pin, and select cells to see their sum.":"Suchen Sie nach “East”, öffnen Sie ein Spaltenmenü, um zu sortieren, zu filtern, zu gruppieren oder anzuheften, und wählen Sie Zellen aus, um ihre Summe zu sehen.","One million orders generated off the main thread. Type “>30” under Units or a name under Customer, sort or group: the work runs in a Worker.":"Eine Million Bestellungen, außerhalb des Hauptthreads erzeugt. Geben Sie “>30” unter Units oder einen Namen unter Customer ein, sortieren oder gruppieren Sie: Die Arbeit läuft in einem Worker.","Rows arrive in blocks of 100 from a simulated server with 150–400 ms latency and an unknown total. Scroll quickly, then sort or search.":"Zeilen kommen in Blöcken zu 100 von einem simulierten Server mit 150–400 ms Latenz und unbekannter Gesamtzahl. Scrollen Sie schnell, dann sortieren oder suchen Sie.","An editable copy: double-click a cell or press Enter to edit, Ctrl+Z to undo. Units must be a whole number from 1 to 500.":"Eine bearbeitbare Kopie: Doppelklicken Sie auf eine Zelle oder drücken Sie Enter zum Bearbeiten, Ctrl+Z zum Rückgängigmachen. Units muss eine ganze Zahl von 1 bis 500 sein.","Choose East, West, North or South.":"Wählen Sie East, West, North oder South.","Units must be a whole number from 1 to 500.":"Units muss eine ganze Zahl von 1 bis 500 sein.","Shift-click to sort by another column":"Shift+Klick, um nach einer weiteren Spalte zu sortieren","Selected cells":"Ausgewählte Zellen","System theme":"Systemdesign","Light theme":"Helles Design","Dark theme":"Dunkles Design","Custom theme":"Benutzerdefiniertes Design",Theme:"Design","Column menu":"Spaltenmenü","Sort ascending":"Aufsteigend sortieren","Sort descending":"Absteigend sortieren","Clear sort":"Sortierung löschen","Hide column":"Spalte ausblenden","is one of":"ist eines von","Clear all":"Alle löschen",Unpin:"Lösen",Ungroup:"Gruppierung aufheben","The data changed. Reopen the record before editing.":"Die Daten haben sich geändert. Öffnen Sie den Datensatz vor dem Bearbeiten erneut.",Rows:"Zeilen",Chart:"Diagramm",Pivot:"Pivot-Tabelle","Back to records":"Zurück zu den Datensätzen","Top 20 by absolute value":"Top 20 nach Absolutwert","Choose different row and column fields.":"Wählen Sie unterschiedliche Zeilen- und Spaltenfelder.","Pick values":"Werte auswählen","No values":"Keine Werte","Back to workbook":"Zurück zur Arbeitsmappe","Read columns as text":"Spalten als Text lesen",Delimiter:"Trennzeichen",Automatic:"Automatisch","Reimport CSV":"CSV erneut importieren","Add record":"Datensatz hinzufügen","Remove record":"Datensatz entfernen",Width:"Breite",Share:"Teilen","Share link":"Freigabelink","Copy link":"Link kopieren","Revoke link":"Link widerrufen","Publish filtered copy":"Gefilterte Kopie veröffentlichen","Prepare file":"Datei vorbereiten","This share link has expired or was revoked.":"Dieser Freigabelink ist abgelaufen oder wurde widerrufen.",Pages:"Seiten",Scroll:"Bildlauf","Table view":"Tabellenansicht","Open file":"Datei öffnen","Open workbook":"Arbeitsmappe öffnen","Sales example":"Verkaufsbeispiel","Open a table":"Tabelle öffnen","Choose a CSV or Excel file to explore its records.":"Wählen Sie eine CSV- oder Excel-Datei, um ihre Datensätze zu durchsuchen.","Search records":"Datensätze durchsuchen",Filter:"Filter",Group:"Gruppieren",Columns:"Spalten",Views:"Ansichten",Export:"Exportieren",Sort:"Sortieren",Apply:"Übernehmen",Cancel:"Abbrechen",Close:"Schließen",Field:"Feld",Condition:"Bedingung",Value:"Wert",Contains:"Enthält",Equals:"Ist gleich","Greater than":"Größer als","Less than":"Kleiner als","Is blank":"Ist leer","Starts with":"Beginnt mit","Not equal":"Ist nicht gleich",Between:"Zwischen","Second value":"Zweiter Wert","Is not blank":"Ist nicht leer",Ascending:"Aufsteigend",Descending:"Absteigend",Remove:"Entfernen","Reset view":"Ansicht zurücksetzen",None:"Keine",Summary:"Zusammenfassung",Sum:"Summe",Average:"Mittelwert",Minimum:"Minimum",Maximum:"Maximum",Count:"Anzahl",Distinct:"Eindeutige Anzahl",Visible:"Sichtbar",Pin:"Anheften","Move up":"Nach oben","Move down":"Nach unten","Save view":"Ansicht speichern","View name":"Ansichtsname",Restore:"Wiederherstellen","Record details":"Datensatzdetails",Details:"Details",Previous:"Zurück",Next:"Weiter",Page:"Seite",of:"von",records:"Datensätzen","Export results":"Ergebnisse exportieren","No matching records":"Keine passenden Datensätze","Clear filters":"Filter löschen","Loading…":"Wird geladen…","A new version of 8sheets is ready.":"Eine neue Version von 8sheets ist verfügbar.",Reload:"Neu laden",Later:"Später","Reload and lose your unsaved edits?":"Neu laden und nicht gespeicherte Änderungen verlieren?","8sheets was updated in another tab. Save your work, then reload to use the new version.":"8sheets wurde in einem anderen Tab aktualisiert. Speichern Sie Ihre Arbeit und laden Sie dann neu, um die neue Version zu verwenden.",Opening:"Wird geöffnet:","Preparing records":"Datensätze werden vorbereitet","Loading records":"Datensätze werden geladen","Building pivot":"Pivot-Tabelle wird erstellt","Generating records":"Datensätze werden generiert","Records read":"Gelesene Datensätze","Cancelling…":"Wird abgebrochen…","Loading cancelled.":"Laden abgebrochen.",Loaded:"Geladen","No data":"Keine Daten",Table:"Tabelle",Source:"Quelle",Range:"Bereich","First row contains headers":"Erste Zeile enthält Überschriften","Edit copy":"Kopie bearbeiten","Editing copy":"Kopie wird bearbeitet","Save changes":"Änderungen speichern",Undo:"Rückgängig",Redo:"Wiederholen","Calculated field":"Berechnetes Feld",Formula:"Formel",Name:"Name",Add:"Hinzufügen","Group by":"Gruppieren nach","Sort by":"Sortieren nach","Add group":"Gruppe hinzufügen","Add sort":"Sortierung hinzufügen",Order:"Reihenfolge","Use Tab to separate fields and a new line for each record.":"Trennen Sie Felder mit Tab und jeden Datensatz mit einer neuen Zeile.","Paste rows":"Zeilen einfügen","Starting field":"Startfeld","Changes live in this copy until exported.":"Änderungen bleiben bis zum Export in dieser Kopie.","Choose at least one visible column.":"Wählen Sie mindestens eine sichtbare Spalte.","No saved views":"Keine gespeicherten Ansichten","Rows per page":"Zeilen pro Seite","Choose source":"Quelle auswählen",Format:"Format","Copy row":"Zeile kopieren",Copied:"Kopiert",Download:"Herunterladen","Local file":"Lokale Datei","View settings":"Ansichtseinstellungen","Saved views":"Gespeicherte Ansichten","Paste exceeds the available records or columns.":"Die eingefügten Daten überschreiten die verfügbaren Datensätze oder Spalten.","Editing is disabled for this view.":"Die Bearbeitung ist für diese Ansicht deaktiviert.","Save or discard your local edits before replacing this table. Continue?":"Speichern oder verwerfen Sie Ihre lokalen Änderungen, bevor Sie diese Tabelle ersetzen. Fortfahren?","Select a value":"Wert auswählen","No table loaded":"Keine Tabelle geladen",Filters:"Filter",Print:"Drucken","Fill down":"Nach unten ausfüllen","Number of records":"Anzahl der Datensätze","Original workbook":"Ursprüngliche Arbeitsmappe",Edit:"Bearbeiten",Reset:"Zurücksetzen",Saved:"Gespeichert","Choose a range inside the source.":"Wählen Sie einen Bereich innerhalb der Quelle.","Choose an unused column name and a formula.":"Wählen Sie einen nicht verwendeten Spaltennamen und eine Formel.","This view is read-only.":"Diese Ansicht ist schreibgeschützt.","This file contains no visible data.":"Diese Datei enthält keine sichtbaren Daten.","This field is read-only.":"Dieses Feld ist schreibgeschützt.","Field unavailable.":"Feld nicht verfügbar.","Record unavailable.":"Datensatz nicht verfügbar.","Invalid column.":"Ungültige Spalte.","This source is read-only.":"Diese Quelle ist schreibgeschützt.","This field or record is read-only.":"Dieses Feld oder dieser Datensatz ist schreibgeschützt.","Use the record editor for this source.":"Verwenden Sie für diese Quelle den Datensatz-Editor.","The selection changed. Open Table view again.":"Die Auswahl hat sich geändert. Öffnen Sie die Tabellenansicht erneut.","The result exceeds the XLSX row limit or the format is unsupported.":"Das Ergebnis überschreitet das XLSX-Zeilenlimit, oder das Format wird nicht unterstützt.","The pivot exceeds the worksheet dimensions.":"Die Pivot-Tabelle überschreitet die Abmessungen des Arbeitsblatts.","File sharing is unavailable on this device.":"Dateifreigabe ist auf diesem Gerät nicht verfügbar.","Allow opening the workbook in a new tab.":"Erlauben Sie das Öffnen der Arbeitsmappe in einem neuen Tab.","The example could not be opened.":"Das Beispiel konnte nicht geöffnet werden.","Invalid snapshot address.":"Ungültige Snapshot-Adresse.","Invalid table response.":"Ungültige Tabellenantwort.","Table view closed.":"Tabellenansicht geschlossen.","Add condition":"Bedingung hinzufügen","Add value":"Wert hinzufügen",Ask:"Fragen","Ask for a view in your own words":"Beschreiben Sie die gewünschte Ansicht in eigenen Worten","Chart the selected cells":"Diagramm aus ausgewählten Zellen","Chart type":"Diagrammtyp","Close find":"Suche schließen",Column:"Säule","Column name":"Spaltenname",Comfortable:"Komfortabel",Compact:"Kompakt","Copy with headings":"Mit Überschriften kopieren","Done.":"Fertig.","Download SVG":"SVG herunterladen","Draw the numbers in the cell, or the values of these fields:":"Zahlen aus der Zelle oder die Werte dieser Felder darstellen:","Each record goes under the record whose key its parent field holds. Or give a field with an outline level instead.":"Jeder Datensatz wird unter dem Datensatz eingeordnet, dessen Schlüssel in seinem übergeordneten Feld steht. Oder geben Sie stattdessen ein Feld mit einer Gliederungsebene an.",Find:"Suchen","Find in cells":"In Zellen suchen","For example: revenue by region for 2026, largest first":"Zum Beispiel: Umsatz nach Region für 2026, größter zuerst",Hide:"Ausblenden","Hide blanks":"Leere ausblenden",Index:"Index",Join:"Verknüpfung","Keep the layout: groups, totals, widths and formatting":"Layout beibehalten: Gruppen, Summen, Breiten und Formatierung","Key field":"Schlüsselfeld","Level field":"Ebenenfeld",Line:"Linie","Match all conditions":"Alle Bedingungen erfüllen","Match any condition":"Eine beliebige Bedingung erfüllen","Next match":"Nächster Treffer","No calculation":"Keine Berechnung",Normal:"Normal","% of column total":"% des Spaltengesamtergebnisses","% of grand total":"% des Gesamtergebnisses","% of row total":"% des Zeilengesamtergebnisses","Parent field":"Übergeordnetes Feld",Paste:"Einfügen","Pin row to bottom":"Zeile unten anheften","Pin row to top":"Zeile oben anheften","Previous match":"Vorheriger Treffer","Rank, largest first":"Rangfolge, größter zuerst","Rank, smallest first":"Rangfolge, kleinster zuerst","Remove condition":"Bedingung entfernen","Remove group":"Gruppe entfernen","Rename column":"Spalte umbenennen","Row height":"Zeilenhöhe","Running total":"Laufende Summe",Search:"Suchen","Show as tree":"Als Baumstruktur anzeigen","Show only":"Nur anzeigen","Show only blanks":"Nur leere anzeigen","Show records that":"Datensätze anzeigen, die","Show values as":"Werte anzeigen als",Sparkline:"Sparkline","Then by":"Dann nach","Thinking…":"Denke nach…",Type:"Typ","Unpin row":"Zeile lösen",Values:"Werte","Win/loss":"Gewinn/Verlust",Tree:"Baumstruktur",Pinned:"Angeheftet",row:"Zeile",rows:"Zeilen","any of":"mindestens eine","all of":"alle","is none of":"ist keines von",Copy:"Kopieren","Copy cells":"Zellen kopieren",Expand:"Erweitern",Collapse:"Reduzieren","Remove records":"Datensätze entfernen","Show as tree…":"Als Baumstruktur anzeigen…","Drop here to group by this column":"Hier ablegen, um nach dieser Spalte zu gruppieren","Drag to move":"Zum Verschieben ziehen","Move record":"Datensatz verschieben","Drag to fill":"Zum Ausfüllen ziehen","No matches":"Keine Treffer",matches:"Treffer","Choose a value from the list.":"Wählen Sie einen Wert aus der Liste.",OK:"OK",Bar:"Balken",Pie:"Kreis","Clear the sort and the groups to move records.":"Heben Sie Sortierung und Gruppen auf, um Datensätze zu verschieben.","Unpin the rows before moving them.":"Lösen Sie die Zeilen, bevor Sie sie verschieben.","Remove sparkline":"Sparkline entfernen","Remove tree":"Baumstruktur entfernen","Choose the key field and the parent field.":"Wählen Sie das Schlüsselfeld und das übergeordnete Feld.","The answer could not be applied.":"Die Antwort konnte nicht angewendet werden.","Choose a row field and a value.":"Wählen Sie ein Zeilenfeld und einen Wert.","Select cells with numbers to chart them.":"Wählen Sie Zellen mit Zahlen aus, um ein Diagramm zu erstellen.","A tree needs a parent field, or a level field.":"Eine Baumstruktur benötigt ein übergeordnetes Feld oder ein Ebenenfeld.","A tree needs a key field that its parent field refers to.":"Eine Baumstruktur benötigt ein Schlüsselfeld, auf das ihr übergeordnetes Feld verweist.","Find needs local records; search the server source instead.":"Suchen erfordert lokale Datensätze; durchsuchen Sie stattdessen die Serverquelle.","This source cannot pin rows.":"Diese Quelle kann keine Zeilen anheften.","Asking needs the assistant option.":"Fragen erfordert die Option assistant.","Select cells first.":"Wählen Sie zuerst Zellen aus.",'Pin rows to "top" or "bottom".':'Heften Sie Zeilen an "top" oder "bottom" an.',"The records are not shown as a tree.":"Die Datensätze werden nicht als Baumstruktur angezeigt.","Does not contain":"Enthält nicht","Ends with":"Endet mit","Not between":"Nicht zwischen",Top:"Obere",Bottom:"Untere","Above average":"Über dem Durchschnitt","Below average":"Unter dem Durchschnitt",Today:"Heute",Yesterday:"Gestern",Tomorrow:"Morgen","This week":"Diese Woche","This month":"Dieser Monat","Last month":"Letzter Monat","This year":"Dieses Jahr","Last year":"Letztes Jahr","A company as a tree: open and close managers with their arrows. Salaries roll up to each manager. Edit an office from its list, a start date in the picker, skills as several choices.":"Ein Unternehmen als Baumstruktur: Öffnen und schließen Sie Vorgesetzte mit ihren Pfeilen. Gehälter werden bei jedem Vorgesetzten summiert. Wählen Sie ein Büro aus seiner Liste, ein Startdatum in der Datumsauswahl und Fähigkeiten als Mehrfachauswahl.","Prices change twice a second and the changed cells flash. Right-click a cell for its menu, drag a row by its grip, pin a row to the top, or press Ctrl+F to find a product.":"Die Preise ändern sich zweimal pro Sekunde, und geänderte Zellen blinken auf. Klicken Sie mit der rechten Maustaste auf eine Zelle für ihr Menü, ziehen Sie eine Zeile an ihrem Griff, heften Sie eine Zeile oben an oder drücken Sie Ctrl+F, um ein Produkt zu suchen.","Orders as a pivot: regions and channels down, product categories across, revenue and units sold. Change the fields in the pivot panel, or choose Back to records.":"Bestellungen als Pivot: Regionen und Kanäle in den Zeilen, Produktkategorien in den Spalten, Umsatz und verkaufte Einheiten. Ändern Sie die Felder im Pivot-Bereich oder wählen Sie „Zurück zu den Datensätzen“.","The filter keeps East orders, or orders above 1,000 of fewer than 5 units: open Filter to see and change its groups. The Find bar marks “Harbor” in every matching record without narrowing them; press Enter for the next one.":"Der Filter behält Bestellungen aus East oder Bestellungen über 1.000 mit weniger als 5 Einheiten: Öffnen Sie „Filter“, um seine Gruppen zu sehen und zu ändern. Die Suchleiste markiert „Harbor“ in jedem passenden Datensatz, ohne sie einzuschränken; Enter springt zum nächsten.","Orders grouped by region, with header bands, a totals row, data bars and a colour scale. Choose Export, then XLSX or PDF with “Keep the layout”, and open the file to see the same view.":"Bestellungen nach Region gruppiert, mit Spaltengruppen, Summenzeile, Datenbalken und Farbskala. Wählen Sie „Exportieren“, dann XLSX oder PDF mit „Layout beibehalten“, und öffnen Sie die Datei, um dieselbe Ansicht zu sehen.","Choose Ask and describe a view, such as “East revenue by product, largest first”. In this example a few lines of keyword matching stand in for the language model your server would ask.":"Wählen Sie „Fragen“ und beschreiben Sie eine Ansicht, etwa „East revenue by product, largest first“. In diesem Beispiel ersetzen wenige Zeilen Stichwortsuche das Sprachmodell, das Ihr Server fragen würde.","This example understands a region (East, West, North, South), “by” a field, and “largest” or “smallest” with Revenue, Units, Price or Date.":"Dieses Beispiel versteht eine Region (East, West, North, South), „by“ mit einem Feld und „largest“ oder „smallest“ mit Revenue, Units, Price oder Date.","Also kept":"Bleiben ebenfalls"};export{e as default};
@@ -0,0 +1 @@
1
+ var e={"Autosize column":"Autoajustar columna","Drag to resize, double-click to fit":"Arrastre para cambiar el tamaño; haga doble clic para autoajustar",Dismiss:"Descartar","Filter row":"Fila de filtros","Clear column filters":"Borrar filtros de columnas","Greater than or equal":"Mayor o igual que","Less than or equal":"Menor o igual que","Open a row with its arrow to see the order lines. One order opens at a time and scrolls with the records.":"Expanda una fila con su flecha para ver las líneas del pedido. Solo se abre un pedido a la vez y se desplaza con los registros.","Tick rows, or the header box for every match. Drag across cells and press Ctrl+C to copy them. Export offers the selected rows.":"Marque filas, o la casilla del encabezado para todas las coincidencias. Arrastre sobre las celdas y presione Ctrl+C para copiarlas. Exportar ofrece las filas seleccionadas.",Quantity:"Cantidad",Price:"Precio",Amount:"Importe",Total:"Total","Order lines":"Líneas del pedido","Order no.":"N.º de pedido",Product:"Producto","Expand details":"Expandir detalles","Collapse details":"Contraer detalles","Conditional formatting":"Formato condicional","Data bar":"Barra de datos","Colour scale":"Escala de color","Green fill":"Relleno verde","Red fill":"Relleno rojo","Amber fill":"Relleno ámbar","Blue fill":"Relleno azul","Bold text":"Texto en negrita",Custom:"Personalizado","No rules":"Sin reglas",Style:"Estilo",Rule:"Regla","Add rule":"Agregar regla","Clear rules":"Borrar reglas","Drag a header edge to resize it and double-click to fit, drag a header to move it. Bars, colour scales and the totals row cover every matching record.":"Arrastre el borde de un encabezado para cambiar el tamaño y haga doble clic para autoajustar; arrastre un encabezado para moverlo. Las barras, las escalas de color y la fila de totales abarcan todos los registros coincidentes.",Totals:"Totales","No total":"Sin total","Select all matching records":"Seleccionar todos los registros coincidentes","Select record":"Seleccionar registro",selected:"seleccionados","All matching selected":"Todos los coincidentes seleccionados","All matching selected except":"Todos los coincidentes seleccionados excepto","Clear selection":"Borrar selección","All matching records":"Todos los registros coincidentes","Selected records":"Registros seleccionados",Records:"Registros","Select records to export first.":"Seleccione primero los registros que quiere exportar.","This source cannot export selected records.":"Este origen no puede exportar los registros seleccionados.","Row selection is off for this table.":"La selección de filas está desactivada en esta tabla.","Wait for the records to load.":"Espere a que se carguen los registros.","Search “East”, open a column menu to sort, filter, group or pin, and select cells to see their sum.":"Busque “East”, abra el menú de una columna para ordenar, filtrar, agrupar o anclar, y seleccione celdas para ver su suma.","One million orders generated off the main thread. Type “>30” under Units or a name under Customer, sort or group: the work runs in a Worker.":"Un millón de pedidos generados fuera del subproceso principal. Escriba “>30” bajo Units o un nombre bajo Customer, ordene o agrupe: el trabajo se ejecuta en un Worker.","Rows arrive in blocks of 100 from a simulated server with 150–400 ms latency and an unknown total. Scroll quickly, then sort or search.":"Las filas llegan en bloques de 100 desde un servidor simulado con una latencia de 150–400 ms y un total desconocido. Desplácese rápidamente y luego ordene o busque.","An editable copy: double-click a cell or press Enter to edit, Ctrl+Z to undo. Units must be a whole number from 1 to 500.":"Una copia editable: haga doble clic en una celda o presione Enter para editar, Ctrl+Z para deshacer. Units debe ser un número entero de 1 a 500.","Choose East, West, North or South.":"Elija East, West, North o South.","Units must be a whole number from 1 to 500.":"Units debe ser un número entero de 1 a 500.","Shift-click to sort by another column":"Mayús+clic para ordenar por otra columna","Selected cells":"Celdas seleccionadas","System theme":"Tema del sistema","Light theme":"Tema claro","Dark theme":"Tema oscuro","Custom theme":"Tema personalizado",Theme:"Tema","Column menu":"Menú de columna","Sort ascending":"Ordenar de forma ascendente","Sort descending":"Ordenar de forma descendente","Clear sort":"Borrar orden","Hide column":"Ocultar columna","is one of":"es uno de","Clear all":"Borrar todo",Unpin:"Desanclar",Ungroup:"Desagrupar","The data changed. Reopen the record before editing.":"Los datos cambiaron. Vuelva a abrir el registro antes de editarlo.",Rows:"Filas",Chart:"Gráfico",Pivot:"Tabla dinámica","Back to records":"Volver a los registros","Top 20 by absolute value":"20 principales por valor absoluto","Choose different row and column fields.":"Elija campos distintos para filas y columnas.","Pick values":"Elegir valores","No values":"Sin valores","Back to workbook":"Volver al libro","Read columns as text":"Leer columnas como texto",Delimiter:"Delimitador",Automatic:"Automático","Reimport CSV":"Volver a importar CSV","Add record":"Agregar registro","Remove record":"Quitar registro",Width:"Ancho",Share:"Compartir","Share link":"Vínculo para compartir","Copy link":"Copiar vínculo","Revoke link":"Revocar vínculo","Publish filtered copy":"Publicar copia filtrada","Prepare file":"Preparar archivo","This share link has expired or was revoked.":"Este vínculo para compartir expiró o se revocó.",Pages:"Páginas",Scroll:"Desplazamiento","Table view":"Vista de tabla","Open file":"Abrir archivo","Open workbook":"Abrir libro","Sales example":"Ejemplo de ventas","Open a table":"Abrir una tabla","Choose a CSV or Excel file to explore its records.":"Elija un archivo CSV o de Excel para explorar sus registros.","Search records":"Buscar registros",Filter:"Filtrar",Group:"Agrupar",Columns:"Columnas",Views:"Vistas",Export:"Exportar",Sort:"Ordenar",Apply:"Aplicar",Cancel:"Cancelar",Close:"Cerrar",Field:"Campo",Condition:"Condición",Value:"Valor",Contains:"Contiene",Equals:"Es igual a","Greater than":"Mayor que","Less than":"Menor que","Is blank":"Está vacío","Starts with":"Comienza por","Not equal":"No es igual a",Between:"Entre","Second value":"Segundo valor","Is not blank":"No está vacío",Ascending:"Ascendente",Descending:"Descendente",Remove:"Quitar","Reset view":"Restablecer vista",None:"Ninguno",Summary:"Resumen",Sum:"Suma",Average:"Promedio",Minimum:"Mínimo",Maximum:"Máximo",Count:"Recuento",Distinct:"Únicos",Visible:"Visible",Pin:"Anclar","Move up":"Subir","Move down":"Bajar","Save view":"Guardar vista","View name":"Nombre de la vista",Restore:"Restaurar","Record details":"Detalles del registro",Details:"Detalles",Previous:"Anterior",Next:"Siguiente",Page:"Página",of:"de",records:"registros","Export results":"Exportar resultados","No matching records":"No hay registros coincidentes","Clear filters":"Borrar filtros","Loading…":"Cargando…","A new version of 8sheets is ready.":"Hay una nueva versión de 8sheets disponible.",Reload:"Recargar",Later:"Más tarde","Reload and lose your unsaved edits?":"¿Recargar y perder los cambios sin guardar?","8sheets was updated in another tab. Save your work, then reload to use the new version.":"8sheets se actualizó en otra pestaña. Guarde su trabajo y luego recargue para usar la nueva versión.",Opening:"Abriendo","Preparing records":"Preparando registros","Loading records":"Cargando registros","Building pivot":"Creando tabla dinámica","Generating records":"Generando registros","Records read":"Registros leídos","Cancelling…":"Cancelando…","Loading cancelled.":"Carga cancelada.",Loaded:"Cargado","No data":"Sin datos",Table:"Tabla",Source:"Origen",Range:"Rango","First row contains headers":"La primera fila contiene encabezados","Edit copy":"Editar copia","Editing copy":"Editando copia","Save changes":"Guardar cambios",Undo:"Deshacer",Redo:"Rehacer","Calculated field":"Campo calculado",Formula:"Fórmula",Name:"Nombre",Add:"Agregar","Group by":"Agrupar por","Sort by":"Ordenar por","Add group":"Agregar grupo","Add sort":"Agregar orden",Order:"Criterio de ordenación","Use Tab to separate fields and a new line for each record.":"Use Tab para separar los campos y una línea nueva para cada registro.","Paste rows":"Pegar filas","Starting field":"Campo inicial","Changes live in this copy until exported.":"Los cambios permanecen en esta copia hasta que se exporte.","Choose at least one visible column.":"Elija al menos una columna visible.","No saved views":"No hay vistas guardadas","Rows per page":"Filas por página","Choose source":"Elegir origen",Format:"Formato","Copy row":"Copiar fila",Copied:"Copiado",Download:"Descargar","Local file":"Archivo local","View settings":"Configuración de la vista","Saved views":"Vistas guardadas","Paste exceeds the available records or columns.":"Lo que se pega supera los registros o columnas disponibles.","Editing is disabled for this view.":"La edición está deshabilitada en esta vista.","Save or discard your local edits before replacing this table. Continue?":"Guarde o descarte sus cambios locales antes de reemplazar esta tabla. ¿Desea continuar?","Select a value":"Seleccione un valor","No table loaded":"No hay ninguna tabla cargada",Filters:"Filtros",Print:"Imprimir","Fill down":"Rellenar hacia abajo","Number of records":"Número de registros","Original workbook":"Libro original",Edit:"Editar",Reset:"Restablecer",Saved:"Guardado","Choose a range inside the source.":"Elija un rango dentro del origen.","Choose an unused column name and a formula.":"Elija un nombre de columna no usado y una fórmula.","This view is read-only.":"Esta vista es de solo lectura.","This file contains no visible data.":"Este archivo no contiene datos visibles.","This field is read-only.":"Este campo es de solo lectura.","Field unavailable.":"Campo no disponible.","Record unavailable.":"Registro no disponible.","Invalid column.":"Columna no válida.","This source is read-only.":"Este origen es de solo lectura.","This field or record is read-only.":"Este campo o registro es de solo lectura.","Use the record editor for this source.":"Use el editor de registros para este origen.","The selection changed. Open Table view again.":"La selección cambió. Vuelva a abrir Vista de tabla.","The result exceeds the XLSX row limit or the format is unsupported.":"El resultado supera el límite de filas de XLSX o el formato no es compatible.","The pivot exceeds the worksheet dimensions.":"La tabla dinámica supera las dimensiones de la hoja de cálculo.","File sharing is unavailable on this device.":"El uso compartido de archivos no está disponible en este dispositivo.","Allow opening the workbook in a new tab.":"Permita abrir el libro en una pestaña nueva.","The example could not be opened.":"No se pudo abrir el ejemplo.","Invalid snapshot address.":"Dirección de instantánea no válida.","Invalid table response.":"Respuesta de tabla no válida.","Table view closed.":"Vista de tabla cerrada.","Add condition":"Agregar condición","Add value":"Agregar valor",Ask:"Preguntar","Ask for a view in your own words":"Pida una vista con sus propias palabras","Chart the selected cells":"Crear gráfico de las celdas seleccionadas","Chart type":"Tipo de gráfico","Close find":"Cerrar búsqueda",Column:"Columna","Column name":"Nombre de columna",Comfortable:"Amplio",Compact:"Compacto","Copy with headings":"Copiar con encabezados","Done.":"Listo.","Download SVG":"Descargar SVG","Draw the numbers in the cell, or the values of these fields:":"Dibujar los números de la celda o los valores de estos campos:","Each record goes under the record whose key its parent field holds. Or give a field with an outline level instead.":"Cada registro se coloca bajo el registro cuya clave contiene su campo primario. O bien, indique en su lugar un campo con un nivel de esquema.",Find:"Buscar","Find in cells":"Buscar en celdas","For example: revenue by region for 2026, largest first":"Por ejemplo: ingresos por región en 2026, de mayor a menor",Hide:"Ocultar","Hide blanks":"Ocultar vacíos",Index:"Índice",Join:"Combinación","Keep the layout: groups, totals, widths and formatting":"Mantener el diseño: grupos, totales, anchos y formato","Key field":"Campo clave","Level field":"Campo de nivel",Line:"Línea","Match all conditions":"Cumplen todas las condiciones","Match any condition":"Cumplen alguna condición","Next match":"Coincidencia siguiente","No calculation":"Sin cálculo",Normal:"Normal","% of column total":"% del total de columna","% of grand total":"% del total general","% of row total":"% del total de fila","Parent field":"Campo primario",Paste:"Pegar","Pin row to bottom":"Anclar fila abajo","Pin row to top":"Anclar fila arriba","Previous match":"Coincidencia anterior","Rank, largest first":"Clasificación de mayor a menor","Rank, smallest first":"Clasificación de menor a mayor","Remove condition":"Quitar condición","Remove group":"Quitar grupo","Rename column":"Cambiar nombre de columna","Row height":"Alto de fila","Running total":"Total acumulado",Search:"Buscar","Show as tree":"Mostrar como árbol","Show only":"Mostrar solo","Show only blanks":"Mostrar solo vacíos","Show records that":"Mostrar registros que","Show values as":"Mostrar valores como",Sparkline:"Minigráfico","Then by":"Luego por","Thinking…":"Pensando…",Type:"Tipo","Unpin row":"Desanclar fila",Values:"Valores","Win/loss":"Ganancia/pérdida",Tree:"Árbol",Pinned:"Anclados",row:"fila",rows:"filas","any of":"cualquiera de","all of":"todos","is none of":"no es ninguno de",Copy:"Copiar","Copy cells":"Copiar celdas",Expand:"Expandir",Collapse:"Contraer","Remove records":"Quitar registros","Show as tree…":"Mostrar como árbol…","Drop here to group by this column":"Suelte aquí para agrupar por esta columna","Drag to move":"Arrastre para mover","Move record":"Mover registro","Drag to fill":"Arrastre para rellenar","No matches":"Sin coincidencias",matches:"coincidencias","Choose a value from the list.":"Elija un valor de la lista.",OK:"Aceptar",Bar:"Barra",Pie:"Circular","Clear the sort and the groups to move records.":"Borre el orden y los grupos para mover registros.","Unpin the rows before moving them.":"Desancle las filas antes de moverlas.","Remove sparkline":"Quitar minigráfico","Remove tree":"Quitar árbol","Choose the key field and the parent field.":"Elija el campo clave y el campo primario.","The answer could not be applied.":"No se pudo aplicar la respuesta.","Choose a row field and a value.":"Elija un campo de fila y un valor.","Select cells with numbers to chart them.":"Seleccione celdas con números para crear un gráfico.","A tree needs a parent field, or a level field.":"Un árbol necesita un campo primario o un campo de nivel.","A tree needs a key field that its parent field refers to.":"Un árbol necesita un campo clave al que haga referencia su campo primario.","Find needs local records; search the server source instead.":"Buscar necesita registros locales; en su lugar, busque en el origen del servidor.","This source cannot pin rows.":"Este origen no puede anclar filas.","Asking needs the assistant option.":"Preguntar requiere la opción assistant.","Select cells first.":"Seleccione primero las celdas.",'Pin rows to "top" or "bottom".':'Ancle las filas a "top" o "bottom".',"The records are not shown as a tree.":"Los registros no se muestran como árbol.","Does not contain":"No contiene","Ends with":"Termina en","Not between":"No está entre",Top:"Superiores",Bottom:"Inferiores","Above average":"Por encima del promedio","Below average":"Por debajo del promedio",Today:"Hoy",Yesterday:"Ayer",Tomorrow:"Mañana","This week":"Esta semana","This month":"Este mes","Last month":"Mes pasado","This year":"Este año","Last year":"Año pasado","A company as a tree: open and close managers with their arrows. Salaries roll up to each manager. Edit an office from its list, a start date in the picker, skills as several choices.":"Una empresa como árbol: expanda y contraiga a los responsables con sus flechas. Los salarios se suman en cada responsable. Edite una oficina desde su lista, una fecha de inicio en el selector y las habilidades como varias opciones.","Prices change twice a second and the changed cells flash. Right-click a cell for its menu, drag a row by its grip, pin a row to the top, or press Ctrl+F to find a product.":"Los precios cambian dos veces por segundo y las celdas modificadas parpadean. Haga clic con el botón derecho en una celda para ver su menú, arrastre una fila por su controlador, ancle una fila arriba o presione Ctrl+F para buscar un producto.","Orders as a pivot: regions and channels down, product categories across, revenue and units sold. Change the fields in the pivot panel, or choose Back to records.":"Los pedidos como tabla dinámica: regiones y canales en filas, categorías de producto en columnas, ingresos y unidades vendidas. Cambie los campos en el panel de la tabla dinámica o elija Volver a los registros.","The filter keeps East orders, or orders above 1,000 of fewer than 5 units: open Filter to see and change its groups. The Find bar marks “Harbor” in every matching record without narrowing them; press Enter for the next one.":"El filtro conserva los pedidos de East, o los de más de 1.000 con menos de 5 unidades: abra Filtrar para ver y cambiar sus grupos. La barra Buscar marca «Harbor» en cada registro coincidente sin reducirlos; Intro pasa al siguiente.","Orders grouped by region, with header bands, a totals row, data bars and a colour scale. Choose Export, then XLSX or PDF with “Keep the layout”, and open the file to see the same view.":"Pedidos agrupados por región, con bandas de columnas, una fila de totales, barras de datos y una escala de colores. Elija Exportar, luego XLSX o PDF con «Conservar el diseño», y abra el archivo para ver la misma vista.","Choose Ask and describe a view, such as “East revenue by product, largest first”. In this example a few lines of keyword matching stand in for the language model your server would ask.":"Elija Preguntar y describa una vista, por ejemplo «East revenue by product, largest first». En este ejemplo, unas pocas líneas de coincidencia de palabras clave sustituyen al modelo de lenguaje que consultaría su servidor.","This example understands a region (East, West, North, South), “by” a field, and “largest” or “smallest” with Revenue, Units, Price or Date.":"Este ejemplo entiende una región (East, West, North, South), «by» seguido de un campo, y «largest» o «smallest» con Revenue, Units, Price o Date.","Also kept":"También se mantienen"};export{e as default};
@@ -0,0 +1 @@
1
+ var e={"Autosize column":"Ajuster la largeur","Drag to resize, double-click to fit":"Faire glisser pour redimensionner, double-cliquer pour ajuster",Dismiss:"Fermer l'astuce","Filter row":"Ligne de filtre","Clear column filters":"Effacer les filtres des colonnes","Greater than or equal":"Supérieur ou égal à","Less than or equal":"Inférieur ou égal à","Open a row with its arrow to see the order lines. One order opens at a time and scrolls with the records.":"Ouvrez une ligne avec sa flèche pour voir les lignes de commande. Une seule commande s'ouvre à la fois et défile avec les enregistrements.","Tick rows, or the header box for every match. Drag across cells and press Ctrl+C to copy them. Export offers the selected rows.":"Cochez des lignes, ou la case de l'en-tête pour toutes les correspondances. Faites glisser sur des cellules et appuyez sur Ctrl+C pour les copier. L'exportation propose les lignes sélectionnées.",Quantity:"Quantité",Price:"Prix",Amount:"Montant",Total:"Total","Order lines":"Lignes de commande","Order no.":"N° de commande",Product:"Produit","Expand details":"Développer les détails","Collapse details":"Réduire les détails","Conditional formatting":"Mise en forme conditionnelle","Data bar":"Barre de données","Colour scale":"Échelle de couleurs","Green fill":"Remplissage vert","Red fill":"Remplissage rouge","Amber fill":"Remplissage jaune","Blue fill":"Remplissage bleu","Bold text":"Texte en gras",Custom:"Personnalisé","No rules":"Aucune règle",Style:"Style",Rule:"Règle","Add rule":"Ajouter une règle","Clear rules":"Effacer les règles","Drag a header edge to resize it and double-click to fit, drag a header to move it. Bars, colour scales and the totals row cover every matching record.":"Faites glisser le bord d'un en-tête pour le redimensionner et double-cliquez pour l'ajuster, faites glisser un en-tête pour le déplacer. Les barres, les échelles de couleurs et la ligne des totaux couvrent tous les enregistrements correspondants.",Totals:"Totaux","No total":"Aucun total","Select all matching records":"Sélectionner tous les enregistrements correspondants","Select record":"Sélectionner l'enregistrement",selected:"sélectionnés","All matching selected":"Toutes les correspondances sélectionnées","All matching selected except":"Toutes les correspondances sélectionnées sauf","Clear selection":"Effacer la sélection","All matching records":"Tous les enregistrements correspondants","Selected records":"Enregistrements sélectionnés",Records:"Enregistrements","Select records to export first.":"Sélectionnez d'abord les enregistrements à exporter.","This source cannot export selected records.":"Cette source ne peut pas exporter les enregistrements sélectionnés.","Row selection is off for this table.":"La sélection de lignes est désactivée pour ce tableau.","Wait for the records to load.":"Attendez le chargement des enregistrements.","Search “East”, open a column menu to sort, filter, group or pin, and select cells to see their sum.":"Recherchez “East”, ouvrez un menu de colonne pour trier, filtrer, grouper ou épingler, et sélectionnez des cellules pour voir leur somme.","One million orders generated off the main thread. Type “>30” under Units or a name under Customer, sort or group: the work runs in a Worker.":"Un million de commandes générées hors du thread principal. Tapez “>30” sous Units ou un nom sous Customer, triez ou groupez : le travail s'exécute dans un Worker.","Rows arrive in blocks of 100 from a simulated server with 150–400 ms latency and an unknown total. Scroll quickly, then sort or search.":"Les lignes arrivent par blocs de 100 depuis un serveur simulé avec une latence de 150–400 ms et un total inconnu. Faites défiler rapidement, puis triez ou recherchez.","An editable copy: double-click a cell or press Enter to edit, Ctrl+Z to undo. Units must be a whole number from 1 to 500.":"Une copie modifiable : double-cliquez sur une cellule ou appuyez sur Enter pour modifier, Ctrl+Z pour annuler. Units doit être un nombre entier de 1 à 500.","Choose East, West, North or South.":"Choisissez East, West, North ou South.","Units must be a whole number from 1 to 500.":"Units doit être un nombre entier de 1 à 500.","Shift-click to sort by another column":"Shift+clic pour trier selon une autre colonne","Selected cells":"Cellules sélectionnées","System theme":"Thème système","Light theme":"Thème clair","Dark theme":"Thème sombre","Custom theme":"Thème personnalisé",Theme:"Thème","Column menu":"Menu de la colonne","Sort ascending":"Trier par ordre croissant","Sort descending":"Trier par ordre décroissant","Clear sort":"Effacer le tri","Hide column":"Masquer la colonne","is one of":"est l'un de","Clear all":"Tout effacer",Unpin:"Détacher",Ungroup:"Dissocier","The data changed. Reopen the record before editing.":"Les données ont changé. Rouvrez l'enregistrement avant de le modifier.",Rows:"Lignes",Chart:"Graphique",Pivot:"Tableau croisé dynamique","Back to records":"Retour aux enregistrements","Top 20 by absolute value":"20 premiers en valeur absolue","Choose different row and column fields.":"Choisissez des champs de ligne et de colonne différents.","Pick values":"Choisir des valeurs","No values":"Aucune valeur","Back to workbook":"Retour au classeur","Read columns as text":"Lire les colonnes comme du texte",Delimiter:"Séparateur",Automatic:"Automatique","Reimport CSV":"Réimporter le CSV","Add record":"Ajouter un enregistrement","Remove record":"Supprimer l'enregistrement",Width:"Largeur",Share:"Partager","Share link":"Lien de partage","Copy link":"Copier le lien","Revoke link":"Révoquer le lien","Publish filtered copy":"Publier une copie filtrée","Prepare file":"Préparer le fichier","This share link has expired or was revoked.":"Ce lien de partage a expiré ou a été révoqué.",Pages:"Pages",Scroll:"Défilement","Table view":"Vue tableau","Open file":"Ouvrir un fichier","Open workbook":"Ouvrir le classeur","Sales example":"Exemple de ventes","Open a table":"Ouvrir un tableau","Choose a CSV or Excel file to explore its records.":"Choisissez un fichier CSV ou Excel pour explorer ses enregistrements.","Search records":"Rechercher des enregistrements",Filter:"Filtrer",Group:"Grouper",Columns:"Colonnes",Views:"Vues",Export:"Exporter",Sort:"Trier",Apply:"Appliquer",Cancel:"Annuler",Close:"Fermer",Field:"Champ",Condition:"Condition",Value:"Valeur",Contains:"Contient",Equals:"Est égal à","Greater than":"Supérieur à","Less than":"Inférieur à","Is blank":"Est vide","Starts with":"Commence par","Not equal":"Est différent de",Between:"Entre","Second value":"Deuxième valeur","Is not blank":"N'est pas vide",Ascending:"Croissant",Descending:"Décroissant",Remove:"Supprimer","Reset view":"Réinitialiser la vue",None:"Aucun",Summary:"Synthèse",Sum:"Somme",Average:"Moyenne",Minimum:"Minimum",Maximum:"Maximum",Count:"Nombre",Distinct:"Nombre distinct",Visible:"Visible",Pin:"Épingler","Move up":"Monter","Move down":"Descendre","Save view":"Enregistrer la vue","View name":"Nom de la vue",Restore:"Restaurer","Record details":"Détails de l'enregistrement",Details:"Détails",Previous:"Précédent",Next:"Suivant",Page:"Page",of:"sur",records:"enregistrements","Export results":"Exporter les résultats","No matching records":"Aucun enregistrement correspondant","Clear filters":"Effacer les filtres","Loading…":"Chargement…","A new version of 8sheets is ready.":"Une nouvelle version de 8sheets est prête.",Reload:"Recharger",Later:"Plus tard","Reload and lose your unsaved edits?":"Recharger et perdre vos modifications non enregistrées ?","8sheets was updated in another tab. Save your work, then reload to use the new version.":"8sheets a été mis à jour dans un autre onglet. Enregistrez votre travail, puis rechargez pour utiliser la nouvelle version.",Opening:"Ouverture de","Preparing records":"Préparation des enregistrements","Loading records":"Chargement des enregistrements","Building pivot":"Création du tableau croisé dynamique","Generating records":"Génération des enregistrements","Records read":"Enregistrements lus","Cancelling…":"Annulation…","Loading cancelled.":"Chargement annulé.",Loaded:"Chargé","No data":"Aucune donnée",Table:"Tableau",Source:"Source",Range:"Plage","First row contains headers":"La première ligne contient les en-têtes","Edit copy":"Modifier une copie","Editing copy":"Modification de la copie","Save changes":"Enregistrer les modifications",Undo:"Annuler",Redo:"Rétablir","Calculated field":"Champ calculé",Formula:"Formule",Name:"Nom",Add:"Ajouter","Group by":"Grouper par","Sort by":"Trier par","Add group":"Ajouter un groupe","Add sort":"Ajouter un tri",Order:"Ordre","Use Tab to separate fields and a new line for each record.":"Utilisez Tab pour séparer les champs et une nouvelle ligne pour chaque enregistrement.","Paste rows":"Coller des lignes","Starting field":"Champ de départ","Changes live in this copy until exported.":"Les modifications restent dans cette copie jusqu'à l'exportation.","Choose at least one visible column.":"Choisissez au moins une colonne visible.","No saved views":"Aucune vue enregistrée","Rows per page":"Lignes par page","Choose source":"Choisir la source",Format:"Format","Copy row":"Copier la ligne",Copied:"Copié",Download:"Télécharger","Local file":"Fichier local","View settings":"Paramètres de la vue","Saved views":"Vues enregistrées","Paste exceeds the available records or columns.":"Le collage dépasse les enregistrements ou les colonnes disponibles.","Editing is disabled for this view.":"La modification est désactivée pour cette vue.","Save or discard your local edits before replacing this table. Continue?":"Enregistrez ou abandonnez vos modifications locales avant de remplacer ce tableau. Continuer ?","Select a value":"Sélectionner une valeur","No table loaded":"Aucun tableau chargé",Filters:"Filtres",Print:"Imprimer","Fill down":"Recopier vers le bas","Number of records":"Nombre d'enregistrements","Original workbook":"Classeur d'origine",Edit:"Modifier",Reset:"Réinitialiser",Saved:"Enregistré","Choose a range inside the source.":"Choisissez une plage à l'intérieur de la source.","Choose an unused column name and a formula.":"Choisissez un nom de colonne inutilisé et une formule.","This view is read-only.":"Cette vue est en lecture seule.","This file contains no visible data.":"Ce fichier ne contient aucune donnée visible.","This field is read-only.":"Ce champ est en lecture seule.","Field unavailable.":"Champ indisponible.","Record unavailable.":"Enregistrement indisponible.","Invalid column.":"Colonne non valide.","This source is read-only.":"Cette source est en lecture seule.","This field or record is read-only.":"Ce champ ou cet enregistrement est en lecture seule.","Use the record editor for this source.":"Utilisez l'éditeur d'enregistrement pour cette source.","The selection changed. Open Table view again.":"La sélection a changé. Rouvrez la vue tableau.","The result exceeds the XLSX row limit or the format is unsupported.":"Le résultat dépasse la limite de lignes XLSX ou le format n'est pas pris en charge.","The pivot exceeds the worksheet dimensions.":"Le tableau croisé dynamique dépasse les dimensions de la feuille de calcul.","File sharing is unavailable on this device.":"Le partage de fichiers n'est pas disponible sur cet appareil.","Allow opening the workbook in a new tab.":"Autorisez l'ouverture du classeur dans un nouvel onglet.","The example could not be opened.":"Impossible d'ouvrir l'exemple.","Invalid snapshot address.":"Adresse d'instantané non valide.","Invalid table response.":"Réponse de tableau non valide.","Table view closed.":"Vue tableau fermée.","Add condition":"Ajouter une condition","Add value":"Ajouter une valeur",Ask:"Demander","Ask for a view in your own words":"Décrivez la vue souhaitée avec vos propres mots","Chart the selected cells":"Graphique des cellules sélectionnées","Chart type":"Type de graphique","Close find":"Fermer la recherche",Column:"Histogramme","Column name":"Nom de la colonne",Comfortable:"Confortable",Compact:"Compacte","Copy with headings":"Copier avec les en-têtes","Done.":"Terminé.","Download SVG":"Télécharger le SVG","Draw the numbers in the cell, or the values of these fields:":"Tracer les nombres de la cellule, ou les valeurs de ces champs :","Each record goes under the record whose key its parent field holds. Or give a field with an outline level instead.":"Chaque enregistrement se place sous l'enregistrement dont la clé figure dans son champ parent. Ou indiquez plutôt un champ contenant un niveau de plan.",Find:"Rechercher","Find in cells":"Rechercher dans les cellules","For example: revenue by region for 2026, largest first":"Par exemple : chiffre d'affaires par région pour 2026, du plus grand au plus petit",Hide:"Masquer","Hide blanks":"Masquer les vides",Index:"Index",Join:"Combinaison","Keep the layout: groups, totals, widths and formatting":"Conserver la disposition : groupes, totaux, largeurs et mise en forme","Key field":"Champ clé","Level field":"Champ de niveau",Line:"Courbes","Match all conditions":"Correspondent à toutes les conditions","Match any condition":"Correspondent à au moins une condition","Next match":"Correspondance suivante","No calculation":"Aucun calcul",Normal:"Normale","% of column total":"% du total de la colonne","% of grand total":"% du total général","% of row total":"% du total de la ligne","Parent field":"Champ parent",Paste:"Coller","Pin row to bottom":"Épingler la ligne en bas","Pin row to top":"Épingler la ligne en haut","Previous match":"Correspondance précédente","Rank, largest first":"Rang, du plus grand au plus petit","Rank, smallest first":"Rang, du plus petit au plus grand","Remove condition":"Supprimer la condition","Remove group":"Supprimer le groupe","Rename column":"Renommer la colonne","Row height":"Hauteur des lignes","Running total":"Total cumulé",Search:"Rechercher","Show as tree":"Afficher en arborescence","Show only":"Afficher uniquement","Show only blanks":"Afficher uniquement les vides","Show records that":"Afficher les enregistrements qui","Show values as":"Afficher les valeurs",Sparkline:"Graphique sparkline","Then by":"Puis par","Thinking…":"Réflexion…",Type:"Type","Unpin row":"Détacher la ligne",Values:"Valeurs","Win/loss":"Positif/Négatif",Tree:"Arborescence",Pinned:"Épinglées",row:"ligne",rows:"lignes","any of":"au moins une","all of":"toutes","is none of":"n'est aucun de",Copy:"Copier","Copy cells":"Copier les cellules",Expand:"Développer",Collapse:"Réduire","Remove records":"Supprimer les enregistrements","Show as tree…":"Afficher en arborescence…","Drop here to group by this column":"Déposer ici pour grouper par cette colonne","Drag to move":"Faire glisser pour déplacer","Move record":"Déplacer l'enregistrement","Drag to fill":"Faire glisser pour remplir","No matches":"Aucune correspondance",matches:"correspondances","Choose a value from the list.":"Choisissez une valeur dans la liste.",OK:"OK",Bar:"Barres",Pie:"Secteurs","Clear the sort and the groups to move records.":"Effacez le tri et les groupes pour déplacer des enregistrements.","Unpin the rows before moving them.":"Détachez les lignes avant de les déplacer.","Remove sparkline":"Supprimer le graphique sparkline","Remove tree":"Supprimer l'arborescence","Choose the key field and the parent field.":"Choisissez le champ clé et le champ parent.","The answer could not be applied.":"Impossible d'appliquer la réponse.","Choose a row field and a value.":"Choisissez un champ de ligne et une valeur.","Select cells with numbers to chart them.":"Sélectionnez des cellules contenant des nombres pour créer un graphique.","A tree needs a parent field, or a level field.":"Une arborescence nécessite un champ parent ou un champ de niveau.","A tree needs a key field that its parent field refers to.":"Une arborescence nécessite un champ clé auquel son champ parent fait référence.","Find needs local records; search the server source instead.":"Rechercher nécessite des enregistrements locaux ; utilisez plutôt la recherche de la source serveur.","This source cannot pin rows.":"Cette source ne peut pas épingler de lignes.","Asking needs the assistant option.":"Poser une question nécessite l'option assistant.","Select cells first.":"Sélectionnez d'abord des cellules.",'Pin rows to "top" or "bottom".':'Épinglez les lignes en "top" ou "bottom".',"The records are not shown as a tree.":"Les enregistrements ne sont pas affichés en arborescence.","Does not contain":"Ne contient pas","Ends with":"Se termine par","Not between":"N'est pas entre",Top:"Premiers",Bottom:"Derniers","Above average":"Au-dessus de la moyenne","Below average":"En dessous de la moyenne",Today:"Aujourd'hui",Yesterday:"Hier",Tomorrow:"Demain","This week":"Cette semaine","This month":"Ce mois-ci","Last month":"Le mois dernier","This year":"Cette année","Last year":"L'année dernière","A company as a tree: open and close managers with their arrows. Salaries roll up to each manager. Edit an office from its list, a start date in the picker, skills as several choices.":"Une entreprise en arborescence : ouvrez et fermez les responsables avec leurs flèches. Les salaires se cumulent pour chaque responsable. Modifiez un bureau depuis sa liste, une date de début dans le sélecteur, les compétences en choix multiples.","Prices change twice a second and the changed cells flash. Right-click a cell for its menu, drag a row by its grip, pin a row to the top, or press Ctrl+F to find a product.":"Les prix changent deux fois par seconde et les cellules modifiées clignotent. Cliquez avec le bouton droit sur une cellule pour afficher son menu, faites glisser une ligne par sa poignée, épinglez une ligne en haut, ou appuyez sur Ctrl+F pour rechercher un produit.","Orders as a pivot: regions and channels down, product categories across, revenue and units sold. Change the fields in the pivot panel, or choose Back to records.":"Les commandes en tableau croisé : régions et canaux en lignes, catégories de produits en colonnes, chiffre d’affaires et unités vendues. Modifiez les champs dans le panneau du tableau croisé ou choisissez Retour aux enregistrements.","The filter keeps East orders, or orders above 1,000 of fewer than 5 units: open Filter to see and change its groups. The Find bar marks “Harbor” in every matching record without narrowing them; press Enter for the next one.":"Le filtre garde les commandes East, ou celles de plus de 1 000 avec moins de 5 unités : ouvrez Filtrer pour voir et modifier ses groupes. La barre Rechercher marque « Harbor » dans chaque enregistrement correspondant sans les restreindre ; Entrée passe au suivant.","Orders grouped by region, with header bands, a totals row, data bars and a colour scale. Choose Export, then XLSX or PDF with “Keep the layout”, and open the file to see the same view.":"Les commandes groupées par région, avec des bandeaux de colonnes, une ligne de totaux, des barres de données et une échelle de couleurs. Choisissez Exporter, puis XLSX ou PDF avec « Conserver la mise en page », et ouvrez le fichier pour retrouver la même vue.","Choose Ask and describe a view, such as “East revenue by product, largest first”. In this example a few lines of keyword matching stand in for the language model your server would ask.":"Choisissez Demander et décrivez une vue, par exemple « East revenue by product, largest first ». Dans cet exemple, quelques lignes de recherche de mots-clés remplacent le modèle de langage qu’interrogerait votre serveur.","This example understands a region (East, West, North, South), “by” a field, and “largest” or “smallest” with Revenue, Units, Price or Date.":"Cet exemple comprend une région (East, West, North, South), « by » suivi d’un champ, et « largest » ou « smallest » avec Revenue, Units, Price ou Date.","Also kept":"Conservés aussi"};export{e as default};