x4js 1.4.21 → 1.4.26
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 +2 -2
- package/lib/action.d.ts +57 -0
- package/lib/action.js +59 -0
- package/lib/application.d.ts +2 -1
- package/lib/application.js +20 -12
- package/lib/base_component.d.ts +6 -0
- package/lib/base_component.js +13 -0
- package/lib/button.d.ts +2 -0
- package/lib/button.js +18 -4
- package/lib/component.d.ts +0 -1
- package/lib/component.js +0 -8
- package/lib/dialog.js +30 -17
- package/lib/fileupload.d.ts +2 -2
- package/lib/fileupload.js +5 -5
- package/lib/gridview.js +11 -9
- package/lib/listview.d.ts +2 -2
- package/lib/menu.d.ts +4 -0
- package/lib/menu.js +20 -4
- package/lib/popup.js +4 -1
- package/lib/settings.js +2 -3
- package/lib/spreadsheet.js +3 -1
- package/lib/x4.css +21 -1
- package/package.json +2 -2
- package/src/action.ts +88 -0
- package/src/application.ts +25 -11
- package/src/base_component.ts +15 -0
- package/src/button.ts +25 -5
- package/src/component.ts +4 -10
- package/src/dialog.ts +34 -19
- package/src/fileupload.ts +2 -2
- package/src/gridview.ts +13 -11
- package/src/listview.ts +1 -1
- package/src/menu.ts +27 -5
- package/src/popup.ts +5 -2
- package/src/settings.ts +2 -4
- package/src/spreadsheet.ts +3 -1
- package/src/x4.less +21 -2
- package/tsconfig.json +0 -6
- package/src/hosts/electron.ts +0 -164
- package/src/hosts/host.ts +0 -100
- package/src/hosts/nwjs.ts +0 -141
- package/src/hosts/nwjs_types.ts +0 -339
- package/src/smartedit.ts +0 -537
- package/src/texthiliter.ts +0 -288
package/README.md
CHANGED
package/lib/action.d.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ___ ___ __
|
|
3
|
+
* \ \/ / / _
|
|
4
|
+
* \ / /_| |_
|
|
5
|
+
* / \____ _|
|
|
6
|
+
* /__/\__\ |_|
|
|
7
|
+
*
|
|
8
|
+
* @file action.ts
|
|
9
|
+
* @author Etienne Cochard
|
|
10
|
+
*
|
|
11
|
+
* Copyright (c) 2019-2022 R-libre ingenierie
|
|
12
|
+
*
|
|
13
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
14
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
15
|
+
* in the Software without restriction, including without limitation the rights
|
|
16
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
17
|
+
* of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
18
|
+
* subject to the following conditions:
|
|
19
|
+
* The above copyright notice and this permission notice shall be included in all copies
|
|
20
|
+
* or substantial portions of the Software.
|
|
21
|
+
*
|
|
22
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
23
|
+
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
|
24
|
+
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
25
|
+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
26
|
+
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
27
|
+
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
28
|
+
**/
|
|
29
|
+
import { BasicEvent } from './x4events';
|
|
30
|
+
import { BaseComponent, BaseComponentEventMap, BaseComponentProps } from './base_component';
|
|
31
|
+
import { IconID } from "./icon";
|
|
32
|
+
import { EvChange, EventHandler } from 'x4js';
|
|
33
|
+
export interface EvAction extends BasicEvent {
|
|
34
|
+
}
|
|
35
|
+
export declare function EvAction(source: Action): EvAction;
|
|
36
|
+
interface ActionEventMap extends BaseComponentEventMap {
|
|
37
|
+
run: EvAction;
|
|
38
|
+
change: EvChange;
|
|
39
|
+
}
|
|
40
|
+
interface ActionProps extends BaseComponentProps<ActionEventMap> {
|
|
41
|
+
id?: any;
|
|
42
|
+
text?: string;
|
|
43
|
+
icon?: IconID;
|
|
44
|
+
disabled?: boolean;
|
|
45
|
+
hidden?: boolean;
|
|
46
|
+
checked?: boolean;
|
|
47
|
+
run: EventHandler<EvAction>;
|
|
48
|
+
change?: EventHandler<EvChange>;
|
|
49
|
+
}
|
|
50
|
+
export declare class Action extends BaseComponent<ActionProps, ActionEventMap> {
|
|
51
|
+
constructor(props: ActionProps);
|
|
52
|
+
get props(): ActionProps;
|
|
53
|
+
set text(t: string);
|
|
54
|
+
set icon(i: IconID);
|
|
55
|
+
fire(): void;
|
|
56
|
+
}
|
|
57
|
+
export {};
|
package/lib/action.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* ___ ___ __
|
|
4
|
+
* \ \/ / / _
|
|
5
|
+
* \ / /_| |_
|
|
6
|
+
* / \____ _|
|
|
7
|
+
* /__/\__\ |_|
|
|
8
|
+
*
|
|
9
|
+
* @file action.ts
|
|
10
|
+
* @author Etienne Cochard
|
|
11
|
+
*
|
|
12
|
+
* Copyright (c) 2019-2022 R-libre ingenierie
|
|
13
|
+
*
|
|
14
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
15
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
16
|
+
* in the Software without restriction, including without limitation the rights
|
|
17
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
18
|
+
* of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
19
|
+
* subject to the following conditions:
|
|
20
|
+
* The above copyright notice and this permission notice shall be included in all copies
|
|
21
|
+
* or substantial portions of the Software.
|
|
22
|
+
*
|
|
23
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
24
|
+
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
|
25
|
+
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
26
|
+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
27
|
+
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
28
|
+
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
29
|
+
**/
|
|
30
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
+
exports.Action = exports.EvAction = void 0;
|
|
32
|
+
const x4events_1 = require("./x4events");
|
|
33
|
+
const base_component_1 = require("./base_component");
|
|
34
|
+
const x4js_1 = require("x4js");
|
|
35
|
+
function EvAction(source) {
|
|
36
|
+
return (0, x4events_1.BasicEvent)({ source });
|
|
37
|
+
}
|
|
38
|
+
exports.EvAction = EvAction;
|
|
39
|
+
class Action extends base_component_1.BaseComponent {
|
|
40
|
+
constructor(props) {
|
|
41
|
+
super(props);
|
|
42
|
+
this.mapPropEvents(props, "run");
|
|
43
|
+
}
|
|
44
|
+
get props() {
|
|
45
|
+
return this.m_props;
|
|
46
|
+
}
|
|
47
|
+
set text(t) {
|
|
48
|
+
this.m_props.text = t;
|
|
49
|
+
this.emit("change", (0, x4js_1.EvChange)(this));
|
|
50
|
+
}
|
|
51
|
+
set icon(i) {
|
|
52
|
+
this.m_props.icon = i;
|
|
53
|
+
this.emit("change", (0, x4js_1.EvChange)(this));
|
|
54
|
+
}
|
|
55
|
+
fire() {
|
|
56
|
+
this.emit("run", EvAction(this));
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.Action = Action;
|
package/lib/application.d.ts
CHANGED
|
@@ -91,8 +91,9 @@ export declare class Application<P extends ApplicationProps = ApplicationProps,
|
|
|
91
91
|
*
|
|
92
92
|
* let myApp = new Application( ... );
|
|
93
93
|
* let mainView = new VLayout( ... );
|
|
94
|
-
* myApp.
|
|
94
|
+
* myApp.mainView = mainView;
|
|
95
95
|
*/
|
|
96
|
+
setMainView(root: Component, clearBefore: boolean): void;
|
|
96
97
|
set mainView(root: Component);
|
|
97
98
|
get mainView(): Component;
|
|
98
99
|
setTitle(title: string): void;
|
package/lib/application.js
CHANGED
|
@@ -33,7 +33,7 @@ const x4dom_1 = require("./x4dom");
|
|
|
33
33
|
const base_component_1 = require("./base_component");
|
|
34
34
|
const component_1 = require("./component");
|
|
35
35
|
const settings_1 = require("./settings");
|
|
36
|
-
const
|
|
36
|
+
const x4js_1 = require("x4js");
|
|
37
37
|
const _x4_touch_time = Symbol();
|
|
38
38
|
/**
|
|
39
39
|
* Represents an x4 application, which is typically a single page app.
|
|
@@ -92,6 +92,7 @@ class Application extends base_component_1.BaseComponent {
|
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
ApplicationCreated() {
|
|
95
|
+
this.setTitle('');
|
|
95
96
|
}
|
|
96
97
|
get app_name() {
|
|
97
98
|
return this.m_app_name;
|
|
@@ -123,24 +124,31 @@ class Application extends base_component_1.BaseComponent {
|
|
|
123
124
|
*
|
|
124
125
|
* let myApp = new Application( ... );
|
|
125
126
|
* let mainView = new VLayout( ... );
|
|
126
|
-
* myApp.
|
|
127
|
+
* myApp.mainView = mainView;
|
|
127
128
|
*/
|
|
128
|
-
|
|
129
|
+
setMainView(root, clearBefore) {
|
|
130
|
+
const ddom = this.m_props.renderTo ?? x4dom_1.x4document.body;
|
|
131
|
+
const dest = (0, x4js_1.flyWrap)(ddom);
|
|
132
|
+
if (!this.m_props.renderTo) {
|
|
133
|
+
dest.setStyleValue('position', 'absolute');
|
|
134
|
+
}
|
|
135
|
+
dest.addClass('x4-root-element');
|
|
136
|
+
if (clearBefore) {
|
|
137
|
+
dest._empty();
|
|
138
|
+
}
|
|
129
139
|
this.m_mainView = root;
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
dest.appendChild(root._build());
|
|
137
|
-
});
|
|
140
|
+
root.setStyleValue('position', 'absolute');
|
|
141
|
+
root._build();
|
|
142
|
+
ddom.appendChild(root.dom);
|
|
143
|
+
}
|
|
144
|
+
set mainView(root) {
|
|
145
|
+
this.setMainView(root, false);
|
|
138
146
|
}
|
|
139
147
|
get mainView() {
|
|
140
148
|
return this.m_mainView;
|
|
141
149
|
}
|
|
142
150
|
setTitle(title) {
|
|
143
|
-
x4dom_1.x4document.title = this.m_app_name + ' > ' + title;
|
|
151
|
+
x4dom_1.x4document.title = this.m_app_name + (title ? (' > ' + title) : '');
|
|
144
152
|
}
|
|
145
153
|
disableZoomWheel() {
|
|
146
154
|
window.addEventListener('wheel', function (ev) {
|
package/lib/base_component.d.ts
CHANGED
|
@@ -77,5 +77,11 @@ export declare class BaseComponent<P extends BaseComponentProps<BaseComponentEve
|
|
|
77
77
|
* @param timeout
|
|
78
78
|
*/
|
|
79
79
|
singleShot(callback: TimerCallback, timeout?: number): void;
|
|
80
|
+
/**
|
|
81
|
+
*
|
|
82
|
+
* @param props
|
|
83
|
+
* @param elements
|
|
84
|
+
*/
|
|
85
|
+
mapPropEvents<N extends keyof E>(props: P, ...elements: N[]): void;
|
|
80
86
|
}
|
|
81
87
|
export {};
|
package/lib/base_component.js
CHANGED
|
@@ -94,5 +94,18 @@ class BaseComponent extends x4events_1.EventSource {
|
|
|
94
94
|
singleShot(callback, timeout = 0) {
|
|
95
95
|
setTimeout(callback, timeout);
|
|
96
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
*
|
|
99
|
+
* @param props
|
|
100
|
+
* @param elements
|
|
101
|
+
*/
|
|
102
|
+
mapPropEvents(props, ...elements) {
|
|
103
|
+
elements.forEach(name => {
|
|
104
|
+
const n = name;
|
|
105
|
+
if (props[n]) {
|
|
106
|
+
this._on(n, props[n]);
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
}
|
|
97
110
|
}
|
|
98
111
|
exports.BaseComponent = BaseComponent;
|
package/lib/button.d.ts
CHANGED
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
**/
|
|
29
29
|
import { Component, CProps, CEventMap, HtmlString } from './component';
|
|
30
30
|
import { EventCallback, EvClick, EvChange } from './x4events';
|
|
31
|
+
import { Action } from './action';
|
|
31
32
|
import { IconID } from './icon';
|
|
32
33
|
import { MenuItem, MenuOrSep } from './menu';
|
|
33
34
|
/**
|
|
@@ -48,6 +49,7 @@ interface ButtonProps<E extends ButtonEventMap = ButtonEventMap> extends CProps<
|
|
|
48
49
|
autoRepeat?: number;
|
|
49
50
|
menu?: MenuOrSep[] | MenuCallBack;
|
|
50
51
|
click?: EventCallback<EvClick>;
|
|
52
|
+
action?: Action;
|
|
51
53
|
}
|
|
52
54
|
/**
|
|
53
55
|
* Base button
|
package/lib/button.js
CHANGED
|
@@ -49,10 +49,21 @@ class BaseButton extends component_1.Component {
|
|
|
49
49
|
this.mapPropEvents(props, 'click');
|
|
50
50
|
}
|
|
51
51
|
render(props) {
|
|
52
|
-
|
|
53
|
-
let
|
|
54
|
-
let
|
|
55
|
-
|
|
52
|
+
const action = props.action;
|
|
53
|
+
let icon = props.icon;
|
|
54
|
+
let text = props.text;
|
|
55
|
+
if (action) {
|
|
56
|
+
if (!icon && action.props.icon) {
|
|
57
|
+
icon = action.props.icon;
|
|
58
|
+
}
|
|
59
|
+
if (text === undefined && action.props.text) {
|
|
60
|
+
text = action.props.text;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
const ui_icon = icon ? new icon_1.Icon({ icon, cls: 'left', ref: 'l_icon' }) : null;
|
|
64
|
+
const ui_label = new label_1.Label({ flex: 1, text: text ?? '', align: props.align, ref: 'label' });
|
|
65
|
+
const ui_ricon = props.rightIcon ? new icon_1.Icon({ icon: props.rightIcon, cls: 'right', ref: 'r_icon' }) : null;
|
|
66
|
+
this.setContent([ui_icon, ui_label, ui_ricon]);
|
|
56
67
|
this._setTabIndex(props.tabIndex);
|
|
57
68
|
}
|
|
58
69
|
/**
|
|
@@ -115,6 +126,9 @@ class BaseButton extends component_1.Component {
|
|
|
115
126
|
}
|
|
116
127
|
else {
|
|
117
128
|
this.emit('click', (0, x4events_1.EvClick)());
|
|
129
|
+
if (this.m_props.action) {
|
|
130
|
+
this.m_props.action.fire();
|
|
131
|
+
}
|
|
118
132
|
}
|
|
119
133
|
}
|
|
120
134
|
/**
|
package/lib/component.d.ts
CHANGED
|
@@ -314,7 +314,6 @@ export declare class Component<P extends CProps<BaseComponentEventMap> = CProps<
|
|
|
314
314
|
*
|
|
315
315
|
*/
|
|
316
316
|
clearDomEvent<K extends keyof X4ElementEventMap>(type: K): void;
|
|
317
|
-
mapPropEvents<N extends keyof E>(props: P, ...elements: N[]): void;
|
|
318
317
|
/**
|
|
319
318
|
*
|
|
320
319
|
* @param name
|
package/lib/component.js
CHANGED
|
@@ -849,14 +849,6 @@ class Component extends base_component_1.BaseComponent {
|
|
|
849
849
|
}
|
|
850
850
|
}
|
|
851
851
|
}
|
|
852
|
-
mapPropEvents(props, ...elements) {
|
|
853
|
-
elements.forEach(name => {
|
|
854
|
-
const n = name;
|
|
855
|
-
if (props[n]) {
|
|
856
|
-
this._on(n, props[n]);
|
|
857
|
-
}
|
|
858
|
-
});
|
|
859
|
-
}
|
|
860
852
|
/**
|
|
861
853
|
*
|
|
862
854
|
* @param name
|
package/lib/dialog.js
CHANGED
|
@@ -346,14 +346,14 @@ class Dialog extends popup_1.Popup {
|
|
|
346
346
|
let trc = this.m_el_title.getBoundingRect();
|
|
347
347
|
let dx = x - rc.left, dy = y - rc.top;
|
|
348
348
|
let cstyle = this.getComputedStyle();
|
|
349
|
-
let topw = cstyle.parse('marginTop') + cstyle.parse('paddingTop') + cstyle.parse('borderTopWidth');
|
|
350
|
-
let botw = cstyle.parse('marginBottom') + cstyle.parse('paddingBottom') + cstyle.parse('borderBottomWidth');
|
|
351
|
-
let lftw = cstyle.parse('marginLeft') + cstyle.parse('paddingLeft') + cstyle.parse('borderLeftWidth');
|
|
352
|
-
let rgtw = cstyle.parse('marginRight') + cstyle.parse('paddingRight') + cstyle.parse('borderRightWidth');
|
|
353
|
-
wrc.top += topw - trc.height;
|
|
354
|
-
wrc.height -= topw + botw - trc.height;
|
|
355
|
-
wrc.left += lftw;
|
|
356
|
-
wrc.width -= lftw + rgtw;
|
|
349
|
+
//let topw = cstyle.parse('marginTop') + cstyle.parse('paddingTop') + cstyle.parse('borderTopWidth');
|
|
350
|
+
//let botw = cstyle.parse('marginBottom') + cstyle.parse('paddingBottom') + cstyle.parse('borderBottomWidth');
|
|
351
|
+
//let lftw = cstyle.parse('marginLeft') + cstyle.parse('paddingLeft') + cstyle.parse('borderLeftWidth');
|
|
352
|
+
//let rgtw = cstyle.parse('marginRight') + cstyle.parse('paddingRight') + cstyle.parse('borderRightWidth');
|
|
353
|
+
//wrc.top += topw - trc.height;
|
|
354
|
+
//wrc.height -= topw + botw - trc.height;
|
|
355
|
+
//wrc.left += lftw;
|
|
356
|
+
//wrc.width -= lftw + rgtw;
|
|
357
357
|
// custom handling double click
|
|
358
358
|
const now = Date.now();
|
|
359
359
|
const delta = now - this.m_last_down;
|
|
@@ -367,19 +367,32 @@ class Dialog extends popup_1.Popup {
|
|
|
367
367
|
return;
|
|
368
368
|
}
|
|
369
369
|
let __move = (ex, ey) => {
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
x = wrc.left - rc.width;
|
|
370
|
+
if (ex > wrc.right) {
|
|
371
|
+
ex = wrc.right;
|
|
373
372
|
}
|
|
374
|
-
else if (
|
|
375
|
-
|
|
373
|
+
else if (ex < wrc.left) {
|
|
374
|
+
ex = wrc.left;
|
|
376
375
|
}
|
|
377
|
-
if (
|
|
378
|
-
|
|
376
|
+
if (ey > wrc.bottom) {
|
|
377
|
+
ey = wrc.bottom;
|
|
379
378
|
}
|
|
380
|
-
else if (
|
|
381
|
-
|
|
379
|
+
else if (ey < wrc.top) {
|
|
380
|
+
ey = wrc.top;
|
|
382
381
|
}
|
|
382
|
+
let x = ex - dx, y = ey - dy;
|
|
383
|
+
//if (x + rc.width < wrc.left) {
|
|
384
|
+
// x = wrc.left - rc.width;
|
|
385
|
+
//}
|
|
386
|
+
//else if (x > wrc.right) {
|
|
387
|
+
// x = wrc.right;
|
|
388
|
+
//}
|
|
389
|
+
//
|
|
390
|
+
//if (y < wrc.top) { // title grip is on top
|
|
391
|
+
// y = wrc.top;
|
|
392
|
+
//}
|
|
393
|
+
//else if (y > wrc.bottom) {
|
|
394
|
+
// y = wrc.bottom;
|
|
395
|
+
//}
|
|
383
396
|
this.setStyle({
|
|
384
397
|
left: x,
|
|
385
398
|
top: y
|
package/lib/fileupload.d.ts
CHANGED
|
@@ -55,10 +55,10 @@ export declare class ImageUpload extends FileUpload {
|
|
|
55
55
|
* @param extensions - string - ex: '.doc,.docx'
|
|
56
56
|
* @param cb - callback to call when user select a file
|
|
57
57
|
*/
|
|
58
|
-
export declare function
|
|
58
|
+
export declare function openFileDialog(extensions: string, cb: (filename: FileList) => void, multiple?: boolean): void;
|
|
59
59
|
/**
|
|
60
60
|
* open saveas dialog
|
|
61
61
|
* @param defFileName - string - proposed filename
|
|
62
62
|
* @param cb - callback to call when user choose the destination
|
|
63
63
|
*/
|
|
64
|
-
export declare function
|
|
64
|
+
export declare function saveFileDialog(defFileName: string, extensions: string, cb: (filename: File) => void): void;
|
package/lib/fileupload.js
CHANGED
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
29
29
|
**/
|
|
30
30
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
-
exports.
|
|
31
|
+
exports.saveFileDialog = exports.openFileDialog = exports.ImageUpload = exports.FileUpload = void 0;
|
|
32
32
|
const x4dom_1 = require("./x4dom");
|
|
33
33
|
const component_1 = require("./component");
|
|
34
34
|
const layout_1 = require("./layout");
|
|
@@ -136,7 +136,7 @@ function _createFileInput() {
|
|
|
136
136
|
* @param extensions - string - ex: '.doc,.docx'
|
|
137
137
|
* @param cb - callback to call when user select a file
|
|
138
138
|
*/
|
|
139
|
-
function
|
|
139
|
+
function openFileDialog(extensions, cb, multiple = false) {
|
|
140
140
|
let fi = _createFileInput();
|
|
141
141
|
fi.removeAttribute('nwsaveas');
|
|
142
142
|
fi.setAttribute('accept', extensions);
|
|
@@ -149,13 +149,13 @@ function openFile(extensions, cb, multiple = false) {
|
|
|
149
149
|
});
|
|
150
150
|
fi.dom.click();
|
|
151
151
|
}
|
|
152
|
-
exports.
|
|
152
|
+
exports.openFileDialog = openFileDialog;
|
|
153
153
|
/**
|
|
154
154
|
* open saveas dialog
|
|
155
155
|
* @param defFileName - string - proposed filename
|
|
156
156
|
* @param cb - callback to call when user choose the destination
|
|
157
157
|
*/
|
|
158
|
-
function
|
|
158
|
+
function saveFileDialog(defFileName, extensions, cb) {
|
|
159
159
|
let fi = _createFileInput();
|
|
160
160
|
fi.setAttribute('nwsaveas', defFileName);
|
|
161
161
|
fi.setAttribute('accept', extensions);
|
|
@@ -167,4 +167,4 @@ function saveFile(defFileName, extensions, cb) {
|
|
|
167
167
|
});
|
|
168
168
|
fi.dom.click();
|
|
169
169
|
}
|
|
170
|
-
exports.
|
|
170
|
+
exports.saveFileDialog = saveFileDialog;
|
package/lib/gridview.js
CHANGED
|
@@ -844,16 +844,18 @@ class GridView extends layout_1.VLayout {
|
|
|
844
844
|
}
|
|
845
845
|
this.m_footer.enumChilds((c) => {
|
|
846
846
|
let cid = c.getData('col');
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
847
|
+
if (cid) {
|
|
848
|
+
let col = this.m_columns[cid];
|
|
849
|
+
let fmt = col.formatter;
|
|
850
|
+
let text;
|
|
851
|
+
if (fmt && fmt instanceof Function) {
|
|
852
|
+
text = fmt(rec[col.id], rec);
|
|
853
|
+
}
|
|
854
|
+
else {
|
|
855
|
+
text = rec[col.id];
|
|
856
|
+
}
|
|
857
|
+
c.setContent(text, false);
|
|
855
858
|
}
|
|
856
|
-
c.setContent(text, false);
|
|
857
859
|
});
|
|
858
860
|
}
|
|
859
861
|
}
|
package/lib/listview.d.ts
CHANGED
|
@@ -134,8 +134,8 @@ export declare class ListView extends VLayout<ListViewProps, ListViewEventMap> {
|
|
|
134
134
|
/**
|
|
135
135
|
* return the current selection or null
|
|
136
136
|
*/
|
|
137
|
-
get selection():
|
|
138
|
-
set selection(id:
|
|
137
|
+
get selection(): any;
|
|
138
|
+
set selection(id: any);
|
|
139
139
|
private _findItemWithId;
|
|
140
140
|
/**
|
|
141
141
|
* append or prepend a new item
|
package/lib/menu.d.ts
CHANGED
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
**/
|
|
29
29
|
import { CEventMap, Component, CProps } from './component';
|
|
30
30
|
import { EvClick, EventCallback } from './x4events';
|
|
31
|
+
import { Action } from './action';
|
|
31
32
|
import { Popup, PopupProps } from './popup';
|
|
32
33
|
import { IconID } from './icon';
|
|
33
34
|
import { Label } from './label';
|
|
@@ -99,10 +100,13 @@ export interface MenuItemProps extends CProps {
|
|
|
99
100
|
checked?: boolean;
|
|
100
101
|
cls?: string;
|
|
101
102
|
click?: EventCallback<EvClick>;
|
|
103
|
+
action?: Action;
|
|
102
104
|
}
|
|
103
105
|
export declare class MenuItem extends Component<MenuItemProps, MenuItemEventMap> {
|
|
104
106
|
private m_menu;
|
|
105
107
|
private m_isOpen;
|
|
108
|
+
private m_action;
|
|
109
|
+
constructor(action: Action);
|
|
106
110
|
constructor(text: string, click: EventCallback<EvClick>);
|
|
107
111
|
constructor(props: MenuItemProps);
|
|
108
112
|
/** @ignore */
|
package/lib/menu.js
CHANGED
|
@@ -32,6 +32,7 @@ exports.MenuBar = exports.MenuItem = exports.Menu = exports.MenuTitle = exports.
|
|
|
32
32
|
const x4dom_1 = require("./x4dom");
|
|
33
33
|
const component_1 = require("./component");
|
|
34
34
|
const x4events_1 = require("./x4events");
|
|
35
|
+
const action_1 = require("./action");
|
|
35
36
|
const popup_1 = require("./popup");
|
|
36
37
|
const icon_1 = require("./icon");
|
|
37
38
|
const label_1 = require("./label");
|
|
@@ -177,8 +178,15 @@ exports.Menu = Menu;
|
|
|
177
178
|
class MenuItem extends component_1.Component {
|
|
178
179
|
m_menu;
|
|
179
180
|
m_isOpen;
|
|
181
|
+
m_action;
|
|
180
182
|
constructor(a, b) {
|
|
181
|
-
if (
|
|
183
|
+
if (a instanceof action_1.Action) {
|
|
184
|
+
super({
|
|
185
|
+
click: () => { a.fire(); }
|
|
186
|
+
});
|
|
187
|
+
this.m_action = a;
|
|
188
|
+
}
|
|
189
|
+
else if ((0, tools_1.isString)(a)) {
|
|
182
190
|
super({
|
|
183
191
|
text: a,
|
|
184
192
|
click: b
|
|
@@ -195,15 +203,23 @@ class MenuItem extends component_1.Component {
|
|
|
195
203
|
}
|
|
196
204
|
/** @ignore */
|
|
197
205
|
render(props) {
|
|
198
|
-
let icon = props.icon ??
|
|
206
|
+
let icon = props.icon ?? 0;
|
|
199
207
|
let text = props.text;
|
|
200
208
|
if (props.checked !== undefined) {
|
|
201
|
-
icon = props.checked ? '
|
|
209
|
+
icon = props.checked ? 'var( --x4-icon-check )' : 0;
|
|
210
|
+
}
|
|
211
|
+
if (this.m_action) {
|
|
212
|
+
if (!icon) {
|
|
213
|
+
icon = this.m_action.props.icon;
|
|
214
|
+
}
|
|
215
|
+
if (text === undefined) {
|
|
216
|
+
text = this.m_action.props.text;
|
|
217
|
+
}
|
|
202
218
|
}
|
|
203
219
|
let popIco = null;
|
|
204
220
|
if (this.isPopup) {
|
|
205
221
|
this.addClass('@popup-menu-item');
|
|
206
|
-
popIco = new icon_1.Icon("var( --x4-icon-chevron-right )");
|
|
222
|
+
popIco = new icon_1.Icon({ icon: "var( --x4-icon-chevron-right )", cls: "pop-mark" });
|
|
207
223
|
}
|
|
208
224
|
if (!text && !icon) {
|
|
209
225
|
this.addClass('@separator');
|
package/lib/popup.js
CHANGED
|
@@ -126,7 +126,10 @@ class Popup extends component_1.Container {
|
|
|
126
126
|
}
|
|
127
127
|
centerOnScreen() {
|
|
128
128
|
let rc = this.getBoundingRect();
|
|
129
|
-
let x = (
|
|
129
|
+
//let x = (x4document.body.clientWidth - rc.width) / 2,
|
|
130
|
+
// y = (x4document.body.clientHeight - rc.height) / 2;
|
|
131
|
+
const x = `max( 0px, 50vw - ${rc.width / 2}px )`; //(x4dom_1.x4document.body.clientWidth - rc.width) / 2;
|
|
132
|
+
const y = `max( 0px, 50vh - ${rc.height / 2}px )`; //(x4dom_1.x4document.body.clientHeight - rc.height) / 2;
|
|
130
133
|
this.setStyleValue('left', x);
|
|
131
134
|
this.setStyleValue('top', y);
|
|
132
135
|
}
|
package/lib/settings.js
CHANGED
|
@@ -29,7 +29,6 @@
|
|
|
29
29
|
**/
|
|
30
30
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
31
|
exports.Settings = void 0;
|
|
32
|
-
const host_1 = require("./hosts/host");
|
|
33
32
|
class Settings {
|
|
34
33
|
m_data;
|
|
35
34
|
m_name;
|
|
@@ -48,14 +47,14 @@ class Settings {
|
|
|
48
47
|
}
|
|
49
48
|
_save() {
|
|
50
49
|
let data = JSON.stringify(this.m_data);
|
|
51
|
-
|
|
50
|
+
localStorage.setItem(this.m_name, data);
|
|
52
51
|
}
|
|
53
52
|
_load() {
|
|
54
53
|
if (this.m_data) {
|
|
55
54
|
return;
|
|
56
55
|
}
|
|
57
56
|
this.m_data = {};
|
|
58
|
-
let data =
|
|
57
|
+
let data = localStorage.getItem(this.m_name);
|
|
59
58
|
if (data !== null) {
|
|
60
59
|
data = JSON.parse(data);
|
|
61
60
|
if (data) {
|
package/lib/spreadsheet.js
CHANGED
|
@@ -389,6 +389,7 @@ class Spreadsheet extends layout_1.VLayout {
|
|
|
389
389
|
if (this.m_recycler.length) {
|
|
390
390
|
cell = this.m_recycler.pop();
|
|
391
391
|
cell.clearClasses();
|
|
392
|
+
cell.addClass('@comp'); // todo: find better to reset to default
|
|
392
393
|
}
|
|
393
394
|
else {
|
|
394
395
|
cell = new component_1.Component({
|
|
@@ -492,7 +493,8 @@ class Spreadsheet extends layout_1.VLayout {
|
|
|
492
493
|
cell.setStyle({
|
|
493
494
|
left: x,
|
|
494
495
|
top: top + y,
|
|
495
|
-
width: calcw[colIdx]
|
|
496
|
+
width: calcw[colIdx],
|
|
497
|
+
height: this.m_itemHeight
|
|
496
498
|
});
|
|
497
499
|
if (this.m_selection.row == rowIdx && this.m_selection.col == colIdx) {
|
|
498
500
|
cell.addClass('@selected');
|