@toolbox-web/grid 1.25.1 → 1.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/all.js +2 -2
- package/all.js.map +1 -1
- package/index.js +1 -1
- package/index.js.map +1 -1
- package/lib/core/grid.d.ts +18 -2
- package/lib/core/internal/diagnostics.d.ts +164 -0
- package/lib/core/internal/sorting.d.ts +53 -4
- package/lib/core/internal/utils.d.ts +0 -8
- package/lib/core/plugin/base-plugin.d.ts +18 -2
- package/lib/core/plugin/plugin-manager.d.ts +6 -4
- package/lib/core/types.d.ts +3 -2
- package/lib/features/registry.js +1 -1
- package/lib/features/registry.js.map +1 -1
- package/lib/plugins/clipboard/index.js +1 -1
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/column-virtualization/index.js +1 -1
- package/lib/plugins/column-virtualization/index.js.map +1 -1
- package/lib/plugins/context-menu/index.js +1 -1
- package/lib/plugins/context-menu/index.js.map +1 -1
- package/lib/plugins/editing/index.js +1 -1
- package/lib/plugins/editing/index.js.map +1 -1
- package/lib/plugins/editing/types.d.ts +52 -4
- package/lib/plugins/export/ExportPlugin.d.ts +2 -2
- package/lib/plugins/export/index.js +1 -1
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/filtering/FilteringPlugin.d.ts +2 -2
- package/lib/plugins/filtering/index.js +1 -1
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/grouping-columns/index.js +1 -1
- package/lib/plugins/grouping-columns/index.js.map +1 -1
- package/lib/plugins/grouping-rows/GroupingRowsPlugin.d.ts +2 -2
- package/lib/plugins/grouping-rows/index.js +2 -2
- package/lib/plugins/grouping-rows/index.js.map +1 -1
- package/lib/plugins/master-detail/index.js +1 -1
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/multi-sort/MultiSortPlugin.d.ts +2 -2
- package/lib/plugins/multi-sort/index.js +1 -1
- package/lib/plugins/multi-sort/index.js.map +1 -1
- package/lib/plugins/pinned-columns/PinnedColumnsPlugin.d.ts +2 -2
- package/lib/plugins/pinned-columns/index.js +1 -1
- package/lib/plugins/pinned-columns/index.js.map +1 -1
- package/lib/plugins/pinned-rows/index.js +1 -1
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pivot/index.js +1 -1
- package/lib/plugins/pivot/index.js.map +1 -1
- package/lib/plugins/print/PrintPlugin.d.ts +2 -1
- package/lib/plugins/print/index.js +1 -1
- package/lib/plugins/print/index.js.map +1 -1
- package/lib/plugins/print/print-isolated.d.ts +2 -1
- package/lib/plugins/reorder-columns/ReorderPlugin.d.ts +2 -2
- package/lib/plugins/reorder-columns/index.js +1 -1
- package/lib/plugins/reorder-columns/index.js.map +1 -1
- package/lib/plugins/reorder-rows/RowReorderPlugin.d.ts +2 -2
- package/lib/plugins/reorder-rows/index.js +1 -1
- package/lib/plugins/reorder-rows/index.js.map +1 -1
- package/lib/plugins/responsive/index.js +1 -1
- package/lib/plugins/responsive/index.js.map +1 -1
- package/lib/plugins/selection/SelectionPlugin.d.ts +2 -0
- package/lib/plugins/selection/index.js +1 -1
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/server-side/index.js +1 -1
- package/lib/plugins/server-side/index.js.map +1 -1
- package/lib/plugins/tree/TreePlugin.d.ts +2 -2
- package/lib/plugins/tree/index.js +1 -1
- package/lib/plugins/tree/index.js.map +1 -1
- package/lib/plugins/undo-redo/UndoRedoPlugin.d.ts +2 -2
- package/lib/plugins/undo-redo/index.js +1 -1
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/visibility/VisibilityPlugin.d.ts +2 -2
- package/lib/plugins/visibility/index.js +1 -1
- package/lib/plugins/visibility/index.js.map +1 -1
- package/package.json +1 -1
- package/umd/grid.all.umd.js +1 -1
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +1 -1
- package/umd/grid.umd.js.map +1 -1
- package/umd/plugins/clipboard.umd.js +1 -1
- package/umd/plugins/clipboard.umd.js.map +1 -1
- package/umd/plugins/context-menu.umd.js +1 -1
- package/umd/plugins/context-menu.umd.js.map +1 -1
- package/umd/plugins/editing.umd.js +1 -1
- package/umd/plugins/editing.umd.js.map +1 -1
- package/umd/plugins/export.umd.js.map +1 -1
- package/umd/plugins/filtering.umd.js.map +1 -1
- package/umd/plugins/grouping-columns.umd.js +1 -1
- package/umd/plugins/grouping-columns.umd.js.map +1 -1
- package/umd/plugins/grouping-rows.umd.js.map +1 -1
- package/umd/plugins/multi-sort.umd.js.map +1 -1
- package/umd/plugins/pinned-columns.umd.js.map +1 -1
- package/umd/plugins/print.umd.js +1 -1
- package/umd/plugins/print.umd.js.map +1 -1
- package/umd/plugins/reorder-columns.umd.js.map +1 -1
- package/umd/plugins/reorder-rows.umd.js.map +1 -1
- package/umd/plugins/responsive.umd.js +1 -1
- package/umd/plugins/responsive.umd.js.map +1 -1
- package/umd/plugins/selection.umd.js +1 -1
- package/umd/plugins/selection.umd.js.map +1 -1
- package/umd/plugins/tree.umd.js.map +1 -1
- package/umd/plugins/undo-redo.umd.js +1 -1
- package/umd/plugins/undo-redo.umd.js.map +1 -1
- package/umd/plugins/visibility.umd.js.map +1 -1
|
@@ -196,8 +196,28 @@ export interface EditCloseDetail<TRow = unknown> {
|
|
|
196
196
|
*/
|
|
197
197
|
declare module '../../core/types' {
|
|
198
198
|
interface BaseColumnConfig<TRow, TValue> {
|
|
199
|
-
/**
|
|
200
|
-
|
|
199
|
+
/**
|
|
200
|
+
* Whether the field is editable (enables editors). Requires EditingPlugin.
|
|
201
|
+
*
|
|
202
|
+
* - `true` — editable for all rows
|
|
203
|
+
* - `false` / omitted — not editable
|
|
204
|
+
* - `(row: TRow) => boolean` — conditionally editable per row
|
|
205
|
+
*
|
|
206
|
+
* When a function is provided it is evaluated each time the grid needs to
|
|
207
|
+
* determine if a specific cell can enter edit mode (click, keyboard, grid
|
|
208
|
+
* mode render, tab navigation, etc.). Keep the function fast — it runs on
|
|
209
|
+
* hot render paths.
|
|
210
|
+
*
|
|
211
|
+
* @example
|
|
212
|
+
* ```typescript
|
|
213
|
+
* // Always editable
|
|
214
|
+
* { field: 'name', editable: true }
|
|
215
|
+
*
|
|
216
|
+
* // Conditionally editable
|
|
217
|
+
* { field: 'price', editable: (row) => row.status !== 'locked' }
|
|
218
|
+
* ```
|
|
219
|
+
*/
|
|
220
|
+
editable?: boolean | ((row: TRow) => boolean);
|
|
201
221
|
/** Optional custom editor factory or element tag name. Requires EditingPlugin. */
|
|
202
222
|
editor?: ColumnEditorSpec<TRow, TValue>;
|
|
203
223
|
/**
|
|
@@ -306,7 +326,7 @@ declare module '../../core/types' {
|
|
|
306
326
|
*/
|
|
307
327
|
editorParams?: Record<string, unknown>;
|
|
308
328
|
}
|
|
309
|
-
interface GridConfig {
|
|
329
|
+
interface GridConfig<TRow = any> {
|
|
310
330
|
/**
|
|
311
331
|
* Edit trigger mode. Requires `EditingPlugin` to be loaded.
|
|
312
332
|
*
|
|
@@ -319,6 +339,32 @@ declare module '../../core/types' {
|
|
|
319
339
|
* - `false`: Disable editing entirely
|
|
320
340
|
*/
|
|
321
341
|
editOn?: 'click' | 'dblclick' | 'manual' | false;
|
|
342
|
+
/**
|
|
343
|
+
* Row-level editability gate. Requires `EditingPlugin` to be loaded.
|
|
344
|
+
*
|
|
345
|
+
* When provided, this function is called **before** the column-level
|
|
346
|
+
* `editable` check. If it returns `false` for a given row, **no cell** in
|
|
347
|
+
* that row can be edited regardless of the column configuration.
|
|
348
|
+
*
|
|
349
|
+
* Omitting this property (or returning `true`) defers to per-column
|
|
350
|
+
* `editable` settings.
|
|
351
|
+
*
|
|
352
|
+
* Keep the callback fast — it is invoked on every editability check
|
|
353
|
+
* (click, keyboard, grid-mode render, tab navigation).
|
|
354
|
+
*
|
|
355
|
+
* @example
|
|
356
|
+
* ```typescript
|
|
357
|
+
* // Block editing for archived rows
|
|
358
|
+
* gridConfig = {
|
|
359
|
+
* rowEditable: (row) => !row.archived,
|
|
360
|
+
* columns: [
|
|
361
|
+
* { field: 'name', editable: true },
|
|
362
|
+
* { field: 'price', editable: (row) => row.status === 'draft' },
|
|
363
|
+
* ],
|
|
364
|
+
* };
|
|
365
|
+
* ```
|
|
366
|
+
*/
|
|
367
|
+
rowEditable?: (row: TRow) => boolean;
|
|
322
368
|
}
|
|
323
369
|
interface DataGridEventMap<TRow = unknown> {
|
|
324
370
|
/** Fired when a cell edit is canceled (Escape key). The cell reverts to its previous value. @group Editing Events */
|
|
@@ -377,7 +423,9 @@ export interface EditingConfig {
|
|
|
377
423
|
*
|
|
378
424
|
* @example
|
|
379
425
|
* ```typescript
|
|
380
|
-
*
|
|
426
|
+
* import { queryGrid } from '@toolbox-web/grid';
|
|
427
|
+
*
|
|
428
|
+
* const grid = queryGrid('tbw-grid');
|
|
381
429
|
* grid.gridConfig = {
|
|
382
430
|
* getRowId: (r) => r.id,
|
|
383
431
|
* columns: [...],
|
|
@@ -41,10 +41,10 @@ import { ExportConfig, ExportFormat, ExportParams } from './types';
|
|
|
41
41
|
*
|
|
42
42
|
* @example Basic Export with Button
|
|
43
43
|
* ```ts
|
|
44
|
-
* import '@toolbox-web/grid';
|
|
44
|
+
* import { queryGrid } from '@toolbox-web/grid';
|
|
45
45
|
* import { ExportPlugin } from '@toolbox-web/grid/plugins/export';
|
|
46
46
|
*
|
|
47
|
-
* const grid =
|
|
47
|
+
* const grid = queryGrid('tbw-grid');
|
|
48
48
|
* grid.gridConfig = {
|
|
49
49
|
* columns: [
|
|
50
50
|
* { field: 'name', header: 'Name' },
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const
|
|
1
|
+
function e(e,t){return`[tbw-grid${e?`#${e}`:""}${t?`:${t}`:""}]`}function t(t,r,n,i){return`${e(n,i)} ${t}: ${r}\n\n → More info: ${function(e){return`https://toolboxjs.com/grid/errors#${e.toLowerCase()}`}(t)}`}const r='<svg viewBox="0 0 16 16" width="12" height="12"><path fill="currentColor" d="M6 10.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 0 1h-3a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5z"/></svg>',n={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:r,filterActive:r,print:"🖨️"};class i{static dependencies;static manifest;aliases;version="undefined"!=typeof __GRID_VERSION__?__GRID_VERSION__:"dev";styles;cellRenderers;headerRenderers;cellEditors;grid;config;userConfig;#e;get defaultConfig(){return{}}constructor(e={}){this.userConfig=e}attach(e){this.#e?.abort(),this.#e=new AbortController,this.grid=e,this.config={...this.defaultConfig,...this.userConfig}}detach(){this.#e?.abort(),this.#e=void 0}getPlugin(e){return this.grid?.getPlugin(e)}emit(e,t){this.grid?.dispatchEvent?.(new CustomEvent(e,{detail:t,bubbles:!0}))}emitCancelable(e,t){const r=new CustomEvent(e,{detail:t,bubbles:!0,cancelable:!0});return this.grid?.dispatchEvent?.(r),r.defaultPrevented}on(e,t){this.grid?._pluginManager?.subscribe(this,e,t)}off(e){this.grid?._pluginManager?.unsubscribe(this,e)}emitPluginEvent(e,t){this.grid?._pluginManager?.emitPluginEvent(e,t)}requestRender(){this.grid?.requestRender?.()}requestColumnsRender(){this.grid?.requestColumnsRender?.()}requestRenderWithFocus(){this.grid?.requestRenderWithFocus?.()}requestAfterRender(){this.grid?.requestAfterRender?.()}requestVirtualRefresh(){this.grid?.requestVirtualRefresh?.()}get rows(){return this.grid?.rows??[]}get sourceRows(){return this.grid?.sourceRows??[]}get columns(){return this.grid?.columns??[]}get visibleColumns(){return this.grid?._visibleColumns??[]}get gridElement(){return this.grid?._hostElement}get disconnectSignal(){return this.#e?.signal??this.grid?.disconnectSignal}get gridIcons(){const e=this.grid?.gridConfig?.icons??{};return{...n,...e}}get isAnimationEnabled(){const e=this.grid?.effectiveConfig?.animation?.mode??"reduced-motion";if(!1===e||"off"===e)return!1;if(!0===e||"on"===e)return!0;const t=this.gridElement;if(t){return"0"!==getComputedStyle(t).getPropertyValue("--tbw-animation-enabled").trim()}return!0}get animationDuration(){const e=this.gridElement;if(e){const t=getComputedStyle(e).getPropertyValue("--tbw-animation-duration").trim(),r=parseInt(t,10);if(!isNaN(r))return r}return 200}resolveIcon(e,t){return void 0!==t?t:this.gridIcons[e]}setIcon(e,t){"string"==typeof t?e.innerHTML=t:t instanceof HTMLElement&&(e.innerHTML="",e.appendChild(t.cloneNode(!0)))}warn(r,n){void 0!==n?console.warn(t(r,n,this.gridElement.id,this.name)):console.warn(`${e(this.gridElement.id,this.name)} ${r}`)}throwDiagnostic(e,r){throw new Error(t(e,r,this.gridElement.id,this.name))}}function s(e,t){return t?.length?[...t].sort((e,t)=>e-t).map(t=>e[t]).filter(e=>null!=e):e}function o(e,t=!0){if(null==e)return"";if(e instanceof Date)return e.toISOString();if("object"==typeof e)return JSON.stringify(e);const r=String(e);return t&&(r.includes(",")||r.includes('"')||r.includes("\n")||r.includes("\r"))?`"${r.replace(/"/g,'""')}"`:r}function l(e,t){const r=URL.createObjectURL(e),n=document.createElement("a");n.href=r,n.download=t,n.style.display="none",document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(r)}function a(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}class c extends i{name="export";get defaultConfig(){return{fileName:"export",includeHeaders:!0,onlyVisible:!0,onlySelected:!1}}isExportingFlag=!1;lastExportInfo=null;performExport(e,t){const r=this.config,n={format:e,fileName:t?.fileName??r.fileName??"export",includeHeaders:t?.includeHeaders??r.includeHeaders,processCell:t?.processCell,processHeader:t?.processHeader,columns:t?.columns,rowIndices:t?.rowIndices},i=function(e,t,r=!0){let n=e;if(r&&(n=n.filter(e=>!e.hidden&&!e.field.startsWith("__")&&!0!==e.meta?.utility)),t?.length){const e=new Set(t);n=n.filter(t=>e.has(t.field))}return n}(this.columns,t?.columns,r.onlyVisible);let c;if(t?.rowIndices)c=s(this.rows,t.rowIndices);else if(r.onlySelected){const e=this.getSelectionState();c=e?.selected?.size?s(this.rows,[...e.selected]):[...this.rows]}else c=[...this.rows];this.isExportingFlag=!0;let d=n.fileName;try{switch(e){case"csv":{const e=function(e,t,r,n={}){const i=n.delimiter??",",s=n.newline??"\n",l=[],a=n.bom?"\ufeff":"";if(!1!==r.includeHeaders){const e=t.map(e=>{const t=e.header||e.field;return o(r.processHeader?r.processHeader(t,e.field):t)});l.push(e.join(i))}for(const c of e){const e=t.map(e=>{let t=c[e.field];return r.processCell&&(t=r.processCell(t,e.field,c)),o(t)});l.push(e.join(i))}return a+l.join(s)}(c,i,n,{bom:!0});d=d.endsWith(".csv")?d:`${d}.csv`,function(e,t){l(new Blob([e],{type:"text/csv;charset=utf-8;"}),t)}(e,d);break}case"excel":{const e=function(e,t,r){let n='<?xml version="1.0" encoding="UTF-8"?>\n<?mso-application progid="Excel.Sheet"?>\n<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"\n xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet">\n<Worksheet ss:Name="Sheet1">\n<Table>';if(!1!==r.includeHeaders){n+="\n<Row>";for(const e of t){const t=e.header||e.field;n+=`<Cell><Data ss:Type="String">${a(r.processHeader?r.processHeader(t,e.field):t)}</Data></Cell>`}n+="</Row>"}for(const i of e){n+="\n<Row>";for(const e of t){let t=i[e.field];r.processCell&&(t=r.processCell(t,e.field,i));let s="String",o="";null==t?o="":"number"!=typeof t||isNaN(t)?t instanceof Date?(s="DateTime",o=t.toISOString()):o=a(String(t)):(s="Number",o=String(t)),n+=`<Cell><Data ss:Type="${s}">${o}</Data></Cell>`}n+="</Row>"}return n+="\n</Table>\n</Worksheet>\n</Workbook>",n}(c,i,n);d=d.endsWith(".xls")?d:`${d}.xls`,function(e,t){const r=t.endsWith(".xls")?t:`${t}.xls`;l(new Blob([e],{type:"application/vnd.ms-excel;charset=utf-8;"}),r)}(e,d);break}case"json":{const e=c.map(e=>{const t={};for(const r of i){let i=e[r.field];n.processCell&&(i=n.processCell(i,r.field,e)),t[r.field]=i}return t}),t=JSON.stringify(e,null,2);d=d.endsWith(".json")?d:`${d}.json`;l(new Blob([t],{type:"application/json"}),d);break}}this.lastExportInfo={format:e,timestamp:/* @__PURE__ */new Date},this.emit("export-complete",{format:e,fileName:d,rowCount:c.length,columnCount:i.length})}finally{this.isExportingFlag=!1}}getSelectionState(){try{return this.grid?.getPluginState?.("selection")??null}catch{return null}}exportCsv(e){this.performExport("csv",e)}exportExcel(e){this.performExport("excel",e)}exportJson(e){this.performExport("json",e)}isExporting(){return this.isExportingFlag}getLastExport(){return this.lastExportInfo}}export{c as ExportPlugin};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|