@gov-design-system-ce/components 4.0.7 → 4.0.8-rc01

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 (167) hide show
  1. package/dist/cjs/array.utils-5a024b3a.js +46 -0
  2. package/dist/cjs/array.utils-5a024b3a.js.map +1 -0
  3. package/dist/cjs/core.cjs.js +1 -1
  4. package/dist/cjs/{form-74063d50.js → form-47b5ef29.js} +2 -2
  5. package/dist/cjs/form-47b5ef29.js.map +1 -0
  6. package/dist/cjs/gov-form-checkbox.cjs.entry.js +1 -1
  7. package/dist/cjs/gov-form-control.cjs.entry.js +1 -1
  8. package/dist/cjs/gov-form-file.cjs.entry.js +1 -1
  9. package/dist/cjs/gov-form-input.cjs.entry.js +1 -1
  10. package/dist/cjs/gov-form-multi-select.cjs.entry.js +82 -101
  11. package/dist/cjs/gov-form-multi-select.cjs.entry.js.map +1 -1
  12. package/dist/cjs/gov-form-radio.cjs.entry.js +1 -1
  13. package/dist/cjs/gov-form-select.cjs.entry.js +14 -18
  14. package/dist/cjs/gov-form-select.cjs.entry.js.map +1 -1
  15. package/dist/cjs/gov-form-switch.cjs.entry.js +1 -1
  16. package/dist/cjs/gov-icon.cjs.entry.js +1 -1
  17. package/dist/cjs/gov-pagination.cjs.entry.js +2 -8
  18. package/dist/cjs/gov-pagination.cjs.entry.js.map +1 -1
  19. package/dist/cjs/loader.cjs.js +1 -1
  20. package/dist/cjs/stencil.utils-22814956.js +11 -0
  21. package/dist/cjs/stencil.utils-22814956.js.map +1 -0
  22. package/dist/collection/components/gov-form/multiselect/gov-form-multi-select.js +134 -253
  23. package/dist/collection/components/gov-form/multiselect/gov-form-multi-select.js.map +1 -1
  24. package/dist/collection/components/gov-form/multiselect/gov-form-multi-select.types.js.map +1 -1
  25. package/dist/collection/components/gov-form/select/constants.js +1 -1
  26. package/dist/collection/components/gov-form/select/constants.js.map +1 -1
  27. package/dist/collection/components/gov-form/select/gov-form-select.js +40 -64
  28. package/dist/collection/components/gov-form/select/gov-form-select.js.map +1 -1
  29. package/dist/collection/components/gov-form/select/gov-form-select.types.js.map +1 -1
  30. package/dist/collection/components/gov-pagination/gov-pagination.js +1 -1
  31. package/dist/collection/components/gov-pagination/gov-pagination.js.map +1 -1
  32. package/dist/collection/pages/Forms.js +8 -7
  33. package/dist/collection/pages/Forms.js.map +1 -1
  34. package/dist/collection/utils/array.utils.js +14 -0
  35. package/dist/collection/utils/array.utils.js.map +1 -1
  36. package/dist/collection/utils/object.utils.js +18 -0
  37. package/dist/collection/utils/object.utils.js.map +1 -0
  38. package/dist/collection/utils/stencil.utils.js +6 -0
  39. package/dist/collection/utils/stencil.utils.js.map +1 -0
  40. package/dist/components/gov-accordion-item.js +1 -1
  41. package/dist/components/gov-attachments-item.js +1 -1
  42. package/dist/components/gov-breadcrumbs.js +1 -1
  43. package/dist/components/gov-button.js +1 -1
  44. package/dist/components/gov-card.js +1 -1
  45. package/dist/components/gov-chip.js +1 -1
  46. package/dist/components/gov-form-autocomplete.js +1 -1
  47. package/dist/components/gov-form-checkbox.js +1 -1
  48. package/dist/components/gov-form-control.js +1 -1
  49. package/dist/components/gov-form-file.js +1 -1
  50. package/dist/components/gov-form-input.js +1 -1
  51. package/dist/components/gov-form-multi-select.js +1 -1
  52. package/dist/components/gov-form-multi-select.js.map +1 -1
  53. package/dist/components/gov-form-radio.js +1 -1
  54. package/dist/components/gov-form-select.js +1 -1
  55. package/dist/components/gov-form-switch.js +1 -1
  56. package/dist/components/gov-icon.js +1 -1
  57. package/dist/components/gov-infobar.js +1 -1
  58. package/dist/components/gov-loading.js +1 -1
  59. package/dist/components/gov-modal.js +1 -1
  60. package/dist/components/gov-pagination.js +1 -1
  61. package/dist/components/gov-pagination.js.map +1 -1
  62. package/dist/components/gov-prompt.js +1 -1
  63. package/dist/components/gov-side-nav-item.js +1 -1
  64. package/dist/components/gov-tabs.js +1 -1
  65. package/dist/components/gov-tag.js +1 -1
  66. package/dist/components/gov-toast.js +1 -1
  67. package/dist/components/gov-tooltip-content.js +1 -1
  68. package/dist/components/gov-wizard-item.js +1 -1
  69. package/dist/components/{p-44762d17.js → p-23990b41.js} +2 -2
  70. package/dist/components/{p-5dbe0178.js → p-26805569.js} +2 -2
  71. package/dist/components/p-2dee9951.js.map +1 -1
  72. package/dist/components/p-6c1d0f47.js +2 -0
  73. package/dist/components/p-6c1d0f47.js.map +1 -0
  74. package/dist/components/{p-99860f34.js → p-a6a15eb1.js} +2 -2
  75. package/dist/components/p-b48d3aae.js +2 -0
  76. package/dist/components/p-b48d3aae.js.map +1 -0
  77. package/dist/components/{p-976404a5.js → p-b5a06a0a.js} +2 -2
  78. package/dist/components/p-c9baa62f.js +2 -0
  79. package/dist/components/p-c9baa62f.js.map +1 -0
  80. package/dist/components/{p-76b229e3.js → p-e2bee1ef.js} +2 -2
  81. package/dist/components/p-f9f8e529.js +2 -0
  82. package/dist/components/{p-8b7b916a.js.map → p-f9f8e529.js.map} +1 -1
  83. package/dist/core/core.esm.js +1 -1
  84. package/dist/core/core.esm.js.map +1 -1
  85. package/dist/core/{p-148501cc.entry.js → p-191e9b0c.entry.js} +2 -2
  86. package/dist/core/{p-9402e4cc.entry.js → p-2a13c39c.entry.js} +2 -2
  87. package/dist/core/p-4b4a270d.entry.js +2 -0
  88. package/dist/core/p-4b4a270d.entry.js.map +1 -0
  89. package/dist/core/p-575d0c94.entry.js +2 -0
  90. package/dist/core/p-575d0c94.entry.js.map +1 -0
  91. package/dist/core/p-5bc604a3.js.map +1 -1
  92. package/dist/core/p-831edc90.entry.js +2 -0
  93. package/dist/core/p-831edc90.entry.js.map +1 -0
  94. package/dist/core/{p-1bc2f62c.entry.js → p-8f121cad.entry.js} +2 -2
  95. package/dist/core/p-8fcc8483.js +2 -0
  96. package/dist/core/p-8fcc8483.js.map +1 -0
  97. package/dist/core/p-927880d6.entry.js.map +1 -1
  98. package/dist/core/p-ab5a13ea.js +2 -0
  99. package/dist/core/p-ab5a13ea.js.map +1 -0
  100. package/dist/core/{p-f9dcaafb.entry.js → p-af9a14e3.entry.js} +2 -2
  101. package/dist/core/{p-835f1187.entry.js → p-c0e8802d.entry.js} +2 -2
  102. package/dist/core/p-d784c44d.js +2 -0
  103. package/dist/core/p-d784c44d.js.map +1 -0
  104. package/dist/core/{p-ac856de6.entry.js → p-dd8816aa.entry.js} +2 -2
  105. package/dist/core/p-ef387ab2.entry.js +2 -0
  106. package/dist/core/{p-e3b14974.entry.js.map → p-ef387ab2.entry.js.map} +1 -1
  107. package/dist/esm/array.utils-b27436ea.js +43 -0
  108. package/dist/esm/array.utils-b27436ea.js.map +1 -0
  109. package/dist/esm/core.js +1 -1
  110. package/dist/esm/{form-39dc6896.js → form-e3424b70.js} +2 -2
  111. package/dist/esm/form-e3424b70.js.map +1 -0
  112. package/dist/esm/gov-form-checkbox.entry.js +1 -1
  113. package/dist/esm/gov-form-control.entry.js +1 -1
  114. package/dist/esm/gov-form-file.entry.js +1 -1
  115. package/dist/esm/gov-form-input.entry.js +1 -1
  116. package/dist/esm/gov-form-multi-select.entry.js +82 -101
  117. package/dist/esm/gov-form-multi-select.entry.js.map +1 -1
  118. package/dist/esm/gov-form-radio.entry.js +1 -1
  119. package/dist/esm/gov-form-select.entry.js +14 -18
  120. package/dist/esm/gov-form-select.entry.js.map +1 -1
  121. package/dist/esm/gov-form-switch.entry.js +1 -1
  122. package/dist/esm/gov-icon.entry.js +1 -1
  123. package/dist/esm/gov-pagination.entry.js +2 -8
  124. package/dist/esm/gov-pagination.entry.js.map +1 -1
  125. package/dist/esm/loader.js +1 -1
  126. package/dist/esm/stencil.utils-7cb5b075.js +9 -0
  127. package/dist/esm/stencil.utils-7cb5b075.js.map +1 -0
  128. package/dist/hydrate/index.js +145 -138
  129. package/dist/types/components/gov-form/multiselect/gov-form-multi-select.d.ts +17 -29
  130. package/dist/types/components/gov-form/multiselect/gov-form-multi-select.types.d.ts +3 -2
  131. package/dist/types/components/gov-form/select/constants.d.ts +1 -1
  132. package/dist/types/components/gov-form/select/gov-form-select.d.ts +6 -9
  133. package/dist/types/components/gov-form/select/gov-form-select.types.d.ts +1 -1
  134. package/dist/types/components.d.ts +28 -36
  135. package/dist/types/utils/array.utils.d.ts +1 -0
  136. package/dist/types/utils/object.utils.d.ts +1 -0
  137. package/dist/types/utils/stencil.utils.d.ts +1 -0
  138. package/package.json +1 -1
  139. package/dist/cjs/form-74063d50.js.map +0 -1
  140. package/dist/components/p-2d5d24af.js +0 -2
  141. package/dist/components/p-2d5d24af.js.map +0 -1
  142. package/dist/components/p-53e02bee.js +0 -2
  143. package/dist/components/p-53e02bee.js.map +0 -1
  144. package/dist/components/p-8b7b916a.js +0 -2
  145. package/dist/core/p-0e5fa8bf.js +0 -2
  146. package/dist/core/p-0e5fa8bf.js.map +0 -1
  147. package/dist/core/p-531c350f.entry.js +0 -2
  148. package/dist/core/p-531c350f.entry.js.map +0 -1
  149. package/dist/core/p-e3b14974.entry.js +0 -2
  150. package/dist/core/p-f1031bac.entry.js +0 -2
  151. package/dist/core/p-f1031bac.entry.js.map +0 -1
  152. package/dist/core/p-f7065042.entry.js +0 -2
  153. package/dist/core/p-f7065042.entry.js.map +0 -1
  154. package/dist/esm/form-39dc6896.js.map +0 -1
  155. package/dist/globals.d.ts +0 -2
  156. package/dist/types/types/typings.d.ts +0 -6
  157. /package/dist/components/{p-44762d17.js.map → p-23990b41.js.map} +0 -0
  158. /package/dist/components/{p-5dbe0178.js.map → p-26805569.js.map} +0 -0
  159. /package/dist/components/{p-99860f34.js.map → p-a6a15eb1.js.map} +0 -0
  160. /package/dist/components/{p-976404a5.js.map → p-b5a06a0a.js.map} +0 -0
  161. /package/dist/components/{p-76b229e3.js.map → p-e2bee1ef.js.map} +0 -0
  162. /package/dist/core/{p-148501cc.entry.js.map → p-191e9b0c.entry.js.map} +0 -0
  163. /package/dist/core/{p-9402e4cc.entry.js.map → p-2a13c39c.entry.js.map} +0 -0
  164. /package/dist/core/{p-1bc2f62c.entry.js.map → p-8f121cad.entry.js.map} +0 -0
  165. /package/dist/core/{p-f9dcaafb.entry.js.map → p-af9a14e3.entry.js.map} +0 -0
  166. /package/dist/core/{p-835f1187.entry.js.map → p-c0e8802d.entry.js.map} +0 -0
  167. /package/dist/core/{p-ac856de6.entry.js.map → p-dd8816aa.entry.js.map} +0 -0
@@ -7,9 +7,12 @@ import { validateWcagLabelFor, validateWcagRef } from "../../../helpers/Validate
7
7
  import { createID, removeDiacritics } from "../../../utils/string.utils";
8
8
  import { delay } from "../../../utils/utils";
9
9
  import { FormMultiSelectClass, FormMultiselectSizes, FormMultiselectVariants } from "./constants";
10
- import { hasOwnProperty } from "../../../utils/helpers.types";
10
+ import { propsValueToArray } from "../../../utils/array.utils";
11
+ import { tick } from "../../../utils/stencil.utils";
11
12
  export class GovFormMultiSelect {
12
13
  constructor() {
14
+ this.value = undefined;
15
+ this.options = undefined;
13
16
  this.identifier = undefined;
14
17
  this.placeholder = undefined;
15
18
  this.variant = undefined;
@@ -26,9 +29,9 @@ export class GovFormMultiSelect {
26
29
  this.wcagLabelledBy = undefined;
27
30
  this.wcagOwns = undefined;
28
31
  this.focused = undefined;
29
- this.value = undefined;
30
- this.selectedOptions = [];
31
- this.options = [];
32
+ this.valueState = undefined;
33
+ this.selectedOptionsState = [];
34
+ this.optionsState = [];
32
35
  this.selectId = createID('GovSelect');
33
36
  this.listId = createID('GovMultiList');
34
37
  this.h = govHost(this.host);
@@ -40,6 +43,12 @@ export class GovFormMultiSelect {
40
43
  validateSize(newValue) {
41
44
  validateProp(FormMultiselectSizes, newValue, FormMultiSelectClass.root);
42
45
  }
46
+ watchOptions(newValue) {
47
+ this.optionsState = propsValueToArray(newValue);
48
+ }
49
+ watchValue(newValue) {
50
+ this.selectedOptionsState = propsValueToArray(newValue);
51
+ }
43
52
  watchDisabled() {
44
53
  this.passControlAttrs();
45
54
  }
@@ -52,65 +61,74 @@ export class GovFormMultiSelect {
52
61
  this.validateVariant(this.variant);
53
62
  this.validateSize(this.size);
54
63
  this.watchDisabled();
64
+ this.passControlAttrs();
65
+ this.f.passAttrToLabel('required', String(this.required));
66
+ this.optionsState = propsValueToArray(this.options);
67
+ this.selectedOptionsState = propsValueToArray(this.value);
55
68
  }
56
69
  getAvailableOptions(ignoreFilter = false) {
57
- if (Array.isArray(this.options) && this.options.length) {
70
+ if (Array.isArray(this.optionsState) && this.optionsState.length) {
58
71
  if (ignoreFilter) {
59
- return this.options;
72
+ return this.optionsState;
60
73
  }
61
- return this.options.filter((option) => {
62
- const isSelected = this.selectedOptions.findIndex((selected) => selected.value === option.value);
63
- return (isSelected !== -1 || (option === null || option === void 0 ? void 0 : option.disabled)) ? false : true;
64
- });
74
+ return this.optionsState.filter((option) => {
75
+ const selectedIndex = this.selectedValueIndex(option.value);
76
+ return (selectedIndex !== -1 || (option === null || option === void 0 ? void 0 : option.disabled)) ? false : true;
77
+ }).map((option) => { var _a; return ({ name: (_a = option.name) !== null && _a !== void 0 ? _a : option.value, value: option.value }); });
65
78
  }
66
79
  return Array.from(this.selectRef.querySelectorAll('option'))
67
80
  .filter((option) => {
68
81
  if (ignoreFilter) {
69
82
  return true;
70
83
  }
71
- return !(option.disabled || option.selected);
84
+ const selectedIndex = this.selectedValueIndex(option.value);
85
+ return !(option.disabled || option.selected || selectedIndex > -1);
72
86
  })
73
87
  .map((option) => ({ name: option.textContent, value: option.value }));
74
88
  }
75
89
  initAutocomplete() {
76
- this.autocompleteRef.addEventListener('gov-select', this.onSelectHandler.bind(this));
77
- this.autocompleteRef.addEventListener('gov-input', this.onInputHandler.bind(this));
78
- this.autocompleteRef.addEventListener('gov-focus', this.onFocusHandler.bind(this));
79
- this.autocompleteRef.addEventListener('gov-blur', this.onBlurHandler.bind(this));
80
- this.autocompleteRef
81
- .setSearchCallback(value => {
90
+ var _a, _b, _c, _d, _e;
91
+ (_a = this.autocompleteRef) === null || _a === void 0 ? void 0 : _a.addEventListener('gov-select', this.onSelectHandler.bind(this));
92
+ (_b = this.autocompleteRef) === null || _b === void 0 ? void 0 : _b.addEventListener('gov-input', this.onInputHandler.bind(this));
93
+ (_c = this.autocompleteRef) === null || _c === void 0 ? void 0 : _c.addEventListener('gov-focus', this.onFocusHandler.bind(this));
94
+ (_d = this.autocompleteRef) === null || _d === void 0 ? void 0 : _d.addEventListener('gov-blur', this.onBlurHandler.bind(this));
95
+ (_e = this.autocompleteRef) === null || _e === void 0 ? void 0 : _e.setSearchCallback(searchString => {
82
96
  return new Promise(resolve => {
83
97
  const data = this.getAvailableOptions();
84
- if (String(value).length === 0) {
98
+ if (String(searchString).length === 0) {
85
99
  return resolve(data);
86
100
  }
87
- resolve(data.filter(({ name }) => {
101
+ resolve(data.filter(({ name, value }) => {
88
102
  if (!name)
89
- return false;
90
- return removeDiacritics(name).toLowerCase().indexOf(removeDiacritics(value).toLowerCase()) > -1;
103
+ name = value;
104
+ return removeDiacritics(name).toLowerCase().indexOf(removeDiacritics(searchString).toLowerCase()) > -1;
91
105
  }));
92
106
  });
93
- })
94
- .then();
107
+ }).finally();
95
108
  }
96
- getOptionIndex(value) {
97
- return this.selectedOptions.findIndex(option => option.value === value.value && option.name === value.name);
109
+ selectedValueIndex(value) {
110
+ return this.selectedOptionsState.findIndex((selected) => selected === value);
98
111
  }
99
112
  getOptionElement(value) {
100
- return this.selectRef.querySelector('option[value="' + value.value + '"]');
113
+ return this.selectRef.querySelector('option[value="' + value + '"]');
114
+ }
115
+ getOption(value) {
116
+ var _a;
117
+ return (_a = this.getAvailableOptions(true).find((option) => option.value === value)) !== null && _a !== void 0 ? _a : null;
101
118
  }
102
119
  selectOption(newOption, notify = true) {
103
- const index = this.getOptionIndex(newOption);
120
+ const index = this.selectedValueIndex(newOption);
104
121
  if (index === -1) {
105
- this.selectedOptions = [...this.selectedOptions, newOption];
122
+ this.selectedOptionsState = [...this.selectedOptionsState, newOption];
123
+ this.value = this.selectedOptionsState;
106
124
  if (notify) {
107
125
  this.govChange.emit({
108
126
  component: FormMultiSelectClass.root,
109
- value: this.selectedOptions,
127
+ value: this.selectedOptionsState,
110
128
  });
111
129
  this.govSelect.emit({
112
130
  component: FormMultiSelectClass.root,
113
- value: this.selectedOptions,
131
+ value: this.selectedOptionsState,
114
132
  });
115
133
  }
116
134
  const option = this.getOptionElement(newOption);
@@ -120,18 +138,19 @@ export class GovFormMultiSelect {
120
138
  }
121
139
  }
122
140
  removeOption(removeOption, notify = true) {
123
- const index = this.getOptionIndex(removeOption);
141
+ const index = this.selectedValueIndex(removeOption);
124
142
  if (index !== -1) {
125
- this.selectedOptions.splice(index, 1);
126
- this.selectedOptions = [...this.selectedOptions];
143
+ this.selectedOptionsState.splice(index, 1);
144
+ this.selectedOptionsState = [...this.selectedOptionsState];
145
+ this.value = this.selectedOptionsState;
127
146
  if (notify) {
128
147
  this.govChange.emit({
129
148
  component: FormMultiSelectClass.root,
130
- value: this.selectedOptions,
149
+ value: this.selectedOptionsState,
131
150
  });
132
151
  this.govRemove.emit({
133
152
  component: FormMultiSelectClass.root,
134
- value: this.selectedOptions,
153
+ value: this.selectedOptionsState,
135
154
  });
136
155
  }
137
156
  const option = this.getOptionElement(removeOption);
@@ -142,13 +161,14 @@ export class GovFormMultiSelect {
142
161
  }
143
162
  async componentDidLoad() {
144
163
  this.initAutocomplete();
145
- this.selectRef.querySelectorAll('option').forEach((option) => {
146
- if (option.selected) {
147
- this.selectOption({
148
- name: option.textContent,
149
- value: option.value,
150
- }, false);
151
- }
164
+ }
165
+ async componentDidRender() {
166
+ tick(() => {
167
+ this.selectRef.querySelectorAll('option').forEach((option) => {
168
+ if (option.selected) {
169
+ this.selectOption(option.value, false);
170
+ }
171
+ });
152
172
  });
153
173
  if (canValidateWcagOnRender()) {
154
174
  await delay(500);
@@ -156,10 +176,16 @@ export class GovFormMultiSelect {
156
176
  }
157
177
  }
158
178
  render() {
159
- return (h(Host, { class: FormMultiSelectClass.root, size: this.size, variant: this.variant }, h("div", { class: FormMultiSelectClass.wrap }, h("div", { class: "element" }, h("gov-form-autocomplete", { value: this.value, disabled: this.disabled, identifier: this.identifier || this.selectId, required: false, size: this.size, variant: this.variant, placeholder: this.placeholder, "message-empty": this.messageEmpty, "message-loading": this.messageLoading, ref: el => (this.autocompleteRef = el), minlength: 0, wcagDescribedBy: this.wcagDescribedBy, wcagLabelledBy: this.wcagLabelledBy, wcagOwns: this.listId }), h("gov-icon", { slot: "right-icon", class: "icon-arrow", name: "chevron-down" }), this.h.hasSlot('right-icon') && !(this.success || this.invalid) && h("slot", { name: "right-icon" }), this.success && h("gov-icon", { slot: "right-icon", class: "icon-validation", name: "check-lg" }), this.invalid && h("gov-icon", { slot: "right-icon", class: "icon-validation", name: "exclamation-lg" }), h("select", { hidden: true, "aria-hidden": toBoolAttr(true), multiple: true, required: this.required, name: this.name, disabled: this.disabled, ref: el => (this.selectRef = el), "aria-disabled": toBoolAttrIfDefined(this.disabled), "aria-required": toBoolAttrIfDefined(this.required), "aria-invalid": toBoolAttrIfDefined(this.invalid), "aria-describedby": this.wcagDescribedBy, "aria-labelledby": this.wcagLabelledBy, "aria-owns": this.wcagOwns }, h("slot", null), this.options.map((option) => {
160
- return (h("option", { value: option.value, selected: option.value === this.value, disabled: option === null || option === void 0 ? void 0 : option.disabled }, option.name));
161
- })))), this.hideSelectedList === false ? (h("ul", { role: "listbox", id: this.listId, class: FormMultiSelectClass.list }, this.selectedOptions.map(option => {
162
- return (h("li", { class: FormMultiSelectClass.item, role: "option" }, option.name, h("gov-button", { wcagLabel: 'Odebrat vybranou položku ' + option.name, variant: "primary", type: "base", size: "s", "on-gov-click": () => this.onTagRemove(option) }, h("gov-icon", { name: "x-lg" }))));
179
+ return (h(Host, { class: FormMultiSelectClass.root, size: this.size, variant: this.variant }, h("div", { class: FormMultiSelectClass.wrap }, h("div", { class: "element" }, h("gov-form-autocomplete", { value: this.valueState, disabled: this.disabled, identifier: this.identifier || this.selectId, required: false, size: this.size, variant: this.variant, placeholder: this.placeholder, "message-empty": this.messageEmpty, "message-loading": this.messageLoading, ref: el => (this.autocompleteRef = el), minlength: 0, wcagDescribedBy: this.wcagDescribedBy, wcagLabelledBy: this.wcagLabelledBy, wcagOwns: this.listId }), h("gov-icon", { slot: "right-icon", class: "icon-arrow", name: "chevron-down" }), this.h.hasSlot('right-icon') && !(this.success || this.invalid) && h("slot", { name: "right-icon" }), this.success && h("gov-icon", { slot: "right-icon", class: "icon-validation", name: "check-lg" }), this.invalid && h("gov-icon", { slot: "right-icon", class: "icon-validation", name: "exclamation-lg" }), h("select", { hidden: true, class: 'hidden-select-list', "aria-hidden": toBoolAttr(true), multiple: true, required: this.required, name: this.name, disabled: this.disabled, ref: el => (this.selectRef = el), "aria-disabled": toBoolAttrIfDefined(this.disabled), "aria-required": toBoolAttrIfDefined(this.required), "aria-invalid": toBoolAttrIfDefined(this.invalid), "aria-describedby": this.wcagDescribedBy, "aria-labelledby": this.wcagLabelledBy, "aria-owns": this.wcagOwns }, h("slot", null), Array.isArray(this.optionsState) && this.optionsState.map((option) => {
180
+ var _a;
181
+ const selectedOption = this.selectedValueIndex(option.value);
182
+ return (h("option", { value: option.value, selected: selectedOption > -1, disabled: option === null || option === void 0 ? void 0 : option.disabled }, (_a = option.name) !== null && _a !== void 0 ? _a : option.value));
183
+ })))), this.hideSelectedList === false ? (h("ul", { role: "listbox", id: this.listId, class: FormMultiSelectClass.list }, Array.isArray(this.selectedOptionsState) && this.selectedOptionsState.map(selected => {
184
+ var _a, _b;
185
+ const option = this.getOption(selected);
186
+ if (!option)
187
+ return null;
188
+ return (h("li", { class: FormMultiSelectClass.item, role: "option" }, (_a = option.name) !== null && _a !== void 0 ? _a : option.value, h("gov-button", { wcagLabel: (_b = 'Odebrat vybranou položku ' + option.name) !== null && _b !== void 0 ? _b : option.value, variant: "primary", type: "base", size: "s", "on-gov-click": () => this.onTagRemove(selected) }, h("gov-icon", { name: "x-lg" }))));
163
189
  }))) : null));
164
190
  }
165
191
  onFocusHandler(e) {
@@ -168,7 +194,7 @@ export class GovFormMultiSelect {
168
194
  this.govFocus.emit({
169
195
  component: FormMultiSelectClass.root,
170
196
  originalEvent: e,
171
- value: this.selectedOptions,
197
+ value: this.selectedOptionsState,
172
198
  });
173
199
  }
174
200
  onBlurHandler(e) {
@@ -178,19 +204,19 @@ export class GovFormMultiSelect {
178
204
  this.govBlur.emit({
179
205
  component: FormMultiSelectClass.root,
180
206
  originalEvent: e,
181
- value: this.selectedOptions,
207
+ value: this.selectedOptionsState,
182
208
  });
183
209
  }
184
210
  onInputHandler(e) {
185
- this.value = e.detail.value;
211
+ this.valueState = e.detail.value;
186
212
  e.stopPropagation();
187
213
  }
188
214
  onSelectHandler(e) {
189
215
  e.stopPropagation();
190
216
  const value = e.detail.selected;
191
- this.selectOption(value);
192
- this.value = '';
193
- this.autocompleteRef.clearValue();
217
+ this.selectOption(value.value);
218
+ this.valueState = '';
219
+ this.autocompleteRef.clearValue().finally();
194
220
  this.autocompleteRef.focus();
195
221
  }
196
222
  onTagRemove(removeOption) {
@@ -206,7 +232,7 @@ export class GovFormMultiSelect {
206
232
  * Sets the ordered value of the element
207
233
  */
208
234
  async setValue(value) {
209
- this.value = value;
235
+ this.valueState = value;
210
236
  }
211
237
  /**
212
238
  * Returns an instance of the native html select element
@@ -214,50 +240,6 @@ export class GovFormMultiSelect {
214
240
  async getRef() {
215
241
  return this.selectRef;
216
242
  }
217
- /**
218
- * Returns a list of selected items
219
- */
220
- async getSelectedOptions() {
221
- return this.selectedOptions;
222
- }
223
- /**
224
- * Setting a list of options to choose from
225
- */
226
- async setOptions(options) {
227
- if (Array.isArray(options)) {
228
- this.options = [...options];
229
- }
230
- }
231
- /**
232
- * Returns all available options
233
- */
234
- async getOptions(ignoreFilter = true) {
235
- return this.getAvailableOptions(ignoreFilter);
236
- }
237
- /**
238
- * Setting the list of selected options
239
- */
240
- async setSelectedOptions(options) {
241
- if (Array.isArray(options)) {
242
- this.selectedOptions = [...options];
243
- }
244
- }
245
- /**
246
- * To remove an option from the selected list
247
- */
248
- async removeSelectedOption(option, notify = false) {
249
- if (typeof option === 'object' && hasOwnProperty(option, 'name') && hasOwnProperty(option, 'value')) {
250
- this.removeOption(option, notify);
251
- }
252
- }
253
- /**
254
- * Returns an instance of the native html select element
255
- */
256
- async setSelectedOption(option, notify = false) {
257
- if (typeof option === 'object' && hasOwnProperty(option, 'name') && hasOwnProperty(option, 'value')) {
258
- this.selectOption(option, notify);
259
- }
260
- }
261
243
  /**
262
244
  * Validate the WCAG attributes of the component
263
245
  */
@@ -280,6 +262,52 @@ export class GovFormMultiSelect {
280
262
  }
281
263
  static get properties() {
282
264
  return {
265
+ "value": {
266
+ "type": "string",
267
+ "mutable": true,
268
+ "complexType": {
269
+ "original": "string | GovFormMultiSelectSelectedItem[]",
270
+ "resolved": "GovFormMultiSelectSelectedItem[] | string",
271
+ "references": {
272
+ "GovFormMultiSelectSelectedItem": {
273
+ "location": "import",
274
+ "path": "./gov-form-multi-select.types",
275
+ "id": "../../../packages/core/src/components/gov-form/multiselect/gov-form-multi-select.types.ts::GovFormMultiSelectSelectedItem"
276
+ }
277
+ }
278
+ },
279
+ "required": false,
280
+ "optional": false,
281
+ "docs": {
282
+ "tags": [],
283
+ "text": "Value of multi-select"
284
+ },
285
+ "attribute": "value",
286
+ "reflect": true
287
+ },
288
+ "options": {
289
+ "type": "string",
290
+ "mutable": true,
291
+ "complexType": {
292
+ "original": "string | GovFormMultiSelectItem[]",
293
+ "resolved": "GovFormMultiSelectItem[] | string",
294
+ "references": {
295
+ "GovFormMultiSelectItem": {
296
+ "location": "import",
297
+ "path": "./gov-form-multi-select.types",
298
+ "id": "../../../packages/core/src/components/gov-form/multiselect/gov-form-multi-select.types.ts::GovFormMultiSelectItem"
299
+ }
300
+ }
301
+ },
302
+ "required": false,
303
+ "optional": true,
304
+ "docs": {
305
+ "tags": [],
306
+ "text": "Options of multi-select"
307
+ },
308
+ "attribute": "options",
309
+ "reflect": true
310
+ },
283
311
  "identifier": {
284
312
  "type": "string",
285
313
  "mutable": false,
@@ -558,9 +586,9 @@ export class GovFormMultiSelect {
558
586
  static get states() {
559
587
  return {
560
588
  "focused": {},
561
- "value": {},
562
- "selectedOptions": {},
563
- "options": {}
589
+ "valueState": {},
590
+ "selectedOptionsState": {},
591
+ "optionsState": {}
564
592
  };
565
593
  }
566
594
  static get events() {
@@ -738,159 +766,6 @@ export class GovFormMultiSelect {
738
766
  "tags": []
739
767
  }
740
768
  },
741
- "getSelectedOptions": {
742
- "complexType": {
743
- "signature": "() => Promise<GovFormMultiSelectItem[]>",
744
- "parameters": [],
745
- "references": {
746
- "Promise": {
747
- "location": "global",
748
- "id": "global::Promise"
749
- },
750
- "GovFormMultiSelectItem": {
751
- "location": "import",
752
- "path": "./gov-form-multi-select.types",
753
- "id": "../../../packages/core/src/components/gov-form/multiselect/gov-form-multi-select.types.ts::GovFormMultiSelectItem"
754
- }
755
- },
756
- "return": "Promise<GovFormMultiSelectItem[]>"
757
- },
758
- "docs": {
759
- "text": "Returns a list of selected items",
760
- "tags": []
761
- }
762
- },
763
- "setOptions": {
764
- "complexType": {
765
- "signature": "(options: GovFormMultiSelectItem[]) => Promise<void>",
766
- "parameters": [{
767
- "tags": [],
768
- "text": ""
769
- }],
770
- "references": {
771
- "Promise": {
772
- "location": "global",
773
- "id": "global::Promise"
774
- },
775
- "GovFormMultiSelectItem": {
776
- "location": "import",
777
- "path": "./gov-form-multi-select.types",
778
- "id": "../../../packages/core/src/components/gov-form/multiselect/gov-form-multi-select.types.ts::GovFormMultiSelectItem"
779
- }
780
- },
781
- "return": "Promise<void>"
782
- },
783
- "docs": {
784
- "text": "Setting a list of options to choose from",
785
- "tags": []
786
- }
787
- },
788
- "getOptions": {
789
- "complexType": {
790
- "signature": "(ignoreFilter?: boolean) => Promise<GovFormMultiSelectItem[]>",
791
- "parameters": [{
792
- "tags": [],
793
- "text": ""
794
- }],
795
- "references": {
796
- "Promise": {
797
- "location": "global",
798
- "id": "global::Promise"
799
- },
800
- "GovFormMultiSelectItem": {
801
- "location": "import",
802
- "path": "./gov-form-multi-select.types",
803
- "id": "../../../packages/core/src/components/gov-form/multiselect/gov-form-multi-select.types.ts::GovFormMultiSelectItem"
804
- }
805
- },
806
- "return": "Promise<GovFormMultiSelectItem[]>"
807
- },
808
- "docs": {
809
- "text": "Returns all available options",
810
- "tags": []
811
- }
812
- },
813
- "setSelectedOptions": {
814
- "complexType": {
815
- "signature": "(options: GovFormMultiSelectItem[]) => Promise<void>",
816
- "parameters": [{
817
- "tags": [],
818
- "text": ""
819
- }],
820
- "references": {
821
- "Promise": {
822
- "location": "global",
823
- "id": "global::Promise"
824
- },
825
- "GovFormMultiSelectItem": {
826
- "location": "import",
827
- "path": "./gov-form-multi-select.types",
828
- "id": "../../../packages/core/src/components/gov-form/multiselect/gov-form-multi-select.types.ts::GovFormMultiSelectItem"
829
- }
830
- },
831
- "return": "Promise<void>"
832
- },
833
- "docs": {
834
- "text": "Setting the list of selected options",
835
- "tags": []
836
- }
837
- },
838
- "removeSelectedOption": {
839
- "complexType": {
840
- "signature": "(option: GovFormMultiSelectItem, notify?: boolean) => Promise<void>",
841
- "parameters": [{
842
- "tags": [],
843
- "text": ""
844
- }, {
845
- "tags": [],
846
- "text": ""
847
- }],
848
- "references": {
849
- "Promise": {
850
- "location": "global",
851
- "id": "global::Promise"
852
- },
853
- "GovFormMultiSelectItem": {
854
- "location": "import",
855
- "path": "./gov-form-multi-select.types",
856
- "id": "../../../packages/core/src/components/gov-form/multiselect/gov-form-multi-select.types.ts::GovFormMultiSelectItem"
857
- }
858
- },
859
- "return": "Promise<void>"
860
- },
861
- "docs": {
862
- "text": "To remove an option from the selected list",
863
- "tags": []
864
- }
865
- },
866
- "setSelectedOption": {
867
- "complexType": {
868
- "signature": "(option: GovFormMultiSelectItem, notify?: boolean) => Promise<void>",
869
- "parameters": [{
870
- "tags": [],
871
- "text": ""
872
- }, {
873
- "tags": [],
874
- "text": ""
875
- }],
876
- "references": {
877
- "Promise": {
878
- "location": "global",
879
- "id": "global::Promise"
880
- },
881
- "GovFormMultiSelectItem": {
882
- "location": "import",
883
- "path": "./gov-form-multi-select.types",
884
- "id": "../../../packages/core/src/components/gov-form/multiselect/gov-form-multi-select.types.ts::GovFormMultiSelectItem"
885
- }
886
- },
887
- "return": "Promise<void>"
888
- },
889
- "docs": {
890
- "text": "Returns an instance of the native html select element",
891
- "tags": []
892
- }
893
- },
894
769
  "validateWcag": {
895
770
  "complexType": {
896
771
  "signature": "() => Promise<void>",
@@ -918,6 +793,12 @@ export class GovFormMultiSelect {
918
793
  }, {
919
794
  "propName": "size",
920
795
  "methodName": "validateSize"
796
+ }, {
797
+ "propName": "options",
798
+ "methodName": "watchOptions"
799
+ }, {
800
+ "propName": "value",
801
+ "methodName": "watchValue"
921
802
  }, {
922
803
  "propName": "disabled",
923
804
  "methodName": "watchDisabled"