x4js 2.2.47 → 2.2.50

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.
Files changed (56) hide show
  1. package/README.md +4 -3
  2. package/package.json +3 -2
  3. package/src/components/boxes/boxes.module.scss +1 -0
  4. package/src/components/breadcrumb/breadcrumb.ts +7 -0
  5. package/src/components/btngroup/btngroup.module.scss +1 -1
  6. package/src/components/button/button.ts +15 -5
  7. package/src/components/calendar/calendar.ts +19 -1
  8. package/src/components/checkbox/checkbox.ts +11 -0
  9. package/src/components/colorinput/colorinput.ts +6 -1
  10. package/src/components/colorpicker/colorpicker.ts +2 -2
  11. package/src/components/combobox/combobox.ts +14 -0
  12. package/src/components/dialog/dialog.ts +6 -2
  13. package/src/components/filedrop/filedrop.ts +10 -0
  14. package/src/components/form/form.ts +4 -1
  15. package/src/components/gauge/gauge.ts +9 -0
  16. package/src/components/gridview/gridview.ts +28 -1
  17. package/src/components/header/header.ts +6 -6
  18. package/src/components/image/image.ts +5 -0
  19. package/src/components/input/input.module.scss +5 -0
  20. package/src/components/input/input.ts +9 -0
  21. package/src/components/keyboard/keyboard.ts +8 -0
  22. package/src/components/label/label.ts +7 -1
  23. package/src/components/link/link.ts +4 -0
  24. package/src/components/listbox/listbox.ts +22 -9
  25. package/src/components/menu/menu.ts +10 -1
  26. package/src/components/messages/messages.ts +6 -0
  27. package/src/components/notification/notification.ts +13 -0
  28. package/src/components/panel/panel.ts +5 -1
  29. package/src/components/popup/popup.module.scss +1 -0
  30. package/src/components/popup/popup.ts +60 -34
  31. package/src/components/progress/progress.ts +8 -0
  32. package/src/components/propgrid/progrid.module.scss +11 -5
  33. package/src/components/propgrid/propgrid.ts +36 -16
  34. package/src/components/rating/rating.ts +6 -0
  35. package/src/components/select/select.ts +1 -0
  36. package/src/components/sizers/sizer.ts +23 -8
  37. package/src/components/slider/slider.ts +7 -0
  38. package/src/components/spreadsheet/spreadsheet.ts +28 -1
  39. package/src/components/switch/switch.ts +7 -0
  40. package/src/components/tabs/tabs.ts +6 -0
  41. package/src/components/tag/tag.ts +11 -0
  42. package/src/components/textarea/textarea.ts +6 -0
  43. package/src/components/textedit/textedit.ts +10 -0
  44. package/src/components/tickline/tickline.ts +9 -0
  45. package/src/components/tooltips/tooltips.ts +12 -2
  46. package/src/components/treeview/treeview.ts +14 -0
  47. package/src/components/viewport/viewport.ts +8 -0
  48. package/src/core/component.ts +44 -43
  49. package/src/core/core_application.ts +16 -4
  50. package/src/core/core_data.ts +1 -4
  51. package/src/core/core_dom.ts +49 -31
  52. package/src/core/core_element.ts +141 -39
  53. package/src/core/core_pdf.ts +1 -0
  54. package/src/core/core_svg.ts +2 -2
  55. package/src/core/core_tools.ts +1 -5
  56. package/src/x4doc.ts +23 -0
@@ -22,6 +22,7 @@ import { Box } from '../boxes/boxes'
22
22
 
23
23
  import "./popup.module.scss"
24
24
  import { getGlobalZoom, getScrollbarSize } from '../../core/core_tools.js';
25
+ import { Application } from '../../core/core_application.js';
25
26
 
26
27
  export interface PopupEvents extends ComponentEvents {
27
28
  closed: ComponentEvent;
@@ -46,7 +47,10 @@ function getRoot( ) {
46
47
  }
47
48
 
48
49
  /**
49
- *
50
+ * @cssvar
51
+ * ```
52
+ * --modal-mask-background
53
+ * ```
50
54
  */
51
55
 
52
56
  @class_ns( "x4" )
@@ -63,6 +67,7 @@ export class Popup<P extends PopupProps = PopupProps, E extends PopupEvents = Po
63
67
  }
64
68
 
65
69
  // wait for element to create it's childs
70
+ // > setContent is in ctor
66
71
  asap( ( ) => {
67
72
  if( this.props.movable===true || (this.props.sizable && this.props.movable===undefined) ) {
68
73
  const movers = this.queryAll( ".caption-element" );
@@ -133,13 +138,31 @@ export class Popup<P extends PopupProps = PopupProps, E extends PopupEvents = Po
133
138
  }
134
139
 
135
140
  /**
136
- * s
141
+ * stupid parameter
137
142
  */
138
143
 
139
- displayCenter( center = true ) {
140
- //this.displayNear( new Rect( window.innerWidth/2, window.innerHeight/2, 0, 0 ), "center middle" );
141
- this.setClass( 'center', center );
144
+ displayCenter( ) {
142
145
  this._do_show( ); // to compute size
146
+
147
+ const fixpos = ( ) => {
148
+ console.log( "fixpos" );
149
+
150
+ const orc = this.getBoundingRect( );
151
+ this.setStyle( {
152
+ left: ((window.innerWidth - orc.width) / 2) +'px',
153
+ top: ((window.innerHeight - orc.height) / 2) +'px',
154
+ } );
155
+
156
+ console.log( orc );
157
+ }
158
+
159
+ asap( fixpos );
160
+
161
+ const tkn = Application.instance( ).on( "resize", () => {
162
+ asap( fixpos );
163
+ } )
164
+
165
+ this.addCleanup( tkn.off );
143
166
  }
144
167
 
145
168
  /**
@@ -395,7 +418,7 @@ export class Popup<P extends PopupProps = PopupProps, E extends PopupEvents = Po
395
418
 
396
419
 
397
420
  /**
398
- *
421
+ * @internal
399
422
  */
400
423
 
401
424
  export
@@ -408,51 +431,54 @@ class CMover {
408
431
 
409
432
  this.self = ref ? true : false;
410
433
 
411
- x.addDOMEvent( "pointerdown", ( e: PointerEvent ) => {
434
+ const mouseDown = ( e: PointerEvent ) => {
412
435
  if( this.self && e.target!=x.dom ) {
413
436
  return;
414
437
  }
415
438
 
416
439
  x.setCapture( e.pointerId );
417
440
 
418
- this.ref = ref ?? componentFromDOM( x.dom.parentElement );
441
+ if( !ref ) {
442
+ ref = componentFromDOM( x.dom.parentElement );
443
+ }
419
444
 
445
+ this.ref = ref;
420
446
  this.delta = {x:0,y:0};
421
- const rc = this.ref.getBoundingRect();
447
+ const rc = ref.getBoundingRect();
422
448
 
423
449
  this.delta.x = e.pageX-rc.left;
424
450
  this.delta.y = e.pageY-rc.top;
425
- });
426
-
427
- x.addDOMEvent( "pointerup", ( e: PointerEvent ) => {
428
- x.releaseCapture( e.pointerId );
429
- this.ref = null;
430
- });
451
+ }
431
452
 
432
- x.addDOMEvent( "pointermove", ( e: PointerEvent ) => {
433
- this._onMouseMove( e );
434
- });
435
- }
453
+ const mouseMove = ( e: PointerEvent ) => {
454
+ if( !this.delta ) {
455
+ return;
456
+ }
436
457
 
437
- private _onMouseMove( e: PointerEvent ) {
438
- if( !this.ref ) {
439
- return;
458
+ const ref = this.ref
459
+ const pt = { x: e.pageX-this.delta.x, y: e.pageY-this.delta.y };
460
+ const rc = ref.getBoundingRect( );
461
+
462
+ ref.setStyle( {
463
+ top: pt.y+"",
464
+ left: pt.x+"",
465
+ } );
466
+
467
+ e.preventDefault( );
468
+ e.stopPropagation( );
440
469
  }
441
470
 
442
- const pt = { x: e.pageX-this.delta.x, y: e.pageY-this.delta.y };
443
- const rc = this.ref.getBoundingRect( );
444
-
445
- let nr: any = {
446
- };
471
+ const mouseUp = ( e: PointerEvent ) => {
472
+ x.releaseCapture( e.pointerId );
473
+ this.delta = null;
474
+ }
447
475
 
448
- this.ref.setStyle( {
449
- top: pt.y+"",
450
- left: pt.x+"",
451
- } );
452
-
453
- e.preventDefault( );
454
- e.stopPropagation( );
476
+ x.addDOMEvent( "pointerdown", mouseDown );
477
+ x.addDOMEvent( "pointerup", mouseUp );
478
+ x.addDOMEvent( "pointermove", mouseMove );
455
479
  }
480
+
481
+
456
482
  }
457
483
 
458
484
 
@@ -25,6 +25,14 @@ interface ProgressProps extends ComponentProps {
25
25
  max: number;
26
26
  }
27
27
 
28
+ /**
29
+ * @cssvar
30
+ * ```
31
+ * --progress-background
32
+ * --progress-color
33
+ * ```
34
+ */
35
+
28
36
  @class_ns( "x4" )
29
37
  export class Progress extends Component<ProgressProps> {
30
38
 
@@ -6,6 +6,8 @@
6
6
 
7
7
  :root {
8
8
  --propertygrid-background: white;
9
+ --propertygrid-gadget-background: white;
10
+ --propertygrid-gadget-color: black;
9
11
  }
10
12
 
11
13
  .x4propertygrid {
@@ -92,10 +94,6 @@
92
94
  flex-basis: 10px;
93
95
  padding: 4px;
94
96
 
95
- &>* {
96
- width: 100%;
97
- }
98
-
99
97
  input {
100
98
  background: rgba(255,255,255,0.6);
101
99
  }
@@ -110,8 +108,16 @@
110
108
  padding-left: 34px;
111
109
  }
112
110
 
113
- .cell:has(.x4button) {
111
+ .cell:has(.button) {
114
112
  padding: 4px 40px;
115
113
  }
114
+
115
+ .gadget {
116
+ &.x4button {
117
+ --button-background: var( --propertygrid-gadget-background );
118
+ --button-color: var( --propertygrid-gadget-color );
119
+ padding: 5px;
120
+ }
121
+ }
116
122
  }
117
123
  }
@@ -44,6 +44,7 @@ export interface PropertyValue {
44
44
  step?: number; // for numbers
45
45
  min?: number;
46
46
  max?: number;
47
+ gadgets?: Component[];
47
48
  }
48
49
 
49
50
  export interface PropertyGroup {
@@ -59,6 +60,13 @@ export interface PropertyProps extends ComponentProps {
59
60
  groups: PropertyGroup[];
60
61
  }
61
62
 
63
+ /**
64
+ * @cssvar
65
+ * ```
66
+ * --propertygrid-background
67
+ * ```
68
+ */
69
+
62
70
  @class_ns( "x4" )
63
71
  export class PropertyGrid extends VBox {
64
72
 
@@ -106,8 +114,6 @@ export class PropertyGrid extends VBox {
106
114
 
107
115
  /**
108
116
  * Gets the html of a group header row
109
- * @param {string} displayName - The group display name
110
- * @param {boolean} isCollapsible - Whether the group should support expand/collapse
111
117
  */
112
118
 
113
119
  makeGroupHeader( g: PropertyGroup ) {
@@ -241,6 +247,7 @@ export class PropertyGrid extends VBox {
241
247
  use_hdr = false;
242
248
  editor = new Button({
243
249
  id: item.name,
250
+ cls: "button",
244
251
  label: value as string,
245
252
  click: ( ) => {
246
253
  item.callback?.( item.name, '' );
@@ -248,17 +255,17 @@ export class PropertyGrid extends VBox {
248
255
  });
249
256
  }
250
257
  else {
251
- editor = new Input({
252
- type: 'text',
253
- id: item.name,
254
- name: item.name,
255
- value: value as string,
256
- focus: ( e: EvFocus ) => {
257
- if( e.focus_out ) {
258
- item.callback?.( item.name, (editor as Input).getValue() );
259
- }
260
- }
261
- });
258
+ editor = new Input({
259
+ type: 'text',
260
+ id: item.name,
261
+ name: item.name,
262
+ value: value as string,
263
+ focus: ( e: EvFocus ) => {
264
+ if( e.focus_out ) {
265
+ item.callback?.( item.name, (editor as Input).getValue() );
266
+ }
267
+ },
268
+ })
262
269
  }
263
270
 
264
271
  let cls = 'row';
@@ -266,12 +273,25 @@ export class PropertyGrid extends VBox {
266
273
  cls += ' ' + item.cls;
267
274
  }
268
275
 
276
+ editor.addClass( "x4flex" );
277
+
278
+ const content: Component[] = [
279
+ editor
280
+ ]
281
+
282
+ if( item.gadgets ) {
283
+ item.gadgets.forEach( g => {
284
+ g.addClass( "gadget" );
285
+ content.push( g );
286
+ } );
287
+ }
288
+
269
289
  return new HBox({
270
290
  cls,
271
291
  content: [
272
- use_hdr ? new Component({ cls: 'cell hdr', content: item.title ?? item.name, tooltip: item.desc }) : null,
273
- new Component({ cls: 'cell', tag: "label", attrs: { "labelFor": item.name }, content: editor })
274
- ]
292
+ use_hdr ? new Component({ cls: 'cell hdr', content: item.title ?? item.name, tooltip: item.desc }) : null,
293
+ new HBox({ cls: 'cell', tag: "label", attrs: { "labelFor": item.name }, content }),
294
+ ]
275
295
  });
276
296
  }
277
297
 
@@ -42,6 +42,12 @@ export interface RatingProps extends ComponentProps {
42
42
 
43
43
  /**
44
44
  *
45
+ * @cssvar
46
+ * ```
47
+ * --rating
48
+ * --rating-hover
49
+ * --rating-checked
50
+ * ```
45
51
  */
46
52
 
47
53
  @class_ns( "x4" )
@@ -44,6 +44,7 @@ interface SelectEvents extends ComponentEvent {
44
44
 
45
45
  /**
46
46
  * simple select
47
+ * cf. Combobox
47
48
  */
48
49
 
49
50
  @class_ns( "x4" )
@@ -24,7 +24,9 @@ import "./sizer.module.scss"
24
24
  */
25
25
 
26
26
  export interface EvSizeChange extends ComponentEvent {
27
- size: number;
27
+ size: number; // compat
28
+ width: number;
29
+ height: number;
28
30
  }
29
31
 
30
32
  interface CSizerEvent extends ComponentEvents {
@@ -111,28 +113,41 @@ export class CSizer extends Component<ComponentProps,CSizerEvent> {
111
113
  let nr: any = {};
112
114
  let horz = true;
113
115
 
116
+ //const center = this._ref.hasClass("center");
117
+ //if( center ) {
118
+ // const orc = this._ref.getBoundingRect( );
119
+ // this._ref.removeClass("center");
120
+ //
121
+ // nr.left = orc.left;
122
+ // nr.top = orc.top;
123
+ //}
124
+
114
125
  if( this._type.includes("top") ) {
115
126
  nr.top = pt.y,
116
127
  nr.height = (rc.top+rc.height)-pt.y;
117
128
  horz = false;
118
129
  }
119
- else if( this._type=="vsize-next" ) {
130
+
131
+ if( this._type=="vsize-next" ) {
120
132
  nr.height = (rc.top+rc.height)-pt.y;
121
133
  horz = false;
122
134
  }
123
- else if( this._type.includes("bottom") || this._type=='vsize-prev' ) {
124
- //nr.top = rc.top;
135
+
136
+ if( this._type.includes("bottom") || this._type=='vsize-prev' ) {
125
137
  nr.height = (pt.y-rc.top);
126
138
  horz = false;
127
139
  }
128
- else if( this._type.includes("left") ) {
140
+
141
+ if( this._type.includes("left") ) {
129
142
  nr.left = pt.x;
130
143
  nr.width = ((rc.left+rc.width)-pt.x);
131
144
  }
132
- else if( this._type=="hsize-next" ) {
145
+
146
+ if( this._type=="hsize-next" ) {
133
147
  nr.width = ((rc.left+rc.width)-pt.x);
134
148
  }
135
- else if( this._type.includes("right") || this._type=='hsize-prev' ) {
149
+
150
+ if( this._type.includes("right") || this._type=='hsize-prev' ) {
136
151
  nr.width = (pt.x-rc.left);
137
152
  }
138
153
 
@@ -140,7 +155,7 @@ export class CSizer extends Component<ComponentProps,CSizerEvent> {
140
155
  //this._ref.setStyleValue( "flexGrow", 0 );
141
156
 
142
157
  const nrc = this._ref.getBoundingRect( );
143
- this.fire( "resize", { size: horz ? nrc.width : nrc.height })
158
+ this.fire( "resize", { size: horz ? nrc.width : nrc.height, width: nrc.width, height: nrc.height })
144
159
 
145
160
  e.preventDefault( );
146
161
  e.stopPropagation( );
@@ -38,6 +38,13 @@ interface SliderProps extends ComponentProps {
38
38
 
39
39
  /**
40
40
  *
41
+ * @cssvar
42
+ * ```
43
+ * --slider-track
44
+ * --slider-thumb-background
45
+ * --slider-thumb-border
46
+ * --slider-thumb-border-focus
47
+ * ```
41
48
  */
42
49
 
43
50
  @class_ns( "x4" )
@@ -202,7 +202,34 @@ export interface SpreadsheetProps extends ComponentProps {
202
202
  */
203
203
 
204
204
  /**
205
- *
205
+ * @cssvar
206
+ * ```
207
+ * --spreadsheet-background
208
+ * --spreadsheet-border
209
+ * --spreadsheet-header-cell-background
210
+ * --spreadsheet-header-cell-color
211
+ * --spreadsheet-header-cell-vline
212
+ * --spreadsheet-header-cell-border
213
+ * --spreadsheet-check-background
214
+ * --spreadsheet-check-color
215
+ * --spreadsheet-check-background-hover
216
+ * --spreadsheet-check-color-hover
217
+ * --spreadsheet-perc-background
218
+ * --spreadsheet-perc-color
219
+ * --spreadsheet-perc-background-hover
220
+ * --spreadsheet-perc-color-hover
221
+ * --spreadsheet-cell-color
222
+ * --spreadsheet-cell-color-sel
223
+ * --spreadsheet-cell-vline
224
+ * --spreadsheet-row-background
225
+ * --spreadsheet-row-odd-background
226
+ * --spreadsheet-row-border
227
+ * --spreadsheet-row-background-hover
228
+ * --spreadsheet-row-background-hover-sel
229
+ * --spreadsheet-row-background-sel
230
+ * --spreadsheet-row-color-sel
231
+ * --spreadsheet-fix-border
232
+ * ```
206
233
  */
207
234
 
208
235
  @class_ns("x4")
@@ -32,6 +32,13 @@ interface SwitchProps extends ComponentProps {
32
32
 
33
33
  /**
34
34
  *
35
+ * @cssvar
36
+ * ```
37
+ * --switch-border
38
+ * --switch-background
39
+ * --switch-background-disabled
40
+ * --switch-checked
41
+ * ```
35
42
  */
36
43
 
37
44
  @class_ns( "x4" )
@@ -75,6 +75,7 @@ interface TablistEvents extends ComponentEvents {
75
75
 
76
76
  /**
77
77
  * bar containing buttons
78
+ * @internal
78
79
  */
79
80
 
80
81
  @class_ns( "x4" )
@@ -141,6 +142,11 @@ interface TabsProps extends Omit<ComponentProps,"content"> {
141
142
 
142
143
  /**
143
144
  *
145
+ * @cssvar
146
+ * ```
147
+ * --tab-border-selected
148
+ * --tab-border-hover
149
+ * ```
144
150
  */
145
151
 
146
152
  @class_ns( "x4" )
@@ -18,6 +18,17 @@ export interface TagProps extends ComponentProps {
18
18
  icon?: string;
19
19
  }
20
20
 
21
+ /**
22
+ *
23
+ * @cssvar
24
+ * ```
25
+ * --tag-border
26
+ * --tag-border-focus
27
+ * --tag-selection
28
+ * --tag-color
29
+ * --tag-icon-color
30
+ * ```
31
+ */
21
32
 
22
33
  @class_ns( "x4" )
23
34
  export class Tag extends HBox<TagProps> {
@@ -96,6 +96,12 @@ export class SimpleTextArea extends Component<TextAreaProps> {
96
96
 
97
97
  /**
98
98
  *
99
+ * @cssvar
100
+ * ```
101
+ * --textarea-border
102
+ * --textarea-border-focus
103
+ * --textarea-selection
104
+ * ```
99
105
  */
100
106
 
101
107
  @class_ns( "x4" )
@@ -69,6 +69,16 @@ interface TextEditProps extends InputProps {
69
69
 
70
70
  /**
71
71
  *
72
+ * @cssvar
73
+ * ```
74
+ * --textedit-border
75
+ * --textedit-border-focus
76
+ * --textedit-required
77
+ * --textedit-btn-background
78
+ * --textedit-btn-color
79
+ * --textedit-btn-color-hover
80
+ * --textedit-color-disabled
81
+ * ```
72
82
  */
73
83
 
74
84
  @class_ns( "x4" )
@@ -13,6 +13,15 @@ interface TickLineProps extends ComponentProps {
13
13
  type: "bars" | "line";
14
14
  }
15
15
 
16
+ /**
17
+ *
18
+ * @cssvar
19
+ * ```
20
+ * --tickline-axis-color
21
+ * --tickline-color
22
+ * --tickline-background
23
+ * ```
24
+ */
16
25
 
17
26
  export class TickLine extends Component<TickLineProps> {
18
27
 
@@ -75,7 +75,7 @@ function showTT( text: string, rc: Rect, pt: Point ) {
75
75
  tooltip = new Tooltip( { } );
76
76
  }
77
77
 
78
- timer.setTimeout( null, 300, ( ) => {
78
+ timer.setTimeout( "update", 300, ( ) => {
79
79
  tooltip.setText( unsafeHtml(text) );
80
80
 
81
81
  let y = mouse_pos.y;
@@ -90,11 +90,21 @@ function showTT( text: string, rc: Rect, pt: Point ) {
90
90
 
91
91
  function closeTT( ) {
92
92
  tooltip.show( false );
93
- timer.clearTimeout( null );
93
+ timer.clearTimeout( "update" );
94
94
  }
95
95
 
96
96
  /**
97
97
  *
98
+ * @cssvar
99
+ * ```
100
+ * --tooltip-caption-background
101
+ * --tooltip-caption-color
102
+ * --tooltip-icon-background
103
+ * --tooltip-icon-color
104
+ * --tooltip-background
105
+ * --tooltip-color
106
+ * --tooltip-border
107
+ * ```
98
108
  */
99
109
 
100
110
  @class_ns( "x4" )
@@ -69,6 +69,18 @@ interface TreeviewEvents extends ComponentEvents {
69
69
 
70
70
  /**
71
71
  *
72
+ * @cssvar
73
+ * ```
74
+ * --treeview-background
75
+ * --treeitem-backgound-hover
76
+ * --treeitem-color-hover
77
+ * --treeitem-background-sel
78
+ * --treeitem-color-sel
79
+ * --treeview-item-color-sel-disabled
80
+ * --treeview-item-color-disabled
81
+ * --treeitem-backgound-active
82
+ * --treeitem-color-active
83
+ * ```
72
84
  */
73
85
 
74
86
  @class_ns( "x4" )
@@ -476,8 +488,10 @@ export class Treeview extends Component<TreeviewProps,TreeviewEvents> {
476
488
  this._selitem = undefined;
477
489
  }
478
490
 
491
+ if( this._selection ) {
479
492
  this._selection = undefined;
480
493
  this.fire( "selectionChange", { selection: [], empty: true } );
494
+ }
481
495
  }
482
496
 
483
497
  /**
@@ -19,6 +19,10 @@ import { Component, ComponentProps } from "../../core/component"
19
19
 
20
20
  import "./viewport.module.scss"
21
21
 
22
+ /**
23
+ *
24
+ */
25
+
22
26
  @class_ns( "x4" )
23
27
  export class Viewport extends Component {
24
28
  constructor( props: ComponentProps ) {
@@ -26,6 +30,10 @@ export class Viewport extends Component {
26
30
  }
27
31
  }
28
32
 
33
+ /**
34
+ *
35
+ */
36
+
29
37
  @class_ns( "x4" )
30
38
  export class ScrollView extends Component {
31
39
  constructor( props: ComponentProps ) {