torch-glare 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 (68) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +207 -0
  3. package/cli/bin/addComponent.js +278 -0
  4. package/cli/bin/addHooks.js +75 -0
  5. package/cli/bin/addLayout.js +71 -0
  6. package/cli/bin/addProvider.js +71 -0
  7. package/cli/bin/addUtils.js +74 -0
  8. package/cli/bin/cli.js +73 -0
  9. package/cli/bin/init/init.js +15 -0
  10. package/cli/bin/init/tailwindInit.js +174 -0
  11. package/cli/bin/update.js +147 -0
  12. package/lib/components/ActionButton.tsx +63 -0
  13. package/lib/components/ActionsGroup.tsx +34 -0
  14. package/lib/components/AlertDialog.tsx +211 -0
  15. package/lib/components/Badge.tsx +116 -0
  16. package/lib/components/BadgeField.tsx +192 -0
  17. package/lib/components/Button.tsx +277 -0
  18. package/lib/components/Card.tsx +63 -0
  19. package/lib/components/Checkbox.tsx +122 -0
  20. package/lib/components/CountBadge.tsx +54 -0
  21. package/lib/components/DatePicker.tsx +464 -0
  22. package/lib/components/Drawer.tsx +118 -0
  23. package/lib/components/DropdownMenu.tsx +399 -0
  24. package/lib/components/FieldHint.tsx +76 -0
  25. package/lib/components/ImageAttachment.tsx +180 -0
  26. package/lib/components/InnerLabelField.tsx +155 -0
  27. package/lib/components/Input.tsx +179 -0
  28. package/lib/components/InputField.tsx +147 -0
  29. package/lib/components/Label.tsx +107 -0
  30. package/lib/components/LabelField.tsx +75 -0
  31. package/lib/components/LabeledCheckBox.tsx +65 -0
  32. package/lib/components/LabeledRadio.tsx +45 -0
  33. package/lib/components/LinkButton.tsx +94 -0
  34. package/lib/components/LoginButton.tsx +56 -0
  35. package/lib/components/PasswordLevel.tsx +58 -0
  36. package/lib/components/Popover.tsx +274 -0
  37. package/lib/components/ProfileMenu.tsx +90 -0
  38. package/lib/components/Radio.tsx +77 -0
  39. package/lib/components/RadioCard.tsx +72 -0
  40. package/lib/components/RingLoading.tsx +190 -0
  41. package/lib/components/SearchField.tsx +49 -0
  42. package/lib/components/Select.tsx +417 -0
  43. package/lib/components/SlideDatePicker.tsx +120 -0
  44. package/lib/components/SpinLoading.tsx +190 -0
  45. package/lib/components/Switcher.tsx +56 -0
  46. package/lib/components/TabFormItem.tsx +158 -0
  47. package/lib/components/Table.tsx +395 -0
  48. package/lib/components/Textarea.tsx +108 -0
  49. package/lib/components/Tooltip.tsx +111 -0
  50. package/lib/components/TransparentLabel.tsx +72 -0
  51. package/lib/components/TreeDropDown.tsx +69 -0
  52. package/lib/hooks/MobileSlidePicker/components/Picker.tsx +218 -0
  53. package/lib/hooks/MobileSlidePicker/components/PickerColumn.tsx +238 -0
  54. package/lib/hooks/MobileSlidePicker/components/PickerItem.tsx +64 -0
  55. package/lib/hooks/MobileSlidePicker/index.ts +10 -0
  56. package/lib/hooks/useActiveTreeItem.tsx +61 -0
  57. package/lib/hooks/useClickOutside.tsx +20 -0
  58. package/lib/hooks/useResize.tsx +78 -0
  59. package/lib/layouts/CLayout.tsx +326 -0
  60. package/lib/layouts/FieldSection.tsx +64 -0
  61. package/lib/layouts/TreeSubLayout.tsx +187 -0
  62. package/lib/providers/ThemeProvider.tsx +99 -0
  63. package/lib/utils/cn.ts +6 -0
  64. package/lib/utils/convertImageFileToDataUrl.ts +17 -0
  65. package/lib/utils/resize.ts +35 -0
  66. package/lib/utils/types.ts +12 -0
  67. package/package.json +28 -0
  68. package/torch-glare.js +24 -0
@@ -0,0 +1,99 @@
1
+ 'use client';
2
+ import {
3
+ createContext,
4
+ ReactNode,
5
+ useContext,
6
+ useEffect,
7
+ useState,
8
+ } from "react";
9
+
10
+ interface ThemeProps {
11
+ theme: "light" | "dark" | "default";
12
+ themeMode: "CSS" | "TORCH";
13
+ updateTheme: (theme: "light" | "dark" | "default") => void;
14
+ updateMode: (themeMode: "CSS" | "TORCH") => void;
15
+ }
16
+
17
+ export const ThemeContext = createContext<ThemeProps | undefined>(undefined);
18
+
19
+ interface ThemeProviderProps {
20
+ children: ReactNode;
21
+ defaultTheme?: "light" | "dark" | "default";
22
+ defaultThemeMode?: "CSS" | "TORCH";
23
+ }
24
+
25
+ export const ThemeProvider: React.FC<ThemeProviderProps> = ({
26
+ children,
27
+ defaultTheme = "default",
28
+ defaultThemeMode = "TORCH",
29
+ }) => {
30
+ const [theme, setTheme] = useState<"light" | "dark" | "default">(() => {
31
+ if (typeof window !== "undefined" && document) {
32
+ const mode =
33
+ (document.documentElement.getAttribute("data-theme") as
34
+ | "light"
35
+ | "dark"
36
+ | "default") || defaultTheme;
37
+ const storedTheme = localStorage.getItem("theme") as
38
+ | "light"
39
+ | "dark"
40
+ | "default";
41
+ return storedTheme || mode || defaultTheme;
42
+ }
43
+ return defaultTheme;
44
+ });
45
+
46
+ const [themeMode, setThemeMode] = useState<"TORCH" | "CSS">(() => {
47
+ if (typeof window !== "undefined") {
48
+ const storedThemeMode = localStorage.getItem("theme-mode") as
49
+ | "TORCH"
50
+ | "CSS";
51
+ return storedThemeMode || defaultThemeMode;
52
+ }
53
+ return defaultThemeMode;
54
+ });
55
+
56
+ useEffect(() => {
57
+ if (document) {
58
+ document.documentElement.setAttribute("data-theme", theme);
59
+ document.documentElement.setAttribute("data-theme-mode", themeMode);
60
+ localStorage.setItem("theme", theme);
61
+ localStorage.setItem("theme-mode", themeMode);
62
+ }
63
+ }, [theme, themeMode]);
64
+
65
+ const updateTheme = (newTheme: "light" | "dark" | "default") => {
66
+ if (document) {
67
+ setTheme(newTheme);
68
+ document.documentElement.setAttribute("data-theme", newTheme);
69
+ localStorage.setItem("theme", newTheme);
70
+ }
71
+ };
72
+
73
+ const updateMode = (newThemeMode: "CSS" | "TORCH") => {
74
+ if (document) {
75
+ setThemeMode(newThemeMode);
76
+ document.documentElement.setAttribute("data-theme-mode", newThemeMode);
77
+ localStorage.setItem("theme-mode", newThemeMode);
78
+ }
79
+ };
80
+
81
+ const value = {
82
+ theme,
83
+ updateTheme,
84
+ updateMode,
85
+ themeMode,
86
+ };
87
+
88
+ return (
89
+ <ThemeContext.Provider value={value}>{children}</ThemeContext.Provider>
90
+ );
91
+ };
92
+
93
+ export const useTheme = () => {
94
+ const context = useContext(ThemeContext);
95
+ if (!context) {
96
+ throw new Error("useTheme must be used within a ThemeProvider");
97
+ }
98
+ return context;
99
+ };
@@ -0,0 +1,6 @@
1
+ import { clsx, type ClassValue } from "clsx";
2
+ import { twMerge } from "tailwind-merge";
3
+
4
+ export function cn(...inputs: ClassValue[]) {
5
+ return twMerge(clsx(inputs));
6
+ }
@@ -0,0 +1,17 @@
1
+ import { Dispatch, SetStateAction } from "react";
2
+
3
+ export const convertImageFileToDataUrl = async (
4
+ file: File | null,
5
+ setter: Dispatch<SetStateAction<string>>
6
+ ) => {
7
+ if (file && file.type.startsWith("image/")) {
8
+ const reader = new FileReader();
9
+ reader.onload = (e: ProgressEvent<FileReader>) => {
10
+ const result = e.target?.result;
11
+ if (typeof result === "string") {
12
+ setter(result);
13
+ }
14
+ };
15
+ reader.readAsDataURL(file);
16
+ }
17
+ };
@@ -0,0 +1,35 @@
1
+ import { MutableRefObject, RefObject } from "react";
2
+
3
+ // Extracted function to get the new width based on the mouse event
4
+ export const calculateNewWidthFromMouse = (
5
+ event: MouseEvent,
6
+ resizableRef:
7
+ | MutableRefObject<HTMLElement | null>
8
+ | RefObject<HTMLElement | null>,
9
+ isRtl: boolean
10
+ ): number => {
11
+ if (resizableRef.current) {
12
+ const rect = resizableRef.current.getBoundingClientRect();
13
+ return isRtl
14
+ ? rect.right - event.clientX // Reverse calculation for RTL
15
+ : event.clientX - rect.left;
16
+ }
17
+ return 0;
18
+ };
19
+
20
+ // Extracted function to get the new width based on the touch event
21
+ export const calculateNewWidthFromTouch = (
22
+ event: TouchEvent,
23
+ resizableRef:
24
+ | MutableRefObject<HTMLElement | null>
25
+ | RefObject<HTMLElement | null>,
26
+ isRtl: boolean
27
+ ): number => {
28
+ if (resizableRef.current) {
29
+ const rect = resizableRef.current.getBoundingClientRect();
30
+ return isRtl
31
+ ? rect.right - event.touches[0].clientX // Reverse calculation for RTL
32
+ : event.touches[0].clientX - rect.left;
33
+ }
34
+ return 0;
35
+ };
@@ -0,0 +1,12 @@
1
+ export type Themes = "dark" | "light" | "default";
2
+
3
+ export type ButtonVariant =
4
+ | "PrimeStyle"
5
+ | "BlueSecStyle"
6
+ | "YelSecStyle"
7
+ | "RedSecStyle"
8
+ | "BorderStyle"
9
+ | "PrimeContStyle"
10
+ | "BlueContStyle"
11
+ | "RedContStyle";
12
+
package/package.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "torch-glare",
3
+ "version": "1.0.2",
4
+ "type": "module",
5
+ "license": "MIT",
6
+ "files": [
7
+ "cli/bin",
8
+ "lib"
9
+ ],
10
+ "bin": {
11
+ "torch-glare": "./torch-glare.js"
12
+ },
13
+ "publishConfig": {
14
+ "access": "public"
15
+ },
16
+ "scripts": {
17
+ "build": "next build --no-lint",
18
+ "deploy": "node ./scripts/publish/index.js"
19
+ },
20
+ "dependencies": {
21
+ "commander": "^13.1.0",
22
+ "inquirer": "^9.2.15"
23
+ },
24
+ "devDependencies": {
25
+ "ts-node": "^10.9.2",
26
+ "typescript": "^5"
27
+ }
28
+ }
package/torch-glare.js ADDED
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env node
2
+ import { spawn } from "child_process";
3
+ import path from "path";
4
+ import { fileURLToPath } from "url";
5
+
6
+ const __filename = fileURLToPath(import.meta.url);
7
+ const __dirname = path.dirname(__filename);
8
+
9
+ const cliPath = path.join(__dirname, "cli/bin/cli.js");
10
+ console.log("Running CLI script:", cliPath);
11
+
12
+ // Run the CLI script
13
+ const cli = spawn("node", [cliPath, ...process.argv.slice(2)], {
14
+ stdio: "inherit",
15
+ });
16
+
17
+ cli.on("error", (error) => {
18
+ console.error("Failed to start CLI:", error);
19
+ process.exit(1);
20
+ });
21
+
22
+ cli.on("exit", (code) => {
23
+ process.exit(code);
24
+ });