@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.
- package/LICENSE +9 -0
- package/README.md +51 -0
- package/index.ts +78 -0
- package/package.json +103 -0
- package/packages/Components/Box/Box.tsx +173 -0
- package/packages/Components/Box/Box.types.ts +48 -0
- package/packages/Components/Button/Button.tsx +275 -0
- package/packages/Components/Button/Button.types.ts +44 -0
- package/packages/Components/Card/Card.default.tsx +180 -0
- package/packages/Components/Card/Card.foldable.tsx +383 -0
- package/packages/Components/Card/Card.module.scss +23 -0
- package/packages/Components/Card/Card.tsx +8 -0
- package/packages/Components/Card/Card.types.ts +91 -0
- package/packages/Components/Card/Card.utils.ts +66 -0
- package/packages/Components/Checkbox/Checkbox.module.scss +11 -0
- package/packages/Components/Checkbox/Checkbox.tsx +104 -0
- package/packages/Components/Checkbox/Checkbox.types.ts +24 -0
- package/packages/Components/CodeBox/CodeBox.copy.tsx +43 -0
- package/packages/Components/CodeBox/CodeBox.module.scss +72 -0
- package/packages/Components/CodeBox/CodeBox.tsx +91 -0
- package/packages/Components/CodeBox/CodeBox.types.ts +17 -0
- package/packages/Components/ContextMenu/ContextMenu.module.scss +8 -0
- package/packages/Components/ContextMenu/ContextMenu.options.tsx +126 -0
- package/packages/Components/ContextMenu/ContextMenu.tsx +381 -0
- package/packages/Components/ContextMenu/ContextMenu.types.ts +46 -0
- package/packages/Components/ContributionGraph/ContributionGraph.module.scss +42 -0
- package/packages/Components/ContributionGraph/ContributionGraph.tsx +454 -0
- package/packages/Components/ContributionGraph/ContributionGraph.types.ts +27 -0
- package/packages/Components/DatePicker/DatePicker.calendar.tsx +161 -0
- package/packages/Components/DatePicker/DatePicker.core.tsx +582 -0
- package/packages/Components/DatePicker/DatePicker.module.scss +26 -0
- package/packages/Components/DatePicker/DatePicker.tsx +786 -0
- package/packages/Components/DatePicker/DatePicker.types.ts +36 -0
- package/packages/Components/DatePicker/DatePicker.utils.ts +80 -0
- package/packages/Components/DatePicker/hooks/useCalendar.ts +61 -0
- package/packages/Components/DatePicker/hooks/useSelection.ts +208 -0
- package/packages/Components/Divider/Divider.tsx +46 -0
- package/packages/Components/Divider/Divider.types.ts +12 -0
- package/packages/Components/Header/Header.module.scss +74 -0
- package/packages/Components/Header/Header.tsx +47 -0
- package/packages/Components/Header/Header.types.ts +8 -0
- package/packages/Components/Icon/Icon.group.tsx +122 -0
- package/packages/Components/Icon/Icon.group.types.ts +20 -0
- package/packages/Components/Icon/Icon.tsx +341 -0
- package/packages/Components/Icon/Icon.types.ts +59 -0
- package/packages/Components/Icon/SVG/data.tsx +232 -0
- package/packages/Components/Input/Input.module.scss +5 -0
- package/packages/Components/Input/Input.tsx +87 -0
- package/packages/Components/Input/Input.types.ts +14 -0
- package/packages/Components/Label/Label.module.scss +19 -0
- package/packages/Components/Label/Label.tsx +115 -0
- package/packages/Components/Label/Label.types.ts +28 -0
- package/packages/Components/Layout/Layout.docs.module.scss +42 -0
- package/packages/Components/Layout/Layout.docs.tsx +150 -0
- package/packages/Components/Layout/Layout.docs.types.ts +18 -0
- package/packages/Components/Layout/Layout.module.scss +91 -0
- package/packages/Components/Layout/Layout.tsx +306 -0
- package/packages/Components/Layout/Layout.types.ts +71 -0
- package/packages/Components/Maps/OSM/MapOSM.module.scss +11 -0
- package/packages/Components/Maps/OSM/MapOSM.shared.ts +121 -0
- package/packages/Components/Maps/OSM/MapOSM.tsx +279 -0
- package/packages/Components/Maps/OSM/MapOSM.types.ts +18 -0
- package/packages/Components/Nav/Nav.module.scss +137 -0
- package/packages/Components/Nav/Nav.tsx +304 -0
- package/packages/Components/Nav/Nav.types.ts +32 -0
- package/packages/Components/Nav/hooks/useNavDrag.ts +374 -0
- package/packages/Components/Nav/hooks/useNavIndicator.ts +137 -0
- package/packages/Components/Pagination/Pagination.tsx +254 -0
- package/packages/Components/Pagination/Pagination.types.ts +18 -0
- package/packages/Components/Pill/Pill.tsx +127 -0
- package/packages/Components/Pill/Pill.types.ts +33 -0
- package/packages/Components/Profile/Profile.shared.ts +74 -0
- package/packages/Components/Profile/Profile.tsx +382 -0
- package/packages/Components/Profile/Profile.types.ts +55 -0
- package/packages/Components/Progress/Progress.module.scss +15 -0
- package/packages/Components/Progress/Progress.tsx +88 -0
- package/packages/Components/Progress/Progress.types.ts +22 -0
- package/packages/Components/Radio/Radio.module.scss +11 -0
- package/packages/Components/Radio/Radio.tsx +121 -0
- package/packages/Components/Radio/Radio.types.ts +20 -0
- package/packages/Components/Select/Select.keyboard.tsx +76 -0
- package/packages/Components/Select/Select.trigger.tsx +88 -0
- package/packages/Components/Select/Select.tsx +11 -0
- package/packages/Components/Select/Select.types.ts +38 -0
- package/packages/Components/Select/Select.utils.ts +84 -0
- package/packages/Components/Select/hooks/useSelectNavigation.ts +461 -0
- package/packages/Components/Select/hooks/useSelectSelection.ts +142 -0
- package/packages/Components/Select/hooks/useSelectState.ts +314 -0
- package/packages/Components/Select/select.control.tsx +228 -0
- package/packages/Components/Select/select.inner.tsx +312 -0
- package/packages/Components/Skeleton/Skeleton.tsx +30 -0
- package/packages/Components/Skeleton/Skeleton.types.ts +12 -0
- package/packages/Components/Spinner/Spinner.module.scss +78 -0
- package/packages/Components/Spinner/Spinner.tsx +125 -0
- package/packages/Components/Spinner/Spinner.types.ts +19 -0
- package/packages/Components/Text/Text.module.scss +7 -0
- package/packages/Components/Text/Text.tsx +49 -0
- package/packages/Components/Text/Text.types.ts +33 -0
- package/packages/Components/TimePicker/TimePicker.core.tsx +448 -0
- package/packages/Components/TimePicker/TimePicker.module.scss +30 -0
- package/packages/Components/TimePicker/TimePicker.tsx +511 -0
- package/packages/Components/TimePicker/TimePicker.types.ts +22 -0
- package/packages/Components/Timeline/Timeline.tsx +111 -0
- package/packages/Components/Timeline/Timeline.types.ts +23 -0
- package/packages/Components/Title/Title.tsx +305 -0
- package/packages/Components/Title/Title.types.ts +64 -0
- package/packages/Components/Toggle/Toggle.module.scss +32 -0
- package/packages/Components/Toggle/Toggle.tsx +272 -0
- package/packages/Components/Toggle/Toggle.types.ts +17 -0
- package/packages/Components/Tooltip/Tooltip.module.scss +44 -0
- package/packages/Components/Tooltip/Tooltip.tsx +340 -0
- package/packages/Components/Tooltip/Tooltip.types.ts +38 -0
- package/packages/Frameworks/Dialog/Dialog.background.tsx +88 -0
- package/packages/Frameworks/Dialog/Dialog.boot.tsx +32 -0
- package/packages/Frameworks/Dialog/Dialog.store.ts +199 -0
- package/packages/Frameworks/Dialog/Dialog.tsx +185 -0
- package/packages/Frameworks/Dialog/Dialog.types.ts +264 -0
- package/packages/Frameworks/Dialog/Dialog.utils.ts +22 -0
- package/packages/Frameworks/Dialog/contents/Dialog.footer.tsx +79 -0
- package/packages/Frameworks/Dialog/contents/Dialog.funnel.tsx +260 -0
- package/packages/Frameworks/Dialog/contents/Dialog.header.tsx +137 -0
- package/packages/Frameworks/Dialog/hooks/useDialogPosition.ts +298 -0
- package/packages/Frameworks/Dialog/hooks/useSheetDrag.ts +325 -0
- package/packages/Frameworks/Dialog/hooks/useSheetGeometry.ts +201 -0
- package/packages/Frameworks/Dialog/hooks/useSheetProgressive.ts +98 -0
- package/packages/Frameworks/Dialog/renderers/renderModal.tsx +228 -0
- package/packages/Frameworks/Dialog/renderers/renderPopover.tsx +220 -0
- package/packages/Frameworks/Dialog/renderers/renderSheet.tsx +571 -0
- package/packages/Frameworks/EdgeEffect/EdgeEffect.tsx +52 -0
- package/packages/Frameworks/EdgeEffect/EdgeEffect.types.ts +5 -0
- package/packages/Frameworks/Motion/Motion.presets.ts +49 -0
- package/packages/Frameworks/Pressable/Pressable.module.scss +19 -0
- package/packages/Frameworks/Pressable/Pressable.tsx +651 -0
- package/packages/Frameworks/Pressable/Pressable.types.ts +73 -0
- package/packages/Frameworks/Squircle/Squircle.tsx +263 -0
- package/packages/Frameworks/Squircle/Squircle.types.ts +15 -0
- package/packages/Frameworks/Theme/Radius.types.ts +55 -0
- package/packages/Frameworks/Theme/Theme.types.ts +325 -0
- package/packages/Frameworks/Toaster/Toaster.boot.tsx +47 -0
- package/packages/Frameworks/Toaster/Toaster.module.scss +168 -0
- package/packages/Frameworks/Toaster/Toaster.types.ts +13 -0
- package/packages/Frameworks/View/DNDView/DNDView.module.scss +8 -0
- package/packages/Frameworks/View/DNDView/DNDView.tsx +470 -0
- package/packages/Frameworks/View/DNDView/DNDView.types.ts +61 -0
- package/packages/Frameworks/View/HScrollView/HScrollView.module.scss +59 -0
- package/packages/Frameworks/View/HScrollView/HScrollView.tsx +386 -0
- package/packages/Frameworks/View/HScrollView/HScrollView.types.ts +46 -0
- package/packages/Frameworks/View/ImageView/Dialog/ImageDialog.counter.tsx +27 -0
- package/packages/Frameworks/View/ImageView/Dialog/ImageDialog.footer.tsx +76 -0
- package/packages/Frameworks/View/ImageView/Dialog/ImageDialog.header.tsx +49 -0
- package/packages/Frameworks/View/ImageView/Dialog/ImageDialog.list.tsx +74 -0
- package/packages/Frameworks/View/ImageView/Dialog/ImageDialog.slide.tsx +71 -0
- package/packages/Frameworks/View/ImageView/Dialog/ImageDialog.tsx +175 -0
- package/packages/Frameworks/View/ImageView/Image.controls.tsx +39 -0
- package/packages/Frameworks/View/ImageView/Image.hooks.ts +82 -0
- package/packages/Frameworks/View/ImageView/Image.module.scss +7 -0
- package/packages/Frameworks/View/ImageView/Image.tsx +375 -0
- package/packages/Frameworks/View/ImageView/Image.types.ts +71 -0
- package/packages/Frameworks/View/ImageView/Image.utils.ts +79 -0
- package/packages/Frameworks/View/View.module.scss +34 -0
- package/packages/Frameworks/View/View.tsx +200 -0
- package/packages/Frameworks/View/View.types.ts +36 -0
- package/packages/Frameworks/_shared/Padding.types.ts +52 -0
- package/packages/Frameworks/_shared/StopParentInteraction.tsx +45 -0
- package/packages/Frameworks/_shared/Wind.types.ts +17 -0
- package/packages/Frameworks/_shared/bodyScrollLock.ts +127 -0
- package/packages/Frameworks/_shared/layer.constants.ts +8 -0
- package/packages/Frameworks/_shared/normalize.ts +39 -0
- package/packages/Frameworks/_shared/sizing.ts +55 -0
- package/packages/Frameworks/_shared/useControllableState.ts +29 -0
- package/packages/Styles/_animation.scss +42 -0
- package/packages/Styles/_color.scss +131 -0
- package/packages/Styles/_font.scss +30 -0
- package/packages/Styles/_icon.scss +782 -0
- package/packages/Styles/_importer.scss +9 -0
- package/packages/Styles/_system.scss +69 -0
- package/packages/Styles/_textstyle.scss +111 -0
- package/packages/Styles/_theme.scss +452 -0
- package/packages/Styles/_viewport-global.scss +99 -0
- package/packages/Styles/_viewport.scss +108 -0
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import clsx from "clsx";
|
|
4
|
+
import type { EmblaOptionsType } from "embla-carousel";
|
|
5
|
+
import useEmblaCarousel from "embla-carousel-react";
|
|
6
|
+
import { WheelGesturesPlugin } from "embla-carousel-wheel-gestures";
|
|
7
|
+
import {
|
|
8
|
+
Children,
|
|
9
|
+
type CSSProperties,
|
|
10
|
+
forwardRef,
|
|
11
|
+
useCallback,
|
|
12
|
+
useEffect,
|
|
13
|
+
useMemo,
|
|
14
|
+
useRef,
|
|
15
|
+
useState,
|
|
16
|
+
} from "react";
|
|
17
|
+
import { Size } from "@/packages/Frameworks/_shared/sizing";
|
|
18
|
+
import EdgeEffect from "@/packages/Frameworks/EdgeEffect/EdgeEffect";
|
|
19
|
+
import { Radius } from "@/packages/Frameworks/Theme/Radius.types";
|
|
20
|
+
import {
|
|
21
|
+
BackgroundBlur,
|
|
22
|
+
Border,
|
|
23
|
+
resolveThemeClasses,
|
|
24
|
+
} from "@/packages/Frameworks/Theme/Theme.types";
|
|
25
|
+
import styles from "@/packages/Frameworks/View/HScrollView/HScrollView.module.scss";
|
|
26
|
+
import type {
|
|
27
|
+
HScrollViewProps,
|
|
28
|
+
HScrollViewViewport,
|
|
29
|
+
} from "@/packages/Frameworks/View/HScrollView/HScrollView.types";
|
|
30
|
+
import View from "@/packages/Frameworks/View/View";
|
|
31
|
+
import viewStyles from "@/packages/Frameworks/View/View.module.scss";
|
|
32
|
+
|
|
33
|
+
type HScrollViewStyle = CSSProperties & {
|
|
34
|
+
"--view-default-gap"?: string | number;
|
|
35
|
+
"--h-scroll-item-width"?: string | number;
|
|
36
|
+
"--h-scroll-item-height"?: string | number;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const VIEWPORT_MAX_QUERY: Record<HScrollViewViewport, string> = {
|
|
40
|
+
w1: "(max-width: 319.98px)",
|
|
41
|
+
w2: "(max-width: 409.98px)",
|
|
42
|
+
w3: "(max-width: 767.98px)",
|
|
43
|
+
w4: "(max-width: 1279.98px)",
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export default forwardRef<HTMLDivElement, HScrollViewProps>(
|
|
47
|
+
function HScrollView(
|
|
48
|
+
{
|
|
49
|
+
active = true,
|
|
50
|
+
children,
|
|
51
|
+
className,
|
|
52
|
+
style,
|
|
53
|
+
rootStyle,
|
|
54
|
+
containerStyle,
|
|
55
|
+
activeContainerStyle,
|
|
56
|
+
inactiveContainerStyle,
|
|
57
|
+
itemWidth,
|
|
58
|
+
itemHeight,
|
|
59
|
+
renderControls,
|
|
60
|
+
showEdgeEffect = true,
|
|
61
|
+
themePreset,
|
|
62
|
+
background,
|
|
63
|
+
color,
|
|
64
|
+
themeInteractive,
|
|
65
|
+
selected,
|
|
66
|
+
border,
|
|
67
|
+
radius,
|
|
68
|
+
backgroundBlur,
|
|
69
|
+
alignItems,
|
|
70
|
+
justifyContent,
|
|
71
|
+
wrap,
|
|
72
|
+
gap,
|
|
73
|
+
fullWidth,
|
|
74
|
+
width,
|
|
75
|
+
height,
|
|
76
|
+
padding,
|
|
77
|
+
margin,
|
|
78
|
+
"data-color-mode": dataColorMode,
|
|
79
|
+
...rest
|
|
80
|
+
},
|
|
81
|
+
ref,
|
|
82
|
+
) {
|
|
83
|
+
const wheelPlugin = useMemo(
|
|
84
|
+
() => WheelGesturesPlugin({ forceWheelAxis: "x" }),
|
|
85
|
+
[],
|
|
86
|
+
);
|
|
87
|
+
const emblaPlugins = useMemo(() => [wheelPlugin], [wheelPlugin]);
|
|
88
|
+
const lastLocationRef = useRef(0);
|
|
89
|
+
const viewportRef = useRef<HTMLDivElement | null>(null);
|
|
90
|
+
const [isScrollActive, setIsScrollActive] = useState(() => active === true);
|
|
91
|
+
const [canScrollPrev, setCanScrollPrev] = useState(false);
|
|
92
|
+
const [canScrollNext, setCanScrollNext] = useState(false);
|
|
93
|
+
const slideCount = Children.count(children);
|
|
94
|
+
const hasSingleSlide = slideCount <= 1;
|
|
95
|
+
const shouldUseEmbla = isScrollActive && !hasSingleSlide;
|
|
96
|
+
const baseContainerStyle: CSSProperties = isScrollActive
|
|
97
|
+
? (activeContainerStyle ??
|
|
98
|
+
containerStyle ?? {
|
|
99
|
+
alignItems,
|
|
100
|
+
justifyContent,
|
|
101
|
+
flexDirection: "row",
|
|
102
|
+
flexWrap: wrap,
|
|
103
|
+
gap: Size(gap),
|
|
104
|
+
})
|
|
105
|
+
: (inactiveContainerStyle ??
|
|
106
|
+
containerStyle ?? {
|
|
107
|
+
alignItems,
|
|
108
|
+
justifyContent,
|
|
109
|
+
flexWrap: wrap,
|
|
110
|
+
gap: Size(gap),
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
const resolvedContainerStyle = useMemo<CSSProperties>(
|
|
114
|
+
() => ({
|
|
115
|
+
...baseContainerStyle,
|
|
116
|
+
flexWrap: isScrollActive ? "nowrap" : baseContainerStyle?.flexWrap,
|
|
117
|
+
flexDirection: "row",
|
|
118
|
+
touchAction: isScrollActive
|
|
119
|
+
? shouldUseEmbla
|
|
120
|
+
? "pan-y pinch-zoom"
|
|
121
|
+
: baseContainerStyle?.touchAction
|
|
122
|
+
: baseContainerStyle?.touchAction,
|
|
123
|
+
}),
|
|
124
|
+
[baseContainerStyle, isScrollActive, shouldUseEmbla],
|
|
125
|
+
);
|
|
126
|
+
const gapValue = resolvedContainerStyle.gap;
|
|
127
|
+
|
|
128
|
+
const emblaOptions = useMemo<EmblaOptionsType>(
|
|
129
|
+
() => ({
|
|
130
|
+
active: shouldUseEmbla,
|
|
131
|
+
align: "start",
|
|
132
|
+
dragFree: true,
|
|
133
|
+
axis: "x",
|
|
134
|
+
}),
|
|
135
|
+
[shouldUseEmbla],
|
|
136
|
+
);
|
|
137
|
+
const [emblaRef, emblaApi] = useEmblaCarousel(emblaOptions, emblaPlugins);
|
|
138
|
+
const setViewportRef = useCallback(
|
|
139
|
+
(node: HTMLDivElement | null) => {
|
|
140
|
+
viewportRef.current = node;
|
|
141
|
+
emblaRef(node);
|
|
142
|
+
},
|
|
143
|
+
[emblaRef],
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
const scrollNative = useCallback((direction: -1 | 1) => {
|
|
147
|
+
const viewport = viewportRef.current;
|
|
148
|
+
if (!viewport) return;
|
|
149
|
+
|
|
150
|
+
viewport.scrollBy({
|
|
151
|
+
left: viewport.clientWidth * direction * 0.85,
|
|
152
|
+
behavior: "smooth",
|
|
153
|
+
});
|
|
154
|
+
}, []);
|
|
155
|
+
|
|
156
|
+
const scrollPrev = useCallback(() => {
|
|
157
|
+
if (emblaApi && shouldUseEmbla) {
|
|
158
|
+
emblaApi.scrollPrev();
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
scrollNative(-1);
|
|
163
|
+
}, [emblaApi, scrollNative, shouldUseEmbla]);
|
|
164
|
+
|
|
165
|
+
const scrollNext = useCallback(() => {
|
|
166
|
+
if (emblaApi && shouldUseEmbla) {
|
|
167
|
+
emblaApi.scrollNext();
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
scrollNative(1);
|
|
172
|
+
}, [emblaApi, scrollNative, shouldUseEmbla]);
|
|
173
|
+
|
|
174
|
+
const syncControls = useCallback(() => {
|
|
175
|
+
if (emblaApi && shouldUseEmbla) {
|
|
176
|
+
const progress = emblaApi.scrollProgress();
|
|
177
|
+
setCanScrollPrev(progress > 0.005);
|
|
178
|
+
setCanScrollNext(progress < 0.995);
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
const viewport = viewportRef.current;
|
|
183
|
+
if (!viewport) return;
|
|
184
|
+
|
|
185
|
+
setCanScrollPrev(Math.ceil(viewport.scrollLeft) > 0);
|
|
186
|
+
setCanScrollNext(
|
|
187
|
+
Math.ceil(viewport.scrollLeft + viewport.clientWidth) <
|
|
188
|
+
viewport.scrollWidth,
|
|
189
|
+
);
|
|
190
|
+
}, [emblaApi, shouldUseEmbla]);
|
|
191
|
+
|
|
192
|
+
useEffect(() => {
|
|
193
|
+
if (active === true) {
|
|
194
|
+
setIsScrollActive(true);
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
if (!active) {
|
|
199
|
+
setIsScrollActive(false);
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
const mediaQueryList = window.matchMedia(VIEWPORT_MAX_QUERY[active]);
|
|
204
|
+
const syncActive = () => {
|
|
205
|
+
setIsScrollActive(mediaQueryList.matches);
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
syncActive();
|
|
209
|
+
mediaQueryList.addEventListener("change", syncActive);
|
|
210
|
+
return () => {
|
|
211
|
+
mediaQueryList.removeEventListener("change", syncActive);
|
|
212
|
+
};
|
|
213
|
+
}, [active]);
|
|
214
|
+
|
|
215
|
+
useEffect(() => {
|
|
216
|
+
if (!emblaApi || !shouldUseEmbla) return;
|
|
217
|
+
|
|
218
|
+
const syncLocation = () => {
|
|
219
|
+
lastLocationRef.current = emblaApi.internalEngine().location.get();
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
syncLocation();
|
|
223
|
+
emblaApi.on("scroll", syncLocation);
|
|
224
|
+
emblaApi.on("select", syncLocation);
|
|
225
|
+
emblaApi.on("settle", syncLocation);
|
|
226
|
+
|
|
227
|
+
return () => {
|
|
228
|
+
emblaApi.off("scroll", syncLocation);
|
|
229
|
+
emblaApi.off("select", syncLocation);
|
|
230
|
+
emblaApi.off("settle", syncLocation);
|
|
231
|
+
};
|
|
232
|
+
}, [emblaApi, shouldUseEmbla]);
|
|
233
|
+
|
|
234
|
+
useEffect(() => {
|
|
235
|
+
syncControls();
|
|
236
|
+
|
|
237
|
+
if (emblaApi && shouldUseEmbla) {
|
|
238
|
+
emblaApi.on("select", syncControls);
|
|
239
|
+
emblaApi.on("scroll", syncControls);
|
|
240
|
+
emblaApi.on("reInit", syncControls);
|
|
241
|
+
|
|
242
|
+
return () => {
|
|
243
|
+
emblaApi.off("select", syncControls);
|
|
244
|
+
emblaApi.off("scroll", syncControls);
|
|
245
|
+
emblaApi.off("reInit", syncControls);
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
const viewport = viewportRef.current;
|
|
250
|
+
if (!viewport) return;
|
|
251
|
+
|
|
252
|
+
viewport.addEventListener("scroll", syncControls);
|
|
253
|
+
window.addEventListener("resize", syncControls);
|
|
254
|
+
|
|
255
|
+
let observer: ResizeObserver | null = null;
|
|
256
|
+
if (typeof ResizeObserver !== "undefined") {
|
|
257
|
+
observer = new ResizeObserver(() => {
|
|
258
|
+
syncControls();
|
|
259
|
+
});
|
|
260
|
+
observer.observe(viewport);
|
|
261
|
+
if (viewport.firstElementChild) {
|
|
262
|
+
observer.observe(viewport.firstElementChild);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
return () => {
|
|
267
|
+
viewport.removeEventListener("scroll", syncControls);
|
|
268
|
+
window.removeEventListener("resize", syncControls);
|
|
269
|
+
if (observer) {
|
|
270
|
+
observer.disconnect();
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
}, [emblaApi, shouldUseEmbla, syncControls]);
|
|
274
|
+
|
|
275
|
+
useEffect(() => {
|
|
276
|
+
if (!emblaApi || !shouldUseEmbla) return;
|
|
277
|
+
|
|
278
|
+
const shouldReInit = slideCount > 0 || gapValue !== undefined;
|
|
279
|
+
if (!shouldReInit) return;
|
|
280
|
+
|
|
281
|
+
const frame = window.requestAnimationFrame(() => {
|
|
282
|
+
const previousLocation = lastLocationRef.current;
|
|
283
|
+
emblaApi.reInit();
|
|
284
|
+
const engine = emblaApi.internalEngine();
|
|
285
|
+
engine.location.set(previousLocation);
|
|
286
|
+
engine.previousLocation.set(previousLocation);
|
|
287
|
+
engine.offsetLocation.set(previousLocation);
|
|
288
|
+
engine.target.set(previousLocation);
|
|
289
|
+
engine.translate.to(previousLocation);
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
return () => {
|
|
293
|
+
window.cancelAnimationFrame(frame);
|
|
294
|
+
};
|
|
295
|
+
}, [emblaApi, gapValue, shouldUseEmbla, slideCount]);
|
|
296
|
+
|
|
297
|
+
const themeClasses = resolveThemeClasses({
|
|
298
|
+
themePreset,
|
|
299
|
+
background,
|
|
300
|
+
color,
|
|
301
|
+
themeInteractive,
|
|
302
|
+
selected,
|
|
303
|
+
isInteractive: false,
|
|
304
|
+
});
|
|
305
|
+
const resolvedRootStyle: HScrollViewStyle = {
|
|
306
|
+
position: "relative",
|
|
307
|
+
"--view-default-gap": Size(gap ?? 12),
|
|
308
|
+
"--h-scroll-item-width": Size(itemWidth),
|
|
309
|
+
"--h-scroll-item-height": Size(itemHeight),
|
|
310
|
+
width: Size(width),
|
|
311
|
+
height: Size(height),
|
|
312
|
+
padding: Size(padding),
|
|
313
|
+
margin: Size(margin),
|
|
314
|
+
borderRadius: Radius(radius),
|
|
315
|
+
...rootStyle,
|
|
316
|
+
...style,
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
const controls = renderControls?.({
|
|
320
|
+
scrollPrev,
|
|
321
|
+
scrollNext,
|
|
322
|
+
canScrollPrev,
|
|
323
|
+
canScrollNext,
|
|
324
|
+
isScrollActive,
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
return (
|
|
328
|
+
<View
|
|
329
|
+
ref={ref}
|
|
330
|
+
column
|
|
331
|
+
data-color-mode={dataColorMode}
|
|
332
|
+
data-h-scroll-active={isScrollActive ? "true" : "false"}
|
|
333
|
+
{...rest}
|
|
334
|
+
className={clsx(
|
|
335
|
+
viewStyles.View,
|
|
336
|
+
...themeClasses,
|
|
337
|
+
Border(border),
|
|
338
|
+
BackgroundBlur(backgroundBlur),
|
|
339
|
+
fullWidth && styles.FullWidth,
|
|
340
|
+
className,
|
|
341
|
+
hasSingleSlide && styles.SingleChild,
|
|
342
|
+
)}
|
|
343
|
+
style={resolvedRootStyle}
|
|
344
|
+
>
|
|
345
|
+
<View
|
|
346
|
+
ref={setViewportRef}
|
|
347
|
+
data-embla-active={emblaApi && shouldUseEmbla ? "true" : "false"}
|
|
348
|
+
className={styles.Viewport}
|
|
349
|
+
>
|
|
350
|
+
<View className={styles.Container} style={resolvedContainerStyle}>
|
|
351
|
+
{children}
|
|
352
|
+
</View>
|
|
353
|
+
</View>
|
|
354
|
+
{showEdgeEffect && canScrollPrev && (
|
|
355
|
+
<EdgeEffect
|
|
356
|
+
side="left"
|
|
357
|
+
style={{
|
|
358
|
+
position: "absolute",
|
|
359
|
+
zIndex: 2,
|
|
360
|
+
pointerEvents: "none",
|
|
361
|
+
top: 0,
|
|
362
|
+
bottom: 0,
|
|
363
|
+
left: 0,
|
|
364
|
+
width: "2.4rem",
|
|
365
|
+
}}
|
|
366
|
+
/>
|
|
367
|
+
)}
|
|
368
|
+
{showEdgeEffect && canScrollNext && (
|
|
369
|
+
<EdgeEffect
|
|
370
|
+
side="right"
|
|
371
|
+
style={{
|
|
372
|
+
position: "absolute",
|
|
373
|
+
zIndex: 2,
|
|
374
|
+
pointerEvents: "none",
|
|
375
|
+
top: 0,
|
|
376
|
+
bottom: 0,
|
|
377
|
+
right: 0,
|
|
378
|
+
width: "2.4rem",
|
|
379
|
+
}}
|
|
380
|
+
/>
|
|
381
|
+
)}
|
|
382
|
+
{controls}
|
|
383
|
+
</View>
|
|
384
|
+
);
|
|
385
|
+
},
|
|
386
|
+
);
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { CSSProperties, HTMLAttributes, ReactNode } from "react";
|
|
2
|
+
import type { UIKitSizeValue } from "@/packages/Frameworks/_shared/sizing";
|
|
3
|
+
import type { ViewProps } from "@/packages/Frameworks/View/View.types";
|
|
4
|
+
|
|
5
|
+
export type HScrollViewViewport = "w1" | "w2" | "w3" | "w4";
|
|
6
|
+
export type HScrollViewActive = boolean | HScrollViewViewport;
|
|
7
|
+
export type HScrollViewControls = {
|
|
8
|
+
scrollPrev: () => void;
|
|
9
|
+
scrollNext: () => void;
|
|
10
|
+
canScrollPrev: boolean;
|
|
11
|
+
canScrollNext: boolean;
|
|
12
|
+
isScrollActive: boolean;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export interface HScrollViewProps
|
|
16
|
+
extends Omit<HTMLAttributes<HTMLDivElement>, "color"> {
|
|
17
|
+
active?: HScrollViewActive;
|
|
18
|
+
children?: ReactNode;
|
|
19
|
+
rootStyle?: CSSProperties;
|
|
20
|
+
containerStyle?: CSSProperties;
|
|
21
|
+
activeContainerStyle?: CSSProperties;
|
|
22
|
+
inactiveContainerStyle?: CSSProperties;
|
|
23
|
+
itemWidth?: UIKitSizeValue;
|
|
24
|
+
itemHeight?: UIKitSizeValue;
|
|
25
|
+
renderControls?: (controls: HScrollViewControls) => ReactNode;
|
|
26
|
+
showEdgeEffect?: boolean;
|
|
27
|
+
width?: UIKitSizeValue;
|
|
28
|
+
height?: UIKitSizeValue;
|
|
29
|
+
padding?: UIKitSizeValue;
|
|
30
|
+
margin?: UIKitSizeValue;
|
|
31
|
+
|
|
32
|
+
alignItems?: ViewProps["alignItems"];
|
|
33
|
+
justifyContent?: ViewProps["justifyContent"];
|
|
34
|
+
wrap?: ViewProps["wrap"];
|
|
35
|
+
gap?: ViewProps["gap"];
|
|
36
|
+
fullWidth?: ViewProps["fullWidth"];
|
|
37
|
+
background?: ViewProps["background"];
|
|
38
|
+
color?: ViewProps["color"];
|
|
39
|
+
themePreset?: ViewProps["themePreset"];
|
|
40
|
+
themeInteractive?: ViewProps["themeInteractive"];
|
|
41
|
+
selected?: ViewProps["selected"];
|
|
42
|
+
border?: ViewProps["border"];
|
|
43
|
+
radius?: ViewProps["radius"];
|
|
44
|
+
backgroundBlur?: ViewProps["backgroundBlur"];
|
|
45
|
+
"data-color-mode"?: ViewProps["data-color-mode"];
|
|
46
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import Text from "@/packages/Components/Text/Text";
|
|
4
|
+
import View from "@/packages/Frameworks/View/View";
|
|
5
|
+
|
|
6
|
+
export function DialogImageCounter({
|
|
7
|
+
selectedIndex,
|
|
8
|
+
total,
|
|
9
|
+
}: {
|
|
10
|
+
selectedIndex: number;
|
|
11
|
+
total: number;
|
|
12
|
+
}) {
|
|
13
|
+
return (
|
|
14
|
+
<View
|
|
15
|
+
alignItems="center"
|
|
16
|
+
background="Base6TP6"
|
|
17
|
+
shadow="Light"
|
|
18
|
+
radius="ExtraLight"
|
|
19
|
+
padding={[6, 8]}
|
|
20
|
+
style={{ whiteSpace: "nowrap" }}
|
|
21
|
+
>
|
|
22
|
+
<Text type="Subheadline">
|
|
23
|
+
{selectedIndex + 1} / {total}
|
|
24
|
+
</Text>
|
|
25
|
+
</View>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import type { MutableRefObject } from "react";
|
|
4
|
+
import { DialogImageCounter } from "@/packages/Frameworks/View/ImageView/Dialog/ImageDialog.counter";
|
|
5
|
+
import { DialogImageList } from "@/packages/Frameworks/View/ImageView/Dialog/ImageDialog.list";
|
|
6
|
+
import type {
|
|
7
|
+
ImageItem,
|
|
8
|
+
ImageProps,
|
|
9
|
+
} from "@/packages/Frameworks/View/ImageView/Image.types";
|
|
10
|
+
import View from "@/packages/Frameworks/View/View";
|
|
11
|
+
|
|
12
|
+
export interface DialogImageFooterProps {
|
|
13
|
+
dialog: NonNullable<ImageProps["dialog"]>;
|
|
14
|
+
items: ImageItem[];
|
|
15
|
+
selectedIndex: number;
|
|
16
|
+
thumbnailRefs: MutableRefObject<(HTMLElement | null)[]>;
|
|
17
|
+
scrollTo: (index: number) => void;
|
|
18
|
+
scrollPrev: () => void;
|
|
19
|
+
scrollNext: () => void;
|
|
20
|
+
canScrollPrev: boolean;
|
|
21
|
+
canScrollNext: boolean;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function DialogImageFooter({
|
|
25
|
+
dialog,
|
|
26
|
+
items,
|
|
27
|
+
selectedIndex,
|
|
28
|
+
thumbnailRefs,
|
|
29
|
+
scrollTo,
|
|
30
|
+
scrollPrev,
|
|
31
|
+
scrollNext,
|
|
32
|
+
canScrollPrev,
|
|
33
|
+
canScrollNext,
|
|
34
|
+
}: DialogImageFooterProps) {
|
|
35
|
+
if (!dialog.footer) return null;
|
|
36
|
+
|
|
37
|
+
const selectedItem = items[selectedIndex];
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<View
|
|
41
|
+
column
|
|
42
|
+
gap={12}
|
|
43
|
+
className={dialog.footer.className}
|
|
44
|
+
style={{
|
|
45
|
+
position: "absolute",
|
|
46
|
+
left: "1.6rem",
|
|
47
|
+
right: "1.6rem",
|
|
48
|
+
bottom: "1.6rem",
|
|
49
|
+
zIndex: 2,
|
|
50
|
+
...dialog.footer.style,
|
|
51
|
+
}}
|
|
52
|
+
>
|
|
53
|
+
{selectedItem && dialog.footer.content?.(selectedItem, selectedIndex)}
|
|
54
|
+
|
|
55
|
+
<View alignItems="flex-end" justifyContent="space-between" gap={12}>
|
|
56
|
+
{dialog.footer.list && (
|
|
57
|
+
<DialogImageList
|
|
58
|
+
items={items}
|
|
59
|
+
selectedIndex={selectedIndex}
|
|
60
|
+
thumbnailRefs={thumbnailRefs}
|
|
61
|
+
onThumbnailClick={scrollTo}
|
|
62
|
+
/>
|
|
63
|
+
)}
|
|
64
|
+
|
|
65
|
+
<View alignItems="center" gap={8} style={{ flexShrink: 0 }}>
|
|
66
|
+
{dialog.footer.counter && (
|
|
67
|
+
<DialogImageCounter
|
|
68
|
+
selectedIndex={selectedIndex}
|
|
69
|
+
total={items.length}
|
|
70
|
+
/>
|
|
71
|
+
)}
|
|
72
|
+
</View>
|
|
73
|
+
</View>
|
|
74
|
+
</View>
|
|
75
|
+
);
|
|
76
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import Icon from "@/packages/Components/Icon/Icon";
|
|
4
|
+
import type { ImageProps } from "@/packages/Frameworks/View/ImageView/Image.types";
|
|
5
|
+
import View from "@/packages/Frameworks/View/View";
|
|
6
|
+
|
|
7
|
+
export interface DialogImageHeaderProps {
|
|
8
|
+
config?: NonNullable<ImageProps["dialog"]>["header"];
|
|
9
|
+
onClose: () => void;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function DialogImageHeader({ config, onClose }: DialogImageHeaderProps) {
|
|
13
|
+
return (
|
|
14
|
+
<View
|
|
15
|
+
justifyContent="space-between"
|
|
16
|
+
alignItems="center"
|
|
17
|
+
className={config?.className}
|
|
18
|
+
style={{
|
|
19
|
+
position: "absolute",
|
|
20
|
+
top: "1.6rem",
|
|
21
|
+
left: "1.6rem",
|
|
22
|
+
right: "1.6rem",
|
|
23
|
+
zIndex: 2,
|
|
24
|
+
pointerEvents: "none",
|
|
25
|
+
...config?.style,
|
|
26
|
+
}}
|
|
27
|
+
>
|
|
28
|
+
{config?.content && (
|
|
29
|
+
<View style={{ pointerEvents: "auto" }}>{config.content}</View>
|
|
30
|
+
)}
|
|
31
|
+
<Icon
|
|
32
|
+
data-color-mode="dark"
|
|
33
|
+
icon="iClose"
|
|
34
|
+
shadow="Regular"
|
|
35
|
+
box
|
|
36
|
+
size={18}
|
|
37
|
+
themePreset="BaseSoft"
|
|
38
|
+
backgroundBlur="ExtraLight"
|
|
39
|
+
boxOptions={{
|
|
40
|
+
padding: 6,
|
|
41
|
+
}}
|
|
42
|
+
pressable={{
|
|
43
|
+
onClick: onClose,
|
|
44
|
+
style: { pointerEvents: "auto", marginLeft: "auto" },
|
|
45
|
+
}}
|
|
46
|
+
/>
|
|
47
|
+
</View>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import NextImage from "next/image";
|
|
4
|
+
import type { MutableRefObject } from "react";
|
|
5
|
+
import Pressable from "@/packages/Frameworks/Pressable/Pressable";
|
|
6
|
+
import styles from "@/packages/Frameworks/View/ImageView/Image.module.scss";
|
|
7
|
+
import type { ImageItem } from "@/packages/Frameworks/View/ImageView/Image.types";
|
|
8
|
+
import {
|
|
9
|
+
resolveBlurDataURL,
|
|
10
|
+
resolveImageSrc,
|
|
11
|
+
} from "@/packages/Frameworks/View/ImageView/Image.utils";
|
|
12
|
+
import View from "@/packages/Frameworks/View/View";
|
|
13
|
+
|
|
14
|
+
export interface DialogImageListProps {
|
|
15
|
+
items: ImageItem[];
|
|
16
|
+
selectedIndex: number;
|
|
17
|
+
thumbnailRefs: MutableRefObject<(HTMLElement | null)[]>;
|
|
18
|
+
onThumbnailClick: (index: number) => void;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function DialogImageList({
|
|
22
|
+
items,
|
|
23
|
+
selectedIndex,
|
|
24
|
+
thumbnailRefs,
|
|
25
|
+
onThumbnailClick,
|
|
26
|
+
}: DialogImageListProps) {
|
|
27
|
+
if (items.length <= 1) return null;
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<View
|
|
31
|
+
style={{
|
|
32
|
+
overflowX: "auto",
|
|
33
|
+
scrollbarWidth: "none",
|
|
34
|
+
flex: 1,
|
|
35
|
+
minWidth: 0,
|
|
36
|
+
}}
|
|
37
|
+
gap={8}
|
|
38
|
+
>
|
|
39
|
+
{items.map((item, index) => (
|
|
40
|
+
<Pressable
|
|
41
|
+
key={item.id}
|
|
42
|
+
ref={(el) => {
|
|
43
|
+
thumbnailRefs.current[index] = el;
|
|
44
|
+
}}
|
|
45
|
+
data-active={selectedIndex === index ? "true" : "false"}
|
|
46
|
+
onClick={() => onThumbnailClick(index)}
|
|
47
|
+
opacity={selectedIndex === index ? 1 : 0.4}
|
|
48
|
+
className={styles.ThumbnailButton}
|
|
49
|
+
style={{ flexShrink: 0 }}
|
|
50
|
+
radius="ExtraLight"
|
|
51
|
+
>
|
|
52
|
+
<View
|
|
53
|
+
style={{
|
|
54
|
+
position: "relative",
|
|
55
|
+
width: "4.8rem",
|
|
56
|
+
height: "4.8rem",
|
|
57
|
+
overflow: "hidden",
|
|
58
|
+
}}
|
|
59
|
+
>
|
|
60
|
+
<NextImage
|
|
61
|
+
fill
|
|
62
|
+
src={resolveImageSrc(item, "inline")}
|
|
63
|
+
alt=""
|
|
64
|
+
placeholder="blur"
|
|
65
|
+
blurDataURL={resolveBlurDataURL(item, index)}
|
|
66
|
+
draggable={false}
|
|
67
|
+
style={{ objectFit: "cover" }}
|
|
68
|
+
/>
|
|
69
|
+
</View>
|
|
70
|
+
</Pressable>
|
|
71
|
+
))}
|
|
72
|
+
</View>
|
|
73
|
+
);
|
|
74
|
+
}
|