@postnord/pn-marketweb-components 2.4.24 → 2.4.25

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/cjs/index-4199ff85.js +16 -8
  2. package/cjs/loader.cjs.js +1 -1
  3. package/cjs/pn-market-web-components.cjs.js +1 -1
  4. package/cjs/pn-multi-row-connected-dropdown-row.cjs.entry.js +372 -0
  5. package/cjs/pn-multi-row-connected-dropdown.cjs.entry.js +205 -0
  6. package/collection/collection-manifest.json +2 -0
  7. package/collection/components/input/pn-multi-row-connected-dropdown/pn-multi-row-connected-dropdown-row.css +90 -0
  8. package/collection/components/input/pn-multi-row-connected-dropdown/pn-multi-row-connected-dropdown-row.js +836 -0
  9. package/collection/components/input/pn-multi-row-connected-dropdown/pn-multi-row-connected-dropdown.css +16 -0
  10. package/collection/components/input/pn-multi-row-connected-dropdown/pn-multi-row-connected-dropdown.js +631 -0
  11. package/collection/components/input/pn-multi-row-connected-dropdown/pn-multi-row-connected-dropdown.stories.js +62 -0
  12. package/collection/components/input/pn-multi-row-connected-dropdown/types.js +1 -0
  13. package/components/index.d.ts +2 -0
  14. package/components/index.js +2 -0
  15. package/components/pn-filter-checkbox.js +1 -88
  16. package/components/pn-filter-checkbox2.js +90 -0
  17. package/components/pn-multi-row-connected-dropdown-row.d.ts +11 -0
  18. package/components/pn-multi-row-connected-dropdown-row.js +6 -0
  19. package/components/pn-multi-row-connected-dropdown-row2.js +434 -0
  20. package/components/pn-multi-row-connected-dropdown.d.ts +11 -0
  21. package/components/pn-multi-row-connected-dropdown.js +262 -0
  22. package/esm/index-ee44c065.js +16 -8
  23. package/esm/loader.js +1 -1
  24. package/esm/pn-market-web-components.js +1 -1
  25. package/esm/pn-multi-row-connected-dropdown-row.entry.js +368 -0
  26. package/esm/pn-multi-row-connected-dropdown.entry.js +201 -0
  27. package/esm-es5/index-ee44c065.js +1 -1
  28. package/esm-es5/loader.js +1 -1
  29. package/esm-es5/pn-market-web-components.js +1 -1
  30. package/esm-es5/pn-multi-row-connected-dropdown-row.entry.js +1 -0
  31. package/esm-es5/pn-multi-row-connected-dropdown.entry.js +1 -0
  32. package/package.json +1 -1
  33. package/pn-market-web-components/p-5d2a19e3.entry.js +1 -0
  34. package/pn-market-web-components/p-7e81b501.system.entry.js +1 -0
  35. package/pn-market-web-components/p-83c85053.system.entry.js +1 -0
  36. package/pn-market-web-components/p-b4416838.entry.js +1 -0
  37. package/pn-market-web-components/p-fcdb7381.system.js +1 -1
  38. package/pn-market-web-components/pn-market-web-components.esm.js +1 -1
  39. package/types/components/input/pn-multi-row-connected-dropdown/pn-multi-row-connected-dropdown-row.d.ts +93 -0
  40. package/types/components/input/pn-multi-row-connected-dropdown/pn-multi-row-connected-dropdown.d.ts +45 -0
  41. package/types/components/input/pn-multi-row-connected-dropdown/types.d.ts +32 -0
  42. package/types/components.d.ts +124 -0
@@ -0,0 +1,368 @@
1
+ import { r as registerInstance, c as createEvent, h, a as Host, g as getElement } from './index-ee44c065.js';
2
+ import { d as debounce_1 } from './index-8976f360.js';
3
+ import { v as v4 } from './v4-f450efa7.js';
4
+
5
+ const pnMultiRowConnectedDropdownRowCss = "pn-multi-row-connected-dropdown-row{gap:1rem}pn-multi-row-connected-dropdown-row .connected-dropdown-parent-element{margin-bottom:0.5rem}pn-multi-row-connected-dropdown-row pn-select{width:35%}pn-multi-row-connected-dropdown-row pn-marketweb-input{width:10%}pn-multi-row-connected-dropdown-row pn-marketweb-input input{height:4.3rem}pn-multi-row-connected-dropdown-row .connected-dropdown{padding:1rem;border-left:0.2rem solid #005D92}pn-multi-row-connected-dropdown-row .connected-dropdown:hover{background-color:#F9F8F8}pn-multi-row-connected-dropdown-row .connected-dropdown__toggle-date-button{width:20%;margin-bottom:0.5rem}pn-multi-row-connected-dropdown-row .connected-dropdown__row{display:-ms-flexbox;display:flex;-ms-flex-align:end;align-items:flex-end;gap:1rem;margin-bottom:1rem;-ms-flex-pack:justify;justify-content:space-between}pn-multi-row-connected-dropdown-row .connected-dropdown__row__no-margin{margin:0}pn-multi-row-connected-dropdown-row .connected-dropdown__multi-date-row{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;gap:1rem;margin-bottom:1rem}pn-multi-row-connected-dropdown-row .connected-dropdown__button-container{display:-ms-flexbox;display:flex;-ms-flex-align:end;align-items:flex-end;gap:1rem}pn-multi-row-connected-dropdown-row .connected-dropdown__button{background-color:#ffffff;border:solid;border-width:0.1rem;border-radius:0.8rem;border-color:#005D92;padding:0.4rem 0.8rem;color:#005D92;font-size:1.4rem;text-align:center;text-decoration:none;cursor:pointer}pn-multi-row-connected-dropdown-row .connected-dropdown__button:hover,pn-multi-row-connected-dropdown-row .connected-dropdown__button.active{background-color:#0D234B;border-color:#0D234B;color:#ffffff}pn-multi-row-connected-dropdown-row .connected-dropdown__buttom-container-right{display:-ms-flexbox;display:flex}pn-multi-row-connected-dropdown-row .connected-dropdown__button-right{margin-left:auto}pn-multi-row-connected-dropdown-row .connected-dropdown__label-container{margin-bottom:0.4rem;color:#5E554A;font-size:0.875em;-ms-flex-pack:justify;justify-content:space-between;-ms-flex-align:end;align-items:flex-end}pn-multi-row-connected-dropdown-row .connected-dropdown__checkbox{display:-ms-flexbox;display:flex;gap:0.5rem}pn-multi-row-connected-dropdown-row .connected-dropdown__date-slot{border:0.1rem solid #005D92;margin-bottom:1rem;padding:1rem}pn-multi-row-connected-dropdown-row .generated-date-row{border-bottom:0.1rem solid #005D92}";
6
+
7
+ const PnMultiRowConnectedDropdownRow = class {
8
+ constructor(hostRef) {
9
+ registerInstance(this, hostRef);
10
+ this.rowValueChange = createEvent(this, "rowValueChange", 7);
11
+ this.deleteRowEvent = createEvent(this, "deleteRowEvent", 7);
12
+ this.pnConnectedDropdown = null;
13
+ this.pnConnectedDropdownSlotElement = null;
14
+ this.pnAddFieldButton = null;
15
+ this.pnFirstDropdown = null;
16
+ this.pnSecondDropdown = null;
17
+ this.pnInputField = null;
18
+ this.pnSingleDatePicker = null;
19
+ this.pnStartDate = null;
20
+ this.pnEndDate = null;
21
+ this.pnShowDateRangeFiledButton = null;
22
+ this.pnDateRangeContainer = null;
23
+ this.pnGenerateDatesButton = null;
24
+ this.pnDaysRow = null;
25
+ this.pnGeneratedDatesSlot = null;
26
+ this.pnSaveGeneratedDatesButton = null;
27
+ this.pnDeleteRowButton = null;
28
+ this.dropdownData = null;
29
+ this.languageCode = null;
30
+ this.label = null;
31
+ this.firstDropdownLabel = null;
32
+ this.secondDropdownLabel = null;
33
+ this.dropdownPlaceholder = null;
34
+ this.addRowText = null;
35
+ this.inputFildLabel = null;
36
+ this.inputFildPlaceholder = null;
37
+ this.dateButtonText = null;
38
+ this.datePlaceholder = null;
39
+ this.dateDaysFromToday = 1;
40
+ this.allowMultipleDates = null;
41
+ this.startDateLabel = null;
42
+ this.endDateLabel = null;
43
+ this.multiDateHelperText = null;
44
+ this.generateDatesButtonText = null;
45
+ this.saveDateButtonText = null;
46
+ this.noDatesText = null;
47
+ this.index = null;
48
+ this.predefinedValue = null;
49
+ this.yearsToAddToEndDate = null;
50
+ this.buttonsArray = null;
51
+ this.firstDropdownArr = null;
52
+ this.secondDropdownArr = [];
53
+ this.firstDropdownClass = null;
54
+ this.secondDropdownClass = null;
55
+ this.firstValidDateString = '';
56
+ this.lastValidDateString = '';
57
+ this.firstDropdownPlaceholder = '-';
58
+ this.secondDropdownPlaceholder = '-';
59
+ this.starDateValue = '';
60
+ this.endDateValue = '';
61
+ this.generatedDatesArr = [];
62
+ this.selectedButtonValue = '';
63
+ this.inputFieldValue = '';
64
+ this.dateValue = '';
65
+ this.daysArr = null;
66
+ }
67
+ componentWillLoad() {
68
+ this.getPredefinedValues();
69
+ this.setDropDownData();
70
+ this.setFirstValidDate();
71
+ }
72
+ componentDidLoad() {
73
+ this.setInitialValues();
74
+ this.addEventHandlers();
75
+ this.emittRowValues();
76
+ }
77
+ setDropDownData() {
78
+ if (typeof this.dropdownData === 'string') {
79
+ this._dropdownData = JSON.parse(this.dropdownData);
80
+ }
81
+ else {
82
+ this._dropdownData = this.dropdownData;
83
+ }
84
+ }
85
+ getPredefinedValues() {
86
+ this._predefinedValue = JSON.parse(this.predefinedValue);
87
+ }
88
+ applyPredefinedValue() {
89
+ this.getPredefinedValues();
90
+ this.setInitialValues();
91
+ }
92
+ setInitialValues() {
93
+ this.setButtonsValue();
94
+ this.setFirstDropdownValues();
95
+ this.setSecondDropdownValues();
96
+ this.setInputField();
97
+ this.setDateValue();
98
+ this.setDateRangeDefaults();
99
+ this.firstDropdownClass = this.firstDropdownLabel.replace(' ', '_') + '-dropdown';
100
+ this.secondDropdownClass = this.secondDropdownLabel.replace(' ', '_') + '-dropdown';
101
+ }
102
+ setButtonsValue() {
103
+ var _a;
104
+ this.buttonsArray = [];
105
+ if ((_a = this._predefinedValue.buttons) === null || _a === void 0 ? void 0 : _a.length) {
106
+ this.buttonsArray = this._predefinedValue.buttons;
107
+ this.buttonsArray.forEach(item => {
108
+ if (item.selected) {
109
+ this.selectedButtonValue = item.value;
110
+ }
111
+ });
112
+ }
113
+ else {
114
+ this._dropdownData.forEach(item => {
115
+ const button = { selected: false, value: item.caption, caption: item.caption };
116
+ this.buttonsArray.push(button);
117
+ });
118
+ }
119
+ }
120
+ setFirstDropdownValues() {
121
+ var _a;
122
+ this.firstDropdownArr = [];
123
+ if ((_a = this._predefinedValue.firstDropdown) === null || _a === void 0 ? void 0 : _a.length) {
124
+ this.firstDropdownArr = [...this._predefinedValue.firstDropdown];
125
+ }
126
+ }
127
+ setSecondDropdownValues() {
128
+ var _a;
129
+ this.secondDropdownArr = [];
130
+ if ((_a = this._predefinedValue.secondDropdown) === null || _a === void 0 ? void 0 : _a.length) {
131
+ this.secondDropdownArr = [...this._predefinedValue.secondDropdown];
132
+ }
133
+ }
134
+ setInputField() {
135
+ var _a;
136
+ this.inputFieldValue = ((_a = this._predefinedValue.input) === null || _a === void 0 ? void 0 : _a.length) ? this._predefinedValue.input : '';
137
+ }
138
+ setDateValue() {
139
+ var _a, _b, _c;
140
+ if (this.allowMultipleDates) {
141
+ this.pnDateRangeContainer.style.display = ((_a = this._predefinedValue.dates) === null || _a === void 0 ? void 0 : _a.length) ? '' : 'none';
142
+ this.generatedDatesArr = ((_b = this._predefinedValue.dates) === null || _b === void 0 ? void 0 : _b.length) ? this._predefinedValue.dates.split(',') : [];
143
+ this.saveGeneratedDates();
144
+ }
145
+ else {
146
+ this.dateValue = ((_c = this._predefinedValue.dates) === null || _c === void 0 ? void 0 : _c.length) ? this._predefinedValue.dates : '';
147
+ }
148
+ }
149
+ setDateRangeDefaults() {
150
+ var _a, _b;
151
+ this.daysArr = this._predefinedValue.dateRange.days;
152
+ this.starDateValue = ((_a = this._predefinedValue.dateRange.startDate) === null || _a === void 0 ? void 0 : _a.length) ? this._predefinedValue.dateRange.startDate : '';
153
+ this.endDateValue = ((_b = this._predefinedValue.dateRange.endDate) === null || _b === void 0 ? void 0 : _b.length) ? this._predefinedValue.dateRange.endDate : '';
154
+ }
155
+ setFirstValidDate() {
156
+ var _a;
157
+ const yearsToadd = this.yearsToAddToEndDate ? this.yearsToAddToEndDate : 2;
158
+ const date = new Date();
159
+ date.setDate((_a = date.getDate() + this.dateDaysFromToday) !== null && _a !== void 0 ? _a : 0);
160
+ const year = date.getFullYear();
161
+ const month = (date.getMonth() + 1).toString().padStart(2, '0');
162
+ const day = date.getDate().toString().padStart(2, '0');
163
+ const endYear = year + yearsToadd;
164
+ this.firstValidDateString = `${year.toString()}-${month}-${day}`;
165
+ this.lastValidDateString = `${endYear.toString()}-${month}-${day}`;
166
+ }
167
+ addEventHandlers() {
168
+ const emmitValues = debounce_1.debounce(this.emittRowValues.bind(this), 500);
169
+ this.pnInputField.addEventListener('keyup', this.handleInput.bind(this));
170
+ this.pnInputField.addEventListener('change', this.handleInput.bind(this));
171
+ this.pnInputField.addEventListener('keyup', emmitValues);
172
+ this.pnInputField.addEventListener('change', emmitValues);
173
+ if (this.allowMultipleDates) {
174
+ this.pnShowDateRangeFiledButton.addEventListener('click', this.showDateRangeRow.bind(this));
175
+ this.pnStartDate.addEventListener('dateselection', this.HandleRangeDatePickers.bind(this));
176
+ this.pnEndDate.addEventListener('dateselection', this.HandleRangeDatePickers.bind(this));
177
+ this.pnGenerateDatesButton.addEventListener('click', this.generateDates.bind(this));
178
+ this.pnSaveGeneratedDatesButton.addEventListener('click', this.saveGeneratedDates.bind(this));
179
+ this.pnSaveGeneratedDatesButton.addEventListener('click', emmitValues);
180
+ }
181
+ else {
182
+ this.pnSingleDatePicker.addEventListener('dateselection', this.setSingleDateValue.bind(this));
183
+ this.pnSingleDatePicker.addEventListener('dateselection', emmitValues);
184
+ }
185
+ if (this.index > 0) {
186
+ this.pnDeleteRowButton.addEventListener('click', this.deleteRow.bind(this));
187
+ }
188
+ }
189
+ generateUniqueId() {
190
+ return v4();
191
+ }
192
+ updateSelectItemArr(arr, val) {
193
+ arr.forEach(item => {
194
+ if (item.value === val) {
195
+ item.selected = !item.selected;
196
+ }
197
+ else {
198
+ item.selected = false;
199
+ }
200
+ });
201
+ return arr;
202
+ }
203
+ handleOptionButtonClick(e) {
204
+ var _a;
205
+ e.preventDefault();
206
+ const elmValue = e.target.innerHTML;
207
+ this.buttonsArray = [...this.updateSelectItemArr(this.buttonsArray, elmValue)];
208
+ this.selectedButtonValue = this.buttonsArray.filter(e => e.selected === true).length > 0 ? elmValue : '';
209
+ if ((_a = this.selectedButtonValue) === null || _a === void 0 ? void 0 : _a.length) {
210
+ this.firstDropdownArr = [];
211
+ const selectionChildren = this._dropdownData.find(arr => arr.caption === elmValue);
212
+ selectionChildren.values.forEach(item => {
213
+ this.firstDropdownArr.push({ selected: false, value: item.caption, caption: item.caption });
214
+ });
215
+ this.firstDropdownArr = [...this.firstDropdownArr];
216
+ this.firstDropdownPlaceholder = this.dropdownPlaceholder;
217
+ const firstDropdownText = this.pnFirstDropdown.querySelector('.current-selection .pn-option-content');
218
+ firstDropdownText.innerHTML = this.dropdownPlaceholder;
219
+ this.secondDropdownArr = [];
220
+ this.secondDropdownPlaceholder = '-';
221
+ const secondDropdownText = this.pnSecondDropdown.querySelector('.current-selection .pn-option-content');
222
+ secondDropdownText.innerHTML = this.secondDropdownPlaceholder;
223
+ }
224
+ else {
225
+ this.firstDropdownArr = [];
226
+ this.firstDropdownPlaceholder = '-';
227
+ const firstDropdownText = this.pnFirstDropdown.querySelector('.current-selection .pn-option-content');
228
+ firstDropdownText.innerHTML = this.firstDropdownPlaceholder;
229
+ this.secondDropdownArr = [];
230
+ this.secondDropdownPlaceholder = '-';
231
+ const secondDropdownText = this.pnSecondDropdown.querySelector('.current-selection .pn-option-content');
232
+ secondDropdownText.innerHTML = this.secondDropdownPlaceholder;
233
+ }
234
+ this.emittRowValues();
235
+ }
236
+ handleFirstDropdownChange() {
237
+ const selected = this.pnFirstDropdown.querySelector('.current-selection .pn-option-content');
238
+ const selectedValue = selected === null || selected === void 0 ? void 0 : selected.textContent;
239
+ this.firstDropdownArr = [...this.updateSelectItemArr(this.firstDropdownArr, selectedValue)];
240
+ this.secondDropdownArr = [];
241
+ const selectedButton = this.buttonsArray.findIndex(item => item.selected === true);
242
+ const firstChildren = this._dropdownData.find(arr => arr.caption === this.buttonsArray[selectedButton].value);
243
+ const secondChildren = firstChildren.values.find(arr => arr.caption === selectedValue);
244
+ secondChildren.values.forEach(item => {
245
+ this.secondDropdownArr.push({ selected: false, value: item.caption, caption: item.caption });
246
+ });
247
+ this.secondDropdownPlaceholder = this.dropdownPlaceholder;
248
+ const secondDropdownText = this.pnSecondDropdown.querySelector('.current-selection .pn-option-content');
249
+ secondDropdownText.innerHTML = this.secondDropdownPlaceholder;
250
+ this.emittRowValues();
251
+ }
252
+ handleSecondDropdownChange() {
253
+ const selected = this.pnSecondDropdown.querySelector('.current-selection .pn-option-content');
254
+ const selectedValue = selected === null || selected === void 0 ? void 0 : selected.textContent;
255
+ this.secondDropdownArr = [...this.updateSelectItemArr(this.secondDropdownArr, selectedValue)];
256
+ this.emittRowValues();
257
+ }
258
+ handleInput(e) {
259
+ const elm = e.target;
260
+ if (elm.value !== '0') {
261
+ this.inputFieldValue = elm.value;
262
+ }
263
+ }
264
+ showDateRangeRow() {
265
+ if (this.pnDateRangeContainer.style.display === 'none') {
266
+ this.pnDateRangeContainer.style.display = '';
267
+ }
268
+ else {
269
+ this.pnDateRangeContainer.style.display = 'none';
270
+ }
271
+ }
272
+ HandleRangeDatePickers(e) {
273
+ const elm = e.target;
274
+ if (elm === this.pnStartDate) {
275
+ this.starDateValue = e.detail;
276
+ }
277
+ if (elm === this.pnEndDate) {
278
+ this.endDateValue = e.detail;
279
+ }
280
+ }
281
+ generateDates(e) {
282
+ var _a;
283
+ e.preventDefault();
284
+ const allCheckboxes = this.pnDaysRow.querySelectorAll('pn-filter-checkbox');
285
+ const selectedDays = [];
286
+ this.generatedDatesArr = [];
287
+ allCheckboxes.forEach(element => {
288
+ const input = element.querySelector('input');
289
+ if (input.value) {
290
+ selectedDays.push(input.value);
291
+ }
292
+ });
293
+ if (selectedDays.length && this.starDateValue && this.endDateValue) {
294
+ this.daysArr.forEach(item => {
295
+ if (selectedDays.some(x => x === item.value)) {
296
+ item.selected = true;
297
+ }
298
+ else {
299
+ item.selected = false;
300
+ }
301
+ });
302
+ const startDate = new Date(Date.parse(this.starDateValue));
303
+ const endDate = new Date(Date.parse(this.endDateValue));
304
+ for (var d = startDate; d <= endDate; d.setDate(d.getDate() + 1)) {
305
+ const i = this.daysArr.findIndex(item => parseInt(item.value) === d.getDay());
306
+ if ((_a = this.daysArr[i]) === null || _a === void 0 ? void 0 : _a.selected) {
307
+ const year = d.getFullYear();
308
+ const month = (d.getMonth() + 1).toString().padStart(2, '0');
309
+ const day = d.getDate().toString().padStart(2, '0');
310
+ this.generatedDatesArr.push(`${year}-${month}-${day}`);
311
+ }
312
+ }
313
+ }
314
+ }
315
+ deleteGeneratedDateRow(index) {
316
+ this.generatedDatesArr.splice(index, 1);
317
+ this.generatedDatesArr = [...this.generatedDatesArr];
318
+ }
319
+ saveGeneratedDates() {
320
+ var _a;
321
+ if ((_a = this.generatedDatesArr) === null || _a === void 0 ? void 0 : _a.length) {
322
+ this.dateValue = String(this.generatedDatesArr);
323
+ const dateCount = this.generatedDatesArr.length;
324
+ const buttonTextElm = this.pnShowDateRangeFiledButton.querySelector('.pn-button-content');
325
+ buttonTextElm.innerHTML = dateCount > 0 ? `${this.dateButtonText} (${dateCount})` : this.dateButtonText;
326
+ this.showDateRangeRow();
327
+ }
328
+ }
329
+ setSingleDateValue(e) {
330
+ const elm = e.target;
331
+ if (elm === this.pnSingleDatePicker) {
332
+ this.dateValue = e.detail;
333
+ }
334
+ }
335
+ emittRowValues() {
336
+ this.rowValueChange.emit({
337
+ id: this._predefinedValue.id,
338
+ buttons: this.buttonsArray,
339
+ firstDropdown: this.firstDropdownArr,
340
+ secondDropdown: this.secondDropdownArr,
341
+ input: this.inputFieldValue,
342
+ dates: this.dateValue,
343
+ dateRange: {
344
+ days: this.daysArr,
345
+ startDate: this.starDateValue,
346
+ endDate: this.endDateValue,
347
+ },
348
+ });
349
+ }
350
+ deleteRow() {
351
+ this.deleteRowEvent.emit(this._predefinedValue.id);
352
+ }
353
+ setActive(active) {
354
+ return active ? 'connected-dropdown__button active' : 'connected-dropdown__button';
355
+ }
356
+ render() {
357
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
358
+ return (h(Host, null, h("div", { ref: el => (this.pnConnectedDropdownSlotElement = el), class: "connected-dropdown-slot-element" }, h("div", { class: "connected-dropdown-parent-element connected-dropdown" }, h("div", { class: "connected-dropdown__row__no-margin" }, h("label", null, this.label)), h("div", { class: "connected-dropdown__row button-row" }, h("div", { class: "connected-dropdown__button-container option-buttons" }, (_a = this.buttonsArray) === null || _a === void 0 ? void 0 : _a.map(item => (h("button", { class: `${this.setActive(item.selected)}`, id: this.generateUniqueId(), onClick: this.handleOptionButtonClick.bind(this) }, item.value)))), h("div", { class: "connected-dropdown__button-container delete-button" }, this.index > 0 ? (h("pn-button", { ref: el => (this.pnDeleteRowButton = el), small: "true", "icon-only": "true", icon: "minus", appearance: "warning", index: this.index }, "Delete")) : null)), h("div", { class: "connected-dropdown__row input-row" }, h("pn-select", { ref: el => (this.pnFirstDropdown = el), class: "pn-row-select-dropdown dropDown1-dropdown", placeholder: this.firstDropdownPlaceholder, label: this.firstDropdownLabel }, (_b = this.firstDropdownArr) === null || _b === void 0 ? void 0 : _b.map((item, i) => (h("pn-option", { index: i, value: item.value, selected: item.selected, onClick: debounce_1.debounce(this.handleFirstDropdownChange.bind(this), 500) }, item.value)))), h("pn-select", { ref: el => (this.pnSecondDropdown = el), class: "pn-row-select-dropdown dropDown2-dropdown", placeholder: this.secondDropdownPlaceholder, label: this.secondDropdownLabel }, (_c = this.secondDropdownArr) === null || _c === void 0 ? void 0 : _c.map((item, i) => (h("pn-option", { index: i, value: item.value, selected: item.selected, onClick: debounce_1.debounce(this.handleSecondDropdownChange.bind(this), 500) }, item.value)))), h("pn-marketweb-input", { ref: el => (this.pnInputField = el), type: "number", placeholder: "0", label: this.inputFildLabel, value: this.inputFieldValue, min: "1" }), this.allowMultipleDates ? (h("pn-button", { ref: el => (this.pnShowDateRangeFiledButton = el), class: "connected-dropdown__toggle-date-button", small: "true", appearance: "light" }, this.dateButtonText)) : (h("div", { class: "connected-dropdown__date-container" }, h("div", { class: "connected-dropdown__label-container" }, h("label", null, this.dateButtonText)), h("pn-date-picker", { ref: el => (this.pnSingleDatePicker = el), range: "false", "disable-weekends": true, "min-date": this.firstValidDateString, language: this.languageCode, placeholder: this.datePlaceholder, class: "connected-dropdown__date-picker", start: ((_d = this.dateValue) === null || _d === void 0 ? void 0 : _d.length) ? this.dateValue : null })))), this.allowMultipleDates ? (h("div", { ref: el => (this.pnDateRangeContainer = el), class: "connected-dropdown__date-container", style: { display: 'none' } }, this.multiDateHelperText ? (h("div", { class: "connected-dropdown__row" }, h("p", null, this.multiDateHelperText))) : null, h("div", { class: "connected-dropdown__multi-date-row" }, h("div", { class: "connected-dropdown__date-container" }, h("div", { class: "connected-dropdown__label-container" }, h("label", null, this.startDateLabel)), h("pn-date-picker", { ref: el => (this.pnStartDate = el), range: "false", "disable-weekends": true, class: "connected-dropdown__date-picker", "min-date": this.firstValidDateString, "max-date": this.lastValidDateString, language: this.languageCode, placeholder: this.datePlaceholder, start: ((_e = this.starDateValue) === null || _e === void 0 ? void 0 : _e.length) ? this.starDateValue : null })), h("div", { class: "connected-dropdown__date-container" }, h("div", { class: "connected-dropdown__label-container" }, h("label", null, this.endDateLabel)), h("pn-date-picker", { ref: el => (this.pnEndDate = el), range: "false", "disable-weekends": true, class: "connected-dropdown__date-picker", "min-date": this.firstValidDateString, "max-date": this.lastValidDateString, language: this.languageCode, placeholder: this.datePlaceholder, start: ((_f = this.endDateValue) === null || _f === void 0 ? void 0 : _f.length) ? this.endDateValue : null }))), h("div", { ref: el => (this.pnDaysRow = el), class: "connected-dropdown__multi-date-row" }, (_g = this.daysArr) === null || _g === void 0 ? void 0 : _g.map((day) => (h("div", { class: "connected-dropdown__checkbox" }, h("pn-filter-checkbox", { checkboxid: 'day-' + day.value, name: '__' + day.caption, value: day.value, checked: day.selected }), h("label", { htmlFor: 'day-' + day.value }, day.caption))))), h("div", { class: "connected-dropdown__row" }, h("pn-button", { ref: el => (this.pnGenerateDatesButton = el), small: "true" }, this.generateDatesButtonText)), h("div", { ref: el => (this.pnGeneratedDatesSlot = el), class: "connected-dropdown__date-slot" }, (_h = this.generatedDatesArr) === null || _h === void 0 ? void 0 :
359
+ _h.map((date, i) => (h("div", { class: "connected-dropdown__row generated-date-row" }, h("p", null, date), h("pn-button", { index: i, small: "true", "icon-only": "true", icon: "minus", appearance: "warning", id: 'delete-date-' + i, onClick: this.deleteGeneratedDateRow.bind(this, i) }, date)))), !((_j = this.generatedDatesArr) === null || _j === void 0 ? void 0 : _j.length) ? h("p", null, this.noDatesText) : null), h("div", { class: "connected-dropdown__row" }, h("pn-button", { ref: el => (this.pnSaveGeneratedDatesButton = el), class: "connected-dropdown__button-right", small: "true" }, this.saveDateButtonText)))) : null))));
360
+ }
361
+ get hostElement() { return getElement(this); }
362
+ static get watchers() { return {
363
+ "predefinedValue": ["applyPredefinedValue"]
364
+ }; }
365
+ };
366
+ PnMultiRowConnectedDropdownRow.style = pnMultiRowConnectedDropdownRowCss;
367
+
368
+ export { PnMultiRowConnectedDropdownRow as pn_multi_row_connected_dropdown_row };
@@ -0,0 +1,201 @@
1
+ import { r as registerInstance, c as createEvent, h, a as Host, g as getElement } from './index-ee44c065.js';
2
+ import { v as v4 } from './v4-f450efa7.js';
3
+
4
+ const pnMultiRowConnectedDropdownCss = "pn-multi-row-connected-dropdown{gap:1rem}pn-multi-row-connected-dropdown .connected-dropdown__row{display:-ms-flexbox;display:flex;-ms-flex-align:end;align-items:flex-end;gap:1rem;margin-bottom:1rem;-ms-flex-pack:justify;justify-content:space-between}pn-multi-row-connected-dropdown .connected-dropdown__row__no-margin{margin:0}pn-multi-row-connected-dropdown .connected-dropdown__button-right{margin-left:auto}";
5
+
6
+ const PnMultiRowConnectedDropdown = class {
7
+ constructor(hostRef) {
8
+ registerInstance(this, hostRef);
9
+ this.allFormValues = createEvent(this, "allFormValues", 7);
10
+ this._buttonValueName = null;
11
+ this._firstDropdownValueName = null;
12
+ this._secondDropdownValueName = null;
13
+ this._inputValueName = null;
14
+ this._dateValueName = null;
15
+ this._defaultRow = {
16
+ id: this.generateUniqueId(),
17
+ buttons: [],
18
+ firstDropdown: [],
19
+ secondDropdown: [],
20
+ input: '',
21
+ dates: '',
22
+ dateRange: {
23
+ days: [],
24
+ startDate: '',
25
+ endDate: '',
26
+ },
27
+ };
28
+ this.dropdownData = null;
29
+ this.languageCode = null;
30
+ this.label = null;
31
+ this.firstDropdownLabel = null;
32
+ this.secondDropdownLabel = null;
33
+ this.dropdownPlaceholder = null;
34
+ this.addRowText = null;
35
+ this.inputFildLabel = null;
36
+ this.inputFildPlaceholder = null;
37
+ this.dateButtonText = null;
38
+ this.datePlaceholder = null;
39
+ this.dateDaysFromToday = null;
40
+ this.allowMultipleRows = false;
41
+ this.allowMultipleDates = false;
42
+ this.startDateLabel = null;
43
+ this.endDateLabel = null;
44
+ this.multiDateHelperText = null;
45
+ this.generateDatesButtonText = null;
46
+ this.saveDateButtonText = null;
47
+ this.noDatesText = null;
48
+ this.yearsToAddToEndDate = null;
49
+ this.rowCount = null;
50
+ this.rowData = null;
51
+ this.formValues = null;
52
+ }
53
+ componentWillLoad() {
54
+ var _a, _b, _c, _d, _e;
55
+ this.setDaysArr();
56
+ this.formValues = [];
57
+ this.rowData = [this._defaultRow];
58
+ this.rowCount = this.rowData.length;
59
+ this._buttonValueName = ((_a = this.label) === null || _a === void 0 ? void 0 : _a.length) ? this.label : 'value0';
60
+ this._firstDropdownValueName = ((_b = this.firstDropdownLabel) === null || _b === void 0 ? void 0 : _b.length) ? this.firstDropdownLabel : 'value1';
61
+ this._secondDropdownValueName = ((_c = this.secondDropdownLabel) === null || _c === void 0 ? void 0 : _c.length) ? this.secondDropdownLabel : 'value2';
62
+ this._inputValueName = ((_d = this.inputFildLabel) === null || _d === void 0 ? void 0 : _d.length) ? this.inputFildLabel : 'value3';
63
+ this._dateValueName = ((_e = this.dateButtonText) === null || _e === void 0 ? void 0 : _e.length) ? this.dateButtonText : 'value4';
64
+ }
65
+ componentDidLoad() { }
66
+ emittValuesIfValid() {
67
+ this.formValues = [];
68
+ this.rowData.forEach(item => {
69
+ const rowValue = { row: [] };
70
+ const buttonSelection = item.buttons.find(x => x.selected === true);
71
+ if (buttonSelection) {
72
+ const buttonValue = { name: this._buttonValueName, value: buttonSelection.caption };
73
+ rowValue.row.push(buttonValue);
74
+ }
75
+ const firstDropdownSelection = item.firstDropdown.find(x => x.selected === true);
76
+ if (firstDropdownSelection) {
77
+ const firstDropdownValue = { name: this._firstDropdownValueName, value: firstDropdownSelection.caption };
78
+ rowValue.row.push(firstDropdownValue);
79
+ }
80
+ const secondDropdownSelection = item.secondDropdown.find(x => x.selected === true);
81
+ if (secondDropdownSelection) {
82
+ const secondDropdownValue = { name: this._secondDropdownValueName, value: secondDropdownSelection.caption };
83
+ rowValue.row.push(secondDropdownValue);
84
+ }
85
+ const input = item.input;
86
+ if (input === null || input === void 0 ? void 0 : input.length) {
87
+ const inputValue = { name: this._inputValueName, value: input };
88
+ rowValue.row.push(inputValue);
89
+ }
90
+ const dates = item.dates;
91
+ if (dates === null || dates === void 0 ? void 0 : dates.length) {
92
+ const datestValue = { name: this._dateValueName, value: dates };
93
+ rowValue.row.push(datestValue);
94
+ }
95
+ if (rowValue.row.length === 5) {
96
+ this.formValues.push(rowValue);
97
+ }
98
+ });
99
+ if (this.formValues.length === this.rowData.length) {
100
+ const valueJsonString = JSON.stringify(this.formValues);
101
+ this.allFormValues.emit(valueJsonString);
102
+ }
103
+ else {
104
+ this.allFormValues.emit('');
105
+ }
106
+ }
107
+ predefinedValueChange(e) {
108
+ const indexToUpdate = this.rowData.findIndex(data => data.id === e.detail.id);
109
+ const val = e.detail;
110
+ this.rowData[indexToUpdate] = Object.assign(Object.assign({}, this.rowData[indexToUpdate]), { buttons: val.buttons, firstDropdown: val.firstDropdown, secondDropdown: val.secondDropdown, input: val.input, dates: val.dates, dateRange: val.dateRange });
111
+ this.emittValuesIfValid();
112
+ }
113
+ deleteRowEvent(e) {
114
+ const indexToRemove = this.rowData.findIndex(data => data.id === e.detail);
115
+ this.rowData.splice(indexToRemove, 1);
116
+ this.rowData = [...this.rowData];
117
+ this.rowCount = this.rowData.length;
118
+ this.emittValuesIfValid();
119
+ }
120
+ generateUniqueId() {
121
+ return v4();
122
+ }
123
+ addRow() {
124
+ const newRow = this._defaultRow;
125
+ newRow.id = this.generateUniqueId();
126
+ this.rowData = [...this.rowData, newRow];
127
+ this.rowCount = this.rowData.length;
128
+ }
129
+ setDaysArr() {
130
+ const language = this.languageCode.toLowerCase();
131
+ switch (language) {
132
+ case 'en':
133
+ this._defaultRow.dateRange.days = [
134
+ { caption: 'Monday', value: '1', selected: false },
135
+ { caption: 'Tuesday', value: '2', selected: false },
136
+ { caption: 'Wednesday', value: '3', selected: false },
137
+ { caption: 'Thursday', value: '4', selected: false },
138
+ { caption: 'Friday', value: '5', selected: false },
139
+ ];
140
+ break;
141
+ case 'sv':
142
+ this._defaultRow.dateRange.days = [
143
+ { caption: 'Måndag', value: '1', selected: false },
144
+ { caption: 'Tisdag', value: '2', selected: false },
145
+ { caption: 'Onsdag', value: '3', selected: false },
146
+ { caption: 'Torsdag', value: '4', selected: false },
147
+ { caption: 'Fredag', value: '5', selected: false },
148
+ ];
149
+ break;
150
+ case 'da':
151
+ this._defaultRow.dateRange.days = [
152
+ { caption: 'Mandag', value: '1', selected: false },
153
+ { caption: 'Tirsdag', value: '2', selected: false },
154
+ { caption: 'Onsdag', value: '3', selected: false },
155
+ { caption: 'Torsdag', value: '4', selected: false },
156
+ { caption: 'Fredag', value: '5', selected: false },
157
+ ];
158
+ break;
159
+ case 'fi':
160
+ this._defaultRow.dateRange.days = [
161
+ { caption: 'Maanantai', value: '1', selected: false },
162
+ { caption: 'Tiistai', value: '2', selected: false },
163
+ { caption: 'Keskiviikko', value: '3', selected: false },
164
+ { caption: 'Torstai', value: '4', selected: false },
165
+ { caption: 'Perjantai', value: '5', selected: false },
166
+ ];
167
+ break;
168
+ case 'no':
169
+ this._defaultRow.dateRange.days = [
170
+ { caption: 'Mandag', value: '1', selected: false },
171
+ { caption: 'Tirsdag', value: '2', selected: false },
172
+ { caption: 'Onsdag', value: '3', selected: false },
173
+ { caption: 'Torsdag', value: '4', selected: false },
174
+ { caption: 'Fredag', value: '5', selected: false },
175
+ ];
176
+ break;
177
+ default:
178
+ this._defaultRow.dateRange.days = [
179
+ { caption: 'Monday', value: '1', selected: false },
180
+ { caption: 'Tuesday', value: '2', selected: false },
181
+ { caption: 'Wednesday', value: '3', selected: false },
182
+ { caption: 'Thursday', value: '4', selected: false },
183
+ { caption: 'Friday', value: '5', selected: false },
184
+ ];
185
+ break;
186
+ }
187
+ }
188
+ render() {
189
+ var _a;
190
+ return (h(Host, null, (_a = this.rowData) === null || _a === void 0 ? void 0 :
191
+ _a.map((data, i) => {
192
+ return (h("div", { class: 'generated-row-' + i, id: 'generated-row-connected-dropdown-' + i }, h("pn-multi-row-connected-dropdown-row", { "dropdown-data": this.dropdownData, "language-code": this.languageCode, label: this.label, "first-dropdown-label": this.firstDropdownLabel, "second-dropdown-label": this.secondDropdownLabel, "dropdown-placeholder": this.dropdownPlaceholder, "add-row-text": this.addRowText, "input-fild-label": this.inputFildLabel, "input-fild-placeholder": this.inputFildPlaceholder, "date-button-text": this.dateButtonText, "date-placeholder": this.datePlaceholder, "date-days-from-today": 1, "allow-multiple-dates": this.allowMultipleDates, "start-date-label": this.startDateLabel, "end-date-label": this.endDateLabel, "multi-date-helper-text": this.multiDateHelperText, "generate-dates-button-text": this.generateDatesButtonText, "save-date-button-text": this.saveDateButtonText, "no-dates-text": this.noDatesText, index: i, "predefined-value": JSON.stringify(data), "years-to-add-to-end-date": this.yearsToAddToEndDate })));
193
+ }), this.allowMultipleRows ? (h("div", { class: "connected-dropdown__row" }, 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: () => {
194
+ this.addRow();
195
+ } }, this.addRowText))) : null));
196
+ }
197
+ get hostElement() { return getElement(this); }
198
+ };
199
+ PnMultiRowConnectedDropdown.style = pnMultiRowConnectedDropdownCss;
200
+
201
+ export { PnMultiRowConnectedDropdown as pn_multi_row_connected_dropdown };