lexgui 0.1.13 → 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.13",
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');
@@ -4638,8 +4640,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
4638
4640
  slider.value = value;
4639
4641
  slider.addEventListener("input", function(e) {
4640
4642
  let new_value = +this.valueAsNumber;
4641
- let fract = new_value % 1;
4642
- 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');
4643
4644
  Panel._dispatch_event(vecinput, "change");
4644
4645
  }, false);
4645
4646
  box.appendChild(slider);
@@ -4655,8 +4656,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
4655
4656
  if(e.shiftKey) mult *= 10;
4656
4657
  else if(e.altKey) mult *= 0.1;
4657
4658
  let new_value = (+this.valueAsNumber - mult * (e.deltaY > 0 ? 1 : -1));
4658
- let fract = new_value % 1;
4659
- 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');
4660
4660
  Panel._dispatch_event(vecinput, "change");
4661
4661
  }, {passive:false});
4662
4662
 
@@ -4699,8 +4699,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
4699
4699
  if(e.shiftKey) mult *= 10;
4700
4700
  else if(e.altKey) mult *= 0.1;
4701
4701
  let new_value = (+vecinput.valueAsNumber + mult * dt);
4702
- let fract = new_value % 1;
4703
- 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');
4704
4703
  Panel._dispatch_event(vecinput, "change");
4705
4704
  }
4706
4705
 
@@ -5314,11 +5313,13 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
5314
5313
 
5315
5314
  this._addBranchSeparator();
5316
5315
 
5317
- if(options.closed) {
5316
+ if( options.closed ) {
5318
5317
  title.className += " closed";
5319
5318
  root.className += " closed";
5320
- this.content.setAttribute('hidden', true);
5321
5319
  this.grabber.setAttribute('hidden', true);
5320
+ doAsync( () => {
5321
+ this.content.setAttribute('hidden', true);
5322
+ }, 15);
5322
5323
  }
5323
5324
 
5324
5325
  this.onclick = function(e){
@@ -5844,7 +5845,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
5844
5845
  const hasSubmenu = o[ k ].length;
5845
5846
  let entry = document.createElement('div');
5846
5847
  entry.className = "lexcontextmenuentry" + (o[ 'className' ] ? " " + o[ 'className' ] : "" );
5847
- entry.id = o.id ?? ("eId" + k.replace(/\s/g, '').replace('@', '_'));
5848
+ entry.id = o.id ?? ("eId" + this._getSupportedDOMName( k ));
5848
5849
  entry.innerHTML = "";
5849
5850
  const icon = o[ 'icon' ];
5850
5851
  if(icon) {
@@ -5991,7 +5992,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
5991
5992
  for( let item of this.items )
5992
5993
  {
5993
5994
  let key = Object.keys(item)[0];
5994
- let pKey = "eId" + key.replace(/\s/g, '').replace('@', '_');
5995
+ let pKey = "eId" + this._getSupportedDOMName( key );
5995
5996
 
5996
5997
  // Item already created
5997
5998
  const id = "#" + (item.id ?? pKey);
@@ -6007,7 +6008,10 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
6007
6008
 
6008
6009
  this.colors[ token ] = color;
6009
6010
  }
6010
-
6011
+
6012
+ _getSupportedDOMName( key ) {
6013
+ return key.replace(/\s/g, '').replaceAll('@', '_').replaceAll('+', '_plus_');
6014
+ }
6011
6015
  };
6012
6016
 
6013
6017
  LX.ContextMenu = ContextMenu;
@@ -8,7 +8,7 @@
8
8
  */
9
9
 
10
10
  var LX = {
11
- version: "0.1.13",
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');
@@ -4634,8 +4636,7 @@ class Panel {
4634
4636
  slider.value = value;
4635
4637
  slider.addEventListener("input", function(e) {
4636
4638
  let new_value = +this.valueAsNumber;
4637
- let fract = new_value % 1;
4638
- 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');
4639
4640
  Panel._dispatch_event(vecinput, "change");
4640
4641
  }, false);
4641
4642
  box.appendChild(slider);
@@ -4651,8 +4652,7 @@ class Panel {
4651
4652
  if(e.shiftKey) mult *= 10;
4652
4653
  else if(e.altKey) mult *= 0.1;
4653
4654
  let new_value = (+this.valueAsNumber - mult * (e.deltaY > 0 ? 1 : -1));
4654
- let fract = new_value % 1;
4655
- 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');
4656
4656
  Panel._dispatch_event(vecinput, "change");
4657
4657
  }, {passive:false});
4658
4658
 
@@ -4695,8 +4695,7 @@ class Panel {
4695
4695
  if(e.shiftKey) mult *= 10;
4696
4696
  else if(e.altKey) mult *= 0.1;
4697
4697
  let new_value = (+vecinput.valueAsNumber + mult * dt);
4698
- let fract = new_value % 1;
4699
- 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');
4700
4699
  Panel._dispatch_event(vecinput, "change");
4701
4700
  }
4702
4701
 
@@ -5310,11 +5309,13 @@ class Branch {
5310
5309
 
5311
5310
  this._addBranchSeparator();
5312
5311
 
5313
- if(options.closed) {
5312
+ if( options.closed ) {
5314
5313
  title.className += " closed";
5315
5314
  root.className += " closed";
5316
- this.content.setAttribute('hidden', true);
5317
5315
  this.grabber.setAttribute('hidden', true);
5316
+ doAsync( () => {
5317
+ this.content.setAttribute('hidden', true);
5318
+ }, 15);
5318
5319
  }
5319
5320
 
5320
5321
  this.onclick = function(e){
@@ -5840,7 +5841,7 @@ class ContextMenu {
5840
5841
  const hasSubmenu = o[ k ].length;
5841
5842
  let entry = document.createElement('div');
5842
5843
  entry.className = "lexcontextmenuentry" + (o[ 'className' ] ? " " + o[ 'className' ] : "" );
5843
- entry.id = o.id ?? ("eId" + k.replace(/\s/g, '').replace('@', '_'));
5844
+ entry.id = o.id ?? ("eId" + this._getSupportedDOMName( k ));
5844
5845
  entry.innerHTML = "";
5845
5846
  const icon = o[ 'icon' ];
5846
5847
  if(icon) {
@@ -5987,7 +5988,7 @@ class ContextMenu {
5987
5988
  for( let item of this.items )
5988
5989
  {
5989
5990
  let key = Object.keys(item)[0];
5990
- let pKey = "eId" + key.replace(/\s/g, '').replace('@', '_');
5991
+ let pKey = "eId" + this._getSupportedDOMName( key );
5991
5992
 
5992
5993
  // Item already created
5993
5994
  const id = "#" + (item.id ?? pKey);
@@ -6003,7 +6004,11 @@ class ContextMenu {
6003
6004
 
6004
6005
  this.colors[ token ] = color;
6005
6006
  }
6006
-
6007
+
6008
+ _getSupportedDOMName( key ) {
6009
+ return key.replace(/\s/g, '').replaceAll('@', '_').replaceAll('+', '_plus_');
6010
+ }
6011
+
6007
6012
  };
6008
6013
 
6009
6014
  LX.ContextMenu = ContextMenu;
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,10 +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
 
50
+ editor.loadFile( "../data/test.json" );
51
+ editor.loadFile( "../data/style.css" );
49
52
  editor.loadFile( "../data/script.js" );
53
+ editor.loadFile( "../data/engine.cpp" );
50
54
 
51
55
  var ctx = canvas.getContext("2d");
52
56
  ctx.fillStyle = "#b7a9b1";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lexgui",
3
- "version": "0.1.13",
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",