@kissflow/lowcode-client-sdk 1.0.1 → 1.0.2-beta.8
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 +152 -13
- package/custom.build.js +22 -2
- package/dist/component.js +10 -0
- package/dist/constants.js +8 -1
- package/dist/form.js +89 -7
- package/dist/global.types.d.ts +39 -23
- package/dist/index.d.ts +64 -31
- package/dist/kflowcode.sdk.js +118 -15
- package/dist/kflowcode.sdk.js.map +1 -1
- package/dist/kflowcode.sdk.module.js +138 -21
- package/dist/kflowcode.sdk.module.js.map +1 -1
- package/dist/lowcode.sdk.js +7 -7
- package/dist/page.js +4 -0
- package/package.json +1 -1
- package/src/base.ts +1 -1
- package/src/component.ts +10 -0
- package/src/constants.ts +8 -1
- package/src/form.ts +112 -2
- package/src/lowcode.sdk.ts +9 -6
- package/src/page.ts +4 -0
- package/webpack.config.js +1 -2
package/README.md
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
# _Kissflow
|
|
1
|
+
# _Kissflow Lowcode JavaScript SDK_
|
|
2
2
|
|
|
3
|
-
JavaScript SDK for developing over the Kissflow
|
|
3
|
+
JavaScript SDK for developing over the Kissflow lowcode platform
|
|
4
4
|
|
|
5
5
|
### Use as an `npm` module
|
|
6
6
|
|
|
7
|
-
Install the SDK as a module: `npm i @kissflow/
|
|
7
|
+
Install the SDK as a module: `npm i @kissflow/lowcode-client-sdk` Then import into your project:
|
|
8
8
|
|
|
9
9
|
```js
|
|
10
|
-
import KFLowcodeSDK from "@kissflow/
|
|
10
|
+
import KFLowcodeSDK from "@kissflow/lowcode-client-sdk";
|
|
11
11
|
const kf = KFLowcodeSDK();
|
|
12
12
|
```
|
|
13
13
|
|
|
@@ -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
|
|
package/custom.build.js
CHANGED
|
@@ -5,7 +5,9 @@ let classMappings = {
|
|
|
5
5
|
Application: { name: "Application" },
|
|
6
6
|
Client: { name: "Client" },
|
|
7
7
|
Component: { name: "Component" },
|
|
8
|
-
Form: { name: "Form"
|
|
8
|
+
Form: { name: "Form" },
|
|
9
|
+
Table: { name: "Table" },
|
|
10
|
+
TableForm: { name: "TableForm" },
|
|
9
11
|
Formatter: { name: "Formatter" },
|
|
10
12
|
LowcodeSDK: { name: "kf", staticDeclarations: true }
|
|
11
13
|
};
|
|
@@ -48,7 +50,25 @@ function transfromTypings() {
|
|
|
48
50
|
// fields on Class
|
|
49
51
|
for (let i = 0; i < _class.fields.length; i++) {
|
|
50
52
|
// if (_class.fields[i].type.modulePath) {
|
|
51
|
-
let className =
|
|
53
|
+
let className = "";
|
|
54
|
+
if (!_class.fields[i].type) {
|
|
55
|
+
continue
|
|
56
|
+
} else if(_class.fields[i].type.options) {
|
|
57
|
+
// TODO: currently we add only the first typechecking
|
|
58
|
+
className = _class.fields[i].type.options[0].typeName;
|
|
59
|
+
|
|
60
|
+
// TODO: need to handle when there are multiple type
|
|
61
|
+
// let options = _class.fields[i].type.options
|
|
62
|
+
// for (let j = 0; j < options.length; j++) {
|
|
63
|
+
// className += options[j].typeName;
|
|
64
|
+
// if (j < options.length - 1) {
|
|
65
|
+
// className += " | ";
|
|
66
|
+
// }
|
|
67
|
+
// }
|
|
68
|
+
} else {
|
|
69
|
+
className = _class.fields[i].type.typeName;
|
|
70
|
+
}
|
|
71
|
+
|
|
52
72
|
let fieldName = _class.fields[i].name;
|
|
53
73
|
// console.log(_class.fields[i]);
|
|
54
74
|
toWrite += `\t${
|
package/dist/component.js
CHANGED
|
@@ -30,6 +30,16 @@ var Component = /** @class */ (function (_super) {
|
|
|
30
30
|
id: this.id
|
|
31
31
|
});
|
|
32
32
|
};
|
|
33
|
+
Component.prototype.show = function () {
|
|
34
|
+
return this._postMessageAsync(constants_1.LISTENER_CMDS.COMPONENT_SHOW, {
|
|
35
|
+
id: this.id
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
Component.prototype.hide = function () {
|
|
39
|
+
return this._postMessageAsync(constants_1.LISTENER_CMDS.COMPONENT_HIDE, {
|
|
40
|
+
id: this.id
|
|
41
|
+
});
|
|
42
|
+
};
|
|
33
43
|
return Component;
|
|
34
44
|
}(base_1.BaseSDK));
|
|
35
45
|
exports.Component = Component;
|
package/dist/constants.js
CHANGED
|
@@ -9,7 +9,12 @@ exports.LISTENER_CMDS = {
|
|
|
9
9
|
//Forms SDK Functions
|
|
10
10
|
GET_FORM_FIELD: "GET_FORM_FIELD",
|
|
11
11
|
UPDATE_FORM: "UPDATE_FORM",
|
|
12
|
+
GET_TABLE: "GET_TABLE",
|
|
13
|
+
GET_TABLE_ROW: "GET_TABLE_ROW",
|
|
12
14
|
ADD_TABLE_ROW: "ADD_TABLE_ROW",
|
|
15
|
+
DELETE_TABLE_ROW: "DELETE_TABLE_ROW",
|
|
16
|
+
TO_JSON: "TO_JSON",
|
|
17
|
+
GET_TABLE_ROWS: "GET_TABLE_ROWS",
|
|
13
18
|
//Client SDK functions
|
|
14
19
|
MESSAGE: "MESSAGE",
|
|
15
20
|
CONFIRM: "CONFIRM",
|
|
@@ -31,7 +36,9 @@ exports.LISTENER_CMDS = {
|
|
|
31
36
|
GET_PAGE_PARAMS: "GET_PAGE_PARAMS",
|
|
32
37
|
OPEN_POPUP_PAGE: "OPEN_POPUP_PAGE",
|
|
33
38
|
PAGE_ON_CLOSE: "PAGE_ON_CLOSE",
|
|
34
|
-
COMPONENT_REFRESH: "COMPONENT_REFRESH"
|
|
39
|
+
COMPONENT_REFRESH: "COMPONENT_REFRESH",
|
|
40
|
+
COMPONENT_SHOW: "COMPONENT_SHOW",
|
|
41
|
+
COMPONENT_HIDE: "COMPONENT_HIDE"
|
|
35
42
|
};
|
|
36
43
|
exports.EVENT_TYPES = {
|
|
37
44
|
ON_CLOSE: "onClose",
|
package/dist/form.js
CHANGED
|
@@ -15,16 +15,24 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
15
15
|
};
|
|
16
16
|
})();
|
|
17
17
|
exports.__esModule = true;
|
|
18
|
-
exports.Form = void 0;
|
|
18
|
+
exports.TableForm = exports.Form = void 0;
|
|
19
19
|
var base_1 = require("./base");
|
|
20
20
|
var constants_1 = require("./constants");
|
|
21
21
|
var Form = /** @class */ (function (_super) {
|
|
22
22
|
__extends(Form, _super);
|
|
23
|
-
function Form() {
|
|
24
|
-
|
|
23
|
+
function Form(instanceId) {
|
|
24
|
+
var _this = _super.call(this, {}) || this;
|
|
25
|
+
_this.instanceId = instanceId;
|
|
26
|
+
return _this;
|
|
25
27
|
}
|
|
28
|
+
Form.prototype.toJSON = function () {
|
|
29
|
+
return this._postMessageAsync(constants_1.LISTENER_CMDS.TO_JSON, {
|
|
30
|
+
instanceId: this.instanceId
|
|
31
|
+
});
|
|
32
|
+
};
|
|
26
33
|
Form.prototype.getField = function (fieldId) {
|
|
27
34
|
return this._postMessageAsync(constants_1.LISTENER_CMDS.GET_FORM_FIELD, {
|
|
35
|
+
instanceId: this.instanceId,
|
|
28
36
|
fieldId: fieldId
|
|
29
37
|
});
|
|
30
38
|
};
|
|
@@ -33,12 +41,86 @@ var Form = /** @class */ (function (_super) {
|
|
|
33
41
|
data: args
|
|
34
42
|
});
|
|
35
43
|
};
|
|
36
|
-
Form.prototype.
|
|
44
|
+
Form.prototype.getTable = function (tableId) {
|
|
45
|
+
return new Table(this.instanceId, tableId);
|
|
46
|
+
};
|
|
47
|
+
return Form;
|
|
48
|
+
}(base_1.BaseSDK));
|
|
49
|
+
exports.Form = Form;
|
|
50
|
+
var Table = /** @class */ (function (_super) {
|
|
51
|
+
__extends(Table, _super);
|
|
52
|
+
function Table(instanceId, tableId) {
|
|
53
|
+
var _this = _super.call(this, {}) || this;
|
|
54
|
+
_this.tableId = tableId;
|
|
55
|
+
_this.instanceId = instanceId;
|
|
56
|
+
return _this;
|
|
57
|
+
}
|
|
58
|
+
// list of obj of rows
|
|
59
|
+
Table.prototype.toJSON = function () {
|
|
60
|
+
return this._postMessageAsync(constants_1.LISTENER_CMDS.TO_JSON, {
|
|
61
|
+
tableId: this.tableId
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
Table.prototype.getRows = function () {
|
|
65
|
+
var _this = this;
|
|
66
|
+
// list of TableForm class
|
|
67
|
+
return this._postMessageAsync(constants_1.LISTENER_CMDS.GET_TABLE_ROWS, { tableId: this.tableId }, true, // has callBack
|
|
68
|
+
function (data) {
|
|
69
|
+
console.log(data);
|
|
70
|
+
return data.map(function (row) { return new TableForm(_this.instanceId, _this.tableId, row.id); });
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
Table.prototype.getRow = function (rowId) {
|
|
74
|
+
return new TableForm(this.instanceId, this.tableId, rowId);
|
|
75
|
+
};
|
|
76
|
+
Table.prototype.addRow = function (rowObject) {
|
|
37
77
|
return this._postMessageAsync(constants_1.LISTENER_CMDS.ADD_TABLE_ROW, {
|
|
38
|
-
tableId: tableId,
|
|
78
|
+
tableId: this.tableId,
|
|
39
79
|
rowObject: rowObject
|
|
40
80
|
});
|
|
41
81
|
};
|
|
42
|
-
|
|
82
|
+
Table.prototype.deleteRow = function (rowId) {
|
|
83
|
+
return this._postMessageAsync(constants_1.LISTENER_CMDS.DELETE_TABLE_ROW, {
|
|
84
|
+
tableId: this.tableId,
|
|
85
|
+
rowId: rowId
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
return Table;
|
|
43
89
|
}(base_1.BaseSDK));
|
|
44
|
-
|
|
90
|
+
var TableForm = /** @class */ (function (_super) {
|
|
91
|
+
__extends(TableForm, _super);
|
|
92
|
+
function TableForm(instanceId, tableId, rowId) {
|
|
93
|
+
var _this = _super.call(this, {}) || this;
|
|
94
|
+
_this.instanceId = instanceId;
|
|
95
|
+
_this.tableId = tableId;
|
|
96
|
+
_this.rowId = rowId;
|
|
97
|
+
return _this;
|
|
98
|
+
}
|
|
99
|
+
TableForm.prototype.getParent = function () {
|
|
100
|
+
return new Form(this.instanceId);
|
|
101
|
+
};
|
|
102
|
+
TableForm.prototype.toJSON = function () {
|
|
103
|
+
return this._postMessageAsync(constants_1.LISTENER_CMDS.TO_JSON, {
|
|
104
|
+
tableId: this.tableId,
|
|
105
|
+
rowId: this.rowId
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
TableForm.prototype.getField = function (fieldId) {
|
|
109
|
+
return this._postMessageAsync(constants_1.LISTENER_CMDS.GET_FORM_FIELD, {
|
|
110
|
+
instanceId: this.instanceId,
|
|
111
|
+
tableId: this.tableId,
|
|
112
|
+
rowId: this.rowId,
|
|
113
|
+
fieldId: fieldId
|
|
114
|
+
});
|
|
115
|
+
};
|
|
116
|
+
TableForm.prototype.updateField = function (args) {
|
|
117
|
+
return this._postMessageAsync(constants_1.LISTENER_CMDS.UPDATE_FORM, {
|
|
118
|
+
instanceId: this.instanceId,
|
|
119
|
+
tableId: this.tableId,
|
|
120
|
+
rowId: this.rowId,
|
|
121
|
+
data: args
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
return TableForm;
|
|
125
|
+
}(base_1.BaseSDK));
|
|
126
|
+
exports.TableForm = TableForm;
|
package/dist/global.types.d.ts
CHANGED
|
@@ -1,46 +1,63 @@
|
|
|
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
|
-
getParameter(key: string):
|
|
5
|
-
getVariable(key: string):
|
|
6
|
-
setVariable(key: string, value: any):
|
|
10
|
+
getParameter(key: string): any;
|
|
11
|
+
getVariable(key: string): any;
|
|
12
|
+
setVariable(key: string, value: any): any;
|
|
7
13
|
openPopup(pageId: string, inputParams: object, popupProperties: {
|
|
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 {
|
|
14
21
|
page: Page
|
|
15
|
-
getVariable(key: string):
|
|
16
|
-
setVariable(key: string | object, value: any):
|
|
17
|
-
openPage(pageId: string, pageParams: object):
|
|
22
|
+
getVariable(key: string): any;
|
|
23
|
+
setVariable(key: string | object, value: any): any;
|
|
24
|
+
openPage(pageId: string, pageParams: object): any;
|
|
18
25
|
}
|
|
19
26
|
declare class Client {
|
|
20
|
-
showInfo(message: string):
|
|
27
|
+
showInfo(message: string): any;
|
|
21
28
|
showConfirm(args: {
|
|
22
29
|
title: string;
|
|
23
30
|
content: string;
|
|
24
31
|
okText: string;
|
|
25
32
|
cancelText: string;
|
|
26
|
-
}):
|
|
27
|
-
redirect(url: string):
|
|
28
|
-
}
|
|
29
|
-
declare class Component {
|
|
30
|
-
id: string
|
|
31
|
-
refresh(): string | object;
|
|
33
|
+
}): any;
|
|
34
|
+
redirect(url: string): any;
|
|
32
35
|
}
|
|
33
36
|
declare class Form {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
+
toJSON(): any;
|
|
38
|
+
getField(fieldId: string): any;
|
|
39
|
+
updateField(args: object): any;
|
|
40
|
+
getTable(tableId: string): Table;
|
|
41
|
+
}
|
|
42
|
+
declare class Table {
|
|
43
|
+
toJSON(): any;
|
|
44
|
+
getRows(): TableForm[];
|
|
45
|
+
getRow(rowId: string): TableForm;
|
|
46
|
+
addRow(rowObject: object): any;
|
|
47
|
+
deleteRow(rowId: string): any;
|
|
48
|
+
}
|
|
49
|
+
declare class TableForm {
|
|
50
|
+
getParent(): Form;
|
|
51
|
+
toJSON(): any;
|
|
52
|
+
getField(fieldId: string): any;
|
|
53
|
+
updateField(args: object): any;
|
|
37
54
|
}
|
|
38
55
|
declare class Formatter {
|
|
39
|
-
toKfDate(date: string):
|
|
40
|
-
toKfDateTime(date: string):
|
|
41
|
-
toKfNumber(value: string):
|
|
42
|
-
toKfCurrency(value: string, currencyCode: string):
|
|
43
|
-
toBoolean(value: string):
|
|
56
|
+
toKfDate(date: string): any;
|
|
57
|
+
toKfDateTime(date: string): any;
|
|
58
|
+
toKfNumber(value: string): any;
|
|
59
|
+
toKfCurrency(value: string, currencyCode: string): any;
|
|
60
|
+
toBoolean(value: string): any;
|
|
44
61
|
}
|
|
45
62
|
declare class kf {
|
|
46
63
|
static currentForm: Form
|
|
@@ -50,5 +67,4 @@ declare class kf {
|
|
|
50
67
|
api(url: string, args?: {}): string | object;
|
|
51
68
|
watchParams(func: (data: any) => any): void;
|
|
52
69
|
getContext(): string | object;
|
|
53
|
-
getComponent(componentId: string): Component;
|
|
54
70
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,12 @@ declare module "constants" {
|
|
|
6
6
|
RETURN: string;
|
|
7
7
|
GET_FORM_FIELD: string;
|
|
8
8
|
UPDATE_FORM: string;
|
|
9
|
+
GET_TABLE: string;
|
|
10
|
+
GET_TABLE_ROW: string;
|
|
9
11
|
ADD_TABLE_ROW: string;
|
|
12
|
+
DELETE_TABLE_ROW: string;
|
|
13
|
+
TO_JSON: string;
|
|
14
|
+
GET_TABLE_ROWS: string;
|
|
10
15
|
MESSAGE: string;
|
|
11
16
|
CONFIRM: string;
|
|
12
17
|
ALERT: string;
|
|
@@ -25,6 +30,8 @@ declare module "constants" {
|
|
|
25
30
|
OPEN_POPUP_PAGE: string;
|
|
26
31
|
PAGE_ON_CLOSE: string;
|
|
27
32
|
COMPONENT_REFRESH: string;
|
|
33
|
+
COMPONENT_SHOW: string;
|
|
34
|
+
COMPONENT_HIDE: string;
|
|
28
35
|
};
|
|
29
36
|
export const EVENT_TYPES: {
|
|
30
37
|
ON_CLOSE: string;
|
|
@@ -36,23 +43,35 @@ declare module "base" {
|
|
|
36
43
|
export class BaseSDK {
|
|
37
44
|
#private;
|
|
38
45
|
constructor(props: any);
|
|
39
|
-
_postMessageAsync(command: string, args: any, hasCallBack?: boolean, callBack?: (data: any) => {}): object | string;
|
|
46
|
+
_postMessageAsync(command: string, args: any, hasCallBack?: boolean, callBack?: (data: any) => {}): object | string | any;
|
|
40
47
|
_postMessage(command: string, func: (data: any) => {}, args?: {}): void;
|
|
41
48
|
_registerEventListener(_id: string, eventType: string, callback: any): void;
|
|
42
49
|
}
|
|
43
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
|
+
}
|
|
44
61
|
declare module "page" {
|
|
62
|
+
import { Component } from "component";
|
|
45
63
|
import { BaseSDK } from "base";
|
|
46
64
|
export class Page extends BaseSDK {
|
|
47
65
|
_id: string;
|
|
48
66
|
constructor(pageId: string);
|
|
49
|
-
getParameter(key: string):
|
|
50
|
-
getVariable(key: string):
|
|
51
|
-
setVariable(key: string, value: any):
|
|
67
|
+
getParameter(key: string): any;
|
|
68
|
+
getVariable(key: string): any;
|
|
69
|
+
setVariable(key: string, value: any): any;
|
|
52
70
|
openPopup(pageId: string, inputParams: object, popupProperties: {
|
|
53
71
|
w: number;
|
|
54
72
|
h: number;
|
|
55
|
-
}):
|
|
73
|
+
}): any;
|
|
74
|
+
getComponent(componentId: string): Component;
|
|
56
75
|
onClose(callback: Function): void;
|
|
57
76
|
}
|
|
58
77
|
}
|
|
@@ -62,59 +81,74 @@ declare module "app" {
|
|
|
62
81
|
export class Application extends BaseSDK {
|
|
63
82
|
page: Page;
|
|
64
83
|
constructor(props: any);
|
|
65
|
-
getVariable(key: string):
|
|
66
|
-
setVariable(key: string | object, value: any):
|
|
67
|
-
openPage(pageId: string, pageParams: object):
|
|
84
|
+
getVariable(key: string): any;
|
|
85
|
+
setVariable(key: string | object, value: any): any;
|
|
86
|
+
openPage(pageId: string, pageParams: object): any;
|
|
68
87
|
}
|
|
69
88
|
}
|
|
70
89
|
declare module "client" {
|
|
71
90
|
import { BaseSDK } from "base";
|
|
72
91
|
export class Client extends BaseSDK {
|
|
73
|
-
showInfo(message: string):
|
|
92
|
+
showInfo(message: string): any;
|
|
74
93
|
showConfirm(args: {
|
|
75
94
|
title: string;
|
|
76
95
|
content: string;
|
|
77
96
|
okText: string;
|
|
78
97
|
cancelText: string;
|
|
79
|
-
}):
|
|
80
|
-
redirect(url: string):
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
declare module "component" {
|
|
84
|
-
import { BaseSDK } from "base";
|
|
85
|
-
export class Component extends BaseSDK {
|
|
86
|
-
id: string;
|
|
87
|
-
constructor(id: string);
|
|
88
|
-
refresh(): string | object;
|
|
98
|
+
}): any;
|
|
99
|
+
redirect(url: string): any;
|
|
89
100
|
}
|
|
90
101
|
}
|
|
91
102
|
declare module "form" {
|
|
92
103
|
import { BaseSDK } from "base";
|
|
93
104
|
export class Form extends BaseSDK {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
105
|
+
private instanceId;
|
|
106
|
+
constructor(instanceId: string);
|
|
107
|
+
toJSON(): any;
|
|
108
|
+
getField(fieldId: string): any;
|
|
109
|
+
updateField(args: object): any;
|
|
110
|
+
getTable(tableId: string): Table;
|
|
111
|
+
}
|
|
112
|
+
class Table extends BaseSDK {
|
|
113
|
+
private tableId;
|
|
114
|
+
private instanceId;
|
|
115
|
+
constructor(instanceId: string, tableId: string);
|
|
116
|
+
toJSON(): any;
|
|
117
|
+
getRows(): TableForm[];
|
|
118
|
+
getRow(rowId: string): TableForm;
|
|
119
|
+
addRow(rowObject: object): any;
|
|
120
|
+
deleteRow(rowId: string): any;
|
|
121
|
+
}
|
|
122
|
+
export class TableForm extends BaseSDK {
|
|
123
|
+
private instanceId;
|
|
124
|
+
private tableId;
|
|
125
|
+
private rowId;
|
|
126
|
+
constructor(instanceId: string, tableId: string, rowId: string);
|
|
127
|
+
getParent(): Form;
|
|
128
|
+
toJSON(): any;
|
|
129
|
+
getField(fieldId: string): any;
|
|
130
|
+
updateField(args: object): any;
|
|
97
131
|
}
|
|
98
132
|
}
|
|
99
133
|
declare module "formatter" {
|
|
100
134
|
import { BaseSDK } from "base";
|
|
101
135
|
export class Formatter extends BaseSDK {
|
|
102
|
-
toKfDate(date: string):
|
|
103
|
-
toKfDateTime(date: string):
|
|
104
|
-
toKfNumber(value: string):
|
|
105
|
-
toKfCurrency(value: string, currencyCode: string):
|
|
106
|
-
toBoolean(value: string):
|
|
136
|
+
toKfDate(date: string): any;
|
|
137
|
+
toKfDateTime(date: string): any;
|
|
138
|
+
toKfNumber(value: string): any;
|
|
139
|
+
toKfCurrency(value: string, currencyCode: string): any;
|
|
140
|
+
toBoolean(value: string): any;
|
|
107
141
|
}
|
|
108
142
|
}
|
|
109
143
|
declare module "lowcode.sdk" {
|
|
110
144
|
import { BaseSDK } from "base";
|
|
111
145
|
import { Form } from "form";
|
|
146
|
+
import { TableForm } from "form";
|
|
112
147
|
import { Client } from "client";
|
|
113
148
|
import { Formatter } from "formatter";
|
|
114
149
|
import { Application } from "app";
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
currentForm: Form;
|
|
150
|
+
class LowcodeSDK extends BaseSDK {
|
|
151
|
+
currentForm: Form | TableForm;
|
|
118
152
|
client: Client;
|
|
119
153
|
formatter: Formatter;
|
|
120
154
|
app: Application;
|
|
@@ -122,7 +156,6 @@ declare module "lowcode.sdk" {
|
|
|
122
156
|
api(url: string, args?: {}): string | object;
|
|
123
157
|
watchParams(func: (data: any) => any): void;
|
|
124
158
|
getContext(): string | object;
|
|
125
|
-
getComponent(componentId: string): Component;
|
|
126
159
|
}
|
|
127
160
|
function initSDK(config?: any): LowcodeSDK;
|
|
128
161
|
export default initSDK;
|