@kissflow/lowcode-client-sdk 1.0.12 → 1.0.13-beta

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 CHANGED
@@ -54,6 +54,9 @@ let resp = await kf.api(url, config)
54
54
  - [3. Application](#3-application)
55
55
  - [4. Page](#4-page)
56
56
  - [5. Component](#5-component)
57
+ - [Standard Component methods](#standard-component-methods)
58
+ - [Component Specific methods](#component-specific-methods)
59
+ - [Tab](#521-tab-component)
57
60
  - [6. Popup](#6-popup)
58
61
  - [7. Formatter](#7-formatter)
59
62
 
@@ -345,26 +348,40 @@ kf.app.page.openPopup("popupId", { inputParam1: "value" });
345
348
  ```
346
349
 
347
350
  ### 5) Component
348
-
351
+ #### getComponent(id)
352
+ Parameter: Component's Id
353
+ Returns: Component class instance
349
354
  ```js
350
355
  const component = await kf.app.page.getComponent(componentId);
351
356
  ```
352
- By using component instance we can invoke following methods.
353
-
354
- ##### Refresh a component
357
+ ##### Standard Component Methods
355
358
  ```js
356
- component.refresh();
359
+ component.refresh(); // Refreshes the component
360
+ component.hide(); // Hides the component
361
+ component.show(); // Shows the component if it's been hidden previously
357
362
  ```
363
+ ##### Component Specific Methods
358
364
 
359
- ##### Show a component
365
+
366
+ ##### 5.2.0) Component onMount
367
+ Component onMount takes in callBack function as argument.
368
+ > ##### Note: Any component specific methods that are used on Page load must be called inside component's onMount event.
369
+ Parameter: function
360
370
  ```js
361
- componentName.show();
371
+ component.onMount(() => {
372
+ // function logic goes here... For eg.
373
+ // component.setActiveTab(2)
374
+ })
362
375
  ```
363
-
364
- ##### Hide a component
376
+ ##### 5.2.1) Tab component
377
+ ##### 1) setActiveTab
378
+ Sets specified tab as active.
379
+ Parameter: Tabs' Number (Starts from 1 to N)
365
380
  ```js
366
- component.hide();
381
+ component.setActiveTab(2) // sets 2nd tab as active one
367
382
  ```
383
+
384
+
368
385
  ### 6) Popup
369
386
  `kf.app.page.popup` returns the active popup instance opened inside the page and its id can be accessed via `kf.app.page.popup._id`
370
387
  And `kf.app.page.getPopup(id)` returns this popup class instance.
@@ -376,7 +393,7 @@ let value = await kf.app.page.popup.getParameter("parameterId"); // for retreivi
376
393
  Get all popup parameters
377
394
  ```js
378
395
  let allParams = await kf.app.page.popup.getAllParameters();
379
- // returns an object
396
+ // Returns an object
380
397
  {
381
398
  parameterName: "Sample value",
382
399
  parameterName2: "Sample value 2"
@@ -441,4 +458,3 @@ let value = await kf.formatter.toBoolean("no");
441
458
  let value = await kf.formatter.toBoolean("0");
442
459
  let value = await kf.formatter.toBoolean("false");
443
460
  ```
444
-
package/dist/index.d.ts CHANGED
@@ -1,7 +1,6 @@
1
- declare module "constants" {
1
+ declare module "core/constants" {
2
2
  export const LISTENER_CMDS: {
3
3
  API: string;
4
- PARAMS: string;
5
4
  GET_CONTEXT: string;
6
5
  RETURN: string;
7
6
  GET_FORM_FIELD: string;
@@ -33,30 +32,44 @@ declare module "constants" {
33
32
  GET_POPUP_PARAMS: string;
34
33
  GET_ALL_POPUP_PARAMS: string;
35
34
  CLOSE_POPUP: string;
36
- GET_COMPONENT: string;
35
+ COMPONENT_GET: string;
37
36
  COMPONENT_REFRESH: string;
38
37
  COMPONENT_SHOW: string;
39
38
  COMPONENT_HIDE: string;
40
- INITIALIZE_CUST_COMP: string;
39
+ COMPONENT_ADD_EVENT_LISTENER: string;
40
+ CC_INITIALIZE: string;
41
+ CC_WATCH_PARAMS: string;
42
+ WINDOW_NDEF_READER_NEW: string;
43
+ WINDOW_NDEF_READER_SCAN: string;
44
+ WINDOW_NDEF_READER_WRITE: string;
45
+ WINDOW_NDEF_READER_ADD_EVENT_LISTENER: string;
46
+ WINDOW_NDEF_READER_MAKE_READONLY: string;
47
+ WINDOW_NDEF_READER_ABORT_SCAN: string;
41
48
  };
42
49
  export const EVENT_TYPES: {
43
- ON_CLOSE: string;
44
- POPUP_ON_CLOSE: string;
45
- ON_CHANGE: string;
46
- ON_LOAD: string;
50
+ COMPONENT_ON_MOUNT: string;
51
+ CC_ON_PARAMS_CHANGE: string;
47
52
  };
48
53
  export const DEFAULTS: {
49
54
  POPUP_ID: string;
50
55
  };
51
56
  }
52
- declare module "base" {
53
- export class BaseSDK {
57
+ declare module "core/index" {
58
+ export function generateId(prefix?: string): string;
59
+ export const globalInstances: {};
60
+ export class EventBase {
54
61
  #private;
55
- constructor(props: any);
62
+ constructor();
63
+ _addEventListener(eventName: string, callBack: Function): void;
64
+ _removeEventListener(eventName: string, callBack?: any): void;
65
+ _dispatchEvent(eventName: string, eventParams: object): boolean;
66
+ _dispatchMessageEvents(req: any, resp: any): void;
67
+ }
68
+ export class BaseSDK extends EventBase {
56
69
  _postMessageAsync(command: string, args: any, hasCallBack?: boolean, callBack?: (data: any) => {}): object | string | any;
57
- _postMessage(command: string, func: (data: any) => {}, args?: {}): void;
58
- _registerEventListener(_id: string, eventType: string, callback: any): void;
70
+ _postMessage(command: string, args: any, callBack?: any): void;
59
71
  }
72
+ export * from "core/constants";
60
73
  }
61
74
  declare module "types/external" {
62
75
  export type userObject = {
@@ -80,7 +93,7 @@ declare module "types/internal" {
80
93
  tableId: string;
81
94
  tableRowId: string;
82
95
  componentId: string;
83
- manifestMethods?: manifestMethodsType[];
96
+ componentMethods?: componentMethodsType[];
84
97
  appId: string;
85
98
  pageId: string;
86
99
  popupId: string;
@@ -89,14 +102,14 @@ declare module "types/internal" {
89
102
  csrfToken: string;
90
103
  envDetails: environmentObject;
91
104
  }
92
- export interface manifestMethodsType {
105
+ export interface componentMethodsType {
93
106
  name: string;
94
107
  returnType?: string;
95
108
  parameters?: string[];
96
109
  }
97
110
  export interface ComponentProps {
98
111
  componentId: string;
99
- manifestMethods?: manifestMethodsType[];
112
+ componentMethods?: componentMethodsType[];
100
113
  }
101
114
  export interface AppContext {
102
115
  appId: string;
@@ -109,26 +122,29 @@ declare module "types/internal" {
109
122
  popupId?: string;
110
123
  }
111
124
  }
112
- declare module "component" {
113
- import { BaseSDK } from "base";
125
+ declare module "app/component" {
126
+ import { BaseSDK } from "core/index";
114
127
  import { ComponentProps } from "types/internal";
115
128
  export class Component extends BaseSDK {
129
+ #private;
116
130
  _id: string;
117
131
  type: string;
118
132
  constructor(props: ComponentProps);
133
+ onMount(callback: Function): void;
119
134
  refresh(): any;
120
135
  show(): any;
121
136
  hide(): any;
122
137
  }
123
138
  export class CustomComponent extends BaseSDK {
124
139
  type: string;
125
- constructor();
126
- watchParams(func: (data: any) => any): void;
140
+ _id: string;
141
+ constructor(id: any);
142
+ watchParams(callBack: (data: any) => any): void;
127
143
  }
128
144
  }
129
- declare module "popup" {
130
- import { Component } from "component";
131
- import { BaseSDK } from "base";
145
+ declare module "app/popup" {
146
+ import { BaseSDK } from "core/index";
147
+ import { Component } from "app/component";
132
148
  import { PopupContext } from "types/internal";
133
149
  export class Popup extends BaseSDK {
134
150
  _id: string;
@@ -140,10 +156,10 @@ declare module "popup" {
140
156
  getComponent(componentId: string): Component;
141
157
  }
142
158
  }
143
- declare module "page" {
144
- import { Component } from "component";
145
- import { BaseSDK } from "base";
146
- import { Popup } from "popup";
159
+ declare module "app/page" {
160
+ import { BaseSDK } from "core/index";
161
+ import { Component } from "app/component";
162
+ import { Popup } from "app/popup";
147
163
  import { PageContext } from "types/internal";
148
164
  export class Page extends BaseSDK {
149
165
  _id: string;
@@ -158,21 +174,24 @@ declare module "page" {
158
174
  getComponent(componentId: string): Component;
159
175
  }
160
176
  }
161
- declare module "app" {
162
- import { BaseSDK } from "base";
163
- import { Page } from "page";
177
+ declare module "app/index" {
178
+ import { BaseSDK } from "core/index";
179
+ import { Page } from "app/page";
164
180
  import { AppContext } from "types/internal";
165
181
  export class Application extends BaseSDK {
166
182
  page: Page;
167
183
  _id: string;
168
184
  constructor(props: AppContext);
169
185
  getVariable(key: string): any;
170
- setVariable(key: string | object, value: any): any;
186
+ setVariable(key: string | object, value?: any): any;
171
187
  openPage(pageId: string, pageParams: object): any;
172
188
  }
189
+ export * from "app/component";
190
+ export { Page };
191
+ export * from "app/popup";
173
192
  }
174
- declare module "client" {
175
- import { BaseSDK } from "base";
193
+ declare module "utils/client" {
194
+ import { BaseSDK } from "core/index";
176
195
  export class Client extends BaseSDK {
177
196
  showInfo(message: string): any;
178
197
  showConfirm(args: {
@@ -184,8 +203,44 @@ declare module "client" {
184
203
  redirect(url: string): any;
185
204
  }
186
205
  }
187
- declare module "form" {
188
- import { BaseSDK } from "base";
206
+ declare module "utils/formatter" {
207
+ import { BaseSDK } from "core/index";
208
+ export class Formatter extends BaseSDK {
209
+ toDate(date: string): any;
210
+ toDateTime(date: string): any;
211
+ toNumber(value: string): any;
212
+ toCurrency(value: string, currencyCode: string): any;
213
+ toBoolean(value: string): any;
214
+ }
215
+ }
216
+ declare module "utils/index" {
217
+ export * from "utils/client";
218
+ export * from "utils/formatter";
219
+ }
220
+ declare module "index" {
221
+ import { BaseSDK } from "core/index";
222
+ import { Application, Page, CustomComponent } from "app/index";
223
+ import { Client, Formatter } from "utils/index";
224
+ import { userObject, accountObject, environmentObject } from "types/external";
225
+ class CustomComponentSDK extends BaseSDK {
226
+ app: Application;
227
+ page: Page;
228
+ user: userObject;
229
+ account: accountObject;
230
+ context: CustomComponent;
231
+ client: Client;
232
+ formatter: Formatter;
233
+ env: environmentObject;
234
+ constructor();
235
+ api(url: string, args?: {}): string | object;
236
+ initialize(): any;
237
+ initialise(): any;
238
+ }
239
+ const _default: CustomComponentSDK;
240
+ export default _default;
241
+ }
242
+ declare module "form/index" {
243
+ import { BaseSDK } from "core/index";
189
244
  export class Form extends BaseSDK {
190
245
  private instanceId;
191
246
  type: string;
@@ -217,38 +272,21 @@ declare module "form" {
217
272
  updateField(args: object): any;
218
273
  }
219
274
  }
220
- declare module "formatter" {
221
- import { BaseSDK } from "base";
222
- export class Formatter extends BaseSDK {
223
- toDate(date: string): any;
224
- toDateTime(date: string): any;
225
- toNumber(value: string): any;
226
- toCurrency(value: string, currencyCode: string): any;
227
- toBoolean(value: string): any;
228
- }
229
- }
230
- declare module "index" {
231
- import { BaseSDK } from "base";
232
- import { Client } from "client";
233
- import { Formatter } from "formatter";
234
- import { Application } from "app";
235
- import { Page } from "page";
236
- import { CustomComponent } from "component";
237
- import { userObject, accountObject, environmentObject } from "types/external";
238
- class CustomComponentSDK extends BaseSDK {
239
- app: Application;
240
- page: Page;
241
- user: userObject;
242
- account: accountObject;
243
- context: CustomComponent;
244
- client: Client;
245
- formatter: Formatter;
246
- env: environmentObject;
275
+ declare module "window/NDEFReader" {
276
+ import { BaseSDK } from "core/index";
277
+ export class NDEFReader extends BaseSDK {
278
+ id: string;
247
279
  constructor();
248
- api(url: string, args?: {}): string | object;
249
- initialize(): any;
250
- initialise(): any;
280
+ scan(): Promise<unknown>;
281
+ write(data: any): Promise<unknown>;
282
+ addEventListener(eventName: string, cb: Function): void;
283
+ makeReadOnly(): Promise<unknown>;
284
+ abortScan(): Promise<unknown>;
251
285
  }
252
- const _default: CustomComponentSDK;
253
- export default _default;
286
+ }
287
+ declare module "window/index" {
288
+ import { NDEFReader } from "window/NDEFReader";
289
+ export const window: {
290
+ NDEFReader: typeof NDEFReader;
291
+ };
254
292
  }