@toolbox-web/grid 1.26.1 → 1.27.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 +64 -1
- package/lib/core/internal/diagnostics.d.ts +4 -3
- package/lib/core/internal/row-manager.d.ts +3 -1
- package/lib/core/plugin/base-plugin.d.ts +2 -2
- package/lib/core/types.d.ts +59 -3
- package/lib/features/registry.js.map +1 -1
- package/lib/plugins/clipboard/ClipboardPlugin.d.ts +1 -1
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/column-virtualization/index.js.map +1 -1
- package/lib/plugins/context-menu/ContextMenuPlugin.d.ts +24 -5
- package/lib/plugins/context-menu/index.js.map +1 -1
- package/lib/plugins/editing/EditingPlugin.d.ts +1 -1
- package/lib/plugins/editing/index.js.map +1 -1
- package/lib/plugins/export/ExportPlugin.d.ts +1 -1
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/filtering/index.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/GroupingColumnsPlugin.d.ts +2 -2
- package/lib/plugins/grouping-columns/grouping-columns.d.ts +18 -3
- package/lib/plugins/grouping-columns/index.d.ts +0 -1
- package/lib/plugins/grouping-columns/index.js +1 -1
- package/lib/plugins/grouping-columns/index.js.map +1 -1
- package/lib/plugins/grouping-columns/types.d.ts +1 -7
- package/lib/plugins/grouping-rows/index.d.ts +2 -1
- package/lib/plugins/grouping-rows/index.js +1 -1
- package/lib/plugins/grouping-rows/index.js.map +1 -1
- package/lib/plugins/master-detail/MasterDetailPlugin.d.ts +2 -0
- package/lib/plugins/master-detail/index.js +1 -1
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/master-detail/types.d.ts +20 -1
- package/lib/plugins/multi-sort/index.js.map +1 -1
- package/lib/plugins/pinned-columns/PinnedColumnsPlugin.d.ts +8 -1
- package/lib/plugins/pinned-columns/index.js +1 -1
- package/lib/plugins/pinned-columns/index.js.map +1 -1
- package/lib/plugins/pinned-columns/pinned-columns.d.ts +11 -1
- package/lib/plugins/pinned-rows/index.d.ts +1 -1
- package/lib/plugins/pinned-rows/index.js +1 -1
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pinned-rows/types.d.ts +10 -3
- package/lib/plugins/pivot/PivotPlugin.d.ts +107 -1
- package/lib/plugins/pivot/index.d.ts +2 -1
- package/lib/plugins/pivot/index.js +1 -1
- package/lib/plugins/pivot/index.js.map +1 -1
- package/lib/plugins/print/index.js.map +1 -1
- package/lib/plugins/print/types.d.ts +0 -3
- package/lib/plugins/reorder-columns/ReorderPlugin.d.ts +19 -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/index.d.ts +1 -1
- package/lib/plugins/reorder-rows/index.js.map +1 -1
- package/lib/plugins/responsive/ResponsivePlugin.d.ts +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 +1 -1
- package/lib/plugins/selection/index.js +1 -1
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/selection/types.d.ts +3 -3
- package/lib/plugins/server-side/ServerSidePlugin.d.ts +6 -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 +116 -0
- package/lib/plugins/tree/index.d.ts +1 -1
- package/lib/plugins/tree/index.js +1 -1
- package/lib/plugins/tree/index.js.map +1 -1
- package/lib/plugins/tree/types.d.ts +16 -1
- package/lib/plugins/undo-redo/UndoRedoPlugin.d.ts +1 -1
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/undo-redo/types.d.ts +15 -3
- package/lib/plugins/visibility/VisibilityPlugin.d.ts +18 -5
- package/lib/plugins/visibility/index.js +1 -1
- package/lib/plugins/visibility/index.js.map +1 -1
- package/package.json +1 -1
- package/public.d.ts +2 -4
- package/themes/dg-theme-material.css +16 -4
- 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.map +1 -1
- package/umd/plugins/context-menu.umd.js.map +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 +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 +1 -1
- package/umd/plugins/grouping-rows.umd.js.map +1 -1
- package/umd/plugins/master-detail.umd.js +1 -1
- package/umd/plugins/master-detail.umd.js.map +1 -1
- package/umd/plugins/pinned-columns.umd.js +1 -1
- package/umd/plugins/pinned-columns.umd.js.map +1 -1
- package/umd/plugins/pinned-rows.umd.js +1 -1
- package/umd/plugins/pinned-rows.umd.js.map +1 -1
- package/umd/plugins/pivot.umd.js +1 -1
- package/umd/plugins/pivot.umd.js.map +1 -1
- package/umd/plugins/reorder-columns.umd.js +1 -1
- package/umd/plugins/reorder-columns.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/server-side.umd.js +1 -1
- package/umd/plugins/server-side.umd.js.map +1 -1
- package/umd/plugins/tree.umd.js +1 -1
- package/umd/plugins/tree.umd.js.map +1 -1
- package/umd/plugins/undo-redo.umd.js.map +1 -1
- package/umd/plugins/visibility.umd.js +1 -1
- package/umd/plugins/visibility.umd.js.map +1 -1
|
@@ -71,14 +71,24 @@ export declare function calculateLeftStickyOffsets(columns: any[], getColumnWidt
|
|
|
71
71
|
* @returns Map of field to right offset
|
|
72
72
|
*/
|
|
73
73
|
export declare function calculateRightStickyOffsets(columns: any[], getColumnWidth: (field: string) => number, direction?: TextDirection): Map<string, number>;
|
|
74
|
+
/**
|
|
75
|
+
* Adjustments to `group-end` borders at pin boundaries within implicit groups.
|
|
76
|
+
* - `addGroupEnd`: fields that should gain `group-end` (last pinned column at boundary)
|
|
77
|
+
* - `removeGroupEnd`: fields that should lose `group-end` (lone non-pinned remnant)
|
|
78
|
+
*/
|
|
79
|
+
export interface GroupEndAdjustments {
|
|
80
|
+
addGroupEnd: Set<string>;
|
|
81
|
+
removeGroupEnd: Set<string>;
|
|
82
|
+
}
|
|
74
83
|
/**
|
|
75
84
|
* Apply sticky offsets to header and body cells.
|
|
76
85
|
* This modifies the DOM elements in place.
|
|
77
86
|
*
|
|
78
87
|
* @param host - The grid host element (render root for DOM queries)
|
|
79
88
|
* @param columns - Array of column configurations
|
|
89
|
+
* @returns Group-end adjustments for `afterCellRender` hooks to maintain during scroll
|
|
80
90
|
*/
|
|
81
|
-
export declare function applyStickyOffsets(host: HTMLElement, columns: any[]):
|
|
91
|
+
export declare function applyStickyOffsets(host: HTMLElement, columns: any[]): GroupEndAdjustments;
|
|
82
92
|
/**
|
|
83
93
|
* Reorder columns so that pinned-left columns come first and pinned-right columns come last.
|
|
84
94
|
* Maintains the relative order within each group (left-pinned, unpinned, right-pinned).
|
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* @module Plugins/Pinned Rows
|
|
6
6
|
*/
|
|
7
7
|
export { PinnedRowsPlugin } from './PinnedRowsPlugin';
|
|
8
|
-
export type { AggregationRowConfig, AggregatorDefinition, PinnedRowsConfig, PinnedRowsContext, PinnedRowsPanel, } from './types';
|
|
8
|
+
export type { AggregationRowConfig, AggregatorConfig, AggregatorDefinition, AggregatorFormatter, PinnedRowsConfig, PinnedRowsContext, PinnedRowsPanel, PinnedRowsPosition, } from './types';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function t(t,e){return`[tbw-grid${t?`#${t}`:""}${e?`:${e}`:""}]`}function e(e,n,i,o){return`${t(i,o)} ${e}: ${n}\n\n → More info: ${function(t){return`https://toolboxjs.com/grid/errors#${t.toLowerCase()}`}(e)}`}const n='<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>',i={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:n,filterActive:n,print:"🖨️"};class o{static dependencies;static manifest;aliases;version="undefined"!=typeof __GRID_VERSION__?__GRID_VERSION__:"dev";styles;cellRenderers;headerRenderers;cellEditors;grid;config;userConfig;#t;get defaultConfig(){return{}}constructor(t={}){this.userConfig=t}attach(t){this.#t?.abort(),this.#t=new AbortController,this.grid=t,this.config={...this.defaultConfig,...this.userConfig}}detach(){this.#t?.abort(),this.#t=void 0}getPlugin(t){return this.grid?.getPlugin(t)}emit(t,e){this.grid?.dispatchEvent?.(new CustomEvent(t,{detail:e,bubbles:!0}))}emitCancelable(t,e){const n=new CustomEvent(t,{detail:e,bubbles:!0,cancelable:!0});return this.grid?.dispatchEvent?.(n),n.defaultPrevented}on(t,e){this.grid?._pluginManager?.subscribe(this,t,e)}off(t){this.grid?._pluginManager?.unsubscribe(this,t)}emitPluginEvent(t,e){this.grid?._pluginManager?.emitPluginEvent(t,e)}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.#t?.signal??this.grid?.disconnectSignal}get gridIcons(){const t=this.grid?.gridConfig?.icons??{};return{...i,...t}}get isAnimationEnabled(){const t=this.grid?.effectiveConfig?.animation?.mode??"reduced-motion";if(!1===t||"off"===t)return!1;if(!0===t||"on"===t)return!0;const e=this.gridElement;if(e){return"0"!==getComputedStyle(e).getPropertyValue("--tbw-animation-enabled").trim()}return!0}get animationDuration(){const t=this.gridElement;if(t){const e=getComputedStyle(t).getPropertyValue("--tbw-animation-duration").trim(),n=parseInt(e,10);if(!isNaN(n))return n}return 200}resolveIcon(t,e){return void 0!==e?e:this.gridIcons[t]}setIcon(t,e){"string"==typeof e?t.innerHTML=e:e instanceof HTMLElement&&(t.innerHTML="",t.appendChild(e.cloneNode(!0)))}warn(n,i){void 0!==i?console.warn(e(n,i,this.gridElement.id,this.name)):console.warn(`${t(this.gridElement.id,this.name)} ${n}`)}throwDiagnostic(t,n){throw new Error(e(t,n,this.gridElement.id,this.name))}}const r={sum:(t,e)=>t.reduce((t,n)=>t+(Number(n[e])||0),0),avg:(t,e)=>{const n=t.reduce((t,n)=>t+(Number(n[e])||0),0);return t.length?n/t.length:0},count:t=>t.length,min:(t,e)=>t.length?Math.min(...t.map(t=>Number(t[e])||1/0)):0,max:(t,e)=>t.length?Math.max(...t.map(t=>Number(t[e])||-1/0)):0,first:(t,e)=>t[0]?.[e],last:(t,e)=>t[t.length-1]?.[e]},s=/* @__PURE__ */new Map,a={register(t,e){s.set(t,e)},unregister(t){s.delete(t)},get(t){if(void 0!==t)return"function"==typeof t?t:s.get(t)??r[t]},run(t,e,n,i){const o=this.get(t);return o?o(e,n,i):void 0},has:t=>s.has(t)||t in r,list:()=>[...Object.keys(r),...s.keys()]};a.register.bind(a),a.unregister.bind(a);const l=a.get.bind(a);function g(t,e){const n=document.createElement("div");n.className="tbw-pinned-rows",n.setAttribute("role","presentation"),n.setAttribute("aria-live","polite");const i=document.createElement("div");i.className="tbw-pinned-rows-left";const o=document.createElement("div");o.className="tbw-pinned-rows-center";const r=document.createElement("div");if(r.className="tbw-pinned-rows-right",!1!==t.showRowCount){const t=document.createElement("span");t.className="tbw-status-panel tbw-status-panel-row-count",t.textContent=`Total: ${e.totalRows} rows`,i.appendChild(t)}if(t.showFilteredCount&&e.filteredRows!==e.totalRows){const t=document.createElement("span");t.className="tbw-status-panel tbw-status-panel-filtered-count",t.textContent=`Filtered: ${e.filteredRows}`,i.appendChild(t)}if(t.showSelectedCount&&e.selectedRows>0){const t=document.createElement("span");t.className="tbw-status-panel tbw-status-panel-selected-count",t.textContent=`Selected: ${e.selectedRows}`,r.appendChild(t)}if(t.customPanels)for(const s of t.customPanels){const t=f(s,e);switch(s.position){case"left":i.appendChild(t);break;case"center":o.appendChild(t);break;case"right":r.appendChild(t)}}return n.appendChild(i),n.appendChild(o),n.appendChild(r),n}function c(t){const e=document.createElement("div");return e.className=`tbw-aggregation-rows tbw-aggregation-rows-${t}`,e.setAttribute("role","presentation"),e}function d(t,e,n,i,o=!1){t.innerHTML="";for(const r of e){const e=document.createElement("div");e.className="tbw-aggregation-row",e.setAttribute("role","presentation"),r.id&&e.setAttribute("data-aggregation-id",r.id);r.fullWidth??o?h(e,r,n,i):u(e,r,n,i),t.appendChild(e)}}function h(t,e,n,i){const o=document.createElement("div");o.className="tbw-aggregation-cell tbw-aggregation-cell-full",o.style.gridColumn="1 / -1";const r="function"==typeof e.label?e.label(i,n):e.label;if(r){const t=document.createElement("span");t.className="tbw-aggregation-label",t.textContent=r,o.appendChild(t)}const s=function(t,e,n){const i=t.aggregators&&Object.keys(t.aggregators).length>0,o=t.cells&&Object.keys(t.cells).length>0;if(!i&&!o)return null;const r=document.createElement("span");r.className="tbw-aggregation-aggregates";for(const s of e){const{value:e,formatter:i}=p(t,s,n);if(null!=e){const t=document.createElement("span");t.className="tbw-aggregation-aggregate",t.setAttribute("data-field",s.field);const n=s.header??s.field,o=i?i(e,s.field,s):String(e);t.textContent=`${n}: ${o}`,r.appendChild(t)}}return r.children.length>0?r:null}(e,n,i);s&&o.appendChild(s),t.appendChild(o)}function u(t,e,n,i){for(const o of n){const n=document.createElement("div");n.className="tbw-aggregation-cell",n.setAttribute("data-field",o.field);const{value:r,formatter:s}=p(e,o,i);n.textContent=null!=r?s?s(r,o.field,o):String(r):"",t.appendChild(n)}}function p(t,e,n){let i,o;const r=t.aggregators?.[e.field];if(r)if("object"==typeof(s=r)&&null!==s&&"aggFunc"in s){const t=l(r.aggFunc);t&&(i=t(n,e.field,e)),o=r.formatter}else{const t=l(r);t&&(i=t(n,e.field,e))}else if(t.cells&&Object.prototype.hasOwnProperty.call(t.cells,e.field)){const o=t.cells[e.field];i="function"==typeof o?o(n,e.field,e):o}var s;return{value:i,formatter:o}}function f(t,e){const n=document.createElement("div");n.className="tbw-status-panel tbw-status-panel-custom",n.id=`status-panel-${t.id}`;const i=t.render(e);return"string"==typeof i?n.innerHTML=i:n.appendChild(i),n}function m(t,e,n,i,o){return{totalRows:t.length,filteredRows:o?.cachedResult?.length??t.length,selectedRows:i?.selected?.size??0,columns:e,rows:t,grid:n}}a.run.bind(a),a.list.bind(a);class b extends o{name="pinnedRows";styles="@layer tbw-plugins{.tbw-footer{flex-shrink:0;z-index:var(--tbw-z-layer-pinned-rows, 20);background:var(--tbw-color-panel-bg)}.tbw-pinned-rows{display:flex;align-items:center;justify-content:space-between;padding:var(--tbw-button-padding, var(--tbw-spacing-md, .5rem) var(--tbw-spacing-lg, .75rem));background:var(--tbw-pinned-rows-bg, var(--tbw-color-panel-bg));border-top:1px solid var(--tbw-pinned-rows-border, var(--tbw-color-border));font-size:var(--tbw-font-size-xs, .75rem);color:var(--tbw-pinned-rows-color, var(--tbw-color-fg-muted));min-height:32px;box-sizing:border-box;min-width:fit-content}.tbw-pinned-rows-left,.tbw-pinned-rows-center,.tbw-pinned-rows-right{display:flex;align-items:center;gap:var(--tbw-spacing-xl, 1rem)}.tbw-pinned-rows-left{justify-content:flex-start}.tbw-pinned-rows-center{justify-content:center;flex:1}.tbw-pinned-rows-right{justify-content:flex-end}.tbw-status-panel{white-space:nowrap}.tbw-aggregation-rows{min-width:fit-content;background:var(--tbw-aggregation-bg, var(--tbw-color-header-bg))}.tbw-aggregation-rows-top{border-bottom:1px solid var(--tbw-aggregation-border, var(--tbw-color-border))}.tbw-aggregation-rows-bottom{border-top:1px solid var(--tbw-aggregation-border, var(--tbw-color-border))}.tbw-aggregation-row{display:grid;grid-template-columns:var(--tbw-column-template);font-size:var(--tbw-aggregation-font-size, .8em);font-weight:var(--tbw-aggregation-font-weight, 600)}.tbw-aggregation-cell{padding:var(--tbw-cell-padding, .125rem .5rem);min-height:var(--tbw-row-height, 1.75rem);display:block;align-items:center;align-content:center;border-right:1px solid var(--tbw-color-border-cell);overflow:hidden;text-overflow:ellipsis;white-space:var(--tbw-cell-white-space, nowrap)}.tbw-aggregation-cell:last-child{border-right:0}.tbw-aggregation-cell-full{grid-column:1 / -1;border-right:0;display:flex;align-items:center;gap:var(--tbw-spacing-lg, .75rem)}.tbw-aggregation-label{white-space:nowrap}.tbw-aggregation-aggregates{display:flex;align-items:center;gap:var(--tbw-spacing-lg, .75rem);font-weight:400;opacity:.85}.tbw-aggregation-aggregate{white-space:nowrap}}";get defaultConfig(){return{position:"bottom",showRowCount:!0,showSelectedCount:!0,showFilteredCount:!0}}infoBarElement=null;topAggregationContainer=null;bottomAggregationContainer=null;footerWrapper=null;detach(){this.infoBarElement&&(this.infoBarElement.remove(),this.infoBarElement=null),this.topAggregationContainer&&(this.topAggregationContainer.remove(),this.topAggregationContainer=null),this.bottomAggregationContainer&&(this.bottomAggregationContainer.remove(),this.bottomAggregationContainer=null),this.footerWrapper&&(this.footerWrapper.remove(),this.footerWrapper=null)}afterRender(){const t=this.gridElement;if(!t)return;const e=t.querySelector(".tbw-scroll-area")??t.querySelector(".tbw-grid-content")??t.children[0];if(!e)return;this.footerWrapper&&!e.contains(this.footerWrapper)&&(this.footerWrapper=null,this.bottomAggregationContainer=null,this.infoBarElement=null),this.topAggregationContainer&&!e.contains(this.topAggregationContainer)&&(this.topAggregationContainer=null),this.infoBarElement&&!e.contains(this.infoBarElement)&&(this.infoBarElement=null);const n=this.getSelectionState(),i=this.getFilterState(),o=m(this.sourceRows,this.columns,this.gridElement,n,i),r=this.config.aggregationRows||[],s=r.filter(t=>"top"===t.position),a=r.filter(t=>"top"!==t.position);if(s.length>0){if(!this.topAggregationContainer){this.topAggregationContainer=c("top");const n=t.querySelector(".header");n&&n.nextSibling?e.insertBefore(this.topAggregationContainer,n.nextSibling):e.appendChild(this.topAggregationContainer)}d(this.topAggregationContainer,s,this.visibleColumns,this.sourceRows,this.config.fullWidth)}else this.topAggregationContainer&&(this.topAggregationContainer.remove(),this.topAggregationContainer=null);const l=!1!==this.config.showRowCount||this.config.showSelectedCount&&o.selectedRows>0||this.config.showFilteredCount&&o.filteredRows!==o.totalRows||this.config.customPanels&&this.config.customPanels.length>0,h=l&&"top"!==this.config.position,u=a.length>0||h;if(l&&"top"===this.config.position)if(this.infoBarElement){const t=g(this.config,o);this.infoBarElement.replaceWith(t),this.infoBarElement=t}else this.infoBarElement=g(this.config,o),e.insertBefore(this.infoBarElement,e.firstChild);else"top"===this.config.position&&this.infoBarElement&&(this.infoBarElement.remove(),this.infoBarElement=null);u?(this.footerWrapper||(this.footerWrapper=document.createElement("div"),this.footerWrapper.className="tbw-footer",e.appendChild(this.footerWrapper)),this.footerWrapper.innerHTML="",a.length>0&&(this.bottomAggregationContainer||(this.bottomAggregationContainer=c("bottom")),this.footerWrapper.appendChild(this.bottomAggregationContainer),d(this.bottomAggregationContainer,a,this.visibleColumns,this.sourceRows,this.config.fullWidth)),h&&(this.infoBarElement=g(this.config,o),this.footerWrapper.appendChild(this.infoBarElement))):this.cleanupFooter()}cleanup(){this.infoBarElement&&(this.infoBarElement.remove(),this.infoBarElement=null),this.topAggregationContainer&&(this.topAggregationContainer.remove(),this.topAggregationContainer=null),this.bottomAggregationContainer&&(this.bottomAggregationContainer.remove(),this.bottomAggregationContainer=null),this.footerWrapper&&(this.footerWrapper.remove(),this.footerWrapper=null)}cleanupFooter(){this.footerWrapper&&(this.footerWrapper.remove(),this.footerWrapper=null),this.bottomAggregationContainer&&(this.bottomAggregationContainer.remove(),this.bottomAggregationContainer=null),this.infoBarElement&&"top"!==this.config.position&&(this.infoBarElement.remove(),this.infoBarElement=null)}getSelectionState(){try{return this.grid?.getPluginState?.("selection")??null}catch{return null}}getFilterState(){try{return this.grid?.getPluginState?.("filtering")??null}catch{return null}}refresh(){this.requestRender()}getContext(){const t=this.getSelectionState(),e=this.getFilterState();return m(this.rows,this.columns,this.gridElement,t,e)}addPanel(t){this.config.customPanels||(this.config.customPanels=[]),this.config.customPanels.push(t),this.requestRender()}removePanel(t){this.config.customPanels&&(this.config.customPanels=this.config.customPanels.filter(e=>e.id!==t),this.requestRender())}addAggregationRow(t){this.config.aggregationRows||(this.config.aggregationRows=[]),this.config.aggregationRows.push(t),this.requestRender()}removeAggregationRow(t){this.config.aggregationRows&&(this.config.aggregationRows=this.config.aggregationRows.filter(e=>e.id!==t),this.requestRender())}}export{b as PinnedRowsPlugin};
|
|
1
|
+
function t(t,e){return`[tbw-grid${t?`#${t}`:""}${e?`:${e}`:""}]`}function e(e,n,i,o){return`${t(i,o)} ${e}: ${n}\n\n → More info: ${function(t){return`https://toolboxjs.com/grid/errors#${t.toLowerCase()}`}(e)}`}const n='<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>',i={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:n,filterActive:n,print:"🖨️"};class o{static dependencies;static manifest;aliases;version="undefined"!=typeof __GRID_VERSION__?__GRID_VERSION__:"dev";styles;cellRenderers;headerRenderers;cellEditors;grid;config;userConfig;#t;get defaultConfig(){return{}}constructor(t={}){this.userConfig=t}attach(t){this.#t?.abort(),this.#t=new AbortController,this.grid=t,this.config={...this.defaultConfig,...this.userConfig}}detach(){this.#t?.abort(),this.#t=void 0}getPlugin(t){return this.grid?.getPlugin(t)}emit(t,e){this.grid?.dispatchEvent?.(new CustomEvent(t,{detail:e,bubbles:!0}))}emitCancelable(t,e){const n=new CustomEvent(t,{detail:e,bubbles:!0,cancelable:!0});return this.grid?.dispatchEvent?.(n),n.defaultPrevented}on(t,e){this.grid?._pluginManager?.subscribe(this,t,e)}off(t){this.grid?._pluginManager?.unsubscribe(this,t)}emitPluginEvent(t,e){this.grid?._pluginManager?.emitPluginEvent(t,e)}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.#t?.signal??this.grid?.disconnectSignal}get gridIcons(){const t=this.grid?.gridConfig?.icons??{};return{...i,...t}}get isAnimationEnabled(){const t=this.grid?.effectiveConfig?.animation?.mode??"reduced-motion";if(!1===t||"off"===t)return!1;if(!0===t||"on"===t)return!0;const e=this.gridElement;if(e){return"0"!==getComputedStyle(e).getPropertyValue("--tbw-animation-enabled").trim()}return!0}get animationDuration(){const t=this.gridElement;if(t){const e=getComputedStyle(t).getPropertyValue("--tbw-animation-duration").trim(),n=parseInt(e,10);if(!isNaN(n))return n}return 200}resolveIcon(t,e){return void 0!==e?e:this.gridIcons[t]}setIcon(t,e){"string"==typeof e?t.innerHTML=e:e instanceof HTMLElement&&(t.innerHTML="",t.appendChild(e.cloneNode(!0)))}warn(n,i){void 0!==i?console.warn(e(n,i,this.gridElement.id,this.name)):console.warn(`${t(this.gridElement.id,this.name)} ${n}`)}throwDiagnostic(t,n){throw new Error(e(t,n,this.gridElement.id,this.name))}}const r={sum:(t,e)=>t.reduce((t,n)=>t+(Number(n[e])||0),0),avg:(t,e)=>{const n=t.reduce((t,n)=>t+(Number(n[e])||0),0);return t.length?n/t.length:0},count:t=>t.length,min:(t,e)=>t.length?Math.min(...t.map(t=>Number(t[e])||1/0)):0,max:(t,e)=>t.length?Math.max(...t.map(t=>Number(t[e])||-1/0)):0,first:(t,e)=>t[0]?.[e],last:(t,e)=>t[t.length-1]?.[e]},s=/* @__PURE__ */new Map,a={register(t,e){s.set(t,e)},unregister(t){s.delete(t)},get(t){if(void 0!==t)return"function"==typeof t?t:s.get(t)??r[t]},run(t,e,n,i){const o=this.get(t);return o?o(e,n,i):void 0},has:t=>s.has(t)||t in r,list:()=>[...Object.keys(r),...s.keys()]};a.register.bind(a),a.unregister.bind(a);const l=a.get.bind(a);function g(t,e){const n=document.createElement("div");n.className="tbw-pinned-rows",n.setAttribute("role","presentation"),n.setAttribute("aria-live","polite");const i=document.createElement("div");i.className="tbw-pinned-rows-left";const o=document.createElement("div");o.className="tbw-pinned-rows-center";const r=document.createElement("div");if(r.className="tbw-pinned-rows-right",!1!==t.showRowCount){const t=document.createElement("span");t.className="tbw-status-panel tbw-status-panel-row-count",t.textContent=`Total: ${e.totalRows} rows`,i.appendChild(t)}if(t.showFilteredCount&&e.filteredRows!==e.totalRows){const t=document.createElement("span");t.className="tbw-status-panel tbw-status-panel-filtered-count",t.textContent=`Filtered: ${e.filteredRows}`,i.appendChild(t)}if(t.showSelectedCount&&e.selectedRows>0){const t=document.createElement("span");t.className="tbw-status-panel tbw-status-panel-selected-count",t.textContent=`Selected: ${e.selectedRows}`,r.appendChild(t)}if(t.customPanels)for(const s of t.customPanels){const t=f(s,e);switch(s.position){case"left":i.appendChild(t);break;case"center":o.appendChild(t);break;case"right":r.appendChild(t)}}return n.appendChild(i),n.appendChild(o),n.appendChild(r),n}function c(t){const e=document.createElement("div");return e.className=`tbw-aggregation-rows tbw-aggregation-rows-${t}`,e.setAttribute("role","presentation"),e}function d(t,e,n,i,o=!1){t.innerHTML="";for(const r of e){const e=document.createElement("div");e.className="tbw-aggregation-row",e.setAttribute("role","presentation"),r.id&&e.setAttribute("data-aggregation-id",r.id);r.fullWidth??o?h(e,r,n,i):u(e,r,n,i),t.appendChild(e)}}function h(t,e,n,i){const o=document.createElement("div");o.className="tbw-aggregation-cell tbw-aggregation-cell-full",o.style.gridColumn="1 / -1";const r="function"==typeof e.label?e.label(i,n):e.label;if(r){const t=document.createElement("span");t.className="tbw-aggregation-label",t.textContent=r,o.appendChild(t)}const s=function(t,e,n){const i=t.aggregators&&Object.keys(t.aggregators).length>0,o=t.cells&&Object.keys(t.cells).length>0;if(!i&&!o)return null;const r=document.createElement("span");r.className="tbw-aggregation-aggregates";for(const s of e){const{value:e,formatter:i}=p(t,s,n);if(null!=e){const t=document.createElement("span");t.className="tbw-aggregation-aggregate",t.setAttribute("data-field",s.field);const n=s.header??s.field,o=i?i(e,s.field,s):String(e);t.textContent=`${n}: ${o}`,r.appendChild(t)}}return r.children.length>0?r:null}(e,n,i);s&&o.appendChild(s),t.appendChild(o)}function u(t,e,n,i){for(const r of n){const n=document.createElement("div");n.className="tbw-aggregation-cell",n.setAttribute("data-field",r.field);const{value:o,formatter:s}=p(e,r,i);n.textContent=null!=o?s?s(o,r.field,r):String(o):"",t.appendChild(n)}const o="function"==typeof e.label?e.label(i,n):e.label;if(o){const e=document.createElement("span");e.className="tbw-aggregation-label",e.textContent=o,t.appendChild(e)}}function p(t,e,n){let i,o;const r=t.aggregators?.[e.field];if(r)if("object"==typeof(s=r)&&null!==s&&"aggFunc"in s){const t=l(r.aggFunc);t&&(i=t(n,e.field,e)),o=r.formatter}else{const t=l(r);t&&(i=t(n,e.field,e))}else if(t.cells&&Object.prototype.hasOwnProperty.call(t.cells,e.field)){const o=t.cells[e.field];i="function"==typeof o?o(n,e.field,e):o}var s;return{value:i,formatter:o}}function f(t,e){const n=document.createElement("div");n.className="tbw-status-panel tbw-status-panel-custom",n.id=`status-panel-${t.id}`;const i=t.render(e);return"string"==typeof i?n.innerHTML=i:n.appendChild(i),n}function m(t,e,n,i,o){return{totalRows:t.length,filteredRows:o?.cachedResult?.length??t.length,selectedRows:i?.selected?.size??0,columns:e,rows:t,grid:n}}a.run.bind(a),a.list.bind(a);class b extends o{name="pinnedRows";styles="@layer tbw-plugins{.tbw-scroll-area{container-type:inline-size}.tbw-footer{flex-shrink:0;z-index:var(--tbw-z-layer-pinned-rows, 20);background:var(--tbw-color-panel-bg);min-width:fit-content}.tbw-pinned-rows{display:flex;align-items:center;justify-content:space-between;padding:var(--tbw-button-padding, var(--tbw-spacing-md, .5rem) var(--tbw-spacing-lg, .75rem));background:var(--tbw-pinned-rows-bg, var(--tbw-color-panel-bg));border-top:1px solid var(--tbw-pinned-rows-border, var(--tbw-color-border));font-size:var(--tbw-font-size-xs, .75rem);color:var(--tbw-pinned-rows-color, var(--tbw-color-fg-muted));min-height:32px;box-sizing:border-box;position:sticky;left:0;min-width:0;width:100cqi}.tbw-pinned-rows-left,.tbw-pinned-rows-center,.tbw-pinned-rows-right{display:flex;align-items:center;gap:var(--tbw-spacing-xl, 1rem)}.tbw-pinned-rows-left{justify-content:flex-start}.tbw-pinned-rows-center{justify-content:center;flex:1}.tbw-pinned-rows-right{justify-content:flex-end}.tbw-status-panel{white-space:nowrap}.tbw-aggregation-rows{min-width:fit-content;background:var(--tbw-aggregation-bg, var(--tbw-color-header-bg))}.tbw-aggregation-rows-top{border-bottom:1px solid var(--tbw-aggregation-border, var(--tbw-color-border))}.tbw-aggregation-rows-bottom{border-top:1px solid var(--tbw-aggregation-border, var(--tbw-color-border))}.tbw-aggregation-row{display:grid;grid-template-columns:var(--tbw-column-template);font-size:var(--tbw-aggregation-font-size, .8em);font-weight:var(--tbw-aggregation-font-weight, 600);position:relative;background:inherit}.tbw-aggregation-row>.tbw-aggregation-label{position:sticky;left:0;grid-row:1;grid-column:1;display:flex;align-items:center;padding:var(--tbw-cell-padding, .125rem .5rem);background:inherit;z-index:1;pointer-events:none}.tbw-aggregation-row>.tbw-aggregation-cell:first-child{grid-column:1;grid-row:1}.tbw-aggregation-cell:not(:empty){position:relative;z-index:2;background:inherit}.tbw-aggregation-cell{padding:var(--tbw-cell-padding, .125rem .5rem);min-height:var(--tbw-row-height, 1.75rem);display:block;align-items:center;align-content:center;border-right:1px solid var(--tbw-color-border-cell);overflow:hidden;text-overflow:ellipsis;white-space:var(--tbw-cell-white-space, nowrap)}.tbw-aggregation-cell:last-child{border-right:0}.tbw-aggregation-cell-full{grid-column:1 / -1;border-right:0;display:flex;align-items:center;gap:var(--tbw-spacing-lg, .75rem)}.tbw-aggregation-label{white-space:nowrap}.tbw-aggregation-aggregates{display:flex;align-items:center;gap:var(--tbw-spacing-lg, .75rem);font-weight:400;opacity:.85}.tbw-aggregation-aggregate{white-space:nowrap}}";get defaultConfig(){return{position:"bottom",showRowCount:!0,showSelectedCount:!0,showFilteredCount:!0}}infoBarElement=null;topAggregationContainer=null;bottomAggregationContainer=null;footerWrapper=null;detach(){this.infoBarElement&&(this.infoBarElement.remove(),this.infoBarElement=null),this.topAggregationContainer&&(this.topAggregationContainer.remove(),this.topAggregationContainer=null),this.bottomAggregationContainer&&(this.bottomAggregationContainer.remove(),this.bottomAggregationContainer=null),this.footerWrapper&&(this.footerWrapper.remove(),this.footerWrapper=null)}afterRender(){const t=this.gridElement;if(!t)return;const e=t.querySelector(".tbw-scroll-area")??t.querySelector(".tbw-grid-content")??t.querySelector(".tbw-grid-root");if(!e)return;this.footerWrapper&&!e.contains(this.footerWrapper)&&(this.footerWrapper=null,this.bottomAggregationContainer=null,this.infoBarElement=null),this.topAggregationContainer&&!e.contains(this.topAggregationContainer)&&(this.topAggregationContainer=null),this.infoBarElement&&!e.contains(this.infoBarElement)&&(this.infoBarElement=null);const n=this.getSelectionState(),i=this.getFilterState(),o=m(this.sourceRows,this.columns,this.gridElement,n,i),r=this.config.aggregationRows||[],s=r.filter(t=>"top"===t.position),a=r.filter(t=>"top"!==t.position);if(s.length>0){if(!this.topAggregationContainer){this.topAggregationContainer=c("top");const n=t.querySelector(".header");n&&n.nextSibling?e.insertBefore(this.topAggregationContainer,n.nextSibling):e.appendChild(this.topAggregationContainer)}d(this.topAggregationContainer,s,this.visibleColumns,this.sourceRows,this.config.fullWidth)}else this.topAggregationContainer&&(this.topAggregationContainer.remove(),this.topAggregationContainer=null);const l=!1!==this.config.showRowCount||this.config.showSelectedCount&&o.selectedRows>0||this.config.showFilteredCount&&o.filteredRows!==o.totalRows||this.config.customPanels&&this.config.customPanels.length>0,h=l&&"top"!==this.config.position,u=a.length>0||h;if(l&&"top"===this.config.position)if(this.infoBarElement){const t=g(this.config,o);this.infoBarElement.replaceWith(t),this.infoBarElement=t}else this.infoBarElement=g(this.config,o),e.insertBefore(this.infoBarElement,e.firstChild);else"top"===this.config.position&&this.infoBarElement&&(this.infoBarElement.remove(),this.infoBarElement=null);u?(this.footerWrapper||(this.footerWrapper=document.createElement("div"),this.footerWrapper.className="tbw-footer",e.appendChild(this.footerWrapper)),this.footerWrapper.innerHTML="",a.length>0&&(this.bottomAggregationContainer||(this.bottomAggregationContainer=c("bottom")),this.footerWrapper.appendChild(this.bottomAggregationContainer),d(this.bottomAggregationContainer,a,this.visibleColumns,this.sourceRows,this.config.fullWidth)),h&&(this.infoBarElement=g(this.config,o),this.footerWrapper.appendChild(this.infoBarElement))):this.cleanupFooter()}cleanup(){this.infoBarElement&&(this.infoBarElement.remove(),this.infoBarElement=null),this.topAggregationContainer&&(this.topAggregationContainer.remove(),this.topAggregationContainer=null),this.bottomAggregationContainer&&(this.bottomAggregationContainer.remove(),this.bottomAggregationContainer=null),this.footerWrapper&&(this.footerWrapper.remove(),this.footerWrapper=null)}cleanupFooter(){this.footerWrapper&&(this.footerWrapper.remove(),this.footerWrapper=null),this.bottomAggregationContainer&&(this.bottomAggregationContainer.remove(),this.bottomAggregationContainer=null),this.infoBarElement&&"top"!==this.config.position&&(this.infoBarElement.remove(),this.infoBarElement=null)}getSelectionState(){try{return this.grid?.getPluginState?.("selection")??null}catch{return null}}getFilterState(){try{return this.grid?.getPluginState?.("filtering")??null}catch{return null}}refresh(){this.requestRender()}getContext(){const t=this.getSelectionState(),e=this.getFilterState();return m(this.rows,this.columns,this.gridElement,t,e)}addPanel(t){this.config.customPanels||(this.config.customPanels=[]),this.config.customPanels.push(t),this.requestRender()}removePanel(t){this.config.customPanels&&(this.config.customPanels=this.config.customPanels.filter(e=>e.id!==t),this.requestRender())}addAggregationRow(t){this.config.aggregationRows||(this.config.aggregationRows=[]),this.config.aggregationRows.push(t),this.requestRender()}removeAggregationRow(t){this.config.aggregationRows&&(this.config.aggregationRows=this.config.aggregationRows.filter(e=>e.id!==t),this.requestRender())}}export{b as PinnedRowsPlugin};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|