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,350 @@
1
+ /**
2
+ * ___ ___ __
3
+ * \ \_/ / / _
4
+ * \ / /_| |_
5
+ * / _ \____ _|
6
+ * /__/ \__\ |_|
7
+ *
8
+ * @file svgcomponent.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 { Component } from './component';
26
+ // degrees to radian
27
+ function d2r(d) {
28
+ return d * Math.PI / 180.0;
29
+ }
30
+ // polar to cartesian
31
+ function p2c(x, y, r, deg) {
32
+ const rad = d2r(deg);
33
+ return {
34
+ x: x + r * Math.cos(rad),
35
+ y: y + r * Math.sin(rad)
36
+ };
37
+ }
38
+ function num(x) {
39
+ return Math.round(x * 1000) / 1000;
40
+ }
41
+ function clean(a, ...b) {
42
+ // just round number values to 3 digits
43
+ b = b.map(v => {
44
+ if (typeof v === 'number' && isFinite(v)) {
45
+ return num(v);
46
+ }
47
+ return v;
48
+ });
49
+ return String.raw(a, ...b);
50
+ }
51
+ /**
52
+ *
53
+ */
54
+ class SVGItem {
55
+ m_tag;
56
+ m_attrs;
57
+ constructor(tag) {
58
+ this.m_tag = tag;
59
+ this.m_attrs = new Map();
60
+ }
61
+ /**
62
+ * render the item
63
+ * @returns
64
+ */
65
+ render() {
66
+ return `<${this.m_tag} ${this.renderAttrs()}>${this.renderContent()}</${this.m_tag}>`;
67
+ }
68
+ /**
69
+ * change the stroke color
70
+ * @param color
71
+ */
72
+ stroke(color) {
73
+ this.attr('stroke', color);
74
+ return this;
75
+ }
76
+ /**
77
+ * change the stroke width
78
+ * @param width
79
+ */
80
+ strokeWidth(width) {
81
+ this.attr('stroke-width', width + 'px');
82
+ return this;
83
+ }
84
+ /**
85
+ * change the fill color
86
+ * @param color
87
+ */
88
+ fill(color) {
89
+ this.attr('fill', color);
90
+ return this;
91
+ }
92
+ /**
93
+ * define a new attribute
94
+ * @param name attibute name
95
+ * @param value attribute value
96
+ * @returns this
97
+ */
98
+ attr(name, value) {
99
+ this.m_attrs.set(name, value);
100
+ return this;
101
+ }
102
+ /**
103
+ * add a class
104
+ * @param name class name to add
105
+ */
106
+ class(name) {
107
+ let c = this.m_attrs.get('class');
108
+ this.m_attrs.set('class', (c ?? '' + ' ' + name).trim());
109
+ return this;
110
+ }
111
+ /**
112
+ *
113
+ */
114
+ renderAttrs() {
115
+ let result = '';
116
+ this.m_attrs.forEach((v, k) => {
117
+ result += ` ${k} = "${v}"`;
118
+ });
119
+ return result;
120
+ }
121
+ renderContent() {
122
+ return '';
123
+ }
124
+ }
125
+ /**
126
+ *
127
+ */
128
+ class SVGPath extends SVGItem {
129
+ m_path;
130
+ constructor() {
131
+ super('path');
132
+ this.m_path = '';
133
+ }
134
+ renderAttrs() {
135
+ this.attr('d', this.m_path);
136
+ return super.renderAttrs();
137
+ }
138
+ /**
139
+ * move the current pos
140
+ * @param x new pos x
141
+ * @param y new pos y
142
+ * @returns this
143
+ */
144
+ moveTo(x, y) {
145
+ this.m_path += clean `M${x},${y}`;
146
+ return this;
147
+ }
148
+ /**
149
+ * draw aline to the given point
150
+ * @param x end x
151
+ * @param y end y
152
+ * @returns this
153
+ */
154
+ lineTo(x, y) {
155
+ this.m_path += clean `L${x},${y}`;
156
+ return this;
157
+ }
158
+ /**
159
+ * close the currentPath
160
+ */
161
+ closePath() {
162
+ this.m_path += 'Z';
163
+ return this;
164
+ }
165
+ /**
166
+ * draw an arc
167
+ * @param x center x
168
+ * @param y center y
169
+ * @param r radius
170
+ * @param start angle start in degrees
171
+ * @param end angle end in degrees
172
+ * @returns this
173
+ */
174
+ arc(x, y, r, start, end) {
175
+ const st = p2c(x, y, r, start - 90);
176
+ const en = p2c(x, y, r, end - 90);
177
+ const flag = end - start <= 180 ? "0" : "1";
178
+ this.m_path += clean `M${st.x},${st.y}A${r},${r} 0 ${flag} 1 ${en.x},${en.y}`;
179
+ return this;
180
+ }
181
+ }
182
+ /**
183
+ *
184
+ */
185
+ class SVGText extends SVGItem {
186
+ m_text;
187
+ constructor(x, y, txt) {
188
+ super('text');
189
+ this.m_text = txt;
190
+ this.attr('x', num(x) + '');
191
+ this.attr('y', num(y) + '');
192
+ }
193
+ font(font) {
194
+ this.attr('font-family', font);
195
+ return this;
196
+ }
197
+ fontSize(size) {
198
+ this.attr('font-size', size + '');
199
+ return this;
200
+ }
201
+ fontWeight(weight) {
202
+ this.attr('font-weight', weight);
203
+ return this;
204
+ }
205
+ textAlign(align) {
206
+ let al;
207
+ switch (align) {
208
+ case 'left':
209
+ al = 'start';
210
+ break;
211
+ case 'center':
212
+ al = 'middle';
213
+ break;
214
+ case 'right':
215
+ al = 'end';
216
+ break;
217
+ default: return this;
218
+ }
219
+ this.attr('text-anchor', al);
220
+ return this;
221
+ }
222
+ verticalAlign(align) {
223
+ let al;
224
+ switch (align) {
225
+ case 'top':
226
+ al = 'hanging';
227
+ break;
228
+ case 'center':
229
+ al = 'middle';
230
+ break;
231
+ case 'bottom':
232
+ al = 'baseline';
233
+ break;
234
+ default: return;
235
+ }
236
+ this.attr('alignment-baseline', al);
237
+ return this;
238
+ }
239
+ renderContent() {
240
+ return this.m_text;
241
+ }
242
+ }
243
+ /**
244
+ *
245
+ */
246
+ class SVGShape extends SVGItem {
247
+ constructor(tag) {
248
+ super(tag);
249
+ }
250
+ }
251
+ /**
252
+ *
253
+ */
254
+ class SVGGradient extends SVGItem {
255
+ static g_id = 1;
256
+ m_id;
257
+ m_stops;
258
+ constructor(x1, y1, x2, y2) {
259
+ super('linearGradient');
260
+ this.m_id = 'gx-' + SVGGradient.g_id;
261
+ this.attr('id', this.m_id);
262
+ this.attr('x1', num(x1) + '');
263
+ this.attr('x2', num(x2) + '');
264
+ this.attr('y1', num(y1) + '');
265
+ this.attr('y2', num(y2) + '');
266
+ this.m_stops = [];
267
+ SVGGradient.g_id++;
268
+ }
269
+ get id() {
270
+ return 'url(#' + this.m_id + ')';
271
+ }
272
+ addStop(offset, color) {
273
+ this.m_stops.push({ offset, color });
274
+ return this;
275
+ }
276
+ renderContent() {
277
+ const result = [];
278
+ this.m_stops.forEach(s => {
279
+ result.push(`<stop offset="${s.offset}%" stop-color="${s.color}"></stop>`);
280
+ });
281
+ return result.join('\n');
282
+ }
283
+ }
284
+ /**
285
+ *
286
+ */
287
+ export class SVGPathBuilder {
288
+ m_items;
289
+ constructor() {
290
+ this.m_items = [];
291
+ }
292
+ path() {
293
+ const path = new SVGPath();
294
+ this.m_items.push(path);
295
+ return path;
296
+ }
297
+ text(x, y, txt) {
298
+ const text = new SVGText(x, y, txt);
299
+ this.m_items.push(text);
300
+ return text;
301
+ }
302
+ ellipse(x, y, r1, r2 = r1) {
303
+ const shape = new SVGShape('ellipse');
304
+ shape.attr('cx', num(x) + '');
305
+ shape.attr('cy', num(y) + '');
306
+ shape.attr('rx', num(r1) + '');
307
+ shape.attr('ry', num(r2) + '');
308
+ this.m_items.push(shape);
309
+ return shape;
310
+ }
311
+ rect(x, y, w, h) {
312
+ const shape = new SVGShape('rect');
313
+ shape.attr('x', num(x) + '');
314
+ shape.attr('y', num(y) + '');
315
+ shape.attr('width', num(w) + '');
316
+ shape.attr('height', num(h) + '');
317
+ this.m_items.push(shape);
318
+ return shape;
319
+ }
320
+ gradient(x1, y1, x2, y2) {
321
+ const grad = new SVGGradient(x1, y1, x2, y2);
322
+ this.m_items.push(grad);
323
+ return grad;
324
+ }
325
+ /**
326
+ * clear
327
+ */
328
+ clear() {
329
+ this.m_items = [];
330
+ }
331
+ render() {
332
+ let result = [];
333
+ this.m_items.forEach(i => {
334
+ result.push(i.render());
335
+ });
336
+ return result.join('\n');
337
+ }
338
+ }
339
+ export class SVGComponent extends Component {
340
+ constructor(props) {
341
+ super(props);
342
+ this.setProp('tag', 'svg');
343
+ this.setProp('ns', 'http://www.w3.org/2000/svg');
344
+ this.setAttribute('xmlns', 'http://www.w3.org/2000/svg');
345
+ this.setAttributes({
346
+ viewBox: props.viewBox,
347
+ });
348
+ this.setContent(props.path);
349
+ }
350
+ }
@@ -0,0 +1,41 @@
1
+ /**
2
+ * ___ ___ __
3
+ * \ \_/ / / _
4
+ * \ / /_| |_
5
+ * / _ \____ _|
6
+ * /__/ \__\ |_|
7
+ *
8
+ * @file tabbar.ts
9
+ * @author Etienne Cochard
10
+ * @copyright (c) 2021 R-libre ingenierie, all rights reserved.
11
+ *
12
+ * @description Tab
13
+ **/
14
+ import { Component, Container, ContainerEventMap, CProps, EventHandler } from './component';
15
+ import { EvChange } from './x4_events';
16
+ import { IconID } from './icon.js';
17
+ interface TabBarEventMap extends ContainerEventMap {
18
+ change: EvChange;
19
+ }
20
+ interface TabBarProps extends CProps<TabBarEventMap> {
21
+ pages?: ITabPage[];
22
+ default?: string;
23
+ vertical?: boolean;
24
+ change: EventHandler<EvChange>;
25
+ }
26
+ export interface ITabPage {
27
+ id: string;
28
+ title?: string;
29
+ icon?: IconID;
30
+ page: Component;
31
+ }
32
+ export declare class TabBar extends Container<TabBarProps, TabBarEventMap> {
33
+ private m_pages;
34
+ private m_curPage;
35
+ constructor(props: TabBarProps);
36
+ addPage(page: ITabPage): void;
37
+ render(): void;
38
+ select(id: string): void;
39
+ private _select;
40
+ }
41
+ export {};
package/lib/tabbar.js ADDED
@@ -0,0 +1,66 @@
1
+ /**
2
+ * ___ ___ __
3
+ * \ \_/ / / _
4
+ * \ / /_| |_
5
+ * / _ \____ _|
6
+ * /__/ \__\ |_|
7
+ *
8
+ * @file tabbar.ts
9
+ * @author Etienne Cochard
10
+ * @copyright (c) 2021 R-libre ingenierie, all rights reserved.
11
+ *
12
+ * @description Tab
13
+ **/
14
+ import { Container } from './component';
15
+ import { Button } from './button';
16
+ import { EvChange } from './x4_events';
17
+ export class TabBar extends Container {
18
+ m_pages;
19
+ m_curPage;
20
+ constructor(props) {
21
+ super(props);
22
+ this.m_pages = [];
23
+ this.m_curPage = null;
24
+ this.mapPropEvents(props, 'change');
25
+ if (props.vertical) {
26
+ this.addClass('@vlayout');
27
+ }
28
+ else {
29
+ this.addClass('@hlayout');
30
+ }
31
+ this.m_props.pages?.forEach(p => this.addPage(p));
32
+ if (this.m_props.default) {
33
+ this.select(this.m_props.default);
34
+ }
35
+ }
36
+ addPage(page) {
37
+ this.m_pages.push({ ...page });
38
+ this._updateContent();
39
+ }
40
+ render() {
41
+ let buttons = [];
42
+ this.m_pages.forEach(p => {
43
+ p.btn = new Button({ cls: p === this.m_curPage ? 'selected' : '', text: p.title, icon: p.icon, click: () => this._select(p) });
44
+ buttons.push(p.btn);
45
+ });
46
+ this.setContent(buttons);
47
+ }
48
+ select(id) {
49
+ let page = this.m_pages.find(x => x.id === id);
50
+ if (page) {
51
+ this._select(page);
52
+ }
53
+ }
54
+ _select(p) {
55
+ if (this.dom && this.m_curPage && this.m_curPage.page) {
56
+ this.m_curPage.btn.removeClass('selected');
57
+ this.m_curPage.page.hide();
58
+ }
59
+ this.m_curPage = p;
60
+ this.signal('change', EvChange(p ? p.id : null));
61
+ if (this.dom && this.m_curPage && this.m_curPage.page) {
62
+ this.m_curPage.btn.addClass('selected');
63
+ this.m_curPage.page.show();
64
+ }
65
+ }
66
+ }
@@ -0,0 +1,45 @@
1
+ /**
2
+ * ___ ___ __
3
+ * \ \_/ / / _
4
+ * \ / /_| |_
5
+ * / _ \____ _|
6
+ * /__/ \__\ |_|
7
+ *
8
+ * @file tabview.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 { Component } from './component';
26
+ import { CardView, CardViewProps, ICardViewItem } from './cardview';
27
+ import { MenuItem } from './menu';
28
+ interface TabProps extends CardViewProps {
29
+ tab_selector?: boolean;
30
+ menu?: MenuItem;
31
+ }
32
+ /**
33
+ * Standard TabView class
34
+ */
35
+ export declare class TabView extends CardView<TabProps> {
36
+ protected m_tab_selector: boolean;
37
+ protected m_menu: MenuItem;
38
+ constructor(props: TabProps);
39
+ /** @ignore */
40
+ render(): void;
41
+ protected _updateSelector(): void;
42
+ protected _prepareSelector(card: ICardViewItem): Component;
43
+ protected _preparePage(page: Component): void;
44
+ }
45
+ export {};
package/lib/tabview.js ADDED
@@ -0,0 +1,79 @@
1
+ /**
2
+ * ___ ___ __
3
+ * \ \_/ / / _
4
+ * \ / /_| |_
5
+ * / _ \____ _|
6
+ * /__/ \__\ |_|
7
+ *
8
+ * @file tabview.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 { HLayout } from './layout';
26
+ import { Button } from './button';
27
+ import { CardView } from './cardview';
28
+ /**
29
+ * Standard TabView class
30
+ */
31
+ export class TabView extends CardView {
32
+ m_tab_selector;
33
+ m_menu;
34
+ constructor(props) {
35
+ super(props);
36
+ this.m_tab_selector = props.tab_selector ? true : false;
37
+ this.m_menu = props.menu;
38
+ this.addClass('@vlayout');
39
+ }
40
+ /** @ignore */
41
+ render() {
42
+ let tabs = [];
43
+ let pages = [];
44
+ if (this.m_menu) {
45
+ this.m_menu.addClass('@button @tab-btn');
46
+ this.m_menu.removeClass('@menu-item');
47
+ tabs.push(this.m_menu);
48
+ }
49
+ this.m_cards.forEach((p) => {
50
+ tabs.push(p.selector);
51
+ if (!(p.page instanceof Function)) {
52
+ pages.push(p.page);
53
+ }
54
+ });
55
+ if (this.m_tab_selector) {
56
+ pages.unshift(new HLayout({
57
+ cls: '@tab-switch',
58
+ content: tabs
59
+ }));
60
+ }
61
+ this.setContent(pages);
62
+ }
63
+ _updateSelector() {
64
+ }
65
+ _prepareSelector(card) {
66
+ return new Button({
67
+ cls: '@tab-btn',
68
+ text: card.title,
69
+ icon: card.icon,
70
+ click: () => { this.switchTo(card.name); }
71
+ });
72
+ }
73
+ _preparePage(page) {
74
+ super._preparePage(page);
75
+ if (!page.dom) {
76
+ this.appendChild(page);
77
+ }
78
+ }
79
+ }
@@ -0,0 +1,59 @@
1
+ /**
2
+ * ___ ___ __
3
+ * \ \_/ / / _
4
+ * \ / /_| |_
5
+ * / _ \____ _|
6
+ * /__/ \__\ |_|
7
+ *
8
+ * @file textarea.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 { Component, CProps, CEventMap } from './component';
26
+ import { EvChange, EventCallback } from './x4_events';
27
+ interface TextAreaEventMap extends CEventMap {
28
+ change: EvChange;
29
+ }
30
+ export interface TextAreaProps extends CProps {
31
+ text?: string;
32
+ readOnly?: boolean;
33
+ tabIndex?: number;
34
+ placeHolder?: string;
35
+ name?: string;
36
+ rows?: number;
37
+ autoGrow?: boolean;
38
+ autoFocus?: boolean;
39
+ spellcheck?: boolean;
40
+ change?: EventCallback<EvChange>;
41
+ }
42
+ export declare class TextArea extends Component<TextAreaProps, TextAreaEventMap> {
43
+ constructor(props: TextAreaProps);
44
+ /** @ignore */
45
+ render(props: TextAreaProps): void;
46
+ private _change;
47
+ componentCreated(): void;
48
+ get value(): string;
49
+ set value(t: string);
50
+ private _calcHeight;
51
+ private _updateHeight;
52
+ /**
53
+ * insert text at cursor position
54
+ */
55
+ insertText(text: any): void;
56
+ getStoreValue(): any;
57
+ setStoreValue(value: any): void;
58
+ }
59
+ export {};