x4js 1.5.17 → 1.5.20
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/{README.md → README.txt} +0 -0
- package/lib/cjs/index.js +39 -103
- package/lib/cjs/index.js.map +7 -0
- package/lib/esm/index.mjs +39 -87
- package/lib/esm/index.mjs.map +7 -0
- package/lib/{license.md → licence.md} +0 -0
- package/lib/src/MIT-license.md +14 -0
- package/lib/{types/action.d.ts → src/action.ts} +64 -33
- package/lib/src/alpha.jpg +0 -0
- package/lib/src/app_sockets.ts +81 -0
- package/lib/src/application.ts +251 -0
- package/lib/src/autocomplete.ts +197 -0
- package/lib/src/base64.ts +166 -0
- package/lib/src/base_component.ts +152 -0
- package/lib/src/button.ts +355 -0
- package/lib/src/calendar.ts +328 -0
- package/lib/src/canvas.ts +505 -0
- package/lib/src/cardview.ts +227 -0
- package/lib/src/checkbox.ts +188 -0
- package/lib/src/color.ts +752 -0
- package/lib/src/colorpicker.ts +1639 -0
- package/lib/src/combobox.ts +465 -0
- package/lib/src/component.ts +2329 -0
- package/lib/{esm/dom_events.js → src/copyright.txt} +27 -29
- package/lib/src/datastore.ts +1322 -0
- package/lib/src/dialog.ts +656 -0
- package/lib/src/dom_events.ts +315 -0
- package/lib/src/drag_manager.ts +199 -0
- package/lib/src/drawtext.ts +355 -0
- package/lib/src/fileupload.ts +213 -0
- package/lib/src/form.ts +375 -0
- package/lib/src/formatters.ts +105 -0
- package/lib/src/gridview.ts +1185 -0
- package/lib/src/i18n.ts +346 -0
- package/lib/src/icon.ts +335 -0
- package/lib/src/image.ts +204 -0
- package/lib/src/index.ts +89 -0
- package/lib/src/input.ts +249 -0
- package/lib/src/label.ts +128 -0
- package/lib/src/layout.ts +430 -0
- package/lib/src/link.ts +86 -0
- package/lib/src/listview.ts +765 -0
- package/lib/{esm/md5.js → src/md5.ts} +438 -403
- package/lib/src/menu.ts +425 -0
- package/lib/src/messagebox.ts +224 -0
- package/lib/src/panel.ts +86 -0
- package/lib/src/popup.ts +494 -0
- package/lib/src/property_editor.ts +337 -0
- package/lib/src/radiobtn.ts +197 -0
- package/lib/src/rating.ts +135 -0
- package/lib/src/request.ts +300 -0
- package/lib/src/router.ts +185 -0
- package/lib/src/settings.ts +77 -0
- package/lib/src/sidebarview.ts +103 -0
- package/lib/src/spreadsheet.ts +1449 -0
- package/lib/src/styles.ts +343 -0
- package/lib/src/svgcomponent.ts +577 -0
- package/lib/src/tabbar.ts +151 -0
- package/lib/src/tabview.ts +110 -0
- package/lib/src/textarea.ts +235 -0
- package/lib/src/textedit.ts +544 -0
- package/lib/src/toaster.ts +80 -0
- package/lib/src/tools.ts +1473 -0
- package/lib/src/tooltips.ts +191 -0
- package/lib/src/treeview.ts +716 -0
- package/lib/{esm/version.js → src/version.ts} +30 -29
- package/lib/{styles → src}/x4.less +0 -0
- package/lib/src/x4dom.ts +57 -0
- package/lib/src/x4events.ts +585 -0
- package/lib/src/x4react.ts +90 -0
- package/package.json +52 -49
- package/lib/cjs/action.js +0 -58
- package/lib/cjs/app_sockets.js +0 -74
- package/lib/cjs/application.js +0 -182
- package/lib/cjs/autocomplete.js +0 -155
- package/lib/cjs/base_component.js +0 -124
- package/lib/cjs/button.js +0 -263
- package/lib/cjs/calendar.js +0 -254
- package/lib/cjs/canvas.js +0 -361
- package/lib/cjs/cardview.js +0 -161
- package/lib/cjs/checkbox.js +0 -139
- package/lib/cjs/color.js +0 -591
- package/lib/cjs/colorpicker.js +0 -1468
- package/lib/cjs/combobox.js +0 -349
- package/lib/cjs/component.js +0 -1719
- package/lib/cjs/datastore.js +0 -985
- package/lib/cjs/dialog.js +0 -478
- package/lib/cjs/dom_events.js +0 -30
- package/lib/cjs/drag_manager.js +0 -145
- package/lib/cjs/drawtext.js +0 -276
- package/lib/cjs/fileupload.js +0 -167
- package/lib/cjs/form.js +0 -304
- package/lib/cjs/formatters.js +0 -90
- package/lib/cjs/gridview.js +0 -881
- package/lib/cjs/i18n.js +0 -266
- package/lib/cjs/icon.js +0 -272
- package/lib/cjs/image.js +0 -157
- package/lib/cjs/input.js +0 -174
- package/lib/cjs/label.js +0 -95
- package/lib/cjs/layout.js +0 -322
- package/lib/cjs/link.js +0 -64
- package/lib/cjs/listview.js +0 -546
- package/lib/cjs/md5.js +0 -403
- package/lib/cjs/menu.js +0 -301
- package/lib/cjs/messagebox.js +0 -177
- package/lib/cjs/panel.js +0 -68
- package/lib/cjs/popup.js +0 -383
- package/lib/cjs/property_editor.js +0 -252
- package/lib/cjs/radiobtn.js +0 -140
- package/lib/cjs/rating.js +0 -102
- package/lib/cjs/request.js +0 -246
- package/lib/cjs/router.js +0 -139
- package/lib/cjs/settings.js +0 -69
- package/lib/cjs/sidebarview.js +0 -82
- package/lib/cjs/spreadsheet.js +0 -1084
- package/lib/cjs/styles.js +0 -275
- package/lib/cjs/svgcomponent.js +0 -447
- package/lib/cjs/tabbar.js +0 -111
- package/lib/cjs/tabview.js +0 -85
- package/lib/cjs/textarea.js +0 -165
- package/lib/cjs/textedit.js +0 -415
- package/lib/cjs/toaster.js +0 -64
- package/lib/cjs/tools.js +0 -1197
- package/lib/cjs/tooltips.js +0 -157
- package/lib/cjs/treeview.js +0 -535
- package/lib/cjs/version.js +0 -32
- package/lib/cjs/x4dom.js +0 -32
- package/lib/cjs/x4events.js +0 -384
- package/lib/cjs/x4react.js +0 -72
- package/lib/esm/action.js +0 -53
- package/lib/esm/app_sockets.js +0 -70
- package/lib/esm/application.js +0 -184
- package/lib/esm/autocomplete.js +0 -155
- package/lib/esm/base_component.js +0 -107
- package/lib/esm/button.js +0 -257
- package/lib/esm/calendar.js +0 -249
- package/lib/esm/canvas.js +0 -358
- package/lib/esm/cardview.js +0 -159
- package/lib/esm/checkbox.js +0 -134
- package/lib/esm/color.js +0 -588
- package/lib/esm/colorpicker.js +0 -1475
- package/lib/esm/combobox.js +0 -351
- package/lib/esm/component.js +0 -1711
- package/lib/esm/datastore.js +0 -990
- package/lib/esm/dialog.js +0 -490
- package/lib/esm/drag_manager.js +0 -147
- package/lib/esm/drawtext.js +0 -271
- package/lib/esm/fileupload.js +0 -163
- package/lib/esm/form.js +0 -304
- package/lib/esm/formatters.js +0 -81
- package/lib/esm/gridview.js +0 -889
- package/lib/esm/i18n.js +0 -257
- package/lib/esm/icon.js +0 -261
- package/lib/esm/image.js +0 -154
- package/lib/esm/input.js +0 -182
- package/lib/esm/label.js +0 -90
- package/lib/esm/layout.js +0 -310
- package/lib/esm/link.js +0 -59
- package/lib/esm/listview.js +0 -534
- package/lib/esm/menu.js +0 -300
- package/lib/esm/messagebox.js +0 -161
- package/lib/esm/panel.js +0 -65
- package/lib/esm/popup.js +0 -379
- package/lib/esm/property_editor.js +0 -251
- package/lib/esm/radiobtn.js +0 -136
- package/lib/esm/rating.js +0 -97
- package/lib/esm/request.js +0 -224
- package/lib/esm/router.js +0 -136
- package/lib/esm/settings.js +0 -66
- package/lib/esm/sidebarview.js +0 -79
- package/lib/esm/spreadsheet.js +0 -1097
- package/lib/esm/styles.js +0 -270
- package/lib/esm/svgcomponent.js +0 -450
- package/lib/esm/tabbar.js +0 -107
- package/lib/esm/tabview.js +0 -83
- package/lib/esm/textarea.js +0 -160
- package/lib/esm/textedit.js +0 -412
- package/lib/esm/toaster.js +0 -62
- package/lib/esm/tools.js +0 -1158
- package/lib/esm/tooltips.js +0 -153
- package/lib/esm/treeview.js +0 -527
- package/lib/esm/x4dom.js +0 -29
- package/lib/esm/x4events.js +0 -376
- package/lib/esm/x4react.js +0 -71
- package/lib/types/app_sockets.d.ts +0 -29
- package/lib/types/application.d.ts +0 -104
- package/lib/types/autocomplete.d.ts +0 -58
- package/lib/types/base_component.d.ts +0 -88
- package/lib/types/button.d.ts +0 -151
- package/lib/types/calendar.d.ts +0 -82
- package/lib/types/canvas.d.ts +0 -92
- package/lib/types/cardview.d.ts +0 -87
- package/lib/types/checkbox.d.ts +0 -77
- package/lib/types/color.d.ts +0 -148
- package/lib/types/colorpicker.d.ts +0 -107
- package/lib/types/combobox.d.ts +0 -107
- package/lib/types/component.d.ts +0 -601
- package/lib/types/datastore.d.ts +0 -396
- package/lib/types/dialog.d.ts +0 -175
- package/lib/types/dom_events.d.ts +0 -302
- package/lib/types/drag_manager.d.ts +0 -54
- package/lib/types/drawtext.d.ts +0 -48
- package/lib/types/fileupload.d.ts +0 -64
- package/lib/types/form.d.ts +0 -133
- package/lib/types/formatters.d.ts +0 -35
- package/lib/types/gridview.d.ts +0 -175
- package/lib/types/i18n.d.ts +0 -73
- package/lib/types/icon.d.ts +0 -64
- package/lib/types/image.d.ts +0 -55
- package/lib/types/index.d.ts +0 -84
- package/lib/types/input.d.ts +0 -91
- package/lib/types/label.d.ts +0 -58
- package/lib/types/layout.d.ts +0 -87
- package/lib/types/link.d.ts +0 -50
- package/lib/types/listview.d.ts +0 -178
- package/lib/types/md5.d.ts +0 -61
- package/lib/types/menu.d.ts +0 -130
- package/lib/types/messagebox.d.ts +0 -69
- package/lib/types/panel.d.ts +0 -47
- package/lib/types/popup.d.ts +0 -75
- package/lib/types/property_editor.d.ts +0 -71
- package/lib/types/radiobtn.d.ts +0 -73
- package/lib/types/rating.d.ts +0 -53
- package/lib/types/request.d.ts +0 -52
- package/lib/types/router.d.ts +0 -42
- package/lib/types/settings.d.ts +0 -37
- package/lib/types/sidebarview.d.ts +0 -49
- package/lib/types/spreadsheet.d.ts +0 -222
- package/lib/types/styles.d.ts +0 -85
- package/lib/types/svgcomponent.d.ts +0 -215
- package/lib/types/tabbar.d.ts +0 -58
- package/lib/types/tabview.d.ts +0 -49
- package/lib/types/textarea.d.ts +0 -77
- package/lib/types/textedit.d.ts +0 -123
- package/lib/types/toaster.d.ts +0 -42
- package/lib/types/tools.d.ts +0 -394
- package/lib/types/tooltips.d.ts +0 -46
- package/lib/types/treeview.d.ts +0 -144
- package/lib/types/version.d.ts +0 -29
- package/lib/types/x4dom.d.ts +0 -49
- package/lib/types/x4events.d.ts +0 -269
- package/lib/types/x4react.d.ts +0 -41
package/lib/cjs/styles.js
DELETED
|
@@ -1,275 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* ___ ___ __
|
|
4
|
-
* \ \_/ / / _
|
|
5
|
-
* \ / /_| |_
|
|
6
|
-
* / _ \____ _|
|
|
7
|
-
* /__/ \__\ |_|
|
|
8
|
-
*
|
|
9
|
-
* @file styles.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.ComputedStyle = exports.CSSParser = exports.Stylesheet = void 0;
|
|
32
|
-
const x4dom_1 = require("./x4dom");
|
|
33
|
-
const tools_1 = require("./tools");
|
|
34
|
-
/**
|
|
35
|
-
* -- [ @STYLESHEET ] -----------------------------------------------------------------
|
|
36
|
-
*/
|
|
37
|
-
class Stylesheet {
|
|
38
|
-
constructor() {
|
|
39
|
-
this.m_rules = new Map();
|
|
40
|
-
function getStyleSheet(name) {
|
|
41
|
-
for (let i = 0; i < x4dom_1.x4document.styleSheets.length; i++) {
|
|
42
|
-
let sheet = x4dom_1.x4document.styleSheets[i];
|
|
43
|
-
if (sheet.title === name) {
|
|
44
|
-
return sheet;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
this.m_sheet = getStyleSheet('@dynamic-css');
|
|
49
|
-
if (!this.m_sheet) {
|
|
50
|
-
let dom = x4dom_1.x4document.createElement('style');
|
|
51
|
-
dom.setAttribute('id', '@dynamic-css');
|
|
52
|
-
x4dom_1.x4document.head.appendChild(dom);
|
|
53
|
-
this.m_sheet = dom.sheet;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* add a new rule to the style sheet
|
|
58
|
-
* @param {string} name - internal rule name
|
|
59
|
-
* @param {string} definition - css definition of the rule
|
|
60
|
-
* @example
|
|
61
|
-
* setRule('xbody', "body { background-color: #ff0000; }" );
|
|
62
|
-
*/
|
|
63
|
-
setRule(name, definition) {
|
|
64
|
-
if ((0, tools_1.isString)(definition)) {
|
|
65
|
-
let index = this.m_rules.get(name);
|
|
66
|
-
if (index !== undefined) {
|
|
67
|
-
this.m_sheet.deleteRule(index);
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
index = this.m_sheet.cssRules.length;
|
|
71
|
-
}
|
|
72
|
-
this.m_rules.set(name, this.m_sheet.insertRule(definition, index));
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
let idx = 1;
|
|
76
|
-
for (let r in definition) {
|
|
77
|
-
let rule = r + " { ", css = definition[r];
|
|
78
|
-
for (let i in css) {
|
|
79
|
-
let values = css[i]; // this is an array !
|
|
80
|
-
for (let j = 0; j < values.length; j++) {
|
|
81
|
-
rule += i + ": " + values[j] + "; ";
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
rule += '}';
|
|
85
|
-
//console.log( rule );
|
|
86
|
-
this.setRule(name + '--' + idx, rule);
|
|
87
|
-
idx++;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* return the style variable value
|
|
93
|
-
* @param name - variable name
|
|
94
|
-
* @example
|
|
95
|
-
* ```
|
|
96
|
-
* let color = Component.getCss( ).getVar( 'button-color' );
|
|
97
|
-
* ```
|
|
98
|
-
*/
|
|
99
|
-
static getVar(name) {
|
|
100
|
-
if (!Stylesheet.doc_style) {
|
|
101
|
-
Stylesheet.doc_style = getComputedStyle(x4dom_1.x4document.documentElement);
|
|
102
|
-
}
|
|
103
|
-
if (name[0] != '-') {
|
|
104
|
-
name = '--' + name;
|
|
105
|
-
}
|
|
106
|
-
return Stylesheet.doc_style.getPropertyValue(name); // #999999
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
exports.Stylesheet = Stylesheet;
|
|
110
|
-
Stylesheet.guid = 1;
|
|
111
|
-
/**
|
|
112
|
-
* -- [ @CSSPARSER ] -----------------------------------------------------------------
|
|
113
|
-
*
|
|
114
|
-
* adaptation of jss-for-node-js
|
|
115
|
-
*/
|
|
116
|
-
class CSSParser {
|
|
117
|
-
constructor() {
|
|
118
|
-
this.result = {};
|
|
119
|
-
}
|
|
120
|
-
parse(css) {
|
|
121
|
-
this.result = {};
|
|
122
|
-
this.parse_json('', css);
|
|
123
|
-
return CSSParser.mk_string(this.result);
|
|
124
|
-
}
|
|
125
|
-
static mk_string(rules) {
|
|
126
|
-
// output result:
|
|
127
|
-
let ret = '';
|
|
128
|
-
for (let a in rules) {
|
|
129
|
-
let css = rules[a];
|
|
130
|
-
ret += a + " { ";
|
|
131
|
-
for (let i in css) {
|
|
132
|
-
let values = css[i]; // this is an array !
|
|
133
|
-
for (let j = 0; j < values.length; j++) {
|
|
134
|
-
ret += i + ": " + values[j] + "; ";
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
ret += "}\n";
|
|
138
|
-
}
|
|
139
|
-
return ret;
|
|
140
|
-
}
|
|
141
|
-
parse_json(scope, css) {
|
|
142
|
-
if (scope && !this.result[scope]) {
|
|
143
|
-
this.result[scope] = {};
|
|
144
|
-
}
|
|
145
|
-
for (let property in css) {
|
|
146
|
-
let value = css[property];
|
|
147
|
-
if ((0, tools_1.isArray)(value)) {
|
|
148
|
-
let values = value;
|
|
149
|
-
for (let i = 0; i < values.length; i++) {
|
|
150
|
-
this.addProperty(scope, property, values[i]);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
/*else if (value instanceof Color) {
|
|
154
|
-
this.addProperty(scope, property, value.toString());
|
|
155
|
-
}*/
|
|
156
|
-
else {
|
|
157
|
-
switch (typeof (value)) {
|
|
158
|
-
case "number": {
|
|
159
|
-
this.addProperty(scope, property, value);
|
|
160
|
-
break;
|
|
161
|
-
}
|
|
162
|
-
case "string": {
|
|
163
|
-
this.addProperty(scope, property, value);
|
|
164
|
-
break;
|
|
165
|
-
}
|
|
166
|
-
case "object": {
|
|
167
|
-
this.parse_json(this.makeSelectorName(scope, property), value);
|
|
168
|
-
break;
|
|
169
|
-
}
|
|
170
|
-
default: {
|
|
171
|
-
console.error("ignoring unknown type " + typeof (value) + " in property " + property);
|
|
172
|
-
break;
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
makePropertyName(n) {
|
|
179
|
-
return (0, tools_1.pascalCase)(n);
|
|
180
|
-
}
|
|
181
|
-
makeSelectorName(scope, name) {
|
|
182
|
-
let snames = [];
|
|
183
|
-
let names = name.split(/\s*,\s*/);
|
|
184
|
-
let scopes = scope.split(/\s*,\s*/);
|
|
185
|
-
for (let s = 0; s < scopes.length; s++) {
|
|
186
|
-
let scope = scopes[s];
|
|
187
|
-
for (let i = 0; i < names.length; i++) {
|
|
188
|
-
let name = names[i], sub = false;
|
|
189
|
-
if (name.charAt(0) == "&") {
|
|
190
|
-
name = name.substr(1);
|
|
191
|
-
sub = true;
|
|
192
|
-
}
|
|
193
|
-
if (name.charAt(0) === '%') {
|
|
194
|
-
name = '.o-' + name.substr(1);
|
|
195
|
-
}
|
|
196
|
-
if (sub) {
|
|
197
|
-
snames.push(scope + name);
|
|
198
|
-
}
|
|
199
|
-
else {
|
|
200
|
-
snames.push(scope ? scope + " " + name : name);
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
return snames.join(", ");
|
|
205
|
-
}
|
|
206
|
-
addProperty(scope, property, value) {
|
|
207
|
-
let properties = property.split(/\s*,\s*/);
|
|
208
|
-
for (let i = 0; i < properties.length; i++) {
|
|
209
|
-
let property = this.makePropertyName(properties[i]);
|
|
210
|
-
if (this.result[scope][property]) {
|
|
211
|
-
this.result[scope][property].push(value);
|
|
212
|
-
}
|
|
213
|
-
else {
|
|
214
|
-
this.result[scope][property] = [value];
|
|
215
|
-
}
|
|
216
|
-
let specials = {
|
|
217
|
-
"box-shadow": [
|
|
218
|
-
"-moz-box-shadow",
|
|
219
|
-
"-webkit-box-shadow"
|
|
220
|
-
],
|
|
221
|
-
"border-radius": [
|
|
222
|
-
"-moz-border-radius",
|
|
223
|
-
"-webkit-border-radius"
|
|
224
|
-
],
|
|
225
|
-
"border-radius-topleft": [
|
|
226
|
-
"-moz-border-radius-topleft",
|
|
227
|
-
"-webkit-border-top-left-radius"
|
|
228
|
-
],
|
|
229
|
-
"border-radius-topright": [
|
|
230
|
-
"-moz-border-radius-topright",
|
|
231
|
-
"-webkit-border-top-right-radius"
|
|
232
|
-
],
|
|
233
|
-
"border-radius-bottomleft": [
|
|
234
|
-
"-moz-border-radius-bottomleft",
|
|
235
|
-
"-webkit-border-bottom-left-radius"
|
|
236
|
-
],
|
|
237
|
-
"border-radius-bottomright": [
|
|
238
|
-
"-moz-border-radius-bottomright",
|
|
239
|
-
"-webkit-border-bottom-right-radius"
|
|
240
|
-
]
|
|
241
|
-
};
|
|
242
|
-
let browser_specials = specials[property];
|
|
243
|
-
for (let j = 0; browser_specials && j < browser_specials.length; j++) {
|
|
244
|
-
this.addProperty(scope, browser_specials[j], value);
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
exports.CSSParser = CSSParser;
|
|
250
|
-
class ComputedStyle {
|
|
251
|
-
constructor(style) {
|
|
252
|
-
this.m_style = style;
|
|
253
|
-
}
|
|
254
|
-
/**
|
|
255
|
-
* return the raw value
|
|
256
|
-
*/
|
|
257
|
-
value(name) {
|
|
258
|
-
name = (0, tools_1.pascalCase)(name);
|
|
259
|
-
return this.m_style[name];
|
|
260
|
-
}
|
|
261
|
-
/**
|
|
262
|
-
* return the interpreted value
|
|
263
|
-
*/
|
|
264
|
-
parse(name) {
|
|
265
|
-
name = (0, tools_1.pascalCase)(name);
|
|
266
|
-
return parseInt(this.m_style[name]);
|
|
267
|
-
}
|
|
268
|
-
/**
|
|
269
|
-
*
|
|
270
|
-
*/
|
|
271
|
-
get style() {
|
|
272
|
-
return this.m_style;
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
exports.ComputedStyle = ComputedStyle;
|
package/lib/cjs/svgcomponent.js
DELETED
|
@@ -1,447 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* ___ ___ __
|
|
4
|
-
* \ \_/ / / _
|
|
5
|
-
* \ / /_| |_
|
|
6
|
-
* / _ \____ _|
|
|
7
|
-
* /__/ \__\ |_|
|
|
8
|
-
*
|
|
9
|
-
* @file svgcomponent.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.SVGComponent = exports.SVGPathBuilder = void 0;
|
|
32
|
-
const component_1 = require("./component");
|
|
33
|
-
const tools_1 = require("./tools");
|
|
34
|
-
const reNumber = /^-?\d+(\.\d+)?$/;
|
|
35
|
-
// degrees to radian
|
|
36
|
-
function d2r(d) {
|
|
37
|
-
return d * Math.PI / 180.0;
|
|
38
|
-
}
|
|
39
|
-
// polar to cartesian
|
|
40
|
-
function p2c(x, y, r, deg) {
|
|
41
|
-
const rad = d2r(deg);
|
|
42
|
-
return {
|
|
43
|
-
x: x + r * Math.cos(rad),
|
|
44
|
-
y: y + r * Math.sin(rad)
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
function num(x) {
|
|
48
|
-
return Math.round(x * 1000) / 1000;
|
|
49
|
-
}
|
|
50
|
-
function clean(a, ...b) {
|
|
51
|
-
// just round number values to 3 digits
|
|
52
|
-
b = b.map(v => {
|
|
53
|
-
if (typeof v === 'number' && isFinite(v)) {
|
|
54
|
-
return num(v);
|
|
55
|
-
}
|
|
56
|
-
return v;
|
|
57
|
-
});
|
|
58
|
-
return String.raw(a, ...b);
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
*
|
|
62
|
-
*/
|
|
63
|
-
class SVGItem {
|
|
64
|
-
constructor(tag) {
|
|
65
|
-
this.m_tag = tag;
|
|
66
|
-
this.m_attrs = new Map();
|
|
67
|
-
this.m_style = new Map();
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* render the item
|
|
71
|
-
* @returns
|
|
72
|
-
*/
|
|
73
|
-
render() {
|
|
74
|
-
return `<${this.m_tag} ${this.renderAttrs()} ${this.renderStyle()}>${this.renderContent()}</${this.m_tag}>`;
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* change the stroke color
|
|
78
|
-
* @param color
|
|
79
|
-
*/
|
|
80
|
-
stroke(color, width) {
|
|
81
|
-
this.attr('stroke', color);
|
|
82
|
-
if (width !== undefined) {
|
|
83
|
-
this.attr('stroke-width', width + 'px');
|
|
84
|
-
}
|
|
85
|
-
return this;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* change the stroke width
|
|
89
|
-
* @param width
|
|
90
|
-
*/
|
|
91
|
-
strokeWidth(width) {
|
|
92
|
-
this.attr('stroke-width', width + 'px');
|
|
93
|
-
return this;
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* change the fill color
|
|
97
|
-
* @param color
|
|
98
|
-
*/
|
|
99
|
-
fill(color) {
|
|
100
|
-
this.attr('fill', color);
|
|
101
|
-
return this;
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* define a new attribute
|
|
105
|
-
* @param name attibute name
|
|
106
|
-
* @param value attribute value
|
|
107
|
-
* @returns this
|
|
108
|
-
*/
|
|
109
|
-
attr(name, value) {
|
|
110
|
-
this.m_attrs.set(name, value);
|
|
111
|
-
return this;
|
|
112
|
-
}
|
|
113
|
-
style(name, value) {
|
|
114
|
-
if (value === undefined || value === '' || value === undefined) {
|
|
115
|
-
this.m_style.delete(name);
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
if (!component_1._x4_unitless[name] && ((0, tools_1.isNumber)(value) || reNumber.test(value))) {
|
|
119
|
-
value = value + 'px';
|
|
120
|
-
}
|
|
121
|
-
this.m_style.set(name, '' + value);
|
|
122
|
-
return this;
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* add a class
|
|
126
|
-
* @param name class name to add
|
|
127
|
-
*/
|
|
128
|
-
class(name) {
|
|
129
|
-
let c = this.m_attrs.get('class');
|
|
130
|
-
this.m_attrs.set('class', (c !== null && c !== void 0 ? c : '' + ' ' + name).trim());
|
|
131
|
-
return this;
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
*
|
|
135
|
-
*/
|
|
136
|
-
renderAttrs() {
|
|
137
|
-
if (!this.m_attrs.size) {
|
|
138
|
-
return "";
|
|
139
|
-
}
|
|
140
|
-
let result = '';
|
|
141
|
-
this.m_attrs.forEach((v, k) => {
|
|
142
|
-
result += ` ${k} = "${v}"`;
|
|
143
|
-
});
|
|
144
|
-
return result;
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
*
|
|
148
|
-
*/
|
|
149
|
-
renderStyle() {
|
|
150
|
-
if (!this.m_style.size) {
|
|
151
|
-
return "";
|
|
152
|
-
}
|
|
153
|
-
let result = 'style="';
|
|
154
|
-
this.m_style.forEach((v, k) => {
|
|
155
|
-
result += `${k}:${v};`;
|
|
156
|
-
});
|
|
157
|
-
return result + '"';
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
*
|
|
161
|
-
*/
|
|
162
|
-
renderContent() {
|
|
163
|
-
return '';
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
*
|
|
167
|
-
*/
|
|
168
|
-
clip(id) {
|
|
169
|
-
this.attr("clip-path", `url(#${id})`);
|
|
170
|
-
return this;
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
*
|
|
174
|
-
*/
|
|
175
|
-
transform(tr) {
|
|
176
|
-
this.attr("transform", tr);
|
|
177
|
-
}
|
|
178
|
-
/**
|
|
179
|
-
*
|
|
180
|
-
*/
|
|
181
|
-
rotate(deg, cx, cy) {
|
|
182
|
-
this.transform(`rotate( ${deg} ${cx} ${cy} )`);
|
|
183
|
-
}
|
|
184
|
-
translate(dx, dy) {
|
|
185
|
-
this.transform(`translate( ${dx} ${dy} )`);
|
|
186
|
-
}
|
|
187
|
-
scale(x) {
|
|
188
|
-
this.transform(`scale( ${x} )`);
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
/**
|
|
192
|
-
*
|
|
193
|
-
*/
|
|
194
|
-
class SVGPath extends SVGItem {
|
|
195
|
-
constructor() {
|
|
196
|
-
super('path');
|
|
197
|
-
this.m_path = '';
|
|
198
|
-
}
|
|
199
|
-
renderAttrs() {
|
|
200
|
-
this.attr('d', this.m_path);
|
|
201
|
-
return super.renderAttrs();
|
|
202
|
-
}
|
|
203
|
-
/**
|
|
204
|
-
* move the current pos
|
|
205
|
-
* @param x new pos x
|
|
206
|
-
* @param y new pos y
|
|
207
|
-
* @returns this
|
|
208
|
-
*/
|
|
209
|
-
moveTo(x, y) {
|
|
210
|
-
this.m_path += clean `M${x},${y}`;
|
|
211
|
-
return this;
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* draw aline to the given point
|
|
215
|
-
* @param x end x
|
|
216
|
-
* @param y end y
|
|
217
|
-
* @returns this
|
|
218
|
-
*/
|
|
219
|
-
lineTo(x, y) {
|
|
220
|
-
this.m_path += clean `L${x},${y}`;
|
|
221
|
-
return this;
|
|
222
|
-
}
|
|
223
|
-
/**
|
|
224
|
-
* close the currentPath
|
|
225
|
-
*/
|
|
226
|
-
closePath() {
|
|
227
|
-
this.m_path += 'Z';
|
|
228
|
-
return this;
|
|
229
|
-
}
|
|
230
|
-
/**
|
|
231
|
-
* draw an arc
|
|
232
|
-
* @param x center x
|
|
233
|
-
* @param y center y
|
|
234
|
-
* @param r radius
|
|
235
|
-
* @param start angle start in degrees
|
|
236
|
-
* @param end angle end in degrees
|
|
237
|
-
* @returns this
|
|
238
|
-
*/
|
|
239
|
-
arc(x, y, r, start, end) {
|
|
240
|
-
const st = p2c(x, y, r, start - 90);
|
|
241
|
-
const en = p2c(x, y, r, end - 90);
|
|
242
|
-
const flag = end - start <= 180 ? "0" : "1";
|
|
243
|
-
this.m_path += clean `M${st.x},${st.y}A${r},${r} 0 ${flag} 1 ${en.x},${en.y}`;
|
|
244
|
-
return this;
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
/**
|
|
248
|
-
*
|
|
249
|
-
*/
|
|
250
|
-
class SVGText extends SVGItem {
|
|
251
|
-
constructor(x, y, txt) {
|
|
252
|
-
super('text');
|
|
253
|
-
this.m_text = txt;
|
|
254
|
-
this.attr('x', num(x) + '');
|
|
255
|
-
this.attr('y', num(y) + '');
|
|
256
|
-
}
|
|
257
|
-
font(font) {
|
|
258
|
-
this.attr('font-family', font);
|
|
259
|
-
return this;
|
|
260
|
-
}
|
|
261
|
-
fontSize(size) {
|
|
262
|
-
this.attr('font-size', size + '');
|
|
263
|
-
return this;
|
|
264
|
-
}
|
|
265
|
-
fontWeight(weight) {
|
|
266
|
-
this.attr('font-weight', weight);
|
|
267
|
-
return this;
|
|
268
|
-
}
|
|
269
|
-
textAlign(align) {
|
|
270
|
-
let al;
|
|
271
|
-
switch (align) {
|
|
272
|
-
case 'left':
|
|
273
|
-
al = 'start';
|
|
274
|
-
break;
|
|
275
|
-
case 'center':
|
|
276
|
-
al = 'middle';
|
|
277
|
-
break;
|
|
278
|
-
case 'right':
|
|
279
|
-
al = 'end';
|
|
280
|
-
break;
|
|
281
|
-
default: return this;
|
|
282
|
-
}
|
|
283
|
-
this.attr('text-anchor', al);
|
|
284
|
-
return this;
|
|
285
|
-
}
|
|
286
|
-
verticalAlign(align) {
|
|
287
|
-
let al;
|
|
288
|
-
switch (align) {
|
|
289
|
-
case 'top':
|
|
290
|
-
al = 'hanging';
|
|
291
|
-
break;
|
|
292
|
-
case 'center':
|
|
293
|
-
al = 'middle';
|
|
294
|
-
break;
|
|
295
|
-
case 'bottom':
|
|
296
|
-
al = 'baseline';
|
|
297
|
-
break;
|
|
298
|
-
default: return;
|
|
299
|
-
}
|
|
300
|
-
this.attr('alignment-baseline', al);
|
|
301
|
-
return this;
|
|
302
|
-
}
|
|
303
|
-
renderContent() {
|
|
304
|
-
return this.m_text;
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
/**
|
|
308
|
-
*
|
|
309
|
-
*/
|
|
310
|
-
class SVGShape extends SVGItem {
|
|
311
|
-
constructor(tag) {
|
|
312
|
-
super(tag);
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
class SVGGradient extends SVGItem {
|
|
316
|
-
constructor(x1, y1, x2, y2) {
|
|
317
|
-
super('linearGradient');
|
|
318
|
-
this.m_id = 'gx-' + SVGGradient.g_id;
|
|
319
|
-
this.attr('id', this.m_id);
|
|
320
|
-
this.attr('x1', (0, tools_1.isString)(x1) ? x1 : num(x1) + '');
|
|
321
|
-
this.attr('x2', (0, tools_1.isString)(x2) ? x2 : num(x2) + '');
|
|
322
|
-
this.attr('y1', (0, tools_1.isString)(y1) ? y1 : num(y1) + '');
|
|
323
|
-
this.attr('y2', (0, tools_1.isString)(y2) ? y2 : num(y2) + '');
|
|
324
|
-
this.m_stops = [];
|
|
325
|
-
SVGGradient.g_id++;
|
|
326
|
-
}
|
|
327
|
-
get id() {
|
|
328
|
-
return 'url(#' + this.m_id + ')';
|
|
329
|
-
}
|
|
330
|
-
addStop(offset, color) {
|
|
331
|
-
this.m_stops.push({ offset, color });
|
|
332
|
-
return this;
|
|
333
|
-
}
|
|
334
|
-
renderContent() {
|
|
335
|
-
const result = [];
|
|
336
|
-
this.m_stops.forEach(s => {
|
|
337
|
-
result.push(`<stop offset="${s.offset}%" stop-color="${s.color}"></stop>`);
|
|
338
|
-
});
|
|
339
|
-
return result.join('\n');
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
SVGGradient.g_id = 1;
|
|
343
|
-
/**
|
|
344
|
-
*
|
|
345
|
-
*/
|
|
346
|
-
class SVGGroup extends SVGItem {
|
|
347
|
-
constructor(tag = "g") {
|
|
348
|
-
super(tag);
|
|
349
|
-
this.m_items = [];
|
|
350
|
-
}
|
|
351
|
-
path() {
|
|
352
|
-
const path = new SVGPath();
|
|
353
|
-
this.m_items.push(path);
|
|
354
|
-
return path;
|
|
355
|
-
}
|
|
356
|
-
text(x, y, txt) {
|
|
357
|
-
const text = new SVGText(x, y, txt);
|
|
358
|
-
this.m_items.push(text);
|
|
359
|
-
return text;
|
|
360
|
-
}
|
|
361
|
-
ellipse(x, y, r1, r2 = r1) {
|
|
362
|
-
const shape = new SVGShape('ellipse');
|
|
363
|
-
shape.attr('cx', num(x) + '');
|
|
364
|
-
shape.attr('cy', num(y) + '');
|
|
365
|
-
shape.attr('rx', num(r1) + '');
|
|
366
|
-
shape.attr('ry', num(r2) + '');
|
|
367
|
-
this.m_items.push(shape);
|
|
368
|
-
return shape;
|
|
369
|
-
}
|
|
370
|
-
rect(x, y, w, h) {
|
|
371
|
-
const shape = new SVGShape('rect');
|
|
372
|
-
shape.attr('x', num(x) + '');
|
|
373
|
-
shape.attr('y', num(y) + '');
|
|
374
|
-
shape.attr('width', num(w) + '');
|
|
375
|
-
shape.attr('height', num(h) + '');
|
|
376
|
-
this.m_items.push(shape);
|
|
377
|
-
return shape;
|
|
378
|
-
}
|
|
379
|
-
/**
|
|
380
|
-
*
|
|
381
|
-
* example
|
|
382
|
-
* ```ts
|
|
383
|
-
* const g = c.linear_gradient( '0%', '0%', '0%', '100%' )
|
|
384
|
-
* .addStop( 0, 'red' )
|
|
385
|
-
* .addStop( 100, 'green' );
|
|
386
|
-
*
|
|
387
|
-
* p.rect( 0, 0, 100, 100 )
|
|
388
|
-
* .stroke( g.id );
|
|
389
|
-
*
|
|
390
|
-
* ```
|
|
391
|
-
*/
|
|
392
|
-
linear_gradient(x1, y1, x2, y2) {
|
|
393
|
-
const grad = new SVGGradient(x1, y1, x2, y2);
|
|
394
|
-
this.m_items.push(grad);
|
|
395
|
-
return grad;
|
|
396
|
-
}
|
|
397
|
-
/**
|
|
398
|
-
* clear
|
|
399
|
-
*/
|
|
400
|
-
clear() {
|
|
401
|
-
this.m_items = [];
|
|
402
|
-
}
|
|
403
|
-
renderContent() {
|
|
404
|
-
let result = [];
|
|
405
|
-
this.m_items.forEach(i => {
|
|
406
|
-
result.push(i.render());
|
|
407
|
-
});
|
|
408
|
-
return result.join('\n');
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
/**
|
|
412
|
-
*
|
|
413
|
-
*/
|
|
414
|
-
class SVGPathBuilder extends SVGGroup {
|
|
415
|
-
constructor() {
|
|
416
|
-
super('');
|
|
417
|
-
}
|
|
418
|
-
addClip(x, y, w, h) {
|
|
419
|
-
const id = 'c-' + SVGPathBuilder.g_clip_id++;
|
|
420
|
-
const clip = new SVGGroup('clipPath');
|
|
421
|
-
clip.attr('id', id);
|
|
422
|
-
clip.rect(x, y, w, h);
|
|
423
|
-
this.m_items.push(clip);
|
|
424
|
-
return id;
|
|
425
|
-
}
|
|
426
|
-
render() {
|
|
427
|
-
let result = [];
|
|
428
|
-
this.m_items.forEach(i => {
|
|
429
|
-
result.push(i.render());
|
|
430
|
-
});
|
|
431
|
-
return result.join('\n');
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
exports.SVGPathBuilder = SVGPathBuilder;
|
|
435
|
-
SVGPathBuilder.g_clip_id = 1;
|
|
436
|
-
class SVGComponent extends component_1.Component {
|
|
437
|
-
constructor(props) {
|
|
438
|
-
super(props);
|
|
439
|
-
this.setTag('svg', 'http://www.w3.org/2000/svg');
|
|
440
|
-
this.setAttribute('xmlns', 'http://www.w3.org/2000/svg');
|
|
441
|
-
this.setAttributes({
|
|
442
|
-
viewBox: props.viewBox,
|
|
443
|
-
});
|
|
444
|
-
this.setContent(props.path);
|
|
445
|
-
}
|
|
446
|
-
}
|
|
447
|
-
exports.SVGComponent = SVGComponent;
|