create-react-scaffold-cli 0.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.
- package/bin/index.js +34 -0
- package/package.json +15 -0
- package/scripts/createProject.js +30 -0
- package/templates/base/.env +1 -0
- package/templates/base/.husky/pre-commit +1 -0
- package/templates/base/.husky/pre-push +0 -0
- package/templates/base/.prettierrc +8 -0
- package/templates/base/.vscode/extensions.json +8 -0
- package/templates/base/.vscode/settings.json +16 -0
- package/templates/base/eslint.config.js +48 -0
- package/templates/base/index.html +16 -0
- package/templates/base/jsconfig.json +7 -0
- package/templates/base/package.json +64 -0
- package/templates/base/postcss.config.mjs +7 -0
- package/templates/base/readme.md +97 -0
- package/templates/base/src/app/App.jsx +13 -0
- package/templates/base/src/app/Router.jsx +4 -0
- package/templates/base/src/app/app_readme.md +74 -0
- package/templates/base/src/app/index.css +1 -0
- package/templates/base/src/app/main.jsx +10 -0
- package/templates/base/src/app/middlewares/index.js +0 -0
- package/templates/base/src/app/providers/QueryProvider.jsx +75 -0
- package/templates/base/src/app/providers/index.js +1 -0
- package/templates/base/src/features/features_readme.md +102 -0
- package/templates/base/src/features/index.js +0 -0
- package/templates/base/src/features/sample/components/index.js +0 -0
- package/templates/base/src/features/sample/constants/index.js +0 -0
- package/templates/base/src/features/sample/constants/sample.constants.js +0 -0
- package/templates/base/src/features/sample/hooks/index.js +0 -0
- package/templates/base/src/features/sample/pages/index.js +0 -0
- package/templates/base/src/features/sample/sample.assets.js +0 -0
- package/templates/base/src/features/sample/sample.context.js +0 -0
- package/templates/base/src/features/sample/sample.navigations.js +0 -0
- package/templates/base/src/features/sample/sample.queryKeys.js +0 -0
- package/templates/base/src/features/sample/sample.routes.jsx +0 -0
- package/templates/base/src/shared/constants/app.constants.js +4 -0
- package/templates/base/src/shared/constants/assets.constants.js +0 -0
- package/templates/base/src/shared/constants/index.js +0 -0
- package/templates/base/src/shared/contexts/index.js +0 -0
- package/templates/base/src/shared/hooks/index.js +3 -0
- package/templates/base/src/shared/hooks/useBooleanState.js +19 -0
- package/templates/base/src/shared/hooks/useDebounce.js +17 -0
- package/templates/base/src/shared/hooks/useToggleState.js +11 -0
- package/templates/base/src/shared/layouts/index.js +0 -0
- package/templates/base/src/shared/libs/axios.js +6 -0
- package/templates/base/src/shared/libs/cn.js +7 -0
- package/templates/base/src/shared/libs/index.js +2 -0
- package/templates/base/src/shared/shared_readme.md +98 -0
- package/templates/base/src/shared/theme/index.js +1 -0
- package/templates/base/src/shared/theme/theme.js +2138 -0
- package/templates/base/src/shared/ui/Box.jsx +200 -0
- package/templates/base/src/shared/ui/Button.jsx +150 -0
- package/templates/base/src/shared/ui/Checkbox.jsx +112 -0
- package/templates/base/src/shared/ui/DropdownMenu.jsx +152 -0
- package/templates/base/src/shared/ui/Flex.jsx +151 -0
- package/templates/base/src/shared/ui/FlexItem.jsx +96 -0
- package/templates/base/src/shared/ui/FormField.jsx +184 -0
- package/templates/base/src/shared/ui/Grid.jsx +151 -0
- package/templates/base/src/shared/ui/GridItem.jsx +95 -0
- package/templates/base/src/shared/ui/Modal.jsx +43 -0
- package/templates/base/src/shared/ui/Scrollable.jsx +47 -0
- package/templates/base/src/shared/ui/Select.jsx +207 -0
- package/templates/base/src/shared/ui/Sheet.jsx +112 -0
- package/templates/base/src/shared/ui/Text.jsx +122 -0
- package/templates/base/src/shared/ui/Toaster.jsx +31 -0
- package/templates/base/src/shared/ui/index.js +1 -0
- package/templates/base/src/shared/utils/getClassName.js +5 -0
- package/templates/base/src/shared/utils/index.js +4 -0
- package/templates/base/src/shared/utils/memo.js +3 -0
- package/templates/base/src/shared/utils/parser.js +41 -0
- package/templates/base/src/shared/utils/tryCatch.js +13 -0
- package/templates/base/vite.config.js +19 -0
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import React 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
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @typedef {'base' | 'md' | 'lg' | 'xl' | '2xl'} Breakpoint
|
|
31
|
+
*
|
|
32
|
+
* @typedef {0
|
|
33
|
+
* | 0.5
|
|
34
|
+
* | 1
|
|
35
|
+
* | 1.5
|
|
36
|
+
* | 2
|
|
37
|
+
* | 2.5
|
|
38
|
+
* | 3
|
|
39
|
+
* | 3.5
|
|
40
|
+
* | 4
|
|
41
|
+
* | 5
|
|
42
|
+
* | 6
|
|
43
|
+
* | 7
|
|
44
|
+
* | 8
|
|
45
|
+
* | 9
|
|
46
|
+
* | 10
|
|
47
|
+
* | 11
|
|
48
|
+
* | 12
|
|
49
|
+
* | 14
|
|
50
|
+
* | 16
|
|
51
|
+
* | 20
|
|
52
|
+
* | 24
|
|
53
|
+
* | 28
|
|
54
|
+
* | 32
|
|
55
|
+
* | 36
|
|
56
|
+
* | 40} Gap
|
|
57
|
+
*
|
|
58
|
+
*
|
|
59
|
+
* @typedef {'normal' | 'start' | 'end' | 'center' | 'between' | 'around' | 'evenly' | 'stretch'} Justify
|
|
60
|
+
*
|
|
61
|
+
*
|
|
62
|
+
* @typedef {0
|
|
63
|
+
* | 0.5
|
|
64
|
+
* | 1
|
|
65
|
+
* | 1.5
|
|
66
|
+
* | 2
|
|
67
|
+
* | 2.5
|
|
68
|
+
* | 3
|
|
69
|
+
* | 3.5
|
|
70
|
+
* | 4
|
|
71
|
+
* | 5
|
|
72
|
+
* | 6
|
|
73
|
+
* | 7
|
|
74
|
+
* | 8
|
|
75
|
+
* | 9
|
|
76
|
+
* | 10
|
|
77
|
+
* | 11
|
|
78
|
+
* | 12
|
|
79
|
+
* | 14
|
|
80
|
+
* | 16
|
|
81
|
+
* | 20
|
|
82
|
+
* | 24
|
|
83
|
+
* | 28
|
|
84
|
+
* | 32
|
|
85
|
+
* | 36
|
|
86
|
+
* | 40
|
|
87
|
+
* | fit
|
|
88
|
+
* | full
|
|
89
|
+
* | auto} Width
|
|
90
|
+
*
|
|
91
|
+
*
|
|
92
|
+
* @typedef {'start' | 'end' | 'center' | 'baseline' | 'stretch'} Align
|
|
93
|
+
*
|
|
94
|
+
* @typedef {'row' | 'rowReverse' | 'column' | 'columnReverse'} Direction
|
|
95
|
+
*
|
|
96
|
+
* @typedef {object} ComponentProps
|
|
97
|
+
* @property {boolean | Record<Breakpoint, boolean>} [grow]
|
|
98
|
+
* @property {Gap | Record<Breakpoint, Gap>} [gap]
|
|
99
|
+
* @property {Direction | Record<Breakpoint, Direction>} [direction]
|
|
100
|
+
* @property {Justify | Record<Breakpoint, Justify>} [justify]
|
|
101
|
+
* @property {Align | Record<Breakpoint, Align>} [align]
|
|
102
|
+
* @property {Width | Record<Breakpoint, Width>} [width]
|
|
103
|
+
* @param {React.ComponentProps<'div'> & ComponentProps} props
|
|
104
|
+
* @returns {JSX.Element}
|
|
105
|
+
*/
|
|
106
|
+
|
|
107
|
+
const Component = ({ grow, gap, direction, justify, align, width, className, ...rest }, ref) => {
|
|
108
|
+
return (
|
|
109
|
+
<div
|
|
110
|
+
ref={ref}
|
|
111
|
+
className={cn(
|
|
112
|
+
'flex',
|
|
113
|
+
typeof grow !== 'object' && grow === true ? 'h-full' : grow === false && 'h-auto',
|
|
114
|
+
grow?.base === true ? 'h-full' : grow?.base === false && 'h-auto',
|
|
115
|
+
grow?.md === true ? 'md:h-full' : grow?.md === false && 'md:h-auto',
|
|
116
|
+
grow?.lg === true ? 'lg:h-full' : grow?.lg === false && 'lg:h-auto',
|
|
117
|
+
typeof gap !== 'object' && getClassName(gap, gapLookup),
|
|
118
|
+
getClassName(gap?.base, gapLookup),
|
|
119
|
+
getClassName(gap?.md, gapMdLookup),
|
|
120
|
+
getClassName(gap?.lg, gapLgLookup),
|
|
121
|
+
getClassName(gap?.xl, gapXlLookup),
|
|
122
|
+
getClassName(gap?.['2xl'], gap2XlLookup),
|
|
123
|
+
typeof direction !== 'object' && getClassName(direction, directionLookup),
|
|
124
|
+
getClassName(direction?.base, directionLookup),
|
|
125
|
+
getClassName(direction?.md, directionMdLookup),
|
|
126
|
+
getClassName(direction?.lg, directionLgLookup),
|
|
127
|
+
getClassName(direction?.xl, directionXlLookup),
|
|
128
|
+
typeof justify !== 'object' && getClassName(justify, justifyLookup),
|
|
129
|
+
getClassName(justify?.base, justifyLookup),
|
|
130
|
+
getClassName(justify?.md, justifyMdLookup),
|
|
131
|
+
getClassName(justify?.lg, justifyLgLookup),
|
|
132
|
+
getClassName(justify?.xl, justifyXlLookup),
|
|
133
|
+
typeof align !== 'object' && getClassName(align, alignLookup),
|
|
134
|
+
getClassName(align?.base, alignLookup),
|
|
135
|
+
getClassName(align?.md, alignMdLookup),
|
|
136
|
+
getClassName(align?.lg, alignLgLookup),
|
|
137
|
+
getClassName(align?.xl, alignXlLookup),
|
|
138
|
+
typeof width !== 'object' && getClassName(width, widthLookup),
|
|
139
|
+
getClassName(width?.base, widthLookup),
|
|
140
|
+
getClassName(width?.md, widthMdLookup),
|
|
141
|
+
getClassName(width?.lg, widthLgLookup),
|
|
142
|
+
getClassName(width?.xl, widthXlLookup),
|
|
143
|
+
getClassName(width?.['2xl'], width2XlLookup),
|
|
144
|
+
className
|
|
145
|
+
)}
|
|
146
|
+
{...rest}
|
|
147
|
+
/>
|
|
148
|
+
);
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
export const Flex = memo(React.forwardRef(Component));
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import React 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
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @typedef {'base' | 'md' | 'lg' | 'xl'} Breakpoint
|
|
21
|
+
*
|
|
22
|
+
* @typedef {'auto' | 'start' | 'end' | 'center' | 'baseline' | 'stretch'} AlignSelf
|
|
23
|
+
*
|
|
24
|
+
* @typedef {0
|
|
25
|
+
* | 0.5
|
|
26
|
+
* | 1
|
|
27
|
+
* | 1.5
|
|
28
|
+
* | 2
|
|
29
|
+
* | 2.5
|
|
30
|
+
* | 3
|
|
31
|
+
* | 3.5
|
|
32
|
+
* | 4
|
|
33
|
+
* | 5
|
|
34
|
+
* | 6
|
|
35
|
+
* | 7
|
|
36
|
+
* | 8
|
|
37
|
+
* | 9
|
|
38
|
+
* | 10
|
|
39
|
+
* | 11
|
|
40
|
+
* | 12
|
|
41
|
+
* | 14
|
|
42
|
+
* | 16
|
|
43
|
+
* | 20
|
|
44
|
+
* | 24
|
|
45
|
+
* | 28
|
|
46
|
+
* | 32
|
|
47
|
+
* | 36
|
|
48
|
+
* | 40
|
|
49
|
+
* | fit
|
|
50
|
+
* | full
|
|
51
|
+
* | auto} Width
|
|
52
|
+
*
|
|
53
|
+
*
|
|
54
|
+
* @typedef {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12} Grow
|
|
55
|
+
*
|
|
56
|
+
* @typedef {object} ComponentProps
|
|
57
|
+
* @property {boolean | Record<Breakpoint, boolean>} [hide]
|
|
58
|
+
* @property {Grow | Record<Breakpoint, Grow>} [grow]
|
|
59
|
+
* @property {Width | Record<Breakpoint, Width>} [width]
|
|
60
|
+
* @property {AlignSelf | Record<Breakpoint, AlignSelf>} [alignSelf]
|
|
61
|
+
* @param {React.ComponentProps<'div'> & ComponentProps} props
|
|
62
|
+
* @returns {JSX.Element}
|
|
63
|
+
*/
|
|
64
|
+
|
|
65
|
+
const Component = ({ hide, grow, alignSelf, width, className, ...rest }, ref) => {
|
|
66
|
+
return (
|
|
67
|
+
<div
|
|
68
|
+
ref={ref}
|
|
69
|
+
className={cn(
|
|
70
|
+
typeof hide !== 'object' && hide === true ? 'hidden' : hide === false && 'block',
|
|
71
|
+
hide?.base === true ? 'hidden' : hide?.base === false && 'block',
|
|
72
|
+
hide?.md === true ? 'md:hidden' : hide?.md === false && 'md:block',
|
|
73
|
+
hide?.lg === true ? 'lg:hidden' : hide?.lg === false && 'lg:block',
|
|
74
|
+
typeof grow !== 'object' && getClassName(grow, growLookup),
|
|
75
|
+
getClassName(grow?.base, growLookup),
|
|
76
|
+
getClassName(grow?.md, growMdLookup),
|
|
77
|
+
getClassName(grow?.lg, growLgLookup),
|
|
78
|
+
getClassName(grow?.xl, growXlLookup),
|
|
79
|
+
typeof alignSelf !== 'object' && getClassName(alignSelf, alignSelfLookup),
|
|
80
|
+
getClassName(alignSelf?.base, alignSelfLookup),
|
|
81
|
+
getClassName(alignSelf?.md, alignSelfMdLookup),
|
|
82
|
+
getClassName(alignSelf?.lg, alignSelfLgLookup),
|
|
83
|
+
getClassName(alignSelf?.xl, alignSelfXlLookup),
|
|
84
|
+
typeof width !== 'object' && getClassName(width, widthLookup),
|
|
85
|
+
getClassName(width?.base, widthLookup),
|
|
86
|
+
getClassName(width?.md, widthMdLookup),
|
|
87
|
+
getClassName(width?.lg, widthLgLookup),
|
|
88
|
+
getClassName(width?.xl, widthXlLookup),
|
|
89
|
+
className
|
|
90
|
+
)}
|
|
91
|
+
{...rest}
|
|
92
|
+
/>
|
|
93
|
+
);
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
export const FlexItem = memo(React.forwardRef(Component));
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
fontSizeLookup,
|
|
4
|
+
fontSizeMdLookup,
|
|
5
|
+
fontSizeLgLookup,
|
|
6
|
+
fontWeightLookup,
|
|
7
|
+
fontWeightMdLookup,
|
|
8
|
+
fontWeightLgLookup,
|
|
9
|
+
gapLookup,
|
|
10
|
+
gapMdLookup,
|
|
11
|
+
gapLgLookup,
|
|
12
|
+
gapXlLookup,
|
|
13
|
+
fontSizeXlLookup,
|
|
14
|
+
fontWeightXlLookup,
|
|
15
|
+
fontSize2xlLookup,
|
|
16
|
+
fontWeight2xlLookup,
|
|
17
|
+
colorLookup,
|
|
18
|
+
} from '../theme';
|
|
19
|
+
import { Text } from './Text';
|
|
20
|
+
import { getClassName, memo } from '../utils';
|
|
21
|
+
import { cn } from '../libs';
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @typedef {'base' | 'md' | 'lg' | 'xl' | '2xl'} Breakpoint
|
|
25
|
+
*
|
|
26
|
+
* @typedef {0
|
|
27
|
+
* | 0.5
|
|
28
|
+
* | 1
|
|
29
|
+
* | 1.5
|
|
30
|
+
* | 2
|
|
31
|
+
* | 2.5
|
|
32
|
+
* | 3
|
|
33
|
+
* | 3.5
|
|
34
|
+
* | 4
|
|
35
|
+
* | 5
|
|
36
|
+
* | 6
|
|
37
|
+
* | 7
|
|
38
|
+
* | 8
|
|
39
|
+
* | 9
|
|
40
|
+
* | 10
|
|
41
|
+
* | 11
|
|
42
|
+
* | 12
|
|
43
|
+
* | 14
|
|
44
|
+
* | 16
|
|
45
|
+
* | 20
|
|
46
|
+
* | 24
|
|
47
|
+
* | 28
|
|
48
|
+
* | 32
|
|
49
|
+
* | 36
|
|
50
|
+
* | 40} Gap
|
|
51
|
+
*
|
|
52
|
+
*
|
|
53
|
+
* @typedef {'xs'
|
|
54
|
+
* | 'sm'
|
|
55
|
+
* | 'base'
|
|
56
|
+
* | 'lg'
|
|
57
|
+
* | 'xl'
|
|
58
|
+
* | '2xl'
|
|
59
|
+
* | '3xl'
|
|
60
|
+
* | '4xl'
|
|
61
|
+
* | '5xl'
|
|
62
|
+
* | '6xl'
|
|
63
|
+
* | '7xl'
|
|
64
|
+
* | '8xl'
|
|
65
|
+
* | '9xl'} Size
|
|
66
|
+
*
|
|
67
|
+
*
|
|
68
|
+
* @typedef {'thin'
|
|
69
|
+
* | 'extralight'
|
|
70
|
+
* | 'light'
|
|
71
|
+
* | 'normal'
|
|
72
|
+
* | 'medium'
|
|
73
|
+
* | 'semibold'
|
|
74
|
+
* | 'bold'
|
|
75
|
+
* | 'extrabold'
|
|
76
|
+
* | 'black'} Weight
|
|
77
|
+
*
|
|
78
|
+
*
|
|
79
|
+
* @typedef {'primary' | 'secondary' | 'success' | 'danger'} Color
|
|
80
|
+
*
|
|
81
|
+
* @typedef {object} ComponentProps
|
|
82
|
+
* @property {string} label
|
|
83
|
+
* @property {Size | Record<Breakpoint, Size>} [labelFontSize]
|
|
84
|
+
* @property {Weight | Record<Breakpoint, Weight>} [labelFontWeight]
|
|
85
|
+
* @property {Color} [labelColor]
|
|
86
|
+
* @property {string} [labelClass]
|
|
87
|
+
* @property {Gap | Record<Breakpoint, Gap>} [gap]
|
|
88
|
+
* @property {string} [error]
|
|
89
|
+
* @property {Size | Record<Breakpoint, Size>} [errorFontSize]
|
|
90
|
+
* @property {Weight | Record<Breakpoint, Weight>} [errorFontWeight]
|
|
91
|
+
* @property {Color} [errorColor]
|
|
92
|
+
* @property {string} [className]
|
|
93
|
+
* @property {boolean | Record<Breakpoint, boolean>} [hide]
|
|
94
|
+
* @property {boolean | Record<Breakpoint, boolean>} [hideLabel]
|
|
95
|
+
* @param {React.PropsWithChildren<ComponentProps>} props
|
|
96
|
+
* @returns {JSX.Element}
|
|
97
|
+
*/
|
|
98
|
+
|
|
99
|
+
const Component = ({
|
|
100
|
+
label,
|
|
101
|
+
labelFontSize,
|
|
102
|
+
labelFontWeight,
|
|
103
|
+
labelColor,
|
|
104
|
+
labelClass,
|
|
105
|
+
gap = 2,
|
|
106
|
+
hide,
|
|
107
|
+
hideLabel,
|
|
108
|
+
error,
|
|
109
|
+
errorFontSize = 'xs',
|
|
110
|
+
errorFontWeight = 'medium',
|
|
111
|
+
errorColor = 'danger',
|
|
112
|
+
className,
|
|
113
|
+
children,
|
|
114
|
+
}) => {
|
|
115
|
+
const id = React.useId();
|
|
116
|
+
const markup = typeof children === 'function' ? children(id) : children;
|
|
117
|
+
|
|
118
|
+
return (
|
|
119
|
+
<div
|
|
120
|
+
className={cn(
|
|
121
|
+
'flex flex-col w-full',
|
|
122
|
+
typeof gap !== 'object' && getClassName(gap, gapLookup),
|
|
123
|
+
getClassName(gap?.base, gapLookup),
|
|
124
|
+
getClassName(gap?.md, gapMdLookup),
|
|
125
|
+
getClassName(gap?.lg, gapLgLookup),
|
|
126
|
+
getClassName(gap?.xl, gapXlLookup),
|
|
127
|
+
typeof hide !== 'object' && hide === true ? 'hidden' : hide === false && 'block',
|
|
128
|
+
hide?.base === true ? 'hidden' : hide?.base === false && 'block',
|
|
129
|
+
hide?.md === true ? 'md:hidden' : hide?.md === false && 'md:block',
|
|
130
|
+
hide?.lg === true ? 'lg:hidden' : hide?.lg === false && 'lg:block',
|
|
131
|
+
typeof className !== 'object' && className
|
|
132
|
+
)}
|
|
133
|
+
>
|
|
134
|
+
{label && (
|
|
135
|
+
<div>
|
|
136
|
+
<label
|
|
137
|
+
htmlFor={id}
|
|
138
|
+
className={cn(
|
|
139
|
+
'font-inter',
|
|
140
|
+
typeof hideLabel !== 'object' && hideLabel === true
|
|
141
|
+
? 'hidden'
|
|
142
|
+
: hideLabel === false && 'block',
|
|
143
|
+
hideLabel?.base === true ? 'hidden' : hideLabel?.base === false && 'block',
|
|
144
|
+
hideLabel?.md === true ? 'md:hidden' : hideLabel?.md === false && 'md:block',
|
|
145
|
+
hideLabel?.lg === true ? 'lg:hidden' : hideLabel?.lg === false && 'lg:block',
|
|
146
|
+
typeof labelFontSize !== 'object' && getClassName(labelFontSize, fontSizeLookup),
|
|
147
|
+
getClassName(labelFontSize?.base, fontSizeLookup),
|
|
148
|
+
getClassName(labelFontSize?.md, fontSizeMdLookup),
|
|
149
|
+
getClassName(labelFontSize?.lg, fontSizeLgLookup),
|
|
150
|
+
getClassName(labelFontSize?.xl, fontSizeXlLookup),
|
|
151
|
+
getClassName(labelFontSize?.['2xl'], fontSize2xlLookup),
|
|
152
|
+
typeof labelFontWeight !== 'object' &&
|
|
153
|
+
getClassName(labelFontWeight, fontWeightLookup),
|
|
154
|
+
getClassName(labelFontWeight?.base, fontWeightLookup),
|
|
155
|
+
getClassName(labelFontWeight?.md, fontWeightMdLookup),
|
|
156
|
+
getClassName(labelFontWeight?.lg, fontWeightLgLookup),
|
|
157
|
+
getClassName(labelFontWeight?.xl, fontWeightXlLookup),
|
|
158
|
+
getClassName(labelFontWeight?.['2xl'], fontWeight2xlLookup),
|
|
159
|
+
getClassName(labelColor, colorLookup),
|
|
160
|
+
labelClass
|
|
161
|
+
)}
|
|
162
|
+
>
|
|
163
|
+
{label}
|
|
164
|
+
</label>
|
|
165
|
+
</div>
|
|
166
|
+
)}
|
|
167
|
+
<div className="-mt-1!">{markup}</div>
|
|
168
|
+
{error && (
|
|
169
|
+
<div>
|
|
170
|
+
<Text
|
|
171
|
+
size={errorFontSize}
|
|
172
|
+
weight={errorFontWeight}
|
|
173
|
+
color={errorColor}
|
|
174
|
+
className="font-inter"
|
|
175
|
+
>
|
|
176
|
+
{error}
|
|
177
|
+
</Text>
|
|
178
|
+
</div>
|
|
179
|
+
)}
|
|
180
|
+
</div>
|
|
181
|
+
);
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
export const FormField = memo(Component);
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { getClassName, memo } from '../utils';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import {
|
|
4
|
+
gapLookup,
|
|
5
|
+
gapMdLookup,
|
|
6
|
+
gapLgLookup,
|
|
7
|
+
columnsLookup,
|
|
8
|
+
columnsMdLookup,
|
|
9
|
+
columnsLgLookup,
|
|
10
|
+
justifyLookup,
|
|
11
|
+
justifyMdLookup,
|
|
12
|
+
justifyLgLookup,
|
|
13
|
+
alignLookup,
|
|
14
|
+
alignMdLookup,
|
|
15
|
+
alignLgLookup,
|
|
16
|
+
widthLookup,
|
|
17
|
+
widthLgLookup,
|
|
18
|
+
widthMdLookup,
|
|
19
|
+
columnsSmLookup,
|
|
20
|
+
gapXlLookup,
|
|
21
|
+
columnsXlLookup,
|
|
22
|
+
justifyXlLookup,
|
|
23
|
+
alignXlLookup,
|
|
24
|
+
widthXlLookup,
|
|
25
|
+
columns2XlLookup,
|
|
26
|
+
} from '../theme';
|
|
27
|
+
import { cn } from '../libs';
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @typedef {'base' | 'sm' | 'md' | 'lg' | 'xl' | '2xl'} Breakpoint
|
|
31
|
+
*
|
|
32
|
+
* @typedef {0
|
|
33
|
+
* | 0.5
|
|
34
|
+
* | 1
|
|
35
|
+
* | 1.5
|
|
36
|
+
* | 2
|
|
37
|
+
* | 2.5
|
|
38
|
+
* | 3
|
|
39
|
+
* | 3.5
|
|
40
|
+
* | 4
|
|
41
|
+
* | 5
|
|
42
|
+
* | 6
|
|
43
|
+
* | 7
|
|
44
|
+
* | 8
|
|
45
|
+
* | 9
|
|
46
|
+
* | 10
|
|
47
|
+
* | 11
|
|
48
|
+
* | 12
|
|
49
|
+
* | 14
|
|
50
|
+
* | 16
|
|
51
|
+
* | 20
|
|
52
|
+
* | 24
|
|
53
|
+
* | 28
|
|
54
|
+
* | 32
|
|
55
|
+
* | 36
|
|
56
|
+
* | 40} Gap
|
|
57
|
+
*
|
|
58
|
+
*
|
|
59
|
+
* @typedef {0
|
|
60
|
+
* | 0.5
|
|
61
|
+
* | 1
|
|
62
|
+
* | 1.5
|
|
63
|
+
* | 2
|
|
64
|
+
* | 2.5
|
|
65
|
+
* | 3
|
|
66
|
+
* | 3.5
|
|
67
|
+
* | 4
|
|
68
|
+
* | 5
|
|
69
|
+
* | 6
|
|
70
|
+
* | 7
|
|
71
|
+
* | 8
|
|
72
|
+
* | 9
|
|
73
|
+
* | 10
|
|
74
|
+
* | 11
|
|
75
|
+
* | 12
|
|
76
|
+
* | 14
|
|
77
|
+
* | 16
|
|
78
|
+
* | 20
|
|
79
|
+
* | 24
|
|
80
|
+
* | 28
|
|
81
|
+
* | 32
|
|
82
|
+
* | 36
|
|
83
|
+
* | 40
|
|
84
|
+
* | fit
|
|
85
|
+
* | full
|
|
86
|
+
* | auto} Width
|
|
87
|
+
*
|
|
88
|
+
*
|
|
89
|
+
* @typedef {'normal' | 'start' | 'end' | 'center' | 'between' | 'around' | 'evenly' | 'stretch'} Justify
|
|
90
|
+
*
|
|
91
|
+
*
|
|
92
|
+
* @typedef {'start' | 'end' | 'center' | 'baseline' | 'stretch'} Align
|
|
93
|
+
*
|
|
94
|
+
* @typedef {1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12} Columns
|
|
95
|
+
*
|
|
96
|
+
* @typedef {object} ComponentProps
|
|
97
|
+
* @property {boolean | Record<Breakpoint, boolean>} [grow]
|
|
98
|
+
* @property {Gap | Record<Breakpoint, Gap>} [gap]
|
|
99
|
+
* @property {Columns | Record<Breakpoint, Columns>} [columns]
|
|
100
|
+
* @property {Justify | Record<Breakpoint, Justify>} [justify]
|
|
101
|
+
* @property {Align | Record<Breakpoint, Align>} [align]
|
|
102
|
+
* @property {Width | Record<Breakpoint, Width>} [width]
|
|
103
|
+
* @param {React.ComponentProps<'div'> & ComponentProps} props
|
|
104
|
+
* @returns {JSX.Element}
|
|
105
|
+
*/
|
|
106
|
+
|
|
107
|
+
const Component = ({ grow, gap, columns, justify, align, className, width, ...rest }, ref) => {
|
|
108
|
+
return (
|
|
109
|
+
<div
|
|
110
|
+
ref={ref}
|
|
111
|
+
className={cn(
|
|
112
|
+
'grid',
|
|
113
|
+
typeof grow !== 'object' && grow === true ? 'h-full' : grow === false && 'h-auto',
|
|
114
|
+
grow?.base === true ? 'h-full' : grow?.base === false && 'h-auto',
|
|
115
|
+
grow?.md === true ? 'md:h-full' : grow?.md === false && 'md:h-auto',
|
|
116
|
+
grow?.lg === true ? 'lg:h-full' : grow?.lg === false && 'lg:h-auto',
|
|
117
|
+
typeof gap !== 'object' && getClassName(gap, gapLookup),
|
|
118
|
+
getClassName(gap?.base, gapLookup),
|
|
119
|
+
getClassName(gap?.md, gapMdLookup),
|
|
120
|
+
getClassName(gap?.lg, gapLgLookup),
|
|
121
|
+
getClassName(gap?.xl, gapXlLookup),
|
|
122
|
+
typeof columns !== 'object' && getClassName(columns, columnsLookup),
|
|
123
|
+
getClassName(columns?.base, columnsLookup),
|
|
124
|
+
getClassName(columns?.md, columnsMdLookup),
|
|
125
|
+
getClassName(columns?.sm, columnsSmLookup),
|
|
126
|
+
getClassName(columns?.lg, columnsLgLookup),
|
|
127
|
+
getClassName(columns?.xl, columnsXlLookup),
|
|
128
|
+
getClassName(columns?.['2xl'], columns2XlLookup),
|
|
129
|
+
typeof justify !== 'object' && getClassName(justify, justifyLookup),
|
|
130
|
+
getClassName(justify?.base, justifyLookup),
|
|
131
|
+
getClassName(justify?.md, justifyMdLookup),
|
|
132
|
+
getClassName(justify?.lg, justifyLgLookup),
|
|
133
|
+
getClassName(justify?.xl, justifyXlLookup),
|
|
134
|
+
typeof align !== 'object' && getClassName(align, alignLookup),
|
|
135
|
+
getClassName(align?.base, alignLookup),
|
|
136
|
+
getClassName(align?.md, alignMdLookup),
|
|
137
|
+
getClassName(align?.lg, alignLgLookup),
|
|
138
|
+
getClassName(align?.xl, alignXlLookup),
|
|
139
|
+
typeof width !== 'object' && getClassName(width, widthLookup),
|
|
140
|
+
getClassName(width?.base, widthLookup),
|
|
141
|
+
getClassName(width?.md, widthMdLookup),
|
|
142
|
+
getClassName(width?.lg, widthLgLookup),
|
|
143
|
+
getClassName(width?.xl, widthXlLookup),
|
|
144
|
+
className
|
|
145
|
+
)}
|
|
146
|
+
{...rest}
|
|
147
|
+
/>
|
|
148
|
+
);
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
export const Grid = memo(React.forwardRef(Component));
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import {
|
|
2
|
+
spanLookup,
|
|
3
|
+
spanMdLookup,
|
|
4
|
+
spanLgLookup,
|
|
5
|
+
alignSelfLookup,
|
|
6
|
+
alignSelfMdLookup,
|
|
7
|
+
alignSelfLgLookup,
|
|
8
|
+
widthLookup,
|
|
9
|
+
widthMdLookup,
|
|
10
|
+
widthLgLookup,
|
|
11
|
+
spanXlLookup,
|
|
12
|
+
alignSelfXlLookup,
|
|
13
|
+
widthXlLookup,
|
|
14
|
+
} from '../theme';
|
|
15
|
+
import { getClassName, memo } from '../utils';
|
|
16
|
+
import { cn } from '../libs';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @typedef {'base' | 'md' | 'lg' | 'xl'} Breakpoint
|
|
20
|
+
*
|
|
21
|
+
* @typedef {'auto' | 'start' | 'end' | 'center' | 'baseline' | 'stretch'} AlignSelf
|
|
22
|
+
*
|
|
23
|
+
* @typedef {'auto' | 'full' | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12} Span
|
|
24
|
+
*
|
|
25
|
+
* @typedef {0
|
|
26
|
+
* | 0.5
|
|
27
|
+
* | 1
|
|
28
|
+
* | 1.5
|
|
29
|
+
* | 2
|
|
30
|
+
* | 2.5
|
|
31
|
+
* | 3
|
|
32
|
+
* | 3.5
|
|
33
|
+
* | 4
|
|
34
|
+
* | 5
|
|
35
|
+
* | 6
|
|
36
|
+
* | 7
|
|
37
|
+
* | 8
|
|
38
|
+
* | 9
|
|
39
|
+
* | 10
|
|
40
|
+
* | 11
|
|
41
|
+
* | 12
|
|
42
|
+
* | 14
|
|
43
|
+
* | 16
|
|
44
|
+
* | 20
|
|
45
|
+
* | 24
|
|
46
|
+
* | 28
|
|
47
|
+
* | 32
|
|
48
|
+
* | 36
|
|
49
|
+
* | 40
|
|
50
|
+
* | fit
|
|
51
|
+
* | full
|
|
52
|
+
* | auto} Width
|
|
53
|
+
*
|
|
54
|
+
*
|
|
55
|
+
* @typedef {object} ComponentProps
|
|
56
|
+
* @property {boolean | Record<Breakpoint, boolean>} [hide]
|
|
57
|
+
* @property {Span | Record<Breakpoint, Span>} [span]
|
|
58
|
+
* @property {AlignSelf | Record<Breakpoint, AlignSelf>} [alignSelf]
|
|
59
|
+
* @property {Width | Record<Breakpoint, Width>} [width]
|
|
60
|
+
* @param {React.ComponentProps<'div'> & ComponentProps} props
|
|
61
|
+
* @returns {JSX.Element}
|
|
62
|
+
*/
|
|
63
|
+
|
|
64
|
+
const Component = ({ hide, span, alignSelf, width, className, ...rest }, ref) => {
|
|
65
|
+
return (
|
|
66
|
+
<div
|
|
67
|
+
ref={ref}
|
|
68
|
+
className={cn(
|
|
69
|
+
typeof hide !== 'object' && hide === true ? 'hidden' : hide === false && 'block',
|
|
70
|
+
hide?.base === true ? 'hidden' : hide?.base === false && 'block',
|
|
71
|
+
hide?.md === true ? 'md:hidden' : hide?.md === false && 'md:block',
|
|
72
|
+
hide?.lg === true ? 'lg:hidden' : hide?.lg === false && 'lg:block',
|
|
73
|
+
typeof span !== 'object' && getClassName(span, spanLookup),
|
|
74
|
+
getClassName(span?.base, spanLookup),
|
|
75
|
+
getClassName(span?.md, spanMdLookup),
|
|
76
|
+
getClassName(span?.lg, spanLgLookup),
|
|
77
|
+
getClassName(span?.xl, spanXlLookup),
|
|
78
|
+
typeof alignSelf !== 'object' && getClassName(alignSelf, alignSelfLookup),
|
|
79
|
+
getClassName(alignSelf?.base, alignSelfLookup),
|
|
80
|
+
getClassName(alignSelf?.md, alignSelfMdLookup),
|
|
81
|
+
getClassName(alignSelf?.lg, alignSelfLgLookup),
|
|
82
|
+
getClassName(alignSelf?.xl, alignSelfXlLookup),
|
|
83
|
+
typeof width !== 'object' && getClassName(width, widthLookup),
|
|
84
|
+
getClassName(width?.base, widthLookup),
|
|
85
|
+
getClassName(width?.md, widthMdLookup),
|
|
86
|
+
getClassName(width?.lg, widthLgLookup),
|
|
87
|
+
getClassName(width?.xl, widthXlLookup),
|
|
88
|
+
className
|
|
89
|
+
)}
|
|
90
|
+
{...rest}
|
|
91
|
+
/>
|
|
92
|
+
);
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export const GridItem = memo(React.forwardRef(Component));
|