@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,192 +1,192 @@
1
- "use client"
2
-
3
- import React, { InputHTMLAttributes, ReactNode } from "react";
4
- import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
5
- import { faSortDown, faSortUp } from "@fortawesome/free-solid-svg-icons";
6
- import { cn, pcn, useInputHandler, useInputRandomId, useValidation, validation, ValidationRules } from "@utils";
7
-
8
-
9
-
10
- type CT = "label" | "tip" | "error" | "input" | "icon";
11
-
12
- export interface InputNumberProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "onChange"> {
13
- label ?: string;
14
- tip ?: string | ReactNode;
15
- leftIcon ?: any;
16
- rightIcon ?: any;
17
-
18
- value ?: number;
19
- invalid ?: string;
20
- validations ?: ValidationRules;
21
- min ?: number;
22
- max ?: number;
23
-
24
- onChange ?: (value: number) => any;
25
- register ?: (name: string, validations?: ValidationRules) => void;
26
- unregister ?: (name: string) => void;
27
-
28
- /** Use custom class with: "label::", "tip::", "error::", "icon::", "suggest::", "suggest-item::". */
29
- className ?: string;
30
- }
31
-
32
-
33
-
34
- export function InputNumberComponent({
35
- label,
36
- tip,
37
- leftIcon,
38
- rightIcon,
39
-
40
- value,
41
- invalid,
42
- validations,
43
- min,
44
- max,
45
-
46
- onChange,
47
- register,
48
- unregister,
49
-
50
- className = "",
51
- ...props
52
- }: InputNumberProps) {
53
-
54
- // =========================>
55
- // ## Initial
56
- // =========================>
57
- const inputHandler = useInputHandler(props.name, value, validations, register, unregister, false)
58
- const randomId = useInputRandomId()
59
-
60
-
61
- // =========================>
62
- // ## Invalid handler
63
- // =========================>
64
- const [invalidMessage] = useValidation(inputHandler.value, validations, invalid, inputHandler.idle);
65
-
66
-
67
- // =========================>
68
- // ## Change value handler
69
- // =========================>
70
- const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
71
- const newValue = e.target.value;
72
-
73
- const regex = /^-?\d*\.?\d*$/;
74
- if (regex.test(newValue)) {
75
- inputHandler.setValue(newValue);
76
- inputHandler.setIdle(false);
77
- onChange?.(Number(newValue));
78
- }
79
- };
80
-
81
-
82
- const handleBlur = (e: React.FocusEvent<HTMLInputElement>) => {
83
- props.onBlur?.(e);
84
- setTimeout(() => inputHandler.setFocus(false), 100);
85
- };
86
-
87
-
88
- const handleFocus = (e: React.FocusEvent<HTMLInputElement>) => {
89
- props.onFocus?.(e);
90
- inputHandler.setFocus(true);
91
- };
92
-
93
-
94
- return (
95
- <>
96
- <div className="relative flex flex-col gap-y-0.5">
97
- <label
98
- htmlFor={randomId}
99
- className={cn(
100
- "input-label",
101
- pcn<CT>(className, "label"),
102
- props.disabled && "opacity-50",
103
- props.disabled && pcn<CT>(className, "label", "disabled"),
104
- inputHandler.focus && "text-primary",
105
- inputHandler.focus && pcn<CT>(className, "label", "focus"),
106
- !!invalidMessage && "text-danger",
107
- !!invalidMessage && pcn<CT>(className, "label", "focus"),
108
- )}
109
- >
110
- {label}
111
- {validations && validation.hasRules(validations, "required") && <span className="text-danger ml-1">*</span>}
112
- </label>
113
-
114
- {tip && (
115
- <small
116
- className={cn(
117
- "input-tip",
118
- pcn<CT>(className, "tip"),
119
- props.disabled && "opacity-60",
120
- props.disabled && pcn<CT>(className, "tip", "disabled"),
121
- )}
122
- >{tip}</small>
123
- )}
124
-
125
- <div className="relative">
126
- <input
127
- {...props}
128
- id={randomId}
129
- className={cn(
130
- "input",
131
- leftIcon && "pl-12",
132
- rightIcon && "pr-12",
133
- pcn<CT>(className, "input"),
134
- !!invalidMessage && "input-error",
135
- !!invalidMessage && pcn<CT>(className, "input", "error"),
136
- )}
137
- value={inputHandler.value}
138
- onChange={handleInputChange}
139
- onFocus={handleFocus}
140
- onBlur={handleBlur}
141
- autoComplete="off"
142
- min={min}
143
- max={max}
144
- />
145
-
146
- {leftIcon && (
147
- <FontAwesomeIcon
148
- className={cn(
149
- "left-4 input-icon ",
150
- pcn<CT>(className, "icon"),
151
- props.disabled && "opacity-60",
152
- props.disabled && pcn<CT>(className, "icon", "disabled"),
153
- inputHandler.focus && "text-primary",
154
- inputHandler.focus && pcn<CT>(className, "icon", "focus"),
155
- )}
156
- icon={leftIcon}
157
- />
158
- )}
159
-
160
- <label
161
- htmlFor={randomId}
162
- className={cn(
163
- "right-4 input-icon",
164
- pcn<CT>(className, "icon"),
165
- props.disabled && "opacity-60",
166
- props.disabled && pcn<CT>(className, "icon", "disabled"),
167
- inputHandler.focus && "text-primary",
168
- inputHandler.focus && pcn<CT>(className, "icon", "focus"),
169
- )}
170
- >
171
- <div className="flex flex-col">
172
- <FontAwesomeIcon
173
- className={`text-light-foreground hover:text-primary -mb-1`}
174
- icon={faSortUp}
175
- onClick={() => inputHandler.setValue(String(Number(inputHandler.value) + 1))}
176
- />
177
- <FontAwesomeIcon
178
- className={`text-light-foreground hover:text-primary -mt-1`}
179
- icon={faSortDown}
180
- onClick={() => inputHandler.setValue(String(Number(inputHandler.value) - 1))}
181
- />
182
- </div>
183
- </label>
184
- </div>
185
-
186
- {invalidMessage && (
187
- <small className={cn("input-error-message", pcn<CT>(className, "error"))}>{invalidMessage}</small>
188
- )}
189
- </div>
190
- </>
191
- );
192
- }
1
+ "use client"
2
+
3
+ import React, { InputHTMLAttributes, ReactNode } from "react";
4
+ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
5
+ import { faSortDown, faSortUp } from "@fortawesome/free-solid-svg-icons";
6
+ import { cn, pcn, useInputHandler, useInputRandomId, useValidation, validation, ValidationRules } from "@utils";
7
+
8
+
9
+
10
+ type CT = "label" | "tip" | "error" | "input" | "icon";
11
+
12
+ export interface InputNumberProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "onChange"> {
13
+ label ?: string;
14
+ tip ?: string | ReactNode;
15
+ leftIcon ?: any;
16
+ rightIcon ?: any;
17
+
18
+ value ?: number;
19
+ invalid ?: string;
20
+ validations ?: ValidationRules;
21
+ min ?: number;
22
+ max ?: number;
23
+
24
+ onChange ?: (value: number) => any;
25
+ register ?: (name: string, validations?: ValidationRules) => void;
26
+ unregister ?: (name: string) => void;
27
+
28
+ /** Use custom class with: "label::", "tip::", "error::", "icon::", "suggest::", "suggest-item::". */
29
+ className ?: string;
30
+ }
31
+
32
+
33
+
34
+ export function InputNumberComponent({
35
+ label,
36
+ tip,
37
+ leftIcon,
38
+ rightIcon,
39
+
40
+ value,
41
+ invalid,
42
+ validations,
43
+ min,
44
+ max,
45
+
46
+ onChange,
47
+ register,
48
+ unregister,
49
+
50
+ className = "",
51
+ ...props
52
+ }: InputNumberProps) {
53
+
54
+ // =========================>
55
+ // ## Initial
56
+ // =========================>
57
+ const inputHandler = useInputHandler(props.name, value, validations, register, unregister, false)
58
+ const randomId = useInputRandomId()
59
+
60
+
61
+ // =========================>
62
+ // ## Invalid handler
63
+ // =========================>
64
+ const [invalidMessage] = useValidation(inputHandler.value, validations, invalid, inputHandler.idle);
65
+
66
+
67
+ // =========================>
68
+ // ## Change value handler
69
+ // =========================>
70
+ const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
71
+ const newValue = e.target.value;
72
+
73
+ const regex = /^-?\d*\.?\d*$/;
74
+ if (regex.test(newValue)) {
75
+ inputHandler.setValue(newValue);
76
+ inputHandler.setIdle(false);
77
+ onChange?.(Number(newValue));
78
+ }
79
+ };
80
+
81
+
82
+ const handleBlur = (e: React.FocusEvent<HTMLInputElement>) => {
83
+ props.onBlur?.(e);
84
+ setTimeout(() => inputHandler.setFocus(false), 100);
85
+ };
86
+
87
+
88
+ const handleFocus = (e: React.FocusEvent<HTMLInputElement>) => {
89
+ props.onFocus?.(e);
90
+ inputHandler.setFocus(true);
91
+ };
92
+
93
+
94
+ return (
95
+ <>
96
+ <div className="relative flex flex-col gap-y-0.5">
97
+ <label
98
+ htmlFor={randomId}
99
+ className={cn(
100
+ "input-label",
101
+ pcn<CT>(className, "label"),
102
+ props.disabled && "opacity-50",
103
+ props.disabled && pcn<CT>(className, "label", "disabled"),
104
+ inputHandler.focus && "text-primary",
105
+ inputHandler.focus && pcn<CT>(className, "label", "focus"),
106
+ !!invalidMessage && "text-danger",
107
+ !!invalidMessage && pcn<CT>(className, "label", "focus"),
108
+ )}
109
+ >
110
+ {label}
111
+ {validations && validation.hasRules(validations, "required") && <span className="text-danger ml-1">*</span>}
112
+ </label>
113
+
114
+ {tip && (
115
+ <small
116
+ className={cn(
117
+ "input-tip",
118
+ pcn<CT>(className, "tip"),
119
+ props.disabled && "opacity-60",
120
+ props.disabled && pcn<CT>(className, "tip", "disabled"),
121
+ )}
122
+ >{tip}</small>
123
+ )}
124
+
125
+ <div className="relative">
126
+ <input
127
+ {...props}
128
+ id={randomId}
129
+ className={cn(
130
+ "input",
131
+ leftIcon && "pl-12",
132
+ rightIcon && "pr-12",
133
+ pcn<CT>(className, "input"),
134
+ !!invalidMessage && "input-error",
135
+ !!invalidMessage && pcn<CT>(className, "input", "error"),
136
+ )}
137
+ value={inputHandler.value}
138
+ onChange={handleInputChange}
139
+ onFocus={handleFocus}
140
+ onBlur={handleBlur}
141
+ autoComplete="off"
142
+ min={min}
143
+ max={max}
144
+ />
145
+
146
+ {leftIcon && (
147
+ <FontAwesomeIcon
148
+ className={cn(
149
+ "left-4 input-icon ",
150
+ pcn<CT>(className, "icon"),
151
+ props.disabled && "opacity-60",
152
+ props.disabled && pcn<CT>(className, "icon", "disabled"),
153
+ inputHandler.focus && "text-primary",
154
+ inputHandler.focus && pcn<CT>(className, "icon", "focus"),
155
+ )}
156
+ icon={leftIcon}
157
+ />
158
+ )}
159
+
160
+ <label
161
+ htmlFor={randomId}
162
+ className={cn(
163
+ "right-4 input-icon",
164
+ pcn<CT>(className, "icon"),
165
+ props.disabled && "opacity-60",
166
+ props.disabled && pcn<CT>(className, "icon", "disabled"),
167
+ inputHandler.focus && "text-primary",
168
+ inputHandler.focus && pcn<CT>(className, "icon", "focus"),
169
+ )}
170
+ >
171
+ <div className="flex flex-col">
172
+ <FontAwesomeIcon
173
+ className={`text-light-foreground hover:text-primary -mb-1`}
174
+ icon={faSortUp}
175
+ onClick={() => inputHandler.setValue(String(Number(inputHandler.value) + 1))}
176
+ />
177
+ <FontAwesomeIcon
178
+ className={`text-light-foreground hover:text-primary -mt-1`}
179
+ icon={faSortDown}
180
+ onClick={() => inputHandler.setValue(String(Number(inputHandler.value) - 1))}
181
+ />
182
+ </div>
183
+ </label>
184
+ </div>
185
+
186
+ {invalidMessage && (
187
+ <small className={cn("input-error-message", pcn<CT>(className, "error"))}>{invalidMessage}</small>
188
+ )}
189
+ </div>
190
+ </>
191
+ );
192
+ }