@postnord/pn-marketweb-components 2.4.27 → 2.4.29

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 (66) hide show
  1. package/cjs/index-4199ff85.js +20 -4
  2. package/cjs/loader.cjs.js +1 -1
  3. package/cjs/pn-cta-block.cjs.entry.js +33 -0
  4. package/cjs/pn-dropdown-with-multi-input-rows-row.cjs.entry.js +183 -0
  5. package/cjs/pn-dropdown-with-multi-input-rows.cjs.entry.js +309 -0
  6. package/cjs/pn-market-web-components.cjs.js +1 -1
  7. package/cjs/pn-multiple-input.cjs.entry.js +105 -0
  8. package/collection/collection-manifest.json +4 -0
  9. package/collection/components/cta/pn-cta-block/cta-block.stories.js +252 -0
  10. package/collection/components/cta/pn-cta-block/pn-cta-block.css +187 -0
  11. package/collection/components/cta/pn-cta-block/pn-cta-block.js +169 -0
  12. package/collection/components/input/pn-dropdown-with-multi-input-rows/pn-dropdown-with-multi-input-rows-row.css +27 -0
  13. package/collection/components/input/pn-dropdown-with-multi-input-rows/pn-dropdown-with-multi-input-rows-row.js +673 -0
  14. package/collection/components/input/pn-dropdown-with-multi-input-rows/pn-dropdown-with-multi-input-rows.css +26 -0
  15. package/collection/components/input/pn-dropdown-with-multi-input-rows/pn-dropdown-with-multi-input-rows.js +970 -0
  16. package/collection/components/input/pn-dropdown-with-multi-input-rows/pn-dropdown-with-multi-input-rows.stories.js +86 -0
  17. package/collection/components/input/pn-dropdown-with-multi-input-rows/types.js +1 -0
  18. package/collection/components/input/pn-multiple-input/pn-multiple-input.css +16 -0
  19. package/collection/components/input/pn-multiple-input/pn-multiple-input.js +185 -0
  20. package/collection/components/input/pn-multiple-input/pn-multiple-input.stories.js +24 -0
  21. package/collection/components/input/pn-multiple-input/types.js +1 -0
  22. package/components/index.d.ts +4 -0
  23. package/components/index.js +4 -0
  24. package/components/pn-cta-block.d.ts +11 -0
  25. package/components/pn-cta-block.js +57 -0
  26. package/components/pn-dropdown-with-multi-input-rows-row.d.ts +11 -0
  27. package/components/pn-dropdown-with-multi-input-rows-row.js +6 -0
  28. package/components/pn-dropdown-with-multi-input-rows-row2.js +232 -0
  29. package/components/pn-dropdown-with-multi-input-rows.d.ts +11 -0
  30. package/components/pn-dropdown-with-multi-input-rows.js +379 -0
  31. package/components/pn-multiple-input.d.ts +11 -0
  32. package/components/pn-multiple-input.js +130 -0
  33. package/esm/index-ee44c065.js +20 -4
  34. package/esm/loader.js +1 -1
  35. package/esm/pn-cta-block.entry.js +29 -0
  36. package/esm/pn-dropdown-with-multi-input-rows-row.entry.js +179 -0
  37. package/esm/pn-dropdown-with-multi-input-rows.entry.js +305 -0
  38. package/esm/pn-market-web-components.js +1 -1
  39. package/esm/pn-multiple-input.entry.js +101 -0
  40. package/esm-es5/index-ee44c065.js +1 -1
  41. package/esm-es5/loader.js +1 -1
  42. package/esm-es5/pn-cta-block.entry.js +1 -0
  43. package/esm-es5/pn-dropdown-with-multi-input-rows-row.entry.js +1 -0
  44. package/esm-es5/pn-dropdown-with-multi-input-rows.entry.js +1 -0
  45. package/esm-es5/pn-market-web-components.js +1 -1
  46. package/esm-es5/pn-multiple-input.entry.js +1 -0
  47. package/package.json +1 -1
  48. package/pn-market-web-components/p-313658e7.entry.js +1 -0
  49. package/pn-market-web-components/p-47239bce.system.entry.js +1 -0
  50. package/pn-market-web-components/p-52e8d0ec.system.entry.js +1 -0
  51. package/pn-market-web-components/p-71740e7e.system.entry.js +1 -0
  52. package/pn-market-web-components/p-7787ca3b.entry.js +1 -0
  53. package/pn-market-web-components/p-ad952e14.system.entry.js +1 -0
  54. package/pn-market-web-components/p-e05b6e0c.entry.js +1 -0
  55. package/pn-market-web-components/p-f02617fc.entry.js +1 -0
  56. package/pn-market-web-components/p-fcdb7381.system.js +1 -1
  57. package/pn-market-web-components/pn-market-web-components.esm.js +1 -1
  58. package/types/components/cta/pn-cta-block/pn-cta-block.d.ts +14 -0
  59. package/types/components/input/pn-dropdown-with-multi-input-rows/pn-dropdown-with-multi-input-rows-row.d.ts +59 -0
  60. package/types/components/input/pn-dropdown-with-multi-input-rows/pn-dropdown-with-multi-input-rows.d.ts +77 -0
  61. package/types/components/input/pn-dropdown-with-multi-input-rows/types.d.ts +18 -0
  62. package/types/components/input/pn-multiple-input/pn-multiple-input.d.ts +22 -0
  63. package/types/components/input/pn-multiple-input/types.d.ts +11 -0
  64. package/types/components.d.ts +207 -6
  65. package/umd/modules/@postnord/web-components/package.json +32 -62
  66. package/umd/modules/@webcomponents/custom-elements/package.json +23 -58
@@ -0,0 +1,232 @@
1
+ import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
2
+ import { d as debounce_1 } from './index2.js';
3
+ import { d as defineCustomElement$1 } from './pn-marketweb-input2.js';
4
+
5
+ const pnDropdownWithMultiInputRowsRowCss = "pn-dropdown-with-multi-input-rows-row .input-element-row{display:-ms-flexbox;display:flex;gap:1rem;margin-bottom:1rem}pn-dropdown-with-multi-input-rows-row .input-element-row .input-container{width:30%}pn-dropdown-with-multi-input-rows-row .input-element-row .input-container pn-marketweb-input .input-container{width:100%}pn-dropdown-with-multi-input-rows-row .input-element-row .input-container pn-date-picker{width:100%}pn-dropdown-with-multi-input-rows-row .input-element-row .input-container .input-element-message-container{margin-top:0.3rem}pn-dropdown-with-multi-input-rows-row .input-element-row .input-container .input-element-message-container__error{color:red;line-height:1}pn-dropdown-with-multi-input-rows-row .input-element-row .input-container .input-element-message-container__warning{line-height:1}pn-dropdown-with-multi-input-rows-row .delete-button-contianer{margin-top:0.6rem}";
6
+
7
+ const PnDropdownWithMultiInputRowsRow = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
8
+ constructor() {
9
+ super();
10
+ this.__registerHost();
11
+ this.rowValueChange = createEvent(this, "rowValueChange", 7);
12
+ this.deleteRowEvent = createEvent(this, "deleteRowEvent", 7);
13
+ this.firstInputChange = createEvent(this, "firstInputChange", 7);
14
+ this.secondInputChange = createEvent(this, "secondInputChange", 7);
15
+ this.pnFirstInputField = null;
16
+ this.pnSecondInputField = null;
17
+ this.pnDatePicker = null;
18
+ this.pnDeleteRowButton = null;
19
+ this.languageCode = null;
20
+ this.fristInputPlaceholder = null;
21
+ this.firstInputMin = null;
22
+ this.firstInputMax = null;
23
+ this.firstInputWarning = null;
24
+ this.firstInputWarningText = null;
25
+ this.firstInputLowErrorText = null;
26
+ this.firstInputHighErrorText = null;
27
+ this.secondInputPlaceholder = null;
28
+ this.secondInputMin = null;
29
+ this.secondInputMax = null;
30
+ this.secondInputWarning = null;
31
+ this.secondInputWarningText = null;
32
+ this.secondInputLowErrorText = null;
33
+ this.secondInputHighErrorText = null;
34
+ this.dateLabel = null;
35
+ this.datePlaceholder = null;
36
+ this.firstValidDate = null;
37
+ this.lastValidDate = null;
38
+ this.predefinedValue = null;
39
+ this.rowIndex = null;
40
+ this.minRowCount = null;
41
+ this.showFirstInputWarning = false;
42
+ this.showFirstInputLowError = false;
43
+ this.showFirstInputHighError = false;
44
+ this.showSecondInputWarning = false;
45
+ this.showSecondInputLowError = false;
46
+ this.showSecondInputHighError = false;
47
+ this.firstInputValue = '';
48
+ this.secondInputValue = '';
49
+ this.dateValue = '';
50
+ }
51
+ componentWillLoad() {
52
+ this.getPredefinedValues();
53
+ this.setInitialValues();
54
+ }
55
+ componentDidLoad() {
56
+ this.addEventHandlers();
57
+ }
58
+ getPredefinedValues() {
59
+ this._predefinedValue = JSON.parse(this.predefinedValue);
60
+ }
61
+ applyPredefinedValue() {
62
+ var _a, _b;
63
+ this.getPredefinedValues();
64
+ this.setInitialValues();
65
+ if ((_a = this.firstInputValue) === null || _a === void 0 ? void 0 : _a.length) {
66
+ this.validateFirstInput(parseInt(this.firstInputValue));
67
+ }
68
+ if ((_b = this.secondInputValue) === null || _b === void 0 ? void 0 : _b.length) {
69
+ this.validateSecondInput(parseInt(this.secondInputValue));
70
+ }
71
+ if (this.rowIndex >= this.minRowCount) {
72
+ this.pnDeleteRowButton.addEventListener('click', this.deleteRow.bind(this));
73
+ }
74
+ }
75
+ setInitialValues() {
76
+ this.firstInputValue = this._predefinedValue.firstInput;
77
+ this.secondInputValue = this._predefinedValue.secondInput;
78
+ this.dateValue = this._predefinedValue.date;
79
+ }
80
+ addEventHandlers() {
81
+ const emmitValues = debounce_1.debounce(this.emitRowValues.bind(this), 500);
82
+ this.pnFirstInputField.addEventListener('keyup', debounce_1.debounce(this.handleFirstInput.bind(this), 500));
83
+ this.pnSecondInputField.addEventListener('keyup', debounce_1.debounce(this.handleSecondInput.bind(this), 500));
84
+ this.pnDatePicker.addEventListener('dateselection', this.handleDateChange.bind(this));
85
+ this.pnDatePicker.addEventListener('dateselection', emmitValues);
86
+ }
87
+ handleFirstInput(e) {
88
+ const elm = e.target;
89
+ const value = parseInt(elm.value);
90
+ if (value > 0) {
91
+ this.firstInputValue = elm.value;
92
+ this.firstInputChange.emit({
93
+ id: this._predefinedValue.id,
94
+ firstInput: this.firstInputValue,
95
+ secondInput: this.secondInputValue,
96
+ date: this.dateValue,
97
+ });
98
+ }
99
+ this.validateFirstInput(value);
100
+ this.emitRowValues();
101
+ }
102
+ handleSecondInput(e) {
103
+ const elm = e.target;
104
+ const value = parseInt(elm.value);
105
+ if (value > 0) {
106
+ this.secondInputValue = elm.value;
107
+ this.secondInputChange.emit({
108
+ id: this._predefinedValue.id,
109
+ firstInput: this.firstInputValue,
110
+ secondInput: this.secondInputValue,
111
+ date: this.dateValue,
112
+ });
113
+ }
114
+ this.validateSecondInput(value);
115
+ this.emitRowValues();
116
+ }
117
+ validateFirstInput(input) {
118
+ this.showFirstInputWarning = false;
119
+ this.showFirstInputLowError = false;
120
+ this.showFirstInputHighError = false;
121
+ if (input < this.firstInputWarning) {
122
+ this.showFirstInputWarning = true;
123
+ }
124
+ if (input < this.firstInputMin) {
125
+ this.showFirstInputWarning = false;
126
+ this.showFirstInputLowError = true;
127
+ }
128
+ if (input > this.firstInputMax) {
129
+ this.showFirstInputWarning = false;
130
+ this.showFirstInputLowError = false;
131
+ this.showFirstInputHighError = true;
132
+ }
133
+ }
134
+ validateSecondInput(input) {
135
+ this.showSecondInputWarning = false;
136
+ this.showSecondInputLowError = false;
137
+ this.showSecondInputHighError = false;
138
+ if (input < this.secondInputWarning) {
139
+ this.showSecondInputWarning = true;
140
+ }
141
+ if (input < this.secondInputMin) {
142
+ this.showSecondInputWarning = false;
143
+ this.showSecondInputLowError = true;
144
+ }
145
+ if (input > this.secondInputMax) {
146
+ this.showSecondInputWarning = false;
147
+ this.showSecondInputLowError = false;
148
+ this.showSecondInputHighError = true;
149
+ }
150
+ }
151
+ handleDateChange(e) {
152
+ const elm = e.target;
153
+ if (elm === this.pnDatePicker) {
154
+ this.dateValue = e.detail;
155
+ }
156
+ }
157
+ emitRowValues() {
158
+ this.rowValueChange.emit({
159
+ id: this._predefinedValue.id,
160
+ firstInput: this.firstInputValue,
161
+ secondInput: this.secondInputValue,
162
+ date: this.dateValue,
163
+ });
164
+ }
165
+ deleteRow() {
166
+ this.deleteRowEvent.emit(this._predefinedValue.id);
167
+ }
168
+ render() {
169
+ var _a;
170
+ return (h(Host, null, h("div", { class: "input-element-row" }, h("div", { class: "input-container" }, h("pn-marketweb-input", { ref: el => (this.pnFirstInputField = el), type: "number", placeholder: this.fristInputPlaceholder, value: this.firstInputValue, min: "1" }), this.showFirstInputLowError || this.showFirstInputHighError || this.showFirstInputWarning ? (h("div", { class: "input-element-message-container" }, this.showFirstInputLowError ? (h("div", { class: "input-element-message-container__error" }, h("small", null, this.firstInputLowErrorText))) : null, this.showFirstInputHighError ? (h("div", { class: "input-element-message-container__error" }, h("small", null, this.firstInputHighErrorText))) : null, this.showFirstInputWarning ? (h("div", { class: "input-element-message-container__warning" }, h("small", null, this.firstInputWarningText))) : null)) : null), h("div", { class: "input-container" }, h("pn-marketweb-input", { ref: el => (this.pnSecondInputField = el), type: "number", placeholder: this.secondInputPlaceholder, value: this.secondInputValue, min: "1" }), this.showSecondInputLowError || this.showSecondInputHighError || this.showSecondInputWarning ? (h("div", { class: "input-element-message-container" }, this.showSecondInputLowError ? (h("div", { class: "input-element-message-container__error" }, h("small", null, this.secondInputLowErrorText))) : null, this.showSecondInputHighError ? (h("div", { class: "input-element-message-container__error" }, h("small", null, this.secondInputHighErrorText))) : null, this.showSecondInputWarning ? (h("div", { class: "input-element-message-container__warning" }, h("small", null, this.secondInputWarningText))) : null)) : null), h("div", { class: "input-container" }, h("pn-date-picker", { ref: el => (this.pnDatePicker = el), range: "false", "disable-weekends": true, "min-date": this.firstValidDate, "max-date": this.lastValidDate, language: this.languageCode, placeholder: this.datePlaceholder, start: ((_a = this.dateValue) === null || _a === void 0 ? void 0 : _a.length) ? this.dateValue : null })), this.rowIndex >= this.minRowCount ? (h("div", { class: "delete-button-contianer" }, h("pn-button", { ref: el => (this.pnDeleteRowButton = el), small: "true", "icon-only": "true", icon: "minus", appearance: "warning", index: this.rowIndex, onClick: () => {
171
+ this.deleteRow();
172
+ } }, "Delete"))) : null)));
173
+ }
174
+ get hostElement() { return this; }
175
+ static get watchers() { return {
176
+ "predefinedValue": ["applyPredefinedValue"]
177
+ }; }
178
+ static get style() { return pnDropdownWithMultiInputRowsRowCss; }
179
+ }, [0, "pn-dropdown-with-multi-input-rows-row", {
180
+ "languageCode": [1, "language-code"],
181
+ "fristInputPlaceholder": [1, "frist-input-placeholder"],
182
+ "firstInputMin": [2, "first-input-min"],
183
+ "firstInputMax": [2, "first-input-max"],
184
+ "firstInputWarning": [2, "first-input-warning"],
185
+ "firstInputWarningText": [1, "first-input-warning-text"],
186
+ "firstInputLowErrorText": [1, "first-input-low-error-text"],
187
+ "firstInputHighErrorText": [1, "first-input-high-error-text"],
188
+ "secondInputPlaceholder": [1, "second-input-placeholder"],
189
+ "secondInputMin": [2, "second-input-min"],
190
+ "secondInputMax": [2, "second-input-max"],
191
+ "secondInputWarning": [2, "second-input-warning"],
192
+ "secondInputWarningText": [1, "second-input-warning-text"],
193
+ "secondInputLowErrorText": [1, "second-input-low-error-text"],
194
+ "secondInputHighErrorText": [1, "second-input-high-error-text"],
195
+ "dateLabel": [1, "date-label"],
196
+ "datePlaceholder": [1, "date-placeholder"],
197
+ "firstValidDate": [1, "first-valid-date"],
198
+ "lastValidDate": [1, "last-valid-date"],
199
+ "predefinedValue": [1, "predefined-value"],
200
+ "rowIndex": [2, "row-index"],
201
+ "minRowCount": [2, "min-row-count"],
202
+ "showFirstInputWarning": [32],
203
+ "showFirstInputLowError": [32],
204
+ "showFirstInputHighError": [32],
205
+ "showSecondInputWarning": [32],
206
+ "showSecondInputLowError": [32],
207
+ "showSecondInputHighError": [32],
208
+ "firstInputValue": [32],
209
+ "secondInputValue": [32],
210
+ "dateValue": [32]
211
+ }]);
212
+ function defineCustomElement() {
213
+ if (typeof customElements === "undefined") {
214
+ return;
215
+ }
216
+ const components = ["pn-dropdown-with-multi-input-rows-row", "pn-marketweb-input"];
217
+ components.forEach(tagName => { switch (tagName) {
218
+ case "pn-dropdown-with-multi-input-rows-row":
219
+ if (!customElements.get(tagName)) {
220
+ customElements.define(tagName, PnDropdownWithMultiInputRowsRow);
221
+ }
222
+ break;
223
+ case "pn-marketweb-input":
224
+ if (!customElements.get(tagName)) {
225
+ defineCustomElement$1();
226
+ }
227
+ break;
228
+ } });
229
+ }
230
+ defineCustomElement();
231
+
232
+ export { PnDropdownWithMultiInputRowsRow as P, defineCustomElement as d };
@@ -0,0 +1,11 @@
1
+ import type { Components, JSX } from "../types/components";
2
+
3
+ interface PnDropdownWithMultiInputRows extends Components.PnDropdownWithMultiInputRows, HTMLElement {}
4
+ export const PnDropdownWithMultiInputRows: {
5
+ prototype: PnDropdownWithMultiInputRows;
6
+ new (): PnDropdownWithMultiInputRows;
7
+ };
8
+ /**
9
+ * Used to define this component and all nested components recursively.
10
+ */
11
+ export const defineCustomElement: () => void;
@@ -0,0 +1,379 @@
1
+ import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
2
+ import { d as debounce_1 } from './index2.js';
3
+ import { d as defineCustomElement$3 } from './pn-dropdown-with-multi-input-rows-row2.js';
4
+ import { d as defineCustomElement$2 } from './pn-marketweb-input2.js';
5
+ import { v as v4 } from './v4.js';
6
+
7
+ const pnDropdownWithMultiInputRowsCss = "pn-dropdown-with-multi-input-rows .dropdown-with-multi-input-elemet__row{margin-bottom:1rem}pn-dropdown-with-multi-input-rows .dropdown-with-multi-input-elemet__delete{display:-ms-flexbox;display:flex;gap:1rem;margin-bottom:1rem;padding:1rem;background-color:#F9F8F8}pn-dropdown-with-multi-input-rows .dropdown-with-multi-input-elemet__delete pn-button{margin-top:0.9rem}pn-dropdown-with-multi-input-rows .dropdown-with-multi-input-elemet__label-row{display:-ms-flexbox;display:flex;gap:1rem}pn-dropdown-with-multi-input-rows .dropdown-with-multi-input-elemet__label{width:30%;font-size:0.875em;color:#5e554a}pn-dropdown-with-multi-input-rows .sum-row{display:-ms-flexbox;display:flex;-ms-flex-pack:justify;justify-content:space-between}";
8
+
9
+ const PnDropdownWithMultiInputRows$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
10
+ constructor() {
11
+ super();
12
+ this.__registerHost();
13
+ this.allFormValues = createEvent(this, "allFormValues", 7);
14
+ this.pnFirstDropdown = null;
15
+ this.pnSecondDropdown = null;
16
+ this.pnSumField = null;
17
+ this.pnConfirmDeleteButton = null;
18
+ this.pnAbortDeleteButton = null;
19
+ this._firstDropdownSelection = null;
20
+ this._secondDropdownSelection = null;
21
+ this._defaultRow = {
22
+ id: this.generateUniqueId(),
23
+ firstInput: '',
24
+ secondInput: this.secondInputWarning.toString(),
25
+ date: '',
26
+ };
27
+ this.dropdownData = null;
28
+ this.languageCode = null;
29
+ this.firstDropdownLabel = null;
30
+ this.firstDropdownHelperText = null;
31
+ this.secondDropdownLabel = null;
32
+ this.secondDropdownHelperText = null;
33
+ this.secondDropdownMax = null;
34
+ this.deleteMultipleRowsWarningText = null;
35
+ this.confirmDeleteButtonText = null;
36
+ this.abortDeleteButtonText = null;
37
+ this.fristInputLabel = null;
38
+ this.fristInputPlaceholder = null;
39
+ this.firstInputMin = null;
40
+ this.firstInputMax = null;
41
+ this.firstInputWarning = null;
42
+ this.firstInputWarningText = null;
43
+ this.firstInputLowErrorText = null;
44
+ this.firstInputHighErrorText = null;
45
+ this.secondInputLabel = null;
46
+ this.secondInputPlaceholder = null;
47
+ this.secondInputMin = null;
48
+ this.secondInputMax = null;
49
+ this.secondInputWarning = null;
50
+ this.secondInputWarningText = null;
51
+ this.secondInputLowErrorText = null;
52
+ this.secondInputHighErrorText = null;
53
+ this.dateLabel = null;
54
+ this.datePlaceholder = null;
55
+ this.dateDaysFromToday = 1;
56
+ this.yearsToAddToEndDate = null;
57
+ this.sumFieldLabel = null;
58
+ this.addRowText = null;
59
+ this.elementHelperText = null;
60
+ this.dropdownDataRoot = null;
61
+ this.secondDropdownArr = [];
62
+ this.rowCount = null;
63
+ this.rowData = null;
64
+ this.formValues = null;
65
+ this.firstValidDateString = '';
66
+ this.lastValidDateString = '';
67
+ this.rowSum = null;
68
+ this.minRowCount = null;
69
+ this.showDelteConfirm = false;
70
+ }
71
+ componentWillLoad() {
72
+ this.formValues = [];
73
+ this.setDropDownData();
74
+ this.updateSecondDropdown();
75
+ this.setRowData();
76
+ this.setFirstValidDate();
77
+ }
78
+ componentDidLoad() {
79
+ this.updateSum();
80
+ }
81
+ setDropDownData() {
82
+ var _a;
83
+ if (typeof this.dropdownData === 'string') {
84
+ this.dropdownDataRoot = JSON.parse(this.dropdownData);
85
+ }
86
+ else {
87
+ this.dropdownDataRoot = this.dropdownData;
88
+ }
89
+ if ((_a = this.dropdownDataRoot) === null || _a === void 0 ? void 0 : _a.length) {
90
+ this.dropdownDataRoot.forEach(element => {
91
+ if (!element.value) {
92
+ element.value = 0;
93
+ }
94
+ });
95
+ }
96
+ if (this.dropdownDataRoot.length > 0) {
97
+ this.dropdownDataRoot[0].checked = true;
98
+ this._firstDropdownSelection = this.dropdownDataRoot[0].caption;
99
+ this._secondDropdownSelection = this.dropdownDataRoot[0].value;
100
+ this.minRowCount = this.dropdownDataRoot[0].value;
101
+ }
102
+ }
103
+ updateSecondDropdown() {
104
+ const selectedItem = this.dropdownDataRoot.find(arr => arr.checked === true);
105
+ this.secondDropdownArr = [];
106
+ for (let index = selectedItem.value; index <= this.secondDropdownMax; index++) {
107
+ this.secondDropdownArr.push(index);
108
+ }
109
+ }
110
+ updateSelectItemArr(arr, caption) {
111
+ arr.forEach(item => {
112
+ if (item.caption === caption) {
113
+ item.checked = !item.checked;
114
+ }
115
+ else {
116
+ item.checked = false;
117
+ }
118
+ });
119
+ return arr;
120
+ }
121
+ setRowData() {
122
+ this.rowData = [];
123
+ for (let index = 0; index < this._secondDropdownSelection; index++) {
124
+ const row = Object.assign({}, this._defaultRow);
125
+ row.id = this.generateUniqueId();
126
+ this.rowData = [...this.rowData, row];
127
+ }
128
+ this.rowCount = this.rowData.length;
129
+ }
130
+ generateUniqueId() {
131
+ return v4();
132
+ }
133
+ setFirstValidDate() {
134
+ var _a;
135
+ const yearsToadd = this.yearsToAddToEndDate ? this.yearsToAddToEndDate : 2;
136
+ const date = new Date();
137
+ date.setDate((_a = date.getDate() + this.dateDaysFromToday) !== null && _a !== void 0 ? _a : 0);
138
+ const year = date.getFullYear();
139
+ const month = (date.getMonth() + 1).toString().padStart(2, '0');
140
+ const day = date.getDate().toString().padStart(2, '0');
141
+ const endYear = year + yearsToadd;
142
+ this.firstValidDateString = `${year.toString()}-${month}-${day}`;
143
+ this.lastValidDateString = `${endYear.toString()}-${month}-${day}`;
144
+ }
145
+ addRow(newRowId) {
146
+ const newRow = Object.assign({}, this.rowData[0]);
147
+ newRow.id = newRowId ? newRowId : this.generateUniqueId();
148
+ newRow.date = '';
149
+ this.rowData = [...this.rowData, newRow];
150
+ this.rowCount = this.rowData.length;
151
+ this._secondDropdownSelection = this.rowCount;
152
+ this.secondDropdownArr = [...this.secondDropdownArr];
153
+ this.updateSum();
154
+ this.emitValuesIfValid();
155
+ }
156
+ handleFirstDropdown() {
157
+ const selected = this.pnFirstDropdown.querySelector('.current-selection .pn-option-content');
158
+ const selectedValue = selected === null || selected === void 0 ? void 0 : selected.textContent;
159
+ if (!(selectedValue === null || selectedValue === void 0 ? void 0 : selectedValue.length)) {
160
+ return;
161
+ }
162
+ this.dropdownDataRoot.forEach(element => {
163
+ element.checked = false;
164
+ });
165
+ const selectionRoot = this.dropdownDataRoot.find(x => x.caption === selectedValue);
166
+ selectionRoot.checked = true;
167
+ this._firstDropdownSelection = selectionRoot.caption;
168
+ this.minRowCount = selectionRoot.value;
169
+ if (selectionRoot.value > this._secondDropdownSelection) {
170
+ this.dropdownDataRoot = [...this.dropdownDataRoot];
171
+ for (let index = this.rowCount; index < selectionRoot.value; index++) {
172
+ this.addRow(this.generateUniqueId());
173
+ }
174
+ }
175
+ this.updateSecondDropdown();
176
+ this.updateSum();
177
+ this.emitValuesIfValid();
178
+ }
179
+ handleSecondDropdown() {
180
+ const selected = this.pnSecondDropdown.querySelector('.current-selection .pn-option-content');
181
+ const selectedValue = selected === null || selected === void 0 ? void 0 : selected.textContent;
182
+ if (!(selectedValue === null || selectedValue === void 0 ? void 0 : selectedValue.length)) {
183
+ return;
184
+ }
185
+ const value = parseInt(selectedValue);
186
+ if (value < this._secondDropdownSelection) {
187
+ this.showDelteConfirm = true;
188
+ }
189
+ else {
190
+ for (let index = this.rowCount; index < value; index++) {
191
+ this.addRow(this.generateUniqueId());
192
+ }
193
+ }
194
+ this.updateSum();
195
+ this.emitValuesIfValid();
196
+ }
197
+ predefinedValueChange(e) {
198
+ const indexToUpdate = this.rowData.findIndex(data => data.id === e.detail.id);
199
+ const val = e.detail;
200
+ this.rowData[indexToUpdate] = Object.assign(Object.assign({}, this.rowData[indexToUpdate]), { firstInput: val.firstInput, secondInput: val.secondInput, date: val.date });
201
+ if (e.type === 'firstInputChange' && indexToUpdate === 0) {
202
+ this.updateFirstInputOfRows(val.firstInput);
203
+ }
204
+ if (e.type === 'secondInputChange' && indexToUpdate === 0) {
205
+ this.updateSecondInputOfRows(val.secondInput);
206
+ }
207
+ this.rowData = [...this.rowData];
208
+ this.emitValuesIfValid();
209
+ this.updateSum();
210
+ }
211
+ updateFirstInputOfRows(value) {
212
+ for (let index = 1; index < this.rowCount; index++) {
213
+ this.rowData[index] = Object.assign(Object.assign({}, this.rowData[index]), { firstInput: value });
214
+ }
215
+ }
216
+ updateSecondInputOfRows(value) {
217
+ for (let index = 1; index < this.rowCount; index++) {
218
+ this.rowData[index] = Object.assign(Object.assign({}, this.rowData[index]), { secondInput: value });
219
+ }
220
+ }
221
+ deleteRowEvent(e) {
222
+ const indexToRemove = this.rowData.findIndex(data => data.id === e.detail);
223
+ if (indexToRemove < 0) {
224
+ return;
225
+ }
226
+ this.rowData.splice(indexToRemove, 1);
227
+ this.rowData = [...this.rowData];
228
+ this.rowCount = this.rowData.length;
229
+ this._secondDropdownSelection = this.rowCount;
230
+ this.secondDropdownArr = [...this.secondDropdownArr];
231
+ this.emitValuesIfValid();
232
+ this.updateSum();
233
+ }
234
+ updateSum() {
235
+ this.rowSum = '';
236
+ let sum = 0;
237
+ this.rowData.forEach(element => {
238
+ var _a;
239
+ if ((_a = element === null || element === void 0 ? void 0 : element.firstInput) === null || _a === void 0 ? void 0 : _a.length) {
240
+ sum += parseInt(element.firstInput);
241
+ }
242
+ });
243
+ this.rowSum = sum.toString();
244
+ }
245
+ deleteExcessRows() {
246
+ const selected = this.pnSecondDropdown.querySelector('.current-selection .pn-option-content');
247
+ const selectedValue = selected === null || selected === void 0 ? void 0 : selected.textContent;
248
+ if (!(selectedValue === null || selectedValue === void 0 ? void 0 : selectedValue.length)) {
249
+ return;
250
+ }
251
+ const rowsToDelete = this.rowCount - parseInt(selectedValue);
252
+ for (let index = 0; index < rowsToDelete; index++) {
253
+ this.rowData.pop();
254
+ }
255
+ this.rowData = [...this.rowData];
256
+ this.showDelteConfirm = false;
257
+ this.updateSum();
258
+ }
259
+ abortDeleteRows() {
260
+ this.showDelteConfirm = false;
261
+ }
262
+ emitValuesIfValid() {
263
+ this.formValues = [];
264
+ this.rowData.forEach(item => {
265
+ var _a, _b, _c, _d;
266
+ const rowValue = { row: [] };
267
+ if ((_a = this._firstDropdownSelection) === null || _a === void 0 ? void 0 : _a.length) {
268
+ const dropDownValue = { name: this.firstDropdownLabel, value: this._firstDropdownSelection };
269
+ rowValue.row.push(dropDownValue);
270
+ }
271
+ if ((_b = item.firstInput) === null || _b === void 0 ? void 0 : _b.length) {
272
+ const firstInputValue = { name: this.fristInputLabel, value: item.firstInput };
273
+ rowValue.row.push(firstInputValue);
274
+ }
275
+ if ((_c = item.secondInput) === null || _c === void 0 ? void 0 : _c.length) {
276
+ const secondInputValue = { name: this.secondInputLabel, value: item.secondInput };
277
+ rowValue.row.push(secondInputValue);
278
+ }
279
+ if ((_d = item.date) === null || _d === void 0 ? void 0 : _d.length) {
280
+ const dateValue = { name: this.dateLabel, value: item.date };
281
+ rowValue.row.push(dateValue);
282
+ }
283
+ if (rowValue.row.length === 4) {
284
+ this.formValues.push(rowValue);
285
+ }
286
+ });
287
+ if (this.formValues.length === this.rowData.length) {
288
+ const valueJsonString = JSON.stringify(this.formValues);
289
+ this.allFormValues.emit(valueJsonString);
290
+ }
291
+ else {
292
+ this.allFormValues.emit('');
293
+ }
294
+ }
295
+ render() {
296
+ var _a, _b, _c, _d, _e, _f;
297
+ return (h(Host, { class: "dropdown-with-multi-input-elemet" }, h("div", { class: "dropdown-with-multi-input-elemet__row" }, h("div", null, h("pn-select", { ref: el => (this.pnFirstDropdown = el), class: "pn-row-select-dropdown dropDown1-dropdown", label: this.firstDropdownLabel }, (_a = this.dropdownDataRoot) === null || _a === void 0 ? void 0 : _a.map((item, i) => (h("pn-option", { index: i, value: item.value, selected: item.checked, onClick: debounce_1.debounce(this.handleFirstDropdown.bind(this), 500) }, item.caption)))), ((_b = this.firstDropdownHelperText) === null || _b === void 0 ? void 0 : _b.length) ? h("small", null, this.firstDropdownHelperText) : null)), h("div", { class: "dropdown-with-multi-input-elemet__row" }, h("div", null, h("pn-select", { ref: el => (this.pnSecondDropdown = el), class: "pn-row-select-dropdown dropDown2-dropdown", label: this.secondDropdownLabel }, (_c = this.secondDropdownArr) === null || _c === void 0 ? void 0 : _c.map((item, i) => (h("pn-option", { index: i, value: item, selected: item === this._secondDropdownSelection, onClick: debounce_1.debounce(this.handleSecondDropdown.bind(this), 500) }, item)))), ((_d = this.secondDropdownHelperText) === null || _d === void 0 ? void 0 : _d.length) ? h("small", null, this.secondDropdownHelperText) : null)), this.showDelteConfirm ? (h("div", { class: "dropdown-with-multi-input-elemet__delete" }, h("p", null, this.deleteMultipleRowsWarningText), h("pn-button", { ref: el => (this.pnConfirmDeleteButton = el), small: "true", appearance: "warning", onClick: this.deleteExcessRows.bind(this) }, this.confirmDeleteButtonText), h("pn-button", { ref: el => (this.pnAbortDeleteButton = el), small: "true", appearance: "light", onClick: this.abortDeleteRows.bind(this) }, this.abortDeleteButtonText))) : null, h("div", { class: "dropdown-with-multi-input-elemet__label-row" }, h("div", { class: "dropdown-with-multi-input-elemet__label" }, h("label", null, this.fristInputLabel)), h("div", { class: "dropdown-with-multi-input-elemet__label" }, h("label", null, this.secondInputLabel)), h("div", { class: "dropdown-with-multi-input-elemet__label" }, h("label", null, this.dateLabel))), (_e = this.rowData) === null || _e === void 0 ? void 0 :
298
+ _e.map((data, i) => {
299
+ return (h("div", { class: 'dropdown-with-multi-input-elemet__row generated-row-' + i, id: 'generated-row-' + i }, h("pn-dropdown-with-multi-input-rows-row", { "language-code": this.languageCode, "frist-input-placeholder": this.fristInputPlaceholder, "first-input-min": this.firstInputMin, "first-input-max": this.firstInputMax, "first-input-warning": this.firstInputWarning, "first-input-warning-text": this.firstInputWarningText, "first-input-low-error-text": this.firstInputLowErrorText, "first-input-high-error-text": this.firstInputHighErrorText, "second-input-placeholder": this.secondInputPlaceholder, "second-input-min": this.secondInputMin, "second-input-max": this.secondInputMax, "second-input-warning": this.secondInputWarning, "second-input-warning-text": this.secondInputWarningText, "second-input-low-error-text": this.secondInputLowErrorText, "second-input-high-error-text": this.secondInputHighErrorText, datePlaceholder: this.datePlaceholder, firstValidDate: this.firstValidDateString, lastValidDate: this.lastValidDateString, "predefined-value": JSON.stringify(data), "min-row-count": this.minRowCount, "row-index": i })));
300
+ }), h("div", { class: "dropdown-with-multi-input-elemet__row sum-row" }, h("pn-marketweb-input", { disabled: true, ref: el => (this.pnSumField = el), type: "number", value: this.rowSum, label: this.sumFieldLabel }), h("pn-button", { "icon-only": this.addRowText ? false : true, "left-icon": "true", "aria-label": "Add", icon: "plus", appearance: "light", variant: "borderless", class: "connected-dropdown__button-right", onClick: () => {
301
+ this.addRow(this.generateUniqueId());
302
+ } }, this.addRowText)), ((_f = this.elementHelperText) === null || _f === void 0 ? void 0 : _f.length) ? h("div", { class: "dropdown-with-multi-input-elemet__row" }, this.elementHelperText) : null));
303
+ }
304
+ get hostElement() { return this; }
305
+ static get style() { return pnDropdownWithMultiInputRowsCss; }
306
+ }, [0, "pn-dropdown-with-multi-input-rows", {
307
+ "dropdownData": [1, "dropdown-data"],
308
+ "languageCode": [1, "language-code"],
309
+ "firstDropdownLabel": [1, "first-dropdown-label"],
310
+ "firstDropdownHelperText": [1, "first-dropdown-helper-text"],
311
+ "secondDropdownLabel": [1, "second-dropdown-label"],
312
+ "secondDropdownHelperText": [1, "second-dropdown-helper-text"],
313
+ "secondDropdownMax": [2, "second-dropdown-max"],
314
+ "deleteMultipleRowsWarningText": [1, "delete-multiple-rows-warning-text"],
315
+ "confirmDeleteButtonText": [1, "confirm-delete-button-text"],
316
+ "abortDeleteButtonText": [1, "abort-delete-button-text"],
317
+ "fristInputLabel": [1, "frist-input-label"],
318
+ "fristInputPlaceholder": [1, "frist-input-placeholder"],
319
+ "firstInputMin": [2, "first-input-min"],
320
+ "firstInputMax": [2, "first-input-max"],
321
+ "firstInputWarning": [2, "first-input-warning"],
322
+ "firstInputWarningText": [1, "first-input-warning-text"],
323
+ "firstInputLowErrorText": [1, "first-input-low-error-text"],
324
+ "firstInputHighErrorText": [1, "first-input-high-error-text"],
325
+ "secondInputLabel": [1, "second-input-label"],
326
+ "secondInputPlaceholder": [1, "second-input-placeholder"],
327
+ "secondInputMin": [2, "second-input-min"],
328
+ "secondInputMax": [2, "second-input-max"],
329
+ "secondInputWarning": [2, "second-input-warning"],
330
+ "secondInputWarningText": [1, "second-input-warning-text"],
331
+ "secondInputLowErrorText": [1, "second-input-low-error-text"],
332
+ "secondInputHighErrorText": [1, "second-input-high-error-text"],
333
+ "dateLabel": [1, "date-label"],
334
+ "datePlaceholder": [1, "date-placeholder"],
335
+ "dateDaysFromToday": [2, "date-days-from-today"],
336
+ "yearsToAddToEndDate": [2, "years-to-add-to-end-date"],
337
+ "sumFieldLabel": [1, "sum-field-label"],
338
+ "addRowText": [1, "add-row-text"],
339
+ "elementHelperText": [1, "element-helper-text"],
340
+ "dropdownDataRoot": [32],
341
+ "secondDropdownArr": [32],
342
+ "rowCount": [32],
343
+ "rowData": [32],
344
+ "formValues": [32],
345
+ "firstValidDateString": [32],
346
+ "lastValidDateString": [32],
347
+ "rowSum": [32],
348
+ "minRowCount": [32],
349
+ "showDelteConfirm": [32]
350
+ }, [[0, "rowValueChange", "predefinedValueChange"], [0, "firstInputChange", "predefinedValueChange"], [0, "secondInputChange", "predefinedValueChange"], [0, "deleteRowEvent", "deleteRowEvent"]]]);
351
+ function defineCustomElement$1() {
352
+ if (typeof customElements === "undefined") {
353
+ return;
354
+ }
355
+ const components = ["pn-dropdown-with-multi-input-rows", "pn-dropdown-with-multi-input-rows-row", "pn-marketweb-input"];
356
+ components.forEach(tagName => { switch (tagName) {
357
+ case "pn-dropdown-with-multi-input-rows":
358
+ if (!customElements.get(tagName)) {
359
+ customElements.define(tagName, PnDropdownWithMultiInputRows$1);
360
+ }
361
+ break;
362
+ case "pn-dropdown-with-multi-input-rows-row":
363
+ if (!customElements.get(tagName)) {
364
+ defineCustomElement$3();
365
+ }
366
+ break;
367
+ case "pn-marketweb-input":
368
+ if (!customElements.get(tagName)) {
369
+ defineCustomElement$2();
370
+ }
371
+ break;
372
+ } });
373
+ }
374
+ defineCustomElement$1();
375
+
376
+ const PnDropdownWithMultiInputRows = PnDropdownWithMultiInputRows$1;
377
+ const defineCustomElement = defineCustomElement$1;
378
+
379
+ export { PnDropdownWithMultiInputRows, defineCustomElement };
@@ -0,0 +1,11 @@
1
+ import type { Components, JSX } from "../types/components";
2
+
3
+ interface PnMultipleInput extends Components.PnMultipleInput, HTMLElement {}
4
+ export const PnMultipleInput: {
5
+ prototype: PnMultipleInput;
6
+ new (): PnMultipleInput;
7
+ };
8
+ /**
9
+ * Used to define this component and all nested components recursively.
10
+ */
11
+ export const defineCustomElement: () => void;