lexgui 0.7.8 → 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.8",
10
+ version: "0.7.10",
11
11
  ready: false,
12
12
  extensions: [], // Store extensions used
13
13
  signals: {}, // Events and triggers
@@ -1325,18 +1325,18 @@ class DropdownMenu {
1325
1325
  else
1326
1326
  {
1327
1327
  menuItem.addEventListener( "click", () => {
1328
- const f = item.callback;
1329
- if( f )
1330
- {
1331
- f.call( this, key, menuItem );
1332
- }
1333
-
1334
1328
  const radioName = menuItem.getAttribute( "data-radioname" );
1335
1329
  if( radioName )
1336
1330
  {
1337
1331
  this._trigger[ radioName ] = key;
1338
1332
  }
1339
1333
 
1334
+ const f = item.callback;
1335
+ if( f )
1336
+ {
1337
+ f.call( this, key, menuItem, radioName );
1338
+ }
1339
+
1340
1340
  // If has options, it's a radio group label, so don't close the menu
1341
1341
  if( !item.options && ( item.closeOnClick ?? true ) )
1342
1342
  {
@@ -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 )
5542
+ if( options.linesAdded )
5548
5543
  {
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++ )
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;
7574
7575
 
7575
- LX.doAsync( () => this.propagateEvent('onresize'), 150 );
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 );
7582
+
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
  /**
@@ -15162,17 +15172,26 @@ class Menubar {
15162
15172
  } });
15163
15173
  };
15164
15174
 
15165
- entry.addEventListener("click", () => {
15175
+ entry.addEventListener("mousedown", (e) => {
15176
+ e.preventDefault();
15177
+ });
15178
+
15179
+ entry.addEventListener("mouseup", (e) => {
15180
+
15181
+ e.preventDefault();
15182
+
15166
15183
  const f = item[ 'callback' ];
15167
15184
  if( f )
15168
15185
  {
15169
- f.call( this, key, entry );
15186
+ f.call( this, key, entry, e );
15170
15187
  return;
15171
15188
  }
15172
15189
 
15173
15190
  _showEntry();
15174
15191
 
15175
15192
  this.focused = true;
15193
+
15194
+ return false;
15176
15195
  });
15177
15196
 
15178
15197
  entry.addEventListener( "mouseover", (e) => {
@@ -15339,7 +15358,12 @@ class Menubar {
15339
15358
  }
15340
15359
 
15341
15360
  const _b = button.querySelector('a');
15342
- _b.addEventListener("click", (e) => {
15361
+
15362
+ _b.addEventListener( "mousedown", (e) => {
15363
+ e.preventDefault();
15364
+ });
15365
+
15366
+ _b.addEventListener( "mouseup", (e) => {
15343
15367
  if( callback && !disabled )
15344
15368
  {
15345
15369
  callback.call( this, _b, e );
@@ -15406,8 +15430,8 @@ class Menubar {
15406
15430
  }
15407
15431
  }
15408
15432
  }
15409
- LX.Menubar = Menubar;
15410
-
15433
+ LX.Menubar = Menubar;
15434
+
15411
15435
  // sidebar.js @jxarco
15412
15436
 
15413
15437
  /**
@@ -16131,8 +16155,8 @@ class Sidebar {
16131
16155
  }
16132
16156
  }
16133
16157
  }
16134
- LX.Sidebar = Sidebar;
16135
-
16158
+ LX.Sidebar = Sidebar;
16159
+
16136
16160
  // asset_view.js @jxarco
16137
16161
 
16138
16162
  class AssetViewEvent {
@@ -16574,13 +16598,13 @@ class AssetView {
16574
16598
  const isListLayout = ( this.layout == AssetView.LAYOUT_LIST );
16575
16599
 
16576
16600
  this.filter = filter ?? ( this.filter ?? "None" );
16577
- this.searchValue = searchValue ?? (this.searchValue ?? "");
16601
+ this.searchValue = searchValue ?? ( this.searchValue ?? "" );
16578
16602
  this.content.innerHTML = "";
16579
16603
  this.content.className = `lexassetscontent${ isCompactLayout ? " compact" : ( isListLayout ? " list" : "" ) }`;
16580
16604
  let that = this;
16581
16605
 
16582
- const _addItem = function(item) {
16583
-
16606
+ const _addItem = function( item )
16607
+ {
16584
16608
  const type = item.type.charAt( 0 ).toUpperCase() + item.type.slice( 1 );
16585
16609
  const extension = LX.getExtension( item.id );
16586
16610
  const isFolder = type === "Folder";
@@ -16599,10 +16623,11 @@ class AssetView {
16599
16623
  {
16600
16624
  let desc = document.createElement( 'span' );
16601
16625
  desc.className = 'lexitemdesc';
16602
- desc.innerHTML = "File: " + item.id + "<br>Type: " + type;
16626
+ desc.id = `floatingTitle_${ item.id }`;
16627
+ desc.innerHTML = `File: ${ item.id }<br>Type: ${ type }`;
16603
16628
  that.content.appendChild( desc );
16604
16629
 
16605
- itemEl.addEventListener("mousemove", e => {
16630
+ itemEl.addEventListener( "mousemove", e => {
16606
16631
 
16607
16632
  if( !isGridLayout )
16608
16633
  {
@@ -16630,23 +16655,7 @@ class AssetView {
16630
16655
 
16631
16656
  desc.style.left = ( localOffsetX ) + "px";
16632
16657
  desc.style.top = ( localOffsetY - 36 ) + "px";
16633
- });
16634
-
16635
- itemEl.addEventListener("mouseenter", () => {
16636
- if( isGridLayout )
16637
- {
16638
- desc.style.display = "unset";
16639
- }
16640
- });
16641
-
16642
- itemEl.addEventListener("mouseleave", () => {
16643
- if( isGridLayout )
16644
- {
16645
- setTimeout( () => {
16646
- desc.style.display = "none";
16647
- }, 100 );
16648
- }
16649
- });
16658
+ } );
16650
16659
  }
16651
16660
  else
16652
16661
  {
@@ -16681,26 +16690,49 @@ class AssetView {
16681
16690
 
16682
16691
  if( !that.skipPreview )
16683
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
+
16684
16706
  let preview = null;
16685
- const hasImage = item.src && (['png', 'jpg'].indexOf( LX.getExtension( item.src ) ) > -1 || item.src.includes("data:image/") ); // Support b64 image as src
16686
16707
 
16687
- 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 )
16688
16718
  {
16719
+ const defaultPreviewPath = `${ that.rootPath }images/file.png`;
16720
+ const defaultFolderPath = `${ that.rootPath }images/folder.png`;
16721
+
16689
16722
  preview = document.createElement('img');
16690
- let real_src = item.unknown_extension ? that.rootPath + "images/file.png" : (isFolder ? that.rootPath + "images/folder.png" : item.src);
16691
- 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 );
16692
16725
  itemEl.appendChild( preview );
16693
16726
  }
16694
16727
  else
16695
16728
  {
16696
- preview = document.createElement('svg');
16697
- preview.className = "asset-file-preview";
16698
- itemEl.appendChild(preview);
16729
+ preview = document.createElement( 'svg' );
16730
+ preview.className = 'asset-file-preview';
16731
+ itemEl.appendChild( preview );
16699
16732
 
16700
- let textEl = document.createElement('text');
16701
- preview.appendChild(textEl);
16702
- // If no extension, e.g. Clip, use the type...
16703
- 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 );
16704
16736
 
16705
16737
  var newLength = textEl.innerText.length;
16706
16738
  var charsPerLine = 2.5;
@@ -16710,8 +16742,8 @@ class AssetView {
16710
16742
  if( newEmSize < 1 )
16711
16743
  {
16712
16744
  var newFontSize = newEmSize * textBaseSize;
16713
- textEl.style.fontSize = newFontSize + "px";
16714
- 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)`;
16715
16747
  }
16716
16748
  }
16717
16749
  }
@@ -16725,7 +16757,7 @@ class AssetView {
16725
16757
  if( item.lastModifiedDate ) itemInfoHtml += ` | ${ item.lastModifiedDate }`;
16726
16758
  }
16727
16759
 
16728
- LX.makeContainer( [ "auto", "auto" ], "lexassetinfo", itemInfoHtml, itemEl );
16760
+ LX.makeContainer( [ 'auto', 'auto' ], 'lexassetinfo', itemInfoHtml, itemEl );
16729
16761
 
16730
16762
  itemEl.addEventListener('click', function( e ) {
16731
16763
  e.stopImmediatePropagation();
@@ -16737,10 +16769,10 @@ class AssetView {
16737
16769
  {
16738
16770
  if( !e.shiftKey )
16739
16771
  {
16740
- that.content.querySelectorAll('.lexassetitem').forEach( i => i.classList.remove('selected') );
16772
+ that.content.querySelectorAll( '.lexassetitem').forEach( i => i.classList.remove( 'selected' ) );
16741
16773
  }
16742
16774
 
16743
- this.classList.add('selected');
16775
+ this.classList.add( 'selected' );
16744
16776
  that.selectedItem = item;
16745
16777
 
16746
16778
  if( !that.skipPreview )
@@ -16793,6 +16825,42 @@ class AssetView {
16793
16825
  e.preventDefault();
16794
16826
  }, false );
16795
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
+
16796
16864
  return itemEl;
16797
16865
  };
16798
16866
 
@@ -16937,7 +17005,7 @@ class AssetView {
16937
17005
  item.type = "mesh"; break;
16938
17006
  default:
16939
17007
  item.type = ext;
16940
- item.unknown_extension = true;
17008
+ item.unknownExtension = true;
16941
17009
  break;
16942
17010
  }
16943
17011
 
@@ -17040,8 +17108,8 @@ class AssetView {
17040
17108
  }
17041
17109
  }
17042
17110
 
17043
- LX.AssetView = AssetView;
17044
-
17111
+ LX.AssetView = AssetView;
17112
+
17045
17113
  // tour.js @jxarco
17046
17114
 
17047
17115
  class Tour {
@@ -17339,6 +17407,6 @@ class Tour {
17339
17407
  } );
17340
17408
  }
17341
17409
  }
17342
- LX.Tour = Tour;
17343
-
17344
- 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 };