mertani-web-toolkit 0.1.68 → 0.1.70
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.
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { iconMap } from '../../icons/index.js';
|
|
3
3
|
import type { TIconName } from '../../icons/index.js';
|
|
4
|
+
import * as lucideIcons from 'lucide-svelte';
|
|
5
|
+
import IconifyIcon from '@iconify/svelte';
|
|
4
6
|
|
|
5
7
|
interface IconProps {
|
|
6
8
|
name: TIconName;
|
|
@@ -14,7 +16,36 @@
|
|
|
14
16
|
|
|
15
17
|
const { name, width, height, color, style, onclick, opacity }: IconProps = $props();
|
|
16
18
|
|
|
17
|
-
const IconComponent = $derived(iconMap[name]);
|
|
19
|
+
const IconComponent = $derived(iconMap[name as keyof typeof iconMap]);
|
|
20
|
+
|
|
21
|
+
// cek apakah ada di lucide
|
|
22
|
+
// lucide pakai PascalCase: "arrow-right" → "ArrowRight"
|
|
23
|
+
const lucideName = $derived(
|
|
24
|
+
name
|
|
25
|
+
.split('-')
|
|
26
|
+
.map((w) => w.charAt(0).toUpperCase() + w.slice(1))
|
|
27
|
+
.join('')
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
31
|
+
const LucideIcon = $derived((lucideIcons as any)[lucideName] ?? null);
|
|
32
|
+
|
|
33
|
+
// heuristic: jika ada colon ":" biasanya itu iconify set
|
|
34
|
+
const isIconify = $derived(name.includes(':'));
|
|
35
|
+
|
|
36
|
+
const sizeValue = $derived(() => {
|
|
37
|
+
if (typeof width === 'number') return width;
|
|
38
|
+
if (typeof width === 'string') {
|
|
39
|
+
const parsed = parseInt(width);
|
|
40
|
+
if (!isNaN(parsed)) return parsed;
|
|
41
|
+
}
|
|
42
|
+
if (typeof height === 'number') return height;
|
|
43
|
+
if (typeof height === 'string') {
|
|
44
|
+
const parsed = parseInt(height);
|
|
45
|
+
if (!isNaN(parsed)) return parsed;
|
|
46
|
+
}
|
|
47
|
+
return 24;
|
|
48
|
+
});
|
|
18
49
|
|
|
19
50
|
const iconWidth = $derived(
|
|
20
51
|
width !== undefined ? (typeof width === 'number' ? `${width}px` : width) : 'auto'
|
|
@@ -56,7 +87,7 @@
|
|
|
56
87
|
</script>
|
|
57
88
|
|
|
58
89
|
{#if IconComponent}
|
|
59
|
-
{@const Component = IconComponent
|
|
90
|
+
{@const Component = IconComponent}
|
|
60
91
|
<div
|
|
61
92
|
class="icon-wrapper"
|
|
62
93
|
class:icon-clickable={onclick !== undefined}
|
|
@@ -74,6 +105,39 @@
|
|
|
74
105
|
<Component />
|
|
75
106
|
</div>
|
|
76
107
|
</div>
|
|
108
|
+
{:else if LucideIcon}
|
|
109
|
+
<div
|
|
110
|
+
class="icon-wrapper"
|
|
111
|
+
class:icon-clickable={onclick !== undefined}
|
|
112
|
+
style={combinedStyles()}
|
|
113
|
+
onclick={onclick ? handleClick : undefined}
|
|
114
|
+
role={onclick ? 'button' : undefined}
|
|
115
|
+
onkeydown={(e) => {
|
|
116
|
+
if (onclick && (e.key === 'Enter' || e.key === ' ')) {
|
|
117
|
+
e.preventDefault();
|
|
118
|
+
handleClick();
|
|
119
|
+
}
|
|
120
|
+
}}
|
|
121
|
+
>
|
|
122
|
+
<!-- svelte-ignore svelte_component_deprecated -->
|
|
123
|
+
<svelte:component this={LucideIcon} size={sizeValue()} color={iconColor} />
|
|
124
|
+
</div>
|
|
125
|
+
{:else if isIconify}
|
|
126
|
+
<div
|
|
127
|
+
class="icon-wrapper"
|
|
128
|
+
class:icon-clickable={onclick !== undefined}
|
|
129
|
+
style={combinedStyles()}
|
|
130
|
+
onclick={onclick ? handleClick : undefined}
|
|
131
|
+
role={onclick ? 'button' : undefined}
|
|
132
|
+
onkeydown={(e) => {
|
|
133
|
+
if (onclick && (e.key === 'Enter' || e.key === ' ')) {
|
|
134
|
+
e.preventDefault();
|
|
135
|
+
handleClick();
|
|
136
|
+
}
|
|
137
|
+
}}
|
|
138
|
+
>
|
|
139
|
+
<IconifyIcon icon={name} width={sizeValue()} height={sizeValue()} style="color: {iconColor}" />
|
|
140
|
+
</div>
|
|
77
141
|
{:else}
|
|
78
142
|
<span class="icon-error">Icon "{name}" tidak ditemukan</span>
|
|
79
143
|
{/if}
|
package/dist/icons/index.js
CHANGED
|
@@ -259,8 +259,8 @@ export const iconMap = {
|
|
|
259
259
|
berawan: Berawan,
|
|
260
260
|
'berawan-tebal': BerawanTebal,
|
|
261
261
|
'udara-kabut': UdaraKabut,
|
|
262
|
-
|
|
263
|
-
|
|
262
|
+
kabut: Kabut,
|
|
263
|
+
asap: Asap,
|
|
264
264
|
'hujan-ringan': HujanRingan,
|
|
265
265
|
'hujan-sedang': HujanSedang,
|
|
266
266
|
'hujan-lebat': HujanLebat,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mertani-web-toolkit",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.70",
|
|
4
4
|
"homepage": "https://storybook.mertani.com/",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "vite dev",
|
|
@@ -79,8 +79,10 @@
|
|
|
79
79
|
"svelte"
|
|
80
80
|
],
|
|
81
81
|
"dependencies": {
|
|
82
|
+
"@iconify/svelte": "^5.2.1",
|
|
82
83
|
"leaflet.markercluster": "^1.5.3",
|
|
83
84
|
"leaflet-velocity": "^1.5.0",
|
|
85
|
+
"lucide-svelte": "^1.0.1",
|
|
84
86
|
"tailwind-merge": "^3.4.0",
|
|
85
87
|
"topojson-client": "^3.1.0"
|
|
86
88
|
}
|