@progressive-development/pd-contact 0.6.26 → 0.9.2
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/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -10
- package/dist/locales/be.js +4 -4
- package/dist/locales/de.js +4 -4
- package/dist/locales/en.js +4 -4
- package/dist/pd-contact/PdContact.d.ts +63 -0
- package/dist/pd-contact/PdContact.d.ts.map +1 -0
- package/dist/pd-contact/PdContact.js +546 -0
- package/dist/{stories/contact-edit.stories.d.ts → pd-contact/pd-contact-edit.stories.d.ts} +2 -2
- package/dist/pd-contact/pd-contact-edit.stories.d.ts.map +1 -0
- package/dist/{stories/contact-view.stories.d.ts → pd-contact/pd-contact-view.stories.d.ts} +2 -2
- package/dist/pd-contact/pd-contact-view.stories.d.ts.map +1 -0
- package/dist/pd-contact/pd-contact.d.ts +3 -0
- package/dist/pd-contact/pd-contact.d.ts.map +1 -0
- package/dist/pd-contact.d.ts +2 -60
- package/dist/pd-contact.js +6 -558
- package/dist/types.js +2 -14
- package/package.json +27 -47
- package/dist/pd-contact.d.ts.map +0 -1
- package/dist/stories/contact-edit.stories.d.ts.map +0 -1
- package/dist/stories/contact-view.stories.d.ts.map +0 -1
|
@@ -0,0 +1,546 @@
|
|
|
1
|
+
import { LitElement, css, html } from 'lit';
|
|
2
|
+
import { property, state, query } from 'lit/decorators.js';
|
|
3
|
+
import { msg, str } from '@lit/localize';
|
|
4
|
+
import '@progressive-development/pd-icon/pd-icon';
|
|
5
|
+
import '@progressive-development/pd-forms/pd-checkbox';
|
|
6
|
+
import '@progressive-development/pd-forms/pd-form-container';
|
|
7
|
+
import '@progressive-development/pd-forms/pd-form-row';
|
|
8
|
+
import '@progressive-development/pd-forms/pd-input';
|
|
9
|
+
import '@progressive-development/pd-forms/pd-select';
|
|
10
|
+
import '@progressive-development/pd-forms/pd-radio-group';
|
|
11
|
+
import { C_TYPE, C_COMPANY, C_BTWNR, C_FIRSTNAME, C_LASTNAME, C_STREET, C_CITY, C_ZIP, C_ADDITIONAL, C_PROPERTY_DATE, C_PHONE1, C_EMAIL } from '../types.js';
|
|
12
|
+
|
|
13
|
+
var __defProp = Object.defineProperty;
|
|
14
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
15
|
+
var result = void 0 ;
|
|
16
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
17
|
+
if (decorator = decorators[i])
|
|
18
|
+
result = (decorator(target, key, result) ) || result;
|
|
19
|
+
if (result) __defProp(target, key, result);
|
|
20
|
+
return result;
|
|
21
|
+
};
|
|
22
|
+
const countryPrefixes = {
|
|
23
|
+
de: "+49",
|
|
24
|
+
// Deutschland
|
|
25
|
+
be: "+32",
|
|
26
|
+
// Belgien
|
|
27
|
+
nl: "+31",
|
|
28
|
+
// Niederland
|
|
29
|
+
fr: "+33",
|
|
30
|
+
// Frankreich
|
|
31
|
+
es: "+34"
|
|
32
|
+
// Spanien
|
|
33
|
+
};
|
|
34
|
+
function transformPhone(phone, country) {
|
|
35
|
+
if (!phone || typeof phone !== "string") return "";
|
|
36
|
+
const countryPrefix = countryPrefixes[country];
|
|
37
|
+
if (!countryPrefix) throw new Error(`Unbekanntes Land: ${country}`);
|
|
38
|
+
const cleanedPhone = phone.replace(/\s+/g, "").replace(/[^0-9+]/g, "");
|
|
39
|
+
if (cleanedPhone.startsWith("+")) return cleanedPhone;
|
|
40
|
+
if (cleanedPhone.startsWith("0"))
|
|
41
|
+
return countryPrefix + cleanedPhone.slice(1);
|
|
42
|
+
return "";
|
|
43
|
+
}
|
|
44
|
+
const yearSelection = [
|
|
45
|
+
{
|
|
46
|
+
value: "UNDEF",
|
|
47
|
+
name: msg("Baujahr auswählen", {
|
|
48
|
+
id: "pd.contact.property.year.selection"
|
|
49
|
+
})
|
|
50
|
+
},
|
|
51
|
+
...Array.from({ length: 2025 - 2014 + 1 }, (_, i) => {
|
|
52
|
+
const year = (2014 + i).toString();
|
|
53
|
+
return { value: year, name: year };
|
|
54
|
+
})
|
|
55
|
+
];
|
|
56
|
+
const _PdContact = class _PdContact extends LitElement {
|
|
57
|
+
constructor() {
|
|
58
|
+
super(...arguments);
|
|
59
|
+
this.addressTitle = msg("Adresse", { id: "pd.contact.address.title" });
|
|
60
|
+
this.phoneMailLink = false;
|
|
61
|
+
this.summary = false;
|
|
62
|
+
this.withPropertyDate = false;
|
|
63
|
+
this.requiredFields = [];
|
|
64
|
+
this.inputFields = [];
|
|
65
|
+
this._business = false;
|
|
66
|
+
}
|
|
67
|
+
static {
|
|
68
|
+
this.styles = [
|
|
69
|
+
css`
|
|
70
|
+
:host {
|
|
71
|
+
display: block;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.contact {
|
|
75
|
+
display: flex;
|
|
76
|
+
flex-direction: column;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
address {
|
|
80
|
+
color: var(
|
|
81
|
+
--pd-contact-address-col,
|
|
82
|
+
var(--pd-default-font-content-col)
|
|
83
|
+
);
|
|
84
|
+
line-height: 1.8;
|
|
85
|
+
font-style: normal;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
dl {
|
|
89
|
+
margin: 0;
|
|
90
|
+
padding: 0;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
dt {
|
|
94
|
+
font-weight: bold;
|
|
95
|
+
padding-top: 10px;
|
|
96
|
+
color: var(
|
|
97
|
+
--pd-contact-address-title-col,
|
|
98
|
+
var(--pd-default-font-title-col)
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
dd {
|
|
103
|
+
font-weight: 400;
|
|
104
|
+
font-size: 1em;
|
|
105
|
+
margin: 0;
|
|
106
|
+
padding: 0;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
dd.larger {
|
|
110
|
+
padding-top: 3px;
|
|
111
|
+
padding-bottom: 5px;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.contact-form {
|
|
115
|
+
--row-padding-top: 10px;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.link-icon {
|
|
119
|
+
--pd-icon-bg-col-active: #859900;
|
|
120
|
+
--pd-icon-bg-col-hover: #859900;
|
|
121
|
+
--pd-icon-size: 14px;
|
|
122
|
+
--pd-icon-col-active: white;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.link-item {
|
|
126
|
+
display: flex;
|
|
127
|
+
align-items: center;
|
|
128
|
+
text-decoration: none;
|
|
129
|
+
color: var(--pd-default-font-link-col, inherit);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.link-item:hover {
|
|
133
|
+
color: var(--pd-default-font-link-col-hover, #451a46);
|
|
134
|
+
}
|
|
135
|
+
`
|
|
136
|
+
];
|
|
137
|
+
}
|
|
138
|
+
willUpdate(changedProps) {
|
|
139
|
+
if (changedProps.has("contact") && this.contact) {
|
|
140
|
+
this._business = this.contact.business ?? false;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
render() {
|
|
144
|
+
return html`
|
|
145
|
+
<div class="contact">
|
|
146
|
+
${this.summary ? this._renderViewContact() : this._renderEditContact()}
|
|
147
|
+
</div>
|
|
148
|
+
`;
|
|
149
|
+
}
|
|
150
|
+
_renderEditContact() {
|
|
151
|
+
return html`
|
|
152
|
+
<pd-form-container id="contactContainerId" requiredFieldInfo autoTrimm>
|
|
153
|
+
${this.inputFields.length === 0 || this._showInput(C_TYPE) ? html`
|
|
154
|
+
<pd-form-row>
|
|
155
|
+
<pd-radio-group
|
|
156
|
+
id="contactTypeRadioId"
|
|
157
|
+
class="quarter3"
|
|
158
|
+
label="${msg("Typ", { id: "pd.contact.label.type" })}"
|
|
159
|
+
required
|
|
160
|
+
initValue="${this._getRadioValue()}"
|
|
161
|
+
@pd-form-element-change="${this._switchAddressType}"
|
|
162
|
+
style="--group-gap: 20px;"
|
|
163
|
+
>
|
|
164
|
+
<pd-checkbox
|
|
165
|
+
checkType="RADIO"
|
|
166
|
+
initValue="${this.contact ? !this.contact.business : true}"
|
|
167
|
+
valueName="private"
|
|
168
|
+
>${msg("Privatperson", {
|
|
169
|
+
id: "pd.contact.check.private"
|
|
170
|
+
})}</pd-checkbox
|
|
171
|
+
>
|
|
172
|
+
<pd-checkbox
|
|
173
|
+
checkType="RADIO"
|
|
174
|
+
valueName="business"
|
|
175
|
+
initValue="${this.contact ? this.contact.business || false : false}"
|
|
176
|
+
>${msg("Unternehmen", {
|
|
177
|
+
id: "pd.contact.check.company"
|
|
178
|
+
})}</pd-checkbox
|
|
179
|
+
>
|
|
180
|
+
</pd-radio-group>
|
|
181
|
+
</pd-form-row>
|
|
182
|
+
` : ""}
|
|
183
|
+
${this._business ? html`
|
|
184
|
+
${this.inputFields.length === 0 || this._showInput(C_COMPANY) ? html`
|
|
185
|
+
<pd-form-row class="contact-form">
|
|
186
|
+
<pd-input
|
|
187
|
+
id="compNameId"
|
|
188
|
+
class="quarter3"
|
|
189
|
+
label="${msg("Name des Unternehmen", {
|
|
190
|
+
id: "pd.contact.label.company"
|
|
191
|
+
})}"
|
|
192
|
+
?required="${this._isRequired(C_COMPANY)}"
|
|
193
|
+
initValue="${this.contact?.companyName || ""}"
|
|
194
|
+
valueName="companyName"
|
|
195
|
+
autoCompleteName="organization"
|
|
196
|
+
></pd-input>
|
|
197
|
+
</pd-form-row>
|
|
198
|
+
` : ""}
|
|
199
|
+
${this.inputFields.length === 0 || this._showInput(C_BTWNR) ? html`
|
|
200
|
+
<pd-form-row class="contact-form">
|
|
201
|
+
<pd-input
|
|
202
|
+
id="vatId"
|
|
203
|
+
class="quarter3"
|
|
204
|
+
label="${msg("USt-IdNr.", {
|
|
205
|
+
id: "pd.contact.label.btw"
|
|
206
|
+
})}"
|
|
207
|
+
?required="${this._isRequired(C_BTWNR)}"
|
|
208
|
+
fieldType="vat"
|
|
209
|
+
valueName="vatNr"
|
|
210
|
+
initValue="${this.contact?.vatNr || ""}"
|
|
211
|
+
autoCompleteName="vat"
|
|
212
|
+
></pd-input>
|
|
213
|
+
</pd-form-row>
|
|
214
|
+
` : ""}
|
|
215
|
+
` : html`
|
|
216
|
+
${this.inputFields.length === 0 || this._showInput(C_FIRSTNAME) ? html`
|
|
217
|
+
<pd-form-row class="contact-form">
|
|
218
|
+
<pd-input
|
|
219
|
+
id="firstNameId"
|
|
220
|
+
class="quarter3"
|
|
221
|
+
label="${msg("Vorname", {
|
|
222
|
+
id: "pd.contact.label.firstName"
|
|
223
|
+
})}"
|
|
224
|
+
valueName="firstName"
|
|
225
|
+
initValue="${this.contact?.firstName || ""}"
|
|
226
|
+
autoCompleteName="given-name"
|
|
227
|
+
?required="${this._isRequired(C_FIRSTNAME)}"
|
|
228
|
+
></pd-input>
|
|
229
|
+
</pd-form-row>
|
|
230
|
+
` : ""}
|
|
231
|
+
${this.inputFields.length === 0 || this._showInput(C_LASTNAME) ? html`
|
|
232
|
+
<pd-form-row class="contact-form">
|
|
233
|
+
<pd-input
|
|
234
|
+
id="lastNameId"
|
|
235
|
+
class="quarter3"
|
|
236
|
+
label="${msg("Nachname", {
|
|
237
|
+
id: "pd.contact.label.lastName"
|
|
238
|
+
})}"
|
|
239
|
+
valueName="lastName"
|
|
240
|
+
initValue="${this.contact?.lastName || ""}"
|
|
241
|
+
autoCompleteName="family-name"
|
|
242
|
+
?required="${this._isRequired(C_LASTNAME)}"
|
|
243
|
+
></pd-input>
|
|
244
|
+
</pd-form-row>
|
|
245
|
+
` : ""}
|
|
246
|
+
`}
|
|
247
|
+
${this.inputFields.length === 0 || this._showInput(C_STREET) ? html`
|
|
248
|
+
<pd-form-row class="contact-form">
|
|
249
|
+
<pd-input
|
|
250
|
+
id="streetId"
|
|
251
|
+
class="quarter2"
|
|
252
|
+
label="${msg("Strasse", { id: "pd.contact.label.street" })}"
|
|
253
|
+
valueName="street"
|
|
254
|
+
initValue="${this.contact?.street || ""}"
|
|
255
|
+
autoCompleteName="street-address"
|
|
256
|
+
?required="${this._isRequired(C_STREET)}"
|
|
257
|
+
></pd-input>
|
|
258
|
+
<pd-input
|
|
259
|
+
id="streetNrId"
|
|
260
|
+
class="quarter1"
|
|
261
|
+
label="${msg("Nr.", { id: "pd.contact.label.streetNr" })}"
|
|
262
|
+
valueName="streetNr"
|
|
263
|
+
initValue="${this.contact?.streetNr || ""}"
|
|
264
|
+
?required="${this._isRequired(C_STREET)}"
|
|
265
|
+
></pd-input>
|
|
266
|
+
</pd-form-row>
|
|
267
|
+
` : ""}
|
|
268
|
+
${this.inputFields.length === 0 || this._showInput(C_CITY) ? html`
|
|
269
|
+
<pd-form-row class="contact-form">
|
|
270
|
+
${this.match && this.match.zip ? html`
|
|
271
|
+
<pd-input
|
|
272
|
+
readonly
|
|
273
|
+
id="zipId"
|
|
274
|
+
class="quarter1"
|
|
275
|
+
label="${msg("PLZ", { id: "pd.contact.label.zip" })}"
|
|
276
|
+
valueName="zip"
|
|
277
|
+
initValue="${this.match.zip}"
|
|
278
|
+
></pd-input>
|
|
279
|
+
` : html`
|
|
280
|
+
<pd-input
|
|
281
|
+
id="zipId"
|
|
282
|
+
class="quarter1"
|
|
283
|
+
label="${msg("PLZ", { id: "pd.contact.label.zip" })}"
|
|
284
|
+
fieldType="number"
|
|
285
|
+
valueName="zip"
|
|
286
|
+
initValue="${this.contact?.zip || ""}"
|
|
287
|
+
autoCompleteName="postal-code"
|
|
288
|
+
?required="${this._isRequired(C_ZIP)}"
|
|
289
|
+
></pd-input>
|
|
290
|
+
`}
|
|
291
|
+
<pd-input
|
|
292
|
+
id="cityId"
|
|
293
|
+
class="quarter2"
|
|
294
|
+
label="${msg("Ort", { id: "pd.contact.label.city" })}"
|
|
295
|
+
valueName="city"
|
|
296
|
+
initValue="${this.contact?.city || ""}"
|
|
297
|
+
autoCompleteName="locality"
|
|
298
|
+
?required="${this._isRequired(C_CITY)}"
|
|
299
|
+
></pd-input>
|
|
300
|
+
</pd-form-row>
|
|
301
|
+
` : ""}
|
|
302
|
+
${this.inputFields.length === 0 || this._showInput(C_ADDITIONAL) ? html`
|
|
303
|
+
<pd-form-row class="contact-form">
|
|
304
|
+
<pd-input
|
|
305
|
+
class="quarter3"
|
|
306
|
+
id="additionalHintId"
|
|
307
|
+
label="${msg("Addresszusatz", {
|
|
308
|
+
id: "pd.contact.label.additional"
|
|
309
|
+
})}"
|
|
310
|
+
initValue="${this.contact?.additionalHint || ""}"
|
|
311
|
+
valueName="additionalHint"
|
|
312
|
+
?required="${this._isRequired(C_ADDITIONAL)}"
|
|
313
|
+
></pd-input>
|
|
314
|
+
</pd-form-row>
|
|
315
|
+
` : ""}
|
|
316
|
+
${this.withPropertyDate ? html`
|
|
317
|
+
<pd-form-row class="contact-form">
|
|
318
|
+
<pd-select
|
|
319
|
+
class="quarter3"
|
|
320
|
+
id="propertyDateId"
|
|
321
|
+
label="${msg("Datum der Immobilie", {
|
|
322
|
+
id: "pd.contact.label.propertyDate"
|
|
323
|
+
})}"
|
|
324
|
+
initValue="${this.contact?.propertyDate || ""}"
|
|
325
|
+
.values="${yearSelection}"
|
|
326
|
+
?required="${this._isRequired(C_PROPERTY_DATE)}"
|
|
327
|
+
></pd-select>
|
|
328
|
+
</pd-form-row>
|
|
329
|
+
` : ""}
|
|
330
|
+
${this.inputFields.length === 0 || this._showInput(C_PHONE1) ? html`
|
|
331
|
+
<pd-form-row class="contact-form">
|
|
332
|
+
<pd-input
|
|
333
|
+
id="phoneId"
|
|
334
|
+
class="quarter3"
|
|
335
|
+
label="${msg("Telefon", { id: "pd.contact.label.phone" })}"
|
|
336
|
+
name="phone"
|
|
337
|
+
valueName="phone1"
|
|
338
|
+
initValue="${this.contact?.phone1 || ""}"
|
|
339
|
+
fieldType="phone"
|
|
340
|
+
autoCompleteName="tel"
|
|
341
|
+
?required="${this._isRequired(C_PHONE1)}"
|
|
342
|
+
></pd-input>
|
|
343
|
+
</pd-form-row>
|
|
344
|
+
` : ""}
|
|
345
|
+
${this.inputFields.length === 0 || this._showInput(C_EMAIL) ? html`
|
|
346
|
+
<pd-form-row class="contact-form">
|
|
347
|
+
<pd-input
|
|
348
|
+
id="mailId"
|
|
349
|
+
class="quarter3"
|
|
350
|
+
label="${msg("E-mail", { id: "pd.contact.label.email" })}"
|
|
351
|
+
fieldType="mail"
|
|
352
|
+
valueName="email"
|
|
353
|
+
initValue="${this.contact?.email || ""}"
|
|
354
|
+
autoCompleteName="email"
|
|
355
|
+
?required="${this._isRequired(C_EMAIL)}"
|
|
356
|
+
></pd-input>
|
|
357
|
+
</pd-form-row>
|
|
358
|
+
` : ""}
|
|
359
|
+
</pd-form-container>
|
|
360
|
+
`;
|
|
361
|
+
}
|
|
362
|
+
_getRadioValue() {
|
|
363
|
+
if (this.contact) {
|
|
364
|
+
return this.contact.business ? "business" : "private";
|
|
365
|
+
}
|
|
366
|
+
return "private";
|
|
367
|
+
}
|
|
368
|
+
_renderViewContact() {
|
|
369
|
+
if (!this.contact) return html`<p>Contact undefined</p>`;
|
|
370
|
+
const trPhoneNr = transformPhone(
|
|
371
|
+
this.contact.phone1 || "",
|
|
372
|
+
this.contact.country || "be"
|
|
373
|
+
);
|
|
374
|
+
return html`
|
|
375
|
+
<address>
|
|
376
|
+
<dl>
|
|
377
|
+
<dt>${this.addressTitle}</dt>
|
|
378
|
+
<dd>${this.contact.companyName}</dd>
|
|
379
|
+
<dd>${this.contact.vatNr}</dd>
|
|
380
|
+
<dd>${this._getFullName()}</dd>
|
|
381
|
+
<dd>${this._getFullStreet()}</dd>
|
|
382
|
+
<dd>${this._getFullLocation()}</dd>
|
|
383
|
+
${this.contact.additionalHint ? html`<dd>${this.contact.additionalHint}</dd>` : ""}
|
|
384
|
+
${this.contact.propertyDate ? html`<dd>
|
|
385
|
+
${msg(str`Baujahr: ${this.contact.propertyDate}`, {
|
|
386
|
+
id: "pd.contact.label.summary.propertyDate"
|
|
387
|
+
})}
|
|
388
|
+
</dd>` : ""}
|
|
389
|
+
<dd>${this.contact.country}</dd>
|
|
390
|
+
|
|
391
|
+
${this.contact.phone1 ? html` <dd class="larger">
|
|
392
|
+
${this.phoneMailLink && trPhoneNr ? html` <a
|
|
393
|
+
href="tel:${trPhoneNr}"
|
|
394
|
+
aria-label="Phone call: ${this.contact.phone1}"
|
|
395
|
+
class="link-item"
|
|
396
|
+
>
|
|
397
|
+
<span style="margin-right: 8px;"
|
|
398
|
+
>${this.contact.phone1}</span
|
|
399
|
+
>
|
|
400
|
+
<pd-icon
|
|
401
|
+
activeIcon
|
|
402
|
+
icon="phoneIcon"
|
|
403
|
+
class="round link-icon"
|
|
404
|
+
></pd-icon>
|
|
405
|
+
</a>` : this.contact.phone1}
|
|
406
|
+
</dd>` : ""}
|
|
407
|
+
${this.contact.email ? html` <dd class="larger">
|
|
408
|
+
${this.phoneMailLink ? html` <a
|
|
409
|
+
href="mailto:${this.contact.email}"
|
|
410
|
+
aria-label="Send mail: ${this.contact.email}"
|
|
411
|
+
class="link-item"
|
|
412
|
+
>
|
|
413
|
+
<span style="margin-right: 8px;"
|
|
414
|
+
>${this.contact.email}</span
|
|
415
|
+
>
|
|
416
|
+
<pd-icon
|
|
417
|
+
activeIcon
|
|
418
|
+
icon="mailIcon"
|
|
419
|
+
class="round link-icon"
|
|
420
|
+
></pd-icon>
|
|
421
|
+
</a>` : this.contact.email}
|
|
422
|
+
</dd>` : ""}
|
|
423
|
+
${this.contact.btw ? html` <dt>BTW</dt>
|
|
424
|
+
<dd>${this.contact.btw}</dd>` : ""}
|
|
425
|
+
${this.contact.kbc ? html` <dt>Bankgegevens</dt>
|
|
426
|
+
<dd>${this.contact.kbc}</dd>
|
|
427
|
+
<dd>${this.contact.bank}</dd>` : ""}
|
|
428
|
+
</dl>
|
|
429
|
+
</address>
|
|
430
|
+
`;
|
|
431
|
+
}
|
|
432
|
+
get valid() {
|
|
433
|
+
return this._contactForm?.valid === true;
|
|
434
|
+
}
|
|
435
|
+
async triggerValidate() {
|
|
436
|
+
return this._contactForm?.triggerValidate();
|
|
437
|
+
}
|
|
438
|
+
getValues() {
|
|
439
|
+
const contactFormValues = this._contactForm?.getValues().origin;
|
|
440
|
+
console.log("VAlues:", contactFormValues);
|
|
441
|
+
const commonValues = {
|
|
442
|
+
business: this._business,
|
|
443
|
+
street: contactFormValues.street,
|
|
444
|
+
streetNr: contactFormValues.streetNr,
|
|
445
|
+
zip: contactFormValues.zip,
|
|
446
|
+
city: contactFormValues.city,
|
|
447
|
+
additionalHint: contactFormValues.additionalHint,
|
|
448
|
+
propertyDate: contactFormValues.propertyDate,
|
|
449
|
+
phone1: contactFormValues.phone1,
|
|
450
|
+
email: contactFormValues.email
|
|
451
|
+
// No input fields for following values
|
|
452
|
+
//country?: string;
|
|
453
|
+
//btw?: string;
|
|
454
|
+
//kbc?: string;
|
|
455
|
+
//bank?: string;
|
|
456
|
+
};
|
|
457
|
+
return this._business ? {
|
|
458
|
+
...commonValues,
|
|
459
|
+
companyName: contactFormValues.companyName,
|
|
460
|
+
vatNr: contactFormValues.vatNr
|
|
461
|
+
} : {
|
|
462
|
+
...commonValues,
|
|
463
|
+
firstName: contactFormValues.firstName,
|
|
464
|
+
lastName: contactFormValues.lastName
|
|
465
|
+
};
|
|
466
|
+
}
|
|
467
|
+
_switchAddressType(e) {
|
|
468
|
+
console.log("Do switch", e);
|
|
469
|
+
if (e.detail.name === "contactTypeRadioId") {
|
|
470
|
+
this._business = e.detail.value === "business";
|
|
471
|
+
}
|
|
472
|
+
e.stopPropagation();
|
|
473
|
+
}
|
|
474
|
+
_isRequired(field) {
|
|
475
|
+
return this.requiredFields.length > 0 ? this.requiredFields.includes(field) : false;
|
|
476
|
+
}
|
|
477
|
+
_showInput(field) {
|
|
478
|
+
return this.inputFields.length > 0 ? this.inputFields.includes(field) : true;
|
|
479
|
+
}
|
|
480
|
+
_setFormData() {
|
|
481
|
+
const getInput = (id) => this.shadowRoot?.getElementById(id)?.value;
|
|
482
|
+
return {
|
|
483
|
+
business: this._business,
|
|
484
|
+
companyName: this._business ? getInput("compNameId") : void 0,
|
|
485
|
+
vatNr: this._business ? getInput("vatId") : void 0,
|
|
486
|
+
firstName: !this._business ? getInput("firstNameId") : void 0,
|
|
487
|
+
lastName: !this._business ? getInput("lastNameId") : void 0,
|
|
488
|
+
street: getInput("streetId"),
|
|
489
|
+
streetNr: getInput("streetNrId"),
|
|
490
|
+
additionalHint: getInput("additionalHintId"),
|
|
491
|
+
propertyDate: this.withPropertyDate ? getInput("propertyDateId") : void 0,
|
|
492
|
+
zip: getInput("zipId"),
|
|
493
|
+
city: getInput("cityId"),
|
|
494
|
+
phone1: getInput("phoneId"),
|
|
495
|
+
email: getInput("mailId")
|
|
496
|
+
};
|
|
497
|
+
}
|
|
498
|
+
_getFullName() {
|
|
499
|
+
return _PdContact._getFullVal(
|
|
500
|
+
this.contact?.firstName,
|
|
501
|
+
this.contact?.lastName
|
|
502
|
+
);
|
|
503
|
+
}
|
|
504
|
+
_getFullStreet() {
|
|
505
|
+
return _PdContact._getFullVal(this.contact?.street, this.contact?.streetNr);
|
|
506
|
+
}
|
|
507
|
+
_getFullLocation() {
|
|
508
|
+
return _PdContact._getFullVal(this.contact?.zip, this.contact?.city);
|
|
509
|
+
}
|
|
510
|
+
static _getFullVal(val1, val2, fallback = "") {
|
|
511
|
+
return [val1, val2].filter(Boolean).join(" ") || fallback;
|
|
512
|
+
}
|
|
513
|
+
};
|
|
514
|
+
__decorateClass([
|
|
515
|
+
property()
|
|
516
|
+
], _PdContact.prototype, "addressTitle");
|
|
517
|
+
__decorateClass([
|
|
518
|
+
property({ type: Boolean })
|
|
519
|
+
], _PdContact.prototype, "phoneMailLink");
|
|
520
|
+
__decorateClass([
|
|
521
|
+
property({ type: Boolean })
|
|
522
|
+
], _PdContact.prototype, "summary");
|
|
523
|
+
__decorateClass([
|
|
524
|
+
property({ type: Boolean })
|
|
525
|
+
], _PdContact.prototype, "withPropertyDate");
|
|
526
|
+
__decorateClass([
|
|
527
|
+
property({ type: Array })
|
|
528
|
+
], _PdContact.prototype, "requiredFields");
|
|
529
|
+
__decorateClass([
|
|
530
|
+
property({ type: Array })
|
|
531
|
+
], _PdContact.prototype, "inputFields");
|
|
532
|
+
__decorateClass([
|
|
533
|
+
property({ type: Object })
|
|
534
|
+
], _PdContact.prototype, "contact");
|
|
535
|
+
__decorateClass([
|
|
536
|
+
property({ type: Object })
|
|
537
|
+
], _PdContact.prototype, "match");
|
|
538
|
+
__decorateClass([
|
|
539
|
+
state()
|
|
540
|
+
], _PdContact.prototype, "_business");
|
|
541
|
+
__decorateClass([
|
|
542
|
+
query("#contactContainerId")
|
|
543
|
+
], _PdContact.prototype, "_contactForm");
|
|
544
|
+
let PdContact = _PdContact;
|
|
545
|
+
|
|
546
|
+
export { PdContact };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { StoryObj } from '@storybook/web-components';
|
|
2
2
|
declare const meta: {
|
|
3
3
|
title: string;
|
|
4
|
-
render: ({ inputFields, requiredFields, withPropertyDate, contact }: import('@storybook/web-components').Args) => import('lit
|
|
4
|
+
render: ({ inputFields, requiredFields, withPropertyDate, contact }: import('@storybook/web-components').Args) => import('lit').TemplateResult<1>;
|
|
5
5
|
argTypes: {};
|
|
6
6
|
};
|
|
7
7
|
export default meta;
|
|
@@ -15,4 +15,4 @@ export declare const ContactFormWithInputFields2: Story;
|
|
|
15
15
|
export declare const ContactPreparedForm: Story;
|
|
16
16
|
export declare const ContactPreparedFormCompany: Story;
|
|
17
17
|
export declare const ContactPreparedFormPropertyDate: Story;
|
|
18
|
-
//# sourceMappingURL=contact-edit.stories.d.ts.map
|
|
18
|
+
//# sourceMappingURL=pd-contact-edit.stories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pd-contact-edit.stories.d.ts","sourceRoot":"","sources":["../../src/pd-contact/pd-contact-edit.stories.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAQ,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAehE,OAAO,iBAAiB,CAAC;AAGzB,QAAA,MAAM,IAAI;;;;CAmCM,CAAC;AAEjB,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC;AA2BtB,eAAO,MAAM,WAAW,EAAE,KAEzB,CAAC;AAEF,eAAO,MAAM,yBAAyB,EAAE,KAevC,CAAC;AAEF,eAAO,MAAM,0BAA0B,EAAE,KAIxC,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,KAIrC,CAAC;AAEF,eAAO,MAAM,2BAA2B,EAAE,KAIzC,CAAC;AAEF,eAAO,MAAM,2BAA2B,EAAE,KAIzC,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,KAIjC,CAAC;AAEF,eAAO,MAAM,0BAA0B,EAAE,KAIxC,CAAC;AAEF,eAAO,MAAM,+BAA+B,EAAE,KAQ7C,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { StoryObj } from '@storybook/web-components';
|
|
2
2
|
declare const meta: {
|
|
3
3
|
title: string;
|
|
4
|
-
render: ({ summary, phoneMailLink, contact, withPropertyDate }: import('@storybook/web-components').Args) => import('lit
|
|
4
|
+
render: ({ summary, phoneMailLink, contact, withPropertyDate }: import('@storybook/web-components').Args) => import('lit').TemplateResult<1>;
|
|
5
5
|
argTypes: {};
|
|
6
6
|
};
|
|
7
7
|
export default meta;
|
|
@@ -10,4 +10,4 @@ export declare const ContactView: Story;
|
|
|
10
10
|
export declare const ContactCompanyView: Story;
|
|
11
11
|
export declare const ContactViewPropertyDate: Story;
|
|
12
12
|
export declare const ContactViewPhone: Story;
|
|
13
|
-
//# sourceMappingURL=contact-view.stories.d.ts.map
|
|
13
|
+
//# sourceMappingURL=pd-contact-view.stories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pd-contact-view.stories.d.ts","sourceRoot":"","sources":["../../src/pd-contact/pd-contact-view.stories.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAQ,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAEhE,OAAO,iBAAiB,CAAC;AAGzB,QAAA,MAAM,IAAI;;;;CAYM,CAAC;AAEjB,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC;AA2BtB,eAAO,MAAM,WAAW,EAAE,KAKzB,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,KAKhC,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,KAQrC,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,KAM9B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pd-contact.d.ts","sourceRoot":"","sources":["../../src/pd-contact/pd-contact.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAO3C,OAAO,EAAE,SAAS,EAAE,CAAC"}
|
package/dist/pd-contact.d.ts
CHANGED
|
@@ -1,60 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export declare class PdContact extends LitElement {
|
|
4
|
-
/**
|
|
5
|
-
* Title shown above address block.
|
|
6
|
-
*/
|
|
7
|
-
addressTitle: string;
|
|
8
|
-
/**
|
|
9
|
-
* If true, phone and email are rendered as clickable links with icons.
|
|
10
|
-
*/
|
|
11
|
-
phoneMailLink: boolean;
|
|
12
|
-
/**
|
|
13
|
-
* If true, render only summary view instead of full editable form.
|
|
14
|
-
*/
|
|
15
|
-
summary: boolean;
|
|
16
|
-
/**
|
|
17
|
-
* Whether the Baujahr / propertyDate should be shown in the form.
|
|
18
|
-
* TODO: Refactor, give selectable property dates from outside, show if set
|
|
19
|
-
*/
|
|
20
|
-
withPropertyDate: boolean;
|
|
21
|
-
/**
|
|
22
|
-
* List of required input field keys (optional).
|
|
23
|
-
*/
|
|
24
|
-
requiredFields: string[];
|
|
25
|
-
/**
|
|
26
|
-
* List of fields to be rendered (optional).
|
|
27
|
-
*/
|
|
28
|
-
inputFields: string[];
|
|
29
|
-
/**
|
|
30
|
-
* Contact object to show or edit.
|
|
31
|
-
*/
|
|
32
|
-
contact?: PdContactData;
|
|
33
|
-
/**
|
|
34
|
-
* Optional location match data.
|
|
35
|
-
*/
|
|
36
|
-
match?: PdContactMatch;
|
|
37
|
-
/**
|
|
38
|
-
* Business or private contact (internal flag).
|
|
39
|
-
*/
|
|
40
|
-
private _business;
|
|
41
|
-
private _contactForm;
|
|
42
|
-
static styles: CSSResultGroup;
|
|
43
|
-
willUpdate(changedProps: PropertyValues<this>): void;
|
|
44
|
-
render(): import('lit-html').TemplateResult<1>;
|
|
45
|
-
private _renderEditContact;
|
|
46
|
-
private _getRadioValue;
|
|
47
|
-
private _renderViewContact;
|
|
48
|
-
get valid(): boolean;
|
|
49
|
-
triggerValidate(): Promise<boolean>;
|
|
50
|
-
getValues(): PdContactData;
|
|
51
|
-
private _switchAddressType;
|
|
52
|
-
private _isRequired;
|
|
53
|
-
private _showInput;
|
|
54
|
-
private _setFormData;
|
|
55
|
-
private _getFullName;
|
|
56
|
-
private _getFullStreet;
|
|
57
|
-
private _getFullLocation;
|
|
58
|
-
private static _getFullVal;
|
|
59
|
-
}
|
|
60
|
-
//# sourceMappingURL=pd-contact.d.ts.map
|
|
1
|
+
export * from './pd-contact/pd-contact'
|
|
2
|
+
export {}
|