atomsystem 0.1.47 → 0.1.48
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/app/templates/Checkbox/Checkbox.tsx +55 -0
- package/app/templates/Checkbox/checkbox.css +38 -0
- package/app/templates/Input/Input.tsx +29 -0
- package/app/templates/Input/input.css +24 -0
- package/app/templates/Label/Label.tsx +22 -0
- package/app/templates/Radio/Radio.tsx +45 -0
- package/app/templates/Radio/radio.css +29 -0
- package/app/templates/{Form/Form.tsx → Select/Select.tsx} +143 -289
- package/app/templates/Select/select.css +47 -0
- package/app/templates/Theme/Theme.tsx +2 -1
- package/dist/index.js +6 -2
- package/package.json +2 -2
- package/app/templates/Form/form.css +0 -115
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import clsx from "clsx";
|
|
3
|
+
import "./checkbox.css";
|
|
4
|
+
|
|
5
|
+
export const Checkbox = ({
|
|
6
|
+
text,
|
|
7
|
+
onChange,
|
|
8
|
+
disabled,
|
|
9
|
+
required,
|
|
10
|
+
defaultChecked,
|
|
11
|
+
}: {
|
|
12
|
+
text?: string;
|
|
13
|
+
className?: string;
|
|
14
|
+
onChange?: () => void;
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
required?: boolean;
|
|
17
|
+
defaultChecked?: boolean;
|
|
18
|
+
}) => {
|
|
19
|
+
return (
|
|
20
|
+
<label className="checkbox-container gap-1.5">
|
|
21
|
+
<input
|
|
22
|
+
type="checkbox"
|
|
23
|
+
className="appearance-none hidden"
|
|
24
|
+
onChange={onChange}
|
|
25
|
+
disabled={disabled}
|
|
26
|
+
required={required}
|
|
27
|
+
defaultChecked={defaultChecked}
|
|
28
|
+
/>
|
|
29
|
+
<span className="checkbox-box">
|
|
30
|
+
<svg
|
|
31
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
32
|
+
className="h-4 w-4"
|
|
33
|
+
viewBox="0 0 20 20"
|
|
34
|
+
strokeWidth="1"
|
|
35
|
+
>
|
|
36
|
+
<path
|
|
37
|
+
fillRule="evenodd"
|
|
38
|
+
d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z"
|
|
39
|
+
clipRule="evenodd"
|
|
40
|
+
></path>
|
|
41
|
+
</svg>
|
|
42
|
+
</span>
|
|
43
|
+
{text ? (
|
|
44
|
+
<span
|
|
45
|
+
className={clsx(
|
|
46
|
+
"text-text-standard text-nowrap select-none",
|
|
47
|
+
{ "!text-text-disabled": disabled }
|
|
48
|
+
)}
|
|
49
|
+
>
|
|
50
|
+
{text}
|
|
51
|
+
</span>
|
|
52
|
+
) : null}
|
|
53
|
+
</label>
|
|
54
|
+
);
|
|
55
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
.checkbox-container{
|
|
2
|
+
display: flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
position: relative;
|
|
5
|
+
cursor: pointer;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.checkbox-box {
|
|
9
|
+
width: var(--spacing-small);
|
|
10
|
+
height: var(--spacing-small);
|
|
11
|
+
border: 1px solid var(--color-border-standard);
|
|
12
|
+
border-radius: var(--radius-common);
|
|
13
|
+
background: var(--color-bg-input-standard);
|
|
14
|
+
display: flex;
|
|
15
|
+
align-items: center;
|
|
16
|
+
justify-content: center;
|
|
17
|
+
transition: all 0.2s;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.checkbox-box svg {
|
|
21
|
+
color: transparent;
|
|
22
|
+
fill: transparent;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
input:checked + .checkbox-box {
|
|
26
|
+
background: var(--color-primary);
|
|
27
|
+
border-color: var(--color-primary);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
input:checked + .checkbox-box svg {
|
|
31
|
+
color: var(--color-text-active);
|
|
32
|
+
fill: var(--color-text-active);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
input:disabled + .checkbox-box {
|
|
36
|
+
background: var(--color-bg-input-disabled);
|
|
37
|
+
cursor: not-allowed;
|
|
38
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import "./input.css";
|
|
4
|
+
|
|
5
|
+
export const Input = ({
|
|
6
|
+
type = "text",
|
|
7
|
+
placeholder = "값을 입력해주세요",
|
|
8
|
+
readOnly,
|
|
9
|
+
disabled,
|
|
10
|
+
required,
|
|
11
|
+
}: {
|
|
12
|
+
type?: string;
|
|
13
|
+
className?: string;
|
|
14
|
+
placeholder?: string;
|
|
15
|
+
readOnly?: boolean;
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
required?: boolean;
|
|
18
|
+
}) => {
|
|
19
|
+
return (
|
|
20
|
+
<input
|
|
21
|
+
className="input"
|
|
22
|
+
type={type}
|
|
23
|
+
placeholder={placeholder}
|
|
24
|
+
readOnly={readOnly}
|
|
25
|
+
disabled={disabled}
|
|
26
|
+
required={required}
|
|
27
|
+
/>
|
|
28
|
+
);
|
|
29
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
.input{
|
|
2
|
+
background: var(--color-bg-input-standard);
|
|
3
|
+
border: 1px solid var(--color-border-standard);
|
|
4
|
+
color: var(--color-text-standard);
|
|
5
|
+
padding: var(--spacing-common-y) var(--spacing-common-x);
|
|
6
|
+
border-radius: var(--radius-common);
|
|
7
|
+
outline: none;
|
|
8
|
+
width: 100%;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.input::placeholder{
|
|
12
|
+
color: var(--color-text-placeholder);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.input:focus{
|
|
16
|
+
border: 1px solid var(--color-border-active);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.input:disabled{
|
|
20
|
+
background: var(--color-bg-input-disabled);
|
|
21
|
+
border: 1px solid var(--color-border-standard);
|
|
22
|
+
color: var(--color-text-disabled);
|
|
23
|
+
cursor: not-allowed;
|
|
24
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import clsx from "clsx";
|
|
3
|
+
|
|
4
|
+
export const Label = ({
|
|
5
|
+
label,
|
|
6
|
+
required,
|
|
7
|
+
}: {
|
|
8
|
+
label: string;
|
|
9
|
+
required?: boolean;
|
|
10
|
+
}) => {
|
|
11
|
+
return (
|
|
12
|
+
<p className={"mb-1 text-text-standard"}>
|
|
13
|
+
<span
|
|
14
|
+
className={clsx("", {
|
|
15
|
+
"after:content-['*'] after:ml-1 after:text-danger": required,
|
|
16
|
+
})}
|
|
17
|
+
>
|
|
18
|
+
{label}
|
|
19
|
+
</span>
|
|
20
|
+
</p>
|
|
21
|
+
);
|
|
22
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import clsx from "clsx";
|
|
3
|
+
import "./radio.css";
|
|
4
|
+
|
|
5
|
+
export const Radio = ({
|
|
6
|
+
name,
|
|
7
|
+
value,
|
|
8
|
+
label,
|
|
9
|
+
className,
|
|
10
|
+
onChange,
|
|
11
|
+
defaultChecked,
|
|
12
|
+
checked,
|
|
13
|
+
}: {
|
|
14
|
+
name: string;
|
|
15
|
+
value: string;
|
|
16
|
+
label?: string;
|
|
17
|
+
className?: string;
|
|
18
|
+
onChange?: () => void;
|
|
19
|
+
defaultChecked?: boolean;
|
|
20
|
+
checked?: boolean;
|
|
21
|
+
}) => {
|
|
22
|
+
return (
|
|
23
|
+
<>
|
|
24
|
+
{label ? <p>{label}</p> : null}
|
|
25
|
+
<label className="flex items-center gap-1 cursor-pointer">
|
|
26
|
+
<input
|
|
27
|
+
type="radio"
|
|
28
|
+
className={clsx(
|
|
29
|
+
"relative appearance-none radio rounded-full ",
|
|
30
|
+
{
|
|
31
|
+
"checked:bg-primary after:w-2.5 after:h-2.5 after:bg-[var(--color-bg-input-standard)] after:content-[''] after:absolute after:rounded-full after:left-1 after:top-1":
|
|
32
|
+
true,
|
|
33
|
+
},
|
|
34
|
+
className
|
|
35
|
+
)}
|
|
36
|
+
name={name}
|
|
37
|
+
onChange={onChange}
|
|
38
|
+
defaultChecked={defaultChecked}
|
|
39
|
+
checked={checked}
|
|
40
|
+
/>
|
|
41
|
+
<span>{value}</span>
|
|
42
|
+
</label>
|
|
43
|
+
</>
|
|
44
|
+
);
|
|
45
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
.radio{
|
|
2
|
+
position: relative;
|
|
3
|
+
width: var(--spacing-small);
|
|
4
|
+
height: var(--spacing-small);
|
|
5
|
+
border: 1px solid var(--color-border-standard);
|
|
6
|
+
background: var(--color-bg-input-standard);
|
|
7
|
+
color: var(--color-bg-input-standard);
|
|
8
|
+
cursor: pointer;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.radio::after{
|
|
12
|
+
content:'';
|
|
13
|
+
position:absolute;
|
|
14
|
+
left: 50%;
|
|
15
|
+
top: 50%;
|
|
16
|
+
transform: translate(-50%, -50%);
|
|
17
|
+
width: var(--spacing-common-y);
|
|
18
|
+
height: var(--spacing-common-y);
|
|
19
|
+
border-radius: var(--radius-circle);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.radio:checked::after{
|
|
23
|
+
background: var(--color-primary);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.radio:disabled {
|
|
27
|
+
background: var(--color-bg-input-disabled);
|
|
28
|
+
cursor: not-allowed;
|
|
29
|
+
}
|
|
@@ -1,289 +1,143 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
export const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}: {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}) => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
)
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
})
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
<span className="text-base input-text-value">arrow_drop_down</span>
|
|
145
|
-
</span>
|
|
146
|
-
</div>
|
|
147
|
-
</label>
|
|
148
|
-
{isOpen &&
|
|
149
|
-
createPortal(
|
|
150
|
-
<ul
|
|
151
|
-
ref={dropdownRef}
|
|
152
|
-
className="absolute w-full select-menu"
|
|
153
|
-
style={{
|
|
154
|
-
top: menuPosition.top,
|
|
155
|
-
left: menuPosition.left,
|
|
156
|
-
width: menuPosition.width,
|
|
157
|
-
}}
|
|
158
|
-
>
|
|
159
|
-
{filteredOptions.length > 0 ? (
|
|
160
|
-
filteredOptions.map((option, index) => (
|
|
161
|
-
<li
|
|
162
|
-
key={index}
|
|
163
|
-
className="select-menu-item"
|
|
164
|
-
onClick={() => {
|
|
165
|
-
setFilterValue(option);
|
|
166
|
-
setIsOpen(false);
|
|
167
|
-
}}
|
|
168
|
-
>
|
|
169
|
-
{option}
|
|
170
|
-
</li>
|
|
171
|
-
))
|
|
172
|
-
) : (
|
|
173
|
-
<li className="select-menu-item">No results</li>
|
|
174
|
-
)}
|
|
175
|
-
</ul>,
|
|
176
|
-
document.body
|
|
177
|
-
)}
|
|
178
|
-
<select
|
|
179
|
-
className="select block sm:hidden"
|
|
180
|
-
>
|
|
181
|
-
{options.map((option, index) => {
|
|
182
|
-
return (
|
|
183
|
-
<option key={index} value={option}>
|
|
184
|
-
{option}
|
|
185
|
-
</option>
|
|
186
|
-
);
|
|
187
|
-
})}
|
|
188
|
-
</select>
|
|
189
|
-
</div>
|
|
190
|
-
);
|
|
191
|
-
};
|
|
192
|
-
|
|
193
|
-
export const Radio = ({
|
|
194
|
-
name,
|
|
195
|
-
value,
|
|
196
|
-
label,
|
|
197
|
-
className,
|
|
198
|
-
onChange,
|
|
199
|
-
defaultChecked,
|
|
200
|
-
checked,
|
|
201
|
-
}: {
|
|
202
|
-
name: string;
|
|
203
|
-
value: string;
|
|
204
|
-
label?: string;
|
|
205
|
-
className?: string;
|
|
206
|
-
onChange?: () => void;
|
|
207
|
-
defaultChecked?: boolean;
|
|
208
|
-
checked?: boolean;
|
|
209
|
-
}) => {
|
|
210
|
-
return (
|
|
211
|
-
<>
|
|
212
|
-
{label ? <p>{label}</p> : null}
|
|
213
|
-
<label className="flex items-center gap-1">
|
|
214
|
-
<input
|
|
215
|
-
type="radio"
|
|
216
|
-
className={clsx(
|
|
217
|
-
"relative appearance-none radio rounded-full ",
|
|
218
|
-
{
|
|
219
|
-
"checked:bg-primary after:w-2.5 after:h-2.5 after:bg-[var(--input-background-standard)] after:content-[''] after:absolute after:rounded-full after:left-1 after:top-1":
|
|
220
|
-
true,
|
|
221
|
-
},
|
|
222
|
-
{ "focus:border-input-border-focus": true },
|
|
223
|
-
{ "disabled:bg-input-background-disabled": true },
|
|
224
|
-
className
|
|
225
|
-
)}
|
|
226
|
-
name={name}
|
|
227
|
-
onChange={onChange}
|
|
228
|
-
defaultChecked={defaultChecked}
|
|
229
|
-
checked={checked}
|
|
230
|
-
/>
|
|
231
|
-
<span>{value}</span>
|
|
232
|
-
</label>
|
|
233
|
-
</>
|
|
234
|
-
);
|
|
235
|
-
};
|
|
236
|
-
|
|
237
|
-
export const Checkbox = ({
|
|
238
|
-
text,
|
|
239
|
-
onChange,
|
|
240
|
-
disabled,
|
|
241
|
-
required,
|
|
242
|
-
defaultChecked,
|
|
243
|
-
}: {
|
|
244
|
-
text?: string;
|
|
245
|
-
className?: string;
|
|
246
|
-
onChange?: () => void;
|
|
247
|
-
disabled?: boolean;
|
|
248
|
-
required?: boolean;
|
|
249
|
-
defaultChecked?: boolean;
|
|
250
|
-
}) => {
|
|
251
|
-
return (
|
|
252
|
-
<>
|
|
253
|
-
<label className="checkbox gap-1.5">
|
|
254
|
-
<input
|
|
255
|
-
type="checkbox"
|
|
256
|
-
className="appearance-none hidden"
|
|
257
|
-
onChange={onChange}
|
|
258
|
-
disabled={disabled}
|
|
259
|
-
required={required}
|
|
260
|
-
defaultChecked={defaultChecked}
|
|
261
|
-
/>
|
|
262
|
-
<span>
|
|
263
|
-
<svg
|
|
264
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
265
|
-
className="h-4 w-4"
|
|
266
|
-
viewBox="0 0 20 20"
|
|
267
|
-
strokeWidth="1"
|
|
268
|
-
>
|
|
269
|
-
<path
|
|
270
|
-
fillRule="evenodd"
|
|
271
|
-
d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z"
|
|
272
|
-
clipRule="evenodd"
|
|
273
|
-
></path>
|
|
274
|
-
</svg>
|
|
275
|
-
</span>
|
|
276
|
-
{text ? (
|
|
277
|
-
<span
|
|
278
|
-
className={clsx(
|
|
279
|
-
"text-text-standard text-nowrap select-none",
|
|
280
|
-
{ "!text-text-disabled": disabled }
|
|
281
|
-
)}
|
|
282
|
-
>
|
|
283
|
-
{text}
|
|
284
|
-
</span>
|
|
285
|
-
) : null}
|
|
286
|
-
</label>
|
|
287
|
-
</>
|
|
288
|
-
);
|
|
289
|
-
};
|
|
1
|
+
"use client";
|
|
2
|
+
import { useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
3
|
+
import { createPortal } from "react-dom";
|
|
4
|
+
import "./select.css";
|
|
5
|
+
|
|
6
|
+
export const Select = ({
|
|
7
|
+
options = [],
|
|
8
|
+
disabled,
|
|
9
|
+
}: {
|
|
10
|
+
options: string[];
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
}) => {
|
|
13
|
+
const [filterValue, setFilterValue] = useState("");
|
|
14
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
15
|
+
const [menuPosition, setMenuPosition] = useState({
|
|
16
|
+
top: 0,
|
|
17
|
+
left: 0,
|
|
18
|
+
width: 0,
|
|
19
|
+
});
|
|
20
|
+
const inputRef = useRef<HTMLInputElement>(null);
|
|
21
|
+
const dropdownRef = useRef<HTMLUListElement>(null);
|
|
22
|
+
const filteredOptions = options.filter((option) =>
|
|
23
|
+
option.toLowerCase().includes(filterValue.toLowerCase())
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
useLayoutEffect(() => {
|
|
27
|
+
if (isOpen && inputRef.current && dropdownRef.current) {
|
|
28
|
+
const rect = inputRef.current.getBoundingClientRect();
|
|
29
|
+
const dropdownRect = dropdownRef.current.getBoundingClientRect();
|
|
30
|
+
|
|
31
|
+
if (Math.abs(menuPosition.width - rect.width) > 0.5) {
|
|
32
|
+
setMenuPosition({
|
|
33
|
+
top: rect.bottom + window.scrollY,
|
|
34
|
+
left: rect.left,
|
|
35
|
+
width: rect.width,
|
|
36
|
+
});
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
let top = rect.bottom + window.scrollY;
|
|
41
|
+
|
|
42
|
+
if (rect.bottom + dropdownRect.height > window.innerHeight) {
|
|
43
|
+
top = rect.top + window.scrollY - dropdownRect.height;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
setMenuPosition((prev) => {
|
|
47
|
+
if (
|
|
48
|
+
Math.abs(prev.top - top) < 0.5 &&
|
|
49
|
+
Math.abs(prev.left - rect.left) < 0.5
|
|
50
|
+
) {
|
|
51
|
+
return prev;
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
top,
|
|
55
|
+
left: rect.left,
|
|
56
|
+
width: rect.width,
|
|
57
|
+
};
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}, [isOpen, filterValue, menuPosition.width]);
|
|
61
|
+
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
const handleClickOutside = (event: MouseEvent) => {
|
|
64
|
+
if (
|
|
65
|
+
dropdownRef.current &&
|
|
66
|
+
!dropdownRef.current.contains(event.target as Node) &&
|
|
67
|
+
inputRef.current &&
|
|
68
|
+
!inputRef.current.contains(event.target as Node)
|
|
69
|
+
) {
|
|
70
|
+
setIsOpen(false);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
74
|
+
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
75
|
+
}, []);
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
<div className="relative">
|
|
79
|
+
<label className="relative w-fit hidden md:block">
|
|
80
|
+
<input
|
|
81
|
+
ref={inputRef}
|
|
82
|
+
type="text"
|
|
83
|
+
value={filterValue}
|
|
84
|
+
placeholder="값을 선택해주세요..."
|
|
85
|
+
onChange={(e) => {
|
|
86
|
+
setFilterValue(e.target.value);
|
|
87
|
+
}}
|
|
88
|
+
onFocus={() => setIsOpen(true)}
|
|
89
|
+
className="select hidden sm:block"
|
|
90
|
+
disabled={disabled}
|
|
91
|
+
/>
|
|
92
|
+
<div
|
|
93
|
+
className="absolute flex items-center right-0 top-0 h-full px-2"
|
|
94
|
+
>
|
|
95
|
+
<span className="material-symbols-outlined">
|
|
96
|
+
<span className="text-base">arrow_drop_down</span>
|
|
97
|
+
</span>
|
|
98
|
+
</div>
|
|
99
|
+
</label>
|
|
100
|
+
{isOpen &&
|
|
101
|
+
createPortal(
|
|
102
|
+
<ul
|
|
103
|
+
ref={dropdownRef}
|
|
104
|
+
className="absolute w-full select-menu"
|
|
105
|
+
style={{
|
|
106
|
+
top: menuPosition.top,
|
|
107
|
+
left: menuPosition.left,
|
|
108
|
+
width: menuPosition.width,
|
|
109
|
+
}}
|
|
110
|
+
>
|
|
111
|
+
{filteredOptions.length > 0 ? (
|
|
112
|
+
filteredOptions.map((option, index) => (
|
|
113
|
+
<li
|
|
114
|
+
key={index}
|
|
115
|
+
className="select-menu-item"
|
|
116
|
+
onClick={() => {
|
|
117
|
+
setFilterValue(option);
|
|
118
|
+
setIsOpen(false);
|
|
119
|
+
}}
|
|
120
|
+
>
|
|
121
|
+
{option}
|
|
122
|
+
</li>
|
|
123
|
+
))
|
|
124
|
+
) : (
|
|
125
|
+
<li className="select-menu-item">No results</li>
|
|
126
|
+
)}
|
|
127
|
+
</ul>,
|
|
128
|
+
document.body
|
|
129
|
+
)}
|
|
130
|
+
<select
|
|
131
|
+
className="select block sm:hidden"
|
|
132
|
+
>
|
|
133
|
+
{options.map((option, index) => {
|
|
134
|
+
return (
|
|
135
|
+
<option key={index} value={option}>
|
|
136
|
+
{option}
|
|
137
|
+
</option>
|
|
138
|
+
);
|
|
139
|
+
})}
|
|
140
|
+
</select>
|
|
141
|
+
</div>
|
|
142
|
+
);
|
|
143
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
.select{
|
|
2
|
+
background: var(--color-bg-input-standard);
|
|
3
|
+
border: 1px solid var(--color-border-standard);
|
|
4
|
+
color: var(--color-text-standard);
|
|
5
|
+
padding: var(--spacing-common-y) var(--spacing-common-x);
|
|
6
|
+
border-radius: var(--radius-common);
|
|
7
|
+
width: 100%;
|
|
8
|
+
outline: none;
|
|
9
|
+
cursor: pointer;
|
|
10
|
+
}
|
|
11
|
+
.select:focus{
|
|
12
|
+
border: 1px solid var(--color-border-active);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.select:disabled{
|
|
16
|
+
background: var(--color-bg-input-disabled);
|
|
17
|
+
border: 1px solid var(--color-border-standard);
|
|
18
|
+
color: var(--color-text-disabled);
|
|
19
|
+
cursor: not-allowed;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.select-menu {
|
|
23
|
+
border: 1px solid var(--color-border-active);
|
|
24
|
+
border-radius: var(--radius-common);
|
|
25
|
+
overflow:hidden;
|
|
26
|
+
z-index: 9999;
|
|
27
|
+
box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
|
|
28
|
+
background: var(--color-bg-input-standard);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.select-menu .select-menu-item {
|
|
32
|
+
background: var(--color-bg-input-standard);
|
|
33
|
+
color: var(--color-text-standard);
|
|
34
|
+
padding: var(--spacing-common-y) var(--spacing-common-x);
|
|
35
|
+
cursor:pointer;
|
|
36
|
+
list-style: none;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.select-menu .select-menu-item:hover {
|
|
40
|
+
background: var(--color-bg-input-hover);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.select-menu .select-menu-item:active,
|
|
44
|
+
.select-menu .select-menu-item:focus {
|
|
45
|
+
background: var(--color-primary);
|
|
46
|
+
color: var(--color-text-active);
|
|
47
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import { useEffect, useState } from "react";
|
|
4
|
-
import { Radio } from "../
|
|
4
|
+
import { Radio } from "../Radio/Radio";
|
|
5
|
+
|
|
5
6
|
import { themes } from "@/build/typescript/theme";
|
|
6
7
|
import { Button } from "../Button/Button";
|
|
7
8
|
import { ModalContent } from "../Modal/Modal";
|
package/dist/index.js
CHANGED
|
@@ -159,10 +159,14 @@ var init_component = __esm({
|
|
|
159
159
|
"Table",
|
|
160
160
|
"Modal",
|
|
161
161
|
"TOC",
|
|
162
|
-
"Dropdown"
|
|
162
|
+
"Dropdown",
|
|
163
|
+
"Checkbox",
|
|
164
|
+
"Radio",
|
|
165
|
+
"Select",
|
|
166
|
+
"Label"
|
|
163
167
|
];
|
|
164
168
|
dependenciesMap = {
|
|
165
|
-
Theme: ["Button", "
|
|
169
|
+
Theme: ["Button", "Radio", "Modal"]
|
|
166
170
|
};
|
|
167
171
|
}
|
|
168
172
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "atomsystem",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.48",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"homepage": "https://system.atomground.com",
|
|
6
6
|
"bin": {
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"css"
|
|
16
16
|
],
|
|
17
17
|
"scripts": {
|
|
18
|
-
"dev": "node build/build-tokens.js && next dev",
|
|
18
|
+
"dev": "node build/build-tokens.js && next dev --webpack",
|
|
19
19
|
"build": "next build",
|
|
20
20
|
"start": "next start",
|
|
21
21
|
"lint": "next lint",
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
.input{
|
|
3
|
-
background: var(--bg-input-standard);
|
|
4
|
-
border: 1px solid var(--border-standard);
|
|
5
|
-
color: var(--text-standard);
|
|
6
|
-
padding: var(--spacing-common-y) var(--spacing-common-x);
|
|
7
|
-
border-radius: var(--radius-common);
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
.input::placeholder{
|
|
11
|
-
color: var(--text-placeholder);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.input:focus{
|
|
15
|
-
border: 1px solid var(--border-active);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
.input:disabled{
|
|
19
|
-
background: var(--bg-input-disabled);
|
|
20
|
-
border: 1px solid var(--border-standard);
|
|
21
|
-
color: var(--text-disabled);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
.select{
|
|
25
|
-
background: var(--bg-input-standard);
|
|
26
|
-
border: 1px solid var(--border-standard);
|
|
27
|
-
color: var(--text-standard);
|
|
28
|
-
padding: var(--spacing-common-y) var(--spacing-common-x);
|
|
29
|
-
border-radius: var(--radius-common);
|
|
30
|
-
}
|
|
31
|
-
.select:focus{
|
|
32
|
-
border: 1px solid var(--border-active);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
.select:disabled{
|
|
36
|
-
background: var(--bg-input-disabled);
|
|
37
|
-
border: 1px solid var(--border-standard);
|
|
38
|
-
color: var(--text-disabled);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
.select-menu {
|
|
42
|
-
border: 1px solid var(--border-active);
|
|
43
|
-
border-radius: var(--radius-common);
|
|
44
|
-
overflow:hidden;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
.select-menu .select-menu-item {
|
|
48
|
-
background: var(--bg-input-standard);
|
|
49
|
-
border: 1px solid var(--border-standard);
|
|
50
|
-
color: var(--text-standard);
|
|
51
|
-
padding: var(--spacing-common-y) var(--spacing-common-x);
|
|
52
|
-
cursor:pointer
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
.select-menu .select-menu-item:hover {
|
|
56
|
-
background: var(--bg-input-hover);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
.select-menu .select-menu-item:active,
|
|
60
|
-
.select-menu .select-menu-item:focus {
|
|
61
|
-
background: var(--color-primary);
|
|
62
|
-
border: 1px solid var(--color-primary);
|
|
63
|
-
color: var(--text-active);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
.checkbox{
|
|
67
|
-
display: flex;
|
|
68
|
-
align-items: center;
|
|
69
|
-
position: relative;
|
|
70
|
-
width: var(--spacing-small);
|
|
71
|
-
height: var(--spacing-small);
|
|
72
|
-
border: 1px solid var(--border-standard);
|
|
73
|
-
border-radius: var(--radius-common);
|
|
74
|
-
background: var(--bg-input-standard);
|
|
75
|
-
color: var(--bg-input-standard);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
.checkbox span svg{
|
|
79
|
-
color: var(--bg-input-standard);
|
|
80
|
-
fill: var(--bg-input-standard);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
.checkbox:has(input:checked){
|
|
84
|
-
background: var(--color-primary);
|
|
85
|
-
border: 1px solid var(--color-primary);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
.checkbox:has(input:checked) span svg{
|
|
89
|
-
color: var(--text-active);
|
|
90
|
-
fill: var(--text-active);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
.radio{
|
|
94
|
-
position: relative;
|
|
95
|
-
width: var(--spacing-small);
|
|
96
|
-
height: var(--spacing-small);
|
|
97
|
-
border: 1px solid var(--border-standard);
|
|
98
|
-
background: var(--bg-input-standard);
|
|
99
|
-
color: var(--bg-input-standard);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
.radio::after{
|
|
103
|
-
content:'';
|
|
104
|
-
position:absolute;
|
|
105
|
-
left: 50%;
|
|
106
|
-
top: 50%;
|
|
107
|
-
transform: translate(-50%, -50%);
|
|
108
|
-
width: var(--spacing-common-y);
|
|
109
|
-
height: var(--spacing-common-y);
|
|
110
|
-
border-radius: var(--radius-circle);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
.radio:checked::after{
|
|
114
|
-
background: var(--color-primary);
|
|
115
|
-
}
|