lexgui 0.1.12 → 0.1.14

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/lexgui.js CHANGED
@@ -12,7 +12,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
12
12
  */
13
13
 
14
14
  var LX = global.LX = {
15
- version: "0.1.12",
15
+ version: "0.1.14",
16
16
  ready: false,
17
17
  components: [], // specific pre-build components
18
18
  signals: {} // events and triggers
@@ -2883,9 +2883,11 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
2883
2883
  // Create new branch
2884
2884
  var branch = new Branch(name, options);
2885
2885
  branch.panel = this;
2886
+
2886
2887
  // Declare new open
2887
2888
  this.branch_open = true;
2888
2889
  this.current_branch = branch;
2890
+
2889
2891
  // Append to panel
2890
2892
  if(this.branches.length == 0)
2891
2893
  branch.root.classList.add('first');
@@ -2899,7 +2901,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
2899
2901
 
2900
2902
  // Add widget filter
2901
2903
  if(options.filter) {
2902
- this._add_filter( options.filter, {callback: this._search_widgets.bind(this, branch.name)} );
2904
+ this._addFilter( options.filter, {callback: this._searchWidgets.bind(this, branch.name)} );
2903
2905
  }
2904
2906
 
2905
2907
  return branch;
@@ -3051,7 +3053,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
3051
3053
  return widget;
3052
3054
  }
3053
3055
 
3054
- _add_filter( placeholder, options = {} ) {
3056
+ _addFilter( placeholder, options = {} ) {
3055
3057
 
3056
3058
  options.placeholder = placeholder.constructor == String ? placeholder : "Filter properties..";
3057
3059
  options.skipWidget = options.skipWidget ?? true;
@@ -3080,7 +3082,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
3080
3082
  return element;
3081
3083
  }
3082
3084
 
3083
- _search_widgets(branchName, value) {
3085
+ _searchWidgets(branchName, value) {
3084
3086
 
3085
3087
  for( let b of this.branches ) {
3086
3088
 
@@ -3474,7 +3476,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
3474
3476
  // Update height depending on the content
3475
3477
  wValue.style.height = wValue.scrollHeight + "px";
3476
3478
  }
3477
- }, 100);
3479
+ }, 10);
3478
3480
 
3479
3481
  return widget;
3480
3482
  }
@@ -3824,7 +3826,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
3824
3826
  // Add filter options
3825
3827
  let filter = null;
3826
3828
  if(options.filter ?? false)
3827
- filter = this._add_filter("Search option", {container: list, callback: this._search_options.bind(list, values)});
3829
+ filter = this._addFilter("Search option", {container: list, callback: this._search_options.bind(list, values)});
3828
3830
 
3829
3831
  // Create option list to empty it easily..
3830
3832
  const list_options = document.createElement('span');
@@ -3835,6 +3837,8 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
3835
3837
  list_options.style.height = "calc(100% - 25px)";
3836
3838
 
3837
3839
  filter.addEventListener('focusout', function(e) {
3840
+ if (e.relatedTarget && e.relatedTarget.tagName == "UL" && e.relatedTarget.classList.contains("lexoptions"))
3841
+ return;
3838
3842
  list.toggleAttribute('hidden', true);
3839
3843
  });
3840
3844
  }
@@ -4636,8 +4640,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
4636
4640
  slider.value = value;
4637
4641
  slider.addEventListener("input", function(e) {
4638
4642
  let new_value = +this.valueAsNumber;
4639
- let fract = new_value % 1;
4640
- vecinput.value = Math.trunc(new_value) + (+fract.toPrecision(5));
4643
+ vecinput.value = (+new_value).toFixed(4).replace(/([0-9]+(\.[0-9]+[1-9])?)(\.?0+$)/,'$1');
4641
4644
  Panel._dispatch_event(vecinput, "change");
4642
4645
  }, false);
4643
4646
  box.appendChild(slider);
@@ -4653,8 +4656,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
4653
4656
  if(e.shiftKey) mult *= 10;
4654
4657
  else if(e.altKey) mult *= 0.1;
4655
4658
  let new_value = (+this.valueAsNumber - mult * (e.deltaY > 0 ? 1 : -1));
4656
- let fract = new_value % 1;
4657
- this.value = Math.trunc(new_value) + (+fract.toPrecision(5));
4659
+ this.value = (+new_value).toFixed(4).replace(/([0-9]+(\.[0-9]+[1-9])?)(\.?0+$)/,'$1');
4658
4660
  Panel._dispatch_event(vecinput, "change");
4659
4661
  }, {passive:false});
4660
4662
 
@@ -4697,8 +4699,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
4697
4699
  if(e.shiftKey) mult *= 10;
4698
4700
  else if(e.altKey) mult *= 0.1;
4699
4701
  let new_value = (+vecinput.valueAsNumber + mult * dt);
4700
- let fract = new_value % 1;
4701
- vecinput.value = Math.trunc(new_value) + (+fract.toPrecision(5));
4702
+ vecinput.value = (+new_value).toFixed(4).replace(/([0-9]+(\.[0-9]+[1-9])?)(\.?0+$)/,'$1');
4702
4703
  Panel._dispatch_event(vecinput, "change");
4703
4704
  }
4704
4705
 
@@ -5312,11 +5313,13 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
5312
5313
 
5313
5314
  this._addBranchSeparator();
5314
5315
 
5315
- if(options.closed) {
5316
+ if( options.closed ) {
5316
5317
  title.className += " closed";
5317
5318
  root.className += " closed";
5318
- this.content.setAttribute('hidden', true);
5319
5319
  this.grabber.setAttribute('hidden', true);
5320
+ doAsync( () => {
5321
+ this.content.setAttribute('hidden', true);
5322
+ }, 15);
5320
5323
  }
5321
5324
 
5322
5325
  this.onclick = function(e){
@@ -5842,7 +5845,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
5842
5845
  const hasSubmenu = o[ k ].length;
5843
5846
  let entry = document.createElement('div');
5844
5847
  entry.className = "lexcontextmenuentry" + (o[ 'className' ] ? " " + o[ 'className' ] : "" );
5845
- entry.id = o.id ?? ("eId" + k.replace(/\s/g, '').replace('@', '_'));
5848
+ entry.id = o.id ?? ("eId" + this._getSupportedDOMName( k ));
5846
5849
  entry.innerHTML = "";
5847
5850
  const icon = o[ 'icon' ];
5848
5851
  if(icon) {
@@ -5989,7 +5992,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
5989
5992
  for( let item of this.items )
5990
5993
  {
5991
5994
  let key = Object.keys(item)[0];
5992
- let pKey = "eId" + key.replace(/\s/g, '').replace('@', '_');
5995
+ let pKey = "eId" + this._getSupportedDOMName( key );
5993
5996
 
5994
5997
  // Item already created
5995
5998
  const id = "#" + (item.id ?? pKey);
@@ -6005,7 +6008,10 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
6005
6008
 
6006
6009
  this.colors[ token ] = color;
6007
6010
  }
6008
-
6011
+
6012
+ _getSupportedDOMName( key ) {
6013
+ return key.replace(/\s/g, '').replaceAll('@', '_').replaceAll('+', '_plus_');
6014
+ }
6009
6015
  };
6010
6016
 
6011
6017
  LX.ContextMenu = ContextMenu;
@@ -6415,6 +6421,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
6415
6421
  this.skip_preview = options.skip_preview ?? false;
6416
6422
  this.only_folders = options.only_folders ?? true;
6417
6423
  this.preview_actions = options.preview_actions ?? [];
6424
+ this.context_menu = options.context_menu ?? [];
6418
6425
 
6419
6426
  if( !this.skip_browser )
6420
6427
  {
@@ -6801,23 +6808,26 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
6801
6808
  }
6802
6809
  });
6803
6810
 
6804
- itemEl.addEventListener('contextmenu', function(e) {
6805
- e.preventDefault();
6806
-
6807
- const multiple = that.content.querySelectorAll('.selected').length;
6808
-
6809
- LX.addContextMenu( multiple > 1 ? (multiple + " selected") :
6810
- is_folder ? item.id : item.type, e, m => {
6811
- if(multiple <= 1)
6812
- m.add("Rename");
6813
- if( !is_folder )
6814
- m.add("Clone", that._cloneItem.bind(that, item));
6815
- if(multiple <= 1)
6816
- m.add("Properties");
6817
- m.add("");
6818
- m.add("Delete", that._deleteItem.bind(that, item));
6811
+ if( that.context_menu )
6812
+ {
6813
+ itemEl.addEventListener('contextmenu', function(e) {
6814
+ e.preventDefault();
6815
+
6816
+ const multiple = that.content.querySelectorAll('.selected').length;
6817
+
6818
+ LX.addContextMenu( multiple > 1 ? (multiple + " selected") :
6819
+ is_folder ? item.id : item.type, e, m => {
6820
+ if(multiple <= 1)
6821
+ m.add("Rename");
6822
+ if( !is_folder )
6823
+ m.add("Clone", that._clone_item.bind(that, item));
6824
+ if(multiple <= 1)
6825
+ m.add("Properties");
6826
+ m.add("");
6827
+ m.add("Delete", that._delete_item.bind(that, item));
6828
+ });
6819
6829
  });
6820
- });
6830
+ }
6821
6831
 
6822
6832
  itemEl.addEventListener("dragstart", function(e) {
6823
6833
  e.preventDefault();
@@ -8,7 +8,7 @@
8
8
  */
9
9
 
10
10
  var LX = {
11
- version: "0.1.12",
11
+ version: "0.1.14",
12
12
  ready: false,
13
13
  components: [], // specific pre-build components
14
14
  signals: {} // events and triggers
@@ -2879,9 +2879,11 @@ class Panel {
2879
2879
  // Create new branch
2880
2880
  var branch = new Branch(name, options);
2881
2881
  branch.panel = this;
2882
+
2882
2883
  // Declare new open
2883
2884
  this.branch_open = true;
2884
2885
  this.current_branch = branch;
2886
+
2885
2887
  // Append to panel
2886
2888
  if(this.branches.length == 0)
2887
2889
  branch.root.classList.add('first');
@@ -2895,7 +2897,7 @@ class Panel {
2895
2897
 
2896
2898
  // Add widget filter
2897
2899
  if(options.filter) {
2898
- this._add_filter( options.filter, {callback: this._search_widgets.bind(this, branch.name)} );
2900
+ this._addFilter( options.filter, {callback: this._searchWidgets.bind(this, branch.name)} );
2899
2901
  }
2900
2902
 
2901
2903
  return branch;
@@ -3047,7 +3049,7 @@ class Panel {
3047
3049
  return widget;
3048
3050
  }
3049
3051
 
3050
- _add_filter( placeholder, options = {} ) {
3052
+ _addFilter( placeholder, options = {} ) {
3051
3053
 
3052
3054
  options.placeholder = placeholder.constructor == String ? placeholder : "Filter properties..";
3053
3055
  options.skipWidget = options.skipWidget ?? true;
@@ -3076,7 +3078,7 @@ class Panel {
3076
3078
  return element;
3077
3079
  }
3078
3080
 
3079
- _search_widgets(branchName, value) {
3081
+ _searchWidgets(branchName, value) {
3080
3082
 
3081
3083
  for( let b of this.branches ) {
3082
3084
 
@@ -3470,7 +3472,7 @@ class Panel {
3470
3472
  // Update height depending on the content
3471
3473
  wValue.style.height = wValue.scrollHeight + "px";
3472
3474
  }
3473
- }, 100);
3475
+ }, 10);
3474
3476
 
3475
3477
  return widget;
3476
3478
  }
@@ -3820,7 +3822,7 @@ class Panel {
3820
3822
  // Add filter options
3821
3823
  let filter = null;
3822
3824
  if(options.filter ?? false)
3823
- filter = this._add_filter("Search option", {container: list, callback: this._search_options.bind(list, values)});
3825
+ filter = this._addFilter("Search option", {container: list, callback: this._search_options.bind(list, values)});
3824
3826
 
3825
3827
  // Create option list to empty it easily..
3826
3828
  const list_options = document.createElement('span');
@@ -3831,6 +3833,8 @@ class Panel {
3831
3833
  list_options.style.height = "calc(100% - 25px)";
3832
3834
 
3833
3835
  filter.addEventListener('focusout', function(e) {
3836
+ if (e.relatedTarget && e.relatedTarget.tagName == "UL" && e.relatedTarget.classList.contains("lexoptions"))
3837
+ return;
3834
3838
  list.toggleAttribute('hidden', true);
3835
3839
  });
3836
3840
  }
@@ -4632,8 +4636,7 @@ class Panel {
4632
4636
  slider.value = value;
4633
4637
  slider.addEventListener("input", function(e) {
4634
4638
  let new_value = +this.valueAsNumber;
4635
- let fract = new_value % 1;
4636
- vecinput.value = Math.trunc(new_value) + (+fract.toPrecision(5));
4639
+ vecinput.value = (+new_value).toFixed(4).replace(/([0-9]+(\.[0-9]+[1-9])?)(\.?0+$)/,'$1');
4637
4640
  Panel._dispatch_event(vecinput, "change");
4638
4641
  }, false);
4639
4642
  box.appendChild(slider);
@@ -4649,8 +4652,7 @@ class Panel {
4649
4652
  if(e.shiftKey) mult *= 10;
4650
4653
  else if(e.altKey) mult *= 0.1;
4651
4654
  let new_value = (+this.valueAsNumber - mult * (e.deltaY > 0 ? 1 : -1));
4652
- let fract = new_value % 1;
4653
- this.value = Math.trunc(new_value) + (+fract.toPrecision(5));
4655
+ this.value = (+new_value).toFixed(4).replace(/([0-9]+(\.[0-9]+[1-9])?)(\.?0+$)/,'$1');
4654
4656
  Panel._dispatch_event(vecinput, "change");
4655
4657
  }, {passive:false});
4656
4658
 
@@ -4693,8 +4695,7 @@ class Panel {
4693
4695
  if(e.shiftKey) mult *= 10;
4694
4696
  else if(e.altKey) mult *= 0.1;
4695
4697
  let new_value = (+vecinput.valueAsNumber + mult * dt);
4696
- let fract = new_value % 1;
4697
- vecinput.value = Math.trunc(new_value) + (+fract.toPrecision(5));
4698
+ vecinput.value = (+new_value).toFixed(4).replace(/([0-9]+(\.[0-9]+[1-9])?)(\.?0+$)/,'$1');
4698
4699
  Panel._dispatch_event(vecinput, "change");
4699
4700
  }
4700
4701
 
@@ -5308,11 +5309,13 @@ class Branch {
5308
5309
 
5309
5310
  this._addBranchSeparator();
5310
5311
 
5311
- if(options.closed) {
5312
+ if( options.closed ) {
5312
5313
  title.className += " closed";
5313
5314
  root.className += " closed";
5314
- this.content.setAttribute('hidden', true);
5315
5315
  this.grabber.setAttribute('hidden', true);
5316
+ doAsync( () => {
5317
+ this.content.setAttribute('hidden', true);
5318
+ }, 15);
5316
5319
  }
5317
5320
 
5318
5321
  this.onclick = function(e){
@@ -5838,7 +5841,7 @@ class ContextMenu {
5838
5841
  const hasSubmenu = o[ k ].length;
5839
5842
  let entry = document.createElement('div');
5840
5843
  entry.className = "lexcontextmenuentry" + (o[ 'className' ] ? " " + o[ 'className' ] : "" );
5841
- entry.id = o.id ?? ("eId" + k.replace(/\s/g, '').replace('@', '_'));
5844
+ entry.id = o.id ?? ("eId" + this._getSupportedDOMName( k ));
5842
5845
  entry.innerHTML = "";
5843
5846
  const icon = o[ 'icon' ];
5844
5847
  if(icon) {
@@ -5985,7 +5988,7 @@ class ContextMenu {
5985
5988
  for( let item of this.items )
5986
5989
  {
5987
5990
  let key = Object.keys(item)[0];
5988
- let pKey = "eId" + key.replace(/\s/g, '').replace('@', '_');
5991
+ let pKey = "eId" + this._getSupportedDOMName( key );
5989
5992
 
5990
5993
  // Item already created
5991
5994
  const id = "#" + (item.id ?? pKey);
@@ -6001,7 +6004,11 @@ class ContextMenu {
6001
6004
 
6002
6005
  this.colors[ token ] = color;
6003
6006
  }
6004
-
6007
+
6008
+ _getSupportedDOMName( key ) {
6009
+ return key.replace(/\s/g, '').replaceAll('@', '_').replaceAll('+', '_plus_');
6010
+ }
6011
+
6005
6012
  };
6006
6013
 
6007
6014
  LX.ContextMenu = ContextMenu;
@@ -6411,6 +6418,7 @@ class AssetView {
6411
6418
  this.skip_preview = options.skip_preview ?? false;
6412
6419
  this.only_folders = options.only_folders ?? true;
6413
6420
  this.preview_actions = options.preview_actions ?? [];
6421
+ this.context_menu = options.context_menu ?? [];
6414
6422
 
6415
6423
  if( !this.skip_browser )
6416
6424
  {
@@ -6797,23 +6805,26 @@ class AssetView {
6797
6805
  }
6798
6806
  });
6799
6807
 
6800
- itemEl.addEventListener('contextmenu', function(e) {
6801
- e.preventDefault();
6808
+ if( that.context_menu )
6809
+ {
6810
+ itemEl.addEventListener('contextmenu', function(e) {
6811
+ e.preventDefault();
6802
6812
 
6803
- const multiple = that.content.querySelectorAll('.selected').length;
6804
-
6805
- LX.addContextMenu( multiple > 1 ? (multiple + " selected") :
6806
- is_folder ? item.id : item.type, e, m => {
6807
- if(multiple <= 1)
6808
- m.add("Rename");
6809
- if( !is_folder )
6810
- m.add("Clone", that._cloneItem.bind(that, item));
6811
- if(multiple <= 1)
6812
- m.add("Properties");
6813
- m.add("");
6814
- m.add("Delete", that._deleteItem.bind(that, item));
6813
+ const multiple = that.content.querySelectorAll('.selected').length;
6814
+
6815
+ LX.addContextMenu( multiple > 1 ? (multiple + " selected") :
6816
+ is_folder ? item.id : item.type, e, m => {
6817
+ if(multiple <= 1)
6818
+ m.add("Rename");
6819
+ if( !is_folder )
6820
+ m.add("Clone", that._clone_item.bind(that, item));
6821
+ if(multiple <= 1)
6822
+ m.add("Properties");
6823
+ m.add("");
6824
+ m.add("Delete", that._delete_item.bind(that, item));
6825
+ });
6815
6826
  });
6816
- });
6827
+ }
6817
6828
 
6818
6829
  itemEl.addEventListener("dragstart", function(e) {
6819
6830
  e.preventDefault();
package/demo.js CHANGED
@@ -693,6 +693,9 @@ function fillBottomPanel( panel ) {
693
693
  panel.addText("Serial number", "194E283DD", (value, event) => {
694
694
  console.log(value);
695
695
  });
696
+
697
+ panel.addNumber( "Decimal Point", 1, null, { min: 0, max: 2, step: 0.001 } )
698
+
696
699
  panel.addTextArea("Notes", "", (value, event) => {
697
700
  console.log(value);
698
701
  }, { placeholder: 'Some notes...' });
@@ -43,12 +43,14 @@
43
43
 
44
44
  let editor = new LX.CodeEditor(rightArea, {
45
45
  // allow_add_scripts: false,
46
- // autocomplete: false
46
+ // autocomplete: false,
47
+ // disable_edition: true
47
48
  });
48
49
 
49
50
  editor.loadFile( "../data/test.json" );
50
51
  editor.loadFile( "../data/style.css" );
51
52
  editor.loadFile( "../data/script.js" );
53
+ editor.loadFile( "../data/engine.cpp" );
52
54
 
53
55
  var ctx = canvas.getContext("2d");
54
56
  ctx.fillStyle = "#b7a9b1";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lexgui",
3
- "version": "0.1.12",
3
+ "version": "0.1.14",
4
4
  "description": "JS library to create web graphical user interfaces",
5
5
  "type": "module",
6
6
  "main": "./build/lexgui.js",