@progressive-development/pd-order 0.1.126 → 0.1.128

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.
Files changed (42) hide show
  1. package/dist/locales/be.js +15 -0
  2. package/dist/locales/de.js +15 -0
  3. package/dist/locales/en.js +15 -0
  4. package/dist/node_modules/@progressive-development/pd-contact/pd-contact.js +2 -0
  5. package/dist/node_modules/@progressive-development/pd-contact/src/PdContact.js +566 -0
  6. package/dist/node_modules/@progressive-development/pd-content/pd-collapse.js +2 -0
  7. package/dist/node_modules/@progressive-development/pd-content/pd-edit-content.js +2 -0
  8. package/dist/node_modules/@progressive-development/pd-content/src/PdCollapse.js +135 -0
  9. package/dist/node_modules/@progressive-development/pd-content/src/PdEditContent.js +223 -0
  10. package/dist/node_modules/@progressive-development/pd-dialog/pd-popup.js +2 -0
  11. package/dist/node_modules/@progressive-development/pd-dialog/src/PdPopup.js +112 -0
  12. package/dist/node_modules/@progressive-development/pd-forms/pd-checkbox.js +2 -0
  13. package/dist/node_modules/@progressive-development/pd-forms/pd-form-container.js +2 -0
  14. package/dist/node_modules/@progressive-development/pd-forms/pd-form-row.js +2 -0
  15. package/dist/node_modules/@progressive-development/pd-forms/pd-hover-box.js +2 -0
  16. package/dist/node_modules/@progressive-development/pd-forms/pd-input.js +2 -0
  17. package/dist/node_modules/@progressive-development/pd-forms/pd-radio-group.js +2 -0
  18. package/dist/node_modules/@progressive-development/pd-forms/src/PdBaseInputElement.js +86 -0
  19. package/dist/node_modules/@progressive-development/pd-forms/src/PdBaseUi.js +33 -0
  20. package/dist/node_modules/@progressive-development/pd-forms/src/PdBaseUiInput.js +229 -0
  21. package/dist/node_modules/@progressive-development/pd-forms/src/PdCheckbox.js +230 -0
  22. package/dist/node_modules/@progressive-development/pd-forms/src/PdFormContainer.js +167 -0
  23. package/dist/node_modules/@progressive-development/pd-forms/src/PdFormRow.js +92 -0
  24. package/dist/node_modules/@progressive-development/pd-forms/src/PdHoverBox.js +108 -0
  25. package/dist/node_modules/@progressive-development/pd-forms/src/PdInput.js +79 -0
  26. package/dist/node_modules/@progressive-development/pd-forms/src/PdRadioGroup.js +72 -0
  27. package/dist/node_modules/@progressive-development/pd-forms/src/shared-input-field-styles.js +152 -0
  28. package/dist/node_modules/@progressive-development/pd-forms/src/shared-input-styles.js +64 -0
  29. package/dist/node_modules/@progressive-development/pd-icon/pd-icon.js +4 -0
  30. package/dist/node_modules/@progressive-development/pd-icon/src/PdIcon.js +595 -0
  31. package/dist/node_modules/@progressive-development/pd-price/pd-pricetable.js +2 -0
  32. package/dist/node_modules/@progressive-development/pd-price/src/PdPricetable.js +149 -0
  33. package/dist/node_modules/fecha/lib/fecha.js +200 -0
  34. package/dist/node_modules/lit/node_modules/lit-html/directive.js +27 -0
  35. package/dist/node_modules/lit/node_modules/lit-html/directives/class-map.js +36 -0
  36. package/dist/node_modules/lit/node_modules/lit-html/lit-html.js +242 -0
  37. package/dist/pd-order-contacts.js +2 -1
  38. package/dist/pd-order-summary.js +1 -703
  39. package/dist/src/PdOrderContacts.js +191 -0
  40. package/dist/src/PdOrderSummary.js +242 -0
  41. package/package.json +13 -5
  42. package/dist/pd-order-contacts-chunk.js +0 -3060
@@ -0,0 +1,191 @@
1
+ import { LitElement, css, html } from "lit";
2
+ import { msg } from "@lit/localize";
3
+ import "../node_modules/@progressive-development/pd-content/pd-collapse.js";
4
+ import "../node_modules/@progressive-development/pd-contact/pd-contact.js";
5
+ import { PDFontStyles } from "@progressive-development/pd-shared-styles";
6
+ /**
7
+ * @license
8
+ * Copyright (c) 2021 PD Progressive Development UG. All rights reserved.
9
+ */
10
+ class PdOrderContacts extends LitElement {
11
+ static get styles() {
12
+ return [
13
+ PDFontStyles,
14
+ css`
15
+ :host {
16
+ display: block;
17
+ }
18
+
19
+ p {
20
+ color: var(--pd-default-font-content-col);
21
+ font-size: var(--pd-default-font-content-size);
22
+ font-family: var(--pd-default-font-content-family);
23
+ max-width: 1000px;
24
+ }
25
+
26
+ a {
27
+ cursor: pointer;
28
+ font-family: var(--pd-default-font-link-family);
29
+ font-size: var(--pd-default-font-link-size);
30
+ color: var(--pd-default-font-link-col);
31
+ }
32
+
33
+ a:hover {
34
+ color: var(--pd-default-font-link-col-hover);
35
+ }
36
+
37
+ .collapse-contact {
38
+ padding: 10px;
39
+ }
40
+
41
+ .summary-box {
42
+ display: flex;
43
+ flex-wrap: wrap;
44
+ gap: 10px;
45
+ }
46
+
47
+ .first-contact {
48
+ min-width: 200px;
49
+ }
50
+ `
51
+ ];
52
+ }
53
+ static get properties() {
54
+ return {
55
+ /**
56
+ * List with required contact fields, if not set use default (previous existing values to be consitent during update)
57
+ */
58
+ requiredFields: { type: Array },
59
+ orderContact: { type: Object },
60
+ billingContact: { type: Object },
61
+ summary: { type: Boolean },
62
+ withPayment: { type: Boolean },
63
+ match: { type: Object },
64
+ _ownBillingContact: { type: Boolean }
65
+ };
66
+ }
67
+ constructor() {
68
+ super();
69
+ this._ownBillingContact = false;
70
+ this.requiredFields = [];
71
+ this.match = {};
72
+ }
73
+ connectedCallback() {
74
+ super.connectedCallback();
75
+ this.addEventListener("validate-form", this._validateForm);
76
+ }
77
+ disconnectedCallback() {
78
+ super.connectedCallback();
79
+ this.removeEventListener("validate-form", this._validateForm);
80
+ }
81
+ firstUpdated() {
82
+ this.addEventListener("toggle-accordion", (e) => {
83
+ const origin = e.composedPath()[0];
84
+ const collapsiblePanels = this.shadowRoot.querySelectorAll(
85
+ "pd-collapse"
86
+ );
87
+ collapsiblePanels.forEach((panel) => {
88
+ if (panel !== origin) {
89
+ panel.close();
90
+ }
91
+ });
92
+ });
93
+ }
94
+ render() {
95
+ if (this.summary) {
96
+ return this._renderSummary();
97
+ }
98
+ return this._renderEditContacts();
99
+ }
100
+ _renderEditContacts() {
101
+ return html`
102
+ <pd-collapse id="orderContactCollapseId" active>
103
+ <div slot="header" class="header">${msg("Adresse", { id: "pd.order.contacts.orderContact.inputHeader" })}</div>
104
+ <pd-contact
105
+ id="orderContactId"
106
+ class="collapse-contact"
107
+ slot="content"
108
+ .requiredFields="${this.requiredFields}"
109
+ .contact="${this.orderContact}"
110
+ .match="${this.match}"
111
+ ></pd-contact>
112
+ </pd-collapse>
113
+
114
+ ${this.withPayment ? html`
115
+ <pd-collapse id="billingContactCollapseId">
116
+ <div slot="header" class="header">${msg("Rechnungsadresse", { id: "pd.order.contacts.billingContact.inputHeader" })}</div>
117
+ <div slot="content">
118
+ ${this._ownBillingContact ? html`
119
+ <p>
120
+ <a @click="${() => {
121
+ this._ownBillingContact = false;
122
+ }}">
123
+ ${msg("Gleiche Rechnungsadresse", { id: "pd.order.contacts.billingContact.sameBillingLink" })}
124
+ </a>
125
+ </p>
126
+ <pd-contact
127
+ id="billingContactId"
128
+ class="collapse-contact"
129
+ .requiredField="${this.requiredFields}"
130
+ .contact="${this.billingContact}"
131
+ ></pd-contact>
132
+ ` : html`
133
+ <p>${msg("Die Adresse, wird auch als Rechnungsadresse verwendet.", { id: "pd.order.contacts.billingContact.sameBillingText" })}</p>
134
+ <p>
135
+ <a @click="${() => {
136
+ this._ownBillingContact = true;
137
+ }}">
138
+ ${msg("Andere Rechnungsadresse verwenden", { id: "pd.order.contacts.billingContact.otherBillingLink" })}
139
+ </a>
140
+ </p>
141
+ `}
142
+ </div>
143
+ </pd-collapse>` : ""}
144
+ `;
145
+ }
146
+ _renderSummary() {
147
+ return html`
148
+ <div class="summary-box">
149
+ <pd-contact
150
+ class="first-contact"
151
+ addressTitle="Onderhoud"
152
+ .contact="${this.orderContact}"
153
+ summary
154
+ ></pd-contact>
155
+ ${this.billingContact ? html`
156
+ <pd-contact
157
+ addressTitle="Facturatie"
158
+ addressRef="adres onderhoud"
159
+ .contact="${this.billingContact}"
160
+ summary
161
+ ></pd-contact>` : ""}
162
+ </div>
163
+ `;
164
+ }
165
+ _validateForm(e) {
166
+ if (e.detail && !e.detail.singleElement) {
167
+ this.shadowRoot.getElementById("orderContactId").dispatchEvent(
168
+ new CustomEvent("validate-form", {
169
+ detail: e.detail
170
+ })
171
+ );
172
+ const errorSize = e.detail.errorMap.size;
173
+ if (errorSize > 0) {
174
+ this.shadowRoot.getElementById("orderContactCollapseId").open();
175
+ }
176
+ if (this._ownBillingContact) {
177
+ this.shadowRoot.getElementById("billingContactId").dispatchEvent(
178
+ new CustomEvent("validate-form", {
179
+ detail: e.detail
180
+ })
181
+ );
182
+ if (e.detail.errorMap.size > errorSize) {
183
+ this.shadowRoot.getElementById("billingContactCollapseId").open();
184
+ }
185
+ }
186
+ }
187
+ }
188
+ }
189
+ export {
190
+ PdOrderContacts
191
+ };
@@ -0,0 +1,242 @@
1
+ import { LitElement, css, html } from "lit";
2
+ import { msg } from "@lit/localize";
3
+ import { format } from "../node_modules/fecha/lib/fecha.js";
4
+ import "../node_modules/@progressive-development/pd-forms/pd-checkbox.js";
5
+ import "../node_modules/@progressive-development/pd-forms/pd-radio-group.js";
6
+ import "../node_modules/@progressive-development/pd-content/pd-edit-content.js";
7
+ import "../node_modules/@progressive-development/pd-price/pd-pricetable.js";
8
+ import "../node_modules/@progressive-development/pd-dialog/pd-popup.js";
9
+ import "../node_modules/@progressive-development/pd-forms/pd-form-container.js";
10
+ import "../node_modules/@progressive-development/pd-forms/pd-form-row.js";
11
+ import { PDFontStyles, PDColorStyles } from "@progressive-development/pd-shared-styles";
12
+ import "../pd-order-contacts.js";
13
+ /**
14
+ * @license
15
+ * Copyright (c) 2021 PD Progressive Development UG. All rights reserved.
16
+ */
17
+ class PdOrderSummary extends LitElement {
18
+ /**
19
+ * @event go-to
20
+ */
21
+ static get styles() {
22
+ return [
23
+ PDFontStyles,
24
+ PDColorStyles,
25
+ css`
26
+ :host {
27
+ display: block;
28
+ }
29
+
30
+ h3 {
31
+ color: var(--pd-default-font-title-col);
32
+ font-family: var(--pd-default-font-title-family);
33
+ font-size: 1.5em;
34
+ /*margin-top: 10px;
35
+ margin-bottom: 20px;*/
36
+ }
37
+
38
+ .edit-summary-container {
39
+ display: flex;
40
+ flex-flow: column;
41
+ flex-wrap: wrap;
42
+ gap: 1em;
43
+ }
44
+
45
+ .payment {
46
+ margin-top: 30px;
47
+ padding: 5px;
48
+ background-color: var(--pd-order-summary-payment-bg-col, var(--pd-default-light-col));
49
+ }
50
+
51
+ .pay-logo-box {
52
+ display: flex;
53
+ }
54
+
55
+ .pay-logo {
56
+ max-width: 6rem;
57
+ }
58
+
59
+ .pricetable {
60
+ padding-top: 20px;
61
+ }
62
+
63
+ /* Temporär */
64
+ a {
65
+ cursor: pointer;
66
+ font-family: var(--pd-default-font-link-family);
67
+ font-size: var(--pd-default-font-link-size);
68
+ color: var(--pd-default-font-link-col);
69
+ }
70
+ a:hover {
71
+ color: var(--pd-default-font-link-col-hover);
72
+ }
73
+
74
+ .agree-box {
75
+ padding-top: 20px;
76
+ }
77
+
78
+ /* Size Elements for small width */
79
+ @media (max-width: 380px) {
80
+ .pay-logo {
81
+ max-width: 5rem;
82
+ }
83
+ }
84
+ `
85
+ ];
86
+ }
87
+ static get properties() {
88
+ return {
89
+ orderSteps: { type: Array },
90
+ withPayment: { type: Boolean },
91
+ withAgreement: { type: Boolean },
92
+ order: { type: Object }
93
+ };
94
+ }
95
+ constructor() {
96
+ super();
97
+ this.orderSteps = [];
98
+ this.order = {};
99
+ }
100
+ firstUpdated() {
101
+ this.addEventListener("edit-content", (e) => {
102
+ this.dispatchEvent(
103
+ new CustomEvent("go-to", {
104
+ detail: {
105
+ step: e.detail.step
106
+ },
107
+ bubbles: true,
108
+ composed: true
109
+ })
110
+ );
111
+ });
112
+ this.addEventListener("validate-form", this._validateForm);
113
+ }
114
+ render() {
115
+ if (!this.order) {
116
+ return html`<p>No order is set</p>`;
117
+ }
118
+ return html`
119
+ <h3>${msg("Übersicht", { id: "pd.order.summary.title" })}</h3>
120
+ <div class="edit-summary-container">
121
+ ${this.orderSteps.map((step, index) => {
122
+ switch (step.key) {
123
+ case "zip":
124
+ case "booking":
125
+ return this._getBookingSummary(index + 1, step);
126
+ case "contacts":
127
+ return this._getContactsSummary(index + 1, step);
128
+ default:
129
+ return html`
130
+ <pd-edit-content
131
+ contentTitle="${step.name}"
132
+ stepNumber="${index + 1}"
133
+ .data="${step.data}"
134
+ >
135
+ <slot name="${step.key}"></slot>
136
+ </pd-edit-content>
137
+ `;
138
+ }
139
+ })}
140
+ </div>
141
+
142
+ ${this.order.priceData ? html`
143
+ <div class="payment">
144
+ <h3>${msg("Rechnung", { id: "pd.order.summary.billing" })}</h3>
145
+ <!--
146
+ <pd-radio-group id="paymentGroupId" style="--group-direction: column;">
147
+ <pd-checkbox name="direct" value="false">
148
+ Pay direct, you will redirected after submit the order
149
+ <div class="pay-logo-box">
150
+ <img class="pay-logo" src="/images/paypal.svg">
151
+ <img class="pay-logo" src="/images/visa.svg">
152
+ <img class="pay-logo" src="/images/mastercard.svg">
153
+ </div>
154
+ </pd-checkbox>
155
+ <pd-checkbox name="bill" value="false">Pay with bill (5€ additional fee)</pd-checkbox>
156
+ </pd-radio-group>
157
+ -->
158
+ <pd-pricetable
159
+ class="pricetable"
160
+ .priceData="${this.order.priceData}"
161
+ ></pd-pricetable>
162
+ </div>
163
+ ` : ""}
164
+
165
+ ${this.withAgreement ? html`
166
+ <pd-form-container id="submitSummaryFormId">
167
+ <pd-form-row>
168
+ <pd-checkbox
169
+ id="agreeConditionsId"
170
+ valueName="agreeId"
171
+ class="agree-box"
172
+ required
173
+ requiredMsg="${msg("Bitte stimmen Sie den Allgemeinen Geschäftsbedingungen zu, um fortzufahren.", { id: "pd.order.summary.agree.required" })}"
174
+ >
175
+ ${msg(
176
+ html`Stimmen Sie unseren <a @click="${this._openTermsAndConditions}" @keypress="${this._openTermsAndConditions}">Allgemeinen Geschäftsbedingungen</a> zu`,
177
+ { id: "pd.order.summary.agree.link" }
178
+ )}
179
+ </pd-checkbox>
180
+ </pd-form-row>
181
+ </pd-form-container>
182
+
183
+ <pd-popup id="agreePopupId">
184
+ <div slot="content"><slot name="legal"></slot></div>
185
+ </pd-popup>
186
+ ` : ""}
187
+ `;
188
+ }
189
+ _validateForm(e) {
190
+ if (e.detail && !e.detail.singleElement && this.withAgreement) {
191
+ this.shadowRoot.getElementById("submitSummaryFormId").dispatchEvent(
192
+ new CustomEvent("validate-form", {
193
+ detail: e.detail
194
+ })
195
+ );
196
+ }
197
+ }
198
+ _getBookingSummary(index, step) {
199
+ let date;
200
+ if (this.order.selectedDate) {
201
+ date = format(this.order.selectedDate, "DD/MM/YYYY");
202
+ }
203
+ const bookingData = [{ name: "Postcode:", val: this.order.zip }];
204
+ if (date) {
205
+ bookingData.push({ name: "Datum van herstelling:", val: date });
206
+ }
207
+ return html`
208
+ <pd-edit-content
209
+ contentTitle="${step.name}"
210
+ stepNumber="${index}"
211
+ .data="${bookingData}"
212
+ >
213
+ </pd-edit-content>
214
+ `;
215
+ }
216
+ _getContactsSummary(index, step) {
217
+ return html`
218
+ <pd-edit-content
219
+ contentTitle="${step.name}"
220
+ stepNumber="${index}"
221
+ ?editDisabled="${this.order.withLogin}"
222
+ >
223
+ ${this.order.contacts ? html`
224
+ <pd-order-contacts
225
+ ?withPayment="${this.withPayment}"
226
+ .orderContact="${this.order.contacts.orderContact}"
227
+ .billingContact="${this.order.contacts.billingContact}"
228
+ summary
229
+ >
230
+ </pd-order-contacts>
231
+ ` : ""}
232
+ </pd-edit-content>
233
+ `;
234
+ }
235
+ _openTermsAndConditions(e) {
236
+ this.shadowRoot.getElementById("agreePopupId").showPopup();
237
+ e.stopPropagation();
238
+ }
239
+ }
240
+ export {
241
+ PdOrderSummary
242
+ };
package/package.json CHANGED
@@ -3,10 +3,16 @@
3
3
  "description": "Progressive Development Order Component",
4
4
  "author": "PD Progressive Development",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
- "version": "0.1.126",
6
+ "version": "0.1.128",
7
+ "main": "./dist/index.js",
8
+ "module": "./dist/index.js",
7
9
  "exports": {
10
+ ".": "./dist/index.js",
8
11
  "./pd-order-contacts": "./dist/pd-order-contacts.js",
9
- "./pd-order-summary": "./dist/pd-order-summary.js"
12
+ "./pd-order-summary": "./dist/pd-order-summary.js",
13
+ "./locales/be": "./dist/generated/locales/be.js",
14
+ "./locales/de": "./dist/generated/locales/de.js",
15
+ "./locales/en": "./dist/generated/locales/en.js"
10
16
  },
11
17
  "files": [
12
18
  "dist/",
@@ -16,7 +22,7 @@
16
22
  ],
17
23
  "scripts": {
18
24
  "analyze": "cem analyze --litelement",
19
- "dev": "vite",
25
+ "start": "vite",
20
26
  "build": "vite build",
21
27
  "preview": "vite preview",
22
28
  "lint": "eslint --ext .js,.html . --ignore-path .gitignore && prettier \"**/*.{js,html}\" --check --ignore-path .gitignore",
@@ -37,7 +43,8 @@
37
43
  "@progressive-development/pd-price": "^0.1.10",
38
44
  "@progressive-development/pd-shared-styles": "^0.1.1",
39
45
  "fecha": "^4.2.3",
40
- "lit": "^2.8.0"
46
+ "lit": "^2.8.0",
47
+ "@lit/localize": "^0.11.4"
41
48
  },
42
49
  "devDependencies": {
43
50
  "@custom-elements-manifest/analyzer": "^0.4.17",
@@ -54,7 +61,8 @@
54
61
  "lint-staged": "^10.5.4",
55
62
  "prettier": "^2.8.8",
56
63
  "storybook": "^7.6.4",
57
- "vite": "^5.4.11"
64
+ "vite": "^5.4.11",
65
+ "vitest": "^2.1.8"
58
66
  },
59
67
  "customElements": "custom-elements.json",
60
68
  "eslintConfig": {