@skalfa/skalfa-app 1.0.0 → 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.
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,169 +1,169 @@
1
- "use client"
2
-
3
- import { ClipboardEvent, FC, KeyboardEvent, ReactNode, useEffect, useRef, useState } from "react";
4
- import { cn, pcn } from "@utils";
5
-
6
-
7
-
8
- type CT = "label" | "tip" | "error" | "base" | "icon";
9
-
10
- export interface InputOtpProps {
11
- label ?: string;
12
- tip ?: string | ReactNode;
13
- name : string;
14
- disabled ?: boolean;
15
-
16
- value ?: string;
17
- invalid ?: string;
18
- length ?: number;
19
-
20
- onChange ?: (value: string) => any;
21
-
22
- /** Use custom class with: "label::", "tip::", "error::". */
23
- className ?: string;
24
- }
25
-
26
-
27
-
28
- export const InputOtpComponent: FC<InputOtpProps> = ({
29
- label,
30
- tip,
31
- name,
32
- disabled,
33
-
34
- value,
35
- invalid,
36
- length = 6,
37
-
38
- onChange,
39
-
40
- className = "",
41
- }) => {
42
- const [isFocus, setIsFocus] = useState(false);
43
- const inputsRef = useRef<(HTMLInputElement | null)[]>([]);
44
- const [otp, setOtp] = useState<string[]>((value || "").split("").concat(Array(length).fill("")).slice(0, length));
45
-
46
-
47
- useEffect(() => {
48
- const handleFocusChange = () => {
49
- const anyFocused = inputsRef.current.some((input) => input === document.activeElement);
50
- setIsFocus(anyFocused);
51
- };
52
-
53
- window.addEventListener("focusin", handleFocusChange);
54
- window.addEventListener("focusout", handleFocusChange);
55
-
56
- return () => {
57
- window.removeEventListener("focusin", handleFocusChange);
58
- window.removeEventListener("focusout", handleFocusChange);
59
- };
60
- }, []);
61
-
62
-
63
- const emitChange = (newOtp: string[]) => {
64
- const val = newOtp.join("");
65
- onChange?.(val);
66
- };
67
-
68
-
69
- const handleChange = (val: string, index: number) => {
70
- if (!/^[0-9]?$/.test(val)) return;
71
- const newOtp = [...otp];
72
- newOtp[index] = val;
73
-
74
- setOtp(newOtp);
75
- emitChange(newOtp);
76
-
77
- (val && index < length - 1) && inputsRef.current[index + 1]?.focus();
78
- };
79
-
80
-
81
- const handleKeyDown = (e: KeyboardEvent<HTMLInputElement>, index: number) => {
82
- if (e.key === "Backspace") {
83
- if (otp[index]) {
84
- const newOtp = [...otp];
85
- newOtp[index] = "";
86
- setOtp(newOtp);
87
- emitChange(newOtp);
88
- } else if (index > 0) {
89
- inputsRef.current[index - 1]?.focus();
90
- }
91
- }
92
- };
93
-
94
-
95
- const handlePaste = (e: ClipboardEvent<HTMLInputElement>) => {
96
- e.preventDefault();
97
- const paste = e.clipboardData.getData("text").trim();
98
- if (!/^[0-9]+$/.test(paste)) return;
99
- const pasted = paste.slice(0, length).split("");
100
- const newOtp = [...otp];
101
- for (let i = 0; i < pasted.length; i++) newOtp[i] = pasted[i];
102
- setOtp(newOtp);
103
- emitChange(newOtp);
104
- inputsRef.current[Math.min(pasted.length, length - 1)]?.focus();
105
- };
106
-
107
-
108
- return (
109
- <>
110
- <div className="relative flex flex-col gap-y-0.5">
111
- <label
112
- className={cn(
113
- "input-label",
114
- pcn<CT>(className, "label"),
115
- disabled && "opacity-50",
116
- disabled && pcn<CT>(className, "label", "disabled"),
117
- isFocus && "text-primary",
118
- isFocus && pcn<CT>(className, "label", "focus"),
119
- !!invalid && "text-danger",
120
- !!invalid && pcn<CT>(className, "label", "focus"),
121
- )}
122
- >
123
- {label}
124
- </label>
125
-
126
- {tip && (
127
- <small
128
- className={cn(
129
- "input-tip",
130
- pcn<CT>(className, "tip"),
131
- disabled && "opacity-60",
132
- disabled && pcn<CT>(className, "tip", "disabled"),
133
- )}
134
- >{tip}</small>
135
- )}
136
- <div className={cn(
137
- "input pb-1",
138
- isFocus && "!border-primary",
139
- !!invalid && "input-error"
140
- )}
141
- >
142
- <div className="flex gap-2 justify-between">
143
- {otp.map((digit, index) => (
144
- <input
145
- key={index}
146
- type="text"
147
- ref={(el) => {inputsRef.current[index] = el }}
148
- inputMode="numeric"
149
- maxLength={1}
150
- value={digit}
151
- onChange={(e) => handleChange(e.target.value, index)}
152
- onKeyDown={(e) => handleKeyDown(e, index)}
153
- onPaste={handlePaste}
154
- className={`w-8 h-full pb-1 text-center border-b outline-none border-foreground focus:!border-primary placeholder:text-light-foreground`}
155
- placeholder="-"
156
- autoFocus={index === 0}
157
- />
158
- ))}
159
- </div>
160
- <input type="hidden" name={name} value={otp.join("")} />
161
- </div>
162
-
163
- {invalid && (
164
- <small className={cn("input-error-message", pcn<CT>(className, "error"))}>{invalid}</small>
165
- )}
166
- </div>
167
- </>
168
- );
169
- };
1
+ "use client"
2
+
3
+ import { ClipboardEvent, FC, KeyboardEvent, ReactNode, useEffect, useRef, useState } from "react";
4
+ import { cn, pcn } from "@utils";
5
+
6
+
7
+
8
+ type CT = "label" | "tip" | "error" | "base" | "icon";
9
+
10
+ export interface InputOtpProps {
11
+ label ?: string;
12
+ tip ?: string | ReactNode;
13
+ name : string;
14
+ disabled ?: boolean;
15
+
16
+ value ?: string;
17
+ invalid ?: string;
18
+ length ?: number;
19
+
20
+ onChange ?: (value: string) => any;
21
+
22
+ /** Use custom class with: "label::", "tip::", "error::". */
23
+ className ?: string;
24
+ }
25
+
26
+
27
+
28
+ export const InputOtpComponent: FC<InputOtpProps> = ({
29
+ label,
30
+ tip,
31
+ name,
32
+ disabled,
33
+
34
+ value,
35
+ invalid,
36
+ length = 6,
37
+
38
+ onChange,
39
+
40
+ className = "",
41
+ }) => {
42
+ const [isFocus, setIsFocus] = useState(false);
43
+ const inputsRef = useRef<(HTMLInputElement | null)[]>([]);
44
+ const [otp, setOtp] = useState<string[]>((value || "").split("").concat(Array(length).fill("")).slice(0, length));
45
+
46
+
47
+ useEffect(() => {
48
+ const handleFocusChange = () => {
49
+ const anyFocused = inputsRef.current.some((input) => input === document.activeElement);
50
+ setIsFocus(anyFocused);
51
+ };
52
+
53
+ window.addEventListener("focusin", handleFocusChange);
54
+ window.addEventListener("focusout", handleFocusChange);
55
+
56
+ return () => {
57
+ window.removeEventListener("focusin", handleFocusChange);
58
+ window.removeEventListener("focusout", handleFocusChange);
59
+ };
60
+ }, []);
61
+
62
+
63
+ const emitChange = (newOtp: string[]) => {
64
+ const val = newOtp.join("");
65
+ onChange?.(val);
66
+ };
67
+
68
+
69
+ const handleChange = (val: string, index: number) => {
70
+ if (!/^[0-9]?$/.test(val)) return;
71
+ const newOtp = [...otp];
72
+ newOtp[index] = val;
73
+
74
+ setOtp(newOtp);
75
+ emitChange(newOtp);
76
+
77
+ (val && index < length - 1) && inputsRef.current[index + 1]?.focus();
78
+ };
79
+
80
+
81
+ const handleKeyDown = (e: KeyboardEvent<HTMLInputElement>, index: number) => {
82
+ if (e.key === "Backspace") {
83
+ if (otp[index]) {
84
+ const newOtp = [...otp];
85
+ newOtp[index] = "";
86
+ setOtp(newOtp);
87
+ emitChange(newOtp);
88
+ } else if (index > 0) {
89
+ inputsRef.current[index - 1]?.focus();
90
+ }
91
+ }
92
+ };
93
+
94
+
95
+ const handlePaste = (e: ClipboardEvent<HTMLInputElement>) => {
96
+ e.preventDefault();
97
+ const paste = e.clipboardData.getData("text").trim();
98
+ if (!/^[0-9]+$/.test(paste)) return;
99
+ const pasted = paste.slice(0, length).split("");
100
+ const newOtp = [...otp];
101
+ for (let i = 0; i < pasted.length; i++) newOtp[i] = pasted[i];
102
+ setOtp(newOtp);
103
+ emitChange(newOtp);
104
+ inputsRef.current[Math.min(pasted.length, length - 1)]?.focus();
105
+ };
106
+
107
+
108
+ return (
109
+ <>
110
+ <div className="relative flex flex-col gap-y-0.5">
111
+ <label
112
+ className={cn(
113
+ "input-label",
114
+ pcn<CT>(className, "label"),
115
+ disabled && "opacity-50",
116
+ disabled && pcn<CT>(className, "label", "disabled"),
117
+ isFocus && "text-primary",
118
+ isFocus && pcn<CT>(className, "label", "focus"),
119
+ !!invalid && "text-danger",
120
+ !!invalid && pcn<CT>(className, "label", "focus"),
121
+ )}
122
+ >
123
+ {label}
124
+ </label>
125
+
126
+ {tip && (
127
+ <small
128
+ className={cn(
129
+ "input-tip",
130
+ pcn<CT>(className, "tip"),
131
+ disabled && "opacity-60",
132
+ disabled && pcn<CT>(className, "tip", "disabled"),
133
+ )}
134
+ >{tip}</small>
135
+ )}
136
+ <div className={cn(
137
+ "input pb-1",
138
+ isFocus && "!border-primary",
139
+ !!invalid && "input-error"
140
+ )}
141
+ >
142
+ <div className="flex gap-2 justify-between">
143
+ {otp.map((digit, index) => (
144
+ <input
145
+ key={index}
146
+ type="text"
147
+ ref={(el) => {inputsRef.current[index] = el }}
148
+ inputMode="numeric"
149
+ maxLength={1}
150
+ value={digit}
151
+ onChange={(e) => handleChange(e.target.value, index)}
152
+ onKeyDown={(e) => handleKeyDown(e, index)}
153
+ onPaste={handlePaste}
154
+ className={`w-8 h-full pb-1 text-center border-b outline-none border-foreground focus:!border-primary placeholder:text-light-foreground`}
155
+ placeholder="-"
156
+ autoFocus={index === 0}
157
+ />
158
+ ))}
159
+ </div>
160
+ <input type="hidden" name={name} value={otp.join("")} />
161
+ </div>
162
+
163
+ {invalid && (
164
+ <small className={cn("input-error-message", pcn<CT>(className, "error"))}>{invalid}</small>
165
+ )}
166
+ </div>
167
+ </>
168
+ );
169
+ };