widget-web-component 1.2.0-dev → 1.3.0
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 +98 -35
- package/bundle.css +1 -1
- package/index.js +581 -581
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
## 📖 Description
|
|
4
4
|
|
|
5
|
-
This package provides
|
|
6
|
-
It can be used in **any frontend
|
|
5
|
+
This package provides `<belender-web-component>`, a reusable web component built with
|
|
6
|
+
Angular and distributed as a standalone package. It can be used in **any frontend
|
|
7
|
+
framework** (Angular, React, Vue, Lit, plain HTML/JS, etc.) without additional setup.
|
|
7
8
|
|
|
8
9
|
---
|
|
9
10
|
|
|
@@ -13,24 +14,33 @@ It can be used in **any frontend framework** (Angular, React, Vue, Lit, plain HT
|
|
|
13
14
|
npm i widget-web-component
|
|
14
15
|
```
|
|
15
16
|
|
|
16
|
-
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## 🚀 Quick start
|
|
17
20
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
The component class is generated asynchronously. Call `initBelenderComponent()`, then
|
|
22
|
+
register the custom element with the tag name of your choice.
|
|
23
|
+
|
|
24
|
+
```js
|
|
25
|
+
import { initBelenderComponent } from 'widget-web-component';
|
|
21
26
|
|
|
22
|
-
// 1. Ejecutar la función asíncrona para iniciar Angular y obtener la clase.
|
|
23
27
|
initBelenderComponent()
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
.then((BelenderWebComponent) => {
|
|
29
|
+
customElements.define('belender-web-component', BelenderWebComponent);
|
|
30
|
+
console.log('✅ Web Component registered');
|
|
31
|
+
})
|
|
32
|
+
.catch((err) => {
|
|
33
|
+
console.error('❌ Failed to register the Web Component:', err);
|
|
34
|
+
});
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Then render the element and configure it. Inputs can be set as **HTML attributes**
|
|
38
|
+
(kebab-case) or as **JS properties** (camelCase).
|
|
39
|
+
|
|
40
|
+
### Example (Lit wrapper)
|
|
41
|
+
|
|
42
|
+
```js
|
|
43
|
+
import { LitElement, html } from 'lit';
|
|
34
44
|
|
|
35
45
|
export class BelenderWidget extends LitElement {
|
|
36
46
|
connectedCallback() {
|
|
@@ -39,29 +49,82 @@ export class BelenderWidget extends LitElement {
|
|
|
39
49
|
}
|
|
40
50
|
|
|
41
51
|
loadData() {
|
|
42
|
-
const widget = this.shadowRoot
|
|
52
|
+
const widget = this.shadowRoot?.getElementById('widget');
|
|
43
53
|
if (!widget) {
|
|
44
|
-
setTimeout(() =>
|
|
45
|
-
this.loadData();
|
|
46
|
-
}, 100);
|
|
54
|
+
setTimeout(() => this.loadData(), 100);
|
|
47
55
|
return;
|
|
48
56
|
}
|
|
49
|
-
|
|
50
|
-
widget.
|
|
51
|
-
widget.
|
|
52
|
-
widget.
|
|
53
|
-
widget.
|
|
54
|
-
|
|
55
|
-
widget.birthDate = "1990/10/10";
|
|
56
|
-
widget.documentExpirationDate = "2030/1/1";
|
|
57
|
-
|
|
58
|
-
this.requestUpdate();
|
|
57
|
+
|
|
58
|
+
widget.isWebComponent = true; // required
|
|
59
|
+
widget.apiUrl = 'https://your-belender-api'; // provided by Belender (see API URL)
|
|
60
|
+
widget.flowType = 'clavepin';
|
|
61
|
+
widget.urlPath =
|
|
62
|
+
'/widget/clavepin/0d529b37-f96e-447d-be86-535b650c4a1e/ec05d020-00b6-494b-86ca-2a9b5d8c2605';
|
|
59
63
|
}
|
|
60
64
|
|
|
61
65
|
render() {
|
|
62
|
-
return html
|
|
63
|
-
<belender-web-component id="widget"></belender-web-component>
|
|
64
|
-
`;
|
|
66
|
+
return html`<belender-web-component id="widget"></belender-web-component>`;
|
|
65
67
|
}
|
|
66
68
|
}
|
|
67
|
-
```
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Example (plain HTML)
|
|
72
|
+
|
|
73
|
+
```html
|
|
74
|
+
<belender-web-component
|
|
75
|
+
is-web-component="true"
|
|
76
|
+
api-url="https://your-belender-api"
|
|
77
|
+
flow-type="clavepin"
|
|
78
|
+
user-id="0d529b37-f96e-447d-be86-535b650c4a1e"
|
|
79
|
+
package-id="ec05d020-00b6-494b-86ca-2a9b5d8c2605"
|
|
80
|
+
request-id="..."
|
|
81
|
+
></belender-web-component>
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## ⚙️ Inputs / Properties
|
|
87
|
+
|
|
88
|
+
| Property (JS) | Attribute (HTML) | Type | Description |
|
|
89
|
+
|---|---|---|---|
|
|
90
|
+
| `isWebComponent` | `is-web-component` | boolean | **Required.** Marks the instance as a web component. |
|
|
91
|
+
| `apiUrl` | `api-url` | string | Base URL of a valid Belender environment. See **API URL** below. |
|
|
92
|
+
| `urlPath` | `url-path` | string | Widget route to open, e.g. `/widget/{flow}/{userId}/{packageId}?request_id=...` |
|
|
93
|
+
| `flowType` | `flow-type` | string | Flow to launch (e.g. `clavepin`, `sms`, `videoid`, `clientcertificate`). |
|
|
94
|
+
| `userID` | `user-id` | string | User / funder id. |
|
|
95
|
+
| `requestId` | `request-id` | string | Request id (pre-request or existing request). |
|
|
96
|
+
| `packageId` | `package-id` | string | Document package id. |
|
|
97
|
+
| `editableDates` | `editable-dates` | boolean | Allows editing the date inputs. |
|
|
98
|
+
| `documentNumber` | `document-number` | string | Prefill: DNI / NIE. |
|
|
99
|
+
| `documentExpirationDate` | `document-expiration-date` | string | Prefill: document expiration (`YYYY/MM/DD`). |
|
|
100
|
+
| `documentSupport` | `document-support` | string | Prefill: document support number. |
|
|
101
|
+
| `birthDate` | `birth-date` | string | Prefill: birth date (`YYYY/MM/DD`). |
|
|
102
|
+
| `phone` | `phone` | string | Prefill: phone. |
|
|
103
|
+
| `email` | `email` | string | Prefill: email. |
|
|
104
|
+
|
|
105
|
+
> Note: the property name is camelCase (`userID` has a capital `ID`); the attribute is
|
|
106
|
+
> always kebab-case (`user-id`).
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## 🌐 API URL (`apiUrl` / `api-url`)
|
|
111
|
+
|
|
112
|
+
Sets the base URL the widget uses for all API calls. The only requirement is that it
|
|
113
|
+
points to a **valid Belender environment**. There is no fixed list of allowed URLs:
|
|
114
|
+
different URLs or domains may resolve to the same environment. Belender will tell you
|
|
115
|
+
which URL to use for your target environment.
|
|
116
|
+
|
|
117
|
+
**Default:** if `apiUrl` is not set, the URL compiled into the bundle is used. It is
|
|
118
|
+
recommended to always set `apiUrl` explicitly with the URL provided by Belender.
|
|
119
|
+
|
|
120
|
+
**Format validation:** only the URL **format** is validated before use (not the target).
|
|
121
|
+
If the value is rejected, the previous / default URL is kept and a `console.warn` is
|
|
122
|
+
logged. A value is rejected when:
|
|
123
|
+
- the protocol is not `http`/`https`,
|
|
124
|
+
- it is `http` in production (except `localhost` / `127.0.0.1` / `::1`),
|
|
125
|
+
- the URL is malformed.
|
|
126
|
+
|
|
127
|
+
Query string, hash and trailing slash are stripped from a valid URL.
|
|
128
|
+
|
|
129
|
+
> ⚠️ Only the URL **format** is validated, not the destination. The widget will only
|
|
130
|
+
> work if `apiUrl` points to a valid Belender environment.
|