@vmz/ui-icons 0.3.10 → 0.3.12

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.
package/README.md CHANGED
@@ -12,7 +12,7 @@ semantic name → registry mark → <Icon name="tool.base64" />
12
12
  - Closed thin: semantic `name`, built-in registry, decorative vs labelled a11y, size density.
13
13
  - Still open: multi-surface path sets, locale-aware marks, icon-only Button integration depth.
14
14
 
15
- Registry kinds: `stroke` (outlined UI chrome and tools), `text-badge` (proprietary converter names such as `tool.base64` → `B64`). `feature.ssr` is intentionally absent — use title copy instead of an icon.
15
+ Registry kinds: `stroke` (outlined UI chrome and tools), `text-badge` (proprietary converter names such as `tool.base64` → `B64`). `text-badge` is the documented exception to the own-SVG rule: the mark is a real text label rendered as content in a bounded chip, not a font glyph or emoji standing in for an unknown silhouette. `feature.ssr` is intentionally absent — use title copy instead of an icon.
16
16
 
17
17
  Verify:
18
18
 
@@ -3,8 +3,4 @@ import type { IconDef } from './icon-types.ts';
3
3
  export type { IconDef, IconFillDef, IconMixedDef, IconMixedNode, IconStrokeDef, IconTextBadgeDef } from './icon-types.ts';
4
4
  export { DEFAULT_STROKE_WIDTH } from './icon-types.ts';
5
5
  export declare const REGISTRY: Record<string, IconDef>;
6
- export declare const LEGACY_ICON_ALIASES: Record<string, string>;
7
- export declare function resolveIconName(name: string): string;
8
6
  export declare function resolveIconDef(name: string): IconDef | null;
9
- /** @deprecated Prefer `resolveIconDef`. Returns primary path data for fill icons or first stroke path. */
10
- export declare function resolveIconPath(name: string): string;
package/dist/registry.js CHANGED
@@ -5,71 +5,13 @@ export const REGISTRY = {
5
5
  ...STROKE_ICONS,
6
6
  ...TEXT_BADGE_ICONS,
7
7
  };
8
- export const LEGACY_ICON_ALIASES = {
9
- check: 'action.check',
10
- close: 'action.close',
11
- search: 'action.search',
12
- 'chevron-down': 'action.chevron-down',
13
- 'chevron-right': 'action.chevron-right',
14
- 'chevron-up': 'action.chevron-up',
15
- 'chevron-left': 'action.chevron-left',
16
- minus: 'action.minus',
17
- more: 'action.more',
18
- filter: 'action.filter',
19
- calendar: 'action.calendar',
20
- upload: 'action.upload',
21
- download: 'action.download',
22
- sort: 'action.sort',
23
- external: 'action.external',
24
- 'arrow-right': 'action.arrow-right',
25
- 'arrow-left': 'action.arrow-left',
26
- trash: 'action.trash',
27
- edit: 'action.edit',
28
- refresh: 'action.refresh',
29
- history: 'action.history',
30
- moon: 'action.moon',
31
- sun: 'action.sun',
32
- monitor: 'action.monitor',
33
- info: 'status.info',
34
- warning: 'status.warning',
35
- success: 'status.success',
36
- danger: 'status.danger',
37
- menu: 'action.menu',
38
- plus: 'action.plus',
39
- home: 'nav.home',
40
- language: 'nav.language',
41
- copy: 'action.copy',
42
- discount: 'tool.percentage',
43
- };
44
- export function resolveIconName(name) {
45
- const key = String(name || '').trim();
46
- if (!key)
47
- return '';
48
- if (LEGACY_ICON_ALIASES[key])
49
- return LEGACY_ICON_ALIASES[key];
50
- return key;
51
- }
52
8
  export function resolveIconDef(name) {
53
- const key = resolveIconName(name);
9
+ const key = String(name || '').trim();
54
10
  if (!key)
55
11
  return null;
56
12
  const def = REGISTRY[key];
57
13
  if (!def) {
58
- throw new Error(`@vmz/ui-icons: unknown icon name "${name}" (resolved: "${key}")`);
14
+ throw new Error(`@vmz/ui-icons: unknown icon name "${key}" — expected a dotted semantic name from the registry (action.*, nav.*, status.*, tool.*, feature.*)`);
59
15
  }
60
16
  return def;
61
17
  }
62
- /** @deprecated Prefer `resolveIconDef`. Returns primary path data for fill icons or first stroke path. */
63
- export function resolveIconPath(name) {
64
- const def = resolveIconDef(name);
65
- if (!def)
66
- return '';
67
- if (def.kind === 'fill')
68
- return def.d;
69
- if (def.kind === 'text-badge')
70
- return '';
71
- if (def.kind === 'stroke')
72
- return def.paths[0] ?? '';
73
- const pathNode = def.nodes.find((node) => node.tag === 'path');
74
- return pathNode?.attrs.d ?? '';
75
- }
package/package.json CHANGED
@@ -25,7 +25,7 @@
25
25
  "license": "MIT",
26
26
  "name": "@vmz/ui-icons",
27
27
  "peerDependencies": {
28
- "@vmz/ui": "0.3.10"
28
+ "@vmz/ui": "0.3.12"
29
29
  },
30
30
  "publishConfig": {
31
31
  "access": "public"
@@ -39,5 +39,5 @@
39
39
  "build": "tsc -p tsconfig.json"
40
40
  },
41
41
  "type": "module",
42
- "version": "0.3.10"
42
+ "version": "0.3.12"
43
43
  }
package/src/Icon.vmz CHANGED
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <span data-vmz-ui="icon" :data-icon="name" :data-size="size" :role="roleAttr" :aria-hidden="hiddenAttr" :aria-label="labelAttr" class="vmz-ui-icon">
2
+ <span data-vmz-ui="icon" :data-icon="name" :data-size="size" :role="roleAttr()" :aria-hidden="hiddenAttr()" :aria-label="labelAttr()" class="vmz-ui-icon">
3
3
  <span v-if="isTextBadge()" class="vmz-ui-icon__badge">
4
4
  {{ badgeLabel() }}
5
5
  </span>
@@ -56,21 +56,15 @@
56
56
  }
57
57
 
58
58
  .vmz-ui-icon[data-size="sm"] {
59
- width: 1.5rem;
60
- height: 1.5rem;
61
- font-size: 0.95rem;
59
+ font-size: 16px;
62
60
  }
63
61
 
64
62
  .vmz-ui-icon[data-size="md"] {
65
- width: 2.35rem;
66
- height: 2.35rem;
67
- font-size: 1.15rem;
63
+ font-size: 20px;
68
64
  }
69
65
 
70
66
  .vmz-ui-icon[data-size="lg"] {
71
- width: 2.85rem;
72
- height: 2.85rem;
73
- font-size: 1.35rem;
67
+ font-size: 24px;
74
68
  }
75
69
  </style>
76
70
  <script client>
@@ -84,17 +78,28 @@ export default class Icon {
84
78
  static __vmzHostBox = "contents";
85
79
  /** Semantic icon id, e.g. tool.base64 / action.search */
86
80
  public name: string = "";
87
- /** sm | md | lg */
81
+ /** sm | md | lg → 16 / 20 / 24 px glyph */
88
82
  public size: string = "md";
89
83
  /** Accessible name; empty ⇒ decorative */
90
84
  public label: string = "";
85
+ /** Optional role override when labelled; defaults to `img`. */
86
+ public role: string = "";
91
87
 
92
- roleAttr = "";
93
- hiddenAttr = "true";
94
- labelAttr = "";
88
+ labelText() {
89
+ return String(this.label || "").trim();
90
+ }
91
+
92
+ roleAttr() {
93
+ if (!this.labelText()) return "";
94
+ return String(this.role || "").trim() || "img";
95
+ }
95
96
 
96
- onMount() {
97
- this.syncA11y();
97
+ hiddenAttr() {
98
+ return this.labelText() ? "" : "true";
99
+ }
100
+
101
+ labelAttr() {
102
+ return this.labelText();
98
103
  }
99
104
 
100
105
  iconDef() {
@@ -219,18 +224,5 @@ export default class Icon {
219
224
  strokeWidth: node.attrs["stroke-width"] ?? DEFAULT_STROKE_WIDTH,
220
225
  }));
221
226
  }
222
-
223
- syncA11y() {
224
- const labelled = String(this.label || "").trim();
225
- if (labelled) {
226
- this.roleAttr = "img";
227
- this.hiddenAttr = "";
228
- this.labelAttr = labelled;
229
- } else {
230
- this.roleAttr = "";
231
- this.hiddenAttr = "true";
232
- this.labelAttr = "";
233
- }
234
- }
235
227
  }
236
228
  </script>
package/src/registry.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /** Shared icon registry for `@vmz/ui-icons` and optional app-level Icon shims. */
2
- import type { IconDef, IconFillDef } from './icon-types.ts';
2
+ import type { IconDef } from './icon-types.ts';
3
3
  import { DEFAULT_STROKE_WIDTH } from './icon-types.ts';
4
4
  import { STROKE_ICONS } from './icons-stroke.ts';
5
5
  import { TEXT_BADGE_ICONS } from './icons-text-badge.ts';
@@ -12,67 +12,14 @@ export const REGISTRY: Record<string, IconDef> = {
12
12
  ...TEXT_BADGE_ICONS,
13
13
  };
14
14
 
15
- export const LEGACY_ICON_ALIASES: Record<string, string> = {
16
- check: 'action.check',
17
- close: 'action.close',
18
- search: 'action.search',
19
- 'chevron-down': 'action.chevron-down',
20
- 'chevron-right': 'action.chevron-right',
21
- 'chevron-up': 'action.chevron-up',
22
- 'chevron-left': 'action.chevron-left',
23
- minus: 'action.minus',
24
- more: 'action.more',
25
- filter: 'action.filter',
26
- calendar: 'action.calendar',
27
- upload: 'action.upload',
28
- download: 'action.download',
29
- sort: 'action.sort',
30
- external: 'action.external',
31
- 'arrow-right': 'action.arrow-right',
32
- 'arrow-left': 'action.arrow-left',
33
- trash: 'action.trash',
34
- edit: 'action.edit',
35
- refresh: 'action.refresh',
36
- history: 'action.history',
37
- moon: 'action.moon',
38
- sun: 'action.sun',
39
- monitor: 'action.monitor',
40
- info: 'status.info',
41
- warning: 'status.warning',
42
- success: 'status.success',
43
- danger: 'status.danger',
44
- menu: 'action.menu',
45
- plus: 'action.plus',
46
- home: 'nav.home',
47
- language: 'nav.language',
48
- copy: 'action.copy',
49
- discount: 'tool.percentage',
50
- };
51
-
52
- export function resolveIconName(name: string): string {
53
- const key = String(name || '').trim();
54
- if (!key) return '';
55
- if (LEGACY_ICON_ALIASES[key]) return LEGACY_ICON_ALIASES[key];
56
- return key;
57
- }
58
-
59
15
  export function resolveIconDef(name: string): IconDef | null {
60
- const key = resolveIconName(name);
16
+ const key = String(name || '').trim();
61
17
  if (!key) return null;
62
18
  const def = REGISTRY[key];
63
19
  if (!def) {
64
- throw new Error(`@vmz/ui-icons: unknown icon name "${name}" (resolved: "${key}")`);
20
+ throw new Error(
21
+ `@vmz/ui-icons: unknown icon name "${key}" — expected a dotted semantic name from the registry (action.*, nav.*, status.*, tool.*, feature.*)`,
22
+ );
65
23
  }
66
24
  return def;
67
25
  }
68
-
69
- /** @deprecated Prefer `resolveIconDef`. Returns primary path data for fill icons or first stroke path. */
70
- export function resolveIconPath(name: string): string {
71
- const def = resolveIconDef(name);
72
- if (!def) return '';
73
- if (def.kind === 'fill') return def.d;
74
- if (def.kind === 'text-badge') return '';
75
- if (def.kind === 'stroke') return def.paths[0] ?? '';
76
- const pathNode = def.nodes.find((node) => node.tag === 'path');
77
- return pathNode?.attrs.d ?? '';
78
- }