x4js 1.5.8 → 1.5.11

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.
@@ -95,6 +95,12 @@ class TextArea extends component_1.Component {
95
95
  }
96
96
  }
97
97
  }
98
+ get text() {
99
+ return this.value;
100
+ }
101
+ set text(text) {
102
+ this.value = text;
103
+ }
98
104
  _calcHeight(text) {
99
105
  return 1 + (text.match(/\n/g) || []).length;
100
106
  }
@@ -107,15 +113,46 @@ class TextArea extends component_1.Component {
107
113
  }
108
114
  }
109
115
  /**
116
+ * @deprected use appendText
110
117
  * insert text at cursor position
111
118
  */
112
119
  insertText(text) {
120
+ this.appendText(text);
121
+ }
122
+ /**
123
+ * append the text
124
+ */
125
+ appendText(text) {
126
+ if (this.dom) {
127
+ let dom = this.dom;
128
+ let end = dom.selectionEnd;
129
+ dom.setRangeText(text, end, end, "end");
130
+ }
131
+ }
132
+ replaceText(text) {
113
133
  if (this.dom) {
114
134
  let dom = this.dom;
115
- let start = dom.selectionStart;
116
135
  dom.setRangeText(text);
117
- dom.selectionStart = start;
118
- dom.selectionEnd = start + text.length;
136
+ }
137
+ }
138
+ getSelection() {
139
+ if (this.dom) {
140
+ let dom = this.dom;
141
+ return { start: dom.selectionStart, end: dom.selectionEnd };
142
+ }
143
+ else {
144
+ return { start: 0, end: 0 };
145
+ }
146
+ }
147
+ setSelection(sel) {
148
+ if (this.dom) {
149
+ let dom = this.dom;
150
+ if (sel.start !== undefined) {
151
+ dom.selectionStart = sel.start;
152
+ }
153
+ if (sel.end !== undefined) {
154
+ dom.selectionEnd = sel.end;
155
+ }
119
156
  }
120
157
  }
121
158
  getStoreValue() {
@@ -157,6 +157,12 @@ class TreeView extends layout_1.VLayout {
157
157
  this.m_props.root = root;
158
158
  this.update();
159
159
  }
160
+ openAll(open = true) {
161
+ this.forEach((node) => {
162
+ node.open = open;
163
+ });
164
+ this.__update();
165
+ }
160
166
  /**
161
167
  * same as root = xxx but keep elements open
162
168
  */
@@ -169,7 +175,9 @@ class TreeView extends layout_1.VLayout {
169
175
  return false;
170
176
  });
171
177
  let oldSel = this.selection;
172
- this.m_props.root = root;
178
+ if (root) {
179
+ this.m_props.root = root;
180
+ }
173
181
  this.forEach((node) => {
174
182
  if (openList.indexOf(node.id) >= 0) {
175
183
  node.open = true;
@@ -478,6 +486,7 @@ class TreeView extends layout_1.VLayout {
478
486
  id: node.id,
479
487
  text: node.name,
480
488
  parent: node.parent,
489
+ cls: node.cls
481
490
  };
482
491
  if (!node.leaf) {
483
492
  elem.children = [];
@@ -29,4 +29,4 @@
29
29
  **/
30
30
  Object.defineProperty(exports, "__esModule", { value: true });
31
31
  exports.x4js_version = void 0;
32
- exports.x4js_version = "1.5.7";
32
+ exports.x4js_version = "1.5.11";
@@ -91,6 +91,12 @@ export class TextArea extends Component {
91
91
  }
92
92
  }
93
93
  }
94
+ get text() {
95
+ return this.value;
96
+ }
97
+ set text(text) {
98
+ this.value = text;
99
+ }
94
100
  _calcHeight(text) {
95
101
  return 1 + (text.match(/\n/g) || []).length;
96
102
  }
@@ -103,15 +109,46 @@ export class TextArea extends Component {
103
109
  }
104
110
  }
105
111
  /**
112
+ * @deprected use appendText
106
113
  * insert text at cursor position
107
114
  */
108
115
  insertText(text) {
116
+ this.appendText(text);
117
+ }
118
+ /**
119
+ * append the text
120
+ */
121
+ appendText(text) {
122
+ if (this.dom) {
123
+ let dom = this.dom;
124
+ let end = dom.selectionEnd;
125
+ dom.setRangeText(text, end, end, "end");
126
+ }
127
+ }
128
+ replaceText(text) {
109
129
  if (this.dom) {
110
130
  let dom = this.dom;
111
- let start = dom.selectionStart;
112
131
  dom.setRangeText(text);
113
- dom.selectionStart = start;
114
- dom.selectionEnd = start + text.length;
132
+ }
133
+ }
134
+ getSelection() {
135
+ if (this.dom) {
136
+ let dom = this.dom;
137
+ return { start: dom.selectionStart, end: dom.selectionEnd };
138
+ }
139
+ else {
140
+ return { start: 0, end: 0 };
141
+ }
142
+ }
143
+ setSelection(sel) {
144
+ if (this.dom) {
145
+ let dom = this.dom;
146
+ if (sel.start !== undefined) {
147
+ dom.selectionStart = sel.start;
148
+ }
149
+ if (sel.end !== undefined) {
150
+ dom.selectionEnd = sel.end;
151
+ }
115
152
  }
116
153
  }
117
154
  getStoreValue() {
@@ -155,6 +155,12 @@ export class TreeView extends VLayout {
155
155
  this.m_props.root = root;
156
156
  this.update();
157
157
  }
158
+ openAll(open = true) {
159
+ this.forEach((node) => {
160
+ node.open = open;
161
+ });
162
+ this.__update();
163
+ }
158
164
  /**
159
165
  * same as root = xxx but keep elements open
160
166
  */
@@ -167,7 +173,9 @@ export class TreeView extends VLayout {
167
173
  return false;
168
174
  });
169
175
  let oldSel = this.selection;
170
- this.m_props.root = root;
176
+ if (root) {
177
+ this.m_props.root = root;
178
+ }
171
179
  this.forEach((node) => {
172
180
  if (openList.indexOf(node.id) >= 0) {
173
181
  node.open = true;
@@ -471,6 +479,7 @@ export class TreeView extends VLayout {
471
479
  id: node.id,
472
480
  text: node.name,
473
481
  parent: node.parent,
482
+ cls: node.cls
474
483
  };
475
484
  if (!node.leaf) {
476
485
  elem.children = [];
@@ -26,4 +26,4 @@
26
26
  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
27
27
  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28
28
  **/
29
- export const x4js_version = "1.5.7";
29
+ export const x4js_version = "1.5.11";
@@ -35,6 +35,11 @@ interface TextAreaEventMap extends CEventMap {
35
35
  change: EvChange;
36
36
  }
37
37
 
38
+ interface Selection {
39
+ start: number;
40
+ end: number;
41
+ }
42
+
38
43
  export interface TextAreaProps extends CProps {
39
44
  text?: string;
40
45
  readOnly?: boolean;
@@ -133,6 +138,14 @@ export class TextArea extends Component<TextAreaProps, TextAreaEventMap> {
133
138
  }
134
139
  }
135
140
  }
141
+
142
+ get text( ): string {
143
+ return this.value;
144
+ }
145
+
146
+ set text( text: string ) {
147
+ this.value = text;
148
+ }
136
149
 
137
150
  private _calcHeight(text: string): number {
138
151
  return 1 + (text.match(/\n/g) || []).length;
@@ -149,21 +162,56 @@ export class TextArea extends Component<TextAreaProps, TextAreaEventMap> {
149
162
  }
150
163
 
151
164
  /**
165
+ * @deprected use appendText
152
166
  * insert text at cursor position
153
167
  */
154
168
 
155
169
  public insertText(text) {
170
+ this.appendText( text );
171
+ }
172
+
173
+ /**
174
+ * append the text
175
+ */
176
+
177
+ public appendText( text ) {
156
178
  if (this.dom) {
157
179
  let dom = (<HTMLTextAreaElement>this.dom);
180
+ let end = dom.selectionEnd;
181
+ dom.setRangeText(text,end,end,"end");
182
+ }
183
+ }
158
184
 
159
- let start = dom.selectionStart;
185
+ public replaceText( text ) {
186
+ if (this.dom) {
187
+ let dom = (<HTMLTextAreaElement>this.dom);
160
188
  dom.setRangeText(text);
161
- dom.selectionStart = start;
162
- dom.selectionEnd = start + text.length;
163
189
  }
164
190
  }
165
-
166
191
 
192
+ public getSelection( ) : Selection {
193
+ if (this.dom) {
194
+ let dom = (<HTMLTextAreaElement>this.dom);
195
+ return { start: dom.selectionStart, end: dom.selectionEnd };
196
+ }
197
+ else {
198
+ return {start: 0, end: 0 };
199
+ }
200
+ }
201
+
202
+ public setSelection( sel : Selection ) {
203
+ if (this.dom) {
204
+ let dom = (<HTMLTextAreaElement>this.dom);
205
+ if( sel.start!==undefined ) {
206
+ dom.selectionStart = sel.start;
207
+ }
208
+
209
+ if( sel.end!==undefined ) {
210
+ dom.selectionEnd = sel.end;
211
+ }
212
+ }
213
+ }
214
+
167
215
  public getStoreValue( ): any {
168
216
  return this.value;
169
217
  }
@@ -46,6 +46,7 @@ export interface HierarchicalNode {
46
46
  id: number;
47
47
  parent: number;
48
48
  name: string;
49
+ cls: string;
49
50
  leaf: boolean
50
51
  }
51
52
 
@@ -239,6 +240,14 @@ export class TreeView extends VLayout<TreeViewProps, TreeViewEventMap> {
239
240
  this.update();
240
241
  }
241
242
 
243
+ openAll( open = true) {
244
+ this.forEach((node: TreeNode) => {
245
+ node.open = open;
246
+ });
247
+
248
+ this.__update( )
249
+ }
250
+
242
251
  /**
243
252
  * same as root = xxx but keep elements open
244
253
  */
@@ -255,7 +264,9 @@ export class TreeView extends VLayout<TreeViewProps, TreeViewEventMap> {
255
264
  });
256
265
 
257
266
  let oldSel = this.selection;
258
- this.m_props.root = root;
267
+ if( root ) {
268
+ this.m_props.root = root;
269
+ }
259
270
 
260
271
  this.forEach((node: TreeNode): boolean => {
261
272
 
@@ -366,7 +377,7 @@ export class TreeView extends VLayout<TreeViewProps, TreeViewEventMap> {
366
377
  *
367
378
  */
368
379
 
369
- forEach(cb: (node) => boolean) {
380
+ forEach(cb: (node: TreeNode) => boolean | void ) {
370
381
  let found = null;
371
382
 
372
383
  function scan(node) {
@@ -645,6 +656,7 @@ export class TreeView extends VLayout<TreeViewProps, TreeViewEventMap> {
645
656
  id: node.id,
646
657
  text: node.name,
647
658
  parent: node.parent,
659
+ cls: node.cls
648
660
  };
649
661
 
650
662
  if (!node.leaf) {
@@ -27,4 +27,4 @@
27
27
  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28
28
  **/
29
29
 
30
- export const x4js_version = "1.5.7";
30
+ export const x4js_version = "1.5.11";
@@ -31,6 +31,10 @@ import { EvChange, EventCallback } from './x4events';
31
31
  interface TextAreaEventMap extends CEventMap {
32
32
  change: EvChange;
33
33
  }
34
+ interface Selection {
35
+ start: number;
36
+ end: number;
37
+ }
34
38
  export interface TextAreaProps extends CProps {
35
39
  text?: string;
36
40
  readOnly?: boolean;
@@ -51,12 +55,22 @@ export declare class TextArea extends Component<TextAreaProps, TextAreaEventMap>
51
55
  componentCreated(): void;
52
56
  get value(): string;
53
57
  set value(t: string);
58
+ get text(): string;
59
+ set text(text: string);
54
60
  private _calcHeight;
55
61
  private _updateHeight;
56
62
  /**
63
+ * @deprected use appendText
57
64
  * insert text at cursor position
58
65
  */
59
66
  insertText(text: any): void;
67
+ /**
68
+ * append the text
69
+ */
70
+ appendText(text: any): void;
71
+ replaceText(text: any): void;
72
+ getSelection(): Selection;
73
+ setSelection(sel: Selection): void;
60
74
  getStoreValue(): any;
61
75
  setStoreValue(value: any): void;
62
76
  }
@@ -38,6 +38,7 @@ export interface HierarchicalNode {
38
38
  id: number;
39
39
  parent: number;
40
40
  name: string;
41
+ cls: string;
41
42
  leaf: boolean;
42
43
  }
43
44
  export interface TreeNode {
@@ -88,6 +89,7 @@ export declare class TreeView extends VLayout<TreeViewProps, TreeViewEventMap> {
88
89
  private __update;
89
90
  updateElement(id: any): void;
90
91
  set root(root: TreeNode);
92
+ openAll(open?: boolean): void;
91
93
  /**
92
94
  * same as root = xxx but keep elements open
93
95
  */
@@ -98,7 +100,7 @@ export declare class TreeView extends VLayout<TreeViewProps, TreeViewEventMap> {
98
100
  /**
99
101
  *
100
102
  */
101
- forEach(cb: (node: any) => boolean): any;
103
+ forEach(cb: (node: TreeNode) => boolean | void): any;
102
104
  ensureVisible(id: any): void;
103
105
  set selection(id: any);
104
106
  private _getNode;
@@ -26,4 +26,4 @@
26
26
  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
27
27
  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28
28
  **/
29
- export declare const x4js_version = "1.5.7";
29
+ export declare const x4js_version = "1.5.11";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "x4js",
3
- "version": "1.5.8",
3
+ "version": "1.5.11",
4
4
  "description": "X4js core files",
5
5
  "main": "lib/cjs/index.js",
6
6
  "types": "lib/types/index.d.ts",