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.
Files changed (109) hide show
  1. package/README.md +15 -15
  2. package/lib/README.txt +15 -15
  3. package/lib/cjs/x4.css +1 -1
  4. package/lib/cjs/x4.js +1 -1
  5. package/lib/esm/x4.css +1 -1
  6. package/lib/esm/x4.mjs +1 -1
  7. package/lib/src/components/base.scss +25 -26
  8. package/lib/src/components/boxes/boxes.module.scss +37 -37
  9. package/lib/src/components/boxes/boxes.ts +129 -125
  10. package/lib/src/components/breadcrumb/breadcrumb.scss +28 -0
  11. package/lib/src/components/breadcrumb/breadcrumb.ts +84 -0
  12. package/lib/src/components/breadcrumb/chevron-right.svg +1 -0
  13. package/lib/src/components/btngroup/btngroup.module.scss +28 -28
  14. package/lib/src/components/btngroup/btngroup.ts +119 -101
  15. package/lib/src/components/button/button.module.scss +154 -153
  16. package/lib/src/components/button/button.ts +117 -117
  17. package/lib/src/components/calendar/calendar.module.scss +162 -162
  18. package/lib/src/components/calendar/calendar.ts +326 -325
  19. package/lib/src/components/checkbox/check.svg +3 -3
  20. package/lib/src/components/checkbox/checkbox.module.scss +141 -141
  21. package/lib/src/components/checkbox/checkbox.ts +125 -124
  22. package/lib/src/components/colorinput/colorinput.module.scss +64 -64
  23. package/lib/src/components/colorinput/colorinput.ts +90 -87
  24. package/lib/src/components/colorpicker/colorpicker.module.scss +132 -132
  25. package/lib/src/components/colorpicker/colorpicker.ts +481 -476
  26. package/lib/src/components/combobox/combobox.module.scss +123 -120
  27. package/lib/src/components/combobox/combobox.ts +192 -190
  28. package/lib/src/components/combobox/updown.svg +3 -3
  29. package/lib/src/components/components.ts +34 -0
  30. package/lib/src/components/dialog/dialog.module.scss +71 -71
  31. package/lib/src/components/dialog/dialog.ts +94 -92
  32. package/lib/src/components/form/form.module.scss +34 -34
  33. package/lib/src/components/form/form.ts +41 -36
  34. package/lib/src/components/grid/datastore.ts +1298 -0
  35. package/lib/src/components/grid/gridview.ts +1108 -0
  36. package/lib/src/components/grid/memdb.ts +325 -0
  37. package/lib/src/components/header/header.module.scss +39 -39
  38. package/lib/src/components/header/header.ts +129 -123
  39. package/lib/src/components/icon/icon.module.scss +29 -29
  40. package/lib/src/components/icon/icon.ts +136 -134
  41. package/lib/src/components/image/image.module.scss +20 -20
  42. package/lib/src/components/image/image.ts +68 -66
  43. package/lib/src/components/input/input.module.scss +69 -69
  44. package/lib/src/components/input/input.ts +275 -274
  45. package/lib/src/components/label/label.module.scss +58 -52
  46. package/lib/src/components/label/label.ts +64 -55
  47. package/lib/src/components/link/link.ts +78 -0
  48. package/lib/src/components/listbox/listbox.module.scss +103 -103
  49. package/lib/src/components/listbox/listbox.ts +431 -427
  50. package/lib/src/components/menu/menu.module.scss +107 -107
  51. package/lib/src/components/menu/menu.ts +171 -168
  52. package/lib/src/components/messages/messages.module.scss +48 -47
  53. package/lib/src/components/messages/messages.ts +68 -63
  54. package/lib/src/components/normalize.scss +386 -386
  55. package/lib/src/components/notification/notification.module.scss +81 -81
  56. package/lib/src/components/notification/notification.ts +109 -108
  57. package/lib/src/components/panel/panel.module.scss +47 -47
  58. package/lib/src/components/panel/panel.ts +57 -56
  59. package/lib/src/components/popup/popup.module.scss +43 -43
  60. package/lib/src/components/popup/popup.ts +396 -395
  61. package/lib/src/components/progress/progress.module.scss +56 -56
  62. package/lib/src/components/progress/progress.ts +43 -42
  63. package/lib/src/components/rating/rating.module.scss +22 -22
  64. package/lib/src/components/rating/rating.ts +131 -125
  65. package/lib/src/components/shared.scss +90 -76
  66. package/lib/src/components/sizers/sizer.module.scss +89 -89
  67. package/lib/src/components/sizers/sizer.ts +123 -119
  68. package/lib/src/components/slider/slider.module.scss +70 -70
  69. package/lib/src/components/slider/slider.ts +147 -142
  70. package/lib/src/components/switch/switch.module.scss +126 -126
  71. package/lib/src/components/switch/switch.ts +61 -55
  72. package/lib/src/components/tabs/tabs.module.scss +46 -46
  73. package/lib/src/components/tabs/tabs.ts +168 -157
  74. package/lib/src/components/textarea/textarea.module.scss +59 -59
  75. package/lib/src/components/textarea/textarea.ts +60 -54
  76. package/lib/src/components/textedit/textedit.module.scss +113 -113
  77. package/lib/src/components/textedit/textedit.ts +83 -82
  78. package/lib/src/components/themes.scss +81 -77
  79. package/lib/src/components/tooltips/tooltips.scss +50 -50
  80. package/lib/src/components/tooltips/tooltips.ts +103 -102
  81. package/lib/src/components/treeview/treeview.module.scss +115 -115
  82. package/lib/src/components/treeview/treeview.ts +410 -403
  83. package/lib/src/components/viewport/viewport.module.scss +24 -24
  84. package/lib/src/components/viewport/viewport.ts +41 -38
  85. package/lib/src/core/component.ts +1002 -979
  86. package/lib/src/core/core_application.ts +44 -0
  87. package/lib/src/core/core_colors.ts +249 -249
  88. package/lib/src/core/core_dom.ts +471 -471
  89. package/lib/src/core/core_dragdrop.ts +200 -200
  90. package/lib/src/core/core_element.ts +97 -97
  91. package/lib/src/core/core_events.ts +149 -149
  92. package/lib/src/core/core_i18n.ts +377 -377
  93. package/lib/src/core/core_router.ts +221 -221
  94. package/lib/src/core/core_styles.ts +214 -214
  95. package/lib/src/core/core_svg.ts +550 -550
  96. package/lib/src/core/core_tools.ts +688 -673
  97. package/lib/src/demo/assets/radio.svg +3 -3
  98. package/lib/src/demo/index.html +11 -11
  99. package/lib/src/demo/main.scss +21 -21
  100. package/lib/src/demo/main.tsx +323 -323
  101. package/lib/src/types/scss.d.ts +4 -4
  102. package/lib/src/types/x4react.d.ts +8 -8
  103. package/lib/src/x4.scss +18 -18
  104. package/lib/src/x4.ts +31 -60
  105. package/lib/styles/x4.css +1 -1
  106. package/lib/types/x4js.d.ts +100 -49
  107. package/package.json +2 -3
  108. package/src/x4.ts +31 -60
  109. 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 { Component, ComponentEvents, ComponentProps } from "../../core/component"
18
-
19
- import "./boxes.module.scss";
20
-
21
- export interface BoxProps extends ComponentProps {
22
- }
23
-
24
- /**
25
- *
26
- */
27
-
28
- export class Box<P extends BoxProps=BoxProps,E extends ComponentEvents=ComponentEvents> extends Component<P,E> {
29
- }
30
-
31
-
32
- /**
33
- *
34
- */
35
-
36
- export class HBox<P extends BoxProps=BoxProps,E extends ComponentEvents=ComponentEvents> extends Box<P,E> {
37
- }
38
-
39
- /**
40
- *
41
- */
42
-
43
- export class VBox<P extends BoxProps=BoxProps,E extends ComponentEvents=ComponentEvents> extends Box<P,E> {
44
- constructor( p: P ) {
45
- super( p );
46
- }
47
- }
48
-
49
-
50
- /**
51
- * stack of widgets where only one widget is visible at a time
52
- */
53
-
54
- interface StackItem {
55
- name: string;
56
- content: Component;
57
- }
58
-
59
- interface StackedLayoutProps extends Omit<ComponentProps,"content"> {
60
- default: string;
61
- items: StackItem[];
62
- }
63
-
64
- interface _StackItem extends StackItem {
65
- page: Component;
66
- }
67
-
68
- export class StackBox extends Box<StackedLayoutProps> {
69
-
70
- private _items: _StackItem[];
71
-
72
- constructor( props: StackedLayoutProps ) {
73
- super( props );
74
-
75
- this._items = props.items?.map( itm => {
76
- return { ...itm, page: null };
77
- });
78
-
79
- if( props.default ) {
80
- this.select( props.default );
81
- }
82
- else if( this._items.length ) {
83
- this.select( this._items[0].name );
84
- }
85
- }
86
-
87
- select( name: string ) {
88
- let sel = this.query( `.selected` );
89
- if( sel ) {
90
- sel.setClass( "selected", false );
91
- }
92
-
93
- const pg = this._items.find( x => x.name==name );
94
- if( pg ) {
95
- if( !pg.page ) {
96
- pg.page = this._createPage( pg );
97
- this.appendContent( pg.page );
98
- }
99
-
100
- sel = pg.page;
101
- if( sel ) {
102
- sel.setClass( "selected", true );
103
- }
104
- }
105
- }
106
-
107
- /**
108
- *
109
- */
110
-
111
- private _createPage( page: _StackItem ) {
112
-
113
- let content: Component;
114
- //if( page.content instanceof ComponentBuilder ) {
115
- // content = page.content.create( );
116
- //}
117
- //else {
118
- content = page.content;
119
- //}
120
-
121
- content?.setData( "stackname", page.name );
122
- return content;
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
- type predefined = "ok" | "cancel" | "yes" | "no" | "retry" | "abort" | "-"; // - = flex
31
- export type BtnGroupItem = predefined | Button | Label;
32
-
33
- interface BtnGroupEvents extends ComponentEvents {
34
- btnclick: EvBtnClick;
35
- }
36
-
37
- interface BtnGroupProps extends Omit<ComponentProps,"content"> {
38
- align?: "left" | "center" | "right"; // left default
39
- vertical?: boolean;
40
- items: BtnGroupItem[];
41
- reverse?: boolean,
42
- btnclick?: EventCallback<EvBtnClick>;
43
- }
44
-
45
- export class BtnGroup extends Box<BtnGroupProps,BtnGroupEvents> {
46
-
47
- constructor( props: BtnGroupProps ) {
48
- super( props );
49
-
50
- if( props.align ) {
51
- this.addClass( "align-"+props.align );
52
- }
53
-
54
- this.addClass( props.vertical ? "x4vbox" : "x4hbox" );
55
-
56
- if( props.items ) {
57
- this.setButtons( props.items );
58
- }
59
-
60
- this.mapPropEvents( props, "btnclick" );
61
- }
62
-
63
- /**
64
- *
65
- * @param btns
66
- */
67
-
68
- setButtons( btns: BtnGroupItem[] ) {
69
-
70
- this.clearContent( );
71
-
72
- const childs: Component[] = [];
73
-
74
- btns?.forEach( (b: string | Component) => {
75
-
76
- if( b==="-" ) {
77
- b = new Flex( );
78
- }
79
- else if( isString(b) ) {
80
- let title: string;
81
- const nm = b as predefined;
82
-
83
- switch( b as predefined ) {
84
- case "ok": title = _tr.global.ok; break;
85
- case "cancel": title = _tr.global.cancel; break;
86
- case "abort": title = _tr.global.abort; break;
87
- case "no": title = _tr.global.no; break;
88
- case "yes": title = _tr.global.yes; break;
89
- case "retry": title = _tr.global.retry; break;
90
- }
91
-
92
- b = new Button( { label: title, click: ( ) => {
93
- this.fire( "btnclick", {button:nm as string} )
94
- } } );
95
- }
96
-
97
- childs.push( b );
98
- });
99
-
100
- super.setContent( childs );
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
  }