lexgui 0.7.5 → 0.7.7
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.
- package/build/extensions/codeeditor.js +305 -86
- package/build/extensions/timeline.js +40 -12
- package/build/lexgui.css +4 -1
- package/build/lexgui.js +67 -22
- package/build/lexgui.min.css +2 -2
- package/build/lexgui.min.js +1 -1
- package/build/lexgui.module.js +67 -22
- package/build/lexgui.module.min.js +1 -1
- package/changelog.md +43 -1
- package/examples/code-editor.html +1 -1
- package/package.json +1 -1
package/build/lexgui.module.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
const LX = {
|
|
10
|
-
version: "0.7.
|
|
10
|
+
version: "0.7.7",
|
|
11
11
|
ready: false,
|
|
12
12
|
extensions: [], // Store extensions used
|
|
13
13
|
signals: {}, // Events and triggers
|
|
@@ -536,16 +536,30 @@ async function init( options = { } )
|
|
|
536
536
|
this.main_area = new LX.Area( { id: options.id ?? 'mainarea' } );
|
|
537
537
|
}
|
|
538
538
|
|
|
539
|
-
|
|
539
|
+
// Initial or automatic changes don't force color scheme
|
|
540
|
+
// to be stored in localStorage
|
|
541
|
+
|
|
542
|
+
this._onChangeSystemTheme = function( event ) {
|
|
543
|
+
const storedcolorScheme = localStorage.getItem( "lxColorScheme" );
|
|
544
|
+
if( storedcolorScheme ) return;
|
|
545
|
+
LX.setTheme( event.matches ? "dark" : "light", false );
|
|
546
|
+
};
|
|
547
|
+
|
|
548
|
+
this._mqlPrefersDarkScheme = window.matchMedia ? window.matchMedia("(prefers-color-scheme: dark)") : null;
|
|
549
|
+
|
|
550
|
+
const storedcolorScheme = localStorage.getItem( "lxColorScheme" );
|
|
551
|
+
if( storedcolorScheme )
|
|
540
552
|
{
|
|
541
|
-
|
|
553
|
+
LX.setTheme( storedcolorScheme );
|
|
554
|
+
}
|
|
555
|
+
else if( this._mqlPrefersDarkScheme && ( options.autoTheme ?? true ) )
|
|
556
|
+
{
|
|
557
|
+
if( window.matchMedia( "(prefers-color-scheme: light)" ).matches )
|
|
542
558
|
{
|
|
543
|
-
LX.setTheme( "light" );
|
|
559
|
+
LX.setTheme( "light", false );
|
|
544
560
|
}
|
|
545
561
|
|
|
546
|
-
|
|
547
|
-
LX.setTheme( event.matches ? "dark" : "light" );
|
|
548
|
-
});
|
|
562
|
+
this._mqlPrefersDarkScheme.addEventListener( "change", this._onChangeSystemTheme );
|
|
549
563
|
}
|
|
550
564
|
|
|
551
565
|
return this.main_area;
|
|
@@ -2545,8 +2559,9 @@ class Tabs {
|
|
|
2545
2559
|
});
|
|
2546
2560
|
|
|
2547
2561
|
// Attach content
|
|
2548
|
-
|
|
2549
|
-
this.root.
|
|
2562
|
+
const indexOffset = options.indexOffset ?? -1;
|
|
2563
|
+
tabEl.childIndex = ( this.root.childElementCount + indexOffset );
|
|
2564
|
+
this.root.insertChildAtIndex( tabEl, tabEl.childIndex + 1 );
|
|
2550
2565
|
this.area.attach( contentEl );
|
|
2551
2566
|
this.tabDOMs[ name ] = tabEl;
|
|
2552
2567
|
this.tabs[ name ] = content;
|
|
@@ -3108,6 +3123,7 @@ class ContextMenu {
|
|
|
3108
3123
|
}
|
|
3109
3124
|
else if( (rect.top + rect.height) > window.innerHeight )
|
|
3110
3125
|
{
|
|
3126
|
+
div.style.marginTop = "";
|
|
3111
3127
|
top = (window.innerHeight - rect.height - margin);
|
|
3112
3128
|
}
|
|
3113
3129
|
}
|
|
@@ -4971,11 +4987,13 @@ LX.deepCopy = deepCopy;
|
|
|
4971
4987
|
* @method setTheme
|
|
4972
4988
|
* @description Set dark or light theme
|
|
4973
4989
|
* @param {String} colorScheme Name of the scheme
|
|
4990
|
+
* @param {Boolean} storeLocal Store in localStorage
|
|
4974
4991
|
*/
|
|
4975
|
-
function setTheme( colorScheme )
|
|
4992
|
+
function setTheme( colorScheme, storeLocal = true )
|
|
4976
4993
|
{
|
|
4977
4994
|
colorScheme = ( colorScheme == "light" ) ? "light" : "dark";
|
|
4978
4995
|
document.documentElement.setAttribute( "data-theme", colorScheme );
|
|
4996
|
+
if( storeLocal ) localStorage.setItem( "lxColorScheme", colorScheme );
|
|
4979
4997
|
LX.emit( "@on_new_color_scheme", colorScheme );
|
|
4980
4998
|
}
|
|
4981
4999
|
|
|
@@ -5004,6 +5022,26 @@ function switchTheme()
|
|
|
5004
5022
|
|
|
5005
5023
|
LX.switchTheme = switchTheme;
|
|
5006
5024
|
|
|
5025
|
+
/**
|
|
5026
|
+
* @method setSystemTheme
|
|
5027
|
+
* @description Sets back the system theme
|
|
5028
|
+
*/
|
|
5029
|
+
function setSystemTheme()
|
|
5030
|
+
{
|
|
5031
|
+
const currentTheme = ( window.matchMedia && window.matchMedia( "(prefers-color-scheme: light)" ).matches ) ? "light" : "dark";
|
|
5032
|
+
setTheme( currentTheme );
|
|
5033
|
+
localStorage.removeItem( "lxColorScheme" );
|
|
5034
|
+
|
|
5035
|
+
// Reapply listener
|
|
5036
|
+
if( this._mqlPrefersDarkScheme )
|
|
5037
|
+
{
|
|
5038
|
+
this._mqlPrefersDarkScheme.removeEventListener( "change", this._onChangeSystemTheme );
|
|
5039
|
+
this._mqlPrefersDarkScheme.addEventListener( "change", this._onChangeSystemTheme );
|
|
5040
|
+
}
|
|
5041
|
+
}
|
|
5042
|
+
|
|
5043
|
+
LX.setSystemTheme = setSystemTheme;
|
|
5044
|
+
|
|
5007
5045
|
/**
|
|
5008
5046
|
* @method setThemeColor
|
|
5009
5047
|
* @description Sets a new value for one of the main theme variables
|
|
@@ -8986,7 +9024,7 @@ class TextInput extends BaseComponent {
|
|
|
8986
9024
|
|
|
8987
9025
|
this.valid = ( v ) => {
|
|
8988
9026
|
v = v ?? this.value();
|
|
8989
|
-
if(
|
|
9027
|
+
if( ( wValue.pattern ?? "" ) == "" ) return true;
|
|
8990
9028
|
const regexp = new RegExp( wValue.pattern );
|
|
8991
9029
|
return regexp.test( v );
|
|
8992
9030
|
};
|
|
@@ -9725,19 +9763,21 @@ class Form extends BaseComponent {
|
|
|
9725
9763
|
|
|
9726
9764
|
const primaryButton = new LX.Button( null, options.primaryActionName ?? "Submit", ( value, event ) => {
|
|
9727
9765
|
|
|
9766
|
+
const errors = [];
|
|
9767
|
+
|
|
9728
9768
|
for( let entry in data )
|
|
9729
9769
|
{
|
|
9730
9770
|
let entryData = data[ entry ];
|
|
9731
9771
|
|
|
9732
9772
|
if( !entryData.textComponent.valid() )
|
|
9733
9773
|
{
|
|
9734
|
-
|
|
9774
|
+
errors.push( { type: "input_not_valid", entry } );
|
|
9735
9775
|
}
|
|
9736
9776
|
}
|
|
9737
9777
|
|
|
9738
9778
|
if( callback )
|
|
9739
9779
|
{
|
|
9740
|
-
callback( container.formData, event );
|
|
9780
|
+
callback( container.formData, errors, event );
|
|
9741
9781
|
}
|
|
9742
9782
|
}, { width: "100%", minWidth: "0", buttonClass: options.primaryButtonClass ?? "contrast" } );
|
|
9743
9783
|
|
|
@@ -11176,7 +11216,7 @@ class RangeInput extends BaseComponent {
|
|
|
11176
11216
|
container.appendChild( slider );
|
|
11177
11217
|
|
|
11178
11218
|
slider.addEventListener( "input", e => {
|
|
11179
|
-
this.set( isRangeValue ? [ e.target.valueAsNumber, ogValue[ 1 ] ] : e.target.valueAsNumber, false, e );
|
|
11219
|
+
this.set( isRangeValue ? [ Math.min(e.target.valueAsNumber, ogValue[ 1 ]), ogValue[ 1 ] ] : e.target.valueAsNumber, false, e );
|
|
11180
11220
|
}, { passive: false });
|
|
11181
11221
|
|
|
11182
11222
|
// If its a range value, we need to update the slider using the thumbs
|
|
@@ -11242,7 +11282,7 @@ class RangeInput extends BaseComponent {
|
|
|
11242
11282
|
container.appendChild( maxSlider );
|
|
11243
11283
|
|
|
11244
11284
|
maxSlider.addEventListener( "input", e => {
|
|
11245
|
-
ogValue[ 1 ] = +e.target.valueAsNumber;
|
|
11285
|
+
ogValue[ 1 ] = Math.max(value, +e.target.valueAsNumber);
|
|
11246
11286
|
this.set( [ value, ogValue[ 1 ] ], false, e );
|
|
11247
11287
|
}, { passive: false });
|
|
11248
11288
|
}
|
|
@@ -15942,8 +15982,7 @@ class Sidebar {
|
|
|
15942
15982
|
return;
|
|
15943
15983
|
}
|
|
15944
15984
|
|
|
15945
|
-
|
|
15946
|
-
if( f ) f.call( this, key, item.value, e );
|
|
15985
|
+
let value = undefined;
|
|
15947
15986
|
|
|
15948
15987
|
if( isCollapsable )
|
|
15949
15988
|
{
|
|
@@ -15953,14 +15992,18 @@ class Sidebar {
|
|
|
15953
15992
|
{
|
|
15954
15993
|
item.value = !item.value;
|
|
15955
15994
|
item.checkbox.set( item.value, true );
|
|
15995
|
+
value = item.value;
|
|
15956
15996
|
}
|
|
15957
|
-
|
|
15958
|
-
if( options.swap && !( e.target instanceof HTMLInputElement ) )
|
|
15997
|
+
else if( options.swap && !( e.target instanceof HTMLInputElement ) )
|
|
15959
15998
|
{
|
|
15960
15999
|
const swapInput = itemDom.querySelector( "input" );
|
|
15961
16000
|
swapInput.checked = !swapInput.checked;
|
|
16001
|
+
value = swapInput.checked;
|
|
15962
16002
|
}
|
|
15963
16003
|
|
|
16004
|
+
const f = options.callback;
|
|
16005
|
+
if( f ) f.call( this, key, value ?? entry, e );
|
|
16006
|
+
|
|
15964
16007
|
// Manage selected
|
|
15965
16008
|
if( this.displaySelected && !options.skipSelection )
|
|
15966
16009
|
{
|
|
@@ -16378,7 +16421,7 @@ class AssetView {
|
|
|
16378
16421
|
}
|
|
16379
16422
|
else
|
|
16380
16423
|
{
|
|
16381
|
-
this.toolsPanel = area.addPanel({ className: 'flex flex-col overflow-hidden' });
|
|
16424
|
+
this.toolsPanel = area.addPanel({ className: 'flex flex-col overflow-hidden', height:"auto" });
|
|
16382
16425
|
this.contentPanel = area.addPanel({ className: 'lexassetcontentpanel flex flex-col overflow-hidden' });
|
|
16383
16426
|
}
|
|
16384
16427
|
|
|
@@ -16431,9 +16474,11 @@ class AssetView {
|
|
|
16431
16474
|
this.toolsPanel.addText(null, textString, null, {
|
|
16432
16475
|
inputClass: "nobg", disabled: true, signal: "@on_page_change", maxWidth: "16ch" }
|
|
16433
16476
|
);
|
|
16477
|
+
this.toolsPanel.endLine();
|
|
16434
16478
|
|
|
16435
16479
|
if( !this.skipBrowser )
|
|
16436
16480
|
{
|
|
16481
|
+
this.toolsPanel.sameLine();
|
|
16437
16482
|
this.toolsPanel.addComboButtons( null, [
|
|
16438
16483
|
{
|
|
16439
16484
|
value: "Left",
|
|
@@ -16468,9 +16513,9 @@ class AssetView {
|
|
|
16468
16513
|
inputClass: "nobg", disabled: true, signal: "@on_folder_change",
|
|
16469
16514
|
style: { fontWeight: "600", fontSize: "15px" }
|
|
16470
16515
|
});
|
|
16471
|
-
}
|
|
16472
16516
|
|
|
16473
|
-
|
|
16517
|
+
this.toolsPanel.endLine();
|
|
16518
|
+
}
|
|
16474
16519
|
};
|
|
16475
16520
|
|
|
16476
16521
|
this.toolsPanel.refresh();
|