@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,537 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { forwardRef } from "react";
|
|
4
|
+
|
|
5
|
+
export type InputUiProps = UiProps;
|
|
6
|
+
export interface InputProps {
|
|
7
|
+
/**
|
|
8
|
+
* Teks label judul field yang ditampilkan di atas input (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 input wrapper (UiProps).
|
|
24
|
+
*/
|
|
25
|
+
wrapperStyle?: UiProps;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Class CSS kustom untuk elemen kontainer input wrapper.
|
|
29
|
+
*/
|
|
30
|
+
wrapperClass?: string;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Style kustom untuk elemen input control HTML (UiProps).
|
|
34
|
+
*/
|
|
35
|
+
inputStyle?: UiProps;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Class CSS kustom untuk elemen input control HTML.
|
|
39
|
+
*/
|
|
40
|
+
inputClass?: 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
|
+
* Menandai field sebagai opsi opsional dengan menambahkan teks '(Opsional)' (12px Regular, #9698A2).
|
|
64
|
+
*/
|
|
65
|
+
optional?: boolean;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Kustomisasi teks keterangan opsional.
|
|
69
|
+
* @default '(Opsional)'
|
|
70
|
+
*/
|
|
71
|
+
optionalText?: string;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Nilai teks placeholder saat input kosong (#9698A2).
|
|
75
|
+
*/
|
|
76
|
+
placeholder?: string;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Nilai terkontrol (controlled value) pada input.
|
|
80
|
+
*/
|
|
81
|
+
value?: string | number;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Nilai awal tidak terkontrol (uncontrolled initial value).
|
|
85
|
+
*/
|
|
86
|
+
defaultValue?: string | number;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Tipe field input HTML standar.
|
|
90
|
+
* @default 'text'
|
|
91
|
+
*/
|
|
92
|
+
type?: string;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Nama form field HTML untuk integrasi formulir.
|
|
96
|
+
*/
|
|
97
|
+
name?: string;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Identifier unik elemen input.
|
|
101
|
+
*/
|
|
102
|
+
id?: string;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Status apakah input sedang dalam kondisi error / tidak valid.
|
|
106
|
+
* @default false
|
|
107
|
+
*/
|
|
108
|
+
error?: boolean;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Pesan teks penjelasan kesalahan validasi di bawah field.
|
|
112
|
+
*/
|
|
113
|
+
errorMessage?: string;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Teks petunjuk atau keterangan bantuan di bawah field (12px Regular, #3C4245).
|
|
117
|
+
*/
|
|
118
|
+
helperText?: string;
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Posisi teks helper
|
|
122
|
+
*/
|
|
123
|
+
helperTextPosition?: "top" | "bottom";
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Skala ukuran input field.
|
|
127
|
+
* - `'sm'`: 36px
|
|
128
|
+
* - `'md'`: 48px (standar)
|
|
129
|
+
* - `'lg'`: 56px
|
|
130
|
+
* @default 'md'
|
|
131
|
+
*/
|
|
132
|
+
size?: "sm" | "md" | "lg";
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Bentuk sudut kelengkungan input.
|
|
136
|
+
* - `'none'`: 0px
|
|
137
|
+
* - `'sm'`: 4px
|
|
138
|
+
* - `'md'`: 8px (standar desain)
|
|
139
|
+
* - `'lg'`: 12px
|
|
140
|
+
* - `'full'`: 9999px (kapsul)
|
|
141
|
+
* @default 'md'
|
|
142
|
+
*/
|
|
143
|
+
rounded?: "none" | "sm" | "md" | "lg" | "full";
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Menjadikan lebar field input memenuhi kontainer penuh (full-width 100%).
|
|
147
|
+
* @default false
|
|
148
|
+
*/
|
|
149
|
+
block?: boolean;
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Status apakah field dinonaktifkan (disabled).
|
|
153
|
+
* @default false
|
|
154
|
+
*/
|
|
155
|
+
disabled?: boolean;
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Status apakah field bersifat hanya-baca (readonly).
|
|
159
|
+
* @default false
|
|
160
|
+
*/
|
|
161
|
+
readOnly?: boolean;
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Menandai field sebagai input wajib diisi (menampilkan tanda bintang merah *).
|
|
165
|
+
* @default false
|
|
166
|
+
*/
|
|
167
|
+
required?: boolean;
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Ikon di sebelah kiri dalam input (ukuran 20-24px, misal: Calendar, Search, User).
|
|
171
|
+
*/
|
|
172
|
+
iconLeft?: any;
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Ikon di sebelah kanan dalam input (ukuran 20-24px, misal: Chevron-down, Eye, Close).
|
|
176
|
+
*/
|
|
177
|
+
iconRight?: any;
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Addon / teks prefix di sebelah kiri luar input (misal: 'Text', '+62 (IDN)').
|
|
181
|
+
*/
|
|
182
|
+
addonLeft?: string | any;
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Addon / teks suffix di sebelah kanan luar input (misal: 'Text', '.com', 'kg').
|
|
186
|
+
*/
|
|
187
|
+
addonRight?: string | any;
|
|
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
|
+
* Nilai minimum untuk input bertipe number atau date.
|
|
206
|
+
*/
|
|
207
|
+
min?: number | string;
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Nilai maksimum untuk input bertipe number atau date.
|
|
211
|
+
*/
|
|
212
|
+
max?: number | string;
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Inline CSS style object native.
|
|
216
|
+
*/
|
|
217
|
+
style?: React.CSSProperties;
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Kustomisasi visual granular root / form-item (UiProps).
|
|
221
|
+
*/
|
|
222
|
+
ui?: UiProps;
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Callback event saat nilai input berubah.
|
|
226
|
+
*/
|
|
227
|
+
onChange?: (event: any) => void;
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Callback event saat pengguna mengetik (input event).
|
|
231
|
+
*/
|
|
232
|
+
onInput?: (event: any) => void;
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Callback event saat field input kehilangan fokus.
|
|
236
|
+
*/
|
|
237
|
+
onBlur?: (event: any) => void;
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Callback event saat field input mendapatkan fokus.
|
|
241
|
+
*/
|
|
242
|
+
onFocus?: (event: any) => void;
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Ref instance elemen input HTML untuk akses kontrol DOM langsung (focus, blur, select).
|
|
246
|
+
*/
|
|
247
|
+
inputRef?: any;
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Class CSS kustom.
|
|
251
|
+
*/
|
|
252
|
+
className?: string;
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Callback event tombol keyboard ditekan.
|
|
256
|
+
*/
|
|
257
|
+
onKeyDown?: (event: any) => void;
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Callback event tombol keyboard dilepaskan.
|
|
261
|
+
*/
|
|
262
|
+
onKeyUp?: (event: any) => void;
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Menampilkan spinner dan menonaktifkan interaksi field sementara menunggu proses async.
|
|
266
|
+
* @default false
|
|
267
|
+
*/
|
|
268
|
+
loading?: boolean;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Komponen Input TTDK sesuai spesifikasi Anatomy Desain:
|
|
273
|
+
* 1. Field title (14px Semibold, #141313)
|
|
274
|
+
* 2. (Opsional) label (12px Regular, #9698A2)
|
|
275
|
+
* 3. Border radius 8px
|
|
276
|
+
* 4. Icon left / right (24px)
|
|
277
|
+
* 5. Field content (14px Regular, #141313, placeholder #9698A2)
|
|
278
|
+
* 6. Additional information / Helper text (12px Regular, #3C4245)
|
|
279
|
+
*/
|
|
280
|
+
|
|
281
|
+
import { buildUiVars, UiProps } from "../../core/types";
|
|
282
|
+
|
|
283
|
+
const Input = forwardRef<any, InputProps>(function Input(
|
|
284
|
+
props: InputProps,
|
|
285
|
+
inputRef
|
|
286
|
+
) {
|
|
287
|
+
return (
|
|
288
|
+
<div
|
|
289
|
+
className={`ttdk-form-item ${props.className || ""}`.trim()}
|
|
290
|
+
data-disabled={props.disabled}
|
|
291
|
+
data-error={Boolean(props.error || props.errorMessage)}
|
|
292
|
+
data-size={props.size || "md"}
|
|
293
|
+
data-block={props.block ? "true" : undefined}
|
|
294
|
+
style={{
|
|
295
|
+
...buildUiVars(props.ui),
|
|
296
|
+
...((props.ui as any) || {}),
|
|
297
|
+
...((props as any)["style"] || {}),
|
|
298
|
+
...props.style,
|
|
299
|
+
}}
|
|
300
|
+
>
|
|
301
|
+
{props.label ? (
|
|
302
|
+
<label
|
|
303
|
+
className={`ttdk-form-label ${props.labelClass || ""}`.trim()}
|
|
304
|
+
htmlFor={props.id}
|
|
305
|
+
style={{
|
|
306
|
+
...buildUiVars(props.labelStyle),
|
|
307
|
+
}}
|
|
308
|
+
>
|
|
309
|
+
<span>{props.label}</span>
|
|
310
|
+
{props.required ? (
|
|
311
|
+
<span className="ttdk-form-required" aria-hidden="true">
|
|
312
|
+
*
|
|
313
|
+
</span>
|
|
314
|
+
) : null}
|
|
315
|
+
{props.optional ? (
|
|
316
|
+
<span className="ttdk-form-optional">
|
|
317
|
+
{props.optionalText || "(Opsional)"}
|
|
318
|
+
</span>
|
|
319
|
+
) : null}
|
|
320
|
+
</label>
|
|
321
|
+
) : null}
|
|
322
|
+
{props.helperText && props.helperTextPosition === "top" ? (
|
|
323
|
+
<div
|
|
324
|
+
className={`ttdk-form-helper-text ${
|
|
325
|
+
props.helperTextClass || ""
|
|
326
|
+
}`.trim()}
|
|
327
|
+
style={{
|
|
328
|
+
...buildUiVars(props.helperTextStyle),
|
|
329
|
+
}}
|
|
330
|
+
>
|
|
331
|
+
{props.helperText}
|
|
332
|
+
</div>
|
|
333
|
+
) : null}
|
|
334
|
+
<div
|
|
335
|
+
className={`ttdk-input-wrapper ${props.wrapperClass || ""}`.trim()}
|
|
336
|
+
data-filled={Boolean(props.value || props.defaultValue)}
|
|
337
|
+
data-error={Boolean(props.error || props.errorMessage)}
|
|
338
|
+
data-disabled={Boolean(props.disabled)}
|
|
339
|
+
data-size={props.size || "md"}
|
|
340
|
+
data-rounded={props.rounded || "md"}
|
|
341
|
+
style={{
|
|
342
|
+
...buildUiVars(props.wrapperStyle),
|
|
343
|
+
}}
|
|
344
|
+
>
|
|
345
|
+
{props.addonLeft ? (
|
|
346
|
+
<div className="ttdk-input-addon ttdk-input-addon-left">
|
|
347
|
+
{props.addonLeft}
|
|
348
|
+
</div>
|
|
349
|
+
) : null}
|
|
350
|
+
<div className="ttdk-input-inner">
|
|
351
|
+
{props.iconLeft ? (
|
|
352
|
+
<span
|
|
353
|
+
className="ttdk-input-icon ttdk-input-icon-left"
|
|
354
|
+
aria-hidden="true"
|
|
355
|
+
>
|
|
356
|
+
{props.iconLeft}
|
|
357
|
+
</span>
|
|
358
|
+
) : null}
|
|
359
|
+
<input
|
|
360
|
+
ref={inputRef}
|
|
361
|
+
className={`ttdk-input-control ${props.inputClass || ""}`.trim()}
|
|
362
|
+
type={props.type || "text"}
|
|
363
|
+
name={props.name}
|
|
364
|
+
id={props.id}
|
|
365
|
+
value={props.value !== undefined ? props.value : props.defaultValue}
|
|
366
|
+
placeholder={props.placeholder}
|
|
367
|
+
disabled={props.disabled}
|
|
368
|
+
readOnly={props.readOnly}
|
|
369
|
+
required={props.required}
|
|
370
|
+
autoComplete={props.autoComplete}
|
|
371
|
+
maxLength={props.maxLength}
|
|
372
|
+
minLength={props.minLength}
|
|
373
|
+
min={props.min}
|
|
374
|
+
max={props.max}
|
|
375
|
+
aria-invalid={Boolean(props.error || props.errorMessage)}
|
|
376
|
+
style={{
|
|
377
|
+
...buildUiVars(props.inputStyle),
|
|
378
|
+
}}
|
|
379
|
+
onChange={(e) => props.onChange && props.onChange(e)}
|
|
380
|
+
onInput={(e) => props.onInput && props.onInput(e)}
|
|
381
|
+
onBlur={(e) => props.onBlur && props.onBlur(e)}
|
|
382
|
+
onFocus={(e) => props.onFocus && props.onFocus(e)}
|
|
383
|
+
onKeyDown={(e) => props.onKeyDown && props.onKeyDown(e)}
|
|
384
|
+
onKeyUp={(e) => props.onKeyUp && props.onKeyUp(e)}
|
|
385
|
+
/>
|
|
386
|
+
{props.loading ? (
|
|
387
|
+
<span
|
|
388
|
+
className="ttdk-input-icon ttdk-input-icon-right ttdk-input-spinner"
|
|
389
|
+
aria-hidden="true"
|
|
390
|
+
>
|
|
391
|
+
<svg viewBox="0 0 24 24">
|
|
392
|
+
<line
|
|
393
|
+
x1="12"
|
|
394
|
+
y1="2.5"
|
|
395
|
+
x2="12"
|
|
396
|
+
y2="6.5"
|
|
397
|
+
opacity="0.175"
|
|
398
|
+
transform="rotate(0 12 12)"
|
|
399
|
+
/>
|
|
400
|
+
<line
|
|
401
|
+
x1="12"
|
|
402
|
+
y1="2.5"
|
|
403
|
+
x2="12"
|
|
404
|
+
y2="6.5"
|
|
405
|
+
opacity="0.25"
|
|
406
|
+
transform="rotate(30 12 12)"
|
|
407
|
+
/>
|
|
408
|
+
<line
|
|
409
|
+
x1="12"
|
|
410
|
+
y1="2.5"
|
|
411
|
+
x2="12"
|
|
412
|
+
y2="6.5"
|
|
413
|
+
opacity="0.325"
|
|
414
|
+
transform="rotate(60 12 12)"
|
|
415
|
+
/>
|
|
416
|
+
<line
|
|
417
|
+
x1="12"
|
|
418
|
+
y1="2.5"
|
|
419
|
+
x2="12"
|
|
420
|
+
y2="6.5"
|
|
421
|
+
opacity="0.4"
|
|
422
|
+
transform="rotate(90 12 12)"
|
|
423
|
+
/>
|
|
424
|
+
<line
|
|
425
|
+
x1="12"
|
|
426
|
+
y1="2.5"
|
|
427
|
+
x2="12"
|
|
428
|
+
y2="6.5"
|
|
429
|
+
opacity="0.475"
|
|
430
|
+
transform="rotate(120 12 12)"
|
|
431
|
+
/>
|
|
432
|
+
<line
|
|
433
|
+
x1="12"
|
|
434
|
+
y1="2.5"
|
|
435
|
+
x2="12"
|
|
436
|
+
y2="6.5"
|
|
437
|
+
opacity="0.55"
|
|
438
|
+
transform="rotate(150 12 12)"
|
|
439
|
+
/>
|
|
440
|
+
<line
|
|
441
|
+
x1="12"
|
|
442
|
+
y1="2.5"
|
|
443
|
+
x2="12"
|
|
444
|
+
y2="6.5"
|
|
445
|
+
opacity="0.625"
|
|
446
|
+
transform="rotate(180 12 12)"
|
|
447
|
+
/>
|
|
448
|
+
<line
|
|
449
|
+
x1="12"
|
|
450
|
+
y1="2.5"
|
|
451
|
+
x2="12"
|
|
452
|
+
y2="6.5"
|
|
453
|
+
opacity="0.7"
|
|
454
|
+
transform="rotate(210 12 12)"
|
|
455
|
+
/>
|
|
456
|
+
<line
|
|
457
|
+
x1="12"
|
|
458
|
+
y1="2.5"
|
|
459
|
+
x2="12"
|
|
460
|
+
y2="6.5"
|
|
461
|
+
opacity="0.775"
|
|
462
|
+
transform="rotate(240 12 12)"
|
|
463
|
+
/>
|
|
464
|
+
<line
|
|
465
|
+
x1="12"
|
|
466
|
+
y1="2.5"
|
|
467
|
+
x2="12"
|
|
468
|
+
y2="6.5"
|
|
469
|
+
opacity="0.85"
|
|
470
|
+
transform="rotate(270 12 12)"
|
|
471
|
+
/>
|
|
472
|
+
<line
|
|
473
|
+
x1="12"
|
|
474
|
+
y1="2.5"
|
|
475
|
+
x2="12"
|
|
476
|
+
y2="6.5"
|
|
477
|
+
opacity="0.925"
|
|
478
|
+
transform="rotate(300 12 12)"
|
|
479
|
+
/>
|
|
480
|
+
<line
|
|
481
|
+
x1="12"
|
|
482
|
+
y1="2.5"
|
|
483
|
+
x2="12"
|
|
484
|
+
y2="6.5"
|
|
485
|
+
opacity="1"
|
|
486
|
+
transform="rotate(330 12 12)"
|
|
487
|
+
/>
|
|
488
|
+
</svg>
|
|
489
|
+
</span>
|
|
490
|
+
) : null}
|
|
491
|
+
{!props.loading && props.iconRight ? (
|
|
492
|
+
<span
|
|
493
|
+
className="ttdk-input-icon ttdk-input-icon-right"
|
|
494
|
+
aria-hidden="true"
|
|
495
|
+
>
|
|
496
|
+
{props.iconRight}
|
|
497
|
+
</span>
|
|
498
|
+
) : null}
|
|
499
|
+
</div>
|
|
500
|
+
{props.addonRight ? (
|
|
501
|
+
<div className="ttdk-input-addon ttdk-input-addon-right">
|
|
502
|
+
{props.addonRight}
|
|
503
|
+
</div>
|
|
504
|
+
) : null}
|
|
505
|
+
</div>
|
|
506
|
+
{props.helperText && props.helperTextPosition !== "top" ? (
|
|
507
|
+
<div
|
|
508
|
+
className={`ttdk-form-helper-text ${
|
|
509
|
+
props.helperTextClass || ""
|
|
510
|
+
}`.trim()}
|
|
511
|
+
style={{
|
|
512
|
+
...buildUiVars(props.helperTextStyle),
|
|
513
|
+
}}
|
|
514
|
+
>
|
|
515
|
+
{props.helperText}
|
|
516
|
+
</div>
|
|
517
|
+
) : null}
|
|
518
|
+
{props.errorMessage && (props.error || props.errorMessage) ? (
|
|
519
|
+
<div
|
|
520
|
+
role="alert"
|
|
521
|
+
className={`ttdk-form-error-msg ${
|
|
522
|
+
props.errorMessageClass || ""
|
|
523
|
+
}`.trim()}
|
|
524
|
+
style={{
|
|
525
|
+
...buildUiVars(props.errorMessageStyle),
|
|
526
|
+
}}
|
|
527
|
+
>
|
|
528
|
+
<span>{props.errorMessage}</span>
|
|
529
|
+
</div>
|
|
530
|
+
) : null}
|
|
531
|
+
</div>
|
|
532
|
+
);
|
|
533
|
+
});
|
|
534
|
+
|
|
535
|
+
export default Input;
|
|
536
|
+
|
|
537
|
+
export { Input };
|