@musecat/uikit 0.1.1

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 (180) hide show
  1. package/LICENSE +9 -0
  2. package/README.md +51 -0
  3. package/index.ts +78 -0
  4. package/package.json +103 -0
  5. package/packages/Components/Box/Box.tsx +173 -0
  6. package/packages/Components/Box/Box.types.ts +48 -0
  7. package/packages/Components/Button/Button.tsx +275 -0
  8. package/packages/Components/Button/Button.types.ts +44 -0
  9. package/packages/Components/Card/Card.default.tsx +180 -0
  10. package/packages/Components/Card/Card.foldable.tsx +383 -0
  11. package/packages/Components/Card/Card.module.scss +23 -0
  12. package/packages/Components/Card/Card.tsx +8 -0
  13. package/packages/Components/Card/Card.types.ts +91 -0
  14. package/packages/Components/Card/Card.utils.ts +66 -0
  15. package/packages/Components/Checkbox/Checkbox.module.scss +11 -0
  16. package/packages/Components/Checkbox/Checkbox.tsx +104 -0
  17. package/packages/Components/Checkbox/Checkbox.types.ts +24 -0
  18. package/packages/Components/CodeBox/CodeBox.copy.tsx +43 -0
  19. package/packages/Components/CodeBox/CodeBox.module.scss +72 -0
  20. package/packages/Components/CodeBox/CodeBox.tsx +91 -0
  21. package/packages/Components/CodeBox/CodeBox.types.ts +17 -0
  22. package/packages/Components/ContextMenu/ContextMenu.module.scss +8 -0
  23. package/packages/Components/ContextMenu/ContextMenu.options.tsx +126 -0
  24. package/packages/Components/ContextMenu/ContextMenu.tsx +381 -0
  25. package/packages/Components/ContextMenu/ContextMenu.types.ts +46 -0
  26. package/packages/Components/ContributionGraph/ContributionGraph.module.scss +42 -0
  27. package/packages/Components/ContributionGraph/ContributionGraph.tsx +454 -0
  28. package/packages/Components/ContributionGraph/ContributionGraph.types.ts +27 -0
  29. package/packages/Components/DatePicker/DatePicker.calendar.tsx +161 -0
  30. package/packages/Components/DatePicker/DatePicker.core.tsx +582 -0
  31. package/packages/Components/DatePicker/DatePicker.module.scss +26 -0
  32. package/packages/Components/DatePicker/DatePicker.tsx +786 -0
  33. package/packages/Components/DatePicker/DatePicker.types.ts +36 -0
  34. package/packages/Components/DatePicker/DatePicker.utils.ts +80 -0
  35. package/packages/Components/DatePicker/hooks/useCalendar.ts +61 -0
  36. package/packages/Components/DatePicker/hooks/useSelection.ts +208 -0
  37. package/packages/Components/Divider/Divider.tsx +46 -0
  38. package/packages/Components/Divider/Divider.types.ts +12 -0
  39. package/packages/Components/Header/Header.module.scss +74 -0
  40. package/packages/Components/Header/Header.tsx +47 -0
  41. package/packages/Components/Header/Header.types.ts +8 -0
  42. package/packages/Components/Icon/Icon.group.tsx +122 -0
  43. package/packages/Components/Icon/Icon.group.types.ts +20 -0
  44. package/packages/Components/Icon/Icon.tsx +341 -0
  45. package/packages/Components/Icon/Icon.types.ts +59 -0
  46. package/packages/Components/Icon/SVG/data.tsx +232 -0
  47. package/packages/Components/Input/Input.module.scss +5 -0
  48. package/packages/Components/Input/Input.tsx +87 -0
  49. package/packages/Components/Input/Input.types.ts +14 -0
  50. package/packages/Components/Label/Label.module.scss +19 -0
  51. package/packages/Components/Label/Label.tsx +115 -0
  52. package/packages/Components/Label/Label.types.ts +28 -0
  53. package/packages/Components/Layout/Layout.docs.module.scss +42 -0
  54. package/packages/Components/Layout/Layout.docs.tsx +150 -0
  55. package/packages/Components/Layout/Layout.docs.types.ts +18 -0
  56. package/packages/Components/Layout/Layout.module.scss +91 -0
  57. package/packages/Components/Layout/Layout.tsx +306 -0
  58. package/packages/Components/Layout/Layout.types.ts +71 -0
  59. package/packages/Components/Maps/OSM/MapOSM.module.scss +11 -0
  60. package/packages/Components/Maps/OSM/MapOSM.shared.ts +121 -0
  61. package/packages/Components/Maps/OSM/MapOSM.tsx +279 -0
  62. package/packages/Components/Maps/OSM/MapOSM.types.ts +18 -0
  63. package/packages/Components/Nav/Nav.module.scss +137 -0
  64. package/packages/Components/Nav/Nav.tsx +304 -0
  65. package/packages/Components/Nav/Nav.types.ts +32 -0
  66. package/packages/Components/Nav/hooks/useNavDrag.ts +374 -0
  67. package/packages/Components/Nav/hooks/useNavIndicator.ts +137 -0
  68. package/packages/Components/Pagination/Pagination.tsx +254 -0
  69. package/packages/Components/Pagination/Pagination.types.ts +18 -0
  70. package/packages/Components/Pill/Pill.tsx +127 -0
  71. package/packages/Components/Pill/Pill.types.ts +33 -0
  72. package/packages/Components/Profile/Profile.shared.ts +74 -0
  73. package/packages/Components/Profile/Profile.tsx +382 -0
  74. package/packages/Components/Profile/Profile.types.ts +55 -0
  75. package/packages/Components/Progress/Progress.module.scss +15 -0
  76. package/packages/Components/Progress/Progress.tsx +88 -0
  77. package/packages/Components/Progress/Progress.types.ts +22 -0
  78. package/packages/Components/Radio/Radio.module.scss +11 -0
  79. package/packages/Components/Radio/Radio.tsx +121 -0
  80. package/packages/Components/Radio/Radio.types.ts +20 -0
  81. package/packages/Components/Select/Select.keyboard.tsx +76 -0
  82. package/packages/Components/Select/Select.trigger.tsx +88 -0
  83. package/packages/Components/Select/Select.tsx +11 -0
  84. package/packages/Components/Select/Select.types.ts +38 -0
  85. package/packages/Components/Select/Select.utils.ts +84 -0
  86. package/packages/Components/Select/hooks/useSelectNavigation.ts +461 -0
  87. package/packages/Components/Select/hooks/useSelectSelection.ts +142 -0
  88. package/packages/Components/Select/hooks/useSelectState.ts +314 -0
  89. package/packages/Components/Select/select.control.tsx +228 -0
  90. package/packages/Components/Select/select.inner.tsx +312 -0
  91. package/packages/Components/Skeleton/Skeleton.tsx +30 -0
  92. package/packages/Components/Skeleton/Skeleton.types.ts +12 -0
  93. package/packages/Components/Spinner/Spinner.module.scss +78 -0
  94. package/packages/Components/Spinner/Spinner.tsx +125 -0
  95. package/packages/Components/Spinner/Spinner.types.ts +19 -0
  96. package/packages/Components/Text/Text.module.scss +7 -0
  97. package/packages/Components/Text/Text.tsx +49 -0
  98. package/packages/Components/Text/Text.types.ts +33 -0
  99. package/packages/Components/TimePicker/TimePicker.core.tsx +448 -0
  100. package/packages/Components/TimePicker/TimePicker.module.scss +30 -0
  101. package/packages/Components/TimePicker/TimePicker.tsx +511 -0
  102. package/packages/Components/TimePicker/TimePicker.types.ts +22 -0
  103. package/packages/Components/Timeline/Timeline.tsx +111 -0
  104. package/packages/Components/Timeline/Timeline.types.ts +23 -0
  105. package/packages/Components/Title/Title.tsx +305 -0
  106. package/packages/Components/Title/Title.types.ts +64 -0
  107. package/packages/Components/Toggle/Toggle.module.scss +32 -0
  108. package/packages/Components/Toggle/Toggle.tsx +272 -0
  109. package/packages/Components/Toggle/Toggle.types.ts +17 -0
  110. package/packages/Components/Tooltip/Tooltip.module.scss +44 -0
  111. package/packages/Components/Tooltip/Tooltip.tsx +340 -0
  112. package/packages/Components/Tooltip/Tooltip.types.ts +38 -0
  113. package/packages/Frameworks/Dialog/Dialog.background.tsx +88 -0
  114. package/packages/Frameworks/Dialog/Dialog.boot.tsx +32 -0
  115. package/packages/Frameworks/Dialog/Dialog.store.ts +199 -0
  116. package/packages/Frameworks/Dialog/Dialog.tsx +185 -0
  117. package/packages/Frameworks/Dialog/Dialog.types.ts +264 -0
  118. package/packages/Frameworks/Dialog/Dialog.utils.ts +22 -0
  119. package/packages/Frameworks/Dialog/contents/Dialog.footer.tsx +79 -0
  120. package/packages/Frameworks/Dialog/contents/Dialog.funnel.tsx +260 -0
  121. package/packages/Frameworks/Dialog/contents/Dialog.header.tsx +137 -0
  122. package/packages/Frameworks/Dialog/hooks/useDialogPosition.ts +298 -0
  123. package/packages/Frameworks/Dialog/hooks/useSheetDrag.ts +325 -0
  124. package/packages/Frameworks/Dialog/hooks/useSheetGeometry.ts +201 -0
  125. package/packages/Frameworks/Dialog/hooks/useSheetProgressive.ts +98 -0
  126. package/packages/Frameworks/Dialog/renderers/renderModal.tsx +228 -0
  127. package/packages/Frameworks/Dialog/renderers/renderPopover.tsx +220 -0
  128. package/packages/Frameworks/Dialog/renderers/renderSheet.tsx +571 -0
  129. package/packages/Frameworks/EdgeEffect/EdgeEffect.tsx +52 -0
  130. package/packages/Frameworks/EdgeEffect/EdgeEffect.types.ts +5 -0
  131. package/packages/Frameworks/Motion/Motion.presets.ts +49 -0
  132. package/packages/Frameworks/Pressable/Pressable.module.scss +19 -0
  133. package/packages/Frameworks/Pressable/Pressable.tsx +651 -0
  134. package/packages/Frameworks/Pressable/Pressable.types.ts +73 -0
  135. package/packages/Frameworks/Squircle/Squircle.tsx +263 -0
  136. package/packages/Frameworks/Squircle/Squircle.types.ts +15 -0
  137. package/packages/Frameworks/Theme/Radius.types.ts +55 -0
  138. package/packages/Frameworks/Theme/Theme.types.ts +325 -0
  139. package/packages/Frameworks/Toaster/Toaster.boot.tsx +47 -0
  140. package/packages/Frameworks/Toaster/Toaster.module.scss +168 -0
  141. package/packages/Frameworks/Toaster/Toaster.types.ts +13 -0
  142. package/packages/Frameworks/View/DNDView/DNDView.module.scss +8 -0
  143. package/packages/Frameworks/View/DNDView/DNDView.tsx +470 -0
  144. package/packages/Frameworks/View/DNDView/DNDView.types.ts +61 -0
  145. package/packages/Frameworks/View/HScrollView/HScrollView.module.scss +59 -0
  146. package/packages/Frameworks/View/HScrollView/HScrollView.tsx +386 -0
  147. package/packages/Frameworks/View/HScrollView/HScrollView.types.ts +46 -0
  148. package/packages/Frameworks/View/ImageView/Dialog/ImageDialog.counter.tsx +27 -0
  149. package/packages/Frameworks/View/ImageView/Dialog/ImageDialog.footer.tsx +76 -0
  150. package/packages/Frameworks/View/ImageView/Dialog/ImageDialog.header.tsx +49 -0
  151. package/packages/Frameworks/View/ImageView/Dialog/ImageDialog.list.tsx +74 -0
  152. package/packages/Frameworks/View/ImageView/Dialog/ImageDialog.slide.tsx +71 -0
  153. package/packages/Frameworks/View/ImageView/Dialog/ImageDialog.tsx +175 -0
  154. package/packages/Frameworks/View/ImageView/Image.controls.tsx +39 -0
  155. package/packages/Frameworks/View/ImageView/Image.hooks.ts +82 -0
  156. package/packages/Frameworks/View/ImageView/Image.module.scss +7 -0
  157. package/packages/Frameworks/View/ImageView/Image.tsx +375 -0
  158. package/packages/Frameworks/View/ImageView/Image.types.ts +71 -0
  159. package/packages/Frameworks/View/ImageView/Image.utils.ts +79 -0
  160. package/packages/Frameworks/View/View.module.scss +34 -0
  161. package/packages/Frameworks/View/View.tsx +200 -0
  162. package/packages/Frameworks/View/View.types.ts +36 -0
  163. package/packages/Frameworks/_shared/Padding.types.ts +52 -0
  164. package/packages/Frameworks/_shared/StopParentInteraction.tsx +45 -0
  165. package/packages/Frameworks/_shared/Wind.types.ts +17 -0
  166. package/packages/Frameworks/_shared/bodyScrollLock.ts +127 -0
  167. package/packages/Frameworks/_shared/layer.constants.ts +8 -0
  168. package/packages/Frameworks/_shared/normalize.ts +39 -0
  169. package/packages/Frameworks/_shared/sizing.ts +55 -0
  170. package/packages/Frameworks/_shared/useControllableState.ts +29 -0
  171. package/packages/Styles/_animation.scss +42 -0
  172. package/packages/Styles/_color.scss +131 -0
  173. package/packages/Styles/_font.scss +30 -0
  174. package/packages/Styles/_icon.scss +782 -0
  175. package/packages/Styles/_importer.scss +9 -0
  176. package/packages/Styles/_system.scss +69 -0
  177. package/packages/Styles/_textstyle.scss +111 -0
  178. package/packages/Styles/_theme.scss +452 -0
  179. package/packages/Styles/_viewport-global.scss +99 -0
  180. package/packages/Styles/_viewport.scss +108 -0
@@ -0,0 +1,71 @@
1
+ "use client";
2
+
3
+ import NextImage from "next/image";
4
+ import type {
5
+ ImageItem,
6
+ ImageOverlay,
7
+ } from "@/packages/Frameworks/View/ImageView/Image.types";
8
+ import {
9
+ resolveImageSrc,
10
+ resolveOverlay,
11
+ } from "@/packages/Frameworks/View/ImageView/Image.utils";
12
+ import View from "@/packages/Frameworks/View/View";
13
+
14
+ export interface DialogImageSlideProps {
15
+ item: ImageItem;
16
+ index: number;
17
+ initialIndex: number;
18
+ priority?: boolean;
19
+ dialogOverlay?: ImageOverlay;
20
+ className?: string;
21
+ }
22
+
23
+ export function DialogImageSlide({
24
+ item,
25
+ index,
26
+ initialIndex,
27
+ priority,
28
+ dialogOverlay,
29
+ className,
30
+ }: DialogImageSlideProps) {
31
+ return (
32
+ <View
33
+ alignItems="center"
34
+ justifyContent="center"
35
+ style={{
36
+ flex: "0 0 100%",
37
+ height: "100%",
38
+ minWidth: 0,
39
+ minHeight: 0,
40
+ position: "relative",
41
+ overflow: "hidden",
42
+ }}
43
+ >
44
+ <NextImage
45
+ fill
46
+ sizes="auto"
47
+ priority={priority && index === initialIndex}
48
+ src={resolveImageSrc(item, "dialog")}
49
+ alt={item.alt}
50
+ draggable={false}
51
+ className={className}
52
+ style={{
53
+ objectFit: "contain",
54
+ objectPosition: "center",
55
+ userSelect: "none",
56
+ }}
57
+ />
58
+ {resolveOverlay(dialogOverlay, index) && (
59
+ <View
60
+ style={{
61
+ position: "absolute",
62
+ inset: 0,
63
+ pointerEvents: "none",
64
+ }}
65
+ >
66
+ {resolveOverlay(dialogOverlay, index)}
67
+ </View>
68
+ )}
69
+ </View>
70
+ );
71
+ }
@@ -0,0 +1,175 @@
1
+ "use client";
2
+
3
+ import { useEffect, useRef } from "react";
4
+ import { DialogImageFooter } from "@/packages/Frameworks/View/ImageView/Dialog/ImageDialog.footer";
5
+ import { DialogImageHeader } from "@/packages/Frameworks/View/ImageView/Dialog/ImageDialog.header";
6
+ import { DialogImageSlide } from "@/packages/Frameworks/View/ImageView/Dialog/ImageDialog.slide";
7
+ import {
8
+ ImageLeftControl,
9
+ ImageRightControl,
10
+ } from "@/packages/Frameworks/View/ImageView/Image.controls";
11
+ import { useImageDialog } from "@/packages/Frameworks/View/ImageView/Image.hooks";
12
+ import type {
13
+ ImageItem,
14
+ ImageProps,
15
+ } from "@/packages/Frameworks/View/ImageView/Image.types";
16
+ import View from "@/packages/Frameworks/View/View";
17
+
18
+ export type ImageDialogProps = {
19
+ items: ImageItem[];
20
+ initialIndex: number;
21
+ dialog: NonNullable<ImageProps["dialog"]>;
22
+ priority?: boolean;
23
+ className?: string;
24
+ onClose: () => void;
25
+ };
26
+
27
+ export default function ImageDialog({
28
+ items,
29
+ initialIndex,
30
+ dialog,
31
+ priority,
32
+ className,
33
+ onClose,
34
+ }: ImageDialogProps) {
35
+ const {
36
+ galleryRef,
37
+ selectedIndex,
38
+ scrollTo,
39
+ scrollPrev,
40
+ scrollNext,
41
+ canScrollPrev,
42
+ canScrollNext,
43
+ } = useImageDialog(initialIndex);
44
+
45
+ const thumbnailRefs = useRef<(HTMLElement | null)[]>([]);
46
+
47
+ useEffect(() => {
48
+ thumbnailRefs.current[selectedIndex]?.scrollIntoView({
49
+ behavior: "smooth",
50
+ block: "nearest",
51
+ inline: "center",
52
+ });
53
+ }, [selectedIndex]);
54
+
55
+ return (
56
+ <View
57
+ column
58
+ width="100%"
59
+ height="100%"
60
+ background="BaseDark1"
61
+ className={dialog.className}
62
+ style={{
63
+ position: "relative",
64
+ minWidth: 0,
65
+ minHeight: 0,
66
+ overflow: "hidden",
67
+ }}
68
+ >
69
+ <DialogImageHeader config={dialog.header} onClose={onClose} />
70
+
71
+ {dialog.control &&
72
+ (() => {
73
+ const control = dialog.control;
74
+ const renderLeft =
75
+ typeof control === "boolean"
76
+ ? control
77
+ : control.left !== false && control.left !== undefined;
78
+ const renderRight =
79
+ typeof control === "boolean"
80
+ ? control
81
+ : control.right !== false && control.right !== undefined;
82
+ const leftSlot =
83
+ typeof control === "object" && typeof control.left === "object"
84
+ ? control.left
85
+ : {};
86
+ const rightSlot =
87
+ typeof control === "object" && typeof control.right === "object"
88
+ ? control.right
89
+ : {};
90
+ return (
91
+ <View
92
+ data-color-mode="dark"
93
+ style={{
94
+ position: "absolute",
95
+ inset: 0,
96
+ pointerEvents: "none",
97
+ zIndex: 2,
98
+ }}
99
+ >
100
+ {renderLeft && (
101
+ <ImageLeftControl
102
+ onClick={scrollPrev}
103
+ disabled={!canScrollPrev}
104
+ className={leftSlot.className}
105
+ style={{
106
+ position: "absolute",
107
+ left: "1.6rem",
108
+ top: "50%",
109
+ transform: "translateY(-50%)",
110
+ pointerEvents: "auto",
111
+ ...leftSlot.style,
112
+ }}
113
+ />
114
+ )}
115
+ {renderRight && (
116
+ <ImageRightControl
117
+ onClick={scrollNext}
118
+ disabled={!canScrollNext}
119
+ className={rightSlot.className}
120
+ style={{
121
+ position: "absolute",
122
+ right: "1.6rem",
123
+ top: "50%",
124
+ transform: "translateY(-50%)",
125
+ pointerEvents: "auto",
126
+ ...rightSlot.style,
127
+ }}
128
+ />
129
+ )}
130
+ </View>
131
+ );
132
+ })()}
133
+
134
+ <View
135
+ ref={galleryRef}
136
+ fullWidth
137
+ padding={32}
138
+ style={{ height: "100%", minHeight: 0, overflow: "hidden" }}
139
+ >
140
+ <View
141
+ fullWidth
142
+ style={{
143
+ display: "flex",
144
+ height: "100%",
145
+ touchAction: "pan-y pinch-zoom",
146
+ }}
147
+ >
148
+ {items.map((item, index) => (
149
+ <DialogImageSlide
150
+ key={item.id}
151
+ item={item}
152
+ index={index}
153
+ initialIndex={initialIndex}
154
+ priority={priority}
155
+ dialogOverlay={dialog.overlay}
156
+ className={className}
157
+ />
158
+ ))}
159
+ </View>
160
+ </View>
161
+
162
+ <DialogImageFooter
163
+ dialog={dialog}
164
+ items={items}
165
+ selectedIndex={selectedIndex}
166
+ thumbnailRefs={thumbnailRefs}
167
+ scrollTo={scrollTo}
168
+ scrollPrev={scrollPrev}
169
+ scrollNext={scrollNext}
170
+ canScrollPrev={canScrollPrev}
171
+ canScrollNext={canScrollNext}
172
+ />
173
+ </View>
174
+ );
175
+ }
@@ -0,0 +1,39 @@
1
+ import type { CSSProperties } from "react";
2
+ import Icon from "@/packages/Components/Icon/Icon";
3
+
4
+ export type ImageControlProps = {
5
+ onClick: () => void;
6
+ disabled?: boolean;
7
+ className?: string;
8
+ style?: CSSProperties;
9
+ };
10
+
11
+ function ImageControl({
12
+ icon,
13
+ onClick,
14
+ disabled,
15
+ className,
16
+ style,
17
+ }: ImageControlProps & { icon: string }) {
18
+ return (
19
+ <Icon
20
+ themePreset="BaseSoft"
21
+ icon={icon}
22
+ className={className}
23
+ backgroundBlur="ExtraLight"
24
+ shadow="Regular"
25
+ size={20}
26
+ box
27
+ boxOptions={{ padding: 6, style }}
28
+ pressable={{ onClick, disabled }}
29
+ />
30
+ );
31
+ }
32
+
33
+ export function ImageLeftControl(props: ImageControlProps) {
34
+ return <ImageControl {...props} icon="iArrowLeft" />;
35
+ }
36
+
37
+ export function ImageRightControl(props: ImageControlProps) {
38
+ return <ImageControl {...props} icon="iArrowRight" />;
39
+ }
@@ -0,0 +1,82 @@
1
+ "use client";
2
+
3
+ import type { EmblaOptionsType } from "embla-carousel";
4
+ import useEmblaCarousel from "embla-carousel-react";
5
+ import { WheelGesturesPlugin } from "embla-carousel-wheel-gestures";
6
+ import { useEffect, useMemo, useState } from "react";
7
+
8
+ export function useImageDialog(initialIndex: number) {
9
+ const wheelPlugin = useMemo(() => WheelGesturesPlugin(), []);
10
+
11
+ const options = useMemo<EmblaOptionsType>(
12
+ () => ({
13
+ align: "center",
14
+ containScroll: "keepSnaps",
15
+ dragFree: false,
16
+ startIndex: initialIndex,
17
+ }),
18
+
19
+ [initialIndex],
20
+ );
21
+
22
+ const [galleryRef, galleryApi] = useEmblaCarousel(options, [wheelPlugin]);
23
+ const [selectedIndex, setSelectedIndex] = useState(initialIndex);
24
+ const [canScrollPrev, setCanScrollPrev] = useState(false);
25
+ const [canScrollNext, setCanScrollNext] = useState(false);
26
+
27
+ useEffect(() => {
28
+ if (!galleryApi) return;
29
+
30
+ const sync = () => {
31
+ setSelectedIndex(galleryApi.selectedScrollSnap());
32
+ setCanScrollPrev(galleryApi.canScrollPrev());
33
+ setCanScrollNext(galleryApi.canScrollNext());
34
+ };
35
+
36
+ sync();
37
+ galleryApi.on("select", sync);
38
+ galleryApi.on("reInit", sync);
39
+ galleryApi.on("resize", sync);
40
+
41
+ return () => {
42
+ galleryApi.off("select", sync);
43
+ galleryApi.off("reInit", sync);
44
+ galleryApi.off("resize", sync);
45
+ };
46
+ }, [galleryApi]);
47
+
48
+ useEffect(() => {
49
+ if (!galleryApi) return;
50
+ const frame = window.requestAnimationFrame(() => {
51
+ galleryApi.reInit();
52
+ galleryApi.scrollTo(initialIndex, true);
53
+ });
54
+ return () => window.cancelAnimationFrame(frame);
55
+ }, [galleryApi, initialIndex]);
56
+
57
+ useEffect(() => {
58
+ const handleKeyDown = (e: KeyboardEvent) => {
59
+ if (e.key === "ArrowLeft") {
60
+ e.preventDefault();
61
+ galleryApi?.scrollPrev();
62
+ }
63
+ if (e.key === "ArrowRight") {
64
+ e.preventDefault();
65
+ galleryApi?.scrollNext();
66
+ }
67
+ };
68
+
69
+ window.addEventListener("keydown", handleKeyDown);
70
+ return () => window.removeEventListener("keydown", handleKeyDown);
71
+ }, [galleryApi]);
72
+
73
+ return {
74
+ galleryRef,
75
+ selectedIndex,
76
+ scrollTo: (index: number) => galleryApi?.scrollTo(index),
77
+ scrollPrev: () => galleryApi?.scrollPrev(),
78
+ scrollNext: () => galleryApi?.scrollNext(),
79
+ canScrollPrev,
80
+ canScrollNext,
81
+ };
82
+ }
@@ -0,0 +1,7 @@
1
+ /* 썸네일 버튼 — 기본 스타일 + data-active 활성 상태 */
2
+ .ThumbnailButton {
3
+ position: relative;
4
+ display: block;
5
+ overflow: hidden;
6
+ cursor: pointer;
7
+ }