vira 31.23.0 → 31.24.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -37,6 +37,13 @@ export declare const ViraDropdown: import("element-vir").DeclarativeElementDefin
|
|
|
37
37
|
*/
|
|
38
38
|
randomId: string;
|
|
39
39
|
}, {
|
|
40
|
+
/**
|
|
41
|
+
* @deprecated Use `selectedValuesChange` instead. `selectedChange` is broken for
|
|
42
|
+
* multi-select (it doesn't emit all the currently selected values) but is temporarily
|
|
43
|
+
* left for backwards compatibility purposes. It will be removed entirely soon.
|
|
44
|
+
*/
|
|
40
45
|
selectedChange: import("element-vir").DefineEvent<string[]>;
|
|
46
|
+
/** Emits all currently selected values. */
|
|
47
|
+
selectedValuesChange: import("element-vir").DefineEvent<string[]>;
|
|
41
48
|
openChange: import("element-vir").DefineEvent<ShowPopUpResult | undefined>;
|
|
42
49
|
}, "vira-dropdown-", "vira-dropdown-", readonly [], readonly ["leadingIcon", "prefixText", "trigger"]>;
|
|
@@ -110,7 +110,14 @@ export const ViraDropdown = defineViraElement()({
|
|
|
110
110
|
}
|
|
111
111
|
`,
|
|
112
112
|
events: {
|
|
113
|
+
/**
|
|
114
|
+
* @deprecated Use `selectedValuesChange` instead. `selectedChange` is broken for
|
|
115
|
+
* multi-select (it doesn't emit all the currently selected values) but is temporarily
|
|
116
|
+
* left for backwards compatibility purposes. It will be removed entirely soon.
|
|
117
|
+
*/
|
|
113
118
|
selectedChange: defineElementEvent(),
|
|
119
|
+
/** Emits all currently selected values. */
|
|
120
|
+
selectedValuesChange: defineElementEvent(),
|
|
114
121
|
openChange: defineElementEvent(),
|
|
115
122
|
},
|
|
116
123
|
state() {
|
|
@@ -160,7 +167,17 @@ export const ViraDropdown = defineViraElement()({
|
|
|
160
167
|
return {
|
|
161
168
|
content: option.label,
|
|
162
169
|
onClick() {
|
|
170
|
+
const newSelectedValues = inputs.isMultiSelect
|
|
171
|
+
? selectedOptions.includes(option)
|
|
172
|
+
? filterMap(selectedOptions, (selectedOption) => selectedOption.value, (value, selectedOption) => selectedOption !== option)
|
|
173
|
+
: [
|
|
174
|
+
...selectedOptions.map((selectedOption) => selectedOption.value),
|
|
175
|
+
option.value,
|
|
176
|
+
]
|
|
177
|
+
: [option.value];
|
|
178
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
163
179
|
dispatch(new events.selectedChange([option.value]));
|
|
180
|
+
dispatch(new events.selectedValuesChange(newSelectedValues));
|
|
164
181
|
},
|
|
165
182
|
disabled: option.disabled,
|
|
166
183
|
selected: selectedOptions.includes(option),
|
|
@@ -171,6 +188,7 @@ export const ViraDropdown = defineViraElement()({
|
|
|
171
188
|
const triggerTemplate = html `
|
|
172
189
|
<${ViraPopUpTrigger.assign({
|
|
173
190
|
...inputs,
|
|
191
|
+
keepOpenAfterInteraction: inputs.isMultiSelect,
|
|
174
192
|
focusOnClose: true,
|
|
175
193
|
popUpOffset: {
|
|
176
194
|
vertical: -1,
|
|
@@ -225,7 +225,15 @@ export const ViraSelect = defineViraElement()({
|
|
|
225
225
|
/** `showPicker` is not in Safari. */
|
|
226
226
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
227
227
|
if (selectElement.showPicker) {
|
|
228
|
-
|
|
228
|
+
try {
|
|
229
|
+
selectElement.showPicker();
|
|
230
|
+
}
|
|
231
|
+
catch {
|
|
232
|
+
/**
|
|
233
|
+
* Chromium throws `NotAllowedError` when `showPicker` runs without
|
|
234
|
+
* transient user activation; the picker just won't open.
|
|
235
|
+
*/
|
|
236
|
+
}
|
|
229
237
|
}
|
|
230
238
|
}),
|
|
231
239
|
listenTo(host, 'click', (event) => {
|
|
@@ -238,7 +246,15 @@ export const ViraSelect = defineViraElement()({
|
|
|
238
246
|
/** `showPicker` is not in Safari. */
|
|
239
247
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
240
248
|
if (selectElement.showPicker) {
|
|
241
|
-
|
|
249
|
+
try {
|
|
250
|
+
selectElement.showPicker();
|
|
251
|
+
}
|
|
252
|
+
catch {
|
|
253
|
+
/**
|
|
254
|
+
* Chromium throws `NotAllowedError` when `showPicker` runs without
|
|
255
|
+
* transient user activation; the picker just won't open.
|
|
256
|
+
*/
|
|
257
|
+
}
|
|
242
258
|
}
|
|
243
259
|
}),
|
|
244
260
|
];
|