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,171 @@
1
+ /**
2
+ * ___ ___ __
3
+ * \ \/ / / _
4
+ * \ / /_| |_
5
+ * / \____ _|
6
+ * /__/\__\ |_|
7
+ *
8
+ * @file dialog.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
+ import { Popup, PopupProps, PopupEventMap } from './popup';
26
+ import { IconID } from './icon';
27
+ import { Label } from './label';
28
+ import { Form, FormButtons } from './form';
29
+ import { Component, ComponentContent } from './component';
30
+ import { BasicEvent, EventCallback } from './x4_events';
31
+ import { Rect, Size } from './tools';
32
+ interface Geometry {
33
+ left: number;
34
+ top: number;
35
+ width: number;
36
+ height: number;
37
+ minimized: boolean;
38
+ maximized: boolean;
39
+ }
40
+ export interface EvClose extends BasicEvent {
41
+ }
42
+ export interface EvBtnClick extends BasicEvent {
43
+ button: string;
44
+ }
45
+ export declare function EvBtnClick(button: string): EvBtnClick;
46
+ export interface DialogBoxEventMap extends PopupEventMap {
47
+ close: EvClose;
48
+ btnClick: EvBtnClick;
49
+ }
50
+ export declare type InitFormCallback = () => Form;
51
+ export interface DialogProps<E extends DialogBoxEventMap = DialogBoxEventMap> extends PopupProps<E> {
52
+ title?: string;
53
+ icon?: IconID;
54
+ buttons?: FormButtons;
55
+ btnClick?: EventCallback<EvBtnClick>;
56
+ closable?: boolean;
57
+ movable?: boolean;
58
+ maximized?: boolean;
59
+ maximizable?: boolean;
60
+ minimizable?: boolean;
61
+ autoClose?: boolean;
62
+ width?: number;
63
+ height?: number;
64
+ dlgWidth?: number;
65
+ dlgHeight?: number;
66
+ form?: Form | InitFormCallback;
67
+ disableSuggestions?: boolean;
68
+ }
69
+ /**
70
+ * Standard dialog class
71
+ */
72
+ export declare class Dialog<P extends DialogProps = DialogProps, E extends DialogBoxEventMap = DialogBoxEventMap> extends Popup<P, E> {
73
+ protected m_icon: IconID;
74
+ protected m_title: string;
75
+ protected m_form: Form;
76
+ protected m_buttons: FormButtons;
77
+ protected m_closable: boolean;
78
+ protected m_movable: boolean;
79
+ protected m_maximized: boolean;
80
+ protected m_minimized: boolean;
81
+ protected m_maximizable: boolean;
82
+ protected m_minimizable: boolean;
83
+ protected m_minFormSize: Size;
84
+ protected m_rc_max: Rect;
85
+ protected m_rc_min: Rect;
86
+ protected m_el_title: Component;
87
+ protected m_last_down: number;
88
+ protected m_auto_close: boolean;
89
+ protected m_ui_title: Label;
90
+ protected m_form_cb: InitFormCallback;
91
+ constructor(props: P);
92
+ /**
93
+ *
94
+ */
95
+ componentCreated(): void;
96
+ /**
97
+ *
98
+ */
99
+ private _handleClick;
100
+ /**
101
+ * restore the geometry
102
+ */
103
+ setGeometry(geom: Geometry): void;
104
+ /**
105
+ * return the geometry (usefull to save state)
106
+ */
107
+ getGeometry(): Geometry;
108
+ /**
109
+ * resize the dialog
110
+ * @param width
111
+ * @param height
112
+ */
113
+ setSize(width: number, height: number): void;
114
+ /** @ignore */
115
+ render(): void;
116
+ /**
117
+ * change the dialog content
118
+ * @param els
119
+ * @param refreshAll
120
+ */
121
+ setContent(els: ComponentContent, refreshAll?: boolean): void;
122
+ /**
123
+ * change the dialog buttons
124
+ * @param buttons
125
+ */
126
+ setButtons(buttons: FormButtons): void;
127
+ /**
128
+ * return the dialog form
129
+ */
130
+ get form(): Form;
131
+ /**
132
+ * close the dialog
133
+ */
134
+ close(): void;
135
+ /**
136
+ *
137
+ */
138
+ private _toggleMax;
139
+ /**
140
+ *
141
+ */
142
+ private _toggleMin;
143
+ /**
144
+ *
145
+ */
146
+ private _mouseDown;
147
+ /**
148
+ * maximize the dialog
149
+ */
150
+ maximize(): void;
151
+ /**
152
+ *
153
+ */
154
+ private _maximize;
155
+ /**
156
+ * minimize the dialog
157
+ */
158
+ minimize(): void;
159
+ /**
160
+ *
161
+ */
162
+ private _minimize;
163
+ /**
164
+ * change the dialog title
165
+ */
166
+ set title(title: string);
167
+ itemWithName<T extends Component>(name: string): T;
168
+ getValues(): any;
169
+ validate(): boolean;
170
+ }
171
+ export {};
package/lib/dialog.js ADDED
@@ -0,0 +1,468 @@
1
+ /**
2
+ * ___ ___ __
3
+ * \ \/ / / _
4
+ * \ / /_| |_
5
+ * / \____ _|
6
+ * /__/\__\ |_|
7
+ *
8
+ * @file dialog.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
+ import { Popup, EvMove } from './popup';
26
+ import { Icon } from './icon';
27
+ import { HLayout } from './layout';
28
+ import { Label } from './label';
29
+ import { Form } from './form';
30
+ import { Component, EvSize, flyWrap } from './component';
31
+ import { BasicEvent } from './x4_events';
32
+ import { Rect, getMousePos, isFunction, isTouchDevice } from './tools';
33
+ export function EvBtnClick(button) {
34
+ return BasicEvent({ button });
35
+ }
36
+ /**
37
+ * Standard dialog class
38
+ */
39
+ export class Dialog extends Popup {
40
+ m_icon;
41
+ m_title;
42
+ m_form;
43
+ m_buttons;
44
+ m_closable;
45
+ m_movable;
46
+ m_maximized;
47
+ m_minimized;
48
+ m_maximizable;
49
+ m_minimizable;
50
+ m_minFormSize;
51
+ m_rc_max;
52
+ m_rc_min;
53
+ m_el_title;
54
+ m_last_down;
55
+ m_auto_close;
56
+ m_ui_title;
57
+ m_form_cb;
58
+ constructor(props) {
59
+ let content = props.content;
60
+ props.content = null;
61
+ let width = props.width;
62
+ let height = props.height;
63
+ props.width = undefined;
64
+ props.height = undefined;
65
+ super(props);
66
+ this.m_minFormSize = { width, height };
67
+ this.enableMask(true);
68
+ if (props.form) {
69
+ if (!isFunction(props.form)) {
70
+ this.m_form = props.form;
71
+ this.m_form.on('btnClick', (e) => this._handleClick(e));
72
+ }
73
+ else {
74
+ this.m_form_cb = props.form;
75
+ }
76
+ }
77
+ else {
78
+ this.m_form = new Form({
79
+ content,
80
+ buttons: props.buttons,
81
+ disableSuggestions: props.disableSuggestions,
82
+ btnClick: (e) => this._handleClick(e)
83
+ });
84
+ }
85
+ this.m_movable = props.movable;
86
+ this.m_auto_close = props.autoClose ?? true;
87
+ this.m_icon = props.icon;
88
+ this.m_title = props.title;
89
+ this.m_buttons = props.buttons ?? null;
90
+ this.m_closable = props.closable ?? false;
91
+ this.m_last_down = 0;
92
+ this.on('size', (ev) => {
93
+ this.addClass('@resized');
94
+ this.m_form.setStyleValue('width', null);
95
+ this.m_form.setStyleValue('height', null);
96
+ });
97
+ this.m_maximized = false;
98
+ this.m_minimized = false;
99
+ this.m_maximizable = false;
100
+ this.m_minimizable = false;
101
+ if (props.maximizable !== undefined) {
102
+ this.m_maximizable = props.maximizable;
103
+ }
104
+ if (props.minimizable !== undefined) {
105
+ this.m_minimizable = props.minimizable;
106
+ }
107
+ if (props.maximized == true) {
108
+ this.m_maximizable = true;
109
+ }
110
+ if (props.btnClick) {
111
+ this.on('btnClick', props.btnClick);
112
+ }
113
+ }
114
+ /**
115
+ *
116
+ */
117
+ componentCreated() {
118
+ super.componentCreated();
119
+ if (this.m_minFormSize.width) {
120
+ this.m_form.setStyle({
121
+ minWidth: this.m_minFormSize.width,
122
+ width: this.m_minFormSize.width
123
+ });
124
+ }
125
+ if (this.m_minFormSize.height) {
126
+ this.m_form.setStyle({
127
+ minHeight: this.m_minFormSize.height,
128
+ height: this.m_minFormSize.height
129
+ });
130
+ }
131
+ const rc = this.getBoundingRect();
132
+ this.setStyleValue('min-width', rc.width);
133
+ this.setStyleValue('min-height', rc.height);
134
+ this.setStyleValue('width', rc.width);
135
+ this.setStyleValue('height', rc.height);
136
+ if (this.m_props.dlgWidth) {
137
+ this.setStyleValue('width', this.m_props.dlgWidth + '%');
138
+ }
139
+ if (this.m_props.dlgHeight) {
140
+ this.setStyleValue('height', this.m_props.dlgHeight + '%');
141
+ }
142
+ this.addClass('@resized');
143
+ if (this.m_props.maximized) {
144
+ this._maximize();
145
+ this.emit('size', EvSize(null));
146
+ }
147
+ else {
148
+ this.centerOnScreen();
149
+ }
150
+ }
151
+ /**
152
+ *
153
+ */
154
+ _handleClick(ev) {
155
+ this.emit('btnClick', ev);
156
+ if (!ev.defaultPrevented) {
157
+ this.close();
158
+ }
159
+ }
160
+ /**
161
+ * restore the geometry
162
+ */
163
+ setGeometry(geom) {
164
+ if (geom.minimized && this.m_minimizable) {
165
+ this._minimize(false);
166
+ this.m_rc_min = new Rect(geom.left, geom.top, geom.width, geom.height);
167
+ this.displayAt(geom.left, geom.top, 'top-left');
168
+ }
169
+ else if (geom.maximized && this.m_maximizable) {
170
+ this._maximize(false);
171
+ this.m_rc_max = new Rect(geom.left, geom.top, geom.width, geom.height);
172
+ }
173
+ else {
174
+ this.setSize(geom.width, geom.height);
175
+ this.displayAt(geom.left, geom.top, 'top-left');
176
+ }
177
+ }
178
+ /**
179
+ * return the geometry (usefull to save state)
180
+ */
181
+ getGeometry() {
182
+ if (this.m_minimized) {
183
+ return {
184
+ left: this.m_rc_min.left,
185
+ top: this.m_rc_min.top,
186
+ width: this.m_rc_min.width,
187
+ height: this.m_rc_min.height,
188
+ minimized: true,
189
+ maximized: false
190
+ };
191
+ }
192
+ else if (this.m_maximized) {
193
+ return {
194
+ left: this.m_rc_max.left,
195
+ top: this.m_rc_max.top,
196
+ width: this.m_rc_max.width,
197
+ height: this.m_rc_max.height,
198
+ minimized: false,
199
+ maximized: true
200
+ };
201
+ }
202
+ let rc = this.getBoundingRect();
203
+ return {
204
+ left: rc.left,
205
+ top: rc.top,
206
+ width: rc.width,
207
+ height: rc.height,
208
+ minimized: false,
209
+ maximized: false
210
+ };
211
+ }
212
+ /**
213
+ * resize the dialog
214
+ * @param width
215
+ * @param height
216
+ */
217
+ setSize(width, height) {
218
+ this.setStyle({ width, height });
219
+ this.emit('size', EvSize({ width, height }));
220
+ }
221
+ /** @ignore */
222
+ render() {
223
+ if (this.m_form_cb) {
224
+ this.m_form = this.m_form_cb();
225
+ this.m_form.on('btnClick', (e) => this._handleClick(e));
226
+ this.m_form_cb = null;
227
+ }
228
+ let hasTitle = this.m_icon !== undefined || this.m_closable || this.m_title !== undefined || this.m_movable;
229
+ this.m_el_title = null;
230
+ if (hasTitle) {
231
+ this.m_el_title = new HLayout({
232
+ cls: 'title',
233
+ content: [
234
+ this.m_icon ? new Icon({ icon: this.m_icon }) : null,
235
+ this.m_ui_title = new Label({ flex: 1, text: this.m_title }),
236
+ this.m_minimizable ? new Icon({ cls: 'min-btn', icon: 'cls(far fa-window-minimize)', dom_events: { click: () => this._toggleMin() } }) : null,
237
+ this.m_maximizable ? new Icon({ cls: 'max-btn', icon: 'cls(far fa-window-maximize)', dom_events: { click: () => this._toggleMax() } }) : null,
238
+ this.m_closable ? new Icon({ icon: 'cls(far fa-rectangle-times)', dom_events: { click: () => this.close() } }) : null,
239
+ ]
240
+ });
241
+ if (this.m_movable) {
242
+ if (isTouchDevice()) {
243
+ this.m_el_title.setDomEvent('touchstart', (e) => this._mouseDown(e));
244
+ }
245
+ else {
246
+ this.m_el_title.setDomEvent('mousedown', (e) => this._mouseDown(e));
247
+ }
248
+ }
249
+ }
250
+ super.setContent([
251
+ this.m_el_title,
252
+ this.m_form
253
+ ]);
254
+ }
255
+ /**
256
+ * change the dialog content
257
+ * @param els
258
+ * @param refreshAll
259
+ */
260
+ setContent(els, refreshAll = true) {
261
+ this.m_form.setContent(els, refreshAll);
262
+ }
263
+ /**
264
+ * change the dialog buttons
265
+ * @param buttons
266
+ */
267
+ setButtons(buttons) {
268
+ this.m_form.setButtons(buttons);
269
+ }
270
+ /**
271
+ * return the dialog form
272
+ */
273
+ get form() {
274
+ return this.m_form;
275
+ }
276
+ /**
277
+ * close the dialog
278
+ */
279
+ close() {
280
+ this.emit('close', {});
281
+ super.close();
282
+ }
283
+ /**
284
+ *
285
+ */
286
+ _toggleMax() {
287
+ if (!this.m_maximizable) {
288
+ return;
289
+ }
290
+ if (this.m_maximized) {
291
+ this.removeClass('maximized');
292
+ this.setStyle({
293
+ left: this.m_rc_max.left,
294
+ top: this.m_rc_max.top,
295
+ width: this.m_rc_max.width,
296
+ height: this.m_rc_max.height,
297
+ });
298
+ this.m_maximized = false;
299
+ this.emit('size', EvSize(null, 'restore'));
300
+ }
301
+ else {
302
+ this._maximize();
303
+ this.emit('size', EvSize(null, 'maximize'));
304
+ }
305
+ }
306
+ /**
307
+ *
308
+ */
309
+ _toggleMin() {
310
+ if (!this.m_minimizable) {
311
+ return;
312
+ }
313
+ if (this.m_minimized) {
314
+ this.removeClass('minimized');
315
+ this.setStyle({
316
+ //left: this.m_rc_min.left,
317
+ //top: this.m_rc_min.top,
318
+ width: this.m_rc_min.width,
319
+ height: this.m_rc_min.height,
320
+ });
321
+ this.m_minimized = false;
322
+ this.emit('size', EvSize(null, 'restore'));
323
+ }
324
+ else {
325
+ this._minimize();
326
+ this.emit('size', EvSize(null, 'minimize'));
327
+ }
328
+ }
329
+ /**
330
+ *
331
+ */
332
+ _mouseDown(event) {
333
+ let { x, y } = getMousePos(event, true);
334
+ let wrc = flyWrap(document.body).getBoundingRect();
335
+ let rc = this.getBoundingRect(true);
336
+ let trc = this.m_el_title.getBoundingRect();
337
+ let dx = x - rc.left, dy = y - rc.top;
338
+ let cstyle = this.getComputedStyle();
339
+ let topw = cstyle.parse('marginTop') + cstyle.parse('paddingTop') + cstyle.parse('borderTopWidth');
340
+ let botw = cstyle.parse('marginBottom') + cstyle.parse('paddingBottom') + cstyle.parse('borderBottomWidth');
341
+ let lftw = cstyle.parse('marginLeft') + cstyle.parse('paddingLeft') + cstyle.parse('borderLeftWidth');
342
+ let rgtw = cstyle.parse('marginRight') + cstyle.parse('paddingRight') + cstyle.parse('borderRightWidth');
343
+ wrc.top += topw - trc.height;
344
+ wrc.height -= topw + botw - trc.height;
345
+ wrc.left += lftw;
346
+ wrc.width -= lftw + rgtw;
347
+ // custom handling double click
348
+ const now = Date.now();
349
+ const delta = now - this.m_last_down;
350
+ if (this.m_maximizable && delta < 700) {
351
+ this._toggleMax();
352
+ return;
353
+ }
354
+ this.m_last_down = now;
355
+ if (this.m_maximized) {
356
+ // cannot move in max state
357
+ return;
358
+ }
359
+ let __move = (ex, ey) => {
360
+ let x = ex - dx, y = ey - dy;
361
+ if (x + rc.width < wrc.left) {
362
+ x = wrc.left - rc.width;
363
+ }
364
+ else if (x > wrc.right) {
365
+ x = wrc.right;
366
+ }
367
+ if (y < wrc.top) { // title grip is on top
368
+ y = wrc.top;
369
+ }
370
+ else if (y > wrc.bottom) {
371
+ y = wrc.bottom;
372
+ }
373
+ this.setStyle({
374
+ left: x,
375
+ top: y
376
+ });
377
+ };
378
+ Component.setCapture(this, (ev) => {
379
+ if (ev.type == 'mousemove') {
380
+ let mev = ev;
381
+ __move(mev.clientX, mev.clientY);
382
+ }
383
+ else if (ev.type == 'touchmove') {
384
+ let tev = ev;
385
+ if (tev.touches.length == 1) {
386
+ __move(tev.touches[0].clientX, tev.touches[0].clientY);
387
+ }
388
+ }
389
+ else if (ev.type == 'mouseup' || ev.type == 'touchend') {
390
+ Component.releaseCapture();
391
+ this.emit('move', EvMove(null));
392
+ }
393
+ else if (ev.type == 'mousedown' || ev.type == 'touchstart') {
394
+ }
395
+ });
396
+ }
397
+ /**
398
+ * maximize the dialog
399
+ */
400
+ maximize() {
401
+ if (!this.m_maximizable || this.m_maximized) {
402
+ return;
403
+ }
404
+ this._maximize();
405
+ this.emit('size', EvSize(null));
406
+ }
407
+ /**
408
+ *
409
+ */
410
+ _maximize(saveRect = true) {
411
+ if (saveRect) {
412
+ this.m_rc_max = this.getBoundingRect(false);
413
+ }
414
+ this.addClass('maximized');
415
+ this.m_maximized = true;
416
+ this.setStyle({
417
+ left: undefined,
418
+ top: undefined,
419
+ width: undefined,
420
+ height: undefined,
421
+ });
422
+ }
423
+ /**
424
+ * minimize the dialog
425
+ */
426
+ minimize() {
427
+ if (!this.m_minimizable || this.m_minimized) {
428
+ return;
429
+ }
430
+ this._minimize();
431
+ this.emit('size', EvSize(null));
432
+ }
433
+ /**
434
+ *
435
+ */
436
+ _minimize(saveRect = true) {
437
+ if (saveRect) {
438
+ this.m_rc_min = this.getBoundingRect(false);
439
+ }
440
+ this.addClass('minimized');
441
+ this.m_minimized = true;
442
+ this.setStyle({
443
+ //left: undefined,
444
+ //top: undefined,
445
+ width: undefined,
446
+ height: undefined,
447
+ });
448
+ }
449
+ /**
450
+ * change the dialog title
451
+ */
452
+ set title(title) {
453
+ this.m_title = title;
454
+ if (this.m_ui_title) {
455
+ this.m_ui_title.text = title;
456
+ }
457
+ }
458
+ itemWithName(name) {
459
+ let result = this.dom.querySelector(`[name="${name}"]`);
460
+ return result ? Component.getElement(result) : null;
461
+ }
462
+ getValues() {
463
+ return this.m_form.getValues();
464
+ }
465
+ validate() {
466
+ return this.m_form.validate();
467
+ }
468
+ }