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.
package/build/lexgui.css CHANGED
@@ -656,6 +656,13 @@ a svg, svg path {
656
656
  color: var(--global-text-secondary);
657
657
  }
658
658
 
659
+ .lexfooter ul li a {
660
+ display: flex;
661
+ gap: 0.4rem;
662
+ align-items: center;
663
+ place-content: center;
664
+ }
665
+
659
666
  .lexfooter a {
660
667
  text-decoration: none;
661
668
  color: var(--global-text-secondary);
@@ -3165,7 +3172,7 @@ meter:-moz-meter-sub-sub-optimum::-moz-meter-bar {
3165
3172
  }
3166
3173
 
3167
3174
  .lexmenubar .lexbutton {
3168
- padding-inline: 0.15rem;
3175
+ padding-inline: 0.1rem;
3169
3176
  }
3170
3177
 
3171
3178
  .lexmenubar .lexbutton:hover, :root[data-theme="light"] .lexmenubar .lexbutton:hover {
@@ -3188,6 +3195,10 @@ meter:-moz-meter-sub-sub-optimum::-moz-meter-bar {
3188
3195
  user-select: none;
3189
3196
  }
3190
3197
 
3198
+ .lexmenubar .lexmenubutton.main:first-child {
3199
+ margin-left: 8px;
3200
+ }
3201
+
3191
3202
  .lexmenubar .lexmenubutton.main:last-child {
3192
3203
  margin-right: 8px;
3193
3204
  }
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 = {
15
- version: "0.5.6",
15
+ version: "0.5.7",
16
16
  ready: false,
17
17
  components: [], // Specific pre-build components
18
18
  signals: {}, // Events and triggers
@@ -728,14 +728,20 @@ LX.makeKbd = makeKbd;
728
728
  * @method makeIcon
729
729
  * @description Gets an SVG element using one of LX.ICONS
730
730
  * @param {String} iconName
731
- * @param {String} iconTitle
732
- * @param {String} extraClass
731
+ * @param {Object} options
732
+ * iconTitle
733
+ * extraClass
734
+ * svgClass
733
735
  */
734
- function makeIcon( iconName, iconTitle, extraClass = "" )
736
+ function makeIcon( iconName, options = { } )
735
737
  {
736
738
  let data = LX.ICONS[ iconName ];
737
739
  console.assert( data, `No icon named _${ iconName }_` );
738
740
 
741
+ const iconTitle = options.iconTitle;
742
+ const iconClass = options.iconClass;
743
+ const svgClass = options.svgClass;
744
+
739
745
  // Just another name for the same icon..
740
746
  if( data.constructor == String )
741
747
  {
@@ -745,9 +751,9 @@ function makeIcon( iconName, iconTitle, extraClass = "" )
745
751
  const svg = document.createElementNS( "http://www.w3.org/2000/svg", "svg" );
746
752
  svg.setAttribute( "viewBox", `0 0 ${ data[ 0 ] } ${ data[ 1 ] }` );
747
753
 
748
- if( extraClass )
754
+ if( svgClass )
749
755
  {
750
- svg.classList.add( extraClass );
756
+ svg.classList.add( svgClass );
751
757
  }
752
758
 
753
759
  if( data[ 5 ] )
@@ -775,7 +781,7 @@ function makeIcon( iconName, iconTitle, extraClass = "" )
775
781
 
776
782
  const icon = document.createElement( "a" );
777
783
  icon.title = iconTitle ?? "";
778
- icon.className = "lexicon " + extraClass;
784
+ icon.className = "lexicon " + ( iconClass ?? "" );
779
785
  icon.appendChild( svg );
780
786
 
781
787
  return icon;
@@ -1374,6 +1380,19 @@ function init( options = { } )
1374
1380
 
1375
1381
  LX.init = init;
1376
1382
 
1383
+ /**
1384
+ * @method setStrictViewport
1385
+ * @param {Boolean} value
1386
+ */
1387
+
1388
+ function setStrictViewport( value )
1389
+ {
1390
+ this.usingStrictViewport = value ?? true;
1391
+ document.documentElement.setAttribute( "data-strictVP", ( this.usingStrictViewport ) ? "true" : "false" );
1392
+ }
1393
+
1394
+ LX.setStrictViewport = setStrictViewport;
1395
+
1377
1396
  /**
1378
1397
  * @method setCommandbarState
1379
1398
  * @param {Boolean} value
@@ -2441,9 +2460,23 @@ class ColorPicker {
2441
2460
  this.labelWidget = new TextInput( null, "", null, { inputClass: "bg-none", fit: true, disabled: true } );
2442
2461
  colorLabel.appendChild( this.labelWidget.root );
2443
2462
 
2444
- colorLabel.appendChild( new Button(null, "eyedrop", async () => {
2445
- navigator.clipboard.writeText( this.labelWidget.value() );
2446
- }, { icon: "copy", buttonClass: "bg-none", className: "ml-auto", title: "Copy" }).root );
2463
+ // Copy button
2464
+ {
2465
+ const copyButtonWidget = new Button(null, "copy", async () => {
2466
+ navigator.clipboard.writeText( this.labelWidget.value() );
2467
+ copyButtonWidget.root.querySelector( "input[type='checkbox']" ).style.pointerEvents = "none";
2468
+
2469
+ doAsync( () => {
2470
+ copyButtonWidget.root.swap( true );
2471
+ copyButtonWidget.root.querySelector( "input[type='checkbox']" ).style.pointerEvents = "auto";
2472
+ }, 3000 );
2473
+
2474
+ }, { swap: "check", icon: "copy", buttonClass: "bg-none", className: "ml-auto", title: "Copy" })
2475
+
2476
+ copyButtonWidget.root.querySelector( ".swap-on svg path" ).style.fill = "#42d065";
2477
+
2478
+ colorLabel.appendChild( copyButtonWidget.root );
2479
+ }
2447
2480
 
2448
2481
  this._updateColorValue( hexValue, true );
2449
2482
 
@@ -2517,7 +2550,7 @@ class ColorPicker {
2517
2550
 
2518
2551
  if( this.useAlpha )
2519
2552
  {
2520
- this.alphaTracker.style.color = `rgb(${ this.currentColor.css.r }, ${ this.currentColor.css.g }, ${ this.currentColor.css.b },${ this.currentColor.css.a })`;
2553
+ this.alphaTracker.style.color = `rgb(${ this.currentColor.css.r }, ${ this.currentColor.css.g }, ${ this.currentColor.css.b })`;
2521
2554
  }
2522
2555
 
2523
2556
  const toFixed = ( s, n = 2) => { return s.toFixed( n ).replace( /([0-9]+(\.[0-9]+[1-9])?)(\.?0+$)/, '$1' ) };
@@ -2525,7 +2558,7 @@ class ColorPicker {
2525
2558
  if( this.colorModel == "CSS" )
2526
2559
  {
2527
2560
  const { r, g, b, a } = this.currentColor.css;
2528
- this.labelWidget.set( `rgba(${ r },${ g },${ b }${ this.useAlpha ? ',' + toFixed( a ) : '' })` );
2561
+ this.labelWidget.set( `rgb${ this.useAlpha ? 'a' : '' }(${ r },${ g },${ b }${ this.useAlpha ? ',' + toFixed( a ) : '' })` );
2529
2562
  }
2530
2563
  else if( this.colorModel == "Hex" )
2531
2564
  {
@@ -4402,7 +4435,7 @@ class Menubar {
4402
4435
  // Otherwise, create it
4403
4436
  button = document.createElement('div');
4404
4437
  const disabled = options.disabled ?? false;
4405
- button.className = "lexmenubutton" + (disabled ? " disabled" : "");
4438
+ button.className = "lexmenubutton main" + (disabled ? " disabled" : "");
4406
4439
  button.title = name;
4407
4440
  button.innerHTML = "<a><image src='" + src + "' class='lexicon' style='height:32px;'></a>";
4408
4441
 
@@ -4566,7 +4599,7 @@ class SideBar {
4566
4599
 
4567
4600
  if( this.collapsable )
4568
4601
  {
4569
- const icon = LX.makeIcon( "sidebar", "Toggle Sidebar", "toggler" );
4602
+ const icon = LX.makeIcon( "sidebar", { title: "Toggle Sidebar", iconClass: "toggler" } );
4570
4603
  this.header.appendChild( icon );
4571
4604
 
4572
4605
  icon.addEventListener( "click", (e) => {
@@ -5053,7 +5086,7 @@ class SideBar {
5053
5086
 
5054
5087
  if( options.action )
5055
5088
  {
5056
- const actionIcon = LX.makeIcon( options.action.icon ?? "more-horizontal", options.action.name );
5089
+ const actionIcon = LX.makeIcon( options.action.icon ?? "more-horizontal", { title: options.action.name } );
5057
5090
  itemDom.appendChild( actionIcon );
5058
5091
 
5059
5092
  actionIcon.addEventListener( "click", (e) => {
@@ -5113,7 +5146,7 @@ class SideBar {
5113
5146
 
5114
5147
  if( suboptions.action )
5115
5148
  {
5116
- const actionIcon = LX.makeIcon( suboptions.action.icon ?? "more-horizontal", suboptions.action.name );
5149
+ const actionIcon = LX.makeIcon( suboptions.action.icon ?? "more-horizontal", { title: suboptions.action.name } );
5117
5150
  subentry.appendChild( actionIcon );
5118
5151
 
5119
5152
  actionIcon.addEventListener( "click", (e) => {
@@ -5305,7 +5338,7 @@ class Widget {
5305
5338
 
5306
5339
  _addResetProperty( container, callback ) {
5307
5340
 
5308
- const domEl = LX.makeIcon( "rotate-left", "Reset" )
5341
+ const domEl = LX.makeIcon( "rotate-left", { title: "Reset" } )
5309
5342
  domEl.style.display = "none";
5310
5343
  domEl.style.marginRight = "6px";
5311
5344
  domEl.style.marginLeft = "0";
@@ -6512,10 +6545,20 @@ class Button extends Widget {
6512
6545
  const input = document.createElement( "input" );
6513
6546
  input.type = "checkbox";
6514
6547
  wValue.prepend( input );
6515
- // trigger = input;
6516
6548
 
6517
- const swapIcon = document.createElement( "a" );
6518
- swapIcon.className = options.swap + " swap-on lexicon";
6549
+ let swapIcon = null;
6550
+
6551
+ // @legacy
6552
+ if( options.swap.includes( "fa-" ) )
6553
+ {
6554
+ swapIcon = document.createElement( 'a' );
6555
+ swapIcon.className = options.swap + " swap-on lexicon";
6556
+ }
6557
+ else
6558
+ {
6559
+ swapIcon = LX.makeIcon( options.swap, { iconClass: "swap-on" } );
6560
+ }
6561
+
6519
6562
  wValue.appendChild( swapIcon );
6520
6563
 
6521
6564
  this.root.swap = function( skipCallback ) {
@@ -8406,7 +8449,6 @@ class NumberInput extends Widget {
8406
8449
  else if( e.altKey ) mult *= 0.1;
8407
8450
  value = ( +vecinput.valueAsNumber + mult * dt );
8408
8451
  this.set( value, false, e );
8409
- // vecinput.value = ( +new_value ).toFixed( 4 ).replace( /([0-9]+(\.[0-9]+[1-9])?)(\.?0+$)/, '$1' );
8410
8452
  }
8411
8453
 
8412
8454
  e.stopPropagation();
@@ -9621,7 +9663,7 @@ class Table extends Widget {
9621
9663
 
9622
9664
  if( this.customFilters )
9623
9665
  {
9624
- const icon = LX.makeIcon( "circle-plus", null, "sm" );
9666
+ const icon = LX.makeIcon( "circle-plus", { svgClass: "sm" } );
9625
9667
 
9626
9668
  for( let f of this.customFilters )
9627
9669
  {
@@ -9646,7 +9688,6 @@ class Table extends Widget {
9646
9688
  headerContainer.appendChild( customFilterBtn.root );
9647
9689
  }
9648
9690
 
9649
- // const resetIcon = LX.makeIcon( "xmark", null, "sm" );
9650
9691
  this._resetCustomFiltersBtn = new Button(null, "resetButton", ( v ) => {
9651
9692
  this.activeCustomFilters = {};
9652
9693
  this.refresh();
@@ -9658,7 +9699,7 @@ class Table extends Widget {
9658
9699
 
9659
9700
  if( this.toggleColumns )
9660
9701
  {
9661
- const icon = LX.makeIcon( "sliders" );
9702
+ const icon = LX.makeIcon( "sliders-large" );
9662
9703
  const toggleColumnsBtn = new Button( "toggleColumnsBtn", icon.innerHTML + "View", (value, e) => {
9663
9704
  const menuOptions = data.head.map( ( colName, idx ) => {
9664
9705
  const item = {
@@ -9741,7 +9782,7 @@ class Table extends Widget {
9741
9782
  {
9742
9783
  const th = document.createElement( 'th' );
9743
9784
  th.innerHTML = `<span>${ headData }</span>`;
9744
- th.querySelector( "span" ).appendChild( LX.makeIcon( "menu-arrows", null, "sm" ) );
9785
+ th.querySelector( "span" ).appendChild( LX.makeIcon( "menu-arrows", { svgClass: "sm" } ) );
9745
9786
 
9746
9787
  const idx = data.head.indexOf( headData );
9747
9788
  if( this.centered && this.centered.indexOf( idx ) > -1 )
@@ -9992,7 +10033,7 @@ class Table extends Widget {
9992
10033
 
9993
10034
  if( action == "delete" )
9994
10035
  {
9995
- button = LX.makeIcon( "trash-can", "Delete Row" );
10036
+ button = LX.makeIcon( "trash-can", { title: "Delete Row" } );
9996
10037
  button.addEventListener( 'click', function() {
9997
10038
  // Don't need to refresh table..
9998
10039
  data.body.splice( r, 1 );
@@ -10001,7 +10042,7 @@ class Table extends Widget {
10001
10042
  }
10002
10043
  else if( action == "menu" )
10003
10044
  {
10004
- button = LX.makeIcon( "more-horizontal", "Menu" );
10045
+ button = LX.makeIcon( "more-horizontal", { title: "Menu" } );
10005
10046
  button.addEventListener( 'click', function( event ) {
10006
10047
  if( !options.onMenuAction )
10007
10048
  {
@@ -10017,7 +10058,7 @@ class Table extends Widget {
10017
10058
  else // custom actions
10018
10059
  {
10019
10060
  console.assert( action.constructor == Object );
10020
- button = LX.makeIcon( action.icon, action.title );
10061
+ button = LX.makeIcon( action.icon, { title: action.title } );
10021
10062
 
10022
10063
  if( action.callback )
10023
10064
  {