@skalfa/skalfa-app 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/.env.example +44 -0
- package/README.md +28 -0
- package/app/auth/edit/page.tsx +65 -0
- package/app/auth/login/page.tsx +63 -0
- package/app/auth/me/page.tsx +58 -0
- package/app/auth/register/page.tsx +69 -0
- package/app/auth/verify/page.tsx +53 -0
- package/app/dashboard/layout.tsx +47 -0
- package/app/dashboard/page.tsx +9 -0
- package/app/dashboard/user/page.tsx +77 -0
- package/app/index.ts +14 -0
- package/app/layout.tsx +38 -0
- package/app/page.tsx +13 -0
- package/barrels.json +6 -0
- package/blueprints/starter.blueprint.json +103 -0
- package/components/base.components/accordion/Accordion.component.tsx +82 -0
- package/components/base.components/breadcrumb/Breadcrumb.component.tsx +80 -0
- package/components/base.components/button/Button.component.tsx +91 -0
- package/components/base.components/button/IconButton.component.tsx +88 -0
- package/components/base.components/button/button.decorate.ts +82 -0
- package/components/base.components/card/AlertCard.component.tsx +69 -0
- package/components/base.components/card/Card.component.tsx +25 -0
- package/components/base.components/card/DashboardCard.component.tsx +44 -0
- package/components/base.components/card/GalleryCard.component.tsx +50 -0
- package/components/base.components/card/ProductCard.component.tsx +65 -0
- package/components/base.components/card/ProfileCard.component.tsx +71 -0
- package/components/base.components/carousel/Carousel.component.tsx +113 -0
- package/components/base.components/chip/Chip.component.tsx +39 -0
- package/components/base.components/document/DocumentViewer.component.tsx +164 -0
- package/components/base.components/document/ExportExcel.component.tsx +340 -0
- package/components/base.components/document/ImportExcel.component.tsx +315 -0
- package/components/base.components/document/PrintTable.component.tsx +204 -0
- package/components/base.components/document/RenderPDF.component.tsx +416 -0
- package/components/base.components/index.ts +85 -0
- package/components/base.components/input/Checkbox.component.tsx +109 -0
- package/components/base.components/input/Input.component.tsx +332 -0
- package/components/base.components/input/InputCheckbox.component.tsx +174 -0
- package/components/base.components/input/InputCurrency.component.tsx +163 -0
- package/components/base.components/input/InputDate.component.tsx +352 -0
- package/components/base.components/input/InputDatetime.component.tsx +260 -0
- package/components/base.components/input/InputDocument.component.tsx +352 -0
- package/components/base.components/input/InputImage.component.tsx +533 -0
- package/components/base.components/input/InputMap.component.tsx +318 -0
- package/components/base.components/input/InputNumber.component.tsx +192 -0
- package/components/base.components/input/InputOtp.component.tsx +169 -0
- package/components/base.components/input/InputPassword.component.tsx +236 -0
- package/components/base.components/input/InputRadio.component.tsx +175 -0
- package/components/base.components/input/InputTime.component.tsx +276 -0
- package/components/base.components/input/InputValues.component.tsx +68 -0
- package/components/base.components/input/Radio.component.tsx +102 -0
- package/components/base.components/input/Select.component.tsx +541 -0
- package/components/base.components/modal/BottomSheet.component.tsx +246 -0
- package/components/base.components/modal/FloatingPage.component.tsx +104 -0
- package/components/base.components/modal/Modal.component.tsx +96 -0
- package/components/base.components/modal/ModalConfirm.component.tsx +218 -0
- package/components/base.components/modal/Toast.component.tsx +126 -0
- package/components/base.components/nav/Bottombar.component.tsx +116 -0
- package/components/base.components/nav/Footer.component.tsx +144 -0
- package/components/base.components/nav/Headbar.component.tsx +104 -0
- package/components/base.components/nav/Navbar.component.tsx +100 -0
- package/components/base.components/nav/Sidebar.component.tsx +301 -0
- package/components/base.components/nav/Tabbar.component.tsx +60 -0
- package/components/base.components/nav/Wizard.component.tsx +73 -0
- package/components/base.components/supervision/FormSupervision.component.tsx +434 -0
- package/components/base.components/supervision/TableSupervision.component.tsx +697 -0
- package/components/base.components/table/ControlBar.component.tsx +497 -0
- package/components/base.components/table/FilterComponent.tsx +518 -0
- package/components/base.components/table/Pagination.component.tsx +159 -0
- package/components/base.components/table/Table.component.tsx +469 -0
- package/components/base.components/typography/TypographyArticle.component.tsx +26 -0
- package/components/base.components/typography/TypographyColumn.component.tsx +20 -0
- package/components/base.components/typography/TypographyContent.component.tsx +20 -0
- package/components/base.components/typography/TypographyTips.component.tsx +20 -0
- package/components/base.components/wrap/Draggable.component.tsx +303 -0
- package/components/base.components/wrap/IDBProvider.tsx +12 -0
- package/components/base.components/wrap/Image.component.tsx +10 -0
- package/components/base.components/wrap/OutsideClick.component.tsx +48 -0
- package/components/base.components/wrap/ScrollContainer.component.tsx +104 -0
- package/components/base.components/wrap/ShortcutProvider.tsx +57 -0
- package/components/base.components/wrap/Swipe.component.tsx +93 -0
- package/components/construct.components/example.tsx +1 -0
- package/components/construct.components/index.ts +5 -0
- package/components/index.ts +3 -0
- package/components/structure.components/example.tsx +1 -0
- package/components/structure.components/index.ts +5 -0
- package/contexts/AppProvider.tsx +12 -0
- package/contexts/Auth.context.tsx +64 -0
- package/contexts/Toggle.context.tsx +44 -0
- package/contexts/index.ts +7 -0
- package/eslint.config.mjs +34 -0
- package/langs/index.ts +1 -0
- package/langs/validation.langs.ts +17 -0
- package/next.config.ts +17 -0
- package/package.json +43 -0
- package/postcss.config.mjs +12 -0
- package/public/204.svg +19 -0
- package/public/500.svg +39 -0
- package/public/images/avatar.jpg +0 -0
- package/public/images/example.png +0 -0
- package/schema/idb/app.schema.ts +9 -0
- package/schema/index.ts +5 -0
- package/styles/globals.css +231 -0
- package/styles/tailwind.safelist +69 -0
- package/tailwind.config.ts +10 -0
- package/tsconfig.json +35 -0
- package/utils/commands/barrels.ts +28 -0
- package/utils/commands/blueprint.ts +421 -0
- package/utils/commands/light.ts +21 -0
- package/utils/commands/logger.ts +42 -0
- package/utils/commands/stubs/table-blueprint.stub +13 -0
- package/utils/commands/use-pdf.ts +29 -0
- package/utils/index.ts +3 -0
|
@@ -0,0 +1,497 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import { ReactNode, useEffect, useRef } from 'react'
|
|
4
|
+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
5
|
+
import { faArrowDownZA, faArrowUpAZ, faEllipsisV, faEyeLowVision, faMagnifyingGlass, faPlus, faRefresh, faSearch, faSliders, faSort } from '@fortawesome/free-solid-svg-icons';
|
|
6
|
+
import { ApiFilterType, cn, conversion, shortcut, useResponsive } from '@utils';
|
|
7
|
+
import { useToggleContext } from '@contexts';
|
|
8
|
+
import { IconButtonComponent, InputCheckboxComponent, InputComponent, SelectComponent, OutsideClickComponent, ButtonComponent, BottomSheetComponent, FilterComponent, FilterColumnOption } from '@components';
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
export type ControlBarOptionType = "SEARCH" | "SEARCHABLE" | "FILTER" | "SELECTABLE" | "REFRESH" | ReactNode;
|
|
13
|
+
|
|
14
|
+
export interface ControlBarProps {
|
|
15
|
+
id ?: string;
|
|
16
|
+
options ?: ControlBarOptionType[];
|
|
17
|
+
className ?: string
|
|
18
|
+
search ?: string,
|
|
19
|
+
onSearch ?: (searchable: string) => void,
|
|
20
|
+
searchableOptions ?: {label: string | ReactNode, selector: string}[]
|
|
21
|
+
searchable ?: string[],
|
|
22
|
+
onSearchable ?: (searchable: string[]) => void,
|
|
23
|
+
selectableOptions ?: {label: string | ReactNode, selector: string}[]
|
|
24
|
+
selectable ?: string[],
|
|
25
|
+
onSelectable ?: (searchable: string[]) => void,
|
|
26
|
+
sortableOptions ?: {label: string | ReactNode, selector: string}[]
|
|
27
|
+
sort ?: string[],
|
|
28
|
+
onSort ?: (sort: string[]) => void,
|
|
29
|
+
filterableColumns ?: FilterColumnOption[],
|
|
30
|
+
onFilter ?: (filters: ApiFilterType[]) => void,
|
|
31
|
+
filter ?: ApiFilterType[],
|
|
32
|
+
onRefresh ?: () => void,
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
export function ControlBarComponent({
|
|
38
|
+
id = "",
|
|
39
|
+
options,
|
|
40
|
+
className,
|
|
41
|
+
search,
|
|
42
|
+
onSearch,
|
|
43
|
+
searchableOptions,
|
|
44
|
+
searchable,
|
|
45
|
+
onSearchable,
|
|
46
|
+
selectableOptions,
|
|
47
|
+
selectable,
|
|
48
|
+
onSelectable,
|
|
49
|
+
sortableOptions,
|
|
50
|
+
sort,
|
|
51
|
+
onSort,
|
|
52
|
+
filterableColumns,
|
|
53
|
+
onFilter,
|
|
54
|
+
filter,
|
|
55
|
+
onRefresh
|
|
56
|
+
}: ControlBarProps) {
|
|
57
|
+
const {toggle, setToggle} = useToggleContext()
|
|
58
|
+
const { isSm } = useResponsive();
|
|
59
|
+
|
|
60
|
+
const searchRef = useRef<HTMLInputElement | null>(null);
|
|
61
|
+
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
if (options?.includes("SEARCH")) {
|
|
64
|
+
shortcut.register("ctrl+s", () => {
|
|
65
|
+
searchRef.current?.focus()
|
|
66
|
+
}, "Cari")
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (options?.includes("FILTER")) {
|
|
70
|
+
shortcut.register("ctrl+f", () => {
|
|
71
|
+
setToggle("FILTER")
|
|
72
|
+
}, "Filter")
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (options?.includes("SORT")) {
|
|
76
|
+
shortcut.register("ctrl+o", () => {
|
|
77
|
+
setToggle("SORT")
|
|
78
|
+
}, "Urutkan")
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (options?.includes("SELECTABLE")) {
|
|
82
|
+
shortcut.register("ctrl+l", () => {
|
|
83
|
+
setToggle("SELECTABLE")
|
|
84
|
+
}, "Kolom Ditampilkan")
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (options?.includes("REFRESH")) {
|
|
88
|
+
shortcut.register("ctrl+shift+r", () => {
|
|
89
|
+
onRefresh?.()
|
|
90
|
+
}, "Refresh Tabel")
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return () => {
|
|
94
|
+
options?.includes("SEARCH") && shortcut.unregister("ctrl+s")
|
|
95
|
+
options?.includes("FILTER") && shortcut.unregister("ctrl+f")
|
|
96
|
+
options?.includes("SORT") && shortcut.unregister("ctrl+o")
|
|
97
|
+
options?.includes("SELECTABLE") && shortcut.unregister("ctrl+l")
|
|
98
|
+
options?.includes("REFRESH") && shortcut.unregister("ctrl+shift+r")
|
|
99
|
+
}
|
|
100
|
+
}, [options])
|
|
101
|
+
|
|
102
|
+
const onChangeSort = (item: string) => {
|
|
103
|
+
if(!!sort?.find((s) => s.split(" ")?.at(0) == item)) {
|
|
104
|
+
const findSort = sort.find((s) => s.split(" ")?.at(0) == item);
|
|
105
|
+
|
|
106
|
+
if (findSort?.split(" ")?.at(1) == "desc") {
|
|
107
|
+
onSort?.(sort.filter((s) => s != findSort));
|
|
108
|
+
} else {
|
|
109
|
+
const newSorts = [...sort];
|
|
110
|
+
newSorts[newSorts?.findIndex((s) => s == findSort)] = `${item} desc`
|
|
111
|
+
onSort?.(newSorts);
|
|
112
|
+
}
|
|
113
|
+
} else {
|
|
114
|
+
onSort?.([...(sort || []), `${item} asc`])
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return (
|
|
119
|
+
<>
|
|
120
|
+
<div className={cn("py-1 md:py-2 md:px-1.5 bg-white rounded-[6px] border flex items-center mb-2", className)}>
|
|
121
|
+
{(isSm ? [
|
|
122
|
+
...(options?.filter((op, iop) => iop == 0 || op == "REFRESH") || []),
|
|
123
|
+
...(options && options?.length > 1 ? ['MOBILE_OPTION'] : [])
|
|
124
|
+
] : options)?.map((option: ControlBarOptionType, key: number) => {
|
|
125
|
+
{
|
|
126
|
+
// =========================>
|
|
127
|
+
// ## Create button
|
|
128
|
+
// =========================>
|
|
129
|
+
}
|
|
130
|
+
if (option == "CREATE") {
|
|
131
|
+
return (
|
|
132
|
+
<div className="pl-1.5 pr-3 mr-2 border-r" key="button-add">
|
|
133
|
+
<ButtonComponent
|
|
134
|
+
icon={faPlus}
|
|
135
|
+
label="Tambah Data"
|
|
136
|
+
size="sm"
|
|
137
|
+
onClick={() => setToggle(`MODAL_FORM_${conversion.strSnake(id).toUpperCase()}`)}
|
|
138
|
+
/>
|
|
139
|
+
</div>
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
{
|
|
144
|
+
// =========================>
|
|
145
|
+
// ## Search Field
|
|
146
|
+
// =========================>
|
|
147
|
+
}
|
|
148
|
+
if (option == "SEARCH") {
|
|
149
|
+
const searchable = !!options?.find((option) => option == "SEARCHABLE");
|
|
150
|
+
|
|
151
|
+
return (
|
|
152
|
+
<div className={cn("w-full min-w-[150px]", searchable ? "pr-1.5" : "px-1.5")} key={key}>
|
|
153
|
+
<InputComponent
|
|
154
|
+
ref={searchRef}
|
|
155
|
+
name="search"
|
|
156
|
+
placeholder="Cari disini..."
|
|
157
|
+
rightIcon={faMagnifyingGlass}
|
|
158
|
+
value={search}
|
|
159
|
+
onChange={(e) => onSearch?.(e)}
|
|
160
|
+
className={cn("py-1.5 text-sm", searchable && "rounded-l-none")}
|
|
161
|
+
/>
|
|
162
|
+
</div>
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
{
|
|
167
|
+
// =========================>
|
|
168
|
+
// ## Searchable Field
|
|
169
|
+
// =========================>
|
|
170
|
+
}
|
|
171
|
+
if (option == "SEARCHABLE") {
|
|
172
|
+
return searchableOptions?.length ? (
|
|
173
|
+
<div className="w-28 pl-1.5" key={key}>
|
|
174
|
+
<SelectComponent
|
|
175
|
+
name="searchableColumn"
|
|
176
|
+
leftIcon={faSearch}
|
|
177
|
+
options={searchableOptions?.map((column) => {
|
|
178
|
+
return {
|
|
179
|
+
label: column.label,
|
|
180
|
+
value: column.selector,
|
|
181
|
+
};
|
|
182
|
+
}) || []}
|
|
183
|
+
value={searchable}
|
|
184
|
+
onChange={(e) => onSearchable?.(e as string[])}
|
|
185
|
+
className="py-1.5 text-sm rounded-r-none border-r-0"
|
|
186
|
+
multiple
|
|
187
|
+
/>
|
|
188
|
+
</div>
|
|
189
|
+
) : <></>;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
{
|
|
193
|
+
// =========================>
|
|
194
|
+
// ## Selectable Button
|
|
195
|
+
// =========================>
|
|
196
|
+
}
|
|
197
|
+
if (option == "SELECTABLE") {
|
|
198
|
+
return (
|
|
199
|
+
<div className="px-1.5 rounded-md relative" key={key}>
|
|
200
|
+
<IconButtonComponent
|
|
201
|
+
icon={faEyeLowVision}
|
|
202
|
+
variant="outline"
|
|
203
|
+
className="!text-foreground p-4"
|
|
204
|
+
onClick={() => setToggle("SELECTABLE")}
|
|
205
|
+
size="sm"
|
|
206
|
+
/>
|
|
207
|
+
<OutsideClickComponent onOutsideClick={() => setToggle("SELECTABLE", false)}>
|
|
208
|
+
<div
|
|
209
|
+
className={cn(
|
|
210
|
+
"absolute -bottom-4 bg-white translate-y-full right-0 w-[240px] z-20 rounded-lg border",
|
|
211
|
+
!toggle.SELECTABLE && "scale-y-0 top-0 opacity-0"
|
|
212
|
+
)}
|
|
213
|
+
>
|
|
214
|
+
<p className='input-label text-xs p-4'>Kolom Ditampilkan</p>
|
|
215
|
+
<InputCheckboxComponent
|
|
216
|
+
vertical
|
|
217
|
+
name="show_column"
|
|
218
|
+
options={selectableOptions?.map((option) => {
|
|
219
|
+
return {
|
|
220
|
+
label: option.label as string,
|
|
221
|
+
value: option.selector,
|
|
222
|
+
};
|
|
223
|
+
})}
|
|
224
|
+
onChange={(e) => onSelectable?.(Array().concat(e).map((val) => String(val)))}
|
|
225
|
+
value={selectable}
|
|
226
|
+
className='px-4 border-0 gap-4 mb-4'
|
|
227
|
+
classNameCheckbox='w-5 h-5 label::text-xs'
|
|
228
|
+
/>
|
|
229
|
+
</div>
|
|
230
|
+
</OutsideClickComponent>
|
|
231
|
+
</div>
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
{
|
|
236
|
+
// =========================>
|
|
237
|
+
// ## Sort Button
|
|
238
|
+
// =========================>
|
|
239
|
+
}
|
|
240
|
+
if (option == "SORT") {
|
|
241
|
+
return sortableOptions?.length ? (
|
|
242
|
+
<div className="px-1.5 rounded-md relative" key={key}>
|
|
243
|
+
<IconButtonComponent
|
|
244
|
+
icon={faSort}
|
|
245
|
+
variant="outline"
|
|
246
|
+
className="!text-foreground p-4"
|
|
247
|
+
onClick={() => setToggle("SORT")}
|
|
248
|
+
size="sm"
|
|
249
|
+
/>
|
|
250
|
+
<OutsideClickComponent onOutsideClick={() => setToggle("SORT", false)}>
|
|
251
|
+
<div
|
|
252
|
+
className={cn(
|
|
253
|
+
"absolute -bottom-4 bg-white translate-y-full right-0 w-[240px] z-20 rounded-lg border",
|
|
254
|
+
!toggle.SORT && "scale-y-0 top-0 opacity-0"
|
|
255
|
+
)}
|
|
256
|
+
>
|
|
257
|
+
<p className='input-label text-xs p-4'>Urut Berdasarkan</p>
|
|
258
|
+
<div className='flex flex-col mb-4'>
|
|
259
|
+
{sortableOptions?.map((option, key) => {
|
|
260
|
+
const sortBy = sort?.find((s) => s.split(" ")?.at(0) == option?.selector)?.split(" ")?.at(1) || "";
|
|
261
|
+
return (
|
|
262
|
+
<div
|
|
263
|
+
key={key}
|
|
264
|
+
className={cn('flex justify-between cursor-pointer text-sm px-4 py-2 hover:bg-light-primary', !!sortBy && "text-primary bg-primary/10")}
|
|
265
|
+
onClick={() => onChangeSort(option.selector)}
|
|
266
|
+
>
|
|
267
|
+
<p>{option.label}</p>
|
|
268
|
+
|
|
269
|
+
{sortBy && (
|
|
270
|
+
<div className='text-primary'>
|
|
271
|
+
<FontAwesomeIcon icon={sortBy == "desc" ? faArrowDownZA : faArrowUpAZ} className='text-xs' />
|
|
272
|
+
{sort?.length && sort?.length > 1 && <span className='text-[9px] ml-1'>{sort.findIndex((s) => s.split(" ")?.at(0) == option?.selector) + 1}</span>}
|
|
273
|
+
</div>
|
|
274
|
+
)}
|
|
275
|
+
</div>
|
|
276
|
+
)
|
|
277
|
+
})}
|
|
278
|
+
</div>
|
|
279
|
+
</div>
|
|
280
|
+
</OutsideClickComponent>
|
|
281
|
+
</div>
|
|
282
|
+
) : <></>;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
{
|
|
286
|
+
// =========================>
|
|
287
|
+
// ## Refresh Button
|
|
288
|
+
// =========================>
|
|
289
|
+
}
|
|
290
|
+
if (option == "REFRESH") {
|
|
291
|
+
return (
|
|
292
|
+
<div className="md:px-1.5 relative" key={key}>
|
|
293
|
+
<IconButtonComponent
|
|
294
|
+
icon={faRefresh}
|
|
295
|
+
variant="outline"
|
|
296
|
+
className="!text-foreground p-4"
|
|
297
|
+
onClick={() => onRefresh?.()}
|
|
298
|
+
size="sm"
|
|
299
|
+
/>
|
|
300
|
+
</div>
|
|
301
|
+
);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
{
|
|
305
|
+
// =========================>
|
|
306
|
+
// ## Filter Button
|
|
307
|
+
// =========================>
|
|
308
|
+
}
|
|
309
|
+
if (option == "FILTER") {
|
|
310
|
+
return (
|
|
311
|
+
<div className="px-1.5 rounded-md relative" key={key}>
|
|
312
|
+
<ButtonComponent
|
|
313
|
+
icon={faSliders}
|
|
314
|
+
label="Filter"
|
|
315
|
+
variant="outline"
|
|
316
|
+
className="!text-foreground"
|
|
317
|
+
onClick={() => setToggle("FILTER")}
|
|
318
|
+
size="sm"
|
|
319
|
+
/>
|
|
320
|
+
</div>
|
|
321
|
+
);
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
{
|
|
325
|
+
// =========================>
|
|
326
|
+
// ## Mobile option button
|
|
327
|
+
// =========================>
|
|
328
|
+
}
|
|
329
|
+
if (option == "MOBILE_OPTION") {
|
|
330
|
+
return (
|
|
331
|
+
<div className="px-1.5 relative" key={key}>
|
|
332
|
+
<IconButtonComponent
|
|
333
|
+
icon={faEllipsisV}
|
|
334
|
+
variant="outline"
|
|
335
|
+
className="!text-foreground p-4"
|
|
336
|
+
onClick={() => setToggle("MOBILE_OPTION")}
|
|
337
|
+
size="sm"
|
|
338
|
+
/>
|
|
339
|
+
</div>
|
|
340
|
+
);
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
return option;
|
|
344
|
+
})}
|
|
345
|
+
</div>
|
|
346
|
+
|
|
347
|
+
{!!filterableColumns && !!filterableColumns?.length && (
|
|
348
|
+
<FilterComponent
|
|
349
|
+
className={cn("", !toggle.FILTER ? "p-0 h-0 hidden overflow-hidden" : "mb-2 animate-intro-down")}
|
|
350
|
+
columns={filterableColumns}
|
|
351
|
+
onChange={onFilter}
|
|
352
|
+
value={filter}
|
|
353
|
+
onMinimize={() => setToggle("FILTER")}
|
|
354
|
+
/>
|
|
355
|
+
)}
|
|
356
|
+
|
|
357
|
+
{isSm && (
|
|
358
|
+
<BottomSheetComponent
|
|
359
|
+
show={!!toggle["MOBILE_OPTION"]}
|
|
360
|
+
onClose={() => setToggle("MOBILE_OPTION", false)}
|
|
361
|
+
maxSize="98vh"
|
|
362
|
+
>
|
|
363
|
+
<div className='flex flex-col gap-4 p-2'>
|
|
364
|
+
{options?.filter((op, iop) => (iop != 0 && op != "CREATE" && op != "REFRESH"))?.map((option: ControlBarOptionType, key: number) => {
|
|
365
|
+
{
|
|
366
|
+
// =========================>
|
|
367
|
+
// ## Search Field
|
|
368
|
+
// =========================>
|
|
369
|
+
}
|
|
370
|
+
if (option == "SEARCH") {
|
|
371
|
+
return (
|
|
372
|
+
<div key={key}>
|
|
373
|
+
<InputComponent
|
|
374
|
+
name="search"
|
|
375
|
+
placeholder="Cari disini..."
|
|
376
|
+
rightIcon={faMagnifyingGlass}
|
|
377
|
+
value={search}
|
|
378
|
+
onChange={(e) => onSearch?.(e)}
|
|
379
|
+
/>
|
|
380
|
+
</div>
|
|
381
|
+
);
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
{
|
|
385
|
+
// =========================>
|
|
386
|
+
// ## Searchable Field
|
|
387
|
+
// =========================>
|
|
388
|
+
}
|
|
389
|
+
if (option == "SEARCHABLE") {
|
|
390
|
+
return searchableOptions?.length ? (
|
|
391
|
+
<div key={key}>
|
|
392
|
+
<SelectComponent
|
|
393
|
+
name="searchableColumn"
|
|
394
|
+
leftIcon={faSearch}
|
|
395
|
+
options={searchableOptions?.map((column) => {
|
|
396
|
+
return {
|
|
397
|
+
label: column.label,
|
|
398
|
+
value: column.selector,
|
|
399
|
+
};
|
|
400
|
+
}) || []}
|
|
401
|
+
value={searchable}
|
|
402
|
+
onChange={(e) => onSearchable?.(e as string[])}
|
|
403
|
+
multiple
|
|
404
|
+
/>
|
|
405
|
+
</div>
|
|
406
|
+
) : <></>;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
{
|
|
410
|
+
// =========================>
|
|
411
|
+
// ## Selectable Button
|
|
412
|
+
// =========================>
|
|
413
|
+
}
|
|
414
|
+
if (option == "SELECTABLE") {
|
|
415
|
+
return (
|
|
416
|
+
<div key={key}>
|
|
417
|
+
<p className='input-label text-xs pb-2'>Kolom Ditampilkan</p>
|
|
418
|
+
<InputCheckboxComponent
|
|
419
|
+
vertical
|
|
420
|
+
name="show_column"
|
|
421
|
+
options={selectableOptions?.map((option) => {
|
|
422
|
+
return {
|
|
423
|
+
label: option.label as string,
|
|
424
|
+
value: option.selector,
|
|
425
|
+
};
|
|
426
|
+
})}
|
|
427
|
+
onChange={(e) => onSelectable?.(Array().concat(e).map((val) => String(val)))}
|
|
428
|
+
value={selectable}
|
|
429
|
+
className='px-2 border-0 gap-4 bg-transparent'
|
|
430
|
+
classNameCheckbox='w-5 h-5 label::text-xs'
|
|
431
|
+
/>
|
|
432
|
+
</div>
|
|
433
|
+
);
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
{
|
|
437
|
+
// =========================>
|
|
438
|
+
// ## Sort Button
|
|
439
|
+
// =========================>
|
|
440
|
+
}
|
|
441
|
+
if (option == "SORT") {
|
|
442
|
+
return sortableOptions?.length ? (
|
|
443
|
+
<div key={key}>
|
|
444
|
+
<p className='input-label text-xs pb-2'>Urut Berdasarkan</p>
|
|
445
|
+
<div className='flex flex-col'>
|
|
446
|
+
{sortableOptions?.map((option, key) => {
|
|
447
|
+
const sortBy = sort?.find((s) => s.split(" ")?.at(0) == option?.selector)?.split(" ")?.at(1) || "";
|
|
448
|
+
return (
|
|
449
|
+
<div
|
|
450
|
+
key={key}
|
|
451
|
+
className={cn('flex justify-between cursor-pointer text-sm p-2 hover:bg-light-primary active:scale-x-[102%]', !!sortBy && "text-primary bg-primary/10")}
|
|
452
|
+
onClick={() => onChangeSort(option.selector)}
|
|
453
|
+
>
|
|
454
|
+
<p>{option.label}</p>
|
|
455
|
+
|
|
456
|
+
{sortBy && (
|
|
457
|
+
<div className='text-primary'>
|
|
458
|
+
<FontAwesomeIcon icon={sortBy == "desc" ? faArrowDownZA : faArrowUpAZ} className='text-xs' />
|
|
459
|
+
{sort?.length && sort?.length > 1 && <span className='text-[9px] ml-1'>{sort.findIndex((s) => s.split(" ")?.at(0) == option?.selector) + 1}</span>}
|
|
460
|
+
</div>
|
|
461
|
+
)}
|
|
462
|
+
</div>
|
|
463
|
+
)
|
|
464
|
+
})}
|
|
465
|
+
</div>
|
|
466
|
+
</div>
|
|
467
|
+
) : <></>;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
{
|
|
471
|
+
// =========================>
|
|
472
|
+
// ## Filter
|
|
473
|
+
// =========================>
|
|
474
|
+
}
|
|
475
|
+
if (option == "FILTER") {
|
|
476
|
+
return (
|
|
477
|
+
<div key={key}>
|
|
478
|
+
{filterableColumns && filterableColumns?.length && (
|
|
479
|
+
<FilterComponent
|
|
480
|
+
className='border-0 p-0 mb-2 title::text-xs'
|
|
481
|
+
columns={filterableColumns}
|
|
482
|
+
onChange={onFilter}
|
|
483
|
+
value={filter}
|
|
484
|
+
/>
|
|
485
|
+
)}
|
|
486
|
+
</div>
|
|
487
|
+
);
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
return option;
|
|
491
|
+
})}
|
|
492
|
+
</div>
|
|
493
|
+
</BottomSheetComponent>
|
|
494
|
+
)}
|
|
495
|
+
</>
|
|
496
|
+
)
|
|
497
|
+
}
|