@zayne-labs/ui-react 0.0.9 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,20 +1,301 @@
1
+ import * as react from 'react';
1
2
  import { RefCallback } from 'react';
3
+ import { InferProps } from '@zayne-labs/toolkit-react/utils';
2
4
 
3
- type DragScrollProps = {
5
+ type DragScrollProps<TElement extends HTMLElement> = {
4
6
  classNames?: {
5
7
  base?: string;
6
8
  item?: string;
7
9
  };
10
+ extraItemProps?: InferProps<HTMLElement>;
11
+ extraRootProps?: InferProps<TElement>;
8
12
  orientation?: "both" | "horizontal" | "vertical";
9
13
  usage?: "allScreens" | "desktopOnly" | "mobileAndTabletOnly";
10
14
  };
11
- declare const useDragScroll: <TElement extends HTMLElement>(props?: DragScrollProps) => {
12
- getItemProps: () => {
15
+ declare const useDragScroll: <TElement extends HTMLElement>(props?: DragScrollProps<TElement>) => {
16
+ getItemProps: (itemProps?: DragScrollProps<TElement>["extraItemProps"]) => {
13
17
  className: string;
14
18
  "data-part": string;
15
19
  "data-scope": string;
20
+ defaultChecked?: boolean | undefined;
21
+ defaultValue?: string | number | readonly string[] | undefined;
22
+ suppressContentEditableWarning?: boolean | undefined;
23
+ suppressHydrationWarning?: boolean | undefined;
24
+ accessKey?: string | undefined;
25
+ autoCapitalize?: "off" | "none" | "on" | "sentences" | "words" | "characters" | undefined | (string & {});
26
+ autoFocus?: boolean | undefined;
27
+ contentEditable?: (boolean | "true" | "false") | "inherit" | "plaintext-only" | undefined;
28
+ contextMenu?: string | undefined;
29
+ dir?: string | undefined;
30
+ draggable?: (boolean | "true" | "false") | undefined;
31
+ enterKeyHint?: "enter" | "done" | "go" | "next" | "previous" | "search" | "send" | undefined;
32
+ hidden?: boolean | undefined;
33
+ id?: string | undefined;
34
+ lang?: string | undefined;
35
+ nonce?: string | undefined;
36
+ slot?: string | undefined;
37
+ spellCheck?: (boolean | "true" | "false") | undefined;
38
+ style?: react.CSSProperties | undefined;
39
+ tabIndex?: number | undefined;
40
+ title?: string | undefined;
41
+ translate?: "yes" | "no" | undefined;
42
+ radioGroup?: string | undefined;
43
+ role?: react.AriaRole | undefined;
44
+ about?: string | undefined;
45
+ content?: string | undefined;
46
+ datatype?: string | undefined;
47
+ inlist?: any;
48
+ prefix?: string | undefined;
49
+ property?: string | undefined;
50
+ rel?: string | undefined;
51
+ resource?: string | undefined;
52
+ rev?: string | undefined;
53
+ typeof?: string | undefined;
54
+ vocab?: string | undefined;
55
+ autoCorrect?: string | undefined;
56
+ autoSave?: string | undefined;
57
+ color?: string | undefined;
58
+ itemProp?: string | undefined;
59
+ itemScope?: boolean | undefined;
60
+ itemType?: string | undefined;
61
+ itemID?: string | undefined;
62
+ itemRef?: string | undefined;
63
+ results?: number | undefined;
64
+ security?: string | undefined;
65
+ unselectable?: "on" | "off" | undefined;
66
+ popover?: "" | "auto" | "manual" | undefined;
67
+ popoverTargetAction?: "toggle" | "show" | "hide" | undefined;
68
+ popoverTarget?: string | undefined;
69
+ inert?: boolean | undefined;
70
+ inputMode?: "none" | "text" | "tel" | "url" | "email" | "numeric" | "decimal" | "search" | undefined;
71
+ is?: string | undefined;
72
+ "aria-activedescendant"?: string | undefined;
73
+ "aria-atomic"?: (boolean | "true" | "false") | undefined;
74
+ "aria-autocomplete"?: "none" | "inline" | "list" | "both" | undefined;
75
+ "aria-braillelabel"?: string | undefined;
76
+ "aria-brailleroledescription"?: string | undefined;
77
+ "aria-busy"?: (boolean | "true" | "false") | undefined;
78
+ "aria-checked"?: boolean | "false" | "mixed" | "true" | undefined;
79
+ "aria-colcount"?: number | undefined;
80
+ "aria-colindex"?: number | undefined;
81
+ "aria-colindextext"?: string | undefined;
82
+ "aria-colspan"?: number | undefined;
83
+ "aria-controls"?: string | undefined;
84
+ "aria-current"?: boolean | "false" | "true" | "page" | "step" | "location" | "date" | "time" | undefined;
85
+ "aria-describedby"?: string | undefined;
86
+ "aria-description"?: string | undefined;
87
+ "aria-details"?: string | undefined;
88
+ "aria-disabled"?: (boolean | "true" | "false") | undefined;
89
+ "aria-dropeffect"?: "none" | "copy" | "execute" | "link" | "move" | "popup" | undefined;
90
+ "aria-errormessage"?: string | undefined;
91
+ "aria-expanded"?: (boolean | "true" | "false") | undefined;
92
+ "aria-flowto"?: string | undefined;
93
+ "aria-grabbed"?: (boolean | "true" | "false") | undefined;
94
+ "aria-haspopup"?: boolean | "false" | "true" | "menu" | "listbox" | "tree" | "grid" | "dialog" | undefined;
95
+ "aria-hidden"?: (boolean | "true" | "false") | undefined;
96
+ "aria-invalid"?: boolean | "false" | "true" | "grammar" | "spelling" | undefined;
97
+ "aria-keyshortcuts"?: string | undefined;
98
+ "aria-label"?: string | undefined;
99
+ "aria-labelledby"?: string | undefined;
100
+ "aria-level"?: number | undefined;
101
+ "aria-live"?: "off" | "assertive" | "polite" | undefined;
102
+ "aria-modal"?: (boolean | "true" | "false") | undefined;
103
+ "aria-multiline"?: (boolean | "true" | "false") | undefined;
104
+ "aria-multiselectable"?: (boolean | "true" | "false") | undefined;
105
+ "aria-orientation"?: "horizontal" | "vertical" | undefined;
106
+ "aria-owns"?: string | undefined;
107
+ "aria-placeholder"?: string | undefined;
108
+ "aria-posinset"?: number | undefined;
109
+ "aria-pressed"?: boolean | "false" | "mixed" | "true" | undefined;
110
+ "aria-readonly"?: (boolean | "true" | "false") | undefined;
111
+ "aria-relevant"?: "additions" | "additions removals" | "additions text" | "all" | "removals" | "removals additions" | "removals text" | "text" | "text additions" | "text removals" | undefined;
112
+ "aria-required"?: (boolean | "true" | "false") | undefined;
113
+ "aria-roledescription"?: string | undefined;
114
+ "aria-rowcount"?: number | undefined;
115
+ "aria-rowindex"?: number | undefined;
116
+ "aria-rowindextext"?: string | undefined;
117
+ "aria-rowspan"?: number | undefined;
118
+ "aria-selected"?: (boolean | "true" | "false") | undefined;
119
+ "aria-setsize"?: number | undefined;
120
+ "aria-sort"?: "none" | "ascending" | "descending" | "other" | undefined;
121
+ "aria-valuemax"?: number | undefined;
122
+ "aria-valuemin"?: number | undefined;
123
+ "aria-valuenow"?: number | undefined;
124
+ "aria-valuetext"?: string | undefined;
125
+ children?: react.ReactNode | undefined;
126
+ dangerouslySetInnerHTML?: {
127
+ __html: string | TrustedHTML;
128
+ } | undefined;
129
+ onCopy?: react.ClipboardEventHandler<HTMLElement> | undefined;
130
+ onCopyCapture?: react.ClipboardEventHandler<HTMLElement> | undefined;
131
+ onCut?: react.ClipboardEventHandler<HTMLElement> | undefined;
132
+ onCutCapture?: react.ClipboardEventHandler<HTMLElement> | undefined;
133
+ onPaste?: react.ClipboardEventHandler<HTMLElement> | undefined;
134
+ onPasteCapture?: react.ClipboardEventHandler<HTMLElement> | undefined;
135
+ onCompositionEnd?: react.CompositionEventHandler<HTMLElement> | undefined;
136
+ onCompositionEndCapture?: react.CompositionEventHandler<HTMLElement> | undefined;
137
+ onCompositionStart?: react.CompositionEventHandler<HTMLElement> | undefined;
138
+ onCompositionStartCapture?: react.CompositionEventHandler<HTMLElement> | undefined;
139
+ onCompositionUpdate?: react.CompositionEventHandler<HTMLElement> | undefined;
140
+ onCompositionUpdateCapture?: react.CompositionEventHandler<HTMLElement> | undefined;
141
+ onFocus?: react.FocusEventHandler<HTMLElement> | undefined;
142
+ onFocusCapture?: react.FocusEventHandler<HTMLElement> | undefined;
143
+ onBlur?: react.FocusEventHandler<HTMLElement> | undefined;
144
+ onBlurCapture?: react.FocusEventHandler<HTMLElement> | undefined;
145
+ onChange?: react.FormEventHandler<HTMLElement> | undefined;
146
+ onChangeCapture?: react.FormEventHandler<HTMLElement> | undefined;
147
+ onBeforeInput?: react.FormEventHandler<HTMLElement> | undefined;
148
+ onBeforeInputCapture?: react.FormEventHandler<HTMLElement> | undefined;
149
+ onInput?: react.FormEventHandler<HTMLElement> | undefined;
150
+ onInputCapture?: react.FormEventHandler<HTMLElement> | undefined;
151
+ onReset?: react.FormEventHandler<HTMLElement> | undefined;
152
+ onResetCapture?: react.FormEventHandler<HTMLElement> | undefined;
153
+ onSubmit?: react.FormEventHandler<HTMLElement> | undefined;
154
+ onSubmitCapture?: react.FormEventHandler<HTMLElement> | undefined;
155
+ onInvalid?: react.FormEventHandler<HTMLElement> | undefined;
156
+ onInvalidCapture?: react.FormEventHandler<HTMLElement> | undefined;
157
+ onLoad?: react.ReactEventHandler<HTMLElement> | undefined;
158
+ onLoadCapture?: react.ReactEventHandler<HTMLElement> | undefined;
159
+ onError?: react.ReactEventHandler<HTMLElement> | undefined;
160
+ onErrorCapture?: react.ReactEventHandler<HTMLElement> | undefined;
161
+ onKeyDown?: react.KeyboardEventHandler<HTMLElement> | undefined;
162
+ onKeyDownCapture?: react.KeyboardEventHandler<HTMLElement> | undefined;
163
+ onKeyPress?: react.KeyboardEventHandler<HTMLElement> | undefined;
164
+ onKeyPressCapture?: react.KeyboardEventHandler<HTMLElement> | undefined;
165
+ onKeyUp?: react.KeyboardEventHandler<HTMLElement> | undefined;
166
+ onKeyUpCapture?: react.KeyboardEventHandler<HTMLElement> | undefined;
167
+ onAbort?: react.ReactEventHandler<HTMLElement> | undefined;
168
+ onAbortCapture?: react.ReactEventHandler<HTMLElement> | undefined;
169
+ onCanPlay?: react.ReactEventHandler<HTMLElement> | undefined;
170
+ onCanPlayCapture?: react.ReactEventHandler<HTMLElement> | undefined;
171
+ onCanPlayThrough?: react.ReactEventHandler<HTMLElement> | undefined;
172
+ onCanPlayThroughCapture?: react.ReactEventHandler<HTMLElement> | undefined;
173
+ onDurationChange?: react.ReactEventHandler<HTMLElement> | undefined;
174
+ onDurationChangeCapture?: react.ReactEventHandler<HTMLElement> | undefined;
175
+ onEmptied?: react.ReactEventHandler<HTMLElement> | undefined;
176
+ onEmptiedCapture?: react.ReactEventHandler<HTMLElement> | undefined;
177
+ onEncrypted?: react.ReactEventHandler<HTMLElement> | undefined;
178
+ onEncryptedCapture?: react.ReactEventHandler<HTMLElement> | undefined;
179
+ onEnded?: react.ReactEventHandler<HTMLElement> | undefined;
180
+ onEndedCapture?: react.ReactEventHandler<HTMLElement> | undefined;
181
+ onLoadedData?: react.ReactEventHandler<HTMLElement> | undefined;
182
+ onLoadedDataCapture?: react.ReactEventHandler<HTMLElement> | undefined;
183
+ onLoadedMetadata?: react.ReactEventHandler<HTMLElement> | undefined;
184
+ onLoadedMetadataCapture?: react.ReactEventHandler<HTMLElement> | undefined;
185
+ onLoadStart?: react.ReactEventHandler<HTMLElement> | undefined;
186
+ onLoadStartCapture?: react.ReactEventHandler<HTMLElement> | undefined;
187
+ onPause?: react.ReactEventHandler<HTMLElement> | undefined;
188
+ onPauseCapture?: react.ReactEventHandler<HTMLElement> | undefined;
189
+ onPlay?: react.ReactEventHandler<HTMLElement> | undefined;
190
+ onPlayCapture?: react.ReactEventHandler<HTMLElement> | undefined;
191
+ onPlaying?: react.ReactEventHandler<HTMLElement> | undefined;
192
+ onPlayingCapture?: react.ReactEventHandler<HTMLElement> | undefined;
193
+ onProgress?: react.ReactEventHandler<HTMLElement> | undefined;
194
+ onProgressCapture?: react.ReactEventHandler<HTMLElement> | undefined;
195
+ onRateChange?: react.ReactEventHandler<HTMLElement> | undefined;
196
+ onRateChangeCapture?: react.ReactEventHandler<HTMLElement> | undefined;
197
+ onResize?: react.ReactEventHandler<HTMLElement> | undefined;
198
+ onResizeCapture?: react.ReactEventHandler<HTMLElement> | undefined;
199
+ onSeeked?: react.ReactEventHandler<HTMLElement> | undefined;
200
+ onSeekedCapture?: react.ReactEventHandler<HTMLElement> | undefined;
201
+ onSeeking?: react.ReactEventHandler<HTMLElement> | undefined;
202
+ onSeekingCapture?: react.ReactEventHandler<HTMLElement> | undefined;
203
+ onStalled?: react.ReactEventHandler<HTMLElement> | undefined;
204
+ onStalledCapture?: react.ReactEventHandler<HTMLElement> | undefined;
205
+ onSuspend?: react.ReactEventHandler<HTMLElement> | undefined;
206
+ onSuspendCapture?: react.ReactEventHandler<HTMLElement> | undefined;
207
+ onTimeUpdate?: react.ReactEventHandler<HTMLElement> | undefined;
208
+ onTimeUpdateCapture?: react.ReactEventHandler<HTMLElement> | undefined;
209
+ onVolumeChange?: react.ReactEventHandler<HTMLElement> | undefined;
210
+ onVolumeChangeCapture?: react.ReactEventHandler<HTMLElement> | undefined;
211
+ onWaiting?: react.ReactEventHandler<HTMLElement> | undefined;
212
+ onWaitingCapture?: react.ReactEventHandler<HTMLElement> | undefined;
213
+ onAuxClick?: react.MouseEventHandler<HTMLElement> | undefined;
214
+ onAuxClickCapture?: react.MouseEventHandler<HTMLElement> | undefined;
215
+ onClick?: react.MouseEventHandler<HTMLElement> | undefined;
216
+ onClickCapture?: react.MouseEventHandler<HTMLElement> | undefined;
217
+ onContextMenu?: react.MouseEventHandler<HTMLElement> | undefined;
218
+ onContextMenuCapture?: react.MouseEventHandler<HTMLElement> | undefined;
219
+ onDoubleClick?: react.MouseEventHandler<HTMLElement> | undefined;
220
+ onDoubleClickCapture?: react.MouseEventHandler<HTMLElement> | undefined;
221
+ onDrag?: react.DragEventHandler<HTMLElement> | undefined;
222
+ onDragCapture?: react.DragEventHandler<HTMLElement> | undefined;
223
+ onDragEnd?: react.DragEventHandler<HTMLElement> | undefined;
224
+ onDragEndCapture?: react.DragEventHandler<HTMLElement> | undefined;
225
+ onDragEnter?: react.DragEventHandler<HTMLElement> | undefined;
226
+ onDragEnterCapture?: react.DragEventHandler<HTMLElement> | undefined;
227
+ onDragExit?: react.DragEventHandler<HTMLElement> | undefined;
228
+ onDragExitCapture?: react.DragEventHandler<HTMLElement> | undefined;
229
+ onDragLeave?: react.DragEventHandler<HTMLElement> | undefined;
230
+ onDragLeaveCapture?: react.DragEventHandler<HTMLElement> | undefined;
231
+ onDragOver?: react.DragEventHandler<HTMLElement> | undefined;
232
+ onDragOverCapture?: react.DragEventHandler<HTMLElement> | undefined;
233
+ onDragStart?: react.DragEventHandler<HTMLElement> | undefined;
234
+ onDragStartCapture?: react.DragEventHandler<HTMLElement> | undefined;
235
+ onDrop?: react.DragEventHandler<HTMLElement> | undefined;
236
+ onDropCapture?: react.DragEventHandler<HTMLElement> | undefined;
237
+ onMouseDown?: react.MouseEventHandler<HTMLElement> | undefined;
238
+ onMouseDownCapture?: react.MouseEventHandler<HTMLElement> | undefined;
239
+ onMouseEnter?: react.MouseEventHandler<HTMLElement> | undefined;
240
+ onMouseLeave?: react.MouseEventHandler<HTMLElement> | undefined;
241
+ onMouseMove?: react.MouseEventHandler<HTMLElement> | undefined;
242
+ onMouseMoveCapture?: react.MouseEventHandler<HTMLElement> | undefined;
243
+ onMouseOut?: react.MouseEventHandler<HTMLElement> | undefined;
244
+ onMouseOutCapture?: react.MouseEventHandler<HTMLElement> | undefined;
245
+ onMouseOver?: react.MouseEventHandler<HTMLElement> | undefined;
246
+ onMouseOverCapture?: react.MouseEventHandler<HTMLElement> | undefined;
247
+ onMouseUp?: react.MouseEventHandler<HTMLElement> | undefined;
248
+ onMouseUpCapture?: react.MouseEventHandler<HTMLElement> | undefined;
249
+ onSelect?: react.ReactEventHandler<HTMLElement> | undefined;
250
+ onSelectCapture?: react.ReactEventHandler<HTMLElement> | undefined;
251
+ onTouchCancel?: react.TouchEventHandler<HTMLElement> | undefined;
252
+ onTouchCancelCapture?: react.TouchEventHandler<HTMLElement> | undefined;
253
+ onTouchEnd?: react.TouchEventHandler<HTMLElement> | undefined;
254
+ onTouchEndCapture?: react.TouchEventHandler<HTMLElement> | undefined;
255
+ onTouchMove?: react.TouchEventHandler<HTMLElement> | undefined;
256
+ onTouchMoveCapture?: react.TouchEventHandler<HTMLElement> | undefined;
257
+ onTouchStart?: react.TouchEventHandler<HTMLElement> | undefined;
258
+ onTouchStartCapture?: react.TouchEventHandler<HTMLElement> | undefined;
259
+ onPointerDown?: react.PointerEventHandler<HTMLElement> | undefined;
260
+ onPointerDownCapture?: react.PointerEventHandler<HTMLElement> | undefined;
261
+ onPointerMove?: react.PointerEventHandler<HTMLElement> | undefined;
262
+ onPointerMoveCapture?: react.PointerEventHandler<HTMLElement> | undefined;
263
+ onPointerUp?: react.PointerEventHandler<HTMLElement> | undefined;
264
+ onPointerUpCapture?: react.PointerEventHandler<HTMLElement> | undefined;
265
+ onPointerCancel?: react.PointerEventHandler<HTMLElement> | undefined;
266
+ onPointerCancelCapture?: react.PointerEventHandler<HTMLElement> | undefined;
267
+ onPointerEnter?: react.PointerEventHandler<HTMLElement> | undefined;
268
+ onPointerLeave?: react.PointerEventHandler<HTMLElement> | undefined;
269
+ onPointerOver?: react.PointerEventHandler<HTMLElement> | undefined;
270
+ onPointerOverCapture?: react.PointerEventHandler<HTMLElement> | undefined;
271
+ onPointerOut?: react.PointerEventHandler<HTMLElement> | undefined;
272
+ onPointerOutCapture?: react.PointerEventHandler<HTMLElement> | undefined;
273
+ onGotPointerCapture?: react.PointerEventHandler<HTMLElement> | undefined;
274
+ onGotPointerCaptureCapture?: react.PointerEventHandler<HTMLElement> | undefined;
275
+ onLostPointerCapture?: react.PointerEventHandler<HTMLElement> | undefined;
276
+ onLostPointerCaptureCapture?: react.PointerEventHandler<HTMLElement> | undefined;
277
+ onScroll?: react.UIEventHandler<HTMLElement> | undefined;
278
+ onScrollCapture?: react.UIEventHandler<HTMLElement> | undefined;
279
+ onWheel?: react.WheelEventHandler<HTMLElement> | undefined;
280
+ onWheelCapture?: react.WheelEventHandler<HTMLElement> | undefined;
281
+ onAnimationStart?: react.AnimationEventHandler<HTMLElement> | undefined;
282
+ onAnimationStartCapture?: react.AnimationEventHandler<HTMLElement> | undefined;
283
+ onAnimationEnd?: react.AnimationEventHandler<HTMLElement> | undefined;
284
+ onAnimationEndCapture?: react.AnimationEventHandler<HTMLElement> | undefined;
285
+ onAnimationIteration?: react.AnimationEventHandler<HTMLElement> | undefined;
286
+ onAnimationIterationCapture?: react.AnimationEventHandler<HTMLElement> | undefined;
287
+ onToggle?: react.ToggleEventHandler<HTMLElement> | undefined;
288
+ onBeforeToggle?: react.ToggleEventHandler<HTMLElement> | undefined;
289
+ onTransitionCancel?: react.TransitionEventHandler<HTMLElement> | undefined;
290
+ onTransitionCancelCapture?: react.TransitionEventHandler<HTMLElement> | undefined;
291
+ onTransitionEnd?: react.TransitionEventHandler<HTMLElement> | undefined;
292
+ onTransitionEndCapture?: react.TransitionEventHandler<HTMLElement> | undefined;
293
+ onTransitionRun?: react.TransitionEventHandler<HTMLElement> | undefined;
294
+ onTransitionRunCapture?: react.TransitionEventHandler<HTMLElement> | undefined;
295
+ onTransitionStart?: react.TransitionEventHandler<HTMLElement> | undefined;
296
+ onTransitionStartCapture?: react.TransitionEventHandler<HTMLElement> | undefined;
16
297
  };
17
- getRootProps: () => {
298
+ getRootProps: (rootProps?: DragScrollProps<TElement>["extraRootProps"]) => InferProps<TElement> & {
18
299
  className: string;
19
300
  "data-part": string;
20
301
  "data-scope": string;
@@ -1,6 +1,8 @@
1
1
  import { cnMerge } from '../../chunk-OHG7GB7O.js';
2
+ import '../../chunk-PZ5AY32C.js';
2
3
  import { off, on, checkIsDeviceMobileOrTablet } from '@zayne-labs/toolkit-core';
3
4
  import { useCallbackRef } from '@zayne-labs/toolkit-react';
5
+ import { mergeProps, composeRefs } from '@zayne-labs/toolkit-react/utils';
4
6
  import { useRef } from 'react';
5
7
 
6
8
  var updateCursor = (element) => {
@@ -27,9 +29,15 @@ var handleScrollSnap = (dragContainer) => {
27
29
  }
28
30
  };
29
31
 
30
- // src/components/ui/drag-scroll/useDragScroll.ts
32
+ // src/components/ui/drag-scroll/use-drag-scroll.ts
31
33
  var useDragScroll = (props = {}) => {
32
- const { classNames, orientation = "horizontal", usage = "allScreens" } = props;
34
+ const {
35
+ classNames,
36
+ extraItemProps,
37
+ extraRootProps,
38
+ orientation = "horizontal",
39
+ usage = "allScreens"
40
+ } = props;
33
41
  const dragContainerRef = useRef(null);
34
42
  const positionRef = useRef({ left: 0, top: 0, x: 0, y: 0 });
35
43
  const handleMouseMove = useCallbackRef((event) => {
@@ -77,25 +85,37 @@ var useDragScroll = (props = {}) => {
77
85
  }
78
86
  return cleanup;
79
87
  });
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
- });
88
+ const getRootProps = (rootProps) => {
89
+ const mergedRootProps = mergeProps(extraRootProps, rootProps);
90
+ return {
91
+ ...mergedRootProps,
92
+ className: cnMerge(
93
+ `flex w-full cursor-grab snap-x snap-mandatory overflow-y-clip overflow-x-scroll
94
+ [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,
95
+ orientation === "horizontal" && "flex-row",
96
+ orientation === "vertical" && "flex-col",
97
+ usage === "mobileAndTabletOnly" && "md:cursor-default md:flex-col",
98
+ usage === "desktopOnly" && "max-md:cursor-default max-md:flex-col",
99
+ classNames?.base,
100
+ mergedRootProps.className
101
+ ),
102
+ "data-part": "root",
103
+ "data-scope": "drag-scroll",
104
+ ref: composeRefs([
105
+ refCallBack,
106
+ mergedRootProps?.ref
107
+ ])
108
+ };
109
+ };
110
+ const getItemProps = (itemProps) => {
111
+ const mergedItemProps = mergeProps(extraItemProps, itemProps);
112
+ return {
113
+ ...mergedItemProps,
114
+ className: cnMerge("snap-center snap-always", classNames?.item, mergedItemProps.className),
115
+ "data-part": "item",
116
+ "data-scope": "drag-scroll"
117
+ };
118
+ };
99
119
  return { getItemProps, getRootProps };
100
120
  };
101
121
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/ui/drag-scroll/utils.ts","../../../../src/components/ui/drag-sc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B,IAAA,UAAA;AAAA,MAChC,gBAAgB,UAAc,IAAA,UAAA;AAAA,MAC9B,UAAU,qBAAyB,IAAA,+BAAA;AAAA,MACnC,UAAU,aAAiB,IAAA,uCAAA;AAAA,MAC3B,UAAY,EAAA;AAAA,KACb;AAAA,IACA,WAAa,EAAA,MAAA;AAAA,IACb,YAAc,EAAA,aAAA;AAAA,IACd,GAAK,EAAA;AAAA,GACN,CAAA;AAEA,EAAA,MAAM,eAAe,OAAO;AAAA,IAC3B,SAAW,EAAA,OAAA,CAAQ,yBAA2B,EAAA,UAAA,EAAY,IAAI,CAAA;AAAA,IAC9D,WAAa,EAAA,MAAA;AAAA,IACb,YAAc,EAAA;AAAA,GACf,CAAA;AAEA,EAAO,OAAA,EAAE,cAAc,YAAa,EAAA;AACrC","file":"index.js","sourcesContent":["import { checkIsDeviceMobileOrTablet } 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 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"]}
1
+ {"version":3,"sources":["../../../../src/components/ui/drag-scroll/utils.ts","../../../../src/components/ui/drag-scroll/use-drag-scroll.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,MAAM,UAAa,GAAA,EAAA;AAC5B,CAAA;AAGO,IAAM,gBAAA,GAAmB,CAAC,aAA+B,KAAA;AAC/D,EAAA,MAAM,mBAAmB,2BAA4B,EAAA;AAErD,EAAA,IAAI,CAAC,gBAAkB,EAAA;AACtB,IAAA,YAAA,CAAa,UAAU,aAAa,CAAA;AAAA,GAC9B,MAAA;AACN,IAAA,YAAA,CAAa,SAAS,aAAa,CAAA;AAAA;AAErC,CAAA;;;ACnBA,IAAM,aAAgB,GAAA,CAA+B,KAAmC,GAAA,EAAO,KAAA;AAC9F,EAAM,MAAA;AAAA,IACL,UAAA;AAAA,IACA,cAAA;AAAA,IACA,cAAA;AAA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Tablet } 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 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 InferProps, composeRefs, mergeProps } from \"@zayne-labs/toolkit-react/utils\";\nimport { type RefCallback, useRef } from \"react\";\nimport { handleScrollSnap, resetCursor, updateCursor } from \"./utils\";\n\ntype DragScrollProps<TElement extends HTMLElement> = {\n\tclassNames?: { base?: string; item?: string };\n\textraItemProps?: InferProps<HTMLElement>;\n\textraRootProps?: InferProps<TElement>;\n\torientation?: \"both\" | \"horizontal\" | \"vertical\";\n\tusage?: \"allScreens\" | \"desktopOnly\" | \"mobileAndTabletOnly\";\n};\n\nconst useDragScroll = <TElement extends HTMLElement>(props: DragScrollProps<TElement> = {}) => {\n\tconst {\n\t\tclassNames,\n\t\textraItemProps,\n\t\textraRootProps,\n\t\torientation = \"horizontal\",\n\t\tusage = \"allScreens\",\n\t} = 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 = (rootProps?: DragScrollProps<TElement>[\"extraRootProps\"]) => {\n\t\tconst mergedRootProps = mergeProps(extraRootProps, rootProps);\n\n\t\treturn {\n\t\t\t...mergedRootProps,\n\t\t\tclassName: cnMerge(\n\t\t\t\t`flex w-full cursor-grab snap-x snap-mandatory overflow-y-clip overflow-x-scroll\n\t\t\t\t[-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,\n\t\t\t\torientation === \"horizontal\" && \"flex-row\",\n\t\t\t\torientation === \"vertical\" && \"flex-col\",\n\t\t\t\tusage === \"mobileAndTabletOnly\" && \"md:cursor-default md:flex-col\",\n\t\t\t\tusage === \"desktopOnly\" && \"max-md:cursor-default max-md:flex-col\",\n\t\t\t\tclassNames?.base,\n\t\t\t\tmergedRootProps.className\n\t\t\t),\n\t\t\t\"data-part\": \"root\",\n\t\t\t\"data-scope\": \"drag-scroll\",\n\t\t\tref: composeRefs([\n\t\t\t\trefCallBack,\n\t\t\t\t(mergedRootProps as { ref?: React.Ref<TElement> } | undefined)?.ref,\n\t\t\t]),\n\t\t};\n\t};\n\n\tconst getItemProps = (itemProps?: DragScrollProps<TElement>[\"extraItemProps\"]) => {\n\t\tconst mergedItemProps = mergeProps(extraItemProps, itemProps);\n\n\t\treturn {\n\t\t\t...mergedItemProps,\n\t\t\tclassName: cnMerge(\"snap-center snap-always\", classNames?.item, mergedItemProps.className),\n\t\t\t\"data-part\": \"item\",\n\t\t\t\"data-scope\": \"drag-scroll\",\n\t\t};\n\t};\n\n\treturn { getItemProps, getRootProps };\n};\n\nexport { useDragScroll };\n"]}
@@ -1,5 +1,4 @@
1
1
  import * as react from 'react';
2
- import { RefCallback } from 'react';
3
2
  import { FileValidationOptions } from '@zayne-labs/toolkit-core';
4
3
  import { InferProps } from '@zayne-labs/toolkit-react/utils';
5
4
 
@@ -8,6 +7,13 @@ type RenderProps = {
8
7
  inputRef: React.RefObject<HTMLInputElement | null>;
9
8
  isDragging: boolean;
10
9
  };
10
+ type RootProps = InferProps<"div"> & {
11
+ classNames?: {
12
+ activeDrag?: string;
13
+ base?: string;
14
+ };
15
+ };
16
+ type InputProps = InferProps<"input">;
11
17
  type UseDropZoneProps = {
12
18
  allowedFileTypes?: string[];
13
19
  children?: React.ReactNode | ((props: RenderProps) => React.ReactNode);
@@ -18,15 +24,14 @@ type UseDropZoneProps = {
18
24
  };
19
25
  disableInbuiltValidation?: boolean;
20
26
  existingFiles?: File[];
21
- extraInputProps?: Omit<InferProps<"input">, "ref">;
22
- extraRootProps?: InferProps<"div">;
27
+ extraInputProps?: InputProps;
28
+ extraRootProps?: RootProps;
23
29
  onUpload?: (details: {
24
30
  acceptedFiles: File[];
25
31
  event: React.ChangeEvent<HTMLInputElement> | React.DragEvent<HTMLDivElement>;
26
32
  }) => void;
27
33
  onUploadError?: FileValidationOptions["onError"];
28
34
  onUploadSuccess?: FileValidationOptions["onSuccess"];
29
- ref?: React.Ref<HTMLInputElement>;
30
35
  validationSettings?: {
31
36
  disallowDuplicates?: boolean;
32
37
  fileLimit?: number;
@@ -39,25 +44,22 @@ type UseDropZoneProps = {
39
44
  };
40
45
  declare const useDropZone: (props: UseDropZoneProps) => {
41
46
  getChildren: () => react.ReactNode;
42
- getInputProps: () => {
47
+ getInputProps: (inputProps?: InputProps) => {
43
48
  accept: string | undefined;
44
49
  className: string;
50
+ "data-active-drag": boolean;
45
51
  "data-part": string;
46
52
  "data-scope": string;
47
53
  onChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
48
- ref: RefCallback<HTMLInputElement>;
54
+ ref: react.RefCallback<HTMLInputElement>;
49
55
  type: string;
50
- form?: string | undefined;
51
- slot?: string | undefined;
52
- style?: react.CSSProperties | undefined;
53
- title?: string | undefined;
54
- pattern?: string | undefined;
55
56
  key?: react.Key | null | undefined;
56
57
  alt?: string | undefined;
57
58
  autoComplete?: react.HTMLInputAutoCompleteAttribute | undefined;
58
59
  capture?: boolean | "user" | "environment" | undefined;
59
60
  checked?: boolean | undefined;
60
61
  disabled?: boolean | undefined;
62
+ form?: string | undefined;
61
63
  formAction?: string | ((formData: FormData) => void | Promise<void>) | react.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS[keyof react.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS] | undefined;
62
64
  formEncType?: string | undefined;
63
65
  formMethod?: string | undefined;
@@ -71,6 +73,7 @@ declare const useDropZone: (props: UseDropZoneProps) => {
71
73
  minLength?: number | undefined;
72
74
  multiple?: boolean | undefined;
73
75
  name?: string | undefined;
76
+ pattern?: string | undefined;
74
77
  placeholder?: string | undefined;
75
78
  readOnly?: boolean | undefined;
76
79
  required?: boolean | undefined;
@@ -95,8 +98,11 @@ declare const useDropZone: (props: UseDropZoneProps) => {
95
98
  id?: string | undefined;
96
99
  lang?: string | undefined;
97
100
  nonce?: string | undefined;
101
+ slot?: string | undefined;
98
102
  spellCheck?: (boolean | "true" | "false") | undefined;
103
+ style?: react.CSSProperties | undefined;
99
104
  tabIndex?: number | undefined;
105
+ title?: string | undefined;
100
106
  translate?: "yes" | "no" | undefined;
101
107
  radioGroup?: string | undefined;
102
108
  role?: react.AriaRole | undefined;
@@ -358,7 +364,7 @@ declare const useDropZone: (props: UseDropZoneProps) => {
358
364
  inputRef: react.RefObject<HTMLInputElement | null>;
359
365
  isDragging: boolean;
360
366
  };
361
- getRootProps: () => {
367
+ getRootProps: (rootProps?: RootProps) => {
362
368
  className: string;
363
369
  "data-active-drag": boolean;
364
370
  "data-part": string;
@@ -642,14 +648,18 @@ declare const useDropZone: (props: UseDropZoneProps) => {
642
648
  onTransitionRunCapture?: react.TransitionEventHandler<HTMLDivElement> | undefined;
643
649
  onTransitionStart?: react.TransitionEventHandler<HTMLDivElement> | undefined;
644
650
  onTransitionStartCapture?: react.TransitionEventHandler<HTMLDivElement> | undefined;
651
+ classNames?: {
652
+ activeDrag?: string;
653
+ base?: string;
654
+ };
645
655
  };
646
656
  handleDragLeave: (event: React.DragEvent<HTMLDivElement>) => void;
647
657
  handleDragOver: (event: React.DragEvent<HTMLDivElement>) => void;
648
658
  handleFileUpload: (event: React.ChangeEvent<HTMLInputElement> | React.DragEvent<HTMLDivElement>) => void;
659
+ inputRef: react.RefObject<HTMLInputElement | null>;
649
660
  isDragging: boolean;
650
- ref: react.Ref<HTMLInputElement> | undefined;
651
661
  };
652
662
 
653
663
  declare function DropZone(props: UseDropZoneProps): react.JSX.Element;
654
664
 
655
- export { DropZone, type UseDropZoneProps, useDropZone };
665
+ export { DropZone, type InputProps, type RootProps, type UseDropZoneProps, useDropZone };