lexgui 0.7.6 → 0.7.8

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.6",
10
+ version: "0.7.8",
11
11
  ready: false,
12
12
  extensions: [], // Store extensions used
13
13
  signals: {}, // Events and triggers
@@ -1239,7 +1239,7 @@ class DropdownMenu {
1239
1239
  }
1240
1240
 
1241
1241
  const menuItem = document.createElement('div');
1242
- menuItem.className = "lexdropdownmenuitem" + ( item.name ? "" : " label" ) + ( item.disabled ?? false ? " disabled" : "" ) + ( ` ${ item.className ?? "" }` );
1242
+ menuItem.className = "lexdropdownmenuitem" + ( ( item.name || item.options ) ? "" : " label" ) + ( item.disabled ?? false ? " disabled" : "" ) + ( ` ${ item.className ?? "" }` );
1243
1243
  menuItem.dataset["id"] = pKey;
1244
1244
  menuItem.innerHTML = `<span>${ key }</span>`;
1245
1245
  menuItem.tabIndex = "1";
@@ -1325,7 +1325,7 @@ class DropdownMenu {
1325
1325
  else
1326
1326
  {
1327
1327
  menuItem.addEventListener( "click", () => {
1328
- const f = item[ 'callback' ];
1328
+ const f = item.callback;
1329
1329
  if( f )
1330
1330
  {
1331
1331
  f.call( this, key, menuItem );
@@ -1337,7 +1337,11 @@ class DropdownMenu {
1337
1337
  this._trigger[ radioName ] = key;
1338
1338
  }
1339
1339
 
1340
- this.destroy( true );
1340
+ // If has options, it's a radio group label, so don't close the menu
1341
+ if( !item.options && ( item.closeOnClick ?? true ) )
1342
+ {
1343
+ this.destroy( true );
1344
+ }
1341
1345
  } );
1342
1346
  }
1343
1347
 
@@ -1375,8 +1379,6 @@ class DropdownMenu {
1375
1379
 
1376
1380
  if( item.options )
1377
1381
  {
1378
- this._addSeparator();
1379
-
1380
1382
  console.assert( this._trigger[ item.name ] && "An item of the radio group must be selected!" );
1381
1383
  this._radioGroup = {
1382
1384
  name: item.name,
@@ -3123,6 +3125,7 @@ class ContextMenu {
3123
3125
  }
3124
3126
  else if( (rect.top + rect.height) > window.innerHeight )
3125
3127
  {
3128
+ div.style.marginTop = "";
3126
3129
  top = (window.innerHeight - rect.height - margin);
3127
3130
  }
3128
3131
  }
@@ -6609,6 +6612,22 @@ Object.assign(LX, {
6609
6612
  }
6610
6613
  });
6611
6614
 
6615
+ /**
6616
+ * @method formatBytes
6617
+ * @param {Number} bytes
6618
+ **/
6619
+ function formatBytes( bytes )
6620
+ {
6621
+ if( bytes === 0 ) return "0 B";
6622
+ const k = 1024;
6623
+ const sizes = [ "B", "KB", "MB", "GB", "TB" ];
6624
+ const i = Math.floor( Math.log( bytes ) / Math.log( k ) );
6625
+ const value = bytes / Math.pow( k, i );
6626
+ return value.toFixed( 2 ) + " " + sizes[ i ];
6627
+ }
6628
+
6629
+ LX.formatBytes = formatBytes;
6630
+
6612
6631
  /**
6613
6632
  * @method compareThreshold
6614
6633
  * @param {String} url
@@ -11215,7 +11234,7 @@ class RangeInput extends BaseComponent {
11215
11234
  container.appendChild( slider );
11216
11235
 
11217
11236
  slider.addEventListener( "input", e => {
11218
- this.set( isRangeValue ? [ e.target.valueAsNumber, ogValue[ 1 ] ] : e.target.valueAsNumber, false, e );
11237
+ this.set( isRangeValue ? [ Math.min(e.target.valueAsNumber, ogValue[ 1 ]), ogValue[ 1 ] ] : e.target.valueAsNumber, false, e );
11219
11238
  }, { passive: false });
11220
11239
 
11221
11240
  // If its a range value, we need to update the slider using the thumbs
@@ -11281,7 +11300,7 @@ class RangeInput extends BaseComponent {
11281
11300
  container.appendChild( maxSlider );
11282
11301
 
11283
11302
  maxSlider.addEventListener( "input", e => {
11284
- ogValue[ 1 ] = +e.target.valueAsNumber;
11303
+ ogValue[ 1 ] = Math.max(value, +e.target.valueAsNumber);
11285
11304
  this.set( [ value, ogValue[ 1 ] ], false, e );
11286
11305
  }, { passive: false });
11287
11306
  }
@@ -16158,7 +16177,8 @@ LX.AssetViewEvent = AssetViewEvent;
16158
16177
  class AssetView {
16159
16178
 
16160
16179
  static LAYOUT_GRID = 0;
16161
- static LAYOUT_LIST = 1;
16180
+ static LAYOUT_COMPACT = 1;
16181
+ static LAYOUT_LIST = 2;
16162
16182
 
16163
16183
  static CONTENT_SORT_ASC = 0;
16164
16184
  static CONTENT_SORT_DESC = 1;
@@ -16420,7 +16440,9 @@ class AssetView {
16420
16440
  }
16421
16441
  else
16422
16442
  {
16423
- this.toolsPanel = area.addPanel({ className: 'flex flex-col overflow-hidden' });
16443
+ area.root.classList.add( "flex", "flex-col" );
16444
+ this.toolsPanel = area.addPanel({ className: 'flex flex-col overflow-hidden', height:"auto" });
16445
+ this.toolsPanel.root.style.flex = "none";
16424
16446
  this.contentPanel = area.addPanel({ className: 'lexassetcontentpanel flex flex-col overflow-hidden' });
16425
16447
  }
16426
16448
 
@@ -16437,7 +16459,8 @@ class AssetView {
16437
16459
  const _onChangeView = ( value, event ) => {
16438
16460
  new LX.DropdownMenu( event.target, [
16439
16461
  { name: "Grid", icon: "LayoutGrid", callback: () => this._setContentLayout( AssetView.LAYOUT_GRID ) },
16440
- { name: "List", icon: "LayoutList", callback: () => this._setContentLayout( AssetView.LAYOUT_LIST ) }
16462
+ { name: "Compact", icon: "LayoutList", callback: () => this._setContentLayout( AssetView.LAYOUT_COMPACT ) },
16463
+ { name: "List", icon: "List", callback: () => this._setContentLayout( AssetView.LAYOUT_LIST ) }
16441
16464
  ], { side: "right", align: "start" });
16442
16465
  };
16443
16466
 
@@ -16473,9 +16496,11 @@ class AssetView {
16473
16496
  this.toolsPanel.addText(null, textString, null, {
16474
16497
  inputClass: "nobg", disabled: true, signal: "@on_page_change", maxWidth: "16ch" }
16475
16498
  );
16499
+ this.toolsPanel.endLine();
16476
16500
 
16477
16501
  if( !this.skipBrowser )
16478
16502
  {
16503
+ this.toolsPanel.sameLine();
16479
16504
  this.toolsPanel.addComboButtons( null, [
16480
16505
  {
16481
16506
  value: "Left",
@@ -16510,9 +16535,9 @@ class AssetView {
16510
16535
  inputClass: "nobg", disabled: true, signal: "@on_folder_change",
16511
16536
  style: { fontWeight: "600", fontSize: "15px" }
16512
16537
  });
16513
- }
16514
16538
 
16515
- this.toolsPanel.endLine();
16539
+ this.toolsPanel.endLine();
16540
+ }
16516
16541
  };
16517
16542
 
16518
16543
  this.toolsPanel.refresh();
@@ -16545,11 +16570,13 @@ class AssetView {
16545
16570
  _refreshContent( searchValue, filter ) {
16546
16571
 
16547
16572
  const isGridLayout = ( this.layout == AssetView.LAYOUT_GRID ); // default
16573
+ const isCompactLayout = ( this.layout == AssetView.LAYOUT_COMPACT );
16574
+ const isListLayout = ( this.layout == AssetView.LAYOUT_LIST );
16548
16575
 
16549
16576
  this.filter = filter ?? ( this.filter ?? "None" );
16550
16577
  this.searchValue = searchValue ?? (this.searchValue ?? "");
16551
16578
  this.content.innerHTML = "";
16552
- this.content.className = (isGridLayout ? "lexassetscontent" : "lexassetscontent list");
16579
+ this.content.className = `lexassetscontent${ isCompactLayout ? " compact" : ( isListLayout ? " list" : "" ) }`;
16553
16580
  let that = this;
16554
16581
 
16555
16582
  const _addItem = function(item) {
@@ -16563,6 +16590,11 @@ class AssetView {
16563
16590
  itemEl.tabIndex = -1;
16564
16591
  that.content.appendChild( itemEl );
16565
16592
 
16593
+ if( item.lastModified && !item.lastModifiedDate )
16594
+ {
16595
+ item.lastModifiedDate = that._lastModifiedToStringDate( item.lastModified );
16596
+ }
16597
+
16566
16598
  if( !that.useNativeTitle )
16567
16599
  {
16568
16600
  let desc = document.createElement( 'span' );
@@ -16684,14 +16716,17 @@ class AssetView {
16684
16716
  }
16685
16717
  }
16686
16718
 
16687
- if( !isFolder )
16719
+ // Add item type info
16720
+ let itemInfoHtml = type;
16721
+
16722
+ if( isListLayout )
16688
16723
  {
16689
- let info = document.createElement('span');
16690
- info.className = "lexassetinfo";
16691
- info.innerText = type;
16692
- itemEl.appendChild(info);
16724
+ if( item.bytesize ) itemInfoHtml += ` | ${ LX.formatBytes( item.bytesize ) }`;
16725
+ if( item.lastModifiedDate ) itemInfoHtml += ` | ${ item.lastModifiedDate }`;
16693
16726
  }
16694
16727
 
16728
+ LX.makeContainer( [ "auto", "auto" ], "lexassetinfo", itemInfoHtml, itemEl );
16729
+
16695
16730
  itemEl.addEventListener('click', function( e ) {
16696
16731
  e.stopImmediatePropagation();
16697
16732
  e.stopPropagation();
@@ -16833,18 +16868,18 @@ class AssetView {
16833
16868
  const options = { disabled: true };
16834
16869
 
16835
16870
  this.previewPanel.addText("Filename", file.id, null, options);
16836
- if( file.lastModified ) this.previewPanel.addText("Last Modified", new Date( file.lastModified ).toLocaleString(), null, options);
16871
+ if( file.lastModifiedDate ) this.previewPanel.addText("Last Modified", file.lastModifiedDate, null, options);
16837
16872
  if( file._path || file.src ) this.previewPanel.addText("URL", file._path ? file._path : file.src, null, options);
16838
16873
  this.previewPanel.addText("Path", this.path.join('/'), null, options);
16839
16874
  this.previewPanel.addText("Type", file.type, null, options);
16840
- if( file.bytesize ) this.previewPanel.addText("Size", (file.bytesize/1024).toPrecision(3) + " KBs", null, options);
16875
+ if( file.bytesize ) this.previewPanel.addText("Size", LX.formatBytes( file.bytesize ), null, options);
16841
16876
  if( file.type == "folder" ) this.previewPanel.addText("Files", file.children ? file.children.length.toString() : "0", null, options);
16842
16877
 
16843
16878
  this.previewPanel.addSeparator();
16844
16879
 
16845
16880
  const previewActions = [...this.previewActions];
16846
16881
 
16847
- if( !previewActions.length )
16882
+ if( !previewActions.length && file.type !== "folder" )
16848
16883
  {
16849
16884
  // By default
16850
16885
  previewActions.push({
@@ -16884,7 +16919,8 @@ class AssetView {
16884
16919
  "id": file.name,
16885
16920
  "src": e.currentTarget.result,
16886
16921
  "extension": ext,
16887
- "lastModified": file.lastModified
16922
+ "lastModified": file.lastModified,
16923
+ "lastModifiedDate": this._lastModifiedToStringDate( file.lastModified )
16888
16924
  };
16889
16925
 
16890
16926
  switch(ext)
@@ -16997,6 +17033,11 @@ class AssetView {
16997
17033
 
16998
17034
  this._processData( this.data );
16999
17035
  }
17036
+
17037
+ _lastModifiedToStringDate( lm ) {
17038
+ const d = new Date( lm ).toLocaleString();
17039
+ return d.substring( 0, d.indexOf( ',' ) );
17040
+ }
17000
17041
  }
17001
17042
 
17002
17043
  LX.AssetView = AssetView;