x4js 2.2.46 → 2.2.47
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 +1 -1
- package/src/components/button/button.ts +14 -11
- package/src/components/listbox/listbox.module.scss +12 -7
- package/src/components/menu/menu.ts +12 -2
- package/src/components/notification/notification.module.scss +5 -0
- package/src/components/notification/notification.ts +8 -3
- package/src/components/popup/popup.ts +4 -1
- package/src/components/tag/tag.module.scss +15 -5
package/package.json
CHANGED
|
@@ -14,9 +14,10 @@
|
|
|
14
14
|
* that can be found in the LICENSE file or at https://opensource.org/licenses/MIT.
|
|
15
15
|
**/
|
|
16
16
|
|
|
17
|
+
import { Menu, MenuElement, MenuProps } from 'x4js';
|
|
17
18
|
import { Component, ComponentEvents, ComponentProps, EvClick } from "../../core/component"
|
|
18
19
|
import { EventCallback } from '../../core/core_events';
|
|
19
|
-
import { class_ns, UnsafeHtml } from '../../core/core_tools';
|
|
20
|
+
import { class_ns, isFunction, UnsafeHtml } from '../../core/core_tools';
|
|
20
21
|
|
|
21
22
|
import { Icon } from "../icon/icon"
|
|
22
23
|
|
|
@@ -68,6 +69,8 @@ export interface ButtonProps extends ComponentProps {
|
|
|
68
69
|
* cf. ButtonEvents
|
|
69
70
|
*/
|
|
70
71
|
click?: EventCallback<EvClick>;
|
|
72
|
+
|
|
73
|
+
menu?: MenuElement[] | (( ) => MenuElement[]);
|
|
71
74
|
}
|
|
72
75
|
|
|
73
76
|
/**
|
|
@@ -131,17 +134,17 @@ export class Button extends Component<ButtonProps,ButtonEvents> {
|
|
|
131
134
|
|
|
132
135
|
protected _on_click( ev: MouseEvent ) {
|
|
133
136
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
137
|
+
if (this.props.menu) {
|
|
138
|
+
let menu = new Menu({
|
|
139
|
+
items: isFunction(this.props.menu) ? this.props.menu() : this.props.menu
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
let rc = this.getBoundingRect();
|
|
143
|
+
menu.displayNear(rc, 'top-left', 'bottom-left' );
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
143
146
|
this.fire('click', {} );
|
|
144
|
-
|
|
147
|
+
}
|
|
145
148
|
|
|
146
149
|
ev.preventDefault();
|
|
147
150
|
ev.stopPropagation();
|
|
@@ -17,16 +17,17 @@
|
|
|
17
17
|
@use "../shared.scss";
|
|
18
18
|
|
|
19
19
|
:root {
|
|
20
|
-
--listbox-item-
|
|
20
|
+
--listbox-item-color: var( --text-primary );
|
|
21
|
+
--listbox-icon-color: var( --text-ternary );
|
|
22
|
+
--listbox-item-color-disabled: var( --disabled-color-dark );
|
|
23
|
+
|
|
21
24
|
--listbox-item-color-sel: var( --accent-color );
|
|
25
|
+
--listbox-item-background-sel: var( --accent-background );
|
|
22
26
|
--listbox-item-color-sel-disabled: var( --disabled-background );
|
|
23
27
|
|
|
24
|
-
--listbox-item-color: var( --text-primary )
|
|
25
|
-
--listbox-item-color-disabled: var( --disabled-color-dark );
|
|
28
|
+
--listbox-item-color-hover: var( --text-primary );;
|
|
26
29
|
--listbox-item-background-hover: var( --background-secondary );
|
|
27
30
|
|
|
28
|
-
--listbox-icon-color: var( --text-ternary );
|
|
29
|
-
|
|
30
31
|
--listbox-background: white;
|
|
31
32
|
--listbox-border: var( --border );
|
|
32
33
|
--listbox-border-focus: var( --accent-background-focus );
|
|
@@ -79,6 +80,7 @@
|
|
|
79
80
|
}
|
|
80
81
|
}
|
|
81
82
|
}
|
|
83
|
+
}
|
|
82
84
|
|
|
83
85
|
.x4item {
|
|
84
86
|
@extend %flex;
|
|
@@ -93,9 +95,10 @@
|
|
|
93
95
|
padding: 4px 0;
|
|
94
96
|
}
|
|
95
97
|
|
|
98
|
+
--label-color: var( --listbox-item-color );
|
|
99
|
+
|
|
96
100
|
.x4label,
|
|
97
101
|
.x4simpletext {
|
|
98
|
-
color: inherit;
|
|
99
102
|
padding: 2px 6px;
|
|
100
103
|
|
|
101
104
|
#icon {
|
|
@@ -106,12 +109,15 @@
|
|
|
106
109
|
|
|
107
110
|
&:hover {
|
|
108
111
|
background-color: var( --listbox-item-background-hover );
|
|
112
|
+
--label-color: var( --listbox-item-color-hover );
|
|
109
113
|
}
|
|
110
114
|
|
|
111
115
|
&.selected {
|
|
112
116
|
background-color: var( --listbox-item-background-sel );
|
|
113
117
|
color: var( --listbox-item-color-sel );
|
|
114
118
|
|
|
119
|
+
--label-color: var( --listbox-item-color-sel );
|
|
120
|
+
|
|
115
121
|
&> .x4label {
|
|
116
122
|
#icon {
|
|
117
123
|
color: var( --listbox-item-color-sel );
|
|
@@ -133,7 +139,6 @@
|
|
|
133
139
|
//color: var(--color-0);
|
|
134
140
|
//}
|
|
135
141
|
|
|
136
|
-
}
|
|
137
142
|
}
|
|
138
143
|
|
|
139
144
|
&.empty .body .x4viewport {
|
|
@@ -16,11 +16,12 @@
|
|
|
16
16
|
|
|
17
17
|
import { Component } from "../../core/component"
|
|
18
18
|
import { DOMEventHandler } from '../../core/core_dom';
|
|
19
|
-
import { Timer, UnsafeHtml, class_ns, isString } from '../../core/core_tools';
|
|
19
|
+
import { Timer, UnsafeHtml, class_ns, isFunction, isString } from '../../core/core_tools';
|
|
20
20
|
|
|
21
21
|
import { Popup, PopupProps } from '../popup/popup';
|
|
22
22
|
import { Icon } from '../icon/icon';
|
|
23
23
|
|
|
24
|
+
import icons from "../assets/icons";
|
|
24
25
|
import "./menu.module.scss"
|
|
25
26
|
|
|
26
27
|
const OPEN_DELAY = 400;
|
|
@@ -35,6 +36,7 @@ export interface MenuItem {
|
|
|
35
36
|
text: string | UnsafeHtml;
|
|
36
37
|
menu?: Menu;
|
|
37
38
|
disabled?: boolean;
|
|
39
|
+
checked?: boolean | ( () => boolean);
|
|
38
40
|
click?: DOMEventHandler;
|
|
39
41
|
}
|
|
40
42
|
|
|
@@ -74,8 +76,16 @@ class CMenuItem extends Component {
|
|
|
74
76
|
this.addClass( "popup" );
|
|
75
77
|
}
|
|
76
78
|
|
|
79
|
+
let iconId = itm.icon;
|
|
80
|
+
if( !iconId && itm.checked ) {
|
|
81
|
+
const chk = isFunction(itm.checked) ? itm.checked() : itm.checked;
|
|
82
|
+
if( chk ) {
|
|
83
|
+
iconId = icons.check;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
77
87
|
this.setContent( [
|
|
78
|
-
new Icon({ id:"icon",iconId
|
|
88
|
+
new Icon({ id:"icon", iconId }),
|
|
79
89
|
new Component( { id: "text", content: itm.text } )
|
|
80
90
|
]);
|
|
81
91
|
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
**/
|
|
16
16
|
|
|
17
17
|
import { ComponentProps } from '../../core/component';
|
|
18
|
-
import { class_ns, Rect, UnsafeHtml } from '../../core/core_tools';
|
|
18
|
+
import { asap, class_ns, Rect, UnsafeHtml } from '../../core/core_tools';
|
|
19
19
|
|
|
20
20
|
import { Popup } from '../popup/popup';
|
|
21
21
|
import { HBox, VBox } from '../boxes/boxes';
|
|
@@ -88,6 +88,8 @@ export class Notification extends Popup {
|
|
|
88
88
|
|
|
89
89
|
close( ) {
|
|
90
90
|
Notification.list.delete( this );
|
|
91
|
+
asap( ( ) => Notification.updatePositions( ) )
|
|
92
|
+
|
|
91
93
|
this.clearTimeout( "close" );
|
|
92
94
|
super.close( );
|
|
93
95
|
}
|
|
@@ -100,14 +102,17 @@ export class Notification extends Popup {
|
|
|
100
102
|
} );
|
|
101
103
|
}
|
|
102
104
|
|
|
103
|
-
|
|
105
|
+
//this.setStyleValue( "top", "9999px" );
|
|
106
|
+
|
|
107
|
+
asap( ( ) => Notification.updatePositions( ) )
|
|
104
108
|
}
|
|
105
109
|
|
|
106
110
|
static updatePositions( ) {
|
|
107
111
|
const r = new Rect( 0, 0, window.innerWidth, window.innerHeight );
|
|
108
112
|
|
|
109
113
|
for( const n of this.list ) {
|
|
110
|
-
n.
|
|
114
|
+
n.addClass( "smooth" );
|
|
115
|
+
n.displayNear( r, "bottom right", "bottom right", { x: -20, y: -10 }, true );
|
|
111
116
|
const nr = n.getBoundingRect( );
|
|
112
117
|
r.height -= nr.height+10;
|
|
113
118
|
if( r.height<10 ) {
|
|
@@ -79,9 +79,12 @@ export class Popup<P extends PopupProps = PopupProps, E extends PopupEvents = Po
|
|
|
79
79
|
*
|
|
80
80
|
*/
|
|
81
81
|
|
|
82
|
-
displayNear( rc: Rect, dst = "top left", src = "top left", offset = {x:0,y:0} ) {
|
|
82
|
+
displayNear( rc: Rect, dst = "top left", src = "top left", offset = {x:0,y:0}, keep_pos = false ) {
|
|
83
83
|
|
|
84
|
+
if( !keep_pos ) {
|
|
84
85
|
this.setStyle( { left: "0px", top: "0px" } ); // avoid scrollbar
|
|
86
|
+
}
|
|
87
|
+
|
|
85
88
|
this._do_show( ); // to compute size
|
|
86
89
|
|
|
87
90
|
let rm = this.getBoundingRect();
|
|
@@ -4,27 +4,37 @@
|
|
|
4
4
|
* @copyright (c) 2026 R-libre ingenierie, all rights reserved.
|
|
5
5
|
**/
|
|
6
6
|
|
|
7
|
+
:root {
|
|
8
|
+
--tag-border: var( --border );
|
|
9
|
+
--tag-border-focus: var( --border-focus );
|
|
10
|
+
--tag-selection: var( --accent-background );
|
|
11
|
+
--tag-color: black;
|
|
12
|
+
--tag-icon-color: var( --tag-color );
|
|
13
|
+
}
|
|
14
|
+
|
|
7
15
|
.x4tag {
|
|
8
|
-
color: black;
|
|
9
16
|
border-radius: 16px;
|
|
10
|
-
border: 1px solid var( --border );
|
|
17
|
+
border: 1px solid var( --tag-border );
|
|
11
18
|
padding: 2px 8px;
|
|
12
19
|
gap: 4px;
|
|
13
20
|
font-weight: normal;
|
|
21
|
+
--label-color: var( --tag-color );
|
|
14
22
|
|
|
15
23
|
.x4icon:empty {
|
|
16
24
|
display: none;
|
|
17
25
|
}
|
|
18
26
|
|
|
19
27
|
.x4icon {
|
|
28
|
+
height: 1em;
|
|
29
|
+
color: var( --tag-icon-color );
|
|
20
30
|
}
|
|
21
31
|
|
|
22
|
-
.x4simpletext {
|
|
23
|
-
|
|
32
|
+
&> .x4simpletext {
|
|
33
|
+
padding: 0;
|
|
24
34
|
}
|
|
25
35
|
|
|
26
36
|
&.alert {
|
|
27
|
-
color: var( --alert-color );
|
|
37
|
+
--tag-color: var( --alert-color );
|
|
28
38
|
background-color: var( --alert-background );
|
|
29
39
|
}
|
|
30
40
|
}
|