lexgui 0.5.6 → 0.5.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.
@@ -6,7 +6,7 @@
6
6
  */
7
7
 
8
8
  var LX = {
9
- version: "0.5.6",
9
+ version: "0.5.7",
10
10
  ready: false,
11
11
  components: [], // Specific pre-build components
12
12
  signals: {}, // Events and triggers
@@ -722,14 +722,20 @@ LX.makeKbd = makeKbd;
722
722
  * @method makeIcon
723
723
  * @description Gets an SVG element using one of LX.ICONS
724
724
  * @param {String} iconName
725
- * @param {String} iconTitle
726
- * @param {String} extraClass
725
+ * @param {Object} options
726
+ * iconTitle
727
+ * extraClass
728
+ * svgClass
727
729
  */
728
- function makeIcon( iconName, iconTitle, extraClass = "" )
730
+ function makeIcon( iconName, options = { } )
729
731
  {
730
732
  let data = LX.ICONS[ iconName ];
731
733
  console.assert( data, `No icon named _${ iconName }_` );
732
734
 
735
+ const iconTitle = options.iconTitle;
736
+ const iconClass = options.iconClass;
737
+ const svgClass = options.svgClass;
738
+
733
739
  // Just another name for the same icon..
734
740
  if( data.constructor == String )
735
741
  {
@@ -739,9 +745,9 @@ function makeIcon( iconName, iconTitle, extraClass = "" )
739
745
  const svg = document.createElementNS( "http://www.w3.org/2000/svg", "svg" );
740
746
  svg.setAttribute( "viewBox", `0 0 ${ data[ 0 ] } ${ data[ 1 ] }` );
741
747
 
742
- if( extraClass )
748
+ if( svgClass )
743
749
  {
744
- svg.classList.add( extraClass );
750
+ svg.classList.add( svgClass );
745
751
  }
746
752
 
747
753
  if( data[ 5 ] )
@@ -769,7 +775,7 @@ function makeIcon( iconName, iconTitle, extraClass = "" )
769
775
 
770
776
  const icon = document.createElement( "a" );
771
777
  icon.title = iconTitle ?? "";
772
- icon.className = "lexicon " + extraClass;
778
+ icon.className = "lexicon " + ( iconClass ?? "" );
773
779
  icon.appendChild( svg );
774
780
 
775
781
  return icon;
@@ -1368,6 +1374,19 @@ function init( options = { } )
1368
1374
 
1369
1375
  LX.init = init;
1370
1376
 
1377
+ /**
1378
+ * @method setStrictViewport
1379
+ * @param {Boolean} value
1380
+ */
1381
+
1382
+ function setStrictViewport( value )
1383
+ {
1384
+ this.usingStrictViewport = value ?? true;
1385
+ document.documentElement.setAttribute( "data-strictVP", ( this.usingStrictViewport ) ? "true" : "false" );
1386
+ }
1387
+
1388
+ LX.setStrictViewport = setStrictViewport;
1389
+
1371
1390
  /**
1372
1391
  * @method setCommandbarState
1373
1392
  * @param {Boolean} value
@@ -2435,9 +2454,23 @@ class ColorPicker {
2435
2454
  this.labelWidget = new TextInput( null, "", null, { inputClass: "bg-none", fit: true, disabled: true } );
2436
2455
  colorLabel.appendChild( this.labelWidget.root );
2437
2456
 
2438
- colorLabel.appendChild( new Button(null, "eyedrop", async () => {
2439
- navigator.clipboard.writeText( this.labelWidget.value() );
2440
- }, { icon: "copy", buttonClass: "bg-none", className: "ml-auto", title: "Copy" }).root );
2457
+ // Copy button
2458
+ {
2459
+ const copyButtonWidget = new Button(null, "copy", async () => {
2460
+ navigator.clipboard.writeText( this.labelWidget.value() );
2461
+ copyButtonWidget.root.querySelector( "input[type='checkbox']" ).style.pointerEvents = "none";
2462
+
2463
+ doAsync( () => {
2464
+ copyButtonWidget.root.swap( true );
2465
+ copyButtonWidget.root.querySelector( "input[type='checkbox']" ).style.pointerEvents = "auto";
2466
+ }, 3000 );
2467
+
2468
+ }, { swap: "check", icon: "copy", buttonClass: "bg-none", className: "ml-auto", title: "Copy" })
2469
+
2470
+ copyButtonWidget.root.querySelector( ".swap-on svg path" ).style.fill = "#42d065";
2471
+
2472
+ colorLabel.appendChild( copyButtonWidget.root );
2473
+ }
2441
2474
 
2442
2475
  this._updateColorValue( hexValue, true );
2443
2476
 
@@ -2511,7 +2544,7 @@ class ColorPicker {
2511
2544
 
2512
2545
  if( this.useAlpha )
2513
2546
  {
2514
- this.alphaTracker.style.color = `rgb(${ this.currentColor.css.r }, ${ this.currentColor.css.g }, ${ this.currentColor.css.b },${ this.currentColor.css.a })`;
2547
+ this.alphaTracker.style.color = `rgb(${ this.currentColor.css.r }, ${ this.currentColor.css.g }, ${ this.currentColor.css.b })`;
2515
2548
  }
2516
2549
 
2517
2550
  const toFixed = ( s, n = 2) => { return s.toFixed( n ).replace( /([0-9]+(\.[0-9]+[1-9])?)(\.?0+$)/, '$1' ) };
@@ -2519,7 +2552,7 @@ class ColorPicker {
2519
2552
  if( this.colorModel == "CSS" )
2520
2553
  {
2521
2554
  const { r, g, b, a } = this.currentColor.css;
2522
- this.labelWidget.set( `rgba(${ r },${ g },${ b }${ this.useAlpha ? ',' + toFixed( a ) : '' })` );
2555
+ this.labelWidget.set( `rgb${ this.useAlpha ? 'a' : '' }(${ r },${ g },${ b }${ this.useAlpha ? ',' + toFixed( a ) : '' })` );
2523
2556
  }
2524
2557
  else if( this.colorModel == "Hex" )
2525
2558
  {
@@ -4396,7 +4429,7 @@ class Menubar {
4396
4429
  // Otherwise, create it
4397
4430
  button = document.createElement('div');
4398
4431
  const disabled = options.disabled ?? false;
4399
- button.className = "lexmenubutton" + (disabled ? " disabled" : "");
4432
+ button.className = "lexmenubutton main" + (disabled ? " disabled" : "");
4400
4433
  button.title = name;
4401
4434
  button.innerHTML = "<a><image src='" + src + "' class='lexicon' style='height:32px;'></a>";
4402
4435
 
@@ -4560,7 +4593,7 @@ class SideBar {
4560
4593
 
4561
4594
  if( this.collapsable )
4562
4595
  {
4563
- const icon = LX.makeIcon( "sidebar", "Toggle Sidebar", "toggler" );
4596
+ const icon = LX.makeIcon( "sidebar", { title: "Toggle Sidebar", iconClass: "toggler" } );
4564
4597
  this.header.appendChild( icon );
4565
4598
 
4566
4599
  icon.addEventListener( "click", (e) => {
@@ -5047,7 +5080,7 @@ class SideBar {
5047
5080
 
5048
5081
  if( options.action )
5049
5082
  {
5050
- const actionIcon = LX.makeIcon( options.action.icon ?? "more-horizontal", options.action.name );
5083
+ const actionIcon = LX.makeIcon( options.action.icon ?? "more-horizontal", { title: options.action.name } );
5051
5084
  itemDom.appendChild( actionIcon );
5052
5085
 
5053
5086
  actionIcon.addEventListener( "click", (e) => {
@@ -5107,7 +5140,7 @@ class SideBar {
5107
5140
 
5108
5141
  if( suboptions.action )
5109
5142
  {
5110
- const actionIcon = LX.makeIcon( suboptions.action.icon ?? "more-horizontal", suboptions.action.name );
5143
+ const actionIcon = LX.makeIcon( suboptions.action.icon ?? "more-horizontal", { title: suboptions.action.name } );
5111
5144
  subentry.appendChild( actionIcon );
5112
5145
 
5113
5146
  actionIcon.addEventListener( "click", (e) => {
@@ -5299,7 +5332,7 @@ class Widget {
5299
5332
 
5300
5333
  _addResetProperty( container, callback ) {
5301
5334
 
5302
- const domEl = LX.makeIcon( "rotate-left", "Reset" )
5335
+ const domEl = LX.makeIcon( "rotate-left", { title: "Reset" } )
5303
5336
  domEl.style.display = "none";
5304
5337
  domEl.style.marginRight = "6px";
5305
5338
  domEl.style.marginLeft = "0";
@@ -6506,10 +6539,20 @@ class Button extends Widget {
6506
6539
  const input = document.createElement( "input" );
6507
6540
  input.type = "checkbox";
6508
6541
  wValue.prepend( input );
6509
- // trigger = input;
6510
6542
 
6511
- const swapIcon = document.createElement( "a" );
6512
- swapIcon.className = options.swap + " swap-on lexicon";
6543
+ let swapIcon = null;
6544
+
6545
+ // @legacy
6546
+ if( options.swap.includes( "fa-" ) )
6547
+ {
6548
+ swapIcon = document.createElement( 'a' );
6549
+ swapIcon.className = options.swap + " swap-on lexicon";
6550
+ }
6551
+ else
6552
+ {
6553
+ swapIcon = LX.makeIcon( options.swap, { iconClass: "swap-on" } );
6554
+ }
6555
+
6513
6556
  wValue.appendChild( swapIcon );
6514
6557
 
6515
6558
  this.root.swap = function( skipCallback ) {
@@ -8400,7 +8443,6 @@ class NumberInput extends Widget {
8400
8443
  else if( e.altKey ) mult *= 0.1;
8401
8444
  value = ( +vecinput.valueAsNumber + mult * dt );
8402
8445
  this.set( value, false, e );
8403
- // vecinput.value = ( +new_value ).toFixed( 4 ).replace( /([0-9]+(\.[0-9]+[1-9])?)(\.?0+$)/, '$1' );
8404
8446
  }
8405
8447
 
8406
8448
  e.stopPropagation();
@@ -9615,7 +9657,7 @@ class Table extends Widget {
9615
9657
 
9616
9658
  if( this.customFilters )
9617
9659
  {
9618
- const icon = LX.makeIcon( "circle-plus", null, "sm" );
9660
+ const icon = LX.makeIcon( "circle-plus", { svgClass: "sm" } );
9619
9661
 
9620
9662
  for( let f of this.customFilters )
9621
9663
  {
@@ -9640,7 +9682,6 @@ class Table extends Widget {
9640
9682
  headerContainer.appendChild( customFilterBtn.root );
9641
9683
  }
9642
9684
 
9643
- // const resetIcon = LX.makeIcon( "xmark", null, "sm" );
9644
9685
  this._resetCustomFiltersBtn = new Button(null, "resetButton", ( v ) => {
9645
9686
  this.activeCustomFilters = {};
9646
9687
  this.refresh();
@@ -9652,7 +9693,7 @@ class Table extends Widget {
9652
9693
 
9653
9694
  if( this.toggleColumns )
9654
9695
  {
9655
- const icon = LX.makeIcon( "sliders" );
9696
+ const icon = LX.makeIcon( "sliders-large" );
9656
9697
  const toggleColumnsBtn = new Button( "toggleColumnsBtn", icon.innerHTML + "View", (value, e) => {
9657
9698
  const menuOptions = data.head.map( ( colName, idx ) => {
9658
9699
  const item = {
@@ -9735,7 +9776,7 @@ class Table extends Widget {
9735
9776
  {
9736
9777
  const th = document.createElement( 'th' );
9737
9778
  th.innerHTML = `<span>${ headData }</span>`;
9738
- th.querySelector( "span" ).appendChild( LX.makeIcon( "menu-arrows", null, "sm" ) );
9779
+ th.querySelector( "span" ).appendChild( LX.makeIcon( "menu-arrows", { svgClass: "sm" } ) );
9739
9780
 
9740
9781
  const idx = data.head.indexOf( headData );
9741
9782
  if( this.centered && this.centered.indexOf( idx ) > -1 )
@@ -9986,7 +10027,7 @@ class Table extends Widget {
9986
10027
 
9987
10028
  if( action == "delete" )
9988
10029
  {
9989
- button = LX.makeIcon( "trash-can", "Delete Row" );
10030
+ button = LX.makeIcon( "trash-can", { title: "Delete Row" } );
9990
10031
  button.addEventListener( 'click', function() {
9991
10032
  // Don't need to refresh table..
9992
10033
  data.body.splice( r, 1 );
@@ -9995,7 +10036,7 @@ class Table extends Widget {
9995
10036
  }
9996
10037
  else if( action == "menu" )
9997
10038
  {
9998
- button = LX.makeIcon( "more-horizontal", "Menu" );
10039
+ button = LX.makeIcon( "more-horizontal", { title: "Menu" } );
9999
10040
  button.addEventListener( 'click', function( event ) {
10000
10041
  if( !options.onMenuAction )
10001
10042
  {
@@ -10011,7 +10052,7 @@ class Table extends Widget {
10011
10052
  else // custom actions
10012
10053
  {
10013
10054
  console.assert( action.constructor == Object );
10014
- button = LX.makeIcon( action.icon, action.title );
10055
+ button = LX.makeIcon( action.icon, { title: action.title } );
10015
10056
 
10016
10057
  if( action.callback )
10017
10058
  {