lexgui 0.7.5 → 0.7.6
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 +69 -14
- package/build/lexgui.css +4 -0
- package/build/lexgui.js +59 -17
- package/build/lexgui.min.css +1 -1
- package/build/lexgui.min.js +1 -1
- package/build/lexgui.module.js +59 -17
- package/build/lexgui.module.min.js +1 -1
- package/changelog.md +16 -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.6",
|
|
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 )
|
|
552
|
+
{
|
|
553
|
+
LX.setTheme( storedcolorScheme );
|
|
554
|
+
}
|
|
555
|
+
else if( this._mqlPrefersDarkScheme && ( options.autoTheme ?? true ) )
|
|
540
556
|
{
|
|
541
|
-
if( window.matchMedia
|
|
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;
|
|
@@ -4971,11 +4986,13 @@ LX.deepCopy = deepCopy;
|
|
|
4971
4986
|
* @method setTheme
|
|
4972
4987
|
* @description Set dark or light theme
|
|
4973
4988
|
* @param {String} colorScheme Name of the scheme
|
|
4989
|
+
* @param {Boolean} storeLocal Store in localStorage
|
|
4974
4990
|
*/
|
|
4975
|
-
function setTheme( colorScheme )
|
|
4991
|
+
function setTheme( colorScheme, storeLocal = true )
|
|
4976
4992
|
{
|
|
4977
4993
|
colorScheme = ( colorScheme == "light" ) ? "light" : "dark";
|
|
4978
4994
|
document.documentElement.setAttribute( "data-theme", colorScheme );
|
|
4995
|
+
if( storeLocal ) localStorage.setItem( "lxColorScheme", colorScheme );
|
|
4979
4996
|
LX.emit( "@on_new_color_scheme", colorScheme );
|
|
4980
4997
|
}
|
|
4981
4998
|
|
|
@@ -5004,6 +5021,26 @@ function switchTheme()
|
|
|
5004
5021
|
|
|
5005
5022
|
LX.switchTheme = switchTheme;
|
|
5006
5023
|
|
|
5024
|
+
/**
|
|
5025
|
+
* @method setSystemTheme
|
|
5026
|
+
* @description Sets back the system theme
|
|
5027
|
+
*/
|
|
5028
|
+
function setSystemTheme()
|
|
5029
|
+
{
|
|
5030
|
+
const currentTheme = ( window.matchMedia && window.matchMedia( "(prefers-color-scheme: light)" ).matches ) ? "light" : "dark";
|
|
5031
|
+
setTheme( currentTheme );
|
|
5032
|
+
localStorage.removeItem( "lxColorScheme" );
|
|
5033
|
+
|
|
5034
|
+
// Reapply listener
|
|
5035
|
+
if( this._mqlPrefersDarkScheme )
|
|
5036
|
+
{
|
|
5037
|
+
this._mqlPrefersDarkScheme.removeEventListener( "change", this._onChangeSystemTheme );
|
|
5038
|
+
this._mqlPrefersDarkScheme.addEventListener( "change", this._onChangeSystemTheme );
|
|
5039
|
+
}
|
|
5040
|
+
}
|
|
5041
|
+
|
|
5042
|
+
LX.setSystemTheme = setSystemTheme;
|
|
5043
|
+
|
|
5007
5044
|
/**
|
|
5008
5045
|
* @method setThemeColor
|
|
5009
5046
|
* @description Sets a new value for one of the main theme variables
|
|
@@ -8986,7 +9023,7 @@ class TextInput extends BaseComponent {
|
|
|
8986
9023
|
|
|
8987
9024
|
this.valid = ( v ) => {
|
|
8988
9025
|
v = v ?? this.value();
|
|
8989
|
-
if(
|
|
9026
|
+
if( ( wValue.pattern ?? "" ) == "" ) return true;
|
|
8990
9027
|
const regexp = new RegExp( wValue.pattern );
|
|
8991
9028
|
return regexp.test( v );
|
|
8992
9029
|
};
|
|
@@ -9725,19 +9762,21 @@ class Form extends BaseComponent {
|
|
|
9725
9762
|
|
|
9726
9763
|
const primaryButton = new LX.Button( null, options.primaryActionName ?? "Submit", ( value, event ) => {
|
|
9727
9764
|
|
|
9765
|
+
const errors = [];
|
|
9766
|
+
|
|
9728
9767
|
for( let entry in data )
|
|
9729
9768
|
{
|
|
9730
9769
|
let entryData = data[ entry ];
|
|
9731
9770
|
|
|
9732
9771
|
if( !entryData.textComponent.valid() )
|
|
9733
9772
|
{
|
|
9734
|
-
|
|
9773
|
+
errors.push( { type: "input_not_valid", entry } );
|
|
9735
9774
|
}
|
|
9736
9775
|
}
|
|
9737
9776
|
|
|
9738
9777
|
if( callback )
|
|
9739
9778
|
{
|
|
9740
|
-
callback( container.formData, event );
|
|
9779
|
+
callback( container.formData, errors, event );
|
|
9741
9780
|
}
|
|
9742
9781
|
}, { width: "100%", minWidth: "0", buttonClass: options.primaryButtonClass ?? "contrast" } );
|
|
9743
9782
|
|
|
@@ -15942,8 +15981,7 @@ class Sidebar {
|
|
|
15942
15981
|
return;
|
|
15943
15982
|
}
|
|
15944
15983
|
|
|
15945
|
-
|
|
15946
|
-
if( f ) f.call( this, key, item.value, e );
|
|
15984
|
+
let value = undefined;
|
|
15947
15985
|
|
|
15948
15986
|
if( isCollapsable )
|
|
15949
15987
|
{
|
|
@@ -15953,14 +15991,18 @@ class Sidebar {
|
|
|
15953
15991
|
{
|
|
15954
15992
|
item.value = !item.value;
|
|
15955
15993
|
item.checkbox.set( item.value, true );
|
|
15994
|
+
value = item.value;
|
|
15956
15995
|
}
|
|
15957
|
-
|
|
15958
|
-
if( options.swap && !( e.target instanceof HTMLInputElement ) )
|
|
15996
|
+
else if( options.swap && !( e.target instanceof HTMLInputElement ) )
|
|
15959
15997
|
{
|
|
15960
15998
|
const swapInput = itemDom.querySelector( "input" );
|
|
15961
15999
|
swapInput.checked = !swapInput.checked;
|
|
16000
|
+
value = swapInput.checked;
|
|
15962
16001
|
}
|
|
15963
16002
|
|
|
16003
|
+
const f = options.callback;
|
|
16004
|
+
if( f ) f.call( this, key, value ?? entry, e );
|
|
16005
|
+
|
|
15964
16006
|
// Manage selected
|
|
15965
16007
|
if( this.displaySelected && !options.skipSelection )
|
|
15966
16008
|
{
|