sh-ui-cli 0.15.0 → 0.21.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 (162) hide show
  1. package/bin/sh-ui.mjs +6 -0
  2. package/data/changelog/versions.json +354 -0
  3. package/data/registry/flutter/foundation/sh_ui_tokens.dart +385 -0
  4. package/data/registry/flutter/registry.json +336 -0
  5. package/data/registry/flutter/widgets/sh_ui_accordion.dart +255 -0
  6. package/data/registry/flutter/widgets/sh_ui_app_shell.dart +267 -0
  7. package/data/registry/flutter/widgets/sh_ui_avatar.dart +95 -0
  8. package/data/registry/flutter/widgets/sh_ui_badge.dart +82 -0
  9. package/data/registry/flutter/widgets/sh_ui_breadcrumb.dart +107 -0
  10. package/data/registry/flutter/widgets/sh_ui_button.dart +201 -0
  11. package/data/registry/flutter/widgets/sh_ui_card.dart +159 -0
  12. package/data/registry/flutter/widgets/sh_ui_carousel.dart +204 -0
  13. package/data/registry/flutter/widgets/sh_ui_checkbox.dart +154 -0
  14. package/data/registry/flutter/widgets/sh_ui_color_picker.dart +264 -0
  15. package/data/registry/flutter/widgets/sh_ui_combobox.dart +614 -0
  16. package/data/registry/flutter/widgets/sh_ui_context_menu.dart +71 -0
  17. package/data/registry/flutter/widgets/sh_ui_date_picker.dart +648 -0
  18. package/data/registry/flutter/widgets/sh_ui_dialog.dart +567 -0
  19. package/data/registry/flutter/widgets/sh_ui_dropdown_menu.dart +251 -0
  20. package/data/registry/flutter/widgets/sh_ui_file_upload.dart +200 -0
  21. package/data/registry/flutter/widgets/sh_ui_header.dart +488 -0
  22. package/data/registry/flutter/widgets/sh_ui_input.dart +664 -0
  23. package/data/registry/flutter/widgets/sh_ui_label.dart +145 -0
  24. package/data/registry/flutter/widgets/sh_ui_menubar.dart +98 -0
  25. package/data/registry/flutter/widgets/sh_ui_pagination.dart +276 -0
  26. package/data/registry/flutter/widgets/sh_ui_popover.dart +248 -0
  27. package/data/registry/flutter/widgets/sh_ui_progress.dart +47 -0
  28. package/data/registry/flutter/widgets/sh_ui_radio.dart +108 -0
  29. package/data/registry/flutter/widgets/sh_ui_select.dart +904 -0
  30. package/data/registry/flutter/widgets/sh_ui_separator.dart +42 -0
  31. package/data/registry/flutter/widgets/sh_ui_sidebar.dart +1116 -0
  32. package/data/registry/flutter/widgets/sh_ui_skeleton.dart +129 -0
  33. package/data/registry/flutter/widgets/sh_ui_slider.dart +147 -0
  34. package/data/registry/flutter/widgets/sh_ui_spinner.dart +56 -0
  35. package/data/registry/flutter/widgets/sh_ui_switch.dart +109 -0
  36. package/data/registry/flutter/widgets/sh_ui_tabs.dart +329 -0
  37. package/data/registry/flutter/widgets/sh_ui_textarea.dart +126 -0
  38. package/data/registry/flutter/widgets/sh_ui_toast.dart +362 -0
  39. package/data/registry/flutter/widgets/sh_ui_toggle.dart +229 -0
  40. package/data/registry/flutter/widgets/sh_ui_tooltip.dart +62 -0
  41. package/data/registry/react/components/accordion/index.tsx +85 -0
  42. package/data/registry/react/components/accordion/styles.css +94 -0
  43. package/data/registry/react/components/animations/animations.css +51 -0
  44. package/data/registry/react/components/avatar/index.tsx +75 -0
  45. package/data/registry/react/components/avatar/styles.css +36 -0
  46. package/data/registry/react/components/badge/index.tsx +42 -0
  47. package/data/registry/react/components/badge/styles.css +57 -0
  48. package/data/registry/react/components/base/base.css +102 -0
  49. package/data/registry/react/components/breadcrumb/index.tsx +154 -0
  50. package/data/registry/react/components/breadcrumb/styles.css +82 -0
  51. package/data/registry/react/components/breakpoints/breakpoints.css +17 -0
  52. package/data/registry/react/components/button/index.tsx +47 -0
  53. package/data/registry/react/components/button/styles.css +93 -0
  54. package/data/registry/react/components/card/index.tsx +86 -0
  55. package/data/registry/react/components/card/styles.css +73 -0
  56. package/data/registry/react/components/carousel/index.tsx +432 -0
  57. package/data/registry/react/components/carousel/styles.css +155 -0
  58. package/data/registry/react/components/checkbox/index.tsx +98 -0
  59. package/data/registry/react/components/checkbox/styles.css +75 -0
  60. package/data/registry/react/components/code-panel/copy.tsx +56 -0
  61. package/data/registry/react/components/code-panel/index.tsx +193 -0
  62. package/data/registry/react/components/code-panel/styles.css +124 -0
  63. package/data/registry/react/components/color-picker/index.tsx +466 -0
  64. package/data/registry/react/components/color-picker/styles.css +166 -0
  65. package/data/registry/react/components/combobox/index.tsx +167 -0
  66. package/data/registry/react/components/combobox/styles.css +151 -0
  67. package/data/registry/react/components/context-menu/index.tsx +253 -0
  68. package/data/registry/react/components/context-menu/styles.css +140 -0
  69. package/data/registry/react/components/date-picker/index.tsx +757 -0
  70. package/data/registry/react/components/date-picker/styles.css +279 -0
  71. package/data/registry/react/components/dialog/index.tsx +97 -0
  72. package/data/registry/react/components/dialog/styles.css +127 -0
  73. package/data/registry/react/components/dropdown-menu/index.tsx +257 -0
  74. package/data/registry/react/components/dropdown-menu/styles.css +150 -0
  75. package/data/registry/react/components/file-upload/index.tsx +489 -0
  76. package/data/registry/react/components/file-upload/styles.css +170 -0
  77. package/data/registry/react/components/focus-ring/focus-ring.css +23 -0
  78. package/data/registry/react/components/form/context.ts +92 -0
  79. package/data/registry/react/components/form/field.test.tsx +230 -0
  80. package/data/registry/react/components/form/field.tsx +236 -0
  81. package/data/registry/react/components/form/focus-first-error.ts +54 -0
  82. package/data/registry/react/components/form/form.section.test.tsx +58 -0
  83. package/data/registry/react/components/form/form.test.tsx +146 -0
  84. package/data/registry/react/components/form/form.tsx +180 -0
  85. package/data/registry/react/components/form/index.tsx +61 -0
  86. package/data/registry/react/components/form/steps.test.tsx +106 -0
  87. package/data/registry/react/components/form/steps.tsx +193 -0
  88. package/data/registry/react/components/form/store.test.ts +206 -0
  89. package/data/registry/react/components/form/store.ts +318 -0
  90. package/data/registry/react/components/form/styles.css +47 -0
  91. package/data/registry/react/components/form/types.ts +104 -0
  92. package/data/registry/react/components/form/use-sh-ui-form.ts +15 -0
  93. package/data/registry/react/components/form/utils.test.ts +44 -0
  94. package/data/registry/react/components/form/utils.ts +49 -0
  95. package/data/registry/react/components/form/validation.test.ts +67 -0
  96. package/data/registry/react/components/form/validation.ts +64 -0
  97. package/data/registry/react/components/form-rhf/README.md +27 -0
  98. package/data/registry/react/components/form-rhf/index.tsx +289 -0
  99. package/data/registry/react/components/form-rhf/rhf.test.tsx +42 -0
  100. package/data/registry/react/components/form-tanstack/README.md +27 -0
  101. package/data/registry/react/components/form-tanstack/index.tsx +352 -0
  102. package/data/registry/react/components/form-tanstack/tanstack.test.tsx +45 -0
  103. package/data/registry/react/components/form-yup/README.md +22 -0
  104. package/data/registry/react/components/form-yup/index.tsx +50 -0
  105. package/data/registry/react/components/form-yup/yup.test.ts +27 -0
  106. package/data/registry/react/components/header/index.tsx +257 -0
  107. package/data/registry/react/components/header/styles.css +190 -0
  108. package/data/registry/react/components/input/index.tsx +517 -0
  109. package/data/registry/react/components/input/styles.css +203 -0
  110. package/data/registry/react/components/label/index.tsx +54 -0
  111. package/data/registry/react/components/label/styles.css +90 -0
  112. package/data/registry/react/components/menubar/index.tsx +34 -0
  113. package/data/registry/react/components/menubar/styles.css +45 -0
  114. package/data/registry/react/components/pagination/index.tsx +271 -0
  115. package/data/registry/react/components/pagination/styles.css +105 -0
  116. package/data/registry/react/components/popover/index.tsx +115 -0
  117. package/data/registry/react/components/popover/styles.css +65 -0
  118. package/data/registry/react/components/progress/index.tsx +56 -0
  119. package/data/registry/react/components/progress/styles.css +41 -0
  120. package/data/registry/react/components/radio/index.tsx +67 -0
  121. package/data/registry/react/components/radio/styles.css +80 -0
  122. package/data/registry/react/components/select/index.tsx +236 -0
  123. package/data/registry/react/components/select/styles.css +193 -0
  124. package/data/registry/react/components/separator/index.tsx +48 -0
  125. package/data/registry/react/components/separator/styles.css +15 -0
  126. package/data/registry/react/components/sidebar/index.tsx +1084 -0
  127. package/data/registry/react/components/sidebar/styles.css +502 -0
  128. package/data/registry/react/components/skeleton/index.tsx +24 -0
  129. package/data/registry/react/components/skeleton/styles.css +24 -0
  130. package/data/registry/react/components/slider/index.tsx +300 -0
  131. package/data/registry/react/components/slider/styles.css +64 -0
  132. package/data/registry/react/components/spinner/index.tsx +40 -0
  133. package/data/registry/react/components/spinner/styles.css +37 -0
  134. package/data/registry/react/components/switch/index.tsx +41 -0
  135. package/data/registry/react/components/switch/styles.css +83 -0
  136. package/data/registry/react/components/tabs/index.tsx +93 -0
  137. package/data/registry/react/components/tabs/styles.css +148 -0
  138. package/data/registry/react/components/textarea/index.tsx +25 -0
  139. package/data/registry/react/components/textarea/styles.css +54 -0
  140. package/data/registry/react/components/theme/index.tsx +91 -0
  141. package/data/registry/react/components/toast/index.tsx +257 -0
  142. package/data/registry/react/components/toast/styles.css +290 -0
  143. package/data/registry/react/components/toggle/index.tsx +133 -0
  144. package/data/registry/react/components/toggle/styles.css +85 -0
  145. package/data/registry/react/components/tooltip/index.tsx +85 -0
  146. package/data/registry/react/components/tooltip/styles.css +44 -0
  147. package/data/registry/react/components/z-index/z-index.css +16 -0
  148. package/data/registry/react/hooks/use-active-section.ts +104 -0
  149. package/data/registry/react/hooks/use-media-query.ts +27 -0
  150. package/data/registry/react/lib/cn.ts +39 -0
  151. package/data/registry/react/registry.json +835 -0
  152. package/data/summaries/flutter.json +42 -0
  153. package/data/summaries/react.json +50 -0
  154. package/data/tokens/build.mjs +553 -0
  155. package/data/tokens/src/primitives.json +146 -0
  156. package/data/tokens/src/semantic.json +146 -0
  157. package/package.json +9 -2
  158. package/src/add.mjs +13 -12
  159. package/src/list.mjs +3 -11
  160. package/src/mcp.mjs +308 -0
  161. package/src/paths.mjs +52 -0
  162. package/src/remove.mjs +4 -11
@@ -0,0 +1,432 @@
1
+ "use client";
2
+
3
+ import * as React from "react";
4
+ import "./styles.css";
5
+
6
+ function cx(...args: (string | undefined | false | null)[]) {
7
+ return args.filter(Boolean).join(" ");
8
+ }
9
+
10
+ type Orientation = "horizontal" | "vertical";
11
+
12
+ interface CarouselContextValue {
13
+ orientation: Orientation;
14
+ loop: boolean;
15
+ index: number;
16
+ count: number;
17
+ goTo: (i: number) => void;
18
+ goPrev: () => void;
19
+ goNext: () => void;
20
+ registerItem: () => () => void;
21
+ setContentEl: (el: HTMLDivElement | null) => void;
22
+ contentRef: React.RefObject<HTMLDivElement | null>;
23
+ }
24
+
25
+ const CarouselContext = React.createContext<CarouselContextValue | null>(null);
26
+
27
+ function useCarousel() {
28
+ const ctx = React.useContext(CarouselContext);
29
+ if (!ctx) {
30
+ throw new Error("Carousel parts must be used within <Carousel>");
31
+ }
32
+ return ctx;
33
+ }
34
+
35
+ /** 현재 캐러셀 상태를 읽을 수 있는 hook. 커스텀 컨트롤을 만들 때 사용. */
36
+ export function useCarouselState(): Pick<
37
+ CarouselContextValue,
38
+ "orientation" | "loop" | "index" | "count" | "goTo" | "goPrev" | "goNext"
39
+ > {
40
+ const { orientation, loop, index, count, goTo, goPrev, goNext } =
41
+ useCarousel();
42
+ return { orientation, loop, index, count, goTo, goPrev, goNext };
43
+ }
44
+
45
+ export interface CarouselProps extends React.HTMLAttributes<HTMLDivElement> {
46
+ /** 스크롤 방향. 기본 `horizontal`. */
47
+ orientation?: Orientation;
48
+ /** 끝에서 다시 처음으로 이어지는 무한 루프. */
49
+ loop?: boolean;
50
+ /** 자동 재생 간격(ms). `true`면 4000ms. */
51
+ autoPlay?: boolean | number;
52
+ /** 초기 인덱스. */
53
+ defaultIndex?: number;
54
+ /** 제어 모드 인덱스. */
55
+ index?: number;
56
+ /** 인덱스 변경 콜백. */
57
+ onIndexChange?: (index: number) => void;
58
+ }
59
+
60
+ /**
61
+ * 순수 CSS scroll-snap 기반 캐러셀. 터치 드래그·키보드 화살표·자동 재생을
62
+ * 지원하며, prefers-reduced-motion 환경에서는 스냅 전환이 즉시 이동한다.
63
+ *
64
+ * 구성 요소: Carousel / CarouselContent / CarouselItem /
65
+ * CarouselPrevious / CarouselNext / CarouselIndicators.
66
+ */
67
+ export const Carousel = React.forwardRef<HTMLDivElement, CarouselProps>(
68
+ (
69
+ {
70
+ className,
71
+ orientation = "horizontal",
72
+ loop = false,
73
+ autoPlay,
74
+ defaultIndex = 0,
75
+ index: controlledIndex,
76
+ onIndexChange,
77
+ children,
78
+ onKeyDown: userOnKeyDown,
79
+ ...props
80
+ },
81
+ ref,
82
+ ) => {
83
+ const isControlled = controlledIndex !== undefined;
84
+ const [uncontrolled, setUncontrolled] = React.useState(defaultIndex);
85
+ const index = isControlled ? controlledIndex : uncontrolled;
86
+
87
+ const [count, setCount] = React.useState(0);
88
+ const contentRef = React.useRef<HTMLDivElement | null>(null);
89
+ const scrollTargetRef = React.useRef<number | null>(null);
90
+
91
+ const setContentEl = React.useCallback((el: HTMLDivElement | null) => {
92
+ contentRef.current = el;
93
+ }, []);
94
+
95
+ const registerItem = React.useCallback(() => {
96
+ setCount((c) => c + 1);
97
+ return () => setCount((c) => Math.max(0, c - 1));
98
+ }, []);
99
+
100
+ const setIndex = React.useCallback(
101
+ (next: number) => {
102
+ if (!isControlled) setUncontrolled(next);
103
+ onIndexChange?.(next);
104
+ },
105
+ [isControlled, onIndexChange],
106
+ );
107
+
108
+ const clamp = React.useCallback(
109
+ (i: number) => {
110
+ if (count <= 0) return 0;
111
+ if (loop) {
112
+ return ((i % count) + count) % count;
113
+ }
114
+ return Math.max(0, Math.min(count - 1, i));
115
+ },
116
+ [count, loop],
117
+ );
118
+
119
+ const goTo = React.useCallback(
120
+ (i: number) => setIndex(clamp(i)),
121
+ [clamp, setIndex],
122
+ );
123
+ const goPrev = React.useCallback(
124
+ () => setIndex(clamp(index - 1)),
125
+ [clamp, index, setIndex],
126
+ );
127
+ const goNext = React.useCallback(
128
+ () => setIndex(clamp(index + 1)),
129
+ [clamp, index, setIndex],
130
+ );
131
+
132
+ // 인덱스 변경 시 프로그래매틱 스크롤
133
+ React.useEffect(() => {
134
+ const el = contentRef.current;
135
+ if (!el) return;
136
+ const child = el.children[index] as HTMLElement | undefined;
137
+ if (!child) return;
138
+ scrollTargetRef.current = index;
139
+ if (orientation === "horizontal") {
140
+ el.scrollTo({ left: child.offsetLeft, behavior: "smooth" });
141
+ } else {
142
+ el.scrollTo({ top: child.offsetTop, behavior: "smooth" });
143
+ }
144
+ }, [index, orientation, count]);
145
+
146
+ // 사용자 스와이프/스크롤 → 인덱스 동기화
147
+ React.useEffect(() => {
148
+ const el = contentRef.current;
149
+ if (!el) return;
150
+ let raf = 0;
151
+ const onScroll = () => {
152
+ cancelAnimationFrame(raf);
153
+ raf = requestAnimationFrame(() => {
154
+ const children = Array.from(el.children) as HTMLElement[];
155
+ if (children.length === 0) return;
156
+ const axis = orientation === "horizontal" ? "offsetLeft" : "offsetTop";
157
+ const scroll =
158
+ orientation === "horizontal" ? el.scrollLeft : el.scrollTop;
159
+ let nearest = 0;
160
+ let minDelta = Infinity;
161
+ children.forEach((c, i) => {
162
+ const d = Math.abs(c[axis] - scroll);
163
+ if (d < minDelta) {
164
+ minDelta = d;
165
+ nearest = i;
166
+ }
167
+ });
168
+ if (nearest !== index) {
169
+ // 프로그래매틱 이동 중이면 target 도착까지 무시
170
+ if (
171
+ scrollTargetRef.current !== null &&
172
+ nearest !== scrollTargetRef.current
173
+ ) {
174
+ return;
175
+ }
176
+ scrollTargetRef.current = null;
177
+ setIndex(nearest);
178
+ } else {
179
+ scrollTargetRef.current = null;
180
+ }
181
+ });
182
+ };
183
+ el.addEventListener("scroll", onScroll, { passive: true });
184
+ return () => {
185
+ cancelAnimationFrame(raf);
186
+ el.removeEventListener("scroll", onScroll);
187
+ };
188
+ }, [orientation, index, setIndex]);
189
+
190
+ // 자동 재생 — 호버·키보드 포커스 시 일시정지(WCAG 2.2.2).
191
+ React.useEffect(() => {
192
+ if (!autoPlay || count <= 1) return;
193
+ const delay = autoPlay === true ? 4000 : autoPlay;
194
+ const el = contentRef.current;
195
+ let paused = false;
196
+ const pause = () => (paused = true);
197
+ const resume = () => (paused = false);
198
+ el?.addEventListener("mouseenter", pause);
199
+ el?.addEventListener("mouseleave", resume);
200
+ el?.addEventListener("focusin", pause);
201
+ el?.addEventListener("focusout", resume);
202
+ const id = window.setInterval(() => {
203
+ if (paused) return;
204
+ setIndex(clamp(index + 1));
205
+ }, delay);
206
+ return () => {
207
+ window.clearInterval(id);
208
+ el?.removeEventListener("mouseenter", pause);
209
+ el?.removeEventListener("mouseleave", resume);
210
+ el?.removeEventListener("focusin", pause);
211
+ el?.removeEventListener("focusout", resume);
212
+ };
213
+ }, [autoPlay, count, index, clamp, setIndex]);
214
+
215
+ const onKeyDown = React.useCallback(
216
+ (event: React.KeyboardEvent<HTMLDivElement>) => {
217
+ userOnKeyDown?.(event);
218
+ if (event.defaultPrevented) return;
219
+ const prevKey = orientation === "horizontal" ? "ArrowLeft" : "ArrowUp";
220
+ const nextKey = orientation === "horizontal" ? "ArrowRight" : "ArrowDown";
221
+ if (event.key === prevKey) {
222
+ event.preventDefault();
223
+ goPrev();
224
+ } else if (event.key === nextKey) {
225
+ event.preventDefault();
226
+ goNext();
227
+ }
228
+ },
229
+ [orientation, goPrev, goNext, userOnKeyDown],
230
+ );
231
+
232
+ const value = React.useMemo<CarouselContextValue>(
233
+ () => ({
234
+ orientation,
235
+ loop,
236
+ index,
237
+ count,
238
+ goTo,
239
+ goPrev,
240
+ goNext,
241
+ registerItem,
242
+ setContentEl,
243
+ contentRef,
244
+ }),
245
+ [
246
+ orientation,
247
+ loop,
248
+ index,
249
+ count,
250
+ goTo,
251
+ goPrev,
252
+ goNext,
253
+ registerItem,
254
+ setContentEl,
255
+ ],
256
+ );
257
+
258
+ return (
259
+ <CarouselContext.Provider value={value}>
260
+ <div
261
+ ref={ref}
262
+ className={cx("sh-ui-carousel", className)}
263
+ data-orientation={orientation}
264
+ role="region"
265
+ aria-roledescription="carousel"
266
+ onKeyDown={onKeyDown}
267
+ {...props}
268
+ >
269
+ {children}
270
+ </div>
271
+ </CarouselContext.Provider>
272
+ );
273
+ },
274
+ );
275
+ Carousel.displayName = "Carousel";
276
+
277
+ export const CarouselContent = React.forwardRef<
278
+ HTMLDivElement,
279
+ React.HTMLAttributes<HTMLDivElement>
280
+ >(({ className, ...props }, ref) => {
281
+ const { orientation, setContentEl } = useCarousel();
282
+
283
+ const mergedRef = React.useCallback(
284
+ (el: HTMLDivElement | null) => {
285
+ setContentEl(el);
286
+ if (typeof ref === "function") ref(el);
287
+ else if (ref) (ref as React.MutableRefObject<HTMLDivElement | null>).current = el;
288
+ },
289
+ [ref, setContentEl],
290
+ );
291
+
292
+ return (
293
+ <div
294
+ ref={mergedRef}
295
+ className={cx("sh-ui-carousel__content", className)}
296
+ data-orientation={orientation}
297
+ {...props}
298
+ />
299
+ );
300
+ });
301
+ CarouselContent.displayName = "CarouselContent";
302
+
303
+ export const CarouselItem = React.forwardRef<
304
+ HTMLDivElement,
305
+ React.HTMLAttributes<HTMLDivElement>
306
+ >(({ className, ...props }, ref) => {
307
+ const { orientation, registerItem } = useCarousel();
308
+
309
+ React.useEffect(() => registerItem(), [registerItem]);
310
+
311
+ return (
312
+ <div
313
+ ref={ref}
314
+ role="group"
315
+ aria-roledescription="slide"
316
+ className={cx("sh-ui-carousel__item", className)}
317
+ data-orientation={orientation}
318
+ {...props}
319
+ />
320
+ );
321
+ });
322
+ CarouselItem.displayName = "CarouselItem";
323
+
324
+ export const CarouselPrevious = React.forwardRef<
325
+ HTMLButtonElement,
326
+ React.ButtonHTMLAttributes<HTMLButtonElement>
327
+ >(({ className, onClick, disabled, children, ...props }, ref) => {
328
+ const { goPrev, orientation, index, count, loop } = useCarousel();
329
+ const atStart = !loop && index <= 0;
330
+ return (
331
+ <button
332
+ ref={ref}
333
+ type="button"
334
+ aria-label="이전"
335
+ className={cx("sh-ui-carousel__nav", "sh-ui-carousel__nav--prev", className)}
336
+ data-orientation={orientation}
337
+ disabled={disabled || atStart || count === 0}
338
+ onClick={(e) => {
339
+ onClick?.(e);
340
+ if (!e.defaultPrevented) goPrev();
341
+ }}
342
+ {...props}
343
+ >
344
+ {children ?? (
345
+ <svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true">
346
+ <path
347
+ d={orientation === "horizontal" ? "M10 4l-4 4 4 4" : "M4 10l4-4 4 4"}
348
+ stroke="currentColor"
349
+ strokeWidth="1.5"
350
+ strokeLinecap="round"
351
+ strokeLinejoin="round"
352
+ />
353
+ </svg>
354
+ )}
355
+ </button>
356
+ );
357
+ });
358
+ CarouselPrevious.displayName = "CarouselPrevious";
359
+
360
+ export const CarouselNext = React.forwardRef<
361
+ HTMLButtonElement,
362
+ React.ButtonHTMLAttributes<HTMLButtonElement>
363
+ >(({ className, onClick, disabled, children, ...props }, ref) => {
364
+ const { goNext, orientation, index, count, loop } = useCarousel();
365
+ const atEnd = !loop && index >= count - 1;
366
+ return (
367
+ <button
368
+ ref={ref}
369
+ type="button"
370
+ aria-label="다음"
371
+ className={cx("sh-ui-carousel__nav", "sh-ui-carousel__nav--next", className)}
372
+ data-orientation={orientation}
373
+ disabled={disabled || atEnd || count === 0}
374
+ onClick={(e) => {
375
+ onClick?.(e);
376
+ if (!e.defaultPrevented) goNext();
377
+ }}
378
+ {...props}
379
+ >
380
+ {children ?? (
381
+ <svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true">
382
+ <path
383
+ d={orientation === "horizontal" ? "M6 4l4 4-4 4" : "M4 6l4 4 4-4"}
384
+ stroke="currentColor"
385
+ strokeWidth="1.5"
386
+ strokeLinecap="round"
387
+ strokeLinejoin="round"
388
+ />
389
+ </svg>
390
+ )}
391
+ </button>
392
+ );
393
+ });
394
+ CarouselNext.displayName = "CarouselNext";
395
+
396
+ export interface CarouselIndicatorsProps
397
+ extends React.HTMLAttributes<HTMLDivElement> {
398
+ /** 각 도트 버튼에 전달할 aria-label 빌더. */
399
+ labelFor?: (index: number) => string;
400
+ }
401
+
402
+ export const CarouselIndicators = React.forwardRef<
403
+ HTMLDivElement,
404
+ CarouselIndicatorsProps
405
+ >(({ className, labelFor, ...props }, ref) => {
406
+ const { count, index, goTo, orientation } = useCarousel();
407
+ if (count <= 0) return null;
408
+ return (
409
+ <div
410
+ ref={ref}
411
+ role="tablist"
412
+ aria-label="슬라이드 선택"
413
+ className={cx("sh-ui-carousel__indicators", className)}
414
+ data-orientation={orientation}
415
+ {...props}
416
+ >
417
+ {Array.from({ length: count }).map((_, i) => (
418
+ <button
419
+ key={i}
420
+ type="button"
421
+ role="tab"
422
+ aria-selected={i === index}
423
+ aria-label={labelFor ? labelFor(i) : `${i + 1}번 슬라이드`}
424
+ className="sh-ui-carousel__indicator"
425
+ data-active={i === index || undefined}
426
+ onClick={() => goTo(i)}
427
+ />
428
+ ))}
429
+ </div>
430
+ );
431
+ });
432
+ CarouselIndicators.displayName = "CarouselIndicators";
@@ -0,0 +1,155 @@
1
+ .sh-ui-carousel {
2
+ position: relative;
3
+ width: 100%;
4
+ }
5
+
6
+ .sh-ui-carousel__content {
7
+ display: flex;
8
+ gap: var(--space-4);
9
+ overflow-x: auto;
10
+ overflow-y: hidden;
11
+ scroll-snap-type: x mandatory;
12
+ scroll-behavior: smooth;
13
+ scrollbar-width: none;
14
+ -ms-overflow-style: none;
15
+ -webkit-overflow-scrolling: touch;
16
+ overscroll-behavior-inline: contain;
17
+ }
18
+
19
+ .sh-ui-carousel__content::-webkit-scrollbar {
20
+ display: none;
21
+ }
22
+
23
+ .sh-ui-carousel__content[data-orientation="vertical"] {
24
+ flex-direction: column;
25
+ overflow-x: hidden;
26
+ overflow-y: auto;
27
+ scroll-snap-type: y mandatory;
28
+ height: 20rem;
29
+ }
30
+
31
+ .sh-ui-carousel__item {
32
+ flex: 0 0 100%;
33
+ min-width: 0;
34
+ scroll-snap-align: start;
35
+ scroll-snap-stop: always;
36
+ }
37
+
38
+ .sh-ui-carousel__item[data-orientation="vertical"] {
39
+ flex-basis: auto;
40
+ }
41
+
42
+ /* 네비게이션 버튼 — 기본은 플로팅 원형. 원하면 className으로 덮어쓰기. */
43
+ .sh-ui-carousel__nav {
44
+ position: absolute;
45
+ top: 50%;
46
+ width: 2rem;
47
+ height: 2rem;
48
+ display: inline-flex;
49
+ align-items: center;
50
+ justify-content: center;
51
+ background: var(--background);
52
+ color: var(--foreground);
53
+ border: 1px solid var(--border);
54
+ border-radius: 999px;
55
+ cursor: pointer;
56
+ transform: translateY(-50%);
57
+ z-index: 1;
58
+ transition:
59
+ opacity var(--duration-fast) ease,
60
+ background var(--duration-fast) ease;
61
+ }
62
+
63
+ .sh-ui-carousel__nav:hover:not(:disabled) {
64
+ background: var(--background-muted);
65
+ }
66
+
67
+ .sh-ui-carousel__nav:focus-visible {
68
+ outline: var(--border-width-strong) solid var(--foreground);
69
+ outline-offset: 2px;
70
+ }
71
+
72
+ .sh-ui-carousel__nav:disabled {
73
+ opacity: 0.4;
74
+ cursor: not-allowed;
75
+ }
76
+
77
+ .sh-ui-carousel__nav--prev {
78
+ left: -1rem;
79
+ }
80
+
81
+ .sh-ui-carousel__nav--next {
82
+ right: -1rem;
83
+ }
84
+
85
+ .sh-ui-carousel__nav[data-orientation="vertical"] {
86
+ top: auto;
87
+ left: 50%;
88
+ transform: translateX(-50%);
89
+ }
90
+
91
+ .sh-ui-carousel__nav--prev[data-orientation="vertical"] {
92
+ top: -1rem;
93
+ left: 50%;
94
+ }
95
+
96
+ .sh-ui-carousel__nav--next[data-orientation="vertical"] {
97
+ bottom: -1rem;
98
+ top: auto;
99
+ left: 50%;
100
+ }
101
+
102
+ /* 인디케이터 */
103
+ .sh-ui-carousel__indicators {
104
+ display: flex;
105
+ justify-content: center;
106
+ align-items: center;
107
+ gap: var(--space-2);
108
+ margin-top: var(--space-3);
109
+ }
110
+
111
+ .sh-ui-carousel__indicators[data-orientation="vertical"] {
112
+ position: absolute;
113
+ top: 50%;
114
+ right: 0.5rem;
115
+ margin-top: 0;
116
+ flex-direction: column;
117
+ transform: translateY(-50%);
118
+ }
119
+
120
+ .sh-ui-carousel__indicator {
121
+ width: 0.5rem;
122
+ height: 0.5rem;
123
+ padding: 0;
124
+ background: var(--border);
125
+ border: none;
126
+ border-radius: 999px;
127
+ cursor: pointer;
128
+ transition:
129
+ background var(--duration-fast) ease,
130
+ transform var(--duration-fast) ease;
131
+ }
132
+
133
+ .sh-ui-carousel__indicator:hover {
134
+ background: var(--border-strong);
135
+ }
136
+
137
+ .sh-ui-carousel__indicator[data-active] {
138
+ background: var(--foreground);
139
+ transform: scale(1.2);
140
+ }
141
+
142
+ .sh-ui-carousel__indicator:focus-visible {
143
+ outline: var(--border-width-strong) solid var(--foreground);
144
+ outline-offset: 2px;
145
+ }
146
+
147
+ @media (prefers-reduced-motion: reduce) {
148
+ .sh-ui-carousel__content {
149
+ scroll-behavior: auto;
150
+ }
151
+ .sh-ui-carousel__nav,
152
+ .sh-ui-carousel__indicator {
153
+ transition: none;
154
+ }
155
+ }
@@ -0,0 +1,98 @@
1
+ import * as React from "react";
2
+ import { Checkbox as BaseCheckbox } from "@base-ui-components/react/checkbox";
3
+ import { CheckboxGroup as BaseCheckboxGroup } from "@base-ui-components/react/checkbox-group";
4
+ import "./styles.css";
5
+
6
+ function cx(...args: (string | undefined | false)[]) {
7
+ return args.filter(Boolean).join(" ");
8
+ }
9
+
10
+ /* ───────────── Checkbox ───────────── */
11
+
12
+ export type CheckboxProps = Omit<
13
+ React.ComponentPropsWithoutRef<typeof BaseCheckbox.Root>,
14
+ "className"
15
+ > & {
16
+ className?: string;
17
+ };
18
+
19
+ /**
20
+ * 폼 제출 시 함께 적용되는 다중 선택. `indeterminate`로 부분 선택 상태를
21
+ * 표현할 수 있고, 여러 개를 묶을 때는 `CheckboxGroup`으로 감싸 그룹 단위 상태를 관리한다.
22
+ */
23
+ export const Checkbox = React.forwardRef<HTMLElement, CheckboxProps>(
24
+ ({ className, ...props }, ref) => (
25
+ <BaseCheckbox.Root
26
+ ref={ref}
27
+ className={cx("sh-ui-checkbox", className)}
28
+ {...props}
29
+ >
30
+ <BaseCheckbox.Indicator className="sh-ui-checkbox__indicator">
31
+ {props.indeterminate ? <MinusIcon /> : <CheckIcon />}
32
+ </BaseCheckbox.Indicator>
33
+ </BaseCheckbox.Root>
34
+ ),
35
+ );
36
+ Checkbox.displayName = "Checkbox";
37
+
38
+ /* ───────────── CheckboxGroup ───────────── */
39
+
40
+ export type CheckboxGroupProps = Omit<
41
+ React.ComponentPropsWithoutRef<typeof BaseCheckboxGroup>,
42
+ "className"
43
+ > & {
44
+ className?: string;
45
+ /**
46
+ * 그룹 내 체크박스 배치 방향.
47
+ * - `vertical` — 세로 나열 (기본)
48
+ * - `horizontal` — 가로 나열. 짧은 라벨 2~3개에만 권장
49
+ *
50
+ * @default "vertical"
51
+ */
52
+ orientation?: "horizontal" | "vertical";
53
+ };
54
+
55
+ /**
56
+ * 여러 Checkbox를 묶는 컨테이너. `value`/`onValueChange`로 선택된 값 배열을 관리하고,
57
+ * `orientation`으로 가로/세로 배치를 정한다. 그룹 라벨은 외부 `<Label>`로 제공할 것.
58
+ */
59
+ export const CheckboxGroup = React.forwardRef<HTMLDivElement, CheckboxGroupProps>(
60
+ ({ className, orientation = "vertical", ...props }, ref) => (
61
+ <BaseCheckboxGroup
62
+ ref={ref}
63
+ className={cx("sh-ui-checkbox-group", className)}
64
+ data-orientation={orientation}
65
+ {...props}
66
+ />
67
+ ),
68
+ );
69
+ CheckboxGroup.displayName = "CheckboxGroup";
70
+
71
+ /* ───────────── Icons ───────────── */
72
+
73
+ function CheckIcon() {
74
+ return (
75
+ <svg viewBox="0 0 16 16" width="12" height="12" fill="none" aria-hidden>
76
+ <path
77
+ d="M3.5 8.5l3 3 6-7"
78
+ stroke="currentColor"
79
+ strokeWidth="2"
80
+ strokeLinecap="round"
81
+ strokeLinejoin="round"
82
+ />
83
+ </svg>
84
+ );
85
+ }
86
+
87
+ function MinusIcon() {
88
+ return (
89
+ <svg viewBox="0 0 16 16" width="12" height="12" fill="none" aria-hidden>
90
+ <path
91
+ d="M4 8h8"
92
+ stroke="currentColor"
93
+ strokeWidth="2"
94
+ strokeLinecap="round"
95
+ />
96
+ </svg>
97
+ );
98
+ }