x4js 1.4.17 → 1.4.21
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/README.md +4 -3
- package/lib/application.d.ts +1 -1
- package/lib/application.js +4 -3
- package/lib/base_component.d.ts +1 -1
- package/lib/base_component.js +3 -3
- package/lib/button.d.ts +1 -1
- package/lib/button.js +3 -3
- package/lib/calendar.d.ts +1 -1
- package/lib/calendar.js +5 -4
- package/lib/canvas.d.ts +1 -1
- package/lib/canvas.js +2 -2
- package/lib/cardview.d.ts +1 -1
- package/lib/cardview.js +2 -2
- package/lib/checkbox.d.ts +1 -1
- package/lib/checkbox.js +2 -2
- package/lib/colorpicker.d.ts +1 -1
- package/lib/colorpicker.js +5 -5
- package/lib/combobox.d.ts +1 -1
- package/lib/combobox.js +3 -3
- package/lib/component.d.ts +1 -5
- package/lib/component.js +35 -39
- package/lib/datastore.d.ts +1 -1
- package/lib/datastore.js +5 -5
- package/lib/dialog.d.ts +1 -1
- package/lib/dialog.js +4 -3
- package/lib/drag_manager.js +30 -1
- package/lib/fileupload.js +2 -1
- package/lib/form.d.ts +1 -1
- package/lib/gridview.d.ts +1 -5
- package/lib/gridview.js +8 -7
- package/lib/i18n.d.ts +35 -33
- package/lib/i18n.js +180 -93
- package/lib/icon.d.ts +1 -1
- package/lib/icon.js +19 -16
- package/lib/image.js +4 -3
- package/lib/index.d.ts +1 -4
- package/lib/index.js +4 -4
- package/lib/input.js +1 -1
- package/lib/link.d.ts +1 -1
- package/lib/link.js +2 -2
- package/lib/listview.d.ts +1 -1
- package/lib/listview.js +10 -9
- package/lib/menu.d.ts +1 -1
- package/lib/menu.js +5 -4
- package/lib/popup.d.ts +1 -1
- package/lib/popup.js +13 -12
- package/lib/property_editor.d.ts +1 -1
- package/lib/property_editor.js +2 -2
- package/lib/radiobtn.d.ts +1 -1
- package/lib/radiobtn.js +4 -3
- package/lib/rating.d.ts +1 -1
- package/lib/rating.js +2 -2
- package/lib/router.d.ts +1 -1
- package/lib/router.js +5 -4
- package/lib/spreadsheet.d.ts +1 -1
- package/lib/spreadsheet.js +9 -8
- package/lib/styles.js +6 -5
- package/lib/svgcomponent.d.ts +1 -1
- package/lib/svgcomponent.js +4 -1
- package/lib/tabbar.d.ts +1 -1
- package/lib/tabbar.js +2 -2
- package/lib/textarea.d.ts +1 -1
- package/lib/textarea.js +2 -2
- package/lib/textedit.d.ts +1 -1
- package/lib/textedit.js +5 -4
- package/lib/tools.d.ts +1 -0
- package/lib/tools.js +15 -6
- package/lib/tooltips.js +6 -5
- package/lib/treeview.d.ts +1 -1
- package/lib/treeview.js +8 -8
- package/lib/x4dom.d.ts +49 -0
- package/lib/x4dom.js +32 -0
- package/lib/x4events.d.ts +266 -0
- package/lib/x4events.js +389 -0
- package/package.json +4 -3
- package/src/application.ts +5 -4
- package/src/base_component.ts +1 -1
- package/src/button.ts +1 -1
- package/src/calendar.ts +5 -3
- package/src/canvas.ts +1 -1
- package/src/cardview.ts +1 -1
- package/src/checkbox.ts +1 -1
- package/src/colorpicker.ts +1 -1
- package/src/combobox.ts +1 -1
- package/src/component.ts +34 -39
- package/src/datastore.ts +1 -1
- package/src/dialog.ts +4 -2
- package/src/drag_manager.ts +4 -1
- package/src/fileupload.ts +2 -1
- package/src/form.ts +1 -1
- package/src/gridview.ts +4 -3
- package/src/hosts/electron.ts +4 -1
- package/src/i18n.ts +234 -97
- package/src/icon.ts +18 -16
- package/src/image.ts +5 -3
- package/src/index.ts +4 -4
- package/src/input.ts +1 -1
- package/src/layout.ts +1 -1
- package/src/link.ts +1 -1
- package/src/listview.ts +6 -4
- package/src/menu.ts +5 -3
- package/src/popup.ts +14 -12
- package/src/property_editor.ts +1 -1
- package/src/radiobtn.ts +4 -2
- package/src/rating.ts +1 -1
- package/src/router.ts +4 -2
- package/src/smartedit.ts +3 -2
- package/src/spreadsheet.ts +8 -6
- package/src/styles.ts +7 -5
- package/src/svgcomponent.ts +4 -1
- package/src/tabbar.ts +1 -1
- package/src/textarea.ts +1 -1
- package/src/textedit.ts +4 -2
- package/src/tools.ts +15 -5
- package/src/tooltips.ts +7 -5
- package/src/treeview.ts +1 -1
- package/src/x4dom.ts +57 -0
- package/src/{x4_events.ts → x4events.ts} +1 -1
- package/tsconfig.json +11 -1
package/lib/drag_manager.js
CHANGED
|
@@ -1,6 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* ___ ___ __
|
|
4
|
+
* \ \_/ / / _
|
|
5
|
+
* \ / /_| |_
|
|
6
|
+
* / _ \____ _|
|
|
7
|
+
* /__/ \__\ |_|
|
|
8
|
+
*
|
|
9
|
+
* @file drag_manager.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
|
+
**/
|
|
2
30
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
31
|
exports.dragManager = void 0;
|
|
32
|
+
const x4dom_1 = require("./x4dom");
|
|
4
33
|
const x_drag_cb = Symbol('x-drag-cb');
|
|
5
34
|
/**
|
|
6
35
|
*
|
|
@@ -19,7 +48,7 @@ class DragManager {
|
|
|
19
48
|
this.dragSource = el;
|
|
20
49
|
this.dragGhost = el.dom.cloneNode(true);
|
|
21
50
|
this.dragGhost.classList.add('dragged');
|
|
22
|
-
|
|
51
|
+
x4dom_1.x4document.body.appendChild(this.dragGhost);
|
|
23
52
|
el.addClass('dragging');
|
|
24
53
|
ev.dataTransfer.setData('text/string', '1');
|
|
25
54
|
ev.dataTransfer.setDragImage(new Image(), 0, 0);
|
package/lib/fileupload.js
CHANGED
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
**/
|
|
30
30
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
31
|
exports.saveFile = exports.openFile = exports.ImageUpload = exports.FileUpload = void 0;
|
|
32
|
+
const x4dom_1 = require("./x4dom");
|
|
32
33
|
const component_1 = require("./component");
|
|
33
34
|
const layout_1 = require("./layout");
|
|
34
35
|
const input_1 = require("./input");
|
|
@@ -125,7 +126,7 @@ function _createFileInput() {
|
|
|
125
126
|
}
|
|
126
127
|
});
|
|
127
128
|
// ajoute un input type:file caché pour pouvoir choir un fichier a ouvrir
|
|
128
|
-
|
|
129
|
+
x4dom_1.x4document.body.appendChild(g_file_input._build());
|
|
129
130
|
}
|
|
130
131
|
g_file_input.clearDomEvent('change');
|
|
131
132
|
return g_file_input;
|
package/lib/form.d.ts
CHANGED
|
@@ -30,7 +30,7 @@ import { Component, Container, CProps, ContainerEventMap, ComponentContent } fro
|
|
|
30
30
|
import { HLayout, VLayout } from './layout';
|
|
31
31
|
import { Button } from './button';
|
|
32
32
|
import { RequestProps } from './request';
|
|
33
|
-
import { EventCallback } from './
|
|
33
|
+
import { EventCallback } from './x4events';
|
|
34
34
|
import { EvBtnClick } from './dialog';
|
|
35
35
|
export declare type FormBtn = 'ok' | 'cancel' | 'ignore' | 'yes' | 'no' | 'close' | 'save' | 'dontsave';
|
|
36
36
|
export declare type FormButtons = (FormBtn | Button | Component)[];
|
package/lib/gridview.d.ts
CHANGED
|
@@ -26,16 +26,12 @@
|
|
|
26
26
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
27
27
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
28
28
|
**/
|
|
29
|
-
/**
|
|
30
|
-
* todo: sizable column
|
|
31
|
-
* todo: button in a column
|
|
32
|
-
*/
|
|
33
29
|
import { VLayout } from './layout';
|
|
34
30
|
import { Component, ContainerEventMap, EvDblClick, CProps, HtmlString } from './component';
|
|
35
31
|
import { Label } from './label';
|
|
36
32
|
import * as Formatters from './formatters';
|
|
37
33
|
import { DataView, DataStore, Record } from './datastore';
|
|
38
|
-
import { EvContextMenu, EvSelectionChange, BasicEvent, EventDisposer } from "./
|
|
34
|
+
import { EvContextMenu, EvSelectionChange, BasicEvent, EventDisposer } from "./x4events";
|
|
39
35
|
export interface EvGridCheck extends BasicEvent {
|
|
40
36
|
rec: Record;
|
|
41
37
|
chk: boolean;
|
package/lib/gridview.js
CHANGED
|
@@ -34,16 +34,17 @@ const T_UPDATE = Symbol('update');
|
|
|
34
34
|
* todo: sizable column
|
|
35
35
|
* todo: button in a column
|
|
36
36
|
*/
|
|
37
|
+
const x4dom_1 = require("./x4dom");
|
|
37
38
|
const layout_1 = require("./layout");
|
|
38
39
|
const component_1 = require("./component");
|
|
39
40
|
const label_1 = require("./label");
|
|
40
41
|
const i18n_1 = require("./i18n");
|
|
41
42
|
const tools_1 = require("./tools");
|
|
42
43
|
const datastore_1 = require("./datastore");
|
|
43
|
-
const
|
|
44
|
+
const x4events_1 = require("./x4events");
|
|
44
45
|
const icon_js_1 = require("./icon.js");
|
|
45
46
|
function EvGridCheck(rec, chk) {
|
|
46
|
-
return (0,
|
|
47
|
+
return (0, x4events_1.BasicEvent)({ rec, chk });
|
|
47
48
|
}
|
|
48
49
|
exports.EvGridCheck = EvGridCheck;
|
|
49
50
|
class ColHeader extends component_1.Component {
|
|
@@ -449,9 +450,9 @@ class GridView extends layout_1.VLayout {
|
|
|
449
450
|
*
|
|
450
451
|
*/
|
|
451
452
|
_computeItemHeight() {
|
|
452
|
-
let gr =
|
|
453
|
+
let gr = x4dom_1.x4document.createElement('div');
|
|
453
454
|
gr.classList.add('x-row');
|
|
454
|
-
let gv =
|
|
455
|
+
let gv = x4dom_1.x4document.createElement('div');
|
|
455
456
|
gv.classList.add('x-grid-view');
|
|
456
457
|
gv.style.position = 'absolute';
|
|
457
458
|
gv.style.top = '-1000px';
|
|
@@ -743,17 +744,17 @@ class GridView extends layout_1.VLayout {
|
|
|
743
744
|
dom_item.addClass('@selected');
|
|
744
745
|
}
|
|
745
746
|
let rec = this.m_dataview.getById(item);
|
|
746
|
-
this.emit('selectionChange', (0,
|
|
747
|
+
this.emit('selectionChange', (0, x4events_1.EvSelectionChange)(rec));
|
|
747
748
|
}
|
|
748
749
|
else {
|
|
749
|
-
this.emit('selectionChange', (0,
|
|
750
|
+
this.emit('selectionChange', (0, x4events_1.EvSelectionChange)(null));
|
|
750
751
|
}
|
|
751
752
|
}
|
|
752
753
|
/**
|
|
753
754
|
*
|
|
754
755
|
*/
|
|
755
756
|
_showItemContextMenu(event, item) {
|
|
756
|
-
this.emit('contextMenu', (0,
|
|
757
|
+
this.emit('contextMenu', (0, x4events_1.EvContextMenu)(event, item));
|
|
757
758
|
}
|
|
758
759
|
/**
|
|
759
760
|
*
|
package/lib/i18n.d.ts
CHANGED
|
@@ -27,45 +27,47 @@
|
|
|
27
27
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
28
28
|
**/
|
|
29
29
|
/**
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* @
|
|
33
|
-
*
|
|
30
|
+
* create a new language
|
|
31
|
+
* @param name language name (code)
|
|
32
|
+
* @param base base language (code)
|
|
33
|
+
* @example:
|
|
34
|
+
* ```js
|
|
35
|
+
* createLanguage( 'en', 'fr' );
|
|
36
|
+
* ```
|
|
34
37
|
*/
|
|
35
|
-
export declare
|
|
38
|
+
export declare function createLanguage(name: string, base: string): void;
|
|
39
|
+
/**
|
|
40
|
+
* check if the given language is known
|
|
41
|
+
* @param name language name (code)
|
|
42
|
+
*/
|
|
43
|
+
export declare function isLanguage(name: string): boolean;
|
|
36
44
|
/**
|
|
37
|
-
*
|
|
38
|
-
* @param name
|
|
39
|
-
* @
|
|
40
|
-
*
|
|
45
|
+
* build the language with given fragments
|
|
46
|
+
* @param name language name (code)
|
|
47
|
+
* @param parts misc elements that make the language
|
|
48
|
+
* @example:
|
|
49
|
+
* ```js
|
|
50
|
+
* createLanguage( 'en', 'fr' );
|
|
51
|
+
* const app = {
|
|
52
|
+
* clients: {
|
|
53
|
+
* translation1: "hello",
|
|
54
|
+
* }
|
|
41
55
|
* }
|
|
56
|
+
* addTranslation( 'en', app );
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export declare function addTranslation(name: any, ...parts: any[]): void;
|
|
60
|
+
export declare let _tr: any;
|
|
61
|
+
/**
|
|
62
|
+
* select the given language as current
|
|
63
|
+
* @param name laguage name (code)
|
|
42
64
|
*/
|
|
43
|
-
export declare function
|
|
65
|
+
export declare function selectLanguage(name: string): void;
|
|
44
66
|
/**
|
|
45
|
-
*
|
|
46
|
-
* @param name - language name
|
|
47
|
-
* @example ```typescript
|
|
48
|
-
* selectLanguage( 'en' );
|
|
67
|
+
*
|
|
49
68
|
*/
|
|
50
|
-
export declare function
|
|
69
|
+
export declare function getCurrentLanguage(): string;
|
|
51
70
|
/**
|
|
52
|
-
* define a translation
|
|
53
|
-
* you can also patch 'global' elements witch are defined by x4
|
|
54
|
-
* @param name - language name
|
|
55
|
-
* @param definition - definition of the language
|
|
56
|
-
* @example ```typescript
|
|
57
|
-
* setTranslation( 'fr', {
|
|
58
|
-
* this_is_an_example: 'ceci est un exemple',
|
|
59
|
-
* this_is: {
|
|
60
|
-
* another_example: 'ceci est un autre exemple'
|
|
61
|
-
* },
|
|
62
|
-
* global: {
|
|
63
|
-
* ok: 'O.K.'
|
|
64
|
-
* }
|
|
65
|
-
* });
|
|
66
|
-
* console.log( _tr.this_is_an_example ); // defined by the previous line
|
|
67
|
-
* selectLanguage( 'en' );
|
|
68
|
-
* console.log( _tr.this_is_an_example ); // 'en' do not define this, so we get 'fr' one
|
|
69
71
|
*
|
|
70
72
|
*/
|
|
71
|
-
export declare function
|
|
73
|
+
export declare function getAvailableLanguages(): string[];
|
package/lib/i18n.js
CHANGED
|
@@ -28,7 +28,158 @@
|
|
|
28
28
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
29
29
|
**/
|
|
30
30
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
-
exports.
|
|
31
|
+
exports.getAvailableLanguages = exports.getCurrentLanguage = exports.selectLanguage = exports._tr = exports.addTranslation = exports.isLanguage = exports.createLanguage = void 0;
|
|
32
|
+
const sym_lang = Symbol("i18n");
|
|
33
|
+
let languages = {};
|
|
34
|
+
/**
|
|
35
|
+
* create a new language
|
|
36
|
+
* @param name language name (code)
|
|
37
|
+
* @param base base language (code)
|
|
38
|
+
* @example:
|
|
39
|
+
* ```js
|
|
40
|
+
* createLanguage( 'en', 'fr' );
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
function createLanguage(name, base) {
|
|
44
|
+
languages[name] = {
|
|
45
|
+
name,
|
|
46
|
+
base,
|
|
47
|
+
src_translations: {},
|
|
48
|
+
translations: {}
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
exports.createLanguage = createLanguage;
|
|
52
|
+
/**
|
|
53
|
+
* check if the given language is known
|
|
54
|
+
* @param name language name (code)
|
|
55
|
+
*/
|
|
56
|
+
function isLanguage(name) {
|
|
57
|
+
return languages[name] !== undefined;
|
|
58
|
+
}
|
|
59
|
+
exports.isLanguage = isLanguage;
|
|
60
|
+
/**
|
|
61
|
+
* build the language with given fragments
|
|
62
|
+
* @param name language name (code)
|
|
63
|
+
* @param parts misc elements that make the language
|
|
64
|
+
* @example:
|
|
65
|
+
* ```js
|
|
66
|
+
* createLanguage( 'en', 'fr' );
|
|
67
|
+
* const app = {
|
|
68
|
+
* clients: {
|
|
69
|
+
* translation1: "hello",
|
|
70
|
+
* }
|
|
71
|
+
* }
|
|
72
|
+
* addTranslation( 'en', app );
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
function addTranslation(name, ...parts) {
|
|
76
|
+
if (!isLanguage(name)) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const lang = languages[name];
|
|
80
|
+
parts.forEach(p => {
|
|
81
|
+
_patch(lang.src_translations, p, lang.base);
|
|
82
|
+
});
|
|
83
|
+
lang.translations = _mk_proxy(lang.src_translations, lang.base, true);
|
|
84
|
+
}
|
|
85
|
+
exports.addTranslation = addTranslation;
|
|
86
|
+
/**
|
|
87
|
+
*
|
|
88
|
+
*/
|
|
89
|
+
function _patch(obj, by, def) {
|
|
90
|
+
for (let n in by) {
|
|
91
|
+
if (obj[n] instanceof Object) {
|
|
92
|
+
_patch(obj[n], by[n], def);
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
obj[n] = by[n];
|
|
96
|
+
obj[n] = _mk_proxy(obj[n], def, false);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return obj;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* when we ask for _tr.xxx
|
|
103
|
+
* reqpath is set to [xxx]
|
|
104
|
+
*
|
|
105
|
+
* then when we try to get _tr.xxx.yyy
|
|
106
|
+
* reqpath is [xxx,yyy]
|
|
107
|
+
* if yyy is not found, we try with base langage for the full reqpath
|
|
108
|
+
* until no base found
|
|
109
|
+
*/
|
|
110
|
+
let req_path;
|
|
111
|
+
/**
|
|
112
|
+
*
|
|
113
|
+
*/
|
|
114
|
+
function _findBaseTrans(base) {
|
|
115
|
+
while (base) {
|
|
116
|
+
const lang = languages[base];
|
|
117
|
+
let trans = lang.translations;
|
|
118
|
+
let value;
|
|
119
|
+
for (const p of req_path) {
|
|
120
|
+
value = trans[p];
|
|
121
|
+
if (value === undefined) {
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
trans = value;
|
|
125
|
+
}
|
|
126
|
+
if (value !== undefined) {
|
|
127
|
+
return trans;
|
|
128
|
+
}
|
|
129
|
+
base = lang.base;
|
|
130
|
+
}
|
|
131
|
+
console.error("I18N error: unable to find", '_tr.' + req_path.join('.'));
|
|
132
|
+
return undefined;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
*
|
|
136
|
+
*/
|
|
137
|
+
function _mk_proxy(obj, base, root) {
|
|
138
|
+
return new Proxy(obj, {
|
|
139
|
+
get: (target, prop) => {
|
|
140
|
+
if (root) {
|
|
141
|
+
req_path = [prop];
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
req_path.push(prop);
|
|
145
|
+
}
|
|
146
|
+
let value = target[prop];
|
|
147
|
+
if (value === undefined && base) {
|
|
148
|
+
value = _findBaseTrans(base);
|
|
149
|
+
// keep it for later
|
|
150
|
+
target[prop] = value;
|
|
151
|
+
}
|
|
152
|
+
return value;
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
exports._tr = {};
|
|
157
|
+
/**
|
|
158
|
+
* select the given language as current
|
|
159
|
+
* @param name laguage name (code)
|
|
160
|
+
*/
|
|
161
|
+
function selectLanguage(name) {
|
|
162
|
+
if (!isLanguage(name)) {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
exports._tr = languages[name].translations;
|
|
166
|
+
exports._tr[sym_lang] = name;
|
|
167
|
+
}
|
|
168
|
+
exports.selectLanguage = selectLanguage;
|
|
169
|
+
/**
|
|
170
|
+
*
|
|
171
|
+
*/
|
|
172
|
+
function getCurrentLanguage() {
|
|
173
|
+
return exports._tr[sym_lang];
|
|
174
|
+
}
|
|
175
|
+
exports.getCurrentLanguage = getCurrentLanguage;
|
|
176
|
+
/**
|
|
177
|
+
*
|
|
178
|
+
*/
|
|
179
|
+
function getAvailableLanguages() {
|
|
180
|
+
return Object.keys(languages);
|
|
181
|
+
}
|
|
182
|
+
exports.getAvailableLanguages = getAvailableLanguages;
|
|
32
183
|
/**
|
|
33
184
|
* language definition
|
|
34
185
|
* x4 specific strings
|
|
@@ -51,9 +202,9 @@ let fr = {
|
|
|
51
202
|
invalid_format: "format invalide",
|
|
52
203
|
invalid_email: 'adresse mail invalide',
|
|
53
204
|
invalid_number: 'valeur numérique invalide',
|
|
54
|
-
diff_date_seconds: '{0}
|
|
205
|
+
diff_date_seconds: '{0} secondes',
|
|
55
206
|
diff_date_minutes: '{0} minutes',
|
|
56
|
-
diff_date_hours: '{0}
|
|
207
|
+
diff_date_hours: '{0} heures',
|
|
57
208
|
invalid_date: 'Date non reconnue ({0})',
|
|
58
209
|
empty_list: 'Liste vide',
|
|
59
210
|
date_input_formats: 'd/m/y|d.m.y|d m y|d-m-y|dmy',
|
|
@@ -78,102 +229,38 @@ let en = {
|
|
|
78
229
|
ignore: 'Ignore',
|
|
79
230
|
yes: 'Yes',
|
|
80
231
|
no: 'No',
|
|
81
|
-
|
|
232
|
+
open: 'Open',
|
|
233
|
+
new: 'New',
|
|
234
|
+
delete: 'Delete',
|
|
235
|
+
close: 'Close',
|
|
236
|
+
save: 'Save',
|
|
237
|
+
search: 'Search',
|
|
238
|
+
search_tip: 'Type in the text to search. <b>Enter</b> to start the search. <b>Esc</b> to cancel.',
|
|
239
|
+
required_field: "missing information",
|
|
82
240
|
invalid_format: "invalid format",
|
|
241
|
+
invalid_email: 'invalid email address',
|
|
242
|
+
invalid_number: 'bad numeric value',
|
|
83
243
|
diff_date_seconds: '{0} seconds',
|
|
84
244
|
diff_date_minutes: '{0} minutes',
|
|
85
245
|
diff_date_hours: '{0} hours',
|
|
86
|
-
invalid_date: '
|
|
246
|
+
invalid_date: 'Unrecognized date({0})',
|
|
247
|
+
empty_list: 'Empty list',
|
|
248
|
+
date_input_formats: 'm/d/y|m.d.y|m d y|m-d-y|mdy',
|
|
249
|
+
date_format: 'M/D/Y',
|
|
250
|
+
day_short: ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'],
|
|
251
|
+
day_long: ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'],
|
|
252
|
+
month_short: ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jui', 'aug', 'sep', 'oct', 'nov', 'dec'],
|
|
253
|
+
month_long: ['january', 'february', 'march', 'april', 'mau', 'june', 'jully', 'august', 'september', 'october', 'november', 'december'],
|
|
254
|
+
property: 'Property',
|
|
255
|
+
value: 'Value',
|
|
256
|
+
err_403: `You do not have sufficient rights to do that action`,
|
|
87
257
|
copy: 'Copy',
|
|
88
258
|
cut: 'Cut',
|
|
89
259
|
paste: 'Paste'
|
|
90
260
|
}
|
|
91
261
|
};
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* current language
|
|
99
|
-
* FR by default
|
|
100
|
-
* @example ```typescript
|
|
101
|
-
* console.log( _tr.global.ok );
|
|
102
|
-
*/
|
|
103
|
-
exports._tr = all_langs['fr'];
|
|
104
|
-
/**
|
|
105
|
-
* check if the language is known
|
|
106
|
-
* @param name - language name to test
|
|
107
|
-
* @example ```typescript
|
|
108
|
-
* if( isLanguage('fr') ) {
|
|
109
|
-
* }
|
|
110
|
-
*/
|
|
111
|
-
function isLanguage(name) {
|
|
112
|
-
return all_langs[name] !== undefined;
|
|
113
|
-
}
|
|
114
|
-
exports.isLanguage = isLanguage;
|
|
115
|
-
/**
|
|
116
|
-
* select the current language
|
|
117
|
-
* @param name - language name
|
|
118
|
-
* @example ```typescript
|
|
119
|
-
* selectLanguage( 'en' );
|
|
120
|
-
*/
|
|
121
|
-
function selectLanguage(name) {
|
|
122
|
-
if (!isLanguage(name)) {
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
exports._tr = all_langs[name];
|
|
126
|
-
}
|
|
127
|
-
exports.selectLanguage = selectLanguage;
|
|
128
|
-
/**
|
|
129
|
-
* define a translation
|
|
130
|
-
* you can also patch 'global' elements witch are defined by x4
|
|
131
|
-
* @param name - language name
|
|
132
|
-
* @param definition - definition of the language
|
|
133
|
-
* @example ```typescript
|
|
134
|
-
* setTranslation( 'fr', {
|
|
135
|
-
* this_is_an_example: 'ceci est un exemple',
|
|
136
|
-
* this_is: {
|
|
137
|
-
* another_example: 'ceci est un autre exemple'
|
|
138
|
-
* },
|
|
139
|
-
* global: {
|
|
140
|
-
* ok: 'O.K.'
|
|
141
|
-
* }
|
|
142
|
-
* });
|
|
143
|
-
* console.log( _tr.this_is_an_example ); // defined by the previous line
|
|
144
|
-
* selectLanguage( 'en' );
|
|
145
|
-
* console.log( _tr.this_is_an_example ); // 'en' do not define this, so we get 'fr' one
|
|
146
|
-
*
|
|
147
|
-
*/
|
|
148
|
-
function extendTranslation(name, definition) {
|
|
149
|
-
if (!isLanguage(name)) {
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
|
-
_patch(all_langs[name], definition);
|
|
153
|
-
}
|
|
154
|
-
exports.extendTranslation = extendTranslation;
|
|
155
|
-
function _patch(obj, by) {
|
|
156
|
-
for (let n in by) {
|
|
157
|
-
if (obj[n] instanceof Object) {
|
|
158
|
-
_patch(obj[n], by[n]);
|
|
159
|
-
}
|
|
160
|
-
else {
|
|
161
|
-
obj[n] = by[n];
|
|
162
|
-
if (obj[n] instanceof Object) {
|
|
163
|
-
obj[n] = _mk_proxy(obj[n]);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
return obj;
|
|
168
|
-
}
|
|
169
|
-
function _mk_proxy(obj) {
|
|
170
|
-
return new Proxy(obj, {
|
|
171
|
-
get: function (target, prop, receiver) {
|
|
172
|
-
let value = target[prop];
|
|
173
|
-
if (value === undefined) {
|
|
174
|
-
return fr[prop];
|
|
175
|
-
}
|
|
176
|
-
return value;
|
|
177
|
-
}
|
|
178
|
-
});
|
|
179
|
-
}
|
|
262
|
+
createLanguage('fr', null);
|
|
263
|
+
addTranslation('fr', fr);
|
|
264
|
+
createLanguage('en', 'fr');
|
|
265
|
+
addTranslation('en', en);
|
|
266
|
+
selectLanguage('fr'); // by default
|
package/lib/icon.d.ts
CHANGED
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
28
28
|
**/
|
|
29
29
|
import { Component, CProps } from './component';
|
|
30
|
-
import { BasicEvent } from './
|
|
30
|
+
import { BasicEvent } from './x4events';
|
|
31
31
|
export declare type IconID = string | number;
|
|
32
32
|
export interface IconProps extends CProps {
|
|
33
33
|
icon: IconID;
|
package/lib/icon.js
CHANGED
|
@@ -32,9 +32,9 @@ exports.Icon = exports.EvLoaded = void 0;
|
|
|
32
32
|
const component_1 = require("./component");
|
|
33
33
|
const styles_1 = require("./styles");
|
|
34
34
|
const tools_1 = require("./tools");
|
|
35
|
-
const
|
|
35
|
+
const x4events_1 = require("./x4events");
|
|
36
36
|
function EvLoaded(url, svg, context = null) {
|
|
37
|
-
return (0,
|
|
37
|
+
return (0, x4events_1.BasicEvent)({ url, svg, context });
|
|
38
38
|
}
|
|
39
39
|
exports.EvLoaded = EvLoaded;
|
|
40
40
|
function trimQuotes(str) {
|
|
@@ -46,7 +46,7 @@ function trimQuotes(str) {
|
|
|
46
46
|
}
|
|
47
47
|
return str;
|
|
48
48
|
}
|
|
49
|
-
class Loader extends
|
|
49
|
+
class Loader extends x4events_1.EventSource {
|
|
50
50
|
svgs;
|
|
51
51
|
constructor() {
|
|
52
52
|
super();
|
|
@@ -75,9 +75,15 @@ class Loader extends x4_events_1.EventSource {
|
|
|
75
75
|
const r = await fetch(url);
|
|
76
76
|
if (r.ok) {
|
|
77
77
|
const svg = await r.text();
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
// check response, must be svg
|
|
79
|
+
if (!svg.startsWith("<svg")) {
|
|
80
|
+
console.error("svg loading error: ", svg);
|
|
81
|
+
this.signal('loaded', EvLoaded(url, ""));
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
this.svgs.set(url, svg);
|
|
85
|
+
this.signal('loaded', EvLoaded(url, svg));
|
|
86
|
+
}
|
|
81
87
|
}
|
|
82
88
|
}
|
|
83
89
|
};
|
|
@@ -115,6 +121,7 @@ class Icon extends component_1.Component {
|
|
|
115
121
|
if (typeof (icon) === 'number') {
|
|
116
122
|
icon = icon.toString(16);
|
|
117
123
|
name = icon;
|
|
124
|
+
console.error("deprecation error: invalid icon name");
|
|
118
125
|
}
|
|
119
126
|
else {
|
|
120
127
|
// var( <var-name> )
|
|
@@ -122,7 +129,7 @@ class Icon extends component_1.Component {
|
|
|
122
129
|
// in the .css
|
|
123
130
|
// --------------------------
|
|
124
131
|
// :root {
|
|
125
|
-
// --chevron-up:
|
|
132
|
+
// --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>';
|
|
126
133
|
// }
|
|
127
134
|
//
|
|
128
135
|
// var( "--chevron-up" )
|
|
@@ -150,14 +157,6 @@ class Icon extends component_1.Component {
|
|
|
150
157
|
this._setSVG(url);
|
|
151
158
|
return;
|
|
152
159
|
}
|
|
153
|
-
// svgpath( <svg-path> )
|
|
154
|
-
// svgpath( "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" )
|
|
155
|
-
const reSvg3 = /\s*svgpath\s*\(\s*(.+)\s*\)\s*/gi;
|
|
156
|
-
let match_pth = reSvg3.exec(icon);
|
|
157
|
-
if (match_pth) {
|
|
158
|
-
const pth = this._setSVGPath(match_pth[1].trim());
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
160
|
// data( <direct> )
|
|
162
161
|
// data( "data:image/svg+xml;utf8,<svg...></svg>" )
|
|
163
162
|
const reSvg4 = /^\s*(data\:image\/.+)\s*$/gi;
|
|
@@ -166,6 +165,8 @@ class Icon extends component_1.Component {
|
|
|
166
165
|
this._setSVG(match_dta[1]);
|
|
167
166
|
return;
|
|
168
167
|
}
|
|
168
|
+
// cls( "fas fa-angle-up" )
|
|
169
|
+
//
|
|
169
170
|
const reCls = /\s*cls\s*\(\s*(.+)\s*\)\s*/gi;
|
|
170
171
|
let match_cls = reCls.exec(icon);
|
|
171
172
|
if (match_cls) {
|
|
@@ -173,6 +174,8 @@ class Icon extends component_1.Component {
|
|
|
173
174
|
this.addClass(classes);
|
|
174
175
|
return;
|
|
175
176
|
}
|
|
177
|
+
// url( "www.google.com" )
|
|
178
|
+
//
|
|
176
179
|
const reUrl = /\s*url\s*\(\s*(.+)\s*\)\s*/gi;
|
|
177
180
|
let match_url = reUrl.exec(icon);
|
|
178
181
|
if (match_url) {
|
|
@@ -187,13 +190,13 @@ class Icon extends component_1.Component {
|
|
|
187
190
|
}
|
|
188
191
|
else {
|
|
189
192
|
// todo: deprecated
|
|
193
|
+
console.error("deprecation error: invalid icon name");
|
|
190
194
|
name = icon;
|
|
191
195
|
icon = styles_1.Stylesheet.getVar('icon-' + icon);
|
|
192
196
|
if (icon == '' || icon === undefined) {
|
|
193
197
|
// name your icon 'icon-xxx'
|
|
194
198
|
// ex:
|
|
195
199
|
// :root { --icon-zoom-p: f00e; }
|
|
196
|
-
console.assert(false);
|
|
197
200
|
icon = '0';
|
|
198
201
|
}
|
|
199
202
|
}
|
package/lib/image.js
CHANGED
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
**/
|
|
30
30
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
31
|
exports.Image = void 0;
|
|
32
|
+
const x4dom_1 = require("./x4dom");
|
|
32
33
|
const component_1 = require("./component");
|
|
33
34
|
const emptyImageSrc = 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==';
|
|
34
35
|
function _isStaticImage(src) {
|
|
@@ -126,7 +127,7 @@ class Image extends component_1.Component {
|
|
|
126
127
|
Image.lazy_images_waiting.forEach((el) => {
|
|
127
128
|
let dom = el.dom, src = el.src;
|
|
128
129
|
// skip deleted elements
|
|
129
|
-
if (!dom ||
|
|
130
|
+
if (!dom || dom.offsetParent === null) {
|
|
130
131
|
// do not append to newList
|
|
131
132
|
return;
|
|
132
133
|
}
|
|
@@ -134,8 +135,8 @@ class Image extends component_1.Component {
|
|
|
134
135
|
// if it is visible & inserted inside the document
|
|
135
136
|
if (!done && dom.offsetParent !== null &&
|
|
136
137
|
rc.bottom >= 0 && rc.right >= 0 &&
|
|
137
|
-
rc.top <= (window.innerHeight ||
|
|
138
|
-
rc.left <= (window.innerWidth ||
|
|
138
|
+
rc.top <= (window.innerHeight || x4dom_1.x4document.documentElement.clientHeight) &&
|
|
139
|
+
rc.left <= (window.innerWidth || x4dom_1.x4document.documentElement.clientWidth)) {
|
|
139
140
|
// ok, we load the image
|
|
140
141
|
let img = dom.firstChild;
|
|
141
142
|
img.setAttribute('src', src);
|