lexgui 0.6.8 → 0.6.9

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.
@@ -1,4 +1,4 @@
1
- // This is a generated file. Do not edit.
1
+ // This is a generated file. Do not edit.
2
2
  // Lexgui.js @jxarco
3
3
 
4
4
  /**
@@ -7,7 +7,7 @@
7
7
  */
8
8
 
9
9
  const LX = {
10
- version: "0.6.8",
10
+ version: "0.6.9",
11
11
  ready: false,
12
12
  components: [], // Specific pre-build components
13
13
  signals: {}, // Events and triggers
@@ -4113,8 +4113,8 @@ Element.prototype.ignore = function( eventName, callbackName ) {
4113
4113
  callbackName = callbackName ?? ( "_on" + eventName );
4114
4114
  const callback = this[ callbackName ];
4115
4115
  this.removeEventListener( eventName, callback );
4116
- };
4117
-
4116
+ };
4117
+
4118
4118
  // icons.js @jxarco
4119
4119
 
4120
4120
  const RAW_ICONS = {
@@ -4292,8 +4292,8 @@ LX.LucideIconAlias = {
4292
4292
  "RotateRight": "RotateCw",
4293
4293
  "RotateBack": "RotateCcw",
4294
4294
  "RotateLeft": "RotateCcw",
4295
- };
4296
-
4295
+ };
4296
+
4297
4297
  // utils.js @jxarco
4298
4298
 
4299
4299
  function clamp( num, min, max ) { return Math.min( Math.max( num, min ), max ); }
@@ -5070,7 +5070,7 @@ LX.makeCodeSnippet = makeCodeSnippet;
5070
5070
  * @param {Array} keys
5071
5071
  * @param {String} extraClass
5072
5072
  */
5073
- function makeKbd( keys, extraClass = "" )
5073
+ function makeKbd( keys, useSpecialKeys = true, extraClass = "" )
5074
5074
  {
5075
5075
  const specialKeys = {
5076
5076
  "Ctrl": '⌃',
@@ -5092,7 +5092,7 @@ function makeKbd( keys, extraClass = "" )
5092
5092
 
5093
5093
  for( const k of keys )
5094
5094
  {
5095
- LX.makeContainer( ["auto", "auto"], "self-center text-xs fg-secondary select-none", specialKeys[ k ] ?? k, kbd );
5095
+ LX.makeContainer( ["auto", "auto"], "self-center text-xs fg-secondary select-none " + extraClass, useSpecialKeys ? specialKeys[ k ] ?? k : k, kbd );
5096
5096
  }
5097
5097
 
5098
5098
  return kbd;
@@ -6009,8 +6009,8 @@ function drawSpline( ctx, pts, t )
6009
6009
  ctx.restore();
6010
6010
  }
6011
6011
 
6012
- LX.drawSpline = drawSpline;
6013
-
6012
+ LX.drawSpline = drawSpline;
6013
+
6014
6014
  // area.js @jxarco
6015
6015
 
6016
6016
  class Area {
@@ -6798,6 +6798,7 @@ class Area {
6798
6798
  this.attach( container );
6799
6799
 
6800
6800
  const float = options.float;
6801
+ let floatClass = "";
6801
6802
 
6802
6803
  if( float )
6803
6804
  {
@@ -6807,15 +6808,17 @@ class Area {
6807
6808
  switch( t )
6808
6809
  {
6809
6810
  case 'h': break;
6810
- case 'v': container.className += " vertical"; break;
6811
+ case 'v': floatClass += " vertical"; break;
6811
6812
  case 't': break;
6812
- case 'm': container.className += " middle"; break;
6813
- case 'b': container.className += " bottom"; break;
6813
+ case 'm': floatClass += " middle"; break;
6814
+ case 'b': floatClass += " bottom"; break;
6814
6815
  case 'l': break;
6815
- case 'c': container.className += " center"; break;
6816
- case 'r': container.className += " right"; break;
6816
+ case 'c': floatClass += " center"; break;
6817
+ case 'r': floatClass += " right"; break;
6817
6818
  }
6818
6819
  }
6820
+
6821
+ container.className += ` ${ floatClass }`;
6819
6822
  }
6820
6823
 
6821
6824
  const _addButton = function( b, group, last ) {
@@ -6890,6 +6893,15 @@ class Area {
6890
6893
 
6891
6894
  for( let b of buttons )
6892
6895
  {
6896
+ if( b === null )
6897
+ {
6898
+ // Add a separator
6899
+ const separator = document.createElement("div");
6900
+ separator.className = "lexoverlayseparator" + floatClass;
6901
+ overlayPanel.root.appendChild( separator );
6902
+ continue;
6903
+ }
6904
+
6893
6905
  if( b.constructor === Array )
6894
6906
  {
6895
6907
  for( let i = 0; i < b.length; ++i )
@@ -7065,8 +7077,8 @@ class Area {
7065
7077
  }
7066
7078
  }
7067
7079
  }
7068
- LX.Area = Area;
7069
-
7080
+ LX.Area = Area;
7081
+
7070
7082
  // widget.js @jxarco
7071
7083
 
7072
7084
  /**
@@ -7421,8 +7433,7 @@ function ADD_CUSTOM_WIDGET( customWidgetName, options = {} )
7421
7433
  if( customWidgetsDom ) customWidgetsDom.remove();
7422
7434
 
7423
7435
  container = document.createElement('div');
7424
- container.className = "lexcustomcontainer";
7425
- container.style.width = "100%";
7436
+ container.className = "lexcustomcontainer w-full";
7426
7437
  element.appendChild( container );
7427
7438
  element.dataset["opened"] = false;
7428
7439
 
@@ -7616,9 +7627,9 @@ class NodeTree {
7616
7627
 
7617
7628
  if( this.options.onlyFolders )
7618
7629
  {
7619
- let has_folders = false;
7620
- node.children.forEach( c => has_folders |= (c.type == 'folder') );
7621
- isParent = !!has_folders;
7630
+ let hasFolders = false;
7631
+ node.children.forEach( c => hasFolders |= (c.type == 'folder') );
7632
+ isParent = !!hasFolders;
7622
7633
  }
7623
7634
 
7624
7635
  let item = document.createElement('li');
@@ -7783,23 +7794,15 @@ class NodeTree {
7783
7794
  } );
7784
7795
 
7785
7796
  event.panel.add( "Delete", { callback: () => {
7786
- // It's the root node
7787
- if( !node.parent )
7788
- {
7789
- return;
7790
- }
7791
7797
 
7792
- if( that.onevent )
7798
+ const ok = that.deleteNode( node );
7799
+
7800
+ if( ok && that.onevent )
7793
7801
  {
7794
7802
  const event = new LX.TreeEvent( LX.TreeEvent.NODE_DELETED, node, e );
7795
7803
  that.onevent( event );
7796
7804
  }
7797
7805
 
7798
- // Delete nodes now
7799
- let childs = node.parent.children;
7800
- const index = childs.indexOf( node );
7801
- childs.splice( index, 1 );
7802
-
7803
7806
  this.refresh();
7804
7807
  } } );
7805
7808
  }
@@ -7816,23 +7819,26 @@ class NodeTree {
7816
7819
 
7817
7820
  if( e.key == "Delete" )
7818
7821
  {
7819
- // Send event now so we have the info in selected array..
7820
- if( that.onevent )
7822
+ const nodesDeleted = [];
7823
+
7824
+ for( let _node of this.selected )
7821
7825
  {
7822
- const event = new LX.TreeEvent( LX.TreeEvent.NODE_DELETED, this.selected.length > 1 ? this.selected : node, e );
7823
- event.multiple = this.selected.length > 1;
7824
- that.onevent( event );
7826
+ if( that.deleteNode( _node ) )
7827
+ {
7828
+ nodesDeleted.push( _node );
7829
+ }
7825
7830
  }
7826
7831
 
7827
- // Delete nodes now
7828
- for( let _node of this.selected )
7832
+ // Send event now so we have the info in selected array..
7833
+ if( nodesDeleted.length && that.onevent )
7829
7834
  {
7830
- let childs = _node.parent.children;
7831
- const index = childs.indexOf( _node );
7832
- childs.splice( index, 1 );
7835
+ const event = new LX.TreeEvent( LX.TreeEvent.NODE_DELETED, nodesDeleted.length > 1 ? nodesDeleted : node, e );
7836
+ event.multiple = nodesDeleted.length > 1;
7837
+ that.onevent( event );
7833
7838
  }
7834
7839
 
7835
7840
  this.selected.length = 0;
7841
+
7836
7842
  this.refresh();
7837
7843
  }
7838
7844
  else if( e.key == "ArrowUp" || e.key == "ArrowDown" ) // Unique or zero selected
@@ -8101,6 +8107,35 @@ class NodeTree {
8101
8107
  this.selected = [ el.treeData ];
8102
8108
  el.focus();
8103
8109
  }
8110
+
8111
+ deleteNode( node ) {
8112
+
8113
+ const dataAsArray = ( this.data.constructor === Array );
8114
+
8115
+ // Can be either Array or Object type data
8116
+ if( node.parent )
8117
+ {
8118
+ let childs = node.parent.children;
8119
+ const index = childs.indexOf( node );
8120
+ childs.splice( index, 1 );
8121
+ }
8122
+ else
8123
+ {
8124
+ if( dataAsArray )
8125
+ {
8126
+ const index = this.data.indexOf( node );
8127
+ console.assert( index > -1, "NodeTree: Can't delete root node " + node.id + " from data array!" );
8128
+ this.data.splice( index, 1 );
8129
+ }
8130
+ else
8131
+ {
8132
+ console.warn( "NodeTree: Can't delete root node from object data!" );
8133
+ return false;
8134
+ }
8135
+ }
8136
+
8137
+ return true;
8138
+ }
8104
8139
  }
8105
8140
 
8106
8141
  LX.NodeTree = NodeTree;
@@ -8468,18 +8503,38 @@ class Button extends Widget {
8468
8503
  wValue.classList.add( "selected" );
8469
8504
  }
8470
8505
 
8471
- if( options.icon )
8472
- {
8473
- const icon = LX.makeIcon( options.icon );
8474
- wValue.prepend( icon );
8475
- wValue.classList.add( "justify-center" );
8476
- }
8477
- else if( options.img )
8506
+ if( options.img )
8478
8507
  {
8479
8508
  let img = document.createElement( 'img' );
8480
8509
  img.src = options.img;
8481
8510
  wValue.prepend( img );
8482
8511
  }
8512
+ else if( options.icon )
8513
+ {
8514
+ const icon = LX.makeIcon( options.icon );
8515
+ const iconPosition = options.iconPosition ?? "cover";
8516
+
8517
+ // Default
8518
+ if( iconPosition == "cover" || ( options.swap !== undefined ) )
8519
+ {
8520
+ wValue.prepend( icon );
8521
+ }
8522
+ else
8523
+ {
8524
+ wValue.innerHTML = `<span>${ ( value || "" ) }</span>`;
8525
+
8526
+ if( iconPosition == "start" )
8527
+ {
8528
+ wValue.querySelector( "span" ).prepend( icon );
8529
+ }
8530
+ else // "end"
8531
+ {
8532
+ wValue.querySelector( "span" ).appendChild( icon );
8533
+ }
8534
+ }
8535
+
8536
+ wValue.classList.add( "justify-center" );
8537
+ }
8483
8538
  else
8484
8539
  {
8485
8540
  wValue.innerHTML = `<span>${ ( value || "" ) }</span>`;
@@ -8935,8 +8990,8 @@ class Select extends Widget {
8935
8990
  value = newValue;
8936
8991
 
8937
8992
  let item = null;
8938
- const options = listOptions.childNodes;
8939
- options.forEach( e => {
8993
+ const listOptionsNodes = listOptions.childNodes;
8994
+ listOptionsNodes.forEach( e => {
8940
8995
  e.classList.remove( "selected" );
8941
8996
  if( e.getAttribute( "value" ) == newValue )
8942
8997
  {
@@ -8956,6 +9011,22 @@ class Select extends Widget {
8956
9011
  list.refresh( filteredOptions );
8957
9012
  }
8958
9013
 
9014
+ // Update suboptions menu
9015
+ const suboptions = this.root.querySelector( ".lexcustomcontainer" );
9016
+ const suboptionsFunc = options[ `on_${ value }` ];
9017
+ suboptions.toggleAttribute( "hidden", !suboptionsFunc );
9018
+
9019
+ if( suboptionsFunc )
9020
+ {
9021
+ suboptions.innerHTML = "";
9022
+ const suboptionsPanel = new LX.Panel();
9023
+ suboptionsPanel.queue( suboptions );
9024
+ suboptionsFunc.call(this, suboptionsPanel);
9025
+ suboptionsPanel.clearQueue();
9026
+ }
9027
+
9028
+ this.root.dataset["opened"] = ( !!suboptionsFunc );
9029
+
8959
9030
  if( !skipCallback )
8960
9031
  {
8961
9032
  this._trigger( new LX.IEvent( name, value, event ), callback );
@@ -9252,6 +9323,25 @@ class Select extends Widget {
9252
9323
 
9253
9324
  container.appendChild( listDialog );
9254
9325
 
9326
+ // Element suboptions
9327
+ let suboptions = document.createElement( "div" );
9328
+ suboptions.className = "lexcustomcontainer w-full";
9329
+
9330
+ const suboptionsFunc = options[ `on_${ value }` ];
9331
+ suboptions.toggleAttribute( "hidden", !suboptionsFunc );
9332
+
9333
+ if( suboptionsFunc )
9334
+ {
9335
+ suboptions.innerHTML = "";
9336
+ const suboptionsPanel = new LX.Panel();
9337
+ suboptionsPanel.queue( suboptions );
9338
+ suboptionsFunc.call( this, suboptionsPanel );
9339
+ suboptionsPanel.clearQueue();
9340
+ }
9341
+
9342
+ this.root.appendChild( suboptions );
9343
+ this.root.dataset["opened"] = ( !!suboptionsFunc );
9344
+
9255
9345
  LX.doAsync( this.onResize.bind( this ) );
9256
9346
  }
9257
9347
 
@@ -10355,6 +10445,7 @@ class NumberInput extends Widget {
10355
10445
  slider.step = options.step ?? 1;
10356
10446
  slider.type = "range";
10357
10447
  slider.value = value;
10448
+ slider.disabled = this.disabled;
10358
10449
 
10359
10450
  slider.addEventListener( "input", ( e ) => {
10360
10451
  this.set( slider.valueAsNumber, false, e );
@@ -11442,7 +11533,7 @@ class TabSections extends Widget {
11442
11533
  let tabEl = document.createElement( "div" );
11443
11534
  tabEl.className = "lextab " + (i == tabs.length - 1 ? "last" : "") + ( isSelected ? "selected" : "" );
11444
11535
  tabEl.innerHTML = ( showNames ? tab.name : "" );
11445
- tabEl.appendChild( LX.makeIcon( tab.icon ?? "Hash", { title: tab.name } ) );
11536
+ tabEl.appendChild( LX.makeIcon( tab.icon ?? "Hash", { title: tab.name, iconClass: tab.iconClass, svgClass: tab.svgClass } ) );
11446
11537
 
11447
11538
  let infoContainer = document.createElement( "div" );
11448
11539
  infoContainer.id = tab.name.replace( /\s/g, '' );
@@ -11478,7 +11569,7 @@ class TabSections extends Widget {
11478
11569
  // Push to tab space
11479
11570
  const creationPanel = new LX.Panel();
11480
11571
  creationPanel.queue( infoContainer );
11481
- tab.onCreate.call(this, creationPanel);
11572
+ tab.onCreate.call( this, creationPanel, infoContainer );
11482
11573
  creationPanel.clearQueue();
11483
11574
  }
11484
11575
  }
@@ -11797,7 +11888,9 @@ class Table extends Widget {
11797
11888
  const body = table.querySelector( "tbody" );
11798
11889
  for( const el of body.childNodes )
11799
11890
  {
11800
- data.checkMap[ el.getAttribute( "rowId" ) ] = this.checked;
11891
+ const rowId = el.getAttribute( "rowId" );
11892
+ if( !rowId ) continue;
11893
+ data.checkMap[ rowId ] = this.checked;
11801
11894
  el.querySelector( "input[type='checkbox']" ).checked = this.checked;
11802
11895
  }
11803
11896
  });
@@ -12008,8 +12101,8 @@ class Table extends Widget {
12008
12101
  }
12009
12102
 
12010
12103
  const row = document.createElement( 'tr' );
12011
- const rowId = LX.getSupportedDOMName( bodyData.join( '-' ) );
12012
- row.setAttribute( "rowId", rowId.substr(0, 32) );
12104
+ const rowId = LX.getSupportedDOMName( bodyData.join( '-' ) ).substr(0, 32);
12105
+ row.setAttribute( "rowId", rowId );
12013
12106
 
12014
12107
  if( options.sortable ?? false )
12015
12108
  {
@@ -12125,7 +12218,7 @@ class Table extends Widget {
12125
12218
  }
12126
12219
  else if( action == "menu" )
12127
12220
  {
12128
- button = LX.makeIcon( "Ellipsis", { title: "Menu" } );
12221
+ button = LX.makeIcon( "EllipsisVertical", { title: "Menu" } );
12129
12222
  button.addEventListener( 'click', function( event ) {
12130
12223
  if( !options.onMenuAction )
12131
12224
  {
@@ -12164,6 +12257,17 @@ class Table extends Widget {
12164
12257
 
12165
12258
  body.appendChild( row );
12166
12259
  }
12260
+
12261
+ if( body.childNodes.length == 0 )
12262
+ {
12263
+ const row = document.createElement( 'tr' );
12264
+ const td = document.createElement( 'td' );
12265
+ td.setAttribute( "colspan", data.head.length + this.rowOffsetCount + 1 ); // +1 for rowActions
12266
+ td.className = "empty-row";
12267
+ td.innerHTML = "No results.";
12268
+ row.appendChild( td );
12269
+ body.appendChild( row );
12270
+ }
12167
12271
  }
12168
12272
 
12169
12273
  for( const v in data.colVisibilityMap )
@@ -12341,8 +12445,8 @@ class Map2D extends Widget {
12341
12445
  }
12342
12446
  }
12343
12447
 
12344
- LX.Map2D = Map2D;
12345
-
12448
+ LX.Map2D = Map2D;
12449
+
12346
12450
  // panel.js @jxarco
12347
12451
 
12348
12452
  /**
@@ -12948,6 +13052,7 @@ class Panel {
12948
13052
  * hideName: Don't use name as label [false]
12949
13053
  * disabled: Make the widget disabled [false]
12950
13054
  * icon: Icon class to show as button value
13055
+ * iconPosition: Icon position (cover|start|end)
12951
13056
  * fileInput: Button click requests a file
12952
13057
  * fileInputType: Type of the requested file
12953
13058
  * img: Path to image to show as button value
@@ -13439,6 +13544,8 @@ class Panel {
13439
13544
  * @param {Array} tabs Contains objects with {
13440
13545
  * name: Name of the tab (if icon, use as title)
13441
13546
  * icon: Icon to be used as the tab icon (optional)
13547
+ * iconClass: Class to be added to the icon (optional)
13548
+ * svgClass: Class to be added to the inner SVG of the icon (optional)
13442
13549
  * onCreate: Func to be called at tab creation
13443
13550
  * onSelect: Func to be called on select tab (optional)
13444
13551
  * }
@@ -13524,8 +13631,8 @@ class Panel {
13524
13631
  }
13525
13632
  }
13526
13633
 
13527
- LX.Panel = Panel;
13528
-
13634
+ LX.Panel = Panel;
13635
+
13529
13636
  // branch.js @jxarco
13530
13637
 
13531
13638
  /**
@@ -13749,8 +13856,8 @@ class Branch {
13749
13856
  }
13750
13857
  }
13751
13858
  }
13752
- LX.Branch = Branch;
13753
-
13859
+ LX.Branch = Branch;
13860
+
13754
13861
  // menubar.js @jxarco
13755
13862
 
13756
13863
  /**
@@ -14038,7 +14145,7 @@ class Menubar {
14038
14145
  this.buttonContainer.className = "lexmenubuttons";
14039
14146
  this.buttonContainer.classList.add( options.float ?? "center" );
14040
14147
 
14041
- if( options.position == "right" )
14148
+ if( options.float == "right" )
14042
14149
  {
14043
14150
  this.buttonContainer.right = true;
14044
14151
  }
@@ -14057,7 +14164,7 @@ class Menubar {
14057
14164
  {
14058
14165
  const data = buttons[ i ];
14059
14166
  const title = data.title;
14060
- const button = new LX.Button( title, "", data.callback, { title, buttonClass: "bg-none", disabled: data.disabled, icon: data.icon, hideName: true, swap: data.swap } );
14167
+ const button = new LX.Button( title, data.label, data.callback, { title, buttonClass: "bg-none", disabled: data.disabled, icon: data.icon, hideName: true, swap: data.swap, iconPosition: "start" } );
14061
14168
  this.buttonContainer.appendChild( button.root );
14062
14169
 
14063
14170
  if( title )
@@ -14067,8 +14174,8 @@ class Menubar {
14067
14174
  }
14068
14175
  }
14069
14176
  }
14070
- LX.Menubar = Menubar;
14071
-
14177
+ LX.Menubar = Menubar;
14178
+
14072
14179
  // sidebar.js @jxarco
14073
14180
 
14074
14181
  /**
@@ -14763,8 +14870,8 @@ class Sidebar {
14763
14870
  }
14764
14871
  }
14765
14872
  }
14766
- LX.Sidebar = Sidebar;
14767
-
14873
+ LX.Sidebar = Sidebar;
14874
+
14768
14875
  // asset_view.js @jxarco
14769
14876
 
14770
14877
  class AssetViewEvent {
@@ -15631,6 +15738,6 @@ class AssetView {
15631
15738
  }
15632
15739
  }
15633
15740
 
15634
- LX.AssetView = AssetView;
15635
-
15636
- export { ADD_CUSTOM_WIDGET, Area, AssetView, AssetViewEvent, Branch, LX, Menubar, Panel, Sidebar, Widget };
15741
+ LX.AssetView = AssetView;
15742
+
15743
+ export { ADD_CUSTOM_WIDGET, Area, AssetView, AssetViewEvent, Branch, LX, Menubar, Panel, Sidebar, Widget };