@toolbox-web/grid 1.23.4 → 1.24.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/README.md +35 -6
- package/all.d.ts +2 -2
- package/all.d.ts.map +1 -1
- 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 +21 -0
- package/lib/core/grid.d.ts.map +1 -1
- package/lib/core/internal/feature-hook.d.ts +8 -0
- package/lib/core/internal/feature-hook.d.ts.map +1 -0
- package/lib/core/plugin/base-plugin.d.ts +8 -2
- package/lib/core/plugin/base-plugin.d.ts.map +1 -1
- package/lib/core/plugin/types.d.ts +1 -1
- package/lib/core/types.d.ts +59 -0
- package/lib/core/types.d.ts.map +1 -1
- package/lib/features/clipboard.d.ts +8 -0
- package/lib/features/clipboard.d.ts.map +1 -0
- package/lib/features/clipboard.js +2 -0
- package/lib/features/clipboard.js.map +1 -0
- package/lib/features/column-virtualization.d.ts +8 -0
- package/lib/features/column-virtualization.d.ts.map +1 -0
- package/lib/features/column-virtualization.js +2 -0
- package/lib/features/column-virtualization.js.map +1 -0
- package/lib/features/context-menu.d.ts +8 -0
- package/lib/features/context-menu.d.ts.map +1 -0
- package/lib/features/context-menu.js +2 -0
- package/lib/features/context-menu.js.map +1 -0
- package/lib/features/editing.d.ts +8 -0
- package/lib/features/editing.d.ts.map +1 -0
- package/lib/features/editing.js +2 -0
- package/lib/features/editing.js.map +1 -0
- package/lib/features/export.d.ts +8 -0
- package/lib/features/export.d.ts.map +1 -0
- package/lib/features/export.js +2 -0
- package/lib/features/export.js.map +1 -0
- package/lib/features/filtering.d.ts +8 -0
- package/lib/features/filtering.d.ts.map +1 -0
- package/lib/features/filtering.js +2 -0
- package/lib/features/filtering.js.map +1 -0
- package/lib/features/grouping-columns.d.ts +8 -0
- package/lib/features/grouping-columns.d.ts.map +1 -0
- package/lib/features/grouping-columns.js +2 -0
- package/lib/features/grouping-columns.js.map +1 -0
- package/lib/features/grouping-rows.d.ts +8 -0
- package/lib/features/grouping-rows.d.ts.map +1 -0
- package/lib/features/grouping-rows.js +2 -0
- package/lib/features/grouping-rows.js.map +1 -0
- package/lib/features/magic-string.es-CkyDP9Ir.mjs.map +1 -0
- package/lib/features/master-detail.d.ts +8 -0
- package/lib/features/master-detail.d.ts.map +1 -0
- package/lib/features/master-detail.js +2 -0
- package/lib/features/master-detail.js.map +1 -0
- package/lib/features/multi-sort.d.ts +10 -0
- package/lib/features/multi-sort.d.ts.map +1 -0
- package/lib/features/multi-sort.js +2 -0
- package/lib/features/multi-sort.js.map +1 -0
- package/lib/features/pinned-columns.d.ts +18 -0
- package/lib/features/pinned-columns.d.ts.map +1 -0
- package/lib/features/pinned-columns.js +2 -0
- package/lib/features/pinned-columns.js.map +1 -0
- package/lib/features/pinned-rows.d.ts +8 -0
- package/lib/features/pinned-rows.d.ts.map +1 -0
- package/lib/features/pinned-rows.js +2 -0
- package/lib/features/pinned-rows.js.map +1 -0
- package/lib/features/pivot.d.ts +8 -0
- package/lib/features/pivot.d.ts.map +1 -0
- package/lib/features/pivot.js +2 -0
- package/lib/features/pivot.js.map +1 -0
- package/lib/features/print.d.ts +8 -0
- package/lib/features/print.d.ts.map +1 -0
- package/lib/features/print.js +2 -0
- package/lib/features/print.js.map +1 -0
- package/lib/features/registry.d.ts +50 -0
- package/lib/features/registry.d.ts.map +1 -0
- package/lib/features/registry.js +2 -0
- package/lib/features/registry.js.map +1 -0
- package/lib/features/registry.spec.js +5 -0
- package/lib/features/registry.spec.js.map +1 -0
- package/lib/features/reorder-columns.d.ts +10 -0
- package/lib/features/reorder-columns.d.ts.map +1 -0
- package/lib/features/reorder-columns.js +2 -0
- package/lib/features/reorder-columns.js.map +1 -0
- package/lib/features/reorder-rows.d.ts +10 -0
- package/lib/features/reorder-rows.d.ts.map +1 -0
- package/lib/features/reorder-rows.js +2 -0
- package/lib/features/reorder-rows.js.map +1 -0
- package/lib/features/responsive.d.ts +8 -0
- package/lib/features/responsive.d.ts.map +1 -0
- package/lib/features/responsive.js +2 -0
- package/lib/features/responsive.js.map +1 -0
- package/lib/features/selection.d.ts +8 -0
- package/lib/features/selection.d.ts.map +1 -0
- package/lib/features/selection.js +2 -0
- package/lib/features/selection.js.map +1 -0
- package/lib/features/server-side.d.ts +8 -0
- package/lib/features/server-side.d.ts.map +1 -0
- package/lib/features/server-side.js +2 -0
- package/lib/features/server-side.js.map +1 -0
- package/lib/features/tree.d.ts +8 -0
- package/lib/features/tree.d.ts.map +1 -0
- package/lib/features/tree.js +2 -0
- package/lib/features/tree.js.map +1 -0
- package/lib/features/undo-redo.d.ts +8 -0
- package/lib/features/undo-redo.d.ts.map +1 -0
- package/lib/features/undo-redo.js +2 -0
- package/lib/features/undo-redo.js.map +1 -0
- package/lib/features/visibility.d.ts +8 -0
- package/lib/features/visibility.d.ts.map +1 -0
- package/lib/features/visibility.js +2 -0
- package/lib/features/visibility.js.map +1 -0
- 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/export/index.js +1 -1
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/filtering/index.js +1 -1
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/filtering/types.d.ts +428 -27
- package/lib/plugins/filtering/types.d.ts.map +1 -1
- package/lib/plugins/grouping-columns/index.d.ts +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/index.d.ts +2 -2
- package/lib/plugins/grouping-rows/index.d.ts.map +1 -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 -2
- package/lib/plugins/master-detail/index.js +1 -1
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/multi-sort/index.js +1 -1
- package/lib/plugins/multi-sort/index.js.map +1 -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/types.d.ts +3 -3
- 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/index.js +1 -1
- package/lib/plugins/print/index.js.map +1 -1
- package/lib/plugins/{reorder → reorder-columns}/ReorderPlugin.d.ts +5 -3
- package/lib/plugins/reorder-columns/ReorderPlugin.d.ts.map +1 -0
- package/lib/plugins/reorder-columns/column-drag.d.ts.map +1 -0
- package/lib/plugins/{reorder → reorder-columns}/index.d.ts +2 -2
- package/lib/plugins/reorder-columns/index.d.ts.map +1 -0
- package/lib/plugins/reorder-columns/index.js +2 -0
- package/lib/plugins/reorder-columns/index.js.map +1 -0
- package/lib/plugins/{reorder → reorder-columns}/types.d.ts +5 -0
- package/lib/plugins/reorder-columns/types.d.ts.map +1 -0
- package/lib/plugins/{row-reorder → reorder-rows}/RowReorderPlugin.d.ts +5 -3
- package/lib/plugins/reorder-rows/RowReorderPlugin.d.ts.map +1 -0
- package/lib/plugins/{row-reorder → reorder-rows}/index.d.ts +2 -2
- package/lib/plugins/reorder-rows/index.d.ts.map +1 -0
- package/lib/plugins/reorder-rows/index.js +2 -0
- package/lib/plugins/reorder-rows/index.js.map +1 -0
- package/lib/plugins/{row-reorder → reorder-rows}/types.d.ts +5 -0
- package/lib/plugins/reorder-rows/types.d.ts.map +1 -0
- package/lib/plugins/responsive/ResponsivePlugin.d.ts +2 -2
- package/lib/plugins/responsive/index.js +1 -1
- package/lib/plugins/responsive/index.js.map +1 -1
- 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/index.js +1 -1
- package/lib/plugins/tree/index.js.map +1 -1
- 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 +1 -1
- package/lib/plugins/visibility/index.js +1 -1
- package/lib/plugins/visibility/index.js.map +1 -1
- package/package.json +17 -2
- package/public.d.ts +9 -2
- package/public.d.ts.map +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/master-detail.umd.js.map +1 -1
- package/umd/plugins/reorder-columns.umd.js +2 -0
- package/umd/plugins/reorder-columns.umd.js.map +1 -0
- package/umd/plugins/reorder-rows.umd.js +2 -0
- package/umd/plugins/reorder-rows.umd.js.map +1 -0
- package/umd/plugins/responsive.umd.js.map +1 -1
- package/umd/plugins/visibility.umd.js.map +1 -1
- package/lib/plugins/reorder/ReorderPlugin.d.ts.map +0 -1
- package/lib/plugins/reorder/column-drag.d.ts.map +0 -1
- package/lib/plugins/reorder/index.d.ts.map +0 -1
- package/lib/plugins/reorder/index.js +0 -2
- package/lib/plugins/reorder/index.js.map +0 -1
- package/lib/plugins/reorder/types.d.ts.map +0 -1
- package/lib/plugins/row-reorder/RowReorderPlugin.d.ts.map +0 -1
- package/lib/plugins/row-reorder/index.d.ts.map +0 -1
- package/lib/plugins/row-reorder/index.js +0 -2
- package/lib/plugins/row-reorder/index.js.map +0 -1
- package/lib/plugins/row-reorder/types.d.ts.map +0 -1
- package/umd/plugins/reorder.umd.js +0 -2
- package/umd/plugins/reorder.umd.js.map +0 -1
- package/umd/plugins/row-reorder.umd.js +0 -2
- package/umd/plugins/row-reorder.umd.js.map +0 -1
- /package/lib/plugins/{reorder → reorder-columns}/column-drag.d.ts +0 -0
|
@@ -10,7 +10,7 @@ import { ReorderConfig } from './types';
|
|
|
10
10
|
* ## Installation
|
|
11
11
|
*
|
|
12
12
|
* ```ts
|
|
13
|
-
* import { ReorderPlugin } from '@toolbox-web/grid/plugins/reorder';
|
|
13
|
+
* import { ReorderPlugin } from '@toolbox-web/grid/plugins/reorder-columns';
|
|
14
14
|
* ```
|
|
15
15
|
*
|
|
16
16
|
* ## Configuration Options
|
|
@@ -36,7 +36,7 @@ import { ReorderConfig } from './types';
|
|
|
36
36
|
* @example Basic Drag-and-Drop Reordering
|
|
37
37
|
* ```ts
|
|
38
38
|
* import '@toolbox-web/grid';
|
|
39
|
-
* import { ReorderPlugin } from '@toolbox-web/grid/plugins/reorder';
|
|
39
|
+
* import { ReorderPlugin } from '@toolbox-web/grid/plugins/reorder-columns';
|
|
40
40
|
*
|
|
41
41
|
* const grid = document.querySelector('tbw-grid');
|
|
42
42
|
* grid.gridConfig = {
|
|
@@ -71,7 +71,9 @@ import { ReorderConfig } from './types';
|
|
|
71
71
|
*/
|
|
72
72
|
export declare class ReorderPlugin extends BaseGridPlugin<ReorderConfig> {
|
|
73
73
|
/** @internal */
|
|
74
|
-
readonly name = "
|
|
74
|
+
readonly name = "reorderColumns";
|
|
75
|
+
/** @internal */
|
|
76
|
+
readonly aliases: readonly ["reorder"];
|
|
75
77
|
/** @internal */
|
|
76
78
|
readonly styles: string;
|
|
77
79
|
/** @internal */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReorderPlugin.d.ts","sourceRoot":"","sources":["../../../../../../libs/grid/src/lib/plugins/reorder-columns/ReorderPlugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAI/D,OAAO,KAAK,EAAoB,aAAa,EAAE,MAAM,SAAS,CAAC;AAE/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AACH,qBAAa,aAAc,SAAQ,cAAc,CAAC,aAAa,CAAC;IAC9D,gBAAgB;IAChB,QAAQ,CAAC,IAAI,oBAAoB;IACjC,gBAAgB;IAChB,SAAkB,OAAO,uBAAwB;IACjD,gBAAgB;IAChB,SAAkB,MAAM,SAAU;IAElC,gBAAgB;IAChB,cAAuB,aAAa,IAAI,OAAO,CAAC,aAAa,CAAC,CAI7D;IAED;;;OAGG;IACH,OAAO,KAAK,aAAa,GAQxB;IAED;;;OAGG;IACH,cAAuB,iBAAiB,IAAI,MAAM,CAMjD;IAGD,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,YAAY,CAAuB;IAC3C,OAAO,CAAC,YAAY,CAAuB;IAC3C,OAAO,CAAC,SAAS,CAAuB;IAExC;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAOhC;;OAEG;IACH,OAAO,CAAC,gBAAgB;IASxB,gBAAgB;IACP,MAAM,CAAC,IAAI,EAAE,OAAO,+BAA+B,EAAE,WAAW,GAAG,IAAI;IAiBhF,gBAAgB;IACP,MAAM,IAAI,IAAI;IAUvB,gBAAgB;IACP,WAAW,IAAI,IAAI;IAiG5B;;;OAGG;IACM,SAAS,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,GAAG,IAAI;IAyCxD;;;OAGG;IACH,cAAc,IAAI,MAAM,EAAE;IAI1B;;;;OAIG;IACH,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;IAoBhD;;;OAGG;IACH,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI;IAIrC;;OAEG;IACH,gBAAgB,IAAI,IAAI;IAQxB;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAS9B;;;;OAIG;IACH,OAAO,CAAC,WAAW;IAmDnB;;;OAGG;IACH,OAAO,CAAC,WAAW;IAgDnB;;OAEG;IACH,OAAO,CAAC,iBAAiB;CAqB1B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"column-drag.d.ts","sourceRoot":"","sources":["../../../../../../libs/grid/src/lib/plugins/reorder-columns/column-drag.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAErD;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAC,IAAI,GAAG,OAAO,EAAE,MAAM,EAAE,YAAY,CAAC,IAAI,CAAC,GAAG,OAAO,CAIjF;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAS1F;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,GAAG,MAAM,CAU/F;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,IAAI,GAAG,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC,IAAI,CAAC,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,YAAY,CAAC,IAAI,CAAC,EAAE,CAmBnH"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Reorder Plugin Entry Point
|
|
2
|
+
* Reorder Columns Plugin Entry Point
|
|
3
3
|
* Re-exports plugin class and types for tree-shakeable imports.
|
|
4
4
|
*
|
|
5
|
-
* @module Plugins/Reorder
|
|
5
|
+
* @module Plugins/Reorder Columns
|
|
6
6
|
*/
|
|
7
7
|
export { ReorderPlugin } from './ReorderPlugin';
|
|
8
8
|
export type { ColumnMoveDetail, ReorderAnimation, ReorderConfig } from './types';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../libs/grid/src/lib/plugins/reorder-columns/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
document.createElement("template").innerHTML='<div class="cell" role="gridcell" part="cell"></div>';document.createElement("template").innerHTML='<div class="data-grid-row" role="row" part="row"></div>';const e='<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>',t={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:e,filterActive:e,print:"🖨️"};class r{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?.()}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}get disconnectSignal(){return this.#e?.signal??this.grid?.disconnectSignal}get gridIcons(){const e=this.grid?.gridConfig?.icons??{};return{...t,...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(e){console.warn(`[tbw-grid:${this.name}] ${e}`)}}function i(e,t,r){if(t===r)return e;if(t<0||t>=e.length)return e;if(r<0||r>e.length)return e;const i=[...e],[n]=i.splice(t,1);return i.splice(r,0,n),i}class n extends r{name="reorderColumns";aliases=["reorder"];styles='@layer tbw-plugins{.header-row>.cell[draggable=true]{cursor:grab;position:relative}.header-row>.cell.dragging{opacity:.5;cursor:grabbing}.header-row>.cell.drop-before:before{content:"";position:absolute;left:0;top:0;bottom:0;width:2px;background:var(--tbw-reorder-indicator, var(--tbw-color-accent));z-index:1}.header-row>.cell.drop-after:after{content:"";position:absolute;right:0;top:0;bottom:0;width:2px;background:var(--tbw-reorder-indicator, var(--tbw-color-accent));z-index:1}.cell.flip-animating{transition:transform var(--tbw-animation-duration, .2s) ease-out;will-change:transform;z-index:1}@keyframes reorder-fade-in{0%{opacity:0}to{opacity:1}}.cell.fade-animating{animation:reorder-fade-in var(--tbw-animation-duration, .2s) ease-out backwards}}';get defaultConfig(){return{animation:"flip"}}get animationType(){return!!this.isAnimationEnabled&&(void 0!==this.config.animation?this.config.animation:"flip")}get animationDuration(){return void 0!==this.config.animationDuration?this.config.animationDuration:super.animationDuration}isDragging=!1;draggedField=null;draggedIndex=null;dropIndex=null;canMoveColumnWithPlugins(e){if(!e||!function(e){const t=e.meta??{};return!0!==t.lockPosition&&!0!==t.suppressMovable}(e))return!1;return!this.grid.query("canMoveColumn",e).includes(!1)}clearDragClasses(){this.gridElement?.querySelectorAll(".header-row > .cell").forEach(e=>{e.classList.remove("dragging","drop-target","drop-before","drop-after")})}attach(e){super.attach(e),e.addEventListener("column-reorder-request",e=>{const t=e.detail;t?.field&&"number"==typeof t.toIndex&&this.moveColumn(t.field,t.toIndex)},{signal:this.disconnectSignal})}detach(){this.isDragging=!1,this.draggedField=null,this.draggedIndex=null,this.dropIndex=null}afterRender(){const e=this.gridElement;if(!e)return;e.querySelectorAll(".header-row > .cell").forEach(e=>{const t=e,r=t.getAttribute("data-field");if(!r)return;const n=this.columns.find(e=>e.field===r);this.canMoveColumnWithPlugins(n)?(t.draggable=!0,t.getAttribute("data-dragstart-bound")||(t.setAttribute("data-dragstart-bound","true"),t.addEventListener("dragstart",e=>{const i=this.getColumnOrder().indexOf(r);this.isDragging=!0,this.draggedField=r,this.draggedIndex=i,e.dataTransfer&&(e.dataTransfer.effectAllowed="move",e.dataTransfer.setData("text/plain",r)),t.classList.add("dragging")}),t.addEventListener("dragend",()=>{this.isDragging=!1,this.draggedField=null,this.draggedIndex=null,this.dropIndex=null,this.clearDragClasses()}),t.addEventListener("dragover",e=>{if(e.preventDefault(),!this.isDragging||this.draggedField===r)return;const i=t.getBoundingClientRect(),n=i.left+i.width/2,o=this.getColumnOrder().indexOf(r);this.dropIndex=e.clientX<n?o:o+1,t.classList.add("drop-target"),t.classList.toggle("drop-before",e.clientX<n),t.classList.toggle("drop-after",e.clientX>=n)}),t.addEventListener("dragleave",()=>{t.classList.remove("drop-target","drop-before","drop-after")}),t.addEventListener("drop",e=>{e.preventDefault();const t=this.draggedField,r=this.draggedIndex,n=this.dropIndex;if(!this.isDragging||null===t||null===r||null===n)return;const o=n>r?n-1:n,s=i(this.getColumnOrder(),r,o),a={field:t,fromIndex:r,toIndex:o,columnOrder:s};this.emitCancelable("column-move",a)||this.updateColumnOrder(s)}))):t.draggable=!1})}onKeyDown(e){if(!e.altKey||"ArrowLeft"!==e.key&&"ArrowRight"!==e.key)return;const t=this.grid,r=t._focusCol,i=t._visibleColumns;if(r<0||r>=i.length)return;const n=i[r];if(!this.canMoveColumnWithPlugins(n))return;const o=this.getColumnOrder(),s=o.indexOf(n.field);if(-1===s)return;const a="ArrowLeft"===e.key?s-1:s+1;if(a<0||a>=o.length)return;const l=i.find(e=>e.field===o[a]);return this.canMoveColumnWithPlugins(l)?(this.moveColumn(n.field,a),t._focusCol=a,function(e,t){if(e._virtualization?.enabled){const{rowHeight:t,container:r,viewportEl:i}=e._virtualization,n=r,o=i?.clientHeight??n?.clientHeight??0;if(n&&o>0){const r=e._focusRow*t;r<n.scrollTop?n.scrollTop=r:r+t>n.scrollTop+o&&(n.scrollTop=r-o+t)}}const r=void 0!==e._activeEditRows&&-1!==e._activeEditRows||!!e._isGridEditMode;var i;r||e.refreshVirtualWindow(!1),(i=e._bodyEl)&&i.querySelectorAll(".cell-focus").forEach(e=>e.classList.remove("cell-focus")),Array.from(e._bodyEl.querySelectorAll('[aria-selected="true"]')).forEach(e=>{e.setAttribute("aria-selected","false")});const n=e._focusRow,o=e._virtualization.start??0,s=e._virtualization.end??e._rows.length;if(n>=o&&n<s){const i=e._bodyEl.querySelectorAll(".data-grid-row")[n-o];let s=i?.children[e._focusCol];if(s&&s.classList?.contains("cell")||(s=i?.querySelector(`.cell[data-col="${e._focusCol}"]`)??i?.querySelector(".cell[data-col]")),s){s.classList.add("cell-focus"),s.setAttribute("aria-selected","true");const n=e.querySelector(".tbw-scroll-area");if(n&&s&&(!r||t?.forceHorizontalScroll)){const t=e._getHorizontalScrollOffsets?.(i??void 0,s)??{left:0,right:0};if(!t.skipScroll){const e=s.getBoundingClientRect(),r=n.getBoundingClientRect(),i=e.left-r.left+n.scrollLeft,o=i+e.width,a=n.scrollLeft+t.left,l=n.scrollLeft+n.clientWidth-t.right;i<a?n.scrollLeft=i-t.left:o>l&&(n.scrollLeft=o-n.clientWidth+t.right)}}if(r&&s.classList.contains("editing")){const e=s.querySelector('input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])');if(e&&document.activeElement!==e)try{e.focus({preventScroll:!0})}catch{}}else if(r&&!s.contains(document.activeElement)){s.hasAttribute("tabindex")||s.setAttribute("tabindex","-1");try{s.focus({preventScroll:!0})}catch{}}else if(!r){const t=e;document.activeElement!==t&&t.focus({preventScroll:!0})}}}}(this.grid),e.preventDefault(),e.stopPropagation(),!0):void 0}getColumnOrder(){return this.grid.getColumnOrder()}moveColumn(e,t){const r=this.getColumnOrder(),n=r.indexOf(e);if(-1===n)return;const o=i(r,n,t);this.emitCancelable("column-move",{field:e,fromIndex:n,toIndex:t,columnOrder:o})||this.updateColumnOrder(o)}setColumnOrder(e){this.updateColumnOrder(e)}resetColumnOrder(){const e=this.columns.map(e=>e.field);this.updateColumnOrder(e)}captureHeaderPositions(){const e=/* @__PURE__ */new Map;return this.gridElement?.querySelectorAll(".header-row > .cell[data-field]").forEach(t=>{const r=t.getAttribute("data-field");r&&e.set(r,t.getBoundingClientRect().left)}),e}animateFLIP(e){const t=this.gridElement;if(!t||0===e.size)return;const r=/* @__PURE__ */new Map;if(t.querySelectorAll(".header-row > .cell[data-field]").forEach(t=>{const i=t.getAttribute("data-field");if(!i)return;const n=e.get(i);if(void 0===n)return;const o=n-t.getBoundingClientRect().left;Math.abs(o)>1&&r.set(i,o)}),0===r.size)return;const i=[];if(t.querySelectorAll(".cell[data-field]").forEach(e=>{const t=r.get(e.getAttribute("data-field")??"");if(void 0!==t){const r=e;r.style.transform=`translateX(${t}px)`,i.push(r)}}),0===i.length)return;this.gridElement.offsetHeight;const n=this.animationDuration;requestAnimationFrame(()=>{i.forEach(e=>{e.classList.add("flip-animating"),e.style.transform=""}),setTimeout(()=>{i.forEach(e=>{e.style.transform="",e.classList.remove("flip-animating")})},n+50)})}animateFade(e){const t=this.gridElement;if(!t)return void e();const r=this.captureHeaderPositions();e();const i=/* @__PURE__ */new Set;if(t.querySelectorAll(".header-row > .cell[data-field]").forEach(e=>{const t=e.getAttribute("data-field");if(!t)return;const n=r.get(t);if(void 0===n)return;const o=e.getBoundingClientRect().left;Math.abs(n-o)>1&&i.add(t)}),0===i.size)return;const n=[];if(t.querySelectorAll(".cell[data-field]").forEach(e=>{const t=e.getAttribute("data-field");if(t&&i.has(t)){const t=e;t.classList.add("fade-animating"),n.push(t)}}),0===n.length)return;const o=this.animationDuration;setTimeout(()=>{n.forEach(e=>e.classList.remove("fade-animating"))},o+50)}updateColumnOrder(e){const t=this.animationType;if("flip"===t&&this.gridElement){const t=this.captureHeaderPositions();this.grid.setColumnOrder(e),requestAnimationFrame(()=>{this.gridElement.offsetHeight,this.animateFLIP(t)})}else"fade"===t?this.animateFade(()=>this.grid.setColumnOrder(e)):this.grid.setColumnOrder(e);this.grid.requestStateChange?.()}}export{n as ReorderPlugin};
|
|
2
|
+
//# sourceMappingURL=index.js.map
|