create-react-scaffold-cli 1.0.7 → 1.1.0

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 (196) hide show
  1. package/bin/index.js +15 -5
  2. package/package.json +1 -1
  3. package/scripts/createProject.js +8 -2
  4. package/templates/{base → base-js}/src/shared/utils/parser.js +1 -1
  5. package/templates/base-ts/.husky/pre-commit +1 -0
  6. package/templates/base-ts/.husky/pre-push +0 -0
  7. package/templates/base-ts/.prettierrc +8 -0
  8. package/templates/base-ts/.vscode/extensions.json +8 -0
  9. package/templates/base-ts/.vscode/settings.json +16 -0
  10. package/templates/base-ts/README.md +165 -0
  11. package/templates/base-ts/docs/DOCS.md +7 -0
  12. package/templates/base-ts/eslint.config.js +56 -0
  13. package/templates/base-ts/index.html +16 -0
  14. package/templates/base-ts/jsconfig.json +7 -0
  15. package/templates/base-ts/package.json +69 -0
  16. package/templates/base-ts/postcss.config.mjs +7 -0
  17. package/templates/base-ts/public/icons/react.svg +1 -0
  18. package/templates/base-ts/src/app/APP.md +74 -0
  19. package/templates/base-ts/src/app/App.tsx +15 -0
  20. package/templates/base-ts/src/app/Router.tsx +48 -0
  21. package/templates/base-ts/src/app/index.css +37 -0
  22. package/templates/base-ts/src/app/main.tsx +13 -0
  23. package/templates/base-ts/src/app/middlewares/AuthMiddleware.tsx +6 -0
  24. package/templates/base-ts/src/app/middlewares/index.ts +1 -0
  25. package/templates/base-ts/src/app/providers/QueryProvider.tsx +75 -0
  26. package/templates/base-ts/src/app/providers/index.ts +1 -0
  27. package/templates/base-ts/src/app/routes.registry.ts +9 -0
  28. package/templates/base-ts/src/features/FEATURES.md +102 -0
  29. package/templates/base-ts/src/features/sample/components/index.ts +0 -0
  30. package/templates/base-ts/src/features/sample/constants/index.ts +3 -0
  31. package/templates/base-ts/src/features/sample/constants/sample.assets.ts +8 -0
  32. package/templates/base-ts/src/features/sample/constants/sample.navigations.ts +5 -0
  33. package/templates/base-ts/src/features/sample/constants/sample.queryKeys.ts +3 -0
  34. package/templates/base-ts/src/features/sample/hooks/index.ts +0 -0
  35. package/templates/base-ts/src/features/sample/index.ts +1 -0
  36. package/templates/base-ts/src/features/sample/pages/SamplePage.tsx +7 -0
  37. package/templates/base-ts/src/features/sample/pages/index.ts +1 -0
  38. package/templates/base-ts/src/features/sample/sample.routes.ts +13 -0
  39. package/templates/base-ts/src/features/welcome/components/CodeLine.tsx +59 -0
  40. package/templates/base-ts/src/features/welcome/components/Divider.tsx +11 -0
  41. package/templates/base-ts/src/features/welcome/components/Footer.tsx +78 -0
  42. package/templates/base-ts/src/features/welcome/components/Hero.tsx +131 -0
  43. package/templates/base-ts/src/features/welcome/components/IconLink.tsx +24 -0
  44. package/templates/base-ts/src/features/welcome/components/QuickStartPanel.tsx +63 -0
  45. package/templates/base-ts/src/features/welcome/components/RingSoft.tsx +21 -0
  46. package/templates/base-ts/src/features/welcome/components/StorySections.tsx +63 -0
  47. package/templates/base-ts/src/features/welcome/components/WhatYouGet.tsx +49 -0
  48. package/templates/base-ts/src/features/welcome/components/index.ts +5 -0
  49. package/templates/base-ts/src/features/welcome/constants/index.ts +2 -0
  50. package/templates/base-ts/src/features/welcome/constants/welcome.constants.ts +21 -0
  51. package/templates/base-ts/src/features/welcome/constants/welcome.navigations.ts +3 -0
  52. package/templates/base-ts/src/features/welcome/index.ts +1 -0
  53. package/templates/base-ts/src/features/welcome/pages/WelcomePage.tsx +28 -0
  54. package/templates/base-ts/src/features/welcome/pages/index.ts +1 -0
  55. package/templates/base-ts/src/features/welcome/welcome.routes.ts +13 -0
  56. package/templates/base-ts/src/shared/SHARED.md +104 -0
  57. package/templates/base-ts/src/shared/constants/app.constants.ts +11 -0
  58. package/templates/base-ts/src/shared/constants/assets.constants.ts +5 -0
  59. package/templates/base-ts/src/shared/constants/index.ts +2 -0
  60. package/templates/base-ts/src/shared/contexts/index.ts +0 -0
  61. package/templates/base-ts/src/shared/hooks/index.ts +3 -0
  62. package/templates/base-ts/src/shared/hooks/useBooleanState.ts +19 -0
  63. package/templates/base-ts/src/shared/hooks/useDebounce.ts +17 -0
  64. package/templates/base-ts/src/shared/hooks/useToggleState.ts +11 -0
  65. package/templates/base-ts/src/shared/layouts/index.ts +0 -0
  66. package/templates/base-ts/src/shared/libs/axios.ts +6 -0
  67. package/templates/base-ts/src/shared/libs/cn.ts +6 -0
  68. package/templates/base-ts/src/shared/libs/index.ts +2 -0
  69. package/templates/base-ts/src/shared/theme/index.ts +1 -0
  70. package/templates/base-ts/src/shared/theme/theme.ts +2149 -0
  71. package/templates/base-ts/src/shared/types/navigation.ts +9 -0
  72. package/templates/base-ts/src/shared/types/ui.ts +5 -0
  73. package/templates/base-ts/src/shared/ui/Box.tsx +153 -0
  74. package/templates/base-ts/src/shared/ui/Button.tsx +124 -0
  75. package/templates/base-ts/src/shared/ui/Checkbox.tsx +87 -0
  76. package/templates/base-ts/src/shared/ui/DropdownMenu.tsx +134 -0
  77. package/templates/base-ts/src/shared/ui/Flex.tsx +96 -0
  78. package/templates/base-ts/src/shared/ui/FlexItem.tsx +67 -0
  79. package/templates/base-ts/src/shared/ui/FormField.tsx +139 -0
  80. package/templates/base-ts/src/shared/ui/Grid.tsx +96 -0
  81. package/templates/base-ts/src/shared/ui/GridItem.tsx +67 -0
  82. package/templates/base-ts/src/shared/ui/Modal.tsx +42 -0
  83. package/templates/base-ts/src/shared/ui/Scrollable.tsx +48 -0
  84. package/templates/base-ts/src/shared/ui/Select.tsx +212 -0
  85. package/templates/base-ts/src/shared/ui/Sheet.tsx +126 -0
  86. package/templates/base-ts/src/shared/ui/Text.tsx +99 -0
  87. package/templates/base-ts/src/shared/ui/Toaster.tsx +31 -0
  88. package/templates/base-ts/src/shared/ui/index.ts +20 -0
  89. package/templates/base-ts/src/shared/utils/getClassName.ts +8 -0
  90. package/templates/base-ts/src/shared/utils/index.ts +4 -0
  91. package/templates/base-ts/src/shared/utils/localStorage.ts +18 -0
  92. package/templates/base-ts/src/shared/utils/memo.ts +9 -0
  93. package/templates/base-ts/src/shared/utils/motion.ts +0 -0
  94. package/templates/base-ts/src/shared/utils/parser.ts +41 -0
  95. package/templates/base-ts/src/shared/utils/regix.ts +3 -0
  96. package/templates/base-ts/src/shared/utils/tryCatch.ts +16 -0
  97. package/templates/base-ts/src/vite-env.d.ts +1 -0
  98. package/templates/base-ts/tsconfig.json +33 -0
  99. package/templates/base-ts/tsconfig.node.json +11 -0
  100. package/templates/base-ts/tsconfig.tsbuildinfo +1 -0
  101. package/templates/base-ts/vercel.json +3 -0
  102. package/templates/base-ts/vite.config.d.ts +2 -0
  103. package/templates/base-ts/vite.config.ts +18 -0
  104. /package/templates/{base → base-js}/.husky/pre-commit +0 -0
  105. /package/templates/{base → base-js}/.husky/pre-push +0 -0
  106. /package/templates/{base → base-js}/.prettierrc +0 -0
  107. /package/templates/{base → base-js}/.vscode/extensions.json +0 -0
  108. /package/templates/{base → base-js}/.vscode/settings.json +0 -0
  109. /package/templates/{base → base-js}/README.md +0 -0
  110. /package/templates/{base → base-js}/docs/DOCS.md +0 -0
  111. /package/templates/{base → base-js}/eslint.config.js +0 -0
  112. /package/templates/{base → base-js}/index.html +0 -0
  113. /package/templates/{base → base-js}/jsconfig.json +0 -0
  114. /package/templates/{base → base-js}/package.json +0 -0
  115. /package/templates/{base → base-js}/postcss.config.mjs +0 -0
  116. /package/templates/{base → base-js}/public/icons/react.svg +0 -0
  117. /package/templates/{base → base-js}/src/app/APP.md +0 -0
  118. /package/templates/{base → base-js}/src/app/App.jsx +0 -0
  119. /package/templates/{base → base-js}/src/app/Router.jsx +0 -0
  120. /package/templates/{base → base-js}/src/app/index.css +0 -0
  121. /package/templates/{base → base-js}/src/app/main.jsx +0 -0
  122. /package/templates/{base → base-js}/src/app/middlewares/AuthMiddleware.jsx +0 -0
  123. /package/templates/{base → base-js}/src/app/middlewares/index.js +0 -0
  124. /package/templates/{base → base-js}/src/app/providers/QueryProvider.jsx +0 -0
  125. /package/templates/{base → base-js}/src/app/providers/index.js +0 -0
  126. /package/templates/{base → base-js}/src/app/routes.registry.js +0 -0
  127. /package/templates/{base → base-js}/src/features/FEATURES.md +0 -0
  128. /package/templates/{base → base-js}/src/features/sample/components/index.js +0 -0
  129. /package/templates/{base → base-js}/src/features/sample/constants/index.js +0 -0
  130. /package/templates/{base → base-js}/src/features/sample/constants/sample.assets.js +0 -0
  131. /package/templates/{base → base-js}/src/features/sample/constants/sample.constants.js +0 -0
  132. /package/templates/{base → base-js}/src/features/sample/constants/sample.navigations.js +0 -0
  133. /package/templates/{base → base-js}/src/features/sample/constants/sample.queryKeys.js +0 -0
  134. /package/templates/{base → base-js}/src/features/sample/hooks/index.js +0 -0
  135. /package/templates/{base → base-js}/src/features/sample/index.js +0 -0
  136. /package/templates/{base → base-js}/src/features/sample/pages/SamplePage.jsx +0 -0
  137. /package/templates/{base → base-js}/src/features/sample/pages/index.js +0 -0
  138. /package/templates/{base → base-js}/src/features/sample/sample.context.js +0 -0
  139. /package/templates/{base → base-js}/src/features/sample/sample.routes.js +0 -0
  140. /package/templates/{base → base-js}/src/features/welcome/components/CodeLine.jsx +0 -0
  141. /package/templates/{base → base-js}/src/features/welcome/components/Divider.jsx +0 -0
  142. /package/templates/{base → base-js}/src/features/welcome/components/Footer.jsx +0 -0
  143. /package/templates/{base → base-js}/src/features/welcome/components/Hero.jsx +0 -0
  144. /package/templates/{base → base-js}/src/features/welcome/components/IconLink.jsx +0 -0
  145. /package/templates/{base → base-js}/src/features/welcome/components/QuickStartPanel.jsx +0 -0
  146. /package/templates/{base → base-js}/src/features/welcome/components/RingSoft.jsx +0 -0
  147. /package/templates/{base → base-js}/src/features/welcome/components/StorySections.jsx +0 -0
  148. /package/templates/{base → base-js}/src/features/welcome/components/WhatYouGet.jsx +0 -0
  149. /package/templates/{base → base-js}/src/features/welcome/components/index.js +0 -0
  150. /package/templates/{base → base-js}/src/features/welcome/constants/index.js +0 -0
  151. /package/templates/{base → base-js}/src/features/welcome/constants/welcome.constants.js +0 -0
  152. /package/templates/{base → base-js}/src/features/welcome/constants/welcome.navigations.js +0 -0
  153. /package/templates/{base → base-js}/src/features/welcome/index.js +0 -0
  154. /package/templates/{base → base-js}/src/features/welcome/pages/WelcomePage.jsx +0 -0
  155. /package/templates/{base → base-js}/src/features/welcome/pages/index.js +0 -0
  156. /package/templates/{base → base-js}/src/features/welcome/welcome.routes.js +0 -0
  157. /package/templates/{base → base-js}/src/shared/SHARED.md +0 -0
  158. /package/templates/{base → base-js}/src/shared/constants/app.constants.js +0 -0
  159. /package/templates/{base → base-js}/src/shared/constants/assets.constants.js +0 -0
  160. /package/templates/{base → base-js}/src/shared/constants/index.js +0 -0
  161. /package/templates/{base → base-js}/src/shared/contexts/index.js +0 -0
  162. /package/templates/{base → base-js}/src/shared/hooks/index.js +0 -0
  163. /package/templates/{base → base-js}/src/shared/hooks/useBooleanState.js +0 -0
  164. /package/templates/{base → base-js}/src/shared/hooks/useDebounce.js +0 -0
  165. /package/templates/{base → base-js}/src/shared/hooks/useToggleState.js +0 -0
  166. /package/templates/{base → base-js}/src/shared/layouts/index.js +0 -0
  167. /package/templates/{base → base-js}/src/shared/libs/axios.js +0 -0
  168. /package/templates/{base → base-js}/src/shared/libs/cn.js +0 -0
  169. /package/templates/{base → base-js}/src/shared/libs/index.js +0 -0
  170. /package/templates/{base → base-js}/src/shared/theme/index.js +0 -0
  171. /package/templates/{base → base-js}/src/shared/theme/theme.js +0 -0
  172. /package/templates/{base → base-js}/src/shared/ui/Box.jsx +0 -0
  173. /package/templates/{base → base-js}/src/shared/ui/Button.jsx +0 -0
  174. /package/templates/{base → base-js}/src/shared/ui/Checkbox.jsx +0 -0
  175. /package/templates/{base → base-js}/src/shared/ui/DropdownMenu.jsx +0 -0
  176. /package/templates/{base → base-js}/src/shared/ui/Flex.jsx +0 -0
  177. /package/templates/{base → base-js}/src/shared/ui/FlexItem.jsx +0 -0
  178. /package/templates/{base → base-js}/src/shared/ui/FormField.jsx +0 -0
  179. /package/templates/{base → base-js}/src/shared/ui/Grid.jsx +0 -0
  180. /package/templates/{base → base-js}/src/shared/ui/GridItem.jsx +0 -0
  181. /package/templates/{base → base-js}/src/shared/ui/Modal.jsx +0 -0
  182. /package/templates/{base → base-js}/src/shared/ui/Scrollable.jsx +0 -0
  183. /package/templates/{base → base-js}/src/shared/ui/Select.jsx +0 -0
  184. /package/templates/{base → base-js}/src/shared/ui/Sheet.jsx +0 -0
  185. /package/templates/{base → base-js}/src/shared/ui/Text.jsx +0 -0
  186. /package/templates/{base → base-js}/src/shared/ui/Toaster.jsx +0 -0
  187. /package/templates/{base → base-js}/src/shared/ui/index.js +0 -0
  188. /package/templates/{base → base-js}/src/shared/utils/getClassName.js +0 -0
  189. /package/templates/{base → base-js}/src/shared/utils/index.js +0 -0
  190. /package/templates/{base → base-js}/src/shared/utils/localStorage.js +0 -0
  191. /package/templates/{base → base-js}/src/shared/utils/memo.js +0 -0
  192. /package/templates/{base → base-js}/src/shared/utils/motion.js +0 -0
  193. /package/templates/{base → base-js}/src/shared/utils/regix.js +0 -0
  194. /package/templates/{base → base-js}/src/shared/utils/tryCatch.js +0 -0
  195. /package/templates/{base → base-js}/vercel.json +0 -0
  196. /package/templates/{base → base-js}/vite.config.js +0 -0
@@ -0,0 +1,9 @@
1
+ import { ComponentType, ReactNode } from 'react';
2
+
3
+ export interface AppRoute {
4
+ path: string;
5
+ element: ComponentType<any> | ReactNode;
6
+ protected?: boolean;
7
+ layout?: string;
8
+ children?: AppRoute[];
9
+ }
@@ -0,0 +1,5 @@
1
+ export type Breakpoint = 'base' | 'md' | 'lg' | 'xl' | '2xl';
2
+
3
+ export type Responsive<T> = T | Partial<Record<Breakpoint, T>>;
4
+
5
+ export type Axis = 'x' | 'y';
@@ -0,0 +1,153 @@
1
+ import { ComponentPropsWithRef, forwardRef, Ref } from 'react';
2
+ import {
3
+ marginLookup,
4
+ marginMdLookup,
5
+ marginLgLookup,
6
+ marginXLookup,
7
+ marginXMdLookup,
8
+ marginYLookup,
9
+ marginYMdLookup,
10
+ marginYLgLookup,
11
+ paddingLgLookup,
12
+ paddingLookup,
13
+ paddingMdLookup,
14
+ paddingXLgLookup,
15
+ paddingXLookup,
16
+ paddingXMdLookup,
17
+ paddingYLgLookup,
18
+ paddingYLookup,
19
+ paddingYMdLookup,
20
+ widthLookup,
21
+ widthMdLookup,
22
+ widthLgLookup,
23
+ marginXlLookup,
24
+ marginXXlLookup,
25
+ marginYXlLookup,
26
+ paddingXlLookup,
27
+ paddingXXlLookup,
28
+ paddingYXlLookup,
29
+ marginXlgLookup,
30
+ radiusLookup,
31
+ radiusMdLookup,
32
+ radiusLgLookup,
33
+ radiusXlLookup,
34
+ paddingY2XlLookup,
35
+ paddingX2XlLookup,
36
+ } from '../theme';
37
+ import { getClassName, memo } from '../utils';
38
+ import { cn } from '../libs';
39
+ import { Breakpoint } from '../types/ui';
40
+
41
+
42
+ export type Size = keyof typeof marginLookup;
43
+ export type Width = keyof typeof widthLookup;
44
+ export type Radius = keyof typeof radiusLookup;
45
+
46
+ type MarginValue = Size; // They share the same keys
47
+ type PaddingValue = Size;
48
+
49
+ type Axis = 'x' | 'y';
50
+
51
+ type ResponsiveProp<T> = T | Partial<Record<Breakpoint, T>>;
52
+
53
+ type AxisProp<T> = {
54
+ [K in Axis]?: ResponsiveProp<T>;
55
+ };
56
+
57
+ type SpacingProp<T> = ResponsiveProp<T> | AxisProp<T>;
58
+
59
+ export interface BoxProps extends ComponentPropsWithRef<'div'> {
60
+ hide?: boolean | ResponsiveProp<boolean>;
61
+ grow?: boolean | ResponsiveProp<boolean>;
62
+ margin?: SpacingProp<MarginValue>;
63
+ padding?: SpacingProp<PaddingValue>;
64
+ width?: ResponsiveProp<Width>;
65
+ radius?: ResponsiveProp<Radius>;
66
+ }
67
+
68
+ const Component = (
69
+ { hide, grow, margin, radius, padding, width, className, ...rest }: BoxProps,
70
+ ref: Ref<HTMLDivElement>
71
+ ) => {
72
+ // Helper to check if a prop is responsive object (not axis)
73
+
74
+
75
+ // We need to cast props to 'any' sometimes to access properties because TS doesn't know for sure if it's an object
76
+ const m = margin as any;
77
+ const p = padding as any;
78
+ const w = width as any;
79
+ const r = radius as any;
80
+ const h = hide as any;
81
+ const g = grow as any;
82
+
83
+ return (
84
+ <div
85
+ ref={ref}
86
+ className={cn(
87
+ typeof hide !== 'object' && hide === true ? 'hidden' : hide === false && 'block',
88
+ h?.base === true ? 'hidden' : h?.base === false && 'block',
89
+ h?.md === true ? 'md:hidden' : h?.md === false && 'md:block',
90
+ h?.lg === true ? 'lg:hidden' : h?.lg === false && 'lg:block',
91
+ typeof grow !== 'object' && grow === true ? 'h-full' : grow === false && 'h-auto',
92
+ g?.base === true ? 'h-full' : g?.base === false && 'h-auto',
93
+ g?.md === true ? 'md:h-full' : g?.md === false && 'md:h-auto',
94
+ g?.lg === true ? 'lg:h-full' : g?.lg === false && 'lg:h-auto',
95
+
96
+ typeof margin !== 'object' && getClassName(margin, marginLookup),
97
+ getClassName(m?.base, marginLookup),
98
+ getClassName(m?.md, marginMdLookup),
99
+ getClassName(m?.lg, marginLgLookup),
100
+ getClassName(m?.xl, marginXlLookup),
101
+
102
+ typeof m?.x !== 'object' && getClassName(m?.x, marginXLookup),
103
+ getClassName(m?.x?.base, marginXLookup),
104
+ getClassName(m?.x?.md, marginXMdLookup),
105
+ getClassName(m?.x?.lg, marginXlgLookup),
106
+ getClassName(m?.x?.xl, marginXXlLookup),
107
+
108
+ typeof m?.y !== 'object' && getClassName(m?.y, marginYLookup),
109
+ getClassName(m?.y?.base, marginYLookup),
110
+ getClassName(m?.y?.md, marginYMdLookup),
111
+ getClassName(m?.y?.lg, marginYLgLookup),
112
+ getClassName(m?.y?.xl, marginYXlLookup),
113
+
114
+ typeof padding !== 'object' && getClassName(padding, paddingLookup),
115
+ getClassName(p?.base, paddingLookup),
116
+ getClassName(p?.md, paddingMdLookup),
117
+ getClassName(p?.lg, paddingLgLookup),
118
+ getClassName(p?.xl, paddingXlLookup),
119
+ getClassName(p?.['2xl'], paddingXlLookup),
120
+
121
+ typeof p?.x !== 'object' && getClassName(p?.x, paddingXLookup),
122
+ getClassName(p?.x?.base, paddingXLookup),
123
+ getClassName(p?.x?.md, paddingXMdLookup),
124
+ getClassName(p?.x?.lg, paddingXLgLookup),
125
+ getClassName(p?.x?.xl, paddingXXlLookup),
126
+ getClassName(p?.x?.['2xl'], paddingX2XlLookup),
127
+
128
+ typeof p?.y !== 'object' && getClassName(p?.y, paddingYLookup),
129
+ getClassName(p?.y?.base, paddingYLookup),
130
+ getClassName(p?.y?.md, paddingYMdLookup),
131
+ getClassName(p?.y?.lg, paddingYLgLookup),
132
+ getClassName(p?.y?.xl, paddingYXlLookup),
133
+ getClassName(p?.y?.['2xl'], paddingY2XlLookup),
134
+
135
+ typeof width !== 'object' && getClassName(width, widthLookup),
136
+ getClassName(w?.base, widthLookup),
137
+ getClassName(w?.md, widthMdLookup),
138
+ getClassName(w?.lg, widthLgLookup),
139
+
140
+ typeof radius !== 'object' && getClassName(radius, radiusLookup),
141
+ getClassName(r?.base, radiusLookup),
142
+ getClassName(r?.md, radiusMdLookup),
143
+ getClassName(r?.lg, radiusLgLookup),
144
+ getClassName(r?.xl, radiusXlLookup),
145
+
146
+ className
147
+ )}
148
+ {...rest}
149
+ />
150
+ );
151
+ };
152
+
153
+ export const Box = memo(forwardRef(Component));
@@ -0,0 +1,124 @@
1
+ import { ComponentPropsWithRef, forwardRef, Ref } from 'react';
2
+ import { PiSpinnerBold } from 'react-icons/pi';
3
+ import {
4
+ colorLookup,
5
+ fieldSize2XlLookup,
6
+ fieldSizeLgLookup,
7
+ fieldSizeLookup,
8
+ fieldSizeMdLookup,
9
+ fieldSizeXlLookup,
10
+ fontFamilyLookup,
11
+ fontSize2xlLookup,
12
+ fontSizeLgLookup,
13
+ fontSizeLookup,
14
+ fontSizeMdLookup,
15
+ fontSizeXlLookup,
16
+ fontWeight2xlLookup,
17
+ fontWeightLgLookup,
18
+ fontWeightLookup,
19
+ fontWeightMdLookup,
20
+ fontWeightXlLookup,
21
+ radiusLgLookup,
22
+ radiusLookup,
23
+ radiusMdLookup,
24
+ radiusXlLookup,
25
+ } from '../theme';
26
+ import { getClassName, memo } from '../utils';
27
+ import { cn } from '../libs';
28
+ import { Responsive } from '../types/ui';
29
+
30
+ const variantLookup = {
31
+ primary:
32
+ 'text-primary-foreground bg-primary hover:bg-primary/90 disabled:text-primary-foreground/70 disabled:bg-primary/50',
33
+ outline:
34
+ 'border text-primary bg-primary-foreground hover:bg-neutral-50 disabled:text-primary/70 disabled:bg-neutral-50/50',
35
+ pill: 'text-primary-foreground bg-primary hover:bg-primary/90 disabled:text-primary-foreground/70 disabled:bg-primary/50',
36
+ };
37
+
38
+ export type Variant = keyof typeof variantLookup;
39
+ export type ButtonSize = keyof typeof fieldSizeLookup;
40
+ export type Font = keyof typeof fontFamilyLookup;
41
+ export type ButtonColor = keyof typeof colorLookup;
42
+ export type Radius = keyof typeof radiusLookup;
43
+ export type Weight = keyof typeof fontWeightLookup;
44
+ export type FontSize = keyof typeof fontSizeLookup;
45
+
46
+ export interface ButtonProps extends ComponentPropsWithRef<'button'> {
47
+ variant?: Variant;
48
+ radius?: Radius | Responsive<Radius>;
49
+ size?: ButtonSize | Responsive<ButtonSize>;
50
+ font?: Font | Responsive<Font>;
51
+ fontSize?: FontSize | Responsive<FontSize>;
52
+ weight?: Weight | Responsive<Weight>;
53
+ isLoading?: boolean;
54
+ color?: ButtonColor;
55
+ }
56
+
57
+ const Component = (
58
+ {
59
+ variant = 'primary',
60
+ radius = 'lg',
61
+ size = 'lg',
62
+ font = 'inter',
63
+ fontSize = 'base',
64
+ weight = 'semibold',
65
+ color,
66
+ isLoading,
67
+ className,
68
+ type = 'button',
69
+ children,
70
+ ...rest
71
+ }: ButtonProps,
72
+ ref: Ref<HTMLButtonElement>
73
+ ) => {
74
+ const fs = fontSize as any;
75
+ const w = weight as any;
76
+ const s = size as any;
77
+ const r = radius as any;
78
+
79
+ return (
80
+ <button
81
+ ref={ref}
82
+ className={cn(
83
+ 'h-14 px-8 inline-flex w-full items-center justify-center gap-2 transition-colors disabled:cursor-not-allowed text-primary-foreground cursor-pointer!',
84
+ 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/30',
85
+ typeof fontSize !== 'object' && getClassName(fontSize, fontSizeLookup),
86
+ getClassName(fs?.base, fontSizeLookup),
87
+ getClassName(fs?.md, fontSizeMdLookup),
88
+ getClassName(fs?.lg, fontSizeLgLookup),
89
+ getClassName(fs?.xl, fontSizeXlLookup),
90
+ getClassName(fs?.['2xl'], fontSize2xlLookup),
91
+ typeof weight !== 'object' && getClassName(weight, fontWeightLookup),
92
+ getClassName(w?.base, fontWeightLookup),
93
+ getClassName(w?.md, fontWeightMdLookup),
94
+ getClassName(w?.lg, fontWeightLgLookup),
95
+ getClassName(w?.xl, fontWeightXlLookup),
96
+ getClassName(w?.['2xl'], fontWeight2xlLookup),
97
+ typeof size !== 'object' && getClassName(size, fieldSizeLookup),
98
+ getClassName(s?.base, fieldSizeLookup),
99
+ getClassName(s?.md, fieldSizeMdLookup),
100
+ getClassName(s?.lg, fieldSizeLgLookup),
101
+ getClassName(s?.xl, fieldSizeXlLookup),
102
+ getClassName(s?.['2xl'], fieldSize2XlLookup),
103
+ typeof radius !== 'object' && getClassName(radius, radiusLookup),
104
+ getClassName(r?.base, radiusLookup),
105
+ getClassName(r?.md, radiusMdLookup),
106
+ getClassName(r?.lg, radiusLgLookup),
107
+ getClassName(r?.xl, radiusXlLookup),
108
+ variantLookup[variant],
109
+ fontFamilyLookup[font as Font], // Cast needed if font is responsive, but here it seems simple. Wait, original component had responsive fonts? No, JSDoc says Font is just string. But Box does support responsive.
110
+ // Checking original: font={...} is passed to getClassName(font, ...) in Text, but here it is passed directly: fontFamilyLookup[font].
111
+ // So in Button, font is NOT responsive in the original code.
112
+ color && colorLookup[color],
113
+ className
114
+ )}
115
+ type={type}
116
+ {...(isLoading && { disabled: true })}
117
+ {...rest}
118
+ >
119
+ {isLoading ? <PiSpinnerBold className="animate-spin size-5 m-auto" /> : children}
120
+ </button>
121
+ );
122
+ };
123
+
124
+ export const Button = memo(forwardRef(Component));
@@ -0,0 +1,87 @@
1
+ import { ComponentPropsWithRef, ReactNode, useId } from 'react';
2
+ import {
3
+ sizeLookup,
4
+ sizeMdLookup,
5
+ sizeLgLookup,
6
+ fontSizeLookup,
7
+ fontSizeMdLookup,
8
+ fontSizeLgLookup,
9
+ fontWeightLookup,
10
+ fontWeightMdLookup,
11
+ fontWeightLgLookup,
12
+ } from '../theme';
13
+ import { getClassName, memo } from '../utils';
14
+ import { cn } from '../libs';
15
+ import { Responsive } from '../types/ui';
16
+
17
+ export type CheckboxSize = keyof typeof sizeLookup;
18
+ export type LabelFontSize = keyof typeof fontSizeLookup;
19
+ export type LabelFontWeight = keyof typeof fontWeightLookup;
20
+
21
+ export interface CheckboxProps extends Omit<ComponentPropsWithRef<'input'>, 'size'> {
22
+ label?: ReactNode;
23
+ labelClass?: string;
24
+ checkClass?: string;
25
+ size?: CheckboxSize | Responsive<CheckboxSize>;
26
+ labelFontSize?: LabelFontSize | Responsive<LabelFontSize>;
27
+ labelFontWeight?: LabelFontWeight | Responsive<LabelFontWeight>;
28
+ }
29
+
30
+ const Component = ({
31
+ label,
32
+ disabled = false,
33
+ className = '',
34
+ labelClass,
35
+ checkClass,
36
+ onChange,
37
+ size = { base: 4, md: 5 } as any, // Default value type casting
38
+ labelFontSize = { base: 'xs', md: 'sm', lg: 'base' } as any,
39
+ labelFontWeight,
40
+ ...rest
41
+ }: CheckboxProps) => {
42
+ const id = useId();
43
+ const s = size as any;
44
+ const lfs = labelFontSize as any;
45
+ const lfw = labelFontWeight as any;
46
+
47
+ return (
48
+ <div className={cn('flex items-center gap-2', className)}>
49
+ <input
50
+ type="checkbox"
51
+ disabled={disabled}
52
+ onChange={onChange}
53
+ className={cn(
54
+ ' border border-tertiary checked:bg-primary accent-primary transition-colors duration-200',
55
+ typeof size !== 'object' && getClassName(size, sizeLookup),
56
+ disabled && 'cursor-not-allowed bg-opacity-60',
57
+ getClassName(s?.base, sizeLookup),
58
+ getClassName(s?.md, sizeMdLookup),
59
+ getClassName(s?.lg, sizeLgLookup),
60
+ checkClass
61
+ )}
62
+ id={id}
63
+ {...rest}
64
+ />
65
+ <label
66
+ htmlFor={id}
67
+ className={cn(
68
+ 'text-secondary font-inter',
69
+ disabled && 'opacity-50 cursor-not-allowed',
70
+ typeof labelFontSize !== 'object' && getClassName(labelFontSize, fontSizeLookup),
71
+ getClassName(lfs?.base, fontSizeLookup),
72
+ getClassName(lfs?.md, fontSizeMdLookup),
73
+ getClassName(lfs?.lg, fontSizeLgLookup),
74
+ typeof labelFontWeight !== 'object' && getClassName(labelFontWeight, fontWeightLookup),
75
+ getClassName(lfw?.base, fontWeightLookup),
76
+ getClassName(lfw?.md, fontWeightMdLookup),
77
+ getClassName(lfw?.lg, fontWeightLgLookup),
78
+ labelClass
79
+ )}
80
+ >
81
+ {label}
82
+ </label>
83
+ </div>
84
+ );
85
+ };
86
+
87
+ export const Checkbox = memo(Component);
@@ -0,0 +1,134 @@
1
+ import { ComponentPropsWithoutRef, ElementRef, forwardRef, ReactNode } from 'react';
2
+ import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
3
+ import { FaChevronRight } from 'react-icons/fa';
4
+ import { memo } from '../utils';
5
+ import { cn } from '../libs';
6
+
7
+ const DropdownMenuRoot = DropdownMenuPrimitive.Root;
8
+
9
+ const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
10
+
11
+ const DropdownMenuSubTrigger = forwardRef<
12
+ ElementRef<typeof DropdownMenuPrimitive.SubTrigger>,
13
+ ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubTrigger> & {
14
+ inset?: boolean;
15
+ }
16
+ >(({ className, inset, children, ...props }, ref) => (
17
+ <DropdownMenuPrimitive.SubTrigger
18
+ ref={ref}
19
+ className={cn(
20
+ 'flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0',
21
+ inset && 'pl-8',
22
+ className
23
+ )}
24
+ {...props}
25
+ >
26
+ {children}
27
+ <FaChevronRight className="ml-auto" />
28
+ </DropdownMenuPrimitive.SubTrigger>
29
+ ));
30
+ DropdownMenuSubTrigger.displayName = DropdownMenuPrimitive.SubTrigger.displayName;
31
+
32
+ const DropdownMenuSubContent = forwardRef<
33
+ ElementRef<typeof DropdownMenuPrimitive.SubContent>,
34
+ ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubContent>
35
+ >(({ className, ...props }, ref) => (
36
+ <DropdownMenuPrimitive.SubContent
37
+ ref={ref}
38
+ className={cn(
39
+ 'z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2',
40
+ className
41
+ )}
42
+ {...props}
43
+ />
44
+ ));
45
+ DropdownMenuSubContent.displayName = DropdownMenuPrimitive.SubContent.displayName;
46
+
47
+ const DropdownMenuContent = forwardRef<
48
+ ElementRef<typeof DropdownMenuPrimitive.Content>,
49
+ ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content> & {
50
+ contentClassName?: string;
51
+ }
52
+ >(({ className, sideOffset = 4, contentClassName, ...props }, ref) => (
53
+ <DropdownMenuPrimitive.Portal>
54
+ <DropdownMenuPrimitive.Content
55
+ ref={ref}
56
+ sideOffset={sideOffset}
57
+ className={cn(
58
+ 'z-50 min-w-[8rem] overflow-hidden rounded-lg border bg-popover p-1 text-popover-foreground shadow',
59
+ 'data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2',
60
+ className,
61
+ contentClassName
62
+ )}
63
+ {...props}
64
+ />
65
+ </DropdownMenuPrimitive.Portal>
66
+ ));
67
+ DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName;
68
+
69
+ const DropdownMenuItem = forwardRef<
70
+ ElementRef<typeof DropdownMenuPrimitive.Item>,
71
+ ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item> & {
72
+ inset?: boolean;
73
+ }
74
+ >(({ className, inset, ...props }, ref) => (
75
+ <DropdownMenuPrimitive.Item
76
+ ref={ref}
77
+ className={cn(
78
+ 'relative flex select-none items-center gap-2 font-inter cursor-pointer rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>svg]:size-4 [&>svg]:shrink-0',
79
+ inset && 'pl-8',
80
+ className
81
+ )}
82
+ {...props}
83
+ />
84
+ ));
85
+ DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName;
86
+
87
+ const DropdownMenuLabel = forwardRef<
88
+ ElementRef<typeof DropdownMenuPrimitive.Label>,
89
+ ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Label> & {
90
+ inset?: boolean;
91
+ }
92
+ >(({ className, inset, ...props }, ref) => (
93
+ <DropdownMenuPrimitive.Label
94
+ ref={ref}
95
+ className={cn('px-2 py-1.5 text-sm font-semibold font-inter', inset && 'pl-8', className)}
96
+ {...props}
97
+ />
98
+ ));
99
+ DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName;
100
+
101
+ const DropdownMenuSeparator = forwardRef<
102
+ ElementRef<typeof DropdownMenuPrimitive.Separator>,
103
+ ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Separator>
104
+ >(({ className, ...props }, ref) => (
105
+ <DropdownMenuPrimitive.Separator
106
+ ref={ref}
107
+ className={cn('-mx-1 my-1 h-px bg-muted', className)}
108
+ {...props}
109
+ />
110
+ ));
111
+ DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName;
112
+
113
+ export interface DropdownMenuProps {
114
+ open?: boolean;
115
+ onOpenChange?: (open: boolean) => void;
116
+ content: ReactNode;
117
+ contentClassName?: string;
118
+ children?: ReactNode;
119
+ }
120
+
121
+ const Component = ({ open, onOpenChange, content, children, contentClassName }: DropdownMenuProps) => {
122
+ return (
123
+ <DropdownMenuRoot modal={false} open={open} onOpenChange={onOpenChange}>
124
+ <DropdownMenuTrigger className="w-full">{children}</DropdownMenuTrigger>
125
+ <DropdownMenuContent align="end" contentClassName={contentClassName}>
126
+ {content}
127
+ </DropdownMenuContent>
128
+ </DropdownMenuRoot>
129
+ );
130
+ };
131
+
132
+ const DropdownMenu = memo(Component);
133
+
134
+ export { DropdownMenu, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuItem };
@@ -0,0 +1,96 @@
1
+ import { ComponentPropsWithRef, forwardRef, Ref } from 'react';
2
+ import {
3
+ gapLookup,
4
+ gapMdLookup,
5
+ gapLgLookup,
6
+ directionLookup,
7
+ directionMdLookup,
8
+ directionLgLookup,
9
+ justifyLookup,
10
+ justifyMdLookup,
11
+ justifyLgLookup,
12
+ alignLookup,
13
+ alignMdLookup,
14
+ alignLgLookup,
15
+ widthLookup,
16
+ widthMdLookup,
17
+ widthLgLookup,
18
+ gapXlLookup,
19
+ directionXlLookup,
20
+ justifyXlLookup,
21
+ alignXlLookup,
22
+ widthXlLookup,
23
+ gap2XlLookup,
24
+ width2XlLookup,
25
+ } from '../theme';
26
+ import { cn } from '../libs';
27
+ import { getClassName, memo } from '../utils';
28
+ import { Responsive } from '../types/ui';
29
+
30
+ export type Gap = keyof typeof gapLookup;
31
+ export type Direction = keyof typeof directionLookup;
32
+ export type Justify = keyof typeof justifyLookup;
33
+ export type Align = keyof typeof alignLookup;
34
+ export type Width = keyof typeof widthLookup;
35
+
36
+ export interface FlexProps extends ComponentPropsWithRef<'div'> {
37
+ grow?: boolean | Responsive<boolean>;
38
+ gap?: Gap | Responsive<Gap>;
39
+ direction?: Direction | Responsive<Direction>;
40
+ justify?: Justify | Responsive<Justify>;
41
+ align?: Align | Responsive<Align>;
42
+ width?: Width | Responsive<Width>;
43
+ }
44
+
45
+ const Component = ({ grow, gap, direction, justify, align, width, className, ...rest }: FlexProps, ref: Ref<HTMLDivElement>) => {
46
+ const g = grow as any;
47
+ const gp = gap as any;
48
+ const d = direction as any;
49
+ const j = justify as any;
50
+ const a = align as any;
51
+ const w = width as any;
52
+
53
+ return (
54
+ <div
55
+ ref={ref}
56
+ className={cn(
57
+ 'flex',
58
+ typeof grow !== 'object' && grow === true ? 'h-full' : grow === false && 'h-auto',
59
+ g?.base === true ? 'h-full' : g?.base === false && 'h-auto',
60
+ g?.md === true ? 'md:h-full' : g?.md === false && 'md:h-auto',
61
+ g?.lg === true ? 'lg:h-full' : g?.lg === false && 'lg:h-auto',
62
+ typeof gap !== 'object' && getClassName(gap, gapLookup),
63
+ getClassName(gp?.base, gapLookup),
64
+ getClassName(gp?.md, gapMdLookup),
65
+ getClassName(gp?.lg, gapLgLookup),
66
+ getClassName(gp?.xl, gapXlLookup),
67
+ getClassName(gp?.['2xl'], gap2XlLookup),
68
+ typeof direction !== 'object' && getClassName(direction, directionLookup),
69
+ getClassName(d?.base, directionLookup),
70
+ getClassName(d?.md, directionMdLookup),
71
+ getClassName(d?.lg, directionLgLookup),
72
+ getClassName(d?.xl, directionXlLookup),
73
+ typeof justify !== 'object' && getClassName(justify, justifyLookup),
74
+ getClassName(j?.base, justifyLookup),
75
+ getClassName(j?.md, justifyMdLookup),
76
+ getClassName(j?.lg, justifyLgLookup),
77
+ getClassName(j?.xl, justifyXlLookup),
78
+ typeof align !== 'object' && getClassName(align, alignLookup),
79
+ getClassName(a?.base, alignLookup),
80
+ getClassName(a?.md, alignMdLookup),
81
+ getClassName(a?.lg, alignLgLookup),
82
+ getClassName(a?.xl, alignXlLookup),
83
+ typeof width !== 'object' && getClassName(width, widthLookup),
84
+ getClassName(w?.base, widthLookup),
85
+ getClassName(w?.md, widthMdLookup),
86
+ getClassName(w?.lg, widthLgLookup),
87
+ getClassName(w?.xl, widthXlLookup),
88
+ getClassName(w?.['2xl'], width2XlLookup),
89
+ className
90
+ )}
91
+ {...rest}
92
+ />
93
+ );
94
+ };
95
+
96
+ export const Flex = memo(forwardRef(Component));
@@ -0,0 +1,67 @@
1
+ import { ComponentPropsWithRef, forwardRef, Ref } from 'react';
2
+ import {
3
+ growLookup,
4
+ growMdLookup,
5
+ growLgLookup,
6
+ alignSelfLookup,
7
+ alignSelfMdLookup,
8
+ alignSelfLgLookup,
9
+ widthLookup,
10
+ widthMdLookup,
11
+ widthLgLookup,
12
+ growXlLookup,
13
+ alignSelfXlLookup,
14
+ widthXlLookup,
15
+ } from '../theme';
16
+ import { getClassName, memo } from '../utils';
17
+ import { cn } from '../libs';
18
+ import { Responsive } from '../types/ui';
19
+
20
+ export type Grow = keyof typeof growLookup;
21
+ export type AlignSelf = keyof typeof alignSelfLookup;
22
+ export type Width = keyof typeof widthLookup;
23
+
24
+ export interface FlexItemProps extends ComponentPropsWithRef<'div'> {
25
+ hide?: boolean | Responsive<boolean>;
26
+ grow?: Grow | Responsive<Grow>;
27
+ width?: Width | Responsive<Width>;
28
+ alignSelf?: AlignSelf | Responsive<AlignSelf>;
29
+ }
30
+
31
+ const Component = ({ hide, grow, alignSelf, width, className, ...rest }: FlexItemProps, ref: Ref<HTMLDivElement>) => {
32
+ const h = hide as any;
33
+ const g = grow as any;
34
+ const as = alignSelf as any;
35
+ const w = width as any;
36
+
37
+ return (
38
+ <div
39
+ ref={ref}
40
+ className={cn(
41
+ typeof hide !== 'object' && hide === true ? 'hidden' : hide === false && 'block',
42
+ h?.base === true ? 'hidden' : h?.base === false && 'block',
43
+ h?.md === true ? 'md:hidden' : h?.md === false && 'md:block',
44
+ h?.lg === true ? 'lg:hidden' : h?.lg === false && 'lg:block',
45
+ typeof grow !== 'object' && getClassName(grow, growLookup),
46
+ getClassName(g?.base, growLookup),
47
+ getClassName(g?.md, growMdLookup),
48
+ getClassName(g?.lg, growLgLookup),
49
+ getClassName(g?.xl, growXlLookup),
50
+ typeof alignSelf !== 'object' && getClassName(alignSelf, alignSelfLookup),
51
+ getClassName(as?.base, alignSelfLookup),
52
+ getClassName(as?.md, alignSelfMdLookup),
53
+ getClassName(as?.lg, alignSelfLgLookup),
54
+ getClassName(as?.xl, alignSelfXlLookup),
55
+ typeof width !== 'object' && getClassName(width, widthLookup),
56
+ getClassName(w?.base, widthLookup),
57
+ getClassName(w?.md, widthMdLookup),
58
+ getClassName(w?.lg, widthLgLookup),
59
+ getClassName(w?.xl, widthXlLookup),
60
+ className
61
+ )}
62
+ {...rest}
63
+ />
64
+ );
65
+ };
66
+
67
+ export const FlexItem = memo(forwardRef(Component));