@soyio/soyio-widget 0.0.14 → 0.0.15

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
@@ -1,4 +1,5 @@
1
1
  # soy-io-widget
2
+
2
3
  This is the library for include a soyio widget.
3
4
 
4
5
  This library contemplate that a div element with ID: `soyio-widget-iframe-container` should be created before instantiate the widget.
@@ -7,26 +8,29 @@ This library contemplate that a div element with ID: `soyio-widget-iframe-contai
7
8
 
8
9
  For frontend frameworks, this should be imported as follows.
9
10
 
10
- ``` html
11
+ ```html
11
12
  <script>
12
- // insert setup of your framework here!!
13
- document.addEventListener('DOMContentLoaded', function() {
14
- new Widget({ userEmail: 'example@email.com', companyName: 'Company name'})
15
- });
13
+ const flow = '<flow>' // Can only take the values of 'register' or 'authenticate'
14
+
15
+ const configProps = {
16
+ companyId: '<company id>', // Starts with 'com_'
17
+ userReference?: '<user identifier of company>' // Optional
18
+ flowTemplateId: '<flow template id', // Starts with 'vft_' only needed in 'register' flow
19
+ identityId: '<identity id>' // Starts with 'id_' only needed in 'authenticate' flow
20
+ }
21
+
22
+ const onEvent = (data) => {
23
+ console.log('APPLICATION: EVENT!');
24
+ console.log(data);
25
+ }
26
+
27
+ // Create widget when needed. In this example, widget is created when page is loaded.
28
+ document.addEventListener('DOMContentLoaded', function() {
29
+ new Widget(flow, configProps, onEvent)
30
+ });
16
31
  </script>
32
+
17
33
  <body>
18
34
  <div id="soyio-widget-iframe-container"></div>
19
35
  </body>
20
-
21
36
  ```
22
-
23
- The widget class receive the following object when is initialized:
24
-
25
- ```JS
26
- {
27
- userEmail?: string
28
- companyName?: string
29
- }
30
- ```
31
-
32
- And if there is an email this is sended to the iframe.