@skalfa/skalfa-app 1.0.2 → 1.0.5

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.
Files changed (99) hide show
  1. package/.env.example +8 -16
  2. package/app/auth/edit/page.tsx +1 -1
  3. package/app/auth/login/page.tsx +1 -1
  4. package/app/auth/me/page.tsx +1 -1
  5. package/app/auth/register/page.tsx +1 -1
  6. package/app/auth/verify/page.tsx +1 -1
  7. package/app/dashboard/layout.tsx +2 -2
  8. package/app/dashboard/page.tsx +1 -1
  9. package/app/index.ts +1 -0
  10. package/app/layout.tsx +2 -4
  11. package/app/page.tsx +2 -2
  12. package/bun.lock +39 -24
  13. package/components/index.ts +1 -3
  14. package/package.json +8 -7
  15. package/styles/components.css +1392 -0
  16. package/styles/globals.css +40 -175
  17. package/styles/utilities.css +37 -0
  18. package/tsconfig.json +4 -2
  19. package/utils/commands/skalfa.ts +3 -0
  20. package/blueprints/starter.blueprint.json +0 -103
  21. package/components/base.components/accordion/Accordion.component.tsx +0 -82
  22. package/components/base.components/breadcrumb/Breadcrumb.component.tsx +0 -80
  23. package/components/base.components/button/Button.component.tsx +0 -91
  24. package/components/base.components/button/IconButton.component.tsx +0 -88
  25. package/components/base.components/button/button.decorate.ts +0 -82
  26. package/components/base.components/card/AlertCard.component.tsx +0 -69
  27. package/components/base.components/card/Card.component.tsx +0 -25
  28. package/components/base.components/card/DashboardCard.component.tsx +0 -44
  29. package/components/base.components/card/GalleryCard.component.tsx +0 -50
  30. package/components/base.components/card/ProductCard.component.tsx +0 -65
  31. package/components/base.components/card/ProfileCard.component.tsx +0 -71
  32. package/components/base.components/carousel/Carousel.component.tsx +0 -113
  33. package/components/base.components/chip/Chip.component.tsx +0 -39
  34. package/components/base.components/document/DocumentViewer.component.tsx +0 -164
  35. package/components/base.components/document/ExportExcel.component.tsx +0 -340
  36. package/components/base.components/document/ImportExcel.component.tsx +0 -315
  37. package/components/base.components/document/PrintTable.component.tsx +0 -204
  38. package/components/base.components/document/RenderPDF.component.tsx +0 -416
  39. package/components/base.components/index.ts +0 -85
  40. package/components/base.components/input/Checkbox.component.tsx +0 -109
  41. package/components/base.components/input/Input.component.tsx +0 -332
  42. package/components/base.components/input/InputCheckbox.component.tsx +0 -174
  43. package/components/base.components/input/InputCurrency.component.tsx +0 -163
  44. package/components/base.components/input/InputDate.component.tsx +0 -352
  45. package/components/base.components/input/InputDatetime.component.tsx +0 -260
  46. package/components/base.components/input/InputDocument.component.tsx +0 -352
  47. package/components/base.components/input/InputImage.component.tsx +0 -533
  48. package/components/base.components/input/InputMap.component.tsx +0 -318
  49. package/components/base.components/input/InputNumber.component.tsx +0 -192
  50. package/components/base.components/input/InputOtp.component.tsx +0 -169
  51. package/components/base.components/input/InputPassword.component.tsx +0 -236
  52. package/components/base.components/input/InputRadio.component.tsx +0 -175
  53. package/components/base.components/input/InputTime.component.tsx +0 -276
  54. package/components/base.components/input/InputValues.component.tsx +0 -68
  55. package/components/base.components/input/Radio.component.tsx +0 -102
  56. package/components/base.components/input/Select.component.tsx +0 -541
  57. package/components/base.components/modal/BottomSheet.component.tsx +0 -246
  58. package/components/base.components/modal/FloatingPage.component.tsx +0 -104
  59. package/components/base.components/modal/Modal.component.tsx +0 -96
  60. package/components/base.components/modal/ModalConfirm.component.tsx +0 -218
  61. package/components/base.components/modal/Toast.component.tsx +0 -126
  62. package/components/base.components/nav/Bottombar.component.tsx +0 -116
  63. package/components/base.components/nav/Footer.component.tsx +0 -144
  64. package/components/base.components/nav/Headbar.component.tsx +0 -104
  65. package/components/base.components/nav/Navbar.component.tsx +0 -100
  66. package/components/base.components/nav/Sidebar.component.tsx +0 -301
  67. package/components/base.components/nav/Tabbar.component.tsx +0 -60
  68. package/components/base.components/nav/Wizard.component.tsx +0 -73
  69. package/components/base.components/supervision/FormSupervision.component.tsx +0 -434
  70. package/components/base.components/supervision/TableSupervision.component.tsx +0 -697
  71. package/components/base.components/table/ControlBar.component.tsx +0 -497
  72. package/components/base.components/table/FilterComponent.tsx +0 -518
  73. package/components/base.components/table/Pagination.component.tsx +0 -159
  74. package/components/base.components/table/Table.component.tsx +0 -469
  75. package/components/base.components/typography/TypographyArticle.component.tsx +0 -26
  76. package/components/base.components/typography/TypographyColumn.component.tsx +0 -20
  77. package/components/base.components/typography/TypographyContent.component.tsx +0 -20
  78. package/components/base.components/typography/TypographyTips.component.tsx +0 -20
  79. package/components/base.components/wrap/Draggable.component.tsx +0 -303
  80. package/components/base.components/wrap/IDBProvider.tsx +0 -12
  81. package/components/base.components/wrap/Image.component.tsx +0 -10
  82. package/components/base.components/wrap/OutsideClick.component.tsx +0 -48
  83. package/components/base.components/wrap/ScrollContainer.component.tsx +0 -104
  84. package/components/base.components/wrap/ShortcutProvider.tsx +0 -57
  85. package/components/base.components/wrap/Swipe.component.tsx +0 -93
  86. package/components/construct.components/example.tsx +0 -1
  87. package/components/construct.components/index.ts +0 -5
  88. package/components/structure.components/example.tsx +0 -1
  89. package/components/structure.components/index.ts +0 -5
  90. package/langs/index.ts +0 -1
  91. package/langs/validation.langs.ts +0 -17
  92. package/schema/idb/app.schema.ts +0 -9
  93. package/schema/index.ts +0 -5
  94. package/utils/commands/barrels.ts +0 -28
  95. package/utils/commands/blueprint.ts +0 -421
  96. package/utils/commands/light.ts +0 -21
  97. package/utils/commands/logger.ts +0 -42
  98. package/utils/commands/stubs/table-blueprint.stub +0 -13
  99. package/utils/commands/use-pdf.ts +0 -29
@@ -1,497 +0,0 @@
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
- }