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
@@ -1,328 +0,0 @@
1
- /**
2
- * ___ ___ __
3
- * \ \/ / / _
4
- * \ / /_| |_
5
- * / \____ _|
6
- * /__/\__\ |_|
7
- *
8
- * @file calendar.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 { x4document } from './x4dom'
31
-
32
- import { Button } from './button';
33
- import { Popup } from './popup';
34
- import { Component, CProps, ContainerEventMap, Flex } from './component'
35
- import { EvChange, EventCallback } from './x4events'
36
- import { Point } from "./tools"
37
-
38
- import { _tr } from './i18n';
39
- import { Label } from './label';
40
- import { HLayout, VLayout } from './layout'
41
- import { date_hash, date_clone, formatIntlDate } from './tools'
42
- import { Menu, MenuItem } from './menu';
43
-
44
-
45
- interface CalendarEventMap extends ContainerEventMap {
46
- change?: EvChange;
47
- }
48
-
49
-
50
- interface CalendarProps extends CProps<CalendarEventMap> {
51
- date?: Date; // initial date to display
52
- minDate?: Date; // minimal date before the user cannot go
53
- maxDate?: Date; // maximal date after the user cannot go
54
-
55
- change?: EventCallback<EvChange>; // shortcut to events: { change: ... }
56
- }
57
-
58
-
59
- /**
60
- * default calendar control
61
- *
62
- * fires:
63
- * EventChange ( value = Date )
64
- */
65
-
66
- export class Calendar extends VLayout<CalendarProps, CalendarEventMap>
67
- {
68
- private m_date: Date;
69
-
70
- constructor(props: CalendarProps) {
71
- super(props);
72
-
73
- this.mapPropEvents( props, 'change' );
74
- this.m_date = props.date?.clone() ?? new Date();
75
- }
76
-
77
- /** @ignore */
78
-
79
- render(props: CalendarProps) {
80
-
81
- let month_start = date_clone(this.m_date);
82
- month_start.setDate(1);
83
-
84
- let day = month_start.getDay();
85
- if (day == 0) {
86
- day = 7;
87
- }
88
-
89
- month_start.setDate(-day + 1 + 1);
90
- let dte = date_clone(month_start);
91
-
92
- let today = this.m_date.hash();
93
-
94
- let month_end = date_clone(this.m_date);
95
- month_end.setDate(1);
96
- month_end.setMonth(month_end.getMonth() + 1);
97
- month_end.setDate(0);
98
-
99
- let end_of_month = date_hash(month_end);
100
-
101
- let rows: HLayout[] = [];
102
-
103
- // month selector
104
- let header = new HLayout({
105
- cls: 'month-sel',
106
- content: [
107
- new Label({
108
- cls: 'month',
109
- text: formatIntlDate(this.m_date, 'O'),
110
- dom_events: {
111
- click: () => this._choose('month')
112
- }
113
- }),
114
- new Label({
115
- cls: 'year',
116
- text: formatIntlDate(this.m_date, 'Y'),
117
- dom_events: {
118
- click: () => this._choose('year')
119
- }
120
- }),
121
- new Flex(),
122
- new Button({ text: '<', click: () => this._next(false) } ),
123
- new Button({ text: '>', click: () => this._next(true) } )
124
- ]
125
- });
126
-
127
- rows.push(header);
128
-
129
- // calendar part
130
- let day_names = [];
131
-
132
- // day names
133
- // empty week num
134
- day_names.push(new HLayout({
135
- cls: 'weeknum cell',
136
- }));
137
-
138
- for (let d = 0; d < 7; d++) {
139
- day_names.push(new Label({
140
- cls: 'cell',
141
- flex: 1,
142
- text: _tr.global.day_short[(d + 1) % 7]
143
- }));
144
- }
145
-
146
- rows.push(new HLayout({
147
- cls: 'week header',
148
- content: day_names
149
- }));
150
-
151
- let cmonth = this.m_date.getMonth();
152
-
153
- // weeks
154
- let first = true;
155
- while (date_hash(dte) <= end_of_month) {
156
-
157
- let days = [
158
- new HLayout({ cls: 'weeknum cell', content: new Component({ tag: 'span', content: formatIntlDate(dte, 'w') }) })
159
- ];
160
-
161
- // days
162
- for (let d = 0; d < 7; d++) {
163
-
164
- let cls = 'cell day';
165
- if (dte.hash() == today) {
166
- cls += ' today';
167
- }
168
-
169
- if (dte.getMonth() != cmonth) {
170
- cls += ' out';
171
- }
172
-
173
- const mkItem = ( dte ) => {
174
- return new HLayout({
175
- cls,
176
- flex: 1,
177
- content: new Component({
178
- tag: 'span',
179
- content: formatIntlDate(dte, 'd'),
180
- }),
181
- dom_events: {
182
- click: () => this.select(dte)
183
- }
184
- })
185
- }
186
-
187
- days.push( mkItem( dte.clone() ) );
188
-
189
- dte.setDate(dte.getDate() + 1);
190
- first = false;
191
- }
192
-
193
- rows.push(new HLayout({
194
- cls: 'week',
195
- flex: 1,
196
- content: days
197
- }));
198
- }
199
-
200
- this.setContent(rows);
201
- }
202
-
203
- /**
204
- * select the given date
205
- * @param date
206
- */
207
-
208
- private select(date: Date) {
209
- this.m_date = date;
210
- this.emit('change', EvChange(date));
211
- this.update();
212
- }
213
-
214
- /**
215
- *
216
- */
217
-
218
- private _next(n: boolean) {
219
- this.m_date.setMonth(this.m_date.getMonth() + (n ? 1 : -1));
220
- this.update();
221
- }
222
-
223
- /**
224
- *
225
- */
226
-
227
- private _choose(type: 'month' | 'year') {
228
-
229
- let items: MenuItem[] = [];
230
-
231
- if (type == 'month') {
232
- for (let m = 0; m < 12; m++) {
233
- items.push(new MenuItem({
234
- text: _tr.global.month_long[m],
235
- click: () => { this.m_date.setMonth(m); this.update(); }
236
- }));
237
- }
238
- }
239
- else if (type == 'year') {
240
-
241
- let min = this.m_props.minDate?.getFullYear() ?? 1900;
242
- let max = this.m_props.maxDate?.getFullYear() ?? 2037;
243
-
244
- for (let m = min; m < max; m++) {
245
- items.push(new MenuItem({
246
- text: '' + m,
247
- click: () => { this.m_date.setFullYear(m); this.update(); }
248
- }));
249
- }
250
- }
251
-
252
- let menu = new Menu({
253
- items
254
- });
255
-
256
- let rc = this.getBoundingRect();
257
- menu.displayAt(rc.left, rc.top);
258
- }
259
-
260
- get date() {
261
- return this.m_date;
262
- }
263
-
264
- set date(date: Date) {
265
- this.m_date = date;
266
- this.update();
267
- }
268
- }
269
-
270
- /**
271
- * default popup calendar
272
- */
273
-
274
- export class PopupCalendar extends Popup {
275
-
276
- m_cal: Calendar;
277
-
278
- constructor(props: CalendarProps) {
279
- super({ tabIndex: 1 });
280
-
281
- this.enableMask(false);
282
-
283
- this.m_cal = new Calendar(props);
284
- this.m_cal.addClass('@fit');
285
-
286
- this.setContent(this.m_cal);
287
- }
288
-
289
- // binded
290
- private _handleClick = (e: MouseEvent) => {
291
- if (!this.dom) {
292
- return;
293
- }
294
-
295
- let newfocus = <HTMLElement>e.target;
296
-
297
- // child of this: ok
298
- if (this.dom.contains(newfocus)) {
299
- return;
300
- }
301
-
302
- // menu: ok
303
- let dest = Component.getElement(newfocus, MenuItem);
304
- if (dest) {
305
- return;
306
- }
307
-
308
- this.close();
309
- }
310
-
311
- /** @ignore */
312
- show(modal?: boolean, at?: Point ) {
313
- x4document.addEventListener('mousedown', this._handleClick);
314
- if( at ) {
315
- super.displayAt( at.x, at.y, 'top left', undefined, modal );
316
- }
317
- else {
318
- super.show(modal);
319
- }
320
- }
321
-
322
- /** @ignore */
323
- close() {
324
- x4document.removeEventListener('mousedown', this._handleClick);
325
- super.close();
326
- }
327
-
328
- }