x4js 1.5.15 → 1.5.17

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 +19 -0
  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 +19 -0
  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 +8 -0
  12. package/lib/types/version.d.ts +1 -1
  13. package/package.json +1 -1
  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 -693
  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
@@ -1,152 +0,0 @@
1
- /**
2
- * ___ ___ __
3
- * \ \/ / / _
4
- * \ / /_| |_
5
- * / \____ _|
6
- * /__/\__\ |_|
7
- *
8
- * @file base_component.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
- import { EventMap, MapEvents, EventSource, EvTimer } from './x4events';
32
-
33
- /**
34
- * Timer Callback
35
- * @see EvTimer, startTimer, stopTimer
36
- */
37
-
38
- interface TimerCallback {
39
- (name: string, time: number): void;
40
- }
41
-
42
- /**
43
- * BaseComponent EventMap
44
- */
45
-
46
- export interface BaseComponentEventMap extends EventMap {
47
- timer: EvTimer,
48
- }
49
-
50
- /**
51
- * BaseCompoment Properties
52
- */
53
-
54
- export interface BaseComponentProps<T = BaseComponentEventMap> {
55
- events?: MapEvents<T>; // basic component event map in base interface, should specialised in derived interfaces
56
- [key: string]: any; // added index signature to solve "Type 'X' has no properties with type 'Y'"
57
- }
58
-
59
- /**
60
- * BaseComponent class
61
- */
62
-
63
- export class BaseComponent< P extends BaseComponentProps<BaseComponentEventMap>, E extends BaseComponentEventMap >
64
- extends EventSource< E > {
65
-
66
- protected m_props: P;
67
- #m_timers: Map<string, Function>;
68
-
69
- constructor(props: P) {
70
- super();
71
-
72
- //this.m_props = { ...props };
73
- this.m_props = props;
74
-
75
- if (props.events) {
76
- this.listen(props.events as EventMap);
77
- }
78
- }
79
-
80
- /**
81
- * start a new timer
82
- * @param name timer name
83
- * @param timeout time out in ms
84
- * @param repeat if true this is an auto repeat timer
85
- * @param callback if !null, the callback to call else a EvTimer is fired
86
- */
87
-
88
- startTimer(name: string, timeout: number, repeat = true, callback: TimerCallback = null) {
89
- if (!this.#m_timers) {
90
- this.#m_timers = new Map();
91
- }
92
- else {
93
- this.stopTimer(name);
94
- }
95
-
96
- const id = (repeat ? setInterval : setTimeout)((tm: number) => {
97
- if (callback) {
98
- callback(name, tm);
99
- }
100
- else {
101
- this.emit('timer', EvTimer( name, tm ));
102
- }
103
- }, timeout);
104
-
105
- this.#m_timers.set(name, () => { (repeat ? clearInterval : clearTimeout)(id) });
106
- }
107
-
108
- /**
109
- * stop the given timer
110
- * @param name
111
- */
112
-
113
- stopTimer(name: string) {
114
- const clear = this.#m_timers.get(name);
115
- if (clear) { clear(); }
116
- }
117
-
118
- /**
119
- * stop all timers
120
- */
121
-
122
- disposeTimers( ) {
123
- this.#m_timers?.forEach( v => v() );
124
- this.#m_timers = undefined;
125
- }
126
-
127
- /**
128
- *
129
- * @param callback
130
- * @param timeout
131
- */
132
-
133
- singleShot( callback: TimerCallback, timeout = 0 ) {
134
- setTimeout( callback, timeout );
135
- }
136
-
137
- /**
138
- *
139
- * @param props
140
- * @param elements
141
- */
142
-
143
- public mapPropEvents<N extends keyof E>(props: P, ...elements: N[] ) {
144
- elements.forEach( name => {
145
- const n = name as string;
146
- if (props[n]) {
147
- this._on(n, props[n]);
148
- }
149
- })
150
- }
151
- }
152
-
package/lib/src/button.ts DELETED
@@ -1,355 +0,0 @@
1
- /**
2
- * ___ ___ __
3
- * \ \/ / / _
4
- * \ / /_| |_
5
- * / \____ _|
6
- * /__/\__\ |_|
7
- *
8
- * @file button.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
- import { Component, CProps, CEventMap, HtmlString } from './component'
32
- import { EventCallback, EvClick, EvChange } from './x4events'
33
-
34
- import { Action } from './action'
35
- import { Icon, IconID } from './icon'
36
- import { Label } from './label'
37
- import { Menu, MenuItem, MenuOrSep } from './menu'
38
- import { isFunction } from './tools'
39
-
40
- /**
41
- * Button events
42
- */
43
-
44
- interface ButtonEventMap extends CEventMap {
45
- click: EvClick;
46
- }
47
-
48
- type MenuCallBack = () => MenuOrSep[];
49
-
50
- /**
51
- * Button properties
52
- */
53
-
54
- interface ButtonProps<E extends ButtonEventMap = ButtonEventMap> extends CProps<E> {
55
- text?: string | HtmlString; // initial button text
56
- icon?: IconID; // optional icon id
57
- rightIcon?: IconID; // optional icon id
58
- align?: 'center' | 'left' | 'right'; // text alignment
59
- autoRepeat?: number; // time in ms or 0/undefined for none
60
- menu?: MenuOrSep[] | MenuCallBack;
61
- click?: EventCallback<EvClick>; // shortcut to events: { click: ... }
62
-
63
- action?: Action;
64
- }
65
-
66
-
67
- /**
68
- * Base button
69
- */
70
-
71
- export class BaseButton<P extends ButtonProps = ButtonProps, E extends ButtonEventMap = ButtonEventMap> extends Component<P, E> {
72
-
73
- constructor(props: P) {
74
- super(props);
75
-
76
- this.setTag( 'button');
77
-
78
- this.setDomEvent('click', (e) => this._handleClick(e));
79
- this.setDomEvent('mousedown', () => { this._startAutoRep(true) });
80
- this.setDomEvent('mouseup', () => { this._startAutoRep(false) });
81
- this.setDomEvent('keydown', (e) => this._handleKeyDown(e));
82
-
83
- this.mapPropEvents( props, 'click' );
84
- }
85
-
86
- render(props: ButtonProps) {
87
-
88
- const action = props.action;
89
-
90
- let icon = props.icon;
91
- let text = props.text;
92
-
93
- if( action ) {
94
- if( !icon && action.props.icon ) {
95
- icon = action.props.icon;
96
- }
97
-
98
- if( text===undefined && action.props.text ) {
99
- text = action.props.text;
100
- }
101
- }
102
-
103
- const ui_icon = icon ? new Icon({ icon, cls: 'left', ref: 'l_icon' }) : null;
104
- const ui_label = new Label({ flex: 1, text: text ?? '', align: props.align, ref: 'label' });
105
- const ui_ricon = props.rightIcon ? new Icon({ icon: props.rightIcon, cls: 'right', ref: 'r_icon' }) : null;
106
-
107
- if( text===undefined ) {
108
- ui_label.addClass( "@hidden" );
109
- }
110
-
111
- this.setContent([ui_icon, ui_label, ui_ricon]);
112
- this._setTabIndex(props.tabIndex);
113
- }
114
-
115
- /**
116
- * starts/stops the autorepeat
117
- */
118
-
119
- private _startAutoRep(start: boolean) {
120
-
121
- if (!this.m_props.autoRepeat) {
122
- return;
123
- }
124
-
125
- if (start) {
126
- // 1st timer 1s
127
- this.startTimer('repeat', 700, false, () => {
128
- // auto click
129
- this.startTimer('repeat', this.m_props.autoRepeat, true, this._sendClick);
130
- });
131
- }
132
- else {
133
- this.stopTimer('repeat');
134
- }
135
- }
136
-
137
- /**
138
- *
139
- */
140
-
141
- protected _handleKeyDown(ev: KeyboardEvent) {
142
- if (!ev.ctrlKey && !ev.shiftKey && !ev.altKey) {
143
- if (ev.key == 'Enter' || ev.key == ' ') {
144
- this._sendClick();
145
- ev.preventDefault();
146
- ev.stopPropagation();
147
- }
148
- }
149
- }
150
-
151
- /**
152
- * called by the system on click event
153
- */
154
-
155
- protected _handleClick(ev: MouseEvent) {
156
-
157
- if (this.m_props.menu) {
158
- let menu = new Menu({
159
- items: isFunction(this.m_props.menu) ? this.m_props.menu() : this.m_props.menu
160
- });
161
-
162
- let rc = this.getBoundingRect();
163
- menu.displayAt(rc.left, rc.bottom, 'tl');
164
- }
165
- else {
166
- this._sendClick();
167
- }
168
-
169
- ev.preventDefault();
170
- ev.stopPropagation();
171
- }
172
-
173
- /**
174
- * sends a click to the observers
175
- */
176
-
177
- protected _sendClick() {
178
- if (this.m_props.menu) {
179
- let menu = new Menu({
180
- items: isFunction(this.m_props.menu) ? this.m_props.menu() : this.m_props.menu
181
- });
182
-
183
- let rc = this.getBoundingRect();
184
- menu.displayAt(rc.left, rc.bottom, 'tl');
185
- }
186
- else {
187
- this.emit('click', EvClick());
188
- if( this.m_props.action ) {
189
- this.m_props.action.fire( );
190
- }
191
- }
192
- }
193
-
194
- /**
195
- * change the button text
196
- * @example
197
- * ```ts
198
- * let btn = new Button( {
199
- * text: 'hello'
200
- * });
201
- *
202
- * btn.text = 'world';
203
- * ```
204
- */
205
-
206
- public set text(text: string | HtmlString) {
207
- this.m_props.text = text;
208
-
209
- let label = this.itemWithRef<Label>('label');
210
- if (label) { label.text = text; label.removeClass("@hidden") }
211
- }
212
-
213
- public get text(): string | HtmlString {
214
- let label = this.itemWithRef<Label>('label');
215
- return label?.text;
216
- }
217
-
218
- /**
219
- * change the button icon
220
- * todo: do nothing if no icon defined at startup
221
- *
222
- * @example
223
- * ```ts
224
- * let btn = new Button( {
225
- * text: 'hello',
226
- * icon: 'close'
227
- * });
228
- * btn.setIcon( 'open' );
229
- * ```
230
- */
231
-
232
- public set icon(icon: IconID) {
233
- this.m_props.icon = icon;
234
-
235
- let ico = this.itemWithRef<Icon>('l_icon');
236
- if (ico) {
237
- ico.icon = icon;
238
- }
239
- else {
240
- this.update( );
241
- }
242
- }
243
-
244
- public get icon() {
245
- let ico = this.itemWithRef<Icon>('l_icon');
246
- return ico?.icon;
247
- }
248
-
249
- /**
250
- * change the button right icon
251
- * todo: do nothing if no icon defined at startup
252
- *
253
- * @example
254
- * ```ts
255
- * let btn = new Button( {
256
- * text: 'hello',
257
- * icon: 'close'
258
- * });
259
- * btn.setIcon( 'open' );
260
- * ```
261
- */
262
-
263
- public set rightIcon(icon: IconID) {
264
- this.m_props.rightIcon = icon;
265
- let ico = this.itemWithRef<Icon>('r_icon');
266
- if (ico) {
267
- ico.icon = icon;
268
- }
269
- }
270
-
271
- public get rightIcon() {
272
- let ico = this.itemWithRef<Icon>('l_icon');
273
- return ico?.icon;
274
- }
275
-
276
- /**
277
- *
278
- */
279
-
280
- set menu( items: MenuItem[] ) {
281
- this.m_props.menu = items;
282
- }
283
- }
284
-
285
- // :: BUTTON ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
286
-
287
- /**
288
- *
289
- */
290
-
291
- export class Button extends BaseButton<ButtonProps> {
292
- }
293
-
294
- // :: TOGGLE BUTTON ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
295
-
296
-
297
- interface ToggleButtonEventMap extends ButtonEventMap {
298
- change: EvChange;
299
- }
300
-
301
- interface ToggleButtonProps extends ButtonProps<ToggleButtonEventMap> {
302
- checked: boolean;
303
- checkedIcon?: IconID;
304
- }
305
-
306
- /**
307
- *
308
- */
309
-
310
- export class ToggleButton extends BaseButton<ToggleButtonProps, ToggleButtonEventMap> {
311
-
312
- constructor(props: ToggleButtonProps) {
313
- super(props);
314
- }
315
-
316
- /**
317
- *
318
- */
319
-
320
- render(props: ToggleButtonProps) {
321
- super.render(props);
322
-
323
- if (props.checked) {
324
- this.addClass('checked');
325
- this._updateIcon( );
326
- }
327
- }
328
-
329
- /**
330
- *
331
- */
332
-
333
- protected _sendClick() {
334
- super._sendClick();
335
-
336
- this.m_props.checked = !this.m_props.checked;
337
- this.setClass('checked', this.m_props.checked);
338
- this.emit('change', EvChange(this.m_props.checked));
339
-
340
- this._updateIcon( );
341
- }
342
-
343
- private _updateIcon( ) {
344
- if( this.m_props.checkedIcon ) {
345
- const ic = this.m_props.checked ? this.m_props.checkedIcon : this.m_props.icon;
346
- let ico = this.itemWithRef<Icon>('l_icon');
347
- if (ico) {
348
- ico.icon = ic;
349
- }
350
- }
351
- }
352
- }
353
-
354
-
355
-