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/icon.js
DELETED
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ___ ___ __
|
|
3
|
-
* \ \/ / / _
|
|
4
|
-
* \ / /_| |_
|
|
5
|
-
* / \____ _|
|
|
6
|
-
* /__/\__\ |_|
|
|
7
|
-
*
|
|
8
|
-
* @file icon.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 { Stylesheet } from './styles';
|
|
27
|
-
import { HtmlString } from './tools';
|
|
28
|
-
import { BasicEvent, EventSource } from './x4_events';
|
|
29
|
-
export function EvLoaded(url, svg, context = null) {
|
|
30
|
-
return BasicEvent({ url, svg, context });
|
|
31
|
-
}
|
|
32
|
-
class Loader extends EventSource {
|
|
33
|
-
svgs;
|
|
34
|
-
constructor() {
|
|
35
|
-
super();
|
|
36
|
-
this.svgs = new Map();
|
|
37
|
-
}
|
|
38
|
-
load(url) {
|
|
39
|
-
if (this.svgs.has(url)) {
|
|
40
|
-
const svg = this.svgs.get(url);
|
|
41
|
-
if (svg) {
|
|
42
|
-
//console.log( 'cached=', url );
|
|
43
|
-
this.signal('loaded', EvLoaded(url, svg));
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
// mark it as loading
|
|
48
|
-
this.svgs.set(url, null);
|
|
49
|
-
// then start loading
|
|
50
|
-
const _load = async (url) => {
|
|
51
|
-
const r = await fetch(url);
|
|
52
|
-
if (r.ok) {
|
|
53
|
-
const svg = await r.text();
|
|
54
|
-
this.svgs.set(url, svg);
|
|
55
|
-
//console.log( 'signal=', url );
|
|
56
|
-
this.signal('loaded', EvLoaded(url, svg));
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
_load(url);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
const svgLoader = new Loader();
|
|
64
|
-
/**
|
|
65
|
-
* standard icon
|
|
66
|
-
*/
|
|
67
|
-
export class Icon extends Component {
|
|
68
|
-
m_icon;
|
|
69
|
-
m_iconName;
|
|
70
|
-
constructor(props) {
|
|
71
|
-
super(props);
|
|
72
|
-
this._setIcon(props.icon, false);
|
|
73
|
-
if (props.size) {
|
|
74
|
-
this.setStyleValue('fontSize', props.size);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
_setIcon(icon, remove_old) {
|
|
78
|
-
const reUrl = /\s*url\s*\(\s*(.+)\s*\)\s*/gi;
|
|
79
|
-
const reSvg = /\s*svg\s*\(\s*(.+)\s*\)\s*/gi;
|
|
80
|
-
const reSvg2 = /(.*\.svg)$/gi;
|
|
81
|
-
const reCls = /\s*cls\s*\(\s*(.+)\s*\)\s*/gi;
|
|
82
|
-
if (!icon) {
|
|
83
|
-
this.m_iconName = '';
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
this.removeClass('@svg');
|
|
87
|
-
let name, url;
|
|
88
|
-
if (typeof (icon) === 'number') {
|
|
89
|
-
icon = icon.toString(16);
|
|
90
|
-
name = icon;
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
let match_svg = reSvg.exec(icon) || reSvg2.exec(icon);
|
|
94
|
-
if (match_svg) {
|
|
95
|
-
const url = match_svg[1].trim();
|
|
96
|
-
this._setSVG(url);
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
let match_cls = reCls.exec(icon);
|
|
100
|
-
if (match_cls) {
|
|
101
|
-
const classes = match_cls[1].trim();
|
|
102
|
-
this.addClass(classes);
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
let match_url = reUrl.exec(icon);
|
|
106
|
-
if (match_url) {
|
|
107
|
-
url = match_url[1].trim();
|
|
108
|
-
name = url.replace(/[/\\\.\* ]/g, '_');
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
name = icon;
|
|
112
|
-
icon = Stylesheet.getVar('icon-' + icon);
|
|
113
|
-
if (icon == '' || icon === undefined) {
|
|
114
|
-
// name your icon 'icon-xxx'
|
|
115
|
-
// ex:
|
|
116
|
-
// :root { --icon-zoom-p: f00e; }
|
|
117
|
-
console.assert(false);
|
|
118
|
-
icon = '0';
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
this.m_iconName = name;
|
|
123
|
-
if (this.m_icon === icon) {
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
let css = Component.getCss(), rulename;
|
|
127
|
-
if (remove_old && this.m_icon) {
|
|
128
|
-
rulename = 'icon-' + name;
|
|
129
|
-
this.removeClass(rulename);
|
|
130
|
-
}
|
|
131
|
-
// generate dynamic css icon rule
|
|
132
|
-
rulename = 'icon-' + name;
|
|
133
|
-
if (Icon.icon_cache[rulename] === undefined) {
|
|
134
|
-
Icon.icon_cache[rulename] = true;
|
|
135
|
-
let rule;
|
|
136
|
-
if (url) {
|
|
137
|
-
rule = `display: block; content: ' '; background-image: url(${url}); background-size: contain; width: 100%; height: 100%; background-repeat: no-repeat; color: white;`;
|
|
138
|
-
}
|
|
139
|
-
else {
|
|
140
|
-
rule = `content: "\\${icon}";`;
|
|
141
|
-
}
|
|
142
|
-
css.setRule(rulename, `.${rulename}::before {${rule}}`);
|
|
143
|
-
}
|
|
144
|
-
this.addClass(rulename);
|
|
145
|
-
this.m_icon = icon;
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* change the icon
|
|
149
|
-
* @param icon - new icon
|
|
150
|
-
*/
|
|
151
|
-
set icon(icon) {
|
|
152
|
-
this._setIcon(icon, true);
|
|
153
|
-
}
|
|
154
|
-
get icon() {
|
|
155
|
-
return this.m_iconName;
|
|
156
|
-
}
|
|
157
|
-
_setSVG(url) {
|
|
158
|
-
const set = (ev) => {
|
|
159
|
-
//console.log( 'set=', ev.url, 'url=', url );
|
|
160
|
-
if (ev.url == url) {
|
|
161
|
-
this.addClass('@svg-icon');
|
|
162
|
-
this.setContent(HtmlString.from(ev.svg), false);
|
|
163
|
-
svgLoader.off('loaded', set);
|
|
164
|
-
}
|
|
165
|
-
};
|
|
166
|
-
svgLoader.on('loaded', set);
|
|
167
|
-
svgLoader.load(url);
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
*
|
|
171
|
-
*/
|
|
172
|
-
static icon_cache = [];
|
|
173
|
-
}
|
package/lib/input.d.ts
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ___ ___ __
|
|
3
|
-
* \ \/ / / _
|
|
4
|
-
* \ / /_| |_
|
|
5
|
-
* / \____ _|
|
|
6
|
-
* /__/\__\ |_|
|
|
7
|
-
*
|
|
8
|
-
* @file input.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 } from './component';
|
|
26
|
-
export declare type EditType = 'text' | 'number' | 'email' | 'date' | 'password' | 'file' | 'checkbox' | 'radio';
|
|
27
|
-
export interface ValueHook {
|
|
28
|
-
get(): any;
|
|
29
|
-
set(v: any): void;
|
|
30
|
-
}
|
|
31
|
-
export interface InputEventMap extends CEventMap {
|
|
32
|
-
}
|
|
33
|
-
export interface InputProps<P extends InputEventMap = InputEventMap> extends CProps<P> {
|
|
34
|
-
value?: string;
|
|
35
|
-
name?: string;
|
|
36
|
-
type?: EditType;
|
|
37
|
-
placeHolder?: string;
|
|
38
|
-
autoFocus?: boolean;
|
|
39
|
-
readOnly?: boolean;
|
|
40
|
-
tabIndex?: number | boolean;
|
|
41
|
-
pattern?: string;
|
|
42
|
-
uppercase?: boolean;
|
|
43
|
-
spellcheck?: boolean;
|
|
44
|
-
value_hook?: ValueHook;
|
|
45
|
-
min?: number;
|
|
46
|
-
max?: number;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* base class for elements implementing an input
|
|
50
|
-
* CARE derived classes must set this.ui.input
|
|
51
|
-
*/
|
|
52
|
-
export declare class Input extends Component<InputProps, InputEventMap> {
|
|
53
|
-
constructor(props: InputProps);
|
|
54
|
-
/** @ignore */
|
|
55
|
-
render(props: InputProps): void;
|
|
56
|
-
getType(): EditType;
|
|
57
|
-
/**
|
|
58
|
-
* return the current editor value
|
|
59
|
-
*/
|
|
60
|
-
get value(): string;
|
|
61
|
-
/**
|
|
62
|
-
* Change the editor value
|
|
63
|
-
* @param value - new value to set
|
|
64
|
-
*/
|
|
65
|
-
set value(value: string);
|
|
66
|
-
getStoreValue(): any;
|
|
67
|
-
setStoreValue(v: any): void;
|
|
68
|
-
set readOnly(ro: boolean);
|
|
69
|
-
/**
|
|
70
|
-
* select all the text
|
|
71
|
-
*/
|
|
72
|
-
selectAll(): void;
|
|
73
|
-
/**
|
|
74
|
-
* select a part of the text
|
|
75
|
-
* @param start
|
|
76
|
-
* @param length
|
|
77
|
-
*/
|
|
78
|
-
select(start: number, length?: number): void;
|
|
79
|
-
/**
|
|
80
|
-
* get the selection as { start, length }
|
|
81
|
-
*/
|
|
82
|
-
getSelection(): {
|
|
83
|
-
start: number;
|
|
84
|
-
length: number;
|
|
85
|
-
};
|
|
86
|
-
}
|
package/lib/input.js
DELETED
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ___ ___ __
|
|
3
|
-
* \ \/ / / _
|
|
4
|
-
* \ / /_| |_
|
|
5
|
-
* / \____ _|
|
|
6
|
-
* /__/\__\ |_|
|
|
7
|
-
*
|
|
8
|
-
* @file input.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
|
-
/**
|
|
27
|
-
* base class for elements implementing an input
|
|
28
|
-
* CARE derived classes must set this.ui.input
|
|
29
|
-
*/
|
|
30
|
-
export class Input extends Component {
|
|
31
|
-
constructor(props) {
|
|
32
|
-
super(props);
|
|
33
|
-
}
|
|
34
|
-
/** @ignore */
|
|
35
|
-
render(props) {
|
|
36
|
-
this.setProp('tag', 'input');
|
|
37
|
-
this._setTabIndex(props.tabIndex);
|
|
38
|
-
this.setAttributes({
|
|
39
|
-
value: props.value,
|
|
40
|
-
type: props.type || 'text',
|
|
41
|
-
name: props.name,
|
|
42
|
-
placeholder: props.placeHolder,
|
|
43
|
-
autofocus: props.autoFocus,
|
|
44
|
-
readonly: props.readOnly,
|
|
45
|
-
autocomplete: 'new-password',
|
|
46
|
-
tabindex: props.tabIndex,
|
|
47
|
-
spellcheck: props.spellcheck === false ? 'false' : undefined,
|
|
48
|
-
min: props.min,
|
|
49
|
-
max: props.max,
|
|
50
|
-
...props.attrs
|
|
51
|
-
});
|
|
52
|
-
if (props.uppercase) {
|
|
53
|
-
this.setStyleValue('textTransform', 'uppercase');
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
getType() {
|
|
57
|
-
return this.m_props.type;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* return the current editor value
|
|
61
|
-
*/
|
|
62
|
-
get value() {
|
|
63
|
-
if (this.dom) {
|
|
64
|
-
this.m_props.value = this.dom.value;
|
|
65
|
-
}
|
|
66
|
-
if (this.m_props.uppercase) {
|
|
67
|
-
let upper = this.m_props.value.toUpperCase(); // todo: locale ?
|
|
68
|
-
if (this.dom && upper != this.m_props.value) {
|
|
69
|
-
this.dom.value = upper; // update the input
|
|
70
|
-
}
|
|
71
|
-
this.m_props.value = upper;
|
|
72
|
-
}
|
|
73
|
-
return this.m_props.value;
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Change the editor value
|
|
77
|
-
* @param value - new value to set
|
|
78
|
-
*/
|
|
79
|
-
set value(value) {
|
|
80
|
-
this.m_props.value = value;
|
|
81
|
-
if (this.dom) {
|
|
82
|
-
this.dom.value = value;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
getStoreValue() {
|
|
86
|
-
if (this.m_props.value_hook) {
|
|
87
|
-
return this.m_props.value_hook.get();
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
let type = this.getAttribute('type');
|
|
91
|
-
if (type) {
|
|
92
|
-
type = type.toLowerCase();
|
|
93
|
-
}
|
|
94
|
-
let value, dom = this.dom;
|
|
95
|
-
if (type === "file") {
|
|
96
|
-
value = [];
|
|
97
|
-
let files = dom.files;
|
|
98
|
-
for (let file = 0; file < files.length; file++) {
|
|
99
|
-
value.push(files[file].name);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
else if (type === 'checkbox') {
|
|
103
|
-
if (dom.checked) {
|
|
104
|
-
value = 1;
|
|
105
|
-
}
|
|
106
|
-
else {
|
|
107
|
-
value = 0;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
else if (type === 'radio') {
|
|
111
|
-
if (dom.checked) {
|
|
112
|
-
value = this.value;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
else if (type === 'date') {
|
|
116
|
-
debugger;
|
|
117
|
-
}
|
|
118
|
-
else {
|
|
119
|
-
value = this.value;
|
|
120
|
-
}
|
|
121
|
-
return value;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
setStoreValue(v) {
|
|
125
|
-
if (this.m_props.value_hook) {
|
|
126
|
-
return this.m_props.value_hook.set(v);
|
|
127
|
-
}
|
|
128
|
-
else {
|
|
129
|
-
let type = this.getAttribute('type'), dom = this.dom;
|
|
130
|
-
if (type) {
|
|
131
|
-
type = type.toLowerCase();
|
|
132
|
-
}
|
|
133
|
-
if (type === 'checkbox') {
|
|
134
|
-
let newval = v !== null && v !== '0' && v !== 0 && v !== false;
|
|
135
|
-
if (newval !== dom.checked) {
|
|
136
|
-
dom.setAttribute('checked', '' + newval);
|
|
137
|
-
dom.dispatchEvent(new Event('change'));
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
else {
|
|
141
|
-
this.value = v;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
set readOnly(ro) {
|
|
146
|
-
this.setAttribute('readonly', ro);
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* select all the text
|
|
150
|
-
*/
|
|
151
|
-
selectAll() {
|
|
152
|
-
this.dom.select();
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* select a part of the text
|
|
156
|
-
* @param start
|
|
157
|
-
* @param length
|
|
158
|
-
*/
|
|
159
|
-
select(start, length = 9999) {
|
|
160
|
-
this.dom.setSelectionRange(start, start + length);
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* get the selection as { start, length }
|
|
164
|
-
*/
|
|
165
|
-
getSelection() {
|
|
166
|
-
let idom = this.dom;
|
|
167
|
-
return {
|
|
168
|
-
start: idom.selectionStart,
|
|
169
|
-
length: idom.selectionEnd - idom.selectionStart,
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
}
|
package/lib/label.d.ts
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ___ ___ __
|
|
3
|
-
* \ \/ / / _
|
|
4
|
-
* \ / /_| |_
|
|
5
|
-
* / \____ _|
|
|
6
|
-
* /__/\__\ |_|
|
|
7
|
-
*
|
|
8
|
-
* @file label.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 } from './component';
|
|
26
|
-
import { HtmlString } from './tools';
|
|
27
|
-
import { IconID } from './icon';
|
|
28
|
-
export interface LabelProps extends CProps {
|
|
29
|
-
text: string | HtmlString;
|
|
30
|
-
icon?: IconID;
|
|
31
|
-
align?: 'left' | 'right' | 'center';
|
|
32
|
-
multiline?: boolean;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Standard label
|
|
36
|
-
*/
|
|
37
|
-
export declare class Label extends Component<LabelProps> {
|
|
38
|
-
/**
|
|
39
|
-
* double constructor, from string/html or as usual
|
|
40
|
-
*/
|
|
41
|
-
constructor(props: LabelProps);
|
|
42
|
-
constructor(text: string | HtmlString);
|
|
43
|
-
/** @ignore */
|
|
44
|
-
render(props: LabelProps): void;
|
|
45
|
-
/**
|
|
46
|
-
* change the displayed text
|
|
47
|
-
* @param text - new text
|
|
48
|
-
*/
|
|
49
|
-
set text(txt: string | HtmlString);
|
|
50
|
-
/**
|
|
51
|
-
*
|
|
52
|
-
*/
|
|
53
|
-
get text(): string | HtmlString;
|
|
54
|
-
}
|
package/lib/label.js
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ___ ___ __
|
|
3
|
-
* \ \/ / / _
|
|
4
|
-
* \ / /_| |_
|
|
5
|
-
* / \____ _|
|
|
6
|
-
* /__/\__\ |_|
|
|
7
|
-
*
|
|
8
|
-
* @file label.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 { HtmlString } from './tools';
|
|
27
|
-
import { Icon } from './icon';
|
|
28
|
-
/**
|
|
29
|
-
* Standard label
|
|
30
|
-
*/
|
|
31
|
-
export class Label extends Component {
|
|
32
|
-
constructor(param) {
|
|
33
|
-
if (typeof (param) === 'string' || param instanceof HtmlString) {
|
|
34
|
-
super({ text: param });
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
super(param);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
/** @ignore */
|
|
41
|
-
render(props) {
|
|
42
|
-
let text = this.m_props.text;
|
|
43
|
-
if (this.m_props.multiline && !(text instanceof HtmlString)) {
|
|
44
|
-
text = new HtmlString(text.replace(/\n/g, '<br/>'));
|
|
45
|
-
}
|
|
46
|
-
if (!props.icon) {
|
|
47
|
-
this.setContent(text);
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
this.setProp('tag', 'span');
|
|
51
|
-
this.addClass('@hlayout');
|
|
52
|
-
this.setContent([
|
|
53
|
-
new Icon({ icon: props.icon }),
|
|
54
|
-
new Component({ content: text, ref: 'text' })
|
|
55
|
-
]);
|
|
56
|
-
}
|
|
57
|
-
this.addClass(props.align ?? 'left');
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* change the displayed text
|
|
61
|
-
* @param text - new text
|
|
62
|
-
*/
|
|
63
|
-
set text(txt) {
|
|
64
|
-
let props = this.m_props;
|
|
65
|
-
if (props.text !== txt) {
|
|
66
|
-
props.text = txt;
|
|
67
|
-
let text = this.m_props.text;
|
|
68
|
-
if (this.m_props.multiline && !(text instanceof HtmlString)) {
|
|
69
|
-
text = new HtmlString(text.replace('/\n/g', '<br/>'));
|
|
70
|
-
}
|
|
71
|
-
if (this.dom) {
|
|
72
|
-
let comp = this;
|
|
73
|
-
if (this.m_props.icon) {
|
|
74
|
-
comp = this.itemWithRef('text');
|
|
75
|
-
}
|
|
76
|
-
comp.setContent(text);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
*
|
|
82
|
-
*/
|
|
83
|
-
get text() {
|
|
84
|
-
return this.m_props.text;
|
|
85
|
-
}
|
|
86
|
-
}
|
package/lib/layout.d.ts
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ___ ___ __
|
|
3
|
-
* \ \/ / / _
|
|
4
|
-
* \ / /_| |_
|
|
5
|
-
* / \____ _|
|
|
6
|
-
* /__/\__\ |_|
|
|
7
|
-
*
|
|
8
|
-
* @file layout.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, ComponentContent, Container, ContainerProps, ContainerEventMap } from './component';
|
|
26
|
-
export declare class AbsLayout<P extends ContainerProps = ContainerProps, E extends ContainerEventMap = ContainerEventMap> extends Container<P, E> {
|
|
27
|
-
}
|
|
28
|
-
export declare class HLayout<P extends ContainerProps = ContainerProps, E extends ContainerEventMap = ContainerEventMap> extends Container<P, E> {
|
|
29
|
-
}
|
|
30
|
-
export declare class VLayout<P extends ContainerProps = ContainerProps, E extends ContainerEventMap = ContainerEventMap> extends Container<P, E> {
|
|
31
|
-
}
|
|
32
|
-
interface AutoLayoutProps extends CProps {
|
|
33
|
-
defaultLayout: 'horizontal' | 'vertical';
|
|
34
|
-
switchSize: number;
|
|
35
|
-
}
|
|
36
|
-
export declare class AutoLayout extends Container<AutoLayoutProps> {
|
|
37
|
-
constructor(props: AutoLayoutProps);
|
|
38
|
-
componentCreated(): void;
|
|
39
|
-
private _updateLayout;
|
|
40
|
-
}
|
|
41
|
-
export interface GridLayoutProps extends ContainerProps {
|
|
42
|
-
colSizes?: string;
|
|
43
|
-
rowSizes?: string;
|
|
44
|
-
colGap?: number;
|
|
45
|
-
template?: string[];
|
|
46
|
-
}
|
|
47
|
-
export declare class GridLayout<P extends GridLayoutProps = GridLayoutProps> extends Container<P> {
|
|
48
|
-
constructor(props: GridLayoutProps);
|
|
49
|
-
/** @ignore */
|
|
50
|
-
render(): void;
|
|
51
|
-
}
|
|
52
|
-
export interface TableLayoutProps extends CProps {
|
|
53
|
-
rows: number;
|
|
54
|
-
columns: number;
|
|
55
|
-
}
|
|
56
|
-
export declare class TableLayout extends Container<TableLayoutProps> {
|
|
57
|
-
private m_cells;
|
|
58
|
-
constructor(props: TableLayoutProps);
|
|
59
|
-
private _getCell;
|
|
60
|
-
private _setCell;
|
|
61
|
-
setCell(row: number, col: number, item: ComponentContent): void;
|
|
62
|
-
merge(row: number, col: number, rowCount: number, colCount: number): void;
|
|
63
|
-
setCellWidth(row: number, col: number, width?: number): void;
|
|
64
|
-
setCellHeight(row: number, col: number, height?: number): void;
|
|
65
|
-
setCellClass(row: number, col: number, cls: string): void;
|
|
66
|
-
setColClass(col: any, cls: any): void;
|
|
67
|
-
setRowClass(row: any, cls: any): void;
|
|
68
|
-
getCell(row: any, col: any): ComponentContent;
|
|
69
|
-
render(): void;
|
|
70
|
-
}
|
|
71
|
-
interface ScrollViewProps extends CProps {
|
|
72
|
-
}
|
|
73
|
-
export declare class ScrollView extends Component<ScrollViewProps> {
|
|
74
|
-
constructor(props: ScrollViewProps);
|
|
75
|
-
setContent(content: ComponentContent): void;
|
|
76
|
-
}
|
|
77
|
-
export {};
|