x4js 1.4.3 → 1.4.4
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/lib/index.d.ts +55 -0
- package/lib/index.js +55 -56
- package/lib/router.d.ts +1 -8
- package/lib/router.js +1 -1
- package/package.json +2 -1
- package/src/index.ts +55 -0
- package/src/router.ts +1 -1
- package/tsconfig.json +2 -1
- package/lib/application.d.ts +0 -95
- package/lib/application.js +0 -137
- package/lib/base64.d.ts +0 -31
- package/lib/base64.js +0 -135
- package/lib/base_component.d.ts +0 -64
- package/lib/base_component.js +0 -77
- package/lib/button.d.ts +0 -145
- package/lib/button.js +0 -235
- package/lib/calendar.d.ts +0 -77
- package/lib/calendar.js +0 -236
- package/lib/canvas.d.ts +0 -88
- package/lib/canvas.js +0 -354
- package/lib/cardview.d.ts +0 -83
- package/lib/cardview.js +0 -152
- package/lib/checkbox.d.ts +0 -72
- package/lib/checkbox.js +0 -126
- package/lib/color.d.ts +0 -144
- package/lib/color.js +0 -584
- package/lib/component.d.ts +0 -572
- package/lib/component.js +0 -1712
- package/lib/dom_events.d.ts +0 -284
- package/lib/dom_events.js +0 -13
- package/lib/hosts/host.d.ts +0 -44
- package/lib/hosts/host.js +0 -69
- package/lib/i18n.d.ts +0 -67
- package/lib/i18n.js +0 -169
- package/lib/icon.d.ts +0 -56
- package/lib/icon.js +0 -173
- package/lib/input.d.ts +0 -86
- package/lib/input.js +0 -172
- package/lib/label.d.ts +0 -54
- package/lib/label.js +0 -86
- package/lib/layout.d.ts +0 -77
- package/lib/layout.js +0 -261
- package/lib/list.txt +0 -56
- package/lib/menu.d.ts +0 -122
- package/lib/menu.js +0 -276
- package/lib/popup.d.ts +0 -71
- package/lib/popup.js +0 -373
- package/lib/settings.d.ts +0 -33
- package/lib/settings.js +0 -63
- package/lib/styles.d.ts +0 -81
- package/lib/styles.js +0 -262
- package/lib/tools.d.ts +0 -382
- package/lib/tools.js +0 -1096
- package/lib/x4_events.d.ts +0 -253
- package/lib/x4_events.js +0 -363
- package/list.txt +0 -0
package/lib/base_component.d.ts
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ___ ___ __
|
|
3
|
-
* \ \/ / / _
|
|
4
|
-
* \ / /_| |_
|
|
5
|
-
* / \____ _|
|
|
6
|
-
* /__/\__\ |_|
|
|
7
|
-
*
|
|
8
|
-
* @file base_component.ts
|
|
9
|
-
* @author Etienne Cochard
|
|
10
|
-
* @copyright (c) 2022 R-libre ingenierie, all rights reserved.
|
|
11
|
-
*
|
|
12
|
-
**/
|
|
13
|
-
import { EventMap, MapEvents, EventSource, EvTimer } from './x4_events';
|
|
14
|
-
/**
|
|
15
|
-
* Timer Callback
|
|
16
|
-
* @see EvTimer, startTimer, stopTimer
|
|
17
|
-
*/
|
|
18
|
-
interface TimerCallback {
|
|
19
|
-
(name: string, time: number): void;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* BaseComponent EventMap
|
|
23
|
-
*/
|
|
24
|
-
export interface BaseComponentEventMap extends EventMap {
|
|
25
|
-
timer: EvTimer;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* BaseCompoment Properties
|
|
29
|
-
*/
|
|
30
|
-
export interface BaseComponentProps<T = BaseComponentEventMap> {
|
|
31
|
-
events?: MapEvents<T>;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* BaseComponent class
|
|
35
|
-
*/
|
|
36
|
-
export declare class BaseComponent<P extends BaseComponentProps<BaseComponentEventMap>, E extends BaseComponentEventMap> extends EventSource<E> {
|
|
37
|
-
#private;
|
|
38
|
-
protected m_props: P;
|
|
39
|
-
constructor(props: P);
|
|
40
|
-
/**
|
|
41
|
-
* start a new timer
|
|
42
|
-
* @param name timer name
|
|
43
|
-
* @param timeout time out in ms
|
|
44
|
-
* @param repeat if true this is an auto repeat timer
|
|
45
|
-
* @param callback if !null, the callback to call else a EvTimer is fired
|
|
46
|
-
*/
|
|
47
|
-
startTimer(name: string, timeout: number, repeat?: boolean, callback?: TimerCallback): void;
|
|
48
|
-
/**
|
|
49
|
-
* stop the given timer
|
|
50
|
-
* @param name
|
|
51
|
-
*/
|
|
52
|
-
stopTimer(name: string): void;
|
|
53
|
-
/**
|
|
54
|
-
* stop all timers
|
|
55
|
-
*/
|
|
56
|
-
disposeTimers(): void;
|
|
57
|
-
/**
|
|
58
|
-
*
|
|
59
|
-
* @param callback
|
|
60
|
-
* @param timeout
|
|
61
|
-
*/
|
|
62
|
-
singleShot(callback: TimerCallback, timeout?: number): void;
|
|
63
|
-
}
|
|
64
|
-
export {};
|
package/lib/base_component.js
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ___ ___ __
|
|
3
|
-
* \ \/ / / _
|
|
4
|
-
* \ / /_| |_
|
|
5
|
-
* / \____ _|
|
|
6
|
-
* /__/\__\ |_|
|
|
7
|
-
*
|
|
8
|
-
* @file base_component.ts
|
|
9
|
-
* @author Etienne Cochard
|
|
10
|
-
* @copyright (c) 2022 R-libre ingenierie, all rights reserved.
|
|
11
|
-
*
|
|
12
|
-
**/
|
|
13
|
-
import { EventSource, EvTimer } from './x4_events';
|
|
14
|
-
/**
|
|
15
|
-
* BaseComponent class
|
|
16
|
-
*/
|
|
17
|
-
export class BaseComponent extends EventSource {
|
|
18
|
-
m_props;
|
|
19
|
-
#m_timers;
|
|
20
|
-
constructor(props) {
|
|
21
|
-
super();
|
|
22
|
-
//this.m_props = { ...props };
|
|
23
|
-
this.m_props = props;
|
|
24
|
-
if (props.events) {
|
|
25
|
-
this.listen(props.events);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* start a new timer
|
|
30
|
-
* @param name timer name
|
|
31
|
-
* @param timeout time out in ms
|
|
32
|
-
* @param repeat if true this is an auto repeat timer
|
|
33
|
-
* @param callback if !null, the callback to call else a EvTimer is fired
|
|
34
|
-
*/
|
|
35
|
-
startTimer(name, timeout, repeat = true, callback = null) {
|
|
36
|
-
if (!this.#m_timers) {
|
|
37
|
-
this.#m_timers = new Map();
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
this.stopTimer(name);
|
|
41
|
-
}
|
|
42
|
-
const id = (repeat ? setInterval : setTimeout)((tm) => {
|
|
43
|
-
if (callback) {
|
|
44
|
-
callback(name, tm);
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
this.emit('timer', EvTimer(name, tm));
|
|
48
|
-
}
|
|
49
|
-
}, timeout);
|
|
50
|
-
this.#m_timers.set(name, () => { (repeat ? clearInterval : clearTimeout)(id); });
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* stop the given timer
|
|
54
|
-
* @param name
|
|
55
|
-
*/
|
|
56
|
-
stopTimer(name) {
|
|
57
|
-
const clear = this.#m_timers.get(name);
|
|
58
|
-
if (clear) {
|
|
59
|
-
clear();
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* stop all timers
|
|
64
|
-
*/
|
|
65
|
-
disposeTimers() {
|
|
66
|
-
this.#m_timers?.forEach(v => v());
|
|
67
|
-
this.#m_timers = undefined;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
*
|
|
71
|
-
* @param callback
|
|
72
|
-
* @param timeout
|
|
73
|
-
*/
|
|
74
|
-
singleShot(callback, timeout = 0) {
|
|
75
|
-
setTimeout(callback, timeout);
|
|
76
|
-
}
|
|
77
|
-
}
|
package/lib/button.d.ts
DELETED
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ___ ___ __
|
|
3
|
-
* \ \/ / / _
|
|
4
|
-
* \ / /_| |_
|
|
5
|
-
* / \____ _|
|
|
6
|
-
* /__/\__\ |_|
|
|
7
|
-
*
|
|
8
|
-
* @file button.ts
|
|
9
|
-
* @author Etienne Cochard
|
|
10
|
-
* @license
|
|
11
|
-
* Copyright (c) 2019-2021 R-libre ingenierie
|
|
12
|
-
*
|
|
13
|
-
* This program is free software; you can redistribute it and/or modify
|
|
14
|
-
* it under the terms of the GNU General Public License as published by
|
|
15
|
-
* the Free Software Foundation; either version 3 of the License, or
|
|
16
|
-
* (at your option) any later version.
|
|
17
|
-
*
|
|
18
|
-
* This program is distributed in the hope that it will be useful,
|
|
19
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
20
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
21
|
-
* GNU General Public License for more details.
|
|
22
|
-
*
|
|
23
|
-
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
24
|
-
**/
|
|
25
|
-
import { Component, CProps, CEventMap, HtmlString } from './component';
|
|
26
|
-
import { EventCallback, EvClick, EvChange } from './x4_events';
|
|
27
|
-
import { IconID } from './icon';
|
|
28
|
-
import { MenuItem, MenuOrSep } from './menu';
|
|
29
|
-
/**
|
|
30
|
-
* Button events
|
|
31
|
-
*/
|
|
32
|
-
interface ButtonEventMap extends CEventMap {
|
|
33
|
-
click: EvClick;
|
|
34
|
-
}
|
|
35
|
-
declare type MenuCallBack = () => MenuOrSep[];
|
|
36
|
-
/**
|
|
37
|
-
* Button properties
|
|
38
|
-
*/
|
|
39
|
-
interface ButtonProps<E extends ButtonEventMap = ButtonEventMap> extends CProps<E> {
|
|
40
|
-
text?: string | HtmlString;
|
|
41
|
-
icon?: IconID;
|
|
42
|
-
rightIcon?: IconID;
|
|
43
|
-
align?: 'center' | 'left' | 'right';
|
|
44
|
-
autoRepeat?: number;
|
|
45
|
-
menu?: MenuOrSep[] | MenuCallBack;
|
|
46
|
-
click?: EventCallback<EvClick>;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Base button
|
|
50
|
-
*/
|
|
51
|
-
export declare class BaseButton<P extends ButtonProps = ButtonProps, E extends ButtonEventMap = ButtonEventMap> extends Component<P, E> {
|
|
52
|
-
constructor(props: P);
|
|
53
|
-
render(props: ButtonProps): void;
|
|
54
|
-
/**
|
|
55
|
-
* starts/stops the autorepeat
|
|
56
|
-
*/
|
|
57
|
-
private _startAutoRep;
|
|
58
|
-
/**
|
|
59
|
-
*
|
|
60
|
-
*/
|
|
61
|
-
protected _handleKeyDown(ev: KeyboardEvent): void;
|
|
62
|
-
/**
|
|
63
|
-
* called by the system on click event
|
|
64
|
-
*/
|
|
65
|
-
protected _handleClick(ev: MouseEvent): void;
|
|
66
|
-
/**
|
|
67
|
-
* sends a click to the observers
|
|
68
|
-
*/
|
|
69
|
-
protected _sendClick(): void;
|
|
70
|
-
/**
|
|
71
|
-
* change the button text
|
|
72
|
-
* @example
|
|
73
|
-
* ```ts
|
|
74
|
-
* let btn = new Button( {
|
|
75
|
-
* text: 'hello'
|
|
76
|
-
* });
|
|
77
|
-
*
|
|
78
|
-
* btn.text = 'world';
|
|
79
|
-
* ```
|
|
80
|
-
*/
|
|
81
|
-
set text(text: string | HtmlString);
|
|
82
|
-
get text(): string | HtmlString;
|
|
83
|
-
/**
|
|
84
|
-
* change the button icon
|
|
85
|
-
* todo: do nothing if no icon defined at startup
|
|
86
|
-
*
|
|
87
|
-
* @example
|
|
88
|
-
* ```ts
|
|
89
|
-
* let btn = new Button( {
|
|
90
|
-
* text: 'hello',
|
|
91
|
-
* icon: 'close'
|
|
92
|
-
* });
|
|
93
|
-
* btn.setIcon( 'open' );
|
|
94
|
-
* ```
|
|
95
|
-
*/
|
|
96
|
-
set icon(icon: IconID);
|
|
97
|
-
get icon(): IconID;
|
|
98
|
-
/**
|
|
99
|
-
* change the button right icon
|
|
100
|
-
* todo: do nothing if no icon defined at startup
|
|
101
|
-
*
|
|
102
|
-
* @example
|
|
103
|
-
* ```ts
|
|
104
|
-
* let btn = new Button( {
|
|
105
|
-
* text: 'hello',
|
|
106
|
-
* icon: 'close'
|
|
107
|
-
* });
|
|
108
|
-
* btn.setIcon( 'open' );
|
|
109
|
-
* ```
|
|
110
|
-
*/
|
|
111
|
-
set rightIcon(icon: IconID);
|
|
112
|
-
get rightIcon(): IconID;
|
|
113
|
-
/**
|
|
114
|
-
*
|
|
115
|
-
*/
|
|
116
|
-
set menu(items: MenuItem[]);
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
*
|
|
120
|
-
*/
|
|
121
|
-
export declare class Button extends BaseButton<ButtonProps> {
|
|
122
|
-
}
|
|
123
|
-
interface ToggleButtonEventMap extends ButtonEventMap {
|
|
124
|
-
change: EvChange;
|
|
125
|
-
}
|
|
126
|
-
interface ToggleButtonProps extends ButtonProps<ToggleButtonEventMap> {
|
|
127
|
-
checked: boolean;
|
|
128
|
-
checkedIcon?: IconID;
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
*
|
|
132
|
-
*/
|
|
133
|
-
export declare class ToggleButton extends BaseButton<ToggleButtonProps, ToggleButtonEventMap> {
|
|
134
|
-
constructor(props: ToggleButtonProps);
|
|
135
|
-
/**
|
|
136
|
-
*
|
|
137
|
-
*/
|
|
138
|
-
render(props: ToggleButtonProps): void;
|
|
139
|
-
/**
|
|
140
|
-
*
|
|
141
|
-
*/
|
|
142
|
-
protected _sendClick(): void;
|
|
143
|
-
private _updateIcon;
|
|
144
|
-
}
|
|
145
|
-
export {};
|
package/lib/button.js
DELETED
|
@@ -1,235 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ___ ___ __
|
|
3
|
-
* \ \/ / / _
|
|
4
|
-
* \ / /_| |_
|
|
5
|
-
* / \____ _|
|
|
6
|
-
* /__/\__\ |_|
|
|
7
|
-
*
|
|
8
|
-
* @file button.ts
|
|
9
|
-
* @author Etienne Cochard
|
|
10
|
-
* @license
|
|
11
|
-
* Copyright (c) 2019-2021 R-libre ingenierie
|
|
12
|
-
*
|
|
13
|
-
* This program is free software; you can redistribute it and/or modify
|
|
14
|
-
* it under the terms of the GNU General Public License as published by
|
|
15
|
-
* the Free Software Foundation; either version 3 of the License, or
|
|
16
|
-
* (at your option) any later version.
|
|
17
|
-
*
|
|
18
|
-
* This program is distributed in the hope that it will be useful,
|
|
19
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
20
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
21
|
-
* GNU General Public License for more details.
|
|
22
|
-
*
|
|
23
|
-
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
24
|
-
**/
|
|
25
|
-
import { Component } from './component';
|
|
26
|
-
import { EvClick, EvChange } from './x4_events';
|
|
27
|
-
import { Icon } from './icon';
|
|
28
|
-
import { Label } from './label';
|
|
29
|
-
import { Menu } from './menu';
|
|
30
|
-
import { isFunction } from './tools';
|
|
31
|
-
/**
|
|
32
|
-
* Base button
|
|
33
|
-
*/
|
|
34
|
-
export class BaseButton extends Component {
|
|
35
|
-
constructor(props) {
|
|
36
|
-
super(props);
|
|
37
|
-
this.setProp('tag', 'button');
|
|
38
|
-
this.setDomEvent('click', (e) => this._handleClick(e));
|
|
39
|
-
this.setDomEvent('mousedown', () => { this._startAutoRep(true); });
|
|
40
|
-
this.setDomEvent('mouseup', () => { this._startAutoRep(false); });
|
|
41
|
-
this.setDomEvent('keydown', (e) => this._handleKeyDown(e));
|
|
42
|
-
this.mapPropEvents(props, 'click');
|
|
43
|
-
}
|
|
44
|
-
render(props) {
|
|
45
|
-
let icon = props.icon ? new Icon({ icon: props.icon, cls: 'left', ref: 'l_icon' }) : null;
|
|
46
|
-
let label = new Label({ flex: 1, text: props.text ?? '', align: props.align, ref: 'label' });
|
|
47
|
-
let ricon = props.rightIcon ? new Icon({ icon: props.rightIcon, cls: 'right', ref: 'r_icon' }) : null;
|
|
48
|
-
this.setContent([icon, label, ricon]);
|
|
49
|
-
this._setTabIndex(props.tabIndex);
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* starts/stops the autorepeat
|
|
53
|
-
*/
|
|
54
|
-
_startAutoRep(start) {
|
|
55
|
-
if (!this.m_props.autoRepeat) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
if (start) {
|
|
59
|
-
// 1st timer 1s
|
|
60
|
-
this.startTimer('repeat', 700, false, () => {
|
|
61
|
-
// auto click
|
|
62
|
-
this.startTimer('repeat', this.m_props.autoRepeat, true, this._sendClick);
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
this.stopTimer('repeat');
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
*
|
|
71
|
-
*/
|
|
72
|
-
_handleKeyDown(ev) {
|
|
73
|
-
if (!ev.ctrlKey && !ev.shiftKey && !ev.altKey) {
|
|
74
|
-
if (ev.key == 'Enter' || ev.key == ' ') {
|
|
75
|
-
this._sendClick();
|
|
76
|
-
ev.preventDefault();
|
|
77
|
-
ev.stopPropagation();
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* called by the system on click event
|
|
83
|
-
*/
|
|
84
|
-
_handleClick(ev) {
|
|
85
|
-
if (this.m_props.menu) {
|
|
86
|
-
let menu = new Menu({
|
|
87
|
-
items: isFunction(this.m_props.menu) ? this.m_props.menu() : this.m_props.menu
|
|
88
|
-
});
|
|
89
|
-
let rc = this.getBoundingRect();
|
|
90
|
-
menu.displayAt(rc.left, rc.bottom, 'tl');
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
this._sendClick();
|
|
94
|
-
}
|
|
95
|
-
ev.preventDefault();
|
|
96
|
-
ev.stopPropagation();
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* sends a click to the observers
|
|
100
|
-
*/
|
|
101
|
-
_sendClick() {
|
|
102
|
-
if (this.m_props.menu) {
|
|
103
|
-
let menu = new Menu({
|
|
104
|
-
items: isFunction(this.m_props.menu) ? this.m_props.menu() : this.m_props.menu
|
|
105
|
-
});
|
|
106
|
-
let rc = this.getBoundingRect();
|
|
107
|
-
menu.displayAt(rc.left, rc.bottom, 'tl');
|
|
108
|
-
}
|
|
109
|
-
else {
|
|
110
|
-
this.emit('click', EvClick());
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* change the button text
|
|
115
|
-
* @example
|
|
116
|
-
* ```ts
|
|
117
|
-
* let btn = new Button( {
|
|
118
|
-
* text: 'hello'
|
|
119
|
-
* });
|
|
120
|
-
*
|
|
121
|
-
* btn.text = 'world';
|
|
122
|
-
* ```
|
|
123
|
-
*/
|
|
124
|
-
set text(text) {
|
|
125
|
-
this.m_props.text = text;
|
|
126
|
-
let label = this.itemWithRef('label');
|
|
127
|
-
if (label) {
|
|
128
|
-
label.text = text;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
get text() {
|
|
132
|
-
let label = this.itemWithRef('label');
|
|
133
|
-
return label?.text;
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* change the button icon
|
|
137
|
-
* todo: do nothing if no icon defined at startup
|
|
138
|
-
*
|
|
139
|
-
* @example
|
|
140
|
-
* ```ts
|
|
141
|
-
* let btn = new Button( {
|
|
142
|
-
* text: 'hello',
|
|
143
|
-
* icon: 'close'
|
|
144
|
-
* });
|
|
145
|
-
* btn.setIcon( 'open' );
|
|
146
|
-
* ```
|
|
147
|
-
*/
|
|
148
|
-
set icon(icon) {
|
|
149
|
-
this.m_props.icon = icon;
|
|
150
|
-
let ico = this.itemWithRef('l_icon');
|
|
151
|
-
if (ico) {
|
|
152
|
-
ico.icon = icon;
|
|
153
|
-
}
|
|
154
|
-
else {
|
|
155
|
-
this.update();
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
get icon() {
|
|
159
|
-
let ico = this.itemWithRef('l_icon');
|
|
160
|
-
return ico?.icon;
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* change the button right icon
|
|
164
|
-
* todo: do nothing if no icon defined at startup
|
|
165
|
-
*
|
|
166
|
-
* @example
|
|
167
|
-
* ```ts
|
|
168
|
-
* let btn = new Button( {
|
|
169
|
-
* text: 'hello',
|
|
170
|
-
* icon: 'close'
|
|
171
|
-
* });
|
|
172
|
-
* btn.setIcon( 'open' );
|
|
173
|
-
* ```
|
|
174
|
-
*/
|
|
175
|
-
set rightIcon(icon) {
|
|
176
|
-
this.m_props.rightIcon = icon;
|
|
177
|
-
let ico = this.itemWithRef('r_icon');
|
|
178
|
-
if (ico) {
|
|
179
|
-
ico.icon = icon;
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
get rightIcon() {
|
|
183
|
-
let ico = this.itemWithRef('l_icon');
|
|
184
|
-
return ico?.icon;
|
|
185
|
-
}
|
|
186
|
-
/**
|
|
187
|
-
*
|
|
188
|
-
*/
|
|
189
|
-
set menu(items) {
|
|
190
|
-
this.m_props.menu = items;
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
// :: BUTTON ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
|
194
|
-
/**
|
|
195
|
-
*
|
|
196
|
-
*/
|
|
197
|
-
export class Button extends BaseButton {
|
|
198
|
-
}
|
|
199
|
-
/**
|
|
200
|
-
*
|
|
201
|
-
*/
|
|
202
|
-
export class ToggleButton extends BaseButton {
|
|
203
|
-
constructor(props) {
|
|
204
|
-
super(props);
|
|
205
|
-
}
|
|
206
|
-
/**
|
|
207
|
-
*
|
|
208
|
-
*/
|
|
209
|
-
render(props) {
|
|
210
|
-
super.render(props);
|
|
211
|
-
if (props.checked) {
|
|
212
|
-
this.addClass('checked');
|
|
213
|
-
this._updateIcon();
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
/**
|
|
217
|
-
*
|
|
218
|
-
*/
|
|
219
|
-
_sendClick() {
|
|
220
|
-
super._sendClick();
|
|
221
|
-
this.m_props.checked = !this.m_props.checked;
|
|
222
|
-
this.setClass('checked', this.m_props.checked);
|
|
223
|
-
this.emit('change', EvChange(this.m_props.checked));
|
|
224
|
-
this._updateIcon();
|
|
225
|
-
}
|
|
226
|
-
_updateIcon() {
|
|
227
|
-
if (this.m_props.checkedIcon) {
|
|
228
|
-
const ic = this.m_props.checked ? this.m_props.checkedIcon : this.m_props.icon;
|
|
229
|
-
let ico = this.itemWithRef('l_icon');
|
|
230
|
-
if (ico) {
|
|
231
|
-
ico.icon = ic;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
}
|
package/lib/calendar.d.ts
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ___ ___ __
|
|
3
|
-
* \ \/ / / _
|
|
4
|
-
* \ / /_| |_
|
|
5
|
-
* / \____ _|
|
|
6
|
-
* /__/\__\ |_|
|
|
7
|
-
*
|
|
8
|
-
* @file calendar.ts
|
|
9
|
-
* @author Etienne Cochard
|
|
10
|
-
* @license
|
|
11
|
-
* Copyright (c) 2019-2021 R-libre ingenierie
|
|
12
|
-
*
|
|
13
|
-
* This program is free software; you can redistribute it and/or modify
|
|
14
|
-
* it under the terms of the GNU General Public License as published by
|
|
15
|
-
* the Free Software Foundation; either version 3 of the License, or
|
|
16
|
-
* (at your option) any later version.
|
|
17
|
-
*
|
|
18
|
-
* This program is distributed in the hope that it will be useful,
|
|
19
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
20
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
21
|
-
* GNU General Public License for more details.
|
|
22
|
-
*
|
|
23
|
-
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
24
|
-
**/
|
|
25
|
-
import { Popup } from './popup';
|
|
26
|
-
import { CProps, ContainerEventMap } from './component';
|
|
27
|
-
import { EvChange, EventCallback } from './x4_events';
|
|
28
|
-
import { VLayout } from './layout';
|
|
29
|
-
interface CalendarEventMap extends ContainerEventMap {
|
|
30
|
-
change?: EvChange;
|
|
31
|
-
}
|
|
32
|
-
interface CalendarProps extends CProps<CalendarEventMap> {
|
|
33
|
-
date?: Date;
|
|
34
|
-
minDate?: Date;
|
|
35
|
-
maxDate?: Date;
|
|
36
|
-
change?: EventCallback<EvChange>;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* default calendar control
|
|
40
|
-
*
|
|
41
|
-
* fires:
|
|
42
|
-
* EventChange ( value = Date )
|
|
43
|
-
*/
|
|
44
|
-
export declare class Calendar extends VLayout<CalendarProps, CalendarEventMap> {
|
|
45
|
-
private m_date;
|
|
46
|
-
constructor(props: CalendarProps);
|
|
47
|
-
/** @ignore */
|
|
48
|
-
render(props: CalendarProps): void;
|
|
49
|
-
/**
|
|
50
|
-
* select the given date
|
|
51
|
-
* @param date
|
|
52
|
-
*/
|
|
53
|
-
private select;
|
|
54
|
-
/**
|
|
55
|
-
*
|
|
56
|
-
*/
|
|
57
|
-
private _next;
|
|
58
|
-
/**
|
|
59
|
-
*
|
|
60
|
-
*/
|
|
61
|
-
private _choose;
|
|
62
|
-
get date(): Date;
|
|
63
|
-
set date(date: Date);
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* default popup calendar
|
|
67
|
-
*/
|
|
68
|
-
export declare class PopupCalendar extends Popup {
|
|
69
|
-
m_cal: Calendar;
|
|
70
|
-
constructor(props: CalendarProps);
|
|
71
|
-
private _handleClick;
|
|
72
|
-
/** @ignore */
|
|
73
|
-
show(modal?: boolean): void;
|
|
74
|
-
/** @ignore */
|
|
75
|
-
close(): void;
|
|
76
|
-
}
|
|
77
|
-
export {};
|