vira 31.9.0 → 31.9.2

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.
@@ -122,12 +122,25 @@ export const ViraMenuItem = defineViraElement()({
122
122
  event.stopPropagation();
123
123
  propagating[event.type] = true;
124
124
  if (event.type === 'click') {
125
- /**
126
- * Use `.click()` instead of dispatching a synthetic MouseEvent so that
127
- * the resulting event is trusted and carries user activation. This is
128
- * required for APIs like `showPicker()` on `<select>` elements.
129
- */
130
- element.click();
125
+ const hasModifiers = event instanceof MouseEvent &&
126
+ (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey);
127
+ if (hasModifiers) {
128
+ /**
129
+ * If modifier keys are present, dispatch a synthetic MouseEvent so
130
+ * that the modifier keys are preserved. This is needed so that
131
+ * cmd+click opens links in a new tab.
132
+ */
133
+ element.dispatchEvent(new MouseEvent('click', event));
134
+ }
135
+ else {
136
+ /**
137
+ * Use `.click()` instead of dispatching a synthetic MouseEvent so
138
+ * that the resulting event is trusted and carries user activation.
139
+ * This is required for APIs like `showPicker()` on `<select>`
140
+ * elements.
141
+ */
142
+ element.click();
143
+ }
131
144
  }
132
145
  else {
133
146
  element.dispatchEvent(new MouseEvent(event.type, event));
@@ -6,16 +6,10 @@ import { type ViraIconSvg } from './icon-svg.js';
6
6
  * @category Internal
7
7
  */
8
8
  export type LucideIconKey = keyof typeof lucideStaticImport;
9
- /**
10
- * An entry in {@link lucideIcons}.
11
- *
12
- * @category Internal
13
- */
14
- export type LucideIconEntry = ViraIconSvg & ((options: Readonly<Record<string, string | number>>) => ViraIconSvg);
15
9
  /**
16
10
  * All [Lucide icons](https://lucide.dev) in a format compatible with `ViraIcon`. Each icon entry
17
- * can be accessed directly or customized by calling it as a function.
11
+ * can be accessed directly as a {@link ViraIconSvg}.
18
12
  *
19
13
  * @category Icon
20
14
  */
21
- export declare const lucideIcons: Readonly<Record<LucideIconKey, LucideIconEntry>>;
15
+ export declare const lucideIcons: Readonly<Record<LucideIconKey, ViraIconSvg>>;
@@ -14,7 +14,7 @@ function setSvgAttribute(svgString, attributeName, value) {
14
14
  : svgString.replace(/<svg\b/, `<svg ${attributeName}="${value}"`);
15
15
  }
16
16
  function applySvgAttributes(svgString, attributes) {
17
- return Object.entries(attributes).reduce((result, [key, value,]) => setSvgAttribute(result, key, String(value)), svgString);
17
+ return Object.entries(attributes).reduce((result, [key, value,]) => setSvgAttribute(result, key, value), svgString);
18
18
  }
19
19
  function isLucideIconKey(key) {
20
20
  return key in lucideStaticImport;
@@ -27,33 +27,17 @@ function getLucideIconSvg(key) {
27
27
  return svg;
28
28
  }
29
29
  function createLucideIconEntry(iconKey) {
30
- const svgString = getLucideIconSvg(iconKey);
31
- const configureIconCallback = (options) => {
32
- return {
33
- name: iconKey,
34
- svgTemplate: html `
35
- ${unsafeHTML(applySvgAttributes(svgString, {
36
- ...defaultLucideAttributes,
37
- ...options,
38
- }))}
39
- `,
40
- };
41
- };
42
- Object.defineProperty(configureIconCallback, 'name', {
43
- value: iconKey,
44
- writable: false,
45
- configurable: true,
46
- });
47
- return Object.assign(configureIconCallback, {
30
+ return {
31
+ name: iconKey,
48
32
  svgTemplate: html `
49
- ${unsafeHTML(applySvgAttributes(svgString, defaultLucideAttributes))}
33
+ ${unsafeHTML(applySvgAttributes(getLucideIconSvg(iconKey), defaultLucideAttributes))}
50
34
  `,
51
- });
35
+ };
52
36
  }
53
37
  const lucideIconCache = new Map();
54
38
  /**
55
39
  * All [Lucide icons](https://lucide.dev) in a format compatible with `ViraIcon`. Each icon entry
56
- * can be accessed directly or customized by calling it as a function.
40
+ * can be accessed directly as a {@link ViraIconSvg}.
57
41
  *
58
42
  * @category Icon
59
43
  */
@@ -35,7 +35,7 @@ export var ViraColorVariant;
35
35
  * @category Internal
36
36
  */
37
37
  export const viraColorVariantToColorName = {
38
- [ViraColorVariant.Accent]: ViraThemeColorName.blue,
38
+ [ViraColorVariant.Accent]: ViraThemeColorName.accent,
39
39
  [ViraColorVariant.Neutral]: ViraThemeColorName.grey,
40
40
  [ViraColorVariant.Danger]: ViraThemeColorName.red,
41
41
  [ViraColorVariant.Warning]: ViraThemeColorName.yellow,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vira",
3
- "version": "31.9.0",
3
+ "version": "31.9.2",
4
4
  "description": "A simple and highly versatile design system using element-vir.",
5
5
  "keywords": [
6
6
  "design",