x4js 1.5.16 → 1.5.18

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.
Files changed (75) hide show
  1. package/lib/cjs/app_sockets.js +74 -0
  2. package/lib/cjs/index.js +1 -0
  3. package/lib/cjs/treeview.js +27 -12
  4. package/lib/cjs/version.js +1 -1
  5. package/lib/esm/app_sockets.js +70 -0
  6. package/lib/esm/index.mjs +1 -0
  7. package/lib/esm/treeview.js +26 -12
  8. package/lib/esm/version.js +1 -1
  9. package/lib/{src/version.ts → types/app_sockets.d.ts} +29 -30
  10. package/lib/types/index.d.ts +1 -0
  11. package/lib/types/treeview.d.ts +5 -2
  12. package/lib/types/version.d.ts +1 -1
  13. package/package.json +1 -4
  14. package/lib/src/MIT-license.md +0 -14
  15. package/lib/src/action.ts +0 -88
  16. package/lib/src/alpha.jpg +0 -0
  17. package/lib/src/application.ts +0 -251
  18. package/lib/src/autocomplete.ts +0 -197
  19. package/lib/src/base64.ts +0 -166
  20. package/lib/src/base_component.ts +0 -152
  21. package/lib/src/button.ts +0 -355
  22. package/lib/src/calendar.ts +0 -328
  23. package/lib/src/canvas.ts +0 -505
  24. package/lib/src/cardview.ts +0 -227
  25. package/lib/src/checkbox.ts +0 -188
  26. package/lib/src/color.ts +0 -752
  27. package/lib/src/colorpicker.ts +0 -1639
  28. package/lib/src/combobox.ts +0 -465
  29. package/lib/src/component.ts +0 -2329
  30. package/lib/src/datastore.ts +0 -1322
  31. package/lib/src/dialog.ts +0 -656
  32. package/lib/src/dom_events.ts +0 -315
  33. package/lib/src/drag_manager.ts +0 -199
  34. package/lib/src/drawtext.ts +0 -355
  35. package/lib/src/fileupload.ts +0 -213
  36. package/lib/src/form.ts +0 -375
  37. package/lib/src/formatters.ts +0 -105
  38. package/lib/src/gridview.ts +0 -1185
  39. package/lib/src/i18n.ts +0 -346
  40. package/lib/src/icon.ts +0 -335
  41. package/lib/src/image.ts +0 -204
  42. package/lib/src/index.ts +0 -88
  43. package/lib/src/input.ts +0 -249
  44. package/lib/src/label.ts +0 -128
  45. package/lib/src/layout.ts +0 -430
  46. package/lib/src/link.ts +0 -86
  47. package/lib/src/listview.ts +0 -765
  48. package/lib/src/md5.ts +0 -438
  49. package/lib/src/menu.ts +0 -425
  50. package/lib/src/messagebox.ts +0 -224
  51. package/lib/src/panel.ts +0 -86
  52. package/lib/src/popup.ts +0 -494
  53. package/lib/src/property_editor.ts +0 -337
  54. package/lib/src/radiobtn.ts +0 -197
  55. package/lib/src/rating.ts +0 -135
  56. package/lib/src/request.ts +0 -300
  57. package/lib/src/router.ts +0 -185
  58. package/lib/src/settings.ts +0 -77
  59. package/lib/src/sidebarview.ts +0 -103
  60. package/lib/src/spreadsheet.ts +0 -1449
  61. package/lib/src/styles.ts +0 -343
  62. package/lib/src/svgcomponent.ts +0 -577
  63. package/lib/src/tabbar.ts +0 -151
  64. package/lib/src/tabview.ts +0 -110
  65. package/lib/src/textarea.ts +0 -235
  66. package/lib/src/textedit.ts +0 -544
  67. package/lib/src/toaster.ts +0 -80
  68. package/lib/src/tools.ts +0 -1473
  69. package/lib/src/tooltips.ts +0 -191
  70. package/lib/src/treeview.ts +0 -696
  71. package/lib/src/x4.less +0 -2243
  72. package/lib/src/x4dom.ts +0 -57
  73. package/lib/src/x4events.ts +0 -585
  74. package/lib/src/x4react.ts +0 -90
  75. package/lib/x4.css +0 -1780
package/lib/src/i18n.ts DELETED
@@ -1,346 +0,0 @@
1
- /**
2
- * ___ ___ __
3
- * \ \/ / / _
4
- * \ / /_| |_
5
- * / \____ _|
6
- * /__/\__\ |_|
7
- *
8
- * @file i18n.ts
9
- * @author Etienne Cochard
10
- *
11
- * Copyright (c) 2019-2022 R-libre ingenierie
12
- *
13
- * Permission is hereby granted, free of charge, to any person obtaining a copy
14
- * of this software and associated documentation files (the "Software"), to deal
15
- * in the Software without restriction, including without limitation the rights
16
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
17
- * of the Software, and to permit persons to whom the Software is furnished to do so,
18
- * subject to the following conditions:
19
- * The above copyright notice and this permission notice shall be included in all copies
20
- * or substantial portions of the Software.
21
- *
22
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
23
- * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
24
- * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
25
- * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
27
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28
- **/
29
-
30
-
31
-
32
-
33
- /**
34
- * language definition
35
- */
36
-
37
- interface Language {
38
- name: string;
39
- base: string;
40
- src_translations: any;
41
- translations: any;
42
- }
43
-
44
- const sym_lang = Symbol( "i18n" );
45
-
46
- let languages: Record<string,Language> = {
47
- };
48
-
49
- /**
50
- * create a new language
51
- * @param name language name (code)
52
- * @param base base language (code)
53
- * @example:
54
- * ```js
55
- * createLanguage( 'en', 'fr' );
56
- * ```
57
- */
58
-
59
- export function createLanguage( name: string, base: string ) {
60
- languages[name] = {
61
- name,
62
- base,
63
- src_translations: {},
64
- translations: {}
65
- };
66
- }
67
-
68
- /**
69
- * check if the given language is known
70
- * @param name language name (code)
71
- */
72
-
73
- export function isLanguage( name: string ): boolean {
74
- return languages[name]!==undefined;
75
- }
76
-
77
- /**
78
- * build the language with given fragments
79
- * @param name language name (code)
80
- * @param parts misc elements that make the language
81
- * @example:
82
- * ```js
83
- * createLanguage( 'en', 'fr' );
84
- * const app = {
85
- * clients: {
86
- * translation1: "hello",
87
- * }
88
- * }
89
- * addTranslation( 'en', app );
90
- * ```
91
- */
92
-
93
- export function addTranslation( name, ...parts ) {
94
-
95
- if( !isLanguage(name) ) {
96
- return;
97
- }
98
-
99
- const lang = languages[name];
100
-
101
- parts.forEach( p => {
102
- _patch( lang.src_translations, p, lang.base );
103
- } );
104
-
105
- lang.translations = _mk_proxy( lang.src_translations, lang.base, true );
106
- }
107
-
108
- /**
109
- *
110
- */
111
-
112
- function _patch( obj: any, by: any, def: string ) {
113
- for( let n in by ) {
114
- if( obj[n] instanceof Object ) {
115
- _patch( obj[n], by[n], def );
116
- }
117
- else {
118
- obj[n] = by[n];
119
- obj[n] = _mk_proxy( obj[n], def, false );
120
- }
121
- }
122
-
123
- return obj;
124
- }
125
-
126
- /**
127
- * when we ask for _tr.xxx
128
- * reqpath is set to [xxx]
129
- *
130
- * then when we try to get _tr.xxx.yyy
131
- * reqpath is [xxx,yyy]
132
- * if yyy is not found, we try with base langage for the full reqpath
133
- * until no base found
134
- */
135
-
136
- let req_path: (string | symbol)[];
137
-
138
- /**
139
- *
140
- */
141
-
142
- function _findBaseTrans( base ) {
143
-
144
- while( base ) {
145
- const lang = languages[base];
146
- let trans = lang.translations;
147
- let value;
148
-
149
- for( const p of req_path ) {
150
- value = trans[p];
151
- if( value===undefined ) {
152
- break;
153
- }
154
-
155
- trans = value;
156
- }
157
-
158
- if( value!==undefined ) {
159
- return trans;
160
- }
161
-
162
- base = lang.base;
163
- }
164
-
165
- console.error( "I18N error: unable to find", '_tr.'+req_path.join('.') );
166
- return undefined;
167
- }
168
-
169
- /**
170
- *
171
- */
172
-
173
- function _mk_proxy( obj: any, base: string, root: boolean ) : any {
174
- return new Proxy( obj, {
175
- get: (target, prop) => {
176
- if( root ) {
177
- req_path = [prop];
178
- }
179
- else {
180
- req_path.push( prop );
181
- }
182
-
183
- let value = target[prop];
184
- if( value===undefined && base ) {
185
- value = _findBaseTrans( base );
186
- // keep it for later
187
- target[prop] = value;
188
- }
189
- return value;
190
- }
191
- });
192
- }
193
-
194
- export let _tr: any = {};
195
-
196
- /**
197
- * select the given language as current
198
- * @param name laguage name (code)
199
- */
200
-
201
- export function selectLanguage( name: string ) {
202
-
203
- if( !isLanguage(name) ) {
204
- return;
205
- }
206
-
207
- _tr = languages[name].translations;
208
- _tr[sym_lang] = name;
209
- }
210
-
211
- /**
212
- *
213
- */
214
-
215
- export function getCurrentLanguage( ): string {
216
- return _tr[sym_lang];
217
- }
218
-
219
- /**
220
- *
221
- */
222
-
223
- export function getAvailableLanguages( ): string[] {
224
- return Object.keys( languages );
225
- }
226
-
227
-
228
-
229
-
230
- /**
231
- * language definition
232
- * x4 specific strings
233
- */
234
-
235
- let fr = {
236
- global: {
237
- ok: 'OK',
238
- cancel: 'Annuler',
239
- ignore: 'Ignorer',
240
- yes: 'Oui',
241
- no: 'Non',
242
-
243
- open: 'Ouvrir',
244
- new: 'Nouveau',
245
- delete: 'Supprimer',
246
- close: 'Fermer',
247
- save: 'Enregistrer',
248
-
249
- search: 'Rechercher',
250
- search_tip: 'Saisissez le texte à rechercher. <b>Enter</b> pour lancer la recherche. <b>Esc</b> pour annuler.',
251
-
252
- required_field: "information requise",
253
- invalid_format: "format invalide",
254
- invalid_email: 'adresse mail invalide',
255
- invalid_number: 'valeur numérique invalide',
256
-
257
- diff_date_seconds: '{0} secondes',
258
- diff_date_minutes: '{0} minutes',
259
- diff_date_hours: '{0} heures',
260
-
261
- invalid_date: 'Date non reconnue ({0})',
262
- empty_list: 'Liste vide',
263
-
264
- date_input_formats: 'd/m/y|d.m.y|d m y|d-m-y|dmy',
265
- date_format: 'D/M/Y',
266
-
267
- day_short: [ 'dim', 'lun', 'mar', 'mer', 'jeu', 'ven', 'sam' ],
268
- day_long: [ 'dimanche', 'lundi', 'mardi', 'mercredi', 'jeudi', 'vendredi', 'samedi' ],
269
-
270
- month_short: [ 'jan', 'fév', 'mar', 'avr', 'mai', 'jun', 'jui', 'aoû', 'sep', 'oct', 'nov', 'déc' ],
271
- month_long: [ 'janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet', 'août', 'septembre', 'octobre', 'novembre', 'décembre' ],
272
-
273
- property: 'Propriété',
274
- value: 'Valeur',
275
-
276
- err_403: `Vous n'avez pas les droits suffisants pour effectuer cette action`,
277
-
278
- copy: 'Copier',
279
- cut: 'Couper',
280
- paste: 'Coller'
281
- }
282
- };
283
-
284
- /** @ignore */
285
-
286
- let en = {
287
- global: {
288
- ok: 'OK',
289
- cancel: 'Cancel',
290
- ignore: 'Ignore',
291
- yes: 'Yes',
292
- no: 'No',
293
-
294
- open: 'Open',
295
- new: 'New',
296
- delete: 'Delete',
297
- close: 'Close',
298
- save: 'Save',
299
-
300
- search: 'Search',
301
- search_tip: 'Type in the text to search. <b>Enter</b> to start the search. <b>Esc</b> to cancel.',
302
-
303
- required_field: "missing information",
304
- invalid_format: "invalid format",
305
- invalid_email: 'invalid email address',
306
- invalid_number: 'bad numeric value',
307
-
308
- diff_date_seconds: '{0} seconds',
309
- diff_date_minutes: '{0} minutes',
310
- diff_date_hours: '{0} hours',
311
-
312
- invalid_date: 'Unrecognized date({0})',
313
- empty_list: 'Empty list',
314
-
315
- date_input_formats: 'm/d/y|m.d.y|m d y|m-d-y|mdy',
316
- date_format: 'M/D/Y',
317
-
318
- day_short: [ 'sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat' ],
319
- day_long: [ 'sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday' ],
320
-
321
- month_short: [ 'jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jui', 'aug', 'sep', 'oct', 'nov', 'dec' ],
322
- month_long: [ 'january', 'february', 'march', 'april', 'mau', 'june', 'jully', 'august', 'september', 'october', 'november', 'december' ],
323
-
324
- property: 'Property',
325
- value: 'Value',
326
-
327
- err_403: `You do not have sufficient rights to do that action`,
328
-
329
- copy: 'Copy',
330
- cut: 'Cut',
331
- paste: 'Paste'
332
- }
333
- };
334
-
335
- createLanguage( 'fr', null );
336
- addTranslation( 'fr', fr );
337
-
338
- createLanguage( 'en', 'fr' );
339
- addTranslation( 'en', en );
340
-
341
- selectLanguage( 'fr' ); // by default
342
-
343
-
344
-
345
-
346
-
package/lib/src/icon.ts DELETED
@@ -1,335 +0,0 @@
1
- /**
2
- * ___ ___ __
3
- * \ \/ / / _
4
- * \ / /_| |_
5
- * / \____ _|
6
- * /__/\__\ |_|
7
- *
8
- * @file icon.ts
9
- * @author Etienne Cochard
10
- *
11
- * Copyright (c) 2019-2022 R-libre ingenierie
12
- *
13
- * Permission is hereby granted, free of charge, to any person obtaining a copy
14
- * of this software and associated documentation files (the "Software"), to deal
15
- * in the Software without restriction, including without limitation the rights
16
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
17
- * of the Software, and to permit persons to whom the Software is furnished to do so,
18
- * subject to the following conditions:
19
- * The above copyright notice and this permission notice shall be included in all copies
20
- * or substantial portions of the Software.
21
- *
22
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
23
- * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
24
- * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
25
- * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
27
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28
- **/
29
-
30
- import { Component, CProps } from './component'
31
- import { Stylesheet } from './styles'
32
- import { HtmlString, isString } from './tools';
33
- import { BasicEvent, EvChange, EventMap, EventSource } from './x4events';
34
-
35
- // ============================================================================
36
- // [ICON]
37
- // ============================================================================
38
-
39
- export type IconID = string | number;
40
-
41
- export interface IconProps extends CProps {
42
- icon: IconID;
43
- size?: number;
44
- }
45
-
46
- export interface EvLoaded extends BasicEvent {
47
- url: string;
48
- svg: string;
49
- }
50
-
51
- export function EvLoaded( url: string, svg: string, context = null ) {
52
- return BasicEvent<EvLoaded>({ url, svg, context });
53
- }
54
-
55
- interface LoadingEventMap extends EventMap {
56
- loaded: EvLoaded;
57
- }
58
-
59
- function trimQuotes( str:string ): string {
60
- const l = str.length;
61
- if( str[0]=='"' && str[l-1]=='"' ) {
62
- str = str.substring( 1, l-1 )
63
- str = str.replaceAll( '\\"', "'" );
64
- return str;
65
- }
66
-
67
- return str;
68
- }
69
-
70
- class Loader extends EventSource<LoadingEventMap> {
71
- svgs: Map<string,string>;
72
-
73
- constructor( ) {
74
- super( );
75
- this.svgs = new Map( );
76
- }
77
-
78
- load( url: string ) {
79
- if( this.svgs.has(url) ) {
80
- const svg = this.svgs.get( url );
81
- if( svg ) {
82
- //console.log( 'cached=', url );
83
- this.signal( 'loaded', EvLoaded(url,svg) );
84
- }
85
- }
86
- else {
87
- // mark it as loading
88
- this.svgs.set( url, null );
89
-
90
- // then start loading
91
- const _load = async ( url ) => {
92
-
93
- // shortcut
94
- if( url.substring(0,24)=="data:image/svg+xml;utf8,") {
95
- const svg = url.substring(24);
96
- this.svgs.set( url, svg );
97
- this.signal( 'loaded', EvLoaded(url,svg) );
98
- }
99
- else {
100
- const r = await fetch( url );
101
- if( r.ok ) {
102
- const svg = await r.text();
103
- // check response, must be svg
104
- //TODO: find better
105
- if (!svg.startsWith("<svg") && !svg.startsWith('<?xml') ) {
106
- console.error( "svg loading error: ", svg );
107
- this.signal( 'loaded', EvLoaded(url,"") );
108
- }
109
- else {
110
- this.svgs.set( url, svg );
111
- this.signal( 'loaded', EvLoaded(url,svg) );
112
- }
113
- }
114
- }
115
- }
116
-
117
- _load( url );
118
- }
119
- }
120
- }
121
-
122
- const svgLoader = new Loader( );
123
-
124
-
125
- /**
126
- * standard icon
127
- */
128
- export class Icon extends Component<IconProps>
129
- {
130
- private m_icon: string;
131
- private m_iconName: IconID;
132
-
133
- constructor( props: IconProps | string ) {
134
-
135
- if( isString(props) ) {
136
- super( { icon: props } );
137
- }
138
- else {
139
- super( props );
140
- }
141
-
142
- this._setIcon( this.m_props.icon, false );
143
- if( this.m_props.size ) {
144
- this.setStyleValue( 'fontSize', this.m_props.size );
145
- }
146
- }
147
-
148
- private _setIcon(icon: IconID, remove_old: boolean) {
149
-
150
- if( !icon ) {
151
- this.m_iconName = '';
152
- return;
153
- }
154
-
155
- this.removeClass( '@svg' );
156
-
157
- // todo: deprecated
158
- let name, url: string;
159
- if (typeof (icon) === 'number') {
160
- icon = icon.toString(16);
161
- name = icon;
162
- console.error( "deprecation error: invalid icon name" );
163
- }
164
- else {
165
- // var( <var-name> )
166
- //
167
- // in the .css
168
- // --------------------------
169
- // :root {
170
- // --chevron-up: data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512"><path d="M0 96C0 78.33 14.33 64 32 64H416C433.7 64 448 78.33 448 96C448 113.7 433.7 128 416 128H32C14.33 128 0 113.7 0 96z"/></svg>';
171
- // }
172
- //
173
- // var( "--chevron-up" )
174
- const reVar = /\s*var\s*\(\s*(.+)\s*\)\s*/gi;
175
- let match_var = reVar.exec( icon );
176
- while( match_var ) {
177
- const varname = match_var[1].trim( );
178
- icon = (Stylesheet.getVar(varname) as string).trim( );
179
- if (icon == '' || icon === undefined) {
180
- console.error( `icon: unable to find variable named '${varname}'` );
181
- return;
182
- }
183
- else {
184
- icon = trimQuotes( icon );
185
- }
186
-
187
- match_var = reVar.exec( icon );
188
- }
189
-
190
- // <svg ...>
191
- if( icon.startsWith('<svg') ) {
192
- this._setSVG( 'data:image/svg+xml;utf8,'+icon);
193
- return;
194
- }
195
-
196
- // svg( <svg-filename> ) -> svg( "mysvgfile.svg" )
197
- // <svg-filename>.svg -> "mysvgfile.svg"
198
-
199
- const reSvg = /\s*svg\s*\(\s*(.+)\s*\)\s*/gi;
200
- const reSvg2 = /(.*\.svg)$/gi;
201
-
202
- let match_svg = reSvg.exec( icon ) || reSvg2.exec(icon);
203
- if( match_svg ) {
204
- const url = match_svg[1].trim( );
205
- this._setSVG( url );
206
- return;
207
- }
208
-
209
- // data( <direct> )
210
- // data( "data:image/svg+xml;utf8,<svg...></svg>" )
211
-
212
- const reSvg4 = /^\s*(data\:image\/.+)\s*$/gi;
213
- let match_dta = reSvg4.exec( icon );
214
- if( match_dta ) {
215
- this._setSVG( match_dta[1] );
216
- return;
217
- }
218
-
219
- // cls( "fas fa-angle-up" )
220
- //
221
- const reCls = /\s*cls\s*\(\s*(.+)\s*\)\s*/gi;
222
- let match_cls = reCls.exec( icon );
223
- if( match_cls ) {
224
- const classes = match_cls[1].trim( );
225
- this.addClass( classes );
226
- return;
227
- }
228
-
229
- // url( "www.google.com" )
230
- //
231
- const reUrl = /\s*url\s*\(\s*(.+)\s*\)\s*/gi;
232
- let match_url = reUrl.exec( icon );
233
- if( match_url ) {
234
- url = trimQuotes( match_url[1].trim( ) );
235
- // this value is escaped
236
- url = url.replaceAll( "\\", "" );
237
- this._setSVG( url );
238
- return;
239
- }
240
- else {
241
- // todo: deprecated
242
- console.error( "deprecation error: invalid icon name" );
243
-
244
- name = icon;
245
- icon = Stylesheet.getVar( 'icon-'+icon ) as string;
246
-
247
- if( icon=='' || icon===undefined ) {
248
- // name your icon 'icon-xxx'
249
- // ex:
250
- // :root { --icon-zoom-p: f00e; }
251
- icon = '0';
252
- }
253
- }
254
- }
255
-
256
- this.m_iconName = name;
257
- if( this.m_icon===icon ) {
258
- return;
259
- }
260
-
261
- let css = Component.getCss(),
262
- rulename: string;
263
-
264
- if (remove_old && this.m_icon) {
265
- rulename = 'icon-' + name;
266
- this.removeClass(rulename);
267
- }
268
-
269
- // generate dynamic css icon rule
270
- rulename = 'icon-' + name;
271
-
272
- if( Icon.icon_cache[rulename]===undefined ) {
273
- Icon.icon_cache[rulename] = true;
274
-
275
- let rule: string;
276
-
277
- if( url ) {
278
- rule = `display: block; content: ' '; background-image: url(${url}); background-size: contain; width: 100%; height: 100%; background-repeat: no-repeat; color: white;`;
279
- }
280
- else {
281
- rule = `content: "\\${icon}";`;
282
- }
283
-
284
- css.setRule(rulename, `.${rulename}::before {${rule}}`);
285
- }
286
-
287
- this.addClass(rulename);
288
- this.m_icon = icon;
289
- }
290
-
291
- /**
292
- * change the icon
293
- * @param icon - new icon
294
- */
295
-
296
- public set icon( icon: IconID ) {
297
- this._setIcon( icon, true );
298
- }
299
-
300
- public get icon( ) : IconID {
301
- return this.m_iconName;
302
- }
303
-
304
- private _setSVG( url: string ) {
305
-
306
- const set = ( ev: EvLoaded ) => {
307
- //console.log( 'set=', ev.url, 'url=', url );
308
-
309
- if( ev.url==url ) {
310
- this.addClass( '@svg-icon' );
311
- this.setContent( HtmlString.from(ev.svg), false );
312
- svgLoader.off( 'loaded', set );
313
- }
314
- }
315
-
316
- svgLoader.on( 'loaded', set );
317
- svgLoader.load( url );
318
- }
319
-
320
- /**
321
- * todo: try to extract viewbox
322
- */
323
-
324
- private _setSVGPath( pth: string ) {
325
- this.addClass( '@svg-icon' );
326
- this.setContent( HtmlString.from(`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor"><path d="${pth}/></svg>`), false );
327
- }
328
-
329
- /**
330
- *
331
- */
332
-
333
- private static icon_cache = [];
334
- }
335
-