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
|
@@ -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",
|
|
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
|
-
|
|
155
|
+
this.props.target?.setStyleVariable( `--${item.name}-width`, width + "px");
|
|
141
156
|
}
|
|
142
157
|
|
|
143
158
|
fullw += width;
|
package/src/core/core_data.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* @file core_data.ts
|
|
9
9
|
* @author Etienne Cochard
|
|
10
10
|
*
|
|
11
|
-
* @copyright (c)
|
|
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 =
|
|
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
|
-
(
|
|
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
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
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
|
-
|
|
258
|
-
|
|
259
|
-
|
|
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
|
-
|
|
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
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
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
|
-
|
|
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
|
|
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[] ) {
|