lexgui 0.7.11 → 0.7.12

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.
@@ -7,7 +7,7 @@
7
7
  */
8
8
 
9
9
  const LX = {
10
- version: "0.7.11",
10
+ version: "0.7.12",
11
11
  ready: false,
12
12
  extensions: [], // Store extensions used
13
13
  signals: {}, // Events and triggers
@@ -12698,6 +12698,7 @@ class Table extends BaseComponent
12698
12698
  this.filter = options.filter ?? false;
12699
12699
  this.customFilters = options.customFilters ?? false;
12700
12700
  this._toggleColumns = options.toggleColumns ?? false;
12701
+ this._sortColumns = options.sortColumns ?? true;
12701
12702
  this._currentFilter = options.filterValue;
12702
12703
 
12703
12704
  data.head = data.head ?? [];
@@ -12964,28 +12965,62 @@ class Table extends BaseComponent
12964
12965
  th.classList.add( "centered" );
12965
12966
  }
12966
12967
 
12967
- const menuOptions = [
12968
- { name: "Asc", icon: "ArrowUpAZ", callback: sortFn.bind( this, idx, 1 ) },
12969
- { name: "Desc", icon: "ArrowDownAZ", callback: sortFn.bind( this, idx, -1 ) }
12970
- ];
12968
+ const menuOptions = [];
12971
12969
 
12972
- if( this._toggleColumns )
12970
+ if( options.columnActions )
12973
12971
  {
12974
- menuOptions.push(
12975
- null,
12972
+ for( let action of options.columnActions )
12973
+ {
12974
+ if( !action.name )
12976
12975
  {
12977
- name: "Hide", icon: "EyeOff", callback: () => {
12978
- data.colVisibilityMap[ idx ] = false;
12979
- const cells = table.querySelectorAll(`tr > *:nth-child(${idx + this.rowOffsetCount + 1})`);
12980
- cells.forEach( cell => {
12981
- cell.style.display = ( cell.style.display === "none" ) ? "" : "none";
12982
- } );
12983
- }
12976
+ console.warn( "Invalid column action (missing name):", action );
12977
+ continue;
12984
12978
  }
12979
+
12980
+ menuOptions.push( { name: action.name, icon: action.icon, className: action.className, callback: () => {
12981
+ const colRows = this.data.body.map( row => [ row[ idx ] ] );
12982
+ const mustRefresh = action.callback( colRows, table );
12983
+ if( mustRefresh )
12984
+ {
12985
+ this.refresh();
12986
+ }
12987
+ } } );
12988
+ }
12989
+ }
12990
+
12991
+ if( this._sortColumns )
12992
+ {
12993
+ if( menuOptions.length > 0 )
12994
+ {
12995
+ menuOptions.push( null );
12996
+ }
12997
+
12998
+ menuOptions.push(
12999
+ { name: "Asc", icon: "ArrowUpAZ", callback: sortFn.bind( this, idx, 1 ) },
13000
+ { name: "Desc", icon: "ArrowDownAZ", callback: sortFn.bind( this, idx, -1 ) }
12985
13001
  );
12986
13002
  }
12987
13003
 
13004
+ if( this._toggleColumns )
13005
+ {
13006
+ if( menuOptions.length > 0 )
13007
+ {
13008
+ menuOptions.push( null );
13009
+ }
13010
+
13011
+ menuOptions.push( {
13012
+ name: "Hide", icon: "EyeOff", callback: () => {
13013
+ data.colVisibilityMap[ idx ] = false;
13014
+ const cells = table.querySelectorAll(`tr > *:nth-child(${idx + this.rowOffsetCount + 1})`);
13015
+ cells.forEach( cell => {
13016
+ cell.style.display = ( cell.style.display === "none" ) ? "" : "none";
13017
+ } );
13018
+ }
13019
+ } );
13020
+ }
13021
+
12988
13022
  th.addEventListener( 'click', event => {
13023
+ if( menuOptions.length === 0 ) return;
12989
13024
  new LX.DropdownMenu( event.target, menuOptions, { side: "bottom", align: "start" });
12990
13025
  });
12991
13026