x4js 2.0.11 → 2.0.13
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/README.md +15 -15
- package/lib/README.txt +15 -15
- package/lib/cjs/x4.css +1 -1
- package/lib/cjs/x4.js +1 -1
- package/lib/esm/x4.css +1 -1
- package/lib/esm/x4.mjs +1 -1
- package/lib/src/components/base.scss +25 -26
- package/lib/src/components/boxes/boxes.module.scss +37 -37
- package/lib/src/components/boxes/boxes.ts +129 -125
- package/lib/src/components/breadcrumb/breadcrumb.scss +28 -0
- package/lib/src/components/breadcrumb/breadcrumb.ts +84 -0
- package/lib/src/components/breadcrumb/chevron-right.svg +1 -0
- package/lib/src/components/btngroup/btngroup.module.scss +28 -28
- package/lib/src/components/btngroup/btngroup.ts +119 -101
- package/lib/src/components/button/button.module.scss +154 -153
- package/lib/src/components/button/button.ts +117 -117
- package/lib/src/components/calendar/calendar.module.scss +162 -162
- package/lib/src/components/calendar/calendar.ts +326 -325
- package/lib/src/components/checkbox/check.svg +3 -3
- package/lib/src/components/checkbox/checkbox.module.scss +141 -141
- package/lib/src/components/checkbox/checkbox.ts +125 -124
- package/lib/src/components/colorinput/colorinput.module.scss +64 -64
- package/lib/src/components/colorinput/colorinput.ts +90 -87
- package/lib/src/components/colorpicker/colorpicker.module.scss +132 -132
- package/lib/src/components/colorpicker/colorpicker.ts +481 -476
- package/lib/src/components/combobox/combobox.module.scss +123 -120
- package/lib/src/components/combobox/combobox.ts +192 -190
- package/lib/src/components/combobox/updown.svg +3 -3
- package/lib/src/components/components.ts +34 -0
- package/lib/src/components/dialog/dialog.module.scss +71 -71
- package/lib/src/components/dialog/dialog.ts +94 -92
- package/lib/src/components/form/form.module.scss +34 -34
- package/lib/src/components/form/form.ts +41 -36
- package/lib/src/components/grid/datastore.ts +1298 -0
- package/lib/src/components/grid/gridview.ts +1108 -0
- package/lib/src/components/grid/memdb.ts +325 -0
- package/lib/src/components/header/header.module.scss +39 -39
- package/lib/src/components/header/header.ts +129 -123
- package/lib/src/components/icon/icon.module.scss +29 -29
- package/lib/src/components/icon/icon.ts +136 -134
- package/lib/src/components/image/image.module.scss +20 -20
- package/lib/src/components/image/image.ts +68 -66
- package/lib/src/components/input/input.module.scss +69 -69
- package/lib/src/components/input/input.ts +275 -274
- package/lib/src/components/label/label.module.scss +58 -52
- package/lib/src/components/label/label.ts +64 -55
- package/lib/src/components/link/link.ts +78 -0
- package/lib/src/components/listbox/listbox.module.scss +103 -103
- package/lib/src/components/listbox/listbox.ts +431 -427
- package/lib/src/components/menu/menu.module.scss +107 -107
- package/lib/src/components/menu/menu.ts +171 -168
- package/lib/src/components/messages/messages.module.scss +48 -47
- package/lib/src/components/messages/messages.ts +68 -63
- package/lib/src/components/normalize.scss +386 -386
- package/lib/src/components/notification/notification.module.scss +81 -81
- package/lib/src/components/notification/notification.ts +109 -108
- package/lib/src/components/panel/panel.module.scss +47 -47
- package/lib/src/components/panel/panel.ts +57 -56
- package/lib/src/components/popup/popup.module.scss +43 -43
- package/lib/src/components/popup/popup.ts +396 -395
- package/lib/src/components/progress/progress.module.scss +56 -56
- package/lib/src/components/progress/progress.ts +43 -42
- package/lib/src/components/rating/rating.module.scss +22 -22
- package/lib/src/components/rating/rating.ts +131 -125
- package/lib/src/components/shared.scss +90 -76
- package/lib/src/components/sizers/sizer.module.scss +89 -89
- package/lib/src/components/sizers/sizer.ts +123 -119
- package/lib/src/components/slider/slider.module.scss +70 -70
- package/lib/src/components/slider/slider.ts +147 -142
- package/lib/src/components/switch/switch.module.scss +126 -126
- package/lib/src/components/switch/switch.ts +61 -55
- package/lib/src/components/tabs/tabs.module.scss +46 -46
- package/lib/src/components/tabs/tabs.ts +168 -157
- package/lib/src/components/textarea/textarea.module.scss +59 -59
- package/lib/src/components/textarea/textarea.ts +60 -54
- package/lib/src/components/textedit/textedit.module.scss +113 -113
- package/lib/src/components/textedit/textedit.ts +83 -82
- package/lib/src/components/themes.scss +81 -77
- package/lib/src/components/tooltips/tooltips.scss +50 -50
- package/lib/src/components/tooltips/tooltips.ts +103 -102
- package/lib/src/components/treeview/treeview.module.scss +115 -115
- package/lib/src/components/treeview/treeview.ts +410 -403
- package/lib/src/components/viewport/viewport.module.scss +24 -24
- package/lib/src/components/viewport/viewport.ts +41 -38
- package/lib/src/core/component.ts +1002 -979
- package/lib/src/core/core_application.ts +44 -0
- package/lib/src/core/core_colors.ts +249 -249
- package/lib/src/core/core_dom.ts +471 -471
- package/lib/src/core/core_dragdrop.ts +200 -200
- package/lib/src/core/core_element.ts +97 -97
- package/lib/src/core/core_events.ts +149 -149
- package/lib/src/core/core_i18n.ts +377 -377
- package/lib/src/core/core_router.ts +221 -221
- package/lib/src/core/core_styles.ts +214 -214
- package/lib/src/core/core_svg.ts +550 -550
- package/lib/src/core/core_tools.ts +688 -673
- package/lib/src/demo/assets/radio.svg +3 -3
- package/lib/src/demo/index.html +11 -11
- package/lib/src/demo/main.scss +21 -21
- package/lib/src/demo/main.tsx +323 -323
- package/lib/src/types/scss.d.ts +4 -4
- package/lib/src/types/x4react.d.ts +8 -8
- package/lib/src/x4.scss +18 -18
- package/lib/src/x4.ts +31 -60
- package/lib/styles/x4.css +1 -1
- package/lib/types/x4js.d.ts +100 -49
- package/package.json +2 -3
- package/src/x4.ts +31 -60
- package/lib/output.d.ts +0 -1472
|
@@ -1,125 +1,129 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ___ ___ __
|
|
3
|
-
* \ \/ / / _
|
|
4
|
-
* \ / /_| |_
|
|
5
|
-
* / \____ _|
|
|
6
|
-
* /__/\__\ |_|
|
|
7
|
-
*
|
|
8
|
-
* @file boxes.ts
|
|
9
|
-
* @author Etienne Cochard
|
|
10
|
-
*
|
|
11
|
-
* @copyright (c) 2024 R-libre ingenierie
|
|
12
|
-
*
|
|
13
|
-
* Use of this source code is governed by an MIT-style license
|
|
14
|
-
* that can be found in the LICENSE file or at https://opensource.org/licenses/MIT.
|
|
15
|
-
**/
|
|
16
|
-
|
|
17
|
-
import {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
//
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
1
|
+
/**
|
|
2
|
+
* ___ ___ __
|
|
3
|
+
* \ \/ / / _
|
|
4
|
+
* \ / /_| |_
|
|
5
|
+
* / \____ _|
|
|
6
|
+
* /__/\__\ |_|
|
|
7
|
+
*
|
|
8
|
+
* @file boxes.ts
|
|
9
|
+
* @author Etienne Cochard
|
|
10
|
+
*
|
|
11
|
+
* @copyright (c) 2024 R-libre ingenierie
|
|
12
|
+
*
|
|
13
|
+
* Use of this source code is governed by an MIT-style license
|
|
14
|
+
* that can be found in the LICENSE file or at https://opensource.org/licenses/MIT.
|
|
15
|
+
**/
|
|
16
|
+
|
|
17
|
+
import { class_ns } from '@core/core_tools.js';
|
|
18
|
+
import { Component, ComponentEvents, ComponentProps } from "../../core/component"
|
|
19
|
+
|
|
20
|
+
import "./boxes.module.scss";
|
|
21
|
+
|
|
22
|
+
export interface BoxProps extends ComponentProps {
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
*
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
@class_ns( "x4" )
|
|
30
|
+
export class Box<P extends BoxProps=BoxProps,E extends ComponentEvents=ComponentEvents> extends Component<P,E> {
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
*
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
@class_ns( "x4" )
|
|
39
|
+
export class HBox<P extends BoxProps=BoxProps,E extends ComponentEvents=ComponentEvents> extends Box<P,E> {
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
*
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
@class_ns( "x4" )
|
|
47
|
+
export class VBox<P extends BoxProps=BoxProps,E extends ComponentEvents=ComponentEvents> extends Box<P,E> {
|
|
48
|
+
constructor( p: P ) {
|
|
49
|
+
super( p );
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* stack of widgets where only one widget is visible at a time
|
|
56
|
+
*/
|
|
57
|
+
|
|
58
|
+
interface StackItem {
|
|
59
|
+
name: string;
|
|
60
|
+
content: Component;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
interface StackedLayoutProps extends Omit<ComponentProps,"content"> {
|
|
64
|
+
default: string;
|
|
65
|
+
items: StackItem[];
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
interface _StackItem extends StackItem {
|
|
69
|
+
page: Component;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
@class_ns( "x4" )
|
|
73
|
+
export class StackBox extends Box<StackedLayoutProps> {
|
|
74
|
+
private _items: _StackItem[];
|
|
75
|
+
|
|
76
|
+
constructor( props: StackedLayoutProps ) {
|
|
77
|
+
super( props );
|
|
78
|
+
|
|
79
|
+
this._items = props.items?.map( itm => {
|
|
80
|
+
return { ...itm, page: null };
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
if( props.default ) {
|
|
84
|
+
this.select( props.default );
|
|
85
|
+
}
|
|
86
|
+
else if( this._items.length ) {
|
|
87
|
+
this.select( this._items[0].name );
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
select( name: string ) {
|
|
92
|
+
let sel = this.query( `.selected` );
|
|
93
|
+
if( sel ) {
|
|
94
|
+
sel.setClass( "selected", false );
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const pg = this._items.find( x => x.name==name );
|
|
98
|
+
if( pg ) {
|
|
99
|
+
if( !pg.page ) {
|
|
100
|
+
pg.page = this._createPage( pg );
|
|
101
|
+
this.appendContent( pg.page );
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
sel = pg.page;
|
|
105
|
+
if( sel ) {
|
|
106
|
+
sel.setClass( "selected", true );
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
*
|
|
113
|
+
*/
|
|
114
|
+
|
|
115
|
+
private _createPage( page: _StackItem ) {
|
|
116
|
+
|
|
117
|
+
let content: Component;
|
|
118
|
+
//if( page.content instanceof ComponentBuilder ) {
|
|
119
|
+
// content = page.content.create( );
|
|
120
|
+
//}
|
|
121
|
+
//else {
|
|
122
|
+
content = page.content;
|
|
123
|
+
//}
|
|
124
|
+
|
|
125
|
+
content?.setData( "stackname", page.name );
|
|
126
|
+
return content;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
|
|
2
|
+
:root {
|
|
3
|
+
--link-color: var( --accent-background );
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.x4breadcrumbs {
|
|
7
|
+
border-bottom: 1px solid var( --border );
|
|
8
|
+
padding: 8px 0;
|
|
9
|
+
font-size: 120%;
|
|
10
|
+
margin-bottom: 2em;
|
|
11
|
+
|
|
12
|
+
&> .x4button {
|
|
13
|
+
border: none;
|
|
14
|
+
background-color: transparent;
|
|
15
|
+
color: var( --link-color );
|
|
16
|
+
border-radius: 16px;
|
|
17
|
+
padding: 6px 8px;
|
|
18
|
+
min-width: 60px;
|
|
19
|
+
|
|
20
|
+
&:hover {
|
|
21
|
+
border-bottom-color: var( --link-color );
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
&:last-child {
|
|
25
|
+
font-weight: bold;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ___ ___ __
|
|
3
|
+
* \ \/ / / _
|
|
4
|
+
* \ / /_| |_
|
|
5
|
+
* / \____ _|
|
|
6
|
+
* /__/\__\ |_|
|
|
7
|
+
*
|
|
8
|
+
* @file breadcrumb.ts
|
|
9
|
+
* @author Etienne Cochard
|
|
10
|
+
*
|
|
11
|
+
* @copyright (c) 2024 R-libre ingenierie
|
|
12
|
+
*
|
|
13
|
+
* Use of this source code is governed by an MIT-style license
|
|
14
|
+
* that can be found in the LICENSE file or at https://opensource.org/licenses/MIT.
|
|
15
|
+
**/
|
|
16
|
+
|
|
17
|
+
import { class_ns } from '@core/core_tools.js';
|
|
18
|
+
import { BoxProps, Button, HBox, Icon, Link } from '../components';
|
|
19
|
+
import { Component, ComponentEvents, EvClick } from '@core/component.js';
|
|
20
|
+
import { EventCallback } from '@core/core_events.js';
|
|
21
|
+
|
|
22
|
+
import "./breadcrumb.scss"
|
|
23
|
+
|
|
24
|
+
import icon_sep from "./chevron-right.svg"
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Breadcrumb events
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
interface BreadcrumbEvents extends ComponentEvents {
|
|
31
|
+
click: EvClick; // context = item name
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
*
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
interface BreadcrumbElement {
|
|
39
|
+
icon?: string;
|
|
40
|
+
name: string;
|
|
41
|
+
label: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
*
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
interface BreadcrumbsProps extends BoxProps{
|
|
49
|
+
items: BreadcrumbElement[];
|
|
50
|
+
click?: EventCallback<EvClick>;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
*
|
|
55
|
+
*/
|
|
56
|
+
|
|
57
|
+
@class_ns( "x4" )
|
|
58
|
+
export class Breadcrumbs extends HBox<BreadcrumbsProps,BreadcrumbEvents> {
|
|
59
|
+
|
|
60
|
+
constructor( props: BreadcrumbsProps ) {
|
|
61
|
+
super( props );
|
|
62
|
+
|
|
63
|
+
this.mapPropEvents( props, "click" );
|
|
64
|
+
|
|
65
|
+
const items: Component[] = [];
|
|
66
|
+
|
|
67
|
+
props.items?.map( (x: BreadcrumbElement, idx ) => {
|
|
68
|
+
items.push( new Button( {
|
|
69
|
+
label: x.label,
|
|
70
|
+
icon: x.icon,
|
|
71
|
+
click: ( ) => {
|
|
72
|
+
this.fire( "click", { context: x.name } );
|
|
73
|
+
}
|
|
74
|
+
}) );
|
|
75
|
+
|
|
76
|
+
if( idx!=props.items.length-1 ) {
|
|
77
|
+
items.push( new Icon( { iconId: icon_sep } ) );
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
this.setContent( items );
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512"><!--!Font Awesome Pro 6.6.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2024 Fonticons, Inc.--><path d="M299.3 244.7c6.2 6.2 6.2 16.4 0 22.6l-192 192c-6.2 6.2-16.4 6.2-22.6 0s-6.2-16.4 0-22.6L265.4 256 84.7 75.3c-6.2-6.2-6.2-16.4 0-22.6s16.4-6.2 22.6 0l192 192z"/></svg>
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ___ ___ __
|
|
3
|
-
* \ \/ / / _
|
|
4
|
-
* \ / /_| |_
|
|
5
|
-
* / \____ _|
|
|
6
|
-
* /__/\__\ |_|
|
|
7
|
-
*
|
|
8
|
-
* @file btngroup.model.scss
|
|
9
|
-
* @author Etienne Cochard
|
|
10
|
-
*
|
|
11
|
-
* @copyright (c) 2024 R-libre ingenierie
|
|
12
|
-
*
|
|
13
|
-
* Use of this source code is governed by an MIT-style license
|
|
14
|
-
* that can be found in the LICENSE file or at https://opensource.org/licenses/MIT.
|
|
15
|
-
**/
|
|
16
|
-
|
|
17
|
-
.x4btngroup {
|
|
18
|
-
align-content: start;
|
|
19
|
-
margin: 5px;
|
|
20
|
-
gap: 4px;
|
|
21
|
-
|
|
22
|
-
&.align-right {
|
|
23
|
-
justify-content: end;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
&.align-center {
|
|
27
|
-
justify-content: center;
|
|
28
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* ___ ___ __
|
|
3
|
+
* \ \/ / / _
|
|
4
|
+
* \ / /_| |_
|
|
5
|
+
* / \____ _|
|
|
6
|
+
* /__/\__\ |_|
|
|
7
|
+
*
|
|
8
|
+
* @file btngroup.model.scss
|
|
9
|
+
* @author Etienne Cochard
|
|
10
|
+
*
|
|
11
|
+
* @copyright (c) 2024 R-libre ingenierie
|
|
12
|
+
*
|
|
13
|
+
* Use of this source code is governed by an MIT-style license
|
|
14
|
+
* that can be found in the LICENSE file or at https://opensource.org/licenses/MIT.
|
|
15
|
+
**/
|
|
16
|
+
|
|
17
|
+
.x4btngroup {
|
|
18
|
+
align-content: start;
|
|
19
|
+
margin: 5px;
|
|
20
|
+
gap: 4px;
|
|
21
|
+
|
|
22
|
+
&.align-right {
|
|
23
|
+
justify-content: end;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
&.align-center {
|
|
27
|
+
justify-content: center;
|
|
28
|
+
}
|
|
29
29
|
}
|
|
@@ -1,102 +1,120 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ___ ___ __
|
|
3
|
-
* \ \/ / / _
|
|
4
|
-
* \ / /_| |_
|
|
5
|
-
* / \____ _|
|
|
6
|
-
* /__/\__\ |_|
|
|
7
|
-
*
|
|
8
|
-
* @file btngroup.ts
|
|
9
|
-
* @author Etienne Cochard
|
|
10
|
-
*
|
|
11
|
-
* @copyright (c) 2024 R-libre ingenierie
|
|
12
|
-
*
|
|
13
|
-
* Use of this source code is governed by an MIT-style license
|
|
14
|
-
* that can be found in the LICENSE file or at https://opensource.org/licenses/MIT.
|
|
15
|
-
**/
|
|
16
|
-
|
|
17
|
-
import { Component, ComponentEvent, ComponentEvents, ComponentProps, Flex } from '../../core/component';
|
|
18
|
-
import { EventCallback } from '../../core/core_events';
|
|
19
|
-
import { isString } from '../../core/core_tools';
|
|
20
|
-
import { _tr } from '../../core/core_i18n'
|
|
21
|
-
|
|
22
|
-
import { Button } from '../button/button';
|
|
23
|
-
import { Box } from '../boxes/boxes.js';
|
|
24
|
-
import { Label } from '../label/label.js';
|
|
25
|
-
import { EvBtnClick } from '../dialog/dialog.js';
|
|
26
|
-
|
|
27
|
-
import "./btngroup.module.scss"
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
b = new
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
1
|
+
/**
|
|
2
|
+
* ___ ___ __
|
|
3
|
+
* \ \/ / / _
|
|
4
|
+
* \ / /_| |_
|
|
5
|
+
* / \____ _|
|
|
6
|
+
* /__/\__\ |_|
|
|
7
|
+
*
|
|
8
|
+
* @file btngroup.ts
|
|
9
|
+
* @author Etienne Cochard
|
|
10
|
+
*
|
|
11
|
+
* @copyright (c) 2024 R-libre ingenierie
|
|
12
|
+
*
|
|
13
|
+
* Use of this source code is governed by an MIT-style license
|
|
14
|
+
* that can be found in the LICENSE file or at https://opensource.org/licenses/MIT.
|
|
15
|
+
**/
|
|
16
|
+
|
|
17
|
+
import { Component, ComponentEvent, ComponentEvents, ComponentProps, Flex } from '../../core/component';
|
|
18
|
+
import { EventCallback } from '../../core/core_events';
|
|
19
|
+
import { class_ns, isString } from '../../core/core_tools';
|
|
20
|
+
import { _tr } from '../../core/core_i18n'
|
|
21
|
+
|
|
22
|
+
import { Button } from '../button/button';
|
|
23
|
+
import { Box } from '../boxes/boxes.js';
|
|
24
|
+
import { Label } from '../label/label.js';
|
|
25
|
+
import { EvBtnClick } from '../dialog/dialog.js';
|
|
26
|
+
|
|
27
|
+
import "./btngroup.module.scss"
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* accept "ok" or "ok.<classname>"
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
type predefined = `ok${ "" | `.${string}`}`
|
|
34
|
+
| `cancel${ "" | `.${string}`}`
|
|
35
|
+
| `yes${ "" | `.${string}`}`
|
|
36
|
+
| `no${ "" | `.${string}`}`
|
|
37
|
+
| `retry${ "" | `.${string}`}`
|
|
38
|
+
| `abort${ "" | `.${string}`}`
|
|
39
|
+
| "-"; // - = flex
|
|
40
|
+
|
|
41
|
+
export type BtnGroupItem = predefined | Button | Label;
|
|
42
|
+
|
|
43
|
+
interface BtnGroupEvents extends ComponentEvents {
|
|
44
|
+
btnclick: EvBtnClick;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
interface BtnGroupProps extends Omit<ComponentProps,"content"> {
|
|
48
|
+
align?: "left" | "center" | "right"; // left default
|
|
49
|
+
vertical?: boolean;
|
|
50
|
+
items: BtnGroupItem[];
|
|
51
|
+
reverse?: boolean,
|
|
52
|
+
btnclick?: EventCallback<EvBtnClick>;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
*
|
|
57
|
+
*/
|
|
58
|
+
|
|
59
|
+
@class_ns( "x4" )
|
|
60
|
+
export class BtnGroup extends Box<BtnGroupProps,BtnGroupEvents> {
|
|
61
|
+
|
|
62
|
+
constructor( props: BtnGroupProps ) {
|
|
63
|
+
super( props );
|
|
64
|
+
|
|
65
|
+
if( props.align ) {
|
|
66
|
+
this.addClass( "align-"+props.align );
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
this.addClass( props.vertical ? "x4vbox" : "x4hbox" );
|
|
70
|
+
|
|
71
|
+
if( props.items ) {
|
|
72
|
+
this.setButtons( props.items );
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
this.mapPropEvents( props, "btnclick" );
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
*
|
|
80
|
+
* @param btns
|
|
81
|
+
*/
|
|
82
|
+
|
|
83
|
+
setButtons( btns: BtnGroupItem[] ) {
|
|
84
|
+
|
|
85
|
+
this.clearContent( );
|
|
86
|
+
|
|
87
|
+
const childs: Component[] = [];
|
|
88
|
+
|
|
89
|
+
btns?.forEach( (b: string | Component) => {
|
|
90
|
+
|
|
91
|
+
if( b==="-" ) {
|
|
92
|
+
b = new Flex( );
|
|
93
|
+
}
|
|
94
|
+
else if( isString(b) ) {
|
|
95
|
+
let title: string;
|
|
96
|
+
|
|
97
|
+
const nm = (b as predefined);
|
|
98
|
+
|
|
99
|
+
let [txt,cls] = nm.split( "." );
|
|
100
|
+
|
|
101
|
+
switch( txt as predefined ) {
|
|
102
|
+
case "ok": title = _tr.global.ok; break;
|
|
103
|
+
case "cancel": title = _tr.global.cancel; break;
|
|
104
|
+
case "abort": title = _tr.global.abort; break;
|
|
105
|
+
case "no": title = _tr.global.no; break;
|
|
106
|
+
case "yes": title = _tr.global.yes; break;
|
|
107
|
+
case "retry": title = _tr.global.retry; break;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
b = new Button( { cls, label: title, click: ( ) => {
|
|
111
|
+
this.fire( "btnclick", {button:nm as string} )
|
|
112
|
+
} } );
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
childs.push( b );
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
super.setContent( childs );
|
|
119
|
+
}
|
|
102
120
|
}
|