@progressive-development/pd-contact 0.5.10 → 0.6.1
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/generated/locale-codes.d.ts +14 -0
- package/dist/generated/locale-codes.d.ts.map +1 -0
- package/dist/generated/locales/be.d.ts +21 -0
- package/dist/generated/locales/be.d.ts.map +1 -0
- package/dist/generated/locales/de.d.ts +21 -0
- package/dist/generated/locales/de.d.ts.map +1 -0
- package/dist/generated/locales/en.d.ts +21 -0
- package/dist/generated/locales/en.d.ts.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -1
- package/dist/locales/be.d.ts +2 -0
- package/dist/locales/de.d.ts +2 -0
- package/dist/locales/en.d.ts +2 -0
- package/dist/pd-contact.d.ts +75 -0
- package/dist/pd-contact.d.ts.map +1 -0
- package/dist/pd-contact.js +565 -3
- package/dist/stories/contact-edit.stories.d.ts +16 -0
- package/dist/stories/contact-edit.stories.d.ts.map +1 -0
- package/dist/stories/contact-view.stories.d.ts +13 -0
- package/dist/stories/contact-view.stories.d.ts.map +1 -0
- package/dist/types.d.ts +34 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +29 -45
- package/dist/src/PdContact.js +0 -666
package/dist/pd-contact.js
CHANGED
|
@@ -1,4 +1,566 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { css, LitElement, html } from "lit";
|
|
2
|
+
import { property, state, customElement } from "lit/decorators.js";
|
|
3
|
+
import { msg, str } from "@lit/localize";
|
|
4
|
+
import { PdFontStyles } from "@progressive-development/pd-shared-styles";
|
|
5
|
+
import "@progressive-development/pd-icon/pd-icon";
|
|
6
|
+
import "@progressive-development/pd-forms/pd-checkbox";
|
|
7
|
+
import "@progressive-development/pd-forms/pd-form-container";
|
|
8
|
+
import "@progressive-development/pd-forms/pd-form-row";
|
|
9
|
+
import "@progressive-development/pd-forms/pd-input";
|
|
10
|
+
import "@progressive-development/pd-forms/pd-select";
|
|
11
|
+
import "@progressive-development/pd-forms/pd-radio-group";
|
|
12
|
+
var __defProp = Object.defineProperty;
|
|
13
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
14
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
15
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
16
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
17
|
+
if (decorator = decorators[i])
|
|
18
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
19
|
+
if (kind && 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 "";
|
|
4
43
|
}
|
|
44
|
+
const C_TYPE = "type";
|
|
45
|
+
const C_COMPANY = "companyName";
|
|
46
|
+
const C_BTWNR = "vatNr";
|
|
47
|
+
const C_FIRSTNAME = "firstName";
|
|
48
|
+
const C_LASTNAME = "lastName";
|
|
49
|
+
const C_STREET = "street";
|
|
50
|
+
const C_CITY = "city";
|
|
51
|
+
const C_ADDITIONAL = "additionalHint";
|
|
52
|
+
const C_PROPERTY_DATE = "propertyDate";
|
|
53
|
+
const C_PHONE1 = "phone1";
|
|
54
|
+
const C_EMAIL = "email";
|
|
55
|
+
const yearSelection = [
|
|
56
|
+
{
|
|
57
|
+
value: "UNDEF",
|
|
58
|
+
name: msg("Baujahr auswählen", {
|
|
59
|
+
id: "pd.contact.property.year.selection"
|
|
60
|
+
})
|
|
61
|
+
},
|
|
62
|
+
...Array.from({ length: 2025 - 2014 + 1 }, (_, i) => {
|
|
63
|
+
const year = (2014 + i).toString();
|
|
64
|
+
return { value: year, name: year };
|
|
65
|
+
})
|
|
66
|
+
];
|
|
67
|
+
let PdContact = class extends LitElement {
|
|
68
|
+
constructor() {
|
|
69
|
+
super(...arguments);
|
|
70
|
+
this.addressTitle = msg("Adresse", { id: "pd.contact.address.title" });
|
|
71
|
+
this.phoneMailLink = false;
|
|
72
|
+
this.summary = false;
|
|
73
|
+
this.withPropertyDate = false;
|
|
74
|
+
this.requiredFields = [];
|
|
75
|
+
this.inputFields = [];
|
|
76
|
+
this._business = false;
|
|
77
|
+
this._errorMap = /* @__PURE__ */ new Map();
|
|
78
|
+
}
|
|
79
|
+
connectedCallback() {
|
|
80
|
+
super.connectedCallback();
|
|
81
|
+
this.addEventListener("validate-form", this._validateForm);
|
|
82
|
+
}
|
|
83
|
+
disconnectedCallback() {
|
|
84
|
+
super.disconnectedCallback();
|
|
85
|
+
this.removeEventListener("validate-form", this._validateForm);
|
|
86
|
+
}
|
|
87
|
+
willUpdate(changedProps) {
|
|
88
|
+
if (changedProps.has("contact") && this.contact) {
|
|
89
|
+
this._business = this.contact.business ?? false;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
firstUpdated() {
|
|
93
|
+
var _a, _b;
|
|
94
|
+
this.addEventListener("key-pressed", (e) => {
|
|
95
|
+
const detail = e.detail;
|
|
96
|
+
this._errorMap.set(detail.name, "");
|
|
97
|
+
this.requestUpdate();
|
|
98
|
+
});
|
|
99
|
+
if (this.contact) {
|
|
100
|
+
const detail = { errorMap: /* @__PURE__ */ new Map() };
|
|
101
|
+
(_b = (_a = this.shadowRoot) == null ? void 0 : _a.getElementById("contactContainerId")) == null ? void 0 : _b.dispatchEvent(new CustomEvent("validate-form", { detail }));
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
render() {
|
|
105
|
+
return html`
|
|
106
|
+
<div class="contact">
|
|
107
|
+
${this.summary ? this._renderViewContact() : this._renderEditContact()}
|
|
108
|
+
</div>
|
|
109
|
+
`;
|
|
110
|
+
}
|
|
111
|
+
_renderEditContact() {
|
|
112
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
113
|
+
return html`
|
|
114
|
+
<pd-form-container id="contactContainerId" requiredFieldInfo>
|
|
115
|
+
${this.inputFields.length === 0 || this._showInput(C_TYPE) ? html`
|
|
116
|
+
<pd-form-row id="testFormId">
|
|
117
|
+
<pd-radio-group
|
|
118
|
+
class="quarter3"
|
|
119
|
+
label="${msg("Typ", { id: "pd.contact.label.type" })}"
|
|
120
|
+
required
|
|
121
|
+
value="${this._getRadioValue()}"
|
|
122
|
+
@field-change="${this._switchAddressType}"
|
|
123
|
+
style="--group-gap: 20px;"
|
|
124
|
+
>
|
|
125
|
+
<pd-checkbox
|
|
126
|
+
value="${!((_a = this.contact) == null ? void 0 : _a.business) || true}"
|
|
127
|
+
valueName="private"
|
|
128
|
+
>${msg("Privatperson", {
|
|
129
|
+
id: "pd.contact.check.private"
|
|
130
|
+
})}</pd-checkbox
|
|
131
|
+
>
|
|
132
|
+
<pd-checkbox
|
|
133
|
+
valueName="business"
|
|
134
|
+
value="${((_b = this.contact) == null ? void 0 : _b.business) || false}"
|
|
135
|
+
>${msg("Unternehmen", {
|
|
136
|
+
id: "pd.contact.check.company"
|
|
137
|
+
})}</pd-checkbox
|
|
138
|
+
>
|
|
139
|
+
</pd-radio-group>
|
|
140
|
+
</pd-form-row>
|
|
141
|
+
` : ""}
|
|
142
|
+
${this._business ? html`
|
|
143
|
+
${this.inputFields.length === 0 || this._showInput(C_COMPANY) ? html`
|
|
144
|
+
<pd-form-row class="contact-form">
|
|
145
|
+
<pd-input
|
|
146
|
+
id="compNameId"
|
|
147
|
+
class="quarter3"
|
|
148
|
+
label="${msg("Name des Unternehmen", {
|
|
149
|
+
id: "pd.contact.label.company"
|
|
150
|
+
})}"
|
|
151
|
+
?required="${this._isRequired(C_COMPANY)}"
|
|
152
|
+
value="${((_c = this.contact) == null ? void 0 : _c.companyName) || ""}"
|
|
153
|
+
valueName="companyName"
|
|
154
|
+
autoCompleteName="organization"
|
|
155
|
+
></pd-input>
|
|
156
|
+
</pd-form-row>
|
|
157
|
+
` : ""}
|
|
158
|
+
${this.inputFields.length === 0 || this._showInput(C_BTWNR) ? html`
|
|
159
|
+
<pd-form-row class="contact-form">
|
|
160
|
+
<pd-input
|
|
161
|
+
id="vatId"
|
|
162
|
+
class="quarter3"
|
|
163
|
+
label="${msg("USt-IdNr.", {
|
|
164
|
+
id: "pd.contact.label.btw"
|
|
165
|
+
})}"
|
|
166
|
+
?required="${this._isRequired(C_BTWNR)}"
|
|
167
|
+
field-type="vat"
|
|
168
|
+
valueName="vatNr"
|
|
169
|
+
value="${((_d = this.contact) == null ? void 0 : _d.vatNr) || ""}"
|
|
170
|
+
autoCompleteName="vat"
|
|
171
|
+
></pd-input>
|
|
172
|
+
</pd-form-row>
|
|
173
|
+
` : ""}
|
|
174
|
+
` : html`
|
|
175
|
+
${this.inputFields.length === 0 || this._showInput(C_FIRSTNAME) ? html`
|
|
176
|
+
<pd-form-row class="contact-form">
|
|
177
|
+
<pd-input
|
|
178
|
+
id="firstNameId"
|
|
179
|
+
class="quarter3"
|
|
180
|
+
label="${msg("Vorname", {
|
|
181
|
+
id: "pd.contact.label.firstName"
|
|
182
|
+
})}"
|
|
183
|
+
valueName="firstName"
|
|
184
|
+
value="${((_e = this.contact) == null ? void 0 : _e.firstName) || ""}"
|
|
185
|
+
autoCompleteName="given-name"
|
|
186
|
+
?required="${this._isRequired(C_FIRSTNAME)}"
|
|
187
|
+
></pd-input>
|
|
188
|
+
</pd-form-row>
|
|
189
|
+
` : ""}
|
|
190
|
+
${this.inputFields.length === 0 || this._showInput(C_LASTNAME) ? html`
|
|
191
|
+
<pd-form-row class="contact-form">
|
|
192
|
+
<pd-input
|
|
193
|
+
id="lastNameId"
|
|
194
|
+
class="quarter3"
|
|
195
|
+
label="${msg("Nachname", {
|
|
196
|
+
id: "pd.contact.label.lastName"
|
|
197
|
+
})}"
|
|
198
|
+
valueName="lastName"
|
|
199
|
+
value="${((_f = this.contact) == null ? void 0 : _f.lastName) || ""}"
|
|
200
|
+
autoCompleteName="family-name"
|
|
201
|
+
?required="${this._isRequired(C_LASTNAME)}"
|
|
202
|
+
></pd-input>
|
|
203
|
+
</pd-form-row>
|
|
204
|
+
` : ""}
|
|
205
|
+
`}
|
|
206
|
+
${this.inputFields.length === 0 || this._showInput(C_STREET) ? html`
|
|
207
|
+
<pd-form-row class="contact-form">
|
|
208
|
+
<pd-input
|
|
209
|
+
id="streetId"
|
|
210
|
+
class="quarter2"
|
|
211
|
+
label="${msg("Strasse", { id: "pd.contact.label.street" })}"
|
|
212
|
+
valueName="street"
|
|
213
|
+
value="${((_g = this.contact) == null ? void 0 : _g.street) || ""}"
|
|
214
|
+
autoCompleteName="street-address"
|
|
215
|
+
?required="${this._isRequired(C_STREET)}"
|
|
216
|
+
></pd-input>
|
|
217
|
+
<pd-input
|
|
218
|
+
id="streetNrId"
|
|
219
|
+
class="quarter1"
|
|
220
|
+
label="${msg("Nr.", { id: "pd.contact.label.streetNr" })}"
|
|
221
|
+
valueName="streetNr"
|
|
222
|
+
value="${((_h = this.contact) == null ? void 0 : _h.streetNr) || ""}"
|
|
223
|
+
?required="${this._isRequired("streetNr")}"
|
|
224
|
+
></pd-input>
|
|
225
|
+
</pd-form-row>
|
|
226
|
+
` : ""}
|
|
227
|
+
${this.inputFields.length === 0 || this._showInput(C_CITY) ? html`
|
|
228
|
+
<pd-form-row class="contact-form">
|
|
229
|
+
${this.match && this.match.zip ? html`
|
|
230
|
+
<pd-input
|
|
231
|
+
readonly
|
|
232
|
+
id="zipId"
|
|
233
|
+
class="quarter1"
|
|
234
|
+
label="${msg("PLZ", { id: "pd.contact.label.zip" })}"
|
|
235
|
+
valueName="zip"
|
|
236
|
+
value="${this.match.zip}"
|
|
237
|
+
></pd-input>
|
|
238
|
+
` : html`
|
|
239
|
+
<pd-input
|
|
240
|
+
id="zipId"
|
|
241
|
+
class="quarter1"
|
|
242
|
+
label="${msg("PLZ", { id: "pd.contact.label.zip" })}"
|
|
243
|
+
field-type="number"
|
|
244
|
+
valueName="zip"
|
|
245
|
+
value="${((_i = this.contact) == null ? void 0 : _i.zip) || ""}"
|
|
246
|
+
autoCompleteName="postal-code"
|
|
247
|
+
?required="${this._isRequired("zip")}"
|
|
248
|
+
></pd-input>
|
|
249
|
+
`}
|
|
250
|
+
<pd-input
|
|
251
|
+
id="cityId"
|
|
252
|
+
class="quarter2"
|
|
253
|
+
label="${msg("Ort", { id: "pd.contact.label.city" })}"
|
|
254
|
+
valueName="city"
|
|
255
|
+
value="${((_j = this.contact) == null ? void 0 : _j.city) || ""}"
|
|
256
|
+
autoCompleteName="locality"
|
|
257
|
+
?required="${this._isRequired(C_CITY)}"
|
|
258
|
+
></pd-input>
|
|
259
|
+
</pd-form-row>
|
|
260
|
+
` : ""}
|
|
261
|
+
${this.inputFields.length === 0 || this._showInput(C_ADDITIONAL) ? html`
|
|
262
|
+
<pd-form-row class="contact-form">
|
|
263
|
+
<pd-input
|
|
264
|
+
class="quarter3"
|
|
265
|
+
id="additionalHintId"
|
|
266
|
+
label="${msg("Addresszusatz", {
|
|
267
|
+
id: "pd.contact.label.additional"
|
|
268
|
+
})}"
|
|
269
|
+
value="${((_k = this.contact) == null ? void 0 : _k.additionalHint) || ""}"
|
|
270
|
+
></pd-input>
|
|
271
|
+
</pd-form-row>
|
|
272
|
+
` : ""}
|
|
273
|
+
${this.withPropertyDate ? html`
|
|
274
|
+
<pd-form-row class="contact-form">
|
|
275
|
+
<pd-select
|
|
276
|
+
class="quarter3"
|
|
277
|
+
id="propertyDateId"
|
|
278
|
+
label="${msg("Datum der Immobilie", {
|
|
279
|
+
id: "pd.contact.label.propertyDate"
|
|
280
|
+
})}"
|
|
281
|
+
value="${((_l = this.contact) == null ? void 0 : _l.propertyDate) || ""}"
|
|
282
|
+
.values="${yearSelection}"
|
|
283
|
+
?required="${this._isRequired(C_PROPERTY_DATE)}"
|
|
284
|
+
></pd-select>
|
|
285
|
+
</pd-form-row>
|
|
286
|
+
` : ""}
|
|
287
|
+
${this.inputFields.length === 0 || this._showInput(C_PHONE1) ? html`
|
|
288
|
+
<pd-form-row class="contact-form">
|
|
289
|
+
<pd-input
|
|
290
|
+
id="phoneId"
|
|
291
|
+
class="quarter3"
|
|
292
|
+
label="${msg("Telefon", { id: "pd.contact.label.phone" })}"
|
|
293
|
+
name="phone"
|
|
294
|
+
valueName="phone1"
|
|
295
|
+
value="${((_m = this.contact) == null ? void 0 : _m.phone1) || ""}"
|
|
296
|
+
field-type="phone"
|
|
297
|
+
autoCompleteName="tel"
|
|
298
|
+
?required="${this._isRequired(C_PHONE1)}"
|
|
299
|
+
></pd-input>
|
|
300
|
+
</pd-form-row>
|
|
301
|
+
` : ""}
|
|
302
|
+
${this.inputFields.length === 0 || this._showInput(C_EMAIL) ? html`
|
|
303
|
+
<pd-form-row class="contact-form">
|
|
304
|
+
<pd-input
|
|
305
|
+
id="mailId"
|
|
306
|
+
class="quarter3"
|
|
307
|
+
label="${msg("E-mail", { id: "pd.contact.label.email" })}"
|
|
308
|
+
field-type="mail"
|
|
309
|
+
valueName="email"
|
|
310
|
+
value="${((_n = this.contact) == null ? void 0 : _n.email) || ""}"
|
|
311
|
+
autoCompleteName="email"
|
|
312
|
+
?required="${this._isRequired(C_EMAIL)}"
|
|
313
|
+
></pd-input>
|
|
314
|
+
</pd-form-row>
|
|
315
|
+
` : ""}
|
|
316
|
+
</pd-form-container>
|
|
317
|
+
`;
|
|
318
|
+
}
|
|
319
|
+
_getRadioValue() {
|
|
320
|
+
if (this.contact) {
|
|
321
|
+
return this.contact.business ? "business" : "private";
|
|
322
|
+
}
|
|
323
|
+
return "private";
|
|
324
|
+
}
|
|
325
|
+
_renderViewContact() {
|
|
326
|
+
if (!this.contact) return html`<p>Contact undefined</p>`;
|
|
327
|
+
const trPhoneNr = transformPhone(
|
|
328
|
+
this.contact.phone1 || "",
|
|
329
|
+
this.contact.country || "be"
|
|
330
|
+
);
|
|
331
|
+
return html`
|
|
332
|
+
<address>
|
|
333
|
+
<dl>
|
|
334
|
+
<dt>${this.addressTitle}</dt>
|
|
335
|
+
<dd>${this.contact.companyName}</dd>
|
|
336
|
+
<dd>${this.contact.vatNr}</dd>
|
|
337
|
+
<dd>${this._getFullName()}</dd>
|
|
338
|
+
<dd>${this._getFullStreet()}</dd>
|
|
339
|
+
<dd>${this._getFullLocation()}</dd>
|
|
340
|
+
${this.contact.additionalHint ? html`<dd>${this.contact.additionalHint}</dd>` : ""}
|
|
341
|
+
${this.contact.propertyDate ? html`<dd>
|
|
342
|
+
${msg(str`Baujahr: ${this.contact.propertyDate}`, {
|
|
343
|
+
id: "pd.contact.label.summary.propertyDate"
|
|
344
|
+
})}
|
|
345
|
+
</dd>` : ""}
|
|
346
|
+
<dd>${this.contact.country}</dd>
|
|
347
|
+
|
|
348
|
+
${this.contact.phone1 ? html` <dd class="larger">
|
|
349
|
+
${this.phoneMailLink && trPhoneNr ? html` <a
|
|
350
|
+
href="tel:${trPhoneNr}"
|
|
351
|
+
aria-label="Phone call: ${this.contact.phone1}"
|
|
352
|
+
class="link-item"
|
|
353
|
+
>
|
|
354
|
+
<span style="margin-right: 8px;"
|
|
355
|
+
>${this.contact.phone1}</span
|
|
356
|
+
>
|
|
357
|
+
<pd-icon
|
|
358
|
+
activeIcon
|
|
359
|
+
icon="phoneIcon"
|
|
360
|
+
class="round link-icon"
|
|
361
|
+
></pd-icon>
|
|
362
|
+
</a>` : this.contact.phone1}
|
|
363
|
+
</dd>` : ""}
|
|
364
|
+
${this.contact.email ? html` <dd class="larger">
|
|
365
|
+
${this.phoneMailLink ? html` <a
|
|
366
|
+
href="mailto:${this.contact.email}"
|
|
367
|
+
aria-label="Send mail: ${this.contact.email}"
|
|
368
|
+
class="link-item"
|
|
369
|
+
>
|
|
370
|
+
<span style="margin-right: 8px;"
|
|
371
|
+
>${this.contact.email}</span
|
|
372
|
+
>
|
|
373
|
+
<pd-icon
|
|
374
|
+
activeIcon
|
|
375
|
+
icon="mailIcon"
|
|
376
|
+
class="round link-icon"
|
|
377
|
+
></pd-icon>
|
|
378
|
+
</a>` : this.contact.email}
|
|
379
|
+
</dd>` : ""}
|
|
380
|
+
${this.contact.btw ? html` <dt>BTW</dt>
|
|
381
|
+
<dd>${this.contact.btw}</dd>` : ""}
|
|
382
|
+
${this.contact.kbc ? html` <dt>Bankgegevens</dt>
|
|
383
|
+
<dd>${this.contact.kbc}</dd>
|
|
384
|
+
<dd>${this.contact.bank}</dd>` : ""}
|
|
385
|
+
</dl>
|
|
386
|
+
</address>
|
|
387
|
+
`;
|
|
388
|
+
}
|
|
389
|
+
_switchAddressType(e) {
|
|
390
|
+
this._business = e.detail.name === "business";
|
|
391
|
+
}
|
|
392
|
+
_isRequired(field) {
|
|
393
|
+
return this.requiredFields.length > 0 ? this.requiredFields.includes(field) : false;
|
|
394
|
+
}
|
|
395
|
+
_showInput(field) {
|
|
396
|
+
return this.inputFields.length > 0 ? this.inputFields.includes(field) : true;
|
|
397
|
+
}
|
|
398
|
+
_validateForm(e) {
|
|
399
|
+
var _a, _b;
|
|
400
|
+
const detail = e.detail;
|
|
401
|
+
if (!detail.singleElement) {
|
|
402
|
+
(_b = (_a = this.shadowRoot) == null ? void 0 : _a.getElementById("contactContainerId")) == null ? void 0 : _b.dispatchEvent(new CustomEvent("validate-form", { detail }));
|
|
403
|
+
if (detail.errorMap.size === 0 && detail.formData) {
|
|
404
|
+
detail.formData[this.id] = this._setFormData();
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
_setFormData() {
|
|
409
|
+
const getInput = (id) => {
|
|
410
|
+
var _a, _b;
|
|
411
|
+
return (_b = (_a = this.shadowRoot) == null ? void 0 : _a.getElementById(id)) == null ? void 0 : _b.value;
|
|
412
|
+
};
|
|
413
|
+
return {
|
|
414
|
+
business: this._business,
|
|
415
|
+
companyName: this._business ? getInput("compNameId") : void 0,
|
|
416
|
+
vatNr: this._business ? getInput("vatId") : void 0,
|
|
417
|
+
firstName: !this._business ? getInput("firstNameId") : void 0,
|
|
418
|
+
lastName: !this._business ? getInput("lastNameId") : void 0,
|
|
419
|
+
street: getInput("streetId"),
|
|
420
|
+
streetNr: getInput("streetNrId"),
|
|
421
|
+
additionalHint: getInput("additionalHintId"),
|
|
422
|
+
propertyDate: this.withPropertyDate ? getInput("propertyDateId") : void 0,
|
|
423
|
+
zip: getInput("zipId"),
|
|
424
|
+
city: getInput("cityId"),
|
|
425
|
+
phone1: getInput("phoneId"),
|
|
426
|
+
email: getInput("mailId")
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
_getFullName() {
|
|
430
|
+
var _a, _b;
|
|
431
|
+
return PdContact._getFullVal(
|
|
432
|
+
(_a = this.contact) == null ? void 0 : _a.firstName,
|
|
433
|
+
(_b = this.contact) == null ? void 0 : _b.lastName
|
|
434
|
+
);
|
|
435
|
+
}
|
|
436
|
+
_getFullStreet() {
|
|
437
|
+
var _a, _b;
|
|
438
|
+
return PdContact._getFullVal((_a = this.contact) == null ? void 0 : _a.street, (_b = this.contact) == null ? void 0 : _b.streetNr);
|
|
439
|
+
}
|
|
440
|
+
_getFullLocation() {
|
|
441
|
+
var _a, _b;
|
|
442
|
+
return PdContact._getFullVal((_a = this.contact) == null ? void 0 : _a.zip, (_b = this.contact) == null ? void 0 : _b.city);
|
|
443
|
+
}
|
|
444
|
+
static _getFullVal(val1, val2, fallback = "") {
|
|
445
|
+
return [val1, val2].filter(Boolean).join(" ") || fallback;
|
|
446
|
+
}
|
|
447
|
+
};
|
|
448
|
+
PdContact.styles = [
|
|
449
|
+
PdFontStyles,
|
|
450
|
+
// Check: Es fehlt wahrschein der andere color import, um die Komonente out-of the box zu machen?
|
|
451
|
+
css`
|
|
452
|
+
:host {
|
|
453
|
+
display: block;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
.contact {
|
|
457
|
+
display: flex;
|
|
458
|
+
flex-direction: column;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
address {
|
|
462
|
+
color: var(
|
|
463
|
+
--pd-contact-address-col,
|
|
464
|
+
var(--pd-default-font-content-col)
|
|
465
|
+
);
|
|
466
|
+
line-height: 1.8;
|
|
467
|
+
font-style: normal;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
dl {
|
|
471
|
+
margin: 0;
|
|
472
|
+
padding: 0;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
dt {
|
|
476
|
+
font-weight: bold;
|
|
477
|
+
padding-top: 10px;
|
|
478
|
+
color: var(
|
|
479
|
+
--pd-contact-address-title-col,
|
|
480
|
+
var(--pd-default-font-title-col)
|
|
481
|
+
);
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
dd {
|
|
485
|
+
font-weight: 400;
|
|
486
|
+
font-size: 1em;
|
|
487
|
+
margin: 0;
|
|
488
|
+
padding: 0;
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
dd.larger {
|
|
492
|
+
padding-top: 3px;
|
|
493
|
+
padding-bottom: 5px;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
.contact-form {
|
|
497
|
+
--row-padding-top: 10px;
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
.link-icon {
|
|
501
|
+
--pd-icon-bg-col-active: #859900;
|
|
502
|
+
--pd-icon-bg-col-hover: #859900;
|
|
503
|
+
--pd-icon-size: 14px;
|
|
504
|
+
--pd-icon-stroke-col-active: white;
|
|
505
|
+
--pd-icon-col-active: white;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
.link-item {
|
|
509
|
+
display: flex;
|
|
510
|
+
align-items: center;
|
|
511
|
+
text-decoration: none;
|
|
512
|
+
color: var(--pd-default-font-link-col, inherit);
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
.link-item:hover {
|
|
516
|
+
color: var(--pd-default-font-link-col-hover, #451a46);
|
|
517
|
+
}
|
|
518
|
+
`
|
|
519
|
+
];
|
|
520
|
+
__decorateClass([
|
|
521
|
+
property()
|
|
522
|
+
], PdContact.prototype, "addressTitle", 2);
|
|
523
|
+
__decorateClass([
|
|
524
|
+
property({ type: Boolean })
|
|
525
|
+
], PdContact.prototype, "phoneMailLink", 2);
|
|
526
|
+
__decorateClass([
|
|
527
|
+
property({ type: Boolean })
|
|
528
|
+
], PdContact.prototype, "summary", 2);
|
|
529
|
+
__decorateClass([
|
|
530
|
+
property({ type: Boolean })
|
|
531
|
+
], PdContact.prototype, "withPropertyDate", 2);
|
|
532
|
+
__decorateClass([
|
|
533
|
+
property({ type: Array })
|
|
534
|
+
], PdContact.prototype, "requiredFields", 2);
|
|
535
|
+
__decorateClass([
|
|
536
|
+
property({ type: Array })
|
|
537
|
+
], PdContact.prototype, "inputFields", 2);
|
|
538
|
+
__decorateClass([
|
|
539
|
+
property({ type: Object })
|
|
540
|
+
], PdContact.prototype, "contact", 2);
|
|
541
|
+
__decorateClass([
|
|
542
|
+
property({ type: Object })
|
|
543
|
+
], PdContact.prototype, "match", 2);
|
|
544
|
+
__decorateClass([
|
|
545
|
+
state()
|
|
546
|
+
], PdContact.prototype, "_business", 2);
|
|
547
|
+
__decorateClass([
|
|
548
|
+
state()
|
|
549
|
+
], PdContact.prototype, "_errorMap", 2);
|
|
550
|
+
PdContact = __decorateClass([
|
|
551
|
+
customElement("pd-contact")
|
|
552
|
+
], PdContact);
|
|
553
|
+
export {
|
|
554
|
+
C_ADDITIONAL,
|
|
555
|
+
C_BTWNR,
|
|
556
|
+
C_CITY,
|
|
557
|
+
C_COMPANY,
|
|
558
|
+
C_EMAIL,
|
|
559
|
+
C_FIRSTNAME,
|
|
560
|
+
C_LASTNAME,
|
|
561
|
+
C_PHONE1,
|
|
562
|
+
C_PROPERTY_DATE,
|
|
563
|
+
C_STREET,
|
|
564
|
+
C_TYPE,
|
|
565
|
+
PdContact
|
|
566
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { StoryObj } from '@storybook/web-components';
|
|
2
|
+
declare const meta: {
|
|
3
|
+
title: string;
|
|
4
|
+
render: ({ inputFields, withPropertyDate, contact }: import('@storybook/web-components').Args) => import('lit-html').TemplateResult<1>;
|
|
5
|
+
argTypes: {};
|
|
6
|
+
};
|
|
7
|
+
export default meta;
|
|
8
|
+
type Story = StoryObj;
|
|
9
|
+
export declare const ContactForm: Story;
|
|
10
|
+
export declare const ContactFormPropertyDate: Story;
|
|
11
|
+
export declare const ContactFormWithInputFields1: Story;
|
|
12
|
+
export declare const ContactFormWithInputFields2: Story;
|
|
13
|
+
export declare const ContactPreparedForm: Story;
|
|
14
|
+
export declare const ContactPreparedFormCompany: Story;
|
|
15
|
+
export declare const ContactPreparedFormPropertyDate: Story;
|
|
16
|
+
//# sourceMappingURL=contact-edit.stories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contact-edit.stories.d.ts","sourceRoot":"","sources":["../../src/stories/contact-edit.stories.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAQ,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAYhE,OAAO,kBAAkB,CAAC;AAG1B,QAAA,MAAM,IAAI;;;;CAWM,CAAC;AAEjB,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC;AA2BtB,eAAO,MAAM,WAAW,EAAE,KAEzB,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"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { StoryObj } from '@storybook/web-components';
|
|
2
|
+
declare const meta: {
|
|
3
|
+
title: string;
|
|
4
|
+
render: ({ summary, phoneMailLink, contact, withPropertyDate }: import('@storybook/web-components').Args) => import('lit-html').TemplateResult<1>;
|
|
5
|
+
argTypes: {};
|
|
6
|
+
};
|
|
7
|
+
export default meta;
|
|
8
|
+
type Story = StoryObj;
|
|
9
|
+
export declare const ContactView: Story;
|
|
10
|
+
export declare const ContactCompanyView: Story;
|
|
11
|
+
export declare const ContactViewPropertyDate: Story;
|
|
12
|
+
export declare const ContactViewPhone: Story;
|
|
13
|
+
//# sourceMappingURL=contact-view.stories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contact-view.stories.d.ts","sourceRoot":"","sources":["../../src/stories/contact-view.stories.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAQ,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAEhE,OAAO,kBAAkB,CAAC;AAG1B,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"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export interface PdContactData {
|
|
2
|
+
business?: boolean;
|
|
3
|
+
companyName?: string;
|
|
4
|
+
vatNr?: string;
|
|
5
|
+
firstName?: string;
|
|
6
|
+
lastName?: string;
|
|
7
|
+
street?: string;
|
|
8
|
+
streetNr?: string;
|
|
9
|
+
zip?: string;
|
|
10
|
+
city?: string;
|
|
11
|
+
additionalHint?: string;
|
|
12
|
+
propertyDate?: string;
|
|
13
|
+
phone1?: string;
|
|
14
|
+
email?: string;
|
|
15
|
+
country?: string;
|
|
16
|
+
btw?: string;
|
|
17
|
+
kbc?: string;
|
|
18
|
+
bank?: string;
|
|
19
|
+
}
|
|
20
|
+
export interface PdContactMatch {
|
|
21
|
+
zip?: string;
|
|
22
|
+
[key: string]: string | undefined;
|
|
23
|
+
}
|
|
24
|
+
export interface PdContactFormOptions {
|
|
25
|
+
addressTitle?: string;
|
|
26
|
+
phoneMailLink?: boolean;
|
|
27
|
+
summary?: boolean;
|
|
28
|
+
withPropertyDate?: boolean;
|
|
29
|
+
requiredFields?: string[];
|
|
30
|
+
inputFields?: string[];
|
|
31
|
+
contact?: PdContactData;
|
|
32
|
+
match?: PdContactMatch;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,cAAc;IAC7B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;CACnC;AAED,MAAM,WAAW,oBAAoB;IACnC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,KAAK,CAAC,EAAE,cAAc,CAAC;CACxB"}
|