@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,430 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
|
|
5
|
+
export type AccordionUiProps = UiProps;
|
|
6
|
+
export interface AccordionItem {
|
|
7
|
+
/**
|
|
8
|
+
* Nilai identifikasi unik untuk item accordion.
|
|
9
|
+
*/
|
|
10
|
+
value: string;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Judul teks yang ditampilkan pada header trigger accordion.
|
|
14
|
+
*/
|
|
15
|
+
title: string;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Subtitle atau deskripsi singkat sekunder di bawah judul.
|
|
19
|
+
*/
|
|
20
|
+
subtitle?: string;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Konten isi panel yang terbuka saat accordion di-expand.
|
|
24
|
+
*/
|
|
25
|
+
content?: any;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Ikon atau elemen visual opsional di samping judul.
|
|
29
|
+
*/
|
|
30
|
+
icon?: any;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Badge teks atau counter angka opsional (misal: '12', 'Baru', 'Wajib').
|
|
34
|
+
*/
|
|
35
|
+
badge?: string | number;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Ikon kustom untuk menggantikan ikon panah bawaan khusus item ini.
|
|
39
|
+
*/
|
|
40
|
+
customIcon?: any;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Menonaktifkan item ini dari interaksi buka/tutup.
|
|
44
|
+
* @default false
|
|
45
|
+
*/
|
|
46
|
+
disabled?: boolean;
|
|
47
|
+
}
|
|
48
|
+
export interface AccordionProps {
|
|
49
|
+
/**
|
|
50
|
+
* Daftar item accordion yang akan dirender.
|
|
51
|
+
*/
|
|
52
|
+
items: AccordionItem[];
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Nilai item yang sedang terbuka (controlled value).
|
|
56
|
+
* Bisa berupa string tunggal atau array string jika multiple={true}.
|
|
57
|
+
*/
|
|
58
|
+
value?: string | string[];
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Nilai default item yang terbuka saat pertama kali dirender (uncontrolled initial value).
|
|
62
|
+
*/
|
|
63
|
+
defaultValue?: string | string[];
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Mengizinkan lebih dari satu item terbuka secara bersamaan.
|
|
67
|
+
* @default false
|
|
68
|
+
*/
|
|
69
|
+
multiple?: boolean;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Mengizinkan item yang terbuka untuk ditutup kembali saat diklik.
|
|
73
|
+
* @default true
|
|
74
|
+
*/
|
|
75
|
+
collapsible?: boolean;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Varian tampilan visual accordion:
|
|
79
|
+
* - `'default'`: Garis pembatas (divider) minimalis antar-item.
|
|
80
|
+
* - `'bordered'`: Pembungkus border luar dengan sudut melengkung.
|
|
81
|
+
* - `'separated'`: Setiap item berupa kartu terpisah mandiri dengan jarak celah (gap).
|
|
82
|
+
* - `'ghost'`: Tampilan bersih tanpa border luar, hanya hover background lembut.
|
|
83
|
+
*
|
|
84
|
+
* @default 'default'
|
|
85
|
+
*/
|
|
86
|
+
variant?: "default" | "bordered" | "separated" | "ghost";
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Skala ukuran proporsional accordion (padding, font, icon):
|
|
90
|
+
* - `'sm'`: Kompak (13px font, padding rapat).
|
|
91
|
+
* - `'md'`: Standar (14px font, padding normal).
|
|
92
|
+
* - `'lg'`: Besar (16px font, padding lapang).
|
|
93
|
+
*
|
|
94
|
+
* @default 'md'
|
|
95
|
+
*/
|
|
96
|
+
size?: "sm" | "md" | "lg";
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Posisi indikator ikon panah / chevron:
|
|
100
|
+
* - `'right'`: Di ujung kanan (standar desain).
|
|
101
|
+
* - `'left'`: Di sebelah kiri sebelum judul.
|
|
102
|
+
*
|
|
103
|
+
* @default 'right'
|
|
104
|
+
*/
|
|
105
|
+
iconPosition?: "left" | "right";
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Sudut kelengkungan radius (khusus untuk varian 'bordered' dan 'separated'):
|
|
109
|
+
* - `'none'`: Sudut 0px.
|
|
110
|
+
* - `'sm'`: Sudut 6px.
|
|
111
|
+
* - `'md'`: Sudut 10px.
|
|
112
|
+
* - `'lg'`: Sudut 14px.
|
|
113
|
+
* - `'full'`: Sudut 20px.
|
|
114
|
+
*
|
|
115
|
+
* @default 'md'
|
|
116
|
+
*/
|
|
117
|
+
rounded?: "none" | "sm" | "md" | "lg" | "full";
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Menonaktifkan seluruh interaksi accordion.
|
|
121
|
+
* @default false
|
|
122
|
+
*/
|
|
123
|
+
disabled?: boolean;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Kustomisasi visual granular root container (UiProps).
|
|
127
|
+
*/
|
|
128
|
+
ui?: UiProps;
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Inline CSS style object native.
|
|
132
|
+
*/
|
|
133
|
+
style?: React.CSSProperties;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Class CSS kustom untuk root accordion.
|
|
137
|
+
*/
|
|
138
|
+
className?: string;
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Style kustom untuk tiap elemen item accordion (UiProps).
|
|
142
|
+
*/
|
|
143
|
+
itemStyle?: UiProps;
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Class CSS kustom untuk tiap elemen item accordion.
|
|
147
|
+
*/
|
|
148
|
+
itemClass?: string;
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Style kustom untuk tombol trigger accordion (UiProps).
|
|
152
|
+
*/
|
|
153
|
+
triggerStyle?: UiProps;
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Class CSS kustom untuk tombol trigger accordion.
|
|
157
|
+
*/
|
|
158
|
+
triggerClass?: string;
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Style kustom untuk teks judul trigger accordion (UiProps).
|
|
162
|
+
*/
|
|
163
|
+
titleStyle?: UiProps;
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Class CSS kustom untuk teks judul trigger accordion.
|
|
167
|
+
*/
|
|
168
|
+
titleClass?: string;
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Style kustom untuk teks subtitle trigger accordion (UiProps).
|
|
172
|
+
*/
|
|
173
|
+
subtitleStyle?: UiProps;
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Class CSS kustom untuk teks subtitle trigger accordion.
|
|
177
|
+
*/
|
|
178
|
+
subtitleClass?: string;
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Style kustom untuk indikator ikon panah / chevron (UiProps).
|
|
182
|
+
*/
|
|
183
|
+
iconStyle?: UiProps;
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Class CSS kustom untuk indikator ikon panah / chevron.
|
|
187
|
+
*/
|
|
188
|
+
iconClass?: string;
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Ikon kustom untuk menggantikan ikon panah bawaan accordion secara global.
|
|
192
|
+
*/
|
|
193
|
+
icon?: any;
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Style kustom untuk panel konten accordion (UiProps).
|
|
197
|
+
* Mengatur seluruh tampilan panel isi (background, padding, border, serta warna & tipografi teks isi).
|
|
198
|
+
*/
|
|
199
|
+
contentStyle?: UiProps;
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Class CSS kustom untuk panel konten accordion.
|
|
203
|
+
*/
|
|
204
|
+
contentClass?: string;
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Callback event saat status item yang terbuka berubah.
|
|
208
|
+
* Mengembalikan string atau array string sesuai mode `multiple`.
|
|
209
|
+
*/
|
|
210
|
+
onChange?: (value: any) => void;
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Konten anak atau slot kustom.
|
|
214
|
+
*/
|
|
215
|
+
children?: any;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Komponen Accordion untuk menyusun informasi berlapis yang dapat dibuka-tutup (collapse/expand)
|
|
220
|
+
* dengan dukungan multiple open, berbagai varian visual (default, bordered, separated, ghost),
|
|
221
|
+
* serta animasi transisi grid CSS yang sangat halus.
|
|
222
|
+
*/
|
|
223
|
+
|
|
224
|
+
import {
|
|
225
|
+
buildUiStyle,
|
|
226
|
+
buildUiVars,
|
|
227
|
+
cleanUiValue,
|
|
228
|
+
UiProps,
|
|
229
|
+
} from "../../core/types";
|
|
230
|
+
|
|
231
|
+
function Accordion(props: AccordionProps) {
|
|
232
|
+
const [openItems, setOpenItems] = useState(() =>
|
|
233
|
+
props.value !== undefined
|
|
234
|
+
? Array.isArray(props.value)
|
|
235
|
+
? props.value
|
|
236
|
+
: [props.value]
|
|
237
|
+
: props.defaultValue !== undefined
|
|
238
|
+
? Array.isArray(props.defaultValue)
|
|
239
|
+
? props.defaultValue
|
|
240
|
+
: [props.defaultValue]
|
|
241
|
+
: ([] as string[])
|
|
242
|
+
);
|
|
243
|
+
|
|
244
|
+
function getOpenList() {
|
|
245
|
+
const val = props.value !== undefined ? props.value : openItems;
|
|
246
|
+
if (!val) return [] as string[];
|
|
247
|
+
return Array.isArray(val) ? val : [val];
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
function isOpen(itemVal: string) {
|
|
251
|
+
const list = getOpenList();
|
|
252
|
+
return list.indexOf(itemVal) !== -1;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
function handleToggle(itemVal: string, itemDisabled?: boolean) {
|
|
256
|
+
if (props.disabled || itemDisabled) return;
|
|
257
|
+
const list = getOpenList();
|
|
258
|
+
const isCurrentlyOpen = list.indexOf(itemVal) !== -1;
|
|
259
|
+
let next: string[];
|
|
260
|
+
if (props.multiple) {
|
|
261
|
+
if (isCurrentlyOpen) {
|
|
262
|
+
next = list.filter((v: string) => v !== itemVal);
|
|
263
|
+
} else {
|
|
264
|
+
next = [...list, itemVal];
|
|
265
|
+
}
|
|
266
|
+
} else {
|
|
267
|
+
if (isCurrentlyOpen) {
|
|
268
|
+
if (props.collapsible === false) {
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
next = [];
|
|
272
|
+
} else {
|
|
273
|
+
next = [itemVal];
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
setOpenItems(next);
|
|
277
|
+
if (props.onChange) {
|
|
278
|
+
props.onChange(props.multiple ? next : next[0] || "");
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
return (
|
|
283
|
+
<div
|
|
284
|
+
className={`ttdk-accordion ${props.className || ""}`.trim()}
|
|
285
|
+
data-variant={props.variant || "default"}
|
|
286
|
+
data-size={props.size || "md"}
|
|
287
|
+
data-icon-position={props.iconPosition || "right"}
|
|
288
|
+
data-rounded={props.rounded || "md"}
|
|
289
|
+
data-disabled={props.disabled ? "true" : "false"}
|
|
290
|
+
style={{
|
|
291
|
+
...buildUiVars(props.ui),
|
|
292
|
+
...((props as any)["style"] || {}),
|
|
293
|
+
...props.style,
|
|
294
|
+
}}
|
|
295
|
+
>
|
|
296
|
+
{props.items?.map((item, index) => (
|
|
297
|
+
<div
|
|
298
|
+
key={item.value || index}
|
|
299
|
+
className={`ttdk-accordion-item ${props.itemClass || ""}`.trim()}
|
|
300
|
+
data-state={isOpen(item.value) ? "open" : "closed"}
|
|
301
|
+
data-disabled={props.disabled || item.disabled ? "true" : "false"}
|
|
302
|
+
style={{
|
|
303
|
+
...buildUiStyle(props.itemStyle),
|
|
304
|
+
}}
|
|
305
|
+
>
|
|
306
|
+
<h3 className="ttdk-accordion-header">
|
|
307
|
+
<button
|
|
308
|
+
type="button"
|
|
309
|
+
className={`ttdk-accordion-trigger ${
|
|
310
|
+
props.triggerClass || ""
|
|
311
|
+
}`.trim()}
|
|
312
|
+
data-state={isOpen(item.value) ? "open" : "closed"}
|
|
313
|
+
data-disabled={props.disabled || item.disabled ? "true" : "false"}
|
|
314
|
+
disabled={props.disabled || item.disabled}
|
|
315
|
+
aria-expanded={isOpen(item.value)}
|
|
316
|
+
onClick={(event) => handleToggle(item.value, item.disabled)}
|
|
317
|
+
style={{
|
|
318
|
+
...buildUiStyle(props.triggerStyle),
|
|
319
|
+
}}
|
|
320
|
+
>
|
|
321
|
+
{props.iconPosition === "left" ? (
|
|
322
|
+
<span
|
|
323
|
+
aria-hidden="true"
|
|
324
|
+
className={`ttdk-accordion-arrow ttdk-accordion-arrow-left ${
|
|
325
|
+
props.iconClass || ""
|
|
326
|
+
}`.trim()}
|
|
327
|
+
data-state={isOpen(item.value) ? "open" : "closed"}
|
|
328
|
+
style={{
|
|
329
|
+
...buildUiStyle(props.iconStyle),
|
|
330
|
+
}}
|
|
331
|
+
>
|
|
332
|
+
{props.icon ? <>{props.icon}</> : null}
|
|
333
|
+
{!props.icon ? (
|
|
334
|
+
<svg
|
|
335
|
+
className="ttdk-accordion-icon"
|
|
336
|
+
viewBox="0 0 24 24"
|
|
337
|
+
fill="none"
|
|
338
|
+
stroke="currentColor"
|
|
339
|
+
>
|
|
340
|
+
<polyline points="6 9 12 15 18 9" />
|
|
341
|
+
</svg>
|
|
342
|
+
) : null}
|
|
343
|
+
</span>
|
|
344
|
+
) : null}
|
|
345
|
+
{item.icon ? (
|
|
346
|
+
<span className="ttdk-accordion-leading-icon">{item.icon}</span>
|
|
347
|
+
) : null}
|
|
348
|
+
<span className="ttdk-accordion-label-group">
|
|
349
|
+
<span
|
|
350
|
+
className={`ttdk-accordion-title ${
|
|
351
|
+
props.titleClass || ""
|
|
352
|
+
}`.trim()}
|
|
353
|
+
style={{
|
|
354
|
+
...buildUiStyle(props.titleStyle),
|
|
355
|
+
}}
|
|
356
|
+
>
|
|
357
|
+
{item.title}
|
|
358
|
+
</span>
|
|
359
|
+
{item.subtitle ? (
|
|
360
|
+
<span
|
|
361
|
+
className={`ttdk-accordion-subtitle ${
|
|
362
|
+
props.subtitleClass || ""
|
|
363
|
+
}`.trim()}
|
|
364
|
+
style={{
|
|
365
|
+
...buildUiStyle(props.subtitleStyle),
|
|
366
|
+
}}
|
|
367
|
+
>
|
|
368
|
+
{item.subtitle}
|
|
369
|
+
</span>
|
|
370
|
+
) : null}
|
|
371
|
+
</span>
|
|
372
|
+
{item.badge !== undefined && item.badge !== null ? (
|
|
373
|
+
<span className="ttdk-accordion-badge">{item.badge}</span>
|
|
374
|
+
) : null}
|
|
375
|
+
{props.iconPosition !== "left" ? (
|
|
376
|
+
<span
|
|
377
|
+
aria-hidden="true"
|
|
378
|
+
className={`ttdk-accordion-arrow ttdk-accordion-arrow-right ${
|
|
379
|
+
props.iconClass || ""
|
|
380
|
+
}`.trim()}
|
|
381
|
+
data-state={isOpen(item.value) ? "open" : "closed"}
|
|
382
|
+
style={{
|
|
383
|
+
...buildUiStyle(props.iconStyle),
|
|
384
|
+
}}
|
|
385
|
+
>
|
|
386
|
+
{props.icon ? <>{props.icon}</> : null}
|
|
387
|
+
{!item.customIcon && !props.icon ? (
|
|
388
|
+
<svg
|
|
389
|
+
className="ttdk-accordion-icon"
|
|
390
|
+
viewBox="0 0 24 24"
|
|
391
|
+
fill="none"
|
|
392
|
+
stroke="currentColor"
|
|
393
|
+
>
|
|
394
|
+
<polyline points="6 9 12 15 18 9" />
|
|
395
|
+
</svg>
|
|
396
|
+
) : null}
|
|
397
|
+
</span>
|
|
398
|
+
) : null}
|
|
399
|
+
</button>
|
|
400
|
+
</h3>
|
|
401
|
+
<div
|
|
402
|
+
className="ttdk-accordion-panel"
|
|
403
|
+
role="region"
|
|
404
|
+
data-state={isOpen(item.value) ? "open" : "closed"}
|
|
405
|
+
>
|
|
406
|
+
<div
|
|
407
|
+
className={`ttdk-accordion-content ${
|
|
408
|
+
props.contentClass || ""
|
|
409
|
+
}`.trim()}
|
|
410
|
+
style={{
|
|
411
|
+
...buildUiStyle(props.contentStyle),
|
|
412
|
+
}}
|
|
413
|
+
>
|
|
414
|
+
{item.content}
|
|
415
|
+
</div>
|
|
416
|
+
</div>
|
|
417
|
+
</div>
|
|
418
|
+
))}
|
|
419
|
+
{props.children ? (
|
|
420
|
+
<div className="ttdk-accordion-children">
|
|
421
|
+
<>{props.children}</>
|
|
422
|
+
</div>
|
|
423
|
+
) : null}
|
|
424
|
+
</div>
|
|
425
|
+
);
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
export default Accordion;
|
|
429
|
+
|
|
430
|
+
export { Accordion };
|