x4js 2.2.59 → 2.2.61

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "x4js",
3
- "version": "2.2.59",
3
+ "version": "2.2.61",
4
4
  "type": "module",
5
5
  "main": "src/x4.ts",
6
6
  "module": "src/x4.ts",
@@ -53,9 +53,9 @@
53
53
  width: 1.5em;
54
54
  }
55
55
 
56
- #icon {
57
- height: 1.5em;
58
- width: 1.5em;
56
+ #icon {
57
+ height: 1.5em;
58
+ width: 1.5em;
59
59
  }
60
60
 
61
61
  &:not(:disabled) {
@@ -110,20 +110,24 @@
110
110
  left: 0;
111
111
  top: 0;
112
112
 
113
- .empty {
114
- position: relative;
115
- left: 50%;
116
- top: 30px;
117
- transform: translateX(-50%);
118
- width: fit-content;
119
-
120
- #icon {
121
- height: 64px;
122
- fill: var( --accent-background );
123
- opacity: 50%;
124
- }
125
- }
126
- }
113
+ &:has(.empty) {
114
+ width: 100% !important;
115
+ }
116
+
117
+ .empty {
118
+ position: absolute;
119
+ left: 50%;
120
+ top: 30px;
121
+ transform: translateX(-50%);
122
+ width: fit-content;
123
+
124
+ #icon {
125
+ height: 64px;
126
+ fill: var( --accent-background );
127
+ opacity: 50%;
128
+ }
129
+ }
130
+ }
127
131
 
128
132
  .row {
129
133
  position: absolute;
@@ -504,7 +504,7 @@ private _view: Viewport;
504
504
  }
505
505
 
506
506
  if( c instanceof Component ) {
507
- c.addClass( "column" );
507
+ c.addClass( `column ref-c${index+2}` );
508
508
  return c;
509
509
  }
510
510
 
@@ -4,6 +4,12 @@ import { Component, ComponentProps } from '../../core/component';
4
4
  import Monaco from './bin/monaco';
5
5
  import "./monaco.module.scss"
6
6
 
7
+ export type IMonarchLanguage = monaco.languages.IMonarchLanguage;
8
+ export type CompletionItem = monaco.languages.CompletionItem;
9
+ export type CompletionItemProvider = monaco.languages.CompletionItemProvider;
10
+
11
+ export { IRange, }
12
+
7
13
 
8
14
  interface MonacoEditorProps extends ComponentProps {
9
15
  language: "typescript" | "javascript" | "json" | "css" | "html" | string;
@@ -174,13 +174,14 @@ export class Popup<P extends PopupProps = PopupProps, E extends PopupEvents = Po
174
174
  this.setStyleValue( "left", x );
175
175
  this.setStyleValue( "top", y );
176
176
 
177
- //TODO: check is already visible
177
+ //TODO: check is already visible
178
178
  this._do_show( ); // to compute size
179
179
 
180
- const rc = this.getBoundingRect( ).scale( 1/zm );
180
+ const rc = this.getBoundingRect( ).scale( 1/zm );
181
181
  const sbw = getScrollbarSize( );
182
182
 
183
183
  const screen_width = window.innerWidth - sbw;
184
+
184
185
  if( rc.right>screen_width ) {
185
186
  this.setStyleValue( "left", screen_width-rc.width );
186
187
  }
@@ -101,7 +101,7 @@
101
101
  &.odd:not(:disabled) {
102
102
  background-color: var(--propertygrid-odd-background)
103
103
  }
104
-
104
+
105
105
  &.odd:disabled {
106
106
  background-color: var(--propertygrid-disabled-background)
107
107
  }
@@ -17,6 +17,7 @@
17
17
 
18
18
  .x4csizer {
19
19
  position: absolute;
20
+ touch-action: none;
20
21
 
21
22
  @mixin horz {
22
23
  left: 0;
@@ -89,6 +89,7 @@ export class CSizer extends Component<ComponentProps,CSizerEvent> {
89
89
  }
90
90
 
91
91
  this.fire( "start", { })
92
+ e.preventDefault( );
92
93
  });
93
94
 
94
95
  this.addDOMEvent( "pointerup", ( e: PointerEvent ) => {
@@ -183,7 +184,7 @@ export class CSizer extends Component<ComponentProps,CSizerEvent> {
183
184
  return;
184
185
  }
185
186
  else {
186
- this._ref.setStyle( nr );
187
+ this._ref.setStyle( nr );
187
188
  }
188
189
 
189
190
  const nrc = this._ref.getBoundingRect( );
@@ -65,3 +65,9 @@
65
65
  }
66
66
  }
67
67
 
68
+ .x4tabs.inline {
69
+ &> .body {
70
+ border: none;
71
+ border-top: 1px solid var( --border );
72
+ }
73
+ }
@@ -17,10 +17,16 @@
17
17
  :root {
18
18
  --tickline-axis-color: var( --border );
19
19
  --tickline-color: var( --accent-color );
20
+ --tickline-width: 1px;
20
21
  --tickline-background: white;
21
22
  }
22
23
 
23
- .x-tick-line {
24
+ .x4tickline {
24
25
  position: relative;
25
26
  background-color: var( --tickline-background );
27
+
28
+ // .tickline-line {
29
+ // stroke: var( --tickline-color );
30
+ // stroke-width: var( --tickline-width );
31
+ // }
26
32
  }
@@ -3,6 +3,7 @@ import { Color } from '../../core/core_colors';
3
3
  import { Component, ComponentProps } from '../../core/component';
4
4
 
5
5
  import "./tickline.module.scss"
6
+ import { class_ns } from '../../core/core_tools.ts';
6
7
 
7
8
  interface TickLineProps extends ComponentProps {
8
9
  values: number[];
@@ -11,6 +12,10 @@ interface TickLineProps extends ComponentProps {
11
12
  color?: Color;
12
13
  background?: Color;
13
14
  type: "bars" | "line";
15
+ display?: {
16
+ tooltips?: boolean; // display values tootips
17
+ axis?: boolean; // display axis
18
+ }
14
19
  }
15
20
 
16
21
  /**
@@ -21,8 +26,12 @@ interface TickLineProps extends ComponentProps {
21
26
  * --tickline-color
22
27
  * --tickline-background
23
28
  * ```
29
+ *
30
+ * by default values are in percent.
31
+ *
24
32
  */
25
33
 
34
+ @class_ns( "x4" )
26
35
  export class TickLine extends Component<TickLineProps> {
27
36
 
28
37
  constructor( props: TickLineProps ) {
@@ -34,30 +43,39 @@ export class TickLine extends Component<TickLineProps> {
34
43
  update( ) {
35
44
  const props = this.props;
36
45
  const vals = props.values;
46
+ const padding = 4;
37
47
 
38
48
  if( !vals.length ) {
39
49
  this.clearContent( );
40
50
  return;
41
51
  }
42
52
 
43
- const rc = this.getBoundingRect( );
44
- const min = props.min ?? 0;
53
+ const rc = this.getBoundingRect( ).moveTo(0,0).inflate( -padding );
54
+
55
+ const min = props.min ?? 0;
45
56
  const max = props.max ?? 100;
46
57
 
47
- const xmul = rc.width/vals.length;
58
+ if( max<=min || rc.width<=0 || rc.height<=0 ) {
59
+ this.clearContent( );
60
+ return;
61
+ }
62
+
63
+ const xmul = props.type=="line" ? rc.width/(vals.length-1) : rc.width/vals.length;
48
64
  const ymul = rc.height/(max-min);
49
65
 
66
+ const b = rc.bottom;
67
+
50
68
  const bld = new SvgBuilder( );
51
69
 
52
70
  if( props.background ) {
53
- bld.rect( 0, 0, rc.width, rc.height )
71
+ bld.rect( 0, 0, rc.width+padding*2, rc.height+padding*2 )
54
72
  .fill( props.background.toHexString() );
55
73
  }
56
74
 
57
- if( min!=0 ) {
75
+ if( min!=0 || props.display?.axis ) {
58
76
  bld.path( )
59
- .moveTo( 0, 0-min )
60
- .lineTo( rc.width, 0-min )
77
+ .moveTo( rc.left, b-(0-min)*ymul )
78
+ .lineTo( rc.right, b-(0-min)*ymul )
61
79
  .stroke( "var(--tickline-axis-color)", 1 )
62
80
  .antiAlias( false )
63
81
  }
@@ -66,10 +84,10 @@ export class TickLine extends Component<TickLineProps> {
66
84
  const pth = bld.path( );
67
85
  for( let x=0; x<vals.length; x++ ) {
68
86
  if( x==0 ) {
69
- pth.moveTo( x*xmul, (vals[x]-min)*ymul );
87
+ pth.moveTo( rc.left+x*xmul, b-(vals[x]-min)*ymul );
70
88
  }
71
89
  else {
72
- pth.lineTo( x*xmul, (vals[x]-min)*ymul );
90
+ pth.lineTo( rc.left+x*xmul, b-(vals[x]-min)*ymul );
73
91
  }
74
92
  }
75
93
 
@@ -78,14 +96,27 @@ export class TickLine extends Component<TickLineProps> {
78
96
  }
79
97
  else {
80
98
  for( let x=0; x<vals.length; x++ ) {
81
- bld.rect( x*xmul, (0-min)*ymul, xmul-1, vals[x]*ymul )
99
+ const r = bld.rect( rc.left+x*xmul, b-(vals[x]-min)*ymul, xmul-1, (vals[x]-min)*ymul )
82
100
  .fill( props.color ? props.color.toHexString() : "var(--tickline-color)" )
83
- .antiAlias( false );
101
+ .antiAlias( false );
102
+
103
+ if( props.display?.tooltips ) {
104
+ r.setAttr( 'tooltip', vals[x].toFixed(1) )
105
+ }
84
106
  }
85
107
  }
86
108
 
87
-
88
-
89
109
  this.setContent( new SvgComponent( {width: "100%", height: "100%", svg: bld, attrs: { viewport:`0 ${props.min??0} ${vals.length} ${props.max??100}` } } ) );
90
110
  }
111
+
112
+ setValues( values: number[], options? : { min: number, max: number } ) {
113
+
114
+ options = { min: 0, max: 100, ...options };
115
+
116
+ this.props.values = values;
117
+ this.props.min = options.min;
118
+ this.props.max = options.max;
119
+
120
+ this.update( );
121
+ }
91
122
  }
@@ -39,7 +39,6 @@
39
39
 
40
40
  border: 1px solid var( --tooltip-border );
41
41
  background-color: var( --tooltip-background );
42
-
43
42
  width: max-content;
44
43
 
45
44
  .x4icon {
@@ -865,7 +865,7 @@ export class Component<P extends ComponentProps = ComponentProps, E extends Comp
865
865
  */
866
866
 
867
867
  isVisible( ) {
868
- return (this.dom as HTMLElement).offsetParent !== null;
868
+ return this.dom.isConnected && this.dom.checkVisibility( {checkVisibilityCSS: true, } );
869
869
  }
870
870
 
871
871
  /**
@@ -88,7 +88,7 @@ export class Color {
88
88
  if( value.startsWith('#') ) {
89
89
  if (value.length == 7 && /#[0-9a-fA-F]{6}/.test(value)) {
90
90
  const hex = parseInt(value.slice(1), 16);
91
- return this.setRgb( hex >> 16, hex >> 8, hex, 1.0 );
91
+ return this.setRgb( (hex >> 16)&0xff, (hex >> 8)&0xff, (hex)&0xff, 1.0 );
92
92
  }
93
93
 
94
94
  if (value.length == 4 && /#[0-9a-fA-F]{3}/.test(value)) {
@@ -98,7 +98,7 @@ export class Color {
98
98
 
99
99
  if (value.length == 9 && /#[0-9a-fA-F]{8}/.test(value)) {
100
100
  const hex = parseInt(value.slice(1), 16) >>> 0;
101
- return this.setRgb( hex >> 24, hex >> 16, hex >> 8, (hex & 0xFF) / 255.0 );
101
+ return this.setRgb( (hex >> 24)&0xff, (hex >> 16)&0xff, (hex >> 8)&0xff, (hex & 0xFF) / 255.0 );
102
102
  }
103
103
  }
104
104
  else {
@@ -131,7 +131,7 @@ export class Color {
131
131
  else {
132
132
  const xx = CSS_COLORS[value];
133
133
  if( xx!==undefined ) {
134
- return this.setRgb( xx>>16, xx>>8, xx, 1.0 );
134
+ return this.setRgb( (xx>>16)&0xff, (xx>>8)&0xff, (xx)&0xff, 1.0 );
135
135
  }
136
136
  else if( value=="transparent" ) {
137
137
  return this.setRgb( 0, 0, 0, 0 );
@@ -119,17 +119,17 @@ export namespace data {
119
119
  **/
120
120
 
121
121
  export function id( ) {
122
- return ( ownerCls: any, fldName: string ) => {
123
- let metas = _getMetas( ownerCls );
124
- metas.fields.push( {
125
- name: fldName,
126
- type: 'any',
127
- required: true,
128
- });
129
-
130
- metas.id = fldName;
131
- }
132
- }
122
+ return ( ownerCls: any, fldName: string ) => {
123
+ let metas = _getMetas( ownerCls );
124
+ metas.fields.push( {
125
+ name: fldName,
126
+ type: 'any',
127
+ required: true,
128
+ });
129
+
130
+ metas.id = fldName;
131
+ }
132
+ }
133
133
 
134
134
  /**
135
135
  * @ignore
@@ -254,6 +254,12 @@ export namespace data {
254
254
 
255
255
  export class DataModel<T = any> {
256
256
 
257
+ constructor( fields?: FieldInfo[] ) {
258
+ if( fields && fields.length ) {
259
+ this.addField( ...fields );
260
+ }
261
+ }
262
+
257
263
  /**
258
264
  * dynamic DataModel
259
265
  */
@@ -845,6 +845,9 @@ export class SvgGroup extends SvgItem {
845
845
  h = -h;
846
846
  }
847
847
 
848
+ console.assert( w>=0 );
849
+ console.assert( h>=0 );
850
+
848
851
  const shape = new SvgShape( 'rect' );
849
852
  shape.setAttr( 'x', num(x)+'' );
850
853
  shape.setAttr( 'y', num(y)+'' );
@@ -221,7 +221,7 @@ export class Rect implements IRect {
221
221
  this.left -= dx;
222
222
  this.width += dx+dx;
223
223
  this.top -= dy;
224
- this.width += dy+dy;
224
+ this.height += dy+dy;
225
225
 
226
226
  return this;
227
227
  }
@@ -234,6 +234,13 @@ export class Rect implements IRect {
234
234
 
235
235
  return this;
236
236
  }
237
+
238
+ moveTo( x: number, y: number ) {
239
+ this.left = x;
240
+ this.top = x;
241
+
242
+ return this;
243
+ }
237
244
  }
238
245
 
239
246
  /**
@@ -984,11 +991,11 @@ export function setWaitCursor(wait: boolean) {
984
991
 
985
992
  const FOCUSABLE = [
986
993
  'button:not([tabindex="-1"])',
987
- '[href]',
994
+ '[href]',
988
995
  'input',
989
996
  'select',
990
997
  'textarea',
991
- '[tabindex]:not([tabindex="-1"])'
998
+ '[tabindex]:not([tabindex="-1"])'
992
999
  ] .map( x => x+':not(:disabled):not([inert])' )
993
1000
  .join( ',' );
994
1001