@sonamu-kit/react-components 0.1.0 โ 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/index.d.ts +65 -0
- package/dist/components/ui/accordion.d.ts +7 -0
- package/dist/components/ui/alert-dialog.d.ts +20 -0
- package/dist/components/ui/alert.d.ts +8 -0
- package/dist/components/ui/aspect-ratio.d.ts +3 -0
- package/dist/components/ui/async-select.d.ts +36 -0
- package/dist/components/ui/avatar.d.ts +6 -0
- package/dist/components/ui/badge.d.ts +9 -0
- package/dist/components/ui/breadcrumb.d.ts +19 -0
- package/dist/components/ui/button.d.ts +13 -0
- package/dist/components/ui/calendar.d.ts +5 -0
- package/dist/components/ui/card.d.ts +9 -0
- package/dist/components/ui/carousel.d.ts +18 -0
- package/dist/components/ui/checkbox.d.ts +8 -0
- package/dist/components/ui/collapsible.d.ts +5 -0
- package/dist/components/ui/combobox.d.ts +20 -0
- package/dist/components/ui/command.d.ts +80 -0
- package/dist/components/ui/common-modal.d.ts +28 -0
- package/dist/components/ui/context-menu.d.ts +27 -0
- package/dist/components/ui/date-input.d.ts +7 -0
- package/dist/components/ui/date-picker.d.ts +26 -0
- package/dist/components/ui/date-selector-multiple.d.ts +38 -0
- package/dist/components/ui/dialog.d.ts +19 -0
- package/dist/components/ui/drawer.d.ts +22 -0
- package/dist/components/ui/dropdown-menu.d.ts +27 -0
- package/dist/components/ui/form.d.ts +23 -0
- package/dist/components/ui/hover-card.d.ts +6 -0
- package/dist/components/ui/image-uploader.d.ts +14 -0
- package/dist/components/ui/input-otp.d.ts +34 -0
- package/dist/components/ui/input.d.ts +7 -0
- package/dist/components/ui/label.d.ts +5 -0
- package/dist/components/ui/menubar.d.ts +28 -0
- package/dist/components/ui/month-picker-multiple.d.ts +41 -0
- package/dist/components/ui/multi-image-uploader.d.ts +15 -0
- package/dist/components/ui/multi-select.d.ts +229 -0
- package/dist/components/ui/navigation-menu.d.ts +12 -0
- package/dist/components/ui/pagination.d.ts +10 -0
- package/dist/components/ui/popover.d.ts +7 -0
- package/dist/components/ui/progress.d.ts +4 -0
- package/dist/components/ui/radio-group.d.ts +5 -0
- package/dist/components/ui/resizable.d.ts +23 -0
- package/dist/components/ui/scroll-area.d.ts +5 -0
- package/dist/components/ui/select.d.ts +20 -0
- package/dist/components/ui/separator.d.ts +4 -0
- package/dist/components/ui/sheet.d.ts +25 -0
- package/dist/components/ui/sidebar.d.ts +69 -0
- package/dist/components/ui/skeleton.d.ts +2 -0
- package/dist/components/ui/slider.d.ts +8 -0
- package/dist/components/ui/sonner.d.ts +4 -0
- package/dist/components/ui/switch.d.ts +8 -0
- package/dist/components/ui/table.d.ts +24 -0
- package/dist/components/ui/tabs.d.ts +7 -0
- package/dist/components/ui/textarea.d.ts +7 -0
- package/dist/components/ui/toast.d.ts +15 -0
- package/dist/components/ui/toaster.d.ts +1 -0
- package/dist/components/ui/toggle-group.d.ts +12 -0
- package/dist/components/ui/toggle.d.ts +12 -0
- package/dist/components/ui/tooltip.d.ts +7 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/use-toast.d.ts +44 -0
- package/dist/index.d.ts +3 -0
- package/dist/lib/caster.d.ts +3 -0
- package/dist/lib/helpers.d.ts +72 -0
- package/dist/lib/index.d.ts +6 -0
- package/{src/lib/lazy-upload.ts โ dist/lib/lazy-upload.d.ts} +1 -12
- package/dist/lib/use-mobile.d.ts +1 -0
- package/dist/lib/utils.d.ts +2 -0
- package/dist/react-components.es.js +28375 -0
- package/package.json +105 -76
- package/COMPONENTS_LIST.md +0 -106
- package/COMPONENTS_STATUS.md +0 -114
- package/HELPERS_GUIDE.md +0 -489
- package/MIGRATION_PLAN.md +0 -404
- package/SETUP_GUIDE.md +0 -125
- package/components.json +0 -21
- package/postcss.config.js +0 -6
- package/src/components/index.ts +0 -315
- package/src/components/ui/accordion.tsx +0 -54
- package/src/components/ui/alert-dialog.tsx +0 -115
- package/src/components/ui/alert.tsx +0 -49
- package/src/components/ui/aspect-ratio.tsx +0 -5
- package/src/components/ui/async-select.tsx +0 -186
- package/src/components/ui/avatar.tsx +0 -45
- package/src/components/ui/badge.tsx +0 -38
- package/src/components/ui/breadcrumb.tsx +0 -102
- package/src/components/ui/button.tsx +0 -54
- package/src/components/ui/calendar.tsx +0 -193
- package/src/components/ui/card.tsx +0 -65
- package/src/components/ui/carousel.tsx +0 -243
- package/src/components/ui/checkbox.tsx +0 -67
- package/src/components/ui/collapsible.tsx +0 -9
- package/src/components/ui/combobox.tsx +0 -135
- package/src/components/ui/command.tsx +0 -143
- package/src/components/ui/common-modal.tsx +0 -95
- package/src/components/ui/context-menu.tsx +0 -189
- package/src/components/ui/date-picker.tsx +0 -112
- package/src/components/ui/date-selector-multiple.tsx +0 -197
- package/src/components/ui/dialog.tsx +0 -104
- package/src/components/ui/drawer.tsx +0 -100
- package/src/components/ui/dropdown-menu.tsx +0 -189
- package/src/components/ui/form.tsx +0 -171
- package/src/components/ui/hover-card.tsx +0 -27
- package/src/components/ui/image-uploader.tsx +0 -251
- package/src/components/ui/input-otp.tsx +0 -69
- package/src/components/ui/input.tsx +0 -38
- package/src/components/ui/label.tsx +0 -19
- package/src/components/ui/menubar.tsx +0 -231
- package/src/components/ui/month-picker-multiple.tsx +0 -351
- package/src/components/ui/multi-image-uploader.tsx +0 -283
- package/src/components/ui/multi-select.tsx +0 -1143
- package/src/components/ui/navigation-menu.tsx +0 -120
- package/src/components/ui/pagination.tsx +0 -72
- package/src/components/ui/popover.tsx +0 -42
- package/src/components/ui/progress.tsx +0 -25
- package/src/components/ui/radio-group.tsx +0 -38
- package/src/components/ui/resizable.tsx +0 -42
- package/src/components/ui/scroll-area.tsx +0 -46
- package/src/components/ui/select.tsx +0 -235
- package/src/components/ui/separator.tsx +0 -24
- package/src/components/ui/sheet.tsx +0 -119
- package/src/components/ui/sidebar.tsx +0 -683
- package/src/components/ui/skeleton.tsx +0 -7
- package/src/components/ui/slider.tsx +0 -57
- package/src/components/ui/sonner.tsx +0 -39
- package/src/components/ui/switch.tsx +0 -63
- package/src/components/ui/table.tsx +0 -94
- package/src/components/ui/tabs.tsx +0 -53
- package/src/components/ui/textarea.tsx +0 -34
- package/src/components/ui/toast.tsx +0 -122
- package/src/components/ui/toaster.tsx +0 -29
- package/src/components/ui/toggle-group.tsx +0 -55
- package/src/components/ui/toggle.tsx +0 -41
- package/src/components/ui/tooltip.tsx +0 -28
- package/src/hooks/index.ts +0 -2
- package/src/hooks/use-toast.ts +0 -189
- package/src/icons.d.ts +0 -1
- package/src/index.ts +0 -4
- package/src/lib/caster.ts +0 -66
- package/src/lib/helpers.ts +0 -394
- package/src/lib/index.ts +0 -31
- package/src/lib/use-mobile.ts +0 -19
- package/src/lib/utils.ts +0 -6
- package/src/styles/globals.css +0 -658
- package/tailwind.config.ts +0 -8
- package/tsconfig.json +0 -31
- package/tsconfig.node.json +0 -11
package/HELPERS_GUIDE.md
DELETED
|
@@ -1,489 +0,0 @@
|
|
|
1
|
-
# shadcn/ui Helpers ์ฌ์ฉ ๊ฐ์ด๋
|
|
2
|
-
|
|
3
|
-
`@sonamu-kit/react-components`์ helpers๋ **semantic-ui-react์ shadcn/ui ๋ชจ๋ ์ง์**ํ๋ ๋ฒ์ฉ helper์
๋๋ค.
|
|
4
|
-
|
|
5
|
-
## โจ ํต์ฌ ํน์ง
|
|
6
|
-
|
|
7
|
-
- โ
**semantic-ui-react์ shadcn/ui ๋ชจ๋ ๋์ผํ๊ฒ ์ฌ์ฉ ๊ฐ๋ฅ**
|
|
8
|
-
- โ
**`{...register("field")}` ํจํด์ผ๋ก ๊ฐ๋จํ ์ฌ์ฉ**
|
|
9
|
-
- โ
**์ปดํฌ๋ํธ๋ณ onChange ์ฐจ์ด ์๋ ์ฒ๋ฆฌ**
|
|
10
|
-
- โ
**URL ์ฟผ๋ฆฌ ํ๋ผ๋ฏธํฐ ์๋ ์ฐ๋** (useListParams)
|
|
11
|
-
|
|
12
|
-
---
|
|
13
|
-
|
|
14
|
-
## ๐ฆ Import
|
|
15
|
-
|
|
16
|
-
```typescript
|
|
17
|
-
import { useTypeForm, useListParams } from "@sonamu-kit/react-components/lib";
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
---
|
|
21
|
-
|
|
22
|
-
## ๐ฏ useListParams
|
|
23
|
-
|
|
24
|
-
URL ์ฟผ๋ฆฌ ํ๋ผ๋ฏธํฐ์ ์๋ ์ฐ๋๋๋ ๋ฆฌ์คํธ ํ๋ผ๋ฏธํฐ ๊ด๋ฆฌ Hook
|
|
25
|
-
|
|
26
|
-
### shadcn/ui ์ฌ์ฉ๋ฒ
|
|
27
|
-
|
|
28
|
-
```typescript
|
|
29
|
-
import { useListParams } from "@sonamu-kit/react-components/lib";
|
|
30
|
-
import {
|
|
31
|
-
Select,
|
|
32
|
-
SelectTrigger,
|
|
33
|
-
SelectValue,
|
|
34
|
-
SelectContent,
|
|
35
|
-
SelectItem,
|
|
36
|
-
Input,
|
|
37
|
-
} from "@sonamu-kit/react-components/components";
|
|
38
|
-
import { z } from "zod";
|
|
39
|
-
|
|
40
|
-
// Zod ์คํค๋ง ์ ์
|
|
41
|
-
const FeedSiteListParams = z.object({
|
|
42
|
-
num: z.number(),
|
|
43
|
-
page: z.number(),
|
|
44
|
-
orderBy: z.string(),
|
|
45
|
-
search: z.string(),
|
|
46
|
-
keyword: z.string().optional(),
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
function FeedSiteList() {
|
|
50
|
-
const { listParams, register } = useListParams(FeedSiteListParams, {
|
|
51
|
-
num: 10,
|
|
52
|
-
page: 1,
|
|
53
|
-
orderBy: "id-desc",
|
|
54
|
-
search: "id",
|
|
55
|
-
keyword: "",
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
return (
|
|
59
|
-
<div>
|
|
60
|
-
{/* ๋ชจ๋ ์ปดํฌ๋ํธ์ register๋ฅผ ๊ทธ๋๋ก ์คํ๋ ๋ */}
|
|
61
|
-
|
|
62
|
-
{/* Search Type Select */}
|
|
63
|
-
<Select {...register("search")}>
|
|
64
|
-
<SelectTrigger>
|
|
65
|
-
<SelectValue />
|
|
66
|
-
</SelectTrigger>
|
|
67
|
-
<SelectContent>
|
|
68
|
-
<SelectItem value="id">Search ID</SelectItem>
|
|
69
|
-
<SelectItem value="title">Search Name</SelectItem>
|
|
70
|
-
</SelectContent>
|
|
71
|
-
</Select>
|
|
72
|
-
|
|
73
|
-
{/* Search Input */}
|
|
74
|
-
<Input {...register("keyword")} placeholder="Search..." />
|
|
75
|
-
|
|
76
|
-
{/* Order By Select */}
|
|
77
|
-
<Select {...register("orderBy")}>
|
|
78
|
-
<SelectTrigger>
|
|
79
|
-
<SelectValue />
|
|
80
|
-
</SelectTrigger>
|
|
81
|
-
<SelectContent>
|
|
82
|
-
<SelectItem value="id-desc">Recently</SelectItem>
|
|
83
|
-
<SelectItem value="id-asc">Oldest</SelectItem>
|
|
84
|
-
</SelectContent>
|
|
85
|
-
</Select>
|
|
86
|
-
</div>
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
### semantic-ui-react ์ฌ์ฉ๋ฒ
|
|
92
|
-
|
|
93
|
-
```typescript
|
|
94
|
-
import { useListParams } from "@sonamu-kit/react-components/lib";
|
|
95
|
-
import { FeedSiteSearchInput } from "src/components/feed-site/FeedSiteSearchInput";
|
|
96
|
-
import { FeedSiteOrderBySelect } from "src/components/feed-site/FeedSiteOrderBySelect";
|
|
97
|
-
|
|
98
|
-
function FeedSiteList() {
|
|
99
|
-
const { listParams, register } = useListParams(FeedSiteListParams, {
|
|
100
|
-
num: 12,
|
|
101
|
-
page: 1,
|
|
102
|
-
orderBy: "id-desc",
|
|
103
|
-
search: "id",
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
return (
|
|
107
|
-
<div>
|
|
108
|
-
{/* semantic-ui-react๋ ๋์ผํ๊ฒ ์ฌ์ฉ */}
|
|
109
|
-
<FeedSiteSearchInput
|
|
110
|
-
input={register("keyword")}
|
|
111
|
-
dropdown={register("search")}
|
|
112
|
-
/>
|
|
113
|
-
|
|
114
|
-
<FeedSiteOrderBySelect {...register("orderBy")} />
|
|
115
|
-
</div>
|
|
116
|
-
);
|
|
117
|
-
}
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
### API
|
|
121
|
-
|
|
122
|
-
#### `useListParams(schema, defaultValue, options?)`
|
|
123
|
-
|
|
124
|
-
**Parameters:**
|
|
125
|
-
|
|
126
|
-
- `schema`: Zod ์คํค๋ง
|
|
127
|
-
- `defaultValue`: ๊ธฐ๋ณธ๊ฐ
|
|
128
|
-
- `options`: (์ ํ)
|
|
129
|
-
- `disableSearchParams?: boolean` - URL ํ๋ผ๋ฏธํฐ ์ฐ๋ ๋นํ์ฑํ
|
|
130
|
-
|
|
131
|
-
**Returns:**
|
|
132
|
-
|
|
133
|
-
- `listParams`: ํ์ฌ ํ๋ผ๋ฏธํฐ ๊ฐ
|
|
134
|
-
- `setListParams`: ํ๋ผ๋ฏธํฐ ์ ์ฒด ์
๋ฐ์ดํธ
|
|
135
|
-
- `register(name)`: ์ปดํฌ๋ํธ์ ์ฐ๊ฒฐํ props ๋ฐํ
|
|
136
|
-
- `registerInput(name)`: Input ์ ์ฉ (ํ์ ์)
|
|
137
|
-
- `registerSelect(name)`: Select ์ ์ฉ (ํ์ ์)
|
|
138
|
-
- `registerCheckbox(name)`: Checkbox ์ ์ฉ (ํ์ ์)
|
|
139
|
-
- `updateParams(updates)`: ๋ถ๋ถ ์
๋ฐ์ดํธ
|
|
140
|
-
|
|
141
|
-
#### `register(name)` ๋ฐํ ๊ฐ
|
|
142
|
-
|
|
143
|
-
```typescript
|
|
144
|
-
{
|
|
145
|
-
name: string;
|
|
146
|
-
value: any;
|
|
147
|
-
checked: boolean;
|
|
148
|
-
// semantic-ui-react: onChange(e, { value })
|
|
149
|
-
// shadcn/ui Input: onChange(e)
|
|
150
|
-
onChange: (e: any, data?: { value: any; checked?: boolean }) => void;
|
|
151
|
-
// shadcn/ui Select: onValueChange(value)
|
|
152
|
-
onValueChange: (value: any) => void;
|
|
153
|
-
// shadcn/ui Checkbox: onCheckedChange(checked)
|
|
154
|
-
onCheckedChange: (checked: boolean) => void;
|
|
155
|
-
}
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
**ํต์ฌ**: ๋ชจ๋ ํธ๋ค๋ฌ๋ฅผ ๋์์ ์ ๊ณตํ๋ฏ๋ก, ๊ฐ ์ปดํฌ๋ํธ๊ฐ ์์ ์๊ฒ ํ์ํ ํธ๋ค๋ฌ๋ง ์ฌ์ฉํฉ๋๋ค.
|
|
159
|
-
|
|
160
|
-
---
|
|
161
|
-
|
|
162
|
-
## ๐ useTypeForm
|
|
163
|
-
|
|
164
|
-
Form ์ํ ๊ด๋ฆฌ ๋ฐ Validation Hook
|
|
165
|
-
|
|
166
|
-
### shadcn/ui ์ฌ์ฉ๋ฒ
|
|
167
|
-
|
|
168
|
-
```typescript
|
|
169
|
-
import { useTypeForm } from "@sonamu-kit/react-components/lib";
|
|
170
|
-
import {
|
|
171
|
-
Input,
|
|
172
|
-
Select,
|
|
173
|
-
SelectTrigger,
|
|
174
|
-
SelectValue,
|
|
175
|
-
SelectContent,
|
|
176
|
-
SelectItem,
|
|
177
|
-
Checkbox,
|
|
178
|
-
} from "@sonamu-kit/react-components/components";
|
|
179
|
-
import { z } from "zod";
|
|
180
|
-
|
|
181
|
-
// Zod ์คํค๋ง ์ ์
|
|
182
|
-
const FeedSiteSchema = z.object({
|
|
183
|
-
title: z.string(),
|
|
184
|
-
list_url: z.string().url(),
|
|
185
|
-
crawling_status: z.enum(["active", "stopped"]),
|
|
186
|
-
is_enabled: z.boolean(),
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
function FeedSiteForm() {
|
|
190
|
-
const { form, setForm, register, reset } = useTypeForm(FeedSiteSchema, {
|
|
191
|
-
title: "",
|
|
192
|
-
list_url: "",
|
|
193
|
-
crawling_status: "active",
|
|
194
|
-
is_enabled: true,
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
const handleSubmit = async () => {
|
|
198
|
-
try {
|
|
199
|
-
await FeedSiteService.save(form);
|
|
200
|
-
reset();
|
|
201
|
-
} catch (error) {
|
|
202
|
-
console.error(error);
|
|
203
|
-
}
|
|
204
|
-
};
|
|
205
|
-
|
|
206
|
-
return (
|
|
207
|
-
<form>
|
|
208
|
-
{/* ๋ชจ๋ ์ปดํฌ๋ํธ์ register๋ฅผ ๊ทธ๋๋ก ์คํ๋ ๋ */}
|
|
209
|
-
|
|
210
|
-
{/* Input */}
|
|
211
|
-
<Input {...register("title")} placeholder="Site Name" />
|
|
212
|
-
<Input {...register("list_url")} placeholder="https://example.com" />
|
|
213
|
-
|
|
214
|
-
{/* Select */}
|
|
215
|
-
<Select {...register("crawling_status")}>
|
|
216
|
-
<SelectTrigger>
|
|
217
|
-
<SelectValue />
|
|
218
|
-
</SelectTrigger>
|
|
219
|
-
<SelectContent>
|
|
220
|
-
<SelectItem value="active">Active</SelectItem>
|
|
221
|
-
<SelectItem value="stopped">Stopped</SelectItem>
|
|
222
|
-
</SelectContent>
|
|
223
|
-
</Select>
|
|
224
|
-
|
|
225
|
-
{/* Checkbox */}
|
|
226
|
-
<Checkbox {...register("is_enabled")} />
|
|
227
|
-
|
|
228
|
-
<Button onClick={handleSubmit}>Save</Button>
|
|
229
|
-
<Button onClick={reset}>Reset</Button>
|
|
230
|
-
</form>
|
|
231
|
-
);
|
|
232
|
-
}
|
|
233
|
-
```
|
|
234
|
-
|
|
235
|
-
### semantic-ui-react ์ฌ์ฉ๋ฒ
|
|
236
|
-
|
|
237
|
-
```typescript
|
|
238
|
-
import { useTypeForm } from "@sonamu-kit/react-components/lib";
|
|
239
|
-
import { Form, Input, Dropdown, Checkbox } from "semantic-ui-react";
|
|
240
|
-
|
|
241
|
-
function FeedSiteForm() {
|
|
242
|
-
const { form, setForm, register, reset } = useTypeForm(
|
|
243
|
-
FeedSiteSchema,
|
|
244
|
-
defaultValue
|
|
245
|
-
);
|
|
246
|
-
|
|
247
|
-
return (
|
|
248
|
-
<Form>
|
|
249
|
-
{/* semantic-ui-react๋ ๋์ผํ๊ฒ ์ฌ์ฉ */}
|
|
250
|
-
<Form.Field>
|
|
251
|
-
<label>Site Name</label>
|
|
252
|
-
<Input {...register("title")} />
|
|
253
|
-
</Form.Field>
|
|
254
|
-
|
|
255
|
-
<Form.Field>
|
|
256
|
-
<label>Status</label>
|
|
257
|
-
<Dropdown
|
|
258
|
-
{...register("crawling_status")}
|
|
259
|
-
options={[
|
|
260
|
-
{ key: "active", value: "active", text: "Active" },
|
|
261
|
-
{ key: "stopped", value: "stopped", text: "Stopped" },
|
|
262
|
-
]}
|
|
263
|
-
/>
|
|
264
|
-
</Form.Field>
|
|
265
|
-
|
|
266
|
-
<Form.Field>
|
|
267
|
-
<Checkbox {...register("is_enabled")} label="Enabled" />
|
|
268
|
-
</Form.Field>
|
|
269
|
-
</Form>
|
|
270
|
-
);
|
|
271
|
-
}
|
|
272
|
-
```
|
|
273
|
-
|
|
274
|
-
### API
|
|
275
|
-
|
|
276
|
-
#### `useTypeForm(schema, defaultValue)`
|
|
277
|
-
|
|
278
|
-
**Parameters:**
|
|
279
|
-
|
|
280
|
-
- `schema`: Zod ์คํค๋ง
|
|
281
|
-
- `defaultValue`: ๊ธฐ๋ณธ๊ฐ
|
|
282
|
-
|
|
283
|
-
**Returns:**
|
|
284
|
-
|
|
285
|
-
- `form`: ํ์ฌ form ์ํ
|
|
286
|
-
- `setForm`: form ์ํ ์
๋ฐ์ดํธ
|
|
287
|
-
- `register(path)`: ์ปดํฌ๋ํธ์ ์ฐ๊ฒฐ (๋ฒ์ฉ)
|
|
288
|
-
- `registerInput(path)`: Input/Textarea ์ ์ฉ
|
|
289
|
-
- `registerSelect(path)`: Select/RadioGroup ์ ์ฉ
|
|
290
|
-
- `registerCheckbox(path)`: Checkbox/Switch ์ ์ฉ
|
|
291
|
-
- `addError(path, message)`: ์๋ฌ ์ถ๊ฐ
|
|
292
|
-
- `removeError(path)`: ์๋ฌ ์ ๊ฑฐ
|
|
293
|
-
- `clearError()`: ๋ชจ๋ ์๋ฌ ์ ๊ฑฐ
|
|
294
|
-
- `reset()`: ์ด๊ธฐ๊ฐ์ผ๋ก ๋ฆฌ์
|
|
295
|
-
|
|
296
|
-
---
|
|
297
|
-
|
|
298
|
-
## ๐ ๋ด๋ถ ๋์ ์๋ฆฌ
|
|
299
|
-
|
|
300
|
-
### ๋ฌธ์ : shadcn/ui์ semantic-ui-react์ onChange ์ฐจ์ด
|
|
301
|
-
|
|
302
|
-
**semantic-ui-react** (ํต์ผ๋ ํจํด):
|
|
303
|
-
|
|
304
|
-
```typescript
|
|
305
|
-
onChange={(e, { value }) => setValue(value)}
|
|
306
|
-
```
|
|
307
|
-
|
|
308
|
-
**shadcn/ui** (์ปดํฌ๋ํธ๋ณ ๋ค๋ฅธ ํจํด):
|
|
309
|
-
|
|
310
|
-
- `Input`: `onChange={(e) => setValue(e.target.value)}`
|
|
311
|
-
- `Select`: `onValueChange={(value) => setValue(value)}`
|
|
312
|
-
- `Checkbox`: `onCheckedChange={(checked) => setChecked(checked)}`
|
|
313
|
-
|
|
314
|
-
### ํด๊ฒฐ: ๋ชจ๋ ํธ๋ค๋ฌ๋ฅผ ๋์์ ์ ๊ณต
|
|
315
|
-
|
|
316
|
-
`register()`๊ฐ ๋ฐํํ๋ ๊ฐ์ฒด๋ **๋ชจ๋ ํธ๋ค๋ฌ๋ฅผ ํฌํจ**ํฉ๋๋ค:
|
|
317
|
-
|
|
318
|
-
```typescript
|
|
319
|
-
{
|
|
320
|
-
name: "field",
|
|
321
|
-
value: "...",
|
|
322
|
-
checked: true/false,
|
|
323
|
-
onChange: (e, data?) => { /* ๋ฒ์ฉ ํธ๋ค๋ฌ */ },
|
|
324
|
-
onValueChange: (value) => { /* Select์ฉ */ },
|
|
325
|
-
onCheckedChange: (checked) => { /* Checkbox์ฉ */ },
|
|
326
|
-
}
|
|
327
|
-
```
|
|
328
|
-
|
|
329
|
-
์ด๋ฅผ `{...register("field")}`๋ก ์คํ๋ ๋ํ๋ฉด:
|
|
330
|
-
|
|
331
|
-
- `Input`์ `onChange`๋ง ์ฌ์ฉ
|
|
332
|
-
- `Select`๋ `onValueChange`๋ง ์ฌ์ฉ
|
|
333
|
-
- `Checkbox`๋ `onCheckedChange`๋ง ์ฌ์ฉ
|
|
334
|
-
|
|
335
|
-
๊ฐ ์ปดํฌ๋ํธ๊ฐ ์์ ์๊ฒ ํ์ํ ํธ๋ค๋ฌ๋ง ์ ํ์ ์ผ๋ก ์ฌ์ฉํ๊ฒ ๋ฉ๋๋ค! ๐
|
|
336
|
-
|
|
337
|
-
---
|
|
338
|
-
|
|
339
|
-
## ๐ก ์ฌ์ฉ ํ
|
|
340
|
-
|
|
341
|
-
### 1. ๊ฐ๋จํ ์ฌ์ฉ๋ฒ
|
|
342
|
-
|
|
343
|
-
```typescript
|
|
344
|
-
// โ
์ด๋ ๊ฒ ๊ฐ๋จํ๊ฒ ์ฌ์ฉํ์ธ์
|
|
345
|
-
<Input {...register("keyword")} />
|
|
346
|
-
<Select {...register("orderBy")}>...</Select>
|
|
347
|
-
<Checkbox {...register("isActive")} />
|
|
348
|
-
|
|
349
|
-
// โ ๋ณต์กํ๊ฒ ์ฌ์ฉํ ํ์ ์์
|
|
350
|
-
<Input
|
|
351
|
-
value={register("keyword").value}
|
|
352
|
-
onChange={(e) => register("keyword").onChange(e, { value: e.target.value })}
|
|
353
|
-
/>
|
|
354
|
-
```
|
|
355
|
-
|
|
356
|
-
### 2. semantic-ui-react ํธํ
|
|
357
|
-
|
|
358
|
-
```typescript
|
|
359
|
-
// FeedSiteSearchInput ๊ฐ์ ์ปค์คํ
์ปดํฌ๋ํธ
|
|
360
|
-
<FeedSiteSearchInput
|
|
361
|
-
input={register("keyword")}
|
|
362
|
-
dropdown={register("search")}
|
|
363
|
-
/>
|
|
364
|
-
|
|
365
|
-
// ๊ธฐ๋ณธ semantic-ui-react ์ปดํฌ๋ํธ
|
|
366
|
-
<Dropdown {...register("category")} options={options} />
|
|
367
|
-
```
|
|
368
|
-
|
|
369
|
-
### 3. URL ํ๋ผ๋ฏธํฐ ์๋ ์ฐ๋
|
|
370
|
-
|
|
371
|
-
```typescript
|
|
372
|
-
const { listParams } = useListParams(Schema, defaultValue);
|
|
373
|
-
|
|
374
|
-
// URL: /admin/feed-sites?keyword=test&search=title
|
|
375
|
-
console.log(listParams.keyword); // "test"
|
|
376
|
-
console.log(listParams.search); // "title"
|
|
377
|
-
|
|
378
|
-
// register๋ก Input์ ๋ณ๊ฒฝํ๋ฉด URL๋ ์๋์ผ๋ก ์
๋ฐ์ดํธ๋จ
|
|
379
|
-
<Input {...register("keyword")} />;
|
|
380
|
-
```
|
|
381
|
-
|
|
382
|
-
### 4. ์ง์ ๊ฐ ์
๋ฐ์ดํธ
|
|
383
|
-
|
|
384
|
-
```typescript
|
|
385
|
-
const { listParams, updateParams } = useListParams(Schema, defaultValue);
|
|
386
|
-
|
|
387
|
-
// ํ์ด์ง๋ค์ด์
๋ฑ์์ ์ง์ ์
๋ฐ์ดํธ
|
|
388
|
-
updateParams({ page: 2 });
|
|
389
|
-
|
|
390
|
-
// ๋๋
|
|
391
|
-
setListParams({ ...listParams, page: 2 });
|
|
392
|
-
```
|
|
393
|
-
|
|
394
|
-
---
|
|
395
|
-
|
|
396
|
-
## ๐ฏ ์ค์ ์์
|
|
397
|
-
|
|
398
|
-
### ์์ ํ Feed Sites ๋ฆฌ์คํธ ํ์ด์ง
|
|
399
|
-
|
|
400
|
-
`src/pages/admin/feed-sites/index-ui.tsx` ์ฐธ๊ณ
|
|
401
|
-
|
|
402
|
-
```typescript
|
|
403
|
-
import { useListParams } from "@sonamu-kit/react-componentslib";
|
|
404
|
-
import {
|
|
405
|
-
Select,
|
|
406
|
-
SelectTrigger,
|
|
407
|
-
SelectValue,
|
|
408
|
-
SelectContent,
|
|
409
|
-
SelectItem,
|
|
410
|
-
Input,
|
|
411
|
-
} from "@sonamu-kit/react-components/components";
|
|
412
|
-
import { FeedSiteService } from "src/services/feed-site/feed-site.service";
|
|
413
|
-
import { FeedSiteListParams } from "src/services/feed-site/feed-site.types";
|
|
414
|
-
|
|
415
|
-
function FeedSiteList() {
|
|
416
|
-
// ๋ฆฌ์คํธ ํ๋ผ๋ฏธํฐ ๊ด๋ฆฌ
|
|
417
|
-
const { listParams, register } = useListParams(FeedSiteListParams, {
|
|
418
|
-
num: 10,
|
|
419
|
-
page: 1,
|
|
420
|
-
orderBy: "id-desc",
|
|
421
|
-
search: "id",
|
|
422
|
-
keyword: "",
|
|
423
|
-
});
|
|
424
|
-
|
|
425
|
-
// API ํธ์ถ (listParams๊ฐ ๋ณ๊ฒฝ๋๋ฉด ์๋์ผ๋ก ์ฌํธ์ถ)
|
|
426
|
-
const { data, mutate, isLoading } = FeedSiteService.useFeedSites(
|
|
427
|
-
"A",
|
|
428
|
-
listParams
|
|
429
|
-
);
|
|
430
|
-
const { rows, total } = data ?? {};
|
|
431
|
-
|
|
432
|
-
return (
|
|
433
|
-
<div>
|
|
434
|
-
{/* ํํฐ ์์ญ */}
|
|
435
|
-
<div className="filters">
|
|
436
|
-
<Select {...register("search")}>
|
|
437
|
-
<SelectTrigger>
|
|
438
|
-
<SelectValue />
|
|
439
|
-
</SelectTrigger>
|
|
440
|
-
<SelectContent>
|
|
441
|
-
<SelectItem value="id">Search ID</SelectItem>
|
|
442
|
-
<SelectItem value="title">Search Name</SelectItem>
|
|
443
|
-
</SelectContent>
|
|
444
|
-
</Select>
|
|
445
|
-
|
|
446
|
-
<Input {...register("keyword")} placeholder="Search..." />
|
|
447
|
-
|
|
448
|
-
<Select {...register("orderBy")}>
|
|
449
|
-
<SelectTrigger>
|
|
450
|
-
<SelectValue />
|
|
451
|
-
</SelectTrigger>
|
|
452
|
-
<SelectContent>
|
|
453
|
-
<SelectItem value="id-desc">Recently</SelectItem>
|
|
454
|
-
<SelectItem value="id-asc">Oldest</SelectItem>
|
|
455
|
-
</SelectContent>
|
|
456
|
-
</Select>
|
|
457
|
-
</div>
|
|
458
|
-
|
|
459
|
-
{/* ํ
์ด๋ธ */}
|
|
460
|
-
<Table>
|
|
461
|
-
<TableBody>
|
|
462
|
-
{rows?.map((row) => (
|
|
463
|
-
<TableRow key={row.id}>
|
|
464
|
-
<TableCell>{row.title}</TableCell>
|
|
465
|
-
<TableCell>{row.list_url}</TableCell>
|
|
466
|
-
</TableRow>
|
|
467
|
-
))}
|
|
468
|
-
</TableBody>
|
|
469
|
-
</Table>
|
|
470
|
-
|
|
471
|
-
{/* ํ์ด์ง๋ค์ด์
*/}
|
|
472
|
-
<Pagination
|
|
473
|
-
{...register("page")}
|
|
474
|
-
totalPages={Math.ceil(total / listParams.num)}
|
|
475
|
-
/>
|
|
476
|
-
</div>
|
|
477
|
-
);
|
|
478
|
-
}
|
|
479
|
-
```
|
|
480
|
-
|
|
481
|
-
---
|
|
482
|
-
|
|
483
|
-
## ๐ ๋ ์์๋ณด๊ธฐ
|
|
484
|
-
|
|
485
|
-
- [shadcn/ui ๊ณต์ ๋ฌธ์](https://ui.shadcn.com)
|
|
486
|
-
- [MIGRATION_PLAN.md](./MIGRATION_PLAN.md) - ์ ์ฒด ๋ง์ด๊ทธ๋ ์ด์
๊ณํ
|
|
487
|
-
- [COMPONENTS_LIST.md](./COMPONENTS_LIST.md) - ์ฌ์ฉ ๊ฐ๋ฅํ ์ปดํฌ๋ํธ ๋ชฉ๋ก
|
|
488
|
-
- `src/pages/admin/feed-sites/index-ui.tsx` - ์ค์ ๊ตฌํ ์์ (shadcn/ui)
|
|
489
|
-
- `src/pages/admin/feed-sites/index.tsx` - ์ค์ ๊ตฌํ ์์ (semantic-ui-react)
|