@skalfa/skalfa-app 1.0.0 → 1.0.2

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 (87) hide show
  1. package/.env.example +43 -43
  2. package/.github/workflows/publish.yml +39 -0
  3. package/CONTRIBUTING.md +45 -0
  4. package/LICENSE +21 -0
  5. package/README.md +91 -28
  6. package/app/auth/edit/page.tsx +65 -65
  7. package/app/auth/login/page.tsx +63 -63
  8. package/app/auth/me/page.tsx +58 -58
  9. package/app/auth/register/page.tsx +69 -69
  10. package/app/auth/verify/page.tsx +53 -53
  11. package/app/dashboard/user/page.tsx +76 -76
  12. package/app/layout.tsx +37 -37
  13. package/app/manifest.ts +25 -0
  14. package/app/page.tsx +13 -13
  15. package/barrels.json +5 -5
  16. package/blueprints/starter.blueprint.json +102 -102
  17. package/bun.lock +916 -0
  18. package/components/base.components/chip/Chip.component.tsx +39 -39
  19. package/components/base.components/document/DocumentViewer.component.tsx +163 -163
  20. package/components/base.components/document/ExportExcel.component.tsx +340 -340
  21. package/components/base.components/document/ImportExcel.component.tsx +315 -315
  22. package/components/base.components/document/PrintTable.component.tsx +204 -204
  23. package/components/base.components/document/RenderPDF.component.tsx +415 -415
  24. package/components/base.components/input/Checkbox.component.tsx +109 -109
  25. package/components/base.components/input/Input.component.tsx +332 -332
  26. package/components/base.components/input/InputCheckbox.component.tsx +174 -174
  27. package/components/base.components/input/InputCurrency.component.tsx +163 -163
  28. package/components/base.components/input/InputDate.component.tsx +352 -352
  29. package/components/base.components/input/InputDatetime.component.tsx +260 -260
  30. package/components/base.components/input/InputDocument.component.tsx +351 -351
  31. package/components/base.components/input/InputImage.component.tsx +533 -533
  32. package/components/base.components/input/InputMap.component.tsx +317 -317
  33. package/components/base.components/input/InputNumber.component.tsx +192 -192
  34. package/components/base.components/input/InputOtp.component.tsx +169 -169
  35. package/components/base.components/input/InputPassword.component.tsx +236 -236
  36. package/components/base.components/input/InputRadio.component.tsx +175 -175
  37. package/components/base.components/input/InputTime.component.tsx +275 -275
  38. package/components/base.components/input/InputValues.component.tsx +68 -68
  39. package/components/base.components/input/Radio.component.tsx +102 -102
  40. package/components/base.components/input/Select.component.tsx +541 -541
  41. package/components/base.components/modal/BottomSheet.component.tsx +245 -245
  42. package/components/base.components/supervision/FormSupervision.component.tsx +433 -433
  43. package/components/base.components/supervision/TableSupervision.component.tsx +697 -697
  44. package/components/base.components/table/ControlBar.component.tsx +497 -497
  45. package/components/base.components/table/FilterComponent.tsx +518 -518
  46. package/components/base.components/table/Table.component.tsx +469 -469
  47. package/components/base.components/typography/TypographyArticle.component.tsx +26 -26
  48. package/components/base.components/typography/TypographyColumn.component.tsx +20 -20
  49. package/components/base.components/typography/TypographyContent.component.tsx +20 -20
  50. package/components/base.components/typography/TypographyTips.component.tsx +20 -20
  51. package/components/base.components/wrap/Draggable.component.tsx +303 -303
  52. package/components/base.components/wrap/IDBProvider.tsx +12 -12
  53. package/components/base.components/wrap/Image.component.tsx +9 -9
  54. package/components/base.components/wrap/ShortcutProvider.tsx +57 -57
  55. package/components/base.components/wrap/Swipe.component.tsx +93 -93
  56. package/components/index.ts +2 -2
  57. package/contexts/AppProvider.tsx +11 -11
  58. package/contexts/Auth.context.tsx +64 -64
  59. package/contexts/Toggle.context.tsx +44 -44
  60. package/next.config.ts +15 -1
  61. package/package.json +14 -13
  62. package/public/204.svg +19 -19
  63. package/public/500.svg +39 -39
  64. package/public/icon-192.png +0 -0
  65. package/public/icon-512.png +0 -0
  66. package/public/images/logo-fill.png +0 -0
  67. package/public/images/logo-full-fill.png +0 -0
  68. package/public/images/logo-full.png +0 -0
  69. package/public/images/logo.png +0 -0
  70. package/schema/idb/app.schema.ts +8 -8
  71. package/src-tauri/Cargo.toml +14 -0
  72. package/src-tauri/build.rs +3 -0
  73. package/src-tauri/capabilities/default.json +11 -0
  74. package/src-tauri/icons/128x128.png +0 -0
  75. package/src-tauri/icons/128x128@2x.png +0 -0
  76. package/src-tauri/icons/32x32.png +0 -0
  77. package/src-tauri/icons/icon.icns +0 -0
  78. package/src-tauri/icons/icon.ico +0 -0
  79. package/src-tauri/src/main.rs +7 -0
  80. package/src-tauri/tauri.conf.json +36 -0
  81. package/styles/globals.css +231 -231
  82. package/styles/tailwind.safelist +68 -68
  83. package/utils/commands/barrels.ts +27 -27
  84. package/utils/commands/light.ts +21 -21
  85. package/utils/commands/logger.ts +42 -42
  86. package/utils/commands/stubs/table-blueprint.stub +12 -12
  87. package/utils/commands/use-pdf.ts +29 -29
@@ -1,276 +1,276 @@
1
- "use client"
2
-
3
- import { FC, InputHTMLAttributes, ReactNode, useEffect, useMemo, useState } from "react";
4
- import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
5
- import { cn, pcn, useInputHandler, useInputRandomId, useResponsive, useValidation, validation, ValidationRules } from "@utils";
6
- import { BottomSheetComponent, ButtonComponent, OutsideClickComponent } from "@components";
7
-
8
-
9
-
10
- type CT = "label" | "tip" | "error" | "input"| "icon";
11
-
12
- export interface InputTimeProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "onChange"> {
13
- label ?: string;
14
- tip ?: string | ReactNode;
15
- leftIcon ?: any;
16
- rightIcon ?: any;
17
-
18
- value ?: string;
19
- invalid ?: string;
20
- validations ?: ValidationRules;
21
-
22
- onChange ?: (value: string) => any;
23
- register ?: (name: string, validations?: ValidationRules) => void;
24
- unregister ?: (name: string) => void;
25
-
26
- /** Use custom class with: "label::", "tip::", "error::", "icon::". */
27
- className ?: string;
28
- }
29
-
30
-
31
-
32
- export function InputTimeComponent({
33
- label,
34
- tip,
35
- leftIcon,
36
- rightIcon,
37
-
38
- value,
39
- invalid,
40
- validations,
41
-
42
- register,
43
- unregister,
44
- onChange,
45
-
46
- className = "",
47
- ...props
48
- }: InputTimeProps) {
49
- const { isSm } = useResponsive();
50
-
51
- // =========================>
52
- // ## Initial
53
- // =========================>
54
- const inputHandler = useInputHandler(props.name, value, validations, register, unregister, false)
55
- const randomId = useInputRandomId()
56
-
57
-
58
- // =========================>
59
- // ## Invalid handler
60
- // =========================>
61
- const [invalidMessage] = useValidation(inputHandler.value, validations, invalid, inputHandler.idle);
62
-
63
-
64
- return (
65
- <>
66
- <div className="relative flex flex-col gap-y-0.5">
67
- <label
68
- htmlFor={randomId}
69
- className={cn(
70
- "input-label",
71
- pcn<CT>(className, "label"),
72
- props.disabled && "opacity-50",
73
- inputHandler.focus && "text-primary",
74
- !!invalidMessage && "text-danger"
75
- )}
76
- >
77
- {label}
78
- {validations && validation.hasRules(validations, "required") && <span className="text-danger ml-1">*</span>}
79
- </label>
80
-
81
- {tip && (
82
- <small
83
- className={cn(
84
- "input-tip",
85
- pcn<CT>(className, "tip"),
86
- props.disabled && "opacity-60"
87
- )}
88
- >{tip}</small>
89
- )}
90
-
91
- <OutsideClickComponent onOutsideClick={!isSm ? () => inputHandler.setFocus(false) : undefined}>
92
- <div className="relative">
93
- <input
94
- {...props}
95
- id={randomId}
96
- className={cn(
97
- "input",
98
- leftIcon && "pl-12",
99
- rightIcon && "pr-12",
100
- pcn<CT>(className, "input"),
101
- !!invalidMessage && "input-error"
102
- )}
103
- value={inputHandler.value}
104
- onChange={(e) => {
105
- inputHandler.setValue(e.target.value);
106
- inputHandler.setIdle(false);
107
- onChange?.(e.target.value);
108
- }}
109
- onFocus={(e) => {
110
- props.onFocus?.(e);
111
- inputHandler.setFocus(true);
112
- }}
113
- autoComplete="off"
114
- inputMode={isSm ? "none" : undefined}
115
- />
116
-
117
- {leftIcon && (
118
- <FontAwesomeIcon
119
- className={cn(
120
- "left-4 input-icon",
121
- pcn<CT>(className, "icon"),
122
- props.disabled && "opacity-60",
123
- inputHandler.focus && "text-primary"
124
- )}
125
- icon={leftIcon}
126
- />
127
- )}
128
-
129
- {rightIcon && (
130
- <FontAwesomeIcon
131
- className={cn(
132
- "right-4 input-icon",
133
- pcn<CT>(className, "icon"),
134
- props.disabled && "opacity-60",
135
- inputHandler.focus && "text-primary"
136
- )}
137
- icon={rightIcon}
138
- />
139
- )}
140
-
141
- {!isSm && inputHandler.focus && (
142
- <div className="absolute z-50 top-full right-0 mt-1 w-max bg-background border rounded-[6px] p-2 shadow min-w-[300]">
143
- <InputTimePickerComponent
144
- onChange={(time) => {
145
- inputHandler.setValue(time);
146
- onChange?.(time);
147
- }}
148
- />
149
- </div>
150
- )}
151
- </div>
152
- </OutsideClickComponent>
153
-
154
- {invalidMessage && (
155
- <small className={cn("input-error-message", pcn<CT>(className, "error"))}>{invalidMessage}</small>
156
- )}
157
- </div>
158
-
159
- {isSm && (
160
- <BottomSheetComponent
161
- show={inputHandler.focus}
162
- onClose={() => inputHandler.setFocus(false)}
163
- size={380}
164
- footer={
165
- <div className="p-4">
166
- <ButtonComponent
167
- label="Selesai"
168
- variant="outline"
169
- onClick={() => inputHandler.setFocus(false)}
170
- block
171
- />
172
- </div>
173
- }
174
- >
175
- <div className="p-4">
176
- <InputTimePickerComponent
177
- onChange={(time) => {
178
- inputHandler.setValue(time);
179
- onChange?.(time);
180
- }}
181
- />
182
- </div>
183
- </BottomSheetComponent>
184
- )}
185
- </>
186
- );
187
- }
188
-
189
-
190
-
191
- interface InputTimePickerProps {
192
- onChange ?: (time: string) => void;
193
- rightElement ?: ReactNode;
194
- };
195
-
196
-
197
-
198
-
199
- export const InputTimePickerComponent: FC<InputTimePickerProps> = ({
200
- onChange,
201
- rightElement,
202
- }) => {
203
- const [hour, setHour] = useState(0);
204
- const [minute, setMinute] = useState(0);
205
- const [second, setSecond] = useState(0);
206
-
207
- const hours = Array.from({ length: 24 }, (_, i) => String(i).padStart(2, "0"));
208
- const minutes = Array.from({ length: 60 }, (_, i) => String(i).padStart(2, "0"));
209
- const seconds = Array.from({ length: 60 }, (_, i) => String(i).padStart(2, "0"));
210
-
211
- const handleSelect = (type: "h" | "m" | "s", val: string) => {
212
- if (type === "h") setHour(Number(val));
213
- if (type === "m") setMinute(Number(val));
214
- if (type === "s") setSecond(Number(val));
215
- };
216
-
217
- useEffect(() => {
218
- const formatted = `${String(hour).padStart(2, "0")}:${String(minute).padStart(2, "0")}:${String(second).padStart(2, "0")}`;
219
- onChange?.(formatted);
220
- }, [hour, minute, second]);
221
-
222
- const renderColumn = (items: string[], type: "h" | "m" | "s", activeValue: number) => (
223
- <div className="flex-1 overflow-y-auto text-center input-scroll">
224
- {items.map((item) => {
225
- const active = Number(item) === activeValue;
226
-
227
- return (
228
- <div
229
- key={item}
230
- onClick={() => handleSelect(type, item)}
231
- className={cn(
232
- "p-2 cursor-pointer rounded text-sm",
233
- active ? "bg-primary text-background font-semibold" : "hover:bg-light-primary"
234
- )}
235
- >{item}</div>
236
- );
237
- })}
238
- </div>
239
- );
240
-
241
- const timeSlots = useMemo(() => {
242
- const newTimeSlots = [];
243
-
244
- for (let i = 0; i <= 24 * 60; i += 30) {
245
- const hours = Math.floor(i / 60);
246
- const minutes = i % 60;
247
- const label = `${String(hours).padStart(2, "0")}:${String(minutes).padStart(2, "0")}`;
248
-
249
- newTimeSlots.push(label);
250
- }
251
-
252
- return newTimeSlots;
253
- }, [])
254
-
255
- return (
256
- <div className="w-full max-h-[260] flex gap-2">
257
- <div className="w-1/3 overflow-y-auto bg-background rounded-[6px] input-scroll">
258
- {timeSlots.map((time) => (
259
- <div
260
- key={time}
261
- className="p-2 text-sm rounded cursor-pointer hover:bg-light-primary text-center"
262
- onClick={() => onChange?.(time)}
263
- >{time}</div>
264
- ))}
265
- </div>
266
-
267
- <div className="w-2/3 flex gap-2">
268
- {renderColumn(hours, "h", hour)}
269
- {renderColumn(minutes, "m", minute)}
270
- {renderColumn(seconds, "s", second)}
271
- </div>
272
-
273
- {rightElement && <div>{rightElement}</div>}
274
- </div>
275
- );
1
+ "use client"
2
+
3
+ import { FC, InputHTMLAttributes, ReactNode, useEffect, useMemo, useState } from "react";
4
+ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
5
+ import { cn, pcn, useInputHandler, useInputRandomId, useResponsive, useValidation, validation, ValidationRules } from "@utils";
6
+ import { BottomSheetComponent, ButtonComponent, OutsideClickComponent } from "@components";
7
+
8
+
9
+
10
+ type CT = "label" | "tip" | "error" | "input"| "icon";
11
+
12
+ export interface InputTimeProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "onChange"> {
13
+ label ?: string;
14
+ tip ?: string | ReactNode;
15
+ leftIcon ?: any;
16
+ rightIcon ?: any;
17
+
18
+ value ?: string;
19
+ invalid ?: string;
20
+ validations ?: ValidationRules;
21
+
22
+ onChange ?: (value: string) => any;
23
+ register ?: (name: string, validations?: ValidationRules) => void;
24
+ unregister ?: (name: string) => void;
25
+
26
+ /** Use custom class with: "label::", "tip::", "error::", "icon::". */
27
+ className ?: string;
28
+ }
29
+
30
+
31
+
32
+ export function InputTimeComponent({
33
+ label,
34
+ tip,
35
+ leftIcon,
36
+ rightIcon,
37
+
38
+ value,
39
+ invalid,
40
+ validations,
41
+
42
+ register,
43
+ unregister,
44
+ onChange,
45
+
46
+ className = "",
47
+ ...props
48
+ }: InputTimeProps) {
49
+ const { isSm } = useResponsive();
50
+
51
+ // =========================>
52
+ // ## Initial
53
+ // =========================>
54
+ const inputHandler = useInputHandler(props.name, value, validations, register, unregister, false)
55
+ const randomId = useInputRandomId()
56
+
57
+
58
+ // =========================>
59
+ // ## Invalid handler
60
+ // =========================>
61
+ const [invalidMessage] = useValidation(inputHandler.value, validations, invalid, inputHandler.idle);
62
+
63
+
64
+ return (
65
+ <>
66
+ <div className="relative flex flex-col gap-y-0.5">
67
+ <label
68
+ htmlFor={randomId}
69
+ className={cn(
70
+ "input-label",
71
+ pcn<CT>(className, "label"),
72
+ props.disabled && "opacity-50",
73
+ inputHandler.focus && "text-primary",
74
+ !!invalidMessage && "text-danger"
75
+ )}
76
+ >
77
+ {label}
78
+ {validations && validation.hasRules(validations, "required") && <span className="text-danger ml-1">*</span>}
79
+ </label>
80
+
81
+ {tip && (
82
+ <small
83
+ className={cn(
84
+ "input-tip",
85
+ pcn<CT>(className, "tip"),
86
+ props.disabled && "opacity-60"
87
+ )}
88
+ >{tip}</small>
89
+ )}
90
+
91
+ <OutsideClickComponent onOutsideClick={!isSm ? () => inputHandler.setFocus(false) : undefined}>
92
+ <div className="relative">
93
+ <input
94
+ {...props}
95
+ id={randomId}
96
+ className={cn(
97
+ "input",
98
+ leftIcon && "pl-12",
99
+ rightIcon && "pr-12",
100
+ pcn<CT>(className, "input"),
101
+ !!invalidMessage && "input-error"
102
+ )}
103
+ value={inputHandler.value}
104
+ onChange={(e) => {
105
+ inputHandler.setValue(e.target.value);
106
+ inputHandler.setIdle(false);
107
+ onChange?.(e.target.value);
108
+ }}
109
+ onFocus={(e) => {
110
+ props.onFocus?.(e);
111
+ inputHandler.setFocus(true);
112
+ }}
113
+ autoComplete="off"
114
+ inputMode={isSm ? "none" : undefined}
115
+ />
116
+
117
+ {leftIcon && (
118
+ <FontAwesomeIcon
119
+ className={cn(
120
+ "left-4 input-icon",
121
+ pcn<CT>(className, "icon"),
122
+ props.disabled && "opacity-60",
123
+ inputHandler.focus && "text-primary"
124
+ )}
125
+ icon={leftIcon}
126
+ />
127
+ )}
128
+
129
+ {rightIcon && (
130
+ <FontAwesomeIcon
131
+ className={cn(
132
+ "right-4 input-icon",
133
+ pcn<CT>(className, "icon"),
134
+ props.disabled && "opacity-60",
135
+ inputHandler.focus && "text-primary"
136
+ )}
137
+ icon={rightIcon}
138
+ />
139
+ )}
140
+
141
+ {!isSm && inputHandler.focus && (
142
+ <div className="absolute z-50 top-full right-0 mt-1 w-max bg-background border rounded-[6px] p-2 shadow min-w-[300]">
143
+ <InputTimePickerComponent
144
+ onChange={(time) => {
145
+ inputHandler.setValue(time);
146
+ onChange?.(time);
147
+ }}
148
+ />
149
+ </div>
150
+ )}
151
+ </div>
152
+ </OutsideClickComponent>
153
+
154
+ {invalidMessage && (
155
+ <small className={cn("input-error-message", pcn<CT>(className, "error"))}>{invalidMessage}</small>
156
+ )}
157
+ </div>
158
+
159
+ {isSm && (
160
+ <BottomSheetComponent
161
+ show={inputHandler.focus}
162
+ onClose={() => inputHandler.setFocus(false)}
163
+ size={380}
164
+ footer={
165
+ <div className="p-4">
166
+ <ButtonComponent
167
+ label="Selesai"
168
+ variant="outline"
169
+ onClick={() => inputHandler.setFocus(false)}
170
+ block
171
+ />
172
+ </div>
173
+ }
174
+ >
175
+ <div className="p-4">
176
+ <InputTimePickerComponent
177
+ onChange={(time) => {
178
+ inputHandler.setValue(time);
179
+ onChange?.(time);
180
+ }}
181
+ />
182
+ </div>
183
+ </BottomSheetComponent>
184
+ )}
185
+ </>
186
+ );
187
+ }
188
+
189
+
190
+
191
+ interface InputTimePickerProps {
192
+ onChange ?: (time: string) => void;
193
+ rightElement ?: ReactNode;
194
+ };
195
+
196
+
197
+
198
+
199
+ export const InputTimePickerComponent: FC<InputTimePickerProps> = ({
200
+ onChange,
201
+ rightElement,
202
+ }) => {
203
+ const [hour, setHour] = useState(0);
204
+ const [minute, setMinute] = useState(0);
205
+ const [second, setSecond] = useState(0);
206
+
207
+ const hours = Array.from({ length: 24 }, (_, i) => String(i).padStart(2, "0"));
208
+ const minutes = Array.from({ length: 60 }, (_, i) => String(i).padStart(2, "0"));
209
+ const seconds = Array.from({ length: 60 }, (_, i) => String(i).padStart(2, "0"));
210
+
211
+ const handleSelect = (type: "h" | "m" | "s", val: string) => {
212
+ if (type === "h") setHour(Number(val));
213
+ if (type === "m") setMinute(Number(val));
214
+ if (type === "s") setSecond(Number(val));
215
+ };
216
+
217
+ useEffect(() => {
218
+ const formatted = `${String(hour).padStart(2, "0")}:${String(minute).padStart(2, "0")}:${String(second).padStart(2, "0")}`;
219
+ onChange?.(formatted);
220
+ }, [hour, minute, second]);
221
+
222
+ const renderColumn = (items: string[], type: "h" | "m" | "s", activeValue: number) => (
223
+ <div className="flex-1 overflow-y-auto text-center input-scroll">
224
+ {items.map((item) => {
225
+ const active = Number(item) === activeValue;
226
+
227
+ return (
228
+ <div
229
+ key={item}
230
+ onClick={() => handleSelect(type, item)}
231
+ className={cn(
232
+ "p-2 cursor-pointer rounded text-sm",
233
+ active ? "bg-primary text-background font-semibold" : "hover:bg-light-primary"
234
+ )}
235
+ >{item}</div>
236
+ );
237
+ })}
238
+ </div>
239
+ );
240
+
241
+ const timeSlots = useMemo(() => {
242
+ const newTimeSlots = [];
243
+
244
+ for (let i = 0; i <= 24 * 60; i += 30) {
245
+ const hours = Math.floor(i / 60);
246
+ const minutes = i % 60;
247
+ const label = `${String(hours).padStart(2, "0")}:${String(minutes).padStart(2, "0")}`;
248
+
249
+ newTimeSlots.push(label);
250
+ }
251
+
252
+ return newTimeSlots;
253
+ }, [])
254
+
255
+ return (
256
+ <div className="w-full max-h-[260] flex gap-2">
257
+ <div className="w-1/3 overflow-y-auto bg-background rounded-[6px] input-scroll">
258
+ {timeSlots.map((time) => (
259
+ <div
260
+ key={time}
261
+ className="p-2 text-sm rounded cursor-pointer hover:bg-light-primary text-center"
262
+ onClick={() => onChange?.(time)}
263
+ >{time}</div>
264
+ ))}
265
+ </div>
266
+
267
+ <div className="w-2/3 flex gap-2">
268
+ {renderColumn(hours, "h", hour)}
269
+ {renderColumn(minutes, "m", minute)}
270
+ {renderColumn(seconds, "s", second)}
271
+ </div>
272
+
273
+ {rightElement && <div>{rightElement}</div>}
274
+ </div>
275
+ );
276
276
  };