x4js 1.4.37 → 1.4.40

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.
@@ -91,7 +91,8 @@ export interface ColorPickerEditorProps extends ColorPickerProps {
91
91
  labelWidth?: number;
92
92
  cust_colors?: Color[];
93
93
  displayValue?: false;
94
- change: EventCallback<EvChange>;
94
+ change?: EventCallback<EvChange>;
95
+ name?: string;
95
96
  }
96
97
  export declare class ColorPickerEditor extends HLayout<ColorPickerEditorProps, ColorPickerEventMap> {
97
98
  constructor(props: ColorPickerEditorProps);
package/lib/combobox.js CHANGED
@@ -131,7 +131,7 @@ class ComboBox extends layout_1.HLayout {
131
131
  */
132
132
  showPopup() {
133
133
  let props = this.m_props;
134
- if (props.readOnly) {
134
+ if (props.readOnly || this.hasClass("@disable")) {
135
135
  return;
136
136
  }
137
137
  // need creation ?
@@ -200,6 +200,11 @@ class ComboBox extends layout_1.HLayout {
200
200
  this.m_props.value = item.id;
201
201
  }
202
202
  }
203
+ else {
204
+ if (this.m_ui_input && this.m_ui_input instanceof input_1.Input) {
205
+ this.m_ui_input.value = "";
206
+ }
207
+ }
203
208
  }
204
209
  /**
205
210
  *
@@ -218,13 +223,17 @@ class ComboBox extends layout_1.HLayout {
218
223
  if ((0, tools_1.isFunction)(items)) {
219
224
  items = items();
220
225
  }
221
- items.some((v) => {
226
+ const found = items.some((v) => {
222
227
  if (v.id === id) {
223
228
  this._setInput(v);
224
229
  this.m_selection = v;
225
230
  return true;
226
231
  }
227
232
  });
233
+ if (!found) {
234
+ this._setInput(null);
235
+ this.m_selection = null;
236
+ }
228
237
  }
229
238
  get input() {
230
239
  return this.m_ui_input instanceof input_1.Input ? this.m_ui_input : null;
package/lib/dialog.js CHANGED
@@ -149,6 +149,9 @@ class Dialog extends popup_1.Popup {
149
149
  this.setStyleValue('height', this.m_props.dlgHeight + '%');
150
150
  }
151
151
  this.addClass('@resized');
152
+ if (this.m_el_title) {
153
+ this.m_el_title.setStyleValue("width", "auto");
154
+ }
152
155
  if (this.m_props.maximized) {
153
156
  this._maximize();
154
157
  this.emit('size', (0, component_1.EvSize)(null));
@@ -343,9 +346,9 @@ class Dialog extends popup_1.Popup {
343
346
  let { x, y } = (0, tools_1.getMousePos)(event, true);
344
347
  let wrc = (0, component_1.flyWrap)(x4dom_1.x4document.body).getBoundingRect();
345
348
  let rc = this.getBoundingRect(true);
346
- let trc = this.m_el_title.getBoundingRect();
349
+ ///let trc = this.m_el_title.getBoundingRect();
347
350
  let dx = x - rc.left, dy = y - rc.top;
348
- let cstyle = this.getComputedStyle();
351
+ //let cstyle = this.getComputedStyle();
349
352
  //let topw = cstyle.parse('marginTop') + cstyle.parse('paddingTop') + cstyle.parse('borderTopWidth');
350
353
  //let botw = cstyle.parse('marginBottom') + cstyle.parse('paddingBottom') + cstyle.parse('borderBottomWidth');
351
354
  //let lftw = cstyle.parse('marginLeft') + cstyle.parse('paddingLeft') + cstyle.parse('borderLeftWidth');
package/lib/gridview.js CHANGED
@@ -642,6 +642,10 @@ class GridView extends layout_1.VLayout {
642
642
  return;
643
643
  }
644
644
  const update = () => {
645
+ // element destroyed between updateScroll and now
646
+ if (!this.dom) {
647
+ return;
648
+ }
645
649
  let newTop = Math.floor(this.m_view_el.dom.scrollTop / (this.m_itemHeight || 1));
646
650
  if (newTop != this.m_topIndex || forceUpdate) {
647
651
  this.m_topIndex = newTop;
package/lib/listview.js CHANGED
@@ -481,6 +481,7 @@ class PopupListView extends popup_1.Popup {
481
481
  constructor(props) {
482
482
  super({ tabIndex: false });
483
483
  this.enableMask(false);
484
+ this.addClass("@non-maskable");
484
485
  props.tabIndex = false;
485
486
  this.m_list = new ListView(props);
486
487
  //this.m_list.addClass( '@fit' );
@@ -753,6 +753,7 @@ class Spreadsheet extends layout_1.VLayout {
753
753
  case 'Enter': {
754
754
  this.editCurCell();
755
755
  event.stopPropagation();
756
+ event.preventDefault();
756
757
  break;
757
758
  }
758
759
  case 'Delete': {
@@ -894,8 +895,8 @@ class Spreadsheet extends layout_1.VLayout {
894
895
  style: {
895
896
  left: rc.left - prc.left,
896
897
  top: rc.top - prc.top,
897
- width: rc.width,
898
- height: rc.height
898
+ width: rc.width - 1,
899
+ height: rc.height - 1
899
900
  },
900
901
  tabIndex: false,
901
902
  value: cellvalue,
@@ -931,10 +932,15 @@ class Spreadsheet extends layout_1.VLayout {
931
932
  this.killEditor(true);
932
933
  });
933
934
  input.setDomEvent('keydown', (e) => {
935
+ // prevented by edit...
936
+ if (e.defaultPrevented) {
937
+ return;
938
+ }
934
939
  switch (e.key) {
935
940
  case 'Escape': {
936
941
  this.killEditor(false);
937
942
  e.stopPropagation();
943
+ e.preventDefault();
938
944
  break;
939
945
  }
940
946
  case 'Enter':
@@ -945,18 +951,21 @@ class Spreadsheet extends layout_1.VLayout {
945
951
  }
946
952
  movesel(0, sens);
947
953
  e.stopPropagation();
954
+ e.preventDefault();
948
955
  break;
949
956
  }
950
957
  case 'ArrowUp':
951
958
  case 'Up': {
952
959
  movesel(-1, 0);
953
960
  e.stopPropagation();
961
+ e.preventDefault();
954
962
  break;
955
963
  }
956
964
  case 'ArrowDown':
957
965
  case 'Down': {
958
966
  movesel(1, 0);
959
967
  e.stopPropagation();
968
+ e.preventDefault();
960
969
  break;
961
970
  }
962
971
  }
@@ -972,6 +981,7 @@ class Spreadsheet extends layout_1.VLayout {
972
981
  case 'Escape': {
973
982
  this.killEditor(false);
974
983
  e.stopPropagation();
984
+ e.preventDefault();
975
985
  break;
976
986
  }
977
987
  case 'Enter':
@@ -982,6 +992,7 @@ class Spreadsheet extends layout_1.VLayout {
982
992
  }
983
993
  movesel(0, sens);
984
994
  e.stopPropagation();
995
+ e.preventDefault();
985
996
  break;
986
997
  }
987
998
  }
@@ -62,7 +62,7 @@ declare abstract class SVGItem {
62
62
  * @returns this
63
63
  */
64
64
  attr(name: string, value: string): this;
65
- style(name: string, value: string): this;
65
+ style(name: string, value: string | number): this;
66
66
  /**
67
67
  * add a class
68
68
  * @param name class name to add
@@ -114,13 +114,14 @@ class SVGItem {
114
114
  return this;
115
115
  }
116
116
  style(name, value) {
117
- if (value === undefined) {
118
- value = null;
117
+ if (value === undefined || value === '' || value === undefined) {
118
+ this.m_style.delete(name);
119
+ return;
119
120
  }
120
- else if (!component_1._x4_unitless[name] && ((0, tools_1.isNumber)(value) || reNumber.test(value))) {
121
+ if (!component_1._x4_unitless[name] && ((0, tools_1.isNumber)(value) || reNumber.test(value))) {
121
122
  value = value + 'px';
122
123
  }
123
- this.m_style.set(name, value);
124
+ this.m_style.set(name, '' + value);
124
125
  return this;
125
126
  }
126
127
  /**
package/lib/x4.css CHANGED
@@ -840,6 +840,7 @@ textarea::selection {
840
840
  display: flex;
841
841
  align-items: center;
842
842
  background-color: var(--x4-selection-color);
843
+ width: 0;
843
844
  }
844
845
  .x-dialog > .title .x-icon {
845
846
  width: 2em;
@@ -858,6 +859,9 @@ textarea::selection {
858
859
  .x-dialog > .title .x-label {
859
860
  border-bottom: none;
860
861
  padding: 0;
862
+ overflow: hidden;
863
+ text-overflow: ellipsis;
864
+ white-space: nowrap;
861
865
  }
862
866
  .x-dialog > .title .res-btn {
863
867
  display: none;
@@ -1149,7 +1153,7 @@ textarea::selection {
1149
1153
  .x-grid-view .x-row {
1150
1154
  position: absolute;
1151
1155
  width: calc(100% - 4px);
1152
- border-bottom: 1px solid #f0f0f0;
1156
+ border-bottom: 1px solid #d0d0d0;
1153
1157
  align-items: center;
1154
1158
  height: 2em;
1155
1159
  }
@@ -1159,7 +1163,7 @@ textarea::selection {
1159
1163
  }
1160
1164
  .x-spreadsheet .x-cell,
1161
1165
  .x-grid-view .x-cell {
1162
- border-right: 1px solid #f0f0f0;
1166
+ border-right: 1px solid #d0d0d0;
1163
1167
  }
1164
1168
  .x-spreadsheet .x-cell.center,
1165
1169
  .x-grid-view .x-cell.center {
@@ -1213,10 +1217,15 @@ textarea::selection {
1213
1217
  .x-spreadsheet .x-editor {
1214
1218
  position: absolute;
1215
1219
  min-height: 0;
1220
+ margin: 0;
1216
1221
  }
1217
1222
  .x-spreadsheet .x-editor input {
1218
1223
  margin: 0;
1219
1224
  min-height: 0;
1225
+ height: 100%;
1226
+ }
1227
+ .x-form .x-spreadsheet .x-editor {
1228
+ background-color: white;
1220
1229
  }
1221
1230
  .x-side-bar {
1222
1231
  min-width: 44px;
@@ -1293,9 +1302,13 @@ textarea::selection {
1293
1302
  background-color: white;
1294
1303
  padding: 2px 0;
1295
1304
  }
1296
- .x-popup-table tr:hover,
1297
1305
  .x-popup-table tr.x-selected {
1298
- background-color: #c8ffff;
1306
+ background-color: var(--x4-selection-color);
1307
+ color: var(--x4-selection-text);
1308
+ }
1309
+ .x-popup-table tr:hover {
1310
+ background-color: var(--x4-hover-color);
1311
+ color: var(--x4-hover-text);
1299
1312
  }
1300
1313
  .x-popup-table td {
1301
1314
  padding: 3px 8px;
package/lib/x4events.d.ts CHANGED
@@ -70,10 +70,12 @@ export declare function EvChange(value: unknown, context?: any): EvChange;
70
70
  * Selection Event
71
71
  * value is the new selection or null
72
72
  */
73
+ interface X4Selection {
74
+ }
73
75
  export interface EvSelectionChange extends BasicEvent {
74
- readonly selection: unknown;
76
+ readonly selection: X4Selection;
75
77
  }
76
- export declare function EvSelectionChange(selection: unknown, context?: any): EvSelectionChange;
78
+ export declare function EvSelectionChange(selection: X4Selection, context?: any): EvSelectionChange;
77
79
  /**
78
80
  * ContextMenu Event
79
81
  */
@@ -264,3 +266,4 @@ export declare class EventSource<Q extends EventMap, T extends EventTypes = MapE
264
266
  */
265
267
  removeAllListeners(eventName: string | null): void;
266
268
  }
269
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "x4js",
3
- "version": "1.4.37",
3
+ "version": "1.4.40",
4
4
  "description": "X4js core files",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -631,8 +631,8 @@ export interface ColorPickerEditorProps extends ColorPickerProps {
631
631
  labelWidth?: number;
632
632
  cust_colors?: Color[];
633
633
  displayValue?: false,
634
-
635
- change: EventCallback<EvChange>;
634
+ change?: EventCallback<EvChange>;
635
+ name?: string;
636
636
  }
637
637
 
638
638
  export class ColorPickerEditor extends HLayout<ColorPickerEditorProps, ColorPickerEventMap> {
package/src/combobox.ts CHANGED
@@ -191,7 +191,7 @@ export class ComboBox extends HLayout<ComboBoxProps,ComboBoxEventMap> {
191
191
  showPopup() {
192
192
 
193
193
  let props = this.m_props;
194
- if (props.readOnly) {
194
+ if (props.readOnly || this.hasClass("@disable") ) {
195
195
  return;
196
196
  }
197
197
 
@@ -278,6 +278,11 @@ export class ComboBox extends HLayout<ComboBoxProps,ComboBoxEventMap> {
278
278
  this.m_props.value = item.id;
279
279
  }
280
280
  }
281
+ else {
282
+ if( this.m_ui_input && this.m_ui_input instanceof Input ) {
283
+ this.m_ui_input.value = "";
284
+ }
285
+ }
281
286
  }
282
287
 
283
288
  /**
@@ -303,13 +308,18 @@ export class ComboBox extends HLayout<ComboBoxProps,ComboBoxEventMap> {
303
308
  items = items( );
304
309
  }
305
310
 
306
- items.some( (v) => {
311
+ const found = items.some( (v) => {
307
312
  if (v.id === id) {
308
313
  this._setInput( v );
309
314
  this.m_selection = v;
310
315
  return true;
311
316
  }
312
317
  });
318
+
319
+ if( !found ) {
320
+ this._setInput( null );
321
+ this.m_selection = null;
322
+ }
313
323
  }
314
324
 
315
325
  get input( ) : Input {
package/src/dialog.ts CHANGED
@@ -234,6 +234,10 @@ export class Dialog<P extends DialogProps = DialogProps, E extends DialogBoxEven
234
234
 
235
235
  this.addClass('@resized');
236
236
 
237
+ if( this.m_el_title ) {
238
+ this.m_el_title.setStyleValue( "width", "auto" );
239
+ }
240
+
237
241
  if (this.m_props.maximized) {
238
242
  this._maximize();
239
243
  this.emit('size', EvSize(null));
@@ -462,13 +466,12 @@ export class Dialog<P extends DialogProps = DialogProps, E extends DialogBoxEven
462
466
 
463
467
  let wrc = flyWrap(x4document.body).getBoundingRect();
464
468
  let rc = this.getBoundingRect(true);
465
- let trc = this.m_el_title.getBoundingRect();
469
+ ///let trc = this.m_el_title.getBoundingRect();
466
470
 
467
471
  let dx = x - rc.left,
468
472
  dy = y - rc.top;
469
473
 
470
- let cstyle = this.getComputedStyle();
471
-
474
+ //let cstyle = this.getComputedStyle();
472
475
  //let topw = cstyle.parse('marginTop') + cstyle.parse('paddingTop') + cstyle.parse('borderTopWidth');
473
476
  //let botw = cstyle.parse('marginBottom') + cstyle.parse('paddingBottom') + cstyle.parse('borderBottomWidth');
474
477
  //let lftw = cstyle.parse('marginLeft') + cstyle.parse('paddingLeft') + cstyle.parse('borderLeftWidth');
package/src/gridview.ts CHANGED
@@ -855,6 +855,12 @@ export class GridView extends VLayout<GridViewProps, GridViewEventMap> {
855
855
  }
856
856
 
857
857
  const update = () => {
858
+
859
+ // element destroyed between updateScroll and now
860
+ if( !this.dom ) {
861
+ return;
862
+ }
863
+
858
864
  let newTop = Math.floor(this.m_view_el.dom.scrollTop / (this.m_itemHeight || 1));
859
865
 
860
866
  if (newTop != this.m_topIndex || forceUpdate) {
package/src/listview.ts CHANGED
@@ -691,6 +691,7 @@ export class PopupListView extends Popup<PopupListViewProps,PopupListViewEventMa
691
691
  super({ tabIndex: false });
692
692
 
693
693
  this.enableMask(false);
694
+ this.addClass( "@non-maskable" );
694
695
 
695
696
  props.tabIndex = false;
696
697
  this.m_list = new ListView(props);
@@ -1015,6 +1015,7 @@ export class Spreadsheet extends VLayout<SpreadsheetProps, SpreadsheetEventSet>
1015
1015
  case 'Enter': {
1016
1016
  this.editCurCell();
1017
1017
  event.stopPropagation( );
1018
+ event.preventDefault( );
1018
1019
  break;
1019
1020
  }
1020
1021
 
@@ -1200,8 +1201,8 @@ export class Spreadsheet extends VLayout<SpreadsheetProps, SpreadsheetEventSet>
1200
1201
  style: {
1201
1202
  left: rc.left - prc.left,
1202
1203
  top: rc.top - prc.top,
1203
- width: rc.width,
1204
- height: rc.height
1204
+ width: rc.width - 1,
1205
+ height: rc.height - 1
1205
1206
  },
1206
1207
  tabIndex: false,
1207
1208
  value: cellvalue,
@@ -1247,11 +1248,16 @@ export class Spreadsheet extends VLayout<SpreadsheetProps, SpreadsheetEventSet>
1247
1248
  } );
1248
1249
 
1249
1250
  input.setDomEvent( 'keydown', (e: KeyboardEvent) => {
1250
-
1251
+ // prevented by edit...
1252
+ if( e.defaultPrevented ) {
1253
+ return;
1254
+ }
1255
+
1251
1256
  switch (e.key) {
1252
1257
  case 'Escape': {
1253
1258
  this.killEditor(false);
1254
1259
  e.stopPropagation();
1260
+ e.preventDefault( );
1255
1261
  break;
1256
1262
  }
1257
1263
 
@@ -1264,6 +1270,7 @@ export class Spreadsheet extends VLayout<SpreadsheetProps, SpreadsheetEventSet>
1264
1270
 
1265
1271
  movesel(0, sens);
1266
1272
  e.stopPropagation();
1273
+ e.preventDefault( );
1267
1274
  break;
1268
1275
  }
1269
1276
 
@@ -1271,6 +1278,7 @@ export class Spreadsheet extends VLayout<SpreadsheetProps, SpreadsheetEventSet>
1271
1278
  case 'Up': {
1272
1279
  movesel(-1, 0);
1273
1280
  e.stopPropagation();
1281
+ e.preventDefault( );
1274
1282
  break;
1275
1283
  }
1276
1284
 
@@ -1278,6 +1286,7 @@ export class Spreadsheet extends VLayout<SpreadsheetProps, SpreadsheetEventSet>
1278
1286
  case 'Down': {
1279
1287
  movesel(1, 0);
1280
1288
  e.stopPropagation();
1289
+ e.preventDefault( );
1281
1290
  break;
1282
1291
  }
1283
1292
  }
@@ -1296,6 +1305,7 @@ export class Spreadsheet extends VLayout<SpreadsheetProps, SpreadsheetEventSet>
1296
1305
  case 'Escape': {
1297
1306
  this.killEditor(false);
1298
1307
  e.stopPropagation();
1308
+ e.preventDefault( );
1299
1309
  break;
1300
1310
  }
1301
1311
 
@@ -1308,6 +1318,7 @@ export class Spreadsheet extends VLayout<SpreadsheetProps, SpreadsheetEventSet>
1308
1318
 
1309
1319
  movesel(0, sens);
1310
1320
  e.stopPropagation();
1321
+ e.preventDefault( );
1311
1322
  break;
1312
1323
  }
1313
1324
  }
@@ -131,16 +131,18 @@ abstract class SVGItem {
131
131
  return this;
132
132
  }
133
133
 
134
- style( name: string, value: string ) : this {
134
+ style( name: string, value: string | number ) : this {
135
135
 
136
- if (value === undefined) {
137
- value = null;
136
+ if (value === undefined || value==='' || value===undefined ) {
137
+ this.m_style.delete( name );
138
+ return;
138
139
  }
139
- else if (!_x4_unitless[name] && (isNumber(value) || reNumber.test(value))) {
140
+
141
+ if (!_x4_unitless[name] && (isNumber(value) || reNumber.test(value))) {
140
142
  value = value + 'px';
141
143
  }
142
144
 
143
- this.m_style.set( name, value );
145
+ this.m_style.set( name, ''+value );
144
146
  return this;
145
147
  }
146
148
 
package/src/x4.less CHANGED
@@ -1052,6 +1052,7 @@ textarea {
1052
1052
  display: flex;
1053
1053
  align-items: center;
1054
1054
  background-color: var( --x4-selection-color );
1055
+ width: 0; // to avoid title changing dialog size when long
1055
1056
 
1056
1057
  .x-icon {
1057
1058
  width: 2em;
@@ -1074,6 +1075,9 @@ textarea {
1074
1075
  .x-label {
1075
1076
  border-bottom: none;
1076
1077
  padding: 0;
1078
+ overflow: hidden;
1079
+ text-overflow: ellipsis;
1080
+ white-space: nowrap;
1077
1081
  }
1078
1082
 
1079
1083
  .res-btn {
@@ -1397,7 +1401,7 @@ textarea {
1397
1401
  .x-row {
1398
1402
  position: absolute;
1399
1403
  width: calc( 100% - @bwidth ); // todo: border of 1st col
1400
- border-bottom: 1px solid #f0f0f0;
1404
+ border-bottom: 1px solid #d0d0d0;
1401
1405
  align-items: center;
1402
1406
  height: @def-height;
1403
1407
 
@@ -1407,7 +1411,7 @@ textarea {
1407
1411
  }
1408
1412
 
1409
1413
  .x-cell {
1410
- border-right: 1px solid #f0f0f0;
1414
+ border-right: 1px solid #d0d0d0;
1411
1415
 
1412
1416
  &.center {
1413
1417
  text-align: center;
@@ -1482,14 +1486,20 @@ textarea {
1482
1486
  .x-editor {
1483
1487
  position: absolute;
1484
1488
  min-height: 0;
1489
+ margin: 0;
1485
1490
 
1486
1491
  input {
1487
1492
  margin: 0;
1488
1493
  min-height: 0;
1494
+ height: 100%;
1489
1495
  }
1490
1496
  }
1491
1497
  }
1492
1498
 
1499
+ .x-form .x-spreadsheet .x-editor {
1500
+ background-color: white;
1501
+ }
1502
+
1493
1503
  .x-side-bar {
1494
1504
  min-width: 44px;
1495
1505
 
@@ -1594,9 +1604,15 @@ textarea {
1594
1604
  background-color: white;
1595
1605
  padding: 2px 0;
1596
1606
 
1597
- tr:hover,
1598
1607
  tr.x-selected {
1599
- background-color: rgba(200,255,255,1);
1608
+ //background-color: rgba(200,255,255,1);
1609
+ background-color: var(--x4-selection-color);
1610
+ color: var( --x4-selection-text);
1611
+ }
1612
+
1613
+ tr:hover {
1614
+ background-color: var(--x4-hover-color);
1615
+ color: var( --x4-hover-text);
1600
1616
  }
1601
1617
 
1602
1618
  td {
package/src/x4events.ts CHANGED
@@ -108,11 +108,14 @@ export function EvChange(value: unknown, context = null ) {
108
108
  * value is the new selection or null
109
109
  */
110
110
 
111
+ interface X4Selection {
112
+ }
113
+
111
114
  export interface EvSelectionChange extends BasicEvent {
112
- readonly selection: unknown;
115
+ readonly selection: X4Selection;
113
116
  }
114
117
 
115
- export function EvSelectionChange( selection: unknown, context = null ) {
118
+ export function EvSelectionChange( selection: X4Selection, context = null ) {
116
119
  return BasicEvent<EvSelectionChange>( { selection, context } );
117
120
  }
118
121