vira 31.3.0 → 31.4.0

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.
@@ -309,11 +309,11 @@ export const ViraButton = defineViraElement()({
309
309
  const styles = viraSizeVariants.map((sizeVariant) => {
310
310
  return css `
311
311
  ${hostClasses[`vira-button-size-${sizeVariant}`].selector} {
312
- height: ${viraSizeHeights[sizeVariant]}px;
313
312
  font-size: ${viraFormCssVars[`vira-form-${sizeVariant}-text-size`].value};
314
313
 
315
314
  button {
316
- padding: 0
315
+ min-height: ${viraSizeHeights[sizeVariant]}px;
316
+ padding: 2px
317
317
  ${viraFormCssVars[`vira-form-${sizeVariant}-text-size`].value};
318
318
  }
319
319
  }
@@ -0,0 +1,24 @@
1
+ import type * as featherIconsImportType from 'feather-icons';
2
+ import { type FeatherAttributes } from 'feather-icons';
3
+ import { type ViraIconSvg } from './icon-svg.js';
4
+ declare const featherIconsImported: typeof featherIconsImportType;
5
+ /**
6
+ * All supported feather icon names.
7
+ *
8
+ * @category Internal
9
+ */
10
+ export type FeatherIconKey = keyof typeof featherIconsImported.icons;
11
+ /**
12
+ * An entry in {@link featherIcons}.
13
+ *
14
+ * @category Internal
15
+ */
16
+ export type FeatherIconEntry = ViraIconSvg & ((options: Readonly<FeatherAttributes>) => ViraIconSvg);
17
+ /**
18
+ * All [Feather icons](https://feathericons.com) in a format compatible with `ViraIcon`. Each icon
19
+ * entry can be accessed directly or customized by calling it as a function.
20
+ *
21
+ * @category Icon
22
+ */
23
+ export declare const featherIcons: Readonly<Record<FeatherIconKey, FeatherIconEntry>>;
24
+ export {};
@@ -0,0 +1,89 @@
1
+ import { check } from '@augment-vir/assert';
2
+ import { html, unsafeHTML } from 'element-vir';
3
+ import { viraIconCssVars } from './icon-css-vars.js';
4
+ /** Feather's export format is all messed up so we have to do this to catch all its possible cases. */
5
+ async function importFeatherIcons() {
6
+ const imported = (await import('feather-icons'));
7
+ function recurseImport(imported) {
8
+ if (check.isObject(imported)) {
9
+ if (check.hasKey(imported, 'default')) {
10
+ return recurseImport(imported.default);
11
+ }
12
+ else if (check.hasKey(imported, 'icons')) {
13
+ return imported;
14
+ }
15
+ }
16
+ return undefined;
17
+ }
18
+ return (recurseImport(imported) ||
19
+ /** Unfortunately, Feather will attach itself to the global state sometimes. */
20
+ globalThis.feather);
21
+ }
22
+ const featherIconsImported = await importFeatherIcons();
23
+ const defaultFeatherOptions = {
24
+ fill: String(viraIconCssVars['vira-icon-fill-color'].value),
25
+ stroke: String(viraIconCssVars['vira-icon-stroke-color'].value),
26
+ 'stroke-width': String(viraIconCssVars['vira-icon-stroke-width'].value),
27
+ };
28
+ function createFeatherIconEntry(iconKey) {
29
+ const featherIcon = featherIconsImported.icons[iconKey];
30
+ const configureIconCallback = (options) => {
31
+ return {
32
+ name: featherIcon.name,
33
+ svgTemplate: html `
34
+ ${unsafeHTML(featherIcon.toSvg({
35
+ ...defaultFeatherOptions,
36
+ ...options,
37
+ }))}
38
+ `,
39
+ };
40
+ };
41
+ Object.defineProperty(configureIconCallback, 'name', {
42
+ value: featherIcon.name,
43
+ writable: false,
44
+ configurable: true,
45
+ });
46
+ return Object.assign(configureIconCallback, {
47
+ svgTemplate: html `
48
+ ${unsafeHTML(featherIcon.toSvg(defaultFeatherOptions))}
49
+ `,
50
+ });
51
+ }
52
+ const featherIconCache = new Map();
53
+ /**
54
+ * All [Feather icons](https://feathericons.com) in a format compatible with `ViraIcon`. Each icon
55
+ * entry can be accessed directly or customized by calling it as a function.
56
+ *
57
+ * @category Icon
58
+ */
59
+ export const featherIcons = new Proxy({}, {
60
+ get(_target, property) {
61
+ const iconKey = property;
62
+ if (!(iconKey in featherIconsImported.icons)) {
63
+ return undefined;
64
+ }
65
+ const cached = featherIconCache.get(iconKey);
66
+ if (cached) {
67
+ return cached;
68
+ }
69
+ const entry = createFeatherIconEntry(iconKey);
70
+ featherIconCache.set(iconKey, entry);
71
+ return entry;
72
+ },
73
+ has(_target, property) {
74
+ return property in featherIconsImported.icons;
75
+ },
76
+ ownKeys() {
77
+ return Object.keys(featherIconsImported.icons);
78
+ },
79
+ getOwnPropertyDescriptor(_target, property) {
80
+ if (property in featherIconsImported.icons) {
81
+ return {
82
+ configurable: true,
83
+ enumerable: true,
84
+ writable: false,
85
+ };
86
+ }
87
+ return undefined;
88
+ },
89
+ });
@@ -1,4 +1,5 @@
1
1
  export * from './colored-icon.js';
2
+ export * from './feather-icons.js';
2
3
  export * from './icon-css-vars.js';
3
4
  export * from './icon-svg.js';
4
5
  export * from './sized-icon.js';
@@ -55,6 +55,7 @@ import { Sun24Icon } from './icon-svgs/24/sun-24.icon.js';
55
55
  import { Upload24Icon } from './icon-svgs/24/upload-24.icon.js';
56
56
  import { X24Icon } from './icon-svgs/24/x-24.icon.js';
57
57
  export * from './colored-icon.js';
58
+ export * from './feather-icons.js';
58
59
  export * from './icon-css-vars.js';
59
60
  export * from './icon-svg.js';
60
61
  export * from './sized-icon.js';
@@ -4,13 +4,13 @@ function doesMatch({ input, matcher }) {
4
4
  if (!input || !matcher) {
5
5
  return true;
6
6
  }
7
- if (input.length > 1) {
7
+ else if (input.length > 1) {
8
8
  return input.split('').every((singleInput) => doesMatch({
9
9
  input: singleInput,
10
10
  matcher,
11
11
  }));
12
12
  }
13
- if (matcher instanceof RegExp) {
13
+ else if (matcher instanceof RegExp) {
14
14
  return !!input.match(matcher);
15
15
  }
16
16
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vira",
3
- "version": "31.3.0",
3
+ "version": "31.4.0",
4
4
  "description": "A simple and highly versatile design system using element-vir.",
5
5
  "keywords": [
6
6
  "design",
@@ -38,27 +38,29 @@
38
38
  "test:docs": "virmator docs check"
39
39
  },
40
40
  "dependencies": {
41
- "@augment-vir/assert": "^31.67.0",
42
- "@augment-vir/common": "^31.67.0",
43
- "@augment-vir/web": "^31.67.0",
41
+ "@augment-vir/assert": "^31.68.1",
42
+ "@augment-vir/common": "^31.68.1",
43
+ "@augment-vir/web": "^31.68.1",
44
44
  "@electrovir/color": "^1.7.8",
45
45
  "date-vir": "^8.2.0",
46
46
  "device-navigation": "^4.5.5",
47
- "lit-css-vars": "^3.5.0",
47
+ "lit-css-vars": "^3.6.2",
48
48
  "observavir": "^2.3.2",
49
49
  "page-active": "^1.0.3",
50
50
  "spa-router-vir": "^6.4.1",
51
51
  "type-fest": "^5.4.4",
52
- "typed-event-target": "^4.1.0"
52
+ "typed-event-target": "^4.3.0"
53
53
  },
54
54
  "devDependencies": {
55
- "@augment-vir/test": "^31.67.0",
55
+ "@augment-vir/test": "^31.68.1",
56
+ "@types/feather-icons": "^4.29.4",
56
57
  "@web/dev-server-esbuild": "^1.0.5",
57
58
  "@web/test-runner": "^0.20.2",
58
59
  "@web/test-runner-commands": "^0.9.0",
59
60
  "@web/test-runner-playwright": "^0.11.1",
60
61
  "@web/test-runner-visual-regression": "^0.10.0",
61
62
  "esbuild": "^0.27.3",
63
+ "feather-icons": "^4.29.2",
62
64
  "istanbul-smart-text-reporter": "^1.1.5",
63
65
  "markdown-code-example-inserter": "^3.0.3",
64
66
  "theme-vir": "^28.22.0",
@@ -68,7 +70,9 @@
68
70
  "vite-tsconfig-paths": "^6.1.1"
69
71
  },
70
72
  "peerDependencies": {
73
+ "@types/feather-icons": ">=4",
71
74
  "element-vir": ">=26",
75
+ "feather-icons": ">=4",
72
76
  "theme-vir": ">=28"
73
77
  },
74
78
  "engines": {