x4js 2.3.25 → 2.3.26

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 (63) hide show
  1. package/aicontext.md +46 -12
  2. package/package.json +1 -1
  3. package/src/components/autocomplete/autocomplete.ts +2 -2
  4. package/src/components/boxes/boxes.module.scss +16 -2
  5. package/src/components/boxes/boxes.ts +24 -11
  6. package/src/components/breadcrumb/breadcrumb.ts +1 -2
  7. package/src/components/btngroup/btngroup.ts +2 -2
  8. package/src/components/button/button.ts +2 -2
  9. package/src/components/calendar/calendar.ts +4 -2
  10. package/src/components/canvas/canvas.ts +1 -2
  11. package/src/components/chart/chart.ts +3 -3
  12. package/src/components/checkbox/checkbox.ts +2 -2
  13. package/src/components/colorinput/colorinput.ts +3 -2
  14. package/src/components/colorpicker/colorpicker.ts +5 -5
  15. package/src/components/combobox/combobox.ts +3 -3
  16. package/src/components/dialog/dialog.ts +2 -2
  17. package/src/components/dockingview/dockingview.ts +1 -2
  18. package/src/components/filedrop/filedrop.ts +3 -2
  19. package/src/components/form/form.ts +4 -3
  20. package/src/components/gauge/gauge.ts +2 -2
  21. package/src/components/gridview/gridview.module.scss +8 -5
  22. package/src/components/gridview/gridview.ts +11 -13
  23. package/src/components/header/header.ts +2 -2
  24. package/src/components/icon/icon.ts +1 -2
  25. package/src/components/image/image.ts +1 -2
  26. package/src/components/input/input.ts +3 -2
  27. package/src/components/keyboard/keyboard.ts +2 -2
  28. package/src/components/label/label.ts +3 -3
  29. package/src/components/link/link.ts +3 -2
  30. package/src/components/listbox/listbox.ts +2 -2
  31. package/src/components/menu/menu.ts +5 -4
  32. package/src/components/messages/messages.module.scss +29 -5
  33. package/src/components/messages/messages.ts +42 -50
  34. package/src/components/notification/notification.ts +3 -2
  35. package/src/components/panel/panel.ts +2 -2
  36. package/src/components/popup/popup.ts +2 -2
  37. package/src/components/progress/progress.ts +1 -2
  38. package/src/components/propgrid/progrid.module.scss +2 -3
  39. package/src/components/propgrid/propgrid.ts +2 -2
  40. package/src/components/radio/radio.ts +1 -2
  41. package/src/components/rating/rating.ts +2 -2
  42. package/src/components/select/select.ts +2 -2
  43. package/src/components/settingsview/settingsview.module.scss +6 -5
  44. package/src/components/settingsview/settingsview.ts +3 -3
  45. package/src/components/sizers/sizer.ts +21 -29
  46. package/src/components/slider/slider.ts +2 -2
  47. package/src/components/spreadsheet/spreadsheet.ts +8 -10
  48. package/src/components/switch/switch.ts +2 -2
  49. package/src/components/tabs/tabs.ts +4 -4
  50. package/src/components/tag/tag.ts +2 -2
  51. package/src/components/textarea/textarea.ts +3 -3
  52. package/src/components/textedit/textedit.ts +2 -2
  53. package/src/components/themes.scss +2 -0
  54. package/src/components/tickline/tickline.ts +3 -3
  55. package/src/components/tooltips/tooltips.ts +2 -2
  56. package/src/components/treeview/treeview.ts +3 -3
  57. package/src/components/video/video.ts +1 -2
  58. package/src/components/viewport/viewport.ts +4 -3
  59. package/src/core/component.ts +15 -24
  60. package/src/core/core_application.ts +29 -1
  61. package/src/core/core_i18n.ts +39 -0
  62. package/src/core/core_svg.ts +1 -0
  63. package/src/core/core_tools.ts +83 -24
@@ -14,7 +14,7 @@
14
14
  * that can be found in the LICENSE file or at https://opensource.org/licenses/MIT.
15
15
  **/
16
16
 
17
- import { centerRect, class_ns } from '../../core/core_tools';
17
+ import { centerRect } from '../../core/core_tools';
18
18
  import { Component, ComponentProps } from '../../core/component'
19
19
  import { SvgBuilder, SvgComponent } from '../../core/core_svg';
20
20
 
@@ -49,8 +49,8 @@ export const simpleColorStop = [
49
49
  * ```
50
50
  */
51
51
 
52
- @class_ns( "x4" )
53
52
  export class Gauge extends Component<GaugeProps> {
53
+ static classPrefix = "x4";
54
54
 
55
55
  private pos: number;
56
56
  private stops: string[];
@@ -22,6 +22,7 @@
22
22
 
23
23
  --gridview-header-cell-background: var( --background-primary );
24
24
  --gridview-header-cell-color: var( --text-primary );
25
+ --gridview-header-sort-color: var( --gridview-header-cell-color ); // the arrow of the column sorted
25
26
  --gridview-header-cell-vline: var( --border );
26
27
  --gridview-header-cell-border: var( --border );
27
28
 
@@ -245,17 +246,19 @@
245
246
  width: 1em;
246
247
  }
247
248
 
249
+ // the arrow is the mask of the box: its colour follows the theme
248
250
  &.sorted .sorter {
249
- background-image: url("./arrow-down-light.svg");
250
251
  display: block;
251
252
  width: 20px;
252
253
  height: 0.7em;
253
- background-repeat: no-repeat;
254
- background-position: 50% 50%;
254
+ background-color: var( --gridview-header-sort-color );
255
+ -webkit-mask: url("./arrow-down-light.svg") no-repeat 50% 50% / contain;
256
+ mask: url("./arrow-down-light.svg") no-repeat 50% 50% / contain;
255
257
  }
256
-
258
+
257
259
  &.sorted.desc .sorter {
258
- background-image: url("./arrow-up-light.svg");
260
+ -webkit-mask-image: url("./arrow-up-light.svg");
261
+ mask-image: url("./arrow-up-light.svg");
259
262
  }
260
263
 
261
264
  .x-c-sizer:hover {
@@ -16,7 +16,7 @@
16
16
 
17
17
 
18
18
  import { Component, ComponentContent, ComponentEvents, ComponentProps, EvClick, EvContextMenu, EvDblClick, EvSelectionChange } from '../../core/component';
19
- import { class_ns, isNumber, isString, setWaitCursor, UnsafeHtml } from '../../core/core_tools';
19
+ import { formatDate, formatDateTime, formatMoney, formatNumber, isNumber, isString, setWaitCursor, UnsafeHtml } from '../../core/core_tools';
20
20
  import { DataModel, DataStore, DataView, DataRecord, EvViewChange, SortCallback } from '../../core/core_data';
21
21
  import { EventCallback } from '../../core/core_events';
22
22
  import { kbNav } from '../../core/core_tools';
@@ -108,6 +108,7 @@ export interface GridviewProps extends ComponentProps {
108
108
  * --gridview-border
109
109
  * --gridview-header-cell-background
110
110
  * --gridview-header-cell-color
111
+ * --gridview-header-sort-color
111
112
  * --gridview-header-cell-vline
112
113
  * --gridview-header-cell-border
113
114
  * --grid-check-background
@@ -132,8 +133,8 @@ export interface GridviewProps extends ComponentProps {
132
133
  * ```
133
134
  */
134
135
 
135
- @class_ns("x4")
136
136
  export class Gridview<P extends GridviewProps = GridviewProps, E extends GridviewEvents = GridviewEvents> extends Component<P,E> {
137
+ static classPrefix = "x4";
137
138
 
138
139
  private _dataview: DataView;
139
140
  private _datamodel: DataModel;
@@ -165,10 +166,6 @@ export class Gridview<P extends GridviewProps = GridviewProps, E extends Gridvie
165
166
 
166
167
 
167
168
  // TODO: that
168
- private _num_fmt = new Intl.NumberFormat('fr-FR');
169
- private _mny_fmt = new Intl.NumberFormat('fr-FR', { style: 'currency', currency: 'EUR' });
170
- private _dte_fmt = new Intl.DateTimeFormat('fr-FR', {});
171
- private _dtetme_fmt = new Intl.DateTimeFormat('fr-FR', {day:'2-digit',month:'2-digit',year:'numeric',hour:'2-digit',minute:"2-digit"});
172
169
 
173
170
  private _has_fixed: boolean;
174
171
  private _has_footer: boolean;
@@ -744,12 +741,13 @@ export class Gridview<P extends GridviewProps = GridviewProps, E extends Gridvie
744
741
  })
745
742
 
746
743
  sizer.on("resize", (ev) => {
747
- cdata.width = ev.size;
744
+ const size = Math.max( ev.size, 16 ); // 16px at least: the min-width of a .cell
745
+ cdata.width = size;
748
746
  cdata.flex = 0;
749
-
747
+
750
748
  const cols = this.queryAll(`[data-col="${col}"]`)
751
749
  cols.forEach(c => {
752
- c.setStyleValue("width", ev.size + "px");
750
+ c.setStyleValue("width", size + "px");
753
751
  });
754
752
 
755
753
  const rh = header.getBoundingRect();
@@ -1005,7 +1003,7 @@ export class Gridview<P extends GridviewProps = GridviewProps, E extends Gridvie
1005
1003
  return "NaN";
1006
1004
  }
1007
1005
 
1008
- data = this._num_fmt.format(data as number);
1006
+ data = formatNumber(data as number);
1009
1007
  break;
1010
1008
  }
1011
1009
 
@@ -1014,7 +1012,7 @@ export class Gridview<P extends GridviewProps = GridviewProps, E extends Gridvie
1014
1012
  return "NaN";
1015
1013
  }
1016
1014
 
1017
- data = this._mny_fmt.format(data as number);
1015
+ data = formatMoney(data as number);
1018
1016
  break;
1019
1017
  }
1020
1018
 
@@ -1034,7 +1032,7 @@ export class Gridview<P extends GridviewProps = GridviewProps, E extends Gridvie
1034
1032
  data = new Date( data );
1035
1033
  }
1036
1034
 
1037
- data = this._dte_fmt.format(data as Date);
1035
+ data = formatDate(data as Date);
1038
1036
  break;
1039
1037
  }
1040
1038
 
@@ -1043,7 +1041,7 @@ export class Gridview<P extends GridviewProps = GridviewProps, E extends Gridvie
1043
1041
  data = new Date( data );
1044
1042
  }
1045
1043
 
1046
- data = this._dtetme_fmt.format(data as Date);
1044
+ data = formatDateTime(data as Date);
1047
1045
  break;
1048
1046
  }
1049
1047
 
@@ -1,4 +1,4 @@
1
- import { class_ns, getScrollbarSize } from '../../core/core_tools';
1
+ import { getScrollbarSize } from '../../core/core_tools';
2
2
  import { Component, ComponentProps } from '../../core/component';
3
3
  import { HBox } from '../boxes/boxes';
4
4
  import { Label } from '../label/label';
@@ -36,8 +36,8 @@ const MAX_COLS = 10; // columns with a default name (ref-c1...ref-c10) handled b
36
36
  * ```
37
37
  */
38
38
 
39
- @class_ns( "x4" )
40
39
  export class Header extends HBox<HeaderProps> {
40
+ static classPrefix = "x4";
41
41
 
42
42
  private _els: Component[];
43
43
  private _vwp: Component;
@@ -14,7 +14,6 @@
14
14
  * that can be found in the LICENSE file or at https://opensource.org/licenses/MIT.
15
15
  **/
16
16
 
17
- import { class_ns } from '../../core/core_tools';
18
17
  import { Component, ComponentProps } from '../../core/component';
19
18
 
20
19
  import "./icon.module.scss"
@@ -111,8 +110,8 @@ export interface IconProps extends ComponentProps {
111
110
  * The CSS class for this component is automatically generated as `x4icon`.
112
111
  */
113
112
 
114
- @class_ns( "x4" )
115
113
  export class Icon extends Component<IconProps> {
114
+ static classPrefix = "x4";
116
115
 
117
116
  /**
118
117
  * Create a new Icon.
@@ -14,7 +14,6 @@
14
14
  * that can be found in the LICENSE file or at https://opensource.org/licenses/MIT.
15
15
  **/
16
16
 
17
- import { class_ns } from '../../core/core_tools';
18
17
  import { Component, ComponentEvents, ComponentProps } from '../../core/component';
19
18
  import { EventCallback, CoreEvent } from '../../core/core_events';
20
19
  import { dragManager } from '../../core/core_dragdrop';
@@ -56,8 +55,8 @@ export interface ImageProps extends ComponentProps {
56
55
  * ```
57
56
  */
58
57
 
59
- @class_ns( "x4" )
60
58
  export class Image<P extends ImageProps = ImageProps, E extends ImageEvents = ImageEvents> extends Component<P,E> {
59
+ static classPrefix = "x4";
61
60
 
62
61
  private _img: Component;
63
62
 
@@ -16,7 +16,7 @@
16
16
 
17
17
  import { EventCallback } from '../../core/core_events';
18
18
  import { Component, ComponentEvent, ComponentProps, EvChange, EvFocus } from '../../core/component';
19
- import { class_ns, formatIntlDate, IComponentInterface, IFormElement, isString } from '../../core/core_tools';
19
+ import { formatIntlDate, IComponentInterface, IFormElement, isString } from '../../core/core_tools';
20
20
 
21
21
  import "./input.module.scss"
22
22
 
@@ -214,8 +214,9 @@ interface InputEvents extends ComponentEvent {
214
214
  * ```
215
215
  */
216
216
 
217
- @class_ns( "x4" )
218
217
  export class Input extends Component<InputProps,InputEvents> {
218
+ static classPrefix = "x4";
219
+
219
220
  constructor( props: InputProps ) {
220
221
  super( { tag: "input", ...props } );
221
222
 
@@ -19,7 +19,6 @@ import { Box, BoxProps, Button, HBox, VBox } from '../components';
19
19
  import { _tr } from '../../core/core_i18n';
20
20
 
21
21
  import "./keyboard.module.scss"
22
- import { class_ns } from '../../core/core_tools';
23
22
  import { Application } from '../../core/core_application';
24
23
 
25
24
  import icon_bksp from "./delete-left.svg";
@@ -275,9 +274,10 @@ interface KeyboardProps extends BoxProps {
275
274
  * --keyboard-zoom
276
275
  * ```
277
276
  */
278
- @class_ns( "x4" )
279
277
  export class Keyboard extends HBox<KeyboardProps>
280
278
  {
279
+ static classPrefix = "x4";
280
+
281
281
  mode: KbMode;
282
282
  upper: boolean;
283
283
  locale: string;
@@ -18,7 +18,7 @@ import { Component, ComponentProps } from "../../core/component"
18
18
  import { Icon } from "../icon/icon"
19
19
 
20
20
  import "./label.module.scss";
21
- import { class_ns, UnsafeHtml } from '../../core/core_tools';
21
+ import { UnsafeHtml } from '../../core/core_tools';
22
22
 
23
23
  export interface LabelProps extends ComponentProps {
24
24
  text?: string | UnsafeHtml;
@@ -37,8 +37,8 @@ export interface LabelProps extends ComponentProps {
37
37
  * ```
38
38
  */
39
39
 
40
- @class_ns( "x4" )
41
40
  export class Label extends Component<LabelProps> {
41
+ static classPrefix = "x4";
42
42
 
43
43
  constructor( p: LabelProps ) {
44
44
  super( { ...p, content: null } );
@@ -79,8 +79,8 @@ export interface SimpleTextProps extends ComponentProps {
79
79
  align?: "left" | "center" | "right";
80
80
  }
81
81
 
82
- @class_ns( "x4" )
83
82
  export class SimpleText extends Component<SimpleTextProps> {
83
+ static classPrefix = "x4";
84
84
 
85
85
  /**
86
86
  *
@@ -16,7 +16,7 @@
16
16
 
17
17
  import { Component, ComponentEvents, ComponentProps, EvClick } from '../../core/component';
18
18
  import { EventCallback } from '../../core/core_events';
19
- import { class_ns, UnsafeHtml } from '../../core/core_tools';
19
+ import { UnsafeHtml } from '../../core/core_tools';
20
20
  import { Label } from '../label/label';
21
21
 
22
22
  import "./link.module.scss"
@@ -45,8 +45,9 @@ interface LinkProps extends ComponentProps {
45
45
  *
46
46
  */
47
47
 
48
- @class_ns( "x4" )
49
48
  export class Link extends Component<LinkProps,LinkEvents> {
49
+ static classPrefix = "x4";
50
+
50
51
  constructor( props: LinkProps ) {
51
52
  super( { tag: "a", ...props} );
52
53
 
@@ -16,7 +16,7 @@
16
16
 
17
17
  import { Component, ComponentEvent, ComponentEvents, componentFromDOM, ComponentProps, EvChange, EvClick, EvContextMenu, EvDblClick, EvSelectionChange } from '../../core/component';
18
18
  import { EventCallback } from '../../core/core_events';
19
- import { kbNav, class_ns, isArray, UnsafeHtml, asap } from '../../core/core_tools';
19
+ import { kbNav, isArray, UnsafeHtml, asap } from '../../core/core_tools';
20
20
 
21
21
  import { ScrollView, Viewport } from '../viewport/viewport';
22
22
  import { Header } from '../header/header';
@@ -118,8 +118,8 @@ export interface ListboxProps extends Omit<ComponentProps,'content'> {
118
118
  * ```
119
119
  */
120
120
 
121
- @class_ns( "x4" )
122
121
  export class Listbox extends Component<ListboxProps,ListboxEvents> {
122
+ static classPrefix = "x4";
123
123
 
124
124
  private _view: Viewport;
125
125
  private _lastsel: ListboxID;
@@ -16,7 +16,7 @@
16
16
 
17
17
  import { Component } from "../../core/component"
18
18
  import { DOMEventHandler } from '../../core/core_dom';
19
- import { Timer, UnsafeHtml, class_ns, isFunction, isString } from '../../core/core_tools';
19
+ import { Timer, UnsafeHtml, isFunction, isString } from '../../core/core_tools';
20
20
 
21
21
  import { Popup, PopupProps } from '../popup/popup';
22
22
  import { Icon } from '../icon/icon';
@@ -59,8 +59,9 @@ export interface MenuProps extends Omit<PopupProps,"content"> {
59
59
  * ```
60
60
  */
61
61
 
62
- @class_ns( "x4" )
63
62
  class CMenuSep extends Component {
63
+ static classPrefix = "x4";
64
+
64
65
  constructor( ) {
65
66
  super( { } );
66
67
  }
@@ -73,8 +74,8 @@ const openTimer = new Timer( );
73
74
  *
74
75
  */
75
76
 
76
- @class_ns( "x4" )
77
77
  class CMenuItem extends Component {
78
+ static classPrefix = "x4";
78
79
 
79
80
  private menu: Menu;
80
81
 
@@ -164,8 +165,8 @@ class CMenuItem extends Component {
164
165
  *
165
166
  */
166
167
 
167
- @class_ns( "x4" )
168
168
  export class Menu extends Popup {
169
+ static classPrefix = "x4";
169
170
 
170
171
  constructor( props: MenuProps ) {
171
172
  super( { ...props, autoClose: "menu" } );
@@ -25,8 +25,10 @@
25
25
  --msgbox-log-background: var( --background-ternary ); // the lines of a ProgressionBox
26
26
  --msgbox-log-border: var( --border );
27
27
  --msgbox-log-border-focus: var( --border-focus );
28
- --msgbox-log-error-color: var( --alert-background );
28
+ --msgbox-log-error-color: var( --alert-background ); // the text and the bar of an error
29
+ --msgbox-log-error-background: var( --alert-background-light );
29
30
  --msgbox-log-warning-color: var( --warning-background );
31
+ --msgbox-log-warning-background: var( --warning-background-light );
30
32
  --msgbox-log-scrollbar: var( --border-hover ); // the thumb; the track is the background of the lines
31
33
  }
32
34
 
@@ -158,9 +160,10 @@
158
160
  margin: 0 6px 0 16px;
159
161
  }
160
162
 
161
- // the lines: a <pre>, 10 lines high at least; its text gives it no size (contain): it
162
- // scrolls, the box does not grow; a line is not wrapped. An error, a warning: their
163
- // icon, their colour
163
+ // the lines: a <pre> in a fixed font, 10 lines high at least; its text gives it no size
164
+ // (contain): it scrolls, the box does not grow; a line is not wrapped. Each line is a
165
+ // <div>, all of them as wide as the longest one (the column of the grid): an error, a
166
+ // warning, coloured on all their width, a bar on their left
164
167
  #sub-text {
165
168
  flex-grow: 1;
166
169
  min-height: calc( 10lh + 10px ); // its padding and its border too
@@ -168,15 +171,35 @@
168
171
  overflow: auto;
169
172
  white-space: pre;
170
173
  contain: size;
174
+ display: grid;
175
+ grid-template-columns: minmax( max-content, 1fr );
176
+ align-content: start;
171
177
  font: inherit;
178
+ font-family: monospace, monospace;
172
179
  line-height: 1.3em;
173
180
  scrollbar-color: var( --msgbox-log-scrollbar ) transparent;
174
181
  outline: none;
175
182
  border: 1px solid var( --msgbox-log-border );
176
183
  background-color: var( --msgbox-log-background );
177
- padding: 4px 8px;
184
+ padding: 4px 0;
178
185
  margin: 0 6px 0 16px;
179
186
 
187
+ .line {
188
+ min-height: 1lh; // an empty line too
189
+ padding: 0 8px;
190
+ border-left: 3px solid transparent;
191
+
192
+ &.error {
193
+ background-color: var( --msgbox-log-error-background );
194
+ border-left-color: var( --msgbox-log-error-color );
195
+ }
196
+
197
+ &.warning {
198
+ background-color: var( --msgbox-log-warning-background );
199
+ border-left-color: var( --msgbox-log-warning-color );
200
+ }
201
+ }
202
+
180
203
  &, * {
181
204
  user-select: text;
182
205
  }
@@ -207,6 +230,7 @@
207
230
 
208
231
  summary {
209
232
  margin-left: -1em;
233
+ padding-left: 11px; // as the text of a line: its padding and its bar
210
234
  cursor: pointer;
211
235
  font-weight: bold;
212
236
  }
@@ -2,7 +2,7 @@
2
2
  // :: MESSAGEBOX ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
3
3
 
4
4
  import { _tr } from '../../core/core_i18n';
5
- import { asap, class_ns, sprintf, unsafeHtml, UnsafeHtml } from '../../core/core_tools';
5
+ import { asap, sprintf, unsafeHtml, UnsafeHtml } from '../../core/core_tools';
6
6
 
7
7
  import { HBox, VBox } from '../boxes/boxes';
8
8
  import { Icon } from '../icon/icon';
@@ -41,16 +41,19 @@ export interface MessageBoxProps extends DialogProps {
41
41
  * --msgbox-log-border
42
42
  * --msgbox-log-border-focus
43
43
  * --msgbox-log-error-color
44
+ * --msgbox-log-error-background
44
45
  * --msgbox-log-warning-color
46
+ * --msgbox-log-warning-background
45
47
  * --msgbox-log-scrollbar
46
48
  * ```
47
49
  * --msgbox-caption-* and --msgbox-icon-color are the ones of an error; a question, an InputBox
48
50
  * and a PromptBox have the title bar of a Dialog and their icon in --msgbox-question-icon-color
49
51
  */
50
52
 
51
- @class_ns( "x4" )
52
53
  export class MessageBox extends Dialog<DialogProps>
53
54
  {
55
+ static classPrefix = "x4";
56
+
54
57
  constructor(props: DialogProps) {
55
58
  super(props);
56
59
  }
@@ -139,9 +142,10 @@ interface InputOptions {
139
142
  trim?: boolean;
140
143
  }
141
144
 
142
- @class_ns( "x4" )
143
145
  export class InputBox extends Dialog<DialogProps>
144
146
  {
147
+ static classPrefix = "x4";
148
+
145
149
  constructor(props: DialogProps) {
146
150
  super(props);
147
151
  }
@@ -208,9 +212,10 @@ export class InputBox extends Dialog<DialogProps>
208
212
  // :: PROMPT ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
209
213
 
210
214
 
211
- @class_ns( "x4" )
212
215
  export class PromptBox extends Dialog<DialogProps>
213
216
  {
217
+ static classPrefix = "x4";
218
+
214
219
  constructor(props: DialogProps) {
215
220
  super(props);
216
221
  }
@@ -284,21 +289,21 @@ export class PromptBox extends Dialog<DialogProps>
284
289
 
285
290
  /**
286
291
  * a modal box that follows a long task: a title, a bar, and the lines of what is done
287
- * in a <pre>: a string is text, an UnsafeHtml is html. An error, a warning have their
288
- * icon and their colour. addSection puts the lines that follow in a section that folds.
289
- * Ctrl+A selects the lines.
292
+ * in a <pre>, in a fixed font, a <div> each: a string is text, an UnsafeHtml is html. An
293
+ * error, a warning are coloured on all their width, a bar on their left. addSection puts
294
+ * the lines that follow in a section that folds. Ctrl+A selects the lines.
290
295
  * done( ) shows its button OK: after an error or a warning it waits for it, their counts
291
296
  * on the left of the bar; else it closes the box after 5s, the seconds left in the button.
292
297
  */
293
298
 
294
- @class_ns( "x4" )
295
299
  export class ProgressionBox extends Dialog {
300
+ static classPrefix = "x4";
296
301
 
297
302
  // an error or a warning: done( ) waits for OK
298
- #errors = 0;
299
- #warnings = 0;
303
+ private _errors = 0;
304
+ private _warnings = 0;
300
305
 
301
- #section: Component; // the last section (a <details>): the lines go in it
306
+ private _section: Component; // the last section (a <details>): the lines go in it
302
307
 
303
308
  constructor( title: string ) {
304
309
  super( {
@@ -348,7 +353,7 @@ export class ProgressionBox extends Dialog {
348
353
  this.query<Progress>( "#prog").setValue( perc );
349
354
  this.addClass( "error" ); // the title bar in red, as the one of an error of MessageBox
350
355
 
351
- this.#errors++;
356
+ this._errors++;
352
357
  }
353
358
 
354
359
  /** a line at the end, with the icon of a warning: done( ) then waits for the button OK */
@@ -357,7 +362,7 @@ export class ProgressionBox extends Dialog {
357
362
  this._addLine( text, "warning" );
358
363
  this.query<Progress>( "#prog").setValue( perc );
359
364
 
360
- this.#warnings++;
365
+ this._warnings++;
361
366
  }
362
367
 
363
368
  /**
@@ -369,10 +374,10 @@ export class ProgressionBox extends Dialog {
369
374
  const summary = new Component( { tag: "summary", content: new Component( { tag: "span", cls: "alert" } ) } );
370
375
  summary.appendContent( title );
371
376
 
372
- this.#section = new Component( { tag: "details", attrs: { open: true }, content: summary } );
377
+ this._section = new Component( { tag: "details", attrs: { open: true }, content: summary } );
373
378
 
374
379
  const log = this.query( "#sub-text" );
375
- log.appendContent( this.#section );
380
+ log.appendContent( this._section );
376
381
  log.dom.scrollTop = log.dom.scrollHeight;
377
382
  this.query<Progress>( "#prog").setValue( perc );
378
383
  }
@@ -380,7 +385,7 @@ export class ProgressionBox extends Dialog {
380
385
  /** the text in place of all the lines */
381
386
 
382
387
  setText( text: string | UnsafeHtml, perc: number ) {
383
- this.#section = null;
388
+ this._section = null;
384
389
  this.query( "#sub-text" ).setContent( text );
385
390
  this.query<Progress>( "#prog").setValue( perc );
386
391
  }
@@ -388,44 +393,31 @@ export class ProgressionBox extends Dialog {
388
393
  /** as at the start: no line, no error, no button OK */
389
394
 
390
395
  clear( ) {
391
- this.#errors = 0;
392
- this.#warnings = 0;
396
+ this._errors = 0;
397
+ this._warnings = 0;
393
398
  this.clearInterval( "close" );
394
399
  this.query( "#btnbar" ).show( false );
395
400
  this.removeClass( "error" );
396
401
  this.query<Label>( "#alerts" ).setText( "" );
397
402
  this.query<Label>( "#alerts" ).setIcon( null );
398
- this.#section = null;
403
+ this._section = null;
399
404
  this.query( "#sub-text" ).clearContent( );
400
405
  }
401
406
 
402
- // the line after the others (in the last section), the last one shown; an error, a
403
- // warning in a span of their class, their icon first
407
+ // the line after the others (in the last section), the last one shown: a <div>, of the
408
+ // class of its kind for an error, a warning
404
409
  private _addLine( text: string | UnsafeHtml, kind?: "error" | "warning" ) {
405
410
  const log = this.query( "#sub-text" );
406
- const target = this.#section ?? log;
411
+ const target = this._section ?? log;
407
412
 
408
- // after the summary of a section, its first line starts below it
409
- if( target.dom.lastChild && target.dom.lastChild.nodeName!="SUMMARY" ) {
410
- target.appendContent( "\n" );
411
- }
413
+ target.appendContent( new Component( { cls: kind ? "line " + kind : "line", content: text } ) );
412
414
 
413
- if( kind ) {
414
- const icon = kind=="error" ? icons.danger : icons.warning;
415
- const line = new Component( { tag: "span", cls: kind, content: unsafeHtml( icon ) } );
416
- line.appendContent( text );
417
- target.appendContent( line );
418
-
419
- // the title of the section: the icon of the worst, in its colour
420
- const alert = this.#section?.query( ".alert" );
421
- if( alert && !alert.hasClass( "error" ) ) {
422
- alert.setClass( "warning", kind=="warning" );
423
- alert.setClass( "error", kind=="error" );
424
- alert.setContent( unsafeHtml( icon ) );
425
- }
426
- }
427
- else {
428
- target.appendContent( text );
415
+ // the title of the section: the icon of the worst, in its colour
416
+ const alert = this._section?.query( ".alert" );
417
+ if( kind && alert && !alert.hasClass( "error" ) ) {
418
+ alert.setClass( "warning", kind=="warning" );
419
+ alert.setClass( "error", kind=="error" );
420
+ alert.setContent( unsafeHtml( kind=="error" ? icons.danger : icons.warning ) );
429
421
  }
430
422
 
431
423
  log.dom.scrollTop = log.dom.scrollHeight;
@@ -449,22 +441,22 @@ export class ProgressionBox extends Dialog {
449
441
  const ok = this.query<Button>( "#ok" );
450
442
  this.query( "#btnbar" ).show( true );
451
443
 
452
- if( this.#errors || this.#warnings ) {
444
+ if( this._errors || this._warnings ) {
453
445
  const tr = _tr.global.progression;
454
446
  const counts = [];
455
- if( this.#errors ) {
456
- counts.push( sprintf( this.#errors>1 ? tr.errors : tr.error, this.#errors ) );
447
+ if( this._errors ) {
448
+ counts.push( sprintf( this._errors>1 ? tr.errors : tr.error, this._errors ) );
457
449
  }
458
- if( this.#warnings ) {
459
- counts.push( sprintf( this.#warnings>1 ? tr.warnings : tr.warning, this.#warnings ) );
450
+ if( this._warnings ) {
451
+ counts.push( sprintf( this._warnings>1 ? tr.warnings : tr.warning, this._warnings ) );
460
452
  }
461
453
 
462
454
  // on the left, the icon of the worst
463
455
  const alerts = this.query<Label>( "#alerts" );
464
456
  alerts.setText( counts.join( " / " ) );
465
- alerts.setIcon( this.#errors ? icons.danger : icons.warning );
466
- alerts.setClass( "error", this.#errors>0 );
467
- alerts.setClass( "warning", this.#errors==0 );
457
+ alerts.setIcon( this._errors ? icons.danger : icons.warning );
458
+ alerts.setClass( "error", this._errors>0 );
459
+ alerts.setClass( "warning", this._errors==0 );
468
460
 
469
461
  ok.setText( _tr.global.ok );
470
462
  return;
@@ -15,7 +15,7 @@
15
15
  **/
16
16
 
17
17
  import { ComponentProps } from '../../core/component';
18
- import { asap, class_ns, Rect, UnsafeHtml } from '../../core/core_tools';
18
+ import { asap, Rect, UnsafeHtml } from '../../core/core_tools';
19
19
 
20
20
  import { Popup } from '../popup/popup';
21
21
  import { HBox, VBox } from '../boxes/boxes';
@@ -61,8 +61,9 @@ interface NotificationProps extends ComponentProps {
61
61
  * ```
62
62
  */
63
63
 
64
- @class_ns( "x4" )
65
64
  export class Notification extends Popup {
65
+ static classPrefix = "x4";
66
+
66
67
  private static list = new Set<Notification>( );
67
68
 
68
69
  constructor( props: NotificationProps ) {
@@ -15,7 +15,7 @@
15
15
  **/
16
16
 
17
17
  import { Component, ComponentContent, ComponentProps } from '../../core/component';
18
- import { UnsafeHtml, Constructor, class_ns } from '../../core/core_tools';
18
+ import { UnsafeHtml, Constructor } from '../../core/core_tools';
19
19
 
20
20
  import { VBox } from '../boxes/boxes';
21
21
  import { Label } from '../label/label';
@@ -37,8 +37,8 @@ interface PanelProps extends ComponentProps {
37
37
  * ```
38
38
  */
39
39
 
40
- @class_ns( "x4" )
41
40
  export class Panel extends VBox<PanelProps> {
41
+ static classPrefix = "x4";
42
42
 
43
43
  private _title: Label;
44
44
  private _body: Component;