vira 31.7.2 → 31.7.4
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.
|
@@ -86,6 +86,8 @@ export const ViraMenuItem = defineViraElement()({
|
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
.slot-wrapper {
|
|
89
|
+
display: flex;
|
|
90
|
+
flex-grow: 1;
|
|
89
91
|
overflow: hidden;
|
|
90
92
|
text-overflow: ellipsis;
|
|
91
93
|
white-space: nowrap;
|
|
@@ -118,7 +120,17 @@ export const ViraMenuItem = defineViraElement()({
|
|
|
118
120
|
event.preventDefault();
|
|
119
121
|
event.stopPropagation();
|
|
120
122
|
propagating[event.type] = true;
|
|
121
|
-
|
|
123
|
+
if (event.type === 'click') {
|
|
124
|
+
/**
|
|
125
|
+
* Use `.click()` instead of dispatching a synthetic MouseEvent so that
|
|
126
|
+
* the resulting event is trusted and carries user activation. This is
|
|
127
|
+
* required for APIs like `showPicker()` on `<select>` elements.
|
|
128
|
+
*/
|
|
129
|
+
element.click();
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
element.dispatchEvent(new MouseEvent(event.type, event));
|
|
133
|
+
}
|
|
122
134
|
delete propagating[event.type];
|
|
123
135
|
}
|
|
124
136
|
});
|
|
@@ -194,9 +194,25 @@ export const ViraSelect = defineViraElement()({
|
|
|
194
194
|
`,
|
|
195
195
|
init({ state, updateState, host }) {
|
|
196
196
|
state.cleanupListeners?.();
|
|
197
|
+
function getSelectElement() {
|
|
198
|
+
return assertWrap.instanceOf(host.shadowRoot.querySelector('select'), HTMLSelectElement);
|
|
199
|
+
}
|
|
197
200
|
const listenerRemovers = [
|
|
198
201
|
listenTo(host, 'mousedown', (event) => {
|
|
199
|
-
const selectElement =
|
|
202
|
+
const selectElement = getSelectElement();
|
|
203
|
+
if (event.composedPath().includes(selectElement)) {
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
event.preventDefault();
|
|
207
|
+
event.stopPropagation();
|
|
208
|
+
/** `showPicker` is not in Safari. */
|
|
209
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
210
|
+
if (selectElement.showPicker) {
|
|
211
|
+
selectElement.showPicker();
|
|
212
|
+
}
|
|
213
|
+
}),
|
|
214
|
+
listenTo(host, 'click', (event) => {
|
|
215
|
+
const selectElement = getSelectElement();
|
|
200
216
|
if (event.composedPath().includes(selectElement)) {
|
|
201
217
|
return;
|
|
202
218
|
}
|
|
@@ -80,4 +80,7 @@ export declare const ViraTabs: import("element-vir").DeclarativeElementDefinitio
|
|
|
80
80
|
isOverflowing: boolean;
|
|
81
81
|
/** A callback to remove all internal observers. */
|
|
82
82
|
cleanupObserver: undefined | (() => void);
|
|
83
|
-
}, {
|
|
83
|
+
}, {
|
|
84
|
+
/** Fires when a tab is clicked with the corresponding tab entry. */
|
|
85
|
+
tabSelect: import("element-vir").DefineEvent<Readonly<ViraTab>>;
|
|
86
|
+
}, "vira-tabs-bar-top" | "vira-tabs-bar-bottom" | "vira-tabs-bar-left" | "vira-tabs-bar-right" | "vira-tabs-color-accent" | "vira-tabs-color-plain" | "vira-tabs-icon-layout-vertical" | "vira-tabs-icon-layout-horizontal" | "vira-tabs-overflowing", "vira-tabs-active-color" | "vira-tabs-active-hover-color" | "vira-tabs-inactive-color" | "vira-tabs-inactive-hover-color" | "vira-tabs-bar-thickness", readonly [], readonly []>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { check } from '@augment-vir/assert';
|
|
2
2
|
import { filterMap } from '@augment-vir/common';
|
|
3
|
-
import { classMap, css, html, nothing, onDomCreated } from 'element-vir';
|
|
3
|
+
import { classMap, css, defineElementEvent, html, listen, nothing, onDomCreated } from 'element-vir';
|
|
4
4
|
import { routeHasPaths, } from 'spa-router-vir';
|
|
5
5
|
import { createFocusStyles } from '../styles/focus.js';
|
|
6
6
|
import { viraFormCssVars } from '../styles/form-styles.js';
|
|
@@ -45,6 +45,10 @@ export var ViraTabsIconLayout;
|
|
|
45
45
|
*/
|
|
46
46
|
export const ViraTabs = defineViraElement()({
|
|
47
47
|
tagName: 'vira-tabs',
|
|
48
|
+
events: {
|
|
49
|
+
/** Fires when a tab is clicked with the corresponding tab entry. */
|
|
50
|
+
tabSelect: defineElementEvent(),
|
|
51
|
+
},
|
|
48
52
|
state() {
|
|
49
53
|
return {
|
|
50
54
|
isOverflowing: false,
|
|
@@ -254,7 +258,7 @@ export const ViraTabs = defineViraElement()({
|
|
|
254
258
|
cleanup({ state }) {
|
|
255
259
|
state.cleanupObserver?.();
|
|
256
260
|
},
|
|
257
|
-
render({ inputs, state, updateState, host }) {
|
|
261
|
+
render({ inputs, state, updateState, host, dispatch, events }) {
|
|
258
262
|
const tabs = filterMap(inputs.tabs, (tab) => {
|
|
259
263
|
if (tab.isHidden) {
|
|
260
264
|
return undefined;
|
|
@@ -275,6 +279,11 @@ export const ViraTabs = defineViraElement()({
|
|
|
275
279
|
disabled: !!tab.isDisabled,
|
|
276
280
|
})}
|
|
277
281
|
role="presentation"
|
|
282
|
+
${listen('click', () => {
|
|
283
|
+
if (!tab.isDisabled) {
|
|
284
|
+
dispatch(new events.tabSelect(tab));
|
|
285
|
+
}
|
|
286
|
+
})}
|
|
278
287
|
>
|
|
279
288
|
<${ViraLink.assign({
|
|
280
289
|
route: {
|
|
@@ -325,6 +334,11 @@ export const ViraTabs = defineViraElement()({
|
|
|
325
334
|
`,
|
|
326
335
|
selected: isSelected,
|
|
327
336
|
disabled: tab.isDisabled,
|
|
337
|
+
onClick() {
|
|
338
|
+
if (!tab.isDisabled) {
|
|
339
|
+
dispatch(new events.tabSelect(tab));
|
|
340
|
+
}
|
|
341
|
+
},
|
|
328
342
|
};
|
|
329
343
|
}, check.isTruthy));
|
|
330
344
|
return html `
|
|
@@ -339,6 +339,11 @@ export const ViraTag = defineViraElement()({
|
|
|
339
339
|
display: flex;
|
|
340
340
|
}
|
|
341
341
|
|
|
342
|
+
${hostClasses['vira-tag-size-small'].selector} button {
|
|
343
|
+
padding: 0 var(${cssVars['vira-tag-horizontal-padding'].name}, 8px);
|
|
344
|
+
gap: 4px;
|
|
345
|
+
}
|
|
346
|
+
|
|
342
347
|
${hostClasses['vira-tag-size-large'].selector} button {
|
|
343
348
|
padding: 0 var(${cssVars['vira-tag-horizontal-padding'].name}, 16px);
|
|
344
349
|
}
|