x4js 1.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (176) hide show
  1. package/lib/application.d.ts +95 -0
  2. package/lib/application.js +137 -0
  3. package/lib/base64.d.ts +31 -0
  4. package/lib/base64.js +135 -0
  5. package/lib/base_component.d.ts +64 -0
  6. package/lib/base_component.js +77 -0
  7. package/lib/button.d.ts +145 -0
  8. package/lib/button.js +235 -0
  9. package/lib/calendar.d.ts +77 -0
  10. package/lib/calendar.js +236 -0
  11. package/lib/canvas.d.ts +88 -0
  12. package/lib/canvas.js +354 -0
  13. package/lib/cardview.d.ts +83 -0
  14. package/lib/cardview.js +152 -0
  15. package/lib/checkbox.d.ts +72 -0
  16. package/lib/checkbox.js +126 -0
  17. package/lib/color.d.ts +144 -0
  18. package/lib/color.js +584 -0
  19. package/lib/colorpicker.d.ts +98 -0
  20. package/lib/colorpicker.js +1457 -0
  21. package/lib/combobox.d.ts +97 -0
  22. package/lib/combobox.js +246 -0
  23. package/lib/component.d.ts +572 -0
  24. package/lib/component.js +1712 -0
  25. package/lib/datastore.d.ts +392 -0
  26. package/lib/datastore.js +986 -0
  27. package/lib/dialog.d.ts +171 -0
  28. package/lib/dialog.js +468 -0
  29. package/lib/dom_events.d.ts +284 -0
  30. package/lib/dom_events.js +13 -0
  31. package/lib/drag_manager.d.ts +26 -0
  32. package/lib/drag_manager.js +118 -0
  33. package/lib/drawtext.d.ts +43 -0
  34. package/lib/drawtext.js +261 -0
  35. package/lib/fileupload.d.ts +60 -0
  36. package/lib/fileupload.js +158 -0
  37. package/lib/form.d.ts +122 -0
  38. package/lib/form.js +293 -0
  39. package/lib/formatters.d.ts +31 -0
  40. package/lib/formatters.js +75 -0
  41. package/lib/gridview.d.ts +171 -0
  42. package/lib/gridview.js +786 -0
  43. package/lib/hosts/host.d.ts +44 -0
  44. package/lib/hosts/host.js +69 -0
  45. package/lib/i18n.d.ts +67 -0
  46. package/lib/i18n.js +169 -0
  47. package/lib/icon.d.ts +56 -0
  48. package/lib/icon.js +173 -0
  49. package/lib/image.d.ts +51 -0
  50. package/lib/image.js +149 -0
  51. package/lib/index.js +1 -0
  52. package/lib/input.d.ts +86 -0
  53. package/lib/input.js +172 -0
  54. package/lib/label.d.ts +54 -0
  55. package/lib/label.js +86 -0
  56. package/lib/layout.d.ts +77 -0
  57. package/lib/layout.js +261 -0
  58. package/lib/link.d.ts +46 -0
  59. package/lib/link.js +55 -0
  60. package/lib/listview.d.ts +173 -0
  61. package/lib/listview.js +532 -0
  62. package/lib/md5.d.ts +56 -0
  63. package/lib/md5.js +397 -0
  64. package/lib/menu.d.ts +122 -0
  65. package/lib/menu.js +276 -0
  66. package/lib/messagebox.d.ts +64 -0
  67. package/lib/messagebox.js +141 -0
  68. package/lib/panel.d.ts +42 -0
  69. package/lib/panel.js +61 -0
  70. package/lib/popup.d.ts +71 -0
  71. package/lib/popup.js +373 -0
  72. package/lib/property_editor.d.ts +67 -0
  73. package/lib/property_editor.js +247 -0
  74. package/lib/radiobtn.d.ts +68 -0
  75. package/lib/radiobtn.js +131 -0
  76. package/lib/rating.d.ts +49 -0
  77. package/lib/rating.js +93 -0
  78. package/lib/request.d.ts +48 -0
  79. package/lib/request.js +220 -0
  80. package/lib/router.d.ts +13 -0
  81. package/lib/router.js +27 -0
  82. package/lib/settings.d.ts +33 -0
  83. package/lib/settings.js +63 -0
  84. package/lib/sidebarview.d.ts +44 -0
  85. package/lib/sidebarview.js +73 -0
  86. package/lib/smartedit.d.ts +103 -0
  87. package/lib/smartedit.js +381 -0
  88. package/lib/spreadsheet.d.ts +214 -0
  89. package/lib/spreadsheet.js +1073 -0
  90. package/lib/styles.d.ts +81 -0
  91. package/lib/styles.js +262 -0
  92. package/lib/svgcomponent.d.ts +165 -0
  93. package/lib/svgcomponent.js +350 -0
  94. package/lib/tabbar.d.ts +41 -0
  95. package/lib/tabbar.js +66 -0
  96. package/lib/tabview.d.ts +45 -0
  97. package/lib/tabview.js +79 -0
  98. package/lib/textarea.d.ts +59 -0
  99. package/lib/textarea.js +119 -0
  100. package/lib/textedit.d.ts +118 -0
  101. package/lib/textedit.js +406 -0
  102. package/lib/texthiliter.d.ts +56 -0
  103. package/lib/texthiliter.js +219 -0
  104. package/lib/toaster.d.ts +38 -0
  105. package/lib/toaster.js +58 -0
  106. package/lib/tools.d.ts +382 -0
  107. package/lib/tools.js +1096 -0
  108. package/lib/tooltips.d.ts +42 -0
  109. package/lib/tooltips.js +148 -0
  110. package/lib/treeview.d.ts +128 -0
  111. package/lib/treeview.js +490 -0
  112. package/lib/x4_events.d.ts +253 -0
  113. package/lib/x4_events.js +363 -0
  114. package/package.json +21 -0
  115. package/src/README.md +2 -0
  116. package/src/application.ts +191 -0
  117. package/src/base64.ts +162 -0
  118. package/src/base_component.ts +118 -0
  119. package/src/button.ts +327 -0
  120. package/src/calendar.ts +312 -0
  121. package/src/canvas.ts +501 -0
  122. package/src/cardview.ts +220 -0
  123. package/src/checkbox.ts +178 -0
  124. package/src/color.ts +748 -0
  125. package/src/colorpicker.ts +1618 -0
  126. package/src/combobox.ts +348 -0
  127. package/src/component.ts +2330 -0
  128. package/src/datastore.ts +1318 -0
  129. package/src/dialog.ts +631 -0
  130. package/src/dom_events.ts +297 -0
  131. package/src/drag_manager.ts +168 -0
  132. package/src/drawtext.ts +342 -0
  133. package/src/fileupload.ts +208 -0
  134. package/src/form.ts +362 -0
  135. package/src/formatters.ts +96 -0
  136. package/src/gridview.ts +1051 -0
  137. package/src/hosts/electron.ts +161 -0
  138. package/src/hosts/host.ts +100 -0
  139. package/src/hosts/nwjs.ts +141 -0
  140. package/src/hosts/nwjs_types.ts +339 -0
  141. package/src/i18n.ts +205 -0
  142. package/src/icon.ts +237 -0
  143. package/src/image.ts +198 -0
  144. package/src/input.ts +236 -0
  145. package/src/label.ts +124 -0
  146. package/src/layout.ts +366 -0
  147. package/src/link.ts +82 -0
  148. package/src/listview.ts +749 -0
  149. package/src/md5.ts +432 -0
  150. package/src/menu.ts +394 -0
  151. package/src/messagebox.ts +199 -0
  152. package/src/panel.ts +81 -0
  153. package/src/popup.ts +488 -0
  154. package/src/property_editor.ts +333 -0
  155. package/src/radiobtn.ts +190 -0
  156. package/src/rating.ts +131 -0
  157. package/src/request.ts +296 -0
  158. package/src/router.ts +43 -0
  159. package/src/settings.ts +75 -0
  160. package/src/sidebarview.ts +97 -0
  161. package/src/smartedit.ts +532 -0
  162. package/src/spreadsheet.ts +1423 -0
  163. package/src/styles.ts +332 -0
  164. package/src/svgcomponent.ts +440 -0
  165. package/src/tabbar.ts +105 -0
  166. package/src/tabview.ts +106 -0
  167. package/src/textarea.ts +183 -0
  168. package/src/textedit.ts +535 -0
  169. package/src/texthiliter.ts +284 -0
  170. package/src/toaster.ts +76 -0
  171. package/src/tools.ts +1391 -0
  172. package/src/tooltips.ts +185 -0
  173. package/src/treeview.ts +670 -0
  174. package/src/x4.less +1940 -0
  175. package/src/x4_events.ts +558 -0
  176. package/tsconfig.json +14 -0
@@ -0,0 +1,339 @@
1
+ /**
2
+ * @file nwjs.ts
3
+ * @author Etienne Cochard
4
+ * @license
5
+ * Copyright (c) 2019-2021 R-libre ingenierie
6
+ *
7
+ * This program is free software; you can redistribute it and/or modify
8
+ * it under the terms of the GNU General Public License as published by
9
+ * the Free Software Foundation; either version 3 of the License, or
10
+ * (at your option) any later version.
11
+ *
12
+ * This program is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ * GNU General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
18
+ **/
19
+
20
+ declare namespace nw {
21
+
22
+ const App: NWApp;
23
+
24
+ class NWApp {
25
+ public readonly argv: string[];
26
+ public readonly fullArgv: string[];
27
+ public readonly filteredArgv: string[];
28
+ public readonly startPath: string;
29
+ public readonly manifest: object;
30
+ public readonly dataPath: string;
31
+
32
+ clearCache(): void;
33
+ clearAppCache(manifest_url: string): void;
34
+ closeAllWindows(): void;
35
+ crashBrowser(): void;
36
+ crashRenderer(): void;
37
+ getProxyForURL(url: string): void;
38
+ setProxyConfig(config: string, pac_url: string): void;
39
+ quit(): void;
40
+ setCrashDumpDir(dir: string): void;
41
+ addOriginAccessWhitelistEntry(sourceOrigin: string, destinationProtocol: string, destinationHost: string, allowDestinationSubdomain: boolean): void;
42
+ removeOriginAccessWhitelistEntry(sourceOrigin: string, destinationProtocol: string, destinationHost: string, allowDestinationSubdomain: boolean): void;
43
+ registerGlobalHotKey(shortcut: Shortcut): void;
44
+ unregisterGlobalHotKey(shortcut: Shortcut): void;
45
+ on(event: "open", listener: (args: string) => void): this;
46
+ on(event: "reopen", listener: () => void): this;
47
+ }
48
+
49
+ namespace Shortcut {
50
+ interface IShortcutOptions {
51
+ key: string;
52
+ active?: Function;
53
+ failed?: Function;
54
+ }
55
+ }
56
+
57
+ class Shortcut {
58
+ public active?: Function;
59
+ public failed?: Function;
60
+ public key: string;
61
+ constructor(option: {
62
+ key: string;
63
+ active?: Function;
64
+ failed?: Function;
65
+ });
66
+ on(name: "active", ...args: any[]): this;
67
+ on(name: "failed", ...args: any[]): this;
68
+ }
69
+
70
+ namespace Clipboard {
71
+ function get(): Clipboard;
72
+ interface IClipboardData {
73
+ data: string;
74
+ type?: "text" | "png" | "jpeg" | "html" | "rtf";
75
+ raw?: boolean;
76
+ }
77
+ }
78
+
79
+ class Clipboard {
80
+ set(data: string, type?: "text" | "png" | "jpeg" | "html" | "rtf", raw?: boolean): this;
81
+ set(clipboardData: Clipboard.IClipboardData): this;
82
+ set(clipboardDataList: Clipboard.IClipboardData[]): this;
83
+ get(type?: string, raw?: boolean): string;
84
+ get(clipboardData: Clipboard.IClipboardData): string;
85
+ get(clipboardDataList: Clipboard.IClipboardData[]): Clipboard.IClipboardData[];
86
+ readAvailableTypes(): "text" | "png" | "jpeg" | "html" | "rtf"[];
87
+ clear(): this;
88
+ }
89
+
90
+ class MenuItem {
91
+ public readonly type: "normal" | "checkbox" | "separator";
92
+ public label: string;
93
+ public icon: string;
94
+ public iconIsTemplate: boolean;
95
+ public tooltip: string;
96
+ public checked: boolean;
97
+ public enabled: boolean;
98
+ public readonly submenu: Menu;
99
+ public click: Function;
100
+ public key: string;
101
+ public modifiers: string;
102
+ constructor(option?: {
103
+ label?: string;
104
+ icon?: string;
105
+ tooltip?: string;
106
+ type?: "normal" | "checkbox" | "separator";
107
+ click?: Function;
108
+ enabled?: boolean;
109
+ checked?: boolean;
110
+ submenu?: Menu;
111
+ key?: string;
112
+ modifiers?: string;
113
+ });
114
+ on(event: "click", listener: (...args: any[]) => void): this;
115
+ }
116
+
117
+ class Menu {
118
+ public items: MenuItem[];
119
+ constructor(option?: {
120
+ type?: string;
121
+ });
122
+ append(item: MenuItem): this;
123
+ insert(item: MenuItem, i: number): this;
124
+ remove(item: MenuItem): this;
125
+ removeAt(i: number): this;
126
+ popup(x: number, y: number): this;
127
+ createMacBuiltin(appname: string, options?: {
128
+ hideEdit?: boolean;
129
+ hideWindow?: boolean;
130
+ }): this;
131
+ }
132
+
133
+ interface IScreenData {
134
+ id: number;
135
+ bounds: {
136
+ x: number;
137
+ y: number;
138
+ width: number;
139
+ height: number;
140
+ };
141
+ work_area: {
142
+ x: number;
143
+ y: number;
144
+ width: number;
145
+ height: number;
146
+ };
147
+ scaleFactor: number;
148
+ isBuiltIn: boolean;
149
+ rotation: number;
150
+ touchSupport: number;
151
+ }
152
+
153
+ class NWDesktopCaptureMonitor {
154
+ public started: boolean;
155
+ constructor();
156
+ start(should_include_screens: boolean, should_include_windows: boolean): this;
157
+ stop(): this;
158
+ registerStream(id: string): this;
159
+ on(event: "added", listener: (id: string, name: string, order: number, type: "screen" | "window" | "other" | "unknown", primary: boolean) => void): this;
160
+ on(event: "removed", listener: (order: number) => void): this;
161
+ on(event: "orderchanged", listener: (id: string, new_order: number, old_order: number) => void): this;
162
+ on(event: "namechanged", listener: (id: string, name: string) => void): this;
163
+ on(event: "thumbnailchanged", listener: (id: string, thumbnail: string) => void): this;
164
+ }
165
+
166
+ const Screen: NWScreen;
167
+ class NWScreen {
168
+ public readonly screens: IScreenData[];
169
+ public readonly DesktopCaptureMonitor: NWDesktopCaptureMonitor;
170
+ constructor();
171
+ Init(): void;
172
+ chooseDesktopMedia(sources: "window" | "screen" [], callback: (streamId: number | false) => void): this;
173
+ on(event: "displayBoundsChanged", listener: (screen: IScreenData) => void): this;
174
+ on(event: "displayAdded", listener: (screen: IScreenData) => void): this;
175
+ on(event: "displayRemoved", listener: (screen: IScreenData) => void): this;
176
+ }
177
+
178
+ interface IWindowSubfields {
179
+ id?: string;
180
+ title?: string;
181
+ width?: number;
182
+ height?: number;
183
+ icon?: string;
184
+ position?: "null" | "center" | "mouse";
185
+ min_width?: number;
186
+ min_height?: number;
187
+ max_width?: number;
188
+ max_height?: number;
189
+ as_desktop?: boolean;
190
+ resizable?: boolean;
191
+ always_on_top?: boolean;
192
+ visible_on_all_workspaces?: boolean;
193
+ fullscreen?: boolean;
194
+ show_in_taskbar?: boolean;
195
+ frame?: boolean;
196
+ show?: boolean;
197
+ kiosk?: boolean;
198
+ transparent?: boolean;
199
+ }
200
+
201
+ interface IWindowOptions extends IWindowSubfields {
202
+ new_instance?: boolean;
203
+ inject_js_start?: string;
204
+ inject_js_end?: string;
205
+ }
206
+
207
+ class Window {
208
+ public readonly window: any;
209
+ public x: number;
210
+ public y: number;
211
+ public width: number;
212
+ public height: number;
213
+ public title: string;
214
+ public menu: Menu;
215
+ public readonly isAlwaysOnTop: boolean;
216
+ public readonly isFullscreen: boolean;
217
+ public readonly isTransparent: boolean;
218
+ public readonly isKioskMode: boolean;
219
+ public zoomLevel: number;
220
+ public cookies: {
221
+ [key: string]: Function;
222
+ }
223
+ constructor();
224
+ static get(window_object: any): Window;
225
+ static open(url: string, options?: IWindowOptions, callback?: (win: Window) => void): Window;
226
+ moveTo(x: number, y: number): this;
227
+ moveBy(x: number, y: number): this;
228
+ resizeTo(width: number, height: number): this;
229
+ resizeBy(width: number, height: number): this;
230
+ focus(): this;
231
+ blur(): this;
232
+ show(is_show?: boolean): this;
233
+ hide(): this;
234
+ close(force?: boolean): this;
235
+ reload(): this;
236
+ reloadDev(): this;
237
+ reloadIgnoringCache(): this;
238
+ maximize(): this;
239
+ minimize(): this;
240
+ restore(): this;
241
+ enterFullscreen(): this;
242
+ leaveFullscreen(): this;
243
+ toggleFullscreen(): this;
244
+ enterKioskMode(): this;
245
+ leaveKioskMode(): this;
246
+ toggleKioskMode(): this;
247
+ setShadow(shadow: boolean): this;
248
+ showDevTools(iframe?: string | HTMLFrameElement, callback?: (dev_win: Window) => void): this;
249
+ closeDevTools(): this;
250
+ getPrinters(callback: object[]): this;
251
+ isDevToolsOpen(): boolean;
252
+ print(options: {
253
+ autoprint: boolean;
254
+ printer: string;
255
+ pdf_path: string;
256
+ headerFooterEnabled: boolean;
257
+ landscape: boolean;
258
+ mediaSize: object;
259
+ shouldPrintBackgrounds: boolean;
260
+ marginsType: 0 | 1 | 2| 3;
261
+ marginsCustom: object;
262
+ copies: number;
263
+ scaleFactor: number;
264
+ headerString: string;
265
+ footerString: string;
266
+ } | {}): this;
267
+ setMaximumSize(width: number, height: number): this;
268
+ setMinimumSize(width: number, height: number): this;
269
+ setResizable(resizable: boolean): this;
270
+ setAlwaysOnTop(top: boolean): this;
271
+ setVisibleOnAllWorkspaces(visible: boolean): this;
272
+ canSetVisibleOnAllWorkspaces(): boolean;
273
+ setPosition(position: "null" | "center" | "mouse"): this;
274
+ setShowInTaskbar(show: boolean): this;
275
+ requestAttention(attention: boolean | number): this;
276
+ capturePage(callback: Function, config?: "png" | "jpeg" | {
277
+ format?: "png" | "jpeg";
278
+ datatype?: "raw" | "buffer" | "datauri";
279
+ }): this;
280
+ setProgressBar(progress: number): this;
281
+ setBadgeLabel(label: string): this;
282
+ eval(frame: HTMLFrameElement | null, script: string): this;
283
+ evalNWBin(frame: HTMLFrameElement | null, path: string | ArrayBuffer | Buffer): this;
284
+ evalNWBinModule(frame: HTMLFrameElement | null, path: string | ArrayBuffer | Buffer, module_path: string): this;
285
+ on(event: "close", listener: () => void): this;
286
+ on(event: "closed", listener: () => void): this;
287
+ on(event: "loading", listener: () => void): this;
288
+ on(event: "loaded", listener: () => void): this;
289
+ on(event: "document-start", listener: (frame: HTMLFrameElement | null) => void): this;
290
+ on(event: "document-end", listener: (frame: HTMLFrameElement | null) => void): this;
291
+ on(event: "focus", listener: () => void): this;
292
+ on(event: "blur", listener: () => void): this;
293
+ on(event: "minimize", listener: () => void): this;
294
+ on(event: "restore", listener: () => void): this;
295
+ on(event: "maximize", listener: () => void): this;
296
+ on(event: "move", listener: (x: number, y: number) => void): this;
297
+ on(event: "resize", listener: (width: number, height: number) => void): this;
298
+ on(event: "enter-fullscreen", listener: () => void): this;
299
+ on(event: "zoom", listener: () => void): this;
300
+ on(event: "devtools-closed", listener: () => void): this;
301
+ on(event: "new-win-policy", listener: (frame: HTMLFrameElement | null, url: string, policy: {
302
+ ignore(): void;
303
+ forceCurrent(): void;
304
+ forceDownload(): void;
305
+ forceNewWindow(): void;
306
+ forceNewPopup(): void;
307
+ setNewWindowManifest(m: IWindowSubfields): void;
308
+ }) => void): this;
309
+ on(event: "navigation", listener: (frame: HTMLFrameElement | null, url: string, policy: {
310
+ ignore(): void;
311
+ }) => void): this;
312
+ }
313
+
314
+ namespace Shell {
315
+ function openExternal(uri: string): void;
316
+ function openItem(file_path: string): void;
317
+ function showItemInFolder(file_path: string): void;
318
+ }
319
+
320
+ class Tray {
321
+ public title: string;
322
+ public tooltip: string;
323
+ public icon: string;
324
+ public alticon: string;
325
+ public menu: Menu;
326
+ constructor(option: {
327
+ title: string;
328
+ tooltip: string;
329
+ icon: string;
330
+ alticon: string;
331
+ iconsAreTemplates: boolean;
332
+ menu: Menu;
333
+ });
334
+ remove(): void;
335
+ on(event: "click", listener: (...args: any[]) => void): this;
336
+ }
337
+
338
+ }
339
+
package/src/i18n.ts ADDED
@@ -0,0 +1,205 @@
1
+ /**
2
+ * ___ ___ __
3
+ * \ \/ / / _
4
+ * \ / /_| |_
5
+ * / \____ _|
6
+ * /__/\__\ |_|
7
+ *
8
+ * @file i18n.ts
9
+ * @author Etienne Cochard
10
+ * @license
11
+ * Copyright (c) 2019-2021 R-libre ingenierie
12
+ *
13
+ * This program is free software; you can redistribute it and/or modify
14
+ * it under the terms of the GNU General Public License as published by
15
+ * the Free Software Foundation; either version 3 of the License, or
16
+ * (at your option) any later version.
17
+ *
18
+ * This program is distributed in the hope that it will be useful,
19
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
+ * GNU General Public License for more details.
22
+ *
23
+ * You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
24
+ **/
25
+
26
+
27
+ /**
28
+ * language definition
29
+ * x4 specific strings
30
+ */
31
+
32
+ let fr = {
33
+ global: {
34
+ ok: 'OK',
35
+ cancel: 'Annuler',
36
+ ignore: 'Ignorer',
37
+ yes: 'Oui',
38
+ no: 'Non',
39
+
40
+ open: 'Ouvrir',
41
+ new: 'Nouveau',
42
+ delete: 'Supprimer',
43
+ close: 'Fermer',
44
+ save: 'Enregistrer',
45
+
46
+ search: 'Rechercher',
47
+ search_tip: 'Saisissez le texte à rechercher. <b>Enter</b> pour lancer la recherche. <b>Esc</b> pour annuler.',
48
+
49
+ required_field: "information requise",
50
+ invalid_format: "format invalide",
51
+ invalid_email: 'adresse mail invalide',
52
+ invalid_number: 'valeur numérique invalide',
53
+
54
+ diff_date_seconds: '{0} seconds',
55
+ diff_date_minutes: '{0} minutes',
56
+ diff_date_hours: '{0} hours',
57
+
58
+ invalid_date: 'Date non reconnue ({0})',
59
+ empty_list: 'Liste vide',
60
+
61
+ date_input_formats: 'd/m/y|d.m.y|d m y|d-m-y|dmy',
62
+ date_format: 'D/M/Y',
63
+
64
+ day_short: [ 'dim', 'lun', 'mar', 'mer', 'jeu', 'ven', 'sam' ],
65
+ day_long: [ 'dimanche', 'lundi', 'mardi', 'mercredi', 'jeudi', 'vendredi', 'samedi' ],
66
+
67
+ month_short: [ 'jan', 'fév', 'mar', 'avr', 'mai', 'jun', 'jui', 'aoû', 'sep', 'oct', 'nov', 'déc' ],
68
+ month_long: [ 'janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet', 'août', 'septembre', 'octobre', 'novembre', 'décembre' ],
69
+
70
+ property: 'Propriété',
71
+ value: 'Valeur',
72
+
73
+ err_403: `Vous n'avez pas les droits suffisants pour effectuer cette action`,
74
+
75
+ copy: 'Copier',
76
+ cut: 'Couper',
77
+ paste: 'Coller'
78
+ }
79
+ };
80
+
81
+ /** @ignore */
82
+ let en = {
83
+ global: {
84
+ ok: 'OK',
85
+ cancel: 'Cancel',
86
+ ignore: 'Ignore',
87
+ yes: 'Yes',
88
+ no: 'No',
89
+
90
+ required_field: "required field",
91
+ invalid_format: "invalid format",
92
+
93
+ diff_date_seconds: '{0} seconds',
94
+ diff_date_minutes: '{0} minutes',
95
+ diff_date_hours: '{0} hours',
96
+
97
+ invalid_date: 'Bad date format {0}',
98
+
99
+ copy: 'Copy',
100
+ cut: 'Cut',
101
+ paste: 'Paste'
102
+ }
103
+ }
104
+
105
+ /** @ignore */
106
+ let all_langs = {
107
+ 'fr': fr,
108
+ 'en': _mk_proxy( _patch( {}, en ) )
109
+ };
110
+
111
+ /**
112
+ * current language
113
+ * FR by default
114
+ * @example ```typescript
115
+ * console.log( _tr.global.ok );
116
+ */
117
+
118
+ export let _tr: any = all_langs['fr'];
119
+
120
+ /**
121
+ * check if the language is known
122
+ * @param name - language name to test
123
+ * @example ```typescript
124
+ * if( isLanguage('fr') ) {
125
+ * }
126
+ */
127
+
128
+ export function isLanguage( name ) {
129
+ return all_langs[name]!==undefined;
130
+ }
131
+
132
+ /**
133
+ * select the current language
134
+ * @param name - language name
135
+ * @example ```typescript
136
+ * selectLanguage( 'en' );
137
+ */
138
+
139
+ export function selectLanguage( name ) {
140
+
141
+ if( !isLanguage(name) ) {
142
+ return;
143
+ }
144
+
145
+ _tr = all_langs[name];
146
+ }
147
+
148
+ /**
149
+ * define a translation
150
+ * you can also patch 'global' elements witch are defined by x4
151
+ * @param name - language name
152
+ * @param definition - definition of the language
153
+ * @example ```typescript
154
+ * setTranslation( 'fr', {
155
+ * this_is_an_example: 'ceci est un exemple',
156
+ * this_is: {
157
+ * another_example: 'ceci est un autre exemple'
158
+ * },
159
+ * global: {
160
+ * ok: 'O.K.'
161
+ * }
162
+ * });
163
+ * console.log( _tr.this_is_an_example ); // defined by the previous line
164
+ * selectLanguage( 'en' );
165
+ * console.log( _tr.this_is_an_example ); // 'en' do not define this, so we get 'fr' one
166
+ *
167
+ */
168
+
169
+ export function extendTranslation( name, definition ) {
170
+
171
+ if( !isLanguage(name) ) {
172
+ return;
173
+ }
174
+
175
+ _patch( all_langs[name], definition );
176
+ }
177
+
178
+
179
+ function _patch( obj, by ) {
180
+ for( let n in by ) {
181
+ if( obj[n] instanceof Object ) {
182
+ _patch( obj[n], by[n] );
183
+ }
184
+ else {
185
+ obj[n] = by[n];
186
+ if( obj[n] instanceof Object ) {
187
+ obj[n] = _mk_proxy( obj[n] );
188
+ }
189
+ }
190
+ }
191
+
192
+ return obj;
193
+ }
194
+
195
+ function _mk_proxy( obj: any ) : any {
196
+ return new Proxy( obj, {
197
+ get: function(target, prop, receiver) {
198
+ let value = target[prop];
199
+ if( value===undefined ) {
200
+ return fr[prop];
201
+ }
202
+ return value;
203
+ }
204
+ });
205
+ }