lexgui 0.7.9 → 0.7.10

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.7.9",
10
+ version: "0.7.10",
11
11
  ready: false,
12
12
  extensions: [], // Store extensions used
13
13
  signals: {}, // Events and triggers
@@ -2577,9 +2577,11 @@ class Tabs {
2577
2577
 
2578
2578
  if( isSelected && this.thumb )
2579
2579
  {
2580
+ this.thumb.classList.add( "no-transition" );
2580
2581
  this.thumb.style.transform = "translate( " + ( tabEl.childIndex * tabEl.offsetWidth ) + "px )";
2581
2582
  this.thumb.style.width = ( tabEl.offsetWidth ) + "px";
2582
2583
  this.thumb.item = tabEl;
2584
+ this.thumb.classList.remove( "no-transition" );
2583
2585
  }
2584
2586
 
2585
2587
  }, 10 );
@@ -4567,8 +4569,8 @@ Element.prototype.ignore = function( eventName, callbackName ) {
4567
4569
  callbackName = callbackName ?? ( "_on" + eventName );
4568
4570
  const callback = this[ callbackName ];
4569
4571
  this.removeEventListener( eventName, callback );
4570
- };
4571
-
4572
+ };
4573
+
4572
4574
  // icons.js @jxarco
4573
4575
 
4574
4576
  const RAW_ICONS = {
@@ -4749,8 +4751,8 @@ LX.LucideIconAlias = {
4749
4751
  "RotateRight": "RotateCw",
4750
4752
  "RotateBack": "RotateCcw",
4751
4753
  "RotateLeft": "RotateCcw",
4752
- };
4753
-
4754
+ };
4755
+
4754
4756
  // utils.js @jxarco
4755
4757
 
4756
4758
  function clamp( num, min, max ) { return Math.min( Math.max( num, min ), max ); }
@@ -5535,47 +5537,49 @@ function makeCodeSnippet( code, size, options = { } )
5535
5537
  disableEdition: true,
5536
5538
  allowAddScripts: false,
5537
5539
  name: options.tabName,
5538
- // showTab: options.showTab ?? true
5539
- } );
5540
- editor.setText( code, options.language ?? "Plain Text" );
5541
-
5542
- if( options.linesAdded )
5543
- {
5544
- const code = editor.root.querySelector( ".code" );
5545
- for( let l of options.linesAdded )
5540
+ callback: () =>
5546
5541
  {
5547
- if( l.constructor == Number )
5548
- {
5549
- code.childNodes[ l - 1 ].classList.add( "added" );
5550
- }
5551
- else if( l.constructor == Array ) // It's a range
5542
+ if( options.linesAdded )
5552
5543
  {
5553
- for( let i = ( l[ 0 ] - 1 ); i <= ( l[ 1 ] - 1 ); i++ )
5544
+ const code = editor.root.querySelector( ".code" );
5545
+ for( let l of options.linesAdded )
5554
5546
  {
5555
- code.childNodes[ i ].classList.add( "added" );
5547
+ if( l.constructor == Number )
5548
+ {
5549
+ code.childNodes[ l - 1 ].classList.add( "added" );
5550
+ }
5551
+ else if( l.constructor == Array ) // It's a range
5552
+ {
5553
+ for( let i = ( l[ 0 ] - 1 ); i <= ( l[ 1 ] - 1 ); i++ )
5554
+ {
5555
+ code.childNodes[ i ].classList.add( "added" );
5556
+ }
5557
+ }
5556
5558
  }
5557
5559
  }
5558
- }
5559
- }
5560
5560
 
5561
- if( options.linesRemoved )
5562
- {
5563
- const code = editor.root.querySelector( ".code" );
5564
- for( let l of options.linesRemoved )
5565
- {
5566
- if( l.constructor == Number )
5567
- {
5568
- code.childNodes[ l - 1 ].classList.add( "removed" );
5569
- }
5570
- else if( l.constructor == Array ) // It's a range
5561
+ if( options.linesRemoved )
5571
5562
  {
5572
- for( let i = ( l[ 0 ] - 1 ); i <= ( l[ 1 ] - 1 ); i++ )
5563
+ const code = editor.root.querySelector( ".code" );
5564
+ for( let l of options.linesRemoved )
5573
5565
  {
5574
- code.childNodes[ i ].classList.add( "removed" );
5566
+ if( l.constructor == Number )
5567
+ {
5568
+ code.childNodes[ l - 1 ].classList.add( "removed" );
5569
+ }
5570
+ else if( l.constructor == Array ) // It's a range
5571
+ {
5572
+ for( let i = ( l[ 0 ] - 1 ); i <= ( l[ 1 ] - 1 ); i++ )
5573
+ {
5574
+ code.childNodes[ i ].classList.add( "removed" );
5575
+ }
5576
+ }
5575
5577
  }
5576
5578
  }
5577
5579
  }
5578
- }
5580
+ } );
5581
+
5582
+ editor.setText( code, options.language ?? "Plain Text" );
5579
5583
 
5580
5584
  if( options.windowMode )
5581
5585
  {
@@ -5600,6 +5604,7 @@ function makeCodeSnippet( code, size, options = { } )
5600
5604
  }
5601
5605
 
5602
5606
  snippet.appendChild( area.root );
5607
+
5603
5608
  return snippet;
5604
5609
  }
5605
5610
 
@@ -6730,8 +6735,8 @@ function drawSpline( ctx, pts, t )
6730
6735
  ctx.restore();
6731
6736
  }
6732
6737
 
6733
- LX.drawSpline = drawSpline;
6734
-
6738
+ LX.drawSpline = drawSpline;
6739
+
6735
6740
  // area.js @jxarco
6736
6741
 
6737
6742
  class AreaOverlayButtons {
@@ -7532,21 +7537,25 @@ class Area {
7532
7537
  let [ area1, area2 ] = this.sections;
7533
7538
  this.splitExtended = true;
7534
7539
 
7540
+ area1.root.classList.add( `maximize-${ this.type }` );
7541
+ area2.root.classList.add( `minimize-${ this.type }` );
7542
+ area2.root.classList.add( `fadeout-${ this.type }` );
7543
+ area2.root.classList.remove( `fadein-${ this.type }` );
7544
+
7535
7545
  if( this.type == "vertical" )
7536
7546
  {
7537
7547
  this.offset = area2.root.offsetHeight;
7538
- area2.root.classList.add("fadeout-vertical");
7539
7548
  this._moveSplit( -Infinity, true );
7540
-
7541
7549
  }
7542
7550
  else
7543
7551
  {
7544
7552
  this.offset = area2.root.offsetWidth - 8; // Force some height here...
7545
- area2.root.classList.add("fadeout-horizontal");
7546
7553
  this._moveSplit( -Infinity, true, 8 );
7547
7554
  }
7548
7555
 
7549
- LX.doAsync( () => this.propagateEvent('onresize'), 150 );
7556
+ LX.doAsync( () => {
7557
+ this.propagateEvent( 'onresize' );
7558
+ }, 100 );
7550
7559
  }
7551
7560
 
7552
7561
  /**
@@ -7556,23 +7565,24 @@ class Area {
7556
7565
  reduce() {
7557
7566
 
7558
7567
  if( !this.splitExtended )
7559
- return;
7568
+ {
7569
+ return;
7570
+ }
7560
7571
 
7561
7572
  this.splitExtended = false;
7562
- let [area1, area2] = this.sections;
7563
7573
 
7564
- if( this.type == "vertical")
7565
- {
7566
- area2.root.classList.add("fadein-vertical");
7567
- this._moveSplit(this.offset);
7568
- }
7569
- else
7570
- {
7571
- area2.root.classList.add("fadein-horizontal");
7572
- this._moveSplit(this.offset);
7573
- }
7574
+ let [ area1, area2 ] = this.sections;
7575
+
7576
+ area1.root.classList.add( `minimize-${ this.type }` );
7577
+ area2.root.classList.add( `maximize-${ this.type }` );
7578
+ area2.root.classList.add( `fadein-${ this.type }` );
7579
+ area2.root.classList.remove( `fadeout-${ this.type }` );
7580
+
7581
+ this._moveSplit( this.offset );
7574
7582
 
7575
- LX.doAsync( () => this.propagateEvent('onresize'), 150 );
7583
+ LX.doAsync( () => {
7584
+ this.propagateEvent( 'onresize' );
7585
+ }, 100 );
7576
7586
  }
7577
7587
 
7578
7588
  /**
@@ -7876,8 +7886,8 @@ class Area {
7876
7886
  }
7877
7887
  }
7878
7888
  }
7879
- LX.Area = Area;
7880
-
7889
+ LX.Area = Area;
7890
+
7881
7891
  // base_component.js @jxarco
7882
7892
 
7883
7893
  /**
@@ -13658,8 +13668,8 @@ class Rate extends BaseComponent {
13658
13668
  }
13659
13669
  }
13660
13670
 
13661
- LX.Rate = Rate;
13662
-
13671
+ LX.Rate = Rate;
13672
+
13663
13673
  // panel.js @jxarco
13664
13674
 
13665
13675
  /**
@@ -14858,8 +14868,8 @@ class Panel {
14858
14868
  }
14859
14869
  }
14860
14870
 
14861
- LX.Panel = Panel;
14862
-
14871
+ LX.Panel = Panel;
14872
+
14863
14873
  // branch.js @jxarco
14864
14874
 
14865
14875
  /**
@@ -15083,8 +15093,8 @@ class Branch {
15083
15093
  }
15084
15094
  }
15085
15095
  }
15086
- LX.Branch = Branch;
15087
-
15096
+ LX.Branch = Branch;
15097
+
15088
15098
  // menubar.js @jxarco
15089
15099
 
15090
15100
  /**
@@ -15420,8 +15430,8 @@ class Menubar {
15420
15430
  }
15421
15431
  }
15422
15432
  }
15423
- LX.Menubar = Menubar;
15424
-
15433
+ LX.Menubar = Menubar;
15434
+
15425
15435
  // sidebar.js @jxarco
15426
15436
 
15427
15437
  /**
@@ -16145,8 +16155,8 @@ class Sidebar {
16145
16155
  }
16146
16156
  }
16147
16157
  }
16148
- LX.Sidebar = Sidebar;
16149
-
16158
+ LX.Sidebar = Sidebar;
16159
+
16150
16160
  // asset_view.js @jxarco
16151
16161
 
16152
16162
  class AssetViewEvent {
@@ -16588,13 +16598,13 @@ class AssetView {
16588
16598
  const isListLayout = ( this.layout == AssetView.LAYOUT_LIST );
16589
16599
 
16590
16600
  this.filter = filter ?? ( this.filter ?? "None" );
16591
- this.searchValue = searchValue ?? (this.searchValue ?? "");
16601
+ this.searchValue = searchValue ?? ( this.searchValue ?? "" );
16592
16602
  this.content.innerHTML = "";
16593
16603
  this.content.className = `lexassetscontent${ isCompactLayout ? " compact" : ( isListLayout ? " list" : "" ) }`;
16594
16604
  let that = this;
16595
16605
 
16596
- const _addItem = function(item) {
16597
-
16606
+ const _addItem = function( item )
16607
+ {
16598
16608
  const type = item.type.charAt( 0 ).toUpperCase() + item.type.slice( 1 );
16599
16609
  const extension = LX.getExtension( item.id );
16600
16610
  const isFolder = type === "Folder";
@@ -16613,10 +16623,11 @@ class AssetView {
16613
16623
  {
16614
16624
  let desc = document.createElement( 'span' );
16615
16625
  desc.className = 'lexitemdesc';
16616
- desc.innerHTML = "File: " + item.id + "<br>Type: " + type;
16626
+ desc.id = `floatingTitle_${ item.id }`;
16627
+ desc.innerHTML = `File: ${ item.id }<br>Type: ${ type }`;
16617
16628
  that.content.appendChild( desc );
16618
16629
 
16619
- itemEl.addEventListener("mousemove", e => {
16630
+ itemEl.addEventListener( "mousemove", e => {
16620
16631
 
16621
16632
  if( !isGridLayout )
16622
16633
  {
@@ -16644,23 +16655,7 @@ class AssetView {
16644
16655
 
16645
16656
  desc.style.left = ( localOffsetX ) + "px";
16646
16657
  desc.style.top = ( localOffsetY - 36 ) + "px";
16647
- });
16648
-
16649
- itemEl.addEventListener("mouseenter", () => {
16650
- if( isGridLayout )
16651
- {
16652
- desc.style.display = "unset";
16653
- }
16654
- });
16655
-
16656
- itemEl.addEventListener("mouseleave", () => {
16657
- if( isGridLayout )
16658
- {
16659
- setTimeout( () => {
16660
- desc.style.display = "none";
16661
- }, 100 );
16662
- }
16663
- });
16658
+ } );
16664
16659
  }
16665
16660
  else
16666
16661
  {
@@ -16695,26 +16690,49 @@ class AssetView {
16695
16690
 
16696
16691
  if( !that.skipPreview )
16697
16692
  {
16693
+ if( item.type === 'video' )
16694
+ {
16695
+ const itemVideo = LX.makeElement( 'video', 'absolute left-0 top-0 w-full border-none pointer-events-none', '', itemEl );
16696
+ itemVideo.setAttribute( 'disablePictureInPicture', false );
16697
+ itemVideo.setAttribute( 'disableRemotePlayback', false );
16698
+ itemVideo.setAttribute( 'loop', true );
16699
+ itemVideo.setAttribute( 'async', true );
16700
+ itemVideo.style.transition = 'opacity 0.2s ease-out';
16701
+ itemVideo.style.opacity = item.preview ? '0' : '1';
16702
+ itemVideo.src = item.src;
16703
+ itemVideo.volume = item.videoVolume ?? 0.4;
16704
+ }
16705
+
16698
16706
  let preview = null;
16699
- const hasImage = item.src && (['png', 'jpg'].indexOf( LX.getExtension( item.src ) ) > -1 || item.src.includes("data:image/") ); // Support b64 image as src
16700
16707
 
16701
- if( hasImage || isFolder || !isGridLayout)
16708
+ const previewSrc = item.preview ?? item.src;
16709
+ const hasImage = previewSrc && (
16710
+ (() => {
16711
+ const ext = LX.getExtension( previewSrc.split( '?' )[ 0 ].split( '#' )[ 0 ]); // get final source without url parameters/anchors
16712
+ return ext ? ['png', 'jpg', 'jpeg', 'gif', 'bmp', 'avif'].includes( ext.toLowerCase() ) : false;
16713
+ })()
16714
+ || previewSrc.startsWith( 'data:image/' )
16715
+ );
16716
+
16717
+ if( hasImage || isFolder || !isGridLayout )
16702
16718
  {
16719
+ const defaultPreviewPath = `${ that.rootPath }images/file.png`;
16720
+ const defaultFolderPath = `${ that.rootPath }images/folder.png`;
16721
+
16703
16722
  preview = document.createElement('img');
16704
- let real_src = item.unknown_extension ? that.rootPath + "images/file.png" : (isFolder ? that.rootPath + "images/folder.png" : item.src);
16705
- preview.src = (isGridLayout || isFolder ? real_src : that.rootPath + "images/file.png");
16723
+ let realSrc = item.unknownExtension ? defaultPreviewPath : ( isFolder ? defaultFolderPath : previewSrc );
16724
+ preview.src = ( isGridLayout || isFolder ? realSrc : defaultPreviewPath );
16706
16725
  itemEl.appendChild( preview );
16707
16726
  }
16708
16727
  else
16709
16728
  {
16710
- preview = document.createElement('svg');
16711
- preview.className = "asset-file-preview";
16712
- itemEl.appendChild(preview);
16729
+ preview = document.createElement( 'svg' );
16730
+ preview.className = 'asset-file-preview';
16731
+ itemEl.appendChild( preview );
16713
16732
 
16714
- let textEl = document.createElement('text');
16715
- preview.appendChild(textEl);
16716
- // If no extension, e.g. Clip, use the type...
16717
- textEl.innerText = (!extension || extension == item.id) ? item.type.toUpperCase() : ("." + extension.toUpperCase());
16733
+ let textEl = document.createElement( 'text' );
16734
+ textEl.innerText = ( !extension || extension == item.id ) ? item.type.toUpperCase() : ( `.${ extension.toUpperCase() }` ); // If no extension, e.g. Clip, use the type...
16735
+ preview.appendChild( textEl );
16718
16736
 
16719
16737
  var newLength = textEl.innerText.length;
16720
16738
  var charsPerLine = 2.5;
@@ -16724,8 +16742,8 @@ class AssetView {
16724
16742
  if( newEmSize < 1 )
16725
16743
  {
16726
16744
  var newFontSize = newEmSize * textBaseSize;
16727
- textEl.style.fontSize = newFontSize + "px";
16728
- preview.style.paddingTop = "calc(50% - " + (textEl.offsetHeight * 0.5 + 10) + "px)";
16745
+ textEl.style.fontSize = newFontSize + 'px';
16746
+ preview.style.paddingTop = `calc(50% - ${ ( textEl.offsetHeight * 0.5 + 10 ) }px)`;
16729
16747
  }
16730
16748
  }
16731
16749
  }
@@ -16739,7 +16757,7 @@ class AssetView {
16739
16757
  if( item.lastModifiedDate ) itemInfoHtml += ` | ${ item.lastModifiedDate }`;
16740
16758
  }
16741
16759
 
16742
- LX.makeContainer( [ "auto", "auto" ], "lexassetinfo", itemInfoHtml, itemEl );
16760
+ LX.makeContainer( [ 'auto', 'auto' ], 'lexassetinfo', itemInfoHtml, itemEl );
16743
16761
 
16744
16762
  itemEl.addEventListener('click', function( e ) {
16745
16763
  e.stopImmediatePropagation();
@@ -16751,10 +16769,10 @@ class AssetView {
16751
16769
  {
16752
16770
  if( !e.shiftKey )
16753
16771
  {
16754
- that.content.querySelectorAll('.lexassetitem').forEach( i => i.classList.remove('selected') );
16772
+ that.content.querySelectorAll( '.lexassetitem').forEach( i => i.classList.remove( 'selected' ) );
16755
16773
  }
16756
16774
 
16757
- this.classList.add('selected');
16775
+ this.classList.add( 'selected' );
16758
16776
  that.selectedItem = item;
16759
16777
 
16760
16778
  if( !that.skipPreview )
@@ -16807,6 +16825,42 @@ class AssetView {
16807
16825
  e.preventDefault();
16808
16826
  }, false );
16809
16827
 
16828
+ itemEl.addEventListener( "mouseenter", ( e ) => {
16829
+
16830
+ if( !that.useNativeTitle && isGridLayout )
16831
+ {
16832
+ const desc = that.content.querySelector( `#floatingTitle_${ item.id }` );
16833
+ if( desc ) desc.style.display = "unset";
16834
+ }
16835
+
16836
+ if( item.type !== "video" ) return;
16837
+ e.preventDefault();
16838
+ const video = itemEl.querySelector( "video" );
16839
+ video.style.opacity = "1";
16840
+ video.play();
16841
+ } );
16842
+
16843
+ itemEl.addEventListener( "mouseleave", ( e ) => {
16844
+
16845
+ if( !that.useNativeTitle && isGridLayout )
16846
+ {
16847
+ setTimeout( () => {
16848
+ const desc = that.content.querySelector( `#floatingTitle_${ item.id }` );
16849
+ if( desc ) desc.style.display = "none";
16850
+ }, 100 );
16851
+ }
16852
+
16853
+ if( item.type !== "video" ) return;
16854
+ e.preventDefault();
16855
+ const video = itemEl.querySelector( "video" );
16856
+ video.pause();
16857
+ video.currentTime = 0;
16858
+ if( item.preview )
16859
+ {
16860
+ video.style.opacity = "0";
16861
+ }
16862
+ } );
16863
+
16810
16864
  return itemEl;
16811
16865
  };
16812
16866
 
@@ -16951,7 +17005,7 @@ class AssetView {
16951
17005
  item.type = "mesh"; break;
16952
17006
  default:
16953
17007
  item.type = ext;
16954
- item.unknown_extension = true;
17008
+ item.unknownExtension = true;
16955
17009
  break;
16956
17010
  }
16957
17011
 
@@ -17054,8 +17108,8 @@ class AssetView {
17054
17108
  }
17055
17109
  }
17056
17110
 
17057
- LX.AssetView = AssetView;
17058
-
17111
+ LX.AssetView = AssetView;
17112
+
17059
17113
  // tour.js @jxarco
17060
17114
 
17061
17115
  class Tour {
@@ -17353,6 +17407,6 @@ class Tour {
17353
17407
  } );
17354
17408
  }
17355
17409
  }
17356
- LX.Tour = Tour;
17357
-
17358
- export { ADD_CUSTOM_COMPONENT, Area, AssetView, AssetViewEvent, BaseComponent, Branch, LX, Menubar, Panel, Sidebar, Tour };
17410
+ LX.Tour = Tour;
17411
+
17412
+ export { ADD_CUSTOM_COMPONENT, Area, AssetView, AssetViewEvent, BaseComponent, Branch, LX, Menubar, Panel, Sidebar, Tour };