x4js 2.2.8 → 2.2.9

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "x4js",
3
- "version": "2.2.8",
3
+ "version": "2.2.9",
4
4
  "type": "module",
5
5
  "main": "src/x4.ts",
6
6
  "module": "src/x4.ts",
@@ -24,6 +24,19 @@
24
24
  @extend %flex;
25
25
  }
26
26
 
27
+ .x4fit-h {
28
+ width: stretch;
29
+ }
30
+
31
+ .x4fit-v {
32
+ height: stretch;
33
+ }
34
+
35
+ .x4fit {
36
+ height: stretch;
37
+ width: stretch;
38
+ }
39
+
27
40
  .fit {
28
41
  @extend %fit;
29
42
  }
@@ -86,4 +99,9 @@
86
99
  animation-iteration-count: infinite;
87
100
  animation-timing-function: linear;
88
101
  animation-direction: reverse;
102
+ }
103
+
104
+ option:checked {
105
+ background-color: var( --accent-background );
106
+ color: var( --accent-color );
89
107
  }
@@ -140,6 +140,14 @@ export class BtnGroup extends Box<BtnGroupProps,BtnGroupEvents> {
140
140
 
141
141
  b.addClass( def.join(" ") );
142
142
  }
143
+ else if( b instanceof Button ) {
144
+ const btn = b as Button;
145
+ if( !btn.props.click && btn.props.id ) {
146
+ btn.on( "click", ( ) => {
147
+ this.fire( "btnclick", { button: btn.props.id} );
148
+ } );
149
+ }
150
+ }
143
151
 
144
152
  childs.push( b );
145
153
  });
@@ -20,7 +20,7 @@ import { BtnGroup, BtnGroupItem } from "../btngroup/btngroup"
20
20
  import { HBox } from '../boxes/boxes';
21
21
  import { Label } from '../label/label';
22
22
  import { CoreEvent, EventCallback } from '../../core/core_events';
23
- import { class_ns, getFocusableElements, IComponentInterface, isString, ITabHandler } from '../../core/core_tools';
23
+ import { asap, class_ns, getFocusableElements, IComponentInterface, isString, ITabHandler } from '../../core/core_tools';
24
24
  import { ComponentEvent } from '../../core/component';
25
25
  import { Button } from '../button/button';
26
26
 
@@ -228,6 +228,26 @@ export class Dialog<P extends DialogProps = DialogProps, E extends DialogEvents
228
228
  getBtnBar( ) {
229
229
  return this.query<BtnGroup>("#btnbar");
230
230
  }
231
+
232
+ /**
233
+ * ! cannot stop close action
234
+ */
235
+
236
+ async showAsync( ) : Promise<string> {
237
+
238
+ return new Promise( (resolve ) => {
239
+
240
+ this.on( "btnclick", ( ev ) => {
241
+ asap( ( ) => {
242
+ this.close( );
243
+ resolve( ev.button );
244
+ });
245
+ });
246
+
247
+ this.show();
248
+ } );
249
+ }
250
+
231
251
  }
232
252
 
233
253
 
@@ -116,7 +116,7 @@ export class Header extends HBox<HeaderProps> {
116
116
 
117
117
  const flex = c.getInternalData( "flex" );
118
118
  if( flex ) {
119
- width = Math.min( unit*flex, rest );
119
+ width = Math.floor(Math.min( unit*flex, rest ));
120
120
  rest -= width;
121
121
  }
122
122
  else {
@@ -62,17 +62,25 @@
62
62
  position: relative;
63
63
 
64
64
  &> .x4viewport {
65
+ overflow: hidden;
65
66
  display: table;
66
67
  }
67
68
 
68
69
  .x4item {
69
70
  @extend %flex;
70
71
 
72
+
71
73
  padding: 4px;
72
74
  background-color: transparent;
73
75
  color: var( --text-primary );
74
76
 
75
- &> .x4label {
77
+ // multicolumns
78
+ &:has( >.x4hbox ) {
79
+ padding: 4px 0;
80
+ }
81
+
82
+ .x4label,
83
+ .x4simpletext {
76
84
  color: inherit;
77
85
  padding: 2px 6px;
78
86
 
@@ -108,6 +116,7 @@
108
116
  //background-color: var( --color-80 );
109
117
  //color: var(--color-0);
110
118
  //}
119
+
111
120
  }
112
121
  }
113
122
 
@@ -130,6 +139,31 @@
130
139
  .x4icon {
131
140
  height: 1.5em;
132
141
  width: 1.5em;
142
+
143
+ .fa-primary, .fa-secondary {
144
+ fill: var( --accent-background );
145
+ }
146
+ }
147
+
148
+ &.icon-danger {
149
+ .x4icon {
150
+ .fa-secondary {
151
+ fill: var( --disabled-color-dark);
152
+ opacity: 0.7;
153
+ }
154
+
155
+ .fa-primary {
156
+ fill: var( --alert-background );
157
+ }
158
+ }
159
+ }
160
+
161
+ &.icon-success {
162
+ .x4icon {
163
+ .fa-primary {
164
+ fill: var( --success-background );
165
+ }
166
+ }
133
167
  }
134
168
 
135
169
  &:hover{
@@ -17,6 +17,8 @@ import { Progress } from '../components.js';
17
17
  import "./messages.module.scss";
18
18
 
19
19
  import error_icon from "./circle-exclamation.svg";
20
+ import question_icon from "./circle-question.svg";
21
+
20
22
  import pen_icon from "./pen-field.svg";
21
23
  import spinner from "./spinner.svg"
22
24
 
@@ -40,7 +42,16 @@ export class MessageBox extends Dialog<DialogProps>
40
42
  *
41
43
  */
42
44
 
43
- private static _create( msg: string | UnsafeHtml, buttons?: BtnGroupItem[], title?: string ) {
45
+ private static _create( msg: string | UnsafeHtml, buttons: BtnGroupItem[], title: string, icon_type: "error" | "question" ) {
46
+
47
+ let icon = error_icon;
48
+ switch( icon_type ) {
49
+ case "question": {
50
+ icon = question_icon;
51
+ break;
52
+ }
53
+ }
54
+
44
55
  const box = new MessageBox({
45
56
  modal: true,
46
57
  title: title ?? _tr.global.error,
@@ -65,9 +76,9 @@ export class MessageBox extends Dialog<DialogProps>
65
76
  * display a messagebox
66
77
  */
67
78
 
68
- static show( msg: string | UnsafeHtml, buttons?: BtnGroupItem[], title?: string ): MessageBox {
79
+ static show( msg: string | UnsafeHtml, buttons?: BtnGroupItem[], title?: string, icon_type?: "error" | "question" ): MessageBox {
69
80
 
70
- const box = this._create( msg, buttons, title );
81
+ const box = this._create( msg, buttons, title, icon_type );
71
82
  box.on( "btnclick", ( ev ) => {
72
83
  asap( ( ) => {
73
84
  box.close()
@@ -82,10 +93,10 @@ export class MessageBox extends Dialog<DialogProps>
82
93
  * idem with promise
83
94
  */
84
95
 
85
- static async showAsync( msg: string | UnsafeHtml, buttons?: BtnGroupItem[], title?: string ) : Promise<string> {
96
+ static async showAsync( msg: string | UnsafeHtml, buttons?: BtnGroupItem[], title?: string, icon_type?: "error" | "question" ) : Promise<string> {
86
97
 
87
98
  return new Promise( (resolve, reject ) => {
88
- const box = this._create( msg, buttons, title );
99
+ const box = this._create( msg, buttons, title, icon_type );
89
100
  box.on( "btnclick", ( ev ) => {
90
101
  asap( ( ) => {
91
102
  resolve( ev.button );
@@ -99,6 +110,7 @@ export class MessageBox extends Dialog<DialogProps>
99
110
  }
100
111
  }
101
112
 
113
+ // :: INPUT ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
102
114
 
103
115
  interface InputOptions {
104
116
  password?: boolean;
@@ -168,6 +180,8 @@ export class InputBox extends Dialog<DialogProps>
168
180
  }
169
181
 
170
182
 
183
+ // :: PROMPT ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
184
+
171
185
 
172
186
  @class_ns( "x4" )
173
187
  export class PromptBox extends Dialog<DialogProps>
@@ -237,6 +251,9 @@ export class PromptBox extends Dialog<DialogProps>
237
251
  }
238
252
  }
239
253
 
254
+
255
+ // :: PROGRESS ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
256
+
240
257
  @class_ns( "x4" )
241
258
  export class ProgressionBox extends Dialog {
242
259
 
@@ -1,3 +1,4 @@
1
1
  # using monaco in x4
2
2
 
3
- you must copy ./bin/* in your destination folder
3
+ you must copy ./bin/* in your destination folder ex. monaco folder
4
+ see demo/components/monaco for a full example.
@@ -10,7 +10,7 @@
10
10
 
11
11
  .x4propertygrid {
12
12
  background: var( --propertygrid-background );
13
- border: 1px solid var(--color-primary-a50);
13
+ border: 1px solid var(--border);
14
14
  overflow-y: auto;
15
15
  flex-basis: 0;
16
16
 
@@ -40,7 +40,7 @@
40
40
 
41
41
  &:not( :last-child ) {
42
42
  border-bottom: 1px solid var(--color-primary-a50);
43
- box-shadow: 4px 4px 8px rgba(0, 0, 0, 0.2);
43
+ //box-shadow: 4px 4px 8px rgba(0, 0, 0, 0.2);
44
44
  }
45
45
 
46
46
  display: flex;
@@ -1,9 +1,32 @@
1
1
 
2
2
 
3
- .x4select {
4
- padding: 4px;
3
+ .x4select,
4
+ ::picker(select) {
5
+ appearance: base-select;
6
+
7
+ padding: 5px;
5
8
  outline: none;
6
9
 
10
+ border-radius: 0;
7
11
  border: 1px solid var( --border );
8
12
  background-color: white;
9
- }
13
+ }
14
+
15
+ //-- global saddly
16
+ option {
17
+ padding: 5px;
18
+ }
19
+
20
+ option:checked {
21
+ background-color: var( --accent-background );
22
+ color: var( --accent-color );
23
+ }
24
+
25
+ option:hover {
26
+ background-color: var( --accent-background-focus );
27
+ color: var( --accent-color );
28
+ }
29
+
30
+ option::checkmark {
31
+ display: none;
32
+ }
@@ -153,7 +153,7 @@ export class Tabs extends Box<TabsProps> {
153
153
  constructor( props: TabsProps ) {
154
154
  super( props );
155
155
 
156
- this.setClass( "vertical", props.vertical );
156
+ this.setClass( "vertical", props.vertical ?? false );
157
157
 
158
158
  const pages = props.items?.map( x => {
159
159
  return {
@@ -380,7 +380,9 @@ export class Treeview extends Component<TreeviewProps,TreeviewEvents> {
380
380
  }
381
381
 
382
382
  if( newSel ) {
383
- const nsel = this.query( `[data-id="${newSel}"]`)
383
+ //const nsel = this.query( `[data-id="${newSel}"]`)
384
+ const all = this._view.enumChildComponents( true );
385
+ const nsel = all.find( x => x.getInternalData("id")===newSel )
384
386
  this._selectItem( newSel, nsel );
385
387
  return true;
386
388
  }
@@ -393,7 +395,7 @@ export class Treeview extends Component<TreeviewProps,TreeviewEvents> {
393
395
  let all: { id: ListboxID, level: number }[] = [];
394
396
 
395
397
  const build = ( x: TreeItem, level: number ) => {
396
- all.push( {id: x.id+"", level } );
398
+ all.push( {id: x.id, level } );
397
399
  if( x.children && x.open ) {
398
400
  x.children.forEach( y => build( y, level+1 ) );
399
401
  }
@@ -14,12 +14,12 @@
14
14
  * that can be found in the LICENSE file or at https://opensource.org/licenses/MIT.
15
15
  **/
16
16
 
17
- import { isArray, UnsafeHtml, isNumber, Rect, Constructor, class_ns, x4_class_ns_sym, IRect } from './core_tools.ts';
18
- import { CoreElement } from './core_element.ts';
19
- import { ariaValues, unitless } from './core_styles.ts';
20
- import { CoreEvent, EventMap } from './core_events.ts';
21
- import { addEvent, DOMEventHandler, GlobalDOMEvents } from './core_dom.ts';
22
- import { Application, EvMessage } from './core_application.ts';
17
+ import { isArray, UnsafeHtml, isNumber, Rect, Constructor, class_ns, x4_class_ns_sym, IRect } from './core_tools';
18
+ import { CoreElement } from './core_element';
19
+ import { ariaValues, unitless } from './core_styles';
20
+ import { CoreEvent, EventMap } from './core_events';
21
+ import { addEvent, DOMEventHandler, GlobalDOMEvents } from './core_dom';
22
+ import { Application, EvMessage } from './core_application';
23
23
 
24
24
  interface RefType<T extends Component> {
25
25
  dom: T;
@@ -1198,6 +1198,7 @@ export function wrapDOM( el: HTMLElement ): Component {
1198
1198
  * Automatically generates CSS class: `x4flex`.
1199
1199
  */
1200
1200
 
1201
+ @class_ns( "x4" )
1201
1202
  export class Flex extends Component {
1202
1203
  constructor( ) {
1203
1204
  super({})
@@ -1214,6 +1215,7 @@ export class Flex extends Component {
1214
1215
  * ```
1215
1216
  */
1216
1217
 
1218
+ @class_ns( "x4" )
1217
1219
  export class Space extends Component {
1218
1220
  constructor( width?: number|string, cls?: string ) {
1219
1221
  super( { width, cls } )