x4js 1.4.11 → 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
@@ -60,7 +60,7 @@ class ColHeader extends component_1.Component {
60
60
  }),
61
61
  new icon_js_1.Icon({
62
62
  ref: 'sorter',
63
- cls: '@hidden',
63
+ cls: '@hidden sort',
64
64
  icon: 'var( --x4-icon-arrow-down )'
65
65
  })
66
66
  ]);
@@ -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,9 +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
  });
335
+ cols.push(new component_1.Flex({
336
+ ref: 'flex',
337
+ cls: flex ? '@hidden' : ''
338
+ }));
331
339
  // compute full width
332
340
  let full_width = 0;
333
341
  this.m_columns.forEach((col) => {
@@ -357,8 +365,13 @@ class GridView extends layout_1.VLayout {
357
365
  width: col.width
358
366
  }
359
367
  });
368
+ col.$ftr = comp;
360
369
  return comp;
361
370
  });
371
+ foots.push(new component_1.Flex({
372
+ ref: 'flex',
373
+ cls: flex ? '@hidden' : ''
374
+ }));
362
375
  this.m_footer = new layout_1.HLayout({
363
376
  cls: '@footer',
364
377
  content: foots,
@@ -378,8 +391,33 @@ class GridView extends layout_1.VLayout {
378
391
  ]);
379
392
  }
380
393
  _on_col_resize(col, width) {
381
- this.m_columns[col].width = width;
382
- 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
+ }
383
421
  this._updateScroll(true);
384
422
  }
385
423
  /**
@@ -391,19 +429,19 @@ class GridView extends layout_1.VLayout {
391
429
  }
392
430
  this.m_columns.forEach((c) => {
393
431
  if (c !== col) {
394
- c.$col.sorted = false;
432
+ c.$hdr.sorted = false;
395
433
  }
396
434
  });
397
- const $col = col.$col;
398
- if ($col.sorted) {
399
- $col.toggleSens();
435
+ const $hdr = col.$hdr;
436
+ if ($hdr.sorted) {
437
+ $hdr.toggleSens();
400
438
  }
401
439
  else {
402
- $col.sorted = true;
440
+ $hdr.sorted = true;
403
441
  }
404
442
  if (this.m_dataview) {
405
443
  this.m_dataview.sort([
406
- { field: col.id, ascending: $col.sens == 'dn' ? false : true }
444
+ { field: col.id, ascending: $hdr.sens == 'dn' ? false : true }
407
445
  ]);
408
446
  }
409
447
  }
@@ -455,7 +493,7 @@ class GridView extends layout_1.VLayout {
455
493
  let cidx = 0;
456
494
  let index = this.m_topIndex;
457
495
  let count = this.m_dataview ? this.m_dataview.count : 0;
458
- let full_width = 0;
496
+ let full_width = 0; // todo: +4 pixel of left border
459
497
  let even = this.m_topIndex & 1 ? true : false;
460
498
  // compute full width
461
499
  this.m_columns.forEach((col) => {
@@ -587,8 +625,8 @@ class GridView extends layout_1.VLayout {
587
625
  });
588
626
  }
589
627
  else {
590
- this.m_header.setStyleValue('width', full_width);
591
- this.m_footer?.setStyleValue('width', full_width);
628
+ this.m_header.setStyleValue('width', full_width + 1000);
629
+ this.m_footer?.setStyleValue('width', full_width + 1000);
592
630
  this.m_container.setStyle({
593
631
  height: count * this.m_itemHeight,
594
632
  width: full_width
package/lib/tooltips.js CHANGED
@@ -47,7 +47,7 @@ class Tooltip extends component_1.Component {
47
47
  render() {
48
48
  this.setClass('@non-maskable', true);
49
49
  this.setContent([
50
- new icon_1.Icon({ icon: 'var( --x4-icon-tip' }),
50
+ new icon_1.Icon({ icon: 'var( --x4-icon-tip )' }),
51
51
  this.m_text = new label_1.Label({ text: 'help' })
52
52
  ]);
53
53
  }
package/lib/x4.css CHANGED
@@ -1113,20 +1113,9 @@ textarea::selection {
1113
1113
  .x-grid-view .x-footer .x-cell.sort,
1114
1114
  .x-spreadsheet .x-header .x-cell.sort,
1115
1115
  .x-grid-view .x-header .x-cell.sort {
1116
- background-image: var(--x4-icon-arrow-down-long);
1117
- background-repeat: no-repeat;
1118
- background-size: 1rem 1rem;
1119
- background-position: right 0 top 6px;
1120
- padding-right: calc(1rem + 4px);
1121
1116
  height: 0.7rem;
1122
1117
  opacity: 0.7;
1123
1118
  }
1124
- .x-spreadsheet .x-footer .x-cell.sort.desc,
1125
- .x-grid-view .x-footer .x-cell.sort.desc,
1126
- .x-spreadsheet .x-header .x-cell.sort.desc,
1127
- .x-grid-view .x-header .x-cell.sort.desc {
1128
- background-image: var(--x4-icon-arrow-up-long);
1129
- }
1130
1119
  .x-spreadsheet .x-header .x-cell,
1131
1120
  .x-grid-view .x-header .x-cell {
1132
1121
  display: flex;
@@ -1135,7 +1124,7 @@ textarea::selection {
1135
1124
  .x-spreadsheet .x-row,
1136
1125
  .x-grid-view .x-row {
1137
1126
  position: absolute;
1138
- width: 100%;
1127
+ width: calc(100% - 4px);
1139
1128
  border-bottom: 1px solid #f0f0f0;
1140
1129
  align-items: center;
1141
1130
  height: 2em;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "x4js",
3
- "version": "1.4.11",
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
@@ -36,7 +36,7 @@ const T_UPDATE = Symbol('update');
36
36
 
37
37
 
38
38
  import { HLayout, VLayout } from './layout'
39
- import { Component, ContainerEventMap, EvSize, EvDblClick, CProps, flyWrap, html, HtmlString, SizerOverlay } from './component'
39
+ import { Component, ContainerEventMap, EvSize, EvDblClick, CProps, flyWrap, html, HtmlString, SizerOverlay, Flex } from './component'
40
40
  import { Label } from './label'
41
41
  import { _tr } from './i18n'
42
42
  import * as Formatters from './formatters'
@@ -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
 
@@ -122,7 +123,7 @@ class ColHeader extends Component {
122
123
  }),
123
124
  new Icon( {
124
125
  ref: 'sorter',
125
- cls: '@hidden',
126
+ cls: '@hidden sort',
126
127
  icon: 'var( --x4-icon-arrow-down )'
127
128
  })
128
129
  ]);
@@ -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,10 +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
 
476
+ (cols as any).push( new Flex( {
477
+ ref: 'flex',
478
+ cls: flex ? '@hidden' : ''
479
+ } ) );
480
+
470
481
  // compute full width
471
482
  let full_width = 0;
472
483
  this.m_columns.forEach((col) => {
@@ -479,8 +490,7 @@ export class GridView extends VLayout<GridViewProps, GridViewEventMap> {
479
490
  style: {
480
491
  minWidth: full_width
481
492
  }
482
- });
483
-
493
+ });
484
494
 
485
495
  if( this.m_props.hasFooter ) {
486
496
  let foots = this.m_columns.map((col, index) => {
@@ -504,9 +514,15 @@ export class GridView extends VLayout<GridViewProps, GridViewEventMap> {
504
514
  }
505
515
  });
506
516
 
517
+ (col as GridColumnInternal).$ftr = comp;
507
518
  return comp;
508
519
  });
509
520
 
521
+ (foots as any).push( new Flex( {
522
+ ref: 'flex',
523
+ cls: flex ? '@hidden' : ''
524
+ } ) );
525
+
510
526
  this.m_footer = new HLayout({
511
527
  cls: '@footer',
512
528
  content: <any>foots,
@@ -528,9 +544,40 @@ export class GridView extends VLayout<GridViewProps, GridViewEventMap> {
528
544
 
529
545
  }
530
546
 
531
- private _on_col_resize(col, width) {
532
- this.m_columns[col].width = width;
533
- 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
+
534
581
  this._updateScroll(true);
535
582
  }
536
583
 
@@ -546,22 +593,22 @@ export class GridView extends VLayout<GridViewProps, GridViewEventMap> {
546
593
 
547
594
  this.m_columns.forEach((c) => {
548
595
  if (c !== col) {
549
- (c as GridColumnInternal).$col.sorted = false;
596
+ (c as GridColumnInternal).$hdr.sorted = false;
550
597
  }
551
598
  });
552
599
 
553
- const $col = (col as GridColumnInternal).$col;
600
+ const $hdr = (col as GridColumnInternal).$hdr;
554
601
 
555
- if ($col.sorted) {
556
- $col.toggleSens( );
602
+ if ($hdr.sorted) {
603
+ $hdr.toggleSens( );
557
604
  }
558
605
  else {
559
- $col.sorted = true;
606
+ $hdr.sorted = true;
560
607
  }
561
608
 
562
609
  if (this.m_dataview) {
563
610
  this.m_dataview.sort([
564
- { field: col.id, ascending: $col.sens=='dn' ? false : true }
611
+ { field: col.id, ascending: $hdr.sens=='dn' ? false : true }
565
612
  ]);
566
613
  }
567
614
  }
@@ -626,7 +673,8 @@ export class GridView extends VLayout<GridViewProps, GridViewEventMap> {
626
673
  let cidx = 0;
627
674
  let index = this.m_topIndex;
628
675
  let count = this.m_dataview ? this.m_dataview.count : 0;
629
- let full_width = 0;
676
+
677
+ let full_width = 0; // todo: +4 pixel of left border
630
678
  let even = this.m_topIndex & 1 ? true : false;
631
679
 
632
680
  // compute full width
@@ -787,9 +835,8 @@ export class GridView extends VLayout<GridViewProps, GridViewEventMap> {
787
835
  });
788
836
  }
789
837
  else {
790
- this.m_header.setStyleValue('width', full_width);
791
- this.m_footer?.setStyleValue('width', full_width);
792
-
838
+ this.m_header.setStyleValue('width', full_width + 1000 );
839
+ this.m_footer?.setStyleValue('width', full_width + 1000 );
793
840
  this.m_container.setStyle({
794
841
  height: count * this.m_itemHeight,
795
842
  width: full_width
package/src/tooltips.ts CHANGED
@@ -52,7 +52,7 @@ export class Tooltip extends Component {
52
52
  render() {
53
53
  this.setClass('@non-maskable', true);
54
54
  this.setContent([
55
- new Icon({ icon: 'var( --x4-icon-tip' }),
55
+ new Icon({ icon: 'var( --x4-icon-tip )' }),
56
56
  this.m_text = new Label({ text: 'help' })
57
57
  ]);
58
58
  }
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;
@@ -1355,18 +1356,9 @@ textarea {
1355
1356
  }
1356
1357
 
1357
1358
  &.sort {
1358
- background-image: var( --x4-icon-arrow-down-long );
1359
- background-repeat: no-repeat;
1360
- background-size: 1rem 1rem;
1361
- background-position: right 0 top 6px;
1362
- padding-right: calc( 1rem + 4px );
1363
1359
  height: 0.7rem;
1364
1360
  opacity: 0.7;
1365
1361
  }
1366
-
1367
- &.sort.desc {
1368
- background-image: var( --x4-icon-arrow-up-long );
1369
- }
1370
1362
  }
1371
1363
  }
1372
1364
 
@@ -1379,7 +1371,7 @@ textarea {
1379
1371
 
1380
1372
  .x-row {
1381
1373
  position: absolute;
1382
- width: 100%;
1374
+ width: calc( 100% - @bwidth ); // todo: border of 1st col
1383
1375
  border-bottom: 1px solid #f0f0f0;
1384
1376
  align-items: center;
1385
1377
  height: @def-height;
@@ -1409,11 +1401,11 @@ textarea {
1409
1401
  .x-grid-view {
1410
1402
  .x-footer,
1411
1403
  .x-header {
1412
- border-left: 4px solid #f0f0f0;
1404
+ border-left: @bwidth solid #f0f0f0;
1413
1405
  }
1414
1406
 
1415
1407
  .x-row {
1416
- border-left: 4px solid transparent;
1408
+ border-left: @bwidth solid transparent;
1417
1409
 
1418
1410
  &:hover {
1419
1411
  background-color: rgba(0,0,0,0.1);