x4js 2.2.60 → 2.2.62

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.60",
3
+ "version": "2.2.62",
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,11 +4,10 @@ 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, }
7
+ export type IMonarchLanguage = Monaco.languages.IMonarchLanguage;
8
+ export type CompletionItem = Monaco.languages.CompletionItem;
9
+ export type CompletionItemProvider = Monaco.languages.CompletionItemProvider;
10
+ export type IRange = Monaco.IRange;
12
11
 
13
12
 
14
13
  interface MonacoEditorProps extends ComponentProps {
@@ -145,10 +145,11 @@ export class Popup<P extends PopupProps = PopupProps, E extends PopupEvents = Po
145
145
  this._do_show( ); // to compute size
146
146
 
147
147
  const fixpos = ( ) => {
148
- const orc = this.getBoundingRect( );
148
+ const self = this.dom as HTMLElement;
149
+
149
150
  this.setStyle( {
150
- left: ((window.innerWidth - orc.width) / 2) +'px',
151
- top: ((window.innerHeight - orc.height) / 2) +'px',
151
+ left: ((document.body.offsetWidth - self.offsetWidth) / 2) +'px',
152
+ top: ((document.body.offsetHeight - self.offsetHeight) / 2) +'px',
152
153
  } );
153
154
  }
154
155
 
@@ -174,13 +175,14 @@ export class Popup<P extends PopupProps = PopupProps, E extends PopupEvents = Po
174
175
  this.setStyleValue( "left", x );
175
176
  this.setStyleValue( "top", y );
176
177
 
177
- //TODO: check is already visible
178
+ //TODO: check is already visible
178
179
  this._do_show( ); // to compute size
179
180
 
180
- const rc = this.getBoundingRect( ).scale( 1/zm );
181
+ const rc = this.getBoundingRect( ).scale( 1/zm );
181
182
  const sbw = getScrollbarSize( );
182
183
 
183
184
  const screen_width = window.innerWidth - sbw;
185
+
184
186
  if( rc.right>screen_width ) {
185
187
  this.setStyleValue( "left", screen_width-rc.width );
186
188
  }
@@ -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
  }
@@ -184,7 +184,7 @@ export class CSizer extends Component<ComponentProps,CSizerEvent> {
184
184
  return;
185
185
  }
186
186
  else {
187
- this._ref.setStyle( nr );
187
+ this._ref.setStyle( nr );
188
188
  }
189
189
 
190
190
  const nrc = this._ref.getBoundingRect( );
@@ -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
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
  }
@@ -1,9 +1,9 @@
1
1
  import { SvgBuilder, SvgComponent } from '../../core/core_svg';
2
2
  import { Color } from '../../core/core_colors';
3
3
  import { Component, ComponentProps } from '../../core/component';
4
- import { class_ns } from '../../core/core_tools';
5
4
 
6
5
  import "./tickline.module.scss"
6
+ import { class_ns } from '../../core/core_tools';
7
7
 
8
8
  interface TickLineProps extends ComponentProps {
9
9
  values: number[];
@@ -12,6 +12,10 @@ interface TickLineProps extends ComponentProps {
12
12
  color?: Color;
13
13
  background?: Color;
14
14
  type: "bars" | "line";
15
+ display?: {
16
+ tooltips?: boolean; // display values tootips
17
+ axis?: boolean; // display axis
18
+ }
15
19
  }
16
20
 
17
21
  /**
@@ -22,6 +26,9 @@ interface TickLineProps extends ComponentProps {
22
26
  * --tickline-color
23
27
  * --tickline-background
24
28
  * ```
29
+ *
30
+ * by default values are in percent.
31
+ *
25
32
  */
26
33
 
27
34
  @class_ns( "x4" )
@@ -36,32 +43,39 @@ export class TickLine extends Component<TickLineProps> {
36
43
  update( ) {
37
44
  const props = this.props;
38
45
  const vals = props.values;
46
+ const padding = 4;
39
47
 
40
48
  if( !vals.length ) {
41
49
  this.clearContent( );
42
50
  return;
43
51
  }
44
52
 
45
- const rc = this.getBoundingRect( );
46
- const min = props.min ?? 0;
53
+ const rc = this.getBoundingRect( ).moveTo(0,0).inflate( -padding );
54
+
55
+ const min = props.min ?? 0;
47
56
  const max = props.max ?? 100;
48
57
 
49
- 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;
50
64
  const ymul = rc.height/(max-min);
51
65
 
52
- const b = rc.height;
66
+ const b = rc.bottom;
53
67
 
54
68
  const bld = new SvgBuilder( );
55
69
 
56
70
  if( props.background ) {
57
- bld.rect( 0, 0, rc.width, rc.height )
71
+ bld.rect( 0, 0, rc.width+padding*2, rc.height+padding*2 )
58
72
  .fill( props.background.toHexString() );
59
73
  }
60
74
 
61
- if( min!=0 ) {
75
+ if( min!=0 || props.display?.axis ) {
62
76
  bld.path( )
63
- .moveTo( 0, b-(0-min)*ymul )
64
- .lineTo( rc.width, b-(0-min)*ymul )
77
+ .moveTo( rc.left, b-(0-min)*ymul )
78
+ .lineTo( rc.right, b-(0-min)*ymul )
65
79
  .stroke( "var(--tickline-axis-color)", 1 )
66
80
  .antiAlias( false )
67
81
  }
@@ -70,10 +84,10 @@ export class TickLine extends Component<TickLineProps> {
70
84
  const pth = bld.path( );
71
85
  for( let x=0; x<vals.length; x++ ) {
72
86
  if( x==0 ) {
73
- pth.moveTo( x*xmul, b-(vals[x]-min)*ymul );
87
+ pth.moveTo( rc.left+x*xmul, b-(vals[x]-min)*ymul );
74
88
  }
75
89
  else {
76
- pth.lineTo( x*xmul, b-(vals[x]-min)*ymul );
90
+ pth.lineTo( rc.left+x*xmul, b-(vals[x]-min)*ymul );
77
91
  }
78
92
  }
79
93
 
@@ -82,14 +96,27 @@ export class TickLine extends Component<TickLineProps> {
82
96
  }
83
97
  else {
84
98
  for( let x=0; x<vals.length; x++ ) {
85
- bld.rect( x*xmul, b-(0-min)*ymul, xmul-1, b-vals[x]*ymul )
99
+ const r = bld.rect( rc.left+x*xmul, b-(vals[x]-min)*ymul, xmul-1, (vals[x]-min)*ymul )
86
100
  .fill( props.color ? props.color.toHexString() : "var(--tickline-color)" )
87
- .antiAlias( false );
101
+ .antiAlias( false );
102
+
103
+ if( props.display?.tooltips ) {
104
+ r.setAttr( 'tooltip', vals[x].toFixed(1) )
105
+ }
88
106
  }
89
107
  }
90
108
 
91
-
92
-
93
109
  this.setContent( new SvgComponent( {width: "100%", height: "100%", svg: bld, attrs: { viewport:`0 ${props.min??0} ${vals.length} ${props.max??100}` } } ) );
94
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
+ }
95
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
  /**
@@ -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
 
package/src/x4.d.ts CHANGED
@@ -1,20 +1,33 @@
1
- /**
1
+ /**
2
2
  * ___ ___ __
3
3
  * \ \/ / / _
4
4
  * \ / /_| |_
5
- * / \____ _|
6
- * /__/\__\ |_|.2
7
- *
8
- * @file x4.d.ts
9
- * @author Etienne Cochard
10
- *
5
+ * / \____ _|
6
+ * /__/\__\ |_|
7
+ *
8
+ * @file x4.ts
9
+ * @author Etienne Cochard
10
+ *
11
11
  * @copyright (c) 2026 R-libre ingenierie
12
12
  *
13
- * Use of this source code is governed by an MIT-style license
13
+ * Use of this source code is governed by an MIT-style license
14
14
  * that can be found in the LICENSE file or at https://opensource.org/licenses/MIT.
15
15
  **/
16
-
17
- declare module "*.svg" {
18
- const content: string;
19
- export default content;
20
- }
16
+ export * from "./core/component";
17
+ export * from "./core/core_application";
18
+ export * from "./core/core_colors";
19
+ export * from "./core/core_data";
20
+ export * from "./core/core_dom";
21
+ export * from "./core/core_dragdrop";
22
+ export * from "./core/core_element";
23
+ export * from "./core/core_events";
24
+ export * from "./core/core_i18n";
25
+ export * from "./core/core_pdf";
26
+ export * from "./core/core_react";
27
+ export * from "./core/core_router";
28
+ export * from "./core/core_state";
29
+ export * from "./core/core_styles";
30
+ export * from "./core/core_svg";
31
+ export * from "./core/core_tools";
32
+ export * from "./components/components";
33
+ import "./x4.scss";