@zayne-labs/ui-react 0.11.2 → 0.11.4
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 → components}/common/await/index.d.ts +8 -8
- package/dist/{esm → components}/common/await/index.js +18 -9
- package/dist/components/common/await/index.js.map +1 -0
- package/dist/{esm → components}/common/client-gate/index.d.ts +2 -2
- package/dist/components/common/error-boundary/index.d.ts +2 -0
- package/dist/{esm → components}/common/error-boundary/index.js +1 -1
- package/dist/{esm → components}/common/for/index.d.ts +4 -4
- package/dist/{esm → components}/common/presence/index.d.ts +2 -2
- package/dist/components/common/presence/index.js +3 -0
- package/dist/{esm → components}/common/show/index.d.ts +4 -4
- package/dist/{esm → components}/common/show/index.js +1 -1
- package/dist/{esm → components}/common/slot/index.d.ts +4 -4
- package/dist/components/common/suspense-with-boundary/index.d.ts +2 -0
- package/dist/components/common/suspense-with-boundary/index.js +19 -0
- package/dist/components/common/suspense-with-boundary/index.js.map +1 -0
- package/dist/{esm → components}/common/switch/index.d.ts +4 -4
- package/dist/{esm → components}/common/teleport/index.d.ts +2 -2
- package/dist/{esm/error-boundary-C4btQhu_.js → components/error-boundary-BOZ3EvMt.js} +33 -31
- package/dist/components/error-boundary-BOZ3EvMt.js.map +1 -0
- package/dist/{esm/index-Dbt-nJhQ.d.ts → components/index-BmD5l0L7.d.ts} +13 -15
- package/dist/components/index-dmMYkH2c.d.ts +10 -0
- package/dist/{esm/presence-CHd9s3IS.js → components/presence-DkWhm7xu.js} +3 -3
- package/dist/{esm/presence-CHd9s3IS.js.map → components/presence-DkWhm7xu.js.map} +1 -1
- package/dist/{esm/show-BzfAw7y3.js → components/show-CMxdpPiN.js} +2 -2
- package/dist/components/show-CMxdpPiN.js.map +1 -0
- package/dist/{esm → components}/ui/card/index.d.ts +8 -8
- package/dist/{esm → components}/ui/carousel/index.d.ts +11 -16
- package/dist/{esm → components}/ui/carousel/index.js +42 -51
- package/dist/components/ui/carousel/index.js.map +1 -0
- package/dist/{esm → components}/ui/drag-scroll/index.d.ts +33 -25
- package/dist/{esm → components}/ui/drag-scroll/index.js +60 -59
- package/dist/components/ui/drag-scroll/index.js.map +1 -0
- package/dist/{esm → components}/ui/drop-zone/index.d.ts +42 -38
- package/dist/{esm → components}/ui/drop-zone/index.js +54 -23
- package/dist/components/ui/drop-zone/index.js.map +1 -0
- package/dist/{esm → components}/ui/form/index.d.ts +22 -22
- package/dist/{esm → components}/ui/form/index.js +11 -8
- package/dist/{esm → components}/ui/form/index.js.map +1 -1
- package/dist/style.css +14 -22
- package/package.json +11 -11
- package/dist/esm/common/await/index.js.map +0 -1
- package/dist/esm/common/error-boundary/index.d.ts +0 -2
- package/dist/esm/common/presence/index.js +0 -3
- package/dist/esm/common/suspense-with-boundary/index.d.ts +0 -2
- package/dist/esm/common/suspense-with-boundary/index.js +0 -20
- package/dist/esm/common/suspense-with-boundary/index.js.map +0 -1
- package/dist/esm/error-boundary-C4btQhu_.js.map +0 -1
- package/dist/esm/index-Ce3J0_vR.d.ts +0 -13
- package/dist/esm/show-BzfAw7y3.js.map +0 -1
- package/dist/esm/ui/carousel/index.js.map +0 -1
- package/dist/esm/ui/drag-scroll/index.js.map +0 -1
- package/dist/esm/ui/drop-zone/index.js.map +0 -1
- /package/dist/{esm → components}/chunk-pbuEa-1d.js +0 -0
- /package/dist/{esm → components}/cn-jNZfGhrk.js +0 -0
- /package/dist/{esm → components}/cn-jNZfGhrk.js.map +0 -0
- /package/dist/{esm → components}/common/client-gate/index.js +0 -0
- /package/dist/{esm → components}/common/client-gate/index.js.map +0 -0
- /package/dist/{esm → components}/common/for/index.js +0 -0
- /package/dist/{esm → components}/common/slot/index.js +0 -0
- /package/dist/{esm → components}/common/switch/index.js +0 -0
- /package/dist/{esm → components}/common/teleport/index.js +0 -0
- /package/dist/{esm → components}/common/teleport/index.js.map +0 -0
- /package/dist/{esm → components}/for-DGTMIS0w.js +0 -0
- /package/dist/{esm → components}/for-DGTMIS0w.js.map +0 -0
- /package/dist/{esm → components}/slot-DuwoiC2C.js +0 -0
- /package/dist/{esm → components}/slot-DuwoiC2C.js.map +0 -0
- /package/dist/{esm → components}/switch-Dwy5Gzsb.js +0 -0
- /package/dist/{esm → components}/switch-Dwy5Gzsb.js.map +0 -0
- /package/dist/{esm → components}/ui/card/index.js +0 -0
- /package/dist/{esm → components}/ui/card/index.js.map +0 -0
|
@@ -33,7 +33,7 @@ const handleScrollSnap = (dragContainer) => {
|
|
|
33
33
|
//#region src/components/ui/drag-scroll/drag-scroll-store.ts
|
|
34
34
|
const createDragScrollStore = (initStoreValues) => {
|
|
35
35
|
const { orientation = "horizontal", scrollAmount = "item", usage = "allScreens" } = initStoreValues;
|
|
36
|
-
const
|
|
36
|
+
const listRef = { current: null };
|
|
37
37
|
const positionRef = { current: {
|
|
38
38
|
left: 0,
|
|
39
39
|
top: 0,
|
|
@@ -62,22 +62,22 @@ const createDragScrollStore = (initStoreValues) => {
|
|
|
62
62
|
abortControllerRef.current.mouseLeave.abort();
|
|
63
63
|
},
|
|
64
64
|
goToNext: () => {
|
|
65
|
-
if (!
|
|
65
|
+
if (!listRef.current) return;
|
|
66
66
|
const { canGoToNext } = get();
|
|
67
67
|
if (!canGoToNext) return;
|
|
68
|
-
const amount = getScrollAmount(
|
|
69
|
-
|
|
68
|
+
const amount = getScrollAmount(listRef.current);
|
|
69
|
+
listRef.current.scrollBy({
|
|
70
70
|
behavior: "smooth",
|
|
71
71
|
left: orientation === "vertical" ? 0 : amount,
|
|
72
72
|
top: orientation === "vertical" || orientation === "both" ? amount : 0
|
|
73
73
|
});
|
|
74
74
|
},
|
|
75
75
|
goToPrev: () => {
|
|
76
|
-
if (!
|
|
76
|
+
if (!listRef.current) return;
|
|
77
77
|
const { canGoToPrev } = get();
|
|
78
78
|
if (!canGoToPrev) return;
|
|
79
|
-
const amount = getScrollAmount(
|
|
80
|
-
|
|
79
|
+
const amount = getScrollAmount(listRef.current);
|
|
80
|
+
listRef.current.scrollBy({
|
|
81
81
|
behavior: "smooth",
|
|
82
82
|
left: orientation === "vertical" ? 0 : -amount,
|
|
83
83
|
top: orientation === "vertical" || orientation === "both" ? -amount : 0
|
|
@@ -86,7 +86,7 @@ const createDragScrollStore = (initStoreValues) => {
|
|
|
86
86
|
handleMouseDown: (event) => {
|
|
87
87
|
if (usage === "mobileAndTabletOnly" && window.innerWidth >= 768) return;
|
|
88
88
|
if (usage === "desktopOnly" && window.innerWidth < 768) return;
|
|
89
|
-
if (!
|
|
89
|
+
if (!listRef.current) return;
|
|
90
90
|
abortControllerRef.current = {
|
|
91
91
|
mouseLeave: new AbortController(),
|
|
92
92
|
mouseMove: new AbortController(),
|
|
@@ -94,37 +94,37 @@ const createDragScrollStore = (initStoreValues) => {
|
|
|
94
94
|
};
|
|
95
95
|
if (orientation === "horizontal" || orientation === "both") {
|
|
96
96
|
positionRef.current.x = event.clientX;
|
|
97
|
-
positionRef.current.left =
|
|
97
|
+
positionRef.current.left = listRef.current.scrollLeft;
|
|
98
98
|
}
|
|
99
99
|
if (orientation === "vertical" || orientation === "both") {
|
|
100
100
|
positionRef.current.y = event.clientY;
|
|
101
|
-
positionRef.current.top =
|
|
101
|
+
positionRef.current.top = listRef.current.scrollTop;
|
|
102
102
|
}
|
|
103
|
-
updateCursor(
|
|
103
|
+
updateCursor(listRef.current);
|
|
104
104
|
set({ isDragging: true });
|
|
105
105
|
const { actions } = get();
|
|
106
|
-
on(
|
|
107
|
-
on(
|
|
108
|
-
on(
|
|
106
|
+
on(listRef.current, "mousemove", actions.handleMouseMove, { signal: abortControllerRef.current.mouseMove.signal });
|
|
107
|
+
on(listRef.current, "mouseup", actions.handleMouseUpOrLeave, { signal: abortControllerRef.current.mouseUp.signal });
|
|
108
|
+
on(listRef.current, "mouseleave", actions.handleMouseUpOrLeave, { signal: abortControllerRef.current.mouseLeave.signal });
|
|
109
109
|
on(document, "mouseup", actions.handleMouseUpOrLeave, {
|
|
110
110
|
once: true,
|
|
111
111
|
signal: abortControllerRef.current.mouseUp.signal
|
|
112
112
|
});
|
|
113
113
|
},
|
|
114
114
|
handleMouseMove: (event) => {
|
|
115
|
-
if (!
|
|
115
|
+
if (!listRef.current) return;
|
|
116
116
|
if (orientation === "horizontal" || orientation === "both") {
|
|
117
117
|
const dx = event.clientX - positionRef.current.x;
|
|
118
|
-
|
|
118
|
+
listRef.current.scrollLeft = positionRef.current.left - dx;
|
|
119
119
|
}
|
|
120
120
|
if (orientation === "vertical" || orientation === "both") {
|
|
121
121
|
const dy = event.clientY - positionRef.current.y;
|
|
122
|
-
|
|
122
|
+
listRef.current.scrollTop = positionRef.current.top - dy;
|
|
123
123
|
}
|
|
124
124
|
},
|
|
125
125
|
handleMouseUpOrLeave: () => {
|
|
126
|
-
if (!
|
|
127
|
-
resetCursor(
|
|
126
|
+
if (!listRef.current) return;
|
|
127
|
+
resetCursor(listRef.current);
|
|
128
128
|
set({ isDragging: false });
|
|
129
129
|
const { actions } = get();
|
|
130
130
|
actions.cleanupDragListeners();
|
|
@@ -134,34 +134,34 @@ const createDragScrollStore = (initStoreValues) => {
|
|
|
134
134
|
actions.updateScrollState();
|
|
135
135
|
}),
|
|
136
136
|
initializeResizeObserver: () => {
|
|
137
|
-
if (!
|
|
137
|
+
if (!listRef.current) return;
|
|
138
138
|
const { actions } = get();
|
|
139
139
|
const resizeObserver = new ResizeObserver(() => actions.updateScrollState());
|
|
140
|
-
resizeObserver.observe(
|
|
141
|
-
for (const child of
|
|
140
|
+
resizeObserver.observe(listRef.current);
|
|
141
|
+
for (const child of listRef.current.children) resizeObserver.observe(child);
|
|
142
142
|
const cleanup = () => {
|
|
143
143
|
resizeObserver.disconnect();
|
|
144
144
|
};
|
|
145
145
|
return cleanup;
|
|
146
146
|
},
|
|
147
|
-
|
|
148
|
-
|
|
147
|
+
setListRef: (element) => {
|
|
148
|
+
listRef.current = element;
|
|
149
149
|
if (!element) return;
|
|
150
150
|
handleScrollSnap(element);
|
|
151
151
|
const { actions } = get();
|
|
152
152
|
actions.updateScrollState();
|
|
153
153
|
},
|
|
154
154
|
updateScrollState: () => {
|
|
155
|
-
if (!
|
|
155
|
+
if (!listRef.current) return;
|
|
156
156
|
if (orientation === "horizontal" || orientation === "both") {
|
|
157
|
-
const { clientWidth, scrollLeft, scrollWidth } =
|
|
157
|
+
const { clientWidth, scrollLeft, scrollWidth } = listRef.current;
|
|
158
158
|
set({
|
|
159
159
|
canGoToNext: Math.ceil(scrollLeft + clientWidth) < scrollWidth,
|
|
160
160
|
canGoToPrev: Math.floor(scrollLeft) > 0
|
|
161
161
|
});
|
|
162
162
|
}
|
|
163
163
|
if (orientation === "vertical") {
|
|
164
|
-
const { clientHeight, scrollHeight, scrollTop } =
|
|
164
|
+
const { clientHeight, scrollHeight, scrollTop } = listRef.current;
|
|
165
165
|
set({
|
|
166
166
|
canGoToNext: Math.ceil(scrollTop + clientHeight) < scrollHeight,
|
|
167
167
|
canGoToPrev: Math.floor(scrollTop) > 0
|
|
@@ -173,14 +173,16 @@ const createDragScrollStore = (initStoreValues) => {
|
|
|
173
173
|
};
|
|
174
174
|
//#endregion
|
|
175
175
|
//#region src/components/ui/drag-scroll/use-drag-scroll.ts
|
|
176
|
-
const
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
176
|
+
const getDragScrollScopeAttrs = (part) => {
|
|
177
|
+
return {
|
|
178
|
+
"data-slot": `drag-scroll-${part}`,
|
|
179
|
+
"data-scope": "drag-scroll",
|
|
180
|
+
"data-part": part
|
|
181
|
+
};
|
|
182
|
+
};
|
|
181
183
|
const useDragScroll = (props) => {
|
|
182
184
|
const { disableInternalStateSubscription = false, orientation = "horizontal", scrollAmount = "item", usage = "allScreens" } = props ?? {};
|
|
183
|
-
const
|
|
185
|
+
const listRef = useRef(null);
|
|
184
186
|
const storeApi = useMemo(() => {
|
|
185
187
|
return createDragScrollStore({
|
|
186
188
|
orientation,
|
|
@@ -200,8 +202,8 @@ const useDragScroll = (props) => {
|
|
|
200
202
|
const canGoToNext = useDragScrollStore((state) => !disableInternalStateSubscription ? state.canGoToNext : null);
|
|
201
203
|
const isDragging = useDragScrollStore((state) => !disableInternalStateSubscription ? state.isDragging : null);
|
|
202
204
|
const refCallback = useCallbackRef((node) => {
|
|
203
|
-
|
|
204
|
-
actions.
|
|
205
|
+
listRef.current = node;
|
|
206
|
+
actions.setListRef(node);
|
|
205
207
|
if (!node) return;
|
|
206
208
|
const cleanupMouseDown = on(node, "mousedown", actions.handleMouseDown);
|
|
207
209
|
const cleanupScroll = on(node, "scroll", actions.handleScroll, { passive: true });
|
|
@@ -215,16 +217,16 @@ const useDragScroll = (props) => {
|
|
|
215
217
|
}, [actions]);
|
|
216
218
|
const getRootProps = useCallbackRef((innerProps) => {
|
|
217
219
|
return {
|
|
218
|
-
...getScopeAttrs("root"),
|
|
219
220
|
...innerProps,
|
|
221
|
+
...getDragScrollScopeAttrs("root"),
|
|
220
222
|
className: cnMerge("relative", innerProps?.className)
|
|
221
223
|
};
|
|
222
224
|
});
|
|
223
|
-
const
|
|
225
|
+
const getListProps = useCallback((innerProps) => {
|
|
224
226
|
return {
|
|
225
|
-
...getScopeAttrs("container"),
|
|
226
|
-
...!disableInternalStateSubscription && { "data-dragging": dataAttr(isDragging) },
|
|
227
227
|
...innerProps,
|
|
228
|
+
...getDragScrollScopeAttrs("list"),
|
|
229
|
+
...!disableInternalStateSubscription && { "data-dragging": dataAttr(isDragging) },
|
|
228
230
|
className: cnMerge(`scrollbar-hidden flex w-full cursor-grab snap-x snap-mandatory overflow-x-scroll overflow-y-hidden`, orientation === "horizontal" && "flex-row", orientation === "vertical" && "flex-col", usage === "mobileAndTabletOnly" && "md:cursor-default md:flex-col", usage === "desktopOnly" && "max-md:cursor-default max-md:flex-col", innerProps?.className),
|
|
229
231
|
ref: composeRefs(refCallback, innerProps?.ref)
|
|
230
232
|
};
|
|
@@ -237,54 +239,53 @@ const useDragScroll = (props) => {
|
|
|
237
239
|
]);
|
|
238
240
|
const getItemProps = useCallbackRef((innerProps) => {
|
|
239
241
|
return {
|
|
240
|
-
...getScopeAttrs("item"),
|
|
241
242
|
...innerProps,
|
|
243
|
+
...getDragScrollScopeAttrs("item"),
|
|
242
244
|
className: cnMerge("snap-center snap-always", innerProps?.className)
|
|
243
245
|
};
|
|
244
246
|
});
|
|
245
247
|
const getPrevButtonProps = useCallback((innerProps) => {
|
|
246
248
|
const isDisabled = innerProps?.disabled ?? !canGoToPrev;
|
|
247
249
|
return {
|
|
248
|
-
...getScopeAttrs("prev-button"),
|
|
249
|
-
type: "button",
|
|
250
250
|
...innerProps,
|
|
251
|
+
...getDragScrollScopeAttrs("prev-button"),
|
|
251
252
|
"aria-disabled": dataAttr(isDisabled),
|
|
252
253
|
"aria-label": innerProps?.["aria-label"] ?? "Scroll back",
|
|
253
254
|
"data-disabled": dataAttr(isDisabled),
|
|
254
255
|
disabled: isDisabled,
|
|
255
|
-
onClick: composeTwoEventHandlers(actions.goToPrev, innerProps?.onClick)
|
|
256
|
+
onClick: composeTwoEventHandlers(actions.goToPrev, innerProps?.onClick),
|
|
257
|
+
type: "button"
|
|
256
258
|
};
|
|
257
259
|
}, [actions.goToPrev, canGoToPrev]);
|
|
258
260
|
const getNextButtonProps = useCallback((innerProps) => {
|
|
259
261
|
const isDisabled = innerProps?.disabled ?? !canGoToNext;
|
|
260
262
|
return {
|
|
261
|
-
...getScopeAttrs("next-button"),
|
|
262
|
-
type: "button",
|
|
263
263
|
...innerProps,
|
|
264
|
-
"
|
|
264
|
+
...getDragScrollScopeAttrs("next-button"),
|
|
265
265
|
"aria-label": innerProps?.["aria-label"] ?? "Scroll forward",
|
|
266
266
|
"data-disabled": dataAttr(isDisabled),
|
|
267
267
|
disabled: isDisabled,
|
|
268
|
-
onClick: composeTwoEventHandlers(actions.goToNext, innerProps?.onClick)
|
|
268
|
+
onClick: composeTwoEventHandlers(actions.goToNext, innerProps?.onClick),
|
|
269
|
+
type: "button"
|
|
269
270
|
};
|
|
270
271
|
}, [actions.goToNext, canGoToNext]);
|
|
271
272
|
const propGetters = useMemo(() => ({
|
|
272
|
-
getContainerProps,
|
|
273
273
|
getItemProps,
|
|
274
|
+
getListProps,
|
|
274
275
|
getNextButtonProps,
|
|
275
276
|
getPrevButtonProps,
|
|
276
277
|
getRootProps
|
|
277
278
|
}), [
|
|
278
279
|
getPrevButtonProps,
|
|
279
|
-
|
|
280
|
+
getListProps,
|
|
280
281
|
getItemProps,
|
|
281
282
|
getNextButtonProps,
|
|
282
283
|
getRootProps
|
|
283
284
|
]);
|
|
284
285
|
const stableUseDragScrollStore = useCallbackRef(useDragScrollStore);
|
|
285
286
|
return useMemo(() => ({
|
|
286
|
-
containerRef,
|
|
287
287
|
disableInternalStateSubscription,
|
|
288
|
+
listRef,
|
|
288
289
|
propGetters,
|
|
289
290
|
storeApi,
|
|
290
291
|
useDragScrollStore: stableUseDragScrollStore
|
|
@@ -310,21 +311,21 @@ const [DragScrollRootContextProvider, useDragScrollRootContext] = createCustomCo
|
|
|
310
311
|
//#endregion
|
|
311
312
|
//#region src/components/ui/drag-scroll/drag-scroll.tsx
|
|
312
313
|
function DragScrollRoot(props) {
|
|
313
|
-
const {
|
|
314
|
-
const {
|
|
314
|
+
const { asChild, children, ...restOfProps } = props;
|
|
315
|
+
const { disableInternalStateSubscription, listRef, propGetters, storeApi } = useDragScroll(restOfProps);
|
|
315
316
|
return /* @__PURE__ */ jsx(DragScrollStoreContextProvider, {
|
|
316
317
|
store: storeApi,
|
|
317
318
|
children: /* @__PURE__ */ jsx(DragScrollRootContextProvider, {
|
|
318
319
|
value: useMemo(() => ({
|
|
319
|
-
containerRef,
|
|
320
320
|
disableInternalStateSubscription,
|
|
321
|
+
listRef,
|
|
321
322
|
propGetters
|
|
322
323
|
}), [
|
|
323
|
-
|
|
324
|
+
listRef,
|
|
324
325
|
disableInternalStateSubscription,
|
|
325
326
|
propGetters
|
|
326
327
|
]),
|
|
327
|
-
children: /* @__PURE__ */ jsx(asChild ? SlotRoot :
|
|
328
|
+
children: /* @__PURE__ */ jsx(asChild ? SlotRoot : "div", {
|
|
328
329
|
...propGetters.getRootProps(restOfProps),
|
|
329
330
|
children
|
|
330
331
|
})
|
|
@@ -336,10 +337,10 @@ function DragScrollContext(props) {
|
|
|
336
337
|
const dragScrollCtx = useDragScrollStoreContext(useCompareSelector(selector));
|
|
337
338
|
return isFunction(children) ? children(dragScrollCtx) : children;
|
|
338
339
|
}
|
|
339
|
-
function
|
|
340
|
+
function DragScrollList(props) {
|
|
340
341
|
const { as: Element = "ul", asChild, ...restOfProps } = props;
|
|
341
342
|
const { propGetters } = useDragScrollRootContext();
|
|
342
|
-
return /* @__PURE__ */ jsx(asChild ? SlotRoot : Element, { ...propGetters.
|
|
343
|
+
return /* @__PURE__ */ jsx(asChild ? SlotRoot : Element, { ...propGetters.getListProps(restOfProps) });
|
|
343
344
|
}
|
|
344
345
|
function DragScrollItem(props) {
|
|
345
346
|
const { as: Element = "li", asChild, ...restOfProps } = props;
|
|
@@ -359,14 +360,14 @@ function DragScrollNext(props) {
|
|
|
359
360
|
//#endregion
|
|
360
361
|
//#region src/components/ui/drag-scroll/drag-scroll-parts.ts
|
|
361
362
|
var drag_scroll_parts_exports = /* @__PURE__ */ __exportAll({
|
|
362
|
-
Container: () => DragScrollContainer,
|
|
363
363
|
Context: () => DragScrollContext,
|
|
364
364
|
Item: () => DragScrollItem,
|
|
365
|
+
List: () => DragScrollList,
|
|
365
366
|
Next: () => DragScrollNext,
|
|
366
367
|
Prev: () => DragScrollPrev,
|
|
367
368
|
Root: () => DragScrollRoot
|
|
368
369
|
});
|
|
369
370
|
//#endregion
|
|
370
|
-
export { drag_scroll_parts_exports as DragScroll,
|
|
371
|
+
export { drag_scroll_parts_exports as DragScroll, DragScrollContext, DragScrollItem, DragScrollList, DragScrollNext, DragScrollPrev, DragScrollRoot, getDragScrollScopeAttrs, useDragScroll, useDragScrollStoreContext };
|
|
371
372
|
|
|
372
373
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["Slot.Root"],"sources":["../../../../src/components/ui/drag-scroll/utils.ts","../../../../src/components/ui/drag-scroll/drag-scroll-store.ts","../../../../src/components/ui/drag-scroll/use-drag-scroll.ts","../../../../src/components/ui/drag-scroll/drag-scroll-context.ts","../../../../src/components/ui/drag-scroll/drag-scroll.tsx","../../../../src/components/ui/drag-scroll/drag-scroll-parts.ts"],"sourcesContent":["import { checkIsDeviceMobile } from \"@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 isMobile = checkIsDeviceMobile();\n\n\tif (!isMobile) {\n\t\tonScrollSnap(\"remove\", dragContainer);\n\t} else {\n\t\tonScrollSnap(\"reset\", dragContainer);\n\t}\n};\n","import { createStore, on, throttleByFrame } from \"@zayne-labs/toolkit-core\";\nimport { isNumber } from \"@zayne-labs/toolkit-type-helpers\";\nimport type { DragScrollStore, UseDragScrollProps } from \"./types\";\nimport { handleScrollSnap, resetCursor, updateCursor } from \"./utils\";\n\ntype RequiredUseDragScrollProps = {\n\t[Key in keyof Required<UseDragScrollProps>]: UseDragScrollProps[Key] | undefined;\n};\n\ntype InitStoreValues = Pick<RequiredUseDragScrollProps, \"orientation\" | \"scrollAmount\" | \"usage\">;\n\nexport const createDragScrollStore = (initStoreValues: InitStoreValues) => {\n\tconst { orientation = \"horizontal\", scrollAmount = \"item\", usage = \"allScreens\" } = initStoreValues;\n\n\tconst listRef: React.RefObject<HTMLElement | null> = {\n\t\tcurrent: null,\n\t};\n\n\tconst positionRef = {\n\t\tcurrent: {\n\t\t\tleft: 0,\n\t\t\ttop: 0,\n\t\t\tx: 0,\n\t\t\ty: 0,\n\t\t},\n\t};\n\n\tconst abortControllerRef = {\n\t\tcurrent: {\n\t\t\tmouseLeave: new AbortController(),\n\t\t\tmouseMove: new AbortController(),\n\t\t\tmouseUp: new AbortController(),\n\t\t},\n\t};\n\n\t// == Calculate scroll amount based on orientation and settings\n\tconst getScrollAmount = (container: HTMLElement): number => {\n\t\tif (isNumber(scrollAmount)) {\n\t\t\treturn scrollAmount;\n\t\t}\n\n\t\tconst firstChild = container.children[0] as HTMLElement | undefined;\n\n\t\tif (!firstChild) {\n\t\t\treturn 0;\n\t\t}\n\n\t\treturn orientation === \"vertical\" || orientation === \"both\" ?\n\t\t\t\tfirstChild.offsetHeight\n\t\t\t:\tfirstChild.offsetWidth;\n\t};\n\n\tconst store = createStore<DragScrollStore>((set, get) => ({\n\t\tcanGoToNext: true,\n\t\tcanGoToPrev: false,\n\t\tisDragging: false,\n\n\t\t// eslint-disable-next-line perfectionist/sort-objects -- actions should be last\n\t\tactions: {\n\t\t\tcleanupDragListeners: () => {\n\t\t\t\tabortControllerRef.current.mouseMove.abort();\n\t\t\t\tabortControllerRef.current.mouseUp.abort();\n\t\t\t\tabortControllerRef.current.mouseLeave.abort();\n\t\t\t},\n\n\t\t\tgoToNext: () => {\n\t\t\t\tif (!listRef.current) return;\n\n\t\t\t\tconst { canGoToNext } = get();\n\t\t\t\tif (!canGoToNext) return;\n\n\t\t\t\tconst amount = getScrollAmount(listRef.current);\n\n\t\t\t\tlistRef.current.scrollBy({\n\t\t\t\t\tbehavior: \"smooth\",\n\t\t\t\t\tleft: orientation === \"vertical\" ? 0 : amount,\n\t\t\t\t\ttop: orientation === \"vertical\" || orientation === \"both\" ? amount : 0,\n\t\t\t\t});\n\t\t\t},\n\n\t\t\tgoToPrev: () => {\n\t\t\t\tif (!listRef.current) return;\n\n\t\t\t\tconst { canGoToPrev } = get();\n\t\t\t\tif (!canGoToPrev) return;\n\n\t\t\t\tconst amount = getScrollAmount(listRef.current);\n\n\t\t\t\tlistRef.current.scrollBy({\n\t\t\t\t\tbehavior: \"smooth\",\n\t\t\t\t\tleft: orientation === \"vertical\" ? 0 : -amount,\n\t\t\t\t\ttop: orientation === \"vertical\" || orientation === \"both\" ? -amount : 0,\n\t\t\t\t});\n\t\t\t},\n\n\t\t\thandleMouseDown: (event) => {\n\t\t\t\tif (usage === \"mobileAndTabletOnly\" && window.innerWidth >= 768) return;\n\t\t\t\tif (usage === \"desktopOnly\" && window.innerWidth < 768) return;\n\n\t\t\t\tif (!listRef.current) return;\n\n\t\t\t\t// == Create fresh AbortControllers for each drag session (they cannot be reused after abort)\n\t\t\t\tabortControllerRef.current = {\n\t\t\t\t\tmouseLeave: new AbortController(),\n\t\t\t\t\tmouseMove: new AbortController(),\n\t\t\t\t\tmouseUp: new AbortController(),\n\t\t\t\t};\n\n\t\t\t\t// == Update all initial position properties\n\t\t\t\tif (orientation === \"horizontal\" || orientation === \"both\") {\n\t\t\t\t\tpositionRef.current.x = event.clientX;\n\t\t\t\t\tpositionRef.current.left = listRef.current.scrollLeft;\n\t\t\t\t}\n\n\t\t\t\tif (orientation === \"vertical\" || orientation === \"both\") {\n\t\t\t\t\tpositionRef.current.y = event.clientY;\n\t\t\t\t\tpositionRef.current.top = listRef.current.scrollTop;\n\t\t\t\t}\n\n\t\t\t\tupdateCursor(listRef.current);\n\t\t\t\tset({ isDragging: true });\n\n\t\t\t\tconst { actions } = get();\n\n\t\t\t\ton(listRef.current, \"mousemove\", actions.handleMouseMove, {\n\t\t\t\t\tsignal: abortControllerRef.current.mouseMove.signal,\n\t\t\t\t});\n\t\t\t\ton(listRef.current, \"mouseup\", actions.handleMouseUpOrLeave, {\n\t\t\t\t\tsignal: abortControllerRef.current.mouseUp.signal,\n\t\t\t\t});\n\t\t\t\ton(listRef.current, \"mouseleave\", actions.handleMouseUpOrLeave, {\n\t\t\t\t\tsignal: abortControllerRef.current.mouseLeave.signal,\n\t\t\t\t});\n\t\t\t\t// == Document-level mouseup fallback for when user releases outside the container\n\t\t\t\ton(document, \"mouseup\", actions.handleMouseUpOrLeave, {\n\t\t\t\t\tonce: true,\n\t\t\t\t\tsignal: abortControllerRef.current.mouseUp.signal,\n\t\t\t\t});\n\t\t\t},\n\n\t\t\thandleMouseMove: (event) => {\n\t\t\t\tif (!listRef.current) return;\n\n\t\t\t\tif (orientation === \"horizontal\" || orientation === \"both\") {\n\t\t\t\t\tconst dx = event.clientX - positionRef.current.x;\n\t\t\t\t\tlistRef.current.scrollLeft = positionRef.current.left - dx;\n\t\t\t\t}\n\n\t\t\t\tif (orientation === \"vertical\" || orientation === \"both\") {\n\t\t\t\t\tconst dy = event.clientY - positionRef.current.y;\n\t\t\t\t\tlistRef.current.scrollTop = positionRef.current.top - dy;\n\t\t\t\t}\n\t\t\t},\n\n\t\t\thandleMouseUpOrLeave: () => {\n\t\t\t\tif (!listRef.current) return;\n\n\t\t\t\tresetCursor(listRef.current);\n\t\t\t\tset({ isDragging: false });\n\n\t\t\t\tconst { actions } = get();\n\t\t\t\tactions.cleanupDragListeners();\n\t\t\t},\n\n\t\t\thandleScroll: throttleByFrame(() => {\n\t\t\t\tconst { actions } = get();\n\t\t\t\tactions.updateScrollState();\n\t\t\t}),\n\n\t\t\tinitializeResizeObserver: () => {\n\t\t\t\tif (!listRef.current) return;\n\n\t\t\t\tconst { actions } = get();\n\n\t\t\t\t// == Use ResizeObserver to detect when container or children resize\n\t\t\t\tconst resizeObserver = new ResizeObserver(() => actions.updateScrollState());\n\n\t\t\t\tresizeObserver.observe(listRef.current);\n\n\t\t\t\t// == Also observe children for size changes\n\t\t\t\tfor (const child of listRef.current.children) {\n\t\t\t\t\tresizeObserver.observe(child);\n\t\t\t\t}\n\n\t\t\t\tconst cleanup = () => {\n\t\t\t\t\tresizeObserver.disconnect();\n\t\t\t\t};\n\n\t\t\t\treturn cleanup;\n\t\t\t},\n\n\t\t\tsetListRef: (element) => {\n\t\t\t\tlistRef.current = element as HTMLElement;\n\n\t\t\t\tif (!element) return;\n\n\t\t\t\thandleScrollSnap(element);\n\n\t\t\t\tconst { actions } = get();\n\t\t\t\tactions.updateScrollState();\n\t\t\t},\n\n\t\t\tupdateScrollState: () => {\n\t\t\t\tif (!listRef.current) return;\n\n\t\t\t\tif (orientation === \"horizontal\" || orientation === \"both\") {\n\t\t\t\t\tconst { clientWidth, scrollLeft, scrollWidth } = listRef.current;\n\n\t\t\t\t\tset({\n\t\t\t\t\t\tcanGoToNext: Math.ceil(scrollLeft + clientWidth) < scrollWidth,\n\t\t\t\t\t\tcanGoToPrev: Math.floor(scrollLeft) > 0,\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tif (orientation === \"vertical\") {\n\t\t\t\t\tconst { clientHeight, scrollHeight, scrollTop } = listRef.current;\n\n\t\t\t\t\tset({\n\t\t\t\t\t\tcanGoToNext: Math.ceil(scrollTop + clientHeight) < scrollHeight,\n\t\t\t\t\t\tcanGoToPrev: Math.floor(scrollTop) > 0,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t}));\n\n\treturn store;\n};\n","import { dataAttr, on } from \"@zayne-labs/toolkit-core\";\nimport { useCallbackRef, useStore } from \"@zayne-labs/toolkit-react\";\nimport { composeRefs, composeTwoEventHandlers } from \"@zayne-labs/toolkit-react/utils\";\nimport { useCallback, useEffect, useMemo, useRef } from \"react\";\nimport { cnMerge } from \"@/lib/utils/cn\";\nimport type { FromCamelToKebabCase } from \"@/lib/utils/type-helpers\";\nimport { createDragScrollStore } from \"./drag-scroll-store\";\nimport type { DragScrollPropGetters, PartProps, UseDragScrollProps, UseDragScrollResult } from \"./types\";\n\nexport const getDragScrollScopeAttrs = (part: FromCamelToKebabCase<keyof PartProps>) => {\n\treturn {\n\t\t/* eslint-disable perfectionist/sort-objects -- I need this order to be maintained */\n\t\t\"data-slot\": `drag-scroll-${part}`,\n\t\t\"data-scope\": \"drag-scroll\",\n\t\t\"data-part\": part,\n\t\t/* eslint-enable perfectionist/sort-objects -- I need this order to be maintained */\n\t} as const;\n};\n\nexport const useDragScroll = <TContainerElement extends HTMLElement = HTMLElement>(\n\tprops?: UseDragScrollProps\n): UseDragScrollResult<TContainerElement> => {\n\tconst {\n\t\tdisableInternalStateSubscription = false,\n\t\torientation = \"horizontal\",\n\t\tscrollAmount = \"item\",\n\t\tusage = \"allScreens\",\n\t} = props ?? {};\n\n\tconst listRef = useRef<TContainerElement>(null);\n\n\tconst storeApi = useMemo(() => {\n\t\treturn createDragScrollStore({ orientation, scrollAmount, usage });\n\t}, [orientation, scrollAmount, usage]);\n\n\tconst actions = storeApi.getState().actions;\n\n\t/* eslint-disable react-hooks/hooks -- ignore */\n\t// eslint-disable-next-line react-x/component-hook-factories -- Ignore\n\tconst useDragScrollStore: UseDragScrollResult<TContainerElement>[\"useDragScrollStore\"] = (selector) => {\n\t\treturn useStore(storeApi as never, selector);\n\t};\n\n\tconst canGoToPrev = useDragScrollStore((state) =>\n\t\t!disableInternalStateSubscription ? state.canGoToPrev : null\n\t);\n\n\tconst canGoToNext = useDragScrollStore((state) =>\n\t\t!disableInternalStateSubscription ? state.canGoToNext : null\n\t);\n\n\tconst isDragging = useDragScrollStore((state) =>\n\t\t!disableInternalStateSubscription ? state.isDragging : null\n\t);\n\t/* eslint-enable react-hooks/hooks -- ignore */\n\n\tconst refCallback: React.RefCallback<TContainerElement> = useCallbackRef((node) => {\n\t\tlistRef.current = node;\n\t\tactions.setListRef(node);\n\n\t\tif (!node) return;\n\n\t\tconst cleanupMouseDown = on(node, \"mousedown\", actions.handleMouseDown);\n\t\tconst cleanupScroll = on(node, \"scroll\", actions.handleScroll, { passive: true });\n\n\t\treturn () => {\n\t\t\tcleanupMouseDown();\n\t\t\tcleanupScroll();\n\t\t};\n\t});\n\n\t// == Update scroll state when children might change (e.g., async loaded content)\n\tuseEffect(() => {\n\t\tconst cleanup = actions.initializeResizeObserver();\n\n\t\treturn cleanup;\n\t}, [actions]);\n\n\tconst getRootProps: DragScrollPropGetters<TContainerElement>[\"getRootProps\"] = useCallbackRef(\n\t\t(innerProps) => {\n\t\t\treturn {\n\t\t\t\t...innerProps,\n\t\t\t\t...getDragScrollScopeAttrs(\"root\"),\n\t\t\t\tclassName: cnMerge(\"relative\", innerProps?.className),\n\t\t\t};\n\t\t}\n\t);\n\n\tconst getListProps: DragScrollPropGetters<TContainerElement>[\"getListProps\"] = useCallback(\n\t\t(innerProps) => {\n\t\t\treturn {\n\t\t\t\t...innerProps,\n\t\t\t\t...getDragScrollScopeAttrs(\"list\"),\n\t\t\t\t...(!disableInternalStateSubscription && {\n\t\t\t\t\t\"data-dragging\": dataAttr(isDragging),\n\t\t\t\t}),\n\t\t\t\tclassName: cnMerge(\n\t\t\t\t\t`scrollbar-hidden flex w-full cursor-grab snap-x snap-mandatory overflow-x-scroll overflow-y-hidden`,\n\t\t\t\t\torientation === \"horizontal\" && \"flex-row\",\n\t\t\t\t\torientation === \"vertical\" && \"flex-col\",\n\t\t\t\t\tusage === \"mobileAndTabletOnly\" && \"md:cursor-default md:flex-col\",\n\t\t\t\t\tusage === \"desktopOnly\" && \"max-md:cursor-default max-md:flex-col\",\n\t\t\t\t\tinnerProps?.className\n\t\t\t\t),\n\t\t\t\tref: composeRefs(\n\t\t\t\t\trefCallback,\n\t\t\t\t\t(innerProps as { ref?: React.Ref<TContainerElement> } | undefined)?.ref\n\t\t\t\t),\n\t\t\t} as never;\n\t\t},\n\t\t[disableInternalStateSubscription, isDragging, orientation, refCallback, usage]\n\t);\n\n\tconst getItemProps: DragScrollPropGetters<TContainerElement>[\"getItemProps\"] = useCallbackRef(\n\t\t(innerProps) => {\n\t\t\treturn {\n\t\t\t\t...innerProps,\n\t\t\t\t...getDragScrollScopeAttrs(\"item\"),\n\t\t\t\tclassName: cnMerge(\"snap-center snap-always\", innerProps?.className),\n\t\t\t};\n\t\t}\n\t);\n\n\tconst getPrevButtonProps: DragScrollPropGetters<TContainerElement>[\"getPrevButtonProps\"] = useCallback(\n\t\t(innerProps) => {\n\t\t\tconst isDisabled = innerProps?.disabled ?? !canGoToPrev;\n\n\t\t\treturn {\n\t\t\t\t...innerProps,\n\t\t\t\t...getDragScrollScopeAttrs(\"prev-button\"),\n\t\t\t\t\"aria-disabled\": dataAttr(isDisabled),\n\t\t\t\t\"aria-label\": innerProps?.[\"aria-label\"] ?? \"Scroll back\",\n\t\t\t\t\"data-disabled\": dataAttr(isDisabled),\n\t\t\t\tdisabled: isDisabled,\n\t\t\t\tonClick: composeTwoEventHandlers(actions.goToPrev, innerProps?.onClick),\n\t\t\t\ttype: \"button\",\n\t\t\t};\n\t\t},\n\t\t[actions.goToPrev, canGoToPrev]\n\t);\n\n\tconst getNextButtonProps: DragScrollPropGetters<TContainerElement>[\"getNextButtonProps\"] = useCallback(\n\t\t(innerProps) => {\n\t\t\tconst isDisabled = innerProps?.disabled ?? !canGoToNext;\n\n\t\t\treturn {\n\t\t\t\t...innerProps,\n\t\t\t\t...getDragScrollScopeAttrs(\"next-button\"),\n\t\t\t\t\"aria-label\": innerProps?.[\"aria-label\"] ?? \"Scroll forward\",\n\t\t\t\t\"data-disabled\": dataAttr(isDisabled),\n\t\t\t\tdisabled: isDisabled,\n\t\t\t\tonClick: composeTwoEventHandlers(actions.goToNext, innerProps?.onClick),\n\t\t\t\ttype: \"button\",\n\t\t\t};\n\t\t},\n\t\t[actions.goToNext, canGoToNext]\n\t);\n\n\tconst propGetters = useMemo<DragScrollPropGetters<TContainerElement>>(\n\t\t() =>\n\t\t\t({\n\t\t\t\tgetItemProps,\n\t\t\t\tgetListProps,\n\t\t\t\tgetNextButtonProps,\n\t\t\t\tgetPrevButtonProps,\n\t\t\t\tgetRootProps,\n\t\t\t}) satisfies DragScrollPropGetters<TContainerElement>,\n\t\t[getPrevButtonProps, getListProps, getItemProps, getNextButtonProps, getRootProps]\n\t);\n\n\tconst stableUseDragScrollStore = useCallbackRef(useDragScrollStore);\n\n\tconst result = useMemo<UseDragScrollResult<TContainerElement>>(\n\t\t() =>\n\t\t\t({\n\t\t\t\tdisableInternalStateSubscription,\n\t\t\t\tlistRef,\n\t\t\t\tpropGetters,\n\t\t\t\tstoreApi,\n\t\t\t\tuseDragScrollStore: stableUseDragScrollStore,\n\t\t\t}) satisfies UseDragScrollResult<TContainerElement>,\n\t\t[propGetters, disableInternalStateSubscription, storeApi, stableUseDragScrollStore]\n\t);\n\n\treturn result;\n};\n","import { createCustomContext } from \"@zayne-labs/toolkit-react\";\nimport { createReactStoreContext } from \"@zayne-labs/toolkit-react/zustand\";\nimport type { DragScrollStore, UseDragScrollResult } from \"./types\";\n\nconst [DragScrollStoreContextProvider, useDragScrollStoreContext] =\n\tcreateReactStoreContext<DragScrollStore>({\n\t\thookName: \"useDragScrollStoreContext\",\n\t\tname: \"DragScrollStoreContext\",\n\t\tproviderName: \"DragScrollRoot\",\n\t});\n\nexport type DragScrollRootContextType<TElement extends HTMLElement = HTMLElement> = Pick<\n\tUseDragScrollResult<TElement>,\n\t\"disableInternalStateSubscription\" | \"listRef\" | \"propGetters\"\n>;\n\nconst [DragScrollRootContextProvider, useDragScrollRootContext] =\n\tcreateCustomContext<DragScrollRootContextType>({\n\t\thookName: \"useDragScrollRootContext\",\n\t\tname: \"DragScrollRootContext\",\n\t\tproviderName: \"DragScrollRoot\",\n\t});\n\nexport {\n\tDragScrollRootContextProvider,\n\tDragScrollStoreContextProvider,\n\tuseDragScrollRootContext,\n\tuseDragScrollStoreContext,\n};\n","\"use client\";\n\nimport { useCompareSelector } from \"@zayne-labs/toolkit-react\";\nimport type { PolymorphicPropsStrict } from \"@zayne-labs/toolkit-react/utils\";\nimport { isFunction, type SelectorFn } from \"@zayne-labs/toolkit-type-helpers\";\nimport { useMemo } from \"react\";\nimport { Slot } from \"@/components/common/slot\";\nimport {\n\tDragScrollRootContextProvider,\n\tDragScrollStoreContextProvider,\n\tuseDragScrollRootContext,\n\tuseDragScrollStoreContext,\n\ttype DragScrollRootContextType,\n} from \"./drag-scroll-context\";\nimport type { DragScrollStore, PartInputProps, UseDragScrollProps } from \"./types\";\nimport { useDragScroll } from \"./use-drag-scroll\";\n\n/* eslint-disable perfectionist/sort-intersection-types -- I need non-standard props to come first */\n\nexport type DragScrollRootProps = UseDragScrollProps & {\n\tasChild?: boolean;\n\tchildren: React.ReactNode;\n} & PartInputProps[\"root\"];\n\nexport function DragScrollRoot(props: DragScrollRootProps) {\n\tconst { asChild, children, ...restOfProps } = props;\n\n\tconst { disableInternalStateSubscription, listRef, propGetters, storeApi } = useDragScroll(restOfProps);\n\n\tconst rootContextValue = useMemo<DragScrollRootContextType>(\n\t\t() =>\n\t\t\t({\n\t\t\t\tdisableInternalStateSubscription,\n\t\t\t\tlistRef,\n\t\t\t\tpropGetters,\n\t\t\t}) satisfies DragScrollRootContextType,\n\t\t[listRef, disableInternalStateSubscription, propGetters]\n\t);\n\n\tconst Component = asChild ? Slot.Root : \"div\";\n\n\treturn (\n\t\t<DragScrollStoreContextProvider store={storeApi}>\n\t\t\t<DragScrollRootContextProvider value={rootContextValue}>\n\t\t\t\t<Component {...propGetters.getRootProps(restOfProps)}>{children}</Component>\n\t\t\t</DragScrollRootContextProvider>\n\t\t</DragScrollStoreContextProvider>\n\t);\n}\n\nexport type DragScrollContextProps<TSlice> = {\n\tchildren: React.ReactNode | ((context: TSlice) => React.ReactNode);\n\tselector?: SelectorFn<DragScrollStore, TSlice>;\n};\n\nexport function DragScrollContext<TSlice = DragScrollStore>(props: DragScrollContextProps<TSlice>) {\n\tconst { children, selector } = props;\n\n\tconst dragScrollCtx = useDragScrollStoreContext(useCompareSelector(selector));\n\n\tconst resolvedChildren = isFunction(children) ? children(dragScrollCtx) : children;\n\n\treturn resolvedChildren;\n}\n\nexport type DragScrollListProps = {\n\tasChild?: boolean;\n} & PartInputProps[\"list\"];\n\nexport function DragScrollList<TElement extends React.ElementType = \"ul\">(\n\tprops: PolymorphicPropsStrict<TElement, DragScrollListProps>\n) {\n\tconst { as: Element = \"ul\", asChild, ...restOfProps } = props;\n\n\tconst { propGetters } = useDragScrollRootContext();\n\n\tconst Component = asChild ? Slot.Root : Element;\n\n\treturn <Component {...propGetters.getListProps(restOfProps)} />;\n}\n\nexport type DragScrollItemProps = {\n\tasChild?: boolean;\n} & PartInputProps[\"item\"];\n\nexport function DragScrollItem<TElement extends React.ElementType = \"li\">(\n\tprops: PolymorphicPropsStrict<TElement, DragScrollItemProps>\n) {\n\tconst { as: Element = \"li\", asChild, ...restOfProps } = props;\n\n\tconst { propGetters } = useDragScrollRootContext();\n\n\tconst Component = asChild ? Slot.Root : Element;\n\n\treturn <Component {...propGetters.getItemProps(restOfProps)} />;\n}\n\nexport type DragScrollPrevProps = {\n\tasChild?: boolean;\n} & PartInputProps[\"prevButton\"];\n\nexport function DragScrollPrev(props: DragScrollPrevProps) {\n\tconst { asChild, ...restOfProps } = props;\n\n\tconst { propGetters } = useDragScrollRootContext();\n\n\tconst Component = asChild ? Slot.Root : \"button\";\n\n\treturn <Component {...propGetters.getPrevButtonProps(restOfProps)} />;\n}\n\nexport type DragScrollNextProps = {\n\tasChild?: boolean;\n} & PartInputProps[\"nextButton\"];\n\nexport function DragScrollNext(props: DragScrollNextProps) {\n\tconst { asChild, ...restOfProps } = props;\n\n\tconst { propGetters } = useDragScrollRootContext();\n\n\tconst Component = asChild ? Slot.Root : \"button\";\n\n\treturn <Component {...propGetters.getNextButtonProps(restOfProps)} />;\n}\n\n/* eslint-enable perfectionist/sort-intersection-types -- I need non-standard props to come first */\n","export {\n\tDragScrollContext as Context,\n\tDragScrollItem as Item,\n\tDragScrollNext as Next,\n\tDragScrollPrev as Prev,\n\tDragScrollRoot as Root,\n\tDragScrollList as List,\n} from \"./drag-sc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QAAO,oBAFW,UAAUA,WAAY,SAEjC,EAAW,GAAI,YAAY,aAAa,YAAY,EAAI,CAAA;;AAOhE,SAAgB,eACf,OACC;CACD,MAAM,EAAE,IAAI,UAAU,MAAM,SAAS,GAAG,gBAAgB;CAExD,MAAM,EAAE,gBAAgB,0BAA0B;AAIlD,QAAO,oBAFW,UAAUA,WAAY,SAEjC,EAAW,GAAI,YAAY,aAAa,YAAY,EAAI,CAAA;;AAOhE,SAAgB,eAAe,OAA4B;CAC1D,MAAM,EAAE,SAAS,GAAG,gBAAgB;CAEpC,MAAM,EAAE,gBAAgB,0BAA0B;AAIlD,QAAO,oBAFW,UAAUA,WAAY,UAEjC,EAAW,GAAI,YAAY,mBAAmB,YAAY,EAAI,CAAA;;AAOtE,SAAgB,eAAe,OAA4B;CAC1D,MAAM,EAAE,SAAS,GAAG,gBAAgB;CAEpC,MAAM,EAAE,gBAAgB,0BAA0B;AAIlD,QAAO,oBAFW,UAAUA,WAAY,UAEjC,EAAW,GAAI,YAAY,mBAAmB,YAAY,EAAI,CAAA"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { InferProps, PolymorphicPropsStrict } from "@zayne-labs/toolkit-react/utils";
|
|
2
|
-
import * as _zayne_labs_toolkit_type_helpers0 from "@zayne-labs/toolkit-type-helpers";
|
|
2
|
+
import * as _$_zayne_labs_toolkit_type_helpers0 from "@zayne-labs/toolkit-type-helpers";
|
|
3
3
|
import { Awaitable, SelectorFn, UnionDiscriminator } from "@zayne-labs/toolkit-type-helpers";
|
|
4
|
-
import * as react from "react";
|
|
5
|
-
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
6
|
-
import * as _zayne_labs_toolkit_core0 from "@zayne-labs/toolkit-core";
|
|
4
|
+
import * as _$react from "react";
|
|
5
|
+
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
6
|
+
import * as _$_zayne_labs_toolkit_core0 from "@zayne-labs/toolkit-core";
|
|
7
7
|
import { FileMeta, FileOrFileMeta, FileValidationErrorContextEach, FileValidationHooksAsync, FileValidationSettingsAsync } from "@zayne-labs/toolkit-core";
|
|
8
8
|
|
|
9
9
|
//#region src/components/ui/drop-zone/drop-zone-store.d.ts
|
|
@@ -30,20 +30,9 @@ declare const createDropZoneStore: (storeContext: StoreContext) => {
|
|
|
30
30
|
shouldReplace: true;
|
|
31
31
|
}) | undefined): void;
|
|
32
32
|
};
|
|
33
|
-
subscribe: _zayne_labs_toolkit_core0.SubscribeFn<DropZoneStore>;
|
|
33
|
+
subscribe: _$_zayne_labs_toolkit_core0.SubscribeFn<DropZoneStore>;
|
|
34
34
|
};
|
|
35
35
|
//#endregion
|
|
36
|
-
//#region src/components/ui/drop-zone/utils.d.ts
|
|
37
|
-
declare class DropZoneError extends Error {
|
|
38
|
-
readonly dropZoneErrorSymbol: symbol;
|
|
39
|
-
file?: FileValidationErrorContextEach["file"];
|
|
40
|
-
name: "DropZoneError";
|
|
41
|
-
constructor(ctx: Pick<FileValidationErrorContextEach, "message"> & {
|
|
42
|
-
file?: FileValidationErrorContextEach["file"];
|
|
43
|
-
}, errorOptions?: ErrorOptions);
|
|
44
|
-
static isError(error: unknown): error is DropZoneError;
|
|
45
|
-
}
|
|
46
|
-
//#endregion
|
|
47
36
|
//#region src/components/ui/drop-zone/types.d.ts
|
|
48
37
|
type FileErrorContext = Omit<FileValidationErrorContextEach, "code"> & {
|
|
49
38
|
code: "upload-error" | FileValidationErrorContextEach["code"];
|
|
@@ -89,11 +78,11 @@ type SharedInputProps = {
|
|
|
89
78
|
};
|
|
90
79
|
interface PartProps {
|
|
91
80
|
container: {
|
|
92
|
-
input: PartProps["container"]["output"]
|
|
81
|
+
input: SharedInputProps & PartProps["container"]["output"];
|
|
93
82
|
output: RecordForDataAttr & InferProps<HTMLElement>;
|
|
94
83
|
};
|
|
95
84
|
fileItem: {
|
|
96
|
-
input: PartProps["fileItem"]["output"]
|
|
85
|
+
input: SharedInputProps & PartProps["fileItem"]["output"];
|
|
97
86
|
output: RecordForDataAttr & InferProps<"li">;
|
|
98
87
|
};
|
|
99
88
|
fileItemClear: {
|
|
@@ -128,6 +117,10 @@ interface PartProps {
|
|
|
128
117
|
input: PartProps["input"]["output"];
|
|
129
118
|
output: RecordForDataAttr & InferProps<"input">;
|
|
130
119
|
};
|
|
120
|
+
root: {
|
|
121
|
+
input: SharedInputProps & PartProps["root"]["output"];
|
|
122
|
+
output: RecordForDataAttr & InferProps<"div">;
|
|
123
|
+
};
|
|
131
124
|
trigger: {
|
|
132
125
|
input: PartProps["trigger"]["output"];
|
|
133
126
|
output: RecordForDataAttr & InferProps<"button">;
|
|
@@ -221,7 +214,7 @@ interface UseDropZoneProps extends FileValidationSettingsAsync, Pick<SharedInput
|
|
|
221
214
|
*/
|
|
222
215
|
onUpload?: (context: Pick<DropZoneState, "fileStateArray"> & {
|
|
223
216
|
onError: (ctx: FileStateOrIDProp & {
|
|
224
|
-
error:
|
|
217
|
+
error: unknown;
|
|
225
218
|
}) => void;
|
|
226
219
|
onProgress: (ctx: FileStateOrIDProp & {
|
|
227
220
|
progress: number;
|
|
@@ -269,9 +262,9 @@ declare const DropZoneStoreContextProvider: (props: {
|
|
|
269
262
|
shouldReplace: true;
|
|
270
263
|
}) | undefined): void;
|
|
271
264
|
};
|
|
272
|
-
subscribe: _zayne_labs_toolkit_core0.SubscribeFn<DropZoneStore>;
|
|
265
|
+
subscribe: _$_zayne_labs_toolkit_core0.SubscribeFn<DropZoneStore>;
|
|
273
266
|
};
|
|
274
|
-
}) => react.FunctionComponentElement<react.ProviderProps<{
|
|
267
|
+
}) => _$react.FunctionComponentElement<_$react.ProviderProps<{
|
|
275
268
|
getInitialState: () => DropZoneStore;
|
|
276
269
|
getListeners: () => Set<(state: DropZoneStore, prevState: DropZoneStore) => void>;
|
|
277
270
|
getState: () => DropZoneStore;
|
|
@@ -292,39 +285,39 @@ declare const DropZoneStoreContextProvider: (props: {
|
|
|
292
285
|
shouldReplace: true;
|
|
293
286
|
}) | undefined): void;
|
|
294
287
|
};
|
|
295
|
-
subscribe: _zayne_labs_toolkit_core0.SubscribeFn<DropZoneStore>;
|
|
296
|
-
}>>, useDropZoneStoreContext: <TResult = DropZoneStore>(selector?: _zayne_labs_toolkit_type_helpers0.SelectorFn<DropZoneStore, TResult> | undefined) => TResult;
|
|
288
|
+
subscribe: _$_zayne_labs_toolkit_core0.SubscribeFn<DropZoneStore>;
|
|
289
|
+
}>>, useDropZoneStoreContext: <TResult = DropZoneStore>(selector?: _$_zayne_labs_toolkit_type_helpers0.SelectorFn<DropZoneStore, TResult> | undefined) => TResult;
|
|
297
290
|
type FileItemContextType = {
|
|
298
291
|
fileState: FileState;
|
|
299
292
|
};
|
|
300
293
|
//#endregion
|
|
301
294
|
//#region src/components/ui/drop-zone/drop-zone.d.ts
|
|
302
295
|
type DropZoneRootProps = UseDropZoneProps & {
|
|
303
|
-
|
|
304
|
-
};
|
|
305
|
-
declare function DropZoneRoot(props: DropZoneRootProps): react_jsx_runtime0.JSX.Element;
|
|
296
|
+
asChild?: boolean;
|
|
297
|
+
} & PartInputProps["root"];
|
|
298
|
+
declare function DropZoneRoot<TElement extends React.ElementType = "div">(props: PolymorphicPropsStrict<TElement, DropZoneRootProps>): _$react_jsx_runtime0.JSX.Element;
|
|
306
299
|
type DropZoneContextProps<TSlice> = {
|
|
307
300
|
children: React.ReactNode | ((context: TSlice) => React.ReactNode);
|
|
308
301
|
selector?: SelectorFn<DropZoneStore, TSlice>;
|
|
309
302
|
};
|
|
310
|
-
declare function DropZoneContext<TSlice = DropZoneStore>(props: DropZoneContextProps<TSlice>): react.ReactNode;
|
|
303
|
+
declare function DropZoneContext<TSlice = DropZoneStore>(props: DropZoneContextProps<TSlice>): _$react.ReactNode;
|
|
311
304
|
type DropZoneContainerProps = {
|
|
312
305
|
asChild?: boolean;
|
|
313
306
|
} & PartInputProps["container"];
|
|
314
|
-
declare function DropZoneContainer<TElement extends React.ElementType = "div">(props: PolymorphicPropsStrict<TElement, DropZoneContainerProps>): react_jsx_runtime0.JSX.Element;
|
|
307
|
+
declare function DropZoneContainer<TElement extends React.ElementType = "div">(props: PolymorphicPropsStrict<TElement, DropZoneContainerProps>): _$react_jsx_runtime0.JSX.Element;
|
|
315
308
|
type DropZoneInputProps = {
|
|
316
309
|
asChild?: boolean;
|
|
317
310
|
} & PartInputProps["input"];
|
|
318
|
-
declare function DropZoneInput(props: DropZoneInputProps): react_jsx_runtime0.JSX.Element;
|
|
311
|
+
declare function DropZoneInput(props: DropZoneInputProps): _$react_jsx_runtime0.JSX.Element;
|
|
319
312
|
type DropZoneAreaProps<TSlice = DropZoneStore> = DropZoneContextProps<TSlice> & {
|
|
320
313
|
classNames?: Partial<Record<Extract<keyof PartInputProps, "container" | "input">, string>>;
|
|
321
314
|
extraProps?: Partial<Pick<PartInputProps, "container" | "input">>;
|
|
322
315
|
} & PartInputProps["container"];
|
|
323
|
-
declare function DropZoneArea<TSlice = DropZoneStore>(props: DropZoneAreaProps<TSlice>): react_jsx_runtime0.JSX.Element;
|
|
316
|
+
declare function DropZoneArea<TSlice = DropZoneStore>(props: DropZoneAreaProps<TSlice>): _$react_jsx_runtime0.JSX.Element;
|
|
324
317
|
type DropZoneTriggerProps = {
|
|
325
318
|
asChild?: boolean;
|
|
326
319
|
} & PartInputProps["trigger"];
|
|
327
|
-
declare function DropZoneTrigger(props: DropZoneTriggerProps): react_jsx_runtime0.JSX.Element;
|
|
320
|
+
declare function DropZoneTrigger(props: DropZoneTriggerProps): _$react_jsx_runtime0.JSX.Element;
|
|
328
321
|
type ListPerItemContext = Pick<DropZoneStore, "actions"> & {
|
|
329
322
|
array: DropZoneStore["fileStateArray"];
|
|
330
323
|
fileState: DropZoneStore["fileStateArray"][number];
|
|
@@ -343,15 +336,15 @@ type DropZoneFileListProps = {
|
|
|
343
336
|
asChild?: boolean;
|
|
344
337
|
forceMount?: boolean;
|
|
345
338
|
} & (FileListManualListVariant | FileListPerItemVariant) & Omit<PartInputProps["fileList"], "children">;
|
|
346
|
-
declare function DropZoneFileList<TElement extends React.ElementType = "ul">(props: PolymorphicPropsStrict<TElement, DropZoneFileListProps>): react_jsx_runtime0.JSX.Element;
|
|
339
|
+
declare function DropZoneFileList<TElement extends React.ElementType = "ul">(props: PolymorphicPropsStrict<TElement, DropZoneFileListProps>): _$react_jsx_runtime0.JSX.Element;
|
|
347
340
|
type DropZoneFileItemProps = FileItemContextType & {
|
|
348
341
|
asChild?: boolean;
|
|
349
342
|
} & PartInputProps["fileItem"];
|
|
350
|
-
declare function DropZoneFileItem<TElement extends React.ElementType = "li">(props: PolymorphicPropsStrict<TElement, DropZoneFileItemProps>): react_jsx_runtime0.JSX.Element;
|
|
343
|
+
declare function DropZoneFileItem<TElement extends React.ElementType = "li">(props: PolymorphicPropsStrict<TElement, DropZoneFileItemProps>): _$react_jsx_runtime0.JSX.Element;
|
|
351
344
|
type DropZoneFileItemDeleteProps = {
|
|
352
345
|
asChild?: boolean;
|
|
353
346
|
} & PartInputProps["fileItemDelete"];
|
|
354
|
-
declare function DropZoneFileItemDelete(props: DropZoneFileItemDeleteProps): react_jsx_runtime0.JSX.Element;
|
|
347
|
+
declare function DropZoneFileItemDelete(props: DropZoneFileItemDeleteProps): _$react_jsx_runtime0.JSX.Element;
|
|
355
348
|
type StrictExtract<TUnion, TPick extends TUnion> = Extract<TUnion, TPick>;
|
|
356
349
|
type DropZoneFileItemProgressProps = {
|
|
357
350
|
asChild?: boolean;
|
|
@@ -375,7 +368,7 @@ type DropZoneFileItemProgressProps = {
|
|
|
375
368
|
};
|
|
376
369
|
variant?: StrictExtract<PartInputProps["fileItemProgress"]["variant"], "linear">;
|
|
377
370
|
});
|
|
378
|
-
declare function DropZoneFileItemProgress<TElement extends React.ElementType = "span">(props: PolymorphicPropsStrict<TElement, DropZoneFileItemProgressProps>): react_jsx_runtime0.JSX.Element | null;
|
|
371
|
+
declare function DropZoneFileItemProgress<TElement extends React.ElementType = "span">(props: PolymorphicPropsStrict<TElement, DropZoneFileItemProgressProps>): _$react_jsx_runtime0.JSX.Element | null;
|
|
379
372
|
type NodeCtx<TElement extends React.ElementType> = {
|
|
380
373
|
getProps: (innerProps: Partial<InferProps<TElement>>) => InferProps<TElement>;
|
|
381
374
|
};
|
|
@@ -407,7 +400,7 @@ type DropZoneFileItemPreviewProps = Partial<Pick<FileItemContextType, "fileState
|
|
|
407
400
|
}) => React.ReactNode);
|
|
408
401
|
renderPreview?: boolean | RenderPreview;
|
|
409
402
|
} & Omit<PartInputProps["fileItemPreview"], "children">;
|
|
410
|
-
declare function DropZoneFileItemPreview<TElement extends React.ElementType>(props: PolymorphicPropsStrict<TElement, DropZoneFileItemPreviewProps>): react_jsx_runtime0.JSX.Element | null;
|
|
403
|
+
declare function DropZoneFileItemPreview<TElement extends React.ElementType>(props: PolymorphicPropsStrict<TElement, DropZoneFileItemPreviewProps>): _$react_jsx_runtime0.JSX.Element | null;
|
|
411
404
|
type DropZoneFileItemMetadataProps = Partial<Pick<FileItemContextType, "fileState">> & {
|
|
412
405
|
asChild?: boolean;
|
|
413
406
|
children?: React.ReactNode | ((context: Pick<FileItemContextType, "fileState">) => React.ReactNode);
|
|
@@ -417,12 +410,12 @@ type DropZoneFileItemMetadataProps = Partial<Pick<FileItemContextType, "fileStat
|
|
|
417
410
|
};
|
|
418
411
|
size?: "default" | "sm";
|
|
419
412
|
} & Omit<PartInputProps["fileItemMetadata"], "children">;
|
|
420
|
-
declare function DropZoneFileItemMetadata(props: DropZoneFileItemMetadataProps): react_jsx_runtime0.JSX.Element | null;
|
|
413
|
+
declare function DropZoneFileItemMetadata(props: DropZoneFileItemMetadataProps): _$react_jsx_runtime0.JSX.Element | null;
|
|
421
414
|
type DropZoneFileClearProps = {
|
|
422
415
|
asChild?: boolean;
|
|
423
416
|
forceMount?: boolean;
|
|
424
417
|
} & PartInputProps["fileItemClear"];
|
|
425
|
-
declare function DropZoneFileClear(props: DropZoneFileClearProps): react_jsx_runtime0.JSX.Element | null;
|
|
418
|
+
declare function DropZoneFileClear(props: DropZoneFileClearProps): _$react_jsx_runtime0.JSX.Element | null;
|
|
426
419
|
declare namespace drop_zone_parts_d_exports {
|
|
427
420
|
export { DropZoneArea as Area, DropZoneContainer as Container, DropZoneContext as Context, DropZoneFileClear as FileClear, DropZoneFileItem as FileItem, DropZoneFileItemDelete as FileItemDelete, DropZoneFileItemMetadata as FileItemMetadata, DropZoneFileItemPreview as FileItemPreview, DropZoneFileItemProgress as FileItemProgress, DropZoneFileList as FileList, DropZoneInput as Input, DropZoneRoot as Root, DropZoneTrigger as Trigger };
|
|
428
421
|
}
|
|
@@ -430,5 +423,16 @@ declare namespace drop_zone_parts_d_exports {
|
|
|
430
423
|
//#region src/components/ui/drop-zone/use-drop-zone.d.ts
|
|
431
424
|
declare const useDropZone: (props?: UseDropZoneProps) => UseDropZoneResult;
|
|
432
425
|
//#endregion
|
|
426
|
+
//#region src/components/ui/drop-zone/utils.d.ts
|
|
427
|
+
declare class DropZoneError extends Error {
|
|
428
|
+
readonly dropZoneErrorSymbol: symbol;
|
|
429
|
+
file?: FileValidationErrorContextEach["file"];
|
|
430
|
+
name: "DropZoneError";
|
|
431
|
+
constructor(ctx: Pick<FileValidationErrorContextEach, "message"> & {
|
|
432
|
+
file?: FileValidationErrorContextEach["file"];
|
|
433
|
+
}, errorOptions?: ErrorOptions);
|
|
434
|
+
static isError(error: unknown): error is DropZoneError;
|
|
435
|
+
}
|
|
436
|
+
//#endregion
|
|
433
437
|
export { drop_zone_parts_d_exports as DropZone, type DropZoneActions, DropZoneArea, DropZoneAreaProps, DropZoneContainer, DropZoneContainerProps, DropZoneContext, DropZoneContextProps, DropZoneError, DropZoneFileClear, DropZoneFileClearProps, DropZoneFileItem, DropZoneFileItemDelete, DropZoneFileItemDeleteProps, DropZoneFileItemMetadata, DropZoneFileItemMetadataProps, DropZoneFileItemPreview, DropZoneFileItemPreviewProps, DropZoneFileItemProgress, DropZoneFileItemProgressProps, DropZoneFileItemProps, DropZoneFileList, DropZoneFileListProps, DropZoneInput, DropZoneInputProps, DropZoneRoot, DropZoneRootProps, type DropZoneState, type DropZoneStore, DropZoneTrigger, DropZoneTriggerProps, type FileState, type UseDropZoneProps, type UseDropZoneResult, useDropZone, useDropZoneStoreContext };
|
|
434
438
|
//# sourceMappingURL=index.d.ts.map
|