morphing-scroll 1.5.21 → 2.0.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.
@@ -0,0 +1,435 @@
1
+ type MorphScrollT = {
2
+ // General Settings
3
+ /**---
4
+ * Custom class name.
5
+ * ___
6
+ * @example
7
+ * ```tsx
8
+ * <MorphScroll {...props}
9
+ * className="custom-class"
10
+ * >
11
+ * {children}
12
+ * </MorphScroll>
13
+ * ```
14
+ * */
15
+ className?: string;
16
+ /**---
17
+ * Custom user content.
18
+ * ___
19
+ * @example
20
+ * ```tsx
21
+ * <MorphScroll {...props} >
22
+ * {children}
23
+ * </MorphScroll>
24
+ * ```
25
+ * */
26
+ children?: React.ReactNode;
27
+
28
+ // Scroll Settings
29
+ /**---
30
+ * Type of progress element.
31
+ * ___
32
+ * @default "scroll"
33
+ *
34
+ * @example
35
+ * ```tsx
36
+ * <MorphScroll {...props}
37
+ * type="slider"
38
+ * >
39
+ * {children}
40
+ * </MorphScroll>
41
+ * ```
42
+ */
43
+ type?: "scroll" | "slider" | "sliderMenu";
44
+ /**---
45
+ * Scrolling direction.
46
+ * ___
47
+ * @default "y"
48
+ *
49
+ * @example
50
+ * ```tsx
51
+ * <MorphScroll {...props}
52
+ * direction="x"
53
+ * >
54
+ * {children}
55
+ * </MorphScroll>
56
+ * ```
57
+ */
58
+ direction?: "x" | "y" | "hybrid";
59
+ /**---
60
+ * Scroll position value and additional options.
61
+ * ___
62
+ * @default { duration: 200; updater: false }
63
+ *
64
+ * @description
65
+ * - `value`: *Scroll position value*
66
+ * - `duration`: *Duration of the scroll animation*
67
+ * - `updater`: *Helper to force an update when setting the same scroll value repeatedly*
68
+ *
69
+ * @note
70
+ * `value` property can be an array of two values for hybrid directions
71
+ *
72
+ * @example
73
+ * ```tsx
74
+ * <MorphScroll {...props}
75
+ * scrollPosition={{ value: 100, duration: 300 }}
76
+ * >
77
+ * {children}
78
+ * </MorphScroll>
79
+ * ```
80
+ */
81
+ scrollPosition?: {
82
+ value: number | "end" | (number | "end")[];
83
+ duration?: number;
84
+ updater?: boolean;
85
+ };
86
+ /**---
87
+ * Callback for scroll value.
88
+ * ___
89
+ * @description
90
+ * - `left`: *Current scroll position on the x-axis*
91
+ * - `top`: *Current scroll position on the y-axis*
92
+ *
93
+ * @example
94
+ * ```tsx
95
+ * <MorphScroll {...props}
96
+ * onScrollValue={(left, top) => console.log("Scroll position:", left, top)}
97
+ * >
98
+ * {children}
99
+ * </MorphScroll>
100
+ * ```
101
+ */
102
+ onScrollValue?: (left: number, top: number) => void;
103
+ /**---
104
+ * Callback for scroll status.
105
+ * ___
106
+ * @example
107
+ * ```tsx
108
+ * <MorphScroll {...props}
109
+ * isScrolling={(motion) => console.log(motion)}
110
+ * >
111
+ * {children}
112
+ * </MorphScroll>
113
+ * ```
114
+ */
115
+ isScrolling?: (motion: boolean) => void;
116
+
117
+ // Visual Settings
118
+ /**---
119
+ * `[width, height]` dimension of `MorphScroll`.
120
+ *
121
+ * **REQUIRED**
122
+ * ___
123
+ * @description
124
+ * - `number` *sets the width and height, can be an array of 2 numbers*
125
+ * - `"auto"` *for automatic resizing based on the parent element*
126
+ *
127
+ * @example
128
+ * ```tsx
129
+ * <MorphScroll {...props}
130
+ * size={[200, 100]}
131
+ * >
132
+ * {children}
133
+ * </MorphScroll>
134
+ * ```
135
+ */
136
+ size: number | number[] | "auto";
137
+ /**---
138
+ * [width, height] dimension of cells for each object.
139
+ * ___
140
+ * @default [width, height] from size
141
+ *
142
+ * @description
143
+ * - `number` *sets the width and height, can be an array of 2 numbers*
144
+ * - `"none"` *objects will be created without defined size*
145
+ * - `"firstChild"` *all objects will have the same size as the first child*
146
+ *
147
+ * @example
148
+ * ```tsx
149
+ * <MorphScroll {...props}
150
+ * objectsSize={[80, 80]}
151
+ * >
152
+ * {children}
153
+ * </MorphScroll>
154
+ * ```
155
+ */
156
+ objectsSize:
157
+ | number
158
+ | "none"
159
+ | "firstChild"
160
+ | (number | "none" | "firstChild")[];
161
+ /**---
162
+ * Number of cells in each direction.
163
+ *___
164
+ * @example
165
+ * ```tsx
166
+ * <MorphScroll {...props}
167
+ * crossCount={3}
168
+ * >
169
+ * {children}
170
+ * </MorphScroll>
171
+ * ```
172
+ */
173
+ crossCount?: number;
174
+ /**---
175
+ * Gap between cells.
176
+ * ___
177
+ * @note
178
+ * *It can be 1 number or an array of 2 or 4 numbers*
179
+ *
180
+ * @example
181
+ * ```tsx
182
+ * <MorphScroll {...props}
183
+ * gap={10}
184
+ * >
185
+ * {children}
186
+ * </MorphScroll>
187
+ * ```
188
+ */
189
+ gap?: number | number[];
190
+ /**---
191
+ * Margin for the* `.ms-objects-wrapper`.
192
+ * ___
193
+ * @note
194
+ * *It can be 1 number or an array of 2 or 4 numbers*
195
+ *
196
+ * @example
197
+ * ```tsx
198
+ * <MorphScroll {...props}
199
+ * wrapperMargin={10}
200
+ * >
201
+ * {children}
202
+ * </MorphScroll>
203
+ * ```
204
+ */
205
+ wrapperMargin?: number | number[];
206
+ /**---
207
+ * Minimum height or width of the `.ms-objects-wrapper`.
208
+ * ___
209
+ * @description
210
+ * - `number` *sets the min-size*
211
+ * - `"full"` *min-size is equal to property `size`*
212
+ *
213
+ * @note
214
+ * - *Can be used as 1 value, or an array of 2 values for [width, height].*
215
+ *
216
+ * @example
217
+ * ```tsx
218
+ * <MorphScroll {...props}
219
+ * wrapperMinSize={"full"}
220
+ * >
221
+ * {children}
222
+ * </MorphScroll>
223
+ * ```
224
+ */
225
+ wrapperMinSize?: number | "full" | (number | "full")[];
226
+ /**---
227
+ * [horizontal, vertical] aligns your content when it is smaller than the `size`.
228
+ *___
229
+ * @note
230
+ * *Use 1 value to align one or both axes, or an array of 2 values to align both axes*
231
+ *
232
+ * @example
233
+ * ```tsx
234
+ * <MorphScroll {...props}
235
+ * wrapperAlign={["start", "center"]}
236
+ * >
237
+ * {children}
238
+ * </MorphScroll>
239
+ * ```
240
+ */
241
+ wrapperAlign?: "start" | "center" | "end" | ("start" | "center" | "end")[];
242
+ /**---
243
+ * Aligns the objects inside `MorphScroll`.
244
+ * ___
245
+ * @example
246
+ * ```tsx
247
+ * <MorphScroll {...props}
248
+ * elementsAlign={"center"}
249
+ * >
250
+ * {children}
251
+ * </MorphScroll>
252
+ * ```
253
+ */
254
+ elementsAlign?: "start" | "center" | "end";
255
+ /**---
256
+ * Direction of the provided elements.
257
+ * ___
258
+ * @default "row"
259
+ *
260
+ * @example
261
+ * ```tsx
262
+ * <MorphScroll {...props}
263
+ * elementsDirection={"column"}
264
+ * >
265
+ * {children}
266
+ * </MorphScroll>
267
+ * ```
268
+ */
269
+ elementsDirection?: "row" | "column";
270
+ /**---
271
+ * Gradient overlay at the edges of the scroll area.
272
+ * ___
273
+ * @default { size: 40 }
274
+ *
275
+ * @example
276
+ * ```tsx
277
+ * <MorphScroll {...props}
278
+ * edgeGradient={{ color: "rgba(0,0,0,0.4)"}}
279
+ * >
280
+ * {children}
281
+ * </MorphScroll>
282
+ * ```
283
+ */
284
+ edgeGradient?: boolean | { color?: string; size?: number };
285
+
286
+ // Progress Bar
287
+ /**---
288
+ * Triggers for the scroll progress.
289
+ * ___
290
+ * @description
291
+ * - `wheel`: *Triggered by mouse wheel scroll*
292
+ * - `content`: *Triggered by content click and drag*
293
+ * - `progressElement`: *Triggered by provided progress element*
294
+ * - `arrows`: *Triggered by arrow button click*
295
+ *
296
+ * @note
297
+ * - *`progressElement` can be thumb or slider, use props `type`*
298
+ * - *If `progressElement` is true and `type` is "scroll", the default browser scroll element will be used*
299
+ * - *`arrows` can be designed with their className or you can provide a custom element*
300
+ *
301
+ * @example
302
+ * ```tsx
303
+ * <MorphScroll {...props}
304
+ * progressTrigger={ wheel: true, progressElement: <ScrollThumb /> }
305
+ * >
306
+ * {children}
307
+ * </MorphScroll>
308
+ * ```
309
+ */
310
+ progressTrigger: {
311
+ wheel?: boolean;
312
+ content?: boolean;
313
+ progressElement?: boolean | React.ReactNode;
314
+ arrows?: boolean | { size?: number; element?: React.ReactNode };
315
+ };
316
+ /**---
317
+ * Reverse the progress bar position.
318
+ * ___
319
+ * @default false
320
+ *
321
+ * @note
322
+ * *Use 1 boolean or an array of 2 booleans to set different values for hybrid `direction`*
323
+ *
324
+ * @example
325
+ * ```tsx
326
+ * <MorphScroll {...props}
327
+ * progressReverse={true}
328
+ * >
329
+ * {children}
330
+ * </MorphScroll>
331
+ * ```
332
+ */
333
+ progressReverse?: boolean | boolean[];
334
+ /**---
335
+ * Hover visibility of the progress bar.
336
+ * ___
337
+ * @default false
338
+ *
339
+ * @example
340
+ * ```tsx
341
+ * <MorphScroll {...props}
342
+ * progressVisibility={"hover"}
343
+ * >
344
+ * {children}
345
+ * </MorphScroll>
346
+ * ```
347
+ */
348
+ scrollBarOnHover?: boolean;
349
+
350
+ // Optimization
351
+ /**---
352
+ * Rendering strategy for performance optimization.
353
+ * ___
354
+ * @description
355
+ * - `"lazy"`: *Does not deleted content when it leaves the viewport*
356
+ * - `"virtual"`: *Deletes content when it leaves the viewport*
357
+ * - `rootMargin`: *Distance for loading from the root element*
358
+ * - `stopLoadOnScroll`: *Stops loading content when scrolling*
359
+ *
360
+ * @note
361
+ * *`render` is not compatible with `objectsSize: "none"`*
362
+ *
363
+ * @example
364
+ * ```tsx
365
+ * <MorphScroll {...props}
366
+ * render={{ type: "virtual" }}
367
+ * >
368
+ * {children}
369
+ * </MorphScroll>
370
+ * ```
371
+ */
372
+ render?: {
373
+ type: "lazy" | "virtual";
374
+ rootMargin?: number | number[];
375
+ stopLoadOnScroll?: boolean;
376
+ };
377
+ /**---
378
+ * Handling of empty scroll elements.
379
+ * ___
380
+ * @description
381
+ * - `"clear"`: *Removes empty elements from the DOM*
382
+ * - `fallback`: *Replaces empty elements with a fallback element*
383
+ * - `clickTrigger`: *Start clearing elements when passed selector is clicked*
384
+ *
385
+ * @example
386
+ * ```tsx
387
+ * <MorphScroll {...props}
388
+ * emptyElements={{
389
+ * mode: "clear",
390
+ * clickTrigger: { selector: ".close-button" }
391
+ * }}
392
+ * >
393
+ * {children}
394
+ * </MorphScroll>
395
+ * ```
396
+ */
397
+ emptyElements?: {
398
+ mode: "clear" | "fallback" | { fallback: React.ReactNode };
399
+ clickTrigger?: { selector: string; delay?: number };
400
+ };
401
+ /**---
402
+ * Enables React Suspense for children.
403
+ * ___
404
+ * @example
405
+ * ```tsx
406
+ * <MorphScroll {...props}
407
+ * suspending
408
+ * >
409
+ * {children}
410
+ * </MorphScroll>
411
+ * ```
412
+ */
413
+ suspending?: boolean;
414
+ /**---
415
+ * Fallback element to display during loading or placeholder.
416
+ * ___
417
+ * @note
418
+ * *Used when:*
419
+ * - *`suspending === true`*
420
+ * - *`render.stopLoadOnScroll === true`*
421
+ * - *`emptyElements.mode === "fallback"`*
422
+ *
423
+ * @example
424
+ * ```tsx
425
+ * <MorphScroll {...props}
426
+ * fallback={<div>Loading...</div>}
427
+ * >
428
+ * {children}
429
+ * </MorphScroll>
430
+ * ```
431
+ */
432
+ fallback?: React.ReactNode;
433
+ };
434
+
435
+ export default MorphScrollT;
@@ -0,0 +1,77 @@
1
+ type ResizeTrackerT = {
2
+ /**---
3
+ * Custom class name.
4
+ * ___
5
+ * @example
6
+ * ```tsx
7
+ * <ResizeTracker
8
+ * className="custom-class"
9
+ * >
10
+ * {children}
11
+ * </ResizeTracker>
12
+ * ```
13
+ */
14
+ className?: string;
15
+ /**---
16
+ * Custom user content.
17
+ * ___
18
+ * @example
19
+ * ```tsx
20
+ * <ResizeTracker>
21
+ * {children}
22
+ * </ResizeTracker>
23
+ * ```
24
+ * */
25
+ children: React.ReactNode;
26
+ /**---
27
+ * Custom inline styles.
28
+ * ___
29
+ * @example
30
+ * ```tsx
31
+ * <ResizeTracker
32
+ * style={{ backgroundColor: "yellow" }}
33
+ * >
34
+ * {children}
35
+ * </ResizeTracker>
36
+ * ```
37
+ */
38
+ style?: React.CSSProperties;
39
+ /**---
40
+ * Defines size measurement behavior.
41
+ * ___
42
+ * @description
43
+ * - `inner`: *Fits content*
44
+ * - `outer`: *Fills parent*
45
+ * - `all`: *Combines both*
46
+ *
47
+ * @default "inner"
48
+ *
49
+ * @example
50
+ * ```tsx
51
+ * <ResizeTracker
52
+ * measure="outer"
53
+ * >
54
+ * {children}
55
+ * </ResizeTracker>
56
+ * ```
57
+ */
58
+ measure?: "inner" | "outer" | "all";
59
+ /**---
60
+ * Callback on dimension change.
61
+ * ___
62
+ * @description
63
+ * *`rect` is the dimensions of the container*
64
+ *
65
+ * @example
66
+ * ```tsx
67
+ * <ResizeTracker
68
+ * onResize={(rect) => console.log(rect)}
69
+ * >
70
+ * {children}
71
+ * </ResizeTracker>
72
+ * ```
73
+ */
74
+ onResize?: (rect: Partial<DOMRectReadOnly>) => void;
75
+ };
76
+
77
+ export default ResizeTrackerT;