x4js 1.4.2
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/application.d.ts +95 -0
- package/lib/application.js +137 -0
- package/lib/base64.d.ts +31 -0
- package/lib/base64.js +135 -0
- package/lib/base_component.d.ts +64 -0
- package/lib/base_component.js +77 -0
- package/lib/button.d.ts +145 -0
- package/lib/button.js +235 -0
- package/lib/calendar.d.ts +77 -0
- package/lib/calendar.js +236 -0
- package/lib/canvas.d.ts +88 -0
- package/lib/canvas.js +354 -0
- package/lib/cardview.d.ts +83 -0
- package/lib/cardview.js +152 -0
- package/lib/checkbox.d.ts +72 -0
- package/lib/checkbox.js +126 -0
- package/lib/color.d.ts +144 -0
- package/lib/color.js +584 -0
- package/lib/colorpicker.d.ts +98 -0
- package/lib/colorpicker.js +1457 -0
- package/lib/combobox.d.ts +97 -0
- package/lib/combobox.js +246 -0
- package/lib/component.d.ts +572 -0
- package/lib/component.js +1712 -0
- package/lib/datastore.d.ts +392 -0
- package/lib/datastore.js +986 -0
- package/lib/dialog.d.ts +171 -0
- package/lib/dialog.js +468 -0
- package/lib/dom_events.d.ts +284 -0
- package/lib/dom_events.js +13 -0
- package/lib/drag_manager.d.ts +26 -0
- package/lib/drag_manager.js +118 -0
- package/lib/drawtext.d.ts +43 -0
- package/lib/drawtext.js +261 -0
- package/lib/fileupload.d.ts +60 -0
- package/lib/fileupload.js +158 -0
- package/lib/form.d.ts +122 -0
- package/lib/form.js +293 -0
- package/lib/formatters.d.ts +31 -0
- package/lib/formatters.js +75 -0
- package/lib/gridview.d.ts +171 -0
- package/lib/gridview.js +786 -0
- package/lib/hosts/host.d.ts +44 -0
- package/lib/hosts/host.js +69 -0
- package/lib/i18n.d.ts +67 -0
- package/lib/i18n.js +169 -0
- package/lib/icon.d.ts +56 -0
- package/lib/icon.js +173 -0
- package/lib/image.d.ts +51 -0
- package/lib/image.js +149 -0
- package/lib/index.js +1 -0
- package/lib/input.d.ts +86 -0
- package/lib/input.js +172 -0
- package/lib/label.d.ts +54 -0
- package/lib/label.js +86 -0
- package/lib/layout.d.ts +77 -0
- package/lib/layout.js +261 -0
- package/lib/link.d.ts +46 -0
- package/lib/link.js +55 -0
- package/lib/listview.d.ts +173 -0
- package/lib/listview.js +532 -0
- package/lib/md5.d.ts +56 -0
- package/lib/md5.js +397 -0
- package/lib/menu.d.ts +122 -0
- package/lib/menu.js +276 -0
- package/lib/messagebox.d.ts +64 -0
- package/lib/messagebox.js +141 -0
- package/lib/panel.d.ts +42 -0
- package/lib/panel.js +61 -0
- package/lib/popup.d.ts +71 -0
- package/lib/popup.js +373 -0
- package/lib/property_editor.d.ts +67 -0
- package/lib/property_editor.js +247 -0
- package/lib/radiobtn.d.ts +68 -0
- package/lib/radiobtn.js +131 -0
- package/lib/rating.d.ts +49 -0
- package/lib/rating.js +93 -0
- package/lib/request.d.ts +48 -0
- package/lib/request.js +220 -0
- package/lib/router.d.ts +13 -0
- package/lib/router.js +27 -0
- package/lib/settings.d.ts +33 -0
- package/lib/settings.js +63 -0
- package/lib/sidebarview.d.ts +44 -0
- package/lib/sidebarview.js +73 -0
- package/lib/smartedit.d.ts +103 -0
- package/lib/smartedit.js +381 -0
- package/lib/spreadsheet.d.ts +214 -0
- package/lib/spreadsheet.js +1073 -0
- package/lib/styles.d.ts +81 -0
- package/lib/styles.js +262 -0
- package/lib/svgcomponent.d.ts +165 -0
- package/lib/svgcomponent.js +350 -0
- package/lib/tabbar.d.ts +41 -0
- package/lib/tabbar.js +66 -0
- package/lib/tabview.d.ts +45 -0
- package/lib/tabview.js +79 -0
- package/lib/textarea.d.ts +59 -0
- package/lib/textarea.js +119 -0
- package/lib/textedit.d.ts +118 -0
- package/lib/textedit.js +406 -0
- package/lib/texthiliter.d.ts +56 -0
- package/lib/texthiliter.js +219 -0
- package/lib/toaster.d.ts +38 -0
- package/lib/toaster.js +58 -0
- package/lib/tools.d.ts +382 -0
- package/lib/tools.js +1096 -0
- package/lib/tooltips.d.ts +42 -0
- package/lib/tooltips.js +148 -0
- package/lib/treeview.d.ts +128 -0
- package/lib/treeview.js +490 -0
- package/lib/x4_events.d.ts +253 -0
- package/lib/x4_events.js +363 -0
- package/package.json +21 -0
- package/src/README.md +2 -0
- package/src/application.ts +191 -0
- package/src/base64.ts +162 -0
- package/src/base_component.ts +118 -0
- package/src/button.ts +327 -0
- package/src/calendar.ts +312 -0
- package/src/canvas.ts +501 -0
- package/src/cardview.ts +220 -0
- package/src/checkbox.ts +178 -0
- package/src/color.ts +748 -0
- package/src/colorpicker.ts +1618 -0
- package/src/combobox.ts +348 -0
- package/src/component.ts +2330 -0
- package/src/datastore.ts +1318 -0
- package/src/dialog.ts +631 -0
- package/src/dom_events.ts +297 -0
- package/src/drag_manager.ts +168 -0
- package/src/drawtext.ts +342 -0
- package/src/fileupload.ts +208 -0
- package/src/form.ts +362 -0
- package/src/formatters.ts +96 -0
- package/src/gridview.ts +1051 -0
- package/src/hosts/electron.ts +161 -0
- package/src/hosts/host.ts +100 -0
- package/src/hosts/nwjs.ts +141 -0
- package/src/hosts/nwjs_types.ts +339 -0
- package/src/i18n.ts +205 -0
- package/src/icon.ts +237 -0
- package/src/image.ts +198 -0
- package/src/input.ts +236 -0
- package/src/label.ts +124 -0
- package/src/layout.ts +366 -0
- package/src/link.ts +82 -0
- package/src/listview.ts +749 -0
- package/src/md5.ts +432 -0
- package/src/menu.ts +394 -0
- package/src/messagebox.ts +199 -0
- package/src/panel.ts +81 -0
- package/src/popup.ts +488 -0
- package/src/property_editor.ts +333 -0
- package/src/radiobtn.ts +190 -0
- package/src/rating.ts +131 -0
- package/src/request.ts +296 -0
- package/src/router.ts +43 -0
- package/src/settings.ts +75 -0
- package/src/sidebarview.ts +97 -0
- package/src/smartedit.ts +532 -0
- package/src/spreadsheet.ts +1423 -0
- package/src/styles.ts +332 -0
- package/src/svgcomponent.ts +440 -0
- package/src/tabbar.ts +105 -0
- package/src/tabview.ts +106 -0
- package/src/textarea.ts +183 -0
- package/src/textedit.ts +535 -0
- package/src/texthiliter.ts +284 -0
- package/src/toaster.ts +76 -0
- package/src/tools.ts +1391 -0
- package/src/tooltips.ts +185 -0
- package/src/treeview.ts +670 -0
- package/src/x4.less +1940 -0
- package/src/x4_events.ts +558 -0
- package/tsconfig.json +14 -0
package/lib/styles.d.ts
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ___ ___ __
|
|
3
|
+
* \ \_/ / / _
|
|
4
|
+
* \ / /_| |_
|
|
5
|
+
* / _ \____ _|
|
|
6
|
+
* /__/ \__\ |_|
|
|
7
|
+
*
|
|
8
|
+
* @file styles.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
|
+
/**
|
|
26
|
+
* -- [ @STYLESHEET ] -----------------------------------------------------------------
|
|
27
|
+
*/
|
|
28
|
+
export declare class Stylesheet {
|
|
29
|
+
private m_sheet;
|
|
30
|
+
private m_rules;
|
|
31
|
+
constructor();
|
|
32
|
+
/**
|
|
33
|
+
* add a new rule to the style sheet
|
|
34
|
+
* @param {string} name - internal rule name
|
|
35
|
+
* @param {string} definition - css definition of the rule
|
|
36
|
+
* @example
|
|
37
|
+
* setRule('xbody', "body { background-color: #ff0000; }" );
|
|
38
|
+
*/
|
|
39
|
+
setRule(name: string, definition: any): void;
|
|
40
|
+
/**
|
|
41
|
+
* return the style variable value
|
|
42
|
+
* @param name - variable name without '--'
|
|
43
|
+
* @example
|
|
44
|
+
* ```
|
|
45
|
+
* let color = Component.getCss( ).getVar( 'button-color' );
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
static getVar(name: string): any;
|
|
49
|
+
static guid: number;
|
|
50
|
+
static doc_style: CSSStyleDeclaration;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* -- [ @CSSPARSER ] -----------------------------------------------------------------
|
|
54
|
+
*
|
|
55
|
+
* adaptation of jss-for-node-js
|
|
56
|
+
*/
|
|
57
|
+
export declare class CSSParser {
|
|
58
|
+
private result;
|
|
59
|
+
parse(css: any): string;
|
|
60
|
+
static mk_string(rules: any): string;
|
|
61
|
+
private parse_json;
|
|
62
|
+
private makePropertyName;
|
|
63
|
+
private makeSelectorName;
|
|
64
|
+
addProperty(scope: string, property: string, value: any): void;
|
|
65
|
+
}
|
|
66
|
+
export declare class ComputedStyle {
|
|
67
|
+
m_style: CSSStyleDeclaration;
|
|
68
|
+
constructor(style: CSSStyleDeclaration);
|
|
69
|
+
/**
|
|
70
|
+
* return the raw value
|
|
71
|
+
*/
|
|
72
|
+
value(name: string): string;
|
|
73
|
+
/**
|
|
74
|
+
* return the interpreted value
|
|
75
|
+
*/
|
|
76
|
+
parse(name: string): number;
|
|
77
|
+
/**
|
|
78
|
+
*
|
|
79
|
+
*/
|
|
80
|
+
get style(): CSSStyleDeclaration;
|
|
81
|
+
}
|
package/lib/styles.js
ADDED
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ___ ___ __
|
|
3
|
+
* \ \_/ / / _
|
|
4
|
+
* \ / /_| |_
|
|
5
|
+
* / _ \____ _|
|
|
6
|
+
* /__/ \__\ |_|
|
|
7
|
+
*
|
|
8
|
+
* @file styles.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 { pascalCase, isString, isArray } from "./tools";
|
|
26
|
+
/**
|
|
27
|
+
* -- [ @STYLESHEET ] -----------------------------------------------------------------
|
|
28
|
+
*/
|
|
29
|
+
export class Stylesheet {
|
|
30
|
+
m_sheet;
|
|
31
|
+
m_rules = new Map();
|
|
32
|
+
constructor() {
|
|
33
|
+
function getStyleSheet(name) {
|
|
34
|
+
for (let i = 0; i < document.styleSheets.length; i++) {
|
|
35
|
+
let sheet = document.styleSheets[i];
|
|
36
|
+
if (sheet.title === name) {
|
|
37
|
+
return sheet;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
this.m_sheet = getStyleSheet('@dynamic-css');
|
|
42
|
+
if (!this.m_sheet) {
|
|
43
|
+
let dom = document.createElement('style');
|
|
44
|
+
dom.setAttribute('id', '@dynamic-css');
|
|
45
|
+
document.head.appendChild(dom);
|
|
46
|
+
this.m_sheet = dom.sheet;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* add a new rule to the style sheet
|
|
51
|
+
* @param {string} name - internal rule name
|
|
52
|
+
* @param {string} definition - css definition of the rule
|
|
53
|
+
* @example
|
|
54
|
+
* setRule('xbody', "body { background-color: #ff0000; }" );
|
|
55
|
+
*/
|
|
56
|
+
setRule(name, definition) {
|
|
57
|
+
if (isString(definition)) {
|
|
58
|
+
let index = this.m_rules.get(name);
|
|
59
|
+
if (index !== undefined) {
|
|
60
|
+
this.m_sheet.deleteRule(index);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
index = this.m_sheet.cssRules.length;
|
|
64
|
+
}
|
|
65
|
+
this.m_rules.set(name, this.m_sheet.insertRule(definition, index));
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
let idx = 1;
|
|
69
|
+
for (let r in definition) {
|
|
70
|
+
let rule = r + " { ", css = definition[r];
|
|
71
|
+
for (let i in css) {
|
|
72
|
+
let values = css[i]; // this is an array !
|
|
73
|
+
for (let j = 0; j < values.length; j++) {
|
|
74
|
+
rule += i + ": " + values[j] + "; ";
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
rule += '}';
|
|
78
|
+
console.log(rule);
|
|
79
|
+
this.setRule(name + '--' + idx, rule);
|
|
80
|
+
idx++;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* return the style variable value
|
|
86
|
+
* @param name - variable name without '--'
|
|
87
|
+
* @example
|
|
88
|
+
* ```
|
|
89
|
+
* let color = Component.getCss( ).getVar( 'button-color' );
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
static getVar(name) {
|
|
93
|
+
if (!Stylesheet.doc_style) {
|
|
94
|
+
Stylesheet.doc_style = getComputedStyle(document.documentElement);
|
|
95
|
+
}
|
|
96
|
+
return Stylesheet.doc_style.getPropertyValue('--' + name); // #999999
|
|
97
|
+
}
|
|
98
|
+
static guid = 1;
|
|
99
|
+
static doc_style;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* -- [ @CSSPARSER ] -----------------------------------------------------------------
|
|
103
|
+
*
|
|
104
|
+
* adaptation of jss-for-node-js
|
|
105
|
+
*/
|
|
106
|
+
export class CSSParser {
|
|
107
|
+
result = {};
|
|
108
|
+
parse(css) {
|
|
109
|
+
this.result = {};
|
|
110
|
+
this.parse_json('', css);
|
|
111
|
+
return CSSParser.mk_string(this.result);
|
|
112
|
+
}
|
|
113
|
+
static mk_string(rules) {
|
|
114
|
+
// output result:
|
|
115
|
+
let ret = '';
|
|
116
|
+
for (let a in rules) {
|
|
117
|
+
let css = rules[a];
|
|
118
|
+
ret += a + " { ";
|
|
119
|
+
for (let i in css) {
|
|
120
|
+
let values = css[i]; // this is an array !
|
|
121
|
+
for (let j = 0; j < values.length; j++) {
|
|
122
|
+
ret += i + ": " + values[j] + "; ";
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
ret += "}\n";
|
|
126
|
+
}
|
|
127
|
+
return ret;
|
|
128
|
+
}
|
|
129
|
+
parse_json(scope, css) {
|
|
130
|
+
if (scope && !this.result[scope]) {
|
|
131
|
+
this.result[scope] = {};
|
|
132
|
+
}
|
|
133
|
+
for (let property in css) {
|
|
134
|
+
let value = css[property];
|
|
135
|
+
if (isArray(value)) {
|
|
136
|
+
let values = value;
|
|
137
|
+
for (let i = 0; i < values.length; i++) {
|
|
138
|
+
this.addProperty(scope, property, values[i]);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
/*else if (value instanceof Color) {
|
|
142
|
+
this.addProperty(scope, property, value.toString());
|
|
143
|
+
}*/
|
|
144
|
+
else {
|
|
145
|
+
switch (typeof (value)) {
|
|
146
|
+
case "number": {
|
|
147
|
+
this.addProperty(scope, property, value);
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
case "string": {
|
|
151
|
+
this.addProperty(scope, property, value);
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
case "object": {
|
|
155
|
+
this.parse_json(this.makeSelectorName(scope, property), value);
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
default: {
|
|
159
|
+
console.error("ignoring unknown type " + typeof (value) + " in property " + property);
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
makePropertyName(n) {
|
|
167
|
+
return pascalCase(n);
|
|
168
|
+
}
|
|
169
|
+
makeSelectorName(scope, name) {
|
|
170
|
+
let snames = [];
|
|
171
|
+
let names = name.split(/\s*,\s*/);
|
|
172
|
+
let scopes = scope.split(/\s*,\s*/);
|
|
173
|
+
for (let s = 0; s < scopes.length; s++) {
|
|
174
|
+
let scope = scopes[s];
|
|
175
|
+
for (let i = 0; i < names.length; i++) {
|
|
176
|
+
let name = names[i], sub = false;
|
|
177
|
+
if (name.charAt(0) == "&") {
|
|
178
|
+
name = name.substr(1);
|
|
179
|
+
sub = true;
|
|
180
|
+
}
|
|
181
|
+
if (name.charAt(0) === '%') {
|
|
182
|
+
name = '.o-' + name.substr(1);
|
|
183
|
+
}
|
|
184
|
+
if (sub) {
|
|
185
|
+
snames.push(scope + name);
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
snames.push(scope ? scope + " " + name : name);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
return snames.join(", ");
|
|
193
|
+
}
|
|
194
|
+
addProperty(scope, property, value) {
|
|
195
|
+
let properties = property.split(/\s*,\s*/);
|
|
196
|
+
for (let i = 0; i < properties.length; i++) {
|
|
197
|
+
let property = this.makePropertyName(properties[i]);
|
|
198
|
+
if (this.result[scope][property]) {
|
|
199
|
+
this.result[scope][property].push(value);
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
this.result[scope][property] = [value];
|
|
203
|
+
}
|
|
204
|
+
let specials = {
|
|
205
|
+
"box-shadow": [
|
|
206
|
+
"-moz-box-shadow",
|
|
207
|
+
"-webkit-box-shadow"
|
|
208
|
+
],
|
|
209
|
+
"border-radius": [
|
|
210
|
+
"-moz-border-radius",
|
|
211
|
+
"-webkit-border-radius"
|
|
212
|
+
],
|
|
213
|
+
"border-radius-topleft": [
|
|
214
|
+
"-moz-border-radius-topleft",
|
|
215
|
+
"-webkit-border-top-left-radius"
|
|
216
|
+
],
|
|
217
|
+
"border-radius-topright": [
|
|
218
|
+
"-moz-border-radius-topright",
|
|
219
|
+
"-webkit-border-top-right-radius"
|
|
220
|
+
],
|
|
221
|
+
"border-radius-bottomleft": [
|
|
222
|
+
"-moz-border-radius-bottomleft",
|
|
223
|
+
"-webkit-border-bottom-left-radius"
|
|
224
|
+
],
|
|
225
|
+
"border-radius-bottomright": [
|
|
226
|
+
"-moz-border-radius-bottomright",
|
|
227
|
+
"-webkit-border-bottom-right-radius"
|
|
228
|
+
]
|
|
229
|
+
};
|
|
230
|
+
let browser_specials = specials[property];
|
|
231
|
+
for (let j = 0; browser_specials && j < browser_specials.length; j++) {
|
|
232
|
+
this.addProperty(scope, browser_specials[j], value);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
export class ComputedStyle {
|
|
238
|
+
m_style;
|
|
239
|
+
constructor(style) {
|
|
240
|
+
this.m_style = style;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* return the raw value
|
|
244
|
+
*/
|
|
245
|
+
value(name) {
|
|
246
|
+
name = pascalCase(name);
|
|
247
|
+
return this.m_style[name];
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* return the interpreted value
|
|
251
|
+
*/
|
|
252
|
+
parse(name) {
|
|
253
|
+
name = pascalCase(name);
|
|
254
|
+
return parseInt(this.m_style[name]);
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
*
|
|
258
|
+
*/
|
|
259
|
+
get style() {
|
|
260
|
+
return this.m_style;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ___ ___ __
|
|
3
|
+
* \ \_/ / / _
|
|
4
|
+
* \ / /_| |_
|
|
5
|
+
* / _ \____ _|
|
|
6
|
+
* /__/ \__\ |_|
|
|
7
|
+
*
|
|
8
|
+
* @file svgcomponent.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
|
+
/**
|
|
27
|
+
*
|
|
28
|
+
*/
|
|
29
|
+
declare abstract class SVGItem {
|
|
30
|
+
private m_tag;
|
|
31
|
+
private m_attrs;
|
|
32
|
+
constructor(tag: string);
|
|
33
|
+
/**
|
|
34
|
+
* render the item
|
|
35
|
+
* @returns
|
|
36
|
+
*/
|
|
37
|
+
render(): string;
|
|
38
|
+
/**
|
|
39
|
+
* change the stroke color
|
|
40
|
+
* @param color
|
|
41
|
+
*/
|
|
42
|
+
stroke(color: string): this;
|
|
43
|
+
/**
|
|
44
|
+
* change the stroke width
|
|
45
|
+
* @param width
|
|
46
|
+
*/
|
|
47
|
+
strokeWidth(width: number): this;
|
|
48
|
+
/**
|
|
49
|
+
* change the fill color
|
|
50
|
+
* @param color
|
|
51
|
+
*/
|
|
52
|
+
fill(color: string): this;
|
|
53
|
+
/**
|
|
54
|
+
* define a new attribute
|
|
55
|
+
* @param name attibute name
|
|
56
|
+
* @param value attribute value
|
|
57
|
+
* @returns this
|
|
58
|
+
*/
|
|
59
|
+
attr(name: string, value: string): this;
|
|
60
|
+
/**
|
|
61
|
+
* add a class
|
|
62
|
+
* @param name class name to add
|
|
63
|
+
*/
|
|
64
|
+
class(name: string): this;
|
|
65
|
+
/**
|
|
66
|
+
*
|
|
67
|
+
*/
|
|
68
|
+
renderAttrs(): string;
|
|
69
|
+
renderContent(): string;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
*
|
|
73
|
+
*/
|
|
74
|
+
declare class SVGPath extends SVGItem {
|
|
75
|
+
private m_path;
|
|
76
|
+
constructor();
|
|
77
|
+
renderAttrs(): string;
|
|
78
|
+
/**
|
|
79
|
+
* move the current pos
|
|
80
|
+
* @param x new pos x
|
|
81
|
+
* @param y new pos y
|
|
82
|
+
* @returns this
|
|
83
|
+
*/
|
|
84
|
+
moveTo(x: number, y: number): this;
|
|
85
|
+
/**
|
|
86
|
+
* draw aline to the given point
|
|
87
|
+
* @param x end x
|
|
88
|
+
* @param y end y
|
|
89
|
+
* @returns this
|
|
90
|
+
*/
|
|
91
|
+
lineTo(x: number, y: number): this;
|
|
92
|
+
/**
|
|
93
|
+
* close the currentPath
|
|
94
|
+
*/
|
|
95
|
+
closePath(): this;
|
|
96
|
+
/**
|
|
97
|
+
* draw an arc
|
|
98
|
+
* @param x center x
|
|
99
|
+
* @param y center y
|
|
100
|
+
* @param r radius
|
|
101
|
+
* @param start angle start in degrees
|
|
102
|
+
* @param end angle end in degrees
|
|
103
|
+
* @returns this
|
|
104
|
+
*/
|
|
105
|
+
arc(x: number, y: number, r: number, start: number, end: number): this;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
*
|
|
109
|
+
*/
|
|
110
|
+
declare class SVGText extends SVGItem {
|
|
111
|
+
private m_text;
|
|
112
|
+
constructor(x: number, y: number, txt: string);
|
|
113
|
+
font(font: string): this;
|
|
114
|
+
fontSize(size: number | string): this;
|
|
115
|
+
fontWeight(weight: 'light' | 'normal' | 'bold'): this;
|
|
116
|
+
textAlign(align: 'left' | 'center' | 'right'): this;
|
|
117
|
+
verticalAlign(align: 'top' | 'center' | 'bottom'): this;
|
|
118
|
+
renderContent(): any;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
*
|
|
122
|
+
*/
|
|
123
|
+
declare class SVGShape extends SVGItem {
|
|
124
|
+
constructor(tag: string);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
*
|
|
128
|
+
*/
|
|
129
|
+
declare class SVGGradient extends SVGItem {
|
|
130
|
+
private static g_id;
|
|
131
|
+
private m_id;
|
|
132
|
+
private m_stops;
|
|
133
|
+
constructor(x1: number, y1: number, x2: number, y2: number);
|
|
134
|
+
get id(): string;
|
|
135
|
+
addStop(offset: number, color: string): this;
|
|
136
|
+
renderContent(): string;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
*
|
|
140
|
+
*/
|
|
141
|
+
export declare class SVGPathBuilder {
|
|
142
|
+
private m_items;
|
|
143
|
+
constructor();
|
|
144
|
+
path(): SVGPath;
|
|
145
|
+
text(x: any, y: any, txt: any): SVGText;
|
|
146
|
+
ellipse(x: any, y: any, r1: any, r2?: any): SVGShape;
|
|
147
|
+
rect(x: any, y: any, w: any, h: any): SVGShape;
|
|
148
|
+
gradient(x1: any, y1: any, x2: any, y2: any): SVGGradient;
|
|
149
|
+
/**
|
|
150
|
+
* clear
|
|
151
|
+
*/
|
|
152
|
+
clear(): void;
|
|
153
|
+
render(): string;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
*
|
|
157
|
+
*/
|
|
158
|
+
export interface SVGProps extends CProps {
|
|
159
|
+
viewBox?: string;
|
|
160
|
+
path?: string;
|
|
161
|
+
}
|
|
162
|
+
export declare class SVGComponent<P extends SVGProps = SVGProps> extends Component<P> {
|
|
163
|
+
constructor(props: P);
|
|
164
|
+
}
|
|
165
|
+
export {};
|