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
package/lib/image.js ADDED
@@ -0,0 +1,149 @@
1
+ /**
2
+ * ___ ___ __
3
+ * \ \/ / / _
4
+ * \ / /_| |_
5
+ * / \____ _|
6
+ * /__/\__\ |_|
7
+ *
8
+ * @file image.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
+ const emptyImageSrc = 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==';
27
+ function _isStaticImage(src) {
28
+ return src.substr(0, 5) == 'data:';
29
+ }
30
+ /**
31
+ * Standard image class
32
+ */
33
+ export class Image extends Component {
34
+ m_created;
35
+ m_lazysrc; // expected
36
+ constructor(props) {
37
+ super(props);
38
+ this.m_created = false;
39
+ this.m_props.lazy = props.lazy === false ? false : true;
40
+ this.m_props.alt = props.alt;
41
+ if (props.lazy !== false) {
42
+ this.m_lazysrc = props.src;
43
+ props.src = emptyImageSrc;
44
+ }
45
+ this.setDomEvent('create', () => {
46
+ if (props.lazy) {
47
+ this.setImage(this.m_lazysrc, true);
48
+ }
49
+ });
50
+ }
51
+ /** @ignore */
52
+ render() {
53
+ let mp = this.m_props;
54
+ const img = new Component({
55
+ tag: 'img',
56
+ attrs: {
57
+ draggable: false,
58
+ alt: mp.alt ?? '',
59
+ decoding: mp.lazy ? 'async' : undefined,
60
+ },
61
+ style: {
62
+ objectFit: mp.alignment ? mp.alignment : undefined
63
+ }
64
+ });
65
+ this.setContent(img);
66
+ }
67
+ /**
68
+ * change the image
69
+ * @param src - image path
70
+ */
71
+ setImage(src, force) {
72
+ if (!src) {
73
+ src = emptyImageSrc;
74
+ }
75
+ if (!this.m_props.lazy) {
76
+ this.m_props.src = src;
77
+ this.m_lazysrc = src;
78
+ if (this.dom) {
79
+ this.dom.firstChild.setAttribute('src', src);
80
+ }
81
+ }
82
+ else if (force || this.m_lazysrc != src) {
83
+ if (_isStaticImage(src)) {
84
+ // not to download -> direct display
85
+ this.m_props.src = src;
86
+ this.m_lazysrc = src;
87
+ if (this.dom) {
88
+ this.dom.firstChild.setAttribute('src', this.m_props.src);
89
+ }
90
+ }
91
+ else {
92
+ // clear current image while waiting
93
+ this.m_props.src = emptyImageSrc;
94
+ if (this.dom) {
95
+ this.dom.firstChild.setAttribute('src', this.m_props.src);
96
+ }
97
+ this.m_lazysrc = src;
98
+ if (this.dom) {
99
+ this._update_image();
100
+ }
101
+ }
102
+ }
103
+ }
104
+ _update_image() {
105
+ console.assert(!!this.dom);
106
+ if (this.m_lazysrc && !_isStaticImage(this.m_lazysrc)) {
107
+ // we do not push Components in a static array...
108
+ Image.lazy_images_waiting.push({ dom: this.dom, src: this.m_lazysrc });
109
+ if (Image.lazy_image_timer === undefined) {
110
+ Image.lazy_image_timer = setInterval(Image.lazyWatch, 10);
111
+ }
112
+ }
113
+ }
114
+ static lazy_images_waiting = [];
115
+ static lazy_image_timer = undefined;
116
+ static lazyWatch() {
117
+ let newList = [];
118
+ let done = 0;
119
+ Image.lazy_images_waiting.forEach((el) => {
120
+ let dom = el.dom, src = el.src;
121
+ // skip deleted elements
122
+ if (!dom || !document.contains(dom)) {
123
+ // do not append to newList
124
+ return;
125
+ }
126
+ let rc = dom.getBoundingClientRect();
127
+ // if it is visible & inserted inside the document
128
+ if (!done && dom.offsetParent !== null &&
129
+ rc.bottom >= 0 && rc.right >= 0 &&
130
+ rc.top <= (window.innerHeight || document.documentElement.clientHeight) &&
131
+ rc.left <= (window.innerWidth || document.documentElement.clientWidth)) {
132
+ // ok, we load the image
133
+ let img = dom.firstChild;
134
+ img.setAttribute('src', src);
135
+ done++;
136
+ }
137
+ else {
138
+ // still not visible: may be next time
139
+ newList.push(el);
140
+ }
141
+ });
142
+ Image.lazy_images_waiting = newList;
143
+ // no more elements to watch...
144
+ if (newList.length == 0) {
145
+ clearInterval(Image.lazy_image_timer);
146
+ Image.lazy_image_timer = undefined;
147
+ }
148
+ }
149
+ }
package/lib/index.js ADDED
@@ -0,0 +1 @@
1
+ export * from "application"
package/lib/input.d.ts ADDED
@@ -0,0 +1,86 @@
1
+ /**
2
+ * ___ ___ __
3
+ * \ \/ / / _
4
+ * \ / /_| |_
5
+ * / \____ _|
6
+ * /__/\__\ |_|
7
+ *
8
+ * @file input.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
+ export declare type EditType = 'text' | 'number' | 'email' | 'date' | 'password' | 'file' | 'checkbox' | 'radio';
27
+ export interface ValueHook {
28
+ get(): any;
29
+ set(v: any): void;
30
+ }
31
+ export interface InputEventMap extends CEventMap {
32
+ }
33
+ export interface InputProps<P extends InputEventMap = InputEventMap> extends CProps<P> {
34
+ value?: string;
35
+ name?: string;
36
+ type?: EditType;
37
+ placeHolder?: string;
38
+ autoFocus?: boolean;
39
+ readOnly?: boolean;
40
+ tabIndex?: number | boolean;
41
+ pattern?: string;
42
+ uppercase?: boolean;
43
+ spellcheck?: boolean;
44
+ value_hook?: ValueHook;
45
+ min?: number;
46
+ max?: number;
47
+ }
48
+ /**
49
+ * base class for elements implementing an input
50
+ * CARE derived classes must set this.ui.input
51
+ */
52
+ export declare class Input extends Component<InputProps, InputEventMap> {
53
+ constructor(props: InputProps);
54
+ /** @ignore */
55
+ render(props: InputProps): void;
56
+ getType(): EditType;
57
+ /**
58
+ * return the current editor value
59
+ */
60
+ get value(): string;
61
+ /**
62
+ * Change the editor value
63
+ * @param value - new value to set
64
+ */
65
+ set value(value: string);
66
+ getStoreValue(): any;
67
+ setStoreValue(v: any): void;
68
+ set readOnly(ro: boolean);
69
+ /**
70
+ * select all the text
71
+ */
72
+ selectAll(): void;
73
+ /**
74
+ * select a part of the text
75
+ * @param start
76
+ * @param length
77
+ */
78
+ select(start: number, length?: number): void;
79
+ /**
80
+ * get the selection as { start, length }
81
+ */
82
+ getSelection(): {
83
+ start: number;
84
+ length: number;
85
+ };
86
+ }
package/lib/input.js ADDED
@@ -0,0 +1,172 @@
1
+ /**
2
+ * ___ ___ __
3
+ * \ \/ / / _
4
+ * \ / /_| |_
5
+ * / \____ _|
6
+ * /__/\__\ |_|
7
+ *
8
+ * @file input.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
+ /**
27
+ * base class for elements implementing an input
28
+ * CARE derived classes must set this.ui.input
29
+ */
30
+ export class Input extends Component {
31
+ constructor(props) {
32
+ super(props);
33
+ }
34
+ /** @ignore */
35
+ render(props) {
36
+ this.setProp('tag', 'input');
37
+ this._setTabIndex(props.tabIndex);
38
+ this.setAttributes({
39
+ value: props.value,
40
+ type: props.type || 'text',
41
+ name: props.name,
42
+ placeholder: props.placeHolder,
43
+ autofocus: props.autoFocus,
44
+ readonly: props.readOnly,
45
+ autocomplete: 'new-password',
46
+ tabindex: props.tabIndex,
47
+ spellcheck: props.spellcheck === false ? 'false' : undefined,
48
+ min: props.min,
49
+ max: props.max,
50
+ ...props.attrs
51
+ });
52
+ if (props.uppercase) {
53
+ this.setStyleValue('textTransform', 'uppercase');
54
+ }
55
+ }
56
+ getType() {
57
+ return this.m_props.type;
58
+ }
59
+ /**
60
+ * return the current editor value
61
+ */
62
+ get value() {
63
+ if (this.dom) {
64
+ this.m_props.value = this.dom.value;
65
+ }
66
+ if (this.m_props.uppercase) {
67
+ let upper = this.m_props.value.toUpperCase(); // todo: locale ?
68
+ if (this.dom && upper != this.m_props.value) {
69
+ this.dom.value = upper; // update the input
70
+ }
71
+ this.m_props.value = upper;
72
+ }
73
+ return this.m_props.value;
74
+ }
75
+ /**
76
+ * Change the editor value
77
+ * @param value - new value to set
78
+ */
79
+ set value(value) {
80
+ this.m_props.value = value;
81
+ if (this.dom) {
82
+ this.dom.value = value;
83
+ }
84
+ }
85
+ getStoreValue() {
86
+ if (this.m_props.value_hook) {
87
+ return this.m_props.value_hook.get();
88
+ }
89
+ else {
90
+ let type = this.getAttribute('type');
91
+ if (type) {
92
+ type = type.toLowerCase();
93
+ }
94
+ let value, dom = this.dom;
95
+ if (type === "file") {
96
+ value = [];
97
+ let files = dom.files;
98
+ for (let file = 0; file < files.length; file++) {
99
+ value.push(files[file].name);
100
+ }
101
+ }
102
+ else if (type === 'checkbox') {
103
+ if (dom.checked) {
104
+ value = 1;
105
+ }
106
+ else {
107
+ value = 0;
108
+ }
109
+ }
110
+ else if (type === 'radio') {
111
+ if (dom.checked) {
112
+ value = this.value;
113
+ }
114
+ }
115
+ else if (type === 'date') {
116
+ debugger;
117
+ }
118
+ else {
119
+ value = this.value;
120
+ }
121
+ return value;
122
+ }
123
+ }
124
+ setStoreValue(v) {
125
+ if (this.m_props.value_hook) {
126
+ return this.m_props.value_hook.set(v);
127
+ }
128
+ else {
129
+ let type = this.getAttribute('type'), dom = this.dom;
130
+ if (type) {
131
+ type = type.toLowerCase();
132
+ }
133
+ if (type === 'checkbox') {
134
+ let newval = v !== null && v !== '0' && v !== 0 && v !== false;
135
+ if (newval !== dom.checked) {
136
+ dom.setAttribute('checked', '' + newval);
137
+ dom.dispatchEvent(new Event('change'));
138
+ }
139
+ }
140
+ else {
141
+ this.value = v;
142
+ }
143
+ }
144
+ }
145
+ set readOnly(ro) {
146
+ this.setAttribute('readonly', ro);
147
+ }
148
+ /**
149
+ * select all the text
150
+ */
151
+ selectAll() {
152
+ this.dom.select();
153
+ }
154
+ /**
155
+ * select a part of the text
156
+ * @param start
157
+ * @param length
158
+ */
159
+ select(start, length = 9999) {
160
+ this.dom.setSelectionRange(start, start + length);
161
+ }
162
+ /**
163
+ * get the selection as { start, length }
164
+ */
165
+ getSelection() {
166
+ let idom = this.dom;
167
+ return {
168
+ start: idom.selectionStart,
169
+ length: idom.selectionEnd - idom.selectionStart,
170
+ };
171
+ }
172
+ }
package/lib/label.d.ts ADDED
@@ -0,0 +1,54 @@
1
+ /**
2
+ * ___ ___ __
3
+ * \ \/ / / _
4
+ * \ / /_| |_
5
+ * / \____ _|
6
+ * /__/\__\ |_|
7
+ *
8
+ * @file label.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 } from './component';
26
+ import { HtmlString } from './tools';
27
+ import { IconID } from './icon';
28
+ export interface LabelProps extends CProps {
29
+ text: string | HtmlString;
30
+ icon?: IconID;
31
+ align?: 'left' | 'right' | 'center';
32
+ multiline?: boolean;
33
+ }
34
+ /**
35
+ * Standard label
36
+ */
37
+ export declare class Label extends Component<LabelProps> {
38
+ /**
39
+ * double constructor, from string/html or as usual
40
+ */
41
+ constructor(props: LabelProps);
42
+ constructor(text: string | HtmlString);
43
+ /** @ignore */
44
+ render(props: LabelProps): void;
45
+ /**
46
+ * change the displayed text
47
+ * @param text - new text
48
+ */
49
+ set text(txt: string | HtmlString);
50
+ /**
51
+ *
52
+ */
53
+ get text(): string | HtmlString;
54
+ }
package/lib/label.js ADDED
@@ -0,0 +1,86 @@
1
+ /**
2
+ * ___ ___ __
3
+ * \ \/ / / _
4
+ * \ / /_| |_
5
+ * / \____ _|
6
+ * /__/\__\ |_|
7
+ *
8
+ * @file label.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 { HtmlString } from './tools';
27
+ import { Icon } from './icon';
28
+ /**
29
+ * Standard label
30
+ */
31
+ export class Label extends Component {
32
+ constructor(param) {
33
+ if (typeof (param) === 'string' || param instanceof HtmlString) {
34
+ super({ text: param });
35
+ }
36
+ else {
37
+ super(param);
38
+ }
39
+ }
40
+ /** @ignore */
41
+ render(props) {
42
+ let text = this.m_props.text;
43
+ if (this.m_props.multiline && !(text instanceof HtmlString)) {
44
+ text = new HtmlString(text.replace(/\n/g, '<br/>'));
45
+ }
46
+ if (!props.icon) {
47
+ this.setContent(text);
48
+ }
49
+ else {
50
+ this.setProp('tag', 'span');
51
+ this.addClass('@hlayout');
52
+ this.setContent([
53
+ new Icon({ icon: props.icon }),
54
+ new Component({ content: text, ref: 'text' })
55
+ ]);
56
+ }
57
+ this.addClass(props.align ?? 'left');
58
+ }
59
+ /**
60
+ * change the displayed text
61
+ * @param text - new text
62
+ */
63
+ set text(txt) {
64
+ let props = this.m_props;
65
+ if (props.text !== txt) {
66
+ props.text = txt;
67
+ let text = this.m_props.text;
68
+ if (this.m_props.multiline && !(text instanceof HtmlString)) {
69
+ text = new HtmlString(text.replace('/\n/g', '<br/>'));
70
+ }
71
+ if (this.dom) {
72
+ let comp = this;
73
+ if (this.m_props.icon) {
74
+ comp = this.itemWithRef('text');
75
+ }
76
+ comp.setContent(text);
77
+ }
78
+ }
79
+ }
80
+ /**
81
+ *
82
+ */
83
+ get text() {
84
+ return this.m_props.text;
85
+ }
86
+ }
@@ -0,0 +1,77 @@
1
+ /**
2
+ * ___ ___ __
3
+ * \ \/ / / _
4
+ * \ / /_| |_
5
+ * / \____ _|
6
+ * /__/\__\ |_|
7
+ *
8
+ * @file layout.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, ComponentContent, Container, ContainerProps, ContainerEventMap } from './component';
26
+ export declare class AbsLayout<P extends ContainerProps = ContainerProps, E extends ContainerEventMap = ContainerEventMap> extends Container<P, E> {
27
+ }
28
+ export declare class HLayout<P extends ContainerProps = ContainerProps, E extends ContainerEventMap = ContainerEventMap> extends Container<P, E> {
29
+ }
30
+ export declare class VLayout<P extends ContainerProps = ContainerProps, E extends ContainerEventMap = ContainerEventMap> extends Container<P, E> {
31
+ }
32
+ interface AutoLayoutProps extends CProps {
33
+ defaultLayout: 'horizontal' | 'vertical';
34
+ switchSize: number;
35
+ }
36
+ export declare class AutoLayout extends Container<AutoLayoutProps> {
37
+ constructor(props: AutoLayoutProps);
38
+ componentCreated(): void;
39
+ private _updateLayout;
40
+ }
41
+ export interface GridLayoutProps extends ContainerProps {
42
+ colSizes?: string;
43
+ rowSizes?: string;
44
+ colGap?: number;
45
+ template?: string[];
46
+ }
47
+ export declare class GridLayout<P extends GridLayoutProps = GridLayoutProps> extends Container<P> {
48
+ constructor(props: GridLayoutProps);
49
+ /** @ignore */
50
+ render(): void;
51
+ }
52
+ export interface TableLayoutProps extends CProps {
53
+ rows: number;
54
+ columns: number;
55
+ }
56
+ export declare class TableLayout extends Container<TableLayoutProps> {
57
+ private m_cells;
58
+ constructor(props: TableLayoutProps);
59
+ private _getCell;
60
+ private _setCell;
61
+ setCell(row: number, col: number, item: ComponentContent): void;
62
+ merge(row: number, col: number, rowCount: number, colCount: number): void;
63
+ setCellWidth(row: number, col: number, width?: number): void;
64
+ setCellHeight(row: number, col: number, height?: number): void;
65
+ setCellClass(row: number, col: number, cls: string): void;
66
+ setColClass(col: any, cls: any): void;
67
+ setRowClass(row: any, cls: any): void;
68
+ getCell(row: any, col: any): ComponentContent;
69
+ render(): void;
70
+ }
71
+ interface ScrollViewProps extends CProps {
72
+ }
73
+ export declare class ScrollView extends Component<ScrollViewProps> {
74
+ constructor(props: ScrollViewProps);
75
+ setContent(content: ComponentContent): void;
76
+ }
77
+ export {};