@ttdk-design-system/library-vue 0.0.0-stage → 1.0.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.
- package/AI_GUIDE.md +6518 -0
- package/llms.txt +6518 -0
- package/package.json +1096 -4
- package/src/core/index.ts +2 -0
- package/src/core/tailwind-preset.cjs +62 -0
- package/src/core/tailwind-preset.ts +85 -0
- package/src/core/theme/tokens.css +663 -0
- package/src/core/types.ts +836 -0
- package/src/index.ts +17 -0
- package/src/tailwind-preset.cjs +62 -0
- package/src/tailwind-preset.ts +85 -0
- package/src/types.ts +1 -0
- package/src/web/accordion/AI_GUIDE.md +149 -0
- package/src/web/accordion/accordion.css +1 -0
- package/src/web/accordion/accordion.vue +432 -0
- package/src/web/accordion/accordion.vue.d.ts +227 -0
- package/src/web/accordion/index.ts +3 -0
- package/src/web/accordion/manifest.json +351 -0
- package/src/web/alert/AI_GUIDE.md +139 -0
- package/src/web/alert/alert.css +1 -0
- package/src/web/alert/alert.vue +290 -0
- package/src/web/alert/alert.vue.d.ts +154 -0
- package/src/web/alert/index.ts +3 -0
- package/src/web/alert/manifest.json +240 -0
- package/src/web/avatar/AI_GUIDE.md +118 -0
- package/src/web/avatar/avatar.css +1 -0
- package/src/web/avatar/avatar.vue +217 -0
- package/src/web/avatar/avatar.vue.d.ts +135 -0
- package/src/web/avatar/index.ts +3 -0
- package/src/web/avatar/manifest.json +195 -0
- package/src/web/badge/AI_GUIDE.md +94 -0
- package/src/web/badge/badge.css +1 -0
- package/src/web/badge/badge.vue +135 -0
- package/src/web/badge/badge.vue.d.ts +108 -0
- package/src/web/badge/index.ts +3 -0
- package/src/web/badge/manifest.json +141 -0
- package/src/web/banner/AI_GUIDE.md +130 -0
- package/src/web/banner/banner.css +1 -0
- package/src/web/banner/banner.vue +303 -0
- package/src/web/banner/banner.vue.d.ts +162 -0
- package/src/web/banner/index.ts +3 -0
- package/src/web/banner/manifest.json +240 -0
- package/src/web/breadcrumb/AI_GUIDE.md +120 -0
- package/src/web/breadcrumb/breadcrumb.css +1 -0
- package/src/web/breadcrumb/breadcrumb.vue +313 -0
- package/src/web/breadcrumb/breadcrumb.vue.d.ts +139 -0
- package/src/web/breadcrumb/index.ts +3 -0
- package/src/web/breadcrumb/manifest.json +225 -0
- package/src/web/button/AI_GUIDE.md +121 -0
- package/src/web/button/button.css +1 -0
- package/src/web/button/button.vue +283 -0
- package/src/web/button/button.vue.d.ts +147 -0
- package/src/web/button/index.ts +3 -0
- package/src/web/button/manifest.json +177 -0
- package/src/web/calendar/AI_GUIDE.md +151 -0
- package/src/web/calendar/calendar.css +1 -0
- package/src/web/calendar/calendar.vue +1536 -0
- package/src/web/calendar/calendar.vue.d.ts +261 -0
- package/src/web/calendar/index.ts +3 -0
- package/src/web/calendar/manifest.json +470 -0
- package/src/web/card/AI_GUIDE.md +133 -0
- package/src/web/card/card.css +1 -0
- package/src/web/card/card.vue +423 -0
- package/src/web/card/card.vue.d.ts +232 -0
- package/src/web/card/index.ts +3 -0
- package/src/web/card/manifest.json +357 -0
- package/src/web/checkbox/AI_GUIDE.md +146 -0
- package/src/web/checkbox/checkbox.css +1 -0
- package/src/web/checkbox/checkbox.vue +304 -0
- package/src/web/checkbox/checkbox.vue.d.ts +189 -0
- package/src/web/checkbox/index.ts +3 -0
- package/src/web/checkbox/manifest.json +294 -0
- package/src/web/chip/AI_GUIDE.md +186 -0
- package/src/web/chip/chip.css +1 -0
- package/src/web/chip/chip.vue +220 -0
- package/src/web/chip/chip.vue.d.ts +140 -0
- package/src/web/chip/index.ts +3 -0
- package/src/web/chip/manifest.json +186 -0
- package/src/web/dropdown/AI_GUIDE.md +167 -0
- package/src/web/dropdown/dropdown.css +1 -0
- package/src/web/dropdown/dropdown.vue +1257 -0
- package/src/web/dropdown/dropdown.vue.d.ts +381 -0
- package/src/web/dropdown/index.ts +3 -0
- package/src/web/dropdown/manifest.json +576 -0
- package/src/web/flex/AI_GUIDE.md +113 -0
- package/src/web/flex/flex-item.vue +94 -0
- package/src/web/flex/flex-item.vue.d.ts +84 -0
- package/src/web/flex/flex.css +1 -0
- package/src/web/flex/flex.vue +103 -0
- package/src/web/flex/flex.vue.d.ts +92 -0
- package/src/web/flex/index.ts +5 -0
- package/src/web/flex/manifest.json +162 -0
- package/src/web/form/index.ts +7 -0
- package/src/web/grid/AI_GUIDE.md +112 -0
- package/src/web/grid/grid-item.vue +109 -0
- package/src/web/grid/grid-item.vue.d.ts +99 -0
- package/src/web/grid/grid.css +1 -0
- package/src/web/grid/grid.vue +94 -0
- package/src/web/grid/grid.vue.d.ts +84 -0
- package/src/web/grid/index.ts +5 -0
- package/src/web/grid/manifest.json +153 -0
- package/src/web/index.ts +86 -0
- package/src/web/input/AI_GUIDE.md +159 -0
- package/src/web/input/index.ts +3 -0
- package/src/web/input/input.css +1 -0
- package/src/web/input/input.vue +521 -0
- package/src/web/input/input.vue.d.ts +274 -0
- package/src/web/input/manifest.json +465 -0
- package/src/web/input-number/AI_GUIDE.md +164 -0
- package/src/web/input-number/index.ts +3 -0
- package/src/web/input-number/input-number.css +1 -0
- package/src/web/input-number/input-number.vue +1153 -0
- package/src/web/input-number/input-number.vue.d.ts +343 -0
- package/src/web/input-number/manifest.json +575 -0
- package/src/web/modal/AI_GUIDE.md +171 -0
- package/src/web/modal/index.ts +3 -0
- package/src/web/modal/manifest.json +375 -0
- package/src/web/modal/modal.css +1 -0
- package/src/web/modal/modal.vue +344 -0
- package/src/web/modal/modal.vue.d.ts +64 -0
- package/src/web/pagination/AI_GUIDE.md +148 -0
- package/src/web/pagination/index.ts +21 -0
- package/src/web/pagination/manifest.json +432 -0
- package/src/web/pagination/pagination-content.vue +42 -0
- package/src/web/pagination/pagination-content.vue.d.ts +28 -0
- package/src/web/pagination/pagination-ellipsis.vue +55 -0
- package/src/web/pagination/pagination-ellipsis.vue.d.ts +28 -0
- package/src/web/pagination/pagination-first.vue +161 -0
- package/src/web/pagination/pagination-first.vue.d.ts +67 -0
- package/src/web/pagination/pagination-item.vue +42 -0
- package/src/web/pagination/pagination-item.vue.d.ts +28 -0
- package/src/web/pagination/pagination-last.vue +161 -0
- package/src/web/pagination/pagination-last.vue.d.ts +67 -0
- package/src/web/pagination/pagination-link.vue +118 -0
- package/src/web/pagination/pagination-link.vue.d.ts +61 -0
- package/src/web/pagination/pagination-next.vue +160 -0
- package/src/web/pagination/pagination-next.vue.d.ts +68 -0
- package/src/web/pagination/pagination-previous.vue +160 -0
- package/src/web/pagination/pagination-previous.vue.d.ts +68 -0
- package/src/web/pagination/pagination.css +1 -0
- package/src/web/pagination/pagination.vue +730 -0
- package/src/web/pagination/pagination.vue.d.ts +247 -0
- package/src/web/popover/AI_GUIDE.md +163 -0
- package/src/web/popover/index.ts +3 -0
- package/src/web/popover/manifest.json +396 -0
- package/src/web/popover/popover.css +1 -0
- package/src/web/popover/popover.vue +579 -0
- package/src/web/popover/popover.vue.d.ts +83 -0
- package/src/web/radio/AI_GUIDE.md +155 -0
- package/src/web/radio/index.ts +3 -0
- package/src/web/radio/manifest.json +294 -0
- package/src/web/radio/radio.css +1 -0
- package/src/web/radio/radio.vue +288 -0
- package/src/web/radio/radio.vue.d.ts +182 -0
- package/src/web/selectbox/AI_GUIDE.md +216 -0
- package/src/web/selectbox/index.ts +3 -0
- package/src/web/selectbox/manifest.json +477 -0
- package/src/web/selectbox/selectbox.css +1 -0
- package/src/web/selectbox/selectbox.vue +1024 -0
- package/src/web/selectbox/selectbox.vue.d.ts +300 -0
- package/src/web/sonner/AI_GUIDE.md +98 -0
- package/src/web/sonner/index.ts +114 -0
- package/src/web/sonner/manifest.json +132 -0
- package/src/web/sonner/sonner.css +1 -0
- package/src/web/sonner/sonner.vue +180 -0
- package/src/web/sonner/sonner.vue.d.ts +113 -0
- package/src/web/table/AI_GUIDE.md +145 -0
- package/src/web/table/index.ts +34 -0
- package/src/web/table/manifest.json +168 -0
- package/src/web/table/table-body.vue +42 -0
- package/src/web/table/table-body.vue.d.ts +28 -0
- package/src/web/table/table-caption.vue +42 -0
- package/src/web/table/table-caption.vue.d.ts +28 -0
- package/src/web/table/table-cell.vue +71 -0
- package/src/web/table/table-cell.vue.d.ts +49 -0
- package/src/web/table/table-empty.vue +105 -0
- package/src/web/table/table-empty.vue.d.ts +57 -0
- package/src/web/table/table-footer.vue +42 -0
- package/src/web/table/table-footer.vue.d.ts +28 -0
- package/src/web/table/table-head.vue +78 -0
- package/src/web/table/table-head.vue.d.ts +50 -0
- package/src/web/table/table-header.vue +42 -0
- package/src/web/table/table-header.vue.d.ts +28 -0
- package/src/web/table/table-row.vue +70 -0
- package/src/web/table/table-row.vue.d.ts +44 -0
- package/src/web/table/table.css +1 -0
- package/src/web/table/table.vue +298 -0
- package/src/web/table/table.vue.d.ts +119 -0
- package/src/web/tabs/AI_GUIDE.md +150 -0
- package/src/web/tabs/index.ts +2 -0
- package/src/web/tabs/manifest.json +315 -0
- package/src/web/tabs/tabs.css +1 -0
- package/src/web/tabs/tabs.vue +164 -0
- package/src/web/tabs/tabs.vue.d.ts +60 -0
- package/src/web/text/AI_GUIDE.md +129 -0
- package/src/web/text/index.ts +2 -0
- package/src/web/text/manifest.json +195 -0
- package/src/web/text/text.css +1 -0
- package/src/web/text/text.vue +195 -0
- package/src/web/text/text.vue.d.ts +161 -0
- package/src/web/textarea/AI_GUIDE.md +141 -0
- package/src/web/textarea/index.ts +3 -0
- package/src/web/textarea/manifest.json +438 -0
- package/src/web/textarea/textarea.css +1 -0
- package/src/web/textarea/textarea.vue +458 -0
- package/src/web/textarea/textarea.vue.d.ts +265 -0
- package/src/web/tooltip/AI_GUIDE.md +110 -0
- package/src/web/tooltip/index.ts +3 -0
- package/src/web/tooltip/manifest.json +222 -0
- package/src/web/tooltip/tooltip.css +1 -0
- package/src/web/tooltip/tooltip.vue +417 -0
- package/src/web/tooltip/tooltip.vue.d.ts +150 -0
- package/src/webview/bottomsheet/AI_GUIDE.md +141 -0
- package/src/webview/bottomsheet/bottomsheet.css +1 -0
- package/src/webview/bottomsheet/bottomsheet.vue +441 -0
- package/src/webview/bottomsheet/bottomsheet.vue.d.ts +178 -0
- package/src/webview/bottomsheet/index.ts +4 -0
- package/src/webview/bottomsheet/manifest.json +377 -0
- package/src/webview/button/AI_GUIDE.md +79 -0
- package/src/webview/button/button-ios.css +1 -0
- package/src/webview/button/button-ios.vue +138 -0
- package/src/webview/button/button-ios.vue.d.ts +102 -0
- package/src/webview/button/button-material.css +1 -0
- package/src/webview/button/button-material.vue +138 -0
- package/src/webview/button/button-material.vue.d.ts +102 -0
- package/src/webview/button/index.ts +7 -0
- package/src/webview/button/manifest.json +148 -0
- package/src/webview/index.ts +7 -0
- package/tailwind-preset.cjs +62 -0
- package/tailwind-preset.js +62 -0
- package/ttdk-manifest.json +10188 -0
- package/README.md +0 -3
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# <Avatar /> — TTDK Component Reference
|
|
2
|
+
|
|
3
|
+
Komponen Avatar untuk menampilkan foto profil, inisial nama, atau ikon pengguna.
|
|
4
|
+
|
|
5
|
+
## 1. Stylesheets & Theming (Pure CSS)
|
|
6
|
+
Import the corresponding stylesheet for the theme you wish to use:
|
|
7
|
+
- **COMMON Theme**: `import "@ttdk-design-system/library-<react|vue|svelte>/web/avatar/avatar.css";`
|
|
8
|
+
|
|
9
|
+
## 2. Subpath Component Import
|
|
10
|
+
```ts
|
|
11
|
+
// React
|
|
12
|
+
import Avatar from "@ttdk-design-system/library-react/web/avatar";
|
|
13
|
+
|
|
14
|
+
// Vue 3
|
|
15
|
+
import Avatar from "@ttdk-design-system/library-vue/web/avatar";
|
|
16
|
+
|
|
17
|
+
// Svelte
|
|
18
|
+
import Avatar from "@ttdk-design-system/library-svelte/web/avatar";
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## 3. Props & API Reference
|
|
22
|
+
|
|
23
|
+
| Prop | Type | Default | Description |
|
|
24
|
+
| :--- | :--- | :--- | :--- |
|
|
25
|
+
| `src?` | `string` | `-` | URL gambar profil avatar. Jika kosong atau gagal dimuat, tampilan otomatis beralih ke `initials` atau ikon pengguna bawaan. |
|
|
26
|
+
| `alt?` | `string` | `-` | Teks alternatif (alt) untuk elemen gambar avatar. |
|
|
27
|
+
| `initials?` | `string` | `-` | Teks inisial pengguna yang ditampilkan di dalam lingkaran avatar (misal: "NA", "SR"). Ditampilkan apabila `src` tidak tersedia atau gagal dimuat. |
|
|
28
|
+
| `size?` | `'xs' | 'sm' | 'md' | 'lg' | 'xl'` | `md` | Skala ukuran avatar: - `'xs'`: Lingkaran 28px. - `'sm'`: Lingkaran 32px. - `'md'`: Lingkaran 40px (standar). - `'lg'`: Lingkaran 48px. - `'xl'`: Lingkaran 56px. |
|
|
29
|
+
| `variant?` | `'info' | 'primary' | 'success' | 'warning' | 'danger' | 'neutral'` | `info` | Varian warna semantik untuk latar & teks/ikon fallback avatar: - `'info'`: Biru informasi sesuai standar profil (default). - `'primary'`: Brand Teal utama. - `'success'`: Hijau sukses. - `'warning'`: Kuning / amber peringatan. - `'danger'`: Merah bahaya. - `'neutral'`: Abu-abu netral. |
|
|
30
|
+
| `rounded?` | `'none' | 'sm' | 'md' | 'lg' | 'full'` | `full` | Sudut kelengkungan lingkaran avatar: - `'full'`: Lingkaran penuh 9999px (default). - `'lg'`: Radius membulat 12px. - `'md'`: Radius sedang 8px. - `'sm'`: Radius halus 4px. - `'none'`: Persegi tajam 0px. |
|
|
31
|
+
| `status?` | `'online' | 'offline' | 'verified'` | `-` | Indikator status kehadiran atau verifikasi di pojok kanan bawah lingkaran avatar: - `'online'`: Titik hijau status aktif. - `'offline'`: Titik abu-abu status luring. - `'verified'`: Lencana perisai biru terverifikasi. |
|
|
32
|
+
| `icon?` | `any` | `-` | Ikon kustom untuk menggantikan ikon pengguna bawaan saat `src` dan `initials` tidak diisi. |
|
|
33
|
+
| `iconColor?` | `string` | `-` | Warna kustom untuk ikon di dalam avatar. |
|
|
34
|
+
| `interactive?` | `boolean` | `false` | Menjadikan komponen avatar interaktif (memiliki efek hover & fokus keyboard). |
|
|
35
|
+
| `disabled?` | `boolean` | `false` | Menonaktifkan interaksi klik pada avatar. |
|
|
36
|
+
| `onClick?` | `(event?: any) => void` | `-` | Event handler saat komponen avatar diklik. |
|
|
37
|
+
| `onImageError?` | `(event?: any) => void` | `-` | Event handler saat gambar `src` gagal dimuat. |
|
|
38
|
+
| `ui?` | `UiProps` | `-` | Kustomisasi visual granular pada elemen root melalui style-like object (+ support pseudo-class: hover, active). |
|
|
39
|
+
| `style?` | `any` | `-` | Inline CSS style object native pada elemen root. |
|
|
40
|
+
| `imageStyle?` | `UiProps` | `-` | Style kustom untuk elemen gambar `<img>` di dalam avatar (UiProps). |
|
|
41
|
+
| `imageClass?` | `string` | `-` | Class CSS kustom untuk elemen gambar `<img>`. |
|
|
42
|
+
| `className?` | `string` | `-` | Class CSS kustom pada elemen root. |
|
|
43
|
+
| `children?` | `any` | `-` | Slot konten tambahan atau pengganti ikon di dalam avatar. |
|
|
44
|
+
|
|
45
|
+
## 4. Usage Examples
|
|
46
|
+
|
|
47
|
+
### React Example
|
|
48
|
+
```tsx
|
|
49
|
+
import Avatar from "@ttdk-design-system/library-react/web/avatar";
|
|
50
|
+
import "@ttdk-design-system/library-react/web/avatar/avatar.css";
|
|
51
|
+
|
|
52
|
+
export function Example() {
|
|
53
|
+
return (
|
|
54
|
+
<div style={{ display: 'flex', gap: '16px', alignItems: 'center' }}>
|
|
55
|
+
<Avatar
|
|
56
|
+
src="https://images.unsplash.com/photo-1534528741775-53994a69daeb?w=160&h=160&fit=crop&crop=faces"
|
|
57
|
+
alt="Olivia"
|
|
58
|
+
size="md"
|
|
59
|
+
/>
|
|
60
|
+
<Avatar
|
|
61
|
+
size="md"
|
|
62
|
+
/>
|
|
63
|
+
<Avatar
|
|
64
|
+
initials="NA"
|
|
65
|
+
size="md"
|
|
66
|
+
/>
|
|
67
|
+
</div>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Vue 3 Example
|
|
73
|
+
```vue
|
|
74
|
+
<script setup lang="ts">
|
|
75
|
+
import Avatar from "@ttdk-design-system/library-vue/web/avatar";
|
|
76
|
+
import "@ttdk-design-system/library-vue/web/avatar/avatar.css";
|
|
77
|
+
</script>
|
|
78
|
+
|
|
79
|
+
<template>
|
|
80
|
+
<div style="display: flex; gap: 16px; align-items: center;">
|
|
81
|
+
<Avatar
|
|
82
|
+
src="https://images.unsplash.com/photo-1534528741775-53994a69daeb?w=160&h=160&fit=crop&crop=faces"
|
|
83
|
+
alt="Olivia"
|
|
84
|
+
size="md"
|
|
85
|
+
/>
|
|
86
|
+
<Avatar
|
|
87
|
+
size="md"
|
|
88
|
+
/>
|
|
89
|
+
<Avatar
|
|
90
|
+
initials="NA"
|
|
91
|
+
size="md"
|
|
92
|
+
/>
|
|
93
|
+
</div>
|
|
94
|
+
</template>
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Svelte Example
|
|
98
|
+
```svelte
|
|
99
|
+
<script lang="ts">
|
|
100
|
+
import Avatar from "@ttdk-design-system/library-svelte/web/avatar";
|
|
101
|
+
import "@ttdk-design-system/library-svelte/web/avatar/avatar.css";
|
|
102
|
+
</script>
|
|
103
|
+
|
|
104
|
+
<div style="display: flex; gap: 16px; align-items: center;">
|
|
105
|
+
<Avatar
|
|
106
|
+
src="https://images.unsplash.com/photo-1534528741775-53994a69daeb?w=160&h=160&fit=crop&crop=faces"
|
|
107
|
+
alt="Olivia"
|
|
108
|
+
size="md"
|
|
109
|
+
/>
|
|
110
|
+
<Avatar
|
|
111
|
+
size="md"
|
|
112
|
+
/>
|
|
113
|
+
<Avatar
|
|
114
|
+
initials="NA"
|
|
115
|
+
size="md"
|
|
116
|
+
/>
|
|
117
|
+
</div>
|
|
118
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.ttdk-avatar{border-radius:var(--ttdk-radius-full,9999px);background-color:var(--ttdk-color-blue-100,#ecf3fe);width:40px;height:40px;color:var(--ttdk-text-icon-status-info,#0968f6);font-family:var(--ttdk-font-sans,"Manrope", sans-serif);box-sizing:border-box;user-select:none;vertical-align:middle;flex-shrink:0;justify-content:center;align-items:center;line-height:1;transition:opacity .15s cubic-bezier(.4,0,.2,1),transform .15s cubic-bezier(.4,0,.2,1);display:inline-flex;position:relative;overflow:visible}.ttdk-avatar[data-interactive=true]{cursor:pointer}.ttdk-avatar[data-interactive=true]:hover{opacity:.9}.ttdk-avatar[data-interactive=true]:focus-visible{outline:2px solid var(--ttdk-stroke-border-focus,#16b3ac);outline-offset:2px}.ttdk-avatar[data-disabled=true]{opacity:.55;cursor:not-allowed;pointer-events:none}.ttdk-avatar-image{object-fit:cover;border-radius:inherit;width:100%;height:100%;display:block}.ttdk-avatar-initials{font-weight:var(--ttdk-font-weight-medium,500);letter-spacing:.01em;text-transform:uppercase;color:inherit;justify-content:center;align-items:center;line-height:1;display:inline-flex}.ttdk-avatar-icon{color:var(--ttdk-ui-icon-color,var(--ttdk-text-icon-primary,#141313));justify-content:center;align-items:center;line-height:0;display:inline-flex}.ttdk-avatar-icon:before{content:"";background-color:currentColor;width:20px;height:20px;display:inline-block;-webkit-mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath stroke='none' d='M0 0h24v24H0z' fill='none'/%3E%3Cpath d='M8 7a4 4 0 1 0 8 0a4 4 0 0 0 -8 0'/%3E%3Cpath d='M6 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2'/%3E%3C/svg%3E");mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath stroke='none' d='M0 0h24v24H0z' fill='none'/%3E%3Cpath d='M8 7a4 4 0 1 0 8 0a4 4 0 0 0 -8 0'/%3E%3Cpath d='M6 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2'/%3E%3C/svg%3E");-webkit-mask-position:50%;mask-position:50%;-webkit-mask-size:contain;mask-size:contain;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat}.ttdk-avatar-icon:not(:empty):before{display:none}.ttdk-avatar-icon svg{stroke:currentColor;stroke-width:1.8px;stroke-linecap:round;stroke-linejoin:round;fill:none;width:20px;height:20px}.ttdk-avatar[data-size=xs]{width:24px;height:24px;font-size:10px}.ttdk-avatar[data-size=xs] .ttdk-avatar-icon:before,.ttdk-avatar[data-size=xs] .ttdk-avatar-icon svg{width:14px;height:14px}.ttdk-avatar[data-size=sm]{width:32px;height:32px;font-size:14px}.ttdk-avatar[data-size=sm] .ttdk-avatar-icon:before,.ttdk-avatar[data-size=sm] .ttdk-avatar-icon svg{width:16px;height:16px}.ttdk-avatar[data-size=md]{width:40px;height:40px;font-size:16px}.ttdk-avatar[data-size=md] .ttdk-avatar-icon:before,.ttdk-avatar[data-size=md] .ttdk-avatar-icon svg{width:20px;height:20px}.ttdk-avatar[data-size=lg]{width:48px;height:48px;font-size:18px}.ttdk-avatar[data-size=lg] .ttdk-avatar-icon:before,.ttdk-avatar[data-size=lg] .ttdk-avatar-icon svg{width:24px;height:24px}.ttdk-avatar[data-size=xl]{width:56px;height:56px;font-size:20px}.ttdk-avatar[data-size=xl] .ttdk-avatar-icon:before,.ttdk-avatar[data-size=xl] .ttdk-avatar-icon svg{width:28px;height:28px}.ttdk-avatar[data-rounded=full]{border-radius:var(--ttdk-radius-full,9999px)}.ttdk-avatar[data-rounded=lg]{border-radius:var(--ttdk-radius-md,12px)}.ttdk-avatar[data-rounded=md]{border-radius:var(--ttdk-radius-sm,8px)}.ttdk-avatar[data-rounded=sm]{border-radius:var(--ttdk-radius-xs,6px)}.ttdk-avatar[data-rounded=none]{border-radius:var(--ttdk-radius-none,0px)}.ttdk-avatar[data-variant=info]{background-color:var(--ttdk-color-blue-100,#ecf3fe);color:var(--ttdk-text-icon-status-info,#0968f6)}.ttdk-avatar[data-variant=primary]{background-color:var(--ttdk-brand-subtle,#e1fbfa);color:var(--ttdk-brand-default,#16b3ac)}.ttdk-avatar[data-variant=success]{background-color:var(--ttdk-bg-status-success-subtle,#e0fae0);color:var(--ttdk-text-icon-status-success,#3cc14e)}.ttdk-avatar[data-variant=warning]{background-color:var(--ttdk-bg-status-warning-subtle,#fff8d5);color:var(--ttdk-text-icon-status-warning,#ff8806)}.ttdk-avatar[data-variant=danger]{background-color:var(--ttdk-bg-status-error-subtle,#ffe0e0);color:var(--ttdk-text-icon-status-error,#f02d2d)}.ttdk-avatar[data-variant=neutral]{background-color:var(--ttdk-bg-secondary-disabled,#f1f2f3);color:var(--ttdk-text-icon-primary,#141313)}.dark .ttdk-avatar,[data-theme=dark] .ttdk-avatar{color:var(--ttdk-text-icon-primary,#fff)}.dark .ttdk-avatar-icon,[data-theme=dark] .ttdk-avatar-icon{color:var(--ttdk-ui-icon-color,var(--ttdk-text-icon-primary,#fff))}.dark .ttdk-avatar[data-variant=info],[data-theme=dark] .ttdk-avatar[data-variant=info]{background-color:var(--ttdk-bg-status-info-subtle,#002a69);color:var(--ttdk-text-icon-status-info,#84b4fb)}.dark .ttdk-avatar[data-variant=primary],[data-theme=dark] .ttdk-avatar[data-variant=primary]{background-color:var(--ttdk-brand-subtle-dark,#062f2d);color:var(--ttdk-brand-default,#16b3ac)}.dark .ttdk-avatar[data-variant=success],[data-theme=dark] .ttdk-avatar[data-variant=success]{background-color:var(--ttdk-bg-status-success-subtle,#1b561a);color:var(--ttdk-text-icon-status-success,#a6f0a5)}.dark .ttdk-avatar[data-variant=warning],[data-theme=dark] .ttdk-avatar[data-variant=warning]{background-color:var(--ttdk-bg-status-warning-subtle,#553b06);color:var(--ttdk-text-icon-status-warning,#ffe58a)}.dark .ttdk-avatar[data-variant=danger],[data-theme=dark] .ttdk-avatar[data-variant=danger]{background-color:var(--ttdk-bg-status-error-subtle,#570303);color:var(--ttdk-text-icon-status-error,#ffa0a0)}.dark .ttdk-avatar[data-variant=neutral],[data-theme=dark] .ttdk-avatar[data-variant=neutral]{background-color:var(--ttdk-bg-secondary-disabled,#313336);color:var(--ttdk-text-icon-primary,#fff)}.ttdk-avatar-status{border:1.5px solid var(--ttdk-bg-base-primary,#fff);box-sizing:border-box;background-color:var(--ttdk-bg-status-success,#3cc14e);border-radius:9999px;position:absolute;bottom:0;right:0}.dark .ttdk-avatar-status,[data-theme=dark] .ttdk-avatar-status{border-color:var(--ttdk-bg-base-primary,#141313)}.ttdk-avatar[data-size=xs] .ttdk-avatar-status{border-width:1px;width:6px;height:6px}.ttdk-avatar[data-size=sm] .ttdk-avatar-status{border-width:1.5px;width:8px;height:8px}.ttdk-avatar[data-size=md] .ttdk-avatar-status{border-width:1.5px;width:10px;height:10px}.ttdk-avatar[data-size=lg] .ttdk-avatar-status{border-width:2px;width:12px;height:12px}.ttdk-avatar[data-size=xl] .ttdk-avatar-status{border-width:2px;width:14px;height:14px}.ttdk-avatar-status[data-status=online]{background-color:var(--ttdk-bg-status-success,#3cc14e)}.ttdk-avatar-status[data-status=offline]{background-color:var(--ttdk-color-neutral-400,#969ba2)}.ttdk-avatar-status[data-status=verified]{background-color:#0000;background-image:url(data:image/svg+xml,%3Csvg%20width%3D%2225%22%20height%3D%2227%22%20viewBox%3D%220%200%2025%2027%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20xmlns%3Axlink%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxlink%22%3E%3Cuse%20xlink%3Ahref%3D%22%23stroke0_696_8896%22%20fill%3D%22%231E81E8%22%2F%3E%3Cmask%20id%3D%22stroke1_696_8896%22%20maskUnits%3D%22userSpaceOnUse%22%20x%3D%22-0.577322%22%20y%3D%22-1.33077%22%20width%3D%2226.4905%22%20height%3D%2229.1467%22%20fill%3D%22black%22%3E%3Crect%20fill%3D%22white%22%20x%3D%22-0.577322%22%20y%3D%22-1.33077%22%20width%3D%2226.4905%22%20height%3D%2229.1467%22%2F%3E%3Cuse%20xlink%3Ahref%3D%22%23stroke0_696_8896%22%2F%3E%3C%2Fmask%3E%3Cpath%20d%3D%22M23.1264%204.39673L24.094%204.14968L23.8502%203.21882L22.9113%203.41901L23.1264%204.39673ZM12.5952%201.23272L13.1994%200.440062L12.6235%205.7958e-05L12.0282%200.405408L12.5952%201.23272ZM1.87074%203.81179L2.13074%202.84824L1.2209%202.59744L0.922051%203.48837L1.87074%203.81179ZM11.7726%2025.626L11.3952%2026.5493L11.7485%2026.6955L12.108%2026.5701L11.7726%2025.626ZM23.1264%204.39673L22.9113%203.41901C20.7297%203.88421%2018.3403%203.19906%2016.4009%202.30664C15.4476%201.868%2014.6401%201.39645%2014.0714%201.03467C13.7878%200.854194%2013.5653%200.702137%2013.4157%200.596732C13.341%200.54406%2013.2846%200.503128%2013.2481%200.476231C13.2298%200.462785%2013.2165%200.452855%2013.2083%200.446729C13.2042%200.443666%2013.2014%200.441555%2013.1999%200.440431C13.1992%200.439869%2013.1988%200.439555%2013.1987%200.439492C13.1986%200.43946%2013.1987%200.439492%2013.1988%200.439586C13.1989%200.439634%2013.199%200.439753%2013.1991%200.439776C13.1992%200.439911%2013.1994%200.440062%2012.5952%201.23272C11.991%202.02539%2011.9913%202.02557%2011.9915%202.02577C11.9917%202.02586%2011.9919%202.02607%2011.9922%202.02625C11.9926%202.0266%2011.9932%202.02702%2011.9938%202.0275C11.9951%202.02846%2011.9967%202.02967%2011.9986%202.03114C12.0025%202.03407%2012.0077%202.03801%2012.0142%202.04292C12.0273%202.05273%2012.0457%202.06642%2012.0692%202.08369C12.1161%202.11822%2012.1836%202.16711%2012.27%202.228C12.4427%202.34972%2012.6917%202.51975%2013.005%202.71912C13.6304%203.11702%2014.519%203.6362%2015.5741%204.12171C17.6514%205.07759%2020.5276%205.97444%2023.3414%205.37444L23.1264%204.39673ZM12.5952%201.23272C12.0282%200.405408%2012.0284%200.405271%2012.0286%200.405149C12.0286%200.405128%2012.0288%200.40502%2012.0288%200.404979C12.0289%200.404895%2012.029%200.40487%2012.0289%200.404904C12.0288%200.404972%2012.0284%200.405275%2012.0276%200.405807C12.026%200.406871%2012.0231%200.408855%2012.0188%200.411723C12.0102%200.417459%2011.9962%200.42673%2011.9771%200.439256C11.9388%200.464314%2011.8798%200.502364%2011.8018%200.551183C11.6458%200.648876%2011.414%200.789355%2011.1192%200.954928C10.5285%201.28684%209.69205%201.71554%208.71167%202.10263C6.71599%202.8906%204.2845%203.44196%202.13074%202.84824L1.87074%203.81179L1.61074%204.77533C4.39472%205.54277%207.32548%204.80459%209.45761%203.96274C10.5411%203.53492%2011.46%203.06365%2012.1086%202.6993C12.4335%202.51675%2012.6923%202.36003%2012.872%202.24756C12.9619%202.1913%2013.0321%202.14602%2013.081%202.11403C13.1055%202.09803%2013.1246%202.08534%2013.1382%202.07625C13.145%202.0717%2013.1504%202.06806%2013.1545%202.06534C13.1565%202.06399%2013.1581%202.06286%2013.1594%202.06198C13.1601%202.06154%2013.1606%202.06115%2013.1611%202.06083C13.1614%202.06067%2013.1617%202.06047%2013.1618%202.06039C13.162%202.06021%2013.1623%202.06004%2012.5952%201.23272ZM1.87074%203.81179C0.922051%203.48837%200.921877%203.48889%200.921684%203.48947C0.921593%203.48974%200.92138%203.49037%200.921199%203.49092C0.920836%203.49201%200.920395%203.49333%200.919878%203.4949C0.918842%203.49802%200.9175%203.5021%200.915863%203.50711C0.912588%203.51713%200.908135%203.5309%200.9026%203.54832C0.891531%203.58316%200.876135%203.63262%200.857201%203.69594C0.819341%203.82255%200.767288%204.00472%200.707393%204.23635C0.587677%204.6993%200.436175%205.36153%200.30413%206.17379C0.0407089%207.79419%20-0.148984%2010.0341%200.158825%2012.4906C0.780892%2017.455%203.44239%2023.2589%2011.3952%2026.5493L11.7726%2025.626L12.15%2024.7028C4.98209%2021.7372%202.69267%2016.634%202.14399%2012.2553C1.86642%2010.0401%202.0364%207.99952%202.27899%206.50725C2.39995%205.76317%202.53804%205.16104%202.64466%204.74871C2.69794%204.54269%202.74324%204.3845%202.77445%204.28014C2.79005%204.22798%202.80211%204.18931%202.80987%204.1649C2.81374%204.15269%202.81655%204.14405%202.81817%204.13907C2.81899%204.13658%202.81951%204.135%202.81972%204.13435C2.81983%204.13403%202.81986%204.13394%202.81981%204.13408C2.81979%204.13415%202.81969%204.13443%202.81968%204.13447C2.81957%204.13481%202.81943%204.13521%201.87074%203.81179ZM11.7726%2025.626L12.108%2026.5701C20.2456%2023.7309%2023.2865%2018.0972%2024.2432%2013.1809C24.7168%2010.7469%2024.6802%208.50039%2024.5277%206.8672C24.4513%206.04866%2024.3453%205.37876%2024.2574%204.90953C24.2134%204.67477%2024.1738%204.48981%2024.1447%204.36111C24.1301%204.29674%2024.1181%204.24641%2024.1094%204.21091C24.105%204.19316%2024.1015%204.17912%2024.0989%204.16888C24.0976%204.16376%2024.0966%204.1596%2024.0957%204.15639C24.0953%204.15479%2024.095%204.15343%2024.0947%204.15231C24.0945%204.15175%2024.0944%204.15109%2024.0943%204.15081C24.0941%204.15022%2024.094%204.14968%2023.1264%204.39673C22.1587%204.64378%2022.1586%204.64336%2022.1585%204.64301C22.1585%204.64297%2022.1584%204.64267%2022.1584%204.64259C22.1584%204.64244%2022.1584%204.64252%2022.1585%204.64284C22.1586%204.64347%2022.159%204.64505%2022.1597%204.64755C22.1609%204.65257%2022.1631%204.6613%2022.1662%204.67365C22.1722%204.69836%2022.1816%204.73753%2022.1936%204.79037C22.2175%204.89609%2022.2519%205.05633%2022.2909%205.26477C22.3691%205.68194%2022.4658%206.2904%2022.5357%207.03968C22.6759%208.54213%2022.7068%2010.5891%2022.2792%2012.7866C21.4334%2017.1332%2018.7974%2022.1141%2011.4372%2024.682L11.7726%2025.626Z%22%20fill%3D%22white%22%20mask%3D%22url\(%23stroke1_696_8896\)%22%2F%3E%3Cpath%20d%3D%22M12.7982%2018.6179C16.1989%2018.4641%2018.8078%2015.7456%2018.6252%2012.5461C18.4427%209.34656%2015.5378%206.87751%2012.137%207.03132C8.73627%207.18513%206.1274%209.90355%206.30996%2013.1031C6.49252%2016.3026%209.39739%2018.7717%2012.7982%2018.6179Z%22%20fill%3D%22white%22%2F%3E%3Cpath%20d%3D%22M11.7845%2016.0567L11.7782%2016.057C11.5591%2016.0653%2011.3451%2015.988%2011.1848%2015.843L8.33674%2013.2645C8.00913%2012.9681%207.99235%2012.4747%208.29919%2012.1629C8.60578%2011.8509%209.11979%2011.8384%209.44741%2012.135L11.6853%2014.1612L15.3696%2010.194C15.6671%209.87369%2016.1805%209.84733%2016.5165%2010.1349C16.8524%2010.4228%2016.8838%2010.9152%2016.5865%2011.2355L12.3486%2015.799C12.2046%2015.9543%2012.0014%2016.0469%2011.7845%2016.0567%22%20fill%3D%22%231E81E8%22%2F%3E%3Cdefs%3E%3Cpath%20id%3D%22stroke0_696_8896%22%20d%3D%22M23.1264%204.39673C18.1309%205.46192%2012.5952%201.23272%2012.5952%201.23272C12.5952%201.23272%206.80847%205.17294%201.87074%203.81179C1.87074%203.81179%20-3.34811%2019.3701%2011.7726%2025.626C27.2704%2020.219%2023.1264%204.39673%2023.1264%204.39673Z%22%20fill-rule%3D%22evenodd%22%20clip-rule%3D%22evenodd%22%2F%3E%3C%2Fdefs%3E%3C%2Fsvg%3E);background-position:50%;background-repeat:no-repeat;background-size:contain;border:none;border-radius:0}.ttdk-avatar[data-size=xs] .ttdk-avatar-status[data-status=verified]{width:8px;height:8.5px}.ttdk-avatar[data-size=sm] .ttdk-avatar-status[data-status=verified]{width:12px;height:12.75px}.ttdk-avatar[data-size=md] .ttdk-avatar-status[data-status=verified]{width:16px;height:17px}.ttdk-avatar[data-size=lg] .ttdk-avatar-status[data-status=verified]{width:20px;height:21.25px}.ttdk-avatar[data-size=xl] .ttdk-avatar-status[data-status=verified]{width:24px;height:25.5px}
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<span
|
|
3
|
+
:class="`ttdk-avatar ${className || ''}`.trim()"
|
|
4
|
+
:data-size="size || 'md'"
|
|
5
|
+
:data-variant="variant || 'info'"
|
|
6
|
+
:data-rounded="rounded || 'full'"
|
|
7
|
+
:data-mode="
|
|
8
|
+
src && !hasImageError ? 'image' : initials ? 'initials' : 'icon'
|
|
9
|
+
"
|
|
10
|
+
:data-interactive="Boolean(interactive || onClick) ? 'true' : 'false'"
|
|
11
|
+
:data-disabled="disabled ? 'true' : 'false'"
|
|
12
|
+
:role="interactive || onClick ? 'button' : undefined"
|
|
13
|
+
:tabIndex="disabled ? -1 : interactive || onClick ? 0 : undefined"
|
|
14
|
+
:aria-disabled="disabled ? 'true' : undefined"
|
|
15
|
+
:style="{
|
|
16
|
+
...buildUiVars(ui),
|
|
17
|
+
...(iconColor
|
|
18
|
+
? {
|
|
19
|
+
'--ttdk-ui-icon-color': iconColor,
|
|
20
|
+
}
|
|
21
|
+
: {}),
|
|
22
|
+
...(typeof style === 'object' ? style : {}),
|
|
23
|
+
}"
|
|
24
|
+
@click="async (event) => handleClick(event)"
|
|
25
|
+
@keydown="async (event) => handleKeyDown(event)"
|
|
26
|
+
>
|
|
27
|
+
<template v-if="src && !hasImageError">
|
|
28
|
+
<img
|
|
29
|
+
:class="`ttdk-avatar-image ${imageClass || ''}`.trim()"
|
|
30
|
+
:src="src"
|
|
31
|
+
:alt="alt || initials || 'Avatar'"
|
|
32
|
+
:style="{
|
|
33
|
+
...buildUiVars(imageStyle),
|
|
34
|
+
}"
|
|
35
|
+
@error="async (event) => handleImgError(event)"
|
|
36
|
+
/>
|
|
37
|
+
</template>
|
|
38
|
+
|
|
39
|
+
<template v-if="(!src || hasImageError) && initials">
|
|
40
|
+
<span class="ttdk-avatar-initials">{{ initials }}</span>
|
|
41
|
+
</template>
|
|
42
|
+
|
|
43
|
+
<template v-if="(!src || hasImageError) && !initials">
|
|
44
|
+
<template v-if="icon">
|
|
45
|
+
<span class="ttdk-avatar-icon">{{ icon }}</span>
|
|
46
|
+
</template>
|
|
47
|
+
|
|
48
|
+
<template v-if="!icon">
|
|
49
|
+
<span class="ttdk-avatar-icon" aria-hidden="true"><slot /></span>
|
|
50
|
+
</template>
|
|
51
|
+
</template>
|
|
52
|
+
|
|
53
|
+
<template v-if="status">
|
|
54
|
+
<span
|
|
55
|
+
class="ttdk-avatar-status"
|
|
56
|
+
:data-status="status"
|
|
57
|
+
:aria-label="status"
|
|
58
|
+
></span>
|
|
59
|
+
</template>
|
|
60
|
+
</span>
|
|
61
|
+
</template>
|
|
62
|
+
|
|
63
|
+
<script setup lang="ts">
|
|
64
|
+
import { ref } from "vue";
|
|
65
|
+
|
|
66
|
+
import { buildUiVars, UiProps } from "../../core/types";
|
|
67
|
+
|
|
68
|
+
export type AvatarUiProps = UiProps;
|
|
69
|
+
export interface AvatarProps {
|
|
70
|
+
/**
|
|
71
|
+
* URL gambar profil avatar.
|
|
72
|
+
* Jika kosong atau gagal dimuat, tampilan otomatis beralih ke `initials` atau ikon pengguna bawaan.
|
|
73
|
+
*/
|
|
74
|
+
src?: string;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Teks alternatif (alt) untuk elemen gambar avatar.
|
|
78
|
+
*/
|
|
79
|
+
alt?: string;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Teks inisial pengguna yang ditampilkan di dalam lingkaran avatar (misal: "NA", "SR").
|
|
83
|
+
* Ditampilkan apabila `src` tidak tersedia atau gagal dimuat.
|
|
84
|
+
*/
|
|
85
|
+
initials?: string;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Skala ukuran avatar:
|
|
89
|
+
* - `'xs'`: Lingkaran 28px.
|
|
90
|
+
* - `'sm'`: Lingkaran 32px.
|
|
91
|
+
* - `'md'`: Lingkaran 40px (standar).
|
|
92
|
+
* - `'lg'`: Lingkaran 48px.
|
|
93
|
+
* - `'xl'`: Lingkaran 56px.
|
|
94
|
+
*
|
|
95
|
+
* @default 'md'
|
|
96
|
+
*/
|
|
97
|
+
size?: "xs" | "sm" | "md" | "lg" | "xl";
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Varian warna semantik untuk latar & teks/ikon fallback avatar:
|
|
101
|
+
* - `'info'`: Biru informasi sesuai standar profil (default).
|
|
102
|
+
* - `'primary'`: Brand Teal utama.
|
|
103
|
+
* - `'success'`: Hijau sukses.
|
|
104
|
+
* - `'warning'`: Kuning / amber peringatan.
|
|
105
|
+
* - `'danger'`: Merah bahaya.
|
|
106
|
+
* - `'neutral'`: Abu-abu netral.
|
|
107
|
+
*
|
|
108
|
+
* @default 'info'
|
|
109
|
+
*/
|
|
110
|
+
variant?: "info" | "primary" | "success" | "warning" | "danger" | "neutral";
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Sudut kelengkungan lingkaran avatar:
|
|
114
|
+
* - `'full'`: Lingkaran penuh 9999px (default).
|
|
115
|
+
* - `'lg'`: Radius membulat 12px.
|
|
116
|
+
* - `'md'`: Radius sedang 8px.
|
|
117
|
+
* - `'sm'`: Radius halus 4px.
|
|
118
|
+
* - `'none'`: Persegi tajam 0px.
|
|
119
|
+
*
|
|
120
|
+
* @default 'full'
|
|
121
|
+
*/
|
|
122
|
+
rounded?: "none" | "sm" | "md" | "lg" | "full";
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Indikator status kehadiran atau verifikasi di pojok kanan bawah lingkaran avatar:
|
|
126
|
+
* - `'online'`: Titik hijau status aktif.
|
|
127
|
+
* - `'offline'`: Titik abu-abu status luring.
|
|
128
|
+
* - `'verified'`: Lencana perisai biru terverifikasi.
|
|
129
|
+
*/
|
|
130
|
+
status?: "online" | "offline" | "verified";
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Ikon kustom untuk menggantikan ikon pengguna bawaan saat `src` dan `initials` tidak diisi.
|
|
134
|
+
*/
|
|
135
|
+
icon?: any;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Warna kustom untuk ikon di dalam avatar.
|
|
139
|
+
*/
|
|
140
|
+
iconColor?: string;
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Menjadikan komponen avatar interaktif (memiliki efek hover & fokus keyboard).
|
|
144
|
+
* @default false
|
|
145
|
+
*/
|
|
146
|
+
interactive?: boolean;
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Menonaktifkan interaksi klik pada avatar.
|
|
150
|
+
* @default false
|
|
151
|
+
*/
|
|
152
|
+
disabled?: boolean;
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Event handler saat komponen avatar diklik.
|
|
156
|
+
*/
|
|
157
|
+
onClick?: (event?: any) => void;
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Event handler saat gambar `src` gagal dimuat.
|
|
161
|
+
*/
|
|
162
|
+
onImageError?: (event?: any) => void;
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Kustomisasi visual granular pada elemen root melalui style-like object (+ support pseudo-class: hover, active).
|
|
166
|
+
*/
|
|
167
|
+
ui?: UiProps;
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Inline CSS style object native pada elemen root.
|
|
171
|
+
*/
|
|
172
|
+
style?: any;
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Style kustom untuk elemen gambar `<img>` di dalam avatar (UiProps).
|
|
176
|
+
*/
|
|
177
|
+
imageStyle?: UiProps;
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Class CSS kustom untuk elemen gambar `<img>`.
|
|
181
|
+
*/
|
|
182
|
+
imageClass?: string;
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Class CSS kustom pada elemen root.
|
|
186
|
+
*/
|
|
187
|
+
className?: string;
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Slot konten tambahan atau pengganti ikon di dalam avatar.
|
|
191
|
+
*/
|
|
192
|
+
children?: any;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Komponen Avatar untuk menampilkan foto profil, inisial nama, atau ikon pengguna.
|
|
197
|
+
*/
|
|
198
|
+
|
|
199
|
+
const props = defineProps<AvatarProps>();
|
|
200
|
+
const hasImageError = ref(false);
|
|
201
|
+
|
|
202
|
+
function handleImgError(event: any) {
|
|
203
|
+
hasImageError.value = true;
|
|
204
|
+
props.onImageError?.(event);
|
|
205
|
+
}
|
|
206
|
+
function handleClick(event: any) {
|
|
207
|
+
if (props.disabled) return;
|
|
208
|
+
props.onClick?.(event);
|
|
209
|
+
}
|
|
210
|
+
function handleKeyDown(event: any) {
|
|
211
|
+
if (props.disabled) return;
|
|
212
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
213
|
+
event.preventDefault();
|
|
214
|
+
props.onClick?.(event);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
</script>
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
// Auto-generated by TTDK Design System Vue Type Generator
|
|
3
|
+
import type { DefineComponent } from "vue";
|
|
4
|
+
import { buildUiVars, UiProps } from "../../core/types";
|
|
5
|
+
|
|
6
|
+
export type AvatarUiProps = UiProps;
|
|
7
|
+
|
|
8
|
+
export interface AvatarProps {
|
|
9
|
+
/**
|
|
10
|
+
* URL gambar profil avatar.
|
|
11
|
+
* Jika kosong atau gagal dimuat, tampilan otomatis beralih ke `initials` atau ikon pengguna bawaan.
|
|
12
|
+
*/
|
|
13
|
+
src?: string;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Teks alternatif (alt) untuk elemen gambar avatar.
|
|
17
|
+
*/
|
|
18
|
+
alt?: string;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Teks inisial pengguna yang ditampilkan di dalam lingkaran avatar (misal: "NA", "SR").
|
|
22
|
+
* Ditampilkan apabila `src` tidak tersedia atau gagal dimuat.
|
|
23
|
+
*/
|
|
24
|
+
initials?: string;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Skala ukuran avatar:
|
|
28
|
+
* - `'xs'`: Lingkaran 28px.
|
|
29
|
+
* - `'sm'`: Lingkaran 32px.
|
|
30
|
+
* - `'md'`: Lingkaran 40px (standar).
|
|
31
|
+
* - `'lg'`: Lingkaran 48px.
|
|
32
|
+
* - `'xl'`: Lingkaran 56px.
|
|
33
|
+
*
|
|
34
|
+
* @default 'md'
|
|
35
|
+
*/
|
|
36
|
+
size?: "xs" | "sm" | "md" | "lg" | "xl";
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Varian warna semantik untuk latar & teks/ikon fallback avatar:
|
|
40
|
+
* - `'info'`: Biru informasi sesuai standar profil (default).
|
|
41
|
+
* - `'primary'`: Brand Teal utama.
|
|
42
|
+
* - `'success'`: Hijau sukses.
|
|
43
|
+
* - `'warning'`: Kuning / amber peringatan.
|
|
44
|
+
* - `'danger'`: Merah bahaya.
|
|
45
|
+
* - `'neutral'`: Abu-abu netral.
|
|
46
|
+
*
|
|
47
|
+
* @default 'info'
|
|
48
|
+
*/
|
|
49
|
+
variant?: "info" | "primary" | "success" | "warning" | "danger" | "neutral";
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Sudut kelengkungan lingkaran avatar:
|
|
53
|
+
* - `'full'`: Lingkaran penuh 9999px (default).
|
|
54
|
+
* - `'lg'`: Radius membulat 12px.
|
|
55
|
+
* - `'md'`: Radius sedang 8px.
|
|
56
|
+
* - `'sm'`: Radius halus 4px.
|
|
57
|
+
* - `'none'`: Persegi tajam 0px.
|
|
58
|
+
*
|
|
59
|
+
* @default 'full'
|
|
60
|
+
*/
|
|
61
|
+
rounded?: "none" | "sm" | "md" | "lg" | "full";
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Indikator status kehadiran atau verifikasi di pojok kanan bawah lingkaran avatar:
|
|
65
|
+
* - `'online'`: Titik hijau status aktif.
|
|
66
|
+
* - `'offline'`: Titik abu-abu status luring.
|
|
67
|
+
* - `'verified'`: Lencana perisai biru terverifikasi.
|
|
68
|
+
*/
|
|
69
|
+
status?: "online" | "offline" | "verified";
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Ikon kustom untuk menggantikan ikon pengguna bawaan saat `src` dan `initials` tidak diisi.
|
|
73
|
+
*/
|
|
74
|
+
icon?: any;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Warna kustom untuk ikon di dalam avatar.
|
|
78
|
+
*/
|
|
79
|
+
iconColor?: string;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Menjadikan komponen avatar interaktif (memiliki efek hover & fokus keyboard).
|
|
83
|
+
* @default false
|
|
84
|
+
*/
|
|
85
|
+
interactive?: boolean;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Menonaktifkan interaksi klik pada avatar.
|
|
89
|
+
* @default false
|
|
90
|
+
*/
|
|
91
|
+
disabled?: boolean;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Event handler saat komponen avatar diklik.
|
|
95
|
+
*/
|
|
96
|
+
onClick?: (event?: any) => void;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Event handler saat gambar `src` gagal dimuat.
|
|
100
|
+
*/
|
|
101
|
+
onImageError?: (event?: any) => void;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Kustomisasi visual granular pada elemen root melalui style-like object (+ support pseudo-class: hover, active).
|
|
105
|
+
*/
|
|
106
|
+
ui?: UiProps;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Inline CSS style object native pada elemen root.
|
|
110
|
+
*/
|
|
111
|
+
style?: any;
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Style kustom untuk elemen gambar `<img>` di dalam avatar (UiProps).
|
|
115
|
+
*/
|
|
116
|
+
imageStyle?: UiProps;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Class CSS kustom untuk elemen gambar `<img>`.
|
|
120
|
+
*/
|
|
121
|
+
imageClass?: string;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Class CSS kustom pada elemen root.
|
|
125
|
+
*/
|
|
126
|
+
className?: string;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Slot konten tambahan atau pengganti ikon di dalam avatar.
|
|
130
|
+
*/
|
|
131
|
+
children?: any;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
declare const component: DefineComponent<AvatarProps>;
|
|
135
|
+
export default component;
|