@kissflow/lowcode-client-sdk 1.0.2-beta.7 → 1.0.3
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.
- package/README.md +156 -17
- package/dist/base.js +7 -8
- package/dist/form.js +4 -6
- package/dist/formatter.js +4 -4
- package/dist/global.types.d.ts +12 -16
- package/dist/index.d.ts +17 -21
- package/dist/index.html +1 -1
- package/dist/kflowcode.sdk.js +19 -22
- package/dist/kflowcode.sdk.js.map +1 -1
- package/dist/kflowcode.sdk.module.js +19 -22
- package/dist/kflowcode.sdk.module.js.map +1 -1
- package/dist/lowcode.sdk.js +0 -4
- package/dist/page.js +4 -0
- package/package.json +1 -1
- package/src/base.ts +9 -10
- package/src/form.ts +5 -12
- package/src/formatter.ts +4 -4
- package/src/lowcode.sdk.ts +0 -3
- package/src/page.ts +4 -0
package/README.md
CHANGED
|
@@ -26,28 +26,159 @@ SDK can also be loaded directly into HTML by adding:
|
|
|
26
26
|
const kf = window.KF();
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
## 1) Form Functions
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
> Use Table:: as a prefix while using TableId
|
|
31
|
+
### Main form functions
|
|
33
32
|
|
|
34
|
-
|
|
33
|
+
`kf.currentForm` returns a `Form` class which has the following functions
|
|
34
|
+
|
|
35
|
+
##### a) getField()
|
|
36
|
+
###### Description:
|
|
37
|
+
Use this function to get the current value of a form field
|
|
38
|
+
|
|
39
|
+
###### Syntax:
|
|
35
40
|
```js
|
|
36
41
|
kf.currentForm.getField(fieldId).then((res) => {...})
|
|
37
42
|
// or
|
|
38
43
|
let value = await kf.currentForm.getField(fieldId)
|
|
39
44
|
```
|
|
40
|
-
|
|
45
|
+
|
|
46
|
+
##### b) updateField()
|
|
47
|
+
###### Description:
|
|
48
|
+
Use this function to get update any field in the form
|
|
49
|
+
###### Syntax:
|
|
41
50
|
```js
|
|
42
51
|
kf.currentForm.updateField({ fieldId_1: fieldValue, fieldId_2: fieldValue });
|
|
43
52
|
```
|
|
44
|
-
|
|
45
|
-
|
|
53
|
+
|
|
54
|
+
##### c) toJSON()
|
|
55
|
+
###### Description:
|
|
56
|
+
Use this function to get the JSON data of the current form
|
|
57
|
+
###### Syntax:
|
|
46
58
|
```js
|
|
47
|
-
kf.currentForm.
|
|
59
|
+
const json = await kf.currentForm.toJSON();
|
|
60
|
+
```
|
|
61
|
+
###### Output:
|
|
62
|
+
```
|
|
63
|
+
{
|
|
64
|
+
"Untitled_Field": "testing",
|
|
65
|
+
"_created_at": "2022-03-01T03:04:09Z",
|
|
66
|
+
"_flow_name": "form events",
|
|
67
|
+
"_id": "Pk4_T1WGWuMe",
|
|
68
|
+
"_modified_at": "2022-03-01T03:04:09Z"
|
|
69
|
+
}
|
|
48
70
|
```
|
|
49
71
|
---
|
|
72
|
+
### Table functions
|
|
73
|
+
`kf.currentForm.getTable(tableId)` returns a `Table` class which has the following functions
|
|
74
|
+
#### a) addRow()
|
|
75
|
+
###### Description:
|
|
76
|
+
Appends row details to the end of table.
|
|
77
|
+
###### Syntax:
|
|
78
|
+
```js
|
|
79
|
+
const table = kf.currentForm.getTable(tableId);
|
|
80
|
+
table.addRow({ columnId1: value, columnId2: value });
|
|
81
|
+
```
|
|
82
|
+
#### b) deleteRow()
|
|
83
|
+
###### Description:
|
|
84
|
+
Deletes a row from the table based on the row id
|
|
85
|
+
###### Syntax:
|
|
86
|
+
```js
|
|
87
|
+
const table = kf.currentForm.getTable(tableId);
|
|
88
|
+
table.deleteRow(rowId);
|
|
89
|
+
```
|
|
90
|
+
#### c) getRow()
|
|
91
|
+
###### Description:
|
|
92
|
+
Use this function to perform form actions on any row inside a child table
|
|
93
|
+
###### Syntax:
|
|
94
|
+
```js
|
|
95
|
+
const table = kf.currentForm.getTable(tableId);
|
|
96
|
+
const row = table.getRow(rowId);
|
|
97
|
+
```
|
|
98
|
+
###### Output:
|
|
99
|
+
Returns an instance of `TableForm` class
|
|
50
100
|
|
|
101
|
+
#### d) getRows()
|
|
102
|
+
###### Description:
|
|
103
|
+
Gets all the rows of the table
|
|
104
|
+
###### Syntax:
|
|
105
|
+
```js
|
|
106
|
+
const rows = await kf.currentForm.getTable(tableId).getRows();
|
|
107
|
+
```
|
|
108
|
+
###### Output:
|
|
109
|
+
Returns an array of `TableForm` instances
|
|
110
|
+
|
|
111
|
+
##### e) toJSON()
|
|
112
|
+
###### Description:
|
|
113
|
+
Use this function to get the JSON data of the child table
|
|
114
|
+
###### Syntax:
|
|
115
|
+
```js
|
|
116
|
+
const json = await kf.currentForm.getTable(tableId).toJSON();
|
|
117
|
+
```
|
|
118
|
+
###### Output:
|
|
119
|
+
```
|
|
120
|
+
[{
|
|
121
|
+
"Untitled_Field": "row 1",
|
|
122
|
+
"_created_at": "2022-03-01T03:04:09Z",
|
|
123
|
+
"_flow_name": "form events",
|
|
124
|
+
"_id": "Pk4_T1WGWuMe",
|
|
125
|
+
"_modified_at": "2022-03-01T03:04:09Z"
|
|
126
|
+
},{
|
|
127
|
+
"Untitled_Field": "row 2",
|
|
128
|
+
"_created_at": "2022-03-01T03:04:09Z",
|
|
129
|
+
"_flow_name": "form events",
|
|
130
|
+
"_id": "Pk4_T1WGWuMe",
|
|
131
|
+
"_modified_at": "2022-03-01T03:04:09Z"
|
|
132
|
+
}]
|
|
133
|
+
```
|
|
134
|
+
---
|
|
135
|
+
### Table Row functions
|
|
136
|
+
`kf.currentForm` returns a `TableForm` class which has the following functions
|
|
137
|
+
|
|
138
|
+
##### a) getField()
|
|
139
|
+
###### Description:
|
|
140
|
+
Use this function to get the value of the table row
|
|
141
|
+
###### Syntax:
|
|
142
|
+
```js
|
|
143
|
+
kf.currentForm.getField(fieldId).then((res) => {...})
|
|
144
|
+
// or
|
|
145
|
+
let value = await kf.currentForm.getField(fieldId)
|
|
146
|
+
```
|
|
147
|
+
##### b) updateField()
|
|
148
|
+
###### Description:
|
|
149
|
+
Use this function to get update any field in the table row
|
|
150
|
+
###### Syntax:
|
|
151
|
+
```js
|
|
152
|
+
kf.currentForm.updateField({ fieldId_1: fieldValue, fieldId_2: fieldValue });
|
|
153
|
+
```
|
|
154
|
+
##### c) getParent()
|
|
155
|
+
###### Description:
|
|
156
|
+
Use this function to perform form actions on the main form
|
|
157
|
+
###### Syntax:
|
|
158
|
+
```js
|
|
159
|
+
const mainForm = kf.currentForm.getParent();
|
|
160
|
+
mainForm.updateField({ fieldId_1: fieldValue, fieldId_2: fieldValue });
|
|
161
|
+
```
|
|
162
|
+
###### Output:
|
|
163
|
+
Returns an instance of `Form` class using which we can perform any action on the main form
|
|
164
|
+
##### d) toJson()
|
|
165
|
+
##### Description:
|
|
166
|
+
Get JSON output of table row
|
|
167
|
+
##### Syntax:
|
|
168
|
+
```js
|
|
169
|
+
const json = await kf.currentForm.toJSON();
|
|
170
|
+
```
|
|
171
|
+
###### Output:
|
|
172
|
+
```
|
|
173
|
+
{
|
|
174
|
+
"Untitled_Field": "testing",
|
|
175
|
+
"_created_at": "2022-03-01T03:04:09Z",
|
|
176
|
+
"_flow_name": "form events",
|
|
177
|
+
"_id": "Pk4_T1WGWuMe",
|
|
178
|
+
"_modified_at": "2022-03-01T03:04:09Z"
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
---
|
|
51
182
|
### 2) Client Functions
|
|
52
183
|
##### Show Toast
|
|
53
184
|
```js
|
|
@@ -65,7 +196,15 @@ kf.client.redirect(url);
|
|
|
65
196
|
### 3) Component Functions
|
|
66
197
|
#### Refresh a component
|
|
67
198
|
```js
|
|
68
|
-
kf.getComponent(componentId).refresh();
|
|
199
|
+
kf.app.page.getComponent(componentId).refresh();
|
|
200
|
+
```
|
|
201
|
+
#### Show a component
|
|
202
|
+
```js
|
|
203
|
+
kf.app.page.getComponent(componentId).show();
|
|
204
|
+
```
|
|
205
|
+
#### Hide a component
|
|
206
|
+
```js
|
|
207
|
+
kf.app.page.getComponent(componentId).hide();
|
|
69
208
|
```
|
|
70
209
|
---
|
|
71
210
|
|
|
@@ -160,27 +299,27 @@ kf.watchParams(function (data) {
|
|
|
160
299
|
### 9) Formatter Functions
|
|
161
300
|
##### Format to KF Date
|
|
162
301
|
```js
|
|
163
|
-
kf.formatter.
|
|
302
|
+
kf.formatter.toDate("08-24-2021").then((res) => {...})
|
|
164
303
|
// or
|
|
165
|
-
let value = await kf.formatter.
|
|
304
|
+
let value = await kf.formatter.toDate("08-24-2021");
|
|
166
305
|
```
|
|
167
306
|
##### Format to KF Date Time
|
|
168
307
|
```js
|
|
169
|
-
kf.formatter.
|
|
308
|
+
kf.formatter.toDateTime("2021-08-26T14:30").then((res) => {...})
|
|
170
309
|
// or
|
|
171
|
-
let value = await kf.formatter.
|
|
310
|
+
let value = await kf.formatter.toDateTime("2021-08-26T14:30");
|
|
172
311
|
```
|
|
173
312
|
##### Format to KF Number
|
|
174
313
|
```js
|
|
175
|
-
kf.formatter.
|
|
314
|
+
kf.formatter.toNumber("1,00,000.500000").then((res) => {...})
|
|
176
315
|
// or
|
|
177
|
-
let value = await kf.formatter.
|
|
316
|
+
let value = await kf.formatter.toNumber("1,00,000.500000");
|
|
178
317
|
```
|
|
179
318
|
##### Format to KF Currency
|
|
180
319
|
```js
|
|
181
|
-
kf.formatter.
|
|
320
|
+
kf.formatter.toCurrency("1,00,000.500000", "USD").then((res) => {...})
|
|
182
321
|
// or
|
|
183
|
-
let value = await kf.formatter.
|
|
322
|
+
let value = await kf.formatter.toCurrency("1,00,000.500000", "USD");
|
|
184
323
|
```
|
|
185
324
|
##### Format to KF Boolean
|
|
186
325
|
```js
|
package/dist/base.js
CHANGED
|
@@ -152,14 +152,13 @@ _BaseSDK_listeners = new WeakMap(), _BaseSDK_eventListeners = new WeakMap(), _Ba
|
|
|
152
152
|
if (listeners) {
|
|
153
153
|
listeners.forEach(function (listener) {
|
|
154
154
|
try {
|
|
155
|
-
if (data_1.resp
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}
|
|
155
|
+
if (data_1.resp &&
|
|
156
|
+
Object.keys(data_1.resp).length === 1 &&
|
|
157
|
+
_req_1.command !== constants_1.LISTENER_CMDS.API) {
|
|
158
|
+
listener(Object.values(data_1.resp)[0]);
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
listener(data_1.resp);
|
|
163
162
|
}
|
|
164
163
|
}
|
|
165
164
|
catch (err) {
|
package/dist/form.js
CHANGED
|
@@ -23,7 +23,6 @@ var Form = /** @class */ (function (_super) {
|
|
|
23
23
|
function Form(instanceId) {
|
|
24
24
|
var _this = _super.call(this, {}) || this;
|
|
25
25
|
_this.instanceId = instanceId;
|
|
26
|
-
_this.id = instanceId;
|
|
27
26
|
return _this;
|
|
28
27
|
}
|
|
29
28
|
Form.prototype.toJSON = function () {
|
|
@@ -54,7 +53,6 @@ var Table = /** @class */ (function (_super) {
|
|
|
54
53
|
var _this = _super.call(this, {}) || this;
|
|
55
54
|
_this.tableId = tableId;
|
|
56
55
|
_this.instanceId = instanceId;
|
|
57
|
-
_this.id = tableId;
|
|
58
56
|
return _this;
|
|
59
57
|
}
|
|
60
58
|
// list of obj of rows
|
|
@@ -96,13 +94,13 @@ var TableForm = /** @class */ (function (_super) {
|
|
|
96
94
|
_this.instanceId = instanceId;
|
|
97
95
|
_this.tableId = tableId;
|
|
98
96
|
_this.rowId = rowId;
|
|
99
|
-
_this.id = rowId;
|
|
100
|
-
_this.parent = new Form(instanceId);
|
|
101
|
-
_this.table = new Table(instanceId, tableId);
|
|
102
97
|
return _this;
|
|
103
98
|
}
|
|
99
|
+
TableForm.prototype.getParent = function () {
|
|
100
|
+
return new Form(this.instanceId);
|
|
101
|
+
};
|
|
104
102
|
TableForm.prototype.toJSON = function () {
|
|
105
|
-
return this._postMessageAsync(constants_1.LISTENER_CMDS.
|
|
103
|
+
return this._postMessageAsync(constants_1.LISTENER_CMDS.TO_JSON, {
|
|
106
104
|
tableId: this.tableId,
|
|
107
105
|
rowId: this.rowId
|
|
108
106
|
});
|
package/dist/formatter.js
CHANGED
|
@@ -23,22 +23,22 @@ var Formatter = /** @class */ (function (_super) {
|
|
|
23
23
|
function Formatter() {
|
|
24
24
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
25
25
|
}
|
|
26
|
-
Formatter.prototype.
|
|
26
|
+
Formatter.prototype.toDate = function (date) {
|
|
27
27
|
return this._postMessageAsync(constants_1.LISTENER_CMDS.FORMAT_DATE, {
|
|
28
28
|
date: date
|
|
29
29
|
});
|
|
30
30
|
};
|
|
31
|
-
Formatter.prototype.
|
|
31
|
+
Formatter.prototype.toDateTime = function (date) {
|
|
32
32
|
return this._postMessageAsync(constants_1.LISTENER_CMDS.FORMAT_DATE_TIME, {
|
|
33
33
|
date: date
|
|
34
34
|
});
|
|
35
35
|
};
|
|
36
|
-
Formatter.prototype.
|
|
36
|
+
Formatter.prototype.toNumber = function (value) {
|
|
37
37
|
return this._postMessageAsync(constants_1.LISTENER_CMDS.FORMAT_NUMBER, {
|
|
38
38
|
value: value
|
|
39
39
|
});
|
|
40
40
|
};
|
|
41
|
-
Formatter.prototype.
|
|
41
|
+
Formatter.prototype.toCurrency = function (value, currencyCode) {
|
|
42
42
|
return this._postMessageAsync(constants_1.LISTENER_CMDS.FORMAT_CURRENCY, {
|
|
43
43
|
value: value,
|
|
44
44
|
currencyCode: currencyCode
|
package/dist/global.types.d.ts
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
|
|
2
|
+
declare class Component {
|
|
3
|
+
id: string
|
|
4
|
+
refresh(): any;
|
|
5
|
+
show(): any;
|
|
6
|
+
hide(): any;
|
|
7
|
+
}
|
|
2
8
|
declare class Page {
|
|
3
9
|
_id: string
|
|
4
10
|
getParameter(key: string): any;
|
|
@@ -8,6 +14,7 @@ declare class Page {
|
|
|
8
14
|
w: number;
|
|
9
15
|
h: number;
|
|
10
16
|
}): any;
|
|
17
|
+
getComponent(componentId: string): Component;
|
|
11
18
|
onClose(callback: Function): void;
|
|
12
19
|
}
|
|
13
20
|
declare class Application {
|
|
@@ -26,21 +33,13 @@ declare class Client {
|
|
|
26
33
|
}): any;
|
|
27
34
|
redirect(url: string): any;
|
|
28
35
|
}
|
|
29
|
-
declare class Component {
|
|
30
|
-
id: string
|
|
31
|
-
refresh(): any;
|
|
32
|
-
show(): any;
|
|
33
|
-
hide(): any;
|
|
34
|
-
}
|
|
35
36
|
declare class Form {
|
|
36
|
-
id: string
|
|
37
37
|
toJSON(): any;
|
|
38
38
|
getField(fieldId: string): any;
|
|
39
39
|
updateField(args: object): any;
|
|
40
40
|
getTable(tableId: string): Table;
|
|
41
41
|
}
|
|
42
42
|
declare class Table {
|
|
43
|
-
id: string
|
|
44
43
|
toJSON(): any;
|
|
45
44
|
getRows(): TableForm[];
|
|
46
45
|
getRow(rowId: string): TableForm;
|
|
@@ -48,18 +47,16 @@ declare class Table {
|
|
|
48
47
|
deleteRow(rowId: string): any;
|
|
49
48
|
}
|
|
50
49
|
declare class TableForm {
|
|
51
|
-
|
|
52
|
-
table: Table
|
|
53
|
-
parent: Form
|
|
50
|
+
getParent(): Form;
|
|
54
51
|
toJSON(): any;
|
|
55
52
|
getField(fieldId: string): any;
|
|
56
53
|
updateField(args: object): any;
|
|
57
54
|
}
|
|
58
55
|
declare class Formatter {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
56
|
+
toDate(date: string): any;
|
|
57
|
+
toDateTime(date: string): any;
|
|
58
|
+
toNumber(value: string): any;
|
|
59
|
+
toCurrency(value: string, currencyCode: string): any;
|
|
63
60
|
toBoolean(value: string): any;
|
|
64
61
|
}
|
|
65
62
|
declare class kf {
|
|
@@ -70,5 +67,4 @@ declare class kf {
|
|
|
70
67
|
api(url: string, args?: {}): string | object;
|
|
71
68
|
watchParams(func: (data: any) => any): void;
|
|
72
69
|
getContext(): string | object;
|
|
73
|
-
getComponent(componentId: string): Component;
|
|
74
70
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -48,7 +48,18 @@ declare module "base" {
|
|
|
48
48
|
_registerEventListener(_id: string, eventType: string, callback: any): void;
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
+
declare module "component" {
|
|
52
|
+
import { BaseSDK } from "base";
|
|
53
|
+
export class Component extends BaseSDK {
|
|
54
|
+
id: string;
|
|
55
|
+
constructor(id: string);
|
|
56
|
+
refresh(): any;
|
|
57
|
+
show(): any;
|
|
58
|
+
hide(): any;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
51
61
|
declare module "page" {
|
|
62
|
+
import { Component } from "component";
|
|
52
63
|
import { BaseSDK } from "base";
|
|
53
64
|
export class Page extends BaseSDK {
|
|
54
65
|
_id: string;
|
|
@@ -60,6 +71,7 @@ declare module "page" {
|
|
|
60
71
|
w: number;
|
|
61
72
|
h: number;
|
|
62
73
|
}): any;
|
|
74
|
+
getComponent(componentId: string): Component;
|
|
63
75
|
onClose(callback: Function): void;
|
|
64
76
|
}
|
|
65
77
|
}
|
|
@@ -87,21 +99,10 @@ declare module "client" {
|
|
|
87
99
|
redirect(url: string): any;
|
|
88
100
|
}
|
|
89
101
|
}
|
|
90
|
-
declare module "component" {
|
|
91
|
-
import { BaseSDK } from "base";
|
|
92
|
-
export class Component extends BaseSDK {
|
|
93
|
-
id: string;
|
|
94
|
-
constructor(id: string);
|
|
95
|
-
refresh(): any;
|
|
96
|
-
show(): any;
|
|
97
|
-
hide(): any;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
102
|
declare module "form" {
|
|
101
103
|
import { BaseSDK } from "base";
|
|
102
104
|
export class Form extends BaseSDK {
|
|
103
105
|
private instanceId;
|
|
104
|
-
id: string;
|
|
105
106
|
constructor(instanceId: string);
|
|
106
107
|
toJSON(): any;
|
|
107
108
|
getField(fieldId: string): any;
|
|
@@ -111,7 +112,6 @@ declare module "form" {
|
|
|
111
112
|
class Table extends BaseSDK {
|
|
112
113
|
private tableId;
|
|
113
114
|
private instanceId;
|
|
114
|
-
id: string;
|
|
115
115
|
constructor(instanceId: string, tableId: string);
|
|
116
116
|
toJSON(): any;
|
|
117
117
|
getRows(): TableForm[];
|
|
@@ -123,10 +123,8 @@ declare module "form" {
|
|
|
123
123
|
private instanceId;
|
|
124
124
|
private tableId;
|
|
125
125
|
private rowId;
|
|
126
|
-
id: string;
|
|
127
|
-
table: Table;
|
|
128
|
-
parent: Form;
|
|
129
126
|
constructor(instanceId: string, tableId: string, rowId: string);
|
|
127
|
+
getParent(): Form;
|
|
130
128
|
toJSON(): any;
|
|
131
129
|
getField(fieldId: string): any;
|
|
132
130
|
updateField(args: object): any;
|
|
@@ -135,10 +133,10 @@ declare module "form" {
|
|
|
135
133
|
declare module "formatter" {
|
|
136
134
|
import { BaseSDK } from "base";
|
|
137
135
|
export class Formatter extends BaseSDK {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
136
|
+
toDate(date: string): any;
|
|
137
|
+
toDateTime(date: string): any;
|
|
138
|
+
toNumber(value: string): any;
|
|
139
|
+
toCurrency(value: string, currencyCode: string): any;
|
|
142
140
|
toBoolean(value: string): any;
|
|
143
141
|
}
|
|
144
142
|
}
|
|
@@ -149,7 +147,6 @@ declare module "lowcode.sdk" {
|
|
|
149
147
|
import { Client } from "client";
|
|
150
148
|
import { Formatter } from "formatter";
|
|
151
149
|
import { Application } from "app";
|
|
152
|
-
import { Component } from "component";
|
|
153
150
|
class LowcodeSDK extends BaseSDK {
|
|
154
151
|
currentForm: Form | TableForm;
|
|
155
152
|
client: Client;
|
|
@@ -159,7 +156,6 @@ declare module "lowcode.sdk" {
|
|
|
159
156
|
api(url: string, args?: {}): string | object;
|
|
160
157
|
watchParams(func: (data: any) => any): void;
|
|
161
158
|
getContext(): string | object;
|
|
162
|
-
getComponent(componentId: string): Component;
|
|
163
159
|
}
|
|
164
160
|
function initSDK(config?: any): LowcodeSDK;
|
|
165
161
|
export default initSDK;
|
package/dist/index.html
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
<iframe id="component2" src="http://localhost:3000" width="500px" height="500px">
|
|
15
15
|
<p>Your browser does not support iframes.</p>
|
|
16
16
|
</iframe>
|
|
17
|
-
<script defer src="kflowcode.sdk.js"></script></body>
|
|
17
|
+
<script defer src="kflowcode.sdk.module.js"></script></body>
|
|
18
18
|
<script type="module">
|
|
19
19
|
import MockAPI from './test/mock/api.js';
|
|
20
20
|
import LCNCHandler from './test/lcnc-handler.js';
|
package/dist/kflowcode.sdk.js
CHANGED
|
@@ -220,14 +220,13 @@ _BaseSDK_listeners = new WeakMap(), _BaseSDK_eventListeners = new WeakMap(), _Ba
|
|
|
220
220
|
if (listeners) {
|
|
221
221
|
listeners.forEach(function (listener) {
|
|
222
222
|
try {
|
|
223
|
-
if (data_1.resp
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
}
|
|
223
|
+
if (data_1.resp &&
|
|
224
|
+
Object.keys(data_1.resp).length === 1 &&
|
|
225
|
+
_req_1.command !== constants_1.LISTENER_CMDS.API) {
|
|
226
|
+
listener(Object.values(data_1.resp)[0]);
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
listener(data_1.resp);
|
|
231
230
|
}
|
|
232
231
|
}
|
|
233
232
|
catch (err) {
|
|
@@ -438,7 +437,6 @@ var Form = /** @class */ (function (_super) {
|
|
|
438
437
|
function Form(instanceId) {
|
|
439
438
|
var _this = _super.call(this, {}) || this;
|
|
440
439
|
_this.instanceId = instanceId;
|
|
441
|
-
_this.id = instanceId;
|
|
442
440
|
return _this;
|
|
443
441
|
}
|
|
444
442
|
Form.prototype.toJSON = function () {
|
|
@@ -469,7 +467,6 @@ var Table = /** @class */ (function (_super) {
|
|
|
469
467
|
var _this = _super.call(this, {}) || this;
|
|
470
468
|
_this.tableId = tableId;
|
|
471
469
|
_this.instanceId = instanceId;
|
|
472
|
-
_this.id = tableId;
|
|
473
470
|
return _this;
|
|
474
471
|
}
|
|
475
472
|
// list of obj of rows
|
|
@@ -511,13 +508,13 @@ var TableForm = /** @class */ (function (_super) {
|
|
|
511
508
|
_this.instanceId = instanceId;
|
|
512
509
|
_this.tableId = tableId;
|
|
513
510
|
_this.rowId = rowId;
|
|
514
|
-
_this.id = rowId;
|
|
515
|
-
_this.parent = new Form(instanceId);
|
|
516
|
-
_this.table = new Table(instanceId, tableId);
|
|
517
511
|
return _this;
|
|
518
512
|
}
|
|
513
|
+
TableForm.prototype.getParent = function () {
|
|
514
|
+
return new Form(this.instanceId);
|
|
515
|
+
};
|
|
519
516
|
TableForm.prototype.toJSON = function () {
|
|
520
|
-
return this._postMessageAsync(constants_1.LISTENER_CMDS.
|
|
517
|
+
return this._postMessageAsync(constants_1.LISTENER_CMDS.TO_JSON, {
|
|
521
518
|
tableId: this.tableId,
|
|
522
519
|
rowId: this.rowId
|
|
523
520
|
});
|
|
@@ -576,22 +573,22 @@ var Formatter = /** @class */ (function (_super) {
|
|
|
576
573
|
function Formatter() {
|
|
577
574
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
578
575
|
}
|
|
579
|
-
Formatter.prototype.
|
|
576
|
+
Formatter.prototype.toDate = function (date) {
|
|
580
577
|
return this._postMessageAsync(constants_1.LISTENER_CMDS.FORMAT_DATE, {
|
|
581
578
|
date: date,
|
|
582
579
|
});
|
|
583
580
|
};
|
|
584
|
-
Formatter.prototype.
|
|
581
|
+
Formatter.prototype.toDateTime = function (date) {
|
|
585
582
|
return this._postMessageAsync(constants_1.LISTENER_CMDS.FORMAT_DATE_TIME, {
|
|
586
583
|
date: date,
|
|
587
584
|
});
|
|
588
585
|
};
|
|
589
|
-
Formatter.prototype.
|
|
586
|
+
Formatter.prototype.toNumber = function (value) {
|
|
590
587
|
return this._postMessageAsync(constants_1.LISTENER_CMDS.FORMAT_NUMBER, {
|
|
591
588
|
value: value,
|
|
592
589
|
});
|
|
593
590
|
};
|
|
594
|
-
Formatter.prototype.
|
|
591
|
+
Formatter.prototype.toCurrency = function (value, currencyCode) {
|
|
595
592
|
return this._postMessageAsync(constants_1.LISTENER_CMDS.FORMAT_CURRENCY, {
|
|
596
593
|
value: value,
|
|
597
594
|
currencyCode: currencyCode,
|
|
@@ -639,7 +636,6 @@ var form_2 = __webpack_require__(/*! ./form */ "./src/form.ts");
|
|
|
639
636
|
var client_1 = __webpack_require__(/*! ./client */ "./src/client.ts");
|
|
640
637
|
var formatter_1 = __webpack_require__(/*! ./formatter */ "./src/formatter.ts");
|
|
641
638
|
var app_1 = __webpack_require__(/*! ./app */ "./src/app.ts");
|
|
642
|
-
var component_1 = __webpack_require__(/*! ./component */ "./src/component.ts");
|
|
643
639
|
var LowcodeSDK = /** @class */ (function (_super) {
|
|
644
640
|
__extends(LowcodeSDK, _super);
|
|
645
641
|
function LowcodeSDK(props) {
|
|
@@ -665,9 +661,6 @@ var LowcodeSDK = /** @class */ (function (_super) {
|
|
|
665
661
|
LowcodeSDK.prototype.getContext = function () {
|
|
666
662
|
return this._postMessageAsync(constants_1.LISTENER_CMDS.GET_CONTEXT, {});
|
|
667
663
|
};
|
|
668
|
-
LowcodeSDK.prototype.getComponent = function (componentId) {
|
|
669
|
-
return new component_1.Component(componentId);
|
|
670
|
-
};
|
|
671
664
|
return LowcodeSDK;
|
|
672
665
|
}(base_1.BaseSDK));
|
|
673
666
|
function initSDK(config) {
|
|
@@ -703,6 +696,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
703
696
|
})();
|
|
704
697
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
705
698
|
exports.Page = void 0;
|
|
699
|
+
var component_1 = __webpack_require__(/*! ./component */ "./src/component.ts");
|
|
706
700
|
var base_1 = __webpack_require__(/*! ./base */ "./src/base.ts");
|
|
707
701
|
var constants_1 = __webpack_require__(/*! ./constants */ "./src/constants.ts");
|
|
708
702
|
var Page = /** @class */ (function (_super) {
|
|
@@ -741,6 +735,9 @@ var Page = /** @class */ (function (_super) {
|
|
|
741
735
|
return new Page(pageId);
|
|
742
736
|
});
|
|
743
737
|
};
|
|
738
|
+
Page.prototype.getComponent = function (componentId) {
|
|
739
|
+
return new component_1.Component(componentId);
|
|
740
|
+
};
|
|
744
741
|
Page.prototype.onClose = function (callback) {
|
|
745
742
|
this._registerEventListener(this._id, constants_1.EVENT_TYPES.ON_CLOSE, callback);
|
|
746
743
|
};
|