@skalfa/skalfa-component 1.0.7 → 1.0.9

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 (107) hide show
  1. package/dist/accordion/Accordion.component.js +2 -3
  2. package/dist/breadcrumb/Breadcrumb.component.js +2 -3
  3. package/dist/button/Button.component.d.ts +2 -1
  4. package/dist/button/Button.component.js +2 -2
  5. package/dist/carousel/Carousel.component.js +2 -3
  6. package/dist/chip/Chip.component.js +2 -3
  7. package/dist/contexts-mock.d.ts +2 -0
  8. package/dist/contexts-mock.js +10 -0
  9. package/dist/input/Checkbox.component.js +2 -3
  10. package/dist/input/Input.component.d.ts +3 -2
  11. package/dist/input/Input.component.js +3 -3
  12. package/dist/input/InputCheckbox.component.js +1 -1
  13. package/dist/input/InputCurrency.component.d.ts +3 -2
  14. package/dist/input/InputCurrency.component.js +3 -3
  15. package/dist/input/InputDate.component.js +4 -5
  16. package/dist/input/InputDatetime.component.d.ts +3 -2
  17. package/dist/input/InputDatetime.component.js +3 -3
  18. package/dist/input/InputDocument.component.js +7 -8
  19. package/dist/input/InputImage.component.js +3 -4
  20. package/dist/input/InputNumber.component.js +3 -4
  21. package/dist/input/InputPassword.component.js +3 -3
  22. package/dist/input/InputRadio.component.js +1 -1
  23. package/dist/input/InputTime.component.js +3 -3
  24. package/dist/input/InputValues.component.js +3 -4
  25. package/dist/input/Select.component.js +6 -7
  26. package/dist/modal/FloatingPage.component.d.ts +3 -1
  27. package/dist/modal/FloatingPage.component.js +7 -3
  28. package/dist/modal/Modal.component.js +1 -2
  29. package/dist/modal/ModalConfirm.component.d.ts +2 -2
  30. package/dist/modal/ModalConfirm.component.js +14 -12
  31. package/dist/modal/Toast.component.js +1 -2
  32. package/dist/nav/Bottombar.component.d.ts +2 -2
  33. package/dist/nav/Bottombar.component.js +7 -8
  34. package/dist/nav/Footer.component.d.ts +2 -2
  35. package/dist/nav/Footer.component.js +6 -7
  36. package/dist/nav/Headbar.component.js +2 -3
  37. package/dist/nav/Navbar.component.d.ts +2 -2
  38. package/dist/nav/Navbar.component.js +3 -4
  39. package/dist/nav/Sidebar.component.d.ts +3 -7
  40. package/dist/nav/Sidebar.component.js +14 -17
  41. package/dist/supervision/FormSupervision.component.d.ts +4 -29
  42. package/dist/supervision/FormSupervision.component.js +84 -136
  43. package/dist/supervision/TableSupervision.component.d.ts +17 -26
  44. package/dist/supervision/TableSupervision.component.js +207 -193
  45. package/dist/table/ControlBar.component.js +15 -16
  46. package/dist/table/FilterComponent.js +4 -6
  47. package/dist/table/Pagination.component.js +2 -3
  48. package/dist/table/Table.component.js +3 -4
  49. package/dist/wrap/Swipe.component.js +2 -2
  50. package/package.json +18 -10
  51. package/src/accordion/Accordion.component.tsx +87 -0
  52. package/src/breadcrumb/Breadcrumb.component.tsx +79 -0
  53. package/src/button/Button.component.tsx +89 -0
  54. package/src/card/AlertCard.component.tsx +69 -0
  55. package/src/card/Card.component.tsx +25 -0
  56. package/src/card/DashboardCard.component.tsx +44 -0
  57. package/src/card/GalleryCard.component.tsx +50 -0
  58. package/src/card/ProductCard.component.tsx +65 -0
  59. package/src/card/ProfileCard.component.tsx +71 -0
  60. package/src/carousel/Carousel.component.tsx +111 -0
  61. package/src/chip/Chip.component.tsx +38 -0
  62. package/src/contexts-mock.ts +6 -0
  63. package/src/index.ts +70 -0
  64. package/src/input/Checkbox.component.tsx +102 -0
  65. package/src/input/Input.component.tsx +334 -0
  66. package/src/input/InputCheckbox.component.tsx +174 -0
  67. package/src/input/InputCurrency.component.tsx +165 -0
  68. package/src/input/InputDate.component.tsx +355 -0
  69. package/src/input/InputDatetime.component.tsx +267 -0
  70. package/src/input/InputDocument.component.tsx +360 -0
  71. package/src/input/InputImage.component.tsx +534 -0
  72. package/src/input/InputNumber.component.tsx +193 -0
  73. package/src/input/InputOtp.component.tsx +169 -0
  74. package/src/input/InputPassword.component.tsx +245 -0
  75. package/src/input/InputRadio.component.tsx +174 -0
  76. package/src/input/InputTime.component.tsx +280 -0
  77. package/src/input/InputValues.component.tsx +70 -0
  78. package/src/input/Radio.component.tsx +98 -0
  79. package/src/input/Select.component.tsx +557 -0
  80. package/src/modal/BottomSheet.component.tsx +246 -0
  81. package/src/modal/FloatingPage.component.tsx +133 -0
  82. package/src/modal/Modal.component.tsx +94 -0
  83. package/src/modal/ModalConfirm.component.tsx +204 -0
  84. package/src/modal/Toast.component.tsx +124 -0
  85. package/src/nav/Bottombar.component.tsx +71 -0
  86. package/src/nav/Footer.component.tsx +176 -0
  87. package/src/nav/Headbar.component.tsx +33 -0
  88. package/src/nav/Navbar.component.tsx +137 -0
  89. package/src/nav/Sidebar.component.tsx +307 -0
  90. package/src/nav/Tabbar.component.tsx +61 -0
  91. package/src/nav/Wizard.component.tsx +80 -0
  92. package/src/supervision/FormSupervision.component.tsx +404 -0
  93. package/src/supervision/TableSupervision.component.tsx +653 -0
  94. package/src/table/ControlBar.component.tsx +501 -0
  95. package/src/table/FilterComponent.tsx +517 -0
  96. package/src/table/Pagination.component.tsx +152 -0
  97. package/src/table/Table.component.tsx +436 -0
  98. package/src/typography/TypographyArticle.component.tsx +26 -0
  99. package/src/typography/TypographyColumn.component.tsx +20 -0
  100. package/src/typography/TypographyContent.component.tsx +20 -0
  101. package/src/typography/TypographyTips.component.tsx +20 -0
  102. package/src/wrap/Draggable.component.tsx +303 -0
  103. package/src/wrap/Image.component.tsx +10 -0
  104. package/src/wrap/OutsideClick.component.tsx +48 -0
  105. package/src/wrap/ScrollContainer.component.tsx +107 -0
  106. package/src/wrap/ShortcutProvider.tsx +57 -0
  107. package/src/wrap/Swipe.component.tsx +121 -0
@@ -0,0 +1,307 @@
1
+ "use client"
2
+
3
+ import { Fragment, ReactNode, useEffect, useState, } from "react";
4
+ import { usePathname } from "next/navigation";
5
+ import Link from "next/link";
6
+ import { cn, pcn } from "@utils";
7
+ import { useToggleContext } from "@contexts";
8
+ import { Icon } from "@skalfa/skalfa-icon";
9
+
10
+
11
+
12
+ type CT = "backdrop" | "base" | "head-item" | "item" | "child-item";
13
+
14
+ export interface SidebarItemProps {
15
+ label : string;
16
+ key ?: number;
17
+ leftContent ?: any;
18
+ rightContent ?: any;
19
+ path ?: string;
20
+ items ?: SidebarItemProps[];
21
+ className ?: string;
22
+ };
23
+
24
+ export interface SidebarHeadItemProps {
25
+ label : string;
26
+ collapse ?: boolean;
27
+ items ?: SidebarItemProps[];
28
+ className ?: string;
29
+ };
30
+
31
+ export interface sidebarProps {
32
+ id ?: string;
33
+ head ?: any;
34
+ footer ?: any;
35
+ items ?: SidebarHeadItemProps[];
36
+ basePath ?: string;
37
+
38
+ /** Use custom class with: "backdrop::", "head-item::", "item::", "child-item::". */
39
+ className?: string;
40
+ };
41
+
42
+ interface sidebarWrapperProps {
43
+ path ?: string;
44
+ onClick ?: () => void;
45
+ children ?: any;
46
+ }
47
+
48
+
49
+
50
+
51
+ function SidebarWrapper({
52
+ path,
53
+ children,
54
+ onClick,
55
+ } : sidebarWrapperProps) {
56
+ if (path) {
57
+ return <Link href={path}>{children}</Link>;
58
+ } else {
59
+ return <div onClick={() => onClick?.()}>{children}</div>;
60
+ }
61
+ }
62
+
63
+
64
+
65
+ export function SidebarComponent({
66
+ id,
67
+ head,
68
+ footer,
69
+ items,
70
+ basePath,
71
+ className = "",
72
+ } : sidebarProps) {
73
+ const pathName = usePathname();
74
+ const { toggle, setToggle } = useToggleContext()
75
+
76
+ const [shows, setShows] = useState<string[]>([]);
77
+
78
+ const setShow = (key: string) => {
79
+ setShows((prevShows) => prevShows?.find((pk) => pk === key) ? prevShows.filter((pk) => pk !== key) : [...prevShows, key]);
80
+ };
81
+
82
+ const checkShow = (key: string): boolean => {
83
+ if (shows?.includes(key)) {
84
+ return true;
85
+ }
86
+
87
+ return false;
88
+ };
89
+
90
+ const cekActive = (path: string) => {
91
+ const activePath =
92
+ pathName?.split("?")[0]?.replace(`${basePath || ""}`, "") || "/";
93
+
94
+ const currentPath = `${path ? `${path}` : ""}`;
95
+
96
+ const isPrefix = (longer: string, shorter: string): boolean => {
97
+ return (
98
+ longer.startsWith(shorter) &&
99
+ (longer === shorter || longer[shorter.length] === "/")
100
+ );
101
+ };
102
+
103
+ return (
104
+ isPrefix(activePath, currentPath) || isPrefix(currentPath, activePath)
105
+ );
106
+ };
107
+
108
+ useEffect(() => {
109
+ items?.map((head, head_key) => {
110
+ head?.items?.map((menu, key) => {
111
+ if (menu?.path && cekActive(menu?.path || "")) {
112
+ setShow(`${head_key}`);
113
+ }
114
+ menu?.items?.map((child) => {
115
+ if (child?.path && cekActive(child?.path || "")) {
116
+ setShow(`${head_key}`);
117
+ setShow(`${head_key}.${key}`);
118
+ }
119
+ });
120
+ });
121
+ });
122
+ }, []);
123
+
124
+ useEffect(() => {
125
+ setToggle(`SIDEBAR${id ? "" : "_" + id?.toUpperCase()}`, false)
126
+ }, [pathName]);
127
+
128
+ return (
129
+ <>
130
+ <div
131
+ className={cn(
132
+ "sidebar-backdrop",
133
+ toggle[`SIDEBAR${id ? "" : "_" + id?.toUpperCase()}`] ? "scale-100 lg:scale-0" : "scale-0",
134
+ pcn<CT>(className, "backdrop"),
135
+ )}
136
+ onClick={() => setToggle(`SIDEBAR${id ? "" : "_" + id?.toUpperCase()}`)}
137
+ ></div>
138
+ <aside
139
+ className={cn(
140
+ "sidebar-base scroll-sm",
141
+ toggle[`SIDEBAR${id ? "" : "_" + id?.toUpperCase()}`] ? "w-full sm:w-[280px]" : "w-0 sm:w-14 lg:w-[280px]",
142
+ pcn<CT>(className, "base"),
143
+ )}
144
+ >
145
+ <div className={toggle[`SIDEBAR${id ? "" : "_" + id?.toUpperCase()}`] ? "block" : "hidden lg:block"}>
146
+ {head}
147
+ </div>
148
+
149
+ <div
150
+ className={toggle[`SIDEBAR${id ? "" : "_" + id?.toUpperCase()}`] ? "hidden" : "flex justify-center pt-4 h-full lg:hidden"}
151
+ onClick={() => setToggle(`SIDEBAR${id ? "" : "_" + id?.toUpperCase()}`)}
152
+ >
153
+ <Icon icon={"solid/bars"} />
154
+ </div>
155
+
156
+ <nav className={cn(
157
+ "flex flex-col flex-1 overflow-hidden",
158
+ toggle[`SIDEBAR${id ? "" : "_" + id?.toUpperCase()}`] ? "w-full" : "w-0 lg:w-full",
159
+ )}>
160
+ {items?.map((menu_head, menu_head_key) => {
161
+ return (
162
+ <Fragment key={menu_head_key}>
163
+ <div className="">
164
+ <div
165
+ className={cn(
166
+ "sidebar-head-item",
167
+ menu_head?.collapse && "cursor-pointer",
168
+ pcn<CT>(className, "head-item"),
169
+ menu_head?.className,
170
+ )}
171
+ onClick={() => setShow(String(menu_head_key))}
172
+ >
173
+ {menu_head?.label}
174
+ {menu_head.collapse && (
175
+ <Icon
176
+ icon={"solid/chevron-down"}
177
+ className={cn(
178
+ checkShow(String(menu_head_key)) && "rotate-180",
179
+ )}
180
+ />
181
+ )}
182
+ </div>
183
+
184
+ {(!menu_head?.collapse || checkShow(String(menu_head_key))) &&
185
+ menu_head?.items?.map((menu, menu_key) => {
186
+ return (
187
+ <Fragment key={`${menu_head_key}.${menu_key}`}>
188
+ <SidebarWrapper
189
+ path={
190
+ menu?.path ? `${basePath || ""}${menu?.path}` : ""
191
+ }
192
+ onClick={() =>
193
+ setShow(`${menu_head_key}.${menu_key}`)
194
+ }
195
+ >
196
+ <div
197
+ className={cn(
198
+ "sidebar-item",
199
+ menu?.path && cekActive(menu?.path || "") && "sidebar-item-active",
200
+ pcn<CT>(className, "item"),
201
+ menu?.className,
202
+ )}
203
+ >
204
+ <div className="flex gap-2 items-center">
205
+ {menu?.leftContent}
206
+ <span className="font-medium">
207
+ {menu?.label}
208
+ </span>
209
+ </div>
210
+ <div className="flex gap-2 items-center">
211
+ {menu?.rightContent}
212
+
213
+ {menu?.items?.length && (
214
+ <Icon
215
+ icon={"solid/chevron-up"}
216
+ className={`text-[10px] ${
217
+ checkShow(
218
+ `${menu_head_key}.${menu_key}`,
219
+ ) || "rotate-180"
220
+ }`}
221
+ />
222
+ )}
223
+ </div>
224
+ </div>
225
+ </SidebarWrapper>
226
+ <div className="px-4">
227
+ <div className="flex flex-col">
228
+ {menu?.items?.length &&
229
+ checkShow(`${menu_head_key}.${menu_key}`) &&
230
+ menu?.items?.map((child, menu_child_key) => {
231
+ return (
232
+ <Fragment
233
+ key={`${menu_head_key}.${menu_key}.${menu_child_key}`}
234
+ >
235
+ <SidebarWrapper
236
+ path={
237
+ child?.path
238
+ ? `${basePath || ""}${child?.path}`
239
+ : ""
240
+ }
241
+ onClick={() =>
242
+ setShow(
243
+ `${menu_head_key}.${menu_key}.${menu_child_key}`,
244
+ )
245
+ }
246
+ >
247
+ <div
248
+ className={cn(
249
+ "sidebar-child-item",
250
+ child?.path &&
251
+ cekActive(child?.path || "") &&
252
+ "sidebar-child-item-active",
253
+ pcn<CT>(className, "child-item"),
254
+ child?.className,
255
+ )}
256
+ >
257
+ <div className="flex gap-2 items-center">
258
+ {child?.leftContent}
259
+ <span className="text-[10px] font-medium">
260
+ {child?.label}
261
+ </span>
262
+ </div>
263
+ <div className="flex gap-2 items-center">
264
+ {child?.rightContent}
265
+
266
+ {child?.items?.length && (
267
+ <Icon
268
+ icon={"solid/chevron-up"}
269
+ className={`block text-[10px] ${
270
+ checkShow(
271
+ `${menu_head_key}.${menu_key}`,
272
+ ) || "rotate-180"
273
+ }`}
274
+ />
275
+ )}
276
+ </div>
277
+ </div>
278
+ </SidebarWrapper>
279
+ </Fragment>
280
+ );
281
+ })}
282
+ </div>
283
+ </div>
284
+ </Fragment>
285
+ );
286
+ })}
287
+ </div>
288
+ </Fragment>
289
+ );
290
+ })}
291
+ </nav>
292
+
293
+ <div className={toggle[`SIDEBAR${id ? "" : "_" + id?.toUpperCase()}`] ? "block" : "hidden lg:block"}>
294
+ {footer}
295
+ </div>
296
+ </aside>
297
+ </>
298
+ );
299
+ }
300
+
301
+ export function SidebarContentComponent({ children }: { children: ReactNode }) {
302
+ return (
303
+ <main className="w-full sm:ml-14 sm:w-[calc(100vw-56px)] lg:ml-[280px] lg:w-[calc(100vw-280px)] min-h-screen overflow-x-hidden">
304
+ {children}
305
+ </main>
306
+ );
307
+ }
@@ -0,0 +1,61 @@
1
+ import { cn, pcn } from "@utils";
2
+
3
+
4
+
5
+ type CT = "item" | "active" | "base";
6
+
7
+ export interface TabbarItemProps {
8
+ label : string;
9
+ value : string | number;
10
+ };
11
+
12
+ export interface TabbarProps {
13
+ items : string[] | TabbarItemProps[];
14
+ onChange ?: (item: string | number) => void;
15
+ active ?: string | number;
16
+ className ?: string;
17
+ };
18
+
19
+
20
+
21
+ export function TabbarComponent({
22
+ items,
23
+ onChange,
24
+ active,
25
+
26
+ /** Use custom class with: "item::", "active::". */
27
+ className = "",
28
+ }: TabbarProps) {
29
+ return (
30
+ <>
31
+ <div
32
+ className={cn(
33
+ "tabbar-base",
34
+ pcn<CT>(className, "base"),
35
+ )}
36
+ >
37
+ {items?.map((item, i) => {
38
+ const isItemActive = active == (typeof item != "string" ? item?.value : item);
39
+ return (
40
+ <div
41
+ key={i}
42
+ className={cn(
43
+ "tabbar-item",
44
+ isItemActive
45
+ ? "tabbar-item-active"
46
+ : "tabbar-item-inactive",
47
+ pcn<CT>(className, "item"),
48
+ pcn<CT>(className, "active"),
49
+ )}
50
+ onClick={() =>
51
+ onChange?.(typeof item != "string" ? item?.value : item)
52
+ }
53
+ >
54
+ {typeof item != "string" ? item?.label : item}
55
+ </div>
56
+ );
57
+ })}
58
+ </div>
59
+ </>
60
+ );
61
+ }
@@ -0,0 +1,80 @@
1
+ import { ReactNode } from "react";
2
+ import { cn } from "@utils";
3
+
4
+
5
+
6
+ export interface WizardProps {
7
+ items : {label: string, circle_content: ReactNode}[];
8
+ active : number;
9
+ };
10
+
11
+
12
+
13
+ export function WizardComponent({
14
+ items,
15
+ active
16
+ }: WizardProps) {
17
+ return (
18
+ <div>
19
+ <div className="w-full py-4">
20
+ <div className="flex">
21
+ {items.map((item, key) => {
22
+ const isStepActive = key <= active;
23
+ const isLineActive = key <= active + 1;
24
+ const isLineGradient = key == active + 1;
25
+
26
+ return (
27
+ <div
28
+ key={key}
29
+ style={{ width: `calc(100% * 1 / ${items.length})` }}
30
+ >
31
+ <div className="wizard-step-header">
32
+ {key > 0 && (
33
+ <div
34
+ className="wizard-progress-bar-wrapper"
35
+ style={{
36
+ width: "calc(100% - 2.5rem - 1rem)",
37
+ top: "50%",
38
+ transform: "translate(-50%, -50%)",
39
+ }}
40
+ >
41
+ <div className="wizard-progress-bar-bg">
42
+ <div
43
+ className={cn(
44
+ "wizard-progress-bar-fill",
45
+ isLineGradient
46
+ ? "wizard-progress-bar-fill-gradient"
47
+ : isLineActive
48
+ ? "wizard-progress-bar-fill-active"
49
+ : ""
50
+ )}
51
+ ></div>
52
+ </div>
53
+ </div>
54
+ )}
55
+
56
+ <div
57
+ className={cn(
58
+ "wizard-circle",
59
+ isStepActive
60
+ ? "wizard-circle-active"
61
+ : "wizard-circle-inactive"
62
+ )}
63
+ >
64
+ <span className="text-center w-full">
65
+ {item.circle_content}
66
+ </span>
67
+ </div>
68
+ </div>
69
+
70
+ <div className="wizard-label">
71
+ {item.label}
72
+ </div>
73
+ </div>
74
+ );
75
+ })}
76
+ </div>
77
+ </div>
78
+ </div>
79
+ );
80
+ }