@zayne-labs/ui-react 0.0.3
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/esm/For-BmvZgK9J.d.ts +17 -0
- package/dist/esm/chunk-7TYZVYD6.js +42 -0
- package/dist/esm/chunk-7TYZVYD6.js.map +1 -0
- package/dist/esm/chunk-ABOA7YOO.js +9 -0
- package/dist/esm/chunk-ABOA7YOO.js.map +1 -0
- package/dist/esm/common/For/index.d.ts +9 -0
- package/dist/esm/common/For/index.js +3 -0
- package/dist/esm/common/For/index.js.map +1 -0
- package/dist/esm/common/Show/index.d.ts +22 -0
- package/dist/esm/common/Show/index.js +38 -0
- package/dist/esm/common/Show/index.js.map +1 -0
- package/dist/esm/common/Slot/index.d.ts +8 -0
- package/dist/esm/common/Slot/index.js +47 -0
- package/dist/esm/common/Slot/index.js.map +1 -0
- package/dist/esm/common/Switch/index.d.ts +20 -0
- package/dist/esm/common/Switch/index.js +26 -0
- package/dist/esm/common/Switch/index.js.map +1 -0
- package/dist/esm/common/Teleport/index.d.ts +12 -0
- package/dist/esm/common/Teleport/index.js +31 -0
- package/dist/esm/common/Teleport/index.js.map +1 -0
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/ui/carousel/index.d.ts +96 -0
- package/dist/esm/ui/carousel/index.js +263 -0
- package/dist/esm/ui/carousel/index.js.map +1 -0
- package/dist/esm/ui/drag-scroll/index.d.ts +25 -0
- package/dist/esm/ui/drag-scroll/index.js +104 -0
- package/dist/esm/ui/drag-scroll/index.js.map +1 -0
- package/dist/esm/ui/drop-zone/index.d.ts +655 -0
- package/dist/esm/ui/drop-zone/index.js +125 -0
- package/dist/esm/ui/drop-zone/index.js.map +1 -0
- package/dist/esm/ui/form/index.d.ts +159 -0
- package/dist/esm/ui/form/index.js +336 -0
- package/dist/esm/ui/form/index.js.map +1 -0
- package/package.json +113 -0
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import { getElementList } from '../../chunk-7TYZVYD6.js';
|
|
2
|
+
import { cnMerge } from '../../chunk-ABOA7YOO.js';
|
|
3
|
+
import * as React2 from 'react';
|
|
4
|
+
import { useEffect, useState } from 'react';
|
|
5
|
+
import { useConstant, useAnimationInterval, useCallbackRef } from '@zayne-labs/toolkit-react';
|
|
6
|
+
import { createZustandContext } from '@zayne-labs/toolkit-react/zustand';
|
|
7
|
+
import { create } from 'zustand';
|
|
8
|
+
|
|
9
|
+
// src/components/icons/ChevronLeftIcon.tsx
|
|
10
|
+
var ChevronLeftIcon = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "1em", height: "1em", viewBox: "0 0 24 24", ...props }, /* @__PURE__ */ React.createElement("g", { fill: "none", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2" }, /* @__PURE__ */ React.createElement("circle", { cx: "12", cy: "12", r: "10" }), /* @__PURE__ */ React.createElement("path", { d: "m14 16l-4-4l4-4" })));
|
|
11
|
+
var [Provider, useCarouselStore] = createZustandContext({
|
|
12
|
+
hookName: "useCarouselStore",
|
|
13
|
+
name: "CarouselStoreContext",
|
|
14
|
+
providerName: "CarouselContextProvider"
|
|
15
|
+
});
|
|
16
|
+
var createCarouselStore = (storeValues) => {
|
|
17
|
+
const { images, onSlideBtnClick } = storeValues;
|
|
18
|
+
const useInitCarouselStore = create()((set, get) => ({
|
|
19
|
+
currentSlide: 0,
|
|
20
|
+
images,
|
|
21
|
+
maxSlide: images.length - 1,
|
|
22
|
+
/* eslint-disable perfectionist/sort-objects -- actions should be last */
|
|
23
|
+
actions: {
|
|
24
|
+
/* eslint-enable perfectionist/sort-objects -- actions should be last */
|
|
25
|
+
goToNextSlide: () => {
|
|
26
|
+
const { currentSlide, maxSlide } = get();
|
|
27
|
+
const { goToSlide } = get().actions;
|
|
28
|
+
if (currentSlide === maxSlide) {
|
|
29
|
+
goToSlide(0);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
goToSlide(currentSlide + 1);
|
|
33
|
+
},
|
|
34
|
+
goToPreviousSlide: () => {
|
|
35
|
+
const { currentSlide, maxSlide } = get();
|
|
36
|
+
const { goToSlide } = get().actions;
|
|
37
|
+
if (currentSlide === 0) {
|
|
38
|
+
goToSlide(maxSlide);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
goToSlide(currentSlide - 1);
|
|
42
|
+
},
|
|
43
|
+
goToSlide: (newValue) => {
|
|
44
|
+
onSlideBtnClick?.();
|
|
45
|
+
set({ currentSlide: newValue });
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}));
|
|
49
|
+
return useInitCarouselStore;
|
|
50
|
+
};
|
|
51
|
+
function CarouselContextProvider(props) {
|
|
52
|
+
const { children, images, onSlideBtnClick } = props;
|
|
53
|
+
const useInitCarouselStore = useConstant(() => createCarouselStore({ images, onSlideBtnClick }));
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
useInitCarouselStore.setState({ images });
|
|
56
|
+
}, [images]);
|
|
57
|
+
return /* @__PURE__ */ React.createElement(Provider, { value: useInitCarouselStore }, children);
|
|
58
|
+
}
|
|
59
|
+
var useCarouselOptions = (options = {}) => {
|
|
60
|
+
const { autoSlideInterval = 5e3, hasAutoSlide = false, shouldPauseOnHover = false } = options;
|
|
61
|
+
const { goToNextSlide } = useCarouselStore((state) => state.actions);
|
|
62
|
+
const [isPaused, setIsPaused] = useState(false);
|
|
63
|
+
const shouldAutoSlide = hasAutoSlide && !isPaused;
|
|
64
|
+
useAnimationInterval({
|
|
65
|
+
intervalDuration: shouldAutoSlide ? autoSlideInterval : null,
|
|
66
|
+
onAnimation: goToNextSlide
|
|
67
|
+
});
|
|
68
|
+
const pauseAutoSlide = useCallbackRef(() => shouldPauseOnHover && setIsPaused(true));
|
|
69
|
+
const resumeAutoSlide = useCallbackRef(() => shouldPauseOnHover && setIsPaused(false));
|
|
70
|
+
return { pauseAutoSlide, resumeAutoSlide };
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
// src/components/ui/carousel/carousel.tsx
|
|
74
|
+
function CarouselContent(props) {
|
|
75
|
+
const {
|
|
76
|
+
as: HtmlElement = "article",
|
|
77
|
+
autoSlideInterval,
|
|
78
|
+
children,
|
|
79
|
+
classNames,
|
|
80
|
+
hasAutoSlide,
|
|
81
|
+
shouldPauseOnHover
|
|
82
|
+
} = props;
|
|
83
|
+
const { pauseAutoSlide, resumeAutoSlide } = useCarouselOptions({
|
|
84
|
+
autoSlideInterval,
|
|
85
|
+
hasAutoSlide,
|
|
86
|
+
shouldPauseOnHover
|
|
87
|
+
});
|
|
88
|
+
return /* @__PURE__ */ React2.createElement(
|
|
89
|
+
HtmlElement,
|
|
90
|
+
{
|
|
91
|
+
"data-id": "Carousel",
|
|
92
|
+
className: cnMerge("relative select-none", classNames?.base),
|
|
93
|
+
onMouseEnter: pauseAutoSlide,
|
|
94
|
+
onMouseLeave: resumeAutoSlide
|
|
95
|
+
},
|
|
96
|
+
/* @__PURE__ */ React2.createElement(
|
|
97
|
+
"div",
|
|
98
|
+
{
|
|
99
|
+
"data-id": "Scroll Container",
|
|
100
|
+
className: cnMerge(
|
|
101
|
+
"flex size-full overflow-x-scroll [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",
|
|
102
|
+
classNames?.scrollContainer
|
|
103
|
+
)
|
|
104
|
+
},
|
|
105
|
+
children
|
|
106
|
+
)
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
function CarouselButton(props) {
|
|
110
|
+
const { classNames, icon, variant } = props;
|
|
111
|
+
const { goToNextSlide, goToPreviousSlide } = useCarouselStore((state) => state.actions);
|
|
112
|
+
return /* @__PURE__ */ React2.createElement(
|
|
113
|
+
"button",
|
|
114
|
+
{
|
|
115
|
+
type: "button",
|
|
116
|
+
className: cnMerge(
|
|
117
|
+
"z-30 flex h-full w-[15%] items-center",
|
|
118
|
+
variant === "prev" ? "justify-start" : "justify-end",
|
|
119
|
+
classNames?.base
|
|
120
|
+
),
|
|
121
|
+
onClick: variant === "prev" ? goToPreviousSlide : goToNextSlide
|
|
122
|
+
},
|
|
123
|
+
/* @__PURE__ */ React2.createElement("span", { className: cnMerge("transition-transform active:scale-[1.06]", classNames?.iconContainer) }, icon ?? /* @__PURE__ */ React2.createElement(
|
|
124
|
+
ChevronLeftIcon,
|
|
125
|
+
{
|
|
126
|
+
className: cnMerge(variant === "next" && "rotate-180", classNames?.defaultIcon)
|
|
127
|
+
}
|
|
128
|
+
))
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
function CarouselControls(props) {
|
|
132
|
+
const { classNames, icon } = props;
|
|
133
|
+
return /* @__PURE__ */ React2.createElement("div", { className: cnMerge("absolute inset-0 flex justify-between", classNames?.base) }, icon?.iconType ? /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(
|
|
134
|
+
CarouselButton,
|
|
135
|
+
{
|
|
136
|
+
variant: "prev",
|
|
137
|
+
classNames: {
|
|
138
|
+
defaultIcon: classNames?.defaultIcon,
|
|
139
|
+
iconContainer: cnMerge(
|
|
140
|
+
icon.iconType === "nextIcon" && "rotate-180",
|
|
141
|
+
classNames?.iconContainer
|
|
142
|
+
)
|
|
143
|
+
},
|
|
144
|
+
icon: icon.icon
|
|
145
|
+
}
|
|
146
|
+
), /* @__PURE__ */ React2.createElement(
|
|
147
|
+
CarouselButton,
|
|
148
|
+
{
|
|
149
|
+
variant: "next",
|
|
150
|
+
classNames: {
|
|
151
|
+
defaultIcon: classNames?.defaultIcon,
|
|
152
|
+
iconContainer: cnMerge(
|
|
153
|
+
icon.iconType === "prevIcon" && "rotate-180",
|
|
154
|
+
classNames?.iconContainer
|
|
155
|
+
)
|
|
156
|
+
},
|
|
157
|
+
icon: icon.icon
|
|
158
|
+
}
|
|
159
|
+
)) : /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(
|
|
160
|
+
CarouselButton,
|
|
161
|
+
{
|
|
162
|
+
variant: "prev",
|
|
163
|
+
classNames: {
|
|
164
|
+
defaultIcon: classNames?.defaultIcon,
|
|
165
|
+
iconContainer: classNames?.iconContainer
|
|
166
|
+
},
|
|
167
|
+
icon: icon?.prev
|
|
168
|
+
}
|
|
169
|
+
), /* @__PURE__ */ React2.createElement(
|
|
170
|
+
CarouselButton,
|
|
171
|
+
{
|
|
172
|
+
variant: "next",
|
|
173
|
+
classNames: {
|
|
174
|
+
defaultIcon: classNames?.defaultIcon,
|
|
175
|
+
iconContainer: classNames?.iconContainer
|
|
176
|
+
},
|
|
177
|
+
icon: icon?.next
|
|
178
|
+
}
|
|
179
|
+
)));
|
|
180
|
+
}
|
|
181
|
+
function CarouselItemWrapper(props) {
|
|
182
|
+
const { children, className, each, render } = props;
|
|
183
|
+
const [ItemList] = getElementList("base");
|
|
184
|
+
const currentSlide = useCarouselStore((state) => state.currentSlide);
|
|
185
|
+
const images = useCarouselStore((state) => each ?? state.images);
|
|
186
|
+
return /* @__PURE__ */ React2.createElement(
|
|
187
|
+
"ul",
|
|
188
|
+
{
|
|
189
|
+
"data-id": "Carousel Image Wrapper",
|
|
190
|
+
className: cnMerge(
|
|
191
|
+
`flex w-full shrink-0 snap-center [transform:translate3d(var(--translate-distance),0,0)]
|
|
192
|
+
[transition:transform_800ms_ease]`,
|
|
193
|
+
className
|
|
194
|
+
),
|
|
195
|
+
style: {
|
|
196
|
+
"--translate-distance": `-${currentSlide * 100}%`
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
typeof render === "function" ? /* @__PURE__ */ React2.createElement(ItemList, { each: images, render }) : /* @__PURE__ */ React2.createElement(ItemList, { each: images }, children)
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
function CarouselItem({ children, className, ...restOfProps }) {
|
|
203
|
+
return /* @__PURE__ */ React2.createElement(
|
|
204
|
+
"li",
|
|
205
|
+
{
|
|
206
|
+
className: cnMerge("flex w-full shrink-0 snap-center justify-center", className),
|
|
207
|
+
...restOfProps
|
|
208
|
+
},
|
|
209
|
+
children
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
function CarouselCaption(props) {
|
|
213
|
+
const { as: HtmlElement = "div", children, className } = props;
|
|
214
|
+
return /* @__PURE__ */ React2.createElement(HtmlElement, { "data-id": "Carousel Caption", className: cnMerge("absolute z-10", className) }, children);
|
|
215
|
+
}
|
|
216
|
+
function CarouselIndicatorWrapper(props) {
|
|
217
|
+
const { children, className, each, render } = props;
|
|
218
|
+
const images = useCarouselStore((state) => each ?? state.images);
|
|
219
|
+
const [IndicatorList] = getElementList("base");
|
|
220
|
+
return /* @__PURE__ */ React2.createElement(
|
|
221
|
+
"ul",
|
|
222
|
+
{
|
|
223
|
+
"data-id": "Carousel Indicators",
|
|
224
|
+
className: cnMerge(
|
|
225
|
+
"absolute bottom-10 z-[2] flex w-full items-center justify-center gap-6",
|
|
226
|
+
className
|
|
227
|
+
)
|
|
228
|
+
},
|
|
229
|
+
typeof render === "function" ? /* @__PURE__ */ React2.createElement(IndicatorList, { each: images, render }) : /* @__PURE__ */ React2.createElement(IndicatorList, { each: images }, children)
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
function CarouselIndicator(props) {
|
|
233
|
+
const { classNames, currentIndex } = props;
|
|
234
|
+
const {
|
|
235
|
+
actions: { goToSlide },
|
|
236
|
+
currentSlide
|
|
237
|
+
} = useCarouselStore((state) => state);
|
|
238
|
+
return /* @__PURE__ */ React2.createElement("li", { className: cnMerge("inline-flex", classNames?.base) }, /* @__PURE__ */ React2.createElement(
|
|
239
|
+
"button",
|
|
240
|
+
{
|
|
241
|
+
"data-active": currentIndex === currentSlide,
|
|
242
|
+
type: "button",
|
|
243
|
+
onClick: () => goToSlide(currentIndex),
|
|
244
|
+
className: cnMerge(
|
|
245
|
+
"size-[6px] rounded-[50%]",
|
|
246
|
+
classNames?.button,
|
|
247
|
+
currentIndex === currentSlide && ["w-14 rounded-lg", classNames?.activeBtn]
|
|
248
|
+
)
|
|
249
|
+
}
|
|
250
|
+
));
|
|
251
|
+
}
|
|
252
|
+
var Content = CarouselContent;
|
|
253
|
+
var Controls = CarouselControls;
|
|
254
|
+
var Button = CarouselButton;
|
|
255
|
+
var Item = CarouselItem;
|
|
256
|
+
var ItemWrapper = CarouselItemWrapper;
|
|
257
|
+
var Caption = CarouselCaption;
|
|
258
|
+
var Indicator = CarouselIndicator;
|
|
259
|
+
var IndicatorWrapper = CarouselIndicatorWrapper;
|
|
260
|
+
|
|
261
|
+
export { Button, Caption, CarouselButton, CarouselCaption, CarouselContent, CarouselControls, CarouselIndicator, CarouselIndicatorWrapper, CarouselItem, CarouselItemWrapper, Content, Controls, Indicator, IndicatorWrapper, Item, ItemWrapper, CarouselContextProvider as Root };
|
|
262
|
+
//# sourceMappingURL=index.js.map
|
|
263
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/icons/ChevronLeftIcon.tsx","../../../../src/components/ui/carousel/carouselStoreContext.tsx","../../../../src/components/ui/carousel/useCarouselOptions.ts","../../../../src/components/ui/carousel/carousel.tsx"],"names":[],"mappings":";;;;;;;;;AAAA,IAAM,kBAAkB,CAAC,KAAA,yCACvB,KAAI,EAAA,EAAA,KAAA,EAAM,8BAA6B,KAAM,EAAA,KAAA,EAAM,MAAO,EAAA,KAAA,EAAM,SAAQ,WAAa,EAAA,GAAG,yBACvF,KAAA,CAAA,aAAA,CAAA,GAAA,EAAA,EAAE,MAAK,MAAO,EAAA,MAAA,EAAO,cAAe,EAAA,aAAA,EAAc,SAAQ,cAAe,EAAA,OAAA,EAAQ,aAAY,GAC7F,EAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,YAAO,EAAG,EAAA,IAAA,EAAK,IAAG,IAAK,EAAA,CAAA,EAAE,MAAK,CAC/B,kBAAA,KAAA,CAAA,aAAA,CAAC,UAAK,CAAE,EAAA,iBAAA,EAAkB,CAC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AW,UAClB,mBAAA,MAAA,CAAA,aAAA,CAAC,aAAc,EAAA,EAAA,IAAA,EAAM,MAAQ,EAAA,MAAA,EAAgB,CAE7C,mBAAA,MAAA,CAAA,aAAA,CAAC,aAAc,EAAA,EAAA,IAAA,EAAM,UAAS,QAAS;AAAA,GAEzC;AAEF;AAEO,SAAS,kBAAkB,KAA+B,EAAA;AAChE,EAAM,MAAA,EAAE,UAAY,EAAA,YAAA,EAAiB,GAAA,KAAA;AAErC,EAAM,MAAA;AAAA,IACL,OAAA,EAAS,EAAE,SAAU,EAAA;AAAA,IACrB;AAAA,GACG,GAAA,gBAAA,CAAiB,CAAC,KAAA,KAAU,KAAK,CAAA;AAErC,EAAA,4CACE,IAAG,EAAA,EAAA,SAAA,EAAW,QAAQ,aAAe,EAAA,UAAA,EAAY,IAAI,CACrD,EAAA,kBAAA,MAAA,CAAA,aAAA;AAAA,IAAC,QAAA;AAAA,IAAA;AAAA,MACA,eAAa,YAAiB,KAAA,YAAA;AAAA,MAC9B,IAAK,EAAA,QAAA;AAAA,MACL,OAAA,EAAS,MAAM,SAAA,CAAU,YAAY,CAAA;AAAA,MACrC,SAAW,EAAA,OAAA;AAAA,QACV,0BAAA;AAAA,QACA,UAAY,EAAA,MAAA;AAAA,QACZ,YAAiB,KAAA,YAAA,IAAgB,CAAC,iBAAA,EAAmB,YAAY,SAAS;AAAA;AAC3E;AAAA,GAEF,CAAA;AAEF;AAIO,IAAM,OAAU,GAAA;AAEhB,IAAM,QAAW,GAAA;AAEjB,IAAM,MAAS,GAAA;AAEf,IAAM,IAAO,GAAA;AAEb,IAAM,WAAc,GAAA;AAEpB,IAAM,OAAU,GAAA;AAEhB,IAAM,SAAY,GAAA;AAElB,IAAM,gBAAmB,GAAA","file":"index.js","sourcesContent":["const ChevronLeftIcon = (props: React.SVGProps<SVGSVGElement>) => (\n\t<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"1em\" height=\"1em\" viewBox=\"0 0 24 24\" {...props}>\n\t\t<g fill=\"none\" stroke=\"currentColor\" strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth=\"2\">\n\t\t\t<circle cx=\"12\" cy=\"12\" r=\"10\" />\n\t\t\t<path d=\"m14 16l-4-4l4-4\" />\n\t\t</g>\n\t</svg>\n);\n\nexport { ChevronLeftIcon };\n","import { useConstant } from \"@zayne-labs/toolkit-react\";\nimport { createZustandContext } from \"@zayne-labs/toolkit-react/zustand\";\nimport type { PrettyOmit } from \"@zayne-labs/toolkit-type-helpers\";\nimport { useEffect } from \"react\";\nimport { create } from \"zustand\";\nimport type { CarouselProviderProps, CarouselStore, ImagesType } from \"./types\";\n\nconst [Provider, useCarouselStore] = createZustandContext<CarouselStore>({\n\thookName: \"useCarouselStore\",\n\tname: \"CarouselStoreContext\",\n\tproviderName: \"CarouselContextProvider\",\n});\n\n// CarouselStore Creation\nconst createCarouselStore = <TImages extends ImagesType>(\n\tstoreValues: PrettyOmit<CarouselProviderProps<TImages>, \"children\">\n) => {\n\tconst { images, onSlideBtnClick } = storeValues;\n\n\tconst useInitCarouselStore = create<CarouselStore<TImages>>()((set, get) => ({\n\t\tcurrentSlide: 0,\n\t\timages,\n\t\tmaxSlide: images.length - 1,\n\n\t\t/* eslint-disable perfectionist/sort-objects -- actions should be last */\n\t\tactions: {\n\t\t\t/* eslint-enable perfectionist/sort-objects -- actions should be last */\n\n\t\t\tgoToNextSlide: () => {\n\t\t\t\tconst { currentSlide, maxSlide } = get();\n\t\t\t\tconst { goToSlide } = get().actions;\n\n\t\t\t\tif (currentSlide === maxSlide) {\n\t\t\t\t\tgoToSlide(0);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tgoToSlide(currentSlide + 1);\n\t\t\t},\n\n\t\t\tgoToPreviousSlide: () => {\n\t\t\t\tconst { currentSlide, maxSlide } = get();\n\t\t\t\tconst { goToSlide } = get().actions;\n\n\t\t\t\tif (currentSlide === 0) {\n\t\t\t\t\tgoToSlide(maxSlide);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tgoToSlide(currentSlide - 1);\n\t\t\t},\n\n\t\t\tgoToSlide: (newValue) => {\n\t\t\t\tonSlideBtnClick?.();\n\n\t\t\t\tset({ currentSlide: newValue });\n\t\t\t},\n\t\t},\n\t}));\n\n\treturn useInitCarouselStore;\n};\n\n// == Provider Component\nfunction CarouselContextProvider<TImages extends ImagesType>(props: CarouselProviderProps<TImages>) {\n\tconst { children, images, onSlideBtnClick } = props;\n\n\tconst useInitCarouselStore = useConstant(() => createCarouselStore({ images, onSlideBtnClick }));\n\n\t// == To set images again when a page is mounted, preventing stale images from previous page\n\tuseEffect(() => {\n\t\tuseInitCarouselStore.setState({ images });\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps -- useInitCarouselStore is stable\n\t}, [images]);\n\n\treturn <Provider value={useInitCarouselStore}>{children}</Provider>;\n}\n\n// eslint-disable-next-line react-refresh/only-export-components -- It's fine\nexport { useCarouselStore, CarouselContextProvider };\n","import { useAnimationInterval, useCallbackRef } from \"@zayne-labs/toolkit-react\";\nimport { useState } from \"react\";\nimport { useCarouselStore } from \"./carouselStoreContext\";\n\ntype CarouselOptions = {\n\tautoSlideInterval?: number;\n\thasAutoSlide?: boolean;\n\tshouldPauseOnHover?: boolean;\n};\n\nconst useCarouselOptions = (options: CarouselOptions = {}) => {\n\tconst { autoSlideInterval = 5000, hasAutoSlide = false, shouldPauseOnHover = false } = options;\n\n\tconst { goToNextSlide } = useCarouselStore((state) => state.actions);\n\n\tconst [isPaused, setIsPaused] = useState(false);\n\n\tconst shouldAutoSlide = hasAutoSlide && !isPaused;\n\n\tuseAnimationInterval({\n\t\tintervalDuration: shouldAutoSlide ? autoSlideInterval : null,\n\t\tonAnimation: goToNextSlide,\n\t});\n\n\tconst pauseAutoSlide = useCallbackRef(() => shouldPauseOnHover && setIsPaused(true));\n\n\tconst resumeAutoSlide = useCallbackRef(() => shouldPauseOnHover && setIsPaused(false));\n\n\treturn { pauseAutoSlide, resumeAutoSlide };\n};\n\nexport { useCarouselOptions };\n","\"use client\";\n\nimport * as React from \"react\";\n\nimport { getElementList } from \"@/components/common/For\";\nimport { ChevronLeftIcon } from \"@/components/icons\";\nimport { cnMerge } from \"@/lib/utils/cn\";\nimport type { MyCustomCss, PolymorphicProps } from \"@zayne-labs/toolkit-react/utils\";\nimport { useCarouselStore } from \"./carouselStoreContext\";\nimport type {\n\tCarouselButtonsProps,\n\tCarouselContentProps,\n\tCarouselControlProps,\n\tCarouselIndicatorProps,\n\tCarouselWrapperProps,\n\tOtherCarouselProps,\n} from \"./types\";\nimport { useCarouselOptions } from \"./useCarouselOptions\";\n\n// TODO - Add dragging and swiping support\nexport function CarouselContent<TElement extends React.ElementType = \"article\">(\n\tprops: PolymorphicProps<TElement, CarouselContentProps>\n) {\n\tconst {\n\t\tas: HtmlElement = \"article\",\n\t\tautoSlideInterval,\n\t\tchildren,\n\t\tclassNames,\n\t\thasAutoSlide,\n\t\tshouldPauseOnHover,\n\t} = props;\n\n\tconst { pauseAutoSlide, resumeAutoSlide } = useCarouselOptions({\n\t\tautoSlideInterval,\n\t\thasAutoSlide,\n\t\tshouldPauseOnHover,\n\t});\n\n\t// FIXME - Prevent touch swipe on mobile using a cover element or allow swipe but it must update the state appriopriately\n\treturn (\n\t\t<HtmlElement\n\t\t\tdata-id=\"Carousel\"\n\t\t\tclassName={cnMerge(\"relative select-none\", classNames?.base)}\n\t\t\tonMouseEnter={pauseAutoSlide}\n\t\t\tonMouseLeave={resumeAutoSlide}\n\t\t>\n\t\t\t<div\n\t\t\t\tdata-id=\"Scroll Container\"\n\t\t\t\tclassName={cnMerge(\n\t\t\t\t\t\"flex size-full overflow-x-scroll [scrollbar-width:none] [&::-webkit-scrollbar]:hidden\",\n\t\t\t\t\tclassNames?.scrollContainer\n\t\t\t\t)}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</div>\n\t\t</HtmlElement>\n\t);\n}\n\nexport function CarouselButton(props: CarouselButtonsProps) {\n\tconst { classNames, icon, variant } = props;\n\n\tconst { goToNextSlide, goToPreviousSlide } = useCarouselStore((state) => state.actions);\n\n\treturn (\n\t\t<button\n\t\t\ttype=\"button\"\n\t\t\tclassName={cnMerge(\n\t\t\t\t\"z-30 flex h-full w-[15%] items-center\",\n\t\t\t\tvariant === \"prev\" ? \"justify-start\" : \"justify-end\",\n\t\t\t\tclassNames?.base\n\t\t\t)}\n\t\t\tonClick={variant === \"prev\" ? goToPreviousSlide : goToNextSlide}\n\t\t>\n\t\t\t<span className={cnMerge(\"transition-transform active:scale-[1.06]\", classNames?.iconContainer)}>\n\t\t\t\t{icon ?? (\n\t\t\t\t\t<ChevronLeftIcon\n\t\t\t\t\t\tclassName={cnMerge(variant === \"next\" && \"rotate-180\", classNames?.defaultIcon)}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t</span>\n\t\t</button>\n\t);\n}\n\nexport function CarouselControls(props: CarouselControlProps) {\n\tconst { classNames, icon } = props;\n\n\treturn (\n\t\t<div className={cnMerge(\"absolute inset-0 flex justify-between\", classNames?.base)}>\n\t\t\t{icon?.iconType ? (\n\t\t\t\t<>\n\t\t\t\t\t<CarouselButton\n\t\t\t\t\t\tvariant=\"prev\"\n\t\t\t\t\t\tclassNames={{\n\t\t\t\t\t\t\tdefaultIcon: classNames?.defaultIcon,\n\t\t\t\t\t\t\ticonContainer: cnMerge(\n\t\t\t\t\t\t\t\ticon.iconType === \"nextIcon\" && \"rotate-180\",\n\t\t\t\t\t\t\t\tclassNames?.iconContainer\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t}}\n\t\t\t\t\t\ticon={icon.icon}\n\t\t\t\t\t/>\n\t\t\t\t\t<CarouselButton\n\t\t\t\t\t\tvariant=\"next\"\n\t\t\t\t\t\tclassNames={{\n\t\t\t\t\t\t\tdefaultIcon: classNames?.defaultIcon,\n\t\t\t\t\t\t\ticonContainer: cnMerge(\n\t\t\t\t\t\t\t\ticon.iconType === \"prevIcon\" && \"rotate-180\",\n\t\t\t\t\t\t\t\tclassNames?.iconContainer\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t}}\n\t\t\t\t\t\ticon={icon.icon}\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t) : (\n\t\t\t\t<>\n\t\t\t\t\t<CarouselButton\n\t\t\t\t\t\tvariant=\"prev\"\n\t\t\t\t\t\tclassNames={{\n\t\t\t\t\t\t\tdefaultIcon: classNames?.defaultIcon,\n\t\t\t\t\t\t\ticonContainer: classNames?.iconContainer,\n\t\t\t\t\t\t}}\n\t\t\t\t\t\ticon={icon?.prev}\n\t\t\t\t\t/>\n\t\t\t\t\t<CarouselButton\n\t\t\t\t\t\tvariant=\"next\"\n\t\t\t\t\t\tclassNames={{\n\t\t\t\t\t\t\tdefaultIcon: classNames?.defaultIcon,\n\t\t\t\t\t\t\ticonContainer: classNames?.iconContainer,\n\t\t\t\t\t\t}}\n\t\t\t\t\t\ticon={icon?.next}\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t)}\n\t\t</div>\n\t);\n}\n\nexport function CarouselItemWrapper<TArrayItem>(props: CarouselWrapperProps<TArrayItem>) {\n\tconst { children, className, each, render } = props;\n\n\tconst [ItemList] = getElementList(\"base\");\n\tconst currentSlide = useCarouselStore((state) => state.currentSlide);\n\tconst images = useCarouselStore((state) => each ?? (state.images as TArrayItem[]));\n\n\treturn (\n\t\t<ul\n\t\t\tdata-id=\"Carousel Image Wrapper\"\n\t\t\tclassName={cnMerge(\n\t\t\t\t`flex w-full shrink-0 snap-center [transform:translate3d(var(--translate-distance),0,0)]\n\t\t\t\t[transition:transform_800ms_ease]`,\n\t\t\t\tclassName\n\t\t\t)}\n\t\t\tstyle={\n\t\t\t\t{\n\t\t\t\t\t\"--translate-distance\": `-${currentSlide * 100}%`,\n\t\t\t\t} satisfies MyCustomCss as MyCustomCss\n\t\t\t}\n\t\t>\n\t\t\t{typeof render === \"function\" ? (\n\t\t\t\t<ItemList each={images} render={render} />\n\t\t\t) : (\n\t\t\t\t<ItemList each={images}>{children}</ItemList>\n\t\t\t)}\n\t\t</ul>\n\t);\n}\n\nexport function CarouselItem({ children, className, ...restOfProps }: OtherCarouselProps) {\n\treturn (\n\t\t<li\n\t\t\tclassName={cnMerge(\"flex w-full shrink-0 snap-center justify-center\", className)}\n\t\t\t{...restOfProps}\n\t\t>\n\t\t\t{children}\n\t\t</li>\n\t);\n}\n\nexport function CarouselCaption<TElement extends React.ElementType = \"div\">(\n\tprops: PolymorphicProps<TElement, OtherCarouselProps>\n) {\n\tconst { as: HtmlElement = \"div\", children, className } = props;\n\n\treturn (\n\t\t<HtmlElement data-id=\"Carousel Caption\" className={cnMerge(\"absolute z-10\", className)}>\n\t\t\t{children}\n\t\t</HtmlElement>\n\t);\n}\n\nexport function CarouselIndicatorWrapper<TArrayItem>(props: CarouselWrapperProps<TArrayItem>) {\n\tconst { children, className, each, render } = props;\n\n\tconst images = useCarouselStore((state) => each ?? (state.images as TArrayItem[]));\n\tconst [IndicatorList] = getElementList(\"base\");\n\n\treturn (\n\t\t<ul\n\t\t\tdata-id=\"Carousel Indicators\"\n\t\t\tclassName={cnMerge(\n\t\t\t\t\"absolute bottom-10 z-[2] flex w-full items-center justify-center gap-6\",\n\t\t\t\tclassName\n\t\t\t)}\n\t\t>\n\t\t\t{typeof render === \"function\" ? (\n\t\t\t\t<IndicatorList each={images} render={render} />\n\t\t\t) : (\n\t\t\t\t<IndicatorList each={images}>{children}</IndicatorList>\n\t\t\t)}\n\t\t</ul>\n\t);\n}\n\nexport function CarouselIndicator(props: CarouselIndicatorProps) {\n\tconst { classNames, currentIndex } = props;\n\n\tconst {\n\t\tactions: { goToSlide },\n\t\tcurrentSlide,\n\t} = useCarouselStore((state) => state);\n\n\treturn (\n\t\t<li className={cnMerge(\"inline-flex\", classNames?.base)}>\n\t\t\t<button\n\t\t\t\tdata-active={currentIndex === currentSlide}\n\t\t\t\ttype=\"button\"\n\t\t\t\tonClick={() => goToSlide(currentIndex)}\n\t\t\t\tclassName={cnMerge(\n\t\t\t\t\t\"size-[6px] rounded-[50%]\",\n\t\t\t\t\tclassNames?.button,\n\t\t\t\t\tcurrentIndex === currentSlide && [\"w-14 rounded-lg\", classNames?.activeBtn]\n\t\t\t\t)}\n\t\t\t/>\n\t\t</li>\n\t);\n}\n\nexport { CarouselContextProvider as Root } from \"./carouselStoreContext\";\n\nexport const Content = CarouselContent;\n\nexport const Controls = CarouselControls;\n\nexport const Button = CarouselButton;\n\nexport const Item = CarouselItem;\n\nexport const ItemWrapper = CarouselItemWrapper;\n\nexport const Caption = CarouselCaption;\n\nexport const Indicator = CarouselIndicator;\n\nexport const IndicatorWrapper = CarouselIndicatorWrapper;\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { RefCallback } from 'react';
|
|
2
|
+
|
|
3
|
+
type DragScrollProps = {
|
|
4
|
+
classNames?: {
|
|
5
|
+
base?: string;
|
|
6
|
+
item?: string;
|
|
7
|
+
};
|
|
8
|
+
orientation?: "both" | "horizontal" | "vertical";
|
|
9
|
+
usage?: "allScreens" | "desktopOnly" | "mobileAndTabletOnly";
|
|
10
|
+
};
|
|
11
|
+
declare const useDragScroll: <TElement extends HTMLElement>(props?: DragScrollProps) => {
|
|
12
|
+
getItemProps: () => {
|
|
13
|
+
className: string;
|
|
14
|
+
"data-part": string;
|
|
15
|
+
"data-scope": string;
|
|
16
|
+
};
|
|
17
|
+
getRootProps: () => {
|
|
18
|
+
className: string;
|
|
19
|
+
"data-part": string;
|
|
20
|
+
"data-scope": string;
|
|
21
|
+
ref: RefCallback<TElement>;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export { useDragScroll };
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { cnMerge } from '../../chunk-ABOA7YOO.js';
|
|
2
|
+
import { off, on, checkIsDeviceMobileOrTablet } from '@zayne-labs/toolkit-core';
|
|
3
|
+
import { useCallbackRef } from '@zayne-labs/toolkit-react';
|
|
4
|
+
import { useRef } from 'react';
|
|
5
|
+
|
|
6
|
+
var updateCursor = (element) => {
|
|
7
|
+
element.style.cursor = "grabbing";
|
|
8
|
+
element.style.userSelect = "none";
|
|
9
|
+
};
|
|
10
|
+
var onScrollSnap = (action, element) => {
|
|
11
|
+
if (action === "remove") {
|
|
12
|
+
element.style.scrollSnapType = "none";
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
element.style.scrollSnapType = "";
|
|
16
|
+
};
|
|
17
|
+
var resetCursor = (element) => {
|
|
18
|
+
element.style.cursor = "";
|
|
19
|
+
element.style.userSelect = "";
|
|
20
|
+
};
|
|
21
|
+
var handleScrollSnap = (dragContainer) => {
|
|
22
|
+
const isMobileOrTablet = checkIsDeviceMobileOrTablet();
|
|
23
|
+
if (!isMobileOrTablet) {
|
|
24
|
+
onScrollSnap("remove", dragContainer);
|
|
25
|
+
} else {
|
|
26
|
+
onScrollSnap("reset", dragContainer);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
// src/components/ui/drag-scroll/useDragScroll.ts
|
|
31
|
+
var useDragScroll = (props = {}) => {
|
|
32
|
+
const { classNames, orientation = "horizontal", usage = "allScreens" } = props;
|
|
33
|
+
const dragContainerRef = useRef(null);
|
|
34
|
+
const positionRef = useRef({ left: 0, top: 0, x: 0, y: 0 });
|
|
35
|
+
const handleMouseMove = useCallbackRef((event) => {
|
|
36
|
+
if (!dragContainerRef.current) return;
|
|
37
|
+
if (orientation === "horizontal" || orientation === "both") {
|
|
38
|
+
const dx = event.clientX - positionRef.current.x;
|
|
39
|
+
dragContainerRef.current.scrollLeft = positionRef.current.left - dx;
|
|
40
|
+
}
|
|
41
|
+
if (orientation === "vertical" || orientation === "both") {
|
|
42
|
+
const dy = event.clientY - positionRef.current.y;
|
|
43
|
+
dragContainerRef.current.scrollTop = positionRef.current.top - dy;
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
const handleMouseUpOrLeave = useCallbackRef(() => {
|
|
47
|
+
if (!dragContainerRef.current) return;
|
|
48
|
+
off("mousemove", dragContainerRef.current, handleMouseMove);
|
|
49
|
+
off("mouseup", dragContainerRef.current, handleMouseUpOrLeave);
|
|
50
|
+
off("mouseleave", dragContainerRef.current, handleMouseUpOrLeave);
|
|
51
|
+
resetCursor(dragContainerRef.current);
|
|
52
|
+
});
|
|
53
|
+
const handleMouseDown = useCallbackRef((event) => {
|
|
54
|
+
if (usage === "mobileAndTabletOnly" && window.innerWidth >= 768) return;
|
|
55
|
+
if (usage === "desktopOnly" && window.innerWidth < 768) return;
|
|
56
|
+
if (!dragContainerRef.current) return;
|
|
57
|
+
if (orientation === "horizontal" || orientation === "both") {
|
|
58
|
+
positionRef.current.x = event.clientX;
|
|
59
|
+
positionRef.current.left = dragContainerRef.current.scrollLeft;
|
|
60
|
+
}
|
|
61
|
+
if (orientation === "vertical" || orientation === "both") {
|
|
62
|
+
positionRef.current.y = event.clientY;
|
|
63
|
+
positionRef.current.top = dragContainerRef.current.scrollTop;
|
|
64
|
+
}
|
|
65
|
+
updateCursor(dragContainerRef.current);
|
|
66
|
+
on("mousemove", dragContainerRef.current, handleMouseMove);
|
|
67
|
+
on("mouseup", dragContainerRef.current, handleMouseUpOrLeave);
|
|
68
|
+
on("mouseleave", dragContainerRef.current, handleMouseUpOrLeave);
|
|
69
|
+
});
|
|
70
|
+
const refCallBack = useCallbackRef((node) => {
|
|
71
|
+
dragContainerRef.current = node;
|
|
72
|
+
node && handleScrollSnap(node);
|
|
73
|
+
const cleanup = on("mousedown", dragContainerRef.current, handleMouseDown);
|
|
74
|
+
if (!node) {
|
|
75
|
+
cleanup();
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
return cleanup;
|
|
79
|
+
});
|
|
80
|
+
const getRootProps = () => ({
|
|
81
|
+
className: cnMerge(
|
|
82
|
+
`flex w-full cursor-grab snap-x snap-mandatory overflow-y-clip overflow-x-scroll
|
|
83
|
+
[-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,
|
|
84
|
+
orientation === "horizontal" && "flex-row",
|
|
85
|
+
orientation === "vertical" && "flex-col",
|
|
86
|
+
usage === "mobileAndTabletOnly" && "md:cursor-default md:flex-col",
|
|
87
|
+
usage === "desktopOnly" && "max-md:cursor-default max-md:flex-col",
|
|
88
|
+
classNames?.base
|
|
89
|
+
),
|
|
90
|
+
"data-part": "root",
|
|
91
|
+
"data-scope": "drag-scroll",
|
|
92
|
+
ref: refCallBack
|
|
93
|
+
});
|
|
94
|
+
const getItemProps = () => ({
|
|
95
|
+
className: cnMerge("snap-center snap-always", classNames?.item),
|
|
96
|
+
"data-part": "item",
|
|
97
|
+
"data-scope": "drag-scroll"
|
|
98
|
+
});
|
|
99
|
+
return { getItemProps, getRootProps };
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
export { useDragScroll };
|
|
103
|
+
//# sourceMappingURL=index.js.map
|
|
104
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/ui/drag-scroll/utils.ts","../../../../src/components/ui/drag-scroll/useDragScroll.ts"],"names":[],"mappings":";;;;;AAGO,IAAM,YAAA,GAAe,CAA+B,OAAsB,KAAA;AAChF,EAAA,OAAA,CAAQ,MAAM,MAAS,GAAA,UAAA;AACvB,EAAA,OAAA,CAAQ,MAAM,UAAa,GAAA,MAAA;AAC5B,CAAA;AAEO,IAAM,YAAA,GAAe,CAC3B,MAAA,EACA,OACI,KAAA;AACJ,EAAA,IAAI,WAAW,QAAU,EAAA;AACxB,IAAA,OAAA,CAAQ,MAAM,cAAiB,GAAA,MAAA;AAC/B,IAAA;AAAA;AAGD,EAAA,OAAA,CAAQ,MAAM,cAAiB,GAAA,EAAA;AAChC,CAAA;AAEO,IAAM,WAAA,GAAc,CAA+B,OAAsB,KAAA;AAC/E,EAAA,OAAA,CAAQ,MAAM,MAAS,GAAA,EAAA;AACvB,EAAA,OAAA,CAAQ,M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\"@zayne-labs/toolkit-core\";\n\n/* eslint-disable no-param-reassign -- Mutation is needed here since it's an element */\nexport const updateCursor = <TElement extends HTMLElement>(element: TElement) => {\n\telement.style.cursor = \"grabbing\";\n\telement.style.userSelect = \"none\";\n};\n\nexport const onScrollSnap = <TElement extends HTMLElement>(\n\taction: \"remove\" | \"reset\",\n\telement: TElement\n) => {\n\tif (action === \"remove\") {\n\t\telement.style.scrollSnapType = \"none\";\n\t\treturn;\n\t}\n\n\telement.style.scrollSnapType = \"\";\n};\n\nexport const resetCursor = <TElement extends HTMLElement>(element: TElement) => {\n\telement.style.cursor = \"\";\n\telement.style.userSelect = \"\";\n};\n/* eslint-enable no-param-reassign -- Mutation is needed here since it's an element */\n\nexport const handleScrollSnap = (dragContainer: HTMLElement) => {\n\tconst isMobileOrTablet = checkIsDeviceMobileOrTablet();\n\n\tif (!isMobileOrTablet) {\n\t\tonScrollSnap(\"remove\", dragContainer);\n\t} else {\n\t\tonScrollSnap(\"reset\", dragContainer);\n\t}\n};\n","import { cnMerge } from \"@/lib/utils/cn\";\nimport { off, on } from \"@zayne-labs/toolkit-core\";\nimport { useCallbackRef } from \"@zayne-labs/toolkit-react\";\nimport { type RefCallback, useRef } from \"react\";\nimport { handleScrollSnap, resetCursor, updateCursor } from \"./utils\";\n\ntype DragScrollProps = {\n\tclassNames?: { base?: string; item?: string };\n\torientation?: \"both\" | \"horizontal\" | \"vertical\";\n\tusage?: \"allScreens\" | \"desktopOnly\" | \"mobileAndTabletOnly\";\n};\n\nconst useDragScroll = <TElement extends HTMLElement>(props: DragScrollProps = {}) => {\n\tconst { classNames, orientation = \"horizontal\", usage = \"allScreens\" } = props;\n\n\tconst dragContainerRef = useRef<TElement>(null);\n\n\tconst positionRef = useRef({ left: 0, top: 0, x: 0, y: 0 });\n\n\tconst handleMouseMove = useCallbackRef((event: MouseEvent) => {\n\t\tif (!dragContainerRef.current) return;\n\n\t\tif (orientation === \"horizontal\" || orientation === \"both\") {\n\t\t\t// == calculate the current change in the horizontal scroll position based on the difference between the previous mouse position and the new mouse position\n\t\t\tconst dx = event.clientX - positionRef.current.x;\n\n\t\t\t// == Assign the scrollLeft of the container to the difference between its previous horizontal scroll position and the change in the mouse position\n\t\t\tdragContainerRef.current.scrollLeft = positionRef.current.left - dx;\n\t\t}\n\n\t\tif (orientation === \"vertical\" || orientation === \"both\") {\n\t\t\t// == calculate the current change in the vertical scroll position based on the difference between the previous mouse position and the new mouse position\n\t\t\tconst dy = event.clientY - positionRef.current.y;\n\n\t\t\t// == Assign the scrollTop of the container to the difference between its previous vertical scroll position and the change in the mouse position\n\t\t\tdragContainerRef.current.scrollTop = positionRef.current.top - dy;\n\t\t}\n\t});\n\n\tconst handleMouseUpOrLeave = useCallbackRef(() => {\n\t\tif (!dragContainerRef.current) return;\n\n\t\toff(\"mousemove\", dragContainerRef.current, handleMouseMove);\n\t\toff(\"mouseup\", dragContainerRef.current, handleMouseUpOrLeave);\n\t\toff(\"mouseleave\", dragContainerRef.current, handleMouseUpOrLeave);\n\n\t\tresetCursor(dragContainerRef.current);\n\t});\n\n\tconst handleMouseDown = useCallbackRef((event: MouseEvent) => {\n\t\tif (usage === \"mobileAndTabletOnly\" && window.innerWidth >= 768) return;\n\t\tif (usage === \"desktopOnly\" && window.innerWidth < 768) return;\n\n\t\tif (!dragContainerRef.current) return;\n\n\t\t// == Update all initial position properties stored in the positionRef\n\t\tif (orientation === \"horizontal\" || orientation === \"both\") {\n\t\t\tpositionRef.current.x = event.clientX;\n\t\t\tpositionRef.current.left = dragContainerRef.current.scrollLeft;\n\t\t}\n\n\t\tif (orientation === \"vertical\" || orientation === \"both\") {\n\t\t\tpositionRef.current.y = event.clientY;\n\t\t\tpositionRef.current.top = dragContainerRef.current.scrollTop;\n\t\t}\n\n\t\tupdateCursor(dragContainerRef.current);\n\n\t\ton(\"mousemove\", dragContainerRef.current, handleMouseMove);\n\t\ton(\"mouseup\", dragContainerRef.current, handleMouseUpOrLeave);\n\t\ton(\"mouseleave\", dragContainerRef.current, handleMouseUpOrLeave);\n\t});\n\n\tconst refCallBack: RefCallback<TElement> = useCallbackRef((node) => {\n\t\tdragContainerRef.current = node;\n\n\t\tnode && handleScrollSnap(node);\n\n\t\tconst cleanup = on(\"mousedown\", dragContainerRef.current, handleMouseDown);\n\n\t\t// == Run cleanup manually on unmount if the user is using a version of react that doesn't support cleanup\n\t\tif (!node) {\n\t\t\tcleanup();\n\t\t\treturn;\n\t\t}\n\n\t\treturn cleanup;\n\t});\n\n\tconst getRootProps = () => ({\n\t\tclassName: cnMerge(\n\t\t\t`flex w-full cursor-grab snap-x snap-mandatory overflow-y-clip overflow-x-scroll\n\t\t\t[-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,\n\t\t\torientation === \"horizontal\" && \"flex-row\",\n\t\t\torientation === \"vertical\" && \"flex-col\",\n\t\t\tusage === \"mobileAndTabletOnly\" && \"md:cursor-default md:flex-col\",\n\t\t\tusage === \"desktopOnly\" && \"max-md:cursor-default max-md:flex-col\",\n\t\t\tclassNames?.base\n\t\t),\n\t\t\"data-part\": \"root\",\n\t\t\"data-scope\": \"drag-scroll\",\n\t\tref: refCallBack,\n\t});\n\n\tconst getItemProps = () => ({\n\t\tclassName: cnMerge(\"snap-center snap-always\", classNames?.item),\n\t\t\"data-part\": \"item\",\n\t\t\"data-scope\": \"drag-scroll\",\n\t});\n\n\treturn { getItemProps, getRootProps };\n};\n\nexport { useDragScroll };\n"]}
|