@quandis/qbo4.ui-bridge 4.0.1-CI-20240919-212538
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/package.json +59 -0
- package/src/Program.d.ts +9 -0
- package/src/Program.js +9 -0
- package/src/Program.ts +10 -0
- package/src/qbo-badge.d.ts +32 -0
- package/src/qbo-badge.js +93 -0
- package/src/qbo-badge.js.map +1 -0
- package/src/qbo-badge.ts +79 -0
- package/src/qbo-breadcrumb.d.ts +23 -0
- package/src/qbo-breadcrumb.js +132 -0
- package/src/qbo-breadcrumb.ts +96 -0
- package/src/qbo-contact-name.d.ts +22 -0
- package/src/qbo-contact-name.js +139 -0
- package/src/qbo-contact-name.ts +97 -0
- package/src/qbo-contact.d.ts +21 -0
- package/src/qbo-contact.js +250 -0
- package/src/qbo-contact.ts +211 -0
- package/src/qbo-mainmenu.d.ts +41 -0
- package/src/qbo-mainmenu.js +314 -0
- package/src/qbo-mainmenu.ts +270 -0
- package/src/qbo-sidebar.d.ts +10 -0
- package/src/qbo-sidebar.js +65 -0
- package/src/qbo-sidebar.ts +41 -0
- package/src/qbo-ssn.d.ts +26 -0
- package/src/qbo-ssn.js +174 -0
- package/src/qbo-ssn.ts +132 -0
- package/src/styles.d.ts +3 -0
- package/src/styles.js +27 -0
- package/src/styles.ts +30 -0
- package/wwwroot/js/qbo4.ui-bridge.js +75902 -0
- package/wwwroot/js/qbo4.ui-bridge.min.js +432 -0
- package/wwwroot/js/qbo4.ui-bridge.min.js.LICENSE.txt +49 -0
- package/wwwroot/js/qbo4.ui-bridge.min.js.map +1 -0
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
import { html, LitElement, PropertyValues } from 'lit';
|
|
2
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
3
|
+
import { QboFetch } from '@quandis/qbo4.ui/src/qbo/qbo-fetch.js';
|
|
4
|
+
import { Popover } from 'bootstrap';
|
|
5
|
+
import { IApiService, RestApiService, services } from '@quandis/qbo4.ui';
|
|
6
|
+
|
|
7
|
+
@customElement('qbo-mainmenu')
|
|
8
|
+
export class QboMainMenu extends LitElement {
|
|
9
|
+
|
|
10
|
+
@property({ type: String })
|
|
11
|
+
ariaExpanded = 'false';
|
|
12
|
+
|
|
13
|
+
@property({ type: String })
|
|
14
|
+
ariaLabel = 'Toggle menu';
|
|
15
|
+
|
|
16
|
+
@property({ type: String })
|
|
17
|
+
buttonType = 'button';
|
|
18
|
+
|
|
19
|
+
@property({ type: String })
|
|
20
|
+
collapseToggle = 'collapse';
|
|
21
|
+
|
|
22
|
+
@property({ type: String })
|
|
23
|
+
dblClickClass = 'qbo-doubleclick';
|
|
24
|
+
|
|
25
|
+
@property({ type: String })
|
|
26
|
+
dropdownId = 'qboMainMenu';
|
|
27
|
+
|
|
28
|
+
@property({ type: String })
|
|
29
|
+
dropdownToggle = 'dropdown';
|
|
30
|
+
|
|
31
|
+
@property({ type: String })
|
|
32
|
+
iconClass = 'qbo-icon';
|
|
33
|
+
|
|
34
|
+
@property({ type: String })
|
|
35
|
+
liLinkToggleClass = 'qbo-dropdown';
|
|
36
|
+
|
|
37
|
+
@property({ type: String })
|
|
38
|
+
liLinkClass = 'qbo-nav-item';
|
|
39
|
+
|
|
40
|
+
@property({ type: String })
|
|
41
|
+
liAMenuClass = 'qbo-dropdown-item';
|
|
42
|
+
|
|
43
|
+
@property({ type: String })
|
|
44
|
+
navClass = 'qbo-mainmenu';
|
|
45
|
+
|
|
46
|
+
@property({ type: String })
|
|
47
|
+
popoverContainer = 'body';
|
|
48
|
+
|
|
49
|
+
@property({ type: String })
|
|
50
|
+
popoverHtml = 'false';
|
|
51
|
+
|
|
52
|
+
@property({ type: String })
|
|
53
|
+
popoverPlacement = 'bottom';
|
|
54
|
+
|
|
55
|
+
@property({ type: String })
|
|
56
|
+
popoverToggle = 'popover';
|
|
57
|
+
|
|
58
|
+
@property({ type: String })
|
|
59
|
+
popoverTrigger = 'hover';
|
|
60
|
+
|
|
61
|
+
@property({ type: String })
|
|
62
|
+
spanMenuClass = 'qbo-submenuexpand';
|
|
63
|
+
|
|
64
|
+
@property({ type: String })
|
|
65
|
+
spanMenuValue = '>';
|
|
66
|
+
|
|
67
|
+
@property({ type: String })
|
|
68
|
+
ulMainMenuToggleClass = 'qbo-dropdown-mainmenu';
|
|
69
|
+
|
|
70
|
+
@property({ type: String })
|
|
71
|
+
ulSubMenuClass = 'submenu';
|
|
72
|
+
|
|
73
|
+
@property({ type: String })
|
|
74
|
+
ulSubMenuToggleClass = 'dropdown-menu';
|
|
75
|
+
|
|
76
|
+
@property({ type: String })
|
|
77
|
+
apiEndpoint = 'qbo';
|
|
78
|
+
|
|
79
|
+
@property({ type: Boolean })
|
|
80
|
+
renderInHost = true;
|
|
81
|
+
|
|
82
|
+
@property({ type: Object })
|
|
83
|
+
jsonData: any | null = {};
|
|
84
|
+
|
|
85
|
+
targetElement: Element | null = null;
|
|
86
|
+
|
|
87
|
+
createRenderRoot() {
|
|
88
|
+
return this.renderInHost ? this : super.createRenderRoot();
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
async connectedCallback() {
|
|
92
|
+
super.connectedCallback();
|
|
93
|
+
window.addEventListener('resize', this.handleResize);
|
|
94
|
+
const service: IApiService = services.container.isRegistered(this.apiEndpoint) ? services.container.resolve<IApiService>(this.apiEndpoint) : new RestApiService(this.apiEndpoint);
|
|
95
|
+
this.jsonData = await service.fetch(`theme/mainmenu`);
|
|
96
|
+
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
disconnectedCallback() {
|
|
100
|
+
window.removeEventListener('resize', this.handleResize);
|
|
101
|
+
super.disconnectedCallback();
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
handleResize = () => {
|
|
105
|
+
if (window.innerWidth < 992) {
|
|
106
|
+
/* Collapse menu on small screens */
|
|
107
|
+
this.renderRoot.querySelectorAll(`button`).forEach(function (btn) {
|
|
108
|
+
if (btn != null && btn instanceof HTMLElement && btn.hasAttribute('aria-expanded') && btn.getAttribute('aria-expanded') == 'true')
|
|
109
|
+
btn.click();
|
|
110
|
+
});
|
|
111
|
+
} else {
|
|
112
|
+
/* Remove collapsed styling on large screens*/
|
|
113
|
+
this.renderRoot.querySelectorAll(`.${this.ulSubMenuToggleClass} .${this.ulSubMenuClass}`).forEach(function (ul) {
|
|
114
|
+
if (ul != null && ul instanceof HTMLElement && ul.hasAttribute('style'))
|
|
115
|
+
ul.removeAttribute('style');
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
updated(changedProperties: PropertyValues) {
|
|
121
|
+
super.updated(changedProperties);
|
|
122
|
+
|
|
123
|
+
if (changedProperties.get('jsonData') != undefined) {
|
|
124
|
+
/* Disable click */
|
|
125
|
+
this.renderRoot.querySelectorAll(`.${this.ulSubMenuToggleClass}`).forEach(ul => {
|
|
126
|
+
ul.addEventListener('click', function (e) {
|
|
127
|
+
e.stopPropagation();
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
/* Click for menu expansion on small screens */
|
|
132
|
+
const className = this.ulSubMenuClass;
|
|
133
|
+
this.renderRoot.querySelectorAll(`.${this.ulSubMenuToggleClass} a`).forEach(function (a) {
|
|
134
|
+
a.addEventListener('click', (e) => {
|
|
135
|
+
if (e.currentTarget != null && e.currentTarget instanceof HTMLElement && window.innerWidth < 992) {
|
|
136
|
+
const nextEl = e.currentTarget.nextElementSibling;
|
|
137
|
+
if (nextEl != null && nextEl instanceof HTMLElement && nextEl.classList.contains(className)) {
|
|
138
|
+
e.preventDefault();
|
|
139
|
+
nextEl.style.display = nextEl.style.display == 'block' ? 'none' : 'block';
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
/* Enable popovers */
|
|
146
|
+
this.renderRoot.querySelectorAll(`[data-bs-toggle="${this.popoverToggle}"]`).forEach(function (t) {
|
|
147
|
+
new Popover(t);
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
renderImage(image) {
|
|
153
|
+
if (image != null) return html`<img src="${image}"/><span/>`;
|
|
154
|
+
else return html``;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
renderMenu(json, isDropdown, isSubmenu) {
|
|
158
|
+
let result = html``;
|
|
159
|
+
const jsonMenu = json != null && json.Menu != null ? json.Menu : json;
|
|
160
|
+
|
|
161
|
+
if (jsonMenu != null) {
|
|
162
|
+
|
|
163
|
+
if (jsonMenu.forEach) {
|
|
164
|
+
jsonMenu.forEach(mm => {
|
|
165
|
+
if (mm.Menu != null)
|
|
166
|
+
result = html`${result}${this.renderMenuDropdown(mm, isSubmenu)}`;
|
|
167
|
+
else if (mm.Type == "Divider")
|
|
168
|
+
result = html`${result}${this.renderMenuDivider()}`;
|
|
169
|
+
else if (isDropdown)
|
|
170
|
+
result = html`${result}${this.renderMenuDropdownLink(mm.URL, mm.Text, mm.Icon)}`;
|
|
171
|
+
else
|
|
172
|
+
result = html`${result}${this.renderMenuLink(mm)}`;
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
if (jsonMenu.Menu != null)
|
|
177
|
+
result = html`${result}${this.renderMenuDropdown(jsonMenu, isSubmenu)}`;
|
|
178
|
+
else if (jsonMenu.Type == "Divider")
|
|
179
|
+
result = html`${result}${this.renderMenuDivider()}`;
|
|
180
|
+
else if (isDropdown)
|
|
181
|
+
result = html`${result}${this.renderMenuDropdownLink(jsonMenu.URL, jsonMenu.Text, jsonMenu.Icon)}`;
|
|
182
|
+
else
|
|
183
|
+
result = html`${result}${this.renderMenuLink(jsonMenu)}`;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
return html`${result}`;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
renderMenuDivider() {
|
|
192
|
+
return html`<li><hr/></li>`;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
renderMenuDropdown(json, isSubmenu) {
|
|
196
|
+
const i = (json.Icon != null && json.Icon != '') ? html`<i class="${json.Icon} ${this.iconClass}" />` : ``;
|
|
197
|
+
if (isSubmenu)
|
|
198
|
+
return html`<li>
|
|
199
|
+
<a class="${this.liAMenuClass}" href="${json.URL}">
|
|
200
|
+
${i}<span>${json.Text}</span>
|
|
201
|
+
<span class="${this.spanMenuClass}">${this.spanMenuValue}</span>
|
|
202
|
+
</a>
|
|
203
|
+
<ul class="${this.ulSubMenuClass} ${this.ulSubMenuToggleClass}">
|
|
204
|
+
${this.renderMenu(json.Menu, true, true)}
|
|
205
|
+
</ul>
|
|
206
|
+
</li>`;
|
|
207
|
+
else
|
|
208
|
+
return html`<li class="${this.liLinkClass} ${this.liLinkToggleClass}">
|
|
209
|
+
<a href="${json.URL}" data-bs-toggle="${this.dropdownToggle}">
|
|
210
|
+
${i}<span>${json.Text}</span>
|
|
211
|
+
</a>
|
|
212
|
+
<ul class="${this.ulSubMenuToggleClass} ${this.ulMainMenuToggleClass}">
|
|
213
|
+
${this.renderMenu(json.Menu, true, true)}
|
|
214
|
+
</ul>
|
|
215
|
+
</li>`;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
renderMenuDropdownLink(url, text, icon) {
|
|
219
|
+
const i = (icon != null && icon != '') ? html`<i class="${icon} ${this.iconClass}" />` : ``;
|
|
220
|
+
return html`<li><a class="${this.liAMenuClass}" href="${url}">${i}${text}</a></li>`;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
renderMenuLink(menu) {
|
|
224
|
+
const i = (menu.Icon != null && menu.Icon != '') ? html`<i class="${menu.Icon} ${this.iconClass}" />` : ``;
|
|
225
|
+
const title = menu.Title;
|
|
226
|
+
const content = menu.DataContent;
|
|
227
|
+
const toggle = menu.DataToggle != null ? menu.DataToggle : this.popoverToggle;
|
|
228
|
+
const container = menu.DataContainer != null ? menu.DataContainer : this.popoverContainer;
|
|
229
|
+
const placement = menu.DataPlacement != null ? menu.DataPlacement : this.popoverPlacement;
|
|
230
|
+
const trigger = menu.DataTrigger != null ? menu.DataTrigger : this.popoverTrigger;
|
|
231
|
+
const isHtml = menu.DataHtml != null ? menu.DataHtml : this.popoverHtml;
|
|
232
|
+
|
|
233
|
+
if (menu.DoubleClick != null)
|
|
234
|
+
return html`<li class="${this.liLinkClass}">
|
|
235
|
+
<a class="${this.dblClickClass}" title="${title}" data-bs-trigger="${trigger}" data-bs-placement="${placement}" data-bs-container="${container}" data-bs-content="${content}" data-bs-toggle="${toggle}" data-bs-html="${isHtml}" ondblclick="${menu.DoubleClick}">
|
|
236
|
+
${i}${menu.Text}
|
|
237
|
+
</a>
|
|
238
|
+
</li>`;
|
|
239
|
+
else
|
|
240
|
+
return html`<li class="${this.liLinkClass}">
|
|
241
|
+
<a title="${title}" data-bs-trigger="${trigger}" data-bs-placement="${placement}" data-bs-container="${container}" data-bs-content="${content}" data-bs-toggle="${toggle}" data-bs-html="${isHtml}" href="${menu.URL}">
|
|
242
|
+
${i}${menu.Text}
|
|
243
|
+
</a>
|
|
244
|
+
</li>`;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
render() {
|
|
248
|
+
if (this.jsonData && this.jsonData.Root && this.jsonData.Root.MainMenu) {
|
|
249
|
+
return html`
|
|
250
|
+
<nav class="${this.navClass}">
|
|
251
|
+
<div>
|
|
252
|
+
<a href="#">
|
|
253
|
+
${this.renderImage(this.jsonData.Root.MainMenu.Image)}
|
|
254
|
+
${this.jsonData.Root.MainMenu.Label}
|
|
255
|
+
</a>
|
|
256
|
+
<button type="${this.buttonType}" data-bs-toggle="${this.collapseToggle}" data-bs-target="#${this.dropdownId}" aria-expanded="${this.ariaExpanded}" aria-label="${this.ariaLabel}">
|
|
257
|
+
<span/>
|
|
258
|
+
</button>
|
|
259
|
+
<div id="${this.dropdownId}">
|
|
260
|
+
<ul>
|
|
261
|
+
${this.renderMenu(this.jsonData.Root.MainMenu, false, false)}
|
|
262
|
+
</ul>
|
|
263
|
+
</div>
|
|
264
|
+
</div>
|
|
265
|
+
</nav>`;
|
|
266
|
+
}
|
|
267
|
+
else
|
|
268
|
+
return html``;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { LitElement, PropertyValues } from 'lit';
|
|
2
|
+
export declare class QboSideBar extends LitElement {
|
|
3
|
+
collapseAttribute: string;
|
|
4
|
+
collapseSelector: string;
|
|
5
|
+
menuCollapsed: string;
|
|
6
|
+
menuExpanded: string;
|
|
7
|
+
menuShow: string;
|
|
8
|
+
updated(changedProperties: PropertyValues): void;
|
|
9
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { html, LitElement } from 'lit';
|
|
11
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
12
|
+
let QboSideBar = class QboSideBar extends LitElement {
|
|
13
|
+
constructor() {
|
|
14
|
+
super(...arguments);
|
|
15
|
+
this.collapseAttribute = `aria-expanded`;
|
|
16
|
+
this.collapseSelector = `[data-qbo-toggle="collapse"]`;
|
|
17
|
+
this.menuCollapsed = `false`;
|
|
18
|
+
this.menuExpanded = `true`;
|
|
19
|
+
this.menuShow = `qbo-show`;
|
|
20
|
+
}
|
|
21
|
+
updated(changedProperties) {
|
|
22
|
+
/* Enable collapsing menus */
|
|
23
|
+
const root = this;
|
|
24
|
+
root.querySelectorAll(`${this.collapseSelector}`).forEach(function (btn) {
|
|
25
|
+
btn.addEventListener('click', (e) => {
|
|
26
|
+
const sibling = btn.nextElementSibling;
|
|
27
|
+
if (btn.getAttribute(root.collapseAttribute) == root.menuCollapsed) {
|
|
28
|
+
if (sibling instanceof HTMLElement)
|
|
29
|
+
sibling.classList.add(root.menuShow);
|
|
30
|
+
btn.setAttribute(root.collapseAttribute, root.menuExpanded);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
if (sibling instanceof HTMLElement)
|
|
34
|
+
sibling.classList.remove(root.menuShow);
|
|
35
|
+
btn.setAttribute(root.collapseAttribute, root.menuCollapsed);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
render() { return html `<slot></slot>`; }
|
|
41
|
+
};
|
|
42
|
+
__decorate([
|
|
43
|
+
property({ type: String }),
|
|
44
|
+
__metadata("design:type", Object)
|
|
45
|
+
], QboSideBar.prototype, "collapseAttribute", void 0);
|
|
46
|
+
__decorate([
|
|
47
|
+
property({ type: String }),
|
|
48
|
+
__metadata("design:type", Object)
|
|
49
|
+
], QboSideBar.prototype, "collapseSelector", void 0);
|
|
50
|
+
__decorate([
|
|
51
|
+
property({ type: String }),
|
|
52
|
+
__metadata("design:type", Object)
|
|
53
|
+
], QboSideBar.prototype, "menuCollapsed", void 0);
|
|
54
|
+
__decorate([
|
|
55
|
+
property({ type: String }),
|
|
56
|
+
__metadata("design:type", Object)
|
|
57
|
+
], QboSideBar.prototype, "menuExpanded", void 0);
|
|
58
|
+
__decorate([
|
|
59
|
+
property({ type: String }),
|
|
60
|
+
__metadata("design:type", Object)
|
|
61
|
+
], QboSideBar.prototype, "menuShow", void 0);
|
|
62
|
+
QboSideBar = __decorate([
|
|
63
|
+
customElement('qbo-sidebar')
|
|
64
|
+
], QboSideBar);
|
|
65
|
+
export { QboSideBar };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { html, LitElement, PropertyValues } from 'lit';
|
|
2
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
3
|
+
|
|
4
|
+
@customElement('qbo-sidebar')
|
|
5
|
+
export class QboSideBar extends LitElement {
|
|
6
|
+
|
|
7
|
+
@property({ type: String })
|
|
8
|
+
collapseAttribute = `aria-expanded`;
|
|
9
|
+
|
|
10
|
+
@property({ type: String })
|
|
11
|
+
collapseSelector = `[data-qbo-toggle="collapse"]`;
|
|
12
|
+
|
|
13
|
+
@property({ type: String })
|
|
14
|
+
menuCollapsed = `false`;
|
|
15
|
+
|
|
16
|
+
@property({ type: String })
|
|
17
|
+
menuExpanded = `true`;
|
|
18
|
+
|
|
19
|
+
@property({ type: String })
|
|
20
|
+
menuShow = `qbo-show`;
|
|
21
|
+
|
|
22
|
+
updated(changedProperties: PropertyValues) {
|
|
23
|
+
/* Enable collapsing menus */
|
|
24
|
+
const root = this;
|
|
25
|
+
root.querySelectorAll(`${this.collapseSelector}`).forEach(function (btn) {
|
|
26
|
+
btn.addEventListener('click', (e) => {
|
|
27
|
+
const sibling = btn.nextElementSibling;
|
|
28
|
+
|
|
29
|
+
if (btn.getAttribute(root.collapseAttribute) == root.menuCollapsed) {
|
|
30
|
+
if (sibling instanceof HTMLElement) sibling.classList.add(root.menuShow);
|
|
31
|
+
btn.setAttribute(root.collapseAttribute, root.menuExpanded);
|
|
32
|
+
} else {
|
|
33
|
+
if (sibling instanceof HTMLElement) sibling.classList.remove(root.menuShow);
|
|
34
|
+
btn.setAttribute(root.collapseAttribute, root.menuCollapsed);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
render() { return html`<slot></slot>`; }
|
|
41
|
+
}
|
package/src/qbo-ssn.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { TemplateResult } from 'lit';
|
|
2
|
+
import { QboFormElement } from '@quandis/qbo4.ui';
|
|
3
|
+
export declare class QboSSN extends QboFormElement {
|
|
4
|
+
apiEndpoint: string;
|
|
5
|
+
disabled: boolean;
|
|
6
|
+
editMode: boolean;
|
|
7
|
+
event: String | null;
|
|
8
|
+
imageClassShow: String | null;
|
|
9
|
+
imageClassHide: String | null;
|
|
10
|
+
inputClass: String | null;
|
|
11
|
+
inputName: String | null;
|
|
12
|
+
selectorImage: String | null;
|
|
13
|
+
selectorInput: String | null;
|
|
14
|
+
selectorSpan: String | null;
|
|
15
|
+
show: boolean;
|
|
16
|
+
slotClass: String | null;
|
|
17
|
+
spanClass: String | null;
|
|
18
|
+
titleMaskText: String | null;
|
|
19
|
+
titleShowText: String | null;
|
|
20
|
+
type: string | null;
|
|
21
|
+
url: String | null;
|
|
22
|
+
renderInHost: boolean;
|
|
23
|
+
createRenderRoot(): HTMLElement | DocumentFragment;
|
|
24
|
+
toggleSSN(): Promise<void>;
|
|
25
|
+
render(): TemplateResult<1>;
|
|
26
|
+
}
|
package/src/qbo-ssn.js
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { html } from 'lit';
|
|
11
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
12
|
+
import { services } from '@quandis/qbo4.configuration';
|
|
13
|
+
import { RestApiService } from '@quandis/qbo4.ui';
|
|
14
|
+
import { QboFormElement } from '@quandis/qbo4.ui';
|
|
15
|
+
const ssnMap = new Map();
|
|
16
|
+
ssnMap.set('defaultLayout', (component) => {
|
|
17
|
+
return html `<div slot="content" class="${component.slotClass}">
|
|
18
|
+
<input type="text" ?disabled=${component.disabled} class="${component.inputClass}" name="${component.inputName}" value="${component.data?.['USSSN']}"/>
|
|
19
|
+
<span @click="${component.toggleSSN}" class="${component.spanClass}" title="${component.titleShowText}"><i class="${component.imageClassShow}"></i></span>
|
|
20
|
+
</div>`;
|
|
21
|
+
});
|
|
22
|
+
let QboSSN = class QboSSN extends QboFormElement {
|
|
23
|
+
constructor() {
|
|
24
|
+
super(...arguments);
|
|
25
|
+
this.apiEndpoint = 'qbo';
|
|
26
|
+
this.disabled = true;
|
|
27
|
+
this.editMode = false;
|
|
28
|
+
this.event = 'click';
|
|
29
|
+
this.imageClassShow = 'qbo-icon-eye';
|
|
30
|
+
this.imageClassHide = 'qbo-icon-eye-slash';
|
|
31
|
+
this.inputClass = 'qbo-sm';
|
|
32
|
+
this.inputName = 'USSSN';
|
|
33
|
+
this.selectorImage = 'i';
|
|
34
|
+
this.selectorInput = 'input';
|
|
35
|
+
this.selectorSpan = 'span';
|
|
36
|
+
this.show = false;
|
|
37
|
+
this.slotClass = 'qbo-input-group';
|
|
38
|
+
this.spanClass = 'qbo-input-group-text qbo-pointer';
|
|
39
|
+
this.titleMaskText = 'Mask';
|
|
40
|
+
this.titleShowText = 'Show';
|
|
41
|
+
this.type = 'defaultLayout';
|
|
42
|
+
this.url = 'contact/UnmaskSSN';
|
|
43
|
+
this.renderInHost = true;
|
|
44
|
+
}
|
|
45
|
+
createRenderRoot() {
|
|
46
|
+
return this.renderInHost ? this : super.createRenderRoot();
|
|
47
|
+
}
|
|
48
|
+
async toggleSSN() {
|
|
49
|
+
this.show = !this.show;
|
|
50
|
+
if (this.show) {
|
|
51
|
+
const service = services.container.isRegistered(this.apiEndpoint)
|
|
52
|
+
? services.container.resolve(this.apiEndpoint) : new RestApiService(this.apiEndpoint);
|
|
53
|
+
const json = await service.fetch(`${this.url}`, { ID: `${this.data?.['ContactID']}` });
|
|
54
|
+
this.renderRoot.querySelectorAll(`${this.selectorInput}`).forEach(input => {
|
|
55
|
+
if (input instanceof HTMLInputElement
|
|
56
|
+
&& json?.ContactCollection?.length > 0
|
|
57
|
+
&& json.ContactCollection[0].USSSN != null
|
|
58
|
+
&& json.ContactCollection[0].USSSN.length == 9) {
|
|
59
|
+
const ssn = json.ContactCollection[0].USSSN;
|
|
60
|
+
input.value = `${ssn.substring(0, 3)}-${ssn.substring(3, 5)}-${ssn.substring(5, 9)}`;
|
|
61
|
+
if (this.editMode)
|
|
62
|
+
input.disabled = false;
|
|
63
|
+
this.renderRoot.querySelectorAll(`${this.selectorSpan}`).forEach(span => {
|
|
64
|
+
span.setAttribute('title', `${this.titleMaskText}`);
|
|
65
|
+
});
|
|
66
|
+
this.renderRoot.querySelectorAll(`${this.selectorImage}`).forEach(i => {
|
|
67
|
+
i.className = `${this.imageClassHide}`;
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
this.show = !this.show;
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
this.renderRoot.querySelectorAll(`${this.selectorInput}`).forEach(input => {
|
|
77
|
+
if (input instanceof HTMLInputElement) {
|
|
78
|
+
input.value = `${this.data?.['USSSN']}`;
|
|
79
|
+
if (this.editMode)
|
|
80
|
+
input.disabled = true;
|
|
81
|
+
}
|
|
82
|
+
this.renderRoot.querySelectorAll(`${this.selectorSpan}`).forEach(span => {
|
|
83
|
+
span.setAttribute('title', `${this.titleShowText}`);
|
|
84
|
+
});
|
|
85
|
+
this.renderRoot.querySelectorAll(`${this.selectorImage}`).forEach(i => {
|
|
86
|
+
i.className = `${this.imageClassShow}`;
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
render() {
|
|
92
|
+
return html `<slot>${ssnMap.has(this.type) ? ssnMap.get(this.type)(this) : null}</slot>`;
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
__decorate([
|
|
96
|
+
property({ type: String }),
|
|
97
|
+
__metadata("design:type", Object)
|
|
98
|
+
], QboSSN.prototype, "apiEndpoint", void 0);
|
|
99
|
+
__decorate([
|
|
100
|
+
property({ type: Boolean }),
|
|
101
|
+
__metadata("design:type", Object)
|
|
102
|
+
], QboSSN.prototype, "disabled", void 0);
|
|
103
|
+
__decorate([
|
|
104
|
+
property({ type: Boolean }),
|
|
105
|
+
__metadata("design:type", Object)
|
|
106
|
+
], QboSSN.prototype, "editMode", void 0);
|
|
107
|
+
__decorate([
|
|
108
|
+
property({ type: String }),
|
|
109
|
+
__metadata("design:type", Object)
|
|
110
|
+
], QboSSN.prototype, "event", void 0);
|
|
111
|
+
__decorate([
|
|
112
|
+
property({ type: String }),
|
|
113
|
+
__metadata("design:type", Object)
|
|
114
|
+
], QboSSN.prototype, "imageClassShow", void 0);
|
|
115
|
+
__decorate([
|
|
116
|
+
property({ type: String }),
|
|
117
|
+
__metadata("design:type", Object)
|
|
118
|
+
], QboSSN.prototype, "imageClassHide", void 0);
|
|
119
|
+
__decorate([
|
|
120
|
+
property({ type: String }),
|
|
121
|
+
__metadata("design:type", Object)
|
|
122
|
+
], QboSSN.prototype, "inputClass", void 0);
|
|
123
|
+
__decorate([
|
|
124
|
+
property({ type: String }),
|
|
125
|
+
__metadata("design:type", Object)
|
|
126
|
+
], QboSSN.prototype, "inputName", void 0);
|
|
127
|
+
__decorate([
|
|
128
|
+
property({ type: String }),
|
|
129
|
+
__metadata("design:type", Object)
|
|
130
|
+
], QboSSN.prototype, "selectorImage", void 0);
|
|
131
|
+
__decorate([
|
|
132
|
+
property({ type: String }),
|
|
133
|
+
__metadata("design:type", Object)
|
|
134
|
+
], QboSSN.prototype, "selectorInput", void 0);
|
|
135
|
+
__decorate([
|
|
136
|
+
property({ type: String }),
|
|
137
|
+
__metadata("design:type", Object)
|
|
138
|
+
], QboSSN.prototype, "selectorSpan", void 0);
|
|
139
|
+
__decorate([
|
|
140
|
+
property({ type: Boolean }),
|
|
141
|
+
__metadata("design:type", Object)
|
|
142
|
+
], QboSSN.prototype, "show", void 0);
|
|
143
|
+
__decorate([
|
|
144
|
+
property({ type: String }),
|
|
145
|
+
__metadata("design:type", Object)
|
|
146
|
+
], QboSSN.prototype, "slotClass", void 0);
|
|
147
|
+
__decorate([
|
|
148
|
+
property({ type: String }),
|
|
149
|
+
__metadata("design:type", Object)
|
|
150
|
+
], QboSSN.prototype, "spanClass", void 0);
|
|
151
|
+
__decorate([
|
|
152
|
+
property({ type: String }),
|
|
153
|
+
__metadata("design:type", Object)
|
|
154
|
+
], QboSSN.prototype, "titleMaskText", void 0);
|
|
155
|
+
__decorate([
|
|
156
|
+
property({ type: String }),
|
|
157
|
+
__metadata("design:type", Object)
|
|
158
|
+
], QboSSN.prototype, "titleShowText", void 0);
|
|
159
|
+
__decorate([
|
|
160
|
+
property(),
|
|
161
|
+
__metadata("design:type", Object)
|
|
162
|
+
], QboSSN.prototype, "type", void 0);
|
|
163
|
+
__decorate([
|
|
164
|
+
property({ type: String }),
|
|
165
|
+
__metadata("design:type", Object)
|
|
166
|
+
], QboSSN.prototype, "url", void 0);
|
|
167
|
+
__decorate([
|
|
168
|
+
property({ type: Boolean }),
|
|
169
|
+
__metadata("design:type", Object)
|
|
170
|
+
], QboSSN.prototype, "renderInHost", void 0);
|
|
171
|
+
QboSSN = __decorate([
|
|
172
|
+
customElement('qbo-ssn')
|
|
173
|
+
], QboSSN);
|
|
174
|
+
export { QboSSN };
|