x4js 2.0.13 → 2.0.15
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/.vscode/launch.json +14 -0
- package/README.md +5 -0
- package/{lib/src/demo → demo}/main.scss +3 -1
- package/{lib/src/demo/main.tsx → demo/main.ts} +37 -36
- package/demo/package.json +26 -0
- package/demo/scss.d.ts +4 -0
- package/demo/svg.d.ts +1 -0
- package/demo/tsconfig.json +14 -0
- package/lib/README.txt +5 -0
- package/lib/cjs/x4.css +1 -1
- package/lib/cjs/x4.js +2 -1
- package/lib/esm/x4.css +1 -1
- package/lib/esm/x4.mjs +2 -1
- package/lib/src/components/boxes/boxes.module.scss +17 -0
- package/lib/src/components/boxes/boxes.ts +258 -17
- package/lib/src/components/breadcrumb/breadcrumb.scss +56 -28
- package/lib/src/components/breadcrumb/breadcrumb.ts +93 -84
- package/lib/src/components/btngroup/btngroup.module.scss +12 -0
- package/lib/src/components/btngroup/btngroup.ts +41 -8
- package/lib/src/components/button/button.module.scss +23 -5
- package/lib/src/components/button/button.ts +72 -4
- package/lib/src/components/canvas/canvas.module.scss +25 -0
- package/lib/src/components/canvas/canvas.ts +189 -0
- package/lib/src/components/canvas/canvas_ex.ts +276 -0
- package/lib/src/components/checkbox/checkbox.ts +18 -4
- package/lib/src/components/combobox/combobox.module.scss +24 -15
- package/lib/src/components/combobox/combobox.ts +107 -24
- package/lib/src/components/components.ts +7 -0
- package/lib/src/components/dialog/dialog.module.scss +40 -7
- package/lib/src/components/dialog/dialog.ts +166 -31
- package/lib/src/components/filedrop/cloud-arrow-up.svg +1 -0
- package/lib/src/components/filedrop/filedrop.module.scss +70 -0
- package/lib/src/components/filedrop/filedrop.ts +131 -0
- package/lib/src/components/form/form.module.scss +4 -0
- package/lib/src/components/form/form.ts +137 -6
- package/lib/src/components/gridview/arrow-down-light.svg +1 -0
- package/lib/src/components/gridview/arrow-up-light.svg +1 -0
- package/lib/src/components/gridview/gridview.module.scss +324 -0
- package/lib/src/components/gridview/gridview.ts +1175 -0
- package/lib/src/components/icon/icon.module.scss +2 -1
- package/lib/src/components/icon/icon.ts +4 -3
- package/lib/src/components/image/image.module.scss +8 -1
- package/lib/src/components/image/image.ts +105 -6
- package/lib/src/components/input/input.module.scss +8 -3
- package/lib/src/components/input/input.ts +178 -31
- package/lib/src/components/keyboard/arrow-up.svg +1 -0
- package/lib/src/components/keyboard/delete-left.svg +1 -0
- package/lib/src/components/keyboard/eye-slash.svg +1 -0
- package/lib/src/components/keyboard/keyboard.module.scss +134 -0
- package/lib/src/components/keyboard/keyboard.ts +526 -0
- package/lib/src/components/label/label.module.scss +22 -4
- package/lib/src/components/label/label.ts +33 -0
- package/lib/src/components/link/link.ts +81 -78
- package/lib/src/components/listbox/listbox.module.scss +61 -3
- package/lib/src/components/listbox/listbox.ts +164 -56
- package/lib/src/components/menu/menu.module.scss +10 -1
- package/lib/src/components/menu/menu.ts +6 -3
- package/lib/src/components/messages/messages.module.scss +44 -0
- package/lib/src/components/messages/messages.ts +164 -18
- package/lib/src/components/messages/pen-field.svg +1 -0
- package/lib/src/components/normalize.scss +5 -0
- package/lib/src/components/notification/notification.module.scss +4 -2
- package/lib/src/components/notification/notification.ts +2 -4
- package/lib/src/components/panel/panel.module.scss +12 -0
- package/lib/src/components/popup/popup.module.scss +10 -2
- package/lib/src/components/popup/popup.ts +141 -95
- package/lib/src/components/propgrid/folder-closed.svg +1 -0
- package/lib/src/components/propgrid/folder-open.svg +1 -0
- package/lib/src/components/propgrid/progrid.module.scss +112 -0
- package/lib/src/components/propgrid/propgrid.ts +288 -0
- package/lib/src/components/propgrid/updown.svg +4 -0
- package/lib/src/components/radio/radio.module.scss +147 -0
- package/lib/src/components/radio/radio.svg +4 -0
- package/lib/src/components/radio/radio.ts +142 -0
- package/lib/src/components/select/select.module.scss +9 -0
- package/lib/src/components/select/select.ts +134 -0
- package/lib/src/components/shared.scss +47 -0
- package/lib/src/components/sizers/sizer.ts +10 -2
- package/lib/src/components/slider/slider.module.scss +77 -30
- package/lib/src/components/slider/slider.ts +72 -22
- package/lib/src/components/tabs/tabs.module.scss +1 -2
- package/lib/src/components/tabs/tabs.ts +49 -12
- package/lib/src/components/textarea/textarea.module.scss +6 -2
- package/lib/src/components/textarea/textarea.ts +73 -8
- package/lib/src/components/textedit/textedit.module.scss +3 -1
- package/lib/src/components/textedit/textedit.ts +47 -15
- package/lib/src/components/themes.scss +7 -0
- package/lib/src/components/tickline/tickline.module.scss +26 -0
- package/lib/src/components/tickline/tickline.ts +82 -0
- package/lib/src/components/tooltips/comments-question.svg +1 -0
- package/lib/src/components/tooltips/tooltips.scss +30 -9
- package/lib/src/components/tooltips/tooltips.ts +10 -5
- package/lib/src/components/treeview/treeview.module.scss +129 -60
- package/lib/src/components/treeview/treeview.ts +47 -12
- package/lib/src/components/viewport/viewport.module.scss +7 -0
- package/lib/src/core/component.ts +113 -40
- package/lib/src/core/core_application.ts +223 -2
- package/lib/src/core/core_colors.ts +2 -2
- package/lib/src/{components/grid/datastore.ts → core/core_data.ts} +264 -252
- package/lib/src/core/core_dragdrop.ts +3 -3
- package/lib/src/core/core_element.ts +18 -1
- package/lib/src/core/core_events.ts +28 -0
- package/lib/src/core/core_i18n.ts +19 -3
- package/lib/src/core/core_react.ts +79 -0
- package/lib/src/core/core_router.ts +25 -9
- package/lib/src/core/core_state.ts +62 -0
- package/lib/src/core/core_styles.ts +5 -5
- package/lib/src/core/core_svg.ts +174 -12
- package/lib/src/core/core_tools.ts +305 -87
- package/lib/src/x4tsx.d.ts +25 -0
- package/lib/styles/x4.css +1 -1
- package/lib/types/x4js.d.ts +828 -119
- package/package.json +4 -4
- package/scripts/build.mjs +378 -0
- package/scripts/prepack.mjs +346 -0
- package/src/components/base.scss +25 -0
- package/src/components/boxes/boxes.module.scss +54 -0
- package/src/components/boxes/boxes.ts +370 -0
- package/src/components/breadcrumb/breadcrumb.scss +56 -0
- package/src/components/breadcrumb/breadcrumb.ts +93 -0
- package/src/components/breadcrumb/chevron-right.svg +1 -0
- package/src/components/btngroup/btngroup.module.scss +41 -0
- package/src/components/btngroup/btngroup.ts +153 -0
- package/src/components/button/button.module.scss +173 -0
- package/src/components/button/button.ts +185 -0
- package/src/components/calendar/calendar-check-sharp-light.svg +1 -0
- package/src/components/calendar/calendar.module.scss +163 -0
- package/src/components/calendar/calendar.ts +327 -0
- package/src/components/calendar/chevron-left-sharp-light.svg +1 -0
- package/src/components/calendar/chevron-right-sharp-light.svg +1 -0
- package/src/components/canvas/canvas.module.scss +25 -0
- package/src/components/canvas/canvas.ts +189 -0
- package/src/components/canvas/canvas_ex.ts +276 -0
- package/src/components/checkbox/check.svg +4 -0
- package/src/components/checkbox/checkbox.module.scss +142 -0
- package/src/components/checkbox/checkbox.ts +140 -0
- package/src/components/colorinput/colorinput.module.scss +65 -0
- package/src/components/colorinput/colorinput.ts +91 -0
- package/src/components/colorinput/crosshairs-simple-sharp-light.svg +1 -0
- package/src/components/colorpicker/colorpicker.module.scss +133 -0
- package/src/components/colorpicker/colorpicker.ts +482 -0
- package/src/components/combobox/combobox.module.scss +133 -0
- package/src/components/combobox/combobox.ts +275 -0
- package/src/components/combobox/updown.svg +4 -0
- package/src/components/components.ts +41 -0
- package/src/components/dialog/dialog.module.scss +104 -0
- package/src/components/dialog/dialog.ts +229 -0
- package/src/components/dialog/xmark-sharp-light.svg +1 -0
- package/src/components/filedrop/cloud-arrow-up.svg +1 -0
- package/src/components/filedrop/filedrop.module.scss +70 -0
- package/src/components/filedrop/filedrop.ts +131 -0
- package/src/components/form/form.module.scss +38 -0
- package/src/components/form/form.ts +172 -0
- package/src/components/gridview/arrow-down-light.svg +1 -0
- package/src/components/gridview/arrow-up-light.svg +1 -0
- package/src/components/gridview/gridview.module.scss +324 -0
- package/src/components/gridview/gridview.ts +1175 -0
- package/src/components/header/header.module.scss +40 -0
- package/src/components/header/header.ts +130 -0
- package/src/components/icon/icon.module.scss +31 -0
- package/src/components/icon/icon.ts +137 -0
- package/src/components/image/image.module.scss +28 -0
- package/src/components/image/image.ts +168 -0
- package/src/components/input/input.module.scss +74 -0
- package/src/components/input/input.ts +422 -0
- package/src/components/keyboard/arrow-up.svg +1 -0
- package/src/components/keyboard/delete-left.svg +1 -0
- package/src/components/keyboard/eye-slash.svg +1 -0
- package/src/components/keyboard/keyboard.module.scss +134 -0
- package/src/components/keyboard/keyboard.ts +526 -0
- package/src/components/label/label.module.scss +76 -0
- package/src/components/label/label.ts +97 -0
- package/src/components/link/link.ts +81 -0
- package/src/components/listbox/listbox.module.scss +161 -0
- package/src/components/listbox/listbox.ts +539 -0
- package/src/components/menu/caret-right-solid.svg +1 -0
- package/src/components/menu/menu.module.scss +117 -0
- package/src/components/menu/menu.ts +174 -0
- package/src/components/messages/circle-exclamation.svg +1 -0
- package/src/components/messages/messages.module.scss +92 -0
- package/src/components/messages/messages.ts +215 -0
- package/src/components/messages/pen-field.svg +1 -0
- package/src/components/normalize.scss +391 -0
- package/src/components/notification/circle-check-solid.svg +1 -0
- package/src/components/notification/circle-exclamation-solid.svg +1 -0
- package/src/components/notification/circle-notch-light.svg +1 -0
- package/src/components/notification/notification.module.scss +84 -0
- package/src/components/notification/notification.ts +107 -0
- package/src/components/notification/xmark-sharp-light.svg +1 -0
- package/src/components/panel/panel.module.scss +60 -0
- package/src/components/panel/panel.ts +58 -0
- package/src/components/popup/popup.module.scss +51 -0
- package/src/components/popup/popup.ts +442 -0
- package/src/components/progress/progress.module.scss +57 -0
- package/src/components/progress/progress.ts +44 -0
- package/src/components/propgrid/folder-closed.svg +1 -0
- package/src/components/propgrid/folder-open.svg +1 -0
- package/src/components/propgrid/progrid.module.scss +112 -0
- package/src/components/propgrid/propgrid.ts +288 -0
- package/src/components/propgrid/updown.svg +4 -0
- package/src/components/radio/radio.module.scss +147 -0
- package/src/components/radio/radio.svg +4 -0
- package/src/components/radio/radio.ts +142 -0
- package/src/components/rating/rating.module.scss +23 -0
- package/src/components/rating/rating.ts +131 -0
- package/src/components/rating/star-sharp-light.svg +1 -0
- package/src/components/rating/star-sharp-solid.svg +1 -0
- package/src/components/select/select.module.scss +9 -0
- package/src/components/select/select.ts +134 -0
- package/src/components/shared.scss +137 -0
- package/src/components/sizers/sizer.module.scss +90 -0
- package/src/components/sizers/sizer.ts +132 -0
- package/src/components/slider/slider.module.scss +118 -0
- package/src/components/slider/slider.ts +198 -0
- package/src/components/switch/switch.module.scss +127 -0
- package/src/components/switch/switch.ts +62 -0
- package/src/components/tabs/tabs.module.scss +45 -0
- package/src/components/tabs/tabs.ts +205 -0
- package/src/components/textarea/textarea.module.scss +63 -0
- package/src/components/textarea/textarea.ts +125 -0
- package/src/components/textedit/textedit.module.scss +116 -0
- package/src/components/textedit/textedit.ts +115 -0
- package/src/components/themes.scss +88 -0
- package/src/components/tickline/tickline.module.scss +26 -0
- package/src/components/tickline/tickline.ts +82 -0
- package/src/components/tooltips/circle-info-sharp-light.svg +1 -0
- package/src/components/tooltips/comments-question.svg +1 -0
- package/src/components/tooltips/tooltips.scss +72 -0
- package/src/components/tooltips/tooltips.ts +109 -0
- package/src/components/treeview/chevron-down-light.svg +1 -0
- package/src/components/treeview/treeview.module.scss +185 -0
- package/src/components/treeview/treeview.ts +445 -0
- package/src/components/viewport/viewport.module.scss +32 -0
- package/src/components/viewport/viewport.ts +41 -0
- package/src/core/component.ts +1075 -0
- package/src/core/core_application.ts +265 -0
- package/src/core/core_colors.ts +250 -0
- package/src/core/core_data.ts +1310 -0
- package/src/core/core_dom.ts +471 -0
- package/src/core/core_dragdrop.ts +201 -0
- package/src/core/core_element.ts +115 -0
- package/src/core/core_events.ts +177 -0
- package/src/core/core_i18n.ts +393 -0
- package/src/core/core_react.ts +79 -0
- package/src/core/core_router.ts +237 -0
- package/src/core/core_state.ts +62 -0
- package/src/core/core_styles.ts +214 -0
- package/src/core/core_svg.ts +712 -0
- package/src/core/core_tools.ts +906 -0
- package/src/types/scss.d.ts +4 -0
- package/src/types/svg.d.ts +1 -0
- package/src/types/x4react.d.ts +9 -0
- package/src/x4.scss +19 -0
- package/src/x4tsx.d.ts +25 -0
- package/tsconfig.json +14 -0
- package/lib/src/components/grid/gridview.ts +0 -1108
- package/lib/src/components/grid/memdb.ts +0 -325
- /package/{lib/src/demo → demo}/assets/house-light.svg +0 -0
- /package/{lib/src/demo → demo}/assets/radio.svg +0 -0
- /package/{lib/src/demo → demo}/index.html +0 -0
package/lib/src/core/core_svg.ts
CHANGED
|
@@ -69,10 +69,28 @@ class SvgItem {
|
|
|
69
69
|
this._dom = document.createElementNS("http://www.w3.org/2000/svg", tag );
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
+
/**
|
|
73
|
+
* @returns the svh element dom
|
|
74
|
+
*/
|
|
75
|
+
|
|
72
76
|
getDom( ) {
|
|
73
77
|
return this._dom;
|
|
74
78
|
}
|
|
75
79
|
|
|
80
|
+
/**
|
|
81
|
+
*
|
|
82
|
+
*/
|
|
83
|
+
|
|
84
|
+
reset( ) {
|
|
85
|
+
const attrs = this._dom.attributes;
|
|
86
|
+
for (let i = attrs.length - 1; i >= 0; i--) {
|
|
87
|
+
this._dom.removeAttribute(attrs[i].name);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return this;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
|
|
76
94
|
/**
|
|
77
95
|
* change the stroke color
|
|
78
96
|
* @param color
|
|
@@ -126,6 +144,18 @@ class SvgItem {
|
|
|
126
144
|
return this;
|
|
127
145
|
}
|
|
128
146
|
|
|
147
|
+
/**
|
|
148
|
+
* return the given attribute if any
|
|
149
|
+
*/
|
|
150
|
+
|
|
151
|
+
getAttr( name: string ) : string {
|
|
152
|
+
return this._dom.getAttribute( name );
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
getNumAttr( name: string ) {
|
|
156
|
+
return parseInt( this._dom.getAttribute( name ) );
|
|
157
|
+
}
|
|
158
|
+
|
|
129
159
|
/**
|
|
130
160
|
* define a new attribute
|
|
131
161
|
* @param name attibute name
|
|
@@ -165,9 +195,10 @@ class SvgItem {
|
|
|
165
195
|
* @param name class name to add
|
|
166
196
|
*/
|
|
167
197
|
|
|
168
|
-
addClass( cls: string ) {
|
|
198
|
+
addClass( cls: string ): this {
|
|
169
199
|
if( !cls ) return;
|
|
170
200
|
|
|
201
|
+
cls = cls.trim();
|
|
171
202
|
if( cls.indexOf(' ')>=0 ) {
|
|
172
203
|
const ccs = cls.split( " " );
|
|
173
204
|
this._dom.classList.add(...ccs);
|
|
@@ -175,6 +206,27 @@ class SvgItem {
|
|
|
175
206
|
else {
|
|
176
207
|
this._dom.classList.add(cls);
|
|
177
208
|
}
|
|
209
|
+
|
|
210
|
+
return this;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* remove a class
|
|
215
|
+
* @param name class name to remove
|
|
216
|
+
*/
|
|
217
|
+
|
|
218
|
+
removeClass( cls: string ): this {
|
|
219
|
+
if( !cls ) return;
|
|
220
|
+
|
|
221
|
+
if( cls.indexOf(' ')>=0 ) {
|
|
222
|
+
const ccs = cls.split( " " );
|
|
223
|
+
this._dom.classList.remove(...ccs);
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
this._dom.classList.remove(cls);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
return this;
|
|
178
230
|
}
|
|
179
231
|
|
|
180
232
|
/**
|
|
@@ -191,7 +243,13 @@ class SvgItem {
|
|
|
191
243
|
*/
|
|
192
244
|
|
|
193
245
|
transform( tr: string ): this {
|
|
194
|
-
this.
|
|
246
|
+
const t = this.getAttr( "transform" ) ?? "";
|
|
247
|
+
this.setAttr( "transform", t+' '+tr );
|
|
248
|
+
return this;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
clear_transform( ) {
|
|
252
|
+
this.setAttr( "transform", null );
|
|
195
253
|
return this;
|
|
196
254
|
}
|
|
197
255
|
|
|
@@ -243,6 +301,12 @@ export class SvgPath extends SvgItem {
|
|
|
243
301
|
return this;
|
|
244
302
|
}
|
|
245
303
|
|
|
304
|
+
reset( ) {
|
|
305
|
+
this._path = "";
|
|
306
|
+
super.reset( );
|
|
307
|
+
return this;
|
|
308
|
+
}
|
|
309
|
+
|
|
246
310
|
/**
|
|
247
311
|
* move the current pos
|
|
248
312
|
* @param x new pos x
|
|
@@ -267,6 +331,16 @@ export class SvgPath extends SvgItem {
|
|
|
267
331
|
return this._update( );
|
|
268
332
|
}
|
|
269
333
|
|
|
334
|
+
/**
|
|
335
|
+
* draw a curve
|
|
336
|
+
*/
|
|
337
|
+
|
|
338
|
+
curveTo( x1: number, y1: number, x2: number, y2: number, x3: number, y3: number ) {
|
|
339
|
+
this._path += clean`C${x1},${y1} ${x2},${y2} ${x3},${y3}`;
|
|
340
|
+
return this._update( );
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
|
|
270
344
|
/**
|
|
271
345
|
* close the currentPath
|
|
272
346
|
*/
|
|
@@ -286,13 +360,13 @@ export class SvgPath extends SvgItem {
|
|
|
286
360
|
* @returns this
|
|
287
361
|
*/
|
|
288
362
|
|
|
289
|
-
arc( x: number, y: number, r: number, start: number, end: number ): this {
|
|
363
|
+
arc( x: number, y: number, r: number, start: number, end: number, clockwise= true ): this {
|
|
290
364
|
|
|
291
365
|
const st = p2c( x, y, r, start-90 );
|
|
292
366
|
const en = p2c( x, y, r, end-90 );
|
|
293
367
|
|
|
294
|
-
const flag = end
|
|
295
|
-
this._path += clean`M${st.x},${st.y}A${r},${r} 0 ${flag} 1 ${en.x},${en.y}`;
|
|
368
|
+
const flag = ((end-start) <= 180 ? "0" : "1");
|
|
369
|
+
this._path += clean`M${st.x},${st.y}A${r},${r} 0 ${flag} ${(clockwise ? '1' : '0')} ${en.x},${en.y}`;
|
|
296
370
|
|
|
297
371
|
return this._update( );
|
|
298
372
|
}
|
|
@@ -353,6 +427,42 @@ export class SvgText extends SvgItem {
|
|
|
353
427
|
}
|
|
354
428
|
}
|
|
355
429
|
|
|
430
|
+
/**
|
|
431
|
+
*
|
|
432
|
+
*/
|
|
433
|
+
|
|
434
|
+
export class SvgIcon extends SvgItem {
|
|
435
|
+
constructor( svg: string ) {
|
|
436
|
+
super( "svg" );
|
|
437
|
+
|
|
438
|
+
if( svg.startsWith("data:image/svg+xml,") ) {
|
|
439
|
+
svg = svg.substring( 19 );
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
const parser = new DOMParser();
|
|
443
|
+
const doc = parser.parseFromString( decodeURIComponent(svg), "image/svg+xml");
|
|
444
|
+
|
|
445
|
+
const parserErrorElement = doc.querySelector("parsererror");
|
|
446
|
+
if( parserErrorElement ) {
|
|
447
|
+
console.error( "error while parsing svg:\n"+ parserErrorElement.textContent );
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
const svgRoot = doc.documentElement; // The <svg> element from the string
|
|
451
|
+
for( let i=0; i<svgRoot.attributes.length; i++) {
|
|
452
|
+
this._dom.setAttribute( svgRoot.attributes[i].name, svgRoot.attributes[i].value );
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
for( let i=0; i<svgRoot.childNodes.length; i++) {
|
|
456
|
+
const child = svgRoot.childNodes[i];
|
|
457
|
+
if (child.nodeType === 1) {
|
|
458
|
+
this._dom.appendChild(child);
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
|
|
465
|
+
|
|
356
466
|
/**
|
|
357
467
|
*
|
|
358
468
|
*/
|
|
@@ -420,6 +530,12 @@ export class SvgGroup extends SvgItem {
|
|
|
420
530
|
return item;
|
|
421
531
|
}
|
|
422
532
|
|
|
533
|
+
appendItems<K extends SvgItem>( items: K[] ) {
|
|
534
|
+
items.forEach( item => {
|
|
535
|
+
this._dom.appendChild( item.getDom() );
|
|
536
|
+
} );
|
|
537
|
+
}
|
|
538
|
+
|
|
423
539
|
/**
|
|
424
540
|
*
|
|
425
541
|
*/
|
|
@@ -434,7 +550,7 @@ export class SvgGroup extends SvgItem {
|
|
|
434
550
|
return this.append( text );
|
|
435
551
|
}
|
|
436
552
|
|
|
437
|
-
ellipse( x: number, y: number, r1: number, r2
|
|
553
|
+
ellipse( x: number, y: number, r1: number, r2: number ): SvgShape {
|
|
438
554
|
const shape = new SvgShape( 'ellipse' );
|
|
439
555
|
shape.setAttr( 'cx', num(x)+'' );
|
|
440
556
|
shape.setAttr( 'cy', num(y)+'' );
|
|
@@ -443,6 +559,24 @@ export class SvgGroup extends SvgItem {
|
|
|
443
559
|
return this.append( shape );
|
|
444
560
|
}
|
|
445
561
|
|
|
562
|
+
circle( x: number, y: number, r1: number ): SvgShape {
|
|
563
|
+
const shape = new SvgShape( 'ellipse' );
|
|
564
|
+
shape.setAttr( 'cx', num(x)+'' );
|
|
565
|
+
shape.setAttr( 'cy', num(y)+'' );
|
|
566
|
+
shape.setAttr( 'rx', num(r1)+'' );
|
|
567
|
+
shape.setAttr( 'ry', num(r1)+'' );
|
|
568
|
+
return this.append( shape );
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
icon( svg: string, x: number, y: number, w: number, h: number ): SvgIcon {
|
|
572
|
+
const icon = new SvgIcon( svg );
|
|
573
|
+
icon.setAttr( 'x', num(x)+'' );
|
|
574
|
+
icon.setAttr( 'y', num(y)+'' );
|
|
575
|
+
icon.setAttr( 'width', num(w)+'' );
|
|
576
|
+
icon.setAttr( 'height', num(h)+'' );
|
|
577
|
+
return this.append( icon );
|
|
578
|
+
}
|
|
579
|
+
|
|
446
580
|
rect( x: number, y: number, w: number, h: number ): SvgShape {
|
|
447
581
|
|
|
448
582
|
if( h<0 ) {
|
|
@@ -458,8 +592,12 @@ export class SvgGroup extends SvgItem {
|
|
|
458
592
|
return this.append( shape );
|
|
459
593
|
}
|
|
460
594
|
|
|
461
|
-
group( ) {
|
|
595
|
+
group( id?: string ) {
|
|
462
596
|
const group = new SvgGroup( );
|
|
597
|
+
if( id ) {
|
|
598
|
+
group.setAttr( 'id', id );
|
|
599
|
+
}
|
|
600
|
+
|
|
463
601
|
return this.append( group );
|
|
464
602
|
}
|
|
465
603
|
|
|
@@ -500,20 +638,35 @@ export class SvgGroup extends SvgItem {
|
|
|
500
638
|
|
|
501
639
|
export class SvgBuilder extends SvgGroup {
|
|
502
640
|
private static g_clip_id = 1;
|
|
641
|
+
private static g_pat_id = 1;
|
|
503
642
|
|
|
504
643
|
constructor( ) {
|
|
505
644
|
super( );
|
|
506
645
|
}
|
|
507
646
|
|
|
508
647
|
addClip( x: number, y: number, w: number, h: number ) {
|
|
509
|
-
|
|
510
|
-
const id = 'c-'+SvgBuilder.g_clip_id++;
|
|
648
|
+
const id = 'clip-'+SvgBuilder.g_clip_id++;
|
|
511
649
|
const clip = new SvgGroup( 'clipPath' );
|
|
512
650
|
clip.setAttr('id', id );
|
|
513
651
|
clip.rect( x, y, w, h );
|
|
514
652
|
|
|
515
653
|
this.append(clip);
|
|
516
|
-
return id;
|
|
654
|
+
return {id,clip};
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
addPattern( x: number, y: number, w: number, h: number ) {
|
|
658
|
+
const id = 'pat-'+SvgBuilder.g_pat_id++;
|
|
659
|
+
|
|
660
|
+
const pat = new SvgGroup( 'pattern' );
|
|
661
|
+
pat.setAttr( 'id', id );
|
|
662
|
+
pat.setAttr( 'x', num(x)+'' );
|
|
663
|
+
pat.setAttr( 'y', num(y)+'' );
|
|
664
|
+
pat.setAttr( 'width', num(w)+'' );
|
|
665
|
+
pat.setAttr( 'height', num(h)+'' );
|
|
666
|
+
pat.setAttr( 'patternUnits', "userSpaceOnUse" );
|
|
667
|
+
|
|
668
|
+
this.append(pat);
|
|
669
|
+
return {id,pat};
|
|
517
670
|
}
|
|
518
671
|
}
|
|
519
672
|
|
|
@@ -525,7 +678,7 @@ export class SvgBuilder extends SvgGroup {
|
|
|
525
678
|
|
|
526
679
|
interface SvgProps extends ComponentProps {
|
|
527
680
|
viewbox?: string;
|
|
528
|
-
svg
|
|
681
|
+
svg: SvgBuilder;
|
|
529
682
|
}
|
|
530
683
|
|
|
531
684
|
/**
|
|
@@ -540,11 +693,20 @@ export class SvgComponent<P extends SvgProps = SvgProps> extends Component<P> {
|
|
|
540
693
|
this.setAttribute( 'xmlns', SVG_NS );
|
|
541
694
|
|
|
542
695
|
if( props.viewbox ) {
|
|
543
|
-
this.setAttribute( "
|
|
696
|
+
this.setAttribute( "viewBox", props.viewbox );
|
|
544
697
|
}
|
|
545
698
|
|
|
546
699
|
if( props.svg ) {
|
|
547
700
|
this.dom.appendChild( props.svg.getDom() );
|
|
548
701
|
}
|
|
549
702
|
}
|
|
703
|
+
|
|
704
|
+
setSvg( bld: SvgBuilder ) {
|
|
705
|
+
this.clearContent( );
|
|
706
|
+
this.dom.appendChild( bld.getDom() );
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
addItems( ...items: SvgItem[] ) {
|
|
710
|
+
items.forEach( item => this.dom.appendChild( item.getDom() ) );
|
|
711
|
+
}
|
|
550
712
|
}
|