x4js 2.3.15 → 2.3.17

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.
@@ -59,6 +59,10 @@ export class Gauge extends Component<GaugeProps> {
59
59
  constructor( props: GaugeProps ) {
60
60
  super( props );
61
61
 
62
+ // no range given: 0 to 100
63
+ this.props.min = props.min ?? 0;
64
+ this.props.max = props.max ?? 100;
65
+
62
66
  this.pos = 70;
63
67
  this.stops = [];
64
68
 
@@ -410,7 +410,12 @@ export class Input extends Component<InputProps,InputEvents> {
410
410
  */
411
411
 
412
412
  public setNumValue( value: number, ndec = -1 ) {
413
-
413
+
414
+ // no number (a field that is not filled): the field is emptied
415
+ if( value===undefined || value===null || isNaN( value ) ) {
416
+ return this.setValue( "" );
417
+ }
418
+
414
419
  if( ndec==-2 && this.props.type=='number' ) {
415
420
  const p = this.props as NumberProps;
416
421
 
@@ -18,7 +18,11 @@
18
18
 
19
19
  :root {
20
20
  --notification-border: var( --border );
21
- --notification-background: white;
21
+ --notification-background: var( --background-primary );
22
+
23
+ --notification-title-color: var( --text-primary );
24
+ --notification-text-color: var( --text-ternary );
25
+ --notification-button-color: var( --text-ternary );
22
26
 
23
27
  --notification-icon-default: var( --accent-background );
24
28
  --notification-icon-success: var( --success-background );
@@ -54,11 +58,12 @@
54
58
  .title {
55
59
  font-weight: bold;
56
60
  padding: 6px 6px 3px 6px;
61
+ color: var( --notification-title-color );
57
62
  }
58
63
 
59
64
  .text {
60
65
  padding: 3px 6px 6px 6px;
61
- color: var( --color-gray-7 );
66
+ color: var( --notification-text-color );
62
67
  }
63
68
  }
64
69
 
@@ -81,7 +86,7 @@
81
86
 
82
87
  .x4button {
83
88
  height: 24px;
84
- color: var( --color-gray-7 );
89
+ color: var( --notification-button-color );
85
90
  border: none;
86
91
 
87
92
  //&:hover {
@@ -52,6 +52,9 @@ interface NotificationProps extends ComponentProps {
52
52
  * ```
53
53
  * --notification-border
54
54
  * --notification-background
55
+ * --notification-title-color
56
+ * --notification-text-color
57
+ * --notification-button-color
55
58
  * --notification-icon-default
56
59
  * --notification-icon-success
57
60
  * --notification-icon-danger
@@ -21,8 +21,8 @@ import "./progress.module.scss";
21
21
 
22
22
  interface ProgressProps extends ComponentProps {
23
23
  value: number;
24
- min: number;
25
- max: number;
24
+ min?: number; // 0 when missing
25
+ max?: number; // 100 when missing
26
26
  }
27
27
 
28
28
  /**
@@ -46,7 +46,11 @@ export class Progress extends Component<ProgressProps> {
46
46
  }
47
47
 
48
48
  setValue( value: number ) {
49
- const perc = value / (this.props.max-this.props.min) * 100;
49
+ const min = this.props.min ?? 0;
50
+ const max = this.props.max ?? 100;
51
+
52
+ // where the value is between the two: min is 0%, max is 100%
53
+ const perc = (value-min) / (max-min) * 100;
50
54
  this._bar.setStyleValue( "width", perc+"%" );
51
55
  }
52
56
  }
@@ -28,6 +28,7 @@ interface SwitchProps extends ComponentProps {
28
28
  label: string;
29
29
  checked?: boolean;
30
30
  value?: string;
31
+ name?: string; // with it, a Form reads and writes the switch (a boolean)
31
32
  }
32
33
 
33
34
  /**
@@ -52,7 +53,7 @@ export class Switch extends HBox<SwitchProps> {
52
53
  new Component( {
53
54
  cls: "switch",
54
55
  content: [
55
- new Input( { type: "checkbox", id: inputId, checked: props.checked } ),
56
+ new Input( { type: "checkbox", id: inputId, name: props.name, checked: props.checked } ),
56
57
  new Component( { cls: "track" } ),
57
58
  new Component( { cls: "thumb" } ),
58
59
  ]
@@ -1197,7 +1197,7 @@ export class Component<P extends ComponentProps = ComponentProps, E extends Comp
1197
1197
 
1198
1198
  // straight on the element, not with addDOMEvent: the handlers of the
1199
1199
  // children are called exactly as before
1200
- this.dom.addEventListener( "keydown", ( ev: KeyboardEvent ) => shortcuts.handle( ev ) );
1200
+ this.dom.addEventListener( "keydown", ( ev ) => shortcuts.handle( ev as KeyboardEvent ) );
1201
1201
  this.dom.addEventListener( "focusin", ( ) => Application.instance( ).setActiveShortcuts( this, shortcuts ) );
1202
1202
  }
1203
1203