@ttdk-design-system/library-react 0.0.0-stage → 1.0.1
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/README.md +106 -2
- package/llms.txt +6518 -0
- package/package.json +1099 -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.tsx +430 -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.tsx +318 -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.tsx +233 -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.tsx +140 -0
- package/src/web/badge/index.ts +2 -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.tsx +334 -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.tsx +306 -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.tsx +287 -0
- package/src/web/button/index.ts +2 -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.tsx +1611 -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.tsx +408 -0
- package/src/web/card/index.ts +4 -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.tsx +307 -0
- package/src/web/checkbox/index.ts +2 -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.tsx +230 -0
- package/src/web/chip/index.ts +2 -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.tsx +1274 -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.tsx +97 -0
- package/src/web/flex/flex.css +1 -0
- package/src/web/flex/flex.tsx +108 -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.tsx +112 -0
- package/src/web/grid/grid.css +1 -0
- package/src/web/grid/grid.tsx +99 -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.tsx +537 -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.tsx +1193 -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.tsx +571 -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.tsx +45 -0
- package/src/web/pagination/pagination-ellipsis.tsx +54 -0
- package/src/web/pagination/pagination-first.tsx +155 -0
- package/src/web/pagination/pagination-item.tsx +45 -0
- package/src/web/pagination/pagination-last.tsx +155 -0
- package/src/web/pagination/pagination-link.tsx +121 -0
- package/src/web/pagination/pagination-next.tsx +158 -0
- package/src/web/pagination/pagination-previous.tsx +158 -0
- package/src/web/pagination/pagination.css +1 -0
- package/src/web/pagination/pagination.tsx +687 -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.tsx +702 -0
- package/src/web/radio/AI_GUIDE.md +155 -0
- package/src/web/radio/index.ts +2 -0
- package/src/web/radio/manifest.json +294 -0
- package/src/web/radio/radio.css +1 -0
- package/src/web/radio/radio.tsx +290 -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.tsx +1048 -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.tsx +177 -0
- package/src/web/table/AI_GUIDE.md +145 -0
- package/src/web/table/index.ts +35 -0
- package/src/web/table/manifest.json +168 -0
- package/src/web/table/table-body.tsx +45 -0
- package/src/web/table/table-caption.tsx +45 -0
- package/src/web/table/table-cell.tsx +74 -0
- package/src/web/table/table-empty.tsx +108 -0
- package/src/web/table/table-footer.tsx +45 -0
- package/src/web/table/table-head.tsx +80 -0
- package/src/web/table/table-header.tsx +45 -0
- package/src/web/table/table-row.tsx +69 -0
- package/src/web/table/table.css +1 -0
- package/src/web/table/table.tsx +305 -0
- package/src/web/tabs/AI_GUIDE.md +150 -0
- package/src/web/tabs/index.ts +3 -0
- package/src/web/tabs/manifest.json +315 -0
- package/src/web/tabs/tabs.css +1 -0
- package/src/web/tabs/tabs.tsx +332 -0
- package/src/web/text/AI_GUIDE.md +129 -0
- package/src/web/text/index.ts +3 -0
- package/src/web/text/manifest.json +195 -0
- package/src/web/text/text.css +1 -0
- package/src/web/text/text.tsx +689 -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.tsx +467 -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.tsx +423 -0
- package/src/webview/bottomsheet/AI_GUIDE.md +141 -0
- package/src/webview/bottomsheet/bottomsheet.css +1 -0
- package/src/webview/bottomsheet/bottomsheet.tsx +603 -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.tsx +138 -0
- package/src/webview/button/button-material.css +1 -0
- package/src/webview/button/button-material.tsx +138 -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
|
@@ -0,0 +1,467 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { useState, forwardRef, useEffect } from "react";
|
|
4
|
+
|
|
5
|
+
export type TextareaUiProps = UiProps;
|
|
6
|
+
export interface TextareaProps {
|
|
7
|
+
/**
|
|
8
|
+
* Teks label judul field yang ditampilkan di atas textarea (14px Semibold, #141313).
|
|
9
|
+
*/
|
|
10
|
+
label?: string;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Style kustom untuk elemen label judul field (UiProps).
|
|
14
|
+
*/
|
|
15
|
+
labelStyle?: UiProps;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Class CSS kustom untuk elemen label judul field.
|
|
19
|
+
*/
|
|
20
|
+
labelClass?: string;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Style kustom untuk elemen kontainer textarea wrapper (UiProps).
|
|
24
|
+
*/
|
|
25
|
+
wrapperStyle?: UiProps;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Class CSS kustom untuk elemen kontainer textarea wrapper.
|
|
29
|
+
*/
|
|
30
|
+
wrapperClass?: string;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Style kustom untuk elemen textarea control HTML (UiProps).
|
|
34
|
+
*/
|
|
35
|
+
textareaStyle?: UiProps;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Class CSS kustom untuk elemen textarea control HTML.
|
|
39
|
+
*/
|
|
40
|
+
textareaClass?: string;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Style kustom untuk elemen pesan error validasi (UiProps).
|
|
44
|
+
*/
|
|
45
|
+
errorMessageStyle?: UiProps;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Class CSS kustom untuk elemen pesan error validasi.
|
|
49
|
+
*/
|
|
50
|
+
errorMessageClass?: string;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Style kustom untuk elemen helper text (UiProps).
|
|
54
|
+
*/
|
|
55
|
+
helperTextStyle?: UiProps;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Class CSS kustom untuk elemen helper text.
|
|
59
|
+
*/
|
|
60
|
+
helperTextClass?: string;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Style kustom untuk elemen penghitung karakter (UiProps).
|
|
64
|
+
*/
|
|
65
|
+
charCountStyle?: UiProps;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Class CSS kustom untuk elemen penghitung karakter.
|
|
69
|
+
*/
|
|
70
|
+
charCountClass?: string;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Menandai field sebagai opsi opsional dengan menambahkan teks '(Opsional)' (12px Regular, #9698A2).
|
|
74
|
+
*/
|
|
75
|
+
optional?: boolean;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Kustomisasi teks keterangan opsional.
|
|
79
|
+
* @default '(Opsional)'
|
|
80
|
+
*/
|
|
81
|
+
optionalText?: string;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Nilai teks placeholder saat textarea kosong (#9698A2).
|
|
85
|
+
*/
|
|
86
|
+
placeholder?: string;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Nilai terkontrol (controlled value) pada textarea.
|
|
90
|
+
*/
|
|
91
|
+
value?: string;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Nilai awal tidak terkontrol (uncontrolled initial value).
|
|
95
|
+
*/
|
|
96
|
+
defaultValue?: string;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Jumlah baris default yang ditampilkan.
|
|
100
|
+
* @default 4
|
|
101
|
+
*/
|
|
102
|
+
rows?: number;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Nama form field HTML untuk integrasi formulir.
|
|
106
|
+
*/
|
|
107
|
+
name?: string;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Identifier unik elemen textarea.
|
|
111
|
+
*/
|
|
112
|
+
id?: string;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Kontrol orientasi resize oleh pengguna.
|
|
116
|
+
* - `'none'`: Tidak dapat di-resize
|
|
117
|
+
* - `'vertical'`: Hanya dapat di-resize vertikal (standar)
|
|
118
|
+
* - `'horizontal'`: Hanya dapat di-resize horizontal
|
|
119
|
+
* - `'both'`: Bebas di-resize kedua arah
|
|
120
|
+
* @default 'vertical'
|
|
121
|
+
*/
|
|
122
|
+
resize?: "none" | "vertical" | "horizontal" | "both";
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Status apakah textarea sedang dalam kondisi error / tidak valid.
|
|
126
|
+
* @default false
|
|
127
|
+
*/
|
|
128
|
+
error?: boolean;
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Pesan teks penjelasan kesalahan validasi di bawah field.
|
|
132
|
+
*/
|
|
133
|
+
errorMessage?: string;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Teks petunjuk atau keterangan bantuan di bawah field (12px Regular, #3C4245).
|
|
137
|
+
*/
|
|
138
|
+
helperText?: string;
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Posisi teks helper
|
|
142
|
+
*/
|
|
143
|
+
helperTextPosition?: "top" | "bottom";
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Skala ukuran textarea.
|
|
147
|
+
* - `'sm'`: Padding rapat
|
|
148
|
+
* - `'md'`: Standar
|
|
149
|
+
* - `'lg'`: Padding lapang
|
|
150
|
+
* @default 'md'
|
|
151
|
+
*/
|
|
152
|
+
size?: "sm" | "md" | "lg";
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Bentuk sudut kelengkungan textarea.
|
|
156
|
+
* - `'none'`: 0px
|
|
157
|
+
* - `'sm'`: 4px
|
|
158
|
+
* - `'md'`: 8px (standar desain)
|
|
159
|
+
* - `'lg'`: 12px
|
|
160
|
+
* - `'full'`: 16px
|
|
161
|
+
* @default 'md'
|
|
162
|
+
*/
|
|
163
|
+
rounded?: "none" | "sm" | "md" | "lg" | "full";
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Menjadikan lebar field textarea memenuhi kontainer penuh (full-width 100%).
|
|
167
|
+
* @default false
|
|
168
|
+
*/
|
|
169
|
+
block?: boolean;
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Status apakah field dinonaktifkan (disabled).
|
|
173
|
+
* @default false
|
|
174
|
+
*/
|
|
175
|
+
disabled?: boolean;
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Status apakah field bersifat hanya-baca (readonly).
|
|
179
|
+
* @default false
|
|
180
|
+
*/
|
|
181
|
+
readOnly?: boolean;
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Menandai field sebagai input wajib diisi (menampilkan tanda bintang merah *).
|
|
185
|
+
* @default false
|
|
186
|
+
*/
|
|
187
|
+
required?: boolean;
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Konfigurasi atribut autocomplete HTML.
|
|
191
|
+
*/
|
|
192
|
+
autoComplete?: string;
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Batas maksimum panjang karakter.
|
|
196
|
+
*/
|
|
197
|
+
maxLength?: number;
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Batas minimum panjang karakter.
|
|
201
|
+
*/
|
|
202
|
+
minLength?: number;
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Inline CSS style object native.
|
|
206
|
+
*/
|
|
207
|
+
style?: React.CSSProperties;
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Kustomisasi visual granular root / form-item (UiProps).
|
|
211
|
+
*/
|
|
212
|
+
ui?: UiProps;
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Callback event saat nilai textarea berubah.
|
|
216
|
+
*/
|
|
217
|
+
onChange?: (event: any) => void;
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Callback event saat pengguna mengetik (input event).
|
|
221
|
+
*/
|
|
222
|
+
onInput?: (event: any) => void;
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Callback event saat textarea kehilangan fokus (blur).
|
|
226
|
+
*/
|
|
227
|
+
onBlur?: (event: any) => void;
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Callback event saat textarea mendapatkan fokus.
|
|
231
|
+
*/
|
|
232
|
+
onFocus?: (event: any) => void;
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Ref instance elemen textarea HTML untuk akses kontrol DOM langsung (focus, blur, select).
|
|
236
|
+
*/
|
|
237
|
+
inputRef?: any;
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Class CSS kustom.
|
|
241
|
+
*/
|
|
242
|
+
className?: string;
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Callback event tombol keyboard ditekan.
|
|
246
|
+
*/
|
|
247
|
+
onKeyDown?: (event: any) => void;
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Callback event tombol keyboard dilepaskan.
|
|
251
|
+
*/
|
|
252
|
+
onKeyUp?: (event: any) => void;
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Menampilkan penghitung karakter di bawah textarea (format: `x / maxLength`).
|
|
256
|
+
* Memerlukan prop `maxLength` untuk berfungsi.
|
|
257
|
+
* @default false
|
|
258
|
+
*/
|
|
259
|
+
showCount?: boolean;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Komponen Textarea TTDK sesuai spesifikasi Anatomy Desain:
|
|
264
|
+
* 1. Field title (14px Semibold, #141313)
|
|
265
|
+
* 2. (Opsional) label (12px Regular, #9698A2)
|
|
266
|
+
* 3. Border radius 8px
|
|
267
|
+
* 4. Field content (14px Regular, #141313, placeholder #9698A2)
|
|
268
|
+
* 5. Additional information / Helper text (12px Regular, #3C4245)
|
|
269
|
+
*/
|
|
270
|
+
|
|
271
|
+
import { buildUiVars, UiProps } from "../../core/types";
|
|
272
|
+
|
|
273
|
+
const Textarea = forwardRef<any, TextareaProps>(function Textarea(
|
|
274
|
+
props: TextareaProps,
|
|
275
|
+
inputRef
|
|
276
|
+
) {
|
|
277
|
+
const [innerValue, setInnerValue] = useState(() =>
|
|
278
|
+
props.value !== undefined
|
|
279
|
+
? String(props.value)
|
|
280
|
+
: props.defaultValue !== undefined
|
|
281
|
+
? String(props.defaultValue)
|
|
282
|
+
: ""
|
|
283
|
+
);
|
|
284
|
+
|
|
285
|
+
function currentLength() {
|
|
286
|
+
if (props.value !== undefined) {
|
|
287
|
+
return String(props.value).length;
|
|
288
|
+
}
|
|
289
|
+
return innerValue.length;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
function handleInput(e: any) {
|
|
293
|
+
if (props.value === undefined) {
|
|
294
|
+
setInnerValue(e.target.value);
|
|
295
|
+
}
|
|
296
|
+
if (props.onInput) {
|
|
297
|
+
props.onInput(e);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
function handleChange(e: any) {
|
|
302
|
+
if (props.value === undefined) {
|
|
303
|
+
setInnerValue(e.target.value);
|
|
304
|
+
}
|
|
305
|
+
if (props.onChange) {
|
|
306
|
+
props.onChange(e);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
useEffect(() => {
|
|
311
|
+
if (props.value !== undefined) {
|
|
312
|
+
setInnerValue(String(props.value));
|
|
313
|
+
}
|
|
314
|
+
}, [props.value]);
|
|
315
|
+
|
|
316
|
+
return (
|
|
317
|
+
<div
|
|
318
|
+
className={`ttdk-form-item ${props.className || ""}`.trim()}
|
|
319
|
+
data-disabled={props.disabled}
|
|
320
|
+
data-error={Boolean(props.error || props.errorMessage)}
|
|
321
|
+
data-size={props.size || "md"}
|
|
322
|
+
data-block={props.block ? "true" : undefined}
|
|
323
|
+
style={{
|
|
324
|
+
...buildUiVars(props.ui),
|
|
325
|
+
...((props.ui as any) || {}),
|
|
326
|
+
...((props as any)["style"] || {}),
|
|
327
|
+
...props.style,
|
|
328
|
+
}}
|
|
329
|
+
>
|
|
330
|
+
{props.label ? (
|
|
331
|
+
<label
|
|
332
|
+
className={`ttdk-form-label ${props.labelClass || ""}`.trim()}
|
|
333
|
+
htmlFor={props.id}
|
|
334
|
+
style={{
|
|
335
|
+
...buildUiVars(props.labelStyle),
|
|
336
|
+
}}
|
|
337
|
+
>
|
|
338
|
+
<span>{props.label}</span>
|
|
339
|
+
{props.required ? (
|
|
340
|
+
<span className="ttdk-form-required" aria-hidden="true">
|
|
341
|
+
*
|
|
342
|
+
</span>
|
|
343
|
+
) : null}
|
|
344
|
+
{props.optional ? (
|
|
345
|
+
<span className="ttdk-form-optional">
|
|
346
|
+
{props.optionalText || "(Opsional)"}
|
|
347
|
+
</span>
|
|
348
|
+
) : null}
|
|
349
|
+
</label>
|
|
350
|
+
) : null}
|
|
351
|
+
{props.helperText && props.helperTextPosition === "top" ? (
|
|
352
|
+
<div
|
|
353
|
+
className={`ttdk-form-helper-text ${
|
|
354
|
+
props.helperTextClass || ""
|
|
355
|
+
}`.trim()}
|
|
356
|
+
style={{
|
|
357
|
+
...buildUiVars(props.helperTextStyle),
|
|
358
|
+
}}
|
|
359
|
+
>
|
|
360
|
+
{props.helperText}
|
|
361
|
+
</div>
|
|
362
|
+
) : null}
|
|
363
|
+
<div
|
|
364
|
+
className={`ttdk-textarea-wrapper ${props.wrapperClass || ""}`.trim()}
|
|
365
|
+
data-filled={Boolean(
|
|
366
|
+
props.value !== undefined ? props.value : innerValue
|
|
367
|
+
)}
|
|
368
|
+
data-error={Boolean(props.error || props.errorMessage)}
|
|
369
|
+
data-disabled={Boolean(props.disabled)}
|
|
370
|
+
data-size={props.size || "md"}
|
|
371
|
+
data-rounded={props.rounded || "md"}
|
|
372
|
+
style={{
|
|
373
|
+
...buildUiVars(props.wrapperStyle),
|
|
374
|
+
}}
|
|
375
|
+
>
|
|
376
|
+
<textarea
|
|
377
|
+
ref={inputRef}
|
|
378
|
+
className={`ttdk-textarea-control ${
|
|
379
|
+
props.textareaClass || ""
|
|
380
|
+
}`.trim()}
|
|
381
|
+
name={props.name}
|
|
382
|
+
id={props.id}
|
|
383
|
+
value={props.value !== undefined ? props.value : innerValue}
|
|
384
|
+
placeholder={props.placeholder}
|
|
385
|
+
rows={props.rows || 4}
|
|
386
|
+
disabled={props.disabled}
|
|
387
|
+
readOnly={props.readOnly}
|
|
388
|
+
required={props.required}
|
|
389
|
+
autoComplete={props.autoComplete}
|
|
390
|
+
maxLength={props.maxLength}
|
|
391
|
+
minLength={props.minLength}
|
|
392
|
+
aria-invalid={Boolean(props.error || props.errorMessage)}
|
|
393
|
+
style={{
|
|
394
|
+
resize: props.resize || "vertical",
|
|
395
|
+
...buildUiVars(props.textareaStyle),
|
|
396
|
+
}}
|
|
397
|
+
onChange={(e) => handleChange(e)}
|
|
398
|
+
onInput={(e) => handleInput(e)}
|
|
399
|
+
onBlur={(e) => props.onBlur && props.onBlur(e)}
|
|
400
|
+
onFocus={(e) => props.onFocus && props.onFocus(e)}
|
|
401
|
+
onKeyDown={(e) => props.onKeyDown && props.onKeyDown(e)}
|
|
402
|
+
onKeyUp={(e) => props.onKeyUp && props.onKeyUp(e)}
|
|
403
|
+
/>
|
|
404
|
+
</div>
|
|
405
|
+
{(props.helperText && props.helperTextPosition !== "top") ||
|
|
406
|
+
(props.errorMessage && (props.error || props.errorMessage)) ||
|
|
407
|
+
props.showCount ? (
|
|
408
|
+
<div className="ttdk-form-footer">
|
|
409
|
+
{(props.helperText && props.helperTextPosition !== "top") ||
|
|
410
|
+
(props.errorMessage && (props.error || props.errorMessage)) ? (
|
|
411
|
+
<div className="ttdk-form-footer-message">
|
|
412
|
+
{props.helperText && props.helperTextPosition !== "top" ? (
|
|
413
|
+
<div
|
|
414
|
+
className={`ttdk-form-helper-text ${
|
|
415
|
+
props.helperTextClass || ""
|
|
416
|
+
}`.trim()}
|
|
417
|
+
style={{
|
|
418
|
+
...buildUiVars(props.helperTextStyle),
|
|
419
|
+
}}
|
|
420
|
+
>
|
|
421
|
+
{props.helperText}
|
|
422
|
+
</div>
|
|
423
|
+
) : null}
|
|
424
|
+
{props.errorMessage && (props.error || props.errorMessage) ? (
|
|
425
|
+
<div
|
|
426
|
+
role="alert"
|
|
427
|
+
className={`ttdk-form-error-msg ${
|
|
428
|
+
props.errorMessageClass || ""
|
|
429
|
+
}`.trim()}
|
|
430
|
+
style={{
|
|
431
|
+
...buildUiVars(props.errorMessageStyle),
|
|
432
|
+
}}
|
|
433
|
+
>
|
|
434
|
+
<span>{props.errorMessage}</span>
|
|
435
|
+
</div>
|
|
436
|
+
) : null}
|
|
437
|
+
</div>
|
|
438
|
+
) : null}
|
|
439
|
+
{props.showCount ? (
|
|
440
|
+
<div
|
|
441
|
+
aria-live="polite"
|
|
442
|
+
className={`ttdk-form-char-count ${
|
|
443
|
+
props.charCountClass || ""
|
|
444
|
+
}`.trim()}
|
|
445
|
+
style={{
|
|
446
|
+
...buildUiVars(props.charCountStyle),
|
|
447
|
+
}}
|
|
448
|
+
>
|
|
449
|
+
{currentLength()}
|
|
450
|
+
{props.maxLength ? (
|
|
451
|
+
<>{` / ${props.maxLength}`}</>
|
|
452
|
+
) : (
|
|
453
|
+
<>
|
|
454
|
+
null
|
|
455
|
+
</>
|
|
456
|
+
)}
|
|
457
|
+
</div>
|
|
458
|
+
) : null}
|
|
459
|
+
</div>
|
|
460
|
+
) : null}
|
|
461
|
+
</div>
|
|
462
|
+
);
|
|
463
|
+
});
|
|
464
|
+
|
|
465
|
+
export default Textarea;
|
|
466
|
+
|
|
467
|
+
export { Textarea };
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# <Tooltip /> — TTDK Component Reference
|
|
2
|
+
|
|
3
|
+
Komponen Tooltip untuk menampilkan informasi kontekstual singkat saat pengguna mengarahkan kursor atau memfokuskan elemen pemicu.
|
|
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/tooltip/tooltip.css";`
|
|
8
|
+
|
|
9
|
+
## 2. Subpath Component Import
|
|
10
|
+
```ts
|
|
11
|
+
// React
|
|
12
|
+
import Tooltip from "@ttdk-design-system/library-react/web/tooltip";
|
|
13
|
+
|
|
14
|
+
// Vue 3
|
|
15
|
+
import Tooltip from "@ttdk-design-system/library-vue/web/tooltip";
|
|
16
|
+
|
|
17
|
+
// Svelte
|
|
18
|
+
import Tooltip from "@ttdk-design-system/library-svelte/web/tooltip";
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## 3. Props & API Reference
|
|
22
|
+
|
|
23
|
+
| Prop | Type | Default | Description |
|
|
24
|
+
| :--- | :--- | :--- | :--- |
|
|
25
|
+
| `text?` | `string` | `-` | Teks konten tooltip yang ditampilkan. |
|
|
26
|
+
| `content?` | `any` | `-` | Konten kustom tooltip (JSX / VNode atau renderable content). |
|
|
27
|
+
| `kbd?` | `string | string[]` | `-` | Pintasan keyboard opsional yang ditampilkan di dalam tooltip (misal: '⌘K', ['Ctrl', 'S']). |
|
|
28
|
+
| `placement?` | `TooltipPlacement` | `top` | Posisi penempatan tooltip terhadap elemen pemicu. |
|
|
29
|
+
| `offsetDistance?` | `number` | `8` | Jarak offset dalam pixel dari elemen pemicu (trigger). |
|
|
30
|
+
| `arrow?` | `boolean` | `true` | Menampilkan elemen panah segitiga penunjuk arah ke elemen pemicu. |
|
|
31
|
+
| `openDelay?` | `number` | `150` | Penundaan kemunculan tooltip dalam milidetik (delay saat pointer enter). |
|
|
32
|
+
| `closeDelay?` | `number` | `100` | Penundaan hilangnya tooltip dalam milidetik (delay saat pointer leave). |
|
|
33
|
+
| `open?` | `boolean` | `-` | Status visibilitas tooltip terkontrol (controlled mode). |
|
|
34
|
+
| `defaultOpen?` | `boolean` | `false` | Status visibilitas awal (uncontrolled initial state). |
|
|
35
|
+
| `disabled?` | `boolean` | `false` | Menonaktifkan tooltip sehingga tidak muncul saat di-hover atau difokus. |
|
|
36
|
+
| `ui?` | `TooltipUiProps` | `-` | Kustomisasi visual granular container utama (UiProps). |
|
|
37
|
+
| `style?` | `any` | `-` | Style inline CSS native untuk wrapper luar. |
|
|
38
|
+
| `className?` | `string` | `-` | Class CSS kustom untuk wrapper luar. |
|
|
39
|
+
| `triggerClass?` | `string` | `-` | Class CSS kustom untuk pemicu (trigger container). |
|
|
40
|
+
| `triggerStyle?` | `UiProps` | `-` | Style kustom untuk pemicu (trigger container) (UiProps). |
|
|
41
|
+
| `contentClass?` | `string` | `-` | Class CSS kustom untuk panel tooltip konten. |
|
|
42
|
+
| `contentStyle?` | `UiProps` | `-` | Style kustom untuk panel tooltip konten (UiProps). |
|
|
43
|
+
| `arrowClass?` | `string` | `-` | Class CSS kustom untuk elemen panah (arrow). |
|
|
44
|
+
| `arrowStyle?` | `UiProps` | `-` | Style kustom untuk elemen panah (arrow) (UiProps). |
|
|
45
|
+
| `onOpenChange?` | `(open: boolean) => void` | `-` | Callback saat status open berubah. |
|
|
46
|
+
| `children?` | `any` | `-` | Elemen pemicu (trigger) yang dibungkus oleh tooltip. |
|
|
47
|
+
|
|
48
|
+
## 4. Usage Examples
|
|
49
|
+
|
|
50
|
+
### React Example
|
|
51
|
+
```tsx
|
|
52
|
+
import React from "react";
|
|
53
|
+
import Tooltip from "@ttdk-design-system/library-react/web/tooltip";
|
|
54
|
+
import Button from "@ttdk-design-system/library-react/button";
|
|
55
|
+
import "@ttdk-design-system/library-react/web/tooltip/tooltip.css";
|
|
56
|
+
import "@ttdk-design-system/library-react/button/button.css";
|
|
57
|
+
|
|
58
|
+
export function Example() {
|
|
59
|
+
return (
|
|
60
|
+
<div style={{ display: "flex", gap: "16px", alignItems: "center" }}>
|
|
61
|
+
<Tooltip text="Salin riwayat rekam medis" placement="top" kbd="⌘C">
|
|
62
|
+
<Button variant="outline">Salin</Button>
|
|
63
|
+
</Tooltip>
|
|
64
|
+
<Tooltip text="Kirim resep digital ke apotek" placement="bottom">
|
|
65
|
+
<Button variant="primary">Kirim Resep</Button>
|
|
66
|
+
</Tooltip>
|
|
67
|
+
</div>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Vue 3 Example
|
|
73
|
+
```vue
|
|
74
|
+
<script setup lang="ts">
|
|
75
|
+
import Tooltip from "@ttdk-design-system/library-vue/web/tooltip";
|
|
76
|
+
import Button from "@ttdk-design-system/library-vue/button";
|
|
77
|
+
import "@ttdk-design-system/library-vue/web/tooltip/tooltip.css";
|
|
78
|
+
import "@ttdk-design-system/library-vue/button/button.css";
|
|
79
|
+
</script>
|
|
80
|
+
|
|
81
|
+
<template>
|
|
82
|
+
<div style="display: flex; gap: 16px; align-items: center;">
|
|
83
|
+
<Tooltip text="Salin riwayat rekam medis" placement="top" kbd="⌘C">
|
|
84
|
+
<Button variant="outline">Salin</Button>
|
|
85
|
+
</Tooltip>
|
|
86
|
+
<Tooltip text="Kirim resep digital ke apotek" placement="bottom">
|
|
87
|
+
<Button variant="primary">Kirim Resep</Button>
|
|
88
|
+
</Tooltip>
|
|
89
|
+
</div>
|
|
90
|
+
</template>
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Svelte Example
|
|
94
|
+
```svelte
|
|
95
|
+
<script lang="ts">
|
|
96
|
+
import Tooltip from "@ttdk-design-system/library-svelte/web/tooltip";
|
|
97
|
+
import Button from "@ttdk-design-system/library-svelte/button";
|
|
98
|
+
import "@ttdk-design-system/library-svelte/web/tooltip/tooltip.css";
|
|
99
|
+
import "@ttdk-design-system/library-svelte/button/button.css";
|
|
100
|
+
</script>
|
|
101
|
+
|
|
102
|
+
<div style="display: flex; gap: 16px; align-items: center;">
|
|
103
|
+
<Tooltip text="Salin riwayat rekam medis" placement="top" kbd="⌘C">
|
|
104
|
+
<Button variant="outline">Salin</Button>
|
|
105
|
+
</Tooltip>
|
|
106
|
+
<Tooltip text="Kirim resep digital ke apotek" placement="bottom">
|
|
107
|
+
<Button variant="primary">Kirim Resep</Button>
|
|
108
|
+
</Tooltip>
|
|
109
|
+
</div>
|
|
110
|
+
```
|