lexgui 0.1.24 → 0.1.26

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.css CHANGED
@@ -3125,7 +3125,7 @@ pre .line-gutter {
3125
3125
 
3126
3126
  /* Common */
3127
3127
  .cm-str { color: #ca7d59; } /* string */
3128
- .cm-std { color: #cf6dcf; } /* statements & declarations */
3128
+ .cm-std { color: #d181d1; } /* statements & declarations */
3129
3129
  .cm-kwd { color: #2194ce; } /* keyword */
3130
3130
  .cm-com { color: #5cab5a; } /* comment */
3131
3131
 
@@ -3152,16 +3152,16 @@ pre .line-gutter {
3152
3152
  .cm-sym.json { color: #cf6dcf; } /* symbol */
3153
3153
 
3154
3154
  .cm-typ.glsl { color: #36c0b0; } /* type */
3155
- .cm-bln.glsl { color: #cfc159; } /* builtin */
3156
3155
  .cm-dec.glsl { color: #b1ce9b; } /* decimal */
3157
3156
  .cm-sym.glsl { color: #f9cb20; } /* symbol */
3158
3157
  .cm-mtd.glsl { color: #e0cc68; } /* method */
3159
3158
 
3160
3159
  .cm-typ.wgsl { color: #36c0b0; } /* type */
3161
- .cm-bln.wgsl { color: #cfc159; } /* builtin */
3162
3160
  .cm-dec.wgsl { color: #b1ce9b; } /* decimal */
3161
+ .cm-mtd.wgsl { color: #dfe093; } /* method */
3163
3162
  .cm-sym.wgsl { color: #f9cb20; } /* symbol */
3164
- .cm-mtd.wgsl { color: #e0cc68; } /* method */
3163
+ .cm-ppc.wgsl { color: #99caf1; } /* preprocessor */
3164
+
3165
3165
 
3166
3166
  .cm-typ.rust { color: #36c0b0; } /* type */
3167
3167
  .cm-dec.rust { color: #b1ce9b; } /* decimal */
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.24",
15
+ version: "0.1.26",
16
16
  ready: false,
17
17
  components: [], // specific pre-build components
18
18
  signals: {} // events and triggers
@@ -2178,7 +2178,9 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
2178
2178
  set( value ) {
2179
2179
 
2180
2180
  if( this.onSetValue )
2181
- this.onSetValue( value );
2181
+ return this.onSetValue( value );
2182
+
2183
+ console.warn("Can't set value of " + this.typeName());
2182
2184
  }
2183
2185
 
2184
2186
  oncontextmenu(e) {
@@ -3029,6 +3031,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
3029
3031
  let domName = document.createElement('div');
3030
3032
  domName.className = "lexwidgetname";
3031
3033
  domName.innerHTML = name || "";
3034
+ domName.title = options.title ?? domName.innerHTML;
3032
3035
  domName.style.width = options.nameWidth || LX.DEFAULT_NAME_WIDTH;
3033
3036
  element.appendChild(domName);
3034
3037
  element.domName = domName;
@@ -4288,47 +4291,70 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
4288
4291
 
4289
4292
  addList( name, values, value, callback, options = {} ) {
4290
4293
 
4291
- let widget = this.create_widget(name, Widget.LIST, options);
4292
- let element = widget.domEl;
4293
-
4294
- // Show list
4295
-
4296
- let list_container = document.createElement('div');
4297
- list_container.className = "lexlist";
4298
- list_container.style.width = "calc( 100% - " + LX.DEFAULT_NAME_WIDTH + ")";
4299
-
4300
- for( let i = 0; i < values.length; ++i )
4301
- {
4302
- let icon = null;
4303
- let item_value = values[i];
4304
-
4305
- if( item_value.constructor === Array )
4294
+ let widget = this.create_widget( name, Widget.LIST, options );
4295
+
4296
+ widget.onGetValue = () => {
4297
+ return value;
4298
+ };
4299
+
4300
+ widget.onSetValue = ( newValue ) => {
4301
+ listContainer.querySelectorAll( '.lexlistitem' ).forEach( e => e.classList.remove( 'selected' ) );
4302
+ const idx = values.indexOf( newValue );
4303
+ if( idx == -1 ) return;
4304
+ listContainer.children[ idx ].classList.toggle( 'selected' );
4305
+ value = newValue;
4306
+ this._trigger( new IEvent( name, newValue ), callback );
4307
+ };
4308
+
4309
+ widget.updateValues = ( newValues ) => {
4310
+
4311
+ values = newValues;
4312
+ listContainer.innerHTML = "";
4313
+
4314
+ for( let i = 0; i < values.length; ++i )
4306
4315
  {
4307
- icon = item_value[1];
4308
- item_value = item_value[0];
4316
+ let icon = null;
4317
+ let itemValue = values[ i ];
4318
+
4319
+ if( itemValue.constructor === Array )
4320
+ {
4321
+ icon = itemValue[ 1 ];
4322
+ itemValue = itemValue[ 0 ];
4323
+ }
4324
+
4325
+ let listElement = document.createElement( 'div' );
4326
+ listElement.className = "lexlistitem" + ( value == itemValue ? " selected" : "" );
4327
+ listElement.innerHTML = "<span>" + itemValue + "</span>" + ( icon ? "<a class='" + icon + "'></a>" : "" );
4328
+
4329
+ listElement.addEventListener( 'click', e => {
4330
+ listContainer.querySelectorAll( '.lexlistitem' ).forEach( e => e.classList.remove( 'selected' ) );
4331
+ listElement.classList.toggle( 'selected' );
4332
+ value = itemValue;
4333
+ this._trigger( new IEvent( name, itemValue, e ), callback );
4334
+ });
4335
+
4336
+ listContainer.appendChild( listElement );
4309
4337
  }
4310
-
4311
- let list_item = document.createElement('div');
4312
- list_item.className = "lexlistitem" + (value == item_value ? " selected" : "");
4313
- list_item.innerHTML = "<span>" + item_value + "</span>" + (icon ? "<a class='" + icon + "'></a>" : "");
4314
-
4315
- list_item.addEventListener('click', (e) => {
4316
- list_container.querySelectorAll('.lexlistitem').forEach( e => e.classList.remove('selected'));
4317
- list_item.classList.toggle( 'selected' );
4318
- this._trigger( new IEvent(name, item_value, e), callback );
4319
- });
4320
-
4321
- list_container.appendChild(list_item);
4322
- }
4323
-
4338
+ };
4339
+
4340
+ let element = widget.domEl;
4341
+
4342
+ // Show list
4343
+
4344
+ let listContainer = document.createElement( 'div' );
4345
+ listContainer.className = "lexlist";
4346
+ listContainer.style.width = "calc( 100% - " + LX.DEFAULT_NAME_WIDTH + ")";
4347
+
4348
+ widget.updateValues( values );
4349
+
4324
4350
  // Remove branch padding and margins
4325
- if(!widget.name) {
4351
+ if( !widget.name ) {
4326
4352
  element.className += " noname";
4327
- list_container.style.width = "100%";
4353
+ listContainer.style.width = "100%";
4328
4354
  }
4329
-
4330
- element.appendChild(list_container);
4331
-
4355
+
4356
+ element.appendChild( listContainer );
4357
+
4332
4358
  return widget;
4333
4359
  }
4334
4360
 
@@ -8,7 +8,7 @@
8
8
  */
9
9
 
10
10
  var LX = {
11
- version: "0.1.24",
11
+ version: "0.1.26",
12
12
  ready: false,
13
13
  components: [], // specific pre-build components
14
14
  signals: {} // events and triggers
@@ -2174,7 +2174,9 @@ class Widget {
2174
2174
  set( value ) {
2175
2175
 
2176
2176
  if( this.onSetValue )
2177
- this.onSetValue( value );
2177
+ return this.onSetValue( value );
2178
+
2179
+ console.warn("Can't set value of " + this.typeName());
2178
2180
  }
2179
2181
 
2180
2182
  oncontextmenu(e) {
@@ -3025,6 +3027,7 @@ class Panel {
3025
3027
  let domName = document.createElement('div');
3026
3028
  domName.className = "lexwidgetname";
3027
3029
  domName.innerHTML = name || "";
3030
+ domName.title = options.title ?? domName.innerHTML;
3028
3031
  domName.style.width = options.nameWidth || LX.DEFAULT_NAME_WIDTH;
3029
3032
  element.appendChild(domName);
3030
3033
  element.domName = domName;
@@ -4284,46 +4287,69 @@ class Panel {
4284
4287
 
4285
4288
  addList( name, values, value, callback, options = {} ) {
4286
4289
 
4287
- let widget = this.create_widget(name, Widget.LIST, options);
4288
- let element = widget.domEl;
4290
+ let widget = this.create_widget( name, Widget.LIST, options );
4289
4291
 
4290
- // Show list
4292
+ widget.onGetValue = () => {
4293
+ return value;
4294
+ };
4291
4295
 
4292
- let list_container = document.createElement('div');
4293
- list_container.className = "lexlist";
4294
- list_container.style.width = "calc( 100% - " + LX.DEFAULT_NAME_WIDTH + ")";
4296
+ widget.onSetValue = ( newValue ) => {
4297
+ listContainer.querySelectorAll( '.lexlistitem' ).forEach( e => e.classList.remove( 'selected' ) );
4298
+ const idx = values.indexOf( newValue );
4299
+ if( idx == -1 ) return;
4300
+ listContainer.children[ idx ].classList.toggle( 'selected' );
4301
+ value = newValue;
4302
+ this._trigger( new IEvent( name, newValue ), callback );
4303
+ };
4295
4304
 
4296
- for( let i = 0; i < values.length; ++i )
4297
- {
4298
- let icon = null;
4299
- let item_value = values[i];
4305
+ widget.updateValues = ( newValues ) => {
4300
4306
 
4301
- if( item_value.constructor === Array )
4307
+ values = newValues;
4308
+ listContainer.innerHTML = "";
4309
+
4310
+ for( let i = 0; i < values.length; ++i )
4302
4311
  {
4303
- icon = item_value[1];
4304
- item_value = item_value[0];
4312
+ let icon = null;
4313
+ let itemValue = values[ i ];
4314
+
4315
+ if( itemValue.constructor === Array )
4316
+ {
4317
+ icon = itemValue[ 1 ];
4318
+ itemValue = itemValue[ 0 ];
4319
+ }
4320
+
4321
+ let listElement = document.createElement( 'div' );
4322
+ listElement.className = "lexlistitem" + ( value == itemValue ? " selected" : "" );
4323
+ listElement.innerHTML = "<span>" + itemValue + "</span>" + ( icon ? "<a class='" + icon + "'></a>" : "" );
4324
+
4325
+ listElement.addEventListener( 'click', e => {
4326
+ listContainer.querySelectorAll( '.lexlistitem' ).forEach( e => e.classList.remove( 'selected' ) );
4327
+ listElement.classList.toggle( 'selected' );
4328
+ value = itemValue;
4329
+ this._trigger( new IEvent( name, itemValue, e ), callback );
4330
+ });
4331
+
4332
+ listContainer.appendChild( listElement );
4305
4333
  }
4334
+ };
4306
4335
 
4307
- let list_item = document.createElement('div');
4308
- list_item.className = "lexlistitem" + (value == item_value ? " selected" : "");
4309
- list_item.innerHTML = "<span>" + item_value + "</span>" + (icon ? "<a class='" + icon + "'></a>" : "");
4336
+ let element = widget.domEl;
4310
4337
 
4311
- list_item.addEventListener('click', (e) => {
4312
- list_container.querySelectorAll('.lexlistitem').forEach( e => e.classList.remove('selected'));
4313
- list_item.classList.toggle( 'selected' );
4314
- this._trigger( new IEvent(name, item_value, e), callback );
4315
- });
4338
+ // Show list
4316
4339
 
4317
- list_container.appendChild(list_item);
4318
- }
4340
+ let listContainer = document.createElement( 'div' );
4341
+ listContainer.className = "lexlist";
4342
+ listContainer.style.width = "calc( 100% - " + LX.DEFAULT_NAME_WIDTH + ")";
4343
+
4344
+ widget.updateValues( values );
4319
4345
 
4320
4346
  // Remove branch padding and margins
4321
- if(!widget.name) {
4347
+ if( !widget.name ) {
4322
4348
  element.className += " noname";
4323
- list_container.style.width = "100%";
4349
+ listContainer.style.width = "100%";
4324
4350
  }
4325
4351
 
4326
- element.appendChild(list_container);
4352
+ element.appendChild( listContainer );
4327
4353
 
4328
4354
  return widget;
4329
4355
  }
package/changelog.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # lexgui.js changelog
2
2
 
3
+ ## 0.1.26
4
+
5
+ Code Editor:
6
+ - Search Next Ocurrence using "Ctrl+D" (Duplicate line moved to "Alt+D")
7
+ - Previous selection is restored on undo.
8
+ - Get text to search from selection.
9
+ - Reverse search bugfixes.
10
+ - Pasting content now scrolls to follow cursor.
11
+
12
+ Minor fixes.
13
+
14
+ ## 0.1.25
15
+
16
+ Code Editor:
17
+ - Added Ctrl+K + C/U Shortcuts to Comment/Uncomment lines.
18
+ - Improved WGSL highlighting.
19
+ - Minor bug fixes.
20
+
21
+ Added title attribute by default to Widget Name Dom elements.
22
+ Added value getter/setter for LIST widget.
23
+ Added updateValues method for modify list options in LIST widget.
24
+
3
25
  ## 0.1.24
4
26
 
5
27
  Code Editor:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lexgui",
3
- "version": "0.1.24",
3
+ "version": "0.1.26",
4
4
  "description": "JS library to create web graphical user interfaces",
5
5
  "type": "module",
6
6
  "main": "./build/lexgui.js",