x4js 1.4.13 → 1.4.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/lib/gridview.js CHANGED
@@ -289,6 +289,7 @@ class GridView extends layout_1.VLayout {
289
289
  },
290
290
  content: this.m_container
291
291
  });
292
+ let flex = false;
292
293
  let cols = this.m_columns.map((col, index) => {
293
294
  let cls = '@cell';
294
295
  if (col.cls) {
@@ -325,10 +326,16 @@ class GridView extends layout_1.VLayout {
325
326
  sens: 'right',
326
327
  events: { resize: (e) => resizeCol(e) }
327
328
  });
328
- col.$col = comp;
329
+ if (col.flex) {
330
+ flex = true;
331
+ }
332
+ col.$hdr = comp;
329
333
  return comp;
330
334
  });
331
- cols.push(new component_1.Flex({}));
335
+ cols.push(new component_1.Flex({
336
+ ref: 'flex',
337
+ cls: flex ? '@hidden' : ''
338
+ }));
332
339
  // compute full width
333
340
  let full_width = 0;
334
341
  this.m_columns.forEach((col) => {
@@ -358,9 +365,13 @@ class GridView extends layout_1.VLayout {
358
365
  width: col.width
359
366
  }
360
367
  });
368
+ col.$ftr = comp;
361
369
  return comp;
362
370
  });
363
- foots.push(new component_1.Flex({}));
371
+ foots.push(new component_1.Flex({
372
+ ref: 'flex',
373
+ cls: flex ? '@hidden' : ''
374
+ }));
364
375
  this.m_footer = new layout_1.HLayout({
365
376
  cls: '@footer',
366
377
  content: foots,
@@ -380,8 +391,33 @@ class GridView extends layout_1.VLayout {
380
391
  ]);
381
392
  }
382
393
  _on_col_resize(col, width) {
383
- this.m_columns[col].width = width;
384
- this.m_columns[col].flex = undefined;
394
+ const _col = this.m_columns[col];
395
+ let updateFlex = false;
396
+ if (width >= 0) {
397
+ _col.width = width;
398
+ if (_col.flex) {
399
+ _col.$hdr.removeClass('@flex');
400
+ _col.flex = undefined;
401
+ updateFlex = true;
402
+ }
403
+ }
404
+ else if (width < 0 && !_col.flex) {
405
+ _col.$hdr.addClass('@flex');
406
+ _col.flex = 1;
407
+ updateFlex = true;
408
+ }
409
+ if (updateFlex) {
410
+ let flex = false;
411
+ this.m_columns.forEach(c => {
412
+ if (c.flex) {
413
+ flex = true;
414
+ }
415
+ });
416
+ this.m_header.itemWithRef('flex')?.show(flex ? false : true);
417
+ if (this.m_footer) {
418
+ this.m_footer.itemWithRef('flex')?.show(flex ? false : true);
419
+ }
420
+ }
385
421
  this._updateScroll(true);
386
422
  }
387
423
  /**
@@ -393,19 +429,19 @@ class GridView extends layout_1.VLayout {
393
429
  }
394
430
  this.m_columns.forEach((c) => {
395
431
  if (c !== col) {
396
- c.$col.sorted = false;
432
+ c.$hdr.sorted = false;
397
433
  }
398
434
  });
399
- const $col = col.$col;
400
- if ($col.sorted) {
401
- $col.toggleSens();
435
+ const $hdr = col.$hdr;
436
+ if ($hdr.sorted) {
437
+ $hdr.toggleSens();
402
438
  }
403
439
  else {
404
- $col.sorted = true;
440
+ $hdr.sorted = true;
405
441
  }
406
442
  if (this.m_dataview) {
407
443
  this.m_dataview.sort([
408
- { field: col.id, ascending: $col.sens == 'dn' ? false : true }
444
+ { field: col.id, ascending: $hdr.sens == 'dn' ? false : true }
409
445
  ]);
410
446
  }
411
447
  }
@@ -457,7 +493,7 @@ class GridView extends layout_1.VLayout {
457
493
  let cidx = 0;
458
494
  let index = this.m_topIndex;
459
495
  let count = this.m_dataview ? this.m_dataview.count : 0;
460
- let full_width = 0;
496
+ let full_width = 0; // todo: +4 pixel of left border
461
497
  let even = this.m_topIndex & 1 ? true : false;
462
498
  // compute full width
463
499
  this.m_columns.forEach((col) => {
@@ -581,16 +617,16 @@ class GridView extends layout_1.VLayout {
581
617
  }
582
618
  this.m_empty_msg.show(show);
583
619
  if (full_width < rc.width) {
584
- //this.m_header.setStyleValue('width', null);
585
- //this.m_footer?.setStyleValue('width', null);
620
+ this.m_header.setStyleValue('width', null);
621
+ this.m_footer?.setStyleValue('width', null);
586
622
  this.m_container.setStyle({
587
623
  height: count * this.m_itemHeight,
588
624
  width: null
589
625
  });
590
626
  }
591
627
  else {
592
- this.m_header.setStyleValue('width', full_width + 5);
593
- this.m_footer?.setStyleValue('width', full_width + 5);
628
+ this.m_header.setStyleValue('width', full_width + 1000);
629
+ this.m_footer?.setStyleValue('width', full_width + 1000);
594
630
  this.m_container.setStyle({
595
631
  height: count * this.m_itemHeight,
596
632
  width: full_width
package/lib/x4.css CHANGED
@@ -1124,7 +1124,7 @@ textarea::selection {
1124
1124
  .x-spreadsheet .x-row,
1125
1125
  .x-grid-view .x-row {
1126
1126
  position: absolute;
1127
- width: 100%;
1127
+ width: calc(100% - 4px);
1128
1128
  border-bottom: 1px solid #f0f0f0;
1129
1129
  align-items: center;
1130
1130
  height: 2em;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "x4js",
3
- "version": "1.4.13",
3
+ "version": "1.4.14",
4
4
  "description": "X4js core files",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
package/src/gridview.ts CHANGED
@@ -76,7 +76,8 @@ export interface GridColumn {
76
76
  }
77
77
 
78
78
  interface GridColumnInternal extends GridColumn {
79
- $col: ColHeader;
79
+ $hdr: ColHeader;
80
+ $ftr: Component;
80
81
  }
81
82
 
82
83
 
@@ -421,6 +422,7 @@ export class GridView extends VLayout<GridViewProps, GridViewEventMap> {
421
422
  content: this.m_container
422
423
  });
423
424
 
425
+ let flex = false;
424
426
  let cols = this.m_columns.map((col, index) => {
425
427
 
426
428
  let cls = '@cell';
@@ -463,12 +465,19 @@ export class GridView extends VLayout<GridViewProps, GridViewEventMap> {
463
465
  events: {resize: ( e ) => resizeCol(e )}
464
466
  });
465
467
 
466
- (<any>col).$col = comp;
468
+ if( col.flex ) {
469
+ flex = true;
470
+ }
471
+
472
+ (<any>col).$hdr = comp;
467
473
  return comp;
468
474
  });
469
475
 
470
- (cols as any).push( new Flex( {} ) );
471
-
476
+ (cols as any).push( new Flex( {
477
+ ref: 'flex',
478
+ cls: flex ? '@hidden' : ''
479
+ } ) );
480
+
472
481
  // compute full width
473
482
  let full_width = 0;
474
483
  this.m_columns.forEach((col) => {
@@ -481,8 +490,7 @@ export class GridView extends VLayout<GridViewProps, GridViewEventMap> {
481
490
  style: {
482
491
  minWidth: full_width
483
492
  }
484
- });
485
-
493
+ });
486
494
 
487
495
  if( this.m_props.hasFooter ) {
488
496
  let foots = this.m_columns.map((col, index) => {
@@ -506,11 +514,15 @@ export class GridView extends VLayout<GridViewProps, GridViewEventMap> {
506
514
  }
507
515
  });
508
516
 
517
+ (col as GridColumnInternal).$ftr = comp;
509
518
  return comp;
510
519
  });
511
520
 
512
- (foots as any).push( new Flex( {} ) );
513
-
521
+ (foots as any).push( new Flex( {
522
+ ref: 'flex',
523
+ cls: flex ? '@hidden' : ''
524
+ } ) );
525
+
514
526
  this.m_footer = new HLayout({
515
527
  cls: '@footer',
516
528
  content: <any>foots,
@@ -532,9 +544,40 @@ export class GridView extends VLayout<GridViewProps, GridViewEventMap> {
532
544
 
533
545
  }
534
546
 
535
- private _on_col_resize(col, width) {
536
- this.m_columns[col].width = width;
537
- this.m_columns[col].flex = undefined;
547
+ private _on_col_resize(col: number, width: number) {
548
+
549
+ const _col = this.m_columns[col] as GridColumnInternal;
550
+
551
+ let updateFlex = false;
552
+
553
+ if( width>=0 ) {
554
+ _col.width = width;
555
+ if( _col.flex ) {
556
+ _col.$hdr.removeClass( '@flex' );
557
+ _col.flex = undefined;
558
+ updateFlex = true;
559
+ }
560
+ }
561
+ else if( width<0 && !_col.flex ) {
562
+ _col.$hdr.addClass( '@flex' );
563
+ _col.flex = 1;
564
+ updateFlex = true;
565
+ }
566
+
567
+ if( updateFlex ) {
568
+ let flex = false;
569
+ this.m_columns.forEach( c => {
570
+ if( c.flex ) {
571
+ flex = true;
572
+ }
573
+ });
574
+
575
+ this.m_header.itemWithRef( 'flex' )?.show( flex ? false : true );
576
+ if( this.m_footer ) {
577
+ this.m_footer.itemWithRef( 'flex' )?.show( flex ? false : true );
578
+ }
579
+ }
580
+
538
581
  this._updateScroll(true);
539
582
  }
540
583
 
@@ -550,22 +593,22 @@ export class GridView extends VLayout<GridViewProps, GridViewEventMap> {
550
593
 
551
594
  this.m_columns.forEach((c) => {
552
595
  if (c !== col) {
553
- (c as GridColumnInternal).$col.sorted = false;
596
+ (c as GridColumnInternal).$hdr.sorted = false;
554
597
  }
555
598
  });
556
599
 
557
- const $col = (col as GridColumnInternal).$col;
600
+ const $hdr = (col as GridColumnInternal).$hdr;
558
601
 
559
- if ($col.sorted) {
560
- $col.toggleSens( );
602
+ if ($hdr.sorted) {
603
+ $hdr.toggleSens( );
561
604
  }
562
605
  else {
563
- $col.sorted = true;
606
+ $hdr.sorted = true;
564
607
  }
565
608
 
566
609
  if (this.m_dataview) {
567
610
  this.m_dataview.sort([
568
- { field: col.id, ascending: $col.sens=='dn' ? false : true }
611
+ { field: col.id, ascending: $hdr.sens=='dn' ? false : true }
569
612
  ]);
570
613
  }
571
614
  }
@@ -630,7 +673,8 @@ export class GridView extends VLayout<GridViewProps, GridViewEventMap> {
630
673
  let cidx = 0;
631
674
  let index = this.m_topIndex;
632
675
  let count = this.m_dataview ? this.m_dataview.count : 0;
633
- let full_width = 0;
676
+
677
+ let full_width = 0; // todo: +4 pixel of left border
634
678
  let even = this.m_topIndex & 1 ? true : false;
635
679
 
636
680
  // compute full width
@@ -783,17 +827,16 @@ export class GridView extends VLayout<GridViewProps, GridViewEventMap> {
783
827
  this.m_empty_msg.show(show);
784
828
 
785
829
  if (full_width < rc.width) {
786
- //this.m_header.setStyleValue('width', null);
787
- //this.m_footer?.setStyleValue('width', null);
830
+ this.m_header.setStyleValue('width', null);
831
+ this.m_footer?.setStyleValue('width', null);
788
832
  this.m_container.setStyle({
789
833
  height: count * this.m_itemHeight,
790
834
  width: null
791
835
  });
792
836
  }
793
837
  else {
794
- this.m_header.setStyleValue('width', full_width + 5 );
795
- this.m_footer?.setStyleValue('width', full_width + 5 );
796
-
838
+ this.m_header.setStyleValue('width', full_width + 1000 );
839
+ this.m_footer?.setStyleValue('width', full_width + 1000 );
797
840
  this.m_container.setStyle({
798
841
  height: count * this.m_itemHeight,
799
842
  width: full_width
package/src/x4.less CHANGED
@@ -1312,12 +1312,13 @@ textarea {
1312
1312
  }
1313
1313
  }
1314
1314
 
1315
+ @bwidth: 4px;
1315
1316
 
1316
1317
  .x-spreadsheet,
1317
1318
  .x-grid-view {
1318
1319
 
1319
1320
  @def-height: 2em;
1320
-
1321
+
1321
1322
  min-height: 0;
1322
1323
  overflow: hidden;
1323
1324
  background-color: white;
@@ -1370,7 +1371,7 @@ textarea {
1370
1371
 
1371
1372
  .x-row {
1372
1373
  position: absolute;
1373
- width: 100%;
1374
+ width: calc( 100% - @bwidth ); // todo: border of 1st col
1374
1375
  border-bottom: 1px solid #f0f0f0;
1375
1376
  align-items: center;
1376
1377
  height: @def-height;
@@ -1400,11 +1401,11 @@ textarea {
1400
1401
  .x-grid-view {
1401
1402
  .x-footer,
1402
1403
  .x-header {
1403
- border-left: 4px solid #f0f0f0;
1404
+ border-left: @bwidth solid #f0f0f0;
1404
1405
  }
1405
1406
 
1406
1407
  .x-row {
1407
- border-left: 4px solid transparent;
1408
+ border-left: @bwidth solid transparent;
1408
1409
 
1409
1410
  &:hover {
1410
1411
  background-color: rgba(0,0,0,0.1);