x4js 2.2.65 → 2.2.68

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.65",
3
+ "version": "2.2.68",
4
4
  "type": "module",
5
5
  "main": "src/x4.ts",
6
6
  "module": "src/x4.ts",
@@ -17,7 +17,7 @@
17
17
  .cell {
18
18
  border-bottom: 1px solid transparent;
19
19
  overflow: hidden;
20
- min-width: 3rem;
20
+ //min-width: 3rem;
21
21
 
22
22
  transition: border-color 0.5s ease;
23
23
  padding: 4px;
@@ -18,6 +18,8 @@ interface HeaderProps extends Omit<ComponentProps,"content"> {
18
18
  target?: Component; // target element to set header col variable width var( --{name}-width ) parent element if not set
19
19
  }
20
20
 
21
+ const CELL_MW = 8;
22
+
21
23
  /**
22
24
  * by default when a header item is resized, the 'target' style '--{name}-width' is updated
23
25
  *
@@ -63,10 +65,19 @@ export class Header extends HBox<HeaderProps> {
63
65
  this._calc_sizes( );
64
66
  })
65
67
 
68
+ sizer.on( "start", ( ) => {
69
+ //todo: remove flex on all cols
70
+ } );
71
+
72
+ sizer.on( "stop", ( ) => {
73
+ //todo: restore flex
74
+ } );
75
+
66
76
  sizer.on( "resize", ( ev ) => {
67
77
  //cell.setStyleValue( "flexGrow", "0" );
78
+ const sze = ev.size<CELL_MW ? CELL_MW : ev.size;
68
79
  cell.setInternalData("flex",0);
69
- cell.setInternalData("width",ev.size);
80
+ cell.setInternalData("width",sze);
70
81
  this._calc_sizes( );
71
82
  });
72
83
 
@@ -129,6 +140,10 @@ export class Header extends HBox<HeaderProps> {
129
140
  width = c.getInternalData( "width" );
130
141
  }
131
142
 
143
+ if( width<CELL_MW ) {
144
+ width = CELL_MW;
145
+ }
146
+
132
147
  c.setWidth( width );
133
148
 
134
149
  const item = c.getInternalData<HeaderItem>( 'data' );
@@ -137,7 +152,7 @@ export class Header extends HBox<HeaderProps> {
137
152
  this.parentElement().setStyleVariable( `--${item.name}-width`, width + "px");
138
153
  }
139
154
  else {
140
- this.props.target?.setStyleVariable( `--${item.name}-width`, width + "px");
155
+ this.props.target?.setStyleVariable( `--${item.name}-width`, width + "px");
141
156
  }
142
157
 
143
158
  fullw += width;
@@ -8,7 +8,7 @@
8
8
  * @file core_data.ts
9
9
  * @author Etienne Cochard
10
10
  *
11
- * @copyright (c) 2026 R-libre ingenierie
11
+ * @copyright (c) 2024 R-libre ingenierie
12
12
  *
13
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.
@@ -78,7 +78,18 @@ const metaFields = Symbol( 'metaField' );
78
78
  function _getMetas( obj: object, create = true ) : MetaInfos {
79
79
 
80
80
  let ctor = obj.constructor as any;
81
- let mfld = Object.prototype.hasOwnProperty.call(ctor,metaFields) ? ctor[metaFields] : undefined;
81
+ let mfld = null;
82
+ let direct = false;
83
+
84
+ // comming from new DataModel(...)
85
+ if( ctor.name=="DataModel" ) {
86
+ direct = true;
87
+ mfld = (obj as any)[metaFields];
88
+ }
89
+ // standard @data....
90
+ else {
91
+ mfld = Object.prototype.hasOwnProperty.call(ctor,metaFields) ? ctor[metaFields] : undefined;
92
+ }
82
93
 
83
94
  if( mfld===undefined ) {
84
95
  if( !create && ctor!=DataModel ) {
@@ -102,7 +113,12 @@ function _getMetas( obj: object, create = true ) : MetaInfos {
102
113
  }
103
114
  }
104
115
 
105
- (obj.constructor as any)[metaFields] = mfld;
116
+ if( !direct ) {
117
+ (obj.constructor as any)[metaFields] = mfld;
118
+ }
119
+ else {
120
+ (obj as any)[metaFields] = mfld;
121
+ }
106
122
  }
107
123
 
108
124
  return mfld;
@@ -119,17 +135,17 @@ export namespace data {
119
135
  **/
120
136
 
121
137
  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
- }
138
+ return ( ownerCls: any, fldName: string ) => {
139
+ let metas = _getMetas( ownerCls );
140
+ metas.fields.push( {
141
+ name: fldName,
142
+ type: 'any',
143
+ required: true,
144
+ });
145
+
146
+ metas.id = fldName;
147
+ }
148
+ }
133
149
 
134
150
  /**
135
151
  * @ignore
@@ -254,12 +270,12 @@ export namespace data {
254
270
 
255
271
  export class DataModel<T = any> {
256
272
 
257
- constructor( fields?: FieldInfo[] ) {
258
- if( fields && fields.length ) {
259
- this.addField( ...fields );
260
- }
261
- }
262
-
273
+ constructor( fields?: FieldInfo[] ) {
274
+ if( fields ) {
275
+ this.addField( ...fields );
276
+ }
277
+ }
278
+
263
279
  /**
264
280
  * dynamic DataModel
265
281
  */
@@ -270,11 +286,11 @@ export class DataModel<T = any> {
270
286
  }
271
287
 
272
288
  let metas = _getMetas( this, false );
273
- if( metas.fields.length==0 ) {
289
+ metas.fields.push( ...fields );
290
+
291
+ if( !metas.id ) {
274
292
  metas.id = fields[0].name;
275
293
  }
276
-
277
- metas.fields.push( ...fields );
278
294
  }
279
295
 
280
296
  /**
@@ -523,24 +539,16 @@ export class DataProxy extends CoreElement<DataEventMap> {
523
539
  url += '?' + this.m_props.params.join( '&' );
524
540
  }
525
541
 
526
- try {
527
- const r = await fetch( url );
528
- if( r.ok ) {
529
- const raw = await r.json( );
530
-
531
- let json = raw;
532
- if( this.m_props.solver ) {
533
- json = this.m_props.solver( json );
534
- }
535
-
536
- this.fire( 'change', {value:json,context:raw} );
537
- }
538
- else {
539
- console.error( r.statusText );
542
+ const r = await fetch( url );
543
+ if( r.ok ) {
544
+ const raw = await r.json( );
545
+
546
+ let json = raw;
547
+ if( this.m_props.solver ) {
548
+ json = this.m_props.solver( json );
540
549
  }
541
- }
542
- catch( e ) {
543
- console.error( e );
550
+
551
+ this.fire( 'change', {value:json,context:raw} );
544
552
  }
545
553
  }
546
554
  }
@@ -608,6 +616,7 @@ export class DataStore<T = any> extends EventSource<DataStoreEventMap> {
608
616
 
609
617
  /**
610
618
  *
619
+ * @param records
611
620
  */
612
621
 
613
622
  async load( url?: string ) {
@@ -671,7 +680,7 @@ export class DataStore<T = any> extends EventSource<DataStoreEventMap> {
671
680
 
672
681
  /**
673
682
  *
674
- * @param rec
683
+ * @param data
675
684
  */
676
685
 
677
686
  public appendRaw( rec: T ) {
@@ -1211,6 +1220,8 @@ export class DataView extends CoreElement<DataViewEventMap>
1211
1220
 
1212
1221
  /**
1213
1222
  *
1223
+ * @param columns
1224
+ * @param ascending
1214
1225
  */
1215
1226
 
1216
1227
  public sort( props: SortProp[] ) {