@hamur/icon 0.0.2 → 0.0.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.
@@ -0,0 +1,60 @@
1
+ <script lang="ts">
2
+ import { untrack } from "svelte"
3
+ import type { SvgNode } from "hamur/adapter"
4
+ import { useApp, useRuntimeConfig, useHead } from "@hamur/adapter-svelte"
5
+ import { svgAttributes, svgValue } from "../render.ts"
6
+ import { iconHead, icons } from "../runtime/index.ts"
7
+ import type { IconDefaults, IconCustomize, IconMode } from "../types.ts"
8
+
9
+ type Props = {
10
+ name: string
11
+ size?: string | number
12
+ mode?: IconMode
13
+ title?: string
14
+ customize?: IconCustomize
15
+ class?: string
16
+ [attribute: string]: unknown
17
+ }
18
+
19
+ let { name, size, mode, title, customize, class: className, ...rest }: Props = $props()
20
+ const id = $props.id()
21
+ const uid = id.replace(/[^\w-]/g, "_")
22
+ const app = useApp()
23
+ const config = useRuntimeConfig().public as { icon?: IconDefaults }
24
+ const seen = icons.version()
25
+ let answers = $state(0)
26
+ $effect(() => {
27
+ if (icons.version() !== seen) untrack(() => answers++)
28
+ return icons.subscribe(() => answers++)
29
+ })
30
+ const view = $derived(
31
+ (answers,
32
+ icons.view(
33
+ app,
34
+ {
35
+ name,
36
+ size,
37
+ mode,
38
+ title,
39
+ customize,
40
+ class: className,
41
+ labelled: rest["aria-label"] != null || rest["aria-labelledby"] != null,
42
+ },
43
+ config.icon,
44
+ )),
45
+ )
46
+ useHead(() => iconHead(view))
47
+ </script>
48
+
49
+ {#snippet draw(node: SvgNode)}{#if typeof node === "string" || Array.isArray(node)}{svgValue(
50
+ node,
51
+ uid,
52
+ )}{:else}<svelte:element this={node.tag} xmlns="http://www.w3.org/2000/svg" {...svgAttributes(node, uid)}
53
+ >{#each node.children as child}{@render draw(child)}{/each}</svelte:element
54
+ >{/if}{/snippet}
55
+
56
+ {#if view.mode === "css"}<span {...view.attrs} {...rest}></span>{:else}<svg {...view.attrs} {...rest}
57
+ >{#if view.title !== undefined}<title>{view.title}</title>{/if}{#each view.nodes as node}{@render draw(
58
+ node,
59
+ )}{/each}</svg
60
+ >{/if}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hamur/icon",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -80,14 +80,14 @@
80
80
  ],
81
81
  "dependencies": {},
82
82
  "peerDependencies": {
83
- "hamur": "^0.0.2",
84
- "@hamur/adapter-react": "^0.0.2",
85
- "@hamur/adapter-vue": "^0.0.2",
86
- "@hamur/adapter-preact": "^0.0.2",
87
- "@hamur/adapter-svelte": "^0.0.2",
88
- "@hamur/adapter-solid": "^0.0.2",
89
- "@hamur/adapter-html": "^0.0.2",
90
- "@hamur/adapter-angular": "^0.0.2",
83
+ "hamur": ">=0.0.4 <0.1.0",
84
+ "@hamur/adapter-react": ">=0.0.4 <0.1.0",
85
+ "@hamur/adapter-vue": ">=0.0.4 <0.1.0",
86
+ "@hamur/adapter-preact": ">=0.0.4 <0.1.0",
87
+ "@hamur/adapter-svelte": ">=0.0.4 <0.1.0",
88
+ "@hamur/adapter-solid": ">=0.0.4 <0.1.0",
89
+ "@hamur/adapter-html": ">=0.0.4 <0.1.0",
90
+ "@hamur/adapter-angular": ">=0.0.4 <0.1.0",
91
91
  "react": "^19.3.1",
92
92
  "preact": "^11.0.2",
93
93
  "vue": "^3.5.44",
package/src/env.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  interface ImportMeta {
2
2
  readonly dev?: boolean
3
3
  readonly server?: boolean
4
- readonly hot?: unknown
5
4
  }
6
5
 
7
6
  declare module "#hamur/icon/options" {